diff --git a/#Test/BlitzBasicLauncher.pdb b/#Test/BlitzBasicLauncher.pdb new file mode 100644 index 0000000..b42a95e Binary files /dev/null and b/#Test/BlitzBasicLauncher.pdb differ diff --git a/_release/samples/zenith/scare/models/pistol/Sav7115.TMP b/#Test/BlitzNextTest.txt similarity index 100% rename from _release/samples/zenith/scare/models/pistol/Sav7115.TMP rename to #Test/BlitzNextTest.txt diff --git a/_release/Games/TunnelRun/Highs/Highs.Hsr b/#Test/Games/TunnelRun/Highs/Highs.Hsr similarity index 100% rename from _release/Games/TunnelRun/Highs/Highs.Hsr rename to #Test/Games/TunnelRun/Highs/Highs.Hsr diff --git a/_release/Games/TunnelRun/Media/BMod.3DS b/#Test/Games/TunnelRun/Media/BMod.3DS similarity index 100% rename from _release/Games/TunnelRun/Media/BMod.3DS rename to #Test/Games/TunnelRun/Media/BMod.3DS diff --git a/_release/Games/TunnelRun/Media/asteroid.3ds b/#Test/Games/TunnelRun/Media/asteroid.3ds similarity index 100% rename from _release/Games/TunnelRun/Media/asteroid.3ds rename to #Test/Games/TunnelRun/Media/asteroid.3ds diff --git a/_release/Games/TunnelRun/Media/blockade.3DS b/#Test/Games/TunnelRun/Media/blockade.3DS similarity index 100% rename from _release/Games/TunnelRun/Media/blockade.3DS rename to #Test/Games/TunnelRun/Media/blockade.3DS diff --git a/_release/Games/TunnelRun/Media/boom.wav b/#Test/Games/TunnelRun/Media/boom.wav similarity index 100% rename from _release/Games/TunnelRun/Media/boom.wav rename to #Test/Games/TunnelRun/Media/boom.wav diff --git a/_release/Games/TunnelRun/Media/claw.3DS b/#Test/Games/TunnelRun/Media/claw.3DS similarity index 100% rename from _release/Games/TunnelRun/Media/claw.3DS rename to #Test/Games/TunnelRun/Media/claw.3DS diff --git a/_release/Games/TunnelRun/Media/energybar.bmp b/#Test/Games/TunnelRun/Media/energybar.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/energybar.bmp rename to #Test/Games/TunnelRun/Media/energybar.bmp diff --git a/_release/Games/TunnelRun/Media/floor1.bmp b/#Test/Games/TunnelRun/Media/floor1.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/floor1.bmp rename to #Test/Games/TunnelRun/Media/floor1.bmp diff --git a/_release/Games/TunnelRun/Media/go.bmp b/#Test/Games/TunnelRun/Media/go.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/go.bmp rename to #Test/Games/TunnelRun/Media/go.bmp diff --git a/_release/Games/TunnelRun/Media/hfighter.3ds b/#Test/Games/TunnelRun/Media/hfighter.3ds similarity index 100% rename from _release/Games/TunnelRun/Media/hfighter.3ds rename to #Test/Games/TunnelRun/Media/hfighter.3ds diff --git a/_release/Games/TunnelRun/Media/lives.bmp b/#Test/Games/TunnelRun/Media/lives.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/lives.bmp rename to #Test/Games/TunnelRun/Media/lives.bmp diff --git a/_release/Games/TunnelRun/Media/missile1.3ds b/#Test/Games/TunnelRun/Media/missile1.3ds similarity index 100% rename from _release/Games/TunnelRun/Media/missile1.3ds rename to #Test/Games/TunnelRun/Media/missile1.3ds diff --git a/_release/Games/TunnelRun/Media/mouse.bmp b/#Test/Games/TunnelRun/Media/mouse.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/mouse.bmp rename to #Test/Games/TunnelRun/Media/mouse.bmp diff --git a/_release/Games/TunnelRun/Media/shoot.wav b/#Test/Games/TunnelRun/Media/shoot.wav similarity index 100% rename from _release/Games/TunnelRun/Media/shoot.wav rename to #Test/Games/TunnelRun/Media/shoot.wav diff --git a/_release/Games/TunnelRun/Media/shot1.bmp b/#Test/Games/TunnelRun/Media/shot1.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/shot1.bmp rename to #Test/Games/TunnelRun/Media/shot1.bmp diff --git a/_release/Games/TunnelRun/Media/smoke1.bmp b/#Test/Games/TunnelRun/Media/smoke1.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/smoke1.bmp rename to #Test/Games/TunnelRun/Media/smoke1.bmp diff --git a/_release/Games/TunnelRun/Media/smoke2.bmp b/#Test/Games/TunnelRun/Media/smoke2.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/smoke2.bmp rename to #Test/Games/TunnelRun/Media/smoke2.bmp diff --git a/_release/Games/TunnelRun/Media/smoke3.bmp b/#Test/Games/TunnelRun/Media/smoke3.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/smoke3.bmp rename to #Test/Games/TunnelRun/Media/smoke3.bmp diff --git a/_release/Games/TunnelRun/Media/smoke4.bmp b/#Test/Games/TunnelRun/Media/smoke4.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/smoke4.bmp rename to #Test/Games/TunnelRun/Media/smoke4.bmp diff --git a/_release/Games/TunnelRun/Media/stone04.bmp b/#Test/Games/TunnelRun/Media/stone04.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/stone04.bmp rename to #Test/Games/TunnelRun/Media/stone04.bmp diff --git a/_release/Games/TunnelRun/Media/target.bmp b/#Test/Games/TunnelRun/Media/target.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/target.bmp rename to #Test/Games/TunnelRun/Media/target.bmp diff --git a/_release/Games/TunnelRun/Media/tex0.bmp b/#Test/Games/TunnelRun/Media/tex0.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/tex0.bmp rename to #Test/Games/TunnelRun/Media/tex0.bmp diff --git a/_release/Games/TunnelRun/Media/tex1.bmp b/#Test/Games/TunnelRun/Media/tex1.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/tex1.bmp rename to #Test/Games/TunnelRun/Media/tex1.bmp diff --git a/_release/Games/TunnelRun/Media/tex2.bmp b/#Test/Games/TunnelRun/Media/tex2.bmp similarity index 100% rename from _release/Games/TunnelRun/Media/tex2.bmp rename to #Test/Games/TunnelRun/Media/tex2.bmp diff --git a/_release/Games/TunnelRun/Media/title.BMP b/#Test/Games/TunnelRun/Media/title.BMP similarity index 100% rename from _release/Games/TunnelRun/Media/title.BMP rename to #Test/Games/TunnelRun/Media/title.BMP diff --git a/_release/Games/TunnelRun/functions.bb b/#Test/Games/TunnelRun/functions.bb similarity index 100% rename from _release/Games/TunnelRun/functions.bb rename to #Test/Games/TunnelRun/functions.bb diff --git a/_release/Games/TunnelRun/globs.bb b/#Test/Games/TunnelRun/globs.bb similarity index 100% rename from _release/Games/TunnelRun/globs.bb rename to #Test/Games/TunnelRun/globs.bb diff --git a/_release/Games/TunnelRun/tr.bb b/#Test/Games/TunnelRun/tr.bb similarity index 100% rename from _release/Games/TunnelRun/tr.bb rename to #Test/Games/TunnelRun/tr.bb diff --git a/_release/Games/bb3d_asteroids/EdzUpAsteroids.bb b/#Test/Games/bb3d_asteroids/EdzUpAsteroids.bb similarity index 100% rename from _release/Games/bb3d_asteroids/EdzUpAsteroids.bb rename to #Test/Games/bb3d_asteroids/EdzUpAsteroids.bb diff --git a/_release/Games/bb3d_asteroids/Title.png b/#Test/Games/bb3d_asteroids/Title.png similarity index 100% rename from _release/Games/bb3d_asteroids/Title.png rename to #Test/Games/bb3d_asteroids/Title.png diff --git a/_release/Games/bb3d_asteroids/asteroid.3ds b/#Test/Games/bb3d_asteroids/asteroid.3ds similarity index 100% rename from _release/Games/bb3d_asteroids/asteroid.3ds rename to #Test/Games/bb3d_asteroids/asteroid.3ds diff --git a/_release/Games/bb3d_asteroids/b3dlogo.png b/#Test/Games/bb3d_asteroids/b3dlogo.png similarity index 100% rename from _release/Games/bb3d_asteroids/b3dlogo.png rename to #Test/Games/bb3d_asteroids/b3dlogo.png diff --git a/_release/Games/bb3d_asteroids/explode.wav b/#Test/Games/bb3d_asteroids/explode.wav similarity index 100% rename from _release/Games/bb3d_asteroids/explode.wav rename to #Test/Games/bb3d_asteroids/explode.wav diff --git a/_release/Games/bb3d_asteroids/explode1.wav b/#Test/Games/bb3d_asteroids/explode1.wav similarity index 100% rename from _release/Games/bb3d_asteroids/explode1.wav rename to #Test/Games/bb3d_asteroids/explode1.wav diff --git a/_release/Games/bb3d_asteroids/flame2.bmp b/#Test/Games/bb3d_asteroids/flame2.bmp similarity index 100% rename from _release/Games/bb3d_asteroids/flame2.bmp rename to #Test/Games/bb3d_asteroids/flame2.bmp diff --git a/_release/Games/bb3d_asteroids/flame3.bmp b/#Test/Games/bb3d_asteroids/flame3.bmp similarity index 100% rename from _release/Games/bb3d_asteroids/flame3.bmp rename to #Test/Games/bb3d_asteroids/flame3.bmp diff --git a/_release/Games/bb3d_asteroids/hfighter.3ds b/#Test/Games/bb3d_asteroids/hfighter.3ds similarity index 100% rename from _release/Games/bb3d_asteroids/hfighter.3ds rename to #Test/Games/bb3d_asteroids/hfighter.3ds diff --git a/_release/Games/bb3d_asteroids/hit.wav b/#Test/Games/bb3d_asteroids/hit.wav similarity index 100% rename from _release/Games/bb3d_asteroids/hit.wav rename to #Test/Games/bb3d_asteroids/hit.wav diff --git a/_release/Games/bb3d_asteroids/lasergun.wav b/#Test/Games/bb3d_asteroids/lasergun.wav similarity index 100% rename from _release/Games/bb3d_asteroids/lasergun.wav rename to #Test/Games/bb3d_asteroids/lasergun.wav diff --git a/_release/Games/bb3d_asteroids/stars.bmp b/#Test/Games/bb3d_asteroids/stars.bmp similarity index 100% rename from _release/Games/bb3d_asteroids/stars.bmp rename to #Test/Games/bb3d_asteroids/stars.bmp diff --git a/_release/Games/bb3d_asteroids/stone04.bmp b/#Test/Games/bb3d_asteroids/stone04.bmp similarity index 100% rename from _release/Games/bb3d_asteroids/stone04.bmp rename to #Test/Games/bb3d_asteroids/stone04.bmp diff --git a/_release/Games/bb3d_asteroids/ufo.3ds b/#Test/Games/bb3d_asteroids/ufo.3ds similarity index 100% rename from _release/Games/bb3d_asteroids/ufo.3ds rename to #Test/Games/bb3d_asteroids/ufo.3ds diff --git a/_release/Games/bb3d_asteroids/ufo.wav b/#Test/Games/bb3d_asteroids/ufo.wav similarity index 100% rename from _release/Games/bb3d_asteroids/ufo.wav rename to #Test/Games/bb3d_asteroids/ufo.wav diff --git a/_release/Games/wing_ring/issues.txt b/#Test/Games/wing_ring/issues.txt similarity index 100% rename from _release/Games/wing_ring/issues.txt rename to #Test/Games/wing_ring/issues.txt diff --git a/_release/Games/wing_ring/media/1000.bmp b/#Test/Games/wing_ring/media/1000.bmp similarity index 100% rename from _release/Games/wing_ring/media/1000.bmp rename to #Test/Games/wing_ring/media/1000.bmp diff --git a/_release/Games/wing_ring/media/1000x10.bmp b/#Test/Games/wing_ring/media/1000x10.bmp similarity index 100% rename from _release/Games/wing_ring/media/1000x10.bmp rename to #Test/Games/wing_ring/media/1000x10.bmp diff --git a/_release/Games/wing_ring/media/1000x2.bmp b/#Test/Games/wing_ring/media/1000x2.bmp similarity index 100% rename from _release/Games/wing_ring/media/1000x2.bmp rename to #Test/Games/wing_ring/media/1000x2.bmp diff --git a/_release/Games/wing_ring/media/1000x4.bmp b/#Test/Games/wing_ring/media/1000x4.bmp similarity index 100% rename from _release/Games/wing_ring/media/1000x4.bmp rename to #Test/Games/wing_ring/media/1000x4.bmp diff --git a/_release/Games/wing_ring/media/1000x6.bmp b/#Test/Games/wing_ring/media/1000x6.bmp similarity index 100% rename from _release/Games/wing_ring/media/1000x6.bmp rename to #Test/Games/wing_ring/media/1000x6.bmp diff --git a/_release/Games/wing_ring/media/1000x8.bmp b/#Test/Games/wing_ring/media/1000x8.bmp similarity index 100% rename from _release/Games/wing_ring/media/1000x8.bmp rename to #Test/Games/wing_ring/media/1000x8.bmp diff --git a/_release/Games/wing_ring/media/200.bmp b/#Test/Games/wing_ring/media/200.bmp similarity index 100% rename from _release/Games/wing_ring/media/200.bmp rename to #Test/Games/wing_ring/media/200.bmp diff --git a/_release/Games/wing_ring/media/200x10.bmp b/#Test/Games/wing_ring/media/200x10.bmp similarity index 100% rename from _release/Games/wing_ring/media/200x10.bmp rename to #Test/Games/wing_ring/media/200x10.bmp diff --git a/_release/Games/wing_ring/media/200x2.bmp b/#Test/Games/wing_ring/media/200x2.bmp similarity index 100% rename from _release/Games/wing_ring/media/200x2.bmp rename to #Test/Games/wing_ring/media/200x2.bmp diff --git a/_release/Games/wing_ring/media/200x4.bmp b/#Test/Games/wing_ring/media/200x4.bmp similarity index 100% rename from _release/Games/wing_ring/media/200x4.bmp rename to #Test/Games/wing_ring/media/200x4.bmp diff --git a/_release/Games/wing_ring/media/200x6.bmp b/#Test/Games/wing_ring/media/200x6.bmp similarity index 100% rename from _release/Games/wing_ring/media/200x6.bmp rename to #Test/Games/wing_ring/media/200x6.bmp diff --git a/_release/Games/wing_ring/media/200x8.bmp b/#Test/Games/wing_ring/media/200x8.bmp similarity index 100% rename from _release/Games/wing_ring/media/200x8.bmp rename to #Test/Games/wing_ring/media/200x8.bmp diff --git a/_release/Games/wing_ring/media/400.bmp b/#Test/Games/wing_ring/media/400.bmp similarity index 100% rename from _release/Games/wing_ring/media/400.bmp rename to #Test/Games/wing_ring/media/400.bmp diff --git a/_release/Games/wing_ring/media/400x10.bmp b/#Test/Games/wing_ring/media/400x10.bmp similarity index 100% rename from _release/Games/wing_ring/media/400x10.bmp rename to #Test/Games/wing_ring/media/400x10.bmp diff --git a/_release/Games/wing_ring/media/400x2.bmp b/#Test/Games/wing_ring/media/400x2.bmp similarity index 100% rename from _release/Games/wing_ring/media/400x2.bmp rename to #Test/Games/wing_ring/media/400x2.bmp diff --git a/_release/Games/wing_ring/media/400x4.bmp b/#Test/Games/wing_ring/media/400x4.bmp similarity index 100% rename from _release/Games/wing_ring/media/400x4.bmp rename to #Test/Games/wing_ring/media/400x4.bmp diff --git a/_release/Games/wing_ring/media/400x6.bmp b/#Test/Games/wing_ring/media/400x6.bmp similarity index 100% rename from _release/Games/wing_ring/media/400x6.bmp rename to #Test/Games/wing_ring/media/400x6.bmp diff --git a/_release/Games/wing_ring/media/400x8.bmp b/#Test/Games/wing_ring/media/400x8.bmp similarity index 100% rename from _release/Games/wing_ring/media/400x8.bmp rename to #Test/Games/wing_ring/media/400x8.bmp diff --git a/_release/Games/wing_ring/media/600.bmp b/#Test/Games/wing_ring/media/600.bmp similarity index 100% rename from _release/Games/wing_ring/media/600.bmp rename to #Test/Games/wing_ring/media/600.bmp diff --git a/_release/Games/wing_ring/media/600x10.bmp b/#Test/Games/wing_ring/media/600x10.bmp similarity index 100% rename from _release/Games/wing_ring/media/600x10.bmp rename to #Test/Games/wing_ring/media/600x10.bmp diff --git a/_release/Games/wing_ring/media/600x2.bmp b/#Test/Games/wing_ring/media/600x2.bmp similarity index 100% rename from _release/Games/wing_ring/media/600x2.bmp rename to #Test/Games/wing_ring/media/600x2.bmp diff --git a/_release/Games/wing_ring/media/600x4.bmp b/#Test/Games/wing_ring/media/600x4.bmp similarity index 100% rename from _release/Games/wing_ring/media/600x4.bmp rename to #Test/Games/wing_ring/media/600x4.bmp diff --git a/_release/Games/wing_ring/media/600x6.bmp b/#Test/Games/wing_ring/media/600x6.bmp similarity index 100% rename from _release/Games/wing_ring/media/600x6.bmp rename to #Test/Games/wing_ring/media/600x6.bmp diff --git a/_release/Games/wing_ring/media/600x8.bmp b/#Test/Games/wing_ring/media/600x8.bmp similarity index 100% rename from _release/Games/wing_ring/media/600x8.bmp rename to #Test/Games/wing_ring/media/600x8.bmp diff --git a/_release/Games/wing_ring/media/800.bmp b/#Test/Games/wing_ring/media/800.bmp similarity index 100% rename from _release/Games/wing_ring/media/800.bmp rename to #Test/Games/wing_ring/media/800.bmp diff --git a/_release/Games/wing_ring/media/800x10.bmp b/#Test/Games/wing_ring/media/800x10.bmp similarity index 100% rename from _release/Games/wing_ring/media/800x10.bmp rename to #Test/Games/wing_ring/media/800x10.bmp diff --git a/_release/Games/wing_ring/media/800x2.bmp b/#Test/Games/wing_ring/media/800x2.bmp similarity index 100% rename from _release/Games/wing_ring/media/800x2.bmp rename to #Test/Games/wing_ring/media/800x2.bmp diff --git a/_release/Games/wing_ring/media/800x4.bmp b/#Test/Games/wing_ring/media/800x4.bmp similarity index 100% rename from _release/Games/wing_ring/media/800x4.bmp rename to #Test/Games/wing_ring/media/800x4.bmp diff --git a/_release/Games/wing_ring/media/800x6.bmp b/#Test/Games/wing_ring/media/800x6.bmp similarity index 100% rename from _release/Games/wing_ring/media/800x6.bmp rename to #Test/Games/wing_ring/media/800x6.bmp diff --git a/_release/Games/wing_ring/media/800x8.bmp b/#Test/Games/wing_ring/media/800x8.bmp similarity index 100% rename from _release/Games/wing_ring/media/800x8.bmp rename to #Test/Games/wing_ring/media/800x8.bmp diff --git a/_release/Games/wing_ring/media/F15.BMP b/#Test/Games/wing_ring/media/F15.BMP similarity index 100% rename from _release/Games/wing_ring/media/F15.BMP rename to #Test/Games/wing_ring/media/F15.BMP diff --git a/_release/Games/wing_ring/media/Thumbs.db b/#Test/Games/wing_ring/media/Thumbs.db similarity index 100% rename from _release/Games/wing_ring/media/Thumbs.db rename to #Test/Games/wing_ring/media/Thumbs.db diff --git a/_release/Games/wing_ring/media/big_spark.BMP b/#Test/Games/wing_ring/media/big_spark.BMP similarity index 100% rename from _release/Games/wing_ring/media/big_spark.BMP rename to #Test/Games/wing_ring/media/big_spark.BMP diff --git a/_release/Games/wing_ring/media/blue_spark.bmp b/#Test/Games/wing_ring/media/blue_spark.bmp similarity index 100% rename from _release/Games/wing_ring/media/blue_spark.bmp rename to #Test/Games/wing_ring/media/blue_spark.bmp diff --git a/_release/Games/wing_ring/media/blue_ufo.X b/#Test/Games/wing_ring/media/blue_ufo.X similarity index 100% rename from _release/Games/wing_ring/media/blue_ufo.X rename to #Test/Games/wing_ring/media/blue_ufo.X diff --git a/_release/Games/wing_ring/media/bust.bmp b/#Test/Games/wing_ring/media/bust.bmp similarity index 100% rename from _release/Games/wing_ring/media/bust.bmp rename to #Test/Games/wing_ring/media/bust.bmp diff --git a/_release/Games/wing_ring/media/camel.x b/#Test/Games/wing_ring/media/camel.x similarity index 100% rename from _release/Games/wing_ring/media/camel.x rename to #Test/Games/wing_ring/media/camel.x diff --git a/_release/Games/wing_ring/media/clouds.bmp b/#Test/Games/wing_ring/media/clouds.bmp similarity index 100% rename from _release/Games/wing_ring/media/clouds.bmp rename to #Test/Games/wing_ring/media/clouds.bmp diff --git a/_release/Games/wing_ring/media/clouds_night.bmp b/#Test/Games/wing_ring/media/clouds_night.bmp similarity index 100% rename from _release/Games/wing_ring/media/clouds_night.bmp rename to #Test/Games/wing_ring/media/clouds_night.bmp diff --git a/_release/Games/wing_ring/media/explode.wav b/#Test/Games/wing_ring/media/explode.wav similarity index 100% rename from _release/Games/wing_ring/media/explode.wav rename to #Test/Games/wing_ring/media/explode.wav diff --git a/_release/Games/wing_ring/media/green_spark.bmp b/#Test/Games/wing_ring/media/green_spark.bmp similarity index 100% rename from _release/Games/wing_ring/media/green_spark.bmp rename to #Test/Games/wing_ring/media/green_spark.bmp diff --git a/_release/Games/wing_ring/media/green_ufo.x b/#Test/Games/wing_ring/media/green_ufo.x similarity index 100% rename from _release/Games/wing_ring/media/green_ufo.x rename to #Test/Games/wing_ring/media/green_ufo.x diff --git a/_release/Games/wing_ring/media/high_scores.sav b/#Test/Games/wing_ring/media/high_scores.sav similarity index 100% rename from _release/Games/wing_ring/media/high_scores.sav rename to #Test/Games/wing_ring/media/high_scores.sav diff --git a/_release/Games/wing_ring/media/lights.bmp b/#Test/Games/wing_ring/media/lights.bmp similarity index 100% rename from _release/Games/wing_ring/media/lights.bmp rename to #Test/Games/wing_ring/media/lights.bmp diff --git a/_release/Games/wing_ring/media/logo.bmp b/#Test/Games/wing_ring/media/logo.bmp similarity index 100% rename from _release/Games/wing_ring/media/logo.bmp rename to #Test/Games/wing_ring/media/logo.bmp diff --git a/_release/Games/wing_ring/media/moon.bmp b/#Test/Games/wing_ring/media/moon.bmp similarity index 100% rename from _release/Games/wing_ring/media/moon.bmp rename to #Test/Games/wing_ring/media/moon.bmp diff --git a/_release/Games/wing_ring/media/mother.x b/#Test/Games/wing_ring/media/mother.x similarity index 100% rename from _release/Games/wing_ring/media/mother.x rename to #Test/Games/wing_ring/media/mother.x diff --git a/_release/Games/wing_ring/media/orange_spark.bmp b/#Test/Games/wing_ring/media/orange_spark.bmp similarity index 100% rename from _release/Games/wing_ring/media/orange_spark.bmp rename to #Test/Games/wing_ring/media/orange_spark.bmp diff --git a/_release/Games/wing_ring/media/orange_ufo.x b/#Test/Games/wing_ring/media/orange_ufo.x similarity index 100% rename from _release/Games/wing_ring/media/orange_ufo.x rename to #Test/Games/wing_ring/media/orange_ufo.x diff --git a/_release/Games/wing_ring/media/pink_spark.bmp b/#Test/Games/wing_ring/media/pink_spark.bmp similarity index 100% rename from _release/Games/wing_ring/media/pink_spark.bmp rename to #Test/Games/wing_ring/media/pink_spark.bmp diff --git a/_release/Games/wing_ring/media/pink_ufo.x b/#Test/Games/wing_ring/media/pink_ufo.x similarity index 100% rename from _release/Games/wing_ring/media/pink_ufo.x rename to #Test/Games/wing_ring/media/pink_ufo.x diff --git a/_release/Games/wing_ring/media/plane.x b/#Test/Games/wing_ring/media/plane.x similarity index 100% rename from _release/Games/wing_ring/media/plane.x rename to #Test/Games/wing_ring/media/plane.x diff --git a/_release/Games/wing_ring/media/ring.bmp b/#Test/Games/wing_ring/media/ring.bmp similarity index 100% rename from _release/Games/wing_ring/media/ring.bmp rename to #Test/Games/wing_ring/media/ring.bmp diff --git a/_release/Games/wing_ring/media/sand.bmp b/#Test/Games/wing_ring/media/sand.bmp similarity index 100% rename from _release/Games/wing_ring/media/sand.bmp rename to #Test/Games/wing_ring/media/sand.bmp diff --git a/_release/Games/wing_ring/media/sphinx.x b/#Test/Games/wing_ring/media/sphinx.x similarity index 100% rename from _release/Games/wing_ring/media/sphinx.x rename to #Test/Games/wing_ring/media/sphinx.x diff --git a/_release/Games/wing_ring/media/stat_lib.x b/#Test/Games/wing_ring/media/stat_lib.x similarity index 100% rename from _release/Games/wing_ring/media/stat_lib.x rename to #Test/Games/wing_ring/media/stat_lib.x diff --git a/_release/Games/wing_ring/media/tune1.mid b/#Test/Games/wing_ring/media/tune1.mid similarity index 100% rename from _release/Games/wing_ring/media/tune1.mid rename to #Test/Games/wing_ring/media/tune1.mid diff --git a/_release/Games/wing_ring/media/tune2.mid b/#Test/Games/wing_ring/media/tune2.mid similarity index 100% rename from _release/Games/wing_ring/media/tune2.mid rename to #Test/Games/wing_ring/media/tune2.mid diff --git a/_release/Games/wing_ring/media/yellow_spark.bmp b/#Test/Games/wing_ring/media/yellow_spark.bmp similarity index 100% rename from _release/Games/wing_ring/media/yellow_spark.bmp rename to #Test/Games/wing_ring/media/yellow_spark.bmp diff --git a/_release/Games/wing_ring/media/yellow_ufo.X b/#Test/Games/wing_ring/media/yellow_ufo.X similarity index 100% rename from _release/Games/wing_ring/media/yellow_ufo.X rename to #Test/Games/wing_ring/media/yellow_ufo.X diff --git a/_release/Games/wing_ring/menus.bb b/#Test/Games/wing_ring/menus.bb similarity index 100% rename from _release/Games/wing_ring/menus.bb rename to #Test/Games/wing_ring/menus.bb diff --git a/_release/Games/wing_ring/player2.bb b/#Test/Games/wing_ring/player2.bb similarity index 100% rename from _release/Games/wing_ring/player2.bb rename to #Test/Games/wing_ring/player2.bb diff --git a/_release/Games/wing_ring/readme.bb b/#Test/Games/wing_ring/readme.bb similarity index 100% rename from _release/Games/wing_ring/readme.bb rename to #Test/Games/wing_ring/readme.bb diff --git a/_release/Games/wing_ring/readme.txt b/#Test/Games/wing_ring/readme.txt similarity index 100% rename from _release/Games/wing_ring/readme.txt rename to #Test/Games/wing_ring/readme.txt diff --git a/_release/Games/wing_ring/scenery.bb b/#Test/Games/wing_ring/scenery.bb similarity index 100% rename from _release/Games/wing_ring/scenery.bb rename to #Test/Games/wing_ring/scenery.bb diff --git a/_release/Games/wing_ring/wing_ring.bb b/#Test/Games/wing_ring/wing_ring.bb similarity index 100% rename from _release/Games/wing_ring/wing_ring.bb rename to #Test/Games/wing_ring/wing_ring.bb diff --git a/_release/Media/geometricks_models/british-tadpole/btadpole.3ds b/#Test/Media/geometricks_models/british-tadpole/btadpole.3ds similarity index 100% rename from _release/Media/geometricks_models/british-tadpole/btadpole.3ds rename to #Test/Media/geometricks_models/british-tadpole/btadpole.3ds diff --git a/_release/Media/geometricks_models/british-tadpole/btadpole.jpg b/#Test/Media/geometricks_models/british-tadpole/btadpole.jpg similarity index 100% rename from _release/Media/geometricks_models/british-tadpole/btadpole.jpg rename to #Test/Media/geometricks_models/british-tadpole/btadpole.jpg diff --git a/_release/Media/geometricks_models/fighter/fighter.3ds b/#Test/Media/geometricks_models/fighter/fighter.3ds similarity index 100% rename from _release/Media/geometricks_models/fighter/fighter.3ds rename to #Test/Media/geometricks_models/fighter/fighter.3ds diff --git a/_release/Media/geometricks_models/fighter/fighter.jpg b/#Test/Media/geometricks_models/fighter/fighter.jpg similarity index 100% rename from _release/Media/geometricks_models/fighter/fighter.jpg rename to #Test/Media/geometricks_models/fighter/fighter.jpg diff --git a/_release/Media/geometricks_models/hearse/hearse.3ds b/#Test/Media/geometricks_models/hearse/hearse.3ds similarity index 100% rename from _release/Media/geometricks_models/hearse/hearse.3ds rename to #Test/Media/geometricks_models/hearse/hearse.3ds diff --git a/_release/Media/geometricks_models/hearse/hearse.jpg b/#Test/Media/geometricks_models/hearse/hearse.jpg similarity index 100% rename from _release/Media/geometricks_models/hearse/hearse.jpg rename to #Test/Media/geometricks_models/hearse/hearse.jpg diff --git a/_release/Media/geometricks_models/oil-drum/oildrum.3ds b/#Test/Media/geometricks_models/oil-drum/oildrum.3ds similarity index 100% rename from _release/Media/geometricks_models/oil-drum/oildrum.3ds rename to #Test/Media/geometricks_models/oil-drum/oildrum.3ds diff --git a/_release/Media/geometricks_models/oil-drum/oildrum.jpg b/#Test/Media/geometricks_models/oil-drum/oildrum.jpg similarity index 100% rename from _release/Media/geometricks_models/oil-drum/oildrum.jpg rename to #Test/Media/geometricks_models/oil-drum/oildrum.jpg diff --git a/_release/Media/geometricks_models/rallycar/rallycar.jpg b/#Test/Media/geometricks_models/rallycar/rallycar.jpg similarity index 100% rename from _release/Media/geometricks_models/rallycar/rallycar.jpg rename to #Test/Media/geometricks_models/rallycar/rallycar.jpg diff --git a/_release/Media/geometricks_models/rallycar/rallycar1.3ds b/#Test/Media/geometricks_models/rallycar/rallycar1.3ds similarity index 100% rename from _release/Media/geometricks_models/rallycar/rallycar1.3ds rename to #Test/Media/geometricks_models/rallycar/rallycar1.3ds diff --git a/_release/Media/geometricks_models/saucer/fsaucer1.3ds b/#Test/Media/geometricks_models/saucer/fsaucer1.3ds similarity index 100% rename from _release/Media/geometricks_models/saucer/fsaucer1.3ds rename to #Test/Media/geometricks_models/saucer/fsaucer1.3ds diff --git a/_release/Media/geometricks_models/saucer/saucer.jpg b/#Test/Media/geometricks_models/saucer/saucer.jpg similarity index 100% rename from _release/Media/geometricks_models/saucer/saucer.jpg rename to #Test/Media/geometricks_models/saucer/saucer.jpg diff --git a/_release/Media/geometricks_models/solarsail/solarsail.3ds b/#Test/Media/geometricks_models/solarsail/solarsail.3ds similarity index 100% rename from _release/Media/geometricks_models/solarsail/solarsail.3ds rename to #Test/Media/geometricks_models/solarsail/solarsail.3ds diff --git a/_release/Media/geometricks_models/solarsail/ssail.jpg b/#Test/Media/geometricks_models/solarsail/ssail.jpg similarity index 100% rename from _release/Media/geometricks_models/solarsail/ssail.jpg rename to #Test/Media/geometricks_models/solarsail/ssail.jpg diff --git a/_release/Media/geometricks_models/stealth/stealth.3ds b/#Test/Media/geometricks_models/stealth/stealth.3ds similarity index 100% rename from _release/Media/geometricks_models/stealth/stealth.3ds rename to #Test/Media/geometricks_models/stealth/stealth.3ds diff --git a/_release/Media/geometricks_models/stealth/stealth.jpg b/#Test/Media/geometricks_models/stealth/stealth.jpg similarity index 100% rename from _release/Media/geometricks_models/stealth/stealth.jpg rename to #Test/Media/geometricks_models/stealth/stealth.jpg diff --git a/_release/Media/geometricks_models/supplies/readme.txt b/#Test/Media/geometricks_models/supplies/readme.txt similarity index 100% rename from _release/Media/geometricks_models/supplies/readme.txt rename to #Test/Media/geometricks_models/supplies/readme.txt diff --git a/_release/Media/geometricks_models/supplies/supplies.x b/#Test/Media/geometricks_models/supplies/supplies.x similarity index 100% rename from _release/Media/geometricks_models/supplies/supplies.x rename to #Test/Media/geometricks_models/supplies/supplies.x diff --git a/_release/Media/geometricks_models/supplies/supplies_0.bmp b/#Test/Media/geometricks_models/supplies/supplies_0.bmp similarity index 100% rename from _release/Media/geometricks_models/supplies/supplies_0.bmp rename to #Test/Media/geometricks_models/supplies/supplies_0.bmp diff --git a/_release/Media/geometricks_models/supplies/supplies_1.bmp b/#Test/Media/geometricks_models/supplies/supplies_1.bmp similarity index 100% rename from _release/Media/geometricks_models/supplies/supplies_1.bmp rename to #Test/Media/geometricks_models/supplies/supplies_1.bmp diff --git a/_release/Media/geometricks_models/warrior/warrior.3ds b/#Test/Media/geometricks_models/warrior/warrior.3ds similarity index 100% rename from _release/Media/geometricks_models/warrior/warrior.3ds rename to #Test/Media/geometricks_models/warrior/warrior.3ds diff --git a/_release/Media/geometricks_models/warrior/warrior.jpg b/#Test/Media/geometricks_models/warrior/warrior.jpg similarity index 100% rename from _release/Media/geometricks_models/warrior/warrior.jpg rename to #Test/Media/geometricks_models/warrior/warrior.jpg diff --git a/_release/Media/geometricks_models/wood-crate/wcrate.jpg b/#Test/Media/geometricks_models/wood-crate/wcrate.jpg similarity index 100% rename from _release/Media/geometricks_models/wood-crate/wcrate.jpg rename to #Test/Media/geometricks_models/wood-crate/wcrate.jpg diff --git a/_release/Media/geometricks_models/wood-crate/wcrate1.3ds b/#Test/Media/geometricks_models/wood-crate/wcrate1.3ds similarity index 100% rename from _release/Media/geometricks_models/wood-crate/wcrate1.3ds rename to #Test/Media/geometricks_models/wood-crate/wcrate1.3ds diff --git a/#Test/bin/BlitzCc.exe b/#Test/bin/BlitzCc.exe new file mode 100644 index 0000000..7f06f43 Binary files /dev/null and b/#Test/bin/BlitzCc.exe differ diff --git a/#Test/bin/BlitzCc.ilk b/#Test/bin/BlitzCc.ilk new file mode 100644 index 0000000..eeb92db Binary files /dev/null and b/#Test/bin/BlitzCc.ilk differ diff --git a/#Test/bin/BlitzCc.pdb b/#Test/bin/BlitzCc.pdb new file mode 100644 index 0000000..ab97fe9 Binary files /dev/null and b/#Test/bin/BlitzCc.pdb differ diff --git a/#Test/bin/Debugger.dll b/#Test/bin/Debugger.dll new file mode 100644 index 0000000..3776923 Binary files /dev/null and b/#Test/bin/Debugger.dll differ diff --git a/#Test/bin/Debugger.pdb b/#Test/bin/Debugger.pdb new file mode 100644 index 0000000..f938a93 Binary files /dev/null and b/#Test/bin/Debugger.pdb differ diff --git a/#Test/bin/FreeImage.dll b/#Test/bin/FreeImage.dll new file mode 100644 index 0000000..cb4cf6e Binary files /dev/null and b/#Test/bin/FreeImage.dll differ diff --git a/#Test/bin/Linker.dll b/#Test/bin/Linker.dll new file mode 100644 index 0000000..a9681d1 Binary files /dev/null and b/#Test/bin/Linker.dll differ diff --git a/#Test/bin/Linker.pdb b/#Test/bin/Linker.pdb new file mode 100644 index 0000000..7bf0324 Binary files /dev/null and b/#Test/bin/Linker.pdb differ diff --git a/#Test/bin/Runtime.dll b/#Test/bin/Runtime.dll new file mode 100644 index 0000000..c3bb258 Binary files /dev/null and b/#Test/bin/Runtime.dll differ diff --git a/#Test/bin/Runtime.pdb b/#Test/bin/Runtime.pdb new file mode 100644 index 0000000..7cd30fa Binary files /dev/null and b/#Test/bin/Runtime.pdb differ diff --git a/#Test/bin/depends.dll b/#Test/bin/depends.dll new file mode 100644 index 0000000..f78fd34 Binary files /dev/null and b/#Test/bin/depends.dll differ diff --git a/#Test/bin/depends.exe b/#Test/bin/depends.exe new file mode 100644 index 0000000..4586e89 Binary files /dev/null and b/#Test/bin/depends.exe differ diff --git a/fmodapi375win/api/fmod.dll b/#Test/bin/fmod.dll similarity index 100% rename from fmodapi375win/api/fmod.dll rename to #Test/bin/fmod.dll diff --git a/#Test/bin/ide.exe b/#Test/bin/ide.exe new file mode 100644 index 0000000..ec19693 Binary files /dev/null and b/#Test/bin/ide.exe differ diff --git a/_release/cfg/Blitz.fon b/#Test/cfg/Blitz.fon similarity index 100% rename from _release/cfg/Blitz.fon rename to #Test/cfg/Blitz.fon diff --git a/#Test/cfg/blitzide.prefs b/#Test/cfg/blitzide.prefs new file mode 100644 index 0000000..47f0fa4 --- /dev/null +++ b/#Test/cfg/blitzide.prefs @@ -0,0 +1,23 @@ +prg_debug 0 +prg_lastbuild C:\Projects\Sirius Online - Client\ExeFile.bb +win_maximized 0 +win_notoolbar 0 +win_rect 395 325 1035 805 +font_editor blitz 12 +font_tabs verdana 8 +font_debug verdana 8 +rgb_bkgrnd 225588 +rgb_string ff66 +rgb_ident ffffff +rgb_keyword aaffff +rgb_comment ffee00 +rgb_digit 33ffdd +rgb_default eeeeee +edit_tabs 4 +edit_blkcursor 0 +edit_backup 2 +img_toolbar toolbar.bmp +cmd_line +file_recent c:\projects\sirius online - client\include\launcher.bb +file_recent c:\projects\sirius online - client\libraries\blitzsteam\blitzsteam.bb +file_recent C:\Projects\Sirius Online - Client\ExeFile.bb diff --git a/_release/cfg/dbg_toolbar.bmp b/#Test/cfg/dbg_toolbar.bmp similarity index 100% rename from _release/cfg/dbg_toolbar.bmp rename to #Test/cfg/dbg_toolbar.bmp diff --git a/_release/cfg/ide_toolbar.bmp b/#Test/cfg/ide_toolbar.bmp similarity index 100% rename from _release/cfg/ide_toolbar.bmp rename to #Test/cfg/ide_toolbar.bmp diff --git a/_release/cfg/toolbar.bmp b/#Test/cfg/toolbar.bmp similarity index 100% rename from _release/cfg/toolbar.bmp rename to #Test/cfg/toolbar.bmp diff --git a/_release/help/b3dlogo.jpg b/#Test/help/b3dlogo.jpg similarity index 100% rename from _release/help/b3dlogo.jpg rename to #Test/help/b3dlogo.jpg diff --git a/_release/help/commands/2d_commands/ACos.htm b/#Test/help/commands/2d_commands/ACos.htm similarity index 100% rename from _release/help/commands/2d_commands/ACos.htm rename to #Test/help/commands/2d_commands/ACos.htm diff --git a/_release/help/commands/2d_commands/ASin.htm b/#Test/help/commands/2d_commands/ASin.htm similarity index 100% rename from _release/help/commands/2d_commands/ASin.htm rename to #Test/help/commands/2d_commands/ASin.htm diff --git a/_release/help/commands/2d_commands/ATan.htm b/#Test/help/commands/2d_commands/ATan.htm similarity index 100% rename from _release/help/commands/2d_commands/ATan.htm rename to #Test/help/commands/2d_commands/ATan.htm diff --git a/_release/help/commands/2d_commands/ATan2.htm b/#Test/help/commands/2d_commands/ATan2.htm similarity index 100% rename from _release/help/commands/2d_commands/ATan2.htm rename to #Test/help/commands/2d_commands/ATan2.htm diff --git a/_release/help/commands/2d_commands/Abs.htm b/#Test/help/commands/2d_commands/Abs.htm similarity index 100% rename from _release/help/commands/2d_commands/Abs.htm rename to #Test/help/commands/2d_commands/Abs.htm diff --git a/_release/help/commands/2d_commands/AcceptTCPStream.htm b/#Test/help/commands/2d_commands/AcceptTCPStream.htm similarity index 100% rename from _release/help/commands/2d_commands/AcceptTCPStream.htm rename to #Test/help/commands/2d_commands/AcceptTCPStream.htm diff --git a/_release/help/commands/2d_commands/After.htm b/#Test/help/commands/2d_commands/After.htm similarity index 100% rename from _release/help/commands/2d_commands/After.htm rename to #Test/help/commands/2d_commands/After.htm diff --git a/_release/help/commands/2d_commands/And.htm b/#Test/help/commands/2d_commands/And.htm similarity index 100% rename from _release/help/commands/2d_commands/And.htm rename to #Test/help/commands/2d_commands/And.htm diff --git a/_release/help/commands/2d_commands/AppTitle.htm b/#Test/help/commands/2d_commands/AppTitle.htm similarity index 100% rename from _release/help/commands/2d_commands/AppTitle.htm rename to #Test/help/commands/2d_commands/AppTitle.htm diff --git a/_release/help/commands/2d_commands/Asc.htm b/#Test/help/commands/2d_commands/Asc.htm similarity index 100% rename from _release/help/commands/2d_commands/Asc.htm rename to #Test/help/commands/2d_commands/Asc.htm diff --git a/_release/help/commands/2d_commands/AutoMidHandle .htm b/#Test/help/commands/2d_commands/AutoMidHandle .htm similarity index 100% rename from _release/help/commands/2d_commands/AutoMidHandle .htm rename to #Test/help/commands/2d_commands/AutoMidHandle .htm diff --git a/_release/help/commands/2d_commands/AvailVidMem.htm b/#Test/help/commands/2d_commands/AvailVidMem.htm similarity index 100% rename from _release/help/commands/2d_commands/AvailVidMem.htm rename to #Test/help/commands/2d_commands/AvailVidMem.htm diff --git a/_release/help/commands/2d_commands/BackBuffer.htm b/#Test/help/commands/2d_commands/BackBuffer.htm similarity index 100% rename from _release/help/commands/2d_commands/BackBuffer.htm rename to #Test/help/commands/2d_commands/BackBuffer.htm diff --git a/_release/help/commands/2d_commands/BankSize.htm b/#Test/help/commands/2d_commands/BankSize.htm similarity index 100% rename from _release/help/commands/2d_commands/BankSize.htm rename to #Test/help/commands/2d_commands/BankSize.htm diff --git a/_release/help/commands/2d_commands/Before.htm b/#Test/help/commands/2d_commands/Before.htm similarity index 100% rename from _release/help/commands/2d_commands/Before.htm rename to #Test/help/commands/2d_commands/Before.htm diff --git a/_release/help/commands/2d_commands/Bin.htm b/#Test/help/commands/2d_commands/Bin.htm similarity index 100% rename from _release/help/commands/2d_commands/Bin.htm rename to #Test/help/commands/2d_commands/Bin.htm diff --git a/_release/help/commands/2d_commands/CPUTimer.htm b/#Test/help/commands/2d_commands/CPUTimer.htm similarity index 100% rename from _release/help/commands/2d_commands/CPUTimer.htm rename to #Test/help/commands/2d_commands/CPUTimer.htm diff --git a/_release/help/commands/2d_commands/Case.htm b/#Test/help/commands/2d_commands/Case.htm similarity index 100% rename from _release/help/commands/2d_commands/Case.htm rename to #Test/help/commands/2d_commands/Case.htm diff --git a/_release/help/commands/2d_commands/Ceil.htm b/#Test/help/commands/2d_commands/Ceil.htm similarity index 100% rename from _release/help/commands/2d_commands/Ceil.htm rename to #Test/help/commands/2d_commands/Ceil.htm diff --git a/_release/help/commands/2d_commands/ChangeDir.htm b/#Test/help/commands/2d_commands/ChangeDir.htm similarity index 100% rename from _release/help/commands/2d_commands/ChangeDir.htm rename to #Test/help/commands/2d_commands/ChangeDir.htm diff --git a/_release/help/commands/2d_commands/ChannelPan.htm b/#Test/help/commands/2d_commands/ChannelPan.htm similarity index 100% rename from _release/help/commands/2d_commands/ChannelPan.htm rename to #Test/help/commands/2d_commands/ChannelPan.htm diff --git a/_release/help/commands/2d_commands/ChannelPitch.htm b/#Test/help/commands/2d_commands/ChannelPitch.htm similarity index 100% rename from _release/help/commands/2d_commands/ChannelPitch.htm rename to #Test/help/commands/2d_commands/ChannelPitch.htm diff --git a/_release/help/commands/2d_commands/ChannelPlaying.htm b/#Test/help/commands/2d_commands/ChannelPlaying.htm similarity index 100% rename from _release/help/commands/2d_commands/ChannelPlaying.htm rename to #Test/help/commands/2d_commands/ChannelPlaying.htm diff --git a/_release/help/commands/2d_commands/ChannelVolume.htm b/#Test/help/commands/2d_commands/ChannelVolume.htm similarity index 100% rename from _release/help/commands/2d_commands/ChannelVolume.htm rename to #Test/help/commands/2d_commands/ChannelVolume.htm diff --git a/_release/help/commands/2d_commands/Chr.htm b/#Test/help/commands/2d_commands/Chr.htm similarity index 100% rename from _release/help/commands/2d_commands/Chr.htm rename to #Test/help/commands/2d_commands/Chr.htm diff --git a/_release/help/commands/2d_commands/CloseDir.htm b/#Test/help/commands/2d_commands/CloseDir.htm similarity index 100% rename from _release/help/commands/2d_commands/CloseDir.htm rename to #Test/help/commands/2d_commands/CloseDir.htm diff --git a/_release/help/commands/2d_commands/CloseFile.htm b/#Test/help/commands/2d_commands/CloseFile.htm similarity index 100% rename from _release/help/commands/2d_commands/CloseFile.htm rename to #Test/help/commands/2d_commands/CloseFile.htm diff --git a/_release/help/commands/2d_commands/CloseTCPServer.htm b/#Test/help/commands/2d_commands/CloseTCPServer.htm similarity index 100% rename from _release/help/commands/2d_commands/CloseTCPServer.htm rename to #Test/help/commands/2d_commands/CloseTCPServer.htm diff --git a/_release/help/commands/2d_commands/CloseTCPStream.htm b/#Test/help/commands/2d_commands/CloseTCPStream.htm similarity index 100% rename from _release/help/commands/2d_commands/CloseTCPStream.htm rename to #Test/help/commands/2d_commands/CloseTCPStream.htm diff --git a/_release/help/commands/2d_commands/Cls.htm b/#Test/help/commands/2d_commands/Cls.htm similarity index 100% rename from _release/help/commands/2d_commands/Cls.htm rename to #Test/help/commands/2d_commands/Cls.htm diff --git a/_release/help/commands/2d_commands/ClsColor.htm b/#Test/help/commands/2d_commands/ClsColor.htm similarity index 100% rename from _release/help/commands/2d_commands/ClsColor.htm rename to #Test/help/commands/2d_commands/ClsColor.htm diff --git a/_release/help/commands/2d_commands/Color.htm b/#Test/help/commands/2d_commands/Color.htm similarity index 100% rename from _release/help/commands/2d_commands/Color.htm rename to #Test/help/commands/2d_commands/Color.htm diff --git a/_release/help/commands/2d_commands/ColorBlue.htm b/#Test/help/commands/2d_commands/ColorBlue.htm similarity index 100% rename from _release/help/commands/2d_commands/ColorBlue.htm rename to #Test/help/commands/2d_commands/ColorBlue.htm diff --git a/_release/help/commands/2d_commands/ColorGreen.htm b/#Test/help/commands/2d_commands/ColorGreen.htm similarity index 100% rename from _release/help/commands/2d_commands/ColorGreen.htm rename to #Test/help/commands/2d_commands/ColorGreen.htm diff --git a/_release/help/commands/2d_commands/ColorRed.htm b/#Test/help/commands/2d_commands/ColorRed.htm similarity index 100% rename from _release/help/commands/2d_commands/ColorRed.htm rename to #Test/help/commands/2d_commands/ColorRed.htm diff --git a/_release/help/commands/2d_commands/CommandLine.htm b/#Test/help/commands/2d_commands/CommandLine.htm similarity index 100% rename from _release/help/commands/2d_commands/CommandLine.htm rename to #Test/help/commands/2d_commands/CommandLine.htm diff --git a/_release/help/commands/2d_commands/Const.htm b/#Test/help/commands/2d_commands/Const.htm similarity index 100% rename from _release/help/commands/2d_commands/Const.htm rename to #Test/help/commands/2d_commands/Const.htm diff --git a/_release/help/commands/2d_commands/CopyBank.htm b/#Test/help/commands/2d_commands/CopyBank.htm similarity index 100% rename from _release/help/commands/2d_commands/CopyBank.htm rename to #Test/help/commands/2d_commands/CopyBank.htm diff --git a/_release/help/commands/2d_commands/CopyFile.htm b/#Test/help/commands/2d_commands/CopyFile.htm similarity index 100% rename from _release/help/commands/2d_commands/CopyFile.htm rename to #Test/help/commands/2d_commands/CopyFile.htm diff --git a/_release/help/commands/2d_commands/CopyImage.htm b/#Test/help/commands/2d_commands/CopyImage.htm similarity index 100% rename from _release/help/commands/2d_commands/CopyImage.htm rename to #Test/help/commands/2d_commands/CopyImage.htm diff --git a/_release/help/commands/2d_commands/CopyPixel.htm b/#Test/help/commands/2d_commands/CopyPixel.htm similarity index 100% rename from _release/help/commands/2d_commands/CopyPixel.htm rename to #Test/help/commands/2d_commands/CopyPixel.htm diff --git a/_release/help/commands/2d_commands/CopyPixelFast.htm b/#Test/help/commands/2d_commands/CopyPixelFast.htm similarity index 100% rename from _release/help/commands/2d_commands/CopyPixelFast.htm rename to #Test/help/commands/2d_commands/CopyPixelFast.htm diff --git a/_release/help/commands/2d_commands/CopyRect.htm b/#Test/help/commands/2d_commands/CopyRect.htm similarity index 100% rename from _release/help/commands/2d_commands/CopyRect.htm rename to #Test/help/commands/2d_commands/CopyRect.htm diff --git a/_release/help/commands/2d_commands/CopyStream.htm b/#Test/help/commands/2d_commands/CopyStream.htm similarity index 100% rename from _release/help/commands/2d_commands/CopyStream.htm rename to #Test/help/commands/2d_commands/CopyStream.htm diff --git a/_release/help/commands/2d_commands/Cos.htm b/#Test/help/commands/2d_commands/Cos.htm similarity index 100% rename from _release/help/commands/2d_commands/Cos.htm rename to #Test/help/commands/2d_commands/Cos.htm diff --git a/_release/help/commands/2d_commands/CountGFXModes.htm b/#Test/help/commands/2d_commands/CountGFXModes.htm similarity index 100% rename from _release/help/commands/2d_commands/CountGFXModes.htm rename to #Test/help/commands/2d_commands/CountGFXModes.htm diff --git a/_release/help/commands/2d_commands/CountGfxDrivers.htm b/#Test/help/commands/2d_commands/CountGfxDrivers.htm similarity index 100% rename from _release/help/commands/2d_commands/CountGfxDrivers.htm rename to #Test/help/commands/2d_commands/CountGfxDrivers.htm diff --git a/_release/help/commands/2d_commands/CreateBank.htm b/#Test/help/commands/2d_commands/CreateBank.htm similarity index 100% rename from _release/help/commands/2d_commands/CreateBank.htm rename to #Test/help/commands/2d_commands/CreateBank.htm diff --git a/_release/help/commands/2d_commands/CreateDir.htm b/#Test/help/commands/2d_commands/CreateDir.htm similarity index 100% rename from _release/help/commands/2d_commands/CreateDir.htm rename to #Test/help/commands/2d_commands/CreateDir.htm diff --git a/_release/help/commands/2d_commands/CreateImage.htm b/#Test/help/commands/2d_commands/CreateImage.htm similarity index 100% rename from _release/help/commands/2d_commands/CreateImage.htm rename to #Test/help/commands/2d_commands/CreateImage.htm diff --git a/_release/help/commands/2d_commands/CreateNetPlayer.htm b/#Test/help/commands/2d_commands/CreateNetPlayer.htm similarity index 100% rename from _release/help/commands/2d_commands/CreateNetPlayer.htm rename to #Test/help/commands/2d_commands/CreateNetPlayer.htm diff --git a/_release/help/commands/2d_commands/CreateTCPServer.htm b/#Test/help/commands/2d_commands/CreateTCPServer.htm similarity index 100% rename from _release/help/commands/2d_commands/CreateTCPServer.htm rename to #Test/help/commands/2d_commands/CreateTCPServer.htm diff --git a/_release/help/commands/2d_commands/CreateTimer.htm b/#Test/help/commands/2d_commands/CreateTimer.htm similarity index 100% rename from _release/help/commands/2d_commands/CreateTimer.htm rename to #Test/help/commands/2d_commands/CreateTimer.htm diff --git a/_release/help/commands/2d_commands/CurrentDate.htm b/#Test/help/commands/2d_commands/CurrentDate.htm similarity index 100% rename from _release/help/commands/2d_commands/CurrentDate.htm rename to #Test/help/commands/2d_commands/CurrentDate.htm diff --git a/_release/help/commands/2d_commands/CurrentDir.htm b/#Test/help/commands/2d_commands/CurrentDir.htm similarity index 100% rename from _release/help/commands/2d_commands/CurrentDir.htm rename to #Test/help/commands/2d_commands/CurrentDir.htm diff --git a/_release/help/commands/2d_commands/CurrentTime.htm b/#Test/help/commands/2d_commands/CurrentTime.htm similarity index 100% rename from _release/help/commands/2d_commands/CurrentTime.htm rename to #Test/help/commands/2d_commands/CurrentTime.htm diff --git a/_release/help/commands/2d_commands/Data.htm b/#Test/help/commands/2d_commands/Data.htm similarity index 100% rename from _release/help/commands/2d_commands/Data.htm rename to #Test/help/commands/2d_commands/Data.htm diff --git a/_release/help/commands/2d_commands/DebugLog.htm b/#Test/help/commands/2d_commands/DebugLog.htm similarity index 100% rename from _release/help/commands/2d_commands/DebugLog.htm rename to #Test/help/commands/2d_commands/DebugLog.htm diff --git a/_release/help/commands/2d_commands/Default.htm b/#Test/help/commands/2d_commands/Default.htm similarity index 100% rename from _release/help/commands/2d_commands/Default.htm rename to #Test/help/commands/2d_commands/Default.htm diff --git a/_release/help/commands/2d_commands/Delay.htm b/#Test/help/commands/2d_commands/Delay.htm similarity index 100% rename from _release/help/commands/2d_commands/Delay.htm rename to #Test/help/commands/2d_commands/Delay.htm diff --git a/_release/help/commands/2d_commands/Delete.htm b/#Test/help/commands/2d_commands/Delete.htm similarity index 100% rename from _release/help/commands/2d_commands/Delete.htm rename to #Test/help/commands/2d_commands/Delete.htm diff --git a/_release/help/commands/2d_commands/DeleteDir.htm b/#Test/help/commands/2d_commands/DeleteDir.htm similarity index 100% rename from _release/help/commands/2d_commands/DeleteDir.htm rename to #Test/help/commands/2d_commands/DeleteDir.htm diff --git a/_release/help/commands/2d_commands/DeleteFile.htm b/#Test/help/commands/2d_commands/DeleteFile.htm similarity index 100% rename from _release/help/commands/2d_commands/DeleteFile.htm rename to #Test/help/commands/2d_commands/DeleteFile.htm diff --git a/_release/help/commands/2d_commands/DeleteNetPlayer.htm b/#Test/help/commands/2d_commands/DeleteNetPlayer.htm similarity index 100% rename from _release/help/commands/2d_commands/DeleteNetPlayer.htm rename to #Test/help/commands/2d_commands/DeleteNetPlayer.htm diff --git a/_release/help/commands/2d_commands/Dim.htm b/#Test/help/commands/2d_commands/Dim.htm similarity index 100% rename from _release/help/commands/2d_commands/Dim.htm rename to #Test/help/commands/2d_commands/Dim.htm diff --git a/_release/help/commands/2d_commands/DrawBlock.htm b/#Test/help/commands/2d_commands/DrawBlock.htm similarity index 100% rename from _release/help/commands/2d_commands/DrawBlock.htm rename to #Test/help/commands/2d_commands/DrawBlock.htm diff --git a/_release/help/commands/2d_commands/DrawBlockRect.htm b/#Test/help/commands/2d_commands/DrawBlockRect.htm similarity index 100% rename from _release/help/commands/2d_commands/DrawBlockRect.htm rename to #Test/help/commands/2d_commands/DrawBlockRect.htm diff --git a/_release/help/commands/2d_commands/DrawImage.htm b/#Test/help/commands/2d_commands/DrawImage.htm similarity index 100% rename from _release/help/commands/2d_commands/DrawImage.htm rename to #Test/help/commands/2d_commands/DrawImage.htm diff --git a/_release/help/commands/2d_commands/DrawImageRect.htm b/#Test/help/commands/2d_commands/DrawImageRect.htm similarity index 100% rename from _release/help/commands/2d_commands/DrawImageRect.htm rename to #Test/help/commands/2d_commands/DrawImageRect.htm diff --git a/_release/help/commands/2d_commands/EOF.htm b/#Test/help/commands/2d_commands/EOF.htm similarity index 100% rename from _release/help/commands/2d_commands/EOF.htm rename to #Test/help/commands/2d_commands/EOF.htm diff --git a/_release/help/commands/2d_commands/Each.htm b/#Test/help/commands/2d_commands/Each.htm similarity index 100% rename from _release/help/commands/2d_commands/Each.htm rename to #Test/help/commands/2d_commands/Each.htm diff --git a/_release/help/commands/2d_commands/Else If.htm b/#Test/help/commands/2d_commands/Else If.htm similarity index 100% rename from _release/help/commands/2d_commands/Else If.htm rename to #Test/help/commands/2d_commands/Else If.htm diff --git a/_release/help/commands/2d_commands/Else.htm b/#Test/help/commands/2d_commands/Else.htm similarity index 100% rename from _release/help/commands/2d_commands/Else.htm rename to #Test/help/commands/2d_commands/Else.htm diff --git a/_release/help/commands/2d_commands/ElseIf.htm b/#Test/help/commands/2d_commands/ElseIf.htm similarity index 100% rename from _release/help/commands/2d_commands/ElseIf.htm rename to #Test/help/commands/2d_commands/ElseIf.htm diff --git a/_release/help/commands/2d_commands/End Function.htm b/#Test/help/commands/2d_commands/End Function.htm similarity index 100% rename from _release/help/commands/2d_commands/End Function.htm rename to #Test/help/commands/2d_commands/End Function.htm diff --git a/_release/help/commands/2d_commands/End If.htm b/#Test/help/commands/2d_commands/End If.htm similarity index 100% rename from _release/help/commands/2d_commands/End If.htm rename to #Test/help/commands/2d_commands/End If.htm diff --git a/_release/help/commands/2d_commands/End Select.htm b/#Test/help/commands/2d_commands/End Select.htm similarity index 100% rename from _release/help/commands/2d_commands/End Select.htm rename to #Test/help/commands/2d_commands/End Select.htm diff --git a/_release/help/commands/2d_commands/End Type.htm b/#Test/help/commands/2d_commands/End Type.htm similarity index 100% rename from _release/help/commands/2d_commands/End Type.htm rename to #Test/help/commands/2d_commands/End Type.htm diff --git a/_release/help/commands/2d_commands/End.htm b/#Test/help/commands/2d_commands/End.htm similarity index 100% rename from _release/help/commands/2d_commands/End.htm rename to #Test/help/commands/2d_commands/End.htm diff --git a/_release/help/commands/2d_commands/EndGraphics.htm b/#Test/help/commands/2d_commands/EndGraphics.htm similarity index 100% rename from _release/help/commands/2d_commands/EndGraphics.htm rename to #Test/help/commands/2d_commands/EndGraphics.htm diff --git a/_release/help/commands/2d_commands/EndIF.htm b/#Test/help/commands/2d_commands/EndIF.htm similarity index 100% rename from _release/help/commands/2d_commands/EndIF.htm rename to #Test/help/commands/2d_commands/EndIF.htm diff --git a/_release/help/commands/2d_commands/ExecFile.htm b/#Test/help/commands/2d_commands/ExecFile.htm similarity index 100% rename from _release/help/commands/2d_commands/ExecFile.htm rename to #Test/help/commands/2d_commands/ExecFile.htm diff --git a/_release/help/commands/2d_commands/Exit.htm b/#Test/help/commands/2d_commands/Exit.htm similarity index 100% rename from _release/help/commands/2d_commands/Exit.htm rename to #Test/help/commands/2d_commands/Exit.htm diff --git a/_release/help/commands/2d_commands/Exp.htm b/#Test/help/commands/2d_commands/Exp.htm similarity index 100% rename from _release/help/commands/2d_commands/Exp.htm rename to #Test/help/commands/2d_commands/Exp.htm diff --git a/_release/help/commands/2d_commands/False.htm b/#Test/help/commands/2d_commands/False.htm similarity index 100% rename from _release/help/commands/2d_commands/False.htm rename to #Test/help/commands/2d_commands/False.htm diff --git a/_release/help/commands/2d_commands/Field.htm b/#Test/help/commands/2d_commands/Field.htm similarity index 100% rename from _release/help/commands/2d_commands/Field.htm rename to #Test/help/commands/2d_commands/Field.htm diff --git a/_release/help/commands/2d_commands/FilePos.htm b/#Test/help/commands/2d_commands/FilePos.htm similarity index 100% rename from _release/help/commands/2d_commands/FilePos.htm rename to #Test/help/commands/2d_commands/FilePos.htm diff --git a/_release/help/commands/2d_commands/FileSize.htm b/#Test/help/commands/2d_commands/FileSize.htm similarity index 100% rename from _release/help/commands/2d_commands/FileSize.htm rename to #Test/help/commands/2d_commands/FileSize.htm diff --git a/_release/help/commands/2d_commands/FileType.htm b/#Test/help/commands/2d_commands/FileType.htm similarity index 100% rename from _release/help/commands/2d_commands/FileType.htm rename to #Test/help/commands/2d_commands/FileType.htm diff --git a/_release/help/commands/2d_commands/FindGfxMode.htm b/#Test/help/commands/2d_commands/FindGfxMode.htm similarity index 100% rename from _release/help/commands/2d_commands/FindGfxMode.htm rename to #Test/help/commands/2d_commands/FindGfxMode.htm diff --git a/_release/help/commands/2d_commands/First.htm b/#Test/help/commands/2d_commands/First.htm similarity index 100% rename from _release/help/commands/2d_commands/First.htm rename to #Test/help/commands/2d_commands/First.htm diff --git a/_release/help/commands/2d_commands/Flip.htm b/#Test/help/commands/2d_commands/Flip.htm similarity index 100% rename from _release/help/commands/2d_commands/Flip.htm rename to #Test/help/commands/2d_commands/Flip.htm diff --git a/_release/help/commands/2d_commands/Float.htm b/#Test/help/commands/2d_commands/Float.htm similarity index 100% rename from _release/help/commands/2d_commands/Float.htm rename to #Test/help/commands/2d_commands/Float.htm diff --git a/_release/help/commands/2d_commands/Floor.htm b/#Test/help/commands/2d_commands/Floor.htm similarity index 100% rename from _release/help/commands/2d_commands/Floor.htm rename to #Test/help/commands/2d_commands/Floor.htm diff --git a/_release/help/commands/2d_commands/FlushJoy.htm b/#Test/help/commands/2d_commands/FlushJoy.htm similarity index 100% rename from _release/help/commands/2d_commands/FlushJoy.htm rename to #Test/help/commands/2d_commands/FlushJoy.htm diff --git a/_release/help/commands/2d_commands/FlushKeys.htm b/#Test/help/commands/2d_commands/FlushKeys.htm similarity index 100% rename from _release/help/commands/2d_commands/FlushKeys.htm rename to #Test/help/commands/2d_commands/FlushKeys.htm diff --git a/_release/help/commands/2d_commands/FlushMouse.htm b/#Test/help/commands/2d_commands/FlushMouse.htm similarity index 100% rename from _release/help/commands/2d_commands/FlushMouse.htm rename to #Test/help/commands/2d_commands/FlushMouse.htm diff --git a/_release/help/commands/2d_commands/FontHeight.htm b/#Test/help/commands/2d_commands/FontHeight.htm similarity index 100% rename from _release/help/commands/2d_commands/FontHeight.htm rename to #Test/help/commands/2d_commands/FontHeight.htm diff --git a/_release/help/commands/2d_commands/FontWidth.htm b/#Test/help/commands/2d_commands/FontWidth.htm similarity index 100% rename from _release/help/commands/2d_commands/FontWidth.htm rename to #Test/help/commands/2d_commands/FontWidth.htm diff --git a/_release/help/commands/2d_commands/For.htm b/#Test/help/commands/2d_commands/For.htm similarity index 100% rename from _release/help/commands/2d_commands/For.htm rename to #Test/help/commands/2d_commands/For.htm diff --git a/_release/help/commands/2d_commands/Forever.htm b/#Test/help/commands/2d_commands/Forever.htm similarity index 100% rename from _release/help/commands/2d_commands/Forever.htm rename to #Test/help/commands/2d_commands/Forever.htm diff --git a/_release/help/commands/2d_commands/FreeBank.htm b/#Test/help/commands/2d_commands/FreeBank.htm similarity index 100% rename from _release/help/commands/2d_commands/FreeBank.htm rename to #Test/help/commands/2d_commands/FreeBank.htm diff --git a/_release/help/commands/2d_commands/FreeFont.htm b/#Test/help/commands/2d_commands/FreeFont.htm similarity index 100% rename from _release/help/commands/2d_commands/FreeFont.htm rename to #Test/help/commands/2d_commands/FreeFont.htm diff --git a/_release/help/commands/2d_commands/FreeImage.htm b/#Test/help/commands/2d_commands/FreeImage.htm similarity index 100% rename from _release/help/commands/2d_commands/FreeImage.htm rename to #Test/help/commands/2d_commands/FreeImage.htm diff --git a/_release/help/commands/2d_commands/FreeSound.htm b/#Test/help/commands/2d_commands/FreeSound.htm similarity index 100% rename from _release/help/commands/2d_commands/FreeSound.htm rename to #Test/help/commands/2d_commands/FreeSound.htm diff --git a/_release/help/commands/2d_commands/FreeTimer.htm b/#Test/help/commands/2d_commands/FreeTimer.htm similarity index 100% rename from _release/help/commands/2d_commands/FreeTimer.htm rename to #Test/help/commands/2d_commands/FreeTimer.htm diff --git a/_release/help/commands/2d_commands/FrontBuffer.htm b/#Test/help/commands/2d_commands/FrontBuffer.htm similarity index 100% rename from _release/help/commands/2d_commands/FrontBuffer.htm rename to #Test/help/commands/2d_commands/FrontBuffer.htm diff --git a/_release/help/commands/2d_commands/Function.htm b/#Test/help/commands/2d_commands/Function.htm similarity index 100% rename from _release/help/commands/2d_commands/Function.htm rename to #Test/help/commands/2d_commands/Function.htm diff --git a/_release/help/commands/2d_commands/GFXModeDepth.htm b/#Test/help/commands/2d_commands/GFXModeDepth.htm similarity index 100% rename from _release/help/commands/2d_commands/GFXModeDepth.htm rename to #Test/help/commands/2d_commands/GFXModeDepth.htm diff --git a/_release/help/commands/2d_commands/GFXModeHeight.htm b/#Test/help/commands/2d_commands/GFXModeHeight.htm similarity index 100% rename from _release/help/commands/2d_commands/GFXModeHeight.htm rename to #Test/help/commands/2d_commands/GFXModeHeight.htm diff --git a/_release/help/commands/2d_commands/GFXModeWidth.htm b/#Test/help/commands/2d_commands/GFXModeWidth.htm similarity index 100% rename from _release/help/commands/2d_commands/GFXModeWidth.htm rename to #Test/help/commands/2d_commands/GFXModeWidth.htm diff --git a/_release/help/commands/2d_commands/GetColor.htm b/#Test/help/commands/2d_commands/GetColor.htm similarity index 100% rename from _release/help/commands/2d_commands/GetColor.htm rename to #Test/help/commands/2d_commands/GetColor.htm diff --git a/_release/help/commands/2d_commands/GetJoy.htm b/#Test/help/commands/2d_commands/GetJoy.htm similarity index 100% rename from _release/help/commands/2d_commands/GetJoy.htm rename to #Test/help/commands/2d_commands/GetJoy.htm diff --git a/_release/help/commands/2d_commands/GetKey.htm b/#Test/help/commands/2d_commands/GetKey.htm similarity index 100% rename from _release/help/commands/2d_commands/GetKey.htm rename to #Test/help/commands/2d_commands/GetKey.htm diff --git a/_release/help/commands/2d_commands/GetMouse.htm b/#Test/help/commands/2d_commands/GetMouse.htm similarity index 100% rename from _release/help/commands/2d_commands/GetMouse.htm rename to #Test/help/commands/2d_commands/GetMouse.htm diff --git a/_release/help/commands/2d_commands/GfxDriverName.htm b/#Test/help/commands/2d_commands/GfxDriverName.htm similarity index 100% rename from _release/help/commands/2d_commands/GfxDriverName.htm rename to #Test/help/commands/2d_commands/GfxDriverName.htm diff --git a/_release/help/commands/2d_commands/GfxModeExists.htm b/#Test/help/commands/2d_commands/GfxModeExists.htm similarity index 100% rename from _release/help/commands/2d_commands/GfxModeExists.htm rename to #Test/help/commands/2d_commands/GfxModeExists.htm diff --git a/_release/help/commands/2d_commands/Global.htm b/#Test/help/commands/2d_commands/Global.htm similarity index 100% rename from _release/help/commands/2d_commands/Global.htm rename to #Test/help/commands/2d_commands/Global.htm diff --git a/_release/help/commands/2d_commands/Gosub.htm b/#Test/help/commands/2d_commands/Gosub.htm similarity index 100% rename from _release/help/commands/2d_commands/Gosub.htm rename to #Test/help/commands/2d_commands/Gosub.htm diff --git a/_release/help/commands/2d_commands/Goto.htm b/#Test/help/commands/2d_commands/Goto.htm similarity index 100% rename from _release/help/commands/2d_commands/Goto.htm rename to #Test/help/commands/2d_commands/Goto.htm diff --git a/_release/help/commands/2d_commands/GrabImage.htm b/#Test/help/commands/2d_commands/GrabImage.htm similarity index 100% rename from _release/help/commands/2d_commands/GrabImage.htm rename to #Test/help/commands/2d_commands/GrabImage.htm diff --git a/_release/help/commands/2d_commands/Graphics.htm b/#Test/help/commands/2d_commands/Graphics.htm similarity index 100% rename from _release/help/commands/2d_commands/Graphics.htm rename to #Test/help/commands/2d_commands/Graphics.htm diff --git a/_release/help/commands/2d_commands/GraphicsBuffer.htm b/#Test/help/commands/2d_commands/GraphicsBuffer.htm similarity index 100% rename from _release/help/commands/2d_commands/GraphicsBuffer.htm rename to #Test/help/commands/2d_commands/GraphicsBuffer.htm diff --git a/_release/help/commands/2d_commands/GraphicsDepth.htm b/#Test/help/commands/2d_commands/GraphicsDepth.htm similarity index 100% rename from _release/help/commands/2d_commands/GraphicsDepth.htm rename to #Test/help/commands/2d_commands/GraphicsDepth.htm diff --git a/_release/help/commands/2d_commands/GraphicsHeight.htm b/#Test/help/commands/2d_commands/GraphicsHeight.htm similarity index 100% rename from _release/help/commands/2d_commands/GraphicsHeight.htm rename to #Test/help/commands/2d_commands/GraphicsHeight.htm diff --git a/_release/help/commands/2d_commands/GraphicsWidth.htm b/#Test/help/commands/2d_commands/GraphicsWidth.htm similarity index 100% rename from _release/help/commands/2d_commands/GraphicsWidth.htm rename to #Test/help/commands/2d_commands/GraphicsWidth.htm diff --git a/_release/help/commands/2d_commands/HandleImage.htm b/#Test/help/commands/2d_commands/HandleImage.htm similarity index 100% rename from _release/help/commands/2d_commands/HandleImage.htm rename to #Test/help/commands/2d_commands/HandleImage.htm diff --git a/_release/help/commands/2d_commands/Hex.htm b/#Test/help/commands/2d_commands/Hex.htm similarity index 100% rename from _release/help/commands/2d_commands/Hex.htm rename to #Test/help/commands/2d_commands/Hex.htm diff --git a/_release/help/commands/2d_commands/HidePointer.htm b/#Test/help/commands/2d_commands/HidePointer.htm similarity index 100% rename from _release/help/commands/2d_commands/HidePointer.htm rename to #Test/help/commands/2d_commands/HidePointer.htm diff --git a/_release/help/commands/2d_commands/HostNetGame.htm b/#Test/help/commands/2d_commands/HostNetGame.htm similarity index 100% rename from _release/help/commands/2d_commands/HostNetGame.htm rename to #Test/help/commands/2d_commands/HostNetGame.htm diff --git a/_release/help/commands/2d_commands/If.htm b/#Test/help/commands/2d_commands/If.htm similarity index 100% rename from _release/help/commands/2d_commands/If.htm rename to #Test/help/commands/2d_commands/If.htm diff --git a/_release/help/commands/2d_commands/ImageBuffer.htm b/#Test/help/commands/2d_commands/ImageBuffer.htm similarity index 100% rename from _release/help/commands/2d_commands/ImageBuffer.htm rename to #Test/help/commands/2d_commands/ImageBuffer.htm diff --git a/_release/help/commands/2d_commands/ImageHeight.htm b/#Test/help/commands/2d_commands/ImageHeight.htm similarity index 100% rename from _release/help/commands/2d_commands/ImageHeight.htm rename to #Test/help/commands/2d_commands/ImageHeight.htm diff --git a/_release/help/commands/2d_commands/ImageRectCollide.htm b/#Test/help/commands/2d_commands/ImageRectCollide.htm similarity index 100% rename from _release/help/commands/2d_commands/ImageRectCollide.htm rename to #Test/help/commands/2d_commands/ImageRectCollide.htm diff --git a/_release/help/commands/2d_commands/ImageRectOverlap.htm b/#Test/help/commands/2d_commands/ImageRectOverlap.htm similarity index 100% rename from _release/help/commands/2d_commands/ImageRectOverlap.htm rename to #Test/help/commands/2d_commands/ImageRectOverlap.htm diff --git a/_release/help/commands/2d_commands/ImageWidth.htm b/#Test/help/commands/2d_commands/ImageWidth.htm similarity index 100% rename from _release/help/commands/2d_commands/ImageWidth.htm rename to #Test/help/commands/2d_commands/ImageWidth.htm diff --git a/_release/help/commands/2d_commands/ImageXHandle.htm b/#Test/help/commands/2d_commands/ImageXHandle.htm similarity index 100% rename from _release/help/commands/2d_commands/ImageXHandle.htm rename to #Test/help/commands/2d_commands/ImageXHandle.htm diff --git a/_release/help/commands/2d_commands/ImageYHandle.htm b/#Test/help/commands/2d_commands/ImageYHandle.htm similarity index 100% rename from _release/help/commands/2d_commands/ImageYHandle.htm rename to #Test/help/commands/2d_commands/ImageYHandle.htm diff --git a/_release/help/commands/2d_commands/ImagesCollide.htm b/#Test/help/commands/2d_commands/ImagesCollide.htm similarity index 100% rename from _release/help/commands/2d_commands/ImagesCollide.htm rename to #Test/help/commands/2d_commands/ImagesCollide.htm diff --git a/_release/help/commands/2d_commands/ImagesOverlap.htm b/#Test/help/commands/2d_commands/ImagesOverlap.htm similarity index 100% rename from _release/help/commands/2d_commands/ImagesOverlap.htm rename to #Test/help/commands/2d_commands/ImagesOverlap.htm diff --git a/_release/help/commands/2d_commands/Include.htm b/#Test/help/commands/2d_commands/Include.htm similarity index 100% rename from _release/help/commands/2d_commands/Include.htm rename to #Test/help/commands/2d_commands/Include.htm diff --git a/_release/help/commands/2d_commands/Input.htm b/#Test/help/commands/2d_commands/Input.htm similarity index 100% rename from _release/help/commands/2d_commands/Input.htm rename to #Test/help/commands/2d_commands/Input.htm diff --git a/_release/help/commands/2d_commands/Insert.htm b/#Test/help/commands/2d_commands/Insert.htm similarity index 100% rename from _release/help/commands/2d_commands/Insert.htm rename to #Test/help/commands/2d_commands/Insert.htm diff --git a/_release/help/commands/2d_commands/Instr.htm b/#Test/help/commands/2d_commands/Instr.htm similarity index 100% rename from _release/help/commands/2d_commands/Instr.htm rename to #Test/help/commands/2d_commands/Instr.htm diff --git a/_release/help/commands/2d_commands/Int.htm b/#Test/help/commands/2d_commands/Int.htm similarity index 100% rename from _release/help/commands/2d_commands/Int.htm rename to #Test/help/commands/2d_commands/Int.htm diff --git a/_release/help/commands/2d_commands/JoinNetGame.htm b/#Test/help/commands/2d_commands/JoinNetGame.htm similarity index 100% rename from _release/help/commands/2d_commands/JoinNetGame.htm rename to #Test/help/commands/2d_commands/JoinNetGame.htm diff --git a/_release/help/commands/2d_commands/JoyDown.htm b/#Test/help/commands/2d_commands/JoyDown.htm similarity index 100% rename from _release/help/commands/2d_commands/JoyDown.htm rename to #Test/help/commands/2d_commands/JoyDown.htm diff --git a/_release/help/commands/2d_commands/JoyHit.htm b/#Test/help/commands/2d_commands/JoyHit.htm similarity index 100% rename from _release/help/commands/2d_commands/JoyHit.htm rename to #Test/help/commands/2d_commands/JoyHit.htm diff --git a/_release/help/commands/2d_commands/JoyType.htm b/#Test/help/commands/2d_commands/JoyType.htm similarity index 100% rename from _release/help/commands/2d_commands/JoyType.htm rename to #Test/help/commands/2d_commands/JoyType.htm diff --git a/_release/help/commands/2d_commands/JoyWait.htm b/#Test/help/commands/2d_commands/JoyWait.htm similarity index 100% rename from _release/help/commands/2d_commands/JoyWait.htm rename to #Test/help/commands/2d_commands/JoyWait.htm diff --git a/_release/help/commands/2d_commands/JoyX.htm b/#Test/help/commands/2d_commands/JoyX.htm similarity index 100% rename from _release/help/commands/2d_commands/JoyX.htm rename to #Test/help/commands/2d_commands/JoyX.htm diff --git a/_release/help/commands/2d_commands/JoyXDir.htm b/#Test/help/commands/2d_commands/JoyXDir.htm similarity index 100% rename from _release/help/commands/2d_commands/JoyXDir.htm rename to #Test/help/commands/2d_commands/JoyXDir.htm diff --git a/_release/help/commands/2d_commands/JoyY.htm b/#Test/help/commands/2d_commands/JoyY.htm similarity index 100% rename from _release/help/commands/2d_commands/JoyY.htm rename to #Test/help/commands/2d_commands/JoyY.htm diff --git a/_release/help/commands/2d_commands/JoyYDir.htm b/#Test/help/commands/2d_commands/JoyYDir.htm similarity index 100% rename from _release/help/commands/2d_commands/JoyYDir.htm rename to #Test/help/commands/2d_commands/JoyYDir.htm diff --git a/_release/help/commands/2d_commands/JoyZ.htm b/#Test/help/commands/2d_commands/JoyZ.htm similarity index 100% rename from _release/help/commands/2d_commands/JoyZ.htm rename to #Test/help/commands/2d_commands/JoyZ.htm diff --git a/_release/help/commands/2d_commands/JoyZDir.htm b/#Test/help/commands/2d_commands/JoyZDir.htm similarity index 100% rename from _release/help/commands/2d_commands/JoyZDir.htm rename to #Test/help/commands/2d_commands/JoyZDir.htm diff --git a/_release/help/commands/2d_commands/KeyDown.htm b/#Test/help/commands/2d_commands/KeyDown.htm similarity index 100% rename from _release/help/commands/2d_commands/KeyDown.htm rename to #Test/help/commands/2d_commands/KeyDown.htm diff --git a/_release/help/commands/2d_commands/KeyHit.htm b/#Test/help/commands/2d_commands/KeyHit.htm similarity index 100% rename from _release/help/commands/2d_commands/KeyHit.htm rename to #Test/help/commands/2d_commands/KeyHit.htm diff --git a/_release/help/commands/2d_commands/LSet.htm b/#Test/help/commands/2d_commands/LSet.htm similarity index 100% rename from _release/help/commands/2d_commands/LSet.htm rename to #Test/help/commands/2d_commands/LSet.htm diff --git a/_release/help/commands/2d_commands/Last.htm b/#Test/help/commands/2d_commands/Last.htm similarity index 100% rename from _release/help/commands/2d_commands/Last.htm rename to #Test/help/commands/2d_commands/Last.htm diff --git a/_release/help/commands/2d_commands/Left.htm b/#Test/help/commands/2d_commands/Left.htm similarity index 100% rename from _release/help/commands/2d_commands/Left.htm rename to #Test/help/commands/2d_commands/Left.htm diff --git a/_release/help/commands/2d_commands/Len.htm b/#Test/help/commands/2d_commands/Len.htm similarity index 100% rename from _release/help/commands/2d_commands/Len.htm rename to #Test/help/commands/2d_commands/Len.htm diff --git a/_release/help/commands/2d_commands/Line.htm b/#Test/help/commands/2d_commands/Line.htm similarity index 100% rename from _release/help/commands/2d_commands/Line.htm rename to #Test/help/commands/2d_commands/Line.htm diff --git a/_release/help/commands/2d_commands/LoadAnimImage.htm b/#Test/help/commands/2d_commands/LoadAnimImage.htm similarity index 100% rename from _release/help/commands/2d_commands/LoadAnimImage.htm rename to #Test/help/commands/2d_commands/LoadAnimImage.htm diff --git a/_release/help/commands/2d_commands/LoadBuffer.htm b/#Test/help/commands/2d_commands/LoadBuffer.htm similarity index 100% rename from _release/help/commands/2d_commands/LoadBuffer.htm rename to #Test/help/commands/2d_commands/LoadBuffer.htm diff --git a/_release/help/commands/2d_commands/LoadFont.htm b/#Test/help/commands/2d_commands/LoadFont.htm similarity index 100% rename from _release/help/commands/2d_commands/LoadFont.htm rename to #Test/help/commands/2d_commands/LoadFont.htm diff --git a/_release/help/commands/2d_commands/LoadImage.htm b/#Test/help/commands/2d_commands/LoadImage.htm similarity index 100% rename from _release/help/commands/2d_commands/LoadImage.htm rename to #Test/help/commands/2d_commands/LoadImage.htm diff --git a/_release/help/commands/2d_commands/LoadSound.htm b/#Test/help/commands/2d_commands/LoadSound.htm similarity index 100% rename from _release/help/commands/2d_commands/LoadSound.htm rename to #Test/help/commands/2d_commands/LoadSound.htm diff --git a/_release/help/commands/2d_commands/Local.htm b/#Test/help/commands/2d_commands/Local.htm similarity index 100% rename from _release/help/commands/2d_commands/Local.htm rename to #Test/help/commands/2d_commands/Local.htm diff --git a/_release/help/commands/2d_commands/Locate.htm b/#Test/help/commands/2d_commands/Locate.htm similarity index 100% rename from _release/help/commands/2d_commands/Locate.htm rename to #Test/help/commands/2d_commands/Locate.htm diff --git a/_release/help/commands/2d_commands/LockBuffer.htm b/#Test/help/commands/2d_commands/LockBuffer.htm similarity index 100% rename from _release/help/commands/2d_commands/LockBuffer.htm rename to #Test/help/commands/2d_commands/LockBuffer.htm diff --git a/_release/help/commands/2d_commands/Log.htm b/#Test/help/commands/2d_commands/Log.htm similarity index 100% rename from _release/help/commands/2d_commands/Log.htm rename to #Test/help/commands/2d_commands/Log.htm diff --git a/_release/help/commands/2d_commands/Log10.htm b/#Test/help/commands/2d_commands/Log10.htm similarity index 100% rename from _release/help/commands/2d_commands/Log10.htm rename to #Test/help/commands/2d_commands/Log10.htm diff --git a/_release/help/commands/2d_commands/LoopSound.htm b/#Test/help/commands/2d_commands/LoopSound.htm similarity index 100% rename from _release/help/commands/2d_commands/LoopSound.htm rename to #Test/help/commands/2d_commands/LoopSound.htm diff --git a/_release/help/commands/2d_commands/Lower.htm b/#Test/help/commands/2d_commands/Lower.htm similarity index 100% rename from _release/help/commands/2d_commands/Lower.htm rename to #Test/help/commands/2d_commands/Lower.htm diff --git a/_release/help/commands/2d_commands/MaskImage.htm b/#Test/help/commands/2d_commands/MaskImage.htm similarity index 100% rename from _release/help/commands/2d_commands/MaskImage.htm rename to #Test/help/commands/2d_commands/MaskImage.htm diff --git a/_release/help/commands/2d_commands/Mid.htm b/#Test/help/commands/2d_commands/Mid.htm similarity index 100% rename from _release/help/commands/2d_commands/Mid.htm rename to #Test/help/commands/2d_commands/Mid.htm diff --git a/_release/help/commands/2d_commands/MidHandle .htm b/#Test/help/commands/2d_commands/MidHandle .htm similarity index 100% rename from _release/help/commands/2d_commands/MidHandle .htm rename to #Test/help/commands/2d_commands/MidHandle .htm diff --git a/_release/help/commands/2d_commands/Millisecs.htm b/#Test/help/commands/2d_commands/Millisecs.htm similarity index 100% rename from _release/help/commands/2d_commands/Millisecs.htm rename to #Test/help/commands/2d_commands/Millisecs.htm diff --git a/_release/help/commands/2d_commands/Mod.htm b/#Test/help/commands/2d_commands/Mod.htm similarity index 100% rename from _release/help/commands/2d_commands/Mod.htm rename to #Test/help/commands/2d_commands/Mod.htm diff --git a/_release/help/commands/2d_commands/MouseDown.htm b/#Test/help/commands/2d_commands/MouseDown.htm similarity index 100% rename from _release/help/commands/2d_commands/MouseDown.htm rename to #Test/help/commands/2d_commands/MouseDown.htm diff --git a/_release/help/commands/2d_commands/MouseHit.htm b/#Test/help/commands/2d_commands/MouseHit.htm similarity index 100% rename from _release/help/commands/2d_commands/MouseHit.htm rename to #Test/help/commands/2d_commands/MouseHit.htm diff --git a/_release/help/commands/2d_commands/MouseWait.htm b/#Test/help/commands/2d_commands/MouseWait.htm similarity index 100% rename from _release/help/commands/2d_commands/MouseWait.htm rename to #Test/help/commands/2d_commands/MouseWait.htm diff --git a/_release/help/commands/2d_commands/MouseX.htm b/#Test/help/commands/2d_commands/MouseX.htm similarity index 100% rename from _release/help/commands/2d_commands/MouseX.htm rename to #Test/help/commands/2d_commands/MouseX.htm diff --git a/_release/help/commands/2d_commands/MouseXSpeed.htm b/#Test/help/commands/2d_commands/MouseXSpeed.htm similarity index 100% rename from _release/help/commands/2d_commands/MouseXSpeed.htm rename to #Test/help/commands/2d_commands/MouseXSpeed.htm diff --git a/_release/help/commands/2d_commands/MouseY.htm b/#Test/help/commands/2d_commands/MouseY.htm similarity index 100% rename from _release/help/commands/2d_commands/MouseY.htm rename to #Test/help/commands/2d_commands/MouseY.htm diff --git a/_release/help/commands/2d_commands/MouseYSpeed.htm b/#Test/help/commands/2d_commands/MouseYSpeed.htm similarity index 100% rename from _release/help/commands/2d_commands/MouseYSpeed.htm rename to #Test/help/commands/2d_commands/MouseYSpeed.htm diff --git a/_release/help/commands/2d_commands/MouseZ.htm b/#Test/help/commands/2d_commands/MouseZ.htm similarity index 100% rename from _release/help/commands/2d_commands/MouseZ.htm rename to #Test/help/commands/2d_commands/MouseZ.htm diff --git a/_release/help/commands/2d_commands/MouseZSpeed.htm b/#Test/help/commands/2d_commands/MouseZSpeed.htm similarity index 100% rename from _release/help/commands/2d_commands/MouseZSpeed.htm rename to #Test/help/commands/2d_commands/MouseZSpeed.htm diff --git a/_release/help/commands/2d_commands/MoveMouse.htm b/#Test/help/commands/2d_commands/MoveMouse.htm similarity index 100% rename from _release/help/commands/2d_commands/MoveMouse.htm rename to #Test/help/commands/2d_commands/MoveMouse.htm diff --git a/_release/help/commands/2d_commands/NetMsgData.htm b/#Test/help/commands/2d_commands/NetMsgData.htm similarity index 100% rename from _release/help/commands/2d_commands/NetMsgData.htm rename to #Test/help/commands/2d_commands/NetMsgData.htm diff --git a/_release/help/commands/2d_commands/NetMsgFrom().htm b/#Test/help/commands/2d_commands/NetMsgFrom().htm similarity index 100% rename from _release/help/commands/2d_commands/NetMsgFrom().htm rename to #Test/help/commands/2d_commands/NetMsgFrom().htm diff --git a/_release/help/commands/2d_commands/NetMsgTo().htm b/#Test/help/commands/2d_commands/NetMsgTo().htm similarity index 100% rename from _release/help/commands/2d_commands/NetMsgTo().htm rename to #Test/help/commands/2d_commands/NetMsgTo().htm diff --git a/_release/help/commands/2d_commands/NetMsgType().htm b/#Test/help/commands/2d_commands/NetMsgType().htm similarity index 100% rename from _release/help/commands/2d_commands/NetMsgType().htm rename to #Test/help/commands/2d_commands/NetMsgType().htm diff --git a/_release/help/commands/2d_commands/NetPlayerLocal.htm b/#Test/help/commands/2d_commands/NetPlayerLocal.htm similarity index 100% rename from _release/help/commands/2d_commands/NetPlayerLocal.htm rename to #Test/help/commands/2d_commands/NetPlayerLocal.htm diff --git a/_release/help/commands/2d_commands/NetPlayerName.htm b/#Test/help/commands/2d_commands/NetPlayerName.htm similarity index 100% rename from _release/help/commands/2d_commands/NetPlayerName.htm rename to #Test/help/commands/2d_commands/NetPlayerName.htm diff --git a/_release/help/commands/2d_commands/New.htm b/#Test/help/commands/2d_commands/New.htm similarity index 100% rename from _release/help/commands/2d_commands/New.htm rename to #Test/help/commands/2d_commands/New.htm diff --git a/_release/help/commands/2d_commands/Next.htm b/#Test/help/commands/2d_commands/Next.htm similarity index 100% rename from _release/help/commands/2d_commands/Next.htm rename to #Test/help/commands/2d_commands/Next.htm diff --git a/_release/help/commands/2d_commands/NextFile.htm b/#Test/help/commands/2d_commands/NextFile.htm similarity index 100% rename from _release/help/commands/2d_commands/NextFile.htm rename to #Test/help/commands/2d_commands/NextFile.htm diff --git a/_release/help/commands/2d_commands/Not.htm b/#Test/help/commands/2d_commands/Not.htm similarity index 100% rename from _release/help/commands/2d_commands/Not.htm rename to #Test/help/commands/2d_commands/Not.htm diff --git a/_release/help/commands/2d_commands/Null.htm b/#Test/help/commands/2d_commands/Null.htm similarity index 100% rename from _release/help/commands/2d_commands/Null.htm rename to #Test/help/commands/2d_commands/Null.htm diff --git a/_release/help/commands/2d_commands/OpenFile.htm b/#Test/help/commands/2d_commands/OpenFile.htm similarity index 100% rename from _release/help/commands/2d_commands/OpenFile.htm rename to #Test/help/commands/2d_commands/OpenFile.htm diff --git a/_release/help/commands/2d_commands/OpenTCPStream.htm b/#Test/help/commands/2d_commands/OpenTCPStream.htm similarity index 100% rename from _release/help/commands/2d_commands/OpenTCPStream.htm rename to #Test/help/commands/2d_commands/OpenTCPStream.htm diff --git a/_release/help/commands/2d_commands/Or.htm b/#Test/help/commands/2d_commands/Or.htm similarity index 100% rename from _release/help/commands/2d_commands/Or.htm rename to #Test/help/commands/2d_commands/Or.htm diff --git a/_release/help/commands/2d_commands/Origin.htm b/#Test/help/commands/2d_commands/Origin.htm similarity index 100% rename from _release/help/commands/2d_commands/Origin.htm rename to #Test/help/commands/2d_commands/Origin.htm diff --git a/_release/help/commands/2d_commands/Oval.htm b/#Test/help/commands/2d_commands/Oval.htm similarity index 100% rename from _release/help/commands/2d_commands/Oval.htm rename to #Test/help/commands/2d_commands/Oval.htm diff --git a/_release/help/commands/2d_commands/PauseChannel.htm b/#Test/help/commands/2d_commands/PauseChannel.htm similarity index 100% rename from _release/help/commands/2d_commands/PauseChannel.htm rename to #Test/help/commands/2d_commands/PauseChannel.htm diff --git a/_release/help/commands/2d_commands/PeekByte.htm b/#Test/help/commands/2d_commands/PeekByte.htm similarity index 100% rename from _release/help/commands/2d_commands/PeekByte.htm rename to #Test/help/commands/2d_commands/PeekByte.htm diff --git a/_release/help/commands/2d_commands/PeekFloat.htm b/#Test/help/commands/2d_commands/PeekFloat.htm similarity index 100% rename from _release/help/commands/2d_commands/PeekFloat.htm rename to #Test/help/commands/2d_commands/PeekFloat.htm diff --git a/_release/help/commands/2d_commands/PeekInt.htm b/#Test/help/commands/2d_commands/PeekInt.htm similarity index 100% rename from _release/help/commands/2d_commands/PeekInt.htm rename to #Test/help/commands/2d_commands/PeekInt.htm diff --git a/_release/help/commands/2d_commands/PeekShort.htm b/#Test/help/commands/2d_commands/PeekShort.htm similarity index 100% rename from _release/help/commands/2d_commands/PeekShort.htm rename to #Test/help/commands/2d_commands/PeekShort.htm diff --git a/_release/help/commands/2d_commands/Pi.htm b/#Test/help/commands/2d_commands/Pi.htm similarity index 100% rename from _release/help/commands/2d_commands/Pi.htm rename to #Test/help/commands/2d_commands/Pi.htm diff --git a/_release/help/commands/2d_commands/PlayCDTrack.htm b/#Test/help/commands/2d_commands/PlayCDTrack.htm similarity index 100% rename from _release/help/commands/2d_commands/PlayCDTrack.htm rename to #Test/help/commands/2d_commands/PlayCDTrack.htm diff --git a/_release/help/commands/2d_commands/PlayMusic.htm b/#Test/help/commands/2d_commands/PlayMusic.htm similarity index 100% rename from _release/help/commands/2d_commands/PlayMusic.htm rename to #Test/help/commands/2d_commands/PlayMusic.htm diff --git a/_release/help/commands/2d_commands/PlaySound.htm b/#Test/help/commands/2d_commands/PlaySound.htm similarity index 100% rename from _release/help/commands/2d_commands/PlaySound.htm rename to #Test/help/commands/2d_commands/PlaySound.htm diff --git a/_release/help/commands/2d_commands/Plot.htm b/#Test/help/commands/2d_commands/Plot.htm similarity index 100% rename from _release/help/commands/2d_commands/Plot.htm rename to #Test/help/commands/2d_commands/Plot.htm diff --git a/_release/help/commands/2d_commands/PokeByte.htm b/#Test/help/commands/2d_commands/PokeByte.htm similarity index 100% rename from _release/help/commands/2d_commands/PokeByte.htm rename to #Test/help/commands/2d_commands/PokeByte.htm diff --git a/_release/help/commands/2d_commands/PokeFloat.htm b/#Test/help/commands/2d_commands/PokeFloat.htm similarity index 100% rename from _release/help/commands/2d_commands/PokeFloat.htm rename to #Test/help/commands/2d_commands/PokeFloat.htm diff --git a/_release/help/commands/2d_commands/PokeInt.htm b/#Test/help/commands/2d_commands/PokeInt.htm similarity index 100% rename from _release/help/commands/2d_commands/PokeInt.htm rename to #Test/help/commands/2d_commands/PokeInt.htm diff --git a/_release/help/commands/2d_commands/PokeShort.htm b/#Test/help/commands/2d_commands/PokeShort.htm similarity index 100% rename from _release/help/commands/2d_commands/PokeShort.htm rename to #Test/help/commands/2d_commands/PokeShort.htm diff --git a/_release/help/commands/2d_commands/Print.htm b/#Test/help/commands/2d_commands/Print.htm similarity index 100% rename from _release/help/commands/2d_commands/Print.htm rename to #Test/help/commands/2d_commands/Print.htm diff --git a/_release/help/commands/2d_commands/RSet.htm b/#Test/help/commands/2d_commands/RSet.htm similarity index 100% rename from _release/help/commands/2d_commands/RSet.htm rename to #Test/help/commands/2d_commands/RSet.htm diff --git a/_release/help/commands/2d_commands/Rand.htm b/#Test/help/commands/2d_commands/Rand.htm similarity index 100% rename from _release/help/commands/2d_commands/Rand.htm rename to #Test/help/commands/2d_commands/Rand.htm diff --git a/_release/help/commands/2d_commands/Read.htm b/#Test/help/commands/2d_commands/Read.htm similarity index 100% rename from _release/help/commands/2d_commands/Read.htm rename to #Test/help/commands/2d_commands/Read.htm diff --git a/_release/help/commands/2d_commands/ReadAvail.htm b/#Test/help/commands/2d_commands/ReadAvail.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadAvail.htm rename to #Test/help/commands/2d_commands/ReadAvail.htm diff --git a/_release/help/commands/2d_commands/ReadByte.htm b/#Test/help/commands/2d_commands/ReadByte.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadByte.htm rename to #Test/help/commands/2d_commands/ReadByte.htm diff --git a/_release/help/commands/2d_commands/ReadBytes.htm b/#Test/help/commands/2d_commands/ReadBytes.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadBytes.htm rename to #Test/help/commands/2d_commands/ReadBytes.htm diff --git a/_release/help/commands/2d_commands/ReadDir.htm b/#Test/help/commands/2d_commands/ReadDir.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadDir.htm rename to #Test/help/commands/2d_commands/ReadDir.htm diff --git a/_release/help/commands/2d_commands/ReadFile.htm b/#Test/help/commands/2d_commands/ReadFile.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadFile.htm rename to #Test/help/commands/2d_commands/ReadFile.htm diff --git a/_release/help/commands/2d_commands/ReadFloat.htm b/#Test/help/commands/2d_commands/ReadFloat.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadFloat.htm rename to #Test/help/commands/2d_commands/ReadFloat.htm diff --git a/_release/help/commands/2d_commands/ReadInt.htm b/#Test/help/commands/2d_commands/ReadInt.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadInt.htm rename to #Test/help/commands/2d_commands/ReadInt.htm diff --git a/_release/help/commands/2d_commands/ReadLine.htm b/#Test/help/commands/2d_commands/ReadLine.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadLine.htm rename to #Test/help/commands/2d_commands/ReadLine.htm diff --git a/_release/help/commands/2d_commands/ReadPixel.htm b/#Test/help/commands/2d_commands/ReadPixel.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadPixel.htm rename to #Test/help/commands/2d_commands/ReadPixel.htm diff --git a/_release/help/commands/2d_commands/ReadPixelFast.htm b/#Test/help/commands/2d_commands/ReadPixelFast.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadPixelFast.htm rename to #Test/help/commands/2d_commands/ReadPixelFast.htm diff --git a/_release/help/commands/2d_commands/ReadShort.htm b/#Test/help/commands/2d_commands/ReadShort.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadShort.htm rename to #Test/help/commands/2d_commands/ReadShort.htm diff --git a/_release/help/commands/2d_commands/ReadString.htm b/#Test/help/commands/2d_commands/ReadString.htm similarity index 100% rename from _release/help/commands/2d_commands/ReadString.htm rename to #Test/help/commands/2d_commands/ReadString.htm diff --git a/_release/help/commands/2d_commands/Rect.htm b/#Test/help/commands/2d_commands/Rect.htm similarity index 100% rename from _release/help/commands/2d_commands/Rect.htm rename to #Test/help/commands/2d_commands/Rect.htm diff --git a/_release/help/commands/2d_commands/RectsOverlap.htm b/#Test/help/commands/2d_commands/RectsOverlap.htm similarity index 100% rename from _release/help/commands/2d_commands/RectsOverlap.htm rename to #Test/help/commands/2d_commands/RectsOverlap.htm diff --git a/_release/help/commands/2d_commands/RecvNetMsg.htm b/#Test/help/commands/2d_commands/RecvNetMsg.htm similarity index 100% rename from _release/help/commands/2d_commands/RecvNetMsg.htm rename to #Test/help/commands/2d_commands/RecvNetMsg.htm diff --git a/_release/help/commands/2d_commands/Repeat.htm b/#Test/help/commands/2d_commands/Repeat.htm similarity index 100% rename from _release/help/commands/2d_commands/Repeat.htm rename to #Test/help/commands/2d_commands/Repeat.htm diff --git a/_release/help/commands/2d_commands/Replace.htm b/#Test/help/commands/2d_commands/Replace.htm similarity index 100% rename from _release/help/commands/2d_commands/Replace.htm rename to #Test/help/commands/2d_commands/Replace.htm diff --git a/_release/help/commands/2d_commands/ResizeBank.htm b/#Test/help/commands/2d_commands/ResizeBank.htm similarity index 100% rename from _release/help/commands/2d_commands/ResizeBank.htm rename to #Test/help/commands/2d_commands/ResizeBank.htm diff --git a/_release/help/commands/2d_commands/ResizeImage.htm b/#Test/help/commands/2d_commands/ResizeImage.htm similarity index 100% rename from _release/help/commands/2d_commands/ResizeImage.htm rename to #Test/help/commands/2d_commands/ResizeImage.htm diff --git a/_release/help/commands/2d_commands/Restore.htm b/#Test/help/commands/2d_commands/Restore.htm similarity index 100% rename from _release/help/commands/2d_commands/Restore.htm rename to #Test/help/commands/2d_commands/Restore.htm diff --git a/_release/help/commands/2d_commands/ResumeChannel.htm b/#Test/help/commands/2d_commands/ResumeChannel.htm similarity index 100% rename from _release/help/commands/2d_commands/ResumeChannel.htm rename to #Test/help/commands/2d_commands/ResumeChannel.htm diff --git a/_release/help/commands/2d_commands/Return.htm b/#Test/help/commands/2d_commands/Return.htm similarity index 100% rename from _release/help/commands/2d_commands/Return.htm rename to #Test/help/commands/2d_commands/Return.htm diff --git a/_release/help/commands/2d_commands/Right.htm b/#Test/help/commands/2d_commands/Right.htm similarity index 100% rename from _release/help/commands/2d_commands/Right.htm rename to #Test/help/commands/2d_commands/Right.htm diff --git a/_release/help/commands/2d_commands/Rnd.htm b/#Test/help/commands/2d_commands/Rnd.htm similarity index 100% rename from _release/help/commands/2d_commands/Rnd.htm rename to #Test/help/commands/2d_commands/Rnd.htm diff --git a/_release/help/commands/2d_commands/RotateImage.htm b/#Test/help/commands/2d_commands/RotateImage.htm similarity index 100% rename from _release/help/commands/2d_commands/RotateImage.htm rename to #Test/help/commands/2d_commands/RotateImage.htm diff --git a/_release/help/commands/2d_commands/RuntimeError.htm b/#Test/help/commands/2d_commands/RuntimeError.htm similarity index 100% rename from _release/help/commands/2d_commands/RuntimeError.htm rename to #Test/help/commands/2d_commands/RuntimeError.htm diff --git a/_release/help/commands/2d_commands/Sar.htm b/#Test/help/commands/2d_commands/Sar.htm similarity index 100% rename from _release/help/commands/2d_commands/Sar.htm rename to #Test/help/commands/2d_commands/Sar.htm diff --git a/_release/help/commands/2d_commands/SaveBuffer.htm b/#Test/help/commands/2d_commands/SaveBuffer.htm similarity index 100% rename from _release/help/commands/2d_commands/SaveBuffer.htm rename to #Test/help/commands/2d_commands/SaveBuffer.htm diff --git a/_release/help/commands/2d_commands/SaveImage.htm b/#Test/help/commands/2d_commands/SaveImage.htm similarity index 100% rename from _release/help/commands/2d_commands/SaveImage.htm rename to #Test/help/commands/2d_commands/SaveImage.htm diff --git a/_release/help/commands/2d_commands/ScaleImage.htm b/#Test/help/commands/2d_commands/ScaleImage.htm similarity index 100% rename from _release/help/commands/2d_commands/ScaleImage.htm rename to #Test/help/commands/2d_commands/ScaleImage.htm diff --git a/_release/help/commands/2d_commands/ScanCodes.htm b/#Test/help/commands/2d_commands/ScanCodes.htm similarity index 100% rename from _release/help/commands/2d_commands/ScanCodes.htm rename to #Test/help/commands/2d_commands/ScanCodes.htm diff --git a/_release/help/commands/2d_commands/ScanLine.htm b/#Test/help/commands/2d_commands/ScanLine.htm similarity index 100% rename from _release/help/commands/2d_commands/ScanLine.htm rename to #Test/help/commands/2d_commands/ScanLine.htm diff --git a/_release/help/commands/2d_commands/SeedRnd.htm b/#Test/help/commands/2d_commands/SeedRnd.htm similarity index 100% rename from _release/help/commands/2d_commands/SeedRnd.htm rename to #Test/help/commands/2d_commands/SeedRnd.htm diff --git a/_release/help/commands/2d_commands/SeekFile.htm b/#Test/help/commands/2d_commands/SeekFile.htm similarity index 100% rename from _release/help/commands/2d_commands/SeekFile.htm rename to #Test/help/commands/2d_commands/SeekFile.htm diff --git a/_release/help/commands/2d_commands/Select.htm b/#Test/help/commands/2d_commands/Select.htm similarity index 100% rename from _release/help/commands/2d_commands/Select.htm rename to #Test/help/commands/2d_commands/Select.htm diff --git a/_release/help/commands/2d_commands/SendNetMsg.htm b/#Test/help/commands/2d_commands/SendNetMsg.htm similarity index 100% rename from _release/help/commands/2d_commands/SendNetMsg.htm rename to #Test/help/commands/2d_commands/SendNetMsg.htm diff --git a/_release/help/commands/2d_commands/SetBuffer.htm b/#Test/help/commands/2d_commands/SetBuffer.htm similarity index 100% rename from _release/help/commands/2d_commands/SetBuffer.htm rename to #Test/help/commands/2d_commands/SetBuffer.htm diff --git a/_release/help/commands/2d_commands/SetFont.htm b/#Test/help/commands/2d_commands/SetFont.htm similarity index 100% rename from _release/help/commands/2d_commands/SetFont.htm rename to #Test/help/commands/2d_commands/SetFont.htm diff --git a/_release/help/commands/2d_commands/SetGfxDriver.htm b/#Test/help/commands/2d_commands/SetGfxDriver.htm similarity index 100% rename from _release/help/commands/2d_commands/SetGfxDriver.htm rename to #Test/help/commands/2d_commands/SetGfxDriver.htm diff --git a/_release/help/commands/2d_commands/Sgn.htm b/#Test/help/commands/2d_commands/Sgn.htm similarity index 100% rename from _release/help/commands/2d_commands/Sgn.htm rename to #Test/help/commands/2d_commands/Sgn.htm diff --git a/_release/help/commands/2d_commands/Shl.htm b/#Test/help/commands/2d_commands/Shl.htm similarity index 100% rename from _release/help/commands/2d_commands/Shl.htm rename to #Test/help/commands/2d_commands/Shl.htm diff --git a/_release/help/commands/2d_commands/ShowPointer.htm b/#Test/help/commands/2d_commands/ShowPointer.htm similarity index 100% rename from _release/help/commands/2d_commands/ShowPointer.htm rename to #Test/help/commands/2d_commands/ShowPointer.htm diff --git a/_release/help/commands/2d_commands/Shr.htm b/#Test/help/commands/2d_commands/Shr.htm similarity index 100% rename from _release/help/commands/2d_commands/Shr.htm rename to #Test/help/commands/2d_commands/Shr.htm diff --git a/_release/help/commands/2d_commands/Sin.htm b/#Test/help/commands/2d_commands/Sin.htm similarity index 100% rename from _release/help/commands/2d_commands/Sin.htm rename to #Test/help/commands/2d_commands/Sin.htm diff --git a/_release/help/commands/2d_commands/SoundPan.htm b/#Test/help/commands/2d_commands/SoundPan.htm similarity index 100% rename from _release/help/commands/2d_commands/SoundPan.htm rename to #Test/help/commands/2d_commands/SoundPan.htm diff --git a/_release/help/commands/2d_commands/SoundPitch.htm b/#Test/help/commands/2d_commands/SoundPitch.htm similarity index 100% rename from _release/help/commands/2d_commands/SoundPitch.htm rename to #Test/help/commands/2d_commands/SoundPitch.htm diff --git a/_release/help/commands/2d_commands/SoundVolume.htm b/#Test/help/commands/2d_commands/SoundVolume.htm similarity index 100% rename from _release/help/commands/2d_commands/SoundVolume.htm rename to #Test/help/commands/2d_commands/SoundVolume.htm diff --git a/_release/help/commands/2d_commands/Sqr.htm b/#Test/help/commands/2d_commands/Sqr.htm similarity index 100% rename from _release/help/commands/2d_commands/Sqr.htm rename to #Test/help/commands/2d_commands/Sqr.htm diff --git a/_release/help/commands/2d_commands/StartNetGame.htm b/#Test/help/commands/2d_commands/StartNetGame.htm similarity index 100% rename from _release/help/commands/2d_commands/StartNetGame.htm rename to #Test/help/commands/2d_commands/StartNetGame.htm diff --git a/_release/help/commands/2d_commands/Step.htm b/#Test/help/commands/2d_commands/Step.htm similarity index 100% rename from _release/help/commands/2d_commands/Step.htm rename to #Test/help/commands/2d_commands/Step.htm diff --git a/_release/help/commands/2d_commands/Stop.htm b/#Test/help/commands/2d_commands/Stop.htm similarity index 100% rename from _release/help/commands/2d_commands/Stop.htm rename to #Test/help/commands/2d_commands/Stop.htm diff --git a/_release/help/commands/2d_commands/StopChannel.htm b/#Test/help/commands/2d_commands/StopChannel.htm similarity index 100% rename from _release/help/commands/2d_commands/StopChannel.htm rename to #Test/help/commands/2d_commands/StopChannel.htm diff --git a/_release/help/commands/2d_commands/StopNetGame.htm b/#Test/help/commands/2d_commands/StopNetGame.htm similarity index 100% rename from _release/help/commands/2d_commands/StopNetGame.htm rename to #Test/help/commands/2d_commands/StopNetGame.htm diff --git a/_release/help/commands/2d_commands/Str.htm b/#Test/help/commands/2d_commands/Str.htm similarity index 100% rename from _release/help/commands/2d_commands/Str.htm rename to #Test/help/commands/2d_commands/Str.htm diff --git a/_release/help/commands/2d_commands/String.htm b/#Test/help/commands/2d_commands/String.htm similarity index 100% rename from _release/help/commands/2d_commands/String.htm rename to #Test/help/commands/2d_commands/String.htm diff --git a/_release/help/commands/2d_commands/StringHeight.htm b/#Test/help/commands/2d_commands/StringHeight.htm similarity index 100% rename from _release/help/commands/2d_commands/StringHeight.htm rename to #Test/help/commands/2d_commands/StringHeight.htm diff --git a/_release/help/commands/2d_commands/StringWidth.htm b/#Test/help/commands/2d_commands/StringWidth.htm similarity index 100% rename from _release/help/commands/2d_commands/StringWidth.htm rename to #Test/help/commands/2d_commands/StringWidth.htm diff --git a/_release/help/commands/2d_commands/SystemProperty.htm b/#Test/help/commands/2d_commands/SystemProperty.htm similarity index 100% rename from _release/help/commands/2d_commands/SystemProperty.htm rename to #Test/help/commands/2d_commands/SystemProperty.htm diff --git a/_release/help/commands/2d_commands/TCPTimeOuts.htm b/#Test/help/commands/2d_commands/TCPTimeOuts.htm similarity index 100% rename from _release/help/commands/2d_commands/TCPTimeOuts.htm rename to #Test/help/commands/2d_commands/TCPTimeOuts.htm diff --git a/_release/help/commands/2d_commands/TFormFilter.htm b/#Test/help/commands/2d_commands/TFormFilter.htm similarity index 100% rename from _release/help/commands/2d_commands/TFormFilter.htm rename to #Test/help/commands/2d_commands/TFormFilter.htm diff --git a/_release/help/commands/2d_commands/Tan.htm b/#Test/help/commands/2d_commands/Tan.htm similarity index 100% rename from _release/help/commands/2d_commands/Tan.htm rename to #Test/help/commands/2d_commands/Tan.htm diff --git a/_release/help/commands/2d_commands/Text.htm b/#Test/help/commands/2d_commands/Text.htm similarity index 100% rename from _release/help/commands/2d_commands/Text.htm rename to #Test/help/commands/2d_commands/Text.htm diff --git a/_release/help/commands/2d_commands/Then.htm b/#Test/help/commands/2d_commands/Then.htm similarity index 100% rename from _release/help/commands/2d_commands/Then.htm rename to #Test/help/commands/2d_commands/Then.htm diff --git a/_release/help/commands/2d_commands/TileBlock.htm b/#Test/help/commands/2d_commands/TileBlock.htm similarity index 100% rename from _release/help/commands/2d_commands/TileBlock.htm rename to #Test/help/commands/2d_commands/TileBlock.htm diff --git a/_release/help/commands/2d_commands/TileImage.htm b/#Test/help/commands/2d_commands/TileImage.htm similarity index 100% rename from _release/help/commands/2d_commands/TileImage.htm rename to #Test/help/commands/2d_commands/TileImage.htm diff --git a/_release/help/commands/2d_commands/To.htm b/#Test/help/commands/2d_commands/To.htm similarity index 100% rename from _release/help/commands/2d_commands/To.htm rename to #Test/help/commands/2d_commands/To.htm diff --git a/_release/help/commands/2d_commands/TotalVidMem.htm b/#Test/help/commands/2d_commands/TotalVidMem.htm similarity index 100% rename from _release/help/commands/2d_commands/TotalVidMem.htm rename to #Test/help/commands/2d_commands/TotalVidMem.htm diff --git a/_release/help/commands/2d_commands/Trim.htm b/#Test/help/commands/2d_commands/Trim.htm similarity index 100% rename from _release/help/commands/2d_commands/Trim.htm rename to #Test/help/commands/2d_commands/Trim.htm diff --git a/_release/help/commands/2d_commands/True.htm b/#Test/help/commands/2d_commands/True.htm similarity index 100% rename from _release/help/commands/2d_commands/True.htm rename to #Test/help/commands/2d_commands/True.htm diff --git a/_release/help/commands/2d_commands/Type.htm b/#Test/help/commands/2d_commands/Type.htm similarity index 100% rename from _release/help/commands/2d_commands/Type.htm rename to #Test/help/commands/2d_commands/Type.htm diff --git a/_release/help/commands/2d_commands/UnlockBuffer.htm b/#Test/help/commands/2d_commands/UnlockBuffer.htm similarity index 100% rename from _release/help/commands/2d_commands/UnlockBuffer.htm rename to #Test/help/commands/2d_commands/UnlockBuffer.htm diff --git a/_release/help/commands/2d_commands/Until.htm b/#Test/help/commands/2d_commands/Until.htm similarity index 100% rename from _release/help/commands/2d_commands/Until.htm rename to #Test/help/commands/2d_commands/Until.htm diff --git a/_release/help/commands/2d_commands/Upper.htm b/#Test/help/commands/2d_commands/Upper.htm similarity index 100% rename from _release/help/commands/2d_commands/Upper.htm rename to #Test/help/commands/2d_commands/Upper.htm diff --git a/_release/help/commands/2d_commands/VWait.htm b/#Test/help/commands/2d_commands/VWait.htm similarity index 100% rename from _release/help/commands/2d_commands/VWait.htm rename to #Test/help/commands/2d_commands/VWait.htm diff --git a/_release/help/commands/2d_commands/Viewport.htm b/#Test/help/commands/2d_commands/Viewport.htm similarity index 100% rename from _release/help/commands/2d_commands/Viewport.htm rename to #Test/help/commands/2d_commands/Viewport.htm diff --git a/_release/help/commands/2d_commands/WaitJoy.htm b/#Test/help/commands/2d_commands/WaitJoy.htm similarity index 100% rename from _release/help/commands/2d_commands/WaitJoy.htm rename to #Test/help/commands/2d_commands/WaitJoy.htm diff --git a/_release/help/commands/2d_commands/WaitKey.htm b/#Test/help/commands/2d_commands/WaitKey.htm similarity index 100% rename from _release/help/commands/2d_commands/WaitKey.htm rename to #Test/help/commands/2d_commands/WaitKey.htm diff --git a/_release/help/commands/2d_commands/WaitMouse.htm b/#Test/help/commands/2d_commands/WaitMouse.htm similarity index 100% rename from _release/help/commands/2d_commands/WaitMouse.htm rename to #Test/help/commands/2d_commands/WaitMouse.htm diff --git a/_release/help/commands/2d_commands/WaitTimer.htm b/#Test/help/commands/2d_commands/WaitTimer.htm similarity index 100% rename from _release/help/commands/2d_commands/WaitTimer.htm rename to #Test/help/commands/2d_commands/WaitTimer.htm diff --git a/_release/help/commands/2d_commands/Wend.htm b/#Test/help/commands/2d_commands/Wend.htm similarity index 100% rename from _release/help/commands/2d_commands/Wend.htm rename to #Test/help/commands/2d_commands/Wend.htm diff --git a/_release/help/commands/2d_commands/While.htm b/#Test/help/commands/2d_commands/While.htm similarity index 100% rename from _release/help/commands/2d_commands/While.htm rename to #Test/help/commands/2d_commands/While.htm diff --git a/_release/help/commands/2d_commands/Write.htm b/#Test/help/commands/2d_commands/Write.htm similarity index 100% rename from _release/help/commands/2d_commands/Write.htm rename to #Test/help/commands/2d_commands/Write.htm diff --git a/_release/help/commands/2d_commands/WriteByte.htm b/#Test/help/commands/2d_commands/WriteByte.htm similarity index 100% rename from _release/help/commands/2d_commands/WriteByte.htm rename to #Test/help/commands/2d_commands/WriteByte.htm diff --git a/_release/help/commands/2d_commands/WriteBytes.htm b/#Test/help/commands/2d_commands/WriteBytes.htm similarity index 100% rename from _release/help/commands/2d_commands/WriteBytes.htm rename to #Test/help/commands/2d_commands/WriteBytes.htm diff --git a/_release/help/commands/2d_commands/WriteFile.htm b/#Test/help/commands/2d_commands/WriteFile.htm similarity index 100% rename from _release/help/commands/2d_commands/WriteFile.htm rename to #Test/help/commands/2d_commands/WriteFile.htm diff --git a/_release/help/commands/2d_commands/WriteFloat.htm b/#Test/help/commands/2d_commands/WriteFloat.htm similarity index 100% rename from _release/help/commands/2d_commands/WriteFloat.htm rename to #Test/help/commands/2d_commands/WriteFloat.htm diff --git a/_release/help/commands/2d_commands/WriteInt.htm b/#Test/help/commands/2d_commands/WriteInt.htm similarity index 100% rename from _release/help/commands/2d_commands/WriteInt.htm rename to #Test/help/commands/2d_commands/WriteInt.htm diff --git a/_release/help/commands/2d_commands/WriteLine.htm b/#Test/help/commands/2d_commands/WriteLine.htm similarity index 100% rename from _release/help/commands/2d_commands/WriteLine.htm rename to #Test/help/commands/2d_commands/WriteLine.htm diff --git a/_release/help/commands/2d_commands/WritePixel.htm b/#Test/help/commands/2d_commands/WritePixel.htm similarity index 100% rename from _release/help/commands/2d_commands/WritePixel.htm rename to #Test/help/commands/2d_commands/WritePixel.htm diff --git a/_release/help/commands/2d_commands/WritePixelFast.htm b/#Test/help/commands/2d_commands/WritePixelFast.htm similarity index 100% rename from _release/help/commands/2d_commands/WritePixelFast.htm rename to #Test/help/commands/2d_commands/WritePixelFast.htm diff --git a/_release/help/commands/2d_commands/WriteShort.htm b/#Test/help/commands/2d_commands/WriteShort.htm similarity index 100% rename from _release/help/commands/2d_commands/WriteShort.htm rename to #Test/help/commands/2d_commands/WriteShort.htm diff --git a/_release/help/commands/2d_commands/WriteString.htm b/#Test/help/commands/2d_commands/WriteString.htm similarity index 100% rename from _release/help/commands/2d_commands/WriteString.htm rename to #Test/help/commands/2d_commands/WriteString.htm diff --git a/_release/help/commands/2d_commands/Xor.htm b/#Test/help/commands/2d_commands/Xor.htm similarity index 100% rename from _release/help/commands/2d_commands/Xor.htm rename to #Test/help/commands/2d_commands/Xor.htm diff --git a/_release/help/commands/2d_commands/template.htm b/#Test/help/commands/2d_commands/template.htm similarity index 100% rename from _release/help/commands/2d_commands/template.htm rename to #Test/help/commands/2d_commands/template.htm diff --git a/_release/help/commands/3d_commands/AddAnimSeq.htm b/#Test/help/commands/3d_commands/AddAnimSeq.htm similarity index 100% rename from _release/help/commands/3d_commands/AddAnimSeq.htm rename to #Test/help/commands/3d_commands/AddAnimSeq.htm diff --git a/_release/help/commands/3d_commands/AddTriangle.htm b/#Test/help/commands/3d_commands/AddTriangle.htm similarity index 100% rename from _release/help/commands/3d_commands/AddTriangle.htm rename to #Test/help/commands/3d_commands/AddTriangle.htm diff --git a/_release/help/commands/3d_commands/AddVertex.htm b/#Test/help/commands/3d_commands/AddVertex.htm similarity index 100% rename from _release/help/commands/3d_commands/AddVertex.htm rename to #Test/help/commands/3d_commands/AddVertex.htm diff --git a/_release/help/commands/3d_commands/AlignToVector.htm b/#Test/help/commands/3d_commands/AlignToVector.htm similarity index 100% rename from _release/help/commands/3d_commands/AlignToVector.htm rename to #Test/help/commands/3d_commands/AlignToVector.htm diff --git a/_release/help/commands/3d_commands/AmbientLight.htm b/#Test/help/commands/3d_commands/AmbientLight.htm similarity index 100% rename from _release/help/commands/3d_commands/AmbientLight.htm rename to #Test/help/commands/3d_commands/AmbientLight.htm diff --git a/_release/help/commands/3d_commands/AnimLength.htm b/#Test/help/commands/3d_commands/AnimLength.htm similarity index 100% rename from _release/help/commands/3d_commands/AnimLength.htm rename to #Test/help/commands/3d_commands/AnimLength.htm diff --git a/_release/help/commands/3d_commands/AnimSeq.htm b/#Test/help/commands/3d_commands/AnimSeq.htm similarity index 100% rename from _release/help/commands/3d_commands/AnimSeq.htm rename to #Test/help/commands/3d_commands/AnimSeq.htm diff --git a/_release/help/commands/3d_commands/AnimTime.htm b/#Test/help/commands/3d_commands/AnimTime.htm similarity index 100% rename from _release/help/commands/3d_commands/AnimTime.htm rename to #Test/help/commands/3d_commands/AnimTime.htm diff --git a/_release/help/commands/3d_commands/Animate.htm b/#Test/help/commands/3d_commands/Animate.htm similarity index 100% rename from _release/help/commands/3d_commands/Animate.htm rename to #Test/help/commands/3d_commands/Animate.htm diff --git a/_release/help/commands/3d_commands/AnimateMD2.htm b/#Test/help/commands/3d_commands/AnimateMD2.htm similarity index 100% rename from _release/help/commands/3d_commands/AnimateMD2.htm rename to #Test/help/commands/3d_commands/AnimateMD2.htm diff --git a/_release/help/commands/3d_commands/Animating.htm b/#Test/help/commands/3d_commands/Animating.htm similarity index 100% rename from _release/help/commands/3d_commands/Animating.htm rename to #Test/help/commands/3d_commands/Animating.htm diff --git a/_release/help/commands/3d_commands/AntiAlias.htm b/#Test/help/commands/3d_commands/AntiAlias.htm similarity index 100% rename from _release/help/commands/3d_commands/AntiAlias.htm rename to #Test/help/commands/3d_commands/AntiAlias.htm diff --git a/_release/help/commands/3d_commands/BrushAlpha.htm b/#Test/help/commands/3d_commands/BrushAlpha.htm similarity index 100% rename from _release/help/commands/3d_commands/BrushAlpha.htm rename to #Test/help/commands/3d_commands/BrushAlpha.htm diff --git a/_release/help/commands/3d_commands/BrushBlend.htm b/#Test/help/commands/3d_commands/BrushBlend.htm similarity index 100% rename from _release/help/commands/3d_commands/BrushBlend.htm rename to #Test/help/commands/3d_commands/BrushBlend.htm diff --git a/_release/help/commands/3d_commands/BrushColor.htm b/#Test/help/commands/3d_commands/BrushColor.htm similarity index 100% rename from _release/help/commands/3d_commands/BrushColor.htm rename to #Test/help/commands/3d_commands/BrushColor.htm diff --git a/_release/help/commands/3d_commands/BrushFX.htm b/#Test/help/commands/3d_commands/BrushFX.htm similarity index 100% rename from _release/help/commands/3d_commands/BrushFX.htm rename to #Test/help/commands/3d_commands/BrushFX.htm diff --git a/_release/help/commands/3d_commands/BrushShininess.htm b/#Test/help/commands/3d_commands/BrushShininess.htm similarity index 100% rename from _release/help/commands/3d_commands/BrushShininess.htm rename to #Test/help/commands/3d_commands/BrushShininess.htm diff --git a/_release/help/commands/3d_commands/BrushTexture.htm b/#Test/help/commands/3d_commands/BrushTexture.htm similarity index 100% rename from _release/help/commands/3d_commands/BrushTexture.htm rename to #Test/help/commands/3d_commands/BrushTexture.htm diff --git a/_release/help/commands/3d_commands/CameraClsColor.htm b/#Test/help/commands/3d_commands/CameraClsColor.htm similarity index 100% rename from _release/help/commands/3d_commands/CameraClsColor.htm rename to #Test/help/commands/3d_commands/CameraClsColor.htm diff --git a/_release/help/commands/3d_commands/CameraClsMode.htm b/#Test/help/commands/3d_commands/CameraClsMode.htm similarity index 100% rename from _release/help/commands/3d_commands/CameraClsMode.htm rename to #Test/help/commands/3d_commands/CameraClsMode.htm diff --git a/_release/help/commands/3d_commands/CameraFogColor.htm b/#Test/help/commands/3d_commands/CameraFogColor.htm similarity index 100% rename from _release/help/commands/3d_commands/CameraFogColor.htm rename to #Test/help/commands/3d_commands/CameraFogColor.htm diff --git a/_release/help/commands/3d_commands/CameraFogMode.htm b/#Test/help/commands/3d_commands/CameraFogMode.htm similarity index 100% rename from _release/help/commands/3d_commands/CameraFogMode.htm rename to #Test/help/commands/3d_commands/CameraFogMode.htm diff --git a/_release/help/commands/3d_commands/CameraFogRange.htm b/#Test/help/commands/3d_commands/CameraFogRange.htm similarity index 100% rename from _release/help/commands/3d_commands/CameraFogRange.htm rename to #Test/help/commands/3d_commands/CameraFogRange.htm diff --git a/_release/help/commands/3d_commands/CameraPick.htm b/#Test/help/commands/3d_commands/CameraPick.htm similarity index 100% rename from _release/help/commands/3d_commands/CameraPick.htm rename to #Test/help/commands/3d_commands/CameraPick.htm diff --git a/_release/help/commands/3d_commands/CameraProject.htm b/#Test/help/commands/3d_commands/CameraProject.htm similarity index 100% rename from _release/help/commands/3d_commands/CameraProject.htm rename to #Test/help/commands/3d_commands/CameraProject.htm diff --git a/_release/help/commands/3d_commands/CameraRange.htm b/#Test/help/commands/3d_commands/CameraRange.htm similarity index 100% rename from _release/help/commands/3d_commands/CameraRange.htm rename to #Test/help/commands/3d_commands/CameraRange.htm diff --git a/_release/help/commands/3d_commands/CameraViewport.htm b/#Test/help/commands/3d_commands/CameraViewport.htm similarity index 100% rename from _release/help/commands/3d_commands/CameraViewport.htm rename to #Test/help/commands/3d_commands/CameraViewport.htm diff --git a/_release/help/commands/3d_commands/CameraZoom.htm b/#Test/help/commands/3d_commands/CameraZoom.htm similarity index 100% rename from _release/help/commands/3d_commands/CameraZoom.htm rename to #Test/help/commands/3d_commands/CameraZoom.htm diff --git a/_release/help/commands/3d_commands/CaptureWorld.htm b/#Test/help/commands/3d_commands/CaptureWorld.htm similarity index 100% rename from _release/help/commands/3d_commands/CaptureWorld.htm rename to #Test/help/commands/3d_commands/CaptureWorld.htm diff --git a/_release/help/commands/3d_commands/ClearCollisions.htm b/#Test/help/commands/3d_commands/ClearCollisions.htm similarity index 100% rename from _release/help/commands/3d_commands/ClearCollisions.htm rename to #Test/help/commands/3d_commands/ClearCollisions.htm diff --git a/_release/help/commands/3d_commands/ClearSurface.htm b/#Test/help/commands/3d_commands/ClearSurface.htm similarity index 100% rename from _release/help/commands/3d_commands/ClearSurface.htm rename to #Test/help/commands/3d_commands/ClearSurface.htm diff --git a/_release/help/commands/3d_commands/ClearTextureFilters.htm b/#Test/help/commands/3d_commands/ClearTextureFilters.htm similarity index 100% rename from _release/help/commands/3d_commands/ClearTextureFilters.htm rename to #Test/help/commands/3d_commands/ClearTextureFilters.htm diff --git a/_release/help/commands/3d_commands/ClearWorld.htm b/#Test/help/commands/3d_commands/ClearWorld.htm similarity index 100% rename from _release/help/commands/3d_commands/ClearWorld.htm rename to #Test/help/commands/3d_commands/ClearWorld.htm diff --git a/_release/help/commands/3d_commands/CollisionEntity.htm b/#Test/help/commands/3d_commands/CollisionEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/CollisionEntity.htm rename to #Test/help/commands/3d_commands/CollisionEntity.htm diff --git a/_release/help/commands/3d_commands/CollisionNX.htm b/#Test/help/commands/3d_commands/CollisionNX.htm similarity index 100% rename from _release/help/commands/3d_commands/CollisionNX.htm rename to #Test/help/commands/3d_commands/CollisionNX.htm diff --git a/_release/help/commands/3d_commands/CollisionNY.htm b/#Test/help/commands/3d_commands/CollisionNY.htm similarity index 100% rename from _release/help/commands/3d_commands/CollisionNY.htm rename to #Test/help/commands/3d_commands/CollisionNY.htm diff --git a/_release/help/commands/3d_commands/CollisionNZ.htm b/#Test/help/commands/3d_commands/CollisionNZ.htm similarity index 100% rename from _release/help/commands/3d_commands/CollisionNZ.htm rename to #Test/help/commands/3d_commands/CollisionNZ.htm diff --git a/_release/help/commands/3d_commands/CollisionSurface.htm b/#Test/help/commands/3d_commands/CollisionSurface.htm similarity index 100% rename from _release/help/commands/3d_commands/CollisionSurface.htm rename to #Test/help/commands/3d_commands/CollisionSurface.htm diff --git a/_release/help/commands/3d_commands/CollisionTime.htm b/#Test/help/commands/3d_commands/CollisionTime.htm similarity index 100% rename from _release/help/commands/3d_commands/CollisionTime.htm rename to #Test/help/commands/3d_commands/CollisionTime.htm diff --git a/_release/help/commands/3d_commands/CollisionTriangle.htm b/#Test/help/commands/3d_commands/CollisionTriangle.htm similarity index 100% rename from _release/help/commands/3d_commands/CollisionTriangle.htm rename to #Test/help/commands/3d_commands/CollisionTriangle.htm diff --git a/_release/help/commands/3d_commands/CollisionX.htm b/#Test/help/commands/3d_commands/CollisionX.htm similarity index 100% rename from _release/help/commands/3d_commands/CollisionX.htm rename to #Test/help/commands/3d_commands/CollisionX.htm diff --git a/_release/help/commands/3d_commands/CollisionY.htm b/#Test/help/commands/3d_commands/CollisionY.htm similarity index 100% rename from _release/help/commands/3d_commands/CollisionY.htm rename to #Test/help/commands/3d_commands/CollisionY.htm diff --git a/_release/help/commands/3d_commands/CollisionZ.htm b/#Test/help/commands/3d_commands/CollisionZ.htm similarity index 100% rename from _release/help/commands/3d_commands/CollisionZ.htm rename to #Test/help/commands/3d_commands/CollisionZ.htm diff --git a/_release/help/commands/3d_commands/Collisions.htm b/#Test/help/commands/3d_commands/Collisions.htm similarity index 100% rename from _release/help/commands/3d_commands/Collisions.htm rename to #Test/help/commands/3d_commands/Collisions.htm diff --git a/_release/help/commands/3d_commands/CopyEntity.htm b/#Test/help/commands/3d_commands/CopyEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/CopyEntity.htm rename to #Test/help/commands/3d_commands/CopyEntity.htm diff --git a/_release/help/commands/3d_commands/CountChildren.htm b/#Test/help/commands/3d_commands/CountChildren.htm similarity index 100% rename from _release/help/commands/3d_commands/CountChildren.htm rename to #Test/help/commands/3d_commands/CountChildren.htm diff --git a/_release/help/commands/3d_commands/CountCollisions.htm b/#Test/help/commands/3d_commands/CountCollisions.htm similarity index 100% rename from _release/help/commands/3d_commands/CountCollisions.htm rename to #Test/help/commands/3d_commands/CountCollisions.htm diff --git a/_release/help/commands/3d_commands/CountSurfaces.htm b/#Test/help/commands/3d_commands/CountSurfaces.htm similarity index 100% rename from _release/help/commands/3d_commands/CountSurfaces.htm rename to #Test/help/commands/3d_commands/CountSurfaces.htm diff --git a/_release/help/commands/3d_commands/CountTriangles.htm b/#Test/help/commands/3d_commands/CountTriangles.htm similarity index 100% rename from _release/help/commands/3d_commands/CountTriangles.htm rename to #Test/help/commands/3d_commands/CountTriangles.htm diff --git a/_release/help/commands/3d_commands/CountVertices.htm b/#Test/help/commands/3d_commands/CountVertices.htm similarity index 100% rename from _release/help/commands/3d_commands/CountVertices.htm rename to #Test/help/commands/3d_commands/CountVertices.htm diff --git a/_release/help/commands/3d_commands/CreateBrush.htm b/#Test/help/commands/3d_commands/CreateBrush.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateBrush.htm rename to #Test/help/commands/3d_commands/CreateBrush.htm diff --git a/_release/help/commands/3d_commands/CreateCamera.htm b/#Test/help/commands/3d_commands/CreateCamera.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateCamera.htm rename to #Test/help/commands/3d_commands/CreateCamera.htm diff --git a/_release/help/commands/3d_commands/CreateCone.htm b/#Test/help/commands/3d_commands/CreateCone.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateCone.htm rename to #Test/help/commands/3d_commands/CreateCone.htm diff --git a/_release/help/commands/3d_commands/CreateCube.htm b/#Test/help/commands/3d_commands/CreateCube.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateCube.htm rename to #Test/help/commands/3d_commands/CreateCube.htm diff --git a/_release/help/commands/3d_commands/CreateCylinder.htm b/#Test/help/commands/3d_commands/CreateCylinder.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateCylinder.htm rename to #Test/help/commands/3d_commands/CreateCylinder.htm diff --git a/_release/help/commands/3d_commands/CreateLight.htm b/#Test/help/commands/3d_commands/CreateLight.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateLight.htm rename to #Test/help/commands/3d_commands/CreateLight.htm diff --git a/_release/help/commands/3d_commands/CreateListener.htm b/#Test/help/commands/3d_commands/CreateListener.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateListener.htm rename to #Test/help/commands/3d_commands/CreateListener.htm diff --git a/_release/help/commands/3d_commands/CreateMesh.htm b/#Test/help/commands/3d_commands/CreateMesh.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateMesh.htm rename to #Test/help/commands/3d_commands/CreateMesh.htm diff --git a/_release/help/commands/3d_commands/CreateMirror.htm b/#Test/help/commands/3d_commands/CreateMirror.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateMirror.htm rename to #Test/help/commands/3d_commands/CreateMirror.htm diff --git a/_release/help/commands/3d_commands/CreatePivot.htm b/#Test/help/commands/3d_commands/CreatePivot.htm similarity index 100% rename from _release/help/commands/3d_commands/CreatePivot.htm rename to #Test/help/commands/3d_commands/CreatePivot.htm diff --git a/_release/help/commands/3d_commands/CreatePlane.htm b/#Test/help/commands/3d_commands/CreatePlane.htm similarity index 100% rename from _release/help/commands/3d_commands/CreatePlane.htm rename to #Test/help/commands/3d_commands/CreatePlane.htm diff --git a/_release/help/commands/3d_commands/CreateSphere.htm b/#Test/help/commands/3d_commands/CreateSphere.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateSphere.htm rename to #Test/help/commands/3d_commands/CreateSphere.htm diff --git a/_release/help/commands/3d_commands/CreateSprite.htm b/#Test/help/commands/3d_commands/CreateSprite.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateSprite.htm rename to #Test/help/commands/3d_commands/CreateSprite.htm diff --git a/_release/help/commands/3d_commands/CreateSurface.htm b/#Test/help/commands/3d_commands/CreateSurface.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateSurface.htm rename to #Test/help/commands/3d_commands/CreateSurface.htm diff --git a/_release/help/commands/3d_commands/CreateTerrain.htm b/#Test/help/commands/3d_commands/CreateTerrain.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateTerrain.htm rename to #Test/help/commands/3d_commands/CreateTerrain.htm diff --git a/_release/help/commands/3d_commands/CreateTexture.htm b/#Test/help/commands/3d_commands/CreateTexture.htm similarity index 100% rename from _release/help/commands/3d_commands/CreateTexture.htm rename to #Test/help/commands/3d_commands/CreateTexture.htm diff --git a/_release/help/commands/3d_commands/Dither.htm b/#Test/help/commands/3d_commands/Dither.htm similarity index 100% rename from _release/help/commands/3d_commands/Dither.htm rename to #Test/help/commands/3d_commands/Dither.htm diff --git a/_release/help/commands/3d_commands/EmitSound.htm b/#Test/help/commands/3d_commands/EmitSound.htm similarity index 100% rename from _release/help/commands/3d_commands/EmitSound.htm rename to #Test/help/commands/3d_commands/EmitSound.htm diff --git a/_release/help/commands/3d_commands/EntityAlpha.htm b/#Test/help/commands/3d_commands/EntityAlpha.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityAlpha.htm rename to #Test/help/commands/3d_commands/EntityAlpha.htm diff --git a/_release/help/commands/3d_commands/EntityAnimTime.htm b/#Test/help/commands/3d_commands/EntityAnimTime.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityAnimTime.htm rename to #Test/help/commands/3d_commands/EntityAnimTime.htm diff --git a/_release/help/commands/3d_commands/EntityAnimating.htm b/#Test/help/commands/3d_commands/EntityAnimating.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityAnimating.htm rename to #Test/help/commands/3d_commands/EntityAnimating.htm diff --git a/_release/help/commands/3d_commands/EntityAutoFade.htm b/#Test/help/commands/3d_commands/EntityAutoFade.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityAutoFade.htm rename to #Test/help/commands/3d_commands/EntityAutoFade.htm diff --git a/_release/help/commands/3d_commands/EntityBlend.htm b/#Test/help/commands/3d_commands/EntityBlend.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityBlend.htm rename to #Test/help/commands/3d_commands/EntityBlend.htm diff --git a/_release/help/commands/3d_commands/EntityBox.htm b/#Test/help/commands/3d_commands/EntityBox.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityBox.htm rename to #Test/help/commands/3d_commands/EntityBox.htm diff --git a/_release/help/commands/3d_commands/EntityCollided.htm b/#Test/help/commands/3d_commands/EntityCollided.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityCollided.htm rename to #Test/help/commands/3d_commands/EntityCollided.htm diff --git a/_release/help/commands/3d_commands/EntityColor.htm b/#Test/help/commands/3d_commands/EntityColor.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityColor.htm rename to #Test/help/commands/3d_commands/EntityColor.htm diff --git a/_release/help/commands/3d_commands/EntityDistance.htm b/#Test/help/commands/3d_commands/EntityDistance.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityDistance.htm rename to #Test/help/commands/3d_commands/EntityDistance.htm diff --git a/_release/help/commands/3d_commands/EntityFX.htm b/#Test/help/commands/3d_commands/EntityFX.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityFX.htm rename to #Test/help/commands/3d_commands/EntityFX.htm diff --git a/_release/help/commands/3d_commands/EntityInView.htm b/#Test/help/commands/3d_commands/EntityInView.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityInView.htm rename to #Test/help/commands/3d_commands/EntityInView.htm diff --git a/_release/help/commands/3d_commands/EntityName.htm b/#Test/help/commands/3d_commands/EntityName.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityName.htm rename to #Test/help/commands/3d_commands/EntityName.htm diff --git a/_release/help/commands/3d_commands/EntityOrder.htm b/#Test/help/commands/3d_commands/EntityOrder.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityOrder.htm rename to #Test/help/commands/3d_commands/EntityOrder.htm diff --git a/_release/help/commands/3d_commands/EntityParent.htm b/#Test/help/commands/3d_commands/EntityParent.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityParent.htm rename to #Test/help/commands/3d_commands/EntityParent.htm diff --git a/_release/help/commands/3d_commands/EntityPick.htm b/#Test/help/commands/3d_commands/EntityPick.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityPick.htm rename to #Test/help/commands/3d_commands/EntityPick.htm diff --git a/_release/help/commands/3d_commands/EntityPickMode.htm b/#Test/help/commands/3d_commands/EntityPickMode.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityPickMode.htm rename to #Test/help/commands/3d_commands/EntityPickMode.htm diff --git a/_release/help/commands/3d_commands/EntityPitch.htm b/#Test/help/commands/3d_commands/EntityPitch.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityPitch.htm rename to #Test/help/commands/3d_commands/EntityPitch.htm diff --git a/_release/help/commands/3d_commands/EntityRadius.htm b/#Test/help/commands/3d_commands/EntityRadius.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityRadius.htm rename to #Test/help/commands/3d_commands/EntityRadius.htm diff --git a/_release/help/commands/3d_commands/EntityRoll.htm b/#Test/help/commands/3d_commands/EntityRoll.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityRoll.htm rename to #Test/help/commands/3d_commands/EntityRoll.htm diff --git a/_release/help/commands/3d_commands/EntityShininess.htm b/#Test/help/commands/3d_commands/EntityShininess.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityShininess.htm rename to #Test/help/commands/3d_commands/EntityShininess.htm diff --git a/_release/help/commands/3d_commands/EntityTexture.htm b/#Test/help/commands/3d_commands/EntityTexture.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityTexture.htm rename to #Test/help/commands/3d_commands/EntityTexture.htm diff --git a/_release/help/commands/3d_commands/EntityType.htm b/#Test/help/commands/3d_commands/EntityType.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityType.htm rename to #Test/help/commands/3d_commands/EntityType.htm diff --git a/_release/help/commands/3d_commands/EntityVisible.htm b/#Test/help/commands/3d_commands/EntityVisible.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityVisible.htm rename to #Test/help/commands/3d_commands/EntityVisible.htm diff --git a/_release/help/commands/3d_commands/EntityX.htm b/#Test/help/commands/3d_commands/EntityX.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityX.htm rename to #Test/help/commands/3d_commands/EntityX.htm diff --git a/_release/help/commands/3d_commands/EntityY.htm b/#Test/help/commands/3d_commands/EntityY.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityY.htm rename to #Test/help/commands/3d_commands/EntityY.htm diff --git a/_release/help/commands/3d_commands/EntityYaw.htm b/#Test/help/commands/3d_commands/EntityYaw.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityYaw.htm rename to #Test/help/commands/3d_commands/EntityYaw.htm diff --git a/_release/help/commands/3d_commands/EntityZ.htm b/#Test/help/commands/3d_commands/EntityZ.htm similarity index 100% rename from _release/help/commands/3d_commands/EntityZ.htm rename to #Test/help/commands/3d_commands/EntityZ.htm diff --git a/_release/help/commands/3d_commands/FindChild.htm b/#Test/help/commands/3d_commands/FindChild.htm similarity index 100% rename from _release/help/commands/3d_commands/FindChild.htm rename to #Test/help/commands/3d_commands/FindChild.htm diff --git a/_release/help/commands/3d_commands/FindSurface.htm b/#Test/help/commands/3d_commands/FindSurface.htm similarity index 100% rename from _release/help/commands/3d_commands/FindSurface.htm rename to #Test/help/commands/3d_commands/FindSurface.htm diff --git a/_release/help/commands/3d_commands/FitMesh.htm b/#Test/help/commands/3d_commands/FitMesh.htm similarity index 100% rename from _release/help/commands/3d_commands/FitMesh.htm rename to #Test/help/commands/3d_commands/FitMesh.htm diff --git a/_release/help/commands/3d_commands/FlipMesh.htm b/#Test/help/commands/3d_commands/FlipMesh.htm similarity index 100% rename from _release/help/commands/3d_commands/FlipMesh.htm rename to #Test/help/commands/3d_commands/FlipMesh.htm diff --git a/_release/help/commands/3d_commands/FreeBrush.htm b/#Test/help/commands/3d_commands/FreeBrush.htm similarity index 100% rename from _release/help/commands/3d_commands/FreeBrush.htm rename to #Test/help/commands/3d_commands/FreeBrush.htm diff --git a/_release/help/commands/3d_commands/FreeEntity.htm b/#Test/help/commands/3d_commands/FreeEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/FreeEntity.htm rename to #Test/help/commands/3d_commands/FreeEntity.htm diff --git a/_release/help/commands/3d_commands/FreeTexture.htm b/#Test/help/commands/3d_commands/FreeTexture.htm similarity index 100% rename from _release/help/commands/3d_commands/FreeTexture.htm rename to #Test/help/commands/3d_commands/FreeTexture.htm diff --git a/_release/help/commands/3d_commands/GetChild.htm b/#Test/help/commands/3d_commands/GetChild.htm similarity index 100% rename from _release/help/commands/3d_commands/GetChild.htm rename to #Test/help/commands/3d_commands/GetChild.htm diff --git a/_release/help/commands/3d_commands/GetEntityType.htm b/#Test/help/commands/3d_commands/GetEntityType.htm similarity index 100% rename from _release/help/commands/3d_commands/GetEntityType.htm rename to #Test/help/commands/3d_commands/GetEntityType.htm diff --git a/_release/help/commands/3d_commands/GetParent.htm b/#Test/help/commands/3d_commands/GetParent.htm similarity index 100% rename from _release/help/commands/3d_commands/GetParent.htm rename to #Test/help/commands/3d_commands/GetParent.htm diff --git a/_release/help/commands/3d_commands/GetSurface.htm b/#Test/help/commands/3d_commands/GetSurface.htm similarity index 100% rename from _release/help/commands/3d_commands/GetSurface.htm rename to #Test/help/commands/3d_commands/GetSurface.htm diff --git a/_release/help/commands/3d_commands/GfxDriver3D.htm b/#Test/help/commands/3d_commands/GfxDriver3D.htm similarity index 100% rename from _release/help/commands/3d_commands/GfxDriver3D.htm rename to #Test/help/commands/3d_commands/GfxDriver3D.htm diff --git a/_release/help/commands/3d_commands/GfxMode3D.htm b/#Test/help/commands/3d_commands/GfxMode3D.htm similarity index 100% rename from _release/help/commands/3d_commands/GfxMode3D.htm rename to #Test/help/commands/3d_commands/GfxMode3D.htm diff --git a/_release/help/commands/3d_commands/GfxModeExists.htm b/#Test/help/commands/3d_commands/GfxModeExists.htm similarity index 100% rename from _release/help/commands/3d_commands/GfxModeExists.htm rename to #Test/help/commands/3d_commands/GfxModeExists.htm diff --git a/_release/help/commands/3d_commands/Graphics3D.htm b/#Test/help/commands/3d_commands/Graphics3D.htm similarity index 100% rename from _release/help/commands/3d_commands/Graphics3D.htm rename to #Test/help/commands/3d_commands/Graphics3D.htm diff --git a/_release/help/commands/3d_commands/HWMultiTex.htm b/#Test/help/commands/3d_commands/HWMultiTex.htm similarity index 100% rename from _release/help/commands/3d_commands/HWMultiTex.htm rename to #Test/help/commands/3d_commands/HWMultiTex.htm diff --git a/_release/help/commands/3d_commands/HandleSprite.htm b/#Test/help/commands/3d_commands/HandleSprite.htm similarity index 100% rename from _release/help/commands/3d_commands/HandleSprite.htm rename to #Test/help/commands/3d_commands/HandleSprite.htm diff --git a/_release/help/commands/3d_commands/HideEntity.htm b/#Test/help/commands/3d_commands/HideEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/HideEntity.htm rename to #Test/help/commands/3d_commands/HideEntity.htm diff --git a/_release/help/commands/3d_commands/LightColor.htm b/#Test/help/commands/3d_commands/LightColor.htm similarity index 100% rename from _release/help/commands/3d_commands/LightColor.htm rename to #Test/help/commands/3d_commands/LightColor.htm diff --git a/_release/help/commands/3d_commands/LightConeAngles.htm b/#Test/help/commands/3d_commands/LightConeAngles.htm similarity index 100% rename from _release/help/commands/3d_commands/LightConeAngles.htm rename to #Test/help/commands/3d_commands/LightConeAngles.htm diff --git a/_release/help/commands/3d_commands/LightMesh.htm b/#Test/help/commands/3d_commands/LightMesh.htm similarity index 100% rename from _release/help/commands/3d_commands/LightMesh.htm rename to #Test/help/commands/3d_commands/LightMesh.htm diff --git a/_release/help/commands/3d_commands/LightRange.htm b/#Test/help/commands/3d_commands/LightRange.htm similarity index 100% rename from _release/help/commands/3d_commands/LightRange.htm rename to #Test/help/commands/3d_commands/LightRange.htm diff --git a/_release/help/commands/3d_commands/LinePick.htm b/#Test/help/commands/3d_commands/LinePick.htm similarity index 100% rename from _release/help/commands/3d_commands/LinePick.htm rename to #Test/help/commands/3d_commands/LinePick.htm diff --git a/_release/help/commands/3d_commands/Load3DSound.htm b/#Test/help/commands/3d_commands/Load3DSound.htm similarity index 100% rename from _release/help/commands/3d_commands/Load3DSound.htm rename to #Test/help/commands/3d_commands/Load3DSound.htm diff --git a/_release/help/commands/3d_commands/LoadAnimMesh.htm b/#Test/help/commands/3d_commands/LoadAnimMesh.htm similarity index 100% rename from _release/help/commands/3d_commands/LoadAnimMesh.htm rename to #Test/help/commands/3d_commands/LoadAnimMesh.htm diff --git a/_release/help/commands/3d_commands/LoadAnimSeq.htm b/#Test/help/commands/3d_commands/LoadAnimSeq.htm similarity index 100% rename from _release/help/commands/3d_commands/LoadAnimSeq.htm rename to #Test/help/commands/3d_commands/LoadAnimSeq.htm diff --git a/_release/help/commands/3d_commands/LoadAnimTexture.htm b/#Test/help/commands/3d_commands/LoadAnimTexture.htm similarity index 100% rename from _release/help/commands/3d_commands/LoadAnimTexture.htm rename to #Test/help/commands/3d_commands/LoadAnimTexture.htm diff --git a/_release/help/commands/3d_commands/LoadBrush.htm b/#Test/help/commands/3d_commands/LoadBrush.htm similarity index 100% rename from _release/help/commands/3d_commands/LoadBrush.htm rename to #Test/help/commands/3d_commands/LoadBrush.htm diff --git a/_release/help/commands/3d_commands/LoadMD2.htm b/#Test/help/commands/3d_commands/LoadMD2.htm similarity index 100% rename from _release/help/commands/3d_commands/LoadMD2.htm rename to #Test/help/commands/3d_commands/LoadMD2.htm diff --git a/_release/help/commands/3d_commands/LoadMesh.htm b/#Test/help/commands/3d_commands/LoadMesh.htm similarity index 100% rename from _release/help/commands/3d_commands/LoadMesh.htm rename to #Test/help/commands/3d_commands/LoadMesh.htm diff --git a/_release/help/commands/3d_commands/LoadSprite.htm b/#Test/help/commands/3d_commands/LoadSprite.htm similarity index 100% rename from _release/help/commands/3d_commands/LoadSprite.htm rename to #Test/help/commands/3d_commands/LoadSprite.htm diff --git a/_release/help/commands/3d_commands/LoadTerrain.htm b/#Test/help/commands/3d_commands/LoadTerrain.htm similarity index 100% rename from _release/help/commands/3d_commands/LoadTerrain.htm rename to #Test/help/commands/3d_commands/LoadTerrain.htm diff --git a/_release/help/commands/3d_commands/LoadTexture.htm b/#Test/help/commands/3d_commands/LoadTexture.htm similarity index 100% rename from _release/help/commands/3d_commands/LoadTexture.htm rename to #Test/help/commands/3d_commands/LoadTexture.htm diff --git a/_release/help/commands/3d_commands/LoaderMatrix.htm b/#Test/help/commands/3d_commands/LoaderMatrix.htm similarity index 100% rename from _release/help/commands/3d_commands/LoaderMatrix.htm rename to #Test/help/commands/3d_commands/LoaderMatrix.htm diff --git a/_release/help/commands/3d_commands/MD2AnimLength.htm b/#Test/help/commands/3d_commands/MD2AnimLength.htm similarity index 100% rename from _release/help/commands/3d_commands/MD2AnimLength.htm rename to #Test/help/commands/3d_commands/MD2AnimLength.htm diff --git a/_release/help/commands/3d_commands/MD2AnimTime.htm b/#Test/help/commands/3d_commands/MD2AnimTime.htm similarity index 100% rename from _release/help/commands/3d_commands/MD2AnimTime.htm rename to #Test/help/commands/3d_commands/MD2AnimTime.htm diff --git a/_release/help/commands/3d_commands/MD2Animating.htm b/#Test/help/commands/3d_commands/MD2Animating.htm similarity index 100% rename from _release/help/commands/3d_commands/MD2Animating.htm rename to #Test/help/commands/3d_commands/MD2Animating.htm diff --git a/_release/help/commands/3d_commands/MeshDepth.htm b/#Test/help/commands/3d_commands/MeshDepth.htm similarity index 100% rename from _release/help/commands/3d_commands/MeshDepth.htm rename to #Test/help/commands/3d_commands/MeshDepth.htm diff --git a/_release/help/commands/3d_commands/MeshHeight.htm b/#Test/help/commands/3d_commands/MeshHeight.htm similarity index 100% rename from _release/help/commands/3d_commands/MeshHeight.htm rename to #Test/help/commands/3d_commands/MeshHeight.htm diff --git a/_release/help/commands/3d_commands/MeshWidth.htm b/#Test/help/commands/3d_commands/MeshWidth.htm similarity index 100% rename from _release/help/commands/3d_commands/MeshWidth.htm rename to #Test/help/commands/3d_commands/MeshWidth.htm diff --git a/_release/help/commands/3d_commands/MeshesIntersect.htm b/#Test/help/commands/3d_commands/MeshesIntersect.htm similarity index 100% rename from _release/help/commands/3d_commands/MeshesIntersect.htm rename to #Test/help/commands/3d_commands/MeshesIntersect.htm diff --git a/_release/help/commands/3d_commands/ModifyTerrain.htm b/#Test/help/commands/3d_commands/ModifyTerrain.htm similarity index 100% rename from _release/help/commands/3d_commands/ModifyTerrain.htm rename to #Test/help/commands/3d_commands/ModifyTerrain.htm diff --git a/_release/help/commands/3d_commands/MoveEntity.htm b/#Test/help/commands/3d_commands/MoveEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/MoveEntity.htm rename to #Test/help/commands/3d_commands/MoveEntity.htm diff --git a/_release/help/commands/3d_commands/NameEntity.htm b/#Test/help/commands/3d_commands/NameEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/NameEntity.htm rename to #Test/help/commands/3d_commands/NameEntity.htm diff --git a/_release/help/commands/3d_commands/PaintEntity.htm b/#Test/help/commands/3d_commands/PaintEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/PaintEntity.htm rename to #Test/help/commands/3d_commands/PaintEntity.htm diff --git a/_release/help/commands/3d_commands/PaintMesh.htm b/#Test/help/commands/3d_commands/PaintMesh.htm similarity index 100% rename from _release/help/commands/3d_commands/PaintMesh.htm rename to #Test/help/commands/3d_commands/PaintMesh.htm diff --git a/_release/help/commands/3d_commands/PaintSurface.htm b/#Test/help/commands/3d_commands/PaintSurface.htm similarity index 100% rename from _release/help/commands/3d_commands/PaintSurface.htm rename to #Test/help/commands/3d_commands/PaintSurface.htm diff --git a/_release/help/commands/3d_commands/PickedEntity.htm b/#Test/help/commands/3d_commands/PickedEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/PickedEntity.htm rename to #Test/help/commands/3d_commands/PickedEntity.htm diff --git a/_release/help/commands/3d_commands/PickedNX.htm b/#Test/help/commands/3d_commands/PickedNX.htm similarity index 100% rename from _release/help/commands/3d_commands/PickedNX.htm rename to #Test/help/commands/3d_commands/PickedNX.htm diff --git a/_release/help/commands/3d_commands/PickedNY.htm b/#Test/help/commands/3d_commands/PickedNY.htm similarity index 100% rename from _release/help/commands/3d_commands/PickedNY.htm rename to #Test/help/commands/3d_commands/PickedNY.htm diff --git a/_release/help/commands/3d_commands/PickedNZ.htm b/#Test/help/commands/3d_commands/PickedNZ.htm similarity index 100% rename from _release/help/commands/3d_commands/PickedNZ.htm rename to #Test/help/commands/3d_commands/PickedNZ.htm diff --git a/_release/help/commands/3d_commands/PickedSurface.htm b/#Test/help/commands/3d_commands/PickedSurface.htm similarity index 100% rename from _release/help/commands/3d_commands/PickedSurface.htm rename to #Test/help/commands/3d_commands/PickedSurface.htm diff --git a/_release/help/commands/3d_commands/PickedTime.htm b/#Test/help/commands/3d_commands/PickedTime.htm similarity index 100% rename from _release/help/commands/3d_commands/PickedTime.htm rename to #Test/help/commands/3d_commands/PickedTime.htm diff --git a/_release/help/commands/3d_commands/PickedTriangle.htm b/#Test/help/commands/3d_commands/PickedTriangle.htm similarity index 100% rename from _release/help/commands/3d_commands/PickedTriangle.htm rename to #Test/help/commands/3d_commands/PickedTriangle.htm diff --git a/_release/help/commands/3d_commands/PickedX.htm b/#Test/help/commands/3d_commands/PickedX.htm similarity index 100% rename from _release/help/commands/3d_commands/PickedX.htm rename to #Test/help/commands/3d_commands/PickedX.htm diff --git a/_release/help/commands/3d_commands/PickedY.htm b/#Test/help/commands/3d_commands/PickedY.htm similarity index 100% rename from _release/help/commands/3d_commands/PickedY.htm rename to #Test/help/commands/3d_commands/PickedY.htm diff --git a/_release/help/commands/3d_commands/PickedZ.htm b/#Test/help/commands/3d_commands/PickedZ.htm similarity index 100% rename from _release/help/commands/3d_commands/PickedZ.htm rename to #Test/help/commands/3d_commands/PickedZ.htm diff --git a/_release/help/commands/3d_commands/PointEntity.htm b/#Test/help/commands/3d_commands/PointEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/PointEntity.htm rename to #Test/help/commands/3d_commands/PointEntity.htm diff --git a/_release/help/commands/3d_commands/PositionEntity.htm b/#Test/help/commands/3d_commands/PositionEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/PositionEntity.htm rename to #Test/help/commands/3d_commands/PositionEntity.htm diff --git a/_release/help/commands/3d_commands/PositionMesh.htm b/#Test/help/commands/3d_commands/PositionMesh.htm similarity index 100% rename from _release/help/commands/3d_commands/PositionMesh.htm rename to #Test/help/commands/3d_commands/PositionMesh.htm diff --git a/_release/help/commands/3d_commands/PositionTexture.htm b/#Test/help/commands/3d_commands/PositionTexture.htm similarity index 100% rename from _release/help/commands/3d_commands/PositionTexture.htm rename to #Test/help/commands/3d_commands/PositionTexture.htm diff --git a/_release/help/commands/3d_commands/ProjectedX.htm b/#Test/help/commands/3d_commands/ProjectedX.htm similarity index 100% rename from _release/help/commands/3d_commands/ProjectedX.htm rename to #Test/help/commands/3d_commands/ProjectedX.htm diff --git a/_release/help/commands/3d_commands/ProjectedY.htm b/#Test/help/commands/3d_commands/ProjectedY.htm similarity index 100% rename from _release/help/commands/3d_commands/ProjectedY.htm rename to #Test/help/commands/3d_commands/ProjectedY.htm diff --git a/_release/help/commands/3d_commands/ProjectedZ.htm b/#Test/help/commands/3d_commands/ProjectedZ.htm similarity index 100% rename from _release/help/commands/3d_commands/ProjectedZ.htm rename to #Test/help/commands/3d_commands/ProjectedZ.htm diff --git a/_release/help/commands/3d_commands/RenderWorld.htm b/#Test/help/commands/3d_commands/RenderWorld.htm similarity index 100% rename from _release/help/commands/3d_commands/RenderWorld.htm rename to #Test/help/commands/3d_commands/RenderWorld.htm diff --git a/_release/help/commands/3d_commands/ResetEntity.htm b/#Test/help/commands/3d_commands/ResetEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/ResetEntity.htm rename to #Test/help/commands/3d_commands/ResetEntity.htm diff --git a/_release/help/commands/3d_commands/RotateEntity.htm b/#Test/help/commands/3d_commands/RotateEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/RotateEntity.htm rename to #Test/help/commands/3d_commands/RotateEntity.htm diff --git a/_release/help/commands/3d_commands/RotateMesh.htm b/#Test/help/commands/3d_commands/RotateMesh.htm similarity index 100% rename from _release/help/commands/3d_commands/RotateMesh.htm rename to #Test/help/commands/3d_commands/RotateMesh.htm diff --git a/_release/help/commands/3d_commands/RotateSprite.htm b/#Test/help/commands/3d_commands/RotateSprite.htm similarity index 100% rename from _release/help/commands/3d_commands/RotateSprite.htm rename to #Test/help/commands/3d_commands/RotateSprite.htm diff --git a/_release/help/commands/3d_commands/RotateTexture.htm b/#Test/help/commands/3d_commands/RotateTexture.htm similarity index 100% rename from _release/help/commands/3d_commands/RotateTexture.htm rename to #Test/help/commands/3d_commands/RotateTexture.htm diff --git a/_release/help/commands/3d_commands/ScaleEntity.htm b/#Test/help/commands/3d_commands/ScaleEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/ScaleEntity.htm rename to #Test/help/commands/3d_commands/ScaleEntity.htm diff --git a/_release/help/commands/3d_commands/ScaleMesh.htm b/#Test/help/commands/3d_commands/ScaleMesh.htm similarity index 100% rename from _release/help/commands/3d_commands/ScaleMesh.htm rename to #Test/help/commands/3d_commands/ScaleMesh.htm diff --git a/_release/help/commands/3d_commands/ScaleSprite.htm b/#Test/help/commands/3d_commands/ScaleSprite.htm similarity index 100% rename from _release/help/commands/3d_commands/ScaleSprite.htm rename to #Test/help/commands/3d_commands/ScaleSprite.htm diff --git a/_release/help/commands/3d_commands/ScaleTexture.htm b/#Test/help/commands/3d_commands/ScaleTexture.htm similarity index 100% rename from _release/help/commands/3d_commands/ScaleTexture.htm rename to #Test/help/commands/3d_commands/ScaleTexture.htm diff --git a/_release/help/commands/3d_commands/SetAnimKey.htm b/#Test/help/commands/3d_commands/SetAnimKey.htm similarity index 100% rename from _release/help/commands/3d_commands/SetAnimKey.htm rename to #Test/help/commands/3d_commands/SetAnimKey.htm diff --git a/_release/help/commands/3d_commands/ShowEntity.htm b/#Test/help/commands/3d_commands/ShowEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/ShowEntity.htm rename to #Test/help/commands/3d_commands/ShowEntity.htm diff --git a/_release/help/commands/3d_commands/SpriteViewMode.htm b/#Test/help/commands/3d_commands/SpriteViewMode.htm similarity index 100% rename from _release/help/commands/3d_commands/SpriteViewMode.htm rename to #Test/help/commands/3d_commands/SpriteViewMode.htm diff --git a/_release/help/commands/3d_commands/TFormNormal.htm b/#Test/help/commands/3d_commands/TFormNormal.htm similarity index 100% rename from _release/help/commands/3d_commands/TFormNormal.htm rename to #Test/help/commands/3d_commands/TFormNormal.htm diff --git a/_release/help/commands/3d_commands/TFormPoint.htm b/#Test/help/commands/3d_commands/TFormPoint.htm similarity index 100% rename from _release/help/commands/3d_commands/TFormPoint.htm rename to #Test/help/commands/3d_commands/TFormPoint.htm diff --git a/_release/help/commands/3d_commands/TFormVector.htm b/#Test/help/commands/3d_commands/TFormVector.htm similarity index 100% rename from _release/help/commands/3d_commands/TFormVector.htm rename to #Test/help/commands/3d_commands/TFormVector.htm diff --git a/_release/help/commands/3d_commands/TFormedX.htm b/#Test/help/commands/3d_commands/TFormedX.htm similarity index 100% rename from _release/help/commands/3d_commands/TFormedX.htm rename to #Test/help/commands/3d_commands/TFormedX.htm diff --git a/_release/help/commands/3d_commands/TFormedY.htm b/#Test/help/commands/3d_commands/TFormedY.htm similarity index 100% rename from _release/help/commands/3d_commands/TFormedY.htm rename to #Test/help/commands/3d_commands/TFormedY.htm diff --git a/_release/help/commands/3d_commands/TFormedZ.htm b/#Test/help/commands/3d_commands/TFormedZ.htm similarity index 100% rename from _release/help/commands/3d_commands/TFormedZ.htm rename to #Test/help/commands/3d_commands/TFormedZ.htm diff --git a/_release/help/commands/3d_commands/TerrainDetail.htm b/#Test/help/commands/3d_commands/TerrainDetail.htm similarity index 100% rename from _release/help/commands/3d_commands/TerrainDetail.htm rename to #Test/help/commands/3d_commands/TerrainDetail.htm diff --git a/_release/help/commands/3d_commands/TerrainHeight.htm b/#Test/help/commands/3d_commands/TerrainHeight.htm similarity index 100% rename from _release/help/commands/3d_commands/TerrainHeight.htm rename to #Test/help/commands/3d_commands/TerrainHeight.htm diff --git a/_release/help/commands/3d_commands/TerrainShading.htm b/#Test/help/commands/3d_commands/TerrainShading.htm similarity index 100% rename from _release/help/commands/3d_commands/TerrainShading.htm rename to #Test/help/commands/3d_commands/TerrainShading.htm diff --git a/_release/help/commands/3d_commands/TerrainSize.htm b/#Test/help/commands/3d_commands/TerrainSize.htm similarity index 100% rename from _release/help/commands/3d_commands/TerrainSize.htm rename to #Test/help/commands/3d_commands/TerrainSize.htm diff --git a/_release/help/commands/3d_commands/TerrainX.htm b/#Test/help/commands/3d_commands/TerrainX.htm similarity index 100% rename from _release/help/commands/3d_commands/TerrainX.htm rename to #Test/help/commands/3d_commands/TerrainX.htm diff --git a/_release/help/commands/3d_commands/TerrainY.htm b/#Test/help/commands/3d_commands/TerrainY.htm similarity index 100% rename from _release/help/commands/3d_commands/TerrainY.htm rename to #Test/help/commands/3d_commands/TerrainY.htm diff --git a/_release/help/commands/3d_commands/TerrainZ.htm b/#Test/help/commands/3d_commands/TerrainZ.htm similarity index 100% rename from _release/help/commands/3d_commands/TerrainZ.htm rename to #Test/help/commands/3d_commands/TerrainZ.htm diff --git a/_release/help/commands/3d_commands/TextureBlend.htm b/#Test/help/commands/3d_commands/TextureBlend.htm similarity index 100% rename from _release/help/commands/3d_commands/TextureBlend.htm rename to #Test/help/commands/3d_commands/TextureBlend.htm diff --git a/_release/help/commands/3d_commands/TextureBuffer.htm b/#Test/help/commands/3d_commands/TextureBuffer.htm similarity index 100% rename from _release/help/commands/3d_commands/TextureBuffer.htm rename to #Test/help/commands/3d_commands/TextureBuffer.htm diff --git a/_release/help/commands/3d_commands/TextureCoords.htm b/#Test/help/commands/3d_commands/TextureCoords.htm similarity index 100% rename from _release/help/commands/3d_commands/TextureCoords.htm rename to #Test/help/commands/3d_commands/TextureCoords.htm diff --git a/_release/help/commands/3d_commands/TextureFilter.htm b/#Test/help/commands/3d_commands/TextureFilter.htm similarity index 100% rename from _release/help/commands/3d_commands/TextureFilter.htm rename to #Test/help/commands/3d_commands/TextureFilter.htm diff --git a/_release/help/commands/3d_commands/TextureHeight.htm b/#Test/help/commands/3d_commands/TextureHeight.htm similarity index 100% rename from _release/help/commands/3d_commands/TextureHeight.htm rename to #Test/help/commands/3d_commands/TextureHeight.htm diff --git a/_release/help/commands/3d_commands/TextureWidth.htm b/#Test/help/commands/3d_commands/TextureWidth.htm similarity index 100% rename from _release/help/commands/3d_commands/TextureWidth.htm rename to #Test/help/commands/3d_commands/TextureWidth.htm diff --git a/_release/help/commands/3d_commands/TranslateEntity.htm b/#Test/help/commands/3d_commands/TranslateEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/TranslateEntity.htm rename to #Test/help/commands/3d_commands/TranslateEntity.htm diff --git a/_release/help/commands/3d_commands/TriangleVertex.htm b/#Test/help/commands/3d_commands/TriangleVertex.htm similarity index 100% rename from _release/help/commands/3d_commands/TriangleVertex.htm rename to #Test/help/commands/3d_commands/TriangleVertex.htm diff --git a/_release/help/commands/3d_commands/TurnEntity.htm b/#Test/help/commands/3d_commands/TurnEntity.htm similarity index 100% rename from _release/help/commands/3d_commands/TurnEntity.htm rename to #Test/help/commands/3d_commands/TurnEntity.htm diff --git a/_release/help/commands/3d_commands/UpdateNormals.htm b/#Test/help/commands/3d_commands/UpdateNormals.htm similarity index 100% rename from _release/help/commands/3d_commands/UpdateNormals.htm rename to #Test/help/commands/3d_commands/UpdateNormals.htm diff --git a/_release/help/commands/3d_commands/UpdateWorld.htm b/#Test/help/commands/3d_commands/UpdateWorld.htm similarity index 100% rename from _release/help/commands/3d_commands/UpdateWorld.htm rename to #Test/help/commands/3d_commands/UpdateWorld.htm diff --git a/_release/help/commands/3d_commands/VertexBlue.htm b/#Test/help/commands/3d_commands/VertexBlue.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexBlue.htm rename to #Test/help/commands/3d_commands/VertexBlue.htm diff --git a/_release/help/commands/3d_commands/VertexColor.htm b/#Test/help/commands/3d_commands/VertexColor.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexColor.htm rename to #Test/help/commands/3d_commands/VertexColor.htm diff --git a/_release/help/commands/3d_commands/VertexCoords.htm b/#Test/help/commands/3d_commands/VertexCoords.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexCoords.htm rename to #Test/help/commands/3d_commands/VertexCoords.htm diff --git a/_release/help/commands/3d_commands/VertexGreen.htm b/#Test/help/commands/3d_commands/VertexGreen.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexGreen.htm rename to #Test/help/commands/3d_commands/VertexGreen.htm diff --git a/_release/help/commands/3d_commands/VertexNX.htm b/#Test/help/commands/3d_commands/VertexNX.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexNX.htm rename to #Test/help/commands/3d_commands/VertexNX.htm diff --git a/_release/help/commands/3d_commands/VertexNY.htm b/#Test/help/commands/3d_commands/VertexNY.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexNY.htm rename to #Test/help/commands/3d_commands/VertexNY.htm diff --git a/_release/help/commands/3d_commands/VertexNZ.htm b/#Test/help/commands/3d_commands/VertexNZ.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexNZ.htm rename to #Test/help/commands/3d_commands/VertexNZ.htm diff --git a/_release/help/commands/3d_commands/VertexNormal.htm b/#Test/help/commands/3d_commands/VertexNormal.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexNormal.htm rename to #Test/help/commands/3d_commands/VertexNormal.htm diff --git a/_release/help/commands/3d_commands/VertexRed.htm b/#Test/help/commands/3d_commands/VertexRed.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexRed.htm rename to #Test/help/commands/3d_commands/VertexRed.htm diff --git a/_release/help/commands/3d_commands/VertexTexCoords.htm b/#Test/help/commands/3d_commands/VertexTexCoords.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexTexCoords.htm rename to #Test/help/commands/3d_commands/VertexTexCoords.htm diff --git a/_release/help/commands/3d_commands/VertexU.htm b/#Test/help/commands/3d_commands/VertexU.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexU.htm rename to #Test/help/commands/3d_commands/VertexU.htm diff --git a/_release/help/commands/3d_commands/VertexV.htm b/#Test/help/commands/3d_commands/VertexV.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexV.htm rename to #Test/help/commands/3d_commands/VertexV.htm diff --git a/_release/help/commands/3d_commands/VertexW.htm b/#Test/help/commands/3d_commands/VertexW.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexW.htm rename to #Test/help/commands/3d_commands/VertexW.htm diff --git a/_release/help/commands/3d_commands/VertexX.htm b/#Test/help/commands/3d_commands/VertexX.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexX.htm rename to #Test/help/commands/3d_commands/VertexX.htm diff --git a/_release/help/commands/3d_commands/VertexY.htm b/#Test/help/commands/3d_commands/VertexY.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexY.htm rename to #Test/help/commands/3d_commands/VertexY.htm diff --git a/_release/help/commands/3d_commands/VertexZ.htm b/#Test/help/commands/3d_commands/VertexZ.htm similarity index 100% rename from _release/help/commands/3d_commands/VertexZ.htm rename to #Test/help/commands/3d_commands/VertexZ.htm diff --git a/_release/help/commands/3d_commands/WBuffer.htm b/#Test/help/commands/3d_commands/WBuffer.htm similarity index 100% rename from _release/help/commands/3d_commands/WBuffer.htm rename to #Test/help/commands/3d_commands/WBuffer.htm diff --git a/_release/help/commands/3d_commands/Windowed3D.htm b/#Test/help/commands/3d_commands/Windowed3D.htm similarity index 100% rename from _release/help/commands/3d_commands/Windowed3D.htm rename to #Test/help/commands/3d_commands/Windowed3D.htm diff --git a/_release/help/commands/3d_commands/Wireframe.htm b/#Test/help/commands/3d_commands/Wireframe.htm similarity index 100% rename from _release/help/commands/3d_commands/Wireframe.htm rename to #Test/help/commands/3d_commands/Wireframe.htm diff --git a/_release/help/commands/3d_commands/main.htm b/#Test/help/commands/3d_commands/main.htm similarity index 100% rename from _release/help/commands/3d_commands/main.htm rename to #Test/help/commands/3d_commands/main.htm diff --git a/_release/help/commands/3d_commands/template.htm b/#Test/help/commands/3d_commands/template.htm similarity index 100% rename from _release/help/commands/3d_commands/template.htm rename to #Test/help/commands/3d_commands/template.htm diff --git a/_release/help/commands/3d_examples/AddAnimSeq.bb b/#Test/help/commands/3d_examples/AddAnimSeq.bb similarity index 100% rename from _release/help/commands/3d_examples/AddAnimSeq.bb rename to #Test/help/commands/3d_examples/AddAnimSeq.bb diff --git a/_release/help/commands/3d_examples/AddTriangle.bb b/#Test/help/commands/3d_examples/AddTriangle.bb similarity index 100% rename from _release/help/commands/3d_examples/AddTriangle.bb rename to #Test/help/commands/3d_examples/AddTriangle.bb diff --git a/_release/help/commands/3d_examples/AddVertex.bb b/#Test/help/commands/3d_examples/AddVertex.bb similarity index 100% rename from _release/help/commands/3d_examples/AddVertex.bb rename to #Test/help/commands/3d_examples/AddVertex.bb diff --git a/_release/help/commands/3d_examples/AlignToVector.bb b/#Test/help/commands/3d_examples/AlignToVector.bb similarity index 100% rename from _release/help/commands/3d_examples/AlignToVector.bb rename to #Test/help/commands/3d_examples/AlignToVector.bb diff --git a/_release/help/commands/3d_examples/AmbientLight.bb b/#Test/help/commands/3d_examples/AmbientLight.bb similarity index 100% rename from _release/help/commands/3d_examples/AmbientLight.bb rename to #Test/help/commands/3d_examples/AmbientLight.bb diff --git a/_release/help/commands/3d_examples/AnimLength.bb b/#Test/help/commands/3d_examples/AnimLength.bb similarity index 100% rename from _release/help/commands/3d_examples/AnimLength.bb rename to #Test/help/commands/3d_examples/AnimLength.bb diff --git a/_release/help/commands/3d_examples/AnimSeq.bb b/#Test/help/commands/3d_examples/AnimSeq.bb similarity index 100% rename from _release/help/commands/3d_examples/AnimSeq.bb rename to #Test/help/commands/3d_examples/AnimSeq.bb diff --git a/_release/help/commands/3d_examples/AnimTime.bb b/#Test/help/commands/3d_examples/AnimTime.bb similarity index 100% rename from _release/help/commands/3d_examples/AnimTime.bb rename to #Test/help/commands/3d_examples/AnimTime.bb diff --git a/_release/help/commands/3d_examples/Animate.bb b/#Test/help/commands/3d_examples/Animate.bb similarity index 100% rename from _release/help/commands/3d_examples/Animate.bb rename to #Test/help/commands/3d_examples/Animate.bb diff --git a/_release/help/commands/3d_examples/AnimateMD2.bb b/#Test/help/commands/3d_examples/AnimateMD2.bb similarity index 100% rename from _release/help/commands/3d_examples/AnimateMD2.bb rename to #Test/help/commands/3d_examples/AnimateMD2.bb diff --git a/_release/help/commands/3d_examples/Animating.bb b/#Test/help/commands/3d_examples/Animating.bb similarity index 100% rename from _release/help/commands/3d_examples/Animating.bb rename to #Test/help/commands/3d_examples/Animating.bb diff --git a/_release/help/commands/3d_examples/AntiAlias.bb b/#Test/help/commands/3d_examples/AntiAlias.bb similarity index 100% rename from _release/help/commands/3d_examples/AntiAlias.bb rename to #Test/help/commands/3d_examples/AntiAlias.bb diff --git a/_release/help/commands/3d_examples/BrushAlpha.bb b/#Test/help/commands/3d_examples/BrushAlpha.bb similarity index 100% rename from _release/help/commands/3d_examples/BrushAlpha.bb rename to #Test/help/commands/3d_examples/BrushAlpha.bb diff --git a/_release/help/commands/3d_examples/BrushBlend.bb b/#Test/help/commands/3d_examples/BrushBlend.bb similarity index 100% rename from _release/help/commands/3d_examples/BrushBlend.bb rename to #Test/help/commands/3d_examples/BrushBlend.bb diff --git a/_release/help/commands/3d_examples/BrushColor.bb b/#Test/help/commands/3d_examples/BrushColor.bb similarity index 100% rename from _release/help/commands/3d_examples/BrushColor.bb rename to #Test/help/commands/3d_examples/BrushColor.bb diff --git a/_release/help/commands/3d_examples/BrushFX.bb b/#Test/help/commands/3d_examples/BrushFX.bb similarity index 100% rename from _release/help/commands/3d_examples/BrushFX.bb rename to #Test/help/commands/3d_examples/BrushFX.bb diff --git a/_release/help/commands/3d_examples/BrushShininess.bb b/#Test/help/commands/3d_examples/BrushShininess.bb similarity index 100% rename from _release/help/commands/3d_examples/BrushShininess.bb rename to #Test/help/commands/3d_examples/BrushShininess.bb diff --git a/_release/help/commands/3d_examples/BrushTexture.bb b/#Test/help/commands/3d_examples/BrushTexture.bb similarity index 100% rename from _release/help/commands/3d_examples/BrushTexture.bb rename to #Test/help/commands/3d_examples/BrushTexture.bb diff --git a/_release/help/commands/3d_examples/CameraClsColor.bb b/#Test/help/commands/3d_examples/CameraClsColor.bb similarity index 100% rename from _release/help/commands/3d_examples/CameraClsColor.bb rename to #Test/help/commands/3d_examples/CameraClsColor.bb diff --git a/_release/help/commands/3d_examples/CameraClsMode.bb b/#Test/help/commands/3d_examples/CameraClsMode.bb similarity index 100% rename from _release/help/commands/3d_examples/CameraClsMode.bb rename to #Test/help/commands/3d_examples/CameraClsMode.bb diff --git a/_release/help/commands/3d_examples/CameraFogColor.bb b/#Test/help/commands/3d_examples/CameraFogColor.bb similarity index 100% rename from _release/help/commands/3d_examples/CameraFogColor.bb rename to #Test/help/commands/3d_examples/CameraFogColor.bb diff --git a/_release/help/commands/3d_examples/CameraFogMode.bb b/#Test/help/commands/3d_examples/CameraFogMode.bb similarity index 100% rename from _release/help/commands/3d_examples/CameraFogMode.bb rename to #Test/help/commands/3d_examples/CameraFogMode.bb diff --git a/_release/help/commands/3d_examples/CameraFogRange.bb b/#Test/help/commands/3d_examples/CameraFogRange.bb similarity index 100% rename from _release/help/commands/3d_examples/CameraFogRange.bb rename to #Test/help/commands/3d_examples/CameraFogRange.bb diff --git a/_release/help/commands/3d_examples/CameraPick.bb b/#Test/help/commands/3d_examples/CameraPick.bb similarity index 100% rename from _release/help/commands/3d_examples/CameraPick.bb rename to #Test/help/commands/3d_examples/CameraPick.bb diff --git a/_release/help/commands/3d_examples/CameraProject.bb b/#Test/help/commands/3d_examples/CameraProject.bb similarity index 100% rename from _release/help/commands/3d_examples/CameraProject.bb rename to #Test/help/commands/3d_examples/CameraProject.bb diff --git a/_release/help/commands/3d_examples/CameraRange.bb b/#Test/help/commands/3d_examples/CameraRange.bb similarity index 100% rename from _release/help/commands/3d_examples/CameraRange.bb rename to #Test/help/commands/3d_examples/CameraRange.bb diff --git a/_release/help/commands/3d_examples/CameraViewport.bb b/#Test/help/commands/3d_examples/CameraViewport.bb similarity index 100% rename from _release/help/commands/3d_examples/CameraViewport.bb rename to #Test/help/commands/3d_examples/CameraViewport.bb diff --git a/_release/help/commands/3d_examples/CameraZoom.bb b/#Test/help/commands/3d_examples/CameraZoom.bb similarity index 100% rename from _release/help/commands/3d_examples/CameraZoom.bb rename to #Test/help/commands/3d_examples/CameraZoom.bb diff --git a/_release/help/commands/3d_examples/CaptureWorld.bb b/#Test/help/commands/3d_examples/CaptureWorld.bb similarity index 100% rename from _release/help/commands/3d_examples/CaptureWorld.bb rename to #Test/help/commands/3d_examples/CaptureWorld.bb diff --git a/_release/help/commands/3d_examples/ClearCollisions.bb b/#Test/help/commands/3d_examples/ClearCollisions.bb similarity index 100% rename from _release/help/commands/3d_examples/ClearCollisions.bb rename to #Test/help/commands/3d_examples/ClearCollisions.bb diff --git a/_release/help/commands/3d_examples/ClearSurface.bb b/#Test/help/commands/3d_examples/ClearSurface.bb similarity index 100% rename from _release/help/commands/3d_examples/ClearSurface.bb rename to #Test/help/commands/3d_examples/ClearSurface.bb diff --git a/_release/help/commands/3d_examples/ClearTextureFilters.bb b/#Test/help/commands/3d_examples/ClearTextureFilters.bb similarity index 100% rename from _release/help/commands/3d_examples/ClearTextureFilters.bb rename to #Test/help/commands/3d_examples/ClearTextureFilters.bb diff --git a/_release/help/commands/3d_examples/ClearWorld.bb b/#Test/help/commands/3d_examples/ClearWorld.bb similarity index 100% rename from _release/help/commands/3d_examples/ClearWorld.bb rename to #Test/help/commands/3d_examples/ClearWorld.bb diff --git a/_release/help/commands/3d_examples/CollisionEntity.bb b/#Test/help/commands/3d_examples/CollisionEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/CollisionEntity.bb rename to #Test/help/commands/3d_examples/CollisionEntity.bb diff --git a/_release/help/commands/3d_examples/CollisionNX.bb b/#Test/help/commands/3d_examples/CollisionNX.bb similarity index 100% rename from _release/help/commands/3d_examples/CollisionNX.bb rename to #Test/help/commands/3d_examples/CollisionNX.bb diff --git a/_release/help/commands/3d_examples/CollisionNY.bb b/#Test/help/commands/3d_examples/CollisionNY.bb similarity index 100% rename from _release/help/commands/3d_examples/CollisionNY.bb rename to #Test/help/commands/3d_examples/CollisionNY.bb diff --git a/_release/help/commands/3d_examples/CollisionNZ.bb b/#Test/help/commands/3d_examples/CollisionNZ.bb similarity index 100% rename from _release/help/commands/3d_examples/CollisionNZ.bb rename to #Test/help/commands/3d_examples/CollisionNZ.bb diff --git a/_release/help/commands/3d_examples/CollisionSurface.bb b/#Test/help/commands/3d_examples/CollisionSurface.bb similarity index 100% rename from _release/help/commands/3d_examples/CollisionSurface.bb rename to #Test/help/commands/3d_examples/CollisionSurface.bb diff --git a/_release/help/commands/3d_examples/CollisionTime.bb b/#Test/help/commands/3d_examples/CollisionTime.bb similarity index 100% rename from _release/help/commands/3d_examples/CollisionTime.bb rename to #Test/help/commands/3d_examples/CollisionTime.bb diff --git a/_release/help/commands/3d_examples/CollisionTriangle.bb b/#Test/help/commands/3d_examples/CollisionTriangle.bb similarity index 100% rename from _release/help/commands/3d_examples/CollisionTriangle.bb rename to #Test/help/commands/3d_examples/CollisionTriangle.bb diff --git a/_release/help/commands/3d_examples/CollisionX.bb b/#Test/help/commands/3d_examples/CollisionX.bb similarity index 100% rename from _release/help/commands/3d_examples/CollisionX.bb rename to #Test/help/commands/3d_examples/CollisionX.bb diff --git a/_release/help/commands/3d_examples/CollisionY.bb b/#Test/help/commands/3d_examples/CollisionY.bb similarity index 100% rename from _release/help/commands/3d_examples/CollisionY.bb rename to #Test/help/commands/3d_examples/CollisionY.bb diff --git a/_release/help/commands/3d_examples/CollisionZ.bb b/#Test/help/commands/3d_examples/CollisionZ.bb similarity index 100% rename from _release/help/commands/3d_examples/CollisionZ.bb rename to #Test/help/commands/3d_examples/CollisionZ.bb diff --git a/_release/help/commands/3d_examples/Collisions.bb b/#Test/help/commands/3d_examples/Collisions.bb similarity index 100% rename from _release/help/commands/3d_examples/Collisions.bb rename to #Test/help/commands/3d_examples/Collisions.bb diff --git a/_release/help/commands/3d_examples/CopyEntity.bb b/#Test/help/commands/3d_examples/CopyEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/CopyEntity.bb rename to #Test/help/commands/3d_examples/CopyEntity.bb diff --git a/_release/help/commands/3d_examples/CountChildren.bb b/#Test/help/commands/3d_examples/CountChildren.bb similarity index 100% rename from _release/help/commands/3d_examples/CountChildren.bb rename to #Test/help/commands/3d_examples/CountChildren.bb diff --git a/_release/help/commands/3d_examples/CountCollisions.bb b/#Test/help/commands/3d_examples/CountCollisions.bb similarity index 100% rename from _release/help/commands/3d_examples/CountCollisions.bb rename to #Test/help/commands/3d_examples/CountCollisions.bb diff --git a/_release/help/commands/3d_examples/CountSurfaces.bb b/#Test/help/commands/3d_examples/CountSurfaces.bb similarity index 100% rename from _release/help/commands/3d_examples/CountSurfaces.bb rename to #Test/help/commands/3d_examples/CountSurfaces.bb diff --git a/_release/help/commands/3d_examples/CountTriangles.bb b/#Test/help/commands/3d_examples/CountTriangles.bb similarity index 100% rename from _release/help/commands/3d_examples/CountTriangles.bb rename to #Test/help/commands/3d_examples/CountTriangles.bb diff --git a/_release/help/commands/3d_examples/CountVertices.bb b/#Test/help/commands/3d_examples/CountVertices.bb similarity index 100% rename from _release/help/commands/3d_examples/CountVertices.bb rename to #Test/help/commands/3d_examples/CountVertices.bb diff --git a/_release/help/commands/3d_examples/CreateBrush.bb b/#Test/help/commands/3d_examples/CreateBrush.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateBrush.bb rename to #Test/help/commands/3d_examples/CreateBrush.bb diff --git a/_release/help/commands/3d_examples/CreateCamera.bb b/#Test/help/commands/3d_examples/CreateCamera.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateCamera.bb rename to #Test/help/commands/3d_examples/CreateCamera.bb diff --git a/_release/help/commands/3d_examples/CreateCone.bb b/#Test/help/commands/3d_examples/CreateCone.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateCone.bb rename to #Test/help/commands/3d_examples/CreateCone.bb diff --git a/_release/help/commands/3d_examples/CreateCube.bb b/#Test/help/commands/3d_examples/CreateCube.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateCube.bb rename to #Test/help/commands/3d_examples/CreateCube.bb diff --git a/_release/help/commands/3d_examples/CreateCylinder.bb b/#Test/help/commands/3d_examples/CreateCylinder.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateCylinder.bb rename to #Test/help/commands/3d_examples/CreateCylinder.bb diff --git a/_release/help/commands/3d_examples/CreateLight.bb b/#Test/help/commands/3d_examples/CreateLight.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateLight.bb rename to #Test/help/commands/3d_examples/CreateLight.bb diff --git a/_release/help/commands/3d_examples/CreateListener.bb b/#Test/help/commands/3d_examples/CreateListener.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateListener.bb rename to #Test/help/commands/3d_examples/CreateListener.bb diff --git a/_release/help/commands/3d_examples/CreateMesh.bb b/#Test/help/commands/3d_examples/CreateMesh.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateMesh.bb rename to #Test/help/commands/3d_examples/CreateMesh.bb diff --git a/_release/help/commands/3d_examples/CreateMirror.bb b/#Test/help/commands/3d_examples/CreateMirror.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateMirror.bb rename to #Test/help/commands/3d_examples/CreateMirror.bb diff --git a/_release/help/commands/3d_examples/CreatePivot.bb b/#Test/help/commands/3d_examples/CreatePivot.bb similarity index 100% rename from _release/help/commands/3d_examples/CreatePivot.bb rename to #Test/help/commands/3d_examples/CreatePivot.bb diff --git a/_release/help/commands/3d_examples/CreatePlane.bb b/#Test/help/commands/3d_examples/CreatePlane.bb similarity index 100% rename from _release/help/commands/3d_examples/CreatePlane.bb rename to #Test/help/commands/3d_examples/CreatePlane.bb diff --git a/_release/help/commands/3d_examples/CreateSphere.bb b/#Test/help/commands/3d_examples/CreateSphere.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateSphere.bb rename to #Test/help/commands/3d_examples/CreateSphere.bb diff --git a/_release/help/commands/3d_examples/CreateSprite.bb b/#Test/help/commands/3d_examples/CreateSprite.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateSprite.bb rename to #Test/help/commands/3d_examples/CreateSprite.bb diff --git a/_release/help/commands/3d_examples/CreateSurface.bb b/#Test/help/commands/3d_examples/CreateSurface.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateSurface.bb rename to #Test/help/commands/3d_examples/CreateSurface.bb diff --git a/_release/help/commands/3d_examples/CreateTerrain.bb b/#Test/help/commands/3d_examples/CreateTerrain.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateTerrain.bb rename to #Test/help/commands/3d_examples/CreateTerrain.bb diff --git a/_release/help/commands/3d_examples/CreateTexture.bb b/#Test/help/commands/3d_examples/CreateTexture.bb similarity index 100% rename from _release/help/commands/3d_examples/CreateTexture.bb rename to #Test/help/commands/3d_examples/CreateTexture.bb diff --git a/_release/help/commands/3d_examples/Dither.bb b/#Test/help/commands/3d_examples/Dither.bb similarity index 100% rename from _release/help/commands/3d_examples/Dither.bb rename to #Test/help/commands/3d_examples/Dither.bb diff --git a/_release/help/commands/3d_examples/EmitSound.bb b/#Test/help/commands/3d_examples/EmitSound.bb similarity index 100% rename from _release/help/commands/3d_examples/EmitSound.bb rename to #Test/help/commands/3d_examples/EmitSound.bb diff --git a/_release/help/commands/3d_examples/EntityAlpha.bb b/#Test/help/commands/3d_examples/EntityAlpha.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityAlpha.bb rename to #Test/help/commands/3d_examples/EntityAlpha.bb diff --git a/_release/help/commands/3d_examples/EntityAnimTime.bb b/#Test/help/commands/3d_examples/EntityAnimTime.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityAnimTime.bb rename to #Test/help/commands/3d_examples/EntityAnimTime.bb diff --git a/_release/help/commands/3d_examples/EntityAnimating.bb b/#Test/help/commands/3d_examples/EntityAnimating.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityAnimating.bb rename to #Test/help/commands/3d_examples/EntityAnimating.bb diff --git a/_release/help/commands/3d_examples/EntityAutoFade.bb b/#Test/help/commands/3d_examples/EntityAutoFade.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityAutoFade.bb rename to #Test/help/commands/3d_examples/EntityAutoFade.bb diff --git a/_release/help/commands/3d_examples/EntityBlend.bb b/#Test/help/commands/3d_examples/EntityBlend.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityBlend.bb rename to #Test/help/commands/3d_examples/EntityBlend.bb diff --git a/_release/help/commands/3d_examples/EntityBox.bb b/#Test/help/commands/3d_examples/EntityBox.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityBox.bb rename to #Test/help/commands/3d_examples/EntityBox.bb diff --git a/_release/help/commands/3d_examples/EntityCollided.bb b/#Test/help/commands/3d_examples/EntityCollided.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityCollided.bb rename to #Test/help/commands/3d_examples/EntityCollided.bb diff --git a/_release/help/commands/3d_examples/EntityColor.bb b/#Test/help/commands/3d_examples/EntityColor.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityColor.bb rename to #Test/help/commands/3d_examples/EntityColor.bb diff --git a/_release/help/commands/3d_examples/EntityDistance.bb b/#Test/help/commands/3d_examples/EntityDistance.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityDistance.bb rename to #Test/help/commands/3d_examples/EntityDistance.bb diff --git a/_release/help/commands/3d_examples/EntityFX.bb b/#Test/help/commands/3d_examples/EntityFX.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityFX.bb rename to #Test/help/commands/3d_examples/EntityFX.bb diff --git a/_release/help/commands/3d_examples/EntityInView.bb b/#Test/help/commands/3d_examples/EntityInView.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityInView.bb rename to #Test/help/commands/3d_examples/EntityInView.bb diff --git a/_release/help/commands/3d_examples/EntityName.bb b/#Test/help/commands/3d_examples/EntityName.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityName.bb rename to #Test/help/commands/3d_examples/EntityName.bb diff --git a/_release/help/commands/3d_examples/EntityOrder.bb b/#Test/help/commands/3d_examples/EntityOrder.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityOrder.bb rename to #Test/help/commands/3d_examples/EntityOrder.bb diff --git a/_release/help/commands/3d_examples/EntityParent.bb b/#Test/help/commands/3d_examples/EntityParent.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityParent.bb rename to #Test/help/commands/3d_examples/EntityParent.bb diff --git a/_release/help/commands/3d_examples/EntityPick.bb b/#Test/help/commands/3d_examples/EntityPick.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityPick.bb rename to #Test/help/commands/3d_examples/EntityPick.bb diff --git a/_release/help/commands/3d_examples/EntityPickMode.bb b/#Test/help/commands/3d_examples/EntityPickMode.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityPickMode.bb rename to #Test/help/commands/3d_examples/EntityPickMode.bb diff --git a/_release/help/commands/3d_examples/EntityPitch.bb b/#Test/help/commands/3d_examples/EntityPitch.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityPitch.bb rename to #Test/help/commands/3d_examples/EntityPitch.bb diff --git a/_release/help/commands/3d_examples/EntityRadius.bb b/#Test/help/commands/3d_examples/EntityRadius.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityRadius.bb rename to #Test/help/commands/3d_examples/EntityRadius.bb diff --git a/_release/help/commands/3d_examples/EntityRoll.bb b/#Test/help/commands/3d_examples/EntityRoll.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityRoll.bb rename to #Test/help/commands/3d_examples/EntityRoll.bb diff --git a/_release/help/commands/3d_examples/EntityShininess.bb b/#Test/help/commands/3d_examples/EntityShininess.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityShininess.bb rename to #Test/help/commands/3d_examples/EntityShininess.bb diff --git a/_release/help/commands/3d_examples/EntityTexture.bb b/#Test/help/commands/3d_examples/EntityTexture.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityTexture.bb rename to #Test/help/commands/3d_examples/EntityTexture.bb diff --git a/_release/help/commands/3d_examples/EntityType.bb b/#Test/help/commands/3d_examples/EntityType.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityType.bb rename to #Test/help/commands/3d_examples/EntityType.bb diff --git a/_release/help/commands/3d_examples/EntityVisible.bb b/#Test/help/commands/3d_examples/EntityVisible.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityVisible.bb rename to #Test/help/commands/3d_examples/EntityVisible.bb diff --git a/_release/help/commands/3d_examples/EntityX.bb b/#Test/help/commands/3d_examples/EntityX.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityX.bb rename to #Test/help/commands/3d_examples/EntityX.bb diff --git a/_release/help/commands/3d_examples/EntityY.bb b/#Test/help/commands/3d_examples/EntityY.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityY.bb rename to #Test/help/commands/3d_examples/EntityY.bb diff --git a/_release/help/commands/3d_examples/EntityYaw.bb b/#Test/help/commands/3d_examples/EntityYaw.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityYaw.bb rename to #Test/help/commands/3d_examples/EntityYaw.bb diff --git a/_release/help/commands/3d_examples/EntityZ.bb b/#Test/help/commands/3d_examples/EntityZ.bb similarity index 100% rename from _release/help/commands/3d_examples/EntityZ.bb rename to #Test/help/commands/3d_examples/EntityZ.bb diff --git a/_release/help/commands/3d_examples/FindChild.bb b/#Test/help/commands/3d_examples/FindChild.bb similarity index 100% rename from _release/help/commands/3d_examples/FindChild.bb rename to #Test/help/commands/3d_examples/FindChild.bb diff --git a/_release/help/commands/3d_examples/FindSurface.bb b/#Test/help/commands/3d_examples/FindSurface.bb similarity index 100% rename from _release/help/commands/3d_examples/FindSurface.bb rename to #Test/help/commands/3d_examples/FindSurface.bb diff --git a/_release/help/commands/3d_examples/FitMesh.bb b/#Test/help/commands/3d_examples/FitMesh.bb similarity index 100% rename from _release/help/commands/3d_examples/FitMesh.bb rename to #Test/help/commands/3d_examples/FitMesh.bb diff --git a/_release/help/commands/3d_examples/FlipMesh.bb b/#Test/help/commands/3d_examples/FlipMesh.bb similarity index 100% rename from _release/help/commands/3d_examples/FlipMesh.bb rename to #Test/help/commands/3d_examples/FlipMesh.bb diff --git a/_release/help/commands/3d_examples/FreeBrush.bb b/#Test/help/commands/3d_examples/FreeBrush.bb similarity index 100% rename from _release/help/commands/3d_examples/FreeBrush.bb rename to #Test/help/commands/3d_examples/FreeBrush.bb diff --git a/_release/help/commands/3d_examples/FreeEntity.bb b/#Test/help/commands/3d_examples/FreeEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/FreeEntity.bb rename to #Test/help/commands/3d_examples/FreeEntity.bb diff --git a/_release/help/commands/3d_examples/FreeTexture.bb b/#Test/help/commands/3d_examples/FreeTexture.bb similarity index 100% rename from _release/help/commands/3d_examples/FreeTexture.bb rename to #Test/help/commands/3d_examples/FreeTexture.bb diff --git a/_release/help/commands/3d_examples/GetChild.bb b/#Test/help/commands/3d_examples/GetChild.bb similarity index 100% rename from _release/help/commands/3d_examples/GetChild.bb rename to #Test/help/commands/3d_examples/GetChild.bb diff --git a/_release/help/commands/3d_examples/GetEntityType.bb b/#Test/help/commands/3d_examples/GetEntityType.bb similarity index 100% rename from _release/help/commands/3d_examples/GetEntityType.bb rename to #Test/help/commands/3d_examples/GetEntityType.bb diff --git a/_release/help/commands/3d_examples/GetParent.bb b/#Test/help/commands/3d_examples/GetParent.bb similarity index 100% rename from _release/help/commands/3d_examples/GetParent.bb rename to #Test/help/commands/3d_examples/GetParent.bb diff --git a/_release/help/commands/3d_examples/GetSurface.bb b/#Test/help/commands/3d_examples/GetSurface.bb similarity index 100% rename from _release/help/commands/3d_examples/GetSurface.bb rename to #Test/help/commands/3d_examples/GetSurface.bb diff --git a/_release/help/commands/3d_examples/GfxDriver3D.bb b/#Test/help/commands/3d_examples/GfxDriver3D.bb similarity index 100% rename from _release/help/commands/3d_examples/GfxDriver3D.bb rename to #Test/help/commands/3d_examples/GfxDriver3D.bb diff --git a/_release/help/commands/3d_examples/GfxMode3D.bb b/#Test/help/commands/3d_examples/GfxMode3D.bb similarity index 100% rename from _release/help/commands/3d_examples/GfxMode3D.bb rename to #Test/help/commands/3d_examples/GfxMode3D.bb diff --git a/_release/help/commands/3d_examples/GfxModeExists.bb b/#Test/help/commands/3d_examples/GfxModeExists.bb similarity index 100% rename from _release/help/commands/3d_examples/GfxModeExists.bb rename to #Test/help/commands/3d_examples/GfxModeExists.bb diff --git a/_release/help/commands/3d_examples/Graphics3D.bb b/#Test/help/commands/3d_examples/Graphics3D.bb similarity index 100% rename from _release/help/commands/3d_examples/Graphics3D.bb rename to #Test/help/commands/3d_examples/Graphics3D.bb diff --git a/_release/help/commands/3d_examples/HWMultiTex.bb b/#Test/help/commands/3d_examples/HWMultiTex.bb similarity index 100% rename from _release/help/commands/3d_examples/HWMultiTex.bb rename to #Test/help/commands/3d_examples/HWMultiTex.bb diff --git a/_release/help/commands/3d_examples/HandleSprite.bb b/#Test/help/commands/3d_examples/HandleSprite.bb similarity index 100% rename from _release/help/commands/3d_examples/HandleSprite.bb rename to #Test/help/commands/3d_examples/HandleSprite.bb diff --git a/_release/help/commands/3d_examples/HideEntity.bb b/#Test/help/commands/3d_examples/HideEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/HideEntity.bb rename to #Test/help/commands/3d_examples/HideEntity.bb diff --git a/_release/help/commands/3d_examples/LightColor.bb b/#Test/help/commands/3d_examples/LightColor.bb similarity index 100% rename from _release/help/commands/3d_examples/LightColor.bb rename to #Test/help/commands/3d_examples/LightColor.bb diff --git a/_release/help/commands/3d_examples/LightConeAngles.bb b/#Test/help/commands/3d_examples/LightConeAngles.bb similarity index 100% rename from _release/help/commands/3d_examples/LightConeAngles.bb rename to #Test/help/commands/3d_examples/LightConeAngles.bb diff --git a/_release/help/commands/3d_examples/LightMesh.bb b/#Test/help/commands/3d_examples/LightMesh.bb similarity index 100% rename from _release/help/commands/3d_examples/LightMesh.bb rename to #Test/help/commands/3d_examples/LightMesh.bb diff --git a/_release/help/commands/3d_examples/LightRange.bb b/#Test/help/commands/3d_examples/LightRange.bb similarity index 100% rename from _release/help/commands/3d_examples/LightRange.bb rename to #Test/help/commands/3d_examples/LightRange.bb diff --git a/_release/help/commands/3d_examples/LinePick.bb b/#Test/help/commands/3d_examples/LinePick.bb similarity index 100% rename from _release/help/commands/3d_examples/LinePick.bb rename to #Test/help/commands/3d_examples/LinePick.bb diff --git a/_release/help/commands/3d_examples/Load3DSound.bb b/#Test/help/commands/3d_examples/Load3DSound.bb similarity index 100% rename from _release/help/commands/3d_examples/Load3DSound.bb rename to #Test/help/commands/3d_examples/Load3DSound.bb diff --git a/_release/help/commands/3d_examples/LoadAnimMesh.bb b/#Test/help/commands/3d_examples/LoadAnimMesh.bb similarity index 100% rename from _release/help/commands/3d_examples/LoadAnimMesh.bb rename to #Test/help/commands/3d_examples/LoadAnimMesh.bb diff --git a/_release/help/commands/3d_examples/LoadAnimSeq.bb b/#Test/help/commands/3d_examples/LoadAnimSeq.bb similarity index 100% rename from _release/help/commands/3d_examples/LoadAnimSeq.bb rename to #Test/help/commands/3d_examples/LoadAnimSeq.bb diff --git a/_release/help/commands/3d_examples/LoadAnimTexture.bb b/#Test/help/commands/3d_examples/LoadAnimTexture.bb similarity index 100% rename from _release/help/commands/3d_examples/LoadAnimTexture.bb rename to #Test/help/commands/3d_examples/LoadAnimTexture.bb diff --git a/_release/help/commands/3d_examples/LoadBrush.bb b/#Test/help/commands/3d_examples/LoadBrush.bb similarity index 100% rename from _release/help/commands/3d_examples/LoadBrush.bb rename to #Test/help/commands/3d_examples/LoadBrush.bb diff --git a/_release/help/commands/3d_examples/LoadMD2.bb b/#Test/help/commands/3d_examples/LoadMD2.bb similarity index 100% rename from _release/help/commands/3d_examples/LoadMD2.bb rename to #Test/help/commands/3d_examples/LoadMD2.bb diff --git a/_release/help/commands/3d_examples/LoadMesh.bb b/#Test/help/commands/3d_examples/LoadMesh.bb similarity index 100% rename from _release/help/commands/3d_examples/LoadMesh.bb rename to #Test/help/commands/3d_examples/LoadMesh.bb diff --git a/_release/help/commands/3d_examples/LoadSprite.bb b/#Test/help/commands/3d_examples/LoadSprite.bb similarity index 100% rename from _release/help/commands/3d_examples/LoadSprite.bb rename to #Test/help/commands/3d_examples/LoadSprite.bb diff --git a/_release/help/commands/3d_examples/LoadTerrain.bb b/#Test/help/commands/3d_examples/LoadTerrain.bb similarity index 100% rename from _release/help/commands/3d_examples/LoadTerrain.bb rename to #Test/help/commands/3d_examples/LoadTerrain.bb diff --git a/_release/help/commands/3d_examples/LoadTexture.bb b/#Test/help/commands/3d_examples/LoadTexture.bb similarity index 100% rename from _release/help/commands/3d_examples/LoadTexture.bb rename to #Test/help/commands/3d_examples/LoadTexture.bb diff --git a/_release/help/commands/3d_examples/LoaderMatrix.bb b/#Test/help/commands/3d_examples/LoaderMatrix.bb similarity index 100% rename from _release/help/commands/3d_examples/LoaderMatrix.bb rename to #Test/help/commands/3d_examples/LoaderMatrix.bb diff --git a/_release/help/commands/3d_examples/MD2AnimLength.bb b/#Test/help/commands/3d_examples/MD2AnimLength.bb similarity index 100% rename from _release/help/commands/3d_examples/MD2AnimLength.bb rename to #Test/help/commands/3d_examples/MD2AnimLength.bb diff --git a/_release/help/commands/3d_examples/MD2AnimTime.bb b/#Test/help/commands/3d_examples/MD2AnimTime.bb similarity index 100% rename from _release/help/commands/3d_examples/MD2AnimTime.bb rename to #Test/help/commands/3d_examples/MD2AnimTime.bb diff --git a/_release/help/commands/3d_examples/MD2Animating.bb b/#Test/help/commands/3d_examples/MD2Animating.bb similarity index 100% rename from _release/help/commands/3d_examples/MD2Animating.bb rename to #Test/help/commands/3d_examples/MD2Animating.bb diff --git a/_release/help/commands/3d_examples/MeshDepth.bb b/#Test/help/commands/3d_examples/MeshDepth.bb similarity index 100% rename from _release/help/commands/3d_examples/MeshDepth.bb rename to #Test/help/commands/3d_examples/MeshDepth.bb diff --git a/_release/help/commands/3d_examples/MeshHeight.bb b/#Test/help/commands/3d_examples/MeshHeight.bb similarity index 100% rename from _release/help/commands/3d_examples/MeshHeight.bb rename to #Test/help/commands/3d_examples/MeshHeight.bb diff --git a/_release/help/commands/3d_examples/MeshWidth.bb b/#Test/help/commands/3d_examples/MeshWidth.bb similarity index 100% rename from _release/help/commands/3d_examples/MeshWidth.bb rename to #Test/help/commands/3d_examples/MeshWidth.bb diff --git a/_release/help/commands/3d_examples/MeshesIntersect.bb b/#Test/help/commands/3d_examples/MeshesIntersect.bb similarity index 100% rename from _release/help/commands/3d_examples/MeshesIntersect.bb rename to #Test/help/commands/3d_examples/MeshesIntersect.bb diff --git a/_release/help/commands/3d_examples/ModifyTerrain.bb b/#Test/help/commands/3d_examples/ModifyTerrain.bb similarity index 100% rename from _release/help/commands/3d_examples/ModifyTerrain.bb rename to #Test/help/commands/3d_examples/ModifyTerrain.bb diff --git a/_release/help/commands/3d_examples/MoveEntity.bb b/#Test/help/commands/3d_examples/MoveEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/MoveEntity.bb rename to #Test/help/commands/3d_examples/MoveEntity.bb diff --git a/_release/help/commands/3d_examples/NameEntity.bb b/#Test/help/commands/3d_examples/NameEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/NameEntity.bb rename to #Test/help/commands/3d_examples/NameEntity.bb diff --git a/_release/help/commands/3d_examples/PaintEntity.bb b/#Test/help/commands/3d_examples/PaintEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/PaintEntity.bb rename to #Test/help/commands/3d_examples/PaintEntity.bb diff --git a/_release/help/commands/3d_examples/PaintMesh.bb b/#Test/help/commands/3d_examples/PaintMesh.bb similarity index 100% rename from _release/help/commands/3d_examples/PaintMesh.bb rename to #Test/help/commands/3d_examples/PaintMesh.bb diff --git a/_release/help/commands/3d_examples/PaintSurface.bb b/#Test/help/commands/3d_examples/PaintSurface.bb similarity index 100% rename from _release/help/commands/3d_examples/PaintSurface.bb rename to #Test/help/commands/3d_examples/PaintSurface.bb diff --git a/_release/help/commands/3d_examples/PickedEntity.bb b/#Test/help/commands/3d_examples/PickedEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/PickedEntity.bb rename to #Test/help/commands/3d_examples/PickedEntity.bb diff --git a/_release/help/commands/3d_examples/PickedNX.bb b/#Test/help/commands/3d_examples/PickedNX.bb similarity index 100% rename from _release/help/commands/3d_examples/PickedNX.bb rename to #Test/help/commands/3d_examples/PickedNX.bb diff --git a/_release/help/commands/3d_examples/PickedNY.bb b/#Test/help/commands/3d_examples/PickedNY.bb similarity index 100% rename from _release/help/commands/3d_examples/PickedNY.bb rename to #Test/help/commands/3d_examples/PickedNY.bb diff --git a/_release/help/commands/3d_examples/PickedNZ.bb b/#Test/help/commands/3d_examples/PickedNZ.bb similarity index 100% rename from _release/help/commands/3d_examples/PickedNZ.bb rename to #Test/help/commands/3d_examples/PickedNZ.bb diff --git a/_release/help/commands/3d_examples/PickedSurface.bb b/#Test/help/commands/3d_examples/PickedSurface.bb similarity index 100% rename from _release/help/commands/3d_examples/PickedSurface.bb rename to #Test/help/commands/3d_examples/PickedSurface.bb diff --git a/_release/help/commands/3d_examples/PickedTime.bb b/#Test/help/commands/3d_examples/PickedTime.bb similarity index 100% rename from _release/help/commands/3d_examples/PickedTime.bb rename to #Test/help/commands/3d_examples/PickedTime.bb diff --git a/_release/help/commands/3d_examples/PickedTriangle.bb b/#Test/help/commands/3d_examples/PickedTriangle.bb similarity index 100% rename from _release/help/commands/3d_examples/PickedTriangle.bb rename to #Test/help/commands/3d_examples/PickedTriangle.bb diff --git a/_release/help/commands/3d_examples/PickedX.bb b/#Test/help/commands/3d_examples/PickedX.bb similarity index 100% rename from _release/help/commands/3d_examples/PickedX.bb rename to #Test/help/commands/3d_examples/PickedX.bb diff --git a/_release/help/commands/3d_examples/PickedY.bb b/#Test/help/commands/3d_examples/PickedY.bb similarity index 100% rename from _release/help/commands/3d_examples/PickedY.bb rename to #Test/help/commands/3d_examples/PickedY.bb diff --git a/_release/help/commands/3d_examples/PickedZ.bb b/#Test/help/commands/3d_examples/PickedZ.bb similarity index 100% rename from _release/help/commands/3d_examples/PickedZ.bb rename to #Test/help/commands/3d_examples/PickedZ.bb diff --git a/_release/help/commands/3d_examples/PointEntity.bb b/#Test/help/commands/3d_examples/PointEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/PointEntity.bb rename to #Test/help/commands/3d_examples/PointEntity.bb diff --git a/_release/help/commands/3d_examples/PositionEntity.bb b/#Test/help/commands/3d_examples/PositionEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/PositionEntity.bb rename to #Test/help/commands/3d_examples/PositionEntity.bb diff --git a/_release/help/commands/3d_examples/PositionMesh.bb b/#Test/help/commands/3d_examples/PositionMesh.bb similarity index 100% rename from _release/help/commands/3d_examples/PositionMesh.bb rename to #Test/help/commands/3d_examples/PositionMesh.bb diff --git a/_release/help/commands/3d_examples/PositionTexture.bb b/#Test/help/commands/3d_examples/PositionTexture.bb similarity index 100% rename from _release/help/commands/3d_examples/PositionTexture.bb rename to #Test/help/commands/3d_examples/PositionTexture.bb diff --git a/_release/help/commands/3d_examples/ProjectedX.bb b/#Test/help/commands/3d_examples/ProjectedX.bb similarity index 100% rename from _release/help/commands/3d_examples/ProjectedX.bb rename to #Test/help/commands/3d_examples/ProjectedX.bb diff --git a/_release/help/commands/3d_examples/ProjectedY.bb b/#Test/help/commands/3d_examples/ProjectedY.bb similarity index 100% rename from _release/help/commands/3d_examples/ProjectedY.bb rename to #Test/help/commands/3d_examples/ProjectedY.bb diff --git a/_release/help/commands/3d_examples/ProjectedZ.bb b/#Test/help/commands/3d_examples/ProjectedZ.bb similarity index 100% rename from _release/help/commands/3d_examples/ProjectedZ.bb rename to #Test/help/commands/3d_examples/ProjectedZ.bb diff --git a/_release/help/commands/3d_examples/RenderWorld.bb b/#Test/help/commands/3d_examples/RenderWorld.bb similarity index 100% rename from _release/help/commands/3d_examples/RenderWorld.bb rename to #Test/help/commands/3d_examples/RenderWorld.bb diff --git a/_release/help/commands/3d_examples/ResetEntity.bb b/#Test/help/commands/3d_examples/ResetEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/ResetEntity.bb rename to #Test/help/commands/3d_examples/ResetEntity.bb diff --git a/_release/help/commands/3d_examples/RotateEntity.bb b/#Test/help/commands/3d_examples/RotateEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/RotateEntity.bb rename to #Test/help/commands/3d_examples/RotateEntity.bb diff --git a/_release/help/commands/3d_examples/RotateMesh.bb b/#Test/help/commands/3d_examples/RotateMesh.bb similarity index 100% rename from _release/help/commands/3d_examples/RotateMesh.bb rename to #Test/help/commands/3d_examples/RotateMesh.bb diff --git a/_release/help/commands/3d_examples/RotateSprite.bb b/#Test/help/commands/3d_examples/RotateSprite.bb similarity index 100% rename from _release/help/commands/3d_examples/RotateSprite.bb rename to #Test/help/commands/3d_examples/RotateSprite.bb diff --git a/_release/help/commands/3d_examples/RotateTexture.bb b/#Test/help/commands/3d_examples/RotateTexture.bb similarity index 100% rename from _release/help/commands/3d_examples/RotateTexture.bb rename to #Test/help/commands/3d_examples/RotateTexture.bb diff --git a/_release/help/commands/3d_examples/ScaleEntity.bb b/#Test/help/commands/3d_examples/ScaleEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/ScaleEntity.bb rename to #Test/help/commands/3d_examples/ScaleEntity.bb diff --git a/_release/help/commands/3d_examples/ScaleMesh.bb b/#Test/help/commands/3d_examples/ScaleMesh.bb similarity index 100% rename from _release/help/commands/3d_examples/ScaleMesh.bb rename to #Test/help/commands/3d_examples/ScaleMesh.bb diff --git a/_release/help/commands/3d_examples/ScaleSprite.bb b/#Test/help/commands/3d_examples/ScaleSprite.bb similarity index 100% rename from _release/help/commands/3d_examples/ScaleSprite.bb rename to #Test/help/commands/3d_examples/ScaleSprite.bb diff --git a/_release/help/commands/3d_examples/ScaleTexture.bb b/#Test/help/commands/3d_examples/ScaleTexture.bb similarity index 100% rename from _release/help/commands/3d_examples/ScaleTexture.bb rename to #Test/help/commands/3d_examples/ScaleTexture.bb diff --git a/_release/help/commands/3d_examples/SetAnimKey.bb b/#Test/help/commands/3d_examples/SetAnimKey.bb similarity index 100% rename from _release/help/commands/3d_examples/SetAnimKey.bb rename to #Test/help/commands/3d_examples/SetAnimKey.bb diff --git a/_release/help/commands/3d_examples/ShowEntity.bb b/#Test/help/commands/3d_examples/ShowEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/ShowEntity.bb rename to #Test/help/commands/3d_examples/ShowEntity.bb diff --git a/_release/help/commands/3d_examples/SpriteViewMode.bb b/#Test/help/commands/3d_examples/SpriteViewMode.bb similarity index 100% rename from _release/help/commands/3d_examples/SpriteViewMode.bb rename to #Test/help/commands/3d_examples/SpriteViewMode.bb diff --git a/_release/help/commands/3d_examples/TFormNormal.bb b/#Test/help/commands/3d_examples/TFormNormal.bb similarity index 100% rename from _release/help/commands/3d_examples/TFormNormal.bb rename to #Test/help/commands/3d_examples/TFormNormal.bb diff --git a/_release/help/commands/3d_examples/TFormPoint.bb b/#Test/help/commands/3d_examples/TFormPoint.bb similarity index 100% rename from _release/help/commands/3d_examples/TFormPoint.bb rename to #Test/help/commands/3d_examples/TFormPoint.bb diff --git a/_release/help/commands/3d_examples/TFormVector.bb b/#Test/help/commands/3d_examples/TFormVector.bb similarity index 100% rename from _release/help/commands/3d_examples/TFormVector.bb rename to #Test/help/commands/3d_examples/TFormVector.bb diff --git a/_release/help/commands/3d_examples/TFormedX.bb b/#Test/help/commands/3d_examples/TFormedX.bb similarity index 100% rename from _release/help/commands/3d_examples/TFormedX.bb rename to #Test/help/commands/3d_examples/TFormedX.bb diff --git a/_release/help/commands/3d_examples/TFormedY.bb b/#Test/help/commands/3d_examples/TFormedY.bb similarity index 100% rename from _release/help/commands/3d_examples/TFormedY.bb rename to #Test/help/commands/3d_examples/TFormedY.bb diff --git a/_release/help/commands/3d_examples/TFormedZ.bb b/#Test/help/commands/3d_examples/TFormedZ.bb similarity index 100% rename from _release/help/commands/3d_examples/TFormedZ.bb rename to #Test/help/commands/3d_examples/TFormedZ.bb diff --git a/_release/help/commands/3d_examples/TerrainDetail.bb b/#Test/help/commands/3d_examples/TerrainDetail.bb similarity index 100% rename from _release/help/commands/3d_examples/TerrainDetail.bb rename to #Test/help/commands/3d_examples/TerrainDetail.bb diff --git a/_release/help/commands/3d_examples/TerrainHeight.bb b/#Test/help/commands/3d_examples/TerrainHeight.bb similarity index 100% rename from _release/help/commands/3d_examples/TerrainHeight.bb rename to #Test/help/commands/3d_examples/TerrainHeight.bb diff --git a/_release/help/commands/3d_examples/TerrainShading.bb b/#Test/help/commands/3d_examples/TerrainShading.bb similarity index 100% rename from _release/help/commands/3d_examples/TerrainShading.bb rename to #Test/help/commands/3d_examples/TerrainShading.bb diff --git a/_release/help/commands/3d_examples/TerrainSize.bb b/#Test/help/commands/3d_examples/TerrainSize.bb similarity index 100% rename from _release/help/commands/3d_examples/TerrainSize.bb rename to #Test/help/commands/3d_examples/TerrainSize.bb diff --git a/_release/help/commands/3d_examples/TerrainX.bb b/#Test/help/commands/3d_examples/TerrainX.bb similarity index 100% rename from _release/help/commands/3d_examples/TerrainX.bb rename to #Test/help/commands/3d_examples/TerrainX.bb diff --git a/_release/help/commands/3d_examples/TerrainY.bb b/#Test/help/commands/3d_examples/TerrainY.bb similarity index 100% rename from _release/help/commands/3d_examples/TerrainY.bb rename to #Test/help/commands/3d_examples/TerrainY.bb diff --git a/_release/help/commands/3d_examples/TerrainZ.bb b/#Test/help/commands/3d_examples/TerrainZ.bb similarity index 100% rename from _release/help/commands/3d_examples/TerrainZ.bb rename to #Test/help/commands/3d_examples/TerrainZ.bb diff --git a/_release/help/commands/3d_examples/TextureBlend.bb b/#Test/help/commands/3d_examples/TextureBlend.bb similarity index 100% rename from _release/help/commands/3d_examples/TextureBlend.bb rename to #Test/help/commands/3d_examples/TextureBlend.bb diff --git a/_release/help/commands/3d_examples/TextureBuffer.bb b/#Test/help/commands/3d_examples/TextureBuffer.bb similarity index 100% rename from _release/help/commands/3d_examples/TextureBuffer.bb rename to #Test/help/commands/3d_examples/TextureBuffer.bb diff --git a/_release/help/commands/3d_examples/TextureCoords.bb b/#Test/help/commands/3d_examples/TextureCoords.bb similarity index 100% rename from _release/help/commands/3d_examples/TextureCoords.bb rename to #Test/help/commands/3d_examples/TextureCoords.bb diff --git a/_release/help/commands/3d_examples/TextureFilter.bb b/#Test/help/commands/3d_examples/TextureFilter.bb similarity index 100% rename from _release/help/commands/3d_examples/TextureFilter.bb rename to #Test/help/commands/3d_examples/TextureFilter.bb diff --git a/_release/help/commands/3d_examples/TextureHeight.bb b/#Test/help/commands/3d_examples/TextureHeight.bb similarity index 100% rename from _release/help/commands/3d_examples/TextureHeight.bb rename to #Test/help/commands/3d_examples/TextureHeight.bb diff --git a/_release/help/commands/3d_examples/TextureWidth.bb b/#Test/help/commands/3d_examples/TextureWidth.bb similarity index 100% rename from _release/help/commands/3d_examples/TextureWidth.bb rename to #Test/help/commands/3d_examples/TextureWidth.bb diff --git a/_release/help/commands/3d_examples/TranslateEntity.bb b/#Test/help/commands/3d_examples/TranslateEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/TranslateEntity.bb rename to #Test/help/commands/3d_examples/TranslateEntity.bb diff --git a/_release/help/commands/3d_examples/TriangleVertex.bb b/#Test/help/commands/3d_examples/TriangleVertex.bb similarity index 100% rename from _release/help/commands/3d_examples/TriangleVertex.bb rename to #Test/help/commands/3d_examples/TriangleVertex.bb diff --git a/_release/help/commands/3d_examples/TurnEntity.bb b/#Test/help/commands/3d_examples/TurnEntity.bb similarity index 100% rename from _release/help/commands/3d_examples/TurnEntity.bb rename to #Test/help/commands/3d_examples/TurnEntity.bb diff --git a/_release/help/commands/3d_examples/UpdateNormals.bb b/#Test/help/commands/3d_examples/UpdateNormals.bb similarity index 100% rename from _release/help/commands/3d_examples/UpdateNormals.bb rename to #Test/help/commands/3d_examples/UpdateNormals.bb diff --git a/_release/help/commands/3d_examples/UpdateWorld.bb b/#Test/help/commands/3d_examples/UpdateWorld.bb similarity index 100% rename from _release/help/commands/3d_examples/UpdateWorld.bb rename to #Test/help/commands/3d_examples/UpdateWorld.bb diff --git a/_release/help/commands/3d_examples/VertexBlue.bb b/#Test/help/commands/3d_examples/VertexBlue.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexBlue.bb rename to #Test/help/commands/3d_examples/VertexBlue.bb diff --git a/_release/help/commands/3d_examples/VertexColor.bb b/#Test/help/commands/3d_examples/VertexColor.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexColor.bb rename to #Test/help/commands/3d_examples/VertexColor.bb diff --git a/_release/help/commands/3d_examples/VertexCoords.bb b/#Test/help/commands/3d_examples/VertexCoords.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexCoords.bb rename to #Test/help/commands/3d_examples/VertexCoords.bb diff --git a/_release/help/commands/3d_examples/VertexGreen.bb b/#Test/help/commands/3d_examples/VertexGreen.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexGreen.bb rename to #Test/help/commands/3d_examples/VertexGreen.bb diff --git a/_release/help/commands/3d_examples/VertexNX.bb b/#Test/help/commands/3d_examples/VertexNX.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexNX.bb rename to #Test/help/commands/3d_examples/VertexNX.bb diff --git a/_release/help/commands/3d_examples/VertexNY.bb b/#Test/help/commands/3d_examples/VertexNY.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexNY.bb rename to #Test/help/commands/3d_examples/VertexNY.bb diff --git a/_release/help/commands/3d_examples/VertexNZ.bb b/#Test/help/commands/3d_examples/VertexNZ.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexNZ.bb rename to #Test/help/commands/3d_examples/VertexNZ.bb diff --git a/_release/help/commands/3d_examples/VertexNormal.bb b/#Test/help/commands/3d_examples/VertexNormal.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexNormal.bb rename to #Test/help/commands/3d_examples/VertexNormal.bb diff --git a/_release/help/commands/3d_examples/VertexRed.bb b/#Test/help/commands/3d_examples/VertexRed.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexRed.bb rename to #Test/help/commands/3d_examples/VertexRed.bb diff --git a/_release/help/commands/3d_examples/VertexTexCoords.bb b/#Test/help/commands/3d_examples/VertexTexCoords.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexTexCoords.bb rename to #Test/help/commands/3d_examples/VertexTexCoords.bb diff --git a/_release/help/commands/3d_examples/VertexU.bb b/#Test/help/commands/3d_examples/VertexU.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexU.bb rename to #Test/help/commands/3d_examples/VertexU.bb diff --git a/_release/help/commands/3d_examples/VertexV.bb b/#Test/help/commands/3d_examples/VertexV.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexV.bb rename to #Test/help/commands/3d_examples/VertexV.bb diff --git a/_release/help/commands/3d_examples/VertexW.bb b/#Test/help/commands/3d_examples/VertexW.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexW.bb rename to #Test/help/commands/3d_examples/VertexW.bb diff --git a/_release/help/commands/3d_examples/VertexX.bb b/#Test/help/commands/3d_examples/VertexX.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexX.bb rename to #Test/help/commands/3d_examples/VertexX.bb diff --git a/_release/help/commands/3d_examples/VertexY.bb b/#Test/help/commands/3d_examples/VertexY.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexY.bb rename to #Test/help/commands/3d_examples/VertexY.bb diff --git a/_release/help/commands/3d_examples/VertexZ.bb b/#Test/help/commands/3d_examples/VertexZ.bb similarity index 100% rename from _release/help/commands/3d_examples/VertexZ.bb rename to #Test/help/commands/3d_examples/VertexZ.bb diff --git a/_release/help/commands/3d_examples/WBuffer.bb b/#Test/help/commands/3d_examples/WBuffer.bb similarity index 100% rename from _release/help/commands/3d_examples/WBuffer.bb rename to #Test/help/commands/3d_examples/WBuffer.bb diff --git a/_release/help/commands/3d_examples/Windowed3D.bb b/#Test/help/commands/3d_examples/Windowed3D.bb similarity index 100% rename from _release/help/commands/3d_examples/Windowed3D.bb rename to #Test/help/commands/3d_examples/Windowed3D.bb diff --git a/_release/help/commands/3d_examples/Wireframe.bb b/#Test/help/commands/3d_examples/Wireframe.bb similarity index 100% rename from _release/help/commands/3d_examples/Wireframe.bb rename to #Test/help/commands/3d_examples/Wireframe.bb diff --git a/_release/help/commands/3d_examples/media/Chorme-2.BMP b/#Test/help/commands/3d_examples/media/Chorme-2.BMP similarity index 100% rename from _release/help/commands/3d_examples/media/Chorme-2.BMP rename to #Test/help/commands/3d_examples/media/Chorme-2.BMP diff --git a/_release/help/commands/3d_examples/media/Gargoyle/Gargoyle.bmp b/#Test/help/commands/3d_examples/media/Gargoyle/Gargoyle.bmp similarity index 100% rename from _release/help/commands/3d_examples/media/Gargoyle/Gargoyle.bmp rename to #Test/help/commands/3d_examples/media/Gargoyle/Gargoyle.bmp diff --git a/_release/help/commands/3d_examples/media/Gargoyle/Gargoyle.md2 b/#Test/help/commands/3d_examples/media/Gargoyle/Gargoyle.md2 similarity index 100% rename from _release/help/commands/3d_examples/media/Gargoyle/Gargoyle.md2 rename to #Test/help/commands/3d_examples/media/Gargoyle/Gargoyle.md2 diff --git a/_release/help/commands/3d_examples/media/Gargoyle/GargoyleSkin.PCX b/#Test/help/commands/3d_examples/media/Gargoyle/GargoyleSkin.PCX similarity index 100% rename from _release/help/commands/3d_examples/media/Gargoyle/GargoyleSkin.PCX rename to #Test/help/commands/3d_examples/media/Gargoyle/GargoyleSkin.PCX diff --git a/_release/help/commands/3d_examples/media/Height_map.bmp b/#Test/help/commands/3d_examples/media/Height_map.bmp similarity index 100% rename from _release/help/commands/3d_examples/media/Height_map.bmp rename to #Test/help/commands/3d_examples/media/Height_map.bmp diff --git a/_release/help/commands/3d_examples/media/MossyGround.BMP b/#Test/help/commands/3d_examples/media/MossyGround.BMP similarity index 100% rename from _release/help/commands/3d_examples/media/MossyGround.BMP rename to #Test/help/commands/3d_examples/media/MossyGround.BMP diff --git a/_release/help/commands/3d_examples/media/b3dlogo.jpg b/#Test/help/commands/3d_examples/media/b3dlogo.jpg similarity index 100% rename from _release/help/commands/3d_examples/media/b3dlogo.jpg rename to #Test/help/commands/3d_examples/media/b3dlogo.jpg diff --git a/_release/help/commands/3d_examples/media/height_map_1024.bmp b/#Test/help/commands/3d_examples/media/height_map_1024.bmp similarity index 100% rename from _release/help/commands/3d_examples/media/height_map_1024.bmp rename to #Test/help/commands/3d_examples/media/height_map_1024.bmp diff --git a/_release/help/commands/3d_examples/media/kaboom.bmp b/#Test/help/commands/3d_examples/media/kaboom.bmp similarity index 100% rename from _release/help/commands/3d_examples/media/kaboom.bmp rename to #Test/help/commands/3d_examples/media/kaboom.bmp diff --git a/_release/help/commands/3d_examples/media/oil-drum/oildrum.3ds b/#Test/help/commands/3d_examples/media/oil-drum/oildrum.3ds similarity index 100% rename from _release/help/commands/3d_examples/media/oil-drum/oildrum.3ds rename to #Test/help/commands/3d_examples/media/oil-drum/oildrum.3ds diff --git a/_release/help/commands/3d_examples/media/oil-drum/oildrum.jpg b/#Test/help/commands/3d_examples/media/oil-drum/oildrum.jpg similarity index 100% rename from _release/help/commands/3d_examples/media/oil-drum/oildrum.jpg rename to #Test/help/commands/3d_examples/media/oil-drum/oildrum.jpg diff --git a/_release/help/commands/3d_examples/media/sky.bmp b/#Test/help/commands/3d_examples/media/sky.bmp similarity index 100% rename from _release/help/commands/3d_examples/media/sky.bmp rename to #Test/help/commands/3d_examples/media/sky.bmp diff --git a/_release/help/commands/3d_examples/media/wood-crate/wcrate.jpg b/#Test/help/commands/3d_examples/media/wood-crate/wcrate.jpg similarity index 100% rename from _release/help/commands/3d_examples/media/wood-crate/wcrate.jpg rename to #Test/help/commands/3d_examples/media/wood-crate/wcrate.jpg diff --git a/_release/help/commands/3d_examples/media/wood-crate/wcrate1.3ds b/#Test/help/commands/3d_examples/media/wood-crate/wcrate1.3ds similarity index 100% rename from _release/help/commands/3d_examples/media/wood-crate/wcrate1.3ds rename to #Test/help/commands/3d_examples/media/wood-crate/wcrate1.3ds diff --git a/_release/help/commands/3d_examples/template.bb b/#Test/help/commands/3d_examples/template.bb similarity index 100% rename from _release/help/commands/3d_examples/template.bb rename to #Test/help/commands/3d_examples/template.bb diff --git a/_release/help/commands/command_list.htm b/#Test/help/commands/command_list.htm similarity index 100% rename from _release/help/commands/command_list.htm rename to #Test/help/commands/command_list.htm diff --git a/_release/help/commands/css/commands.css b/#Test/help/commands/css/commands.css similarity index 100% rename from _release/help/commands/css/commands.css rename to #Test/help/commands/css/commands.css diff --git a/_release/help/commands/css/commands_old.css b/#Test/help/commands/css/commands_old.css similarity index 100% rename from _release/help/commands/css/commands_old.css rename to #Test/help/commands/css/commands_old.css diff --git a/_release/help/commands/css/readme.txt b/#Test/help/commands/css/readme.txt similarity index 100% rename from _release/help/commands/css/readme.txt rename to #Test/help/commands/css/readme.txt diff --git a/_release/help/commands/index.htm b/#Test/help/commands/index.htm similarity index 100% rename from _release/help/commands/index.htm rename to #Test/help/commands/index.htm diff --git a/_release/help/commands/scancodes.htm b/#Test/help/commands/scancodes.htm similarity index 100% rename from _release/help/commands/scancodes.htm rename to #Test/help/commands/scancodes.htm diff --git a/_release/help/credits.html b/#Test/help/credits.html similarity index 100% rename from _release/help/credits.html rename to #Test/help/credits.html diff --git a/_release/help/index.html b/#Test/help/index.html similarity index 100% rename from _release/help/index.html rename to #Test/help/index.html diff --git a/_release/help/language/index.html b/#Test/help/language/index.html similarity index 100% rename from _release/help/language/index.html rename to #Test/help/language/index.html diff --git a/_release/help/language/lang_ref.css b/#Test/help/language/lang_ref.css similarity index 100% rename from _release/help/language/lang_ref.css rename to #Test/help/language/lang_ref.css diff --git a/_release/help/language/lang_ref_arrays.html b/#Test/help/language/lang_ref_arrays.html similarity index 100% rename from _release/help/language/lang_ref_arrays.html rename to #Test/help/language/lang_ref_arrays.html diff --git a/_release/help/language/lang_ref_basicdatatypes.html b/#Test/help/language/lang_ref_basicdatatypes.html similarity index 100% rename from _release/help/language/lang_ref_basicdatatypes.html rename to #Test/help/language/lang_ref_basicdatatypes.html diff --git a/_release/help/language/lang_ref_comments.html b/#Test/help/language/lang_ref_comments.html similarity index 100% rename from _release/help/language/lang_ref_comments.html rename to #Test/help/language/lang_ref_comments.html diff --git a/_release/help/language/lang_ref_constants.html b/#Test/help/language/lang_ref_constants.html similarity index 100% rename from _release/help/language/lang_ref_constants.html rename to #Test/help/language/lang_ref_constants.html diff --git a/_release/help/language/lang_ref_customtypes.html b/#Test/help/language/lang_ref_customtypes.html similarity index 100% rename from _release/help/language/lang_ref_customtypes.html rename to #Test/help/language/lang_ref_customtypes.html diff --git a/_release/help/language/lang_ref_expressions.html b/#Test/help/language/lang_ref_expressions.html similarity index 100% rename from _release/help/language/lang_ref_expressions.html rename to #Test/help/language/lang_ref_expressions.html diff --git a/_release/help/language/lang_ref_functions.html b/#Test/help/language/lang_ref_functions.html similarity index 100% rename from _release/help/language/lang_ref_functions.html rename to #Test/help/language/lang_ref_functions.html diff --git a/_release/help/language/lang_ref_identifiers.html b/#Test/help/language/lang_ref_identifiers.html similarity index 100% rename from _release/help/language/lang_ref_identifiers.html rename to #Test/help/language/lang_ref_identifiers.html diff --git a/_release/help/language/lang_ref_intro.html b/#Test/help/language/lang_ref_intro.html similarity index 100% rename from _release/help/language/lang_ref_intro.html rename to #Test/help/language/lang_ref_intro.html diff --git a/_release/help/language/lang_ref_keywords.html b/#Test/help/language/lang_ref_keywords.html similarity index 100% rename from _release/help/language/lang_ref_keywords.html rename to #Test/help/language/lang_ref_keywords.html diff --git a/_release/help/language/lang_ref_programflow.html b/#Test/help/language/lang_ref_programflow.html similarity index 100% rename from _release/help/language/lang_ref_programflow.html rename to #Test/help/language/lang_ref_programflow.html diff --git a/_release/help/language/lang_ref_variables.html b/#Test/help/language/lang_ref_variables.html similarity index 100% rename from _release/help/language/lang_ref_variables.html rename to #Test/help/language/lang_ref_variables.html diff --git a/_release/help/language/navbar.html b/#Test/help/language/navbar.html similarity index 100% rename from _release/help/language/navbar.html rename to #Test/help/language/navbar.html diff --git a/_release/help/language/title.html b/#Test/help/language/title.html similarity index 100% rename from _release/help/language/title.html rename to #Test/help/language/title.html diff --git a/_release/mediaview/mediaview.bb b/#Test/mediaview/mediaview.bb similarity index 100% rename from _release/mediaview/mediaview.bb rename to #Test/mediaview/mediaview.bb diff --git a/_release/samples/AGore/BirdDemo/Bird.md2 b/#Test/samples/AGore/BirdDemo/Bird.md2 similarity index 100% rename from _release/samples/AGore/BirdDemo/Bird.md2 rename to #Test/samples/AGore/BirdDemo/Bird.md2 diff --git a/_release/samples/AGore/BirdDemo/Bird1.bbm b/#Test/samples/AGore/BirdDemo/Bird1.bbm similarity index 100% rename from _release/samples/AGore/BirdDemo/Bird1.bbm rename to #Test/samples/AGore/BirdDemo/Bird1.bbm diff --git a/_release/samples/AGore/BirdDemo/Bird2.bbm b/#Test/samples/AGore/BirdDemo/Bird2.bbm similarity index 100% rename from _release/samples/AGore/BirdDemo/Bird2.bbm rename to #Test/samples/AGore/BirdDemo/Bird2.bbm diff --git a/_release/samples/AGore/BirdDemo/BirdDemo.bb b/#Test/samples/AGore/BirdDemo/BirdDemo.bb similarity index 100% rename from _release/samples/AGore/BirdDemo/BirdDemo.bb rename to #Test/samples/AGore/BirdDemo/BirdDemo.bb diff --git a/_release/samples/AGore/BirdDemo/Cam.bbm b/#Test/samples/AGore/BirdDemo/Cam.bbm similarity index 100% rename from _release/samples/AGore/BirdDemo/Cam.bbm rename to #Test/samples/AGore/BirdDemo/Cam.bbm diff --git a/_release/samples/AGore/BirdDemo/Canyon.x b/#Test/samples/AGore/BirdDemo/Canyon.x similarity index 100% rename from _release/samples/AGore/BirdDemo/Canyon.x rename to #Test/samples/AGore/BirdDemo/Canyon.x diff --git a/_release/samples/AGore/BirdDemo/KBSplines.bb b/#Test/samples/AGore/BirdDemo/KBSplines.bb similarity index 100% rename from _release/samples/AGore/BirdDemo/KBSplines.bb rename to #Test/samples/AGore/BirdDemo/KBSplines.bb diff --git a/_release/samples/AGore/BirdDemo/Textures/Bird.bmp b/#Test/samples/AGore/BirdDemo/Textures/Bird.bmp similarity index 100% rename from _release/samples/AGore/BirdDemo/Textures/Bird.bmp rename to #Test/samples/AGore/BirdDemo/Textures/Bird.bmp diff --git a/_release/samples/AGore/BirdDemo/Textures/Moss.bmp b/#Test/samples/AGore/BirdDemo/Textures/Moss.bmp similarity index 100% rename from _release/samples/AGore/BirdDemo/Textures/Moss.bmp rename to #Test/samples/AGore/BirdDemo/Textures/Moss.bmp diff --git a/_release/samples/AGore/BirdDemo/Textures/Rock.bmp b/#Test/samples/AGore/BirdDemo/Textures/Rock.bmp similarity index 100% rename from _release/samples/AGore/BirdDemo/Textures/Rock.bmp rename to #Test/samples/AGore/BirdDemo/Textures/Rock.bmp diff --git a/_release/samples/AGore/BirdDemo/Textures/sky_BK.bmp b/#Test/samples/AGore/BirdDemo/Textures/sky_BK.bmp similarity index 100% rename from _release/samples/AGore/BirdDemo/Textures/sky_BK.bmp rename to #Test/samples/AGore/BirdDemo/Textures/sky_BK.bmp diff --git a/_release/samples/AGore/BirdDemo/Textures/sky_FR.bmp b/#Test/samples/AGore/BirdDemo/Textures/sky_FR.bmp similarity index 100% rename from _release/samples/AGore/BirdDemo/Textures/sky_FR.bmp rename to #Test/samples/AGore/BirdDemo/Textures/sky_FR.bmp diff --git a/_release/samples/AGore/BirdDemo/Textures/sky_LF.bmp b/#Test/samples/AGore/BirdDemo/Textures/sky_LF.bmp similarity index 100% rename from _release/samples/AGore/BirdDemo/Textures/sky_LF.bmp rename to #Test/samples/AGore/BirdDemo/Textures/sky_LF.bmp diff --git a/_release/samples/AGore/BirdDemo/Textures/sky_RT.bmp b/#Test/samples/AGore/BirdDemo/Textures/sky_RT.bmp similarity index 100% rename from _release/samples/AGore/BirdDemo/Textures/sky_RT.bmp rename to #Test/samples/AGore/BirdDemo/Textures/sky_RT.bmp diff --git a/_release/samples/AGore/BirdDemo/Textures/sky_UP.bmp b/#Test/samples/AGore/BirdDemo/Textures/sky_UP.bmp similarity index 100% rename from _release/samples/AGore/BirdDemo/Textures/sky_UP.bmp rename to #Test/samples/AGore/BirdDemo/Textures/sky_UP.bmp diff --git a/_release/samples/AGore/GrassDemo/Data/GrassClip.bmp b/#Test/samples/AGore/GrassDemo/Data/GrassClip.bmp similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/GrassClip.bmp rename to #Test/samples/AGore/GrassDemo/Data/GrassClip.bmp diff --git a/_release/samples/AGore/GrassDemo/Data/Ground.bmp b/#Test/samples/AGore/GrassDemo/Data/Ground.bmp similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/Ground.bmp rename to #Test/samples/AGore/GrassDemo/Data/Ground.bmp diff --git a/_release/samples/AGore/GrassDemo/Data/lens1.jpg b/#Test/samples/AGore/GrassDemo/Data/lens1.jpg similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/lens1.jpg rename to #Test/samples/AGore/GrassDemo/Data/lens1.jpg diff --git a/_release/samples/AGore/GrassDemo/Data/lens2.jpg b/#Test/samples/AGore/GrassDemo/Data/lens2.jpg similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/lens2.jpg rename to #Test/samples/AGore/GrassDemo/Data/lens2.jpg diff --git a/_release/samples/AGore/GrassDemo/Data/lens3.jpg b/#Test/samples/AGore/GrassDemo/Data/lens3.jpg similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/lens3.jpg rename to #Test/samples/AGore/GrassDemo/Data/lens3.jpg diff --git a/_release/samples/AGore/GrassDemo/Data/lens4.jpg b/#Test/samples/AGore/GrassDemo/Data/lens4.jpg similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/lens4.jpg rename to #Test/samples/AGore/GrassDemo/Data/lens4.jpg diff --git a/_release/samples/AGore/GrassDemo/Data/sky_BK.bmp b/#Test/samples/AGore/GrassDemo/Data/sky_BK.bmp similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/sky_BK.bmp rename to #Test/samples/AGore/GrassDemo/Data/sky_BK.bmp diff --git a/_release/samples/AGore/GrassDemo/Data/sky_FR.bmp b/#Test/samples/AGore/GrassDemo/Data/sky_FR.bmp similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/sky_FR.bmp rename to #Test/samples/AGore/GrassDemo/Data/sky_FR.bmp diff --git a/_release/samples/AGore/GrassDemo/Data/sky_LF.bmp b/#Test/samples/AGore/GrassDemo/Data/sky_LF.bmp similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/sky_LF.bmp rename to #Test/samples/AGore/GrassDemo/Data/sky_LF.bmp diff --git a/_release/samples/AGore/GrassDemo/Data/sky_RT.bmp b/#Test/samples/AGore/GrassDemo/Data/sky_RT.bmp similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/sky_RT.bmp rename to #Test/samples/AGore/GrassDemo/Data/sky_RT.bmp diff --git a/_release/samples/AGore/GrassDemo/Data/sky_UP.bmp b/#Test/samples/AGore/GrassDemo/Data/sky_UP.bmp similarity index 100% rename from _release/samples/AGore/GrassDemo/Data/sky_UP.bmp rename to #Test/samples/AGore/GrassDemo/Data/sky_UP.bmp diff --git a/_release/samples/AGore/GrassDemo/Grass.bb b/#Test/samples/AGore/GrassDemo/Grass.bb similarity index 100% rename from _release/samples/AGore/GrassDemo/Grass.bb rename to #Test/samples/AGore/GrassDemo/Grass.bb diff --git a/_release/samples/AGore/HeadDemo/Bkgd.jpg b/#Test/samples/AGore/HeadDemo/Bkgd.jpg similarity index 100% rename from _release/samples/AGore/HeadDemo/Bkgd.jpg rename to #Test/samples/AGore/HeadDemo/Bkgd.jpg diff --git a/_release/samples/AGore/HeadDemo/Eye.jpg b/#Test/samples/AGore/HeadDemo/Eye.jpg similarity index 100% rename from _release/samples/AGore/HeadDemo/Eye.jpg rename to #Test/samples/AGore/HeadDemo/Eye.jpg diff --git a/_release/samples/AGore/HeadDemo/Eye.x b/#Test/samples/AGore/HeadDemo/Eye.x similarity index 100% rename from _release/samples/AGore/HeadDemo/Eye.x rename to #Test/samples/AGore/HeadDemo/Eye.x diff --git a/_release/samples/AGore/HeadDemo/EyeFocus.bbm b/#Test/samples/AGore/HeadDemo/EyeFocus.bbm similarity index 100% rename from _release/samples/AGore/HeadDemo/EyeFocus.bbm rename to #Test/samples/AGore/HeadDemo/EyeFocus.bbm diff --git a/_release/samples/AGore/HeadDemo/Face.jpg b/#Test/samples/AGore/HeadDemo/Face.jpg similarity index 100% rename from _release/samples/AGore/HeadDemo/Face.jpg rename to #Test/samples/AGore/HeadDemo/Face.jpg diff --git a/_release/samples/AGore/HeadDemo/Head.bbm b/#Test/samples/AGore/HeadDemo/Head.bbm similarity index 100% rename from _release/samples/AGore/HeadDemo/Head.bbm rename to #Test/samples/AGore/HeadDemo/Head.bbm diff --git a/_release/samples/AGore/HeadDemo/Head.x b/#Test/samples/AGore/HeadDemo/Head.x similarity index 100% rename from _release/samples/AGore/HeadDemo/Head.x rename to #Test/samples/AGore/HeadDemo/Head.x diff --git a/_release/samples/AGore/HeadDemo/KBSplines.bb b/#Test/samples/AGore/HeadDemo/KBSplines.bb similarity index 100% rename from _release/samples/AGore/HeadDemo/KBSplines.bb rename to #Test/samples/AGore/HeadDemo/KBSplines.bb diff --git a/_release/samples/AGore/HeadDemo/Reflection.jpg b/#Test/samples/AGore/HeadDemo/Reflection.jpg similarity index 100% rename from _release/samples/AGore/HeadDemo/Reflection.jpg rename to #Test/samples/AGore/HeadDemo/Reflection.jpg diff --git a/_release/samples/AGore/HeadDemo/TheHead.bb b/#Test/samples/AGore/HeadDemo/TheHead.bb similarity index 100% rename from _release/samples/AGore/HeadDemo/TheHead.bb rename to #Test/samples/AGore/HeadDemo/TheHead.bb diff --git a/_release/samples/AGore/start.bb b/#Test/samples/AGore/start.bb similarity index 100% rename from _release/samples/AGore/start.bb rename to #Test/samples/AGore/start.bb diff --git a/_release/samples/Hi-Toro/Death Island/deathisland.bb b/#Test/samples/Hi-Toro/Death Island/deathisland.bb similarity index 100% rename from _release/samples/Hi-Toro/Death Island/deathisland.bb rename to #Test/samples/Hi-Toro/Death Island/deathisland.bb diff --git a/_release/samples/Hi-Toro/Death Island/gfx/di.bmp b/#Test/samples/Hi-Toro/Death Island/gfx/di.bmp similarity index 100% rename from _release/samples/Hi-Toro/Death Island/gfx/di.bmp rename to #Test/samples/Hi-Toro/Death Island/gfx/di.bmp diff --git a/_release/samples/Hi-Toro/Death Island/gfx/greygrass.bmp b/#Test/samples/Hi-Toro/Death Island/gfx/greygrass.bmp similarity index 100% rename from _release/samples/Hi-Toro/Death Island/gfx/greygrass.bmp rename to #Test/samples/Hi-Toro/Death Island/gfx/greygrass.bmp diff --git a/_release/samples/Hi-Toro/Death Island/gfx/greywater.bmp b/#Test/samples/Hi-Toro/Death Island/gfx/greywater.bmp similarity index 100% rename from _release/samples/Hi-Toro/Death Island/gfx/greywater.bmp rename to #Test/samples/Hi-Toro/Death Island/gfx/greywater.bmp diff --git a/_release/samples/Hi-Toro/Death Island/gfx/height.bmp b/#Test/samples/Hi-Toro/Death Island/gfx/height.bmp similarity index 100% rename from _release/samples/Hi-Toro/Death Island/gfx/height.bmp rename to #Test/samples/Hi-Toro/Death Island/gfx/height.bmp diff --git a/_release/samples/Hi-Toro/Death Island/gfx/realsky.bmp b/#Test/samples/Hi-Toro/Death Island/gfx/realsky.bmp similarity index 100% rename from _release/samples/Hi-Toro/Death Island/gfx/realsky.bmp rename to #Test/samples/Hi-Toro/Death Island/gfx/realsky.bmp diff --git a/_release/samples/Hi-Toro/Death Island/incs/lensHowTo.bb b/#Test/samples/Hi-Toro/Death Island/incs/lensHowTo.bb similarity index 100% rename from _release/samples/Hi-Toro/Death Island/incs/lensHowTo.bb rename to #Test/samples/Hi-Toro/Death Island/incs/lensHowTo.bb diff --git a/_release/samples/Hi-Toro/Death Island/incs/lensIncs.bb b/#Test/samples/Hi-Toro/Death Island/incs/lensIncs.bb similarity index 100% rename from _release/samples/Hi-Toro/Death Island/incs/lensIncs.bb rename to #Test/samples/Hi-Toro/Death Island/incs/lensIncs.bb diff --git a/_release/samples/Hi-Toro/Death Island/msh/747.X b/#Test/samples/Hi-Toro/Death Island/msh/747.X similarity index 100% rename from _release/samples/Hi-Toro/Death Island/msh/747.X rename to #Test/samples/Hi-Toro/Death Island/msh/747.X diff --git a/_release/samples/Hi-Toro/Death Island/snd/Water2.wav b/#Test/samples/Hi-Toro/Death Island/snd/Water2.wav similarity index 100% rename from _release/samples/Hi-Toro/Death Island/snd/Water2.wav rename to #Test/samples/Hi-Toro/Death Island/snd/Water2.wav diff --git a/_release/samples/Hi-Toro/Death Island/snd/gravel.wav b/#Test/samples/Hi-Toro/Death Island/snd/gravel.wav similarity index 100% rename from _release/samples/Hi-Toro/Death Island/snd/gravel.wav rename to #Test/samples/Hi-Toro/Death Island/snd/gravel.wav diff --git a/_release/samples/Hi-Toro/Death Island/snd/rainroof.wav b/#Test/samples/Hi-Toro/Death Island/snd/rainroof.wav similarity index 100% rename from _release/samples/Hi-Toro/Death Island/snd/rainroof.wav rename to #Test/samples/Hi-Toro/Death Island/snd/rainroof.wav diff --git a/_release/samples/Hi-Toro/Death Island/snd/seawind2.wav b/#Test/samples/Hi-Toro/Death Island/snd/seawind2.wav similarity index 100% rename from _release/samples/Hi-Toro/Death Island/snd/seawind2.wav rename to #Test/samples/Hi-Toro/Death Island/snd/seawind2.wav diff --git a/_release/samples/Hi-Toro/Death Island/snd/thunder.wav b/#Test/samples/Hi-Toro/Death Island/snd/thunder.wav similarity index 100% rename from _release/samples/Hi-Toro/Death Island/snd/thunder.wav rename to #Test/samples/Hi-Toro/Death Island/snd/thunder.wav diff --git a/_release/samples/Hi-Toro/Death Island/snd/txstorm.wav b/#Test/samples/Hi-Toro/Death Island/snd/txstorm.wav similarity index 100% rename from _release/samples/Hi-Toro/Death Island/snd/txstorm.wav rename to #Test/samples/Hi-Toro/Death Island/snd/txstorm.wav diff --git a/_release/samples/Hi-Toro/Death Island/snd/wavdance.wav b/#Test/samples/Hi-Toro/Death Island/snd/wavdance.wav similarity index 100% rename from _release/samples/Hi-Toro/Death Island/snd/wavdance.wav rename to #Test/samples/Hi-Toro/Death Island/snd/wavdance.wav diff --git a/_release/samples/Hi-Toro/Shooter/Shooter/gfx/ashot.bmp b/#Test/samples/Hi-Toro/Shooter/Shooter/gfx/ashot.bmp similarity index 100% rename from _release/samples/Hi-Toro/Shooter/Shooter/gfx/ashot.bmp rename to #Test/samples/Hi-Toro/Shooter/Shooter/gfx/ashot.bmp diff --git a/_release/samples/Hi-Toro/Shooter/Shooter/gfx/fire.bmp b/#Test/samples/Hi-Toro/Shooter/Shooter/gfx/fire.bmp similarity index 100% rename from _release/samples/Hi-Toro/Shooter/Shooter/gfx/fire.bmp rename to #Test/samples/Hi-Toro/Shooter/Shooter/gfx/fire.bmp diff --git a/_release/samples/Hi-Toro/Shooter/Shooter/gfx/grass.bmp b/#Test/samples/Hi-Toro/Shooter/Shooter/gfx/grass.bmp similarity index 100% rename from _release/samples/Hi-Toro/Shooter/Shooter/gfx/grass.bmp rename to #Test/samples/Hi-Toro/Shooter/Shooter/gfx/grass.bmp diff --git a/_release/samples/Hi-Toro/Shooter/Shooter/gfx/height.bmp b/#Test/samples/Hi-Toro/Shooter/Shooter/gfx/height.bmp similarity index 100% rename from _release/samples/Hi-Toro/Shooter/Shooter/gfx/height.bmp rename to #Test/samples/Hi-Toro/Shooter/Shooter/gfx/height.bmp diff --git a/_release/samples/Hi-Toro/Shooter/Shooter/gfx/splash.bmp b/#Test/samples/Hi-Toro/Shooter/Shooter/gfx/splash.bmp similarity index 100% rename from _release/samples/Hi-Toro/Shooter/Shooter/gfx/splash.bmp rename to #Test/samples/Hi-Toro/Shooter/Shooter/gfx/splash.bmp diff --git a/_release/samples/Hi-Toro/Shooter/Shooter/gfx/target.bmp b/#Test/samples/Hi-Toro/Shooter/Shooter/gfx/target.bmp similarity index 100% rename from _release/samples/Hi-Toro/Shooter/Shooter/gfx/target.bmp rename to #Test/samples/Hi-Toro/Shooter/Shooter/gfx/target.bmp diff --git a/_release/samples/Hi-Toro/Shooter/Shooter/gfx/water.bmp b/#Test/samples/Hi-Toro/Shooter/Shooter/gfx/water.bmp similarity index 100% rename from _release/samples/Hi-Toro/Shooter/Shooter/gfx/water.bmp rename to #Test/samples/Hi-Toro/Shooter/Shooter/gfx/water.bmp diff --git a/_release/samples/Hi-Toro/Shooter/Shooter/msh/ship.x b/#Test/samples/Hi-Toro/Shooter/Shooter/msh/ship.x similarity index 100% rename from _release/samples/Hi-Toro/Shooter/Shooter/msh/ship.x rename to #Test/samples/Hi-Toro/Shooter/Shooter/msh/ship.x diff --git a/_release/samples/Hi-Toro/Shooter/Shooter/shooter-testbed.bb b/#Test/samples/Hi-Toro/Shooter/Shooter/shooter-testbed.bb similarity index 100% rename from _release/samples/Hi-Toro/Shooter/Shooter/shooter-testbed.bb rename to #Test/samples/Hi-Toro/Shooter/Shooter/shooter-testbed.bb diff --git a/_release/samples/MattDavey/Matts Balls/bouncey.bb b/#Test/samples/MattDavey/Matts Balls/bouncey.bb similarity index 100% rename from _release/samples/MattDavey/Matts Balls/bouncey.bb rename to #Test/samples/MattDavey/Matts Balls/bouncey.bb diff --git a/_release/samples/MattDavey/Matts Balls/plane.3DS b/#Test/samples/MattDavey/Matts Balls/plane.3DS similarity index 100% rename from _release/samples/MattDavey/Matts Balls/plane.3DS rename to #Test/samples/MattDavey/Matts Balls/plane.3DS diff --git a/_release/samples/MattDavey/Matts Balls/planks02.jpg b/#Test/samples/MattDavey/Matts Balls/planks02.jpg similarity index 100% rename from _release/samples/MattDavey/Matts Balls/planks02.jpg rename to #Test/samples/MattDavey/Matts Balls/planks02.jpg diff --git a/_release/samples/MattDavey/Matts Balls/spark.BMP b/#Test/samples/MattDavey/Matts Balls/spark.BMP similarity index 100% rename from _release/samples/MattDavey/Matts Balls/spark.BMP rename to #Test/samples/MattDavey/Matts Balls/spark.BMP diff --git a/_release/samples/Richard_Betson/Big_Bang_1b/Big_Bang_1b.bb b/#Test/samples/Richard_Betson/Big_Bang_1b/Big_Bang_1b.bb similarity index 100% rename from _release/samples/Richard_Betson/Big_Bang_1b/Big_Bang_1b.bb rename to #Test/samples/Richard_Betson/Big_Bang_1b/Big_Bang_1b.bb diff --git a/_release/samples/Richard_Betson/Big_Bang_1b/Bigspark.BMP b/#Test/samples/Richard_Betson/Big_Bang_1b/Bigspark.BMP similarity index 100% rename from _release/samples/Richard_Betson/Big_Bang_1b/Bigspark.BMP rename to #Test/samples/Richard_Betson/Big_Bang_1b/Bigspark.BMP diff --git a/_release/samples/Richard_Betson/Big_Bang_1b/gate4.bmp b/#Test/samples/Richard_Betson/Big_Bang_1b/gate4.bmp similarity index 100% rename from _release/samples/Richard_Betson/Big_Bang_1b/gate4.bmp rename to #Test/samples/Richard_Betson/Big_Bang_1b/gate4.bmp diff --git a/_release/samples/Richard_Betson/Big_Bang_1b/ring2.bmp b/#Test/samples/Richard_Betson/Big_Bang_1b/ring2.bmp similarity index 100% rename from _release/samples/Richard_Betson/Big_Bang_1b/ring2.bmp rename to #Test/samples/Richard_Betson/Big_Bang_1b/ring2.bmp diff --git a/_release/samples/Richard_Betson/Binary_Cage_12/Binary_Cage_12.bb b/#Test/samples/Richard_Betson/Binary_Cage_12/Binary_Cage_12.bb similarity index 100% rename from _release/samples/Richard_Betson/Binary_Cage_12/Binary_Cage_12.bb rename to #Test/samples/Richard_Betson/Binary_Cage_12/Binary_Cage_12.bb diff --git a/_release/samples/Richard_Betson/Power_fountain_b/brick1.bmp b/#Test/samples/Richard_Betson/Power_fountain_b/brick1.bmp similarity index 100% rename from _release/samples/Richard_Betson/Power_fountain_b/brick1.bmp rename to #Test/samples/Richard_Betson/Power_fountain_b/brick1.bmp diff --git a/_release/samples/Richard_Betson/Power_fountain_b/power_fountian_b.bb b/#Test/samples/Richard_Betson/Power_fountain_b/power_fountian_b.bb similarity index 100% rename from _release/samples/Richard_Betson/Power_fountain_b/power_fountian_b.bb rename to #Test/samples/Richard_Betson/Power_fountain_b/power_fountian_b.bb diff --git a/_release/samples/Richard_Betson/Power_fountain_b/spark.BMP b/#Test/samples/Richard_Betson/Power_fountain_b/spark.BMP similarity index 100% rename from _release/samples/Richard_Betson/Power_fountain_b/spark.BMP rename to #Test/samples/Richard_Betson/Power_fountain_b/spark.BMP diff --git a/_release/samples/Richard_Betson/Power_fountain_b/stone.bmp b/#Test/samples/Richard_Betson/Power_fountain_b/stone.bmp similarity index 100% rename from _release/samples/Richard_Betson/Power_fountain_b/stone.bmp rename to #Test/samples/Richard_Betson/Power_fountain_b/stone.bmp diff --git a/_release/samples/Richard_Betson/emerald_gate/Emerald_Gate.txt b/#Test/samples/Richard_Betson/emerald_gate/Emerald_Gate.txt similarity index 100% rename from _release/samples/Richard_Betson/emerald_gate/Emerald_Gate.txt rename to #Test/samples/Richard_Betson/emerald_gate/Emerald_Gate.txt diff --git a/_release/samples/Richard_Betson/emerald_gate/Emerald_Gate_1.bb b/#Test/samples/Richard_Betson/emerald_gate/Emerald_Gate_1.bb similarity index 100% rename from _release/samples/Richard_Betson/emerald_gate/Emerald_Gate_1.bb rename to #Test/samples/Richard_Betson/emerald_gate/Emerald_Gate_1.bb diff --git a/_release/samples/Richard_Betson/emerald_gate/gate1.bmp b/#Test/samples/Richard_Betson/emerald_gate/gate1.bmp similarity index 100% rename from _release/samples/Richard_Betson/emerald_gate/gate1.bmp rename to #Test/samples/Richard_Betson/emerald_gate/gate1.bmp diff --git a/_release/samples/Richard_Betson/emerald_gate/my_stargate3.3ds b/#Test/samples/Richard_Betson/emerald_gate/my_stargate3.3ds similarity index 100% rename from _release/samples/Richard_Betson/emerald_gate/my_stargate3.3ds rename to #Test/samples/Richard_Betson/emerald_gate/my_stargate3.3ds diff --git a/_release/samples/Richard_Betson/emerald_gate/stone.bmp b/#Test/samples/Richard_Betson/emerald_gate/stone.bmp similarity index 100% rename from _release/samples/Richard_Betson/emerald_gate/stone.bmp rename to #Test/samples/Richard_Betson/emerald_gate/stone.bmp diff --git a/_release/samples/Richard_Betson/emerald_gate/water_anim.bmp b/#Test/samples/Richard_Betson/emerald_gate/water_anim.bmp similarity index 100% rename from _release/samples/Richard_Betson/emerald_gate/water_anim.bmp rename to #Test/samples/Richard_Betson/emerald_gate/water_anim.bmp diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/belt.bmp b/#Test/samples/Richard_Betson/orbit_nebula_source/belt.bmp similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/belt.bmp rename to #Test/samples/Richard_Betson/orbit_nebula_source/belt.bmp diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/io.BMP b/#Test/samples/Richard_Betson/orbit_nebula_source/io.BMP similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/io.BMP rename to #Test/samples/Richard_Betson/orbit_nebula_source/io.BMP diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/moon.BMP b/#Test/samples/Richard_Betson/orbit_nebula_source/moon.BMP similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/moon.BMP rename to #Test/samples/Richard_Betson/orbit_nebula_source/moon.BMP diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/nebula1.bmp b/#Test/samples/Richard_Betson/orbit_nebula_source/nebula1.bmp similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/nebula1.bmp rename to #Test/samples/Richard_Betson/orbit_nebula_source/nebula1.bmp diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/orbit.bb b/#Test/samples/Richard_Betson/orbit_nebula_source/orbit.bb similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/orbit.bb rename to #Test/samples/Richard_Betson/orbit_nebula_source/orbit.bb diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/ring.bmp b/#Test/samples/Richard_Betson/orbit_nebula_source/ring.bmp similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/ring.bmp rename to #Test/samples/Richard_Betson/orbit_nebula_source/ring.bmp diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/ring2.bmp b/#Test/samples/Richard_Betson/orbit_nebula_source/ring2.bmp similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/ring2.bmp rename to #Test/samples/Richard_Betson/orbit_nebula_source/ring2.bmp diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/rock.3DS b/#Test/samples/Richard_Betson/orbit_nebula_source/rock.3DS similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/rock.3DS rename to #Test/samples/Richard_Betson/orbit_nebula_source/rock.3DS diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/rock.bmp b/#Test/samples/Richard_Betson/orbit_nebula_source/rock.bmp similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/rock.bmp rename to #Test/samples/Richard_Betson/orbit_nebula_source/rock.bmp diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/signal.wav b/#Test/samples/Richard_Betson/orbit_nebula_source/signal.wav similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/signal.wav rename to #Test/samples/Richard_Betson/orbit_nebula_source/signal.wav diff --git a/_release/samples/Richard_Betson/orbit_nebula_source/spark.bmp b/#Test/samples/Richard_Betson/orbit_nebula_source/spark.bmp similarity index 100% rename from _release/samples/Richard_Betson/orbit_nebula_source/spark.bmp rename to #Test/samples/Richard_Betson/orbit_nebula_source/spark.bmp diff --git a/_release/samples/Richard_Betson/start.bb b/#Test/samples/Richard_Betson/start.bb similarity index 100% rename from _release/samples/Richard_Betson/start.bb rename to #Test/samples/Richard_Betson/start.bb diff --git a/_release/samples/RobCummings/Bumpy/b.jpg b/#Test/samples/RobCummings/Bumpy/b.jpg similarity index 100% rename from _release/samples/RobCummings/Bumpy/b.jpg rename to #Test/samples/RobCummings/Bumpy/b.jpg diff --git a/_release/samples/RobCummings/Bumpy/bumpyfun.bb b/#Test/samples/RobCummings/Bumpy/bumpyfun.bb similarity index 100% rename from _release/samples/RobCummings/Bumpy/bumpyfun.bb rename to #Test/samples/RobCummings/Bumpy/bumpyfun.bb diff --git a/_release/samples/RobCummings/Bumpy/c.jpg b/#Test/samples/RobCummings/Bumpy/c.jpg similarity index 100% rename from _release/samples/RobCummings/Bumpy/c.jpg rename to #Test/samples/RobCummings/Bumpy/c.jpg diff --git a/_release/samples/RobCummings/Bumpy/glow.bmp b/#Test/samples/RobCummings/Bumpy/glow.bmp similarity index 100% rename from _release/samples/RobCummings/Bumpy/glow.bmp rename to #Test/samples/RobCummings/Bumpy/glow.bmp diff --git a/_release/samples/RobCummings/Bumpy/s.jpg b/#Test/samples/RobCummings/Bumpy/s.jpg similarity index 100% rename from _release/samples/RobCummings/Bumpy/s.jpg rename to #Test/samples/RobCummings/Bumpy/s.jpg diff --git a/_release/samples/RobCummings/PyromaniaBB/PyromaniaBB-1.bb b/#Test/samples/RobCummings/PyromaniaBB/PyromaniaBB-1.bb similarity index 100% rename from _release/samples/RobCummings/PyromaniaBB/PyromaniaBB-1.bb rename to #Test/samples/RobCummings/PyromaniaBB/PyromaniaBB-1.bb diff --git a/_release/samples/RobCummings/PyromaniaBB/boomstrip.bmp b/#Test/samples/RobCummings/PyromaniaBB/boomstrip.bmp similarity index 100% rename from _release/samples/RobCummings/PyromaniaBB/boomstrip.bmp rename to #Test/samples/RobCummings/PyromaniaBB/boomstrip.bmp diff --git a/_release/samples/RobCummings/PyromaniaBB/readme.txt b/#Test/samples/RobCummings/PyromaniaBB/readme.txt similarity index 100% rename from _release/samples/RobCummings/PyromaniaBB/readme.txt rename to #Test/samples/RobCummings/PyromaniaBB/readme.txt diff --git a/_release/samples/RobCummings/PyromaniaBB/start.bb b/#Test/samples/RobCummings/PyromaniaBB/start.bb similarity index 100% rename from _release/samples/RobCummings/PyromaniaBB/start.bb rename to #Test/samples/RobCummings/PyromaniaBB/start.bb diff --git a/_release/samples/RobHutchinson/BBLauncher/About.TXT b/#Test/samples/RobHutchinson/BBLauncher/About.TXT similarity index 100% rename from _release/samples/RobHutchinson/BBLauncher/About.TXT rename to #Test/samples/RobHutchinson/BBLauncher/About.TXT diff --git a/_release/samples/RobHutchinson/BBLauncher/Docs/Readme.txt b/#Test/samples/RobHutchinson/BBLauncher/Docs/Readme.txt similarity index 100% rename from _release/samples/RobHutchinson/BBLauncher/Docs/Readme.txt rename to #Test/samples/RobHutchinson/BBLauncher/Docs/Readme.txt diff --git a/_release/samples/RobHutchinson/BBLauncher/Launcher.INI b/#Test/samples/RobHutchinson/BBLauncher/Launcher.INI similarity index 100% rename from _release/samples/RobHutchinson/BBLauncher/Launcher.INI rename to #Test/samples/RobHutchinson/BBLauncher/Launcher.INI diff --git a/_release/samples/RobHutchinson/BBLauncher/Launcher.exe b/#Test/samples/RobHutchinson/BBLauncher/Launcher.exe similarity index 100% rename from _release/samples/RobHutchinson/BBLauncher/Launcher.exe rename to #Test/samples/RobHutchinson/BBLauncher/Launcher.exe diff --git a/_release/samples/RobHutchinson/BBLauncher/Launcher_CLEAN.INI b/#Test/samples/RobHutchinson/BBLauncher/Launcher_CLEAN.INI similarity index 100% rename from _release/samples/RobHutchinson/BBLauncher/Launcher_CLEAN.INI rename to #Test/samples/RobHutchinson/BBLauncher/Launcher_CLEAN.INI diff --git a/_release/samples/RobHutchinson/BBLauncher/example.bb b/#Test/samples/RobHutchinson/BBLauncher/example.bb similarity index 100% rename from _release/samples/RobHutchinson/BBLauncher/example.bb rename to #Test/samples/RobHutchinson/BBLauncher/example.bb diff --git a/_release/samples/RobHutchinson/BBLauncher/icon.ico b/#Test/samples/RobHutchinson/BBLauncher/icon.ico similarity index 100% rename from _release/samples/RobHutchinson/BBLauncher/icon.ico rename to #Test/samples/RobHutchinson/BBLauncher/icon.ico diff --git a/_release/samples/RobHutchinson/BBLauncher/launcher2d.bb b/#Test/samples/RobHutchinson/BBLauncher/launcher2d.bb similarity index 100% rename from _release/samples/RobHutchinson/BBLauncher/launcher2d.bb rename to #Test/samples/RobHutchinson/BBLauncher/launcher2d.bb diff --git a/_release/samples/RobHutchinson/BBLauncher/launcher3d.bb b/#Test/samples/RobHutchinson/BBLauncher/launcher3d.bb similarity index 100% rename from _release/samples/RobHutchinson/BBLauncher/launcher3d.bb rename to #Test/samples/RobHutchinson/BBLauncher/launcher3d.bb diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Block Graveyard.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Block Graveyard.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Block Graveyard.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Block Graveyard.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Block Heaven.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Block Heaven.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Block Heaven.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Block Heaven.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Colour Tunnel 2.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Colour Tunnel 2.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Colour Tunnel 2.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Colour Tunnel 2.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Colour Tunnel.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Colour Tunnel.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Colour Tunnel.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Colour Tunnel.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Original + Zoom Panning SLOW.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Original + Zoom Panning SLOW.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Original + Zoom Panning SLOW.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Original + Zoom Panning SLOW.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Original + Zoom Panning.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Original + Zoom Panning.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Original + Zoom Panning.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Original + Zoom Panning.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Original Beta Version.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Original Beta Version.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Original Beta Version.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Original Beta Version.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Original Fish Eye.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Original Fish Eye.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Original Fish Eye.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Original Fish Eye.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Pole Position Tunnel Race I.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Pole Position Tunnel Race I.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Pole Position Tunnel Race I.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Pole Position Tunnel Race I.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Red Weirdness.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Red Weirdness.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Red Weirdness.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Red Weirdness.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Scorching Sun.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Scorching Sun.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Scorching Sun.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Scorching Sun.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Super Fish Eye.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Super Fish Eye.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Super Fish Eye.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Super Fish Eye.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/Warp Factor 10 Tunnel Race.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Warp Factor 10 Tunnel Race.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/Warp Factor 10 Tunnel Race.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/Warp Factor 10 Tunnel Race.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Profiles/_Default.pro b/#Test/samples/RobHutchinson/BloxAndSpheres/Profiles/_Default.pro similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Profiles/_Default.pro rename to #Test/samples/RobHutchinson/BloxAndSpheres/Profiles/_Default.pro diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Textures/BlueMush.bmp b/#Test/samples/RobHutchinson/BloxAndSpheres/Textures/BlueMush.bmp similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Textures/BlueMush.bmp rename to #Test/samples/RobHutchinson/BloxAndSpheres/Textures/BlueMush.bmp diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Textures/Brick1.bmp b/#Test/samples/RobHutchinson/BloxAndSpheres/Textures/Brick1.bmp similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Textures/Brick1.bmp rename to #Test/samples/RobHutchinson/BloxAndSpheres/Textures/Brick1.bmp diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Textures/GridEnv.jpg b/#Test/samples/RobHutchinson/BloxAndSpheres/Textures/GridEnv.jpg similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Textures/GridEnv.jpg rename to #Test/samples/RobHutchinson/BloxAndSpheres/Textures/GridEnv.jpg diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Textures/Marble1.jpg b/#Test/samples/RobHutchinson/BloxAndSpheres/Textures/Marble1.jpg similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Textures/Marble1.jpg rename to #Test/samples/RobHutchinson/BloxAndSpheres/Textures/Marble1.jpg diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Textures/RedTile.bmp b/#Test/samples/RobHutchinson/BloxAndSpheres/Textures/RedTile.bmp similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Textures/RedTile.bmp rename to #Test/samples/RobHutchinson/BloxAndSpheres/Textures/RedTile.bmp diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Textures/SDS.bmp b/#Test/samples/RobHutchinson/BloxAndSpheres/Textures/SDS.bmp similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Textures/SDS.bmp rename to #Test/samples/RobHutchinson/BloxAndSpheres/Textures/SDS.bmp diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Textures/Stone1.bmp b/#Test/samples/RobHutchinson/BloxAndSpheres/Textures/Stone1.bmp similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Textures/Stone1.bmp rename to #Test/samples/RobHutchinson/BloxAndSpheres/Textures/Stone1.bmp diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/Textures/Wood1.bmp b/#Test/samples/RobHutchinson/BloxAndSpheres/Textures/Wood1.bmp similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/Textures/Wood1.bmp rename to #Test/samples/RobHutchinson/BloxAndSpheres/Textures/Wood1.bmp diff --git a/_release/samples/RobHutchinson/BloxAndSpheres/blox&spheres.bb b/#Test/samples/RobHutchinson/BloxAndSpheres/blox&spheres.bb similarity index 100% rename from _release/samples/RobHutchinson/BloxAndSpheres/blox&spheres.bb rename to #Test/samples/RobHutchinson/BloxAndSpheres/blox&spheres.bb diff --git a/_release/samples/RobHutchinson/CraftFlare/Craft1.x b/#Test/samples/RobHutchinson/CraftFlare/Craft1.x similarity index 100% rename from _release/samples/RobHutchinson/CraftFlare/Craft1.x rename to #Test/samples/RobHutchinson/CraftFlare/Craft1.x diff --git a/_release/samples/RobHutchinson/CraftFlare/Craft1_0.bmp b/#Test/samples/RobHutchinson/CraftFlare/Craft1_0.bmp similarity index 100% rename from _release/samples/RobHutchinson/CraftFlare/Craft1_0.bmp rename to #Test/samples/RobHutchinson/CraftFlare/Craft1_0.bmp diff --git a/_release/samples/RobHutchinson/CraftFlare/Craft1_1.bmp b/#Test/samples/RobHutchinson/CraftFlare/Craft1_1.bmp similarity index 100% rename from _release/samples/RobHutchinson/CraftFlare/Craft1_1.bmp rename to #Test/samples/RobHutchinson/CraftFlare/Craft1_1.bmp diff --git a/_release/samples/RobHutchinson/CraftFlare/Craft1_2.bmp b/#Test/samples/RobHutchinson/CraftFlare/Craft1_2.bmp similarity index 100% rename from _release/samples/RobHutchinson/CraftFlare/Craft1_2.bmp rename to #Test/samples/RobHutchinson/CraftFlare/Craft1_2.bmp diff --git a/_release/samples/RobHutchinson/CraftFlare/CraftFlare.bb b/#Test/samples/RobHutchinson/CraftFlare/CraftFlare.bb similarity index 100% rename from _release/samples/RobHutchinson/CraftFlare/CraftFlare.bb rename to #Test/samples/RobHutchinson/CraftFlare/CraftFlare.bb diff --git a/_release/samples/RobHutchinson/CraftFlare/CraftFlare_Readme.txt b/#Test/samples/RobHutchinson/CraftFlare/CraftFlare_Readme.txt similarity index 100% rename from _release/samples/RobHutchinson/CraftFlare/CraftFlare_Readme.txt rename to #Test/samples/RobHutchinson/CraftFlare/CraftFlare_Readme.txt diff --git a/_release/samples/RobHutchinson/CraftFlare/Flame1.bmp b/#Test/samples/RobHutchinson/CraftFlare/Flame1.bmp similarity index 100% rename from _release/samples/RobHutchinson/CraftFlare/Flame1.bmp rename to #Test/samples/RobHutchinson/CraftFlare/Flame1.bmp diff --git a/_release/samples/RobHutchinson/CraftFlare/Flame2.bmp b/#Test/samples/RobHutchinson/CraftFlare/Flame2.bmp similarity index 100% rename from _release/samples/RobHutchinson/CraftFlare/Flame2.bmp rename to #Test/samples/RobHutchinson/CraftFlare/Flame2.bmp diff --git a/_release/samples/RobHutchinson/CraftFlare/start.bb b/#Test/samples/RobHutchinson/CraftFlare/start.bb similarity index 100% rename from _release/samples/RobHutchinson/CraftFlare/start.bb rename to #Test/samples/RobHutchinson/CraftFlare/start.bb diff --git a/_release/samples/RobHutchinson/ModelChildren/Models/facia.x b/#Test/samples/RobHutchinson/ModelChildren/Models/facia.x similarity index 100% rename from _release/samples/RobHutchinson/ModelChildren/Models/facia.x rename to #Test/samples/RobHutchinson/ModelChildren/Models/facia.x diff --git a/_release/samples/RobHutchinson/ModelChildren/Models/facia_0.bmp b/#Test/samples/RobHutchinson/ModelChildren/Models/facia_0.bmp similarity index 100% rename from _release/samples/RobHutchinson/ModelChildren/Models/facia_0.bmp rename to #Test/samples/RobHutchinson/ModelChildren/Models/facia_0.bmp diff --git a/_release/samples/RobHutchinson/ModelChildren/Models/facia_1.bmp b/#Test/samples/RobHutchinson/ModelChildren/Models/facia_1.bmp similarity index 100% rename from _release/samples/RobHutchinson/ModelChildren/Models/facia_1.bmp rename to #Test/samples/RobHutchinson/ModelChildren/Models/facia_1.bmp diff --git a/_release/samples/RobHutchinson/ModelChildren/modelchildren.bb b/#Test/samples/RobHutchinson/ModelChildren/modelchildren.bb similarity index 100% rename from _release/samples/RobHutchinson/ModelChildren/modelchildren.bb rename to #Test/samples/RobHutchinson/ModelChildren/modelchildren.bb diff --git a/_release/samples/RobHutchinson/ModelChildren/start.bb b/#Test/samples/RobHutchinson/ModelChildren/start.bb similarity index 100% rename from _release/samples/RobHutchinson/ModelChildren/start.bb rename to #Test/samples/RobHutchinson/ModelChildren/start.bb diff --git a/_release/samples/RobHutchinson/SkyPlateau/About.TXT b/#Test/samples/RobHutchinson/SkyPlateau/About.TXT similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/About.TXT rename to #Test/samples/RobHutchinson/SkyPlateau/About.TXT diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/env.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/env.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/env.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/env.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/env2.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/env2.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/env2.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/env2.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/flare.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/flare.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/flare.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/flare.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/hyperflare.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/hyperflare.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/hyperflare.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/hyperflare.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/logo.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/logo.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/logo.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/logo.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/lower.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/lower.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/lower.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/lower.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/menubar.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/menubar.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/menubar.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/menubar.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/options.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/options.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/options.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/options.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/plantlife.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/plantlife.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/plantlife.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/plantlife.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/shields.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/shields.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/shields.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/shields.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/sky.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/sky.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/sky.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/sky.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Graphics/stars.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Graphics/stars.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Graphics/stars.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Graphics/stars.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Launcher.INI b/#Test/samples/RobHutchinson/SkyPlateau/Launcher.INI similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Launcher.INI rename to #Test/samples/RobHutchinson/SkyPlateau/Launcher.INI diff --git a/_release/samples/RobHutchinson/SkyPlateau/Launcher.exe b/#Test/samples/RobHutchinson/SkyPlateau/Launcher.exe similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Launcher.exe rename to #Test/samples/RobHutchinson/SkyPlateau/Launcher.exe diff --git a/_release/samples/RobHutchinson/SkyPlateau/Models/ground.x b/#Test/samples/RobHutchinson/SkyPlateau/Models/ground.x similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Models/ground.x rename to #Test/samples/RobHutchinson/SkyPlateau/Models/ground.x diff --git a/_release/samples/RobHutchinson/SkyPlateau/Models/ground_0.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Models/ground_0.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Models/ground_0.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Models/ground_0.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Models/ground_1.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Models/ground_1.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Models/ground_1.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Models/ground_1.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Models/ground_2.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Models/ground_2.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Models/ground_2.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Models/ground_2.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Models/ground_3.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Models/ground_3.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Models/ground_3.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Models/ground_3.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Models/icon.x b/#Test/samples/RobHutchinson/SkyPlateau/Models/icon.x similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Models/icon.x rename to #Test/samples/RobHutchinson/SkyPlateau/Models/icon.x diff --git a/_release/samples/RobHutchinson/SkyPlateau/Models/mix.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Models/mix.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Models/mix.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Models/mix.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Models/plantlife.md2 b/#Test/samples/RobHutchinson/SkyPlateau/Models/plantlife.md2 similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Models/plantlife.md2 rename to #Test/samples/RobHutchinson/SkyPlateau/Models/plantlife.md2 diff --git a/_release/samples/RobHutchinson/SkyPlateau/Models/totem.x b/#Test/samples/RobHutchinson/SkyPlateau/Models/totem.x similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Models/totem.x rename to #Test/samples/RobHutchinson/SkyPlateau/Models/totem.x diff --git a/_release/samples/RobHutchinson/SkyPlateau/Models/totem_0.bmp b/#Test/samples/RobHutchinson/SkyPlateau/Models/totem_0.bmp similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Models/totem_0.bmp rename to #Test/samples/RobHutchinson/SkyPlateau/Models/totem_0.bmp diff --git a/_release/samples/RobHutchinson/SkyPlateau/Music/atmos.mp3 b/#Test/samples/RobHutchinson/SkyPlateau/Music/atmos.mp3 similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Music/atmos.mp3 rename to #Test/samples/RobHutchinson/SkyPlateau/Music/atmos.mp3 diff --git a/_release/samples/RobHutchinson/SkyPlateau/Settings.INI b/#Test/samples/RobHutchinson/SkyPlateau/Settings.INI similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/Settings.INI rename to #Test/samples/RobHutchinson/SkyPlateau/Settings.INI diff --git a/_release/samples/RobHutchinson/SkyPlateau/SkyPlateau.bb b/#Test/samples/RobHutchinson/SkyPlateau/SkyPlateau.bb similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/SkyPlateau.bb rename to #Test/samples/RobHutchinson/SkyPlateau/SkyPlateau.bb diff --git a/_release/samples/RobHutchinson/SkyPlateau/icon.ico b/#Test/samples/RobHutchinson/SkyPlateau/icon.ico similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/icon.ico rename to #Test/samples/RobHutchinson/SkyPlateau/icon.ico diff --git a/_release/samples/RobHutchinson/SkyPlateau/launcher3d.bb b/#Test/samples/RobHutchinson/SkyPlateau/launcher3d.bb similarity index 100% rename from _release/samples/RobHutchinson/SkyPlateau/launcher3d.bb rename to #Test/samples/RobHutchinson/SkyPlateau/launcher3d.bb diff --git a/_release/samples/RobHutchinson/WateryTerrain/oceanfloor.bmp b/#Test/samples/RobHutchinson/WateryTerrain/oceanfloor.bmp similarity index 100% rename from _release/samples/RobHutchinson/WateryTerrain/oceanfloor.bmp rename to #Test/samples/RobHutchinson/WateryTerrain/oceanfloor.bmp diff --git a/_release/samples/RobHutchinson/WateryTerrain/start.bb b/#Test/samples/RobHutchinson/WateryTerrain/start.bb similarity index 100% rename from _release/samples/RobHutchinson/WateryTerrain/start.bb rename to #Test/samples/RobHutchinson/WateryTerrain/start.bb diff --git a/_release/samples/RobHutchinson/WateryTerrain/water.bb b/#Test/samples/RobHutchinson/WateryTerrain/water.bb similarity index 100% rename from _release/samples/RobHutchinson/WateryTerrain/water.bb rename to #Test/samples/RobHutchinson/WateryTerrain/water.bb diff --git a/_release/samples/RobHutchinson/WateryTerrain/water.bmp b/#Test/samples/RobHutchinson/WateryTerrain/water.bmp similarity index 100% rename from _release/samples/RobHutchinson/WateryTerrain/water.bmp rename to #Test/samples/RobHutchinson/WateryTerrain/water.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/Craft1.x b/#Test/samples/RobHutchinson/WingPilot/Craft1.x similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/Craft1.x rename to #Test/samples/RobHutchinson/WingPilot/Craft1.x diff --git a/_release/samples/RobHutchinson/WingPilot/Craft1_0.bmp b/#Test/samples/RobHutchinson/WingPilot/Craft1_0.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/Craft1_0.bmp rename to #Test/samples/RobHutchinson/WingPilot/Craft1_0.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/Craft1_1.bmp b/#Test/samples/RobHutchinson/WingPilot/Craft1_1.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/Craft1_1.bmp rename to #Test/samples/RobHutchinson/WingPilot/Craft1_1.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/Craft1_2.bmp b/#Test/samples/RobHutchinson/WingPilot/Craft1_2.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/Craft1_2.bmp rename to #Test/samples/RobHutchinson/WingPilot/Craft1_2.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/WingPilotV0_01.bb b/#Test/samples/RobHutchinson/WingPilot/WingPilotV0_01.bb similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/WingPilotV0_01.bb rename to #Test/samples/RobHutchinson/WingPilot/WingPilotV0_01.bb diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/Lava3.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/Lava3.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/Lava3.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/Lava3.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/Marblate1.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/Marblate1.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/Marblate1.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/Marblate1.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/Watery.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/Watery.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/Watery.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/Watery.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/Watery3.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/Watery3.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/Watery3.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/Watery3.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/Weird.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/Weird.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/Weird.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/Weird.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/bullet1.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/bullet1.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/bullet1.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/bullet1.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/bullet2.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/bullet2.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/bullet2.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/bullet2.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/central.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/central.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/central.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/central.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/flame1.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/flame1.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/flame1.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/flame1.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/flame2.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/flame2.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/flame2.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/flame2.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/lamp.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/lamp.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/lamp.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/lamp.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/ring.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/ring.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/ring.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/ring.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/graphics/shields.bmp b/#Test/samples/RobHutchinson/WingPilot/graphics/shields.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/graphics/shields.bmp rename to #Test/samples/RobHutchinson/WingPilot/graphics/shields.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/image_source/insignia.bmp b/#Test/samples/RobHutchinson/WingPilot/image_source/insignia.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/image_source/insignia.bmp rename to #Test/samples/RobHutchinson/WingPilot/image_source/insignia.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/model_source/eye_piece1.3ds b/#Test/samples/RobHutchinson/WingPilot/model_source/eye_piece1.3ds similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/model_source/eye_piece1.3ds rename to #Test/samples/RobHutchinson/WingPilot/model_source/eye_piece1.3ds diff --git a/_release/samples/RobHutchinson/WingPilot/model_source/frame.bmp b/#Test/samples/RobHutchinson/WingPilot/model_source/frame.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/model_source/frame.bmp rename to #Test/samples/RobHutchinson/WingPilot/model_source/frame.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/model_source/grscreen.bmp b/#Test/samples/RobHutchinson/WingPilot/model_source/grscreen.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/model_source/grscreen.bmp rename to #Test/samples/RobHutchinson/WingPilot/model_source/grscreen.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/objects/eyepiece.x b/#Test/samples/RobHutchinson/WingPilot/objects/eyepiece.x similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/objects/eyepiece.x rename to #Test/samples/RobHutchinson/WingPilot/objects/eyepiece.x diff --git a/_release/samples/RobHutchinson/WingPilot/objects/eyepiece_0.bmp b/#Test/samples/RobHutchinson/WingPilot/objects/eyepiece_0.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/objects/eyepiece_0.bmp rename to #Test/samples/RobHutchinson/WingPilot/objects/eyepiece_0.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/objects/eyepiece_1.bmp b/#Test/samples/RobHutchinson/WingPilot/objects/eyepiece_1.bmp similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/objects/eyepiece_1.bmp rename to #Test/samples/RobHutchinson/WingPilot/objects/eyepiece_1.bmp diff --git a/_release/samples/RobHutchinson/WingPilot/objects/maincent.x b/#Test/samples/RobHutchinson/WingPilot/objects/maincent.x similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/objects/maincent.x rename to #Test/samples/RobHutchinson/WingPilot/objects/maincent.x diff --git a/_release/samples/RobHutchinson/WingPilot/objects/mainring.x b/#Test/samples/RobHutchinson/WingPilot/objects/mainring.x similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/objects/mainring.x rename to #Test/samples/RobHutchinson/WingPilot/objects/mainring.x diff --git a/_release/samples/RobHutchinson/WingPilot/sounds/bonus.wav b/#Test/samples/RobHutchinson/WingPilot/sounds/bonus.wav similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/sounds/bonus.wav rename to #Test/samples/RobHutchinson/WingPilot/sounds/bonus.wav diff --git a/_release/samples/RobHutchinson/WingPilot/sounds/bullet1.wav b/#Test/samples/RobHutchinson/WingPilot/sounds/bullet1.wav similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/sounds/bullet1.wav rename to #Test/samples/RobHutchinson/WingPilot/sounds/bullet1.wav diff --git a/_release/samples/RobHutchinson/WingPilot/sounds/damage.wav b/#Test/samples/RobHutchinson/WingPilot/sounds/damage.wav similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/sounds/damage.wav rename to #Test/samples/RobHutchinson/WingPilot/sounds/damage.wav diff --git a/_release/samples/RobHutchinson/WingPilot/sounds/toot.wav b/#Test/samples/RobHutchinson/WingPilot/sounds/toot.wav similarity index 100% rename from _release/samples/RobHutchinson/WingPilot/sounds/toot.wav rename to #Test/samples/RobHutchinson/WingPilot/sounds/toot.wav diff --git a/_release/samples/Skully/flares/Graphics/redspark.bmp b/#Test/samples/Skully/flares/Graphics/redspark.bmp similarity index 100% rename from _release/samples/Skully/flares/Graphics/redspark.bmp rename to #Test/samples/Skully/flares/Graphics/redspark.bmp diff --git a/_release/samples/Skully/flares/flares.bb b/#Test/samples/Skully/flares/flares.bb similarity index 100% rename from _release/samples/Skully/flares/flares.bb rename to #Test/samples/Skully/flares/flares.bb diff --git a/_release/samples/Skully/flares/readme.txt b/#Test/samples/Skully/flares/readme.txt similarity index 100% rename from _release/samples/Skully/flares/readme.txt rename to #Test/samples/Skully/flares/readme.txt diff --git a/_release/samples/Skully/flares/startup.ini b/#Test/samples/Skully/flares/startup.ini similarity index 100% rename from _release/samples/Skully/flares/startup.ini rename to #Test/samples/Skully/flares/startup.ini diff --git a/_release/samples/Skully/start.bb b/#Test/samples/Skully/start.bb similarity index 100% rename from _release/samples/Skully/start.bb rename to #Test/samples/Skully/start.bb diff --git a/_release/samples/birdie/2d-3dsprites/sprites.bb b/#Test/samples/birdie/2d-3dsprites/sprites.bb similarity index 100% rename from _release/samples/birdie/2d-3dsprites/sprites.bb rename to #Test/samples/birdie/2d-3dsprites/sprites.bb diff --git a/_release/samples/birdie/2d-3dsprites/test.jpg b/#Test/samples/birdie/2d-3dsprites/test.jpg similarity index 100% rename from _release/samples/birdie/2d-3dsprites/test.jpg rename to #Test/samples/birdie/2d-3dsprites/test.jpg diff --git a/_release/samples/birdie/Brush Tiles/Moss.bmp b/#Test/samples/birdie/Brush Tiles/Moss.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/Moss.bmp rename to #Test/samples/birdie/Brush Tiles/Moss.bmp diff --git a/_release/samples/birdie/Brush Tiles/bl3d_big.jpg b/#Test/samples/birdie/Brush Tiles/bl3d_big.jpg similarity index 100% rename from _release/samples/birdie/Brush Tiles/bl3d_big.jpg rename to #Test/samples/birdie/Brush Tiles/bl3d_big.jpg diff --git a/_release/samples/birdie/Brush Tiles/hmap.BMP b/#Test/samples/birdie/Brush Tiles/hmap.BMP similarity index 100% rename from _release/samples/birdie/Brush Tiles/hmap.BMP rename to #Test/samples/birdie/Brush Tiles/hmap.BMP diff --git a/_release/samples/birdie/Brush Tiles/lightmap.bmp b/#Test/samples/birdie/Brush Tiles/lightmap.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/lightmap.bmp rename to #Test/samples/birdie/Brush Tiles/lightmap.bmp diff --git a/_release/samples/birdie/Brush Tiles/mask.BMP b/#Test/samples/birdie/Brush Tiles/mask.BMP similarity index 100% rename from _release/samples/birdie/Brush Tiles/mask.BMP rename to #Test/samples/birdie/Brush Tiles/mask.BMP diff --git a/_release/samples/birdie/Brush Tiles/sky_BK.bmp b/#Test/samples/birdie/Brush Tiles/sky_BK.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/sky_BK.bmp rename to #Test/samples/birdie/Brush Tiles/sky_BK.bmp diff --git a/_release/samples/birdie/Brush Tiles/sky_FR.bmp b/#Test/samples/birdie/Brush Tiles/sky_FR.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/sky_FR.bmp rename to #Test/samples/birdie/Brush Tiles/sky_FR.bmp diff --git a/_release/samples/birdie/Brush Tiles/sky_LF.bmp b/#Test/samples/birdie/Brush Tiles/sky_LF.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/sky_LF.bmp rename to #Test/samples/birdie/Brush Tiles/sky_LF.bmp diff --git a/_release/samples/birdie/Brush Tiles/sky_RT.bmp b/#Test/samples/birdie/Brush Tiles/sky_RT.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/sky_RT.bmp rename to #Test/samples/birdie/Brush Tiles/sky_RT.bmp diff --git a/_release/samples/birdie/Brush Tiles/sky_UP.bmp b/#Test/samples/birdie/Brush Tiles/sky_UP.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/sky_UP.bmp rename to #Test/samples/birdie/Brush Tiles/sky_UP.bmp diff --git a/_release/samples/birdie/Brush Tiles/tex0.bmp b/#Test/samples/birdie/Brush Tiles/tex0.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/tex0.bmp rename to #Test/samples/birdie/Brush Tiles/tex0.bmp diff --git a/_release/samples/birdie/Brush Tiles/tex1.bmp b/#Test/samples/birdie/Brush Tiles/tex1.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/tex1.bmp rename to #Test/samples/birdie/Brush Tiles/tex1.bmp diff --git a/_release/samples/birdie/Brush Tiles/tex2.bmp b/#Test/samples/birdie/Brush Tiles/tex2.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/tex2.bmp rename to #Test/samples/birdie/Brush Tiles/tex2.bmp diff --git a/_release/samples/birdie/Brush Tiles/tex3.bmp b/#Test/samples/birdie/Brush Tiles/tex3.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/tex3.bmp rename to #Test/samples/birdie/Brush Tiles/tex3.bmp diff --git a/_release/samples/birdie/Brush Tiles/tex4.bmp b/#Test/samples/birdie/Brush Tiles/tex4.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/tex4.bmp rename to #Test/samples/birdie/Brush Tiles/tex4.bmp diff --git a/_release/samples/birdie/Brush Tiles/tex5.bmp b/#Test/samples/birdie/Brush Tiles/tex5.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/tex5.bmp rename to #Test/samples/birdie/Brush Tiles/tex5.bmp diff --git a/_release/samples/birdie/Brush Tiles/tex6.bmp b/#Test/samples/birdie/Brush Tiles/tex6.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/tex6.bmp rename to #Test/samples/birdie/Brush Tiles/tex6.bmp diff --git a/_release/samples/birdie/Brush Tiles/tex7.bmp b/#Test/samples/birdie/Brush Tiles/tex7.bmp similarity index 100% rename from _release/samples/birdie/Brush Tiles/tex7.bmp rename to #Test/samples/birdie/Brush Tiles/tex7.bmp diff --git a/_release/samples/birdie/Brush Tiles/tt.bb b/#Test/samples/birdie/Brush Tiles/tt.bb similarity index 100% rename from _release/samples/birdie/Brush Tiles/tt.bb rename to #Test/samples/birdie/Brush Tiles/tt.bb diff --git a/_release/samples/birdie/CameraPickST/CameraPickST/main.bb b/#Test/samples/birdie/CameraPickST/CameraPickST/main.bb similarity index 100% rename from _release/samples/birdie/CameraPickST/CameraPickST/main.bb rename to #Test/samples/birdie/CameraPickST/CameraPickST/main.bb diff --git a/_release/samples/birdie/Explode/Explode.bb b/#Test/samples/birdie/Explode/Explode.bb similarity index 100% rename from _release/samples/birdie/Explode/Explode.bb rename to #Test/samples/birdie/Explode/Explode.bb diff --git a/_release/samples/birdie/Explode/tex0.bmp b/#Test/samples/birdie/Explode/tex0.bmp similarity index 100% rename from _release/samples/birdie/Explode/tex0.bmp rename to #Test/samples/birdie/Explode/tex0.bmp diff --git a/_release/samples/birdie/Fire Effect/Fire Effect/Main.bb b/#Test/samples/birdie/Fire Effect/Fire Effect/Main.bb similarity index 100% rename from _release/samples/birdie/Fire Effect/Fire Effect/Main.bb rename to #Test/samples/birdie/Fire Effect/Fire Effect/Main.bb diff --git a/_release/samples/birdie/Fire Effect/Fire Effect/particle.bmp b/#Test/samples/birdie/Fire Effect/Fire Effect/particle.bmp similarity index 100% rename from _release/samples/birdie/Fire Effect/Fire Effect/particle.bmp rename to #Test/samples/birdie/Fire Effect/Fire Effect/particle.bmp diff --git a/_release/samples/birdie/Fire Effect/Fire Effect/smk01.BMP b/#Test/samples/birdie/Fire Effect/Fire Effect/smk01.BMP similarity index 100% rename from _release/samples/birdie/Fire Effect/Fire Effect/smk01.BMP rename to #Test/samples/birdie/Fire Effect/Fire Effect/smk01.BMP diff --git a/_release/samples/birdie/Jet Tails/Main.bb b/#Test/samples/birdie/Jet Tails/Main.bb similarity index 100% rename from _release/samples/birdie/Jet Tails/Main.bb rename to #Test/samples/birdie/Jet Tails/Main.bb diff --git a/_release/samples/birdie/Jet Tails/jet.x b/#Test/samples/birdie/Jet Tails/jet.x similarity index 100% rename from _release/samples/birdie/Jet Tails/jet.x rename to #Test/samples/birdie/Jet Tails/jet.x diff --git a/_release/samples/birdie/LodMesh/SKELETON.3DS b/#Test/samples/birdie/LodMesh/SKELETON.3DS similarity index 100% rename from _release/samples/birdie/LodMesh/SKELETON.3DS rename to #Test/samples/birdie/LodMesh/SKELETON.3DS diff --git a/_release/samples/birdie/LodMesh/dolphin.bmp b/#Test/samples/birdie/LodMesh/dolphin.bmp similarity index 100% rename from _release/samples/birdie/LodMesh/dolphin.bmp rename to #Test/samples/birdie/LodMesh/dolphin.bmp diff --git a/_release/samples/birdie/LodMesh/dolphin.x b/#Test/samples/birdie/LodMesh/dolphin.x similarity index 100% rename from _release/samples/birdie/LodMesh/dolphin.x rename to #Test/samples/birdie/LodMesh/dolphin.x diff --git a/_release/samples/birdie/LodMesh/gnome.3DS b/#Test/samples/birdie/LodMesh/gnome.3DS similarity index 100% rename from _release/samples/birdie/LodMesh/gnome.3DS rename to #Test/samples/birdie/LodMesh/gnome.3DS diff --git a/_release/samples/birdie/LodMesh/lmesh.bb b/#Test/samples/birdie/LodMesh/lmesh.bb similarity index 100% rename from _release/samples/birdie/LodMesh/lmesh.bb rename to #Test/samples/birdie/LodMesh/lmesh.bb diff --git a/_release/samples/birdie/LodMesh/skull.3ds b/#Test/samples/birdie/LodMesh/skull.3ds similarity index 100% rename from _release/samples/birdie/LodMesh/skull.3ds rename to #Test/samples/birdie/LodMesh/skull.3ds diff --git a/_release/samples/birdie/Mirror/mirror.bb b/#Test/samples/birdie/Mirror/mirror.bb similarity index 100% rename from _release/samples/birdie/Mirror/mirror.bb rename to #Test/samples/birdie/Mirror/mirror.bb diff --git a/_release/samples/birdie/Mirror/tex0.bmp b/#Test/samples/birdie/Mirror/tex0.bmp similarity index 100% rename from _release/samples/birdie/Mirror/tex0.bmp rename to #Test/samples/birdie/Mirror/tex0.bmp diff --git a/_release/samples/birdie/Quick Deform/bl3d_big.jpg b/#Test/samples/birdie/Quick Deform/bl3d_big.jpg similarity index 100% rename from _release/samples/birdie/Quick Deform/bl3d_big.jpg rename to #Test/samples/birdie/Quick Deform/bl3d_big.jpg diff --git a/_release/samples/birdie/Quick Deform/qd.bb b/#Test/samples/birdie/Quick Deform/qd.bb similarity index 100% rename from _release/samples/birdie/Quick Deform/qd.bb rename to #Test/samples/birdie/Quick Deform/qd.bb diff --git a/_release/samples/birdie/Spherical Landscapes/functions.bb b/#Test/samples/birdie/Spherical Landscapes/functions.bb similarity index 100% rename from _release/samples/birdie/Spherical Landscapes/functions.bb rename to #Test/samples/birdie/Spherical Landscapes/functions.bb diff --git a/_release/samples/birdie/Spherical Landscapes/geosphere.3DS b/#Test/samples/birdie/Spherical Landscapes/geosphere.3DS similarity index 100% rename from _release/samples/birdie/Spherical Landscapes/geosphere.3DS rename to #Test/samples/birdie/Spherical Landscapes/geosphere.3DS diff --git a/_release/samples/birdie/Spherical Landscapes/testbed.bb b/#Test/samples/birdie/Spherical Landscapes/testbed.bb similarity index 100% rename from _release/samples/birdie/Spherical Landscapes/testbed.bb rename to #Test/samples/birdie/Spherical Landscapes/testbed.bb diff --git a/_release/samples/birdie/Spherical Landscapes/tex0.bmp b/#Test/samples/birdie/Spherical Landscapes/tex0.bmp similarity index 100% rename from _release/samples/birdie/Spherical Landscapes/tex0.bmp rename to #Test/samples/birdie/Spherical Landscapes/tex0.bmp diff --git a/_release/samples/birdie/Terrain Tiling/16tex.bmp b/#Test/samples/birdie/Terrain Tiling/16tex.bmp similarity index 100% rename from _release/samples/birdie/Terrain Tiling/16tex.bmp rename to #Test/samples/birdie/Terrain Tiling/16tex.bmp diff --git a/_release/samples/birdie/Terrain Tiling/PREVIEW.PIX b/#Test/samples/birdie/Terrain Tiling/PREVIEW.PIX similarity index 100% rename from _release/samples/birdie/Terrain Tiling/PREVIEW.PIX rename to #Test/samples/birdie/Terrain Tiling/PREVIEW.PIX diff --git a/_release/samples/birdie/Terrain Tiling/hmap.BMP b/#Test/samples/birdie/Terrain Tiling/hmap.BMP similarity index 100% rename from _release/samples/birdie/Terrain Tiling/hmap.BMP rename to #Test/samples/birdie/Terrain Tiling/hmap.BMP diff --git a/_release/samples/birdie/Terrain Tiling/mask.BMP b/#Test/samples/birdie/Terrain Tiling/mask.BMP similarity index 100% rename from _release/samples/birdie/Terrain Tiling/mask.BMP rename to #Test/samples/birdie/Terrain Tiling/mask.BMP diff --git a/_release/samples/birdie/Terrain Tiling/tex0.bmp b/#Test/samples/birdie/Terrain Tiling/tex0.bmp similarity index 100% rename from _release/samples/birdie/Terrain Tiling/tex0.bmp rename to #Test/samples/birdie/Terrain Tiling/tex0.bmp diff --git a/_release/samples/birdie/Terrain Tiling/tt.bb b/#Test/samples/birdie/Terrain Tiling/tt.bb similarity index 100% rename from _release/samples/birdie/Terrain Tiling/tt.bb rename to #Test/samples/birdie/Terrain Tiling/tt.bb diff --git a/_release/samples/birdie/UVMapping/UVMapping/test.bb b/#Test/samples/birdie/UVMapping/UVMapping/test.bb similarity index 100% rename from _release/samples/birdie/UVMapping/UVMapping/test.bb rename to #Test/samples/birdie/UVMapping/UVMapping/test.bb diff --git a/_release/samples/birdie/UVMapping/UVMapping/tex0.jpg b/#Test/samples/birdie/UVMapping/UVMapping/tex0.jpg similarity index 100% rename from _release/samples/birdie/UVMapping/UVMapping/tex0.jpg rename to #Test/samples/birdie/UVMapping/UVMapping/tex0.jpg diff --git a/_release/samples/birdie/dolphin/ddown.x b/#Test/samples/birdie/dolphin/ddown.x similarity index 100% rename from _release/samples/birdie/dolphin/ddown.x rename to #Test/samples/birdie/dolphin/ddown.x diff --git a/_release/samples/birdie/dolphin/dolphin.bb b/#Test/samples/birdie/dolphin/dolphin.bb similarity index 100% rename from _release/samples/birdie/dolphin/dolphin.bb rename to #Test/samples/birdie/dolphin/dolphin.bb diff --git a/_release/samples/birdie/dolphin/dolphin.bmp b/#Test/samples/birdie/dolphin/dolphin.bmp similarity index 100% rename from _release/samples/birdie/dolphin/dolphin.bmp rename to #Test/samples/birdie/dolphin/dolphin.bmp diff --git a/_release/samples/birdie/dolphin/dolphin.x b/#Test/samples/birdie/dolphin/dolphin.x similarity index 100% rename from _release/samples/birdie/dolphin/dolphin.x rename to #Test/samples/birdie/dolphin/dolphin.x diff --git a/_release/samples/birdie/dolphin/dup.x b/#Test/samples/birdie/dolphin/dup.x similarity index 100% rename from _release/samples/birdie/dolphin/dup.x rename to #Test/samples/birdie/dolphin/dup.x diff --git a/_release/samples/birdie/dolphin/seafloor.bmp b/#Test/samples/birdie/dolphin/seafloor.bmp similarity index 100% rename from _release/samples/birdie/dolphin/seafloor.bmp rename to #Test/samples/birdie/dolphin/seafloor.bmp diff --git a/_release/samples/birdie/dolphin/seafloor.x b/#Test/samples/birdie/dolphin/seafloor.x similarity index 100% rename from _release/samples/birdie/dolphin/seafloor.x rename to #Test/samples/birdie/dolphin/seafloor.x diff --git a/_release/samples/birdie/dominos/FloorTile.bmp b/#Test/samples/birdie/dominos/FloorTile.bmp similarity index 100% rename from _release/samples/birdie/dominos/FloorTile.bmp rename to #Test/samples/birdie/dominos/FloorTile.bmp diff --git a/_release/samples/birdie/dominos/dominos.bb b/#Test/samples/birdie/dominos/dominos.bb similarity index 100% rename from _release/samples/birdie/dominos/dominos.bb rename to #Test/samples/birdie/dominos/dominos.bb diff --git a/_release/samples/birdie/dominos/tex0.bmp b/#Test/samples/birdie/dominos/tex0.bmp similarity index 100% rename from _release/samples/birdie/dominos/tex0.bmp rename to #Test/samples/birdie/dominos/tex0.bmp diff --git a/_release/samples/birdie/lodBalls/geo1.3DS b/#Test/samples/birdie/lodBalls/geo1.3DS similarity index 100% rename from _release/samples/birdie/lodBalls/geo1.3DS rename to #Test/samples/birdie/lodBalls/geo1.3DS diff --git a/_release/samples/birdie/lodBalls/subdiv.bb b/#Test/samples/birdie/lodBalls/subdiv.bb similarity index 100% rename from _release/samples/birdie/lodBalls/subdiv.bb rename to #Test/samples/birdie/lodBalls/subdiv.bb diff --git a/_release/samples/birdie/lodBalls/tex0.bmp b/#Test/samples/birdie/lodBalls/tex0.bmp similarity index 100% rename from _release/samples/birdie/lodBalls/tex0.bmp rename to #Test/samples/birdie/lodBalls/tex0.bmp diff --git a/_release/samples/birdie/te/TE.bb b/#Test/samples/birdie/te/TE.bb similarity index 100% rename from _release/samples/birdie/te/TE.bb rename to #Test/samples/birdie/te/TE.bb diff --git a/_release/samples/birdie/te/forest.BMP b/#Test/samples/birdie/te/forest.BMP similarity index 100% rename from _release/samples/birdie/te/forest.BMP rename to #Test/samples/birdie/te/forest.BMP diff --git a/_release/samples/birdie/te/hmap.bmp b/#Test/samples/birdie/te/hmap.bmp similarity index 100% rename from _release/samples/birdie/te/hmap.bmp rename to #Test/samples/birdie/te/hmap.bmp diff --git a/_release/samples/birdie/te/hmap2.bmp b/#Test/samples/birdie/te/hmap2.bmp similarity index 100% rename from _release/samples/birdie/te/hmap2.bmp rename to #Test/samples/birdie/te/hmap2.bmp diff --git a/_release/samples/birdie/te/rock.bmp b/#Test/samples/birdie/te/rock.bmp similarity index 100% rename from _release/samples/birdie/te/rock.bmp rename to #Test/samples/birdie/te/rock.bmp diff --git a/_release/samples/birdie/te/tex0.bmp b/#Test/samples/birdie/te/tex0.bmp similarity index 100% rename from _release/samples/birdie/te/tex0.bmp rename to #Test/samples/birdie/te/tex0.bmp diff --git a/_release/samples/birdie/te/tex1.bmp b/#Test/samples/birdie/te/tex1.bmp similarity index 100% rename from _release/samples/birdie/te/tex1.bmp rename to #Test/samples/birdie/te/tex1.bmp diff --git a/_release/samples/birdie/texpaint/main.bb b/#Test/samples/birdie/texpaint/main.bb similarity index 100% rename from _release/samples/birdie/texpaint/main.bb rename to #Test/samples/birdie/texpaint/main.bb diff --git a/_release/samples/birdie/texpaint/tex0.bmp b/#Test/samples/birdie/texpaint/tex0.bmp similarity index 100% rename from _release/samples/birdie/texpaint/tex0.bmp rename to #Test/samples/birdie/texpaint/tex0.bmp diff --git a/_release/samples/birdie/thunder/PREVIEW.PIX b/#Test/samples/birdie/thunder/PREVIEW.PIX similarity index 100% rename from _release/samples/birdie/thunder/PREVIEW.PIX rename to #Test/samples/birdie/thunder/PREVIEW.PIX diff --git a/_release/samples/birdie/thunder/WIND.wav b/#Test/samples/birdie/thunder/WIND.wav similarity index 100% rename from _release/samples/birdie/thunder/WIND.wav rename to #Test/samples/birdie/thunder/WIND.wav diff --git a/_release/samples/birdie/thunder/forest.BMP b/#Test/samples/birdie/thunder/forest.BMP similarity index 100% rename from _release/samples/birdie/thunder/forest.BMP rename to #Test/samples/birdie/thunder/forest.BMP diff --git a/_release/samples/birdie/thunder/hmap.bmp b/#Test/samples/birdie/thunder/hmap.bmp similarity index 100% rename from _release/samples/birdie/thunder/hmap.bmp rename to #Test/samples/birdie/thunder/hmap.bmp diff --git a/_release/samples/birdie/thunder/lightning.bb b/#Test/samples/birdie/thunder/lightning.bb similarity index 100% rename from _release/samples/birdie/thunder/lightning.bb rename to #Test/samples/birdie/thunder/lightning.bb diff --git a/_release/samples/birdie/thunder/tex0.bmp b/#Test/samples/birdie/thunder/tex0.bmp similarity index 100% rename from _release/samples/birdie/thunder/tex0.bmp rename to #Test/samples/birdie/thunder/tex0.bmp diff --git a/_release/samples/birdie/thunder/tex1.bmp b/#Test/samples/birdie/thunder/tex1.bmp similarity index 100% rename from _release/samples/birdie/thunder/tex1.bmp rename to #Test/samples/birdie/thunder/tex1.bmp diff --git a/_release/samples/birdie/thunder/thunder.bb b/#Test/samples/birdie/thunder/thunder.bb similarity index 100% rename from _release/samples/birdie/thunder/thunder.bb rename to #Test/samples/birdie/thunder/thunder.bb diff --git a/_release/samples/birdie/thunder/thunder.wav b/#Test/samples/birdie/thunder/thunder.wav similarity index 100% rename from _release/samples/birdie/thunder/thunder.wav rename to #Test/samples/birdie/thunder/thunder.wav diff --git a/_release/samples/halo/Lightmap/blocks.bmp b/#Test/samples/halo/Lightmap/blocks.bmp similarity index 100% rename from _release/samples/halo/Lightmap/blocks.bmp rename to #Test/samples/halo/Lightmap/blocks.bmp diff --git a/_release/samples/halo/Lightmap/flagstn.bmp b/#Test/samples/halo/Lightmap/flagstn.bmp similarity index 100% rename from _release/samples/halo/Lightmap/flagstn.bmp rename to #Test/samples/halo/Lightmap/flagstn.bmp diff --git a/_release/samples/halo/Lightmap/level.x b/#Test/samples/halo/Lightmap/level.x similarity index 100% rename from _release/samples/halo/Lightmap/level.x rename to #Test/samples/halo/Lightmap/level.x diff --git a/_release/samples/halo/Lightmap/lightmap.bb b/#Test/samples/halo/Lightmap/lightmap.bb similarity index 100% rename from _release/samples/halo/Lightmap/lightmap.bb rename to #Test/samples/halo/Lightmap/lightmap.bb diff --git a/_release/samples/halo/Lightmap/lightmap.bmp b/#Test/samples/halo/Lightmap/lightmap.bmp similarity index 100% rename from _release/samples/halo/Lightmap/lightmap.bmp rename to #Test/samples/halo/Lightmap/lightmap.bmp diff --git a/_release/samples/halo/Lightmap/lightmap.x b/#Test/samples/halo/Lightmap/lightmap.x similarity index 100% rename from _release/samples/halo/Lightmap/lightmap.x rename to #Test/samples/halo/Lightmap/lightmap.x diff --git a/_release/samples/halo/Lightmap/log.txt b/#Test/samples/halo/Lightmap/log.txt similarity index 100% rename from _release/samples/halo/Lightmap/log.txt rename to #Test/samples/halo/Lightmap/log.txt diff --git a/_release/samples/halo/Lightmap/readme.txt b/#Test/samples/halo/Lightmap/readme.txt similarity index 100% rename from _release/samples/halo/Lightmap/readme.txt rename to #Test/samples/halo/Lightmap/readme.txt diff --git a/_release/samples/halo/MeshFX/meshfx.bb b/#Test/samples/halo/MeshFX/meshfx.bb similarity index 100% rename from _release/samples/halo/MeshFX/meshfx.bb rename to #Test/samples/halo/MeshFX/meshfx.bb diff --git a/_release/samples/halo/MeshFX/readme.txt b/#Test/samples/halo/MeshFX/readme.txt similarity index 100% rename from _release/samples/halo/MeshFX/readme.txt rename to #Test/samples/halo/MeshFX/readme.txt diff --git a/_release/samples/halo/MeshFX/skin.bmp b/#Test/samples/halo/MeshFX/skin.bmp similarity index 100% rename from _release/samples/halo/MeshFX/skin.bmp rename to #Test/samples/halo/MeshFX/skin.bmp diff --git a/_release/samples/halo/MeshFX/test.3DS b/#Test/samples/halo/MeshFX/test.3DS similarity index 100% rename from _release/samples/halo/MeshFX/test.3DS rename to #Test/samples/halo/MeshFX/test.3DS diff --git a/_release/samples/halo/Shadows/blitzlogo.bmp b/#Test/samples/halo/Shadows/blitzlogo.bmp similarity index 100% rename from _release/samples/halo/Shadows/blitzlogo.bmp rename to #Test/samples/halo/Shadows/blitzlogo.bmp diff --git a/_release/samples/halo/Shadows/flare0.bmp b/#Test/samples/halo/Shadows/flare0.bmp similarity index 100% rename from _release/samples/halo/Shadows/flare0.bmp rename to #Test/samples/halo/Shadows/flare0.bmp diff --git a/_release/samples/halo/Shadows/readme.txt b/#Test/samples/halo/Shadows/readme.txt similarity index 100% rename from _release/samples/halo/Shadows/readme.txt rename to #Test/samples/halo/Shadows/readme.txt diff --git a/_release/samples/halo/Shadows/shadows.bb b/#Test/samples/halo/Shadows/shadows.bb similarity index 100% rename from _release/samples/halo/Shadows/shadows.bb rename to #Test/samples/halo/Shadows/shadows.bb diff --git a/_release/samples/halo/Shadows/wall.bmp b/#Test/samples/halo/Shadows/wall.bmp similarity index 100% rename from _release/samples/halo/Shadows/wall.bmp rename to #Test/samples/halo/Shadows/wall.bmp diff --git a/_release/samples/halo/start.bb b/#Test/samples/halo/start.bb similarity index 100% rename from _release/samples/halo/start.bb rename to #Test/samples/halo/start.bb diff --git a/_release/samples/mak/anim/anim.bb b/#Test/samples/mak/anim/anim.bb similarity index 100% rename from _release/samples/mak/anim/anim.bb rename to #Test/samples/mak/anim/anim.bb diff --git a/_release/samples/mak/anim/makbot/MAK-sfx.bb b/#Test/samples/mak/anim/makbot/MAK-sfx.bb similarity index 100% rename from _release/samples/mak/anim/makbot/MAK-sfx.bb rename to #Test/samples/mak/anim/makbot/MAK-sfx.bb diff --git a/_release/samples/mak/anim/makbot/Panels.jpg b/#Test/samples/mak/anim/makbot/Panels.jpg similarity index 100% rename from _release/samples/mak/anim/makbot/Panels.jpg rename to #Test/samples/mak/anim/makbot/Panels.jpg diff --git a/_release/samples/mak/anim/makbot/README.txt b/#Test/samples/mak/anim/makbot/README.txt similarity index 100% rename from _release/samples/mak/anim/makbot/README.txt rename to #Test/samples/mak/anim/makbot/README.txt diff --git a/_release/samples/mak/anim/makbot/blshine.jpg b/#Test/samples/mak/anim/makbot/blshine.jpg similarity index 100% rename from _release/samples/mak/anim/makbot/blshine.jpg rename to #Test/samples/mak/anim/makbot/blshine.jpg diff --git a/_release/samples/mak/anim/makbot/dkshine.jpg b/#Test/samples/mak/anim/makbot/dkshine.jpg similarity index 100% rename from _release/samples/mak/anim/makbot/dkshine.jpg rename to #Test/samples/mak/anim/makbot/dkshine.jpg diff --git a/_release/samples/mak/anim/makbot/flare.bmp b/#Test/samples/mak/anim/makbot/flare.bmp similarity index 100% rename from _release/samples/mak/anim/makbot/flare.bmp rename to #Test/samples/mak/anim/makbot/flare.bmp diff --git a/_release/samples/mak/anim/makbot/mak_robotic.3DS b/#Test/samples/mak/anim/makbot/mak_robotic.3DS similarity index 100% rename from _release/samples/mak/anim/makbot/mak_robotic.3DS rename to #Test/samples/mak/anim/makbot/mak_robotic.3DS diff --git a/_release/samples/mak/anim/makbot/mak_robotic.x b/#Test/samples/mak/anim/makbot/mak_robotic.x similarity index 100% rename from _release/samples/mak/anim/makbot/mak_robotic.x rename to #Test/samples/mak/anim/makbot/mak_robotic.x diff --git a/_release/samples/mak/anim/makbot/mak_running.3DS b/#Test/samples/mak/anim/makbot/mak_running.3DS similarity index 100% rename from _release/samples/mak/anim/makbot/mak_running.3DS rename to #Test/samples/mak/anim/makbot/mak_running.3DS diff --git a/_release/samples/mak/anim/makbot/mak_running.x b/#Test/samples/mak/anim/makbot/mak_running.x similarity index 100% rename from _release/samples/mak/anim/makbot/mak_running.x rename to #Test/samples/mak/anim/makbot/mak_running.x diff --git a/_release/samples/mak/b3dlogo.jpg b/#Test/samples/mak/b3dlogo.jpg similarity index 100% rename from _release/samples/mak/b3dlogo.jpg rename to #Test/samples/mak/b3dlogo.jpg diff --git a/_release/samples/mak/castle/castle.bb b/#Test/samples/mak/castle/castle.bb similarity index 100% rename from _release/samples/mak/castle/castle.bb rename to #Test/samples/mak/castle/castle.bb diff --git a/_release/samples/mak/castle/castle/CASTLE1.X b/#Test/samples/mak/castle/castle/CASTLE1.X similarity index 100% rename from _release/samples/mak/castle/castle/CASTLE1.X rename to #Test/samples/mak/castle/castle/CASTLE1.X diff --git a/_release/samples/mak/castle/castle/castlest.jpg b/#Test/samples/mak/castle/castle/castlest.jpg similarity index 100% rename from _release/samples/mak/castle/castle/castlest.jpg rename to #Test/samples/mak/castle/castle/castlest.jpg diff --git a/_release/samples/mak/castle/castle/gothic3.jpg b/#Test/samples/mak/castle/castle/gothic3.jpg similarity index 100% rename from _release/samples/mak/castle/castle/gothic3.jpg rename to #Test/samples/mak/castle/castle/gothic3.jpg diff --git a/_release/samples/mak/castle/castle/oldbric.jpg b/#Test/samples/mak/castle/castle/oldbric.jpg similarity index 100% rename from _release/samples/mak/castle/castle/oldbric.jpg rename to #Test/samples/mak/castle/castle/oldbric.jpg diff --git a/_release/samples/mak/castle/castle/shingle.jpg b/#Test/samples/mak/castle/castle/shingle.jpg similarity index 100% rename from _release/samples/mak/castle/castle/shingle.jpg rename to #Test/samples/mak/castle/castle/shingle.jpg diff --git a/_release/samples/mak/castle/castle/stone2.jpg b/#Test/samples/mak/castle/castle/stone2.jpg similarity index 100% rename from _release/samples/mak/castle/castle/stone2.jpg rename to #Test/samples/mak/castle/castle/stone2.jpg diff --git a/_release/samples/mak/castle/environ/Water-2_mip.BMP b/#Test/samples/mak/castle/environ/Water-2_mip.BMP similarity index 100% rename from _release/samples/mak/castle/environ/Water-2_mip.BMP rename to #Test/samples/mak/castle/environ/Water-2_mip.BMP diff --git a/_release/samples/mak/castle/environ/heightmap_256.BMP b/#Test/samples/mak/castle/environ/heightmap_256.BMP similarity index 100% rename from _release/samples/mak/castle/environ/heightmap_256.BMP rename to #Test/samples/mak/castle/environ/heightmap_256.BMP diff --git a/_release/samples/mak/castle/environ/sky_BK.jpg b/#Test/samples/mak/castle/environ/sky_BK.jpg similarity index 100% rename from _release/samples/mak/castle/environ/sky_BK.jpg rename to #Test/samples/mak/castle/environ/sky_BK.jpg diff --git a/_release/samples/mak/castle/environ/sky_DN.jpg b/#Test/samples/mak/castle/environ/sky_DN.jpg similarity index 100% rename from _release/samples/mak/castle/environ/sky_DN.jpg rename to #Test/samples/mak/castle/environ/sky_DN.jpg diff --git a/_release/samples/mak/castle/environ/sky_FR.jpg b/#Test/samples/mak/castle/environ/sky_FR.jpg similarity index 100% rename from _release/samples/mak/castle/environ/sky_FR.jpg rename to #Test/samples/mak/castle/environ/sky_FR.jpg diff --git a/_release/samples/mak/castle/environ/sky_LF.jpg b/#Test/samples/mak/castle/environ/sky_LF.jpg similarity index 100% rename from _release/samples/mak/castle/environ/sky_LF.jpg rename to #Test/samples/mak/castle/environ/sky_LF.jpg diff --git a/_release/samples/mak/castle/environ/sky_RT.jpg b/#Test/samples/mak/castle/environ/sky_RT.jpg similarity index 100% rename from _release/samples/mak/castle/environ/sky_RT.jpg rename to #Test/samples/mak/castle/environ/sky_RT.jpg diff --git a/_release/samples/mak/castle/environ/sky_UP.jpg b/#Test/samples/mak/castle/environ/sky_UP.jpg similarity index 100% rename from _release/samples/mak/castle/environ/sky_UP.jpg rename to #Test/samples/mak/castle/environ/sky_UP.jpg diff --git a/_release/samples/mak/castle/environ/terrain-1.jpg b/#Test/samples/mak/castle/environ/terrain-1.jpg similarity index 100% rename from _release/samples/mak/castle/environ/terrain-1.jpg rename to #Test/samples/mak/castle/environ/terrain-1.jpg diff --git a/_release/samples/mak/castle/markio/blue.bmp b/#Test/samples/mak/castle/markio/blue.bmp similarity index 100% rename from _release/samples/mak/castle/markio/blue.bmp rename to #Test/samples/mak/castle/markio/blue.bmp diff --git a/_release/samples/mak/castle/markio/brown.bmp b/#Test/samples/mak/castle/markio/brown.bmp similarity index 100% rename from _release/samples/mak/castle/markio/brown.bmp rename to #Test/samples/mak/castle/markio/brown.bmp diff --git a/_release/samples/mak/castle/markio/face.bmp b/#Test/samples/mak/castle/markio/face.bmp similarity index 100% rename from _release/samples/mak/castle/markio/face.bmp rename to #Test/samples/mak/castle/markio/face.bmp diff --git a/_release/samples/mak/castle/markio/hatM.bmp b/#Test/samples/mak/castle/markio/hatM.bmp similarity index 100% rename from _release/samples/mak/castle/markio/hatM.bmp rename to #Test/samples/mak/castle/markio/hatM.bmp diff --git a/_release/samples/mak/castle/markio/mariorun.x b/#Test/samples/mak/castle/markio/mariorun.x similarity index 100% rename from _release/samples/mak/castle/markio/mariorun.x rename to #Test/samples/mak/castle/markio/mariorun.x diff --git a/_release/samples/mak/castle/markio/red.bmp b/#Test/samples/mak/castle/markio/red.bmp similarity index 100% rename from _release/samples/mak/castle/markio/red.bmp rename to #Test/samples/mak/castle/markio/red.bmp diff --git a/_release/samples/mak/castle/sounds/boom.wav b/#Test/samples/mak/castle/sounds/boom.wav similarity index 100% rename from _release/samples/mak/castle/sounds/boom.wav rename to #Test/samples/mak/castle/sounds/boom.wav diff --git a/_release/samples/mak/castle/sounds/shoot.wav b/#Test/samples/mak/castle/sounds/shoot.wav similarity index 100% rename from _release/samples/mak/castle/sounds/shoot.wav rename to #Test/samples/mak/castle/sounds/shoot.wav diff --git a/_release/samples/mak/castle/sprites/Bigspark.BMP b/#Test/samples/mak/castle/sprites/Bigspark.BMP similarity index 100% rename from _release/samples/mak/castle/sprites/Bigspark.BMP rename to #Test/samples/mak/castle/sprites/Bigspark.BMP diff --git a/_release/samples/mak/castle/sprites/bluspark.BMP b/#Test/samples/mak/castle/sprites/bluspark.BMP similarity index 100% rename from _release/samples/mak/castle/sprites/bluspark.BMP rename to #Test/samples/mak/castle/sprites/bluspark.BMP diff --git a/_release/samples/mak/castle/sprites/bullet_hole.BMP b/#Test/samples/mak/castle/sprites/bullet_hole.BMP similarity index 100% rename from _release/samples/mak/castle/sprites/bullet_hole.BMP rename to #Test/samples/mak/castle/sprites/bullet_hole.BMP diff --git a/_release/samples/mak/castle/sprites/tree.BMP b/#Test/samples/mak/castle/sprites/tree.BMP similarity index 100% rename from _release/samples/mak/castle/sprites/tree.BMP rename to #Test/samples/mak/castle/sprites/tree.BMP diff --git a/_release/samples/mak/collide/collide.bb b/#Test/samples/mak/collide/collide.bb similarity index 100% rename from _release/samples/mak/collide/collide.bb rename to #Test/samples/mak/collide/collide.bb diff --git a/_release/samples/mak/createanim/createanim.bb b/#Test/samples/mak/createanim/createanim.bb similarity index 100% rename from _release/samples/mak/createanim/createanim.bb rename to #Test/samples/mak/createanim/createanim.bb diff --git a/_release/samples/mak/detailtex/detail2.JPG b/#Test/samples/mak/detailtex/detail2.JPG similarity index 100% rename from _release/samples/mak/detailtex/detail2.JPG rename to #Test/samples/mak/detailtex/detail2.JPG diff --git a/_release/samples/mak/detailtex/detailtex.bb b/#Test/samples/mak/detailtex/detailtex.bb similarity index 100% rename from _release/samples/mak/detailtex/detailtex.bb rename to #Test/samples/mak/detailtex/detailtex.bb diff --git a/_release/samples/mak/detailtex/texture.JPG b/#Test/samples/mak/detailtex/texture.JPG similarity index 100% rename from _release/samples/mak/detailtex/texture.JPG rename to #Test/samples/mak/detailtex/texture.JPG diff --git a/_release/samples/mak/dragon/Chorme-2.BMP b/#Test/samples/mak/dragon/Chorme-2.BMP similarity index 100% rename from _release/samples/mak/dragon/Chorme-2.BMP rename to #Test/samples/mak/dragon/Chorme-2.BMP diff --git a/_release/samples/mak/dragon/dragon.bb b/#Test/samples/mak/dragon/dragon.bb similarity index 100% rename from _release/samples/mak/dragon/dragon.bb rename to #Test/samples/mak/dragon/dragon.bb diff --git a/_release/samples/mak/dragon/model/dragon.bmp b/#Test/samples/mak/dragon/model/dragon.bmp similarity index 100% rename from _release/samples/mak/dragon/model/dragon.bmp rename to #Test/samples/mak/dragon/model/dragon.bmp diff --git a/_release/samples/mak/dragon/model/dragon.md2 b/#Test/samples/mak/dragon/model/dragon.md2 similarity index 100% rename from _release/samples/mak/dragon/model/dragon.md2 rename to #Test/samples/mak/dragon/model/dragon.md2 diff --git a/_release/samples/mak/driver/car.x b/#Test/samples/mak/driver/car.x similarity index 100% rename from _release/samples/mak/driver/car.x rename to #Test/samples/mak/driver/car.x diff --git a/_release/samples/mak/driver/driver.bb b/#Test/samples/mak/driver/driver.bb similarity index 100% rename from _release/samples/mak/driver/driver.bb rename to #Test/samples/mak/driver/driver.bb diff --git a/_release/samples/mak/driver/heightmap_256.BMP b/#Test/samples/mak/driver/heightmap_256.BMP similarity index 100% rename from _release/samples/mak/driver/heightmap_256.BMP rename to #Test/samples/mak/driver/heightmap_256.BMP diff --git a/_release/samples/mak/driver/terrain-1.jpg b/#Test/samples/mak/driver/terrain-1.jpg similarity index 100% rename from _release/samples/mak/driver/terrain-1.jpg rename to #Test/samples/mak/driver/terrain-1.jpg diff --git a/_release/samples/mak/fakelight/brick.bmp b/#Test/samples/mak/fakelight/brick.bmp similarity index 100% rename from _release/samples/mak/fakelight/brick.bmp rename to #Test/samples/mak/fakelight/brick.bmp diff --git a/_release/samples/mak/fakelight/fakelight.bb b/#Test/samples/mak/fakelight/fakelight.bb similarity index 100% rename from _release/samples/mak/fakelight/fakelight.bb rename to #Test/samples/mak/fakelight/fakelight.bb diff --git a/_release/samples/mak/firepaint3d/blitzlogo.bmp b/#Test/samples/mak/firepaint3d/blitzlogo.bmp similarity index 100% rename from _release/samples/mak/firepaint3d/blitzlogo.bmp rename to #Test/samples/mak/firepaint3d/blitzlogo.bmp diff --git a/_release/samples/mak/firepaint3d/bluspark.bmp b/#Test/samples/mak/firepaint3d/bluspark.bmp similarity index 100% rename from _release/samples/mak/firepaint3d/bluspark.bmp rename to #Test/samples/mak/firepaint3d/bluspark.bmp diff --git a/_release/samples/mak/firepaint3d/firepaint3d.bb b/#Test/samples/mak/firepaint3d/firepaint3d.bb similarity index 100% rename from _release/samples/mak/firepaint3d/firepaint3d.bb rename to #Test/samples/mak/firepaint3d/firepaint3d.bb diff --git a/_release/samples/mak/firepaint3d/stars.bmp b/#Test/samples/mak/firepaint3d/stars.bmp similarity index 100% rename from _release/samples/mak/firepaint3d/stars.bmp rename to #Test/samples/mak/firepaint3d/stars.bmp diff --git a/_release/samples/mak/flag/b3dlogo.jpg b/#Test/samples/mak/flag/b3dlogo.jpg similarity index 100% rename from _release/samples/mak/flag/b3dlogo.jpg rename to #Test/samples/mak/flag/b3dlogo.jpg diff --git a/_release/samples/mak/flag/flag.bb b/#Test/samples/mak/flag/flag.bb similarity index 100% rename from _release/samples/mak/flag/flag.bb rename to #Test/samples/mak/flag/flag.bb diff --git a/_release/samples/mak/insaner/CrackedStone.BMP b/#Test/samples/mak/insaner/CrackedStone.BMP similarity index 100% rename from _release/samples/mak/insaner/CrackedStone.BMP rename to #Test/samples/mak/insaner/CrackedStone.BMP diff --git a/_release/samples/mak/insaner/CrackedStone_diff.BMP b/#Test/samples/mak/insaner/CrackedStone_diff.BMP similarity index 100% rename from _release/samples/mak/insaner/CrackedStone_diff.BMP rename to #Test/samples/mak/insaner/CrackedStone_diff.BMP diff --git a/_release/samples/mak/insaner/MossyGround.BMP b/#Test/samples/mak/insaner/MossyGround.BMP similarity index 100% rename from _release/samples/mak/insaner/MossyGround.BMP rename to #Test/samples/mak/insaner/MossyGround.BMP diff --git a/_release/samples/mak/insaner/hmap.BMP b/#Test/samples/mak/insaner/hmap.BMP similarity index 100% rename from _release/samples/mak/insaner/hmap.BMP rename to #Test/samples/mak/insaner/hmap.BMP diff --git a/_release/samples/mak/insaner/hmap_1024.BMP b/#Test/samples/mak/insaner/hmap_1024.BMP similarity index 100% rename from _release/samples/mak/insaner/hmap_1024.BMP rename to #Test/samples/mak/insaner/hmap_1024.BMP diff --git a/_release/samples/mak/insaner/insaner.bb b/#Test/samples/mak/insaner/insaner.bb similarity index 100% rename from _release/samples/mak/insaner/insaner.bb rename to #Test/samples/mak/insaner/insaner.bb diff --git a/_release/samples/mak/insaner/lmap.BMP b/#Test/samples/mak/insaner/lmap.BMP similarity index 100% rename from _release/samples/mak/insaner/lmap.BMP rename to #Test/samples/mak/insaner/lmap.BMP diff --git a/_release/samples/mak/insaner/lmap_1024.BMP b/#Test/samples/mak/insaner/lmap_1024.BMP similarity index 100% rename from _release/samples/mak/insaner/lmap_1024.BMP rename to #Test/samples/mak/insaner/lmap_1024.BMP diff --git a/_release/samples/mak/insaner/track.BMP b/#Test/samples/mak/insaner/track.BMP similarity index 100% rename from _release/samples/mak/insaner/track.BMP rename to #Test/samples/mak/insaner/track.BMP diff --git a/_release/samples/mak/insectoids/graphics/alien.bmp b/#Test/samples/mak/insectoids/graphics/alien.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/alien.bmp rename to #Test/samples/mak/insectoids/graphics/alien.bmp diff --git a/_release/samples/mak/insectoids/graphics/ball.bmp b/#Test/samples/mak/insectoids/graphics/ball.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/ball.bmp rename to #Test/samples/mak/insectoids/graphics/ball.bmp diff --git a/_release/samples/mak/insectoids/graphics/bang.bmp b/#Test/samples/mak/insectoids/graphics/bang.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/bang.bmp rename to #Test/samples/mak/insectoids/graphics/bang.bmp diff --git a/_release/samples/mak/insectoids/graphics/bat.bmp b/#Test/samples/mak/insectoids/graphics/bat.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/bat.bmp rename to #Test/samples/mak/insectoids/graphics/bat.bmp diff --git a/_release/samples/mak/insectoids/graphics/bbomb.bmp b/#Test/samples/mak/insectoids/graphics/bbomb.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/bbomb.bmp rename to #Test/samples/mak/insectoids/graphics/bbomb.bmp diff --git a/_release/samples/mak/insectoids/graphics/bomb.bmp b/#Test/samples/mak/insectoids/graphics/bomb.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/bomb.bmp rename to #Test/samples/mak/insectoids/graphics/bomb.bmp diff --git a/_release/samples/mak/insectoids/graphics/bullet.bmp b/#Test/samples/mak/insectoids/graphics/bullet.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/bullet.bmp rename to #Test/samples/mak/insectoids/graphics/bullet.bmp diff --git a/_release/samples/mak/insectoids/graphics/bullet_mask.bmp b/#Test/samples/mak/insectoids/graphics/bullet_mask.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/bullet_mask.bmp rename to #Test/samples/mak/insectoids/graphics/bullet_mask.bmp diff --git a/_release/samples/mak/insectoids/graphics/dir.bmp b/#Test/samples/mak/insectoids/graphics/dir.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/dir.bmp rename to #Test/samples/mak/insectoids/graphics/dir.bmp diff --git a/_release/samples/mak/insectoids/graphics/disc.bmp b/#Test/samples/mak/insectoids/graphics/disc.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/disc.bmp rename to #Test/samples/mak/insectoids/graphics/disc.bmp diff --git a/_release/samples/mak/insectoids/graphics/file.bmp b/#Test/samples/mak/insectoids/graphics/file.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/file.bmp rename to #Test/samples/mak/insectoids/graphics/file.bmp diff --git a/_release/samples/mak/insectoids/graphics/insectoids_logo.bmp b/#Test/samples/mak/insectoids/graphics/insectoids_logo.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/insectoids_logo.bmp rename to #Test/samples/mak/insectoids/graphics/insectoids_logo.bmp diff --git a/_release/samples/mak/insectoids/graphics/kaboom.bmp b/#Test/samples/mak/insectoids/graphics/kaboom.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/kaboom.bmp rename to #Test/samples/mak/insectoids/graphics/kaboom.bmp diff --git a/_release/samples/mak/insectoids/graphics/player.bmp b/#Test/samples/mak/insectoids/graphics/player.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/player.bmp rename to #Test/samples/mak/insectoids/graphics/player.bmp diff --git a/_release/samples/mak/insectoids/graphics/pointer.bmp b/#Test/samples/mak/insectoids/graphics/pointer.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/pointer.bmp rename to #Test/samples/mak/insectoids/graphics/pointer.bmp diff --git a/_release/samples/mak/insectoids/graphics/ship1.bmp b/#Test/samples/mak/insectoids/graphics/ship1.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/ship1.bmp rename to #Test/samples/mak/insectoids/graphics/ship1.bmp diff --git a/_release/samples/mak/insectoids/graphics/spark.bmp b/#Test/samples/mak/insectoids/graphics/spark.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/spark.bmp rename to #Test/samples/mak/insectoids/graphics/spark.bmp diff --git a/_release/samples/mak/insectoids/graphics/star1.bmp b/#Test/samples/mak/insectoids/graphics/star1.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/star1.bmp rename to #Test/samples/mak/insectoids/graphics/star1.bmp diff --git a/_release/samples/mak/insectoids/graphics/star2.bmp b/#Test/samples/mak/insectoids/graphics/star2.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/star2.bmp rename to #Test/samples/mak/insectoids/graphics/star2.bmp diff --git a/_release/samples/mak/insectoids/graphics/star3.bmp b/#Test/samples/mak/insectoids/graphics/star3.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/star3.bmp rename to #Test/samples/mak/insectoids/graphics/star3.bmp diff --git a/_release/samples/mak/insectoids/graphics/stars.bmp b/#Test/samples/mak/insectoids/graphics/stars.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/stars.bmp rename to #Test/samples/mak/insectoids/graphics/stars.bmp diff --git a/_release/samples/mak/insectoids/graphics/starsfar.bmp b/#Test/samples/mak/insectoids/graphics/starsfar.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/starsfar.bmp rename to #Test/samples/mak/insectoids/graphics/starsfar.bmp diff --git a/_release/samples/mak/insectoids/graphics/starsmid.bmp b/#Test/samples/mak/insectoids/graphics/starsmid.bmp similarity index 100% rename from _release/samples/mak/insectoids/graphics/starsmid.bmp rename to #Test/samples/mak/insectoids/graphics/starsmid.bmp diff --git a/_release/samples/mak/insectoids/insectoids.bb b/#Test/samples/mak/insectoids/insectoids.bb similarity index 100% rename from _release/samples/mak/insectoids/insectoids.bb rename to #Test/samples/mak/insectoids/insectoids.bb diff --git a/_release/samples/mak/insectoids/sounds/beep.wav b/#Test/samples/mak/insectoids/sounds/beep.wav similarity index 100% rename from _release/samples/mak/insectoids/sounds/beep.wav rename to #Test/samples/mak/insectoids/sounds/beep.wav diff --git a/_release/samples/mak/insectoids/sounds/beeplow.wav b/#Test/samples/mak/insectoids/sounds/beeplow.wav similarity index 100% rename from _release/samples/mak/insectoids/sounds/beeplow.wav rename to #Test/samples/mak/insectoids/sounds/beeplow.wav diff --git a/_release/samples/mak/insectoids/sounds/boom.wav b/#Test/samples/mak/insectoids/sounds/boom.wav similarity index 100% rename from _release/samples/mak/insectoids/sounds/boom.wav rename to #Test/samples/mak/insectoids/sounds/boom.wav diff --git a/_release/samples/mak/insectoids/sounds/buzz.wav b/#Test/samples/mak/insectoids/sounds/buzz.wav similarity index 100% rename from _release/samples/mak/insectoids/sounds/buzz.wav rename to #Test/samples/mak/insectoids/sounds/buzz.wav diff --git a/_release/samples/mak/insectoids/sounds/cool.wav b/#Test/samples/mak/insectoids/sounds/cool.wav similarity index 100% rename from _release/samples/mak/insectoids/sounds/cool.wav rename to #Test/samples/mak/insectoids/sounds/cool.wav diff --git a/_release/samples/mak/insectoids/sounds/kazap.wav b/#Test/samples/mak/insectoids/sounds/kazap.wav similarity index 100% rename from _release/samples/mak/insectoids/sounds/kazap.wav rename to #Test/samples/mak/insectoids/sounds/kazap.wav diff --git a/_release/samples/mak/insectoids/sounds/mtruc.wav b/#Test/samples/mak/insectoids/sounds/mtruc.wav similarity index 100% rename from _release/samples/mak/insectoids/sounds/mtruc.wav rename to #Test/samples/mak/insectoids/sounds/mtruc.wav diff --git a/_release/samples/mak/insectoids/sounds/shoot.wav b/#Test/samples/mak/insectoids/sounds/shoot.wav similarity index 100% rename from _release/samples/mak/insectoids/sounds/shoot.wav rename to #Test/samples/mak/insectoids/sounds/shoot.wav diff --git a/_release/samples/mak/lights/lights.bb b/#Test/samples/mak/lights/lights.bb similarity index 100% rename from _release/samples/mak/lights/lights.bb rename to #Test/samples/mak/lights/lights.bb diff --git a/_release/samples/mak/multi_tex/blitzlogo.bmp b/#Test/samples/mak/multi_tex/blitzlogo.bmp similarity index 100% rename from _release/samples/mak/multi_tex/blitzlogo.bmp rename to #Test/samples/mak/multi_tex/blitzlogo.bmp diff --git a/_release/samples/mak/multi_tex/multi_tex.bb b/#Test/samples/mak/multi_tex/multi_tex.bb similarity index 100% rename from _release/samples/mak/multi_tex/multi_tex.bb rename to #Test/samples/mak/multi_tex/multi_tex.bb diff --git a/_release/samples/mak/multi_tex/spheremap.bmp b/#Test/samples/mak/multi_tex/spheremap.bmp similarity index 100% rename from _release/samples/mak/multi_tex/spheremap.bmp rename to #Test/samples/mak/multi_tex/spheremap.bmp diff --git a/_release/samples/mak/multicam/multicam.bb b/#Test/samples/mak/multicam/multicam.bb similarity index 100% rename from _release/samples/mak/multicam/multicam.bb rename to #Test/samples/mak/multicam/multicam.bb diff --git a/_release/samples/mak/pick/pick.bb b/#Test/samples/mak/pick/pick.bb similarity index 100% rename from _release/samples/mak/pick/pick.bb rename to #Test/samples/mak/pick/pick.bb diff --git a/_release/samples/mak/primitives/primitives.bb b/#Test/samples/mak/primitives/primitives.bb similarity index 100% rename from _release/samples/mak/primitives/primitives.bb rename to #Test/samples/mak/primitives/primitives.bb diff --git a/_release/samples/mak/start.bb b/#Test/samples/mak/start.bb similarity index 100% rename from _release/samples/mak/start.bb rename to #Test/samples/mak/start.bb diff --git a/_release/samples/mak/teapot/b3dlogo.jpg b/#Test/samples/mak/teapot/b3dlogo.jpg similarity index 100% rename from _release/samples/mak/teapot/b3dlogo.jpg rename to #Test/samples/mak/teapot/b3dlogo.jpg diff --git a/_release/samples/mak/teapot/blitzlogo.bmp b/#Test/samples/mak/teapot/blitzlogo.bmp similarity index 100% rename from _release/samples/mak/teapot/blitzlogo.bmp rename to #Test/samples/mak/teapot/blitzlogo.bmp diff --git a/_release/samples/mak/teapot/spheremap.bmp b/#Test/samples/mak/teapot/spheremap.bmp similarity index 100% rename from _release/samples/mak/teapot/spheremap.bmp rename to #Test/samples/mak/teapot/spheremap.bmp diff --git a/_release/samples/mak/teapot/teapot.bb b/#Test/samples/mak/teapot/teapot.bb similarity index 100% rename from _release/samples/mak/teapot/teapot.bb rename to #Test/samples/mak/teapot/teapot.bb diff --git a/_release/samples/mak/teapot/teapot.x b/#Test/samples/mak/teapot/teapot.x similarity index 100% rename from _release/samples/mak/teapot/teapot.x rename to #Test/samples/mak/teapot/teapot.x diff --git a/_release/samples/mak/tex_render/b3dlogo.jpg b/#Test/samples/mak/tex_render/b3dlogo.jpg similarity index 100% rename from _release/samples/mak/tex_render/b3dlogo.jpg rename to #Test/samples/mak/tex_render/b3dlogo.jpg diff --git a/_release/samples/mak/tex_render/tex_render.bb b/#Test/samples/mak/tex_render/tex_render.bb similarity index 100% rename from _release/samples/mak/tex_render/tex_render.bb rename to #Test/samples/mak/tex_render/tex_render.bb diff --git a/_release/samples/mak/tron/b3dlogo.jpg b/#Test/samples/mak/tron/b3dlogo.jpg similarity index 100% rename from _release/samples/mak/tron/b3dlogo.jpg rename to #Test/samples/mak/tron/b3dlogo.jpg diff --git a/_release/samples/mak/tron/tron.bb b/#Test/samples/mak/tron/tron.bb similarity index 100% rename from _release/samples/mak/tron/tron.bb rename to #Test/samples/mak/tron/tron.bb diff --git a/_release/samples/mak/xfighter/Water-2_mip.BMP b/#Test/samples/mak/xfighter/Water-2_mip.BMP similarity index 100% rename from _release/samples/mak/xfighter/Water-2_mip.BMP rename to #Test/samples/mak/xfighter/Water-2_mip.BMP diff --git a/_release/samples/mak/xfighter/bihull.bmp b/#Test/samples/mak/xfighter/bihull.bmp similarity index 100% rename from _release/samples/mak/xfighter/bihull.bmp rename to #Test/samples/mak/xfighter/bihull.bmp diff --git a/_release/samples/mak/xfighter/biplane.x b/#Test/samples/mak/xfighter/biplane.x similarity index 100% rename from _release/samples/mak/xfighter/biplane.x rename to #Test/samples/mak/xfighter/biplane.x diff --git a/_release/samples/mak/xfighter/cloud_2.BMP b/#Test/samples/mak/xfighter/cloud_2.BMP similarity index 100% rename from _release/samples/mak/xfighter/cloud_2.BMP rename to #Test/samples/mak/xfighter/cloud_2.BMP diff --git a/_release/samples/mak/xfighter/coolgrass2.BMP b/#Test/samples/mak/xfighter/coolgrass2.BMP similarity index 100% rename from _release/samples/mak/xfighter/coolgrass2.BMP rename to #Test/samples/mak/xfighter/coolgrass2.BMP diff --git a/_release/samples/mak/xfighter/hmap_1024.BMP b/#Test/samples/mak/xfighter/hmap_1024.BMP similarity index 100% rename from _release/samples/mak/xfighter/hmap_1024.BMP rename to #Test/samples/mak/xfighter/hmap_1024.BMP diff --git a/_release/samples/mak/xfighter/lmap_256.BMP b/#Test/samples/mak/xfighter/lmap_256.BMP similarity index 100% rename from _release/samples/mak/xfighter/lmap_256.BMP rename to #Test/samples/mak/xfighter/lmap_256.BMP diff --git a/_release/samples/mak/xfighter/wings.bmp b/#Test/samples/mak/xfighter/wings.bmp similarity index 100% rename from _release/samples/mak/xfighter/wings.bmp rename to #Test/samples/mak/xfighter/wings.bmp diff --git a/_release/samples/mak/xfighter/xfighter.bb b/#Test/samples/mak/xfighter/xfighter.bb similarity index 100% rename from _release/samples/mak/xfighter/xfighter.bb rename to #Test/samples/mak/xfighter/xfighter.bb diff --git a/_release/samples/si/fps/Bigspark.BMP b/#Test/samples/si/fps/Bigspark.BMP similarity index 100% rename from _release/samples/si/fps/Bigspark.BMP rename to #Test/samples/si/fps/Bigspark.BMP diff --git a/_release/samples/si/fps/Gargoyle/Gargoyle.bmp b/#Test/samples/si/fps/Gargoyle/Gargoyle.bmp similarity index 100% rename from _release/samples/si/fps/Gargoyle/Gargoyle.bmp rename to #Test/samples/si/fps/Gargoyle/Gargoyle.bmp diff --git a/_release/samples/si/fps/Gargoyle/Gargoyle.md2 b/#Test/samples/si/fps/Gargoyle/Gargoyle.md2 similarity index 100% rename from _release/samples/si/fps/Gargoyle/Gargoyle.md2 rename to #Test/samples/si/fps/Gargoyle/Gargoyle.md2 diff --git a/_release/samples/si/fps/Gargoyle/GargoyleSkin.PCX b/#Test/samples/si/fps/Gargoyle/GargoyleSkin.PCX similarity index 100% rename from _release/samples/si/fps/Gargoyle/GargoyleSkin.PCX rename to #Test/samples/si/fps/Gargoyle/GargoyleSkin.PCX diff --git a/_release/samples/si/fps/Stone_grey1.bmp b/#Test/samples/si/fps/Stone_grey1.bmp similarity index 100% rename from _release/samples/si/fps/Stone_grey1.bmp rename to #Test/samples/si/fps/Stone_grey1.bmp diff --git a/_release/samples/si/fps/blood.bmp b/#Test/samples/si/fps/blood.bmp similarity index 100% rename from _release/samples/si/fps/blood.bmp rename to #Test/samples/si/fps/blood.bmp diff --git a/_release/samples/si/fps/fps.bb b/#Test/samples/si/fps/fps.bb similarity index 100% rename from _release/samples/si/fps/fps.bb rename to #Test/samples/si/fps/fps.bb diff --git a/_release/samples/si/fps/gunshot.wav b/#Test/samples/si/fps/gunshot.wav similarity index 100% rename from _release/samples/si/fps/gunshot.wav rename to #Test/samples/si/fps/gunshot.wav diff --git a/_release/samples/si/fps/interior.X b/#Test/samples/si/fps/interior.X similarity index 100% rename from _release/samples/si/fps/interior.X rename to #Test/samples/si/fps/interior.X diff --git a/_release/samples/si/fps/ladders.BMP b/#Test/samples/si/fps/ladders.BMP similarity index 100% rename from _release/samples/si/fps/ladders.BMP rename to #Test/samples/si/fps/ladders.BMP diff --git a/_release/samples/si/fps/ladders.X b/#Test/samples/si/fps/ladders.X similarity index 100% rename from _release/samples/si/fps/ladders.X rename to #Test/samples/si/fps/ladders.X diff --git a/_release/samples/si/fps/squish.wav b/#Test/samples/si/fps/squish.wav similarity index 100% rename from _release/samples/si/fps/squish.wav rename to #Test/samples/si/fps/squish.wav diff --git a/_release/samples/si/fps/stone_blue1.bmp b/#Test/samples/si/fps/stone_blue1.bmp similarity index 100% rename from _release/samples/si/fps/stone_blue1.bmp rename to #Test/samples/si/fps/stone_blue1.bmp diff --git a/_release/samples/si/fps/stone_red1.bmp b/#Test/samples/si/fps/stone_red1.bmp similarity index 100% rename from _release/samples/si/fps/stone_red1.bmp rename to #Test/samples/si/fps/stone_red1.bmp diff --git a/_release/samples/si/fps/stone_yellow1.bmp b/#Test/samples/si/fps/stone_yellow1.bmp similarity index 100% rename from _release/samples/si/fps/stone_yellow1.bmp rename to #Test/samples/si/fps/stone_yellow1.bmp diff --git a/_release/samples/si/fps/target.bmp b/#Test/samples/si/fps/target.bmp similarity index 100% rename from _release/samples/si/fps/target.bmp rename to #Test/samples/si/fps/target.bmp diff --git a/_release/samples/si/matrix/command_ref.bb b/#Test/samples/si/matrix/command_ref.bb similarity index 100% rename from _release/samples/si/matrix/command_ref.bb rename to #Test/samples/si/matrix/command_ref.bb diff --git a/_release/samples/si/matrix/example.bb b/#Test/samples/si/matrix/example.bb similarity index 100% rename from _release/samples/si/matrix/example.bb rename to #Test/samples/si/matrix/example.bb diff --git a/_release/samples/si/matrix/matrix.bb b/#Test/samples/si/matrix/matrix.bb similarity index 100% rename from _release/samples/si/matrix/matrix.bb rename to #Test/samples/si/matrix/matrix.bb diff --git a/_release/samples/si/matrix/tiles.bmp b/#Test/samples/si/matrix/tiles.bmp similarity index 100% rename from _release/samples/si/matrix/tiles.bmp rename to #Test/samples/si/matrix/tiles.bmp diff --git a/_release/samples/warpy/blitzdoc.bb b/#Test/samples/warpy/blitzdoc.bb similarity index 100% rename from _release/samples/warpy/blitzdoc.bb rename to #Test/samples/warpy/blitzdoc.bb diff --git a/_release/samples/zenith/scare/models/cb.ms3d b/#Test/samples/zenith/scare/models/cb.ms3d similarity index 100% rename from _release/samples/zenith/scare/models/cb.ms3d rename to #Test/samples/zenith/scare/models/cb.ms3d diff --git a/_release/samples/zenith/scare/models/hands/hands.ms3d b/#Test/samples/zenith/scare/models/hands/hands.ms3d similarity index 100% rename from _release/samples/zenith/scare/models/hands/hands.ms3d rename to #Test/samples/zenith/scare/models/hands/hands.ms3d diff --git a/_release/samples/zenith/scare/models/level/crate.ms3d b/#Test/samples/zenith/scare/models/level/crate.ms3d similarity index 100% rename from _release/samples/zenith/scare/models/level/crate.ms3d rename to #Test/samples/zenith/scare/models/level/crate.ms3d diff --git a/_release/samples/zenith/scare/models/level/crate.png b/#Test/samples/zenith/scare/models/level/crate.png similarity index 100% rename from _release/samples/zenith/scare/models/level/crate.png rename to #Test/samples/zenith/scare/models/level/crate.png diff --git a/_release/samples/zenith/scare/models/level/crate.x b/#Test/samples/zenith/scare/models/level/crate.x similarity index 100% rename from _release/samples/zenith/scare/models/level/crate.x rename to #Test/samples/zenith/scare/models/level/crate.x diff --git a/_release/samples/zenith/scare/models/level/level.ms3d b/#Test/samples/zenith/scare/models/level/level.ms3d similarity index 100% rename from _release/samples/zenith/scare/models/level/level.ms3d rename to #Test/samples/zenith/scare/models/level/level.ms3d diff --git a/_release/samples/zenith/scare/models/level/level.x b/#Test/samples/zenith/scare/models/level/level.x similarity index 100% rename from _release/samples/zenith/scare/models/level/level.x rename to #Test/samples/zenith/scare/models/level/level.x diff --git a/_release/samples/zenith/scare/models/level/st1.png b/#Test/samples/zenith/scare/models/level/st1.png similarity index 100% rename from _release/samples/zenith/scare/models/level/st1.png rename to #Test/samples/zenith/scare/models/level/st1.png diff --git a/_release/samples/zenith/scare/models/level/st2.png b/#Test/samples/zenith/scare/models/level/st2.png similarity index 100% rename from _release/samples/zenith/scare/models/level/st2.png rename to #Test/samples/zenith/scare/models/level/st2.png diff --git a/_release/samples/zenith/scare/models/level/wall.png b/#Test/samples/zenith/scare/models/level/wall.png similarity index 100% rename from _release/samples/zenith/scare/models/level/wall.png rename to #Test/samples/zenith/scare/models/level/wall.png diff --git a/_release/tutorials/basic_tuts/hello.bb b/#Test/samples/zenith/scare/models/pistol/Sav7115.TMP similarity index 100% rename from _release/tutorials/basic_tuts/hello.bb rename to #Test/samples/zenith/scare/models/pistol/Sav7115.TMP diff --git a/_release/samples/zenith/scare/models/pistol/g1.png b/#Test/samples/zenith/scare/models/pistol/g1.png similarity index 100% rename from _release/samples/zenith/scare/models/pistol/g1.png rename to #Test/samples/zenith/scare/models/pistol/g1.png diff --git a/_release/samples/zenith/scare/models/pistol/ghit.png b/#Test/samples/zenith/scare/models/pistol/ghit.png similarity index 100% rename from _release/samples/zenith/scare/models/pistol/ghit.png rename to #Test/samples/zenith/scare/models/pistol/ghit.png diff --git a/_release/samples/zenith/scare/models/pistol/gun.ms3d b/#Test/samples/zenith/scare/models/pistol/gun.ms3d similarity index 100% rename from _release/samples/zenith/scare/models/pistol/gun.ms3d rename to #Test/samples/zenith/scare/models/pistol/gun.ms3d diff --git a/_release/samples/zenith/scare/models/pistol/gun.png b/#Test/samples/zenith/scare/models/pistol/gun.png similarity index 100% rename from _release/samples/zenith/scare/models/pistol/gun.png rename to #Test/samples/zenith/scare/models/pistol/gun.png diff --git a/_release/samples/zenith/scare/models/pistol/hit.png b/#Test/samples/zenith/scare/models/pistol/hit.png similarity index 100% rename from _release/samples/zenith/scare/models/pistol/hit.png rename to #Test/samples/zenith/scare/models/pistol/hit.png diff --git a/_release/samples/zenith/scare/models/pistol/pistol.x b/#Test/samples/zenith/scare/models/pistol/pistol.x similarity index 100% rename from _release/samples/zenith/scare/models/pistol/pistol.x rename to #Test/samples/zenith/scare/models/pistol/pistol.x diff --git a/_release/samples/zenith/scare/models/player/guy.ms3d b/#Test/samples/zenith/scare/models/player/guy.ms3d similarity index 100% rename from _release/samples/zenith/scare/models/player/guy.ms3d rename to #Test/samples/zenith/scare/models/player/guy.ms3d diff --git a/_release/samples/zenith/scare/models/player/guy.png b/#Test/samples/zenith/scare/models/player/guy.png similarity index 100% rename from _release/samples/zenith/scare/models/player/guy.png rename to #Test/samples/zenith/scare/models/player/guy.png diff --git a/_release/samples/zenith/scare/scare.bb b/#Test/samples/zenith/scare/scare.bb similarity index 100% rename from _release/samples/zenith/scare/scare.bb rename to #Test/samples/zenith/scare/scare.bb diff --git a/_release/samples/zenith/scare/sounds/boot1.wav b/#Test/samples/zenith/scare/sounds/boot1.wav similarity index 100% rename from _release/samples/zenith/scare/sounds/boot1.wav rename to #Test/samples/zenith/scare/sounds/boot1.wav diff --git a/_release/samples/zenith/scare/sounds/boot2.wav b/#Test/samples/zenith/scare/sounds/boot2.wav similarity index 100% rename from _release/samples/zenith/scare/sounds/boot2.wav rename to #Test/samples/zenith/scare/sounds/boot2.wav diff --git a/_release/samples/zenith/scare/sounds/fall1.wav b/#Test/samples/zenith/scare/sounds/fall1.wav similarity index 100% rename from _release/samples/zenith/scare/sounds/fall1.wav rename to #Test/samples/zenith/scare/sounds/fall1.wav diff --git a/_release/samples/zenith/scare/sounds/jump1.wav b/#Test/samples/zenith/scare/sounds/jump1.wav similarity index 100% rename from _release/samples/zenith/scare/sounds/jump1.wav rename to #Test/samples/zenith/scare/sounds/jump1.wav diff --git a/_release/samples/zenith/scare/textures/gui/chat.png b/#Test/samples/zenith/scare/textures/gui/chat.png similarity index 100% rename from _release/samples/zenith/scare/textures/gui/chat.png rename to #Test/samples/zenith/scare/textures/gui/chat.png diff --git a/_release/samples/zenith/scare/textures/gui/cursors.png b/#Test/samples/zenith/scare/textures/gui/cursors.png similarity index 100% rename from _release/samples/zenith/scare/textures/gui/cursors.png rename to #Test/samples/zenith/scare/textures/gui/cursors.png diff --git a/#Test/tmp/tmp.bb b/#Test/tmp/tmp.bb new file mode 100644 index 0000000..20484c5 --- /dev/null +++ b/#Test/tmp/tmp.bb @@ -0,0 +1,16 @@ +Graphics3D 800,600,32,2 +SetBuffer BackBuffer() + +Cam = CreateCamera() +Cube = CreateCube() +MoveEntity(Cam, 0, 0, -5) + +While Not KeyHit(1) + TurnEntity Cube, 0.1, 0.1, 0.1 + + RenderWorld + Flip 0 +Wend + +EndGraphics +End \ No newline at end of file diff --git a/_release/tutorials/GCUK_Tuts/10c.jpg b/#Test/tutorials/GCUK_Tuts/10c.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/10c.jpg rename to #Test/tutorials/GCUK_Tuts/10c.jpg diff --git a/_release/tutorials/GCUK_Tuts/1c.jpg b/#Test/tutorials/GCUK_Tuts/1c.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/1c.jpg rename to #Test/tutorials/GCUK_Tuts/1c.jpg diff --git a/_release/tutorials/GCUK_Tuts/2c.jpg b/#Test/tutorials/GCUK_Tuts/2c.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/2c.jpg rename to #Test/tutorials/GCUK_Tuts/2c.jpg diff --git a/_release/tutorials/GCUK_Tuts/3c.jpg b/#Test/tutorials/GCUK_Tuts/3c.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/3c.jpg rename to #Test/tutorials/GCUK_Tuts/3c.jpg diff --git a/_release/tutorials/GCUK_Tuts/4c.jpg b/#Test/tutorials/GCUK_Tuts/4c.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/4c.jpg rename to #Test/tutorials/GCUK_Tuts/4c.jpg diff --git a/_release/tutorials/GCUK_Tuts/5c.jpg b/#Test/tutorials/GCUK_Tuts/5c.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/5c.jpg rename to #Test/tutorials/GCUK_Tuts/5c.jpg diff --git a/_release/tutorials/GCUK_Tuts/6c.jpg b/#Test/tutorials/GCUK_Tuts/6c.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/6c.jpg rename to #Test/tutorials/GCUK_Tuts/6c.jpg diff --git a/_release/tutorials/GCUK_Tuts/7c.jpg b/#Test/tutorials/GCUK_Tuts/7c.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/7c.jpg rename to #Test/tutorials/GCUK_Tuts/7c.jpg diff --git a/_release/tutorials/GCUK_Tuts/8c.jpg b/#Test/tutorials/GCUK_Tuts/8c.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/8c.jpg rename to #Test/tutorials/GCUK_Tuts/8c.jpg diff --git a/_release/tutorials/GCUK_Tuts/9c.jpg b/#Test/tutorials/GCUK_Tuts/9c.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/9c.jpg rename to #Test/tutorials/GCUK_Tuts/9c.jpg diff --git a/_release/tutorials/GCUK_Tuts/Cameras.html b/#Test/tutorials/GCUK_Tuts/Cameras.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/Cameras.html rename to #Test/tutorials/GCUK_Tuts/Cameras.html diff --git a/_release/tutorials/GCUK_Tuts/Entities.html b/#Test/tutorials/GCUK_Tuts/Entities.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/Entities.html rename to #Test/tutorials/GCUK_Tuts/Entities.html diff --git a/_release/tutorials/GCUK_Tuts/Gargoyle.md2 b/#Test/tutorials/GCUK_Tuts/Gargoyle.md2 similarity index 100% rename from _release/tutorials/GCUK_Tuts/Gargoyle.md2 rename to #Test/tutorials/GCUK_Tuts/Gargoyle.md2 diff --git a/_release/tutorials/GCUK_Tuts/Meshes.html b/#Test/tutorials/GCUK_Tuts/Meshes.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/Meshes.html rename to #Test/tutorials/GCUK_Tuts/Meshes.html diff --git a/_release/tutorials/GCUK_Tuts/Planes.html b/#Test/tutorials/GCUK_Tuts/Planes.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/Planes.html rename to #Test/tutorials/GCUK_Tuts/Planes.html diff --git a/_release/tutorials/GCUK_Tuts/Terrains.html b/#Test/tutorials/GCUK_Tuts/Terrains.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/Terrains.html rename to #Test/tutorials/GCUK_Tuts/Terrains.html diff --git a/_release/tutorials/GCUK_Tuts/Texturing.html b/#Test/tutorials/GCUK_Tuts/Texturing.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/Texturing.html rename to #Test/tutorials/GCUK_Tuts/Texturing.html diff --git a/_release/tutorials/GCUK_Tuts/animation.bb b/#Test/tutorials/GCUK_Tuts/animation.bb similarity index 100% rename from _release/tutorials/GCUK_Tuts/animation.bb rename to #Test/tutorials/GCUK_Tuts/animation.bb diff --git a/_release/tutorials/GCUK_Tuts/b3dlogo_small.jpg b/#Test/tutorials/GCUK_Tuts/b3dlogo_small.jpg similarity index 100% rename from _release/tutorials/GCUK_Tuts/b3dlogo_small.jpg rename to #Test/tutorials/GCUK_Tuts/b3dlogo_small.jpg diff --git a/_release/tutorials/GCUK_Tuts/blitztexture.bmp b/#Test/tutorials/GCUK_Tuts/blitztexture.bmp similarity index 100% rename from _release/tutorials/GCUK_Tuts/blitztexture.bmp rename to #Test/tutorials/GCUK_Tuts/blitztexture.bmp diff --git a/_release/tutorials/GCUK_Tuts/camera.bb b/#Test/tutorials/GCUK_Tuts/camera.bb similarity index 100% rename from _release/tutorials/GCUK_Tuts/camera.bb rename to #Test/tutorials/GCUK_Tuts/camera.bb diff --git a/_release/tutorials/GCUK_Tuts/collision.bb b/#Test/tutorials/GCUK_Tuts/collision.bb similarity index 100% rename from _release/tutorials/GCUK_Tuts/collision.bb rename to #Test/tutorials/GCUK_Tuts/collision.bb diff --git a/_release/tutorials/GCUK_Tuts/house.3ds b/#Test/tutorials/GCUK_Tuts/house.3ds similarity index 100% rename from _release/tutorials/GCUK_Tuts/house.3ds rename to #Test/tutorials/GCUK_Tuts/house.3ds diff --git a/_release/tutorials/GCUK_Tuts/lights.bb b/#Test/tutorials/GCUK_Tuts/lights.bb similarity index 100% rename from _release/tutorials/GCUK_Tuts/lights.bb rename to #Test/tutorials/GCUK_Tuts/lights.bb diff --git a/_release/tutorials/GCUK_Tuts/movement.bb b/#Test/tutorials/GCUK_Tuts/movement.bb similarity index 100% rename from _release/tutorials/GCUK_Tuts/movement.bb rename to #Test/tutorials/GCUK_Tuts/movement.bb diff --git a/_release/tutorials/GCUK_Tuts/page1.html b/#Test/tutorials/GCUK_Tuts/page1.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/page1.html rename to #Test/tutorials/GCUK_Tuts/page1.html diff --git a/_release/tutorials/GCUK_Tuts/page2.html b/#Test/tutorials/GCUK_Tuts/page2.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/page2.html rename to #Test/tutorials/GCUK_Tuts/page2.html diff --git a/_release/tutorials/GCUK_Tuts/page3.html b/#Test/tutorials/GCUK_Tuts/page3.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/page3.html rename to #Test/tutorials/GCUK_Tuts/page3.html diff --git a/_release/tutorials/GCUK_Tuts/page4.html b/#Test/tutorials/GCUK_Tuts/page4.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/page4.html rename to #Test/tutorials/GCUK_Tuts/page4.html diff --git a/_release/tutorials/GCUK_Tuts/page5.html b/#Test/tutorials/GCUK_Tuts/page5.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/page5.html rename to #Test/tutorials/GCUK_Tuts/page5.html diff --git a/_release/tutorials/GCUK_Tuts/page6.html b/#Test/tutorials/GCUK_Tuts/page6.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/page6.html rename to #Test/tutorials/GCUK_Tuts/page6.html diff --git a/_release/tutorials/GCUK_Tuts/page7.html b/#Test/tutorials/GCUK_Tuts/page7.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/page7.html rename to #Test/tutorials/GCUK_Tuts/page7.html diff --git a/_release/tutorials/GCUK_Tuts/page8.html b/#Test/tutorials/GCUK_Tuts/page8.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/page8.html rename to #Test/tutorials/GCUK_Tuts/page8.html diff --git a/_release/tutorials/GCUK_Tuts/plane.3ds b/#Test/tutorials/GCUK_Tuts/plane.3ds similarity index 100% rename from _release/tutorials/GCUK_Tuts/plane.3ds rename to #Test/tutorials/GCUK_Tuts/plane.3ds diff --git a/_release/tutorials/GCUK_Tuts/rocket.3ds b/#Test/tutorials/GCUK_Tuts/rocket.3ds similarity index 100% rename from _release/tutorials/GCUK_Tuts/rocket.3ds rename to #Test/tutorials/GCUK_Tuts/rocket.3ds diff --git a/_release/tutorials/GCUK_Tuts/settingup.bb b/#Test/tutorials/GCUK_Tuts/settingup.bb similarity index 100% rename from _release/tutorials/GCUK_Tuts/settingup.bb rename to #Test/tutorials/GCUK_Tuts/settingup.bb diff --git a/_release/tutorials/GCUK_Tuts/startup.html b/#Test/tutorials/GCUK_Tuts/startup.html similarity index 100% rename from _release/tutorials/GCUK_Tuts/startup.html rename to #Test/tutorials/GCUK_Tuts/startup.html diff --git a/_release/tutorials/GCUK_Tuts/texture.bb b/#Test/tutorials/GCUK_Tuts/texture.bb similarity index 100% rename from _release/tutorials/GCUK_Tuts/texture.bb rename to #Test/tutorials/GCUK_Tuts/texture.bb diff --git a/_release/tutorials/GCUK_Tuts/vertex.bb b/#Test/tutorials/GCUK_Tuts/vertex.bb similarity index 100% rename from _release/tutorials/GCUK_Tuts/vertex.bb rename to #Test/tutorials/GCUK_Tuts/vertex.bb diff --git a/_release/tutorials/basic_tuts/array.bb b/#Test/tutorials/basic_tuts/array.bb similarity index 100% rename from _release/tutorials/basic_tuts/array.bb rename to #Test/tutorials/basic_tuts/array.bb diff --git a/_release/tutorials/basic_tuts/array1.bb b/#Test/tutorials/basic_tuts/array1.bb similarity index 100% rename from _release/tutorials/basic_tuts/array1.bb rename to #Test/tutorials/basic_tuts/array1.bb diff --git a/_release/tutorials/basic_tuts/array2.bb b/#Test/tutorials/basic_tuts/array2.bb similarity index 100% rename from _release/tutorials/basic_tuts/array2.bb rename to #Test/tutorials/basic_tuts/array2.bb diff --git a/_release/tutorials/basic_tuts/basic.html b/#Test/tutorials/basic_tuts/basic.html similarity index 100% rename from _release/tutorials/basic_tuts/basic.html rename to #Test/tutorials/basic_tuts/basic.html diff --git a/_release/tutorials/basic_tuts/blitzlogo.gif b/#Test/tutorials/basic_tuts/blitzlogo.gif similarity index 100% rename from _release/tutorials/basic_tuts/blitzlogo.gif rename to #Test/tutorials/basic_tuts/blitzlogo.gif diff --git a/_release/tutorials/basic_tuts/counter.bb b/#Test/tutorials/basic_tuts/counter.bb similarity index 100% rename from _release/tutorials/basic_tuts/counter.bb rename to #Test/tutorials/basic_tuts/counter.bb diff --git a/_release/tutorials/basic_tuts/credits.html b/#Test/tutorials/basic_tuts/credits.html similarity index 100% rename from _release/tutorials/basic_tuts/credits.html rename to #Test/tutorials/basic_tuts/credits.html diff --git a/_release/tutorials/basic_tuts/doublebuffering.bb b/#Test/tutorials/basic_tuts/doublebuffering.bb similarity index 100% rename from _release/tutorials/basic_tuts/doublebuffering.bb rename to #Test/tutorials/basic_tuts/doublebuffering.bb diff --git a/_release/tutorials/basic_tuts/end if.bb b/#Test/tutorials/basic_tuts/end if.bb similarity index 100% rename from _release/tutorials/basic_tuts/end if.bb rename to #Test/tutorials/basic_tuts/end if.bb diff --git a/_release/tutorials/basic_tuts/examples.html b/#Test/tutorials/basic_tuts/examples.html similarity index 100% rename from _release/tutorials/basic_tuts/examples.html rename to #Test/tutorials/basic_tuts/examples.html diff --git a/_release/tutorials/basic_tuts/for next loop.bb b/#Test/tutorials/basic_tuts/for next loop.bb similarity index 100% rename from _release/tutorials/basic_tuts/for next loop.bb rename to #Test/tutorials/basic_tuts/for next loop.bb diff --git a/_release/tutorials/basic_tuts/game.html b/#Test/tutorials/basic_tuts/game.html similarity index 100% rename from _release/tutorials/basic_tuts/game.html rename to #Test/tutorials/basic_tuts/game.html diff --git a/_release/tutorials/basic_tuts/gettingstarted.html b/#Test/tutorials/basic_tuts/gettingstarted.html similarity index 100% rename from _release/tutorials/basic_tuts/gettingstarted.html rename to #Test/tutorials/basic_tuts/gettingstarted.html diff --git a/_release/tutorials/basic_tuts/goto.bb b/#Test/tutorials/basic_tuts/goto.bb similarity index 100% rename from _release/tutorials/basic_tuts/goto.bb rename to #Test/tutorials/basic_tuts/goto.bb diff --git a/_release/tutorials/basic_tuts/goto1.bb b/#Test/tutorials/basic_tuts/goto1.bb similarity index 100% rename from _release/tutorials/basic_tuts/goto1.bb rename to #Test/tutorials/basic_tuts/goto1.bb diff --git a/bbruntime/runtime.cpp b/#Test/tutorials/basic_tuts/hello.bb similarity index 100% rename from bbruntime/runtime.cpp rename to #Test/tutorials/basic_tuts/hello.bb diff --git a/_release/tutorials/basic_tuts/hello.gif b/#Test/tutorials/basic_tuts/hello.gif similarity index 100% rename from _release/tutorials/basic_tuts/hello.gif rename to #Test/tutorials/basic_tuts/hello.gif diff --git a/_release/tutorials/basic_tuts/hellooutput.gif b/#Test/tutorials/basic_tuts/hellooutput.gif similarity index 100% rename from _release/tutorials/basic_tuts/hellooutput.gif rename to #Test/tutorials/basic_tuts/hellooutput.gif diff --git a/_release/tutorials/basic_tuts/if then.bb b/#Test/tutorials/basic_tuts/if then.bb similarity index 100% rename from _release/tutorials/basic_tuts/if then.bb rename to #Test/tutorials/basic_tuts/if then.bb diff --git a/_release/tutorials/basic_tuts/if then1.bb b/#Test/tutorials/basic_tuts/if then1.bb similarity index 100% rename from _release/tutorials/basic_tuts/if then1.bb rename to #Test/tutorials/basic_tuts/if then1.bb diff --git a/_release/tutorials/basic_tuts/index.html b/#Test/tutorials/basic_tuts/index.html similarity index 100% rename from _release/tutorials/basic_tuts/index.html rename to #Test/tutorials/basic_tuts/index.html diff --git a/_release/tutorials/basic_tuts/input.bb b/#Test/tutorials/basic_tuts/input.bb similarity index 100% rename from _release/tutorials/basic_tuts/input.bb rename to #Test/tutorials/basic_tuts/input.bb diff --git a/_release/tutorials/basic_tuts/input1.bb b/#Test/tutorials/basic_tuts/input1.bb similarity index 100% rename from _release/tutorials/basic_tuts/input1.bb rename to #Test/tutorials/basic_tuts/input1.bb diff --git a/_release/tutorials/basic_tuts/main.html b/#Test/tutorials/basic_tuts/main.html similarity index 100% rename from _release/tutorials/basic_tuts/main.html rename to #Test/tutorials/basic_tuts/main.html diff --git a/_release/tutorials/basic_tuts/maths.bb b/#Test/tutorials/basic_tuts/maths.bb similarity index 100% rename from _release/tutorials/basic_tuts/maths.bb rename to #Test/tutorials/basic_tuts/maths.bb diff --git a/_release/tutorials/basic_tuts/print.bb b/#Test/tutorials/basic_tuts/print.bb similarity index 100% rename from _release/tutorials/basic_tuts/print.bb rename to #Test/tutorials/basic_tuts/print.bb diff --git a/_release/tutorials/basic_tuts/random numbers.bb b/#Test/tutorials/basic_tuts/random numbers.bb similarity index 100% rename from _release/tutorials/basic_tuts/random numbers.bb rename to #Test/tutorials/basic_tuts/random numbers.bb diff --git a/_release/tutorials/basic_tuts/rocket.gif b/#Test/tutorials/basic_tuts/rocket.gif similarity index 100% rename from _release/tutorials/basic_tuts/rocket.gif rename to #Test/tutorials/basic_tuts/rocket.gif diff --git a/_release/tutorials/basic_tuts/simple maths.bb b/#Test/tutorials/basic_tuts/simple maths.bb similarity index 100% rename from _release/tutorials/basic_tuts/simple maths.bb rename to #Test/tutorials/basic_tuts/simple maths.bb diff --git a/_release/tutorials/basic_tuts/step.bb b/#Test/tutorials/basic_tuts/step.bb similarity index 100% rename from _release/tutorials/basic_tuts/step.bb rename to #Test/tutorials/basic_tuts/step.bb diff --git a/_release/tutorials/basic_tuts/toolbar1.bmp b/#Test/tutorials/basic_tuts/toolbar1.bmp similarity index 100% rename from _release/tutorials/basic_tuts/toolbar1.bmp rename to #Test/tutorials/basic_tuts/toolbar1.bmp diff --git a/_release/tutorials/basic_tuts/topbar.html b/#Test/tutorials/basic_tuts/topbar.html similarity index 100% rename from _release/tutorials/basic_tuts/topbar.html rename to #Test/tutorials/basic_tuts/topbar.html diff --git a/_release/tutorials/basic_tuts/types1.bb b/#Test/tutorials/basic_tuts/types1.bb similarity index 100% rename from _release/tutorials/basic_tuts/types1.bb rename to #Test/tutorials/basic_tuts/types1.bb diff --git a/_release/tutorials/basic_tuts/types2.bb b/#Test/tutorials/basic_tuts/types2.bb similarity index 100% rename from _release/tutorials/basic_tuts/types2.bb rename to #Test/tutorials/basic_tuts/types2.bb diff --git a/_release/tutorials/basic_tuts/variables.bb b/#Test/tutorials/basic_tuts/variables.bb similarity index 100% rename from _release/tutorials/basic_tuts/variables.bb rename to #Test/tutorials/basic_tuts/variables.bb diff --git a/_release/tutorials/basic_tuts/variables1.bb b/#Test/tutorials/basic_tuts/variables1.bb similarity index 100% rename from _release/tutorials/basic_tuts/variables1.bb rename to #Test/tutorials/basic_tuts/variables1.bb diff --git a/_release/tutorials/basic_tuts/variables2.bb b/#Test/tutorials/basic_tuts/variables2.bb similarity index 100% rename from _release/tutorials/basic_tuts/variables2.bb rename to #Test/tutorials/basic_tuts/variables2.bb diff --git a/_release/tutorials/basic_tuts/variables3.bb b/#Test/tutorials/basic_tuts/variables3.bb similarity index 100% rename from _release/tutorials/basic_tuts/variables3.bb rename to #Test/tutorials/basic_tuts/variables3.bb diff --git a/#Test/userlibs/BlitzPointer.decls b/#Test/userlibs/BlitzPointer.decls new file mode 100644 index 0000000..c2c0edc --- /dev/null +++ b/#Test/userlibs/BlitzPointer.decls @@ -0,0 +1,1136 @@ +; BlitzPointer - Adding Pointers to Blitz. +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzPointer.dll" + +; BlitzPointer +BP_GetReturnAddress%() +BP_GetFunctionPointer%() +;BP_GetLastCalledFunctionPointer%() +;BP_GetNextCalledFunctionPointer%() +;BP_GetVariablePointer%(pVariable%) +BP_GetVariablePointerI%(pVariable%) : "BP_GetVariablePointer" +BP_GetVariablePointerF%(pVariable#) : "BP_GetVariablePointer" +BP_GetVariablePointerP%(pVariable*) : "BP_GetVariablePointerType" +BP_GetLocalVariablePointerI%(pVariable%) : "BP_GetLocalVariablePointer" +BP_GetLocalVariablePointerF%(pVariable#) : "BP_GetLocalVariablePointer" +BP_GetLocalVariablePointerP%(pVariable*) : "BP_GetLocalVariablePointer" + +; Memory Modification +PeekMemoryByte%(lpMemoryPointer%) +PeekMemoryShort%(lpMemoryPointer%) +PeekMemoryInt%(lpMemoryPointer%) +PeekMemoryFloat#(lpMemoryPointer%) +PeekMemory(lpMemoryPointer%, iLength%, lpBank*) +PokeMemoryByte(lpMemoryPointer%, value%) +PokeMemoryShort(lpMemoryPointer%, value%) +PokeMemoryInt(lpMemoryPointer%, value%) +PokeMemoryFloat(lpMemoryPointer%, value#) +PokeMemory(lpMemoryPointer%, iLength%, lpBank*) + +; Function Calling +BP_CallFunctionV(fpFunctionPointer%): "BP_CallFunction0" +BP_CallFunctionI%(fpFunctionPointer%): "BP_CallFunction0" +BP_CallFunctionF#(fpFunctionPointer%): "BP_CallFunction0" +BP_CallFunctionVI(fpFunctionPointer%, Integer1%): "BP_CallFunction1" +BP_CallFunctionII%(fpFunctionPointer%, Integer1%): "BP_CallFunction1" +BP_CallFunctionFI#(fpFunctionPointer%, Integer1%): "BP_CallFunction1" +BP_CallFunctionVF(fpFunctionPointer%, Float1#): "BP_CallFunction1" +BP_CallFunctionIF%(fpFunctionPointer%, Float1#): "BP_CallFunction1" +BP_CallFunctionFF#(fpFunctionPointer%, Float1#): "BP_CallFunction1" +BP_CallFunctionVP(fpFunctionPointer%, Pointer1*): "BP_CallFunction1" +BP_CallFunctionIP%(fpFunctionPointer%, Pointer1*): "BP_CallFunction1" +BP_CallFunctionFP#(fpFunctionPointer%, Pointer1*): "BP_CallFunction1" +BP_CallFunctionVII(fpFunctionPointer%, Integer1%, Integer2%): "BP_CallFunction2" +BP_CallFunctionIII%(fpFunctionPointer%, Integer1%, Integer2%): "BP_CallFunction2" +BP_CallFunctionFII#(fpFunctionPointer%, Integer1%, Integer2%): "BP_CallFunction2" +BP_CallFunctionVFI(fpFunctionPointer%, Float1#, Integer2%): "BP_CallFunction2" +BP_CallFunctionIFI%(fpFunctionPointer%, Float1#, Integer2%): "BP_CallFunction2" +BP_CallFunctionFFI#(fpFunctionPointer%, Float1#, Integer2%): "BP_CallFunction2" +BP_CallFunctionVPI(fpFunctionPointer%, Pointer1*, Integer2%): "BP_CallFunction2" +BP_CallFunctionIPI%(fpFunctionPointer%, Pointer1*, Integer2%): "BP_CallFunction2" +BP_CallFunctionFPI#(fpFunctionPointer%, Pointer1*, Integer2%): "BP_CallFunction2" +BP_CallFunctionVIF(fpFunctionPointer%, Integer1%, Float2#): "BP_CallFunction2" +BP_CallFunctionIIF%(fpFunctionPointer%, Integer1%, Float2#): "BP_CallFunction2" +BP_CallFunctionFIF#(fpFunctionPointer%, Integer1%, Float2#): "BP_CallFunction2" +BP_CallFunctionVFF(fpFunctionPointer%, Float1#, Float2#): "BP_CallFunction2" +BP_CallFunctionIFF%(fpFunctionPointer%, Float1#, Float2#): "BP_CallFunction2" +BP_CallFunctionFFF#(fpFunctionPointer%, Float1#, Float2#): "BP_CallFunction2" +BP_CallFunctionVPF(fpFunctionPointer%, Pointer1*, Float2#): "BP_CallFunction2" +BP_CallFunctionIPF%(fpFunctionPointer%, Pointer1*, Float2#): "BP_CallFunction2" +BP_CallFunctionFPF#(fpFunctionPointer%, Pointer1*, Float2#): "BP_CallFunction2" +BP_CallFunctionVIP(fpFunctionPointer%, Integer1%, Pointer2*): "BP_CallFunction2" +BP_CallFunctionIIP%(fpFunctionPointer%, Integer1%, Pointer2*): "BP_CallFunction2" +BP_CallFunctionFIP#(fpFunctionPointer%, Integer1%, Pointer2*): "BP_CallFunction2" +BP_CallFunctionVFP(fpFunctionPointer%, Float1#, Pointer2*): "BP_CallFunction2" +BP_CallFunctionIFP%(fpFunctionPointer%, Float1#, Pointer2*): "BP_CallFunction2" +BP_CallFunctionFFP#(fpFunctionPointer%, Float1#, Pointer2*): "BP_CallFunction2" +BP_CallFunctionVPP(fpFunctionPointer%, Pointer1*, Pointer2*): "BP_CallFunction2" +BP_CallFunctionIPP%(fpFunctionPointer%, Pointer1*, Pointer2*): "BP_CallFunction2" +BP_CallFunctionFPP#(fpFunctionPointer%, Pointer1*, Pointer2*): "BP_CallFunction2" +BP_CallFunctionVIII(fpFunctionPointer%, Integer1%, Integer2%, Integer3%): "BP_CallFunction3" +BP_CallFunctionIIII%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%): "BP_CallFunction3" +BP_CallFunctionFIII#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%): "BP_CallFunction3" +BP_CallFunctionVFII(fpFunctionPointer%, Float1#, Integer2%, Integer3%): "BP_CallFunction3" +BP_CallFunctionIFII%(fpFunctionPointer%, Float1#, Integer2%, Integer3%): "BP_CallFunction3" +BP_CallFunctionFFII#(fpFunctionPointer%, Float1#, Integer2%, Integer3%): "BP_CallFunction3" +BP_CallFunctionVPII(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%): "BP_CallFunction3" +BP_CallFunctionIPII%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%): "BP_CallFunction3" +BP_CallFunctionFPII#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%): "BP_CallFunction3" +BP_CallFunctionVIFI(fpFunctionPointer%, Integer1%, Float2#, Integer3%): "BP_CallFunction3" +BP_CallFunctionIIFI%(fpFunctionPointer%, Integer1%, Float2#, Integer3%): "BP_CallFunction3" +BP_CallFunctionFIFI#(fpFunctionPointer%, Integer1%, Float2#, Integer3%): "BP_CallFunction3" +BP_CallFunctionVFFI(fpFunctionPointer%, Float1#, Float2#, Integer3%): "BP_CallFunction3" +BP_CallFunctionIFFI%(fpFunctionPointer%, Float1#, Float2#, Integer3%): "BP_CallFunction3" +BP_CallFunctionFFFI#(fpFunctionPointer%, Float1#, Float2#, Integer3%): "BP_CallFunction3" +BP_CallFunctionVPFI(fpFunctionPointer%, Pointer1*, Float2#, Integer3%): "BP_CallFunction3" +BP_CallFunctionIPFI%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%): "BP_CallFunction3" +BP_CallFunctionFPFI#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%): "BP_CallFunction3" +BP_CallFunctionVIPI(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%): "BP_CallFunction3" +BP_CallFunctionIIPI%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%): "BP_CallFunction3" +BP_CallFunctionFIPI#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%): "BP_CallFunction3" +BP_CallFunctionVFPI(fpFunctionPointer%, Float1#, Pointer2*, Integer3%): "BP_CallFunction3" +BP_CallFunctionIFPI%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%): "BP_CallFunction3" +BP_CallFunctionFFPI#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%): "BP_CallFunction3" +BP_CallFunctionVPPI(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%): "BP_CallFunction3" +BP_CallFunctionIPPI%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%): "BP_CallFunction3" +BP_CallFunctionFPPI#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%): "BP_CallFunction3" +BP_CallFunctionVIIF(fpFunctionPointer%, Integer1%, Integer2%, Float3#): "BP_CallFunction3" +BP_CallFunctionIIIF%(fpFunctionPointer%, Integer1%, Integer2%, Float3#): "BP_CallFunction3" +BP_CallFunctionFIIF#(fpFunctionPointer%, Integer1%, Integer2%, Float3#): "BP_CallFunction3" +BP_CallFunctionVFIF(fpFunctionPointer%, Float1#, Integer2%, Float3#): "BP_CallFunction3" +BP_CallFunctionIFIF%(fpFunctionPointer%, Float1#, Integer2%, Float3#): "BP_CallFunction3" +BP_CallFunctionFFIF#(fpFunctionPointer%, Float1#, Integer2%, Float3#): "BP_CallFunction3" +BP_CallFunctionVPIF(fpFunctionPointer%, Pointer1*, Integer2%, Float3#): "BP_CallFunction3" +BP_CallFunctionIPIF%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#): "BP_CallFunction3" +BP_CallFunctionFPIF#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#): "BP_CallFunction3" +BP_CallFunctionVIFF(fpFunctionPointer%, Integer1%, Float2#, Float3#): "BP_CallFunction3" +BP_CallFunctionIIFF%(fpFunctionPointer%, Integer1%, Float2#, Float3#): "BP_CallFunction3" +BP_CallFunctionFIFF#(fpFunctionPointer%, Integer1%, Float2#, Float3#): "BP_CallFunction3" +BP_CallFunctionVFFF(fpFunctionPointer%, Float1#, Float2#, Float3#): "BP_CallFunction3" +BP_CallFunctionIFFF%(fpFunctionPointer%, Float1#, Float2#, Float3#): "BP_CallFunction3" +BP_CallFunctionFFFF#(fpFunctionPointer%, Float1#, Float2#, Float3#): "BP_CallFunction3" +BP_CallFunctionVPFF(fpFunctionPointer%, Pointer1*, Float2#, Float3#): "BP_CallFunction3" +BP_CallFunctionIPFF%(fpFunctionPointer%, Pointer1*, Float2#, Float3#): "BP_CallFunction3" +BP_CallFunctionFPFF#(fpFunctionPointer%, Pointer1*, Float2#, Float3#): "BP_CallFunction3" +BP_CallFunctionVIPF(fpFunctionPointer%, Integer1%, Pointer2*, Float3#): "BP_CallFunction3" +BP_CallFunctionIIPF%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#): "BP_CallFunction3" +BP_CallFunctionFIPF#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#): "BP_CallFunction3" +BP_CallFunctionVFPF(fpFunctionPointer%, Float1#, Pointer2*, Float3#): "BP_CallFunction3" +BP_CallFunctionIFPF%(fpFunctionPointer%, Float1#, Pointer2*, Float3#): "BP_CallFunction3" +BP_CallFunctionFFPF#(fpFunctionPointer%, Float1#, Pointer2*, Float3#): "BP_CallFunction3" +BP_CallFunctionVPPF(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#): "BP_CallFunction3" +BP_CallFunctionIPPF%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#): "BP_CallFunction3" +BP_CallFunctionFPPF#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#): "BP_CallFunction3" +BP_CallFunctionVIIP(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*): "BP_CallFunction3" +BP_CallFunctionIIIP%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*): "BP_CallFunction3" +BP_CallFunctionFIIP#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*): "BP_CallFunction3" +BP_CallFunctionVFIP(fpFunctionPointer%, Float1#, Integer2%, Pointer3*): "BP_CallFunction3" +BP_CallFunctionIFIP%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*): "BP_CallFunction3" +BP_CallFunctionFFIP#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*): "BP_CallFunction3" +BP_CallFunctionVPIP(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*): "BP_CallFunction3" +BP_CallFunctionIPIP%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*): "BP_CallFunction3" +BP_CallFunctionFPIP#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*): "BP_CallFunction3" +BP_CallFunctionVIFP(fpFunctionPointer%, Integer1%, Float2#, Pointer3*): "BP_CallFunction3" +BP_CallFunctionIIFP%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*): "BP_CallFunction3" +BP_CallFunctionFIFP#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*): "BP_CallFunction3" +BP_CallFunctionVFFP(fpFunctionPointer%, Float1#, Float2#, Pointer3*): "BP_CallFunction3" +BP_CallFunctionIFFP%(fpFunctionPointer%, Float1#, Float2#, Pointer3*): "BP_CallFunction3" +BP_CallFunctionFFFP#(fpFunctionPointer%, Float1#, Float2#, Pointer3*): "BP_CallFunction3" +BP_CallFunctionVPFP(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*): "BP_CallFunction3" +BP_CallFunctionIPFP%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*): "BP_CallFunction3" +BP_CallFunctionFPFP#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*): "BP_CallFunction3" +BP_CallFunctionVIPP(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*): "BP_CallFunction3" +BP_CallFunctionIIPP%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*): "BP_CallFunction3" +BP_CallFunctionFIPP#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*): "BP_CallFunction3" +BP_CallFunctionVFPP(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*): "BP_CallFunction3" +BP_CallFunctionIFPP%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*): "BP_CallFunction3" +BP_CallFunctionFFPP#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*): "BP_CallFunction3" +BP_CallFunctionVPPP(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*): "BP_CallFunction3" +BP_CallFunctionIPPP%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*): "BP_CallFunction3" +BP_CallFunctionFPPP#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*): "BP_CallFunction3" +BP_CallFunctionVIIII(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionIIIII%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionFIIII#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionVFIII(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionIFIII%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionFFIII#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionVPIII(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionIPIII%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionFPIII#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionVIFII(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionIIFII%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionFIFII#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionVFFII(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionIFFII%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionFFFII#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionVPFII(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionIPFII%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionFPFII#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionVIPII(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionIIPII%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionFIPII#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionVFPII(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionIFPII%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionFFPII#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionVPPII(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionIPPII%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionFPPII#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%): "BP_CallFunction4" +BP_CallFunctionVIIFI(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionIIIFI%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionFIIFI#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionVFIFI(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionIFIFI%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionFFIFI#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionVPIFI(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionIPIFI%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionFPIFI#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionVIFFI(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionIIFFI%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionFIFFI#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionVFFFI(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionIFFFI%(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionFFFFI#(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionVPFFI(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionIPFFI%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionFPFFI#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionVIPFI(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionIIPFI%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionFIPFI#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionVFPFI(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionIFPFI%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionFFPFI#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionVPPFI(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionIPPFI%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionFPPFI#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%): "BP_CallFunction4" +BP_CallFunctionVIIPI(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionIIIPI%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionFIIPI#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionVFIPI(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionIFIPI%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionFFIPI#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionVPIPI(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionIPIPI%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionFPIPI#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionVIFPI(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionIIFPI%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionFIFPI#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionVFFPI(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionIFFPI%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionFFFPI#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionVPFPI(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionIPFPI%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionFPFPI#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionVIPPI(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionIIPPI%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionFIPPI#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionVFPPI(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionIFPPI%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionFFPPI#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionVPPPI(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionIPPPI%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionFPPPI#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%): "BP_CallFunction4" +BP_CallFunctionVIIIF(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionIIIIF%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionFIIIF#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionVFIIF(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionIFIIF%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionFFIIF#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionVPIIF(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionIPIIF%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionFPIIF#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionVIFIF(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionIIFIF%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionFIFIF#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionVFFIF(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionIFFIF%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionFFFIF#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionVPFIF(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionIPFIF%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionFPFIF#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionVIPIF(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionIIPIF%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionFIPIF#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionVFPIF(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionIFPIF%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionFFPIF#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionVPPIF(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionIPPIF%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionFPPIF#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#): "BP_CallFunction4" +BP_CallFunctionVIIFF(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionIIIFF%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionFIIFF#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionVFIFF(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionIFIFF%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionFFIFF#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionVPIFF(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionIPIFF%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionFPIFF#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionVIFFF(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionIIFFF%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionFIFFF#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionVFFFF(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionIFFFF%(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionFFFFF#(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionVPFFF(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionIPFFF%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionFPFFF#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionVIPFF(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionIIPFF%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionFIPFF#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionVFPFF(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionIFPFF%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionFFPFF#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionVPPFF(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionIPPFF%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionFPPFF#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#): "BP_CallFunction4" +BP_CallFunctionVIIPF(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionIIIPF%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionFIIPF#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionVFIPF(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionIFIPF%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionFFIPF#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionVPIPF(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionIPIPF%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionFPIPF#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionVIFPF(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionIIFPF%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionFIFPF#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionVFFPF(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionIFFPF%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionFFFPF#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionVPFPF(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionIPFPF%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionFPFPF#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionVIPPF(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionIIPPF%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionFIPPF#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionVFPPF(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionIFPPF%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionFFPPF#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionVPPPF(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionIPPPF%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionFPPPF#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#): "BP_CallFunction4" +BP_CallFunctionVIIIP(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIIIIP%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFIIIP#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVFIIP(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIFIIP%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFFIIP#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVPIIP(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIPIIP%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFPIIP#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVIFIP(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIIFIP%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFIFIP#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVFFIP(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIFFIP%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFFFIP#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVPFIP(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIPFIP%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFPFIP#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVIPIP(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIIPIP%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFIPIP#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVFPIP(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIFPIP%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFFPIP#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVPPIP(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIPPIP%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFPPIP#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVIIFP(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIIIFP%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFIIFP#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVFIFP(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIFIFP%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFFIFP#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVPIFP(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIPIFP%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFPIFP#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVIFFP(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIIFFP%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFIFFP#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVFFFP(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIFFFP%(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFFFFP#(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVPFFP(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIPFFP%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFPFFP#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVIPFP(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIIPFP%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFIPFP#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVFPFP(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIFPFP%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFFPFP#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVPPFP(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIPPFP%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFPPFP#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVIIPP(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIIIPP%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFIIPP#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVFIPP(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIFIPP%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFFIPP#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVPIPP(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIPIPP%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFPIPP#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVIFPP(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIIFPP%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFIFPP#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVFFPP(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIFFPP%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFFFPP#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVPFPP(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIPFPP%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFPFPP#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVIPPP(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIIPPP%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFIPPP#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVFPPP(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIFPPP%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFFPPP#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVPPPP(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionIPPPP%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionFPPPP#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*): "BP_CallFunction4" +BP_CallFunctionVIIIII(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIIIII%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIIIII#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFIIII(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFIIII%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFIIII#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPIIII(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPIIII%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPIIII#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIFIII(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIFIII%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIFIII#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFFIII(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFFIII%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFFIII#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPFIII(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPFIII%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPFIII#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIPIII(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIPIII%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIPIII#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFPIII(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFPIII%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFPIII#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPPIII(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPPIII%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPPIII#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIIFII(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIIFII%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIIFII#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFIFII(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFIFII%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFIFII#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPIFII(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPIFII%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPIFII#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIFFII(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIFFII%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIFFII#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFFFII(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFFFII%(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFFFII#(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPFFII(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPFFII%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPFFII#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIPFII(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIPFII%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIPFII#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFPFII(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFPFII%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFPFII#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPPFII(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPPFII%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPPFII#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIIPII(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIIPII%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIIPII#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFIPII(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFIPII%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFIPII#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPIPII(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPIPII%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPIPII#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIFPII(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIFPII%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIFPII#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFFPII(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFFPII%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFFPII#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPFPII(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPFPII%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPFPII#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIPPII(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIPPII%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIPPII#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFPPII(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFPPII%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFPPII#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPPPII(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPPPII%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPPPII#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIIIFI(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIIIFI%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIIIFI#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFIIFI(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFIIFI%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFIIFI#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPIIFI(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPIIFI%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPIIFI#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIFIFI(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIFIFI%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIFIFI#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFFIFI(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFFIFI%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFFIFI#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPFIFI(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPFIFI%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPFIFI#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIPIFI(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIPIFI%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIPIFI#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFPIFI(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFPIFI%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFPIFI#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPPIFI(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPPIFI%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPPIFI#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIIFFI(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIIFFI%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIIFFI#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFIFFI(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFIFFI%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFIFFI#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPIFFI(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPIFFI%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPIFFI#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIFFFI(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIFFFI%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIFFFI#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFFFFI(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFFFFI%(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFFFFI#(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPFFFI(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPFFFI%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPFFFI#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIPFFI(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIPFFI%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIPFFI#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFPFFI(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFPFFI%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFPFFI#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPPFFI(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPPFFI%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPPFFI#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIIPFI(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIIPFI%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIIPFI#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFIPFI(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFIPFI%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFIPFI#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPIPFI(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPIPFI%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPIPFI#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIFPFI(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIFPFI%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIFPFI#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFFPFI(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFFPFI%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFFPFI#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPFPFI(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPFPFI%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPFPFI#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIPPFI(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIPPFI%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIPPFI#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFPPFI(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFPPFI%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFPPFI#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPPPFI(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPPPFI%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPPPFI#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIIIPI(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIIIPI%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIIIPI#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFIIPI(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFIIPI%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFIIPI#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPIIPI(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPIIPI%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPIIPI#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIFIPI(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIFIPI%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIFIPI#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFFIPI(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFFIPI%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFFIPI#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPFIPI(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPFIPI%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPFIPI#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIPIPI(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIPIPI%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIPIPI#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFPIPI(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFPIPI%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFPIPI#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPPIPI(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPPIPI%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPPIPI#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIIFPI(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIIFPI%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIIFPI#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFIFPI(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFIFPI%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFIFPI#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPIFPI(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPIFPI%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPIFPI#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIFFPI(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIFFPI%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIFFPI#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFFFPI(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFFFPI%(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFFFPI#(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPFFPI(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPFFPI%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPFFPI#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIPFPI(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIPFPI%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIPFPI#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFPFPI(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFPFPI%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFPFPI#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPPFPI(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPPFPI%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPPFPI#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIIPPI(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIIPPI%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIIPPI#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFIPPI(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFIPPI%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFIPPI#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPIPPI(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPIPPI%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPIPPI#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIFPPI(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIFPPI%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIFPPI#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFFPPI(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFFPPI%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFFPPI#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPFPPI(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPFPPI%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPFPPI#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIPPPI(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIIPPPI%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFIPPPI#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVFPPPI(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIFPPPI%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFFPPPI#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVPPPPI(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionIPPPPI%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionFPPPPI#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*, Integer5%): "BP_CallFunction5" +BP_CallFunctionVIIIIF(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIIIIIF%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFIIIIF#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVFIIIF(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIFIIIF%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFFIIIF#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVPIIIF(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIPIIIF%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFPIIIF#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVIFIIF(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIIFIIF%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFIFIIF#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVFFIIF(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIFFIIF%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFFFIIF#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVPFIIF(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIPFIIF%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFPFIIF#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVIPIIF(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIIPIIF%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFIPIIF#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVFPIIF(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIFPIIF%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFFPIIF#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVPPIIF(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIPPIIF%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFPPIIF#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVIIFIF(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIIIFIF%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFIIFIF#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVFIFIF(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIFIFIF%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFFIFIF#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVPIFIF(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIPIFIF%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFPIFIF#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVIFFIF(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIIFFIF%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFIFFIF#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVFFFIF(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIFFFIF%(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFFFFIF#(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVPFFIF(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIPFFIF%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFPFFIF#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVIPFIF(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIIPFIF%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFIPFIF#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVFPFIF(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIFPFIF%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFFPFIF#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVPPFIF(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIPPFIF%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFPPFIF#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVIIPIF(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIIIPIF%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFIIPIF#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVFIPIF(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIFIPIF%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFFIPIF#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVPIPIF(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIPIPIF%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFPIPIF#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVIFPIF(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIIFPIF%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFIFPIF#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVFFPIF(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIFFPIF%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFFFPIF#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVPFPIF(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIPFPIF%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFPFPIF#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVIPPIF(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIIPPIF%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFIPPIF#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVFPPIF(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIFPPIF%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFFPPIF#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVPPPIF(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionIPPPIF%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionFPPPIF#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%, Float5#): "BP_CallFunction5" +BP_CallFunctionVIIIFF(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIIIIFF%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFIIIFF#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVFIIFF(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIFIIFF%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFFIIFF#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVPIIFF(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIPIIFF%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFPIIFF#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVIFIFF(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIIFIFF%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFIFIFF#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVFFIFF(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIFFIFF%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFFFIFF#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVPFIFF(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIPFIFF%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFPFIFF#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVIPIFF(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIIPIFF%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFIPIFF#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVFPIFF(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIFPIFF%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFFPIFF#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVPPIFF(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIPPIFF%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFPPIFF#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVIIFFF(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIIIFFF%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFIIFFF#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVFIFFF(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIFIFFF%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFFIFFF#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVPIFFF(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIPIFFF%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFPIFFF#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVIFFFF(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIIFFFF%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFIFFFF#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVFFFFF(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIFFFFF%(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFFFFFF#(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVPFFFF(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIPFFFF%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFPFFFF#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVIPFFF(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIIPFFF%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFIPFFF#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVFPFFF(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIFPFFF%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFFPFFF#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVPPFFF(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIPPFFF%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFPPFFF#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVIIPFF(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIIIPFF%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFIIPFF#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVFIPFF(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIFIPFF%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFFIPFF#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVPIPFF(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIPIPFF%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFPIPFF#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVIFPFF(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIIFPFF%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFIFPFF#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVFFPFF(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIFFPFF%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFFFPFF#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVPFPFF(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIPFPFF%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFPFPFF#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVIPPFF(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIIPPFF%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFIPPFF#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVFPPFF(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIFPPFF%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFFPPFF#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVPPPFF(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionIPPPFF%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionFPPPFF#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#, Float5#): "BP_CallFunction5" +BP_CallFunctionVIIIPF(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIIIIPF%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFIIIPF#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVFIIPF(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIFIIPF%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFFIIPF#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVPIIPF(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIPIIPF%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFPIIPF#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVIFIPF(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIIFIPF%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFIFIPF#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVFFIPF(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIFFIPF%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFFFIPF#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVPFIPF(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIPFIPF%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFPFIPF#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVIPIPF(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIIPIPF%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFIPIPF#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVFPIPF(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIFPIPF%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFFPIPF#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVPPIPF(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIPPIPF%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFPPIPF#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVIIFPF(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIIIFPF%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFIIFPF#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVFIFPF(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIFIFPF%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFFIFPF#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVPIFPF(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIPIFPF%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFPIFPF#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVIFFPF(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIIFFPF%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFIFFPF#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVFFFPF(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIFFFPF%(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFFFFPF#(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVPFFPF(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIPFFPF%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFPFFPF#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVIPFPF(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIIPFPF%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFIPFPF#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVFPFPF(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIFPFPF%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFFPFPF#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVPPFPF(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIPPFPF%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFPPFPF#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVIIPPF(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIIIPPF%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFIIPPF#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVFIPPF(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIFIPPF%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFFIPPF#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVPIPPF(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIPIPPF%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFPIPPF#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVIFPPF(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIIFPPF%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFIFPPF#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVFFPPF(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIFFPPF%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFFFPPF#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVPFPPF(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIPFPPF%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFPFPPF#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVIPPPF(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIIPPPF%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFIPPPF#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVFPPPF(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIFPPPF%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFFPPPF#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVPPPPF(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionIPPPPF%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionFPPPPF#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*, Float5#): "BP_CallFunction5" +BP_CallFunctionVIIIIP(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIIIIP%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIIIIP#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFIIIP(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFIIIP%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFIIIP#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPIIIP(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPIIIP%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPIIIP#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIFIIP(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIFIIP%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIFIIP#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFFIIP(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFFIIP%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFFIIP#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPFIIP(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPFIIP%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPFIIP#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIPIIP(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIPIIP%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIPIIP#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFPIIP(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFPIIP%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFPIIP#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPPIIP(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPPIIP%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPPIIP#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIIFIP(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIIFIP%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIIFIP#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFIFIP(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFIFIP%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFIFIP#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPIFIP(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPIFIP%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPIFIP#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIFFIP(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIFFIP%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIFFIP#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFFFIP(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFFFIP%(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFFFIP#(fpFunctionPointer%, Float1#, Float2#, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPFFIP(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPFFIP%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPFFIP#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIPFIP(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIPFIP%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIPFIP#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFPFIP(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFPFIP%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFPFIP#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPPFIP(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPPFIP%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPPFIP#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIIPIP(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIIPIP%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIIPIP#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFIPIP(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFIPIP%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFIPIP#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPIPIP(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPIPIP%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPIPIP#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIFPIP(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIFPIP%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIFPIP#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFFPIP(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFFPIP%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFFPIP#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPFPIP(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPFPIP%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPFPIP#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIPPIP(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIPPIP%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIPPIP#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFPPIP(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFPPIP%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFPPIP#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPPPIP(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPPPIP%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPPPIP#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Integer4%, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIIIFP(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIIIFP%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIIIFP#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFIIFP(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFIIFP%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFIIFP#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPIIFP(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPIIFP%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPIIFP#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIFIFP(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIFIFP%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIFIFP#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFFIFP(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFFIFP%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFFIFP#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPFIFP(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPFIFP%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPFIFP#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIPIFP(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIPIFP%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIPIFP#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFPIFP(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFPIFP%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFPIFP#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPPIFP(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPPIFP%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPPIFP#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIIFFP(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIIFFP%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIIFFP#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFIFFP(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFIFFP%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFIFFP#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPIFFP(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPIFFP%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPIFFP#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIFFFP(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIFFFP%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIFFFP#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFFFFP(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFFFFP%(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFFFFP#(fpFunctionPointer%, Float1#, Float2#, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPFFFP(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPFFFP%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPFFFP#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIPFFP(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIPFFP%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIPFFP#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFPFFP(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFPFFP%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFPFFP#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPPFFP(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPPFFP%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPPFFP#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIIPFP(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIIPFP%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIIPFP#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFIPFP(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFIPFP%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFIPFP#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPIPFP(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPIPFP%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPIPFP#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIFPFP(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIFPFP%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIFPFP#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFFPFP(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFFPFP%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFFPFP#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPFPFP(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPFPFP%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPFPFP#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIPPFP(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIPPFP%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIPPFP#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFPPFP(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFPPFP%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFPPFP#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPPPFP(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPPPFP%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPPPFP#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Float4#, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIIIPP(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIIIPP%(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIIIPP#(fpFunctionPointer%, Integer1%, Integer2%, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFIIPP(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFIIPP%(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFIIPP#(fpFunctionPointer%, Float1#, Integer2%, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPIIPP(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPIIPP%(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPIIPP#(fpFunctionPointer%, Pointer1*, Integer2%, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIFIPP(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIFIPP%(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIFIPP#(fpFunctionPointer%, Integer1%, Float2#, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFFIPP(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFFIPP%(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFFIPP#(fpFunctionPointer%, Float1#, Float2#, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPFIPP(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPFIPP%(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPFIPP#(fpFunctionPointer%, Pointer1*, Float2#, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIPIPP(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIPIPP%(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIPIPP#(fpFunctionPointer%, Integer1%, Pointer2*, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFPIPP(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFPIPP%(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFPIPP#(fpFunctionPointer%, Float1#, Pointer2*, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPPIPP(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPPIPP%(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPPIPP#(fpFunctionPointer%, Pointer1*, Pointer2*, Integer3%, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIIFPP(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIIFPP%(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIIFPP#(fpFunctionPointer%, Integer1%, Integer2%, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFIFPP(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFIFPP%(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFIFPP#(fpFunctionPointer%, Float1#, Integer2%, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPIFPP(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPIFPP%(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPIFPP#(fpFunctionPointer%, Pointer1*, Integer2%, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIFFPP(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIFFPP%(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIFFPP#(fpFunctionPointer%, Integer1%, Float2#, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFFFPP(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFFFPP%(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFFFPP#(fpFunctionPointer%, Float1#, Float2#, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPFFPP(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPFFPP%(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPFFPP#(fpFunctionPointer%, Pointer1*, Float2#, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIPFPP(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIPFPP%(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIPFPP#(fpFunctionPointer%, Integer1%, Pointer2*, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFPFPP(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFPFPP%(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFPFPP#(fpFunctionPointer%, Float1#, Pointer2*, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPPFPP(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPPFPP%(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPPFPP#(fpFunctionPointer%, Pointer1*, Pointer2*, Float3#, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIIPPP(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIIPPP%(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIIPPP#(fpFunctionPointer%, Integer1%, Integer2%, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFIPPP(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFIPPP%(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFIPPP#(fpFunctionPointer%, Float1#, Integer2%, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPIPPP(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPIPPP%(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPIPPP#(fpFunctionPointer%, Pointer1*, Integer2%, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIFPPP(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIFPPP%(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIFPPP#(fpFunctionPointer%, Integer1%, Float2#, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFFPPP(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFFPPP%(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFFPPP#(fpFunctionPointer%, Float1#, Float2#, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPFPPP(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPFPPP%(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPFPPP#(fpFunctionPointer%, Pointer1*, Float2#, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVIPPPP(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIIPPPP%(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFIPPPP#(fpFunctionPointer%, Integer1%, Pointer2*, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVFPPPP(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIFPPPP%(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFFPPPP#(fpFunctionPointer%, Float1#, Pointer2*, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionVPPPPP(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionIPPPPP%(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" +BP_CallFunctionFPPPPP#(fpFunctionPointer%, Pointer1*, Pointer2*, Pointer3*, Pointer4*, Pointer5*): "BP_CallFunction5" diff --git a/#Test/userlibs/BlitzPointer.dll b/#Test/userlibs/BlitzPointer.dll new file mode 100644 index 0000000..8276f2a Binary files /dev/null and b/#Test/userlibs/BlitzPointer.dll differ diff --git a/#Test/userlibs/BlitzSteam.decls b/#Test/userlibs/BlitzSteam.decls new file mode 100644 index 0000000..032af34 --- /dev/null +++ b/#Test/userlibs/BlitzSteam.decls @@ -0,0 +1,23 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" +; Generic --------------------------------------------------------------------- +BS_Helper_FormatUnixTime$(unixTime%, pchFormat$) :"_BS_Helper_FormatUnixTime@8" +BS_Helper_CopyMemoryIntMangle(pSource%, pDest%, iMangling%, iSourceW%, iSourceH%, iDestW%, iDestH%, iAreaX%, iAreaY%, iAreaW%, iAreaH%):"_BS_Helper_CopyMemoryIntMangle@44" + +BS_BlitzPointer_GetReturnAddress%() :"_BS_BlitzPointer_GetReturnAddress@0" +BS_BlitzPointer_GetFunctionPointer%() :"_BS_BlitzPointer_GetFunctionPointer@0" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam.dll b/#Test/userlibs/BlitzSteam.dll new file mode 100644 index 0000000..4df3a21 Binary files /dev/null and b/#Test/userlibs/BlitzSteam.dll differ diff --git a/#Test/userlibs/BlitzSteam_CSteamID.decls b/#Test/userlibs/BlitzSteam_CSteamID.decls new file mode 100644 index 0000000..5aff58d --- /dev/null +++ b/#Test/userlibs/BlitzSteam_CSteamID.decls @@ -0,0 +1,55 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" +; CSteamID -------------------------------------------------------------------- +BS_CSteamID_New%() :"_BS_CSteamID_New@0" +BS_CSteamID_Copy%(pThis%) :"_BS_CSteamID_Copy@4" +BS_CSteamID_Destroy(pThis%) :"_BS_CSteamID_Destroy@4" +BS_CSteamID_New_IdUniverseType%(iAccountId%, EUniverse%, EAccountType%) :"_BS_CSteamID_New_IdUniverseType@12" +BS_CSteamID_New_IdInstanceUniverseType%(iAccountId%, iInstance%, EUniverse%, EAccountType%):"_BS_CSteamID_New_IdInstanceUniverseType@16" +BS_CSteamID_FromL%(pOther%) :"_BS_CSteamID_FromL@4" +BS_CSteamID_ToL%(pThis%) :"_BS_CSteamID_ToL@4" +BS_CSteamID_Set(pThis%, iAccountId%, EUniverse%, EAccountType%) :"_BS_CSteamID_Set@16" +BS_CSteamID_InstancedSet(pThis%, iAccountId%, iInstance%, EUniverse%, EAccountType%):"_BS_CSteamID_InstancedSet@20" +BS_CSteamID_FullSet(pThis%, plIdentifier%, EUniverse%, EAccountType%) :"_BS_CSteamID_FullSet@16" +BS_CSteamID_SetFromLong(pthis%, plSteamID%) :"_BS_CSteamID_SetFromLong@8" +BS_CSteamID_Clear(pThis%) :"_BS_CSteamID_Clear@4" +BS_CSteamID_GetStaticAccountKey%(pThis%) :"_BS_CSteamID_GetStaticAccountKey@4" +BS_CSteamID_CreateBlankAnonLogon(pThis%, EUniverse%) :"_BS_CSteamID_CreateBlankAnonLogon@8" +BS_CSteamID_CreateBlankAnonUserLogon(pThis%, EUniverse%) :"_BS_CSteamID_CreateBlankAnonUserLogon@8" +BS_CSteamID_IsBlankAnonAccount%(pThis%) :"_BS_CSteamID_IsBlankAnonAccount@4" +BS_CSteamID_IsGameServerAccount%(pThis%) :"_BS_CSteamID_IsGameServerAccount@4" +BS_CSteamID_IsPersistentGameServerAccount%(pThis%) :"_BS_CSteamID_IsPersistentGameServerAccount@4" +BS_CSteamID_IsAnonGameServerAccount%(pThis%) :"_BS_CSteamID_IsAnonGameServerAccount@4" +BS_CSteamID_IsContentServerAccount%(pThis%) :"_BS_CSteamID_IsContentServerAccount@4" +BS_CSteamID_IsClanAccount%(pThis%) :"_BS_CSteamID_IsClanAccount@4" +BS_CSteamID_IsChatAccount%(pThis%) :"_BS_CSteamID_IsChatAccount@4" +BS_CSteamID_IsLobby%(pThis%) :"_BS_CSteamID_IsLobby@4" +BS_CSteamID_IsIndividualAccount%(pThis%) :"_BS_CSteamID_IsIndividualAccount@4" +BS_CSteamID_IsAnonAccount%(pThis%) :"_BS_CSteamID_IsAnonAccount@4" +BS_CSteamID_IsAnonUserAccount%(pThis%) :"_BS_CSteamID_IsAnonUserAccount@4" +BS_CSteamID_IsConsoleUserAccount%(pThis%) :"_BS_CSteamID_IsConsoleUserAccount@4" +BS_CSteamID_SetAccountID(pThis%, iAccountId%) :"_BS_CSteamID_SetAccountID@8" +BS_CSteamID_GetAccountID%(pThis%) :"_BS_CSteamID_GetAccountID@4" +BS_CSteamID_SetAccountInstance(pThis%, iInstance%) :"_BS_CSteamID_SetAccountInstance@8" +BS_CSteamID_ClearIndividualInstance(pThis%) :"_BS_CSteamID_ClearIndividualInstance@4" +BS_CSteamID_HasNoIndividualInstance%(pThis%) :"_BS_CSteamID_HasNoIndividualInstance@4" +BS_CSteamID_GetAccountInstance%(pThis%) :"_BS_CSteamID_GetAccountInstance@4" +BS_CSteamID_GetEAccountType%(pThis%) :"_BS_CSteamID_GetEAccountType@4" +BS_CSteamID_SetEUniverse%(pThis%, EUniverse%) :"_BS_CSteamID_SetEUniverse@8" +BS_CSteamID_GetEUniverse%(pThis%) :"_BS_CSteamID_GetEUniverse@4" +BS_CSteamID_Compare%(pThis%, pOther%) :"_BS_CSteamID_Compare@8" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_Callback.decls b/#Test/userlibs/BlitzSteam_Callback.decls new file mode 100644 index 0000000..ff20199 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_Callback.decls @@ -0,0 +1,33 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" +; BlitzCallback --------------------------------------------------------------- +BS_Callback_New%(pFunction%) :"_BS_Callback_New@4" +BS_Callback_Destroy(pThis%) :"_BS_Callback_Destroy@4" +BS_Callback_GetCallbackSizeBytes%(pThis%) :"_BS_Callback_GetCallbackSizeBytes@4" +BS_Callback_SetCallback(pThis%, iCallback%) :"_BS_Callback_SetCallback@8" +BS_Callback_GetCallback%(pThis%) :"_BS_Callback_GetCallback@4" +BS_Callback_SetFunction(pThis%, pFunction%) :"_BS_Callback_SetFunction@8" +BS_Callback_GetFunction%(pThis%) :"_BS_Callback_GetFunction@4" +BS_Callback_SetRegistered(pThis%, bIsRegistered%) :"_BS_Callback_SetRegistered@8" +BS_Callback_IsRegistered%(pThis%) :"_BS_Callback_IsRegistered@4" +BS_Callback_SetGameServer(pThis%, bIsGameServer%) :"_BS_Callback_SetGameServer@8" +BS_Callback_IsGameServer%(pThis%) :"_BS_Callback_IsGameServer@4" +BS_Callback_Register(pThis%, iCallback%) :"_BS_Callback_Register@8" +BS_Callback_Unregister(pThis%) :"_BS_Callback_Unregister@4" +BS_Callback_RegisterResult(pThis%, lSteamAPICall%, iCallback%) :"_BS_Callback_RegisterResult@12" +BS_Callback_UnregisterResult(pThis%) :"_BS_Callback_UnregisterResult@4" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_Double.decls b/#Test/userlibs/BlitzSteam_Double.decls new file mode 100644 index 0000000..f2d0bce --- /dev/null +++ b/#Test/userlibs/BlitzSteam_Double.decls @@ -0,0 +1,42 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; aDouble with this program. If not, see . + +.lib "BlitzSteam.dll" +; Double ------------------------------------------------------------------------ +BS_Double_New%() :"_BS_Double_New@0" +BS_Double_Copy%(pThis%) :"_BS_Double_Copy@4" +BS_Double_Destroy(pThis%) :"_BS_Double_Destroy@4" +BS_Double_ToString$(pThis%) :"_BS_Double_ToString@4" +BS_Double_FromString%(cString$) :"_BS_Double_FromString@4" +BS_Double_FromF%(Float#) :"_BS_Double_FromF@4" +BS_Double_ToF#(pThis%) :"_BS_Double_ToF@4" +BS_Double_FromI%(iRight%) :"_BS_Double_FromI@4" +BS_Double_ToI%(pThis%) :"_BS_Double_ToI@8" +BS_Double_FromL(pDouble%) :"_BS_Double_FromL@4" +BS_Double_ToL(pThis%) :"_BS_Double_ToL@4" +BS_Double_Compare%(pThis%, pOther%) :"_BS_Double_Compare@8" +BS_Double_Set%(pThis%, pOther%) :"_BS_Double_Set@8" +BS_Double_Add%(pThis%, pOther%) :"_BS_Double_Add@8" +BS_Double_Sub%(pThis%, pOther%) :"_BS_Double_Sub@8" +BS_Double_Div%(pThis%, pOther%) :"_BS_Double_Div@8" +BS_Double_Mul%(pThis%, pOther%) :"_BS_Double_Mul@8" +BS_Double_Mod%(pThis%, pOther%) :"_BS_Double_Mod@8" +BS_Double_SetF%(pThis%, fOther%) :"_BS_Double_SetF@8" +BS_Double_AddF%(pThis%, fOther%) :"_BS_Double_AddF@8" +BS_Double_SubF%(pThis%, fOther%) :"_BS_Double_SubF@8" +BS_Double_DivF%(pThis%, fOther%) :"_BS_Double_DivF@8" +BS_Double_MulF%(pThis%, fOther%) :"_BS_Double_MulF@8" +BS_Double_ModF%(pThis%, fOther%) :"_BS_Double_ModF@8" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_Long.decls b/#Test/userlibs/BlitzSteam_Long.decls new file mode 100644 index 0000000..f227374 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_Long.decls @@ -0,0 +1,52 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" +; Long ------------------------------------------------------------------------ +BS_Long_New%() :"_BS_Long_New@0" +BS_Long_Copy%(pThis%) :"_BS_Long_Copy@4" +BS_Long_Destroy(pThis%) :"_BS_Long_Destroy@4" +BS_Long_ToString$(pThis%) :"_BS_Long_ToString@4" +BS_Long_FromString%(cString$) :"_BS_Long_FromString@4" +BS_Long_FromI%(iRight%) :"_BS_Long_FromI@4" +BS_Long_FromII%(iLeft%, iRight%) :"_BS_Long_FromII@8" +BS_Long_ToI%(pThis%, iShift%) :"_BS_Long_ToI@8" +BS_Long_ToIH%(pThis%) :"_BS_Long_ToIH@4" +BS_Long_ToIL%(pThis%) :"_BS_Long_ToIL@4" +BS_Long_FromF%(Float#) :"_BS_Long_FromF@4" +BS_Long_ToF#(pThis%) :"_BS_Long_ToF@4" +BS_Long_FromD(pDouble%) :"_BS_Long_FromD@4" +BS_Long_ToD(pThis%) :"_BS_Long_ToD@4" +BS_Long_Compare%(pThis%, pRight%) :"_BS_Long_Compare@8" +BS_Long_Set%(pThis%, pOther%) :"_BS_Long_Set@8" +BS_Long_Add%(pThis%, pOther%) :"_BS_Long_Add@8" +BS_Long_Sub%(pThis%, pOther%) :"_BS_Long_Sub@8" +BS_Long_Div%(pThis%, pOther%) :"_BS_Long_Div@8" +BS_Long_Mul%(pThis%, pOther%) :"_BS_Long_Mul@8" +BS_Long_Mod%(pThis%, pOther%) :"_BS_Long_Mod@8" +BS_Long_SetI%(pThis%, iRight%) :"_BS_Long_SetI@8" +BS_Long_AddI%(pThis%, iRight%) :"_BS_Long_AddI@8" +BS_Long_SubI%(pThis%, iRight%) :"_BS_Long_SubI@8" +BS_Long_DivI%(pThis%, iRight%) :"_BS_Long_DivI@8" +BS_Long_MulI%(pThis%, iRight%) :"_BS_Long_MulI@8" +BS_Long_ModI%(pThis%, iRight%) :"_BS_Long_ModI@8" +BS_Long_SetII%(pThis%, iLeft%, iRight%) :"_BS_Long_SetII@12" +BS_Long_AddII%(pThis%, iLeft%, iRight%) :"_BS_Long_AddII@12" +BS_Long_SubII%(pThis%, iLeft%, iRight%) :"_BS_Long_SubII@12" +BS_Long_DivII%(pThis%, iLeft%, iRight%) :"_BS_Long_DivII@12" +BS_Long_MulII%(pThis%, iLeft%, iRight%) :"_BS_Long_MulII@12" +BS_Long_ModII%(pThis%, iLeft%, iRight%) :"_BS_Long_ModII@12" +BS_Long_Shift%(pThis%, iRight%) :"_BS_Long_Shift@8" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_Memory.decls b/#Test/userlibs/BlitzSteam_Memory.decls new file mode 100644 index 0000000..8db029f --- /dev/null +++ b/#Test/userlibs/BlitzSteam_Memory.decls @@ -0,0 +1,33 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" +; Memory ---------------------------------------------------------------------- +BS_Memory_Alloc%(iSize%) :"_BS_Memory_Alloc@4" +BS_Memory_ReAlloc%(pMemory%, iSize%) :"_BS_Memory_ReAlloc@8" +BS_Memory_Free(pMemory%) :"_BS_Memory_Free@4" +BS_Memory_PokeByte(pMemory%, iOffset%, bValue%) :"_BS_Memory_PokeByte@12" +BS_Memory_PeekByte%(pMemory%, iOffset%) :"_BS_Memory_PeekByte@8" +BS_Memory_PokeShort(pMemory%, iOffset%, sValue%) :"_BS_Memory_PokeShort@12" +BS_Memory_PeekShort%(pMemory%, iOffset%) :"_BS_Memory_PeekShort@8" +BS_Memory_PokeInt(pMemory%, iOffset%, iValue%) :"_BS_Memory_PokeInt@12" +BS_Memory_PeekInt%(pMemory%, iOffset%) :"_BS_Memory_PeekInt@8" +BS_Memory_PokeFloat(pMemory%, iOffset%, fValue#) :"_BS_Memory_PokeFloat@12" +BS_Memory_PeekFloat#(pMemory%, iOffset%) :"_BS_Memory_PeekFloat@8" +BS_Memory_PokeLong(pMemory%, iOffset%, lValue%) :"_BS_Memory_PokeLong@12" +BS_Memory_PeekLong%(pMemory%, iOffset%) :"_BS_Memory_PeekLong@8" +BS_Memory_PokeDouble(pMemory%, iOffset%, dValue%) :"_BS_Memory_PokeDouble@12" +BS_Memory_PeekDouble%(pMemory%, iOffset%) :"_BS_Memory_PeekDouble@8" diff --git a/#Test/userlibs/BlitzSteam_Steam.decls b/#Test/userlibs/BlitzSteam_Steam.decls new file mode 100644 index 0000000..75e0ab3 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_Steam.decls @@ -0,0 +1,28 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Steam ----------------------------------------------------------------------- +BS_SteamAPI_Init%() :"_BS_SteamAPI_Init@0" +BS_SteamAPI_Shutdown() :"_BS_SteamAPI_Shutdown@0" +BS_SteamAPI_IsSteamRunning%() :"_BS_SteamAPI_IsSteamRunning@0" +BS_SteamAPI_RestartAppIfNecessary%(iAppId%) :"_BS_SteamAPI_RestartAppIfNecessary@4" +BS_SteamAPI_SetMiniDumpComment(cComment$) :"_BS_SteamAPI_SetMiniDumpComment@4" +BS_SteamAPI_WriteMiniDump(iExceptionCode%, pExceptionInfo*, iBuildId%) :"_BS_SteamAPI_WriteMiniDump@12" +BS_SteamAPI_WriteMiniDumpEx(iExceptionCode%, pExceptionInfo%, iBuildId%) :"_BS_SteamAPI_WriteMiniDump@12" +BS_SteamAPI_ReleaseCurrentThreadMemory%() :"_BS_SteamAPI_ReleaseCurrentThreadMemory@0" +BS_SteamAPI_RunCallbacks() :"_BS_SteamAPI_RunCallbacks@0" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamAppList.decls b/#Test/userlibs/BlitzSteam_SteamAppList.decls new file mode 100644 index 0000000..65f99fb --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamAppList.decls @@ -0,0 +1,28 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; AppList --------------------------------------------------------------------- +BS_SteamAppList%() :"_BS_SteamAppList@0" +BS_ISteamAppList_GetNumInstalledApps%(pThis%) :"_BS_ISteamAppList_GetNumInstalledApps@4" +BS_ISteamAppList_GetInstalledApps%(pThis%, pAppIdBuffer*, iMaxIDs%) :"_BS_ISteamAppList_GetInstalledApps@12" +BS_ISteamAppList_GetInstalledAppsEx%(pThis%, pAppIdBuffer%, iMaxIDs%) :"_BS_ISteamAppList_GetInstalledApps@12" +BS_ISteamAppList_GetAppName%(pThis%, iAppId%, pNameBuffer*, iNameMax%) :"_BS_ISteamAppList_GetAppName@12" +BS_ISteamAppList_GetAppNameEx%(pThis%, iAppId%, pNameBuffer%, iNameMax%) :"_BS_ISteamAppList_GetAppName@12" +BS_ISteamAppList_GetAppInstallDir%(pThis%, iAppId%, pPathBuffer*, iPathMax%) :"_BS_ISteamAppList_GetAppInstallDir@16" +BS_ISteamAppList_GetAppInstallDirEx%(pThis%, iAppId%, pPathBuffer%, iPathMax%) :"_BS_ISteamAppList_GetAppInstallDir@16" +BS_ISteamAppList_GetAppBuildId%(pThis%, iAppId%) :"_BS_ISteamAppList_GetAppBuildId@8" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamApps.decls b/#Test/userlibs/BlitzSteam_SteamApps.decls new file mode 100644 index 0000000..fc5d46d --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamApps.decls @@ -0,0 +1,49 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Apps ------------------------------------------------------------------------ +BS_SteamApps%() :"_BS_SteamApps@0" +BS_ISteamApps_IsSubscribed%(pThis%) :"_BS_ISteamApps_IsSubscribed@4" +BS_ISteamApps_IsLowViolence%(pThis%) :"_BS_ISteamApps_IsLowViolence@4" +BS_ISteamApps_IsCybercafe%(pThis%) :"_BS_ISteamApps_IsCybercafe@4" +BS_ISteamApps_IsVACBanned%(pThis%) :"_BS_ISteamApps_IsVACBanned@4" +BS_ISteamApps_GetCurrentGameLanguage$(pThis%) :"_BS_ISteamApps_GetCurrentGameLanguage@4" +BS_ISteamApps_GetAvailableGameLanguages$(pThis%) :"_BS_ISteamApps_GetAvailableGameLanguages@4" +BS_ISteamApps_IsSubscribedApp%(pThis%, iAppId%) :"_BS_ISteamApps_IsSubscribedApp@8" +BS_ISteamApps_IsDlcInstalled%(pThis%, iAppId%) :"_BS_ISteamApps_IsDlcInstalled@8" +BS_ISteamApps_GetEarliestPurchaseUnixTime%(pThis%, iAppId%) :"_BS_ISteamApps_GetEarliestPurchaseUnixTime@8" +BS_ISteamApps_IsSubscribedFromFreeWeekend%(pThis%) :"_BS_ISteamApps_IsSubscribedFromFreeWeekend@4" +BS_ISteamApps_GetDLCCount%(pThis%) :"_BS_ISteamApps_GetDLCCount@4" +BS_ISteamApps_GetDLCDataByIndex%(pThis%, iDLC%, pAppId*, pAvailable*, pName*, iNameSize%):"_BS_ISteamApps_GetDLCDataByIndex@24" +BS_ISteamApps_GetDLCDataByIndexEx%(pThis%, iDLC%, pAppId%, pAvailable%, pName%, iNameSize%):"_BS_ISteamApps_GetDLCDataByIndex@24" +BS_ISteamApps_InstallDLC(pThis%, iAppId%) :"_BS_ISteamApps_InstallDLC@8" +BS_ISteamApps_UninstallDLC(pThis%, iAppId%) :"_BS_ISteamApps_UninstallDLC@8" +BS_ISteamApps_RequestAppProofOfPurchaseKey(pThis%, iAppId%) :"_BS_ISteamApps_RequestAppProofOfPurchaseKey@8" +BS_ISteamApps_GetCurrentBetaName%(pThis%, pName*, iNameSize%) :"_BS_ISteamApps_GetCurrentBetaName@12" +BS_ISteamApps_GetCurrentBetaNameEx%(pThis%, pName%, iNameSize%) :"_BS_ISteamApps_GetCurrentBetaName@12" +BS_ISteamApps_MarkContentCorrupt%(pThis%, bMissingFilesOnly%) :"_BS_ISteamApps_MarkContentCorrupt@8" +BS_ISteamApps_GetInstalledDepots%(pThis%, iAppId%, pDepots*, iMaxDepots%) :"_BS_ISteamApps_GetInstalledDepots@16" +BS_ISteamApps_GetInstalledDepotsEx%(pThis%, iAppId%, pDepots%, iMaxDepots%) :"_BS_ISteamApps_GetInstalledDepots@16" +BS_ISteamApps_GetAppInstallDir%(pThis%, iAppId%, pPathBuffer*, iPathBufferSize%):"_BS_ISteamApps_GetAppInstallDir@16" +BS_ISteamApps_GetAppInstallDirEx%(pThis%, iAppId%, pPathBuffer%, iPathBufferSize%):"_BS_ISteamApps_GetAppInstallDir@16" +BS_ISteamApps_IsAppInstalled%(pThis%, iAppId%) :"_BS_ISteamApps_IsAppInstalled@8" +BS_ISteamApps_GetAppOwner%(pThis%) :"_BS_ISteamApps_GetAppOwner@4" +BS_ISteamApps_GetLaunchQueryParam$(pThis%, cKey$) :"_BS_ISteamApps_GetLaunchQueryParam@8" +BS_ISteamApps_GetDlcDownloadProgress%(pThis%, iAppId%, llDownloaded*, llTotal*) :"_BS_ISteamApps_GetDlcDownloadProgress@16" +BS_ISteamApps_GetDlcDownloadProgressEx%(pThis%, iAppId%, llDownloaded%, llTotal%):"_BS_ISteamApps_GetDlcDownloadProgress@16" +BS_ISteamApps_GetAppBuildId%(pThis%) :"_BS_ISteamApps_GetAppBuildId@4" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamClient.decls b/#Test/userlibs/BlitzSteam_SteamClient.decls new file mode 100644 index 0000000..b541e80 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamClient.decls @@ -0,0 +1,51 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Client ---------------------------------------------------------------------- +BS_SteamClient%() :"_BS_SteamClient@0" +BS_ISteamClient_CreateSteamPipe%(pThis%) :"_BS_ISteamClient_CreateSteamPipe@4" +BS_ISteamClient_ReleaseSteamPipe%(pThis%, hPipe%) :"_BS_ISteamClient_ReleaseSteamPipe@8" +BS_ISteamClient_ConnectToGlobalUser%(pThis%, hPipe%) :"_BS_ISteamClient_ConnectToGlobalUser@8" +BS_ISteamClient_SetLocalIPBinding(pThis, unIP%, usPort%) :"_BS_ISteamClient_SetLocalIPBinding@12" +BS_ISteamClient_CreateLocalUser%(pThis%, pSteamPipe%, EAccountType%) :"_BS_ISteamClient_CreateLocalUser@12" +BS_ISteamClient_ReleaseUser(pThis%, hPipe%, hUser%) :"_BS_ISteamClient_ReleaseUser@12" +BS_ISteamClient_GetIPCCallCount%(pThis%) :"_BS_ISteamClient_GetIPCCallCount@4" +BS_ISteamClient_ShutdownIfAllPipesClosed%(pThis%) :"_BS_ISteamClient_ShutdownIfAllPipesClosed@4" +BS_ISteamClient_GetSteamAppList%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamAppList@16" +BS_ISteamClient_GetSteamApps%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamApps@16" +BS_ISteamClient_GetSteamController%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamController@16" +BS_ISteamClient_GetSteamFriends%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamFriends@16" +BS_ISteamClient_GetSteamGameServer%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamGameServer@16" +BS_ISteamClient_GetSteamGameServerStats%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamGameServerStats@16" +BS_ISteamClient_GetSteamHTMLSurface%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamHTMLSurface@16" +BS_ISteamClient_GetSteamHTTP%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamHTTP@16" +BS_ISteamClient_GetSteamInventory%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamInventory@16" +BS_ISteamClient_GetSteamMatchmaking%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamMatchmaking@16" +BS_ISteamClient_GetSteamMatchmakingServers%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamMatchmakingServers@16" +BS_ISteamClient_GetSteamMusic%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamMusic@16" +BS_ISteamClient_GetSteamMusicRemote%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamMusicRemote@16" +BS_ISteamClient_GetSteamNetworking%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamNetworking@16" +BS_ISteamClient_GetSteamRemoteStorage%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamRemoteStorage@16" +BS_ISteamClient_GetSteamScreenshots%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamScreenshots@16" +BS_ISteamClient_GetSteamUGC%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamUGC@16" +BS_ISteamClient_GetSteamUnifiedMessages%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamUnifiedMessages@16" +BS_ISteamClient_GetSteamUser%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamUser@16" +BS_ISteamClient_GetSteamUserStats%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamUserStats@16" +BS_ISteamClient_GetSteamUtils%(pThis%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamUtils@12" +BS_ISteamClient_GetSteamVideo%(pThis%, hUser%, hPipe%, cVersion$) :"_BS_ISteamClient_GetSteamVideo@16" +BS_ISteamClient_SetWarningMessageHook(pThis%, pFunction%) :"_BS_ISteamClient_SetWarningMessageHook@8" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamController.decls b/#Test/userlibs/BlitzSteam_SteamController.decls new file mode 100644 index 0000000..fb955d7 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamController.decls @@ -0,0 +1,48 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Controller ------------------------------------------------------------------ +BS_SteamController%() :"_BS_SteamController@0" +BS_SteamController_Init%(pThis%, cControlConfigVDF$) :"_BS_ISteamController_Init@8" +BS_ISteamController_Shutdown%(pThis%) :"_BS_ISteamController_Shutdown@4" +BS_ISteamController_RunFrame(pThis%) :"_BS_ISteamController_RunFrame@4" +BS_ISteamController_GetConnectedControllers%(pThis%, pHandles*) :"_BS_ISteamController_GetConnectedControllers@8" +BS_ISteamController_GetConnectedControllersEx%(pThis%, pHandles%) :"_BS_ISteamController_GetConnectedControllers@8" +BS_ISteamController_GetConnectedControllersSimple%(pThis%) :"_BS_ISteamController_GetConnectedControllersSimple@4" +BS_ISteamController_GetConnectedControllersSimple_Index%(iIndex%) :"_BS_ISteamController_GetConnectedControllersSimple@4" +BS_ISteamController_ShowBindingPanel%(pThis%, pController%) :"_BS_ISteamController_ShowBindingPanel@8" +BS_ISteamController_GetActionSetHandle%(pThis%, cSetName$) :"_BS_ISteamController_GetActionSetHandle@8" +;! Returns: ControllerActionSetHandle_t*. Clean Up! +BS_ISteamController_ActivateActionSet(pThis%, pController%, pActionSet%) :"_BS_ISteamController_ActivateActionSet@12" +BS_ISteamController_GetCurrentActionSet%(pThis%, pController%) :"_BS_ISteamController_GetCurrentActionSet@8" +;! Returns: ControllerActionSetHandle_t*. Clean Up! +BS_ISteamController_GetDigitalActionHandle%(pThis%, cName$) :"_BS_ISteamController_GetDigitalActionHandle@8" +;! Returns: ControllerDigitalActionHandle_t*. Clean Up! +BS_ISteamController_GetDigitalActionData%(pThis%, pController%, pDigital%) :"_BS_ISteamController_GetDigitalActionData@12" +;! Returns: ControllerDigitalActionData_t*. Clean Up! +BS_ISteamController_GetDigitalActionOrigins%(pThis%, pController%, pActionSet%, pDigital%, pEControllerActionOrigin*):"_BS_ISteamController_GetDigitalActionOrigins@20" +BS_ISteamController_GetDigitalActionOriginsEx%(pThis%, pController%, pActionSet%, pDigital%, pEControllerActionOrigin%):"_BS_ISteamController_GetDigitalActionOrigins@20" +BS_ISteamController_GetAnalogActionHandle%(pThis%, cName$) :"_BS_ISteamController_GetAnalogActionHandle@8" +;! Returns: ControllerAnalogActionHandle_t*. Clean Up! +BS_ISteamController_GetAnalogActionData%(pThis%, pController%, pAnalog%) :"_BS_ISteamController_GetAnalogActionData@12" +;! Returns: ControllerAnalogActionData_t*. Clean Up! +BS_ISteamController_GetAnalogActionOrigins%(pThis%, pController%, pActionSet%, pAnalog%, pEControllerActionOrigin*):"_BS_ISteamController_GetAnalogActionOrigins@20" +BS_ISteamController_GetAnalogActionOriginsEx%(pThis%, pController%, pActionSet%, pAnalog%, pEControllerActionOrigin*):"_BS_ISteamController_GetAnalogActionOrigins@20" +BS_ISteamController_StopAnalogActionMomentum(pThis%, pController%, pAnalog%):"_BS_ISteamController_StopAnalogActionMomentum@12" +BS_ISteamController_TriggerHapticPulse(pThis%, pController%, ESteamControllerPad%, iDuration%):"_BS_ISteamController_TriggerHapticPulse@16" +BS_ISteamController_TriggerRepeatedHapticPulse(pThis%, pController%, ESteamControllerPad%, iDuration%, iOffDuration%, iRepeats%, iFlags%):"_BS_ISteamController_TriggerRepeatedHapticPulse@28" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamFriends.decls b/#Test/userlibs/BlitzSteam_SteamFriends.decls new file mode 100644 index 0000000..1893a5e --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamFriends.decls @@ -0,0 +1,104 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Friends --------------------------------------------------------------------- +BS_SteamFriends%() :"_BS_SteamFriends@0" +BS_ISteamFriends_GetPersonaName$(pThis%) :"_BS_ISteamFriends_GetPersonaName@4" +BS_ISteamFriends_SetPersonaName%(pThis%, cPersonaName$) :"_BS_ISteamFriends_SetPersonaName@8" +;! Returns: SteamAPICall_t*. Clean Up! +BS_ISteamFriends_GetPersonaState%(pThis%) :"_BS_ISteamFriends_GetPersonaState@4" +BS_ISteamFriends_GetFriendCount%(pThis%, EFriendFlags%) :"_BS_ISteamFriends_GetFriendCount@8" +BS_ISteamFriends_GetFriendByIndex%(pThis%, iFriend%, EFriendFlags%) :"_BS_ISteamFriends_GetFriendByIndex@12" +;! Returns: CSteamID*. Clean Up! +BS_ISteamFriends_GetFriendRelationship%(pThis%, pllFriend%) :"_BS_ISteamFriends_GetFriendRelationship@8" +BS_ISteamFriends_GetFriendPersonaState%(pThis%, pllFriend%) :"_BS_ISteamFriends_GetFriendPersonaState@8" +BS_ISteamFriends_GetFriendPersonaName$(pThis%, pllFriend%) :"_BS_ISteamFriends_GetFriendPersonaName@8" +BS_ISteamFriends_GetFriendGamePlayed%(pThis%, pllFriend%, pFriendGameInfo*) :"_BS_ISteamFriends_GetFriendGamePlayed@12" +BS_ISteamFriends_GetFriendGamePlayedEx%(pThis%, pllFriend%, pFriendGameInfo%) :"_BS_ISteamFriends_GetFriendGamePlayed@12" +BS_ISteamFriends_GetFriendPersonaNameHistory$(pThis%, pllFriend%, iDepth%) :"_BS_ISteamFriends_GetFriendPersonaNameHistory@12" +BS_ISteamFriends_GetFriendSteamLevel%(pThis%, pllFriend%) :"_BS_ISteamFriends_GetFriendSteamLevel@8" +BS_ISteamFriends_GetPlayerNickname$(pThis%, pllFriend%) :"_BS_ISteamFriends_GetPlayerNickname@8" +BS_ISteamFriends_GetFriendsGroupCount%(pThis%) :"_BS_ISteamFriends_GetFriendsGroupCount@4" +BS_ISteamFriends_GetFriendsGroupIDByIndex%(pThis%, iIndex%) :"_BS_ISteamFriends_GetFriendsGroupIDByIndex@8" +BS_ISteamFriends_GetFriendsGroupName$(pThis%, iGroupID%) :"_BS_ISteamFriends_GetFriendsGroupName@8" +BS_ISteamFriends_GetFriendsGroupMembersCount%(pThis%, iGroupID%) :"_BS_ISteamFriends_GetFriendsGroupMembersCount@8" +BS_ISteamFriends_GetFriendsGroupMembersList(pThis%, iGroupID%, pllMembers*, nMembersCount%):"_BS_ISteamFriends_GetFriendsGroupMembersList@16" +BS_ISteamFriends_GetFriendsGroupMembersListEx(pThis%, iGroupID%, pllMembers%, nMembersCount%):"_BS_ISteamFriends_GetFriendsGroupMembersList@16" +BS_ISteamFriends_HasFriend(pThis%, pllFriend%, EFriendFlags%) :"_BS_ISteamFriends_HasFriend@12" +BS_ISteamFriends_GetClanCount%(pThis%) :"_BS_ISteamFriends_GetClanCount@4" +BS_ISteamFriends_GetClanByIndex%(pThis%, iClan%) :"_BS_ISteamFriends_GetClanByIndex@8" +BS_ISteamFriends_GetClanName$(pThis%, llClanID%) :"_BS_ISteamFriends_GetClanName@8" +BS_ISteamFriends_GetClanTag$(pThis%, llClanID%) :"_BS_ISteamFriends_GetClanTag@8" +BS_ISteamFriends_GetClanActivityCounts%(pThis%, llClanID%, pnOnline*, pnInGame*, pnChatting*):"_BS_ISteamFriends_GetClanActivityCounts@20" +BS_ISteamFriends_GetClanActivityCountsEx%(pThis%, llClanID%, pnOnline%, pnInGame%, pnChatting%):"_BS_ISteamFriends_GetClanActivityCounts@20" +BS_ISteamFriends_DownloadClanActivityCounts%(pThis%, llClanID%, cClansToRequest%):"_BS_ISteamFriends_DownloadClanActivityCounts@12" +BS_ISteamFriends_GetFriendCountFromSource%(pThis%, llSourceID%) :"_BS_ISteamFriends_GetFriendCountFromSource@8" +BS_ISteamFriends_GetFriendFromSourceByIndex%(pThis%, llSourceID%, iFriend%) :"_BS_ISteamFriends_GetFriendFromSourceByIndex@12" +BS_ISteamFriends_IsUserInSource%(pThis%, llSteamID%, llSourceID%) :"_BS_ISteamFriends_IsUserInSource@12" +BS_ISteamFriends_SetInGameVoiceSpeaking(pThis%, llSteamID%, bSpeaking%) :"_BS_ISteamFriends_SetInGameVoiceSpeaking@12" +BS_ISteamFriends_ActivateGameOverlay(pThis%, cDialog$) :"_BS_ISteamFriends_ActivateGameOverlay@8" +BS_ISteamFriends_ActivateGameOverlayToUser(pThis%, cDialog$, llSteamID%) :"_BS_ISteamFriends_ActivateGameOverlayToUser@12" +BS_ISteamFriends_ActivateGameOverlayToWebPage(pThis%, cURL$) :"_BS_ISteamFriends_ActivateGameOverlayToWebPage@8" +BS_ISteamFriends_ActivateGameOverlayToStore(pThis%, nAppID%, EOverlayToStoreFlag%):"_BS_ISteamFriends_ActivateGameOverlayToStore@12" +BS_ISteamFriends_SetPlayedWith(pThis%, llSteamID%) :"_BS_ISteamFriends_SetPlayedWith@8" +BS_ISteamFriends_ActivateGameOverlayInviteDialog(pThis%, llLobbyID%) :"_BS_ISteamFriends_ActivateGameOverlayInviteDialog@8" +BS_ISteamFriends_GetSmallFriendAvatar%(pThis%, llSteamID%) :"_BS_ISteamFriends_GetSmallFriendAvatar@8" +BS_ISteamFriends_GetMediumFriendAvatar%(pThis%, llSteamID%) :"_BS_ISteamFriends_GetMediumFriendAvatar@8" +BS_ISteamFriends_GetLargeFriendAvatar%(pThis%, llSteamID%) :"_BS_ISteamFriends_GetLargeFriendAvatar@8" +BS_ISteamFriends_RequestUserInformation%(pThis%, llSteamID%, bNameOnly%) :"_BS_ISteamFriends_RequestUserInformation@12" +BS_ISteamFriends_RequestClanOfficerList%(pThis%, llClanID%) :"_BS_ISteamFriends_RequestClanOfficerList@8" +BS_ISteamFriends_GetClanOwner%(pThis%, llClanID%) :"_BS_ISteamFriends_GetClanOwner@8" +BS_ISteamFriends_GetClanOfficerCount%(pThis%, llClanID%) :"_BS_ISteamFriends_GetClanOfficerCount@8" +BS_ISteamFriends_GetClanOfficerByIndex%(pThis%, llClanID%, iOfficer%) :"_BS_ISteamFriends_GetClanOfficerByIndex@12" +;! Returns: CSteamID*. Clean Up! +BS_ISteamFriends_GetUserRestrictions%(pThis%) :"_BS_ISteamFriends_GetUserRestrictions@4" +BS_ISteamFriends_SetRichPresence%(pThis%, cKey$, cValue$) :"_BS_ISteamFriends_SetRichPresence@12" +BS_ISteamFriends_ClearRichPresence(pThis%) :"_BS_ISteamFriends_ClearRichPresence@4" +BS_ISteamFriends_GetFriendRichPresence$(pThis%, llSteamID%, cKey$) :"_BS_ISteamFriends_GetFriendRichPresence@12" +BS_ISteamFriends_GetFriendRichPresenceKeyCount%(pThis%, llSteamID%) :"_BS_ISteamFriends_GetFriendRichPresenceKeyCount@8" +BS_ISteamFriends_GetFriendRichPresenceKeyByIndex$(pThis%, llSteamID%, iKey%) :"_BS_ISteamFriends_GetFriendRichPresenceKeyByIndex@12" +BS_ISteamFriends_RequestFriendRichPresence(pThis%, llSteamID%) :"_BS_ISteamFriends_RequestFriendRichPresence@8" +BS_ISteamFriends_InviteUserToGame%(pThis%, llSteamID%, cConnectString%) :"_BS_ISteamFriends_InviteUserToGame@12" +BS_ISteamFriends_GetCoplayFriendCount%(pThis%) :"_BS_ISteamFriends_GetCoplayFriendCount@4" +BS_ISteamFriends_GetCoplayFriend%(pThis%, iCoplayFriend%) :"_BS_ISteamFriends_GetCoplayFriend@8" +;! Returns: CSteamID*. Clean Up! +BS_ISteamFriends_GetFriendCoplayTime%(pThis%, llSteamID%) :"_BS_ISteamFriends_GetFriendCoplayTime@8" +BS_ISteamFriends_GetFriendCoplayGame%(pThis%, llSteamID%) :"_BS_ISteamFriends_GetFriendCoplayGame@8" +BS_ISteamFriends_JoinClanChatRoom%(pThis%, llClanID%) :"_BS_ISteamFriends_JoinClanChatRoom@8" +;! Returns: SteamAPICall_t*. Clean Up! +BS_ISteamFriends_LeaveClanChatRoom%(pThis%, llClanID%) :"_BS_ISteamFriends_LeaveClanChatRoom@8" +BS_ISteamFriends_GetClanChatMemberCount%(pThis%, llClanID%) :"_BS_ISteamFriends_GetClanChatMemberCount@8" +BS_ISteamFriends_GetChatMemberByIndex%(pThis%, llClanID%, iUser%) :"_BS_ISteamFriends_GetChatMemberByIndex@12" +;! Returns: CSteamID*. Clean Up! +BS_ISteamFriends_SendClanChatMessage%(pThis%, llClanChatID%, cMessage$) :"_BS_ISteamFriends_SendClanChatMessage@12" +BS_ISteamFriends_GetClanChatMessage%(pThis%, llClanChatID%, iMessage%, pMessage*, iMessageSize%, pEChatEntryType*, pSteamID*):"_BS_ISteamFriends_GetClanChatMessage@28" +BS_ISteamFriends_GetClanChatMessageEx%(pThis%, llClanChatID%, iMessage%, pMessage%, iMessageSize%, peChatEntryType%, pSteamID%):"_BS_ISteamFriends_GetClanChatMessage@28" +BS_ISteamFriends_IsClanChatAdmin%(pThis%, llClanChatID%, llSteamID%) :"_BS_ISteamFriends_IsClanChatAdmin@12" +BS_ISteamFriends_IsClanChatWindowOpenInSteam%(pThis%, llClanChatID%) :"_BS_ISteamFriends_IsClanChatWindowOpenInSteam@8" +BS_ISteamFriends_OpenClanChatWindowInSteam%(pThis%, llClanChatID%) :"_BS_ISteamFriends_OpenClanChatWindowInSteam@8" +BS_ISteamFriends_CloseClanChatWindowInSteam%(pThis%, llClanChatID%) :"_BS_ISteamFriends_CloseClanChatWindowInSteam@8" +BS_ISteamFriends_SetListenForFriendsMessages%(pThis%, bInterceptEnabled%) :"_BS_ISteamFriends_SetListenForFriendsMessages@8" +BS_ISteamFriends_ReplyToFriendMessage%(pThis%, llSteamID%, cMessage$) :"_BS_ISteamFriends_ReplyToFriendMessage@12" +BS_ISteamFriends_GetFriendMessage%(pThis%, llSteamID%, iMessageID%, pData*, iDataSize%, pEChatEntryType*):"_BS_ISteamFriends_GetFriendMessage@24" +BS_ISteamFriends_GetFriendMessageEx%(pThis%, llSteamID%, iMessageID%, pData%, iDataSize%, pEChatEntryType%):"_BS_ISteamFriends_GetFriendMessage@24" +BS_ISteamFriends_GetFollowerCount%(pThis%, llSteamID%) :"_BS_ISteamFriends_GetFollowerCount@8" +;! Returns: SteamAPICall_t*. Clean Up! +BS_ISteamFriends_IsFollowing%(pThis%, llSteamID%) :"_BS_ISteamFriends_IsFollowing@8" +;! Returns: SteamAPICall_t*. Clean Up! +BS_ISteamFriends_EnumerateFollowingList%(pThis%, iStartIndex%) :"_BS_ISteamFriends_EnumerateFollowingList@8" +;! Returns: SteamAPICall_t*. Clean Up! \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamGameServer.decls b/#Test/userlibs/BlitzSteam_SteamGameServer.decls new file mode 100644 index 0000000..d91bf2c --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamGameServer.decls @@ -0,0 +1,77 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; GameServer ------------------------------------------------------------------ +BS_SteamGameServer_Init%(iIP%, sSteamPort%, sGamePort%, sQueryPort%, EServerMode%, cVersion$):"_BS_SteamGameServer_Init@24" +BS_SteamGameServer_Shutdown() :"_BS_SteamGameServer_Shutdown@0" +BS_SteamGameServer_RunCallbacks() :"_BS_SteamGameServer_RunCallbacks@0" +BS_SteamGameServer_GetHSteamPipe%() :"_BS_SteamGameServer_GetHSteamPipe@0" +BS_SteamGameServer_IsSecure%() :"_BS_SteamGameServer_IsSecure@0" +BS_SteamGameServer_GetSteamID%() :"_BS_SteamGameServer_GetSteamID@0" +;! Function above returns a CSteamID*, clean it up afterwards! +BS_SteamGameServer%() :"_BS_SteamGameServer@0" +BS_ISteamGameServer_InitGameServer%(pThis%, iIP%, sGamePort%, sQueryPort%, iFlags%, iAppId%, cVersion$):"_BS_ISteamGameServer_InitGameServer@24" +BS_ISteamGameServer_SetProduct(pThis%, cProduct$) :"_BS_ISteamGameServer_SetProduct@8" +BS_ISteamGameServer_SetGameDescription(pThis%, cDescription$) :"_BS_ISteamGameServer_SetGameDescription@8" +BS_ISteamGameServer_SetModDir(pThis%, cDirectory$) :"_BS_ISteamGameServer_SetModDir@8" +BS_ISteamGameServer_SetDedicatedServer(pThis%, bDedicated%) :"_BS_ISteamGameServer_SetDedicatedServer@8" +BS_ISteamGameServer_LogOn(pThis%, cToken$) :"_BS_ISteamGameServer_LogOn@8" +BS_ISteamGameServer_LogOnAnonymous(pThis%) :"_BS_ISteamGameServer_LogOnAnonymous@4" +BS_ISteamGameServer_LogOff(pThis%) :"_BS_ISteamGameServer_LogOff@4" +BS_ISteamGameServer_IsLoggedOn%(pThis%) :"_BS_ISteamGameServer_IsLoggedOn@4" +BS_ISteamGameServer_IsSecure%(pThis%) :"_BS_ISteamGameServer_IsSecure@4" +BS_ISteamGameServer_GetSteamID%(pThis%) :"_BS_ISteamGameServer_GetSteamID@4" +BS_ISteamGameServer_WasRestartRequested%(pThis%) :"_BS_ISteamGameServer_WasRestartRequested@4" +BS_ISteamGameServer_SetMaxPlayerCount(pThis%, iMaxPlayers%) :"_BS_ISteamGameServer_SetMaxPlayerCount@8" +BS_ISteamGameServer_SetBotPlayerCount(pThis%, iBotPlayers%) :"_BS_ISteamGameServer_SetBotPlayerCount@8" +BS_ISteamGameServer_SetServerName(pThis%, cName$) :"_BS_ISteamGameServer_SetServerName@8" +BS_ISteamGameServer_SetMapName(pThis%, cName$) :"_BS_ISteamGameServer_SetMapName@8" +BS_ISteamGameServer_SetPasswordProtected(pThis%, bPassworded%) :"_BS_ISteamGameServer_SetPasswordProtected@8" +BS_ISteamGameServer_SetSpectatorPort(pThis%, sPort%) :"_BS_ISteamGameServer_SetSpectatorPort@8" +BS_ISteamGameServer_SetSpectatorServerName(pThis%, cName$) :"_BS_ISteamGameServer_SetSpectatorServerName@8" +BS_ISteamGameServer_ClearAllKeyValues(pThis%) :"_BS_ISteamGameServer_ClearAllKeyValues@4" +BS_ISteamGameServer_SetKeyValue(pThis%, cKey$, cValue$) :"_BS_ISteamGameServer_SetKeyValue@12" +BS_ISteamGameServer_SetGameTags(pThis%, cTags$) :"_BS_ISteamGameServer_SetGameTags@8" +BS_ISteamGameServer_SetGameData(pThis%, cData$) :"_BS_ISteamGameServer_SetGameData@8" +BS_ISteamGameServer_SetRegion(pThis%, cRegion$) :"_BS_ISteamGameServer_SetRegion@8" +BS_ISteamGameServer_SendUserConnectAndAuthenticate%(pThis%, iIP%, pAuthBlob*, iAuthBlobSize%, lSteamId%):"_BS_ISteamGameServer_SendUserConnectAndAuthenticate@20" +BS_ISteamGameServer_SendUserConnectAndAuthenticateEx%(pThis%, iIP%, pAuthBlob%, iAuthBlobSize%, lSteamId%):"_BS_ISteamGameServer_SendUserConnectAndAuthenticate@20" +BS_ISteamGameServer_CreateUnauthenticatedUserConnection%(pThis%) :"_BS_ISteamGameServer_CreateUnauthenticatedUserConnection@4" +;! Function above returns a CSteamID*, clean it up afterwards! +BS_ISteamGameServer_SendUserDisconnect(pThis%, lSteamId%) :"_BS_ISteamGameServer_SendUserDisconnect@8" +BS_ISteamGameServer_UpdateUserData%(pThis%, lSteamId%, cName$, iScore%):"_BS_ISteamGameServer_UpdateUserData@16" +BS_ISteamGameServer_GetAuthSessionTicket%(pThis%, pTicket*, iTicketSize%, piTicketSize*):"_BS_ISteamGameServer_GetAuthSessionTicket@16" +BS_ISteamGameServer_GetAuthSessionTicketEx%(pThis%, pTicket%, iTicketSize%, piTicketSize%):"_BS_ISteamGameServer_GetAuthSessionTicket@16" +BS_ISteamGameServer_BeginAuthSession%(pThis%, pTicket*, iTicketSize%, lSteamId%):"_BS_ISteamGameServer_BeginAuthSession@16" +BS_ISteamGameServer_BeginAuthSessionEx%(pThis%, pTicket%, iTicketSize%, lSteamId%):"_BS_ISteamGameServer_BeginAuthSession@16" +BS_ISteamGameServer_EndAuthSession(pThis%, lSteamId%) :"_BS_ISteamGameServer_EndAuthSession@8" +BS_ISteamGameServer_CancelAuthTicket(pThis%, iAuthTicket%) :"_BS_ISteamGameServer_CancelAuthTicket@8" +BS_ISteamGameServer_UserHasLicenseForApp%(pThis%, lSteamId%, iAppId%) :"_BS_ISteamGameServer_UserHasLicenseForApp@12" +BS_ISteamGameServer_RequestUserGroupStatus%(pThis%, lSteamId%, pSteamIdGroup%) :"_BS_ISteamGameServer_RequestUserGroupStatus@12" +BS_ISteamGameServer_GetPublicIP%(pThis%) :"_BS_ISteamGameServer_GetPublicIP@4" +BS_ISteamGameServer_HandleIncomingPacket%(pThis%, pBuffer*, iBufferSize%, iIP%, sPort%):"_BS_ISteamGameServer_HandleIncomingPacket@20" +BS_ISteamGameServer_HandleIncomingPacketEx%(pThis%, pBuffer%, iBufferSize%, iIP%, sPort%):"_BS_ISteamGameServer_HandleIncomingPacket@20" +BS_ISteamGameServer_GetNextOutgoingPacket%(pThis%, pBuffer*, iBufferSize%, piIP*, psPort*):"_BS_ISteamGameServer_GetNextOutgoingPacket@20" +BS_ISteamGameServer_GetNextOutgoingPacketEx%(pThis%, pBuffer%, iBufferSize%, piIP%, psPort%):"_BS_ISteamGameServer_GetNextOutgoingPacket@20" +BS_ISteamGameServer_EnableHeartbeats(pThis%, bActive%) :"_BS_ISteamGameServer_EnableHeartbeats@8" +BS_ISteamGameServer_SetHeartbeatInterval(pThis%, iInterval%) :"_BS_ISteamGameServer_SetHeartbeatInterval@8" +BS_ISteamGameServer_ForceHeartbeat(pThis%) :"_BS_ISteamGameServer_ForceHeartbeat@4" +BS_ISteamGameServer_AssociateWithClan%(pThis%, pSteamIDClan%) :"_BS_ISteamGameServer_AssociateWithClan@8" +;! Function above returns a SteamAPICall_t*, clean it up afterwards! +BS_ISteamGameServer_ComputeNewPlayerCompatibility%(pThis%, pSteamIDNewPlayer%) :"_BS_ISteamGameServer_ComputeNewPlayerCompatibility@8" +;! Function above returns a SteamAPICall_t*, clean it up afterwards! diff --git a/#Test/userlibs/BlitzSteam_SteamGameServerStats.decls b/#Test/userlibs/BlitzSteam_SteamGameServerStats.decls new file mode 100644 index 0000000..61241d1 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamGameServerStats.decls @@ -0,0 +1,36 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; GameServerStats ------------------------------------------------------------- +BS_SteamGameServerStats%() :"_BS_SteamGameServerStats@0" +BS_ISteamGameServerStats_RequestUserStats%(pThis%, lSteamId%) :"_BS_ISteamGameServerStats_RequestUserStats@8" +;! Function above returns a SteamAPICall_t*, clean it up afterwards! +BS_ISteamGameServerStats_StoreUserStats%(pThis%, lSteamId%) :"_BS_ISteamGameServerStats_StoreUserStats@8" +;! Function above returns a SteamAPICall_t*, clean it up afterwards! +BS_ISteamGameServerStats_GetUserStat%(pThis%, lSteamId%, cName$, pData*) :"_BS_ISteamGameServerStats_GetUserStat@16" +BS_ISteamGameServerStats_GetUserStatEx%(pThis%, lSteamId%, cName$, pData%) :"_BS_ISteamGameServerStats_GetUserStat@16" +BS_ISteamGameServerStats_GetUserStatF%(pThis%, lSteamId%, cName$, pData*) :"_BS_ISteamGameServerStats_GetUserStatF@16" +BS_ISteamGameServerStats_GetUserStatFEx%(pThis%, lSteamId%, cName$, pData%) :"_BS_ISteamGameServerStats_GetUserStatF@16" +BS_ISteamGameServerStats_GetUserAchievement%(pThis%, lSteamId%, cName$, pbAchieved*):"_BS_ISteamGameServerStats_GetUserAchievement@16" +BS_ISteamGameServerStats_GetUserAchievementEx%(pThis%, lSteamId%, cName$, pbAchieved%):"_BS_ISteamGameServerStats_GetUserAchievement@16" +BS_ISteamGameServerStats_SetUserStat%(pThis%, lSteamId%, cName%, iData%) :"_BS_ISteamGameServerStats_SetUserStat@16" +BS_ISteamGameServerStats_SetUserStatF%(pThis%, lSteamId%, cName%, fData#) :"_BS_ISteamGameServerStats_SetUserStatF@16" +BS_ISteamGameServerStats_UpdateUserAvgRateStat%(pThis%, lSteamId%, cName$, fCountThisSession#, dSessionLength%):"_BS_ISteamGameServerStats_UpdateUserAvgRateStat@20" +;! Function above takes a Double* as last parameter. +BS_ISteamGameServerStats_SetUserAchievement%(pThis%, lSteamId%, cName$) :"_BS_ISteamGameServerStats_SetUserAchievement@12" +BS_ISteamGameServerStats_ClearUserAchievement%(pThis%, lSteamId%, cName$) :"_BS_ISteamGameServerStats_ClearUserAchievement@12" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamHTMLSurface.decls b/#Test/userlibs/BlitzSteam_SteamHTMLSurface.decls new file mode 100644 index 0000000..9e4dee5 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamHTMLSurface.decls @@ -0,0 +1,56 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; HTMLSurface ----------------------------------------------------------------- +BS_SteamHTMLSurface%() :"_BS_SteamHTMLSurface@0" +BS_ISteamHTMLSurface_Init%(pThis%) :"_BS_ISteamHTMLSurface_Init@4" +BS_ISteamHTMLSurface_Shutdown%(pThis%) :"_BS_ISteamHTMLSurface_Shutdown@4" +BS_ISteamHTMLSurface_CreateBrowser%(pThis%, cUserAgent$, cUserCSS$) :"_BS_ISteamHTMLSurface_CreateBrowser@12" +;! Function above returns a SteamAPICall_t*, clean it up afterwards! +BS_ISteamHTMLSurface_RemoveBrowser(pThis%, iHandle%) :"_BS_ISteamHTMLSurface_RemoveBrowser@8" +BS_ISteamHTMLSurface_LoadURL(pThis%, iHandle%, cURL$, cPostData$) :"_BS_ISteamHTMLSurface_LoadURL@16" +BS_ISteamHTMLSurface_SetSize(pThis%, iHandle%, iWidth%, iHeight%) :"_BS_ISteamHTMLSurface_SetSize@16" +BS_ISteamHTMLSurface_StopLoad(pThis%, iHandle%) :"_BS_ISteamHTMLSurface_StopLoad@8" +BS_ISteamHTMLSurface_Reload(pThis%, iHandle%) :"_BS_ISteamHTMLSurface_Reload@8" +BS_ISteamHTMLSurface_GoBack(pThis%, iHandle%) :"_BS_ISteamHTMLSurface_GoBack@8" +BS_ISteamHTMLSurface_GoForward(pThis%, iHandle%) :"_BS_ISteamHTMLSurface_GoForward@8" +BS_ISteamHTMLSurface_AddHeader(pThis%, iHandle%, cKey$, cValue$) :"_BS_ISteamHTMLSurface_AddHeader@16" +BS_ISteamHTMLSurface_ExecuteJavascript(pThis%, iHandle%, cScript$) :"_BS_ISteamHTMLSurface_ExecuteJavascript@12" +BS_ISteamHTMLSurface_MouseUp(pThis%, iHandle%, EMouseButton%) :"_BS_ISteamHTMLSurface_MouseUp@12" +BS_ISteamHTMLSurface_MouseDown(pThis%, iHandle%, EMouseButton%) :"_BS_ISteamHTMLSurface_MouseDown@12" +BS_ISteamHTMLSurface_MouseDoubleClick(pThis%, iHandle%, EMouseButton%) :"_BS_ISteamHTMLSurface_MouseDoubleClick@12" +BS_ISteamHTMLSurface_MouseMove(pThis%, iHandle%, X%, Y%) :"_BS_ISteamHTMLSurface_MouseMove@16" +BS_ISteamHTMLSurface_MouseWheel(pThis%, iHandle%, iDelta%) :"_BS_ISteamHTMLSurface_MouseWheel@12" +BS_ISteamHTMLSurface_KeyDown(pThis%, iHandle%, iKeyCode%, EHTMLKeyModifiers%) :"_BS_ISteamHTMLSurface_KeyDown@16" +BS_ISteamHTMLSurface_KeyUp(pThis%, iHandle%, iKeyCode%, EHTMLKeyModifiers%) :"_BS_ISteamHTMLSurface_KeyUp@16" +BS_ISteamHTMLSurface_KeyChar(pThis%, iHandle%, iUnicodeChar%, EHTMLKeyModifiers%):"_BS_ISteamHTMLSurface_KeyChar@16" +BS_ISteamHTMLSurface_SetHorizontalScroll(pThis%, iHandle%, iAbsolutePixelScroll%):"_BS_ISteamHTMLSurface_SetHorizontalScroll@16" +BS_ISteamHTMLSurface_SetVerticalScroll(pThis%, iHandle%, iAbsolutePixelScroll%) :"_BS_ISteamHTMLSurface_SetVerticalScroll@16" +BS_ISteamHTMLSurface_SetKeyFocus(pThis%, iHandle%, bHasKeyFocus%) :"_BS_ISteamHTMLSurface_SetKeyFocus@12" +BS_ISteamHTMLSurface_ViewSource(pThis%, iHandle%) :"_BS_ISteamHTMLSurface_ViewSource@8" +BS_ISteamHTMLSurface_CopyToClipboard(pThis%, iHandle%) :"_BS_ISteamHTMLSurface_CopyToClipboard@8" +BS_ISteamHTMLSurface_PasteFromClipboard(pThis%, iHandle%) :"_BS_ISteamHTMLSurface_PasteFromClipboard@8" +BS_ISteamHTMLSurface_Find(pThis%, iHandle%, cSearch$, bCurrentlyInFind%, bReverse%):"_BS_ISteamHTMLSurface_Find@20" +BS_ISteamHTMLSurface_StopFind(pThis%, iHandle%) :"_BS_ISteamHTMLSurface_StopFind@8" +BS_ISteamHTMLSurface_GetLinkAtPosition(pThis%, iHandle%, X%, Y%) :"_BS_ISteamHTMLSurface_GetLinkAtPosition@16" +BS_ISteamHTMLSurface_SetCookie(pThis%, iHandle%, cHostName$, cKey$, cValue$, cPath$, nExpires%, bSecure%, bHTTPOnly%):"_BS_ISteamHTMLSurface_SetCookie@36" +BS_ISteamHTMLSurface_SetPageScaleFactor(pThis%, iHandle%, fZoom#, iX%, iY%) :"_BS_ISteamHTMLSurface_SetPageScaleFactor@20" +BS_ISteamHTMLSurface_SetBackgroundMode(pThis%, iHandle%, bBackgroundMode%) :"_BS_ISteamHTMLSurface_SetBackgroundMode@12" +BS_ISteamHTMLSurface_AllowStartRequest(pThis%, iHandle%, bAllowed%) :"_BS_ISteamHTMLSurface_AllowStartRequest@12" +BS_ISteamHTMLSurface_JSDialogResponse(pThis%, iHandle%, bResult%) :"_BS_ISteamHTMLSurface_JSDialogResponse@12" +BS_ISteamHTMLSurface_FileLoadDialogResponse(pThis%, iHandle%, pcSelectedFiles%) :"_BS_ISteamHTMLSurface_FileLoadDialogResponse@12" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamHTTP.decls b/#Test/userlibs/BlitzSteam_SteamHTTP.decls new file mode 100644 index 0000000..e51d1df --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamHTTP.decls @@ -0,0 +1,54 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; HTTP ------------------------------------------------------------------------ +BS_SteamHTTP%() :"_BS_SteamHTTP@0" +BS_SteamGameServerHTTP%() :"_BS_SteamGameServerHTTP@0" +BS_ISteamHTTP_CreateHTTPRequest%(pThis%, EHTTPRequestMethod%, cAbsoluteUrl$) :"_BS_ISteamHTTP_CreateHTTPRequest@12" +BS_ISteamHTTP_SetHTTPRequestContextValue%(pThis%, iRequest%, lContextValue%) :"_BS_ISteamHTTP_SetHTTPRequestContextValue@12" +BS_ISteamHTTP_SetHTTPNetworkActivityTimeout%(pThis%, iRequest%, iSeconds%) :"_BS_ISteamHTTP_SetHTTPNetworkActivityTimeout@12" +BS_ISteamHTTP_SetHTTPRequestHeaderValue%(pThis%, iRequest%, cName$, cValue$) :"_BS_ISteamHTTP_SetHTTPRequestHeaderValue@16" +BS_ISteamHTTP_SetHTTPRequestGetOrPostParameter%(pThis%, iRequest%, cName$, cValue$):"_BS_ISteamHTTP_SetHTTPRequestGetOrPostParameter@16" +BS_ISteamHTTP_SendHTTPRequest%(pThis%, iRequest, lCallHandle%) :"_BS_ISteamHTTP_SendHTTPRequest@12" +BS_ISteamHTTP_SendHTTPRequestAndStreamResponse%(pThis%, iRequest%, lCallHandle%):"_BS_ISteamHTTP_SendHTTPRequestAndStreamResponse@12" +BS_ISteamHTTP_DeferHTTPRequest%(pThis%, iRequest%) :"_BS_ISteamHTTP_DeferHTTPRequest@8" +BS_ISteamHTTP_PrioritizeHTTPRequest%(pThis%, iRequest%) :"_BS_ISteamHTTP_PrioritizeHTTPRequest@8" +BS_ISteamHTTP_GetHTTPResponseHeaderSize%(pThis%, iRequest%, cName$, piSize*) :"_BS_ISteamHTTP_GetHTTPResponseHeaderSize@16" +BS_ISteamHTTP_GetHTTPResponseHeaderSizeEx%(pThis%, iRequest%, cName$, piSize%) :"_BS_ISteamHTTP_GetHTTPResponseHeaderSize@16" +BS_ISteamHTTP_GetHTTPResponseHeaderValue%(pThis%, iRequest%, cName$, pBuffer*, iSize%):"_BS_ISteamHTTP_GetHTTPResponseHeaderValue@20" +BS_ISteamHTTP_GetHTTPResponseHeaderValueEx%(pThis%, iRequest%, cName$, pBuffer%, iSize%):"_BS_ISteamHTTP_GetHTTPResponseHeaderValue@20" +BS_ISteamHTTP_GetHTTPResponseBodySize%(pThis%, iRequest%, piSize*) :"_BS_ISteamHTTP_GetHTTPResponseBodySize@12" +BS_ISteamHTTP_GetHTTPResponseBodySizeEx%(pThis%, iRequest%, piSize%) :"_BS_ISteamHTTP_GetHTTPResponseBodySize@12" +BS_ISteamHTTP_GetHTTPResponseBodyData%(pThis%, iRequest%, pBuffer*, nSize%) :"_BS_ISteamHTTP_GetHTTPResponseBodyData@16" +BS_ISteamHTTP_GetHTTPResponseBodyDataEx%(pThis%, iRequest%, pBuffer%, nSize%) :"_BS_ISteamHTTP_GetHTTPResponseBodyData@16" +BS_ISteamHTTP_GetHTTPStreamingResponseBodyData%(pThis%, iRequest%, iOffset%, pBuffer*, nSize%):"_BS_ISteamHTTP_GetHTTPStreamingResponseBodyData@20" +BS_ISteamHTTP_GetHTTPStreamingResponseBodyDataEx%(pThis%, iRequest%, iOffset%, pBuffer%, nSize%):"_BS_ISteamHTTP_GetHTTPStreamingResponseBodyData@20" +BS_ISteamHTTP_ReleaseHTTPRequest%(pThis%, iRequest%) :"_BS_ISteamHTTP_ReleaseHTTPRequest@8" +BS_ISteamHTTP_GetHTTPDownloadProgressPct%(pThis%, iRequest%, pfPercent*) :"_BS_ISteamHTTP_GetHTTPDownloadProgressPct@12" +BS_ISteamHTTP_GetHTTPDownloadProgressPctEx%(pThis%, iRequest%, pfPercent%) :"_BS_ISteamHTTP_GetHTTPDownloadProgressPct@12" +BS_ISteamHTTP_SetHTTPRequestRawPostBody%(pThis%, iRequest%, cType$, pBody*, nSize%):"_BS_ISteamHTTP_SetHTTPRequestRawPostBody@16" +BS_ISteamHTTP_SetHTTPRequestRawPostBodyEx%(pThis%, iRequest%, cType$, pBody*, nSize%):"_BS_ISteamHTTP_SetHTTPRequestRawPostBody@16" +BS_ISteamHTTP_CreateCookieContainer%(pThis%, bAllowResponsesToModify%) :"_BS_ISteamHTTP_CreateCookieContainer@8" +BS_ISteamHTTP_ReleaseCookieContainer%(pThis%, iCookieContainer%) :"_BS_ISteamHTTP_ReleaseCookieContainer@8" +BS_ISteamHTTP_SetCookie%(pthis%, iCookieContainer%, cHost$, cUrl$, cCookie$) :"_BS_ISteamHTTP_SetCookie@20" +BS_ISteamHTTP_SetHTTPRequestCookieContainer%(pThis%, iRequest%, iCookieContainer%):"_BS_ISteamHTTP_SetHTTPRequestCookieContainer@12" +BS_ISteamHTTP_SetHTTPRequestUserAgentInfo%(pThis%, iRequest%, cUserAgent$) :"_BS_ISteamHTTP_SetHTTPRequestUserAgentInfo@12" +BS_ISteamHTTP_SetHTTPRequestRequiresVerifiedCertificate%(pThis%, iRequest%, bRequire%):"_BS_ISteamHTTP_SetHTTPRequestRequiresVerifiedCertificate@12" +BS_ISteamHTTP_SetHTTPRequestAbsoluteTimeoutMS%(pThis%, iRequest%, iMilliseconds%):"_BS_ISteamHTTP_SetHTTPRequestAbsoluteTimeoutMS@12" +BS_ISteamHTTP_GetHTTPRequestWasTimedOut%(pThis%, iRequest%, pbWasTimedOut*) :"_BS_ISteamHTTP_GetHTTPRequestWasTimedOut@12" +BS_ISteamHTTP_GetHTTPRequestWasTimedOutEx%(pThis%, iRequest%, pbWasTimedOut%) :"_BS_ISteamHTTP_GetHTTPRequestWasTimedOut@12" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamInventory.decls b/#Test/userlibs/BlitzSteam_SteamInventory.decls new file mode 100644 index 0000000..adb6819 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamInventory.decls @@ -0,0 +1,59 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Inventory ------------------------------------------------------------------- +BS_SteamInventory%() :"_BS_SteamInventory@0" +BS_SteamGameServerInventory%() :"_BS_SteamGameServerInventory@0" +BS_ISteamInventory_GetResultStatus%(pThis%, iResultHandle%) :"_BS_ISteamInventory_GetResultStatus@8" +BS_ISteamInventory_GetResultItems%(pThis%, iResultHandle%, pItemsArray*, piItemsArraySize*):"_BS_ISteamInventory_GetResultItems@16" +BS_ISteamInventory_GetResultItemsEx%(pThis%, iResultHandle%, pItemsArray%, piItemsArraySize%):"_BS_ISteamInventory_GetResultItems@16" +BS_ISteamInventory_GetResultTimestamp%(pThis%, iResultHandle%) :"_BS_ISteamInventory_GetResultTimestamp@8" +BS_ISteamInventory_CheckResultSteamID%(pThis%, iResultHandle%, lSteamIdExpected%):"_BS_ISteamInventory_GetResultTimestamp@12" +BS_ISteamInventory_DestroyResult(pThis%, iResultHandle%) :"_BS_ISteamInventory_DestroyResult@8" +BS_ISteamInventory_GetAllItems%(pThis%, piResultHandle*) :"_BS_ISteamInventory_GetAllItems@8" +BS_ISteamInventory_GetAllItemsEx%(pThis%, piResultHandle%) :"_BS_ISteamInventory_GetAllItems@8" +BS_ISteamInventory_GetItemsByID%(pThis%, piResultHandle*, plInstanceIds*, iInstanceIdCount%):"_BS_ISteamInventory_GetItemsByID@16" +BS_ISteamInventory_GetItemsByIDEx%(pThis%, piResultHandle%, plInstanceIds%, iInstanceIdCount%):"_BS_ISteamInventory_GetItemsByID@16" +BS_ISteamInventory_SerializeResult%(pThis%, iResultHandle%, pOutBuffer*, piOutBufferSize*):"_BS_ISteamInventory_SerializeResult@16" +BS_ISteamInventory_SerializeResultEx%(pThis%, iResultHandle%, pOutBuffer%, piOutBufferSize%):"_BS_ISteamInventory_SerializeResult@16" +BS_ISteamInventory_DeserializeResult%(pThis%, piResultHandle*, pBuffer*, iBufferSize%, bReservedMustBeFalse):"_BS_ISteamInventory_DeserializeResult@20" +BS_ISteamInventory_DeserializeResultEx%(pThis%, piResultHandle%, pBuffer%, iBufferSize%, bReservedMustBeFalse):"_BS_ISteamInventory_DeserializeResult@20" +BS_ISteamInventory_GenerateItems%(pThis%, piResultHandle*, piIdArray*, piQuantityArray*, iArrayLength%):"_BS_ISteamInventory_GenerateItems@20" +BS_ISteamInventory_GenerateItemsEx%(pThis%, piResultHandle%, piIdArray%, piQuantityArray%, iArrayLength%):"_BS_ISteamInventory_GenerateItems@20" +BS_ISteamInventory_GrantPromoItems%(pThis%, piResultHandle*) :"_BS_ISteamInventory_GrantPromoItems@8" +BS_ISteamInventory_GrantPromoItemsEx%(pThis%, piResultHandle%) :"_BS_ISteamInventory_GrantPromoItems@8" +BS_ISteamInventory_AddPromoItem%(pThis%, piResultHandle*, iId%) :"_BS_ISteamInventory_AddPromoItem@12" +BS_ISteamInventory_AddPromoItemEx%(pThis%, piResultHandle%, iId%) :"_BS_ISteamInventory_AddPromoItem@12" +BS_ISteamInventory_AddPromoItems%(pThis%, piResultHandle*, piIdsArray*, iArrayLength%):"_BS_ISteamInventory_AddPromoItems@16" +BS_ISteamInventory_AddPromoItemsEx%(pThis%, piResultHandle%, piIdsArray%, iArrayLength%):"_BS_ISteamInventory_AddPromoItems@16" +BS_ISteamInventory_ConsumeItem%(pThis%, piResultHandle*, iId%, iQuantity%) :"_BS_ISteamInventory_ConsumeItem@16" +BS_ISteamInventory_ConsumeItemEx%(pThis%, piResultHandle%, iId%, iQuantity%) :"_BS_ISteamInventory_ConsumeItem@16" +BS_ISteamInventory_ExchangeItems%(pThis%, piResultHandle*, piGenerateArray*, piGenerateQuantityArray*, iArrayGenerateLength%, piDestroyArray*, piDestroyQuantityArray*, iArrayDestroyLength%):"_BS_ISteamInventory_ExchangeItems@32" +BS_ISteamInventory_ExchangeItemsEx%(pThis%, piResultHandle%, piGenerateArray%, piGenerateQuantityArray%, iArrayGenerateLength%, piDestroyArray%, piDestroyQuantityArray%, iArrayDestroyLength%):"_BS_ISteamInventory_ExchangeItems@32" +BS_ISteamInventory_TransferItemQuantity%(pThis%, piResultHandle*, iSourceId%, iQuantity%, iDestId%):"_BS_ISteamInventory_TransferItemQuantity@20" +BS_ISteamInventory_TransferItemQuantityEx%(pThis%, piResultHandle%, iSourceId%, iQuantity%, iDestId%):"_BS_ISteamInventory_TransferItemQuantity@20" +BS_ISteamInventory_SendItemDropHeartbeat%(pThis%) :"_BS_ISteamInventory_SendItemDropHeartbeat@4" +BS_ISteamInventory_TriggerItemDrop%(pThis%, piResultHandle*, iDropListId%) :"_BS_ISteamInventory_TriggerItemDrop@12" +BS_ISteamInventory_TriggerItemDropEx%(pThis%, piResultHandle%, iDropListId%) :"_BS_ISteamInventory_TriggerItemDrop@12" +BS_ISteamInventory_TradeItems%(pThis%, piResultHandle*, lSteamIdPartner%, piArrayGive*, piArrayGiveQuantity*, iArrayGiveLength%, piArrayGet*, piArrayGetQuantity*, iArrayGetLength%):"_BS_ISteamInventory_TradeItems@36" +BS_ISteamInventory_TradeItemsEx%(pThis%, piResultHandle%, lSteamIdPartner%, piArrayGive%, piArrayGiveQuantity%, iArrayGiveLength%, piArrayGet%, piArrayGetQuantity%, iArrayGetLength%):"_BS_ISteamInventory_TradeItems@36" +BS_ISteamInventory_LoadItemDefinitions%(pThis%) :"_BS_ISteamInventory_LoadItemDefinitions@4" +BS_ISteamInventory_GetItemDefinitionIDs%(pThis%, piArrayId*, piArrayIdSize*) :"_BS_ISteamInventory_GetItemDefinitionIDs@12" +BS_ISteamInventory_GetItemDefinitionIDsEx%(pThis%, piArrayId%, piArrayIdSize%) :"_BS_ISteamInventory_GetItemDefinitionIDs@12" +BS_ISteamInventory_GetItemDefinitionProperty%(pThis%, iId%, cName$, pcValueBuffer*, piValueBufferSize*):"_BS_ISteamInventory_GetItemDefinitionProperty@20" +BS_ISteamInventory_GetItemDefinitionPropertyEx%(pThis%, iId%, cName$, pcValueBuffer%, piValueBufferSize%):"_BS_ISteamInventory_GetItemDefinitionProperty@20" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamMatchmaking.decls b/#Test/userlibs/BlitzSteam_SteamMatchmaking.decls new file mode 100644 index 0000000..2923f02 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamMatchmaking.decls @@ -0,0 +1,21 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Matchmaking ----------------------------------------------------------------- +BS_SteamMatchmaking%() :"_BS_SteamMatchmaking@0" +; Todo \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamMatchmakingServers.decls b/#Test/userlibs/BlitzSteam_SteamMatchmakingServers.decls new file mode 100644 index 0000000..337e2f8 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamMatchmakingServers.decls @@ -0,0 +1,42 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; MatchmakingServers ---------------------------------------------------------- +BS_SteamMatchmakingServers%() :"_BS_SteamMatchmakingServers@0" +BS_ISteamMatchmakingServers_RequestInternetServerList%(pThis%, iApp%, ppchFilters*, nFilters%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestInternetServerList@20" +BS_ISteamMatchmakingServers_RequestInternetServerListEx%(pThis%, iApp%, ppchFilters%, nFilters%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestInternetServerList@20" +BS_ISteamMatchmakingServers_RequestLANServerList%(pThis%, iApp%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestLANServerList@12" +BS_ISteamMatchmakingServers_RequestFriendsServerList%(pThis%, iApp%, ppchFilters*, nFilters%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestFriendsServerList@20" +BS_ISteamMatchmakingServers_RequestFriendsServerListEx%(pThis%, iApp%, ppchFilters%, nFilters%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestFriendsServerList@20" +BS_ISteamMatchmakingServers_RequestFavoritesServerList%(pThis%, iApp%, ppchFilters*, nFilters%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestFavoritesServerList@20" +BS_ISteamMatchmakingServers_RequestFavoritesServerListEx%(pThis%, iApp%, ppchFilters%, nFilters%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestFavoritesServerList@20" +BS_ISteamMatchmakingServers_RequestHistoryServerList%(pThis%, iApp%, ppchFilters*, nFilters%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestHistoryServerList@20" +BS_ISteamMatchmakingServers_RequestHistoryServerListEx%(pThis%, iApp%, ppchFilters%, nFilters%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestHistoryServerList@20" +BS_ISteamMatchmakingServers_RequestSpectatorServerList%(pThis%, iApp%, ppchFilters*, nFilters%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestSpectatorServerList@20" +BS_ISteamMatchmakingServers_RequestSpectatorServerListEx%(pThis%, iApp%, ppchFilters%, nFilters%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_RequestSpectatorServerList@20" +BS_ISteamMatchmakingServers_ReleaseRequest%(pThis%, hServerListRequest%) :"_BS_ISteamMatchmakingServers_ReleaseRequest@8" +BS_ISteamMatchmakingServers_GetServerDetails%(pThis%, hRequest%, iServer%) :"_BS_ISteamMatchmakingServers_GetServerDetails@12" +BS_ISteamMatchmakingServers_CancelQuery%(pThis%, hRequest%) :"_BS_ISteamMatchmakingServers_CancelQuery@8" +BS_ISteamMatchmakingServers_RefreshQuery%(pThis%, hRequest%) :"_BS_ISteamMatchmakingServers_RefreshQuery@8" +BS_ISteamMatchmakingServers_IsRefreshing%(pThis%, hRequest%) :"_BS_ISteamMatchmakingServers_IsRefreshing@8" +BS_ISteamMatchmakingServers_GetServerCount%(pThis%, hRequest%) :"_BS_ISteamMatchmakingServers_GetServerCount@8" +BS_ISteamMatchmakingServers_RefreshServer%(pThis%, hRequest%) :"_BS_ISteamMatchmakingServers_RefreshServer@8" +BS_ISteamMatchmakingServers_PingServer%(pThis%, unIP%, usPort%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_PingServer@16" +BS_ISteamMatchmakingServers_PlayerDetails%(pThis%, unIP%, usPort%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_PlayerDetails@16" +BS_ISteamMatchmakingServers_ServerRules%(pThis%, unIP%, usPort%, pRequestServersResponse%):"_BS_ISteamMatchmakingServers_ServerRules@16" +BS_ISteamMatchmakingServers_CancelServerQuery%(pThis%, hServerQuery) :"_BS_ISteamMatchmakingServers_CancelServerQuery@8" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamMatchmakingTypes.decls b/#Test/userlibs/BlitzSteam_SteamMatchmakingTypes.decls new file mode 100644 index 0000000..47c09a7 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamMatchmakingTypes.decls @@ -0,0 +1,78 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; ISteamMatchmakingServerListResponse ----------------------------------------- +BS_ISteamMatchmakingServerListResponse_New%(Data%, pServerResponded%, pServerFailedToRespond%, pRefreshComplete%):"_BS_ISteamMatchmakingServerListResponse_New@16" +BS_ISteamMatchmakingServerListResponse_Destroy%(pThis%):"_BS_ISteamMatchmakingServerListResponse_Destroy@4" +;- Callback pServerResponded: Function(Data%, hRequest%, iServer%) +;- Callback pServerFailedToRespond: Function(Data%, hRequest%, iServer%) +;- Callback pRefreshComplete: Function(Data%) + +; ISteamMatchmakingPingResponse ----------------------------------------------- +BS_ISteamMatchmakingPingResponse_New%(Data%, pServerResponded%, pServerFailedToRespond%):"_BS_ISteamMatchmakingPingResponse_New@12" +BS_ISteamMatchmakingPingResponse_Destroy%(pThis%):"_BS_ISteamMatchmakingPingResponse_Destroy@4" +;- Callback pServerResponded: Function(Data%, TGameServerItem%) +;- Callback pServerFailedToRespond: Function(Data%) + +; ISteamMatchmakingPlayersResponse -------------------------------------------- +BS_ISteamMatchmakingPlayersResponse_New%(Data%, pAddPlayerToList%, pPlayersFailedToRespond%, pPlayersRefreshComplete%):"_BS_ISteamMatchmakingPlayersResponse_New@16" +BS_ISteamMatchmakingPlayersResponse_Destroy%(pThis%):"_BS_ISteamMatchmakingPlayersResponse_Destroy@4" +;- Callback pAddPlayerToList: Function(Data%, pchName%, nScore%, flTimePlayer#) +;- Callback pPlayersFailedToRespond: Function(Data%) +;- Callback pPlayersRefreshComplete: Function(Data%) + +; ISteamMatchmakingRulesResponse ---------------------------------------------- +BS_ISteamMatchmakingRulesResponse_New%(Data%, pRulesResponded%, pRulesFailedToRespond%, pRulesRefreshComplete%):"_BS_ISteamMatchmakingRulesResponse_New@16" +BS_ISteamMatchmakingRulesResponse_Destroy%(pThis%):"_BS_ISteamMatchmakingPlayersResponse_Destroy@4" +;- Callback pRulesResponded: Function(Data%, pchRule%, pchValue%) +;- Callback pRulesFailedToRespond: Function(Data%) +;- Callback pRulesRefreshComplete: Function(Data%) + +; TGameServerItem ------------------------------------------------------------- +BS_TGameServerItem_GetName$(pThis%) :"_BS_TGameServerItem_GetName@4" +BS_TGameServerItem_SetName(pThis%, cName$) :"_BS_TGameServerItem_SetName@8" +BS_TGameServerItem_NetAdr%(pThis%) :"_BS_TGameServerItem_NetAdr@4" +BS_TGameServerItem_Ping%(pThis%) :"_BS_TGameServerItem_Ping@4" +BS_TGameServerItem_HadSuccessfulResponse%(pThis%) :"_BS_TGameServerItem_HadSuccessfulResponse@4" +BS_TGameServerItem_DoNotRefresh%(pThis%) :"_BS_TGameServerItem_DoNotRefresh@4" +BS_TGameServerItem_GameDir$(pThis%) :"_BS_TGameServerItem_GameDir@4" +BS_TGameServerItem_Map$(pThis%) :"_BS_TGameServerItem_Map@4" +BS_TGameServerItem_GameDescription$(pThis%) :"_BS_TGameServerItem_GameDescription@4" +BS_TGameServerItem_AppId%(pThis%) :"_BS_TGameServerItem_AppId@4" +BS_TGameServerItem_Players%(pThis%) :"_BS_TGameServerItem_Players@4" +BS_TGameServerItem_MaxPlayers%(pThis%) :"_BS_TGameServerItem_MaxPlayers@4" +BS_TGameServerItem_BotPlayers%(pThis%) :"_BS_TGameServerItem_BotPlayers@4" +BS_TGameServerItem_Password%(pThis%) :"_BS_TGameServerItem_Password@4" +BS_TGameServerItem_Secure%(pThis%) :"_BS_TGameServerItem_Secure@4" +BS_TGameServerItem_TimeLastPlayed%(pThis%) :"_BS_TGameServerItem_TimeLastPlayed@4" +BS_TGameServerItem_ServerVersion%(pThis%) :"_BS_TGameServerItem_ServerVersion@4" +BS_TGameServerItem_GameTags$(pThis%) :"_BS_TGameServerItem_GameTags@4" +BS_TGameServerItem_SteamID%(pThis%) :"_BS_TGameServerItem_SteamID@4" + +; TServerNetAdr --------------------------------------------------------------- +BS_TServerNetAdr_Set(pThis%, pThat%) :"_BS_TServerNetAdr_Set@8" +BS_TServerNetAdr_Init(pThis%, iIP%, iQueryPort%, iConnectionPort%) :"_BS_TServerNetAdr_Init@16" +BS_TServerNetAdr_GetQueryPort%(pThis%) :"_BS_TServerNetAdr_GetQueryPort@4" +BS_TServerNetAdr_SetQueryPort(pThis%, iPort%) :"_BS_TServerNetAdr_SetQueryPort@8" +BS_TServerNetAdr_GetConnectionPort%(pThis%) :"_BS_TServerNetAdr_GetConnectionPort@4" +BS_TServerNetAdr_SetConnectionPort(pThis%, iPort%) :"_BS_TServerNetAdr_SetConnectionPort@8" +BS_TServerNetAdr_GetIP%(pThis%) :"_BS_TServerNetAdr_GetIP@4" +BS_TServerNetAdr_SetIP(pThis%, iIP%) :"_BS_TServerNetAdr_SetIP@8" +BS_TServerNetAdr_GetConnectionAddressString$(pThis%) :"_BS_TServerNetAdr_GetConnectionAddressString@4" +BS_TServerNetAdr_GetQueryAddressString$(pThis%) :"_BS_TServerNetAdr_GetQueryAddressString@4" +BS_TServerNetAdr_Compare%(pThis%, pThat%) :"_BS_TServerNetAdr_Compare@8" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamMusic.decls b/#Test/userlibs/BlitzSteam_SteamMusic.decls new file mode 100644 index 0000000..2294d38 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamMusic.decls @@ -0,0 +1,21 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Music ----------------------------------------------------------------------- +BS_SteamMusic%() :"_BS_SteamMusic@0" +; Todo diff --git a/#Test/userlibs/BlitzSteam_SteamMusicRemote.decls b/#Test/userlibs/BlitzSteam_SteamMusicRemote.decls new file mode 100644 index 0000000..2093ce9 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamMusicRemote.decls @@ -0,0 +1,21 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; MusicRemote ----------------------------------------------------------------- +BS_SteamMusicRemote%() :"_BS_SteamMusicRemote@0" +; Todo diff --git a/#Test/userlibs/BlitzSteam_SteamNetworking.decls b/#Test/userlibs/BlitzSteam_SteamNetworking.decls new file mode 100644 index 0000000..ecd6157 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamNetworking.decls @@ -0,0 +1,32 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Networking ------------------------------------------------------------------ +BS_SteamNetworking%() :"_BS_SteamNetworking@0" +BS_SteamGameServerNetworking%() :"_BS_SteamGameServerNetworking@0" +BS_ISteamNetworking_SendP2PPacket%(pThis%, lRemoteSteamId%, pData*, iDataSize%, EP2PSendType%, iChannel%):"_BS_ISteamNetworking_SendP2PPacket@24" +BS_ISteamNetworking_SendP2PPacketEx%(pThis%, lRemoteSteamId%, pData%, iDataSize%, EP2PSendType%, iChannel%):"_BS_ISteamNetworking_SendP2PPacket@24" +BS_ISteamNetworking_IsP2PPacketAvailable%(pThis%, piSize*, iChannel%) :"_BS_ISteamNetworking_IsP2PPacketAvailable@12" +BS_ISteamNetworking_IsP2PPacketAvailableEx%(pThis%, piSize%, iChannel%) :"_BS_ISteamNetworking_IsP2PPacketAvailable@12" +BS_ISteamNetworking_ReadP2PPacket%(pThis%, pBuffer*, iBufferSize%, piMessageSize*, plRemoteSteamId*, iChannel%):"_BS_ISteamNetworking_ReadP2PPacket@24" +BS_ISteamNetworking_ReadP2PPacketEx%(pThis%, pBuffer%, iBufferSize%, piMessageSize%, plRemoteSteamId%, iChannel%):"_BS_ISteamNetworking_ReadP2PPacket@24" +BS_ISteamNetworking_AcceptP2PSessionWithUser%(pThis%, lRemoteSteamId%) :"_BS_ISteamNetworking_AcceptP2PSessionWithUser@8" +BS_ISteamNetworking_CloseP2PSessionWithUser%(pThis%, lRemoteSteamId%) :"_BS_ISteamNetworking_CloseP2PSessionWithUser@8" +BS_ISteamNetworking_CloseP2PChannelWithUser%(pThis%, lRemoteSteamId%, iChannel%):"_BS_ISteamNetworking_CloseP2PChannelWithUser@12" +BS_ISteamNetworking_GetP2PSessionState%(pThis%, lRemoteSteamId%, pConnectionState*):"_BS_ISteamNetworking_GetP2PSessionState@12" +BS_ISteamNetworking_AllowP2PPacketRelay%(pThis%, bAllow%) :"_BS_ISteamNetworking_AllowP2PPacketRelay@8" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamRemoteStorage.decls b/#Test/userlibs/BlitzSteam_SteamRemoteStorage.decls new file mode 100644 index 0000000..ea3f10b --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamRemoteStorage.decls @@ -0,0 +1,21 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; RemoteStorage --------------------------------------------------------------- +BS_SteamRemoteStorage%() :"_BS_SteamRemoteStorage@0" +; Todo diff --git a/#Test/userlibs/BlitzSteam_SteamScreenshots.decls b/#Test/userlibs/BlitzSteam_SteamScreenshots.decls new file mode 100644 index 0000000..671fa4b --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamScreenshots.decls @@ -0,0 +1,21 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Screenshots ----------------------------------------------------------------- +BS_SteamScreenshots%() :"_BS_SteamScreenshots@0" +; Todo diff --git a/#Test/userlibs/BlitzSteam_SteamUGC.decls b/#Test/userlibs/BlitzSteam_SteamUGC.decls new file mode 100644 index 0000000..ce0a3e6 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamUGC.decls @@ -0,0 +1,22 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; UGC ------------------------------------------------------------------------- +BS_SteamUGC%() :"_BS_SteamUGC@0" +BS_SteamGameServerUGC%() :"_BS_SteamGameServerUGC@0" +; Todo diff --git a/#Test/userlibs/BlitzSteam_SteamUnifiedMessages.decls b/#Test/userlibs/BlitzSteam_SteamUnifiedMessages.decls new file mode 100644 index 0000000..84e4d38 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamUnifiedMessages.decls @@ -0,0 +1,20 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; UnifiedMessages ------------------------------------------------------------- +BS_SteamUnifiedMessages%() :"_BS_SteamUnifiedMessages@0" diff --git a/#Test/userlibs/BlitzSteam_SteamUser.decls b/#Test/userlibs/BlitzSteam_SteamUser.decls new file mode 100644 index 0000000..54037e4 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamUser.decls @@ -0,0 +1,49 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; User ------------------------------------------------------------------------ +BS_SteamUser%() :"_BS_SteamUser@0" +BS_ISteamUser_GetHSteamUser%(pThis%) :"_BS_ISteamUser_GetHSteamUser@4" +BS_ISteamUser_IsLoggedOn%(pThis%) :"_BS_ISteamUser_IsLoggedOn@4" +BS_ISteamUser_GetSteamID%(pThis%) :"_BS_ISteamUser_GetSteamID@4" +BS_ISteamUser_InitiateGameConnection%(pThis%, pAuthBlob*, iAuthBlobSize%, lSteamId%, iIp%, sPort%, bSecure%):"_BS_ISteamUser_InitiateGameConnection@28" +BS_ISteamUser_InitiateGameConnectionEx%(pThis%, pAuthBlob%, iAuthBlobSize%, lSteamId%, iIp%, sPort%, bSecure%):"_BS_ISteamUser_InitiateGameConnection@28" +BS_ISteamUser_TerminateGameConnection(pThis%, iIp%, sPort%) :"_BS_ISteamUser_TerminateGameConnection@12" +BS_ISteamUser_TrackAppUsageEvent(pThis%, iAppId%, EAppUsageEvent%, cExtraInfo$) :"_BS_ISteamUser_TrackAppUsageEvent@16" +BS_ISteamUser_GetUserDataFolder%(pThis%, pBuffer*, iBufferSize%) :"_BS_ISteamUser_GetUserDataFolder@12" +BS_ISteamUser_StartVoiceRecording(pThis%) :"_BS_ISteamUser_StartVoiceRecording@4" +BS_ISteamUser_StopVoiceRecording(pThis%) :"_BS_ISteamUser_StopVoiceRecording@4" +BS_ISteamUser_GetAvailableVoice%(pThis%, pCompressed*, pUncompressed*, nDesiredSampleRate%):"_BS_ISteamUser_GetAvailableVoice@16" +BS_ISteamUser_GetAvailableVoiceEx%(pThis%, pCompressed%, pUncompressed%, nDesiredSampleRate%):"_BS_ISteamUser_GetAvailableVoice@16" +BS_ISteamUser_GetVoice%(pThis%, bCompressed%, pCompressed*, iCompressedSize%, piCompressedBytesWritten*, bUncompressed%, pUncompressed*, iUncompressedSize%, piUncompressedBytesWritten*, iSampleRate%):"_BS_ISteamUser_GetVoice@36" +BS_ISteamUser_GetVoiceEx%(pThisEx%, bCompressed%, pCompressed%, iCompressedSize%, piCompressedBytesWritten%, bUncompressed%, pUncompressed%, iUncompressedSize%, piUncompressedBytesWritten%, iSampleRate%):"_BS_ISteamUser_GetVoice@36" +BS_ISteamUser_DecompressVoice(pThis%, pCompressed*, iCompressedSize%, pUncompressed*, iUncompressedSize%, iUncompressedBytesWritten*, iSampleRate%):"_BS_ISteamUser_DecompressVoice@28" +BS_ISteamUser_DecompressVoiceEx(pThis%, pCompressed*, iCompressedSize%, pUncompressed%, iUncompressedSize%, iUncompressedBytesWritten%, iSampleRate%):"_BS_ISteamUser_DecompressVoice@28" +BS_ISteamUser_GetVoiceOptimalSampleRate%(pThis%) :"_BS_ISteamUser_GetVoiceOptimalSampleRate@4" +BS_ISteamUser_GetAuthSessionTicket%(pThis%, pTicket*, iTicketSize%, piTicketSize*):"_BS_ISteamUser_GetAuthSessionTicket@16" +BS_ISteamUser_BeginAuthSession%(pThis%, pAuthTicket*, iAuthTicketSize%, lSteamId%):"_BS_ISteamUser_BeginAuthSession@16" +BS_ISteamUser_EndAuthSession(pThis%, lSteamId%) :"_BS_ISteamUser_EndAuthSession@8" +BS_ISteamUser_CancelAuthTicket(pThis%, hAuthTicket%) :"_BS_ISteamUser_CancelAuthTicket@8" +BS_ISteamUser_UserHasLicenseForApp%(pThis%, lSteamId%, iAppId%) :"_BS_ISteamUser_UserHasLicenseForApp@12" +BS_ISteamUser_IsBehindNAT%(pThis%) :"_BS_ISteamUser_IsBehindNAT@4" +BS_ISteamUser_AdvertiseGame%(pThis%, lSteamId%, iIp%, sPort%) :"_BS_ISteamUser_AdvertiseGame@16" +BS_ISteamUser_RequestEncryptedAppTicket%(pThis%, pData*, iDataSize%) :"_BS_ISteamUser_RequestEncryptedAppTicket@12" +BS_ISteamUser_GetEncryptedAppTicket%(pThis%, pTicket*, iTicketSize%, piTicketSize*):"_BS_ISteamUser_GetEncryptedAppTicket@16" +BS_ISteamUser_GetGameBadgeLevel%(pThis%, iSeries%, bFoil%) :"_BS_ISteamUser_GetGameBadgeLevel@12" +BS_ISteamUser_GetPlayerSteamLevel%(pThis%) :"_BS_ISteamUser_GetPlayerSteamLevel@4" +BS_ISteamUser_RequestStoreAuthURL%(pThis%, cRedirectUrl$) :"_BS_ISteamUser_RequestStoreAuthURL@8" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamUserStats.decls b/#Test/userlibs/BlitzSteam_SteamUserStats.decls new file mode 100644 index 0000000..8f04e41 --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamUserStats.decls @@ -0,0 +1,77 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; UserStats ------------------------------------------------------------------- +BS_UserStats%() :"_BS_UserStats@0" +BS_UserStats_RequestCurrentStats%(pThis%) :"_BS_UserStats_RequestCurrentStats@4" +BS_UserStats_GetStat%(pThis%, cName$, pData*) :"_BS_UserStats_GetStat@12" +BS_UserStats_GetStatEx%(pThis%, cName$, pData%) :"_BS_UserStats_GetStat@12" +BS_UserStats_GetStatF%(pThis%, cName$, pData*) :"_BS_UserStats_GetStatF@12" +BS_UserStats_GetStatFEx%(pThis%, cName$, pData%) :"_BS_UserStats_GetStatF@12" +BS_UserStats_SetStat%(pThis%, cName$, pData%) :"_BS_UserStats_SetStat@12" +BS_UserStats_SetStatF%(pThis%, cName$, pData#) :"_BS_UserStats_SetStatF@12" +BS_UserStats_UpdateAvgRateStat%(pThis%, cName$, fCountThisSession#, dSessionLength%):"_BS_UserStats_UpdateAvgRateStat@16" +BS_UserStats_GetAchievement%(pThis%, cName$, pbAchieved*) :"_BS_UserStats_GetAchievement@12" +BS_UserStats_GetAchievementEx%(pThis%, cName$, pbAchieved%) :"_BS_UserStats_GetAchievement@12" +BS_UserStats_SetAchievement%(pThis%, cName$) :"_BS_UserStats_SetAchievement@8" +BS_UserStats_ClearAchievement%(pThis%, cName$) :"_BS_UserStats_ClearAchievement@8" +BS_UserStats_GetAchievementAndUnlockTime%(pThis%, cName$, pbAchieved*, piUnlockTime*):"_BS_UserStats_GetAchievementAndUnlockTime@16" +BS_UserStats_GetAchievementAndUnlockTimeEx%(pThis%, cName$, pbAchieved%, piUnlockTime%):"_BS_UserStats_GetAchievementAndUnlockTime@16" +BS_UserStats_StoreStats%(pThis%) :"_BS_UserStats_StoreStats@4" +BS_UserStats_GetAchievementIcon%(pThis%, cName$) :"_BS_UserStats_GetAchievementIcon@8" +BS_UserStats_GetAchievementDisplayAttribute$(pThis%, cName$, cKey$) :"_BS_UserStats_GetAchievementDisplayAttribute@12" +BS_UserStats_IndicateAchievementProgress%(pThis%, cName$, iProgress%, iMaxProgress%):"_BS_UserStats_IndicateAchievementProgress@16" +BS_UserStats_GetNumAchievements%(pThis%) :"_BS_UserStats_GetNumAchievements@4" +BS_UserStats_GetAchievementName$(pThis%, iAchievement%) :"_BS_UserStats_GetAchievementName@8" +BS_UserStats_RequestUserStats%(pThis%, lSteamId%) :"_BS_UserStats_RequestUserStats@8" +BS_UserStats_GetUserStat%(pThis%, lSteamId%, cName$, pData*) :"_BS_UserStats_GetUserStat@16" +BS_UserStats_GetUserStatEx%(pThis%, lSteamId%, cName$, pData%) :"_BS_UserStats_GetUserStat@16" +BS_UserStats_GetUserStatF%(pThis%, lSteamId%, cName$, pData*) :"_BS_UserStats_GetUserStatF@16" +BS_UserStats_GetUserStatFEx%(pThis%, lSteamId%, cName$, pData%) :"_BS_UserStats_GetUserStatF@16" +BS_UserStats_GetUserAchievement%(pThis%, lSteamId%, cName$, pbAchieved*) :"_BS_UserStats_GetUserAchievement@16" +BS_UserStats_GetUserAchievementEx%(pThis%, lSteamId%, cName$, pbAchieved%) :"_BS_UserStats_GetUserAchievement@16" +BS_UserStats_GetUserAchievementAndUnlockTime%(pThis%, lSteamId%, cName$, pbAchieved*, piUnlockTime*):"_BS_UserStats_GetUserAchievementAndUnlockTime@20" +BS_UserStats_GetUserAchievementAndUnlockTimeEx%(pThis%, lSteamId%, cName$, pbAchieved%, piUnlockTime%):"_BS_UserStats_GetUserAchievementAndUnlockTime@20" +BS_UserStats_ResetAllStats%(pThis%, bAchievementsToo%) :"_BS_UserStats_ResetAllStats@8" +BS_UserStats_FindOrCreateLeaderboard%(pThis%, cLeaderboardName$, eLeaderboardSortMethod%, eLeaderboardDisplayType%):"_BS_UserStats_FindOrCreateLeaderboard@16" +BS_UserStats_FindLeaderboard%(pThis%, cLeaderboardName$) :"_BS_UserStats_FindLeaderboard@8" +BS_UserStats_GetLeaderboardName$(pThis%, hSteamLeaderboard%) :"_BS_UserStats_GetLeaderboardName@8" +BS_UserStats_GetLeaderboardEntryCount%(pThis%, hSteamLeaderboard%) :"_BS_UserStats_GetLeaderboardEntryCount@8" +BS_UserStats_GetLeaderboardSortMethod%(pThis%, hSteamLeaderboard%) :"_BS_UserStats_GetLeaderboardSortMethod@8" +BS_UserStats_GetLeaderboardDisplayType%(pThis%, hSteamLeaderboard%) :"_BS_UserStats_GetLeaderboardDisplayType@8" +BS_UserStats_DownloadLeaderboardEntries%(pThis%, hSteamLeaderboard%, eLeaderboardDataRequest%, iRangeStart%, iRangeEnd%):"_BS_UserStats_DownloadLeaderboardEntries@20" +BS_UserStats_DownloadLeaderboardEntriesForUsers%(pThis%, hSteamLeaderboard%, plUsers*, iUserCount%):"_BS_UserStats_DownloadLeaderboardEntriesForUsers@16" +BS_UserStats_DownloadLeaderboardEntriesForUsersEx%(pThis%, hSteamLeaderboard%, plUsers%, iUserCount%):"_BS_UserStats_DownloadLeaderboardEntriesForUsers@16" +BS_UserStats_GetDownloadedLeaderboardEntry%(lpSteamUsers%, hSteamLeaderboardEntries%, iIndex%, pLeaderboardEntry*, pDetails*, iDetailsMax%):"_BS_UserStats_GetDownloadedLeaderboardEntry@24" +BS_UserStats_GetDownloadedLeaderboardEntryEx%(lpSteamUsers%, hSteamLeaderboardEntries%, iIndex%, pLeaderboardEntry%, pDetails%, iDetailsMax%):"_BS_UserStats_GetDownloadedLeaderboardEntry@24" +BS_UserStats_UploadLeaderboardScore%(pThis%, hSteamLeaderboard%, eLeaderboardUploadScoreMethod%, iScore%, pScoreDetails*, iScoreDetailsCount%):"_BS_UserStats_UploadLeaderboardScore@24" +BS_UserStats_UploadLeaderboardScoreEx%(pThis%, hSteamLeaderboard%, eLeaderboardUploadScoreMethod%, iScore%, pScoreDetails%, iScoreDetailsCount%):"_BS_UserStats_UploadLeaderboardScore@24" +BS_UserStats_AttachLeaderboardUGC%(pThis%, hSteamLeaderboard%, hUGC%) :"_BS_UserStats_AttachLeaderboardUGC@12" +BS_UserStats_GetNumberOfCurrentPlayers%(pThis%) :"_BS_UserStats_GetNumberOfCurrentPlayers@4" +BS_UserStats_RequestGlobalAchievementPercentages%(pThis%) :"_BS_UserStats_RequestGlobalAchievementPercentages@4" +BS_UserStats_GetMostAchievedAchievementInfo%(pThis%, cName$, iNameLength%, pfPercent*, pbAchieved*):"_BS_UserStats_GetMostAchievedAchievementInfo@20" +BS_UserStats_GetMostAchievedAchievementInfoEx%(pThis%, cName$, iNameLength%, pfPercent%, pbAchieved%):"_BS_UserStats_GetMostAchievedAchievementInfo@20" +BS_UserStats_GetNextMostAchievedAchievementInfo%(pThis%, iIteratorPrevious%, cName$, iNameLength%, pfPercent*, pbAchieved*):"_BS_UserStats_GetNextMostAchievedAchievementInfo@24" +BS_UserStats_GetNextMostAchievedAchievementInfoEx%(pThis%, iIteratorPrevious%, cName$, iNameLength%, pfPercent%, pbAchieved%):"_BS_UserStats_GetNextMostAchievedAchievementInfo@24" +BS_UserStats_GetAchievementAchievedPercent%(pThis%, cName$, pfPercent*) :"_BS_UserStats_GetAchievementAchievedPercent@12" +BS_UserStats_GetAchievementAchievedPercentEx%(pThis%, cName$, pfPercent%) :"_BS_UserStats_GetAchievementAchievedPercent@12" +BS_UserStats_RequestGlobalStats%(pThis%, iHistoryDays%) :"_BS_UserStats_RequestGlobalStats@8" +BS_UserStats_GetGlobalStatL%(pThis, cStatName$, plData%) :"_BS_UserStats_GetGlobalStatL@12" +BS_UserStats_GetGlobalStatD%(pThis, cStatName$, pdData%) :"_BS_UserStats_GetGlobalStatD@12" +BS_UserStats_GetGlobalStatHistoryL%(pThis, cStatName$, plDataArray%, iDataSize%):"BS_UserStats_GetGlobalStatHistoryL@16" +BS_UserStats_GetGlobalStatHistoryD%(pThis, cStatName$, pdDataArray%, iDataSize%):"BS_UserStats_GetGlobalStatHistoryD@16" \ No newline at end of file diff --git a/#Test/userlibs/BlitzSteam_SteamUtils.decls b/#Test/userlibs/BlitzSteam_SteamUtils.decls new file mode 100644 index 0000000..25c78ab --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamUtils.decls @@ -0,0 +1,21 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Utils ----------------------------------------------------------------------- +BS_SteamUtils%() :"_BS_SteamUtils@0" +BS_SteamGameServerUtils%() :"_BS_SteamGameServerUtils@0" diff --git a/#Test/userlibs/BlitzSteam_SteamVideo.decls b/#Test/userlibs/BlitzSteam_SteamVideo.decls new file mode 100644 index 0000000..f86493c --- /dev/null +++ b/#Test/userlibs/BlitzSteam_SteamVideo.decls @@ -0,0 +1,20 @@ +; BlitzSteam - Steam wrapper for Blitz +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzSteam.dll" + +; Utils ----------------------------------------------------------------------- +BS_SteamVideo%() :"_BS_SteamVideo@0" diff --git a/#Test/userlibs/BlitzUtility.decls b/#Test/userlibs/BlitzUtility.decls new file mode 100644 index 0000000..4fe90cd --- /dev/null +++ b/#Test/userlibs/BlitzUtility.decls @@ -0,0 +1,306 @@ +; BlitzUtility - Expanding the normal Blitz functionality. +; Copyright (C) 2015 Xaymar (Michael Fabian Dirks) +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as +; published by the Free Software Foundation, either version 3 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this program. If not, see . + +.lib "BlitzUtility.dll" +; Container ------------------------------------------------------------------- +; -- List (Single Element) +BU_List_Create%(element*) +BU_List_Destroy%(list%) +BU_List_First%(list%) +BU_List_Last%(list%) +BU_List_Previous%(list%) +BU_List_Next%(list%) +BU_List_Before%(list%, other*) +BU_List_After%(list%, other*) +BU_List_Insert(list%, element*) +BU_List_InsertEx(list%, element*, other*) +BU_List_Remove(list%, element*) +; -- TypeList (Single Type) +BU_TypeList_Create%(obj*) +BU_TypeList_Activate(list%) +BU_TypeList_Deactivate(list%) +BU_TypeList_Destroy(list%) + +; Database -------------------------------------------------------------------- +; -- SQLite3 +; Core +BU_SQLite_Version$() +BU_SQLite_Version_Number%() +BU_SQLite_SourceID$() +BU_SQLite_CompileOption_Used%(zOptName$) +BU_SQLite_CompileOption_Get$(n%) +BU_SQLite_ThreadSafe%() +BU_SQLite_Initialize%() +BU_SQLite_Shutdown%() +BU_SQLite_Sleep%(ms%) +; Open & Close +BU_SQLite_Open%(file$, db*) +BU_SQLite_Open_V2%(file$, db*, flags%, zVfs$) +BU_SQLite_Open_V2Ex%(file$, db*, flags%, zVfs%) : "BU_SQLite_Open_V2" +BU_SQLite_Close%(db%) +BU_SQLite_Close_V2%(db%) +BU_SQLite_OpenSimple%(file$) +BU_SQLite_OpenSimple_V2%(file$, flags%, zVfs$) +BU_SQLite_OpenSimple_V2Ex%(file$, flags%, zVfs%) : "BU_SQLite_OpenSimple_V2" +BU_SQLite_OpenSimpleError%() +; Error Handling +BU_SQLite_Error_Code%(db%) +BU_SQLite_Extended_Error_Code%(db%) +BU_SQLite_Error_Message$(db%) +BU_SQLite_Error_String$(errorCode%) +BU_SQLite_Extended_Result_Codes%(db%, onoff%) +; Busy Handler +BU_SQLite_Busy_Timeout%(db%, timeout%) +BU_SQLite_Busy_Handler%(db%, pHandlerFunction3IPI%, param%) +BU_SQLite_Busy_Handler_Simple%(db%, pHandlerFunc2II%) +; Memory Management +BU_SQLite_Memory_Used%() +BU_SQLite_Memory_Highwater%(bReset%) +BU_SQLite_Release_Memory%(bytes%) +BU_SQLite_DB_Release_Memory%(db%) +BU_SQLite_Randomness(n%, pBank*) +; Database Management & Modification +BU_SQLite_Exec%(db%, sql$, pCallback3PIPP%, param%, errMsg*) +BU_SQLite_ExecEx%(db%, sql$, pCallback3PIPP%, param%, errMsg%) : "BU_SQLite_Exec" +BU_SQLite_Last_Insert_RowId%(db%) +BU_SQLite_Changes%(db%) +BU_SQLite_Total_Changes%(db%) +BU_SQLite_Interrupt(db%) +BU_SQLite_Complete%(sql$) +BU_SQLite_Get_Table%(db, zSql$, pazResult*, pnRow*, pnColumn*, pzErrMessage*) +BU_SQLite_Free_Table%(result*) +BU_SQLite_Set_Authorizer%(db%, pAuth5PIPPPP, pArg%) +BU_SQLite_Trace%(db%, pTrace1PP, pArg%) +BU_SQLite_Profile%(db%, pProfile2PPI, pArg%) +BU_SQLite_Progress_Handler%(db%, nOps%, pProgress1IP%, pArg%) +BU_SQLite_URI_Parameter$(zFilename$, zParam$) +BU_SQLite_URI_Boolean%(zFilename$, zParam$, bDefault%) +BU_SQLite_URI_LongLong%(zFilename$, zParam$, bDefault%) +BU_SQLite_Limit%(db%, id%, newVal%) +; Prepared Statements +BU_SQLite_Next_Statement%(db%, pStmt%) +BU_SQLite_Prepare%(db%, zSql$, nByte%, ppStmt*) +BU_SQLite_PrepareEx%(db%, zSql$, nByte%, ppStmt%) : "BU_SQLite_Prepare" +BU_SQLite_Prepare_V2%(db%, zSql$, nByte%, ppStmt*) +BU_SQLite_Prepare_V2Ex%(db%, zSql$, nByte%, ppStmt%) : "BU_SQLite_Prepare_V2" +BU_SQLite_Statement_ReadOnly%(pStmt%) +BU_SQLite_Statement_Busy%(pStmt%) +BU_SQLite_Statement_Status%(pStmt%, op%, resetFlag%) +BU_SQLite_SQL$(pStmt%) +BU_SQLite_Database_Handle%(pStmt%) +BU_SQLite_Bind_Null%(pStmt%, index%) +BU_SQLite_Bind_Int%(pStmt%, index%, value%) +BU_SQLite_Bind_LongLong%(pStmt%, index%, pValue%) +BU_SQLite_Bind_Float%(pStmt%, index%, value#) +BU_SQLite_Bind_Double%(pStmt%, index%, pValue%) +BU_SQLite_Bind_Text%(pStmt%, index%, zData$, nData%) +BU_SQLite_Bind_Blob%(pStmt%, index%, zData$, nData%) +BU_SQLite_Bind_Value%(pStmt%, index%, pValue%) +BU_SQLite_Bind_ZeroBlob%(pStmt%, index%, bytes%) +BU_SQLite_Bind_Parameter_Count%(pStmt%) +BU_SQLite_Bind_Parameter_Name$(pStmt%, index%) +BU_SQLite_Bind_Parameter_Index%(pStmt%, zName$) +BU_SQLite_Clear_Bindings%(pStmt%) +BU_SQLite_Column_Count%(pStmt%) +BU_SQLite_Column_Name$(pStmt%, index%) +BU_SQLite_Column_DeclaredType$(pStmt%, index%) +BU_SQLite_Step%(pStmt%) +BU_SQLite_Data_Count%(pStmt%) +BU_SQLite_Column_Blob%(pStmt%, iCol%) +BU_SQLite_Column_Bytes%(pStmt%, iCol%) +BU_SQLite_Column_Float%(pStmt%, iCol%) +BU_SQLite_Column_Double%(pStmt%, iCol%) +BU_SQLite_Column_Int%(pStmt%, iCol%) +BU_SQLite_Column_LongLong%(pStmt%, iCol%) +BU_SQLite_Column_Text$(pStmt%, iCol%) +BU_SQLite_Column_Value%(pStmt%, iCol%) +BU_SQLite_Column_Type%(pStmt%, iCol%) +BU_SQLite_Finalize%(pStmt%) +BU_SQLite_Reset%(pStmt%) +; SQLite Values +BU_SQLite_Value_Blob%(pValue%) +BU_SQLite_Value_Bytes%(pValue%) +BU_SQLite_Value_Int%(pValue%) +BU_SQLite_Value_LongLong%(pValue%) +BU_SQLite_Value_Float#(pValue%) +BU_SQLite_Value_Double%(pValue%) +BU_SQLite_Value_Text$(pValue%) +BU_SQLite_Value_Type%(pValue%) +BU_SQLite_Value_Numeric_Type%(pValue%) +BU_SQLite_Value_SubType%(pValue%) +BU_SQLite_Value_Duplicate%(pValue%) +BU_SQLite_Value_Free(pValue%) + +; Time ------------------------------------------------------------------------ +; -- Time +BU_Time_Now%() +BU_Time_Create%(seconds%, minutes%, hours%, days%, months%, years%, isDST%) +BU_Time_Destroy(pTime%) +BU_Time_Format$(pTime%, formatString$) +; -- Timer +BU_Timer_Create%(Interval%, hwnd%) : "_BU_Timer_Create@8" +BU_Timer_Destroy%(Timer%) : "_BU_Timer_Destroy@4" +BU_Timer_Wait%(Timer%) : "_BU_Timer_Wait@4" +; -- SystemClock +BU_SystemClock_Now%() +BU_SystemClock_Destroy(pSystemClock%) +BU_SystemClock_FromTime%(pTime%) +BU_SystemClock_AsTime%(pSystemClock%) +; -- HighResolutionClock +BU_HighResolutionClock_Now%() +BU_HighResolutionClock_Destroy(pHighResolutionClock%) +BU_HighResolutionClock_Duration%(pHighResolutionClock%, pOther%) +BU_HighResolutionClock_DurationLL%(pHighResolutionClock%, pOther%) +BU_HighResolutionClock_DurationF#(pHighResolutionClock%, pOther%) +BU_HighResolutionClock_DurationD%(pHighResolutionClock%, pOther%) + +; Types - Long ---------------------------------------------------------------- +BU_Long_New%() :"_BU_Long_New@0" +BU_Long_Copy%(pThis%) :"_BU_Long_Copy@4" +BU_Long_Destroy(pThis%) :"_BU_Long_Destroy@4" +BU_Long_ToString$(pThis%) :"_BU_Long_ToString@4" +BU_Long_FromString%(cString$) :"_BU_Long_FromString@4" +BU_Long_FromI%(iRight%) :"_BU_Long_FromI@4" +BU_Long_FromII%(iLeft%, iRight%) :"_BU_Long_FromII@8" +BU_Long_ToI%(pThis%, iShift%) :"_BU_Long_ToI@8" +BU_Long_ToIH%(pThis%) :"_BU_Long_ToIH@4" +BU_Long_ToIL%(pThis%) :"_BU_Long_ToIL@4" +BU_Long_FromF%(Float#) :"_BU_Long_FromF@4" +BU_Long_ToF#(pThis%) :"_BU_Long_ToF@4" +BU_Long_FromD(pDouble%) :"_BU_Long_FromD@4" +BU_Long_ToD(pThis%) :"_BU_Long_ToD@4" +BU_Long_Compare%(pThis%, pRight%) :"_BU_Long_Compare@8" +BU_Long_Set%(pThis%, pOther%) :"_BU_Long_Set@8" +BU_Long_Add%(pThis%, pOther%) :"_BU_Long_Add@8" +BU_Long_Sub%(pThis%, pOther%) :"_BU_Long_Sub@8" +BU_Long_Div%(pThis%, pOther%) :"_BU_Long_Div@8" +BU_Long_Mul%(pThis%, pOther%) :"_BU_Long_Mul@8" +BU_Long_Mod%(pThis%, pOther%) :"_BU_Long_Mod@8" +BU_Long_SetI%(pThis%, iRight%) :"_BU_Long_SetI@8" +BU_Long_AddI%(pThis%, iRight%) :"_BU_Long_AddI@8" +BU_Long_SubI%(pThis%, iRight%) :"_BU_Long_SubI@8" +BU_Long_DivI%(pThis%, iRight%) :"_BU_Long_DivI@8" +BU_Long_MulI%(pThis%, iRight%) :"_BU_Long_MulI@8" +BU_Long_ModI%(pThis%, iRight%) :"_BU_Long_ModI@8" +BU_Long_SetII%(pThis%, iLeft%, iRight%) :"_BU_Long_SetII@12" +BU_Long_AddII%(pThis%, iLeft%, iRight%) :"_BU_Long_AddII@12" +BU_Long_SubII%(pThis%, iLeft%, iRight%) :"_BU_Long_SubII@12" +BU_Long_DivII%(pThis%, iLeft%, iRight%) :"_BU_Long_DivII@12" +BU_Long_MulII%(pThis%, iLeft%, iRight%) :"_BU_Long_MulII@12" +BU_Long_ModII%(pThis%, iLeft%, iRight%) :"_BU_Long_ModII@12" +BU_Long_Shift%(pThis%, iRight%) :"_BU_Long_Shift@8" + +; Double ------------------------------------------------------------------------ +BU_Double_New%() :"_BU_Double_New@0" +BU_Double_Copy%(pThis%) :"_BU_Double_Copy@4" +BU_Double_Destroy(pThis%) :"_BU_Double_Destroy@4" +BU_Double_ToString$(pThis%) :"_BU_Double_ToString@4" +BU_Double_FromString%(cString$) :"_BU_Double_FromString@4" +BU_Double_FromF%(Float#) :"_BU_Double_FromF@4" +BU_Double_ToF#(pThis%) :"_BU_Double_ToF@4" +BU_Double_FromI%(iRight%) :"_BU_Double_FromI@4" +BU_Double_ToI%(pThis%) :"_BU_Double_ToI@8" +BU_Double_FromL(pDouble%) :"_BU_Double_FromL@4" +BU_Double_ToL(pThis%) :"_BU_Double_ToL@4" +BU_Double_Compare%(pThis%, pOther%) :"_BU_Double_Compare@8" +BU_Double_Set%(pThis%, pOther%) :"_BU_Double_Set@8" +BU_Double_Add%(pThis%, pOther%) :"_BU_Double_Add@8" +BU_Double_Sub%(pThis%, pOther%) :"_BU_Double_Sub@8" +BU_Double_Div%(pThis%, pOther%) :"_BU_Double_Div@8" +BU_Double_Mul%(pThis%, pOther%) :"_BU_Double_Mul@8" +BU_Double_Mod%(pThis%, pOther%) :"_BU_Double_Mod@8" +BU_Double_SetF%(pThis%, fOther%) :"_BU_Double_SetF@8" +BU_Double_AddF%(pThis%, fOther%) :"_BU_Double_AddF@8" +BU_Double_SubF%(pThis%, fOther%) :"_BU_Double_SubF@8" +BU_Double_DivF%(pThis%, fOther%) :"_BU_Double_DivF@8" +BU_Double_MulF%(pThis%, fOther%) :"_BU_Double_MulF@8" +BU_Double_ModF%(pThis%, fOther%) :"_BU_Double_ModF@8" + +; Utility --------------------------------------------------------------------- +; -- Display Enumerator +BU_DisplayEnumerator_Create%() :"_BU_DisplayEnumerator_Create@0" +BU_DisplayEnumerator_Destroy(DisplayEnumerator%) :"_BU_DisplayEnumerator_Destroy@4" +BU_DisplayEnumerator_Enumerate%(DisplayEnumerator%) :"_BU_DisplayEnumerator_Enumerate@4" +BU_DisplayEnumerator_Count%(DisplayEnumerator%) :"_BU_DisplayEnumerator_Count@4" +BU_DisplayEnumerator_Retrieve(DisplayEnumerator%, index%, Rect*) :"_BU_DisplayEnumerator_Retrieve@12" +; -- Indexer V1 (Array) +BU_IndexerV1_Create%() +BU_IndexerV1_Destroy(Indexer%) +BU_IndexerV1_Mark(Indexer%, Used%) +BU_IndexerV1_MarkFree(Indexer%) +BU_IndexerV1_MarkUsed(Indexer%) +BU_IndexerV1_Is%(Indexer%, Used%) +BU_IndexerV1_IsFree%(Indexer%) +BU_IndexerV1_IsUsed%(Indexer%) +BU_IndexerV1_Get%(Indexer%) +BU_IndexerV1_Count%(Indexer%, Used%) +BU_IndexerV1_CountFree%(Indexer%) +BU_IndexerV1_CountUsed%(Indexer%) +; -- Indexer V2 (List) +BU_IndexerV2_Create%() +BU_IndexerV2_Destroy(Indexer%) +BU_IndexerV2_Mark(Indexer%, Used%) +BU_IndexerV2_MarkFree(Indexer%) +BU_IndexerV2_MarkUsed(Indexer%) +BU_IndexerV2_Is%(Indexer%, Used%) +BU_IndexerV2_IsFree%(Indexer%) +BU_IndexerV2_IsUsed%(Indexer%) +BU_IndexerV2_Get%(Indexer%) +BU_IndexerV2_Count%(Indexer%, Used%) +BU_IndexerV2_CountFree%(Indexer%) +BU_IndexerV2_CountUsed%(Indexer%) +; -- Mass Operation +BU_MassOp_Create%(length%) +BU_MassOp_Destroy(massop%) +BU_MassOp_Instruction(massop%, index%, type%, code%, leftOperand%, rightOperand%, result%) +BU_MassOp_Run(massop%) +; -- Window Message Handler +BU_WindowMessageHandler_Install(hwnd%) +BU_WindowMessageHandler_Uninstall(hwnd%) +BU_WindowMessageHandler_Message_Close%(hwnd%) +BU_WindowMessageHandler_Message_Destroy%(hwnd%) +BU_WindowMessageHandler_Message_Resize%(hwnd%, point*) + +; Helpers --------------------------------------------------------------------- +.lib " " +; -- Blitz Functions +BU_Helper_Window_LockPointer(HWND%) +BU_Helper_Window_LockPointerAuto(HWND%) +BU_Helper_Window_MakeBorderless(HWND%) +BU_Helper_Window_Center(HWND%, Monitor%) +BU_Helper_Window_Fill(HWND%, Monitor%) +; -- Windows API (User32) +.lib "User32.dll" +BU_User32_ClientToScreen%(hwnd%, point*) : "ClientToScreen" +BU_User32_ClientToScreenEx%(hwnd%, point%) : "ClientToScreen" +BU_User32_ClipCursor%(rect*) : "ClipCursor" +BU_User32_ClipCursorEx%(ptr%) : "ClipCursor" +BU_User32_GetActiveWindow%() : "GetActiveWindow" +BU_User32_GetSystemMetrics%(index%) : "GetSystemMetrics" +BU_User32_SetWindowLong%(hwnd%, nIndex%, dwNewLong%) : "SetWindowLongA" +BU_User32_GetWindowLong%(hwnd%, index%) : "GetWindowLongA" +BU_User32_GetWindowRect%(hwnd%, rect*) : "GetWindowRect" +BU_User32_GetWindowRectEx%(hwnd%, rect%) : "GetWindowRect" +BU_User32_GetClientRect%(hwnd%, rect*) : "GetClientRect" +BU_User32_GetClientRectEx%(hwnd%, rect%) : "GetClientRect" +BU_User32_SetWindowPos%(hwnd%, hWndInsertAfter%, x%, y%, cx%, cy%, wFlags%) : "SetWindowPos" +BU_User32_MessageBox%(hwnd%, lpText$, lpCaption$, uType%) : "MessageBoxA" +; -- Windows API (Kernel32) +.lib "Kernel32.dll" +BU_Kernel32_FlushFileBuffers%(hFile%) : "FlushFileBuffers" +FlushFile%(hFile%) : "FlushFileBuffers" +BU_Kernel32_QueryPerformanceCounter%(pLongLong%) : "QueryPerformanceCounter" +BU_Kernel32_QueryPerformanceFrequency%(pLongLong%) : "QueryPerformanceFrequency" \ No newline at end of file diff --git a/#Test/userlibs/BlitzUtility.dll b/#Test/userlibs/BlitzUtility.dll new file mode 100644 index 0000000..b980c69 Binary files /dev/null and b/#Test/userlibs/BlitzUtility.dll differ diff --git a/#Test/userlibs/Draw3D2.decls b/#Test/userlibs/Draw3D2.decls new file mode 100644 index 0000000..9b2046d --- /dev/null +++ b/#Test/userlibs/Draw3D2.decls @@ -0,0 +1,82 @@ +.lib "user32.dll" + +Draw3D2_GCP% (lpPoint*) : "GetCursorPos" +Draw3D2_GWR% (hwnd%,lpRect*) : "GetWindowRect" + +.lib " " + +MouseX3D( ) +MouseY3D( ) +MouseXOld3D( ) +MouseYOld3D( ) +MouseXSpeed3D( ) +MouseYSpeed3D( ) +MouseHit3D( ) +MousePit3D( ) +MouseDown3D( ) +MouseOver3D( ) +MouseTest3D( ) +ProjectedX3D( ) +ProjectedY3D( ) +GetMOW3D( ) + +BumpImage3D( main_handle%, bump_handle% ) +IlluImage3D( main_handle%, illu_handle% ) +CameraProjectEntity3D( entity_handle%, offset_adding% ) +CameraProjectCoords3D( x#, y#, z#, offset_Adding% ) +ChangeCamera3D( camera% ) +CheckQuad3D( x1#, y1#, x2#, y2#, x3#, y3#, x4#, y4#, button%, handle% ) +Clear3D( handle% ) +ClearOff3D( handle% ) +ClearOn3D( handle% ) +ColorG3D( red%, green%, blue%, alpha# ) +ColorT3D( red%, green%, blue%, alpha# ) +CopyImage3D( handle%, mode%, blend%, pivot%, order% ) +CreateImage3D( size%, mode%, blend%, pivot%, order% ) +CreatePivot3D( parent%, x_position#, y_position#, z_position#, x_rotation#, y_rotation#, z_rotation#, scale# ) +DeffBzBend3D( x5#, y5#, x6#, y6#, x7#, y7#, x8#, y8# ) +DeffBzQuad3D( x1#, y1#, x2#, y2#, x3#, y3#, x4#, y4# ) +DrawBzQuad3D( handle%, frame%, depth%, color%, z_position% ) +DrawFree3D( ) +DrawImage3D( handle%, x#, y#, button%, angle#, scale#, frame% ) +DrawImage4D( handle%, x#, y#, z#, button%, angle#, scale#, frame% ) +DrawInit3D( camera% ) +DrawLine3D( handle%, x1#, y1#, x2#, y2#, size#, mode%, frame% ) +DrawLine4D( handle%, x1#, y1#, z1#, x2#, y2#, z2#, size#, frame% ) +DrawNerd3D( handle%, x1#, y1#, x2#, y2#, x3#, y3#, x4#, y4#, u_set#, v_set#, w_set#, h_set#, button% ) +DrawOrder3D( handle%, order% ) +DrawQuad3D( handle%, x1#, y1#, x2#, y2#, x3#, y3#, x4#, y4#, button%, frame% ) +DrawRect3D( handle%, x#, y#, u_set#, v_set#, w_set#, h_set#, button%, angle#, scale# ) +DrawTile3D( handle%, x1#, y1#, x2#, y2#, x3#, y3#, x4#, y4#, scale#, button% ) +FlushFace3D( handle% ) +FontRange3D( link%, u_set%, v_set%, w_set%, h_set%, rows% ) +FreeImage3D( handle% ) +GetPixel3D( handle%, x%, y%, mask% ) +GetTexel3D( handle%, x1#, y1#, x2#, y2#, angle#, scale#, mask% ) +GrabAnimImage3D( handle%, w_set%, h_set%, start%, frames%, x_scale#, y_scale# ) +GrabImage3D( handle%, u_set%, v_set%, w_set%, h_set%, x_scale#, y_scale# ) +ImageSize3D( handle%, source% ) +ImagesOverlap3D( handle1%, x1#, y1#, angle1#, scale1#, handle2%, x2#, y2#, angle2#, scale2# ) +LoadImage3D( file$, mode%, blend%, pivot%, order% ) +MaskImage3D( handle%, rgb% ) +OnLockBuffer3D( handle% ) +Origin3D( x#, y#, pivot% ) +SetFont3D( handle%, scale_font#, height_scale_font#, padding_font#, italic_font# ) +SetPivot3D( handle%, x_position#, y_position#, z_position#, x_rotation#, y_rotation#, z_rotation#, scale# ) +SetPixel3D( handle%, x%, y%, argb% ) +SetTexel3D( handle%, x1#, y1#, x2#, y2#, angle#, scale#, argb% ) +StringHeight3D( handle% ) +StringWidth3D( handle%, string$ ) +Text3D( handle%, x#, y#, string$, align#, button%, angle# ) +Text3DTT( font_handle%, image_handle%, x%, y%, string$ ) +UnLockBuffer3D( handle% ) +USwap3D( handle%, frame%, mode% ) +VSwap3D( handle%, frame%, mode% ) + +ColorN3D( reg%, green%, blue%, alpha# ) +Line3D( handle%, x1#, y1#, x2#, y2#, line_width# ) +Oval3D( handle%, x#, y#, x_size#, y_size#, fill%, border_width# ) +Plot3D( handle%, x#, y#, size# ) +Poly3D( handle%, x1#, y1#, x2#, y2#, x3#, y3# ) +Rect3D( handle%, x#, y#, x_size#, y_size#, fill%, border_width# ) + diff --git a/#Test/userlibs/DrawSGG.decls b/#Test/userlibs/DrawSGG.decls new file mode 100644 index 0000000..eb9bf3a --- /dev/null +++ b/#Test/userlibs/DrawSGG.decls @@ -0,0 +1,49 @@ +.lib " " + +SGGOver3D( ) +SGGDown3D( ) +SGGHit3D( ) +SGGSpz3D( ) +SGGKey3D( ) +SGGEntry( ) + +SGGOUTLAY( ) +SGGBUTTON( ) +SGGINTAKE( ) +SGGROSTER( ) +SGGSLIDER( ) + +AddingSGG%( handle%, arts%, x_pos%, y_pos%, string$, align%, width% ) +AppendSGG%( handle%, string$ ) +CreateSGG%( x_pos%, y_pos%, width%, height%, sgg_file$, pivot%, order% ) +DeleteSGG%( handle%, list_pos% ) +DrawSGG%( handle%, x_pos%, y_pos% ) +FreeSGG%( handle% ) + +GetArtsSGG%( handle% ) +GetAlignSGG%( handle% ) +GetBoundSGG%( handle% ) +GetEntriesSGG%( handle% ) +GetListPosSGG%( handle% ) +GetSelectSGG%( handle% ) +GetStringSGG$( handle% ) +GetWidthSGG%( handle% ) +GetXPosSGG%( handle% ) +GetYPosSGG%( handle% ) + +SetArtsSGG%( handle%, value% ) +SetAlignSGG%( handle%, value% ) +SetBoundSGG%( handle%, value% ) +SetListPosSGG%( handle%, value% ) +SetSelectSGG%( handle%, value% ) +SetStringSGG%( handle%, value% ) +SetWidthSGG%( handle%, value% ) +SetXPosSGG%( handle%, value% ) +SetYPosSGG%( handle%, value% ) + +AddListPosSGG%( handle%, value% ) +AddSelectSGG%( handle%, value% ) +DrawButton3D%( handle%, x_pos%, y_pos%, string$, align%, width% ) +InviteSGG%( handle%, string$, dash%, directory$ ) +SortSGG%( handle% ) + diff --git a/#Test/userlibs/DrawXTD.decls b/#Test/userlibs/DrawXTD.decls new file mode 100644 index 0000000..56100e6 --- /dev/null +++ b/#Test/userlibs/DrawXTD.decls @@ -0,0 +1,32 @@ +.lib " " + +AdaptKPID( handle%, id%, slide# ) +AddCL( handle%, x1#, y1#, x2#, y2# ) +AddKP( handle%, x_pos%, y_pos%, radius%, mass%, collision_type%, torque%, id% ) +AddVK( handle%, source_kp%, destin_kp%, spring%, damping%, id% ) +AddVKIDLen( bank%, id%, lenght# ) +AppCED( handle%, loops# ) +BreakKPID( handle%, id%, linear#, fricty#, free_abs# ) +DelCED( handle% ) +DrawCED( handle% ) +DrawKP( handle%, Image% ) +FreeCED( handle% ) +GetCEDXPos#( handle%, mode% ) +GetCEDYPos#( handle%, mode% ) +GetID( file$, id% ) +LoadCED( file$, scale# ) +LoadVED( file$, scale#, z_step% ) +NewCED( ) +SetCED( handle%, x_pos#, y_pos#, angle#, mode% ) +TurnKPID( handle%, id%, speed#, damping# ) +CollBzQuad3D( area_code%, depth% ) +DrawImageKP( handle%, x_pos#, y_pos#, angle#, size#, frame% ) + +DropSED( image_handle%, sed_handle%, x_pos#, y_pos#, x_adding#, y_adding#, angle#, speed#, adder# ) +LoadSED( file$ ) +AnimSED( ) + +AnimFlakes4D( handle%, x_speed#, y_speed#, z_speed#, muddle# ) +AnimRifled4D( handle%, x_speed#, y_speed#, z_speed#, muddle#, expand# ) +CreateFlakes4D( particles%, dimension#, fading#, lakes# ) + diff --git a/#Test/userlibs/InputEx.decls b/#Test/userlibs/InputEx.decls new file mode 100644 index 0000000..897b4b4 --- /dev/null +++ b/#Test/userlibs/InputEx.decls @@ -0,0 +1,32 @@ +.lib "User32.dll" +InputEx_User32_FindWindow%(class$, title$):"FindWindowA" +InputEx_User32_GetActiveWindow%():"GetActiveWindow" +InputEx_User32_GetCursorPosition%(point*):"GetCursorPos" +InputEx_User32_ScreenToClient%(hwnd%, point*):"ScreenToClient" +InputEx_User32_MapVirtualKeyEx%(code%, mapType%, dwhkl%):"MapVirtualKeyExA" +InputEx_User32_GetAsyncKeyState%(vkey%):"GetAsyncKeyState" + +.lib " " +InputEx_Init() +InputEx_Update() +InputEx_VKeyTime%(VirtualKey%) +InputEx_VKeyDownEx%(VirtualKey%) +InputEx_VKeyDown%(VirtualKey%) +InputEx_VKeyHitEx%(VirtualKey%) +InputEx_VKeyHit%(VirtualKey%) +InputEx_KeyTime%(ScanCode%) +InputEx_KeyDownEx%(ScanCode%) +InputEx_KeyDown%(ScanCode%) +InputEx_KeyHitEx%(ScanCode%) +InputEx_KeyHit%(ScanCode%) +InputEx_MouseTime%(Button%) +InputEx_MouseDownEx%(Button%) +InputEx_MouseDown%(Button%) +InputEx_MouseHitEx%(Button%) +InputEx_MouseHit%(Button%) +KeyTime%(Key%) +KeyDownEx%(Key%) +KeyHitEx%(Key%) +MouseTime%(Button%) +MouseDownEx%(Button%) +MouseHitEx%(Button%) \ No newline at end of file diff --git a/#Test/userlibs/Kernel32.decls b/#Test/userlibs/Kernel32.decls new file mode 100644 index 0000000..fcab8a1 --- /dev/null +++ b/#Test/userlibs/Kernel32.decls @@ -0,0 +1,31 @@ +.lib "Kernel32.dll" +; Mutex +Kernel32_CreateMutex%( lpMutexAttributes%, bInitialOwner%, lpName$ ) : "CreateMutexA" +Kernel32_CreateMutex2%( lpMutexAttributes%, bInitialOwner%, lpName% ) : "CreateMutexA" +Kernel32_ReleaseMutex%( hMutex% ) : "ReleaseMutex" + +; Thread +Kernel32_CreateThread%( lpThreadAttributes%, dwStackSize%, lpStartAddress%, lpParameter%, dwCreationFlags%, lpThreadId% ) : "CreateThread" +Kernel32_TerminateThread%( hThread%, dwExitCode% ) : "TerminateThread" +Kernel32_ExitThread%( dwExitCode% ) : "ExitThread" +Kernel32_GetExitCodeThread%( hThread% ) : "GetExitCodeThread" +Kernel32_ResumeThread%(hThread%) : "ResumeThread" +Kernel32_SuspendThread%(hThread%) : "SuspendThread" + +; Semaphorre +Kernel32_CreateSemaphore%(lpSemaphoreAttributes%, lInitialCount%, lMaximumCount%, lpName$) : "CreateSemaphoreA" +Kernel32_CreateSemaphore2%(lpSemaphoreAttributes%, lInitialCount%, lMaximumCount%, lpName%) : "CreateSemaphoreA" +Kernel32_ReleaseSemaphore%(hSemaphore%, lReleaseCount%, lpPreviousCount%) : "ReleaseSemaphore" + +; Objects +Kernel32_WaitForSingleObject%( hHandle%, dwMilliseconds% ) : "WaitForSingleObject" +Kernel32_WaitForMultipleObjects%( nCount%, lpHandles*, bWaitAll%, dwMilliseconds% ) : "WaitForMultipleObjects" + +; Other +Kernel32_CloseHandle%( hObject% ) : "CloseHandle" +Kernel32_GetLastError%( ) : "GetLastError" +Kernel32_FormatMessage$( dwFlags%, lpSource*, dwMessageId%, dwLanguageId%, lpBuffer$, nSize%, Arguments*) : "FormatMessage" +Kernel32_ExitProcess( uExitCode% ) : "ExitProcess" + +.lib "User32.dll" +User32_MessageBox(hwnd%, lpText$, lpCaption$, uType%) : "MessageBoxA" \ No newline at end of file diff --git a/_release/userlibs/UserLibs.txt b/#Test/userlibs/UserLibs.txt similarity index 97% rename from _release/userlibs/UserLibs.txt rename to #Test/userlibs/UserLibs.txt index 1f1d3de..792b5c0 100644 --- a/_release/userlibs/UserLibs.txt +++ b/#Test/userlibs/UserLibs.txt @@ -1,123 +1,123 @@ - -New DLL interface spec ----------------------- - -There is now a directory in the root blitzpath called 'userlibs'. - -By adding DLLs and '.decls' files to this directory, you can extend blitz's command set. - -DLLs contain actually library code, while .decls files contain 'declarations' to be added to the -base command set. These declarations describe the functions contained in the Dll. - - -Format of decls files ---------------------- - -Decls files should always start with a '.lib' directive, followed by the quoted name of the DLL to be -loaded, eg: - -.lib "mylib.dll" - -Following the .lib is a list of function declarations. The syntax of these is identical to -function declarations in Blitz, with the following exceptions: - -* No default parameter values are allowed. - -* If no function return type is specified, the function is a 'void' function - ie: it returns nothing. - -* Instead of object parameters, you can only specify 'void*' parameters using a '*' type tag. Such -parameters can be assigned ANY object or bank, so BE CAREFUL! - -* A declaration may be optionally followed by a 'decorated name'. This takes the form of a ':' -followed by a quoted string denoting the decorated name, eg: - -MyFunction( text$ ):"_MyFunction@4" -MessageBox%( hwnd,text$,title$,style ):"MessageBoxA" - -The decorated name is the name of the function as it appears in the dll, and only needs to be -specified if it is different from the actual function name. - - -Writing DLLs ------------- - -All functions MUST use the _stdcall calling convention. - -Floats are passed and returned as per standard C/C++ conventions. - -Strings are passed and returned in 'C' format - ie: a pointer to a null-terminated sequence of -characters. - -Returned strings must be in a 'static' memory buffer. Once the function returns, this string is -immediately copied into an internal Blitz style string, so its OK to share this buffer between -multiple functions. - -Both banks and objects can be passed to functions. The value passed is the address of the first byte -of storage. No information is sent regarding the size or type of memory passed so, again, BE CAREFUL! - -Neither Banks or objects can be returned from functions. - -Arrays are not supported at all. - -VisualC decorates symbols quite heavily! If you are coding in 'C', the necessary stdcall specifier -will cause a '_' to be prepended, and a '@' (followed by the number of bytes passed to the function -- ie: number of parameters*4) to be appended. So, something like: 'void _stdcall MyFunc( int x )' -will end up as '_MyFunc@4'. In C++, the name decoration is even messier! But you can supress it by -using the 'extern "C"' feature (see examples below) so you're just left with the 'C' stdcall mess. - -Other languages such as Delphi and Purebasic don't appear to suffer from this feature, but it can be -worthwhile looking through dll symbols if you're having problems. Check out PEview at -http://www.magma.ca/~wjr Open your dll and select 'SECTION .rdata'/'EXPORT address table' -to have a look at the exported symbols your compiler has seen fit to bestow upon your dll. - -Example -------- - -Ok, here's a little C++ example, as it would appear in VisualC. - -First, we write the DLL: - -//demo.dll -// -#include -#include -#include - -#define BBDECL extern "C" _declspec(dllexport) -#define BBCALL _stdcall - -//returns a float and has 6 float parameters -BBDECL float BBCALL VecDistance( float x1,float y1,float z1,float x2,float y2,float z2 ){ - float dx=x1-x2,dy=y1-y2,dz=z1-z2; - return sqrtf( dx*dx+dy*dy+dz*dz ); -} - -//returns a string and has one string parameter -BBDECL const char * BBCALL ShuffleString( const char *str ){ - static char *_buf; - - int sz=strlen(str); - - delete[] _buf; - _buf=new char[ sz+1 ]; - strcpy( _buf,str ); - - for( int k=0;k +#include +#include + +#define BBDECL extern "C" _declspec(dllexport) +#define BBCALL _stdcall + +//returns a float and has 6 float parameters +BBDECL float BBCALL VecDistance( float x1,float y1,float z1,float x2,float y2,float z2 ){ + float dx=x1-x2,dy=y1-y2,dz=z1-z2; + return sqrtf( dx*dx+dy*dy+dz*dz ); +} + +//returns a string and has one string parameter +BBDECL const char * BBCALL ShuffleString( const char *str ){ + static char *_buf; + + int sz=strlen(str); + + delete[] _buf; + _buf=new char[ sz+1 ]; + strcpy( _buf,str ); + + for( int k=0;k // needed for UNICODE functions + +#if defined(FREEIMAGE_LIB) + #define DLL_API + #define DLL_CALLCONV +#else + #if defined(_WIN32) || defined(__WIN32__) + #define DLL_CALLCONV __stdcall + // The following ifdef block is the standard way of creating macros which make exporting + // from a DLL simpler. All files within this DLL are compiled with the FREEIMAGE_EXPORTS + // symbol defined on the command line. this symbol should not be defined on any project + // that uses this DLL. This way any other project whose source files include this file see + // DLL_API functions as being imported from a DLL, wheras this DLL sees symbols + // defined with this macro as being exported. + #ifdef FREEIMAGE_EXPORTS + #define DLL_API __declspec(dllexport) + #else + #define DLL_API __declspec(dllimport) + #endif // FREEIMAGE_EXPORTS + #else + // try the gcc visibility support (see http://gcc.gnu.org/wiki/Visibility) + #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) + #ifndef GCC_HASCLASSVISIBILITY + #define GCC_HASCLASSVISIBILITY + #endif + #endif // __GNUC__ + #define DLL_CALLCONV + #if defined(GCC_HASCLASSVISIBILITY) + #define DLL_API __attribute__ ((visibility("default"))) + #else + #define DLL_API + #endif + #endif // WIN32 / !WIN32 +#endif // FREEIMAGE_LIB + +// Endianness: +// Some versions of gcc may have BYTE_ORDER or __BYTE_ORDER defined. +// If your big endian system isn't being detected, add an OS specific check +// or define any of FREEIMAGE_BIGENDIAN and FREEIMAGE_LITTLEENDIAN directly +// to specify the desired endianness. +#if (!defined(FREEIMAGE_BIGENDIAN) && !defined(FREEIMAGE_LITTLEENDIAN)) + #if (defined(BYTE_ORDER) && BYTE_ORDER==BIG_ENDIAN) || (defined(__BYTE_ORDER) && __BYTE_ORDER==__BIG_ENDIAN) || defined(__BIG_ENDIAN__) + #define FREEIMAGE_BIGENDIAN + #endif // BYTE_ORDER +#endif // !FREEIMAGE_[BIG|LITTLE]ENDIAN + +// Color-Order: +// The specified order of color components red, green and blue affects 24- +// and 32-bit images of type FIT_BITMAP as well as the colors that are part +// of a color palette. All other images always use RGB order. By default, +// color order is coupled to endianness: +// little-endian -> BGR +// big-endian -> RGB +// However, you can always define FREEIMAGE_COLORORDER to any of the known +// orders FREEIMAGE_COLORORDER_BGR (0) and FREEIMAGE_COLORORDER_RGB (1) to +// specify your preferred color order. +#define FREEIMAGE_COLORORDER_BGR 0 +#define FREEIMAGE_COLORORDER_RGB 1 +#if (!defined(FREEIMAGE_COLORORDER)) || ((FREEIMAGE_COLORORDER != FREEIMAGE_COLORORDER_BGR) && (FREEIMAGE_COLORORDER != FREEIMAGE_COLORORDER_RGB)) + #if defined(FREEIMAGE_BIGENDIAN) + #define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_RGB + #else + #define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_BGR + #endif // FREEIMAGE_BIGENDIAN +#endif // FREEIMAGE_COLORORDER + +// Ensure 4-byte enums if we're using Borland C++ compilers +#if defined(__BORLANDC__) +#pragma option push -b +#endif + +// For C compatibility -------------------------------------------------------- + +#ifdef __cplusplus +#define FI_DEFAULT(x) = x +#define FI_ENUM(x) enum x +#define FI_STRUCT(x) struct x +#else +#define FI_DEFAULT(x) +#define FI_ENUM(x) typedef int x; enum x +#define FI_STRUCT(x) typedef struct x x; struct x +#endif + +// Bitmap types ------------------------------------------------------------- + +FI_STRUCT (FIBITMAP) { void *data; }; +FI_STRUCT (FIMULTIBITMAP) { void *data; }; + +// Types used in the library (directly copied from Windows) ----------------- + +#if defined(__MINGW32__) && defined(_WINDOWS_H) +#define _WINDOWS_ // prevent a bug in MinGW32 +#endif // __MINGW32__ + +#ifndef _WINDOWS_ +#define _WINDOWS_ + +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef NULL +#define NULL 0 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _MSC_VER +// define portable types for 32-bit / 64-bit OS +#include +typedef int32_t BOOL; +typedef uint8_t BYTE; +typedef uint16_t WORD; +typedef uint32_t DWORD; +typedef int32_t LONG; +typedef int64_t INT64; +typedef uint64_t UINT64; +#else +// MS is not C99 ISO compliant +typedef long BOOL; +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef unsigned long DWORD; +typedef long LONG; +typedef signed __int64 INT64; +typedef unsigned __int64 UINT64; +#endif // _MSC_VER + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(push, 1) +#else +#pragma pack(1) +#endif // WIN32 + +typedef struct tagRGBQUAD { +#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR + BYTE rgbBlue; + BYTE rgbGreen; + BYTE rgbRed; +#else + BYTE rgbRed; + BYTE rgbGreen; + BYTE rgbBlue; +#endif // FREEIMAGE_COLORORDER + BYTE rgbReserved; +} RGBQUAD; + +typedef struct tagRGBTRIPLE { +#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR + BYTE rgbtBlue; + BYTE rgbtGreen; + BYTE rgbtRed; +#else + BYTE rgbtRed; + BYTE rgbtGreen; + BYTE rgbtBlue; +#endif // FREEIMAGE_COLORORDER +} RGBTRIPLE; + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(pop) +#else +#pragma pack() +#endif // WIN32 + +typedef struct tagBITMAPINFOHEADER{ + DWORD biSize; + LONG biWidth; + LONG biHeight; + WORD biPlanes; + WORD biBitCount; + DWORD biCompression; + DWORD biSizeImage; + LONG biXPelsPerMeter; + LONG biYPelsPerMeter; + DWORD biClrUsed; + DWORD biClrImportant; +} BITMAPINFOHEADER, *PBITMAPINFOHEADER; + +typedef struct tagBITMAPINFO { + BITMAPINFOHEADER bmiHeader; + RGBQUAD bmiColors[1]; +} BITMAPINFO, *PBITMAPINFO; + +#endif // _WINDOWS_ + +// Types used in the library (specific to FreeImage) ------------------------ + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(push, 1) +#else +#pragma pack(1) +#endif // WIN32 + +/** 48-bit RGB +*/ +typedef struct tagFIRGB16 { + WORD red; + WORD green; + WORD blue; +} FIRGB16; + +/** 64-bit RGBA +*/ +typedef struct tagFIRGBA16 { + WORD red; + WORD green; + WORD blue; + WORD alpha; +} FIRGBA16; + +/** 96-bit RGB Float +*/ +typedef struct tagFIRGBF { + float red; + float green; + float blue; +} FIRGBF; + +/** 128-bit RGBA Float +*/ +typedef struct tagFIRGBAF { + float red; + float green; + float blue; + float alpha; +} FIRGBAF; + +/** Data structure for COMPLEX type (complex number) +*/ +typedef struct tagFICOMPLEX { + /// real part + double r; + /// imaginary part + double i; +} FICOMPLEX; + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(pop) +#else +#pragma pack() +#endif // WIN32 + +// Indexes for byte arrays, masks and shifts for treating pixels as words --- +// These coincide with the order of RGBQUAD and RGBTRIPLE ------------------- + +#ifndef FREEIMAGE_BIGENDIAN +#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR +// Little Endian (x86 / MS Windows, Linux) : BGR(A) order +#define FI_RGBA_RED 2 +#define FI_RGBA_GREEN 1 +#define FI_RGBA_BLUE 0 +#define FI_RGBA_ALPHA 3 +#define FI_RGBA_RED_MASK 0x00FF0000 +#define FI_RGBA_GREEN_MASK 0x0000FF00 +#define FI_RGBA_BLUE_MASK 0x000000FF +#define FI_RGBA_ALPHA_MASK 0xFF000000 +#define FI_RGBA_RED_SHIFT 16 +#define FI_RGBA_GREEN_SHIFT 8 +#define FI_RGBA_BLUE_SHIFT 0 +#define FI_RGBA_ALPHA_SHIFT 24 +#else +// Little Endian (x86 / MaxOSX) : RGB(A) order +#define FI_RGBA_RED 0 +#define FI_RGBA_GREEN 1 +#define FI_RGBA_BLUE 2 +#define FI_RGBA_ALPHA 3 +#define FI_RGBA_RED_MASK 0x000000FF +#define FI_RGBA_GREEN_MASK 0x0000FF00 +#define FI_RGBA_BLUE_MASK 0x00FF0000 +#define FI_RGBA_ALPHA_MASK 0xFF000000 +#define FI_RGBA_RED_SHIFT 0 +#define FI_RGBA_GREEN_SHIFT 8 +#define FI_RGBA_BLUE_SHIFT 16 +#define FI_RGBA_ALPHA_SHIFT 24 +#endif // FREEIMAGE_COLORORDER +#else +#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR +// Big Endian (PPC / none) : BGR(A) order +#define FI_RGBA_RED 2 +#define FI_RGBA_GREEN 1 +#define FI_RGBA_BLUE 0 +#define FI_RGBA_ALPHA 3 +#define FI_RGBA_RED_MASK 0x0000FF00 +#define FI_RGBA_GREEN_MASK 0x00FF0000 +#define FI_RGBA_BLUE_MASK 0xFF000000 +#define FI_RGBA_ALPHA_MASK 0x000000FF +#define FI_RGBA_RED_SHIFT 8 +#define FI_RGBA_GREEN_SHIFT 16 +#define FI_RGBA_BLUE_SHIFT 24 +#define FI_RGBA_ALPHA_SHIFT 0 +#else +// Big Endian (PPC / Linux, MaxOSX) : RGB(A) order +#define FI_RGBA_RED 0 +#define FI_RGBA_GREEN 1 +#define FI_RGBA_BLUE 2 +#define FI_RGBA_ALPHA 3 +#define FI_RGBA_RED_MASK 0xFF000000 +#define FI_RGBA_GREEN_MASK 0x00FF0000 +#define FI_RGBA_BLUE_MASK 0x0000FF00 +#define FI_RGBA_ALPHA_MASK 0x000000FF +#define FI_RGBA_RED_SHIFT 24 +#define FI_RGBA_GREEN_SHIFT 16 +#define FI_RGBA_BLUE_SHIFT 8 +#define FI_RGBA_ALPHA_SHIFT 0 +#endif // FREEIMAGE_COLORORDER +#endif // FREEIMAGE_BIGENDIAN + +#define FI_RGBA_RGB_MASK (FI_RGBA_RED_MASK|FI_RGBA_GREEN_MASK|FI_RGBA_BLUE_MASK) + +// The 16bit macros only include masks and shifts, since each color element is not byte aligned + +#define FI16_555_RED_MASK 0x7C00 +#define FI16_555_GREEN_MASK 0x03E0 +#define FI16_555_BLUE_MASK 0x001F +#define FI16_555_RED_SHIFT 10 +#define FI16_555_GREEN_SHIFT 5 +#define FI16_555_BLUE_SHIFT 0 +#define FI16_565_RED_MASK 0xF800 +#define FI16_565_GREEN_MASK 0x07E0 +#define FI16_565_BLUE_MASK 0x001F +#define FI16_565_RED_SHIFT 11 +#define FI16_565_GREEN_SHIFT 5 +#define FI16_565_BLUE_SHIFT 0 + +// ICC profile support ------------------------------------------------------ + +#define FIICC_DEFAULT 0x00 +#define FIICC_COLOR_IS_CMYK 0x01 + +FI_STRUCT (FIICCPROFILE) { + WORD flags; //! info flag + DWORD size; //! profile's size measured in bytes + void *data; //! points to a block of contiguous memory containing the profile +}; + +// Important enums ---------------------------------------------------------- + +/** I/O image format identifiers. +*/ +FI_ENUM(FREE_IMAGE_FORMAT) { + FIF_UNKNOWN = -1, + FIF_BMP = 0, + FIF_ICO = 1, + FIF_JPEG = 2, + FIF_JNG = 3, + FIF_KOALA = 4, + FIF_LBM = 5, + FIF_IFF = FIF_LBM, + FIF_MNG = 6, + FIF_PBM = 7, + FIF_PBMRAW = 8, + FIF_PCD = 9, + FIF_PCX = 10, + FIF_PGM = 11, + FIF_PGMRAW = 12, + FIF_PNG = 13, + FIF_PPM = 14, + FIF_PPMRAW = 15, + FIF_RAS = 16, + FIF_TARGA = 17, + FIF_TIFF = 18, + FIF_WBMP = 19, + FIF_PSD = 20, + FIF_CUT = 21, + FIF_XBM = 22, + FIF_XPM = 23, + FIF_DDS = 24, + FIF_GIF = 25, + FIF_HDR = 26, + FIF_FAXG3 = 27, + FIF_SGI = 28, + FIF_EXR = 29, + FIF_J2K = 30, + FIF_JP2 = 31, + FIF_PFM = 32, + FIF_PICT = 33, + FIF_RAW = 34, + FIF_WEBP = 35, + FIF_JXR = 36 +}; + +/** Image type used in FreeImage. +*/ +FI_ENUM(FREE_IMAGE_TYPE) { + FIT_UNKNOWN = 0, //! unknown type + FIT_BITMAP = 1, //! standard image : 1-, 4-, 8-, 16-, 24-, 32-bit + FIT_UINT16 = 2, //! array of unsigned short : unsigned 16-bit + FIT_INT16 = 3, //! array of short : signed 16-bit + FIT_UINT32 = 4, //! array of unsigned long : unsigned 32-bit + FIT_INT32 = 5, //! array of long : signed 32-bit + FIT_FLOAT = 6, //! array of float : 32-bit IEEE floating point + FIT_DOUBLE = 7, //! array of double : 64-bit IEEE floating point + FIT_COMPLEX = 8, //! array of FICOMPLEX : 2 x 64-bit IEEE floating point + FIT_RGB16 = 9, //! 48-bit RGB image : 3 x 16-bit + FIT_RGBA16 = 10, //! 64-bit RGBA image : 4 x 16-bit + FIT_RGBF = 11, //! 96-bit RGB float image : 3 x 32-bit IEEE floating point + FIT_RGBAF = 12 //! 128-bit RGBA float image : 4 x 32-bit IEEE floating point +}; + +/** Image color type used in FreeImage. +*/ +FI_ENUM(FREE_IMAGE_COLOR_TYPE) { + FIC_MINISWHITE = 0, //! min value is white + FIC_MINISBLACK = 1, //! min value is black + FIC_RGB = 2, //! RGB color model + FIC_PALETTE = 3, //! color map indexed + FIC_RGBALPHA = 4, //! RGB color model with alpha channel + FIC_CMYK = 5 //! CMYK color model +}; + +/** Color quantization algorithms. +Constants used in FreeImage_ColorQuantize. +*/ +FI_ENUM(FREE_IMAGE_QUANTIZE) { + FIQ_WUQUANT = 0, //! Xiaolin Wu color quantization algorithm + FIQ_NNQUANT = 1, //! NeuQuant neural-net quantization algorithm by Anthony Dekker + FIQ_LFPQUANT = 2 //! Lossless Fast Pseudo-Quantization Algorithm by Carsten Klein +}; + +/** Dithering algorithms. +Constants used in FreeImage_Dither. +*/ +FI_ENUM(FREE_IMAGE_DITHER) { + FID_FS = 0, //! Floyd & Steinberg error diffusion + FID_BAYER4x4 = 1, //! Bayer ordered dispersed dot dithering (order 2 dithering matrix) + FID_BAYER8x8 = 2, //! Bayer ordered dispersed dot dithering (order 3 dithering matrix) + FID_CLUSTER6x6 = 3, //! Ordered clustered dot dithering (order 3 - 6x6 matrix) + FID_CLUSTER8x8 = 4, //! Ordered clustered dot dithering (order 4 - 8x8 matrix) + FID_CLUSTER16x16= 5, //! Ordered clustered dot dithering (order 8 - 16x16 matrix) + FID_BAYER16x16 = 6 //! Bayer ordered dispersed dot dithering (order 4 dithering matrix) +}; + +/** Lossless JPEG transformations +Constants used in FreeImage_JPEGTransform +*/ +FI_ENUM(FREE_IMAGE_JPEG_OPERATION) { + FIJPEG_OP_NONE = 0, //! no transformation + FIJPEG_OP_FLIP_H = 1, //! horizontal flip + FIJPEG_OP_FLIP_V = 2, //! vertical flip + FIJPEG_OP_TRANSPOSE = 3, //! transpose across UL-to-LR axis + FIJPEG_OP_TRANSVERSE = 4, //! transpose across UR-to-LL axis + FIJPEG_OP_ROTATE_90 = 5, //! 90-degree clockwise rotation + FIJPEG_OP_ROTATE_180 = 6, //! 180-degree rotation + FIJPEG_OP_ROTATE_270 = 7 //! 270-degree clockwise (or 90 ccw) +}; + +/** Tone mapping operators. +Constants used in FreeImage_ToneMapping. +*/ +FI_ENUM(FREE_IMAGE_TMO) { + FITMO_DRAGO03 = 0, //! Adaptive logarithmic mapping (F. Drago, 2003) + FITMO_REINHARD05 = 1, //! Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005) + FITMO_FATTAL02 = 2 //! Gradient domain high dynamic range compression (R. Fattal, 2002) +}; + +/** Upsampling / downsampling filters. +Constants used in FreeImage_Rescale. +*/ +FI_ENUM(FREE_IMAGE_FILTER) { + FILTER_BOX = 0, //! Box, pulse, Fourier window, 1st order (constant) b-spline + FILTER_BICUBIC = 1, //! Mitchell & Netravali's two-param cubic filter + FILTER_BILINEAR = 2, //! Bilinear filter + FILTER_BSPLINE = 3, //! 4th order (cubic) b-spline + FILTER_CATMULLROM = 4, //! Catmull-Rom spline, Overhauser spline + FILTER_LANCZOS3 = 5 //! Lanczos3 filter +}; + +/** Color channels. +Constants used in color manipulation routines. +*/ +FI_ENUM(FREE_IMAGE_COLOR_CHANNEL) { + FICC_RGB = 0, //! Use red, green and blue channels + FICC_RED = 1, //! Use red channel + FICC_GREEN = 2, //! Use green channel + FICC_BLUE = 3, //! Use blue channel + FICC_ALPHA = 4, //! Use alpha channel + FICC_BLACK = 5, //! Use black channel + FICC_REAL = 6, //! Complex images: use real part + FICC_IMAG = 7, //! Complex images: use imaginary part + FICC_MAG = 8, //! Complex images: use magnitude + FICC_PHASE = 9 //! Complex images: use phase +}; + +// Metadata support --------------------------------------------------------- + +/** + Tag data type information (based on TIFF specifications) + + Note: RATIONALs are the ratio of two 32-bit integer values. +*/ +FI_ENUM(FREE_IMAGE_MDTYPE) { + FIDT_NOTYPE = 0, //! placeholder + FIDT_BYTE = 1, //! 8-bit unsigned integer + FIDT_ASCII = 2, //! 8-bit bytes w/ last byte null + FIDT_SHORT = 3, //! 16-bit unsigned integer + FIDT_LONG = 4, //! 32-bit unsigned integer + FIDT_RATIONAL = 5, //! 64-bit unsigned fraction + FIDT_SBYTE = 6, //! 8-bit signed integer + FIDT_UNDEFINED = 7, //! 8-bit untyped data + FIDT_SSHORT = 8, //! 16-bit signed integer + FIDT_SLONG = 9, //! 32-bit signed integer + FIDT_SRATIONAL = 10, //! 64-bit signed fraction + FIDT_FLOAT = 11, //! 32-bit IEEE floating point + FIDT_DOUBLE = 12, //! 64-bit IEEE floating point + FIDT_IFD = 13, //! 32-bit unsigned integer (offset) + FIDT_PALETTE = 14, //! 32-bit RGBQUAD + FIDT_LONG8 = 16, //! 64-bit unsigned integer + FIDT_SLONG8 = 17, //! 64-bit signed integer + FIDT_IFD8 = 18 //! 64-bit unsigned integer (offset) +}; + +/** + Metadata models supported by FreeImage +*/ +FI_ENUM(FREE_IMAGE_MDMODEL) { + FIMD_NODATA = -1, + FIMD_COMMENTS = 0, //! single comment or keywords + FIMD_EXIF_MAIN = 1, //! Exif-TIFF metadata + FIMD_EXIF_EXIF = 2, //! Exif-specific metadata + FIMD_EXIF_GPS = 3, //! Exif GPS metadata + FIMD_EXIF_MAKERNOTE = 4, //! Exif maker note metadata + FIMD_EXIF_INTEROP = 5, //! Exif interoperability metadata + FIMD_IPTC = 6, //! IPTC/NAA metadata + FIMD_XMP = 7, //! Abobe XMP metadata + FIMD_GEOTIFF = 8, //! GeoTIFF metadata + FIMD_ANIMATION = 9, //! Animation metadata + FIMD_CUSTOM = 10, //! Used to attach other metadata types to a dib + FIMD_EXIF_RAW = 11 //! Exif metadata as a raw buffer +}; + +/** + Handle to a metadata model +*/ +FI_STRUCT (FIMETADATA) { void *data; }; + +/** + Handle to a FreeImage tag +*/ +FI_STRUCT (FITAG) { void *data; }; + +// File IO routines --------------------------------------------------------- + +#ifndef FREEIMAGE_IO +#define FREEIMAGE_IO + +typedef void* fi_handle; +typedef unsigned (DLL_CALLCONV *FI_ReadProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); +typedef unsigned (DLL_CALLCONV *FI_WriteProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); +typedef int (DLL_CALLCONV *FI_SeekProc) (fi_handle handle, long offset, int origin); +typedef long (DLL_CALLCONV *FI_TellProc) (fi_handle handle); + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(push, 1) +#else +#pragma pack(1) +#endif // WIN32 + +FI_STRUCT(FreeImageIO) { + FI_ReadProc read_proc; //! pointer to the function used to read data + FI_WriteProc write_proc; //! pointer to the function used to write data + FI_SeekProc seek_proc; //! pointer to the function used to seek + FI_TellProc tell_proc; //! pointer to the function used to aquire the current position +}; + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(pop) +#else +#pragma pack() +#endif // WIN32 + +/** +Handle to a memory I/O stream +*/ +FI_STRUCT (FIMEMORY) { void *data; }; + +#endif // FREEIMAGE_IO + +// Plugin routines ---------------------------------------------------------- + +#ifndef PLUGINS +#define PLUGINS + +typedef const char *(DLL_CALLCONV *FI_FormatProc)(void); +typedef const char *(DLL_CALLCONV *FI_DescriptionProc)(void); +typedef const char *(DLL_CALLCONV *FI_ExtensionListProc)(void); +typedef const char *(DLL_CALLCONV *FI_RegExprProc)(void); +typedef void *(DLL_CALLCONV *FI_OpenProc)(FreeImageIO *io, fi_handle handle, BOOL read); +typedef void (DLL_CALLCONV *FI_CloseProc)(FreeImageIO *io, fi_handle handle, void *data); +typedef int (DLL_CALLCONV *FI_PageCountProc)(FreeImageIO *io, fi_handle handle, void *data); +typedef int (DLL_CALLCONV *FI_PageCapabilityProc)(FreeImageIO *io, fi_handle handle, void *data); +typedef FIBITMAP *(DLL_CALLCONV *FI_LoadProc)(FreeImageIO *io, fi_handle handle, int page, int flags, void *data); +typedef BOOL (DLL_CALLCONV *FI_SaveProc)(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data); +typedef BOOL (DLL_CALLCONV *FI_ValidateProc)(FreeImageIO *io, fi_handle handle); +typedef const char *(DLL_CALLCONV *FI_MimeProc)(void); +typedef BOOL (DLL_CALLCONV *FI_SupportsExportBPPProc)(int bpp); +typedef BOOL (DLL_CALLCONV *FI_SupportsExportTypeProc)(FREE_IMAGE_TYPE type); +typedef BOOL (DLL_CALLCONV *FI_SupportsICCProfilesProc)(void); +typedef BOOL (DLL_CALLCONV *FI_SupportsNoPixelsProc)(void); + +FI_STRUCT (Plugin) { + FI_FormatProc format_proc; + FI_DescriptionProc description_proc; + FI_ExtensionListProc extension_proc; + FI_RegExprProc regexpr_proc; + FI_OpenProc open_proc; + FI_CloseProc close_proc; + FI_PageCountProc pagecount_proc; + FI_PageCapabilityProc pagecapability_proc; + FI_LoadProc load_proc; + FI_SaveProc save_proc; + FI_ValidateProc validate_proc; + FI_MimeProc mime_proc; + FI_SupportsExportBPPProc supports_export_bpp_proc; + FI_SupportsExportTypeProc supports_export_type_proc; + FI_SupportsICCProfilesProc supports_icc_profiles_proc; + FI_SupportsNoPixelsProc supports_no_pixels_proc; +}; + +typedef void (DLL_CALLCONV *FI_InitProc)(Plugin *plugin, int format_id); + +#endif // PLUGINS + + +// Load / Save flag constants ----------------------------------------------- + +#define FIF_LOAD_NOPIXELS 0x8000 //! loading: load the image header only (not supported by all plugins, default to full loading) + +#define BMP_DEFAULT 0 +#define BMP_SAVE_RLE 1 +#define CUT_DEFAULT 0 +#define DDS_DEFAULT 0 +#define EXR_DEFAULT 0 //! save data as half with piz-based wavelet compression +#define EXR_FLOAT 0x0001 //! save data as float instead of as half (not recommended) +#define EXR_NONE 0x0002 //! save with no compression +#define EXR_ZIP 0x0004 //! save with zlib compression, in blocks of 16 scan lines +#define EXR_PIZ 0x0008 //! save with piz-based wavelet compression +#define EXR_PXR24 0x0010 //! save with lossy 24-bit float compression +#define EXR_B44 0x0020 //! save with lossy 44% float compression - goes to 22% when combined with EXR_LC +#define EXR_LC 0x0040 //! save images with one luminance and two chroma channels, rather than as RGB (lossy compression) +#define FAXG3_DEFAULT 0 +#define GIF_DEFAULT 0 +#define GIF_LOAD256 1 //! load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color +#define GIF_PLAYBACK 2 //! 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading +#define HDR_DEFAULT 0 +#define ICO_DEFAULT 0 +#define ICO_MAKEALPHA 1 //! convert to 32bpp and create an alpha channel from the AND-mask when loading +#define IFF_DEFAULT 0 +#define J2K_DEFAULT 0 //! save with a 16:1 rate +#define JP2_DEFAULT 0 //! save with a 16:1 rate +#define JPEG_DEFAULT 0 //! loading (see JPEG_FAST); saving (see JPEG_QUALITYGOOD|JPEG_SUBSAMPLING_420) +#define JPEG_FAST 0x0001 //! load the file as fast as possible, sacrificing some quality +#define JPEG_ACCURATE 0x0002 //! load the file with the best quality, sacrificing some speed +#define JPEG_CMYK 0x0004 //! load separated CMYK "as is" (use | to combine with other load flags) +#define JPEG_EXIFROTATE 0x0008 //! load and rotate according to Exif 'Orientation' tag if available +#define JPEG_GREYSCALE 0x0010 //! load and convert to a 8-bit greyscale image +#define JPEG_QUALITYSUPERB 0x80 //! save with superb quality (100:1) +#define JPEG_QUALITYGOOD 0x0100 //! save with good quality (75:1) +#define JPEG_QUALITYNORMAL 0x0200 //! save with normal quality (50:1) +#define JPEG_QUALITYAVERAGE 0x0400 //! save with average quality (25:1) +#define JPEG_QUALITYBAD 0x0800 //! save with bad quality (10:1) +#define JPEG_PROGRESSIVE 0x2000 //! save as a progressive-JPEG (use | to combine with other save flags) +#define JPEG_SUBSAMPLING_411 0x1000 //! save with high 4x1 chroma subsampling (4:1:1) +#define JPEG_SUBSAMPLING_420 0x4000 //! save with medium 2x2 medium chroma subsampling (4:2:0) - default value +#define JPEG_SUBSAMPLING_422 0x8000 //! save with low 2x1 chroma subsampling (4:2:2) +#define JPEG_SUBSAMPLING_444 0x10000 //! save with no chroma subsampling (4:4:4) +#define JPEG_OPTIMIZE 0x20000 //! on saving, compute optimal Huffman coding tables (can reduce a few percent of file size) +#define JPEG_BASELINE 0x40000 //! save basic JPEG, without metadata or any markers +#define KOALA_DEFAULT 0 +#define LBM_DEFAULT 0 +#define MNG_DEFAULT 0 +#define PCD_DEFAULT 0 +#define PCD_BASE 1 //! load the bitmap sized 768 x 512 +#define PCD_BASEDIV4 2 //! load the bitmap sized 384 x 256 +#define PCD_BASEDIV16 3 //! load the bitmap sized 192 x 128 +#define PCX_DEFAULT 0 +#define PFM_DEFAULT 0 +#define PICT_DEFAULT 0 +#define PNG_DEFAULT 0 +#define PNG_IGNOREGAMMA 1 //! loading: avoid gamma correction +#define PNG_Z_BEST_SPEED 0x0001 //! save using ZLib level 1 compression flag (default value is 6) +#define PNG_Z_DEFAULT_COMPRESSION 0x0006 //! save using ZLib level 6 compression flag (default recommended value) +#define PNG_Z_BEST_COMPRESSION 0x0009 //! save using ZLib level 9 compression flag (default value is 6) +#define PNG_Z_NO_COMPRESSION 0x0100 //! save without ZLib compression +#define PNG_INTERLACED 0x0200 //! save using Adam7 interlacing (use | to combine with other save flags) +#define PNM_DEFAULT 0 +#define PNM_SAVE_RAW 0 //! if set the writer saves in RAW format (i.e. P4, P5 or P6) +#define PNM_SAVE_ASCII 1 //! if set the writer saves in ASCII format (i.e. P1, P2 or P3) +#define PSD_DEFAULT 0 +#define PSD_CMYK 1 //! reads tags for separated CMYK (default is conversion to RGB) +#define PSD_LAB 2 //! reads tags for CIELab (default is conversion to RGB) +#define RAS_DEFAULT 0 +#define RAW_DEFAULT 0 //! load the file as linear RGB 48-bit +#define RAW_PREVIEW 1 //! try to load the embedded JPEG preview with included Exif Data or default to RGB 24-bit +#define RAW_DISPLAY 2 //! load the file as RGB 24-bit +#define RAW_HALFSIZE 4 //! output a half-size color image +#define RAW_UNPROCESSED 8 //! output a FIT_UINT16 raw Bayer image +#define SGI_DEFAULT 0 +#define TARGA_DEFAULT 0 +#define TARGA_LOAD_RGB888 1 //! if set the loader converts RGB555 and ARGB8888 -> RGB888. +#define TARGA_SAVE_RLE 2 //! if set, the writer saves with RLE compression +#define TIFF_DEFAULT 0 +#define TIFF_CMYK 0x0001 //! reads/stores tags for separated CMYK (use | to combine with compression flags) +#define TIFF_PACKBITS 0x0100 //! save using PACKBITS compression +#define TIFF_DEFLATE 0x0200 //! save using DEFLATE compression (a.k.a. ZLIB compression) +#define TIFF_ADOBE_DEFLATE 0x0400 //! save using ADOBE DEFLATE compression +#define TIFF_NONE 0x0800 //! save without any compression +#define TIFF_CCITTFAX3 0x1000 //! save using CCITT Group 3 fax encoding +#define TIFF_CCITTFAX4 0x2000 //! save using CCITT Group 4 fax encoding +#define TIFF_LZW 0x4000 //! save using LZW compression +#define TIFF_JPEG 0x8000 //! save using JPEG compression +#define TIFF_LOGLUV 0x10000 //! save using LogLuv compression +#define WBMP_DEFAULT 0 +#define XBM_DEFAULT 0 +#define XPM_DEFAULT 0 +#define WEBP_DEFAULT 0 //! save with good quality (75:1) +#define WEBP_LOSSLESS 0x100 //! save in lossless mode +#define JXR_DEFAULT 0 //! save with quality 80 and no chroma subsampling (4:4:4) +#define JXR_LOSSLESS 0x0064 //! save lossless +#define JXR_PROGRESSIVE 0x2000 //! save as a progressive-JXR (use | to combine with other save flags) + +// Background filling options --------------------------------------------------------- +// Constants used in FreeImage_FillBackground and FreeImage_EnlargeCanvas + +#define FI_COLOR_IS_RGB_COLOR 0x00 //! RGBQUAD color is a RGB color (contains no valid alpha channel) +#define FI_COLOR_IS_RGBA_COLOR 0x01 //! RGBQUAD color is a RGBA color (contains a valid alpha channel) +#define FI_COLOR_FIND_EQUAL_COLOR 0x02 //! For palettized images: lookup equal RGB color from palette +#define FI_COLOR_ALPHA_IS_INDEX 0x04 //! The color's rgbReserved member (alpha) contains the palette index to be used +#define FI_COLOR_PALETTE_SEARCH_MASK (FI_COLOR_FIND_EQUAL_COLOR | FI_COLOR_ALPHA_IS_INDEX) // No color lookup is performed + +// RescaleEx options --------------------------------------------------------- +// Constants used in FreeImage_RescaleEx + +#define FI_RESCALE_DEFAULT 0x00 //! default options; none of the following other options apply +#define FI_RESCALE_TRUE_COLOR 0x01 //! for non-transparent greyscale images, convert to 24-bit if src bitdepth <= 8 (default is a 8-bit greyscale image). +#define FI_RESCALE_OMIT_METADATA 0x02 //! do not copy metadata to the rescaled image + + +#ifdef __cplusplus +extern "C" { +#endif + +// Init / Error routines ---------------------------------------------------- + +DLL_API void DLL_CALLCONV FreeImage_Initialise(BOOL load_local_plugins_only FI_DEFAULT(FALSE)); +DLL_API void DLL_CALLCONV FreeImage_DeInitialise(void); + +// Version routines --------------------------------------------------------- + +DLL_API const char *DLL_CALLCONV FreeImage_GetVersion(void); +DLL_API const char *DLL_CALLCONV FreeImage_GetCopyrightMessage(void); + +// Message output functions ------------------------------------------------- + +typedef void (*FreeImage_OutputMessageFunction)(FREE_IMAGE_FORMAT fif, const char *msg); +typedef void (DLL_CALLCONV *FreeImage_OutputMessageFunctionStdCall)(FREE_IMAGE_FORMAT fif, const char *msg); + +DLL_API void DLL_CALLCONV FreeImage_SetOutputMessageStdCall(FreeImage_OutputMessageFunctionStdCall omf); +DLL_API void DLL_CALLCONV FreeImage_SetOutputMessage(FreeImage_OutputMessageFunction omf); +DLL_API void DLL_CALLCONV FreeImage_OutputMessageProc(int fif, const char *fmt, ...); + +// Allocate / Clone / Unload routines --------------------------------------- + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Allocate(int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp FI_DEFAULT(8), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); +DLL_API FIBITMAP * DLL_CALLCONV FreeImage_Clone(FIBITMAP *dib); +DLL_API void DLL_CALLCONV FreeImage_Unload(FIBITMAP *dib); + +// Header loading routines +DLL_API BOOL DLL_CALLCONV FreeImage_HasPixels(FIBITMAP *dib); + +// Load / Save routines ----------------------------------------------------- + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif, const char *filename, int flags FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadU(FREE_IMAGE_FORMAT fif, const wchar_t *filename, int flags FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const wchar_t *filename, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); + +// Memory I/O stream routines ----------------------------------------------- + +DLL_API FIMEMORY *DLL_CALLCONV FreeImage_OpenMemory(BYTE *data FI_DEFAULT(0), DWORD size_in_bytes FI_DEFAULT(0)); +DLL_API void DLL_CALLCONV FreeImage_CloseMemory(FIMEMORY *stream); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags FI_DEFAULT(0)); +DLL_API long DLL_CALLCONV FreeImage_TellMemory(FIMEMORY *stream); +DLL_API BOOL DLL_CALLCONV FreeImage_SeekMemory(FIMEMORY *stream, long offset, int origin); +DLL_API BOOL DLL_CALLCONV FreeImage_AcquireMemory(FIMEMORY *stream, BYTE **data, DWORD *size_in_bytes); +DLL_API unsigned DLL_CALLCONV FreeImage_ReadMemory(void *buffer, unsigned size, unsigned count, FIMEMORY *stream); +DLL_API unsigned DLL_CALLCONV FreeImage_WriteMemory(const void *buffer, unsigned size, unsigned count, FIMEMORY *stream); + +DLL_API FIMULTIBITMAP *DLL_CALLCONV FreeImage_LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_SaveMultiBitmapToMemory(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, FIMEMORY *stream, int flags); + +// Plugin Interface --------------------------------------------------------- + +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterLocalPlugin(FI_InitProc proc_address, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0)); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterExternalPlugin(const char *path, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0)); +DLL_API int DLL_CALLCONV FreeImage_GetFIFCount(void); +DLL_API int DLL_CALLCONV FreeImage_SetPluginEnabled(FREE_IMAGE_FORMAT fif, BOOL enable); +DLL_API int DLL_CALLCONV FreeImage_IsPluginEnabled(FREE_IMAGE_FORMAT fif); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFormat(const char *format); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromMime(const char *mime); +DLL_API const char *DLL_CALLCONV FreeImage_GetFormatFromFIF(FREE_IMAGE_FORMAT fif); +DLL_API const char *DLL_CALLCONV FreeImage_GetFIFExtensionList(FREE_IMAGE_FORMAT fif); +DLL_API const char *DLL_CALLCONV FreeImage_GetFIFDescription(FREE_IMAGE_FORMAT fif); +DLL_API const char *DLL_CALLCONV FreeImage_GetFIFRegExpr(FREE_IMAGE_FORMAT fif); +DLL_API const char *DLL_CALLCONV FreeImage_GetFIFMimeType(FREE_IMAGE_FORMAT fif); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilename(const char *filename); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilenameU(const wchar_t *filename); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsReading(FREE_IMAGE_FORMAT fif); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsWriting(FREE_IMAGE_FORMAT fif); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportBPP(FREE_IMAGE_FORMAT fif, int bpp); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportType(FREE_IMAGE_FORMAT fif, FREE_IMAGE_TYPE type); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsICCProfiles(FREE_IMAGE_FORMAT fif); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsNoPixels(FREE_IMAGE_FORMAT fif); + +// Multipaging interface ---------------------------------------------------- + +DLL_API FIMULTIBITMAP * DLL_CALLCONV FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL create_new, BOOL read_only, BOOL keep_cache_in_memory FI_DEFAULT(FALSE), int flags FI_DEFAULT(0)); +DLL_API FIMULTIBITMAP * DLL_CALLCONV FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_SaveMultiBitmapToHandle(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_CloseMultiBitmap(FIMULTIBITMAP *bitmap, int flags FI_DEFAULT(0)); +DLL_API int DLL_CALLCONV FreeImage_GetPageCount(FIMULTIBITMAP *bitmap); +DLL_API void DLL_CALLCONV FreeImage_AppendPage(FIMULTIBITMAP *bitmap, FIBITMAP *data); +DLL_API void DLL_CALLCONV FreeImage_InsertPage(FIMULTIBITMAP *bitmap, int page, FIBITMAP *data); +DLL_API void DLL_CALLCONV FreeImage_DeletePage(FIMULTIBITMAP *bitmap, int page); +DLL_API FIBITMAP * DLL_CALLCONV FreeImage_LockPage(FIMULTIBITMAP *bitmap, int page); +DLL_API void DLL_CALLCONV FreeImage_UnlockPage(FIMULTIBITMAP *bitmap, FIBITMAP *data, BOOL changed); +DLL_API BOOL DLL_CALLCONV FreeImage_MovePage(FIMULTIBITMAP *bitmap, int target, int source); +DLL_API BOOL DLL_CALLCONV FreeImage_GetLockedPageNumbers(FIMULTIBITMAP *bitmap, int *pages, int *count); + +// Filetype request routines ------------------------------------------------ + +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileType(const char *filename, int size FI_DEFAULT(0)); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeU(const wchar_t *filename, int size FI_DEFAULT(0)); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size FI_DEFAULT(0)); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromMemory(FIMEMORY *stream, int size FI_DEFAULT(0)); + +// Image type request routine ----------------------------------------------- + +DLL_API FREE_IMAGE_TYPE DLL_CALLCONV FreeImage_GetImageType(FIBITMAP *dib); + +// FreeImage helper routines ------------------------------------------------ + +DLL_API BOOL DLL_CALLCONV FreeImage_IsLittleEndian(void); +DLL_API BOOL DLL_CALLCONV FreeImage_LookupX11Color(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nBlue); +DLL_API BOOL DLL_CALLCONV FreeImage_LookupSVGColor(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nBlue); + +// Pixel access routines ---------------------------------------------------- + +DLL_API BYTE *DLL_CALLCONV FreeImage_GetBits(FIBITMAP *dib); +DLL_API BYTE *DLL_CALLCONV FreeImage_GetScanLine(FIBITMAP *dib, int scanline); + +DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value); +DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value); +DLL_API BOOL DLL_CALLCONV FreeImage_SetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value); +DLL_API BOOL DLL_CALLCONV FreeImage_SetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value); + +// DIB info routines -------------------------------------------------------- + +DLL_API unsigned DLL_CALLCONV FreeImage_GetColorsUsed(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetBPP(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetWidth(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetHeight(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetLine(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetPitch(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetDIBSize(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetMemorySize(FIBITMAP *dib); +DLL_API RGBQUAD *DLL_CALLCONV FreeImage_GetPalette(FIBITMAP *dib); + +DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterX(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterY(FIBITMAP *dib); +DLL_API void DLL_CALLCONV FreeImage_SetDotsPerMeterX(FIBITMAP *dib, unsigned res); +DLL_API void DLL_CALLCONV FreeImage_SetDotsPerMeterY(FIBITMAP *dib, unsigned res); + +DLL_API BITMAPINFOHEADER *DLL_CALLCONV FreeImage_GetInfoHeader(FIBITMAP *dib); +DLL_API BITMAPINFO *DLL_CALLCONV FreeImage_GetInfo(FIBITMAP *dib); +DLL_API FREE_IMAGE_COLOR_TYPE DLL_CALLCONV FreeImage_GetColorType(FIBITMAP *dib); + +DLL_API unsigned DLL_CALLCONV FreeImage_GetRedMask(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetGreenMask(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetBlueMask(FIBITMAP *dib); + +DLL_API unsigned DLL_CALLCONV FreeImage_GetTransparencyCount(FIBITMAP *dib); +DLL_API BYTE * DLL_CALLCONV FreeImage_GetTransparencyTable(FIBITMAP *dib); +DLL_API void DLL_CALLCONV FreeImage_SetTransparent(FIBITMAP *dib, BOOL enabled); +DLL_API void DLL_CALLCONV FreeImage_SetTransparencyTable(FIBITMAP *dib, BYTE *table, int count); +DLL_API BOOL DLL_CALLCONV FreeImage_IsTransparent(FIBITMAP *dib); +DLL_API void DLL_CALLCONV FreeImage_SetTransparentIndex(FIBITMAP *dib, int index); +DLL_API int DLL_CALLCONV FreeImage_GetTransparentIndex(FIBITMAP *dib); + +DLL_API BOOL DLL_CALLCONV FreeImage_HasBackgroundColor(FIBITMAP *dib); +DLL_API BOOL DLL_CALLCONV FreeImage_GetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor); +DLL_API BOOL DLL_CALLCONV FreeImage_SetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetThumbnail(FIBITMAP *dib); +DLL_API BOOL DLL_CALLCONV FreeImage_SetThumbnail(FIBITMAP *dib, FIBITMAP *thumbnail); + +// ICC profile routines ----------------------------------------------------- + +DLL_API FIICCPROFILE *DLL_CALLCONV FreeImage_GetICCProfile(FIBITMAP *dib); +DLL_API FIICCPROFILE *DLL_CALLCONV FreeImage_CreateICCProfile(FIBITMAP *dib, void *data, long size); +DLL_API void DLL_CALLCONV FreeImage_DestroyICCProfile(FIBITMAP *dib); + +// Line conversion routines ------------------------------------------------- + +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To4(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To4(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To4_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To4_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To4(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To4(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To8(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To8(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To8(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To8(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_565_To16_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_555_To16_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To24(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To32(BYTE *target, BYTE *source, int width_in_pixels); + +// Smart conversion routines ------------------------------------------------ + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo4Bits(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo8Bits(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToGreyscale(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits555(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits565(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo24Bits(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo32Bits(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantize(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantizeEx(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize FI_DEFAULT(FIQ_WUQUANT), int PaletteSize FI_DEFAULT(256), int ReserveSize FI_DEFAULT(0), RGBQUAD *ReservePalette FI_DEFAULT(NULL)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Threshold(FIBITMAP *dib, BYTE T); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Dither(FIBITMAP *dib, FREE_IMAGE_DITHER algorithm); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertFromRawBits(BYTE *bits, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertFromRawBitsEx(BOOL copySource, BYTE *bits, FREE_IMAGE_TYPE type, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); +DLL_API void DLL_CALLCONV FreeImage_ConvertToRawBits(BYTE *bits, FIBITMAP *dib, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToFloat(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGBF(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGBAF(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToUINT16(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGB16(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGBA16(FIBITMAP *dib); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToStandardType(FIBITMAP *src, BOOL scale_linear FI_DEFAULT(TRUE)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToType(FIBITMAP *src, FREE_IMAGE_TYPE dst_type, BOOL scale_linear FI_DEFAULT(TRUE)); + +// Tone mapping operators --------------------------------------------------- + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ToneMapping(FIBITMAP *dib, FREE_IMAGE_TMO tmo, double first_param FI_DEFAULT(0), double second_param FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoDrago03(FIBITMAP *src, double gamma FI_DEFAULT(2.2), double exposure FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoReinhard05(FIBITMAP *src, double intensity FI_DEFAULT(0), double contrast FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoReinhard05Ex(FIBITMAP *src, double intensity FI_DEFAULT(0), double contrast FI_DEFAULT(0), double adaptation FI_DEFAULT(1), double color_correction FI_DEFAULT(0)); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoFattal02(FIBITMAP *src, double color_saturation FI_DEFAULT(0.5), double attenuation FI_DEFAULT(0.85)); + +// ZLib interface ----------------------------------------------------------- + +DLL_API DWORD DLL_CALLCONV FreeImage_ZLibCompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); +DLL_API DWORD DLL_CALLCONV FreeImage_ZLibUncompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); +DLL_API DWORD DLL_CALLCONV FreeImage_ZLibGZip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); +DLL_API DWORD DLL_CALLCONV FreeImage_ZLibGUnzip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); +DLL_API DWORD DLL_CALLCONV FreeImage_ZLibCRC32(DWORD crc, BYTE *source, DWORD source_size); + +// -------------------------------------------------------------------------- +// Metadata routines +// -------------------------------------------------------------------------- + +// tag creation / destruction +DLL_API FITAG *DLL_CALLCONV FreeImage_CreateTag(void); +DLL_API void DLL_CALLCONV FreeImage_DeleteTag(FITAG *tag); +DLL_API FITAG *DLL_CALLCONV FreeImage_CloneTag(FITAG *tag); + +// tag getters and setters +DLL_API const char *DLL_CALLCONV FreeImage_GetTagKey(FITAG *tag); +DLL_API const char *DLL_CALLCONV FreeImage_GetTagDescription(FITAG *tag); +DLL_API WORD DLL_CALLCONV FreeImage_GetTagID(FITAG *tag); +DLL_API FREE_IMAGE_MDTYPE DLL_CALLCONV FreeImage_GetTagType(FITAG *tag); +DLL_API DWORD DLL_CALLCONV FreeImage_GetTagCount(FITAG *tag); +DLL_API DWORD DLL_CALLCONV FreeImage_GetTagLength(FITAG *tag); +DLL_API const void *DLL_CALLCONV FreeImage_GetTagValue(FITAG *tag); + +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagKey(FITAG *tag, const char *key); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagDescription(FITAG *tag, const char *description); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagID(FITAG *tag, WORD id); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagType(FITAG *tag, FREE_IMAGE_MDTYPE type); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagCount(FITAG *tag, DWORD count); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagLength(FITAG *tag, DWORD length); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagValue(FITAG *tag, const void *value); + +// iterator +DLL_API FIMETADATA *DLL_CALLCONV FreeImage_FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, FITAG **tag); +DLL_API BOOL DLL_CALLCONV FreeImage_FindNextMetadata(FIMETADATA *mdhandle, FITAG **tag); +DLL_API void DLL_CALLCONV FreeImage_FindCloseMetadata(FIMETADATA *mdhandle); + +// metadata setter and getter +DLL_API BOOL DLL_CALLCONV FreeImage_SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG *tag); +DLL_API BOOL DLL_CALLCONV FreeImage_GetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG **tag); +DLL_API BOOL DLL_CALLCONV FreeImage_SetMetadataKeyValue(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, const char *value); + +// helpers +DLL_API unsigned DLL_CALLCONV FreeImage_GetMetadataCount(FREE_IMAGE_MDMODEL model, FIBITMAP *dib); +DLL_API BOOL DLL_CALLCONV FreeImage_CloneMetadata(FIBITMAP *dst, FIBITMAP *src); + +// tag to C string conversion +DLL_API const char* DLL_CALLCONV FreeImage_TagToString(FREE_IMAGE_MDMODEL model, FITAG *tag, char *Make FI_DEFAULT(NULL)); + +// -------------------------------------------------------------------------- +// JPEG lossless transformation routines +// -------------------------------------------------------------------------- + +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransform(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE)); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE)); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCropU(const wchar_t *src_file, const wchar_t *dst_file, int left, int top, int right, int bottom); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformFromHandle(FreeImageIO* src_io, fi_handle src_handle, FreeImageIO* dst_io, fi_handle dst_handle, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombined(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedFromMemory(FIMEMORY* src_stream, FIMEMORY* dst_stream, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); + + +// -------------------------------------------------------------------------- +// Image manipulation toolkit +// -------------------------------------------------------------------------- + +// rotation and flipping +/// @deprecated see FreeImage_Rotate +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateClassic(FIBITMAP *dib, double angle); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rotate(FIBITMAP *dib, double angle, const void *bkcolor FI_DEFAULT(NULL)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateEx(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask); +DLL_API BOOL DLL_CALLCONV FreeImage_FlipHorizontal(FIBITMAP *dib); +DLL_API BOOL DLL_CALLCONV FreeImage_FlipVertical(FIBITMAP *dib); + +// upsampling / downsampling +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rescale(FIBITMAP *dib, int dst_width, int dst_height, FREE_IMAGE_FILTER filter FI_DEFAULT(FILTER_CATMULLROM)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MakeThumbnail(FIBITMAP *dib, int max_pixel_size, BOOL convert FI_DEFAULT(TRUE)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RescaleRect(FIBITMAP *dib, int dst_width, int dst_height, int left, int top, int right, int bottom, FREE_IMAGE_FILTER filter FI_DEFAULT(FILTER_CATMULLROM), unsigned flags FI_DEFAULT(0)); + +// color manipulation routines (point operations) +DLL_API BOOL DLL_CALLCONV FreeImage_AdjustCurve(FIBITMAP *dib, BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel); +DLL_API BOOL DLL_CALLCONV FreeImage_AdjustGamma(FIBITMAP *dib, double gamma); +DLL_API BOOL DLL_CALLCONV FreeImage_AdjustBrightness(FIBITMAP *dib, double percentage); +DLL_API BOOL DLL_CALLCONV FreeImage_AdjustContrast(FIBITMAP *dib, double percentage); +DLL_API BOOL DLL_CALLCONV FreeImage_Invert(FIBITMAP *dib); +DLL_API BOOL DLL_CALLCONV FreeImage_GetHistogram(FIBITMAP *dib, DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel FI_DEFAULT(FICC_BLACK)); +DLL_API int DLL_CALLCONV FreeImage_GetAdjustColorsLookupTable(BYTE *LUT, double brightness, double contrast, double gamma, BOOL invert); +DLL_API BOOL DLL_CALLCONV FreeImage_AdjustColors(FIBITMAP *dib, double brightness, double contrast, double gamma, BOOL invert FI_DEFAULT(FALSE)); +DLL_API unsigned DLL_CALLCONV FreeImage_ApplyColorMapping(FIBITMAP *dib, RGBQUAD *srccolors, RGBQUAD *dstcolors, unsigned count, BOOL ignore_alpha, BOOL swap); +DLL_API unsigned DLL_CALLCONV FreeImage_SwapColors(FIBITMAP *dib, RGBQUAD *color_a, RGBQUAD *color_b, BOOL ignore_alpha); +DLL_API unsigned DLL_CALLCONV FreeImage_ApplyPaletteIndexMapping(FIBITMAP *dib, BYTE *srcindices, BYTE *dstindices, unsigned count, BOOL swap); +DLL_API unsigned DLL_CALLCONV FreeImage_SwapPaletteIndices(FIBITMAP *dib, BYTE *index_a, BYTE *index_b); + +// channel processing routines +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetChannel(FIBITMAP *dib, FREE_IMAGE_COLOR_CHANNEL channel); +DLL_API BOOL DLL_CALLCONV FreeImage_SetChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetComplexChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel); +DLL_API BOOL DLL_CALLCONV FreeImage_SetComplexChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel); + +// copy / paste / composite routines +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Copy(FIBITMAP *dib, int left, int top, int right, int bottom); +DLL_API BOOL DLL_CALLCONV FreeImage_Paste(FIBITMAP *dst, FIBITMAP *src, int left, int top, int alpha); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_CreateView(FIBITMAP *dib, unsigned left, unsigned top, unsigned right, unsigned bottom); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Composite(FIBITMAP *fg, BOOL useFileBkg FI_DEFAULT(FALSE), RGBQUAD *appBkColor FI_DEFAULT(NULL), FIBITMAP *bg FI_DEFAULT(NULL)); +DLL_API BOOL DLL_CALLCONV FreeImage_PreMultiplyWithAlpha(FIBITMAP *dib); + +// background filling routines +DLL_API BOOL DLL_CALLCONV FreeImage_FillBackground(FIBITMAP *dib, const void *color, int options FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_EnlargeCanvas(FIBITMAP *src, int left, int top, int right, int bottom, const void *color, int options FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateEx(int width, int height, int bpp, const RGBQUAD *color, int options FI_DEFAULT(0), const RGBQUAD *palette FI_DEFAULT(NULL), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateExT(FREE_IMAGE_TYPE type, int width, int height, int bpp, const void *color, int options FI_DEFAULT(0), const RGBQUAD *palette FI_DEFAULT(NULL), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); + +// miscellaneous algorithms +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle FI_DEFAULT(3)); + +// restore the borland-specific enum size option +#if defined(__BORLANDC__) +#pragma option pop +#endif + +#ifdef __cplusplus +} +#endif + +#endif // FREEIMAGE_H diff --git a/#ThirdParty/FreeImage/Dist/x32/FreeImage.lib b/#ThirdParty/FreeImage/Dist/x32/FreeImage.lib new file mode 100644 index 0000000..28071aa Binary files /dev/null and b/#ThirdParty/FreeImage/Dist/x32/FreeImage.lib differ diff --git a/#ThirdParty/FreeImage/Dist/x64/FreeImage.dll b/#ThirdParty/FreeImage/Dist/x64/FreeImage.dll new file mode 100644 index 0000000..0562f4a Binary files /dev/null and b/#ThirdParty/FreeImage/Dist/x64/FreeImage.dll differ diff --git a/#ThirdParty/FreeImage/Dist/x64/FreeImage.h b/#ThirdParty/FreeImage/Dist/x64/FreeImage.h new file mode 100644 index 0000000..e2d1c5a --- /dev/null +++ b/#ThirdParty/FreeImage/Dist/x64/FreeImage.h @@ -0,0 +1,1153 @@ +// ========================================================== +// FreeImage 3 +// +// Design and implementation by +// - Floris van den Berg (flvdberg@wxs.nl) +// - Hervé Drolon (drolon@infonie.fr) +// +// Contributors: +// - see changes log named 'Whatsnew.txt', see header of each .h and .cpp file +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#ifndef FREEIMAGE_H +#define FREEIMAGE_H + +// Version information ------------------------------------------------------ + +#define FREEIMAGE_MAJOR_VERSION 3 +#define FREEIMAGE_MINOR_VERSION 17 +#define FREEIMAGE_RELEASE_SERIAL 0 + +// Compiler options --------------------------------------------------------- + +#include // needed for UNICODE functions + +#if defined(FREEIMAGE_LIB) + #define DLL_API + #define DLL_CALLCONV +#else + #if defined(_WIN32) || defined(__WIN32__) + #define DLL_CALLCONV __stdcall + // The following ifdef block is the standard way of creating macros which make exporting + // from a DLL simpler. All files within this DLL are compiled with the FREEIMAGE_EXPORTS + // symbol defined on the command line. this symbol should not be defined on any project + // that uses this DLL. This way any other project whose source files include this file see + // DLL_API functions as being imported from a DLL, wheras this DLL sees symbols + // defined with this macro as being exported. + #ifdef FREEIMAGE_EXPORTS + #define DLL_API __declspec(dllexport) + #else + #define DLL_API __declspec(dllimport) + #endif // FREEIMAGE_EXPORTS + #else + // try the gcc visibility support (see http://gcc.gnu.org/wiki/Visibility) + #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) + #ifndef GCC_HASCLASSVISIBILITY + #define GCC_HASCLASSVISIBILITY + #endif + #endif // __GNUC__ + #define DLL_CALLCONV + #if defined(GCC_HASCLASSVISIBILITY) + #define DLL_API __attribute__ ((visibility("default"))) + #else + #define DLL_API + #endif + #endif // WIN32 / !WIN32 +#endif // FREEIMAGE_LIB + +// Endianness: +// Some versions of gcc may have BYTE_ORDER or __BYTE_ORDER defined. +// If your big endian system isn't being detected, add an OS specific check +// or define any of FREEIMAGE_BIGENDIAN and FREEIMAGE_LITTLEENDIAN directly +// to specify the desired endianness. +#if (!defined(FREEIMAGE_BIGENDIAN) && !defined(FREEIMAGE_LITTLEENDIAN)) + #if (defined(BYTE_ORDER) && BYTE_ORDER==BIG_ENDIAN) || (defined(__BYTE_ORDER) && __BYTE_ORDER==__BIG_ENDIAN) || defined(__BIG_ENDIAN__) + #define FREEIMAGE_BIGENDIAN + #endif // BYTE_ORDER +#endif // !FREEIMAGE_[BIG|LITTLE]ENDIAN + +// Color-Order: +// The specified order of color components red, green and blue affects 24- +// and 32-bit images of type FIT_BITMAP as well as the colors that are part +// of a color palette. All other images always use RGB order. By default, +// color order is coupled to endianness: +// little-endian -> BGR +// big-endian -> RGB +// However, you can always define FREEIMAGE_COLORORDER to any of the known +// orders FREEIMAGE_COLORORDER_BGR (0) and FREEIMAGE_COLORORDER_RGB (1) to +// specify your preferred color order. +#define FREEIMAGE_COLORORDER_BGR 0 +#define FREEIMAGE_COLORORDER_RGB 1 +#if (!defined(FREEIMAGE_COLORORDER)) || ((FREEIMAGE_COLORORDER != FREEIMAGE_COLORORDER_BGR) && (FREEIMAGE_COLORORDER != FREEIMAGE_COLORORDER_RGB)) + #if defined(FREEIMAGE_BIGENDIAN) + #define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_RGB + #else + #define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_BGR + #endif // FREEIMAGE_BIGENDIAN +#endif // FREEIMAGE_COLORORDER + +// Ensure 4-byte enums if we're using Borland C++ compilers +#if defined(__BORLANDC__) +#pragma option push -b +#endif + +// For C compatibility -------------------------------------------------------- + +#ifdef __cplusplus +#define FI_DEFAULT(x) = x +#define FI_ENUM(x) enum x +#define FI_STRUCT(x) struct x +#else +#define FI_DEFAULT(x) +#define FI_ENUM(x) typedef int x; enum x +#define FI_STRUCT(x) typedef struct x x; struct x +#endif + +// Bitmap types ------------------------------------------------------------- + +FI_STRUCT (FIBITMAP) { void *data; }; +FI_STRUCT (FIMULTIBITMAP) { void *data; }; + +// Types used in the library (directly copied from Windows) ----------------- + +#if defined(__MINGW32__) && defined(_WINDOWS_H) +#define _WINDOWS_ // prevent a bug in MinGW32 +#endif // __MINGW32__ + +#ifndef _WINDOWS_ +#define _WINDOWS_ + +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef NULL +#define NULL 0 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#ifndef _MSC_VER +// define portable types for 32-bit / 64-bit OS +#include +typedef int32_t BOOL; +typedef uint8_t BYTE; +typedef uint16_t WORD; +typedef uint32_t DWORD; +typedef int32_t LONG; +typedef int64_t INT64; +typedef uint64_t UINT64; +#else +// MS is not C99 ISO compliant +typedef long BOOL; +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef unsigned long DWORD; +typedef long LONG; +typedef signed __int64 INT64; +typedef unsigned __int64 UINT64; +#endif // _MSC_VER + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(push, 1) +#else +#pragma pack(1) +#endif // WIN32 + +typedef struct tagRGBQUAD { +#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR + BYTE rgbBlue; + BYTE rgbGreen; + BYTE rgbRed; +#else + BYTE rgbRed; + BYTE rgbGreen; + BYTE rgbBlue; +#endif // FREEIMAGE_COLORORDER + BYTE rgbReserved; +} RGBQUAD; + +typedef struct tagRGBTRIPLE { +#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR + BYTE rgbtBlue; + BYTE rgbtGreen; + BYTE rgbtRed; +#else + BYTE rgbtRed; + BYTE rgbtGreen; + BYTE rgbtBlue; +#endif // FREEIMAGE_COLORORDER +} RGBTRIPLE; + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(pop) +#else +#pragma pack() +#endif // WIN32 + +typedef struct tagBITMAPINFOHEADER{ + DWORD biSize; + LONG biWidth; + LONG biHeight; + WORD biPlanes; + WORD biBitCount; + DWORD biCompression; + DWORD biSizeImage; + LONG biXPelsPerMeter; + LONG biYPelsPerMeter; + DWORD biClrUsed; + DWORD biClrImportant; +} BITMAPINFOHEADER, *PBITMAPINFOHEADER; + +typedef struct tagBITMAPINFO { + BITMAPINFOHEADER bmiHeader; + RGBQUAD bmiColors[1]; +} BITMAPINFO, *PBITMAPINFO; + +#endif // _WINDOWS_ + +// Types used in the library (specific to FreeImage) ------------------------ + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(push, 1) +#else +#pragma pack(1) +#endif // WIN32 + +/** 48-bit RGB +*/ +typedef struct tagFIRGB16 { + WORD red; + WORD green; + WORD blue; +} FIRGB16; + +/** 64-bit RGBA +*/ +typedef struct tagFIRGBA16 { + WORD red; + WORD green; + WORD blue; + WORD alpha; +} FIRGBA16; + +/** 96-bit RGB Float +*/ +typedef struct tagFIRGBF { + float red; + float green; + float blue; +} FIRGBF; + +/** 128-bit RGBA Float +*/ +typedef struct tagFIRGBAF { + float red; + float green; + float blue; + float alpha; +} FIRGBAF; + +/** Data structure for COMPLEX type (complex number) +*/ +typedef struct tagFICOMPLEX { + /// real part + double r; + /// imaginary part + double i; +} FICOMPLEX; + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(pop) +#else +#pragma pack() +#endif // WIN32 + +// Indexes for byte arrays, masks and shifts for treating pixels as words --- +// These coincide with the order of RGBQUAD and RGBTRIPLE ------------------- + +#ifndef FREEIMAGE_BIGENDIAN +#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR +// Little Endian (x86 / MS Windows, Linux) : BGR(A) order +#define FI_RGBA_RED 2 +#define FI_RGBA_GREEN 1 +#define FI_RGBA_BLUE 0 +#define FI_RGBA_ALPHA 3 +#define FI_RGBA_RED_MASK 0x00FF0000 +#define FI_RGBA_GREEN_MASK 0x0000FF00 +#define FI_RGBA_BLUE_MASK 0x000000FF +#define FI_RGBA_ALPHA_MASK 0xFF000000 +#define FI_RGBA_RED_SHIFT 16 +#define FI_RGBA_GREEN_SHIFT 8 +#define FI_RGBA_BLUE_SHIFT 0 +#define FI_RGBA_ALPHA_SHIFT 24 +#else +// Little Endian (x86 / MaxOSX) : RGB(A) order +#define FI_RGBA_RED 0 +#define FI_RGBA_GREEN 1 +#define FI_RGBA_BLUE 2 +#define FI_RGBA_ALPHA 3 +#define FI_RGBA_RED_MASK 0x000000FF +#define FI_RGBA_GREEN_MASK 0x0000FF00 +#define FI_RGBA_BLUE_MASK 0x00FF0000 +#define FI_RGBA_ALPHA_MASK 0xFF000000 +#define FI_RGBA_RED_SHIFT 0 +#define FI_RGBA_GREEN_SHIFT 8 +#define FI_RGBA_BLUE_SHIFT 16 +#define FI_RGBA_ALPHA_SHIFT 24 +#endif // FREEIMAGE_COLORORDER +#else +#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR +// Big Endian (PPC / none) : BGR(A) order +#define FI_RGBA_RED 2 +#define FI_RGBA_GREEN 1 +#define FI_RGBA_BLUE 0 +#define FI_RGBA_ALPHA 3 +#define FI_RGBA_RED_MASK 0x0000FF00 +#define FI_RGBA_GREEN_MASK 0x00FF0000 +#define FI_RGBA_BLUE_MASK 0xFF000000 +#define FI_RGBA_ALPHA_MASK 0x000000FF +#define FI_RGBA_RED_SHIFT 8 +#define FI_RGBA_GREEN_SHIFT 16 +#define FI_RGBA_BLUE_SHIFT 24 +#define FI_RGBA_ALPHA_SHIFT 0 +#else +// Big Endian (PPC / Linux, MaxOSX) : RGB(A) order +#define FI_RGBA_RED 0 +#define FI_RGBA_GREEN 1 +#define FI_RGBA_BLUE 2 +#define FI_RGBA_ALPHA 3 +#define FI_RGBA_RED_MASK 0xFF000000 +#define FI_RGBA_GREEN_MASK 0x00FF0000 +#define FI_RGBA_BLUE_MASK 0x0000FF00 +#define FI_RGBA_ALPHA_MASK 0x000000FF +#define FI_RGBA_RED_SHIFT 24 +#define FI_RGBA_GREEN_SHIFT 16 +#define FI_RGBA_BLUE_SHIFT 8 +#define FI_RGBA_ALPHA_SHIFT 0 +#endif // FREEIMAGE_COLORORDER +#endif // FREEIMAGE_BIGENDIAN + +#define FI_RGBA_RGB_MASK (FI_RGBA_RED_MASK|FI_RGBA_GREEN_MASK|FI_RGBA_BLUE_MASK) + +// The 16bit macros only include masks and shifts, since each color element is not byte aligned + +#define FI16_555_RED_MASK 0x7C00 +#define FI16_555_GREEN_MASK 0x03E0 +#define FI16_555_BLUE_MASK 0x001F +#define FI16_555_RED_SHIFT 10 +#define FI16_555_GREEN_SHIFT 5 +#define FI16_555_BLUE_SHIFT 0 +#define FI16_565_RED_MASK 0xF800 +#define FI16_565_GREEN_MASK 0x07E0 +#define FI16_565_BLUE_MASK 0x001F +#define FI16_565_RED_SHIFT 11 +#define FI16_565_GREEN_SHIFT 5 +#define FI16_565_BLUE_SHIFT 0 + +// ICC profile support ------------------------------------------------------ + +#define FIICC_DEFAULT 0x00 +#define FIICC_COLOR_IS_CMYK 0x01 + +FI_STRUCT (FIICCPROFILE) { + WORD flags; //! info flag + DWORD size; //! profile's size measured in bytes + void *data; //! points to a block of contiguous memory containing the profile +}; + +// Important enums ---------------------------------------------------------- + +/** I/O image format identifiers. +*/ +FI_ENUM(FREE_IMAGE_FORMAT) { + FIF_UNKNOWN = -1, + FIF_BMP = 0, + FIF_ICO = 1, + FIF_JPEG = 2, + FIF_JNG = 3, + FIF_KOALA = 4, + FIF_LBM = 5, + FIF_IFF = FIF_LBM, + FIF_MNG = 6, + FIF_PBM = 7, + FIF_PBMRAW = 8, + FIF_PCD = 9, + FIF_PCX = 10, + FIF_PGM = 11, + FIF_PGMRAW = 12, + FIF_PNG = 13, + FIF_PPM = 14, + FIF_PPMRAW = 15, + FIF_RAS = 16, + FIF_TARGA = 17, + FIF_TIFF = 18, + FIF_WBMP = 19, + FIF_PSD = 20, + FIF_CUT = 21, + FIF_XBM = 22, + FIF_XPM = 23, + FIF_DDS = 24, + FIF_GIF = 25, + FIF_HDR = 26, + FIF_FAXG3 = 27, + FIF_SGI = 28, + FIF_EXR = 29, + FIF_J2K = 30, + FIF_JP2 = 31, + FIF_PFM = 32, + FIF_PICT = 33, + FIF_RAW = 34, + FIF_WEBP = 35, + FIF_JXR = 36 +}; + +/** Image type used in FreeImage. +*/ +FI_ENUM(FREE_IMAGE_TYPE) { + FIT_UNKNOWN = 0, //! unknown type + FIT_BITMAP = 1, //! standard image : 1-, 4-, 8-, 16-, 24-, 32-bit + FIT_UINT16 = 2, //! array of unsigned short : unsigned 16-bit + FIT_INT16 = 3, //! array of short : signed 16-bit + FIT_UINT32 = 4, //! array of unsigned long : unsigned 32-bit + FIT_INT32 = 5, //! array of long : signed 32-bit + FIT_FLOAT = 6, //! array of float : 32-bit IEEE floating point + FIT_DOUBLE = 7, //! array of double : 64-bit IEEE floating point + FIT_COMPLEX = 8, //! array of FICOMPLEX : 2 x 64-bit IEEE floating point + FIT_RGB16 = 9, //! 48-bit RGB image : 3 x 16-bit + FIT_RGBA16 = 10, //! 64-bit RGBA image : 4 x 16-bit + FIT_RGBF = 11, //! 96-bit RGB float image : 3 x 32-bit IEEE floating point + FIT_RGBAF = 12 //! 128-bit RGBA float image : 4 x 32-bit IEEE floating point +}; + +/** Image color type used in FreeImage. +*/ +FI_ENUM(FREE_IMAGE_COLOR_TYPE) { + FIC_MINISWHITE = 0, //! min value is white + FIC_MINISBLACK = 1, //! min value is black + FIC_RGB = 2, //! RGB color model + FIC_PALETTE = 3, //! color map indexed + FIC_RGBALPHA = 4, //! RGB color model with alpha channel + FIC_CMYK = 5 //! CMYK color model +}; + +/** Color quantization algorithms. +Constants used in FreeImage_ColorQuantize. +*/ +FI_ENUM(FREE_IMAGE_QUANTIZE) { + FIQ_WUQUANT = 0, //! Xiaolin Wu color quantization algorithm + FIQ_NNQUANT = 1, //! NeuQuant neural-net quantization algorithm by Anthony Dekker + FIQ_LFPQUANT = 2 //! Lossless Fast Pseudo-Quantization Algorithm by Carsten Klein +}; + +/** Dithering algorithms. +Constants used in FreeImage_Dither. +*/ +FI_ENUM(FREE_IMAGE_DITHER) { + FID_FS = 0, //! Floyd & Steinberg error diffusion + FID_BAYER4x4 = 1, //! Bayer ordered dispersed dot dithering (order 2 dithering matrix) + FID_BAYER8x8 = 2, //! Bayer ordered dispersed dot dithering (order 3 dithering matrix) + FID_CLUSTER6x6 = 3, //! Ordered clustered dot dithering (order 3 - 6x6 matrix) + FID_CLUSTER8x8 = 4, //! Ordered clustered dot dithering (order 4 - 8x8 matrix) + FID_CLUSTER16x16= 5, //! Ordered clustered dot dithering (order 8 - 16x16 matrix) + FID_BAYER16x16 = 6 //! Bayer ordered dispersed dot dithering (order 4 dithering matrix) +}; + +/** Lossless JPEG transformations +Constants used in FreeImage_JPEGTransform +*/ +FI_ENUM(FREE_IMAGE_JPEG_OPERATION) { + FIJPEG_OP_NONE = 0, //! no transformation + FIJPEG_OP_FLIP_H = 1, //! horizontal flip + FIJPEG_OP_FLIP_V = 2, //! vertical flip + FIJPEG_OP_TRANSPOSE = 3, //! transpose across UL-to-LR axis + FIJPEG_OP_TRANSVERSE = 4, //! transpose across UR-to-LL axis + FIJPEG_OP_ROTATE_90 = 5, //! 90-degree clockwise rotation + FIJPEG_OP_ROTATE_180 = 6, //! 180-degree rotation + FIJPEG_OP_ROTATE_270 = 7 //! 270-degree clockwise (or 90 ccw) +}; + +/** Tone mapping operators. +Constants used in FreeImage_ToneMapping. +*/ +FI_ENUM(FREE_IMAGE_TMO) { + FITMO_DRAGO03 = 0, //! Adaptive logarithmic mapping (F. Drago, 2003) + FITMO_REINHARD05 = 1, //! Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005) + FITMO_FATTAL02 = 2 //! Gradient domain high dynamic range compression (R. Fattal, 2002) +}; + +/** Upsampling / downsampling filters. +Constants used in FreeImage_Rescale. +*/ +FI_ENUM(FREE_IMAGE_FILTER) { + FILTER_BOX = 0, //! Box, pulse, Fourier window, 1st order (constant) b-spline + FILTER_BICUBIC = 1, //! Mitchell & Netravali's two-param cubic filter + FILTER_BILINEAR = 2, //! Bilinear filter + FILTER_BSPLINE = 3, //! 4th order (cubic) b-spline + FILTER_CATMULLROM = 4, //! Catmull-Rom spline, Overhauser spline + FILTER_LANCZOS3 = 5 //! Lanczos3 filter +}; + +/** Color channels. +Constants used in color manipulation routines. +*/ +FI_ENUM(FREE_IMAGE_COLOR_CHANNEL) { + FICC_RGB = 0, //! Use red, green and blue channels + FICC_RED = 1, //! Use red channel + FICC_GREEN = 2, //! Use green channel + FICC_BLUE = 3, //! Use blue channel + FICC_ALPHA = 4, //! Use alpha channel + FICC_BLACK = 5, //! Use black channel + FICC_REAL = 6, //! Complex images: use real part + FICC_IMAG = 7, //! Complex images: use imaginary part + FICC_MAG = 8, //! Complex images: use magnitude + FICC_PHASE = 9 //! Complex images: use phase +}; + +// Metadata support --------------------------------------------------------- + +/** + Tag data type information (based on TIFF specifications) + + Note: RATIONALs are the ratio of two 32-bit integer values. +*/ +FI_ENUM(FREE_IMAGE_MDTYPE) { + FIDT_NOTYPE = 0, //! placeholder + FIDT_BYTE = 1, //! 8-bit unsigned integer + FIDT_ASCII = 2, //! 8-bit bytes w/ last byte null + FIDT_SHORT = 3, //! 16-bit unsigned integer + FIDT_LONG = 4, //! 32-bit unsigned integer + FIDT_RATIONAL = 5, //! 64-bit unsigned fraction + FIDT_SBYTE = 6, //! 8-bit signed integer + FIDT_UNDEFINED = 7, //! 8-bit untyped data + FIDT_SSHORT = 8, //! 16-bit signed integer + FIDT_SLONG = 9, //! 32-bit signed integer + FIDT_SRATIONAL = 10, //! 64-bit signed fraction + FIDT_FLOAT = 11, //! 32-bit IEEE floating point + FIDT_DOUBLE = 12, //! 64-bit IEEE floating point + FIDT_IFD = 13, //! 32-bit unsigned integer (offset) + FIDT_PALETTE = 14, //! 32-bit RGBQUAD + FIDT_LONG8 = 16, //! 64-bit unsigned integer + FIDT_SLONG8 = 17, //! 64-bit signed integer + FIDT_IFD8 = 18 //! 64-bit unsigned integer (offset) +}; + +/** + Metadata models supported by FreeImage +*/ +FI_ENUM(FREE_IMAGE_MDMODEL) { + FIMD_NODATA = -1, + FIMD_COMMENTS = 0, //! single comment or keywords + FIMD_EXIF_MAIN = 1, //! Exif-TIFF metadata + FIMD_EXIF_EXIF = 2, //! Exif-specific metadata + FIMD_EXIF_GPS = 3, //! Exif GPS metadata + FIMD_EXIF_MAKERNOTE = 4, //! Exif maker note metadata + FIMD_EXIF_INTEROP = 5, //! Exif interoperability metadata + FIMD_IPTC = 6, //! IPTC/NAA metadata + FIMD_XMP = 7, //! Abobe XMP metadata + FIMD_GEOTIFF = 8, //! GeoTIFF metadata + FIMD_ANIMATION = 9, //! Animation metadata + FIMD_CUSTOM = 10, //! Used to attach other metadata types to a dib + FIMD_EXIF_RAW = 11 //! Exif metadata as a raw buffer +}; + +/** + Handle to a metadata model +*/ +FI_STRUCT (FIMETADATA) { void *data; }; + +/** + Handle to a FreeImage tag +*/ +FI_STRUCT (FITAG) { void *data; }; + +// File IO routines --------------------------------------------------------- + +#ifndef FREEIMAGE_IO +#define FREEIMAGE_IO + +typedef void* fi_handle; +typedef unsigned (DLL_CALLCONV *FI_ReadProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); +typedef unsigned (DLL_CALLCONV *FI_WriteProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); +typedef int (DLL_CALLCONV *FI_SeekProc) (fi_handle handle, long offset, int origin); +typedef long (DLL_CALLCONV *FI_TellProc) (fi_handle handle); + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(push, 1) +#else +#pragma pack(1) +#endif // WIN32 + +FI_STRUCT(FreeImageIO) { + FI_ReadProc read_proc; //! pointer to the function used to read data + FI_WriteProc write_proc; //! pointer to the function used to write data + FI_SeekProc seek_proc; //! pointer to the function used to seek + FI_TellProc tell_proc; //! pointer to the function used to aquire the current position +}; + +#if (defined(_WIN32) || defined(__WIN32__)) +#pragma pack(pop) +#else +#pragma pack() +#endif // WIN32 + +/** +Handle to a memory I/O stream +*/ +FI_STRUCT (FIMEMORY) { void *data; }; + +#endif // FREEIMAGE_IO + +// Plugin routines ---------------------------------------------------------- + +#ifndef PLUGINS +#define PLUGINS + +typedef const char *(DLL_CALLCONV *FI_FormatProc)(void); +typedef const char *(DLL_CALLCONV *FI_DescriptionProc)(void); +typedef const char *(DLL_CALLCONV *FI_ExtensionListProc)(void); +typedef const char *(DLL_CALLCONV *FI_RegExprProc)(void); +typedef void *(DLL_CALLCONV *FI_OpenProc)(FreeImageIO *io, fi_handle handle, BOOL read); +typedef void (DLL_CALLCONV *FI_CloseProc)(FreeImageIO *io, fi_handle handle, void *data); +typedef int (DLL_CALLCONV *FI_PageCountProc)(FreeImageIO *io, fi_handle handle, void *data); +typedef int (DLL_CALLCONV *FI_PageCapabilityProc)(FreeImageIO *io, fi_handle handle, void *data); +typedef FIBITMAP *(DLL_CALLCONV *FI_LoadProc)(FreeImageIO *io, fi_handle handle, int page, int flags, void *data); +typedef BOOL (DLL_CALLCONV *FI_SaveProc)(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data); +typedef BOOL (DLL_CALLCONV *FI_ValidateProc)(FreeImageIO *io, fi_handle handle); +typedef const char *(DLL_CALLCONV *FI_MimeProc)(void); +typedef BOOL (DLL_CALLCONV *FI_SupportsExportBPPProc)(int bpp); +typedef BOOL (DLL_CALLCONV *FI_SupportsExportTypeProc)(FREE_IMAGE_TYPE type); +typedef BOOL (DLL_CALLCONV *FI_SupportsICCProfilesProc)(void); +typedef BOOL (DLL_CALLCONV *FI_SupportsNoPixelsProc)(void); + +FI_STRUCT (Plugin) { + FI_FormatProc format_proc; + FI_DescriptionProc description_proc; + FI_ExtensionListProc extension_proc; + FI_RegExprProc regexpr_proc; + FI_OpenProc open_proc; + FI_CloseProc close_proc; + FI_PageCountProc pagecount_proc; + FI_PageCapabilityProc pagecapability_proc; + FI_LoadProc load_proc; + FI_SaveProc save_proc; + FI_ValidateProc validate_proc; + FI_MimeProc mime_proc; + FI_SupportsExportBPPProc supports_export_bpp_proc; + FI_SupportsExportTypeProc supports_export_type_proc; + FI_SupportsICCProfilesProc supports_icc_profiles_proc; + FI_SupportsNoPixelsProc supports_no_pixels_proc; +}; + +typedef void (DLL_CALLCONV *FI_InitProc)(Plugin *plugin, int format_id); + +#endif // PLUGINS + + +// Load / Save flag constants ----------------------------------------------- + +#define FIF_LOAD_NOPIXELS 0x8000 //! loading: load the image header only (not supported by all plugins, default to full loading) + +#define BMP_DEFAULT 0 +#define BMP_SAVE_RLE 1 +#define CUT_DEFAULT 0 +#define DDS_DEFAULT 0 +#define EXR_DEFAULT 0 //! save data as half with piz-based wavelet compression +#define EXR_FLOAT 0x0001 //! save data as float instead of as half (not recommended) +#define EXR_NONE 0x0002 //! save with no compression +#define EXR_ZIP 0x0004 //! save with zlib compression, in blocks of 16 scan lines +#define EXR_PIZ 0x0008 //! save with piz-based wavelet compression +#define EXR_PXR24 0x0010 //! save with lossy 24-bit float compression +#define EXR_B44 0x0020 //! save with lossy 44% float compression - goes to 22% when combined with EXR_LC +#define EXR_LC 0x0040 //! save images with one luminance and two chroma channels, rather than as RGB (lossy compression) +#define FAXG3_DEFAULT 0 +#define GIF_DEFAULT 0 +#define GIF_LOAD256 1 //! load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color +#define GIF_PLAYBACK 2 //! 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading +#define HDR_DEFAULT 0 +#define ICO_DEFAULT 0 +#define ICO_MAKEALPHA 1 //! convert to 32bpp and create an alpha channel from the AND-mask when loading +#define IFF_DEFAULT 0 +#define J2K_DEFAULT 0 //! save with a 16:1 rate +#define JP2_DEFAULT 0 //! save with a 16:1 rate +#define JPEG_DEFAULT 0 //! loading (see JPEG_FAST); saving (see JPEG_QUALITYGOOD|JPEG_SUBSAMPLING_420) +#define JPEG_FAST 0x0001 //! load the file as fast as possible, sacrificing some quality +#define JPEG_ACCURATE 0x0002 //! load the file with the best quality, sacrificing some speed +#define JPEG_CMYK 0x0004 //! load separated CMYK "as is" (use | to combine with other load flags) +#define JPEG_EXIFROTATE 0x0008 //! load and rotate according to Exif 'Orientation' tag if available +#define JPEG_GREYSCALE 0x0010 //! load and convert to a 8-bit greyscale image +#define JPEG_QUALITYSUPERB 0x80 //! save with superb quality (100:1) +#define JPEG_QUALITYGOOD 0x0100 //! save with good quality (75:1) +#define JPEG_QUALITYNORMAL 0x0200 //! save with normal quality (50:1) +#define JPEG_QUALITYAVERAGE 0x0400 //! save with average quality (25:1) +#define JPEG_QUALITYBAD 0x0800 //! save with bad quality (10:1) +#define JPEG_PROGRESSIVE 0x2000 //! save as a progressive-JPEG (use | to combine with other save flags) +#define JPEG_SUBSAMPLING_411 0x1000 //! save with high 4x1 chroma subsampling (4:1:1) +#define JPEG_SUBSAMPLING_420 0x4000 //! save with medium 2x2 medium chroma subsampling (4:2:0) - default value +#define JPEG_SUBSAMPLING_422 0x8000 //! save with low 2x1 chroma subsampling (4:2:2) +#define JPEG_SUBSAMPLING_444 0x10000 //! save with no chroma subsampling (4:4:4) +#define JPEG_OPTIMIZE 0x20000 //! on saving, compute optimal Huffman coding tables (can reduce a few percent of file size) +#define JPEG_BASELINE 0x40000 //! save basic JPEG, without metadata or any markers +#define KOALA_DEFAULT 0 +#define LBM_DEFAULT 0 +#define MNG_DEFAULT 0 +#define PCD_DEFAULT 0 +#define PCD_BASE 1 //! load the bitmap sized 768 x 512 +#define PCD_BASEDIV4 2 //! load the bitmap sized 384 x 256 +#define PCD_BASEDIV16 3 //! load the bitmap sized 192 x 128 +#define PCX_DEFAULT 0 +#define PFM_DEFAULT 0 +#define PICT_DEFAULT 0 +#define PNG_DEFAULT 0 +#define PNG_IGNOREGAMMA 1 //! loading: avoid gamma correction +#define PNG_Z_BEST_SPEED 0x0001 //! save using ZLib level 1 compression flag (default value is 6) +#define PNG_Z_DEFAULT_COMPRESSION 0x0006 //! save using ZLib level 6 compression flag (default recommended value) +#define PNG_Z_BEST_COMPRESSION 0x0009 //! save using ZLib level 9 compression flag (default value is 6) +#define PNG_Z_NO_COMPRESSION 0x0100 //! save without ZLib compression +#define PNG_INTERLACED 0x0200 //! save using Adam7 interlacing (use | to combine with other save flags) +#define PNM_DEFAULT 0 +#define PNM_SAVE_RAW 0 //! if set the writer saves in RAW format (i.e. P4, P5 or P6) +#define PNM_SAVE_ASCII 1 //! if set the writer saves in ASCII format (i.e. P1, P2 or P3) +#define PSD_DEFAULT 0 +#define PSD_CMYK 1 //! reads tags for separated CMYK (default is conversion to RGB) +#define PSD_LAB 2 //! reads tags for CIELab (default is conversion to RGB) +#define RAS_DEFAULT 0 +#define RAW_DEFAULT 0 //! load the file as linear RGB 48-bit +#define RAW_PREVIEW 1 //! try to load the embedded JPEG preview with included Exif Data or default to RGB 24-bit +#define RAW_DISPLAY 2 //! load the file as RGB 24-bit +#define RAW_HALFSIZE 4 //! output a half-size color image +#define RAW_UNPROCESSED 8 //! output a FIT_UINT16 raw Bayer image +#define SGI_DEFAULT 0 +#define TARGA_DEFAULT 0 +#define TARGA_LOAD_RGB888 1 //! if set the loader converts RGB555 and ARGB8888 -> RGB888. +#define TARGA_SAVE_RLE 2 //! if set, the writer saves with RLE compression +#define TIFF_DEFAULT 0 +#define TIFF_CMYK 0x0001 //! reads/stores tags for separated CMYK (use | to combine with compression flags) +#define TIFF_PACKBITS 0x0100 //! save using PACKBITS compression +#define TIFF_DEFLATE 0x0200 //! save using DEFLATE compression (a.k.a. ZLIB compression) +#define TIFF_ADOBE_DEFLATE 0x0400 //! save using ADOBE DEFLATE compression +#define TIFF_NONE 0x0800 //! save without any compression +#define TIFF_CCITTFAX3 0x1000 //! save using CCITT Group 3 fax encoding +#define TIFF_CCITTFAX4 0x2000 //! save using CCITT Group 4 fax encoding +#define TIFF_LZW 0x4000 //! save using LZW compression +#define TIFF_JPEG 0x8000 //! save using JPEG compression +#define TIFF_LOGLUV 0x10000 //! save using LogLuv compression +#define WBMP_DEFAULT 0 +#define XBM_DEFAULT 0 +#define XPM_DEFAULT 0 +#define WEBP_DEFAULT 0 //! save with good quality (75:1) +#define WEBP_LOSSLESS 0x100 //! save in lossless mode +#define JXR_DEFAULT 0 //! save with quality 80 and no chroma subsampling (4:4:4) +#define JXR_LOSSLESS 0x0064 //! save lossless +#define JXR_PROGRESSIVE 0x2000 //! save as a progressive-JXR (use | to combine with other save flags) + +// Background filling options --------------------------------------------------------- +// Constants used in FreeImage_FillBackground and FreeImage_EnlargeCanvas + +#define FI_COLOR_IS_RGB_COLOR 0x00 //! RGBQUAD color is a RGB color (contains no valid alpha channel) +#define FI_COLOR_IS_RGBA_COLOR 0x01 //! RGBQUAD color is a RGBA color (contains a valid alpha channel) +#define FI_COLOR_FIND_EQUAL_COLOR 0x02 //! For palettized images: lookup equal RGB color from palette +#define FI_COLOR_ALPHA_IS_INDEX 0x04 //! The color's rgbReserved member (alpha) contains the palette index to be used +#define FI_COLOR_PALETTE_SEARCH_MASK (FI_COLOR_FIND_EQUAL_COLOR | FI_COLOR_ALPHA_IS_INDEX) // No color lookup is performed + +// RescaleEx options --------------------------------------------------------- +// Constants used in FreeImage_RescaleEx + +#define FI_RESCALE_DEFAULT 0x00 //! default options; none of the following other options apply +#define FI_RESCALE_TRUE_COLOR 0x01 //! for non-transparent greyscale images, convert to 24-bit if src bitdepth <= 8 (default is a 8-bit greyscale image). +#define FI_RESCALE_OMIT_METADATA 0x02 //! do not copy metadata to the rescaled image + + +#ifdef __cplusplus +extern "C" { +#endif + +// Init / Error routines ---------------------------------------------------- + +DLL_API void DLL_CALLCONV FreeImage_Initialise(BOOL load_local_plugins_only FI_DEFAULT(FALSE)); +DLL_API void DLL_CALLCONV FreeImage_DeInitialise(void); + +// Version routines --------------------------------------------------------- + +DLL_API const char *DLL_CALLCONV FreeImage_GetVersion(void); +DLL_API const char *DLL_CALLCONV FreeImage_GetCopyrightMessage(void); + +// Message output functions ------------------------------------------------- + +typedef void (*FreeImage_OutputMessageFunction)(FREE_IMAGE_FORMAT fif, const char *msg); +typedef void (DLL_CALLCONV *FreeImage_OutputMessageFunctionStdCall)(FREE_IMAGE_FORMAT fif, const char *msg); + +DLL_API void DLL_CALLCONV FreeImage_SetOutputMessageStdCall(FreeImage_OutputMessageFunctionStdCall omf); +DLL_API void DLL_CALLCONV FreeImage_SetOutputMessage(FreeImage_OutputMessageFunction omf); +DLL_API void DLL_CALLCONV FreeImage_OutputMessageProc(int fif, const char *fmt, ...); + +// Allocate / Clone / Unload routines --------------------------------------- + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Allocate(int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp FI_DEFAULT(8), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); +DLL_API FIBITMAP * DLL_CALLCONV FreeImage_Clone(FIBITMAP *dib); +DLL_API void DLL_CALLCONV FreeImage_Unload(FIBITMAP *dib); + +// Header loading routines +DLL_API BOOL DLL_CALLCONV FreeImage_HasPixels(FIBITMAP *dib); + +// Load / Save routines ----------------------------------------------------- + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif, const char *filename, int flags FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadU(FREE_IMAGE_FORMAT fif, const wchar_t *filename, int flags FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const wchar_t *filename, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); + +// Memory I/O stream routines ----------------------------------------------- + +DLL_API FIMEMORY *DLL_CALLCONV FreeImage_OpenMemory(BYTE *data FI_DEFAULT(0), DWORD size_in_bytes FI_DEFAULT(0)); +DLL_API void DLL_CALLCONV FreeImage_CloseMemory(FIMEMORY *stream); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags FI_DEFAULT(0)); +DLL_API long DLL_CALLCONV FreeImage_TellMemory(FIMEMORY *stream); +DLL_API BOOL DLL_CALLCONV FreeImage_SeekMemory(FIMEMORY *stream, long offset, int origin); +DLL_API BOOL DLL_CALLCONV FreeImage_AcquireMemory(FIMEMORY *stream, BYTE **data, DWORD *size_in_bytes); +DLL_API unsigned DLL_CALLCONV FreeImage_ReadMemory(void *buffer, unsigned size, unsigned count, FIMEMORY *stream); +DLL_API unsigned DLL_CALLCONV FreeImage_WriteMemory(const void *buffer, unsigned size, unsigned count, FIMEMORY *stream); + +DLL_API FIMULTIBITMAP *DLL_CALLCONV FreeImage_LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_SaveMultiBitmapToMemory(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, FIMEMORY *stream, int flags); + +// Plugin Interface --------------------------------------------------------- + +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterLocalPlugin(FI_InitProc proc_address, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0)); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterExternalPlugin(const char *path, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0)); +DLL_API int DLL_CALLCONV FreeImage_GetFIFCount(void); +DLL_API int DLL_CALLCONV FreeImage_SetPluginEnabled(FREE_IMAGE_FORMAT fif, BOOL enable); +DLL_API int DLL_CALLCONV FreeImage_IsPluginEnabled(FREE_IMAGE_FORMAT fif); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFormat(const char *format); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromMime(const char *mime); +DLL_API const char *DLL_CALLCONV FreeImage_GetFormatFromFIF(FREE_IMAGE_FORMAT fif); +DLL_API const char *DLL_CALLCONV FreeImage_GetFIFExtensionList(FREE_IMAGE_FORMAT fif); +DLL_API const char *DLL_CALLCONV FreeImage_GetFIFDescription(FREE_IMAGE_FORMAT fif); +DLL_API const char *DLL_CALLCONV FreeImage_GetFIFRegExpr(FREE_IMAGE_FORMAT fif); +DLL_API const char *DLL_CALLCONV FreeImage_GetFIFMimeType(FREE_IMAGE_FORMAT fif); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilename(const char *filename); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilenameU(const wchar_t *filename); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsReading(FREE_IMAGE_FORMAT fif); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsWriting(FREE_IMAGE_FORMAT fif); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportBPP(FREE_IMAGE_FORMAT fif, int bpp); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportType(FREE_IMAGE_FORMAT fif, FREE_IMAGE_TYPE type); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsICCProfiles(FREE_IMAGE_FORMAT fif); +DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsNoPixels(FREE_IMAGE_FORMAT fif); + +// Multipaging interface ---------------------------------------------------- + +DLL_API FIMULTIBITMAP * DLL_CALLCONV FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL create_new, BOOL read_only, BOOL keep_cache_in_memory FI_DEFAULT(FALSE), int flags FI_DEFAULT(0)); +DLL_API FIMULTIBITMAP * DLL_CALLCONV FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_SaveMultiBitmapToHandle(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); +DLL_API BOOL DLL_CALLCONV FreeImage_CloseMultiBitmap(FIMULTIBITMAP *bitmap, int flags FI_DEFAULT(0)); +DLL_API int DLL_CALLCONV FreeImage_GetPageCount(FIMULTIBITMAP *bitmap); +DLL_API void DLL_CALLCONV FreeImage_AppendPage(FIMULTIBITMAP *bitmap, FIBITMAP *data); +DLL_API void DLL_CALLCONV FreeImage_InsertPage(FIMULTIBITMAP *bitmap, int page, FIBITMAP *data); +DLL_API void DLL_CALLCONV FreeImage_DeletePage(FIMULTIBITMAP *bitmap, int page); +DLL_API FIBITMAP * DLL_CALLCONV FreeImage_LockPage(FIMULTIBITMAP *bitmap, int page); +DLL_API void DLL_CALLCONV FreeImage_UnlockPage(FIMULTIBITMAP *bitmap, FIBITMAP *data, BOOL changed); +DLL_API BOOL DLL_CALLCONV FreeImage_MovePage(FIMULTIBITMAP *bitmap, int target, int source); +DLL_API BOOL DLL_CALLCONV FreeImage_GetLockedPageNumbers(FIMULTIBITMAP *bitmap, int *pages, int *count); + +// Filetype request routines ------------------------------------------------ + +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileType(const char *filename, int size FI_DEFAULT(0)); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeU(const wchar_t *filename, int size FI_DEFAULT(0)); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size FI_DEFAULT(0)); +DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromMemory(FIMEMORY *stream, int size FI_DEFAULT(0)); + +// Image type request routine ----------------------------------------------- + +DLL_API FREE_IMAGE_TYPE DLL_CALLCONV FreeImage_GetImageType(FIBITMAP *dib); + +// FreeImage helper routines ------------------------------------------------ + +DLL_API BOOL DLL_CALLCONV FreeImage_IsLittleEndian(void); +DLL_API BOOL DLL_CALLCONV FreeImage_LookupX11Color(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nBlue); +DLL_API BOOL DLL_CALLCONV FreeImage_LookupSVGColor(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nBlue); + +// Pixel access routines ---------------------------------------------------- + +DLL_API BYTE *DLL_CALLCONV FreeImage_GetBits(FIBITMAP *dib); +DLL_API BYTE *DLL_CALLCONV FreeImage_GetScanLine(FIBITMAP *dib, int scanline); + +DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value); +DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value); +DLL_API BOOL DLL_CALLCONV FreeImage_SetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value); +DLL_API BOOL DLL_CALLCONV FreeImage_SetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value); + +// DIB info routines -------------------------------------------------------- + +DLL_API unsigned DLL_CALLCONV FreeImage_GetColorsUsed(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetBPP(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetWidth(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetHeight(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetLine(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetPitch(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetDIBSize(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetMemorySize(FIBITMAP *dib); +DLL_API RGBQUAD *DLL_CALLCONV FreeImage_GetPalette(FIBITMAP *dib); + +DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterX(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterY(FIBITMAP *dib); +DLL_API void DLL_CALLCONV FreeImage_SetDotsPerMeterX(FIBITMAP *dib, unsigned res); +DLL_API void DLL_CALLCONV FreeImage_SetDotsPerMeterY(FIBITMAP *dib, unsigned res); + +DLL_API BITMAPINFOHEADER *DLL_CALLCONV FreeImage_GetInfoHeader(FIBITMAP *dib); +DLL_API BITMAPINFO *DLL_CALLCONV FreeImage_GetInfo(FIBITMAP *dib); +DLL_API FREE_IMAGE_COLOR_TYPE DLL_CALLCONV FreeImage_GetColorType(FIBITMAP *dib); + +DLL_API unsigned DLL_CALLCONV FreeImage_GetRedMask(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetGreenMask(FIBITMAP *dib); +DLL_API unsigned DLL_CALLCONV FreeImage_GetBlueMask(FIBITMAP *dib); + +DLL_API unsigned DLL_CALLCONV FreeImage_GetTransparencyCount(FIBITMAP *dib); +DLL_API BYTE * DLL_CALLCONV FreeImage_GetTransparencyTable(FIBITMAP *dib); +DLL_API void DLL_CALLCONV FreeImage_SetTransparent(FIBITMAP *dib, BOOL enabled); +DLL_API void DLL_CALLCONV FreeImage_SetTransparencyTable(FIBITMAP *dib, BYTE *table, int count); +DLL_API BOOL DLL_CALLCONV FreeImage_IsTransparent(FIBITMAP *dib); +DLL_API void DLL_CALLCONV FreeImage_SetTransparentIndex(FIBITMAP *dib, int index); +DLL_API int DLL_CALLCONV FreeImage_GetTransparentIndex(FIBITMAP *dib); + +DLL_API BOOL DLL_CALLCONV FreeImage_HasBackgroundColor(FIBITMAP *dib); +DLL_API BOOL DLL_CALLCONV FreeImage_GetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor); +DLL_API BOOL DLL_CALLCONV FreeImage_SetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetThumbnail(FIBITMAP *dib); +DLL_API BOOL DLL_CALLCONV FreeImage_SetThumbnail(FIBITMAP *dib, FIBITMAP *thumbnail); + +// ICC profile routines ----------------------------------------------------- + +DLL_API FIICCPROFILE *DLL_CALLCONV FreeImage_GetICCProfile(FIBITMAP *dib); +DLL_API FIICCPROFILE *DLL_CALLCONV FreeImage_CreateICCProfile(FIBITMAP *dib, void *data, long size); +DLL_API void DLL_CALLCONV FreeImage_DestroyICCProfile(FIBITMAP *dib); + +// Line conversion routines ------------------------------------------------- + +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To4(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To4(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To4_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To4_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To4(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To4(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To8(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To8(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To8(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To8(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_565_To16_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_555_To16_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To24(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_555(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_565(BYTE *target, BYTE *source, int width_in_pixels); +DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To32(BYTE *target, BYTE *source, int width_in_pixels); + +// Smart conversion routines ------------------------------------------------ + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo4Bits(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo8Bits(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToGreyscale(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits555(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits565(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo24Bits(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo32Bits(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantize(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantizeEx(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize FI_DEFAULT(FIQ_WUQUANT), int PaletteSize FI_DEFAULT(256), int ReserveSize FI_DEFAULT(0), RGBQUAD *ReservePalette FI_DEFAULT(NULL)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Threshold(FIBITMAP *dib, BYTE T); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Dither(FIBITMAP *dib, FREE_IMAGE_DITHER algorithm); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertFromRawBits(BYTE *bits, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertFromRawBitsEx(BOOL copySource, BYTE *bits, FREE_IMAGE_TYPE type, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); +DLL_API void DLL_CALLCONV FreeImage_ConvertToRawBits(BYTE *bits, FIBITMAP *dib, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToFloat(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGBF(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGBAF(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToUINT16(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGB16(FIBITMAP *dib); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGBA16(FIBITMAP *dib); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToStandardType(FIBITMAP *src, BOOL scale_linear FI_DEFAULT(TRUE)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToType(FIBITMAP *src, FREE_IMAGE_TYPE dst_type, BOOL scale_linear FI_DEFAULT(TRUE)); + +// Tone mapping operators --------------------------------------------------- + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ToneMapping(FIBITMAP *dib, FREE_IMAGE_TMO tmo, double first_param FI_DEFAULT(0), double second_param FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoDrago03(FIBITMAP *src, double gamma FI_DEFAULT(2.2), double exposure FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoReinhard05(FIBITMAP *src, double intensity FI_DEFAULT(0), double contrast FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoReinhard05Ex(FIBITMAP *src, double intensity FI_DEFAULT(0), double contrast FI_DEFAULT(0), double adaptation FI_DEFAULT(1), double color_correction FI_DEFAULT(0)); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoFattal02(FIBITMAP *src, double color_saturation FI_DEFAULT(0.5), double attenuation FI_DEFAULT(0.85)); + +// ZLib interface ----------------------------------------------------------- + +DLL_API DWORD DLL_CALLCONV FreeImage_ZLibCompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); +DLL_API DWORD DLL_CALLCONV FreeImage_ZLibUncompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); +DLL_API DWORD DLL_CALLCONV FreeImage_ZLibGZip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); +DLL_API DWORD DLL_CALLCONV FreeImage_ZLibGUnzip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); +DLL_API DWORD DLL_CALLCONV FreeImage_ZLibCRC32(DWORD crc, BYTE *source, DWORD source_size); + +// -------------------------------------------------------------------------- +// Metadata routines +// -------------------------------------------------------------------------- + +// tag creation / destruction +DLL_API FITAG *DLL_CALLCONV FreeImage_CreateTag(void); +DLL_API void DLL_CALLCONV FreeImage_DeleteTag(FITAG *tag); +DLL_API FITAG *DLL_CALLCONV FreeImage_CloneTag(FITAG *tag); + +// tag getters and setters +DLL_API const char *DLL_CALLCONV FreeImage_GetTagKey(FITAG *tag); +DLL_API const char *DLL_CALLCONV FreeImage_GetTagDescription(FITAG *tag); +DLL_API WORD DLL_CALLCONV FreeImage_GetTagID(FITAG *tag); +DLL_API FREE_IMAGE_MDTYPE DLL_CALLCONV FreeImage_GetTagType(FITAG *tag); +DLL_API DWORD DLL_CALLCONV FreeImage_GetTagCount(FITAG *tag); +DLL_API DWORD DLL_CALLCONV FreeImage_GetTagLength(FITAG *tag); +DLL_API const void *DLL_CALLCONV FreeImage_GetTagValue(FITAG *tag); + +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagKey(FITAG *tag, const char *key); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagDescription(FITAG *tag, const char *description); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagID(FITAG *tag, WORD id); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagType(FITAG *tag, FREE_IMAGE_MDTYPE type); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagCount(FITAG *tag, DWORD count); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagLength(FITAG *tag, DWORD length); +DLL_API BOOL DLL_CALLCONV FreeImage_SetTagValue(FITAG *tag, const void *value); + +// iterator +DLL_API FIMETADATA *DLL_CALLCONV FreeImage_FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, FITAG **tag); +DLL_API BOOL DLL_CALLCONV FreeImage_FindNextMetadata(FIMETADATA *mdhandle, FITAG **tag); +DLL_API void DLL_CALLCONV FreeImage_FindCloseMetadata(FIMETADATA *mdhandle); + +// metadata setter and getter +DLL_API BOOL DLL_CALLCONV FreeImage_SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG *tag); +DLL_API BOOL DLL_CALLCONV FreeImage_GetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG **tag); +DLL_API BOOL DLL_CALLCONV FreeImage_SetMetadataKeyValue(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, const char *value); + +// helpers +DLL_API unsigned DLL_CALLCONV FreeImage_GetMetadataCount(FREE_IMAGE_MDMODEL model, FIBITMAP *dib); +DLL_API BOOL DLL_CALLCONV FreeImage_CloneMetadata(FIBITMAP *dst, FIBITMAP *src); + +// tag to C string conversion +DLL_API const char* DLL_CALLCONV FreeImage_TagToString(FREE_IMAGE_MDMODEL model, FITAG *tag, char *Make FI_DEFAULT(NULL)); + +// -------------------------------------------------------------------------- +// JPEG lossless transformation routines +// -------------------------------------------------------------------------- + +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransform(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE)); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE)); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCropU(const wchar_t *src_file, const wchar_t *dst_file, int left, int top, int right, int bottom); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformFromHandle(FreeImageIO* src_io, fi_handle src_handle, FreeImageIO* dst_io, fi_handle dst_handle, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombined(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); +DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedFromMemory(FIMEMORY* src_stream, FIMEMORY* dst_stream, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); + + +// -------------------------------------------------------------------------- +// Image manipulation toolkit +// -------------------------------------------------------------------------- + +// rotation and flipping +/// @deprecated see FreeImage_Rotate +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateClassic(FIBITMAP *dib, double angle); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rotate(FIBITMAP *dib, double angle, const void *bkcolor FI_DEFAULT(NULL)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateEx(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask); +DLL_API BOOL DLL_CALLCONV FreeImage_FlipHorizontal(FIBITMAP *dib); +DLL_API BOOL DLL_CALLCONV FreeImage_FlipVertical(FIBITMAP *dib); + +// upsampling / downsampling +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rescale(FIBITMAP *dib, int dst_width, int dst_height, FREE_IMAGE_FILTER filter FI_DEFAULT(FILTER_CATMULLROM)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MakeThumbnail(FIBITMAP *dib, int max_pixel_size, BOOL convert FI_DEFAULT(TRUE)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RescaleRect(FIBITMAP *dib, int dst_width, int dst_height, int left, int top, int right, int bottom, FREE_IMAGE_FILTER filter FI_DEFAULT(FILTER_CATMULLROM), unsigned flags FI_DEFAULT(0)); + +// color manipulation routines (point operations) +DLL_API BOOL DLL_CALLCONV FreeImage_AdjustCurve(FIBITMAP *dib, BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel); +DLL_API BOOL DLL_CALLCONV FreeImage_AdjustGamma(FIBITMAP *dib, double gamma); +DLL_API BOOL DLL_CALLCONV FreeImage_AdjustBrightness(FIBITMAP *dib, double percentage); +DLL_API BOOL DLL_CALLCONV FreeImage_AdjustContrast(FIBITMAP *dib, double percentage); +DLL_API BOOL DLL_CALLCONV FreeImage_Invert(FIBITMAP *dib); +DLL_API BOOL DLL_CALLCONV FreeImage_GetHistogram(FIBITMAP *dib, DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel FI_DEFAULT(FICC_BLACK)); +DLL_API int DLL_CALLCONV FreeImage_GetAdjustColorsLookupTable(BYTE *LUT, double brightness, double contrast, double gamma, BOOL invert); +DLL_API BOOL DLL_CALLCONV FreeImage_AdjustColors(FIBITMAP *dib, double brightness, double contrast, double gamma, BOOL invert FI_DEFAULT(FALSE)); +DLL_API unsigned DLL_CALLCONV FreeImage_ApplyColorMapping(FIBITMAP *dib, RGBQUAD *srccolors, RGBQUAD *dstcolors, unsigned count, BOOL ignore_alpha, BOOL swap); +DLL_API unsigned DLL_CALLCONV FreeImage_SwapColors(FIBITMAP *dib, RGBQUAD *color_a, RGBQUAD *color_b, BOOL ignore_alpha); +DLL_API unsigned DLL_CALLCONV FreeImage_ApplyPaletteIndexMapping(FIBITMAP *dib, BYTE *srcindices, BYTE *dstindices, unsigned count, BOOL swap); +DLL_API unsigned DLL_CALLCONV FreeImage_SwapPaletteIndices(FIBITMAP *dib, BYTE *index_a, BYTE *index_b); + +// channel processing routines +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetChannel(FIBITMAP *dib, FREE_IMAGE_COLOR_CHANNEL channel); +DLL_API BOOL DLL_CALLCONV FreeImage_SetChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetComplexChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel); +DLL_API BOOL DLL_CALLCONV FreeImage_SetComplexChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel); + +// copy / paste / composite routines +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Copy(FIBITMAP *dib, int left, int top, int right, int bottom); +DLL_API BOOL DLL_CALLCONV FreeImage_Paste(FIBITMAP *dst, FIBITMAP *src, int left, int top, int alpha); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_CreateView(FIBITMAP *dib, unsigned left, unsigned top, unsigned right, unsigned bottom); + +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Composite(FIBITMAP *fg, BOOL useFileBkg FI_DEFAULT(FALSE), RGBQUAD *appBkColor FI_DEFAULT(NULL), FIBITMAP *bg FI_DEFAULT(NULL)); +DLL_API BOOL DLL_CALLCONV FreeImage_PreMultiplyWithAlpha(FIBITMAP *dib); + +// background filling routines +DLL_API BOOL DLL_CALLCONV FreeImage_FillBackground(FIBITMAP *dib, const void *color, int options FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_EnlargeCanvas(FIBITMAP *src, int left, int top, int right, int bottom, const void *color, int options FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateEx(int width, int height, int bpp, const RGBQUAD *color, int options FI_DEFAULT(0), const RGBQUAD *palette FI_DEFAULT(NULL), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateExT(FREE_IMAGE_TYPE type, int width, int height, int bpp, const void *color, int options FI_DEFAULT(0), const RGBQUAD *palette FI_DEFAULT(NULL), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); + +// miscellaneous algorithms +DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle FI_DEFAULT(3)); + +// restore the borland-specific enum size option +#if defined(__BORLANDC__) +#pragma option pop +#endif + +#ifdef __cplusplus +} +#endif + +#endif // FREEIMAGE_H diff --git a/#ThirdParty/FreeImage/Dist/x64/FreeImage.lib b/#ThirdParty/FreeImage/Dist/x64/FreeImage.lib new file mode 100644 index 0000000..59e3d84 Binary files /dev/null and b/#ThirdParty/FreeImage/Dist/x64/FreeImage.lib differ diff --git a/#ThirdParty/FreeImage/Examples/Generic/BatchLoad.cpp b/#ThirdParty/FreeImage/Examples/Generic/BatchLoad.cpp new file mode 100644 index 0000000..d1c80b4 --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/Generic/BatchLoad.cpp @@ -0,0 +1,214 @@ +// ========================================================== +// Batch loader +// +// Design and implementation by +// - Floris van den Berg +// - Hervé Drolon +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at own risk! +// ========================================================== + +// +// This example shows how to easily batch load a directory +// full of images. Because not all formats can be identified +// by their header (some images don't have a header or one +// at the end of the file) we make use of the +// FreeImage_GetFIFFromFilename function. This function +// receives a file name, for example 'myfile.bmp', and returns +// a FREE_IMAGE_TYPE enum which identifies that bitmap. +// +// Functions used in this sample : +// FreeImage_GetFileType, FreeImage_GetFIFFromFilename, FreeImage_FIFSupportsReading, +// FreeImage_Load, FreeImage_GetBPP, FreeImage_FIFSupportsWriting, FreeImage_GetFormatFromFIF +// FreeImage_FIFSupportsExportBPP, FreeImage_Save, FreeImage_Unload, +// FreeImage_SetOutputMessage, FreeImage_GetVersion, FreeImage_GetCopyrightMessage +// +// ========================================================== + +#include +#include +#include +#include +#include + +#include "FreeImage.h" + +// ---------------------------------------------------------- + +/** Generic image loader + @param lpszPathName Pointer to the full file name + @param flag Optional load flag constant + @return Returns the loaded dib if successful, returns NULL otherwise +*/ +FIBITMAP* GenericLoader(const char* lpszPathName, int flag) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + + // check the file signature and deduce its format + // (the second argument is currently not used by FreeImage) + fif = FreeImage_GetFileType(lpszPathName, 0); + if(fif == FIF_UNKNOWN) { + // no signature ? + // try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilename(lpszPathName); + } + // check that the plugin has reading capabilities ... + if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) { + // ok, let's load the file + FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, flag); + // unless a bad file format, we are done ! + return dib; + } + return NULL; +} + +/** Generic image writer + @param dib Pointer to the dib to be saved + @param lpszPathName Pointer to the full file name + @param flag Optional save flag constant + @return Returns true if successful, returns false otherwise +*/ +bool GenericWriter(FIBITMAP* dib, const char* lpszPathName, int flag) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + BOOL bSuccess = FALSE; + + if(dib) { + // try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilename(lpszPathName); + if(fif != FIF_UNKNOWN ) { + // check that the plugin has sufficient writing and export capabilities ... + WORD bpp = FreeImage_GetBPP(dib); + if(FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp)) { + // ok, we can save the file + bSuccess = FreeImage_Save(fif, dib, lpszPathName, flag); + // unless an abnormal bug, we are done ! + } + } + } + return (bSuccess == TRUE) ? true : false; +} + +// ---------------------------------------------------------- + +/** + FreeImage error handler + @param fif Format / Plugin responsible for the error + @param message Error message +*/ +void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { + printf("\n*** "); + if(fif != FIF_UNKNOWN) { + printf("%s Format\n", FreeImage_GetFormatFromFIF(fif)); + } + printf(message); + printf(" ***\n"); +} + +// ---------------------------------------------------------- + +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif + +int +main(int argc, char *argv[]) { + + const char *input_dir = "d:\\images\\"; + FIBITMAP *dib = NULL; + int id = 1; + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_Initialise(); +#endif // FREEIMAGE_LIB + + // initialize your own FreeImage error handler + + FreeImage_SetOutputMessage(FreeImageErrorHandler); + + // print version & copyright infos + + printf(FreeImage_GetVersion()); + printf("\n"); + printf(FreeImage_GetCopyrightMessage()); + printf("\n"); + + // open the log file + + FILE *log_file = fopen("log_file.txt", "w"); + + // batch convert all supported bitmaps + + _finddata_t finddata; + long handle; + char image_path[MAX_PATH]; + + // scan all files + strcpy(image_path, input_dir); + strcat(image_path, "*.*"); + + if ((handle = _findfirst(image_path, &finddata)) != -1) { + do { + // make a path to a directory + + char *directory = new char[MAX_PATH]; + strcpy(directory, input_dir); + strcat(directory, finddata.name); + + // make a unique filename + + char *unique = new char[128]; + itoa(id, unique, 10); + strcat(unique, ".png"); + + // open and load the file using the default load option + dib = GenericLoader(directory, 0); + + if (dib != NULL) { + // save the file as PNG + bool bSuccess = GenericWriter(dib, unique, PNG_DEFAULT); + + // free the dib + FreeImage_Unload(dib); + + if(bSuccess) { + fwrite(unique, strlen(unique), 1, log_file); + } else { + strcpy(unique, "FAILED"); + fwrite(unique, strlen(unique), 1, log_file); + } + fwrite(" >> ", 4, 1, log_file); + fwrite(directory, strlen(directory), 1, log_file); + fwrite("\n", 1, 1, log_file); + + id++; + } + + delete [] unique; + delete [] directory; + + } while (_findnext(handle, &finddata) == 0); + + _findclose(handle); + } + + fclose(log_file); + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_DeInitialise(); +#endif // FREEIMAGE_LIB + + return 0; +} diff --git a/#ThirdParty/FreeImage/Examples/Generic/CloneMultiPage.cpp b/#ThirdParty/FreeImage/Examples/Generic/CloneMultiPage.cpp new file mode 100644 index 0000000..bbeef58 --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/Generic/CloneMultiPage.cpp @@ -0,0 +1,112 @@ +// ========================================================== +// Multipage functions demonstration +// +// Design and implementation by +// - Hervé Drolon +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at own risk! +// ========================================================== + +// This sample shows how to clone a multipage TIFF +// +// Functions used in this sample : +// FreeImage_OpenMultiBitmap, FreeImage_GetPageCount, FreeImage_LockPage, +// FreeImage_AppendPage, FreeImage_UnlockPage, FreeImage_CloseMultiBitmap; +// FreeImage_SetOutputMessage +// +// ========================================================== + +#include +#include +#include + +#include "FreeImage.h" + +// ---------------------------------------------------------- + +/** + FreeImage error handler +*/ +void MyMessageFunc(FREE_IMAGE_FORMAT fif, const char *message) { + cout << "\n*** " << message << " ***\n"; + cout.flush(); +} + +// ---------------------------------------------------------- + +bool CloneMultiPage(FREE_IMAGE_FORMAT fif, char *input, char *output, int output_flag) { + + BOOL bMemoryCache = TRUE; + + // Open src file (read-only, use memory cache) + FIMULTIBITMAP *src = FreeImage_OpenMultiBitmap(fif, input, FALSE, TRUE, bMemoryCache); + + if(src) { + // Open dst file (creation, use memory cache) + FIMULTIBITMAP *dst = FreeImage_OpenMultiBitmap(fif, output, TRUE, FALSE, bMemoryCache); + + // Get src page count + int count = FreeImage_GetPageCount(src); + + // Clone src to dst + for(int page = 0; page < count; page++) { + // Load the bitmap at position 'page' + FIBITMAP *dib = FreeImage_LockPage(src, page); + if(dib) { + // add a new bitmap to dst + FreeImage_AppendPage(dst, dib); + // Unload the bitmap (do not apply any change to src) + FreeImage_UnlockPage(src, dib, FALSE); + } + } + + // Close src + FreeImage_CloseMultiBitmap(src, 0); + // Save and close dst + FreeImage_CloseMultiBitmap(dst, output_flag); + + return true; + } + + return false; +} + + +int +main(int argc, char *argv[]) { + + char *input_filename = "images\\input.tif"; + char *output_filename = "images\\clone.tif"; + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_Initialise(); +#endif // FREEIMAGE_LIB + + // initialize our own FreeImage error handler + + FreeImage_SetOutputMessage(MyMessageFunc); + + // Copy 'input.tif' to 'clone.tif' + + CloneMultiPage(FIF_TIFF, input_filename, output_filename, 0); + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_DeInitialise(); +#endif // FREEIMAGE_LIB + + return 0; +} diff --git a/#ThirdParty/FreeImage/Examples/Generic/CreateAlpha.cpp b/#ThirdParty/FreeImage/Examples/Generic/CreateAlpha.cpp new file mode 100644 index 0000000..48b3e29 --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/Generic/CreateAlpha.cpp @@ -0,0 +1,181 @@ +// ========================================================== +// Alpha channel manipulation example +// +// Design and implementation by +// - Hervé Drolon +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at own risk! +// ========================================================== + +// This example shows how to create a transparent image from any input image +// using the greyscale version of the input image as the alpha channel mask. +// The alpha channel is set using the FreeImage_SetChannel function. +// +// +// ========================================================== + +#include +#include "FreeImage.h" + +// ---------------------------------------------------------- + +/** Generic image loader + @param lpszPathName Pointer to the full file name + @param flag Optional load flag constant + @return Returns the loaded dib if successful, returns NULL otherwise +*/ +FIBITMAP* GenericLoader(const char* lpszPathName, int flag) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + + // check the file signature and deduce its format + // (the second argument is currently not used by FreeImage) + fif = FreeImage_GetFileType(lpszPathName, 0); + if(fif == FIF_UNKNOWN) { + // no signature ? + // try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilename(lpszPathName); + } + // check that the plugin has reading capabilities ... + if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) { + // ok, let's load the file + FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, flag); + // unless a bad file format, we are done ! + return dib; + } + return NULL; +} + +/** Generic image writer + @param dib Pointer to the dib to be saved + @param lpszPathName Pointer to the full file name + @param flag Optional save flag constant + @return Returns true if successful, returns false otherwise +*/ +bool GenericWriter(FIBITMAP* dib, const char* lpszPathName, int flag) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + BOOL bSuccess = FALSE; + + if(dib) { + // try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilename(lpszPathName); + if(fif != FIF_UNKNOWN ) { + // check that the plugin has sufficient writing and export capabilities ... + WORD bpp = FreeImage_GetBPP(dib); + if(FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp)) { + // ok, we can save the file + bSuccess = FreeImage_Save(fif, dib, lpszPathName, flag); + // unless an abnormal bug, we are done ! + } + } + } + return (bSuccess == TRUE) ? true : false; +} + +// ---------------------------------------------------------- + +/** + FreeImage error handler + @param fif Format / Plugin responsible for the error + @param message Error message +*/ +void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { + printf("\n*** "); + if(fif != FIF_UNKNOWN) { + printf("%s Format\n", FreeImage_GetFormatFromFIF(fif)); + } + printf(message); + printf(" ***\n"); +} + +// ---------------------------------------------------------- + + +/** + Creates a 32-bit transparent image using the black channel of the source image + @param src Source image + @return Returns a 32-bit transparent image +*/ +FIBITMAP* CreateAlphaFromLightness(FIBITMAP *src) { + // create a 32-bit image from the source + FIBITMAP *dst = FreeImage_ConvertTo32Bits(src); + + // create a 8-bit mask + FreeImage_Invert(src); + FIBITMAP *mask = FreeImage_ConvertTo8Bits(src); + FreeImage_Invert(src); + + // insert the mask as an alpha channel + FreeImage_SetChannel(dst, mask, FICC_ALPHA); + + // free the mask and return + FreeImage_Unload(mask); + + return dst; +} + +int +main(int argc, char *argv[]) { + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_Initialise(); +#endif // FREEIMAGE_LIB + + // initialize your own FreeImage error handler + + FreeImage_SetOutputMessage(FreeImageErrorHandler); + + // print version & copyright infos + + printf("FreeImage version : %s", FreeImage_GetVersion()); + printf("\n"); + printf(FreeImage_GetCopyrightMessage()); + printf("\n"); + + + if(argc != 3) { + printf("Usage : CreateAlpha \n"); + return 0; + } + + // Load the source image + FIBITMAP *src = GenericLoader(argv[1], 0); + if(src) { + // Create a transparent image from the lightness image of src + FIBITMAP *dst = CreateAlphaFromLightness(src); + + if(dst) { + // Save the destination image + bool bSuccess = GenericWriter(dst, argv[2], 0); + if(!bSuccess) { + printf("\nUnable to save %s file", argv[2]); + printf("\nThis format does not support 32-bit images"); + } + + // Free dst + FreeImage_Unload(dst); + } + + // Free src + FreeImage_Unload(src); + } + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_DeInitialise(); +#endif // FREEIMAGE_LIB + + return 0; +} diff --git a/#ThirdParty/FreeImage/Examples/Generic/FIFImportExport.cpp b/#ThirdParty/FreeImage/Examples/Generic/FIFImportExport.cpp new file mode 100644 index 0000000..f78c054 --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/Generic/FIFImportExport.cpp @@ -0,0 +1,149 @@ +// ========================================================== +// Plugin functions demonstration +// +// Design and implementation by +// - Hervé Drolon +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at own risk! +// ========================================================== + +// This example shows how to use Plugin functions to explore FreeImage capabilities. +// Whenever an external plugin is added to the library, it is automatically loaded +// with FreeImage and can be asked for its capabilities via the plugin functions. +// +// Functions used in this sample : +// FreeImage_FIFSupportsExportBPP, FreeImage_FIFSupportsICCProfiles, FreeImage_FIFSupportsReading, +// FreeImage_FIFSupportsWriting, FreeImage_GetFIFCount, FreeImage_GetFIFDescription, +// FreeImage_GetFIFExtensionList, FreeImage_GetFormatFromFIF, +// FreeImage_GetVersion, FreeImage_GetCopyrightMessage, FreeImage_SetOutputMessage +// +// ========================================================== + +#include +#include +#include +#include + +#include "FreeImage.h" + +// ---------------------------------------------------------- + +/** + FreeImage error handler +*/ +void MyMessageFunc(FREE_IMAGE_FORMAT fif, const char *message) { + cout << "\n*** " << message << " ***\n"; +} + +// ---------------------------------------------------------- + +/** + Print plugins import capabilities +*/ +void PrintImportFormats(iostream& ios) { + int count = FreeImage_GetFIFCount(); + if(count) + ios << "FORMAT;DESCRIPTION;EXTENSIONS;ICC PROFILES\n"; + for(int i = 0; i < count; i++) { + FREE_IMAGE_FORMAT fif = (FREE_IMAGE_FORMAT)i; + + if(FreeImage_FIFSupportsReading(fif)) { + const char * format = FreeImage_GetFormatFromFIF(fif); + const char * description = FreeImage_GetFIFDescription(fif); + const char * ext = FreeImage_GetFIFExtensionList(fif); + const char * icc = "*"; + if(FreeImage_FIFSupportsICCProfiles(fif)) { + ios << format << ";" << description << ";" << ext << ";" << icc << "\n"; + } else { + ios << format << ";" << description << ";" << ext << "; \n"; + } + } + } +} + +/** + Print plugins export capabilities +*/ +void PrintExportFormats(iostream& ios) { + int count = FreeImage_GetFIFCount(); + if(count) + ios << "FORMAT;DESCRIPTION;EXTENSIONS;BITDEPTH;ICC PROFILES\n"; + for(int i = 0; i < count; i++) { + FREE_IMAGE_FORMAT fif = (FREE_IMAGE_FORMAT)i; + + if(FreeImage_FIFSupportsWriting(fif)) { + const char * format = FreeImage_GetFormatFromFIF(fif); + const char * description = FreeImage_GetFIFDescription(fif); + const char * ext = FreeImage_GetFIFExtensionList(fif); + const char * icc = "*"; + + ios << format << ";" << description << ";" << ext << ";"; + if(FreeImage_FIFSupportsExportBPP(fif, 1)) + ios << "1 "; + if(FreeImage_FIFSupportsExportBPP(fif, 4)) + ios << "4 "; + if(FreeImage_FIFSupportsExportBPP(fif, 8)) + ios << "8 "; + if(FreeImage_FIFSupportsExportBPP(fif, 16)) + ios << "16 "; + if(FreeImage_FIFSupportsExportBPP(fif, 24)) + ios << "24 "; + if(FreeImage_FIFSupportsExportBPP(fif, 32)) + ios << "32 "; + if(FreeImage_FIFSupportsICCProfiles(fif)) { + ios << ";" << icc; + } else { + ios << "; "; + } + ios << "\n"; + } + } +} + +int +main(int argc, char *argv[]) { + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_Initialise(); +#endif // FREEIMAGE_LIB + + // initialize FreeImage error handler + + FreeImage_SetOutputMessage(MyMessageFunc); + + // print version & copyright infos + + cout << "FreeImage " << FreeImage_GetVersion() << "\n"; + cout << FreeImage_GetCopyrightMessage() << "\n\n"; + + // Print input formats (including external plugins) known by the library + fstream importFile("fif_import.csv", ios::out); + PrintImportFormats(importFile); + importFile.close(); + + // Print output formats (including plugins) known by the library + // for each export format, supported bitdepths are given + fstream exportFile("fif_export.csv", ios::out); + PrintExportFormats(exportFile); + exportFile.close(); + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_DeInitialise(); +#endif // FREEIMAGE_LIB + + return 0; + +} diff --git a/#ThirdParty/FreeImage/Examples/Generic/FIIO_Mem.cpp b/#ThirdParty/FreeImage/Examples/Generic/FIIO_Mem.cpp new file mode 100644 index 0000000..33eea8a --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/Generic/FIIO_Mem.cpp @@ -0,0 +1,146 @@ +/*--------------------------------------------------------------------------*\ +|| fiio_mem.cpp by Ryan Rubley || +|| || +|| (v1.02) 4-28-2004 || +|| FreeImageIO to memory || +|| || +\*--------------------------------------------------------------------------*/ + +#include +#include +#include "fiio_mem.h" + +#ifdef __cplusplus +extern "C" { +#endif + +FIBITMAP * +FreeImage_LoadFromMem(FREE_IMAGE_FORMAT fif, fiio_mem_handle *handle, int flags) { + FreeImageIO io; + SetMemIO(&io); + + if (handle && handle->data) { + handle->curpos = 0; + return FreeImage_LoadFromHandle(fif, &io, (fi_handle)handle, flags); + } + + return NULL; +} + +BOOL +FreeImage_SaveToMem(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, fiio_mem_handle *handle, int flags) { + FreeImageIO io; + SetMemIO(&io); + + if (handle) { + handle->filelen = 0; + handle->curpos = 0; + return FreeImage_SaveToHandle(fif, dib, &io, (fi_handle)handle, flags); + } + + return FALSE; +} + +// ---------------------------------------------------------- + +void +SetMemIO(FreeImageIO *io) { + io->read_proc = fiio_mem_ReadProc; + io->seek_proc = fiio_mem_SeekProc; + io->tell_proc = fiio_mem_TellProc; + io->write_proc = fiio_mem_WriteProc; +} + +// ---------------------------------------------------------- + +#define FIIOMEM(member) (((fiio_mem_handle *)handle)->member) + +unsigned +fiio_mem_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { + unsigned x; + for( x=0; x= FIIOMEM(datalen) ) { + //if we are at or above 1G, we cant double without going negative + if( FIIOMEM(datalen) & 0x40000000 ) { + //max 2G + if( FIIOMEM(datalen) == 0x7FFFFFFF ) { + return 0; + } + newdatalen = 0x7FFFFFFF; + } else if( FIIOMEM(datalen) == 0 ) { + //default to 4K if nothing yet + newdatalen = 4096; + } else { + //double size + newdatalen = FIIOMEM(datalen) << 1; + } + newdata = realloc( FIIOMEM(data), newdatalen ); + if( !newdata ) { + return 0; + } + FIIOMEM(data) = newdata; + FIIOMEM(datalen) = newdatalen; + } + memcpy( (char *)FIIOMEM(data) + FIIOMEM(curpos), buffer, size*count ); + FIIOMEM(curpos) += size*count; + if( FIIOMEM(curpos) > FIIOMEM(filelen) ) { + FIIOMEM(filelen) = FIIOMEM(curpos); + } + return count; +} + +int +fiio_mem_SeekProc(fi_handle handle, long offset, int origin) { + switch(origin) { //0 to filelen-1 are 'inside' the file + default: + case SEEK_SET: //can fseek() to 0-7FFFFFFF always + if( offset >= 0 ) { + FIIOMEM(curpos) = offset; + return 0; + } + break; + + case SEEK_CUR: + if( FIIOMEM(curpos)+offset >= 0 ) { + FIIOMEM(curpos) += offset; + return 0; + } + break; + + case SEEK_END: + if( FIIOMEM(filelen)+offset >= 0 ) { + FIIOMEM(curpos) = FIIOMEM(filelen)+offset; + return 0; + } + break; + } + + return -1; +} + +long +fiio_mem_TellProc(fi_handle handle) { + return FIIOMEM(curpos); +} + +#ifdef __cplusplus +} +#endif diff --git a/#ThirdParty/FreeImage/Examples/Generic/FIIO_Mem.h b/#ThirdParty/FreeImage/Examples/Generic/FIIO_Mem.h new file mode 100644 index 0000000..e686b1c --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/Generic/FIIO_Mem.h @@ -0,0 +1,74 @@ +/*--------------------------------------------------------------------------*\ +|| fiio_mem.h by Ryan Rubley || +|| || +|| (v1.02) 4-28-2004 || +|| FreeImageIO to memory || +|| || +\*--------------------------------------------------------------------------*/ + +#ifndef _FIIO_MEM_H_ +#define _FIIO_MEM_H_ + +#include "freeimage.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct fiio_mem_handle_s { + long filelen,datalen,curpos; + void *data; +} fiio_mem_handle; + +/* it is up to the user to create a fiio_mem_handle and init datalen and data + * filelen will be pre-set to 0 by SaveToMem + * curpos will be pre-set to 0 by SaveToMem and LoadFromMem + * IMPORTANT: data should be set to NULL and datalen to 0, + * unless the user wants to manually malloc a larger buffer + */ +FIBITMAP *FreeImage_LoadFromMem(FREE_IMAGE_FORMAT fif, fiio_mem_handle *handle, int flags); +BOOL FreeImage_SaveToMem(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, fiio_mem_handle *handle, int flags); + +void SetMemIO(FreeImageIO *io); +unsigned fiio_mem_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); +unsigned fiio_mem_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle); +int fiio_mem_SeekProc(fi_handle handle, long offset, int origin); +long fiio_mem_TellProc(fi_handle handle); + +/*** Example Usage *** + +//variables +FIBITMAP *bitmap, *bitmap2; +fiio_mem_handle fmh; + +//important initialization +fmh.data = NULL; +fmh.datalen = 0; + +//load a regular file +bitmap = FreeImage_Load(FIF_PNG, "sample.png"); + +//save the file to memory +FreeImage_SaveToMem(FIF_PNG, bitmap, &fmh, 0); + +//at this point, fmh.data contains the entire PNG data in memory +//fmh.datalen is the amount of space malloc'd for the image in memory, +//but only fmh.filelen amount of that space is actually used. + +//its easy load an image from memory as well +bitmap2 = FreeImage_LoadFromMem(FIF_PNG, &fmh, 0); +//you could also have image data in memory via some other method, and just set +//fmh.data to point to it, and set both fmh.datalen and fmh.filelen to the +//size of that data, then FreeImage_LoadFromMem could load the image from that +//memory + +//make sure to free the data since SaveToMem will cause it to be malloc'd +free(fmh.data); + +*/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/#ThirdParty/FreeImage/Examples/Generic/LoadFromHandle.cpp b/#ThirdParty/FreeImage/Examples/Generic/LoadFromHandle.cpp new file mode 100644 index 0000000..d8e14e8 --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/Generic/LoadFromHandle.cpp @@ -0,0 +1,145 @@ +// ========================================================== +// Load From Handle Example +// +// Design and implementation by +// - Hervé Drolon +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at own risk! +// ========================================================== + +// This example shows how to load a bitmap from a +// user allocated FILE pointer. +// +// Functions used in this sample : +// FreeImage_GetFormatFromFIF, FreeImage_GetFileTypeFromHandle, FreeImage_LoadFromHandle, +// FreeImage_GetFIFFromFilename, FreeImage_Save, FreeImage_Unload +// FreeImage_GetVersion, FreeImage_GetCopyrightMessage, FreeImage_SetOutputMessage +// +// ========================================================== + +#include +#include +#include + +#include "FreeImage.h" + +// ---------------------------------------------------------- + +/** + FreeImage error handler + @param fif Format / Plugin responsible for the error + @param message Error message +*/ +void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { + printf("\n*** "); + if(fif != FIF_UNKNOWN) { + printf("%s Format\n", FreeImage_GetFormatFromFIF(fif)); + } + printf(message); + printf(" ***\n"); +} + +// ---------------------------------------------------------- + +unsigned DLL_CALLCONV +myReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { + return fread(buffer, size, count, (FILE *)handle); +} + +unsigned DLL_CALLCONV +myWriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { + return fwrite(buffer, size, count, (FILE *)handle); +} + +int DLL_CALLCONV +mySeekProc(fi_handle handle, long offset, int origin) { + return fseek((FILE *)handle, offset, origin); +} + +long DLL_CALLCONV +myTellProc(fi_handle handle) { + return ftell((FILE *)handle); +} + +// ---------------------------------------------------------- + +int +main(int argc, char *argv[]) { + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_Initialise(); +#endif // FREEIMAGE_LIB + + // initialize your own FreeImage error handler + + FreeImage_SetOutputMessage(FreeImageErrorHandler); + + // print version & copyright infos + + printf(FreeImage_GetVersion()); + printf("\n"); + printf(FreeImage_GetCopyrightMessage()); + printf("\n"); + + + if(argc != 2) { + printf("Usage : LoadFromHandle \n"); + return 0; + } + + // initialize your own IO functions + + FreeImageIO io; + + io.read_proc = myReadProc; + io.write_proc = myWriteProc; + io.seek_proc = mySeekProc; + io.tell_proc = myTellProc; + + FILE *file = fopen(argv[1], "rb"); + + if (file != NULL) { + // find the buffer format + FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromHandle(&io, (fi_handle)file, 0); + + if(fif != FIF_UNKNOWN) { + // load from the file handle + FIBITMAP *dib = FreeImage_LoadFromHandle(fif, &io, (fi_handle)file, 0); + + // save the bitmap as a PNG ... + const char *output_filename = "test.png"; + + // first, check the output format from the file name or file extension + FREE_IMAGE_FORMAT out_fif = FreeImage_GetFIFFromFilename(output_filename); + + if(out_fif != FIF_UNKNOWN) { + // then save the file + FreeImage_Save(out_fif, dib, output_filename, 0); + } + + // free the loaded FIBITMAP + FreeImage_Unload(dib); + } + fclose(file); + } + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_DeInitialise(); +#endif // FREEIMAGE_LIB + + return 0; +} diff --git a/#ThirdParty/FreeImage/Examples/Generic/LoadFromMemory-classified.cpp b/#ThirdParty/FreeImage/Examples/Generic/LoadFromMemory-classified.cpp new file mode 100644 index 0000000..7494ba9 --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/Generic/LoadFromMemory-classified.cpp @@ -0,0 +1,101 @@ +// ========================================================== +// Classified FreeImageIO handler +// +// Design and implementation by +// - schickb (schickb@hotmail.com) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +class MemIO : public FreeImageIO { +public : + MemIO( BYTE *data ) : _start(data), _cp(data) { + read_proc = _ReadProc; + write_proc = _WriteProc; + tell_proc = _TellProc; + seek_proc = _SeekProc; + } + + void Reset() { + _cp = _start; + } + + static unsigned _ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); + static unsigned _WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle); + static int _SeekProc(fi_handle handle, long offset, int origin); + static long _TellProc(fi_handle handle); + +private: + BYTE * const _start; + BYTE *_cp; +}; + + +unsigned +MemIO::_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { + MemIO *memIO = (MemIO*)handle; + + BYTE *tmp = (BYTE *)buffer; + + for (unsigned c = 0; c < count; c++) { + memcpy(tmp, memIO->_cp, size); + + memIO->_cp = memIO->_cp + size; + + tmp += size; + } + + return count; +} + +unsigned +MemIO::_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { + ASSERT( false ); + return size; +} + +int +MemIO::_SeekProc(fi_handle handle, long offset, int origin) { + ASSERT(origin != SEEK_END); + + MemIO *memIO = (MemIO*)handle; + + if (origin == SEEK_SET) + memIO->_cp = memIO->_start + offset; + else + memIO->_cp = memIO->_cp + offset; + + return 0; +} + +long +MemIO::_TellProc(fi_handle handle) { + MemIO *memIO = (MemIO*)handle; + + return memIO->_cp - memIO->_start; +} + +// ---------------------------------------------------------- +// PSEUDOCODE... HELPS TO UNDERSTAND HOW THE MEMIO CLASS WORKS +// ---------------------------------------------------------- + +int +main(int argc, char *argv[]) { + BYTE *data = loadimagesomehow(); + + MemIO memIO(data); + + FIBITMAP *fbmp = FreeImage_LoadFromHandle( fif, &memIO, (fi_handle)&memIO ); +} \ No newline at end of file diff --git a/freeimage241/Examples/Generic/LoadFromMemory.cpp b/#ThirdParty/FreeImage/Examples/Generic/LoadFromMemory.cpp similarity index 84% rename from freeimage241/Examples/Generic/LoadFromMemory.cpp rename to #ThirdParty/FreeImage/Examples/Generic/LoadFromMemory.cpp index 72acc73..f62e0b5 100644 --- a/freeimage241/Examples/Generic/LoadFromMemory.cpp +++ b/#ThirdParty/FreeImage/Examples/Generic/LoadFromMemory.cpp @@ -1,112 +1,113 @@ -// ========================================================== -// Load From Memory Example -// -// Design and implementation by Floris van den Berg -// -// This file is part of FreeImage -// -// Use at own risk! -// ========================================================== -// -// This example shows how to load a bitmap from memory -// rather than from a file. To do this we make use of the -// FreeImage_LoadXXXFromHandle functions where we override -// the i/o functions to simulate FILE* access in memory. -// -// For seeking purposes the fi_handle passed to the i/o -// functions contain the start of the data block where the -// bitmap is stored. -// -// ========================================================== - -#include -#include -#include - -#include "FreeImage.h" - -// ---------------------------------------------------------- - -fi_handle g_load_address; - -// ---------------------------------------------------------- - -inline unsigned -_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { - BYTE *tmp = (BYTE *)buffer; - - for (unsigned c = 0; c < count; c++) { - memcpy(tmp, g_load_address, size); - - g_load_address = (BYTE *)g_load_address + size; - - tmp += size; - } - - return count; -} - -inline unsigned -_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { - // there's not much use for saving the bitmap into memory now, is there? - - return size; -} - -inline int -_SeekProc(fi_handle handle, long offset, int origin) { - assert(origin != SEEK_END); - - if (origin == SEEK_SET) { - g_load_address = (BYTE *)handle + offset; - } else { - g_load_address = (BYTE *)g_load_address + offset; - } - - return 0; -} - -inline long -_TellProc(fi_handle handle) { - assert((int)handle > (int)g_load_address); - - return ((int)g_load_address - (int)handle); -} - -// ---------------------------------------------------------- - -int __cdecl -main(int argc, char *argv[]) { - FreeImageIO io; - - io.read_proc = _ReadProc; - io.write_proc = _WriteProc; - io.tell_proc = _TellProc; - io.seek_proc = _SeekProc; - - // allocate some memory for the bitmap - - BYTE *test = new BYTE[159744]; - - if (test != NULL) { - // load the bitmap into memory. ofcourse you can do this any way you want - - FILE *file = fopen("e:\\projects\\images\\money-256.tif", "rb"); - fread(test, 159744, 1, file); - fclose(file); - - // we store the load address of the bitmap for internal reasons - - g_load_address = test; - - // convert the bitmap - - FIBITMAP *dib = FreeImage_LoadTIFFFromHandle(&io, (fi_handle)test); - - FreeImage_Free(dib); - - delete [] test; - } - - return 0; +// ========================================================== +// Load From Memory Example +// +// Design and implementation by Floris van den Berg +// +// This file is part of FreeImage 3 +// +// Use at own risk! +// ========================================================== +// +// This example shows how to load a bitmap from memory +// rather than from a file. To do this we make use of the +// FreeImage_LoadFromHandle functions where we override +// the i/o functions to simulate FILE* access in memory. +// +// For seeking purposes the fi_handle passed to the i/o +// functions contain the start of the data block where the +// bitmap is stored. +// +// ========================================================== + +#include +#include +#include + +#include "FreeImage.h" + +// ---------------------------------------------------------- + +fi_handle g_load_address; + +// ---------------------------------------------------------- + +inline unsigned _stdcall +_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { + BYTE *tmp = (BYTE *)buffer; + + for (unsigned c = 0; c < count; c++) { + memcpy(tmp, g_load_address, size); + + g_load_address = (BYTE *)g_load_address + size; + + tmp += size; + } + + return count; +} + +inline unsigned _stdcall +_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { + // there's not much use for saving the bitmap into memory now, is there? + + return size; +} + +inline int _stdcall +_SeekProc(fi_handle handle, long offset, int origin) { + assert(origin != SEEK_END); + + if (origin == SEEK_SET) { + g_load_address = (BYTE *)handle + offset; + } else { + g_load_address = (BYTE *)g_load_address + offset; + } + + return 0; +} + +inline long _stdcall +_TellProc(fi_handle handle) { + assert((int)handle > (int)g_load_address); + + return ((int)g_load_address - (int)handle); +} + +// ---------------------------------------------------------- + +int +main(int argc, char *argv[]) { + FreeImageIO io; + + io.read_proc = _ReadProc; + io.write_proc = _WriteProc; + io.tell_proc = _TellProc; + io.seek_proc = _SeekProc; + + // allocate some memory for the bitmap + + BYTE *test = new BYTE[159744]; + + if (test != NULL) { + // load the bitmap into memory. ofcourse you can do this any way you want + + FILE *file = fopen("e:\\projects\\images\\money-256.tif", "rb"); + fread(test, 159744, 1, file); + fclose(file); + + // we store the load address of the bitmap for internal reasons + + g_load_address = test; + + // convert the bitmap + + FIBITMAP *dib = FreeImage_LoadFromHandle(FIF_TIFF, &io, (fi_handle)test); + + // don't forget to free the dib ! + FreeImage_Unload(dib); + + delete [] test; + } + + return 0; } \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Examples/Generic/ShowMetadata.cpp b/#ThirdParty/FreeImage/Examples/Generic/ShowMetadata.cpp new file mode 100644 index 0000000..1df0af8 --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/Generic/ShowMetadata.cpp @@ -0,0 +1,317 @@ +// ========================================================== +// Simple metadata reader +// +// Design and implementation by +// - Hervé Drolon +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at own risk! +// ========================================================== + +// +// This example shows how to easily parse all metadata +// contained in a JPEG, TIFF or PNG image. +// Comments, Exif and IPTC/NAA metadata tags are written to a HTML file +// for later reading, and Adobe XMP XML packets are written +// in a file whose extension is '.xmp'. This file can be later +// processed using a XML parser. +// +// Metadata functions showed in this sample : +// FreeImage_GetMetadataCount, FreeImage_FindFirstMetadata, FreeImage_FindNextMetadata, +// FreeImage_FindCloseMetadata, FreeImage_TagToString, FreeImage_GetMetadata +// +// ========================================================== + +#include +#include +#include + +using namespace std; + +#include "FreeImage.h" + +// ---------------------------------------------------------- + +/** Generic image loader + @param lpszPathName Pointer to the full file name + @param flag Optional load flag constant + @return Returns the loaded dib if successful, returns NULL otherwise +*/ +FIBITMAP* GenericLoader(const char* lpszPathName, int flag) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + + // check the file signature and deduce its format + // (the second argument is currently not used by FreeImage) + fif = FreeImage_GetFileType(lpszPathName, 0); + if(fif == FIF_UNKNOWN) { + // no signature ? + // try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilename(lpszPathName); + } + // check that the plugin has reading capabilities ... + if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) { + // ok, let's load the file + FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, flag); + // unless a bad file format, we are done ! + return dib; + } + return NULL; +} + +/** Generic image writer + @param dib Pointer to the dib to be saved + @param lpszPathName Pointer to the full file name + @param flag Optional save flag constant + @return Returns true if successful, returns false otherwise +*/ +bool GenericWriter(FIBITMAP* dib, const char* lpszPathName, int flag) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + BOOL bSuccess = FALSE; + + if(dib) { + // try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilename(lpszPathName); + if(fif != FIF_UNKNOWN ) { + // check that the plugin has sufficient writing and export capabilities ... + WORD bpp = FreeImage_GetBPP(dib); + if(FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp)) { + // ok, we can save the file + bSuccess = FreeImage_Save(fif, dib, lpszPathName, flag); + // unless an abnormal bug, we are done ! + } + } + } + return (bSuccess == TRUE) ? true : false; +} + +// ---------------------------------------------------------- + +/** + FreeImage error handler + @param fif Format / Plugin responsible for the error + @param message Error message +*/ +void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { + cout << "\n*** "; + if(fif != FIF_UNKNOWN) { + cout << FreeImage_GetFormatFromFIF(fif) << " Format\n"; + } + cout << message; + cout << " ***\n"; +} + +// ---------------------------------------------------------- + +/** +Print a basic HTML header +*/ +void PrintHTMLHeader(iostream& ios) { + ios << "\n\n
\n"; + ios << "\n"; +} + +/** +Print a HTML footer +*/ +void PrintHTMLFooter(iostream& ios) { + ios << "
\n\n\n\n"; +} + +/** +Print a table header +*/ +void PrintTableHeader(iostream& ios, const char *title) { + ios << "\n"; + ios << "\n"; +} + +/** +Print a table section +*/ +void PrintTableSection(iostream& ios, const char *title) { + ios << "\n"; + ios << ""; +} + +/** +Print a table footer +*/ +void PrintTableFooter(iostream& ios) { + ios << "
" << title << "
" << title << "
Tag nameTag valueDescription
\n"; +} + + +/** +Print the metadata tags to a HTML file +*/ +void PrintMetadata(iostream& ios, const char *sectionTitle, FIBITMAP *dib, FREE_IMAGE_MDMODEL model) { + FITAG *tag = NULL; + FIMETADATA *mdhandle = NULL; + + mdhandle = FreeImage_FindFirstMetadata(model, dib, &tag); + + if(mdhandle) { + // Print a table section + PrintTableSection(ios, sectionTitle); + + do { + // convert the tag value to a string + const char *value = FreeImage_TagToString(model, tag); + + // print the tag + // note that most tags do not have a description, + // especially when the metadata specifications are not available + if(FreeImage_GetTagDescription(tag)) { + ios << "" << FreeImage_GetTagKey(tag) << "" << value << "" << FreeImage_GetTagDescription(tag) << "\n"; + } else { + ios << "" << FreeImage_GetTagKey(tag) << "" << value << "" << " " << "\n"; + } + + } while(FreeImage_FindNextMetadata(mdhandle, &tag)); + } + + FreeImage_FindCloseMetadata(mdhandle); +} + +int +main(int argc, char *argv[]) { + unsigned count; + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_Initialise(); +#endif // FREEIMAGE_LIB + + // initialize your own FreeImage error handler + + FreeImage_SetOutputMessage(FreeImageErrorHandler); + + // print version & copyright infos + + cout << "FreeImage " << FreeImage_GetVersion() << "\n"; + cout << FreeImage_GetCopyrightMessage() << "\n\n"; + + if(argc != 2) { + cout << "Usage : ShowMetadata \n"; + return 0; + } + + // Load the bitmap + + FIBITMAP *dib = GenericLoader(argv[1], 0); + if(!dib) + return 0; + + // Create a HTML file + std::string html_file(strtok(argv[1], ".") + std::string(".html")); + + fstream metadataFile(html_file.c_str(), ios::out); + + // Print the header + + PrintHTMLHeader(metadataFile); + PrintTableHeader(metadataFile, argv[1]); + + // Parse and print metadata + + if(count = FreeImage_GetMetadataCount(FIMD_COMMENTS, dib)) { + cout << "\nFIMD_COMMENTS (" << count << " data)\n-----------------------------------------\n"; + + PrintMetadata(metadataFile, "Comments", dib, FIMD_COMMENTS); + } + if(count = FreeImage_GetMetadataCount(FIMD_EXIF_MAIN, dib)) { + cout << "\nFIMD_EXIF_MAIN (" << count << " data)\n-----------------------------------------\n"; + + PrintMetadata(metadataFile, "Exif - main info", dib, FIMD_EXIF_MAIN); + } + if(count = FreeImage_GetMetadataCount(FIMD_EXIF_EXIF, dib)) { + cout << "\nFIMD_EXIF_EXIF (" << count << " data)\n-----------------------------------------\n"; + + PrintMetadata(metadataFile, "Exif - advanced info", dib, FIMD_EXIF_EXIF); + } + if(count = FreeImage_GetMetadataCount(FIMD_EXIF_GPS, dib)) { + cout << "\nFIMD_EXIF_GPS (" << count << " data)\n-----------------------------------------\n"; + + PrintMetadata(metadataFile, "Exif GPS", dib, FIMD_EXIF_GPS); + } + if(count = FreeImage_GetMetadataCount(FIMD_EXIF_INTEROP, dib)) { + cout << "\nFIMD_EXIF_INTEROP (" << count << " data)\n-----------------------------------------\n"; + + PrintMetadata(metadataFile, "Exif interoperability", dib, FIMD_EXIF_INTEROP); + } + if(count = FreeImage_GetMetadataCount(FIMD_EXIF_MAKERNOTE, dib)) { + cout << "\nFIMD_EXIF_MAKERNOTE (" << count << " data)\n-----------------------------------------\n"; + + // Get the camera model + FITAG *tagMake = NULL; + FreeImage_GetMetadata(FIMD_EXIF_MAIN, dib, "Make", &tagMake); + + std::string buffer((char*)FreeImage_GetTagValue(tagMake)); + buffer += " Makernote"; + + PrintMetadata(metadataFile, buffer.c_str(), dib, FIMD_EXIF_MAKERNOTE); + } + if(count = FreeImage_GetMetadataCount(FIMD_IPTC, dib)) { + cout << "\nFIMD_IPTC (" << count << " data)\n-----------------------------------------\n"; + + PrintMetadata(metadataFile, "IPTC/NAA", dib, FIMD_IPTC); + } + if(count = FreeImage_GetMetadataCount(FIMD_GEOTIFF, dib)) { + cout << "\nFIMD_GEOTIFF (" << count << " data)\n-----------------------------------------\n"; + + PrintMetadata(metadataFile, "GEOTIFF", dib, FIMD_GEOTIFF); + } + + // Print the footer + + PrintTableFooter(metadataFile); + PrintHTMLFooter(metadataFile); + + // close the HTML file + + metadataFile.close(); + + // print XMP data + + if(count = FreeImage_GetMetadataCount(FIMD_XMP, dib)) { + cout << "\nFIMD_XMP (" << count << " packet)\n-----------------------------------------\n"; + + std::string xmp_file(strtok(argv[1], ".") + std::string(".xmp")); + metadataFile.open(xmp_file.c_str(), ios::out); + + FITAG *tag = NULL; + FreeImage_GetMetadata(FIMD_XMP, dib, "XMLPacket", &tag); + if(tag) { + metadataFile << (char*)FreeImage_GetTagValue(tag); + } + + metadataFile.close(); + } + + + // Unload the bitmap + + FreeImage_Unload(dib); + + + // call this ONLY when linking with FreeImage as a static library +#ifdef FREEIMAGE_LIB + FreeImage_DeInitialise(); +#endif // FREEIMAGE_LIB + + return 0; +} + + + diff --git a/freeimage241/Examples/Linux/Makefile b/#ThirdParty/FreeImage/Examples/Linux/Makefile similarity index 51% rename from freeimage241/Examples/Linux/Makefile rename to #ThirdParty/FreeImage/Examples/Linux/Makefile index 10282ab..768e784 100644 --- a/freeimage241/Examples/Linux/Makefile +++ b/#ThirdParty/FreeImage/Examples/Linux/Makefile @@ -1,26 +1,24 @@ -include ../../Makefile.cfg - - - -INCLUDE = -I../../Source -VGALIBRARIES = -lfreeimage -lvga -GTKLIBRARIES = -lfreeimage -lgtk -lgdk -GTKINCLUDE = -I/usr/lib/glib/include -CFLAGS = $(COMPILERFLAGS) $(INCLUDE) - - - -all: default - -default: linux-svgalib linux-gtk - -linux-svgalib: linux-svgalib.c - $(CC) $(CFLAGS) $< -o $@ $(VGALIBRARIES) - strip $@ - -linux-gtk: linux-gtk.c - $(CC) $(CFLAGS) $< -o $@ $(GTKLIBRARIES) $(GTKINCLUDE) - strip $@ - -clean: - rm -f core linux-svgalib linux-gtk +CC = gcc +CPP = g++ +COMPILERFLAGS = -O3 +INCLUDE = -I../../Dist +VGALIBRARIES = -lfreeimage -lvga +VGAINCLUDE = -I/usr/include/asm +GTKLIBRARIES = -lfreeimage `pkg-config --libs gtk+-2.0` +GTKINCLUDE = `pkg-config --cflags gtk+-2.0` +CFLAGS = $(COMPILERFLAGS) $(INCLUDE) + +all: default + +default: linux-svgalib linux-gtk + +linux-svgalib: linux-svgalib.c + $(CC) $(CFLAGS) $< -o $@ $(VGALIBRARIES) $(VGAINCLUDE) + strip $@ + +linux-gtk: linux-gtk.c + $(CC) $(CFLAGS) $< -o $@ $(GTKLIBRARIES) $(GTKINCLUDE) + strip $@ + +clean: + rm -f core linux-svgalib linux-gtk diff --git a/freeimage241/Examples/Linux/linux-gtk.c b/#ThirdParty/FreeImage/Examples/Linux/linux-gtk.c similarity index 79% rename from freeimage241/Examples/Linux/linux-gtk.c rename to #ThirdParty/FreeImage/Examples/Linux/linux-gtk.c index 016acc3..e5cf51f 100644 --- a/freeimage241/Examples/Linux/linux-gtk.c +++ b/#ThirdParty/FreeImage/Examples/Linux/linux-gtk.c @@ -1,91 +1,100 @@ -#include -#include "FreeImage.h" - -void destroy(GtkWidget * widget, gpointer data) { - gtk_main_quit(); -} - -int main(int argc, char *argv[]) -{ - GtkWidget *window, *imagebox; - GdkVisual *visual; - GdkImage *image; - FIBITMAP *dib; - int y; - - dib = FreeImage_LoadPNG("freeimage.png",PNG_DEFAULT); - - gtk_init(&argc, &argv); - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - - gtk_signal_connect(GTK_OBJECT(window), "destroy", - GTK_SIGNAL_FUNC(destroy), NULL); - - visual = gdk_visual_get_system(); - - image = gdk_image_new(GDK_IMAGE_NORMAL,visual, - FreeImage_GetWidth(dib),FreeImage_GetHeight(dib)); - - g_print("picture: %d bpp\n" - "system: %d bpp byteorder: %d\n" - " redbits: %d greenbits: %d bluebits: %d\n" - "image: %d bpp %d bytes/pixel\n", - FreeImage_GetBPP(dib), - visual->depth,visual->byte_order, - visual->red_prec,visual->green_prec,visual->blue_prec, - image->depth,image->bpp ); - - if (FreeImage_GetBPP(dib) != (image->bpp << 3)) { - FIBITMAP *ptr; - - switch (image->bpp) { - case 1: - ptr = FreeImage_ConvertTo8Bits(dib); - break; - - case 2: - if (image->depth == 15) { - ptr = FreeImage_ConvertTo16Bits555(dib); - } else { - ptr = FreeImage_ConvertTo16Bits565(dib); - } - - break; - case 3: - ptr = FreeImage_ConvertTo24Bits(dib); - break; - - default: - case 4: - ptr = FreeImage_ConvertTo32Bits(dib); - break; - } - - FreeImage_Free(dib); - dib = ptr; - } - -//makes it upside down :( -// memcpy(image->mem, FreeImage_GetBits(dib), image->bpl * image->height); - - BYTE *ptr = FreeImage_GetBits(dib); - - for (y = 0; y < image->height; y++) { - memcpy(image->mem + (y * image->bpl), - ptr + ((image->height - y - 1) * image->bpl), - image->bpl); - } - - FreeImage_Free(dib); - - imagebox = gtk_image_new(image, NULL); - gtk_container_add(GTK_CONTAINER(window), imagebox); - - gtk_widget_show(imagebox); - gtk_widget_show(window); - - gtk_main(); - - return 0; -} +#include +#include +#include + +void destroy(GtkWidget * widget, gpointer data) { + gtk_main_quit(); +} + +int main(int argc, char *argv[]) +{ + GtkWidget *window, *imagebox; + GdkVisual *visual; + GdkImage *image; + FIBITMAP *dib; + int y; + + // initialize the FreeImage library + FreeImage_Initialise(TRUE); + + dib = FreeImage_Load(FIF_PNG, "freeimage.png", PNG_DEFAULT); + + gtk_init(&argc, &argv); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + + gtk_signal_connect(GTK_OBJECT(window), "destroy", + GTK_SIGNAL_FUNC(destroy), NULL); + + visual = gdk_visual_get_system(); + + image = gdk_image_new(GDK_IMAGE_NORMAL,visual, + FreeImage_GetWidth(dib),FreeImage_GetHeight(dib)); + + g_print("picture: %d bpp\n" + "system: %d bpp byteorder: %d\n" + " redbits: %d greenbits: %d bluebits: %d\n" + "image: %d bpp %d bytes/pixel\n", + FreeImage_GetBPP(dib), + visual->depth,visual->byte_order, + visual->red_prec,visual->green_prec,visual->blue_prec, + image->depth,image->bpp ); + + if (FreeImage_GetBPP(dib) != (image->bpp << 3)) { + FIBITMAP *ptr; + + switch (image->bpp) { + case 1: + ptr = FreeImage_ConvertTo8Bits(dib); + break; + + case 2: + if (image->depth == 15) { + ptr = FreeImage_ConvertTo16Bits555(dib); + } else { + ptr = FreeImage_ConvertTo16Bits565(dib); + } + + break; + case 3: + ptr = FreeImage_ConvertTo24Bits(dib); + break; + + default: + case 4: + ptr = FreeImage_ConvertTo32Bits(dib); + break; + } + + FreeImage_Unload(dib); + dib = ptr; + } + +//makes it upside down :( +// memcpy(image->mem, FreeImage_GetBits(dib), image->bpl * image->height); + + BYTE *ptr = FreeImage_GetBits(dib); + + for (y = 0; y < image->height; y++) { + memcpy(image->mem + (y * image->bpl), + ptr + ((image->height - y - 1) * image->bpl), + image->bpl); + } + + FreeImage_Unload(dib); + + imagebox = gtk_image_new_from_image(image, NULL); + gtk_container_add(GTK_CONTAINER(window), imagebox); + + gtk_widget_show(imagebox); + gtk_widget_show(window); + + gtk_main(); + + // release the FreeImage library + FreeImage_DeInitialise(); + + return 0; +} + + diff --git a/freeimage241/Examples/Linux/linux-svgalib.c b/#ThirdParty/FreeImage/Examples/Linux/linux-svgalib.c similarity index 71% rename from freeimage241/Examples/Linux/linux-svgalib.c rename to #ThirdParty/FreeImage/Examples/Linux/linux-svgalib.c index 820329b..159a238 100644 --- a/freeimage241/Examples/Linux/linux-svgalib.c +++ b/#ThirdParty/FreeImage/Examples/Linux/linux-svgalib.c @@ -1,91 +1,96 @@ -#include -#include "FreeImage.h" - -int main(void) -{ - FIBITMAP *dib,*ptr; - vga_modeinfo *inf; - int length,height,bpp,y; - - dib = FreeImage_LoadPNG("freeimage.png",PNG_DEFAULT); - - vga_init(); - vga_setmode(vga_getdefaultmode()); - - inf = vga_getmodeinfo(vga_getcurrentmode()); - - switch(inf->colors) { - default: - printf("Must be at least 256color mode!\n"); - return; - - case 1 << 8: - bpp = 8; - break; - - case 1 << 15: - bpp = 15; - break; - - case 1 << 16: - bpp = 16; - break; - - case 1 << 24: - if( inf->bytesperpixel == 3 ) { - bpp = 24; - } else { - bpp = 32; - } - break; - } - - if(FreeImage_GetBPP(dib) != bpp) { - switch(bpp) { - case 8: - ptr = FreeImage_ConvertTo8Bits(dib); - break; - - case 15: - ptr = FreeImage_ConvertTo16Bits555(dib); - break; - - case 16: - ptr = FreeImage_ConvertTo16Bits565(dib); - break; - - case 24: - ptr = FreeImage_ConvertTo24Bits(dib); - break; - - default: - case 32: - ptr = FreeImage_ConvertTo32Bits(dib); - break; - } - - FreeImage_Free(dib); - dib = ptr; - } - - length = FreeImage_GetWidth(dib); - if( inf->width < length ) { - length = inf->width; - } - height = FreeImage_GetHeight(dib); - if( inf->height < height ) { - height = inf->height; - } - - for(y = 0; y < height; y++) { - vga_drawscansegment(FreeImage_GetScanLine(dib, y), - 0,y,length); - } - - FreeImage_Free(dib); - - vga_getch(); - vga_setmode(TEXT); - - return 0; -} +#include +#include "FreeImage.h" + +int main(void) +{ + FIBITMAP *dib,*ptr; + vga_modeinfo *inf; + int length,height,bpp,y; + + // initialize the FreeImage library + FreeImage_Initialise(); + + dib = FreeImage_Load(FIF_PNG, "freeimage.png", PNG_DEFAULT); + + vga_init(); + vga_setmode(vga_getdefaultmode()); + + inf = vga_getmodeinfo(vga_getcurrentmode()); + + switch(inf->colors) { + default: + printf("Must be at least 256 color mode!\n"); + return; + + case 1 << 8: + bpp = 8; + break; + + case 1 << 15: + bpp = 15; + break; + + case 1 << 16: + bpp = 16; + break; + + case 1 << 24: + if( inf->bytesperpixel == 3 ) { + bpp = 24; + } else { + bpp = 32; + } + break; + } + + if(FreeImage_GetBPP(dib) != bpp) { + switch(bpp) { + case 8: + ptr = FreeImage_ConvertTo8Bits(dib); + break; + + case 15: + ptr = FreeImage_ConvertTo16Bits555(dib); + break; + + case 16: + ptr = FreeImage_ConvertTo16Bits565(dib); + break; + + case 24: + ptr = FreeImage_ConvertTo24Bits(dib); + break; + + default: + case 32: + ptr = FreeImage_ConvertTo32Bits(dib); + break; + } + + FreeImage_Unload(dib); + dib = ptr; + } + + length = FreeImage_GetWidth(dib); + if( inf->width < length ) { + length = inf->width; + } + height = FreeImage_GetHeight(dib); + if( inf->height < height ) { + height = inf->height; + } + + for(y = 0; y < height; y++) { + vga_drawscansegment(FreeImage_GetScanLine(dib, y), 0, y, length); + } + + FreeImage_Unload(dib); + + vga_getch(); + vga_setmode(TEXT); + + // release the FreeImage library + FreeImage_DeInitialise(); + + return 0; +} diff --git a/#ThirdParty/FreeImage/Examples/OpenGL/TextureManager/TextureManager.cpp b/#ThirdParty/FreeImage/Examples/OpenGL/TextureManager/TextureManager.cpp new file mode 100644 index 0000000..dfc0ed9 --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/OpenGL/TextureManager/TextureManager.cpp @@ -0,0 +1,145 @@ +//********************************************** +//Singleton Texture Manager class +//Written by Ben English +//benjamin.english@oit.edu +// +//For use with OpenGL and the FreeImage library +//********************************************** + +#include "TextureManager.h" + +TextureManager* TextureManager::m_inst(0); + +TextureManager* TextureManager::Inst() +{ + if(!m_inst) + m_inst = new TextureManager(); + + return m_inst; +} + +TextureManager::TextureManager() +{ + // call this ONLY when linking with FreeImage as a static library + #ifdef FREEIMAGE_LIB + FreeImage_Initialise(); + #endif +} + +//these should never be called +//TextureManager::TextureManager(const TextureManager& tm){} +//TextureManager& TextureManager::operator=(const TextureManager& tm){} + +TextureManager::~TextureManager() +{ + // call this ONLY when linking with FreeImage as a static library + #ifdef FREEIMAGE_LIB + FreeImage_DeInitialise(); + #endif + + UnloadAllTextures(); + m_inst = 0; +} + +bool TextureManager::LoadTexture(const char* filename, const unsigned int texID, GLenum image_format, GLint internal_format, GLint level, GLint border) +{ + //image format + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + //pointer to the image, once loaded + FIBITMAP *dib(0); + //pointer to the image data + BYTE* bits(0); + //image width and height + unsigned int width(0), height(0); + //OpenGL's image ID to map to + GLuint gl_texID; + + //check the file signature and deduce its format + fif = FreeImage_GetFileType(filename, 0); + //if still unknown, try to guess the file format from the file extension + if(fif == FIF_UNKNOWN) + fif = FreeImage_GetFIFFromFilename(filename); + //if still unkown, return failure + if(fif == FIF_UNKNOWN) + return false; + + //check that the plugin has reading capabilities and load the file + if(FreeImage_FIFSupportsReading(fif)) + dib = FreeImage_Load(fif, filename); + //if the image failed to load, return failure + if(!dib) + return false; + + //retrieve the image data + bits = FreeImage_GetBits(dib); + //get the image width and height + width = FreeImage_GetWidth(dib); + height = FreeImage_GetHeight(dib); + //if this somehow one of these failed (they shouldn't), return failure + if((bits == 0) || (width == 0) || (height == 0)) + return false; + + //if this texture ID is in use, unload the current texture + if(m_texID.find(texID) != m_texID.end()) + glDeleteTextures(1, &(m_texID[texID])); + + //generate an OpenGL texture ID for this texture + glGenTextures(1, &gl_texID); + //store the texture ID mapping + m_texID[texID] = gl_texID; + //bind to the new texture ID + glBindTexture(GL_TEXTURE_2D, gl_texID); + //store the texture data for OpenGL use + glTexImage2D(GL_TEXTURE_2D, level, internal_format, width, height, + border, image_format, GL_UNSIGNED_BYTE, bits); + + //Free FreeImage's copy of the data + FreeImage_Unload(dib); + + //return success + return true; +} + +bool TextureManager::UnloadTexture(const unsigned int texID) +{ + bool result(true); + //if this texture ID mapped, unload it's texture, and remove it from the map + if(m_texID.find(texID) != m_texID.end()) + { + glDeleteTextures(1, &(m_texID[texID])); + m_texID.erase(texID); + } + //otherwise, unload failed + else + { + result = false; + } + + return result; +} + +bool TextureManager::BindTexture(const unsigned int texID) +{ + bool result(true); + //if this texture ID mapped, bind it's texture as current + if(m_texID.find(texID) != m_texID.end()) + glBindTexture(GL_TEXTURE_2D, m_texID[texID]); + //otherwise, binding failed + else + result = false; + + return result; +} + +void TextureManager::UnloadAllTextures() +{ + //start at the begginning of the texture map + std::map::iterator i = m_texID.begin(); + + //Unload the textures untill the end of the texture map is found + while(i != m_texID.end()) + UnloadTexture(i->first); + + //clear the texture map + m_texID.clear(); +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Examples/OpenGL/TextureManager/TextureManager.h b/#ThirdParty/FreeImage/Examples/OpenGL/TextureManager/TextureManager.h new file mode 100644 index 0000000..0afa4b1 --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/OpenGL/TextureManager/TextureManager.h @@ -0,0 +1,51 @@ +//********************************************** +//Singleton Texture Manager class +//Written by Ben English +//benjamin.english@oit.edu +// +//For use with OpenGL and the FreeImage library +//********************************************** + +#ifndef TextureManager_H +#define TextureManager_H + +#include +#include +#include "FreeImage.h" +#include + +class TextureManager +{ +public: + static TextureManager* Inst(); + virtual ~TextureManager(); + + //load a texture an make it the current texture + //if texID is already in use, it will be unloaded and replaced with this texture + bool LoadTexture(const char* filename, //where to load the file from + const unsigned int texID, //arbitrary id you will reference the texture by + //does not have to be generated with glGenTextures + GLenum image_format = GL_RGB, //format the image is in + GLint internal_format = GL_RGB, //format to store the image in + GLint level = 0, //mipmapping level + GLint border = 0); //border size + + //free the memory for a texture + bool UnloadTexture(const unsigned int texID); + + //set the current texture + bool BindTexture(const unsigned int texID); + + //free all texture memory + void UnloadAllTextures(); + +protected: + TextureManager(); + TextureManager(const TextureManager& tm); + TextureManager& operator=(const TextureManager& tm); + + static TextureManager* m_inst; + std::map m_texID; +}; + +#endif \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Examples/OpenGL/TextureManager/readme.txt b/#ThirdParty/FreeImage/Examples/OpenGL/TextureManager/readme.txt new file mode 100644 index 0000000..7930599 --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/OpenGL/TextureManager/readme.txt @@ -0,0 +1,31 @@ +Hello everyone, this is my 2D texture manager class for OpenGL using the FreeImage Library. + +Requirements: +-------------------- +OpenGL +STL map class +FreeImage (included) + + +Usage +-------------------- +To load a texture, simply call the LoadTexture function: + +TextureManager::Inst()->LoadTexture("img\\bg.jpg", BACKGROUND_IMAGE_ID); + +This also binds the loaded texture as the current texture, so after calling it you may make any calls to glTexParameter you may need to specify the properties of the texture. + +When you are rendering, just call the TextureManager's BindImage function instead of glBindImage: + +TextureManager::Inst()->BindImage(BACKGROUND_IMAGE_ID); + +and then do your rendering as normal. +-------------------- + + +Feel free to distribute this as you like, but mind the FreeImage licence included in license-fi.txt, and please don't take credit for my code. If you modify it, be sure to mention me (Ben English) somewhere. + +Please send any comments or suggestions to me at benjamin.english@oit.edu + + +Thanks to Herve Drolon for the FreeImage library, I've found it to be very useful! \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Examples/Plugin/PluginCradle.cpp b/#ThirdParty/FreeImage/Examples/Plugin/PluginCradle.cpp new file mode 100644 index 0000000..10c363d --- /dev/null +++ b/#ThirdParty/FreeImage/Examples/Plugin/PluginCradle.cpp @@ -0,0 +1,253 @@ +// ========================================================== +// Loader/Saver Plugin Cradle +// +// Design and implementation by +// - Floris van den Berg (flvdberg@wxs.nl) +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include +#include + +#include "FreeImage.h" +#include "Utilities.h" + +// ========================================================== + +BOOL APIENTRY +DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH : + case DLL_PROCESS_DETACH : + case DLL_THREAD_ATTACH : + case DLL_THREAD_DETACH : + break; + } + + return TRUE; +} + +// ========================================================== +// Plugin Interface +// ========================================================== + +static int s_format_id; + +// ========================================================== +// Plugin Implementation +// ========================================================== + +/** + Returns the format string for the plugin. Each plugin, + both internal in the DLL and external in a .fip file, must have + a unique format string to be addressable. +*/ + +static const char * DLL_CALLCONV +Format() { + return "CRADLE"; +} + +/** + Returns a description string for the plugin. Though a + description is not necessary per-se, + it is advised to return an unique string in order to tell the + user what type of bitmaps this plugin will read and/or write. +*/ + +static const char * DLL_CALLCONV +Description() { + return "Here comes the description for your image loader/saver"; +} + +/** + Returns a comma separated list of file extensions indicating + what files this plugin can open. no spaces or whatsoever are allowed. + The list, being used by FreeImage_GetFIFFromFilename, is usually + used as a last resort in finding the type of the bitmap we + are dealing with. Best is to check the first few bytes on + the low-level bits level first and compare them with a known + signature . If this fails, FreeImage_GetFIFFromFilename can be + used. +*/ + +static const char * DLL_CALLCONV +Extension() { + return "ext1,ext2"; +} + +/** + RegExpr is only needed for the Qt wrapper + It allows the Qt mechanism for loading bitmaps to identify the bitmap +*/ +static const char * DLL_CALLCONV +RegExpr() { + return NULL; +} + +/** + Returns a MIME content type string for that format (MIME stands + for Multipurpose Internet Mail Extension). +*/ +static const char * DLL_CALLCONV +MimeType() { + return "image/myformat"; +} + +/** + FreeImage's internal way of seeing if a bitmap is of the desired type. + When the type of a bitmap is to be retrieved, FreeImage runs Validate + for each registered plugin until one returns true. If a plugin doesn't + have a validate function, a return value of false is assumed. + + You can always force to use a particular plugin by directly specifying + it on the command line, but this can result in a dead DLL if the plugin + was not made for the bitmap. +*/ +static BOOL DLL_CALLCONV +Validate(FreeImageIO &io, fi_handle handle) { + return FALSE; +} + +/** + SupportsExportDepth is the first in a possible range of new plugin functions + to ask specific information to that plugin. This function returns TRUE if it + can save a bitmap in the required bitdepth. If it can't the bitmap has to be + converted by the user or another plugin has to be chosen. +*/ +static BOOL DLL_CALLCONV +SupportsExportDepth(int depth) { + return FALSE; +} + +/** + Returns TRUE if the plugin belonging to the given FREE_IMAGE_FORMAT can save a + bitmap in the desired data type, returns FALSE otherwise. Currently, TIFF is the only plugin + able to save all non-standard images. The PNG plugin is able to save unsigned 16-bit + images. +*/ +static BOOL DLL_CALLCONV +SupportsExportType(FREE_IMAGE_TYPE type) { + return (type == FIT_BITMAP) ? TRUE : FALSE; +} + +/** + SupportsICCProfiles informs FreeImage that a plugin supports ICC profiles. + This function returns TRUE if the plugin can load and save a profile. + ICC profile information is accessed via freeimage->get_icc_profile_proc(dib) +*/ +static BOOL DLL_CALLCONV +SupportsICCProfiles() { + return FALSE; +} + + +// ---------------------------------------------------------- + +/** + Loads a bitmap into memory. On entry it is assumed that + the bitmap to be loaded is of the correct type. If the bitmap + is of an incorrect type, the plugin might not gracefully fail but + crash or enter an endless loop. It is also assumed that all + the bitmap data is available at one time. If the bitmap is not complete, + for example because it is being downloaded while loaded, the plugin + might also not gracefully fail. + + The Load function has the following parameters: + + The first parameter (FreeImageIO *io) is a structure providing + function pointers in order to make use of FreeImage's IO redirection. Using + FreeImage's file i/o functions instead of standard ones it is garantueed + that all bitmap types, both current and future ones, can be loaded from + memory, file cabinets, the internet and more. The second parameter (fi_handle handle) + is a companion of FreeImageIO and can be best compared with the standard FILE* type, + in a generalized form. + + The third parameter (int page) indicates wether we will be loading a certain page + in the bitmap or if we will load the default one. This parameter is only used if + the plugin supports multi-paged bitmaps, e.g. cabinet bitmaps that contain a series + of images or pages. If the plugin does support multi-paging, the page parameter + can contain either a number higher or equal to 0 to load a certain page, or -1 to + load the default page. If the plugin does not support multi-paging, + the page parameter is always -1. + + The fourth parameter (int flags) manipulates the load function to load a bitmap + in a certain way. Every plugin has a different flag parameter with different meanings. + + The last parameter (void *data) can contain a special data block used when + the file is read multi-paged. Because not every plugin supports multi-paging + not every plugin will use the data parameter and it will be set to NULL.However, + when the plugin does support multi-paging the parameter contains a pointer to a + block of data allocated by the Open function. +*/ + +static FIBITMAP * DLL_CALLCONV +Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { + return NULL; +} + +static BOOL DLL_CALLCONV +Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { + return FALSE; +} + +// ========================================================== +// Init +// ========================================================== + +/** + Initialises the plugin. The first parameter (Plugin *plugin) + contains a pointer to a pre-allocated Plugin structure + wherein pointers to the available plugin functions + has to be stored. The second parameter (int format_id) is an identification + number that the plugin may use to show plugin specific warning messages + or other information to the user. The plugin number + is generated by FreeImage and can differ everytime the plugin is + initialised. + + If you want to create your own plugin you have to take some + rules into account. Plugin functions have to be compiled + __stdcall using the multithreaded c runtime libraries. Throwing + exceptions in plugin functions is allowed, as long as those exceptions + are being caught inside the same plugin. It is forbidden for a plugin + function to directly call FreeImage functions or to allocate memory + and pass it to the main DLL. Exception to this rule is the special file data + block that may be allocated the Open function. Allocating a FIBITMAP inside a + plugin can be using the function allocate_proc in the FreeImage structure, + which will allocate the memory using the DLL's c runtime library. +*/ + +void DLL_CALLCONV +Init(Plugin *plugin, int format_id) { + s_format_id = format_id; + + plugin->format_proc = Format; + plugin->description_proc = Description; + plugin->extension_proc = Extension; + plugin->regexpr_proc = RegExpr; + plugin->open_proc = NULL; + plugin->close_proc = NULL; + plugin->pagecount_proc = NULL; + plugin->pagecapability_proc = NULL; + plugin->load_proc = Load; + plugin->save_proc = Save; + plugin->validate_proc = Validate; + plugin->mime_proc = MimeType; + plugin->supports_export_bpp_proc = SupportsExportDepth; + plugin->supports_export_type_proc = SupportsExportType; + plugin->supports_icc_profiles_proc = SupportsICCProfiles; +} diff --git a/freeimage241/Examples/Plugin/PluginCradle.h b/#ThirdParty/FreeImage/Examples/Plugin/PluginCradle.h similarity index 93% rename from freeimage241/Examples/Plugin/PluginCradle.h rename to #ThirdParty/FreeImage/Examples/Plugin/PluginCradle.h index ec0b8f6..b049efb 100644 --- a/freeimage241/Examples/Plugin/PluginCradle.h +++ b/#ThirdParty/FreeImage/Examples/Plugin/PluginCradle.h @@ -4,7 +4,7 @@ // Design and implementation by // - Floris van den Berg (flvdberg@wxs.nl) // -// This file is part of FreeImage 2 +// This file is part of FreeImage 3 // // COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES @@ -39,7 +39,7 @@ struct Plugin; // ---------------------------------------------------------- extern "C" { - PLUGIN_API void DLL_CALLCONV Init(Plugin &plugin, int format_id); + PLUGIN_API void DLL_CALLCONV Init(Plugin *plugin, int format_id); } #endif diff --git a/#ThirdParty/FreeImage/README.minGW b/#ThirdParty/FreeImage/README.minGW new file mode 100644 index 0000000..30195c3 --- /dev/null +++ b/#ThirdParty/FreeImage/README.minGW @@ -0,0 +1,236 @@ +===================================================================== +Using the FreeImage library with the MinGW Compiler Suite +===================================================================== + +This file describes how to use the precompiled FreeImage library +FreeImage.dll with the MinGW port of the GNU Compiler Collection +(GCC), how to build this library from source using MinGW and how +to use this MinGW-built library with Microsoft Visual Studio. + +Contents: + +I. Prerequisites + +1. Using the precompiled FreeImage library with MinGW + +2. Building the FreeImage library with MinGW + +3. Using the MinGW FreeImage library with Microsoft Visual Studio + +4. Useful links + + +--------------------------------------------------------------------- +I. Prerequisites +===================================================================== + +The procedures described in this document have been developed and +tested using the following free tools: + +1. MinGW GCC Version 4.4.0 (Core and C++ including required libs) +2. MinGW GNU Binutils Version 2.19.1 +3. MinGW GNU Make Version 3.81-20080326-3 +4. MinGW Runtime Version 3.15.2 +5. MinGW API for MS-Windows Version 3.13 +6. GnuWin32 Package CoreUtils Version 5.3.0 (only for building) +7. GnuWin32 Package Sed Version 4.2 (only for creating the GCC + import library)* + +* Sed is only needed to create a GCC-native import library from + the MSVC import library FreeImage.lib. However, since MinGW now + supports linking against MSVC lib files, this process seems to + be obsolete. See section 1. + +Basically, no version dependent capabilities are used so, this +should also work with older versions of the tools mentioned above. +Similarly, the GnuWin32 packages (which I just prefer over MSYS) +could likely be replaced by a properly installed MSYS environment. + +Furthermore, the following preconditions should be met: + +1. The folders 'bin' under both the MinGW and the GnuWin32 + installation directory should have been added to the PATH + environment variable. Likely it is best adding these + directories permanently to PATH through the System + Properties dialog on the Control Panel. + +2. The MinGW Make package only provides a 'mingw32-make.exe' + executable. There is no alias 'make.exe'. However, make is + preconfigured to use 'make' as the default $(MAKE) command. + This seems to be a bug in the MinGW GNU Make distribution. + Thus, a copy of 'mingw32-make.exe' named 'make.exe' should + be placed into MinGW's 'bin' directory. + + + +--------------------------------------------------------------------- +1. Using the precompiled FreeImage library with MinGW +===================================================================== + +When using functions from C/C++, that reside in a DLL, the linker +needs a so called import library, which specifies, how to +dynamically link these external functions during runtime. However, +different linkers use different types or formats of these import +libraries. + +Since the precompiled FreeImage library was build with Microsoft +Visual Studio, in the past, some extra work was required to use it +from MinGW. An import library, that was compatible with GNU ld, +must have been created first. + +However, for several MinGW versions, the GNU linker ld also +supports linking against Microsoft Visual C++ import libraries +directly. So, this effectively makes any circulating HOWTO's on +how to create a GCC-compatible import library from a MSVC lib file +more or less obsolete. Additionally, MinGW does not require the +GCC/Linux usual lib prefix for libraries, so linking with MinGW +against the precompiled FreeImage DLL is as easy as with MSVC: + +1.) Open a DOS shell (run application cmd.exe) + +2.) Ensure, that the 'bin' folder of MinGW is added to the PATH + environment variable (see Prerequisites). + +3.) Link directly against the supplied lib file: + + C:\>gcc -oFreeImageTest.exe FreeImageTest.c -lFreeImage + +Nonetheless, for the sake of completeness, the following steps +describe how to create a native GCC import library: + +1.) Open a DOS shell (run application cmd.exe) + +2.) Ensure, that the 'bin' folders of both MinGW and GnuWin32 are + added to the PATH environment variable (see Prerequisites). + +3.) Create a .def file 'libfreeimage.def', that contains all symbols + exported by the FreeImage library: + + C:\>pexports FreeImage.dll | sed "s/^_//" > libfreeimage.def + +4.) Create the GCC compatible import library 'libfreeimage.a': + + C:\>dlltool --add-underscore -d libfreeimage.def -l libfreeimage.a + +5.) Use this library to link against with GCC: + + C:\>gcc -oFreeImageTest.exe FreeImageTest.c -lfreeimage + + + +--------------------------------------------------------------------- +2. Building the FreeImage library with MinGW +===================================================================== + +You *do not* need to have any other third party library (like +libjpeg, libpng, libtiff, libmng and zlib and others) installed on +your system in order to compile and use the library. FreeImage uses +its own versions of these libraries. This way, you can be sure that +FreeImage will always use the latest and properly tested versions +of of these third party libraries. + +In order to build the FreeImage library under Windows with MinGW +(GCC), ensure that all the prerequisites mentioned above are met. +The MinGW makefile aims to build a Windows DLL, that differs as +least as possible from the precompiled library that comes with the +FreeImage distribution. Thus, the build process also includes the +DLL version resource as well as the __stdcall attribute for all the +exported functions, including the MSVC-like function decorations +_FuncName@nn. + +When building the FreeImage DLL, of course, an import library is +generated, too. However, this input library is not in GCC's native +format, but in MSVC lib format, which makes it usable from both +MinGW and Microsoft Visual Studio with no further processing. + +The MinGW makefile can also be used to build a static library. +However, due to the different function export attributes needed +for both the dynamic and the shared library (DLL), this requires +a separate invocation of make, which in turn needs to rebuild every +source file after switching from dynamic to static and vice versa. +So, a 'make clean' is required each time, the library type is +changed. + +The type of library to build is specified by a variable named +FREEIMAGE_LIBRARY_TYPE, which may either be set directly in the +Makefile.mingw near line 18 or may be specified as an environment +variable. This variable may either take SHARED or STATIC to build +a dynamic link library (DLL) or a static library respectively. +Since this value is used to dynamically form the actual make target +internally, only uppercase values are valid. Defaults to SHARED. + +The MinGW makefile also supports the 'install' target. However, +this only copies the FreeImage dynamic link library (DLL) from the +Dist folder into the %SystemRoot%\system32 folder. So, invoking this +target only makes sense, if the DLL has been built before. + +Since there is neither a common system wide 'include' nor a 'lib' +directory available under Windows, the FreeImage header file +FreeImage.h as well as both the static library and the DLL import +library FreeImage.lib just remain in the 'Dist' folder. + +The following procedure creates the FreeImage dynamic link library +(DLL) from the sources, installs it and also creates a static +FreeImage library: + +1.) Open a DOS shell (run application cmd.exe) + +2.) Ensure, that the 'bin' folders of both MinGW and GnuWin32 are + added to the PATH environment variable (see Prerequisites). + +3.) Create the FreeImage dynamic link library (DLL): + + C:\>make + +4.) Install the FreeImage dynamic link library (DLL): + + C:\>make install + +5.) Clean all files produced by the recent build process: + + C:\>make clean + +6.) Create a static FreeImage library: + + C:\>set FREEIMAGE_LIBRARY_TYPE=STATIC + C:\>make + +You should be able to link progams with the -lFreeImage option +after the shared library is compiled and installed. You can also +link statically against FreeImage.a from MinGW. + + + +--------------------------------------------------------------------- +3. Using the MinGW FreeImage library with Microsoft Visual Studio +===================================================================== + +Since the MinGW makefile creates an import library in MSVC's lib +format, the produced shared library (DLL) can be used from both +MinGW and Microsoft Visual Studio with no further adaption. Just +link to the import library FreeImage.lib from either MinGW or +Microsoft Visual Studio. + + + +--------------------------------------------------------------------- +4. Useful links +===================================================================== + +- The MinGW homepage: + http://www.mingw.org/ + +- The GnuWin32 homepage: + http://gnuwin32.sourceforge.net/ + +- The GCC homepage and online documentation: + http://gcc.gnu.org/ + http://gcc.gnu.org/onlinedocs/ + +- The GNU Binutils homepage and online documentation: + http://www.gnu.org/software/binutils/ + http://sourceware.org/binutils/docs-2.19/ + +- The GNU Make homepage and online documentation: + http://www.gnu.org/software/make/ + http://www.gnu.org/software/make/manual/make.html diff --git a/#ThirdParty/FreeImage/Whatsnew.txt b/#ThirdParty/FreeImage/Whatsnew.txt new file mode 100644 index 0000000..6e19915 --- /dev/null +++ b/#ThirdParty/FreeImage/Whatsnew.txt @@ -0,0 +1,1258 @@ +What's New for FreeImage + +* : fixed +- : removed +! : changed ++ : added + +Month day, 2015 - 3.17.0 +! FreeImage now uses LibPNG 1.6.16 +! FreeImage now uses LibWebP 0.4.2 (GIT patch 2015-03-03) +! FreeImage now uses LibRaw 0.17-Alpha1 +! FreeImage now uses LibTIFF 4.0.4 (CVS patch 2015-01-26) +! FreeImage now uses OpenEXR 2.2.0 +- [Herve Drolon] removed VS 2003 project files : this IDE is no longer supported because of its outdated C++ compiler ++ [Mihail Naydenov] added FreeImage_ConvertFromRawBitsEx ++ [Herve Drolon] added RAW_UNPROCESSED load flag to the RAW plugin ++ [Herve Drolon] added FreeImage_SetMetadataKeyValue ++ [Herve Drolon] added support for metadata writing to the JPEG-JXR plugin ++ [Herve Drolon] added VS 2013 project files ++ [Herve Drolon] added support for PNG tIME metadata (read/write, handle as Exif-TIFF DateTime) ++ [Carsten Klein] added explicit definition of endianness and color order in compiler options ++ [Carsten Klein] added FIQ_LFPQUANT quantizer algorithm ++ [Carsten Klein] added support for input 32-bit dib in Wu quantizer ++ [Tanner Helland] added FreeImage_ConvertToRGBAF and updated conversions in FreeImage_ConvertToType ++ [Herve Drolon] added FreeImage_ConvertToRGBA16 and updated conversions in FreeImage_ConvertToType ++ [Carsten Klein] added FreeImage_CreateView ++ [Carsten Klein] added FreeImage_RescaleRect ++ [Carsten Klein] added FreeImage_GetMemorySize +* [Tanner Helland] ICO plugin: improved support for Vista icons +* [fpgaminer] fixed a rounding error in RGB to greyscale conversion formula +* [Sven-Hendrik Haase] fixed Makefile.fip so that it installs symlinks +* [Joachim Reichel] fixed a potential memory access violation in PluginHDR Save function +* [Christian Schluchter] fixed a bug in FreeImage_LookupSVGColor ("green" color was not found) +* [Marco Altomonte] fixed TARGA signature validation for TARGA versions < 2.0 +* [Jeremy Reyniers] fixed FreeImage_GetScanLine not working with very large images on x64 platforms +* [Herve Drolon] improved PluginTIFF compatibility with LibTIFF 4 +* [Aaron Shumate] fixed a segfault occuring on a corrupted animated GIF +* [Herve Drolon] improved memory allocation in PluginRAW +* [Herve Drolon] fixed loading/saving of TIFF containing a GPS IFD inside the Exif-TIFF metadata segment (the solution is to ignore the tag) +* [Mihail Naydenov] fixed a bug in FreeImage_JPEGCrop*/_JPEGTransform* functions occuring when using the same source / destination filename +* [Herve Drolon] fixed a bug with output image quality in PluginJP2::Save & PluginJ2K::Save functions (regression from FI 3.15.4) +* [Herve Drolon] improved RAW file format detection +* [Aaron Shumate] fixed FreeImage_GetFileType behavior with ANI file formats +* [Herve Drolon] improved Exif reader so as to handle Exif IFD with a suspicious offset (can occur with maker notes) +* [Herve Drolon] fixed a memory leak in PluginPNG:Save occuring when dealing with invalid PNG files +* [Tanner Helland] fixed PNG plugin handling of 16-bit grayscale + 16-bit alpha images +* [Tanner Helland] fixed PNG plugin handling of 16-bit grayscale + tRNS chunk images +* [Tanner Helland] fixed PNG plugin handling of 24-bit RGB + tRNS chunk images +* [Tanner Helland] fixed PNG plugin handling of 1-,4-bit greyscale/palettized + tRNS chunk images +* [ekpyron] fixed invalid directory delimiter in include statement (mingw-w64) in Source/LibJXR/image/sys/strcodec.h +* [ekpyron] fixed Invalid condition for defining _byteswap_ulong (mingw-w64) in Source/LibJXR/image/sys/strcodec.c +* [tostercx] fixed FreeImage_Get*Mask not returning 0 for greyscale images +* [robpats] fixed loading of external plugins when using UNICODE directory names to store plugins +* [Herve Drolon] fixed loading of JXR files when using memory streams +* [Carsten Klein] added Dist/ directory creation in Makefiles (in case it is not already present) + +March 23rd, 2014 - 3.16.0 +! FreeImage now uses LibJPEG 9a +! FreeImage now uses LibPNG 1.6.10 +! FreeImage now uses LibTIFF 4.0.3 (CVS patch 2013-11-30) +! FreeImage now uses LibRaw 0.16.0 +! FreeImage now uses OpenJPEG 2.1.0 (SVN patch 2748) +! FreeImage now uses ZLib 1.2.8 +! FreeImage now uses LibWebP 0.4.0 (GIT patch 2014-03-21) +! FreeImage now uses LibJXR 1.1 (GIT patch 2014-01-31) ++ [Herve Drolon] added loading & writing support for the JPEG-XR image format (also support the FIF_LOAD_NOPIXELS flag) ++ [Herve Drolon] added loading & writing support for the WebP image format (also support the FIF_LOAD_NOPIXELS flag) ++ [Herve Drolon] added support for FIF_LOAD_NOPIXELS flag to JP2/J2K plugins ++ [Gaël Zimmermann] added basic support for BMP v4, v5 in BMP plugin (useful for drag and drop from another application such as Firefox) ++ [Mihail Naydenov] FreeImage_GetFIFFromFilename[U] : added support for *rgb,*rgba,*.bw extensions to the SGI plugin ++ [Mihail Naydenov] improved FreeImage_Rescale speed & spatial accuracy ++ [Mihail Naydenov] improved JPEG transform functions and added new functions (see below) : + added FreeImage_JPEGTransformFromHandle + added FreeImage_JPEGTransformCombined + added FreeImage_JPEGTransformCombinedU + added FreeImage_JPEGTransformCombinedFromMemory +* [Herve Drolon] fixed FreeImage_CloneTag behavior with ASCII data handling (regression that appeared in 3.15.2, affect metadata writing) +* [Carsten Klein] ICO plugin: avoid using the AND mask when loading a 32-bit (already transparent) icon +* [Andreas Baumann] HDR plugin: removed a comma at end of an enumerator list +* [mark] added missing in OpenEXR (needed with mingw) +* [Herve Drolon] added support for FIC_MINISWHITE color type inside FreeImage_GetColorType for FIT_UINT16 images +* [Takamasa Mitsuji] FreeImage_Rescale : fixed a NULL-pointer access bug occurring for transparent images with a linear palette +* [Herve Drolon] fixed PSD parser when reading PSD files with corrupted resources +* [Herve Drolon] fixed TIFF plugin truncating metadata tag on loading if type is ASCII and it's value is of variable size (TIFF_VARIABLE) +* [Herve Drolon] fixed loading of TGA 8-bit files with a palette size greater that 256 +* [Anton Kukoba] TIFF parser didn't initialize the memory with zeros in stripped mode. This caused random bitmap data if the tiff file was corrupted/invalid. +* [Herve Drolon] improved TGA file detection when the format version is < 2.0 +* [Christian Heimes] fixed compiler errors on 64bit Linux (INT64 / UINT64 type mismatches and missing prototype for memset) +* [Christian Heimes] fixed FreeImage_Get*Mask() returning 0 on 24-, -32-bit FIT_BITMAP images +* [Mihail Naydenov] fixed GIF plugin LZW decoder failing on some images +* [Herve Drolon] fixed the TIFF plugin against race condition when used simultaneously in multiple threads +* [Herve Drolon] fixed float <--> rgb[a]f conversions when pixels are out of [0..1] range + +October 27th, 2012 - 3.15.4 +! FreeImage now uses LibPNG 1.5.13 +! FreeImage now uses LibRaw 0.14.7 +! FreeImage now uses ZLib 1.2.7 +! FreeImage now uses LibTIFF 4.0.3 +! FreeImage now uses OpenJPEG 1.5.1 +! FreeImage now uses OpenEXR 1.7.1 ++ [Herve Drolon] improved the speed of RAW files detection in FreeImage_GetFileType* functions ++ [Herve Drolon] added JPEG_GREYSCALE load flag to the JPEG plugin (force to load as 8-bit greyscale) ++ [Herve Drolon] added 64-bit RGBA to 24-bit conversion support in FreeImage_ConvertTo24Bits ++ [Carsten Klein] improved the speed of FreeImage_Rescale for FIT_BITMAP & UINT16, RGB[A]16 types ++ [Carsten Klein] improved the speed of FreeImage_ConvertToGreyscale +* [Carsten Klein] updated makefile for building FreeImage with MinGW +* [Herve Drolon] fixed BigTIFF signature validation in FreeImage_GetFileType* functions +* [Carsten Klein] fixed handling of RGB-565 16-bit images (needed for conversion from HBITMAP to FIBITMAP) +* [Herve Drolon] fixed loading of JPEG with invalid IPTC marker +* [Herve Drolon] changed default TIF RowsPerStrips to image height when saving as TIF G3 or TIF G4 (improved compression) +* [Herve Drolon] improved the memory behavior of the RAW plugin (do not allocate huge variables on the stack) +* [Herve Drolon] fixed FreeImage_AllocateT so that it returns NULL with images with a zero width and/or height +* [Herve Drolon] replaced FIUINT64/FIINT64 with standard types UINT64/INT64 +* [Rustam Abdullaev] fixed PNG plugin with saving of transparent monochrome images +* [Floris van den Berg] improved plugin registering when replacing an existing internal plugin with a new equivalent plugin +* [Herve Drolon] fixed a crash when calling FreeImage_GetColorType on a 32-bit RGBA images loaded with the FIF_LOAD_NOPIXELS flag +* [Herve Drolon] fixed FreeImage_SetTransparencyTable falsely setting a dib to 'transparent' when called with a count of 0 +* [Carsten Klein] fixed storing of RGB masks for 16-bit RGB standard images in order to be in a MSDN compatible way +* [Herve Drolon] added an error handling message inside HDR plugin when trying to save an unsupported format +* [Corey Taylor] fixed DDS plugin color channel swapping for RGB color order, when using FREEIMAGE_COLORORDER_RGB color order +* [Herve Drolon] fixed internal TagLib singleton initialization against double-checked locking so that it is multi-thread safe + +March 17th, 2012 - 3.15.3 +! FreeImage now uses LibPNG 1.5.9 +! FreeImage now uses LibTIFF 4.0.1 ++ [Herve Drolon] added new 64-bit data types FIINT64, FIUINT64 ++ [Herve Drolon] added new 64-bit metadata types to FREE_IMAGE_MDTYPE (FIDT_LONG8, FIDT_SLONG8, FIDT_IFD8) ++ [Herve Drolon] added support for 64-bit metadata types to FreeImage_TagToString +* [Herve Drolon] fixed a regression with Fax3/Fax4 TIFF images on 64-bit OS (introduced with FI 3.15.2) +* [Herve Drolon] fixed some gcc 4.4.6 warnings +* [Petr Pytelka] refactored FreeImage_InsertPage and FreeImage_AppendPage +* [Herve Drolon] fixed JP2/J2K plugins with saving of 32-bit dib with a fully opaque layer +* [Herve Drolon] fixed loading of CMYK JPEG when using JPEG_CMYK load flag (need to invert pixels) +* [Herve Drolon] fixed loading of CMYK PSD when using PSD_CMYK load flag + +February 20th, 2012 - 3.15.2 +! FreeImage now uses LibRaw 0.14.5 +! FreeImage now uses LibPNG 1.5.8 +! FreeImage now uses LibJPEG 8d +! FreeImage now uses ZLib 1.2.6 +! FreeImage now uses OpenJPEG 1.5.0 (released version) +! FreeImage now uses LibTIFF 4.0.0 +- [Herve Drolon] removed dependency on LibMNG 1.0.10 (MNG and JNG files are now handled internally) ++ [Herve Drolon] replaced the MNG plugin with a new MNG internal FreeImage plugin (with read support) ++ [Herve Drolon] added a new JNG internal FreeImage plugin (with read/write support) ++ [Christian Heimes] added write support to the TIFF plugin for EXIF_MAIN tags ++ [Herve Drolon] added new Exif maker note tags ++ [Herve Drolon] added TAG_COMPRESSION conversion to FreeImage_TagToString +* [Mylek Grey] enabled the use of multi-component transforms (MCT) in J2K and JP2 saving +* [Herve Drolon] refactored PluginICO in order to correctly support Windows Vista 256x256 icons +* [Herve Drolon] added minor speed improvements to FreeImage_Rescale +* [Herve Drolon] fixed dib allocation failing with very large images (i.e. more than 4GB) +* [Herve Drolon] fixed FreeImage_CloneTag behavior with ASCII data handling +* [Herve Drolon] improved JPEG plugin behavior with very big images +* [Herve Drolon] improved JPEG plugin behavior with C++ exceptions +* [Herve Drolon] fixed loading of palettized PNG with more that 256 palette entries +* [Herve Drolon] fixed a bug inside IFF plugin occuring when loading a 24-bit dib with a palette +* [Herve Drolon] fixed a bug with loading of PNG images containing a cHRM chunk (regression introduced by LibPNG 1.5.4 and fixed by LibPNG 1.5.5) +* [Herve Drolon] allowed loading of PNG with benign errors (such as images with too many IDATs) +* [Mihail Naydenov] fixed some incorrect MIME types returned by FreeImage_GetFIFMimeType +* [Herve Drolon] fixed loading of Exif with bad thumbnail data or with a bad first offset size + +July 25th, 2011 - 3.15.1 +! FreeImage now uses LibRaw 0.13.7 +! FreeImage now uses LibPNG 1.5.4 +! FreeImage now uses LibTIFF 3.9.5 +! FreeImage now uses OpenJPEG 1.5.0 (SVN patch 2011-07-23) ++ [Herve Drolon] added FreeImage_ConvertToRGB16 and updated FreeImage_ConvertToType ++ [Herve Drolon] added RAW_HALFSIZE flag to RAW plugin +* [Herve Drolon] fixed a memory leak in JPEG plugin occuring when loading some corrupted images +* [Eberhard Mattes] improved thread safety behavior inside internal TagLib class +* [Hew How Chee] fixed a bug in FreeImage_EnlargeCanvas when called with negative left and right parameters and bpp <= 4 +* [Herve Drolon] improved memory allocation checking in FreeImage_ConvertTo[Float/RGBF/UINT16] +* [Herve Drolon] allowed loading of TIF with missing bitspersample/samplesperpixel/photometric tags +* [Herve Drolon] fixed FreeImage_AllocateHeaderT against possible malloc overflow +* [Herve Drolon] fixed CUT plugin against heap corruption vulnerability +* [Herve Drolon] fixed BMP plugin for images with a truncated input data stream +* [Herve Drolon] improved PCX format detection in FreeImage_GetFileType* functions +* [Christian Heimes] fixed a TIFF G4 compression bug occuring with gcc-Version 4.1.2 20080704 (Red Hat 4.1.2-50) + +January 24th, 2011 - 3.15.0 +! FreeImage now uses LibRaw 0.13-Beta3 +! FreeImage now uses LibPNG 1.4.5 +! FreeImage now uses LibTIFF 3.9.4 (CVS patch 2011-01-03) +! FreeImage now uses LibJPEG 8c +! FreeImage now uses OpenJPEG 1.4.0 (SVN patch 2011-01-18) +! [Herve Drolon] FreeImage_CloneMetadata now clone resolution info returned by FreeImage_GetDotsPerMeter(X / Y) ++ [Herve Drolon] added loading support for "half float" format to TIF plugin ++ [Herve Drolon] FreeImage_IsTransparent is now independant of FREE_IMAGE_TYPE ++ [Herve Drolon] added FIT_UINT16 to FIT_RGBF conversion to FreeImage_ConvertToRGBF & FreeImage_ConvertToType ++ [Herve Drolon] added FreeImage_ConvertToUINT16 and updated FreeImage_ConvertToType ++ [Mihail Naydenov] added FreeImage_GetThumbnail / FreeImage_SetThumbnail ++ [Mihail Naydenov] added thumbnail support to Exif, JPEG, EXR, PSD, TGA, TIF formats ++ [Mihail Naydenov] added JPEG_BASELINE save flag to the JPEG plugin ++ [Herve Drolon] added new Exif-TIFF tags (PageName, PageNumber, XPosition, YPosition) and Exif WinXP tags ++ [Herve Drolon] added support for 256x256 icon size to PluginICO:Save +* [Domingo Stephan] fixed a compilation error in TARGA plugin when using a big endian OS (OS X 10.6) +* [Christian Heimes] fixed a compilation error with gcc 4.3.x and OpenEXR +* [Eric Fruhinsholz] fixed a crash in JPEG plugin when reading a JPEG with corrupted XMP data +* [Herve Drolon] improved FreeImage_MultigridPoissonSolver for images whose size is a power-of-two +* [Herve Drolon] fixed a crash in PSD plugin when loading a PSD with a CMYK embedded thumbnail +* [Herve Drolon] fixed loading of JPEG images with a not null but zero length IPTC segment (bad files produced by Picasa) +* [Carsten Klein] fixed a bug in FreeImage_ColorQuantizeEx when using FIQ_WUQUANT quantizer +* [Herve Drolon] added support for RGBA[16][F] to FreeImage_IsTransparent +* [Herve Drolon] fixed loading of resolution info in TIFF CMYK images (bug introduced with 3.14.0) +* [Tom May] fixed JPEG plugin crashing on some Exif files containing tags with an invalid tag length +* [Herve Drolon] fixed a crash when loading TIFF images with a TIFFTAG_TRANSFERFUNCTION Exif tag +* [Tom May] removed assertions in PSD plugin, causing crashes on some malformed images in debug mode +* [Mihail Naydenov] fixed a crash in TIFF plugin when reading an uncommon 24-bit palettized file +* [Carsten Klein] fixed a bug in FreeImage_EnlargeCanvas when using the function as a FreeImage_Copy function +* [Herve Drolon] fixed a bug in PluginBMP with loading of OS/2 2.x palettized BMP +* [luispedro] fixed a bug in PluginBMP when reading malformed 16-bit RGB-555 BMP + +August 12th, 2010 - 3.14.1 ++ [Mihail Naydenov] added support for FIF_LOAD_NOPIXELS flag to EXR plugin ++ [Herve Drolon] added support for FIF_LOAD_NOPIXELS flag to CUT, HDR, RAS, ICO, PNM, RAW, BMP, PFM, XPM plugins +* [Eberhard Mattes] fixed memory allocation checking in multipage API +* [Herve Drolon] (compiler options) removed Win32 OpenMP support introduced in 3.14.0 + +August 9th, 2010 - 3.14.0 +! FreeImage now uses OpenEXR 1.7.0 +! FreeImage now uses ZLib 1.2.5 +! FreeImage now uses LibPNG 1.4.3 +! FreeImage now uses LibJPEG 8b +! FreeImage now uses LibTIFF 3.9.4 (CVS patch 2010-07-13) +! FreeImage now uses LibRaw 0.10-Beta3 +! FreeImage now uses OpenJPEG 1.4.0 (SVN patch 2010-04-16) +! [Herve Drolon] FreeImage_AllocateT now builds a default greyscale palette for 8-bit images +! [Volodymyr Goncharov] FreeImage_LoadMultiBitmapFromMemory now supports read/write operations +! [Herve Drolon] FreeImage_OpenMultiBitmapFromHandle now supports read/write operations +! [Herve Drolon] greyscale conversions now use the Rec. 709 formula +! [Mihail Naydenov] saving RGBF images to TIFF no longer use LogLuv encoding (unless you use the TIFF_LOGLUV save flag) ++ [Herve Drolon] added FIT_FLOAT to FIT_RGBF conversion to FreeImage_ConvertToRGBF & FreeImage_ConvertToType ++ [Herve Drolon] added VS 2008 project files ++ [Herve Drolon] added FreeImage_ConvertToFloat ++ [Mihail Naydenov] added RLE saving to the Targa plugin (see flag TARGA_SAVE_RLE) ++ [Volodymyr Goncharov] added FreeImage_SaveMultiBitmapToHandle ++ [Herve Drolon] added FreeImage_SaveMultiBitmapToMemory ++ [Herve Drolon] added new Exif maker note tags ++ [Lucian Sabo] added JPEG_OPTIMIZE to PluginJPEG:Save ++ [Mihail Naydenov] improved support for Exif tag reading in TIFF plugin ++ [Mihail Naydenov] allowed dataWindow with minimal bounds different from zero in OpenEXR plugin ++ [Herve Drolon] added FIMD_EXIF_RAW metadata model ++ [Herve Drolon] JPEG plugin can load & save raw Exif data (see FIMD_EXIF_RAW) ++ [Herve Drolon] added FIF_LOAD_NOPIXELS load flag constant - used to load header & metadata only ++ [Herve Drolon] added FreeImage_HasPixels ++ [Herve Drolon] added FreeImage_FIFSupportsNoPixels ++ [Herve Drolon] added support for FIF_LOAD_NOPIXELS flag to JPEG, PNG, PCD, PCX plugins ++ [Mihail Naydenov] added support for FIF_LOAD_NOPIXELS flag to TGA, PSD, TIFF plugins ++ [Mihail Naydenov] added support for 16-bit image types to FreeImage_Invert ++ [Mihail Naydenov] improved PSD plugin (faster code, added support for CMYK and LAB loading) + added load flags PSD_CMYK & PSD_LAB ++ [Mihail Naydenov] improved TIFF plugin (CMYK 16-bit loading and saving / RGBAF saving) + added TIFF_LOGLUV save flag +* [Herve Drolon] fixed FreeImage_GetFileType behavior with ANI file formats +* [Herve Drolon] fixed loading of JNG with progressive-JPEG formats +* [Mihail Naydenov] fixed loading of TGA with a corrupted rle count +* [Herve Drolon] fixed conversion formula in FreeImage_PreMultiplyWithAlpha +* [Christoph Brill] removed the use of libmng_data.h private API in MNG Plugin +* [phe02sf] fixed handling of bad Exif-GPS data in a Nikon D5000 image +* [Atsuhiro Igarashi] fixed handling of last data block in PluginGIF::Save (sometimes it saves corrupted images) +* [Christian Heimes] fixed saving of G3 & G4 compressed TIFF with 1bpp on 64bit Linux +* [Herve Drolon] fixed long data type being 64-bit on Unix/Linux platforms (use LONG/DWORD instead of long/unsigned long) +* [Herve Drolon] fixed a memory leak in FreeImage_DeletePage +* [Herve Drolon] fixed the loading of RGBZ images in OpenEXR plugin +* [Lucian Sabo] improved conversion from 1-, 4-, 8-bpp transparent images to 32-bpp +* [Roy F.] fixed a bug in FreeImage_EnlargeCanvas (unable to crop an image on the right) +* [Herve Drolon] fixed the loading of Exif with unusual IFD offset value +* [Eberhard Mattes] fixed page numbering info when saving multipage TIFF +* [Herve Drolon] fixed PluginPICT causing an infinite loop on a malformed PICT image +* [Eberhard Mattes] improved memory allocation checking when using the new operator +* [Herve Drolon] (multipage internals) fixed a potential buffer overflow in ReplaceExtension +* [Eberhard Mattes] improved error checking in FreeImage_CloseMultiBitmap + +December 22, 2009 - 3.13.1 +! FreeImage now uses libTIFF 3.9.2 +! FreeImage now uses OpenJPEG 1.3.0 (SVN patch 2009-11-05) +! FreeImage now uses libPNG 1.2.41 ++ [Berend Engelbrecht] added loading of Exif orientation tag in TIFF plugin ++ [Herve Drolon] added decoding support for the old and outdated JPEG-in-TIFF 6.0 format in TIFF plugin ++ [Herve Drolon] added new 'non standard' Exif tags ++ [Herve Drolon] added new Exif makernote tags +* [Herve Drolon] fixed TIF plugin crashing on a malformed TIFF-JPEG compressed image +* [Herve Drolon] fixed MNG plugin crashing on some old mng images +* [Herve Drolon] fixed handling of 2-bit grayscale transparent PNG +* [Herve Drolon] fixed a bug with the compression rate of JP2 and J2K encoders +* [zestony] fixed TIF plugin with the '65535 bytes' pitch size limitation on saving +* [Herve Drolon] fixed handling of PSD files with a non zero file header reserved member +* [Lucian Sabo] PNG plugin now keep transparency when saving 1- or 4-bit transparent images + +September 28th, 2009 - 3.13.0 +! FreeImage now uses LibJPEG 7 +! FreeImage now uses LibRaw-Lite 0.7.2 +! FreeImage now uses libPNG 1.2.40 +! FreeImage now uses libTIFF 3.9.1 +! FreeImage_RotateClassic is deprecated (use FreeImage_Rotate instead) ++ [Herve Drolon] added support for all Photoshop supported color modes to PSD plugin ++ [Herve Drolon] added support for 32-bit to JNG/MNG plugin ++ [Amir Ebrahimi] added loading support for the PICT format ++ [Herve Drolon] added loading support for camera RAW formats (using LibRawLite wrapper for dcraw) ++ [Mihail Naydenov] added UNICODE functions FreeImage_JPEGTransformU and FreeImage_JPEGCropU ++ [Carsten Klein] added FreeImage_OpenMultiBitmapFromHandle ++ [Carsten Klein] added FreeImage_FillBackground ++ [Carsten Klein] added FreeImage_EnlargeCanvas ++ [Carsten Klein] added FreeImage_AllocateEx / FreeImage_AllocateExT ++ [Mihail Naydenov/Herve Drolon] added FreeImage_TmoReinhard05Ex ++ [Herve Drolon] added FIT_RGBA16 to FIT_RGBF conversion to FreeImage_ConvertToRGBF ++ [Herve Drolon] added FreeImage_Rotate (support for most image types, support background color) +* [Christian Heimes] fixed function prototypes to use a void argument when no argument exist +* [Herve Drolon] fixed RGB color ordering on Intel macs +* [Herve Drolon] FreeImage_RotateClassic now keep transparency when applied to 8-bit images +* [Herve Drolon] fixed handling of transparency info in FreeImage_Copy +* [Herve Drolon] fixed a normalization error in FreeImage_GetAdjustColorsLookupTable +* [Herve Drolon] fixed invalid Exif rotation in PluginJPEG for orientation cases 2 and 4 +* [Mihail Naydenov / Carsten Klein] fixed compilation issues with MinGW32 +* [Mihail Naydenov] improved the loading speed of all targa images +* [Herve Drolon] FreeImage_TagToString now handles the Exif UserComment tag + +April 14th, 2009 - 3.12.0 +! FreeImage now uses libPNG 1.2.35 +! FreeImage now uses libTIFF 3.9.0beta (CVS patch 2009-02-12) +! FreeImage now uses OpenJPEG 1.3.0 (SVN patch 2008-08-21) +! [Herve Drolon] FreeImage_CloneMetadata no longer clone the FIMD_ANIMATION metadata (this was causing problems when saving to GIF format) ++ [Herve Drolon] added full support for the PFM format ++ [Herve Drolon] added JPEG_EXIFROTATE load flag to the JPEG plugin ++ [Herve Drolon] added 16-bit RGB(A) and float RGB(A)F support to FreeImage_GetChannel / FreeImage_SetChannel ++ [Herve Drolon] added src FIT_RGBA16 to dst 32-bit FIT_BITMAP conversion to FreeImage_ConvertToType +* [Carsten Klein] FreeImage_Copy now copies transparency info, resolution info, ICC profile and metadata +* [Carsten Klein] check for negative top/left values in FreeImage_Paste +* [Christian Heimes] changed exceptions with a "catch(char *text)" to a "catch(const char *text)" to make GCC 4.1 happy +* [Deif Lou] fixed a bug in FreeImage_SetTransparentIndex +* [Thomas Maiwald] BMP plugin: on saving, fixed correct setting of bfSize BMP file header for palettized images +* [Timothy Lee] fixed handling of frame disposal in GIF_PLAYBACK mode (GIF plugin) +* [Herve Drolon] fixed handling of Exif Olympus Type 2 maker notes (not yet supported but now safely ignored) +* [Rich Geldreich] fixed DXT1 color endpoint precision problem in DDS plugin +* [Mihail Naydenov] improved loading speed of 24-bit targa images +* [Eugene Golushkov] improved big endian / little endian swapping functions +* [Carsten Klein/Jean-Philippe Goerke] improved FreeImage_SetMetadata / FreeImage_GetMetadata accessors +* [Christian Ruppert] improved Linux Makefiles +* [Eugene Golushkov] fixed PluginBMP alignment bug while saving 16 or 24bit BMP on big endian or Apple machines + +July 28th, 2008 - 3.11.0 +! FreeImage now uses libTIFF 3.9.0beta (CVS patch 2008-05-24) +! FreeImage now uses OpenJPEG 1.3.0 (SVN patch 2008-05-22) +! FreeImage now uses libMNG 1.0.10 +! FreeImage now uses libPNG 1.2.29 ++ [Yves Schmid] added 48-bit RGB to 32-bit conversion support in FreeImage_ConvertTo32Bits ++ [Aaron Shumate] added RGB16-to-BITMAP and All-to-RGBF conversion support in FreeImage_ConvertToType ++ [Benjamin English] added a new OpenGL sample to FreeImage/Examples ++ [Lucian Sabo] added new compression flags to the PNG plugin ++ [Lucian Sabo] added new compression flags to the JPEG plugin (chroma subsampling options) ++ [Noam Gat] added support for SGI grayscale + alpha pics to SGI plugin ++ [Herve Drolon] added FreeImage_CloneMetadata ++ [Herve Drolon] added loading support for Windows Vista icons in ICO Plugin ++ [Herve Drolon] added loading and saving support for RGBF images to the TIF plugin (using the LogLuv codec) +* [Will Bryant] fixed makefile for MacOSX Tiger and Leopard +* [Maria Gullickson] fixed a 'divide by 0' error in PNM plugin and FreeImage_Rescale function +* [Yves Schmid] fixed a bug with Exif metadata reading in TIFF images +* [Herve Drolon] fixed some possible 64-bit portability issues with pointer calculations +* [wangyn] fixed a bug with transparency handling of indexed images in PNG plugin +* [Martin Dyring-Andersen] fixed a bug with GIFinfo structure initialization in GIF plugin +* [Noam Gat] fixed a bug in SGI plugin: when the file reports as two-dimensional, the height factor does not get loaded +* [Herve Drolon] added error messages in FreeImage_Load(U) / FreeImage_Save(U) in case of bad filenames +* [Scott Smith/Herve Drolon] added missing IPTC tags and renamed some tag names to be compatible with ExifTool naming convention +* [Martin Dyring-Andersen] fixed a crash problem with images containing exif data emitted by Picassa +* [Herve Drolon] removed RGBA to RGB transparent conversion in EXR plugin +* [Glenn Pierce] improved the speed of FreeImage_FlipHorizontal +* [Carsten Klein] fixed 65535 pixels width/height limitation in FreeImage_Paste + +November 19th, 2007 - 3.10.0 +! FreeImage now uses libTIFF 3.9.0beta (CVS patch 2007-10-05) +! FreeImage now uses OpenJPEG 1.2.0 (SVN patch 2007-07-13) +! FreeImage now uses OpenEXR 1.6.1 +! FreeImage now uses libPNG 1.2.23 +! FreeImage now hides its internal functions and internal libraries when compiled with gcc +- [Herve Drolon] removed VS C+ 6.0 project files : this IDE is no longer supported because of OpenEXR ++ [Herve Drolon] added VS 2005 project files ++ [Herve Drolon] added full support for the OpenEXR format ++ [Herve Drolon] added full support for the JPEG-2000 format ++ [Herve Drolon] added FreeImage_TmoFattal02 tone mapping operator ++ [Ryan Rubley] added support for RGB vs BGR regardless of endian ++ [Herve Drolon] added FreeImage_MultigridPoissonSolver ++ [Carsten Klein] added FreeImage_PreMultiplyWithAlpha ++ [Carsten Klein] added __stdcall version of FreeImage_OutputMessage ++ [Carsten Klein] added new palette and color manipulation functions (see below) : + added FreeImage_SetTransparentIndex + added FreeImage_GetTransparentIndex + added FreeImage_GetAdjustColorsLookupTable + added FreeImage_AdjustColors + added FreeImage_ApplyColorMapping + added FreeImage_SwapColors + added FreeImage_ApplyPaletteIndexMapping + added FreeImage_SwapPaletteIndices +* [Herve Drolon] fixed a bug in TIFF plugin when reading 8-bit + 8-bit alpha images +* [Herve Drolon] fixed a bug in TIFF plugin when reading images with uncommon bitdepths +* [rodrigo] fixed FreeImage exception handling under gcc (added -fexceptions to gcc compiler flags) +* [Martin Dyring-Andersen] fixed GIF plugin crashing on some corrupted files +* [Herve Drolon] fixed a bug with RLE encoding for 8-bit BMP images +* [Herve Drolon] fixed GPS metadata being skipped when reading metadata in Exif images +* [Herve Drolon] fixed a bug when reading OS/2 BMP images with a negative height +* [Ryan Rubley] fixed a bug with loading of GIFs with large amounts of solid color areas +* [Ryan Rubley] fixed OS X compile error in BitmapAccess.cpp +* [Herve Drolon] fixed a bug in FreeImage_Paste when pasting non-standard image types +* [Herve Drolon] saving 1-bit TIF with the TIFF_CCITTFAX3 flag is now compliant with the TIFF Class F specification +* [Carsten Klein] fixed topdown parameter in FreeImage_ConvertFromRawBits and FreeImage_ConvertToRawBits being handled in reverse +* [Herve Drolon] fixed a bug when reading some RLE-4 encoded BMP data +* [Carsten Klein] conversion from 1-bit to 32-bit now keep possibly present transparency + +February 11th, 2007 - 3.9.3 +! FreeImage now uses libPNG 1.2.16 +! [Ryan Rubley/Ryan Davis] reworked the MacOSX makefile in order to fully support Universal Binary builds of FreeImage +! [Herve Drolon] makefiles are now generated from VS2003 project files instead of VS6 project files +! [Herve Drolon] changed JPEG load/save flag option values ++ [Herve Drolon] added support for RGBAF images to FreeImage_ConvertToRGBF ++ [Herve Drolon] FreeImage_Paste now works with any bitmap type ++ [Herve Drolon] added full support for 64-bit RGBA images to the PNG and TIFF plugins ++ [Jascha Wetzel] added JPEG downsampling feature to PluginJPEG:Load +* [Thomas Chmielewski] fixed a bug in FreeImage_Dither and Bayer dithering, added FID_BAYER16x16 +* [Raphael Gaquer] greatly improved the speed of the GIF encoder +* [Herve Drolon] fixed saving of metadata in the PNG plugin +* [rampelstinskin] fixed transparency table to alpha channel conversion for 4-bit images in FreeImage_ConvertTo32Bits +* [Scott Smith] added missing IPTC tag named "Country/PrimaryLocationCode" +* [Herve Drolon] changed #include by #include in FreeImage.h (needed by Solaris 9) +* [Pierre Arnaud] fixed the use of FreeImage in low memory condition by checking some returned values of the malloc function +* [Pierre Arnaud] fixed TagLib::getTagFieldName not being thread safe + +October 30th, 2006 - 3.9.2 +! FreeImage now uses libTIFF 3.8.2 (with patch 2006-10-13) ++ [Herve Drolon] added full support for 16-bit greyscale and 48-bit RGB to the PNM plugin ++ [Herve Drolon] added IPTC writing support to JPEG & TIFF plugins ++ [Herve Drolon] added new Exif maker note tags ++ [Herve Drolon] added FreeImage_JPEGCrop ++ [Thorsten Radde] added support for 8-bit palettized bitmaps in FreeImage_RotateClassic ++ [Matt Rice] added automatic call to FreeImage_Initialise / FreeImage_DeInitialise when using FreeImage as a .so ++ [Martin Dyring-Andersen] added FreeImage_LoadMultiBitmapFromMemory to the multi-page API ++ [Herve Drolon] added support for tiled TIFF images +* [Carsten Klein] fixed a bug in FreeImage_SetMetadata occuring when deleting a tag +* [Herve Drolon] fixed a bug in PNG plugin when reading Macromedia 'false' PNG files +* [Thorsten Radde] added resolution support to PluginPSD +* [Ryan Rubley] fixed a bug in PluginGIF occuring with interlaced GIF +* [Ryan Rubley] fixed a bug in the multipage cache mechanism (internal FreeImage_FindBlock function) +* [Thorsten Radde] fixed a stack corruption in TIFF plugin occuring when reading exif tags +* [checkered] fixed a bug in the multipage cache mechanism causing VS2005 to crash on multipage files +* [Herve Drolon] fixed a bug with transparency support of 1- and 4-bit images +* [Roar Flolo] fixed a bug in PSD plugin when reading non compressed RGB images (alpha channel initialization) +* [Nicolas Hatier] fixed a bug in PluginGIF when using the GIF_PLAYBACK flag +* [Herve Drolon] fixed a bug in TIFF plugin when saving 8-bit images using LZW with differenciation +* [Herve Drolon] fixed 64-bit compilation issue with LibPNG and assembler code + +July 16th, 2006 - 3.9.1 +* [Ryan Rubley] fixed a bug in PluginGIF plugin causing FreeImage to crash on malformed GIF files + +July 6th, 2006 - 3.9.0 +! FreeImage now uses libPNG 1.2.12 +! FreeImage now uses libTIFF 3.8.2 (with patch 2006-06-24) +! FreeImage_Allocate/FreeImage_Allocate now set the resolution to 72 dpi instead of 0 ++ [Herve Drolon/Petr Pytelka] added a raw FAX G3 format loader ++ [Herve Drolon] added support for most image types to FreeImage_Rescale ++ [Herve Drolon] added FreeImage_MakeThumbnail ++ [Herve Drolon] added support for 64-bit images to FreeImage_ConvertTo32Bits ++ [Herve Drolon] added support for Exif tags to TIF plugin (read only) ++ [Herve Drolon] added FreeImage_ReadMemory ++ [Herve Drolon] added FreeImage_WriteMemory ++ [Herve Drolon] added new Exif maker note tags ++ [Sherman Wilcox] added a SGI file format loader ++ [Herve Drolon] added support for separated images to PluginTIFF ++ [Herve Drolon] added support for progressive-JPEG saving to PluginJPEG +* [Carsten Klein] FreeImage_Dither and FreeImage_Threshold now work with palettized 8-bit dib +* [Christophe Petit] fixed a bug in FreeImage_GetFIFFromFilenameU occuring with files without extension +* [Leigh Brasington] fixed a bug in PluginGIF causing FreeImage not working on Win/98/ME +* [Herve Drolon] fixed a bug in PluginTIFF with writing of JPEG-in-TIFF files +* [Jojakim Stahl] fixed a bug occuring with 4-bit PCX files +* [Sandor Szalacsi] fixed a bug in FreeImage_SetBackgroundColor (bkgnd clearing) +* [Petr Pytelka] fixed PluginTIFF::_tiffSizeProc failing on some images +* [Sherman Wilcox] fixed a bug in DDS plugin when loading images whose size is not a multiple of 4 +* [Sherman Wilcox] fixed a memory leak in PluginDDS::LoadDXT_Helper +* [Sherman Wilcox] fixed DDS plugin bad behavior with invalid DDS files (such as files with zero length) +* [Floris van den Berg] fixed a memory leak in the MultiPage cache mechanism +* [Herve Drolon] replaced WIN32 #define by _WIN32 #define as this is needed by VS2005 +* [Herve Drolon] fixed a VS2005 error in FreeImage_DeletePage +* [Petr Supina] fixed a pow(long,long) function not being standard ANSI C/C++ +* [Petr Supina] fixed FreeImage_FindBlock function not being standard ANSI C/C++ +* [Olaf Stoyke] added support for 64-bit Linux OS +* [Craig Stark] fixed FreeImage support on Intel based Mac OS +* [Herve Drolon] fixed PluginTIFF failing on bad fax tiff images (bad images are now loaded 'as is') +* [Zack Simpson] fixed a bug occuring in rare situations with FreeImage_Aligned_Malloc + +September 5, 2005 - 3.8.0 +! FreeImage now uses libTIFF 3.7.3 +! FreeImage now uses ZLib 1.2.3 ++ [Herve Drolon] added support for 48-bit images to FreeImage_ConvertTo24Bits ++ [Herve Drolon] added FreeImage_ConvertToGreyscale ++ [Herve Drolon] added support for 16-bit greyscale images to FreeImage_ConvertTo8Bits ++ [Petr Pytelka] added UNICODE functions (see below) + added FreeImage_LoadU + added FreeImage_SaveU + added FreeImage_GetFIFFromFilenameU + added FreeImage_GetFileTypeU ++ [Herve Drolon] FreeImage_Copy now works with any bitmap type ++ [Herve Drolon] added support for 1-bit images to FreeImage_Paste +* [Ryan Rubley] fixed PluginGIF failing to link on some broken gcc versions +* [Karl-Heinz Bussian] fixed a bug in LookupX11Color/LookupSVGColor with handling of grey color names +* [Herve Drolon] FreeImage_Dither now uses FreeImage_ConvertToGreyscale and handles 4/8-bit palletized images +* [Herve Drolon] FreeImage_Threshold now uses FreeImage_ConvertToGreyscale and handles 4/8-bit palletized images +* [Craig Hockenberry] fixed PluginGIF::Save swapping the byte order for the height on big endian machines (e.g. PPC on Mac OS X.) +* [Herve Drolon] fixed a bug in JPEG plugin when reading Exif maker notes from images produced by Nikon Editor +* [Herve Drolon] fixed a bug in BMP plugin when reading some malformed RLE8 bmp +* [Herve Drolon] fixed a bug in RAS plugin when loading 8-bit palettized images with less than 256 colors +* [Herve Drolon] fixed a bug in FreeImage_Rescale with 16-,48-,64-bit images +* [Herve Drolon] fixed a bug in the ICC profiles API when loading profile-less CMYK TIFF +* [Herve Drolon] 4-bit PNG are now loaded as 4-bit and no longer converted to 8-bit +* [Greg Ng] fixed a bug in FreeImage_ConvertToRGBF (FIT_BITMAP -> FIT_RGBF conversion) + +May 7, 2005 - 3.7.0 +! FreeImage now uses libTIFF 3.7.2 +! [Ryan Rubley] improved FreeImage_OpenMultiBitmap ++ [Detlev Vendt] added FreeImage_ZLibGUnzip ++ [Herve Drolon] added new image data types FIT_RGB16, FIT_RGBA16, FIT_RGBF, FIT_RGBAF ++ [Herve Drolon] FreeImage_FlipHorizontal & FreeImage_FlipVertical now work with any bitmap type ++ [Herve Drolon] added conversions to float and double in FreeImage_ConvertToType ++ [Herve Drolon] added FreeImage_ConvertToRGBF ++ [Herve Drolon] added support for 16-, 48- and 96-bit images to FreeImage_Rescale ++ [Ryan Rubley] added FreeImage_ColorQuantizeEx ++ [Ryan Rubley] added FIMD_ANIMATION and FIDT_PALETTE ++ [Ryan Rubley] added brand new PluginGIF with full animation multipage and metadata support ++ [Herve Drolon] added support for FIC_MINISWHITE 8-bit images to FreeImage_Rescale ++ [Herve Drolon] added HDR (High Dynamic Range) format (loader & writer) ++ [Herve Drolon] added support for 48-bit images in TIFF plugin ++ [Herve Drolon] added support for 48-bit images in PNG plugin ++ [Herve Drolon] added tone mapping operators (see below) ++ added FreeImage_ToneMapping ++ added FreeImage_TmoDrago03 ++ added FreeImage_TmoReinhard05 ++ [Petr Pytelka] added FreeImage_JPEGTransform +* [Herve Drolon] allowed loading of corrupted JPEG with a premature end of file +* [Herve Drolon] fixed a memory leak with loading of exif JPEG images +* [Detlev Vendt] changed some 'pointer-to-int' casts to 'pointer-to-long' for 64bit machines +* [Ryan Rubley] fixed a memory leak in the multipage API +* [Ryan Rubley] updated VB6 wrapper generation for new functions +* [Herve Drolon] fixed incorrect behavior when reading JPEG comments containing special characters +* [Herve Drolon] fixed incorrect behavior when reading JPEG ICC profiles with a size greater than 64 KB +* [Herve Drolon] fixed a bug in TIFF plugin when loading malformed multipage TIFF +* [Herve Drolon] fixed PluginTIFF not being thread safe + +February 20, 2005 - 3.6.1 +* [Ryan Rubley] fixed a memory leak in the metadata API +* [luedi] improved the robustness of FIBITMAP allocations + +February 13, 2005 - 3.6.0 +! FreeImage now uses libMNG 1.0.9 +! [Herve Drolon] improved the speed of FreeImage_Rescale +! [Herve Drolon] improved FreeImage_RotateClassic (more compact code, a little faster) +! [Herve Drolon] improved the metadata API using tag accessors ++ [Detlev Vendt] added LZW support to PluginGIF:Save ++ [Herve Drolon] added VS.Net 2003 project files ++ [Herve Drolon] added VERSIONINFO resource to the DLL ++ [Herve Drolon] added support for CMYK JPEG on loading ++ [Petr Supina] added 16-bytes alignment to FIBITMAP palette and pixels starting address ++ [Petr Supina] added support for MMX/SSE2 code in LibJPEG (based on Mozilla/Firefox code) ++ [Herve Drolon] added TIFF_JPEG compression flag to the TIFF plugin ++ [Detlev Vendt] added FreeImage_ZLibGZip ++ [Detlev Vendt] added FreeImage_ZLibCRC32 +* [Detlev Vendt] fixed PluginPNG not being thread safe +* [Herve Drolon] fixed compiler warning C4018 occuring with VS.Net 2003 + +December 29, 2004 - 3.5.3 +! FreeImage now uses ZLib 1.2.2 +! FreeImage now uses libPNG 1.2.8 +! FreeImage now uses libTIFF 3.7.1 +! [Herve Drolon] improved FreeImage_RotateClassic +! [Detlev Vendt] improved FreeImage_Rescale (more compact code, preserving 8-bpp colors) ++ [Herve Drolon] added support for transparency saving in ICO plugin ++ [Herve Drolon] added support for 1-bit images to FreeImage_RotateClassic ++ [Herve Drolon] added FreeImage_SetDotsPerMeterX and FreeImage_SetDotsPerMeterY +* [Nan Feng] fixed memory leak in FreeImage_DeleteTag (internal stuff) +* [Nigel Stewart] added conditional #pragma with #ifdef _MSC_VER / #endif +* [Herve Drolon] fixed the '65536 lines' limit on loading in PNM plugin + +November 27th, 2004 - 3.5.2 +* [Herve Drolon] fixed a second bug in FreeImage_Clone function + +November 26th, 2004 - 3.5.1 ++ [Riley McNiff] added FreeImage_ConvertTo4Bits +* [Herve Drolon] fixed a buffer overrun with some ILBM images +* [Riley McNiff] fixed a potential problem when reading TIFF resolution info +* [Dimitar Atanasov] fixed a bug in FreeImage_Clone function +* [Dimitar Atanasov] fixed several bugs in TIFF plugin + +November 1st, 2004 - 3.5.0 +! FreeImage now uses libPNG 1.2.7 +! FreeImage now uses libTIFF 3.7.0 +! FreeImage now uses libMNG 1.0.8 +! [Herve Drolon] improved TIFF LZW compression using a predictor +! [Detlev Vendt] FreeImagesPlus: corrected references to FreeImage.h and FreeImage.lib ++ [Herve Drolon] added support for loading/saving of 8-bit transparent TIFF ++ [Riley McNiff] added support for 4-bit dib in FreeImage_Paste ++ [Herve Drolon] added support for memory IO streams (see below) ++ added FreeImage_OpenMemory ++ added FreeImage_CloseMemory ++ added FreeImage_LoadFromMemory ++ added FreeImage_SaveToMemory ++ added FreeImage_TellMemory ++ added FreeImage_SeekMemory ++ added FreeImage_AcquireMemory ++ added FreeImage_GetFileTypeFromMemory ++ [Petr Pytelka] added FreeImage_GetFIFMimeType to the plugins function list ++ [Herve Drolon] added ICC profile support to JPEG plugin ++ [Herve Drolon] added support for metadata (see below) ++ added FreeImage_SetMetadata ++ added FreeImage_GetMetadata ++ added FreeImage_GetMetadataCount ++ added FreeImage_TagToString ++ added FreeImage_FindFirstMetadata ++ added FreeImage_FindNextMetadata ++ added FreeImage_FindCloseMetadata +* [Riley McNiff] fixed a bug with FreeImage_SetPixelIndex and 4-bit images +* [Petr Pytelka] fixed returned value in FreeImage_CloseMultiBitmap +* [Petr Pytelka] fixed index of new page in FreeImage_InsertPage +* [Aaron Shumate] fixed a minor bug in PNG plugin +* [Aaron Shumate] fixed a bug in IFF plugin (odd-length chunks) +* [Rupert Hewitt] fixed FreeImage not compiling on National Instruments Cvi Ccompiler +* [Herve Drolon] fixed a bug in IFF plugin (ILBM data) +* [Fred Harju] added a Makefile for Solaris 9 +* [Roddy Pratt] fixed FreeImage not linking under Borland C++ Builder +* [Vadim Alexandrov] fixed a memory leak in the multipage API +* [Herve Drolon] fixed a bug with DDS plugin behaviour on Big Endian OS +* [Herve Drolon] fixed a bug with conversion of JPEG resolution info on saving + +July 8th, 2004 - 3.4.0 +! [Jim Keir] improved FreeImage_FlipVertical function +! [Herve Drolon] LZW compression is now enabled in FreeImage ++ [Karl-Heinz Bussian] added constants to FreeImage.h to get at compile time the library version ++ [Karl-Heinz Bussian] added color lookup functions for X11 and SVG ++ [Herve Drolon] added TIFF tags TIFF_CCITTFAX3, TIFF_CCITTFAX4 and TIFF_LZW ++ [Detlev Vendt] added support for CMYK TIFF files with alpha channel ++ [Detlev Vendt] added (re-introduction of) PluginGIF +* [Herve Drolon] fixed a bug with loading of FAX TIFF images (introduced with LibTIFF 3.6.1) +* [Herve Drolon] fixed a bug in Floyd-Steinberg dithering algorithm +* [Herve Drolon] fixed a bug in Targa plugin save function +* [Herve Drolon] fixed a bug in FreeImage_AdjustCurve function +* [Ryan Rubley] fixed a bug with FreeImage_Rescale's filters accuracy +* [Ryan Rubley] fixed a bug in NN quantizer +* [Herve Drolon] fixed a bug with TIFF files containing additional Photoshop alpha channels +* [James Rossfeld] fixed a memory leak with some PSD images +* [Herve Drolon] fixed a bug with saving of 32-bit non transparent PNG images +* [Alexandr Zamaraev] fixed FreeImage not compiling with mingw32 +* [Herve Drolon] fixed FreeImage not compiling with VC.NET (pow function needs casts) + +May 2, 2004 - 3.3.0 +! [Ryan Rubley] FreeImage has been ported to MacOSX and should also work on other big endian processors ++ [Ryan Rubley] rewrote XPM plugin (better load support) and added save support ++ [Ryan Rubley] added ICO_MAKEALPHA flag to ICO plugin ++ [Ryan Rubley] Set/GetPixelColor now works with 16-bit pixels (555 or 565) ++ [Herve Drolon] PNG plugin now supports loading and saving of unsigned 16-bit greyscale images +* [Herve Drolon] fixed a bug with loading of 8-bit and 16-bit PNG with a 8-bit alpha channel +* [Herve Drolon] fixed a bug in NN quantizer algorithm with handling of 4-byte boundary alignment. +* [Herve Drolon] fixed a bug in PluginIFF Validate function +* [Herve Drolon] fixed a minor design issue in FreeImage_GetFIFFromFormat +* [Brad Schick] fixed some compiler warnings with VC++ 7.1 +* [Herve Drolon] fixed a bug with saving of 8-bit palettized images to 24-bit JPEG (channel inversion) + +March 16, 2004 - 3.2.1 +! [Volker Gärtner] improved the DDS plugin +! [Herve Drolon] FreeImage_Rescale now works on 8-, 24- and 32-bit images +! [Herve Drolon] FreeImage_Copy now works on 1-, 4-, 8-, 16-, 24- and 32-bit images +* [Floris van den Berg] fixed a bug in the MultiPage cache mechanism +* [Herve Drolon] fixed a bug with loading/saving of 8-bit transparent tga images +* [Herve Drolon] fixed a bug with loading of 1-bit TIFF (introduced with LibTIFF 3.6.1) + +February 18, 2004 - 3.2.0 +! FreeImage now uses libTIFF 3.6.1 ++ [Herve Drolon] added FreeImage_HasBackgroundColor ++ [Herve Drolon] added FreeImage_GetBackgroundColor ++ [Herve Drolon] added FreeImage_SetBackgroundColor ++ [Herve Drolon] added FreeImage_Composite ++ [Herve Drolon] added ICC profile support to PNG plugin ++ [Herve Drolon] added background color support to PNG plugin ++ [Volker Gärtner] added support for DDS format (loader) +* [Steve Johnson] improved FreeImage_OpenMultiBitmap/FreeImage_CloseMultiBitmap +* [Steve Johnson] fixed a bug in FreeImage_InsertPage +* [Herve Drolon] fixed a bug with JPEG compressed TIFF (red/blue swapping) +* [Herve Drolon] fixed a bug in PluginTarga where 8-bit images were saved incorrectly + +January 26, 2004 - 3.1.0 +! FreeImage now uses ZLib 1.2.1 ++ [Herve Drolon] added support for integer, real and complex image types (see below) ++ added FREE_IMAGE_TYPE enum ++ added FreeImage_AllocateT ++ added FreeImage_GetImageType ++ added FreeImage_FIFSupportsExportType ++ added FreeImage_ConvertToStandardType ++ added FreeImage_ConvertToType ++ added load/save support of all image types to TIFF plugin ++ [Peter Lemmens] added a Validate function to TARGA plugin ++ [Herve Drolon] added FreeImage_GetPixelIndex / FreeImage_SetPixelIndex ++ [Herve Drolon] added FreeImage_GetPixelColor / FreeImage_SetPixelColor ++ [Herve Drolon] added FreeImage_GetComplexChannel / FreeImage_SetComplexChannel +* [Serge Ivanchenko] TIFF_DEFLATE compression is now enabled in TIFF plugin +* [Herve Drolon] fixed a bug in NeuQuant color reduction algorithm + +November 16, 2003 - 3.0.4 +* [Tobias Persson] fixed FreeImage_GetChannel not working with FICC_ALPHA channel +* [Detlev Vendt] fixed a minor bug with PNG plugin and PNG_IGNOREGAMMA flag +* [Detlev Vendt] fixed a memory leak in PNG plugin save routine +* [Detlev Vendt] fixed JPEG validation problem with .jpe files +* [Ryan Rubley] added Source/LibTIFF/tif_extension.c to LibTIFF (needed for MacOSX) +* [Herve Drolon] improved error handling in TIFF plugin ++ [Karl-Heinz Bussian] added FreeImage_IsLittleEndian ++ [Karl-Heinz Bussian] added JPEG save support for 8-bit miniswhite bitmaps (transparent conversion to minisblack) ++ [Karl-Heinz Bussian] FreeImage_GetColorType now recognizes 8-bit FIC_MINISWHITE images +! [Herve Drolon] FreeImage_Rescale now supports rescaling of 32-bit images with alpha channel +! [Herve Drolon] FreeImage_Invert now supports inversion of 32-bit images with alpha channel +! [Herve Drolon] FreeImage_AdjustCurve now supports working with FICC_ALPHA channel + +November 2, 2003 - 3.0.3 +* [Ryan Rubley] improved makefile for Linux +* [Ryan Rubley] fixed FreeImage not compiling under MacOSX +* [Detlev Vendt] fixed still present inconsistancy with 32bpp transparency handling +* [Herve Drolon] fixed incorrect loading of 4-bit greyscale images in TIFF plugin + +October 27, 2003 - 3.0.2 +! FreeImage now uses libMNG 1.0.6 +* [Herve Drolon] fixed a boolean test in PluginCUT returning always false +* [Herve Drolon] fixed a warning in PluginIFF generated with g++ +* [Linus Tan] fixed a bug in FreeImage_Copy +* [Herve Drolon] fixed FreeImage not compiling under Linux (thanks to Michal) + +October 20, 2003 - 3.0.1 + +! FreeImage now uses libTIFF 3.6.0 +* [Detlev Vendt] fixed incorrect definition of the FREE_IMAGE_FORMAT enum +* [Detlev Vendt] fixed a potential crash problem with Load / Save routines +* [Herve Drolon] fixed incorrect loading of 16-bit greyscale images in TIFF plugin +* [Dennis Lim] fixed a memory leak in Floyd & Steinberg dithering routine +* [Herve Drolon] fixed a bug in BMP loader (incorrect loading of RLE4 bmp) +* [Detlev Vendt] fixed some inconsistancy with 32bpp transparency handling ++ [David Boland] added a C# wrapper +// Linux compatibility issues +- [Michal Novotny] removed the round function in Utilities.h +! [Herve Drolon] replaced the round routine by the clamp routine in PluginPCD ++ [Herve Drolon] added _itoa version in Utilities.h +* [Michal Novotny] fixed untyped consts not accepted by g++ in PluginBMP + +September 8, 2003 - 3.0.0 +- [Herve Drolon] removed deprecated functions +- [Herve Drolon] removed deprecated flags (TARGA_LOAD_RGB555, ICO_*, except ICO_DEFAULT) +- [Herve Drolon] removed the FreeImage pointer table (internal stuff) ++ [Herve Drolon] added a C++ wrapper ++ [Herve Drolon] added the FreeImage Toolkit (see below) ++ added FreeImage_Rescale ++ added FreeImage_RotateClassic ++ added FreeImage_RotateEx ++ added FreeImage_FlipHorizontal ++ added FreeImage_FlipVertical ++ added FreeImage_Invert ++ added FreeImage_AdjustCurve ++ added FreeImage_AdjustGamma ++ added FreeImage_AdjustBrightness ++ added FreeImage_AdjustContrast ++ added FreeImage_GetHistogram ++ added FreeImage_GetChannel ++ added FreeImage_SetChannel ++ added FreeImage_Copy ++ added FreeImage_Paste ++ [Karl-Heinz Bussian] added XPM loader ++ [Karl-Heinz Bussian] added flags parameter to FreeImage_CloseMultiBitmap ++ [Karl-Heinz Bussian] added JPEG save support for 8-bit palettized bitmaps (transparent conversion to 24-bit) ++ [Herve Drolon] added interface to ZLib compression functions ++ [Herve Drolon] added ICO format to the multipage API (loader & writer) ++ [Herve Drolon] added a MIME type to all plugins +* [Karl-Heinz Bussian] fixed incorrect conversion from 1-bit FIC_MINISWHITE bitmaps to 8-bit +* [Herve Drolon] fixed a bug in FreeImage_CloseMultiBitmap +* [Herve Drolon] fixed a potential memory leak in conversion functions (8-, 24-, 32-bit) +* [Robert Walker] fixed incorrect conversion from 16-bit to 24-bit and 16-bit to 32-bit +* [blurble] fixed TIFF validate signature problem (3DS files were recognized as TIFF) +* [Kurt Jankowski-Tepe] fixed FreeImage not compiling on MinGW / LCC WIN32 +* [Jani Peltonen] fixed bug in PluginTARGA where 32-bit bitmaps are not always correctly flipped +* [Detlev Vendt] fixed a bug with TIFF (memory leak with ICC profiles) + +May 25, 2003 - 2.6.1 ++ [Detlev Vendt] added FIC_CMYK to FREE_IMAGE_COLOR_TYPE ++ [Detlev Vendt] added ICC profile support to the library (see below) ++ added FreeImage_GetICCProfile ++ added FreeImage_CreateICCProfile ++ added FreeImage_DestroyICCProfile ++ added FIICCPROFILE & FIICCPROFILE flags ++ added plugin function FreeImage_FIFSupportsICCProfiles ++ [Detlev Vendt] added ICC profile support for TIFF ++ [Herve Drolon] added XBM (X11 Bitmap Format) support : loading +* [Herve Drolon] fixed incorrect IFF file detection (thanks Floris) +* [Herve Drolon] fixed incorrect conversion from 1/4-bit greyscale bitmaps to 8-bit +* [Herve Drolon] fixed a bug in TIFF writer when saving 1,4,8 bit dib (introduced in 2.6.0, sorry) +* [Herve Drolon] fixed a palette problem in TIFF loader when loading 1-bit b & w images +* [Herve Drolon] improved FreeImage_Dither to handle any bitdepth + +May 5th, 2003 - 2.6.0 +! FreeImage now uses libPNG 1.2.5 +! FreeImage now uses libMNG 1.0.5 +! [Markus Loibl] ActiveX wrapper is now distributed in a separate release (since 2.5.5) +! [Herve Drolon] the function FreeImage_Free is now deprecated : use FreeImage_Unload instead +! [Herve Drolon] updated the generic samples and removed deprecated functions ++ [Detlev Vendt] added CMYK support to TIFF save function ++ [Detlev Vendt] added TIFF_SAVE_CMYK flag constant ++ [Detlev Vendt] added 32-bit support (with transparency handling) to TIFF plugin ++ [Herve Drolon] added FreeImage_Threshold ++ [Herve Drolon] added FreeImage_Dither ++ [Herve Drolon] added FREE_IMAGE_DITHER parameter to FreeImage_Dither +* [Herve Drolon] improved error handling in PluginMNG +* [Herve Drolon] improved TIFF flags handling in TIFF save function +* [Herve Drolon] fixed a potential crash-problem in FreeImage_OutputMessage (in case of a null message) +* [Detlev Vendt] fixed a bug with the deprecated FreeImage_GetBitsRowCol (trailling backslash behind the DEPRECATE macro) + +July 24th, 2002 - 2.5.5 +! FreeImage now uses libPNG 1.2.4 +! FreeImage now uses libMNG 1.0.4 ++ [Markus Loibl] added ActiveX wrapper + +June 22th, 2002 - 2.5.4 +* [Timothy Roughton] fixed FreeImage not compiling on LCC WIN32 +* [Markus Loibl] fixed PluginTIFF sometimes saving with wrong X/Y resolution +* fixed crashbug when loading some RLE4 BMPs +! FreeImage now uses LibPNG 1.2.3 +! [Markus Loibl] improved startup plugin locate handling code +! [Gerhard Gruber] made some changes so that FreeImage compiles on VC5 ++ [Markus Loibl] added flags TIFF_PACKBITS, TIFF_DEFLATE, TIFF_ADOBE_DEFLATE and TIFF_NONE + +May 21th, 2002 - 2.5.3 +* fixed wrong colors when loading 16-bit grayscale TIFF +* fixed crash-problem with FreeImageQt +* fixed PluginTIFF saving some bitmaps flipped vertically +* [Laurent Rocher] fixed bug in FreeImage_GetLockedPageNumbers +* [Laurent Rocher] fixed bug in FreeImage_UnlockPage +! FreeImage now uses libpng 1.2.2 ++ added TARGA save support ++ added BMP RLE8 save support + +March 30th, 2002 - 2.5.2 +* fixed bug in PluginTARGA where 32-bit bitmaps are not always correctly flipped +* fixed FreeImage_GetLockedPageNumber being mentioned in FreeImage.h +* fixed crash bug when handling read-only multipage bitmaps +- removed internal function FreeImage_GetExtraDataPointer +! FreeImage now uses zlib 1.1.4 ++ added function FreeImage_GetLockedPageNumbers + +March 2nd 2002 - 2.5.1 +* fixed pluginTIFF not being able to save 32-bit bitmaps +* fixed not being able to save PNM bitmaps through the LoadXXX wrappers +* fixed a webcam generated BMP image being loaded with wrong colors +! FI_ReadProc, FI_WriteProc, etc. do now carry the DLL_CALLCONV flag +! the function FreeImage_GetBitsRowCol is now deprecated +! FreeImage_SetTransparencyTable now taken an integer as count parameter +! FreeImage_IsTransparent now always returns true for 32-bit bitmaps +! PluginPNG::Save now ignores the result of FreeImage_IsTransparent +! PluginTIFF now converts all 32-bit bitmaps to 24-bit, until our patch + to fully support alpha in TIFF is applied in libtiff ++ added full multi-paging support ++ added octal and hexadecimal number support to FreeImage_OutputMessage + +January 3rd 2002 - 2.5.0 +* fixed bug in FreeImage_SaveJPEG +* fixed bug in FreeImage_LoadMNG +* fixed bug in FreeImage_LoadPNG +* fixed small Visual C++ 5.0 compiler issue in PluginMNG.cpp +* fixed FreeImage crashing on JPEG 6.0 encoded TIFFs +! FreeImage now uses libTIFF 3.5.7 +! FreeImage now uses libPNG 1.2.1 +! all the FreeImage_LoadXXX and FreeImage_SaveXXX functions are now deprecated ++ added Dr. Halo (*.cut) support ++ added printf-like format string support to SetOutputMessage ++ added basic multi-paging support: open, close, counting and grabbing ++ added deprecation manager ++ added FreeImage_Clone function + +October 3rd 2001 - 2.4.2 +* fixed missing BI_BITFIELDS support for 32-bit BMPs +* fixed bug in FreeImage_ConvertLine16_555_To16_565 and vice versa +* fixed bug in FreeImage_ConvertToRawBits +* fixed PluginTIFF behaving incorrectly on PHOTOMETRIC_MASK images +* fixed 16 bit TIFFs not loading correctly +* fixed incorrect handling of CCITTFAX3 and CCITTFAX4 TIFFs +* fixed JPEG encoded TIFFs not being supported +! [Yours Detlev] patched libTIFF to handle EXTRASAMPLE_UNSPECIFIED +! [Juergen Riecker] improved speed of PCX loading a lot +! rewrote parts of FreeImage to improve support for c +! the internal RGB555 and RGB565 macros now read BGR instead of RGB +! FreeImage now uses libMNG 1.0.3 +! FreeImage now uses libPNG 1.2.0 +! FreeImage_Save now opens files with the "w+b" flag +! renamed internal macro CalculateUsedColors to CalculateUsedPaletteEntries +! enabling/disabling plugins no longer has effect on FIFSupportsReading +! enabling/disabling plugins no longer has effect on FIFSupportsWriting ++ added flag PNG_IGNOREGAMMA ++ added function FreeImage_FIFSupportsExportBPP + +July 30th 2001 - 2.4.1 +* [Jan Nauta] fixed some plugin ids not being passed to plugins +* [Jan Nauta] fixed some functions being natively called instead of indirect +* [Jan Nauta] fixed BMPs with signature BA not being regognised +* [Remo Eichenberger] fixed memory leak in the plugin system +* fixed seek bug in PluginIFF's Validate +* fixed transparency issue in PluginPNG +* fixed uncaught exceptions in WUQuantizer and NNQuantizer +* fixed some problems with PluginTARGA +* fixed some problems with PluginICO +* fixed some problems with PluginBMP +! improved FreeImageQt's load function a little +! tell/seek control for validation is now handled inside the plugin framework + +July 22th 2001 - 2.4.0 +* (Yours Detlev) fixed memory leak in FreeImage_GetFIFFromFilename +* (Yours Detlev) fixed memory leak in the ICO plugin +* (Yours Detlev) fixed memory leak in the PNG plugin +* fixed potential NULL-pointer access bug in Plugin::AddNode +* fixed problems with linking the static lib +- removed LBM plugin. Its functionality is placed in the IFF plugin now +- removed FreeImage_GetFIFByIndex +! FreeImage now uses LibMNG 1.0.2 +! FreeImage_SetTransparent now only enables alpha when the bitmap is 8 or 32 bit +! FreeImage_SetTransparencyTable now only enables alpha when the bitmap is 8 bit +! FreeImage_LoadLBM now uses Mark Sibly's IFF plugin +! FreeImage_SaveBMP now converts to 24-bit when bpp is 32 and transparency is off +! FreeImage_SaveJPEG now converts to 24-bit when bpp is 32 and transparency is off +! FreeImage_SavePNM now converts to 24-bit when bpp is 32 and transparency is off +! FreeImage_SaveTIFF now converts to 24-bit when bpp is 32 and transparency is off ++ [Mark Sibly] added IFF (ILBM) support ++ added basic support for Photoshop files ++ added mime type support (FreeImage_GetFIFFromMime) ++ added functions FreeImage_SetPluginEnabled and FreeImage_IsPluginEnabled + Disabling plugins modifies the behaviour of the following functions: + * FreeImage_LoadFromHandle + * FreeImage_SaveToHandle + * FreeImage_FIFSupportsReading + * FreeImage_FIFSupportsWriting + * FreeImage_GetFIFFromFormat + * FreeImage_GetFIFFromFilename + * FreeImage_GetFIFFromMime + * FreeImage_Validate + +June 30th 2001 - 2.3.2 +* fixed missing "targa" extension in targa extension list +* fixed small memory leak in PluginList::AddNode +* fixed 32 bit PNG saving suddenly disappeared from the distro? +* fixed 'black line' bug in LoadTARGA +- removed project FreeImageM2 +- removed FreeImage_Combine +! FreeImage_RegisterLocalPlugin now receives a FI_InitProc as first parameter +! FreeImage_GetFIFFromFilename now also takes the format id into account +! cleanup up the code a little for PluginPCD and PluginPCX ++ added static lib project + +June 11th 2001 - 2.3.1 +* [Machiel ten Brinke] fixed the loading of some 'ancient' TARGAs +* [Rui Lopes] fixed some bugs in the external plugin registration +* fixed the plugin system crashing when the init function isn't called +- removed project FreeImagePy +- removed 32 to 24 bit conversion while saving PNG in FreeImageQt +! the scanline convert functions are now accessable in plugins +! FreeImage now uses an STL map to store the plugin list +! PluginSDK.h is now integrated into FreeImage.h +! FreeImage_Register now receives the boolean parameter 'load_local_plugins_only' +! FreeImage now uses LibPNG 1.0.12 ++ [Rui Lopes] added plugin for GIF reading/writing support ++ added function FreeImage_SetTransparencyCount ++ added support for 32 bit PNG saving ++ added FreeImage_RegisterLocalPlugin to allow plugins inside apps ++ added FreeImage_RegisterExternalPlugin to manually load DLLs ++ added plugin for JBIG reading/writing support + +May 4th 2001 - 2.3.0 +* [Martin Weber] fixed some small bugs in the TARGA and BMP plugins +* [Martin Weber] fixed tiny bug in new 16 bit conversions +* [Martin Weber] fixed load flag inconsistency in the TARGA plugin +* [Martin Weber] fixed plugin id / load reference inconsistency for PNM +* [Jan Nauta] fixed bug in conversion 16 -> 16 +* [Herve Drolon] fixed small bug in 4-bit PCX loader +- removed code that loads BMPs renamed to ICO in PluginICO +! the flag TARGA_LOAD_RGB555 is now obsolete +! the plugin list is now sorted internally +! ConvertTo32Bits now stores the transparency table as alpha mask +! FreeImage now uses LibMNG 1.0,1 +! FreeImage now uses LibPNG 1.0.11 ++ added external plugin support via DLLs ++ added function FreeImage_GetFIFByIndex ++ added internal function CalculateScanLine ++ added transparency support for high-color PNGs ++ added transparency support for high-color TIFFs ++ added functions FreeImage_SetTransparent and FreeImage_IsTransparent ++ added constant FIC_RGBALPHA to FREE_IMAGE_COLOR_TYPE + +April 5th 2001 - 2.2.0 +* [Remo Eichenberger] fixed small bug concerning DLLMain and static LIB generation +* fixed 1-bit bitmaps not properly loading in FreeImageQt +* fixed bug in conversion 16->16 +* FreeImage now uses LibPNG 1.0.10 +! [Martin Weber] improved loading of BMP files +! [Martin Weber] improved loading of TARGA files +! [Dave Larson] improved visual appearance after 16 conversions +! FreeImageQt now converts 32-bit bitmaps to 24-bit when saving PNGs and JPEGs ++ added functions FreeImage_Initialise and FreeImage_DeInitialise ++ added internal plugins ++ re-added combine/alphablend functions + +March 8th 2001 - 2.1.0 +* [Martin Hemming] fixed bug in 16-bit TARGA loading code +* fixed PNG's with alpha masks not loading correctly +! FreeImage is now dual-licensed: the FI-License and the GPL license +! FreeImage now uses LibPNG 1.0.9 +! FreeImage now uses LibTIFF 3.5.6 Beta +! FreeImage now uses LiBMNG 1.0.0 +! changed the ordering of the FREE_IMAGE_FORMAT table +! improved linux support +! improved test script ++ added transparency table support to SavePNG ++ added BI_BITFIELDS support to LoadBMP and SaveBMP ++ added reading support for OS/2 2.x BMPs ++ added support for MNG and JNG reading using LibMNG ++ added support for Deluxe Paint reading ++ added 'hot swap' support to the Core DLL ++ added 'hot swap' support to FreeImage Qt ++ added functions GetFIFFromFormat and GetFIFFromFilename ++ added functions FIFSupportsReading and FIFSupportsWriting ++ added function GetFIFRegExpr + +January 14th 2001 - 2.0.0 +* [Herve Drolon] fixed a bug in the conversion 4->8 +* [Herve Drolon] fixed a bug in metrics handling in SaveJPEG +* [Herve Drolon] fixed a bug in the return value of the function SaveTIFF +* fixed the presence of two WuQuantizer.cpp files in the distribution +* fixed bug where a BMP renamed to ICO isn't loaded +- removed FreeImage_ConvertToGreyScale. Use FreeImage_ConvertTo8Bits instead. +- removed the boolean parameters from all conversion routines +- removed page handling in LoadTIFF. A new range of functions will be added. +! The void pointers used in FreeImage are now typed +! LoadBMP now takes palettes in 24/32 bit images in respect +! All effects and MMX functions are now stored in a new library (FreeEffects) +! [Herve Drolon] fixed bug in FreeImage_GetColorType +! [Herve Drolon] improved PCX loader. It can now read 1, 4, 8 and 24-bit images +! [Manfred Tausch] improved FreeImage_Rotate +! [Luca Piergentili] fixed crash bug when saving some 1-bit TIFFs +! rewrote all bitdepth conversion routines making use of the new scanline converters +! rewrote bitdepth conversion in FreeImageQt (uses less memory) +! FreeImage is now compiled __stdcall ++ [Herve Drolon] added WBMP (Wireless Bitmap Format) support: loading and saving ++ [Herve Drolon] added 4, 16 and 32 bitdepth handling in GetColorType ++ [Herve Drolon] added handling of 8-bit greyscale bitmaps in SaveJPEG ++ [Herve Drolon] added NeuQuant color reduction algorithm to ColorQuantize ++ added DLL_CALLCONV (calling convention) flag ++ added bitmask support to all bitmaps ++ added a series of functions converting scanlines from one bitdepth to another ++ added functions ConvertFromRawBits and ConvertToRawBits ++ added project FreeImageM2: Magenta II MMT bindings for FreeImage ++ added basic foundation for linux support + +December 2th 2000 - 1.4.4 +* fixed small bug related to TIFFSetDirectory in FreeImage_LoadTIFF +* fixed FreeImage_Rotate sometimes clipping too much pixels +* fixed other small bug in FreeImage_Rotate +* fixed FreeImage_Clone not taking the FREEIMAGEHEADER in account +* fixed bug in FreeImageQt where 1-bit images are not correctly allocated +* fixed FreeImage_Crop not copying the palette +* fixed message function pointer crash bug +* fixed bug where the palette wasn't copied when saving in FreeImageQt +* fixed FreeImage_Clone not copying the transparency table +- removed FreeImage_WritePaletteEntry +! [Adam Gates] rewrote parts of FreeImage so that c compilers can handle it better +! FreeImageQt doesn't statically link with the FreeImage lib anymore +! FreeImageQt now uses atexit() to automatically unregister +! rewrote parts of FreeImage_LoadBMP to increase speed ++ [Markus Loibl] added metrics handling code to LoadBMP, LoadJPEG, LoadTIFF and LoadPCX ++ added metrics handling code to FreeImageQt ++ added functions FIQT_IsLoaded, FIQT_GetVersion and FIQT_GetCopyrightMessage ++ added conversion 1 -> 16 ++ added FreeImage_SaveJPEG and JPEG quality settings ++ added FreeImage_GetBitsRowCol ++ added function FIQT_SetOutputMessage to FreeImageQt ++ added FreeImage_GetFileTypeFromExtension and FIQT_GetFileTypeFromFormat ++ added project FreeImagePy: python bindings for FreeImage + +November 7th 2000 - 1.4.3 +* fixed FreeImage_SavePNG crash bug +* fixed slighly corrupt size filter in FreeImage_Combine +* fixed FreeImage_SaveTIFF not saving 4-bit images +* [Herve Drolon] fixed bug in FreeImage_LoadTIFF +* [Herve Drolon] fixed bug in FreeImage_GetColorType +- removed fclose from FreeImage_SavePNM (who put it there?) +! rewrote FreeImage_Rotate +! FreeImageQt now automatically detects which formats are supported by Qt and which not +! FreeImage_Allocate now returns a void pointer +! FreeImage_Unload is now called FreeImage_Free ++ added 16-bit 5-5-5 support to FreeImage_LoadBMP ++ added RLE_DELTA support to FreeImage_LoadBMP ++ added directory support to FreeImage_LoadTIFF ++ added functions dealing with transparency ++ added transparency support to 8-bit PNG's in Qt ++ added FREE_IMAGE_QUANTIZE parameter to FreeImage_ColorQuantize ++ added custom FREEIMAGEHEADER header prepended to internal bitmaps ++ added new documentation + +October 18th 2000 - 1.4.2 +* fixed FreeImage_SaveBMP storing an incorrect bfSize value in the BITMAPFILEHEADER +* fixed bug where JPEG and PNG wouldn't load in FreeImageQt +* fixed FreeImage_Mirror mirroring one pixel less than needed +! FreeImage_MaskedCombine24 is now called FreeImage_MaskedCombine24Ex +! FreeImage_MaskedCombine32 is now called FreeImage_MaskedCombine32Ex ++ added 16-bit bitmap support to FreeImage_Mirror ++ added 16-bit bitmap support to FreeImage_ConvertTo8Bits ++ added simple version of FreeImage_MaskedCombine24 ++ added simple version of FreeImage_MaskedCombine32 + +October 17th 2000 - 1.4.1 +* [Herve Drolon] fixed bug in FreeImage_ConvertTo8Bits +* fixed bug in conversion with 16 -> 24 and 16 -> 32 +- removed static library support +- removed all unnecessary files from LibTIFF, LibPNG, LibJPEG and ZLib +- removed all absolute seeks from the library +! FreeImageQt now makes use of the DLL distro +! rebuilt the entire directory structure +! improved handling of BMP +! renamed FreeImage_MaskedCombine to FreeImage_MaskedCombine32 ++ [Alexander Dymerets] added 24-bit masked alpha blending with a seperate alpha mask ++ added FreeImage_Rotate (known bug in degrees 76 to 106) ++ added 4-bit bitmap support to FreeImage_ConvertTo16Bits ++ added 8-bit bitmap support to FreeImage_ConvertTo16Bits ++ added 32-bit bitmap support to FreeImage_ConvertTo16Bits ++ added 32-bit bitmap support to FreeImage_Mirror ++ added 16-bit 5-5-5 support to FreeImage_ConvertTo24Bits ++ added 16-bit 5-5-5 support to FreeImage_ConvertTo32Bits + +October 2th 2000 - 1.4.0 +* [Jani Kajala] fixed bug in conversion with 4 -> 24 and 8 -> 32 +* [Jani Kajala] fixed bug in FreeImage_Flip +* [Jani Kajala] fixed minor bug in FreeImage_LoadBMP +- [Herve Drolon] removed PBMFlags, PGMFlags and PPMFlags +- [Herve Drolon] removed FI_LoadGeneric +- removed FreeImage_Win32.h +! [Herve Drolon] changed FI_GetFileType +! [Herve Drolon] replaced FI_LoadPBM, FI_LoadPGM and FI_LoadPPM with FI_LoadPNM +! [Herve Drolon] improved FreeImage_LoadPNG +! FreeImage_WritePaletteEntry is now exported ++ [Herve Drolon] added FreeImage_SavePNG ++ [Herve Drolon] added FreeImage_SavePNM and PNMFlags ++ [Herve Drolon] added XXXFlags parameter to save functions ++ [Herve Drolon] added FreeImage_LoadRAS and FIF_RAS ++ added FreeImage_GetFileTypeFromExt + +September 7th 2000 - 1.3.5 ++ added conversion 4 -> 8 to FI_ConvertTo8Bits ++ added simple version of FI_GetFileType ++ added project FreeImageQt; a port of the library to the TrollTech library + +August 31th 2000 - 1.3.4 +* fixed 'ice effect' bug in new 24 bit PCX code +* fixed some bugs with the conversion 16 -> 24 and 16 -> 32 +! FI_Blur now returns void +! A debug build of the library now produces FreeImaged.dll and FreeImaged.lib +! TARGA_LOAD_ARGB8888 is now called TARGA_LOAD_RGB888 +! Alpha channels are now automatically loaded unless TARGA_LOAD_RGB888 is specified +! cleaned up the code a lot ++ added 32-bit bitmap support to FreeImage_ConvertToGreyscale ++ added support for 32-bit bottom-left TARGA images ++ added internal functions FreeImage_WritePaletteEntry() and FreeImage_GetScanLine() ++ added FreeImage_Win32.h, containing Windows functions needed to create DIBs ++ added documentation through Doxygen + +July 30th 2000 - 1.3.3 +* [Jani Kajala] fixed some bugs with the conversion 4 -> 24 and 8 -> 24 +* [Jani Kajala] fixed some bugs with the conversion 4 -> 32 and 8 -> 32 +* fixed bug in FI_LoadPNM's ASCII number loader +! [Herve Drolon] improved FI_LoadPNG +! [Herve Drolon] changed FI_ConvertToGreyScale (added changeable macro for conversion) +! improved FI_ConvertTo24Bits +! improved FI_ConvertTo32Bits +! freeImage now uses LibPNG 1.0.8 ++ [Herve Drolon] added FI_ColorQuantize, based on Wu's color quantizer ++ added the conversion 1 -> 24 ++ added the conversion 1 -> 32 ++ added FI_ConvertTo8Bits ++ added FI_Invert (very useful for image processing) ++ added FI_GetColorType and 'enum FREE_IMAGE_COLOR_TYPE' + +June 30th 2000 - 1.3.2 +- removed color reduction functions from the project +! [Herve Drolon] Improved FI_LoadTIFF code +! renamed FI_ToGrayscale to FI_ConvertToGreyScale +! renamed FI_IncreaseColors to FI_ConvertTo24Bits +! LoadBMP now supports 32-bit bitmaps +! [Jani Kajala] Improved FI_LoadTARGA and FI_LoadPCX code ++ added FI_ConvertTo32Bits to convert a bitmap to 32-bit ++ added FI_MaskCombine to combine two 32-bit bitmaps using a alpha mask ++ added FI_AddAlphaMask to enrich a 32-bit bitmap with an alpha mask ++ added FI_SaveTIFF ++ added 16-bit bitmap (565) support to the ConvertToXXX functions. ++ added FI_ConvertTo16Bits (555 and 565) + +June 1th 2000 - 1.3.1 +- removed Standard Template Library (STL) code +* [Jani Kajala] fixed minor bug in FI_LoadTARGA +* [Jani Kajala] fixed some minor bugs in FI_LoadPCX +! streamlined FI_LoadJPEG a little +! FreeImage now uses LibPNG 1.0.6 +! FreeImage now uses LibTIFF 3.5.5 +! FreeImage now uses malloc and free instead of new and delete ++ introduced compiler flags to disable certain features in the DLL ++ added experimental nearest color reduction (FI_ReduceColorsNearestColor) + +April 13th 2000 - 1.3.0 +* fixed some 8 bit PCX files loading incorrectly +* fixed tiny bug in internally used CalculateUsedColors function +- removed FI_SaveXPM. Only BMP is supported now. +- removed Windows dependencies for easier porting +! optimized FI_LoadKOALA a little +! optimized FI_Combine using MMX technology +! FI_Combine now receives an 'unsigned integer' as alpha blend parameter +! FI_InCreaseColors and FI_ReduceColors don't dispose the old bitmap anymore ++ added PNM support (PGM, PPM and PBM; both binary and ascii) ++ [Alexander Dymerets] added FI_EnableMMX and FI_DisableMMX ++ added various effect functions (FI_Blur, FI_Brighten and FI_Crop) + +March 1st 2000 - 1.2.1 +* fixed some 24 bit PCX files loading incorrectly + +February 8th 2000 - 1.2.0 +* fixed last bitmap data block in JPEG files being truncated +* fixed 4/8 bit BMP's incorrectly loading when the palette is smaller than the bitcount predicts +- removed FI_Load. There is no reliable way to identify all image formats +- removed FI_SetJpegDecodeMode. + Mode selection is now done using the 'DataEnum data' parameter of FI_LoadJPEG +! read_proc/write_proc/tell_proc in FreeImageIO now are same as fread/fwrite/ftell ++ added a 'DataEnum data' parameter to all FI_LoadXXX functions. ++ added 16 bit TARGA support ++ added RLE support for TARGA images ++ added FI_GetDIBSize to get the size of a DIB in bytes ++ added Kodak PhotoCD support (Base, Base/4 and Base/16 encoding) ++ added KOALA support ++ added FI_GetFileType. Note: there is no reliable way to identify TARGA, ICO and PCD. Therefore they have been excluded +In KOALA files only the files converted by a C64 emulator can be identified. ++ added FI_Combine to combine two 24-bit bitmaps with (optional) alpha blending + +January 15th 2000 - 1.1.1 +! FI_Copy is now called FI_Clone ++ added FI_ToGrayscale to convert a color bitmap to grayscale ++ added 32 bit TARGA support ++ added FI_IncreaseColors to increase the bitmap bitdepth from 4/8 bit to 24 bit + +January 14th 2000 - 1.1.0 +* FI_MIRROR: fixed nibbles not being mirrored in 4 bit images +* FI_MIRROR: fixed bits not being mirrored in 1 bit images +* fixed improper loading of 1, 4 and 8 bit OS/2 BMP's +* fixed some inconsistensies in the calculation of lines and pitches +* fixed incorrectly loading of Huffman and FAX encoded TIFFs +* fixed LoadTGA accepting 16 bit TGA's and returning corrupt DIB's +- removed LZW support for TIFFs +! FreeImage now uses LibTIFF 3.5.4 ++ added ICO support ++ added overridable file I/O support in the form of FreeImageIO and fi_handle ++ added FI_Load for generic image loading ++ added FI_ReduceColors for color reduction ++ added FI_Copy to copy a bitmap in memory + +January 5th 2000 - 1.0.0 diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/WhatsNew_Delphi.txt b/#ThirdParty/FreeImage/Wrapper/Delphi/WhatsNew_Delphi.txt new file mode 100644 index 0000000..5cce257 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/WhatsNew_Delphi.txt @@ -0,0 +1,117 @@ +What's New for FreeImage Delphi Wrapper + +* : fixed +- : removed +! : changed ++ : added + +May 5, 2014 ++ [Lorenzo Monti] updated wrapper for FreeImage 3.16.1 ++ [Lorenzo Monti] added preprocessor tests for Delphi XE2..XE6 ++ [Lorenzo Monti] merged changes for OSX compatibility (submitted by Maurício) + +December 8, 2012 ++ [Lorenzo Monti] updated wrapper for FreeImage 3.15.4 + +June 4, 2012 ++ [Lorenzo Monti] updated wrapper for FreeImage 3.15.3 + +March 4, 2011 +* [Jean-Marc Bottura] some bugfixes in FreeBitmap.pas ++ [Jean-Marc Bottura] added support for 64 bit compilers + +February 15, 2011 ++ [Lorenzo Monti] updated wrapper for FreeImage 3.15.0 + +January 4, 2011 ++ [Lorenzo Monti] updated ImagePreview demo to support latest Graphics32 components (1.9) and Delphi 2010 / XE + +November 12, 2010 ++ [Lorenzo Monti] updated wrapper for FreeImage 3.14.1 ++ [Lorenzo Monti] added Delphi XE support + +July 29, 2010 ++ [Lorenzo Monti] added Free Pascal / Lazarus 32 bit support + +July 14, 2010 ++ [Lorenzo Monti] updated wrapper for FreeImage 3.13.1 +* [Lorenzo Monti] fixed declaration of FreeImageIO functions (FI_ReadProc, FI_WriteProc, FI_SeekProc, FI_TellProc) +! [Lorenzo Monti] renamed structure PluginStruct to Plugin, according to FreeImage.h +* [Lorenzo Monti] fixed declaration of JPEG_CMYK constant +* [Lorenzo Monti] fixed declaration of type FreeImage_OutputMessageFunction +* [Lorenzo Monti] fixed declaration of FreeImage_OutputMessageProc ++ [Lorenzo Monti] added wrapper for FreeImage_OutputMessageProc for older Delphi compilers (<6) not supporting varargs +* [Lorenzo Monti] fixed declaration of FreeImage_LookupX11Color and FreeImage_LookupSVGColor +! [Lorenzo Monti] changed declaration of FreeImage_GetPixelIndex, FreeImage_GetPixelColor, FreeImage_SetPixelIndex, FreeImage_SetPixelColor +! [Lorenzo Monti] changed declaration of FreeImage_GetInfo +! [Lorenzo Monti] changed declaration of FreeImage_GetICCProfile, FreeImage_CreateICCProfile, FreeImage_DestroyICCProfile +* [Lorenzo Monti] fixed declaration of FreeImage_SetComplexChannel ++ [Lorenzo Monti] added Delphi 2010 support ++ [Lorenzo Monti] added Version.inc to determine compiler version +! [Lorenzo Monti] moved all "external" definitions to implementation section +! [Lorenzo Monti] changed FreeBitmap.pas, FreeUtils.pas and TargaImage.pas to reflect changes in the FreeImage.pas unit + +July 17, 2006 ++ [Hervé Drolon] added FIF_FAXG3 and FIF_SGI definitions, added FreeImage_MakeThumbnail definition. + +January 20, 2006 +! [Anatoliy Pulyaevskiy] updated WinBitmap demo +* [Anatoliy Pulyaevskiy] fixed TFreeBitmap.ConvertToStandartType renamed to TFreeBitmap.ConvertToStandardType +* [Anatoliy Pulyaevskiy] fixed using of SetFreeImageMarker (only for HDR dib) + +October 19, 2005 ++ [Anatoliy Pulyaevskiy] updated wrapper for FreeImage 3.8.0 ++ [Anatoliy Pulyaevskiy] added Delphi 5 support ++ [Anatoliy Pulyaevskiy] added TFreeBitmap.OnChanging event +! [Anatoliy Pulyaevskiy] changed declaration of TFreeBitmap.Assign method ++ [Anatoliy Pulyaevskiy] added TFreeBitmap.CanSave function +! [Anatoliy Pulyaevskiy] property TFreeBitmap.Dib now have read/write access ++ [Anatoliy Pulyaevskiy] added TFreeTag class incapsulating FreeImage FITAG type + +August 5, 2005 +* [kaare-nysite] fixed the prototype of FreeImage_ConvertFromRawBits + +June 21, 2005 +* [Maarten Veerman] fixed the prototype of FreeImage_OpenMultiBitmap + +February 17, 2005 - Version 1.3.0 ++ [Anatoliy Pulyaevskiy] updated the wrapper for FreeImage 3.6.0 +! [Anatoliy Pulyaevskiy] FreeImage.pas unit has been reworked + +January 14, 2005 - Version 1.2.1 ++ [Anatoliy Pulyaevskiy] updated the wrapper for FreeImage 3.5.3 ++ [Anatoliy Pulyaevskiy] added TFreeBitmap.SetHorizontalResolution and TFreeBitmap.SetVerticalResolution ++ [Anatoliy Pulyaevskiy] added TFreeBitmap.MakeThumbnail procedure ( an adapted version of function given by Enzo Costantini) ++ [Enzo Costantini] added FIU_GetFIFType utility function ++ [Enzo Costantini] added TFreeWinBitmap.CopyToBitmapH function +* [Anatoliy Pulyaevskiy] fixed TFreeBitmap.Rotate (fix from FreeImage CVS) ++ [Anatoliy Pulyaevskiy] added TFreeBitmap.ConvertToStandartType + +December 20, 2004 - Version 1.2.0 ++ [Anatoliy Pulyaevskiy] added MultiBitmap Demo +* [Anatoliy Pulyaevskiy] fixed TFreeMultiBitmap.LockPage due to error with Locking/Unlocking pages ++ [Anatoliy Pulyaevskiy] added TFreeBitmap.ConvertTo4Bits +* [Anatoliy Pulyaevskiy] TFreeBitmap.ConvertToGrayScale fixed converting bitmaps with FIC_MINISWHITE color type +* [Anatoliy Pulyaevskiy] fixed TFreeWinBitmap.DrawEx FDisplayDib deleting ++ [Anatoliy Pulyaevskiy] updated the wrapper for FreeImage 3.5.2 + +November 12, 2004 - Version 1.1.0 ++ [Anatoliy Pulyaevskiy] added TFreeBitmap.Assign(Source: PFIBITMAP) +- [Anatoliy Pulyaevskiy] removed TFreeBitmap.SetDib +! [Anatoliy Pulyaevskiy] TFreeBitmap.Dib property now read-only +* [Anatoliy Pulyaevskiy] TFreeMultiBitmap.UnlockPage implemented +* [Anatoliy Pulyaevskiy] fixed TFreeBitmap.Rescale not applies changes + +November 8, 2004 - Version 1.0.0 ++ [Anatoliy Pulyaevskiy] added Delphi version of FreeImagePlus ++ [Anatoliy Pulyaevskiy] updated the wrapper for FreeImage 3.5.0 + +January 7, 2004 ++ [Tommy] added TargaImage unit + +October 28, 2003 ++ [Peter Byström] updated the wrapper for FreeImage 3.0.2 + +August 9, 2003 ++ [Simon Beavis] added a wrapper for FreeImage 2.6.1 + diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/_clean.bat b/#ThirdParty/FreeImage/Wrapper/Delphi/_clean.bat new file mode 100644 index 0000000..43924b0 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/_clean.bat @@ -0,0 +1,13 @@ +del /S *.~* +del /S *.dcu +del /S *.dsk +del /S *.cfg +del /S *.dof +del /S *.obj +del /S *.hpp +del /S *.ddp +del /S *.mps +del /S *.mpt +del /S *.bak +del /S *.exe +del /S *.stat \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/ImagePreview.dpr b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/ImagePreview.dpr new file mode 100644 index 0000000..79fc38b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/ImagePreview.dpr @@ -0,0 +1,13 @@ +program ImagePreview; + +uses + Forms, + MainFrm in 'MainFrm.pas' {MainForm}; + +{$R *.res} + +begin + Application.Initialize; + Application.CreateForm(TMainForm, MainForm); + Application.Run; +end. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/ImagePreview.res b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/ImagePreview.res new file mode 100644 index 0000000..b40deef Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/ImagePreview.res differ diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/MainFrm.dfm b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/MainFrm.dfm new file mode 100644 index 0000000..d8cf90f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/MainFrm.dfm @@ -0,0 +1,135 @@ +object MainForm: TMainForm + Left = 304 + Top = 165 + Width = 467 + Height = 405 + Caption = 'Image Preview' + Color = clWhite + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + KeyPreview = True + OldCreateOrder = False + Position = poDesktopCenter + OnCreate = FormCreate + OnDestroy = FormDestroy + OnKeyUp = FormKeyUp + OnMouseWheel = ScrollBoxMouseWheel + OnShow = FormShow + PixelsPerInch = 96 + TextHeight = 13 + object ImgView32: TImgView32 + Left = 0 + Top = 0 + Width = 459 + Height = 371 + Align = alClient + ParentShowHint = False + PopupMenu = PopupMenu + Scale = 1 + ScrollBars.Color = clScrollBar + ScrollBars.ShowHandleGrip = True + ScrollBars.Style = rbsDefault + ShowHint = True + SizeGrip = sgAuto + TabOrder = 0 + OnScroll = ImgView32Scroll + object AlphaView: TImgView32 + Left = 8 + Top = 8 + Width = 161 + Height = 145 + Scale = 1 + ScrollBars.Color = clScrollBar + ScrollBars.ShowHandleGrip = True + ScrollBars.Style = rbsDefault + SizeGrip = sgAuto + TabOrder = 2 + Visible = False + end + end + object PopupMenu: TPopupMenu + Left = 304 + Top = 28 + object ZoomInItem: TMenuItem + Caption = 'Zoom In' + OnClick = ZoomInItemClick + end + object ZoomOutItem: TMenuItem + Caption = 'Zoom Out' + OnClick = ZoomOutItemClick + end + object ActualSizeItem: TMenuItem + Caption = 'Actual Size' + OnClick = ActualSizeItemClick + end + object N1: TMenuItem + Caption = '-' + end + object RotateClockwiseItem: TMenuItem + Caption = 'Rotate Clockwise' + OnClick = RotateClockwiseItemClick + end + object RotateAntiClockwiseItem: TMenuItem + Caption = 'Rotate Anti-Clockwise' + OnClick = RotateAntiClockwiseItemClick + end + object N4: TMenuItem + Caption = '-' + end + object FlipHorizontalItem: TMenuItem + Caption = 'Flip Horizontal' + OnClick = FlipHorizontalItemClick + end + object FilpVerticalItem: TMenuItem + Caption = 'Filp Vertical' + OnClick = FilpVerticalItemClick + end + object N3: TMenuItem + Caption = '-' + end + object ShowAlphaItem: TMenuItem + Caption = 'Show Just Alpha Channel' + OnClick = ShowAlphaItemClick + end + object ShowWithAlphaItem: TMenuItem + Caption = 'Show With Alpha Channel' + OnClick = ShowWithAlphaItemClick + end + object N2: TMenuItem + Caption = '-' + end + object OpenImageItem: TMenuItem + Caption = 'Open New Image' + OnClick = OpenImageItemClick + end + end + object FilterTimer: TTimer + Interval = 500 + OnTimer = FilterTimerTimer + Left = 308 + Top = 84 + end + object OpenDialog: TOpenDialog + Filter = + 'All image files|*.bmp;*.cut;*.ico;*.iff;*.lbm;*.jng;*.jpg;*.jpeg' + + ';*.koa;*.mng;*.pbm;*.pcd;*.pcx;*.pgm;*.png;*.ppm;*.psd;*.ras;*.t' + + 'ga;*.tif;*.tiff;.wbmp;*.xbm;*.xpm)|Windows or OS/2 Bitmap File (' + + '*.BMP)|*.BMP|Dr. Halo (*.CUT)|*.CUT|Windows Icon (*.ICO)|*.ICO|A' + + 'miga IFF (*.IFF, *.LBM)|*.IFF;*.LBM|JPEG Network Graphics (*.JNG' + + ')|*.JNG|Independent JPEG Group (*.JPG)|*.JPG|Commodore 64 Koala ' + + '(*.KOA)|*.KOA|Multiple Network Graphics (*.MNG)|*.MNG|Portable B' + + 'itmap (*.PBM)|*.PBM|Kodak PhotoCD (*.PCD)|*.PCD|PCX bitmap forma' + + 't (*.PCX)|*.PCX|Portable Graymap (*.PGM)|*.PGM|Portable Network ' + + 'Graphics (*.PNG)|*.PNG|Portable Pixelmap (*.PPM)|*.PPM|Photoshop' + + ' (*.PSD)|*.PSD|Sun Rasterfile (*.RAS)|*.RAS|Targa files (*.TGA)|' + + '*.TGA|Tagged Image File Format (*.TIF)|*.TIF;*.TIFF|Wireless Bit' + + 'map (*.WBMP)|*.WBMP|X11 Bitmap Format (*.XBM)|*.XBM|X11 Pixmap F' + + 'ormat (*.XPM)|*.XPM' + Title = 'Open Image File' + Left = 328 + Top = 228 + end +end diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/MainFrm.pas b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/MainFrm.pas new file mode 100644 index 0000000..1db403a --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/MainFrm.pas @@ -0,0 +1,524 @@ +unit MainFrm; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, Menus, ExtCtrls, Math, GR32, GR32_Image, GR32_Transforms, + ExtDlgs; + +type + TMainForm = class(TForm) + PopupMenu: TPopupMenu; + ZoomInItem: TMenuItem; + ZoomOutItem: TMenuItem; + ActualSizeItem: TMenuItem; + ImgView32: TImgView32; + N1: TMenuItem; + AlphaView: TImgView32; + ShowAlphaItem: TMenuItem; + RotateClockwiseItem: TMenuItem; + RotateAntiClockwiseItem: TMenuItem; + N3: TMenuItem; + ShowWithAlphaItem: TMenuItem; + N4: TMenuItem; + FlipHorizontalItem: TMenuItem; + FilpVerticalItem: TMenuItem; + FilterTimer: TTimer; + OpenImageItem: TMenuItem; + N2: TMenuItem; + OpenDialog: TOpenDialog; + procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure ZoomInItemClick(Sender: TObject); + procedure ZoomOutItemClick(Sender: TObject); + procedure ActualSizeItemClick(Sender: TObject); + procedure ScrollBoxMouseWheel(Sender: TObject; Shift: TShiftState; + WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); + procedure FormKeyUp(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure ShowAlphaItemClick(Sender: TObject); + procedure RotateClockwiseItemClick(Sender: TObject); + procedure RotateAntiClockwiseItemClick(Sender: TObject); + procedure ShowWithAlphaItemClick(Sender: TObject); + procedure FlipHorizontalItemClick(Sender: TObject); + procedure FilpVerticalItemClick(Sender: TObject); + procedure FilterTimerTimer(Sender: TObject); + procedure ImgView32Scroll(Sender: TObject); + procedure OpenImageItemClick(Sender: TObject); + private + { Private declarations } + OrigWidth : integer; + OrigHeight : integer; + BPP : longword; + + procedure LoadImage( Name : string); + procedure RecalcWindowSize; + public + { Public declarations } + end; + +var + MainForm: TMainForm; + +implementation + +{$R *.dfm} + +uses FreeImage, GR32_Resamplers; + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +procedure TMainForm.FormCreate(Sender: TObject); +begin + AlphaView.Visible := False; + AlphaView.Align := alClient; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.FormDestroy(Sender: TObject); +begin + // ... +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.FormShow(Sender: TObject); +var + Resampler: TKernelResampler; +begin + Resampler := TKernelResampler.Create(ImgView32.Bitmap); + Resampler.Kernel := TSplineKernel.Create; + if ParamCount = 1 then + LoadImage(ParamStr(1)); +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.LoadImage( Name : string); +var + dib : PFIBITMAP; + PBH : PBITMAPINFOHEADER; + PBI : PBITMAPINFO; + t : FREE_IMAGE_FORMAT; + Ext : string; + BM : TBitmap; + x, y : integer; + BP : PLONGWORD; + DC : HDC; +begin + try + t := FreeImage_GetFileType(PAnsiChar(AnsiString(Name)), 16); + + if t = FIF_UNKNOWN then + begin + // Check for types not supported by GetFileType + Ext := UpperCase(ExtractFileExt(Name)); + if (Ext = '.TGA') or(Ext = '.TARGA') then + t := FIF_TARGA + else if Ext = '.MNG' then + t := FIF_MNG + else if Ext = '.PCD' then + t := FIF_PCD + else if Ext = '.WBMP' then + t := FIF_WBMP + else if Ext = '.CUT' then + t := FIF_CUT + else + raise Exception.Create('The file "' + Name + '" cannot be displayed because SFM does not recognise the file type.'); + end; + + dib := FreeImage_Load(t, PAnsiChar(AnsiString(name)), 0); + if Dib = nil then + Close; + PBH := FreeImage_GetInfoHeader(dib); + PBI := FreeImage_GetInfo(dib); + + BPP := FreeImage_GetBPP(dib); + + ShowWithAlphaItem.Enabled := BPP = 32; + ShowAlphaItem.Enabled := BPP = 32; + + if BPP = 32 then + begin + ImgView32.Bitmap.SetSize(FreeImage_GetWidth(dib), FreeImage_GetHeight(dib)); + + BP := PLONGWORD(FreeImage_GetBits(dib)); + for y := ImgView32.Bitmap.Height - 1 downto 0 do + for x := 0 to ImgView32.Bitmap.Width - 1 do + begin + ImgView32.Bitmap.Pixel[x, y] := BP^; + inc(BP); + end; + end + else + begin + BM := TBitmap.Create; + + BM.Assign(nil); + DC := GetDC(Handle); + + BM.handle := CreateDIBitmap(DC, + PBH^, + CBM_INIT, + PChar(FreeImage_GetBits(dib)), + PBI^, + DIB_RGB_COLORS); + + ImgView32.Bitmap.Assign(BM); + AlphaView.Bitmap.Assign(BM); + + BM.Free; + ReleaseDC(Handle, DC); + end; + FreeImage_Unload(dib); + + OrigWidth := ImgView32.Bitmap.Width; + OrigHeight := ImgView32.Bitmap.Height; + + Caption := ExtractFileName( Name ) + ' (' + IntToStr(OrigWidth) + + ' x ' + IntToStr(OrigHeight) + ')'; + if BPP = 32 then + Caption := Caption + ' + Alpha'; + + AlphaView.Bitmap.SetSize(OrigWidth, OrigWidth); + + ImgView32.Hint := 'Name: ' + Name + #13 + + 'Width: ' + IntToStr(OrigWidth) + #13 + + 'Height: ' + IntToStr(OrigHeight) + #13 + + 'BPP: ' + IntToStr(BPP); + + RecalcWindowSize; + + Show; + except + on e:exception do + begin + Application.BringToFront; + MessageDlg(e.message, mtInformation, [mbOK], 0); + Close; + end; + end; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.ZoomInItemClick(Sender: TObject); +begin + FilterTimer.Enabled := False; + if not (ImgView32.Bitmap.Resampler is TNearestResampler) then + TNearestResampler.Create(ImgView32.Bitmap); + FilterTimer.Enabled := True; + + ImgView32.Scale := ImgView32.Scale * 2.0; + RecalcWindowSize; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.ZoomOutItemClick(Sender: TObject); +begin + FilterTimer.Enabled := False; + if not (ImgView32.Bitmap.Resampler is TNearestResampler) then + TNearestResampler.Create(ImgView32.Bitmap); + FilterTimer.Enabled := True; + + ImgView32.Scale := ImgView32.Scale / 2.0; + RecalcWindowSize; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.ActualSizeItemClick(Sender: TObject); +begin + FilterTimer.Enabled := False; + if not (ImgView32.Bitmap.Resampler is TNearestResampler) then + TNearestResampler.Create(ImgView32.Bitmap); + FilterTimer.Enabled := True; + + ImgView32.Scale := 1.0; + + RecalcWindowSize; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.RecalcWindowSize; +var + Rect : TRect; + CW, CH : integer; + WSH, WSW : integer; + TitleH : integer; + BorderY : integer; + BorderX : integer; +begin + CW := ImgView32.Bitmap.Width + GetSystemMetrics(SM_CXVSCROLL); + CH := ImgView32.Bitmap.Height + GetSystemMetrics(SM_CYVSCROLL); + + SystemParametersInfo( SPI_GETWORKAREA, 0, @Rect, 0); + + WSH := Rect.Bottom - Rect.Top; + WSW := Rect.Right - Rect.Left; + TitleH := GetSystemMetrics(SM_CYCAPTION); + BorderY := GetSystemMetrics(SM_CYSIZEFRAME) * 2; + BorderX := GetSystemMetrics(SM_CXSIZEFRAME) * 2; + + if (Top + CH + TitleH + BorderY > WSH) or (CH + TitleH + BorderY > WSH) then + begin + Top := Rect.Bottom - CH - BorderY; + if Top < 0 then + begin + Top := 0; + CH := WSH - TitleH - BorderY; + CW := CW + GetSystemMetrics(SM_CXVSCROLL); + + if CW + BorderX > WSW then + CH := CH - GetSystemMetrics(SM_CYVSCROLL); + end; + end; + + if (Left + CW + BorderX > WSW) or (CW + BorderX > WSW) then + begin + Left := Rect.Right - CW - BorderX; + if Left < 0 then + begin + Left := 0; + CW := WSW - BorderX; + CH := CH + GetSystemMetrics(SM_CYVSCROLL); + + if CH + TitleH + BorderY > WSH then + CW := CW + GetSystemMetrics(SM_CXVSCROLL); + end + end; + + ClientWidth := CW; + ClientHeight := CH; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.ScrollBoxMouseWheel(Sender: TObject; + Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; + var Handled: Boolean); +begin + FilterTimer.Enabled := False; + if not (ImgView32.Bitmap.Resampler is TNearestResampler) then + TNearestResampler.Create(ImgView32.Bitmap); + FilterTimer.Enabled := True; + + if WheelDelta < 0 then + ImgView32.Scroll(0, 20) + else + ImgView32.Scroll(0, -20); + Handled := True; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.FormKeyUp(Sender: TObject; var Key: Word; + Shift: TShiftState); +var + Amount : integer; +begin + FilterTimer.Enabled := False; + if not (ImgView32.Bitmap.Resampler is TNearestResampler) then + TNearestResampler.Create(ImgView32.Bitmap); + FilterTimer.Enabled := True; + + if ssShift in Shift then + Amount := 20 * 2 + else + Amount := 20; + + case Key of + VK_ESCAPE: + Close; + VK_UP: + ImgView32.Scroll(0, -Amount); + VK_DOWN: + ImgView32.Scroll(0, Amount); + VK_LEFT: + ImgView32.Scroll(-Amount, 0); + VK_RIGHT: + ImgView32.Scroll(Amount, 0); + VK_HOME: + ImgView32.ScrollToCenter(0, 0); + VK_END: + ImgView32.ScrollToCenter(ImgView32.Bitmap.Width, ImgView32.Bitmap.Height); + VK_NEXT: + ImgView32.Scroll(0, (Trunc(ImgView32.Bitmap.Height div 4))); + VK_PRIOR: + ImgView32.Scroll(0, -(Trunc(ImgView32.Bitmap.Height div 4))); + end; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.ShowAlphaItemClick(Sender: TObject); +var + x, y : integer; + Col : TColor32; + Alpha : TColor; +begin + if ShowAlphaItem.Checked then + begin + AlphaView.Visible := False; + AlphaView.Bitmap.Delete; + end + else + begin + AlphaView.Bitmap.Width := ImgView32.Bitmap.Width; + AlphaView.Bitmap.Height := ImgView32.Bitmap.Height; + + for x := 0 to AlphaView.Bitmap.Width - 1 do + for y := 0 to AlphaView.Bitmap.Height - 1 do + begin + Col := ImgView32.Bitmap.Pixel[x, y]; + Alpha := Col shr 24; + AlphaView.Bitmap.Pixel[x, y] := Alpha + (Alpha shl 8) + (Alpha shl 16); + end; + AlphaView.Visible := True; + end; + ShowAlphaItem.Checked := not ShowAlphaItem.Checked; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.RotateClockwiseItemClick(Sender: TObject); +var + x : integer; + y : integer; + DestX : integer; + DestY : integer; + C : TColor32; +begin + AlphaView.Bitmap.Assign(ImgView32.Bitmap); + + ImgView32.BeginUpdate; + ImgView32.Bitmap.Width := AlphaView.Bitmap.Height; + ImgView32.Bitmap.Height := AlphaView.Bitmap.Width; + + for x := 0 to AlphaView.Bitmap.Width - 1 do + for y := 0 to AlphaView.Bitmap.Height - 1 do + begin + C := AlphaView.Bitmap.Pixel[x, y]; + + DestX := (ImgView32.Bitmap.Width - 1) - Y; + DestY := X; + + ImgView32.Bitmap.Pixels[DestX, DestY] := C; + end; + + ImgView32.EndUpdate; + ImgView32.Refresh; +end; + +// ----------------------------------------------------------------------------- +procedure TMainForm.RotateAntiClockwiseItemClick(Sender: TObject); +var + x : integer; + y : integer; + DestX : integer; + DestY : integer; + C : TColor32; +begin + AlphaView.Bitmap.Assign(ImgView32.Bitmap); + + ImgView32.BeginUpdate; + ImgView32.Bitmap.Width := AlphaView.Bitmap.Height; + ImgView32.Bitmap.Height := AlphaView.Bitmap.Width; + + for x := 0 to AlphaView.Bitmap.Width - 1 do + for y := 0 to AlphaView.Bitmap.Height - 1 do + begin + C := AlphaView.Bitmap.Pixel[x, y]; + + DestX := Y; + DestY := (ImgView32.Bitmap.Height - 1) -X; + + ImgView32.Bitmap.Pixels[DestX, DestY] := C; + end; + + ImgView32.EndUpdate; + ImgView32.Refresh; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.ShowWithAlphaItemClick(Sender: TObject); +begin + if ShowWithAlphaItem.Checked then + ImgView32.Bitmap.DrawMode := dmOpaque + else + ImgView32.Bitmap.DrawMode := dmBlend; + ShowWithAlphaItem.Checked := not ShowWithAlphaItem.Checked; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.FlipHorizontalItemClick(Sender: TObject); +var + x : integer; + y : integer; + DestX : integer; + DestY : integer; + C : TColor32; +begin + AlphaView.Bitmap.Assign(ImgView32.Bitmap); + + ImgView32.BeginUpdate; + ImgView32.Bitmap.Width := AlphaView.Bitmap.Width; + ImgView32.Bitmap.Height := AlphaView.Bitmap.Height; + + for x := 0 to AlphaView.Bitmap.Width - 1 do + for y := 0 to AlphaView.Bitmap.Height - 1 do + begin + C := AlphaView.Bitmap.Pixel[x, y]; + + DestX := (ImgView32.Bitmap.Width - 1) -X; + DestY := Y; + + ImgView32.Bitmap.Pixels[DestX, DestY] := C; + end; + + ImgView32.EndUpdate; + ImgView32.Refresh; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.FilpVerticalItemClick(Sender: TObject); +var + x : integer; + y : integer; + DestX : integer; + DestY : integer; + C : TColor32; +begin + AlphaView.Bitmap.Assign(ImgView32.Bitmap); + + ImgView32.BeginUpdate; + ImgView32.Bitmap.Width := AlphaView.Bitmap.Width; + ImgView32.Bitmap.Height := AlphaView.Bitmap.Height; + + for x := 0 to AlphaView.Bitmap.Width - 1 do + for y := 0 to AlphaView.Bitmap.Height - 1 do + begin + C := AlphaView.Bitmap.Pixel[x, y]; + + DestX := X; + DestY := (ImgView32.Bitmap.Height - 1) - Y; + + ImgView32.Bitmap.Pixels[DestX, DestY] := C; + end; + + ImgView32.EndUpdate; + ImgView32.Refresh; +end; + +// ----------------------------------------------------------------------------- +procedure TMainForm.FilterTimerTimer(Sender: TObject); +var + Resampler: TKernelResampler; +begin + FilterTimer.Enabled := False; + Resampler := TKernelResampler.Create(ImgView32.Bitmap); + Resampler.Kernel := TSplineKernel.Create; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.ImgView32Scroll(Sender: TObject); +begin + FilterTimer.Enabled := False; + if not (ImgView32.Bitmap.Resampler is TNearestResampler) then + TNearestResampler.Create(ImgView32.Bitmap); + FilterTimer.Enabled := True; +end; +// ----------------------------------------------------------------------------- +procedure TMainForm.OpenImageItemClick(Sender: TObject); +begin + if OpenDialog.Execute then + begin + try + Screen.Cursor := crHourGlass; + LoadImage(OpenDialog.FileName); + finally + Screen.Cursor := crDefault; + end; + end; +end; + +end. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/Readme.txt b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/Readme.txt new file mode 100644 index 0000000..f7f1a7d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/Readme.txt @@ -0,0 +1,8 @@ +This is a simple image viewing application that uses the FreeImage library to display images in many different formats. + +The app displays the image whose name is passed in as a command line argument. + + +To compile the app you will also need the Graphics32 library available from www.g32.org. It has been tested with version 1.5.1 of Graphics32. + +SJB. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/Tiger.jpg b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/Tiger.jpg new file mode 100644 index 0000000..c152073 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/ImagePreview/Tiger.jpg differ diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/MultiBitmap.dpr b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/MultiBitmap.dpr new file mode 100644 index 0000000..f435c14 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/MultiBitmap.dpr @@ -0,0 +1,13 @@ +program MultiBitmap; + +uses + Forms, + mbMainForm in 'mbMainForm.pas' {MainForm}; + +{$R *.res} + +begin + Application.Initialize; + Application.CreateForm(TMainForm, MainForm); + Application.Run; +end. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/MultiBitmap.res b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/MultiBitmap.res new file mode 100644 index 0000000..1228533 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/MultiBitmap.res differ diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/MultiBitmap.stat b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/MultiBitmap.stat new file mode 100644 index 0000000..6e11772 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/MultiBitmap.stat @@ -0,0 +1,10 @@ +[Stats] +EditorSecs=82 +DesignerSecs=5 +InspectorSecs=1 +CompileSecs=850 +OtherSecs=5 +StartTime=20.12.2004 11:40:22 +RealKeys=0 +EffectiveKeys=0 +DebugSecs=19 diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/mbMainForm.dfm b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/mbMainForm.dfm new file mode 100644 index 0000000..5029ce7 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/mbMainForm.dfm @@ -0,0 +1,89 @@ +object MainForm: TMainForm + Left = 203 + Top = 192 + Width = 696 + Height = 480 + Caption = 'MultiBitmap Demo' + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Shell Dlg 2' + Font.Style = [] + OldCreateOrder = False + OnPaint = FormPaint + OnResize = FormResize + PixelsPerInch = 96 + TextHeight = 13 + object ToolBar: TToolBar + Left = 0 + Top = 0 + Width = 688 + Height = 25 + AutoSize = True + ButtonHeight = 21 + ButtonWidth = 33 + Caption = 'ToolBar' + EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom] + Flat = True + Indent = 3 + ShowCaptions = True + TabOrder = 0 + object tbLoad: TToolButton + Left = 3 + Top = 0 + Caption = 'Load' + ImageIndex = 0 + OnClick = tbLoadClick + end + object ToolButton1: TToolButton + Left = 36 + Top = 0 + Width = 8 + Caption = 'ToolButton1' + ImageIndex = 1 + Style = tbsSeparator + end + object tbClose: TToolButton + Left = 44 + Top = 0 + Caption = 'Close' + ImageIndex = 1 + OnClick = tbCloseClick + end + object ToolButton2: TToolButton + Left = 77 + Top = 0 + Width = 8 + Caption = 'ToolButton2' + ImageIndex = 2 + Style = tbsSeparator + end + object Label1: TLabel + Left = 85 + Top = 0 + Width = 36 + Height = 21 + Caption = 'Pages: ' + Layout = tlCenter + end + object cbPages: TComboBox + Left = 121 + Top = 0 + Width = 60 + Height = 21 + Style = csDropDownList + DropDownCount = 15 + ItemHeight = 13 + TabOrder = 0 + OnChange = cbPagesChange + end + end + object OD: TOpenDialog + Filter = 'TIFF multibitmap (*.tiff, *.tif)|*.tiff; *.tif|ICO|*.ico' + Options = [ofHideReadOnly, ofPathMustExist, ofFileMustExist, ofEnableSizing] + Title = 'Open multibitmap..' + Left = 64 + Top = 96 + end +end diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/mbMainForm.pas b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/mbMainForm.pas new file mode 100644 index 0000000..07fd997 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/MultiBitmap/mbMainForm.pas @@ -0,0 +1,150 @@ +unit mbMainForm; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ComCtrls, ToolWin, StdCtrls, FreeBitmap; + +type + TMainForm = class(TForm) + ToolBar: TToolBar; + tbLoad: TToolButton; + ToolButton1: TToolButton; + tbClose: TToolButton; + ToolButton2: TToolButton; + cbPages: TComboBox; + Label1: TLabel; + OD: TOpenDialog; + procedure tbLoadClick(Sender: TObject); + procedure FormPaint(Sender: TObject); + procedure tbCloseClick(Sender: TObject); + procedure cbPagesChange(Sender: TObject); + procedure FormResize(Sender: TObject); + private + FMultiBitmap: TFreeMultiBitmap; + FPage: TFreeWinBitmap; + + procedure PageBitmapChangeHandler(Sender: TObject); + procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + + procedure OpenMultiBitmap(const FileName: string); + procedure CloseMultiBitmap; + procedure OpenPage(Number: Integer); + end; + +var + MainForm: TMainForm; + +implementation + +{$R *.dfm} + +{ TMainForm } + +procedure TMainForm.CloseMultiBitmap; +begin + if FPage.IsValid then + FMultiBitmap.UnlockPage(Fpage, False); + FMultiBitmap.Close; + cbPages.Clear; +end; + +constructor TMainForm.Create(AOwner: TComponent); +begin + inherited; + FMultiBitmap := TFreeMultiBitmap.Create; + FPage := TFreeWinBitmap.Create; + FPage.OnChange := PageBitmapChangeHandler; +end; + +destructor TMainForm.Destroy; +begin + if FMultiBitmap.IsValid then + CloseMultiBitmap; + FMultiBitmap.Free; + inherited; +end; + +procedure TMainForm.OpenMultiBitmap(const FileName: string); +var + I, Cnt: Integer; +begin + if FMultiBitmap.IsValid then CloseMultiBitmap; + + FMultiBitmap.Open(FileName, False, True); + + Cnt := FMultiBitmap.GetPageCount; + cbPages.OnChange := nil; + cbPages.Clear; + for I := 0 to Cnt - 1 do + cbPages.Items.Add(IntToStr(I)); + cbPages.OnChange := cbPagesChange; +end; + +procedure TMainForm.OpenPage(Number: Integer); +begin + if not FMultiBitmap.IsValid then Exit; + + if FPage.IsValid then + FMultiBitmap.UnlockPage(FPage, False); + + FMultiBitmap.LockPage(Number, FPage); +end; + +procedure TMainForm.PageBitmapChangeHandler(Sender: TObject); +begin + Invalidate; +end; + +procedure TMainForm.tbLoadClick(Sender: TObject); +begin + if OD.Execute then + begin + try + OpenMultiBitmap(OD.FileName); + except + raise Exception.CreateFmt('Can not load file %s', [OD.FileName]); + end; + end; +end; + +procedure TMainForm.WMEraseBkgnd(var Message: TWMEraseBkgnd); +begin + Message.Result := 1; +end; + +procedure TMainForm.FormPaint(Sender: TObject); +begin + if not FPage.IsValid then + begin + Canvas.Brush.Color := clBtnFace; + Canvas.FillRect(ClientRect); + end + else + FPage.Draw(Canvas.Handle, ClientRect); +end; + +procedure TMainForm.tbCloseClick(Sender: TObject); +begin + if FMultiBitmap.IsValid then + CloseMultiBitmap; +end; + +procedure TMainForm.cbPagesChange(Sender: TObject); +var + Page: Integer; +begin + Page := StrToInt(cbPages.Text); + OpenPage(Page); +end; + +procedure TMainForm.FormResize(Sender: TObject); +begin + Invalidate; +end; + +end. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/TargaUnit/Readme.txt b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/TargaUnit/Readme.txt new file mode 100644 index 0000000..280c6d2 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/TargaUnit/Readme.txt @@ -0,0 +1,22 @@ +TargaImage.pas is a TGraphic descendant for Delphi. Installing it +will allow Delphi TImage and TDBImage components to read Targa files +just like BMP & WMF files with no coding on your part. + +It also adds the TGA file type to the Delphi Open/Save Picture dialog +boxes. + +To install this unit, place it in your one of your library folders +and make it available to all your Delphi projects by using +Component>Install Component from the Delphi menus. + +NOTE: any Delphi applications using this *must* have FreeImage.dll +installed in your application's folder, or somewhere in the path. + +----------------------- + +Tommy +Edinburgh, Scotland +LeTene@battlefieldeurope.org + + + diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/TargaUnit/TargaImage.pas b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/TargaUnit/TargaImage.pas new file mode 100644 index 0000000..3badc60 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/TargaUnit/TargaImage.pas @@ -0,0 +1,212 @@ +unit TargaImage; + +// ========================================================== +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// +// ========================================================== + +interface + +uses + Windows, + Classes, + FreeImage, + Graphics, + Types; + +type + TTargaImage = class(TGraphic) + private + fImage: PFIBITMAP; + fWidth: Integer; + fHeight: Integer; + protected + procedure Draw(ACanvas: TCanvas; const ARect: TRect); override; + function GetEmpty: Boolean; override; + function GetHeight: Integer; override; + function GetWidth: Integer; override; + procedure SetHeight(Value: Integer); override; + procedure SetWidth(Value: Integer); override; + public + constructor Create; override; + destructor Destroy; override; + procedure Assign(Source: TPersistent); override; + procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle; APalette: HPALETTE); override; + procedure LoadFromStream(Stream: TStream); override; + procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle; var APalette: HPALETTE); override; + procedure SaveToStream(Stream: TStream); override; + end; + + procedure Register; + +implementation + +{ Design-time registration } + +procedure Register; +begin + TPicture.RegisterFileFormat('tga', 'TARGA Files', TTargaImage); +end; + +{ IO functions } + +function FI_ReadProc(buffer : pointer; size : Cardinal; count : Cardinal; handle : fi_handle) : UInt; stdcall; +var + stream: TStream; + bytesToRead: Cardinal; +begin + stream := TStream(handle); + bytesToRead := size*count; + Result := stream.Read(buffer^, bytesToRead); +end; + +function FI_WriteProc(buffer : pointer; size, count : Cardinal; handle : fi_handle) : UInt; stdcall; +var + stream: TStream; + bytesToWrite: Cardinal; +begin + stream := TStream(handle); + bytesToWrite := size*count; + Result := stream.Write(buffer^, bytesToWrite); +end; + +function FI_SeekProc(handle : fi_handle; offset : longint; origin : integer) : Integer; stdcall; +begin + TStream(handle).Seek(offset, origin); + Result := 0; +end; + +function FI_TellProc(handle : fi_handle) : LongInt; stdcall; +begin + Result := TStream(handle).Position; +end; + +{ TTargaImage } + +constructor TTargaImage.Create; +begin + fImage := nil; + fWidth := 0; + fHeight := 0; + inherited; +end; + +destructor TTargaImage.Destroy; +begin + if Assigned(fImage) then + FreeImage_Unload(fImage); + inherited; +end; + +procedure TTargaImage.Assign(Source: TPersistent); +begin + if Source is TTargaImage then begin + fImage := FreeImage_Clone(TTargaImage(Source).fImage); + fWidth := FreeImage_GetWidth(fImage); + fHeight := FreeImage_GetHeight(fImage); + Changed(Self); + end else + inherited; +end; + +procedure TTargaImage.Draw(ACanvas: TCanvas; const ARect: TRect); +var + pbi: PBitmapInfo; +begin + if Assigned(fImage) then begin + pbi := FreeImage_GetInfo(fImage); + SetStretchBltMode(ACanvas.Handle, COLORONCOLOR); + StretchDIBits(ACanvas.Handle, ARect.left, ARect.top, + ARect.right-ARect.left, ARect.bottom-ARect.top, + 0, 0, fWidth, fHeight, + FreeImage_GetBits(fImage), pbi^, DIB_RGB_COLORS, SRCCOPY); + end; +end; + +function TTargaImage.GetEmpty: Boolean; +begin + Result := Assigned(fImage); +end; + +function TTargaImage.GetHeight: Integer; +begin + Result := fHeight; +end; + +function TTargaImage.GetWidth: Integer; +begin + Result := fWidth; +end; + +procedure TTargaImage.LoadFromClipboardFormat(AFormat: Word; AData: THandle; APalette: HPALETTE); +begin + if Assigned(fImage) then begin + end; +end; + +procedure TTargaImage.LoadFromStream(Stream: TStream); +var + io: FreeImageIO; +begin + with io do begin + read_proc := FI_ReadProc; + write_proc := FI_WriteProc; + seek_proc := FI_SeekProc; + tell_proc := FI_TellProc; + end; + fImage := FreeImage_LoadFromHandle(FIF_TARGA, @io, Stream); + if Assigned(fImage) then begin + fWidth := FreeImage_GetWidth(fImage); + fHeight := FreeImage_GetHeight(fImage); + end; +end; + +procedure TTargaImage.SaveToClipboardFormat(var AFormat: Word; var AData: THandle; var APalette: HPALETTE); +begin +end; + +procedure TTargaImage.SaveToStream(Stream: TStream); +var + io: FreeImageIO; +begin + with io do begin + read_proc := FI_ReadProc; + write_proc := FI_WriteProc; + seek_proc := FI_SeekProc; + tell_proc := FI_TellProc; + end; + FreeImage_SaveToHandle(FIF_TARGA, fImage, @io, Stream); +end; + +procedure TTargaImage.SetHeight(Value: Integer); +begin + if Assigned(fImage) then begin + fHeight := Value; + FreeImage_Rescale(fImage, fWidth, fHeight, FILTER_BICUBIC); + end; +end; + +procedure TTargaImage.SetWidth(Value: Integer); +begin + if Assigned(fImage) then begin + fWidth := Value; + FreeImage_Rescale(fImage, fWidth, fHeight, FILTER_BICUBIC); + end; +end; + +initialization + TPicture.RegisterFileFormat('tga', 'TARGA Files', TTargaImage); +end. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainDemo.dpr b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainDemo.dpr new file mode 100644 index 0000000..b8ffadd --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainDemo.dpr @@ -0,0 +1,13 @@ +program MainDemo; + +uses + Forms, + MainForm in 'MainForm.pas' {fwbMainForm}; + +{$R *.res} + +begin + Application.Initialize; + Application.CreateForm(TfwbMainForm, fwbMainForm); + Application.Run; +end. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainDemo.res b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainDemo.res new file mode 100644 index 0000000..1228533 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainDemo.res differ diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainForm.dfm b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainForm.dfm new file mode 100644 index 0000000..46d690b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainForm.dfm @@ -0,0 +1,607 @@ +object fwbMainForm: TfwbMainForm + Left = 205 + Top = 206 + Width = 696 + Height = 480 + Caption = 'FreeWinBitmap - MainDemo' + Color = clCaptionText + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + Menu = MainMenu + OldCreateOrder = False + ShowHint = True + OnCreate = FormCreate + OnDestroy = FormDestroy + OnPaint = FormPaint + OnResize = FormResize + PixelsPerInch = 96 + TextHeight = 13 + object StatusBar: TStatusBar + Left = 0 + Top = 411 + Width = 688 + Height = 23 + Panels = < + item + Alignment = taCenter + Width = 120 + end + item + Alignment = taCenter + Width = 80 + end + item + Width = 50 + end> + end + object tbTools: TToolBar + Left = 0 + Top = 0 + Width = 688 + Height = 29 + Caption = 'ToolBar' + Color = clBtnFace + EdgeBorders = [ebTop, ebBottom] + Flat = True + Images = ImageList1 + ParentColor = False + TabOrder = 1 + object ToolButton1: TToolButton + Left = 0 + Top = 0 + Width = 8 + Caption = 'ToolButton1' + ImageIndex = 1 + Style = tbsSeparator + end + object btnOpen: TToolButton + Left = 8 + Top = 0 + Hint = 'Open image file...' + Caption = 'Open...' + ImageIndex = 0 + OnClick = mnuFileOpenClick + end + object ToolButton4: TToolButton + Left = 31 + Top = 0 + Width = 8 + Caption = 'ToolButton4' + ImageIndex = 4 + Style = tbsSeparator + end + object btnCopy: TToolButton + Left = 39 + Top = 0 + Hint = 'Copy to clipboard' + Caption = 'Copy' + ImageIndex = 1 + OnClick = btnCopyClick + end + object btnPaste: TToolButton + Left = 62 + Top = 0 + Hint = 'Paste from from clipboard' + Caption = 'Paste' + ImageIndex = 2 + OnClick = btnPasteClick + end + object ToolButton3: TToolButton + Left = 85 + Top = 0 + Width = 8 + Caption = 'ToolButton3' + ImageIndex = 4 + Style = tbsSeparator + end + object btnClear: TToolButton + Left = 93 + Top = 0 + Caption = 'Clear' + ImageIndex = 3 + OnClick = btnClearClick + end + end + object MainMenu: TMainMenu + Left = 120 + Top = 48 + object mnuFile: TMenuItem + Caption = '&File' + object mnuFileOpen: TMenuItem + Caption = '&Open' + OnClick = mnuFileOpenClick + end + object mnuExit: TMenuItem + Caption = 'E&xit' + OnClick = mnuExitClick + end + end + object mnuImage: TMenuItem + Caption = 'Image' + object mnuImageFlip: TMenuItem + Caption = 'Flip' + object mnuFlipHorz: TMenuItem + Caption = 'Horizontal' + OnClick = mnuFlipHorzClick + end + object mnuFlipVert: TMenuItem + Caption = 'Vertical' + OnClick = mnuFlipHorzClick + end + end + object mnuConvert: TMenuItem + Caption = 'Convert' + object mnuTo4Bits: TMenuItem + Caption = 'To 4 Bits' + OnClick = mnuFlipHorzClick + end + object mnuTo8Bits: TMenuItem + Caption = 'To 8 Bits' + OnClick = mnuFlipHorzClick + end + object mnuTo16Bits555: TMenuItem + Caption = 'To 16 Bits (555)' + OnClick = mnuFlipHorzClick + end + object mnuTo16Bits565: TMenuItem + Caption = 'To 16 Bits (565)' + OnClick = mnuFlipHorzClick + end + object mnuTo24Bits: TMenuItem + Caption = 'To 24 Bits' + OnClick = mnuFlipHorzClick + end + object mnuTo32Bits: TMenuItem + Caption = 'To 32 Bits' + OnClick = mnuFlipHorzClick + end + object mnuDither: TMenuItem + Caption = 'Dither' + OnClick = mnuFlipHorzClick + end + object mnuQuantize: TMenuItem + Caption = 'Quantize' + OnClick = mnuFlipHorzClick + end + object mnuGrayScale: TMenuItem + Caption = 'GrayScale' + OnClick = mnuFlipHorzClick + end + end + object mnuRotate: TMenuItem + Caption = 'Rotate' + object mnuClockwise: TMenuItem + Caption = 'Clockwise' + OnClick = mnuFlipHorzClick + end + object mnuAntiClockwise: TMenuItem + Caption = 'AntiClockwise' + OnClick = mnuFlipHorzClick + end + end + object mnuInvert: TMenuItem + Caption = 'Invert' + OnClick = mnuFlipHorzClick + end + object mnuClear: TMenuItem + Caption = 'Clear' + OnClick = mnuFlipHorzClick + end + end + end + object OD: TOpenDialog + Title = 'Open file ...' + Left = 152 + Top = 48 + end + object ImageList1: TImageList + Left = 184 + Top = 48 + Bitmap = { + 494C010104000900040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 0000000000003600000028000000400000003000000001002000000000000030 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000007088900060809000607880005070 + 8000506070004058600040485000303840002030300020203000101820001010 + 1000101020000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000080685000203040002030400020304000203040002030 + 4000203040002030400020304000203040000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000DFE2F700EFF0FB0000000000000000007088900090A0B00070B0D0000090 + D0000090D0000090D0000090C0001088C0001080B0001080B0002078A0002070 + 900020486000B9BEBE0000000000000000000000000000000000000000000000 + 00000000000000000000C0704000B0583000B0583000A0502000A05020009048 + 2000904820009040200080402000000000007086900060809000506070004050 + 6000304050002030400090706000F0E0D000B0A09000B0A09000B0A09000B0A0 + 9000B0A09000B0A09000B0A0900020304000000000000000000000000000EFF1 + FF001F3BF100EFF1FF000000000000000000000000000000000000000000CFD3 + F3001F2DB900CFD2F30000000000000000008088900080C0D00090A8B00080E0 + FF0060D0FF0050C8FF0050C8FF0040C0F00030B0F00030A8F00020A0E0001090 + D00020688000656A700000000000000000000000000000000000000000000000 + 00000000000000000000C0785000FFF8F000D0B0A000D0B0A000D0B0A000C0B0 + A000C0A8A000C0A8900090402000000000007080900020B8F0000090D0000090 + D0000090D0000090D00090786000F0E8E000F0D8D000E0D0C000E0C8C000D0C0 + B000D0B8B000D0B8B000B0A09000203040000000000000000000F0F2FF00576F + FF001030FF001E34FF00EFF1FF00000000000000000000000000DFE2F7003F51 + CF000018C0000F1EB400DFE2F700000000008090A00080D0F00090A8B00090C0 + D00070D8FF0060D0FF0060D0FF0050C8FF0050C0FF0040B8F00030B0F00030A8 + F0001088D00020486000E1E4E500000000000000000000000000000000000000 + 00000000000000000000D0886000FFFFFF00E0906000D0805000D0805000D080 + 5000D0805000C0A8A00090482000000000007088900070C8F00010B8F00010B0 + F00000A8E0000098D000A0807000F0F0F000C0B0A000C0B0A000C0A8A000B0A0 + 9000D0C0B000B0A09000B0A0900020304000000000000000000000000000F1F2 + FF002D52FF001030FF000028FF00CFD5FF0000000000CFD3F3001F34C7000018 + D0000F25C300BFC5EF0000000000000000008090A00080D8F00080C8E00090A8 + B00080E0FF0070D0FF0060D8FF0060D0FF0060D0FF0050C8FF0040C0F00040B8 + F00030B0F000206880007897A50000000000B0A0900060483000604830006048 + 30006048300060483000D0907000FFFFFF00FFFFFF00FFF0F000F0E0D000F0D0 + C000F0C0B000C0B0A00090482000000000008088900070D0F00030C0F00010B8 + F00000A8F00000A0E000A0888000FFF8FF00F0F0F000F0E8E000F0D8D000E0D0 + C000705850006050400050484000404040000000000000000000000000000000 + 0000F1F2FF002D52FF001030FF000F2DFF00CFD3F6001F34D5000020E0000F25 + D200DFE2F7000000000000000000000000008098A00090E0F00090E0FF0090A8 + B00090B8C00070D8FF0060D8FF0060D8FF0060D8FF0060D0FF0050D0FF0050C8 + FF0040B8F00030A0E0004B697800DEE1E400B0A09000FFF0F000F0E0D000E0D8 + D000E0D0C000E0C8C000E0A08000FFFFFF00F0A88000E0987000E0906000D080 + 5000D0805000D0B0A000A0482000000000008090A00080D8F00040C8F00030C0 + F00010B8F00000A0E000B0908000FFFFFF00C0B0A000C0B0A000C0A8A000F0E0 + D00080605000D0C8C00060504000000000000000000000000000000000000000 + 000000000000E3E6FF005669FF001038FF000020F0000F2DF0002F42D800DFE2 + F700000000000000000000000000000000008098A00090E0F000A0E8FF0080C8 + E00090A8B00080E0FF0080E0FF0080E0FF0080E0FF0080E0FF0080E0FF0080E0 + FF0070D8FF0070D8FF0050A8D000919BA500B0A09000FFF8F000E0B08000E0A0 + 7000E0A07000D0987000E0A89000FFFFFF00FFFFFF00FFFFFF00FFF8F000F0E8 + E000F0D0C000D0B0A000A0502000000000008098A00090E0F00060D8F00050C8 + F00030C0F00010B0F000B0989000FFFFFF00FFFFFF00FFF8FF00F0F0F000F0E8 + E000806850008060500000000000000000000000000000000000000000000000 + 00000000000000000000C3CAFF002048FF001030FF000F2DF000CFD3F6000000 + 00000000000000000000000000000000000090A0A000A0E8F000A0E8FF00A0E8 + FF0090B0C00090B0C00090A8B00090A8B00080A0B00080A0B0008098A0008098 + A0008090A0008090A0008088900070889000C0A89000FFFFFF00FFF8F000F0F0 + F000F0E8E000F0E0D000E0B8A000FFFFFF00FFB09000FFB09000F0D8D000E090 + 6000B0583000B0583000A0502000000000008098A000A0E8F00080E0F00070D8 + F00050D0F00010B0F000B0A09000B0989000B0908000A0888000A08070009078 + 6000907060000000000000000000000000000000000000000000000000000000 + 000000000000CFD7FF004060FF003050FF002D4BFF001038FF000020F000DFE3 + FD000000000000000000000000000000000090A0B000A0E8F000A0F0FF00A0E8 + FF00A0E8FF0080D8FF0060D8FF0060D8FF0060D8FF0060D8FF0060D8FF0060D8 + FF0070889000000000000000000000000000C0A8A000FFFFFF00FFC8A000F0B8 + 9000E0B08000E0A07000F0C0A000FFFFFF00FFFFFF00FFFFFF00FFFFFF00F098 + 7000F0C8B000B0583000EBD5CB000000000090A0A000B0F0FF00A0E8FF0090E0 + F00070D0F00010A0D00010A0D00010A0D0001098D0000090D0000090D0000090 + D000303840000000000000000000000000000000000000000000000000000000 + 0000DBE1FF004060FF004058FF004B70FF00CFD5FF004B69FF002040FF000020 + F000CFD5FC0000000000000000000000000090A0B000A0F0F000B0F0F000A0F0 + FF00A0E8FF00A0E8FF0070D8FF0090A0A0008098A0008098A0008090A0008090 + 900070889000000000000000000000000000C0B0A000FFFFFF00FFFFFF00FFF8 + FF00FFF0F000F0E8E000F0C8B000FFFFFF00FFFFFF00FFFFFF00FFFFFF00F0A8 + 8000C0683000EFD9CB00000000000000000090A0B000B0F0FF00A0F0FF006080 + 9000607080005070800050687000506870005060700040587000207090000090 + D00040486000000000000000000000000000000000000000000000000000E7EB + FF005070FF005078FF00708AFF00E7EBFF0000000000DBDFFF004B69FF003048 + FF000020F000CFD5FC00000000000000000090A8B000A0D0E000B0F0F000B0F0 + F000A0F0FF00A0E8FF0090A0B000B3C7CB000000000000000000000000000000 + 000000000000906850009068500090685000D0B8B000FFFFFF00FFD8C000FFD0 + B000F0E0D000B0A09000F0C8B000F0C0B000F0C0B000F0B8A000F0B09000F0B0 + 9000F7E3D70000000000000000000000000090A8B000B0F0FF00B0F0FF006088 + 900090C8D00090E8F00080D8E00060C8E0005098B000405860002080A0000090 + D000505870000000000000000000000000000000000000000000F3F5FF006078 + FF006078FF00697FFF00F3F5FF00000000000000000000000000E7EAFF004B69 + FF003050FF000028FF00DFE3FD0000000000DCE3E60090A8B00090A8B00090A8 + B00090A8B00090A8B000AAB3B400000000000000000000000000000000000000 + 000000000000E1D4D2009068500090685000D0C0B000FFFFFF00FFFFFF00FFFF + FF00FFFFFF00C0A89000D0C8C00090706000E1DCD80000000000000000000000 + 00000000000000000000000000000000000090A8B000B0F0F000B0F0FF00A0F0 + F0007098A000A0F0F00060757C0080C8D000507080003060800060C0F00020B8 + F00050607000000000000000000000000000000000000000000000000000E7EB + FF006987FF00F3F5FF000000000000000000000000000000000000000000E7EA + FF005773FF00E1E5FF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000090786000B7A498000000 + 0000F9F6F600A0908000E1D9D20090786000E0C0B000FFFFFF00FFFFFF00FFFF + FF00FFFFFF00C0B0A000A0806000E1DCD8000000000000000000000000000000 + 000000000000000000000000000000000000CED8DC0090A8B00090A8B00090A8 + B0006090A000A0E8F000A0E8F00090D8E0004068700070889000808890007088 + 9000D7DADC000000000000000000000000000000000000000000000000000000 + 0000F3F5FF000000000000000000000000000000000000000000000000000000 + 0000E7EAFF000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000D1CFC900A0908000A088 + 8000B0988000CFC7BF000000000000000000E0C0B000E0C0B000D0C0B000D0C0 + B000D0B8B000D0B0A000E6DEDC00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000080B0C00080B0C00080A0B000DEE1E40000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000424D3E000000000000003E000000 + 2800000040000000300000000100010000000000800100000000000000000000 + 000000000000000000000000FFFFFF0000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000FFFFFFFFFFFFFFFF0007FFFFFC00FFF3 + 0003FC010000E3E30003FC010000C1C10001FC010000E083000100010000F007 + 000000010001F80F000000010003FC1F000000010007F80F000700010007F007 + 000700030007E08300F800070007C1C101F8007F0007E3E3FF9000FF0007F7F7 + FF8301FFF87FFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000 + 000000000000} + end +end diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainForm.pas b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainForm.pas new file mode 100644 index 0000000..41b038b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/demo/WinBitmap/MainForm.pas @@ -0,0 +1,227 @@ +unit MainForm; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, Menus, FreeBitmap, ComCtrls, ImgList, ToolWin; + +type + TfwbMainForm = class(TForm) + MainMenu: TMainMenu; + mnuFile: TMenuItem; + mnuFileOpen: TMenuItem; + mnuExit: TMenuItem; + OD: TOpenDialog; + StatusBar: TStatusBar; + mnuImage: TMenuItem; + mnuImageFlip: TMenuItem; + mnuFlipHorz: TMenuItem; + mnuFlipVert: TMenuItem; + mnuConvert: TMenuItem; + mnuTo8Bits: TMenuItem; + mnuTo16Bits555: TMenuItem; + mnuTo16Bits565: TMenuItem; + mnuTo24Bits: TMenuItem; + mnuTo32Bits: TMenuItem; + mnuDither: TMenuItem; + mnuQuantize: TMenuItem; + mnuGrayScale: TMenuItem; + mnuRotate: TMenuItem; + mnuClockwise: TMenuItem; + mnuAntiClockwise: TMenuItem; + mnuInvert: TMenuItem; + mnuClear: TMenuItem; + mnuTo4Bits: TMenuItem; + tbTools: TToolBar; + btnCopy: TToolButton; + ImageList1: TImageList; + ToolButton1: TToolButton; + btnPaste: TToolButton; + btnClear: TToolButton; + btnOpen: TToolButton; + ToolButton3: TToolButton; + ToolButton4: TToolButton; + procedure FormDestroy(Sender: TObject); + procedure FormPaint(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure mnuExitClick(Sender: TObject); + procedure mnuFileOpenClick(Sender: TObject); + procedure FormResize(Sender: TObject); + procedure mnuFlipHorzClick(Sender: TObject); + procedure btnCopyClick(Sender: TObject); + procedure btnClearClick(Sender: TObject); + procedure btnPasteClick(Sender: TObject); + private + FBitmap: TFreeWinBitmap; + procedure WMEraseBkgnd(var Message: TMessage); message WM_ERASEBKGND; + public + { Public declarations } + end; + +var + fwbMainForm: TfwbMainForm; + +implementation + +{$R *.dfm} + +uses + FreeUtils, FreeImage, Math; + +procedure TfwbMainForm.FormDestroy(Sender: TObject); +begin + if Assigned(FBitmap) then + FBitmap.Free; +end; + +procedure TfwbMainForm.FormPaint(Sender: TObject); +var + dx, dy, w, h: Integer; + r1, r2: Double; + R: TRect; +begin + if FBitmap.IsValid then // draw the bitmap + begin + // determine paint rect + r1 := FBitmap.GetWidth / FBitmap.GetHeight; + r2 := ClientWidth / ClientHeight; + if r1 > r2 then // fit by width + begin + w := ClientWidth; + h := Floor(w / r1); + dx := 0; + dy := (ClientHeight - h) div 2; + end + else // fit by height + begin + h := ClientHeight; + w := Floor(h * r1); + dy := 0; + dx := (ClientWidth - w) div 2; + end; + with ClientRect do + R := Bounds(Left + dx, Top + dy, w, h); + FBitmap.Draw(Canvas.Handle, R); + + // erase area around the image + Canvas.Brush.Color := Color; + if dx > 0 then + begin + with ClientRect do + R := Bounds(Left, Top, dx, ClientHeight); + Canvas.FillRect(R); + with ClientRect do + R := Bounds(Right - dx, Top, dx, ClientHeight); + Canvas.FillRect(R); + end else + if dy > 0 then + begin + with ClientRect do + R := Bounds(Left, Top, ClientWidth, dy); + Canvas.FillRect(R); + with ClientRect do + R := Bounds(Left, Bottom - dy, ClientWidth, dy); + Canvas.FillRect(R); + end + end + else // clear + begin + Canvas.Brush.Color := Color; + Canvas.FillRect(ClientRect); + end +end; + +procedure TfwbMainForm.FormCreate(Sender: TObject); +begin + FBitmap := TFreeWinBitmap.Create; + + mnuImage.Enabled := FBitmap.IsValid; + OD.Filter := FIU_GetAllFilters; +end; + +procedure TfwbMainForm.mnuExitClick(Sender: TObject); +begin + Close; +end; + +procedure TfwbMainForm.mnuFileOpenClick(Sender: TObject); +var + t: Cardinal; +begin + if OD.Execute then + begin + t := GetTickCount; + FBitmap.Load(OD.FileName); + t := GetTickCount - t; + mnuImage.Enabled := FBitmap.IsValid; + StatusBar.Panels[0].Text := 'Loaded in ' + IntToStr(t) + ' msec.'; + StatusBar.Panels[1].Text := Format('%dx%d', [FBitmap.GetWidth, FBitmap.GetHeight]); + Invalidate; + end; +end; + +procedure TfwbMainForm.FormResize(Sender: TObject); +begin + Invalidate +end; + +procedure TfwbMainForm.WMEraseBkgnd(var Message: TMessage); +begin + Message.Result := 1; +end; + +procedure TfwbMainForm.mnuFlipHorzClick(Sender: TObject); +begin + with FBitmap do + if Sender = mnuFlipHorz then + FLipHorizontal else + if Sender = mnuFlipVert then + FlipVertical else + if Sender = mnuTo4Bits then + ConvertTo4Bits else + if Sender = mnuTo8Bits then + ConvertTo8Bits else + if Sender = mnuTo16Bits555 then + ConvertTo16Bits555 else + if Sender = mnuTo16Bits565 then + ConvertTo16Bits565 else + if Sender = mnuTo24Bits then + ConvertTo24Bits else + if Sender = mnuTo32Bits then + ConvertTo32Bits else + if Sender = mnuDither then + Dither(FID_FS) else + if Sender = mnuQuantize then + ColorQuantize(FIQ_WUQUANT) else + if Sender = mnuGrayScale then + ConvertToGrayscale else + if Sender = mnuClockwise then + Rotate(-90) else + if Sender = mnuAntiClockwise then + Rotate(90) else + if Sender = mnuInvert then + Invert else + if Sender = mnuClear then + Clear; + Invalidate; +end; + +procedure TfwbMainForm.btnCopyClick(Sender: TObject); +begin + if FBitmap.IsValid then FBitmap.CopyToClipBoard(Handle); +end; + +procedure TfwbMainForm.btnClearClick(Sender: TObject); +begin + FBitmap.Clear; + Invalidate; +end; + +procedure TfwbMainForm.btnPasteClick(Sender: TObject); +begin + FBitmap.PasteFromClipBoard; + Invalidate; +end; + +end. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/license.txt b/#ThirdParty/FreeImage/Wrapper/Delphi/license.txt new file mode 100644 index 0000000..a930004 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/license.txt @@ -0,0 +1,3 @@ +The contents of FreeImageDW package are subject to the FreeImage Public License Version 1.0 (the "License"); you may not use this package except in compliance with the License. You may obtain a copy of the License at http://home.wxs.nl/~flvdberg/freeimage-license.txt + +Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/src/FreeBitmap.pas b/#ThirdParty/FreeImage/Wrapper/Delphi/src/FreeBitmap.pas new file mode 100644 index 0000000..582e2ae --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/src/FreeBitmap.pas @@ -0,0 +1,2187 @@ +unit FreeBitmap; + +// ========================================================== +// +// Delphi wrapper for FreeImage 3 +// +// Design and implementation by +// - Anatoliy Pulyaevskiy (xvel84@rambler.ru) +// +// Contributors: +// - Enzo Costantini (enzocostantini@libero.it) +// - Lorenzo Monti (LM) lomo74@gmail.com +// - Maurício (MAU) mauricio_box@yahoo.com - see also http://sourceforge.net/projects/tcycomponents/ +// +// Revision history +// When Who What +// ----------- ----- ----------------------------------------------------------- +// 2010-07-14 LM made RAD2010 compliant (unicode) +// 2011-03-04 JMB modifications to run on 64 bits (Windows and linux) : +// - FreeImage_RotateClassic : deprecated function, call to DeprecationManager in 64 bits crashes freeimage.dll +// ==> FreeImage_RotateClassic : replaced by FreeImage_Rotate +// modifications to run on linux : +// - exclude windows specific functions by compilation directives +// some corrections in : +// - TFreeBitmap.DoChanging +// - TFreeBitmap.IsGrayScale +// - TFreeWinBitmap.CopyFromBitmap +// - TFreeMultiBitmap.Open +// 2013-11-25 MAU Added type FreeImageAnsiString for handling accents on MAC OSX filenames/path + +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// +// ========================================================== +// +// From begining all code of this file is based on C++ wrapper to +// FreeImage - FreeImagePlus. +// +// ========================================================== + +interface + +{$I 'Version.inc'} + +uses + SysUtils, Classes, +{$IFDEF MSWINDOWS} + Windows, +{$ENDIF} + FreeImage; + +type + { TFreeObject } + + TFreeObject = class(TObject) + public + function IsValid: Boolean; virtual; + end; + + { TFreeTag } + + TFreeTag = class(TFreeObject) + private + // fields + FTag: PFITAG; + + // getters & setters + function GetCount: Cardinal; + function GetDescription: AnsiString; + function GetID: Word; + function GetKey: AnsiString; + function GetLength: Cardinal; + function GetTagType: FREE_IMAGE_MDTYPE; + function GetValue: Pointer; + procedure SetCount(const Value: Cardinal); + procedure SetDescription(const Value: AnsiString); + procedure SetID(const Value: Word); + procedure SetKey(const Value: AnsiString); + procedure SetLength(const Value: Cardinal); + procedure SetTagType(const Value: FREE_IMAGE_MDTYPE); + procedure SetValue(const Value: Pointer); + public + // construction & destruction + constructor Create(ATag: PFITAG = nil); virtual; + destructor Destroy; override; + + // methods + function Clone: TFreeTag; + function IsValid: Boolean; override; + function ToString(Model: FREE_IMAGE_MDMODEL; Make: PAnsiChar = nil): AnsiString; reintroduce; + + // properties + property Key: AnsiString read GetKey write SetKey; + property Description: AnsiString read GetDescription write SetDescription; + property ID: Word read GetID write SetID; + property TagType: FREE_IMAGE_MDTYPE read GetTagType write SetTagType; + property Count: Cardinal read GetCount write SetCount; + property Length: Cardinal read GetLength write SetLength; + property Value: Pointer read GetValue write SetValue; + property Tag: PFITAG read FTag; + end; + + { forward declarations } + + TFreeBitmap = class; + TFreeMemoryIO = class; + + { TFreeBitmap } + + TFreeBitmapChangingEvent = procedure(Sender: TFreeBitmap; var OldDib, NewDib: PFIBITMAP; var Handled: Boolean) of object; + + TFreeBitmap = class(TFreeObject) + private + // fields + FDib: PFIBITMAP; + FOnChange: TNotifyEvent; + FOnChanging: TFreeBitmapChangingEvent; + + procedure SetDib(Value: PFIBITMAP); + protected + function DoChanging(var OldDib, NewDib: PFIBITMAP): Boolean; dynamic; + function Replace(NewDib: PFIBITMAP): Boolean; dynamic; + public + constructor Create(ImageType: FREE_IMAGE_TYPE = FIT_BITMAP; Width: Integer = 0; Height: Integer = 0; Bpp: Integer = 0); + destructor Destroy; override; + function SetSize(ImageType: FREE_IMAGE_TYPE; Width, Height, Bpp: Integer; RedMask: Cardinal = 0; GreenMask: Cardinal = 0; BlueMask: Cardinal = 0): Boolean; + procedure Change; dynamic; + procedure Assign(Source: TFreeBitmap); + function CopySubImage(Left, Top, Right, Bottom: Integer; Dest: TFreeBitmap): Boolean; + function PasteSubImage(Src: TFreeBitmap; Left, Top: Integer; Alpha: Integer = 256): Boolean; + procedure Clear; virtual; + function Load(const FileName: FreeImageAnsiString; Flag: Integer = 0): Boolean; + function LoadU(const FileName: {$IFDEF DELPHI2010}string{$ELSE}WideString{$ENDIF}; Flag: Integer = 0): Boolean; + function LoadFromHandle(IO: PFreeImageIO; Handle: fi_handle; Flag: Integer = 0): Boolean; + function LoadFromMemory(MemIO: TFreeMemoryIO; Flag: Integer = 0): Boolean; + function LoadFromStream(Stream: TStream; Flag: Integer = 0): Boolean; + // save functions + function CanSave(fif: FREE_IMAGE_FORMAT): Boolean; + function Save(const FileName: FreeImageAnsiString; Flag: Integer = 0): Boolean; + function SaveU(const FileName: {$IFDEF DELPHI2010}string{$ELSE}WideString{$ENDIF}; Flag: Integer = 0): Boolean; + function SaveToHandle(fif: FREE_IMAGE_FORMAT; IO: PFreeImageIO; Handle: fi_handle; Flag: Integer = 0): Boolean; + function SaveToMemory(fif: FREE_IMAGE_FORMAT; MemIO: TFreeMemoryIO; Flag: Integer = 0): Boolean; + function SaveToStream(fif: FREE_IMAGE_FORMAT; Stream: TStream; Flag: Integer = 0): Boolean; + // image information + function GetImageType: FREE_IMAGE_TYPE; + function GetWidth: Integer; + function GetHeight: Integer; + function GetScanWidth: Integer; + function IsValid: Boolean; override; + function GetInfo: PBitmapInfo; + function GetInfoHeader: PBitmapInfoHeader; + function GetImageSize: Cardinal; + function GetBitsPerPixel: Integer; + function GetLine: Integer; + function GetHorizontalResolution: Double; + function GetVerticalResolution: Double; + procedure SetHorizontalResolution(Value: Double); + procedure SetVerticalResolution(Value: Double); + // palette operations + function GetPalette: PRGBQUAD; + function GetPaletteSize: Integer; + function GetColorsUsed: Integer; + function GetColorType: FREE_IMAGE_COLOR_TYPE; + function IsGrayScale: Boolean; + // pixels access + function AccessPixels: PByte; + function GetScanLine(ScanLine: Integer): PByte; + function GetPixelIndex(X, Y: Cardinal; var Value: Byte): Boolean; + function GetPixelColor(X, Y: Cardinal; var Value: RGBQUAD): Boolean; + function SetPixelIndex(X, Y: Cardinal; var Value: Byte): Boolean; + function SetPixelColor(X, Y: Cardinal; var Value: RGBQUAD): Boolean; + // convertion + function ConvertToStandardType(ScaleLinear: Boolean): Boolean; + function ConvertToType(ImageType: FREE_IMAGE_TYPE; ScaleLinear: Boolean): Boolean; + function Threshold(T: Byte): Boolean; + function ConvertTo4Bits: Boolean; + function ConvertTo8Bits: Boolean; + function ConvertTo16Bits555: Boolean; + function ConvertTo16Bits565: Boolean; + function ConvertTo24Bits: Boolean; + function ConvertTo32Bits: Boolean; + function ConvertToGrayscale: Boolean; + function ColorQuantize(Algorithm: FREE_IMAGE_QUANTIZE): Boolean; + function Dither(Algorithm: FREE_IMAGE_DITHER): Boolean; + function ConvertToRGBF: Boolean; + function ToneMapping(TMO: FREE_IMAGE_TMO; FirstParam, SecondParam: Double): Boolean; + // transparency + function IsTransparent: Boolean; + function GetTransparencyCount: Cardinal; + function GetTransparencyTable: PByte; + procedure SetTransparencyTable(Table: PByte; Count: Integer); + function HasFileBkColor: Boolean; + function GetFileBkColor(var BkColor: RGBQUAD): Boolean; + function SetFileBkColor(BkColor: PRGBQuad): Boolean; + // channel processing routines + function GetChannel(Bitmap: TFreeBitmap; Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean; + function SetChannel(Bitmap: TFreeBitmap; Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean; + function SplitChannels(RedChannel, GreenChannel, BlueChannel: TFreeBitmap): Boolean; + function CombineChannels(Red, Green, Blue: TFreeBitmap): Boolean; + // rotation and flipping + function RotateEx(Angle, XShift, YShift, XOrigin, YOrigin: Double; UseMask: Boolean): Boolean; + function Rotate(Angle: Double): Boolean; + function FlipHorizontal: Boolean; + function FlipVertical: Boolean; + // color manipulation routines + function Invert: Boolean; + function AdjustCurve(Lut: PByte; Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean; + function AdjustGamma(Gamma: Double): Boolean; + function AdjustBrightness(Percentage: Double): Boolean; + function AdjustContrast(Percentage: Double): Boolean; + function GetHistogram(Histo: PDWORD; Channel: FREE_IMAGE_COLOR_CHANNEL = FICC_BLACK): Boolean; + // upsampling / downsampling + procedure MakeThumbnail(const Width, Height: Integer; DestBitmap: TFreeBitmap); + function Rescale(NewWidth, NewHeight: Integer; Filter: FREE_IMAGE_FILTER; Dest: TFreeBitmap = nil): Boolean; + // metadata routines + function FindFirstMetadata(Model: FREE_IMAGE_MDMODEL; var Tag: TFreeTag): PFIMETADATA; + function FindNextMetadata(MDHandle: PFIMETADATA; var Tag: TFreeTag): Boolean; + procedure FindCloseMetadata(MDHandle: PFIMETADATA); + function SetMetadata(Model: FREE_IMAGE_MDMODEL; const Key: AnsiString; Tag: TFreeTag): Boolean; + function GetMetadata(Model: FREE_IMAGE_MDMODEL; const Key: AnsiString; var Tag: TFreeTag): Boolean; + function GetMetadataCount(Model: FREE_IMAGE_MDMODEL): Cardinal; + + // properties + property Dib: PFIBITMAP read FDib write SetDib; + property OnChange: TNotifyEvent read FOnChange write FOnChange; + property OnChanging: TFreeBitmapChangingEvent read FOnChanging write FOnChanging; + end; + + { TFreeWinBitmap } + + TFreeWinBitmap = class(TFreeBitmap) + private + FDeleteMe: Boolean; // True - need to delete FDisplayDib + FDisplayDib: PFIBITMAP; // Image that paints on DC + public + constructor Create(ImageType: FREE_IMAGE_TYPE = FIT_BITMAP; Width: Integer = 0; Height: Integer = 0; Bpp: Integer = 0); + destructor Destroy; override; + + procedure Clear; override; +{$IFDEF MSWINDOWS} + function CopyToHandle: THandle; + function CopyFromHandle(HMem: THandle): Boolean; + function CopyFromBitmap(HBmp: HBITMAP): Boolean; + function CopyToBitmapH: HBITMAP; + function CopyToClipBoard(NewOwner: HWND): Boolean; + function PasteFromClipBoard: Boolean; + function CaptureWindow(ApplicationWindow, SelectedWindow: HWND): Boolean; + + procedure Draw(DC: HDC; Rect: TRect); + procedure DrawEx(DC: HDC; Rect: TRect; UseFileBkg: Boolean = False; AppBkColor: PRGBQuad = nil; Bg: PFIBITMAP = nil); +{$ENDIF} + end; + + { TFreeMemoryIO } + + TFreeMemoryIO = class(TFreeObject) + private + FHMem: PFIMEMORY; + public + // construction and destruction + constructor Create(Data: PByte = nil; SizeInBytes: DWORD = 0); + destructor Destroy; override; + + function GetFileType: FREE_IMAGE_FORMAT; + function Read(fif: FREE_IMAGE_FORMAT; Flag: Integer = 0): PFIBITMAP; + function Write(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; Flag: Integer = 0): Boolean; + function Tell: Longint; + function Seek(Offset: Longint; Origin: Word): Boolean; + function Acquire(var Data: PByte; var SizeInBytes: DWORD): Boolean; + // overriden methods + function IsValid: Boolean; override; + end; + + { TFreeMultiBitmap } + + TFreeMultiBitmap = class(TFreeObject) + private + FMPage: PFIMULTIBITMAP; + FMemoryCache: Boolean; + public + // constructor and destructor + constructor Create(KeepCacheInMemory: Boolean = False); + destructor Destroy; override; + + // methods + function Open(const FileName: FreeImageAnsiString; CreateNew, ReadOnly: Boolean; Flags: Integer = 0): Boolean; + function Close(Flags: Integer = 0): Boolean; + function GetPageCount: Integer; + procedure AppendPage(Bitmap: TFreeBitmap); + procedure InsertPage(Page: Integer; Bitmap: TFreeBitmap); + procedure DeletePage(Page: Integer); + function MovePage(Target, Source: Integer): Boolean; + procedure LockPage(Page: Integer; DestBitmap: TFreeBitmap); + procedure UnlockPage(Bitmap: TFreeBitmap; Changed: Boolean); + function GetLockedPageNumbers(var Pages: Integer; var Count: Integer): Boolean; + // overriden methods + function IsValid: Boolean; override; + + // properties + // change of this property influences only on the next opening of a file + property MemoryCache: Boolean read FMemoryCache write FMemoryCache; + end; + +implementation + +const + ThumbSize = 150; + +// marker used for clipboard copy / paste + +procedure SetFreeImageMarker(bmih: PBitmapInfoHeader; dib: PFIBITMAP); +begin + // Windows constants goes from 0L to 5L + // Add $FF to avoid conflicts + bmih.biCompression := $FF + FreeImage_GetImageType(dib); +end; + +function GetFreeImageMarker(bmih: PBitmapInfoHeader): FREE_IMAGE_TYPE; +begin + Result := FREE_IMAGE_TYPE(bmih.biCompression - $FF); +end; + +{ TFreePersistent } + +function TFreeObject.IsValid: Boolean; +begin + Result := False +end; + +{ TFreeBitmap } + +function TFreeBitmap.AccessPixels: PByte; +begin + Result := FreeImage_GetBits(FDib) +end; + +function TFreeBitmap.AdjustBrightness(Percentage: Double): Boolean; +begin + if FDib <> nil then + begin + Result := FreeImage_AdjustBrightness(FDib, Percentage); + Change; + end + else + Result := False +end; + +function TFreeBitmap.AdjustContrast(Percentage: Double): Boolean; +begin + if FDib <> nil then + begin + Result := FreeImage_AdjustContrast(FDib, Percentage); + Change; + end + else + Result := False +end; + +function TFreeBitmap.AdjustCurve(Lut: PByte; + Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean; +begin + if FDib <> nil then + begin + Result := FreeImage_AdjustCurve(FDib, Lut, Channel); + Change; + end + else + Result := False +end; + +function TFreeBitmap.AdjustGamma(Gamma: Double): Boolean; +begin + if FDib <> nil then + begin + Result := FreeImage_AdjustGamma(FDib, Gamma); + Change; + end + else + Result := False +end; + +procedure TFreeBitmap.Assign(Source: TFreeBitmap); +var + SourceBmp: TFreeBitmap; + Clone: PFIBITMAP; +begin + if Source = nil then + begin + Clear; + Exit; + end; + + if Source is TFreeBitmap then + begin + SourceBmp := TFreeBitmap(Source); + if SourceBmp <> Self then + begin + if SourceBmp.IsValid then + begin + Clone := FreeImage_Clone(SourceBmp.FDib); + Replace(Clone); + end + else + Clear; + end; + end; +end; + +function TFreeBitmap.CanSave(fif: FREE_IMAGE_FORMAT): Boolean; +var + ImageType: FREE_IMAGE_TYPE; + Bpp: Word; +begin + Result := False; + if not IsValid then Exit; + + if fif <> FIF_UNKNOWN then + begin + // check that the dib can be saved in this format + ImageType := FreeImage_GetImageType(FDib); + if ImageType = FIT_BITMAP then + begin + // standard bitmap type + Bpp := FreeImage_GetBPP(FDib); + Result := FreeImage_FIFSupportsWriting(fif) + and FreeImage_FIFSupportsExportBPP(fif, Bpp); + end + else // special bitmap type + Result := FreeImage_FIFSupportsExportType(fif, ImageType); + end; +end; + +procedure TFreeBitmap.Change; +begin + if Assigned(FOnChange) then FOnChange(Self) +end; + +procedure TFreeBitmap.Clear; +begin + if FDib <> nil then + begin + FreeImage_Unload(FDib); + FDib := nil; + Change; + end; +end; + +function TFreeBitmap.ColorQuantize( + Algorithm: FREE_IMAGE_QUANTIZE): Boolean; +var + dib8: PFIBITMAP; +begin + if FDib <> nil then + begin + dib8 := FreeImage_ColorQuantize(FDib, Algorithm); + Result := Replace(dib8); + end + else + Result := False; +end; + +function TFreeBitmap.CombineChannels(Red, Green, + Blue: TFreeBitmap): Boolean; +var + Width, Height: Integer; +begin + if FDib = nil then + begin + Width := Red.GetWidth; + Height := Red.GetHeight; + FDib := FreeImage_Allocate(Width, Height, 24, FI_RGBA_RED_MASK, + FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + end; + + if FDib <> nil then + begin + Result := FreeImage_SetChannel(FDib, Red.FDib, FICC_RED) and + FreeImage_SetChannel(FDib, Green.FDib, FICC_GREEN) and + FreeImage_SetChannel(FDib, Blue.FDib, FICC_BLUE); + + Change + end + else + Result := False; +end; + +function TFreeBitmap.ConvertTo16Bits555: Boolean; +var + dib16_555: PFIBITMAP; +begin + if FDib <> nil then + begin + dib16_555 := FreeImage_ConvertTo16Bits555(FDib); + Result := Replace(dib16_555); + end + else + Result := False +end; + +function TFreeBitmap.ConvertTo16Bits565: Boolean; +var + dib16_565: PFIBITMAP; +begin + if FDib <> nil then + begin + dib16_565 := FreeImage_ConvertTo16Bits565(FDib); + Result := Replace(dib16_565); + end + else + Result := False +end; + +function TFreeBitmap.ConvertTo24Bits: Boolean; +var + dibRGB: PFIBITMAP; +begin + if FDib <> nil then + begin + dibRGB := FreeImage_ConvertTo24Bits(FDib); + Result := Replace(dibRGB); + end + else + Result := False +end; + +function TFreeBitmap.ConvertTo32Bits: Boolean; +var + dib32: PFIBITMAP; +begin + if FDib <> nil then + begin + dib32 := FreeImage_ConvertTo32Bits(FDib); + Result := Replace(dib32); + end + else + Result := False +end; + +function TFreeBitmap.ConvertTo4Bits: Boolean; +var + dib4: PFIBITMAP; +begin + Result := False; + if IsValid then + begin + dib4 := FreeImage_ConvertTo4Bits(FDib); + Result := Replace(dib4); + end; +end; + +function TFreeBitmap.ConvertTo8Bits: Boolean; +var + dib8: PFIBITMAP; +begin + if FDib <> nil then + begin + dib8 := FreeImage_ConvertTo8Bits(FDib); + Result := Replace(dib8); + end + else + Result := False +end; + +function TFreeBitmap.ConvertToGrayscale: Boolean; +var + dib8: PFIBITMAP; +begin + Result := False; + + if IsValid then + begin + dib8 := FreeImage_ConvertToGreyscale(FDib); + Result := Replace(dib8); + end +end; + +function TFreeBitmap.ConvertToRGBF: Boolean; +var + ImageType: FREE_IMAGE_TYPE; + NewDib: PFIBITMAP; +begin + Result := False; + if not IsValid then Exit; + + ImageType := GetImageType; + + if (ImageType = FIT_BITMAP) then + begin + if GetBitsPerPixel < 24 then + if not ConvertTo24Bits then + Exit + end; + NewDib := FreeImage_ConvertToRGBF(FDib); + Result := Replace(NewDib); +end; + +function TFreeBitmap.ConvertToStandardType(ScaleLinear: Boolean): Boolean; +var + dibStandard: PFIBITMAP; +begin + if IsValid then + begin + dibStandard := FreeImage_ConvertToStandardType(FDib, ScaleLinear); + Result := Replace(dibStandard); + end + else + Result := False; +end; + +function TFreeBitmap.ConvertToType(ImageType: FREE_IMAGE_TYPE; + ScaleLinear: Boolean): Boolean; +var + dib: PFIBITMAP; +begin + if FDib <> nil then + begin + dib := FreeImage_ConvertToType(FDib, ImageType, ScaleLinear); + Result := Replace(dib) + end + else + Result := False +end; + +function TFreeBitmap.CopySubImage(Left, Top, Right, Bottom: Integer; + Dest: TFreeBitmap): Boolean; +begin + if FDib <> nil then + begin + Dest.FDib := FreeImage_Copy(FDib, Left, Top, Right, Bottom); + Result := Dest.IsValid; + end else + Result := False; +end; + +constructor TFreeBitmap.Create(ImageType: FREE_IMAGE_TYPE; Width, Height, + Bpp: Integer); +begin + inherited Create; + + FDib := nil; + if (Width > 0) and (Height > 0) and (Bpp > 0) then + SetSize(ImageType, Width, Height, Bpp); +end; + +destructor TFreeBitmap.Destroy; +begin + if FDib <> nil then + FreeImage_Unload(FDib); + inherited; +end; + +function TFreeBitmap.Dither(Algorithm: FREE_IMAGE_DITHER): Boolean; +var + dib: PFIBITMAP; +begin + if FDib <> nil then + begin + dib := FreeImage_Dither(FDib, Algorithm); + Result := Replace(dib); + end + else + Result := False; +end; + +function TFreeBitmap.DoChanging(var OldDib, NewDib: PFIBITMAP): Boolean; +begin + Result := False; + if (OldDib <> NewDib) and Assigned(FOnChanging) then + FOnChanging(Self, OldDib, NewDib, Result); +end; + +procedure TFreeBitmap.FindCloseMetadata(MDHandle: PFIMETADATA); +begin + FreeImage_FindCloseMetadata(MDHandle); +end; + +function TFreeBitmap.FindFirstMetadata(Model: FREE_IMAGE_MDMODEL; + var Tag: TFreeTag): PFIMETADATA; +begin + Result := FreeImage_FindFirstMetadata(Model, FDib, Tag.FTag); +end; + +function TFreeBitmap.FindNextMetadata(MDHandle: PFIMETADATA; + var Tag: TFreeTag): Boolean; +begin + Result := FreeImage_FindNextMetadata(MDHandle, Tag.FTag); +end; + +function TFreeBitmap.FlipHorizontal: Boolean; +begin + if FDib <> nil then + begin + Result := FreeImage_FlipHorizontal(FDib); + Change; + end + else + Result := False +end; + +function TFreeBitmap.FlipVertical: Boolean; +begin + if FDib <> nil then + begin + Result := FreeImage_FlipVertical(FDib); + Change; + end + else + Result := False +end; + +function TFreeBitmap.GetBitsPerPixel: Integer; +begin + Result := FreeImage_GetBPP(FDib) +end; + +function TFreeBitmap.GetChannel(Bitmap: TFreeBitmap; + Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean; +begin + if FDib <> nil then + begin + Bitmap.Dib := FreeImage_GetChannel(FDib, Channel); + Result := Bitmap.IsValid; + end + else + Result := False +end; + +function TFreeBitmap.GetColorsUsed: Integer; +begin + Result := FreeImage_GetColorsUsed(FDib) +end; + +function TFreeBitmap.GetColorType: FREE_IMAGE_COLOR_TYPE; +begin + Result := FreeImage_GetColorType(FDib); +end; + +function TFreeBitmap.GetFileBkColor(var BkColor: RGBQUAD): Boolean; +begin + Result := FreeImage_GetBackgroundColor(FDib, BkColor); +end; + +function TFreeBitmap.GetHeight: Integer; +begin + Result := FreeImage_GetHeight(FDib) +end; + +function TFreeBitmap.GetHistogram(Histo: PDWORD; + Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean; +begin + if FDib <> nil then + Result := FreeImage_GetHistogram(FDib, Histo, Channel) + else + Result := False +end; + +function TFreeBitmap.GetHorizontalResolution: Double; +begin + Result := FreeImage_GetDotsPerMeterX(FDib) / 100 +end; + +function TFreeBitmap.GetImageSize: Cardinal; +begin + Result := FreeImage_GetDIBSize(FDib); +end; + +function TFreeBitmap.GetImageType: FREE_IMAGE_TYPE; +begin + Result := FreeImage_GetImageType(FDib); +end; + +function TFreeBitmap.GetInfo: PBitmapInfo; +begin + Result := FreeImage_GetInfo(FDib); +end; + +function TFreeBitmap.GetInfoHeader: PBITMAPINFOHEADER; +begin + Result := FreeImage_GetInfoHeader(FDib) +end; + +function TFreeBitmap.GetLine: Integer; +begin + Result := FreeImage_GetLine(FDib) +end; + +function TFreeBitmap.GetMetadata(Model: FREE_IMAGE_MDMODEL; + const Key: AnsiString; var Tag: TFreeTag): Boolean; +begin + Result := FreeImage_GetMetadata(Model, FDib, PAnsiChar(Key), Tag.FTag); +end; + +function TFreeBitmap.GetMetadataCount(Model: FREE_IMAGE_MDMODEL): Cardinal; +begin + Result := FreeImage_GetMetadataCount(Model, FDib); +end; + +function TFreeBitmap.GetPalette: PRGBQUAD; +begin + Result := FreeImage_GetPalette(FDib) +end; + +function TFreeBitmap.GetPaletteSize: Integer; +begin + Result := FreeImage_GetColorsUsed(FDib) * SizeOf(RGBQUAD) +end; + +function TFreeBitmap.GetPixelColor(X, Y: Cardinal; + var Value: RGBQUAD): Boolean; +begin + Result := FreeImage_GetPixelColor(FDib, X, Y, Value); +end; + +function TFreeBitmap.GetPixelIndex(X, Y: Cardinal; + var Value: Byte): Boolean; +begin + Result := FreeImage_GetPixelIndex(FDib, X, Y, Value); +end; + +function TFreeBitmap.GetScanLine(ScanLine: Integer): PByte; +var + H: Integer; +begin + H := FreeImage_GetHeight(FDib); + if ScanLine < H then + Result := FreeImage_GetScanLine(FDib, ScanLine) + else + Result := nil; +end; + +function TFreeBitmap.GetScanWidth: Integer; +begin + Result := FreeImage_GetPitch(FDib) +end; + +function TFreeBitmap.GetTransparencyCount: Cardinal; +begin + Result := FreeImage_GetTransparencyCount(FDib) +end; + +function TFreeBitmap.GetTransparencyTable: PByte; +begin + Result := FreeImage_GetTransparencyTable(FDib) +end; + +function TFreeBitmap.GetVerticalResolution: Double; +begin + Result := FreeImage_GetDotsPerMeterY(Fdib) / 100 +end; + +function TFreeBitmap.GetWidth: Integer; +begin + Result := FreeImage_GetWidth(FDib) +end; + +function TFreeBitmap.HasFileBkColor: Boolean; +begin + Result := FreeImage_HasBackgroundColor(FDib) +end; + +function TFreeBitmap.Invert: Boolean; +begin + if FDib <> nil then + begin + Result := FreeImage_Invert(FDib); + Change; + end + else + Result := False +end; + +function TFreeBitmap.IsGrayScale: Boolean; +begin + Result := (FreeImage_GetBPP(FDib) = 8) +// modif JMB NOVAXEL +// FIC_PALETTE isn't enough to tell the bitmap is grayscale +// and (FreeImage_GetColorType(FDib) = FIC_PALETTE); + and ((FreeImage_GetColorType(FDib) = FIC_MINISBLACK) or + (FreeImage_GetColorType(FDib) = FIC_MINISWHITE)); +// end of modif JMB NOVAXEL +end; + +function TFreeBitmap.IsTransparent: Boolean; +begin + Result := FreeImage_IsTransparent(FDib); +end; + +function TFreeBitmap.IsValid: Boolean; +begin + Result := FDib <> nil +end; + +function TFreeBitmap.Load(const FileName: FreeImageAnsiString; Flag: Integer): Boolean; +var + fif: FREE_IMAGE_FORMAT; +begin + + // check the file signature and get its format + fif := FreeImage_GetFileType(PAnsiChar(FileName), 0); + if fif = FIF_UNKNOWN then + // no signature? + // try to guess the file format from the file extention + fif := FreeImage_GetFIFFromFilename(PAnsiChar(FileName)); + + // check that the plugin has reading capabilities ... + if (fif <> FIF_UNKNOWN) and FreeImage_FIFSupportsReading(FIF) then + begin + // free the previous dib + if FDib <> nil then + FreeImage_Unload(dib); + + // load the file + FDib := FreeImage_Load(fif, PAnsiChar(FileName), Flag); + + Change; + Result := IsValid; + end else + Result := False; +end; + +function TFreeBitmap.LoadFromHandle(IO: PFreeImageIO; Handle: fi_handle; + Flag: Integer): Boolean; +var + fif: FREE_IMAGE_FORMAT; +begin + // check the file signature and get its format + fif := FreeImage_GetFileTypeFromHandle(IO, Handle, 16); + if (fif <> FIF_UNKNOWN) and FreeImage_FIFSupportsReading(fif) then + begin + // free the previous dib + if FDib <> nil then + FreeImage_Unload(FDib); + + // load the file + FDib := FreeImage_LoadFromHandle(fif, IO, Handle, Flag); + + Change; + Result := IsValid; + end else + Result := False; +end; + +function TFreeBitmap.LoadFromMemory(MemIO: TFreeMemoryIO; + Flag: Integer): Boolean; +var + fif: FREE_IMAGE_FORMAT; +begin + + // check the file signature and get its format + fif := MemIO.GetFileType; + if (fif <> FIF_UNKNOWN) and FreeImage_FIFSupportsReading(fif) then + begin + // free the previous dib + if FDib <> nil then + FreeImage_Unload(FDib); + + // load the file + FDib := MemIO.Read(fif, Flag); + + Result := IsValid; + Change; + end else + Result := False; +end; + +function TFreeBitmap.LoadFromStream(Stream: TStream; + Flag: Integer): Boolean; +var + MemIO: TFreeMemoryIO; + Data: PByte; + MemStream: TMemoryStream; + Size: Cardinal; +begin + Size := Stream.Size; + + MemStream := TMemoryStream.Create; + try + MemStream.CopyFrom(Stream, Size); + Data := MemStream.Memory; + + MemIO := TFreeMemoryIO.Create(Data, Size); + try + Result := LoadFromMemory(MemIO); + finally + MemIO.Free; + end; + finally + MemStream.Free; + end; +end; + +function TFreeBitmap.LoadU(const FileName: {$IFDEF DELPHI2010}string{$ELSE}WideString{$ENDIF}; + Flag: Integer): Boolean; +var + fif: FREE_IMAGE_FORMAT; +begin + + // check the file signature and get its format + fif := FreeImage_GetFileTypeU(PWideChar(Filename), 0); + if fif = FIF_UNKNOWN then + // no signature? + // try to guess the file format from the file extention + fif := FreeImage_GetFIFFromFilenameU(PWideChar(FileName)); + + // check that the plugin has reading capabilities ... + if (fif <> FIF_UNKNOWN) and FreeImage_FIFSupportsReading(FIF) then + begin + // free the previous dib + if FDib <> nil then + FreeImage_Unload(dib); + + // load the file + FDib := FreeImage_LoadU(fif, PWideChar(FileName), Flag); + + Change; + Result := IsValid; + end else + Result := False; +end; + +procedure TFreeBitmap.MakeThumbnail(const Width, Height: Integer; + DestBitmap: TFreeBitmap); +type + PRGB24 = ^TRGB24; + TRGB24 = packed record + B: Byte; + G: Byte; + R: Byte; + end; +var + x, y, ix, iy: integer; + x1, x2, x3: integer; + + xscale, yscale: single; + iRed, iGrn, iBlu, iRatio: Longword; + p, c1, c2, c3, c4, c5: TRGB24; + pt, pt1: PRGB24; + iSrc, iDst, s1: integer; + i, j, r, g, b, tmpY: integer; + + RowDest, RowSource, RowSourceStart: integer; + w, h: Integer; + dxmin, dymin: integer; + ny1, ny2, ny3: integer; + dx, dy: integer; + lutX, lutY: array of integer; + + SrcBmp, DestBmp: PFIBITMAP; +begin + if not IsValid then Exit; + + if (GetWidth <= ThumbSize) and (GetHeight <= ThumbSize) then + begin + DestBitmap.Assign(Self); + Exit; + end; + + w := Width; + h := Height; + + // prepare bitmaps + if GetBitsPerPixel <> 24 then + SrcBmp := FreeImage_ConvertTo24Bits(FDib) + else + SrcBmp := FDib; + DestBmp := FreeImage_Allocate(w, h, 24); + Assert(DestBmp <> nil, 'TFreeBitmap.MakeThumbnail error'); + +{ iDst := (w * 24 + 31) and not 31; + iDst := iDst div 8; //BytesPerScanline + iSrc := (GetWidth * 24 + 31) and not 31; + iSrc := iSrc div 8; +} + // BytesPerScanline + iDst := FreeImage_GetPitch(DestBmp); + iSrc := FreeImage_GetPitch(SrcBmp); + + xscale := 1 / (w / FreeImage_GetWidth(SrcBmp)); + yscale := 1 / (h / FreeImage_GetHeight(SrcBmp)); + + // X lookup table + SetLength(lutX, w); + x1 := 0; + x2 := trunc(xscale); + for x := 0 to w - 1 do + begin + lutX[x] := x2 - x1; + x1 := x2; + x2 := trunc((x + 2) * xscale); + end; + + // Y lookup table + SetLength(lutY, h); + x1 := 0; + x2 := trunc(yscale); + for x := 0 to h - 1 do + begin + lutY[x] := x2 - x1; + x1 := x2; + x2 := trunc((x + 2) * yscale); + end; + + Dec(w); + Dec(h); + RowDest := integer(FreeImage_GetScanLine(DestBmp, 0)); + RowSourceStart := integer(FreeImage_GetScanLine(SrcBmp, 0)); + RowSource := RowSourceStart; + + for y := 0 to h do + // resampling + begin + dy := lutY[y]; + x1 := 0; + x3 := 0; + for x := 0 to w do // loop through row + begin + dx:= lutX[x]; + iRed:= 0; + iGrn:= 0; + iBlu:= 0; + RowSource := RowSourceStart; + for iy := 1 to dy do + begin + pt := PRGB24(RowSource + x1); + for ix := 1 to dx do + begin + iRed := iRed + pt.R; + iGrn := iGrn + pt.G; + iBlu := iBlu + pt.B; + inc(pt); + end; + RowSource := RowSource + iSrc; + end; + iRatio := 65535 div (dx * dy); + pt1 := PRGB24(RowDest + x3); + pt1.R := (iRed * iRatio) shr 16; + pt1.G := (iGrn * iRatio) shr 16; + pt1.B := (iBlu * iRatio) shr 16; + x1 := x1 + 3 * dx; + inc(x3,3); + end; + RowDest := RowDest + iDst; + RowSourceStart := RowSource; + end; // resampling + + if FreeImage_GetHeight(DestBmp) >= 3 then + // Sharpening... + begin + s1 := integer(FreeImage_GetScanLine(DestBmp, 0)); + iDst := integer(FreeImage_GetScanLine(DestBmp, 1)) - s1; + ny1 := Integer(s1); + ny2 := ny1 + iDst; + ny3 := ny2 + iDst; + for y := 1 to FreeImage_GetHeight(DestBmp) - 2 do + begin + for x := 0 to FreeImage_GetWidth(DestBmp) - 3 do + begin + x1 := x * 3; + x2 := x1 + 3; + x3 := x1 + 6; + + c1 := pRGB24(ny1 + x1)^; + c2 := pRGB24(ny1 + x3)^; + c3 := pRGB24(ny2 + x2)^; + c4 := pRGB24(ny3 + x1)^; + c5 := pRGB24(ny3 + x3)^; + + r := (c1.R + c2.R + (c3.R * -12) + c4.R + c5.R) div -8; + g := (c1.G + c2.G + (c3.G * -12) + c4.G + c5.G) div -8; + b := (c1.B + c2.B + (c3.B * -12) + c4.B + c5.B) div -8; + + if r < 0 then r := 0 else if r > 255 then r := 255; + if g < 0 then g := 0 else if g > 255 then g := 255; + if b < 0 then b := 0 else if b > 255 then b := 255; + + pt1 := pRGB24(ny2 + x2); + pt1.R := r; + pt1.G := g; + pt1.B := b; + end; + inc(ny1, iDst); + inc(ny2, iDst); + inc(ny3, iDst); + end; + end; // sharpening + + if SrcBmp <> FDib then + FreeImage_Unload(SrcBmp); + DestBitmap.Replace(DestBmp); +end; + +function TFreeBitmap.PasteSubImage(Src: TFreeBitmap; Left, Top, + Alpha: Integer): Boolean; +begin + if FDib <> nil then + begin + Result := FreeImage_Paste(FDib, Src.Dib, Left, Top, Alpha); + Change; + end else + Result := False; +end; + +function TFreeBitmap.Replace(NewDib: PFIBITMAP): Boolean; +begin + Result := False; + if NewDib = nil then Exit; + + if not DoChanging(FDib, NewDib) and IsValid then + FreeImage_Unload(FDib); + + FDib := NewDib; + Result := True; + Change; +end; + +function TFreeBitmap.Rescale(NewWidth, NewHeight: Integer; + Filter: FREE_IMAGE_FILTER; Dest: TFreeBitmap): Boolean; +var + Bpp: Integer; + DstDib: PFIBITMAP; +begin + Result := False; + + if FDib <> nil then + begin + Bpp := FreeImage_GetBPP(FDib); + + if Bpp < 8 then + if not ConvertToGrayscale then Exit + else + if Bpp = 16 then + // convert to 24-bit + if not ConvertTo24Bits then Exit; + + // perform upsampling / downsampling + DstDib := FreeImage_Rescale(FDib, NewWidth, NewHeight, Filter); + if Dest = nil then + Result := Replace(DstDib) + else + Result := Dest.Replace(DstDib) + end +end; + +function TFreeBitmap.Rotate(Angle: Double): Boolean; +var + Bpp: Integer; + Rotated: PFIBITMAP; +begin + Result := False; + if IsValid then + begin + Bpp := FreeImage_GetBPP(FDib); + if Bpp in [1, 8, 24, 32] then + begin +// modif JMB : FreeImage_RotateClassic : deprecated function, call to DeprecationManager in 64 bits crash freeimage.dll + //Rotated := FreeImage_RotateClassic(FDib, Angle); + Rotated := FreeImage_Rotate(FDib, Angle, nil); +// end of modif JMB + //Rotated := FreeImage_Rotate(FDib, Angle); + Result := Replace(Rotated); + end + end; +end; + +function TFreeBitmap.RotateEx(Angle, XShift, YShift, XOrigin, + YOrigin: Double; UseMask: Boolean): Boolean; +var + Rotated: PFIBITMAP; +begin + Result := False; + if FDib <> nil then + begin + if FreeImage_GetBPP(FDib) >= 8 then + begin + Rotated := FreeImage_RotateEx(FDib, Angle, XShift, YShift, XOrigin, YOrigin, UseMask); + Result := Replace(Rotated); + end + end; +end; + +function TFreeBitmap.Save(const FileName: FreeImageAnsiString; Flag: Integer): Boolean; +var + fif: FREE_IMAGE_FORMAT; +begin + Result := False; + + // try to guess the file format from the file extension + fif := FreeImage_GetFIFFromFilename(PAnsiChar(FileName)); + if CanSave(fif) then + Result := FreeImage_Save(fif, FDib, PAnsiChar(FileName), Flag); +end; + +function TFreeBitmap.SaveToHandle(fif: FREE_IMAGE_FORMAT; IO: PFreeImageIO; + Handle: fi_handle; Flag: Integer): Boolean; +begin + Result := False; + if CanSave(fif) then + Result := FreeImage_SaveToHandle(fif, FDib, IO, Handle, Flag) +end; + +function TFreeBitmap.SaveToMemory(fif: FREE_IMAGE_FORMAT; + MemIO: TFreeMemoryIO; Flag: Integer): Boolean; +begin + Result := False; + + if CanSave(fif) then + Result := MemIO.Write(fif, FDib, Flag) +end; + +function TFreeBitmap.SaveToStream(fif: FREE_IMAGE_FORMAT; Stream: TStream; + Flag: Integer): Boolean; +var + MemIO: TFreeMemoryIO; + Data: PByte; + Size: Cardinal; +begin + MemIO := TFreeMemoryIO.Create; + try + Result := SaveToMemory(fif, MemIO, Flag); + if Result then + begin + MemIO.Acquire(Data, Size); + Stream.WriteBuffer(Data^, Size); + end; + finally + MemIO.Free; + end; +end; + +function TFreeBitmap.SaveU(const FileName: {$IFDEF DELPHI2010}string{$ELSE}WideString{$ENDIF}; + Flag: Integer): Boolean; +var + fif: FREE_IMAGE_FORMAT; +begin + Result := False; + + // try to guess the file format from the file extension + fif := FreeImage_GetFIFFromFilenameU(PWideChar(Filename)); + if CanSave(fif) then + Result := FreeImage_SaveU(fif, FDib, PWideChar(FileName), Flag); +end; + +function TFreeBitmap.SetChannel(Bitmap: TFreeBitmap; + Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean; +begin + if FDib <> nil then + begin + Result := FreeImage_SetChannel(FDib, Bitmap.FDib, Channel); + Change; + end + else + Result := False +end; + +procedure TFreeBitmap.SetDib(Value: PFIBITMAP); +begin + Replace(Value); +end; + +function TFreeBitmap.SetFileBkColor(BkColor: PRGBQuad): Boolean; +begin + Result := FreeImage_SetBackgroundColor(FDib, BkColor); + Change; +end; + +procedure TFreeBitmap.SetHorizontalResolution(Value: Double); +begin + if IsValid then + begin + FreeImage_SetDotsPerMeterX(FDib, Trunc(Value * 100 + 0.5)); + Change; + end; +end; + +function TFreeBitmap.SetMetadata(Model: FREE_IMAGE_MDMODEL; + const Key: AnsiString; Tag: TFreeTag): Boolean; +begin + Result := FreeImage_SetMetadata(Model, FDib, PAnsiChar(Key), Tag.Tag); +end; + +function TFreeBitmap.SetPixelColor(X, Y: Cardinal; + var Value: RGBQUAD): Boolean; +begin + Result := FreeImage_SetPixelColor(FDib, X, Y, Value); + Change; +end; + +function TFreeBitmap.SetPixelIndex(X, Y: Cardinal; var Value: Byte): Boolean; +begin + Result := FreeImage_SetPixelIndex(FDib, X, Y, Value); + Change; +end; + +function TFreeBitmap.SetSize(ImageType: FREE_IMAGE_TYPE; Width, Height, + Bpp: Integer; RedMask, GreenMask, BlueMask: Cardinal): Boolean; +var + Pal: PRGBQuad; + I: Cardinal; +begin + Result := False; + + if FDib <> nil then + FreeImage_Unload(FDib); + + FDib := FreeImage_Allocate(Width, Height, Bpp, RedMask, GreenMask, BlueMask); + if FDib = nil then Exit; + + if ImageType = FIT_BITMAP then + case Bpp of + 1, 4, 8: + begin + Pal := FreeImage_GetPalette(FDib); + for I := 0 to FreeImage_GetColorsUsed(FDib) - 1 do + begin + Pal.rgbBlue := I; + Pal.rgbGreen := I; + Pal.rgbRed := I; + Inc(Pal);//, SizeOf(RGBQUAD)); + end; + end; + end; + + Result := True; + Change; +end; + +procedure TFreeBitmap.SetTransparencyTable(Table: PByte; Count: Integer); +begin + FreeImage_SetTransparencyTable(FDib, Table, Count); + Change; +end; + +procedure TFreeBitmap.SetVerticalResolution(Value: Double); +begin + if IsValid then + begin + FreeImage_SetDotsPerMeterY(FDib, Trunc(Value * 100 + 0.5)); + Change; + end; +end; + +function TFreeBitmap.SplitChannels(RedChannel, GreenChannel, + BlueChannel: TFreeBitmap): Boolean; +begin + if FDib <> nil then + begin + RedChannel.FDib := FreeImage_GetChannel(FDib, FICC_RED); + GreenChannel.FDib := FreeImage_GetChannel(FDib, FICC_GREEN); + BlueChannel.FDib := FreeImage_GetChannel(FDib, FICC_BLUE); + Result := RedChannel.IsValid and GreenChannel.IsValid and BlueChannel.IsValid; + end + else + Result := False +end; + +function TFreeBitmap.Threshold(T: Byte): Boolean; +var + dib1: PFIBITMAP; +begin + if FDib <> nil then + begin + dib1 := FreeImage_Threshold(FDib, T); + Result := Replace(dib1); + end + else + Result := False +end; + +function TFreeBitmap.ToneMapping(TMO: FREE_IMAGE_TMO; FirstParam, + SecondParam: Double): Boolean; +var + NewDib: PFIBITMAP; +begin + Result := False; + if not IsValid then Exit; + + NewDib := FreeImage_ToneMapping(Fdib, TMO, FirstParam, SecondParam); + Result := Replace(NewDib); +end; + +{ TFreeWinBitmap } +{$IFDEF MSWINDOWS} +function TFreeWinBitmap.CaptureWindow(ApplicationWindow, + SelectedWindow: HWND): Boolean; +var + XScreen, YScreen, XShift, YShift, Width, Height: Integer; + R: TRect; + dstDC, srcDC, memDC: HDC; + BM, oldBM: HBITMAP; +begin + Result := False; + + // get window size + GetWindowRect(SelectedWindow, R); + + // check if the window is out of screen or maximized + XShift := 0; + YShift := 0; + XScreen := GetSystemMetrics(SM_CXSCREEN); + YScreen := GetSystemMetrics(SM_CYSCREEN); + if R.Right > XScreen then + R.Right := XScreen; + if R.Bottom > YScreen then + R.Bottom := YScreen; + if R.Left < 0 then + begin + XShift := -R.Left; + R.Left := 0; + end; + if R.Top < 0 then + begin + YShift := -R.Top; + R.Top := 0; + end; + + Width := R.Right - R.Left; + Height := R.Bottom - R.Top; + + if (Width <= 0) or (Height <= 0) then Exit; + + // hide the application window + ShowWindow(ApplicationWindow, SW_HIDE); + + // bring the window at the top most level + SetWindowPos(SelectedWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE); + + // give enough time to refresh the window + Sleep(500); + + // prepare the DCs + dstDc := GetDC(0); + srcDC := GetWindowDC(SelectedWindow); //full window (GetDC(SelectedWindow) = clientarea) + memDC := CreateCompatibleDC(dstDC); + + // copy the screen to the bitmap + BM := CreateCompatibleBitmap(dstDC, Width, Height); + oldBM := HBITMAP(SelectObject(memDC, BM)); + BitBlt(memDC, 0, 0, Width, Height, srcDC, XShift, YShift, SRCCOPY); + + // redraw the application window + ShowWindow(ApplicationWindow, SW_SHOW); + + // restore the position + SetWindowPos(SelectedWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE); + SetWindowPos(ApplicationWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE); + + // convert the HBITMAP to FIBITMAP + CopyFromBitmap(BM); + + // free objects + DeleteObject(SelectObject(memDC, oldBM)); + DeleteObject(memDC); + + if GetBitsPerPixel = 32 then ConvertTo24Bits; + + Result := True; +end; +{$ENDIF} + +procedure TFreeWinBitmap.Clear; +begin + if FDeleteMe then FreeImage_Unload(FDisplayDib); + inherited; +end; + +{$IFDEF MSWINDOWS} +function TFreeWinBitmap.CopyFromBitmap(HBmp: HBITMAP): Boolean; +var + bm: BITMAP; + DC: HDC; + Success: Integer; +// modif NOVAXEL + nColors : integer; + bmih: PBitmapInfoHeader; +// end of modif NOVAXEL +begin + Result := False; + + if HBmp <> 0 then + begin + // get information about the bitmap + GetObject(HBmp, SizeOf(BITMAP), @bm); + + // create the image + SetSize(FIT_BITMAP, bm.bmWidth, bm.bmHeight, bm.bmBitsPixel); + +// modif NOVAXEL + // GetDIBits clears the biClrUsed and biClrImportant BITMAPINFO properties. + // So for the Palettized bitmaps, we need to save the count of colors and + // to restore it after the call to GetDIBits + nColors := GetColorsUsed; +// end of modif NOVAXEL + // create the device context for the bitmap + DC := GetDC(0); + + // copy the pixels + Success := GetDIBits(DC, // handle to DC + HBmp, // handle to Bitmap + 0, // first scan line + FreeImage_GetHeight(Dib), // number of scan lines to copy + FreeImage_GetBits(Dib), // array for bitmap bits + FreeImage_GetInfo(Dib)^, // bitmap data buffer + DIB_RGB_COLORS // RGB + ); + + ReleaseDC(0, DC); +// modif NOVAXEL + // as seen above, wr restore the properties which have been cleared by GetDIBits + bmih := GetInfoHeader; + bmih.biClrUsed := nColors; + bmih.biClrImportant := nColors; +// end of modif NOVAXEL + + if Success = 0 then + raise Exception.Create('Error: GetDIBits failed') + else + Result := True; + end; +end; + +function TFreeWinBitmap.CopyFromHandle(HMem: THandle): Boolean; +var + Data: PByte; + bmih: PBitmapInfoHeader; + Palette: PRGBQuad; + Bits: PByte; + BitFields: array [0..2] of DWORD; + MaskSize: Longint; + image_type: FREE_IMAGE_TYPE; +begin + Result := False; + Palette := nil; + BitFields[0] := 0; BitFields[1] := 0; BitFields[2] := 0; + + // get a pointer to the bitmap + Data := GlobalLock(HMem); + + // get a pointer to the bitmap header + bmih := PBitmapInfoHeader(Data); + + // get a pointer to the palette + if bmih.biBitCount < 16 then + begin + Palette := PRGBQUAD(bmih); + Inc(PByte(Palette), SizeOf(BITMAPINFOHEADER)); + end; + + // get a pointer to the pixels + Bits := PByte(bmih); + Inc(Bits, SizeOf(BITMAPINFOHEADER) + SizeOF(RGBQUAD) * bmih.biClrUsed); + + if bmih.biCompression = BI_BITFIELDS then + begin + // take into account the color masks that specify the red, green and blue + // components (16- and 32-bit) + MaskSize := 3 * SizeOf(DWORD); + CopyMemory(@BitFields[0], Bits, MaskSize); + Inc(Bits, MaskSize); + end; + + if Data <> nil then + begin + image_type := FIT_BITMAP; + + case GetFreeImageMarker(bmih) of + FIT_UINT16..FIT_RGBAF: image_type := GetFreeImageMarker(bmih); + end; + + // allocate a new FIBITMAP + if not SetSize(image_type, bmih.biWidth, bmih.biHeight, bmih.biBitCount, + BitFields[2], BitFields[1], BitFields[0]) then + begin + GlobalUnlock(HMem); + Exit; + end; + + // copy the bitmap header + CopyMemory(FreeImage_GetInfoHeader(Dib), bmih, SizeOf(BITMAPINFOHEADER)); + + // copy the palette + CopyMemory(FreeImage_GetPalette(Dib), Palette, bmih.biClrUsed * SizeOf(RGBQUAD)); + + // copy the bitmap + CopyMemory(FreeImage_GetBits(Dib), Bits, FreeImage_GetPitch(Dib) * FreeImage_GetHeight(Dib)); + + GlobalUnlock(HMem); + end; +end; + +function TFreeWinBitmap.CopyToBitmapH: HBITMAP; +var DC : HDC; +begin + Result:=0; + if IsValid then + begin + DC:=GetDC(0); + Result:=CreateDIBitmap(DC, + FreeImage_GetInfoHeader(Dib)^, + CBM_INIT, + PAnsiChar(FreeImage_GetBits(Dib)), + FreeImage_GetInfo(Dib)^, + DIB_RGB_COLORS); + ReleaseDC(0,DC); + end; +end; + +function TFreeWinBitmap.CopyToClipBoard(NewOwner: HWND): Boolean; +var + HDib: THandle; +begin + Result := False; + HDib := CopyToHandle; + + if OpenClipboard(NewOwner) and EmptyClipboard then + begin + if SetClipboardData(CF_DIB, HDib) = 0 then + begin + MessageBox(NewOwner, 'Unable to set clipboard data', 'FreeImage', MB_ICONERROR); + CloseClipboard; + Exit; + end; + end; + CloseClipboard; + Result := True; +end; + +function TFreeWinBitmap.CopyToHandle: THandle; +var + DibSize: Longint; + ADib, pdib: PByte; + bmih: PBITMAPINFOHEADER; + Pal: PRGBQuad; + Bits: PByte; +begin + Result := 0; + if IsValid then + begin + // get equivalent DIB size + DibSize := SizeOf(BITMAPINFOHEADER); + Inc(DibSize, FreeImage_GetColorsUsed(Dib) * SizeOf(RGBQUAD)); + Inc(DibSize, FreeImage_GetPitch(Dib) * FreeImage_GetHeight(Dib)); + + // allocate a DIB + Result := GlobalAlloc(GHND, DibSize); + ADib := GlobalLock(Result); + + pdib := ADib; + + // copy the BITMAPINFOHEADER + bmih := FreeImage_GetInfoHeader(Dib); + CopyMemory(pdib, bmih, SizeOf(BITMAPINFOHEADER)); + Inc(pdib, SizeOf(BITMAPINFOHEADER)); + if FreeImage_GetImageType(Dib) <> FIT_BITMAP then + SetFreeImageMarker(bmih, FDib); + + // copy the palette + Pal := FreeImage_GetPalette(Dib); + CopyMemory(pdib, Pal, FreeImage_GetColorsUsed(Dib) * SizeOf(RGBQUAD)); + Inc(pdib, FreeImage_GetColorsUsed(Dib) * SizeOf(RGBQUAD)); + + // copy the bitmap + Bits := FreeImage_GetBits(Dib); + CopyMemory(pdib, Bits, FreeImage_GetPitch(Dib) * FreeImage_GetHeight(Dib)); + + GlobalUnlock(Result); + end; +end; +{$ENDIF} + +constructor TFreeWinBitmap.Create(ImageType: FREE_IMAGE_TYPE; Width, + Height, Bpp: Integer); +begin + inherited Create(ImageType, Width, Height, Bpp); + + FDisplayDib := nil; + FDeleteMe := False; +end; + +destructor TFreeWinBitmap.Destroy; +begin + if FDeleteMe then + FreeImage_Unload(FDisplayDib); + inherited; +end; + +{$IFDEF MSWINDOWS} +procedure TFreeWinBitmap.Draw(DC: HDC; Rect: TRect); +begin + DrawEx(DC, Rect); +end; + +procedure TFreeWinBitmap.DrawEx(DC: HDC; Rect: TRect; UseFileBkg: Boolean; + AppBkColor: PRGBQuad; Bg: PFIBITMAP); +var + ImageType: FREE_IMAGE_TYPE; + HasBackground, Transparent: Boolean; + DibDouble: PFIBITMAP; +begin + if not IsValid then Exit; + + // convert to standard bitmap if needed + if FDeleteMe then + begin + FreeImage_Unload(FDisplayDib); + FDisplayDib := nil; + FDeleteMe := False; + end; + + ImageType := FreeImage_GetImageType(FDib); + if ImageType = FIT_BITMAP then + begin + HasBackground := FreeImage_HasBackgroundColor(Dib); + Transparent := FreeImage_IsTransparent(Dib); + + if not Transparent and not HasBackground then + // copy pointer + FDisplayDib := Dib + else + begin + // create the transparent / alpha blended image + FDisplayDib := FreeImage_Composite(Dib, UseFileBkg, AppBkColor, Bg); + // remember to delete FDisplayDib + FDeleteMe := True; + end + end + else + begin + // convert to standard dib for display + if ImageType <> FIT_COMPLEX then + FDisplayDib := FreeImage_ConvertToStandardType(Dib, True) + else + begin + // convert to type FIT_DOUBLE + DibDouble := FreeImage_GetComplexChannel(Dib, FICC_MAG); + FDisplayDib := FreeImage_ConvertToStandardType(DibDouble, True); + // free image of type FIT_DOUBLE + FreeImage_Unload(DibDouble); + end; + // remember to delete FDisplayDib + FDeleteMe := True; + end; + + // Draw the DIB + SetStretchBltMode(DC, COLORONCOLOR); + StretchDIBits(DC, Rect.Left, Rect.Top, + Rect.Right - Rect.Left, Rect.Bottom - Rect.Top, + 0, 0, FreeImage_GetWidth(FDisplayDib), FreeImage_GetHeight(FDisplayDib), + FreeImage_GetBits(FDisplayDib), FreeImage_GetInfo(FDisplayDib)^, DIB_RGB_COLORS, SRCCOPY); +end; + +function TFreeWinBitmap.PasteFromClipBoard: Boolean; +var + HDib: THandle; +begin + Result := False; + if not IsClipboardFormatAvailable(CF_DIB) then Exit; + + if OpenClipboard(0) then + begin + HDib := GetClipboardData(CF_DIB); + CopyFromHandle(HDib); + Result := True; + end; + CloseClipboard; +end; +{$ENDIF} + +{ TFreeMultiBitmap } + +procedure TFreeMultiBitmap.AppendPage(Bitmap: TFreeBitmap); +begin + if IsValid then + FreeImage_AppendPage(FMPage, Bitmap.FDib); +end; + +function TFreeMultiBitmap.Close(Flags: Integer): Boolean; +begin + Result := FreeImage_CloseMultiBitmap(FMPage, Flags); + FMPage := nil; +end; + +constructor TFreeMultiBitmap.Create(KeepCacheInMemory: Boolean); +begin + inherited Create; + FMemoryCache := KeepCacheInMemory; +end; + +procedure TFreeMultiBitmap.DeletePage(Page: Integer); +begin + if IsValid then + FreeImage_DeletePage(FMPage, Page); +end; + +destructor TFreeMultiBitmap.Destroy; +begin + if FMPage <> nil then Close; + inherited; +end; + +function TFreeMultiBitmap.GetLockedPageNumbers(var Pages, + Count: Integer): Boolean; +begin + Result := False; + if not IsValid then Exit; + Result := FreeImage_GetLockedPageNumbers(FMPage, Pages, Count) +end; + +function TFreeMultiBitmap.GetPageCount: Integer; +begin + Result := 0; + if IsValid then + Result := FreeImage_GetPageCount(FMPage) +end; + +procedure TFreeMultiBitmap.InsertPage(Page: Integer; Bitmap: TFreeBitmap); +begin + if IsValid then + FreeImage_InsertPage(FMPage, Page, Bitmap.FDib); +end; + +function TFreeMultiBitmap.IsValid: Boolean; +begin + Result := FMPage <> nil +end; + +procedure TFreeMultiBitmap.LockPage(Page: Integer; DestBitmap: TFreeBitmap); +begin + if not IsValid then Exit; + + if Assigned(DestBitmap) then + begin + DestBitmap.Replace(FreeImage_LockPage(FMPage, Page)); + end; +end; + +function TFreeMultiBitmap.MovePage(Target, Source: Integer): Boolean; +begin + Result := False; + if not IsValid then Exit; + Result := FreeImage_MovePage(FMPage, Target, Source); +end; + +function TFreeMultiBitmap.Open(const FileName: FreeImageAnsiString; CreateNew, + ReadOnly: Boolean; Flags: Integer): Boolean; +var + fif: FREE_IMAGE_FORMAT; +begin + Result := False; + +// modif NOVAXEL +// In order to try to get the file format even if the extension is not standard, +// we check first the file signature + fif := FreeImage_GetFileType(PAnsiChar(FileName), 0); + + if fif = FIF_UNKNOWN then + // no signature? +// end of modif NOVAXEL + // try to guess the file format from the filename + fif := FreeImage_GetFIFFromFilename(PAnsiChar(FileName)); + + // check for supported file types + if (fif <> FIF_UNKNOWN) and (not fif in [FIF_TIFF, FIF_ICO, FIF_GIF]) then + Exit; + + // open the stream + FMPage := FreeImage_OpenMultiBitmap(fif, PAnsiChar(FileName), CreateNew, ReadOnly, FMemoryCache, Flags); + + Result := FMPage <> nil; +end; + +procedure TFreeMultiBitmap.UnlockPage(Bitmap: TFreeBitmap; + Changed: Boolean); +begin + if IsValid then + begin + FreeImage_UnlockPage(FMPage, Bitmap.FDib, Changed); + // clear the image so that it becomes invalid. + // don't use Bitmap.Clear method because it calls FreeImage_Unload + // just clear the pointer + Bitmap.FDib := nil; + Bitmap.Change; + end; +end; + +{ TFreeMemoryIO } + +function TFreeMemoryIO.Acquire(var Data: PByte; + var SizeInBytes: DWORD): Boolean; +begin + Result := FreeImage_AcquireMemory(FHMem, Data, SizeInBytes); +end; + +constructor TFreeMemoryIO.Create(Data: PByte; SizeInBytes: DWORD); +begin + inherited Create; + FHMem := FreeImage_OpenMemory(Data, SizeInBytes); +end; + +destructor TFreeMemoryIO.Destroy; +begin + FreeImage_CloseMemory(FHMem); + inherited; +end; + +function TFreeMemoryIO.GetFileType: FREE_IMAGE_FORMAT; +begin + Result := FreeImage_GetFileTypeFromMemory(FHMem); +end; + +function TFreeMemoryIO.IsValid: Boolean; +begin + Result := FHMem <> nil +end; + +function TFreeMemoryIO.Read(fif: FREE_IMAGE_FORMAT; + Flag: Integer): PFIBITMAP; +begin + Result := FreeImage_LoadFromMemory(fif, FHMem, Flag) +end; + +function TFreeMemoryIO.Seek(Offset: Longint; Origin: Word): Boolean; +begin + Result := FreeImage_SeekMemory(FHMem, Offset, Origin) +end; + +function TFreeMemoryIO.Tell: Longint; +begin + Result := FreeImage_TellMemory(FHMem) +end; + +function TFreeMemoryIO.Write(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; + Flag: Integer): Boolean; +begin + Result := FreeImage_SaveToMemory(fif, dib, FHMem, Flag) +end; + +{ TFreeTag } + +function TFreeTag.Clone: TFreeTag; +var + CloneTag: PFITAG; +begin + Result := nil; + if not IsValid then Exit; + + CloneTag := FreeImage_CloneTag(FTag); + Result := TFreeTag.Create(CloneTag); +end; + +constructor TFreeTag.Create(ATag: PFITAG); +begin + inherited Create; + + if ATag <> nil then + FTag := ATag + else + FTag := FreeImage_CreateTag; +end; + +destructor TFreeTag.Destroy; +begin + if IsValid then + FreeImage_DeleteTag(FTag); + + inherited; +end; + +function TFreeTag.GetCount: Cardinal; +begin + Result := 0; + if not IsValid then Exit; + + Result := FreeImage_GetTagCount(FTag); +end; + +function TFreeTag.GetDescription: AnsiString; +begin + Result := ''; + if not IsValid then Exit; + + Result := FreeImage_GetTagDescription(FTag); +end; + +function TFreeTag.GetID: Word; +begin + Result := 0; + if not IsValid then Exit; + + Result := FreeImage_GetTagID(FTag); +end; + +function TFreeTag.GetKey: AnsiString; +begin + Result := ''; + if not IsValid then Exit; + + Result := FreeImage_GetTagKey(FTag); +end; + +function TFreeTag.GetLength: Cardinal; +begin + Result := 0; + if not IsValid then Exit; + + Result := FreeImage_GetTagLength(FTag); +end; + +function TFreeTag.GetTagType: FREE_IMAGE_MDTYPE; +begin + Result := FIDT_NOTYPE; + if not IsValid then Exit; + + Result := FreeImage_GetTagType(FTag); +end; + +function TFreeTag.GetValue: Pointer; +begin + Result := nil; + if not IsValid then Exit; + + Result := FreeImage_GetTagValue(FTag); +end; + +function TFreeTag.IsValid: Boolean; +begin + Result := FTag <> nil; +end; + +procedure TFreeTag.SetCount(const Value: Cardinal); +begin + if IsValid then + FreeImage_SetTagCount(FTag, Value); +end; + +procedure TFreeTag.SetDescription(const Value: AnsiString); +begin + if IsValid then + FreeImage_SetTagDescription(FTag, PAnsiChar(Value)); +end; + +procedure TFreeTag.SetID(const Value: Word); +begin + if IsValid then + FreeImage_SetTagID(FTag, Value); +end; + +procedure TFreeTag.SetKey(const Value: AnsiString); +begin + if IsValid then + FreeImage_SetTagKey(FTag, PAnsiChar(Value)); +end; + +procedure TFreeTag.SetLength(const Value: Cardinal); +begin + if IsValid then + FreeImage_SetTagLength(FTag, Value); +end; + +procedure TFreeTag.SetTagType(const Value: FREE_IMAGE_MDTYPE); +begin + if IsValid then + FreeImage_SetTagType(FTag, Value); +end; + +procedure TFreeTag.SetValue(const Value: Pointer); +begin + if IsValid then + FreeImage_SetTagValue(FTag, Value); +end; + +function TFreeTag.ToString(Model: FREE_IMAGE_MDMODEL; Make: PAnsiChar): AnsiString; +begin + Result := FreeImage_TagToString(Model, FTag, Make); +end; + +end. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/src/FreeImage.pas b/#ThirdParty/FreeImage/Wrapper/Delphi/src/FreeImage.pas new file mode 100644 index 0000000..66f0408 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/src/FreeImage.pas @@ -0,0 +1,1746 @@ +unit FreeImage; + +// ========================================================== +// Delphi wrapper for FreeImage 3 +// +// Design and implementation by +// - Simon Beavis +// - Peter Byström +// - Anatoliy Pulyaevskiy (xvel84@rambler.ru) +// +// Contributors: +// - Lorenzo Monti (LM) lomo74@gmail.com +// - Maurício (MAU) mauricio_box@yahoo.com - see also http://sourceforge.net/projects/tcycomponents/ +// +// Revision history +// When Who What +// ----------- ----- ----------------------------------------------------------- +// 2010-07-14 LM Fixed some C->Delphi translation errors, +// updated to 3.13.1, made RAD2010 compliant (unicode) +// 2010-07-29 LM Added Free Pascal / Lazarus 32 bit support +// 2010-11-12 LM Updated to 3.14.1 +// 2011-02-15 LM Updated to 3.15.0 +// 2011-03-04 JMB Modifications to compile on Free Pascal / Lazarus 64 bits (tested on Windows 7 and linux OpenSuse) : +// - in 64 bits, the names of the exported function are different : +// e.g. : _FreeImage_AcquireMemory@12 in 32 bits and FreeImage_AcquireMemory in 64 bits +// so the define WIN32 will allow to distinguish 32 and 64 bits in the calls to the freeimage library +// - in 64 bits, the Boolean type is not correctly converted to freeimage BOOL type (integer 32 bits) +// ==> replace Boolean with LongBool in the calls to the freeimage library +// - as linux sees the difference between uppercase and lowercase : +// ==> replace FreeImage_GetMetaData with FreeImage_GetMetadata in the call to the freeimage library +// 2012-06-04 LM Updated to 3.15.3 +// 2012-12-08 LM Updated to 3.15.4 +// 2013-05-06 MAU Corrected calls definition to MAC OSX library +// 2013-11-25 MAU Added type FreeImageAnsiString for handling accents on MAC OSX filenames/path +// 2014-05-05 LM Updated to 3.16.1 +// + +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +interface + +{$MINENUMSIZE 4} // Make sure enums are stored as an integer to be compatible with C/C++ + +{$I 'Version.inc'} + +{$IFDEF MSWINDOWS} +uses Windows; + +type + FreeImageAnsiString = AnsiString; + +{$ELSE} +type + FreeImageAnsiString = UTF8String; + + LONG = LongInt; + DWORD = Cardinal; + + PDWORD = ^DWORD; + + BITMAPINFOHEADER = record + biSize : DWORD; + biWidth : LONG; + biHeight : LONG; + biPlanes : WORD; + biBitCount : WORD; + biCompression : DWORD; + biSizeImage : DWORD; + biXPelsPerMeter : LONG; + biYPelsPerMeter : LONG; + biClrUsed : DWORD; + biClrImportant : DWORD; + end; + LPBITMAPINFOHEADER = ^BITMAPINFOHEADER; + TBITMAPINFOHEADER = BITMAPINFOHEADER; + PBITMAPINFOHEADER = ^BITMAPINFOHEADER; + + RGBQUAD = record + rgbBlue : BYTE; + rgbGreen : BYTE; + rgbRed : BYTE; + rgbReserved : BYTE; + end; + tagRGBQUAD = RGBQUAD; + TRGBQUAD = RGBQUAD; + PRGBQUAD = ^RGBQUAD; + + BITMAPINFO = record + bmiHeader : BITMAPINFOHEADER; + bmiColors : array[0..0] of RGBQUAD; + end; + LPBITMAPINFO = ^BITMAPINFO; + PBITMAPINFO = ^BITMAPINFO; + TBITMAPINFO = BITMAPINFO; +// modif JMB NOVAXEL + HBITMAP = type LongWord; + HWND = type LongWord; + HDC = type LongWord; +// end of modif JMB NOVAXEL +{$ENDIF} + +const + FIDLL = {$IFDEF MSWINDOWS}'FreeImage.dll';{$ENDIF} + {$IFDEF LINUX}'libfreeimage.so';{$ENDIF} + {$IFDEF MACOS}'libfreeimage.dylib';{$ENDIF} + +const + // Version information + FREEIMAGE_MAJOR_VERSION = 3; + FREEIMAGE_MINOR_VERSION = 16; + FREEIMAGE_RELEASE_SERIAL = 1; + // This really only affects 24 and 32 bit formats, the rest are always RGB order. + FREEIMAGE_COLORORDER_BGR = 0; + FREEIMAGE_COLORORDER_RGB = 1; + FREEIMAGE_COLORORDER = FREEIMAGE_COLORORDER_BGR; + +// -------------------------------------------------------------------------- +// Bitmap types ------------------------------------------------------------- +// -------------------------------------------------------------------------- + +type + FIBITMAP = record + data: Pointer; + end; + PFIBITMAP = ^FIBITMAP; + + FIMULTIBITMAP = record + data: Pointer; + end; + PFIMULTIBITMAP = ^FIMULTIBITMAP; + +// -------------------------------------------------------------------------- +// Types used in the library (specific to FreeImage) ------------------------ +// -------------------------------------------------------------------------- + +type + {* 48-bit RGB } + tagFIRGB16 = packed record + red: WORD; + green: WORD; + blue: WORD; + end; + FIRGB16 = tagFIRGB16; + + {* 64-bit RGBA } + tagFIRGBA16 = packed record + red: WORD; + green: WORD; + blue: WORD; + alpha: WORD; + end; + FIRGBA16 = tagFIRGBA16; + + {* 96-bit RGB Float } + tagFIRGBF = packed record + red: Single; + green: Single; + blue: Single; + end; + FIRGBF = tagFIRGBF; + + {* 128-bit RGBA Float } + tagFIRGBAF = packed record + red: Single; + green: Single; + blue: Single; + alpha: Single; + end; + FIRGBAF = tagFIRGBAF; + + {* Data structure for COMPLEX type (complex number) } + tagFICOMPLEX = packed record + /// real part + r: Double; + /// imaginary part + i: Double; + end; + FICOMPLEX = tagFICOMPLEX; + +// -------------------------------------------------------------------------- +// Indexes for byte arrays, masks and shifts for treating pixels as words --- +// These coincide with the order of RGBQUAD and RGBTRIPLE ------------------- +// Little Endian (x86 / MS Windows, Linux) : BGR(A) order ------------------- +// -------------------------------------------------------------------------- + +const + FI_RGBA_RED = 2; + FI_RGBA_GREEN = 1; + FI_RGBA_BLUE = 0; + FI_RGBA_ALPHA = 3; + FI_RGBA_RED_MASK = $00FF0000; + FI_RGBA_GREEN_MASK = $0000FF00; + FI_RGBA_BLUE_MASK = $000000FF; + FI_RGBA_ALPHA_MASK = $FF000000; + FI_RGBA_RED_SHIFT = 16; + FI_RGBA_GREEN_SHIFT = 8; + FI_RGBA_BLUE_SHIFT = 0; + FI_RGBA_ALPHA_SHIFT = 24; + + FI_RGBA_RGB_MASK = FI_RGBA_RED_MASK or FI_RGBA_GREEN_MASK or FI_RGBA_BLUE_MASK; + +// -------------------------------------------------------------------------- +// The 16bit macros only include masks and shifts, -------------------------- +// since each color element is not byte aligned ----------------------------- +// -------------------------------------------------------------------------- + +const + FI16_555_RED_MASK = $7C00; + FI16_555_GREEN_MASK = $03E0; + FI16_555_BLUE_MASK = $001F; + FI16_555_RED_SHIFT = 10; + FI16_555_GREEN_SHIFT = 5; + FI16_555_BLUE_SHIFT = 0; + FI16_565_RED_MASK = $F800; + FI16_565_GREEN_MASK = $07E0; + FI16_565_BLUE_MASK = $001F; + FI16_565_RED_SHIFT = 11; + FI16_565_GREEN_SHIFT = 5; + FI16_565_BLUE_SHIFT = 0; + +// -------------------------------------------------------------------------- +// ICC profile support ------------------------------------------------------ +// -------------------------------------------------------------------------- + +const + FIICC_DEFAULT = $0; + FIICC_COLOR_IS_CMYK = $1; + +type + FIICCPROFILE = record + flags: WORD; // info flag + size: DWORD; // profile's size measured in bytes + data: Pointer; // points to a block of contiguous memory containing the profile + end; + PFIICCPROFILE = ^FIICCPROFILE; + +// -------------------------------------------------------------------------- +// Important enums ---------------------------------------------------------- +// -------------------------------------------------------------------------- + +type + FREE_IMAGE_FORMAT = type Integer; + FREE_IMAGE_TYPE = type Integer; + FREE_IMAGE_COLOR_TYPE = type Integer; + FREE_IMAGE_QUANTIZE = type Integer; + FREE_IMAGE_DITHER = type Integer; + FREE_IMAGE_FILTER = type Integer; + FREE_IMAGE_COLOR_CHANNEL = type Integer; + FREE_IMAGE_MDTYPE = type Integer; + FREE_IMAGE_MDMODEL = type Integer; + FREE_IMAGE_JPEG_OPERATION = type Integer; + FREE_IMAGE_TMO = type Integer; + +const + // I/O image format identifiers. + FIF_UNKNOWN = FREE_IMAGE_FORMAT(-1); + FIF_BMP = FREE_IMAGE_FORMAT(0); + FIF_ICO = FREE_IMAGE_FORMAT(1); + FIF_JPEG = FREE_IMAGE_FORMAT(2); + FIF_JNG = FREE_IMAGE_FORMAT(3); + FIF_KOALA = FREE_IMAGE_FORMAT(4); + FIF_LBM = FREE_IMAGE_FORMAT(5); + FIF_IFF = FIF_LBM; + FIF_MNG = FREE_IMAGE_FORMAT(6); + FIF_PBM = FREE_IMAGE_FORMAT(7); + FIF_PBMRAW = FREE_IMAGE_FORMAT(8); + FIF_PCD = FREE_IMAGE_FORMAT(9); + FIF_PCX = FREE_IMAGE_FORMAT(10); + FIF_PGM = FREE_IMAGE_FORMAT(11); + FIF_PGMRAW = FREE_IMAGE_FORMAT(12); + FIF_PNG = FREE_IMAGE_FORMAT(13); + FIF_PPM = FREE_IMAGE_FORMAT(14); + FIF_PPMRAW = FREE_IMAGE_FORMAT(15); + FIF_RAS = FREE_IMAGE_FORMAT(16); + FIF_TARGA = FREE_IMAGE_FORMAT(17); + FIF_TIFF = FREE_IMAGE_FORMAT(18); + FIF_WBMP = FREE_IMAGE_FORMAT(19); + FIF_PSD = FREE_IMAGE_FORMAT(20); + FIF_CUT = FREE_IMAGE_FORMAT(21); + FIF_XBM = FREE_IMAGE_FORMAT(22); + FIF_XPM = FREE_IMAGE_FORMAT(23); + FIF_DDS = FREE_IMAGE_FORMAT(24); + FIF_GIF = FREE_IMAGE_FORMAT(25); + FIF_HDR = FREE_IMAGE_FORMAT(26); + FIF_FAXG3 = FREE_IMAGE_FORMAT(27); + FIF_SGI = FREE_IMAGE_FORMAT(28); + FIF_EXR = FREE_IMAGE_FORMAT(29); + FIF_J2K = FREE_IMAGE_FORMAT(30); + FIF_JP2 = FREE_IMAGE_FORMAT(31); + FIF_PFM = FREE_IMAGE_FORMAT(32); + FIF_PICT = FREE_IMAGE_FORMAT(33); + FIF_RAW = FREE_IMAGE_FORMAT(34); + FIF_WEBP = FREE_IMAGE_FORMAT(35); + FIF_JXR = FREE_IMAGE_FORMAT(36); + + // Image type used in FreeImage. + FIT_UNKNOWN = FREE_IMAGE_TYPE(0); // unknown type + FIT_BITMAP = FREE_IMAGE_TYPE(1); // standard image: 1-, 4-, 8-, 16-, 24-, 32-bit + FIT_UINT16 = FREE_IMAGE_TYPE(2); // array of unsigned short: unsigned 16-bit + FIT_INT16 = FREE_IMAGE_TYPE(3); // array of short: signed 16-bit + FIT_UINT32 = FREE_IMAGE_TYPE(4); // array of unsigned long: unsigned 32-bit + FIT_INT32 = FREE_IMAGE_TYPE(5); // array of long: signed 32-bit + FIT_FLOAT = FREE_IMAGE_TYPE(6); // array of float: 32-bit IEEE floating point + FIT_DOUBLE = FREE_IMAGE_TYPE(7); // array of double: 64-bit IEEE floating point + FIT_COMPLEX = FREE_IMAGE_TYPE(8); // array of FICOMPLEX: 2 x 64-bit IEEE floating point + FIT_RGB16 = FREE_IMAGE_TYPE(9); // 48-bit RGB image: 3 x 16-bit + FIT_RGBA16 = FREE_IMAGE_TYPE(10); // 64-bit RGBA image: 4 x 16-bit + FIT_RGBF = FREE_IMAGE_TYPE(11); // 96-bit RGB float image: 3 x 32-bit IEEE floating point + FIT_RGBAF = FREE_IMAGE_TYPE(12); // 128-bit RGBA float image: 4 x 32-bit IEEE floating point + + // Image color type used in FreeImage. + FIC_MINISWHITE = FREE_IMAGE_COLOR_TYPE(0); // min value is white + FIC_MINISBLACK = FREE_IMAGE_COLOR_TYPE(1); // min value is black + FIC_RGB = FREE_IMAGE_COLOR_TYPE(2); // RGB color model + FIC_PALETTE = FREE_IMAGE_COLOR_TYPE(3); // color map indexed + FIC_RGBALPHA = FREE_IMAGE_COLOR_TYPE(4); // RGB color model with alpha channel + FIC_CMYK = FREE_IMAGE_COLOR_TYPE(5); // CMYK color model + + // Color quantization algorithms. Constants used in FreeImage_ColorQuantize. + FIQ_WUQUANT = FREE_IMAGE_QUANTIZE(0); // Xiaolin Wu color quantization algorithm + FIQ_NNQUANT = FREE_IMAGE_QUANTIZE(1); // NeuQuant neural-net quantization algorithm by Anthony Dekker + + // Dithering algorithms. Constants used FreeImage_Dither. + FID_FS = FREE_IMAGE_DITHER(0); // Floyd & Steinberg error diffusion + FID_BAYER4x4 = FREE_IMAGE_DITHER(1); // Bayer ordered dispersed dot dithering (order 2 dithering matrix) + FID_BAYER8x8 = FREE_IMAGE_DITHER(2); // Bayer ordered dispersed dot dithering (order 3 dithering matrix) + FID_CLUSTER6x6 = FREE_IMAGE_DITHER(3); // Ordered clustered dot dithering (order 3 - 6x6 matrix) + FID_CLUSTER8x8 = FREE_IMAGE_DITHER(4); // Ordered clustered dot dithering (order 4 - 8x8 matrix) + FID_CLUSTER16x16 = FREE_IMAGE_DITHER(5); // Ordered clustered dot dithering (order 8 - 16x16 matrix) + FID_BAYER16x16 = FREE_IMAGE_DITHER(6); // Bayer ordered dispersed dot dithering (order 4 dithering matrix) + + // Lossless JPEG transformations Constants used in FreeImage_JPEGTransform + FIJPEG_OP_NONE = FREE_IMAGE_JPEG_OPERATION(0); // no transformation + FIJPEG_OP_FLIP_H = FREE_IMAGE_JPEG_OPERATION(1); // horizontal flip + FIJPEG_OP_FLIP_V = FREE_IMAGE_JPEG_OPERATION(2); // vertical flip + FIJPEG_OP_TRANSPOSE = FREE_IMAGE_JPEG_OPERATION(3); // transpose across UL-to-LR axis + FIJPEG_OP_TRANSVERSE = FREE_IMAGE_JPEG_OPERATION(4); // transpose across UR-to-LL axis + FIJPEG_OP_ROTATE_90 = FREE_IMAGE_JPEG_OPERATION(5); // 90-degree clockwise rotation + FIJPEG_OP_ROTATE_180 = FREE_IMAGE_JPEG_OPERATION(6); // 180-degree rotation + FIJPEG_OP_ROTATE_270 = FREE_IMAGE_JPEG_OPERATION(7); // 270-degree clockwise (or 90 ccw) + + // Tone mapping operators. Constants used in FreeImage_ToneMapping. + FITMO_DRAGO03 = FREE_IMAGE_TMO(0); // Adaptive logarithmic mapping (F. Drago, 2003) + FITMO_REINHARD05 = FREE_IMAGE_TMO(1); // Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005) + FITMO_FATTAL02 = FREE_IMAGE_TMO(2); // Gradient domain high dynamic range compression (R. Fattal, 2002) + + // Upsampling / downsampling filters. Constants used in FreeImage_Rescale. + FILTER_BOX = FREE_IMAGE_FILTER(0); // Box, pulse, Fourier window, 1st order (constant) b-spline + FILTER_BICUBIC = FREE_IMAGE_FILTER(1); // Mitchell & Netravali's two-param cubic filter + FILTER_BILINEAR = FREE_IMAGE_FILTER(2); // Bilinear filter + FILTER_BSPLINE = FREE_IMAGE_FILTER(3); // 4th order (cubic) b-spline + FILTER_CATMULLROM = FREE_IMAGE_FILTER(4); // Catmull-Rom spline, Overhauser spline + FILTER_LANCZOS3 = FREE_IMAGE_FILTER(5); // Lanczos3 filter + + // Color channels. Constants used in color manipulation routines. + FICC_RGB = FREE_IMAGE_COLOR_CHANNEL(0); // Use red, green and blue channels + FICC_RED = FREE_IMAGE_COLOR_CHANNEL(1); // Use red channel + FICC_GREEN = FREE_IMAGE_COLOR_CHANNEL(2); // Use green channel + FICC_BLUE = FREE_IMAGE_COLOR_CHANNEL(3); // Use blue channel + FICC_ALPHA = FREE_IMAGE_COLOR_CHANNEL(4); // Use alpha channel + FICC_BLACK = FREE_IMAGE_COLOR_CHANNEL(5); // Use black channel + FICC_REAL = FREE_IMAGE_COLOR_CHANNEL(6); // Complex images: use real part + FICC_IMAG = FREE_IMAGE_COLOR_CHANNEL(7); // Complex images: use imaginary part + FICC_MAG = FREE_IMAGE_COLOR_CHANNEL(8); // Complex images: use magnitude + FICC_PHASE = FREE_IMAGE_COLOR_CHANNEL(9); // Complex images: use phase + + // Tag data type information (based on TIFF specifications) + FIDT_NOTYPE = FREE_IMAGE_MDTYPE(0); // placeholder + FIDT_BYTE = FREE_IMAGE_MDTYPE(1); // 8-bit unsigned integer + FIDT_ASCII = FREE_IMAGE_MDTYPE(2); // 8-bit bytes w/ last byte null + FIDT_SHORT = FREE_IMAGE_MDTYPE(3); // 16-bit unsigned integer + FIDT_LONG = FREE_IMAGE_MDTYPE(4); // 32-bit unsigned integer + FIDT_RATIONAL = FREE_IMAGE_MDTYPE(5); // 64-bit unsigned fraction + FIDT_SBYTE = FREE_IMAGE_MDTYPE(6); // 8-bit signed integer + FIDT_UNDEFINED = FREE_IMAGE_MDTYPE(7); // 8-bit untyped data + FIDT_SSHORT = FREE_IMAGE_MDTYPE(8); // 16-bit signed integer + FIDT_SLONG = FREE_IMAGE_MDTYPE(9); // 32-bit signed integer + FIDT_SRATIONAL = FREE_IMAGE_MDTYPE(10); // 64-bit signed fraction + FIDT_FLOAT = FREE_IMAGE_MDTYPE(11); // 32-bit IEEE floating point + FIDT_DOUBLE = FREE_IMAGE_MDTYPE(12); // 64-bit IEEE floating point + FIDT_IFD = FREE_IMAGE_MDTYPE(13); // 32-bit unsigned integer (offset) + FIDT_PALETTE = FREE_IMAGE_MDTYPE(14); // 32-bit RGBQUAD + FIDT_LONG8 = FREE_IMAGE_MDTYPE(16); // 64-bit unsigned integer + FIDT_SLONG8 = FREE_IMAGE_MDTYPE(17); // 64-bit signed integer + FIDT_IFD8 = FREE_IMAGE_MDTYPE(18); // 64-bit unsigned integer (offset) + + // Metadata models supported by FreeImage + FIMD_NODATA = FREE_IMAGE_MDMODEL(-1); + FIMD_COMMENTS = FREE_IMAGE_MDMODEL(0); // single comment or keywords + FIMD_EXIF_MAIN = FREE_IMAGE_MDMODEL(1); // Exif-TIFF metadata + FIMD_EXIF_EXIF = FREE_IMAGE_MDMODEL(2); // Exif-specific metadata + FIMD_EXIF_GPS = FREE_IMAGE_MDMODEL(3); // Exif GPS metadata + FIMD_EXIF_MAKERNOTE = FREE_IMAGE_MDMODEL(4); // Exif maker note metadata + FIMD_EXIF_INTEROP = FREE_IMAGE_MDMODEL(5); // Exif interoperability metadata + FIMD_IPTC = FREE_IMAGE_MDMODEL(6); // IPTC/NAA metadata + FIMD_XMP = FREE_IMAGE_MDMODEL(7); // Abobe XMP metadata + FIMD_GEOTIFF = FREE_IMAGE_MDMODEL(8); // GeoTIFF metadata (to be implemented) + FIMD_ANIMATION = FREE_IMAGE_MDMODEL(9); // Animation metadata + FIMD_CUSTOM = FREE_IMAGE_MDMODEL(10); // Used to attach other metadata types to a dib + FIMD_EXIF_RAW = FREE_IMAGE_MDMODEL(11); // Exif metadata as a raw buffer + +type + // Handle to a metadata model + FIMETADATA = record + data: Pointer; + end; + PFIMETADATA = ^FIMETADATA; + + // Handle to a metadata tag + FITAG = record + data: Pointer; + end; + PFITAG = ^FITAG; + +// -------------------------------------------------------------------------- +// File IO routines --------------------------------------------------------- +// -------------------------------------------------------------------------- + +type + fi_handle = Pointer; + + FI_ReadProc = function(buffer: Pointer; size, count: Cardinal; + handle: fi_handle): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_WriteProc = function(buffer: Pointer; size, count: Cardinal; + handle: fi_handle): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_SeekProc = function(handle: fi_handle; offset: LongInt; + origin: Integer): Integer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_TellProc = function(handle: fi_handle): LongInt; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + + FreeImageIO = packed record + read_proc : FI_ReadProc; // pointer to the function used to read data + write_proc: FI_WriteProc; // pointer to the function used to write data + seek_proc : FI_SeekProc; // pointer to the function used to seek + tell_proc : FI_TellProc; // pointer to the function used to aquire the current position + end; + PFreeImageIO = ^FreeImageIO; + + // Handle to a memory I/O stream + FIMEMORY = record + data: Pointer; + end; + PFIMEMORY = ^FIMEMORY; + +const + // constants used in FreeImage_Seek for Origin parameter + SEEK_SET = 0; + SEEK_CUR = 1; + SEEK_END = 2; + +//type + // define portable types for 32-bit / 64-bit OS + //FIINT64 = Int64; + //FIUINT64 = UInt64; + +// -------------------------------------------------------------------------- +// Plugin routines ---------------------------------------------------------- +// -------------------------------------------------------------------------- + +type + PPlugin = ^Plugin; + + FI_FormatProc = function: PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_DescriptionProc = function: PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_ExtensionListProc = function: PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_RegExprProc = function: PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_OpenProc = function(io: PFreeImageIO; handle: fi_handle; + read: LongBool): Pointer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_CloseProc = procedure(io: PFreeImageIO; handle: fi_handle; + data: Pointer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_PageCountProc = function(io: PFreeImageIO; handle: fi_handle; + data: Pointer): Integer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_PageCapabilityProc = function(io: PFreeImageIO; handle: fi_handle; + data: Pointer): Integer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_LoadProc = function(io: PFreeImageIO; handle: fi_handle; page, flags: Integer; + data: Pointer): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_SaveProc = function(io: PFreeImageIO; dib: PFIBITMAP; handle: fi_handle; + page, flags: Integer; data: Pointer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_ValidateProc = function(io: PFreeImageIO; handle: fi_handle): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_MimeProc = function: PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_SupportsExportBPPProc = function(bpp: integer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_SupportsExportTypeProc = function(_type: FREE_IMAGE_TYPE): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_SupportsICCProfilesProc = function: LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + FI_SupportsNoPixelsProc = function: LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + + Plugin = record + format_proc: FI_FormatProc; + description_proc: FI_DescriptionProc; + extension_proc: FI_ExtensionListProc; + regexpr_proc: FI_RegExprProc; + open_proc: FI_OpenProc; + close_proc: FI_CloseProc; + pagecount_proc: FI_PageCountProc; + pagecapability_proc: FI_PageCapabilityProc; + load_proc: FI_LoadProc; + save_proc: FI_SaveProc; + validate_proc: FI_ValidateProc; + mime_proc: FI_MimeProc; + supports_export_bpp_proc: FI_SupportsExportBPPProc; + supports_export_type_proc: FI_SupportsExportTypeProc; + supports_icc_profiles_proc: FI_SupportsICCProfilesProc; + supports_no_pixels_proc: FI_SupportsNoPixelsProc; + end; + + FI_InitProc = procedure(aplugin: PPlugin; format_id: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + +// -------------------------------------------------------------------------- +// Load/Save flag constants ------------------------------------------------- +// -------------------------------------------------------------------------- + +const + FIF_LOAD_NOPIXELS = $8000; //! loading: load the image header only (not supported by all plugins, default to full loading) + BMP_DEFAULT = 0; + BMP_SAVE_RLE = 1; + CUT_DEFAULT = 0; + DDS_DEFAULT = 0; + EXR_DEFAULT = 0; //! save data as half with piz-based wavelet compression + EXR_FLOAT = $0001; //! save data as float instead of as half (not recommended) + EXR_NONE = $0002; //! save with no compression + EXR_ZIP = $0004; //! save with zlib compression, in blocks of 16 scan lines + EXR_PIZ = $0008; //! save with piz-based wavelet compression + EXR_PXR24 = $0010; //! save with lossy 24-bit float compression + EXR_B44 = $0020; //! save with lossy 44% float compression - goes to 22% when combined with EXR_LC + EXR_LC = $0040; //! save images with one luminance and two chroma channels, rather than as RGB (lossy compression) + FAXG3_DEFAULT = 0; + GIF_DEFAULT = 0; + GIF_LOAD256 = 1; //! Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color + GIF_PLAYBACK = 2; //! 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading + HDR_DEFAULT = 0; + ICO_DEFAULT = 0; + ICO_MAKEALPHA = 1; //! convert to 32bpp and create an alpha channel from the AND-mask when loading + IFF_DEFAULT = 0; + J2K_DEFAULT = 0; //! save with a 16:1 rate + JP2_DEFAULT = 0; //! save with a 16:1 rate + JPEG_DEFAULT = 0; //! loading (see JPEG_FAST); saving (see JPEG_QUALITYGOOD|JPEG_SUBSAMPLING_420) + JPEG_FAST = 1; //! load the file as fast as possible, sacrificing some quality + JPEG_ACCURATE = 2; //! load the file with the best quality, sacrificing some speed + JPEG_CMYK = $0004; //! load separated CMYK "as is" (use | to combine with other flags) + JPEG_EXIFROTATE = $0008; //! load and rotate according to Exif 'Orientation' tag if available + JPEG_GREYSCALE = $0010; //! load and convert to a 8-bit greyscale image + JPEG_QUALITYSUPERB = $0080; //! save with superb quality (100:1) + JPEG_QUALITYGOOD = $0100; //! save with good quality (75:1) + JPEG_QUALITYNORMAL = $0200; //! save with normal quality (50:1) + JPEG_QUALITYAVERAGE = $0400; //! save with average quality (25:1) + JPEG_QUALITYBAD = $0800; //! save with bad quality (10:1) + JPEG_PROGRESSIVE = $2000; //! save as a progressive-JPEG (use | to combine with other save flags) + JPEG_SUBSAMPLING_411 = $1000; //! save with high 4x1 chroma subsampling (4:1:1) + JPEG_SUBSAMPLING_420 = $4000; //! save with medium 2x2 medium chroma subsampling (4:2:0) - default value + JPEG_SUBSAMPLING_422 = $8000; //! save with low 2x1 chroma subsampling (4:2:2) + JPEG_SUBSAMPLING_444 = $10000; //! save with no chroma subsampling (4:4:4) + JPEG_OPTIMIZE = $20000; //! on saving, compute optimal Huffman coding tables (can reduce a few percent of file size) + JPEG_BASELINE = $40000; //! save basic JPEG, without metadata or any markers + KOALA_DEFAULT = 0; + LBM_DEFAULT = 0; + MNG_DEFAULT = 0; + PCD_DEFAULT = 0; + PCD_BASE = 1; //! load the bitmap sized 768 x 512 + PCD_BASEDIV4 = 2; //! load the bitmap sized 384 x 256 + PCD_BASEDIV16 = 3; //! load the bitmap sized 192 x 128 + PCX_DEFAULT = 0; + PFM_DEFAULT = 0; + PICT_DEFAULT = 0; + PNG_DEFAULT = 0; + PNG_IGNOREGAMMA = 1; //! loading: avoid gamma correction + PNG_Z_BEST_SPEED = $0001; //! save using ZLib level 1 compression flag (default value is 6) + PNG_Z_DEFAULT_COMPRESSION = $0006; //! save using ZLib level 6 compression flag (default recommended value) + PNG_Z_BEST_COMPRESSION = $0009; //! save using ZLib level 9 compression flag (default value is 6) + PNG_Z_NO_COMPRESSION = $0100; //! save without ZLib compression + PNG_INTERLACED = $0200; //! save using Adam7 interlacing (use | to combine with other save flags) + PNM_DEFAULT = 0; + PNM_SAVE_RAW = 0; //! if set the writer saves in RAW format (i.e. P4, P5 or P6) + PNM_SAVE_ASCII = 1; //! if set the writer saves in ASCII format (i.e. P1, P2 or P3) + PSD_DEFAULT = 0; + PSD_CMYK = 1; //! reads tags for separated CMYK (default is conversion to RGB) + PSD_LAB = 2; //! reads tags for CIELab (default is conversion to RGB) + RAS_DEFAULT = 0; + RAW_DEFAULT = 0; //! load the file as linear RGB 48-bit + RAW_PREVIEW = 1; //! try to load the embedded JPEG preview with included Exif Data or default to RGB 24-bit + RAW_DISPLAY = 2; //! load the file as RGB 24-bit + RAW_HALFSIZE = 4; //! output a half-size color image + SGI_DEFAULT = 0; + TARGA_DEFAULT = 0; + TARGA_LOAD_RGB888 = 1; //! if set the loader converts RGB555 and ARGB8888 -> RGB888. + TARGA_SAVE_RLE = 2; //! if set, the writer saves with RLE compression + TIFF_DEFAULT = 0; + TIFF_CMYK = $0001; //! reads/stores tags for separated CMYK (use | to combine with compression flags) + TIFF_PACKBITS = $0100; //! save using PACKBITS compression + TIFF_DEFLATE = $0200; //! save using DEFLATE compression + TIFF_ADOBE_DEFLATE = $0400; //! save using ADOBE DEFLATE compression + TIFF_NONE = $0800; //! save without any compression + TIFF_CCITTFAX3 = $1000; //! save using CCITT Group 3 fax encoding + TIFF_CCITTFAX4 = $2000; //! save using CCITT Group 4 fax encoding + TIFF_LZW = $4000; //! save using LZW compression + TIFF_JPEG = $8000; //! save using JPEG compression + TIFF_LOGLUV = $10000; //! save using LogLuv compression + WBMP_DEFAULT = 0; + XBM_DEFAULT = 0; + XPM_DEFAULT = 0; + WEBP_DEFAULT = 0; //! save with good quality (75:1) + WEBP_LOSSLESS = $100; //! save in lossless mode + JXR_DEFAULT = 0; //! save with quality 80 and no chroma subsampling (4:4:4) + JXR_LOSSLESS = $0064; //! save lossless + JXR_PROGRESSIVE = $2000; //! save as a progressive-JXR (use | to combine with other save flags) + +// -------------------------------------------------------------------------- +// Background filling options ----------------------------------------------- +// Constants used in FreeImage_FillBackground and FreeImage_EnlargeCanvas +// -------------------------------------------------------------------------- + +const + FI_COLOR_IS_RGB_COLOR = $00; // RGBQUAD color is a RGB color (contains no valid alpha channel) + FI_COLOR_IS_RGBA_COLOR = $01; // RGBQUAD color is a RGBA color (contains a valid alpha channel) + FI_COLOR_FIND_EQUAL_COLOR = $02; // For palettized images: lookup equal RGB color from palette + FI_COLOR_ALPHA_IS_INDEX = $04; // The color's rgbReserved member (alpha) contains the palette index to be used + FI_COLOR_PALETTE_SEARCH_MASK = FI_COLOR_FIND_EQUAL_COLOR or FI_COLOR_ALPHA_IS_INDEX; // No color lookup is performed + +// -------------------------------------------------------------------------- +// Init/Error routines ------------------------------------------------------ +// -------------------------------------------------------------------------- + +procedure FreeImage_Initialise(load_local_plugins_only: LongBool = False); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Initialise@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Initialise'{$ENDIF}; +procedure FreeImage_DeInitialise; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_DeInitialise@0'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_DeInitialise'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Version routines --------------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_GetVersion: PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetVersion@0'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetVersion'{$ENDIF}; +function FreeImage_GetCopyrightMessage: PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetCopyrightMessage@0'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetCopyrightMessage'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Message output functions ------------------------------------------------- +// -------------------------------------------------------------------------- + +type + FreeImage_OutputMessageFunction = procedure(fif: FREE_IMAGE_FORMAT; + msg: PAnsiChar); cdecl; + FreeImage_OutputMessageFunctionStdCall = procedure(fif: FREE_IMAGE_FORMAT; + msg: PAnsiChar); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + +procedure FreeImage_SetOutputMessageStdCall(omf: FreeImage_OutputMessageFunctionStdCall); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetOutputMessageStdCall@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetOutputMessageStdCall'{$ENDIF}; +procedure FreeImage_SetOutputMessage(omf: FreeImage_OutputMessageFunction); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetOutputMessage@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetOutputMessage'{$ENDIF}; + +{$IFDEF DELPHI6} +//this is declared stdcall in the C header but it is actually cdecl. +//with varargs functions, clearing the stack is caller's responsibility +//(since the callee doesn't know how many parameters were passed). +//cdecl is the right convention here, not stdcall +procedure FreeImage_OutputMessageProc(fif: Integer; fmt: PAnsiChar); cdecl; varargs; + external FIDLL; +{$ELSE} +//older Delphi versions (<6) do not support varargs. +//we provide a wrapper that uses open arrays instead +procedure FreeImage_OutputMessageProc(fif: Integer; fmt: PAnsiChar; args: array of const); +{$ENDIF} + +// -------------------------------------------------------------------------- +// Allocate / Clone / Unload routines --------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_Allocate(width, height, bpp: Integer; red_mask: Cardinal = 0; + green_mask: Cardinal = 0; blue_mask: Cardinal = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Allocate@24'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Allocate'{$ENDIF}; +function FreeImage_AllocateT(_type: FREE_IMAGE_TYPE; width, height: Integer; + bpp: Integer = 8; red_mask: Cardinal = 0; green_mask: Cardinal = 0; + blue_mask: Cardinal = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_AllocateT@28'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_AllocateT'{$ENDIF}; +function FreeImage_Clone(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Clone@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Clone'{$ENDIF}; +procedure FreeImage_Unload(dib: PFIBITMAP); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Unload@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Unload'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Header loading routines +// -------------------------------------------------------------------------- +function FreeImage_HasPixels(dib: PFIBITMAP): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_HasPixels@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_HasPixels'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Load / Save routines ----------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_Load(fif: FREE_IMAGE_FORMAT; filename: PAnsiChar; + flags: Integer = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Load@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Load'{$ENDIF}; +function FreeImage_LoadU(fif: FREE_IMAGE_FORMAT; filename: PWideChar; + flags: Integer = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_LoadU@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_LoadU'{$ENDIF}; +function FreeImage_LoadFromHandle(fif: FREE_IMAGE_FORMAT; io: PFreeImageIO; + handle: fi_handle; flags: Integer = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_LoadFromHandle@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_LoadFromHandle'{$ENDIF}; +function FreeImage_Save(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; filename: PAnsiChar; + flags: Integer = 0): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Save@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Save'{$ENDIF}; +function FreeImage_SaveU(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; filename: PWideChar; + flags: Integer = 0): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SaveU@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SaveU'{$ENDIF}; +function FreeImage_SaveToHandle(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; + io: PFreeImageIO; handle: fi_handle; flags: Integer = 0): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SaveToHandle@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SaveToHandle'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Memory I/O stream routines ----------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_OpenMemory(data: PByte = nil; size_in_bytes: DWORD = 0): PFIMEMORY; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_OpenMemory@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_OpenMemory'{$ENDIF}; +procedure FreeImage_CloseMemory(stream: PFIMEMORY); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_CloseMemory@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_CloseMemory'{$ENDIF}; +function FreeImage_LoadFromMemory(fif: FREE_IMAGE_FORMAT; stream: PFIMEMORY; + flags: Integer = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_LoadFromMemory@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_LoadFromMemory'{$ENDIF}; +function FreeImage_SaveToMemory(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; + stream: PFIMEMORY; flags: Integer = 0): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SaveToMemory@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SaveToMemory'{$ENDIF}; +function FreeImage_TellMemory(stream: PFIMEMORY): LongInt; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_TellMemory@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_TellMemory'{$ENDIF}; +function FreeImage_SeekMemory(stream: PFIMEMORY; offset: LongInt; + origin: Integer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SeekMemory@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SeekMemory'{$ENDIF}; +function FreeImage_AcquireMemory(stream: PFIMEMORY; var data: PByte; + var size_in_bytes: DWORD): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_AcquireMemory@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_AcquireMemory'{$ENDIF}; +function FreeImage_ReadMemory(buffer: Pointer; size, count: Cardinal; + stream: PFIMEMORY): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ReadMemory@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ReadMemory'{$ENDIF}; +function FreeImage_WriteMemory(buffer: Pointer; size, count: Cardinal; + stream: PFIMEMORY): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_WriteMemory@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_WriteMemory'{$ENDIF}; +function FreeImage_LoadMultiBitmapFromMemory(fif: FREE_IMAGE_FORMAT; stream: PFIMEMORY; + flags: Integer = 0): PFIMULTIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_LoadMultiBitmapFromMemory@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_LoadMultiBitmapFromMemory'{$ENDIF}; +function FreeImage_SaveMultiBitmapToMemory(fif: FREE_IMAGE_FORMAT; bitmap: PFIMULTIBITMAP; + stream: PFIMEMORY; flags: Integer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SaveMultiBitmapToMemory@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SaveMultiBitmapToMemory'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Plugin Interface --------------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_RegisterLocalPlugin(proc_address: FI_InitProc; format: PAnsiChar = nil; + description: PAnsiChar = nil; extension: PAnsiChar = nil; + regexpr: PAnsiChar = nil): FREE_IMAGE_FORMAT; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_RegisterLocalPlugin@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_RegisterLocalPlugin'{$ENDIF}; +function FreeImage_RegisterExternalPlugin(path: PAnsiChar; format: PAnsiChar = nil; + description: PAnsiChar = nil; extension: PAnsiChar = nil; + regexpr: PAnsiChar = nil): FREE_IMAGE_FORMAT; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_RegisterExternalPlugin@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_RegisterExternalPlugin'{$ENDIF}; +function FreeImage_GetFIFCount: Integer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFIFCount@0'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFIFCount'{$ENDIF}; +procedure FreeImage_SetPluginEnabled(fif: FREE_IMAGE_FORMAT; enable: LongBool); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetPluginEnabled@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetPluginEnabled'{$ENDIF}; +function FreeImage_IsPluginEnabled(fif: FREE_IMAGE_FORMAT): Integer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_IsPluginEnabled@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_IsPluginEnabled'{$ENDIF}; +function FreeImage_GetFIFFromFormat(format: PAnsiChar): FREE_IMAGE_FORMAT; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFIFFromFormat@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFIFFromFormat'{$ENDIF}; +function FreeImage_GetFIFFromMime(mime: PAnsiChar): FREE_IMAGE_FORMAT; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFIFFromMime@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFIFFromMime'{$ENDIF}; +function FreeImage_GetFormatFromFIF(fif: FREE_IMAGE_FORMAT): PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFormatFromFIF@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFormatFromFIF'{$ENDIF}; +function FreeImage_GetFIFExtensionList(fif: FREE_IMAGE_FORMAT): PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFIFExtensionList@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFIFExtensionList'{$ENDIF}; +function FreeImage_GetFIFDescription(fif: FREE_IMAGE_FORMAT): PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFIFDescription@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFIFDescription'{$ENDIF}; +function FreeImage_GetFIFRegExpr(fif: FREE_IMAGE_FORMAT): PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFIFRegExpr@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFIFRegExpr'{$ENDIF}; +function FreeImage_GetFIFMimeType(fif: FREE_IMAGE_FORMAT): PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFIFMimeType@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFIFMimeType'{$ENDIF}; +function FreeImage_GetFIFFromFilename(filename: PAnsiChar): FREE_IMAGE_FORMAT; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFIFFromFilename@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFIFFromFilename'{$ENDIF}; +function FreeImage_GetFIFFromFilenameU(filename: PWideChar): FREE_IMAGE_FORMAT; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFIFFromFilenameU@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFIFFromFilenameU'{$ENDIF}; +function FreeImage_FIFSupportsReading(fif: FREE_IMAGE_FORMAT): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FIFSupportsReading@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FIFSupportsReading'{$ENDIF}; +function FreeImage_FIFSupportsWriting(fif: FREE_IMAGE_FORMAT): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FIFSupportsWriting@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FIFSupportsWriting'{$ENDIF}; +function FreeImage_FIFSupportsExportBPP(fif: FREE_IMAGE_FORMAT; + bpp: Integer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FIFSupportsExportBPP@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FIFSupportsExportBPP'{$ENDIF}; +function FreeImage_FIFSupportsExportType(fif: FREE_IMAGE_FORMAT; + _type: FREE_IMAGE_TYPE): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FIFSupportsExportType@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FIFSupportsExportType'{$ENDIF}; +function FreeImage_FIFSupportsICCProfiles(fif: FREE_IMAGE_FORMAT): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FIFSupportsICCProfiles@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FIFSupportsICCProfiles'{$ENDIF}; +function FreeImage_FIFSupportsNoPixels(fif: FREE_IMAGE_FORMAT): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FIFSupportsNoPixels@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FIFSupportsNoPixels'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Multipaging interface ---------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_OpenMultiBitmap(fif: FREE_IMAGE_FORMAT; filename: PAnsiChar; + create_new, read_only: LongBool; keep_cache_in_memory: LongBool = False; + flags: Integer = 0): PFIMULTIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_OpenMultiBitmap@24'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_OpenMultiBitmap'{$ENDIF}; +function FreeImage_OpenMultiBitmapFromHandle(fif: FREE_IMAGE_FORMAT; io: PFreeImageIO; + handle: fi_handle; flags: Integer = 0): PFIMULTIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_OpenMultiBitmapFromHandle@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_OpenMultiBitmapFromHandle'{$ENDIF}; +function FreeImage_SaveMultiBitmapToHandle(fif: FREE_IMAGE_FORMAT; bitmap: PFIMULTIBITMAP; + io: PFreeImageIO; handle: fi_handle; flags: Integer = 0): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SaveMultiBitmapToHandle@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SaveMultiBitmapToHandle'{$ENDIF}; +function FreeImage_CloseMultiBitmap(bitmap: PFIMULTIBITMAP; + flags: Integer = 0): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_CloseMultiBitmap@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_CloseMultiBitmap'{$ENDIF}; +function FreeImage_GetPageCount(bitmap: PFIMULTIBITMAP): Integer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetPageCount@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetPageCount'{$ENDIF}; +procedure FreeImage_AppendPage(bitmap: PFIMULTIBITMAP; data: PFIBITMAP); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_AppendPage@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_AppendPage'{$ENDIF}; +procedure FreeImage_InsertPage(bitmap: PFIMULTIBITMAP; page: Integer; + data: PFIBITMAP); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_InsertPage@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_InsertPage'{$ENDIF}; +procedure FreeImage_DeletePage(bitmap: PFIMULTIBITMAP; page: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_DeletePage@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_DeletePage'{$ENDIF}; +function FreeImage_LockPage(bitmap: PFIMULTIBITMAP; page: Integer): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_LockPage@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_LockPage'{$ENDIF}; +procedure FreeImage_UnlockPage(bitmap: PFIMULTIBITMAP; data: PFIBITMAP; + changed: LongBool); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_UnlockPage@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_UnlockPage'{$ENDIF}; +function FreeImage_MovePage(bitmap: PFIMULTIBITMAP; target, source: Integer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_MovePage@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_MovePage'{$ENDIF}; +function FreeImage_GetLockedPageNumbers(bitmap: PFIMULTIBITMAP; var pages: Integer; + var count: Integer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetLockedPageNumbers@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetLockedPageNumbers'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Filetype request routines ------------------------------------------------ +// -------------------------------------------------------------------------- + +function FreeImage_GetFileType(filename: PAnsiChar; + size: Integer = 0): FREE_IMAGE_FORMAT; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFileType@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFileType'{$ENDIF}; +function FreeImage_GetFileTypeU(filename: PWideChar; + size: Integer = 0): FREE_IMAGE_FORMAT; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFileTypeU@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFileTypeU'{$ENDIF}; +function FreeImage_GetFileTypeFromHandle(io: PFreeImageIO; handle: FI_Handle; + size: Integer = 0): FREE_IMAGE_FORMAT; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFileTypeFromHandle@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFileTypeFromHandle'{$ENDIF}; +function FreeImage_GetFileTypeFromMemory(stream: PFIMEMORY; + size: Integer = 0): FREE_IMAGE_FORMAT; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetFileTypeFromMemory@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetFileTypeFromMemory'{$ENDIF}; + +// -------------------------------------------------------------------------- +// ImageType request routine ------------------------------------------------ +// -------------------------------------------------------------------------- + +function FreeImage_GetImageType(dib: PFIBITMAP): FREE_IMAGE_TYPE; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetImageType@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetImageType'{$ENDIF}; + +// -------------------------------------------------------------------------- +// FreeImage helper routines ------------------------------------------------ +// -------------------------------------------------------------------------- + +function FreeImage_IsLittleEndian: LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_IsLittleEndian@0'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_IsLittleEndian'{$ENDIF}; +function FreeImage_LookupX11Color(szColor: PAnsiChar; var nRed, nGreen, nBlue: Byte): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_LookupX11Color@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_LookupX11Color'{$ENDIF}; +function FreeImage_LookupSVGColor(szColor: PAnsiChar; var nRed, nGreen, nBlue: Byte): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_LookupSVGColor@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_LookupSVGColor'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Pixels access routines --------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_GetBits(dib: PFIBITMAP): PByte; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetBits@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetBits'{$ENDIF}; +function FreeImage_GetScanLine(dib: PFIBITMAP; scanline: Integer): PByte; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetScanLine@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetScanLine'{$ENDIF}; + +function FreeImage_GetPixelIndex(dib: PFIBITMAP; x, y: Cardinal; var value: Byte): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetPixelIndex@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetPixelIndex'{$ENDIF}; +function FreeImage_GetPixelColor(dib: PFIBITMAP; x, y: Cardinal; var value: RGBQUAD): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetPixelColor@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetPixelColor'{$ENDIF}; +function FreeImage_SetPixelIndex(dib: PFIBITMAP; x, y: Cardinal; var value: Byte): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetPixelIndex@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetPixelIndex'{$ENDIF}; +function FreeImage_SetPixelColor(dib: PFIBITMAP; x, y: Cardinal; var value: RGBQUAD): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetPixelColor@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetPixelColor'{$ENDIF}; + +// -------------------------------------------------------------------------- +// DIB info routines -------------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_GetColorsUsed(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetColorsUsed@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetColorsUsed'{$ENDIF}; +function FreeImage_GetBPP(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetBPP@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetBPP'{$ENDIF}; +function FreeImage_GetWidth(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetWidth@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetWidth'{$ENDIF}; +function FreeImage_GetHeight(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetHeight@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetHeight'{$ENDIF}; +function FreeImage_GetLine(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetLine@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetLine'{$ENDIF}; +function FreeImage_GetPitch(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetPitch@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetPitch'{$ENDIF}; +function FreeImage_GetDIBSize(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetDIBSize@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetDIBSize'{$ENDIF}; +function FreeImage_GetPalette(dib: PFIBITMAP): PRGBQuad; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetPalette@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetPalette'{$ENDIF}; + +function FreeImage_GetDotsPerMeterX(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetDotsPerMeterX@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetDotsPerMeterX'{$ENDIF}; +function FreeImage_GetDotsPerMeterY(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetDotsPerMeterY@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetDotsPerMeterY'{$ENDIF}; +procedure FreeImage_SetDotsPerMeterX(dib: PFIBITMAP; res: Cardinal); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetDotsPerMeterX@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetDotsPerMeterX'{$ENDIF}; +procedure FreeImage_SetDotsPerMeterY(dib: PFIBITMAP; res: Cardinal); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetDotsPerMeterY@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetDotsPerMeterY'{$ENDIF}; + +function FreeImage_GetInfoHeader(dib: PFIBITMAP): PBITMAPINFOHEADER; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetInfoHeader@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetInfoHeader'{$ENDIF}; +function FreeImage_GetInfo(dib: PFIBITMAP): PBITMAPINFO; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetInfo@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetInfo'{$ENDIF}; +function FreeImage_GetColorType(dib: PFIBITMAP): FREE_IMAGE_COLOR_TYPE; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetColorType@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetColorType'{$ENDIF}; + +function FreeImage_GetRedMask(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetRedMask@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetRedMask'{$ENDIF}; +function FreeImage_GetGreenMask(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetGreenMask@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetGreenMask'{$ENDIF}; +function FreeImage_GetBlueMask(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetBlueMask@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetBlueMask'{$ENDIF}; + +function FreeImage_GetTransparencyCount(dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetTransparencyCount@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetTransparencyCount'{$ENDIF}; +function FreeImage_GetTransparencyTable(dib: PFIBITMAP): PByte; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetTransparencyTable@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetTransparencyTable'{$ENDIF}; +procedure FreeImage_SetTransparent(dib: PFIBITMAP; enabled: LongBool); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetTransparent@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetTransparent'{$ENDIF}; +procedure FreeImage_SetTransparencyTable(dib: PFIBITMAP; table: PByte; + count: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetTransparencyTable@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetTransparencyTable'{$ENDIF}; +function FreeImage_IsTransparent(dib: PFIBITMAP): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_IsTransparent@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_IsTransparent'{$ENDIF}; +procedure FreeImage_SetTransparentIndex(dib: PFIBITMAP; index: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetTransparentIndex@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetTransparentIndex'{$ENDIF}; +function FreeImage_GetTransparentIndex(dib: PFIBITMAP): Integer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetTransparentIndex@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetTransparentIndex'{$ENDIF}; + +function FreeImage_HasBackgroundColor(dib: PFIBITMAP): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_HasBackgroundColor@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_HasBackgroundColor'{$ENDIF}; +function FreeImage_GetBackgroundColor(dib: PFIBITMAP; var bkcolor: RGBQUAD): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetBackgroundColor@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetBackgroundColor'{$ENDIF}; +function FreeImage_SetBackgroundColor(dib: PFIBITMAP; bkcolor: PRGBQuad): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetBackgroundColor@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetBackgroundColor'{$ENDIF}; + +function FreeImage_GetThumbnail(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetThumbnail@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetThumbnail'{$ENDIF}; +function FreeImage_SetThumbnail(dib, thumbnail: PFIBITMAP): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetThumbnail@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetThumbnail'{$ENDIF}; + +// -------------------------------------------------------------------------- +// ICC profile routines ----------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_GetICCProfile(dib: PFIBITMAP): PFIICCPROFILE; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetICCProfile@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetICCProfile'{$ENDIF}; +function FreeImage_CreateICCProfile(dib: PFIBITMAP; data: Pointer; + size: LongInt): PFIICCPROFILE; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name 'FreeImage_CreateICCProfile@12'{$ENDIF} + {$IFDEF MACOS}name 'FreeImage_CreateICCProfile'{$ENDIF}; +procedure FreeImage_DestroyICCProfile(dib: PFIBITMAP); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name 'FreeImage_DestroyICCProfile@4'{$ENDIF} + {$IFDEF MACOS}name 'FreeImage_DestroyICCProfile'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Line conversion routines ------------------------------------------------- +// -------------------------------------------------------------------------- + +procedure FreeImage_ConvertLine1To4(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine1To4@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine1To4'{$ENDIF}; +procedure FreeImage_ConvertLine8To4(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine8To4@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine8To4'{$ENDIF}; +procedure FreeImage_ConvertLine16To4_555(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine16To4_555@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine16To4_555'{$ENDIF}; +procedure FreeImage_ConvertLine16To4_565(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine16To4_565@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine16To4_565'{$ENDIF}; +procedure FreeImage_ConvertLine24To4(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine24To4@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine24To4'{$ENDIF}; +procedure FreeImage_ConvertLine32To4(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine32To4@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine32To4'{$ENDIF}; + +procedure FreeImage_ConvertLine1To8(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine1To8@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine1To8'{$ENDIF}; +procedure FreeImage_ConvertLine4To8(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine4To8@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine4To8'{$ENDIF}; +procedure FreeImage_ConvertLine16To8_555(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine16To8_555@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine16To8_555'{$ENDIF}; +procedure FreeImage_ConvertLine16To8_565(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine16To8_565@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine16To8_565'{$ENDIF}; +procedure FreeImage_ConvertLine24To8(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine24To8@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine24To8'{$ENDIF}; +procedure FreeImage_ConvertLine32To8(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine32To8@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine32To8'{$ENDIF}; + +procedure FreeImage_ConvertLine1To16_555(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine1To16_555@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine1To16_555'{$ENDIF}; +procedure FreeImage_ConvertLine4To16_555(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine4To16_555@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine4To16_555'{$ENDIF}; +procedure FreeImage_ConvertLine8To16_555(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine8To16_555@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine8To16_555'{$ENDIF}; +procedure FreeImage_ConvertLine16_565_To16_555(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine16_565_To16_555@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine16_565_To16_555'{$ENDIF}; +procedure FreeImage_ConvertLine24To16_555(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine24To16_555@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine24To16_555'{$ENDIF}; +procedure FreeImage_ConvertLine32To16_555(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine32To16_555@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine32To16_555'{$ENDIF}; + +procedure FreeImage_ConvertLine1To16_565(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine1To16_565@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine1To16_565'{$ENDIF}; +procedure FreeImage_ConvertLine4To16_565(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine4To16_565@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine4To16_565'{$ENDIF}; +procedure FreeImage_ConvertLine8To16_565(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine8To16_565@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine8To16_565'{$ENDIF}; +procedure FreeImage_ConvertLine16_555_To16_565(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine16_555_To16_565@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine16_555_To16_565'{$ENDIF}; +procedure FreeImage_ConvertLine24To16_565(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine24To16_565@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine24To16_565'{$ENDIF}; +procedure FreeImage_ConvertLine32To16_565(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine32To16_565@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine32To16_565'{$ENDIF}; + +procedure FreeImage_ConvertLine1To24(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine1To24@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine1To24'{$ENDIF}; +procedure FreeImage_ConvertLine4To24(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine4To24@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine4To24'{$ENDIF}; +procedure FreeImage_ConvertLine8To24(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine8To24@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine8To24'{$ENDIF}; +procedure FreeImage_ConvertLine16To24_555(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine16To24_555@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine16To24_555'{$ENDIF}; +procedure FreeImage_ConvertLine16To24_565(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine16To24_565@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine16To24_565'{$ENDIF}; +procedure FreeImage_ConvertLine32To24(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine32To24@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine32To24'{$ENDIF}; + +procedure FreeImage_ConvertLine1To32(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine1To32@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine1To32'{$ENDIF}; +procedure FreeImage_ConvertLine4To32(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine4To32@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine4To32'{$ENDIF}; +procedure FreeImage_ConvertLine8To32(target, source: PByte; width_in_pixels: Integer; + palette: PRGBQuad); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine8To32@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine8To32'{$ENDIF}; +procedure FreeImage_ConvertLine16To32_555(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine16To32_555@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine16To32_555'{$ENDIF}; +procedure FreeImage_ConvertLine16To32_565(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine16To32_565@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine16To32_565'{$ENDIF}; +procedure FreeImage_ConvertLine24To32(target, source: PByte; width_in_pixels: Integer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertLine24To32@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertLine24To32'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Smart conversion routines ------------------------------------------------ +// -------------------------------------------------------------------------- + +function FreeImage_ConvertTo4Bits(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertTo4Bits@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertTo4Bits'{$ENDIF}; +function FreeImage_ConvertTo8Bits(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertTo8Bits@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertTo8Bits'{$ENDIF}; +function FreeImage_ConvertToGreyscale(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertToGreyscale@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertToGreyscale'{$ENDIF}; +function FreeImage_ConvertTo16Bits555(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertTo16Bits555@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertTo16Bits555'{$ENDIF}; +function FreeImage_ConvertTo16Bits565(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertTo16Bits565@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertTo16Bits565'{$ENDIF}; +function FreeImage_ConvertTo24Bits(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertTo24Bits@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertTo24Bits'{$ENDIF}; +function FreeImage_ConvertTo32Bits(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertTo32Bits@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertTo32Bits'{$ENDIF}; +function FreeImage_ColorQuantize(dib: PFIBITMAP; quantize: FREE_IMAGE_QUANTIZE): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ColorQuantize@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ColorQuantize'{$ENDIF}; +function FreeImage_ColorQuantizeEx(dib: PFIBITMAP; quantize: FREE_IMAGE_QUANTIZE = FIQ_WUQUANT; + PaletteSize: Integer = 256; ReserveSize: Integer = 0; + ReservePalette: PRGBQuad = nil): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ColorQuantizeEx@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ColorQuantizeEx'{$ENDIF}; +function FreeImage_Threshold(dib: PFIBITMAP; T: Byte): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Threshold@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Threshold'{$ENDIF}; +function FreeImage_Dither(dib: PFIBITMAP; algorithm: FREE_IMAGE_DITHER): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Dither@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Dither'{$ENDIF}; + +function FreeImage_ConvertFromRawBits(bits: PByte; width, height, pitch: Integer; + bpp, red_mask, green_mask, blue_mask: Cardinal; topdown: LongBool = False): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertFromRawBits@36'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertFromRawBits'{$ENDIF}; +function FreeImage_ConvertFromRawBitsEx(copySource: LongBool; bits: PByte; _type: FREE_IMAGE_TYPE; + width, height, pitch: Integer; bpp, red_mask, green_mask, blue_mask: Cardinal; + topdown: LongBool = False): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertFromRawBitsEx@44'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertFromRawBitsEx'{$ENDIF}; +procedure FreeImage_ConvertToRawBits(bits: PByte; dib: PFIBITMAP; pitch: Integer; + bpp, red_mask, green_mask, blue_mask: Cardinal; topdown: LongBool = False); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertToRawBits@32'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertToRawBits'{$ENDIF}; + +function FreeImage_ConvertToFloat(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertToFloat@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertToFloat'{$ENDIF}; +function FreeImage_ConvertToRGBF(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertToRGBF@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertToRGBF'{$ENDIF}; +function FreeImage_ConvertToUINT16(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertToUINT16@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertToUINT16'{$ENDIF}; +function FreeImage_ConvertToRGB16(dib: PFIBITMAP): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertToRGB16@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertToRGB16'{$ENDIF}; + +function FreeImage_ConvertToStandardType(src: PFIBITMAP; + scale_linear: LongBool = True): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertToStandardType@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertToStandardType'{$ENDIF}; +function FreeImage_ConvertToType(src: PFIBITMAP; dst_type: FREE_IMAGE_TYPE; + scale_linear: LongBool = True): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ConvertToType@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ConvertToType'{$ENDIF}; + +// Tone mapping operators --------------------------------------------------- +function FreeImage_ToneMapping(dib: PFIBITMAP; tmo: FREE_IMAGE_TMO; + first_param: Double = 0; second_param: Double = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ToneMapping@24'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ToneMapping'{$ENDIF}; +function FreeImage_TmoDrago03(src: PFIBITMAP; gamma: Double = 2.2; + exposure: Double = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_TmoDrago03@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_TmoDrago03'{$ENDIF}; +function FreeImage_TmoReinhard05(src: PFIBITMAP; intensity: Double = 0; + contrast: Double = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_TmoReinhard05@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_TmoReinhard05'{$ENDIF}; +function FreeImage_TmoReinhard05Ex(src: PFIBITMAP; intensity: Double = 0; + contrast: Double = 0; adaptation: Double = 1; color_correction: Double = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_TmoReinhard05Ex@36'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_TmoReinhard05Ex'{$ENDIF}; + +function FreeImage_TmoFattal02(src: PFIBITMAP; color_saturation: Double = 0.5; + attenuation: Double = 0.85): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_TmoFattal02@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_TmoFattal02'{$ENDIF}; + +// -------------------------------------------------------------------------- +// ZLib interface ----------------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_ZLibCompress(target: PByte; target_size: DWORD; source: PByte; source_size: DWORD): DWORD; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ZLibCompress@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ZLibCompress'{$ENDIF}; +function FreeImage_ZLibUncompress(target: PByte; target_size: DWORD; source: PByte; source_size: DWORD): DWORD; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ZLibUncompress@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ZLibUncompress'{$ENDIF}; +function FreeImage_ZLibGZip(target: PByte; target_size: DWORD; source: PByte; source_size: DWORD): DWORD; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ZLibGZip@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ZLibGZip'{$ENDIF}; +function FreeImage_ZLibGUnzip(target: PByte; target_size: DWORD; source: PByte; source_size: DWORD): DWORD; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ZLibGUnzip@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ZLibGUnzip'{$ENDIF}; +function FreeImage_ZLibCRC32(crc: DWORD; source: PByte; source_size: DWORD): DWORD; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ZLibCRC32@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ZLibCRC32'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Metadata routines +// -------------------------------------------------------------------------- + +// tag creation / destruction +function FreeImage_CreateTag: PFITAG; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_CreateTag@0'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_CreateTag'{$ENDIF}; +procedure FreeImage_DeleteTag(tag: PFITAG); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_DeleteTag@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_DeleteTag'{$ENDIF}; +function FreeImage_CloneTag(tag: PFITAG): PFITAG; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_CloneTag@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_CloneTag'{$ENDIF}; + +// tag getters and setters +function FreeImage_GetTagKey(tag: PFITAG): PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetTagKey@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetTagKey'{$ENDIF}; +function FreeImage_GetTagDescription(tag: PFITAG): PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetTagDescription@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetTagDescription'{$ENDIF}; +function FreeImage_GetTagID(tag: PFITAG): Word; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetTagID@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetTagID'{$ENDIF}; +function FreeImage_GetTagType(tag: PFITAG): FREE_IMAGE_MDTYPE; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetTagType@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetTagType'{$ENDIF}; +function FreeImage_GetTagCount(tag: PFITAG): DWORD; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetTagCount@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetTagCount'{$ENDIF}; +function FreeImage_GetTagLength(tag: PFITAG): DWORD; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetTagLength@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetTagLength'{$ENDIF}; +function FreeImage_GetTagValue(tag: PFITAG): Pointer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetTagValue@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetTagValue'{$ENDIF}; + +function FreeImage_SetTagKey(tag: PFITAG; key: PAnsiChar): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetTagKey@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetTagKey'{$ENDIF}; +function FreeImage_SetTagDescription(tag: PFITAG; description: PAnsiChar): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetTagDescription@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetTagDescription'{$ENDIF}; +function FreeImage_SetTagID(tag: PFITAG; id: Word): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetTagID@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetTagID'{$ENDIF}; +function FreeImage_SetTagType(tag: PFITAG; _type: FREE_IMAGE_MDTYPE): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetTagType@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetTagType'{$ENDIF}; +function FreeImage_SetTagCount(tag: PFITAG; count: DWORD): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetTagCount@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetTagCount'{$ENDIF}; +function FreeImage_SetTagLength(tag: PFITAG; length: DWORD): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetTagLength@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetTagLength'{$ENDIF}; +function FreeImage_SetTagValue(tag: PFITAG; value: Pointer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetTagValue@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetTagValue'{$ENDIF}; + +// iterator +function FreeImage_FindFirstMetadata(model: FREE_IMAGE_MDMODEL; dib: PFIBITMAP; + var tag: PFITAG): PFIMETADATA; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FindFirstMetadata@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FindFirstMetadata'{$ENDIF}; +function FreeImage_FindNextMetadata(mdhandle: PFIMETADATA; var tag: PFITAG): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FindNextMetadata@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FindNextMetadata'{$ENDIF}; +procedure FreeImage_FindCloseMetadata(mdhandle: PFIMETADATA); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FindCloseMetadata@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FindCloseMetadata'{$ENDIF}; + +// metadata setter and getter +function FreeImage_SetMetadata(model: FREE_IMAGE_MDMODEL; dib: PFIBITMAP; + key: PAnsiChar; tag: PFITAG): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetMetadata@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetMetadata'{$ENDIF}; +function FreeImage_GetMetadata(model: FREE_IMAGE_MDMODEL; dib: PFIBITMAP; + key: PAnsiChar; var tag: PFITAG): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetMetadata@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetMetadata'{$ENDIF}; + +// helpers +function FreeImage_GetMetadataCount(model: FREE_IMAGE_MDMODEL; dib: PFIBITMAP): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetMetadataCount@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetMetadataCount'{$ENDIF}; +function FreeImage_CloneMetadata(dst, src: PFIBITMAP): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_CloneMetadata@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_CloneMetadata'{$ENDIF}; + +// tag to C string conversion +function FreeImage_TagToString(model: FREE_IMAGE_MDMODEL; tag: PFITAG; + Make: PAnsiChar = nil): PAnsiChar; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_TagToString@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_TagToString'{$ENDIF}; + +// -------------------------------------------------------------------------- +// JPEG lossless transformation routines +// -------------------------------------------------------------------------- + +function FreeImage_JPEGTransform(src_file, dst_file: PAnsiChar; operation: FREE_IMAGE_JPEG_OPERATION; + perfect: LongBool = False): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_JPEGTransform@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_JPEGTransform'{$ENDIF}; +function FreeImage_JPEGTransformU(src_file, dst_file: PWideChar; operation: FREE_IMAGE_JPEG_OPERATION; + perfect: LongBool = False): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_JPEGTransformU@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_JPEGTransformU'{$ENDIF}; +function FreeImage_JPEGCrop(src_file, dst_file: PAnsiChar; + left, top, right, bottom: Integer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_JPEGCrop@24'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_JPEGCrop'{$ENDIF}; +function FreeImage_JPEGCropU(src_file, dst_file: PWideChar; + left, top, right, bottom: Integer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_JPEGCropU@24'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_JPEGCropU'{$ENDIF}; +function FreeImage_JPEGTransformFromHandle(src_io: PFreeImageIO; src_handle: fi_handle; dst_io: PFreeImageIO; + dst_handle: fi_handle; operation: FREE_IMAGE_JPEG_OPERATION; var left, top, right, bottom: Integer; + perfect: LongBool = True): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_JPEGTransformFromHandle@40'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_JPEGTransformFromHandle'{$ENDIF}; +function FreeImage_JPEGTransformCombined(src_file, dst_file: PAnsiChar; operation: FREE_IMAGE_JPEG_OPERATION; + var left, top, right, bottom: Integer; perfect: LongBool = True): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_JPEGTransformCombined@32'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_JPEGTransformCombined'{$ENDIF}; +function FreeImage_JPEGTransformCombinedU(src_file, dst_file: PWideChar; operation: FREE_IMAGE_JPEG_OPERATION; + var left, top, right, bottom: Integer; perfect: LongBool = True): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_JPEGTransformCombinedU@32'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_JPEGTransformCombinedU'{$ENDIF}; +function FreeImage_JPEGTransformCombinedFromMemory(src_stream, dst_stream: PFIMEMORY; operation: FREE_IMAGE_JPEG_OPERATION; + var left, top, right, bottom: Integer; perfect: LongBool = True): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_JPEGTransformCombinedFromMemory@32'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_JPEGTransformCombinedFromMemory'{$ENDIF}; + +// -------------------------------------------------------------------------- +// Image manipulation toolkit +// -------------------------------------------------------------------------- + +// rotation and flipping +// modif JMB : FreeImage_RotateClassic : deprecated function, call to DeprecationManager in 64 bits crashes freeimage.dll +//function FreeImage_RotateClassic(dib: PFIBITMAP; angle: Double): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} +// external FIDLL {$IFDEF WIN32}name '_FreeImage_RotateClassic@12'{$ENDIF} +// {$IFDEF MACOS}name '_FreeImage_RotateClassic'{$ENDIF}; +function FreeImage_Rotate(dib: PFIBITMAP; angle: Double; bkcolor: Pointer = nil): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Rotate@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Rotate'{$ENDIF}; +function FreeImage_RotateEx(dib: PFIBITMAP; angle, x_shift, y_shift, x_origin, y_origin: Double; + use_mask: LongBool): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_RotateEx@48'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_RotateEx'{$ENDIF}; +function FreeImage_FlipHorizontal(dib: PFIBITMAP): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FlipHorizontal@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FlipHorizontal'{$ENDIF}; +function FreeImage_FlipVertical(dib: PFIBITMAP): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FlipVertical@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FlipVertical'{$ENDIF}; + +// upsampling / downsampling +function FreeImage_Rescale(dib: PFIBITMAP; dst_width, dst_height: Integer; + filter: FREE_IMAGE_FILTER = FILTER_CATMULLROM): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Rescale@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Rescale'{$ENDIF}; +function FreeImage_MakeThumbnail(dib: PFIBITMAP; max_pixel_size: Integer; convert: LongBool = True): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_MakeThumbnail@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_MakeThumbnail'{$ENDIF}; + +// color manipulation routines (point operations) +function FreeImage_AdjustCurve(dib: PFIBITMAP; LUT: PByte; + channel: FREE_IMAGE_COLOR_CHANNEL): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_AdjustCurve@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_AdjustCurve'{$ENDIF}; +function FreeImage_AdjustGamma(dib: PFIBITMAP; gamma: Double): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_AdjustGamma@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_AdjustGamma'{$ENDIF}; +function FreeImage_AdjustBrightness(dib: PFIBITMAP; percentage: Double): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_AdjustBrightness@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_AdjustBrightness'{$ENDIF}; +function FreeImage_AdjustContrast(dib: PFIBITMAP; percentage: Double): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_AdjustContrast@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_AdjustContrast'{$ENDIF}; +function FreeImage_Invert(dib: PFIBITMAP): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Invert@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Invert'{$ENDIF}; +function FreeImage_GetHistogram(dib: PFIBITMAP; histo: PDWORD; + channel: FREE_IMAGE_COLOR_CHANNEL = FICC_BLACK): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetHistogram@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetHistogram'{$ENDIF}; +function FreeImage_GetAdjustColorsLookupTable(LUT: PByte; brightness, contrast, gamma: Double; + invert: LongBool): Integer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetAdjustColorsLookupTable@32'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetAdjustColorsLookupTable'{$ENDIF}; +function FreeImage_AdjustColors(dib: PFIBITMAP; brightness, contrast, gamma: Double; + invert: LongBool = False): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_AdjustColors@32'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_AdjustColors'{$ENDIF}; +function FreeImage_ApplyColorMapping(dib: PFIBITMAP; srccolors, dstcolors: PRGBQuad; + count: Cardinal; ignore_alpha, swap: LongBool): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ApplyColorMapping@24'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ApplyColorMapping'{$ENDIF}; +function FreeImage_SwapColors(dib: PFIBITMAP; color_a, color_b: PRGBQuad; + ignore_alpha: LongBool): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SwapColors@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SwapColors'{$ENDIF}; +function FreeImage_ApplyPaletteIndexMapping(dib: PFIBITMAP; srcindices, dstindices: PByte; + count: Cardinal; swap: LongBool): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_ApplyPaletteIndexMapping@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_ApplyPaletteIndexMapping'{$ENDIF}; +function FreeImage_SwapPaletteIndices(dib: PFIBITMAP; index_a, index_b: PByte): Cardinal; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SwapPaletteIndices@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SwapPaletteIndices'{$ENDIF}; + +// channel processing routines +function FreeImage_GetChannel(dib: PFIBITMAP; channel: FREE_IMAGE_COLOR_CHANNEL): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetChannel@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetChannel'{$ENDIF}; +function FreeImage_SetChannel(dst, src: PFIBITMAP; channel: FREE_IMAGE_COLOR_CHANNEL): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetChannel@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetChannel'{$ENDIF}; +function FreeImage_GetComplexChannel(src: PFIBITMAP; channel: FREE_IMAGE_COLOR_CHANNEL): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_GetComplexChannel@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_GetComplexChannel'{$ENDIF}; +function FreeImage_SetComplexChannel(dst, src: PFIBITMAP; channel: FREE_IMAGE_COLOR_CHANNEL): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_SetComplexChannel@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_SetComplexChannel'{$ENDIF}; + +// copy / paste / composite routines + +function FreeImage_Copy(dib: PFIBITMAP; left, top, right, bottom: Integer): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Copy@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Copy'{$ENDIF}; +function FreeImage_Paste(dst, src: PFIBITMAP; left, top, alpha: Integer): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Paste@20'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Paste'{$ENDIF}; +function FreeImage_Composite(fg: PFIBITMAP; useFileBkg: LongBool = False; + appBkColor: PRGBQuad = nil; bg: PFIBITMAP = nil): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_Composite@16'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_Composite'{$ENDIF}; +function FreeImage_PreMultiplyWithAlpha(dib: PFIBITMAP): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_PreMultiplyWithAlpha@4'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_PreMultiplyWithAlpha'{$ENDIF}; + +// background filling routines +function FreeImage_FillBackground(dib: PFIBITMAP; color: Pointer; + options: Integer = 0): LongBool; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_FillBackground@12'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_FillBackground'{$ENDIF}; +function FreeImage_EnlargeCanvas(src: PFIBITMAP; left, top, right, bottom: Integer; + color: Pointer; options: Integer = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_EnlargeCanvas@28'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_EnlargeCanvas'{$ENDIF}; +function FreeImage_AllocateEx(width, height, bpp: Integer; color: PRGBQuad; + options: Integer = 0; palette: PRGBQuad = nil; red_mask: Cardinal = 0; + green_mask: Cardinal = 0; blue_mask: Cardinal = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_AllocateEx@36'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_AllocateEx'{$ENDIF}; +function FreeImage_AllocateExT(_type: FREE_IMAGE_TYPE; width, height, bpp: Integer; + color: Pointer; options: Integer = 0; palette: PRGBQuad = nil; red_mask: Cardinal = 0; + green_mask: Cardinal = 0; blue_mask: Cardinal = 0): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_AllocateExT@40'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_AllocateExT'{$ENDIF}; + +// miscellaneous algorithms +function FreeImage_MultigridPoissonSolver(Laplacian: PFIBITMAP; + ncycle: Integer = 3): PFIBITMAP; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} + external FIDLL {$IFDEF WIN32}name '_FreeImage_MultigridPoissonSolver@8'{$ENDIF} + {$IFDEF MACOS}name '_FreeImage_MultigridPoissonSolver'{$ENDIF}; + + +implementation + +{$IFNDEF DELPHI6} +uses SysUtils; + +//we provide a wrapper since we haven't varargs in older versions of Delphi +procedure __FreeImage_OutputMessageProc; cdecl; + external FIDLL name 'FreeImage_OutputMessageProc'; + +procedure FreeImage_OutputMessageProc(fif: Integer; fmt: PAnsiChar; args: array of const); + function ArrayToBuffer(Args: array of const; + var Argv: Pointer; Buffer: Pointer; Size: Cardinal): Integer; + var + i: Integer; + temp: AnsiString; + parg: Pointer; + psrc, pbuf: PAnsiChar; + len: Cardinal; + begin + Result := High(Args) + 1; + if Result = 0 then + Exit; + //array of pointers to push on stack + GetMem(Argv, Result * SizeOf(Pointer)); + //pointer to current string in buffer + pbuf := Buffer; + //pointer to current arg + parg := Argv; + //for each const... + for i := 0 to Result - 1 do begin + case Args[i].VType of + vtInteger: begin + //integer + psrc := nil; + len := 0; + Integer(parg^) := Args[i].VInteger; + end; + vtString: begin + //short string + psrc := PAnsiChar(Cardinal(Args[i].VString) + SizeOf(Byte)); + len := PByte(Args[i].VString)^; + PAnsiChar(parg^) := pbuf; + end; + vtPChar: begin + //NULL terminated MBCS string + psrc := nil; + len := 0; + PAnsiChar(parg^) := Args[i].VPChar; + end; + vtPWideChar: begin + //NULL terminated Unicode string + temp := AnsiString(Args[i].VPWideChar); + psrc := PAnsiChar(temp); + len := Length(temp); + PAnsiChar(parg^) := pbuf; + end; + vtAnsiString: begin + //ANSI string + psrc := PAnsiChar(Args[i].VAnsiString); + len := StrLen(psrc); + PAnsiChar(parg^) := pbuf; + end; + vtWideString: begin + //Wide string (OLE) + temp := AnsiString(PWideChar(Args[i].VWideString)); + psrc := PAnsiChar(temp); + len := Length(temp); + PAnsiChar(parg^) := pbuf; + end; + else raise Exception.Create('Unsupported argument type'); + end; + if (psrc <> nil) and (len <> 0) then begin + //enough space to hold string? + if Size < (len + 1) then + raise Exception.Create('Buffer overflow'); + //copy string + Move(psrc^, pbuf^, len); + //NULL terminator + PAnsiChar(Cardinal(pbuf) + len)^ := #0; + //shift pointer... + Inc(pbuf, len + 1); + //...and decrease space left + Dec(Size, len + 1); + end; + Cardinal(parg) := Cardinal(parg) + SizeOf(Pointer); + end; + end; + + procedure DoVarargsCall(fif: Integer; fmt: PAnsiChar; Argv: Pointer; Argc: Integer); + { + fif -> EAX + fmt -> EDX + Argv -> ECX + Argc -> [EBP+$08] + } + asm + PUSH EAX //remember fif + PUSH ECX //make room for ESP backup + + MOV DWORD PTR [EBP-$08], ESP //backup stack pointer + + MOV EAX, DWORD PTR [EBP+$08] //store Argc + + TEST EAX, EAX //Argc <= 0? + JLE @Call + + @Loop: + PUSH DWORD PTR [ECX+EAX*$04-$04] //push Argv in right to left order + DEC EAX + JNZ @Loop + + @Call: + PUSH EDX //push fmt + PUSH DWORD PTR [EBP-$04] //push fif + CALL __FreeImage_OutputMessageProc + + MOV ESP, DWORD PTR [EBP-$08] //restore stack pointer + + POP ECX //clean stack + POP EAX + end; +var + Argc: Integer; + Argv: Pointer; + //buffer to hold strings - FreeImage allocates 512 bytes, we needn't more... + Buffer: array[1..512] of Byte; +begin + Argv := nil; + //build array of pointers from array of const + Argc := ArrayToBuffer(args, Argv, @Buffer, SizeOf(Buffer)); + try + //mimic cdecl call with varargs + DoVarargsCall(fif, fmt, Argv, Argc); + finally + //cleanup + FreeMem(Argv); + end; +end; +{$ENDIF} + +end. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/src/FreeUtils.pas b/#ThirdParty/FreeImage/Wrapper/Delphi/src/FreeUtils.pas new file mode 100644 index 0000000..9665dca --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/src/FreeUtils.pas @@ -0,0 +1,186 @@ +unit FreeUtils; + +// ========================================================== +// +// Delphi wrapper for FreeImage 3 +// +// Design and implementation by +// - Anatoliy Pulyaevskiy (xvel84@rambler.ru) +// +// Contributors: +// - Enzo Costantini (enzocostantini@libero.it) +// - Armindo (tech1.yxendis@wanadoo.fr) +// - Lorenzo Monti (LM) lomo74@gmail.com +// +// Revision history +// When Who What +// ----------- ----- ----------------------------------------------------------- +// 2010-07-14 LM made RAD2010 compliant (unicode) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// +// ========================================================== + +interface + +{$I 'Version.inc'} + +uses + {$IFDEF DELPHI2010}AnsiStrings,{$ENDIF} SysUtils, Classes, FreeImage; + +function FIU_GetFIFType(filename: AnsiString): FREE_IMAGE_FORMAT; + +// returns FIF (plugin) description string +function FIU_GetFIFDescription(fif: FREE_IMAGE_FORMAT): AnsiString; + +procedure FIU_GetAllDescriptions(var Descriptions: TStringList); + +// returns file extentions for FIF (e.g. '*.tif;*.tiff) +function FIU_GetFIFExtList(fif: FREE_IMAGE_FORMAT): AnsiString; + +// returns file extentions for all plugins +function FIU_GetFullExtList: AnsiString; + +// returns "Description + | + ExtList" for specified FIF +function FIU_GetFIFFilter(fif: FREE_IMAGE_FORMAT): AnsiString; + +// All supported formats + Full filter list for FIFs +function FIU_GetAllFilters: AnsiString; + +//Filter for OpenDialogs +function FIU_GetAllOpenFilters: AnsiString; + +//Filter for SaveDialogs +function FIU_GetAllSaveFilters: AnsiString; + +implementation + +const + FIF_START = FIF_UNKNOWN; + FIF_END = FIF_XPM; + +function FIU_GetFIFType(filename: AnsiString): FREE_IMAGE_FORMAT; +begin + Result := FreeImage_GetFileType(PAnsiChar(filename), 0); +end; + +function FIU_GetFIFDescription(fif: FREE_IMAGE_FORMAT): AnsiString; +begin + Result := FreeImage_GetFIFDescription(fif) +end; + +procedure FIU_GetAllDescriptions(var Descriptions: TStringList); +var + fif: FREE_IMAGE_FORMAT; +begin + Descriptions.Clear; + for fif := FIF_START to FIF_END do + Descriptions.Add(string(FreeImage_GetFIFDescription(fif)) + ' (' + + string(FIu_GetFIFExtList(fif)) + ')'); +end; + +function FIU_GetFIFExtList(fif: FREE_IMAGE_FORMAT): AnsiString; +var + ExtList: AnsiString; + I: Smallint; + C: AnsiChar; +begin + Result := '*.'; + ExtList := FreeImage_GetFIFExtensionList(fif); + for I := 1 to Length(ExtList) do + begin + C := ExtList[i]; + if C <> ',' then + Result := Result + C + else + Result := Result + ';*.'; + end +end; + +function FIU_GetFullExtList: AnsiString; +var + fif: FREE_IMAGE_FORMAT; +begin + Result := FIU_GetFIFExtList(FIF_START); + for fif := FIF_START to FIF_END do + Result := Result + ';' + FIU_GetFIFExtList(fif) +end; + +function FIU_GetFIFFilter(fif: FREE_IMAGE_FORMAT): AnsiString; +var + Text, ExtList: AnsiString; +begin + Result := ''; + if fif <> FIF_UNKNOWN then + begin + Text := {$IFDEF DELPHI2010}AnsiStrings.{$ENDIF}Trim(FreeImage_GetFIFDescription(fif)); + ExtList := FIU_GetFIFExtList(fif); + Result := Text + '(' + ExtList + ')' + '|' + ExtList + end +end; + +function FIU_GetAllFilters: AnsiString; +var + fif: FREE_IMAGE_FORMAT; +begin + Result := 'All supported formats|' + FIU_GetFullExtList; + for fif := FIF_START to FIF_END do + begin + Result := Result + '|' + FIU_GetFIFFilter(fif) + end; +end; + +function FIU_GetAllOpenFilters: AnsiString; +var + fif: FREE_IMAGE_FORMAT; +begin + Result := 'All supported formats|' + FIU_GetFullExtList; + for fif := FIF_START to FIF_END do + if FreeImage_FIFSupportsReading(fif) then + begin + Result := Result + '|' + FIU_GetFIFFilter(fif) + end; +end; + +function FIU_GetAllSaveFilters: AnsiString; +var + ExtList: AnsiString; + I: Smallint; + C: AnsiChar; + fif: FREE_IMAGE_FORMAT; + s: AnsiString; +begin + result := ''; + for fif := FIF_START to FIF_END do + if FreeImage_FIFSupportsWriting(fif) then + begin + ExtList := FreeImage_GetFIFExtensionList(fif); + s := ''; + for I := 1 to Length(ExtList) do + begin + C := ExtList[i]; + if C <> ',' then + S := S + C + else + begin + result := Result + FreeImage_GetFIFDescription(fif) + ' (' + UpperCase(s) + ')|*.' + s + '|'; + s := ''; + end; + end; + result := Result + FreeImage_GetFIFDescription(fif) + ' (' + UpperCase(s) + ')|*.' + s + '|'; + end; +end; + +end. diff --git a/#ThirdParty/FreeImage/Wrapper/Delphi/src/Version.inc b/#ThirdParty/FreeImage/Wrapper/Delphi/src/Version.inc new file mode 100644 index 0000000..f72863d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/Delphi/src/Version.inc @@ -0,0 +1,305 @@ +// ========================================================== +// Delphi wrapper for FreeImage 3 +// +// Design and implementation by +// - Simon Beavis +// - Peter Byström +// - Anatoliy Pulyaevskiy (xvel84@rambler.ru) +// +// Contributors: +// - Lorenzo Monti (LM) lomo74@gmail.com +// +// Revision history +// When Who What +// ----------- ----- ----------------------------------------------------------- +// 2010-07-29 LM Added Free Pascal / Lazarus 32 bit support +// 2010-11-12 LM Added Delphi XE support +// 2011-03-04 JMB Added 64 bit compiler support +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +//some older Delphi version will define WIN32 but not MSWINDOWS +{$IFNDEF MSWINDOWS} + {$IFDEF WIN32} + {$DEFINE MSWINDOWS} + {$ENDIF} +{$ENDIF} + +//test for compiler +{$IFDEF FPC} + //Free pascal + {$IFNDEF CPU32} + //{$ERROR "64 bit platforms not tested yet. Remove this line if you feel brave."} + {$ENDIF} + {$IFNDEF ENDIAN_LITTLE} + {$ERROR "Big endian CPUs not tested yet. Remove this line if you feel brave."} + {$ENDIF} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} +{$ELSE} + //Delphi + {$IFDEF VER80} + {$DEFINE DELPHI1} + {$ENDIF} + + {$IFDEF VER90} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$ENDIF} + + {$IFDEF VER100} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$ENDIF} + + {$IFDEF VER120} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$ENDIF} + + {$IFDEF VER130} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$ENDIF} + + {$IFDEF VER140} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$ENDIF} + + {$IFDEF VER150} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$ENDIF} + + {$IFDEF VER160} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$ENDIF} + + {$IFDEF VER170} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$ENDIF} + + {$IFDEF VER180} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$DEFINE DELPHI2006} + {$ENDIF} + + {$IFDEF VER185} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$DEFINE DELPHI2006} + {$DEFINE DELPHI2007} + {$ENDIF} + + {$IFDEF VER200} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$DEFINE DELPHI2006} + {$DEFINE DELPHI2007} + {$DEFINE DELPHI2009} + {$ENDIF} + + {$IFDEF VER210} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$DEFINE DELPHI2006} + {$DEFINE DELPHI2007} + {$DEFINE DELPHI2009} + {$DEFINE DELPHI2010} + {$ENDIF} + + {$IFDEF VER220} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$DEFINE DELPHI2006} + {$DEFINE DELPHI2007} + {$DEFINE DELPHI2009} + {$DEFINE DELPHI2010} + {$DEFINE DELPHIXE} + {$ENDIF} + + {$IFDEF VER230} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$DEFINE DELPHI2006} + {$DEFINE DELPHI2007} + {$DEFINE DELPHI2009} + {$DEFINE DELPHI2010} + {$DEFINE DELPHIXE} + {$DEFINE DELPHIXE2} + {$ENDIF} + + {$IFDEF VER240} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$DEFINE DELPHI2006} + {$DEFINE DELPHI2007} + {$DEFINE DELPHI2009} + {$DEFINE DELPHI2010} + {$DEFINE DELPHIXE} + {$DEFINE DELPHIXE2} + {$DEFINE DELPHIXE3} + {$ENDIF} + + {$IFDEF VER250} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$DEFINE DELPHI2006} + {$DEFINE DELPHI2007} + {$DEFINE DELPHI2009} + {$DEFINE DELPHI2010} + {$DEFINE DELPHIXE} + {$DEFINE DELPHIXE2} + {$DEFINE DELPHIXE3} + {$DEFINE DELPHIXE4} + {$ENDIF} + + {$IFDEF VER260} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$DEFINE DELPHI2006} + {$DEFINE DELPHI2007} + {$DEFINE DELPHI2009} + {$DEFINE DELPHI2010} + {$DEFINE DELPHIXE} + {$DEFINE DELPHIXE2} + {$DEFINE DELPHIXE3} + {$DEFINE DELPHIXE4} + {$DEFINE DELPHIXE5} + {$ENDIF} + + {$IFDEF VER270} + {$DEFINE DELPHI1} + {$DEFINE DELPHI2} + {$DEFINE DELPHI3} + {$DEFINE DELPHI4} + {$DEFINE DELPHI5} + {$DEFINE DELPHI6} + {$DEFINE DELPHI7} + {$DEFINE DELPHI8} + {$DEFINE DELPHI2005} + {$DEFINE DELPHI2006} + {$DEFINE DELPHI2007} + {$DEFINE DELPHI2009} + {$DEFINE DELPHI2010} + {$DEFINE DELPHIXE} + {$DEFINE DELPHIXE2} + {$DEFINE DELPHIXE3} + {$DEFINE DELPHIXE4} + {$DEFINE DELPHIXE5} + {$DEFINE DELPHIXE6} + {$ENDIF} +{$ENDIF} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/AssemblyInfo.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/AssemblyInfo.cpp new file mode 100644 index 0000000..2c401db --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/AssemblyInfo.cpp @@ -0,0 +1,58 @@ +#include "stdafx.h" + +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("")]; +[assembly:AssemblyCopyrightAttribute("")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project directory. +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly:AssemblyDelaySignAttribute(false)]; +[assembly:AssemblyKeyFileAttribute("")]; +[assembly:AssemblyKeyNameAttribute("")]; + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.Net.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.Net.cpp new file mode 100644 index 0000000..cbc88b7 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.Net.cpp @@ -0,0 +1,69 @@ +// ========================================================== +// FreeImageIO.Net +// +// Design and implementation by +// - Marcos Pernambuco Motta (marcos.pernambuco@gmail.com) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "stdafx.h" +#include "FreeImageIO.Net.h" + + +extern "C" static unsigned __stdcall ReadProc (void *buffer, unsigned size, unsigned count, fi_handle handle) +{ + int total_read = 0; + struct UNMANAGED_HANDLER* puh = (struct UNMANAGED_HANDLER*)handle; + gcroot mbuffer = new unsigned char __gc[size]; + try + { + total_read = puh->_stream->Read(mbuffer,0,size); + Marshal::Copy(mbuffer,0,buffer,total_read); + } __finally { + mbuffer=NULL; + } + return (unsigned)total_read; +} + +extern "C" static unsigned __stdcall WriteProc (void *buffer, unsigned size, unsigned count, fi_handle handle) +{ + struct UNMANAGED_HANDLER* puh = (struct UNMANAGED_HANDLER*)handle; + gcroot mbuffer = new unsigned char __gc[size*count]; + try + { + + unsigned char __pin* pbuffer = &mbuffer[0]; + memcpy(pbuffer,buffer,size*count); + puh->_stream->Write(mbuffer,0,size); + } __finally { + mbuffer=NULL; + } + return count; +} + +extern "C" static int __stdcall SeekProc (fi_handle handle, long offset, int origin) +{ + struct UNMANAGED_HANDLER* puh = (struct UNMANAGED_HANDLER*)handle; + return (int)puh->_stream->Seek(offset,(SeekOrigin) origin); + +} + +extern "C" static long __stdcall TellProc(fi_handle handle) +{ + struct UNMANAGED_HANDLER* puh = (struct UNMANAGED_HANDLER*)handle; + return (long)puh->_stream->Position; +} + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.Net.h b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.Net.h new file mode 100644 index 0000000..358e871 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.Net.h @@ -0,0 +1,83 @@ +// ========================================================== +// FreeImageIO.Net +// +// Design and implementation by +// - Marcos Pernambuco Motta (marcos.pernambuco@gmail.com) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#pragma once +#include +#include "FreeImage.h" + +using namespace System; +using namespace System::IO; +using namespace System::Runtime::InteropServices; + +extern "C" { + // forward decls + unsigned __stdcall ReadProc (void *buffer, unsigned size, unsigned count, fi_handle handle); + unsigned __stdcall WriteProc (void *buffer, unsigned size, unsigned count, fi_handle handle); + int __stdcall SeekProc (fi_handle handle, long offset, int origin); + long __stdcall TellProc(fi_handle handle); + + #pragma pack(push, 1) + __nogc struct UNMANAGED_HANDLER { + UNMANAGED_HANDLER() { + read_proc = &ReadProc; + write_proc = WriteProc; + seek_proc = SeekProc; + tell_proc = TellProc; + } + FI_ReadProc read_proc; // pointer to the function used to read data + FI_WriteProc write_proc; // pointer to the function used to write data + FI_SeekProc seek_proc; // pointer to the function used to seek + FI_TellProc tell_proc; // pointer to the function used to aquire the current position + gcroot _stream; + }; + #pragma pack(pop) +} + +#define FREEIMAGE_DLL "freeimaged.dll" + +namespace FreeImageIODotNet +{ + __gc public class FreeImageStream + { + private: + struct UNMANAGED_HANDLER* _pUnmanaged; + public: + FreeImageStream(System::IO::Stream* stream) + { + FreeImage_SaveToHandle((FREE_IMAGE_FORMAT) 1,0,0,0,0); + _pUnmanaged = new struct UNMANAGED_HANDLER; + _pUnmanaged->_stream = stream; + } + ~FreeImageStream() + { + _pUnmanaged->_stream = NULL; + delete _pUnmanaged; + } + + bool SaveImage(FREE_IMAGE_FORMAT fif, unsigned int dib, int flags) { + return (bool)FreeImage_SaveToHandle(fif,(FIBITMAP*) dib,(FreeImageIO*)_pUnmanaged,(fi_handle)_pUnmanaged,flags); + } + + unsigned int LoadImage(FREE_IMAGE_FORMAT fif, int flags) { + return (unsigned int)FreeImage_LoadFromHandle(fif,(FreeImageIO*)_pUnmanaged,(fi_handle)_pUnmanaged,flags); + } + }; +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.Net.vcproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.Net.vcproj new file mode 100644 index 0000000..ddb942f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.Net.vcproj @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.sln b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.sln new file mode 100644 index 0000000..93bf45d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/FreeImageIO.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeImageIO.Net", "FreeImageIO.Net.vcproj", "{E87923FF-1FBD-450D-9287-539A90DE9776}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {E87923FF-1FBD-450D-9287-539A90DE9776}.Debug.ActiveCfg = Debug|Win32 + {E87923FF-1FBD-450D-9287-539A90DE9776}.Debug.Build.0 = Debug|Win32 + {E87923FF-1FBD-450D-9287-539A90DE9776}.Release.ActiveCfg = Release|Win32 + {E87923FF-1FBD-450D-9287-539A90DE9776}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/ReadMe.txt b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/ReadMe.txt new file mode 100644 index 0000000..8412e57 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/ReadMe.txt @@ -0,0 +1,27 @@ +======================================================================== +FreeImageIO.Net + +Author: Marcos Pernambuco Motta (marcos.pernambuco@gmail.com) +======================================================================== + +This library allows programs that use FreeImage.Net to save images to or +to load images from .Net Streams. + +The class FreeImageStream implements a FreeImageIO handler and routes +IO calls (read,write,tell and seek) to a wrapped System.IO.Stream. + +Example: + +using FreeImageAPI; +using FreeImageIODotNet; + +uint dib = FreeImageAPI.FreeImage.Allocate(width,height,32,0,0,0); + +// ... Image handling code goes here + +System.IO.FileStream stream = new System.IO.FileStream(@"c:\sample.png",System.IO.FileMode.Create); +FreeImageStream imageStream = new FreeImageStream(stream); +imageStream.SaveImage((int)FREE_IMAGE_FORMAT.FIF_PNG,dib,0); +stream.Close(); + +Compile with VS2003. diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/Stdafx.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/Stdafx.cpp new file mode 100644 index 0000000..4f8b8cf --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/Stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// FreeImageIO.Net.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/Stdafx.h b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/Stdafx.h new file mode 100644 index 0000000..07ec3fb --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/Stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#pragma once + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/app.ico b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/app.ico differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/app.rc b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/app.rc new file mode 100644 index 0000000..b488dbd --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/app.rc @@ -0,0 +1,52 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/resource.h b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cpp/FreeImageIO/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Bin/delete.me b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Bin/delete.me new file mode 100644 index 0000000..ee53b98 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Bin/delete.me @@ -0,0 +1 @@ +You may safely delete this file. diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Content.txt b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Content.txt new file mode 100644 index 0000000..9d17916 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Content.txt @@ -0,0 +1,43 @@ + +This file gives you a short description of the .NET wrapper's folders +and what's located in them. + + +"Doc" +Sandcastle Help File Builder project file for creating a Microsoft Help API +documentation (CHM file). +FreeImage.NET uses Eric Woodruff's Sandcastle Help File Builder GUI to +generate the API documentation. See http://www.codeplex.com/SHFB + +"Library" +Source code of the C# .NET wrapper. Builds the FreeImageNET.dll. + +"Samples" +Example projects showing how to use the wrapper. + +"SourceFileMerger" +Program to merge all the wrapper's source files into a single source file +for easy integration into your projects on source code basis. + +"UnitTest" +NUnit-based test project for the .NET wrapper. NUnit needs to be installed +for this project to work. + +"UnitTestData" (not in CVS) +Several images in each available color depth used by "UnitTest". + +"clear.bat" +Batch file to clear the whole project, removing all temporary files. + +"FreeImage.chm" (not in CVS) +The .NET wrapper's API documentation. Build with Microsoft's Sandcastle +project from C# source code documentation. + +"FreeImage.NET.nunit" +NUnit project file. NUnit needs to be installed for this project to work. + +"FreeImage.NET.sln" +The Microsoft Visual Studio 2005 solution file. + +"Whats_New.NET.txt" +The changelog. \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/3.11.0/FreeImage.NET.shfbproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/3.11.0/FreeImage.NET.shfbproj new file mode 100644 index 0000000..1e4da12 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/3.11.0/FreeImage.NET.shfbproj @@ -0,0 +1,41 @@ + + + + Debug + AnyCPU + 2.0 + {d68736d0-a80d-453c-a921-6ada865504b5} + 1.8.0.0 + + Documentation + Documentation + Documentation + + .\Out\ + FreeImage.NET + HtmlHelp1x + False + FreeImage - The productivity booster. FreeImage is licensed under the GNU General Public License %28GPL%29 and the FreeImage Public License %28FIPL%29. + FreeImage .NET Documentation + HashedMemberName + Msdn + AutoDocumentCtors + InheritedMembers, Protected + + + + + + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/3.12.0/FreeImage.NET.shfbproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/3.12.0/FreeImage.NET.shfbproj new file mode 100644 index 0000000..1e4da12 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/3.12.0/FreeImage.NET.shfbproj @@ -0,0 +1,41 @@ + + + + Debug + AnyCPU + 2.0 + {d68736d0-a80d-453c-a921-6ada865504b5} + 1.8.0.0 + + Documentation + Documentation + Documentation + + .\Out\ + FreeImage.NET + HtmlHelp1x + False + FreeImage - The productivity booster. FreeImage is licensed under the GNU General Public License %28GPL%29 and the FreeImage Public License %28FIPL%29. + FreeImage .NET Documentation + HashedMemberName + Msdn + AutoDocumentCtors + InheritedMembers, Protected + + + + + + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/3.13.0/FreeImage.NET.shfbproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/3.13.0/FreeImage.NET.shfbproj new file mode 100644 index 0000000..1e4da12 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/3.13.0/FreeImage.NET.shfbproj @@ -0,0 +1,41 @@ + + + + Debug + AnyCPU + 2.0 + {d68736d0-a80d-453c-a921-6ada865504b5} + 1.8.0.0 + + Documentation + Documentation + Documentation + + .\Out\ + FreeImage.NET + HtmlHelp1x + False + FreeImage - The productivity booster. FreeImage is licensed under the GNU General Public License %28GPL%29 and the FreeImage Public License %28FIPL%29. + FreeImage .NET Documentation + HashedMemberName + Msdn + AutoDocumentCtors + InheritedMembers, Protected + + + + + + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/FreeImage.NET.shfbproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/FreeImage.NET.shfbproj new file mode 100644 index 0000000..fd76c1a --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/FreeImage.NET.shfbproj @@ -0,0 +1,52 @@ + + + + Debug + AnyCPU + 2.0 + {d68736d0-a80d-453c-a921-6ada865504b5} + 1.8.0.0 + + Documentation + Documentation + Documentation + + .\Out\ + FreeImage.NET + HtmlHelp1x + False + FreeImage - The productivity booster. FreeImage is licensed under the GNU General Public License %28GPL%29 and the FreeImage Public License %28FIPL%29. + FreeImage .NET Documentation + HashedMemberName + Msdn + AutoDocumentCtors + InheritedMembers, Protected + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/SHFB.txt b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/SHFB.txt new file mode 100644 index 0000000..fae9b3f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Doc/SHFB.txt @@ -0,0 +1,9 @@ +Eric Woodruff's Sandcastle Help File Builder 1.6.x.x (SHFB) is needed for FreeImage.NET wrapper +help file creation. It can be downloaded from http://www.codeplex.com/SHFB + +As of FreeImage.NET version 1.08, version 1.8.01 of Sandcastle Help File Builder is used by FreeImage.NET +and thus needed for FreeImage.NET wrapper help file creation. It can still be downloaded +from http://www.codeplex.com/SHFB + +Microsoft's Sandcaste is also needed for SHFB to run correctly. It can be downloaded from +http://www.microsoft.com/downloads/details.aspx?FamilyId=E82EA71D-DA89-42EE-A715-696E3A4873B2&displaylang=en diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/FreeImage.NET.2005.sln b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/FreeImage.NET.2005.sln new file mode 100644 index 0000000..c86757e --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/FreeImage.NET.2005.sln @@ -0,0 +1,214 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "Library\Library.2005.csproj", "{6598A7CD-8F27-4D3F-A675-5AE63113A7C3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceFileMerger", "SourceFileMerger\SourceFileMerger.2005.csproj", "{2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.2005.csproj", "{FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 01 - Loading and saving", "Samples\Sample 01 - Loading and saving\Sample 01 - Loading and saving.2005.csproj", "{0D294AB6-FAD4-4364-AAB6-43C1796116A9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 02 - Multipaged bitmaps", "Samples\Sample 02 - Multipaged bitmaps\Sample 02 - Multipaged bitmaps.2005.csproj", "{AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 03 - Allocating", "Samples\Sample 03 - Allocating\Sample 03 - Allocating.2005.csproj", "{A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 04 - Getting bitmap informations", "Samples\Sample 04 - Getting bitmap informations\Sample 04 - Getting bitmap informations.2005.csproj", "{1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 05 - Working with pixels", "Samples\Sample 05 - Working with pixels\Sample 05 - Working with pixels.2005.csproj", "{A501F134-8FB6-460B-AFE9-884A696C1C07}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 06 - Converting", "Samples\Sample 06 - Converting\Sample 06 - Converting.2005.csproj", "{E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 07 - ICC Profiles", "Samples\Sample 07 - ICC Profiles\Sample 07 - ICC Profiles.2005.csproj", "{3B1BB976-64A7-41FD-B7E2-59104161AF7E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 08 - Creating a plugin", "Samples\Sample 08 - Creating a plugin\Sample 08 - Creating a plugin.2005.csproj", "{491042DB-495B-420C-A3BE-5D13019707C5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 09 - Working with streams", "Samples\Sample 09 - Working with streams\Sample 09 - Working with streams.2005.csproj", "{92A454B2-67EF-4B70-99C9-F22B83B6FBFF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 10 - Metadata", "Samples\Sample 10 - Metadata\Sample 10 - Metadata.2005.csproj", "{55DCC37A-E56C-44D9-9C44-8DAB10CD3003}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 11 - Using the FreeImageBitmap class", "Samples\Sample 11 - Using the FreeImageBitmap class\Sample 11 - Using the FreeImageBitmap class.2005.csproj", "{996068CD-D07A-42E0-856F-ACC71E8565EF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|x64.ActiveCfg = Debug|x64 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|x64.Build.0 = Debug|x64 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|x86.ActiveCfg = Debug|x86 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|x86.Build.0 = Debug|x86 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|Any CPU.Build.0 = Release|Any CPU + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x64.ActiveCfg = Release|x64 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x64.Build.0 = Release|x64 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x86.ActiveCfg = Release|x86 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x86.Build.0 = Release|x86 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|x64.ActiveCfg = Debug|x64 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|x64.Build.0 = Debug|x64 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|x86.ActiveCfg = Debug|x86 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|x86.Build.0 = Debug|x86 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|Any CPU.Build.0 = Release|Any CPU + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|x64.ActiveCfg = Release|x64 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|x64.Build.0 = Release|x64 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|x86.ActiveCfg = Release|x86 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|x86.Build.0 = Release|x86 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|x64.ActiveCfg = Debug|x64 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|x64.Build.0 = Debug|x64 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|x86.ActiveCfg = Debug|x86 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|x86.Build.0 = Debug|x86 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|Any CPU.Build.0 = Release|Any CPU + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|x64.ActiveCfg = Release|x64 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|x64.Build.0 = Release|x64 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|x86.ActiveCfg = Release|x86 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|x86.Build.0 = Release|x86 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|x64.ActiveCfg = Debug|x64 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|x64.Build.0 = Debug|x64 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|x86.ActiveCfg = Debug|x86 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|x86.Build.0 = Debug|x86 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|Any CPU.Build.0 = Release|Any CPU + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|x64.ActiveCfg = Release|x64 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|x64.Build.0 = Release|x64 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|x86.ActiveCfg = Release|x86 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|x86.Build.0 = Release|x86 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|x64.ActiveCfg = Debug|x64 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|x64.Build.0 = Debug|x64 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|x86.ActiveCfg = Debug|x86 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|x86.Build.0 = Debug|x86 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|Any CPU.Build.0 = Release|Any CPU + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|x64.ActiveCfg = Release|x64 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|x64.Build.0 = Release|x64 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|x86.ActiveCfg = Release|x86 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|x86.Build.0 = Release|x86 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|x64.ActiveCfg = Debug|x64 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|x64.Build.0 = Debug|x64 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|x86.ActiveCfg = Debug|x86 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|x86.Build.0 = Debug|x86 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|Any CPU.Build.0 = Release|Any CPU + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|x64.ActiveCfg = Release|x64 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|x64.Build.0 = Release|x64 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|x86.ActiveCfg = Release|x86 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|x86.Build.0 = Release|x86 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|x64.ActiveCfg = Debug|x64 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|x64.Build.0 = Debug|x64 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|x86.ActiveCfg = Debug|x86 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|x86.Build.0 = Debug|x86 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|Any CPU.Build.0 = Release|Any CPU + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|x64.ActiveCfg = Release|x64 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|x64.Build.0 = Release|x64 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|x86.ActiveCfg = Release|x86 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|x86.Build.0 = Release|x86 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|x64.ActiveCfg = Debug|x64 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|x64.Build.0 = Debug|x64 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|x86.ActiveCfg = Debug|x86 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|x86.Build.0 = Debug|x86 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|Any CPU.Build.0 = Release|Any CPU + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|x64.ActiveCfg = Release|x64 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|x64.Build.0 = Release|x64 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|x86.ActiveCfg = Release|x86 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|x86.Build.0 = Release|x86 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|x64.ActiveCfg = Debug|x64 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|x64.Build.0 = Debug|x64 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|x86.ActiveCfg = Debug|x86 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|x86.Build.0 = Debug|x86 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|Any CPU.Build.0 = Release|Any CPU + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|x64.ActiveCfg = Release|x64 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|x64.Build.0 = Release|x64 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|x86.ActiveCfg = Release|x86 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|x86.Build.0 = Release|x86 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|x64.ActiveCfg = Debug|x64 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|x64.Build.0 = Debug|x64 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|x86.ActiveCfg = Debug|x86 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|x86.Build.0 = Debug|x86 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|Any CPU.Build.0 = Release|Any CPU + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|x64.ActiveCfg = Release|x64 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|x64.Build.0 = Release|x64 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|x86.ActiveCfg = Release|x86 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|x86.Build.0 = Release|x86 + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|x64.ActiveCfg = Debug|x64 + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|x64.Build.0 = Debug|x64 + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|x86.ActiveCfg = Debug|x86 + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|x86.Build.0 = Debug|x86 + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|Any CPU.Build.0 = Release|Any CPU + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|x64.ActiveCfg = Release|x64 + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|x64.Build.0 = Release|x64 + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|x86.ActiveCfg = Release|x86 + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|x86.Build.0 = Release|x86 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|x64.ActiveCfg = Debug|x64 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|x64.Build.0 = Debug|x64 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|x86.ActiveCfg = Debug|x86 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|x86.Build.0 = Debug|x86 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|Any CPU.Build.0 = Release|Any CPU + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|x64.ActiveCfg = Release|x64 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|x64.Build.0 = Release|x64 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|x86.ActiveCfg = Release|x86 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|x86.Build.0 = Release|x86 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|Any CPU.Build.0 = Debug|Any CPU + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|x64.ActiveCfg = Debug|x64 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|x64.Build.0 = Debug|x64 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|x86.ActiveCfg = Debug|x86 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|x86.Build.0 = Debug|x86 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|Any CPU.ActiveCfg = Release|Any CPU + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|Any CPU.Build.0 = Release|Any CPU + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|x64.ActiveCfg = Release|x64 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|x64.Build.0 = Release|x64 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|x86.ActiveCfg = Release|x86 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|x86.Build.0 = Release|x86 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|x64.ActiveCfg = Debug|x64 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|x64.Build.0 = Debug|x64 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|x86.ActiveCfg = Debug|x86 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|x86.Build.0 = Debug|x86 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|Any CPU.Build.0 = Release|Any CPU + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|x64.ActiveCfg = Release|x64 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|x64.Build.0 = Release|x64 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|x86.ActiveCfg = Release|x86 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/FreeImage.NET.nunit b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/FreeImage.NET.nunit new file mode 100644 index 0000000..c1da949 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/FreeImage.NET.nunit @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/FreeImage.NET.sln b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/FreeImage.NET.sln new file mode 100644 index 0000000..e2df94d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/FreeImage.NET.sln @@ -0,0 +1,214 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "Library\Library.csproj", "{6598A7CD-8F27-4D3F-A675-5AE63113A7C3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceFileMerger", "SourceFileMerger\SourceFileMerger.csproj", "{2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 01 - Loading and saving", "Samples\Sample 01 - Loading and saving\Sample 01 - Loading and saving.csproj", "{0D294AB6-FAD4-4364-AAB6-43C1796116A9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 02 - Multipaged bitmaps", "Samples\Sample 02 - Multipaged bitmaps\Sample 02 - Multipaged bitmaps.csproj", "{AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 03 - Allocating", "Samples\Sample 03 - Allocating\Sample 03 - Allocating.csproj", "{A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 04 - Getting bitmap informations", "Samples\Sample 04 - Getting bitmap informations\Sample 04 - Getting bitmap informations.csproj", "{1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 05 - Working with pixels", "Samples\Sample 05 - Working with pixels\Sample 05 - Working with pixels.csproj", "{A501F134-8FB6-460B-AFE9-884A696C1C07}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 06 - Converting", "Samples\Sample 06 - Converting\Sample 06 - Converting.csproj", "{E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 07 - ICC Profiles", "Samples\Sample 07 - ICC Profiles\Sample 07 - ICC Profiles.csproj", "{3B1BB976-64A7-41FD-B7E2-59104161AF7E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 08 - Creating a plugin", "Samples\Sample 08 - Creating a plugin\Sample 08 - Creating a plugin.csproj", "{491042DB-495B-420C-A3BE-5D13019707C5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 09 - Working with streams", "Samples\Sample 09 - Working with streams\Sample 09 - Working with streams.csproj", "{92A454B2-67EF-4B70-99C9-F22B83B6FBFF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 10 - Metadata", "Samples\Sample 10 - Metadata\Sample 10 - Metadata.csproj", "{55DCC37A-E56C-44D9-9C44-8DAB10CD3003}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample 11 - Using the FreeImageBitmap class", "Samples\Sample 11 - Using the FreeImageBitmap class\Sample 11 - Using the FreeImageBitmap class.csproj", "{996068CD-D07A-42E0-856F-ACC71E8565EF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|x64.ActiveCfg = Debug|x64 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|x64.Build.0 = Debug|x64 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|x86.ActiveCfg = Debug|x86 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Debug|x86.Build.0 = Debug|x86 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|Any CPU.Build.0 = Release|Any CPU + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x64.ActiveCfg = Release|x64 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x64.Build.0 = Release|x64 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x86.ActiveCfg = Release|x86 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x86.Build.0 = Release|x86 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|x64.ActiveCfg = Debug|x64 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|x64.Build.0 = Debug|x64 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|x86.ActiveCfg = Debug|x86 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Debug|x86.Build.0 = Debug|x86 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|Any CPU.Build.0 = Release|Any CPU + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|x64.ActiveCfg = Release|x64 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|x64.Build.0 = Release|x64 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|x86.ActiveCfg = Release|x86 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1}.Release|x86.Build.0 = Release|x86 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|x64.ActiveCfg = Debug|x64 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|x64.Build.0 = Debug|x64 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|x86.ActiveCfg = Debug|x86 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Debug|x86.Build.0 = Debug|x86 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|Any CPU.Build.0 = Release|Any CPU + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|x64.ActiveCfg = Release|x64 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|x64.Build.0 = Release|x64 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|x86.ActiveCfg = Release|x86 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC}.Release|x86.Build.0 = Release|x86 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|x64.ActiveCfg = Debug|x64 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|x64.Build.0 = Debug|x64 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|x86.ActiveCfg = Debug|x86 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Debug|x86.Build.0 = Debug|x86 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|Any CPU.Build.0 = Release|Any CPU + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|x64.ActiveCfg = Release|x64 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|x64.Build.0 = Release|x64 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|x86.ActiveCfg = Release|x86 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9}.Release|x86.Build.0 = Release|x86 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|x64.ActiveCfg = Debug|x64 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|x64.Build.0 = Debug|x64 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|x86.ActiveCfg = Debug|x86 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Debug|x86.Build.0 = Debug|x86 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|Any CPU.Build.0 = Release|Any CPU + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|x64.ActiveCfg = Release|x64 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|x64.Build.0 = Release|x64 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|x86.ActiveCfg = Release|x86 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}.Release|x86.Build.0 = Release|x86 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|x64.ActiveCfg = Debug|x64 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|x64.Build.0 = Debug|x64 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|x86.ActiveCfg = Debug|x86 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Debug|x86.Build.0 = Debug|x86 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|Any CPU.Build.0 = Release|Any CPU + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|x64.ActiveCfg = Release|x64 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|x64.Build.0 = Release|x64 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|x86.ActiveCfg = Release|x86 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}.Release|x86.Build.0 = Release|x86 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|x64.ActiveCfg = Debug|x64 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|x64.Build.0 = Debug|x64 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|x86.ActiveCfg = Debug|x86 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Debug|x86.Build.0 = Debug|x86 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|Any CPU.Build.0 = Release|Any CPU + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|x64.ActiveCfg = Release|x64 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|x64.Build.0 = Release|x64 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|x86.ActiveCfg = Release|x86 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}.Release|x86.Build.0 = Release|x86 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|x64.ActiveCfg = Debug|x64 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|x64.Build.0 = Debug|x64 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|x86.ActiveCfg = Debug|x86 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Debug|x86.Build.0 = Debug|x86 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|Any CPU.Build.0 = Release|Any CPU + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|x64.ActiveCfg = Release|x64 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|x64.Build.0 = Release|x64 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|x86.ActiveCfg = Release|x86 + {A501F134-8FB6-460B-AFE9-884A696C1C07}.Release|x86.Build.0 = Release|x86 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|x64.ActiveCfg = Debug|x64 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|x64.Build.0 = Debug|x64 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|x86.ActiveCfg = Debug|x86 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Debug|x86.Build.0 = Debug|x86 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|Any CPU.Build.0 = Release|Any CPU + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|x64.ActiveCfg = Release|x64 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|x64.Build.0 = Release|x64 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|x86.ActiveCfg = Release|x86 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}.Release|x86.Build.0 = Release|x86 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|x64.ActiveCfg = Debug|x64 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|x64.Build.0 = Debug|x64 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|x86.ActiveCfg = Debug|x86 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Debug|x86.Build.0 = Debug|x86 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|Any CPU.Build.0 = Release|Any CPU + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|x64.ActiveCfg = Release|x64 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|x64.Build.0 = Release|x64 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|x86.ActiveCfg = Release|x86 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E}.Release|x86.Build.0 = Release|x86 + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|x64.ActiveCfg = Debug|x64 + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|x64.Build.0 = Debug|x64 + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|x86.ActiveCfg = Debug|x86 + {491042DB-495B-420C-A3BE-5D13019707C5}.Debug|x86.Build.0 = Debug|x86 + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|Any CPU.Build.0 = Release|Any CPU + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|x64.ActiveCfg = Release|x64 + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|x64.Build.0 = Release|x64 + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|x86.ActiveCfg = Release|x86 + {491042DB-495B-420C-A3BE-5D13019707C5}.Release|x86.Build.0 = Release|x86 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|x64.ActiveCfg = Debug|x64 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|x64.Build.0 = Debug|x64 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|x86.ActiveCfg = Debug|x86 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Debug|x86.Build.0 = Debug|x86 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|Any CPU.Build.0 = Release|Any CPU + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|x64.ActiveCfg = Release|x64 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|x64.Build.0 = Release|x64 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|x86.ActiveCfg = Release|x86 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF}.Release|x86.Build.0 = Release|x86 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|Any CPU.Build.0 = Debug|Any CPU + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|x64.ActiveCfg = Debug|x64 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|x64.Build.0 = Debug|x64 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|x86.ActiveCfg = Debug|x86 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Debug|x86.Build.0 = Debug|x86 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|Any CPU.ActiveCfg = Release|Any CPU + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|Any CPU.Build.0 = Release|Any CPU + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|x64.ActiveCfg = Release|x64 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|x64.Build.0 = Release|x64 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|x86.ActiveCfg = Release|x86 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003}.Release|x86.Build.0 = Release|x86 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|x64.ActiveCfg = Debug|x64 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|x64.Build.0 = Debug|x64 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|x86.ActiveCfg = Debug|x86 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Debug|x86.Build.0 = Debug|x86 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|Any CPU.Build.0 = Release|Any CPU + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|x64.ActiveCfg = Release|x64 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|x64.Build.0 = Release|x64 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|x86.ActiveCfg = Release|x86 + {996068CD-D07A-42E0-856F-ACC71E8565EF}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImageBitmap.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImageBitmap.cs new file mode 100644 index 0000000..f22d396 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImageBitmap.cs @@ -0,0 +1,4378 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.12 $ +// $Date: 2011/12/22 14:54:22 $ +// $Id: FreeImageBitmap.cs,v 1.12 2011/12/22 14:54:22 drolon Exp $ +// ========================================================== + +using System; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.IO.Compression; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; +using System.Collections; +using System.Collections.Generic; +using FreeImageAPI.Metadata; +using System.Diagnostics; + +namespace FreeImageAPI +{ + /// + /// Encapsulates a FreeImage-bitmap. + /// + [Serializable, Guid("64a4c935-b757-499c-ab8c-6110316a9e51")] + public class FreeImageBitmap : MarshalByRefObject, ICloneable, IDisposable, IEnumerable, ISerializable + { + #region Fields + + /// + /// Indicates whether this instance is disposed. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool disposed; + + /// + /// Tab object. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private object tag; + + /// + /// Object used to syncronize lock methods. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private object lockObject = new object(); + + /// + /// Holds information used by SaveAdd() methods. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private SaveInformation saveInformation = new SaveInformation(); + + /// + /// The stream that this instance was loaded from or + /// null if it has been cloned or deserialized. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private Stream stream; + + /// + /// True if the stream must be disposed with this + /// instance. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool disposeStream; + + /// + /// The number of frames contained by a mutlipage bitmap. + /// Default value is 1 and only changed if needed. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private int frameCount = 1; + + /// + /// The index of the loaded frame. + /// Default value is 0 and only changed if needed. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private int frameIndex = 0; + + /// + /// Format of the sourceimage. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private FREE_IMAGE_FORMAT originalFormat = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + + /// + /// Handle to the encapsulated FreeImage-bitmap. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private FIBITMAP dib; + + private const string ErrorLoadingBitmap = "Unable to load bitmap."; + private const string ErrorLoadingFrame = "Unable to load frame."; + private const string ErrorCreatingBitmap = "Unable to create bitmap."; + private const string ErrorUnloadBitmap = "Unable to unload bitmap."; + + #endregion + + #region Constructors and Destructor + + /// + /// Initializes a new instance of the class. + /// + protected FreeImageBitmap() + { + } + + /// + /// Initializes a new instance of the class. + /// For internal use only. + /// + /// The operation failed. + internal protected FreeImageBitmap(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + this.dib = dib; + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image. + /// + /// The original to clone from. + /// The operation failed. + /// is a null reference. + public FreeImageBitmap(FreeImageBitmap original) + { + if (original == null) + { + throw new ArgumentNullException("original"); + } + original.EnsureNotDisposed(); + dib = FreeImage.Clone(original.dib); + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + originalFormat = original.originalFormat; + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// The Size structure that represent the + /// size of the new . + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + /// + public FreeImageBitmap(FreeImageBitmap original, Size newSize) + : this(original, newSize.Width, newSize.Height) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// Width of the new . + /// Height of the new . + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + public FreeImageBitmap(FreeImageBitmap original, int width, int height) + { + if (original == null) + { + throw new ArgumentNullException("original"); + } + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + original.EnsureNotDisposed(); + dib = FreeImage.Rescale(original.dib, width, height, FREE_IMAGE_FILTER.FILTER_BICUBIC); + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + originalFormat = original.originalFormat; + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image. + /// + /// The original to clone from. + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + public FreeImageBitmap(Image original) + : this(original as Bitmap) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// The Size structure that represent the + /// size of the new . + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + /// + public FreeImageBitmap(Image original, Size newSize) + : this(original as Bitmap, newSize.Width, newSize.Height) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + public FreeImageBitmap(Image original, int width, int height) + : this(original as Bitmap, width, height) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image. + /// + /// The original to clone from. + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// is a null reference. + /// The operation failed. + public FreeImageBitmap(Bitmap original) + { + if (original == null) + { + throw new ArgumentNullException("original"); + } + dib = FreeImage.CreateFromBitmap(original, true); + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + originalFormat = FreeImage.GetFormat(original.RawFormat); + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// The Size structure that represent the + /// size of the new . + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + /// + public FreeImageBitmap(Bitmap original, Size newSize) + : this(original, newSize.Width, newSize.Height) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + public FreeImageBitmap(Bitmap original, int width, int height) + { + if (original == null) + { + throw new ArgumentNullException("original"); + } + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + FIBITMAP temp = FreeImage.CreateFromBitmap(original, true); + if (temp.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + dib = FreeImage.Rescale(temp, width, height, FREE_IMAGE_FILTER.FILTER_BICUBIC); + FreeImage.Unload(temp); + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + originalFormat = FreeImage.GetFormat(original.RawFormat); + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified stream. + /// + /// Stream to read from. + /// Ignored. + /// The operation failed. + /// is a null reference. + /// + /// You must keep the stream open for the lifetime of the . + /// + public FreeImageBitmap(Stream stream, bool useIcm) + : this(stream) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified stream. + /// + /// Stream to read from. + /// The operation failed. + /// is a null reference. + /// + /// You must keep the stream open for the lifetime of the . + /// + public FreeImageBitmap(Stream stream) + : this(stream, FREE_IMAGE_FORMAT.FIF_UNKNOWN, FREE_IMAGE_LOAD_FLAGS.DEFAULT) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified stream in the specified format. + /// + /// Stream to read from. + /// Format of the image. + /// The operation failed. + /// is a null reference. + /// + /// You must keep the stream open for the lifetime of the . + /// + public FreeImageBitmap(Stream stream, FREE_IMAGE_FORMAT format) + : this(stream, format, FREE_IMAGE_LOAD_FLAGS.DEFAULT) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified stream with the specified loading flags. + /// + /// Stream to read from. + /// Flags to enable or disable plugin-features. + /// The operation failed. + /// is a null reference. + /// + /// You must keep the stream open for the lifetime of the . + /// + public FreeImageBitmap(Stream stream, FREE_IMAGE_LOAD_FLAGS flags) + : this(stream, FREE_IMAGE_FORMAT.FIF_UNKNOWN, flags) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified stream in the specified format + /// with the specified loading flags. + /// + /// Stream to read from. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// The operation failed. + /// is a null reference. + /// + /// You must keep the stream open for the lifetime of the . + /// + public FreeImageBitmap(Stream stream, FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags) + { + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + this.stream = stream; + disposeStream = false; + LoadFromStream(stream, format, flags); + } + + /// + /// Initializes a new instance of the class bases on the specified file. + /// + /// The complete name of the file to load. + /// The operation failed. + /// is a null reference. + /// does not exist. + public FreeImageBitmap(string filename) + : this(filename, FREE_IMAGE_LOAD_FLAGS.DEFAULT) + { + } + + /// + /// Initializes a new instance of the class bases on the specified file. + /// + /// The complete name of the file to load. + /// Ignored. + /// The operation failed. + /// is a null reference. + /// does not exist. + public FreeImageBitmap(string filename, bool useIcm) + : this(filename) + { + } + + /// + /// Initializes a new instance of the class bases on the specified file + /// with the specified loading flags. + /// + /// The complete name of the file to load. + /// Flags to enable or disable plugin-features. + /// The operation failed. + /// is a null reference. + /// does not exist. + public FreeImageBitmap(string filename, FREE_IMAGE_LOAD_FLAGS flags) + : this(filename, FREE_IMAGE_FORMAT.FIF_UNKNOWN, flags) + { + } + + /// + /// Initializes a new instance of the class bases on the specified file + /// in the specified format. + /// + /// The complete name of the file to load. + /// Format of the image. + /// The operation failed. + /// is a null reference. + /// does not exist. + public FreeImageBitmap(string filename, FREE_IMAGE_FORMAT format) + : this(filename, format, FREE_IMAGE_LOAD_FLAGS.DEFAULT) + { + } + + /// + /// Initializes a new instance of the class bases on the specified file + /// in the specified format with the specified loading flags. + /// + /// The complete name of the file to load. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// The operation failed. + /// is a null reference. + /// does not exist. + public FreeImageBitmap(string filename, FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags) + { + if (filename == null) + { + throw new ArgumentNullException("filename"); + } + if (!File.Exists(filename)) + { + throw new FileNotFoundException("filename"); + } + + saveInformation.filename = filename; + stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); + disposeStream = true; + LoadFromStream(stream, format, flags); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified size. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// The operation failed. + public FreeImageBitmap(int width, int height) + { + dib = FreeImage.Allocate( + width, + height, + 24, + FreeImage.FI_RGBA_RED_MASK, + FreeImage.FI_RGBA_GREEN_MASK, + FreeImage.FI_RGBA_BLUE_MASK); + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified resource. + /// + /// The class used to extract the resource. + /// The name of the resource. + /// The operation failed. + public FreeImageBitmap(Type type, string resource) + : this(type.Module.Assembly.GetManifestResourceStream(type, resource)) + { + } + + /// + /// Initializes a new instance of the class bases on the specified size + /// and with the resolution of the specified object. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// The Graphics object that specifies the resolution for the new . + /// The operation failed. + /// is a null reference. + public FreeImageBitmap(int width, int height, Graphics g) + : this(width, height) + { + FreeImage.SetResolutionX(dib, (uint)g.DpiX); + FreeImage.SetResolutionY(dib, (uint)g.DpiY); + } + + /// + /// Initializes a new instance of the class bases on the specified size and format. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// The PixelFormat enumeration for the new . + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is invalid. + /// + /// or are less or equal zero. + public FreeImageBitmap(int width, int height, PixelFormat format) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + uint bpp, redMask, greenMask, blueMask; + FREE_IMAGE_TYPE type; + if (!FreeImage.GetFormatParameters(format, out type, out bpp, out redMask, out greenMask, out blueMask)) + { + throw new ArgumentException("format is invalid"); + } + dib = FreeImage.AllocateT(type, width, height, (int)bpp, redMask, greenMask, blueMask); + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified size and type. + /// Only non standard bitmaps are supported. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// The type of the bitmap. + /// The operation failed. + /// + /// is FIT_BITMAP or FIT_UNKNOWN. + /// is invalid. + /// + /// or are less or equal zero. + public FreeImageBitmap(int width, int height, FREE_IMAGE_TYPE type) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + if ((type == FREE_IMAGE_TYPE.FIT_BITMAP) || (type == FREE_IMAGE_TYPE.FIT_UNKNOWN)) + { + throw new ArgumentException("type is invalid."); + } + dib = FreeImage.AllocateT(type, width, height, 0, 0u, 0u, 0u); + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified size, + /// pixel format and pixel data. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// Integer that specifies the byte offset between the beginning + /// of one scan line and the next. This is usually (but not necessarily) + /// the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) + /// multiplied by the width of the bitmap. The value passed to this parameter must + /// be a multiple of four.. + /// The PixelFormat enumeration for the new . + /// Pointer to an array of bytes that contains the pixel data. + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is invalid. + /// + /// or are less or equal zero. + public FreeImageBitmap(int width, int height, int stride, PixelFormat format, IntPtr scan0) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + uint bpp, redMask, greenMask, blueMask; + FREE_IMAGE_TYPE type; + bool topDown = (stride > 0); + stride = (stride > 0) ? stride : (stride * -1); + + if (!FreeImage.GetFormatParameters(format, out type, out bpp, out redMask, out greenMask, out blueMask)) + { + throw new ArgumentException("format is invalid."); + } + + dib = FreeImage.ConvertFromRawBits( + scan0, type, width, height, stride, bpp, redMask, greenMask, blueMask, topDown); + + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified size, + /// pixel format and pixel data. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// Integer that specifies the byte offset between the beginning + /// of one scan line and the next. This is usually (but not necessarily) + /// the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) + /// multiplied by the width of the bitmap. The value passed to this parameter must + /// be a multiple of four.. + /// The PixelFormat enumeration for the new . + /// Array of bytes containing the bitmap data. + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is invalid. + /// + /// or are less or equal zero. + /// is null + public FreeImageBitmap(int width, int height, int stride, PixelFormat format, byte[] bits) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + if (bits == null) + { + throw new ArgumentNullException("bits"); + } + uint bpp, redMask, greenMask, blueMask; + FREE_IMAGE_TYPE type; + bool topDown = (stride > 0); + stride = (stride > 0) ? stride : (stride * -1); + + if (!FreeImage.GetFormatParameters(format, out type, out bpp, out redMask, out greenMask, out blueMask)) + { + throw new ArgumentException("format is invalid."); + } + + dib = FreeImage.ConvertFromRawBits( + bits, type, width, height, stride, bpp, redMask, greenMask, blueMask, topDown); + + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified size, + /// pixel format and pixel data. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// Integer that specifies the byte offset between the beginning + /// of one scan line and the next. This is usually (but not necessarily) + /// the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) + /// multiplied by the width of the bitmap. The value passed to this parameter must + /// be a multiple of four.. + /// The color depth of the new + /// The type for the new . + /// Pointer to an array of bytes that contains the pixel data. + /// The operation failed. + /// is invalid. + /// + /// or are less or equal zero. + public FreeImageBitmap(int width, int height, int stride, int bpp, FREE_IMAGE_TYPE type, IntPtr scan0) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + uint redMask, greenMask, blueMask; + bool topDown = (stride > 0); + stride = (stride > 0) ? stride : (stride * -1); + + if (!FreeImage.GetTypeParameters(type, bpp, out redMask, out greenMask, out blueMask)) + { + throw new ArgumentException("bpp and type are invalid or not supported."); + } + + dib = FreeImage.ConvertFromRawBits( + scan0, type, width, height, stride, (uint)bpp, redMask, greenMask, blueMask, topDown); + + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified size, + /// pixel format and pixel data. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// Integer that specifies the byte offset between the beginning + /// of one scan line and the next. This is usually (but not necessarily) + /// the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) + /// multiplied by the width of the bitmap. The value passed to this parameter must + /// be a multiple of four.. + /// The color depth of the new + /// The type for the new . + /// Array of bytes containing the bitmap data. + /// The operation failed. + /// is invalid. + /// + /// or are less or equal zero. + /// is null + public FreeImageBitmap(int width, int height, int stride, int bpp, FREE_IMAGE_TYPE type, byte[] bits) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + if (bits == null) + { + throw new ArgumentNullException("bits"); + } + uint redMask, greenMask, blueMask; + bool topDown = (stride > 0); + stride = (stride > 0) ? stride : (stride * -1); + + if (!FreeImage.GetTypeParameters(type, bpp, out redMask, out greenMask, out blueMask)) + { + throw new ArgumentException("bpp and type are invalid or not supported."); + } + + dib = FreeImage.ConvertFromRawBits( + bits, type, width, height, stride, (uint)bpp, redMask, greenMask, blueMask, topDown); + + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The operation failed. + /// The operation failed. + public FreeImageBitmap(SerializationInfo info, StreamingContext context) + { + try + { + byte[] data = (byte[])info.GetValue("Bitmap Data", typeof(byte[])); + if ((data != null) && (data.Length > 0)) + { + MemoryStream memory = new MemoryStream(data); + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_TIFF; + dib = FreeImage.LoadFromStream(memory, ref format); + + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + + AddMemoryPressure(); + } + } + catch (Exception ex) + { + throw new SerializationException("Deserialization failed.", ex); + } + } + + /// + /// Frees all managed and unmanaged ressources. + /// + ~FreeImageBitmap() + { + Dispose(false); + } + + #endregion + + #region Operators + + /// + /// Converts a instance to a instance. + /// + /// A instance. + /// A new instance of initialized to . + /// + /// The explicit conversion from into Bitmap + /// allows to create an instance on the fly and use it as if + /// was a Bitmap. This way it can be directly used with a + /// PixtureBox for example without having to call any + /// conversion operations. + /// + public static explicit operator Bitmap(FreeImageBitmap value) + { + return value.ToBitmap(); + } + + /// + /// Converts a instance to a instance. + /// + /// A instance. + /// A new instance of initialized to . + /// + /// The explicit conversion from into + /// allows to create an instance on the fly to perform + /// image processing operations and converting it back. + /// + public static explicit operator FreeImageBitmap(Bitmap value) + { + return new FreeImageBitmap(value); + } + + /// + /// Determines whether two specified objects have the same value. + /// + /// A or a null reference (Nothing in Visual Basic). + /// A or a null reference (Nothing in Visual Basic). + /// + /// true if the value of left is the same as the value of right; otherwise, false. + /// + public static bool operator ==(FreeImageBitmap left, FreeImageBitmap right) + { + if (object.ReferenceEquals(left, right)) + { + return true; + } + else if (object.ReferenceEquals(left, null) || object.ReferenceEquals(right, null)) + { + return false; + } + else + { + left.EnsureNotDisposed(); + right.EnsureNotDisposed(); + return FreeImage.Compare(left.dib, right.dib, FREE_IMAGE_COMPARE_FLAGS.COMPLETE); + } + } + + /// + /// Determines whether two specified objects have different values. + /// + /// A or a null reference (Nothing in Visual Basic). + /// A or a null reference (Nothing in Visual Basic). + /// + /// true if the value of left is different from the value of right; otherwise, false. + /// + public static bool operator !=(FreeImageBitmap left, FreeImageBitmap right) + { + return (!(left == right)); + } + + #endregion + + #region Properties + + /// + /// Type of the bitmap. + /// + public FREE_IMAGE_TYPE ImageType + { + get + { + EnsureNotDisposed(); + return FreeImage.GetImageType(dib); + } + } + + /// + /// Number of palette entries. + /// + public int ColorsUsed + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetColorsUsed(dib); + } + } + + /// + /// The number of unique colors actually used by the bitmap. This might be different from + /// what ColorsUsed returns, which actually returns the palette size for palletised images. + /// Works for FIT_BITMAP type bitmaps only. + /// + public int UniqueColors + { + get + { + EnsureNotDisposed(); + return FreeImage.GetUniqueColors(dib); + } + } + + /// + /// The size of one pixel in the bitmap in bits. + /// + public int ColorDepth + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetBPP(dib); + } + } + + /// + /// Width of the bitmap in pixel units. + /// + public int Width + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetWidth(dib); + } + } + + /// + /// Height of the bitmap in pixel units. + /// + public int Height + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetHeight(dib); + } + } + + /// + /// Returns the width of the bitmap in bytes, rounded to the next 32-bit boundary. + /// + public int Pitch + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetPitch(dib); + } + } + + /// + /// Size of the bitmap in memory. + /// + public int DataSize + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetDIBSize(dib); + } + } + + /// + /// Returns a structure that represents the palette of a FreeImage bitmap. + /// + /// is false. + public Palette Palette + { + get + { + EnsureNotDisposed(); + if (HasPalette) + { + return new Palette(dib); + } + throw new InvalidOperationException("This bitmap does not have a palette."); + } + } + + /// + /// Gets whether the bitmap is RGB 555. + /// + public bool IsRGB555 + { + get + { + EnsureNotDisposed(); + return FreeImage.IsRGB555(dib); + } + } + + /// + /// Gets whether the bitmap is RGB 565. + /// + public bool IsRGB565 + { + get + { + EnsureNotDisposed(); + return FreeImage.IsRGB565(dib); + } + } + + /// + /// Gets the horizontal resolution, in pixels per inch, of this . + /// + public float HorizontalResolution + { + get + { + EnsureNotDisposed(); + return (float)FreeImage.GetResolutionX(dib); + } + private set + { + EnsureNotDisposed(); + FreeImage.SetResolutionX(dib, (uint)value); + } + } + + /// + /// Gets the vertical resolution, in pixels per inch, of this . + /// + public float VerticalResolution + { + get + { + EnsureNotDisposed(); + return (float)FreeImage.GetResolutionY(dib); + } + private set + { + EnsureNotDisposed(); + FreeImage.SetResolutionY(dib, (uint)value); + } + } + + /// + /// Returns the structure of this . + /// + public BITMAPINFOHEADER InfoHeader + { + get + { + EnsureNotDisposed(); + return FreeImage.GetInfoHeaderEx(dib); + } + } + + /// + /// Returns the structure of a this . + /// + public BITMAPINFO Info + { + get + { + EnsureNotDisposed(); + return FreeImage.GetInfoEx(dib); + } + } + + /// + /// Investigates the color type of this + /// by reading the bitmaps pixel bits and analysing them. + /// + public FREE_IMAGE_COLOR_TYPE ColorType + { + get + { + EnsureNotDisposed(); + return FreeImage.GetColorType(dib); + } + } + + /// + /// Bit pattern describing the red color component of a pixel in this . + /// + public uint RedMask + { + get + { + EnsureNotDisposed(); + return FreeImage.GetRedMask(dib); + } + } + + /// + /// Bit pattern describing the green color component of a pixel in this . + /// + public uint GreenMask + { + get + { + EnsureNotDisposed(); + return FreeImage.GetGreenMask(dib); + } + } + + /// + /// Bit pattern describing the blue color component of a pixel in this . + /// + public uint BlueMask + { + get + { + EnsureNotDisposed(); + return FreeImage.GetBlueMask(dib); + } + } + + /// + /// Number of transparent colors in a palletised . + /// + public int TransparencyCount + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetTransparencyCount(dib); + } + } + + /// + /// Get or sets transparency table of this . + /// + public byte[] TransparencyTable + { + get + { + EnsureNotDisposed(); + return FreeImage.GetTransparencyTableEx(dib); + } + set + { + EnsureNotDisposed(); + FreeImage.SetTransparencyTable(dib, value); + } + } + + /// + /// Gets or sets whether this is transparent. + /// + public bool IsTransparent + { + get + { + EnsureNotDisposed(); + return FreeImage.IsTransparent(dib); + } + set + { + EnsureNotDisposed(); + FreeImage.SetTransparent(dib, value); + } + } + + /// + /// Gets whether this has a file background color. + /// + public bool HasBackgroundColor + { + get + { + EnsureNotDisposed(); + return FreeImage.HasBackgroundColor(dib); + } + } + + /// + /// Gets or sets the background color of this . + /// In case the value is null, the background color is removed. + /// + /// Get: There is no background color available. + /// Set: Setting background color failed. + public Color? BackgroundColor + { + get + { + EnsureNotDisposed(); + if (!FreeImage.HasBackgroundColor(dib)) + { + throw new InvalidOperationException("No background color available."); + } + RGBQUAD rgbq; + FreeImage.GetBackgroundColor(dib, out rgbq); + return rgbq.Color; + } + set + { + EnsureNotDisposed(); + if (!FreeImage.SetBackgroundColor(dib, (value.HasValue ? new RGBQUAD[] { value.Value } : null))) + { + throw new Exception("Setting background color failed."); + } + } + } + + /// + /// Pointer to the data-bits of this . + /// + public IntPtr Bits + { + get + { + EnsureNotDisposed(); + return FreeImage.GetBits(dib); + } + } + + /// + /// Width, in bytes, of this . + /// + public int Line + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetLine(dib); + } + } + + /// + /// Pointer to the scanline of the top most pixel row of this . + /// + public IntPtr Scan0 + { + get + { + EnsureNotDisposed(); + return FreeImage.GetScanLine(dib, (int)(FreeImage.GetHeight(dib) - 1)); + } + } + + /// + /// Width, in bytes, of this . + /// In case this is top down Stride will be positive, else negative. + /// + public int Stride + { + get + { + return -Line; + } + } + + /// + /// Gets attribute flags for the pixel data of this . + /// + public unsafe int Flags + { + get + { + EnsureNotDisposed(); + int result = 0; + byte alpha; + int cd = ColorDepth; + + if ((cd == 32) || (FreeImage.GetTransparencyCount(dib) != 0)) + { + result += (int)ImageFlags.HasAlpha; + } + + if (cd == 32) + { + uint width = FreeImage.GetWidth(dib); + uint height = FreeImage.GetHeight(dib); + for (int y = 0; y < height; y++) + { + RGBQUAD* scanline = (RGBQUAD*)FreeImage.GetScanLine(dib, y); + for (int x = 0; x < width; x++) + { + alpha = scanline[x].Color.A; + if (alpha != byte.MinValue && alpha != byte.MaxValue) + { + result += (int)ImageFlags.HasTranslucent; + y = (int)height; + break; + } + } + } + } + else if (FreeImage.GetTransparencyCount(dib) != 0) + { + byte[] transTable = FreeImage.GetTransparencyTableEx(dib); + for (int i = 0; i < transTable.Length; i++) + { + if (transTable[i] != byte.MinValue && transTable[i] != byte.MaxValue) + { + result += (int)ImageFlags.HasTranslucent; + break; + } + } + } + + if (FreeImage.GetICCProfileEx(dib).IsCMYK) + { + result += (int)ImageFlags.ColorSpaceCmyk; + } + else + { + result += (int)ImageFlags.ColorSpaceRgb; + } + + if (FreeImage.GetColorType(dib) == FREE_IMAGE_COLOR_TYPE.FIC_MINISBLACK || + FreeImage.GetColorType(dib) == FREE_IMAGE_COLOR_TYPE.FIC_MINISWHITE) + { + result += (int)ImageFlags.ColorSpaceGray; + } + + if (originalFormat == FREE_IMAGE_FORMAT.FIF_BMP || + originalFormat == FREE_IMAGE_FORMAT.FIF_FAXG3 || + originalFormat == FREE_IMAGE_FORMAT.FIF_ICO || + originalFormat == FREE_IMAGE_FORMAT.FIF_JPEG || + originalFormat == FREE_IMAGE_FORMAT.FIF_PCX || + originalFormat == FREE_IMAGE_FORMAT.FIF_PNG || + originalFormat == FREE_IMAGE_FORMAT.FIF_PSD || + originalFormat == FREE_IMAGE_FORMAT.FIF_TIFF) + { + result += (int)ImageFlags.HasRealDpi; + } + + return result; + } + } + + /// + /// Gets the width and height of this . + /// + public SizeF PhysicalDimension + { + get + { + EnsureNotDisposed(); + return new SizeF((float)FreeImage.GetWidth(dib), (float)FreeImage.GetHeight(dib)); + } + } + + /// + /// Gets the pixel format for this . + /// + public PixelFormat PixelFormat + { + get + { + EnsureNotDisposed(); + return FreeImage.GetPixelFormat(dib); + } + } + + /// + /// Gets IDs of the property items stored in this . + /// + public int[] PropertyIdList + { + get + { + EnsureNotDisposed(); + List list = new List(); + ImageMetadata metaData = new ImageMetadata(dib, true); + + foreach (MetadataModel metadataModel in metaData) + { + foreach (MetadataTag metadataTag in metadataModel) + { + list.Add(metadataTag.ID); + } + } + + return list.ToArray(); + } + } + + /// + /// Gets all the property items (pieces of metadata) stored in this . + /// + public PropertyItem[] PropertyItems + { + get + { + EnsureNotDisposed(); + List list = new List(); + ImageMetadata metaData = new ImageMetadata(dib, true); + + foreach (MetadataModel metadataModel in metaData) + { + foreach (MetadataTag metadataTag in metadataModel) + { + list.Add(metadataTag.GetPropertyItem()); + } + } + + return list.ToArray(); + } + } + + /// + /// Gets the format of this . + /// + public ImageFormat RawFormat + { + get + { + EnsureNotDisposed(); + Attribute guidAttribute = + Attribute.GetCustomAttribute( + typeof(FreeImageBitmap), typeof(System.Runtime.InteropServices.GuidAttribute) + ); + return (guidAttribute == null) ? + null : + new ImageFormat(new Guid(((GuidAttribute)guidAttribute).Value)); + } + } + + /// + /// Gets the width and height, in pixels, of this . + /// + public Size Size + { + get + { + EnsureNotDisposed(); + return new Size(Width, Height); + } + } + + /// + /// Gets or sets an object that provides additional data about the . + /// + public Object Tag + { + get + { + EnsureNotDisposed(); + return tag; + } + set + { + EnsureNotDisposed(); + tag = value; + } + } + + /// + /// Gets whether this has been disposed. + /// + public bool IsDisposed + { + get + { + return disposed; + } + } + + /// + /// Gets a new instance of a metadata representing class. + /// + public ImageMetadata Metadata + { + get + { + EnsureNotDisposed(); + return new ImageMetadata(dib, true); + } + } + + /// + /// Gets or sets the comment of this . + /// Supported formats are JPEG, PNG and GIF. + /// + public string Comment + { + get + { + EnsureNotDisposed(); + return FreeImage.GetImageComment(dib); + } + set + { + EnsureNotDisposed(); + FreeImage.SetImageComment(dib, value); + } + } + + /// + /// Returns whether this has a palette. + /// + public bool HasPalette + { + get + { + EnsureNotDisposed(); + return (FreeImage.GetPalette(dib) != IntPtr.Zero); + } + } + + /// + /// Gets or sets the entry used as transparent color in this . + /// Only works for 1-, 4- and 8-bpp. + /// + public int TransparentIndex + { + get + { + EnsureNotDisposed(); + return FreeImage.GetTransparentIndex(dib); + } + set + { + EnsureNotDisposed(); + FreeImage.SetTransparentIndex(dib, value); + } + } + + /// + /// Gets the number of frames in this . + /// + public int FrameCount + { + get + { + EnsureNotDisposed(); + return frameCount; + } + } + + /// + /// Gets the ICCProfile structure of this . + /// + public FIICCPROFILE ICCProfile + { + get + { + EnsureNotDisposed(); + return FreeImage.GetICCProfileEx(dib); + } + } + + /// + /// Gets the format of the original image in case + /// this was loaded from a file or stream. + /// + public FREE_IMAGE_FORMAT ImageFormat + { + get + { + EnsureNotDisposed(); + return originalFormat; + } + } + + /// + /// Gets the encapsulated FIBITMAP. + /// + internal FIBITMAP Dib + { + get { EnsureNotDisposed(); return dib; } + } + + #endregion + + #region Methods + + /// + /// Gets the bounds of this in the specified unit. + /// + /// One of the values indicating + /// the unit of measure for the bounding rectangle. + /// The that represents the bounds of this + /// , in the specified unit. + public RectangleF GetBounds(ref GraphicsUnit pageUnit) + { + EnsureNotDisposed(); + pageUnit = GraphicsUnit.Pixel; + return new RectangleF( + 0f, + 0f, + (float)FreeImage.GetWidth(dib), + (float)FreeImage.GetHeight(dib)); + } + + /// + /// Gets the specified property item from this . + /// + /// The ID of the property item to get. + /// The this method gets. + public PropertyItem GetPropertyItem(int propid) + { + EnsureNotDisposed(); + ImageMetadata metadata = new ImageMetadata(dib, true); + foreach (MetadataModel metadataModel in metadata) + { + foreach (MetadataTag tag in metadataModel) + { + if (tag.ID == propid) + { + return tag.GetPropertyItem(); + } + } + } + return null; + } + + /// + /// Returns a thumbnail for this . + /// + /// The width, in pixels, of the requested thumbnail image. + /// The height, in pixels, of the requested thumbnail image. + /// Ignored. + /// Ignored. + /// A that represents the thumbnail. + public FreeImageBitmap GetThumbnailImage(int thumbWidth, int thumbHeight, + Image.GetThumbnailImageAbort callback, IntPtr callBackData) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.Rescale( + dib, thumbWidth, thumbHeight, FREE_IMAGE_FILTER.FILTER_BICUBIC); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Returns a thumbnail for this , keeping aspect ratio. + /// defines the maximum width or height + /// of the thumbnail. + /// + /// Thumbnail square size. + /// When true HDR images are transperantly + /// converted to standard images. + /// The thumbnail in a new instance. + public FreeImageBitmap GetThumbnailImage(int maxPixelSize, bool convert) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.MakeThumbnail(dib, maxPixelSize, convert); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Converts this instance to a instance. + /// + /// A new instance of initialized this instance. + public Bitmap ToBitmap() + { + EnsureNotDisposed(); + return FreeImage.GetBitmap(dib, true); + } + + /// + /// Returns an instance of , representing the scanline + /// specified by of this . + /// Since FreeImage bitmaps are always bottum up aligned, keep in mind that scanline 0 is the + /// bottom-most line of the image. + /// + /// Number of the scanline to retrieve. + /// An instance of representing the + /// th scanline. + /// + /// List of return-types of T: + /// + /// Color Depth / TypeResult Type + /// 1 () + /// 4 () + /// 8 () + /// 16 () + /// 16 - 555 () + /// 16 - 565 () + /// 24 () + /// 32 () + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// FreeImageBitmap bitmap = new FreeImageBitmap(@"C:\Pictures\picture.bmp"); + /// if (bitmap.ColorDepth == 32) + /// { + /// Scanline<RGBQUAD> scanline = bitmap.GetScanline<RGBQUAD>(0); + /// foreach (RGBQUAD pixel in scanline) + /// { + /// Console.WriteLine(pixel); + /// } + /// } + /// + /// + /// + /// The bitmap's type or color depth are not supported. + /// + /// + /// is no valid value. + /// + public Scanline GetScanline(int scanline) where T : struct + { + EnsureNotDisposed(); + return new Scanline(dib, scanline); + } + + /// + /// Returns an instance of , representing the scanline + /// specified by of this . + /// Since FreeImage bitmaps are always bottum up aligned, keep in mind that scanline 0 is the + /// bottom-most line of the image. + /// + /// Number of the scanline to retrieve. + /// An instance of representing the + /// th scanline. + /// + /// List of return-types of T: + /// + /// Color Depth / TypeResult Type + /// 1 () + /// 4 () + /// 8 () + /// 16 () + /// 16 - 555 () + /// 16 - 565 () + /// 24 () + /// 32 () + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// FreeImageBitmap bitmap = new FreeImageBitmap(@"C:\Pictures\picture.bmp"); + /// if (bitmap.ColorDepth == 32) + /// { + /// Scanline<RGBQUAD> scanline = (Scanline<RGBQUAD>)bitmap.GetScanline(0); + /// foreach (RGBQUAD pixel in scanline) + /// { + /// Console.WriteLine(pixel); + /// } + /// } + /// + /// + /// + /// The type of the bitmap or color depth are not supported. + /// + /// + /// is no valid value. + /// + public object GetScanline(int scanline) + { + EnsureNotDisposed(); + object result = null; + int width = (int)FreeImage.GetWidth(dib); + + switch (FreeImage.GetImageType(dib)) + { + case FREE_IMAGE_TYPE.FIT_BITMAP: + + switch (FreeImage.GetBPP(dib)) + { + case 1u: result = new Scanline(dib, scanline, width); break; + case 4u: result = new Scanline(dib, scanline, width); break; + case 8u: result = new Scanline(dib, scanline, width); break; + case 16u: + if ((RedMask == FreeImage.FI16_555_RED_MASK) && + (GreenMask == FreeImage.FI16_555_GREEN_MASK) && + (BlueMask == FreeImage.FI16_555_BLUE_MASK)) + { + result = new Scanline(dib, scanline, width); + } + else if ((RedMask == FreeImage.FI16_565_RED_MASK) && + (GreenMask == FreeImage.FI16_565_GREEN_MASK) && + (BlueMask == FreeImage.FI16_565_BLUE_MASK)) + { + result = new Scanline(dib, scanline, width); + } + else + { + result = new Scanline(dib, scanline, width); + } + break; + case 24u: result = new Scanline(dib, scanline, width); break; + case 32u: result = new Scanline(dib, scanline, width); break; + default: throw new ArgumentException("Color depth is not supported."); + } + break; + + case FREE_IMAGE_TYPE.FIT_COMPLEX: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_DOUBLE: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_FLOAT: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_INT16: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_INT32: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_RGB16: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_RGBA16: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_RGBAF: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_RGBF: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_UINT16: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_UINT32: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_UNKNOWN: + default: throw new ArgumentException("Type is not supported."); + } + + return result; + } + + /// + /// Returns a pointer to the specified scanline. + /// Due to FreeImage bitmaps are bottum up, + /// scanline 0 is the most bottom line of the image. + /// + /// Number of the scanline. + /// Pointer to the scanline. + public IntPtr GetScanlinePointer(int scanline) + { + EnsureNotDisposed(); + return FreeImage.GetScanLine(dib, scanline); + } + + /// + /// Returns a list of structures, representing the scanlines of this . + /// Due to FreeImage bitmaps are bottum up, scanline 0 is the + /// bottom-most line of the image. + /// Each color depth has a different representing structure due to different memory layouts. + /// + /// + /// List of return-types of T: + /// + /// Color Depth / TypeResult Type of IEnmuerable<Scanline<T>> + /// 1 () + /// 4 () + /// 8 () + /// 16 () + /// 16 - 555 () + /// 16 - 565 () + /// 24 () + /// 32 () + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public IList GetScanlines() + { + EnsureNotDisposed(); + + int height = (int)FreeImage.GetHeight(dib); + IList list; + + switch (FreeImage.GetImageType(dib)) + { + case FREE_IMAGE_TYPE.FIT_BITMAP: + + switch (FreeImage.GetBPP(dib)) + { + case 1u: list = new List>(height); break; + case 4u: list = new List>(height); break; + case 8u: list = new List>(height); break; + case 16u: + if (FreeImage.IsRGB555(dib)) + { + list = new List>(height); + } + else if (FreeImage.IsRGB565(dib)) + { + list = new List>(height); + } + else + { + list = new List>(height); + } + break; + case 24u: list = new List>(height); break; + case 32u: list = new List>(height); break; + default: throw new ArgumentException("Color depth is not supported."); + } + break; + + case FREE_IMAGE_TYPE.FIT_COMPLEX: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_DOUBLE: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_FLOAT: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_INT16: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_INT32: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_RGB16: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_RGBA16: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_RGBAF: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_RGBF: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_UINT16: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_UINT32: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_UNKNOWN: + default: throw new ArgumentException("Type is not supported."); + } + + for (int i = 0; i < height; i++) + { + list.Add(GetScanline(i)); + } + + return list; + } + + /// + /// Removes the specified property item from this . + /// + /// The ID of the property item to remove. + public void RemovePropertyItem(int propid) + { + EnsureNotDisposed(); + ImageMetadata mdata = new ImageMetadata(dib, true); + foreach (MetadataModel model in mdata) + { + foreach (MetadataTag tag in model) + { + if (tag.ID == propid) + { + model.RemoveTag(tag.Key); + return; + } + } + } + } + + /// + /// This method rotates, flips, or rotates and flips this . + /// + /// A RotateFlipType member + /// that specifies the type of rotation and flip to apply to this . + public void RotateFlip(RotateFlipType rotateFlipType) + { + EnsureNotDisposed(); + + FIBITMAP newDib = new FIBITMAP(); + uint bpp = FreeImage.GetBPP(dib); + + switch (rotateFlipType) + { + case RotateFlipType.RotateNoneFlipX: + + FreeImage.FlipHorizontal(dib); + break; + + case RotateFlipType.RotateNoneFlipY: + + FreeImage.FlipVertical(dib); + break; + + case RotateFlipType.RotateNoneFlipXY: + + FreeImage.FlipHorizontal(dib); + FreeImage.FlipVertical(dib); + break; + + case RotateFlipType.Rotate90FlipNone: + + newDib = (bpp == 4u) ? FreeImage.Rotate4bit(dib, 90d) : FreeImage.Rotate(dib, 90d); + break; + + case RotateFlipType.Rotate90FlipX: + + newDib = (bpp == 4u) ? FreeImage.Rotate4bit(dib, 90d) : FreeImage.Rotate(dib, 90d); + FreeImage.FlipHorizontal(newDib); + break; + + case RotateFlipType.Rotate90FlipY: + + newDib = (bpp == 4u) ? FreeImage.Rotate4bit(dib, 90d) : FreeImage.Rotate(dib, 90d); + FreeImage.FlipVertical(newDib); + break; + + case RotateFlipType.Rotate90FlipXY: + + newDib = (bpp == 4u) ? FreeImage.Rotate4bit(dib, 90d) : FreeImage.Rotate(dib, 90d); + FreeImage.FlipHorizontal(newDib); + FreeImage.FlipVertical(newDib); + break; + + case RotateFlipType.Rotate180FlipXY: + newDib = FreeImage.Clone(dib); + break; + } + ReplaceDib(newDib); + } + + /// + /// Copies the metadata from another . + /// + /// The bitmap to read the metadata from. + /// + /// is a null reference. + /// + public void CloneMetadataFrom(FreeImageBitmap bitmap) + { + if (bitmap == null) + { + throw new ArgumentNullException("bitmap"); + } + EnsureNotDisposed(); + bitmap.EnsureNotDisposed(); + FreeImage.CloneMetadata(dib, bitmap.dib); + } + + /// + /// Copies the metadata from another using + /// the provided options. + /// + /// The bitmap to read the metadata from. + /// Specifies the way the metadata is copied. + /// + /// is a null reference. + /// + public void CloneMetadataFrom(FreeImageBitmap bitmap, FREE_IMAGE_METADATA_COPY flags) + { + if (bitmap == null) + { + throw new ArgumentNullException("bitmap"); + } + EnsureNotDisposed(); + bitmap.EnsureNotDisposed(); + FreeImage.CloneMetadataEx(bitmap.dib, dib, flags); + } + + /// + /// Saves this to the specified file. + /// + /// A string that contains the name of the file to which + /// to save this . + /// is null or empty. + /// Saving the image failed. + public void Save(string filename) + { + Save(filename, FREE_IMAGE_FORMAT.FIF_UNKNOWN, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Saves this to the specified file in the specified format. + /// + /// A string that contains the name of the file to which + /// to save this . + /// An that specifies the format of the saved image. + /// is null or empty. + /// Saving the image failed. + public void Save(string filename, FREE_IMAGE_FORMAT format) + { + Save(filename, format, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Saves this to the specified file in the specified format + /// using the specified saving flags. + /// + /// A string that contains the name of the file to which + /// to save this . + /// An that specifies the format of the saved image. + /// Flags to enable or disable plugin-features. + /// is null or empty. + /// Saving the image failed. + public void Save(string filename, FREE_IMAGE_FORMAT format, FREE_IMAGE_SAVE_FLAGS flags) + { + EnsureNotDisposed(); + if (string.IsNullOrEmpty(filename)) + { + throw new ArgumentException("filename"); + } + if (!FreeImage.SaveEx(dib, filename, format, flags)) + { + throw new Exception("Unable to save bitmap"); + } + + saveInformation.filename = filename; + saveInformation.format = format; + saveInformation.saveFlags = flags; + } + + /// + /// Saves this to the specified stream in the specified format. + /// + /// The stream where this will be saved. + /// An that specifies the format of the saved image. + /// is a null reference. + /// Saving the image failed. + public void Save(Stream stream, FREE_IMAGE_FORMAT format) + { + Save(stream, format, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Saves this to the specified stream in the specified format + /// using the specified saving flags. + /// + /// The stream where this will be saved. + /// An that specifies the format of the saved image. + /// Flags to enable or disable plugin-features. + /// is a null reference. + /// Saving the image failed. + public void Save(Stream stream, FREE_IMAGE_FORMAT format, FREE_IMAGE_SAVE_FLAGS flags) + { + EnsureNotDisposed(); + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + if (!FreeImage.SaveToStream(dib, stream, format, flags)) + { + throw new Exception("Unable to save bitmap"); + } + + saveInformation.filename = null; + } + + /// + /// Adds a frame to the file specified in a previous call to the + /// method. + /// + /// + /// This instance has not been saved to a file using Save(...) before. + public void SaveAdd() + { + SaveAdd(this); + } + + /// + /// Adds a frame to the file specified in a previous call to the method. + /// + /// The position at which the frame should be inserted. + /// + /// This instance has not yet been saved to a file using the Save(...) method. + /// is out of range. + public void SaveAdd(int insertPosition) + { + SaveAdd(this, insertPosition); + } + + /// + /// Adds a frame to the file specified in a previous call to the method. + /// + /// A that contains the frame to add. + /// + /// This instance has not yet been saved to a file using the Save(...) method. + public void SaveAdd(FreeImageBitmap bitmap) + { + if (saveInformation.filename == null) + { + throw new InvalidOperationException("This operation requires a previous call of Save()."); + } + + SaveAdd( + saveInformation.filename, + bitmap, + saveInformation.format, + saveInformation.loadFlags, + saveInformation.saveFlags); + } + + /// + /// Adds a frame to the file specified in a previous call to the method. + /// + /// A that contains the frame to add. + /// The position at which the frame should be inserted. + /// + /// This instance has not yet been saved to a file using the Save(...) method. + /// is out of range. + public void SaveAdd(FreeImageBitmap bitmap, int insertPosition) + { + if (saveInformation.filename == null) + { + throw new InvalidOperationException("This operation requires a previous call of Save()."); + } + + SaveAdd( + saveInformation.filename, + bitmap, + insertPosition, + saveInformation.format, + saveInformation.loadFlags, + saveInformation.saveFlags); + } + + /// + /// Adds a frame to the file specified. + /// + /// File to add this frame to. + /// is a null reference. + /// does not exist. + /// Saving the image has failed. + public void SaveAdd(string filename) + { + SaveAdd( + filename, + this, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Adds a frame to the file specified. + /// + /// File to add this frame to. + /// The position at which the frame should be inserted. + /// is a null reference. + /// does not exist. + /// Saving the image has failed. + /// is out of range. + public void SaveAdd(string filename, int insertPosition) + { + SaveAdd( + filename, + this, + insertPosition, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Adds a frame to the file specified using the specified parameters. + /// + /// File to add this frame to. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// Flags to enable or disable plugin-features. + /// is a null reference. + /// does not exist. + /// Saving the image has failed. + public void SaveAdd( + string filename, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS loadFlags, + FREE_IMAGE_SAVE_FLAGS saveFlags) + { + SaveAdd( + filename, + this, + format, + loadFlags, + saveFlags); + } + + /// + /// Adds a frame to the file specified using the specified parameters. + /// + /// File to add this frame to. + /// The position at which the frame should be inserted. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// Flags to enable or disable plugin-features. + /// is a null reference. + /// does not exist. + /// Saving the image has failed. + /// is out of range. + public void SaveAdd( + string filename, + int insertPosition, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS loadFlags, + FREE_IMAGE_SAVE_FLAGS saveFlags) + { + SaveAdd( + filename, + this, + insertPosition, + format, + loadFlags, + saveFlags); + } + + /// + /// Selects the frame specified by the index. + /// + /// The index of the active frame. + /// + /// is out of range. + /// The operation failed. + /// The source of the bitmap is not available. + /// + public void SelectActiveFrame(int frameIndex) + { + EnsureNotDisposed(); + if ((frameIndex < 0) || (frameIndex >= frameCount)) + { + throw new ArgumentOutOfRangeException("frameIndex"); + } + + if (frameIndex != this.frameIndex) + { + if (stream == null) + { + throw new InvalidOperationException("No source available."); + } + + FREE_IMAGE_FORMAT format = originalFormat; + FIMULTIBITMAP mdib = FreeImage.OpenMultiBitmapFromStream(stream, ref format, saveInformation.loadFlags); + if (mdib.IsNull) + throw new Exception(ErrorLoadingBitmap); + + try + { + if (frameIndex >= FreeImage.GetPageCount(mdib)) + { + throw new ArgumentOutOfRangeException("frameIndex"); + } + + FIBITMAP newDib = FreeImage.LockPage(mdib, frameIndex); + if (newDib.IsNull) + { + throw new Exception(ErrorLoadingFrame); + } + + try + { + FIBITMAP clone = FreeImage.Clone(newDib); + if (clone.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + ReplaceDib(clone); + } + finally + { + if (!newDib.IsNull) + { + FreeImage.UnlockPage(mdib, newDib, false); + } + } + } + finally + { + if (!FreeImage.CloseMultiBitmapEx(ref mdib)) + { + throw new Exception(ErrorUnloadBitmap); + } + } + + this.frameIndex = frameIndex; + } + } + + /// + /// Creates a GDI bitmap object from this . + /// + /// A handle to the GDI bitmap object that this method creates. + public IntPtr GetHbitmap() + { + EnsureNotDisposed(); + return FreeImage.GetHbitmap(dib, IntPtr.Zero, false); + } + + /// + /// Creates a GDI bitmap object from this . + /// + /// A structure that specifies the background color. + /// This parameter is ignored if the bitmap is totally opaque. + /// A handle to the GDI bitmap object that this method creates. + public IntPtr GetHbitmap(Color background) + { + EnsureNotDisposed(); + using (FreeImageBitmap temp = new FreeImageBitmap(this)) + { + temp.BackgroundColor = background; + return temp.GetHbitmap(); + } + } + + /// + /// Returns the handle to an icon. + /// + /// A Windows handle to an icon with the same image as this . + public IntPtr GetHicon() + { + EnsureNotDisposed(); + using (Bitmap bitmap = FreeImage.GetBitmap(dib, true)) + { + return bitmap.GetHicon(); + } + } + + /// + /// Creates a GDI bitmap object from this with the same + /// color depth as the primary device. + /// + /// A handle to the GDI bitmap object that this method creates. + public IntPtr GetHbitmapForDevice() + { + EnsureNotDisposed(); + return FreeImage.GetBitmapForDevice(dib, IntPtr.Zero, false); + } + + /// + /// Gets the of the specified pixel in this . + /// + /// The x-coordinate of the pixel to retrieve. + /// The y-coordinate of the pixel to retrieve. + /// A structure that represents the color of the specified pixel. + /// The operation failed. + /// The type of this bitmap is not supported. + public unsafe Color GetPixel(int x, int y) + { + EnsureNotDisposed(); + if (FreeImage.GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) + { + if (ColorDepth == 16 || ColorDepth == 24 || ColorDepth == 32) + { + RGBQUAD rgbq; + if (!FreeImage.GetPixelColor(dib, (uint)x, (uint)y, out rgbq)) + { + throw new Exception("FreeImage.GetPixelColor() failed"); + } + return rgbq.Color; + } + else if (ColorDepth == 1 || ColorDepth == 4 || ColorDepth == 8) + { + byte index; + if (!FreeImage.GetPixelIndex(dib, (uint)x, (uint)y, out index)) + { + throw new Exception("FreeImage.GetPixelIndex() failed"); + } + RGBQUAD* palette = (RGBQUAD*)FreeImage.GetPalette(dib); + return palette[index].Color; + } + } + throw new NotSupportedException("The type of the image is not supported"); + } + + /// + /// Makes the default transparent color transparent for this . + /// + public void MakeTransparent() + { + EnsureNotDisposed(); + MakeTransparent(Color.Transparent); + } + + /// + /// Makes the specified color transparent for this . + /// + /// The structure that represents + /// the color to make transparent. + /// + /// This method is not implemented. + public void MakeTransparent(Color transparentColor) + { + EnsureNotDisposed(); + throw new System.NotImplementedException(); + } + + /// + /// Sets the of the specified pixel in this . + /// + /// The x-coordinate of the pixel to set. + /// The y-coordinate of the pixel to set. + /// A structure that represents the color + /// to assign to the specified pixel. + /// The operation failed. + /// The type of this bitmap is not supported. + public unsafe void SetPixel(int x, int y, Color color) + { + EnsureNotDisposed(); + if (FreeImage.GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) + { + if (ColorDepth == 16 || ColorDepth == 24 || ColorDepth == 32) + { + RGBQUAD rgbq = color; + if (!FreeImage.SetPixelColor(dib, (uint)x, (uint)y, ref rgbq)) + { + throw new Exception("FreeImage.SetPixelColor() failed"); + } + return; + } + else if (ColorDepth == 1 || ColorDepth == 4 || ColorDepth == 8) + { + uint colorsUsed = FreeImage.GetColorsUsed(dib); + RGBQUAD* palette = (RGBQUAD*)FreeImage.GetPalette(dib); + for (int i = 0; i < colorsUsed; i++) + { + if (palette[i].Color == color) + { + byte index = (byte)i; + if (!FreeImage.SetPixelIndex(dib, (uint)x, (uint)y, ref index)) + { + throw new Exception("FreeImage.SetPixelIndex() failed"); + } + return; + } + } + throw new ArgumentOutOfRangeException("color"); + } + } + throw new NotSupportedException("The type of the image is not supported"); + } + + /// + /// Sets the resolution for this . + /// + /// The horizontal resolution, in dots per inch, of this . + /// The vertical resolution, in dots per inch, of this . + public void SetResolution(float xDpi, float yDpi) + { + EnsureNotDisposed(); + FreeImage.SetResolutionX(dib, (uint)xDpi); + FreeImage.SetResolutionY(dib, (uint)yDpi); + } + + /// + /// This function is not yet implemented. + /// + /// + /// This method is not implemented. + public BitmapData LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format) + { + throw new NotImplementedException(); + } + + /// + /// This function is not yet implemented. + /// + /// + /// This method is not implemented. + public BitmapData LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format, BitmapData bitmapData) + { + throw new NotImplementedException(); + } + + /// + /// This function is not yet implemented. + /// + /// + /// This method is not implemented. + public void UnlockBits(BitmapData bitmapdata) + { + throw new NotImplementedException(); + } + + /// + /// Converts this into a different color depth. + /// The parameter specifies color depth, greyscale conversion + /// and palette reorder. + /// Adding the flag + /// will first perform a convesion to greyscale. This can be done with any target + /// color depth. + /// Adding the flag + /// will allow the algorithm to reorder the palette. This operation will not be performed to + /// non-greyscale images to prevent data loss by mistake. + /// + /// A bitfield containing information about the conversion + /// to perform. + /// Returns true on success, false on failure. + public bool ConvertColorDepth(FREE_IMAGE_COLOR_DEPTH bpp) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.ConvertColorDepth(dib, bpp, false)); + } + + /// + /// Converts this to + /// initializing a new instance. + /// In case source and destination type are the same, the operation fails. + /// An error message can be catched using the 'Message' event. + /// + /// Destination type. + /// True to scale linear, else false. + /// Returns true on success, false on failure. + public bool ConvertType(FREE_IMAGE_TYPE type, bool scaleLinear) + { + EnsureNotDisposed(); + return (ImageType == type) ? false : ReplaceDib(FreeImage.ConvertToType(dib, type, scaleLinear)); + } + + /// + /// Converts this to . + /// In case source and destination type are the same, the operation fails. + /// An error message can be catched using the 'Message' event. + /// + /// Destination type. + /// True to scale linear, else false. + /// The converted instance. + public FreeImageBitmap GetTypeConvertedInstance(FREE_IMAGE_TYPE type, bool scaleLinear) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + if (ImageType != type) + { + FIBITMAP newDib = FreeImage.ConvertToType(dib, type, scaleLinear); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + } + return result; + } + + /// + /// Converts this into a different color depth initializing + /// a new instance. + /// The parameter specifies color depth, greyscale conversion + /// and palette reorder. + /// Adding the flag will + /// first perform a convesion to greyscale. This can be done with any target color depth. + /// Adding the flag will + /// allow the algorithm to reorder the palette. This operation will not be performed to + /// non-greyscale images to prevent data loss by mistake. + /// + /// A bitfield containing information about the conversion + /// to perform. + /// The converted instance. + public FreeImageBitmap GetColorConvertedInstance(FREE_IMAGE_COLOR_DEPTH bpp) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.ConvertColorDepth(dib, bpp, false); + if (newDib == dib) + { + newDib = FreeImage.Clone(dib); + } + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Rescales this to the specified size using the + /// specified filter. + /// + /// The Size structure that represent the + /// size of the new . + /// Filter to use for resizing. + /// Returns true on success, false on failure. + public bool Rescale(Size newSize, FREE_IMAGE_FILTER filter) + { + return Rescale(newSize.Width, newSize.Height, filter); + } + + /// + /// Rescales this to the specified size using the + /// specified filter. + /// + /// Width of the new . + /// Height of the new . + /// Filter to use for resizing. + /// Returns true on success, false on failure. + public bool Rescale(int width, int height, FREE_IMAGE_FILTER filter) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.Rescale(dib, width, height, filter)); + } + + /// + /// Rescales this to the specified size using the + /// specified filter initializing a new instance. + /// + /// The Size structure that represent the + /// size of the new . + /// Filter to use for resizing. + /// The rescaled instance. + public FreeImageBitmap GetScaledInstance(Size newSize, FREE_IMAGE_FILTER filter) + { + return GetScaledInstance(newSize.Width, newSize.Height, filter); + } + + /// + /// Rescales this to the specified size using the + /// specified filter initializing a new instance. + /// + /// Width of the new . + /// Height of the new . + /// Filter to use for resizing. + /// The rescaled instance. + public FreeImageBitmap GetScaledInstance(int width, int height, FREE_IMAGE_FILTER filter) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.Rescale(dib, width, height, filter); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Enlarges or shrinks this selectively per side and fills + /// newly added areas with the specified background color. + /// See for further details. + /// + /// The type of the specified color. + /// The number of pixels, the image should be enlarged on its left side. + /// Negative values shrink the image on its left side. + /// The number of pixels, the image should be enlarged on its top side. + /// Negative values shrink the image on its top side. + /// The number of pixels, the image should be enlarged on its right side. + /// Negative values shrink the image on its right side. + /// The number of pixels, the image should be enlarged on its bottom side. + /// Negative values shrink the image on its bottom side. + /// The color, the enlarged sides of the image should be filled with. + /// true on success, false on failure. + public bool EnlargeCanvas(int left, int top, int right, int bottom, T? color) where T : struct + { + return EnlargeCanvas(left, top, right, bottom, color, FREE_IMAGE_COLOR_OPTIONS.FICO_DEFAULT); + } + + /// + /// Enlarges or shrinks this selectively per side and fills + /// newly added areas with the specified background color. + /// See for further details. + /// + /// The type of the specified color. + /// The number of pixels, the image should be enlarged on its left side. + /// Negative values shrink the image on its left side. + /// The number of pixels, the image should be enlarged on its top side. + /// Negative values shrink the image on its top side. + /// The number of pixels, the image should be enlarged on its right side. + /// Negative values shrink the image on its right side. + /// The number of pixels, the image should be enlarged on its bottom side. + /// Negative values shrink the image on its bottom side. + /// The color, the enlarged sides of the image should be filled with. + /// Options that affect the color search process for palletized images. + /// true on success, false on failure. + public bool EnlargeCanvas(int left, int top, int right, int bottom, + T? color, FREE_IMAGE_COLOR_OPTIONS options) where T : struct + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.EnlargeCanvas(dib, left, top, right, bottom, color, options)); + } + + /// + /// Enlarges or shrinks this selectively per side and fills + /// newly added areas with the specified background color returning a new instance. + /// See for further details. + /// + /// The type of the specified color. + /// The number of pixels, the image should be enlarged on its left side. + /// Negative values shrink the image on its left side. + /// The number of pixels, the image should be enlarged on its top side. + /// Negative values shrink the image on its top side. + /// The number of pixels, the image should be enlarged on its right side. + /// Negative values shrink the image on its right side. + /// The number of pixels, the image should be enlarged on its bottom side. + /// Negative values shrink the image on its bottom side. + /// The color, the enlarged sides of the image should be filled with. + /// The enlarged instance. + public FreeImageBitmap GetEnlargedInstance(int left, int top, int right, int bottom, + T? color) where T : struct + { + return GetEnlargedInstance(left, top, right, bottom, color, FREE_IMAGE_COLOR_OPTIONS.FICO_DEFAULT); + } + + /// + /// Enlarges or shrinks this selectively per side and fills + /// newly added areas with the specified background color returning a new instance. + /// See for further details. + /// + /// The type of the specified color. + /// The number of pixels, the image should be enlarged on its left side. + /// Negative values shrink the image on its left side. + /// The number of pixels, the image should be enlarged on its top side. + /// Negative values shrink the image on its top side. + /// The number of pixels, the image should be enlarged on its right side. + /// Negative values shrink the image on its right side. + /// The number of pixels, the image should be enlarged on its bottom side. + /// Negative values shrink the image on its bottom side. + /// The color, the enlarged sides of the image should be filled with. + /// Options that affect the color search process for palletized images. + /// The enlarged instance. + public FreeImageBitmap GetEnlargedInstance(int left, int top, int right, int bottom, + T? color, FREE_IMAGE_COLOR_OPTIONS options) where T : struct + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.EnlargeCanvas(dib, left, top, right, bottom, color, options); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Quantizes this from 24 bit to 8bit creating a new + /// palette with the specified using the specified + /// . + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// Returns true on success, false on failure. + public bool Quantize(FREE_IMAGE_QUANTIZE algorithm, int paletteSize) + { + return Quantize(algorithm, paletteSize, 0, (RGBQUAD[])null); + } + + /// + /// Quantizes this from 24 bit to 8bit creating a new + /// palette with the specified using the specified + /// and the specified + /// palette up to the + /// specified length. + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// The provided palette. + /// Returns true on success, false on failure. + public bool Quantize(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, Palette reservePalette) + { + return Quantize(algorithm, paletteSize, reservePalette.Length, reservePalette.Data); + } + + /// + /// Quantizes this from 24 bit to 8bit creating a new + /// palette with the specified using the specified + /// and the specified + /// palette up to the + /// specified length. + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// Size of the provided palette of ReservePalette. + /// The provided palette. + /// Returns true on success, false on failure. + public bool Quantize(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, int reserveSize, Palette reservePalette) + { + return Quantize(algorithm, paletteSize, reserveSize, reservePalette.Data); + } + + /// + /// Quantizes this from 24 bit to 8bit creating a new + /// palette with the specified using the specified + /// and the specified + /// palette up to the + /// specified length. + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// Size of the provided palette of ReservePalette. + /// The provided palette. + /// Returns true on success, false on failure. + public bool Quantize(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, int reserveSize, RGBQUAD[] reservePalette) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.ColorQuantizeEx(dib, algorithm, paletteSize, reserveSize, reservePalette)); + } + + /// + /// Quantizes this from 24 bit, using the specified + /// initializing a new 8 bit instance with the + /// specified . + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// The quantized instance. + public FreeImageBitmap GetQuantizedInstance(FREE_IMAGE_QUANTIZE algorithm, int paletteSize) + { + return GetQuantizedInstance(algorithm, paletteSize, 0, (RGBQUAD[])null); + } + + /// + /// Quantizes this from 24 bit, using the specified + /// and palette + /// initializing a new 8 bit instance with the specified . + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// The provided palette. + /// The quantized instance. + public FreeImageBitmap GetQuantizedInstance(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, Palette reservePalette) + { + return GetQuantizedInstance(algorithm, paletteSize, reservePalette.Length, reservePalette); + } + + /// + /// Quantizes this from 24 bit, using the specified + /// and up to + /// entries from palette initializing + /// a new 8 bit instance with the specified . + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// Size of the provided palette. + /// The provided palette. + /// The quantized instance. + public FreeImageBitmap GetQuantizedInstance(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, int reserveSize, Palette reservePalette) + { + return GetQuantizedInstance(algorithm, paletteSize, reserveSize, reservePalette.Data); + } + + /// + /// Quantizes this from 24 bit, using the specified + /// and up to + /// entries from palette initializing + /// a new 8 bit instance with the specified . + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// Size of the provided palette. + /// The provided palette. + /// The quantized instance. + public FreeImageBitmap GetQuantizedInstance(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, int reserveSize, RGBQUAD[] reservePalette) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.ColorQuantizeEx(dib, algorithm, paletteSize, reserveSize, reservePalette); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Converts a High Dynamic Range image to a 24-bit RGB image using a global + /// operator based on logarithmic compression of luminance values, imitating + /// the human response to light. + /// + /// A gamma correction that is applied after the tone mapping. + /// A value of 1 means no correction. + /// Scale factor allowing to adjust the brightness of the output image. + /// Returns true on success, false on failure. + public bool TmoDrago03(double gamma, double exposure) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.TmoDrago03(dib, gamma, exposure)); + } + + /// + /// Converts a High Dynamic Range image to a 24-bit RGB image using a global operator inspired + /// by photoreceptor physiology of the human visual system. + /// + /// Controls the overall image intensity in the range [-8, 8]. + /// Controls the overall image contrast in the range [0.3, 1.0[. + /// Returns true on success, false on failure. + public bool TmoReinhard05(double intensity, double contrast) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.TmoReinhard05(dib, intensity, contrast)); + } + + /// + /// Apply the Gradient Domain High Dynamic Range Compression to a RGBF image and convert to 24-bit RGB. + /// + /// Color saturation (s parameter in the paper) in [0.4..0.6] + /// Atenuation factor (beta parameter in the paper) in [0.8..0.9] + /// Returns true on success, false on failure. + public bool TmoFattal02(double color_saturation, double attenuation) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.TmoFattal02(dib, color_saturation, attenuation)); + } + + /// + /// This method rotates a 1-, 4-, 8-bit greyscale or a 24-, 32-bit color image by means of 3 shears. + /// For 1- and 4-bit images, rotation is limited to angles whose value is an integer + /// multiple of 90. + /// + /// The angle of rotation. + /// Returns true on success, false on failure. + public bool Rotate(double angle) + { + EnsureNotDisposed(); + bool result = false; + if (ColorDepth == 4) + { + result = ReplaceDib(FreeImage.Rotate4bit(dib, angle)); + } + else + { + result = ReplaceDib(FreeImage.Rotate(dib, angle)); + } + return result; + } + + /// + /// This method rotates a 1-, 4-, 8-bit greyscale or a 24-, 32-bit color image by means of 3 shears. + /// For 1- and 4-bit images, rotation is limited to angles whose value is an integer + /// multiple of 90. + /// + /// The type of the color to use as background. + /// The angle of rotation. + /// The color used used to fill the bitmap's background. + /// Returns true on success, false on failure. + public bool Rotate(double angle, T? backgroundColor) where T : struct + { + EnsureNotDisposed(); + bool result = false; + if (ColorDepth == 4) + { + result = ReplaceDib(FreeImage.Rotate4bit(dib, angle)); + } + else + { + result = ReplaceDib(FreeImage.Rotate(dib, angle, backgroundColor)); + } + return result; + } + + /// + /// Rotates this by the specified angle initializing a new instance. + /// For 1- and 4-bit images, rotation is limited to angles whose value is an integer + /// multiple of 90. + /// + /// The type of the color to use as background. + /// The angle of rotation. + /// The color used used to fill the bitmap's background. + /// The rotated instance. + public FreeImageBitmap GetRotatedInstance(double angle, T? backgroundColor) where T : struct + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib; + if (ColorDepth == 4) + { + newDib = FreeImage.Rotate4bit(dib, angle); + } + else + { + newDib = FreeImage.Rotate(dib, angle, backgroundColor); + } + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Rotates this by the specified angle initializing a new instance. + /// For 1- and 4-bit images, rotation is limited to angles whose value is an integer + /// multiple of 90. + /// + /// The angle of rotation. + /// The rotated instance. + public FreeImageBitmap GetRotatedInstance(double angle) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib; + if (ColorDepth == 4) + { + newDib = FreeImage.Rotate4bit(dib, angle); + } + else + { + newDib = FreeImage.Rotate(dib, angle); + } + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// This method performs a rotation and / or translation of an 8-bit greyscale, + /// 24- or 32-bit image, using a 3rd order (cubic) B-Spline. + /// + /// The angle of rotation. + /// Horizontal image translation. + /// Vertical image translation. + /// Rotation center x-coordinate. + /// Rotation center y-coordinate. + /// When true the irrelevant part of the image is set to a black color, + /// otherwise, a mirroring technique is used to fill irrelevant pixels. + /// Returns true on success, false on failure. + public bool Rotate(double angle, double xShift, double yShift, + double xOrigin, double yOrigin, bool useMask) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.RotateEx(dib, angle, xShift, yShift, xOrigin, yOrigin, useMask)); + } + + /// + /// This method performs a rotation and / or translation of an 8-bit greyscale, + /// 24- or 32-bit image, using a 3rd order (cubic) B-Spline initializing a new instance. + /// + /// The angle of rotation. + /// Horizontal image translation. + /// Vertical image translation. + /// Rotation center x-coordinate. + /// Rotation center y-coordinate. + /// When true the irrelevant part of the image is set to a black color, + /// otherwise, a mirroring technique is used to fill irrelevant pixels. + /// The rotated instance. + public FreeImageBitmap GetRotatedInstance(double angle, double xShift, double yShift, + double xOrigin, double yOrigin, bool useMask) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.RotateEx( + dib, angle, xShift, yShift, xOrigin, yOrigin, useMask); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Perfoms an histogram transformation on a 8-, 24- or 32-bit image. + /// + /// The lookup table (LUT). + /// It's size is assumed to be 256 in length. + /// The color channel to be transformed. + /// Returns true on success, false on failure. + public bool AdjustCurve(byte[] lookUpTable, FREE_IMAGE_COLOR_CHANNEL channel) + { + EnsureNotDisposed(); + return FreeImage.AdjustCurve(dib, lookUpTable, channel); + } + + /// + /// Performs gamma correction on a 8-, 24- or 32-bit image. + /// + /// The parameter represents the gamma value to use (gamma > 0). + /// A value of 1.0 leaves the image alone, less than one darkens it, and greater than one lightens it. + /// Returns true on success, false on failure. + public bool AdjustGamma(double gamma) + { + EnsureNotDisposed(); + return FreeImage.AdjustGamma(dib, gamma); + } + + /// + /// Adjusts the brightness of a 8-, 24- or 32-bit image by a certain amount. + /// + /// A value 0 means no change, + /// less than 0 will make the image darker and greater than 0 will make the image brighter. + /// Returns true on success, false on failure. + public bool AdjustBrightness(double percentage) + { + EnsureNotDisposed(); + return FreeImage.AdjustBrightness(dib, percentage); + } + + /// + /// Adjusts the contrast of a 8-, 24- or 32-bit image by a certain amount. + /// + /// A value 0 means no change, + /// less than 0 will decrease the contrast and greater than 0 will increase the contrast of the image. + /// Returns true on success, false on failure. + public bool AdjustContrast(double percentage) + { + EnsureNotDisposed(); + return FreeImage.AdjustContrast(dib, percentage); + } + + /// + /// Inverts each pixel data. + /// + /// Returns true on success, false on failure. + public bool Invert() + { + EnsureNotDisposed(); + return FreeImage.Invert(dib); + } + + /// + /// Computes the image histogram. + /// + /// Channel to compute from. + /// Array of integers containing the histogram. + /// Returns true on success, false on failure. + public bool GetHistogram(FREE_IMAGE_COLOR_CHANNEL channel, out int[] histogram) + { + EnsureNotDisposed(); + histogram = new int[256]; + return FreeImage.GetHistogram(dib, histogram, channel); + } + + /// + /// Retrieves the red, green, blue or alpha channel of a 24- or 32-bit image. + /// + /// The color channel to extract. + /// The color channel in a new instance. + public FreeImageBitmap GetChannel(FREE_IMAGE_COLOR_CHANNEL channel) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.GetChannel(dib, channel); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Insert a 8-bit dib into a 24- or 32-bit image. + /// Both images must have to same width and height. + /// + /// The to insert. + /// The color channel to replace. + /// Returns true on success, false on failure. + public bool SetChannel(FreeImageBitmap bitmap, FREE_IMAGE_COLOR_CHANNEL channel) + { + EnsureNotDisposed(); + bitmap.EnsureNotDisposed(); + return FreeImage.SetChannel(dib, bitmap.dib, channel); + } + + /// + /// Retrieves the real part, imaginary part, magnitude or phase of a complex image. + /// + /// The color channel to extract. + /// The color channel in a new instance. + public FreeImageBitmap GetComplexChannel(FREE_IMAGE_COLOR_CHANNEL channel) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.GetComplexChannel(dib, channel); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Set the real or imaginary part of a complex image. + /// Both images must have to same width and height. + /// + /// The to insert. + /// The color channel to replace. + /// Returns true on success, false on failure. + public bool SetComplexChannel(FreeImageBitmap bitmap, FREE_IMAGE_COLOR_CHANNEL channel) + { + EnsureNotDisposed(); + bitmap.EnsureNotDisposed(); + return FreeImage.SetComplexChannel(dib, bitmap.dib, channel); + } + + /// + /// Copy a sub part of this . + /// + /// The subpart to copy. + /// The sub part in a new instance. + public FreeImageBitmap Copy(Rectangle rect) + { + EnsureNotDisposed(); + return Copy(rect.Left, rect.Top, rect.Right, rect.Bottom); + } + + /// + /// Copy a sub part of this . + /// + /// Specifies the left position of the cropped rectangle. + /// Specifies the top position of the cropped rectangle. + /// Specifies the right position of the cropped rectangle. + /// Specifies the bottom position of the cropped rectangle. + /// The sub part in a new instance. + public FreeImageBitmap Copy(int left, int top, int right, int bottom) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.Copy(dib, left, top, right, bottom); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Alpha blend or combine a sub part image with this . + /// The bit depth of must be greater than or equal to the bit depth this instance. + /// + /// The to paste into this instance. + /// Specifies the left position of the sub image. + /// Specifies the top position of the sub image. + /// alpha blend factor. + /// The source and destination images are alpha blended if alpha=0..255. + /// If alpha > 255, then the source image is combined to the destination image. + /// Returns true on success, false on failure. + public bool Paste(FreeImageBitmap bitmap, int left, int top, int alpha) + { + EnsureNotDisposed(); + bitmap.EnsureNotDisposed(); + return FreeImage.Paste(dib, bitmap.dib, left, top, alpha); + } + + /// + /// Alpha blend or combine a sub part image with tthis . + /// The bit depth of must be greater than or equal to the bit depth this instance. + /// + /// The to paste into this instance. + /// Specifies the position of the sub image. + /// alpha blend factor. + /// The source and destination images are alpha blended if alpha=0..255. + /// If alpha > 255, then the source image is combined to the destination image. + /// Returns true on success, false on failure. + public bool Paste(FreeImageBitmap bitmap, Point point, int alpha) + { + EnsureNotDisposed(); + return Paste(bitmap, point.X, point.Y, alpha); + } + + /// + /// This method composite a transparent foreground image against a single background color or + /// against a background image. + /// In case is false and + /// and + /// are null, a checkerboard will be used as background. + /// + /// When true the background of this instance is used + /// if it contains one. + /// Backgroundcolor used in case is false + /// and is not null. + /// Background used in case + /// is false and is a null reference. + /// Returns true on success, false on failure. + public bool Composite(bool useBitmapBackground, Color? applicationBackground, FreeImageBitmap bitmapBackGround) + { + EnsureNotDisposed(); + bitmapBackGround.EnsureNotDisposed(); + RGBQUAD? rgb = applicationBackground; + return ReplaceDib( + FreeImage.Composite( + dib, + useBitmapBackground, + rgb.HasValue ? new RGBQUAD[] { rgb.Value } : null, + bitmapBackGround.dib)); + } + + /// + /// Applies the alpha value of each pixel to its color components. + /// The aplha value stays unchanged. + /// Only works with 32-bits color depth. + /// + /// Returns true on success, false on failure. + public bool PreMultiplyWithAlpha() + { + EnsureNotDisposed(); + return FreeImage.PreMultiplyWithAlpha(dib); + } + + /// + /// Solves a Poisson equation, remap result pixels to [0..1] and returns the solution. + /// + /// Number of cycles in the multigrid algorithm (usually 2 or 3) + /// Returns true on success, false on failure. + public bool MultigridPoissonSolver(int ncycle) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.MultigridPoissonSolver(dib, ncycle)); + } + + /// + /// Adjusts an image's brightness, contrast and gamma as well as it may + /// optionally invert the image within a single operation. + /// + /// Percentage brightness value where -100 <= brightness <= 100. + /// A value of 0 means no change, less than 0 will make the image darker and greater + /// than 0 will make the image brighter. + /// Percentage contrast value where -100 <= contrast <= 100. + /// A value of 0 means no change, less than 0 will decrease the contrast + /// and greater than 0 will increase the contrast of the image. + /// Gamma value to be used for gamma correction. + /// A value of 1.0 leaves the image alone, less than one darkens it, + /// and greater than one lightens it. + /// This parameter must not be zero or smaller than zero. + /// If so, it will be ignored and no gamma correction will be performed on the image. + /// If set to true, the image will be inverted. + /// Returns true on success, false on failure. + public bool AdjustColors(double brightness, double contrast, double gamma, bool invert) + { + EnsureNotDisposed(); + return FreeImage.AdjustColors(dib, brightness, contrast, gamma, invert); + } + + /// + /// Applies color mapping for one or several colors on a 1-, 4- or 8-bit + /// palletized or a 16-, 24- or 32-bit high color image. + /// + /// Array of colors to be used as the mapping source. + /// Array of colors to be used as the mapping destination. + /// If true, 32-bit images and colors are treated as 24-bit. + /// If true, source and destination colors are swapped, that is, + /// each destination color is also mapped to the corresponding source color. + /// The total number of pixels changed. + /// + /// or is a null reference. + /// + /// + /// has a different length than . + /// + public uint ApplyColorMapping(RGBQUAD[] srccolors, RGBQUAD[] dstcolors, bool ignore_alpha, bool swap) + { + EnsureNotDisposed(); + if (srccolors == null) + { + throw new ArgumentNullException("srccolors"); + } + if (dstcolors == null) + { + throw new ArgumentNullException("dstcolors"); + } + if (srccolors.Length != dstcolors.Length) + { + throw new ArgumentException("srccolors and dstcolors must have the same length."); + } + return FreeImage.ApplyColorMapping(dib, srccolors, dstcolors, (uint)srccolors.Length, ignore_alpha, swap); + } + + /// + /// Swaps two specified colors on a 1-, 4- or 8-bit palletized + /// or a 16-, 24- or 32-bit high color image. + /// + /// One of the two colors to be swapped. + /// The other of the two colors to be swapped. + /// If true, 32-bit images and colors are treated as 24-bit. + /// The total number of pixels changed. + public uint SwapColors(RGBQUAD color_a, RGBQUAD color_b, bool ignore_alpha) + { + EnsureNotDisposed(); + return FreeImage.SwapColors(dib, ref color_a, ref color_b, ignore_alpha); + } + + /// + /// Applies palette index mapping for one or several indices + /// on a 1-, 4- or 8-bit palletized image. + /// + /// Array of palette indices to be used as the mapping source. + /// Array of palette indices to be used as the mapping destination. + /// The number of palette indices to be mapped. This is the size of both + /// srcindices and dstindices + /// If true, source and destination palette indices are swapped, that is, + /// each destination index is also mapped to the corresponding source index. + /// The total number of pixels changed. + /// + /// or is a null reference. + /// + /// + /// has a different length than . + /// + public uint ApplyPaletteIndexMapping(byte[] srcindices, byte[] dstindices, uint count, bool swap) + { + EnsureNotDisposed(); + if (srcindices == null) + { + throw new ArgumentNullException("srcindices"); + } + if (dstindices == null) + { + throw new ArgumentNullException("dstindices"); + } + if (srcindices.Length != dstindices.Length) + { + throw new ArgumentException("srcindices and dstindices must have the same length."); + } + return FreeImage.ApplyPaletteIndexMapping(dib, srcindices, dstindices, (uint)srcindices.Length, swap); + } + + /// + /// Swaps two specified palette indices on a 1-, 4- or 8-bit palletized image. + /// + /// One of the two palette indices to be swapped. + /// The other of the two palette indices to be swapped. + /// The total number of pixels changed. + public uint SwapPaletteIndices(byte index_a, byte index_b) + { + EnsureNotDisposed(); + return FreeImage.SwapPaletteIndices(dib, ref index_a, ref index_b); + } + + /// + /// Sets all pixels of this to the specified color. + /// See for further details. + /// + /// The type of the specified color. + /// The color to fill this with. + /// true on success, false on failure. + public bool FillBackground(T color) where T : struct + { + return FillBackground(color, FREE_IMAGE_COLOR_OPTIONS.FICO_DEFAULT); + } + + /// + /// Sets all pixels of this to the specified color. + /// See for further details. + /// + /// The type of the specified color. + /// The color to fill this with. + /// Options that affect the color search process for palletized images. + /// true on success, false on failure. + public bool FillBackground(T color, FREE_IMAGE_COLOR_OPTIONS options) where T : struct + { + EnsureNotDisposed(); + return FreeImage.FillBackground(dib, color, options); + } + + /// + /// Creates a new ICC-Profile. + /// + /// The data of the new ICC-Profile. + /// The new ICC-Profile of the bitmap. + /// is a null reference. + public FIICCPROFILE CreateICCProfile(byte[] data) + { + if (data == null) + { + throw new ArgumentNullException("data"); + } + return CreateICCProfile(data, data.Length); + } + + /// + /// Creates a new ICC-Profile. + /// + /// The data of the new ICC-Profile. + /// The number of bytes of to use. + /// The new ICC-Profile of the bitmap. + /// is null. + public FIICCPROFILE CreateICCProfile(byte[] data, int size) + { + EnsureNotDisposed(); + if (data == null) + { + throw new ArgumentNullException("data"); + } + return FreeImage.CreateICCProfileEx(dib, data, size); + } + + /// + /// Determines whether this and the specified instances are the same. + /// + /// The object to test. + /// true if this instance is the same + /// or if both are null references; otherwise, false. + public override bool Equals(object obj) + { + return ReferenceEquals(this, obj); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return dib.GetHashCode(); + } + + #endregion + + #region Static functions + + /// + /// Returns a value that indicates whether the pixel format for this contains alpha information. + /// + /// The to test. + /// true if pixfmt contains alpha information; otherwise, false. + public static bool IsAlphaPixelFormat(PixelFormat pixfmt) + { + return Bitmap.IsAlphaPixelFormat(pixfmt); + } + + /// + /// Returns a value that indicates whether the pixel format is 32 bits per pixel. + /// + /// The to test. + /// true if pixfmt is canonical; otherwise, false. + public static bool IsCanonicalPixelFormat(PixelFormat pixfmt) + { + return Bitmap.IsCanonicalPixelFormat(pixfmt); + } + + /// + /// Returns a value that indicates whether the pixel format is 64 bits per pixel. + /// + /// The enumeration to test. + /// true if pixfmt is extended; otherwise, false. + public static bool IsExtendedPixelFormat(PixelFormat pixfmt) + { + return Bitmap.IsExtendedPixelFormat(pixfmt); + } + + /// + /// Creates a from a Windows handle to an icon. + /// + /// A handle to an icon. + /// The that this method creates. + public static FreeImageBitmap FromHicon(IntPtr hicon) + { + using (Bitmap bitmap = Bitmap.FromHicon(hicon)) + { + return new FreeImageBitmap(bitmap); + } + } + + /// + /// Creates a from the specified Windows resource. + /// + /// A handle to an instance of the executable + /// file that contains the resource. + /// A string containing the name of the resource bitmap. + /// The that this method creates. + public static FreeImageBitmap FromResource(IntPtr hinstance, string bitmapName) + { + using (Bitmap bitmap = Bitmap.FromResource(hinstance, bitmapName)) + { + return new FreeImageBitmap(bitmap); + } + } + + /// + /// Creates a from the specified file. + /// + /// A string that contains the name of the file + /// from which to create the . + /// The this method creates. + public static FreeImageBitmap FromFile(string filename) + { + return new FreeImageBitmap(filename); + } + + /// + /// Creates a from the specified file + /// using embedded color management information in that file. + /// + /// A string that contains the + /// name of the file from which to create the . + /// Ignored. + /// The this method creates. + public static FreeImageBitmap FromFile(string filename, bool useEmbeddedColorManagement) + { + return new FreeImageBitmap(filename); + } + + /// + /// Creates a from a handle to a GDI bitmap. + /// + /// The GDI bitmap handle from which to create the . + /// The this method creates. + public static FreeImageBitmap FromHbitmap(IntPtr hbitmap) + { + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.CreateFromHbitmap(hbitmap, IntPtr.Zero); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Creates a from a handle to a GDI bitmap and a handle to a GDI palette. + /// + /// The GDI bitmap handle from which to create the . + /// Ignored. + /// The this method creates. + public static FreeImageBitmap FromHbitmap(IntPtr hbitmap, IntPtr hpalette) + { + return FromHbitmap(hbitmap); + } + + /// + /// Frees a bitmap handle. + /// + /// Handle to a bitmap. + /// true on success, false on failure. + public static bool FreeHbitmap(IntPtr hbitmap) + { + return FreeImage.FreeHbitmap(hbitmap); + } + + /// + /// Creates a from the specified data stream. + /// + /// A that contains the data for this . + /// The this method creates. + public static FreeImageBitmap FromStream(Stream stream) + { + return new FreeImageBitmap(stream); + } + + /// + /// Creates a from the specified data stream. + /// + /// A that contains the data for this . + /// Ignored. + /// The this method creates. + public static FreeImageBitmap FromStream(Stream stream, bool useEmbeddedColorManagement) + { + return new FreeImageBitmap(stream); + } + + /// + /// Creates a from the specified data stream. + /// + /// A that contains the data for this . + /// Ignored. + /// Ignored. + /// The this method creates. + public static FreeImageBitmap FromStream(Stream stream, bool useEmbeddedColorManagement, bool validateImageData) + { + return new FreeImageBitmap(stream); + } + + /// + /// Returns the color depth, in number of bits per pixel, + /// of the specified pixel format. + /// + /// The member that specifies + /// the format for which to find the size. + /// The color depth of the specified pixel format. + public static int GetPixelFormatSize(PixelFormat pixfmt) + { + return Bitmap.GetPixelFormatSize(pixfmt); + } + + /// + /// Performs a lossless rotation or flipping on a JPEG file. + /// + /// Source file. + /// Destination file; can be the source file; will be overwritten. + /// The operation to apply. + /// To avoid lossy transformation, you can set the perfect parameter to true. + /// Returns true on success, false on failure. + public static bool JPEGTransform(string source, string destination, FREE_IMAGE_JPEG_OPERATION operation, bool perfect) + { + return FreeImage.JPEGTransform(source, destination, operation, perfect); + } + + /// + /// Performs a lossless crop on a JPEG file. + /// + /// Source filename. + /// Destination filename. + /// Specifies the cropped rectangle. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// + /// does not exist. + /// + public static bool JPEGCrop(string source, string destination, Rectangle rect) + { + if (source == null) + { + throw new ArgumentNullException("source"); + } + if (!File.Exists(source)) + { + throw new FileNotFoundException("source"); + } + if (destination == null) + { + throw new ArgumentNullException("destination"); + } + return JPEGCrop(source, destination, rect.Left, rect.Top, rect.Right, rect.Bottom); + } + + /// + /// Performs a lossless crop on a JPEG file. + /// + /// Source filename. + /// Destination filename. + /// Specifies the left position of the cropped rectangle. + /// Specifies the top position of the cropped rectangle. + /// Specifies the right position of the cropped rectangle. + /// Specifies the bottom position of the cropped rectangle. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// + /// does not exist. + /// + public static bool JPEGCrop(string source, string destination, int left, int top, int right, int bottom) + { + if (source == null) + { + throw new ArgumentNullException("source"); + } + if (!File.Exists(source)) + { + throw new FileNotFoundException("source"); + } + if (destination == null) + { + throw new ArgumentNullException("destination"); + } + return FreeImage.JPEGCrop(source, destination, left, top, right, bottom); + } + + /// + /// Converts a X11 color name into a corresponding RGB value. + /// + /// Name of the color to convert. + /// Red component. + /// Green component. + /// Blue component. + /// Returns true on success, false on failure. + /// is null. + public static bool LookupX11Color(string color, out byte red, out byte green, out byte blue) + { + if (color == null) + { + throw new ArgumentNullException("color"); + } + return FreeImage.LookupX11Color(color, out red, out green, out blue); + } + + /// + /// Converts a SVG color name into a corresponding RGB value. + /// + /// Name of the color to convert. + /// Red component. + /// Green component. + /// Blue component. + /// Returns true on success, false on failure. + /// is null. + public static bool LookupSVGColor(string color, out byte red, out byte green, out byte blue) + { + if (color == null) + { + throw new ArgumentNullException("color"); + } + return FreeImage.LookupSVGColor(color, out red, out green, out blue); + } + + /// + /// Creates a lookup table to be used with AdjustCurve() which + /// may adjusts brightness and contrast, correct gamma and invert the image with a + /// single call to AdjustCurve(). + /// + /// Output lookup table to be used with AdjustCurve(). + /// The size of is assumed to be 256. + /// Percentage brightness value where -100 <= brightness <= 100. + /// A value of 0 means no change, less than 0 will make the image darker and greater + /// than 0 will make the image brighter. + /// Percentage contrast value where -100 <= contrast <= 100. + /// A value of 0 means no change, less than 0 will decrease the contrast + /// and greater than 0 will increase the contrast of the image. + /// Gamma value to be used for gamma correction. + /// A value of 1.0 leaves the image alone, less than one darkens it, + /// and greater than one lightens it. + /// If set to true, the image will be inverted. + /// The number of adjustments applied to the resulting lookup table + /// compared to a blind lookup table. + /// is null. + /// is not 256. + public static int GetAdjustColorsLookupTable(byte[] lookUpTable, double brightness, double contrast, double gamma, bool invert) + { + if (lookUpTable == null) + { + throw new ArgumentNullException("lookUpTable"); + } + if (lookUpTable.Length != 256) + { + throw new ArgumentException("lookUpTable"); + } + return FreeImage.GetAdjustColorsLookupTable(lookUpTable, brightness, contrast, gamma, invert); + } + + /// + /// Adds a specified frame to the file specified using the specified parameters. + /// Use this method to save selected frames from an to a multiple-frame image. + /// + /// File to add this frame to. + /// A that contains the frame to add. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// Flags to enable or disable plugin-features. + /// + /// or is null. + /// + /// does not exist. + /// Saving the image failed. + public static void SaveAdd( + string filename, + FreeImageBitmap bitmap, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS loadFlags, + FREE_IMAGE_SAVE_FLAGS saveFlags) + { + if (filename == null) + { + throw new ArgumentNullException("filename"); + } + if (!File.Exists(filename)) + { + throw new FileNotFoundException("filename"); + } + if (bitmap == null) + { + throw new ArgumentNullException("bitmap"); + } + bitmap.EnsureNotDisposed(); + + FIBITMAP dib = bitmap.dib; + if (dib.IsNull) + throw new ArgumentNullException("bitmap"); + + FIMULTIBITMAP mpBitmap = + FreeImage.OpenMultiBitmapEx(filename, ref format, loadFlags, false, false, true); + + if (mpBitmap.IsNull) + throw new Exception(ErrorLoadingBitmap); + + FreeImage.AppendPage(mpBitmap, bitmap.dib); + + if (!FreeImage.CloseMultiBitmap(mpBitmap, saveFlags)) + throw new Exception(ErrorUnloadBitmap); + } + + /// + /// Adds a specified frame to the file specified using the specified parameters. + /// Use this method to save selected frames from an image to a multiple-frame image. + /// + /// File to add this frame to. + /// A that contains the frame to add. + /// The position of the inserted frame. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// Flags to enable or disable plugin-features. + /// + /// or is null. + /// + /// does not exist. + /// Saving the image failed. + /// is out of range. + public static void SaveAdd( + string filename, + FreeImageBitmap bitmap, + int insertPosition, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS loadFlags, + FREE_IMAGE_SAVE_FLAGS saveFlags) + { + if (filename == null) + { + throw new ArgumentNullException("filename"); + } + if (!File.Exists(filename)) + { + throw new FileNotFoundException("filename"); + } + if (bitmap == null) + { + throw new ArgumentNullException("bitmap"); + } + if (insertPosition < 0) + { + throw new ArgumentOutOfRangeException("insertPosition"); + } + bitmap.EnsureNotDisposed(); + + FIBITMAP dib = bitmap.dib; + if (dib.IsNull) + throw new ArgumentNullException("bitmap"); + + FIMULTIBITMAP mpBitmap = + FreeImage.OpenMultiBitmapEx(filename, ref format, loadFlags, false, false, true); + + if (mpBitmap.IsNull) + throw new Exception(ErrorLoadingBitmap); + + int pageCount = FreeImage.GetPageCount(mpBitmap); + + if (insertPosition > pageCount) + throw new ArgumentOutOfRangeException("insertPosition"); + + if (insertPosition == pageCount) + FreeImage.AppendPage(mpBitmap, bitmap.dib); + else + FreeImage.InsertPage(mpBitmap, insertPosition, bitmap.dib); + + if (!FreeImage.CloseMultiBitmap(mpBitmap, saveFlags)) + throw new Exception(ErrorUnloadBitmap); + } + + /// + /// Returns a new instance of the class which + /// has no public accessible constructor. + /// + /// A new instace of . + public static PropertyItem CreateNewPropertyItem() + { + return FreeImage.CreatePropertyItem(); + } + + #endregion + + #region Helper functions + + /// + /// Throws an exception in case the instance has already been disposed. + /// + private void EnsureNotDisposed() + { + lock (lockObject) + { + if (!this.disposed) + { + return; + } + } + throw new ObjectDisposedException(ToString()); + } + + /// + /// Tries to replace the wrapped with a new one. + /// In case the new dib is null or the same as the already + /// wrapped one, nothing will be changed and the result will + /// be false. + /// Otherwise the wrapped will be unloaded and replaced. + /// + /// The new dib. + /// Returns true on success, false on failure. + private bool ReplaceDib(FIBITMAP newDib) + { + bool result = false; + if ((dib != newDib) && (!newDib.IsNull)) + { + UnloadDib(); + dib = newDib; + AddMemoryPressure(); + result = true; + } + return result; + } + + /// + /// Unloads currently wrapped or unlocks the locked page + /// in case it came from a multipaged bitmap. + /// + private void UnloadDib() + { + if (!dib.IsNull) + { + long size = FreeImage.GetDIBSize(dib); + FreeImage.UnloadEx(ref dib); + if (size > 0L) + GC.RemoveMemoryPressure(size); + } + } + + /// + /// Informs the runtime about unmanaged allocoted memory. + /// + private void AddMemoryPressure() + { + long dataSize; + if ((dataSize = DataSize) > 0L) + GC.AddMemoryPressure(dataSize); + } + + /// + /// Opens the stream and reads the number of available pages. + /// Then loads the first page to this instance. + /// + private void LoadFromStream(Stream stream, FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags) + { + FIMULTIBITMAP mdib = FreeImage.OpenMultiBitmapFromStream(stream, ref format, flags); + if (mdib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + try + { + frameCount = FreeImage.GetPageCount(mdib); + } + finally + { + if (!FreeImage.CloseMultiBitmapEx(ref mdib)) + { + throw new Exception(ErrorUnloadBitmap); + } + } + + dib = FreeImage.LoadFromStream(stream, flags, ref format); + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + + saveInformation.loadFlags = flags; + originalFormat = format; + AddMemoryPressure(); + } + + #endregion + + #region Interfaces + + /// + /// Helper class to store informations for . + /// + private sealed class SaveInformation : ICloneable + { + public string filename; + public FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + public FREE_IMAGE_LOAD_FLAGS loadFlags = FREE_IMAGE_LOAD_FLAGS.DEFAULT; + public FREE_IMAGE_SAVE_FLAGS saveFlags = FREE_IMAGE_SAVE_FLAGS.DEFAULT; + + public object Clone() + { + return base.MemberwiseClone(); + } + } + + /// + /// Creates a deep copy of this . + /// + /// A deep copy of this . + public object Clone() + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.Clone(dib); + if (!dib.IsNull) + { + result = new FreeImageBitmap(newDib); + result.saveInformation = (SaveInformation)saveInformation.Clone(); + result.tag = tag; + result.originalFormat = originalFormat; + } + return result; + } + + /// + /// Performs application-defined tasks associated with freeing, + /// releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Performs application-defined tasks associated with freeing, + /// releasing, or resetting unmanaged resources. + /// + /// If true managed ressources are released. + protected virtual void Dispose(bool disposing) + { + // Only clean up once + lock (lockObject) + { + if (disposed) + { + return; + } + disposed = true; + } + + // Clean up managed resources + if (disposing) + { + if (stream != null) + { + if (disposeStream) + { + stream.Dispose(); + } + stream = null; + } + } + + tag = null; + saveInformation = null; + + // Clean up unmanaged resources + UnloadDib(); + } + + /// + /// Retrieves an object that can iterate through the individual scanlines in this . + /// + /// An for the . + /// The bitmaps's type is not supported. + IEnumerator IEnumerable.GetEnumerator() + { + return GetScanlines().GetEnumerator(); + } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + EnsureNotDisposed(); + using (MemoryStream memory = new MemoryStream(DataSize)) + { + if (!FreeImage.SaveToStream(dib, memory, FREE_IMAGE_FORMAT.FIF_TIFF, FREE_IMAGE_SAVE_FLAGS.TIFF_LZW)) + { + throw new SerializationException(); + } + memory.Capacity = (int)memory.Length; + info.AddValue("Bitmap Data", memory.GetBuffer()); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImageEngine.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImageEngine.cs new file mode 100644 index 0000000..be287bc --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImageEngine.cs @@ -0,0 +1,101 @@ +using System; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace FreeImageAPI +{ + /// + /// Class handling non-bitmap related functions. + /// + public static class FreeImageEngine + { + #region Callback + + // Callback delegate + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly OutputMessageFunction outputMessageFunction; + + static FreeImageEngine() + { + // Check if FreeImage.dll is present and cancel setting the callbackfuntion if not + if (!IsAvailable) + { + return; + } + // Create a delegate (function pointer) to 'OnMessage' + outputMessageFunction = new OutputMessageFunction(OnMessage); + // Set the callback + FreeImage.SetOutputMessage(outputMessageFunction); + } + + /// + /// Internal callback + /// + private static void OnMessage(FREE_IMAGE_FORMAT fif, string message) + { + // Get a local copy of the multicast-delegate + OutputMessageFunction m = Message; + + // Check the local copy instead of the static instance + // to prevent a second thread from setting the delegate + // to null, which would cause a nullreference exception + if (m != null) + { + // Invoke the multicast-delegate + m.Invoke(fif, message); + } + } + + /// + /// Gets a value indicating if the FreeImage DLL is available or not. + /// + public static bool IsAvailable + { + get + { + return FreeImage.IsAvailable(); + } + } + + /// + /// Internal errors in FreeImage generate a logstring that can be + /// captured by this event. + /// + public static event OutputMessageFunction Message; + + #endregion + + /// + /// Gets a string containing the current version of the library. + /// + public static string Version + { + get + { + return FreeImage.GetVersion(); + } + } + + /// + /// Gets a string containing a standard copyright message. + /// + public static string CopyrightMessage + { + get + { + return FreeImage.GetCopyrightMessage(); + } + } + + /// + /// Gets whether the platform is using Little Endian. + /// + public static bool IsLittleEndian + { + get + { + return FreeImage.IsLittleEndian(); + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImagePlugin.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImagePlugin.cs new file mode 100644 index 0000000..399d492 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImagePlugin.cs @@ -0,0 +1,202 @@ +using System; +using System.Diagnostics; + +namespace FreeImageAPI.Plugins +{ + /// + /// Class representing a FreeImage format. + /// + public sealed class FreeImagePlugin + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly FREE_IMAGE_FORMAT fif; + + /// + /// Initializes a new instance of this class. + /// + /// The FreeImage format to wrap. + internal FreeImagePlugin(FREE_IMAGE_FORMAT fif) + { + this.fif = fif; + } + + /// + /// Gets the format of this instance. + /// + public FREE_IMAGE_FORMAT FIFormat + { + get + { + return fif; + } + } + + /// + /// Gets or sets whether this plugin is enabled. + /// + public bool Enabled + { + get + { + return (FreeImage.IsPluginEnabled(fif) == 1); + } + set + { + FreeImage.SetPluginEnabled(fif, value); + } + } + + /// + /// Gets a string describing the format. + /// + public string Format + { + get + { + return FreeImage.GetFormatFromFIF(fif); + } + } + + /// + /// Gets a comma-delimited file extension list describing the bitmap formats + /// this plugin can read and/or write. + /// + public string ExtentsionList + { + get + { + return FreeImage.GetFIFExtensionList(fif); + } + } + + /// + /// Gets a descriptive string that describes the bitmap formats + /// this plugin can read and/or write. + /// + public string Description + { + get + { + return FreeImage.GetFIFDescription(fif); + } + } + + /// + /// Returns a regular expression string that can be used by + /// a regular expression engine to identify the bitmap. + /// FreeImageQt makes use of this function. + /// + public string RegExpr + { + get + { + return FreeImage.GetFIFRegExpr(fif); + } + } + + /// + /// Gets whether this plugin can load bitmaps. + /// + public bool SupportsReading + { + get + { + return FreeImage.FIFSupportsReading(fif); + } + } + + /// + /// Gets whether this plugin can save bitmaps. + /// + public bool SupportsWriting + { + get + { + return FreeImage.FIFSupportsWriting(fif); + } + } + + /// + /// Checks whether this plugin can save a bitmap in the desired data type. + /// + /// The desired image type. + /// True if this plugin can save bitmaps as the desired type, else false. + public bool SupportsExportType(FREE_IMAGE_TYPE type) + { + return FreeImage.FIFSupportsExportType(fif, type); + } + + /// + /// Checks whether this plugin can save bitmaps in the desired bit depth. + /// + /// The desired bit depth. + /// True if this plugin can save bitmaps in the desired bit depth, else false. + public bool SupportsExportBPP(int bpp) + { + return FreeImage.FIFSupportsExportBPP(fif, bpp); + } + + /// + /// Gets whether this plugin can load or save an ICC profile. + /// + public bool SupportsICCProfiles + { + get + { + return FreeImage.FIFSupportsICCProfiles(fif); + } + } + + /// + /// Checks whether an extension is valid for this format. + /// + /// The desired extension. + /// True if the extension is valid for this format, false otherwise. + public bool ValidExtension(string extension) + { + return FreeImage.IsExtensionValidForFIF(fif, extension); + } + + /// + /// Checks whether an extension is valid for this format. + /// + /// The desired extension. + /// The string comparison type. + /// True if the extension is valid for this format, false otherwise. + public bool ValidExtension(string extension, StringComparison comparisonType) + { + return FreeImage.IsExtensionValidForFIF(fif, extension, comparisonType); + } + + /// + /// Checks whether a filename is valid for this format. + /// + /// The desired filename. + /// True if the filename is valid for this format, false otherwise. + public bool ValidFilename(string filename) + { + return FreeImage.IsFilenameValidForFIF(fif, filename); + } + + /// + /// Checks whether a filename is valid for this format. + /// + /// The desired filename. + /// The string comparison type. + /// True if the filename is valid for this format, false otherwise. + public bool ValidFilename(string filename, StringComparison comparisonType) + { + return FreeImage.IsFilenameValidForFIF(fif, filename, comparisonType); + } + + /// + /// Gets a descriptive string that describes the bitmap formats + /// this plugin can read and/or write. + /// + /// A descriptive string that describes the bitmap formats. + public override string ToString() + { + return Description; + } + } +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImageStreamIO.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImageStreamIO.cs new file mode 100644 index 0000000..fa0bfc7 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImageStreamIO.cs @@ -0,0 +1,167 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.5 $ +// $Date: 2009/09/15 11:47:46 $ +// $Id: FreeImageStreamIO.cs,v 1.5 2009/09/15 11:47:46 cklein05 Exp $ +// ========================================================== + +using System; +using System.IO; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace FreeImageAPI.IO +{ + /// + /// Internal class wrapping stream io functions. + /// + /// + /// FreeImage can read files from a disk or a network drive but also allows the user to + /// implement their own loading or saving functions to load them directly from an ftp or web + /// server for example. + /// + /// In .NET streams are a common way to handle data. The FreeImageStreamIO class handles + /// the loading and saving from and to streams. It implements the funtions FreeImage needs + /// to load data from an an arbitrary source. + /// + /// The class is for internal use only. + /// + internal static class FreeImageStreamIO + { + /// + /// structure that can be used to read from streams via + /// . + /// + public static readonly FreeImageIO io; + + /// + /// Initializes a new instances which can be used to + /// create a FreeImage compatible structure. + /// + static FreeImageStreamIO() + { + io.readProc = new ReadProc(streamRead); + io.writeProc = new WriteProc(streamWrite); + io.seekProc = new SeekProc(streamSeek); + io.tellProc = new TellProc(streamTell); + } + + /// + /// Reads the requested data from the stream and writes it to the given address. + /// + static unsafe uint streamRead(IntPtr buffer, uint size, uint count, fi_handle handle) + { + Stream stream = handle.GetObject() as Stream; + if ((stream == null) || (!stream.CanRead)) + { + return 0; + } + uint readCount = 0; + byte* ptr = (byte*)buffer; + byte[] bufferTemp = new byte[size]; + int read; + while (readCount < count) + { + read = stream.Read(bufferTemp, 0, (int)size); + if (read != (int)size) + { + stream.Seek(-read, SeekOrigin.Current); + break; + } + for (int i = 0; i < read; i++, ptr++) + { + *ptr = bufferTemp[i]; + } + readCount++; + } + return (uint)readCount; + } + + /// + /// Reads the given data and writes it into the stream. + /// + static unsafe uint streamWrite(IntPtr buffer, uint size, uint count, fi_handle handle) + { + Stream stream = handle.GetObject() as Stream; + if ((stream == null) || (!stream.CanWrite)) + { + return 0; + } + uint writeCount = 0; + byte[] bufferTemp = new byte[size]; + byte* ptr = (byte*)buffer; + while (writeCount < count) + { + for (int i = 0; i < size; i++, ptr++) + { + bufferTemp[i] = *ptr; + } + try + { + stream.Write(bufferTemp, 0, bufferTemp.Length); + } + catch + { + return writeCount; + } + writeCount++; + } + return writeCount; + } + + /// + /// Moves the streams position. + /// + static int streamSeek(fi_handle handle, int offset, SeekOrigin origin) + { + Stream stream = handle.GetObject() as Stream; + if (stream == null) + { + return 1; + } + stream.Seek((long)offset, origin); + return 0; + } + + /// + /// Returns the streams current position + /// + static int streamTell(fi_handle handle) + { + Stream stream = handle.GetObject() as Stream; + if (stream == null) + { + return -1; + } + return (int)stream.Position; + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/GifInformation.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/GifInformation.cs new file mode 100644 index 0000000..75af8ad --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/GifInformation.cs @@ -0,0 +1,131 @@ +using System; +using System.Diagnostics; +using System.Drawing; + +namespace FreeImageAPI.Metadata +{ + /// + /// Provides additional information specific for GIF files. This class cannot be inherited. + /// + public class GifInformation : MDM_ANIMATION + { + /// + /// Initializes a new instance of the class + /// with the specified . + /// + /// A reference to a instance. + public GifInformation(FreeImageBitmap bitmap) + : base(bitmap.Dib) + { + } + + /// + /// Gets or sets a value indicating whether this frame uses the + /// GIF image's global palette. If set to false, this + /// frame uses its local palette. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? UseGlobalPalette + { + get + { + byte? useGlobalPalette = GetTagValue("NoLocalPalette"); + return useGlobalPalette.HasValue ? (useGlobalPalette.Value != 0) : default(bool?); + } + set + { + byte? val = null; + if (value.HasValue) + { + val = (byte)(value.Value ? 1 : 0); + } + SetTagValue("NoLocalPalette", val); + } + } + + /// + /// Creates a global palette for the GIF image, intialized with all entries of the + /// current local palette. + /// The property will be set to true when + /// invoking this method. This effectively enables the newly created global palette. + /// + /// + /// The image does not have a palette. + /// + public void CreateGlobalPalette() + { + CreateGlobalPalette(new Palette(dib)); + } + + /// + /// Creates a global palette for the GIF image with the specified size, intialized + /// with the first entries of the current local palette. + /// The property will be set to true when + /// invoking this method. This effectively enables the newly created global palette. + /// + /// The size of the newly created global palette. + /// + /// is a null reference. + public void CreateGlobalPalette(int size) + { + CreateGlobalPalette(new Palette(dib), size); + } + + /// + /// Creates a global palette for the GIF image, intialized with the entries + /// of the specified palette. + /// The property will be set to true when + /// invoking this method. This effectively enables the newly created global palette. + /// + /// The palette that contains the initial values for + /// the newly created global palette. + /// + /// is a null reference. + public void CreateGlobalPalette(Palette palette) + { + if (palette == null) + { + throw new ArgumentNullException("palette"); + } + + GlobalPalette = palette; + UseGlobalPalette = true; + } + + /// + /// Creates a global palette for the GIF image with the specified size, intialized + /// with the first entries of the specified palette. + /// The property will be set to true when + /// invoking this method. This effectively enables the newly created global palette. + /// + /// The palette that contains the initial values for + /// the newly created global palette. + /// The size of the newly created global palette. + /// + /// is a null reference. + public void CreateGlobalPalette(Palette palette, int size) + { + if (palette == null) + { + throw new ArgumentNullException("palette"); + } + if (size <= 0) + { + throw new ArgumentOutOfRangeException("size"); + } + + Palette pal = new Palette(size); + pal.CopyFrom(palette); + GlobalPalette = palette; + UseGlobalPalette = true; + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/ImageMetadata.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/ImageMetadata.cs new file mode 100644 index 0000000..d0bb44b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/ImageMetadata.cs @@ -0,0 +1,286 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.7 $ +// $Date: 2009/02/27 16:34:59 $ +// $Id: ImageMetadata.cs,v 1.7 2009/02/27 16:34:59 cklein05 Exp $ +// ========================================================== + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Diagnostics; + +namespace FreeImageAPI.Metadata +{ + /// + /// Class handling metadata of a FreeImage bitmap. + /// + public class ImageMetadata : IEnumerable, IComparable, IComparable + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly List data; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly FIBITMAP dib; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool hideEmptyModels; + + /// + /// Initializes a new instance based on the specified , + /// showing all known models. + /// + /// Handle to a FreeImage bitmap. + public ImageMetadata(FIBITMAP dib) : this(dib, false) { } + + /// + /// Initializes a new instance based on the specified , + /// showing or hiding empry models. + /// + /// Handle to a FreeImage bitmap. + /// When true, empty metadata models + /// will be hidden until a tag to this model is added. + public ImageMetadata(FIBITMAP dib, bool hideEmptyModels) + { + if (dib.IsNull) throw new ArgumentNullException("dib"); + data = new List(FreeImage.FREE_IMAGE_MDMODELS.Length); + this.dib = dib; + this.hideEmptyModels = hideEmptyModels; + + data.Add(new MDM_ANIMATION(dib)); + data.Add(new MDM_COMMENTS(dib)); + data.Add(new MDM_CUSTOM(dib)); + data.Add(new MDM_EXIF_EXIF(dib)); + data.Add(new MDM_EXIF_GPS(dib)); + data.Add(new MDM_INTEROP(dib)); + data.Add(new MDM_EXIF_MAIN(dib)); + data.Add(new MDM_MAKERNOTE(dib)); + data.Add(new MDM_GEOTIFF(dib)); + data.Add(new MDM_IPTC(dib)); + data.Add(new MDM_NODATA(dib)); + data.Add(new MDM_XMP(dib)); + } + + /// + /// Gets or sets the of the specified type. + /// In case the getter returns null the model is not contained + /// by the list. + /// null can be used calling the setter to destroy the model. + /// + /// Type of the model. + /// The object of the specified type. + public MetadataModel this[FREE_IMAGE_MDMODEL model] + { + get + { + for (int i = 0; i < data.Count; i++) + { + if (data[i].Model == model) + { + if (!data[i].Exists && hideEmptyModels) + { + return null; + } + return data[i]; + } + } + return null; + } + } + + /// + /// Gets or sets the at the specified index. + /// In case the getter returns null the model is not contained + /// by the list. + /// null can be used calling the setter to destroy the model. + /// + /// Index of the within + /// this instance. + /// The + /// object at the specified index. + public MetadataModel this[int index] + { + get + { + if (index < 0 || index >= data.Count) + { + throw new ArgumentOutOfRangeException("index"); + } + return (hideEmptyModels && !data[index].Exists) ? null : data[index]; + } + } + + /// + /// Returns a list of all visible + /// MetadataModels. + /// + public List List + { + get + { + if (hideEmptyModels) + { + List result = new List(); + for (int i = 0; i < data.Count; i++) + { + if (data[i].Exists) + { + result.Add(data[i]); + } + } + return result; + } + else + { + return data; + } + } + } + + /// + /// Adds new tag to the bitmap or updates its value in case it already exists. + /// will be used as key. + /// + /// The tag to add or update. + /// Returns true on success, false on failure. + /// + /// is null. + public bool AddTag(MetadataTag tag) + { + for (int i = 0; i < data.Count; i++) + { + if (tag.Model == data[i].Model) + { + return data[i].AddTag(tag); + } + } + return false; + } + + /// + /// Returns the number of visible + /// MetadataModels. + /// + public int Count + { + get + { + if (hideEmptyModels) + { + int count = 0; + for (int i = 0; i < data.Count; i++) + { + if (data[i].Exists) + { + count++; + } + } + return count; + } + else + { + return data.Count; + } + } + } + + /// + /// Gets or sets whether empty + /// MetadataModels are hidden. + /// + public bool HideEmptyModels + { + get + { + return hideEmptyModels; + } + set + { + hideEmptyModels = value; + } + } + + /// + /// Retrieves an object that can iterate through the individual + /// MetadataModels + /// in this . + /// + /// An for this . + public IEnumerator GetEnumerator() + { + if (hideEmptyModels) + { + List tempList = new List(data.Count); + for (int i = 0; i < data.Count; i++) + { + if (data[i].Exists) + { + tempList.Add(data[i]); + } + } + return tempList.GetEnumerator(); + } + else + { + return data.GetEnumerator(); + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is ImageMetadata)) + { + throw new ArgumentException("obj"); + } + return CompareTo((ImageMetadata)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(ImageMetadata other) + { + return this.dib.CompareTo(other.dib); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/LocalPlugin.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/LocalPlugin.cs new file mode 100644 index 0000000..4c6bbe8 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/LocalPlugin.cs @@ -0,0 +1,466 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.9 $ +// $Date: 2009/09/15 11:47:46 $ +// $Id: LocalPlugin.cs,v 1.9 2009/09/15 11:47:46 cklein05 Exp $ +// ========================================================== + +using System; +using System.IO; +using System.Runtime.InteropServices; +using FreeImageAPI.IO; +using System.Diagnostics; + +namespace FreeImageAPI.Plugins +{ + /// + /// Class representing own FreeImage-Plugins. + /// + /// + /// FreeImages itself is plugin based. Each supported format is integrated by a seperat plugin, + /// that handles loading, saving, descriptions, identifing ect. + /// And of course the user can create own plugins and use them in FreeImage. + /// To do that the above mentioned predefined methodes need to be implemented. + /// + /// The class below handles the creation of such a plugin. The class itself is abstract + /// as well as some core functions that need to be implemented. + /// The class can be used to enable or disable the plugin in FreeImage after regististration or + /// retrieve the formatid, assigned by FreeImage. + /// The class handles the callback functions, garbage collector and pointer operation to make + /// the implementation as user friendly as possible. + /// + /// How to: + /// There are two functions that need to be implemented: + /// and + /// . + /// is used by the constructor + /// of the abstract class. FreeImage wants a list of the implemented functions. Each function is + /// represented by a function pointer (a .NET ). In case a function + /// is not implemented FreeImage receives an empty delegate). To tell the constructor + /// which functions have been implemented the information is represented by a disjunction of + /// . + /// + /// For example: + /// return MethodFlags.LoadProc | MethodFlags.SaveProc; + /// + /// The above statement means that LoadProc and SaveProc have been implemented by the user. + /// Keep in mind, that each function has a standard implementation that has static return + /// values that may cause errors if listed in + /// without a real implementation. + /// + /// is used by some checks of FreeImage and + /// must be implemented. for example can be + /// implemented if the plugin supports reading, but it doesn't have to, the plugin could only + /// be used to save an already loaded bitmap in a special format. + /// + public abstract class LocalPlugin + { + /// + /// Struct containing function pointers. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private Plugin plugin; + + /// + /// Delegate for register callback by FreeImage. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private InitProc initProc; + + /// + /// The format id assiged to the plugin. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + + /// + /// When true the plugin was registered successfully else false. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected readonly bool registered = false; + + /// + /// A copy of the functions used to register. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected readonly MethodFlags implementedMethods; + + /// + /// MethodFlags defines values to fill a bitfield telling which + /// functions have been implemented by a plugin. + /// + [Flags] + protected enum MethodFlags + { + /// + /// No mothods implemented. + /// + None = 0x0, + + /// + /// DescriptionProc has been implemented. + /// + DescriptionProc = 0x1, + + /// + /// ExtensionListProc has been implemented. + /// + ExtensionListProc = 0x2, + + /// + /// RegExprProc has been implemented. + /// + RegExprProc = 0x4, + + /// + /// OpenProc has been implemented. + /// + OpenProc = 0x8, + + /// + /// CloseProc has been implemented. + /// + CloseProc = 0x10, + + /// + /// PageCountProc has been implemented. + /// + PageCountProc = 0x20, + + /// + /// PageCapabilityProc has been implemented. + /// + PageCapabilityProc = 0x40, + + /// + /// LoadProc has been implemented. + /// + LoadProc = 0x80, + + /// + /// SaveProc has been implemented. + /// + SaveProc = 0x100, + + /// + /// ValidateProc has been implemented. + /// + ValidateProc = 0x200, + + /// + /// MimeProc has been implemented. + /// + MimeProc = 0x400, + + /// + /// SupportsExportBPPProc has been implemented. + /// + SupportsExportBPPProc = 0x800, + + /// + /// SupportsExportTypeProc has been implemented. + /// + SupportsExportTypeProc = 0x1000, + + /// + /// SupportsICCProfilesProc has been implemented. + /// + SupportsICCProfilesProc = 0x2000 + } + + // Functions that must be implemented. + + /// + /// Function that returns a bitfield containing the + /// implemented methods. + /// + /// Bitfield of the implemented methods. + protected abstract MethodFlags GetImplementedMethods(); + + /// + /// Implementation of FormatProc + /// + /// A string containing the plugins format. + protected abstract string FormatProc(); + + // Functions that can be implemented. + + /// + /// Function that can be implemented. + /// + protected virtual string DescriptionProc() { return ""; } + /// + /// Function that can be implemented. + /// + protected virtual string ExtensionListProc() { return ""; } + /// + /// Function that can be implemented. + /// + protected virtual string RegExprProc() { return ""; } + /// + /// Function that can be implemented. + /// + protected virtual IntPtr OpenProc(ref FreeImageIO io, fi_handle handle, bool read) { return IntPtr.Zero; } + /// + /// Function that can be implemented. + /// + protected virtual void CloseProc(ref FreeImageIO io, fi_handle handle, IntPtr data) { } + /// + /// Function that can be implemented. + /// + protected virtual int PageCountProc(ref FreeImageIO io, fi_handle handle, IntPtr data) { return 0; } + /// + /// Function that can be implemented. + /// + protected virtual int PageCapabilityProc(ref FreeImageIO io, fi_handle handle, IntPtr data) { return 0; } + /// + /// Function that can be implemented. + /// + protected virtual FIBITMAP LoadProc(ref FreeImageIO io, fi_handle handle, int page, int flags, IntPtr data) { return FIBITMAP.Zero; } + /// + /// Function that can be implemented. + /// + protected virtual bool SaveProc(ref FreeImageIO io, FIBITMAP dib, fi_handle handle, int page, int flags, IntPtr data) { return false; } + /// + /// Function that can be implemented. + /// + protected virtual bool ValidateProc(ref FreeImageIO io, fi_handle handle) { return false; } + /// + /// Function that can be implemented. + /// + protected virtual string MimeProc() { return ""; } + /// + /// Function that can be implemented. + /// + protected virtual bool SupportsExportBPPProc(int bpp) { return false; } + /// + /// Function that can be implemented. + /// + protected virtual bool SupportsExportTypeProc(FREE_IMAGE_TYPE type) { return false; } + /// + /// Function that can be implemented. + /// + protected virtual bool SupportsICCProfilesProc() { return false; } + + /// + /// The constructor automatically registeres the plugin in FreeImage. + /// To do this it prepares a FreeImage defined structure with function pointers + /// to the implemented functions or null if not implemented. + /// Before registing the functions they are pinned in memory so the garbage collector + /// can't move them around in memory after we passed there addresses to FreeImage. + /// + public LocalPlugin() + { + implementedMethods = GetImplementedMethods(); + + if ((implementedMethods & MethodFlags.DescriptionProc) != 0) + { + plugin.descriptionProc = new DescriptionProc(DescriptionProc); + } + if ((implementedMethods & MethodFlags.ExtensionListProc) != 0) + { + plugin.extensionListProc = new ExtensionListProc(ExtensionListProc); + } + if ((implementedMethods & MethodFlags.RegExprProc) != 0) + { + plugin.regExprProc = new RegExprProc(RegExprProc); + } + if ((implementedMethods & MethodFlags.OpenProc) != 0) + { + plugin.openProc = new OpenProc(OpenProc); + } + if ((implementedMethods & MethodFlags.CloseProc) != 0) + { + plugin.closeProc = new CloseProc(CloseProc); + } + if ((implementedMethods & MethodFlags.PageCountProc) != 0) + { + plugin.pageCountProc = new PageCountProc(PageCountProc); + } + if ((implementedMethods & MethodFlags.PageCapabilityProc) != 0) + { + plugin.pageCapabilityProc = new PageCapabilityProc(PageCapabilityProc); + } + if ((implementedMethods & MethodFlags.LoadProc) != 0) + { + plugin.loadProc = new LoadProc(LoadProc); + } + if ((implementedMethods & MethodFlags.SaveProc) != 0) + { + plugin.saveProc = new SaveProc(SaveProc); + } + if ((implementedMethods & MethodFlags.ValidateProc) != 0) + { + plugin.validateProc = new ValidateProc(ValidateProc); + } + if ((implementedMethods & MethodFlags.MimeProc) != 0) + { + plugin.mimeProc = new MimeProc(MimeProc); + } + if ((implementedMethods & MethodFlags.SupportsExportBPPProc) != 0) + { + plugin.supportsExportBPPProc = new SupportsExportBPPProc(SupportsExportBPPProc); + } + if ((implementedMethods & MethodFlags.SupportsExportTypeProc) != 0) + { + plugin.supportsExportTypeProc = new SupportsExportTypeProc(SupportsExportTypeProc); + } + if ((implementedMethods & MethodFlags.SupportsICCProfilesProc) != 0) + { + plugin.supportsICCProfilesProc = new SupportsICCProfilesProc(SupportsICCProfilesProc); + } + + // FormatProc is always implemented + plugin.formatProc = new FormatProc(FormatProc); + + // InitProc is the register call back. + initProc = new InitProc(RegisterProc); + + // Register the plugin. The result will be saved and can be accessed later. + registered = FreeImage.RegisterLocalPlugin(initProc, null, null, null, null) != FREE_IMAGE_FORMAT.FIF_UNKNOWN; + if (registered) + { + PluginRepository.RegisterLocalPlugin(this); + } + } + + private void RegisterProc(ref Plugin plugin, int format_id) + { + // Copy the function pointers + plugin = this.plugin; + // Retrieve the format if assigned to this plugin by FreeImage. + format = (FREE_IMAGE_FORMAT)format_id; + } + + /// + /// Gets or sets if the plugin is enabled. + /// + public bool Enabled + { + get + { + if (registered) + { + return (FreeImage.IsPluginEnabled(format) > 0); + } + else + { + throw new ObjectDisposedException("plugin not registered"); + } + } + set + { + if (registered) + { + FreeImage.SetPluginEnabled(format, value); + } + else + { + throw new ObjectDisposedException("plugin not registered"); + } + } + } + + /// + /// Gets if the plugin was registered successfully. + /// + public bool Registered + { + get { return registered; } + } + + /// + /// Gets the FreeImage assigned to this plugin. + /// + public FREE_IMAGE_FORMAT Format + { + get + { + return format; + } + } + + /// + /// Reads from an unmanaged stream. + /// + protected unsafe int Read(FreeImageIO io, fi_handle handle, uint size, uint count, ref byte[] buffer) + { + fixed (byte* ptr = buffer) + { + return (int)io.readProc(new IntPtr(ptr), size, count, handle); + } + } + + /// + /// Reads a single byte from an unmanaged stream. + /// + protected unsafe int ReadByte(FreeImageIO io, fi_handle handle) + { + byte buffer = 0; + return (int)io.readProc(new IntPtr(&buffer), 1, 1, handle) > 0 ? buffer : -1; + } + + /// + /// Writes to an unmanaged stream. + /// + protected unsafe int Write(FreeImageIO io, fi_handle handle, uint size, uint count, ref byte[] buffer) + { + fixed (byte* ptr = buffer) + { + return (int)io.writeProc(new IntPtr(ptr), size, count, handle); + } + } + + /// + /// Writes a single byte to an unmanaged stream. + /// + protected unsafe int WriteByte(FreeImageIO io, fi_handle handle, byte value) + { + return (int)io.writeProc(new IntPtr(&value), 1, 1, handle); + } + + /// + /// Seeks in an unmanaged stream. + /// + protected int Seek(FreeImageIO io, fi_handle handle, int offset, SeekOrigin origin) + { + return io.seekProc(handle, offset, origin); + } + + /// + /// Retrieves the position of an unmanaged stream. + /// + protected int Tell(FreeImageIO io, fi_handle handle) + { + return io.tellProc(handle); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MemoryArray.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MemoryArray.cs new file mode 100644 index 0000000..a1ff887 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MemoryArray.cs @@ -0,0 +1,828 @@ +using System; +using System.Runtime.InteropServices; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; + +namespace FreeImageAPI +{ + /// + /// Represents unmanaged memory, containing an array of a given structure. + /// + /// Structuretype represented by the instance. + /// + /// and can not be marshalled. + /// + /// Use instead of and + /// instead of . + /// + public unsafe class MemoryArray : IDisposable, ICloneable, ICollection, IEnumerable, IEquatable> where T : struct + { + /// + /// Baseaddress of the wrapped memory. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected byte* baseAddress; + + /// + /// Number of elements being wrapped. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected int length; + + /// + /// Size, in bytes, of each element. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly int size; + + /// + /// Array of T containing a single element. + /// The array is used as a workaround, because there are no pointer for generic types. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected T[] buffer; + + /// + /// Pointer to the element of buffer. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected byte* ptr; + + /// + /// Handle for pinning buffer. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected GCHandle handle; + + /// + /// Indicates whether the wrapped memory is handled like a bitfield. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected readonly bool isOneBit; + + /// + /// Indicates whther the wrapped memory is handles like 4-bit blocks. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected readonly bool isFourBit; + + /// + /// An object that can be used to synchronize access to the . + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected object syncRoot = null; + + static MemoryArray() + { + T[] dummy = new T[2]; + long marshalledSize = Marshal.SizeOf(typeof(T)); + long structureSize = + Marshal.UnsafeAddrOfPinnedArrayElement(dummy, 1).ToInt64() - + Marshal.UnsafeAddrOfPinnedArrayElement(dummy, 0).ToInt64(); + if (marshalledSize != structureSize) + { + throw new NotSupportedException( + "The desired type can not be handled, " + + "because its managed and unmanaged size in bytes are different."); + } + + size = (int)marshalledSize; + } + + /// + /// Initializes a new instance. + /// + protected MemoryArray() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Address of the memory block. + /// Length of the array. + /// + /// is null. + /// + /// is less or equal zero. + /// + /// The type is not supported. + public MemoryArray(IntPtr baseAddress, int length) + : this(baseAddress.ToPointer(), length) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Address of the memory block. + /// Length of the array. + /// + /// is null. + /// + /// is less or equal zero. + /// + /// The type is not supported. + public MemoryArray(void* baseAddress, int length) + { + if (typeof(T) == typeof(FI1BIT)) + { + isOneBit = true; + } + else if (typeof(T) == typeof(FI4BIT)) + { + isFourBit = true; + } + + if (baseAddress == null) + { + throw new ArgumentNullException("baseAddress"); + } + if (length < 1) + { + throw new ArgumentOutOfRangeException("length"); + } + + this.baseAddress = (byte*)baseAddress; + this.length = (int)length; + + if (!isOneBit && !isFourBit) + { + // Create an array containing a single element. + // Due to the fact, that it's not possible to create pointers + // of generic types, an array is used to obtain the memory + // address of an element of T. + this.buffer = new T[1]; + // The array is pinned immediately to prevent the GC from + // moving it to a different position in memory. + this.handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + // The array and its content have beed pinned, so that its address + // can be safely requested and stored for the whole lifetime + // of the instace. + this.ptr = (byte*)handle.AddrOfPinnedObject(); + } + } + + /// + /// Frees the allocated . + /// + ~MemoryArray() + { + Dispose(false); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(MemoryArray left, MemoryArray right) + { + if (object.ReferenceEquals(left, right)) + { + return true; + } + if (object.ReferenceEquals(right, null) || + object.ReferenceEquals(left, null) || + (left.length != right.length)) + { + return false; + } + if (left.baseAddress == right.baseAddress) + { + return true; + } + return FreeImage.CompareMemory(left.baseAddress, right.baseAddress, (uint)left.length); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(MemoryArray left, MemoryArray right) + { + return (!(left == right)); + } + + /// + /// Gets the value at the specified position. + /// + /// A 32-bit integer that represents the position + /// of the array element to get. + /// The value at the specified position. + /// + /// is outside the range of valid indexes + /// for the unmanaged array. + public T GetValue(int index) + { + if ((index >= this.length) || (index < 0)) + { + throw new ArgumentOutOfRangeException("index"); + } + + return GetValueInternal(index); + } + + private T GetValueInternal(int index) + { + EnsureNotDisposed(); + if (isOneBit) + { + return (T)(object)(FI1BIT)(((baseAddress[index / 8] & ((1 << (7 - (index % 8))))) == 0) ? 0 : 1); + } + else if (isFourBit) + { + return (T)(object)(FI4BIT)(((index % 2) == 0) ? (baseAddress[index / 2] >> 4) : (baseAddress[index / 2] & 0x0F)); + } + else + { + CopyMemory(ptr, baseAddress + (index * size), size); + return buffer[0]; + } + } + + /// + /// Sets a value to the element at the specified position. + /// + /// The new value for the specified element. + /// A 32-bit integer that represents the + /// position of the array element to set. + /// + /// is outside the range of valid indexes + /// for the unmanaged array. + public void SetValue(T value, int index) + { + if ((index >= this.length) || (index < 0)) + { + throw new ArgumentOutOfRangeException("index"); + } + SetValueInternal(value, index); + } + + private void SetValueInternal(T value, int index) + { + EnsureNotDisposed(); + if (isOneBit) + { + if ((FI1BIT)(object)value != 0) + { + baseAddress[index / 8] |= (byte)(1 << (7 - (index % 8))); + } + else + { + baseAddress[index / 8] &= (byte)(~(1 << (7 - (index % 8)))); + } + } + else if (isFourBit) + { + if ((index % 2) == 0) + { + baseAddress[index / 2] = (byte)((baseAddress[index / 2] & 0x0F) | ((FI4BIT)(object)value << 4)); + } + else + { + baseAddress[index / 2] = (byte)((baseAddress[index / 2] & 0xF0) | ((FI4BIT)(object)value & 0x0F)); + } + } + else + { + buffer[0] = value; + CopyMemory(baseAddress + (index * size), ptr, size); + } + } + + /// + /// Gets the values at the specified position and length. + /// + /// A 32-bit integer that represents the position + /// of the array elements to get. + /// A 32-bit integer that represents the length + /// of the array elements to get. + /// The values at the specified position and length. + /// + /// is outside the range of valid indexes + /// for the unmanaged array or is greater than the number of elements + /// from to the end of the unmanaged array. + public T[] GetValues(int index, int length) + { + EnsureNotDisposed(); + if ((index >= this.length) || (index < 0)) + { + throw new ArgumentOutOfRangeException("index"); + } + if (((index + length) > this.length) || (length < 1)) + { + throw new ArgumentOutOfRangeException("length"); + } + + T[] data = new T[length]; + if (isOneBit || isFourBit) + { + for (int i = 0; i < length; i++) + { + data[i] = GetValueInternal(i); + } + } + else + { + GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); + byte* dst = (byte*)Marshal.UnsafeAddrOfPinnedArrayElement(data, 0); + CopyMemory(dst, baseAddress + (size * index), size * length); + handle.Free(); + } + return data; + } + + /// + /// Sets the values at the specified position. + /// + /// An array containing the new values for the specified elements. + /// A 32-bit integer that represents the position + /// of the array elements to set. + /// + /// is a null reference (Nothing in Visual Basic). + /// + /// is outside the range of valid indexes + /// for the unmanaged array or is greater than the number of elements + /// from to the end of the array. + public void SetValues(T[] values, int index) + { + EnsureNotDisposed(); + if (values == null) + { + throw new ArgumentNullException("values"); + } + if ((index >= this.length) || (index < 0)) + { + throw new ArgumentOutOfRangeException("index"); + } + if ((index + values.Length) > this.length) + { + throw new ArgumentOutOfRangeException("values.Length"); + } + + if (isOneBit || isFourBit) + { + for (int i = 0; i != values.Length; ) + { + SetValueInternal(values[i++], index++); + } + } + else + { + GCHandle handle = GCHandle.Alloc(values, GCHandleType.Pinned); + byte* src = (byte*)Marshal.UnsafeAddrOfPinnedArrayElement(values, 0); + CopyMemory(baseAddress + (index * size), src, size * length); + handle.Free(); + } + } + + /// + /// Copies the entire array to a compatible one-dimensional , + /// starting at the specified index of the target array. + /// + /// The one-dimensional that is the destination + /// of the elements copied from . + /// The must have zero-based indexing. + /// The zero-based index in + /// at which copying begins. + public void CopyTo(Array array, int index) + { + EnsureNotDisposed(); + if (!(array is T[])) + { + throw new InvalidCastException("array"); + } + try + { + CopyTo((T[])array, 0, index, length); + } + catch (ArgumentOutOfRangeException ex) + { + throw new ArgumentException(ex.Message, ex); + } + } + + /// + /// Copies a range of elements from the unmanaged array starting at the specified + /// and pastes them to + /// starting at the specified . + /// The length and the indexes are specified as 32-bit integers. + /// + /// The array that receives the data. + /// A 32-bit integer that represents the index + /// in the unmanaged array at which copying begins. + /// A 32-bit integer that represents the index in + /// the destination array at which storing begins. + /// A 32-bit integer that represents the number of elements to copy. + /// + /// is a null reference (Nothing in Visual Basic). + /// + /// is outside the range of valid indexes + /// for the unmanaged array or is greater than the number of elements + /// from to the end of the unmanaged array + /// -or- + /// is outside the range of valid indexes + /// for the array or is greater than the number of elements + /// from to the end of the array. + /// + public void CopyTo(T[] array, int sourceIndex, int destinationIndex, int length) + { + EnsureNotDisposed(); + if (array == null) + { + throw new ArgumentNullException("array"); + } + if ((sourceIndex >= this.length) || (sourceIndex < 0)) + { + throw new ArgumentOutOfRangeException("sourceIndex"); + } + if ((destinationIndex >= array.Length) || (destinationIndex < 0)) + { + throw new ArgumentOutOfRangeException("destinationIndex"); + } + if ((sourceIndex + length > this.length) || + (destinationIndex + length > array.Length) || + (length < 1)) + { + throw new ArgumentOutOfRangeException("length"); + } + + if (isOneBit || isFourBit) + { + for (int i = 0; i != length; i++) + { + array[destinationIndex++] = GetValueInternal(sourceIndex++); + } + } + else + { + GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned); + byte* dst = (byte*)Marshal.UnsafeAddrOfPinnedArrayElement(array, destinationIndex); + CopyMemory(dst, baseAddress + (size * sourceIndex), size * length); + handle.Free(); + } + } + + /// + /// Copies a range of elements from the array starting at the specified + /// and pastes them to the unmanaged array + /// starting at the specified . + /// The length and the indexes are specified as 32-bit integers. + /// + /// The array that holds the data. + /// A 32-bit integer that represents the index + /// in the array at which copying begins. + /// A 32-bit integer that represents the index in + /// the unmanaged array at which storing begins. + /// A 32-bit integer that represents the number of elements to copy. + /// + /// is a null reference (Nothing in Visual Basic). + /// + /// is outside the range of valid indexes + /// for the array or is greater than the number of elements + /// from to the end of the array + /// -or- + /// is outside the range of valid indexes + /// for the unmanaged array or is greater than the number of elements + /// from to the end of the unmanaged array. + /// + public void CopyFrom(T[] array, int sourceIndex, int destinationIndex, int length) + { + EnsureNotDisposed(); + if (array == null) + { + throw new ArgumentNullException("array"); + } + if ((destinationIndex >= this.length) || (destinationIndex < 0)) + { + throw new ArgumentOutOfRangeException("destinationIndex"); + } + if ((sourceIndex >= array.Length) || (sourceIndex < 0)) + { + throw new ArgumentOutOfRangeException("sourceIndex"); + } + if ((destinationIndex + length > this.length) || + (sourceIndex + length > array.Length) || + (length < 1)) + { + throw new ArgumentOutOfRangeException("length"); + } + + if (isOneBit || isFourBit) + { + for (int i = 0; i != length; i++) + { + SetValueInternal(array[sourceIndex++], destinationIndex++); + } + } + else + { + GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned); + byte* src = (byte*)Marshal.UnsafeAddrOfPinnedArrayElement(array, sourceIndex); + CopyMemory(baseAddress + (size * destinationIndex), src, size * length); + handle.Free(); + } + } + + /// + /// Returns the represented block of memory as an array of . + /// + /// The represented block of memory. + public byte[] ToByteArray() + { + EnsureNotDisposed(); + byte[] result; + if (isOneBit) + { + result = new byte[(length + 7) / 8]; + } + else if (isFourBit) + { + result = new byte[(length + 3) / 4]; + } + else + { + result = new byte[size * length]; + } + fixed (byte* dst = result) + { + CopyMemory(dst, baseAddress, result.Length); + } + return result; + } + + /// + /// Gets or sets the value at the specified position in the array. + /// + /// A 32-bit integer that represents the position + /// of the array element to get. + /// The value at the specified position in the array. + /// + /// is outside the range of valid indexes + /// for the unmanaged array. + public T this[int index] + { + get + { + return GetValue(index); + } + set + { + SetValue(value, index); + } + } + + /// + /// Gets or sets the values of the unmanaged array. + /// + public T[] Data + { + get + { + return GetValues(0, length); + } + set + { + if (value == null) + { + throw new ArgumentNullException("value"); + } + if (value.Length != length) + { + throw new ArgumentOutOfRangeException("value.Lengt"); + } + SetValues(value, 0); + } + } + + /// + /// Gets the length of the unmanaged array. + /// + public int Length + { + get + { + EnsureNotDisposed(); + return length; + } + } + + /// + /// Gets the base address of the represented memory block. + /// + public IntPtr BaseAddress + { + get + { + EnsureNotDisposed(); + return new IntPtr(baseAddress); + } + } + + /// + /// Creates a shallow copy of the . + /// + /// A shallow copy of the . + public object Clone() + { + EnsureNotDisposed(); + return new MemoryArray(baseAddress, length); + } + + /// + /// Gets a 32-bit integer that represents the total number of elements + /// in the . + /// + public int Count + { + get { EnsureNotDisposed(); return length; } + } + + /// + /// Gets a value indicating whether access to the + /// is synchronized (thread safe). + /// + public bool IsSynchronized + { + get { EnsureNotDisposed(); return false; } + } + + /// + /// Gets an object that can be used to synchronize access to the . + /// + public object SyncRoot + { + get + { + EnsureNotDisposed(); + if (syncRoot == null) + { + System.Threading.Interlocked.CompareExchange(ref syncRoot, new object(), null); + } + return syncRoot; + } + } + + /// + /// Retrieves an object that can iterate through the individual + /// elements in this . + /// + /// An for the . + public IEnumerator GetEnumerator() + { + EnsureNotDisposed(); + T[] values = GetValues(0, length); + for (int i = 0; i != values.Length; i++) + { + yield return values[i]; + } + } + + /// + /// Retrieves an object that can iterate through the individual + /// elements in this . + /// + /// An for the . + IEnumerator IEnumerable.GetEnumerator() + { + EnsureNotDisposed(); + T[] values = GetValues(0, length); + for (int i = 0; i != values.Length; i++) + { + yield return values[i]; + } + } + + /// + /// Releases all ressources. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases allocated handles associated with this instance. + /// + /// true to release managed resources. + protected virtual void Dispose(bool disposing) + { + if (baseAddress != null) + { + if (handle.IsAllocated) + handle.Free(); + baseAddress = null; + buffer = null; + length = 0; + syncRoot = null; + } + } + + /// + /// Throws an if + /// this instance is disposed. + /// + protected virtual void EnsureNotDisposed() + { + if (baseAddress == null) + throw new ObjectDisposedException("This instance is disposed."); + } + + /// + /// Tests whether the specified structure is equivalent to this + /// structure. + /// + /// The structure to test. + /// true if is a + /// instance equivalent to this structure; otherwise, + /// false. + public override bool Equals(object obj) + { + EnsureNotDisposed(); + return ((obj is MemoryArray) && Equals((MemoryArray)obj)); + } + + /// + /// Tests whether the specified structure is equivalent to this + /// structure. + /// + /// The structure to test. + /// true if is equivalent to this + /// structure; otherwise, + /// false. + public bool Equals(MemoryArray other) + { + EnsureNotDisposed(); + return ((this.baseAddress == other.baseAddress) && (this.length == other.length)); + } + + /// + /// Serves as a hash function for a particular type. + /// + /// A hash code for the current . + public override int GetHashCode() + { + EnsureNotDisposed(); + return (int)baseAddress ^ length; + } + + /// + /// Copies a block of memory from one location to another. + /// + /// Pointer to the starting address of the copy destination. + /// Pointer to the starting address of the block of memory to be copied. + /// Size of the block of memory to copy, in bytes. + protected static unsafe void CopyMemory(byte* dest, byte* src, int len) + { + if (len >= 0x10) + { + do + { + *((int*)dest) = *((int*)src); + *((int*)(dest + 4)) = *((int*)(src + 4)); + *((int*)(dest + 8)) = *((int*)(src + 8)); + *((int*)(dest + 12)) = *((int*)(src + 12)); + dest += 0x10; + src += 0x10; + } + while ((len -= 0x10) >= 0x10); + } + if (len > 0) + { + if ((len & 8) != 0) + { + *((int*)dest) = *((int*)src); + *((int*)(dest + 4)) = *((int*)(src + 4)); + dest += 8; + src += 8; + } + if ((len & 4) != 0) + { + *((int*)dest) = *((int*)src); + dest += 4; + src += 4; + } + if ((len & 2) != 0) + { + *((short*)dest) = *((short*)src); + dest += 2; + src += 2; + } + if ((len & 1) != 0) + { + *dest = *src; + } + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MetadataModel.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MetadataModel.cs new file mode 100644 index 0000000..c7ad248 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MetadataModel.cs @@ -0,0 +1,941 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.8 $ +// $Date: 2009/02/27 16:34:31 $ +// $Id: MetadataModel.cs,v 1.8 2009/02/27 16:34:31 cklein05 Exp $ +// ========================================================== + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System.Diagnostics; + +namespace FreeImageAPI.Metadata +{ + /// + /// Base class that represents a collection of all tags contained in a metadata model. + /// + /// + /// The MetedataModel class is an abstract base class, which is inherited by + /// several derived classes, one for each existing metadata model. + /// + public abstract class MetadataModel : IEnumerable + { + /// + /// Handle to the encapsulated FreeImage-bitmap. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected readonly FIBITMAP dib; + + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + /// + /// is null. + protected MetadataModel(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + this.dib = dib; + } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public abstract FREE_IMAGE_MDMODEL Model + { + get; + } + + /// + /// Adds new tag to the bitmap or updates its value in case it already exists. + /// will be used as key. + /// + /// The tag to add or update. + /// Returns true on success, false on failure. + /// + /// is null. + /// + /// The tags model differs from this instances model. + public bool AddTag(MetadataTag tag) + { + if (tag == null) + { + throw new ArgumentNullException("tag"); + } + if (tag.Model != Model) + { + throw new ArgumentException("tag.Model"); + } + return tag.AddToImage(dib); + } + + /// + /// Adds a list of tags to the bitmap or updates their values in case they already exist. + /// will be used as key. + /// + /// A list of tags to add or update. + /// Returns the number of successfully added tags. + /// + /// is null. + public int AddTag(IEnumerable list) + { + if (list == null) + { + throw new ArgumentNullException("list"); + } + int count = 0; + foreach (MetadataTag tag in list) + { + if (tag.Model == Model && tag.AddToImage(dib)) + { + count++; + } + } + return count; + } + + /// + /// Removes the specified tag from the bitmap. + /// + /// The key of the tag. + /// Returns true on success, false on failure. + /// + /// is null. + public bool RemoveTag(string key) + { + if (key == null) + { + throw new ArgumentNullException("key"); + } + return FreeImage.SetMetadata(Model, dib, key, FITAG.Zero); + } + + /// + /// Destroys the metadata model + /// which will remove all tags of this model from the bitmap. + /// + /// Returns true on success, false on failure. + public bool DestoryModel() + { + return FreeImage.SetMetadata(Model, dib, null, FITAG.Zero); + } + + /// + /// Returns the specified metadata tag. + /// + /// The key of the tag. + /// The metadata tag. + /// + /// is null. + public MetadataTag GetTag(string key) + { + if (key == null) + { + throw new ArgumentNullException("key"); + } + MetadataTag tag; + return FreeImage.GetMetadata(Model, dib, key, out tag) ? tag : null; + } + + /// + /// Returns whether the specified tag exists. + /// + /// The key of the tag. + /// True in case the tag exists, else false. + /// + /// is null. + public bool TagExists(string key) + { + if (key == null) + { + throw new ArgumentNullException("key"); + } + MetadataTag tag; + return FreeImage.GetMetadata(Model, dib, key, out tag); + } + + /// + /// Returns a list of all metadata tags this instance represents. + /// + public List List + { + get + { + List list = new List((int)FreeImage.GetMetadataCount(Model, dib)); + MetadataTag tag; + FIMETADATA mdHandle = FreeImage.FindFirstMetadata(Model, dib, out tag); + if (!mdHandle.IsNull) + { + do + { + list.Add(tag); + } + while (FreeImage.FindNextMetadata(mdHandle, out tag)); + FreeImage.FindCloseMetadata(mdHandle); + } + return list; + } + } + + /// + /// Returns the tag at the given index. + /// + /// Index of the tag to return. + /// The tag at the given index. + protected MetadataTag GetTagFromIndex(int index) + { + if (index >= Count || index < 0) + { + throw new ArgumentOutOfRangeException("index"); + } + MetadataTag tag; + int count = 0; + FIMETADATA mdHandle = FreeImage.FindFirstMetadata(Model, dib, out tag); + if (!mdHandle.IsNull) + { + try + { + do + { + if (count++ == index) + { + break; + } + } + while (FreeImage.FindNextMetadata(mdHandle, out tag)); + } + finally + { + FreeImage.FindCloseMetadata(mdHandle); + } + } + return tag; + } + + /// + /// Returns the metadata tag at the given index. This operation is slow when accessing all tags. + /// + /// Index of the tag. + /// The metadata tag. + /// + /// is greater or equal Count + /// or index is less than zero. + public MetadataTag this[int index] + { + get + { + return GetTagFromIndex(index); + } + } + + /// + /// Retrieves an object that can iterate through the individual MetadataTags in this MetadataModel. + /// + /// An for the + /// . + public IEnumerator GetEnumerator() + { + return List.GetEnumerator(); + } + + /// + /// Returns the number of metadata tags this instance represents. + /// + public int Count + { + get { return (int)FreeImage.GetMetadataCount(Model, dib); } + } + + /// + /// Returns whether this model exists in the bitmaps metadata structure. + /// + public bool Exists + { + get + { + return Count > 0; + } + } + + /// + /// Searches for a pattern in each metadata tag and returns the result as a list. + /// + /// The regular expression to use for the search. + /// A bitfield that controls which fields should be searched in. + /// A list containing all found metadata tags. + /// + /// is null. + /// + /// is empty. + public List RegexSearch(string searchPattern, MD_SEARCH_FLAGS flags) + { + if (searchPattern == null) + { + throw new ArgumentNullException("searchString"); + } + if (searchPattern.Length == 0) + { + throw new ArgumentException("searchString is empty"); + } + List result = new List(Count); + Regex regex = new Regex(searchPattern); + List list = List; + foreach (MetadataTag tag in list) + { + if (((flags & MD_SEARCH_FLAGS.KEY) > 0) && regex.Match(tag.Key).Success) + { + result.Add(tag); + continue; + } + if (((flags & MD_SEARCH_FLAGS.DESCRIPTION) > 0) && regex.Match(tag.Description).Success) + { + result.Add(tag); + continue; + } + if (((flags & MD_SEARCH_FLAGS.TOSTRING) > 0) && regex.Match(tag.ToString()).Success) + { + result.Add(tag); + continue; + } + } + result.Capacity = result.Count; + return result; + } + + /// + /// Returns the value of the specified tag. + /// + /// Type of the tag's data. + /// The key of the tag. + /// The value of the specified tag. + protected T? GetTagValue(string key) where T : struct + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + MetadataTag tag = GetTag(key); + if (tag != null) + { + T[] value = tag.Value as T[]; + if ((value != null) && (value.Length != 0)) + { + return value[0]; + } + } + return null; + } + + /// + /// Returns an array containing the data of the specified tag. + /// + /// The type of the tag's data. + /// The key of the tag. + /// An array containing the data of the specified tag. + protected T[] GetTagArray(string key) where T : struct + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + MetadataTag tag = GetTag(key); + return (tag == null) ? null : tag.Value as T[]; + } + + /// + /// Returns the string contained by the specified tag. + /// + /// The key of the tag. + /// The string contained by the specified tag. + protected string GetTagText(string key) + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + MetadataTag tag = GetTag(key); + return (tag == null) ? null : tag.Value as string; + } + + /// + /// Returns an array containg the data of the specified tag + /// as unsigned 32bit integer. + /// + /// The key of the tag. + /// An array containg the data of the specified tag + /// as unsigned 32bit integer. + protected uint[] GetUInt32Array(string key) + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + uint[] result = null; + MetadataTag tag = GetTag(key); + if (tag != null) + { + object value = tag.Value; + if (value != null) + { + if (value is ushort[]) + { + ushort[] array = (ushort[])value; + result = new uint[array.Length]; + for (int i = 0, j = array.Length; i < j; i++) + { + result[i] = (uint)array[i]; + } + } + else if (value is uint[]) + { + result = (uint[])value; + } + } + } + return result; + } + + /// + /// Returns the value of the tag as unsigned 32bit integer. + /// + /// The key of the tag. + /// The value of the tag as unsigned 32bit integer. + protected uint? GetUInt32Value(string key) + { + uint[] value = GetUInt32Array(key); + return value == null ? default(uint?) : value[0]; + } + + /// + /// Sets the value of the specified tag. + /// + /// The type of the tag's data. + /// The key of the tag. + /// The new value of the specified tag or null. + protected void SetTagValue(string key, T? value) where T : struct + { + SetTagValue(key, value.HasValue ? new T[] { value.Value } : null); + } + + /// + /// Sets the value of the specified tag. + /// + /// The key of the tag. + /// The new value of the specified tag or null. + protected void SetTagValue(string key, object value) + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + if (value == null) + { + RemoveTag(key); + } + else + { + MetadataTag tag = GetTag(key); + if (tag == null) + { + tag = new MetadataTag(Model); + tag.Key = key; + tag.Value = value; + AddTag(tag); + } + else + { + tag.Value = value; + } + } + } + + /// + /// Sets the value of the specified tag as undefined. + /// + /// The key of the tag. + /// The new value of the specified tag or null. + protected void SetTagValueUndefined(string key, byte[] value) + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + if (value == null) + { + RemoveTag(key); + } + else + { + MetadataTag tag = GetTag(key); + if (tag == null) + { + tag = new MetadataTag(Model); + tag.Key = key; + tag.SetValue(value, FREE_IMAGE_MDTYPE.FIDT_UNDEFINED); + AddTag(tag); + } + else + { + tag.Value = value; + } + } + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The string containing the . + /// The equivalent for the + /// specified . + protected static DirectionReference? ToDirectionType(string s) + { + if (string.IsNullOrEmpty(s)) + return null; + switch (s[0]) + { + case 'T': + return DirectionReference.TrueDirection; + case 'M': + return DirectionReference.MagneticDirection; + default: + return DirectionReference.Undefined; + } + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The to convert. + /// The equivalent for the + /// specified . + protected static string ToString(DirectionReference? type) + { + if (type.HasValue) + { + switch (type.Value) + { + case DirectionReference.TrueDirection: + return "T"; + case DirectionReference.MagneticDirection: + return "M"; + default: + return "\0"; + } + } + return null; + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The string containing the . + /// The equivalent for the + /// specified . + protected static VelocityUnit? ToUnitType(string s) + { + if (string.IsNullOrEmpty(s)) + return null; + switch (s[0]) + { + case 'K': + return VelocityUnit.Kilometers; + case 'M': + return VelocityUnit.Miles; + case 'N': + return VelocityUnit.Knots; + default: + return VelocityUnit.Undefinied; + } + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The to convert. + /// The equivalent for the + /// specified . + protected static string ToString(VelocityUnit? type) + { + if (type.HasValue) + { + switch (type.Value) + { + case VelocityUnit.Kilometers: + return "K"; + case VelocityUnit.Miles: + return "M"; + case VelocityUnit.Knots: + return "N"; + default: + return "\0"; + } + } + return null; + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The string containing the . + /// The equivalent for the + /// specified . + protected static LongitudeType? ToLongitudeType(string s) + { + if (string.IsNullOrEmpty(s)) + return null; + switch (s[0]) + { + case 'E': + return LongitudeType.East; + case 'W': + return LongitudeType.West; + default: + return LongitudeType.Undefined; + } + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The to convert. + /// The equivalent for the + /// specified . + protected static string ToString(LongitudeType? type) + { + if (type.HasValue) + { + switch (type.Value) + { + case LongitudeType.East: + return "E"; + case LongitudeType.West: + return "W"; + default: + return "\0"; + } + } + return null; + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The string containing the . + /// The equivalent for the + /// specified . + protected static LatitudeType? ToLatitudeType(string s) + { + if (string.IsNullOrEmpty(s)) + return null; + switch (s[0]) + { + case 'N': + return LatitudeType.North; + case 'S': + return LatitudeType.South; + default: + return LatitudeType.Undefined; + } + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The to convert. + /// The equivalent for the + /// specified . + protected static string ToString(LatitudeType? type) + { + if (type.HasValue) + { + switch (type.Value) + { + case LatitudeType.North: + return "N"; + case LatitudeType.South: + return "S"; + default: + return "\0"; + } + } + return null; + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The string containing the . + /// The equivalent for the + /// specified . + protected static InteroperabilityMode? ToInteroperabilityType(string s) + { + if (string.IsNullOrEmpty(s)) + return null; + if (s.StartsWith("R98")) + return InteroperabilityMode.R98; + if (s.StartsWith("THM")) + return InteroperabilityMode.THM; + return InteroperabilityMode.Undefined; + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The to convert. + /// The equivalent for the + /// specified . + protected static string ToString(InteroperabilityMode? type) + { + if (type.HasValue) + { + switch (type.Value) + { + case InteroperabilityMode.R98: + return "R98"; + case InteroperabilityMode.THM: + return "THM"; + default: + return "\0\0\0"; + } + } + return null; + } + + /// + /// Specified different unit types. + /// + public enum VelocityUnit + { + /// + /// No or unknown type. + /// + Undefinied, + + /// + /// Kilometers per hour. + /// + Kilometers, + + /// + /// Miles per hour. + /// + Miles, + + /// + /// Knots. + /// + Knots, + } + + /// + /// Specifies different direction types. + /// + public enum DirectionReference + { + /// + /// No or unknown direction type. + /// + Undefined, + + /// + /// True direction. + /// + TrueDirection, + + /// + /// Magnatic direction. + /// + MagneticDirection, + } + + /// + /// Specifies the type of a latitude value. + /// + public enum LatitudeType + { + /// + /// No or unknown type. + /// + Undefined, + + /// + /// North. + /// + North, + + /// + /// South. + /// + South, + } + + /// + /// Specifies the type of a longitude value. + /// + public enum LongitudeType + { + /// + /// No or unknown type. + /// + Undefined, + + /// + /// East. + /// + East, + + /// + /// West. + /// + West, + } + + /// + /// Specifies different altitude types. + /// + public enum AltitudeType + { + /// + /// No or unknown type. + /// + Undefined, + + /// + /// East. + /// + AboveSeaLevel, + + /// + /// West. + /// + BelowSeaLevel, + } + + /// + /// Specifies interoperability types. + /// + public enum InteroperabilityMode + { + /// + /// No or unknown type. + /// + Undefined, + + /// + /// Indicates a file conforming to R98 file specification of Recommended + /// Exif Interoperability Rules (ExifR98) or to DCF basic file stipulated + /// by Design Rule for Camera File System. + /// + R98, + + /// + /// Indicates a file conforming to DCF thumbnail file stipulated by Design + /// rule for Camera File System. + /// + THM, + } + + /// + /// Specifies orientation of images. + /// + public enum ExifImageOrientation : ushort + { + /// + /// Undefinied orientation. + /// + Undefined, + + /// + /// TopLeft. + /// + TopLeft = 1, + + /// + /// TopRight. + /// + TopRight, + + /// + /// BottomRight. + /// + BottomRight, + + /// + /// BottomLeft. + /// + BottomLeft, + + /// + /// LeftTop. + /// + LeftTop, + + /// + /// RightTop. + /// + RightTop, + + /// + /// RightBottom. + /// + RightBottom, + + /// + /// LeftBottom. + /// + LeftBottom, + } + + /// + /// Converts the model of the MetadataModel object to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return Model.ToString(); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MetadataModels.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MetadataModels.cs new file mode 100644 index 0000000..4cd2835 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MetadataModels.cs @@ -0,0 +1,6724 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.6 $ +// $Date: 2009/09/15 11:49:24 $ +// $Id: MetadataModels.cs,v 1.6 2009/09/15 11:49:24 cklein05 Exp $ +// ========================================================== + +using System; +using System.Xml; +using System.IO; +using System.Text; + +namespace FreeImageAPI.Metadata +{ + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_ANIMATION : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_ANIMATION(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_ANIMATION; } + } + + /// + /// Gets or sets the width of the entire canvas area, that each page is displayed in. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? LogicalWidth + { + get + { + return GetTagValue("LogicalWidth"); + } + set + { + SetTagValue("LogicalWidth", value); + } + } + + /// + /// Gets or sets the height of the entire canvas area, that each page is displayed in. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? LogicalHeight + { + get + { + return GetTagValue("LogicalHeight"); + } + set + { + SetTagValue("LogicalHeight", value); + } + } + + /// + /// Gets or sets the global palette of the GIF image. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public Palette GlobalPalette + { + get + { + MetadataTag mdtag = GetTag("GlobalPalette"); + return (mdtag == null) ? null : new Palette(mdtag); + } + set + { + SetTagValue("GlobalPalette", (value != null) ? null : value.Data); + } + } + + /// + /// Gets or sets the number of replays for the animation. + /// Use 0 (zero) to specify an infinte number of replays. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? LoopCount + { + get + { + return GetTagValue("Loop"); + } + set + { + SetTagValue("Loop", value); + } + } + + /// + /// Gets or sets the horizontal offset within the logical canvas area, this frame is to be displayed at. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? FrameLeft + { + get + { + return GetTagValue("FrameLeft"); + } + set + { + SetTagValue("FrameLeft", value); + } + } + + /// + /// Gets or sets the vertical offset within the logical canvas area, this frame is to be displayed at. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? FrameTop + { + get + { + return GetTagValue("FrameTop"); + } + set + { + SetTagValue("FrameTop", value); + } + } + + /// + /// Gets or sets a flag to supress saving the dib's attached palette + /// (making it use the global palette). The local palette is the palette used by a page. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? NoLocalPalette + { + get + { + byte? useGlobalPalette = GetTagValue("NoLocalPalette"); + return useGlobalPalette.HasValue ? (useGlobalPalette.Value != 0) : default(bool?); + } + set + { + byte? val = null; + if (value.HasValue) + { + val = (byte)(value.Value ? 1 : 0); + } + SetTagValue("NoLocalPalette", val); + } + } + + /// + /// Gets or sets a value indicating whether the image is interlaced. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? Interlaced + { + get + { + byte? useGlobalPalette = GetTagValue("Interlaced"); + return useGlobalPalette.HasValue ? (useGlobalPalette.Value != 0) : default(bool?); + } + set + { + byte? val = null; + if (value.HasValue) + { + val = (byte)(value.Value ? 1 : 0); + } + SetTagValue("Interlaced", val); + } + } + + /// + /// Gets or sets the amout of time in milliseconds this frame is to be displayed. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? FrameTime + { + get + { + return GetTagValue("FrameTime"); + } + set + { + SetTagValue("FrameTime", value); + } + } + + /// + /// Gets or sets this frame's disposal method. Generally, this method defines, how to + /// remove or replace a frame when the next frame has to be drawn. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public DisposalMethodType? DisposalMethod + { + get + { + return GetTagValue("DisposalMethod"); + } + set + { + SetTagValue("DisposalMethod", value); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_COMMENTS : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_COMMENTS(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_COMMENTS; } + } + + /// + /// Gets or sets the comment of the image. + /// Supported formats are JPEG, PNG and GIF. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Comment + { + get + { + return GetTagText("Comment"); + } + set + { + SetTagValue("Comment", value); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_CUSTOM : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_CUSTOM(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_CUSTOM; } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_EXIF_EXIF : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_EXIF_EXIF(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF; } + } + + /// + /// Gets or sets the version of this standard supported. + /// Constant length or 4. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] ExifVersion + { + get + { + return GetTagArray("ExifVersion"); + } + set + { + FreeImage.Resize(ref value, 4); + SetTagValueUndefined("ExifVersion", value); + } + } + + /// + /// Gets or sets the Flashpix format version supported by a FPXR file. + /// Constant length or 4. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] FlashpixVersion + { + get + { + return GetTagArray("FlashpixVersion"); + } + set + { + FreeImage.Resize(ref value, 4); + SetTagValueUndefined("FlashpixVersion", value); + } + } + + /// + /// Gets or sets the color space information tag. + /// See remarks for further information. + /// + /// + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 1 + /// sRGB (default) + /// + /// + /// 0xFFFF + /// uncalibrated + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? ColorSpace + { + get + { + return GetTagValue("ColorSpace"); + } + set + { + SetTagValue("ColorSpace", value); + } + } + + /// + /// Gets or sets the valid width of a compressed image. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? PixelXDimension + { + get + { + return GetUInt32Value("PixelXDimension"); + } + set + { + RemoveTag("PixelXDimension"); + if (value.HasValue) + { + SetTagValue("PixelXDimension", value.Value); + } + } + } + + /// + /// Gets or sets the valid height of a compressed image. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? PixelYDimension + { + get + { + return GetUInt32Value("PixelYDimension"); + } + set + { + RemoveTag("PixelYDimension"); + if (value.HasValue) + { + SetTagValue("PixelYDimension", value.Value); + } + } + } + + /// + /// Gets or sets components configuration. See remarks for further information. + /// Constant length of 4. + /// + /// + /// The channels of each component are arranged in order from the 1st component to the 4th. + /// For uncompressed data the data arrangement is given in the PhotometricInterpretation tag. + /// However, since PhotometricInterpretation can only express the order of Y,Cb and Cr, + /// this tag is provided for cases when compressed data uses components other than Y, Cb, + /// and Cr and to enable support of other sequences. + /// Default = 4 5 6 0 (if RGB uncompressed) + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// does not exist + /// + /// + /// 1 + /// Y + /// + /// + /// 2 + /// Cb + /// + /// + /// 3 + /// Cr + /// + /// + /// 4 + /// R + /// + /// + /// 5 + /// R + /// + /// + /// 6 + /// R + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public byte[] ComponentsConfiguration + { + get + { + return GetTagArray("ComponentsConfiguration"); + } + set + { + FreeImage.Resize(ref value, 4); + SetTagValueUndefined("ComponentsConfiguration", value); + } + } + + /// + /// Gets or sets compression mode used for a compressed image is indicated + /// in unit bits per pixel. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? CompressedBitsPerPixel + { + get + { + return GetTagValue("CompressedBitsPerPixel"); + } + set + { + SetTagValue("CompressedBitsPerPixel", value); + } + } + + /// + /// Gets or sets a tag for manufacturers of Exif writers to record any desired information. + /// The contents are up to the manufacturer, but this tag should not be used for any other + /// than its intended purpose. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] MakerNote + { + get + { + return GetTagArray("FlashpixVersion"); + } + set + { + SetTagValueUndefined("FlashpixVersion", value); + } + } + + /// + /// Gets or sets a tag for Exif users to write keywords or comments on the image besides + /// those in ImageDescription, and without the character code limitations of the ImageDescription tag. + /// Minimum length of 8. See remarks for further information. + /// + /// + /// The character code used in the UserComment tag is identified based on an ID code in a fixed 8-byte + /// area at the start of the tag data area. The unused portion of the area is padded with NULL. + /// The ID code for the UserComment area may be a Defined code such as JIS or ASCII, or may be Undefined. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public byte[] UserComment + { + get + { + return GetTagArray("UserComment"); + } + set + { + FreeImage.Resize(ref value, 8, int.MaxValue); + SetTagValueUndefined("UserComment", value); + } + } + + /// + /// Gets or sets the name of an audio file related to the image data. + /// The format is 8.3. + /// Constant length of 12 + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string RelatedSoundFile + { + get + { + string text = GetTagText("RelatedSoundFile"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + FreeImage.Resize(ref value, 12); + value += '\0'; + } + SetTagValue("RelatedSoundFile", value); + } + } + + /// + /// Gets or sets the date and time when the original image data was generated. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public DateTime? DateTimeOriginal + { + get + { + DateTime? result = null; + string text = GetTagText("DateTimeOriginal"); + if (text != null) + { + try + { + result = System.DateTime.ParseExact(text, "yyyy:MM:dd HH:mm:ss\0", null); + } + catch + { + } + } + return result; + } + set + { + string val = null; + if (value.HasValue) + { + try + { + val = value.Value.ToString("yyyy:MM:dd HH:mm:ss\0"); + } + catch + { + } + } + SetTagValue("DateTimeOriginal", val); + } + } + + /// + /// Gets or sets the date and time when the image was stored as digital data. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public DateTime? DateTimeDigitized + { + get + { + DateTime? result = null; + string text = GetTagText("DateTimeDigitized"); + if (text != null) + { + try + { + result = System.DateTime.ParseExact(text, "yyyy:MM:dd HH:mm:ss\0", null); + } + catch + { + } + } + return result; + } + set + { + string val = null; + if (value.HasValue) + { + try + { + val = value.Value.ToString("yyyy:MM:dd HH:mm:ss\0"); + } + catch + { + } + } + SetTagValue("DateTimeDigitized", val); + } + } + + /// + /// Gets or sets a tag used to record fractions of seconds for the DateTime tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SubsecTime + { + get + { + string text = GetTagText("SubsecTime"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("SubsecTime", value); + } + } + + /// + /// Gets or sets a tag used to record fractions of seconds for the DateTimeOriginal tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SubsecTimeOriginal + { + get + { + string text = GetTagText("SubsecTimeOriginal"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("SubsecTimeOriginal", value); + } + } + + /// + /// Gets or sets a tag used to record fractions of seconds for the DateTimeDigitized tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SubsecTimeDigitized + { + get + { + string text = GetTagText("SubsecTimeDigitized"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("SubsecTimeDigitized", value); + } + } + + /// + /// Gets or the exposure time, given in seconds (sec). + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? ExposureTime + { + get + { + return GetTagValue("ExposureTime"); + } + set + { + SetTagValue("ExposureTime", value); + } + } + + /// + /// Gets or the F number. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? FNumber + { + get + { + return GetTagValue("FNumber"); + } + set + { + SetTagValue("FNumber", value); + } + } + + /// + /// Gets or sets the class of the program used by the camera to set exposure when the + /// picture is taken. + /// See remarks for further information. + /// + /// + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// not defined + /// + /// + /// 1 + /// manual + /// + /// + /// 2 + /// normal program + /// + /// + /// 3 + /// aperture priority + /// + /// + /// 4 + /// shutter priority + /// + /// + /// 5 + /// create program + /// + /// + /// 6 + /// action program + /// + /// + /// 7 + /// portrait mode + /// + /// + /// 8 + /// landscape mode + /// + /// + /// others + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? ExposureProgram + { + get + { + return GetTagValue("ExposureProgram"); + } + set + { + SetTagValue("ExposureProgram", value); + } + } + + /// + /// Gets or sets the spectral sensitivity of each channel of the camera used. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SpectralSensitivity + { + get + { + string text = GetTagText("SpectralSensitivity"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("SpectralSensitivity", value); + } + } + + /// + /// Gets or sets the the ISO Speed and ISO Latitude of the camera or input device as + /// specified in ISO 12232. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort[] ISOSpeedRatings + { + get + { + return GetTagArray("ISOSpeedRatings"); + } + set + { + SetTagValue("ISOSpeedRatings", value); + } + } + + /// + /// Gets or sets the Opto-Electric Conversion Function (OECF) specified in ISO 14524. + /// OECF is the relationship between the camera optical input and the image values. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] OECF + { + get + { + return GetTagArray("OECF"); + } + set + { + SetTagValueUndefined("OECF", value); + } + } + + /// + /// Gets or sets the shutter speed. The unit is the APEX (Additive System of Photographic Exposure). + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIRational? ShutterSpeedValue + { + get + { + return GetTagValue("ShutterSpeedValue"); + } + set + { + SetTagValue("ShutterSpeedValue", value); + } + } + + /// + /// Gets or sets the lens aperture. The unit is the APEX value. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? ApertureValue + { + get + { + return GetTagValue("ApertureValue"); + } + set + { + SetTagValue("ApertureValue", value); + } + } + + /// + /// Gets or sets the value of brightness. The unit is the APEX value. + /// Ordinarily it is given in the range of -99.99 to 99.99. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIRational? BrightnessValue + { + get + { + return GetTagValue("BrightnessValue"); + } + set + { + SetTagValue("BrightnessValue", value); + } + } + + /// + /// Gets or sets the exposure bias. The unit is the APEX value. + /// Ordinarily it is given in the range of –99.99 to 99.99. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIRational? ExposureBiasValue + { + get + { + return GetTagValue("ExposureBiasValue"); + } + set + { + SetTagValue("ExposureBiasValue", value); + } + } + + /// + /// Gets or sets the smallest F number of the lens. The unit is the APEX value. + /// Ordinarily it is given in the range of 00.00 to 99.99, + /// but it is not limited to this range. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? MaxApertureValue + { + get + { + return GetTagValue("MaxApertureValue"); + } + set + { + SetTagValue("MaxApertureValue", value); + } + } + + /// + /// Gets or sets distance to the subject, given in meters. + /// Note that if the numerator of the recorded value is FFFFFFFF, infinity shall be indicated; + /// and if the numerator is 0, distance unknown shall be indicated. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? SubjectDistance + { + get + { + return GetTagValue("SubjectDistance"); + } + set + { + SetTagValue("SubjectDistance", value); + } + } + + /// + /// Gets or sets the metering mode. See remarks for further information. + /// + /// + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// unknown + /// + /// + /// 1 + /// average + /// + /// + /// 2 + /// center-weighted-average + /// + /// + /// 3 + /// spot + /// + /// + /// 4 + /// multi-spot + /// + /// + /// 5 + /// pattern + /// + /// + /// 6 + /// partial + /// + /// + /// other + /// reserved + /// + /// + /// 255 + /// other + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? MeteringMode + { + get + { + return GetTagValue("MeteringMode"); + } + set + { + SetTagValue("MeteringMode", value); + } + } + + /// + /// Gets or sets the kind of light source. + /// See remarks for further information. + /// + /// + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// unknown + /// + /// + /// 1 + /// daylight + /// + /// + /// 2 + /// fluorescent + /// + /// + /// 3 + /// tungsten + /// + /// + /// 4 + /// flash + /// + /// + /// 9 + /// fine weather + /// + /// + /// 10 + /// cloudy weather + /// + /// + /// 11 + /// shade + /// + /// + /// 12 + /// daylight fluorecent (D 5700 - 7100K) + /// + /// + /// 13 + /// day white fluorescent (N 4600 - 5400K) + /// + /// + /// 14 + /// cool white fluorescent (W 3900 - 4500K) + /// + /// + /// 15 + /// white fluorescent (WW 3200 - 3700K) + /// + /// + /// 17 + /// standard light A + /// + /// + /// 18 + /// standard light B + /// + /// + /// 19 + /// standard light C + /// + /// + /// 20 + /// D55 + /// + /// + /// 21 + /// D65 + /// + /// + /// 22 + /// D75 + /// + /// + /// 23 + /// D50 + /// + /// + /// 24 + /// ISO studio tungsten + /// + /// + /// 255 + /// other light source + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? LightSource + { + get + { + return GetTagValue("LightSource"); + } + set + { + SetTagValue("LightSource", value); + } + } + + /// + /// Gets or sets a value indicating the status of flash when the image was shot. + /// Bit 0 indicates the flash firing status, bits 1 and 2 indicate the flash return + /// status, bits 3 and 4 indicate the flash mode, bit 5 indicates whether the flash + /// function is present, and bit 6 indicates "red eye" mode. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? Flash + { + get + { + return GetTagValue("Flash"); + } + set + { + SetTagValue("Flash", value); + } + } + + /// + /// Gets or sets a value indicating the location and area of the main subject in + /// the overall scene. Variable length between 2 and 4. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort[] SubjectArea + { + get + { + return GetTagArray("SubjectArea"); + } + set + { + FreeImage.Resize(ref value, 2, 4); + SetTagValue("SubjectArea", value); + } + } + + /// + /// Gets or sets the actual focal length of the lens, in mm. + /// Conversion is not made to the focal length of a 35 mm film camera. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? FocalLength + { + get + { + return GetTagValue("FocalLength"); + } + set + { + SetTagValue("FocalLength", value); + } + } + + /// + /// Gets or sets the strobe energy at the time the image is captured, + /// as measured in Beam Candle Power Seconds (BCPS). + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? FlashEnergy + { + get + { + return GetTagValue("FlashEnergy"); + } + set + { + SetTagValue("FlashEnergy", value); + } + } + + /// + /// Gets or sets the camera or input device spatial frequency table and SFR values + /// in the direction of image width, image height, and diagonal direction, + /// as specified in ISO 12233. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] SpatialFrequencyResponse + { + get + { + return GetTagArray("SpatialFrequencyResponse"); + } + set + { + SetTagValueUndefined("SpatialFrequencyResponse", value); + } + } + + /// + /// Gets or sets the number of pixels in the image width (X) direction per + /// FocalPlaneResolutionUnit on the camera focal plane. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? FocalPlaneXResolution + { + get + { + return GetTagValue("FocalPlaneXResolution"); + } + set + { + SetTagValue("FocalPlaneXResolution", value); + } + } + + /// + /// Gets or sets the number of pixels in the image height (Y) direction per + /// FocalPlaneResolutionUnit on the camera focal plane. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? FocalPlaneYResolution + { + get + { + return GetTagValue("FocalPlaneYResolution"); + } + set + { + SetTagValue("FocalPlaneYResolution", value); + } + } + + /// + /// Gets or sets the unit for measuring FocalPlaneXResolution and FocalPlaneYResolution. + /// This value is the same as the ResolutionUnit. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? FocalPlaneResolutionUnit + { + get + { + return GetTagValue("FocalPlaneResolutionUnit"); + } + set + { + SetTagValue("FocalPlaneResolutionUnit", value); + } + } + + /// + /// Gets or sets the location of the main subject in the scene. + /// The value of this tag represents the pixel at the center of the main subject + /// relative to the left edge, prior to rotation processing as per the Rotation tag. + /// The first value indicates the X column number and second indicates the Y row number. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? SubjectLocation + { + get + { + return GetTagValue("SubjectLocation"); + } + set + { + SetTagValue("SubjectLocation", value); + } + } + + /// + /// Gets or sets the exposure index selected on the camera or input device at the + /// time the image was captured. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? ExposureIndex + { + get + { + return GetTagValue("ExposureIndex"); + } + set + { + SetTagValue("ExposureIndex", value); + } + } + + /// + /// Gets or sets the image sensor type on the camera or input device. + /// See remarks for further information. + /// + /// + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 1 + /// not defined + /// + /// + /// 2 + /// one-chip color area sensor + /// + /// + /// 3 + /// two-chip color area sensor + /// + /// + /// 4 + /// three-chip color area sensor + /// + /// + /// 5 + /// color sequential area sensor + /// + /// + /// 7 + /// trilinear sensor + /// + /// + /// 8 + /// color sequential linear sensor + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? SensingMethod + { + get + { + return GetTagValue("SensingMethod"); + } + set + { + SetTagValue("SensingMethod", value); + } + } + + /// + /// Gets or sets the image source. If a DSC recorded the image, this tag value of this + /// tag always be set to 3, indicating that the image was recorded on a DSC. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte? FileSource + { + get + { + return GetTagValue("FileSource"); + } + set + { + SetTagValueUndefined("FileSource", value.HasValue ? new byte[] { value.Value } : null); + } + } + + /// + /// Gets or sets the type of scene. If a DSC recorded the image, this tag value shall + /// always be set to 1, indicating that the image was directly photographed. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte? SceneType + { + get + { + return GetTagValue("SceneType"); + } + set + { + SetTagValueUndefined("SceneType", value.HasValue ? new byte[] { value.Value } : null); + } + } + + /// + /// Gets or sets the color filter array (CFA) geometric pattern of the image sensor + /// when a one-chip color area sensor is used. It does not apply to all sensing methods. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] CFAPattern + { + get + { + return GetTagArray("CFAPattern"); + } + set + { + SetTagValueUndefined("CFAPattern", value); + } + } + + /// + /// Gets or sets the use of special processing on image data, such as rendering geared to output. + /// When special processing is performed, the reader is expected to disable or minimize any + /// further processing. See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// normal process + /// + /// + /// 1 + /// custom process + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? CustomRendered + { + get + { + return GetTagValue("CustomRendered"); + } + set + { + SetTagValue("CustomRendered", value); + } + } + + /// + /// Gets or sets the exposure mode set when the image was shot. + /// In auto-bracketing mode, the camera shoots a series of frames of the same scene + /// at different exposure settings. See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// auto exposure + /// + /// + /// 1 + /// manual exposure + /// + /// + /// 2 + /// auto bracket + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? ExposureMode + { + get + { + return GetTagValue("ExposureMode"); + } + set + { + SetTagValue("ExposureMode", value); + } + } + + /// + /// Gets or sets the white balance mode set when the image was shot. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// auto white balance + /// + /// + /// 1 + /// manual white balance + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? WhiteBalance + { + get + { + return GetTagValue("WhiteBalance"); + } + set + { + SetTagValue("WhiteBalance", value); + } + } + + /// + /// Gets or sets the digital zoom ratio when the image was shot. + /// If the numerator of the recorded value is 0, this indicates that digital zoom was not used. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? DigitalZoomRatio + { + get + { + return GetTagValue("DigitalZoomRatio"); + } + set + { + SetTagValue("DigitalZoomRatio", value); + } + } + + /// + /// Gets or sets the equivalent focal length assuming a 35mm film camera, in mm. + /// A value of 0 means the focal length is unknown. Note that this tag differs + /// from the FocalLength tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? FocalLengthIn35mmFilm + { + get + { + return GetTagValue("DigitalZoomRatio"); + } + set + { + SetTagValue("DigitalZoomRatio", value); + } + } + + /// + /// Gets or sets the type of scene that was shot. + /// It can also be used to record the mode in which the image was shot. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// standard + /// + /// + /// 1 + /// landscape + /// + /// + /// 2 + /// portrait + /// + /// + /// 3 + /// night scene + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? SceneCaptureType + { + get + { + return GetTagValue("SceneCaptureType"); + } + set + { + SetTagValue("SceneCaptureType", value); + } + } + + /// + /// Gets or sets the degree of overall image gain adjustment. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// none + /// + /// + /// 1 + /// low gain up + /// + /// + /// 2 + /// high gain up + /// + /// + /// 3 + /// low gain down + /// + /// + /// 4 + /// high gain down + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? GainControl + { + get + { + return GetTagValue("GainControl"); + } + set + { + SetTagValue("GainControl", value); + } + } + + /// + /// Gets or sets the direction of contrast processing applied by the camera + /// when the image was shot. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// normal + /// + /// + /// 1 + /// soft + /// + /// + /// 2 + /// hard + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? Contrast + { + get + { + return GetTagValue("Contrast"); + } + set + { + SetTagValue("Contrast", value); + } + } + + /// + /// Gets or sets the direction of saturation processing applied by the camera + /// when the image was shot. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// normal + /// + /// + /// 1 + /// low saturation + /// + /// + /// 2 + /// high saturation + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? Saturation + { + get + { + return GetTagValue("Saturation"); + } + set + { + SetTagValue("Saturation", value); + } + } + + /// + /// Gets or sets the direction of sharpness processing applied by the camera + /// when the image was shot. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// normal + /// + /// + /// 1 + /// soft + /// + /// + /// 2 + /// hard + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? Sharpness + { + get + { + return GetTagValue("Sharpness"); + } + set + { + SetTagValue("Sharpness", value); + } + } + + /// + /// Gets or sets information on the picture-taking conditions of a particular camera model. + /// The tag is used only to indicate the picture-taking conditions in the reader. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] DeviceSettingDescription + { + get + { + return GetTagArray("DeviceSettingDescription"); + } + set + { + SetTagValueUndefined("DeviceSettingDescription", value); + } + } + + /// + /// Gets or sets the distance to the subject. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// unknown + /// + /// + /// 1 + /// macro + /// + /// + /// 2 + /// close view + /// + /// + /// 3 + /// distant view + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? SubjectDistanceRange + { + get + { + return GetTagValue("SubjectDistanceRange"); + } + set + { + SetTagValue("SubjectDistanceRange", value); + } + } + + /// + /// Gets or sets an identifier assigned uniquely to each image. + /// It is recorded as an ASCII string equivalent to hexadecimal notation and 128-bit fixed length. + /// Constant length of 32. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ImageUniqueID + { + get + { + string text = GetTagText("ImageUniqueID"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + FreeImage.Resize(ref value, 32); + value += '\0'; + } + SetTagValue("ImageUniqueID", value); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_EXIF_GPS : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_EXIF_GPS(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_EXIF_GPS; } + } + + /// + /// Gets or sets the GPS version ID. Constant length of 4. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] VersionID + { + get + { + return GetTagArray("GPSVersionID"); + } + set + { + FreeImage.Resize(ref value, 4); + SetTagValue("GPSVersionID", value); + } + } + + /// + /// Gets or sets a value indicating whether the + /// is north or south latitude. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public LatitudeType? LatitudeDirection + { + get + { + return ToLatitudeType(GetTagText("GPSLatitudeRef")); + } + set + { + SetTagValue("GPSLatitudeRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the latitude of the image. The latitude is expressed as three rational + /// values giving the degrees, minutes, and seconds, respectively. Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational[] Latitude + { + get + { + return GetTagArray("GPSLatitude"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("GPSLatitude", value); + } + } + + /// + /// Gets or sets a value indicating whether + /// is east or west longitude. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public LongitudeType? LongitudeDirection + { + get + { + return ToLongitudeType(GetTagText("GPSLongitudeRef")); + } + set + { + SetTagValue("GPSLongitudeRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the longitude of the image. The longitude is expressed as three rational + /// values giving the degrees, minutes, and seconds, respectively. Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational[] Longitude + { + get + { + return GetTagArray("GPSLongitude"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("GPSLongitude", value); + } + } + + /// + /// Gets a value indicating whether is sea level and the altitude + /// is above sea level. If the altitude is below sea level is + /// indicated as an absolute value. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public AltitudeType? AltitudeDirection + { + get + { + byte? flag = GetTagValue("GPSAltitudeRef"); + if (flag.HasValue) + { + switch (flag.Value) + { + case 0: + return AltitudeType.AboveSeaLevel; + case 1: + return AltitudeType.BelowSeaLevel; + default: + return AltitudeType.Undefined; + } + } + return null; + } + set + { + byte? val = null; + if (value.HasValue) + { + switch (value.Value) + { + case AltitudeType.AboveSeaLevel: + val = 0; + break; + + case AltitudeType.BelowSeaLevel: + val = 1; + break; + + default: + val = 2; + break; + } + } + SetTagValue("GPSAltitudeRef", val); + } + } + + /// + /// Gets or sets the altitude based on the reference in . + /// Altitude is expressed as one rational value. The reference unit is meters. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? Altitude + { + get + { + return GetTagValue("GPSAltitude"); + } + set + { + SetTagValue("GPSAltitude", value); + } + } + + /// + /// Gets or sets the sign of the . + /// + /// + /// This is a derived property. There is no metadata tag directly associated + /// with this property value. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public int? AltitudeSign + { + get + { + AltitudeType? seaLevel = AltitudeDirection; + if (seaLevel.HasValue) + { + return (seaLevel.Value == AltitudeType.BelowSeaLevel) ? -1 : 1; + } + return null; + } + set + { + if (value.HasValue) + { + AltitudeDirection = value.Value >= 0 ? AltitudeType.AboveSeaLevel : AltitudeType.BelowSeaLevel; + } + else + { + AltitudeDirection = null; + } + } + } + + /// + /// Gets or sets the signed altitude. + /// Altitude is expressed as one rational value. The reference unit is meters. + /// + /// + /// Altitude is too large to fit into a FIRational. + /// + /// + /// This is a derived property. There is no metadata tag directly associated + /// with this property value. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public FIRational? SignedAltitude + { + get + { + FIRational? result = null; + FIURational? altitude = Altitude; + if (altitude.HasValue) + { + int sign = AltitudeSign ?? 1; + if (((int)altitude.Value.Numerator < 0) || ((int)altitude.Value.Denominator < 0)) + throw new OverflowException(); + result = new FIRational((int)altitude.Value.Numerator * sign, (int)altitude.Value.Denominator); + } + return result; + } + set + { + FIURational? val = null; + if (value.HasValue) + { + if (value.Value < 0) + { + AltitudeSign = -1; + value = -value.Value; + } + else + { + AltitudeSign = 1; + } + val = new FIURational((uint)value.Value.Numerator, (uint)value.Value.Denominator); + } + Altitude = val; + } + } + + + /// + /// Gets or sets the time as UTC (Coordinated Universal Time). Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public TimeSpan? TimeStamp + { + get + { + FIURational[] stamp = GetTagArray("GPSTimeStamp"); + if ((stamp == null) || stamp.Length != 3) + { + return null; + } + else + { + return new TimeSpan((int)stamp[0], (int)stamp[1], (int)stamp[2]); + } + } + set + { + FIURational[] stamp = null; + if (value.HasValue) + { + TimeSpan span = value.Value; + stamp = new FIURational[3]; + stamp[0] = span.Hours; + stamp[1] = span.Minutes; + stamp[2] = span.Seconds; + } + SetTagValue("GPSTimeStamp", stamp); + } + } + + /// + /// Gets or sets the GPS satellites used for measurements. This tag can be used to describe + /// the number of satellites, their ID number, angle of elevation, azimuth, SNR and other + /// information in ASCII notation. The format is not specified. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Satellites + { + get + { + string result = GetTagText("GPSSatellites"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("GPSTimeStamp", value); + } + } + + /// + /// Gets or sets a value indicating the status of the GPS receiver when the image was recorded. + /// true indicates measurement was in progress; + /// false indicates measurement was Interoperability. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? Status + { + get + { + string text = GetTagText("GPSStatus"); + return string.IsNullOrEmpty(text) ? default(bool?) : text[0] == 'A'; + } + set + { + SetTagValue("GPSStatus", value.HasValue ? (value.Value ? "A\0" : "V\0") : null); + } + } + + /// + /// Gets or sets a value indicating the GPS measurement mode. + /// true indicates three-dimensional measurement; + /// false indicated two-dimensional measurement was in progress. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? MeasureMode3D + { + get + { + string text = GetTagText("GPSMeasureMode"); + return string.IsNullOrEmpty(text) ? default(bool?) : text[0] == '3'; + } + set + { + SetTagValue("GPSMeasureMode", value.HasValue ? (value.Value ? "3\0" : "2\0") : null); + } + } + + /// + /// Gets or sets the GPS DOP (data degree of precision). An HDOP value is written during + /// two-dimensional measurement, and PDOP during three-dimensional measurement. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? DOP + { + get + { + return GetTagValue("GPSDOP"); + } + set + { + SetTagValue("GPSDOP", value); + } + } + + /// + /// Gets or sets the unit used to express the GPS receiver of movement. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public VelocityUnit? SpeedUnit + { + get + { + return ToUnitType(GetTagText("GPSSpeedRef")); + } + set + { + SetTagValue("GPSSpeedRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the speed of GPS receiver movement. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational? Speed + { + get + { + return GetTagValue("GPSSpeed"); + } + set + { + SetTagValue("GPSSpeed", value); + } + } + + /// + /// Gets or sets the reference for giving the direction of GPS receiver movement. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public DirectionReference? TrackDirectionReference + { + get + { + return ToDirectionType(GetTagText("GPSTrackRef")); + } + set + { + SetTagValue("GPSTrackRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the direction of GPS receiver movement. + /// The range of values is from 0.00 to 359.99. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational? Track + { + get + { + return GetTagValue("GPSTrack"); + } + set + { + SetTagValue("GPSTrack", value); + } + } + + /// + /// Gets or sets the reference for giving the direction of GPS receiver movement. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public DirectionReference? ImageDirectionReference + { + get + { + return ToDirectionType(GetTagText("GPSImgDirectionRef")); + } + set + { + SetTagValue("GPSImgDirectionRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the direction of the image when it was captured. + /// The range of values is from 0.00 to 359.99. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational? ImageDirection + { + get + { + return GetTagValue("GPSImgDirection"); + } + set + { + SetTagValue("GPSImgDirection", value); + } + } + + /// + /// Gets or sets the geodetic survey data used by the GPS receiver. If the survey data + /// is restricted to Japan, the value of this tag is 'TOKYO' or 'WGS-84'. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string MapDatum + { + get + { + string result = GetTagText("GPSMapDatum"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + SetTagValue("GPSMapDatum", value + '\0'); + } + } + + /// + /// Gets or sets a value indicating whether the destination point + /// is north or south latitude. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public LatitudeType? DestinationLatitudeDirection + { + get + { + return ToLatitudeType(GetTagText("GPSDestLatitudeRef")); + } + set + { + SetTagValue("GPSDestLatitudeRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the latitude of the destination point. The latitude is expressed as three rational + /// values giving the degrees, minutes, and seconds, respectively. Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational[] DestinationLatitude + { + get + { + return GetTagArray("GPSDestLatitude"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("GPSDestLatitude", value); + } + } + + /// + /// Gets or sets a value indicating whether the destination point + /// is east or west longitude. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public LongitudeType? DestinationLongitudeDirection + { + get + { + return ToLongitudeType(GetTagText("GPSDestLongitudeRef")); + } + set + { + SetTagValue("GPSDestLongitudeRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the longitude of the destination point. The longitude is expressed as three rational + /// values giving the degrees, minutes, and seconds, respectively. Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational[] DestinationLongitude + { + get + { + return GetTagArray("GPSDestLongitude"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("GPSDestLongitude", value); + } + } + + /// + /// Gets or sets the reference used for giving the bearing to the destination point. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public DirectionReference? DestinationDirectionReference + { + get + { + return ToDirectionType(GetTagText("GPSDestBearingRef")); + } + set + { + SetTagValue("GPSDestBearingRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the bearing to the destination point. + /// The range of values is from 0.00 to 359.99. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational? DestinationBearing + { + get + { + return GetTagValue("GPSDestBearing"); + } + set + { + SetTagValue("GPSDestBearing", value); + } + } + + /// + /// Gets or sets the unit used to express the distance to the destination point. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public VelocityUnit? DestinationUnit + { + get + { + return ToUnitType(GetTagText("GPSDestDistanceRef")); + } + set + { + SetTagValue("GPSDestDistanceRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets a character string recording the name of the method used + /// for location finding. The first byte indicates the character code used, + /// and this is followed by the name of the method. Since the Type is not ASCII, + /// NULL termination is not necessary. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] ProcessingMethod + { + get + { + return GetTagArray("GPSProcessingMethod"); + } + set + { + SetTagValue("GPSProcessingMethod", value); + } + } + + /// + /// Gets or sets a character string recording the name of the GPS area. + /// The first byte indicates the character code used, and this is followed by + /// the name of the GPS area. Since the Type is not ASCII, NULL termination is + /// not necessary. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] AreaInformation + { + get + { + return GetTagArray("GPSAreaInformation"); + } + set + { + SetTagValue("GPSAreaInformation", value); + } + } + + /// + /// Gets or sets date and time information relative to UTC (Coordinated Universal Time). + /// + /// + /// This is a derived property. There is no metadata tag directly associated + /// with this property value. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public DateTime? DateTimeStamp + { + get + { + DateTime? date = DateStamp; + TimeSpan? time = TimeStamp; + if ((date == null) && (time == null)) + { + return null; + } + else + { + if (date == null) + { + date = DateTime.MinValue; + } + if (time == null) + { + time = TimeSpan.MinValue; + } + return date.Value.Add(time.Value); + } + } + set + { + if (value.HasValue) + { + DateStamp = value.Value.Date; + TimeStamp = value.Value.TimeOfDay; + } + else + { + DateStamp = null; + TimeStamp = null; + } + } + } + + /// + /// Gets or sets date information relative to UTC (Coordinated Universal Time). + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public DateTime? DateStamp + { + get + { + string stamp = GetTagText("GPSDateStamp"); + if (stamp != null) + { + try + { + return DateTime.ParseExact(stamp, "yyyy:MM:dd\0", null); + } + catch + { + } + } + return null; + } + set + { + string val = null; + if (value.HasValue) + { + try + { + val = value.Value.ToString("yyyy:MM:dd\0"); + } + catch + { + } + } + SetTagValue("GPSDateStamp", val); + } + } + + /// + /// Gets or sets a value indicating whether differential correction was applied to + /// the GPS receiver. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? IsDifferential + { + get + { + ushort? value = GetTagValue("GPSDifferential"); + return value.HasValue ? (value != 0) : (default(bool?)); + } + set + { + SetTagValue("GPSDifferential", value.HasValue ? (object)(value.Value ? (ushort)1 : (ushort)0) : (null)); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_INTEROP : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_INTEROP(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_EXIF_INTEROP; } + } + + /// + /// Gets or sets the identification of the Interoperability rule. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public InteroperabilityMode? Identification + { + get + { + return ToInteroperabilityType(GetTagText("InteroperabilityIndex")); + } + set + { + SetTagValue("InteroperabilityIndex", ToString(value) + '\0'); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + /// This class is obsolete. Use class instead. + /// + [Obsolete("To be removed in future releases. Use MDM_EXIF_MAIN instead.")] + public class MDM_MAIN : MDM_EXIF_MAIN + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_MAIN(FIBITMAP dib) : base(dib) { } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_EXIF_MAIN : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_EXIF_MAIN(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN; } + } + + /// + /// Gets or sets the number of columns of image data, equal to the number + /// of pixels per row. In JPEG compressed data a JPEG marker is used + /// instead of this tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? ImageWidth + { + get + { + return GetUInt32Value("ImageWidth"); + } + set + { + RemoveTag("ImageWidth"); + if (value.HasValue) + { + SetTagValue("ImageWidth", value); + } + } + } + + /// + /// Gets or sets number of rows of image data. In JPEG compressed data a JPEG marker + /// is used instead of this tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? ImageHeight + { + get + { + return GetUInt32Value("ImageLength"); + } + set + { + RemoveTag("ImageLength"); + if (value.HasValue) + { + SetTagValue("ImageLength", value); + } + } + } + + /// + /// Gets or sets number of bits per image component. In this standard + /// each component of the image is 8 bits, so the value for this tag is 8. + /// Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort[] BitsPerSample + { + get + { + return GetTagArray("BitsPerSample"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("BitsPerSample", value); + } + } + + /// + /// Gets or sets compression scheme used for the image data. When a primary image + /// is JPEG compressed, this designation is not necessary and is omitted. + /// When thumbnails use JPEG compression, this tag value is set to 6. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? Compression + { + get + { + return GetTagValue("Compression"); + } + set + { + SetTagValue("Compression", value); + } + } + + /// + /// Gets or sets pixel composition. In JPEG compressed data a JPEG marker is + /// used instead of this tag. See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 2 + /// RGB + /// + /// + /// 6 + /// YCbCr + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? PhotometricInterpretation + { + get + { + return GetTagValue("PhotometricInterpretation"); + } + set + { + SetTagValue("PhotometricInterpretation", value); + } + } + + /// + /// Gets or sets the image orientation viewed in terms of rows and columns. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ExifImageOrientation? Orientation + { + get + { + return (ExifImageOrientation?)GetTagValue("Orientation"); + } + set + { + SetTagValue("Orientation", (ushort?)value); + } + } + + /// + /// Gets or sets the number of components per pixel. Since this standard applies + /// to RGB and YCbCr images, the value set for this tag is 3. In JPEG compressed + /// data a JPEG marker is used instead of this tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? SamplesPerPixel + { + get + { + return GetTagValue("SamplesPerPixel"); + } + set + { + SetTagValue("SamplesPerPixel", value); + } + } + + /// + /// Gets or sets a value that indicates whether pixel components are recorded in + /// chunky or planar format. In JPEG compressed files a JPEG marker is used instead + /// of this tag. If this field does not exist, the TIFF default of 1 (chunky) is assumed. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 1 + /// chunky format + /// + /// + /// 2 + /// planar format + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? PlanarConfiguration + { + get + { + return GetTagValue("PlanarConfiguration"); + } + set + { + SetTagValue("PlanarConfiguration", value); + } + } + + /// + /// Gets or sets the sampling ratio of chrominance components in relation to + /// the luminance component. In JPEG compressed dat a JPEG marker is used + /// instead of this tag. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// [2,1] + /// YCbCr4:2:2 + /// + /// + /// [2,2] + /// YCbCr4:2:0 + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort[] YCbCrSubSampling + { + get + { + return GetTagArray("YCbCrSubSampling"); + } + set + { + FreeImage.Resize(ref value, 2); + SetTagValue("YCbCrSubSampling", value); + } + } + + /// + /// Gets or sets position of chrominance components in relation to the luminance component. + /// See remarks for further information. + /// + /// + /// This field is designated only for JPEG compressed data or uncompressed YCbCr data. + /// The TIFF default is 1 (centered); but when Y:Cb:Cr = 4:2:2 it is recommended in + /// this standard that 2 (co-sited) be used to record data, in order to improve the + /// image quality when viewed on TV systems. + /// + /// When this field does not exist, the reader shall assume the TIFF default. + /// In the case of Y:Cb:Cr = 4:2:0, the TIFF default (centered) is recommended. + /// If the reader does not have the capability of supporting both kinds of YCbCrPositioning, + /// it shall follow the TIFF default regardless of the value in this field. + /// It is preferable that readers be able to support both centered and co-sited positioning. + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 1 + /// centered + /// + /// + /// 2 + /// co-sited + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? YCbCrPositioning + { + get + { + return GetTagValue("YCbCrPositioning"); + } + set + { + SetTagValue("YCbCrPositioning", value); + } + } + + /// + /// Gets or sets the number of pixels per + /// in the direction. When the image resolution is unknown, + /// 72 [dpi] is designated. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? XResolution + { + get + { + return GetTagValue("XResolution"); + } + set + { + SetTagValue("XResolution", value); + } + } + + /// + /// Gets or sets the number of pixels per + /// in the direction. When the image resolution is unknown, + /// 72 [dpi] is designated. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? YResolution + { + get + { + return GetTagValue("YResolution"); + } + set + { + SetTagValue("YResolution", value); + } + } + + /// + /// Gets or sets the unit for measuring and . + /// The same unit is used for both and . + /// If the image resolution in unknown, 2 (inches) is designated. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 2 + /// inches + /// + /// + /// 3 + /// YCbCr4:2:0 + /// + /// + /// other + /// centimeters + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? ResolutionUnit + { + get + { + return GetTagValue("ResolutionUnit"); + } + set + { + SetTagValue("ResolutionUnit", value); + } + } + + /// + /// Gets or sets the byte offset of that strip. + /// It is recommended that this be selected so the number of strip bytes + /// does not exceed 64 Kbytes. + /// With JPEG compressed data this designation is not needed and is omitted. + /// Constant length of * StripsPerImage. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + /// + public uint[] StripOffsets + { + get + { + return GetUInt32Array("StripOffsets"); + } + set + { + RemoveTag("StripOffsets"); + if (value != null) + { + SetTagValue("StripOffsets", value); + } + } + } + + /// + /// Gets or sets number of rows per strip. This is the number of rows in the image of + /// one strip when an image is divided into strips. With JPEG compressed data this + /// designation is not needed and is omitted. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public uint? RowsPerStrip + { + get + { + return GetUInt32Value("RowsPerStrip"); + } + set + { + RemoveTag("RowsPerStrip"); + if (value.HasValue) + { + SetTagValue("RowsPerStrip", value); + } + } + } + + /// + /// Gets or sets the total number of bytes in each strip. + /// With JPEG compressed data this designation is not needed and is omitted. + /// Constant length of * StripsPerImage. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint[] StripByteCounts + { + get + { + return GetUInt32Array("StripByteCounts"); + } + set + { + RemoveTag("StripByteCounts"); + if (value != null) + { + SetTagValue("StripByteCounts", value); + } + } + } + + /// + /// Gets or sets the offset to the start byte (SOI) of JPEG compressed thumbnail data. + /// This is not used for primary image JPEG data. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? JPEGInterchangeFormat + { + get + { + return GetTagValue("JPEGInterchangeFormat"); + } + set + { + SetTagValue("JPEGInterchangeFormat", value); + } + } + + /// + /// Gets or sets the number of bytes of JPEG compressed thumbnail data. + /// + /// + /// This is not used for primary image JPEG data. + /// JPEG thumbnails are not divided but are recorded as a continuous + /// JPEG bitstream from SOI to EOI. APPn and COM markers should not be recorded. + /// Compressed thumbnails shall be recorded in no more than 64 Kbytes, + /// including all other data to be recorded in APP1. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public uint? JPEGInterchangeFormatLength + { + get + { + return GetTagValue("JPEGInterchangeFormatLength"); + } + set + { + SetTagValue("JPEGInterchangeFormatLength", value); + } + } + + /// + /// Gets or sets a transfer function for the image, described in tabular style. + /// Constant length of 3 * 256. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort[] TransferFunction + { + get + { + return GetTagArray("TransferFunction"); + } + set + { + FreeImage.Resize(ref value, 3 * 256); + SetTagValue("TransferFunction", value); + } + } + + /// + /// Gets or sets the chromaticity of the white point of the image. + /// Constant length of 2. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational[] WhitePoint + { + get + { + return GetTagArray("WhitePoint"); + } + set + { + FreeImage.Resize(ref value, 2); + SetTagValue("WhitePoint", value); + } + } + + /// + /// Gets or sets the chromaticity of the three primary colors of the image. + /// Constant length of 6. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational[] PrimaryChromaticities + { + get + { + return GetTagArray("PrimaryChromaticities"); + } + set + { + FreeImage.Resize(ref value, 6); + SetTagValue("PrimaryChromaticities", value); + } + } + + /// + /// Gets or sets the matrix coefficients for transformation from RGB to YCbCr image data. + /// Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational[] YCbCrCoefficients + { + get + { + return GetTagArray("YCbCrCoefficients"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("PrimaryChromaticities", value); + } + } + + /// + /// Gets or sets the reference black point value and reference white point value. + /// Constant length of 6. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational[] ReferenceBlackWhite + { + get + { + return GetTagArray("ReferenceBlackWhite"); + } + set + { + FreeImage.Resize(ref value, 6); + SetTagValue("ReferenceBlackWhite", value); + } + } + + /// + /// Gets or sets the date and time of image creation. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public DateTime? DateTime + { + get + { + DateTime? result = null; + string text = GetTagText("DateTime"); + if (text != null) + { + try + { + result = System.DateTime.ParseExact(text, "yyyy:MM:dd HH:mm:ss\0", null); + } + catch + { + } + } + return result; + } + set + { + string val = null; + if (value.HasValue) + { + try + { + val = value.Value.ToString("yyyy:MM:dd HH:mm:ss\0"); + } + catch + { + } + } + SetTagValue("DateTime", val); + } + } + + /// + /// Gets or sets a string giving the title of the image. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ImageDescription + { + get + { + string result = GetTagText("ImageDescription"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("ImageDescription", value); + } + } + + /// + /// Gets or sets the manufacturer of the recording equipment. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Make + { + get + { + string result = GetTagText("Make"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("Make", value); + } + } + + /// + /// Gets or sets the model name or model number of the equipment. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string EquipmentModel + { + get + { + string result = GetTagText("Model"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("Model", value); + } + } + + /// + /// Gets or sets the name and version of the software or firmware of the camera + /// or image input device used to generate the image. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Software + { + get + { + string result = GetTagText("Software"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("Software", value); + } + } + + /// + /// Gets or sets the name of the camera owner, photographer or image creator. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Artist + { + get + { + string result = GetTagText("Artist"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("Artist", value); + } + } + + /// + /// Gets or sets the photographer and editor copyrights. + /// Constant length of 1-2. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string[] Copyright + { + get + { + string[] result = null; + string text = GetTagText("Copyright"); + if (!string.IsNullOrEmpty(text)) + { + result = text.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries); + } + return result; + } + set + { + string val = null; + if (value != null) + { + if (value.Length == 1) + { + if (value[0] != null) + { + val = value[0] + '\0'; + } + } + else if (value.Length == 2) + { + if ((value[0] != null) && (value[1] != null)) + { + val = value[0] + '\0' + value[1] + '\0'; + } + } + } + SetTagValue("Copyright", val); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_MAKERNOTE : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_MAKERNOTE(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_EXIF_MAKERNOTE; } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_GEOTIFF : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_GEOTIFF(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_GEOTIFF; } + } + + /// + /// Gets or sets the value of the GeoTIFF GeoASCIIParamsTag. + /// + /// + /// The GeoASCIIParamsTag is used to store all of the valued + /// GeoKeys, referenced by the property. Since keys + /// defined in the GeoKeyDirectoryTag use offsets into this tag, any special + /// comments may be placed at the beginning of this tag. + /// For the most part, the only keys that are valued are + /// Citation keys, giving documentation and references for obscure + /// projections, datums, etc. + /// + /// Special handling is required for -valued keys. While it + /// is true that TIFF 6.0 permits multiple NULL-delimited strings within a single + /// ASCII tag, the secondary strings might not appear in the output of naive + /// tiffdump programs. For this reason, the NULL delimiter of each ASCII key + /// value shall be converted to a "|" (pipe) character before being installed + /// back into the holding tag, so that a dump of the tag + /// will look like this. + /// + /// AsciiTag="first_value|second_value|etc...last_value|" + /// + /// A baseline GeoTIFF-reader must check for and convert the final "|" pipe + /// character of a key back into a NULL before returning it to the client + /// software. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public string GeoASCIIParams + { + get + { + string text = GetTagText("GeoASCIIParams"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("GeoASCIIParams", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF GeoDoubleParamsTag. + /// + /// + /// The GeoDoubleParamsTag is used to store all of the valued + /// GeoKeys, referenced by the property. The meaning of + /// any value of this double array is determined from the GeoKeyDirectoryTag reference + /// pointing to it. values should first be converted to + /// and stored here. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public double[] GeoDoubleParams + { + get + { + return GetTagArray("GeoDoubleParams"); + } + set + { + SetTagValue("GeoDoubleParams", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF GeoKeyDirectoryTag. + /// + /// + /// The GeoKeyDirectoryTag may be used to store the GeoKey Directory, which defines and + /// references the GeoKeys. + /// + /// The tag is an array of unsigned values, which are primarily + /// grouped into blocks of 4. The first 4 values are special, and contain GeoKey directory + /// header information. The header values consist of the following information, in order: + /// + /// Header={KeyDirectoryVersion, KeyRevision, MinorRevision, NumberOfKeys} + /// + /// where + /// + /// KeyDirectoryVersion indicates the current version of Key implementation, and will + /// only change if this Tag's Key structure is changed. (Similar to the TIFFVersion (42)). + /// The current DirectoryVersion number is 1. This value will most likely never change, + /// and may be used to ensure that this is a valid Key-implementation. + /// + /// KeyRevision indicates what revision of Key-Sets are used. + /// + /// MinorRevision indicates what set of Key-Codes are used. The complete revision number + /// is denoted <KeyRevision>.<MinorRevision>. + /// + /// NumberOfKeys indicates how many Keys are defined by the rest of this Tag. + /// + /// This header is immediately followed by a collection of <NumberOfKeys> KeyEntry + /// sets, each of which is also 4- long. Each KeyEntry is modeled on the + /// TIFFEntry format of the TIFF directory header, and is of the form: + /// + /// KeyEntry = { KeyID, TIFFTagLocation, Count, Value_Offset } + /// + /// where + /// + /// KeyID gives the Key-ID value of the Key (identical in function to TIFF tag ID, + /// but completely independent of TIFF tag-space), + /// + /// TIFFTagLocation indicates which TIFF tag contains the value(s) of the Key: if + /// TIFFTagLocation is 0, then the value is , and is contained in the + /// Value_Offset entry. Otherwise, the type (format) of the value is implied by the + /// TIFF-Type of the tag containing the value. + /// + /// Count indicates the number of values in this key. + /// + /// Value_Offset Value_Offset indicates the index-offset into the TagArray indicated + /// by TIFFTagLocation, if it is nonzero. If TIFFTagLocation is 0 (zero) , then Value_Offset + /// contains the actual () value of the Key, and Count=1 is implied. + /// Note that the offset is not a byte-offset, but rather an index based on the natural data + /// type of the specified tag array. + /// + /// Following the KeyEntry definitions, the KeyDirectory tag may also contain additional + /// values. For example, if a key requires multiple values, they shall + /// be placed at the end of this tag, and the KeyEntry will set + /// TIFFTagLocation=GeoKeyDirectoryTag, with the Value_Offset pointing to the location of the + /// value(s). + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort[] GeoKeyDirectory + { + get + { + return GetTagArray("GeoKeyDirectory"); + } + set + { + SetTagValue("GeoKeyDirectory", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF ModelPixelScaleTag. + /// + /// + /// The ModelPixelScaleTag tag may be used to specify the size of raster pixel spacing + /// in the model space units, when the raster space can be embedded in the model space + /// coordinate system without rotation, and consists of the following 3 values: + /// + /// ModelPixelScaleTag = (ScaleX, ScaleY, ScaleZ) + /// + /// where ScaleX and ScaleY give the horizontal and vertical spacing of + /// raster pixels. The ScaleZ is primarily used to map the pixel value of a + /// digital elevation model into the correct Z-scale, and so for most other purposes + /// this value should be zero (since most model spaces are 2-D, with Z=0). + /// + /// A single tiepoint in the tag, together with this tag, + /// completely determine the relationship between raster and model space; thus they + /// comprise the two tags which Baseline GeoTIFF files most often will use to place a + /// raster image into a "standard position" in model space. + /// + /// Like the tag, this tag information is independent of the + /// XPosition, YPosition, Resolution and Orientation tags of the standard TIFF 6.0 spec. + /// However, simple reversals of orientation between raster and model space + /// (e.g. horizontal or vertical flips) may be indicated by reversal of sign in the + /// corresponding component of the ModelPixelScaleTag. GeoTIFF compliant readers must + /// honor this signreversal convention. + /// + /// This tag must not be used if the raster image requires rotation or shearing to place + /// it into the standard model space. In such cases the transformation shall be defined + /// with the more general . + /// + ///
Naming differences + /// In the native FreeImage library and thus, in the FreeImage API documentation, this + /// property's key is named GeoPixelScale. Since the GeoTIFF specification + /// as well as Java's EXIFTIFFTagSet class call this tag + /// , this property was renamed accordingly. + /// However, when accessing this property's tag by its object, + /// the native FreeImage tag key GeoPixelScale must be used. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public double[] ModelPixelScale + { + get + { + return GetTagArray("GeoPixelScale"); + } + set + { + SetTagValue("GeoPixelScale", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF GeoTiePointsTag. + /// + /// + /// The GeoTiePointsTag stores raster -> model tiepoint pairs in the order + /// + /// ModelTiePoints = (...,I,J,K, X,Y,Z...), + /// + /// where (I,J,K) is the point at location (I,J) in raster space with + /// pixel-value K, and (X,Y,Z) is a vector in model space. In most cases + /// the model space is only two-dimensional, in which case both K and Z should be set + /// to zero; this third dimension is provided in anticipation of future support for 3D + /// digital elevation models and vertical coordinate systems. + /// + /// A raster image may be georeferenced simply by specifying its location, size and + /// orientation in the model coordinate space M. This may be done by specifying the + /// location of three of the four bounding corner points. However, tiepoints are only + /// to be considered exact at the points specified; thus defining such a set of + /// bounding tiepoints does not imply that the model space locations of the interior + /// of the image may be exactly computed by a linear interpolation of these tiepoints. + /// + /// However, since the relationship between the Raster space and the model space will + /// often be an exact, affine transformation, this relationship can be defined using + /// one set of tiepoints and the , described below, which + /// gives the vertical and horizontal raster grid cell size, specified in model units. + /// + /// If possible, the first tiepoint placed in this tag shall be the one establishing + /// the location of the point (0,0) in raster space. However, if this is not possible + /// (for example, if (0,0) is goes to a part of model space in which the projection is + /// ill-defined), then there is no particular order in which the tiepoints need be + /// listed. + /// + /// For orthorectification or mosaicking applications a large number of tiepoints may + /// be specified on a mesh over the raster image. However, the definition of associated + /// grid interpolation methods is not in the scope of the current GeoTIFF spec. + /// + ///
Naming differences + /// In the native FreeImage library and thus, in the FreeImage API documentation, this + /// property's key is named GeoTiePoints. Since the GeoTIFF specification + /// as well as Java's EXIFTIFFTagSet class call this tag + /// , this property was renamed accordingly. + /// However, when accessing this property's tag by its object, + /// the native FreeImage tag key GeoTiePoints must be used. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public double[] ModelTiePoints + { + get + { + return GetTagArray("GeoTiePoints"); + } + set + { + SetTagValue("GeoTiePoints", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF ModelTransformationMatrixTag. + /// + /// + /// This tag may be used to specify the transformation matrix between the raster space + /// (and its dependent pixel-value space) and the (possibly 3D) model space. + /// + ///
Naming differences + /// In the native FreeImage library and thus, in the FreeImage API documentation, this + /// property's key is named GeoTransformationMatrix. Since the GeoTIFF specification + /// as well as Java's EXIFTIFFTagSet class call this tag + /// , this property was renamed accordingly. + /// However, when accessing this property's tag by its object, + /// the native FreeImage tag key GeoTransformationMatrix must be used. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public double[] ModelTransformationMatrix + { + get + { + return GetTagArray("GeoTransformationMatrix"); + } + set + { + SetTagValue("GeoTransformationMatrix", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF IntergraphTransformationMatrixTag. + /// + /// + /// The IntergraphTransformationMatrixTag conflicts with an internal software implementation + /// at Intergraph, and so its use is no longer encouraged. A GeoTIFF reader should look first + /// for the new tag, and only if it is not found should it check for this older tag. If found, + /// it should only consider it to be contain valid GeoTIFF matrix information if the tag-count + /// is 16; the Intergraph version uses 17 values. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public double[] IntergraphTransformationMatrix + { + get + { + return GetTagArray("Intergraph TransformationMatrix"); + } + set + { + SetTagValue("Intergraph TransformationMatrix", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF JPLCartoIFDOffsetTag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? JPLCartoIFDOffset + { + get + { + return GetTagValue("JPL Carto IFD offset"); + } + set + { + SetTagValue("JPL Carto IFD offset", value); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_IPTC : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_IPTC(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_IPTC; } + } + + /// + /// Gets the Application Record Version. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public short? ApplicationRecordVersion + { + get + { + return GetTagValue("ApplicationRecordVersion"); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Type Reference. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectTypeReference + { + get + { + return GetTagText("ObjectTypeReference"); + } + set + { + SetTagValue("ObjectTypeReference", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Attribute Reference. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectAttributeReference + { + get + { + return GetTagText("ObjectAttributeReference"); + } + set + { + SetTagValue("ObjectAttributeReference", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Name. + /// This is also referred to as Title. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectName + { + get + { + return GetTagText("ObjectName"); + } + set + { + SetTagValue("ObjectName", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Edit Status. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string EditStatus + { + get + { + return GetTagText("EditStatus"); + } + set + { + SetTagValue("EditStatus", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Editorial Update. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string EditorialUpdate + { + get + { + return GetTagText("EditorialUpdate"); + } + set + { + SetTagValue("EditorialUpdate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Urgency. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Urgency + { + get + { + return GetTagText("Urgency"); + } + set + { + SetTagValue("Urgency", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Subject Reference. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SubjectReference + { + get + { + return GetTagText("SubjectReference"); + } + set + { + SetTagValue("SubjectReference", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Category. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Category + { + get + { + return GetTagText("Category"); + } + set + { + SetTagValue("Category", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Supplemental Categories. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SupplementalCategories + { + get + { + return GetTagText("SupplementalCategories"); + } + set + { + SetTagValue("SupplementalCategories", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Fixture Identifier. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string FixtureIdentifier + { + get + { + return GetTagText("FixtureIdentifier"); + } + set + { + SetTagValue("FixtureIdentifier", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Keywords. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Keywords + { + get + { + return GetTagText("Keywords"); + } + set + { + SetTagValue("Keywords", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Content Location Code. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ContentLocationCode + { + get + { + return GetTagText("ContentLocationCode"); + } + set + { + SetTagValue("ContentLocationCode", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Content Location Name. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ContentLocationName + { + get + { + return GetTagText("ContentLocationName"); + } + set + { + SetTagValue("ContentLocationName", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Release Date. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ReleaseDate + { + get + { + return GetTagText("ReleaseDate"); + } + set + { + SetTagValue("ReleaseDate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Release Time. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ReleaseTime + { + get + { + return GetTagText("ReleaseTime"); + } + set + { + SetTagValue("ReleaseTime", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Expiration Date. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ExpirationDate + { + get + { + return GetTagText("ExpirationDate"); + } + set + { + SetTagValue("ExpirationDate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Expiration Time. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ExpirationTime + { + get + { + return GetTagText("ExpirationTime"); + } + set + { + SetTagValue("ExpirationTime", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Special Instructions. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SpecialInstructions + { + get + { + return GetTagText("SpecialInstructions"); + } + set + { + SetTagValue("SpecialInstructions", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Action Advised. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ActionAdvised + { + get + { + return GetTagText("ActionAdvised"); + } + set + { + SetTagValue("ActionAdvised", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Reference Service. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ReferenceService + { + get + { + return GetTagText("ReferenceService"); + } + set + { + SetTagValue("ReferenceService", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Reference Date. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ReferenceDate + { + get + { + return GetTagText("ReferenceDate"); + } + set + { + SetTagValue("ReferenceDate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Reference Number. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ReferenceNumber + { + get + { + return GetTagText("ReferenceNumber"); + } + set + { + SetTagValue("ReferenceNumber", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Date Created. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string DateCreated + { + get + { + return GetTagText("DateCreated"); + } + set + { + SetTagValue("DateCreated", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Time Created. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string TimeCreated + { + get + { + return GetTagText("TimeCreated"); + } + set + { + SetTagValue("TimeCreated", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Digital Creation Date. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string DigitalCreationDate + { + get + { + return GetTagText("DigitalCreationDate"); + } + set + { + SetTagValue("DigitalCreationDate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Digital Creation Time. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string DigitalCreationTime + { + get + { + return GetTagText("DigitalCreationTime"); + } + set + { + SetTagValue("DigitalCreationTime", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Originating Program. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string OriginatingProgram + { + get + { + return GetTagText("OriginatingProgram"); + } + set + { + SetTagValue("OriginatingProgram", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Program Version. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ProgramVersion + { + get + { + return GetTagText("ProgramVersion"); + } + set + { + SetTagValue("ProgramVersion", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Cycle. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectCycle + { + get + { + return GetTagText("ObjectCycle"); + } + set + { + SetTagValue("ObjectCycle", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag By Line. + /// This is the author's name. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ByLine + { + get + { + return GetTagText("By-line"); + } + set + { + SetTagValue("By-line", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag By Line Title. + /// This is the author's position. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ByLineTitle + { + get + { + return GetTagText("By-lineTitle"); + } + set + { + SetTagValue("By-lineTitle", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag City. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string City + { + get + { + return GetTagText("City"); + } + set + { + SetTagValue("City", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Sub Location. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SubLocation + { + get + { + return GetTagText("SubLocation"); + } + set + { + SetTagValue("SubLocation", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Province State. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ProvinceState + { + get + { + return GetTagText("ProvinceState"); + } + set + { + SetTagValue("ProvinceState", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Country Primary Location Code. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string CountryPrimaryLocationCode + { + get + { + return GetTagText("Country-PrimaryLocationCode"); + } + set + { + SetTagValue("Country-PrimaryLocationCode", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Country Primary Location Name. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string CountryPrimaryLocationName + { + get + { + return GetTagText("Country-PrimaryLocationName"); + } + set + { + SetTagValue("Country-PrimaryLocationName", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Original Transmission Reference. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string OriginalTransmissionReference + { + get + { + return GetTagText("OriginalTransmissionReference"); + } + set + { + SetTagValue("OriginalTransmissionReference", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Headline. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Headline + { + get + { + return GetTagText("Headline"); + } + set + { + SetTagValue("Headline", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Credit. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Credit + { + get + { + return GetTagText("Credit"); + } + set + { + SetTagValue("Credit", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Source. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Source + { + get + { + return GetTagText("Source"); + } + set + { + SetTagValue("Source", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Copyright Notice. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string CopyrightNotice + { + get + { + return GetTagText("CopyrightNotice"); + } + set + { + SetTagValue("CopyrightNotice", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Contact. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Contact + { + get + { + return GetTagText("Contact"); + } + set + { + SetTagValue("Contact", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Caption Abstract. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string CaptionAbstract + { + get + { + return GetTagText("CaptionAbstract"); + } + set + { + SetTagValue("CaptionAbstract", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Writer Editor. + /// This is also referred to as Caption Writer. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string WriterEditor + { + get + { + return GetTagText("WriterEditor"); + } + set + { + SetTagValue("WriterEditor", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Rasterized Caption. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string RasterizedCaption + { + get + { + return GetTagText("RasterizedCaption"); + } + set + { + SetTagValue("RasterizedCaption", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Image Type. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ImageType + { + get + { + return GetTagText("ImageType"); + } + set + { + SetTagValue("ImageType", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Image Orientation. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ImageOrientation + { + get + { + return GetTagText("ImageOrientation"); + } + set + { + SetTagValue("ImageOrientation", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Language Identifier. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string LanguageIdentifier + { + get + { + return GetTagText("LanguageIdentifier"); + } + set + { + SetTagValue("LanguageIdentifier", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Audio Type. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string AudioType + { + get + { + return GetTagText("AudioType"); + } + set + { + SetTagValue("AudioType", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Audio Sampling Rate. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string AudioSamplingRate + { + get + { + return GetTagText("AudioSamplingRate"); + } + set + { + SetTagValue("AudioSamplingRate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Audio Sampling Resolution. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string AudioSamplingResolution + { + get + { + return GetTagText("AudioSamplingResolution"); + } + set + { + SetTagValue("AudioSamplingResolution", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Audio Duration. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string AudioDuration + { + get + { + return GetTagText("AudioDuration"); + } + set + { + SetTagValue("AudioDuration", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Audio Outcue. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string AudioOutcue + { + get + { + return GetTagText("AudioOutcue"); + } + set + { + SetTagValue("AudioOutcue", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Job I D. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string JobID + { + get + { + return GetTagText("JobID"); + } + set + { + SetTagValue("JobID", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Master Document I D. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string MasterDocumentID + { + get + { + return GetTagText("MasterDocumentID"); + } + set + { + SetTagValue("MasterDocumentID", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Short Document I D. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ShortDocumentID + { + get + { + return GetTagText("ShortDocumentID"); + } + set + { + SetTagValue("ShortDocumentID", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Unique Document I D. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string UniqueDocumentID + { + get + { + return GetTagText("UniqueDocumentID"); + } + set + { + SetTagValue("UniqueDocumentID", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Owner I D. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string OwnerID + { + get + { + return GetTagText("OwnerID"); + } + set + { + SetTagValue("OwnerID", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Preview File Format. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectPreviewFileFormat + { + get + { + return GetTagText("ObjectPreviewFileFormat"); + } + set + { + SetTagValue("ObjectPreviewFileFormat", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Preview File Version. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectPreviewFileVersion + { + get + { + return GetTagText("ObjectPreviewFileVersion"); + } + set + { + SetTagValue("ObjectPreviewFileVersion", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Preview Data. + /// This is also referred to as Audio Outcue. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectPreviewData + { + get + { + return GetTagText("ObjectPreviewData"); + } + set + { + SetTagValue("ObjectPreviewData", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Prefs. + /// This is also referred to as photo-mechanic preferences. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Prefs + { + get + { + return GetTagText("Prefs"); + } + set + { + SetTagValue("Prefs", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Classify State. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ClassifyState + { + get + { + return GetTagText("ClassifyState"); + } + set + { + SetTagValue("ClassifyState", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Similarity Index. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SimilarityIndex + { + get + { + return GetTagText("SimilarityIndex"); + } + set + { + SetTagValue("SimilarityIndex", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Document Notes. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string DocumentNotes + { + get + { + return GetTagText("DocumentNotes"); + } + set + { + SetTagValue("DocumentNotes", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Document History. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string DocumentHistory + { + get + { + return GetTagText("DocumentHistory"); + } + set + { + SetTagValue("DocumentHistory", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Exif Camera Info. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ExifCameraInfo + { + get + { + return GetTagText("ExifCameraInfo"); + } + set + { + SetTagValue("ExifCameraInfo", value); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_NODATA : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_NODATA(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_NODATA; } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_XMP : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_XMP(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_XMP; } + } + + /// + /// Gets or sets the XMP XML content. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Xml + { + get + { + return GetTagText("XMLPacket"); + } + set + { + SetTagValue("XMLPacket", value); + } + } + + /// + /// Gets an initialized to read the XMP XML content. + /// Returns null, if the metadata tag XMLPacket is not present in + /// this model. + /// + public XmlReader XmlReader + { + get + { + string xmlString = Xml; + if (xmlString == null) + { + return null; + } + else + { + MemoryStream stream = new MemoryStream(); + StreamWriter writer = new StreamWriter(stream); + writer.Write(xmlString); + return XmlReader.Create(stream); + } + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MetadataTag.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MetadataTag.cs new file mode 100644 index 0000000..8fa580d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/MetadataTag.cs @@ -0,0 +1,757 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.9 $ +// $Date: 2009/02/27 16:35:12 $ +// $Id: MetadataTag.cs,v 1.9 2009/02/27 16:35:12 cklein05 Exp $ +// ========================================================== + +using System; +using System.Text; +using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.Diagnostics; + +namespace FreeImageAPI.Metadata +{ + /// + /// Manages metadata objects and operations. + /// + public sealed class MetadataTag : IComparable, IComparable, ICloneable, IEquatable, IDisposable + { + /// + /// The encapsulated FreeImage-tag. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + internal FITAG tag; + + /// + /// The metadata model of . + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private FREE_IMAGE_MDMODEL model; + + /// + /// Indicates whether this instance has already been disposed. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool disposed = false; + + /// + /// Indicates whether this instance was created by FreeImage or + /// by the user. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool selfCreated; + + /// + /// List linking metadata-model and Type. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly Dictionary idList; + + /// + /// List linking Type and metadata-model. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly Dictionary typeList; + + /// + /// Initializes a new instance of this class. + /// + private MetadataTag() + { + } + + /// + /// Initializes a new instance of this class. + /// + /// The new model the tag should be of. + public MetadataTag(FREE_IMAGE_MDMODEL model) + { + this.model = model; + tag = FreeImage.CreateTag(); + selfCreated = true; + + if (model == FREE_IMAGE_MDMODEL.FIMD_XMP) + { + Key = "XMLPacket"; + } + } + + /// + /// Initializes a new instance of this class. + /// + /// The to represent. + /// The bitmap was extracted from. + public MetadataTag(FITAG tag, FIBITMAP dib) + { + if (tag.IsNull) + { + throw new ArgumentNullException("tag"); + } + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + this.tag = tag; + model = GetModel(dib, tag); + selfCreated = false; + + if (model == FREE_IMAGE_MDMODEL.FIMD_XMP) + { + Key = "XMLPacket"; + } + } + + /// + /// Initializes a new instance of this class. + /// + /// The to represent. + /// The model of . + public MetadataTag(FITAG tag, FREE_IMAGE_MDMODEL model) + { + if (tag.IsNull) + { + throw new ArgumentNullException("tag"); + } + this.tag = tag; + this.model = model; + selfCreated = false; + + if (model == FREE_IMAGE_MDMODEL.FIMD_XMP) + { + Key = "XMLPacket"; + } + } + + static MetadataTag() + { + idList = new Dictionary(); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_BYTE, typeof(byte)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_SHORT, typeof(ushort)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_LONG, typeof(uint)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_RATIONAL, typeof(FIURational)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_SBYTE, typeof(sbyte)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_UNDEFINED, typeof(byte)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_SSHORT, typeof(short)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_SLONG, typeof(int)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_SRATIONAL, typeof(FIRational)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_FLOAT, typeof(float)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_DOUBLE, typeof(double)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_IFD, typeof(uint)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_PALETTE, typeof(RGBQUAD)); + + typeList = new Dictionary(); + typeList.Add(typeof(ushort), FREE_IMAGE_MDTYPE.FIDT_SHORT); + typeList.Add(typeof(ushort[]), FREE_IMAGE_MDTYPE.FIDT_SHORT); + typeList.Add(typeof(string), FREE_IMAGE_MDTYPE.FIDT_ASCII); + typeList.Add(typeof(uint), FREE_IMAGE_MDTYPE.FIDT_LONG); + typeList.Add(typeof(uint[]), FREE_IMAGE_MDTYPE.FIDT_LONG); + typeList.Add(typeof(FIURational), FREE_IMAGE_MDTYPE.FIDT_RATIONAL); + typeList.Add(typeof(FIURational[]), FREE_IMAGE_MDTYPE.FIDT_RATIONAL); + typeList.Add(typeof(sbyte), FREE_IMAGE_MDTYPE.FIDT_SBYTE); + typeList.Add(typeof(sbyte[]), FREE_IMAGE_MDTYPE.FIDT_SBYTE); + typeList.Add(typeof(byte), FREE_IMAGE_MDTYPE.FIDT_BYTE); + typeList.Add(typeof(byte[]), FREE_IMAGE_MDTYPE.FIDT_BYTE); + typeList.Add(typeof(short), FREE_IMAGE_MDTYPE.FIDT_SSHORT); + typeList.Add(typeof(short[]), FREE_IMAGE_MDTYPE.FIDT_SSHORT); + typeList.Add(typeof(int), FREE_IMAGE_MDTYPE.FIDT_SLONG); + typeList.Add(typeof(int[]), FREE_IMAGE_MDTYPE.FIDT_SLONG); + typeList.Add(typeof(FIRational), FREE_IMAGE_MDTYPE.FIDT_SRATIONAL); + typeList.Add(typeof(FIRational[]), FREE_IMAGE_MDTYPE.FIDT_SRATIONAL); + typeList.Add(typeof(float), FREE_IMAGE_MDTYPE.FIDT_FLOAT); + typeList.Add(typeof(float[]), FREE_IMAGE_MDTYPE.FIDT_FLOAT); + typeList.Add(typeof(double), FREE_IMAGE_MDTYPE.FIDT_DOUBLE); + typeList.Add(typeof(double[]), FREE_IMAGE_MDTYPE.FIDT_DOUBLE); + typeList.Add(typeof(RGBQUAD), FREE_IMAGE_MDTYPE.FIDT_PALETTE); + typeList.Add(typeof(RGBQUAD[]), FREE_IMAGE_MDTYPE.FIDT_PALETTE); + } + + /// + /// Releases all resources used by the instance. + /// + ~MetadataTag() + { + Dispose(); + } + + /// + /// Determines whether two specified objects have the same value. + /// + /// A or a null reference (Nothing in Visual Basic). + /// A or a null reference (Nothing in Visual Basic). + /// + /// true if the value of left is the same as the value of right; otherwise, false. + /// + public static bool operator ==(MetadataTag left, MetadataTag right) + { + // Check whether both are null + if ((object)left == (object)right) + { + return true; + } + else if ((object)left == null || (object)right == null) + { + return false; + } + left.CheckDisposed(); + right.CheckDisposed(); + // Check all properties + if ((left.Key != right.Key) || + (left.ID != right.ID) || + (left.Description != right.Description) || + (left.Count != right.Count) || + (left.Length != right.Length) || + (left.Model != right.Model) || + (left.Type != right.Type)) + { + return false; + } + if (left.Length == 0) + { + return true; + } + IntPtr ptr1 = FreeImage.GetTagValue(left.tag); + IntPtr ptr2 = FreeImage.GetTagValue(right.tag); + return FreeImage.CompareMemory(ptr1, ptr2, left.Length); + } + + /// + /// Determines whether two specified objects have different values. + /// + /// A or a null reference (Nothing in Visual Basic). + /// A or a null reference (Nothing in Visual Basic). + /// + /// true if the value of left is different from the value of right; otherwise, false. + /// + public static bool operator !=(MetadataTag left, MetadataTag right) + { + return !(left == right); + } + + /// + /// Extracts the value of a instance to a handle. + /// + /// A instance. + /// A new instance of initialized to . + public static implicit operator FITAG(MetadataTag value) + { + return value.tag; + } + + private static FREE_IMAGE_MDMODEL GetModel(FIBITMAP dib, FITAG tag) + { + FITAG value; + foreach (FREE_IMAGE_MDMODEL model in FreeImage.FREE_IMAGE_MDMODELS) + { + FIMETADATA mData = FreeImage.FindFirstMetadata(model, dib, out value); + if (mData.IsNull) + { + continue; + } + try + { + do + { + if (value == tag) + { + return model; + } + } + while (FreeImage.FindNextMetadata(mData, out value)); + } + finally + { + if (!mData.IsNull) + { + FreeImage.FindCloseMetadata(mData); + } + } + } + throw new ArgumentException("'tag' is no metadata object of 'dib'"); + } + + /// + /// Gets the model of the metadata. + /// + public FREE_IMAGE_MDMODEL Model + { + get { CheckDisposed(); return model; } + } + + /// + /// Gets or sets the key of the metadata. + /// + public string Key + { + get { CheckDisposed(); return FreeImage.GetTagKey(tag); } + set + { + CheckDisposed(); + if ((model != FREE_IMAGE_MDMODEL.FIMD_XMP) || (value == "XMLPacket")) + { + FreeImage.SetTagKey(tag, value); + } + } + } + + /// + /// Gets or sets the description of the metadata. + /// + public string Description + { + get { CheckDisposed(); return FreeImage.GetTagDescription(tag); } + set { CheckDisposed(); FreeImage.SetTagDescription(tag, value); } + } + + /// + /// Gets or sets the ID of the metadata. + /// + public ushort ID + { + get { CheckDisposed(); return FreeImage.GetTagID(tag); } + set { CheckDisposed(); FreeImage.SetTagID(tag, value); } + } + + /// + /// Gets the type of the metadata. + /// + public FREE_IMAGE_MDTYPE Type + { + get { CheckDisposed(); return FreeImage.GetTagType(tag); } + internal set { FreeImage.SetTagType(tag, value); } + } + + /// + /// Gets the number of elements the metadata object contains. + /// + public uint Count + { + get { CheckDisposed(); return FreeImage.GetTagCount(tag); } + private set { FreeImage.SetTagCount(tag, value); } + } + + /// + /// Gets the length of the value in bytes. + /// + public uint Length + { + get { CheckDisposed(); return FreeImage.GetTagLength(tag); } + private set { FreeImage.SetTagLength(tag, value); } + } + + private unsafe byte[] GetData() + { + uint length = Length; + byte[] value = new byte[length]; + byte* ptr = (byte*)FreeImage.GetTagValue(tag); + for (int i = 0; i < length; i++) + { + value[i] = ptr[i]; + } + return value; + } + + /// + /// Gets or sets the value of the metadata. + /// + public object Value + { + get + { + unsafe + { + CheckDisposed(); + int cnt = (int)Count; + + if (Type == FREE_IMAGE_MDTYPE.FIDT_ASCII) + { + byte* value = (byte*)FreeImage.GetTagValue(tag); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < cnt; i++) + { + sb.Append(Convert.ToChar(value[i])); + } + return sb.ToString(); + } + else if (Type == FREE_IMAGE_MDTYPE.FIDT_NOTYPE) + { + return null; + } + + Array array = Array.CreateInstance(idList[Type], Count); + void* src = (void*)FreeImage.GetTagValue(tag); + FreeImage.CopyMemory(array, src, Length); + return array; + } + } + set + { + SetValue(value); + } + } + + /// + /// Sets the value of the metadata. + /// In case value is of byte or byte[] is assumed. + /// In case value is of uint or uint[] is assumed. + /// + /// New data of the metadata. + /// True on success, false on failure. + /// + /// The data format is not supported. + /// + /// is null. + public bool SetValue(object value) + { + Type type = value.GetType(); + if (!typeList.ContainsKey(type)) + { + throw new NotSupportedException("The type of value is not supported"); + } + return SetValue(value, typeList[type]); + } + + /// + /// Sets the value of the metadata. + /// + /// New data of the metadata. + /// Type of the data. + /// True on success, false on failure. + /// + /// The data type is not supported. + /// + /// is null. + /// + /// and to not fit. + public bool SetValue(object value, FREE_IMAGE_MDTYPE type) + { + CheckDisposed(); + if ((!value.GetType().IsArray) && (!(value is string))) + { + Array array = Array.CreateInstance(value.GetType(), 1); + array.SetValue(value, 0); + return SetArrayValue(array, type); + } + return SetArrayValue(value, type); + } + + /// + /// Sets the value of this tag to the value of + /// using the given type. + /// + /// New value of the tag. + /// Data-type of the tag. + /// + /// + /// is a null reference. + /// + /// + /// is FIDT_ASCII and + /// is not String. + /// is not FIDT_ASCII and + /// is not Array. + /// + /// is FIDT_NOTYPE. + private unsafe bool SetArrayValue(object value, FREE_IMAGE_MDTYPE type) + { + if (value == null) + { + throw new ArgumentNullException("value"); + } + + byte[] data = null; + + if (type == FREE_IMAGE_MDTYPE.FIDT_ASCII) + { + string tempValue = value as string; + if (tempValue == null) + { + throw new ArgumentException("value"); + } + Type = type; + Length = Count = (uint)tempValue.Length; + data = new byte[Length]; + + for (int i = 0; i < tempValue.Length; i++) + { + data[i] = (byte)tempValue[i]; + } + } + else if (type == FREE_IMAGE_MDTYPE.FIDT_NOTYPE) + { + throw new NotSupportedException("type is not supported."); + } + else + { + Array array = value as Array; + if (array == null) + { + throw new ArgumentException("value"); + } + + if (array.Length != 0) + if (!CheckType(array.GetValue(0).GetType(), type)) + throw new ArgumentException("The type of value is incorrect."); + + Type = type; + Count = (uint)array.Length; + Length = (uint)(array.Length * Marshal.SizeOf(idList[type])); + data = new byte[Length]; + FreeImage.CopyMemory(data, array, Length); + } + + return FreeImage.SetTagValue(tag, data); + } + + private static bool CheckType(Type dataType, FREE_IMAGE_MDTYPE type) + { + if (dataType != null) + switch (type) + { + case FREE_IMAGE_MDTYPE.FIDT_ASCII: + return dataType == typeof(string); + case FREE_IMAGE_MDTYPE.FIDT_BYTE: + return dataType == typeof(byte); + case FREE_IMAGE_MDTYPE.FIDT_DOUBLE: + return dataType == typeof(double); + case FREE_IMAGE_MDTYPE.FIDT_FLOAT: + return dataType == typeof(float); + case FREE_IMAGE_MDTYPE.FIDT_IFD: + return dataType == typeof(uint); + case FREE_IMAGE_MDTYPE.FIDT_LONG: + return dataType == typeof(uint); + case FREE_IMAGE_MDTYPE.FIDT_NOTYPE: + return false; + case FREE_IMAGE_MDTYPE.FIDT_PALETTE: + return dataType == typeof(RGBQUAD); + case FREE_IMAGE_MDTYPE.FIDT_RATIONAL: + return dataType == typeof(FIURational); + case FREE_IMAGE_MDTYPE.FIDT_SBYTE: + return dataType == typeof(sbyte); + case FREE_IMAGE_MDTYPE.FIDT_SHORT: + return dataType == typeof(ushort); + case FREE_IMAGE_MDTYPE.FIDT_SLONG: + return dataType == typeof(int); + case FREE_IMAGE_MDTYPE.FIDT_SRATIONAL: + return dataType == typeof(FIRational); + case FREE_IMAGE_MDTYPE.FIDT_SSHORT: + return dataType == typeof(short); + case FREE_IMAGE_MDTYPE.FIDT_UNDEFINED: + return dataType == typeof(byte); + } + return false; + } + + /// + /// Add this metadata to an image. + /// + /// Handle to a FreeImage bitmap. + /// True on success, false on failure. + public bool AddToImage(FIBITMAP dib) + { + CheckDisposed(); + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (Key == null) + { + throw new ArgumentNullException("Key"); + } + if (!selfCreated) + { + tag = FreeImage.CloneTag(tag); + if (tag.IsNull) + { + throw new Exception("FreeImage.CloneTag() failed."); + } + selfCreated = true; + } + if (!FreeImage.SetMetadata(Model, dib, Key, tag)) + { + return false; + } + FREE_IMAGE_MDMODEL _model = Model; + string _key = Key; + selfCreated = false; + FreeImage.DeleteTag(tag); + return FreeImage.GetMetadata(_model, dib, _key, out tag); + } + + /// + /// Gets a .NET PropertyItem for this metadata tag. + /// + /// The .NET PropertyItem. + public unsafe System.Drawing.Imaging.PropertyItem GetPropertyItem() + { + System.Drawing.Imaging.PropertyItem item = FreeImage.CreatePropertyItem(); + item.Id = ID; + item.Len = (int)Length; + item.Type = (short)Type; + FreeImage.CopyMemory(item.Value = new byte[item.Len], FreeImage.GetTagValue(tag), item.Len); + return item; + } + + /// + /// Converts the value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + CheckDisposed(); + string fiString = FreeImage.TagToString(model, tag, 0); + + if (String.IsNullOrEmpty(fiString)) + { + return tag.ToString(); + } + else + { + return fiString; + } + } + + /// + /// Creates a deep copy of this . + /// + /// A deep copy of this . + public object Clone() + { + CheckDisposed(); + MetadataTag clone = new MetadataTag(); + clone.model = model; + clone.tag = FreeImage.CloneTag(tag); + clone.selfCreated = true; + return clone; + } + + /// + /// Tests whether the specified object is a instance + /// and is equivalent to this instance. + /// + /// The object to test. + /// true if is a instance + /// equivalent to this instance; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is MetadataTag) && (Equals((MetadataTag)obj))); + } + + /// + /// Tests whether the specified instance is equivalent to this instance. + /// + /// A instance to compare to this instance. + /// true if equivalent to this instance; + /// otherwise, false. + public bool Equals(MetadataTag other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return tag.GetHashCode(); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is MetadataTag)) + { + throw new ArgumentException("obj"); + } + return CompareTo((MetadataTag)obj); + } + + /// + /// Compares the current instance with another object of the same type. + /// + /// An object to compare with this instance. + /// A 32-bit signed integer that indicates the relative order of the objects being compared. + public int CompareTo(MetadataTag other) + { + CheckDisposed(); + other.CheckDisposed(); + return tag.CompareTo(other.tag); + } + + /// + /// Releases all resources used by the instance. + /// + public void Dispose() + { + if (!disposed) + { + disposed = true; + if (selfCreated) + { + FreeImage.DeleteTag(tag); + tag = FITAG.Zero; + } + } + } + + /// + /// Gets whether this instance has already been disposed. + /// + public bool Disposed + { + get { return disposed; } + } + + /// + /// Throwns an in case + /// this instance has already been disposed. + /// + private void CheckDisposed() + { + if (disposed) + { + throw new ObjectDisposedException("The object has already been disposed."); + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/Palette.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/Palette.cs new file mode 100644 index 0000000..c5cdfbe --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/Palette.cs @@ -0,0 +1,422 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Drawing; +using System.IO; +using FreeImageAPI.Metadata; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace FreeImageAPI +{ + /// + /// Provides methods for working with the standard bitmap palette. + /// + public sealed class Palette : MemoryArray + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private GCHandle paletteHandle; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private RGBQUAD[] array; + + /// + /// Initializes a new instance for the given FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// is null. + /// is not + /// -or- + /// has more than 8bpp. + public Palette(FIBITMAP dib) + : base(FreeImage.GetPalette(dib), (int)FreeImage.GetColorsUsed(dib)) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (FreeImage.GetImageType(dib) != FREE_IMAGE_TYPE.FIT_BITMAP) + { + throw new ArgumentException("dib"); + } + if (FreeImage.GetBPP(dib) > 8u) + { + throw new ArgumentException("dib"); + } + } + + /// + /// Initializes a new instance for the given FITAG that contains + /// a palette. + /// + /// The tag containing the palette. + /// is null. + /// is not + /// . + public Palette(FITAG tag) + : base(FreeImage.GetTagValue(tag), (int)FreeImage.GetTagCount(tag)) + { + if (FreeImage.GetTagType(tag) != FREE_IMAGE_MDTYPE.FIDT_PALETTE) + { + throw new ArgumentException("tag"); + } + } + + /// + /// Initializes a new instance for the given MetadataTag that contains + /// a palette. + /// + /// The tag containing the palette. + /// is null. + /// is not + /// . + public Palette(MetadataTag tag) + : base(FreeImage.GetTagValue(tag.tag), (int)tag.Count) + { + if (FreeImage.GetTagType(tag) != FREE_IMAGE_MDTYPE.FIDT_PALETTE) + { + throw new ArgumentException("tag"); + } + } + + /// + /// Initializes a new instance for the given array of that contains + /// a palette. + /// + /// A RGBQUAD array containing the palette data to initialize this instance. + public Palette(RGBQUAD[] palette) + { + unsafe + { + this.array = (RGBQUAD[])palette.Clone(); + this.paletteHandle = GCHandle.Alloc(array, GCHandleType.Pinned); + + base.baseAddress = (byte*)this.paletteHandle.AddrOfPinnedObject(); + base.length = (int)this.array.Length; + + // Create an array containing a single element. + // Due to the fact, that it's not possible to create pointers + // of generic types, an array is used to obtain the memory + // address of an element of T. + base.buffer = new RGBQUAD[1]; + // The array is pinned immediately to prevent the GC from + // moving it to a different position in memory. + base.handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + // The array and its content have beed pinned, so that its address + // can be safely requested and stored for the whole lifetime + // of the instace. + base.ptr = (byte*)base.handle.AddrOfPinnedObject(); + } + } + + /// + /// Initializes a new instance for the given array of that contains + /// a palette. + /// + /// A Color array containing the palette data to initialize this instance. + public Palette(Color[] palette) + : this(RGBQUAD.ToRGBQUAD(palette)) + { + } + + /// + /// Initializes a new instance with the specified size. + /// + /// The size of the palette. + public Palette(int size) + : this(new RGBQUAD[size]) + { + } + + /// + /// Gets or sets the palette through an array of . + /// + public RGBQUAD[] AsArray + { + get + { + return Data; + } + set + { + Data = value; + } + } + + /// + /// Get an array of that the block of memory represents. + /// This property is used for internal palette operations. + /// + internal unsafe Color[] ColorData + { + get + { + EnsureNotDisposed(); + Color[] data = new Color[length]; + for (int i = 0; i < length; i++) + { + data[i] = Color.FromArgb((int)(((uint*)baseAddress)[i] | 0xFF000000)); + } + return data; + } + } + + /// + /// Returns the palette as an array of . + /// + /// The palette as an array of . + public RGBQUAD[] ToArray() + { + return Data; + } + + /// + /// Creates a linear palette based on the provided . + /// + /// The used to colorize the palette. + /// + /// Only call this method on linear palettes. + /// + public void Colorize(Color color) + { + Colorize(color, 0.5d); + } + + /// + /// Creates a linear palette based on the provided . + /// + /// The used to colorize the palette. + /// The position of the color within the new palette. + /// 0 < < 1. + /// + /// Only call this method on linear palettes. + /// + public void Colorize(Color color, double splitSize) + { + Colorize(color, (int)(length * splitSize)); + } + + /// + /// Creates a linear palette based on the provided . + /// + /// The used to colorize the palette. + /// The position of the color within the new palette. + /// 0 < < . + /// + /// Only call this method on linear palettes. + /// + public void Colorize(Color color, int splitSize) + { + EnsureNotDisposed(); + if (splitSize < 1 || splitSize >= length) + { + throw new ArgumentOutOfRangeException("splitSize"); + } + + RGBQUAD[] pal = new RGBQUAD[length]; + + double red = color.R; + double green = color.G; + double blue = color.B; + + int i = 0; + double r, g, b; + + r = red / splitSize; + g = green / splitSize; + b = blue / splitSize; + + for (; i <= splitSize; i++) + { + pal[i].rgbRed = (byte)(i * r); + pal[i].rgbGreen = (byte)(i * g); + pal[i].rgbBlue = (byte)(i * b); + } + + r = (255 - red) / (length - splitSize); + g = (255 - green) / (length - splitSize); + b = (255 - blue) / (length - splitSize); + + for (; i < length; i++) + { + pal[i].rgbRed = (byte)(red + ((i - splitSize) * r)); + pal[i].rgbGreen = (byte)(green + ((i - splitSize) * g)); + pal[i].rgbBlue = (byte)(blue + ((i - splitSize) * b)); + } + + Data = pal; + } + + /// + /// Creates a linear grayscale palette. + /// + public void CreateGrayscalePalette() + { + Colorize(Color.White, length - 1); + } + + /// + /// Creates a linear grayscale palette. + /// + /// true to create an inverse grayscale palette. + public void CreateGrayscalePalette(bool inverse) + { + Colorize(Color.White, inverse ? 0 : length - 1); + } + + /// + /// Creates a linear palette with the specified . + /// + /// + /// A linear grayscale palette contains all shades of colors from + /// black to white. This method creates a similar palette with the white + /// color being replaced by the specified color. + /// + /// The used to create the palette. + /// true to create an inverse palette. + public void CreateGrayscalePalette(Color color, bool inverse) + { + Colorize(color, inverse ? 0 : length - 1); + } + + /// + /// Reverses the palette. + /// + public void Reverse() + { + EnsureNotDisposed(); + if (array != null) + { + Array.Reverse(array); + } + else + { + RGBQUAD[] localArray = Data; + Array.Reverse(localArray); + Data = localArray; + } + } + + /// + /// Copies the values from the specified to this instance. + /// + /// The palette to copy from. + /// + /// is a null reference. + public void CopyFrom(Palette palette) + { + EnsureNotDisposed(); + if (palette == null) + { + throw new ArgumentNullException("palette"); + } + CopyFrom(palette.Data, 0, 0, Math.Min(palette.Length, this.Length)); + } + + /// + /// Copies the values from the specified to this instance, + /// starting at the specified . + /// + /// The palette to copy from. + /// The position in this instance where the values + /// will be copied to. + /// + /// is a null reference. + /// + /// is outside the range of valid indexes. + public void CopyFrom(Palette palette, int offset) + { + EnsureNotDisposed(); + CopyFrom(palette.Data, 0, offset, Math.Min(palette.Length, this.Length - offset)); + } + + /// + /// Saves this to the specified file. + /// + /// + /// A string that contains the name of the file to which to save this . + /// + public void Save(string filename) + { + using (Stream stream = new FileStream(filename, FileMode.Create, FileAccess.Write)) + { + Save(stream); + } + } + + /// + /// Saves this to the specified stream. + /// + /// + /// The where the image will be saved. + /// + public void Save(Stream stream) + { + Save(new BinaryWriter(stream)); + } + + /// + /// Saves this using the specified writer. + /// + /// + /// The used to save the image. + /// + public void Save(BinaryWriter writer) + { + EnsureNotDisposed(); + writer.Write(ToByteArray()); + } + + /// + /// Loads a palette from the specified file. + /// + /// The name of the palette file. + public void Load(string filename) + { + using (Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read)) + { + Load(stream); + } + } + + /// + /// Loads a palette from the specified stream. + /// + /// The stream to load the palette from. + public void Load(Stream stream) + { + Load(new BinaryReader(stream)); + } + + /// + /// Loads a palette from the reader. + /// + /// The reader to load the palette from. + public void Load(BinaryReader reader) + { + EnsureNotDisposed(); + unsafe + { + int size = length * sizeof(RGBQUAD); + byte[] data = reader.ReadBytes(size); + fixed (byte* src = data) + { + CopyMemory(baseAddress, src, data.Length); + } + } + } + + /// + /// Releases allocated handles associated with this instance. + /// + /// true to release managed resources. + protected override void Dispose(bool disposing) + { + if (paletteHandle.IsAllocated) + paletteHandle.Free(); + array = null; + + base.Dispose(disposing); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/PluginRepository.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/PluginRepository.cs new file mode 100644 index 0000000..cc658a7 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/PluginRepository.cs @@ -0,0 +1,449 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; + +namespace FreeImageAPI.Plugins +{ + /// + /// Class representing all registered in FreeImage. + /// + public static class PluginRepository + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly List plugins = null; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly List localPlugins = null; + + static PluginRepository() + { + plugins = new List(FreeImage.GetFIFCount()); + localPlugins = new List(0); + for (int i = 0; i < plugins.Capacity; i++) + { + plugins.Add(new FreeImagePlugin((FREE_IMAGE_FORMAT)i)); + } + } + + /// + /// Adds local plugin to this class. + /// + /// The registered plugin. + internal static void RegisterLocalPlugin(LocalPlugin localPlugin) + { + FreeImagePlugin plugin = new FreeImagePlugin(localPlugin.Format); + plugins.Add(plugin); + localPlugins.Add(plugin); + } + + /// + /// Returns an instance of , representing the given format. + /// + /// The representing format. + /// An instance of . + public static FreeImagePlugin Plugin(FREE_IMAGE_FORMAT fif) + { + return Plugin((int)fif); + } + + /// + /// Returns an instance of , + /// representing the format at the given index. + /// + /// The index of the representing format. + /// An instance of . + public static FreeImagePlugin Plugin(int index) + { + return (index >= 0) ? plugins[index] : null; + } + + /// + /// Returns an instance of . + /// is searched in: + /// Format, RegExpr, + /// ValidExtension and ValidFilename. + /// + /// The expression to search for. + /// An instance of . + public static FreeImagePlugin Plugin(string expression) + { + FreeImagePlugin result = null; + expression = expression.ToLower(); + + foreach (FreeImagePlugin plugin in plugins) + { + if (plugin.Format.ToLower().Contains(expression) || + plugin.RegExpr.ToLower().Contains(expression) || + plugin.ValidExtension(expression, StringComparison.CurrentCultureIgnoreCase) || + plugin.ValidFilename(expression, StringComparison.CurrentCultureIgnoreCase)) + { + result = plugin; + break; + } + } + + return result; + } + + /// + /// Returns an instance of for the given format. + /// + /// The format of the Plugin. + /// An instance of . + public static FreeImagePlugin PluginFromFormat(string format) + { + return Plugin(FreeImage.GetFIFFromFormat(format)); + } + + /// + /// Returns an instance of for the given filename. + /// + /// The valid filename for the plugin. + /// An instance of . + public static FreeImagePlugin PluginFromFilename(string filename) + { + return Plugin(FreeImage.GetFIFFromFilename(filename)); + } + + /// + /// Returns an instance of for the given mime. + /// + /// The valid mime for the plugin. + /// An instance of . + public static FreeImagePlugin PluginFromMime(string mime) + { + return Plugin(FreeImage.GetFIFFromMime(mime)); + } + + /// + /// Gets the number of registered plugins. + /// + public static int FIFCount + { + get + { + return FreeImage.GetFIFCount(); + } + } + + /// + /// Gets a readonly collection of all plugins. + /// + public static ReadOnlyCollection PluginList + { + get + { + return plugins.AsReadOnly(); + } + } + + /// + /// Gets a list of plugins that are only able to + /// read but not to write. + /// + public static List ReadOnlyPlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (p.SupportsReading && !p.SupportsWriting) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Gets a list of plugins that are only able to + /// write but not to read. + /// + public static List WriteOnlyPlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (!p.SupportsReading && p.SupportsWriting) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Gets a list of plugins that are not able to + /// read or write. + /// + public static List StupidPlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (!p.SupportsReading && !p.SupportsWriting) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Gets a list of plugins that are able to read. + /// + public static List ReadablePlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (p.SupportsReading) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Gets a list of plugins that are able to write. + /// + public static List WriteablePlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (p.SupportsWriting) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Gets a list of local plugins. + /// + public static ReadOnlyCollection LocalPlugins + { + get + { + return localPlugins.AsReadOnly(); + } + } + + /// + /// Gets a list of built-in plugins. + /// + public static List BuiltInPlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (!localPlugins.Contains(p)) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Windows or OS/2 Bitmap File (*.BMP) + /// + public static FreeImagePlugin BMP { get { return plugins[0]; } } + + /// + /// Independent JPEG Group (*.JPG, *.JIF, *.JPEG, *.JPE) + /// + public static FreeImagePlugin ICO { get { return plugins[1]; } } + + /// + /// Independent JPEG Group (*.JPG, *.JIF, *.JPEG, *.JPE) + /// + public static FreeImagePlugin JPEG { get { return plugins[2]; } } + + /// + /// JPEG Network Graphics (*.JNG) + /// + public static FreeImagePlugin JNG { get { return plugins[3]; } } + + /// + /// Commodore 64 Koala format (*.KOA) + /// + public static FreeImagePlugin KOALA { get { return plugins[4]; } } + + /// + /// Amiga IFF (*.IFF, *.LBM) + /// + public static FreeImagePlugin LBM { get { return plugins[5]; } } + + /// + /// Amiga IFF (*.IFF, *.LBM) + /// + public static FreeImagePlugin IFF { get { return plugins[5]; } } + + /// + /// Multiple Network Graphics (*.MNG) + /// + public static FreeImagePlugin MNG { get { return plugins[6]; } } + + /// + /// Portable Bitmap (ASCII) (*.PBM) + /// + public static FreeImagePlugin PBM { get { return plugins[7]; } } + + /// + /// Portable Bitmap (BINARY) (*.PBM) + /// + public static FreeImagePlugin PBMRAW { get { return plugins[8]; } } + + /// + /// Kodak PhotoCD (*.PCD) + /// + public static FreeImagePlugin PCD { get { return plugins[9]; } } + + /// + /// Zsoft Paintbrush PCX bitmap format (*.PCX) + /// + public static FreeImagePlugin PCX { get { return plugins[10]; } } + + /// + /// Portable Graymap (ASCII) (*.PGM) + /// + public static FreeImagePlugin PGM { get { return plugins[11]; } } + + /// + /// Portable Graymap (BINARY) (*.PGM) + /// + public static FreeImagePlugin PGMRAW { get { return plugins[12]; } } + + /// + /// Portable Network Graphics (*.PNG) + /// + public static FreeImagePlugin PNG { get { return plugins[13]; } } + + /// + /// Portable Pixelmap (ASCII) (*.PPM) + /// + public static FreeImagePlugin PPM { get { return plugins[14]; } } + + /// + /// Portable Pixelmap (BINARY) (*.PPM) + /// + public static FreeImagePlugin PPMRAW { get { return plugins[15]; } } + + /// + /// Sun Rasterfile (*.RAS) + /// + public static FreeImagePlugin RAS { get { return plugins[16]; } } + + /// + /// truevision Targa files (*.TGA, *.TARGA) + /// + public static FreeImagePlugin TARGA { get { return plugins[17]; } } + + /// + /// Tagged Image File Format (*.TIF, *.TIFF) + /// + public static FreeImagePlugin TIFF { get { return plugins[18]; } } + + /// + /// Wireless Bitmap (*.WBMP) + /// + public static FreeImagePlugin WBMP { get { return plugins[19]; } } + + /// + /// Adobe Photoshop (*.PSD) + /// + public static FreeImagePlugin PSD { get { return plugins[20]; } } + + /// + /// Dr. Halo (*.CUT) + /// + public static FreeImagePlugin CUT { get { return plugins[21]; } } + + /// + /// X11 Bitmap Format (*.XBM) + /// + public static FreeImagePlugin XBM { get { return plugins[22]; } } + + /// + /// X11 Pixmap Format (*.XPM) + /// + public static FreeImagePlugin XPM { get { return plugins[23]; } } + + /// + /// DirectDraw Surface (*.DDS) + /// + public static FreeImagePlugin DDS { get { return plugins[24]; } } + + /// + /// Graphics Interchange Format (*.GIF) + /// + public static FreeImagePlugin GIF { get { return plugins[25]; } } + + /// + /// High Dynamic Range (*.HDR) + /// + public static FreeImagePlugin HDR { get { return plugins[26]; } } + + /// + /// Raw Fax format CCITT G3 (*.G3) + /// + public static FreeImagePlugin FAXG3 { get { return plugins[27]; } } + + /// + /// Silicon Graphics SGI image format (*.SGI) + /// + public static FreeImagePlugin SGI { get { return plugins[28]; } } + + /// + /// OpenEXR format (*.EXR) + /// + public static FreeImagePlugin EXR { get { return plugins[29]; } } + + /// + /// JPEG-2000 format (*.J2K, *.J2C) + /// + public static FreeImagePlugin J2K { get { return plugins[30]; } } + + /// + /// JPEG-2000 format (*.JP2) + /// + public static FreeImagePlugin JP2 { get { return plugins[31]; } } + + /// + /// Portable FloatMap (*.PFM) + /// + public static FreeImagePlugin PFM { get { return plugins[32]; } } + + /// + /// Macintosh PICT (*.PICT) + /// + public static FreeImagePlugin PICT { get { return plugins[33]; } } + + /// + /// RAW camera image (*.*) + /// + public static FreeImagePlugin RAW { get { return plugins[34]; } } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/Scanline.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/Scanline.cs new file mode 100644 index 0000000..6ad592d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/Scanline.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// Provides methods for working with generic bitmap scanlines. + /// + /// Type of the bitmaps' scanlines. + public sealed class Scanline : MemoryArray where T : struct + { + /// + /// Initializes a new instance based on the specified FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + public Scanline(FIBITMAP dib) + : this(dib, 0) + { + } + + /// + /// Initializes a new instance based on the specified FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Index of the zero based scanline. + public Scanline(FIBITMAP dib, int scanline) + : this(dib, scanline, (int)(typeof(T) == typeof(FI1BIT) ? + FreeImage.GetBPP(dib) * FreeImage.GetWidth(dib) : + typeof(T) == typeof(FI4BIT) ? + FreeImage.GetBPP(dib) * FreeImage.GetWidth(dib) / 4 : + (FreeImage.GetBPP(dib) * FreeImage.GetWidth(dib)) / (Marshal.SizeOf(typeof(T)) * 8))) + { + } + + internal Scanline(FIBITMAP dib, int scanline, int length) + : base(FreeImage.GetScanLine(dib, scanline), length) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if ((scanline < 0) || (scanline >= FreeImage.GetHeight(dib))) + { + throw new ArgumentOutOfRangeException("scanline"); + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/StreamWrapper.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/StreamWrapper.cs new file mode 100644 index 0000000..2b8cba7 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Classes/StreamWrapper.cs @@ -0,0 +1,312 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.6 $ +// $Date: 2009/02/23 12:28:56 $ +// $Id: StreamWrapper.cs,v 1.6 2009/02/23 12:28:56 cklein05 Exp $ +// ========================================================== + +using System; +using System.IO; +using System.Diagnostics; + +namespace FreeImageAPI.IO +{ + /// + /// Class wrapping streams, implementing a buffer for read data, + /// so that seek operations can be made. + /// + /// + /// FreeImage can load bitmaps from arbitrary sources. + /// .NET works with different streams like File- or NetConnection-strams. + /// NetConnection streams, which are used to load files from web servers, + /// for example cannot seek. + /// But FreeImage frequently uses the seek operation when loading bitmaps. + /// StreamWrapper wrapps a stream and makes it seekable by caching all read + /// data into an internal MemoryStream to jump back- and forward. + /// StreamWapper is for internal use and only for loading from streams. + /// + internal class StreamWrapper : Stream + { + /// + /// The stream to wrap + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly Stream stream; + + /// + /// The caching stream + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private MemoryStream memoryStream = new MemoryStream(); + + /// + /// Indicates if the wrapped stream reached its end + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool eos = false; + + /// + /// Tells the wrapper to block readings or not + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool blocking = false; + + /// + /// Indicates if the wrapped stream is disposed or not + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool disposed = false; + + /// + /// Initializes a new instance based on the specified . + /// + /// The stream to wrap. + /// When true the wrapper always tries to read the requested + /// amount of data from the wrapped stream. + public StreamWrapper(Stream stream, bool blocking) + { + if (!stream.CanRead) + { + throw new ArgumentException("stream is not capable of reading."); + } + this.stream = stream; + this.blocking = blocking; + } + + /// + /// Releases all resources used by the instance. + /// + ~StreamWrapper() + { + Dispose(false); + } + + // The wrapper only accepts readable streams + public override bool CanRead + { + get { checkDisposed(); return true; } + } + + // We implement that feature + public override bool CanSeek + { + get { checkDisposed(); return true; } + } + + // The wrapper is readonly + public override bool CanWrite + { + get { checkDisposed(); return false; } + } + + // Just forward it + public override void Flush() + { + checkDisposed(); + stream.Flush(); + } + + // Calling this property will cause the wrapper to read the stream + // to its end and cache it completely. + public override long Length + { + get + { + checkDisposed(); + if (!eos) + { + Fill(); + } + return memoryStream.Length; + } + } + + // Gets or sets the current position + public override long Position + { + get + { + checkDisposed(); + return memoryStream.Position; + } + set + { + checkDisposed(); + Seek(value, SeekOrigin.Begin); + } + } + + // Implements the reading feature + public override int Read(byte[] buffer, int offset, int count) + { + checkDisposed(); + // total bytes read from memory-stream + int memoryBytes = 0; + // total bytes read from the original stream + int streamBytes = 0; + memoryBytes = memoryStream.Read(buffer, offset, count); + if ((count > memoryBytes) && (!eos)) + { + // read the rest from the original stream (can be 0 bytes) + do + { + int read = stream.Read( + buffer, + offset + memoryBytes + streamBytes, + count - memoryBytes - streamBytes); + streamBytes += read; + if (read == 0) + { + eos = true; + break; + } + if (!blocking) + { + break; + } + } while ((memoryBytes + streamBytes) < count); + // copy the bytes from the original stream into the memory stream + // if 0 bytes were read we write 0 so the memory-stream is not changed + memoryStream.Write(buffer, offset + memoryBytes, streamBytes); + } + return memoryBytes + streamBytes; + } + + // Implements the seeking feature + public override long Seek(long offset, SeekOrigin origin) + { + checkDisposed(); + long newPosition = 0L; + // get new position + switch (origin) + { + case SeekOrigin.Begin: + newPosition = offset; + break; + case SeekOrigin.Current: + newPosition = memoryStream.Position + offset; + break; + case SeekOrigin.End: + // to seek from the end have have to read to the end first + if (!eos) + { + Fill(); + } + newPosition = memoryStream.Length + offset; + break; + default: + throw new ArgumentOutOfRangeException("origin"); + } + // in case the new position is beyond the memory-streams end + // and the original streams end hasn't been reached + // the original stream is read until either the stream ends or + // enough bytes have been read + if ((newPosition > memoryStream.Length) && (!eos)) + { + memoryStream.Position = memoryStream.Length; + int bytesToRead = (int)(newPosition - memoryStream.Length); + byte[] buffer = new byte[1024]; + do + { + bytesToRead -= Read(buffer, 0, (bytesToRead >= buffer.Length) ? buffer.Length : bytesToRead); + } while ((bytesToRead > 0) && (!eos)); + } + memoryStream.Position = (newPosition <= memoryStream.Length) ? newPosition : memoryStream.Length; + return 0; + } + + // No write-support + public override void SetLength(long value) + { + throw new Exception("The method or operation is not implemented."); + } + + // No write-support + public override void Write(byte[] buffer, int offset, int count) + { + throw new Exception("The method or operation is not implemented."); + } + + public void Reset() + { + checkDisposed(); + Position = 0; + } + + // Reads the wrapped stream until its end. + private void Fill() + { + if (!eos) + { + memoryStream.Position = memoryStream.Length; + int bytesRead = 0; + byte[] buffer = new byte[1024]; + do + { + bytesRead = stream.Read(buffer, 0, buffer.Length); + memoryStream.Write(buffer, 0, bytesRead); + } while (bytesRead != 0); + eos = true; + } + } + + public new void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private new void Dispose(bool disposing) + { + if (!disposed) + { + disposed = true; + if (disposing) + { + if (memoryStream != null) + { + memoryStream.Dispose(); + } + } + } + } + + public bool Disposed + { + get { return disposed; } + } + + private void checkDisposed() + { + if (disposed) throw new ObjectDisposedException("StreamWrapper"); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Delegates.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Delegates.cs new file mode 100644 index 0000000..ff8847e --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Delegates.cs @@ -0,0 +1,191 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.4 $ +// $Date: 2009/09/15 11:39:10 $ +// $Id: Delegates.cs,v 1.4 2009/09/15 11:39:10 cklein05 Exp $ +// ========================================================== + +using System; +using System.IO; +using System.Runtime.InteropServices; +using FreeImageAPI.IO; + +namespace FreeImageAPI +{ + // Delegates used by the FreeImageIO structure + + /// + /// Delegate for capturing FreeImage error messages. + /// + /// The format of the image. + /// The errormessage. + // DLL_API is missing in the definition of the callbackfuntion. + [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi, ThrowOnUnmappableChar = false)] + public delegate void OutputMessageFunction(FREE_IMAGE_FORMAT fif, string message); +} + +namespace FreeImageAPI.IO +{ + /// + /// Delegate to the C++ function fread. + /// + /// Pointer to read from. + /// Item size in bytes. + /// Maximum number of items to be read. + /// Handle/stream to read from. + /// Number of full items actually read, + /// which may be less than count if an error occurs or + /// if the end of the file is encountered before reaching count. + public delegate uint ReadProc(IntPtr buffer, uint size, uint count, fi_handle handle); + + /// + /// Delegate to the C++ function fwrite. + /// + /// Pointer to data to be written. + /// Item size in bytes. + /// Maximum number of items to be written. + /// Handle/stream to write to. + /// Number of full items actually written, + /// which may be less than count if an error occurs. + /// Also, if an error occurs, the file-position indicator cannot be determined. + public delegate uint WriteProc(IntPtr buffer, uint size, uint count, fi_handle handle); + + /// + /// Delegate to the C++ function fseek. + /// + /// Handle/stream to seek in. + /// Number of bytes from origin. + /// Initial position. + /// If successful 0 is returned; otherwise a nonzero value. + public delegate int SeekProc(fi_handle handle, int offset, SeekOrigin origin); + + /// + /// Delegate to the C++ function ftell. + /// + /// Handle/stream to retrieve its currents position from. + /// The current position. + public delegate int TellProc(fi_handle handle); + + // Delegates used by 'Plugin' structure +} + +namespace FreeImageAPI.Plugins +{ + /// + /// Delegate to a function that returns a string which describes + /// the plugins format. + /// + public delegate string FormatProc(); + + /// + /// Delegate to a function that returns a string which contains + /// a more detailed description. + /// + public delegate string DescriptionProc(); + + /// + /// Delegate to a function that returns a comma seperated list + /// of file extensions the plugin can read or write. + /// + public delegate string ExtensionListProc(); + + /// + /// Delegate to a function that returns a regular expression that + /// can be used to idientify whether a file can be handled by the plugin. + /// + public delegate string RegExprProc(); + + /// + /// Delegate to a function that opens a file. + /// + public delegate IntPtr OpenProc(ref FreeImageIO io, fi_handle handle, bool read); + + /// + /// Delegate to a function that closes a previosly opened file. + /// + public delegate void CloseProc(ref FreeImageIO io, fi_handle handle, IntPtr data); + + /// + /// Delegate to a function that returns the number of pages of a multipage + /// bitmap if the plugin is capable of handling multipage bitmaps. + /// + public delegate int PageCountProc(ref FreeImageIO io, fi_handle handle, IntPtr data); + + /// + /// UNKNOWN + /// + public delegate int PageCapabilityProc(ref FreeImageIO io, fi_handle handle, IntPtr data); + + /// + /// Delegate to a function that loads and decodes a bitmap into memory. + /// + public delegate FIBITMAP LoadProc(ref FreeImageIO io, fi_handle handle, int page, int flags, IntPtr data); + + /// + /// Delegate to a function that saves a bitmap. + /// + public delegate bool SaveProc(ref FreeImageIO io, FIBITMAP dib, fi_handle handle, int page, int flags, IntPtr data); + + /// + /// Delegate to a function that determines whether the source defined + /// by and is a valid image. + /// + public delegate bool ValidateProc(ref FreeImageIO io, fi_handle handle); + + /// + /// Delegate to a function that returns a string which contains + /// the plugin's mime type. + /// + public delegate string MimeProc(); + + /// + /// Delegate to a function that returns whether the plugin can handle the + /// specified color depth. + /// + public delegate bool SupportsExportBPPProc(int bpp); + + /// + /// Delegate to a function that returns whether the plugin can handle the + /// specified image type. + /// + public delegate bool SupportsExportTypeProc(FREE_IMAGE_TYPE type); + + /// + /// Delegate to a function that returns whether the plugin can handle + /// ICC-Profiles. + /// + public delegate bool SupportsICCProfilesProc(); + + /// + /// Callback function used by FreeImage to register plugins. + /// + public delegate void InitProc(ref Plugin plugin, int format_id); +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/DisposalMethodType.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/DisposalMethodType.cs new file mode 100644 index 0000000..ac2c1ee --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/DisposalMethodType.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace FreeImageAPI.Metadata +{ + /// + /// Specifies how a single frame will be handled after being displayed. + /// + public enum DisposalMethodType : byte + { + /// + /// Same behavior as but should not be used. + /// + Unspecified, + + /// + /// The image is left in place and will be overdrawn by the next image. + /// + Leave, + + /// + /// The area of the image will be blanked out by its background. + /// + Background, + + /// + /// Restores the the area of the image to the state it was before it + /// has been dawn. + /// + Previous, + } +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_CHANNEL.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_CHANNEL.cs new file mode 100644 index 0000000..859b7d1 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_CHANNEL.cs @@ -0,0 +1,84 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:40 $ +// $Id: FREE_IMAGE_COLOR_CHANNEL.cs,v 1.1 2007/11/28 15:33:40 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Color channels. Constants used in color manipulation routines. + /// + public enum FREE_IMAGE_COLOR_CHANNEL + { + /// + /// Use red, green and blue channels + /// + FICC_RGB = 0, + /// + /// Use red channel + /// + FICC_RED = 1, + /// + /// Use green channel + /// + FICC_GREEN = 2, + /// + /// Use blue channel + /// + FICC_BLUE = 3, + /// + /// Use alpha channel + /// + FICC_ALPHA = 4, + /// + /// Use black channel + /// + FICC_BLACK = 5, + /// + /// Complex images: use real part + /// + FICC_REAL = 6, + /// + /// Complex images: use imaginary part + /// + FICC_IMAG = 7, + /// + /// Complex images: use magnitude + /// + FICC_MAG = 8, + /// + /// Complex images: use phase + /// + FICC_PHASE = 9 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_DEPTH.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_DEPTH.cs new file mode 100644 index 0000000..2479ce7 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_DEPTH.cs @@ -0,0 +1,105 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:39 $ +// $Id: FREE_IMAGE_COLOR_DEPTH.cs,v 1.1 2007/11/28 15:33:39 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Enumeration used for color conversions. + /// FREE_IMAGE_COLOR_DEPTH contains several colors to convert to. + /// The default value 'FICD_AUTO'. + /// + [System.Flags] + public enum FREE_IMAGE_COLOR_DEPTH + { + /// + /// Unknown. + /// + FICD_UNKNOWN = 0, + /// + /// Auto selected by the used algorithm. + /// + FICD_AUTO = FICD_UNKNOWN, + /// + /// 1-bit. + /// + FICD_01_BPP = 1, + /// + /// 1-bit using dithering. + /// + FICD_01_BPP_DITHER = FICD_01_BPP, + /// + /// 1-bit using threshold. + /// + FICD_01_BPP_THRESHOLD = FICD_01_BPP | 2, + /// + /// 4-bit. + /// + FICD_04_BPP = 4, + /// + /// 8-bit. + /// + FICD_08_BPP = 8, + /// + /// 16-bit 555 (1 bit remains unused). + /// + FICD_16_BPP_555 = FICD_16_BPP | 2, + /// + /// 16-bit 565 (all bits are used). + /// + FICD_16_BPP = 16, + /// + /// 24-bit. + /// + FICD_24_BPP = 24, + /// + /// 32-bit. + /// + FICD_32_BPP = 32, + /// + /// Reorder palette (make it linear). Only affects 1-, 4- and 8-bit images. + /// The palette is only reordered in case the image is greyscale + /// (all palette entries have the same red, green and blue value). + /// + FICD_REORDER_PALETTE = 1024, + /// + /// Converts the image to greyscale. + /// + FICD_FORCE_GREYSCALE = 2048, + /// + /// Flag to mask out all non color depth flags. + /// + FICD_COLOR_MASK = FICD_01_BPP | FICD_04_BPP | FICD_08_BPP | FICD_16_BPP | FICD_24_BPP | FICD_32_BPP + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_OPTIONS.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_OPTIONS.cs new file mode 100644 index 0000000..302f6bb --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_OPTIONS.cs @@ -0,0 +1,68 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2009/09/15 11:44:24 $ +// $Id: FREE_IMAGE_COLOR_OPTIONS.cs,v 1.1 2009/09/15 11:44:24 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Constants used in color filling routines. + /// + public enum FREE_IMAGE_COLOR_OPTIONS + { + /// + /// Default value. + /// + FICO_DEFAULT = 0x0, + /// + /// color is RGB color (contains no valid alpha channel). + /// + FICO_RGB = 0x0, + /// + /// color is RGBA color (contains a valid alpha channel). + /// + FICO_RGBA = 0x1, + /// + /// Lookup nearest RGB color from palette. + /// + FICO_NEAREST_COLOR = 0x0, + /// + /// Lookup equal RGB color from palette. + /// + FICO_EQUAL_COLOR = 0x2, + /// + /// contains the palette index to be used. + /// + FICO_ALPHA_IS_INDEX = 0x4, + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_TYPE.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_TYPE.cs new file mode 100644 index 0000000..f69c64d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COLOR_TYPE.cs @@ -0,0 +1,68 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:40 $ +// $Id: FREE_IMAGE_COLOR_TYPE.cs,v 1.1 2007/11/28 15:33:40 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Image color types used in FreeImage. + /// + public enum FREE_IMAGE_COLOR_TYPE + { + /// + /// min value is white + /// + FIC_MINISWHITE = 0, + /// + /// min value is black + /// + FIC_MINISBLACK = 1, + /// + /// RGB color model + /// + FIC_RGB = 2, + /// + /// color map indexed + /// + FIC_PALETTE = 3, + /// + /// RGB color model with alpha channel + /// + FIC_RGBALPHA = 4, + /// + /// CMYK color model + /// + FIC_CMYK = 5 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COMPARE_FLAGS.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COMPARE_FLAGS.cs new file mode 100644 index 0000000..69b3035 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_COMPARE_FLAGS.cs @@ -0,0 +1,65 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:40 $ +// $Id: FREE_IMAGE_COMPARE_FLAGS.cs,v 1.1 2007/11/28 15:33:40 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// List of combinable compare modes. + /// + [System.Flags] + public enum FREE_IMAGE_COMPARE_FLAGS + { + /// + /// Compare headers. + /// + HEADER = 0x1, + /// + /// Compare palettes. + /// + PALETTE = 0x2, + /// + /// Compare pixel data. + /// + DATA = 0x4, + /// + /// Compare meta data. + /// + METADATA = 0x8, + /// + /// Compare everything. + /// + COMPLETE = (HEADER | PALETTE | DATA | METADATA) + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_DITHER.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_DITHER.cs new file mode 100644 index 0000000..c1c87f8 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_DITHER.cs @@ -0,0 +1,73 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:40 $ +// $Id: FREE_IMAGE_DITHER.cs,v 1.1 2007/11/28 15:33:40 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Dithering algorithms. + /// Constants used in FreeImage_Dither. + /// + public enum FREE_IMAGE_DITHER + { + /// + /// Floyd and Steinberg error diffusion + /// + FID_FS = 0, + /// + /// Bayer ordered dispersed dot dithering (order 2 dithering matrix) + /// + FID_BAYER4x4 = 1, + /// + /// Bayer ordered dispersed dot dithering (order 3 dithering matrix) + /// + FID_BAYER8x8 = 2, + /// + /// Ordered clustered dot dithering (order 3 - 6x6 matrix) + /// + FID_CLUSTER6x6 = 3, + /// + /// Ordered clustered dot dithering (order 4 - 8x8 matrix) + /// + FID_CLUSTER8x8 = 4, + /// + /// Ordered clustered dot dithering (order 8 - 16x16 matrix) + /// + FID_CLUSTER16x16 = 5, + /// + /// Bayer ordered dispersed dot dithering (order 4 dithering matrix) + /// + FID_BAYER16x16 = 6 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_FILTER.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_FILTER.cs new file mode 100644 index 0000000..3d54566 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_FILTER.cs @@ -0,0 +1,68 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:39 $ +// $Id: FREE_IMAGE_FILTER.cs,v 1.1 2007/11/28 15:33:39 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Upsampling / downsampling filters. Constants used in FreeImage_Rescale. + /// + public enum FREE_IMAGE_FILTER + { + /// + /// Box, pulse, Fourier window, 1st order (constant) b-spline + /// + FILTER_BOX = 0, + /// + /// Mitchell and Netravali's two-param cubic filter + /// + FILTER_BICUBIC = 1, + /// + /// Bilinear filter + /// + FILTER_BILINEAR = 2, + /// + /// 4th order (cubic) b-spline + /// + FILTER_BSPLINE = 3, + /// + /// Catmull-Rom spline, Overhauser spline + /// + FILTER_CATMULLROM = 4, + /// + /// Lanczos3 filter + /// + FILTER_LANCZOS3 = 5 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_FORMAT.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_FORMAT.cs new file mode 100644 index 0000000..e57fb0e --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_FORMAT.cs @@ -0,0 +1,192 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.2 $ +// $Date: 2009/09/15 11:44:42 $ +// $Id: FREE_IMAGE_FORMAT.cs,v 1.2 2009/09/15 11:44:42 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// I/O image format identifiers. + /// + public enum FREE_IMAGE_FORMAT + { + /// + /// Unknown format (returned value only, never use it as input value) + /// + FIF_UNKNOWN = -1, + /// + /// Windows or OS/2 Bitmap File (*.BMP) + /// + FIF_BMP = 0, + /// + /// Windows Icon (*.ICO) + /// + FIF_ICO = 1, + /// + /// Independent JPEG Group (*.JPG, *.JIF, *.JPEG, *.JPE) + /// + FIF_JPEG = 2, + /// + /// JPEG Network Graphics (*.JNG) + /// + FIF_JNG = 3, + /// + /// Commodore 64 Koala format (*.KOA) + /// + FIF_KOALA = 4, + /// + /// Amiga IFF (*.IFF, *.LBM) + /// + FIF_LBM = 5, + /// + /// Amiga IFF (*.IFF, *.LBM) + /// + FIF_IFF = 5, + /// + /// Multiple Network Graphics (*.MNG) + /// + FIF_MNG = 6, + /// + /// Portable Bitmap (ASCII) (*.PBM) + /// + FIF_PBM = 7, + /// + /// Portable Bitmap (BINARY) (*.PBM) + /// + FIF_PBMRAW = 8, + /// + /// Kodak PhotoCD (*.PCD) + /// + FIF_PCD = 9, + /// + /// Zsoft Paintbrush PCX bitmap format (*.PCX) + /// + FIF_PCX = 10, + /// + /// Portable Graymap (ASCII) (*.PGM) + /// + FIF_PGM = 11, + /// + /// Portable Graymap (BINARY) (*.PGM) + /// + FIF_PGMRAW = 12, + /// + /// Portable Network Graphics (*.PNG) + /// + FIF_PNG = 13, + /// + /// Portable Pixelmap (ASCII) (*.PPM) + /// + FIF_PPM = 14, + /// + /// Portable Pixelmap (BINARY) (*.PPM) + /// + FIF_PPMRAW = 15, + /// + /// Sun Rasterfile (*.RAS) + /// + FIF_RAS = 16, + /// + /// truevision Targa files (*.TGA, *.TARGA) + /// + FIF_TARGA = 17, + /// + /// Tagged Image File Format (*.TIF, *.TIFF) + /// + FIF_TIFF = 18, + /// + /// Wireless Bitmap (*.WBMP) + /// + FIF_WBMP = 19, + /// + /// Adobe Photoshop (*.PSD) + /// + FIF_PSD = 20, + /// + /// Dr. Halo (*.CUT) + /// + FIF_CUT = 21, + /// + /// X11 Bitmap Format (*.XBM) + /// + FIF_XBM = 22, + /// + /// X11 Pixmap Format (*.XPM) + /// + FIF_XPM = 23, + /// + /// DirectDraw Surface (*.DDS) + /// + FIF_DDS = 24, + /// + /// Graphics Interchange Format (*.GIF) + /// + FIF_GIF = 25, + /// + /// High Dynamic Range (*.HDR) + /// + FIF_HDR = 26, + /// + /// Raw Fax format CCITT G3 (*.G3) + /// + FIF_FAXG3 = 27, + /// + /// Silicon Graphics SGI image format (*.SGI) + /// + FIF_SGI = 28, + /// + /// OpenEXR format (*.EXR) + /// + FIF_EXR = 29, + /// + /// JPEG-2000 format (*.J2K, *.J2C) + /// + FIF_J2K = 30, + /// + /// JPEG-2000 format (*.JP2) + /// + FIF_JP2 = 31, + /// + /// Portable FloatMap (*.PFM) + /// + FIF_PFM = 32, + /// + /// Macintosh PICT (*.PICT) + /// + FIF_PICT = 33, + /// + /// RAW camera image (*.*) + /// + FIF_RAW = 34, + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_JPEG_OPERATION.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_JPEG_OPERATION.cs new file mode 100644 index 0000000..e76dc22 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_JPEG_OPERATION.cs @@ -0,0 +1,76 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:38 $ +// $Id: FREE_IMAGE_JPEG_OPERATION.cs,v 1.1 2007/11/28 15:33:38 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Lossless JPEG transformations constants used in FreeImage_JPEGTransform. + /// + public enum FREE_IMAGE_JPEG_OPERATION + { + /// + /// no transformation + /// + FIJPEG_OP_NONE = 0, + /// + /// horizontal flip + /// + FIJPEG_OP_FLIP_H = 1, + /// + /// vertical flip + /// + FIJPEG_OP_FLIP_V = 2, + /// + /// transpose across UL-to-LR axis + /// + FIJPEG_OP_TRANSPOSE = 3, + /// + /// transpose across UR-to-LL axis + /// + FIJPEG_OP_TRANSVERSE = 4, + /// + /// 90-degree clockwise rotation + /// + FIJPEG_OP_ROTATE_90 = 5, + /// + /// 180-degree rotation + /// + FIJPEG_OP_ROTATE_180 = 6, + /// + /// 270-degree clockwise (or 90 ccw) + /// + FIJPEG_OP_ROTATE_270 = 7 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_LOAD_FLAGS.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_LOAD_FLAGS.cs new file mode 100644 index 0000000..0f8c91b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_LOAD_FLAGS.cs @@ -0,0 +1,111 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.2 $ +// $Date: 2009/09/15 11:45:16 $ +// $Id: FREE_IMAGE_LOAD_FLAGS.cs,v 1.2 2009/09/15 11:45:16 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Flags used in load functions. + /// + [System.Flags] + public enum FREE_IMAGE_LOAD_FLAGS + { + /// + /// Default option for all types. + /// + DEFAULT = 0, + /// + /// Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color. + /// + GIF_LOAD256 = 1, + /// + /// 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading. + /// + GIF_PLAYBACK = 2, + /// + /// Convert to 32bpp and create an alpha channel from the AND-mask when loading. + /// + ICO_MAKEALPHA = 1, + /// + /// Load the file as fast as possible, sacrificing some quality. + /// + JPEG_FAST = 0x0001, + /// + /// Load the file with the best quality, sacrificing some speed. + /// + JPEG_ACCURATE = 0x0002, + /// + /// Load separated CMYK "as is" (use | to combine with other load flags). + /// + JPEG_CMYK = 0x0004, + /// + /// Load and rotate according to Exif 'Orientation' tag if available. + /// + JPEG_EXIFROTATE = 0x0008, + /// + /// Load the bitmap sized 768 x 512. + /// + PCD_BASE = 1, + /// + /// Load the bitmap sized 384 x 256. + /// + PCD_BASEDIV4 = 2, + /// + /// Load the bitmap sized 192 x 128. + /// + PCD_BASEDIV16 = 3, + /// + /// Avoid gamma correction. + /// + PNG_IGNOREGAMMA = 1, + /// + /// If set the loader converts RGB555 and ARGB8888 -> RGB888. + /// + TARGA_LOAD_RGB888 = 1, + /// + /// Reads tags for separated CMYK. + /// + TIFF_CMYK = 0x0001, + /// + /// Tries to load the JPEG preview image, embedded in + /// Exif Metadata or load the image as RGB 24-bit if no + /// preview image is available. + /// + RAW_PREVIEW = 0x1, + /// + /// Loads the image as RGB 24-bit. + /// + RAW_DISPLAY = 0x2, + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_MDMODEL.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_MDMODEL.cs new file mode 100644 index 0000000..4fb4f66 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_MDMODEL.cs @@ -0,0 +1,92 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:39 $ +// $Id: FREE_IMAGE_MDMODEL.cs,v 1.1 2007/11/28 15:33:39 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Metadata models supported by FreeImage. + /// + public enum FREE_IMAGE_MDMODEL + { + /// + /// No data + /// + FIMD_NODATA = -1, + /// + /// single comment or keywords + /// + FIMD_COMMENTS = 0, + /// + /// Exif-TIFF metadata + /// + FIMD_EXIF_MAIN = 1, + /// + /// Exif-specific metadata + /// + FIMD_EXIF_EXIF = 2, + /// + /// Exif GPS metadata + /// + FIMD_EXIF_GPS = 3, + /// + /// Exif maker note metadata + /// + FIMD_EXIF_MAKERNOTE = 4, + /// + /// Exif interoperability metadata + /// + FIMD_EXIF_INTEROP = 5, + /// + /// IPTC/NAA metadata + /// + FIMD_IPTC = 6, + /// + /// Abobe XMP metadata + /// + FIMD_XMP = 7, + /// + /// GeoTIFF metadata + /// + FIMD_GEOTIFF = 8, + /// + /// Animation metadata + /// + FIMD_ANIMATION = 9, + /// + /// Used to attach other metadata types to a dib + /// + FIMD_CUSTOM = 10 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_MDTYPE.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_MDTYPE.cs new file mode 100644 index 0000000..60a0d11 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_MDTYPE.cs @@ -0,0 +1,105 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:39 $ +// $Id: FREE_IMAGE_MDTYPE.cs,v 1.1 2007/11/28 15:33:39 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Tag data type information (based on TIFF specifications) + /// Note: RATIONALs are the ratio of two 32-bit integer values. + /// + public enum FREE_IMAGE_MDTYPE + { + /// + /// placeholder + /// + FIDT_NOTYPE = 0, + /// + /// 8-bit unsigned integer + /// + FIDT_BYTE = 1, + /// + /// 8-bit bytes w/ last byte null + /// + FIDT_ASCII = 2, + /// + /// 16-bit unsigned integer + /// + FIDT_SHORT = 3, + /// + /// 32-bit unsigned integer + /// + FIDT_LONG = 4, + /// + /// 64-bit unsigned fraction + /// + FIDT_RATIONAL = 5, + /// + /// 8-bit signed integer + /// + FIDT_SBYTE = 6, + /// + /// 8-bit untyped data + /// + FIDT_UNDEFINED = 7, + /// + /// 16-bit signed integer + /// + FIDT_SSHORT = 8, + /// + /// 32-bit signed integer + /// + FIDT_SLONG = 9, + /// + /// 64-bit signed fraction + /// + FIDT_SRATIONAL = 10, + /// + /// 32-bit IEEE floating point + /// + FIDT_FLOAT = 11, + /// + /// 64-bit IEEE floating point + /// + FIDT_DOUBLE = 12, + /// + /// 32-bit unsigned integer (offset) + /// + FIDT_IFD = 13, + /// + /// 32-bit RGBQUAD + /// + FIDT_PALETTE = 14 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_METADATA_COPY.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_METADATA_COPY.cs new file mode 100644 index 0000000..f0d4a8c --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_METADATA_COPY.cs @@ -0,0 +1,56 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:39 $ +// $Id: FREE_IMAGE_METADATA_COPY.cs,v 1.1 2007/11/28 15:33:39 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Flags for copying data from a bitmap to another. + /// + public enum FREE_IMAGE_METADATA_COPY + { + /// + /// Exisiting metadata will remain unchanged. + /// + KEEP_EXISITNG = 0x0, + /// + /// Existing metadata will be cleared. + /// + CLEAR_EXISTING = 0x1, + /// + /// Existing metadata will be overwritten. + /// + REPLACE_EXISTING = 0x2 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_QUANTIZE.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_QUANTIZE.cs new file mode 100644 index 0000000..3aeace2 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_QUANTIZE.cs @@ -0,0 +1,53 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:39 $ +// $Id: FREE_IMAGE_QUANTIZE.cs,v 1.1 2007/11/28 15:33:39 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Color quantization algorithms. + /// Constants used in FreeImage_ColorQuantize. + /// + public enum FREE_IMAGE_QUANTIZE + { + /// + /// Xiaolin Wu color quantization algorithm + /// + FIQ_WUQUANT = 0, + /// + /// NeuQuant neural-net quantization algorithm by Anthony Dekker + /// + FIQ_NNQUANT = 1 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_SAVE_FLAGS.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_SAVE_FLAGS.cs new file mode 100644 index 0000000..ad1fc55 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_SAVE_FLAGS.cs @@ -0,0 +1,191 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2011/12/22 14:53:28 $ +// $Id: FREE_IMAGE_SAVE_FLAGS.cs,v 1.3 2011/12/22 14:53:28 drolon Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Flags used in save functions. + /// + [System.Flags] + public enum FREE_IMAGE_SAVE_FLAGS + { + /// + /// Default option for all types. + /// + DEFAULT = 0, + /// + /// Save with run length encoding. + /// + BMP_SAVE_RLE = 1, + /// + /// Save data as float instead of as half (not recommended). + /// + EXR_FLOAT = 0x0001, + /// + /// Save with no compression. + /// + EXR_NONE = 0x0002, + /// + /// Save with zlib compression, in blocks of 16 scan lines. + /// + EXR_ZIP = 0x0004, + /// + /// Save with piz-based wavelet compression. + /// + EXR_PIZ = 0x0008, + /// + /// Save with lossy 24-bit float compression. + /// + EXR_PXR24 = 0x0010, + /// + /// Save with lossy 44% float compression - goes to 22% when combined with EXR_LC. + /// + EXR_B44 = 0x0020, + /// + /// Save images with one luminance and two chroma channels, rather than as RGB (lossy compression). + /// + EXR_LC = 0x0040, + /// + /// Save with superb quality (100:1). + /// + JPEG_QUALITYSUPERB = 0x80, + /// + /// Save with good quality (75:1). + /// + JPEG_QUALITYGOOD = 0x0100, + /// + /// Save with normal quality (50:1). + /// + JPEG_QUALITYNORMAL = 0x0200, + /// + /// Save with average quality (25:1). + /// + JPEG_QUALITYAVERAGE = 0x0400, + /// + /// Save with bad quality (10:1). + /// + JPEG_QUALITYBAD = 0x0800, + /// + /// Save as a progressive-JPEG (use | to combine with other save flags). + /// + JPEG_PROGRESSIVE = 0x2000, + /// + /// Save with high 4x1 chroma subsampling (4:1:1). + /// + JPEG_SUBSAMPLING_411 = 0x1000, + /// + /// Save with medium 2x2 medium chroma (4:2:0). + /// + JPEG_SUBSAMPLING_420 = 0x4000, + /// + /// Save with low 2x1 chroma subsampling (4:2:2). + /// + JPEG_SUBSAMPLING_422 = 0x8000, + /// + /// Save with no chroma subsampling (4:4:4). + /// + JPEG_SUBSAMPLING_444 = 0x10000, + /// + /// On saving, compute optimal Huffman coding tables (can reduce a few percent of file size). + /// + JPEG_OPTIMIZE = 0x20000, + /// + /// save basic JPEG, without metadata or any markers. + /// + JPEG_BASELINE = 0x40000, + /// + /// Save using ZLib level 1 compression flag + /// (default value is ). + /// + PNG_Z_BEST_SPEED = 0x0001, + /// + /// Save using ZLib level 6 compression flag (default recommended value). + /// + PNG_Z_DEFAULT_COMPRESSION = 0x0006, + /// + /// save using ZLib level 9 compression flag + /// (default value is ). + /// + PNG_Z_BEST_COMPRESSION = 0x0009, + /// + /// Save without ZLib compression. + /// + PNG_Z_NO_COMPRESSION = 0x0100, + /// + /// Save using Adam7 interlacing (use | to combine with other save flags). + /// + PNG_INTERLACED = 0x0200, + /// + /// If set the writer saves in ASCII format (i.e. P1, P2 or P3). + /// + PNM_SAVE_ASCII = 1, + /// + /// Stores tags for separated CMYK (use | to combine with compression flags). + /// + TIFF_CMYK = 0x0001, + /// + /// Save using PACKBITS compression. + /// + TIFF_PACKBITS = 0x0100, + /// + /// Save using DEFLATE compression (a.k.a. ZLIB compression). + /// + TIFF_DEFLATE = 0x0200, + /// + /// Save using ADOBE DEFLATE compression. + /// + TIFF_ADOBE_DEFLATE = 0x0400, + /// + /// Save without any compression. + /// + TIFF_NONE = 0x0800, + /// + /// Save using CCITT Group 3 fax encoding. + /// + TIFF_CCITTFAX3 = 0x1000, + /// + /// Save using CCITT Group 4 fax encoding. + /// + TIFF_CCITTFAX4 = 0x2000, + /// + /// Save using LZW compression. + /// + TIFF_LZW = 0x4000, + /// + /// Save using JPEG compression. + /// + TIFF_JPEG = 0x8000 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_TMO.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_TMO.cs new file mode 100644 index 0000000..5f3b9fd --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_TMO.cs @@ -0,0 +1,56 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:39 $ +// $Id: FREE_IMAGE_TMO.cs,v 1.1 2007/11/28 15:33:39 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Tone mapping operators. Constants used in FreeImage_ToneMapping. + /// + public enum FREE_IMAGE_TMO + { + /// + /// Adaptive logarithmic mapping (F. Drago, 2003) + /// + FITMO_DRAGO03 = 0, + /// + /// Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005) + /// + FITMO_REINHARD05 = 1, + /// + /// Gradient domain high dynamic range compression (R. Fattal, 2002) + /// + FITMO_FATTAL02 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_TYPE.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_TYPE.cs new file mode 100644 index 0000000..eeeb43e --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/FREE_IMAGE_TYPE.cs @@ -0,0 +1,96 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:40 $ +// $Id: FREE_IMAGE_TYPE.cs,v 1.1 2007/11/28 15:33:40 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Image types used in FreeImage. + /// + public enum FREE_IMAGE_TYPE + { + /// + /// unknown type + /// + FIT_UNKNOWN = 0, + /// + /// standard image : 1-, 4-, 8-, 16-, 24-, 32-bit + /// + FIT_BITMAP = 1, + /// + /// array of unsigned short : unsigned 16-bit + /// + FIT_UINT16 = 2, + /// + /// array of short : signed 16-bit + /// + FIT_INT16 = 3, + /// + /// array of unsigned long : unsigned 32-bit + /// + FIT_UINT32 = 4, + /// + /// array of long : signed 32-bit + /// + FIT_INT32 = 5, + /// + /// array of float : 32-bit IEEE floating point + /// + FIT_FLOAT = 6, + /// + /// array of double : 64-bit IEEE floating point + /// + FIT_DOUBLE = 7, + /// + /// array of FICOMPLEX : 2 x 64-bit IEEE floating point + /// + FIT_COMPLEX = 8, + /// + /// 48-bit RGB image : 3 x 16-bit + /// + FIT_RGB16 = 9, + /// + /// 64-bit RGBA image : 4 x 16-bit + /// + FIT_RGBA16 = 10, + /// + /// 96-bit RGB float image : 3 x 32-bit IEEE floating point + /// + FIT_RGBF = 11, + /// + /// 128-bit RGBA float image : 4 x 32-bit IEEE floating point + /// + FIT_RGBAF = 12 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/ICC_FLAGS.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/ICC_FLAGS.cs new file mode 100644 index 0000000..cf1f6cd --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/ICC_FLAGS.cs @@ -0,0 +1,53 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:38 $ +// $Id: ICC_FLAGS.cs,v 1.1 2007/11/28 15:33:38 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// Flags for ICC profiles. + /// + [System.Flags] + public enum ICC_FLAGS : ushort + { + /// + /// Default value. + /// + FIICC_DEFAULT = 0x00, + /// + /// The color is CMYK. + /// + FIICC_COLOR_IS_CMYK = 0x01 + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/MD_SEARCH_FLAGS.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/MD_SEARCH_FLAGS.cs new file mode 100644 index 0000000..aa91715 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Enumerations/MD_SEARCH_FLAGS.cs @@ -0,0 +1,57 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.1 $ +// $Date: 2007/11/28 15:33:40 $ +// $Id: MD_SEARCH_FLAGS.cs,v 1.1 2007/11/28 15:33:40 cklein05 Exp $ +// ========================================================== + +namespace FreeImageAPI +{ + /// + /// List different search modes. + /// + [System.Flags] + public enum MD_SEARCH_FLAGS + { + /// + /// The key of the metadata. + /// + KEY = 0x1, + /// + /// The description of the metadata + /// + DESCRIPTION = 0x2, + /// + /// The ToString value of the metadata + /// + TOSTRING = 0x4, + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/FreeImageStaticImports.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/FreeImageStaticImports.cs new file mode 100644 index 0000000..54c8f7f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/FreeImageStaticImports.cs @@ -0,0 +1,2369 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.9 $ +// $Date: 2009/09/15 11:41:37 $ +// $Id: FreeImageStaticImports.cs,v 1.9 2009/09/15 11:41:37 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; +using FreeImageAPI.Plugins; +using FreeImageAPI.IO; + +namespace FreeImageAPI +{ + public static partial class FreeImage + { + #region Constants + + /// + /// Filename of the FreeImage library. + /// + private const string FreeImageLibrary = "FreeImage"; + + /// + /// Number of bytes to shift left within a 4 byte block. + /// + public const int FI_RGBA_RED = 2; + + /// + /// Number of bytes to shift left within a 4 byte block. + /// + public const int FI_RGBA_GREEN = 1; + + /// + /// Number of bytes to shift left within a 4 byte block. + /// + public const int FI_RGBA_BLUE = 0; + + /// + /// Number of bytes to shift left within a 4 byte block. + /// + public const int FI_RGBA_ALPHA = 3; + + /// + /// Mask indicating the position of the given color. + /// + public const uint FI_RGBA_RED_MASK = 0x00FF0000; + + /// + /// Mask indicating the position of the given color. + /// + public const uint FI_RGBA_GREEN_MASK = 0x0000FF00; + + /// + /// Mask indicating the position of the given color. + /// + public const uint FI_RGBA_BLUE_MASK = 0x000000FF; + + /// + /// Mask indicating the position of the given color. + /// + public const uint FI_RGBA_ALPHA_MASK = 0xFF000000; + + /// + /// Number of bits to shift left within a 32 bit block. + /// + public const int FI_RGBA_RED_SHIFT = 16; + + /// + /// Number of bits to shift left within a 32 bit block. + /// + public const int FI_RGBA_GREEN_SHIFT = 8; + + /// + /// Number of bits to shift left within a 32 bit block. + /// + public const int FI_RGBA_BLUE_SHIFT = 0; + + /// + /// Number of bits to shift left within a 32 bit block. + /// + public const int FI_RGBA_ALPHA_SHIFT = 24; + + /// + /// Mask indicating the position of color components of a 32 bit color. + /// + public const uint FI_RGBA_RGB_MASK = (FI_RGBA_RED_MASK | FI_RGBA_GREEN_MASK | FI_RGBA_BLUE_MASK); + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_555_RED_MASK = 0x7C00; + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_555_GREEN_MASK = 0x03E0; + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_555_BLUE_MASK = 0x001F; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_555_RED_SHIFT = 10; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_555_GREEN_SHIFT = 5; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_555_BLUE_SHIFT = 0; + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_565_RED_MASK = 0xF800; + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_565_GREEN_MASK = 0x07E0; + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_565_BLUE_MASK = 0x001F; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_565_RED_SHIFT = 11; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_565_GREEN_SHIFT = 5; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_565_BLUE_SHIFT = 0; + + #endregion + + #region General functions + + /// + /// Initialises the library. + /// + /// + /// When the is true, FreeImage won't make use of external plugins. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Initialise")] + private static extern void Initialise(bool load_local_plugins_only); + + /// + /// Deinitialises the library. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_DeInitialise")] + private static extern void DeInitialise(); + + /// + /// Returns a string containing the current version of the library. + /// + /// The current version of the library. + public static unsafe string GetVersion() { return PtrToStr(GetVersion_()); } + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetVersion")] + private static unsafe extern byte* GetVersion_(); + + /// + /// Returns a string containing a standard copyright message. + /// + /// A standard copyright message. + public static unsafe string GetCopyrightMessage() { return PtrToStr(GetCopyrightMessage_()); } + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetCopyrightMessage")] + private static unsafe extern byte* GetCopyrightMessage_(); + + /// + /// Calls the set error message function in FreeImage. + /// + /// Format of the bitmaps. + /// The error message. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_OutputMessageProc")] + public static extern void OutputMessageProc(FREE_IMAGE_FORMAT fif, string message); + + /// + /// You use the function FreeImage_SetOutputMessage to capture the log string + /// so that you can show it to the user of the program. + /// The callback is implemented in the event of this class. + /// + /// The function is private because FreeImage can only have a single + /// callback function. To use the callback use the + /// event of this class. + /// Handler to the callback function. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetOutputMessage")] + internal static extern void SetOutputMessage(OutputMessageFunction omf); + + #endregion + + #region Bitmap management functions + + /// + /// Creates a new bitmap in memory. + /// + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new Bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// Red part of the color layout. + /// eg: 0xFF0000 + /// Green part of the color layout. + /// eg: 0x00FF00 + /// Blue part of the color layout. + /// eg: 0x0000FF + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Allocate")] + public static extern FIBITMAP Allocate(int width, int height, int bpp, + uint red_mask, uint green_mask, uint blue_mask); + + /// + /// Creates a new bitmap in memory. + /// + /// Type of the image. + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new Bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// Red part of the color layout. + /// eg: 0xFF0000 + /// Green part of the color layout. + /// eg: 0x00FF00 + /// Blue part of the color layout. + /// eg: 0x0000FF + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AllocateT")] + public static extern FIBITMAP AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp, + uint red_mask, uint green_mask, uint blue_mask); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AllocateEx")] + internal static extern FIBITMAP AllocateEx(int width, int height, int bpp, + IntPtr color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette, + uint red_mask, uint green_mask, uint blue_mask); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AllocateExT")] + internal static extern FIBITMAP AllocateExT(FREE_IMAGE_TYPE type, int width, int height, int bpp, + IntPtr color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette, + uint red_mask, uint green_mask, uint blue_mask); + + /// + /// Makes an exact reproduction of an existing bitmap, including metadata and attached profile if any. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Clone")] + public static extern FIBITMAP Clone(FIBITMAP dib); + + /// + /// Deletes a previously loaded FIBITMAP from memory. + /// + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Unload")] + public static extern void Unload(FIBITMAP dib); + + /// + /// Decodes a bitmap, allocates memory for it and returns it as a FIBITMAP. + /// + /// Type of the bitmap. + /// Name of the file to decode. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_LoadU")] + public static extern FIBITMAP Load(FREE_IMAGE_FORMAT fif, string filename, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Decodes a bitmap, allocates memory for it and returns it as a FIBITMAP. + /// The filename supports UNICODE. + /// + /// Type of the bitmap. + /// Name of the file to decode. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_LoadU")] + private static extern FIBITMAP LoadU(FREE_IMAGE_FORMAT fif, string filename, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Loads a bitmap from an arbitrary source. + /// + /// Type of the bitmap. + /// A FreeImageIO structure with functionpointers to handle the source. + /// A handle to the source. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LoadFromHandle")] + public static extern FIBITMAP LoadFromHandle(FREE_IMAGE_FORMAT fif, ref FreeImageIO io, fi_handle handle, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Saves a previosly loaded FIBITMAP to a file. + /// + /// Type of the bitmap. + /// Handle to a FreeImage bitmap. + /// Name of the file to save to. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_SaveU")] + public static extern bool Save(FREE_IMAGE_FORMAT fif, FIBITMAP dib, string filename, FREE_IMAGE_SAVE_FLAGS flags); + + /// + /// Saves a previosly loaded FIBITMAP to a file. + /// The filename supports UNICODE. + /// + /// Type of the bitmap. + /// Handle to a FreeImage bitmap. + /// Name of the file to save to. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_SaveU")] + private static extern bool SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP dib, string filename, FREE_IMAGE_SAVE_FLAGS flags); + + /// + /// Saves a bitmap to an arbitrary source. + /// + /// Type of the bitmap. + /// Handle to a FreeImage bitmap. + /// A FreeImageIO structure with functionpointers to handle the source. + /// A handle to the source. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SaveToHandle")] + public static extern bool SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP dib, ref FreeImageIO io, fi_handle handle, + FREE_IMAGE_SAVE_FLAGS flags); + + #endregion + + #region Memory I/O streams + + /// + /// Open a memory stream. + /// + /// Pointer to the data in memory. + /// Length of the data in byte. + /// Handle to a memory stream. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_OpenMemory")] + public static extern FIMEMORY OpenMemory(IntPtr data, uint size_in_bytes); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_OpenMemory")] + internal static extern FIMEMORY OpenMemoryEx(byte[] data, uint size_in_bytes); + + /// + /// Close and free a memory stream. + /// + /// Handle to a memory stream. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CloseMemory")] + public static extern void CloseMemory(FIMEMORY stream); + + /// + /// Decodes a bitmap from a stream, allocates memory for it and returns it as a FIBITMAP. + /// + /// Type of the bitmap. + /// Handle to a memory stream. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LoadFromMemory")] + public static extern FIBITMAP LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY stream, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Saves a previosly loaded FIBITMAP to a stream. + /// + /// Type of the bitmap. + /// Handle to a FreeImage bitmap. + /// Handle to a memory stream. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SaveToMemory")] + public static extern bool SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP dib, FIMEMORY stream, FREE_IMAGE_SAVE_FLAGS flags); + + /// + /// Gets the current position of a memory handle. + /// + /// Handle to a memory stream. + /// The current file position if successful, -1 otherwise. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_TellMemory")] + public static extern int TellMemory(FIMEMORY stream); + + /// + /// Moves the memory handle to a specified location. + /// + /// Handle to a memory stream. + /// Number of bytes from origin. + /// Initial position. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SeekMemory")] + public static extern bool SeekMemory(FIMEMORY stream, int offset, System.IO.SeekOrigin origin); + + /// + /// Provides a direct buffer access to a memory stream. + /// + /// The target memory stream. + /// Pointer to the data in memory. + /// Size of the data in bytes. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AcquireMemory")] + public static extern bool AcquireMemory(FIMEMORY stream, ref IntPtr data, ref uint size_in_bytes); + + /// + /// Reads data from a memory stream. + /// + /// The buffer to store the data in. + /// Size in bytes of the items. + /// Number of items to read. + /// The stream to read from. + /// The memory pointer associated with stream is increased by the number of bytes actually read. + /// The number of full items actually read. + /// May be less than count on error or stream-end. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ReadMemory")] + public static extern uint ReadMemory(byte[] buffer, uint size, uint count, FIMEMORY stream); + + /// + /// Writes data to a memory stream. + /// + /// The buffer to read the data from. + /// Size in bytes of the items. + /// Number of items to write. + /// The stream to write to. + /// The memory pointer associated with stream is increased by the number of bytes actually written. + /// The number of full items actually written. + /// May be less than count on error or stream-end. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_WriteMemory")] + public static extern uint WriteMemory(byte[] buffer, uint size, uint count, FIMEMORY stream); + + /// + /// Open a multi-page bitmap from a memory stream. + /// + /// Type of the bitmap. + /// The stream to decode. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage multi-paged bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LoadMultiBitmapFromMemory")] + public static extern FIMULTIBITMAP LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY stream, FREE_IMAGE_LOAD_FLAGS flags); + + #endregion + + #region Plugin functions + + /// + /// Registers a new plugin to be used in FreeImage. + /// + /// Pointer to the function that initialises the plugin. + /// A string describing the format of the plugin. + /// A string describing the plugin. + /// A string witha comma sperated list of extensions. f.e: "pl,pl2,pl4" + /// A regular expression used to identify the bitmap. + /// The format idientifier assigned by FreeImage. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_RegisterLocalPlugin")] + public static extern FREE_IMAGE_FORMAT RegisterLocalPlugin(InitProc proc_address, + string format, string description, string extension, string regexpr); + + /// + /// Registers a new plugin to be used in FreeImage. The plugin is residing in a DLL. + /// The Init function must be called “Init” and must use the stdcall calling convention. + /// + /// Complete path to the dll file hosting the plugin. + /// A string describing the format of the plugin. + /// A string describing the plugin. + /// A string witha comma sperated list of extensions. f.e: "pl,pl2,pl4" + /// A regular expression used to identify the bitmap. + /// The format idientifier assigned by FreeImage. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_RegisterExternalPlugin")] + public static extern FREE_IMAGE_FORMAT RegisterExternalPlugin(string path, + string format, string description, string extension, string regexpr); + + /// + /// Retrieves the number of FREE_IMAGE_FORMAT identifiers being currently registered. + /// + /// The number of registered formats. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFIFCount")] + public static extern int GetFIFCount(); + + /// + /// Enables or disables a plugin. + /// + /// The plugin to enable or disable. + /// True: enable the plugin. false: disable the plugin. + /// The previous state of the plugin. + /// 1 - enabled. 0 - disables. -1 plugin does not exist. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetPluginEnabled")] + public static extern int SetPluginEnabled(FREE_IMAGE_FORMAT fif, bool enable); + + /// + /// Retrieves the state of a plugin. + /// + /// The plugin to check. + /// 1 - enabled. 0 - disables. -1 plugin does not exist. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_IsPluginEnabled")] + public static extern int IsPluginEnabled(FREE_IMAGE_FORMAT fif); + + /// + /// Returns a identifier from the format string that was used to register the FIF. + /// + /// The string that was used to register the plugin. + /// A identifier from the format. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetFIFFromFormat")] + public static extern FREE_IMAGE_FORMAT GetFIFFromFormat(string format); + + /// + /// Returns a identifier from a MIME content type string + /// (MIME stands for Multipurpose Internet Mail Extension). + /// + /// A MIME content type. + /// A identifier from the MIME. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetFIFFromMime")] + public static extern FREE_IMAGE_FORMAT GetFIFFromMime(string mime); + + /// + /// Returns the string that was used to register a plugin from the system assigned . + /// + /// The assigned . + /// The string that was used to register the plugin. + public static unsafe string GetFormatFromFIF(FREE_IMAGE_FORMAT fif) { return PtrToStr(GetFormatFromFIF_(fif)); } + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFormatFromFIF")] + private static unsafe extern byte* GetFormatFromFIF_(FREE_IMAGE_FORMAT fif); + + /// + /// Returns a comma-delimited file extension list describing the bitmap formats the given plugin can read and/or write. + /// + /// The desired . + /// A comma-delimited file extension list. + public static unsafe string GetFIFExtensionList(FREE_IMAGE_FORMAT fif) { return PtrToStr(GetFIFExtensionList_(fif)); } + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFIFExtensionList")] + private static unsafe extern byte* GetFIFExtensionList_(FREE_IMAGE_FORMAT fif); + + /// + /// Returns a descriptive string that describes the bitmap formats the given plugin can read and/or write. + /// + /// The desired . + /// A descriptive string that describes the bitmap formats. + public static unsafe string GetFIFDescription(FREE_IMAGE_FORMAT fif) { return PtrToStr(GetFIFDescription_(fif)); } + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFIFDescription")] + private static unsafe extern byte* GetFIFDescription_(FREE_IMAGE_FORMAT fif); + + /// + /// Returns a regular expression string that can be used by a regular expression engine to identify the bitmap. + /// FreeImageQt makes use of this function. + /// + /// The desired . + /// A regular expression string. + public static unsafe string GetFIFRegExpr(FREE_IMAGE_FORMAT fif) { return PtrToStr(GetFIFRegExpr_(fif)); } + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFIFRegExpr")] + private static unsafe extern byte* GetFIFRegExpr_(FREE_IMAGE_FORMAT fif); + + /// + /// Given a identifier, returns a MIME content type string (MIME stands for Multipurpose Internet Mail Extension). + /// + /// The desired . + /// A MIME content type string. + public static unsafe string GetFIFMimeType(FREE_IMAGE_FORMAT fif) { return PtrToStr(GetFIFMimeType_(fif)); } + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFIFMimeType")] + private static unsafe extern byte* GetFIFMimeType_(FREE_IMAGE_FORMAT fif); + + /// + /// This function takes a filename or a file-extension and returns the plugin that can + /// read/write files with that extension in the form of a identifier. + /// + /// The filename or -extension. + /// The of the plugin. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_GetFIFFromFilenameU")] + public static extern FREE_IMAGE_FORMAT GetFIFFromFilename(string filename); + + /// + /// This function takes a filename or a file-extension and returns the plugin that can + /// read/write files with that extension in the form of a identifier. + /// Supports UNICODE filenames. + /// + /// The filename or -extension. + /// The of the plugin. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_GetFIFFromFilenameU")] + private static extern FREE_IMAGE_FORMAT GetFIFFromFilenameU(string filename); + + /// + /// Checks if a plugin can load bitmaps. + /// + /// The of the plugin. + /// True if the plugin can load bitmaps, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FIFSupportsReading")] + public static extern bool FIFSupportsReading(FREE_IMAGE_FORMAT fif); + + /// + /// Checks if a plugin can save bitmaps. + /// + /// The of the plugin. + /// True if the plugin can save bitmaps, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FIFSupportsWriting")] + public static extern bool FIFSupportsWriting(FREE_IMAGE_FORMAT fif); + + /// + /// Checks if a plugin can save bitmaps in the desired bit depth. + /// + /// The of the plugin. + /// The desired bit depth. + /// True if the plugin can save bitmaps in the desired bit depth, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FIFSupportsExportBPP")] + public static extern bool FIFSupportsExportBPP(FREE_IMAGE_FORMAT fif, int bpp); + + /// + /// Checks if a plugin can save a bitmap in the desired data type. + /// + /// The of the plugin. + /// The desired image type. + /// True if the plugin can save bitmaps as the desired type, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FIFSupportsExportType")] + public static extern bool FIFSupportsExportType(FREE_IMAGE_FORMAT fif, FREE_IMAGE_TYPE type); + + /// + /// Checks if a plugin can load or save an ICC profile. + /// + /// The of the plugin. + /// True if the plugin can load or save an ICC profile, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FIFSupportsICCProfiles")] + public static extern bool FIFSupportsICCProfiles(FREE_IMAGE_FORMAT fif); + + #endregion + + #region Multipage functions + + /// + /// Loads a FreeImage multi-paged bitmap. + /// Load flags can be provided by the flags parameter. + /// + /// Format of the image. + /// The complete name of the file to load. + /// When true a new bitmap is created. + /// When true the bitmap will be loaded read only. + /// When true performance is increased at the cost of memory. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage multi-paged bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_OpenMultiBitmap")] + public static extern FIMULTIBITMAP OpenMultiBitmap(FREE_IMAGE_FORMAT fif, string filename, bool create_new, + bool read_only, bool keep_cache_in_memory, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Loads a FreeImage multi-pages bitmap from the specified handle + /// using the specified functions. + /// Load flags can be provided by the flags parameter. + /// + /// Format of the image. + /// IO functions used to read from the specified handle. + /// The handle to load the bitmap from. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage multi-paged bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_OpenMultiBitmapFromHandle")] + public static extern FIMULTIBITMAP OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, ref FreeImageIO io, + fi_handle handle, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Closes a previously opened multi-page bitmap and, when the bitmap was not opened read-only, applies any changes made to it. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CloseMultiBitmap")] + private static extern bool CloseMultiBitmap_(FIMULTIBITMAP bitmap, FREE_IMAGE_SAVE_FLAGS flags); + + /// + /// Returns the number of pages currently available in the multi-paged bitmap. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Number of pages. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetPageCount")] + public static extern int GetPageCount(FIMULTIBITMAP bitmap); + + /// + /// Appends a new page to the end of the bitmap. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AppendPage")] + public static extern void AppendPage(FIMULTIBITMAP bitmap, FIBITMAP data); + + /// + /// Inserts a new page before the given position in the bitmap. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Page has to be a number smaller than the current number of pages available in the bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_InsertPage")] + public static extern void InsertPage(FIMULTIBITMAP bitmap, int page, FIBITMAP data); + + /// + /// Deletes the page on the given position. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Number of the page to delete. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_DeletePage")] + public static extern void DeletePage(FIMULTIBITMAP bitmap, int page); + + /// + /// Locks a page in memory for editing. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Number of the page to lock. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LockPage")] + public static extern FIBITMAP LockPage(FIMULTIBITMAP bitmap, int page); + + /// + /// Unlocks a previously locked page and gives it back to the multi-page engine. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Handle to a FreeImage bitmap. + /// If true, the page is applied to the multi-page bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_UnlockPage")] + public static extern void UnlockPage(FIMULTIBITMAP bitmap, FIBITMAP data, bool changed); + + /// + /// Moves the source page to the position of the target page. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// New position of the page. + /// Old position of the page. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_MovePage")] + public static extern bool MovePage(FIMULTIBITMAP bitmap, int target, int source); + + /// + /// Returns an array of page-numbers that are currently locked in memory. + /// When the pages parameter is null, the size of the array is returned in the count variable. + /// + /// + /// + /// int[] lockedPages = null; + /// int count = 0; + /// GetLockedPageNumbers(dib, lockedPages, ref count); + /// lockedPages = new int[count]; + /// GetLockedPageNumbers(dib, lockedPages, ref count); + /// + /// + /// Handle to a FreeImage multi-paged bitmap. + /// The list of locked pages in the multi-pages bitmap. + /// If set to null, count will contain the number of pages. + /// If is set to null count will contain the number of locked pages. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetLockedPageNumbers")] + public static extern bool GetLockedPageNumbers(FIMULTIBITMAP bitmap, int[] pages, ref int count); + + #endregion + + #region Filetype functions + + /// + /// Orders FreeImage to analyze the bitmap signature. + /// + /// Name of the file to analyze. + /// Reserved parameter - use 0. + /// Type of the bitmap. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_GetFileTypeU")] + public static extern FREE_IMAGE_FORMAT GetFileType(string filename, int size); + + + /// + /// Orders FreeImage to analyze the bitmap signature. + /// Supports UNICODE filenames. + /// + /// Name of the file to analyze. + /// Reserved parameter - use 0. + /// Type of the bitmap. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_GetFileTypeU")] + private static extern FREE_IMAGE_FORMAT GetFileTypeU(string filename, int size); + + /// + /// Uses the structure as described in the topic bitmap management functions + /// to identify a bitmap type. + /// + /// A structure with functionpointers to handle the source. + /// A handle to the source. + /// Size in bytes of the source. + /// Type of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFileTypeFromHandle")] + public static extern FREE_IMAGE_FORMAT GetFileTypeFromHandle(ref FreeImageIO io, fi_handle handle, int size); + + /// + /// Uses a memory handle to identify a bitmap type. + /// + /// Pointer to the stream. + /// Size in bytes of the source. + /// Type of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFileTypeFromMemory")] + public static extern FREE_IMAGE_FORMAT GetFileTypeFromMemory(FIMEMORY stream, int size); + + #endregion + + #region Helper functions + + /// + /// Returns whether the platform is using Little Endian. + /// + /// Returns true if the platform is using Litte Endian, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_IsLittleEndian")] + public static extern bool IsLittleEndian(); + + /// + /// Converts a X11 color name into a corresponding RGB value. + /// + /// Name of the color to convert. + /// Red component. + /// Green component. + /// Blue component. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_LookupX11Color")] + public static extern bool LookupX11Color(string szColor, out byte nRed, out byte nGreen, out byte nBlue); + + /// + /// Converts a SVG color name into a corresponding RGB value. + /// + /// Name of the color to convert. + /// Red component. + /// Green component. + /// Blue component. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_LookupSVGColor")] + public static extern bool LookupSVGColor(string szColor, out byte nRed, out byte nGreen, out byte nBlue); + + #endregion + + #region Pixel access functions + + /// + /// Returns a pointer to the data-bits of the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the data-bits. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetBits")] + public static extern IntPtr GetBits(FIBITMAP dib); + + /// + /// Returns a pointer to the start of the given scanline in the bitmap's data-bits. + /// + /// Handle to a FreeImage bitmap. + /// Number of the scanline. + /// Pointer to the scanline. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetScanLine")] + public static extern IntPtr GetScanLine(FIBITMAP dib, int scanline); + + /// + /// Get the pixel index of a palettized image at position (x, y), including range check (slow access). + /// + /// Handle to a FreeImage bitmap. + /// Pixel position in horizontal direction. + /// Pixel position in vertical direction. + /// The pixel index. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetPixelIndex")] + public static extern bool GetPixelIndex(FIBITMAP dib, uint x, uint y, out byte value); + + /// + /// Get the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access). + /// + /// Handle to a FreeImage bitmap. + /// Pixel position in horizontal direction. + /// Pixel position in vertical direction. + /// The pixel color. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetPixelColor")] + public static extern bool GetPixelColor(FIBITMAP dib, uint x, uint y, out RGBQUAD value); + + /// + /// Set the pixel index of a palettized image at position (x, y), including range check (slow access). + /// + /// Handle to a FreeImage bitmap. + /// Pixel position in horizontal direction. + /// Pixel position in vertical direction. + /// The new pixel index. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetPixelIndex")] + public static extern bool SetPixelIndex(FIBITMAP dib, uint x, uint y, ref byte value); + + /// + /// Set the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access). + /// + /// Handle to a FreeImage bitmap. + /// Pixel position in horizontal direction. + /// Pixel position in vertical direction. + /// The new pixel color. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetPixelColor")] + public static extern bool SetPixelColor(FIBITMAP dib, uint x, uint y, ref RGBQUAD value); + + #endregion + + #region Bitmap information functions + + /// + /// Retrieves the type of the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Type of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetImageType")] + public static extern FREE_IMAGE_TYPE GetImageType(FIBITMAP dib); + + /// + /// Returns the number of colors used in a bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Palette-size for palletised bitmaps, and 0 for high-colour bitmaps. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetColorsUsed")] + public static extern uint GetColorsUsed(FIBITMAP dib); + + /// + /// Returns the size of one pixel in the bitmap in bits. + /// + /// Handle to a FreeImage bitmap. + /// Size of one pixel in the bitmap in bits. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetBPP")] + public static extern uint GetBPP(FIBITMAP dib); + + /// + /// Returns the width of the bitmap in pixel units. + /// + /// Handle to a FreeImage bitmap. + /// With of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetWidth")] + public static extern uint GetWidth(FIBITMAP dib); + + /// + /// Returns the height of the bitmap in pixel units. + /// + /// Handle to a FreeImage bitmap. + /// Height of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetHeight")] + public static extern uint GetHeight(FIBITMAP dib); + + /// + /// Returns the width of the bitmap in bytes. + /// + /// Handle to a FreeImage bitmap. + /// With of the bitmap in bytes. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetLine")] + public static extern uint GetLine(FIBITMAP dib); + + /// + /// Returns the width of the bitmap in bytes, rounded to the next 32-bit boundary, + /// also known as pitch or stride or scan width. + /// + /// Handle to a FreeImage bitmap. + /// With of the bitmap in bytes. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetPitch")] + public static extern uint GetPitch(FIBITMAP dib); + + /// + /// Returns the size of the DIB-element of a FIBITMAP in memory. + /// + /// Handle to a FreeImage bitmap. + /// Size of the DIB-element + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetDIBSize")] + public static extern uint GetDIBSize(FIBITMAP dib); + + /// + /// Returns a pointer to the bitmap's palette. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the bitmap's palette. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetPalette")] + public static extern IntPtr GetPalette(FIBITMAP dib); + + /// + /// Returns the horizontal resolution, in pixels-per-meter, of the target device for the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The horizontal resolution, in pixels-per-meter. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetDotsPerMeterX")] + public static extern uint GetDotsPerMeterX(FIBITMAP dib); + + /// + /// Returns the vertical resolution, in pixels-per-meter, of the target device for the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The vertical resolution, in pixels-per-meter. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetDotsPerMeterY")] + public static extern uint GetDotsPerMeterY(FIBITMAP dib); + + /// + /// Set the horizontal resolution, in pixels-per-meter, of the target device for the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The new horizontal resolution. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetDotsPerMeterX")] + public static extern void SetDotsPerMeterX(FIBITMAP dib, uint res); + + /// + /// Set the vertical resolution, in pixels-per-meter, of the target device for the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The new vertical resolution. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetDotsPerMeterY")] + public static extern void SetDotsPerMeterY(FIBITMAP dib, uint res); + + /// + /// Returns a pointer to the of the DIB-element in a FIBITMAP. + /// + /// Handle to a FreeImage bitmap. + /// Poiter to the header of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetInfoHeader")] + public static extern IntPtr GetInfoHeader(FIBITMAP dib); + + /// + /// Alias for FreeImage_GetInfoHeader that returns a pointer to a + /// rather than to a . + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the structure for the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetInfo")] + public static extern IntPtr GetInfo(FIBITMAP dib); + + /// + /// Investigates the color type of the bitmap by reading the bitmap's pixel bits and analysing them. + /// + /// Handle to a FreeImage bitmap. + /// The color type of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetColorType")] + public static extern FREE_IMAGE_COLOR_TYPE GetColorType(FIBITMAP dib); + + /// + /// Returns a bit pattern describing the red color component of a pixel in a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The bit pattern for RED. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetRedMask")] + public static extern uint GetRedMask(FIBITMAP dib); + + /// + /// Returns a bit pattern describing the green color component of a pixel in a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The bit pattern for green. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetGreenMask")] + public static extern uint GetGreenMask(FIBITMAP dib); + + /// + /// Returns a bit pattern describing the blue color component of a pixel in a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The bit pattern for blue. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetBlueMask")] + public static extern uint GetBlueMask(FIBITMAP dib); + + /// + /// Returns the number of transparent colors in a palletised bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The number of transparent colors in a palletised bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTransparencyCount")] + public static extern uint GetTransparencyCount(FIBITMAP dib); + + /// + /// Returns a pointer to the bitmap's transparency table. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the bitmap's transparency table. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTransparencyTable")] + public static extern IntPtr GetTransparencyTable(FIBITMAP dib); + + /// + /// Tells FreeImage if it should make use of the transparency table + /// or the alpha channel that may accompany a bitmap. + /// + /// Handle to a FreeImage bitmap. + /// True to enable the transparency, false to disable. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTransparent")] + public static extern void SetTransparent(FIBITMAP dib, bool enabled); + + /// + /// Set the bitmap's transparency table. Only affects palletised bitmaps. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the bitmap's new transparency table. + /// The number of transparent colors in the new transparency table. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTransparencyTable")] + internal static extern void SetTransparencyTable(FIBITMAP dib, byte[] table, int count); + + /// + /// Returns whether the transparency table is enabled. + /// + /// Handle to a FreeImage bitmap. + /// Returns true when the transparency table is enabled (1-, 4- or 8-bit images) + /// or when the input dib contains alpha values (32-bit images). Returns false otherwise. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_IsTransparent")] + public static extern bool IsTransparent(FIBITMAP dib); + + /// + /// Returns whether the bitmap has a file background color. + /// + /// Handle to a FreeImage bitmap. + /// Returns true when the image has a file background color, false otherwise. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_HasBackgroundColor")] + public static extern bool HasBackgroundColor(FIBITMAP dib); + + /// + /// Returns the file background color of an image. + /// For 8-bit images, the color index in the palette is returned in the + /// rgbReserved member of the bkcolor parameter. + /// + /// Handle to a FreeImage bitmap. + /// The background color. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetBackgroundColor")] + public static extern bool GetBackgroundColor(FIBITMAP dib, out RGBQUAD bkcolor); + + /// + /// Set the file background color of an image. + /// When saving an image to PNG, this background color is transparently saved to the PNG file. + /// + /// Handle to a FreeImage bitmap. + /// The new background color. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetBackgroundColor")] + public static unsafe extern bool SetBackgroundColor(FIBITMAP dib, ref RGBQUAD bkcolor); + + /// + /// Set the file background color of an image. + /// When saving an image to PNG, this background color is transparently saved to the PNG file. + /// When the bkcolor parameter is null, the background color is removed from the image. + /// + /// This overloaded version of the function with an array parameter is provided to allow + /// passing null in the parameter. This is similar to the + /// original C/C++ function. Passing null as parameter will + /// unset the dib's previously set background color. + /// + /// + /// Handle to a FreeImage bitmap. + /// The new background color. + /// The first entry in the array is used. + /// Returns true on success, false on failure. + /// + /// + /// // create a RGBQUAD color + /// RGBQUAD color = new RGBQUAD(Color.Green); + /// + /// // set the dib's background color (using the other version of the function) + /// FreeImage.SetBackgroundColor(dib, ref color); + /// + /// // remove it again (this only works due to the array parameter RGBQUAD[]) + /// FreeImage.SetBackgroundColor(dib, null); + /// + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetBackgroundColor")] + public static unsafe extern bool SetBackgroundColor(FIBITMAP dib, RGBQUAD[] bkcolor); + + /// + /// Sets the index of the palette entry to be used as transparent color + /// for the image specified. Does nothing on high color images. + /// + /// Handle to a FreeImage bitmap. + /// The index of the palette entry to be set as transparent color. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTransparentIndex")] + public static extern void SetTransparentIndex(FIBITMAP dib, int index); + + /// + /// Returns the palette entry used as transparent color for the image specified. + /// Works for palletised images only and returns -1 for high color + /// images or if the image has no color set to be transparent. + /// + /// Handle to a FreeImage bitmap. + /// the index of the palette entry used as transparent color for + /// the image specified or -1 if there is no transparent color found + /// (e.g. the image is a high color image). + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTransparentIndex")] + public static extern int GetTransparentIndex(FIBITMAP dib); + + #endregion + + #region ICC profile functions + + /// + /// Retrieves the data of the bitmap. + /// This function can also be called safely, when the original format does not support profiles. + /// + /// Handle to a FreeImage bitmap. + /// The data of the bitmap. + public static FIICCPROFILE GetICCProfileEx(FIBITMAP dib) { unsafe { return *(FIICCPROFILE*)FreeImage.GetICCProfile(dib); } } + + /// + /// Retrieves a pointer to the data of the bitmap. + /// This function can also be called safely, when the original format does not support profiles. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the data of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetICCProfile")] + public static extern IntPtr GetICCProfile(FIBITMAP dib); + + /// + /// Creates a new block from ICC profile data previously read from a file + /// or built by a color management system. The profile data is attached to the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the new data. + /// Size of the data. + /// Pointer to the created structure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CreateICCProfile")] + public static extern IntPtr CreateICCProfile(FIBITMAP dib, byte[] data, int size); + + /// + /// This function destroys an previously created by . + /// After this call the bitmap will contain no profile information. + /// This function should be called to ensure that a stored bitmap will not contain any profile information. + /// + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_DestroyICCProfile")] + public static extern void DestroyICCProfile(FIBITMAP dib); + + #endregion + + #region Conversion functions + + /// + /// Converts a bitmap to 4 bits. + /// If the bitmap was a high-color bitmap (16, 24 or 32-bit) or if it was a + /// monochrome or greyscale bitmap (1 or 8-bit), the end result will be a + /// greyscale bitmap, otherwise (1-bit palletised bitmaps) it will be a palletised bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo4Bits")] + public static extern FIBITMAP ConvertTo4Bits(FIBITMAP dib); + + /// + /// Converts a bitmap to 8 bits. If the bitmap was a high-color bitmap (16, 24 or 32-bit) + /// or if it was a monochrome or greyscale bitmap (1 or 4-bit), the end result will be a + /// greyscale bitmap, otherwise (1 or 4-bit palletised bitmaps) it will be a palletised bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo8Bits")] + public static extern FIBITMAP ConvertTo8Bits(FIBITMAP dib); + + /// + /// Converts a bitmap to a 8-bit greyscale image with a linear ramp. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToGreyscale")] + public static extern FIBITMAP ConvertToGreyscale(FIBITMAP dib); + + /// + /// Converts a bitmap to 16 bits, where each pixel has a color pattern of + /// 5 bits red, 5 bits green and 5 bits blue. One bit in each pixel is unused. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo16Bits555")] + public static extern FIBITMAP ConvertTo16Bits555(FIBITMAP dib); + + /// + /// Converts a bitmap to 16 bits, where each pixel has a color pattern of + /// 5 bits red, 6 bits green and 5 bits blue. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo16Bits565")] + public static extern FIBITMAP ConvertTo16Bits565(FIBITMAP dib); + + /// + /// Converts a bitmap to 24 bits. A clone of the input bitmap is returned for 24-bit bitmaps. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo24Bits")] + public static extern FIBITMAP ConvertTo24Bits(FIBITMAP dib); + + /// + /// Converts a bitmap to 32 bits. A clone of the input bitmap is returned for 32-bit bitmaps. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo32Bits")] + public static extern FIBITMAP ConvertTo32Bits(FIBITMAP dib); + + /// + /// Quantizes a high-color 24-bit bitmap to an 8-bit palette color bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Specifies the color reduction algorithm to be used. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ColorQuantize")] + public static extern FIBITMAP ColorQuantize(FIBITMAP dib, FREE_IMAGE_QUANTIZE quantize); + + /// + /// ColorQuantizeEx is an extension to the method that + /// provides additional options used to quantize a 24-bit image to any + /// number of colors (up to 256), as well as quantize a 24-bit image using a + /// partial or full provided palette. + /// + /// Handle to a FreeImage bitmap. + /// Specifies the color reduction algorithm to be used. + /// Size of the desired output palette. + /// Size of the provided palette of ReservePalette. + /// The provided palette. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ColorQuantizeEx")] + public static extern FIBITMAP ColorQuantizeEx(FIBITMAP dib, FREE_IMAGE_QUANTIZE quantize, int PaletteSize, int ReserveSize, RGBQUAD[] ReservePalette); + + /// + /// Converts a bitmap to 1-bit monochrome bitmap using a threshold T between [0..255]. + /// The function first converts the bitmap to a 8-bit greyscale bitmap. + /// Then, any brightness level that is less than T is set to zero, otherwise to 1. + /// For 1-bit input bitmaps, the function clones the input bitmap and builds a monochrome palette. + /// + /// Handle to a FreeImage bitmap. + /// The threshold. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Threshold")] + public static extern FIBITMAP Threshold(FIBITMAP dib, byte t); + + /// + /// Converts a bitmap to 1-bit monochrome bitmap using a dithering algorithm. + /// For 1-bit input bitmaps, the function clones the input bitmap and builds a monochrome palette. + /// + /// Handle to a FreeImage bitmap. + /// The dithering algorithm to use. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Dither")] + public static extern FIBITMAP Dither(FIBITMAP dib, FREE_IMAGE_DITHER algorithm); + + /// + /// Converts a raw bitmap to a FreeImage bitmap. + /// + /// Pointer to the memory block containing the raw bitmap. + /// The width in pixels of the raw bitmap. + /// The height in pixels of the raw bitmap. + /// Defines the total width of a scanline in the raw bitmap, + /// including padding bytes. + /// The bit depth (bits per pixel) of the raw bitmap. + /// The bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap is stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertFromRawBits")] + public static extern FIBITMAP ConvertFromRawBits(IntPtr bits, int width, int height, int pitch, + uint bpp, uint red_mask, uint green_mask, uint blue_mask, bool topdown); + + /// + /// Converts a raw bitmap to a FreeImage bitmap. + /// + /// Array of bytes containing the raw bitmap. + /// The width in pixels of the raw bitmap. + /// The height in pixels of the raw bitmap. + /// Defines the total width of a scanline in the raw bitmap, + /// including padding bytes. + /// The bit depth (bits per pixel) of the raw bitmap. + /// The bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap is stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertFromRawBits")] + public static extern FIBITMAP ConvertFromRawBits(byte[] bits, int width, int height, int pitch, + uint bpp, uint red_mask, uint green_mask, uint blue_mask, bool topdown); + + /// + /// Converts a FreeImage bitmap to a raw bitmap, that is a raw piece of memory. + /// + /// Pointer to the memory block receiving the raw bitmap. + /// Handle to a FreeImage bitmap. + /// The desired total width in bytes of a scanline in the raw bitmap, + /// including any padding bytes. + /// The desired bit depth (bits per pixel) of the raw bitmap. + /// The desired bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The desired bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The desired bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap will be stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToRawBits")] + public static extern void ConvertToRawBits(IntPtr bits, FIBITMAP dib, int pitch, uint bpp, + uint red_mask, uint green_mask, uint blue_mask, bool topdown); + + /// + /// Converts a FreeImage bitmap to a raw bitmap, that is a raw piece of memory. + /// + /// Array of bytes receiving the raw bitmap. + /// Handle to a FreeImage bitmap. + /// The desired total width in bytes of a scanline in the raw bitmap, + /// including any padding bytes. + /// The desired bit depth (bits per pixel) of the raw bitmap. + /// The desired bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The desired bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The desired bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap will be stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToRawBits")] + public static extern void ConvertToRawBits(byte[] bits, FIBITMAP dib, int pitch, uint bpp, + uint red_mask, uint green_mask, uint blue_mask, bool topdown); + + /// + /// Converts a 24- or 32-bit RGB(A) standard image or a 48-bit RGB image to a FIT_RGBF type image. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToRGBF")] + public static extern FIBITMAP ConvertToRGBF(FIBITMAP dib); + + /// + /// Converts a non standard image whose color type is FIC_MINISBLACK + /// to a standard 8-bit greyscale image. + /// + /// Handle to a FreeImage bitmap. + /// When true the conversion is done by scaling linearly + /// each pixel value from [min, max] to an integer value between [0..255], + /// where min and max are the minimum and maximum pixel values in the image. + /// When false the conversion is done by rounding each pixel value to an integer between [0..255]. + /// + /// Rounding is done using the following formula: + /// + /// dst_pixel = (BYTE) MIN(255, MAX(0, q)) where int q = int(src_pixel + 0.5); + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToStandardType")] + public static extern FIBITMAP ConvertToStandardType(FIBITMAP src, bool scale_linear); + + /// + /// Converts an image of any type to type dst_type. + /// + /// Handle to a FreeImage bitmap. + /// Destination type. + /// True to scale linear, else false. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToType")] + public static extern FIBITMAP ConvertToType(FIBITMAP src, FREE_IMAGE_TYPE dst_type, bool scale_linear); + + #endregion + + #region Tone mapping operators + + /// + /// Converts a High Dynamic Range image (48-bit RGB or 96-bit RGBF) to a 24-bit RGB image, suitable for display. + /// + /// Handle to a FreeImage bitmap. + /// The tone mapping operator to be used. + /// Parmeter depending on the used algorithm + /// Parmeter depending on the used algorithm + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ToneMapping")] + public static extern FIBITMAP ToneMapping(FIBITMAP dib, FREE_IMAGE_TMO tmo, double first_param, double second_param); + + /// + /// Converts a High Dynamic Range image to a 24-bit RGB image using a global + /// operator based on logarithmic compression of luminance values, imitating the human response to light. + /// + /// Handle to a FreeImage bitmap. + /// A gamma correction that is applied after the tone mapping. + /// A value of 1 means no correction. + /// Scale factor allowing to adjust the brightness of the output image. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_TmoDrago03")] + public static extern FIBITMAP TmoDrago03(FIBITMAP src, double gamma, double exposure); + + /// + /// Converts a High Dynamic Range image to a 24-bit RGB image using a global operator inspired + /// by photoreceptor physiology of the human visual system. + /// + /// Handle to a FreeImage bitmap. + /// Controls the overall image intensity in the range [-8, 8]. + /// Controls the overall image contrast in the range [0.3, 1.0[. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_TmoReinhard05")] + public static extern FIBITMAP TmoReinhard05(FIBITMAP src, double intensity, double contrast); + + /// + /// Apply the Gradient Domain High Dynamic Range Compression to a RGBF image and convert to 24-bit RGB. + /// + /// Handle to a FreeImage bitmap. + /// Color saturation (s parameter in the paper) in [0.4..0.6] + /// Atenuation factor (beta parameter in the paper) in [0.8..0.9] + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_TmoFattal02")] + public static extern FIBITMAP TmoFattal02(FIBITMAP src, double color_saturation, double attenuation); + + #endregion + + #region Compression functions + + /// + /// Compresses a source buffer into a target buffer, using the ZLib library. + /// + /// Pointer to the target buffer. + /// Size of the target buffer. + /// Must be at least 0.1% larger than source_size plus 12 bytes. + /// Pointer to the source buffer. + /// Size of the source buffer. + /// The actual size of the compressed buffer, or 0 if an error occurred. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ZLibCompress")] + public static extern uint ZLibCompress(byte[] target, uint target_size, byte[] source, uint source_size); + + /// + /// Decompresses a source buffer into a target buffer, using the ZLib library. + /// + /// Pointer to the target buffer. + /// Size of the target buffer. + /// Must have been saved outlide of zlib. + /// Pointer to the source buffer. + /// Size of the source buffer. + /// The actual size of the uncompressed buffer, or 0 if an error occurred. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ZLibUncompress")] + public static extern uint ZLibUncompress(byte[] target, uint target_size, byte[] source, uint source_size); + + /// + /// Compresses a source buffer into a target buffer, using the ZLib library. + /// + /// Pointer to the target buffer. + /// Size of the target buffer. + /// Must be at least 0.1% larger than source_size plus 24 bytes. + /// Pointer to the source buffer. + /// Size of the source buffer. + /// The actual size of the compressed buffer, or 0 if an error occurred. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ZLibGZip")] + public static extern uint ZLibGZip(byte[] target, uint target_size, byte[] source, uint source_size); + + /// + /// Decompresses a source buffer into a target buffer, using the ZLib library. + /// + /// Pointer to the target buffer. + /// Size of the target buffer. + /// Must have been saved outlide of zlib. + /// Pointer to the source buffer. + /// Size of the source buffer. + /// The actual size of the uncompressed buffer, or 0 if an error occurred. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ZLibGUnzip")] + public static extern uint ZLibGUnzip(byte[] target, uint target_size, byte[] source, uint source_size); + + /// + /// Generates a CRC32 checksum. + /// + /// The CRC32 checksum to begin with. + /// Pointer to the source buffer. + /// If the value is 0, the function returns the required initial value for the crc. + /// Size of the source buffer. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ZLibCRC32")] + public static extern uint ZLibCRC32(uint crc, byte[] source, uint source_size); + + #endregion + + #region Tag creation and destruction + + /// + /// Allocates a new object. + /// This object must be destroyed with a call to + /// when no longer in use. + /// + /// The new . + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CreateTag")] + public static extern FITAG CreateTag(); + + /// + /// Delete a previously allocated object. + /// + /// The to destroy. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_DeleteTag")] + public static extern void DeleteTag(FITAG tag); + + /// + /// Creates and returns a copy of a object. + /// + /// The to clone. + /// The new . + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CloneTag")] + public static extern FITAG CloneTag(FITAG tag); + + #endregion + + #region Tag accessors + + /// + /// Returns the tag field name (unique inside a metadata model). + /// + /// The tag field. + /// The field name. + public static unsafe string GetTagKey(FITAG tag) { return PtrToStr(GetTagKey_(tag)); } + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetTagKey")] + private static unsafe extern byte* GetTagKey_(FITAG tag); + + /// + /// Returns the tag description. + /// + /// The tag field. + /// The description or NULL if unavailable. + public static unsafe string GetTagDescription(FITAG tag) { return PtrToStr(GetTagDescription_(tag)); } + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetTagDescription")] + private static unsafe extern byte* GetTagDescription_(FITAG tag); + + /// + /// Returns the tag ID. + /// + /// The tag field. + /// The ID or 0 if unavailable. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTagID")] + public static extern ushort GetTagID(FITAG tag); + + /// + /// Returns the tag data type. + /// + /// The tag field. + /// The tag type. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTagType")] + public static extern FREE_IMAGE_MDTYPE GetTagType(FITAG tag); + + /// + /// Returns the number of components in the tag (in tag type units). + /// + /// The tag field. + /// The number of components. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTagCount")] + public static extern uint GetTagCount(FITAG tag); + + /// + /// Returns the length of the tag value in bytes. + /// + /// The tag field. + /// The length of the tag value. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTagLength")] + public static extern uint GetTagLength(FITAG tag); + + /// + /// Returns the tag value. + /// It is up to the programmer to interpret the returned pointer correctly, + /// according to the results of GetTagType and GetTagCount. + /// + /// The tag field. + /// Pointer to the value. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTagValue")] + public static extern IntPtr GetTagValue(FITAG tag); + + /// + /// Sets the tag field name. + /// + /// The tag field. + /// The new name. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_SetTagKey")] + public static extern bool SetTagKey(FITAG tag, string key); + + /// + /// Sets the tag description. + /// + /// The tag field. + /// The new description. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_SetTagDescription")] + public static extern bool SetTagDescription(FITAG tag, string description); + + /// + /// Sets the tag ID. + /// + /// The tag field. + /// The new ID. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTagID")] + public static extern bool SetTagID(FITAG tag, ushort id); + + /// + /// Sets the tag data type. + /// + /// The tag field. + /// The new type. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTagType")] + public static extern bool SetTagType(FITAG tag, FREE_IMAGE_MDTYPE type); + + /// + /// Sets the number of data in the tag. + /// + /// The tag field. + /// New number of data. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTagCount")] + public static extern bool SetTagCount(FITAG tag, uint count); + + /// + /// Sets the length of the tag value in bytes. + /// + /// The tag field. + /// The new length. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTagLength")] + public static extern bool SetTagLength(FITAG tag, uint length); + + /// + /// Sets the tag value. + /// + /// The tag field. + /// Pointer to the new value. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTagValue")] + public static extern bool SetTagValue(FITAG tag, byte[] value); + + #endregion + + #region Metadata iterator + + /// + /// Provides information about the first instance of a tag that matches the metadata model. + /// + /// The model to match. + /// Handle to a FreeImage bitmap. + /// Tag that matches the metadata model. + /// Unique search handle that can be used to call FindNextMetadata or FindCloseMetadata. + /// Null if the metadata model does not exist. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FindFirstMetadata")] + public static extern FIMETADATA FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP dib, out FITAG tag); + + /// + /// Find the next tag, if any, that matches the metadata model argument in a previous call + /// to FindFirstMetadata, and then alters the tag object contents accordingly. + /// + /// Unique search handle provided by FindFirstMetadata. + /// Tag that matches the metadata model. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FindNextMetadata")] + public static extern bool FindNextMetadata(FIMETADATA mdhandle, out FITAG tag); + + /// + /// Closes the specified metadata search handle and releases associated resources. + /// + /// The handle to close. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FindCloseMetadata")] + private static extern void FindCloseMetadata_(FIMETADATA mdhandle); + + #endregion + + #region Metadata setter and getter + + /// + /// Retrieve a metadata attached to a dib. + /// + /// The metadata model to look for. + /// Handle to a FreeImage bitmap. + /// The metadata field name. + /// A FITAG structure returned by the function. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetMetadata")] + public static extern bool GetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, out FITAG tag); + + /// + /// Attach a new FreeImage tag to a dib. + /// + /// The metadata model used to store the tag. + /// Handle to a FreeImage bitmap. + /// The tag field name. + /// The FreeImage tag to be attached. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_SetMetadata")] + public static extern bool SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, FITAG tag); + + #endregion + + #region Metadata helper functions + + /// + /// Returns the number of tags contained in the model metadata model attached to the input dib. + /// + /// The metadata model. + /// Handle to a FreeImage bitmap. + /// Number of tags contained in the metadata model. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetMetadataCount")] + public static extern uint GetMetadataCount(FREE_IMAGE_MDMODEL model, FIBITMAP dib); + + /// + /// Copies the metadata of FreeImage bitmap to another. + /// + /// The FreeImage bitmap to copy the metadata to. + /// The FreeImage bitmap to copy the metadata from. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CloneMetadata")] + public static extern bool CloneMetadata(FIBITMAP dst, FIBITMAP src); + + /// + /// Converts a FreeImage tag structure to a string that represents the interpreted tag value. + /// The function is not thread safe. + /// + /// The metadata model. + /// The interpreted tag value. + /// Reserved. + /// The representing string. + public static unsafe string TagToString(FREE_IMAGE_MDMODEL model, FITAG tag, uint Make) { return PtrToStr(TagToString_(model, tag, Make)); } + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_TagToString")] + private static unsafe extern byte* TagToString_(FREE_IMAGE_MDMODEL model, FITAG tag, uint Make); + + #endregion + + #region Rotation and flipping + + /// + /// This function rotates a 1-, 8-bit greyscale or a 24-, 32-bit color image by means of 3 shears. + /// 1-bit images rotation is limited to integer multiple of 90°. + /// null is returned for other values. + /// + /// Handle to a FreeImage bitmap. + /// The angle of rotation. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_RotateClassic")] + [Obsolete("RotateClassic is deprecated (use Rotate instead).")] + public static extern FIBITMAP RotateClassic(FIBITMAP dib, double angle); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Rotate")] + internal static extern FIBITMAP Rotate(FIBITMAP dib, double angle, IntPtr backgroundColor); + + /// + /// This function performs a rotation and / or translation of an 8-bit greyscale, + /// 24- or 32-bit image, using a 3rd order (cubic) B-Spline. + /// + /// Handle to a FreeImage bitmap. + /// The angle of rotation. + /// Horizontal image translation. + /// Vertical image translation. + /// Rotation center x-coordinate. + /// Rotation center y-coordinate. + /// When true the irrelevant part of the image is set to a black color, + /// otherwise, a mirroring technique is used to fill irrelevant pixels. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_RotateEx")] + public static extern FIBITMAP RotateEx(FIBITMAP dib, double angle, + double x_shift, double y_shift, double x_origin, double y_origin, bool use_mask); + + /// + /// Flip the input dib horizontally along the vertical axis. + /// + /// Handle to a FreeImage bitmap. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FlipHorizontal")] + public static extern bool FlipHorizontal(FIBITMAP dib); + + /// + /// Flip the input dib vertically along the horizontal axis. + /// + /// Handle to a FreeImage bitmap. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FlipVertical")] + public static extern bool FlipVertical(FIBITMAP dib); + + /// + /// Performs a lossless rotation or flipping on a JPEG file. + /// + /// Source file. + /// Destination file; can be the source file; will be overwritten. + /// The operation to apply. + /// To avoid lossy transformation, you can set the perfect parameter to true. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_JPEGTransformU")] + public static extern bool JPEGTransform(string src_file, string dst_file, + FREE_IMAGE_JPEG_OPERATION operation, bool perfect); + + #endregion + + #region Upsampling / downsampling + + /// + /// Performs resampling (or scaling, zooming) of a greyscale or RGB(A) image + /// to the desired destination width and height. + /// + /// Handle to a FreeImage bitmap. + /// Destination width. + /// Destination height. + /// The filter to apply. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Rescale")] + public static extern FIBITMAP Rescale(FIBITMAP dib, int dst_width, int dst_height, FREE_IMAGE_FILTER filter); + + /// + /// Creates a thumbnail from a greyscale or RGB(A) image, keeping aspect ratio. + /// + /// Handle to a FreeImage bitmap. + /// Thumbnail square size. + /// When true HDR images are transperantly converted to standard images. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_MakeThumbnail")] + public static extern FIBITMAP MakeThumbnail(FIBITMAP dib, int max_pixel_size, bool convert); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_EnlargeCanvas")] + internal static extern FIBITMAP EnlargeCanvas(FIBITMAP dib, + int left, int top, int right, int bottom, IntPtr color, FREE_IMAGE_COLOR_OPTIONS options); + + #endregion + + #region Color manipulation + + /// + /// Perfoms an histogram transformation on a 8-, 24- or 32-bit image. + /// + /// Handle to a FreeImage bitmap. + /// The lookup table. + /// It's size is assumed to be 256 in length. + /// The color channel to be transformed. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AdjustCurve")] + public static extern bool AdjustCurve(FIBITMAP dib, byte[] lookUpTable, FREE_IMAGE_COLOR_CHANNEL channel); + + /// + /// Performs gamma correction on a 8-, 24- or 32-bit image. + /// + /// Handle to a FreeImage bitmap. + /// The parameter represents the gamma value to use (gamma > 0). + /// A value of 1.0 leaves the image alone, less than one darkens it, and greater than one lightens it. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AdjustGamma")] + public static extern bool AdjustGamma(FIBITMAP dib, double gamma); + + /// + /// Adjusts the brightness of a 8-, 24- or 32-bit image by a certain amount. + /// + /// Handle to a FreeImage bitmap. + /// A value 0 means no change, + /// less than 0 will make the image darker and greater than 0 will make the image brighter. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AdjustBrightness")] + public static extern bool AdjustBrightness(FIBITMAP dib, double percentage); + + /// + /// Adjusts the contrast of a 8-, 24- or 32-bit image by a certain amount. + /// + /// Handle to a FreeImage bitmap. + /// A value 0 means no change, + /// less than 0 will decrease the contrast and greater than 0 will increase the contrast of the image. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AdjustContrast")] + public static extern bool AdjustContrast(FIBITMAP dib, double percentage); + + /// + /// Inverts each pixel data. + /// + /// Handle to a FreeImage bitmap. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Invert")] + public static extern bool Invert(FIBITMAP dib); + + /// + /// Computes the image histogram. + /// + /// Handle to a FreeImage bitmap. + /// Array of integers with a size of 256. + /// Channel to compute from. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetHistogram")] + public static extern bool GetHistogram(FIBITMAP dib, int[] histo, FREE_IMAGE_COLOR_CHANNEL channel); + + #endregion + + #region Channel processing + + /// + /// Retrieves the red, green, blue or alpha channel of a 24- or 32-bit image. + /// + /// Handle to a FreeImage bitmap. + /// The color channel to extract. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetChannel")] + public static extern FIBITMAP GetChannel(FIBITMAP dib, FREE_IMAGE_COLOR_CHANNEL channel); + + /// + /// Insert a 8-bit dib into a 24- or 32-bit image. + /// Both images must have to same width and height. + /// + /// Handle to a FreeImage bitmap. + /// Handle to the bitmap to insert. + /// The color channel to replace. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetChannel")] + public static extern bool SetChannel(FIBITMAP dib, FIBITMAP dib8, FREE_IMAGE_COLOR_CHANNEL channel); + + /// + /// Retrieves the real part, imaginary part, magnitude or phase of a complex image. + /// + /// Handle to a FreeImage bitmap. + /// The color channel to extract. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetComplexChannel")] + public static extern FIBITMAP GetComplexChannel(FIBITMAP src, FREE_IMAGE_COLOR_CHANNEL channel); + + /// + /// Set the real or imaginary part of a complex image. + /// Both images must have to same width and height. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + /// The color channel to replace. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetComplexChannel")] + public static extern bool SetComplexChannel(FIBITMAP dst, FIBITMAP src, FREE_IMAGE_COLOR_CHANNEL channel); + + #endregion + + #region Copy / Paste / Composite routines + + /// + /// Copy a sub part of the current dib image. + /// + /// Handle to a FreeImage bitmap. + /// Specifies the left position of the cropped rectangle. + /// Specifies the top position of the cropped rectangle. + /// Specifies the right position of the cropped rectangle. + /// Specifies the bottom position of the cropped rectangle. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Copy")] + public static extern FIBITMAP Copy(FIBITMAP dib, int left, int top, int right, int bottom); + + /// + /// Alpha blend or combine a sub part image with the current dib image. + /// The bit depth of the dst bitmap must be greater than or equal to the bit depth of the src. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + /// Specifies the left position of the sub image. + /// Specifies the top position of the sub image. + /// alpha blend factor. + /// The source and destination images are alpha blended if alpha=0..255. + /// If alpha > 255, then the source image is combined to the destination image. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Paste")] + public static extern bool Paste(FIBITMAP dst, FIBITMAP src, int left, int top, int alpha); + + /// + /// This function composite a transparent foreground image against a single background color or + /// against a background image. + /// + /// Handle to a FreeImage bitmap. + /// When true the background of fg is used if it contains one. + /// The application background is used if useFileBkg is false. + /// Image used as background when useFileBkg is false or fg has no background + /// and appBkColor is null. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Composite")] + public static extern FIBITMAP Composite(FIBITMAP fg, bool useFileBkg, ref RGBQUAD appBkColor, FIBITMAP bg); + + /// + /// This function composite a transparent foreground image against a single background color or + /// against a background image. + /// + /// Handle to a FreeImage bitmap. + /// When true the background of fg is used if it contains one. + /// The application background is used if useFileBkg is false + /// and 'appBkColor' is not null. + /// Image used as background when useFileBkg is false or fg has no background + /// and appBkColor is null. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Composite")] + public static extern FIBITMAP Composite(FIBITMAP fg, bool useFileBkg, RGBQUAD[] appBkColor, FIBITMAP bg); + + /// + /// Performs a lossless crop on a JPEG file. + /// + /// Source filename. + /// Destination filename. + /// Specifies the left position of the cropped rectangle. + /// Specifies the top position of the cropped rectangle. + /// Specifies the right position of the cropped rectangle. + /// Specifies the bottom position of the cropped rectangle. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_JPEGCropU")] + public static extern bool JPEGCrop(string src_file, string dst_file, int left, int top, int right, int bottom); + + /// + /// Applies the alpha value of each pixel to its color components. + /// The aplha value stays unchanged. + /// Only works with 32-bits color depth. + /// + /// Handle to a FreeImage bitmap. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_PreMultiplyWithAlpha")] + public static extern bool PreMultiplyWithAlpha(FIBITMAP dib); + + #endregion + + #region Miscellaneous algorithms + + /// + /// Solves a Poisson equation, remap result pixels to [0..1] and returns the solution. + /// + /// Handle to a FreeImage bitmap. + /// Number of cycles in the multigrid algorithm (usually 2 or 3) + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_MultigridPoissonSolver")] + public static extern FIBITMAP MultigridPoissonSolver(FIBITMAP Laplacian, int ncycle); + + #endregion + + #region Colors + + /// + /// Creates a lookup table to be used with which may adjusts brightness and + /// contrast, correct gamma and invert the image with a single call to . + /// + /// Output lookup table to be used with . + /// The size of 'lookUpTable' is assumed to be 256. + /// Percentage brightness value where -100 <= brightness <= 100. + /// A value of 0 means no change, less than 0 will make the image darker and greater + /// than 0 will make the image brighter. + /// Percentage contrast value where -100 <= contrast <= 100. + /// A value of 0 means no change, less than 0 will decrease the contrast + /// and greater than 0 will increase the contrast of the image. + /// Gamma value to be used for gamma correction. + /// A value of 1.0 leaves the image alone, less than one darkens it, + /// and greater than one lightens it. + /// If set to true, the image will be inverted. + /// The number of adjustments applied to the resulting lookup table + /// compared to a blind lookup table. + /// + /// This function creates a lookup table to be used with which may adjust + /// brightness and contrast, correct gamma and invert the image with a single call to + /// . If more than one of these image display properties need to be adjusted, + /// using a combined lookup table should be preferred over calling each adjustment function + /// separately. That's particularly true for huge images or if performance is an issue. Then, + /// the expensive process of iterating over all pixels of an image is performed only once and + /// not up to four times. + /// + /// Furthermore, the lookup table created does not depend on the order, in which each single + /// adjustment operation is performed. Due to rounding and byte casting issues, it actually + /// matters in which order individual adjustment operations are performed. Both of the following + /// snippets most likely produce different results: + /// + /// + /// // snippet 1: contrast, brightness + /// AdjustContrast(dib, 15.0); + /// AdjustBrightness(dib, 50.0); + /// + /// + /// + /// // snippet 2: brightness, contrast + /// AdjustBrightness(dib, 50.0); + /// AdjustContrast(dib, 15.0); + /// + /// + /// Better and even faster would be snippet 3: + /// + /// + /// // snippet 3: + /// byte[] lut = new byte[256]; + /// GetAdjustColorsLookupTable(lut, 50.0, 15.0, 1.0, false); + /// AdjustCurve(dib, lut, FREE_IMAGE_COLOR_CHANNEL.FICC_RGB); + /// + /// + /// This function is also used internally by , which does not return the + /// lookup table, but uses it to call on the passed image. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetAdjustColorsLookupTable")] + public static extern int GetAdjustColorsLookupTable(byte[] lookUpTable, double brightness, double contrast, double gamma, bool invert); + + /// + /// Adjusts an image's brightness, contrast and gamma as well as it may + /// optionally invert the image within a single operation. + /// + /// Handle to a FreeImage bitmap. + /// Percentage brightness value where -100 <= brightness <= 100. + /// A value of 0 means no change, less than 0 will make the image darker and greater + /// than 0 will make the image brighter. + /// Percentage contrast value where -100 <= contrast <= 100. + /// A value of 0 means no change, less than 0 will decrease the contrast + /// and greater than 0 will increase the contrast of the image. + /// Gamma value to be used for gamma correction. + /// A value of 1.0 leaves the image alone, less than one darkens it, + /// and greater than one lightens it. + /// This parameter must not be zero or smaller than zero. + /// If so, it will be ignored and no gamma correction will be performed on the image. + /// If set to true, the image will be inverted. + /// Returns true on success, false on failure. + /// + /// This function adjusts an image's brightness, contrast and gamma as well as it + /// may optionally invert the image within a single operation. If more than one of + /// these image display properties need to be adjusted, using this function should + /// be preferred over calling each adjustment function separately. That's particularly + /// true for huge images or if performance is an issue. + /// + /// This function relies on , + /// which creates a single lookup table, that combines all adjustment operations requested. + /// + /// Furthermore, the lookup table created by does + /// not depend on the order, in which each single adjustment operation is performed. + /// Due to rounding and byte casting issues, it actually matters in which order individual + /// adjustment operations are performed. Both of the following snippets most likely produce + /// different results: + /// + /// + /// // snippet 1: contrast, brightness + /// AdjustContrast(dib, 15.0); + /// AdjustBrightness(dib, 50.0); + /// + /// + /// + /// // snippet 2: brightness, contrast + /// AdjustBrightness(dib, 50.0); + /// AdjustContrast(dib, 15.0); + /// + /// + /// Better and even faster would be snippet 3: + /// + /// + /// // snippet 3: + /// AdjustColors(dib, 50.0, 15.0, 1.0, false); + /// + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AdjustColors")] + public static extern bool AdjustColors(FIBITMAP dib, double brightness, double contrast, double gamma, bool invert); + + /// + /// Applies color mapping for one or several colors on a 1-, 4- or 8-bit + /// palletized or a 16-, 24- or 32-bit high color image. + /// + /// Handle to a FreeImage bitmap. + /// Array of colors to be used as the mapping source. + /// Array of colors to be used as the mapping destination. + /// The number of colors to be mapped. This is the size of both + /// srccolors and dstcolors. + /// If true, 32-bit images and colors are treated as 24-bit. + /// If true, source and destination colors are swapped, that is, + /// each destination color is also mapped to the corresponding source color. + /// The total number of pixels changed. + /// + /// This function maps up to colors specified in + /// to these specified in . + /// Thereby, color srccolors[N], if found in the image, will be replaced by color + /// dstcolors[N]. If is true, additionally all colors + /// specified in are also mapped to these specified + /// in . For high color images, the actual image data will be + /// modified whereas, for palletized images only the palette will be changed. + /// + /// The function returns the number of pixels changed or zero, if no pixels were changed. + /// + /// Both arrays and are assumed + /// not to hold less than colors. + /// + /// For 16-bit images, all colors specified are transparently converted to their + /// proper 16-bit representation (either in RGB555 or RGB565 format, which is determined + /// by the image's red- green- and blue-mask). + /// + /// Note, that this behaviour is different from what does, + /// which modifies the actual image data on palletized images. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ApplyColorMapping")] + public static extern uint ApplyColorMapping(FIBITMAP dib, RGBQUAD[] srccolors, RGBQUAD[] dstcolors, uint count, bool ignore_alpha, bool swap); + + /// + /// Swaps two specified colors on a 1-, 4- or 8-bit palletized + /// or a 16-, 24- or 32-bit high color image. + /// + /// Handle to a FreeImage bitmap. + /// One of the two colors to be swapped. + /// The other of the two colors to be swapped. + /// If true, 32-bit images and colors are treated as 24-bit. + /// The total number of pixels changed. + /// + /// This function swaps the two specified colors and + /// on a palletized or high color image. + /// For high color images, the actual image data will be modified whereas, for palletized + /// images only the palette will be changed. + /// + /// Note, that this behaviour is different from what does, + /// which modifies the actual image data on palletized images. + /// + /// This is just a thin wrapper for and resolves to: + /// + /// + /// return ApplyColorMapping(dib, color_a, color_b, 1, ignore_alpha, true); + /// + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SwapColors")] + public static extern uint SwapColors(FIBITMAP dib, ref RGBQUAD color_a, ref RGBQUAD color_b, bool ignore_alpha); + + /// + /// Applies palette index mapping for one or several indices + /// on a 1-, 4- or 8-bit palletized image. + /// + /// Handle to a FreeImage bitmap. + /// Array of palette indices to be used as the mapping source. + /// Array of palette indices to be used as the mapping destination. + /// The number of palette indices to be mapped. This is the size of both + /// srcindices and dstindices + /// If true, source and destination palette indices are swapped, that is, + /// each destination index is also mapped to the corresponding source index. + /// The total number of pixels changed. + /// + /// This function maps up to palette indices specified in + /// to these specified in . + /// Thereby, index srcindices[N], if present in the image, will be replaced by index + /// dstindices[N]. If is true, additionally all indices + /// specified in are also mapped to these specified in + /// . + /// + /// The function returns the number of pixels changed or zero, if no pixels were changed. + /// Both arrays and are assumed not to + /// hold less than indices. + /// + /// Note, that this behaviour is different from what does, which + /// modifies the actual image data on palletized images. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ApplyPaletteIndexMapping")] + public static extern uint ApplyPaletteIndexMapping(FIBITMAP dib, byte[] srcindices, byte[] dstindices, uint count, bool swap); + + /// + /// Swaps two specified palette indices on a 1-, 4- or 8-bit palletized image. + /// + /// Handle to a FreeImage bitmap. + /// One of the two palette indices to be swapped. + /// The other of the two palette indices to be swapped. + /// The total number of pixels changed. + /// + /// This function swaps the two specified palette indices index_a and + /// index_b on a palletized image. Therefore, not the palette, but the + /// actual image data will be modified. + /// + /// Note, that this behaviour is different from what does on palletized images, + /// which only swaps the colors in the palette. + /// + /// This is just a thin wrapper for and resolves to: + /// + /// + /// return ApplyPaletteIndexMapping(dib, index_a, index_b, 1, true); + /// + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SwapPaletteIndices")] + public static extern uint SwapPaletteIndices(FIBITMAP dib, ref byte index_a, ref byte index_b); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FillBackground")] + internal static extern bool FillBackground(FIBITMAP dib, IntPtr color, FREE_IMAGE_COLOR_OPTIONS options); + + #endregion + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/FreeImageWrapper.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/FreeImageWrapper.cs new file mode 100644 index 0000000..696d77a --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/FreeImageWrapper.cs @@ -0,0 +1,5329 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.19 $ +// $Date: 2011/10/02 13:00:45 $ +// $Id: FreeImageWrapper.cs,v 1.19 2011/10/02 13:00:45 drolon Exp $ +// ========================================================== + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using FreeImageAPI.IO; +using FreeImageAPI.Metadata; + +namespace FreeImageAPI +{ + /// + /// Static class importing functions from the FreeImage library + /// and providing additional functions. + /// + public static partial class FreeImage + { + #region Constants + + /// + /// Array containing all 'FREE_IMAGE_MDMODEL's. + /// + public static readonly FREE_IMAGE_MDMODEL[] FREE_IMAGE_MDMODELS = + (FREE_IMAGE_MDMODEL[])Enum.GetValues(typeof(FREE_IMAGE_MDMODEL)); + + /// + /// Stores handles used to read from streams. + /// + private static Dictionary streamHandles = + new Dictionary(); + + /// + /// Version of the wrapper library. + /// + private static Version WrapperVersion; + + private const int DIB_RGB_COLORS = 0; + private const int DIB_PAL_COLORS = 1; + private const int CBM_INIT = 0x4; + + /// + /// An uncompressed format. + /// + public const int BI_RGB = 0; + + /// + /// A run-length encoded (RLE) format for bitmaps with 8 bpp. The compression format is a 2-byte + /// format consisting of a count byte followed by a byte containing a color index. + /// + public const int BI_RLE8 = 1; + + /// + /// An RLE format for bitmaps with 4 bpp. The compression format is a 2-byte format consisting + /// of a count byte followed by two word-length color indexes. + /// + public const int BI_RLE4 = 2; + + /// + /// Specifies that the bitmap is not compressed and that the color table consists of three + /// DWORD color masks that specify the red, green, and blue components, respectively, + /// of each pixel. This is valid when used with 16- and 32-bpp bitmaps. + /// + public const int BI_BITFIELDS = 3; + + /// + /// Windows 98/Me, Windows 2000/XP: Indicates that the image is a JPEG image. + /// + public const int BI_JPEG = 4; + + /// + /// Windows 98/Me, Windows 2000/XP: Indicates that the image is a PNG image. + /// + public const int BI_PNG = 5; + + #endregion + + #region General functions + + /// + /// Returns the internal version of this FreeImage .NET wrapper. + /// + /// The internal version of this FreeImage .NET wrapper. + public static Version GetWrapperVersion() + { + if (WrapperVersion == null) + { + try + { + object[] attributes = Assembly.GetAssembly(typeof(FreeImage)) + .GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false); + if ((attributes != null) && (attributes.Length != 0)) + { + AssemblyFileVersionAttribute attribute = + attributes[0] as AssemblyFileVersionAttribute; + if ((attribute != null) && (attribute.Version != null)) + { + return (WrapperVersion = new Version(attribute.Version)); + } + } + } + catch + { + + } + + WrapperVersion = new Version(); + } + + return WrapperVersion; + } + + /// + /// Returns the version of the native FreeImage library. + /// + /// The version of the native FreeImage library. + public static Version GetNativeVersion() + { + return new Version(GetVersion()); + } + + /// + /// Returns a value indicating if the FreeImage library is available or not. + /// See remarks for further details. + /// + /// false if the file is not available or out of date; + /// true, otherwise. + /// + /// The FreeImage.NET library is a wrapper for the native C++ library + /// (FreeImage.dll ... dont mix ist up with this library FreeImageNet.dll). + /// The native library must be either in the same folder as the program's + /// executable or in a folder contained in the envirent variable PATH + /// (for example %WINDIR%\System32). + /// Further more must both libraries, including the program itself, + /// be the same architecture (x86 or x64). + /// + public static bool IsAvailable() + { + try + { + // Call a static fast executing function + Version nativeVersion = new Version(GetVersion()); + Version wrapperVersion = GetWrapperVersion(); + // No exception thrown, the library seems to be present + return + (nativeVersion.Major > wrapperVersion.Major) || + ((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor > wrapperVersion.Minor)) || + ((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor == wrapperVersion.Minor) && (nativeVersion.Build >= wrapperVersion.Build)); + } + catch (DllNotFoundException) + { + return false; + } + catch (EntryPointNotFoundException) + { + return false; + } + catch (BadImageFormatException) + { + return false; + } + } + + #endregion + + #region Bitmap management functions + + /// + /// Creates a new bitmap in memory. + /// + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new Bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// Handle to a FreeImage bitmap. + public static FIBITMAP Allocate(int width, int height, int bpp) + { + return Allocate(width, height, bpp, 0, 0, 0); + } + + /// + /// Creates a new bitmap in memory. + /// + /// Type of the image. + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new Bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// Handle to a FreeImage bitmap. + public static FIBITMAP AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp) + { + return AllocateT(type, width, height, bpp, 0, 0, 0); + } + + /// + /// Allocates a new image of the specified width, height and bit depth and optionally + /// fills it with the specified color. See remarks for further details. + /// + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmaps. + /// The color to fill the bitmap with or null. + /// Options to enable or disable function-features. + /// The palette of the bitmap or null. + /// Handle to a FreeImage bitmap. + /// + /// This function is an extension to , which additionally supports + /// specifying a palette to be set for the newly create image, as well as specifying a + /// background color, the newly created image should initially be filled with. + /// + /// Basically, this function internally relies on function , followed by a + /// call to . This is why both parameters + /// and behave the same as it is + /// documented for function . + /// So, please refer to the documentation of to + /// learn more about parameters and . + /// + /// The palette specified through parameter is only copied to the + /// newly created image, if the desired bit depth is smaller than or equal to 8 bits per pixel. + /// In other words, the parameter is only taken into account for + /// palletized images. So, for an 8-bit image, the length is 256, for an 4-bit image it is 16 + /// and it is 2 for a 1-bit image. In other words, this function does not support partial palettes. + /// + /// However, specifying a palette is not necesarily needed, even for palletized images. This + /// function is capable of implicitly creating a palette, if is null. + /// If the specified background color is a greyscale value (red = green = blue) or if option + /// is specified, a greyscale palette + /// is created. For a 1-bit image, only if the specified background color is either black or white, + /// a monochrome palette, consisting of black and white only is created. In any case, the darker + /// colors are stored at the smaller palette indices. + /// + /// If the specified background color is not a greyscale value, or is neither black nor white + /// for a 1-bit image, solely this specified color is injected into the otherwise black-initialized + /// palette. For this operation, option + /// is implicit, so the specified is applied to the palette entry, + /// specified by the background color's field. + /// The image is then filled with this palette index. + /// + /// This function returns a newly created image as function does, if both + /// parameters and are null. + /// If only is null, the palette pointed to by + /// parameter is initially set for the new image, if a palletized + /// image of type is created. + /// However, in the latter case, this function returns an image, whose + /// pixels are all initialized with zeros so, the image will be filled with the color of the + /// first palette entry. + /// + public static FIBITMAP AllocateEx(int width, int height, int bpp, + RGBQUAD? color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette) + { + return AllocateEx(width, height, bpp, color, options, palette, 0, 0, 0); + } + + /// + /// Allocates a new image of the specified width, height and bit depth and optionally + /// fills it with the specified color. See remarks for further details. + /// + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmaps. + /// The color to fill the bitmap with or null. + /// Options to enable or disable function-features. + /// The palette of the bitmap or null. + /// Red part of the color layout. + /// eg: 0xFF0000 + /// Green part of the color layout. + /// eg: 0x00FF00 + /// Blue part of the color layout. + /// eg: 0x0000FF + /// Handle to a FreeImage bitmap. + /// + /// This function is an extension to , which additionally supports + /// specifying a palette to be set for the newly create image, as well as specifying a + /// background color, the newly created image should initially be filled with. + /// + /// Basically, this function internally relies on function , followed by a + /// call to . This is why both parameters + /// and behave the same as it is + /// documented for function . + /// So, please refer to the documentation of to + /// learn more about parameters and . + /// + /// The palette specified through parameter is only copied to the + /// newly created image, if the desired bit depth is smaller than or equal to 8 bits per pixel. + /// In other words, the parameter is only taken into account for + /// palletized images. So, for an 8-bit image, the length is 256, for an 4-bit image it is 16 + /// and it is 2 for a 1-bit image. In other words, this function does not support partial palettes. + /// + /// However, specifying a palette is not necesarily needed, even for palletized images. This + /// function is capable of implicitly creating a palette, if is null. + /// If the specified background color is a greyscale value (red = green = blue) or if option + /// is specified, a greyscale palette + /// is created. For a 1-bit image, only if the specified background color is either black or white, + /// a monochrome palette, consisting of black and white only is created. In any case, the darker + /// colors are stored at the smaller palette indices. + /// + /// If the specified background color is not a greyscale value, or is neither black nor white + /// for a 1-bit image, solely this specified color is injected into the otherwise black-initialized + /// palette. For this operation, option + /// is implicit, so the specified is applied to the palette entry, + /// specified by the background color's field. + /// The image is then filled with this palette index. + /// + /// This function returns a newly created image as function does, if both + /// parameters and are null. + /// If only is null, the palette pointed to by + /// parameter is initially set for the new image, if a palletized + /// image of type is created. + /// However, in the latter case, this function returns an image, whose + /// pixels are all initialized with zeros so, the image will be filled with the color of the + /// first palette entry. + /// + public static FIBITMAP AllocateEx(int width, int height, int bpp, + RGBQUAD? color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette, + uint red_mask, uint green_mask, uint blue_mask) + { + if ((palette != null) && (bpp <= 8) && (palette.Length < (1 << bpp))) + return FIBITMAP.Zero; + + if (color.HasValue) + { + GCHandle handle = new GCHandle(); + try + { + RGBQUAD[] buffer = new RGBQUAD[] { color.Value }; + handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + return AllocateEx(width, height, bpp, handle.AddrOfPinnedObject(), + options, palette, red_mask, green_mask, blue_mask); + } + finally + { + if (handle.IsAllocated) + handle.Free(); + } + } + else + { + return AllocateEx(width, height, bpp, IntPtr.Zero, + options, palette, red_mask, green_mask, blue_mask); + } + } + + /// + /// Allocates a new image of the specified type, width, height and bit depth and optionally + /// fills it with the specified color. See remarks for further details. + /// + /// The type of the specified color. + /// Type of the image. + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// The color to fill the bitmap with or null. + /// Options to enable or disable function-features. + /// The palette of the bitmap or null. + /// Handle to a FreeImage bitmap. + /// + /// This function is an extension to , which additionally supports + /// specifying a palette to be set for the newly create image, as well as specifying a + /// background color, the newly created image should initially be filled with. + /// + /// Basically, this function internally relies on function , followed by a + /// call to . This is why both parameters + /// and behave the same as it is + /// documented for function . So, please refer to the + /// documentation of to learn more about parameters color and options. + /// + /// The palette specified through parameter palette is only copied to the newly created + /// image, if its image type is and the desired bit + /// depth is smaller than or equal to 8 bits per pixel. In other words, the + /// palette is only taken into account for palletized images. However, if the preceding conditions + /// match and if is not null, the palette is assumed to be at + /// least as large as the size of a fully populated palette for the desired bit depth. + /// So, for an 8-bit image, this length is 256, for an 4-bit image it is 16 and it is + /// 2 for a 1-bit image. In other words, this function does not support partial palettes. + /// + /// However, specifying a palette is not necesarily needed, even for palletized images. This + /// function is capable of implicitly creating a palette, if is null. + /// If the specified background color is a greyscale value (red = green = blue) or if option + /// is specified, a greyscale palette + /// is created. For a 1-bit image, only if the specified background color is either black or white, + /// a monochrome palette, consisting of black and white only is created. In any case, the darker + /// colors are stored at the smaller palette indices. + /// + /// If the specified background color is not a greyscale value, or is neither black nor white + /// for a 1-bit image, solely this specified color is injected into the otherwise black-initialized + /// palette. For this operation, option + /// is implicit, so the specified color is applied to the palette entry, specified by the + /// background color's field. The image is then filled with + /// this palette index. + /// + /// This function returns a newly created image as function does, if both + /// parameters and are null. + /// If only is null, the palette pointed to by + /// parameter is initially set for the new image, if a palletized + /// image of type is created. + /// However, in the latter case, this function returns an image, whose + /// pixels are all initialized with zeros so, the image will be filled with the color of the + /// first palette entry. + /// + public static FIBITMAP AllocateExT(FREE_IMAGE_TYPE type, int width, int height, int bpp, + T? color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette) where T : struct + { + return AllocateExT(type, width, height, bpp, color, options, palette, 0, 0, 0); + } + + /// + /// Allocates a new image of the specified type, width, height and bit depth and optionally + /// fills it with the specified color. See remarks for further details. + /// + /// The type of the specified color. + /// Type of the image. + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// The color to fill the bitmap with or null. + /// Options to enable or disable function-features. + /// The palette of the bitmap or null. + /// Red part of the color layout. + /// eg: 0xFF0000 + /// Green part of the color layout. + /// eg: 0x00FF00 + /// Blue part of the color layout. + /// eg: 0x0000FF + /// Handle to a FreeImage bitmap. + /// + /// This function is an extension to , which additionally supports + /// specifying a palette to be set for the newly create image, as well as specifying a + /// background color, the newly created image should initially be filled with. + /// + /// Basically, this function internally relies on function , followed by a + /// call to . This is why both parameters + /// and behave the same as it is + /// documented for function . So, please refer to the + /// documentation of to learn more about parameters color and options. + /// + /// The palette specified through parameter palette is only copied to the newly created + /// image, if its image type is and the desired bit + /// depth is smaller than or equal to 8 bits per pixel. In other words, the + /// palette is only taken into account for palletized images. However, if the preceding conditions + /// match and if is not null, the palette is assumed to be at + /// least as large as the size of a fully populated palette for the desired bit depth. + /// So, for an 8-bit image, this length is 256, for an 4-bit image it is 16 and it is + /// 2 for a 1-bit image. In other words, this function does not support partial palettes. + /// + /// However, specifying a palette is not necesarily needed, even for palletized images. This + /// function is capable of implicitly creating a palette, if is null. + /// If the specified background color is a greyscale value (red = green = blue) or if option + /// is specified, a greyscale palette + /// is created. For a 1-bit image, only if the specified background color is either black or white, + /// a monochrome palette, consisting of black and white only is created. In any case, the darker + /// colors are stored at the smaller palette indices. + /// + /// If the specified background color is not a greyscale value, or is neither black nor white + /// for a 1-bit image, solely this specified color is injected into the otherwise black-initialized + /// palette. For this operation, option + /// is implicit, so the specified color is applied to the palette entry, specified by the + /// background color's field. The image is then filled with + /// this palette index. + /// + /// This function returns a newly created image as function does, if both + /// parameters and are null. + /// If only is null, the palette pointed to by + /// parameter is initially set for the new image, if a palletized + /// image of type is created. + /// However, in the latter case, this function returns an image, whose + /// pixels are all initialized with zeros so, the image will be filled with the color of the + /// first palette entry. + /// + public static FIBITMAP AllocateExT(FREE_IMAGE_TYPE type, int width, int height, int bpp, + T? color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette, + uint red_mask, uint green_mask, uint blue_mask) where T : struct + { + if ((palette != null) && (bpp <= 8) && (palette.Length < (1 << bpp))) + return FIBITMAP.Zero; + + if (color.HasValue) + { + if (!CheckColorType(type, color.Value)) + return FIBITMAP.Zero; + + GCHandle handle = new GCHandle(); + try + { + T[] buffer = new T[] { color.Value }; + handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + return AllocateExT(type, width, height, bpp, handle.AddrOfPinnedObject(), + options, palette, red_mask, green_mask, blue_mask); + } + finally + { + if (handle.IsAllocated) + handle.Free(); + } + } + else + { + return AllocateExT(type, width, height, bpp, IntPtr.Zero, + options, palette, red_mask, green_mask, blue_mask); + } + } + + /// + /// Converts a FreeImage bitmap to a .NET . + /// + /// Handle to a FreeImage bitmap. + /// The converted .NET . + /// Copying metadata has been disabled until a proper way + /// of reading and storing metadata in a .NET bitmap is found. + /// + /// is null. + /// + /// The image type of is not FIT_BITMAP. + public static Bitmap GetBitmap(FIBITMAP dib) + { + return GetBitmap(dib, true); + } + + /// + /// Converts a FreeImage bitmap to a .NET . + /// + /// Handle to a FreeImage bitmap. + /// When true existing metadata will be copied. + /// The converted .NET . + /// Copying metadata has been disabled until a proper way + /// of reading and storing metadata in a .NET bitmap is found. + /// + /// is null. + /// + /// The image type of is not FIT_BITMAP. + internal static Bitmap GetBitmap(FIBITMAP dib, bool copyMetadata) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (GetImageType(dib) != FREE_IMAGE_TYPE.FIT_BITMAP) + { + throw new ArgumentException("Only bitmaps with type of FIT_BITMAP can be converted."); + } + + PixelFormat format = GetPixelFormat(dib); + + if ((format == PixelFormat.Undefined) && (GetBPP(dib) == 16u)) + { + throw new ArgumentException("Only 16bit 555 and 565 are supported."); + } + + int height = (int)GetHeight(dib); + int width = (int)GetWidth(dib); + int pitch = (int)GetPitch(dib); + + Bitmap result = new Bitmap(width, height, format); + BitmapData data; + // Locking the complete bitmap in writeonly mode + data = result.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, format); + // Writing the bitmap data directly into the new created .NET bitmap. + ConvertToRawBits(data.Scan0, dib, pitch, GetBPP(dib), + GetRedMask(dib), GetGreenMask(dib), GetBlueMask(dib), true); + // Unlock the bitmap + result.UnlockBits(data); + // Apply the bitmap resolution + if((GetResolutionX(dib) > 0) && (GetResolutionY(dib) > 0)) + { + // SetResolution will throw an exception when zero values are given on input + result.SetResolution(GetResolutionX(dib), GetResolutionY(dib)); + } + // Check whether the bitmap has a palette + if (GetPalette(dib) != IntPtr.Zero) + { + // Get the bitmaps palette to apply changes + ColorPalette palette = result.Palette; + // Get the orgininal palette + Color[] colorPalette = new Palette(dib).ColorData; + // Get the maximum number of palette entries to copy + int entriesToCopy = Math.Min(colorPalette.Length, palette.Entries.Length); + + // Check whether the bitmap is transparent + if (IsTransparent(dib)) + { + byte[] transTable = GetTransparencyTableEx(dib); + int i = 0; + int maxEntriesWithTrans = Math.Min(entriesToCopy, transTable.Length); + // Copy palette entries and include transparency + for (; i < maxEntriesWithTrans; i++) + { + palette.Entries[i] = Color.FromArgb(transTable[i], colorPalette[i]); + } + // Copy palette entries and that have no transparancy + for (; i < entriesToCopy; i++) + { + palette.Entries[i] = Color.FromArgb(0xFF, colorPalette[i]); + } + } + else + { + for (int i = 0; i < entriesToCopy; i++) + { + palette.Entries[i] = colorPalette[i]; + } + } + + // Set the bitmaps palette + result.Palette = palette; + } + // Copy metadata + if (copyMetadata) + { + try + { + List list = new List(); + // Get a list of all types + FITAG tag; + FIMETADATA mData; + foreach (FREE_IMAGE_MDMODEL model in FREE_IMAGE_MDMODELS) + { + // Get a unique search handle + mData = FindFirstMetadata(model, dib, out tag); + // Check if metadata exists for this type + if (mData.IsNull) continue; + do + { + PropertyItem propItem = CreatePropertyItem(); + propItem.Len = (int)GetTagLength(tag); + propItem.Id = (int)GetTagID(tag); + propItem.Type = (short)GetTagType(tag); + byte[] buffer = new byte[propItem.Len]; + + unsafe + { + byte* src = (byte*)GetTagValue(tag); + fixed (byte* dst = buffer) + { + CopyMemory(dst, src, (uint)propItem.Len); + } + } + + propItem.Value = buffer; + list.Add(propItem); + } + while (FindNextMetadata(mData, out tag)); + FindCloseMetadata(mData); + } + foreach (PropertyItem propItem in list) + { + result.SetPropertyItem(propItem); + } + } + catch + { + } + } + return result; + } + + /// + /// Converts an .NET into a FreeImage bitmap. + /// + /// The to convert. + /// Handle to a FreeImage bitmap. + /// Copying metadata has been disabled until a proper way + /// of reading and storing metadata in a .NET bitmap is found. + /// + /// is null. + /// + /// The bitmaps pixelformat is invalid. + public static FIBITMAP CreateFromBitmap(Bitmap bitmap) + { + return CreateFromBitmap(bitmap, false); + } + + /// + /// Converts an .NET into a FreeImage bitmap. + /// + /// The to convert. + /// When true existing metadata will be copied. + /// Handle to a FreeImage bitmap. + /// Copying metadata has been disabled until a proper way + /// of reading and storing metadata in a .NET bitmap is found. + /// + /// is null. + /// + /// The bitmaps pixelformat is invalid. + internal static FIBITMAP CreateFromBitmap(Bitmap bitmap, bool copyMetadata) + { + if (bitmap == null) + { + throw new ArgumentNullException("bitmap"); + } + uint bpp, red_mask, green_mask, blue_mask; + FREE_IMAGE_TYPE type; + if (!GetFormatParameters(bitmap.PixelFormat, out type, out bpp, out red_mask, out green_mask, out blue_mask)) + { + throw new ArgumentException("The bitmaps pixelformat is invalid."); + } + + // Locking the complete bitmap in readonly mode + BitmapData data = bitmap.LockBits( + new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat); + // Copying the bitmap data directly from the .NET bitmap + FIBITMAP result = ConvertFromRawBits( + data.Scan0, + type, + data.Width, + data.Height, + data.Stride, + bpp, + red_mask, + green_mask, + blue_mask, + true); + bitmap.UnlockBits(data); + // Handle palette + if (GetPalette(result) != IntPtr.Zero) + { + Palette palette = new Palette(result); + Color[] colors = bitmap.Palette.Entries; + // Only copy available palette entries + int entriesToCopy = Math.Min(palette.Length, colors.Length); + byte[] transTable = new byte[entriesToCopy]; + for (int i = 0; i < entriesToCopy; i++) + { + RGBQUAD color = (RGBQUAD)colors[i]; + color.rgbReserved = 0x00; + palette[i] = color; + transTable[i] = colors[i].A; + } + if ((bitmap.Flags & (int)ImageFlags.HasAlpha) != 0) + { + FreeImage.SetTransparencyTable(result, transTable); + } + } + // Handle meta data + // Disabled + //if (copyMetadata) + //{ + // foreach (PropertyItem propItem in bitmap.PropertyItems) + // { + // FITAG tag = CreateTag(); + // SetTagLength(tag, (uint)propItem.Len); + // SetTagID(tag, (ushort)propItem.Id); + // SetTagType(tag, (FREE_IMAGE_MDTYPE)propItem.Type); + // SetTagValue(tag, propItem.Value); + // SetMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, result, "", tag); + // } + //} + return result; + } + + /// + /// Converts a raw bitmap to a FreeImage bitmap. + /// + /// Array of bytes containing the raw bitmap. + /// The type of the raw bitmap. + /// The width in pixels of the raw bitmap. + /// The height in pixels of the raw bitmap. + /// Defines the total width of a scanline in the raw bitmap, + /// including padding bytes. + /// The bit depth (bits per pixel) of the raw bitmap. + /// The bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap is stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + /// Handle to a FreeImage bitmap. + public static unsafe FIBITMAP ConvertFromRawBits( + byte[] bits, + FREE_IMAGE_TYPE type, + int width, + int height, + int pitch, + uint bpp, + uint red_mask, + uint green_mask, + uint blue_mask, + bool topdown) + { + fixed (byte* ptr = bits) + { + return ConvertFromRawBits( + (IntPtr)ptr, + type, + width, + height, + pitch, + bpp, + red_mask, + green_mask, + blue_mask, + topdown); + } + } + + /// + /// Converts a raw bitmap to a FreeImage bitmap. + /// + /// Pointer to the memory block containing the raw bitmap. + /// The type of the raw bitmap. + /// The width in pixels of the raw bitmap. + /// The height in pixels of the raw bitmap. + /// Defines the total width of a scanline in the raw bitmap, + /// including padding bytes. + /// The bit depth (bits per pixel) of the raw bitmap. + /// The bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap is stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + /// Handle to a FreeImage bitmap. + public static unsafe FIBITMAP ConvertFromRawBits( + IntPtr bits, + FREE_IMAGE_TYPE type, + int width, + int height, + int pitch, + uint bpp, + uint red_mask, + uint green_mask, + uint blue_mask, + bool topdown) + { + byte* addr = (byte*)bits; + if ((addr == null) || (width <= 0) || (height <= 0)) + { + return FIBITMAP.Zero; + } + + FIBITMAP dib = AllocateT(type, width, height, (int)bpp, red_mask, green_mask, blue_mask); + if (dib != FIBITMAP.Zero) + { + if (topdown) + { + for (int i = height - 1; i >= 0; --i) + { + CopyMemory((byte*)GetScanLine(dib, i), addr, (int)GetLine(dib)); + addr += pitch; + } + } + else + { + for (int i = 0; i < height; ++i) + { + CopyMemory((byte*)GetScanLine(dib, i), addr, (int)GetLine(dib)); + addr += pitch; + } + } + } + return dib; + } + + /// + /// Saves a .NET to a file. + /// + /// The .NET to save. + /// Name of the file to save to. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// The bitmaps pixelformat is invalid. + public static bool SaveBitmap(Bitmap bitmap, string filename) + { + return SaveBitmap( + bitmap, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Saves a .NET to a file. + /// + /// The .NET to save. + /// Name of the file to save to. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// The bitmaps pixelformat is invalid. + public static bool SaveBitmap(Bitmap bitmap, string filename, FREE_IMAGE_SAVE_FLAGS flags) + { + return SaveBitmap( + bitmap, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + flags); + } + + /// + /// Saves a .NET to a file. + /// + /// The .NET to save. + /// Name of the file to save to. + /// Format of the bitmap. If the format should be taken from the + /// filename use . + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// The bitmaps pixelformat is invalid. + public static bool SaveBitmap( + Bitmap bitmap, + string filename, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags) + { + FIBITMAP dib = CreateFromBitmap(bitmap); + bool result = SaveEx(dib, filename, format, flags); + Unload(dib); + return result; + } + + /// + /// Loads a FreeImage bitmap. + /// The file will be loaded with default loading flags. + /// + /// The complete name of the file to load. + /// Handle to a FreeImage bitmap. + /// + /// does not exists. + public static FIBITMAP LoadEx(string filename) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return LoadEx(filename, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// Load flags can be provided by the flags parameter. + /// + /// The complete name of the file to load. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + /// + /// does not exists. + public static FIBITMAP LoadEx(string filename, FREE_IMAGE_LOAD_FLAGS flags) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return LoadEx(filename, flags, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// In case the loading format is the files + /// real format is being analysed. If no plugin can read the file, format remains + /// and 0 is returned. + /// The file will be loaded with default loading flags. + /// + /// The complete name of the file to load. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadEx it will be returned in format. + /// Handle to a FreeImage bitmap. + /// + /// does not exists. + public static FIBITMAP LoadEx(string filename, ref FREE_IMAGE_FORMAT format) + { + return LoadEx(filename, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// In case the loading format is the files + /// real format is being analysed. If no plugin can read the file, format remains + /// and 0 is returned. + /// Load flags can be provided by the flags parameter. + /// + /// The complete name of the file to load. + /// Flags to enable or disable plugin-features. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadEx it will be returned in format. + /// + /// Handle to a FreeImage bitmap. + /// + /// does not exists. + public static FIBITMAP LoadEx(string filename, FREE_IMAGE_LOAD_FLAGS flags, ref FREE_IMAGE_FORMAT format) + { + // check if file exists + if (!File.Exists(filename)) + { + throw new FileNotFoundException(filename + " could not be found."); + } + FIBITMAP dib = new FIBITMAP(); + if (format == FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + // query all plugins to see if one can read the file + format = GetFileType(filename, 0); + } + // check if the plugin is capable of loading files + if (FIFSupportsReading(format)) + { + dib = Load(format, filename, flags); + } + return dib; + } + + /// + /// Loads a .NET from a file. + /// + /// Name of the file to be loaded. + /// Format of the image. If the format should be taken from the + /// filename use . + /// Flags to enable or disable plugin-features. + /// The loaded .NET . + /// + /// does not exists. + /// + /// The image type of the image is not . + public static Bitmap LoadBitmap(string filename, FREE_IMAGE_LOAD_FLAGS flags, ref FREE_IMAGE_FORMAT format) + { + FIBITMAP dib = LoadEx(filename, flags, ref format); + Bitmap result = GetBitmap(dib, true); + Unload(dib); + return result; + } + + /// + /// Deletes a previously loaded FreeImage bitmap from memory and resets the handle to 0. + /// + /// Handle to a FreeImage bitmap. + public static void UnloadEx(ref FIBITMAP dib) + { + if (!dib.IsNull) + { + Unload(dib); + dib.SetNull(); + } + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// The format is taken off the filename. + /// If no suitable format was found false will be returned. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx(FIBITMAP dib, string filename) + { + return SaveEx( + ref dib, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// In case the loading format is + /// the format is taken off the filename. + /// If no suitable format was found false will be returned. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Format of the image. If the format should be taken from the + /// filename use . + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + FIBITMAP dib, + string filename, + FREE_IMAGE_FORMAT format) + { + return SaveEx( + ref dib, + filename, + format, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// The format is taken off the filename. + /// If no suitable format was found false will be returned. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// When true the structure will be unloaded on success. + /// If the function failed and returned false, the bitmap was not unloaded. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + ref FIBITMAP dib, + string filename, + bool unloadSource) + { + return SaveEx( + ref dib, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + unloadSource); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// The format is taken off the filename. + /// If no suitable format was found false will be returned. + /// Save flags can be provided by the flags parameter. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + FIBITMAP dib, + string filename, + FREE_IMAGE_SAVE_FLAGS flags) + { + return SaveEx( + ref dib, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + flags, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// The format is taken off the filename. + /// If no suitable format was found false will be returned. + /// Save flags can be provided by the flags parameter. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Flags to enable or disable plugin-features. + /// When true the structure will be unloaded on success. + /// If the function failed and returned false, the bitmap was not unloaded. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + ref FIBITMAP dib, + string filename, + FREE_IMAGE_SAVE_FLAGS flags, + bool unloadSource) + { + return SaveEx( + ref dib, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + flags, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + unloadSource); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// In case the loading format is + /// the format is taken off the filename. + /// If no suitable format was found false will be returned. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Format of the image. If the format should be taken from the + /// filename use . + /// When true the structure will be unloaded on success. + /// If the function failed and returned false, the bitmap was not unloaded. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + ref FIBITMAP dib, + string filename, + FREE_IMAGE_FORMAT format, + bool unloadSource) + { + return SaveEx( + ref dib, + filename, + format, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + unloadSource); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// In case the loading format is + /// the format is taken off the filename. + /// If no suitable format was found false will be returned. + /// Save flags can be provided by the flags parameter. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Format of the image. If the format should be taken from the + /// filename use . + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + FIBITMAP dib, + string filename, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags) + { + return SaveEx( + ref dib, + filename, + format, + flags, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// In case the loading format is + /// the format is taken off the filename. + /// If no suitable format was found false will be returned. + /// Save flags can be provided by the flags parameter. + /// The bitmaps color depth can be set by 'colorDepth'. + /// If set to a suitable color depth + /// will be taken if available. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Format of the image. If the format should be taken from the + /// filename use . + /// Flags to enable or disable plugin-features. + /// The new color depth of the bitmap. + /// Set to if Save should take the + /// best suitable color depth. + /// If a color depth is selected that the provided format cannot write an + /// error-message will be thrown. + /// When true the structure will be unloaded on success. + /// If the function failed and returned false, the bitmap was not unloaded. + /// Returns true on success, false on failure. + /// + /// A direct color conversion failed. + /// + /// or is null. + public static bool SaveEx( + ref FIBITMAP dib, + string filename, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags, + FREE_IMAGE_COLOR_DEPTH colorDepth, + bool unloadSource) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (filename == null) + { + throw new ArgumentNullException("filename"); + } + bool result = false; + // Gets format from filename if the format is unknown + if (format == FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + format = GetFIFFromFilename(filename); + } + if (format != FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + // Checks writing support + if (FIFSupportsWriting(format) && FIFSupportsExportType(format, GetImageType(dib))) + { + // Check valid filename and correct it if needed + if (!IsFilenameValidForFIF(format, filename)) + { + string extension = GetPrimaryExtensionFromFIF(format); + filename = Path.ChangeExtension(filename, extension); + } + + FIBITMAP dibToSave = PrepareBitmapColorDepth(dib, format, colorDepth); + try + { + result = Save(format, dibToSave, filename, flags); + } + finally + { + // Always unload a temporary created bitmap. + if (dibToSave != dib) + { + UnloadEx(ref dibToSave); + } + // On success unload the bitmap + if (result && unloadSource) + { + UnloadEx(ref dib); + } + } + } + } + return result; + } + + /// + /// Loads a FreeImage bitmap. + /// The stream must be set to the correct position before calling LoadFromStream. + /// + /// The stream to read from. + /// Handle to a FreeImage bitmap. + /// + /// is null. + /// + /// is not capable of reading. + public static FIBITMAP LoadFromStream(Stream stream) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return LoadFromStream(stream, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// The stream must be set to the correct position before calling LoadFromStream. + /// + /// The stream to read from. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + /// + /// is null. + /// + /// is not capable of reading. + public static FIBITMAP LoadFromStream(Stream stream, FREE_IMAGE_LOAD_FLAGS flags) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return LoadFromStream(stream, flags, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// In case the loading format is the + /// bitmaps real format is being analysed. + /// The stream must be set to the correct position before calling LoadFromStream. + /// + /// The stream to read from. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadFromStream it will be returned in format. + /// Handle to a FreeImage bitmap. + /// + /// is null. + /// + /// is not capable of reading. + public static FIBITMAP LoadFromStream(Stream stream, ref FREE_IMAGE_FORMAT format) + { + return LoadFromStream(stream, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// In case the loading format is + /// the bitmaps real format is being analysed. + /// The stream must be set to the correct position before calling LoadFromStream. + /// + /// The stream to read from. + /// Flags to enable or disable plugin-features. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadFromStream it will be returned in format. + /// Handle to a FreeImage bitmap. + /// + /// is null. + /// + /// is not capable of reading. + public static FIBITMAP LoadFromStream( + Stream stream, + FREE_IMAGE_LOAD_FLAGS flags, + ref FREE_IMAGE_FORMAT format) + { + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + if (!stream.CanRead) + { + throw new ArgumentException("stream is not capable of reading."); + } + // Wrap the source stream if it is unable to seek (which is required by FreeImage) + stream = (stream.CanSeek) ? stream : new StreamWrapper(stream, true); + + stream.Position = 0L; + if (format == FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + // Get the format of the bitmap + format = GetFileTypeFromStream(stream); + // Restore the streams position + stream.Position = 0L; + } + if (!FIFSupportsReading(format)) + { + return FIBITMAP.Zero; + } + // Create a 'FreeImageIO' structure for calling 'LoadFromHandle' + // using the internal structure 'FreeImageStreamIO'. + FreeImageIO io = FreeImageStreamIO.io; + using (fi_handle handle = new fi_handle(stream)) + { + return LoadFromHandle(format, ref io, handle, flags); + } + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format) + { + return SaveToStream( + ref dib, + stream, + format, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// When true the structure will be unloaded on success. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + ref FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format, + bool unloadSource) + { + return SaveToStream( + ref dib, + stream, + format, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + unloadSource); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags) + { + return SaveToStream( + ref dib, + stream, + format, + flags, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// When true the structure will be unloaded on success. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + ref FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags, + bool unloadSource) + { + return SaveToStream( + ref dib, stream, + format, + flags, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + unloadSource); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// The new color depth of the bitmap. + /// Set to if SaveToStream should + /// take the best suitable color depth. + /// If a color depth is selected that the provided format cannot write an + /// error-message will be thrown. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags, + FREE_IMAGE_COLOR_DEPTH colorDepth) + { + return SaveToStream( + ref dib, + stream, + format, + flags, + colorDepth, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// The new color depth of the bitmap. + /// Set to if SaveToStream should + /// take the best suitable color depth. + /// If a color depth is selected that the provided format cannot write an + /// error-message will be thrown. + /// When true the structure will be unloaded on success. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + ref FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags, + FREE_IMAGE_COLOR_DEPTH colorDepth, + bool unloadSource) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + if (!stream.CanWrite) + { + throw new ArgumentException("stream is not capable of writing."); + } + if ((!FIFSupportsWriting(format)) || (!FIFSupportsExportType(format, GetImageType(dib)))) + { + return false; + } + + FIBITMAP dibToSave = PrepareBitmapColorDepth(dib, format, colorDepth); + bool result = false; + + try + { + // Create a 'FreeImageIO' structure for calling 'SaveToHandle' + FreeImageIO io = FreeImageStreamIO.io; + + using (fi_handle handle = new fi_handle(stream)) + { + result = SaveToHandle(format, dibToSave, ref io, handle, flags); + } + } + finally + { + // Always unload a temporary created bitmap. + if (dibToSave != dib) + { + UnloadEx(ref dibToSave); + } + // On success unload the bitmap + if (result && unloadSource) + { + UnloadEx(ref dib); + } + } + + return result; + } + + #endregion + + #region Plugin functions + + /// + /// Checks if an extension is valid for a certain format. + /// + /// The desired format. + /// The desired extension. + /// True if the extension is valid for the given format, false otherwise. + /// + /// is null. + public static bool IsExtensionValidForFIF(FREE_IMAGE_FORMAT fif, string extension) + { + return IsExtensionValidForFIF(fif, extension, StringComparison.CurrentCultureIgnoreCase); + } + + /// + /// Checks if an extension is valid for a certain format. + /// + /// The desired format. + /// The desired extension. + /// The string comparison type. + /// True if the extension is valid for the given format, false otherwise. + /// + /// is null. + public static bool IsExtensionValidForFIF(FREE_IMAGE_FORMAT fif, string extension, StringComparison comparisonType) + { + if (extension == null) + { + throw new ArgumentNullException("extension"); + } + bool result = false; + // Split up the string and compare each with the given extension + string tempList = GetFIFExtensionList(fif); + if (tempList != null) + { + string[] extensionList = tempList.Split(','); + foreach (string ext in extensionList) + { + if (extension.Equals(ext, comparisonType)) + { + result = true; + break; + } + } + } + return result; + } + + /// + /// Checks if a filename is valid for a certain format. + /// + /// The desired format. + /// The desired filename. + /// True if the filename is valid for the given format, false otherwise. + /// + /// is null. + public static bool IsFilenameValidForFIF(FREE_IMAGE_FORMAT fif, string filename) + { + return IsFilenameValidForFIF(fif, filename, StringComparison.CurrentCultureIgnoreCase); + } + + /// + /// Checks if a filename is valid for a certain format. + /// + /// The desired format. + /// The desired filename. + /// The string comparison type. + /// True if the filename is valid for the given format, false otherwise. + /// + /// is null. + public static bool IsFilenameValidForFIF(FREE_IMAGE_FORMAT fif, string filename, StringComparison comparisonType) + { + if (filename == null) + { + throw new ArgumentNullException("filename"); + } + bool result = false; + // Extract the filenames extension if it exists + string extension = Path.GetExtension(filename); + if (extension.Length != 0) + { + extension = extension.Remove(0, 1); + result = IsExtensionValidForFIF(fif, extension, comparisonType); + } + return result; + } + + /// + /// This function returns the primary (main or most commonly used?) extension of a certain + /// image format (fif). This is done by returning the first of all possible extensions + /// returned by GetFIFExtensionList(). + /// That assumes, that the plugin returns the extensions in ordered form. + /// The image format to obtain the primary extension for. + /// The primary extension of the specified image format. + public static string GetPrimaryExtensionFromFIF(FREE_IMAGE_FORMAT fif) + { + string result = null; + string extensions = GetFIFExtensionList(fif); + if (extensions != null) + { + int position = extensions.IndexOf(','); + if (position < 0) + { + result = extensions; + } + else + { + result = extensions.Substring(0, position); + } + } + return result; + } + + #endregion + + #region Multipage functions + + /// + /// Loads a FreeImage multi-paged bitmap. + /// + /// The complete name of the file to load. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx(string filename) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return OpenMultiBitmapEx( + filename, + ref format, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + false, + false, + false); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// + /// The complete name of the file to load. + /// When true performance is increased at the cost of memory. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx(string filename, bool keep_cache_in_memory) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return OpenMultiBitmapEx( + filename, + ref format, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + false, + false, + keep_cache_in_memory); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// + /// The complete name of the file to load. + /// When true the bitmap will be loaded read only. + /// When true performance is increased at the cost of memory. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx( + string filename, + bool read_only, + bool keep_cache_in_memory) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return OpenMultiBitmapEx( + filename, + ref format, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + false, + read_only, + keep_cache_in_memory); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// + /// The complete name of the file to load. + /// When true a new bitmap is created. + /// When true the bitmap will be loaded read only. + /// When true performance is increased at the cost of memory. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx( + string filename, + bool create_new, + bool read_only, + bool keep_cache_in_memory) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return OpenMultiBitmapEx( + filename, + ref format, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + create_new, + read_only, + keep_cache_in_memory); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// In case the loading format is the files real + /// format is being analysed. If no plugin can read the file, format remains + /// and 0 is returned. + /// + /// The complete name of the file to load. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadEx it will be returned in format. + /// When true a new bitmap is created. + /// When true the bitmap will be loaded read only. + /// When true performance is increased at the cost of memory. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx( + string filename, + ref FREE_IMAGE_FORMAT format, + bool create_new, + bool read_only, + bool keep_cache_in_memory) + { + return OpenMultiBitmapEx( + filename, + ref format, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + create_new, + read_only, + keep_cache_in_memory); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// In case the loading format is the files + /// real format is being analysed. If no plugin can read the file, format remains + /// and 0 is returned. + /// Load flags can be provided by the flags parameter. + /// + /// The complete name of the file to load. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadEx it will be returned in format. + /// Flags to enable or disable plugin-features. + /// When true a new bitmap is created. + /// When true the bitmap will be loaded read only. + /// When true performance is increased at the cost of memory. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx( + string filename, + ref FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS flags, + bool create_new, + bool read_only, + bool keep_cache_in_memory) + { + if (!File.Exists(filename) && !create_new) + { + throw new FileNotFoundException(filename + " could not be found."); + } + if (format == FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + // Check if a plugin can read the data + format = GetFileType(filename, 0); + } + FIMULTIBITMAP dib = new FIMULTIBITMAP(); + if (FIFSupportsReading(format)) + { + dib = OpenMultiBitmap(format, filename, create_new, read_only, keep_cache_in_memory, flags); + } + return dib; + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// + /// The stream to load the bitmap from. + /// Handle to a FreeImage multi-paged bitmap. + public static FIMULTIBITMAP OpenMultiBitmapFromStream(Stream stream) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return OpenMultiBitmapFromStream(stream, ref format, FREE_IMAGE_LOAD_FLAGS.DEFAULT); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// In case the loading format is the files + /// real format is being analysed. If no plugin can read the file, format remains + /// and 0 is returned. + /// Load flags can be provided by the flags parameter. + /// + /// The stream to load the bitmap from. + /// Format of the image. If the format is unknown use + /// . + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage multi-paged bitmap. + public static FIMULTIBITMAP OpenMultiBitmapFromStream(Stream stream, ref FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags) + { + if (stream == null) + return FIMULTIBITMAP.Zero; + + if (!stream.CanSeek) + stream = new StreamWrapper(stream, true); + + FIMULTIBITMAP mdib = FIMULTIBITMAP.Zero; + FreeImageIO io = FreeImageStreamIO.io; + fi_handle handle = new fi_handle(stream); + + try + { + if (format == FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + format = GetFileTypeFromHandle(ref io, handle, checked((int)stream.Length)); + } + + mdib = OpenMultiBitmapFromHandle(format, ref io, handle, flags); + + if (mdib.IsNull) + { + handle.Dispose(); + } + else + { + lock (streamHandles) + { + streamHandles.Add(mdib, handle); + } + } + + return mdib; + } + catch + { + if (!mdib.IsNull) + CloseMultiBitmap(mdib, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + + if (handle != null) + handle.Dispose(); + + throw; + } + } + + /// + /// Closes a previously opened multi-page bitmap and, when the bitmap was not opened read-only, applies any changes made to it. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + public static bool CloseMultiBitmap(FIMULTIBITMAP bitmap, FREE_IMAGE_SAVE_FLAGS flags) + { + if (CloseMultiBitmap_(bitmap, flags)) + { + fi_handle handle; + lock (streamHandles) + { + if (streamHandles.TryGetValue(bitmap, out handle)) + { + streamHandles.Remove(bitmap); + handle.Dispose(); + } + } + return true; + } + return false; + } + + /// + /// Closes a previously opened multi-page bitmap and, when the bitmap was not opened read-only, + /// applies any changes made to it. + /// On success the handle will be reset to null. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Returns true on success, false on failure. + public static bool CloseMultiBitmapEx(ref FIMULTIBITMAP bitmap) + { + return CloseMultiBitmapEx(ref bitmap, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Closes a previously opened multi-page bitmap and, when the bitmap was not opened read-only, + /// applies any changes made to it. + /// On success the handle will be reset to null. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + public static bool CloseMultiBitmapEx(ref FIMULTIBITMAP bitmap, FREE_IMAGE_SAVE_FLAGS flags) + { + bool result = false; + if (!bitmap.IsNull) + { + if (CloseMultiBitmap(bitmap, flags)) + { + bitmap.SetNull(); + result = true; + } + } + return result; + } + + /// + /// Retrieves the number of pages that are locked in a multi-paged bitmap. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Number of locked pages. + /// + /// is null. + public static int GetLockedPageCount(FIMULTIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + int result = 0; + GetLockedPageNumbers(dib, null, ref result); + return result; + } + + /// + /// Retrieves a list locked pages of a multi-paged bitmap. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// List containing the indexes of the locked pages. + /// + /// is null. + public static int[] GetLockedPages(FIMULTIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + // Get the number of pages and create an array to save the information + int count = 0; + int[] result = null; + // Get count + if (GetLockedPageNumbers(dib, result, ref count)) + { + result = new int[count]; + // Fill array + if (!GetLockedPageNumbers(dib, result, ref count)) + { + result = null; + } + } + return result; + } + + /// + /// Loads a FreeImage multi-paged bitmap from a stream and returns the + /// FreeImage memory stream used as temporary buffer. + /// The bitmap can not be modified by calling + /// , + /// , + /// or + /// . + /// + /// The stream to read from. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// The temporary memory buffer used to load the bitmap. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// is null. + /// + /// can not read. + public static FIMULTIBITMAP LoadMultiBitmapFromStream( + Stream stream, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS flags, + out FIMEMORY memory) + { + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + if (!stream.CanRead) + { + throw new ArgumentException("stream"); + } + const int blockSize = 1024; + int bytesRead; + byte[] buffer = new byte[blockSize]; + + stream = stream.CanSeek ? stream : new StreamWrapper(stream, true); + memory = OpenMemory(IntPtr.Zero, 0); + + do + { + bytesRead = stream.Read(buffer, 0, blockSize); + WriteMemory(buffer, (uint)blockSize, (uint)1, memory); + } + while (bytesRead == blockSize); + + return LoadMultiBitmapFromMemory(format, memory, flags); + } + + #endregion + + #region Filetype functions + + /// + /// Orders FreeImage to analyze the bitmap signature. + /// In case the stream is not seekable, the stream will have been used + /// and must be recreated for loading. + /// + /// Name of the stream to analyze. + /// Type of the bitmap. + /// + /// is null. + /// + /// can not read. + public static FREE_IMAGE_FORMAT GetFileTypeFromStream(Stream stream) + { + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + if (!stream.CanRead) + { + throw new ArgumentException("stream is not capable of reading."); + } + // Wrap the stream if it cannot seek + stream = (stream.CanSeek) ? stream : new StreamWrapper(stream, true); + // Create a 'FreeImageIO' structure for the stream + FreeImageIO io = FreeImageStreamIO.io; + using (fi_handle handle = new fi_handle(stream)) + { + return GetFileTypeFromHandle(ref io, handle, 0); + } + } + + #endregion + + #region Pixel access functions + + /// + /// Retrieves an hBitmap for a FreeImage bitmap. + /// Call FreeHbitmap(IntPtr) to free the handle. + /// + /// Handle to a FreeImage bitmap. + /// A reference device context. + /// Use IntPtr.Zero if no reference is available. + /// When true dib will be unloaded if the function succeeded. + /// The hBitmap for the FreeImage bitmap. + /// + /// is null. + public static unsafe IntPtr GetHbitmap(FIBITMAP dib, IntPtr hdc, bool unload) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + IntPtr hBitmap = IntPtr.Zero; + bool release = false; + IntPtr ppvBits = IntPtr.Zero; + // Check if we have destination + if (release = (hdc == IntPtr.Zero)) + { + // We don't so request dc + hdc = GetDC(IntPtr.Zero); + } + if (hdc != IntPtr.Zero) + { + // Get pointer to the infoheader of the bitmap + IntPtr info = GetInfo(dib); + // Create a bitmap in the dc + hBitmap = CreateDIBSection(hdc, info, DIB_RGB_COLORS, out ppvBits, IntPtr.Zero, 0); + if (hBitmap != IntPtr.Zero && ppvBits != IntPtr.Zero) + { + // Copy the data into the dc + CopyMemory(ppvBits, GetBits(dib), (GetHeight(dib) * GetPitch(dib))); + // Success: we unload the bitmap + if (unload) + { + Unload(dib); + } + } + // We have to release the dc + if (release) + { + ReleaseDC(IntPtr.Zero, hdc); + } + } + return hBitmap; + } + + /// + /// Returns an HBITMAP created by the CreateDIBitmap() function which in turn + /// has always the same color depth as the reference DC, which may be provided + /// through . The desktop DC will be used, + /// if IntPtr.Zero DC is specified. + /// Call to free the handle. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a device context. + /// When true the structure will be unloaded on success. + /// If the function failed and returned false, the bitmap was not unloaded. + /// If the function succeeds, the return value is a handle to the + /// compatible bitmap. If the function fails, the return value is . + /// + /// is null. + public static IntPtr GetBitmapForDevice(FIBITMAP dib, IntPtr hdc, bool unload) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + IntPtr hbitmap = IntPtr.Zero; + bool release = false; + if (release = (hdc == IntPtr.Zero)) + { + hdc = GetDC(IntPtr.Zero); + } + if (hdc != IntPtr.Zero) + { + hbitmap = CreateDIBitmap( + hdc, + GetInfoHeader(dib), + CBM_INIT, + GetBits(dib), + GetInfo(dib), + DIB_RGB_COLORS); + if (unload) + { + Unload(dib); + } + if (release) + { + ReleaseDC(IntPtr.Zero, hdc); + } + } + return hbitmap; + } + + /// + /// Creates a FreeImage DIB from a Device Context/Compatible Bitmap. + /// + /// Handle to the bitmap. + /// Handle to a device context. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public unsafe static FIBITMAP CreateFromHbitmap(IntPtr hbitmap, IntPtr hdc) + { + if (hbitmap == IntPtr.Zero) + { + throw new ArgumentNullException("hbitmap"); + } + + FIBITMAP dib = new FIBITMAP(); + BITMAP bm; + uint colors; + bool release; + + if (GetObject(hbitmap, sizeof(BITMAP), (IntPtr)(&bm)) != 0) + { + dib = Allocate(bm.bmWidth, bm.bmHeight, bm.bmBitsPixel, 0, 0, 0); + if (!dib.IsNull) + { + colors = GetColorsUsed(dib); + if (release = (hdc == IntPtr.Zero)) + { + hdc = GetDC(IntPtr.Zero); + } + if (GetDIBits( + hdc, + hbitmap, + 0, + (uint)bm.bmHeight, + GetBits(dib), + GetInfo(dib), + DIB_RGB_COLORS) != 0) + { + if (colors != 0) + { + BITMAPINFOHEADER* bmih = (BITMAPINFOHEADER*)GetInfo(dib); + bmih[0].biClrImportant = bmih[0].biClrUsed = colors; + } + } + else + { + UnloadEx(ref dib); + } + if (release) + { + ReleaseDC(IntPtr.Zero, hdc); + } + } + } + + return dib; + } + + /// + /// Frees a bitmap handle. + /// + /// Handle to a bitmap. + /// True on success, false on failure. + public static bool FreeHbitmap(IntPtr hbitmap) + { + return DeleteObject(hbitmap); + } + + #endregion + + #region Bitmap information functions + + /// + /// Retrieves a DIB's resolution in X-direction measured in 'dots per inch' (DPI) and not in + /// 'dots per meter'. + /// + /// Handle to a FreeImage bitmap. + /// The resolution in 'dots per inch'. + /// + /// is null. + public static uint GetResolutionX(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + return (uint)(0.5d + 0.0254d * GetDotsPerMeterX(dib)); + } + + /// + /// Retrieves a DIB's resolution in Y-direction measured in 'dots per inch' (DPI) and not in + /// 'dots per meter'. + /// + /// Handle to a FreeImage bitmap. + /// The resolution in 'dots per inch'. + /// + /// is null. + public static uint GetResolutionY(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + return (uint)(0.5d + 0.0254d * GetDotsPerMeterY(dib)); + } + + /// + /// Sets a DIB's resolution in X-direction measured in 'dots per inch' (DPI) and not in + /// 'dots per meter'. + /// + /// Handle to a FreeImage bitmap. + /// The new resolution in 'dots per inch'. + /// + /// is null. + public static void SetResolutionX(FIBITMAP dib, uint res) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + SetDotsPerMeterX(dib, (uint)((double)res / 0.0254d + 0.5d)); + } + + /// + /// Sets a DIB's resolution in Y-direction measured in 'dots per inch' (DPI) and not in + /// 'dots per meter'. + /// + /// Handle to a FreeImage bitmap. + /// The new resolution in 'dots per inch'. + /// + /// is null. + public static void SetResolutionY(FIBITMAP dib, uint res) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + SetDotsPerMeterY(dib, (uint)((double)res / 0.0254d + 0.5d)); + } + + /// + /// Returns whether the image is a greyscale image or not. + /// The function scans all colors in the bitmaps palette for entries where + /// red, green and blue are not all the same (not a grey color). + /// Supports 1-, 4- and 8-bit bitmaps. + /// + /// Handle to a FreeImage bitmap. + /// True if the image is a greyscale image, else false. + /// + /// is null. + public static unsafe bool IsGreyscaleImage(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + bool result = true; + uint bpp = GetBPP(dib); + switch (bpp) + { + case 1: + case 4: + case 8: + RGBQUAD* palette = (RGBQUAD*)GetPalette(dib); + uint paletteLength = GetColorsUsed(dib); + for (int i = 0; i < paletteLength; i++) + { + if (palette[i].rgbRed != palette[i].rgbGreen || + palette[i].rgbRed != palette[i].rgbBlue) + { + result = false; + break; + } + } + break; + default: + result = false; + break; + } + return result; + } + + /// + /// Returns a structure that represents the palette of a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// A structure representing the bitmaps palette. + /// + /// is null. + public static Palette GetPaletteEx(FIBITMAP dib) + { + return new Palette(dib); + } + + /// + /// Returns the structure of a FreeImage bitmap. + /// The structure is a copy, so changes will have no effect on + /// the bitmap itself. + /// + /// Handle to a FreeImage bitmap. + /// structure of the bitmap. + /// + /// is null. + public static unsafe BITMAPINFOHEADER GetInfoHeaderEx(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + return *(BITMAPINFOHEADER*)GetInfoHeader(dib); + } + + /// + /// Returns the structure of a FreeImage bitmap. + /// The structure is a copy, so changes will have no effect on + /// the bitmap itself. + /// + /// Handle to a FreeImage bitmap. + /// structure of the bitmap. + /// + /// is null. + public static BITMAPINFO GetInfoEx(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + BITMAPINFO result = new BITMAPINFO(); + result.bmiHeader = GetInfoHeaderEx(dib); + IntPtr ptr = GetPalette(dib); + if (ptr == IntPtr.Zero) + { + result.bmiColors = new RGBQUAD[0]; + } + else + { + result.bmiColors = new MemoryArray(ptr, (int)result.bmiHeader.biClrUsed).Data; + } + return result; + } + + /// + /// Returns the pixelformat of the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// of the bitmap. + /// + /// is null. + public static PixelFormat GetPixelFormat(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + + PixelFormat result = PixelFormat.Undefined; + + if (GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) + { + switch (GetBPP(dib)) + { + case 1: + result = PixelFormat.Format1bppIndexed; + break; + case 4: + result = PixelFormat.Format4bppIndexed; + break; + case 8: + result = PixelFormat.Format8bppIndexed; + break; + case 16: + if ((GetBlueMask(dib) == FI16_565_BLUE_MASK) && + (GetGreenMask(dib) == FI16_565_GREEN_MASK) && + (GetRedMask(dib) == FI16_565_RED_MASK)) + { + result = PixelFormat.Format16bppRgb565; + } + if ((GetBlueMask(dib) == FI16_555_BLUE_MASK) && + (GetGreenMask(dib) == FI16_555_GREEN_MASK) && + (GetRedMask(dib) == FI16_555_RED_MASK)) + { + result = PixelFormat.Format16bppRgb555; + } + break; + case 24: + result = PixelFormat.Format24bppRgb; + break; + case 32: + result = PixelFormat.Format32bppArgb; + break; + } + } + return result; + } + + /// + /// Retrieves all parameters needed to create a new FreeImage bitmap from + /// the format of a .NET . + /// + /// The + /// of the .NET . + /// Returns the type used for the new bitmap. + /// Returns the color depth for the new bitmap. + /// Returns the red_mask for the new bitmap. + /// Returns the green_mask for the new bitmap. + /// Returns the blue_mask for the new bitmap. + /// True in case a matching conversion exists; else false. + /// + public static bool GetFormatParameters( + PixelFormat format, + out FREE_IMAGE_TYPE type, + out uint bpp, + out uint red_mask, + out uint green_mask, + out uint blue_mask) + { + bool result = false; + type = FREE_IMAGE_TYPE.FIT_UNKNOWN; + bpp = 0; + red_mask = 0; + green_mask = 0; + blue_mask = 0; + switch (format) + { + case PixelFormat.Format1bppIndexed: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 1; + result = true; + break; + case PixelFormat.Format4bppIndexed: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 4; + result = true; + break; + case PixelFormat.Format8bppIndexed: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 8; + result = true; + break; + case PixelFormat.Format16bppRgb565: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 16; + red_mask = FI16_565_RED_MASK; + green_mask = FI16_565_GREEN_MASK; + blue_mask = FI16_565_BLUE_MASK; + result = true; + break; + case PixelFormat.Format16bppRgb555: + case PixelFormat.Format16bppArgb1555: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 16; + red_mask = FI16_555_RED_MASK; + green_mask = FI16_555_GREEN_MASK; + blue_mask = FI16_555_BLUE_MASK; + result = true; + break; + case PixelFormat.Format24bppRgb: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 24; + red_mask = FI_RGBA_RED_MASK; + green_mask = FI_RGBA_GREEN_MASK; + blue_mask = FI_RGBA_BLUE_MASK; + result = true; + break; + case PixelFormat.Format32bppRgb: + case PixelFormat.Format32bppArgb: + case PixelFormat.Format32bppPArgb: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 32; + red_mask = FI_RGBA_RED_MASK; + green_mask = FI_RGBA_GREEN_MASK; + blue_mask = FI_RGBA_BLUE_MASK; + result = true; + break; + case PixelFormat.Format16bppGrayScale: + type = FREE_IMAGE_TYPE.FIT_UINT16; + bpp = 16; + result = true; + break; + case PixelFormat.Format48bppRgb: + type = FREE_IMAGE_TYPE.FIT_RGB16; + bpp = 48; + result = true; + break; + case PixelFormat.Format64bppArgb: + case PixelFormat.Format64bppPArgb: + type = FREE_IMAGE_TYPE.FIT_RGBA16; + bpp = 64; + result = true; + break; + } + return result; + } + + /// + /// Returns the for the specified + /// . + /// + /// The + /// for which to return the corresponding . + /// The for the specified + /// + public static FREE_IMAGE_FORMAT GetFormat(ImageFormat imageFormat) + { + if (imageFormat != null) + { + if (imageFormat.Equals(ImageFormat.Bmp)) + return FREE_IMAGE_FORMAT.FIF_BMP; + if (imageFormat.Equals(ImageFormat.Gif)) + return FREE_IMAGE_FORMAT.FIF_GIF; + if (imageFormat.Equals(ImageFormat.Icon)) + return FREE_IMAGE_FORMAT.FIF_ICO; + if (imageFormat.Equals(ImageFormat.Jpeg)) + return FREE_IMAGE_FORMAT.FIF_JPEG; + if (imageFormat.Equals(ImageFormat.Png)) + return FREE_IMAGE_FORMAT.FIF_PNG; + if (imageFormat.Equals(ImageFormat.Tiff)) + return FREE_IMAGE_FORMAT.FIF_TIFF; + } + return FREE_IMAGE_FORMAT.FIF_UNKNOWN; + } + + /// + /// Retrieves all parameters needed to create a new FreeImage bitmap from + /// raw bits . + /// + /// The + /// of the data in memory. + /// The color depth for the data. + /// Returns the red_mask for the data. + /// Returns the green_mask for the data. + /// Returns the blue_mask for the data. + /// True in case a matching conversion exists; else false. + /// + public static bool GetTypeParameters( + FREE_IMAGE_TYPE type, + int bpp, + out uint red_mask, + out uint green_mask, + out uint blue_mask) + { + bool result = false; + red_mask = 0; + green_mask = 0; + blue_mask = 0; + switch (type) + { + case FREE_IMAGE_TYPE.FIT_BITMAP: + switch (bpp) + { + case 1: + case 4: + case 8: + result = true; + break; + case 16: + result = true; + red_mask = FI16_555_RED_MASK; + green_mask = FI16_555_GREEN_MASK; + blue_mask = FI16_555_BLUE_MASK; + break; + case 24: + case 32: + result = true; + red_mask = FI_RGBA_RED_MASK; + green_mask = FI_RGBA_GREEN_MASK; + blue_mask = FI_RGBA_BLUE_MASK; + break; + } + break; + case FREE_IMAGE_TYPE.FIT_UNKNOWN: + break; + default: + result = true; + break; + } + return result; + } + + /// + /// Compares two FreeImage bitmaps. + /// + /// The first bitmap to compare. + /// The second bitmap to compare. + /// Determines which components of the bitmaps will be compared. + /// True in case both bitmaps match the compare conditions, false otherwise. + public static bool Compare(FIBITMAP dib1, FIBITMAP dib2, FREE_IMAGE_COMPARE_FLAGS flags) + { + // Check whether one bitmap is null + if (dib1.IsNull ^ dib2.IsNull) + { + return false; + } + // Check whether both pointers are the same + if (dib1 == dib2) + { + return true; + } + if (((flags & FREE_IMAGE_COMPARE_FLAGS.HEADER) > 0) && (!CompareHeader(dib1, dib2))) + { + return false; + } + if (((flags & FREE_IMAGE_COMPARE_FLAGS.PALETTE) > 0) && (!ComparePalette(dib1, dib2))) + { + return false; + } + if (((flags & FREE_IMAGE_COMPARE_FLAGS.DATA) > 0) && (!CompareData(dib1, dib2))) + { + return false; + } + if (((flags & FREE_IMAGE_COMPARE_FLAGS.METADATA) > 0) && (!CompareMetadata(dib1, dib2))) + { + return false; + } + return true; + } + + private static unsafe bool CompareHeader(FIBITMAP dib1, FIBITMAP dib2) + { + IntPtr i1 = GetInfoHeader(dib1); + IntPtr i2 = GetInfoHeader(dib2); + return CompareMemory((void*)i1, (void*)i2, sizeof(BITMAPINFOHEADER)); + } + + private static unsafe bool ComparePalette(FIBITMAP dib1, FIBITMAP dib2) + { + IntPtr pal1 = GetPalette(dib1), pal2 = GetPalette(dib2); + bool hasPalette1 = pal1 != IntPtr.Zero; + bool hasPalette2 = pal2 != IntPtr.Zero; + if (hasPalette1 ^ hasPalette2) + { + return false; + } + if (!hasPalette1) + { + return true; + } + uint colors = GetColorsUsed(dib1); + if (colors != GetColorsUsed(dib2)) + { + return false; + } + return CompareMemory((void*)pal1, (void*)pal2, sizeof(RGBQUAD) * colors); + } + + private static unsafe bool CompareData(FIBITMAP dib1, FIBITMAP dib2) + { + uint width = GetWidth(dib1); + if (width != GetWidth(dib2)) + { + return false; + } + uint height = GetHeight(dib1); + if (height != GetHeight(dib2)) + { + return false; + } + uint bpp = GetBPP(dib1); + if (bpp != GetBPP(dib2)) + { + return false; + } + if (GetColorType(dib1) != GetColorType(dib2)) + { + return false; + } + FREE_IMAGE_TYPE type = GetImageType(dib1); + if (type != GetImageType(dib2)) + { + return false; + } + if (GetRedMask(dib1) != GetRedMask(dib2)) + { + return false; + } + if (GetGreenMask(dib1) != GetGreenMask(dib2)) + { + return false; + } + if (GetBlueMask(dib1) != GetBlueMask(dib2)) + { + return false; + } + + byte* ptr1, ptr2; + int fullBytes; + int shift; + uint line = GetLine(dib1); + + if (type == FREE_IMAGE_TYPE.FIT_BITMAP) + { + switch (bpp) + { + case 32: + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (!CompareMemory(ptr1, ptr2, line)) + { + return false; + } + } + break; + case 24: + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (!CompareMemory(ptr1, ptr2, line)) + { + return false; + } + } + break; + case 16: + short* sPtr1, sPtr2; + short mask = (short)(GetRedMask(dib1) | GetGreenMask(dib1) | GetBlueMask(dib1)); + if (mask == -1) + { + for (int i = 0; i < height; i++) + { + sPtr1 = (short*)GetScanLine(dib1, i); + sPtr2 = (short*)GetScanLine(dib2, i); + if (!CompareMemory(sPtr1, sPtr1, line)) + { + return false; + } + } + } + else + { + for (int i = 0; i < height; i++) + { + sPtr1 = (short*)GetScanLine(dib1, i); + sPtr2 = (short*)GetScanLine(dib2, i); + for (int x = 0; x < width; x++) + { + if ((sPtr1[x] & mask) != (sPtr2[x] & mask)) + { + return false; + } + } + } + } + break; + case 8: + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (!CompareMemory(ptr1, ptr2, line)) + { + return false; + } + } + break; + case 4: + fullBytes = (int)width / 2; + shift = (width % 2) == 0 ? 8 : 4; + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (fullBytes != 0) + { + if (!CompareMemory(ptr1, ptr2, fullBytes)) + { + return false; + } + ptr1 += fullBytes; + ptr2 += fullBytes; + } + if (shift != 8) + { + if ((ptr1[0] >> shift) != (ptr2[0] >> shift)) + { + return false; + } + } + } + break; + case 1: + fullBytes = (int)width / 8; + shift = 8 - ((int)width % 8); + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (fullBytes != 0) + { + if (!CompareMemory(ptr1, ptr2, fullBytes)) + { + return false; + } + ptr1 += fullBytes; + ptr2 += fullBytes; + } + if (shift != 8) + { + if ((ptr1[0] >> shift) != (ptr2[0] >> shift)) + { + return false; + } + } + } + break; + default: + throw new NotSupportedException("Only 1, 4, 8, 16, 24 and 32 bpp bitmaps are supported."); + } + } + else + { + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (!CompareMemory(ptr1, ptr2, line)) + { + return false; + } + } + } + return true; + } + + private static bool CompareMetadata(FIBITMAP dib1, FIBITMAP dib2) + { + MetadataTag tag1, tag2; + + foreach (FREE_IMAGE_MDMODEL metadataModel in FREE_IMAGE_MDMODELS) + { + if (GetMetadataCount(metadataModel, dib1) != + GetMetadataCount(metadataModel, dib2)) + { + return false; + } + if (GetMetadataCount(metadataModel, dib1) == 0) + { + continue; + } + + FIMETADATA mdHandle = FindFirstMetadata(metadataModel, dib1, out tag1); + if (mdHandle.IsNull) + { + continue; + } + do + { + if ((!GetMetadata(metadataModel, dib2, tag1.Key, out tag2)) || (tag1 != tag2)) + { + FindCloseMetadata(mdHandle); + return false; + } + } + while (FindNextMetadata(mdHandle, out tag1)); + FindCloseMetadata(mdHandle); + } + + return true; + } + + /// + /// Returns the FreeImage bitmap's transparency table. + /// The array is empty in case the bitmap has no transparency table. + /// + /// Handle to a FreeImage bitmap. + /// The FreeImage bitmap's transparency table. + /// + /// is null. + public static unsafe byte[] GetTransparencyTableEx(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + uint count = GetTransparencyCount(dib); + byte[] result = new byte[count]; + byte* ptr = (byte*)GetTransparencyTable(dib); + fixed (byte* dst = result) + { + CopyMemory(dst, ptr, count); + } + return result; + } + + /// + /// Set the FreeImage bitmap's transparency table. Only affects palletised bitmaps. + /// + /// Handle to a FreeImage bitmap. + /// The FreeImage bitmap's new transparency table. + /// + /// or is null. + public static void SetTransparencyTable(FIBITMAP dib, byte[] table) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (table == null) + { + throw new ArgumentNullException("table"); + } + SetTransparencyTable(dib, table, table.Length); + } + + /// + /// This function returns the number of unique colors actually used by the + /// specified 1-, 4-, 8-, 16-, 24- or 32-bit image. This might be different from + /// what function FreeImage_GetColorsUsed() returns, which actually returns the + /// palette size for palletised images. Works for + /// type images only. + /// + /// Handle to a FreeImage bitmap. + /// Returns the number of unique colors used by the image specified or + /// zero, if the image type cannot be handled. + /// + /// is null. + public static unsafe int GetUniqueColors(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + + int result = 0; + + if (GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) + { + BitArray bitArray; + int uniquePalEnts; + int hashcode; + byte[] lut; + int width = (int)GetWidth(dib); + int height = (int)GetHeight(dib); + + switch (GetBPP(dib)) + { + case 1: + + result = 1; + lut = CreateShrunkenPaletteLUT(dib, out uniquePalEnts); + if (uniquePalEnts == 1) + { + break; + } + + if ((*(byte*)GetScanLine(dib, 0) & 0x80) == 0) + { + for (int y = 0; y < height; y++) + { + byte* scanline = (byte*)GetScanLine(dib, y); + int mask = 0x80; + for (int x = 0; x < width; x++) + { + if ((scanline[x / 8] & mask) > 0) + { + return 2; + } + mask = (mask == 0x1) ? 0x80 : (mask >> 1); + } + } + } + else + { + for (int y = 0; y < height; y++) + { + byte* scanline = (byte*)GetScanLine(dib, y); + int mask = 0x80; + for (int x = 0; x < width; x++) + { + if ((scanline[x / 8] & mask) == 0) + { + return 2; + } + mask = (mask == 0x1) ? 0x80 : (mask >> 1); + } + } + } + break; + + case 4: + + bitArray = new BitArray(0x10); + lut = CreateShrunkenPaletteLUT(dib, out uniquePalEnts); + if (uniquePalEnts == 1) + { + result = 1; + break; + } + + for (int y = 0; (y < height) && (result < uniquePalEnts); y++) + { + byte* scanline = (byte*)GetScanLine(dib, y); + bool top = true; + for (int x = 0; (x < width) && (result < uniquePalEnts); x++) + { + if (top) + { + hashcode = lut[scanline[x / 2] >> 4]; + } + else + { + hashcode = lut[scanline[x / 2] & 0xF]; + } + top = !top; + if (!bitArray[hashcode]) + { + bitArray[hashcode] = true; + result++; + } + } + } + break; + + case 8: + + bitArray = new BitArray(0x100); + lut = CreateShrunkenPaletteLUT(dib, out uniquePalEnts); + if (uniquePalEnts == 1) + { + result = 1; + break; + } + + for (int y = 0; (y < height) && (result < uniquePalEnts); y++) + { + byte* scanline = (byte*)GetScanLine(dib, y); + for (int x = 0; (x < width) && (result < uniquePalEnts); x++) + { + hashcode = lut[scanline[x]]; + if (!bitArray[hashcode]) + { + bitArray[hashcode] = true; + result++; + } + } + } + break; + + case 16: + + bitArray = new BitArray(0x10000); + + for (int y = 0; y < height; y++) + { + short* scanline = (short*)GetScanLine(dib, y); + for (int x = 0; x < width; x++, scanline++) + { + hashcode = *scanline; + if (!bitArray[hashcode]) + { + bitArray[hashcode] = true; + result++; + } + } + } + break; + + case 24: + + bitArray = new BitArray(0x1000000); + + for (int y = 0; y < height; y++) + { + byte* scanline = (byte*)GetScanLine(dib, y); + for (int x = 0; x < width; x++, scanline += 3) + { + hashcode = *((int*)scanline) & 0x00FFFFFF; + if (!bitArray[hashcode]) + { + bitArray[hashcode] = true; + result++; + } + } + } + break; + + case 32: + + bitArray = new BitArray(0x1000000); + + for (int y = 0; y < height; y++) + { + int* scanline = (int*)GetScanLine(dib, y); + for (int x = 0; x < width; x++, scanline++) + { + hashcode = *scanline & 0x00FFFFFF; + if (!bitArray[hashcode]) + { + bitArray[hashcode] = true; + result++; + } + } + } + break; + } + } + return result; + } + + /// + /// Verifies whether the FreeImage bitmap is 16bit 555. + /// + /// The FreeImage bitmap to verify. + /// true if the bitmap is RGB16-555; otherwise false. + public static bool IsRGB555(FIBITMAP dib) + { + return ((GetRedMask(dib) == FI16_555_RED_MASK) && + (GetGreenMask(dib) == FI16_555_GREEN_MASK) && + (GetBlueMask(dib) == FI16_555_BLUE_MASK)); + } + + /// + /// Verifies whether the FreeImage bitmap is 16bit 565. + /// + /// The FreeImage bitmap to verify. + /// true if the bitmap is RGB16-565; otherwise false. + public static bool IsRGB565(FIBITMAP dib) + { + return ((GetRedMask(dib) == FI16_565_RED_MASK) && + (GetGreenMask(dib) == FI16_565_GREEN_MASK) && + (GetBlueMask(dib) == FI16_565_BLUE_MASK)); + } + + #endregion + + #region ICC profile functions + + /// + /// Creates a new ICC-Profile for a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The data of the new ICC-Profile. + /// The new ICC-Profile of the bitmap. + /// + /// is null. + public static FIICCPROFILE CreateICCProfileEx(FIBITMAP dib, byte[] data) + { + return new FIICCPROFILE(dib, data); + } + + /// + /// Creates a new ICC-Profile for a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The data of the new ICC-Profile. + /// The number of bytes of to use. + /// The new ICC-Profile of the FreeImage bitmap. + /// + /// is null. + public static FIICCPROFILE CreateICCProfileEx(FIBITMAP dib, byte[] data, int size) + { + return new FIICCPROFILE(dib, data, size); + } + + #endregion + + #region Conversion functions + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion) + { + return ConvertColorDepth( + dib, + conversion, + 128, + FREE_IMAGE_DITHER.FID_FS, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + false); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// When true the structure will be unloaded on success. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + bool unloadSource) + { + return ConvertColorDepth( + dib, + conversion, + 128, + FREE_IMAGE_DITHER.FID_FS, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + unloadSource); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Threshold value when converting with + /// . + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + byte threshold) + { + return ConvertColorDepth( + dib, + conversion, + threshold, + FREE_IMAGE_DITHER.FID_FS, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + false); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Dither algorithm when converting + /// with . + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + FREE_IMAGE_DITHER ditherMethod) + { + return ConvertColorDepth( + dib, + conversion, + 128, + ditherMethod, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + false); + } + + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// The quantization algorithm for conversion to 8-bit color depth. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + FREE_IMAGE_QUANTIZE quantizationMethod) + { + return ConvertColorDepth( + dib, + conversion, + 128, + FREE_IMAGE_DITHER.FID_FS, + quantizationMethod, + false); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Threshold value when converting with + /// . + /// When true the structure will be unloaded on success. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + byte threshold, + bool unloadSource) + { + return ConvertColorDepth( + dib, + conversion, + threshold, + FREE_IMAGE_DITHER.FID_FS, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + unloadSource); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Dither algorithm when converting with + /// . + /// When true the structure will be unloaded on success. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + FREE_IMAGE_DITHER ditherMethod, + bool unloadSource) + { + return ConvertColorDepth( + dib, + conversion, + 128, + ditherMethod, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + unloadSource); + } + + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// The quantization algorithm for conversion to 8-bit color depth. + /// When true the structure will be unloaded on success. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + FREE_IMAGE_QUANTIZE quantizationMethod, + bool unloadSource) + { + return ConvertColorDepth( + dib, + conversion, + 128, + FREE_IMAGE_DITHER.FID_FS, + quantizationMethod, + unloadSource); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Threshold value when converting with + /// . + /// Dither algorithm when converting with + /// . + /// The quantization algorithm for conversion to 8-bit color depth. + /// When true the structure will be unloaded on success. + /// Handle to a FreeImage bitmap. + /// + /// is null. + internal static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + byte threshold, + FREE_IMAGE_DITHER ditherMethod, + FREE_IMAGE_QUANTIZE quantizationMethod, + bool unloadSource) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + + FIBITMAP result = new FIBITMAP(); + FIBITMAP dibTemp = new FIBITMAP(); + uint bpp = GetBPP(dib); + bool reorderPalette = ((conversion & FREE_IMAGE_COLOR_DEPTH.FICD_REORDER_PALETTE) > 0); + bool forceGreyscale = ((conversion & FREE_IMAGE_COLOR_DEPTH.FICD_FORCE_GREYSCALE) > 0); + + if (GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) + { + switch (conversion & (FREE_IMAGE_COLOR_DEPTH)0xFF) + { + case FREE_IMAGE_COLOR_DEPTH.FICD_01_BPP_THRESHOLD: + + if (bpp != 1) + { + if (forceGreyscale) + { + result = Threshold(dib, threshold); + } + else + { + dibTemp = ConvertTo24Bits(dib); + result = ColorQuantizeEx(dibTemp, quantizationMethod, 2, null, 1); + Unload(dibTemp); + } + } + else + { + bool isGreyscale = IsGreyscaleImage(dib); + if ((forceGreyscale && (!isGreyscale)) || + (reorderPalette && isGreyscale)) + { + result = Threshold(dib, threshold); + } + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_01_BPP_DITHER: + + if (bpp != 1) + { + if (forceGreyscale) + { + result = Dither(dib, ditherMethod); + } + else + { + dibTemp = ConvertTo24Bits(dib); + result = ColorQuantizeEx(dibTemp, quantizationMethod, 2, null, 1); + Unload(dibTemp); + } + } + else + { + bool isGreyscale = IsGreyscaleImage(dib); + if ((forceGreyscale && (!isGreyscale)) || + (reorderPalette && isGreyscale)) + { + result = Dither(dib, ditherMethod); + } + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_04_BPP: + + if (bpp != 4) + { + // Special case when 1bpp and FIC_PALETTE + if (forceGreyscale || + ((bpp == 1) && (GetColorType(dib) == FREE_IMAGE_COLOR_TYPE.FIC_PALETTE))) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo4Bits(dibTemp); + Unload(dibTemp); + } + else + { + dibTemp = ConvertTo24Bits(dib); + result = ColorQuantizeEx(dibTemp, quantizationMethod, 16, null, 4); + Unload(dibTemp); + } + } + else + { + bool isGreyscale = IsGreyscaleImage(dib); + if ((forceGreyscale && (!isGreyscale)) || + (reorderPalette && isGreyscale)) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo4Bits(dibTemp); + Unload(dibTemp); + } + } + + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP: + + if (bpp != 8) + { + if (forceGreyscale) + { + result = ConvertToGreyscale(dib); + } + else + { + dibTemp = ConvertTo24Bits(dib); + result = ColorQuantize(dibTemp, quantizationMethod); + Unload(dibTemp); + } + } + else + { + bool isGreyscale = IsGreyscaleImage(dib); + if ((forceGreyscale && (!isGreyscale)) || (reorderPalette && isGreyscale)) + { + result = ConvertToGreyscale(dib); + } + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_16_BPP_555: + + if (forceGreyscale) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo16Bits555(dibTemp); + Unload(dibTemp); + } + else if (bpp != 16 || GetRedMask(dib) != FI16_555_RED_MASK || GetGreenMask(dib) != FI16_555_GREEN_MASK || GetBlueMask(dib) != FI16_555_BLUE_MASK) + { + result = ConvertTo16Bits555(dib); + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_16_BPP: + + if (forceGreyscale) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo16Bits565(dibTemp); + Unload(dibTemp); + } + else if (bpp != 16 || GetRedMask(dib) != FI16_565_RED_MASK || GetGreenMask(dib) != FI16_565_GREEN_MASK || GetBlueMask(dib) != FI16_565_BLUE_MASK) + { + result = ConvertTo16Bits565(dib); + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_24_BPP: + + if (forceGreyscale) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo24Bits(dibTemp); + Unload(dibTemp); + } + else if (bpp != 24) + { + result = ConvertTo24Bits(dib); + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_32_BPP: + + if (forceGreyscale) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo32Bits(dibTemp); + Unload(dibTemp); + } + else if (bpp != 32) + { + result = ConvertTo32Bits(dib); + } + break; + } + } + + if (result.IsNull) + { + return dib; + } + if (unloadSource) + { + Unload(dib); + } + + return result; + } + + /// + /// ColorQuantizeEx is an extension to the + /// method that provides additional options used to quantize a 24-bit image to any + /// number of colors (up to 256), as well as quantize a 24-bit image using a + /// provided palette. + /// + /// Handle to a FreeImage bitmap. + /// Specifies the color reduction algorithm to be used. + /// Size of the desired output palette. + /// The provided palette. + /// true to create a bitmap with the smallest possible + /// color depth for the specified . + /// Handle to a FreeImage bitmap. + public static FIBITMAP ColorQuantizeEx(FIBITMAP dib, FREE_IMAGE_QUANTIZE quantize, int PaletteSize, RGBQUAD[] ReservePalette, bool minColorDepth) + { + FIBITMAP result; + if (minColorDepth) + { + int bpp; + if (PaletteSize >= 256) + bpp = 8; + else if (PaletteSize > 2) + bpp = 4; + else + bpp = 1; + result = ColorQuantizeEx(dib, quantize, PaletteSize, ReservePalette, bpp); + } + else + { + result = ColorQuantizeEx(dib, quantize, PaletteSize, ReservePalette, 8); + } + return result; + } + + /// + /// ColorQuantizeEx is an extension to the + /// method that provides additional options used to quantize a 24-bit image to any + /// number of colors (up to 256), as well as quantize a 24-bit image using a + /// partial or full provided palette. + /// + /// Handle to a FreeImage bitmap. + /// Specifies the color reduction algorithm to be used. + /// Size of the desired output palette. + /// The provided palette. + /// The desired color depth of the created image. + /// Handle to a FreeImage bitmap. + public static FIBITMAP ColorQuantizeEx(FIBITMAP dib, FREE_IMAGE_QUANTIZE quantize, int PaletteSize, RGBQUAD[] ReservePalette, int bpp) + { + unsafe + { + FIBITMAP result = FIBITMAP.Zero; + FIBITMAP temp = FIBITMAP.Zero; + int reservedSize = (ReservePalette == null) ? 0 : ReservePalette.Length; + + if (bpp == 8) + { + result = ColorQuantizeEx(dib, quantize, PaletteSize, reservedSize, ReservePalette); + } + else if (bpp == 4) + { + temp = ColorQuantizeEx(dib, quantize, Math.Min(16, PaletteSize), reservedSize, ReservePalette); + if (!temp.IsNull) + { + result = Allocate((int)GetWidth(temp), (int)GetHeight(temp), 4, 0, 0, 0); + CloneMetadata(result, temp); + CopyMemory(GetPalette(result), GetPalette(temp), sizeof(RGBQUAD) * 16); + + for (int y = (int)GetHeight(temp) - 1; y >= 0; y--) + { + Scanline srcScanline = new Scanline(temp, y); + Scanline dstScanline = new Scanline(result, y); + + for (int x = (int)GetWidth(temp) - 1; x >= 0; x--) + { + dstScanline[x] = srcScanline[x]; + } + } + } + } + else if (bpp == 1) + { + temp = ColorQuantizeEx(dib, quantize, 2, reservedSize, ReservePalette); + if (!temp.IsNull) + { + result = Allocate((int)GetWidth(temp), (int)GetHeight(temp), 1, 0, 0, 0); + CloneMetadata(result, temp); + CopyMemory(GetPalette(result), GetPalette(temp), sizeof(RGBQUAD) * 2); + + for (int y = (int)GetHeight(temp) - 1; y >= 0; y--) + { + Scanline srcScanline = new Scanline(temp, y); + Scanline dstScanline = new Scanline(result, y); + + for (int x = (int)GetWidth(temp) - 1; x >= 0; x--) + { + dstScanline[x] = srcScanline[x]; + } + } + } + } + + UnloadEx(ref temp); + return result; + } + } + + #endregion + + #region Metadata + + /// + /// Copies metadata from one FreeImage bitmap to another. + /// + /// Source FreeImage bitmap containing the metadata. + /// FreeImage bitmap to copy the metadata to. + /// Flags to switch different copy modes. + /// Returns -1 on failure else the number of copied tags. + /// + /// or is null. + public static int CloneMetadataEx(FIBITMAP src, FIBITMAP dst, FREE_IMAGE_METADATA_COPY flags) + { + if (src.IsNull) + { + throw new ArgumentNullException("src"); + } + if (dst.IsNull) + { + throw new ArgumentNullException("dst"); + } + + FITAG tag = new FITAG(), tag2 = new FITAG(); + int copied = 0; + + // Clear all existing metadata + if ((flags & FREE_IMAGE_METADATA_COPY.CLEAR_EXISTING) > 0) + { + foreach (FREE_IMAGE_MDMODEL model in FREE_IMAGE_MDMODELS) + { + if (!SetMetadata(model, dst, null, tag)) + { + return -1; + } + } + } + + bool keep = !((flags & FREE_IMAGE_METADATA_COPY.REPLACE_EXISTING) > 0); + + foreach (FREE_IMAGE_MDMODEL model in FREE_IMAGE_MDMODELS) + { + FIMETADATA mData = FindFirstMetadata(model, src, out tag); + if (mData.IsNull) continue; + do + { + string key = GetTagKey(tag); + if (!(keep && GetMetadata(model, dst, key, out tag2))) + { + if (SetMetadata(model, dst, key, tag)) + { + copied++; + } + } + } + while (FindNextMetadata(mData, out tag)); + FindCloseMetadata(mData); + } + + return copied; + } + + /// + /// Returns the comment of a JPEG, PNG or GIF image. + /// + /// Handle to a FreeImage bitmap. + /// Comment of the FreeImage bitmp, or null in case no comment exists. + /// + /// is null. + public static string GetImageComment(FIBITMAP dib) + { + string result = null; + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + FITAG tag; + if (GetMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, "Comment", out tag)) + { + MetadataTag metadataTag = new MetadataTag(tag, FREE_IMAGE_MDMODEL.FIMD_COMMENTS); + result = metadataTag.Value as string; + } + return result; + } + + /// + /// Sets the comment of a JPEG, PNG or GIF image. + /// + /// Handle to a FreeImage bitmap. + /// New comment of the FreeImage bitmap. + /// Use null to remove the comment. + /// Returns true on success, false on failure. + /// + /// is null. + public static bool SetImageComment(FIBITMAP dib, string comment) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + bool result; + if (comment != null) + { + FITAG tag = CreateTag(); + MetadataTag metadataTag = new MetadataTag(tag, FREE_IMAGE_MDMODEL.FIMD_COMMENTS); + metadataTag.Value = comment; + result = SetMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, "Comment", tag); + DeleteTag(tag); + } + else + { + result = SetMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, "Comment", FITAG.Zero); + } + return result; + } + + /// + /// Retrieve a metadata attached to a FreeImage bitmap. + /// + /// The metadata model to look for. + /// Handle to a FreeImage bitmap. + /// The metadata field name. + /// A structure returned by the function. + /// Returns true on success, false on failure. + /// + /// is null. + public static bool GetMetadata( + FREE_IMAGE_MDMODEL model, + FIBITMAP dib, + string key, + out MetadataTag tag) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + + FITAG _tag; + bool result; + if (GetMetadata(model, dib, key, out _tag)) + { + tag = new MetadataTag(_tag, model); + result = true; + } + else + { + tag = null; + result = false; + } + return result; + } + + /// + /// Attach a new metadata tag to a FreeImage bitmap. + /// + /// The metadata model used to store the tag. + /// Handle to a FreeImage bitmap. + /// The tag field name. + /// The to be attached. + /// Returns true on success, false on failure. + /// + /// is null. + public static bool SetMetadata( + FREE_IMAGE_MDMODEL model, + FIBITMAP dib, + string key, + MetadataTag tag) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + return SetMetadata(model, dib, key, tag.tag); + } + + /// + /// Provides information about the first instance of a tag that matches the metadata model. + /// + /// The model to match. + /// Handle to a FreeImage bitmap. + /// Tag that matches the metadata model. + /// Unique search handle that can be used to call FindNextMetadata or FindCloseMetadata. + /// Null if the metadata model does not exist. + /// + /// is null. + public static FIMETADATA FindFirstMetadata( + FREE_IMAGE_MDMODEL model, + FIBITMAP dib, + out MetadataTag tag) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + FITAG _tag; + FIMETADATA result = FindFirstMetadata(model, dib, out _tag); + if (result.IsNull) + { + tag = null; + return result; + } + tag = new MetadataTag(_tag, model); + if (metaDataSearchHandler.ContainsKey(result)) + { + metaDataSearchHandler[result] = model; + } + else + { + metaDataSearchHandler.Add(result, model); + } + return result; + } + + /// + /// Find the next tag, if any, that matches the metadata model argument in a previous call + /// to FindFirstMetadata, and then alters the tag object contents accordingly. + /// + /// Unique search handle provided by FindFirstMetadata. + /// Tag that matches the metadata model. + /// Returns true on success, false on failure. + public static bool FindNextMetadata(FIMETADATA mdhandle, out MetadataTag tag) + { + FITAG _tag; + bool result; + if (FindNextMetadata(mdhandle, out _tag)) + { + tag = new MetadataTag(_tag, metaDataSearchHandler[mdhandle]); + result = true; + } + else + { + tag = null; + result = false; + } + return result; + } + + /// + /// Closes the specified metadata search handle and releases associated resources. + /// + /// The handle to close. + public static void FindCloseMetadata(FIMETADATA mdhandle) + { + if (metaDataSearchHandler.ContainsKey(mdhandle)) + { + metaDataSearchHandler.Remove(mdhandle); + } + FindCloseMetadata_(mdhandle); + } + + /// + /// This dictionary links FIMETADATA handles and FREE_IMAGE_MDMODEL models. + /// + private static Dictionary metaDataSearchHandler + = new Dictionary(1); + + #endregion + + #region Rotation and Flipping + + /// + /// This function rotates a 1-, 8-bit greyscale or a 24-, 32-bit color image by means of 3 shears. + /// 1-bit images rotation is limited to integer multiple of 90°. + /// null is returned for other values. + /// + /// Handle to a FreeImage bitmap. + /// The angle of rotation. + /// Handle to a FreeImage bitmap. + public static FIBITMAP Rotate(FIBITMAP dib, double angle) + { + return Rotate(dib, angle, IntPtr.Zero); + } + + /// + /// This function rotates a 1-, 8-bit greyscale or a 24-, 32-bit color image by means of 3 shears. + /// 1-bit images rotation is limited to integer multiple of 90°. + /// null is returned for other values. + /// + /// The type of the color to use as background. + /// Handle to a FreeImage bitmap. + /// The angle of rotation. + /// The color used used to fill the bitmap's background. + /// Handle to a FreeImage bitmap. + public static FIBITMAP Rotate(FIBITMAP dib, double angle, T? backgroundColor) where T : struct + { + if (backgroundColor.HasValue) + { + GCHandle handle = new GCHandle(); + try + { + T[] buffer = new T[] { backgroundColor.Value }; + handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + return Rotate(dib, angle, handle.AddrOfPinnedObject()); + } + finally + { + if (handle.IsAllocated) + handle.Free(); + } + } + else + { + return Rotate(dib, angle, IntPtr.Zero); + } + } + + /// + /// Rotates a 4-bit color FreeImage bitmap. + /// Allowed values for are 90, 180 and 270. + /// In case is 0 or 360 a clone is returned. + /// 0 is returned for other values or in case the rotation fails. + /// + /// Handle to a FreeImage bitmap. + /// The angle of rotation. + /// Handle to a FreeImage bitmap. + /// + /// This function is kind of temporary due to FreeImage's lack of + /// rotating 4-bit images. It's particularly used by 's + /// method RotateFlip. This function will be removed as soon as FreeImage + /// supports rotating 4-bit images. + /// + /// + /// is null. + public static unsafe FIBITMAP Rotate4bit(FIBITMAP dib, double angle) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + + FIBITMAP result = new FIBITMAP(); + int ang = (int)angle; + + if ((GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) && + (GetBPP(dib) == 4) && + ((ang % 90) == 0)) + { + int width, height, xOrg, yOrg; + Scanline[] src, dst; + width = (int)GetWidth(dib); + height = (int)GetHeight(dib); + byte index = 0; + switch (ang) + { + case 90: + result = Allocate(height, width, 4, 0, 0, 0); + if (result.IsNull) + { + break; + } + CopyPalette(dib, result); + src = Get04BitScanlines(dib); + dst = Get04BitScanlines(result); + for (int y = 0; y < width; y++) + { + yOrg = height - 1; + for (int x = 0; x < height; x++, yOrg--) + { + index = src[yOrg][y]; + dst[y][x] = index; + } + } + break; + case 180: + result = Allocate(width, height, 4, 0, 0, 0); + if (result.IsNull) + { + break; + } + CopyPalette(dib, result); + src = Get04BitScanlines(dib); + dst = Get04BitScanlines(result); + + yOrg = height - 1; + for (int y = 0; y < height; y++, yOrg--) + { + xOrg = width - 1; + for (int x = 0; x < width; x++, xOrg--) + { + index = src[yOrg][xOrg]; + dst[y][x] = index; + } + } + break; + case 270: + result = Allocate(height, width, 4, 0, 0, 0); + if (result.IsNull) + { + break; + } + CopyPalette(dib, result); + src = Get04BitScanlines(dib); + dst = Get04BitScanlines(result); + xOrg = width - 1; + for (int y = 0; y < width; y++, xOrg--) + { + for (int x = 0; x < height; x++) + { + index = src[x][xOrg]; + dst[y][x] = index; + } + } + break; + case 0: + case 360: + result = Clone(dib); + break; + } + } + return result; + } + + #endregion + + #region Upsampling / downsampling + + /// + /// Enlarges or shrinks the FreeImage bitmap selectively per side and fills newly added areas + /// with the specified background color. See remarks for further details. + /// + /// The type of the specified color. + /// Handle to a FreeImage bitmap. + /// The number of pixels, the image should be enlarged on its left side. + /// Negative values shrink the image on its left side. + /// The number of pixels, the image should be enlarged on its top side. + /// Negative values shrink the image on its top side. + /// The number of pixels, the image should be enlarged on its right side. + /// Negative values shrink the image on its right side. + /// The number of pixels, the image should be enlarged on its bottom side. + /// Negative values shrink the image on its bottom side. + /// The color, the enlarged sides of the image should be filled with. + /// Options that affect the color search process for palletized images. + /// Handle to a FreeImage bitmap. + /// + /// This function enlarges or shrinks an image selectively per side. + /// The main purpose of this function is to add borders to an image. + /// To add a border to any of the image's sides, a positive integer value must be passed in + /// any of the parameters , , + /// or . This value represents the border's + /// width in pixels. Newly created parts of the image (the border areas) are filled with the + /// specified . + /// Specifying a negative integer value for a certain side, will shrink or crop the image on + /// this side. Consequently, specifying zero for a certain side will not change the image's + /// extension on that side. + /// + /// So, calling this function with all parameters , , + /// and set to zero, is + /// effectively the same as calling function ; setting all parameters + /// , , and + /// to value equal to or smaller than zero, my easily be substituted + /// by a call to function . Both these cases produce a new image, which is + /// guaranteed not to be larger than the input image. Thus, since the specified + /// is not needed in these cases, + /// may be null. + /// + /// Both parameters and work according to + /// function . So, please refer to the documentation of + /// to learn more about parameters + /// and . For palletized images, the palette of the input image is + /// transparently copied to the newly created enlarged or shrunken image, so any color look-ups + /// are performed on this palette. + /// + /// + /// // create a white color
+ /// RGBQUAD c;
+ /// c.rgbRed = 0xFF;
+ /// c.rgbGreen = 0xFF;
+ /// c.rgbBlue = 0xFF;
+ /// c.rgbReserved = 0x00;
+ ///
+ /// // add a white, symmetric 10 pixel wide border to the image
+ /// dib2 = FreeImage_EnlargeCanvas(dib, 10, 10, 10, 10, c, FREE_IMAGE_COLOR_OPTIONS.FICO_RGB);
+ ///
+ /// // add white, 20 pixel wide stripes to the top and bottom side of the image
+ /// dib3 = FreeImage_EnlargeCanvas(dib, 0, 20, 0, 20, c, FREE_IMAGE_COLOR_OPTIONS.FICO_RGB);
+ ///
+ /// // add white, 30 pixel wide stripes to the right side of the image and
+ /// // cut off the 40 leftmost pixel columns
+ /// dib3 = FreeImage_EnlargeCanvas(dib, -40, 0, 30, 0, c, FREE_IMAGE_COLOR_OPTIONS.FICO_RGB);
+ ///
+ public static FIBITMAP EnlargeCanvas(FIBITMAP dib, int left, int top, int right, int bottom, + T? color, FREE_IMAGE_COLOR_OPTIONS options) where T : struct + { + if (dib.IsNull) + return FIBITMAP.Zero; + + if (color.HasValue) + { + if (!CheckColorType(GetImageType(dib), color.Value)) + return FIBITMAP.Zero; + + GCHandle handle = new GCHandle(); + try + { + T[] buffer = new T[] { color.Value }; + handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + return EnlargeCanvas(dib, left, top, right, bottom, handle.AddrOfPinnedObject(), options); + } + finally + { + if (handle.IsAllocated) + handle.Free(); + } + } + else + { + return EnlargeCanvas(dib, left, top, right, bottom, IntPtr.Zero, options); + } + } + + #endregion + + #region Color + + /// + /// Sets all pixels of the specified image to the color provided through the + /// parameter. See remarks for further details. + /// + /// The type of the specified color. + /// Handle to a FreeImage bitmap. + /// The color to fill the bitmap with. See remarks for further details. + /// Options that affect the color search process for palletized images. + /// true on success, false on failure. + /// + /// This function sets all pixels of an image to the color provided through + /// the parameter. is used for standard type images. + /// For non standard type images the underlaying structure is used. + /// + /// So, must be of type , if the image to be filled is of type + /// and must be a structure if the + /// image is of type and so on. + /// + /// However, the fill color is always specified through a structure + /// for all images of type . + /// So, for 32- and 24-bit images, the red, green and blue members of the + /// structure are directly used for the image's red, green and blue channel respectively. + /// Although alpha transparent colors are + /// supported, the alpha channel of a 32-bit image never gets modified by this function. + /// A fill color with an alpha value smaller than 255 gets blended with the image's actual + /// background color, which is determined from the image's bottom-left pixel. + /// So, currently using alpha enabled colors, assumes the image to be unicolor before the + /// fill operation. However, the field is only taken into account, + /// if option has been specified. + /// + /// For 16-bit images, the red-, green- and blue components of the specified color are + /// transparently translated into either the 16-bit 555 or 565 representation. This depends + /// on the image's actual red- green- and blue masks. + /// + /// Special attention must be payed for palletized images. Generally, the RGB color specified + /// is looked up in the image's palette. The found palette index is then used to fill the image. + /// There are some option flags, that affect this lookup process: + /// + /// + /// Value + /// Meaning + /// + /// + /// + /// + /// Uses the color, that is nearest to the specified color. + /// This is the default behavior and should always find a + /// color in the palette. However, the visual result may + /// far from what was expected and mainly depends on the + /// image's palette. + /// + /// + /// + /// + /// + /// Searches the image's palette for the specified color + /// but only uses the returned palette index, if the specified + /// color exactly matches the palette entry. Of course, + /// depending on the image's actual palette entries, this + /// operation may fail. In this case, the function falls back + /// to option + /// and uses the RGBQUAD's rgbReserved member (or its low nibble for 4-bit images + /// or its least significant bit (LSB) for 1-bit images) as + /// the palette index used for the fill operation. + /// + /// + /// + /// + /// + /// Does not perform any color lookup from the palette, but + /// uses the RGBQUAD's alpha channel member rgbReserved as + /// the palette index to be used for the fill operation. + /// However, for 4-bit images, only the low nibble of the + /// rgbReserved member are used and for 1-bit images, only + /// the least significant bit (LSB) is used. + /// + /// + /// + /// + public static bool FillBackground(FIBITMAP dib, T color, FREE_IMAGE_COLOR_OPTIONS options) + where T : struct + { + if (dib.IsNull) + return false; + + if (!CheckColorType(GetImageType(dib), color)) + return false; + + GCHandle handle = new GCHandle(); + try + { + T[] buffer = new T[] { color }; + handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + return FillBackground(dib, handle.AddrOfPinnedObject(), options); + } + finally + { + if (handle.IsAllocated) + handle.Free(); + } + } + + #endregion + + #region Wrapper functions + + /// + /// Returns the next higher possible color depth. + /// + /// Color depth to increase. + /// The next higher color depth or 0 if there is no valid color depth. + internal static int GetNextColorDepth(int bpp) + { + int result = 0; + switch (bpp) + { + case 1: + result = 4; + break; + case 4: + result = 8; + break; + case 8: + result = 16; + break; + case 16: + result = 24; + break; + case 24: + result = 32; + break; + } + return result; + } + + /// + /// Returns the next lower possible color depth. + /// + /// Color depth to decrease. + /// The next lower color depth or 0 if there is no valid color depth. + internal static int GetPrevousColorDepth(int bpp) + { + int result = 0; + switch (bpp) + { + case 32: + result = 24; + break; + case 24: + result = 16; + break; + case 16: + result = 8; + break; + case 8: + result = 4; + break; + case 4: + result = 1; + break; + } + return result; + } + + /// + /// Reads a null-terminated c-string. + /// + /// Pointer to the first char of the string. + /// The converted string. + internal static unsafe string PtrToStr(byte* ptr) + { + string result = null; + if (ptr != null) + { + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + + while (*ptr != 0) + { + sb.Append((char)(*(ptr++))); + } + result = sb.ToString(); + } + return result; + } + + internal static unsafe byte[] CreateShrunkenPaletteLUT(FIBITMAP dib, out int uniqueColors) + { + byte[] result = null; + uniqueColors = 0; + + if ((!dib.IsNull) && (GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) && (GetBPP(dib) <= 8)) + { + int size = (int)GetColorsUsed(dib); + List newPalette = new List(size); + List lut = new List(size); + RGBQUAD* palette = (RGBQUAD*)GetPalette(dib); + RGBQUAD color; + int index; + + for (int i = 0; i < size; i++) + { + color = palette[i]; + color.rgbReserved = 255; // ignore alpha + + index = newPalette.IndexOf(color); + if (index < 0) + { + newPalette.Add(color); + lut.Add((byte)(newPalette.Count - 1)); + } + else + { + lut.Add((byte)index); + } + } + result = lut.ToArray(); + uniqueColors = newPalette.Count; + } + return result; + } + + internal static PropertyItem CreatePropertyItem() + { + return (PropertyItem)Activator.CreateInstance(typeof(PropertyItem), true); + } + + private static unsafe void CopyPalette(FIBITMAP src, FIBITMAP dst) + { + RGBQUAD* orgPal = (RGBQUAD*)GetPalette(src); + RGBQUAD* newPal = (RGBQUAD*)GetPalette(dst); + uint size = (uint)(sizeof(RGBQUAD) * GetColorsUsed(src)); + CopyMemory(newPal, orgPal, size); + } + + private static unsafe Scanline[] Get04BitScanlines(FIBITMAP dib) + { + int height = (int)GetHeight(dib); + Scanline[] array = new Scanline[height]; + for (int i = 0; i < height; i++) + { + array[i] = new Scanline(dib, i); + } + return array; + } + + /// + /// Changes a bitmaps color depth. + /// Used by SaveEx and SaveToStream. + /// + private static FIBITMAP PrepareBitmapColorDepth(FIBITMAP dibToSave, FREE_IMAGE_FORMAT format, FREE_IMAGE_COLOR_DEPTH colorDepth) + { + FREE_IMAGE_TYPE type = GetImageType(dibToSave); + if (type == FREE_IMAGE_TYPE.FIT_BITMAP) + { + int bpp = (int)GetBPP(dibToSave); + int targetBpp = (int)(colorDepth & FREE_IMAGE_COLOR_DEPTH.FICD_COLOR_MASK); + + if (colorDepth != FREE_IMAGE_COLOR_DEPTH.FICD_AUTO) + { + // A fix colordepth was chosen + if (FIFSupportsExportBPP(format, targetBpp)) + { + dibToSave = ConvertColorDepth(dibToSave, colorDepth, false); + } + else + { + throw new ArgumentException("FreeImage\n\nFreeImage Library plugin " + + GetFormatFromFIF(format) + " is unable to write images with a color depth of " + + targetBpp + " bpp."); + } + } + else + { + // Auto selection was chosen + if (!FIFSupportsExportBPP(format, bpp)) + { + // The color depth is not supported + int bppUpper = bpp; + int bppLower = bpp; + // Check from the bitmaps current color depth in both directions + do + { + bppUpper = GetNextColorDepth(bppUpper); + if (FIFSupportsExportBPP(format, bppUpper)) + { + dibToSave = ConvertColorDepth(dibToSave, (FREE_IMAGE_COLOR_DEPTH)bppUpper, false); + break; + } + bppLower = GetPrevousColorDepth(bppLower); + if (FIFSupportsExportBPP(format, bppLower)) + { + dibToSave = ConvertColorDepth(dibToSave, (FREE_IMAGE_COLOR_DEPTH)bppLower, false); + break; + } + } while (!((bppLower == 0) && (bppUpper == 0))); + } + } + } + return dibToSave; + } + + /// + /// Compares blocks of memory. + /// + /// A pointer to a block of memory to compare. + /// A pointer to a block of memory to compare. + /// Specifies the number of bytes to be compared. + /// true, if all bytes compare as equal, false otherwise. + public static unsafe bool CompareMemory(void* buf1, void* buf2, uint length) + { + return (length == RtlCompareMemory(buf1, buf2, length)); + } + + /// + /// Compares blocks of memory. + /// + /// A pointer to a block of memory to compare. + /// A pointer to a block of memory to compare. + /// Specifies the number of bytes to be compared. + /// true, if all bytes compare as equal, false otherwise. + public static unsafe bool CompareMemory(void* buf1, void* buf2, long length) + { + return (length == RtlCompareMemory(buf1, buf2, checked((uint)length))); + } + + /// + /// Compares blocks of memory. + /// + /// A pointer to a block of memory to compare. + /// A pointer to a block of memory to compare. + /// Specifies the number of bytes to be compared. + /// true, if all bytes compare as equal, false otherwise. + public static unsafe bool CompareMemory(IntPtr buf1, IntPtr buf2, uint length) + { + return (length == RtlCompareMemory(buf1.ToPointer(), buf2.ToPointer(), length)); + } + + /// + /// Compares blocks of memory. + /// + /// A pointer to a block of memory to compare. + /// A pointer to a block of memory to compare. + /// Specifies the number of bytes to be compared. + /// true, if all bytes compare as equal, false otherwise. + public static unsafe bool CompareMemory(IntPtr buf1, IntPtr buf2, long length) + { + return (length == RtlCompareMemory(buf1.ToPointer(), buf2.ToPointer(), checked((uint)length))); + } + + /// + /// Moves a block of memory from one location to another. + /// + /// A pointer to the starting address of the move destination. + /// A pointer to the starting address of the block of memory to be moved. + /// The size of the block of memory to move, in bytes. + public static unsafe void MoveMemory(void* dst, void* src, long size) + { + MoveMemory(dst, src, checked((uint)size)); + } + + /// + /// Moves a block of memory from one location to another. + /// + /// A pointer to the starting address of the move destination. + /// A pointer to the starting address of the block of memory to be moved. + /// The size of the block of memory to move, in bytes. + public static unsafe void MoveMemory(IntPtr dst, IntPtr src, uint size) + { + MoveMemory(dst.ToPointer(), src.ToPointer(), size); + } + + /// + /// Moves a block of memory from one location to another. + /// + /// A pointer to the starting address of the move destination. + /// A pointer to the starting address of the block of memory to be moved. + /// The size of the block of memory to move, in bytes. + public static unsafe void MoveMemory(IntPtr dst, IntPtr src, long size) + { + MoveMemory(dst.ToPointer(), src.ToPointer(), checked((uint)size)); + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(byte* dest, byte* src, int len) + { + if (len >= 0x10) + { + do + { + *((int*)dest) = *((int*)src); + *((int*)(dest + 4)) = *((int*)(src + 4)); + *((int*)(dest + 8)) = *((int*)(src + 8)); + *((int*)(dest + 12)) = *((int*)(src + 12)); + dest += 0x10; + src += 0x10; + } + while ((len -= 0x10) >= 0x10); + } + if (len > 0) + { + if ((len & 8) != 0) + { + *((int*)dest) = *((int*)src); + *((int*)(dest + 4)) = *((int*)(src + 4)); + dest += 8; + src += 8; + } + if ((len & 4) != 0) + { + *((int*)dest) = *((int*)src); + dest += 4; + src += 4; + } + if ((len & 2) != 0) + { + *((short*)dest) = *((short*)src); + dest += 2; + src += 2; + } + if ((len & 1) != 0) + { + *dest = *src; + } + } + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(byte* dest, byte* src, long len) + { + CopyMemory(dest, src, checked((int)len)); + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(void* dest, void* src, long len) + { + CopyMemory((byte*)dest, (byte*)src, checked((int)len)); + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(void* dest, void* src, int len) + { + CopyMemory((byte*)dest, (byte*)src, len); + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(IntPtr dest, IntPtr src, int len) + { + CopyMemory((byte*)dest, (byte*)src, len); + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(IntPtr dest, IntPtr src, long len) + { + CopyMemory((byte*)dest, (byte*)src, checked((int)len)); + } + + /// + /// Copies a block of memory into an array. + /// + /// An array used as the destination of the copy process. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(Array dest, void* src, int len) + { + GCHandle handle = GCHandle.Alloc(dest, GCHandleType.Pinned); + try + { + CopyMemory((byte*)handle.AddrOfPinnedObject(), (byte*)src, len); + } + finally + { + handle.Free(); + } + } + + /// + /// Copies a block of memory into an array. + /// + /// An array used as the destination of the copy process. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(Array dest, void* src, long len) + { + CopyMemory(dest, (byte*)src, checked((int)len)); + } + + /// + /// Copies a block of memory into an array. + /// + /// An array used as the destination of the copy process. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(Array dest, IntPtr src, int len) + { + CopyMemory(dest, (byte*)src, len); + } + + /// + /// Copies a block of memory into an array. + /// + /// An array used as the destination of the copy process. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(Array dest, IntPtr src, long len) + { + CopyMemory(dest, (byte*)src, checked((int)len)); + } + + /// + /// Copies the content of an array to a memory location. + /// + /// A pointer to the starting address of the copied block's destination. + /// An array used as the source of the copy process. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(void* dest, Array src, int len) + { + GCHandle handle = GCHandle.Alloc(src, GCHandleType.Pinned); + try + { + CopyMemory((byte*)dest, (byte*)handle.AddrOfPinnedObject(), len); + } + finally + { + handle.Free(); + } + } + + /// + /// Copies the content of an array to a memory location. + /// + /// A pointer to the starting address of the copied block's destination. + /// An array used as the source of the copy process. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(void* dest, Array src, long len) + { + CopyMemory((byte*)dest, src, checked((int)len)); + } + + /// + /// Copies the content of an array to a memory location. + /// + /// A pointer to the starting address of the copied block's destination. + /// An array used as the source of the copy process. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(IntPtr dest, Array src, int len) + { + CopyMemory((byte*)dest, src, len); + } + + /// + /// Copies the content of an array to a memory location. + /// + /// A pointer to the starting address of the copied block's destination. + /// An array used as the source of the copy process. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(IntPtr dest, Array src, long len) + { + CopyMemory((byte*)dest, src, checked((int)len)); + } + + /// + /// Copies the content of one array into another array. + /// + /// An array used as the destination of the copy process. + /// An array used as the source of the copy process. + /// The size of the content to copy, in bytes. + public static unsafe void CopyMemory(Array dest, Array src, int len) + { + GCHandle dHandle = GCHandle.Alloc(dest, GCHandleType.Pinned); + try + { + GCHandle sHandle = GCHandle.Alloc(src, GCHandleType.Pinned); + try + { + CopyMemory((byte*)dHandle.AddrOfPinnedObject(), (byte*)sHandle.AddrOfPinnedObject(), len); + } + finally + { + sHandle.Free(); + } + } + finally + { + dHandle.Free(); + } + } + + /// + /// Copies the content of one array into another array. + /// + /// An array used as the destination of the copy process. + /// An array used as the source of the copy process. + /// The size of the content to copy, in bytes. + public static unsafe void CopyMemory(Array dest, Array src, long len) + { + CopyMemory(dest, src, checked((int)len)); + } + + internal static string ColorToString(Color color) + { + return string.Format( + System.Globalization.CultureInfo.CurrentCulture, + "{{Name={0}, ARGB=({1}, {2}, {3}, {4})}}", + new object[] { color.Name, color.A, color.R, color.G, color.B }); + } + + internal static void Resize(ref string str, int length) + { + if ((str != null) && (length >= 0) && (str.Length != length)) + { + char[] chars = str.ToCharArray(); + Array.Resize(ref chars, length); + str = new string(chars); + } + } + + internal static void Resize(ref string str, int min, int max) + { + if ((str != null) && (min >= 0) && (max >= 0) && (min <= max)) + { + if (str.Length < min) + { + char[] chars = str.ToCharArray(); + Array.Resize(ref chars, min); + str = new string(chars); + } + else if (str.Length > max) + { + char[] chars = str.ToCharArray(); + Array.Resize(ref chars, max); + str = new string(chars); + } + } + } + + internal static void Resize(ref T[] array, int length) + { + if ((array != null) && (length >= 0) && (array.Length != length)) + { + Array.Resize(ref array, length); + } + } + + internal static void Resize(ref T[] array, int min, int max) + { + if ((array != null) && (min >= 0) && (max >= 0) && (min <= max)) + { + if (array.Length < min) + { + Array.Resize(ref array, min); + } + else if (array.Length > max) + { + Array.Resize(ref array, max); + } + } + } + + internal static bool CheckColorType(FREE_IMAGE_TYPE imageType, T color) + { + Type type = typeof(T); + bool result; + switch (imageType) + { + case FREE_IMAGE_TYPE.FIT_BITMAP: + result = (type == typeof(RGBQUAD)); break; + case FREE_IMAGE_TYPE.FIT_COMPLEX: + result = (type == typeof(FICOMPLEX)); break; + case FREE_IMAGE_TYPE.FIT_DOUBLE: + result = (type == typeof(double)); break; + case FREE_IMAGE_TYPE.FIT_FLOAT: + result = (type == typeof(float)); break; + case FREE_IMAGE_TYPE.FIT_INT16: + result = (type == typeof(Int16)); break; + case FREE_IMAGE_TYPE.FIT_INT32: + result = (type == typeof(Int32)); break; + case FREE_IMAGE_TYPE.FIT_RGB16: + result = (type == typeof(FIRGB16)); break; + case FREE_IMAGE_TYPE.FIT_RGBA16: + result = (type == typeof(FIRGBA16)); break; + case FREE_IMAGE_TYPE.FIT_RGBAF: + result = (type == typeof(FIRGBAF)); break; + case FREE_IMAGE_TYPE.FIT_RGBF: + result = (type == typeof(FIRGBF)); break; + case FREE_IMAGE_TYPE.FIT_UINT16: + result = (type == typeof(UInt16)); break; + case FREE_IMAGE_TYPE.FIT_UINT32: + result = (type == typeof(UInt32)); break; + default: + result = false; break; + } + return result; + } + + #endregion + + #region Dll-Imports + + /// + /// Retrieves a handle to a display device context (DC) for the client area of a specified window + /// or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC. + /// + /// Handle to the window whose DC is to be retrieved. + /// If this value is IntPtr.Zero, GetDC retrieves the DC for the entire screen. + /// If the function succeeds, the return value is a handle to the DC for the specified window's client area. + /// If the function fails, the return value is NULL. + [DllImport("user32.dll")] + private static extern IntPtr GetDC(IntPtr hWnd); + + /// + /// Releases a device context (DC), freeing it for use by other applications. + /// The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs. + /// It has no effect on class or private DCs. + /// + /// Handle to the window whose DC is to be released. + /// Handle to the DC to be released. + /// Returns true on success, false on failure. + [DllImport("user32.dll")] + private static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC); + + /// + /// Creates a DIB that applications can write to directly. + /// The function gives you a pointer to the location of the bitmap bit values. + /// You can supply a handle to a file-mapping object that the function will use to create the bitmap, + /// or you can let the system allocate the memory for the bitmap. + /// + /// Handle to a device context. + /// Pointer to a BITMAPINFO structure that specifies various attributes of the DIB, + /// including the bitmap dimensions and colors. + /// Specifies the type of data contained in the bmiColors array member of the BITMAPINFO structure + /// pointed to by pbmi (either logical palette indexes or literal RGB values). + /// Pointer to a variable that receives a pointer to the location of the DIB bit values. + /// Handle to a file-mapping object that the function will use to create the DIB. + /// This parameter can be NULL. + /// Specifies the offset from the beginning of the file-mapping object referenced by hSection + /// where storage for the bitmap bit values is to begin. This value is ignored if hSection is NULL. + /// If the function succeeds, the return value is a handle to the newly created DIB, + /// and *ppvBits points to the bitmap bit values. If the function fails, the return value is NULL, and *ppvBits is NULL. + [DllImport("gdi32.dll")] + private static extern IntPtr CreateDIBSection( + IntPtr hdc, + [In] IntPtr pbmi, + uint iUsage, + out IntPtr ppvBits, + IntPtr hSection, + uint dwOffset); + + /// + /// Deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object. + /// After the object is deleted, the specified handle is no longer valid. + /// + /// Handle to a logical pen, brush, font, bitmap, region, or palette. + /// Returns true on success, false on failure. + [DllImport("gdi32.dll")] + private static extern bool DeleteObject(IntPtr hObject); + + /// + /// Creates a compatible bitmap (DDB) from a DIB and, optionally, sets the bitmap bits. + /// + /// Handle to a device context. + /// Pointer to a bitmap information header structure. + /// Specifies how the system initializes the bitmap bits - (use 4). + /// Pointer to an array of bytes containing the initial bitmap data. + /// Pointer to a BITMAPINFO structure that describes the dimensions + /// and color format of the array pointed to by the lpbInit parameter. + /// Specifies whether the bmiColors member of the BITMAPINFO structure + /// was initialized - (use 0). + /// Handle to a DIB or null on failure. + [DllImport("gdi32.dll")] + private static extern IntPtr CreateDIBitmap( + IntPtr hdc, + IntPtr lpbmih, + uint fdwInit, + IntPtr lpbInit, + IntPtr lpbmi, + uint fuUsage); + + /// + /// Retrieves information for the specified graphics object. + /// + /// Handle to the graphics object of interest. + /// Specifies the number of bytes of information to + /// be written to the buffer. + /// Pointer to a buffer that receives the information + /// about the specified graphics object. + /// 0 on failure. + [DllImport("gdi32.dll")] + private static extern int GetObject(IntPtr hgdiobj, int cbBuffer, IntPtr lpvObject); + + /// + /// Retrieves the bits of the specified compatible bitmap and copies them into a buffer + /// as a DIB using the specified format. + /// + /// Handle to the device context. + /// Handle to the bitmap. This must be a compatible bitmap (DDB). + /// Specifies the first scan line to retrieve. + /// Specifies the number of scan lines to retrieve. + /// Pointer to a buffer to receive the bitmap data. + /// Pointer to a BITMAPINFO structure that specifies the desired + /// format for the DIB data. + /// Specifies the format of the bmiColors member of the + /// BITMAPINFO structure - (use 0). + /// 0 on failure. + [DllImport("gdi32.dll")] + private static extern unsafe int GetDIBits( + IntPtr hdc, + IntPtr hbmp, + uint uStartScan, + uint cScanLines, + IntPtr lpvBits, + IntPtr lpbmi, + uint uUsage); + + /// + /// Moves a block of memory from one location to another. + /// + /// Pointer to the starting address of the move destination. + /// Pointer to the starting address of the block of memory to be moved. + /// Size of the block of memory to move, in bytes. + [DllImport("Kernel32.dll", EntryPoint = "RtlMoveMemory", SetLastError = false)] + public static unsafe extern void MoveMemory(void* dst, void* src, uint size); + + /// + /// The RtlCompareMemory routine compares blocks of memory + /// and returns the number of bytes that are equivalent. + /// + /// A pointer to a block of memory to compare. + /// A pointer to a block of memory to compare. + /// Specifies the number of bytes to be compared. + /// RtlCompareMemory returns the number of bytes that compare as equal. + /// If all bytes compare as equal, the input Length is returned. + [DllImport("ntdll.dll", EntryPoint = "RtlCompareMemory", SetLastError = false)] + internal static unsafe extern uint RtlCompareMemory(void* buf1, void* buf2, uint count); + + #endregion + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Library.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Library.2005.csproj new file mode 100644 index 0000000..1aa3345 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Library.2005.csproj @@ -0,0 +1,190 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + Properties + FreeImageAPI + FreeImageNET + + + OnOutputUpdated + + + true + full + false + bin\Debug\ + DEBUG + none + 4 + 4194304 + 512 + true + 419 + false + bin\Debug\FreeImageNET.XML + true + + + none + true + bin\Release\ + + + none + 4 + 512 + 4194304 + true + false + 419 + bin\Release\FreeImageNET.XML + + + true + bin\Debug\ + DEBUG + true + bin\Debug\FreeImageNET.XML + false + 512 + full + x86 + false + none + + + bin\Release\ + true + bin\Release\FreeImageNET.XML + true + 512 + + + x86 + false + none + + + true + bin\Debug\ + DEBUG + true + bin\Debug\FreeImageNET.XML + false + 512 + full + x64 + false + none + + + bin\Release\ + true + bin\Release\FreeImageNET.XML + true + 512 + + + x64 + false + none + + + + + + + + + + + + + + + + + Code + + + + + + Code + + + + Code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Library.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Library.csproj new file mode 100644 index 0000000..1d40089 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Library.csproj @@ -0,0 +1,231 @@ + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + Properties + FreeImageAPI + FreeImageNET + + + OnOutputUpdated + + + 2.0 + + + v3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + DEBUG + none + 4 + 4194304 + 512 + true + 419 + false + bin\Debug\FreeImageNET.XML + true + + + none + true + bin\Release\ + + + none + 4 + 512 + 4194304 + true + false + 419 + bin\Release\FreeImageNET.XML + + + true + bin\Debug\ + DEBUG + true + bin\Debug\FreeImageNET.XML + true + 512 + full + x86 + false + none + + + bin\Release\ + true + bin\Release\FreeImageNET.XML + true + 512 + + + x86 + false + none + + + true + bin\Debug\ + DEBUG + true + bin\Debug\FreeImageNET.XML + true + 512 + full + x64 + false + none + + + bin\Release\ + true + bin\Release\FreeImageNET.XML + true + 512 + + + x64 + false + none + + + + + 3.5 + + + + + + + + + + + + + + + Code + + + + + + Code + + + + Code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f6f8b84 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; +// +[assembly: AssemblyTitle("FreeImage.NET")] +[assembly: AssemblyDescription(".NET wrapper for the FreeImage 3.15.1 Library")] +[assembly: AssemblyConfiguration("All")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FreeImage.NET Wrapper")] +[assembly: AssemblyCopyright("Copyright 2003-2011, FreeImage, DataGis")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyVersion("3.15.1.0")] +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyFileVersionAttribute("3.15.1.0")] +[assembly: ComVisibleAttribute(false)] +[assembly: NeutralResourcesLanguageAttribute("")] +[assembly: GuidAttribute("64a4c935-b757-499c-ab8c-6110316a9e51")] +// \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/BITMAP.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/BITMAP.cs new file mode 100644 index 0000000..a4347c0 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/BITMAP.cs @@ -0,0 +1,104 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.2 $ +// $Date: 2008/06/16 15:15:36 $ +// $Id: BITMAP.cs,v 1.2 2008/06/16 15:15:36 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The BITMAP structure defines the type, width, height, color format, and bit values of a bitmap. + /// + /// + /// The bitmap formats currently used are monochrome and color. The monochrome bitmap uses a one-bit, + /// one-plane format. Each scan is a multiple of 32 bits. + /// + /// Scans are organized as follows for a monochrome bitmap of height n: + /// + /// + /// Scan 0 + /// Scan 1 + /// . + /// . + /// . + /// Scan n-2 + /// Scan n-1 + /// + /// + /// The pixels on a monochrome device are either black or white. If the corresponding bit in the + /// bitmap is 1, the pixel is set to the foreground color; if the corresponding bit in the bitmap + /// is zero, the pixel is set to the background color. + /// + /// All devices that have the RC_BITBLT device capability support bitmaps. For more information, + /// see GetDeviceCaps. + /// + /// Each device has a unique color format. To transfer a bitmap from one device to another, + /// use the GetDIBits and SetDIBits functions. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct BITMAP + { + /// + /// Specifies the bitmap type. This member must be zero. + /// + public int bmType; + /// + /// Specifies the width, in pixels, of the bitmap. The width must be greater than zero. + /// + public int bmWidth; + /// + /// Specifies the height, in pixels, of the bitmap. The height must be greater than zero. + /// + public int bmHeight; + /// + /// Specifies the number of bytes in each scan line. This value must be divisible by 2, + /// because the system assumes that the bit values of a bitmap form an array that is word aligned. + /// + public int bmWidthBytes; + /// + /// Specifies the count of color planes. + /// + public ushort bmPlanes; + /// + /// Specifies the number of bits required to indicate the color of a pixel. + /// + public ushort bmBitsPixel; + /// + /// Pointer to the location of the bit values for the bitmap. + /// The bmBits member must be a long pointer to an array of character (1-byte) values. + /// + public IntPtr bmBits; + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/BITMAPINFO.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/BITMAPINFO.cs new file mode 100644 index 0000000..5b0a9f0 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/BITMAPINFO.cs @@ -0,0 +1,203 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2008/06/16 15:16:07 $ +// $Id: BITMAPINFO.cs,v 1.3 2008/06/16 15:16:07 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The BITMAPINFO structure defines the dimensions and color information for a DIB. + /// + /// + /// A DIB consists of two distinct parts: a BITMAPINFO structure describing the dimensions + /// and colors of the bitmap, and an array of bytes defining the pixels of the bitmap. The bits in + /// the array are packed together, but each scan line must be padded with zeroes to end on a + /// LONG data-type boundary. If the height of the bitmap is positive, the bitmap is a + /// bottom-up DIB and its origin is the lower-left corner. If the height is negative, the bitmap is + /// a top-down DIB and its origin is the upper left corner. + /// + /// A bitmap is packed when the bitmap array immediately follows the BITMAPINFO header. + /// Packed bitmaps are referenced by a single pointer. For packed bitmaps, the biClrUsed + /// member must be set to an even number when using the DIB_PAL_COLORS mode so that the DIB bitmap + /// array starts on a DWORD boundary. + /// + /// Note The bmiColors member should not contain palette indexes if the bitmap is to + /// be stored in a file or transferred to another application. + /// + /// Unless the application has exclusive use and control of the bitmap, the bitmap color table + /// should contain explicit RGB values. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct BITMAPINFO : IEquatable + { + /// + /// Specifies a structure that contains information + /// about the dimensions of color format. + /// + public BITMAPINFOHEADER bmiHeader; + /// + /// The bmiColors member contains one of the following: + /// + /// + /// + /// + /// An array of . The elements of the array that make up the + /// color table. + /// + /// + /// + /// + /// + /// An array of 16-bit unsigned integers that specifies indexes into the currently realized + /// logical palette. This use of bmiColors is allowed for functions that use DIBs. + /// When bmiColors elements contain indexes to a realized logical palette, they must + /// also call the following bitmap functions: + /// + /// + /// + /// + /// CreateDIBitmap + /// + /// CreateDIBPatternBrush + /// + /// CreateDIBSection + /// + /// The iUsage parameter of CreateDIBSection must be set to DIB_PAL_COLORS. + /// + /// The number of entries in the array depends on the values of the biBitCount and + /// biClrUsed members of the structure. + /// + /// The colors in the bmiColors table appear in order of importance. For more information, + /// see the Remarks section. + /// + public RGBQUAD[] bmiColors; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(BITMAPINFO left, BITMAPINFO right) + { + if (left.bmiHeader != right.bmiHeader) + { + return false; + } + if ((left.bmiColors == null) && (right.bmiColors == null)) + { + return true; + } + if ((left.bmiColors == null) || (right.bmiColors == null)) + { + return false; + } + if (left.bmiColors.Length != right.bmiColors.Length) + { + return false; + } + for (int i = 0; i < left.bmiColors.Length; i++) + { + if (left.bmiColors[i] != right.bmiColors[i]) + { + return false; + } + } + return true; + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(BITMAPINFO left, BITMAPINFO right) + { + return !(left == right); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(BITMAPINFO other) + { + return (this == other); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is BITMAPINFO) && (this == ((BITMAPINFO)obj))); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + int hash = bmiHeader.GetHashCode(); + if (bmiColors != null) + { + for (int c = 0; c < bmiColors.Length; c++) + { + hash ^= bmiColors[c].GetHashCode(); + hash <<= 1; + } + hash <<= 1; + } + else + { + hash >>= 1; + } + return hash; + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/BITMAPINFOHEADER.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/BITMAPINFOHEADER.cs new file mode 100644 index 0000000..007870b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/BITMAPINFOHEADER.cs @@ -0,0 +1,352 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.4 $ +// $Date: 2008/06/16 15:17:37 $ +// $Id: BITMAPINFOHEADER.cs,v 1.4 2008/06/16 15:17:37 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// This structure contains information about the dimensions and color format + /// of a device-independent bitmap (DIB). + /// + /// + /// The structure combines the + /// BITMAPINFOHEADER structure and a color table to provide a complete + /// definition of the dimensions and colors of a DIB. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct BITMAPINFOHEADER : IEquatable + { + /// + /// Specifies the size of the structure, in bytes. + /// + public uint biSize; + /// + /// Specifies the width of the bitmap, in pixels. + /// + /// Windows 98/Me, Windows 2000/XP: If biCompression is BI_JPEG or BI_PNG, + /// the biWidth member specifies the width of the decompressed JPEG or PNG image file, + /// respectively. + /// + public int biWidth; + /// + /// Specifies the height of the bitmap, in pixels. If biHeight is positive, the bitmap + /// is a bottom-up DIB and its origin is the lower-left corner. If biHeight is negative, + /// the bitmap is a top-down DIB and its origin is the upper-left corner. + /// + /// If biHeight is negative, indicating a top-down DIB, biCompression must be + /// either BI_RGB or BI_BITFIELDS. Top-down DIBs cannot be compressed. + /// + /// Windows 98/Me, Windows 2000/XP: If biCompression is BI_JPEG or BI_PNG, + /// the biHeight member specifies the height of the decompressed JPEG or PNG image file, + /// respectively. + /// + public int biHeight; + /// + /// Specifies the number of planes for the target device. This value must be set to 1. + /// + public ushort biPlanes; + /// + /// Specifies the number of bits per pixel.The biBitCount member of the BITMAPINFOHEADER + /// structure determines the number of bits that define each pixel and the maximum number of + /// colors in the bitmap. This member must be one of the following values. + /// + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// + /// 0 + /// + /// Windows 98/Me, Windows 2000/XP: The number of bits-per-pixel is specified + /// or is implied by the JPEG or PNG format. + /// + /// + /// + /// + /// 1 + /// + /// The bitmap is monochrome, and the bmiColors member of + /// contains two entries. Each bit in the bitmap array represents a pixel. If the bit is clear, + /// the pixel is displayed with the color of the first entry in the bmiColors table; if the bit + /// is set, the pixel has the color of the second entry in the table. + /// + /// + /// + /// + /// 4 + /// + /// The bitmap has a maximum of 16 colors, and the bmiColors member of BITMAPINFO + /// contains up to 16 entries. Each pixel in the bitmap is represented by a 4-bit index into the + /// color table. For example, if the first byte in the bitmap is 0x1F, the byte represents two + /// pixels. The first pixel contains the color in the second table entry, and the second pixel + /// contains the color in the sixteenth table entry. + /// + /// + /// + /// 8 + /// + /// The bitmap has a maximum of 256 colors, and the bmiColors member of BITMAPINFO + /// contains up to 256 entries. In this case, each byte in the array represents a single pixel. + /// + /// + /// + /// + /// 16 + /// + /// The bitmap has a maximum of 2^16 colors. If the biCompression member of the + /// BITMAPINFOHEADER is BI_RGB, the bmiColors member of BITMAPINFO is NULL. + /// Each WORD in the bitmap array represents a single pixel. The relative intensities + /// of red, green, and blue are represented with five bits for each color component. + /// The value for blue is in the least significant five bits, followed by five bits each for + /// green and red. The most significant bit is not used. The bmiColors color table is used + /// for optimizing colors used on palette-based devices, and must contain the number of entries + /// specified by the biClrUsed member of the BITMAPINFOHEADER. + /// + /// If the biCompression member of the BITMAPINFOHEADER is BI_BITFIELDS, the + /// bmiColors member contains three DWORD color masks that specify the red, green, + /// and blue components, respectively, of each pixel. Each WORD in the bitmap array represents + /// a single pixel. + /// + /// Windows NT/Windows 2000/XP: When the biCompression member is BI_BITFIELDS, + /// bits set in each DWORD mask must be contiguous and should not overlap the bits + /// of another mask. All the bits in the pixel do not have to be used. + /// + /// Windows 95/98/Me: When the biCompression member is BI_BITFIELDS, the system + /// supports only the following 16bpp color masks: A 5-5-5 16-bit image, where the blue mask is + /// 0x001F, the green mask is 0x03E0, and the red mask is 0x7C00; and a 5-6-5 16-bit image, + /// where the blue mask is 0x001F, the green mask is 0x07E0, and the red mask is 0xF800. + /// + /// + /// + /// + /// 24 + /// + /// The bitmap has a maximum of 2^24 colors, and the bmiColors member of BITMAPINFO + /// is NULL. Each 3-byte triplet in the bitmap array represents the relative intensities of blue, + /// green, and red, respectively, for a pixel. The bmiColors color table is used for + /// optimizing colors used on palette-based devices, and must contain the number of entries + /// specified by the biClrUsed member of the BITMAPINFOHEADER. + /// + /// + /// + /// + /// 32 + /// + /// The bitmap has a maximum of 2^32 colors. If the biCompression member of the + /// BITMAPINFOHEADER is BI_RGB, the bmiColors member of BITMAPINFO is NULL. + /// Each DWORD in the bitmap array represents the relative intensities of blue, green, and red, + /// respectively, for a pixel. The high byte in each DWORD is not used. The bmiColors + /// color table is used for optimizing colors used on palette-based devices, and must contain the + /// number of entries specified by the biClrUsed member of the BITMAPINFOHEADER. + /// + /// If the biCompression member of the BITMAPINFOHEADER is BI_BITFIELDS, + /// the bmiColors member contains three DWORD color masks that specify the red, green, + /// and blue components, respectively, of each pixel. Each DWORD in the bitmap array represents + /// a single pixel. + /// + /// Windows NT/ 2000: When the biCompression member is BI_BITFIELDS, bits set in each + /// DWORD mask must be contiguous and should not overlap the bits of another mask. All the + /// bits in the pixel do not need to be used. + /// + /// Windows 95/98/Me: When the biCompression member is BI_BITFIELDS, the system + /// supports only the following 32-bpp color mask: The blue mask is 0x000000FF, the green mask is + /// 0x0000FF00, and the red mask is 0x00FF0000. + /// + /// + /// + /// + public ushort biBitCount; + /// + /// Specifies the type of compression for a compressed bottom-up bitmap (top-down DIBs cannot be + /// compressed). + /// + /// + /// Value + /// Meaning + /// + /// + /// + /// BI_RGB + /// An uncompressed format. + /// + /// + /// + /// BI_RLE8 + /// A run-length encoded (RLE) format for bitmaps with 8 bpp. The compression format + /// is a 2-byte format consisting of a count byte followed by a byte containing a color index. + /// + /// + /// + /// + /// BI_RLE4 + /// An RLE format for bitmaps with 4 bpp. The compression format is a 2-byte format + /// consisting of a count byte followed by two word-length color indexes. + /// + /// + /// + /// BI_BITFIELDS + /// Specifies that the bitmap is not compressed and that the color table consists + /// of three DWORD color masks that specify the red, green, and blue components, respectively, + /// of each pixel. This is valid when used with 16- and 32-bpp bitmaps. + /// + /// + /// + /// BI_JPEG + /// Windows 98/Me, Windows 2000/XP: Indicates that the image is a JPEG image. + /// + /// + /// + /// + /// BI_PNG + /// Windows 98/Me, Windows 2000/XP: Indicates that the image is a PNG image. + /// + /// + /// + /// + /// + public uint biCompression; + /// + /// Specifies the size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps. + /// + /// Windows 98/Me, Windows 2000/XP: If biCompression is BI_JPEG or BI_PNG, + /// biSizeImage indicates the size of the JPEG or PNG image buffer, respectively. + /// + public uint biSizeImage; + /// + /// Specifies the horizontal resolution, in pixels-per-meter, of the target device for the bitmap. + /// An application can use this value to select a bitmap from a resource group that best matches + /// the characteristics of the current device. + /// + public int biXPelsPerMeter; + /// + /// Specifies the vertical resolution, in pixels-per-meter, of the target device for the bitmap. + /// + public int biYPelsPerMeter; + /// + /// Specifies the number of color indexes in the color table that are actually used by the bitmap. + /// If this value is zero, the bitmap uses the maximum number of colors corresponding to the value + /// of the biBitCount member for the compression mode specified by biCompression. + /// + /// If iClrUsed is nonzero and the biBitCount member is less than 16, the biClrUsed + /// member specifies the actual number of colors the graphics engine or device driver accesses. + /// If biBitCount is 16 or greater, the biClrUsed member specifies the size of the color + /// table used to optimize performance of the system color palettes. If biBitCount equals 16 or 32, + /// the optimal color palette starts immediately following the three DWORD masks. + /// + /// When the bitmap array immediately follows the structure, it is a packed bitmap. + /// Packed bitmaps are referenced by a single pointer. Packed bitmaps require that the + /// biClrUsed member must be either zero or the actual size of the color table. + /// + public uint biClrUsed; + /// + /// Specifies the number of color indexes that are required for displaying the bitmap. If this value + /// is zero, all colors are required. + /// + public uint biClrImportant; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(BITMAPINFOHEADER left, BITMAPINFOHEADER right) + { + return ((left.biSize == right.biSize) && + (left.biWidth == right.biWidth) && + (left.biHeight == right.biHeight) && + (left.biPlanes == right.biPlanes) && + (left.biBitCount == right.biBitCount) && + (left.biCompression == right.biCompression) && + (left.biSizeImage == right.biSizeImage) && + (left.biXPelsPerMeter == right.biXPelsPerMeter) && + (left.biYPelsPerMeter == right.biYPelsPerMeter) && + (left.biClrUsed == right.biClrUsed) && + (left.biClrImportant == right.biClrImportant)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(BITMAPINFOHEADER left, BITMAPINFOHEADER right) + { + return !(left == right); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(BITMAPINFOHEADER other) + { + return (this == other); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is BITMAPINFOHEADER) && (this == (BITMAPINFOHEADER)obj)); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI16RGB555.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI16RGB555.cs new file mode 100644 index 0000000..83adb5a --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI16RGB555.cs @@ -0,0 +1,277 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FI16RGB555.cs,v 1.3 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FI16RGB555 structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 5 bits and so, takes values in the range from 0 to 31. + /// + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FI16RGB555 structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FI16RGB555 structure and my be used in all situations which require + /// an FI16RGB555 type. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FI16RGB555 structure and the structure. + /// + /// FI16RGB555 fi16rgb; + /// // Initialize the structure using a native .NET Color structure. + /// fi16rgb = new FI16RGB555(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// fi16rgb = Color.DarkSeaGreen; + /// // Convert the FI16RGB555 instance into a native .NET Color + /// // using its implicit operator. + /// Color color = fi16rgb; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = fi16rgb.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FI16RGB555 : IComparable, IComparable, IEquatable + { + /// + /// The value of the color. + /// + private ushort value; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FI16RGB555(Color color) + { + value = (ushort)( + (((color.R * 31) / 255) << FreeImage.FI16_555_RED_SHIFT) + + (((color.G * 31) / 255) << FreeImage.FI16_555_GREEN_SHIFT) + + (((color.B * 31) / 255) << FreeImage.FI16_555_BLUE_SHIFT)); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FI16RGB555 left, FI16RGB555 right) + { + return (left.value == right.value); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FI16RGB555 left, FI16RGB555 right) + { + return (!(left == right)); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FI16RGB555(Color value) + { + return new FI16RGB555(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FI16RGB555 value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + ((value & FreeImage.FI16_555_RED_MASK) >> FreeImage.FI16_555_RED_SHIFT) * 255 / 31, + ((value & FreeImage.FI16_555_GREEN_MASK) >> FreeImage.FI16_555_GREEN_SHIFT) * 255 / 31, + ((value & FreeImage.FI16_555_BLUE_MASK) >> FreeImage.FI16_555_BLUE_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)( + (((value.R * 31) / 255) << FreeImage.FI16_555_RED_SHIFT) + + (((value.G * 31) / 255) << FreeImage.FI16_555_GREEN_SHIFT) + + (((value.B * 31) / 255) << FreeImage.FI16_555_BLUE_SHIFT)); + } + } + + /// + /// Gets or sets the red color component. + /// + public byte Red + { + get + { + return (byte)(((value & FreeImage.FI16_555_RED_MASK) >> FreeImage.FI16_555_RED_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_555_RED_MASK)) | (((value * 31) / 255) << FreeImage.FI16_555_RED_SHIFT)); + } + } + + /// + /// Gets or sets the green color component. + /// + public byte Green + { + get + { + return (byte)(((value & FreeImage.FI16_555_GREEN_MASK) >> FreeImage.FI16_555_GREEN_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_555_GREEN_MASK)) | (((value * 31) / 255) << FreeImage.FI16_555_GREEN_SHIFT)); + } + } + + /// + /// Gets or sets the blue color component. + /// + public byte Blue + { + get + { + return (byte)(((value & FreeImage.FI16_555_BLUE_MASK) >> FreeImage.FI16_555_BLUE_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_555_BLUE_MASK)) | (((value * 31) / 255) << FreeImage.FI16_555_BLUE_SHIFT)); + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FI16RGB555)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FI16RGB555)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FI16RGB555 other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return base.Equals(obj); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FI16RGB555 other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI16RGB565.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI16RGB565.cs new file mode 100644 index 0000000..26e59c3 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI16RGB565.cs @@ -0,0 +1,277 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FI16RGB565.cs,v 1.3 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FI16RGB565 structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 5 bits and so, takes values in the range from 0 to 31. + /// + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FI16RGB565 structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FI16RGB565 structure and my be used in all situations which require + /// an FI16RGB565 type. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FI16RGB565 structure and the structure. + /// + /// FI16RGB565 fi16rgb; + /// // Initialize the structure using a native .NET Color structure. + /// fi16rgb = new FI16RGB565(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// fi16rgb = Color.DarkSeaGreen; + /// // Convert the FI16RGB565 instance into a native .NET Color + /// // using its implicit operator. + /// Color color = fi16rgb; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = fi16rgb.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FI16RGB565 : IComparable, IComparable, IEquatable + { + /// + /// The value of the color. + /// + private ushort value; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FI16RGB565(Color color) + { + value = (ushort)( + (((color.R * 31) / 255) << FreeImage.FI16_565_RED_SHIFT) + + (((color.G * 63) / 255) << FreeImage.FI16_565_GREEN_SHIFT) + + (((color.B * 31) / 255) << FreeImage.FI16_565_BLUE_SHIFT)); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FI16RGB565 left, FI16RGB565 right) + { + return (left.value == right.value); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FI16RGB565 left, FI16RGB565 right) + { + return (!(left == right)); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FI16RGB565(Color value) + { + return new FI16RGB565(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FI16RGB565 value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + ((value & FreeImage.FI16_565_RED_MASK) >> FreeImage.FI16_565_RED_SHIFT) * 255 / 31, + ((value & FreeImage.FI16_565_GREEN_MASK) >> FreeImage.FI16_565_GREEN_SHIFT) * 255 / 63, + ((value & FreeImage.FI16_565_BLUE_MASK) >> FreeImage.FI16_565_BLUE_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)( + (((value.R * 31) / 255) << FreeImage.FI16_565_RED_SHIFT) + + (((value.G * 63) / 255) << FreeImage.FI16_565_GREEN_SHIFT) + + (((value.B * 31) / 255) << FreeImage.FI16_565_BLUE_SHIFT)); + } + } + + /// + /// Gets or sets the red color component. + /// + public byte Red + { + get + { + return (byte)(((value & FreeImage.FI16_565_RED_MASK) >> FreeImage.FI16_565_RED_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_565_RED_MASK)) | (((value * 31) / 255) << FreeImage.FI16_565_RED_SHIFT)); + } + } + + /// + /// Gets or sets the green color component. + /// + public byte Green + { + get + { + return (byte)(((value & FreeImage.FI16_565_GREEN_MASK) >> FreeImage.FI16_565_GREEN_SHIFT) * 255 / 63); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_565_GREEN_MASK)) | (((value * 63) / 255) << FreeImage.FI16_565_GREEN_SHIFT)); + } + } + + /// + /// Gets or sets the blue color component. + /// + public byte Blue + { + get + { + return (byte)(((value & FreeImage.FI16_565_BLUE_MASK) >> FreeImage.FI16_565_BLUE_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_565_BLUE_MASK)) | (((value * 31) / 255) << FreeImage.FI16_565_BLUE_SHIFT)); + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FI16RGB565)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FI16RGB565)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FI16RGB565 other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return base.Equals(obj); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FI16RGB565 other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI1BIT.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI1BIT.cs new file mode 100644 index 0000000..5712466 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI1BIT.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Diagnostics; + +namespace FreeImageAPI +{ + /// + /// The FI1BIT structure represents a single bit. + /// It's value can be 0 or 1. + /// + [DebuggerDisplay("{value}"), + Serializable] + public struct FI1BIT + { + /// + /// Represents the largest possible value of . This field is constant. + /// + public const byte MaxValue = 0x01; + + /// + /// Represents the smallest possible value of . This field is constant. + /// + public const byte MinValue = 0x00; + + /// + /// The value of the structure. + /// + private byte value; + + /// + /// Initializes a new instance based on the specified value. + /// + /// The value to initialize with. + private FI1BIT(byte value) + { + this.value = (byte)(value & MaxValue); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator byte(FI1BIT value) + { + return value.value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FI1BIT(byte value) + { + return new FI1BIT(value); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return value.ToString(); + } + } +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI4BIT.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI4BIT.cs new file mode 100644 index 0000000..a047a80 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FI4BIT.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Diagnostics; + +namespace FreeImageAPI +{ + /// + /// The FI4BIT structure represents the half of a . + /// It's valuerange is between 0 and 15. + /// + [DebuggerDisplay("{value}"), + Serializable] + public struct FI4BIT + { + /// + /// Represents the largest possible value of . This field is constant. + /// + public const byte MaxValue = 0x0F; + + /// + /// Represents the smallest possible value of . This field is constant. + /// + public const byte MinValue = 0x00; + + /// + /// The value of the structure. + /// + private byte value; + + /// + /// Initializes a new instance based on the specified value. + /// + /// The value to initialize with. + private FI4BIT(byte value) + { + this.value = (byte)(value & MaxValue); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator byte(FI4BIT value) + { + return value.value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FI4BIT(byte value) + { + return new FI4BIT(value); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return value.ToString(); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIBITMAP.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIBITMAP.cs new file mode 100644 index 0000000..4403817 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIBITMAP.cs @@ -0,0 +1,175 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.5 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FIBITMAP.cs,v 1.5 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FIBITMAP structure is a handle to a FreeImage bimtap. + /// + /// + /// The handle represented by a FIBITBAP structure provides + /// access to either a singlepage bitmap or exactly one page of + /// a multipage bitmap. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIBITMAP : IComparable, IComparable, IEquatable + { + private IntPtr data; + + /// + /// A read-only field that represents a handle that has been initialized to zero. + /// + public static readonly FIBITMAP Zero; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIBITMAP left, FIBITMAP right) + { + return (left.data == right.data); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIBITMAP left, FIBITMAP right) + { + return (left.data != right.data); + } + + /// + /// Gets whether the handle is a null or not. + /// + /// true if this handle is a null; + /// otherwise, false. + public bool IsNull + { + get + { + return (data == IntPtr.Zero); + } + } + + /// + /// Sets the handle to null. + /// + public void SetNull() + { + data = IntPtr.Zero; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return data.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return data.GetHashCode(); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIBITMAP) && (this == ((FIBITMAP)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// true if the current object is equal to the other parameter; otherwise, false. + public bool Equals(FIBITMAP other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIBITMAP)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIBITMAP)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIBITMAP other) + { + return this.data.ToInt64().CompareTo(other.data.ToInt64()); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FICOMPLEX.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FICOMPLEX.cs new file mode 100644 index 0000000..c3ea716 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FICOMPLEX.cs @@ -0,0 +1,146 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.4 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FICOMPLEX.cs,v 1.4 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FICOMPLEX structure describes a color consisting of a real and an imaginary part. + /// Each part is using 4 bytes of data. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FICOMPLEX : IComparable, IComparable, IEquatable + { + /// + /// Real part of the color. + /// + public double real; + + /// + /// Imaginary part of the color. + /// + public double imag; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FICOMPLEX left, FICOMPLEX right) + { + return ((left.real == right.real) && (left.imag == right.imag)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FICOMPLEX left, FICOMPLEX right) + { + return ((left.real != right.real) || (left.imag == right.imag)); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FICOMPLEX)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FICOMPLEX)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FICOMPLEX other) + { + return base.GetHashCode(); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FICOMPLEX) && (this == ((FICOMPLEX)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FICOMPLEX other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIICCPROFILE.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIICCPROFILE.cs new file mode 100644 index 0000000..04f6b64 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIICCPROFILE.cs @@ -0,0 +1,133 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.5 $ +// $Date: 2008/11/05 13:19:06 $ +// $Id: FIICCPROFILE.cs,v 1.5 2008/11/05 13:19:06 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// This Structure contains ICC-Profile data. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIICCPROFILE + { + private ICC_FLAGS flags; + private uint size; + private IntPtr data; + + /// + /// Creates a new ICC-Profile for . + /// + /// Handle to a FreeImage bitmap. + /// The ICC-Profile data. + /// + /// is null. + public FIICCPROFILE(FIBITMAP dib, byte[] data) + : this(dib, data, (int)data.Length) + { + } + + /// + /// Creates a new ICC-Profile for . + /// + /// Handle to a FreeImage bitmap. + /// The ICC-Profile data. + /// Number of bytes to use from data. + /// + /// is null. + public unsafe FIICCPROFILE(FIBITMAP dib, byte[] data, int size) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + FIICCPROFILE prof; + size = Math.Min(size, (int)data.Length); + prof = *(FIICCPROFILE*)FreeImage.CreateICCProfile(dib, data, size); + this.flags = prof.flags; + this.size = prof.size; + this.data = prof.data; + } + + /// + /// Info flag of the profile. + /// + public ICC_FLAGS Flags + { + get { return flags; } + } + + /// + /// Profile's size measured in bytes. + /// + public uint Size + { + get { return size; } + } + + /// + /// Points to a block of contiguous memory containing the profile. + /// + public IntPtr DataPointer + { + get { return data; } + } + + /// + /// Copy of the ICC-Profiles data. + /// + public unsafe byte[] Data + { + get + { + byte[] result; + FreeImage.CopyMemory(result = new byte[size], data.ToPointer(), size); + return result; + } + } + + /// + /// Indicates whether the profile is CMYK. + /// + public bool IsCMYK + { + get + { + return ((flags & ICC_FLAGS.FIICC_COLOR_IS_CMYK) != 0); + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIMEMORY.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIMEMORY.cs new file mode 100644 index 0000000..e190975 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIMEMORY.cs @@ -0,0 +1,170 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.5 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FIMEMORY.cs,v 1.5 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FIMEMORY structure is a handle to an opened memory stream. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIMEMORY : IComparable, IComparable, IEquatable + { + private IntPtr data; + + /// + /// A read-only field that represents a handle that has been initialized to zero. + /// + public static readonly FIMEMORY Zero; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIMEMORY left, FIMEMORY right) + { + return (left.data == right.data); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIMEMORY left, FIMEMORY right) + { + return (left.data != right.data); + } + + /// + /// Gets whether the pointer is a null pointer or not. + /// + /// true if this is a null pointer; + /// otherwise, false. + public bool IsNull + { + get + { + return (data == IntPtr.Zero); + } + } + + /// + /// Sets the handle to null. + /// + public void SetNull() + { + data = IntPtr.Zero; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return data.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return data.GetHashCode(); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIMEMORY) && (this == ((FIMEMORY)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// true if the current object is equal to the other parameter; otherwise, false. + public bool Equals(FIMEMORY other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIMEMORY)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIMEMORY)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIMEMORY other) + { + return this.data.ToInt64().CompareTo(other.data.ToInt64()); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIMETADATA.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIMETADATA.cs new file mode 100644 index 0000000..0fee77e --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIMETADATA.cs @@ -0,0 +1,178 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.5 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FIMETADATA.cs,v 1.5 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FIMETADATA structure is an unique search handle for metadata search operations. + /// + /// + /// The FIMETADATA structure is usually returned by the + /// + /// function and then used on subsequent calls to + /// . + /// When the FIMETADATA handle is no longer used, it needs to be freed by the + /// function. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIMETADATA : IComparable, IComparable, IEquatable + { + private IntPtr data; + + /// + /// A read-only field that represents a handle that has been initialized to zero. + /// + public static readonly FIMETADATA Zero; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIMETADATA left, FIMETADATA right) + { + return (left.data == right.data); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIMETADATA left, FIMETADATA right) + { + return (left.data != right.data); + } + + /// + /// Gets whether the pointer is a null pointer or not. + /// + /// true if this is a null pointer; + /// otherwise, false. + public bool IsNull + { + get + { + return (data == IntPtr.Zero); + } + } + + /// + /// Sets the handle to null. + /// + public void SetNull() + { + data = IntPtr.Zero; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return data.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return data.GetHashCode(); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIMETADATA) && (this == ((FIMETADATA)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// true if the current object is equal to the other parameter; otherwise, false. + public bool Equals(FIMETADATA other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIMETADATA)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIMETADATA)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIMETADATA other) + { + return this.data.ToInt64().CompareTo(other.data.ToInt64()); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIMULTIBITMAP.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIMULTIBITMAP.cs new file mode 100644 index 0000000..931b911 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIMULTIBITMAP.cs @@ -0,0 +1,170 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.5 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FIMULTIBITMAP.cs,v 1.5 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FIMULTIBITMAP structure is a handle to a FreeImage multipaged bimtap. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIMULTIBITMAP : IComparable, IComparable, IEquatable + { + private IntPtr data; + + /// + /// A read-only field that represents a handle that has been initialized to zero. + /// + public static readonly FIMULTIBITMAP Zero; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIMULTIBITMAP left, FIMULTIBITMAP right) + { + return (left.data == right.data); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIMULTIBITMAP left, FIMULTIBITMAP right) + { + return (left.data != right.data); + } + + /// + /// Gets whether the handle is a null or not. + /// + /// true if this handle is a null; + /// otherwise, false. + public bool IsNull + { + get + { + return (data == IntPtr.Zero); + } + } + + /// + /// Sets the handle to null. + /// + public void SetNull() + { + data = IntPtr.Zero; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return data.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return data.GetHashCode(); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIMULTIBITMAP) && (this == ((FIMULTIBITMAP)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// true if the current object is equal to the other parameter; otherwise, false. + public bool Equals(FIMULTIBITMAP other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIMULTIBITMAP)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIMULTIBITMAP)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIMULTIBITMAP other) + { + return this.data.ToInt64().CompareTo(other.data.ToInt64()); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGB16.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGB16.cs new file mode 100644 index 0000000..fbdf816 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGB16.cs @@ -0,0 +1,267 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FIRGB16.cs,v 1.3 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FIRGB16 structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 16 bits and so, takes values in the range from 0 to 65535. + /// + /// + /// + /// The FIRGB16 structure provides access to an underlying FreeImage FIRGB16 + /// structure. To determine the red, green or blue component of a color, + /// use the red, green or blue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FIRGB16 structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FIRGB16 structure and my be used in all situations which require + /// an FIRGB16 type. + /// + /// + /// Each color component red, green or blue of FIRGB16 is translated into + /// it's corresponding color component R, G or B of + /// by right shifting 8 bits and shifting left 8 bits for the reverse conversion. + /// When converting from into FIRGB16, the + /// color's alpha value is ignored and assumed to be 255 when converting from + /// FIRGB16 into , creating a fully + /// opaque color. + /// + /// + /// Conversion from System.Drawing.Color to FIRGB16 + /// + /// FIRGB16.component = Color.component << 8 + /// + /// Conversion from FIRGB16 to System.Drawing.Color + /// + /// Color.component = FIRGB16.component >> 8 + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FIRGB16 structure and the structure. + /// + /// FIRGB16 firgb16; + /// // Initialize the structure using a native .NET Color structure. + /// firgb16 = new FIRGBA16(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// firgb16 = Color.DarkSeaGreen; + /// // Convert the FIRGB16 instance into a native .NET Color + /// // using its implicit operator. + /// Color color = firgb16; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = firgb16.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIRGB16 : IComparable, IComparable, IEquatable + { + /// + /// The red color component. + /// + public ushort red; + + /// + /// The green color component. + /// + public ushort green; + + /// + /// The blue color component. + /// + public ushort blue; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FIRGB16(Color color) + { + red = (ushort)(color.R << 8); + green = (ushort)(color.G << 8); + blue = (ushort)(color.B << 8); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIRGB16 left, FIRGB16 right) + { + return + ((left.blue == right.blue) && + (left.green == right.green) && + (left.red == right.red)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIRGB16 left, FIRGB16 right) + { + return !(left == right); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRGB16(Color value) + { + return new FIRGB16(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FIRGB16 value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb((red >> 8), (green >> 8), (blue >> 8)); + } + set + { + red = (ushort)(value.R << 8); + green = (ushort)(value.G << 8); + blue = (ushort)(value.B << 8); + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIRGB16)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIRGB16)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIRGB16 other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIRGB16) && (this == ((FIRGB16)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIRGB16 other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGBA16.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGBA16.cs new file mode 100644 index 0000000..d63698d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGBA16.cs @@ -0,0 +1,271 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FIRGBA16.cs,v 1.3 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FIRGBA16 structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 16 bits and so, takes values in the range from 0 to 65535. + /// + /// + /// + /// The FIRGBA16 structure provides access to an underlying FreeImage FIRGBA16 + /// structure. To determine the alpha, red, green or blue component of a color, + /// use the alpha, red, green or blue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FIRGBA16 structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FIRGBA16 structure and my be used in all situations which require + /// an FIRGBA16 type. + /// + /// + /// Each color component alpha, red, green or blue of FIRGBA16 + /// is translated into it's corresponding color component A, R, G or B of + /// by an 8 bit right shift and vice versa. + /// + /// + /// Conversion from System.Drawing.Color to FIRGBA16 + /// + /// FIRGBA16.component = Color.component << 8 + /// + /// Conversion from FIRGBA16 to System.Drawing.Color + /// + /// Color.component = FIRGBA16.component >> 8 + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FIRGBA16 structure and the structure. + /// + /// FIRGBA16 firgba16; + /// // Initialize the structure using a native .NET Color structure. + /// firgba16 = new FIRGBA16(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// firgba16 = Color.DarkSeaGreen; + /// // Convert the FIRGBA16 instance into a native .NET Color + /// // using its implicit operator. + /// Color color = firgba16; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = firgba16.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIRGBA16 : IComparable, IComparable, IEquatable + { + /// + /// The red color component. + /// + public ushort red; + + /// + /// The green color component. + /// + public ushort green; + + /// + /// The blue color component. + /// + public ushort blue; + + /// + /// The alpha color component. + /// + public ushort alpha; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FIRGBA16(Color color) + { + red = (ushort)(color.R << 8); + green = (ushort)(color.G << 8); + blue = (ushort)(color.B << 8); + alpha = (ushort)(color.A << 8); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIRGBA16 left, FIRGBA16 right) + { + return + ((left.alpha == right.alpha) && + (left.blue == right.blue) && + (left.green == right.green) && + (left.red == right.red)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIRGBA16 left, FIRGBA16 right) + { + return !(left == right); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRGBA16(Color value) + { + return new FIRGBA16(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FIRGBA16 value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb((alpha >> 8), (red >> 8), (green >> 8), (blue >> 8)); + } + set + { + red = (ushort)(value.R << 8); + green = (ushort)(value.G << 8); + blue = (ushort)(value.B << 8); + alpha = (ushort)(value.A << 8); + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIRGBA16)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIRGBA16)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIRGBA16 other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIRGBA16) && (this == ((FIRGBA16)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIRGBA16 other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGBAF.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGBAF.cs new file mode 100644 index 0000000..aa515a0 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGBAF.cs @@ -0,0 +1,276 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FIRGBAF.cs,v 1.3 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FIRGBAF structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 32 bits and takes values in the range from 0 to 1. + /// + /// + /// + /// The FIRGBAF structure provides access to an underlying FreeImage FIRGBAF + /// structure. To determine the alpha, red, green or blue component of a color, + /// use the alpha, red, green or blue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FIRGBAF structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FIRGBAF structure and my be used in all situations which require + /// an FIRGBAF type. + /// + /// + /// Each color component alpha, red, green or blue of FIRGBAF is translated + /// into it's corresponding color component A, R, G or B of + /// by linearly mapping the values of one range + /// into the other range and vice versa. + /// + /// + /// Conversion from System.Drawing.Color to FIRGBAF + /// + /// FIRGBAF.component = (float)Color.component / 255f + /// + /// Conversion from FIRGBAF to System.Drawing.Color + /// + /// Color.component = (int)(FIRGBAF.component * 255f) + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FIRGBAF structure and the structure. + /// + /// FIRGBAF firgbaf; + /// // Initialize the structure using a native .NET Color structure. + /// firgbaf = new FIRGBAF(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// firgbaf = Color.DarkSeaGreen; + /// // Convert the FIRGBAF instance into a native .NET Color + /// // using its implicit operator. + /// Color color = firgbaf; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = firgbaf.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIRGBAF : IComparable, IComparable, IEquatable + { + /// + /// The red color component. + /// + public float red; + + /// + /// The green color component. + /// + public float green; + + /// + /// The blue color component. + /// + public float blue; + + /// + /// The alpha color component. + /// + public float alpha; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FIRGBAF(Color color) + { + red = (float)color.R / 255f; + green = (float)color.G / 255f; + blue = (float)color.B / 255f; + alpha = (float)color.A / 255f; + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIRGBAF left, FIRGBAF right) + { + return + ((left.alpha == right.alpha) && + (left.blue == right.blue) && + (left.green == right.green) && + (left.red == right.red)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIRGBAF left, FIRGBAF right) + { + return !(left == right); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRGBAF(Color value) + { + return new FIRGBAF(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FIRGBAF value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + (int)(alpha * 255f), + (int)(red * 255f), + (int)(green * 255f), + (int)(blue * 255f)); + } + set + { + red = (float)value.R / 255f; + green = (float)value.G / 255f; + blue = (float)value.B / 255f; + alpha = (float)value.A / 255f; + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIRGBAF)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIRGBAF)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIRGBAF other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIRGBAF) && (this == ((FIRGBAF)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIRGBAF other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGBF.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGBF.cs new file mode 100644 index 0000000..0fce242 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRGBF.cs @@ -0,0 +1,272 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FIRGBF.cs,v 1.3 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FIRGBF structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 32 bits and takes values in the range from 0 to 1. + /// + /// + /// + /// The FIRGBF structure provides access to an underlying FreeImage FIRGBF + /// structure. To determine the red, green or blue component of a color, use the + /// red, green or blue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FIRGBF structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FIRGBF structure and my be used in all situations which require + /// an FIRGBF type. + /// + /// + /// Each color component alpha, red, green or blue of FIRGBF is translated + /// into it's corresponding color component A, R, G or B of + /// by linearly mapping the values of one range + /// into the other range and vice versa. + /// When converting from into FIRGBF, the + /// color's alpha value is ignored and assumed to be 255 when converting from + /// FIRGBF into , creating a fully + /// opaque color. + /// + /// + /// Conversion from System.Drawing.Color to FIRGBF + /// + /// FIRGBF.component = (float)Color.component / 255f + /// + /// Conversion from FIRGBF to System.Drawing.Color + /// + /// Color.component = (int)(FIRGBF.component * 255f) + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FIRGBF structure and the structure. + /// + /// FIRGBF firgbf; + /// // Initialize the structure using a native .NET Color structure. + /// firgbf = new FIRGBF(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// firgbf = Color.DarkSeaGreen; + /// // Convert the FIRGBF instance into a native .NET Color + /// // using its implicit operator. + /// Color color = firgbf; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = firgbf.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIRGBF : IComparable, IComparable, IEquatable + { + /// + /// The red color component. + /// + public float red; + + /// + /// The green color component. + /// + public float green; + + /// + /// The blue color component. + /// + public float blue; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FIRGBF(Color color) + { + red = (float)color.R / 255f; + green = (float)color.G / 255f; + blue = (float)color.B / 255f; + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIRGBF left, FIRGBF right) + { + return + ((left.blue == right.blue) && + (left.green == right.green) && + (left.red == right.red)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIRGBF left, FIRGBF right) + { + return !(left == right); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRGBF(Color value) + { + return new FIRGBF(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FIRGBF value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + (int)(red * 255f), + (int)(green * 255f), + (int)(blue * 255f)); + } + set + { + red = (float)value.R / 255f; + green = (float)value.G / 255f; + blue = (float)value.B / 255f; + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIRGBF)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIRGBF)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIRGBF other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIRGBF) && (this == ((FIRGBF)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIRGBF other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRational.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRational.cs new file mode 100644 index 0000000..4788a0b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIRational.cs @@ -0,0 +1,1011 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.5 $ +// $Date: 2009/02/27 16:36:23 $ +// $Id: FIRational.cs,v 1.5 2009/02/27 16:36:23 cklein05 Exp $ +// ========================================================== + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace FreeImageAPI +{ + /// + /// The FIRational structure represents a fraction via two + /// instances which are interpreted as numerator and denominator. + /// + /// + /// The structure tries to approximate the value of + /// when creating a new instance by using a better algorithm than FreeImage does. + /// + /// The structure implements the following operators: + /// +, -, ++, --, ==, != , >, >==, <, <== and ~ (which switches nominator and denomiator). + /// + /// The structure can be converted into all .NET standard types either implicit or + /// explicit. + /// + [Serializable, StructLayout(LayoutKind.Sequential), ComVisible(true)] + public struct FIRational : IConvertible, IComparable, IFormattable, IComparable, IEquatable + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private int numerator; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private int denominator; + + /// + /// Represents the largest possible value of . This field is constant. + /// + public static readonly FIRational MaxValue = new FIRational(Int32.MaxValue, 1); + + /// + /// Represents the smallest possible value of . This field is constant. + /// + public static readonly FIRational MinValue = new FIRational(Int32.MinValue, 1); + + /// + /// Represents the smallest positive value greater than zero. This field is constant. + /// + public static readonly FIRational Epsilon = new FIRational(1, Int32.MaxValue); + + /// + /// Initializes a new instance based on the specified parameters. + /// + /// The numerator. + /// The denominator. + public FIRational(int n, int d) + { + numerator = n; + denominator = d; + Normalize(); + } + + /// + /// Initializes a new instance based on the specified parameters. + /// + /// The tag to read the data from. + public unsafe FIRational(FITAG tag) + { + switch (FreeImage.GetTagType(tag)) + { + case FREE_IMAGE_MDTYPE.FIDT_SRATIONAL: + int* value = (int*)FreeImage.GetTagValue(tag); + numerator = (int)value[0]; + denominator = (int)value[1]; + Normalize(); + return; + default: + throw new ArgumentException("tag"); + } + } + + /// + /// Initializes a new instance based on the specified parameters. + /// + /// The value to convert into a fraction. + /// + /// cannot be converted into a fraction + /// represented by two integer values. + public FIRational(decimal value) + { + try + { + int sign = value < 0 ? -1 : 1; + value = Math.Abs(value); + try + { + int[] contFract = CreateContinuedFraction(value); + CreateFraction(contFract, out numerator, out denominator); + Normalize(); + } + catch + { + numerator = 0; + denominator = 1; + } + if (Math.Abs(((decimal)numerator / (decimal)denominator) - value) > 0.0001m) + { + int maxDen = (Int32.MaxValue / (int)value) - 2; + maxDen = maxDen < 10000 ? maxDen : 10000; + ApproximateFraction(value, maxDen, out numerator, out denominator); + Normalize(); + if (Math.Abs(((decimal)numerator / (decimal)denominator) - value) > 0.0001m) + { + throw new OverflowException("Unable to convert value into a fraction"); + } + } + numerator *= sign; + Normalize(); + } + catch (Exception ex) + { + throw new OverflowException("Unable to calculate fraction.", ex); + } + } + + /// + /// The numerator of the fraction. + /// + public int Numerator + { + get { return numerator; } + } + + /// + /// The denominator of the fraction. + /// + public int Denominator + { + get { return denominator; } + } + + /// + /// Returns the truncated value of the fraction. + /// + /// + public int Truncate() + { + return denominator > 0 ? (int)(numerator / denominator) : 0; + } + + /// + /// Returns whether the fraction is representing an integer value. + /// + public bool IsInteger + { + get + { + return (denominator == 1 || + (denominator != 0 && (numerator % denominator == 0)) || + (denominator == 0 && numerator == 0)); + } + } + + /// + /// Calculated the greatest common divisor of 'a' and 'b'. + /// + private static long Gcd(long a, long b) + { + a = Math.Abs(a); + b = Math.Abs(b); + long r; + while (b > 0) + { + r = a % b; + a = b; + b = r; + } + return a; + } + + /// + /// Calculated the smallest common multiple of 'a' and 'b'. + /// + private static long Scm(int n, int m) + { + return Math.Abs((long)n * (long)m) / Gcd(n, m); + } + + /// + /// Normalizes the fraction. + /// + private void Normalize() + { + if (denominator == 0) + { + numerator = 0; + denominator = 1; + return; + } + + if (numerator != 1 && denominator != 1) + { + int common = (int)Gcd(numerator, denominator); + if (common != 1 && common != 0) + { + numerator /= common; + denominator /= common; + } + } + + if (denominator < 0) + { + numerator *= -1; + denominator *= -1; + } + } + + /// + /// Normalizes a fraction. + /// + private static void Normalize(ref long numerator, ref long denominator) + { + if (denominator == 0) + { + numerator = 0; + denominator = 1; + } + else if (numerator != 1 && denominator != 1) + { + long common = Gcd(numerator, denominator); + if (common != 1) + { + numerator /= common; + denominator /= common; + } + } + if (denominator < 0) + { + numerator *= -1; + denominator *= -1; + } + } + + /// + /// Returns the digits after the point. + /// + private static int GetDigits(decimal value) + { + int result = 0; + value -= decimal.Truncate(value); + while (value != 0) + { + value *= 10; + value -= decimal.Truncate(value); + result++; + } + return result; + } + + /// + /// Creates a continued fraction of a decimal value. + /// + private static int[] CreateContinuedFraction(decimal value) + { + int precision = GetDigits(value); + decimal epsilon = 0.0000001m; + List list = new List(); + value = Math.Abs(value); + + byte b = 0; + + list.Add((int)value); + value -= ((int)value); + + while (value != 0m) + { + if (++b == byte.MaxValue || value < epsilon) + { + break; + } + value = 1m / value; + if (Math.Abs((Math.Round(value, precision - 1) - value)) < epsilon) + { + value = Math.Round(value, precision - 1); + } + list.Add((int)value); + value -= ((int)value); + } + return list.ToArray(); + } + + /// + /// Creates a fraction from a continued fraction. + /// + private static void CreateFraction(int[] continuedFraction, out int numerator, out int denominator) + { + numerator = 1; + denominator = 0; + int temp; + + for (int i = continuedFraction.Length - 1; i > -1; i--) + { + temp = numerator; + numerator = continuedFraction[i] * numerator + denominator; + denominator = temp; + } + } + + /// + /// Tries 'brute force' to approximate with a fraction. + /// + private static void ApproximateFraction(decimal value, int maxDen, out int num, out int den) + { + num = 0; + den = 0; + decimal bestDifference = 1m; + decimal currentDifference = -1m; + int digits = GetDigits(value); + + if (digits <= 9) + { + int mul = 1; + for (int i = 1; i <= digits; i++) + { + mul *= 10; + } + if (mul <= maxDen) + { + num = (int)(value * mul); + den = mul; + return; + } + } + + for (int i = 1; i <= maxDen; i++) + { + int numerator = (int)Math.Floor(value * (decimal)i + 0.5m); + currentDifference = Math.Abs(value - (decimal)numerator / (decimal)i); + if (currentDifference < bestDifference) + { + num = numerator; + den = i; + bestDifference = currentDifference; + } + } + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return ((IConvertible)this).ToDouble(null).ToString(); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIRational) && (this == ((FIRational)obj))); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + #region Operators + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator +(FIRational r1) + { + return r1; + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator -(FIRational r1) + { + r1.numerator *= -1; + return r1; + } + + /// + /// Returns the reciprocal value of this instance. + /// + public static FIRational operator ~(FIRational r1) + { + int temp = r1.denominator; + r1.denominator = r1.numerator; + r1.numerator = temp; + r1.Normalize(); + return r1; + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator ++(FIRational r1) + { + checked + { + r1.numerator += r1.denominator; + } + return r1; + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator --(FIRational r1) + { + checked + { + r1.numerator -= r1.denominator; + } + return r1; + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator +(FIRational r1, FIRational r2) + { + long numerator = 0; + long denominator = Scm(r1.denominator, r2.denominator); + numerator = (r1.numerator * (denominator / r1.denominator)) + (r2.numerator * (denominator / r2.denominator)); + Normalize(ref numerator, ref denominator); + checked + { + return new FIRational((int)numerator, (int)denominator); + } + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator -(FIRational r1, FIRational r2) + { + return r1 + (-r2); + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator *(FIRational r1, FIRational r2) + { + long numerator = r1.numerator * r2.numerator; + long denominator = r1.denominator * r2.denominator; + Normalize(ref numerator, ref denominator); + checked + { + return new FIRational((int)numerator, (int)denominator); + } + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator /(FIRational r1, FIRational r2) + { + int temp = r2.denominator; + r2.denominator = r2.numerator; + r2.numerator = temp; + return r1 * r2; + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator %(FIRational r1, FIRational r2) + { + r2.Normalize(); + if (Math.Abs(r2.numerator) < r2.denominator) + return new FIRational(0, 0); + int div = (int)(r1 / r2); + return r1 - (r2 * div); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator ==(FIRational r1, FIRational r2) + { + r1.Normalize(); + r2.Normalize(); + return (r1.numerator == r2.numerator) && (r1.denominator == r2.denominator); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator !=(FIRational r1, FIRational r2) + { + return !(r1 == r2); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator >(FIRational r1, FIRational r2) + { + long denominator = Scm(r1.denominator, r2.denominator); + return (r1.numerator * (denominator / r1.denominator)) > (r2.numerator * (denominator / r2.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator <(FIRational r1, FIRational r2) + { + long denominator = Scm(r1.denominator, r2.denominator); + return (r1.numerator * (denominator / r1.denominator)) < (r2.numerator * (denominator / r2.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator >=(FIRational r1, FIRational r2) + { + long denominator = Scm(r1.denominator, r2.denominator); + return (r1.numerator * (denominator / r1.denominator)) >= (r2.numerator * (denominator / r2.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator <=(FIRational r1, FIRational r2) + { + long denominator = Scm(r1.denominator, r2.denominator); + return (r1.numerator * (denominator / r1.denominator)) <= (r2.numerator * (denominator / r2.denominator)); + } + + #endregion + + #region Conversions + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator bool(FIRational value) + { + return (value.numerator != 0); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator byte(FIRational value) + { + return (byte)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator char(FIRational value) + { + return (char)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator decimal(FIRational value) + { + return value.denominator == 0 ? 0m : (decimal)value.numerator / (decimal)value.denominator; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator double(FIRational value) + { + return value.denominator == 0 ? 0d : (double)value.numerator / (double)value.denominator; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator short(FIRational value) + { + return (short)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator int(FIRational value) + { + return (int)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator long(FIRational value) + { + return (byte)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator float(FIRational value) + { + return value.denominator == 0 ? 0f : (float)value.numerator / (float)value.denominator; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator sbyte(FIRational value) + { + return (sbyte)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator ushort(FIRational value) + { + return (ushort)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator uint(FIRational value) + { + return (uint)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator ulong(FIRational value) + { + return (ulong)(double)value; + } + + // + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIRational(bool value) + { + return new FIRational(value ? 1 : 0, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRational(byte value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRational(char value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIRational(decimal value) + { + return new FIRational(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIRational(double value) + { + return new FIRational((decimal)value); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIRational(short value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIRational(int value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIRational(long value) + { + return new FIRational((int)value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRational(sbyte value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIRational(float value) + { + return new FIRational((decimal)value); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIRational(ushort value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIRational(uint value) + { + return new FIRational((int)value, 1); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIRational(ulong value) + { + return new FIRational((int)value, 1); + } + + #endregion + + #region IConvertible Member + + TypeCode IConvertible.GetTypeCode() + { + return TypeCode.Double; + } + + bool IConvertible.ToBoolean(IFormatProvider provider) + { + return (bool)this; + } + + byte IConvertible.ToByte(IFormatProvider provider) + { + return (byte)this; + } + + char IConvertible.ToChar(IFormatProvider provider) + { + return (char)this; + } + + DateTime IConvertible.ToDateTime(IFormatProvider provider) + { + return Convert.ToDateTime(((IConvertible)this).ToDouble(provider)); + } + + decimal IConvertible.ToDecimal(IFormatProvider provider) + { + return this; + } + + double IConvertible.ToDouble(IFormatProvider provider) + { + return this; + } + + short IConvertible.ToInt16(IFormatProvider provider) + { + return (short)this; + } + + int IConvertible.ToInt32(IFormatProvider provider) + { + return (int)this; + } + + long IConvertible.ToInt64(IFormatProvider provider) + { + return (long)this; + } + + sbyte IConvertible.ToSByte(IFormatProvider provider) + { + return (sbyte)this; + } + + float IConvertible.ToSingle(IFormatProvider provider) + { + return this; + } + + string IConvertible.ToString(IFormatProvider provider) + { + return ToString(((double)this).ToString(), provider); + } + + object IConvertible.ToType(Type conversionType, IFormatProvider provider) + { + return Convert.ChangeType(((IConvertible)this).ToDouble(provider), conversionType, provider); + } + + ushort IConvertible.ToUInt16(IFormatProvider provider) + { + return (ushort)this; + } + + uint IConvertible.ToUInt32(IFormatProvider provider) + { + return (uint)this; + } + + ulong IConvertible.ToUInt64(IFormatProvider provider) + { + return (ulong)this; + } + + #endregion + + #region IComparable Member + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIRational)) + { + throw new ArgumentException(); + } + return CompareTo((FIRational)obj); + } + + #endregion + + #region IFormattable Member + + /// + /// Formats the value of the current instance using the specified format. + /// + /// The String specifying the format to use. + /// The IFormatProvider to use to format the value. + /// A String containing the value of the current instance in the specified format. + public string ToString(string format, IFormatProvider formatProvider) + { + if (format == null) + { + format = ""; + } + return String.Format(formatProvider, format, ((IConvertible)this).ToDouble(formatProvider)); + } + + #endregion + + #region IEquatable Member + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIRational other) + { + return (this == other); + } + + #endregion + + #region IComparable Member + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIRational other) + { + FIRational difference = this - other; + difference.Normalize(); + if (difference.numerator > 0) return 1; + if (difference.numerator < 0) return -1; + else return 0; + } + + #endregion + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FITAG.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FITAG.cs new file mode 100644 index 0000000..a439bb9 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FITAG.cs @@ -0,0 +1,170 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.5 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: FITAG.cs,v 1.5 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The FITAG structure is a handle to a FreeImage metadata tag. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FITAG : IComparable, IComparable, IEquatable + { + private IntPtr data; + + /// + /// A read-only field that represents a handle that has been initialized to zero. + /// + public static readonly FITAG Zero; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FITAG left, FITAG right) + { + return (left.data == right.data); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FITAG left, FITAG right) + { + return (left.data != right.data); + } + + /// + /// Gets whether the pointer is a null pointer or not. + /// + /// true if this is a null pointer; + /// otherwise, false. + public bool IsNull + { + get + { + return (data == IntPtr.Zero); + } + } + + /// + /// Sets the handle to null. + /// + public void SetNull() + { + data = IntPtr.Zero; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return data.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return data.GetHashCode(); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FITAG) && (this == ((FITAG)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// true if the current object is equal to the other parameter; otherwise, false. + public bool Equals(FITAG other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FITAG)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FITAG)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FITAG other) + { + return this.data.ToInt64().CompareTo(other.data.ToInt64()); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIURational.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIURational.cs new file mode 100644 index 0000000..4c2f24d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FIURational.cs @@ -0,0 +1,1010 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.5 $ +// $Date: 2009/02/27 16:36:23 $ +// $Id: FIURational.cs,v 1.5 2009/02/27 16:36:23 cklein05 Exp $ +// ========================================================== + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace FreeImageAPI +{ + /// + /// The FIURational structure represents a fraction via two + /// instances which are interpreted as numerator and denominator. + /// + /// + /// The structure tries to approximate the value of + /// when creating a new instance by using a better algorithm than FreeImage does. + /// + /// The structure implements the following operators: + /// +, ++, --, ==, != , >, >==, <, <== and ~ (which switches nominator and denomiator). + /// + /// The structure can be converted into all .NET standard types either implicit or + /// explicit. + /// + [Serializable, StructLayout(LayoutKind.Sequential), ComVisible(true)] + public struct FIURational : IConvertible, IComparable, IFormattable, IComparable, IEquatable + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private uint numerator; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private uint denominator; + + /// + /// Represents the largest possible value of . This field is constant. + /// + public static readonly FIURational MaxValue = new FIURational(UInt32.MaxValue, 1u); + + /// + /// Represents the smallest possible value of . This field is constant. + /// + public static readonly FIURational MinValue = new FIURational(0u, 1u); + + /// + /// Represents the smallest positive value greater than zero. This field is constant. + /// + public static readonly FIURational Epsilon = new FIURational(1u, UInt32.MaxValue); + + /// + /// Initializes a new instance based on the specified parameters. + /// + /// The numerator. + /// The denominator. + public FIURational(uint n, uint d) + { + numerator = n; + denominator = d; + Normalize(); + } + + /// + /// Initializes a new instance based on the specified parameters. + /// + /// The tag to read the data from. + public unsafe FIURational(FITAG tag) + { + switch (FreeImage.GetTagType(tag)) + { + case FREE_IMAGE_MDTYPE.FIDT_RATIONAL: + uint* pvalue = (uint*)FreeImage.GetTagValue(tag); + numerator = pvalue[0]; + denominator = pvalue[1]; + Normalize(); + return; + default: + throw new ArgumentException("tag"); + } + } + + /// + ///Initializes a new instance based on the specified parameters. + /// + /// The value to convert into a fraction. + /// + /// cannot be converted into a fraction + /// represented by two unsigned integer values. + public FIURational(decimal value) + { + try + { + if (value < 0) + { + throw new OverflowException("value"); + } + try + { + int[] contFract = CreateContinuedFraction(value); + CreateFraction(contFract, out numerator, out denominator); + Normalize(); + } + catch + { + numerator = 0; + denominator = 1; + } + if (Math.Abs(((decimal)numerator / (decimal)denominator) - value) > 0.0001m) + { + int maxDen = (Int32.MaxValue / (int)value) - 2; + maxDen = maxDen < 10000 ? maxDen : 10000; + ApproximateFraction(value, maxDen, out numerator, out denominator); + Normalize(); + if (Math.Abs(((decimal)numerator / (decimal)denominator) - value) > 0.0001m) + { + throw new OverflowException("Unable to convert value into a fraction"); + } + } + Normalize(); + } + catch (Exception ex) + { + throw new OverflowException("Unable to calculate fraction.", ex); + } + } + + /// + /// The numerator of the fraction. + /// + public uint Numerator + { + get { return numerator; } + } + + /// + /// The denominator of the fraction. + /// + public uint Denominator + { + get { return denominator; } + } + + /// + /// Returns the truncated value of the fraction. + /// + /// + public int Truncate() + { + return denominator > 0 ? (int)(numerator / denominator) : 0; + } + + /// + /// Returns whether the fraction is representing an integer value. + /// + public bool IsInteger + { + get + { + return (denominator == 1 || + (denominator != 0 && (numerator % denominator == 0)) || + (denominator == 0 && numerator == 0)); + } + } + + /// + /// Calculated the greatest common divisor of 'a' and 'b'. + /// + private static ulong Gcd(ulong a, ulong b) + { + ulong r; + while (b > 0) + { + r = a % b; + a = b; + b = r; + } + return a; + } + + /// + /// Calculated the smallest common multiple of 'a' and 'b'. + /// + private static ulong Scm(uint n, uint m) + { + return (ulong)n * (ulong)m / Gcd(n, m); + } + + /// + /// Normalizes the fraction. + /// + private void Normalize() + { + if (denominator == 0) + { + numerator = 0; + denominator = 1; + return; + } + + if (numerator != 1 && denominator != 1) + { + uint common = (uint)Gcd(numerator, denominator); + if (common != 1 && common != 0) + { + numerator /= common; + denominator /= common; + } + } + } + + /// + /// Normalizes a fraction. + /// + private static void Normalize(ref ulong numerator, ref ulong denominator) + { + if (denominator == 0) + { + numerator = 0; + denominator = 1; + } + else if (numerator != 1 && denominator != 1) + { + ulong common = Gcd(numerator, denominator); + if (common != 1) + { + numerator /= common; + denominator /= common; + } + } + } + + /// + /// Returns the digits after the point. + /// + private static int GetDigits(decimal value) + { + int result = 0; + value -= decimal.Truncate(value); + while (value != 0) + { + value *= 10; + value -= decimal.Truncate(value); + result++; + } + return result; + } + + /// + /// Creates a continued fraction of a decimal value. + /// + private static int[] CreateContinuedFraction(decimal value) + { + int precision = GetDigits(value); + decimal epsilon = 0.0000001m; + List list = new List(); + value = Math.Abs(value); + + byte b = 0; + + list.Add((int)value); + value -= ((int)value); + + while (value != 0m) + { + if (++b == byte.MaxValue || value < epsilon) + { + break; + } + value = 1m / value; + if (Math.Abs((Math.Round(value, precision - 1) - value)) < epsilon) + { + value = Math.Round(value, precision - 1); + } + list.Add((int)value); + value -= ((int)value); + } + return list.ToArray(); + } + + /// + /// Creates a fraction from a continued fraction. + /// + private static void CreateFraction(int[] continuedFraction, out uint numerator, out uint denominator) + { + numerator = 1; + denominator = 0; + uint temp; + + for (int i = continuedFraction.Length - 1; i > -1; i--) + { + temp = numerator; + numerator = (uint)(continuedFraction[i] * numerator + denominator); + denominator = temp; + } + } + + /// + /// Tries 'brute force' to approximate with a fraction. + /// + private static void ApproximateFraction(decimal value, int maxDen, out uint num, out uint den) + { + num = 0; + den = 0; + decimal bestDifference = 1m; + decimal currentDifference = -1m; + int digits = GetDigits(value); + + if (digits <= 9) + { + uint mul = 1; + for (int i = 1; i <= digits; i++) + { + mul *= 10; + } + if (mul <= maxDen) + { + num = (uint)(value * mul); + den = mul; + return; + } + } + + for (uint u = 1; u <= maxDen; u++) + { + uint numerator = (uint)Math.Floor(value * (decimal)u + 0.5m); + currentDifference = Math.Abs(value - (decimal)numerator / (decimal)u); + if (currentDifference < bestDifference) + { + num = numerator; + den = u; + bestDifference = currentDifference; + } + } + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return ((IConvertible)this).ToDouble(null).ToString(); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIURational) && (this == ((FIURational)obj))); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + #region Operators + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator +(FIURational value) + { + return value; + } + + /// + /// Returns the reciprocal value of this instance. + /// + public static FIURational operator ~(FIURational value) + { + uint temp = value.denominator; + value.denominator = value.numerator; + value.numerator = temp; + value.Normalize(); + return value; + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator ++(FIURational value) + { + checked + { + value.numerator += value.denominator; + } + return value; + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator --(FIURational value) + { + checked + { + value.numerator -= value.denominator; + } + return value; + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator +(FIURational left, FIURational right) + { + ulong numerator = 0; + ulong denominator = Scm(left.denominator, right.denominator); + numerator = (left.numerator * (denominator / left.denominator)) + + (right.numerator * (denominator / right.denominator)); + Normalize(ref numerator, ref denominator); + checked + { + return new FIURational((uint)numerator, (uint)denominator); + } + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator -(FIURational left, FIURational right) + { + checked + { + if (left.denominator != right.denominator) + { + uint denom = left.denominator; + left.numerator *= right.denominator; + left.denominator *= right.denominator; + right.numerator *= denom; + right.denominator *= denom; + } + left.numerator -= right.numerator; + left.Normalize(); + return left; + } + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator *(FIURational left, FIURational r2) + { + ulong numerator = left.numerator * r2.numerator; + ulong denominator = left.denominator * r2.denominator; + Normalize(ref numerator, ref denominator); + checked + { + return new FIURational((uint)numerator, (uint)denominator); + } + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator /(FIURational left, FIURational right) + { + uint temp = right.denominator; + right.denominator = right.numerator; + right.numerator = temp; + return left * right; + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator %(FIURational left, FIURational right) + { + right.Normalize(); + if (Math.Abs(right.numerator) < right.denominator) + return new FIURational(0, 0); + int div = (int)(left / right); + return left - (right * div); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator ==(FIURational left, FIURational right) + { + left.Normalize(); + right.Normalize(); + return (left.numerator == right.numerator) && (left.denominator == right.denominator); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator !=(FIURational left, FIURational right) + { + left.Normalize(); + right.Normalize(); + return (left.numerator != right.numerator) || (left.denominator != right.denominator); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator >(FIURational left, FIURational right) + { + ulong denominator = Scm(left.denominator, right.denominator); + return (left.numerator * (denominator / left.denominator)) > + (right.numerator * (denominator / right.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator <(FIURational left, FIURational right) + { + ulong denominator = Scm(left.denominator, right.denominator); + return (left.numerator * (denominator / left.denominator)) < + (right.numerator * (denominator / right.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator >=(FIURational left, FIURational right) + { + ulong denominator = Scm(left.denominator, right.denominator); + return (left.numerator * (denominator / left.denominator)) >= + (right.numerator * (denominator / right.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator <=(FIURational left, FIURational right) + { + ulong denominator = Scm(left.denominator, right.denominator); + return (left.numerator * (denominator / left.denominator)) <= + (right.numerator * (denominator / right.denominator)); + } + + #endregion + + #region Conversions + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator bool(FIURational value) + { + return (value.numerator != 0); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator byte(FIURational value) + { + return (byte)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator char(FIURational value) + { + return (char)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator decimal(FIURational value) + { + return value.denominator == 0 ? 0m : (decimal)value.numerator / (decimal)value.denominator; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator double(FIURational value) + { + return value.denominator == 0 ? 0d : (double)value.numerator / (double)value.denominator; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator short(FIURational value) + { + return (short)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator int(FIURational value) + { + return (int)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator long(FIURational value) + { + return (byte)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator float(FIURational value) + { + return value.denominator == 0 ? 0f : (float)value.numerator / (float)value.denominator; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator sbyte(FIURational value) + { + return (sbyte)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator ushort(FIURational value) + { + return (ushort)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator uint(FIURational value) + { + return (uint)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator ulong(FIURational value) + { + return (ulong)(double)value; + } + + // + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIURational(bool value) + { + return new FIURational(value ? 1u : 0u, 1u); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIURational(byte value) + { + return new FIURational(value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIURational(char value) + { + return new FIURational(value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIURational(decimal value) + { + return new FIURational(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIURational(double value) + { + return new FIURational((decimal)value); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIURational(short value) + { + return new FIURational((uint)value, 1u); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIURational(int value) + { + return new FIURational((uint)value, 1u); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIURational(long value) + { + return new FIURational((uint)value, 1u); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIURational(sbyte value) + { + return new FIURational((uint)value, 1u); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIURational(float value) + { + return new FIURational((decimal)value); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIURational(ushort value) + { + return new FIURational(value, 1); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIURational(uint value) + { + return new FIURational(value, 1u); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIURational(ulong value) + { + return new FIURational((uint)value, 1u); + } + + #endregion + + #region IConvertible Member + + TypeCode IConvertible.GetTypeCode() + { + return TypeCode.Double; + } + + bool IConvertible.ToBoolean(IFormatProvider provider) + { + return (bool)this; + } + + byte IConvertible.ToByte(IFormatProvider provider) + { + return (byte)this; + } + + char IConvertible.ToChar(IFormatProvider provider) + { + return (char)this; + } + + DateTime IConvertible.ToDateTime(IFormatProvider provider) + { + return Convert.ToDateTime(((IConvertible)this).ToDouble(provider)); + } + + decimal IConvertible.ToDecimal(IFormatProvider provider) + { + return this; + } + + double IConvertible.ToDouble(IFormatProvider provider) + { + return this; + } + + short IConvertible.ToInt16(IFormatProvider provider) + { + return (short)this; + } + + int IConvertible.ToInt32(IFormatProvider provider) + { + return (int)this; + } + + long IConvertible.ToInt64(IFormatProvider provider) + { + return (long)this; + } + + sbyte IConvertible.ToSByte(IFormatProvider provider) + { + return (sbyte)this; + } + + float IConvertible.ToSingle(IFormatProvider provider) + { + return this; + } + + string IConvertible.ToString(IFormatProvider provider) + { + return ToString(((double)this).ToString(), provider); + } + + object IConvertible.ToType(Type conversionType, IFormatProvider provider) + { + return Convert.ChangeType(((IConvertible)this).ToDouble(provider), conversionType, provider); + } + + ushort IConvertible.ToUInt16(IFormatProvider provider) + { + return (ushort)this; + } + + uint IConvertible.ToUInt32(IFormatProvider provider) + { + return (uint)this; + } + + ulong IConvertible.ToUInt64(IFormatProvider provider) + { + return (ulong)this; + } + + #endregion + + #region IComparable Member + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIURational)) + { + throw new ArgumentException(); + } + return CompareTo((FIURational)obj); + } + + #endregion + + #region IFormattable Member + + /// + /// Formats the value of the current instance using the specified format. + /// + /// The String specifying the format to use. + /// The IFormatProvider to use to format the value. + /// A String containing the value of the current instance in the specified format. + public string ToString(string format, IFormatProvider formatProvider) + { + if (format == null) + { + format = ""; + } + return String.Format(formatProvider, format, ((IConvertible)this).ToDouble(formatProvider)); + } + + #endregion + + #region IEquatable Member + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIURational other) + { + return (this == other); + } + + #endregion + + #region IComparable Member + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIURational other) + { + FIURational difference = this - other; + difference.Normalize(); + if (difference.numerator > 0) return 1; + if (difference.numerator < 0) return -1; + else return 0; + } + + #endregion + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FreeImageIO.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FreeImageIO.cs new file mode 100644 index 0000000..af464d0 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/FreeImageIO.cs @@ -0,0 +1,66 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2008/06/17 13:49:23 $ +// $Id: FreeImageIO.cs,v 1.3 2008/06/17 13:49:23 cklein05 Exp $ +// ========================================================== + +using System.Runtime.InteropServices; + +namespace FreeImageAPI.IO +{ + /// + /// Structure for implementing access to custom handles. + /// + [StructLayout(LayoutKind.Sequential)] + public struct FreeImageIO + { + /// + /// Delegate to the C++ function fread. + /// + public ReadProc readProc; + + /// + /// Delegate to the C++ function fwrite. + /// + public WriteProc writeProc; + + /// + /// Delegate to the C++ function fseek. + /// + public SeekProc seekProc; + + /// + /// Delegate to the C++ function ftell. + /// + public TellProc tellProc; + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/Plugin.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/Plugin.cs new file mode 100644 index 0000000..0148c45 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/Plugin.cs @@ -0,0 +1,132 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2008/06/17 13:48:22 $ +// $Id: Plugin.cs,v 1.3 2008/06/17 13:48:22 cklein05 Exp $ +// ========================================================== + +using System; +using System.Runtime.InteropServices; +using FreeImageAPI.Plugins; + +namespace FreeImageAPI.Plugins +{ + /// + /// The structure contains functionpointers that make up a FreeImage plugin. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct Plugin + { + /// + /// Delegate to a function that returns a string which describes + /// the plugins format. + /// + public FormatProc formatProc; + + /// + /// Delegate to a function that returns a string which contains + /// a more detailed description. + /// + public DescriptionProc descriptionProc; + + /// + /// Delegate to a function that returns a comma seperated list + /// of file extensions the plugin can read or write. + /// + public ExtensionListProc extensionListProc; + + /// + /// Delegate to a function that returns a regular expression that + /// can be used to idientify whether a file can be handled by the plugin. + /// + public RegExprProc regExprProc; + + /// + /// Delegate to a function that opens a file. + /// + public OpenProc openProc; + + /// + /// Delegate to a function that closes a previosly opened file. + /// + public CloseProc closeProc; + + /// + /// Delegate to a function that returns the number of pages of a multipage + /// bitmap if the plugin is capable of handling multipage bitmaps. + /// + public PageCountProc pageCountProc; + + /// + /// UNKNOWN + /// + public PageCapabilityProc pageCapabilityProc; + + /// + /// Delegate to a function that loads and decodes a bitmap into memory. + /// + public LoadProc loadProc; + + /// + /// Delegate to a function that saves a bitmap. + /// + public SaveProc saveProc; + + /// + /// Delegate to a function that determines whether the source is a valid image. + /// + public ValidateProc validateProc; + + /// + /// Delegate to a function that returns a string which contains + /// the plugin's mime type. + /// + public MimeProc mimeProc; + + /// + /// Delegate to a function that returns whether the plugin can handle the + /// specified color depth. + /// + public SupportsExportBPPProc supportsExportBPPProc; + + /// + /// Delegate to a function that returns whether the plugin can handle the + /// specified image type. + /// + public SupportsExportTypeProc supportsExportTypeProc; + + /// + /// Delegate to a function that returns whether the plugin can handle + /// ICC-Profiles. + /// + public SupportsICCProfilesProc supportsICCProfilesProc; + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/RGBQUAD.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/RGBQUAD.cs new file mode 100644 index 0000000..fce303e --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/RGBQUAD.cs @@ -0,0 +1,342 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.4 $ +// $Date: 2009/02/20 07:40:53 $ +// $Id: RGBQUAD.cs,v 1.4 2009/02/20 07:40:53 cklein05 Exp $ +// ========================================================== + +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The RGBQUAD structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 8 bits and so, takes values in the range from 0 to 255. + /// + /// + /// + /// The RGBQUAD structure provides access to an underlying Win32 RGBQUAD + /// structure. To determine the alpha, red, green or blue component of a color, + /// use the rgbReserved, rgbRed, rgbGreen or rgbBlue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the RGBQUAD structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the RGBQUAD structure and my be used in all situations which require + /// an RGBQUAD type. + /// + /// + /// Each color component rgbReserved, rgbRed, rgbGreen or rgbBlue of RGBQUAD + /// is translated into it's corresponding color component A, R, G or B of + /// by an one-to-one manner and vice versa. + /// + /// + /// Conversion from System.Drawing.Color to RGBQUAD + /// + /// RGBQUAD.component = Color.component + /// + /// Conversion from RGBQUAD to System.Drawing.Color + /// + /// Color.component = RGBQUAD.component + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// RGBQUAD structure and the structure. + /// + /// RGBQUAD rgbq; + /// // Initialize the structure using a native .NET Color structure. + /// rgbq = new RGBQUAD(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// rgbq = Color.DarkSeaGreen; + /// // Convert the RGBQUAD instance into a native .NET Color + /// // using its implicit operator. + /// Color color = rgbq; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = rgbq.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Explicit)] + public struct RGBQUAD : IComparable, IComparable, IEquatable + { + /// + /// The blue color component. + /// + [FieldOffset(0)] + public byte rgbBlue; + + /// + /// The green color component. + /// + [FieldOffset(1)] + public byte rgbGreen; + + /// + /// The red color component. + /// + [FieldOffset(2)] + public byte rgbRed; + + /// + /// The alpha color component. + /// + [FieldOffset(3)] + public byte rgbReserved; + + /// + /// The color's value. + /// + [FieldOffset(0)] + public uint uintValue; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public RGBQUAD(Color color) + { + uintValue = 0u; + rgbBlue = color.B; + rgbGreen = color.G; + rgbRed = color.R; + rgbReserved = color.A; + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(RGBQUAD left, RGBQUAD right) + { + return (left.uintValue == right.uintValue); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(RGBQUAD left, RGBQUAD right) + { + return (left.uintValue != right.uintValue); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator RGBQUAD(Color value) + { + return new RGBQUAD(value); + } + + /// + /// Converts the value of a structure to a Color structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(RGBQUAD value) + { + return value.Color; + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator RGBQUAD(uint value) + { + RGBQUAD result = new RGBQUAD(); + result.uintValue = value; + return result; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator uint(RGBQUAD value) + { + return value.uintValue; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + rgbReserved, + rgbRed, + rgbGreen, + rgbBlue); + } + set + { + rgbRed = value.R; + rgbGreen = value.G; + rgbBlue = value.B; + rgbReserved = value.A; + } + } + + /// + /// Converts an array of into an array of + /// . + /// + /// The array to convert. + /// An array of . + public static RGBQUAD[] ToRGBQUAD(Color[] array) + { + if (array == null) + return null; + + RGBQUAD[] result = new RGBQUAD[array.Length]; + for (int i = 0; i < array.Length; i++) + { + result[i] = array[i]; + } + return result; + } + + /// + /// Converts an array of into an array of + /// . + /// + /// The array to convert. + /// An array of . + public static Color[] ToColor(RGBQUAD[] array) + { + if (array == null) + return null; + + Color[] result = new Color[array.Length]; + for (int i = 0; i < array.Length; i++) + { + result[i] = array[i].Color; + } + return result; + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is RGBQUAD)) + { + throw new ArgumentException("obj"); + } + return CompareTo((RGBQUAD)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(RGBQUAD other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is RGBQUAD) && (this == ((RGBQUAD)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(RGBQUAD other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/RGBTRIPLE.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/RGBTRIPLE.cs new file mode 100644 index 0000000..feddcbf --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/RGBTRIPLE.cs @@ -0,0 +1,295 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.3 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: RGBTRIPLE.cs,v 1.3 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace FreeImageAPI +{ + /// + /// The RGBTRIPLE structure describes a color consisting of relative + /// intensities of red, green and blue value. Each single color component + /// consumes 8 bits and so, takes values in the range from 0 to 255. + /// + /// + /// + /// The RGBTRIPLE structure provides access to an underlying Win32 RGBTRIPLE + /// structure. To determine the red, green or blue component of a color, use the + /// rgbtRed, rgbtGreen or rgbtBlue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the RGBTRIPLE structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the RGBTRIPLE structure and my be used in all situations which require + /// an RGBTRIPLE type. + /// + /// + /// Each of the color components rgbtRed, rgbtGreen or rgbtBlue of RGBTRIPLE is + /// translated into it's corresponding color component R, G or B of + /// by an one-to-one manner and vice versa. + /// When converting from into RGBTRIPLE, the + /// color's alpha value is ignored and assumed to be 255 when converting from + /// RGBTRIPLE into , creating a fully + /// opaque color. + /// + /// + /// Conversion from System.Drawing.Color to RGBTRIPLE + /// + /// RGBTRIPLE.component = Color.component + /// + /// Conversion from RGBTRIPLE to System.Drawing.Color + /// + /// Color.component = RGBTRIPLE.component + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// RGBTRIPLE structure and the structure. + /// + /// RGBTRIPLE rgbt; + /// // Initialize the structure using a native .NET Color structure. + /// rgbt = new RGBTRIPLE(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// rgbt = Color.DarkSeaGreen; + /// // Convert the RGBTRIPLE instance into a native .NET Color + /// // using its implicit operator. + /// Color color = rgbt; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = rgbt.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct RGBTRIPLE : IComparable, IComparable, IEquatable + { + /// + /// The blue color component. + /// + public byte rgbtBlue; + + /// + /// The green color component. + /// + public byte rgbtGreen; + + /// + /// The red color component. + /// + public byte rgbtRed; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public RGBTRIPLE(Color color) + { + rgbtBlue = color.B; + rgbtGreen = color.G; + rgbtRed = color.R; + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(RGBTRIPLE left, RGBTRIPLE right) + { + return + left.rgbtBlue == right.rgbtBlue && + left.rgbtGreen == right.rgbtGreen && + left.rgbtRed == right.rgbtRed; + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(RGBTRIPLE left, RGBTRIPLE right) + { + return !(left == right); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator RGBTRIPLE(Color value) + { + return new RGBTRIPLE(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(RGBTRIPLE value) + { + return value.Color; + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator RGBTRIPLE(uint value) + { + RGBTRIPLE result = new RGBTRIPLE(); + result.rgbtBlue = (byte)(value & 0xFF); + result.rgbtGreen = (byte)((value >> 8) & 0xFF); + result.rgbtRed = (byte)((value >> 16) & 0xFF); + return result; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator uint(RGBTRIPLE value) + { + return (uint)((value.rgbtRed << 16) | (value.rgbtGreen << 8) | (value.rgbtBlue)); + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + rgbtRed, + rgbtGreen, + rgbtBlue); + } + set + { + rgbtBlue = value.B; + rgbtGreen = value.G; + rgbtRed = value.R; + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is RGBTRIPLE)) + { + throw new ArgumentException("obj"); + } + return CompareTo((RGBTRIPLE)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(RGBTRIPLE other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is RGBTRIPLE) && (this == ((RGBTRIPLE)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this + /// structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(RGBTRIPLE other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/fi_handle.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/fi_handle.cs new file mode 100644 index 0000000..7547d78 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/Structs/fi_handle.cs @@ -0,0 +1,256 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// CVS +// $Revision: 1.7 $ +// $Date: 2009/02/20 07:41:08 $ +// $Id: fi_handle.cs,v 1.7 2009/02/20 07:41:08 cklein05 Exp $ +// ========================================================== + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace FreeImageAPI.IO +{ + /// + /// Wrapper for a custom handle. + /// + /// + /// The fi_handle of FreeImage in C++ is a simple pointer, but in .NET + /// it's not that simple. This wrapper uses fi_handle in two different ways. + /// + /// We implement a new plugin and FreeImage gives us a handle (pointer) that + /// we can simply pass through to the given functions in a 'FreeImageIO' + /// structure. + /// But when we want to use LoadFromhandle or SaveToHandle we need + /// a fi_handle (that we receive again in our own functions). + /// This handle is for example a stream (see LoadFromStream / SaveToStream) + /// that we want to work with. To know which stream a read/write is meant for + /// we could use a hash value that the wrapper itself handles or we can + /// go the unmanaged way of using a handle. + /// Therefor we use a to receive a unique pointer that we can + /// convert back into a .NET object. + /// When the fi_handle instance is no longer needed the instance must be disposed + /// by the creater manually! It is recommended to use the using statement to + /// be sure the instance is always disposed: + /// + /// + /// using (fi_handle handle = new fi_handle(object)) + /// { + /// callSomeFunctions(handle); + /// } + /// + /// + /// What does that mean? + /// If we get a fi_handle from unmanaged code we get a pointer to unmanaged + /// memory that we do not have to care about, and just pass ist back to FreeImage. + /// If we have to create a handle our own we use the standard constructur + /// that fills the with an pointer that represents the given object. + /// With calling the is used to retrieve the original + /// object we passed through the constructor. + /// + /// This way we can implement a fi_handle that works with managed an unmanaged + /// code. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct fi_handle : IComparable, IComparable, IEquatable, IDisposable + { + /// + /// The handle to wrap. + /// + public IntPtr handle; + + /// + /// Initializes a new instance wrapping a managed object. + /// + /// The object to wrap. + /// + /// is null. + public fi_handle(object obj) + { + if (obj == null) + { + throw new ArgumentNullException("obj"); + } + GCHandle gch = GCHandle.Alloc(obj, GCHandleType.Normal); + handle = GCHandle.ToIntPtr(gch); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(fi_handle left, fi_handle right) + { + return (left.handle == right.handle); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(fi_handle left, fi_handle right) + { + return (left.handle != right.handle); + } + + /// + /// Gets whether the pointer is a null pointer. + /// + public bool IsNull + { + get + { + return (handle == IntPtr.Zero); + } + } + + /// + /// Returns the object assigned to the handle in case this instance + /// was created by managed code. + /// + /// assigned to this handle or null on failure. + internal object GetObject() + { + object result = null; + if (handle != IntPtr.Zero) + { + try + { + result = GCHandle.FromIntPtr(handle).Target; + } + catch + { + } + } + return result; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return handle.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return handle.GetHashCode(); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is fi_handle) && (this == ((fi_handle)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// True if the current object is equal to the other parameter; otherwise, false. + public bool Equals(fi_handle other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is fi_handle)) + { + throw new ArgumentException("obj"); + } + return CompareTo((fi_handle)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(fi_handle other) + { + return handle.ToInt64().CompareTo(other.handle.ToInt64()); + } + + /// + /// Releases all resources used by the instance. + /// + public void Dispose() + { + if (this.handle != IntPtr.Zero) + { + try + { + GCHandle.FromIntPtr(handle).Free(); + } + catch + { + } + finally + { + this.handle = IntPtr.Zero; + } + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/build.bat b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/build.bat new file mode 100644 index 0000000..8c9f4db --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Library/build.bat @@ -0,0 +1,7 @@ +@ECHO OFF +IF NOT EXIST bin MD bin +IF NOT EXIST bin\Release MD bin\Release +csc.exe /out:bin\Release\FreeImageNET.dll /target:library /doc:bin\Release\FreeImageNET.XML /debug- /o /nowarn:419 /unsafe+ /filealign:512 /recurse:*.cs +IF EXIST ..\Bin copy bin\Release\FreeImageNET.dll ..\Bin > NUL +IF EXIST ..\Bin copy bin\Release\FreeImageNET.XML ..\Bin > NUL +pause \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Program.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Program.cs new file mode 100644 index 0000000..4ca025f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Program.cs @@ -0,0 +1,179 @@ +using System; +using System.IO; +using FreeImageAPI; +using System.Collections.Generic; +using System.Runtime.Serialization.Formatters.Binary; +using System.Drawing; +using System.Drawing.Imaging; +using System.Runtime.InteropServices; + +namespace Sample01 +{ + class Program + { + static void Main(string[] args) + { + // Check if FreeImage.dll is available (can be in %path%). + if (!FreeImage.IsAvailable()) + { + Console.WriteLine("FreeImage.dll seems to be missing. Aborting."); + return; + } + + Sample sample = new Sample(); + // This example shows the basic loading and saving operations offered by FreeImage. + sample.Example01(); + + // This example shows a more comfortable way offered by the .NET Wrapper. + sample.Example02(); + + // This example shows the FreeImage-Errormessage-Callback + sample.Example03(); + } + } + + public class Sample + { + const string fileName = @"Sample.jpg"; + const string outFileName = @"Sample.tif"; + FIBITMAP dib = new FIBITMAP(); + string message = null; + + public void Example01() + { + if (!File.Exists(fileName)) + { + Console.WriteLine(fileName + " does not exist. Aborting."); + return; + } + + // Try to unload the bitmap handle (in case it is not null). + // Always assert that a handle (like dib) is unloaded before it is reused, because + // on unmanaged side there is no garbage collector that will clean up unreferenced + // objects. + // The following code will produce a memory leak (in case the bitmap is loaded + // successfully) because the handle to the first bitmap is lost: + // dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, fileName, FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE); + // dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, fileName, FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE); + if (!dib.IsNull) + FreeImage.Unload(dib); + + // Loading a sample bitmap. In this case it's a .jpg file. 'Load' requires the file + // format or the loading process will fail. An additional flag (the default value is + // 'DEFAULT') can be set to enable special loading options. + dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, fileName, FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE); + + // Check if the handle is null which means the bitmap could not be loaded. + if (dib.IsNull) + { + Console.WriteLine("Loading bitmap failed. Aborting."); + // Check whether there was an error message. + return; + } + + // Try flipping the bitmap. + if (!FreeImage.FlipHorizontal(dib)) + { + Console.WriteLine("Unable to flip bitmap."); + // Check whether there was an error message. + } + + // Store the bitmap back to disk. Again the desired format is needed. In this case the format is 'TIFF'. + // An output filename has to be chosen (which will be overwritten without a warning). + // A flag can be provided to enable pluginfunctions (compression is this case). + FreeImage.Save(FREE_IMAGE_FORMAT.FIF_TIFF, dib, outFileName, FREE_IMAGE_SAVE_FLAGS.TIFF_DEFLATE); + + // The bitmap was saved to disk but is still allocated in memory, so the handle has to be freed. + if (!dib.IsNull) + FreeImage.Unload(dib); + + // Make sure to set the handle to null so that it is clear that the handle is not pointing to a bitmap. + dib.SetNull(); + } + + public void Example02() + { + // 'UnloadEx' is a comfortable way of unloading a bitmap. The coder can call 'UnloadEx' even + // when the handle is pointing to null (in this case nothing will happen). In case the handle + // is valid (valid means that it is NOT pointing to null) the bitmap will be unloaded and the + // handle will be set to null manually. + FreeImage.UnloadEx(ref dib); + + // 'LoadEx' is a comfortable way of loading a bitmap. 'LoadEx' tries to find out the format of + // the file and will use this to load it. It will use DEFAULT loading values. + dib = FreeImage.LoadEx(fileName); + + // Check if the handle is null which means the bitmap could not be loaded. + if (dib.IsNull) + { + Console.WriteLine("Loading bitmap failed. Aborting."); + return; + } + + // 'SaveEx' (like 'LoadEx') will try to save the bitmap with default values. + // Before saving the bitmap, 'SaveEx' checks whether the extension is valid for the file type + // and if the plugin can use the colordepth of the bitmap. If not it will automatically convert + // the bitmap into the next best colordepth and save it. + if (!FreeImage.SaveEx(ref dib, @"Sample.gif", false)) + { + Console.WriteLine("Saving bitmap failed."); + } + + // The handle is still valid. + if (!FreeImage.SaveEx( + ref dib, + @"Sample", // No extension was selected so let 'SaveEx' decide. + FREE_IMAGE_FORMAT.FIF_PNG, // A format is needed this time. + FREE_IMAGE_SAVE_FLAGS.DEFAULT, // PNG has no options so use default. + FREE_IMAGE_COLOR_DEPTH.FICD_04_BPP, // 4bpp as result color depth. + true)) // We're done so unload + { + // SaveEx will not unload the bitmap in case saving failed. + // This way possible operations done to the bitmaps aren't lost. + FreeImage.UnloadEx(ref dib); + } + } + + public void Example03() + { + // Safely unload to prevent memory leak. + FreeImage.UnloadEx(ref dib); + + // Load the example bitmap. + dib = FreeImage.LoadEx(fileName); + + // Check whether loading succeeded. + if (dib.IsNull) + { + return; + } + + // Add this class to the callback event. + FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message); + + // Try to save the bitmap as a gif + if (!FreeImage.Save(FREE_IMAGE_FORMAT.FIF_GIF, dib, @"Sample_fail.gif", FREE_IMAGE_SAVE_FLAGS.DEFAULT)) + { + // Saving failed + // Check whether there was an error callback + if (message != null) + { + // Print the message and delete it. + Console.WriteLine("Error message recieved: {0}", message); + message = null; + } + } + + // Unload bitmap. + FreeImage.UnloadEx(ref dib); + + // Remove this class from the callback event. + FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message); + } + + void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message) + { + this.message = message; + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0a5e51f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("ac0569fe-c021-4f40-bfe9-275baf0fd21a")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Sample 01 - Loading and saving.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Sample 01 - Loading and saving.2005.csproj new file mode 100644 index 0000000..451beb7 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Sample 01 - Loading and saving.2005.csproj @@ -0,0 +1,105 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9} + Exe + Properties + Sample01 + Sample01 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + true + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + true + + + true + bin\Debug\ + DEBUG;TRACE + true + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + true + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + true + + + x64 + false + prompt + + + + + + + + + + + + Always + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Sample 01 - Loading and saving.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Sample 01 - Loading and saving.csproj new file mode 100644 index 0000000..b26a3cb --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Sample 01 - Loading and saving.csproj @@ -0,0 +1,110 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {0D294AB6-FAD4-4364-AAB6-43C1796116A9} + Exe + Properties + Sample01 + Sample01 + + + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + true + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + true + + + true + bin\Debug\ + DEBUG;TRACE + true + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + true + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + true + + + x64 + false + prompt + + + + + + + + + + + + Always + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Sample.jpg b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Sample.jpg new file mode 100644 index 0000000..b537c00 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Sample.jpg differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Program.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Program.cs new file mode 100644 index 0000000..306cce0 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Program.cs @@ -0,0 +1,140 @@ +using System; +using System.IO; +using FreeImageAPI; + +namespace Sample02 +{ + class Program + { + static void Main(string[] args) + { + // Check if FreeImage.dll is available (can be in %path%). + if (!FreeImage.IsAvailable()) + { + Console.WriteLine("FreeImage.dll seems to be missing. Aborting."); + return; + } + + Sample sample = new Sample(); + sample.Example(); + } + } + + public class Sample + { + const string fileName = @"multipaged.tif"; + FIMULTIBITMAP dib = new FIMULTIBITMAP(); + Random rand = new Random(); + + public void Example() + { + if (!File.Exists(fileName)) + { + Console.WriteLine("File not found. Aborting."); + return; + } + + // Load the multipaged bitmap. + // 'OpenMultiBitmapEx' tries to find the correct file format, loads the bitmap + // with default options, with write support and does not use caching. + dib = FreeImage.OpenMultiBitmapEx(fileName); + + // Check whether loading succeeded. + if (dib.IsNull) + { + Console.WriteLine("File could not be loaded. Aborting."); + return; + } + + // Get the number of bitmaps the multipaged bitmap contains. + int count = FreeImage.GetPageCount(dib); + + // Multipaged bitmaps consist of multiple single FIBITMAPs + FIBITMAP page = new FIBITMAP(); + + // There are bitmaps we can work with. + if (count > 0) + { + // Lock a random bitmap to work with. + page = FreeImage.LockPage(dib, rand.Next(0, count)); + } + + // Check whether locking succeeded. + if (page.IsNull) + { + // Locking failed. Unload the bitmap and return. + FreeImage.CloseMultiBitmapEx(ref dib); + return; + } + + // Get a list of locked pages. This can be usefull to check whether a page has already been locked. + int[] lockedPages = FreeImage.GetLockedPages(dib); + + // Lets modify the page. + if (FreeImage.AdjustGamma(page, 2d)) + { + Console.WriteLine("Successfully changed gamma of page {0}.", lockedPages[0]); + } + else + { + Console.WriteLine("Failed to adjust gamma ..."); + } + + // Print out the list of locked pages + foreach (int i in lockedPages) + Console.WriteLine("Page {0} is locked.", i); + + // Use 'UnlockPage' instead of 'Unload' to free the page. Set the third parameter to 'true' + // so that FreeImage can store the changed page within the multipaged bitmap. + FreeImage.UnlockPage(dib, page, true); + + // Retieve the list again to see whether unlocking succeeded. + lockedPages = FreeImage.GetLockedPages(dib); + + // No output should be produced here. + foreach (int i in lockedPages) + Console.WriteLine("Page {0} is still locked.", i); + + // If there are more than one page we can swap them + if (count > 1) + { + if (!FreeImage.MovePage(dib, 1, 0)) + { + Console.WriteLine("Swapping pages failed."); + } + } + + if (count > 2) + { + // Lock page 2 + page = FreeImage.LockPage(dib, 2); + if (!page.IsNull) + { + // Clone the page for later appending + FIBITMAP temp = FreeImage.Clone(page); + + // Unlock the page again + FreeImage.UnlockPage(dib, page, false); + + // Delete the page form the multipaged bitmap + FreeImage.DeletePage(dib, 2); + + // Append the clone again + FreeImage.AppendPage(dib, temp); + + // Check whether the number of pages is still the same + Console.WriteLine("Pages before: {0}. Pages after: {1}", count, FreeImage.GetPageCount(dib)); + + // Unload clone to prevent memory leak + FreeImage.UnloadEx(ref temp); + } + } + + // We are done and close the multipaged bitmap. + if (!FreeImage.CloseMultiBitmapEx(ref dib)) + { + Console.WriteLine("Closing bitmap failed!"); + } + } + } +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fc97675 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("35960522-c01a-40d2-a86b-37b9839b131c")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Sample 02 - Multipaged bitmaps.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Sample 02 - Multipaged bitmaps.2005.csproj new file mode 100644 index 0000000..f0b7f29 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Sample 02 - Multipaged bitmaps.2005.csproj @@ -0,0 +1,97 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B} + Exe + Properties + Sample02 + Sample02 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + + + Always + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Sample 02 - Multipaged bitmaps.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Sample 02 - Multipaged bitmaps.csproj new file mode 100644 index 0000000..23255a3 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/Sample 02 - Multipaged bitmaps.csproj @@ -0,0 +1,102 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B} + Exe + Properties + Sample02 + Sample02 + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + + + Always + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/multipaged.tif b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/multipaged.tif new file mode 100644 index 0000000..886a7c9 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 02 - Multipaged bitmaps/multipaged.tif differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Program.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Program.cs new file mode 100644 index 0000000..50d3cde --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Program.cs @@ -0,0 +1,74 @@ +using System; +using System.IO; +using FreeImageAPI; + +namespace Sample03 +{ + class Program + { + static void Main(string[] args) + { + // Check if FreeImage.dll is available (can be in %path%). + if (!FreeImage.IsAvailable()) + { + Console.WriteLine("FreeImage.dll seems to be missing. Aborting."); + return; + } + + // Add this class to the message event + FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message); + + Sample sample = new Sample(); + sample.Example(); + + // Remove this class from the message event + FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message); + } + + static void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message) + { + Console.WriteLine("Error for {0}: {1}", fif.ToString(), message); + } + } + + public class Sample + { + FIBITMAP dib = new FIBITMAP(); + + public void Example() + { + // Allocating a new bitmap with 99x99 pixels, 16-bit color depth and an allocation of 5 bits for each color. + dib = FreeImage.Allocate(99, 99, 16, FreeImage.FI16_555_RED_MASK, FreeImage.FI16_555_GREEN_MASK, FreeImage.FI16_555_BLUE_MASK); + + // Saving bitmap. + if (!FreeImage.SaveEx(ref dib, "example01.bmp", true)) + { + Console.WriteLine("Saving 'example.bmp' failed."); + FreeImage.UnloadEx(ref dib); + } + + // Allocation a new bitmap with 71x33 pixels, 4-bit color depth. Bitmaps below 16-bit have paletts. + // Each pixel references an index within the palette wich contains the true color. + // Therefor no bit-masks are needed and can be set to 0. + dib = FreeImage.Allocate(71, 33, 4, 0, 0, 0); + + // Saving bitmap. + if (!FreeImage.SaveEx(ref dib, "example02.tif", true)) + { + Console.WriteLine("Saving 'example02.tif' failed."); + FreeImage.UnloadEx(ref dib); + } + + // Allocation a new bitmap. This time 'AllocateT' is used because 'Allocate' can only create standard bitmaps. + // In this case a RGBF bitmap is created. Red, green and blue are represented by a float-value so no bit-masks are needed. + dib = FreeImage.AllocateT(FREE_IMAGE_TYPE.FIT_RGBF, 50, 75, 9, 0, 0, 0); + + // Saving bitmap. + if (!FreeImage.SaveEx(ref dib, "example03.hdr", true)) + { + Console.WriteLine("Saving 'example03.hdr' failed."); + FreeImage.UnloadEx(ref dib); + } + } + } +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..96b32c1 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("7139f1dc-3312-4c76-aeb3-891f869409b3")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Sample 03 - Allocating.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Sample 03 - Allocating.2005.csproj new file mode 100644 index 0000000..a836a07 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Sample 03 - Allocating.2005.csproj @@ -0,0 +1,91 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9} + Exe + Properties + Sample03 + Sample03 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Sample 03 - Allocating.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Sample 03 - Allocating.csproj new file mode 100644 index 0000000..ae8324c --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 03 - Allocating/Sample 03 - Allocating.csproj @@ -0,0 +1,96 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {A7E452A1-1A43-47C4-8BF3-DA28E1402FB9} + Exe + Properties + Sample03 + Sample03 + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/MainForm.Designer.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/MainForm.Designer.cs new file mode 100644 index 0000000..9ddcf38 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/MainForm.Designer.cs @@ -0,0 +1,205 @@ +namespace Sample04 +{ + partial class MainForm + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.ofd = new System.Windows.Forms.OpenFileDialog(); + this.bOpenFile = new System.Windows.Forms.Button(); + this.lWidth = new System.Windows.Forms.Label(); + this.lHeight = new System.Windows.Forms.Label(); + this.lBPP = new System.Windows.Forms.Label(); + this.lRedMask = new System.Windows.Forms.Label(); + this.lGreenMask = new System.Windows.Forms.Label(); + this.lBlueMask = new System.Windows.Forms.Label(); + this.lImageType = new System.Windows.Forms.Label(); + this.lDPIY = new System.Windows.Forms.Label(); + this.lDPIX = new System.Windows.Forms.Label(); + this.lFormat = new System.Windows.Forms.Label(); + this.lHeader = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // ofd + // + this.ofd.Filter = "All files (*.*)|*.*"; + // + // bOpenFile + // + this.bOpenFile.Location = new System.Drawing.Point(12, 358); + this.bOpenFile.Name = "bOpenFile"; + this.bOpenFile.Size = new System.Drawing.Size(75, 23); + this.bOpenFile.TabIndex = 4; + this.bOpenFile.Text = "Open file"; + this.bOpenFile.UseVisualStyleBackColor = true; + this.bOpenFile.Click += new System.EventHandler(this.bOpenFile_Click); + // + // lWidth + // + this.lWidth.AutoSize = true; + this.lWidth.Location = new System.Drawing.Point(9, 51); + this.lWidth.Name = "lWidth"; + this.lWidth.Size = new System.Drawing.Size(46, 16); + this.lWidth.TabIndex = 0; + this.lWidth.Text = "Width:"; + // + // lHeight + // + this.lHeight.AutoSize = true; + this.lHeight.Location = new System.Drawing.Point(9, 76); + this.lHeight.Name = "lHeight"; + this.lHeight.Size = new System.Drawing.Size(53, 16); + this.lHeight.TabIndex = 1; + this.lHeight.Text = "Height: "; + // + // lBPP + // + this.lBPP.AutoSize = true; + this.lBPP.Location = new System.Drawing.Point(9, 101); + this.lBPP.Name = "lBPP"; + this.lBPP.Size = new System.Drawing.Size(80, 16); + this.lBPP.TabIndex = 2; + this.lBPP.Text = "Color Depth:"; + // + // lRedMask + // + this.lRedMask.AutoSize = true; + this.lRedMask.Location = new System.Drawing.Point(9, 129); + this.lRedMask.Name = "lRedMask"; + this.lRedMask.Size = new System.Drawing.Size(68, 16); + this.lRedMask.TabIndex = 3; + this.lRedMask.Text = "Red Mask:"; + // + // lGreenMask + // + this.lGreenMask.AutoSize = true; + this.lGreenMask.Location = new System.Drawing.Point(9, 188); + this.lGreenMask.Name = "lGreenMask"; + this.lGreenMask.Size = new System.Drawing.Size(80, 16); + this.lGreenMask.TabIndex = 5; + this.lGreenMask.Text = "Green Mask:"; + // + // lBlueMask + // + this.lBlueMask.AutoSize = true; + this.lBlueMask.Location = new System.Drawing.Point(9, 158); + this.lBlueMask.Name = "lBlueMask"; + this.lBlueMask.Size = new System.Drawing.Size(70, 16); + this.lBlueMask.TabIndex = 6; + this.lBlueMask.Text = "Blue Mask:"; + // + // lImageType + // + this.lImageType.AutoSize = true; + this.lImageType.Location = new System.Drawing.Point(9, 215); + this.lImageType.Name = "lImageType"; + this.lImageType.Size = new System.Drawing.Size(81, 16); + this.lImageType.TabIndex = 7; + this.lImageType.Text = "Image Type:"; + // + // lDPIY + // + this.lDPIY.AutoSize = true; + this.lDPIY.Location = new System.Drawing.Point(9, 244); + this.lDPIY.Name = "lDPIY"; + this.lDPIY.Size = new System.Drawing.Size(43, 16); + this.lDPIY.TabIndex = 8; + this.lDPIY.Text = "DPI Y:"; + // + // lDPIX + // + this.lDPIX.AutoSize = true; + this.lDPIX.Location = new System.Drawing.Point(9, 273); + this.lDPIX.Name = "lDPIX"; + this.lDPIX.Size = new System.Drawing.Size(44, 16); + this.lDPIX.TabIndex = 9; + this.lDPIX.Text = "DPI X:"; + // + // lFormat + // + this.lFormat.AutoSize = true; + this.lFormat.Location = new System.Drawing.Point(9, 302); + this.lFormat.Name = "lFormat"; + this.lFormat.Size = new System.Drawing.Size(78, 16); + this.lFormat.TabIndex = 10; + this.lFormat.Text = "File Format:"; + // + // lHeader + // + this.lHeader.AutoSize = true; + this.lHeader.Location = new System.Drawing.Point(117, 19); + this.lHeader.Name = "lHeader"; + this.lHeader.Size = new System.Drawing.Size(162, 16); + this.lHeader.TabIndex = 11; + this.lHeader.Text = "Bitmap-Information Viewer"; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(400, 393); + this.Controls.Add(this.lHeader); + this.Controls.Add(this.lFormat); + this.Controls.Add(this.lDPIX); + this.Controls.Add(this.lDPIY); + this.Controls.Add(this.lImageType); + this.Controls.Add(this.lBlueMask); + this.Controls.Add(this.lGreenMask); + this.Controls.Add(this.bOpenFile); + this.Controls.Add(this.lRedMask); + this.Controls.Add(this.lBPP); + this.Controls.Add(this.lHeight); + this.Controls.Add(this.lWidth); + this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MainForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Sample04"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.OpenFileDialog ofd; + private System.Windows.Forms.Button bOpenFile; + private System.Windows.Forms.Label lWidth; + private System.Windows.Forms.Label lHeight; + private System.Windows.Forms.Label lBPP; + private System.Windows.Forms.Label lRedMask; + private System.Windows.Forms.Label lGreenMask; + private System.Windows.Forms.Label lBlueMask; + private System.Windows.Forms.Label lImageType; + private System.Windows.Forms.Label lDPIY; + private System.Windows.Forms.Label lDPIX; + private System.Windows.Forms.Label lFormat; + private System.Windows.Forms.Label lHeader; + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/MainForm.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/MainForm.cs new file mode 100644 index 0000000..21e7342 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/MainForm.cs @@ -0,0 +1,120 @@ +using System; +using System.Windows.Forms; +using FreeImageAPI; + +namespace Sample04 +{ + public partial class MainForm : Form + { + string message = null; + + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + + public MainForm() + { + InitializeComponent(); + FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message); + } + + ~MainForm() + { + FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message); + } + + void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message) + { + if (this.message == null) + { + this.message = message; + } + else + { + this.message += "\n" + message; + } + } + + private void bOpenFile_Click(object sender, EventArgs e) + { + // Resetting filename + ofd.FileName = ""; + + // Was a file selected + if (ofd.ShowDialog() == DialogResult.OK) + { + // Format is stored in 'format' on successfull load. + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + + // Try loading the file + FIBITMAP dib = FreeImage.LoadEx(ofd.FileName, ref format); + + try + { + // Error handling + if (dib.IsNull) + { + // Chech whether FreeImage generated an error messe + if (message != null) + { + MessageBox.Show("File could not be loaded!\nError:{0}", message); + } + else + { + MessageBox.Show("File could not be loaded!", message); + } + return; + } + + // Read width + lWidth.Text = String.Format("Width: {0}", FreeImage.GetWidth(dib)); + + // Read height + lHeight.Text = String.Format("Height: {0}", FreeImage.GetHeight(dib)); + + // Read color depth + lBPP.Text = String.Format("Color Depth: {0}", FreeImage.GetBPP(dib)); + + // Read red bitmask (16 - 32 bpp) + lRedMask.Text = String.Format("Red Mask: 0x{0:X8}", FreeImage.GetRedMask(dib)); + + // Read green bitmask (16 - 32 bpp) + lBlueMask.Text = String.Format("Green Mask: 0x{0:X8}", FreeImage.GetGreenMask(dib)); + + // Read blue bitmask (16 - 32 bpp) + lGreenMask.Text = String.Format("Blue Mask: 0x{0:X8}", FreeImage.GetBlueMask(dib)); + + // Read image type (FI_BITMAP, FIT_RGB16, FIT_COMPLEX ect) + lImageType.Text = String.Format("Image Type: {0}", FreeImage.GetImageType(dib)); + + // Read x-axis dpi + lDPIX.Text = String.Format("DPI X: {0}", FreeImage.GetResolutionX(dib)); + + // Read y-axis dpi + lDPIY.Text = String.Format("DPI Y: {0}", FreeImage.GetResolutionY(dib)); + + // Read file format + lFormat.Text = String.Format("File Format: {0}", FreeImage.GetFormatFromFIF(format)); + } + catch + { + } + + // Always unload bitmap + FreeImage.UnloadEx(ref dib); + + // Reset the error massage buffer + message = null; + } + // No file was selected + else + { + MessageBox.Show("No file loaded.", "Error"); + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/MainForm.resx b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/MainForm.resx new file mode 100644 index 0000000..63f7f57 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/MainForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..eafebc8 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("7c8fdc9a-a8f9-4996-99c8-9df47513edeb")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/Sample 04 - Getting bitmap informations.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/Sample 04 - Getting bitmap informations.2005.csproj new file mode 100644 index 0000000..dcd7f10 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/Sample 04 - Getting bitmap informations.2005.csproj @@ -0,0 +1,104 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A} + WinExe + Properties + Sample04 + Sample04 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + Form + + + MainForm.cs + + + + + + Designer + MainForm.cs + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/Sample 04 - Getting bitmap informations.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/Sample 04 - Getting bitmap informations.csproj new file mode 100644 index 0000000..009f830 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 04 - Getting bitmap informations/Sample 04 - Getting bitmap informations.csproj @@ -0,0 +1,109 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A} + WinExe + Properties + Sample04 + Sample04 + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + Form + + + MainForm.cs + + + + + + Designer + MainForm.cs + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Program.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Program.cs new file mode 100644 index 0000000..de6819f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Program.cs @@ -0,0 +1,213 @@ +using System; +using FreeImageAPI; +using System.Drawing; + +namespace Sample05 +{ + class Program + { + static void Main(string[] args) + { + // Check if FreeImage.dll is available (can be in %path%). + if (!FreeImage.IsAvailable()) + { + Console.WriteLine("FreeImage.dll seems to be missing. Aborting."); + return; + } + + Sample sample = new Sample(); + + // The example will flip the bitmap by manually accessing the + // bitmaps scanlines and swapping them + sample.Example01(); + + // The example will access each pixel of the bitmap manually + // and change its color intensity to 3/4 of the original value + // which will have a darker bitmap as result. + sample.Example02(); + + // The example will access and swap the bitmaps palette from + // 'FIC_MINISBLACK' to 'FIC_MINISWHITE'. Then it will swap each pixels + // palette index so that each pixel is assigned to the its old value + // so that the bitmaps "pixeldata" stays the same. + sample.Example03(); + } + } + + public class Sample + { + FIBITMAP dib = new FIBITMAP(); + + public void Example01() + { + // Load sample file + dib = FreeImage.LoadEx("Sample.jpg", FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE); + + // Check whether loading succeeded + if (dib.IsNull) + { + Console.WriteLine("Sample.jpg could not be loaded. Aborting."); + return; + } + + // Check whether the bitmap has 24 bpp color depth to ensure + // using RGBTRIPPLE is correct. + if (FreeImage.GetBPP(dib) != 24) + { + Console.WriteLine("Sample.jpg is no 24 bpp bitmap. Aborting."); + FreeImage.UnloadEx(ref dib); + return; + } + + // Store height of the bitmap + int height = (int)FreeImage.GetHeight(dib); + + // Iterate over half of the bitmaps scanlines and swap + // line[1] with line[height], line[2] with line[height-1] etc which will + // flip the image. + for (int i = 0; i < (height / 2); i++) + { + // Get scanline from the bottom part of the bitmap + Scanline scanlineBottom = new Scanline(dib, i); + + // Get scanline from the top part of the bitmap + Scanline scanlineTop = new Scanline(dib, height - 1 - i); + + // Get arrays of RGBTRIPPLEs that contain the bitmaps real pixel data + // of the two scanlines. + RGBTRIPLE[] rgbtBottom = scanlineBottom.Data; + RGBTRIPLE[] rgbtTop = scanlineTop.Data; + + // Restore the scanline across to switch the bitmaps lines. + scanlineBottom.Data = rgbtTop; + scanlineTop.Data = rgbtBottom; + } + + // Store the bitmap to disk + if (!FreeImage.SaveEx(ref dib, "SampleOut01.jpg", FREE_IMAGE_SAVE_FLAGS.JPEG_QUALITYGOOD, true)) + { + Console.WriteLine("Error while saving 'SampleOut01.jpg'"); + FreeImage.UnloadEx(ref dib); + } + } + + public void Example02() + { + dib = FreeImage.LoadEx("Sample.jpg", FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE); + + // Check whether loading succeeded + if (dib.IsNull) + { + Console.WriteLine("Sample.jpg could not be loaded. Aborting."); + return; + } + + // Check whether the bitmap has 24 bpp color depth to ensure + // using RGBTRIPPLE is correct. + if (FreeImage.GetBPP(dib) != 24) + { + Console.WriteLine("Sample.jpg is no 24 bpp bitmap. Aborting."); + FreeImage.UnloadEx(ref dib); + return; + } + + // Iterate over all scanlines + for (int i = 0; i < FreeImage.GetHeight(dib); i++) + { + // Get scanline + Scanline scanline = new Scanline(dib, i); + + // Get pixeldata from scanline + RGBTRIPLE[] rgbt = scanline.Data; + + // Iterate over each pixel reducing the colors intensity to 3/4 which + // will darken the bitmap. + for (int j = 0; j < rgbt.Length; j++) + { + rgbt[j].rgbtBlue = (byte)((int)rgbt[j].rgbtBlue * 3 / 4); + rgbt[j].rgbtGreen = (byte)((int)rgbt[j].rgbtGreen * 3 / 4); + rgbt[j].rgbtRed = (byte)((int)rgbt[j].rgbtRed * 3 / 4); + + // In case no direct access to the data is implemented + // the following way is equivalent: + // + // Color color = rgbt[j].color; + // rgbt[j].color = Color.FromArgb(color.R * 3 / 4, color.G * 3 / 4, color.B * 3 / 4); + } + + // Write the darkened scanline back to memory + scanline.Data = rgbt; + } + + // Store the bitmap to disk + if (!FreeImage.SaveEx(ref dib, "SampleOut02.jpg", FREE_IMAGE_SAVE_FLAGS.JPEG_QUALITYGOOD, true)) + { + Console.WriteLine("Error while saving 'SampleOut02.jpg'"); + FreeImage.UnloadEx(ref dib); + } + } + + public void Example03() + { + dib = FreeImage.LoadEx("Sample.tif"); + + // Check whether loading succeeded + if (dib.IsNull) + { + Console.WriteLine("Sample.tif could not be loaded. Aborting."); + return; + } + + // Check whether the bitmap has 4 bpp color depth to ensure + // using FI4B is correct. + if (FreeImage.GetBPP(dib) != 4) + { + Console.WriteLine("Sample.tif is no 4 bpp bitmap. Aborting."); + FreeImage.UnloadEx(ref dib); + return; + } + + // Get the bitmaps palette + Palette palette = FreeImage.GetPaletteEx(dib); + + int size = (int)palette.Length; + + // Check whether the palette has a color (is valid) + if (size == 0) + { + Console.WriteLine("Sample.tif has no valid palette. Aborting."); + FreeImage.UnloadEx(ref dib); + return; + } + + // Swapping the palette + for (int i = 0; i < size / 2; i++) + { + RGBQUAD temp = palette[i]; + palette[i] = palette[size - 1 - i]; + palette[size - 1 - i] = temp; + } + + // Iterate over each scanline + for (int i = 0; i < FreeImage.GetHeight(dib); i++) + { + // Get scanline + Scanline scanline = new Scanline(dib, i); + + // Iterate over all pixels swapping the palette index + // so that the color will stay the same + for (int j = 0; j < scanline.Length; j++) + { + scanline[j] = (byte)(size - 1 - scanline[j]); + } + } + + // Save the bitmap to disk + if (!FreeImage.SaveEx(ref dib, "SampleOut03.tif", FREE_IMAGE_SAVE_FLAGS.TIFF_LZW, true)) + { + Console.WriteLine("Error while saving 'SampleOut03.tif'"); + FreeImage.UnloadEx(ref dib); + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7dd2e1a --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("fd43331d-5ea4-40f8-86d5-8f820d606912")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample 05 - Working with pixels.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample 05 - Working with pixels.2005.csproj new file mode 100644 index 0000000..6483373 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample 05 - Working with pixels.2005.csproj @@ -0,0 +1,100 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {A501F134-8FB6-460B-AFE9-884A696C1C07} + Exe + Properties + Sample05 + Sample05 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + + + Always + + + Always + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample 05 - Working with pixels.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample 05 - Working with pixels.csproj new file mode 100644 index 0000000..b5a9d36 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample 05 - Working with pixels.csproj @@ -0,0 +1,105 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {A501F134-8FB6-460B-AFE9-884A696C1C07} + Exe + Properties + Sample05 + Sample05 + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + + + Always + + + Always + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample.jpg b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample.jpg new file mode 100644 index 0000000..df1918c Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample.jpg differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample.tif b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample.tif new file mode 100644 index 0000000..7b37c6b Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 05 - Working with pixels/Sample.tif differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/MainForm.Designer.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/MainForm.Designer.cs new file mode 100644 index 0000000..fd131e6 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/MainForm.Designer.cs @@ -0,0 +1,120 @@ +namespace Sample06 +{ + partial class MainForm + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.picBox = new System.Windows.Forms.PictureBox(); + this.bExample01 = new System.Windows.Forms.Button(); + this.bOriginal = new System.Windows.Forms.Button(); + this.bExample02 = new System.Windows.Forms.Button(); + this.bExample03 = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.picBox)).BeginInit(); + this.SuspendLayout(); + // + // picBox + // + this.picBox.BackColor = System.Drawing.Color.White; + this.picBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picBox.Location = new System.Drawing.Point(12, 12); + this.picBox.Name = "picBox"; + this.picBox.Size = new System.Drawing.Size(747, 465); + this.picBox.TabIndex = 0; + this.picBox.TabStop = false; + // + // bExample01 + // + this.bExample01.Location = new System.Drawing.Point(93, 483); + this.bExample01.Name = "bExample01"; + this.bExample01.Size = new System.Drawing.Size(88, 23); + this.bExample01.TabIndex = 1; + this.bExample01.Text = "Example 01"; + this.bExample01.UseVisualStyleBackColor = true; + this.bExample01.Click += new System.EventHandler(this.bExample01_Click); + // + // bOriginal + // + this.bOriginal.Location = new System.Drawing.Point(12, 483); + this.bOriginal.Name = "bOriginal"; + this.bOriginal.Size = new System.Drawing.Size(75, 23); + this.bOriginal.TabIndex = 2; + this.bOriginal.Text = "Original"; + this.bOriginal.UseVisualStyleBackColor = true; + this.bOriginal.Click += new System.EventHandler(this.bOriginal_Click); + // + // bExample02 + // + this.bExample02.Location = new System.Drawing.Point(187, 483); + this.bExample02.Name = "bExample02"; + this.bExample02.Size = new System.Drawing.Size(88, 23); + this.bExample02.TabIndex = 3; + this.bExample02.Text = "Example 02"; + this.bExample02.UseVisualStyleBackColor = true; + this.bExample02.Click += new System.EventHandler(this.bExample02_Click); + // + // bExample03 + // + this.bExample03.Location = new System.Drawing.Point(281, 483); + this.bExample03.Name = "bExample03"; + this.bExample03.Size = new System.Drawing.Size(88, 23); + this.bExample03.TabIndex = 4; + this.bExample03.Text = "Example 03"; + this.bExample03.UseVisualStyleBackColor = true; + this.bExample03.Click += new System.EventHandler(this.bExample03_Click); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(771, 518); + this.Controls.Add(this.bExample03); + this.Controls.Add(this.bExample02); + this.Controls.Add(this.bOriginal); + this.Controls.Add(this.bExample01); + this.Controls.Add(this.picBox); + this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MainForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Sample06"; + ((System.ComponentModel.ISupportInitialize)(this.picBox)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.PictureBox picBox; + private System.Windows.Forms.Button bExample01; + private System.Windows.Forms.Button bOriginal; + private System.Windows.Forms.Button bExample02; + private System.Windows.Forms.Button bExample03; + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/MainForm.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/MainForm.cs new file mode 100644 index 0000000..125b9c3 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/MainForm.cs @@ -0,0 +1,177 @@ +using System; +using System.Drawing; +using System.Windows.Forms; +using FreeImageAPI; +using System.Drawing.Imaging; + +namespace Sample06 +{ + public partial class MainForm : Form + { + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + + public MainForm() + { + InitializeComponent(); + } + + private void bExample01_Click(object sender, EventArgs e) + { + // Load bitmap + FIBITMAP dib = FreeImage.LoadEx("Sample.jpg"); + + // Check success + if (dib.IsNull) + { + MessageBox.Show("Could not load Sample.jpg", "Error"); + return; + } + + // Check whether bitmap is 24-bit + if (FreeImage.GetBPP(dib) != 24) + { + MessageBox.Show("Sample.jpg is not 24-bit.", "Error"); + FreeImage.UnloadEx(ref dib); + return; + } + + // Convert the 24-bit bitmap to 8-bit and forcing the result will be greyscale + dib = FreeImage.ConvertColorDepth(dib, FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP | FREE_IMAGE_COLOR_DEPTH.FICD_FORCE_GREYSCALE, true); + + if (FreeImage.GetBPP(dib) == 8) + { + // Convert the FreeImage-Bitmap into a .NET bitmap + Bitmap bitmap = FreeImage.GetBitmap(dib); + + // Dispose the bitmap of the pictureBox + if (picBox.Image != null) + { + picBox.Image.Dispose(); + } + + // Assign the bitmap to the picturebox + picBox.Image = bitmap; + } + + // Unload source bitmap + FreeImage.UnloadEx(ref dib); + } + + private void bOriginal_Click(object sender, EventArgs e) + { + // Load bitmap + FIBITMAP dib = FreeImage.LoadEx("Sample.jpg"); + + // Check success + if (dib.IsNull) + { + MessageBox.Show("Could not load Sample.jpg", "Error"); + return; + } + + // Convert the FreeImage-Bitmap into a .NET bitmap + Bitmap bitmap = FreeImage.GetBitmap(dib); + + // Check success + if (bitmap != null) + { + // Dispose old bitmap + if (picBox.Image != null) + { + picBox.Image.Dispose(); + } + + // Assign new bitmap + picBox.Image = bitmap; + } + + // Unload bitmap + FreeImage.UnloadEx(ref dib); + } + + private void bExample02_Click(object sender, EventArgs e) + { + FIBITMAP dib = FreeImage.LoadEx("Sample.jpg"); + + // Check success + if (dib.IsNull) + { + MessageBox.Show("Could not load Sample.jpg", "Error"); + return; + } + + // Convert bitmap to 8 bit + dib = FreeImage.ConvertColorDepth(dib, FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP, true); + + // Check whether conversion succeeded + if (FreeImage.GetBPP(dib) != 8) + { + MessageBox.Show("Converting Sample.jpg to 8-bit failed.", "Error"); + FreeImage.UnloadEx(ref dib); + return; + } + + // Convert the FreeImage-Bitmap into a .NET bitmap + Bitmap bitmap = FreeImage.GetBitmap(dib); + + // Dispose old bitmap + if (picBox.Image != null) + { + picBox.Image.Dispose(); + } + + // Assign new bitmap + picBox.Image = bitmap; + + // Unload bitmap + FreeImage.UnloadEx(ref dib); + } + + private void bExample03_Click(object sender, EventArgs e) + { + // Load bitmap + Bitmap bitmap = (Bitmap)Bitmap.FromFile("Sample.jpg"); + + // Convert the .NET bitmap into a FreeImage-Bitmap + FIBITMAP dib = FreeImage.CreateFromBitmap(bitmap); + + // Unload bitmap + bitmap.Dispose(); + + // Rescale the bitmap + FIBITMAP temp = FreeImage.Rescale(dib, 300, 300, FREE_IMAGE_FILTER.FILTER_BICUBIC); + + // Unload bitmap + FreeImage.UnloadEx(ref dib); + + Random rand = new Random(); + + // Rotate the bitmap + dib = FreeImage.Rotate(temp, rand.NextDouble() * 360d); + + // Unload bitmap + FreeImage.UnloadEx(ref temp); + + // Convert the FreeImage-Bitmap into a .NET bitmap + bitmap = FreeImage.GetBitmap(dib); + + // Unload bitmap + FreeImage.UnloadEx(ref dib); + + // Unload bitmap + if (picBox.Image != null) + { + picBox.Image.Dispose(); + } + + // Assign new bitmap + picBox.Image = bitmap; + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/MainForm.resx b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/MainForm.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..18e8904 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("69a8cbdd-43da-49e3-8d0b-2680c4ca2851")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Sample 06 - Converting.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Sample 06 - Converting.2005.csproj new file mode 100644 index 0000000..df1703b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Sample 06 - Converting.2005.csproj @@ -0,0 +1,109 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81} + WinExe + Properties + Sample06 + Sample06 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + Form + + + MainForm.cs + + + + + + Designer + MainForm.cs + + + + + Always + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Sample 06 - Converting.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Sample 06 - Converting.csproj new file mode 100644 index 0000000..1ff53b4 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Sample 06 - Converting.csproj @@ -0,0 +1,114 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81} + WinExe + Properties + Sample06 + Sample06 + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + Form + + + MainForm.cs + + + + + + Designer + MainForm.cs + + + + + Always + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Sample.jpg b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Sample.jpg new file mode 100644 index 0000000..b537c00 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 06 - Converting/Sample.jpg differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Program.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Program.cs new file mode 100644 index 0000000..1b1732f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Program.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using FreeImageAPI; + +namespace Sample07 +{ + class Program + { + static void Main(string[] args) + { + // Check if FreeImage.dll is available (can be in %path%). + if (!FreeImage.IsAvailable()) + { + Console.WriteLine("FreeImage.dll seems to be missing. Aborting."); + return; + } + + Sample sample = new Sample(); + // This example shows how to work with ICC-Profiles. + sample.Example(); + } + } + + public class Sample + { + public void Example() + { + // Load the sample bitmap. + FIBITMAP dib = FreeImage.LoadEx("Sample.jpg"); + + // Check success + if (dib.IsNull) + { + Console.WriteLine("Sample.jpg could not be loaded. Aborting."); + return; + } + + // Get the bitmaps ICC-Profile. + FIICCPROFILE icc = FreeImage.GetICCProfileEx(dib); + + // Print the profiles address. + Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X")); + + // Print the profiles size + Console.WriteLine("The profiles size is : {0} bytes", icc.Size); + + // Create data for a new profile. + byte[] data = new byte[256]; + for (int i = 0; i < data.Length; i++) + data[i] = (byte)i; + + // Create the new profile + icc = new FIICCPROFILE(dib, data); + + Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X")); + Console.WriteLine("The profiles size is : {0} bytes", icc.Size); + + // Create the new profile but only use the first 64 bytes + icc = new FIICCPROFILE(dib, data, 64); + + Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X")); + Console.WriteLine("The profiles size is : {0} bytes", icc.Size); + + // CreateICCProfileEx(...) does the same as above + icc = FreeImage.CreateICCProfileEx(dib, data, 16); + + Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X")); + Console.WriteLine("The profiles size is : {0} bytes", icc.Size); + + FreeImage.UnloadEx(ref dib); + } + } +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d7f3a03 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("c9991d1d-684a-4736-b088-369a216b35b6")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Sample 07 - ICC Profiles.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Sample 07 - ICC Profiles.2005.csproj new file mode 100644 index 0000000..ba97bbe --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Sample 07 - ICC Profiles.2005.csproj @@ -0,0 +1,96 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E} + Exe + Properties + Sample07 + Sample07 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + + Always + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Sample 07 - ICC Profiles.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Sample 07 - ICC Profiles.csproj new file mode 100644 index 0000000..02a824f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Sample 07 - ICC Profiles.csproj @@ -0,0 +1,101 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {3B1BB976-64A7-41FD-B7E2-59104161AF7E} + Exe + Properties + Sample07 + Sample07 + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + + Always + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Sample.jpg b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Sample.jpg new file mode 100644 index 0000000..c9e425d Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Sample.jpg differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2db8f57 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("dc891ffc-ab5c-451f-97da-2c0d5d90edcc")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Sample 08 - Creating a plugin.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Sample 08 - Creating a plugin.2005.csproj new file mode 100644 index 0000000..763a8e5 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Sample 08 - Creating a plugin.2005.csproj @@ -0,0 +1,110 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {491042DB-495B-420C-A3BE-5D13019707C5} + WinExe + Properties + Sample08 + Sample08 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + Form + + + SampleForm.cs + + + + + + Always + + + + + SampleForm.cs + Designer + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Sample 08 - Creating a plugin.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Sample 08 - Creating a plugin.csproj new file mode 100644 index 0000000..83039d4 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Sample 08 - Creating a plugin.csproj @@ -0,0 +1,115 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {491042DB-495B-420C-A3BE-5D13019707C5} + WinExe + Properties + Sample08 + Sample08 + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + Form + + + SampleForm.cs + + + + + + Always + + + + + SampleForm.cs + Designer + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Sample.jpg b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Sample.jpg new file mode 100644 index 0000000..b537c00 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/Sample.jpg differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SampleForm.Designer.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SampleForm.Designer.cs new file mode 100644 index 0000000..4eafbae --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SampleForm.Designer.cs @@ -0,0 +1,119 @@ +namespace Sample08 +{ + partial class SampleForm + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.pictureBox = new System.Windows.Forms.PictureBox(); + this.bLoad = new System.Windows.Forms.Button(); + this.SaveToSer = new System.Windows.Forms.Button(); + this.LoadSerBitmap = new System.Windows.Forms.Button(); + this.bClearBitmap = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.SuspendLayout(); + // + // pictureBox + // + this.pictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.pictureBox.Location = new System.Drawing.Point(12, 12); + this.pictureBox.Name = "pictureBox"; + this.pictureBox.Size = new System.Drawing.Size(600, 400); + this.pictureBox.TabIndex = 0; + this.pictureBox.TabStop = false; + // + // bLoad + // + this.bLoad.Location = new System.Drawing.Point(12, 418); + this.bLoad.Name = "bLoad"; + this.bLoad.Size = new System.Drawing.Size(98, 23); + this.bLoad.TabIndex = 1; + this.bLoad.Text = "Load any bitmap"; + this.bLoad.UseVisualStyleBackColor = true; + this.bLoad.Click += new System.EventHandler(this.bLoad_Click); + // + // SaveToSer + // + this.SaveToSer.Location = new System.Drawing.Point(324, 418); + this.SaveToSer.Name = "SaveToSer"; + this.SaveToSer.Size = new System.Drawing.Size(98, 23); + this.SaveToSer.TabIndex = 2; + this.SaveToSer.Text = "Save as .ser"; + this.SaveToSer.UseVisualStyleBackColor = true; + this.SaveToSer.Click += new System.EventHandler(this.SaveToSer_Click); + // + // LoadSerBitmap + // + this.LoadSerBitmap.Location = new System.Drawing.Point(220, 418); + this.LoadSerBitmap.Name = "LoadSerBitmap"; + this.LoadSerBitmap.Size = new System.Drawing.Size(98, 23); + this.LoadSerBitmap.TabIndex = 3; + this.LoadSerBitmap.Text = "Load .ser bitmap"; + this.LoadSerBitmap.UseVisualStyleBackColor = true; + this.LoadSerBitmap.Click += new System.EventHandler(this.LoadSerBitmap_Click); + // + // bClearBitmap + // + this.bClearBitmap.Location = new System.Drawing.Point(116, 418); + this.bClearBitmap.Name = "bClearBitmap"; + this.bClearBitmap.Size = new System.Drawing.Size(98, 23); + this.bClearBitmap.TabIndex = 4; + this.bClearBitmap.Text = "Clear screen"; + this.bClearBitmap.UseVisualStyleBackColor = true; + this.bClearBitmap.Click += new System.EventHandler(this.bClearBitmap_Click); + // + // SampleForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(627, 448); + this.Controls.Add(this.bClearBitmap); + this.Controls.Add(this.LoadSerBitmap); + this.Controls.Add(this.SaveToSer); + this.Controls.Add(this.bLoad); + this.Controls.Add(this.pictureBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SampleForm"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Sample 08"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox; + private System.Windows.Forms.Button bLoad; + private System.Windows.Forms.Button SaveToSer; + private System.Windows.Forms.Button LoadSerBitmap; + private System.Windows.Forms.Button bClearBitmap; + } +} + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SampleForm.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SampleForm.cs new file mode 100644 index 0000000..2551f0e --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SampleForm.cs @@ -0,0 +1,217 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using FreeImageAPI; +using System.Runtime.InteropServices; +using System.Security.Permissions; + +namespace Sample08 +{ + public partial class SampleForm : Form + { + SerializationPlugin serialPlugin; + + [STAThread] + static void Main() + { + // Check if FreeImage is available + if (!FreeImage.IsAvailable()) + { + throw new Exception("FreeImage is not available!"); + } + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new SampleForm()); + } + + public SampleForm() + { + InitializeComponent(); + FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message); + + // Creating a new instance of the plugin will register it automatically. + serialPlugin = new SerializationPlugin(); + } + + void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message) + { + // Show the message + MessageBox.Show(String.Format("Format: {0}\nMessage: {1}", fif, message), "FreeImage Message"); + } + + private void bLoad_Click(object sender, EventArgs e) + { + // Create a new dialog instance + OpenFileDialog ofd = new OpenFileDialog(); + try + { + // Apply settings + ofd.CheckPathExists = true; + ofd.CheckFileExists = true; + ofd.RestoreDirectory = true; + ofd.Filter = "All files (*.*)|*.*"; + + // Get filename + if (ofd.ShowDialog(this) == DialogResult.OK) + { + Bitmap bitmap = null; + try + { + // Try loading the selected file + // a ser-file will create an exception + bitmap = (Bitmap)Bitmap.FromFile(ofd.FileName); + } + catch + { + MessageBox.Show("Unable to load bitmap from file.", "Error"); + return; + } + + // Unload old bitmap + if (pictureBox.Image != null) + { + pictureBox.Image.Dispose(); + } + + // Set new bitmap + pictureBox.Image = bitmap; + MessageBox.Show("Bitmap loaded successfully", "Success"); + } + else + { + MessageBox.Show("Action aborted."); + } + } + finally + { + // Unload dialog + ofd.Dispose(); + } + } + + private void LoadSerBitmap_Click(object sender, EventArgs e) + { + // Creat a new dialog + OpenFileDialog ofd = new OpenFileDialog(); + + FIBITMAP dib = new FIBITMAP(); + try + { + // Apply settings + ofd.CheckPathExists = true; + ofd.CheckFileExists = true; + ofd.RestoreDirectory = true; + ofd.Filter = "Serialized bitmap (*.ser)|*.ser"; + + // Get filename + if (ofd.ShowDialog() == DialogResult.OK) + { + // Try loading the file forcing the new format + dib = FreeImage.Load(serialPlugin.Format, ofd.FileName, FREE_IMAGE_LOAD_FLAGS.DEFAULT); + if (dib.IsNull) + { + MessageBox.Show("Loading bitmap failed", "Error"); + return; + } + + // Convert the loaded bitmap into a .NET bitmap + Bitmap bitmap = FreeImage.GetBitmap(dib); + if (bitmap == null) + { + MessageBox.Show("Converting bitmap failed.", "Error"); + return; + } + + // Unload the picturebox + if (pictureBox.Image != null) + { + pictureBox.Image.Dispose(); + } + + // Apply the loaded bitmap + pictureBox.Image = bitmap; + MessageBox.Show("Bitmap loaded successfully", "Success"); + } + else + { + MessageBox.Show("Action aborted."); + } + } + finally + { + // Unload bitmap + FreeImage.UnloadEx(ref dib); + + // Unload dialog + ofd.Dispose(); + } + } + + private void SaveToSer_Click(object sender, EventArgs e) + { + // Create a new dialog + SaveFileDialog sfd = new SaveFileDialog(); + + FIBITMAP dib = new FIBITMAP(); + try + { + // Check if the picture box contains a bitmap that can be saved. + if (pictureBox.Image == null) + { + MessageBox.Show("No bitmap loaded.", "Error"); + return; + } + + // Convert the picture-boxes bitmap into a FreeImage bitmap. + dib = FreeImage.CreateFromBitmap((Bitmap)pictureBox.Image); + if (dib.IsNull) + { + MessageBox.Show("Unable to convert bitmap to FIBITMAP.", "Error"); + return; + } + + // Apply settings + sfd.Filter = "Serialized bitmap (*.ser)|*.ser"; + sfd.FileName = "Bitmap.ser"; + sfd.OverwritePrompt = true; + sfd.RestoreDirectory = true; + + // Get filename + if (sfd.ShowDialog() == DialogResult.OK) + { + // Save bitmap in the new format + if (FreeImage.SaveEx(dib, sfd.FileName, serialPlugin.Format)) + MessageBox.Show("Bitmap saved successfully.", "Success"); + else + MessageBox.Show("Saving bitmap failed.", "Failure"); + } + else + { + MessageBox.Show("Action aborted."); + } + } + finally + { + // Unload bitmap + FreeImage.UnloadEx(ref dib); + + // Unload dialog + sfd.Dispose(); + } + } + + private void bClearBitmap_Click(object sender, EventArgs e) + { + // Unload the picture-box + if (pictureBox.Image != null) + { + pictureBox.Image.Dispose(); + pictureBox.Image = null; + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SampleForm.resx b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SampleForm.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SampleForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SerializationPlugin.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SerializationPlugin.cs new file mode 100644 index 0000000..96043e0 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 08 - Creating a plugin/SerializationPlugin.cs @@ -0,0 +1,222 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using System.Runtime.Serialization.Formatters.Binary; +using System.IO; +using System.IO.Compression; +using FreeImageAPI; +using FreeImageAPI.IO; +using FreeImageAPI.Plugins; + +namespace Sample08 +{ + public sealed class SerializationPlugin : LocalPlugin + { + // Header for the file + private byte[] header = new byte[] { 0xff, 0x12, 0x0f, 0xff, 0x01, 0x00 }; + + // Structure that will store all bitmap data. + [Serializable] + private struct SerialDib + { + public uint width; + public uint height; + public int pitch; + public uint bpp; + public uint red_mask; + public uint green_mask; + public uint blue_mask; + public byte[] data; + } + + // Implementation of 'GetImplementedMethods()' + // All implemented methods are listed. + protected override LocalPlugin.MethodFlags GetImplementedMethods() + { + return + MethodFlags.DescriptionProc | + MethodFlags.SupportsExportBPPProc | + MethodFlags.SupportsExportTypeProc | + MethodFlags.SupportsICCProfilesProc | + MethodFlags.LoadProc | + MethodFlags.SaveProc | + MethodFlags.ValidateProc | + MethodFlags.ExtensionListProc; + } + + // Returns a format string. + protected override string FormatProc() + { + return "Serialization"; + } + + // Returns a more specific description + protected override string DescriptionProc() + { + return "Serializes bitmaps for .NET"; + } + + // Returns whether a color depth is supported. + protected override bool SupportsExportBPPProc(int bpp) + { + return ((bpp == 1) || + (bpp == 4) || + (bpp == 8) || + (bpp == 16) || + (bpp == 24) || + (bpp == 32)); + } + + // This plugin can only export standard bitmaps + protected override bool SupportsExportTypeProc(FREE_IMAGE_TYPE type) + { + return (type == FREE_IMAGE_TYPE.FIT_BITMAP); + } + + // This plugin does not support icc profiles + protected override bool SupportsICCProfilesProc() + { + return false; + } + + // The function reads the first bytes of the file and compares it + // with the predefined header. + protected override bool ValidateProc(ref FreeImageIO io, fi_handle handle) + { + for (int i = 0; i < header.Length; i++) + if (ReadByte(io, handle) != header[i]) + return false; + return true; + } + + // Loading function + protected override FIBITMAP LoadProc(ref FreeImageIO io, fi_handle handle, int page, int flags, IntPtr data) + { + // Check if the data has the correct format + if (!ValidateProc(ref io, handle)) + { + // Create a free-image message + FreeImage.OutputMessageProc(format, "Invalid format."); + // return 0 (operation failed) + return FIBITMAP.Zero; + } + + SerialDib sdib; + int read = 0; + System.IO.MemoryStream stream = new System.IO.MemoryStream(); + byte[] buffer = new byte[1024]; + + do + { + // Use the helper function 'Read' to read from the source + read = Read(io, handle, 1, 1024, ref buffer); + + // Store the data in a temporary buffer + stream.Write(buffer, 0, read); + } + while (read != 0); + + // Set the memory stream back to the beginning. + stream.Position = 0; + + // Unzip the stream + GZipStream zipStream = new GZipStream(stream, CompressionMode.Decompress); + + // Create a serializer + BinaryFormatter formatter = new BinaryFormatter(); + + // Deserialize the stream + sdib = (SerialDib)formatter.Deserialize(zipStream); + + // Unload the stream + zipStream.Dispose(); + + // Use 'ConvertFromRawBits and the deserialized struct to recreate the bitmap + // In this case the marshaller is used to create the needed IntPtr to the data + // array. + FIBITMAP dib = FreeImage.ConvertFromRawBits( + Marshal.UnsafeAddrOfPinnedArrayElement(sdib.data, 0), + (int)sdib.width, (int)sdib.height, sdib.pitch, sdib.bpp, + sdib.red_mask, sdib.green_mask, sdib.blue_mask, + false); + + // Unload the temporary stream + stream.Dispose(); + + // Return the created bitmap + return dib; + } + + // Saving function + protected override bool SaveProc(ref FreeImageIO io, FIBITMAP dib, fi_handle handle, int page, int flags, IntPtr data) + { + SerialDib sdib; + uint size = FreeImage.GetDIBSize(dib); + + // Store all data needed to recreate the bitmap + sdib.width = FreeImage.GetWidth(dib); + sdib.height = FreeImage.GetHeight(dib); + sdib.pitch = (int)FreeImage.GetPitch(dib); + sdib.bpp = FreeImage.GetBPP(dib); + sdib.red_mask = FreeImage.GetRedMask(dib); + sdib.green_mask = FreeImage.GetGreenMask(dib); + sdib.blue_mask = FreeImage.GetBlueMask(dib); + sdib.data = new byte[size]; + + // Copy the bitmaps data into the structures byte-array + // The marshaller is used to create an IntPtr for using + // 'ConvertToRawBits'. + FreeImage.ConvertToRawBits(Marshal.UnsafeAddrOfPinnedArrayElement(sdib.data, 0), + dib, sdib.pitch, sdib.bpp, + sdib.red_mask, sdib.green_mask, sdib.blue_mask, + false); + + // Use the healper function to write the header to the destination + if (Write(io, handle, (uint)header.Length, 1, ref header) != 1) + return false; + + // Create a serializer + BinaryFormatter formatter = new BinaryFormatter(); + + // Create a temporary stream + MemoryStream stream = new MemoryStream(); + + // Create a compression stream + GZipStream zipStream = new GZipStream(stream, CompressionMode.Compress); + + // Serialize the structure into the compression stream + formatter.Serialize(zipStream, sdib); + + // Unload the compression stream + zipStream.Dispose(); + + // Get the result data + byte[] buffer = stream.GetBuffer(); + + // Use the healper function 'Write' to write the data to the destination + if (Write(io, handle, 1, (uint)buffer.Length, ref buffer) != buffer.Length) + { + // Unload the temporary stream + stream.Dispose(); + return false; + } + + // Unload the temporary stream + stream.Dispose(); + return true; + } + + // Return a list of supported file extensions (comma seperated) + protected override string ExtensionListProc() + { + return "ser"; + } + + // Implementation of 'ToString()' + public override string ToString() + { + return DescriptionProc(); + } + } +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..62165f0 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("7f29fbaa-d2b3-4011-b34f-5a109bc282af")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/Sample 09 - Working with streams.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/Sample 09 - Working with streams.2005.csproj new file mode 100644 index 0000000..4674213 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/Sample 09 - Working with streams.2005.csproj @@ -0,0 +1,105 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF} + WinExe + Properties + Sample09 + Sample09 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + + Form + + + SampleForm.cs + + + + + Designer + SampleForm.cs + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/Sample 09 - Working with streams.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/Sample 09 - Working with streams.csproj new file mode 100644 index 0000000..a3cea35 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/Sample 09 - Working with streams.csproj @@ -0,0 +1,110 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {92A454B2-67EF-4B70-99C9-F22B83B6FBFF} + WinExe + Properties + Sample09 + Sample09 + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + false + prompt + + + + + + + + + + + Form + + + SampleForm.cs + + + + + Designer + SampleForm.cs + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/SampleForm.Designer.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/SampleForm.Designer.cs new file mode 100644 index 0000000..cf4489d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/SampleForm.Designer.cs @@ -0,0 +1,115 @@ +namespace Sample09 +{ + partial class SampleForm + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.picBox = new System.Windows.Forms.PictureBox(); + this.tbURL = new System.Windows.Forms.TextBox(); + this.lUrl = new System.Windows.Forms.Label(); + this.bLoadUrl = new System.Windows.Forms.Button(); + this.bSave = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.picBox)).BeginInit(); + this.SuspendLayout(); + // + // picBox + // + this.picBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picBox.Location = new System.Drawing.Point(12, 12); + this.picBox.Name = "picBox"; + this.picBox.Size = new System.Drawing.Size(536, 299); + this.picBox.TabIndex = 0; + this.picBox.TabStop = false; + // + // tbURL + // + this.tbURL.Location = new System.Drawing.Point(155, 317); + this.tbURL.Name = "tbURL"; + this.tbURL.Size = new System.Drawing.Size(393, 20); + this.tbURL.TabIndex = 1; + this.tbURL.Text = "http://freeimage.sourceforge.net/images/logo.jpg"; + // + // lUrl + // + this.lUrl.AutoSize = true; + this.lUrl.Location = new System.Drawing.Point(9, 320); + this.lUrl.Name = "lUrl"; + this.lUrl.Size = new System.Drawing.Size(137, 13); + this.lUrl.TabIndex = 2; + this.lUrl.Text = "Enter the URL of an Image:"; + // + // bLoadUrl + // + this.bLoadUrl.Location = new System.Drawing.Point(12, 344); + this.bLoadUrl.Name = "bLoadUrl"; + this.bLoadUrl.Size = new System.Drawing.Size(75, 23); + this.bLoadUrl.TabIndex = 3; + this.bLoadUrl.Text = "Load URL"; + this.bLoadUrl.UseVisualStyleBackColor = true; + this.bLoadUrl.Click += new System.EventHandler(this.bLoadUrl_Click); + // + // bSave + // + this.bSave.Location = new System.Drawing.Point(93, 344); + this.bSave.Name = "bSave"; + this.bSave.Size = new System.Drawing.Size(75, 23); + this.bSave.TabIndex = 4; + this.bSave.Text = "Save to disk"; + this.bSave.UseVisualStyleBackColor = true; + this.bSave.Click += new System.EventHandler(this.bSave_Click); + // + // SampleForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(560, 379); + this.Controls.Add(this.bSave); + this.Controls.Add(this.bLoadUrl); + this.Controls.Add(this.lUrl); + this.Controls.Add(this.tbURL); + this.Controls.Add(this.picBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SampleForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Sample09"; + ((System.ComponentModel.ISupportInitialize)(this.picBox)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.PictureBox picBox; + private System.Windows.Forms.TextBox tbURL; + private System.Windows.Forms.Label lUrl; + private System.Windows.Forms.Button bLoadUrl; + private System.Windows.Forms.Button bSave; + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/SampleForm.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/SampleForm.cs new file mode 100644 index 0000000..72af7cf --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/SampleForm.cs @@ -0,0 +1,147 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using FreeImageAPI; +using System.Net; +using System.IO; + +namespace Sample09 +{ + public partial class SampleForm : Form + { + [STAThread] + static void Main() + { + // Check if FreeImage is available + if (!FreeImage.IsAvailable()) + { + throw new Exception("FreeImage is not available!"); + } + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new SampleForm()); + } + + public SampleForm() + { + InitializeComponent(); + } + + private void bLoadUrl_Click(object sender, EventArgs e) + { + // Verify url + if (String.IsNullOrEmpty(tbURL.Text)) + { + MessageBox.Show("Please enter a valid URL.", "Error"); + return; + } + FIBITMAP dib = new FIBITMAP(); + Stream sourceStream = null; + try + { + // Build a stream to read from + WebRequest request = (WebRequest)HttpWebRequest.Create(tbURL.Text); + WebResponse response = request.GetResponse(); + sourceStream = response.GetResponseStream(); + if (sourceStream == null) + { + throw new Exception(); + } + // Load the image from stream + dib = FreeImage.LoadFromStream(sourceStream); + // Check success + if (dib.IsNull) + { + throw new Exception(); + } + // Convert the bitmap into a .NET bitmap + Bitmap bitmap = FreeImage.GetBitmap(dib); + if (bitmap == null) + { + throw new Exception(); + } + // Show the bitmap + if (picBox.Image != null) + { + picBox.Image.Dispose(); + } + picBox.Image = bitmap; + } + catch + { + // Error handling + MessageBox.Show("Error loading URL.", "Error"); + } + finally + { + // Clean up memory + FreeImage.UnloadEx(ref dib); + if (sourceStream != null) sourceStream.Dispose(); + } + } + + private void bSave_Click(object sender, EventArgs e) + { + // Check if there is a loaded bitmap + if (picBox.Image == null) + { + MessageBox.Show("No image loaded.", "Error"); + return; + } + SaveFileDialog sfd = null; + FileStream fStream = null; + FIBITMAP dib = new FIBITMAP(); + try + { + sfd = new SaveFileDialog(); + sfd.CreatePrompt = false; + sfd.FileName = ""; + sfd.Filter = "TIF (*tif)|*.tif"; + sfd.OverwritePrompt = true; + sfd.RestoreDirectory = true; + if (sfd.ShowDialog() == DialogResult.OK) + { + // Convert the .NET bitmap into a FreeImage-Bitmap + dib = FreeImage.CreateFromBitmap((Bitmap)picBox.Image); + if (dib.IsNull) + { + throw new Exception(); + } + // Create a filestream to write to + fStream = new FileStream(sfd.FileName, FileMode.Create); + if (!FreeImage.SaveToStream( + ref dib, + fStream, + FREE_IMAGE_FORMAT.FIF_TIFF, + FREE_IMAGE_SAVE_FLAGS.TIFF_LZW, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false)) + { + throw new Exception(); + } + MessageBox.Show("Image saved successfully.", "Success"); + } + else + { + MessageBox.Show("Operation aborted.", "Aborted"); + } + } + catch + { + MessageBox.Show("Error saving image.", "Error"); + } + finally + { + // Clean up + if (sfd != null) sfd.Dispose(); + if (fStream != null) fStream.Dispose(); + FreeImage.UnloadEx(ref dib); + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/SampleForm.resx b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/SampleForm.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 09 - Working with streams/SampleForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/MainForm.Designer.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/MainForm.Designer.cs new file mode 100644 index 0000000..b552724 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/MainForm.Designer.cs @@ -0,0 +1,87 @@ +namespace Sample10 +{ + partial class MainForm + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.bLoad = new System.Windows.Forms.Button(); + this.bQuit = new System.Windows.Forms.Button(); + this.tvMetadata = new System.Windows.Forms.TreeView(); + this.SuspendLayout(); + // + // bLoad + // + this.bLoad.Location = new System.Drawing.Point(12, 336); + this.bLoad.Name = "bLoad"; + this.bLoad.Size = new System.Drawing.Size(75, 23); + this.bLoad.TabIndex = 0; + this.bLoad.Text = "Load Image"; + this.bLoad.UseVisualStyleBackColor = true; + this.bLoad.Click += new System.EventHandler(this.bLoad_Click); + // + // bQuit + // + this.bQuit.Location = new System.Drawing.Point(328, 336); + this.bQuit.Name = "bQuit"; + this.bQuit.Size = new System.Drawing.Size(75, 23); + this.bQuit.TabIndex = 1; + this.bQuit.Text = "Quit"; + this.bQuit.UseVisualStyleBackColor = true; + this.bQuit.Click += new System.EventHandler(this.bQuit_Click); + // + // tvMetadata + // + this.tvMetadata.Location = new System.Drawing.Point(12, 12); + this.tvMetadata.Name = "tvMetadata"; + this.tvMetadata.Size = new System.Drawing.Size(389, 318); + this.tvMetadata.TabIndex = 2; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(415, 371); + this.Controls.Add(this.tvMetadata); + this.Controls.Add(this.bQuit); + this.Controls.Add(this.bLoad); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MainForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "MainForm"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button bLoad; + private System.Windows.Forms.Button bQuit; + private System.Windows.Forms.TreeView tvMetadata; + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/MainForm.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/MainForm.cs new file mode 100644 index 0000000..7ce6021 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/MainForm.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; +using FreeImageAPI; +using FreeImageAPI.Metadata; + +namespace Sample10 +{ + public partial class MainForm : Form + { + [STAThread] + static void Main() + { + // Check if FreeImage.dll is available + if (!FreeImage.IsAvailable()) + { + MessageBox.Show("FreeImage is not available. Aborting.", "Error"); + } + + // Add this class to the FreeImage-Message-Callback + FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message); + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + + static void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message) + { + // Display the data + MessageBox.Show( + String.Format("FreeImage-Message:\n{1}\nFormat:{0}", fif.ToString(), message), + "FreeImage-Message"); + } + + public MainForm() + { + InitializeComponent(); + } + + private void bQuit_Click(object sender, EventArgs e) + { + Application.Exit(); + } + + private void bLoad_Click(object sender, EventArgs e) + { + // Create variables + OpenFileDialog ofd = new OpenFileDialog(); + FIBITMAP dib = new FIBITMAP(); + try + { + // Apply settings + ofd.CheckFileExists = true; + ofd.CheckPathExists = true; + ofd.FileName = ""; + ofd.Filter = "All files (*.*)|*.*"; + ofd.Multiselect = false; + ofd.RestoreDirectory = true; + // Get image filename + if (ofd.ShowDialog() == DialogResult.OK) + { + // Load the image + dib = FreeImage.LoadEx(ofd.FileName); + // Check if image was loaded successfully + if (dib.IsNull) throw new Exception("Failed to load image."); + // Clear the treeview + tvMetadata.Nodes.Clear(); + // Create a wrapper for all metadata the image contains + ImageMetadata iMetadata = new ImageMetadata(dib); + // Get each metadata model + foreach (MetadataModel metadataModel in iMetadata) + { + // Create a new node for each model + TreeNode modelNode = tvMetadata.Nodes.Add(metadataModel.ToString()); + + // Get each metadata tag and create a subnode for it + foreach (MetadataTag metadataTag in metadataModel) + { + modelNode.Nodes.Add(metadataTag.Key + ": " + metadataTag.ToString()); + } + } + } + else + { + MessageBox.Show("Operation aborted.", "Aborted"); + } + } + // Display error message + catch (Exception ex) + { + while (ex.InnerException != null) + ex = ex.InnerException; + MessageBox.Show(ex.ToString(), "Exception caught"); + } + // Clean up + finally + { + ofd.Dispose(); + FreeImage.UnloadEx(ref dib); + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/MainForm.resx b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/MainForm.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..67c1d7a --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("e8da4fa8-cc15-4b0e-8c57-d55ceb771559")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/Sample 10 - Metadata.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/Sample 10 - Metadata.2005.csproj new file mode 100644 index 0000000..c909e88 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/Sample 10 - Metadata.2005.csproj @@ -0,0 +1,103 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003} + WinExe + Properties + Sample10 + Sample10 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + prompt + + + + + + + + + + + Form + + + MainForm.cs + + + + + + Designer + MainForm.cs + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/Sample 10 - Metadata.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/Sample 10 - Metadata.csproj new file mode 100644 index 0000000..bb218d6 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 10 - Metadata/Sample 10 - Metadata.csproj @@ -0,0 +1,108 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {55DCC37A-E56C-44D9-9C44-8DAB10CD3003} + WinExe + Properties + Sample10 + Sample10 + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\Debug\ + DEBUG;TRACE + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + + + x86 + prompt + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + + + x64 + prompt + + + + + + + + + + + Form + + + MainForm.cs + + + + + + Designer + MainForm.cs + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MainForm.Designer.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MainForm.Designer.cs new file mode 100644 index 0000000..9f2ffe2 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MainForm.Designer.cs @@ -0,0 +1,382 @@ +namespace Sample11 +{ + partial class MainForm + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.pictureBox = new System.Windows.Forms.PictureBox(); + this.bLoadImage = new System.Windows.Forms.Button(); + this.bSaveImage = new System.Windows.Forms.Button(); + this.ofd = new System.Windows.Forms.OpenFileDialog(); + this.sfd = new System.Windows.Forms.SaveFileDialog(); + this.lWidth = new System.Windows.Forms.Label(); + this.lHeight = new System.Windows.Forms.Label(); + this.lBpp = new System.Windows.Forms.Label(); + this.lMetadataCount = new System.Windows.Forms.Label(); + this.bGreyscale = new System.Windows.Forms.Button(); + this.cbSelectFrame = new System.Windows.Forms.ComboBox(); + this.lComment = new System.Windows.Forms.Label(); + this.bAdjustGamma = new System.Windows.Forms.Button(); + this.vGamma = new System.Windows.Forms.NumericUpDown(); + this.bRedChannelOnly = new System.Windows.Forms.Button(); + this.bBlueChannel = new System.Windows.Forms.Button(); + this.bGreenChannel = new System.Windows.Forms.Button(); + this.bAllChannels = new System.Windows.Forms.Button(); + this.lSelectFrame = new System.Windows.Forms.Label(); + this.lImageFormat = new System.Windows.Forms.Label(); + this.bRotate = new System.Windows.Forms.Button(); + this.vRotate = new System.Windows.Forms.TrackBar(); + this.lRotate = new System.Windows.Forms.Label(); + this.lColors = new System.Windows.Forms.Label(); + this.nShowMetadata = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.vGamma)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.vRotate)).BeginInit(); + this.SuspendLayout(); + // + // pictureBox + // + this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pictureBox.Location = new System.Drawing.Point(14, 15); + this.pictureBox.Margin = new System.Windows.Forms.Padding(4); + this.pictureBox.Name = "pictureBox"; + this.pictureBox.Size = new System.Drawing.Size(542, 395); + this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox.TabIndex = 0; + this.pictureBox.TabStop = false; + // + // bLoadImage + // + this.bLoadImage.Location = new System.Drawing.Point(564, 15); + this.bLoadImage.Margin = new System.Windows.Forms.Padding(4); + this.bLoadImage.Name = "bLoadImage"; + this.bLoadImage.Size = new System.Drawing.Size(125, 28); + this.bLoadImage.TabIndex = 1; + this.bLoadImage.Text = "Load image"; + this.bLoadImage.UseVisualStyleBackColor = true; + this.bLoadImage.Click += new System.EventHandler(this.bLoadImage_Click); + // + // bSaveImage + // + this.bSaveImage.Location = new System.Drawing.Point(564, 51); + this.bSaveImage.Margin = new System.Windows.Forms.Padding(4); + this.bSaveImage.Name = "bSaveImage"; + this.bSaveImage.Size = new System.Drawing.Size(125, 28); + this.bSaveImage.TabIndex = 2; + this.bSaveImage.Text = "Save image"; + this.bSaveImage.UseVisualStyleBackColor = true; + this.bSaveImage.Click += new System.EventHandler(this.bSaveImage_Click); + // + // ofd + // + this.ofd.AddExtension = false; + this.ofd.AutoUpgradeEnabled = false; + this.ofd.Filter = "All files|*.*"; + this.ofd.RestoreDirectory = true; + this.ofd.SupportMultiDottedExtensions = true; + // + // sfd + // + this.sfd.AddExtension = false; + this.sfd.Filter = "All files|*.*"; + this.sfd.RestoreDirectory = true; + this.sfd.SupportMultiDottedExtensions = true; + // + // lWidth + // + this.lWidth.AutoSize = true; + this.lWidth.Location = new System.Drawing.Point(563, 350); + this.lWidth.Name = "lWidth"; + this.lWidth.Size = new System.Drawing.Size(57, 16); + this.lWidth.TabIndex = 6; + this.lWidth.Text = "Width: 0"; + // + // lHeight + // + this.lHeight.AutoSize = true; + this.lHeight.Location = new System.Drawing.Point(649, 350); + this.lHeight.Name = "lHeight"; + this.lHeight.Size = new System.Drawing.Size(60, 16); + this.lHeight.TabIndex = 7; + this.lHeight.Text = "Height: 0"; + // + // lBpp + // + this.lBpp.AutoSize = true; + this.lBpp.Location = new System.Drawing.Point(740, 350); + this.lBpp.Name = "lBpp"; + this.lBpp.Size = new System.Drawing.Size(45, 16); + this.lBpp.TabIndex = 8; + this.lBpp.Text = "Bpp: 0"; + // + // lMetadataCount + // + this.lMetadataCount.AutoSize = true; + this.lMetadataCount.Location = new System.Drawing.Point(809, 350); + this.lMetadataCount.Name = "lMetadataCount"; + this.lMetadataCount.Size = new System.Drawing.Size(77, 16); + this.lMetadataCount.TabIndex = 9; + this.lMetadataCount.Text = "Metadata: 0"; + // + // bGreyscale + // + this.bGreyscale.Location = new System.Drawing.Point(564, 121); + this.bGreyscale.Name = "bGreyscale"; + this.bGreyscale.Size = new System.Drawing.Size(125, 28); + this.bGreyscale.TabIndex = 10; + this.bGreyscale.Text = "Conv to greyscale"; + this.bGreyscale.UseVisualStyleBackColor = true; + this.bGreyscale.Click += new System.EventHandler(this.bGreyscale_Click); + // + // cbSelectFrame + // + this.cbSelectFrame.FormattingEnabled = true; + this.cbSelectFrame.Location = new System.Drawing.Point(695, 156); + this.cbSelectFrame.Name = "cbSelectFrame"; + this.cbSelectFrame.Size = new System.Drawing.Size(121, 24); + this.cbSelectFrame.TabIndex = 11; + this.cbSelectFrame.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // lComment + // + this.lComment.AutoSize = true; + this.lComment.Location = new System.Drawing.Point(563, 373); + this.lComment.Name = "lComment"; + this.lComment.Size = new System.Drawing.Size(107, 16); + this.lComment.TabIndex = 12; + this.lComment.Text = "Image-comment:"; + // + // bAdjustGamma + // + this.bAdjustGamma.Location = new System.Drawing.Point(564, 185); + this.bAdjustGamma.Name = "bAdjustGamma"; + this.bAdjustGamma.Size = new System.Drawing.Size(125, 28); + this.bAdjustGamma.TabIndex = 13; + this.bAdjustGamma.Text = "Adjust gamma"; + this.bAdjustGamma.UseVisualStyleBackColor = true; + this.bAdjustGamma.Click += new System.EventHandler(this.bAdjustGamma_Click); + // + // vGamma + // + this.vGamma.DecimalPlaces = 2; + this.vGamma.Increment = new decimal(new int[] { + 0, + 0, + 0, + 0}); + this.vGamma.Location = new System.Drawing.Point(695, 189); + this.vGamma.Maximum = new decimal(new int[] { + 2, + 0, + 0, + 0}); + this.vGamma.Name = "vGamma"; + this.vGamma.Size = new System.Drawing.Size(121, 23); + this.vGamma.TabIndex = 14; + // + // bRedChannelOnly + // + this.bRedChannelOnly.Location = new System.Drawing.Point(564, 219); + this.bRedChannelOnly.Name = "bRedChannelOnly"; + this.bRedChannelOnly.Size = new System.Drawing.Size(125, 28); + this.bRedChannelOnly.TabIndex = 15; + this.bRedChannelOnly.Text = "Red channel"; + this.bRedChannelOnly.UseVisualStyleBackColor = true; + this.bRedChannelOnly.Click += new System.EventHandler(this.bRedChannelOnly_Click); + // + // bBlueChannel + // + this.bBlueChannel.Location = new System.Drawing.Point(564, 287); + this.bBlueChannel.Name = "bBlueChannel"; + this.bBlueChannel.Size = new System.Drawing.Size(125, 28); + this.bBlueChannel.TabIndex = 16; + this.bBlueChannel.Text = "Blue channel"; + this.bBlueChannel.UseVisualStyleBackColor = true; + this.bBlueChannel.Click += new System.EventHandler(this.bBlueChannel_Click); + // + // bGreenChannel + // + this.bGreenChannel.Location = new System.Drawing.Point(564, 253); + this.bGreenChannel.Name = "bGreenChannel"; + this.bGreenChannel.Size = new System.Drawing.Size(125, 28); + this.bGreenChannel.TabIndex = 17; + this.bGreenChannel.Text = "Green channel"; + this.bGreenChannel.UseVisualStyleBackColor = true; + this.bGreenChannel.Click += new System.EventHandler(this.bGreenChannel_Click); + // + // bAllChannels + // + this.bAllChannels.Location = new System.Drawing.Point(563, 321); + this.bAllChannels.Name = "bAllChannels"; + this.bAllChannels.Size = new System.Drawing.Size(126, 28); + this.bAllChannels.TabIndex = 18; + this.bAllChannels.Text = "All channels"; + this.bAllChannels.UseVisualStyleBackColor = true; + this.bAllChannels.Click += new System.EventHandler(this.bAllChannels_Click); + // + // lSelectFrame + // + this.lSelectFrame.AutoSize = true; + this.lSelectFrame.Location = new System.Drawing.Point(563, 159); + this.lSelectFrame.Name = "lSelectFrame"; + this.lSelectFrame.Size = new System.Drawing.Size(86, 16); + this.lSelectFrame.TabIndex = 19; + this.lSelectFrame.Text = "Select frame:"; + // + // lImageFormat + // + this.lImageFormat.AutoSize = true; + this.lImageFormat.Location = new System.Drawing.Point(563, 395); + this.lImageFormat.Name = "lImageFormat"; + this.lImageFormat.Size = new System.Drawing.Size(92, 16); + this.lImageFormat.TabIndex = 20; + this.lImageFormat.Text = "Image-format:"; + // + // bRotate + // + this.bRotate.Location = new System.Drawing.Point(564, 86); + this.bRotate.Name = "bRotate"; + this.bRotate.Size = new System.Drawing.Size(125, 28); + this.bRotate.TabIndex = 21; + this.bRotate.Text = "Rotate"; + this.bRotate.UseVisualStyleBackColor = true; + this.bRotate.Click += new System.EventHandler(this.bRotate_Click); + // + // vRotate + // + this.vRotate.Location = new System.Drawing.Point(695, 80); + this.vRotate.Maximum = 360; + this.vRotate.Name = "vRotate"; + this.vRotate.Size = new System.Drawing.Size(170, 45); + this.vRotate.TabIndex = 22; + this.vRotate.TickFrequency = 10; + this.vRotate.TickStyle = System.Windows.Forms.TickStyle.Both; + this.vRotate.Scroll += new System.EventHandler(this.vRotate_Scroll); + // + // lRotate + // + this.lRotate.AutoSize = true; + this.lRotate.Location = new System.Drawing.Point(871, 92); + this.lRotate.Name = "lRotate"; + this.lRotate.Size = new System.Drawing.Size(15, 16); + this.lRotate.TabIndex = 23; + this.lRotate.Text = "0"; + // + // lColors + // + this.lColors.AutoSize = true; + this.lColors.Location = new System.Drawing.Point(740, 394); + this.lColors.Name = "lColors"; + this.lColors.Size = new System.Drawing.Size(60, 16); + this.lColors.TabIndex = 24; + this.lColors.Text = "Colors: 0"; + // + // nShowMetadata + // + this.nShowMetadata.Location = new System.Drawing.Point(696, 15); + this.nShowMetadata.Name = "nShowMetadata"; + this.nShowMetadata.Size = new System.Drawing.Size(125, 28); + this.nShowMetadata.TabIndex = 25; + this.nShowMetadata.Text = "Show metadata"; + this.nShowMetadata.UseVisualStyleBackColor = true; + this.nShowMetadata.Click += new System.EventHandler(this.nShowMetadata_Click); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(908, 423); + this.Controls.Add(this.nShowMetadata); + this.Controls.Add(this.lColors); + this.Controls.Add(this.lRotate); + this.Controls.Add(this.vRotate); + this.Controls.Add(this.bRotate); + this.Controls.Add(this.lImageFormat); + this.Controls.Add(this.lSelectFrame); + this.Controls.Add(this.bAllChannels); + this.Controls.Add(this.bGreenChannel); + this.Controls.Add(this.bBlueChannel); + this.Controls.Add(this.bRedChannelOnly); + this.Controls.Add(this.vGamma); + this.Controls.Add(this.bAdjustGamma); + this.Controls.Add(this.lComment); + this.Controls.Add(this.cbSelectFrame); + this.Controls.Add(this.bGreyscale); + this.Controls.Add(this.lMetadataCount); + this.Controls.Add(this.lBpp); + this.Controls.Add(this.lHeight); + this.Controls.Add(this.lWidth); + this.Controls.Add(this.bSaveImage); + this.Controls.Add(this.bLoadImage); + this.Controls.Add(this.pictureBox); + this.DoubleBuffered = true; + this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Margin = new System.Windows.Forms.Padding(4); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MainForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Sample 11"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.vGamma)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.vRotate)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox; + private System.Windows.Forms.Button bLoadImage; + private System.Windows.Forms.Button bSaveImage; + private System.Windows.Forms.OpenFileDialog ofd; + private System.Windows.Forms.SaveFileDialog sfd; + private System.Windows.Forms.Label lWidth; + private System.Windows.Forms.Label lHeight; + private System.Windows.Forms.Label lBpp; + private System.Windows.Forms.Label lMetadataCount; + private System.Windows.Forms.Button bGreyscale; + private System.Windows.Forms.ComboBox cbSelectFrame; + private System.Windows.Forms.Label lComment; + private System.Windows.Forms.Button bAdjustGamma; + private System.Windows.Forms.NumericUpDown vGamma; + private System.Windows.Forms.Button bRedChannelOnly; + private System.Windows.Forms.Button bBlueChannel; + private System.Windows.Forms.Button bGreenChannel; + private System.Windows.Forms.Button bAllChannels; + private System.Windows.Forms.Label lSelectFrame; + private System.Windows.Forms.Label lImageFormat; + private System.Windows.Forms.Button bRotate; + private System.Windows.Forms.TrackBar vRotate; + private System.Windows.Forms.Label lRotate; + private System.Windows.Forms.Label lColors; + private System.Windows.Forms.Button nShowMetadata; + } +} + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MainForm.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MainForm.cs new file mode 100644 index 0000000..68a4702 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MainForm.cs @@ -0,0 +1,412 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using FreeImageAPI; +using FreeImageAPI.Metadata; +using FreeImageAPI.Plugins; + +namespace Sample11 +{ + public partial class MainForm : Form + { + public MainForm() + { + InitializeComponent(); + } + + [STAThread] + static void Main() + { + // Capture messages generated by FreeImage + FreeImageEngine.Message += new OutputMessageFunction(FreeImageEngine_Message); + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + + static void FreeImageEngine_Message(FREE_IMAGE_FORMAT fif, string message) + { + // Display the message + // FreeImage continues code executing when all + // addes subscribers of 'Message' finished returned. + MessageBox.Show(message, "FreeImage-Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + // The FreeImageBitmap this sample will work with. + FreeImageBitmap bitmap = null; + + // Replaces the current bitmap with the given one. + private void ReplaceBitmap(FreeImageBitmap newBitmap) + { + // Checks whether the bitmap is usable + if (newBitmap == null || newBitmap.IsDisposed) + { + MessageBox.Show( + "Unexpected error.", + "Error", + MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + + // Check whether the image type of the new bitmap is 'FIT_BITMAP'. + // If not convert to 'FIT_BITMAP'. + if (newBitmap.ImageType != FREE_IMAGE_TYPE.FIT_BITMAP) + { + if (!newBitmap.ConvertType(FREE_IMAGE_TYPE.FIT_BITMAP, true)) + { + MessageBox.Show( + "Error converting bitmap to standard type.", + "Error", + MessageBoxButtons.OK, + MessageBoxIcon.Error); + return; + } + } + + // Dispose the old bitmap only in case it exists and + // the old instance is another than the new one. + if ((bitmap != null) && !object.ReferenceEquals(bitmap, newBitmap)) + { + bitmap.Dispose(); + } + // Dispose the picturebox's bitmap in case it exists. + if (pictureBox.Image != null) + { + pictureBox.Image.Dispose(); + } + + // Set the new bitmap. + pictureBox.Image = (Bitmap)(bitmap = newBitmap); + + // Update gui. + UpdateBitmapInformations(); + UpdateFrameSelection(); + } + + // Get bitmap properties and display them in the gui. + private void UpdateBitmapInformations() + { + if (Bitmap) + { + // Get width + lWidth.Text = String.Format("Width: {0}", bitmap.Width); + // Get Height + lHeight.Text = String.Format("Height: {0}", bitmap.Height); + // Get color depth + lBpp.Text = String.Format("Bpp: {0}", bitmap.ColorDepth); + // Get number of metadata + ImageMetadata mData = bitmap.Metadata; + mData.HideEmptyModels = true; + int mCnt = 0; + foreach (MetadataModel model in mData.List) + { + mCnt += model.Count; + } + lMetadataCount.Text = String.Format("Metadata: {0}", mCnt); + // Get image comment + lComment.Text = String.Format("Image-comment: {0}", bitmap.Comment != null ? bitmap.Comment : String.Empty); + // Get the number of real colors in the image + lColors.Text = String.Format("Colors: {0}", bitmap.UniqueColors); + } + else + { + // Reset all values + lWidth.Text = String.Format("Width: {0}", 0); + lHeight.Text = String.Format("Height: {0}", 0); + lBpp.Text = String.Format("Bpp: {0}", 0); + lMetadataCount.Text = String.Format("Metadata: {0}", 0); + lComment.Text = String.Format("Image-comment: {0}", String.Empty); + lColors.Text = String.Format("Colors: {0}", 0); + } + } + + // Update combobox for frame selection. + private void UpdateFrameSelection() + { + cbSelectFrame.Items.Clear(); + if (Bitmap) + { + // Get number of frames in the bitmap + if (bitmap.FrameCount > 1) + { + // Add an entry for each frame to the combobox + for (int i = 0; i < bitmap.FrameCount; i++) + { + cbSelectFrame.Items.Add(String.Format("Frame {0}", i + 1)); + } + } + } + } + + // Returns true in case the variable 'bitmap' + // is set and not disposed. + private bool Bitmap + { + get { return ((bitmap != null) && (!bitmap.IsDisposed)); } + } + + private void bLoadImage_Click(object sender, EventArgs e) + { + if (ofd.ShowDialog() == DialogResult.OK) + { + try + { + // Load the file using autodetection + FreeImageBitmap fib = new FreeImageBitmap(ofd.FileName); + // Rescale the image so that it fits the picturebox + // Get the plugin that was used to load the bitmap + FreeImagePlugin plug = PluginRepository.Plugin(fib.ImageFormat); + lImageFormat.Text = String.Format("Image-format: {0}", plug.Format); + // Replace the existing bitmap with the new one + ReplaceBitmap(fib); + } + catch + { + } + } + } + + private void bSaveImage_Click(object sender, EventArgs e) + { + if (pictureBox.Image != null) + { + try + { + if (sfd.ShowDialog() == DialogResult.OK) + { + // Save the bitmap using autodetection + using (FreeImageBitmap temp = new FreeImageBitmap(pictureBox.Image)) + { + temp.Save(sfd.FileName); + } + } + } + catch + { + } + } + } + + private void bRotate_Click(object sender, EventArgs e) + { + if (Bitmap) + { + // Create a temporary rescaled bitmap + using (FreeImageBitmap temp = bitmap.GetScaledInstance( + pictureBox.DisplayRectangle.Width, pictureBox.DisplayRectangle.Height, + FREE_IMAGE_FILTER.FILTER_CATMULLROM)) + { + if (temp != null) + { + // Rotate the bitmap + temp.Rotate((double)vRotate.Value); + if (pictureBox.Image != null) + { + pictureBox.Image.Dispose(); + } + // Display the result + pictureBox.Image = (Bitmap)temp; + } + } + } + } + + private void bGreyscale_Click(object sender, EventArgs e) + { + if (Bitmap) + { + // Convert the bitmap to 8bpp and greyscale + ReplaceBitmap(bitmap.GetColorConvertedInstance( + FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP | + FREE_IMAGE_COLOR_DEPTH.FICD_FORCE_GREYSCALE)); + } + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + ComboBox cb = sender as ComboBox; + if ((cb != null) && (cb.Items.Count > 0)) + { + if (Bitmap) + { + try + { + // Switch the selected frame + bitmap.SelectActiveFrame(cb.SelectedIndex); + ReplaceBitmap(bitmap); + } + catch (ArgumentOutOfRangeException) + { + MessageBox.Show("Error changing frame.", "Error"); + } + } + } + } + + private void bAdjustGamma_Click(object sender, EventArgs e) + { + if (Bitmap) + { + // Adjust the gamma value + bitmap.AdjustGamma((double)vGamma.Value); + ReplaceBitmap(bitmap); + } + } + + private void bRedChannelOnly_Click(object sender, EventArgs e) + { + // Mask out green and blue + SetColorChannels(0xFF, 0x00, 0x00); + } + + private void bGreenChannel_Click(object sender, EventArgs e) + { + // Mask out red and blue + SetColorChannels(0x00, 0xFF, 0x00); + } + + private void bBlueChannel_Click(object sender, EventArgs e) + { + // Mask out red and green + SetColorChannels(0x00, 0x00, 0xFF); + } + + private void bAllChannels_Click(object sender, EventArgs e) + { + if (Bitmap) + { + // Restore the bitmap using the original + ReplaceBitmap(bitmap); + } + } + + private void SetColorChannels(int redmask, int greenmask, int bluemask) + { + if (Bitmap) + { + // Create a temporary clone. + using (FreeImageBitmap bitmap = (FreeImageBitmap)this.bitmap.Clone()) + { + if (bitmap != null) + { + // Check whether the bitmap has a palette + if (bitmap.HasPalette) + { + // Use the Palette class to handle the bitmap's + // palette. A palette always consist of RGBQUADs. + Palette palette = bitmap.Palette; + // Apply the new values for all three color components. + for (int i = 0; i < palette.Length; i++) + { + RGBQUAD rgbq = palette[i]; + + rgbq.rgbRed = (byte)(rgbq.rgbRed & redmask); + rgbq.rgbGreen = (byte)(rgbq.rgbGreen & greenmask); + rgbq.rgbBlue = (byte)(rgbq.rgbBlue & bluemask); + + palette[i] = rgbq; + } + } + // In case the bitmap has no palette it must have a color depth + // of 16, 24 or 32. Each color depth needs a different wrapping + // structure for the bitmaps data. These structures can be accessed + // by using the foreach clause. + else if (bitmap.ColorDepth == 16) + { + // Iterate over each scanline + // For 16bpp use either Scanline or Scanline + if (bitmap.IsRGB555) + { + foreach (Scanline scanline in bitmap) + { + for (int x = 0; x < scanline.Length; x++) + { + FI16RGB555 pixel = scanline[x]; + pixel.Red = (byte)(pixel.Red & redmask); + pixel.Green = (byte)(pixel.Green & greenmask); + pixel.Blue = (byte)(pixel.Blue & bluemask); + scanline[x] = pixel; + } + } + } + else if (bitmap.IsRGB565) + { + foreach (Scanline scanline in bitmap) + { + for (int x = 0; x < scanline.Length; x++) + { + FI16RGB565 pixel = scanline[x]; + pixel.Red = (byte)(pixel.Red & redmask); + pixel.Green = (byte)(pixel.Green & greenmask); + pixel.Blue = (byte)(pixel.Blue & bluemask); + scanline[x] = pixel; + } + } + } + } + else if (bitmap.ColorDepth == 24) + { + // Iterate over each scanline + // For 24bpp Scanline must be used + foreach (Scanline scanline in bitmap) + { + for (int x = 0; x < scanline.Length; x++) + { + RGBTRIPLE pixel = scanline[x]; + pixel.rgbtRed = (byte)(pixel.rgbtRed & redmask); + pixel.rgbtGreen = (byte)(pixel.rgbtGreen & greenmask); + pixel.rgbtBlue = (byte)(pixel.rgbtBlue & bluemask); + scanline[x] = pixel; + } + } + } + else if (bitmap.ColorDepth == 32) + { + // Iterate over each scanline + // For 32bpp Scanline must be used + foreach (Scanline scanline in bitmap) + { + for (int x = 0; x < scanline.Length; x++) + { + RGBQUAD pixel = scanline[x]; + pixel.rgbRed = (byte)(pixel.rgbRed & redmask); + pixel.rgbGreen = (byte)(pixel.rgbGreen & greenmask); + pixel.rgbBlue = (byte)(pixel.rgbBlue & bluemask); + scanline[x] = pixel; + } + } + } + // Dispose only the picturebox's bitmap + if (pictureBox.Image != null) + { + pictureBox.Image.Dispose(); + } + pictureBox.Image = (Bitmap)bitmap; + } + } + } + } + + private void vRotate_Scroll(object sender, EventArgs e) + { + TrackBar bar = sender as TrackBar; + if (bar != null) + { + lRotate.Text = bar.Value.ToString(); + } + } + + private void nShowMetadata_Click(object sender, EventArgs e) + { + if (Bitmap) + { + MetaDataFrame mFrame = new MetaDataFrame(); + mFrame.Tag = bitmap.Metadata; + mFrame.ShowDialog(this); + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MainForm.resx b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MainForm.resx new file mode 100644 index 0000000..5becef4 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MainForm.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 84, 17 + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MetaDataFrame.Designer.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MetaDataFrame.Designer.cs new file mode 100644 index 0000000..12c1031 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MetaDataFrame.Designer.cs @@ -0,0 +1,63 @@ +namespace Sample11 +{ + partial class MetaDataFrame + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.tvMetadata = new System.Windows.Forms.TreeView(); + this.SuspendLayout(); + // + // tvMetadata + // + this.tvMetadata.Location = new System.Drawing.Point(12, 12); + this.tvMetadata.Name = "tvMetadata"; + this.tvMetadata.Size = new System.Drawing.Size(389, 318); + this.tvMetadata.TabIndex = 3; + // + // MetaDataFrame + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(417, 349); + this.Controls.Add(this.tvMetadata); + this.DoubleBuffered = true; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MetaDataFrame"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Metadata"; + this.Load += new System.EventHandler(this.MetaDataFrame_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TreeView tvMetadata; + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MetaDataFrame.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MetaDataFrame.cs new file mode 100644 index 0000000..77e670b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MetaDataFrame.cs @@ -0,0 +1,49 @@ +using System; +using System.ComponentModel; +using System.Windows.Forms; +using FreeImageAPI; +using FreeImageAPI.Metadata; + +namespace Sample11 +{ + public partial class MetaDataFrame : Form + { + public MetaDataFrame() + { + InitializeComponent(); + } + + private void MetaDataFrame_Load(object sender, EventArgs e) + { + ImageMetadata iMetadata = this.Tag as ImageMetadata; + if (iMetadata != null) + { + bool backup = iMetadata.HideEmptyModels; + iMetadata.HideEmptyModels = false; + try + { + // Get each metadata model + foreach (MetadataModel metadataModel in iMetadata) + { + // Create a new node for each model + TreeNode modelNode = tvMetadata.Nodes.Add(metadataModel.ToString()); + + // Get each metadata tag and create a subnode for it + foreach (MetadataTag metadataTag in metadataModel) + { + modelNode.Nodes.Add(metadataTag.Key + ": " + metadataTag.ToString()); + } + } + } + // Display error message + catch (Exception ex) + { + while (ex.InnerException != null) + ex = ex.InnerException; + MessageBox.Show(ex.ToString(), "Exception caught"); + } + iMetadata.HideEmptyModels = backup; + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MetaDataFrame.resx b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MetaDataFrame.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/MetaDataFrame.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ce7c549 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("219019e1-9a57-46c7-b9d7-3928a9277fd6")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/Sample 11 - Using the FreeImageBitmap class.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/Sample 11 - Using the FreeImageBitmap class.2005.csproj new file mode 100644 index 0000000..001e0d4 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/Sample 11 - Using the FreeImageBitmap class.2005.csproj @@ -0,0 +1,115 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {996068CD-D07A-42E0-856F-ACC71E8565EF} + WinExe + Properties + Sample11 + Sample11 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + none + 4 + 512 + false + + + none + true + bin\Release\ + TRACE + none + 4 + 512 + + + true + bin\Debug\ + DEBUG;TRACE + 512 + full + x86 + false + none + + + bin\Release\ + TRACE + true + 512 + + + x86 + none + + + true + bin\Debug\ + DEBUG;TRACE + 512 + full + x64 + false + none + + + bin\Release\ + TRACE + true + 512 + + + x64 + none + + + + + + + + + Form + + + MainForm.cs + + + Form + + + MetaDataFrame.cs + + + + Designer + MainForm.cs + + + Designer + MetaDataFrame.cs + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/Sample 11 - Using the FreeImageBitmap class.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/Sample 11 - Using the FreeImageBitmap class.csproj new file mode 100644 index 0000000..f8a87bd --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Samples/Sample 11 - Using the FreeImageBitmap class/Sample 11 - Using the FreeImageBitmap class.csproj @@ -0,0 +1,120 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {996068CD-D07A-42E0-856F-ACC71E8565EF} + WinExe + Properties + Sample11 + Sample11 + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + none + 4 + 512 + false + + + none + true + bin\Release\ + TRACE + none + 4 + 512 + + + true + bin\Debug\ + DEBUG;TRACE + 512 + full + x86 + false + none + + + bin\Release\ + TRACE + true + 512 + + + x86 + none + + + true + bin\Debug\ + DEBUG;TRACE + 512 + full + x64 + false + none + + + bin\Release\ + TRACE + true + 512 + + + x64 + none + + + + + + + + + Form + + + MainForm.cs + + + Form + + + MetaDataFrame.cs + + + + Designer + MainForm.cs + + + Designer + MetaDataFrame.cs + + + + + {6598A7CD-8F27-4D3F-A675-5AE63113A7C3} + Library + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/FreeImage.cs.template b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/FreeImage.cs.template new file mode 100644 index 0000000..f02974d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/FreeImage.cs.template @@ -0,0 +1,219 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// To build the project without VS use the following commandline: +// "csc.exe /out:FreeImageNET.dll /target:library /doc:FreeImageNET.XML /debug- /o /unsafe+ /filealign:512 FreeImage.cs" +// ========================================================== + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using FreeImageAPI; +using FreeImageAPI.IO; +using FreeImageAPI.Metadata; +using FreeImageAPI.Plugins; + +///////////////////////////////////////////////////// +// // +// FreeImage.h import // +// // +///////////////////////////////////////////////////// + + #region Structs + +#include "Structs\BITMAP.cs" + +#include "Structs\BITMAPINFOHEADER.cs" + +#include "Structs\BITMAPINFO.cs" + +#include "Structs\FIBITMAP.cs" + +#include "Structs\FIMULTIBITMAP.cs" + +#include "Structs\FIMEMORY.cs" + +#include "Structs\FIMETADATA.cs" + +#include "Structs\FITAG.cs" + +#include "Structs\FreeImageIO.cs" + +#include "Structs\RGBQUAD.cs" + +#include "Structs\RGBTRIPLE.cs" + +#include "Structs\FIRGBA16.cs" + +#include "Structs\FIRGB16.cs" + +#include "Structs\FIRGBAF.cs" + +#include "Structs\FIRGBF.cs" + +#include "Structs\FICOMPLEX.cs" + +#include "Structs\FIICCPROFILE.cs" + +#include "Structs\Plugin.cs" + + #endregion + + #region Enums + +#include "Enumerations\DisposalMethodType.cs" + +#include "Enumerations\FREE_IMAGE_FORMAT.cs" + +#include "Enumerations\FREE_IMAGE_TYPE.cs" + +#include "Enumerations\FREE_IMAGE_COLOR_OPTIONS.cs" + +#include "Enumerations\FREE_IMAGE_COLOR_TYPE.cs" + +#include "Enumerations\FREE_IMAGE_QUANTIZE.cs" + +#include "Enumerations\FREE_IMAGE_DITHER.cs" + +#include "Enumerations\FREE_IMAGE_JPEG_OPERATION.cs" + +#include "Enumerations\FREE_IMAGE_TMO.cs" + +#include "Enumerations\FREE_IMAGE_FILTER.cs" + +#include "Enumerations\FREE_IMAGE_COLOR_CHANNEL.cs" + +#include "Enumerations\FREE_IMAGE_MDTYPE.cs" + +#include "Enumerations\FREE_IMAGE_MDMODEL.cs" + +#include "Enumerations\FREE_IMAGE_LOAD_FLAGS.cs" + +#include "Enumerations\FREE_IMAGE_SAVE_FLAGS.cs" + +#include "Enumerations\ICC_FLAGS.cs" + + #endregion + + #region Delegates + +#include "Delegates.cs" + + #endregion + +#include "FreeImageStaticImports.cs" + +///////////////////////////////////////////////////// +// // +// Wrapper functions // +// // +///////////////////////////////////////////////////// + + #region Structs + +#include "Structs\fi_handle.cs" + +#include "Structs\FI1BIT.cs" + +#include "Structs\FI4BIT.cs" + +#include "Structs\FI16RGB555.cs" + +#include "Structs\FI16RGB565.cs" + +#include "Structs\FIRational.cs" + +#include "Structs\FIURational.cs" + + #endregion + + #region Classes + +#include "Classes\FreeImageBitmap.cs" + +#include "Classes\FreeImageEngine.cs" + +#include "Classes\FreeImagePlugin.cs" + +#include "Classes\FreeImageStreamIO.cs" + +#include "Classes\GifInformation.cs" + +#include "Classes\ImageMetadata.cs" + +#include "Classes\LocalPlugin.cs" + +#include "Classes\MemoryArray.cs" + +#include "Classes\MetadataModel.cs" + + #region Metadata Models + + #include "Classes\MetadataModels.cs" + + #endregion + +#include "Classes\MetadataTag.cs" + +#include "Classes\Palette.cs" + +#include "Classes\PluginRepository.cs" + +#include "Classes\Scanline.cs" + +#include "Classes\StreamWrapper.cs" + + #endregion + + #region Enums + +#include "Enumerations\FREE_IMAGE_COLOR_DEPTH.cs" + +#include "Enumerations\FREE_IMAGE_COMPARE_FLAGS.cs" + +#include "Enumerations\FREE_IMAGE_METADATA_COPY.cs" + +#include "Enumerations\MD_SEARCH_FLAGS.cs" + + #endregion + +#include "FreeImageWrapper.cs" \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/Program.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/Program.cs new file mode 100644 index 0000000..dd7ce7e --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/Program.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Text.RegularExpressions; + +namespace FreeImageNET_SFM +{ + class Program + { + static private Regex searchPattern = new Regex("#include[ \\t]*\"(.*)\"", RegexOptions.Compiled); + static private FileStream fStream = null; + static private TextWriter textOut = null; + private const string baseFolder = @"..\..\..\Library\"; + private const string templateName = @"FreeImage.cs.template"; + + static int Main(string[] args) + { + try + { + if (!File.Exists(templateName)) + { + Console.WriteLine(templateName + " not found."); return 1; + } + + try + { + fStream = new FileStream(@"FreeImage.cs", FileMode.Create); + } + catch + { + Console.WriteLine("Unable to create output file."); return 2; + } + + textOut = new StreamWriter(fStream); + + string[] content = File.ReadAllLines(templateName); + + for (int lineNumber = 0; lineNumber < content.Length; lineNumber++) + { + string line = content[lineNumber].Trim(); + Match match = searchPattern.Match(line); + + if (match.Success && match.Groups.Count == 2 && match.Groups[1].Value != null) + { + if (!File.Exists(baseFolder + match.Groups[1].Value)) + { + throw new FileNotFoundException(baseFolder + match.Groups[1].Value + " does not exist."); + } + + ParseFile(baseFolder + match.Groups[1].Value); + } + else + { + textOut.WriteLine(content[lineNumber]); + } + } + + return 0; + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + //Console.WriteLine("Error while parsing."); + return 3; + } + finally + { + if (textOut != null) + { + textOut.Flush(); + textOut.Close(); + } + } + } + + private static void ParseFile(string fileName) + { + int lineNumber = 0; + string line; + Match match; + string[] content = File.ReadAllLines(fileName); + + if (fileName.Contains("AssemblyInfo.cs")) + { + while (content[lineNumber].Trim().StartsWith("using") && lineNumber < content.Length) + { + lineNumber++; + } + lineNumber++; + } + else + { + while (!(content[lineNumber].Trim().StartsWith("namespace")) && lineNumber < content.Length) + { + lineNumber++; + } + //lineNumber += 2; + } + + for (; lineNumber < content.Length; lineNumber++) + { + line = content[lineNumber].Trim(); + match = searchPattern.Match(line); + + if (match.Success && match.Groups.Count == 2 && match.Groups[1].Value != null) + { + if (!File.Exists(baseFolder + match.Groups[1].Value)) + { + throw new FileNotFoundException(baseFolder + match.Groups[1].Value + " does not exist."); + } + + ParseFile(baseFolder + match.Groups[1].Value); + } + else + { + textOut.WriteLine(content[lineNumber]); + } + } + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1634d6f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("4fcae9f3-1b12-4137-9c5b-047124da37e9")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/SourceFileMerger.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/SourceFileMerger.2005.csproj new file mode 100644 index 0000000..6bc856b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/SourceFileMerger.2005.csproj @@ -0,0 +1,97 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1} + Exe + Properties + FreeImageNET_SFM + sourcefilemerger + + + true + full + false + bin\Debug\ + DEBUG;TRACE + none + 4 + false + 512 + + + none + true + bin\Release\ + TRACE + none + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + 512 + full + x86 + false + none + + + bin\Release\ + TRACE + true + + + x86 + false + none + + + true + bin\Debug\ + DEBUG;TRACE + 512 + full + x64 + false + none + + + bin\Release\ + TRACE + true + + + x64 + false + none + + + + + + + + + + + Always + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/SourceFileMerger.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/SourceFileMerger.csproj new file mode 100644 index 0000000..559e803 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/SourceFileMerger/SourceFileMerger.csproj @@ -0,0 +1,102 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {2AD35641-C1EA-492C-B081-F4AA5AAE8FA1} + Exe + Properties + FreeImageNET_SFM + sourcefilemerger + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + none + 4 + false + 512 + + + none + true + bin\Release\ + TRACE + none + 4 + false + + + true + bin\Debug\ + DEBUG;TRACE + 512 + full + x86 + false + none + + + bin\Release\ + TRACE + true + + + x86 + false + none + + + true + bin\Debug\ + DEBUG;TRACE + 512 + full + x64 + false + none + + + bin\Release\ + TRACE + true + + + x64 + false + none + + + + + + + + + + + Always + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/FreeImage.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/FreeImage.cs new file mode 100644 index 0000000..46cb386 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/FreeImage.cs @@ -0,0 +1,30584 @@ +// ========================================================== +// FreeImage 3 .NET wrapper +// Original FreeImage 3 functions and .NET compatible derived functions +// +// Design and implementation by +// - Jean-Philippe Goerke (jpgoerke@users.sourceforge.net) +// - Carsten Klein (cklein05@users.sourceforge.net) +// +// Contributors: +// - David Boland (davidboland@vodafone.ie) +// +// Main reference : MSDN Knowlede Base +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +// ========================================================== +// To build the project without VS use the following commandline: +// "csc.exe /out:FreeImageNET.dll /target:library /doc:FreeImageNET.XML /debug- /o /unsafe+ /filealign:512 FreeImage.cs" +// ========================================================== + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using FreeImageAPI; +using FreeImageAPI.IO; +using FreeImageAPI.Metadata; +using FreeImageAPI.Plugins; + +///////////////////////////////////////////////////// +// // +// FreeImage.h import // +// // +///////////////////////////////////////////////////// + + #region Structs + +namespace FreeImageAPI +{ + /// + /// The BITMAP structure defines the type, width, height, color format, and bit values of a bitmap. + /// + /// + /// The bitmap formats currently used are monochrome and color. The monochrome bitmap uses a one-bit, + /// one-plane format. Each scan is a multiple of 32 bits. + /// + /// Scans are organized as follows for a monochrome bitmap of height n: + /// + /// + /// Scan 0 + /// Scan 1 + /// . + /// . + /// . + /// Scan n-2 + /// Scan n-1 + /// + /// + /// The pixels on a monochrome device are either black or white. If the corresponding bit in the + /// bitmap is 1, the pixel is set to the foreground color; if the corresponding bit in the bitmap + /// is zero, the pixel is set to the background color. + /// + /// All devices that have the RC_BITBLT device capability support bitmaps. For more information, + /// see GetDeviceCaps. + /// + /// Each device has a unique color format. To transfer a bitmap from one device to another, + /// use the GetDIBits and SetDIBits functions. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct BITMAP + { + /// + /// Specifies the bitmap type. This member must be zero. + /// + public int bmType; + /// + /// Specifies the width, in pixels, of the bitmap. The width must be greater than zero. + /// + public int bmWidth; + /// + /// Specifies the height, in pixels, of the bitmap. The height must be greater than zero. + /// + public int bmHeight; + /// + /// Specifies the number of bytes in each scan line. This value must be divisible by 2, + /// because the system assumes that the bit values of a bitmap form an array that is word aligned. + /// + public int bmWidthBytes; + /// + /// Specifies the count of color planes. + /// + public ushort bmPlanes; + /// + /// Specifies the number of bits required to indicate the color of a pixel. + /// + public ushort bmBitsPixel; + /// + /// Pointer to the location of the bit values for the bitmap. + /// The bmBits member must be a long pointer to an array of character (1-byte) values. + /// + public IntPtr bmBits; + } +} + +namespace FreeImageAPI +{ + /// + /// This structure contains information about the dimensions and color format + /// of a device-independent bitmap (DIB). + /// + /// + /// The structure combines the + /// BITMAPINFOHEADER structure and a color table to provide a complete + /// definition of the dimensions and colors of a DIB. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct BITMAPINFOHEADER : IEquatable + { + /// + /// Specifies the size of the structure, in bytes. + /// + public uint biSize; + /// + /// Specifies the width of the bitmap, in pixels. + /// + /// Windows 98/Me, Windows 2000/XP: If biCompression is BI_JPEG or BI_PNG, + /// the biWidth member specifies the width of the decompressed JPEG or PNG image file, + /// respectively. + /// + public int biWidth; + /// + /// Specifies the height of the bitmap, in pixels. If biHeight is positive, the bitmap + /// is a bottom-up DIB and its origin is the lower-left corner. If biHeight is negative, + /// the bitmap is a top-down DIB and its origin is the upper-left corner. + /// + /// If biHeight is negative, indicating a top-down DIB, biCompression must be + /// either BI_RGB or BI_BITFIELDS. Top-down DIBs cannot be compressed. + /// + /// Windows 98/Me, Windows 2000/XP: If biCompression is BI_JPEG or BI_PNG, + /// the biHeight member specifies the height of the decompressed JPEG or PNG image file, + /// respectively. + /// + public int biHeight; + /// + /// Specifies the number of planes for the target device. This value must be set to 1. + /// + public ushort biPlanes; + /// + /// Specifies the number of bits per pixel.The biBitCount member of the BITMAPINFOHEADER + /// structure determines the number of bits that define each pixel and the maximum number of + /// colors in the bitmap. This member must be one of the following values. + /// + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// + /// 0 + /// + /// Windows 98/Me, Windows 2000/XP: The number of bits-per-pixel is specified + /// or is implied by the JPEG or PNG format. + /// + /// + /// + /// + /// 1 + /// + /// The bitmap is monochrome, and the bmiColors member of + /// contains two entries. Each bit in the bitmap array represents a pixel. If the bit is clear, + /// the pixel is displayed with the color of the first entry in the bmiColors table; if the bit + /// is set, the pixel has the color of the second entry in the table. + /// + /// + /// + /// + /// 4 + /// + /// The bitmap has a maximum of 16 colors, and the bmiColors member of BITMAPINFO + /// contains up to 16 entries. Each pixel in the bitmap is represented by a 4-bit index into the + /// color table. For example, if the first byte in the bitmap is 0x1F, the byte represents two + /// pixels. The first pixel contains the color in the second table entry, and the second pixel + /// contains the color in the sixteenth table entry. + /// + /// + /// + /// 8 + /// + /// The bitmap has a maximum of 256 colors, and the bmiColors member of BITMAPINFO + /// contains up to 256 entries. In this case, each byte in the array represents a single pixel. + /// + /// + /// + /// + /// 16 + /// + /// The bitmap has a maximum of 2^16 colors. If the biCompression member of the + /// BITMAPINFOHEADER is BI_RGB, the bmiColors member of BITMAPINFO is NULL. + /// Each WORD in the bitmap array represents a single pixel. The relative intensities + /// of red, green, and blue are represented with five bits for each color component. + /// The value for blue is in the least significant five bits, followed by five bits each for + /// green and red. The most significant bit is not used. The bmiColors color table is used + /// for optimizing colors used on palette-based devices, and must contain the number of entries + /// specified by the biClrUsed member of the BITMAPINFOHEADER. + /// + /// If the biCompression member of the BITMAPINFOHEADER is BI_BITFIELDS, the + /// bmiColors member contains three DWORD color masks that specify the red, green, + /// and blue components, respectively, of each pixel. Each WORD in the bitmap array represents + /// a single pixel. + /// + /// Windows NT/Windows 2000/XP: When the biCompression member is BI_BITFIELDS, + /// bits set in each DWORD mask must be contiguous and should not overlap the bits + /// of another mask. All the bits in the pixel do not have to be used. + /// + /// Windows 95/98/Me: When the biCompression member is BI_BITFIELDS, the system + /// supports only the following 16bpp color masks: A 5-5-5 16-bit image, where the blue mask is + /// 0x001F, the green mask is 0x03E0, and the red mask is 0x7C00; and a 5-6-5 16-bit image, + /// where the blue mask is 0x001F, the green mask is 0x07E0, and the red mask is 0xF800. + /// + /// + /// + /// + /// 24 + /// + /// The bitmap has a maximum of 2^24 colors, and the bmiColors member of BITMAPINFO + /// is NULL. Each 3-byte triplet in the bitmap array represents the relative intensities of blue, + /// green, and red, respectively, for a pixel. The bmiColors color table is used for + /// optimizing colors used on palette-based devices, and must contain the number of entries + /// specified by the biClrUsed member of the BITMAPINFOHEADER. + /// + /// + /// + /// + /// 32 + /// + /// The bitmap has a maximum of 2^32 colors. If the biCompression member of the + /// BITMAPINFOHEADER is BI_RGB, the bmiColors member of BITMAPINFO is NULL. + /// Each DWORD in the bitmap array represents the relative intensities of blue, green, and red, + /// respectively, for a pixel. The high byte in each DWORD is not used. The bmiColors + /// color table is used for optimizing colors used on palette-based devices, and must contain the + /// number of entries specified by the biClrUsed member of the BITMAPINFOHEADER. + /// + /// If the biCompression member of the BITMAPINFOHEADER is BI_BITFIELDS, + /// the bmiColors member contains three DWORD color masks that specify the red, green, + /// and blue components, respectively, of each pixel. Each DWORD in the bitmap array represents + /// a single pixel. + /// + /// Windows NT/ 2000: When the biCompression member is BI_BITFIELDS, bits set in each + /// DWORD mask must be contiguous and should not overlap the bits of another mask. All the + /// bits in the pixel do not need to be used. + /// + /// Windows 95/98/Me: When the biCompression member is BI_BITFIELDS, the system + /// supports only the following 32-bpp color mask: The blue mask is 0x000000FF, the green mask is + /// 0x0000FF00, and the red mask is 0x00FF0000. + /// + /// + /// + /// + public ushort biBitCount; + /// + /// Specifies the type of compression for a compressed bottom-up bitmap (top-down DIBs cannot be + /// compressed). + /// + /// + /// Value + /// Meaning + /// + /// + /// + /// BI_RGB + /// An uncompressed format. + /// + /// + /// + /// BI_RLE8 + /// A run-length encoded (RLE) format for bitmaps with 8 bpp. The compression format + /// is a 2-byte format consisting of a count byte followed by a byte containing a color index. + /// + /// + /// + /// + /// BI_RLE4 + /// An RLE format for bitmaps with 4 bpp. The compression format is a 2-byte format + /// consisting of a count byte followed by two word-length color indexes. + /// + /// + /// + /// BI_BITFIELDS + /// Specifies that the bitmap is not compressed and that the color table consists + /// of three DWORD color masks that specify the red, green, and blue components, respectively, + /// of each pixel. This is valid when used with 16- and 32-bpp bitmaps. + /// + /// + /// + /// BI_JPEG + /// Windows 98/Me, Windows 2000/XP: Indicates that the image is a JPEG image. + /// + /// + /// + /// + /// BI_PNG + /// Windows 98/Me, Windows 2000/XP: Indicates that the image is a PNG image. + /// + /// + /// + /// + /// + public uint biCompression; + /// + /// Specifies the size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps. + /// + /// Windows 98/Me, Windows 2000/XP: If biCompression is BI_JPEG or BI_PNG, + /// biSizeImage indicates the size of the JPEG or PNG image buffer, respectively. + /// + public uint biSizeImage; + /// + /// Specifies the horizontal resolution, in pixels-per-meter, of the target device for the bitmap. + /// An application can use this value to select a bitmap from a resource group that best matches + /// the characteristics of the current device. + /// + public int biXPelsPerMeter; + /// + /// Specifies the vertical resolution, in pixels-per-meter, of the target device for the bitmap. + /// + public int biYPelsPerMeter; + /// + /// Specifies the number of color indexes in the color table that are actually used by the bitmap. + /// If this value is zero, the bitmap uses the maximum number of colors corresponding to the value + /// of the biBitCount member for the compression mode specified by biCompression. + /// + /// If iClrUsed is nonzero and the biBitCount member is less than 16, the biClrUsed + /// member specifies the actual number of colors the graphics engine or device driver accesses. + /// If biBitCount is 16 or greater, the biClrUsed member specifies the size of the color + /// table used to optimize performance of the system color palettes. If biBitCount equals 16 or 32, + /// the optimal color palette starts immediately following the three DWORD masks. + /// + /// When the bitmap array immediately follows the structure, it is a packed bitmap. + /// Packed bitmaps are referenced by a single pointer. Packed bitmaps require that the + /// biClrUsed member must be either zero or the actual size of the color table. + /// + public uint biClrUsed; + /// + /// Specifies the number of color indexes that are required for displaying the bitmap. If this value + /// is zero, all colors are required. + /// + public uint biClrImportant; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(BITMAPINFOHEADER left, BITMAPINFOHEADER right) + { + return ((left.biSize == right.biSize) && + (left.biWidth == right.biWidth) && + (left.biHeight == right.biHeight) && + (left.biPlanes == right.biPlanes) && + (left.biBitCount == right.biBitCount) && + (left.biCompression == right.biCompression) && + (left.biSizeImage == right.biSizeImage) && + (left.biXPelsPerMeter == right.biXPelsPerMeter) && + (left.biYPelsPerMeter == right.biYPelsPerMeter) && + (left.biClrUsed == right.biClrUsed) && + (left.biClrImportant == right.biClrImportant)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(BITMAPINFOHEADER left, BITMAPINFOHEADER right) + { + return !(left == right); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(BITMAPINFOHEADER other) + { + return (this == other); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is BITMAPINFOHEADER) && (this == (BITMAPINFOHEADER)obj)); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The BITMAPINFO structure defines the dimensions and color information for a DIB. + /// + /// + /// A DIB consists of two distinct parts: a BITMAPINFO structure describing the dimensions + /// and colors of the bitmap, and an array of bytes defining the pixels of the bitmap. The bits in + /// the array are packed together, but each scan line must be padded with zeroes to end on a + /// LONG data-type boundary. If the height of the bitmap is positive, the bitmap is a + /// bottom-up DIB and its origin is the lower-left corner. If the height is negative, the bitmap is + /// a top-down DIB and its origin is the upper left corner. + /// + /// A bitmap is packed when the bitmap array immediately follows the BITMAPINFO header. + /// Packed bitmaps are referenced by a single pointer. For packed bitmaps, the biClrUsed + /// member must be set to an even number when using the DIB_PAL_COLORS mode so that the DIB bitmap + /// array starts on a DWORD boundary. + /// + /// Note The bmiColors member should not contain palette indexes if the bitmap is to + /// be stored in a file or transferred to another application. + /// + /// Unless the application has exclusive use and control of the bitmap, the bitmap color table + /// should contain explicit RGB values. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct BITMAPINFO : IEquatable + { + /// + /// Specifies a structure that contains information + /// about the dimensions of color format. + /// + public BITMAPINFOHEADER bmiHeader; + /// + /// The bmiColors member contains one of the following: + /// + /// + /// + /// + /// An array of . The elements of the array that make up the + /// color table. + /// + /// + /// + /// + /// + /// An array of 16-bit unsigned integers that specifies indexes into the currently realized + /// logical palette. This use of bmiColors is allowed for functions that use DIBs. + /// When bmiColors elements contain indexes to a realized logical palette, they must + /// also call the following bitmap functions: + /// + /// + /// + /// + /// CreateDIBitmap + /// + /// CreateDIBPatternBrush + /// + /// CreateDIBSection + /// + /// The iUsage parameter of CreateDIBSection must be set to DIB_PAL_COLORS. + /// + /// The number of entries in the array depends on the values of the biBitCount and + /// biClrUsed members of the structure. + /// + /// The colors in the bmiColors table appear in order of importance. For more information, + /// see the Remarks section. + /// + public RGBQUAD[] bmiColors; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(BITMAPINFO left, BITMAPINFO right) + { + if (left.bmiHeader != right.bmiHeader) + { + return false; + } + if ((left.bmiColors == null) && (right.bmiColors == null)) + { + return true; + } + if ((left.bmiColors == null) || (right.bmiColors == null)) + { + return false; + } + if (left.bmiColors.Length != right.bmiColors.Length) + { + return false; + } + for (int i = 0; i < left.bmiColors.Length; i++) + { + if (left.bmiColors[i] != right.bmiColors[i]) + { + return false; + } + } + return true; + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(BITMAPINFO left, BITMAPINFO right) + { + return !(left == right); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(BITMAPINFO other) + { + return (this == other); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is BITMAPINFO) && (this == ((BITMAPINFO)obj))); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + int hash = bmiHeader.GetHashCode(); + if (bmiColors != null) + { + for (int c = 0; c < bmiColors.Length; c++) + { + hash ^= bmiColors[c].GetHashCode(); + hash <<= 1; + } + hash <<= 1; + } + else + { + hash >>= 1; + } + return hash; + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FIBITMAP structure is a handle to a FreeImage bimtap. + /// + /// + /// The handle represented by a FIBITBAP structure provides + /// access to either a singlepage bitmap or exactly one page of + /// a multipage bitmap. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIBITMAP : IComparable, IComparable, IEquatable + { + private IntPtr data; + + /// + /// A read-only field that represents a handle that has been initialized to zero. + /// + public static readonly FIBITMAP Zero; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIBITMAP left, FIBITMAP right) + { + return (left.data == right.data); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIBITMAP left, FIBITMAP right) + { + return (left.data != right.data); + } + + /// + /// Gets whether the handle is a null or not. + /// + /// true if this handle is a null; + /// otherwise, false. + public bool IsNull + { + get + { + return (data == IntPtr.Zero); + } + } + + /// + /// Sets the handle to null. + /// + public void SetNull() + { + data = IntPtr.Zero; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return data.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return data.GetHashCode(); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIBITMAP) && (this == ((FIBITMAP)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// true if the current object is equal to the other parameter; otherwise, false. + public bool Equals(FIBITMAP other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIBITMAP)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIBITMAP)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIBITMAP other) + { + return this.data.ToInt64().CompareTo(other.data.ToInt64()); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FIMULTIBITMAP structure is a handle to a FreeImage multipaged bimtap. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIMULTIBITMAP : IComparable, IComparable, IEquatable + { + private IntPtr data; + + /// + /// A read-only field that represents a handle that has been initialized to zero. + /// + public static readonly FIMULTIBITMAP Zero; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIMULTIBITMAP left, FIMULTIBITMAP right) + { + return (left.data == right.data); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIMULTIBITMAP left, FIMULTIBITMAP right) + { + return (left.data != right.data); + } + + /// + /// Gets whether the handle is a null or not. + /// + /// true if this handle is a null; + /// otherwise, false. + public bool IsNull + { + get + { + return (data == IntPtr.Zero); + } + } + + /// + /// Sets the handle to null. + /// + public void SetNull() + { + data = IntPtr.Zero; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return data.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return data.GetHashCode(); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIMULTIBITMAP) && (this == ((FIMULTIBITMAP)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// true if the current object is equal to the other parameter; otherwise, false. + public bool Equals(FIMULTIBITMAP other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIMULTIBITMAP)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIMULTIBITMAP)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIMULTIBITMAP other) + { + return this.data.ToInt64().CompareTo(other.data.ToInt64()); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FIMEMORY structure is a handle to an opened memory stream. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIMEMORY : IComparable, IComparable, IEquatable + { + private IntPtr data; + + /// + /// A read-only field that represents a handle that has been initialized to zero. + /// + public static readonly FIMEMORY Zero; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIMEMORY left, FIMEMORY right) + { + return (left.data == right.data); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIMEMORY left, FIMEMORY right) + { + return (left.data != right.data); + } + + /// + /// Gets whether the pointer is a null pointer or not. + /// + /// true if this is a null pointer; + /// otherwise, false. + public bool IsNull + { + get + { + return (data == IntPtr.Zero); + } + } + + /// + /// Sets the handle to null. + /// + public void SetNull() + { + data = IntPtr.Zero; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return data.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return data.GetHashCode(); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIMEMORY) && (this == ((FIMEMORY)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// true if the current object is equal to the other parameter; otherwise, false. + public bool Equals(FIMEMORY other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIMEMORY)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIMEMORY)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIMEMORY other) + { + return this.data.ToInt64().CompareTo(other.data.ToInt64()); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FIMETADATA structure is an unique search handle for metadata search operations. + /// + /// + /// The FIMETADATA structure is usually returned by the + /// + /// function and then used on subsequent calls to + /// . + /// When the FIMETADATA handle is no longer used, it needs to be freed by the + /// function. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIMETADATA : IComparable, IComparable, IEquatable + { + private IntPtr data; + + /// + /// A read-only field that represents a handle that has been initialized to zero. + /// + public static readonly FIMETADATA Zero; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIMETADATA left, FIMETADATA right) + { + return (left.data == right.data); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIMETADATA left, FIMETADATA right) + { + return (left.data != right.data); + } + + /// + /// Gets whether the pointer is a null pointer or not. + /// + /// true if this is a null pointer; + /// otherwise, false. + public bool IsNull + { + get + { + return (data == IntPtr.Zero); + } + } + + /// + /// Sets the handle to null. + /// + public void SetNull() + { + data = IntPtr.Zero; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return data.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return data.GetHashCode(); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIMETADATA) && (this == ((FIMETADATA)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// true if the current object is equal to the other parameter; otherwise, false. + public bool Equals(FIMETADATA other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIMETADATA)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIMETADATA)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIMETADATA other) + { + return this.data.ToInt64().CompareTo(other.data.ToInt64()); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FITAG structure is a handle to a FreeImage metadata tag. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FITAG : IComparable, IComparable, IEquatable + { + private IntPtr data; + + /// + /// A read-only field that represents a handle that has been initialized to zero. + /// + public static readonly FITAG Zero; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FITAG left, FITAG right) + { + return (left.data == right.data); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FITAG left, FITAG right) + { + return (left.data != right.data); + } + + /// + /// Gets whether the pointer is a null pointer or not. + /// + /// true if this is a null pointer; + /// otherwise, false. + public bool IsNull + { + get + { + return (data == IntPtr.Zero); + } + } + + /// + /// Sets the handle to null. + /// + public void SetNull() + { + data = IntPtr.Zero; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return data.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return data.GetHashCode(); + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// The to compare with the current . + /// true if the specified is equal to the current ; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FITAG) && (this == ((FITAG)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// true if the current object is equal to the other parameter; otherwise, false. + public bool Equals(FITAG other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FITAG)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FITAG)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FITAG other) + { + return this.data.ToInt64().CompareTo(other.data.ToInt64()); + } + } +} + +namespace FreeImageAPI.IO +{ + /// + /// Structure for implementing access to custom handles. + /// + [StructLayout(LayoutKind.Sequential)] + public struct FreeImageIO + { + /// + /// Delegate to the C++ function fread. + /// + public ReadProc readProc; + + /// + /// Delegate to the C++ function fwrite. + /// + public WriteProc writeProc; + + /// + /// Delegate to the C++ function fseek. + /// + public SeekProc seekProc; + + /// + /// Delegate to the C++ function ftell. + /// + public TellProc tellProc; + } +} + +namespace FreeImageAPI +{ + /// + /// The RGBQUAD structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 8 bits and so, takes values in the range from 0 to 255. + /// + /// + /// + /// The RGBQUAD structure provides access to an underlying Win32 RGBQUAD + /// structure. To determine the alpha, red, green or blue component of a color, + /// use the rgbReserved, rgbRed, rgbGreen or rgbBlue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the RGBQUAD structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the RGBQUAD structure and my be used in all situations which require + /// an RGBQUAD type. + /// + /// + /// Each color component rgbReserved, rgbRed, rgbGreen or rgbBlue of RGBQUAD + /// is translated into it's corresponding color component A, R, G or B of + /// by an one-to-one manner and vice versa. + /// + /// + /// Conversion from System.Drawing.Color to RGBQUAD + /// + /// RGBQUAD.component = Color.component + /// + /// Conversion from RGBQUAD to System.Drawing.Color + /// + /// Color.component = RGBQUAD.component + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// RGBQUAD structure and the structure. + /// + /// RGBQUAD rgbq; + /// // Initialize the structure using a native .NET Color structure. + /// rgbq = new RGBQUAD(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// rgbq = Color.DarkSeaGreen; + /// // Convert the RGBQUAD instance into a native .NET Color + /// // using its implicit operator. + /// Color color = rgbq; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = rgbq.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Explicit)] + public struct RGBQUAD : IComparable, IComparable, IEquatable + { + /// + /// The blue color component. + /// + [FieldOffset(0)] + public byte rgbBlue; + + /// + /// The green color component. + /// + [FieldOffset(1)] + public byte rgbGreen; + + /// + /// The red color component. + /// + [FieldOffset(2)] + public byte rgbRed; + + /// + /// The alpha color component. + /// + [FieldOffset(3)] + public byte rgbReserved; + + /// + /// The color's value. + /// + [FieldOffset(0)] + public uint uintValue; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public RGBQUAD(Color color) + { + uintValue = 0u; + rgbBlue = color.B; + rgbGreen = color.G; + rgbRed = color.R; + rgbReserved = color.A; + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(RGBQUAD left, RGBQUAD right) + { + return (left.uintValue == right.uintValue); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(RGBQUAD left, RGBQUAD right) + { + return (left.uintValue != right.uintValue); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator RGBQUAD(Color value) + { + return new RGBQUAD(value); + } + + /// + /// Converts the value of a structure to a Color structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(RGBQUAD value) + { + return value.Color; + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator RGBQUAD(uint value) + { + RGBQUAD result = new RGBQUAD(); + result.uintValue = value; + return result; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator uint(RGBQUAD value) + { + return value.uintValue; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + rgbReserved, + rgbRed, + rgbGreen, + rgbBlue); + } + set + { + rgbRed = value.R; + rgbGreen = value.G; + rgbBlue = value.B; + rgbReserved = value.A; + } + } + + /// + /// Converts an array of into an array of + /// . + /// + /// The array to convert. + /// An array of . + public static RGBQUAD[] ToRGBQUAD(Color[] array) + { + if (array == null) + return null; + + RGBQUAD[] result = new RGBQUAD[array.Length]; + for (int i = 0; i < array.Length; i++) + { + result[i] = array[i]; + } + return result; + } + + /// + /// Converts an array of into an array of + /// . + /// + /// The array to convert. + /// An array of . + public static Color[] ToColor(RGBQUAD[] array) + { + if (array == null) + return null; + + Color[] result = new Color[array.Length]; + for (int i = 0; i < array.Length; i++) + { + result[i] = array[i].Color; + } + return result; + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is RGBQUAD)) + { + throw new ArgumentException("obj"); + } + return CompareTo((RGBQUAD)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(RGBQUAD other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is RGBQUAD) && (this == ((RGBQUAD)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(RGBQUAD other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The RGBTRIPLE structure describes a color consisting of relative + /// intensities of red, green and blue value. Each single color component + /// consumes 8 bits and so, takes values in the range from 0 to 255. + /// + /// + /// + /// The RGBTRIPLE structure provides access to an underlying Win32 RGBTRIPLE + /// structure. To determine the red, green or blue component of a color, use the + /// rgbtRed, rgbtGreen or rgbtBlue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the RGBTRIPLE structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the RGBTRIPLE structure and my be used in all situations which require + /// an RGBTRIPLE type. + /// + /// + /// Each of the color components rgbtRed, rgbtGreen or rgbtBlue of RGBTRIPLE is + /// translated into it's corresponding color component R, G or B of + /// by an one-to-one manner and vice versa. + /// When converting from into RGBTRIPLE, the + /// color's alpha value is ignored and assumed to be 255 when converting from + /// RGBTRIPLE into , creating a fully + /// opaque color. + /// + /// + /// Conversion from System.Drawing.Color to RGBTRIPLE + /// + /// RGBTRIPLE.component = Color.component + /// + /// Conversion from RGBTRIPLE to System.Drawing.Color + /// + /// Color.component = RGBTRIPLE.component + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// RGBTRIPLE structure and the structure. + /// + /// RGBTRIPLE rgbt; + /// // Initialize the structure using a native .NET Color structure. + /// rgbt = new RGBTRIPLE(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// rgbt = Color.DarkSeaGreen; + /// // Convert the RGBTRIPLE instance into a native .NET Color + /// // using its implicit operator. + /// Color color = rgbt; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = rgbt.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct RGBTRIPLE : IComparable, IComparable, IEquatable + { + /// + /// The blue color component. + /// + public byte rgbtBlue; + + /// + /// The green color component. + /// + public byte rgbtGreen; + + /// + /// The red color component. + /// + public byte rgbtRed; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public RGBTRIPLE(Color color) + { + rgbtBlue = color.B; + rgbtGreen = color.G; + rgbtRed = color.R; + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(RGBTRIPLE left, RGBTRIPLE right) + { + return + left.rgbtBlue == right.rgbtBlue && + left.rgbtGreen == right.rgbtGreen && + left.rgbtRed == right.rgbtRed; + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(RGBTRIPLE left, RGBTRIPLE right) + { + return !(left == right); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator RGBTRIPLE(Color value) + { + return new RGBTRIPLE(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(RGBTRIPLE value) + { + return value.Color; + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator RGBTRIPLE(uint value) + { + RGBTRIPLE result = new RGBTRIPLE(); + result.rgbtBlue = (byte)(value & 0xFF); + result.rgbtGreen = (byte)((value >> 8) & 0xFF); + result.rgbtRed = (byte)((value >> 16) & 0xFF); + return result; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator uint(RGBTRIPLE value) + { + return (uint)((value.rgbtRed << 16) | (value.rgbtGreen << 8) | (value.rgbtBlue)); + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + rgbtRed, + rgbtGreen, + rgbtBlue); + } + set + { + rgbtBlue = value.B; + rgbtGreen = value.G; + rgbtRed = value.R; + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is RGBTRIPLE)) + { + throw new ArgumentException("obj"); + } + return CompareTo((RGBTRIPLE)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(RGBTRIPLE other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is RGBTRIPLE) && (this == ((RGBTRIPLE)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this + /// structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(RGBTRIPLE other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FIRGBA16 structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 16 bits and so, takes values in the range from 0 to 65535. + /// + /// + /// + /// The FIRGBA16 structure provides access to an underlying FreeImage FIRGBA16 + /// structure. To determine the alpha, red, green or blue component of a color, + /// use the alpha, red, green or blue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FIRGBA16 structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FIRGBA16 structure and my be used in all situations which require + /// an FIRGBA16 type. + /// + /// + /// Each color component alpha, red, green or blue of FIRGBA16 + /// is translated into it's corresponding color component A, R, G or B of + /// by an 8 bit right shift and vice versa. + /// + /// + /// Conversion from System.Drawing.Color to FIRGBA16 + /// + /// FIRGBA16.component = Color.component << 8 + /// + /// Conversion from FIRGBA16 to System.Drawing.Color + /// + /// Color.component = FIRGBA16.component >> 8 + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FIRGBA16 structure and the structure. + /// + /// FIRGBA16 firgba16; + /// // Initialize the structure using a native .NET Color structure. + /// firgba16 = new FIRGBA16(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// firgba16 = Color.DarkSeaGreen; + /// // Convert the FIRGBA16 instance into a native .NET Color + /// // using its implicit operator. + /// Color color = firgba16; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = firgba16.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIRGBA16 : IComparable, IComparable, IEquatable + { + /// + /// The red color component. + /// + public ushort red; + + /// + /// The green color component. + /// + public ushort green; + + /// + /// The blue color component. + /// + public ushort blue; + + /// + /// The alpha color component. + /// + public ushort alpha; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FIRGBA16(Color color) + { + red = (ushort)(color.R << 8); + green = (ushort)(color.G << 8); + blue = (ushort)(color.B << 8); + alpha = (ushort)(color.A << 8); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIRGBA16 left, FIRGBA16 right) + { + return + ((left.alpha == right.alpha) && + (left.blue == right.blue) && + (left.green == right.green) && + (left.red == right.red)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIRGBA16 left, FIRGBA16 right) + { + return !(left == right); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRGBA16(Color value) + { + return new FIRGBA16(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FIRGBA16 value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb((alpha >> 8), (red >> 8), (green >> 8), (blue >> 8)); + } + set + { + red = (ushort)(value.R << 8); + green = (ushort)(value.G << 8); + blue = (ushort)(value.B << 8); + alpha = (ushort)(value.A << 8); + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIRGBA16)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIRGBA16)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIRGBA16 other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIRGBA16) && (this == ((FIRGBA16)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIRGBA16 other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FIRGB16 structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 16 bits and so, takes values in the range from 0 to 65535. + /// + /// + /// + /// The FIRGB16 structure provides access to an underlying FreeImage FIRGB16 + /// structure. To determine the red, green or blue component of a color, + /// use the red, green or blue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FIRGB16 structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FIRGB16 structure and my be used in all situations which require + /// an FIRGB16 type. + /// + /// + /// Each color component red, green or blue of FIRGB16 is translated into + /// it's corresponding color component R, G or B of + /// by right shifting 8 bits and shifting left 8 bits for the reverse conversion. + /// When converting from into FIRGB16, the + /// color's alpha value is ignored and assumed to be 255 when converting from + /// FIRGB16 into , creating a fully + /// opaque color. + /// + /// + /// Conversion from System.Drawing.Color to FIRGB16 + /// + /// FIRGB16.component = Color.component << 8 + /// + /// Conversion from FIRGB16 to System.Drawing.Color + /// + /// Color.component = FIRGB16.component >> 8 + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FIRGB16 structure and the structure. + /// + /// FIRGB16 firgb16; + /// // Initialize the structure using a native .NET Color structure. + /// firgb16 = new FIRGBA16(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// firgb16 = Color.DarkSeaGreen; + /// // Convert the FIRGB16 instance into a native .NET Color + /// // using its implicit operator. + /// Color color = firgb16; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = firgb16.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIRGB16 : IComparable, IComparable, IEquatable + { + /// + /// The red color component. + /// + public ushort red; + + /// + /// The green color component. + /// + public ushort green; + + /// + /// The blue color component. + /// + public ushort blue; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FIRGB16(Color color) + { + red = (ushort)(color.R << 8); + green = (ushort)(color.G << 8); + blue = (ushort)(color.B << 8); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIRGB16 left, FIRGB16 right) + { + return + ((left.blue == right.blue) && + (left.green == right.green) && + (left.red == right.red)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIRGB16 left, FIRGB16 right) + { + return !(left == right); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRGB16(Color value) + { + return new FIRGB16(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FIRGB16 value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb((red >> 8), (green >> 8), (blue >> 8)); + } + set + { + red = (ushort)(value.R << 8); + green = (ushort)(value.G << 8); + blue = (ushort)(value.B << 8); + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIRGB16)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIRGB16)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIRGB16 other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIRGB16) && (this == ((FIRGB16)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIRGB16 other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FIRGBAF structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 32 bits and takes values in the range from 0 to 1. + /// + /// + /// + /// The FIRGBAF structure provides access to an underlying FreeImage FIRGBAF + /// structure. To determine the alpha, red, green or blue component of a color, + /// use the alpha, red, green or blue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FIRGBAF structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FIRGBAF structure and my be used in all situations which require + /// an FIRGBAF type. + /// + /// + /// Each color component alpha, red, green or blue of FIRGBAF is translated + /// into it's corresponding color component A, R, G or B of + /// by linearly mapping the values of one range + /// into the other range and vice versa. + /// + /// + /// Conversion from System.Drawing.Color to FIRGBAF + /// + /// FIRGBAF.component = (float)Color.component / 255f + /// + /// Conversion from FIRGBAF to System.Drawing.Color + /// + /// Color.component = (int)(FIRGBAF.component * 255f) + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FIRGBAF structure and the structure. + /// + /// FIRGBAF firgbaf; + /// // Initialize the structure using a native .NET Color structure. + /// firgbaf = new FIRGBAF(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// firgbaf = Color.DarkSeaGreen; + /// // Convert the FIRGBAF instance into a native .NET Color + /// // using its implicit operator. + /// Color color = firgbaf; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = firgbaf.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIRGBAF : IComparable, IComparable, IEquatable + { + /// + /// The red color component. + /// + public float red; + + /// + /// The green color component. + /// + public float green; + + /// + /// The blue color component. + /// + public float blue; + + /// + /// The alpha color component. + /// + public float alpha; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FIRGBAF(Color color) + { + red = (float)color.R / 255f; + green = (float)color.G / 255f; + blue = (float)color.B / 255f; + alpha = (float)color.A / 255f; + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIRGBAF left, FIRGBAF right) + { + return + ((left.alpha == right.alpha) && + (left.blue == right.blue) && + (left.green == right.green) && + (left.red == right.red)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIRGBAF left, FIRGBAF right) + { + return !(left == right); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRGBAF(Color value) + { + return new FIRGBAF(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FIRGBAF value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + (int)(alpha * 255f), + (int)(red * 255f), + (int)(green * 255f), + (int)(blue * 255f)); + } + set + { + red = (float)value.R / 255f; + green = (float)value.G / 255f; + blue = (float)value.B / 255f; + alpha = (float)value.A / 255f; + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIRGBAF)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIRGBAF)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIRGBAF other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIRGBAF) && (this == ((FIRGBAF)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIRGBAF other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FIRGBF structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 32 bits and takes values in the range from 0 to 1. + /// + /// + /// + /// The FIRGBF structure provides access to an underlying FreeImage FIRGBF + /// structure. To determine the red, green or blue component of a color, use the + /// red, green or blue fields, respectively. + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FIRGBF structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FIRGBF structure and my be used in all situations which require + /// an FIRGBF type. + /// + /// + /// Each color component alpha, red, green or blue of FIRGBF is translated + /// into it's corresponding color component A, R, G or B of + /// by linearly mapping the values of one range + /// into the other range and vice versa. + /// When converting from into FIRGBF, the + /// color's alpha value is ignored and assumed to be 255 when converting from + /// FIRGBF into , creating a fully + /// opaque color. + /// + /// + /// Conversion from System.Drawing.Color to FIRGBF + /// + /// FIRGBF.component = (float)Color.component / 255f + /// + /// Conversion from FIRGBF to System.Drawing.Color + /// + /// Color.component = (int)(FIRGBF.component * 255f) + /// + /// The same conversion is also applied when the + /// property or the constructor + /// is invoked. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FIRGBF structure and the structure. + /// + /// FIRGBF firgbf; + /// // Initialize the structure using a native .NET Color structure. + /// firgbf = new FIRGBF(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// firgbf = Color.DarkSeaGreen; + /// // Convert the FIRGBF instance into a native .NET Color + /// // using its implicit operator. + /// Color color = firgbf; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = firgbf.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIRGBF : IComparable, IComparable, IEquatable + { + /// + /// The red color component. + /// + public float red; + + /// + /// The green color component. + /// + public float green; + + /// + /// The blue color component. + /// + public float blue; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FIRGBF(Color color) + { + red = (float)color.R / 255f; + green = (float)color.G / 255f; + blue = (float)color.B / 255f; + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FIRGBF left, FIRGBF right) + { + return + ((left.blue == right.blue) && + (left.green == right.green) && + (left.red == right.red)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FIRGBF left, FIRGBF right) + { + return !(left == right); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRGBF(Color value) + { + return new FIRGBF(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FIRGBF value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + (int)(red * 255f), + (int)(green * 255f), + (int)(blue * 255f)); + } + set + { + red = (float)value.R / 255f; + green = (float)value.G / 255f; + blue = (float)value.B / 255f; + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIRGBF)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FIRGBF)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIRGBF other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIRGBF) && (this == ((FIRGBF)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIRGBF other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FICOMPLEX structure describes a color consisting of a real and an imaginary part. + /// Each part is using 4 bytes of data. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FICOMPLEX : IComparable, IComparable, IEquatable + { + /// + /// Real part of the color. + /// + public double real; + + /// + /// Imaginary part of the color. + /// + public double imag; + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FICOMPLEX left, FICOMPLEX right) + { + return ((left.real == right.real) && (left.imag == right.imag)); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FICOMPLEX left, FICOMPLEX right) + { + return ((left.real != right.real) || (left.imag == right.imag)); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FICOMPLEX)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FICOMPLEX)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FICOMPLEX other) + { + return base.GetHashCode(); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FICOMPLEX) && (this == ((FICOMPLEX)obj))); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FICOMPLEX other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} + +namespace FreeImageAPI +{ + /// + /// This Structure contains ICC-Profile data. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FIICCPROFILE + { + private ICC_FLAGS flags; + private uint size; + private IntPtr data; + + /// + /// Creates a new ICC-Profile for . + /// + /// Handle to a FreeImage bitmap. + /// The ICC-Profile data. + /// + /// is null. + public FIICCPROFILE(FIBITMAP dib, byte[] data) + : this(dib, data, (int)data.Length) + { + } + + /// + /// Creates a new ICC-Profile for . + /// + /// Handle to a FreeImage bitmap. + /// The ICC-Profile data. + /// Number of bytes to use from data. + /// + /// is null. + public unsafe FIICCPROFILE(FIBITMAP dib, byte[] data, int size) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + FIICCPROFILE prof; + size = Math.Min(size, (int)data.Length); + prof = *(FIICCPROFILE*)FreeImage.CreateICCProfile(dib, data, size); + this.flags = prof.flags; + this.size = prof.size; + this.data = prof.data; + } + + /// + /// Info flag of the profile. + /// + public ICC_FLAGS Flags + { + get { return flags; } + } + + /// + /// Profile's size measured in bytes. + /// + public uint Size + { + get { return size; } + } + + /// + /// Points to a block of contiguous memory containing the profile. + /// + public IntPtr DataPointer + { + get { return data; } + } + + /// + /// Copy of the ICC-Profiles data. + /// + public unsafe byte[] Data + { + get + { + byte[] result; + FreeImage.CopyMemory(result = new byte[size], data.ToPointer(), size); + return result; + } + } + + /// + /// Indicates whether the profile is CMYK. + /// + public bool IsCMYK + { + get + { + return ((flags & ICC_FLAGS.FIICC_COLOR_IS_CMYK) != 0); + } + } + } +} + +namespace FreeImageAPI.Plugins +{ + /// + /// The structure contains functionpointers that make up a FreeImage plugin. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct Plugin + { + /// + /// Delegate to a function that returns a string which describes + /// the plugins format. + /// + public FormatProc formatProc; + + /// + /// Delegate to a function that returns a string which contains + /// a more detailed description. + /// + public DescriptionProc descriptionProc; + + /// + /// Delegate to a function that returns a comma seperated list + /// of file extensions the plugin can read or write. + /// + public ExtensionListProc extensionListProc; + + /// + /// Delegate to a function that returns a regular expression that + /// can be used to idientify whether a file can be handled by the plugin. + /// + public RegExprProc regExprProc; + + /// + /// Delegate to a function that opens a file. + /// + public OpenProc openProc; + + /// + /// Delegate to a function that closes a previosly opened file. + /// + public CloseProc closeProc; + + /// + /// Delegate to a function that returns the number of pages of a multipage + /// bitmap if the plugin is capable of handling multipage bitmaps. + /// + public PageCountProc pageCountProc; + + /// + /// UNKNOWN + /// + public PageCapabilityProc pageCapabilityProc; + + /// + /// Delegate to a function that loads and decodes a bitmap into memory. + /// + public LoadProc loadProc; + + /// + /// Delegate to a function that saves a bitmap. + /// + public SaveProc saveProc; + + /// + /// Delegate to a function that determines whether the source is a valid image. + /// + public ValidateProc validateProc; + + /// + /// Delegate to a function that returns a string which contains + /// the plugin's mime type. + /// + public MimeProc mimeProc; + + /// + /// Delegate to a function that returns whether the plugin can handle the + /// specified color depth. + /// + public SupportsExportBPPProc supportsExportBPPProc; + + /// + /// Delegate to a function that returns whether the plugin can handle the + /// specified image type. + /// + public SupportsExportTypeProc supportsExportTypeProc; + + /// + /// Delegate to a function that returns whether the plugin can handle + /// ICC-Profiles. + /// + public SupportsICCProfilesProc supportsICCProfilesProc; + } +} + + #endregion + + #region Enums + +namespace FreeImageAPI.Metadata +{ + /// + /// Specifies how a single frame will be handled after being displayed. + /// + public enum DisposalMethodType : byte + { + /// + /// Same behavior as but should not be used. + /// + Unspecified, + + /// + /// The image is left in place and will be overdrawn by the next image. + /// + Leave, + + /// + /// The area of the image will be blanked out by its background. + /// + Background, + + /// + /// Restores the the area of the image to the state it was before it + /// has been dawn. + /// + Previous, + } +} + +namespace FreeImageAPI +{ + /// + /// I/O image format identifiers. + /// + public enum FREE_IMAGE_FORMAT + { + /// + /// Unknown format (returned value only, never use it as input value) + /// + FIF_UNKNOWN = -1, + /// + /// Windows or OS/2 Bitmap File (*.BMP) + /// + FIF_BMP = 0, + /// + /// Windows Icon (*.ICO) + /// + FIF_ICO = 1, + /// + /// Independent JPEG Group (*.JPG, *.JIF, *.JPEG, *.JPE) + /// + FIF_JPEG = 2, + /// + /// JPEG Network Graphics (*.JNG) + /// + FIF_JNG = 3, + /// + /// Commodore 64 Koala format (*.KOA) + /// + FIF_KOALA = 4, + /// + /// Amiga IFF (*.IFF, *.LBM) + /// + FIF_LBM = 5, + /// + /// Amiga IFF (*.IFF, *.LBM) + /// + FIF_IFF = 5, + /// + /// Multiple Network Graphics (*.MNG) + /// + FIF_MNG = 6, + /// + /// Portable Bitmap (ASCII) (*.PBM) + /// + FIF_PBM = 7, + /// + /// Portable Bitmap (BINARY) (*.PBM) + /// + FIF_PBMRAW = 8, + /// + /// Kodak PhotoCD (*.PCD) + /// + FIF_PCD = 9, + /// + /// Zsoft Paintbrush PCX bitmap format (*.PCX) + /// + FIF_PCX = 10, + /// + /// Portable Graymap (ASCII) (*.PGM) + /// + FIF_PGM = 11, + /// + /// Portable Graymap (BINARY) (*.PGM) + /// + FIF_PGMRAW = 12, + /// + /// Portable Network Graphics (*.PNG) + /// + FIF_PNG = 13, + /// + /// Portable Pixelmap (ASCII) (*.PPM) + /// + FIF_PPM = 14, + /// + /// Portable Pixelmap (BINARY) (*.PPM) + /// + FIF_PPMRAW = 15, + /// + /// Sun Rasterfile (*.RAS) + /// + FIF_RAS = 16, + /// + /// truevision Targa files (*.TGA, *.TARGA) + /// + FIF_TARGA = 17, + /// + /// Tagged Image File Format (*.TIF, *.TIFF) + /// + FIF_TIFF = 18, + /// + /// Wireless Bitmap (*.WBMP) + /// + FIF_WBMP = 19, + /// + /// Adobe Photoshop (*.PSD) + /// + FIF_PSD = 20, + /// + /// Dr. Halo (*.CUT) + /// + FIF_CUT = 21, + /// + /// X11 Bitmap Format (*.XBM) + /// + FIF_XBM = 22, + /// + /// X11 Pixmap Format (*.XPM) + /// + FIF_XPM = 23, + /// + /// DirectDraw Surface (*.DDS) + /// + FIF_DDS = 24, + /// + /// Graphics Interchange Format (*.GIF) + /// + FIF_GIF = 25, + /// + /// High Dynamic Range (*.HDR) + /// + FIF_HDR = 26, + /// + /// Raw Fax format CCITT G3 (*.G3) + /// + FIF_FAXG3 = 27, + /// + /// Silicon Graphics SGI image format (*.SGI) + /// + FIF_SGI = 28, + /// + /// OpenEXR format (*.EXR) + /// + FIF_EXR = 29, + /// + /// JPEG-2000 format (*.J2K, *.J2C) + /// + FIF_J2K = 30, + /// + /// JPEG-2000 format (*.JP2) + /// + FIF_JP2 = 31, + /// + /// Portable FloatMap (*.PFM) + /// + FIF_PFM = 32, + /// + /// Macintosh PICT (*.PICT) + /// + FIF_PICT = 33, + /// + /// RAW camera image (*.*) + /// + FIF_RAW = 34, + } +} + +namespace FreeImageAPI +{ + /// + /// Image types used in FreeImage. + /// + public enum FREE_IMAGE_TYPE + { + /// + /// unknown type + /// + FIT_UNKNOWN = 0, + /// + /// standard image : 1-, 4-, 8-, 16-, 24-, 32-bit + /// + FIT_BITMAP = 1, + /// + /// array of unsigned short : unsigned 16-bit + /// + FIT_UINT16 = 2, + /// + /// array of short : signed 16-bit + /// + FIT_INT16 = 3, + /// + /// array of unsigned long : unsigned 32-bit + /// + FIT_UINT32 = 4, + /// + /// array of long : signed 32-bit + /// + FIT_INT32 = 5, + /// + /// array of float : 32-bit IEEE floating point + /// + FIT_FLOAT = 6, + /// + /// array of double : 64-bit IEEE floating point + /// + FIT_DOUBLE = 7, + /// + /// array of FICOMPLEX : 2 x 64-bit IEEE floating point + /// + FIT_COMPLEX = 8, + /// + /// 48-bit RGB image : 3 x 16-bit + /// + FIT_RGB16 = 9, + /// + /// 64-bit RGBA image : 4 x 16-bit + /// + FIT_RGBA16 = 10, + /// + /// 96-bit RGB float image : 3 x 32-bit IEEE floating point + /// + FIT_RGBF = 11, + /// + /// 128-bit RGBA float image : 4 x 32-bit IEEE floating point + /// + FIT_RGBAF = 12 + } +} + +namespace FreeImageAPI +{ + /// + /// Constants used in color filling routines. + /// + public enum FREE_IMAGE_COLOR_OPTIONS + { + /// + /// Default value. + /// + FICO_DEFAULT = 0x0, + /// + /// color is RGB color (contains no valid alpha channel). + /// + FICO_RGB = 0x0, + /// + /// color is RGBA color (contains a valid alpha channel). + /// + FICO_RGBA = 0x1, + /// + /// Lookup nearest RGB color from palette. + /// + FICO_NEAREST_COLOR = 0x0, + /// + /// Lookup equal RGB color from palette. + /// + FICO_EQUAL_COLOR = 0x2, + /// + /// contains the palette index to be used. + /// + FICO_ALPHA_IS_INDEX = 0x4, + } +} + +namespace FreeImageAPI +{ + /// + /// Image color types used in FreeImage. + /// + public enum FREE_IMAGE_COLOR_TYPE + { + /// + /// min value is white + /// + FIC_MINISWHITE = 0, + /// + /// min value is black + /// + FIC_MINISBLACK = 1, + /// + /// RGB color model + /// + FIC_RGB = 2, + /// + /// color map indexed + /// + FIC_PALETTE = 3, + /// + /// RGB color model with alpha channel + /// + FIC_RGBALPHA = 4, + /// + /// CMYK color model + /// + FIC_CMYK = 5 + } +} + +namespace FreeImageAPI +{ + /// + /// Color quantization algorithms. + /// Constants used in FreeImage_ColorQuantize. + /// + public enum FREE_IMAGE_QUANTIZE + { + /// + /// Xiaolin Wu color quantization algorithm + /// + FIQ_WUQUANT = 0, + /// + /// NeuQuant neural-net quantization algorithm by Anthony Dekker + /// + FIQ_NNQUANT = 1 + } +} + +namespace FreeImageAPI +{ + /// + /// Dithering algorithms. + /// Constants used in FreeImage_Dither. + /// + public enum FREE_IMAGE_DITHER + { + /// + /// Floyd and Steinberg error diffusion + /// + FID_FS = 0, + /// + /// Bayer ordered dispersed dot dithering (order 2 dithering matrix) + /// + FID_BAYER4x4 = 1, + /// + /// Bayer ordered dispersed dot dithering (order 3 dithering matrix) + /// + FID_BAYER8x8 = 2, + /// + /// Ordered clustered dot dithering (order 3 - 6x6 matrix) + /// + FID_CLUSTER6x6 = 3, + /// + /// Ordered clustered dot dithering (order 4 - 8x8 matrix) + /// + FID_CLUSTER8x8 = 4, + /// + /// Ordered clustered dot dithering (order 8 - 16x16 matrix) + /// + FID_CLUSTER16x16 = 5, + /// + /// Bayer ordered dispersed dot dithering (order 4 dithering matrix) + /// + FID_BAYER16x16 = 6 + } +} + +namespace FreeImageAPI +{ + /// + /// Lossless JPEG transformations constants used in FreeImage_JPEGTransform. + /// + public enum FREE_IMAGE_JPEG_OPERATION + { + /// + /// no transformation + /// + FIJPEG_OP_NONE = 0, + /// + /// horizontal flip + /// + FIJPEG_OP_FLIP_H = 1, + /// + /// vertical flip + /// + FIJPEG_OP_FLIP_V = 2, + /// + /// transpose across UL-to-LR axis + /// + FIJPEG_OP_TRANSPOSE = 3, + /// + /// transpose across UR-to-LL axis + /// + FIJPEG_OP_TRANSVERSE = 4, + /// + /// 90-degree clockwise rotation + /// + FIJPEG_OP_ROTATE_90 = 5, + /// + /// 180-degree rotation + /// + FIJPEG_OP_ROTATE_180 = 6, + /// + /// 270-degree clockwise (or 90 ccw) + /// + FIJPEG_OP_ROTATE_270 = 7 + } +} + +namespace FreeImageAPI +{ + /// + /// Tone mapping operators. Constants used in FreeImage_ToneMapping. + /// + public enum FREE_IMAGE_TMO + { + /// + /// Adaptive logarithmic mapping (F. Drago, 2003) + /// + FITMO_DRAGO03 = 0, + /// + /// Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005) + /// + FITMO_REINHARD05 = 1, + /// + /// Gradient domain high dynamic range compression (R. Fattal, 2002) + /// + FITMO_FATTAL02 + } +} + +namespace FreeImageAPI +{ + /// + /// Upsampling / downsampling filters. Constants used in FreeImage_Rescale. + /// + public enum FREE_IMAGE_FILTER + { + /// + /// Box, pulse, Fourier window, 1st order (constant) b-spline + /// + FILTER_BOX = 0, + /// + /// Mitchell and Netravali's two-param cubic filter + /// + FILTER_BICUBIC = 1, + /// + /// Bilinear filter + /// + FILTER_BILINEAR = 2, + /// + /// 4th order (cubic) b-spline + /// + FILTER_BSPLINE = 3, + /// + /// Catmull-Rom spline, Overhauser spline + /// + FILTER_CATMULLROM = 4, + /// + /// Lanczos3 filter + /// + FILTER_LANCZOS3 = 5 + } +} + +namespace FreeImageAPI +{ + /// + /// Color channels. Constants used in color manipulation routines. + /// + public enum FREE_IMAGE_COLOR_CHANNEL + { + /// + /// Use red, green and blue channels + /// + FICC_RGB = 0, + /// + /// Use red channel + /// + FICC_RED = 1, + /// + /// Use green channel + /// + FICC_GREEN = 2, + /// + /// Use blue channel + /// + FICC_BLUE = 3, + /// + /// Use alpha channel + /// + FICC_ALPHA = 4, + /// + /// Use black channel + /// + FICC_BLACK = 5, + /// + /// Complex images: use real part + /// + FICC_REAL = 6, + /// + /// Complex images: use imaginary part + /// + FICC_IMAG = 7, + /// + /// Complex images: use magnitude + /// + FICC_MAG = 8, + /// + /// Complex images: use phase + /// + FICC_PHASE = 9 + } +} + +namespace FreeImageAPI +{ + /// + /// Tag data type information (based on TIFF specifications) + /// Note: RATIONALs are the ratio of two 32-bit integer values. + /// + public enum FREE_IMAGE_MDTYPE + { + /// + /// placeholder + /// + FIDT_NOTYPE = 0, + /// + /// 8-bit unsigned integer + /// + FIDT_BYTE = 1, + /// + /// 8-bit bytes w/ last byte null + /// + FIDT_ASCII = 2, + /// + /// 16-bit unsigned integer + /// + FIDT_SHORT = 3, + /// + /// 32-bit unsigned integer + /// + FIDT_LONG = 4, + /// + /// 64-bit unsigned fraction + /// + FIDT_RATIONAL = 5, + /// + /// 8-bit signed integer + /// + FIDT_SBYTE = 6, + /// + /// 8-bit untyped data + /// + FIDT_UNDEFINED = 7, + /// + /// 16-bit signed integer + /// + FIDT_SSHORT = 8, + /// + /// 32-bit signed integer + /// + FIDT_SLONG = 9, + /// + /// 64-bit signed fraction + /// + FIDT_SRATIONAL = 10, + /// + /// 32-bit IEEE floating point + /// + FIDT_FLOAT = 11, + /// + /// 64-bit IEEE floating point + /// + FIDT_DOUBLE = 12, + /// + /// 32-bit unsigned integer (offset) + /// + FIDT_IFD = 13, + /// + /// 32-bit RGBQUAD + /// + FIDT_PALETTE = 14 + } +} + +namespace FreeImageAPI +{ + /// + /// Metadata models supported by FreeImage. + /// + public enum FREE_IMAGE_MDMODEL + { + /// + /// No data + /// + FIMD_NODATA = -1, + /// + /// single comment or keywords + /// + FIMD_COMMENTS = 0, + /// + /// Exif-TIFF metadata + /// + FIMD_EXIF_MAIN = 1, + /// + /// Exif-specific metadata + /// + FIMD_EXIF_EXIF = 2, + /// + /// Exif GPS metadata + /// + FIMD_EXIF_GPS = 3, + /// + /// Exif maker note metadata + /// + FIMD_EXIF_MAKERNOTE = 4, + /// + /// Exif interoperability metadata + /// + FIMD_EXIF_INTEROP = 5, + /// + /// IPTC/NAA metadata + /// + FIMD_IPTC = 6, + /// + /// Abobe XMP metadata + /// + FIMD_XMP = 7, + /// + /// GeoTIFF metadata + /// + FIMD_GEOTIFF = 8, + /// + /// Animation metadata + /// + FIMD_ANIMATION = 9, + /// + /// Used to attach other metadata types to a dib + /// + FIMD_CUSTOM = 10 + } +} + +namespace FreeImageAPI +{ + /// + /// Flags used in load functions. + /// + [System.Flags] + public enum FREE_IMAGE_LOAD_FLAGS + { + /// + /// Default option for all types. + /// + DEFAULT = 0, + /// + /// Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color. + /// + GIF_LOAD256 = 1, + /// + /// 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading. + /// + GIF_PLAYBACK = 2, + /// + /// Convert to 32bpp and create an alpha channel from the AND-mask when loading. + /// + ICO_MAKEALPHA = 1, + /// + /// Load the file as fast as possible, sacrificing some quality. + /// + JPEG_FAST = 0x0001, + /// + /// Load the file with the best quality, sacrificing some speed. + /// + JPEG_ACCURATE = 0x0002, + /// + /// Load separated CMYK "as is" (use | to combine with other load flags). + /// + JPEG_CMYK = 0x0004, + /// + /// Load and rotate according to Exif 'Orientation' tag if available. + /// + JPEG_EXIFROTATE = 0x0008, + /// + /// Load the bitmap sized 768 x 512. + /// + PCD_BASE = 1, + /// + /// Load the bitmap sized 384 x 256. + /// + PCD_BASEDIV4 = 2, + /// + /// Load the bitmap sized 192 x 128. + /// + PCD_BASEDIV16 = 3, + /// + /// Avoid gamma correction. + /// + PNG_IGNOREGAMMA = 1, + /// + /// If set the loader converts RGB555 and ARGB8888 -> RGB888. + /// + TARGA_LOAD_RGB888 = 1, + /// + /// Reads tags for separated CMYK. + /// + TIFF_CMYK = 0x0001, + /// + /// Tries to load the JPEG preview image, embedded in + /// Exif Metadata or load the image as RGB 24-bit if no + /// preview image is available. + /// + RAW_PREVIEW = 0x1, + /// + /// Loads the image as RGB 24-bit. + /// + RAW_DISPLAY = 0x2, + } +} + +namespace FreeImageAPI +{ + /// + /// Flags used in save functions. + /// + [System.Flags] + public enum FREE_IMAGE_SAVE_FLAGS + { + /// + /// Default option for all types. + /// + DEFAULT = 0, + /// + /// Save with run length encoding. + /// + BMP_SAVE_RLE = 1, + /// + /// Save data as float instead of as half (not recommended). + /// + EXR_FLOAT = 0x0001, + /// + /// Save with no compression. + /// + EXR_NONE = 0x0002, + /// + /// Save with zlib compression, in blocks of 16 scan lines. + /// + EXR_ZIP = 0x0004, + /// + /// Save with piz-based wavelet compression. + /// + EXR_PIZ = 0x0008, + /// + /// Save with lossy 24-bit float compression. + /// + EXR_PXR24 = 0x0010, + /// + /// Save with lossy 44% float compression - goes to 22% when combined with EXR_LC. + /// + EXR_B44 = 0x0020, + /// + /// Save images with one luminance and two chroma channels, rather than as RGB (lossy compression). + /// + EXR_LC = 0x0040, + /// + /// Save with superb quality (100:1). + /// + JPEG_QUALITYSUPERB = 0x80, + /// + /// Save with good quality (75:1). + /// + JPEG_QUALITYGOOD = 0x0100, + /// + /// Save with normal quality (50:1). + /// + JPEG_QUALITYNORMAL = 0x0200, + /// + /// Save with average quality (25:1). + /// + JPEG_QUALITYAVERAGE = 0x0400, + /// + /// Save with bad quality (10:1). + /// + JPEG_QUALITYBAD = 0x0800, + /// + /// Save as a progressive-JPEG (use | to combine with other save flags). + /// + JPEG_PROGRESSIVE = 0x2000, + /// + /// Save with high 4x1 chroma subsampling (4:1:1). + /// + JPEG_SUBSAMPLING_411 = 0x1000, + /// + /// Save with medium 2x2 medium chroma (4:2:0). + /// + JPEG_SUBSAMPLING_420 = 0x4000, + /// + /// Save with low 2x1 chroma subsampling (4:2:2). + /// + JPEG_SUBSAMPLING_422 = 0x8000, + /// + /// Save with no chroma subsampling (4:4:4). + /// + JPEG_SUBSAMPLING_444 = 0x10000, + /// + /// Save using ZLib level 1 compression flag + /// (default value is ). + /// + PNG_Z_BEST_SPEED = 0x0001, + /// + /// Save using ZLib level 6 compression flag (default recommended value). + /// + PNG_Z_DEFAULT_COMPRESSION = 0x0006, + /// + /// save using ZLib level 9 compression flag + /// (default value is ). + /// + PNG_Z_BEST_COMPRESSION = 0x0009, + /// + /// Save without ZLib compression. + /// + PNG_Z_NO_COMPRESSION = 0x0100, + /// + /// Save using Adam7 interlacing (use | to combine with other save flags). + /// + PNG_INTERLACED = 0x0200, + /// + /// If set the writer saves in ASCII format (i.e. P1, P2 or P3). + /// + PNM_SAVE_ASCII = 1, + /// + /// Stores tags for separated CMYK (use | to combine with compression flags). + /// + TIFF_CMYK = 0x0001, + /// + /// Save using PACKBITS compression. + /// + TIFF_PACKBITS = 0x0100, + /// + /// Save using DEFLATE compression (a.k.a. ZLIB compression). + /// + TIFF_DEFLATE = 0x0200, + /// + /// Save using ADOBE DEFLATE compression. + /// + TIFF_ADOBE_DEFLATE = 0x0400, + /// + /// Save without any compression. + /// + TIFF_NONE = 0x0800, + /// + /// Save using CCITT Group 3 fax encoding. + /// + TIFF_CCITTFAX3 = 0x1000, + /// + /// Save using CCITT Group 4 fax encoding. + /// + TIFF_CCITTFAX4 = 0x2000, + /// + /// Save using LZW compression. + /// + TIFF_LZW = 0x4000, + /// + /// Save using JPEG compression. + /// + TIFF_JPEG = 0x8000 + } +} + +namespace FreeImageAPI +{ + /// + /// Flags for ICC profiles. + /// + [System.Flags] + public enum ICC_FLAGS : ushort + { + /// + /// Default value. + /// + FIICC_DEFAULT = 0x00, + /// + /// The color is CMYK. + /// + FIICC_COLOR_IS_CMYK = 0x01 + } +} + + #endregion + + #region Delegates + +namespace FreeImageAPI +{ + // Delegates used by the FreeImageIO structure + + /// + /// Delegate for capturing FreeImage error messages. + /// + /// The format of the image. + /// The errormessage. + // DLL_API is missing in the definition of the callbackfuntion. + [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi, ThrowOnUnmappableChar = false)] + public delegate void OutputMessageFunction(FREE_IMAGE_FORMAT fif, string message); +} + +namespace FreeImageAPI.IO +{ + /// + /// Delegate to the C++ function fread. + /// + /// Pointer to read from. + /// Item size in bytes. + /// Maximum number of items to be read. + /// Handle/stream to read from. + /// Number of full items actually read, + /// which may be less than count if an error occurs or + /// if the end of the file is encountered before reaching count. + public delegate uint ReadProc(IntPtr buffer, uint size, uint count, fi_handle handle); + + /// + /// Delegate to the C++ function fwrite. + /// + /// Pointer to data to be written. + /// Item size in bytes. + /// Maximum number of items to be written. + /// Handle/stream to write to. + /// Number of full items actually written, + /// which may be less than count if an error occurs. + /// Also, if an error occurs, the file-position indicator cannot be determined. + public delegate uint WriteProc(IntPtr buffer, uint size, uint count, fi_handle handle); + + /// + /// Delegate to the C++ function fseek. + /// + /// Handle/stream to seek in. + /// Number of bytes from origin. + /// Initial position. + /// If successful 0 is returned; otherwise a nonzero value. + public delegate int SeekProc(fi_handle handle, int offset, SeekOrigin origin); + + /// + /// Delegate to the C++ function ftell. + /// + /// Handle/stream to retrieve its currents position from. + /// The current position. + public delegate int TellProc(fi_handle handle); + + // Delegates used by 'Plugin' structure +} + +namespace FreeImageAPI.Plugins +{ + /// + /// Delegate to a function that returns a string which describes + /// the plugins format. + /// + public delegate string FormatProc(); + + /// + /// Delegate to a function that returns a string which contains + /// a more detailed description. + /// + public delegate string DescriptionProc(); + + /// + /// Delegate to a function that returns a comma seperated list + /// of file extensions the plugin can read or write. + /// + public delegate string ExtensionListProc(); + + /// + /// Delegate to a function that returns a regular expression that + /// can be used to idientify whether a file can be handled by the plugin. + /// + public delegate string RegExprProc(); + + /// + /// Delegate to a function that opens a file. + /// + public delegate IntPtr OpenProc(ref FreeImageIO io, fi_handle handle, bool read); + + /// + /// Delegate to a function that closes a previosly opened file. + /// + public delegate void CloseProc(ref FreeImageIO io, fi_handle handle, IntPtr data); + + /// + /// Delegate to a function that returns the number of pages of a multipage + /// bitmap if the plugin is capable of handling multipage bitmaps. + /// + public delegate int PageCountProc(ref FreeImageIO io, fi_handle handle, IntPtr data); + + /// + /// UNKNOWN + /// + public delegate int PageCapabilityProc(ref FreeImageIO io, fi_handle handle, IntPtr data); + + /// + /// Delegate to a function that loads and decodes a bitmap into memory. + /// + public delegate FIBITMAP LoadProc(ref FreeImageIO io, fi_handle handle, int page, int flags, IntPtr data); + + /// + /// Delegate to a function that saves a bitmap. + /// + public delegate bool SaveProc(ref FreeImageIO io, FIBITMAP dib, fi_handle handle, int page, int flags, IntPtr data); + + /// + /// Delegate to a function that determines whether the source defined + /// by and is a valid image. + /// + public delegate bool ValidateProc(ref FreeImageIO io, fi_handle handle); + + /// + /// Delegate to a function that returns a string which contains + /// the plugin's mime type. + /// + public delegate string MimeProc(); + + /// + /// Delegate to a function that returns whether the plugin can handle the + /// specified color depth. + /// + public delegate bool SupportsExportBPPProc(int bpp); + + /// + /// Delegate to a function that returns whether the plugin can handle the + /// specified image type. + /// + public delegate bool SupportsExportTypeProc(FREE_IMAGE_TYPE type); + + /// + /// Delegate to a function that returns whether the plugin can handle + /// ICC-Profiles. + /// + public delegate bool SupportsICCProfilesProc(); + + /// + /// Callback function used by FreeImage to register plugins. + /// + public delegate void InitProc(ref Plugin plugin, int format_id); +} + + #endregion + +namespace FreeImageAPI +{ + public static partial class FreeImage + { + #region Constants + + /// + /// Filename of the FreeImage library. + /// + private const string FreeImageLibrary = "FreeImage"; + + /// + /// Number of bytes to shift left within a 4 byte block. + /// + public const int FI_RGBA_RED = 2; + + /// + /// Number of bytes to shift left within a 4 byte block. + /// + public const int FI_RGBA_GREEN = 1; + + /// + /// Number of bytes to shift left within a 4 byte block. + /// + public const int FI_RGBA_BLUE = 0; + + /// + /// Number of bytes to shift left within a 4 byte block. + /// + public const int FI_RGBA_ALPHA = 3; + + /// + /// Mask indicating the position of the given color. + /// + public const uint FI_RGBA_RED_MASK = 0x00FF0000; + + /// + /// Mask indicating the position of the given color. + /// + public const uint FI_RGBA_GREEN_MASK = 0x0000FF00; + + /// + /// Mask indicating the position of the given color. + /// + public const uint FI_RGBA_BLUE_MASK = 0x000000FF; + + /// + /// Mask indicating the position of the given color. + /// + public const uint FI_RGBA_ALPHA_MASK = 0xFF000000; + + /// + /// Number of bits to shift left within a 32 bit block. + /// + public const int FI_RGBA_RED_SHIFT = 16; + + /// + /// Number of bits to shift left within a 32 bit block. + /// + public const int FI_RGBA_GREEN_SHIFT = 8; + + /// + /// Number of bits to shift left within a 32 bit block. + /// + public const int FI_RGBA_BLUE_SHIFT = 0; + + /// + /// Number of bits to shift left within a 32 bit block. + /// + public const int FI_RGBA_ALPHA_SHIFT = 24; + + /// + /// Mask indicating the position of color components of a 32 bit color. + /// + public const uint FI_RGBA_RGB_MASK = (FI_RGBA_RED_MASK | FI_RGBA_GREEN_MASK | FI_RGBA_BLUE_MASK); + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_555_RED_MASK = 0x7C00; + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_555_GREEN_MASK = 0x03E0; + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_555_BLUE_MASK = 0x001F; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_555_RED_SHIFT = 10; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_555_GREEN_SHIFT = 5; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_555_BLUE_SHIFT = 0; + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_565_RED_MASK = 0xF800; + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_565_GREEN_MASK = 0x07E0; + + /// + /// Mask indicating the position of the given color. + /// + public const int FI16_565_BLUE_MASK = 0x001F; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_565_RED_SHIFT = 11; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_565_GREEN_SHIFT = 5; + + /// + /// Number of bits to shift left within a 16 bit block. + /// + public const int FI16_565_BLUE_SHIFT = 0; + + #endregion + + #region General functions + + /// + /// Initialises the library. + /// + /// + /// When the is true, FreeImage won't make use of external plugins. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Initialise")] + private static extern void Initialise(bool load_local_plugins_only); + + /// + /// Deinitialises the library. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_DeInitialise")] + private static extern void DeInitialise(); + + /// + /// Returns a string containing the current version of the library. + /// + /// The current version of the library. + public static unsafe string GetVersion() { return PtrToStr(GetVersion_()); } + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetVersion")] + private static unsafe extern byte* GetVersion_(); + + /// + /// Returns a string containing a standard copyright message. + /// + /// A standard copyright message. + public static unsafe string GetCopyrightMessage() { return PtrToStr(GetCopyrightMessage_()); } + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetCopyrightMessage")] + private static unsafe extern byte* GetCopyrightMessage_(); + + /// + /// Calls the set error message function in FreeImage. + /// + /// Format of the bitmaps. + /// The error message. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_OutputMessageProc")] + public static extern void OutputMessageProc(FREE_IMAGE_FORMAT fif, string message); + + /// + /// You use the function FreeImage_SetOutputMessage to capture the log string + /// so that you can show it to the user of the program. + /// The callback is implemented in the event of this class. + /// + /// The function is private because FreeImage can only have a single + /// callback function. To use the callback use the + /// event of this class. + /// Handler to the callback function. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetOutputMessage")] + internal static extern void SetOutputMessage(OutputMessageFunction omf); + + #endregion + + #region Bitmap management functions + + /// + /// Creates a new bitmap in memory. + /// + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new Bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// Red part of the color layout. + /// eg: 0xFF0000 + /// Green part of the color layout. + /// eg: 0x00FF00 + /// Blue part of the color layout. + /// eg: 0x0000FF + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Allocate")] + public static extern FIBITMAP Allocate(int width, int height, int bpp, + uint red_mask, uint green_mask, uint blue_mask); + + /// + /// Creates a new bitmap in memory. + /// + /// Type of the image. + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new Bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// Red part of the color layout. + /// eg: 0xFF0000 + /// Green part of the color layout. + /// eg: 0x00FF00 + /// Blue part of the color layout. + /// eg: 0x0000FF + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AllocateT")] + public static extern FIBITMAP AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp, + uint red_mask, uint green_mask, uint blue_mask); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AllocateEx")] + internal static extern FIBITMAP AllocateEx(int width, int height, int bpp, + IntPtr color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette, + uint red_mask, uint green_mask, uint blue_mask); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AllocateExT")] + internal static extern FIBITMAP AllocateExT(FREE_IMAGE_TYPE type, int width, int height, int bpp, + IntPtr color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette, + uint red_mask, uint green_mask, uint blue_mask); + + /// + /// Makes an exact reproduction of an existing bitmap, including metadata and attached profile if any. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Clone")] + public static extern FIBITMAP Clone(FIBITMAP dib); + + /// + /// Deletes a previously loaded FIBITMAP from memory. + /// + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Unload")] + public static extern void Unload(FIBITMAP dib); + + /// + /// Decodes a bitmap, allocates memory for it and returns it as a FIBITMAP. + /// + /// Type of the bitmap. + /// Name of the file to decode. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_LoadU")] + public static extern FIBITMAP Load(FREE_IMAGE_FORMAT fif, string filename, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Decodes a bitmap, allocates memory for it and returns it as a FIBITMAP. + /// The filename supports UNICODE. + /// + /// Type of the bitmap. + /// Name of the file to decode. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_LoadU")] + private static extern FIBITMAP LoadU(FREE_IMAGE_FORMAT fif, string filename, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Loads a bitmap from an arbitrary source. + /// + /// Type of the bitmap. + /// A FreeImageIO structure with functionpointers to handle the source. + /// A handle to the source. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LoadFromHandle")] + public static extern FIBITMAP LoadFromHandle(FREE_IMAGE_FORMAT fif, ref FreeImageIO io, fi_handle handle, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Saves a previosly loaded FIBITMAP to a file. + /// + /// Type of the bitmap. + /// Handle to a FreeImage bitmap. + /// Name of the file to save to. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_SaveU")] + public static extern bool Save(FREE_IMAGE_FORMAT fif, FIBITMAP dib, string filename, FREE_IMAGE_SAVE_FLAGS flags); + + /// + /// Saves a previosly loaded FIBITMAP to a file. + /// The filename supports UNICODE. + /// + /// Type of the bitmap. + /// Handle to a FreeImage bitmap. + /// Name of the file to save to. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_SaveU")] + private static extern bool SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP dib, string filename, FREE_IMAGE_SAVE_FLAGS flags); + + /// + /// Saves a bitmap to an arbitrary source. + /// + /// Type of the bitmap. + /// Handle to a FreeImage bitmap. + /// A FreeImageIO structure with functionpointers to handle the source. + /// A handle to the source. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SaveToHandle")] + public static extern bool SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP dib, ref FreeImageIO io, fi_handle handle, + FREE_IMAGE_SAVE_FLAGS flags); + + #endregion + + #region Memory I/O streams + + /// + /// Open a memory stream. + /// + /// Pointer to the data in memory. + /// Length of the data in byte. + /// Handle to a memory stream. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_OpenMemory")] + public static extern FIMEMORY OpenMemory(IntPtr data, uint size_in_bytes); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_OpenMemory")] + internal static extern FIMEMORY OpenMemoryEx(byte[] data, uint size_in_bytes); + + /// + /// Close and free a memory stream. + /// + /// Handle to a memory stream. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CloseMemory")] + public static extern void CloseMemory(FIMEMORY stream); + + /// + /// Decodes a bitmap from a stream, allocates memory for it and returns it as a FIBITMAP. + /// + /// Type of the bitmap. + /// Handle to a memory stream. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LoadFromMemory")] + public static extern FIBITMAP LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY stream, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Saves a previosly loaded FIBITMAP to a stream. + /// + /// Type of the bitmap. + /// Handle to a FreeImage bitmap. + /// Handle to a memory stream. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SaveToMemory")] + public static extern bool SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP dib, FIMEMORY stream, FREE_IMAGE_SAVE_FLAGS flags); + + /// + /// Gets the current position of a memory handle. + /// + /// Handle to a memory stream. + /// The current file position if successful, -1 otherwise. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_TellMemory")] + public static extern int TellMemory(FIMEMORY stream); + + /// + /// Moves the memory handle to a specified location. + /// + /// Handle to a memory stream. + /// Number of bytes from origin. + /// Initial position. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SeekMemory")] + public static extern bool SeekMemory(FIMEMORY stream, int offset, System.IO.SeekOrigin origin); + + /// + /// Provides a direct buffer access to a memory stream. + /// + /// The target memory stream. + /// Pointer to the data in memory. + /// Size of the data in bytes. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AcquireMemory")] + public static extern bool AcquireMemory(FIMEMORY stream, ref IntPtr data, ref uint size_in_bytes); + + /// + /// Reads data from a memory stream. + /// + /// The buffer to store the data in. + /// Size in bytes of the items. + /// Number of items to read. + /// The stream to read from. + /// The memory pointer associated with stream is increased by the number of bytes actually read. + /// The number of full items actually read. + /// May be less than count on error or stream-end. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ReadMemory")] + public static extern uint ReadMemory(byte[] buffer, uint size, uint count, FIMEMORY stream); + + /// + /// Writes data to a memory stream. + /// + /// The buffer to read the data from. + /// Size in bytes of the items. + /// Number of items to write. + /// The stream to write to. + /// The memory pointer associated with stream is increased by the number of bytes actually written. + /// The number of full items actually written. + /// May be less than count on error or stream-end. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_WriteMemory")] + public static extern uint WriteMemory(byte[] buffer, uint size, uint count, FIMEMORY stream); + + /// + /// Open a multi-page bitmap from a memory stream. + /// + /// Type of the bitmap. + /// The stream to decode. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage multi-paged bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LoadMultiBitmapFromMemory")] + public static extern FIMULTIBITMAP LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY stream, FREE_IMAGE_LOAD_FLAGS flags); + + #endregion + + #region Plugin functions + + /// + /// Registers a new plugin to be used in FreeImage. + /// + /// Pointer to the function that initialises the plugin. + /// A string describing the format of the plugin. + /// A string describing the plugin. + /// A string witha comma sperated list of extensions. f.e: "pl,pl2,pl4" + /// A regular expression used to identify the bitmap. + /// The format idientifier assigned by FreeImage. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_RegisterLocalPlugin")] + public static extern FREE_IMAGE_FORMAT RegisterLocalPlugin(InitProc proc_address, + string format, string description, string extension, string regexpr); + + /// + /// Registers a new plugin to be used in FreeImage. The plugin is residing in a DLL. + /// The Init function must be called �Init� and must use the stdcall calling convention. + /// + /// Complete path to the dll file hosting the plugin. + /// A string describing the format of the plugin. + /// A string describing the plugin. + /// A string witha comma sperated list of extensions. f.e: "pl,pl2,pl4" + /// A regular expression used to identify the bitmap. + /// The format idientifier assigned by FreeImage. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_RegisterExternalPlugin")] + public static extern FREE_IMAGE_FORMAT RegisterExternalPlugin(string path, + string format, string description, string extension, string regexpr); + + /// + /// Retrieves the number of FREE_IMAGE_FORMAT identifiers being currently registered. + /// + /// The number of registered formats. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFIFCount")] + public static extern int GetFIFCount(); + + /// + /// Enables or disables a plugin. + /// + /// The plugin to enable or disable. + /// True: enable the plugin. false: disable the plugin. + /// The previous state of the plugin. + /// 1 - enabled. 0 - disables. -1 plugin does not exist. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetPluginEnabled")] + public static extern int SetPluginEnabled(FREE_IMAGE_FORMAT fif, bool enable); + + /// + /// Retrieves the state of a plugin. + /// + /// The plugin to check. + /// 1 - enabled. 0 - disables. -1 plugin does not exist. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_IsPluginEnabled")] + public static extern int IsPluginEnabled(FREE_IMAGE_FORMAT fif); + + /// + /// Returns a identifier from the format string that was used to register the FIF. + /// + /// The string that was used to register the plugin. + /// A identifier from the format. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetFIFFromFormat")] + public static extern FREE_IMAGE_FORMAT GetFIFFromFormat(string format); + + /// + /// Returns a identifier from a MIME content type string + /// (MIME stands for Multipurpose Internet Mail Extension). + /// + /// A MIME content type. + /// A identifier from the MIME. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetFIFFromMime")] + public static extern FREE_IMAGE_FORMAT GetFIFFromMime(string mime); + + /// + /// Returns the string that was used to register a plugin from the system assigned . + /// + /// The assigned . + /// The string that was used to register the plugin. + public static unsafe string GetFormatFromFIF(FREE_IMAGE_FORMAT fif) { return PtrToStr(GetFormatFromFIF_(fif)); } + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFormatFromFIF")] + private static unsafe extern byte* GetFormatFromFIF_(FREE_IMAGE_FORMAT fif); + + /// + /// Returns a comma-delimited file extension list describing the bitmap formats the given plugin can read and/or write. + /// + /// The desired . + /// A comma-delimited file extension list. + public static unsafe string GetFIFExtensionList(FREE_IMAGE_FORMAT fif) { return PtrToStr(GetFIFExtensionList_(fif)); } + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFIFExtensionList")] + private static unsafe extern byte* GetFIFExtensionList_(FREE_IMAGE_FORMAT fif); + + /// + /// Returns a descriptive string that describes the bitmap formats the given plugin can read and/or write. + /// + /// The desired . + /// A descriptive string that describes the bitmap formats. + public static unsafe string GetFIFDescription(FREE_IMAGE_FORMAT fif) { return PtrToStr(GetFIFDescription_(fif)); } + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFIFDescription")] + private static unsafe extern byte* GetFIFDescription_(FREE_IMAGE_FORMAT fif); + + /// + /// Returns a regular expression string that can be used by a regular expression engine to identify the bitmap. + /// FreeImageQt makes use of this function. + /// + /// The desired . + /// A regular expression string. + public static unsafe string GetFIFRegExpr(FREE_IMAGE_FORMAT fif) { return PtrToStr(GetFIFRegExpr_(fif)); } + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFIFRegExpr")] + private static unsafe extern byte* GetFIFRegExpr_(FREE_IMAGE_FORMAT fif); + + /// + /// Given a identifier, returns a MIME content type string (MIME stands for Multipurpose Internet Mail Extension). + /// + /// The desired . + /// A MIME content type string. + public static unsafe string GetFIFMimeType(FREE_IMAGE_FORMAT fif) { return PtrToStr(GetFIFMimeType_(fif)); } + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFIFMimeType")] + private static unsafe extern byte* GetFIFMimeType_(FREE_IMAGE_FORMAT fif); + + /// + /// This function takes a filename or a file-extension and returns the plugin that can + /// read/write files with that extension in the form of a identifier. + /// + /// The filename or -extension. + /// The of the plugin. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_GetFIFFromFilenameU")] + public static extern FREE_IMAGE_FORMAT GetFIFFromFilename(string filename); + + /// + /// This function takes a filename or a file-extension and returns the plugin that can + /// read/write files with that extension in the form of a identifier. + /// Supports UNICODE filenames. + /// + /// The filename or -extension. + /// The of the plugin. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_GetFIFFromFilenameU")] + private static extern FREE_IMAGE_FORMAT GetFIFFromFilenameU(string filename); + + /// + /// Checks if a plugin can load bitmaps. + /// + /// The of the plugin. + /// True if the plugin can load bitmaps, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FIFSupportsReading")] + public static extern bool FIFSupportsReading(FREE_IMAGE_FORMAT fif); + + /// + /// Checks if a plugin can save bitmaps. + /// + /// The of the plugin. + /// True if the plugin can save bitmaps, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FIFSupportsWriting")] + public static extern bool FIFSupportsWriting(FREE_IMAGE_FORMAT fif); + + /// + /// Checks if a plugin can save bitmaps in the desired bit depth. + /// + /// The of the plugin. + /// The desired bit depth. + /// True if the plugin can save bitmaps in the desired bit depth, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FIFSupportsExportBPP")] + public static extern bool FIFSupportsExportBPP(FREE_IMAGE_FORMAT fif, int bpp); + + /// + /// Checks if a plugin can save a bitmap in the desired data type. + /// + /// The of the plugin. + /// The desired image type. + /// True if the plugin can save bitmaps as the desired type, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FIFSupportsExportType")] + public static extern bool FIFSupportsExportType(FREE_IMAGE_FORMAT fif, FREE_IMAGE_TYPE type); + + /// + /// Checks if a plugin can load or save an ICC profile. + /// + /// The of the plugin. + /// True if the plugin can load or save an ICC profile, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FIFSupportsICCProfiles")] + public static extern bool FIFSupportsICCProfiles(FREE_IMAGE_FORMAT fif); + + #endregion + + #region Multipage functions + + /// + /// Loads a FreeImage multi-paged bitmap. + /// Load flags can be provided by the flags parameter. + /// + /// Format of the image. + /// The complete name of the file to load. + /// When true a new bitmap is created. + /// When true the bitmap will be loaded read only. + /// When true performance is increased at the cost of memory. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage multi-paged bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_OpenMultiBitmap")] + public static extern FIMULTIBITMAP OpenMultiBitmap(FREE_IMAGE_FORMAT fif, string filename, bool create_new, + bool read_only, bool keep_cache_in_memory, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Loads a FreeImage multi-pages bitmap from the specified handle + /// using the specified functions. + /// Load flags can be provided by the flags parameter. + /// + /// Format of the image. + /// IO functions used to read from the specified handle. + /// The handle to load the bitmap from. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage multi-paged bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_OpenMultiBitmapFromHandle")] + public static extern FIMULTIBITMAP OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, ref FreeImageIO io, + fi_handle handle, FREE_IMAGE_LOAD_FLAGS flags); + + /// + /// Closes a previously opened multi-page bitmap and, when the bitmap was not opened read-only, applies any changes made to it. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CloseMultiBitmap")] + private static extern bool CloseMultiBitmap_(FIMULTIBITMAP bitmap, FREE_IMAGE_SAVE_FLAGS flags); + + /// + /// Returns the number of pages currently available in the multi-paged bitmap. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Number of pages. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetPageCount")] + public static extern int GetPageCount(FIMULTIBITMAP bitmap); + + /// + /// Appends a new page to the end of the bitmap. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AppendPage")] + public static extern void AppendPage(FIMULTIBITMAP bitmap, FIBITMAP data); + + /// + /// Inserts a new page before the given position in the bitmap. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Page has to be a number smaller than the current number of pages available in the bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_InsertPage")] + public static extern void InsertPage(FIMULTIBITMAP bitmap, int page, FIBITMAP data); + + /// + /// Deletes the page on the given position. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Number of the page to delete. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_DeletePage")] + public static extern void DeletePage(FIMULTIBITMAP bitmap, int page); + + /// + /// Locks a page in memory for editing. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Number of the page to lock. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_LockPage")] + public static extern FIBITMAP LockPage(FIMULTIBITMAP bitmap, int page); + + /// + /// Unlocks a previously locked page and gives it back to the multi-page engine. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Handle to a FreeImage bitmap. + /// If true, the page is applied to the multi-page bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_UnlockPage")] + public static extern void UnlockPage(FIMULTIBITMAP bitmap, FIBITMAP data, bool changed); + + /// + /// Moves the source page to the position of the target page. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// New position of the page. + /// Old position of the page. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_MovePage")] + public static extern bool MovePage(FIMULTIBITMAP bitmap, int target, int source); + + /// + /// Returns an array of page-numbers that are currently locked in memory. + /// When the pages parameter is null, the size of the array is returned in the count variable. + /// + /// + /// + /// int[] lockedPages = null; + /// int count = 0; + /// GetLockedPageNumbers(dib, lockedPages, ref count); + /// lockedPages = new int[count]; + /// GetLockedPageNumbers(dib, lockedPages, ref count); + /// + /// + /// Handle to a FreeImage multi-paged bitmap. + /// The list of locked pages in the multi-pages bitmap. + /// If set to null, count will contain the number of pages. + /// If is set to null count will contain the number of locked pages. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetLockedPageNumbers")] + public static extern bool GetLockedPageNumbers(FIMULTIBITMAP bitmap, int[] pages, ref int count); + + #endregion + + #region Filetype functions + + /// + /// Orders FreeImage to analyze the bitmap signature. + /// + /// Name of the file to analyze. + /// Reserved parameter - use 0. + /// Type of the bitmap. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_GetFileTypeU")] + public static extern FREE_IMAGE_FORMAT GetFileType(string filename, int size); + + + /// + /// Orders FreeImage to analyze the bitmap signature. + /// Supports UNICODE filenames. + /// + /// Name of the file to analyze. + /// Reserved parameter - use 0. + /// Type of the bitmap. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_GetFileTypeU")] + private static extern FREE_IMAGE_FORMAT GetFileTypeU(string filename, int size); + + /// + /// Uses the structure as described in the topic bitmap management functions + /// to identify a bitmap type. + /// + /// A structure with functionpointers to handle the source. + /// A handle to the source. + /// Size in bytes of the source. + /// Type of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFileTypeFromHandle")] + public static extern FREE_IMAGE_FORMAT GetFileTypeFromHandle(ref FreeImageIO io, fi_handle handle, int size); + + /// + /// Uses a memory handle to identify a bitmap type. + /// + /// Pointer to the stream. + /// Size in bytes of the source. + /// Type of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFileTypeFromMemory")] + public static extern FREE_IMAGE_FORMAT GetFileTypeFromMemory(FIMEMORY stream, int size); + + #endregion + + #region Helper functions + + /// + /// Returns whether the platform is using Little Endian. + /// + /// Returns true if the platform is using Litte Endian, else false. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_IsLittleEndian")] + public static extern bool IsLittleEndian(); + + /// + /// Converts a X11 color name into a corresponding RGB value. + /// + /// Name of the color to convert. + /// Red component. + /// Green component. + /// Blue component. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_LookupX11Color")] + public static extern bool LookupX11Color(string szColor, out byte nRed, out byte nGreen, out byte nBlue); + + /// + /// Converts a SVG color name into a corresponding RGB value. + /// + /// Name of the color to convert. + /// Red component. + /// Green component. + /// Blue component. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_LookupSVGColor")] + public static extern bool LookupSVGColor(string szColor, out byte nRed, out byte nGreen, out byte nBlue); + + #endregion + + #region Pixel access functions + + /// + /// Returns a pointer to the data-bits of the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the data-bits. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetBits")] + public static extern IntPtr GetBits(FIBITMAP dib); + + /// + /// Returns a pointer to the start of the given scanline in the bitmap's data-bits. + /// + /// Handle to a FreeImage bitmap. + /// Number of the scanline. + /// Pointer to the scanline. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetScanLine")] + public static extern IntPtr GetScanLine(FIBITMAP dib, int scanline); + + /// + /// Get the pixel index of a palettized image at position (x, y), including range check (slow access). + /// + /// Handle to a FreeImage bitmap. + /// Pixel position in horizontal direction. + /// Pixel position in vertical direction. + /// The pixel index. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetPixelIndex")] + public static extern bool GetPixelIndex(FIBITMAP dib, uint x, uint y, out byte value); + + /// + /// Get the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access). + /// + /// Handle to a FreeImage bitmap. + /// Pixel position in horizontal direction. + /// Pixel position in vertical direction. + /// The pixel color. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetPixelColor")] + public static extern bool GetPixelColor(FIBITMAP dib, uint x, uint y, out RGBQUAD value); + + /// + /// Set the pixel index of a palettized image at position (x, y), including range check (slow access). + /// + /// Handle to a FreeImage bitmap. + /// Pixel position in horizontal direction. + /// Pixel position in vertical direction. + /// The new pixel index. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetPixelIndex")] + public static extern bool SetPixelIndex(FIBITMAP dib, uint x, uint y, ref byte value); + + /// + /// Set the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access). + /// + /// Handle to a FreeImage bitmap. + /// Pixel position in horizontal direction. + /// Pixel position in vertical direction. + /// The new pixel color. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetPixelColor")] + public static extern bool SetPixelColor(FIBITMAP dib, uint x, uint y, ref RGBQUAD value); + + #endregion + + #region Bitmap information functions + + /// + /// Retrieves the type of the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Type of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetImageType")] + public static extern FREE_IMAGE_TYPE GetImageType(FIBITMAP dib); + + /// + /// Returns the number of colors used in a bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Palette-size for palletised bitmaps, and 0 for high-colour bitmaps. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetColorsUsed")] + public static extern uint GetColorsUsed(FIBITMAP dib); + + /// + /// Returns the size of one pixel in the bitmap in bits. + /// + /// Handle to a FreeImage bitmap. + /// Size of one pixel in the bitmap in bits. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetBPP")] + public static extern uint GetBPP(FIBITMAP dib); + + /// + /// Returns the width of the bitmap in pixel units. + /// + /// Handle to a FreeImage bitmap. + /// With of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetWidth")] + public static extern uint GetWidth(FIBITMAP dib); + + /// + /// Returns the height of the bitmap in pixel units. + /// + /// Handle to a FreeImage bitmap. + /// Height of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetHeight")] + public static extern uint GetHeight(FIBITMAP dib); + + /// + /// Returns the width of the bitmap in bytes. + /// + /// Handle to a FreeImage bitmap. + /// With of the bitmap in bytes. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetLine")] + public static extern uint GetLine(FIBITMAP dib); + + /// + /// Returns the width of the bitmap in bytes, rounded to the next 32-bit boundary, + /// also known as pitch or stride or scan width. + /// + /// Handle to a FreeImage bitmap. + /// With of the bitmap in bytes. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetPitch")] + public static extern uint GetPitch(FIBITMAP dib); + + /// + /// Returns the size of the DIB-element of a FIBITMAP in memory. + /// + /// Handle to a FreeImage bitmap. + /// Size of the DIB-element + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetDIBSize")] + public static extern uint GetDIBSize(FIBITMAP dib); + + /// + /// Returns a pointer to the bitmap's palette. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the bitmap's palette. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetPalette")] + public static extern IntPtr GetPalette(FIBITMAP dib); + + /// + /// Returns the horizontal resolution, in pixels-per-meter, of the target device for the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The horizontal resolution, in pixels-per-meter. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetDotsPerMeterX")] + public static extern uint GetDotsPerMeterX(FIBITMAP dib); + + /// + /// Returns the vertical resolution, in pixels-per-meter, of the target device for the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The vertical resolution, in pixels-per-meter. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetDotsPerMeterY")] + public static extern uint GetDotsPerMeterY(FIBITMAP dib); + + /// + /// Set the horizontal resolution, in pixels-per-meter, of the target device for the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The new horizontal resolution. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetDotsPerMeterX")] + public static extern void SetDotsPerMeterX(FIBITMAP dib, uint res); + + /// + /// Set the vertical resolution, in pixels-per-meter, of the target device for the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The new vertical resolution. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetDotsPerMeterY")] + public static extern void SetDotsPerMeterY(FIBITMAP dib, uint res); + + /// + /// Returns a pointer to the of the DIB-element in a FIBITMAP. + /// + /// Handle to a FreeImage bitmap. + /// Poiter to the header of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetInfoHeader")] + public static extern IntPtr GetInfoHeader(FIBITMAP dib); + + /// + /// Alias for FreeImage_GetInfoHeader that returns a pointer to a + /// rather than to a . + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the structure for the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetInfo")] + public static extern IntPtr GetInfo(FIBITMAP dib); + + /// + /// Investigates the color type of the bitmap by reading the bitmap's pixel bits and analysing them. + /// + /// Handle to a FreeImage bitmap. + /// The color type of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetColorType")] + public static extern FREE_IMAGE_COLOR_TYPE GetColorType(FIBITMAP dib); + + /// + /// Returns a bit pattern describing the red color component of a pixel in a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The bit pattern for RED. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetRedMask")] + public static extern uint GetRedMask(FIBITMAP dib); + + /// + /// Returns a bit pattern describing the green color component of a pixel in a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The bit pattern for green. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetGreenMask")] + public static extern uint GetGreenMask(FIBITMAP dib); + + /// + /// Returns a bit pattern describing the blue color component of a pixel in a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The bit pattern for blue. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetBlueMask")] + public static extern uint GetBlueMask(FIBITMAP dib); + + /// + /// Returns the number of transparent colors in a palletised bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The number of transparent colors in a palletised bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTransparencyCount")] + public static extern uint GetTransparencyCount(FIBITMAP dib); + + /// + /// Returns a pointer to the bitmap's transparency table. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the bitmap's transparency table. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTransparencyTable")] + public static extern IntPtr GetTransparencyTable(FIBITMAP dib); + + /// + /// Tells FreeImage if it should make use of the transparency table + /// or the alpha channel that may accompany a bitmap. + /// + /// Handle to a FreeImage bitmap. + /// True to enable the transparency, false to disable. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTransparent")] + public static extern void SetTransparent(FIBITMAP dib, bool enabled); + + /// + /// Set the bitmap's transparency table. Only affects palletised bitmaps. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the bitmap's new transparency table. + /// The number of transparent colors in the new transparency table. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTransparencyTable")] + internal static extern void SetTransparencyTable(FIBITMAP dib, byte[] table, int count); + + /// + /// Returns whether the transparency table is enabled. + /// + /// Handle to a FreeImage bitmap. + /// Returns true when the transparency table is enabled (1-, 4- or 8-bit images) + /// or when the input dib contains alpha values (32-bit images). Returns false otherwise. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_IsTransparent")] + public static extern bool IsTransparent(FIBITMAP dib); + + /// + /// Returns whether the bitmap has a file background color. + /// + /// Handle to a FreeImage bitmap. + /// Returns true when the image has a file background color, false otherwise. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_HasBackgroundColor")] + public static extern bool HasBackgroundColor(FIBITMAP dib); + + /// + /// Returns the file background color of an image. + /// For 8-bit images, the color index in the palette is returned in the + /// rgbReserved member of the bkcolor parameter. + /// + /// Handle to a FreeImage bitmap. + /// The background color. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetBackgroundColor")] + public static extern bool GetBackgroundColor(FIBITMAP dib, out RGBQUAD bkcolor); + + /// + /// Set the file background color of an image. + /// When saving an image to PNG, this background color is transparently saved to the PNG file. + /// + /// Handle to a FreeImage bitmap. + /// The new background color. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetBackgroundColor")] + public static unsafe extern bool SetBackgroundColor(FIBITMAP dib, ref RGBQUAD bkcolor); + + /// + /// Set the file background color of an image. + /// When saving an image to PNG, this background color is transparently saved to the PNG file. + /// When the bkcolor parameter is null, the background color is removed from the image. + /// + /// This overloaded version of the function with an array parameter is provided to allow + /// passing null in the parameter. This is similar to the + /// original C/C++ function. Passing null as parameter will + /// unset the dib's previously set background color. + /// + /// + /// Handle to a FreeImage bitmap. + /// The new background color. + /// The first entry in the array is used. + /// Returns true on success, false on failure. + /// + /// + /// // create a RGBQUAD color + /// RGBQUAD color = new RGBQUAD(Color.Green); + /// + /// // set the dib's background color (using the other version of the function) + /// FreeImage.SetBackgroundColor(dib, ref color); + /// + /// // remove it again (this only works due to the array parameter RGBQUAD[]) + /// FreeImage.SetBackgroundColor(dib, null); + /// + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetBackgroundColor")] + public static unsafe extern bool SetBackgroundColor(FIBITMAP dib, RGBQUAD[] bkcolor); + + /// + /// Sets the index of the palette entry to be used as transparent color + /// for the image specified. Does nothing on high color images. + /// + /// Handle to a FreeImage bitmap. + /// The index of the palette entry to be set as transparent color. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTransparentIndex")] + public static extern void SetTransparentIndex(FIBITMAP dib, int index); + + /// + /// Returns the palette entry used as transparent color for the image specified. + /// Works for palletised images only and returns -1 for high color + /// images or if the image has no color set to be transparent. + /// + /// Handle to a FreeImage bitmap. + /// the index of the palette entry used as transparent color for + /// the image specified or -1 if there is no transparent color found + /// (e.g. the image is a high color image). + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTransparentIndex")] + public static extern int GetTransparentIndex(FIBITMAP dib); + + #endregion + + #region ICC profile functions + + /// + /// Retrieves the data of the bitmap. + /// This function can also be called safely, when the original format does not support profiles. + /// + /// Handle to a FreeImage bitmap. + /// The data of the bitmap. + public static FIICCPROFILE GetICCProfileEx(FIBITMAP dib) { unsafe { return *(FIICCPROFILE*)FreeImage.GetICCProfile(dib); } } + + /// + /// Retrieves a pointer to the data of the bitmap. + /// This function can also be called safely, when the original format does not support profiles. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the data of the bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetICCProfile")] + public static extern IntPtr GetICCProfile(FIBITMAP dib); + + /// + /// Creates a new block from ICC profile data previously read from a file + /// or built by a color management system. The profile data is attached to the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Pointer to the new data. + /// Size of the data. + /// Pointer to the created structure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CreateICCProfile")] + public static extern IntPtr CreateICCProfile(FIBITMAP dib, byte[] data, int size); + + /// + /// This function destroys an previously created by . + /// After this call the bitmap will contain no profile information. + /// This function should be called to ensure that a stored bitmap will not contain any profile information. + /// + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_DestroyICCProfile")] + public static extern void DestroyICCProfile(FIBITMAP dib); + + #endregion + + #region Conversion functions + + /// + /// Converts a bitmap to 4 bits. + /// If the bitmap was a high-color bitmap (16, 24 or 32-bit) or if it was a + /// monochrome or greyscale bitmap (1 or 8-bit), the end result will be a + /// greyscale bitmap, otherwise (1-bit palletised bitmaps) it will be a palletised bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo4Bits")] + public static extern FIBITMAP ConvertTo4Bits(FIBITMAP dib); + + /// + /// Converts a bitmap to 8 bits. If the bitmap was a high-color bitmap (16, 24 or 32-bit) + /// or if it was a monochrome or greyscale bitmap (1 or 4-bit), the end result will be a + /// greyscale bitmap, otherwise (1 or 4-bit palletised bitmaps) it will be a palletised bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo8Bits")] + public static extern FIBITMAP ConvertTo8Bits(FIBITMAP dib); + + /// + /// Converts a bitmap to a 8-bit greyscale image with a linear ramp. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToGreyscale")] + public static extern FIBITMAP ConvertToGreyscale(FIBITMAP dib); + + /// + /// Converts a bitmap to 16 bits, where each pixel has a color pattern of + /// 5 bits red, 5 bits green and 5 bits blue. One bit in each pixel is unused. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo16Bits555")] + public static extern FIBITMAP ConvertTo16Bits555(FIBITMAP dib); + + /// + /// Converts a bitmap to 16 bits, where each pixel has a color pattern of + /// 5 bits red, 6 bits green and 5 bits blue. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo16Bits565")] + public static extern FIBITMAP ConvertTo16Bits565(FIBITMAP dib); + + /// + /// Converts a bitmap to 24 bits. A clone of the input bitmap is returned for 24-bit bitmaps. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo24Bits")] + public static extern FIBITMAP ConvertTo24Bits(FIBITMAP dib); + + /// + /// Converts a bitmap to 32 bits. A clone of the input bitmap is returned for 32-bit bitmaps. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertTo32Bits")] + public static extern FIBITMAP ConvertTo32Bits(FIBITMAP dib); + + /// + /// Quantizes a high-color 24-bit bitmap to an 8-bit palette color bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Specifies the color reduction algorithm to be used. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ColorQuantize")] + public static extern FIBITMAP ColorQuantize(FIBITMAP dib, FREE_IMAGE_QUANTIZE quantize); + + /// + /// ColorQuantizeEx is an extension to the method that + /// provides additional options used to quantize a 24-bit image to any + /// number of colors (up to 256), as well as quantize a 24-bit image using a + /// partial or full provided palette. + /// + /// Handle to a FreeImage bitmap. + /// Specifies the color reduction algorithm to be used. + /// Size of the desired output palette. + /// Size of the provided palette of ReservePalette. + /// The provided palette. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ColorQuantizeEx")] + public static extern FIBITMAP ColorQuantizeEx(FIBITMAP dib, FREE_IMAGE_QUANTIZE quantize, int PaletteSize, int ReserveSize, RGBQUAD[] ReservePalette); + + /// + /// Converts a bitmap to 1-bit monochrome bitmap using a threshold T between [0..255]. + /// The function first converts the bitmap to a 8-bit greyscale bitmap. + /// Then, any brightness level that is less than T is set to zero, otherwise to 1. + /// For 1-bit input bitmaps, the function clones the input bitmap and builds a monochrome palette. + /// + /// Handle to a FreeImage bitmap. + /// The threshold. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Threshold")] + public static extern FIBITMAP Threshold(FIBITMAP dib, byte t); + + /// + /// Converts a bitmap to 1-bit monochrome bitmap using a dithering algorithm. + /// For 1-bit input bitmaps, the function clones the input bitmap and builds a monochrome palette. + /// + /// Handle to a FreeImage bitmap. + /// The dithering algorithm to use. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Dither")] + public static extern FIBITMAP Dither(FIBITMAP dib, FREE_IMAGE_DITHER algorithm); + + /// + /// Converts a raw bitmap to a FreeImage bitmap. + /// + /// Pointer to the memory block containing the raw bitmap. + /// The width in pixels of the raw bitmap. + /// The height in pixels of the raw bitmap. + /// Defines the total width of a scanline in the raw bitmap, + /// including padding bytes. + /// The bit depth (bits per pixel) of the raw bitmap. + /// The bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap is stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertFromRawBits")] + public static extern FIBITMAP ConvertFromRawBits(IntPtr bits, int width, int height, int pitch, + uint bpp, uint red_mask, uint green_mask, uint blue_mask, bool topdown); + + /// + /// Converts a raw bitmap to a FreeImage bitmap. + /// + /// Array of bytes containing the raw bitmap. + /// The width in pixels of the raw bitmap. + /// The height in pixels of the raw bitmap. + /// Defines the total width of a scanline in the raw bitmap, + /// including padding bytes. + /// The bit depth (bits per pixel) of the raw bitmap. + /// The bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap is stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertFromRawBits")] + public static extern FIBITMAP ConvertFromRawBits(byte[] bits, int width, int height, int pitch, + uint bpp, uint red_mask, uint green_mask, uint blue_mask, bool topdown); + + /// + /// Converts a FreeImage bitmap to a raw bitmap, that is a raw piece of memory. + /// + /// Pointer to the memory block receiving the raw bitmap. + /// Handle to a FreeImage bitmap. + /// The desired total width in bytes of a scanline in the raw bitmap, + /// including any padding bytes. + /// The desired bit depth (bits per pixel) of the raw bitmap. + /// The desired bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The desired bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The desired bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap will be stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToRawBits")] + public static extern void ConvertToRawBits(IntPtr bits, FIBITMAP dib, int pitch, uint bpp, + uint red_mask, uint green_mask, uint blue_mask, bool topdown); + + /// + /// Converts a FreeImage bitmap to a raw bitmap, that is a raw piece of memory. + /// + /// Array of bytes receiving the raw bitmap. + /// Handle to a FreeImage bitmap. + /// The desired total width in bytes of a scanline in the raw bitmap, + /// including any padding bytes. + /// The desired bit depth (bits per pixel) of the raw bitmap. + /// The desired bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The desired bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The desired bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap will be stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToRawBits")] + public static extern void ConvertToRawBits(byte[] bits, FIBITMAP dib, int pitch, uint bpp, + uint red_mask, uint green_mask, uint blue_mask, bool topdown); + + /// + /// Converts a 24- or 32-bit RGB(A) standard image or a 48-bit RGB image to a FIT_RGBF type image. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToRGBF")] + public static extern FIBITMAP ConvertToRGBF(FIBITMAP dib); + + /// + /// Converts a non standard image whose color type is FIC_MINISBLACK + /// to a standard 8-bit greyscale image. + /// + /// Handle to a FreeImage bitmap. + /// When true the conversion is done by scaling linearly + /// each pixel value from [min, max] to an integer value between [0..255], + /// where min and max are the minimum and maximum pixel values in the image. + /// When false the conversion is done by rounding each pixel value to an integer between [0..255]. + /// + /// Rounding is done using the following formula: + /// + /// dst_pixel = (BYTE) MIN(255, MAX(0, q)) where int q = int(src_pixel + 0.5); + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToStandardType")] + public static extern FIBITMAP ConvertToStandardType(FIBITMAP src, bool scale_linear); + + /// + /// Converts an image of any type to type dst_type. + /// + /// Handle to a FreeImage bitmap. + /// Destination type. + /// True to scale linear, else false. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ConvertToType")] + public static extern FIBITMAP ConvertToType(FIBITMAP src, FREE_IMAGE_TYPE dst_type, bool scale_linear); + + #endregion + + #region Tone mapping operators + + /// + /// Converts a High Dynamic Range image (48-bit RGB or 96-bit RGBF) to a 24-bit RGB image, suitable for display. + /// + /// Handle to a FreeImage bitmap. + /// The tone mapping operator to be used. + /// Parmeter depending on the used algorithm + /// Parmeter depending on the used algorithm + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ToneMapping")] + public static extern FIBITMAP ToneMapping(FIBITMAP dib, FREE_IMAGE_TMO tmo, double first_param, double second_param); + + /// + /// Converts a High Dynamic Range image to a 24-bit RGB image using a global + /// operator based on logarithmic compression of luminance values, imitating the human response to light. + /// + /// Handle to a FreeImage bitmap. + /// A gamma correction that is applied after the tone mapping. + /// A value of 1 means no correction. + /// Scale factor allowing to adjust the brightness of the output image. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_TmoDrago03")] + public static extern FIBITMAP TmoDrago03(FIBITMAP src, double gamma, double exposure); + + /// + /// Converts a High Dynamic Range image to a 24-bit RGB image using a global operator inspired + /// by photoreceptor physiology of the human visual system. + /// + /// Handle to a FreeImage bitmap. + /// Controls the overall image intensity in the range [-8, 8]. + /// Controls the overall image contrast in the range [0.3, 1.0[. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_TmoReinhard05")] + public static extern FIBITMAP TmoReinhard05(FIBITMAP src, double intensity, double contrast); + + /// + /// Apply the Gradient Domain High Dynamic Range Compression to a RGBF image and convert to 24-bit RGB. + /// + /// Handle to a FreeImage bitmap. + /// Color saturation (s parameter in the paper) in [0.4..0.6] + /// Atenuation factor (beta parameter in the paper) in [0.8..0.9] + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_TmoFattal02")] + public static extern FIBITMAP TmoFattal02(FIBITMAP src, double color_saturation, double attenuation); + + #endregion + + #region Compression functions + + /// + /// Compresses a source buffer into a target buffer, using the ZLib library. + /// + /// Pointer to the target buffer. + /// Size of the target buffer. + /// Must be at least 0.1% larger than source_size plus 12 bytes. + /// Pointer to the source buffer. + /// Size of the source buffer. + /// The actual size of the compressed buffer, or 0 if an error occurred. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ZLibCompress")] + public static extern uint ZLibCompress(byte[] target, uint target_size, byte[] source, uint source_size); + + /// + /// Decompresses a source buffer into a target buffer, using the ZLib library. + /// + /// Pointer to the target buffer. + /// Size of the target buffer. + /// Must have been saved outlide of zlib. + /// Pointer to the source buffer. + /// Size of the source buffer. + /// The actual size of the uncompressed buffer, or 0 if an error occurred. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ZLibUncompress")] + public static extern uint ZLibUncompress(byte[] target, uint target_size, byte[] source, uint source_size); + + /// + /// Compresses a source buffer into a target buffer, using the ZLib library. + /// + /// Pointer to the target buffer. + /// Size of the target buffer. + /// Must be at least 0.1% larger than source_size plus 24 bytes. + /// Pointer to the source buffer. + /// Size of the source buffer. + /// The actual size of the compressed buffer, or 0 if an error occurred. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ZLibGZip")] + public static extern uint ZLibGZip(byte[] target, uint target_size, byte[] source, uint source_size); + + /// + /// Decompresses a source buffer into a target buffer, using the ZLib library. + /// + /// Pointer to the target buffer. + /// Size of the target buffer. + /// Must have been saved outlide of zlib. + /// Pointer to the source buffer. + /// Size of the source buffer. + /// The actual size of the uncompressed buffer, or 0 if an error occurred. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ZLibGUnzip")] + public static extern uint ZLibGUnzip(byte[] target, uint target_size, byte[] source, uint source_size); + + /// + /// Generates a CRC32 checksum. + /// + /// The CRC32 checksum to begin with. + /// Pointer to the source buffer. + /// If the value is 0, the function returns the required initial value for the crc. + /// Size of the source buffer. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ZLibCRC32")] + public static extern uint ZLibCRC32(uint crc, byte[] source, uint source_size); + + #endregion + + #region Tag creation and destruction + + /// + /// Allocates a new object. + /// This object must be destroyed with a call to + /// when no longer in use. + /// + /// The new . + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CreateTag")] + public static extern FITAG CreateTag(); + + /// + /// Delete a previously allocated object. + /// + /// The to destroy. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_DeleteTag")] + public static extern void DeleteTag(FITAG tag); + + /// + /// Creates and returns a copy of a object. + /// + /// The to clone. + /// The new . + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CloneTag")] + public static extern FITAG CloneTag(FITAG tag); + + #endregion + + #region Tag accessors + + /// + /// Returns the tag field name (unique inside a metadata model). + /// + /// The tag field. + /// The field name. + public static unsafe string GetTagKey(FITAG tag) { return PtrToStr(GetTagKey_(tag)); } + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetTagKey")] + private static unsafe extern byte* GetTagKey_(FITAG tag); + + /// + /// Returns the tag description. + /// + /// The tag field. + /// The description or NULL if unavailable. + public static unsafe string GetTagDescription(FITAG tag) { return PtrToStr(GetTagDescription_(tag)); } + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetTagDescription")] + private static unsafe extern byte* GetTagDescription_(FITAG tag); + + /// + /// Returns the tag ID. + /// + /// The tag field. + /// The ID or 0 if unavailable. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTagID")] + public static extern ushort GetTagID(FITAG tag); + + /// + /// Returns the tag data type. + /// + /// The tag field. + /// The tag type. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTagType")] + public static extern FREE_IMAGE_MDTYPE GetTagType(FITAG tag); + + /// + /// Returns the number of components in the tag (in tag type units). + /// + /// The tag field. + /// The number of components. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTagCount")] + public static extern uint GetTagCount(FITAG tag); + + /// + /// Returns the length of the tag value in bytes. + /// + /// The tag field. + /// The length of the tag value. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTagLength")] + public static extern uint GetTagLength(FITAG tag); + + /// + /// Returns the tag value. + /// It is up to the programmer to interpret the returned pointer correctly, + /// according to the results of GetTagType and GetTagCount. + /// + /// The tag field. + /// Pointer to the value. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetTagValue")] + public static extern IntPtr GetTagValue(FITAG tag); + + /// + /// Sets the tag field name. + /// + /// The tag field. + /// The new name. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_SetTagKey")] + public static extern bool SetTagKey(FITAG tag, string key); + + /// + /// Sets the tag description. + /// + /// The tag field. + /// The new description. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_SetTagDescription")] + public static extern bool SetTagDescription(FITAG tag, string description); + + /// + /// Sets the tag ID. + /// + /// The tag field. + /// The new ID. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTagID")] + public static extern bool SetTagID(FITAG tag, ushort id); + + /// + /// Sets the tag data type. + /// + /// The tag field. + /// The new type. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTagType")] + public static extern bool SetTagType(FITAG tag, FREE_IMAGE_MDTYPE type); + + /// + /// Sets the number of data in the tag. + /// + /// The tag field. + /// New number of data. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTagCount")] + public static extern bool SetTagCount(FITAG tag, uint count); + + /// + /// Sets the length of the tag value in bytes. + /// + /// The tag field. + /// The new length. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTagLength")] + public static extern bool SetTagLength(FITAG tag, uint length); + + /// + /// Sets the tag value. + /// + /// The tag field. + /// Pointer to the new value. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetTagValue")] + public static extern bool SetTagValue(FITAG tag, byte[] value); + + #endregion + + #region Metadata iterator + + /// + /// Provides information about the first instance of a tag that matches the metadata model. + /// + /// The model to match. + /// Handle to a FreeImage bitmap. + /// Tag that matches the metadata model. + /// Unique search handle that can be used to call FindNextMetadata or FindCloseMetadata. + /// Null if the metadata model does not exist. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FindFirstMetadata")] + public static extern FIMETADATA FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP dib, out FITAG tag); + + /// + /// Find the next tag, if any, that matches the metadata model argument in a previous call + /// to FindFirstMetadata, and then alters the tag object contents accordingly. + /// + /// Unique search handle provided by FindFirstMetadata. + /// Tag that matches the metadata model. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FindNextMetadata")] + public static extern bool FindNextMetadata(FIMETADATA mdhandle, out FITAG tag); + + /// + /// Closes the specified metadata search handle and releases associated resources. + /// + /// The handle to close. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FindCloseMetadata")] + private static extern void FindCloseMetadata_(FIMETADATA mdhandle); + + #endregion + + #region Metadata setter and getter + + /// + /// Retrieve a metadata attached to a dib. + /// + /// The metadata model to look for. + /// Handle to a FreeImage bitmap. + /// The metadata field name. + /// A FITAG structure returned by the function. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_GetMetadata")] + public static extern bool GetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, out FITAG tag); + + /// + /// Attach a new FreeImage tag to a dib. + /// + /// The metadata model used to store the tag. + /// Handle to a FreeImage bitmap. + /// The tag field name. + /// The FreeImage tag to be attached. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_SetMetadata")] + public static extern bool SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, FITAG tag); + + #endregion + + #region Metadata helper functions + + /// + /// Returns the number of tags contained in the model metadata model attached to the input dib. + /// + /// The metadata model. + /// Handle to a FreeImage bitmap. + /// Number of tags contained in the metadata model. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetMetadataCount")] + public static extern uint GetMetadataCount(FREE_IMAGE_MDMODEL model, FIBITMAP dib); + + /// + /// Copies the metadata of FreeImage bitmap to another. + /// + /// The FreeImage bitmap to copy the metadata to. + /// The FreeImage bitmap to copy the metadata from. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_CloneMetadata")] + public static extern bool CloneMetadata(FIBITMAP dst, FIBITMAP src); + + /// + /// Converts a FreeImage tag structure to a string that represents the interpreted tag value. + /// The function is not thread safe. + /// + /// The metadata model. + /// The interpreted tag value. + /// Reserved. + /// The representing string. + public static unsafe string TagToString(FREE_IMAGE_MDMODEL model, FITAG tag, uint Make) { return PtrToStr(TagToString_(model, tag, Make)); } + [DllImport(FreeImageLibrary, CharSet = CharSet.Ansi, EntryPoint = "FreeImage_TagToString")] + private static unsafe extern byte* TagToString_(FREE_IMAGE_MDMODEL model, FITAG tag, uint Make); + + #endregion + + #region Rotation and flipping + + /// + /// This function rotates a 1-, 8-bit greyscale or a 24-, 32-bit color image by means of 3 shears. + /// 1-bit images rotation is limited to integer multiple of 90�. + /// null is returned for other values. + /// + /// Handle to a FreeImage bitmap. + /// The angle of rotation. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_RotateClassic")] + [Obsolete("RotateClassic is deprecated (use Rotate instead).")] + public static extern FIBITMAP RotateClassic(FIBITMAP dib, double angle); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Rotate")] + internal static extern FIBITMAP Rotate(FIBITMAP dib, double angle, IntPtr backgroundColor); + + /// + /// This function performs a rotation and / or translation of an 8-bit greyscale, + /// 24- or 32-bit image, using a 3rd order (cubic) B-Spline. + /// + /// Handle to a FreeImage bitmap. + /// The angle of rotation. + /// Horizontal image translation. + /// Vertical image translation. + /// Rotation center x-coordinate. + /// Rotation center y-coordinate. + /// When true the irrelevant part of the image is set to a black color, + /// otherwise, a mirroring technique is used to fill irrelevant pixels. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_RotateEx")] + public static extern FIBITMAP RotateEx(FIBITMAP dib, double angle, + double x_shift, double y_shift, double x_origin, double y_origin, bool use_mask); + + /// + /// Flip the input dib horizontally along the vertical axis. + /// + /// Handle to a FreeImage bitmap. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FlipHorizontal")] + public static extern bool FlipHorizontal(FIBITMAP dib); + + /// + /// Flip the input dib vertically along the horizontal axis. + /// + /// Handle to a FreeImage bitmap. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FlipVertical")] + public static extern bool FlipVertical(FIBITMAP dib); + + /// + /// Performs a lossless rotation or flipping on a JPEG file. + /// + /// Source file. + /// Destination file; can be the source file; will be overwritten. + /// The operation to apply. + /// To avoid lossy transformation, you can set the perfect parameter to true. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_JPEGTransformU")] + public static extern bool JPEGTransform(string src_file, string dst_file, + FREE_IMAGE_JPEG_OPERATION operation, bool perfect); + + #endregion + + #region Upsampling / downsampling + + /// + /// Performs resampling (or scaling, zooming) of a greyscale or RGB(A) image + /// to the desired destination width and height. + /// + /// Handle to a FreeImage bitmap. + /// Destination width. + /// Destination height. + /// The filter to apply. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Rescale")] + public static extern FIBITMAP Rescale(FIBITMAP dib, int dst_width, int dst_height, FREE_IMAGE_FILTER filter); + + /// + /// Creates a thumbnail from a greyscale or RGB(A) image, keeping aspect ratio. + /// + /// Handle to a FreeImage bitmap. + /// Thumbnail square size. + /// When true HDR images are transperantly converted to standard images. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_MakeThumbnail")] + public static extern FIBITMAP MakeThumbnail(FIBITMAP dib, int max_pixel_size, bool convert); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_EnlargeCanvas")] + internal static extern FIBITMAP EnlargeCanvas(FIBITMAP dib, + int left, int top, int right, int bottom, IntPtr color, FREE_IMAGE_COLOR_OPTIONS options); + + #endregion + + #region Color manipulation + + /// + /// Perfoms an histogram transformation on a 8-, 24- or 32-bit image. + /// + /// Handle to a FreeImage bitmap. + /// The lookup table. + /// It's size is assumed to be 256 in length. + /// The color channel to be transformed. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AdjustCurve")] + public static extern bool AdjustCurve(FIBITMAP dib, byte[] lookUpTable, FREE_IMAGE_COLOR_CHANNEL channel); + + /// + /// Performs gamma correction on a 8-, 24- or 32-bit image. + /// + /// Handle to a FreeImage bitmap. + /// The parameter represents the gamma value to use (gamma > 0). + /// A value of 1.0 leaves the image alone, less than one darkens it, and greater than one lightens it. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AdjustGamma")] + public static extern bool AdjustGamma(FIBITMAP dib, double gamma); + + /// + /// Adjusts the brightness of a 8-, 24- or 32-bit image by a certain amount. + /// + /// Handle to a FreeImage bitmap. + /// A value 0 means no change, + /// less than 0 will make the image darker and greater than 0 will make the image brighter. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AdjustBrightness")] + public static extern bool AdjustBrightness(FIBITMAP dib, double percentage); + + /// + /// Adjusts the contrast of a 8-, 24- or 32-bit image by a certain amount. + /// + /// Handle to a FreeImage bitmap. + /// A value 0 means no change, + /// less than 0 will decrease the contrast and greater than 0 will increase the contrast of the image. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AdjustContrast")] + public static extern bool AdjustContrast(FIBITMAP dib, double percentage); + + /// + /// Inverts each pixel data. + /// + /// Handle to a FreeImage bitmap. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Invert")] + public static extern bool Invert(FIBITMAP dib); + + /// + /// Computes the image histogram. + /// + /// Handle to a FreeImage bitmap. + /// Array of integers with a size of 256. + /// Channel to compute from. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetHistogram")] + public static extern bool GetHistogram(FIBITMAP dib, int[] histo, FREE_IMAGE_COLOR_CHANNEL channel); + + #endregion + + #region Channel processing + + /// + /// Retrieves the red, green, blue or alpha channel of a 24- or 32-bit image. + /// + /// Handle to a FreeImage bitmap. + /// The color channel to extract. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetChannel")] + public static extern FIBITMAP GetChannel(FIBITMAP dib, FREE_IMAGE_COLOR_CHANNEL channel); + + /// + /// Insert a 8-bit dib into a 24- or 32-bit image. + /// Both images must have to same width and height. + /// + /// Handle to a FreeImage bitmap. + /// Handle to the bitmap to insert. + /// The color channel to replace. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetChannel")] + public static extern bool SetChannel(FIBITMAP dib, FIBITMAP dib8, FREE_IMAGE_COLOR_CHANNEL channel); + + /// + /// Retrieves the real part, imaginary part, magnitude or phase of a complex image. + /// + /// Handle to a FreeImage bitmap. + /// The color channel to extract. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetComplexChannel")] + public static extern FIBITMAP GetComplexChannel(FIBITMAP src, FREE_IMAGE_COLOR_CHANNEL channel); + + /// + /// Set the real or imaginary part of a complex image. + /// Both images must have to same width and height. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + /// The color channel to replace. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SetComplexChannel")] + public static extern bool SetComplexChannel(FIBITMAP dst, FIBITMAP src, FREE_IMAGE_COLOR_CHANNEL channel); + + #endregion + + #region Copy / Paste / Composite routines + + /// + /// Copy a sub part of the current dib image. + /// + /// Handle to a FreeImage bitmap. + /// Specifies the left position of the cropped rectangle. + /// Specifies the top position of the cropped rectangle. + /// Specifies the right position of the cropped rectangle. + /// Specifies the bottom position of the cropped rectangle. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Copy")] + public static extern FIBITMAP Copy(FIBITMAP dib, int left, int top, int right, int bottom); + + /// + /// Alpha blend or combine a sub part image with the current dib image. + /// The bit depth of the dst bitmap must be greater than or equal to the bit depth of the src. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a FreeImage bitmap. + /// Specifies the left position of the sub image. + /// Specifies the top position of the sub image. + /// alpha blend factor. + /// The source and destination images are alpha blended if alpha=0..255. + /// If alpha > 255, then the source image is combined to the destination image. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Paste")] + public static extern bool Paste(FIBITMAP dst, FIBITMAP src, int left, int top, int alpha); + + /// + /// This function composite a transparent foreground image against a single background color or + /// against a background image. + /// + /// Handle to a FreeImage bitmap. + /// When true the background of fg is used if it contains one. + /// The application background is used if useFileBkg is false. + /// Image used as background when useFileBkg is false or fg has no background + /// and appBkColor is null. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Composite")] + public static extern FIBITMAP Composite(FIBITMAP fg, bool useFileBkg, ref RGBQUAD appBkColor, FIBITMAP bg); + + /// + /// This function composite a transparent foreground image against a single background color or + /// against a background image. + /// + /// Handle to a FreeImage bitmap. + /// When true the background of fg is used if it contains one. + /// The application background is used if useFileBkg is false + /// and 'appBkColor' is not null. + /// Image used as background when useFileBkg is false or fg has no background + /// and appBkColor is null. + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_Composite")] + public static extern FIBITMAP Composite(FIBITMAP fg, bool useFileBkg, RGBQUAD[] appBkColor, FIBITMAP bg); + + /// + /// Performs a lossless crop on a JPEG file. + /// + /// Source filename. + /// Destination filename. + /// Specifies the left position of the cropped rectangle. + /// Specifies the top position of the cropped rectangle. + /// Specifies the right position of the cropped rectangle. + /// Specifies the bottom position of the cropped rectangle. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_JPEGCropU")] + public static extern bool JPEGCrop(string src_file, string dst_file, int left, int top, int right, int bottom); + + /// + /// Applies the alpha value of each pixel to its color components. + /// The aplha value stays unchanged. + /// Only works with 32-bits color depth. + /// + /// Handle to a FreeImage bitmap. + /// Returns true on success, false on failure. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_PreMultiplyWithAlpha")] + public static extern bool PreMultiplyWithAlpha(FIBITMAP dib); + + #endregion + + #region Miscellaneous algorithms + + /// + /// Solves a Poisson equation, remap result pixels to [0..1] and returns the solution. + /// + /// Handle to a FreeImage bitmap. + /// Number of cycles in the multigrid algorithm (usually 2 or 3) + /// Handle to a FreeImage bitmap. + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_MultigridPoissonSolver")] + public static extern FIBITMAP MultigridPoissonSolver(FIBITMAP Laplacian, int ncycle); + + #endregion + + #region Colors + + /// + /// Creates a lookup table to be used with which may adjusts brightness and + /// contrast, correct gamma and invert the image with a single call to . + /// + /// Output lookup table to be used with . + /// The size of 'lookUpTable' is assumed to be 256. + /// Percentage brightness value where -100 <= brightness <= 100. + /// A value of 0 means no change, less than 0 will make the image darker and greater + /// than 0 will make the image brighter. + /// Percentage contrast value where -100 <= contrast <= 100. + /// A value of 0 means no change, less than 0 will decrease the contrast + /// and greater than 0 will increase the contrast of the image. + /// Gamma value to be used for gamma correction. + /// A value of 1.0 leaves the image alone, less than one darkens it, + /// and greater than one lightens it. + /// If set to true, the image will be inverted. + /// The number of adjustments applied to the resulting lookup table + /// compared to a blind lookup table. + /// + /// This function creates a lookup table to be used with which may adjust + /// brightness and contrast, correct gamma and invert the image with a single call to + /// . If more than one of these image display properties need to be adjusted, + /// using a combined lookup table should be preferred over calling each adjustment function + /// separately. That's particularly true for huge images or if performance is an issue. Then, + /// the expensive process of iterating over all pixels of an image is performed only once and + /// not up to four times. + /// + /// Furthermore, the lookup table created does not depend on the order, in which each single + /// adjustment operation is performed. Due to rounding and byte casting issues, it actually + /// matters in which order individual adjustment operations are performed. Both of the following + /// snippets most likely produce different results: + /// + /// + /// // snippet 1: contrast, brightness + /// AdjustContrast(dib, 15.0); + /// AdjustBrightness(dib, 50.0); + /// + /// + /// + /// // snippet 2: brightness, contrast + /// AdjustBrightness(dib, 50.0); + /// AdjustContrast(dib, 15.0); + /// + /// + /// Better and even faster would be snippet 3: + /// + /// + /// // snippet 3: + /// byte[] lut = new byte[256]; + /// GetAdjustColorsLookupTable(lut, 50.0, 15.0, 1.0, false); + /// AdjustCurve(dib, lut, FREE_IMAGE_COLOR_CHANNEL.FICC_RGB); + /// + /// + /// This function is also used internally by , which does not return the + /// lookup table, but uses it to call on the passed image. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetAdjustColorsLookupTable")] + public static extern int GetAdjustColorsLookupTable(byte[] lookUpTable, double brightness, double contrast, double gamma, bool invert); + + /// + /// Adjusts an image's brightness, contrast and gamma as well as it may + /// optionally invert the image within a single operation. + /// + /// Handle to a FreeImage bitmap. + /// Percentage brightness value where -100 <= brightness <= 100. + /// A value of 0 means no change, less than 0 will make the image darker and greater + /// than 0 will make the image brighter. + /// Percentage contrast value where -100 <= contrast <= 100. + /// A value of 0 means no change, less than 0 will decrease the contrast + /// and greater than 0 will increase the contrast of the image. + /// Gamma value to be used for gamma correction. + /// A value of 1.0 leaves the image alone, less than one darkens it, + /// and greater than one lightens it. + /// This parameter must not be zero or smaller than zero. + /// If so, it will be ignored and no gamma correction will be performed on the image. + /// If set to true, the image will be inverted. + /// Returns true on success, false on failure. + /// + /// This function adjusts an image's brightness, contrast and gamma as well as it + /// may optionally invert the image within a single operation. If more than one of + /// these image display properties need to be adjusted, using this function should + /// be preferred over calling each adjustment function separately. That's particularly + /// true for huge images or if performance is an issue. + /// + /// This function relies on , + /// which creates a single lookup table, that combines all adjustment operations requested. + /// + /// Furthermore, the lookup table created by does + /// not depend on the order, in which each single adjustment operation is performed. + /// Due to rounding and byte casting issues, it actually matters in which order individual + /// adjustment operations are performed. Both of the following snippets most likely produce + /// different results: + /// + /// + /// // snippet 1: contrast, brightness + /// AdjustContrast(dib, 15.0); + /// AdjustBrightness(dib, 50.0); + /// + /// + /// + /// // snippet 2: brightness, contrast + /// AdjustBrightness(dib, 50.0); + /// AdjustContrast(dib, 15.0); + /// + /// + /// Better and even faster would be snippet 3: + /// + /// + /// // snippet 3: + /// AdjustColors(dib, 50.0, 15.0, 1.0, false); + /// + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_AdjustColors")] + public static extern bool AdjustColors(FIBITMAP dib, double brightness, double contrast, double gamma, bool invert); + + /// + /// Applies color mapping for one or several colors on a 1-, 4- or 8-bit + /// palletized or a 16-, 24- or 32-bit high color image. + /// + /// Handle to a FreeImage bitmap. + /// Array of colors to be used as the mapping source. + /// Array of colors to be used as the mapping destination. + /// The number of colors to be mapped. This is the size of both + /// srccolors and dstcolors. + /// If true, 32-bit images and colors are treated as 24-bit. + /// If true, source and destination colors are swapped, that is, + /// each destination color is also mapped to the corresponding source color. + /// The total number of pixels changed. + /// + /// This function maps up to colors specified in + /// to these specified in . + /// Thereby, color srccolors[N], if found in the image, will be replaced by color + /// dstcolors[N]. If is true, additionally all colors + /// specified in are also mapped to these specified + /// in . For high color images, the actual image data will be + /// modified whereas, for palletized images only the palette will be changed. + /// + /// The function returns the number of pixels changed or zero, if no pixels were changed. + /// + /// Both arrays and are assumed + /// not to hold less than colors. + /// + /// For 16-bit images, all colors specified are transparently converted to their + /// proper 16-bit representation (either in RGB555 or RGB565 format, which is determined + /// by the image's red- green- and blue-mask). + /// + /// Note, that this behaviour is different from what does, + /// which modifies the actual image data on palletized images. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ApplyColorMapping")] + public static extern uint ApplyColorMapping(FIBITMAP dib, RGBQUAD[] srccolors, RGBQUAD[] dstcolors, uint count, bool ignore_alpha, bool swap); + + /// + /// Swaps two specified colors on a 1-, 4- or 8-bit palletized + /// or a 16-, 24- or 32-bit high color image. + /// + /// Handle to a FreeImage bitmap. + /// One of the two colors to be swapped. + /// The other of the two colors to be swapped. + /// If true, 32-bit images and colors are treated as 24-bit. + /// The total number of pixels changed. + /// + /// This function swaps the two specified colors and + /// on a palletized or high color image. + /// For high color images, the actual image data will be modified whereas, for palletized + /// images only the palette will be changed. + /// + /// Note, that this behaviour is different from what does, + /// which modifies the actual image data on palletized images. + /// + /// This is just a thin wrapper for and resolves to: + /// + /// + /// return ApplyColorMapping(dib, color_a, color_b, 1, ignore_alpha, true); + /// + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SwapColors")] + public static extern uint SwapColors(FIBITMAP dib, ref RGBQUAD color_a, ref RGBQUAD color_b, bool ignore_alpha); + + /// + /// Applies palette index mapping for one or several indices + /// on a 1-, 4- or 8-bit palletized image. + /// + /// Handle to a FreeImage bitmap. + /// Array of palette indices to be used as the mapping source. + /// Array of palette indices to be used as the mapping destination. + /// The number of palette indices to be mapped. This is the size of both + /// srcindices and dstindices + /// If true, source and destination palette indices are swapped, that is, + /// each destination index is also mapped to the corresponding source index. + /// The total number of pixels changed. + /// + /// This function maps up to palette indices specified in + /// to these specified in . + /// Thereby, index srcindices[N], if present in the image, will be replaced by index + /// dstindices[N]. If is true, additionally all indices + /// specified in are also mapped to these specified in + /// . + /// + /// The function returns the number of pixels changed or zero, if no pixels were changed. + /// Both arrays and are assumed not to + /// hold less than indices. + /// + /// Note, that this behaviour is different from what does, which + /// modifies the actual image data on palletized images. + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_ApplyPaletteIndexMapping")] + public static extern uint ApplyPaletteIndexMapping(FIBITMAP dib, byte[] srcindices, byte[] dstindices, uint count, bool swap); + + /// + /// Swaps two specified palette indices on a 1-, 4- or 8-bit palletized image. + /// + /// Handle to a FreeImage bitmap. + /// One of the two palette indices to be swapped. + /// The other of the two palette indices to be swapped. + /// The total number of pixels changed. + /// + /// This function swaps the two specified palette indices index_a and + /// index_b on a palletized image. Therefore, not the palette, but the + /// actual image data will be modified. + /// + /// Note, that this behaviour is different from what does on palletized images, + /// which only swaps the colors in the palette. + /// + /// This is just a thin wrapper for and resolves to: + /// + /// + /// return ApplyPaletteIndexMapping(dib, index_a, index_b, 1, true); + /// + /// + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_SwapPaletteIndices")] + public static extern uint SwapPaletteIndices(FIBITMAP dib, ref byte index_a, ref byte index_b); + + [DllImport(FreeImageLibrary, EntryPoint = "FreeImage_FillBackground")] + internal static extern bool FillBackground(FIBITMAP dib, IntPtr color, FREE_IMAGE_COLOR_OPTIONS options); + + #endregion + } +} + +///////////////////////////////////////////////////// +// // +// Wrapper functions // +// // +///////////////////////////////////////////////////// + + #region Structs + +namespace FreeImageAPI.IO +{ + /// + /// Wrapper for a custom handle. + /// + /// + /// The fi_handle of FreeImage in C++ is a simple pointer, but in .NET + /// it's not that simple. This wrapper uses fi_handle in two different ways. + /// + /// We implement a new plugin and FreeImage gives us a handle (pointer) that + /// we can simply pass through to the given functions in a 'FreeImageIO' + /// structure. + /// But when we want to use LoadFromhandle or SaveToHandle we need + /// a fi_handle (that we receive again in our own functions). + /// This handle is for example a stream (see LoadFromStream / SaveToStream) + /// that we want to work with. To know which stream a read/write is meant for + /// we could use a hash value that the wrapper itself handles or we can + /// go the unmanaged way of using a handle. + /// Therefor we use a to receive a unique pointer that we can + /// convert back into a .NET object. + /// When the fi_handle instance is no longer needed the instance must be disposed + /// by the creater manually! It is recommended to use the using statement to + /// be sure the instance is always disposed: + /// + /// + /// using (fi_handle handle = new fi_handle(object)) + /// { + /// callSomeFunctions(handle); + /// } + /// + /// + /// What does that mean? + /// If we get a fi_handle from unmanaged code we get a pointer to unmanaged + /// memory that we do not have to care about, and just pass ist back to FreeImage. + /// If we have to create a handle our own we use the standard constructur + /// that fills the with an pointer that represents the given object. + /// With calling the is used to retrieve the original + /// object we passed through the constructor. + /// + /// This way we can implement a fi_handle that works with managed an unmanaged + /// code. + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct fi_handle : IComparable, IComparable, IEquatable, IDisposable + { + /// + /// The handle to wrap. + /// + public IntPtr handle; + + /// + /// Initializes a new instance wrapping a managed object. + /// + /// The object to wrap. + /// + /// is null. + public fi_handle(object obj) + { + if (obj == null) + { + throw new ArgumentNullException("obj"); + } + GCHandle gch = GCHandle.Alloc(obj, GCHandleType.Normal); + handle = GCHandle.ToIntPtr(gch); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(fi_handle left, fi_handle right) + { + return (left.handle == right.handle); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(fi_handle left, fi_handle right) + { + return (left.handle != right.handle); + } + + /// + /// Gets whether the pointer is a null pointer. + /// + public bool IsNull + { + get + { + return (handle == IntPtr.Zero); + } + } + + /// + /// Returns the object assigned to the handle in case this instance + /// was created by managed code. + /// + /// assigned to this handle or null on failure. + internal object GetObject() + { + object result = null; + if (handle != IntPtr.Zero) + { + try + { + result = GCHandle.FromIntPtr(handle).Target; + } + catch + { + } + } + return result; + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return handle.ToString(); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return handle.GetHashCode(); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is fi_handle) && (this == ((fi_handle)obj))); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// An object to compare with this object. + /// True if the current object is equal to the other parameter; otherwise, false. + public bool Equals(fi_handle other) + { + return (this == other); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is fi_handle)) + { + throw new ArgumentException("obj"); + } + return CompareTo((fi_handle)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(fi_handle other) + { + return handle.ToInt64().CompareTo(other.handle.ToInt64()); + } + + /// + /// Releases all resources used by the instance. + /// + public void Dispose() + { + if (this.handle != IntPtr.Zero) + { + try + { + GCHandle.FromIntPtr(handle).Free(); + } + catch + { + } + finally + { + this.handle = IntPtr.Zero; + } + } + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FI1BIT structure represents a single bit. + /// It's value can be 0 or 1. + /// + [DebuggerDisplay("{value}"), + Serializable] + public struct FI1BIT + { + /// + /// Represents the largest possible value of . This field is constant. + /// + public const byte MaxValue = 0x01; + + /// + /// Represents the smallest possible value of . This field is constant. + /// + public const byte MinValue = 0x00; + + /// + /// The value of the structure. + /// + private byte value; + + /// + /// Initializes a new instance based on the specified value. + /// + /// The value to initialize with. + private FI1BIT(byte value) + { + this.value = (byte)(value & MaxValue); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator byte(FI1BIT value) + { + return value.value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FI1BIT(byte value) + { + return new FI1BIT(value); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return value.ToString(); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FI4BIT structure represents the half of a . + /// It's valuerange is between 0 and 15. + /// + [DebuggerDisplay("{value}"), + Serializable] + public struct FI4BIT + { + /// + /// Represents the largest possible value of . This field is constant. + /// + public const byte MaxValue = 0x0F; + + /// + /// Represents the smallest possible value of . This field is constant. + /// + public const byte MinValue = 0x00; + + /// + /// The value of the structure. + /// + private byte value; + + /// + /// Initializes a new instance based on the specified value. + /// + /// The value to initialize with. + private FI4BIT(byte value) + { + this.value = (byte)(value & MaxValue); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator byte(FI4BIT value) + { + return value.value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FI4BIT(byte value) + { + return new FI4BIT(value); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return value.ToString(); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FI16RGB555 structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 5 bits and so, takes values in the range from 0 to 31. + /// + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FI16RGB555 structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FI16RGB555 structure and my be used in all situations which require + /// an FI16RGB555 type. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FI16RGB555 structure and the structure. + /// + /// FI16RGB555 fi16rgb; + /// // Initialize the structure using a native .NET Color structure. + /// fi16rgb = new FI16RGB555(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// fi16rgb = Color.DarkSeaGreen; + /// // Convert the FI16RGB555 instance into a native .NET Color + /// // using its implicit operator. + /// Color color = fi16rgb; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = fi16rgb.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FI16RGB555 : IComparable, IComparable, IEquatable + { + /// + /// The value of the color. + /// + private ushort value; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FI16RGB555(Color color) + { + value = (ushort)( + (((color.R * 31) / 255) << FreeImage.FI16_555_RED_SHIFT) + + (((color.G * 31) / 255) << FreeImage.FI16_555_GREEN_SHIFT) + + (((color.B * 31) / 255) << FreeImage.FI16_555_BLUE_SHIFT)); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FI16RGB555 left, FI16RGB555 right) + { + return (left.value == right.value); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FI16RGB555 left, FI16RGB555 right) + { + return (!(left == right)); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FI16RGB555(Color value) + { + return new FI16RGB555(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FI16RGB555 value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + ((value & FreeImage.FI16_555_RED_MASK) >> FreeImage.FI16_555_RED_SHIFT) * 255 / 31, + ((value & FreeImage.FI16_555_GREEN_MASK) >> FreeImage.FI16_555_GREEN_SHIFT) * 255 / 31, + ((value & FreeImage.FI16_555_BLUE_MASK) >> FreeImage.FI16_555_BLUE_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)( + (((value.R * 31) / 255) << FreeImage.FI16_555_RED_SHIFT) + + (((value.G * 31) / 255) << FreeImage.FI16_555_GREEN_SHIFT) + + (((value.B * 31) / 255) << FreeImage.FI16_555_BLUE_SHIFT)); + } + } + + /// + /// Gets or sets the red color component. + /// + public byte Red + { + get + { + return (byte)(((value & FreeImage.FI16_555_RED_MASK) >> FreeImage.FI16_555_RED_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_555_RED_MASK)) | (((value * 31) / 255) << FreeImage.FI16_555_RED_SHIFT)); + } + } + + /// + /// Gets or sets the green color component. + /// + public byte Green + { + get + { + return (byte)(((value & FreeImage.FI16_555_GREEN_MASK) >> FreeImage.FI16_555_GREEN_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_555_GREEN_MASK)) | (((value * 31) / 255) << FreeImage.FI16_555_GREEN_SHIFT)); + } + } + + /// + /// Gets or sets the blue color component. + /// + public byte Blue + { + get + { + return (byte)(((value & FreeImage.FI16_555_BLUE_MASK) >> FreeImage.FI16_555_BLUE_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_555_BLUE_MASK)) | (((value * 31) / 255) << FreeImage.FI16_555_BLUE_SHIFT)); + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FI16RGB555)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FI16RGB555)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FI16RGB555 other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return base.Equals(obj); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FI16RGB555 other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FI16RGB565 structure describes a color consisting of relative + /// intensities of red, green, blue and alpha value. Each single color + /// component consumes 5 bits and so, takes values in the range from 0 to 31. + /// + /// + /// For easy integration of the underlying structure into the .NET framework, + /// the FI16RGB565 structure implements implicit conversion operators to + /// convert the represented color to and from the + /// type. This makes the type a real replacement + /// for the FI16RGB565 structure and my be used in all situations which require + /// an FI16RGB565 type. + /// + /// + /// + /// The following code example demonstrates the various conversions between the + /// FI16RGB565 structure and the structure. + /// + /// FI16RGB565 fi16rgb; + /// // Initialize the structure using a native .NET Color structure. + /// fi16rgb = new FI16RGB565(Color.Indigo); + /// // Initialize the structure using the implicit operator. + /// fi16rgb = Color.DarkSeaGreen; + /// // Convert the FI16RGB565 instance into a native .NET Color + /// // using its implicit operator. + /// Color color = fi16rgb; + /// // Using the structure's Color property for converting it + /// // into a native .NET Color. + /// Color another = fi16rgb.Color; + /// + /// + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct FI16RGB565 : IComparable, IComparable, IEquatable + { + /// + /// The value of the color. + /// + private ushort value; + + /// + /// Initializes a new instance based on the specified . + /// + /// to initialize with. + public FI16RGB565(Color color) + { + value = (ushort)( + (((color.R * 31) / 255) << FreeImage.FI16_565_RED_SHIFT) + + (((color.G * 63) / 255) << FreeImage.FI16_565_GREEN_SHIFT) + + (((color.B * 31) / 255) << FreeImage.FI16_565_BLUE_SHIFT)); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(FI16RGB565 left, FI16RGB565 right) + { + return (left.value == right.value); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(FI16RGB565 left, FI16RGB565 right) + { + return (!(left == right)); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FI16RGB565(Color value) + { + return new FI16RGB565(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator Color(FI16RGB565 value) + { + return value.Color; + } + + /// + /// Gets or sets the of the structure. + /// + public Color Color + { + get + { + return Color.FromArgb( + ((value & FreeImage.FI16_565_RED_MASK) >> FreeImage.FI16_565_RED_SHIFT) * 255 / 31, + ((value & FreeImage.FI16_565_GREEN_MASK) >> FreeImage.FI16_565_GREEN_SHIFT) * 255 / 63, + ((value & FreeImage.FI16_565_BLUE_MASK) >> FreeImage.FI16_565_BLUE_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)( + (((value.R * 31) / 255) << FreeImage.FI16_565_RED_SHIFT) + + (((value.G * 63) / 255) << FreeImage.FI16_565_GREEN_SHIFT) + + (((value.B * 31) / 255) << FreeImage.FI16_565_BLUE_SHIFT)); + } + } + + /// + /// Gets or sets the red color component. + /// + public byte Red + { + get + { + return (byte)(((value & FreeImage.FI16_565_RED_MASK) >> FreeImage.FI16_565_RED_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_565_RED_MASK)) | (((value * 31) / 255) << FreeImage.FI16_565_RED_SHIFT)); + } + } + + /// + /// Gets or sets the green color component. + /// + public byte Green + { + get + { + return (byte)(((value & FreeImage.FI16_565_GREEN_MASK) >> FreeImage.FI16_565_GREEN_SHIFT) * 255 / 63); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_565_GREEN_MASK)) | (((value * 63) / 255) << FreeImage.FI16_565_GREEN_SHIFT)); + } + } + + /// + /// Gets or sets the blue color component. + /// + public byte Blue + { + get + { + return (byte)(((value & FreeImage.FI16_565_BLUE_MASK) >> FreeImage.FI16_565_BLUE_SHIFT) * 255 / 31); + } + set + { + this.value = (ushort)((this.value & (~FreeImage.FI16_565_BLUE_MASK)) | (((value * 31) / 255) << FreeImage.FI16_565_BLUE_SHIFT)); + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FI16RGB565)) + { + throw new ArgumentException("obj"); + } + return CompareTo((FI16RGB565)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FI16RGB565 other) + { + return this.Color.ToArgb().CompareTo(other.Color.ToArgb()); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return base.Equals(obj); + } + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FI16RGB565 other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return FreeImage.ColorToString(Color); + } + } +} + +namespace FreeImageAPI +{ + /// + /// The FIRational structure represents a fraction via two + /// instances which are interpreted as numerator and denominator. + /// + /// + /// The structure tries to approximate the value of + /// when creating a new instance by using a better algorithm than FreeImage does. + /// + /// The structure implements the following operators: + /// +, -, ++, --, ==, != , >, >==, <, <== and ~ (which switches nominator and denomiator). + /// + /// The structure can be converted into all .NET standard types either implicit or + /// explicit. + /// + [Serializable, StructLayout(LayoutKind.Sequential), ComVisible(true)] + public struct FIRational : IConvertible, IComparable, IFormattable, IComparable, IEquatable + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private int numerator; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private int denominator; + + /// + /// Represents the largest possible value of . This field is constant. + /// + public static readonly FIRational MaxValue = new FIRational(Int32.MaxValue, 1); + + /// + /// Represents the smallest possible value of . This field is constant. + /// + public static readonly FIRational MinValue = new FIRational(Int32.MinValue, 1); + + /// + /// Represents the smallest positive value greater than zero. This field is constant. + /// + public static readonly FIRational Epsilon = new FIRational(1, Int32.MaxValue); + + /// + /// Initializes a new instance based on the specified parameters. + /// + /// The numerator. + /// The denominator. + public FIRational(int n, int d) + { + numerator = n; + denominator = d; + Normalize(); + } + + /// + /// Initializes a new instance based on the specified parameters. + /// + /// The tag to read the data from. + public unsafe FIRational(FITAG tag) + { + switch (FreeImage.GetTagType(tag)) + { + case FREE_IMAGE_MDTYPE.FIDT_SRATIONAL: + int* value = (int*)FreeImage.GetTagValue(tag); + numerator = (int)value[0]; + denominator = (int)value[1]; + Normalize(); + return; + default: + throw new ArgumentException("tag"); + } + } + + /// + /// Initializes a new instance based on the specified parameters. + /// + /// The value to convert into a fraction. + /// + /// cannot be converted into a fraction + /// represented by two integer values. + public FIRational(decimal value) + { + try + { + int sign = value < 0 ? -1 : 1; + value = Math.Abs(value); + try + { + int[] contFract = CreateContinuedFraction(value); + CreateFraction(contFract, out numerator, out denominator); + Normalize(); + } + catch + { + numerator = 0; + denominator = 1; + } + if (Math.Abs(((decimal)numerator / (decimal)denominator) - value) > 0.0001m) + { + int maxDen = (Int32.MaxValue / (int)value) - 2; + maxDen = maxDen < 10000 ? maxDen : 10000; + ApproximateFraction(value, maxDen, out numerator, out denominator); + Normalize(); + if (Math.Abs(((decimal)numerator / (decimal)denominator) - value) > 0.0001m) + { + throw new OverflowException("Unable to convert value into a fraction"); + } + } + numerator *= sign; + Normalize(); + } + catch (Exception ex) + { + throw new OverflowException("Unable to calculate fraction.", ex); + } + } + + /// + /// The numerator of the fraction. + /// + public int Numerator + { + get { return numerator; } + } + + /// + /// The denominator of the fraction. + /// + public int Denominator + { + get { return denominator; } + } + + /// + /// Returns the truncated value of the fraction. + /// + /// + public int Truncate() + { + return denominator > 0 ? (int)(numerator / denominator) : 0; + } + + /// + /// Returns whether the fraction is representing an integer value. + /// + public bool IsInteger + { + get + { + return (denominator == 1 || + (denominator != 0 && (numerator % denominator == 0)) || + (denominator == 0 && numerator == 0)); + } + } + + /// + /// Calculated the greatest common divisor of 'a' and 'b'. + /// + private static long Gcd(long a, long b) + { + a = Math.Abs(a); + b = Math.Abs(b); + long r; + while (b > 0) + { + r = a % b; + a = b; + b = r; + } + return a; + } + + /// + /// Calculated the smallest common multiple of 'a' and 'b'. + /// + private static long Scm(int n, int m) + { + return Math.Abs((long)n * (long)m) / Gcd(n, m); + } + + /// + /// Normalizes the fraction. + /// + private void Normalize() + { + if (denominator == 0) + { + numerator = 0; + denominator = 1; + return; + } + + if (numerator != 1 && denominator != 1) + { + int common = (int)Gcd(numerator, denominator); + if (common != 1 && common != 0) + { + numerator /= common; + denominator /= common; + } + } + + if (denominator < 0) + { + numerator *= -1; + denominator *= -1; + } + } + + /// + /// Normalizes a fraction. + /// + private static void Normalize(ref long numerator, ref long denominator) + { + if (denominator == 0) + { + numerator = 0; + denominator = 1; + } + else if (numerator != 1 && denominator != 1) + { + long common = Gcd(numerator, denominator); + if (common != 1) + { + numerator /= common; + denominator /= common; + } + } + if (denominator < 0) + { + numerator *= -1; + denominator *= -1; + } + } + + /// + /// Returns the digits after the point. + /// + private static int GetDigits(decimal value) + { + int result = 0; + value -= decimal.Truncate(value); + while (value != 0) + { + value *= 10; + value -= decimal.Truncate(value); + result++; + } + return result; + } + + /// + /// Creates a continued fraction of a decimal value. + /// + private static int[] CreateContinuedFraction(decimal value) + { + int precision = GetDigits(value); + decimal epsilon = 0.0000001m; + List list = new List(); + value = Math.Abs(value); + + byte b = 0; + + list.Add((int)value); + value -= ((int)value); + + while (value != 0m) + { + if (++b == byte.MaxValue || value < epsilon) + { + break; + } + value = 1m / value; + if (Math.Abs((Math.Round(value, precision - 1) - value)) < epsilon) + { + value = Math.Round(value, precision - 1); + } + list.Add((int)value); + value -= ((int)value); + } + return list.ToArray(); + } + + /// + /// Creates a fraction from a continued fraction. + /// + private static void CreateFraction(int[] continuedFraction, out int numerator, out int denominator) + { + numerator = 1; + denominator = 0; + int temp; + + for (int i = continuedFraction.Length - 1; i > -1; i--) + { + temp = numerator; + numerator = continuedFraction[i] * numerator + denominator; + denominator = temp; + } + } + + /// + /// Tries 'brute force' to approximate with a fraction. + /// + private static void ApproximateFraction(decimal value, int maxDen, out int num, out int den) + { + num = 0; + den = 0; + decimal bestDifference = 1m; + decimal currentDifference = -1m; + int digits = GetDigits(value); + + if (digits <= 9) + { + int mul = 1; + for (int i = 1; i <= digits; i++) + { + mul *= 10; + } + if (mul <= maxDen) + { + num = (int)(value * mul); + den = mul; + return; + } + } + + for (int i = 1; i <= maxDen; i++) + { + int numerator = (int)Math.Floor(value * (decimal)i + 0.5m); + currentDifference = Math.Abs(value - (decimal)numerator / (decimal)i); + if (currentDifference < bestDifference) + { + num = numerator; + den = i; + bestDifference = currentDifference; + } + } + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return ((IConvertible)this).ToDouble(null).ToString(); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIRational) && (this == ((FIRational)obj))); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + #region Operators + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator +(FIRational r1) + { + return r1; + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator -(FIRational r1) + { + r1.numerator *= -1; + return r1; + } + + /// + /// Returns the reciprocal value of this instance. + /// + public static FIRational operator ~(FIRational r1) + { + int temp = r1.denominator; + r1.denominator = r1.numerator; + r1.numerator = temp; + r1.Normalize(); + return r1; + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator ++(FIRational r1) + { + checked + { + r1.numerator += r1.denominator; + } + return r1; + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator --(FIRational r1) + { + checked + { + r1.numerator -= r1.denominator; + } + return r1; + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator +(FIRational r1, FIRational r2) + { + long numerator = 0; + long denominator = Scm(r1.denominator, r2.denominator); + numerator = (r1.numerator * (denominator / r1.denominator)) + (r2.numerator * (denominator / r2.denominator)); + Normalize(ref numerator, ref denominator); + checked + { + return new FIRational((int)numerator, (int)denominator); + } + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator -(FIRational r1, FIRational r2) + { + return r1 + (-r2); + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator *(FIRational r1, FIRational r2) + { + long numerator = r1.numerator * r2.numerator; + long denominator = r1.denominator * r2.denominator; + Normalize(ref numerator, ref denominator); + checked + { + return new FIRational((int)numerator, (int)denominator); + } + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator /(FIRational r1, FIRational r2) + { + int temp = r2.denominator; + r2.denominator = r2.numerator; + r2.numerator = temp; + return r1 * r2; + } + + /// + /// Standard implementation of the operator. + /// + public static FIRational operator %(FIRational r1, FIRational r2) + { + r2.Normalize(); + if (Math.Abs(r2.numerator) < r2.denominator) + return new FIRational(0, 0); + int div = (int)(r1 / r2); + return r1 - (r2 * div); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator ==(FIRational r1, FIRational r2) + { + r1.Normalize(); + r2.Normalize(); + return (r1.numerator == r2.numerator) && (r1.denominator == r2.denominator); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator !=(FIRational r1, FIRational r2) + { + return !(r1 == r2); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator >(FIRational r1, FIRational r2) + { + long denominator = Scm(r1.denominator, r2.denominator); + return (r1.numerator * (denominator / r1.denominator)) > (r2.numerator * (denominator / r2.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator <(FIRational r1, FIRational r2) + { + long denominator = Scm(r1.denominator, r2.denominator); + return (r1.numerator * (denominator / r1.denominator)) < (r2.numerator * (denominator / r2.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator >=(FIRational r1, FIRational r2) + { + long denominator = Scm(r1.denominator, r2.denominator); + return (r1.numerator * (denominator / r1.denominator)) >= (r2.numerator * (denominator / r2.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator <=(FIRational r1, FIRational r2) + { + long denominator = Scm(r1.denominator, r2.denominator); + return (r1.numerator * (denominator / r1.denominator)) <= (r2.numerator * (denominator / r2.denominator)); + } + + #endregion + + #region Conversions + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator bool(FIRational value) + { + return (value.numerator != 0); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator byte(FIRational value) + { + return (byte)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator char(FIRational value) + { + return (char)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator decimal(FIRational value) + { + return value.denominator == 0 ? 0m : (decimal)value.numerator / (decimal)value.denominator; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator double(FIRational value) + { + return value.denominator == 0 ? 0d : (double)value.numerator / (double)value.denominator; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator short(FIRational value) + { + return (short)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator int(FIRational value) + { + return (int)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator long(FIRational value) + { + return (byte)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator float(FIRational value) + { + return value.denominator == 0 ? 0f : (float)value.numerator / (float)value.denominator; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator sbyte(FIRational value) + { + return (sbyte)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator ushort(FIRational value) + { + return (ushort)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator uint(FIRational value) + { + return (uint)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator ulong(FIRational value) + { + return (ulong)(double)value; + } + + // + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIRational(bool value) + { + return new FIRational(value ? 1 : 0, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRational(byte value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRational(char value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIRational(decimal value) + { + return new FIRational(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIRational(double value) + { + return new FIRational((decimal)value); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIRational(short value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIRational(int value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIRational(long value) + { + return new FIRational((int)value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIRational(sbyte value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIRational(float value) + { + return new FIRational((decimal)value); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIRational(ushort value) + { + return new FIRational(value, 1); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIRational(uint value) + { + return new FIRational((int)value, 1); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIRational(ulong value) + { + return new FIRational((int)value, 1); + } + + #endregion + + #region IConvertible Member + + TypeCode IConvertible.GetTypeCode() + { + return TypeCode.Double; + } + + bool IConvertible.ToBoolean(IFormatProvider provider) + { + return (bool)this; + } + + byte IConvertible.ToByte(IFormatProvider provider) + { + return (byte)this; + } + + char IConvertible.ToChar(IFormatProvider provider) + { + return (char)this; + } + + DateTime IConvertible.ToDateTime(IFormatProvider provider) + { + return Convert.ToDateTime(((IConvertible)this).ToDouble(provider)); + } + + decimal IConvertible.ToDecimal(IFormatProvider provider) + { + return this; + } + + double IConvertible.ToDouble(IFormatProvider provider) + { + return this; + } + + short IConvertible.ToInt16(IFormatProvider provider) + { + return (short)this; + } + + int IConvertible.ToInt32(IFormatProvider provider) + { + return (int)this; + } + + long IConvertible.ToInt64(IFormatProvider provider) + { + return (long)this; + } + + sbyte IConvertible.ToSByte(IFormatProvider provider) + { + return (sbyte)this; + } + + float IConvertible.ToSingle(IFormatProvider provider) + { + return this; + } + + string IConvertible.ToString(IFormatProvider provider) + { + return ToString(((double)this).ToString(), provider); + } + + object IConvertible.ToType(Type conversionType, IFormatProvider provider) + { + return Convert.ChangeType(((IConvertible)this).ToDouble(provider), conversionType, provider); + } + + ushort IConvertible.ToUInt16(IFormatProvider provider) + { + return (ushort)this; + } + + uint IConvertible.ToUInt32(IFormatProvider provider) + { + return (uint)this; + } + + ulong IConvertible.ToUInt64(IFormatProvider provider) + { + return (ulong)this; + } + + #endregion + + #region IComparable Member + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIRational)) + { + throw new ArgumentException(); + } + return CompareTo((FIRational)obj); + } + + #endregion + + #region IFormattable Member + + /// + /// Formats the value of the current instance using the specified format. + /// + /// The String specifying the format to use. + /// The IFormatProvider to use to format the value. + /// A String containing the value of the current instance in the specified format. + public string ToString(string format, IFormatProvider formatProvider) + { + if (format == null) + { + format = ""; + } + return String.Format(formatProvider, format, ((IConvertible)this).ToDouble(formatProvider)); + } + + #endregion + + #region IEquatable Member + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIRational other) + { + return (this == other); + } + + #endregion + + #region IComparable Member + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIRational other) + { + FIRational difference = this - other; + difference.Normalize(); + if (difference.numerator > 0) return 1; + if (difference.numerator < 0) return -1; + else return 0; + } + + #endregion + } +} + +namespace FreeImageAPI +{ + /// + /// The FIURational structure represents a fraction via two + /// instances which are interpreted as numerator and denominator. + /// + /// + /// The structure tries to approximate the value of + /// when creating a new instance by using a better algorithm than FreeImage does. + /// + /// The structure implements the following operators: + /// +, ++, --, ==, != , >, >==, <, <== and ~ (which switches nominator and denomiator). + /// + /// The structure can be converted into all .NET standard types either implicit or + /// explicit. + /// + [Serializable, StructLayout(LayoutKind.Sequential), ComVisible(true)] + public struct FIURational : IConvertible, IComparable, IFormattable, IComparable, IEquatable + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private uint numerator; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private uint denominator; + + /// + /// Represents the largest possible value of . This field is constant. + /// + public static readonly FIURational MaxValue = new FIURational(UInt32.MaxValue, 1u); + + /// + /// Represents the smallest possible value of . This field is constant. + /// + public static readonly FIURational MinValue = new FIURational(0u, 1u); + + /// + /// Represents the smallest positive value greater than zero. This field is constant. + /// + public static readonly FIURational Epsilon = new FIURational(1u, UInt32.MaxValue); + + /// + /// Initializes a new instance based on the specified parameters. + /// + /// The numerator. + /// The denominator. + public FIURational(uint n, uint d) + { + numerator = n; + denominator = d; + Normalize(); + } + + /// + /// Initializes a new instance based on the specified parameters. + /// + /// The tag to read the data from. + public unsafe FIURational(FITAG tag) + { + switch (FreeImage.GetTagType(tag)) + { + case FREE_IMAGE_MDTYPE.FIDT_RATIONAL: + uint* pvalue = (uint*)FreeImage.GetTagValue(tag); + numerator = pvalue[0]; + denominator = pvalue[1]; + Normalize(); + return; + default: + throw new ArgumentException("tag"); + } + } + + /// + ///Initializes a new instance based on the specified parameters. + /// + /// The value to convert into a fraction. + /// + /// cannot be converted into a fraction + /// represented by two unsigned integer values. + public FIURational(decimal value) + { + try + { + if (value < 0) + { + throw new OverflowException("value"); + } + try + { + int[] contFract = CreateContinuedFraction(value); + CreateFraction(contFract, out numerator, out denominator); + Normalize(); + } + catch + { + numerator = 0; + denominator = 1; + } + if (Math.Abs(((decimal)numerator / (decimal)denominator) - value) > 0.0001m) + { + int maxDen = (Int32.MaxValue / (int)value) - 2; + maxDen = maxDen < 10000 ? maxDen : 10000; + ApproximateFraction(value, maxDen, out numerator, out denominator); + Normalize(); + if (Math.Abs(((decimal)numerator / (decimal)denominator) - value) > 0.0001m) + { + throw new OverflowException("Unable to convert value into a fraction"); + } + } + Normalize(); + } + catch (Exception ex) + { + throw new OverflowException("Unable to calculate fraction.", ex); + } + } + + /// + /// The numerator of the fraction. + /// + public uint Numerator + { + get { return numerator; } + } + + /// + /// The denominator of the fraction. + /// + public uint Denominator + { + get { return denominator; } + } + + /// + /// Returns the truncated value of the fraction. + /// + /// + public int Truncate() + { + return denominator > 0 ? (int)(numerator / denominator) : 0; + } + + /// + /// Returns whether the fraction is representing an integer value. + /// + public bool IsInteger + { + get + { + return (denominator == 1 || + (denominator != 0 && (numerator % denominator == 0)) || + (denominator == 0 && numerator == 0)); + } + } + + /// + /// Calculated the greatest common divisor of 'a' and 'b'. + /// + private static ulong Gcd(ulong a, ulong b) + { + ulong r; + while (b > 0) + { + r = a % b; + a = b; + b = r; + } + return a; + } + + /// + /// Calculated the smallest common multiple of 'a' and 'b'. + /// + private static ulong Scm(uint n, uint m) + { + return (ulong)n * (ulong)m / Gcd(n, m); + } + + /// + /// Normalizes the fraction. + /// + private void Normalize() + { + if (denominator == 0) + { + numerator = 0; + denominator = 1; + return; + } + + if (numerator != 1 && denominator != 1) + { + uint common = (uint)Gcd(numerator, denominator); + if (common != 1 && common != 0) + { + numerator /= common; + denominator /= common; + } + } + } + + /// + /// Normalizes a fraction. + /// + private static void Normalize(ref ulong numerator, ref ulong denominator) + { + if (denominator == 0) + { + numerator = 0; + denominator = 1; + } + else if (numerator != 1 && denominator != 1) + { + ulong common = Gcd(numerator, denominator); + if (common != 1) + { + numerator /= common; + denominator /= common; + } + } + } + + /// + /// Returns the digits after the point. + /// + private static int GetDigits(decimal value) + { + int result = 0; + value -= decimal.Truncate(value); + while (value != 0) + { + value *= 10; + value -= decimal.Truncate(value); + result++; + } + return result; + } + + /// + /// Creates a continued fraction of a decimal value. + /// + private static int[] CreateContinuedFraction(decimal value) + { + int precision = GetDigits(value); + decimal epsilon = 0.0000001m; + List list = new List(); + value = Math.Abs(value); + + byte b = 0; + + list.Add((int)value); + value -= ((int)value); + + while (value != 0m) + { + if (++b == byte.MaxValue || value < epsilon) + { + break; + } + value = 1m / value; + if (Math.Abs((Math.Round(value, precision - 1) - value)) < epsilon) + { + value = Math.Round(value, precision - 1); + } + list.Add((int)value); + value -= ((int)value); + } + return list.ToArray(); + } + + /// + /// Creates a fraction from a continued fraction. + /// + private static void CreateFraction(int[] continuedFraction, out uint numerator, out uint denominator) + { + numerator = 1; + denominator = 0; + uint temp; + + for (int i = continuedFraction.Length - 1; i > -1; i--) + { + temp = numerator; + numerator = (uint)(continuedFraction[i] * numerator + denominator); + denominator = temp; + } + } + + /// + /// Tries 'brute force' to approximate with a fraction. + /// + private static void ApproximateFraction(decimal value, int maxDen, out uint num, out uint den) + { + num = 0; + den = 0; + decimal bestDifference = 1m; + decimal currentDifference = -1m; + int digits = GetDigits(value); + + if (digits <= 9) + { + uint mul = 1; + for (int i = 1; i <= digits; i++) + { + mul *= 10; + } + if (mul <= maxDen) + { + num = (uint)(value * mul); + den = mul; + return; + } + } + + for (uint u = 1; u <= maxDen; u++) + { + uint numerator = (uint)Math.Floor(value * (decimal)u + 0.5m); + currentDifference = Math.Abs(value - (decimal)numerator / (decimal)u); + if (currentDifference < bestDifference) + { + num = numerator; + den = u; + bestDifference = currentDifference; + } + } + } + + /// + /// Converts the numeric value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return ((IConvertible)this).ToDouble(null).ToString(); + } + + /// + /// Tests whether the specified object is a structure + /// and is equivalent to this structure. + /// + /// The object to test. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is FIURational) && (this == ((FIURational)obj))); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return base.GetHashCode(); + } + + #region Operators + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator +(FIURational value) + { + return value; + } + + /// + /// Returns the reciprocal value of this instance. + /// + public static FIURational operator ~(FIURational value) + { + uint temp = value.denominator; + value.denominator = value.numerator; + value.numerator = temp; + value.Normalize(); + return value; + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator ++(FIURational value) + { + checked + { + value.numerator += value.denominator; + } + return value; + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator --(FIURational value) + { + checked + { + value.numerator -= value.denominator; + } + return value; + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator +(FIURational left, FIURational right) + { + ulong numerator = 0; + ulong denominator = Scm(left.denominator, right.denominator); + numerator = (left.numerator * (denominator / left.denominator)) + + (right.numerator * (denominator / right.denominator)); + Normalize(ref numerator, ref denominator); + checked + { + return new FIURational((uint)numerator, (uint)denominator); + } + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator -(FIURational left, FIURational right) + { + checked + { + if (left.denominator != right.denominator) + { + uint denom = left.denominator; + left.numerator *= right.denominator; + left.denominator *= right.denominator; + right.numerator *= denom; + right.denominator *= denom; + } + left.numerator -= right.numerator; + left.Normalize(); + return left; + } + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator *(FIURational left, FIURational r2) + { + ulong numerator = left.numerator * r2.numerator; + ulong denominator = left.denominator * r2.denominator; + Normalize(ref numerator, ref denominator); + checked + { + return new FIURational((uint)numerator, (uint)denominator); + } + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator /(FIURational left, FIURational right) + { + uint temp = right.denominator; + right.denominator = right.numerator; + right.numerator = temp; + return left * right; + } + + /// + /// Standard implementation of the operator. + /// + public static FIURational operator %(FIURational left, FIURational right) + { + right.Normalize(); + if (Math.Abs(right.numerator) < right.denominator) + return new FIURational(0, 0); + int div = (int)(left / right); + return left - (right * div); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator ==(FIURational left, FIURational right) + { + left.Normalize(); + right.Normalize(); + return (left.numerator == right.numerator) && (left.denominator == right.denominator); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator !=(FIURational left, FIURational right) + { + left.Normalize(); + right.Normalize(); + return (left.numerator != right.numerator) || (left.denominator != right.denominator); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator >(FIURational left, FIURational right) + { + ulong denominator = Scm(left.denominator, right.denominator); + return (left.numerator * (denominator / left.denominator)) > + (right.numerator * (denominator / right.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator <(FIURational left, FIURational right) + { + ulong denominator = Scm(left.denominator, right.denominator); + return (left.numerator * (denominator / left.denominator)) < + (right.numerator * (denominator / right.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator >=(FIURational left, FIURational right) + { + ulong denominator = Scm(left.denominator, right.denominator); + return (left.numerator * (denominator / left.denominator)) >= + (right.numerator * (denominator / right.denominator)); + } + + /// + /// Standard implementation of the operator. + /// + public static bool operator <=(FIURational left, FIURational right) + { + ulong denominator = Scm(left.denominator, right.denominator); + return (left.numerator * (denominator / left.denominator)) <= + (right.numerator * (denominator / right.denominator)); + } + + #endregion + + #region Conversions + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator bool(FIURational value) + { + return (value.numerator != 0); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator byte(FIURational value) + { + return (byte)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator char(FIURational value) + { + return (char)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator decimal(FIURational value) + { + return value.denominator == 0 ? 0m : (decimal)value.numerator / (decimal)value.denominator; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator double(FIURational value) + { + return value.denominator == 0 ? 0d : (double)value.numerator / (double)value.denominator; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator short(FIURational value) + { + return (short)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator int(FIURational value) + { + return (int)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator long(FIURational value) + { + return (byte)(double)value; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator float(FIURational value) + { + return value.denominator == 0 ? 0f : (float)value.numerator / (float)value.denominator; + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator sbyte(FIURational value) + { + return (sbyte)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator ushort(FIURational value) + { + return (ushort)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator uint(FIURational value) + { + return (uint)(double)value; + } + + /// + /// Converts the value of a structure to an structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator ulong(FIURational value) + { + return (ulong)(double)value; + } + + // + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIURational(bool value) + { + return new FIURational(value ? 1u : 0u, 1u); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIURational(byte value) + { + return new FIURational(value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIURational(char value) + { + return new FIURational(value, 1); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIURational(decimal value) + { + return new FIURational(value); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIURational(double value) + { + return new FIURational((decimal)value); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIURational(short value) + { + return new FIURational((uint)value, 1u); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIURational(int value) + { + return new FIURational((uint)value, 1u); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIURational(long value) + { + return new FIURational((uint)value, 1u); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static implicit operator FIURational(sbyte value) + { + return new FIURational((uint)value, 1u); + } + + /// + /// Converts the value of a structure to a structure. + /// + /// A structure. + /// A new instance of initialized to . + public static explicit operator FIURational(float value) + { + return new FIURational((decimal)value); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static implicit operator FIURational(ushort value) + { + return new FIURational(value, 1); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIURational(uint value) + { + return new FIURational(value, 1u); + } + + /// + /// Converts the value of an structure to a structure. + /// + /// An structure. + /// A new instance of initialized to . + public static explicit operator FIURational(ulong value) + { + return new FIURational((uint)value, 1u); + } + + #endregion + + #region IConvertible Member + + TypeCode IConvertible.GetTypeCode() + { + return TypeCode.Double; + } + + bool IConvertible.ToBoolean(IFormatProvider provider) + { + return (bool)this; + } + + byte IConvertible.ToByte(IFormatProvider provider) + { + return (byte)this; + } + + char IConvertible.ToChar(IFormatProvider provider) + { + return (char)this; + } + + DateTime IConvertible.ToDateTime(IFormatProvider provider) + { + return Convert.ToDateTime(((IConvertible)this).ToDouble(provider)); + } + + decimal IConvertible.ToDecimal(IFormatProvider provider) + { + return this; + } + + double IConvertible.ToDouble(IFormatProvider provider) + { + return this; + } + + short IConvertible.ToInt16(IFormatProvider provider) + { + return (short)this; + } + + int IConvertible.ToInt32(IFormatProvider provider) + { + return (int)this; + } + + long IConvertible.ToInt64(IFormatProvider provider) + { + return (long)this; + } + + sbyte IConvertible.ToSByte(IFormatProvider provider) + { + return (sbyte)this; + } + + float IConvertible.ToSingle(IFormatProvider provider) + { + return this; + } + + string IConvertible.ToString(IFormatProvider provider) + { + return ToString(((double)this).ToString(), provider); + } + + object IConvertible.ToType(Type conversionType, IFormatProvider provider) + { + return Convert.ChangeType(((IConvertible)this).ToDouble(provider), conversionType, provider); + } + + ushort IConvertible.ToUInt16(IFormatProvider provider) + { + return (ushort)this; + } + + uint IConvertible.ToUInt32(IFormatProvider provider) + { + return (uint)this; + } + + ulong IConvertible.ToUInt64(IFormatProvider provider) + { + return (ulong)this; + } + + #endregion + + #region IComparable Member + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is FIURational)) + { + throw new ArgumentException(); + } + return CompareTo((FIURational)obj); + } + + #endregion + + #region IFormattable Member + + /// + /// Formats the value of the current instance using the specified format. + /// + /// The String specifying the format to use. + /// The IFormatProvider to use to format the value. + /// A String containing the value of the current instance in the specified format. + public string ToString(string format, IFormatProvider formatProvider) + { + if (format == null) + { + format = ""; + } + return String.Format(formatProvider, format, ((IConvertible)this).ToDouble(formatProvider)); + } + + #endregion + + #region IEquatable Member + + /// + /// Tests whether the specified structure is equivalent to this structure. + /// + /// A structure to compare to this instance. + /// true if is a structure + /// equivalent to this structure; otherwise, false. + public bool Equals(FIURational other) + { + return (this == other); + } + + #endregion + + #region IComparable Member + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(FIURational other) + { + FIURational difference = this - other; + difference.Normalize(); + if (difference.numerator > 0) return 1; + if (difference.numerator < 0) return -1; + else return 0; + } + + #endregion + } +} + + #endregion + + #region Classes + +namespace FreeImageAPI +{ + /// + /// Encapsulates a FreeImage-bitmap. + /// + [Serializable, Guid("64a4c935-b757-499c-ab8c-6110316a9e51")] + public class FreeImageBitmap : MarshalByRefObject, ICloneable, IDisposable, IEnumerable, ISerializable + { + #region Fields + + /// + /// Indicates whether this instance is disposed. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool disposed; + + /// + /// Tab object. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private object tag; + + /// + /// Object used to syncronize lock methods. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private object lockObject = new object(); + + /// + /// Holds information used by SaveAdd() methods. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private SaveInformation saveInformation = new SaveInformation(); + + /// + /// The stream that this instance was loaded from or + /// null if it has been cloned or deserialized. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private Stream stream; + + /// + /// True if the stream must be disposed with this + /// instance. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool disposeStream; + + /// + /// The number of frames contained by a mutlipage bitmap. + /// Default value is 1 and only changed if needed. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private int frameCount = 1; + + /// + /// The index of the loaded frame. + /// Default value is 0 and only changed if needed. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private int frameIndex = 0; + + /// + /// Format of the sourceimage. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private FREE_IMAGE_FORMAT originalFormat = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + + /// + /// Handle to the encapsulated FreeImage-bitmap. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private FIBITMAP dib; + + private const string ErrorLoadingBitmap = "Unable to load bitmap."; + private const string ErrorLoadingFrame = "Unable to load frame."; + private const string ErrorCreatingBitmap = "Unable to create bitmap."; + private const string ErrorUnloadBitmap = "Unable to unload bitmap."; + + #endregion + + #region Constructors and Destructor + + /// + /// Initializes a new instance of the class. + /// + protected FreeImageBitmap() + { + } + + /// + /// Initializes a new instance of the class. + /// For internal use only. + /// + /// The operation failed. + internal protected FreeImageBitmap(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + this.dib = dib; + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image. + /// + /// The original to clone from. + /// The operation failed. + /// is a null reference. + public FreeImageBitmap(FreeImageBitmap original) + { + if (original == null) + { + throw new ArgumentNullException("original"); + } + original.EnsureNotDisposed(); + dib = FreeImage.Clone(original.dib); + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + originalFormat = original.originalFormat; + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// The Size structure that represent the + /// size of the new . + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + /// + public FreeImageBitmap(FreeImageBitmap original, Size newSize) + : this(original, newSize.Width, newSize.Height) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// Width of the new . + /// Height of the new . + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + public FreeImageBitmap(FreeImageBitmap original, int width, int height) + { + if (original == null) + { + throw new ArgumentNullException("original"); + } + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + original.EnsureNotDisposed(); + dib = FreeImage.Rescale(original.dib, width, height, FREE_IMAGE_FILTER.FILTER_BICUBIC); + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + originalFormat = original.originalFormat; + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image. + /// + /// The original to clone from. + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + public FreeImageBitmap(Image original) + : this(original as Bitmap) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// The Size structure that represent the + /// size of the new . + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + /// + public FreeImageBitmap(Image original, Size newSize) + : this(original as Bitmap, newSize.Width, newSize.Height) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + public FreeImageBitmap(Image original, int width, int height) + : this(original as Bitmap, width, height) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image. + /// + /// The original to clone from. + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// is a null reference. + /// The operation failed. + public FreeImageBitmap(Bitmap original) + { + if (original == null) + { + throw new ArgumentNullException("original"); + } + dib = FreeImage.CreateFromBitmap(original, true); + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + originalFormat = FreeImage.GetFormat(original.RawFormat); + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// The Size structure that represent the + /// size of the new . + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + /// + public FreeImageBitmap(Bitmap original, Size newSize) + : this(original, newSize.Width, newSize.Height) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified image with the specified size. + /// + /// The original to clone from. + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is a null reference. + /// + /// or are less or equal zero. + public FreeImageBitmap(Bitmap original, int width, int height) + { + if (original == null) + { + throw new ArgumentNullException("original"); + } + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + FIBITMAP temp = FreeImage.CreateFromBitmap(original, true); + if (temp.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + dib = FreeImage.Rescale(temp, width, height, FREE_IMAGE_FILTER.FILTER_BICUBIC); + FreeImage.Unload(temp); + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + originalFormat = FreeImage.GetFormat(original.RawFormat); + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified stream. + /// + /// Stream to read from. + /// Ignored. + /// The operation failed. + /// is a null reference. + /// + /// You must keep the stream open for the lifetime of the . + /// + public FreeImageBitmap(Stream stream, bool useIcm) + : this(stream) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified stream. + /// + /// Stream to read from. + /// The operation failed. + /// is a null reference. + /// + /// You must keep the stream open for the lifetime of the . + /// + public FreeImageBitmap(Stream stream) + : this(stream, FREE_IMAGE_FORMAT.FIF_UNKNOWN, FREE_IMAGE_LOAD_FLAGS.DEFAULT) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified stream in the specified format. + /// + /// Stream to read from. + /// Format of the image. + /// The operation failed. + /// is a null reference. + /// + /// You must keep the stream open for the lifetime of the . + /// + public FreeImageBitmap(Stream stream, FREE_IMAGE_FORMAT format) + : this(stream, format, FREE_IMAGE_LOAD_FLAGS.DEFAULT) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified stream with the specified loading flags. + /// + /// Stream to read from. + /// Flags to enable or disable plugin-features. + /// The operation failed. + /// is a null reference. + /// + /// You must keep the stream open for the lifetime of the . + /// + public FreeImageBitmap(Stream stream, FREE_IMAGE_LOAD_FLAGS flags) + : this(stream, FREE_IMAGE_FORMAT.FIF_UNKNOWN, flags) + { + } + + /// + /// Initializes a new instance of the class + /// bases on the specified stream in the specified format + /// with the specified loading flags. + /// + /// Stream to read from. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// The operation failed. + /// is a null reference. + /// + /// You must keep the stream open for the lifetime of the . + /// + public FreeImageBitmap(Stream stream, FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags) + { + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + this.stream = stream; + disposeStream = false; + LoadFromStream(stream, format, flags); + } + + /// + /// Initializes a new instance of the class bases on the specified file. + /// + /// The complete name of the file to load. + /// The operation failed. + /// is a null reference. + /// does not exist. + public FreeImageBitmap(string filename) + : this(filename, FREE_IMAGE_LOAD_FLAGS.DEFAULT) + { + } + + /// + /// Initializes a new instance of the class bases on the specified file. + /// + /// The complete name of the file to load. + /// Ignored. + /// The operation failed. + /// is a null reference. + /// does not exist. + public FreeImageBitmap(string filename, bool useIcm) + : this(filename) + { + } + + /// + /// Initializes a new instance of the class bases on the specified file + /// with the specified loading flags. + /// + /// The complete name of the file to load. + /// Flags to enable or disable plugin-features. + /// The operation failed. + /// is a null reference. + /// does not exist. + public FreeImageBitmap(string filename, FREE_IMAGE_LOAD_FLAGS flags) + : this(filename, FREE_IMAGE_FORMAT.FIF_UNKNOWN, flags) + { + } + + /// + /// Initializes a new instance of the class bases on the specified file + /// in the specified format. + /// + /// The complete name of the file to load. + /// Format of the image. + /// The operation failed. + /// is a null reference. + /// does not exist. + public FreeImageBitmap(string filename, FREE_IMAGE_FORMAT format) + : this(filename, format, FREE_IMAGE_LOAD_FLAGS.DEFAULT) + { + } + + /// + /// Initializes a new instance of the class bases on the specified file + /// in the specified format with the specified loading flags. + /// + /// The complete name of the file to load. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// The operation failed. + /// is a null reference. + /// does not exist. + public FreeImageBitmap(string filename, FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags) + { + if (filename == null) + { + throw new ArgumentNullException("filename"); + } + if (!File.Exists(filename)) + { + throw new FileNotFoundException("filename"); + } + + saveInformation.filename = filename; + stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); + disposeStream = true; + LoadFromStream(stream, format, flags); + } + + /// + /// Initializes a new instance of the class + /// bases on the specified size. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// The operation failed. + public FreeImageBitmap(int width, int height) + { + dib = FreeImage.Allocate( + width, + height, + 24, + FreeImage.FI_RGBA_RED_MASK, + FreeImage.FI_RGBA_GREEN_MASK, + FreeImage.FI_RGBA_BLUE_MASK); + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified resource. + /// + /// The class used to extract the resource. + /// The name of the resource. + /// The operation failed. + public FreeImageBitmap(Type type, string resource) + : this(type.Module.Assembly.GetManifestResourceStream(type, resource)) + { + } + + /// + /// Initializes a new instance of the class bases on the specified size + /// and with the resolution of the specified object. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// The Graphics object that specifies the resolution for the new . + /// The operation failed. + /// is a null reference. + public FreeImageBitmap(int width, int height, Graphics g) + : this(width, height) + { + FreeImage.SetResolutionX(dib, (uint)g.DpiX); + FreeImage.SetResolutionY(dib, (uint)g.DpiY); + } + + /// + /// Initializes a new instance of the class bases on the specified size and format. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// The PixelFormat enumeration for the new . + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is invalid. + /// + /// or are less or equal zero. + public FreeImageBitmap(int width, int height, PixelFormat format) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + uint bpp, redMask, greenMask, blueMask; + FREE_IMAGE_TYPE type; + if (!FreeImage.GetFormatParameters(format, out type, out bpp, out redMask, out greenMask, out blueMask)) + { + throw new ArgumentException("format is invalid"); + } + dib = FreeImage.AllocateT(type, width, height, (int)bpp, redMask, greenMask, blueMask); + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified size and type. + /// Only non standard bitmaps are supported. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// The type of the bitmap. + /// The operation failed. + /// + /// is FIT_BITMAP or FIT_UNKNOWN. + /// is invalid. + /// + /// or are less or equal zero. + public FreeImageBitmap(int width, int height, FREE_IMAGE_TYPE type) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + if ((type == FREE_IMAGE_TYPE.FIT_BITMAP) || (type == FREE_IMAGE_TYPE.FIT_UNKNOWN)) + { + throw new ArgumentException("type is invalid."); + } + dib = FreeImage.AllocateT(type, width, height, 0, 0u, 0u, 0u); + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified size, + /// pixel format and pixel data. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// Integer that specifies the byte offset between the beginning + /// of one scan line and the next. This is usually (but not necessarily) + /// the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) + /// multiplied by the width of the bitmap. The value passed to this parameter must + /// be a multiple of four.. + /// The PixelFormat enumeration for the new . + /// Pointer to an array of bytes that contains the pixel data. + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is invalid. + /// + /// or are less or equal zero. + public FreeImageBitmap(int width, int height, int stride, PixelFormat format, IntPtr scan0) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + uint bpp, redMask, greenMask, blueMask; + FREE_IMAGE_TYPE type; + bool topDown = (stride > 0); + stride = (stride > 0) ? stride : (stride * -1); + + if (!FreeImage.GetFormatParameters(format, out type, out bpp, out redMask, out greenMask, out blueMask)) + { + throw new ArgumentException("format is invalid."); + } + + dib = FreeImage.ConvertFromRawBits( + scan0, type, width, height, stride, bpp, redMask, greenMask, blueMask, topDown); + + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified size, + /// pixel format and pixel data. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// Integer that specifies the byte offset between the beginning + /// of one scan line and the next. This is usually (but not necessarily) + /// the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) + /// multiplied by the width of the bitmap. The value passed to this parameter must + /// be a multiple of four.. + /// The PixelFormat enumeration for the new . + /// Array of bytes containing the bitmap data. + /// + /// Although this constructor supports creating images in both formats + /// + /// and , bitmaps + /// created in these formats are treated like any normal 32-bit RGBA and 64-bit RGBA + /// images respectively. Currently, there is no support for automatic premultiplying images in + /// . + /// + /// The operation failed. + /// is invalid. + /// + /// or are less or equal zero. + /// is null + public FreeImageBitmap(int width, int height, int stride, PixelFormat format, byte[] bits) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + if (bits == null) + { + throw new ArgumentNullException("bits"); + } + uint bpp, redMask, greenMask, blueMask; + FREE_IMAGE_TYPE type; + bool topDown = (stride > 0); + stride = (stride > 0) ? stride : (stride * -1); + + if (!FreeImage.GetFormatParameters(format, out type, out bpp, out redMask, out greenMask, out blueMask)) + { + throw new ArgumentException("format is invalid."); + } + + dib = FreeImage.ConvertFromRawBits( + bits, type, width, height, stride, bpp, redMask, greenMask, blueMask, topDown); + + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified size, + /// pixel format and pixel data. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// Integer that specifies the byte offset between the beginning + /// of one scan line and the next. This is usually (but not necessarily) + /// the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) + /// multiplied by the width of the bitmap. The value passed to this parameter must + /// be a multiple of four.. + /// The color depth of the new + /// The type for the new . + /// Pointer to an array of bytes that contains the pixel data. + /// The operation failed. + /// is invalid. + /// + /// or are less or equal zero. + public FreeImageBitmap(int width, int height, int stride, int bpp, FREE_IMAGE_TYPE type, IntPtr scan0) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + uint redMask, greenMask, blueMask; + bool topDown = (stride > 0); + stride = (stride > 0) ? stride : (stride * -1); + + if (!FreeImage.GetTypeParameters(type, bpp, out redMask, out greenMask, out blueMask)) + { + throw new ArgumentException("bpp and type are invalid or not supported."); + } + + dib = FreeImage.ConvertFromRawBits( + scan0, type, width, height, stride, (uint)bpp, redMask, greenMask, blueMask, topDown); + + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class bases on the specified size, + /// pixel format and pixel data. + /// + /// The width, in pixels, of the new . + /// The height, in pixels, of the new . + /// Integer that specifies the byte offset between the beginning + /// of one scan line and the next. This is usually (but not necessarily) + /// the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) + /// multiplied by the width of the bitmap. The value passed to this parameter must + /// be a multiple of four.. + /// The color depth of the new + /// The type for the new . + /// Array of bytes containing the bitmap data. + /// The operation failed. + /// is invalid. + /// + /// or are less or equal zero. + /// is null + public FreeImageBitmap(int width, int height, int stride, int bpp, FREE_IMAGE_TYPE type, byte[] bits) + { + if (width <= 0) + { + throw new ArgumentOutOfRangeException("width"); + } + if (height <= 0) + { + throw new ArgumentOutOfRangeException("height"); + } + if (bits == null) + { + throw new ArgumentNullException("bits"); + } + uint redMask, greenMask, blueMask; + bool topDown = (stride > 0); + stride = (stride > 0) ? stride : (stride * -1); + + if (!FreeImage.GetTypeParameters(type, bpp, out redMask, out greenMask, out blueMask)) + { + throw new ArgumentException("bpp and type are invalid or not supported."); + } + + dib = FreeImage.ConvertFromRawBits( + bits, type, width, height, stride, (uint)bpp, redMask, greenMask, blueMask, topDown); + + if (dib.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + AddMemoryPressure(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The operation failed. + /// The operation failed. + public FreeImageBitmap(SerializationInfo info, StreamingContext context) + { + try + { + byte[] data = (byte[])info.GetValue("Bitmap Data", typeof(byte[])); + if ((data != null) && (data.Length > 0)) + { + MemoryStream memory = new MemoryStream(data); + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_TIFF; + dib = FreeImage.LoadFromStream(memory, ref format); + + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + + AddMemoryPressure(); + } + } + catch (Exception ex) + { + throw new SerializationException("Deserialization failed.", ex); + } + } + + /// + /// Frees all managed and unmanaged ressources. + /// + ~FreeImageBitmap() + { + Dispose(false); + } + + #endregion + + #region Operators + + /// + /// Converts a instance to a instance. + /// + /// A instance. + /// A new instance of initialized to . + /// + /// The explicit conversion from into Bitmap + /// allows to create an instance on the fly and use it as if + /// was a Bitmap. This way it can be directly used with a + /// PixtureBox for example without having to call any + /// conversion operations. + /// + public static explicit operator Bitmap(FreeImageBitmap value) + { + return value.ToBitmap(); + } + + /// + /// Converts a instance to a instance. + /// + /// A instance. + /// A new instance of initialized to . + /// + /// The explicit conversion from into + /// allows to create an instance on the fly to perform + /// image processing operations and converting it back. + /// + public static explicit operator FreeImageBitmap(Bitmap value) + { + return new FreeImageBitmap(value); + } + + /// + /// Determines whether two specified objects have the same value. + /// + /// A or a null reference (Nothing in Visual Basic). + /// A or a null reference (Nothing in Visual Basic). + /// + /// true if the value of left is the same as the value of right; otherwise, false. + /// + public static bool operator ==(FreeImageBitmap left, FreeImageBitmap right) + { + if (object.ReferenceEquals(left, right)) + { + return true; + } + else if (object.ReferenceEquals(left, null) || object.ReferenceEquals(right, null)) + { + return false; + } + else + { + left.EnsureNotDisposed(); + right.EnsureNotDisposed(); + return FreeImage.Compare(left.dib, right.dib, FREE_IMAGE_COMPARE_FLAGS.COMPLETE); + } + } + + /// + /// Determines whether two specified objects have different values. + /// + /// A or a null reference (Nothing in Visual Basic). + /// A or a null reference (Nothing in Visual Basic). + /// + /// true if the value of left is different from the value of right; otherwise, false. + /// + public static bool operator !=(FreeImageBitmap left, FreeImageBitmap right) + { + return (!(left == right)); + } + + #endregion + + #region Properties + + /// + /// Type of the bitmap. + /// + public FREE_IMAGE_TYPE ImageType + { + get + { + EnsureNotDisposed(); + return FreeImage.GetImageType(dib); + } + } + + /// + /// Number of palette entries. + /// + public int ColorsUsed + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetColorsUsed(dib); + } + } + + /// + /// The number of unique colors actually used by the bitmap. This might be different from + /// what ColorsUsed returns, which actually returns the palette size for palletised images. + /// Works for FIT_BITMAP type bitmaps only. + /// + public int UniqueColors + { + get + { + EnsureNotDisposed(); + return FreeImage.GetUniqueColors(dib); + } + } + + /// + /// The size of one pixel in the bitmap in bits. + /// + public int ColorDepth + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetBPP(dib); + } + } + + /// + /// Width of the bitmap in pixel units. + /// + public int Width + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetWidth(dib); + } + } + + /// + /// Height of the bitmap in pixel units. + /// + public int Height + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetHeight(dib); + } + } + + /// + /// Returns the width of the bitmap in bytes, rounded to the next 32-bit boundary. + /// + public int Pitch + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetPitch(dib); + } + } + + /// + /// Size of the bitmap in memory. + /// + public int DataSize + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetDIBSize(dib); + } + } + + /// + /// Returns a structure that represents the palette of a FreeImage bitmap. + /// + /// is false. + public Palette Palette + { + get + { + EnsureNotDisposed(); + if (HasPalette) + { + return new Palette(dib); + } + throw new InvalidOperationException("This bitmap does not have a palette."); + } + } + + /// + /// Gets whether the bitmap is RGB 555. + /// + public bool IsRGB555 + { + get + { + EnsureNotDisposed(); + return FreeImage.IsRGB555(dib); + } + } + + /// + /// Gets whether the bitmap is RGB 565. + /// + public bool IsRGB565 + { + get + { + EnsureNotDisposed(); + return FreeImage.IsRGB565(dib); + } + } + + /// + /// Gets the horizontal resolution, in pixels per inch, of this . + /// + public float HorizontalResolution + { + get + { + EnsureNotDisposed(); + return (float)FreeImage.GetResolutionX(dib); + } + private set + { + EnsureNotDisposed(); + FreeImage.SetResolutionX(dib, (uint)value); + } + } + + /// + /// Gets the vertical resolution, in pixels per inch, of this . + /// + public float VerticalResolution + { + get + { + EnsureNotDisposed(); + return (float)FreeImage.GetResolutionY(dib); + } + private set + { + EnsureNotDisposed(); + FreeImage.SetResolutionY(dib, (uint)value); + } + } + + /// + /// Returns the structure of this . + /// + public BITMAPINFOHEADER InfoHeader + { + get + { + EnsureNotDisposed(); + return FreeImage.GetInfoHeaderEx(dib); + } + } + + /// + /// Returns the structure of a this . + /// + public BITMAPINFO Info + { + get + { + EnsureNotDisposed(); + return FreeImage.GetInfoEx(dib); + } + } + + /// + /// Investigates the color type of this + /// by reading the bitmaps pixel bits and analysing them. + /// + public FREE_IMAGE_COLOR_TYPE ColorType + { + get + { + EnsureNotDisposed(); + return FreeImage.GetColorType(dib); + } + } + + /// + /// Bit pattern describing the red color component of a pixel in this . + /// + public uint RedMask + { + get + { + EnsureNotDisposed(); + return FreeImage.GetRedMask(dib); + } + } + + /// + /// Bit pattern describing the green color component of a pixel in this . + /// + public uint GreenMask + { + get + { + EnsureNotDisposed(); + return FreeImage.GetGreenMask(dib); + } + } + + /// + /// Bit pattern describing the blue color component of a pixel in this . + /// + public uint BlueMask + { + get + { + EnsureNotDisposed(); + return FreeImage.GetBlueMask(dib); + } + } + + /// + /// Number of transparent colors in a palletised . + /// + public int TransparencyCount + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetTransparencyCount(dib); + } + } + + /// + /// Get or sets transparency table of this . + /// + public byte[] TransparencyTable + { + get + { + EnsureNotDisposed(); + return FreeImage.GetTransparencyTableEx(dib); + } + set + { + EnsureNotDisposed(); + FreeImage.SetTransparencyTable(dib, value); + } + } + + /// + /// Gets or sets whether this is transparent. + /// + public bool IsTransparent + { + get + { + EnsureNotDisposed(); + return FreeImage.IsTransparent(dib); + } + set + { + EnsureNotDisposed(); + FreeImage.SetTransparent(dib, value); + } + } + + /// + /// Gets whether this has a file background color. + /// + public bool HasBackgroundColor + { + get + { + EnsureNotDisposed(); + return FreeImage.HasBackgroundColor(dib); + } + } + + /// + /// Gets or sets the background color of this . + /// In case the value is null, the background color is removed. + /// + /// Get: There is no background color available. + /// Set: Setting background color failed. + public Color? BackgroundColor + { + get + { + EnsureNotDisposed(); + if (!FreeImage.HasBackgroundColor(dib)) + { + throw new InvalidOperationException("No background color available."); + } + RGBQUAD rgbq; + FreeImage.GetBackgroundColor(dib, out rgbq); + return rgbq.Color; + } + set + { + EnsureNotDisposed(); + if (!FreeImage.SetBackgroundColor(dib, (value.HasValue ? new RGBQUAD[] { value.Value } : null))) + { + throw new Exception("Setting background color failed."); + } + } + } + + /// + /// Pointer to the data-bits of this . + /// + public IntPtr Bits + { + get + { + EnsureNotDisposed(); + return FreeImage.GetBits(dib); + } + } + + /// + /// Width, in bytes, of this . + /// + public int Line + { + get + { + EnsureNotDisposed(); + return (int)FreeImage.GetLine(dib); + } + } + + /// + /// Pointer to the scanline of the top most pixel row of this . + /// + public IntPtr Scan0 + { + get + { + EnsureNotDisposed(); + return FreeImage.GetScanLine(dib, (int)(FreeImage.GetHeight(dib) - 1)); + } + } + + /// + /// Width, in bytes, of this . + /// In case this is top down Stride will be positive, else negative. + /// + public int Stride + { + get + { + return -Line; + } + } + + /// + /// Gets attribute flags for the pixel data of this . + /// + public unsafe int Flags + { + get + { + EnsureNotDisposed(); + int result = 0; + byte alpha; + int cd = ColorDepth; + + if ((cd == 32) || (FreeImage.GetTransparencyCount(dib) != 0)) + { + result += (int)ImageFlags.HasAlpha; + } + + if (cd == 32) + { + uint width = FreeImage.GetWidth(dib); + uint height = FreeImage.GetHeight(dib); + for (int y = 0; y < height; y++) + { + RGBQUAD* scanline = (RGBQUAD*)FreeImage.GetScanLine(dib, y); + for (int x = 0; x < width; x++) + { + alpha = scanline[x].Color.A; + if (alpha != byte.MinValue && alpha != byte.MaxValue) + { + result += (int)ImageFlags.HasTranslucent; + y = (int)height; + break; + } + } + } + } + else if (FreeImage.GetTransparencyCount(dib) != 0) + { + byte[] transTable = FreeImage.GetTransparencyTableEx(dib); + for (int i = 0; i < transTable.Length; i++) + { + if (transTable[i] != byte.MinValue && transTable[i] != byte.MaxValue) + { + result += (int)ImageFlags.HasTranslucent; + break; + } + } + } + + if (FreeImage.GetICCProfileEx(dib).IsCMYK) + { + result += (int)ImageFlags.ColorSpaceCmyk; + } + else + { + result += (int)ImageFlags.ColorSpaceRgb; + } + + if (FreeImage.GetColorType(dib) == FREE_IMAGE_COLOR_TYPE.FIC_MINISBLACK || + FreeImage.GetColorType(dib) == FREE_IMAGE_COLOR_TYPE.FIC_MINISWHITE) + { + result += (int)ImageFlags.ColorSpaceGray; + } + + if (originalFormat == FREE_IMAGE_FORMAT.FIF_BMP || + originalFormat == FREE_IMAGE_FORMAT.FIF_FAXG3 || + originalFormat == FREE_IMAGE_FORMAT.FIF_ICO || + originalFormat == FREE_IMAGE_FORMAT.FIF_JPEG || + originalFormat == FREE_IMAGE_FORMAT.FIF_PCX || + originalFormat == FREE_IMAGE_FORMAT.FIF_PNG || + originalFormat == FREE_IMAGE_FORMAT.FIF_PSD || + originalFormat == FREE_IMAGE_FORMAT.FIF_TIFF) + { + result += (int)ImageFlags.HasRealDpi; + } + + return result; + } + } + + /// + /// Gets the width and height of this . + /// + public SizeF PhysicalDimension + { + get + { + EnsureNotDisposed(); + return new SizeF((float)FreeImage.GetWidth(dib), (float)FreeImage.GetHeight(dib)); + } + } + + /// + /// Gets the pixel format for this . + /// + public PixelFormat PixelFormat + { + get + { + EnsureNotDisposed(); + return FreeImage.GetPixelFormat(dib); + } + } + + /// + /// Gets IDs of the property items stored in this . + /// + public int[] PropertyIdList + { + get + { + EnsureNotDisposed(); + List list = new List(); + ImageMetadata metaData = new ImageMetadata(dib, true); + + foreach (MetadataModel metadataModel in metaData) + { + foreach (MetadataTag metadataTag in metadataModel) + { + list.Add(metadataTag.ID); + } + } + + return list.ToArray(); + } + } + + /// + /// Gets all the property items (pieces of metadata) stored in this . + /// + public PropertyItem[] PropertyItems + { + get + { + EnsureNotDisposed(); + List list = new List(); + ImageMetadata metaData = new ImageMetadata(dib, true); + + foreach (MetadataModel metadataModel in metaData) + { + foreach (MetadataTag metadataTag in metadataModel) + { + list.Add(metadataTag.GetPropertyItem()); + } + } + + return list.ToArray(); + } + } + + /// + /// Gets the format of this . + /// + public ImageFormat RawFormat + { + get + { + EnsureNotDisposed(); + Attribute guidAttribute = + Attribute.GetCustomAttribute( + typeof(FreeImageBitmap), typeof(System.Runtime.InteropServices.GuidAttribute) + ); + return (guidAttribute == null) ? + null : + new ImageFormat(new Guid(((GuidAttribute)guidAttribute).Value)); + } + } + + /// + /// Gets the width and height, in pixels, of this . + /// + public Size Size + { + get + { + EnsureNotDisposed(); + return new Size(Width, Height); + } + } + + /// + /// Gets or sets an object that provides additional data about the . + /// + public Object Tag + { + get + { + EnsureNotDisposed(); + return tag; + } + set + { + EnsureNotDisposed(); + tag = value; + } + } + + /// + /// Gets whether this has been disposed. + /// + public bool IsDisposed + { + get + { + return disposed; + } + } + + /// + /// Gets a new instance of a metadata representing class. + /// + public ImageMetadata Metadata + { + get + { + EnsureNotDisposed(); + return new ImageMetadata(dib, true); + } + } + + /// + /// Gets or sets the comment of this . + /// Supported formats are JPEG, PNG and GIF. + /// + public string Comment + { + get + { + EnsureNotDisposed(); + return FreeImage.GetImageComment(dib); + } + set + { + EnsureNotDisposed(); + FreeImage.SetImageComment(dib, value); + } + } + + /// + /// Returns whether this has a palette. + /// + public bool HasPalette + { + get + { + EnsureNotDisposed(); + return (FreeImage.GetPalette(dib) != IntPtr.Zero); + } + } + + /// + /// Gets or sets the entry used as transparent color in this . + /// Only works for 1-, 4- and 8-bpp. + /// + public int TransparentIndex + { + get + { + EnsureNotDisposed(); + return FreeImage.GetTransparentIndex(dib); + } + set + { + EnsureNotDisposed(); + FreeImage.SetTransparentIndex(dib, value); + } + } + + /// + /// Gets the number of frames in this . + /// + public int FrameCount + { + get + { + EnsureNotDisposed(); + return frameCount; + } + } + + /// + /// Gets the ICCProfile structure of this . + /// + public FIICCPROFILE ICCProfile + { + get + { + EnsureNotDisposed(); + return FreeImage.GetICCProfileEx(dib); + } + } + + /// + /// Gets the format of the original image in case + /// this was loaded from a file or stream. + /// + public FREE_IMAGE_FORMAT ImageFormat + { + get + { + EnsureNotDisposed(); + return originalFormat; + } + } + + /// + /// Gets the encapsulated FIBITMAP. + /// + internal FIBITMAP Dib + { + get { EnsureNotDisposed(); return dib; } + } + + #endregion + + #region Methods + + /// + /// Gets the bounds of this in the specified unit. + /// + /// One of the values indicating + /// the unit of measure for the bounding rectangle. + /// The that represents the bounds of this + /// , in the specified unit. + public RectangleF GetBounds(ref GraphicsUnit pageUnit) + { + EnsureNotDisposed(); + pageUnit = GraphicsUnit.Pixel; + return new RectangleF( + 0f, + 0f, + (float)FreeImage.GetWidth(dib), + (float)FreeImage.GetHeight(dib)); + } + + /// + /// Gets the specified property item from this . + /// + /// The ID of the property item to get. + /// The this method gets. + public PropertyItem GetPropertyItem(int propid) + { + EnsureNotDisposed(); + ImageMetadata metadata = new ImageMetadata(dib, true); + foreach (MetadataModel metadataModel in metadata) + { + foreach (MetadataTag tag in metadataModel) + { + if (tag.ID == propid) + { + return tag.GetPropertyItem(); + } + } + } + return null; + } + + /// + /// Returns a thumbnail for this . + /// + /// The width, in pixels, of the requested thumbnail image. + /// The height, in pixels, of the requested thumbnail image. + /// Ignored. + /// Ignored. + /// A that represents the thumbnail. + public FreeImageBitmap GetThumbnailImage(int thumbWidth, int thumbHeight, + Image.GetThumbnailImageAbort callback, IntPtr callBackData) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.Rescale( + dib, thumbWidth, thumbHeight, FREE_IMAGE_FILTER.FILTER_BICUBIC); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Returns a thumbnail for this , keeping aspect ratio. + /// defines the maximum width or height + /// of the thumbnail. + /// + /// Thumbnail square size. + /// When true HDR images are transperantly + /// converted to standard images. + /// The thumbnail in a new instance. + public FreeImageBitmap GetThumbnailImage(int maxPixelSize, bool convert) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.MakeThumbnail(dib, maxPixelSize, convert); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Converts this instance to a instance. + /// + /// A new instance of initialized this instance. + public Bitmap ToBitmap() + { + EnsureNotDisposed(); + return FreeImage.GetBitmap(dib, true); + } + + /// + /// Returns an instance of , representing the scanline + /// specified by of this . + /// Since FreeImage bitmaps are always bottum up aligned, keep in mind that scanline 0 is the + /// bottom-most line of the image. + /// + /// Number of the scanline to retrieve. + /// An instance of representing the + /// th scanline. + /// + /// List of return-types of T: + /// + /// Color Depth / TypeResult Type + /// 1 () + /// 4 () + /// 8 () + /// 16 () + /// 16 - 555 () + /// 16 - 565 () + /// 24 () + /// 32 () + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// FreeImageBitmap bitmap = new FreeImageBitmap(@"C:\Pictures\picture.bmp"); + /// if (bitmap.ColorDepth == 32) + /// { + /// Scanline<RGBQUAD> scanline = bitmap.GetScanline<RGBQUAD>(0); + /// foreach (RGBQUAD pixel in scanline) + /// { + /// Console.WriteLine(pixel); + /// } + /// } + /// + /// + /// + /// The bitmap's type or color depth are not supported. + /// + /// + /// is no valid value. + /// + public Scanline GetScanline(int scanline) where T : struct + { + EnsureNotDisposed(); + return new Scanline(dib, scanline); + } + + /// + /// Returns an instance of , representing the scanline + /// specified by of this . + /// Since FreeImage bitmaps are always bottum up aligned, keep in mind that scanline 0 is the + /// bottom-most line of the image. + /// + /// Number of the scanline to retrieve. + /// An instance of representing the + /// th scanline. + /// + /// List of return-types of T: + /// + /// Color Depth / TypeResult Type + /// 1 () + /// 4 () + /// 8 () + /// 16 () + /// 16 - 555 () + /// 16 - 565 () + /// 24 () + /// 32 () + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// FreeImageBitmap bitmap = new FreeImageBitmap(@"C:\Pictures\picture.bmp"); + /// if (bitmap.ColorDepth == 32) + /// { + /// Scanline<RGBQUAD> scanline = (Scanline<RGBQUAD>)bitmap.GetScanline(0); + /// foreach (RGBQUAD pixel in scanline) + /// { + /// Console.WriteLine(pixel); + /// } + /// } + /// + /// + /// + /// The type of the bitmap or color depth are not supported. + /// + /// + /// is no valid value. + /// + public object GetScanline(int scanline) + { + EnsureNotDisposed(); + object result = null; + int width = (int)FreeImage.GetWidth(dib); + + switch (FreeImage.GetImageType(dib)) + { + case FREE_IMAGE_TYPE.FIT_BITMAP: + + switch (FreeImage.GetBPP(dib)) + { + case 1u: result = new Scanline(dib, scanline, width); break; + case 4u: result = new Scanline(dib, scanline, width); break; + case 8u: result = new Scanline(dib, scanline, width); break; + case 16u: + if ((RedMask == FreeImage.FI16_555_RED_MASK) && + (GreenMask == FreeImage.FI16_555_GREEN_MASK) && + (BlueMask == FreeImage.FI16_555_BLUE_MASK)) + { + result = new Scanline(dib, scanline, width); + } + else if ((RedMask == FreeImage.FI16_565_RED_MASK) && + (GreenMask == FreeImage.FI16_565_GREEN_MASK) && + (BlueMask == FreeImage.FI16_565_BLUE_MASK)) + { + result = new Scanline(dib, scanline, width); + } + else + { + result = new Scanline(dib, scanline, width); + } + break; + case 24u: result = new Scanline(dib, scanline, width); break; + case 32u: result = new Scanline(dib, scanline, width); break; + default: throw new ArgumentException("Color depth is not supported."); + } + break; + + case FREE_IMAGE_TYPE.FIT_COMPLEX: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_DOUBLE: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_FLOAT: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_INT16: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_INT32: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_RGB16: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_RGBA16: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_RGBAF: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_RGBF: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_UINT16: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_UINT32: result = new Scanline(dib, scanline, width); break; + case FREE_IMAGE_TYPE.FIT_UNKNOWN: + default: throw new ArgumentException("Type is not supported."); + } + + return result; + } + + /// + /// Returns a pointer to the specified scanline. + /// Due to FreeImage bitmaps are bottum up, + /// scanline 0 is the most bottom line of the image. + /// + /// Number of the scanline. + /// Pointer to the scanline. + public IntPtr GetScanlinePointer(int scanline) + { + EnsureNotDisposed(); + return FreeImage.GetScanLine(dib, scanline); + } + + /// + /// Returns a list of structures, representing the scanlines of this . + /// Due to FreeImage bitmaps are bottum up, scanline 0 is the + /// bottom-most line of the image. + /// Each color depth has a different representing structure due to different memory layouts. + /// + /// + /// List of return-types of T: + /// + /// Color Depth / TypeResult Type of IEnmuerable<Scanline<T>> + /// 1 () + /// 4 () + /// 8 () + /// 16 () + /// 16 - 555 () + /// 16 - 565 () + /// 24 () + /// 32 () + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public IList GetScanlines() + { + EnsureNotDisposed(); + + int height = (int)FreeImage.GetHeight(dib); + IList list; + + switch (FreeImage.GetImageType(dib)) + { + case FREE_IMAGE_TYPE.FIT_BITMAP: + + switch (FreeImage.GetBPP(dib)) + { + case 1u: list = new List>(height); break; + case 4u: list = new List>(height); break; + case 8u: list = new List>(height); break; + case 16u: + if (FreeImage.IsRGB555(dib)) + { + list = new List>(height); + } + else if (FreeImage.IsRGB565(dib)) + { + list = new List>(height); + } + else + { + list = new List>(height); + } + break; + case 24u: list = new List>(height); break; + case 32u: list = new List>(height); break; + default: throw new ArgumentException("Color depth is not supported."); + } + break; + + case FREE_IMAGE_TYPE.FIT_COMPLEX: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_DOUBLE: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_FLOAT: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_INT16: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_INT32: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_RGB16: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_RGBA16: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_RGBAF: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_RGBF: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_UINT16: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_UINT32: list = new List>(height); break; + case FREE_IMAGE_TYPE.FIT_UNKNOWN: + default: throw new ArgumentException("Type is not supported."); + } + + for (int i = 0; i < height; i++) + { + list.Add(GetScanline(i)); + } + + return list; + } + + /// + /// Removes the specified property item from this . + /// + /// The ID of the property item to remove. + public void RemovePropertyItem(int propid) + { + EnsureNotDisposed(); + ImageMetadata mdata = new ImageMetadata(dib, true); + foreach (MetadataModel model in mdata) + { + foreach (MetadataTag tag in model) + { + if (tag.ID == propid) + { + model.RemoveTag(tag.Key); + return; + } + } + } + } + + /// + /// This method rotates, flips, or rotates and flips this . + /// + /// A RotateFlipType member + /// that specifies the type of rotation and flip to apply to this . + public void RotateFlip(RotateFlipType rotateFlipType) + { + EnsureNotDisposed(); + + FIBITMAP newDib = new FIBITMAP(); + uint bpp = FreeImage.GetBPP(dib); + + switch (rotateFlipType) + { + case RotateFlipType.RotateNoneFlipX: + + FreeImage.FlipHorizontal(dib); + break; + + case RotateFlipType.RotateNoneFlipY: + + FreeImage.FlipVertical(dib); + break; + + case RotateFlipType.RotateNoneFlipXY: + + FreeImage.FlipHorizontal(dib); + FreeImage.FlipVertical(dib); + break; + + case RotateFlipType.Rotate90FlipNone: + + newDib = (bpp == 4u) ? FreeImage.Rotate4bit(dib, 90d) : FreeImage.Rotate(dib, 90d); + break; + + case RotateFlipType.Rotate90FlipX: + + newDib = (bpp == 4u) ? FreeImage.Rotate4bit(dib, 90d) : FreeImage.Rotate(dib, 90d); + FreeImage.FlipHorizontal(newDib); + break; + + case RotateFlipType.Rotate90FlipY: + + newDib = (bpp == 4u) ? FreeImage.Rotate4bit(dib, 90d) : FreeImage.Rotate(dib, 90d); + FreeImage.FlipVertical(newDib); + break; + + case RotateFlipType.Rotate90FlipXY: + + newDib = (bpp == 4u) ? FreeImage.Rotate4bit(dib, 90d) : FreeImage.Rotate(dib, 90d); + FreeImage.FlipHorizontal(newDib); + FreeImage.FlipVertical(newDib); + break; + + case RotateFlipType.Rotate180FlipXY: + newDib = FreeImage.Clone(dib); + break; + } + ReplaceDib(newDib); + } + + /// + /// Copies the metadata from another . + /// + /// The bitmap to read the metadata from. + /// + /// is a null reference. + /// + public void CloneMetadataFrom(FreeImageBitmap bitmap) + { + if (bitmap == null) + { + throw new ArgumentNullException("bitmap"); + } + EnsureNotDisposed(); + bitmap.EnsureNotDisposed(); + FreeImage.CloneMetadata(dib, bitmap.dib); + } + + /// + /// Copies the metadata from another using + /// the provided options. + /// + /// The bitmap to read the metadata from. + /// Specifies the way the metadata is copied. + /// + /// is a null reference. + /// + public void CloneMetadataFrom(FreeImageBitmap bitmap, FREE_IMAGE_METADATA_COPY flags) + { + if (bitmap == null) + { + throw new ArgumentNullException("bitmap"); + } + EnsureNotDisposed(); + bitmap.EnsureNotDisposed(); + FreeImage.CloneMetadataEx(bitmap.dib, dib, flags); + } + + /// + /// Saves this to the specified file. + /// + /// A string that contains the name of the file to which + /// to save this . + /// is null or empty. + /// Saving the image failed. + public void Save(string filename) + { + Save(filename, FREE_IMAGE_FORMAT.FIF_UNKNOWN, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Saves this to the specified file in the specified format. + /// + /// A string that contains the name of the file to which + /// to save this . + /// An that specifies the format of the saved image. + /// is null or empty. + /// Saving the image failed. + public void Save(string filename, FREE_IMAGE_FORMAT format) + { + Save(filename, format, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Saves this to the specified file in the specified format + /// using the specified saving flags. + /// + /// A string that contains the name of the file to which + /// to save this . + /// An that specifies the format of the saved image. + /// Flags to enable or disable plugin-features. + /// is null or empty. + /// Saving the image failed. + public void Save(string filename, FREE_IMAGE_FORMAT format, FREE_IMAGE_SAVE_FLAGS flags) + { + EnsureNotDisposed(); + if (string.IsNullOrEmpty(filename)) + { + throw new ArgumentException("filename"); + } + if (!FreeImage.SaveEx(dib, filename, format, flags)) + { + throw new Exception("Unable to save bitmap"); + } + + saveInformation.filename = filename; + saveInformation.format = format; + saveInformation.saveFlags = flags; + } + + /// + /// Saves this to the specified stream in the specified format. + /// + /// The stream where this will be saved. + /// An that specifies the format of the saved image. + /// is a null reference. + /// Saving the image failed. + public void Save(Stream stream, FREE_IMAGE_FORMAT format) + { + Save(stream, format, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Saves this to the specified stream in the specified format + /// using the specified saving flags. + /// + /// The stream where this will be saved. + /// An that specifies the format of the saved image. + /// Flags to enable or disable plugin-features. + /// is a null reference. + /// Saving the image failed. + public void Save(Stream stream, FREE_IMAGE_FORMAT format, FREE_IMAGE_SAVE_FLAGS flags) + { + EnsureNotDisposed(); + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + if (!FreeImage.SaveToStream(dib, stream, format, flags)) + { + throw new Exception("Unable to save bitmap"); + } + + saveInformation.filename = null; + } + + /// + /// Adds a frame to the file specified in a previous call to the + /// method. + /// + /// + /// This instance has not been saved to a file using Save(...) before. + public void SaveAdd() + { + SaveAdd(this); + } + + /// + /// Adds a frame to the file specified in a previous call to the method. + /// + /// The position at which the frame should be inserted. + /// + /// This instance has not yet been saved to a file using the Save(...) method. + /// is out of range. + public void SaveAdd(int insertPosition) + { + SaveAdd(this, insertPosition); + } + + /// + /// Adds a frame to the file specified in a previous call to the method. + /// + /// A that contains the frame to add. + /// + /// This instance has not yet been saved to a file using the Save(...) method. + public void SaveAdd(FreeImageBitmap bitmap) + { + if (saveInformation.filename == null) + { + throw new InvalidOperationException("This operation requires a previous call of Save()."); + } + + SaveAdd( + saveInformation.filename, + bitmap, + saveInformation.format, + saveInformation.loadFlags, + saveInformation.saveFlags); + } + + /// + /// Adds a frame to the file specified in a previous call to the method. + /// + /// A that contains the frame to add. + /// The position at which the frame should be inserted. + /// + /// This instance has not yet been saved to a file using the Save(...) method. + /// is out of range. + public void SaveAdd(FreeImageBitmap bitmap, int insertPosition) + { + if (saveInformation.filename == null) + { + throw new InvalidOperationException("This operation requires a previous call of Save()."); + } + + SaveAdd( + saveInformation.filename, + bitmap, + insertPosition, + saveInformation.format, + saveInformation.loadFlags, + saveInformation.saveFlags); + } + + /// + /// Adds a frame to the file specified. + /// + /// File to add this frame to. + /// is a null reference. + /// does not exist. + /// Saving the image has failed. + public void SaveAdd(string filename) + { + SaveAdd( + filename, + this, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Adds a frame to the file specified. + /// + /// File to add this frame to. + /// The position at which the frame should be inserted. + /// is a null reference. + /// does not exist. + /// Saving the image has failed. + /// is out of range. + public void SaveAdd(string filename, int insertPosition) + { + SaveAdd( + filename, + this, + insertPosition, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Adds a frame to the file specified using the specified parameters. + /// + /// File to add this frame to. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// Flags to enable or disable plugin-features. + /// is a null reference. + /// does not exist. + /// Saving the image has failed. + public void SaveAdd( + string filename, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS loadFlags, + FREE_IMAGE_SAVE_FLAGS saveFlags) + { + SaveAdd( + filename, + this, + format, + loadFlags, + saveFlags); + } + + /// + /// Adds a frame to the file specified using the specified parameters. + /// + /// File to add this frame to. + /// The position at which the frame should be inserted. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// Flags to enable or disable plugin-features. + /// is a null reference. + /// does not exist. + /// Saving the image has failed. + /// is out of range. + public void SaveAdd( + string filename, + int insertPosition, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS loadFlags, + FREE_IMAGE_SAVE_FLAGS saveFlags) + { + SaveAdd( + filename, + this, + insertPosition, + format, + loadFlags, + saveFlags); + } + + /// + /// Selects the frame specified by the index. + /// + /// The index of the active frame. + /// + /// is out of range. + /// The operation failed. + /// The source of the bitmap is not available. + /// + public void SelectActiveFrame(int frameIndex) + { + EnsureNotDisposed(); + if ((frameIndex < 0) || (frameIndex >= frameCount)) + { + throw new ArgumentOutOfRangeException("frameIndex"); + } + + if (frameIndex != this.frameIndex) + { + if (stream == null) + { + throw new InvalidOperationException("No source available."); + } + + FREE_IMAGE_FORMAT format = originalFormat; + FIMULTIBITMAP mdib = FreeImage.OpenMultiBitmapFromStream(stream, ref format, saveInformation.loadFlags); + if (mdib.IsNull) + throw new Exception(ErrorLoadingBitmap); + + try + { + if (frameIndex >= FreeImage.GetPageCount(mdib)) + { + throw new ArgumentOutOfRangeException("frameIndex"); + } + + FIBITMAP newDib = FreeImage.LockPage(mdib, frameIndex); + if (newDib.IsNull) + { + throw new Exception(ErrorLoadingFrame); + } + + try + { + FIBITMAP clone = FreeImage.Clone(newDib); + if (clone.IsNull) + { + throw new Exception(ErrorCreatingBitmap); + } + ReplaceDib(clone); + } + finally + { + if (!newDib.IsNull) + { + FreeImage.UnlockPage(mdib, newDib, false); + } + } + } + finally + { + if (!FreeImage.CloseMultiBitmapEx(ref mdib)) + { + throw new Exception(ErrorUnloadBitmap); + } + } + + this.frameIndex = frameIndex; + } + } + + /// + /// Creates a GDI bitmap object from this . + /// + /// A handle to the GDI bitmap object that this method creates. + public IntPtr GetHbitmap() + { + EnsureNotDisposed(); + return FreeImage.GetHbitmap(dib, IntPtr.Zero, false); + } + + /// + /// Creates a GDI bitmap object from this . + /// + /// A structure that specifies the background color. + /// This parameter is ignored if the bitmap is totally opaque. + /// A handle to the GDI bitmap object that this method creates. + public IntPtr GetHbitmap(Color background) + { + EnsureNotDisposed(); + using (FreeImageBitmap temp = new FreeImageBitmap(this)) + { + temp.BackgroundColor = background; + return temp.GetHbitmap(); + } + } + + /// + /// Returns the handle to an icon. + /// + /// A Windows handle to an icon with the same image as this . + public IntPtr GetHicon() + { + EnsureNotDisposed(); + using (Bitmap bitmap = FreeImage.GetBitmap(dib, true)) + { + return bitmap.GetHicon(); + } + } + + /// + /// Creates a GDI bitmap object from this with the same + /// color depth as the primary device. + /// + /// A handle to the GDI bitmap object that this method creates. + public IntPtr GetHbitmapForDevice() + { + EnsureNotDisposed(); + return FreeImage.GetBitmapForDevice(dib, IntPtr.Zero, false); + } + + /// + /// Gets the of the specified pixel in this . + /// + /// The x-coordinate of the pixel to retrieve. + /// The y-coordinate of the pixel to retrieve. + /// A structure that represents the color of the specified pixel. + /// The operation failed. + /// The type of this bitmap is not supported. + public unsafe Color GetPixel(int x, int y) + { + EnsureNotDisposed(); + if (FreeImage.GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) + { + if (ColorDepth == 16 || ColorDepth == 24 || ColorDepth == 32) + { + RGBQUAD rgbq; + if (!FreeImage.GetPixelColor(dib, (uint)x, (uint)y, out rgbq)) + { + throw new Exception("FreeImage.GetPixelColor() failed"); + } + return rgbq.Color; + } + else if (ColorDepth == 1 || ColorDepth == 4 || ColorDepth == 8) + { + byte index; + if (!FreeImage.GetPixelIndex(dib, (uint)x, (uint)y, out index)) + { + throw new Exception("FreeImage.GetPixelIndex() failed"); + } + RGBQUAD* palette = (RGBQUAD*)FreeImage.GetPalette(dib); + return palette[index].Color; + } + } + throw new NotSupportedException("The type of the image is not supported"); + } + + /// + /// Makes the default transparent color transparent for this . + /// + public void MakeTransparent() + { + EnsureNotDisposed(); + MakeTransparent(Color.Transparent); + } + + /// + /// Makes the specified color transparent for this . + /// + /// The structure that represents + /// the color to make transparent. + /// + /// This method is not implemented. + public void MakeTransparent(Color transparentColor) + { + EnsureNotDisposed(); + throw new System.NotImplementedException(); + } + + /// + /// Sets the of the specified pixel in this . + /// + /// The x-coordinate of the pixel to set. + /// The y-coordinate of the pixel to set. + /// A structure that represents the color + /// to assign to the specified pixel. + /// The operation failed. + /// The type of this bitmap is not supported. + public unsafe void SetPixel(int x, int y, Color color) + { + EnsureNotDisposed(); + if (FreeImage.GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) + { + if (ColorDepth == 16 || ColorDepth == 24 || ColorDepth == 32) + { + RGBQUAD rgbq = color; + if (!FreeImage.SetPixelColor(dib, (uint)x, (uint)y, ref rgbq)) + { + throw new Exception("FreeImage.SetPixelColor() failed"); + } + return; + } + else if (ColorDepth == 1 || ColorDepth == 4 || ColorDepth == 8) + { + uint colorsUsed = FreeImage.GetColorsUsed(dib); + RGBQUAD* palette = (RGBQUAD*)FreeImage.GetPalette(dib); + for (int i = 0; i < colorsUsed; i++) + { + if (palette[i].Color == color) + { + byte index = (byte)i; + if (!FreeImage.SetPixelIndex(dib, (uint)x, (uint)y, ref index)) + { + throw new Exception("FreeImage.SetPixelIndex() failed"); + } + return; + } + } + throw new ArgumentOutOfRangeException("color"); + } + } + throw new NotSupportedException("The type of the image is not supported"); + } + + /// + /// Sets the resolution for this . + /// + /// The horizontal resolution, in dots per inch, of this . + /// The vertical resolution, in dots per inch, of this . + public void SetResolution(float xDpi, float yDpi) + { + EnsureNotDisposed(); + FreeImage.SetResolutionX(dib, (uint)xDpi); + FreeImage.SetResolutionY(dib, (uint)yDpi); + } + + /// + /// This function is not yet implemented. + /// + /// + /// This method is not implemented. + public BitmapData LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format) + { + throw new NotImplementedException(); + } + + /// + /// This function is not yet implemented. + /// + /// + /// This method is not implemented. + public BitmapData LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format, BitmapData bitmapData) + { + throw new NotImplementedException(); + } + + /// + /// This function is not yet implemented. + /// + /// + /// This method is not implemented. + public void UnlockBits(BitmapData bitmapdata) + { + throw new NotImplementedException(); + } + + /// + /// Converts this into a different color depth. + /// The parameter specifies color depth, greyscale conversion + /// and palette reorder. + /// Adding the flag + /// will first perform a convesion to greyscale. This can be done with any target + /// color depth. + /// Adding the flag + /// will allow the algorithm to reorder the palette. This operation will not be performed to + /// non-greyscale images to prevent data loss by mistake. + /// + /// A bitfield containing information about the conversion + /// to perform. + /// Returns true on success, false on failure. + public bool ConvertColorDepth(FREE_IMAGE_COLOR_DEPTH bpp) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.ConvertColorDepth(dib, bpp, false)); + } + + /// + /// Converts this to + /// initializing a new instance. + /// In case source and destination type are the same, the operation fails. + /// An error message can be catched using the 'Message' event. + /// + /// Destination type. + /// True to scale linear, else false. + /// Returns true on success, false on failure. + public bool ConvertType(FREE_IMAGE_TYPE type, bool scaleLinear) + { + EnsureNotDisposed(); + return (ImageType == type) ? false : ReplaceDib(FreeImage.ConvertToType(dib, type, scaleLinear)); + } + + /// + /// Converts this to . + /// In case source and destination type are the same, the operation fails. + /// An error message can be catched using the 'Message' event. + /// + /// Destination type. + /// True to scale linear, else false. + /// The converted instance. + public FreeImageBitmap GetTypeConvertedInstance(FREE_IMAGE_TYPE type, bool scaleLinear) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + if (ImageType != type) + { + FIBITMAP newDib = FreeImage.ConvertToType(dib, type, scaleLinear); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + } + return result; + } + + /// + /// Converts this into a different color depth initializing + /// a new instance. + /// The parameter specifies color depth, greyscale conversion + /// and palette reorder. + /// Adding the flag will + /// first perform a convesion to greyscale. This can be done with any target color depth. + /// Adding the flag will + /// allow the algorithm to reorder the palette. This operation will not be performed to + /// non-greyscale images to prevent data loss by mistake. + /// + /// A bitfield containing information about the conversion + /// to perform. + /// The converted instance. + public FreeImageBitmap GetColorConvertedInstance(FREE_IMAGE_COLOR_DEPTH bpp) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.ConvertColorDepth(dib, bpp, false); + if (newDib == dib) + { + newDib = FreeImage.Clone(dib); + } + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Rescales this to the specified size using the + /// specified filter. + /// + /// The Size structure that represent the + /// size of the new . + /// Filter to use for resizing. + /// Returns true on success, false on failure. + public bool Rescale(Size newSize, FREE_IMAGE_FILTER filter) + { + return Rescale(newSize.Width, newSize.Height, filter); + } + + /// + /// Rescales this to the specified size using the + /// specified filter. + /// + /// Width of the new . + /// Height of the new . + /// Filter to use for resizing. + /// Returns true on success, false on failure. + public bool Rescale(int width, int height, FREE_IMAGE_FILTER filter) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.Rescale(dib, width, height, filter)); + } + + /// + /// Rescales this to the specified size using the + /// specified filter initializing a new instance. + /// + /// The Size structure that represent the + /// size of the new . + /// Filter to use for resizing. + /// The rescaled instance. + public FreeImageBitmap GetScaledInstance(Size newSize, FREE_IMAGE_FILTER filter) + { + return GetScaledInstance(newSize.Width, newSize.Height, filter); + } + + /// + /// Rescales this to the specified size using the + /// specified filter initializing a new instance. + /// + /// Width of the new . + /// Height of the new . + /// Filter to use for resizing. + /// The rescaled instance. + public FreeImageBitmap GetScaledInstance(int width, int height, FREE_IMAGE_FILTER filter) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.Rescale(dib, width, height, filter); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Enlarges or shrinks this selectively per side and fills + /// newly added areas with the specified background color. + /// See for further details. + /// + /// The type of the specified color. + /// The number of pixels, the image should be enlarged on its left side. + /// Negative values shrink the image on its left side. + /// The number of pixels, the image should be enlarged on its top side. + /// Negative values shrink the image on its top side. + /// The number of pixels, the image should be enlarged on its right side. + /// Negative values shrink the image on its right side. + /// The number of pixels, the image should be enlarged on its bottom side. + /// Negative values shrink the image on its bottom side. + /// The color, the enlarged sides of the image should be filled with. + /// true on success, false on failure. + public bool EnlargeCanvas(int left, int top, int right, int bottom, T? color) where T : struct + { + return EnlargeCanvas(left, top, right, bottom, color, FREE_IMAGE_COLOR_OPTIONS.FICO_DEFAULT); + } + + /// + /// Enlarges or shrinks this selectively per side and fills + /// newly added areas with the specified background color. + /// See for further details. + /// + /// The type of the specified color. + /// The number of pixels, the image should be enlarged on its left side. + /// Negative values shrink the image on its left side. + /// The number of pixels, the image should be enlarged on its top side. + /// Negative values shrink the image on its top side. + /// The number of pixels, the image should be enlarged on its right side. + /// Negative values shrink the image on its right side. + /// The number of pixels, the image should be enlarged on its bottom side. + /// Negative values shrink the image on its bottom side. + /// The color, the enlarged sides of the image should be filled with. + /// Options that affect the color search process for palletized images. + /// true on success, false on failure. + public bool EnlargeCanvas(int left, int top, int right, int bottom, + T? color, FREE_IMAGE_COLOR_OPTIONS options) where T : struct + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.EnlargeCanvas(dib, left, top, right, bottom, color, options)); + } + + /// + /// Enlarges or shrinks this selectively per side and fills + /// newly added areas with the specified background color returning a new instance. + /// See for further details. + /// + /// The type of the specified color. + /// The number of pixels, the image should be enlarged on its left side. + /// Negative values shrink the image on its left side. + /// The number of pixels, the image should be enlarged on its top side. + /// Negative values shrink the image on its top side. + /// The number of pixels, the image should be enlarged on its right side. + /// Negative values shrink the image on its right side. + /// The number of pixels, the image should be enlarged on its bottom side. + /// Negative values shrink the image on its bottom side. + /// The color, the enlarged sides of the image should be filled with. + /// The enlarged instance. + public FreeImageBitmap GetEnlargedInstance(int left, int top, int right, int bottom, + T? color) where T : struct + { + return GetEnlargedInstance(left, top, right, bottom, color, FREE_IMAGE_COLOR_OPTIONS.FICO_DEFAULT); + } + + /// + /// Enlarges or shrinks this selectively per side and fills + /// newly added areas with the specified background color returning a new instance. + /// See for further details. + /// + /// The type of the specified color. + /// The number of pixels, the image should be enlarged on its left side. + /// Negative values shrink the image on its left side. + /// The number of pixels, the image should be enlarged on its top side. + /// Negative values shrink the image on its top side. + /// The number of pixels, the image should be enlarged on its right side. + /// Negative values shrink the image on its right side. + /// The number of pixels, the image should be enlarged on its bottom side. + /// Negative values shrink the image on its bottom side. + /// The color, the enlarged sides of the image should be filled with. + /// Options that affect the color search process for palletized images. + /// The enlarged instance. + public FreeImageBitmap GetEnlargedInstance(int left, int top, int right, int bottom, + T? color, FREE_IMAGE_COLOR_OPTIONS options) where T : struct + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.EnlargeCanvas(dib, left, top, right, bottom, color, options); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Quantizes this from 24 bit to 8bit creating a new + /// palette with the specified using the specified + /// . + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// Returns true on success, false on failure. + public bool Quantize(FREE_IMAGE_QUANTIZE algorithm, int paletteSize) + { + return Quantize(algorithm, paletteSize, 0, (RGBQUAD[])null); + } + + /// + /// Quantizes this from 24 bit to 8bit creating a new + /// palette with the specified using the specified + /// and the specified + /// palette up to the + /// specified length. + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// The provided palette. + /// Returns true on success, false on failure. + public bool Quantize(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, Palette reservePalette) + { + return Quantize(algorithm, paletteSize, reservePalette.Length, reservePalette.Data); + } + + /// + /// Quantizes this from 24 bit to 8bit creating a new + /// palette with the specified using the specified + /// and the specified + /// palette up to the + /// specified length. + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// Size of the provided palette of ReservePalette. + /// The provided palette. + /// Returns true on success, false on failure. + public bool Quantize(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, int reserveSize, Palette reservePalette) + { + return Quantize(algorithm, paletteSize, reserveSize, reservePalette.Data); + } + + /// + /// Quantizes this from 24 bit to 8bit creating a new + /// palette with the specified using the specified + /// and the specified + /// palette up to the + /// specified length. + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// Size of the provided palette of ReservePalette. + /// The provided palette. + /// Returns true on success, false on failure. + public bool Quantize(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, int reserveSize, RGBQUAD[] reservePalette) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.ColorQuantizeEx(dib, algorithm, paletteSize, reserveSize, reservePalette)); + } + + /// + /// Quantizes this from 24 bit, using the specified + /// initializing a new 8 bit instance with the + /// specified . + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// The quantized instance. + public FreeImageBitmap GetQuantizedInstance(FREE_IMAGE_QUANTIZE algorithm, int paletteSize) + { + return GetQuantizedInstance(algorithm, paletteSize, 0, (RGBQUAD[])null); + } + + /// + /// Quantizes this from 24 bit, using the specified + /// and palette + /// initializing a new 8 bit instance with the specified . + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// The provided palette. + /// The quantized instance. + public FreeImageBitmap GetQuantizedInstance(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, Palette reservePalette) + { + return GetQuantizedInstance(algorithm, paletteSize, reservePalette.Length, reservePalette); + } + + /// + /// Quantizes this from 24 bit, using the specified + /// and up to + /// entries from palette initializing + /// a new 8 bit instance with the specified . + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// Size of the provided palette. + /// The provided palette. + /// The quantized instance. + public FreeImageBitmap GetQuantizedInstance(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, int reserveSize, Palette reservePalette) + { + return GetQuantizedInstance(algorithm, paletteSize, reserveSize, reservePalette.Data); + } + + /// + /// Quantizes this from 24 bit, using the specified + /// and up to + /// entries from palette initializing + /// a new 8 bit instance with the specified . + /// + /// The color reduction algorithm to be used. + /// Size of the desired output palette. + /// Size of the provided palette. + /// The provided palette. + /// The quantized instance. + public FreeImageBitmap GetQuantizedInstance(FREE_IMAGE_QUANTIZE algorithm, int paletteSize, int reserveSize, RGBQUAD[] reservePalette) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.ColorQuantizeEx(dib, algorithm, paletteSize, reserveSize, reservePalette); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Converts a High Dynamic Range image to a 24-bit RGB image using a global + /// operator based on logarithmic compression of luminance values, imitating + /// the human response to light. + /// + /// A gamma correction that is applied after the tone mapping. + /// A value of 1 means no correction. + /// Scale factor allowing to adjust the brightness of the output image. + /// Returns true on success, false on failure. + public bool TmoDrago03(double gamma, double exposure) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.TmoDrago03(dib, gamma, exposure)); + } + + /// + /// Converts a High Dynamic Range image to a 24-bit RGB image using a global operator inspired + /// by photoreceptor physiology of the human visual system. + /// + /// Controls the overall image intensity in the range [-8, 8]. + /// Controls the overall image contrast in the range [0.3, 1.0[. + /// Returns true on success, false on failure. + public bool TmoReinhard05(double intensity, double contrast) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.TmoReinhard05(dib, intensity, contrast)); + } + + /// + /// Apply the Gradient Domain High Dynamic Range Compression to a RGBF image and convert to 24-bit RGB. + /// + /// Color saturation (s parameter in the paper) in [0.4..0.6] + /// Atenuation factor (beta parameter in the paper) in [0.8..0.9] + /// Returns true on success, false on failure. + public bool TmoFattal02(double color_saturation, double attenuation) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.TmoFattal02(dib, color_saturation, attenuation)); + } + + /// + /// This method rotates a 1-, 4-, 8-bit greyscale or a 24-, 32-bit color image by means of 3 shears. + /// For 1- and 4-bit images, rotation is limited to angles whose value is an integer + /// multiple of 90. + /// + /// The angle of rotation. + /// Returns true on success, false on failure. + public bool Rotate(double angle) + { + EnsureNotDisposed(); + bool result = false; + if (ColorDepth == 4) + { + result = ReplaceDib(FreeImage.Rotate4bit(dib, angle)); + } + else + { + result = ReplaceDib(FreeImage.Rotate(dib, angle)); + } + return result; + } + + /// + /// This method rotates a 1-, 4-, 8-bit greyscale or a 24-, 32-bit color image by means of 3 shears. + /// For 1- and 4-bit images, rotation is limited to angles whose value is an integer + /// multiple of 90. + /// + /// The type of the color to use as background. + /// The angle of rotation. + /// The color used used to fill the bitmap's background. + /// Returns true on success, false on failure. + public bool Rotate(double angle, T? backgroundColor) where T : struct + { + EnsureNotDisposed(); + bool result = false; + if (ColorDepth == 4) + { + result = ReplaceDib(FreeImage.Rotate4bit(dib, angle)); + } + else + { + result = ReplaceDib(FreeImage.Rotate(dib, angle, backgroundColor)); + } + return result; + } + + /// + /// Rotates this by the specified angle initializing a new instance. + /// For 1- and 4-bit images, rotation is limited to angles whose value is an integer + /// multiple of 90. + /// + /// The type of the color to use as background. + /// The angle of rotation. + /// The color used used to fill the bitmap's background. + /// The rotated instance. + public FreeImageBitmap GetRotatedInstance(double angle, T? backgroundColor) where T : struct + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib; + if (ColorDepth == 4) + { + newDib = FreeImage.Rotate4bit(dib, angle); + } + else + { + newDib = FreeImage.Rotate(dib, angle, backgroundColor); + } + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Rotates this by the specified angle initializing a new instance. + /// For 1- and 4-bit images, rotation is limited to angles whose value is an integer + /// multiple of 90. + /// + /// The angle of rotation. + /// The rotated instance. + public FreeImageBitmap GetRotatedInstance(double angle) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib; + if (ColorDepth == 4) + { + newDib = FreeImage.Rotate4bit(dib, angle); + } + else + { + newDib = FreeImage.Rotate(dib, angle); + } + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// This method performs a rotation and / or translation of an 8-bit greyscale, + /// 24- or 32-bit image, using a 3rd order (cubic) B-Spline. + /// + /// The angle of rotation. + /// Horizontal image translation. + /// Vertical image translation. + /// Rotation center x-coordinate. + /// Rotation center y-coordinate. + /// When true the irrelevant part of the image is set to a black color, + /// otherwise, a mirroring technique is used to fill irrelevant pixels. + /// Returns true on success, false on failure. + public bool Rotate(double angle, double xShift, double yShift, + double xOrigin, double yOrigin, bool useMask) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.RotateEx(dib, angle, xShift, yShift, xOrigin, yOrigin, useMask)); + } + + /// + /// This method performs a rotation and / or translation of an 8-bit greyscale, + /// 24- or 32-bit image, using a 3rd order (cubic) B-Spline initializing a new instance. + /// + /// The angle of rotation. + /// Horizontal image translation. + /// Vertical image translation. + /// Rotation center x-coordinate. + /// Rotation center y-coordinate. + /// When true the irrelevant part of the image is set to a black color, + /// otherwise, a mirroring technique is used to fill irrelevant pixels. + /// The rotated instance. + public FreeImageBitmap GetRotatedInstance(double angle, double xShift, double yShift, + double xOrigin, double yOrigin, bool useMask) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.RotateEx( + dib, angle, xShift, yShift, xOrigin, yOrigin, useMask); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Perfoms an histogram transformation on a 8-, 24- or 32-bit image. + /// + /// The lookup table (LUT). + /// It's size is assumed to be 256 in length. + /// The color channel to be transformed. + /// Returns true on success, false on failure. + public bool AdjustCurve(byte[] lookUpTable, FREE_IMAGE_COLOR_CHANNEL channel) + { + EnsureNotDisposed(); + return FreeImage.AdjustCurve(dib, lookUpTable, channel); + } + + /// + /// Performs gamma correction on a 8-, 24- or 32-bit image. + /// + /// The parameter represents the gamma value to use (gamma > 0). + /// A value of 1.0 leaves the image alone, less than one darkens it, and greater than one lightens it. + /// Returns true on success, false on failure. + public bool AdjustGamma(double gamma) + { + EnsureNotDisposed(); + return FreeImage.AdjustGamma(dib, gamma); + } + + /// + /// Adjusts the brightness of a 8-, 24- or 32-bit image by a certain amount. + /// + /// A value 0 means no change, + /// less than 0 will make the image darker and greater than 0 will make the image brighter. + /// Returns true on success, false on failure. + public bool AdjustBrightness(double percentage) + { + EnsureNotDisposed(); + return FreeImage.AdjustBrightness(dib, percentage); + } + + /// + /// Adjusts the contrast of a 8-, 24- or 32-bit image by a certain amount. + /// + /// A value 0 means no change, + /// less than 0 will decrease the contrast and greater than 0 will increase the contrast of the image. + /// Returns true on success, false on failure. + public bool AdjustContrast(double percentage) + { + EnsureNotDisposed(); + return FreeImage.AdjustContrast(dib, percentage); + } + + /// + /// Inverts each pixel data. + /// + /// Returns true on success, false on failure. + public bool Invert() + { + EnsureNotDisposed(); + return FreeImage.Invert(dib); + } + + /// + /// Computes the image histogram. + /// + /// Channel to compute from. + /// Array of integers containing the histogram. + /// Returns true on success, false on failure. + public bool GetHistogram(FREE_IMAGE_COLOR_CHANNEL channel, out int[] histogram) + { + EnsureNotDisposed(); + histogram = new int[256]; + return FreeImage.GetHistogram(dib, histogram, channel); + } + + /// + /// Retrieves the red, green, blue or alpha channel of a 24- or 32-bit image. + /// + /// The color channel to extract. + /// The color channel in a new instance. + public FreeImageBitmap GetChannel(FREE_IMAGE_COLOR_CHANNEL channel) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.GetChannel(dib, channel); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Insert a 8-bit dib into a 24- or 32-bit image. + /// Both images must have to same width and height. + /// + /// The to insert. + /// The color channel to replace. + /// Returns true on success, false on failure. + public bool SetChannel(FreeImageBitmap bitmap, FREE_IMAGE_COLOR_CHANNEL channel) + { + EnsureNotDisposed(); + bitmap.EnsureNotDisposed(); + return FreeImage.SetChannel(dib, bitmap.dib, channel); + } + + /// + /// Retrieves the real part, imaginary part, magnitude or phase of a complex image. + /// + /// The color channel to extract. + /// The color channel in a new instance. + public FreeImageBitmap GetComplexChannel(FREE_IMAGE_COLOR_CHANNEL channel) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.GetComplexChannel(dib, channel); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Set the real or imaginary part of a complex image. + /// Both images must have to same width and height. + /// + /// The to insert. + /// The color channel to replace. + /// Returns true on success, false on failure. + public bool SetComplexChannel(FreeImageBitmap bitmap, FREE_IMAGE_COLOR_CHANNEL channel) + { + EnsureNotDisposed(); + bitmap.EnsureNotDisposed(); + return FreeImage.SetComplexChannel(dib, bitmap.dib, channel); + } + + /// + /// Copy a sub part of this . + /// + /// The subpart to copy. + /// The sub part in a new instance. + public FreeImageBitmap Copy(Rectangle rect) + { + EnsureNotDisposed(); + return Copy(rect.Left, rect.Top, rect.Right, rect.Bottom); + } + + /// + /// Copy a sub part of this . + /// + /// Specifies the left position of the cropped rectangle. + /// Specifies the top position of the cropped rectangle. + /// Specifies the right position of the cropped rectangle. + /// Specifies the bottom position of the cropped rectangle. + /// The sub part in a new instance. + public FreeImageBitmap Copy(int left, int top, int right, int bottom) + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.Copy(dib, left, top, right, bottom); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Alpha blend or combine a sub part image with this . + /// The bit depth of must be greater than or equal to the bit depth this instance. + /// + /// The to paste into this instance. + /// Specifies the left position of the sub image. + /// Specifies the top position of the sub image. + /// alpha blend factor. + /// The source and destination images are alpha blended if alpha=0..255. + /// If alpha > 255, then the source image is combined to the destination image. + /// Returns true on success, false on failure. + public bool Paste(FreeImageBitmap bitmap, int left, int top, int alpha) + { + EnsureNotDisposed(); + bitmap.EnsureNotDisposed(); + return FreeImage.Paste(dib, bitmap.dib, left, top, alpha); + } + + /// + /// Alpha blend or combine a sub part image with tthis . + /// The bit depth of must be greater than or equal to the bit depth this instance. + /// + /// The to paste into this instance. + /// Specifies the position of the sub image. + /// alpha blend factor. + /// The source and destination images are alpha blended if alpha=0..255. + /// If alpha > 255, then the source image is combined to the destination image. + /// Returns true on success, false on failure. + public bool Paste(FreeImageBitmap bitmap, Point point, int alpha) + { + EnsureNotDisposed(); + return Paste(bitmap, point.X, point.Y, alpha); + } + + /// + /// This method composite a transparent foreground image against a single background color or + /// against a background image. + /// In case is false and + /// and + /// are null, a checkerboard will be used as background. + /// + /// When true the background of this instance is used + /// if it contains one. + /// Backgroundcolor used in case is false + /// and is not null. + /// Background used in case + /// is false and is a null reference. + /// Returns true on success, false on failure. + public bool Composite(bool useBitmapBackground, Color? applicationBackground, FreeImageBitmap bitmapBackGround) + { + EnsureNotDisposed(); + bitmapBackGround.EnsureNotDisposed(); + RGBQUAD? rgb = applicationBackground; + return ReplaceDib( + FreeImage.Composite( + dib, + useBitmapBackground, + rgb.HasValue ? new RGBQUAD[] { rgb.Value } : null, + bitmapBackGround.dib)); + } + + /// + /// Applies the alpha value of each pixel to its color components. + /// The aplha value stays unchanged. + /// Only works with 32-bits color depth. + /// + /// Returns true on success, false on failure. + public bool PreMultiplyWithAlpha() + { + EnsureNotDisposed(); + return FreeImage.PreMultiplyWithAlpha(dib); + } + + /// + /// Solves a Poisson equation, remap result pixels to [0..1] and returns the solution. + /// + /// Number of cycles in the multigrid algorithm (usually 2 or 3) + /// Returns true on success, false on failure. + public bool MultigridPoissonSolver(int ncycle) + { + EnsureNotDisposed(); + return ReplaceDib(FreeImage.MultigridPoissonSolver(dib, ncycle)); + } + + /// + /// Adjusts an image's brightness, contrast and gamma as well as it may + /// optionally invert the image within a single operation. + /// + /// Percentage brightness value where -100 <= brightness <= 100. + /// A value of 0 means no change, less than 0 will make the image darker and greater + /// than 0 will make the image brighter. + /// Percentage contrast value where -100 <= contrast <= 100. + /// A value of 0 means no change, less than 0 will decrease the contrast + /// and greater than 0 will increase the contrast of the image. + /// Gamma value to be used for gamma correction. + /// A value of 1.0 leaves the image alone, less than one darkens it, + /// and greater than one lightens it. + /// This parameter must not be zero or smaller than zero. + /// If so, it will be ignored and no gamma correction will be performed on the image. + /// If set to true, the image will be inverted. + /// Returns true on success, false on failure. + public bool AdjustColors(double brightness, double contrast, double gamma, bool invert) + { + EnsureNotDisposed(); + return FreeImage.AdjustColors(dib, brightness, contrast, gamma, invert); + } + + /// + /// Applies color mapping for one or several colors on a 1-, 4- or 8-bit + /// palletized or a 16-, 24- or 32-bit high color image. + /// + /// Array of colors to be used as the mapping source. + /// Array of colors to be used as the mapping destination. + /// If true, 32-bit images and colors are treated as 24-bit. + /// If true, source and destination colors are swapped, that is, + /// each destination color is also mapped to the corresponding source color. + /// The total number of pixels changed. + /// + /// or is a null reference. + /// + /// + /// has a different length than . + /// + public uint ApplyColorMapping(RGBQUAD[] srccolors, RGBQUAD[] dstcolors, bool ignore_alpha, bool swap) + { + EnsureNotDisposed(); + if (srccolors == null) + { + throw new ArgumentNullException("srccolors"); + } + if (dstcolors == null) + { + throw new ArgumentNullException("dstcolors"); + } + if (srccolors.Length != dstcolors.Length) + { + throw new ArgumentException("srccolors and dstcolors must have the same length."); + } + return FreeImage.ApplyColorMapping(dib, srccolors, dstcolors, (uint)srccolors.Length, ignore_alpha, swap); + } + + /// + /// Swaps two specified colors on a 1-, 4- or 8-bit palletized + /// or a 16-, 24- or 32-bit high color image. + /// + /// One of the two colors to be swapped. + /// The other of the two colors to be swapped. + /// If true, 32-bit images and colors are treated as 24-bit. + /// The total number of pixels changed. + public uint SwapColors(RGBQUAD color_a, RGBQUAD color_b, bool ignore_alpha) + { + EnsureNotDisposed(); + return FreeImage.SwapColors(dib, ref color_a, ref color_b, ignore_alpha); + } + + /// + /// Applies palette index mapping for one or several indices + /// on a 1-, 4- or 8-bit palletized image. + /// + /// Array of palette indices to be used as the mapping source. + /// Array of palette indices to be used as the mapping destination. + /// The number of palette indices to be mapped. This is the size of both + /// srcindices and dstindices + /// If true, source and destination palette indices are swapped, that is, + /// each destination index is also mapped to the corresponding source index. + /// The total number of pixels changed. + /// + /// or is a null reference. + /// + /// + /// has a different length than . + /// + public uint ApplyPaletteIndexMapping(byte[] srcindices, byte[] dstindices, uint count, bool swap) + { + EnsureNotDisposed(); + if (srcindices == null) + { + throw new ArgumentNullException("srcindices"); + } + if (dstindices == null) + { + throw new ArgumentNullException("dstindices"); + } + if (srcindices.Length != dstindices.Length) + { + throw new ArgumentException("srcindices and dstindices must have the same length."); + } + return FreeImage.ApplyPaletteIndexMapping(dib, srcindices, dstindices, (uint)srcindices.Length, swap); + } + + /// + /// Swaps two specified palette indices on a 1-, 4- or 8-bit palletized image. + /// + /// One of the two palette indices to be swapped. + /// The other of the two palette indices to be swapped. + /// The total number of pixels changed. + public uint SwapPaletteIndices(byte index_a, byte index_b) + { + EnsureNotDisposed(); + return FreeImage.SwapPaletteIndices(dib, ref index_a, ref index_b); + } + + /// + /// Sets all pixels of this to the specified color. + /// See for further details. + /// + /// The type of the specified color. + /// The color to fill this with. + /// true on success, false on failure. + public bool FillBackground(T color) where T : struct + { + return FillBackground(color, FREE_IMAGE_COLOR_OPTIONS.FICO_DEFAULT); + } + + /// + /// Sets all pixels of this to the specified color. + /// See for further details. + /// + /// The type of the specified color. + /// The color to fill this with. + /// Options that affect the color search process for palletized images. + /// true on success, false on failure. + public bool FillBackground(T color, FREE_IMAGE_COLOR_OPTIONS options) where T : struct + { + EnsureNotDisposed(); + return FreeImage.FillBackground(dib, color, options); + } + + /// + /// Creates a new ICC-Profile. + /// + /// The data of the new ICC-Profile. + /// The new ICC-Profile of the bitmap. + /// is a null reference. + public FIICCPROFILE CreateICCProfile(byte[] data) + { + if (data == null) + { + throw new ArgumentNullException("data"); + } + return CreateICCProfile(data, data.Length); + } + + /// + /// Creates a new ICC-Profile. + /// + /// The data of the new ICC-Profile. + /// The number of bytes of to use. + /// The new ICC-Profile of the bitmap. + /// is null. + public FIICCPROFILE CreateICCProfile(byte[] data, int size) + { + EnsureNotDisposed(); + if (data == null) + { + throw new ArgumentNullException("data"); + } + return FreeImage.CreateICCProfileEx(dib, data, size); + } + + /// + /// Determines whether this and the specified instances are the same. + /// + /// The object to test. + /// true if this instance is the same + /// or if both are null references; otherwise, false. + public override bool Equals(object obj) + { + return ReferenceEquals(this, obj); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return dib.GetHashCode(); + } + + #endregion + + #region Static functions + + /// + /// Returns a value that indicates whether the pixel format for this contains alpha information. + /// + /// The to test. + /// true if pixfmt contains alpha information; otherwise, false. + public static bool IsAlphaPixelFormat(PixelFormat pixfmt) + { + return Bitmap.IsAlphaPixelFormat(pixfmt); + } + + /// + /// Returns a value that indicates whether the pixel format is 32 bits per pixel. + /// + /// The to test. + /// true if pixfmt is canonical; otherwise, false. + public static bool IsCanonicalPixelFormat(PixelFormat pixfmt) + { + return Bitmap.IsCanonicalPixelFormat(pixfmt); + } + + /// + /// Returns a value that indicates whether the pixel format is 64 bits per pixel. + /// + /// The enumeration to test. + /// true if pixfmt is extended; otherwise, false. + public static bool IsExtendedPixelFormat(PixelFormat pixfmt) + { + return Bitmap.IsExtendedPixelFormat(pixfmt); + } + + /// + /// Creates a from a Windows handle to an icon. + /// + /// A handle to an icon. + /// The that this method creates. + public static FreeImageBitmap FromHicon(IntPtr hicon) + { + using (Bitmap bitmap = Bitmap.FromHicon(hicon)) + { + return new FreeImageBitmap(bitmap); + } + } + + /// + /// Creates a from the specified Windows resource. + /// + /// A handle to an instance of the executable + /// file that contains the resource. + /// A string containing the name of the resource bitmap. + /// The that this method creates. + public static FreeImageBitmap FromResource(IntPtr hinstance, string bitmapName) + { + using (Bitmap bitmap = Bitmap.FromResource(hinstance, bitmapName)) + { + return new FreeImageBitmap(bitmap); + } + } + + /// + /// Creates a from the specified file. + /// + /// A string that contains the name of the file + /// from which to create the . + /// The this method creates. + public static FreeImageBitmap FromFile(string filename) + { + return new FreeImageBitmap(filename); + } + + /// + /// Creates a from the specified file + /// using embedded color management information in that file. + /// + /// A string that contains the + /// name of the file from which to create the . + /// Ignored. + /// The this method creates. + public static FreeImageBitmap FromFile(string filename, bool useEmbeddedColorManagement) + { + return new FreeImageBitmap(filename); + } + + /// + /// Creates a from a handle to a GDI bitmap. + /// + /// The GDI bitmap handle from which to create the . + /// The this method creates. + public static FreeImageBitmap FromHbitmap(IntPtr hbitmap) + { + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.CreateFromHbitmap(hbitmap, IntPtr.Zero); + if (!newDib.IsNull) + { + result = new FreeImageBitmap(newDib); + } + return result; + } + + /// + /// Creates a from a handle to a GDI bitmap and a handle to a GDI palette. + /// + /// The GDI bitmap handle from which to create the . + /// Ignored. + /// The this method creates. + public static FreeImageBitmap FromHbitmap(IntPtr hbitmap, IntPtr hpalette) + { + return FromHbitmap(hbitmap); + } + + /// + /// Frees a bitmap handle. + /// + /// Handle to a bitmap. + /// true on success, false on failure. + public static bool FreeHbitmap(IntPtr hbitmap) + { + return FreeImage.FreeHbitmap(hbitmap); + } + + /// + /// Creates a from the specified data stream. + /// + /// A that contains the data for this . + /// The this method creates. + public static FreeImageBitmap FromStream(Stream stream) + { + return new FreeImageBitmap(stream); + } + + /// + /// Creates a from the specified data stream. + /// + /// A that contains the data for this . + /// Ignored. + /// The this method creates. + public static FreeImageBitmap FromStream(Stream stream, bool useEmbeddedColorManagement) + { + return new FreeImageBitmap(stream); + } + + /// + /// Creates a from the specified data stream. + /// + /// A that contains the data for this . + /// Ignored. + /// Ignored. + /// The this method creates. + public static FreeImageBitmap FromStream(Stream stream, bool useEmbeddedColorManagement, bool validateImageData) + { + return new FreeImageBitmap(stream); + } + + /// + /// Returns the color depth, in number of bits per pixel, + /// of the specified pixel format. + /// + /// The member that specifies + /// the format for which to find the size. + /// The color depth of the specified pixel format. + public static int GetPixelFormatSize(PixelFormat pixfmt) + { + return Bitmap.GetPixelFormatSize(pixfmt); + } + + /// + /// Performs a lossless rotation or flipping on a JPEG file. + /// + /// Source file. + /// Destination file; can be the source file; will be overwritten. + /// The operation to apply. + /// To avoid lossy transformation, you can set the perfect parameter to true. + /// Returns true on success, false on failure. + public static bool JPEGTransform(string source, string destination, FREE_IMAGE_JPEG_OPERATION operation, bool perfect) + { + return FreeImage.JPEGTransform(source, destination, operation, perfect); + } + + /// + /// Performs a lossless crop on a JPEG file. + /// + /// Source filename. + /// Destination filename. + /// Specifies the cropped rectangle. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// + /// does not exist. + /// + public static bool JPEGCrop(string source, string destination, Rectangle rect) + { + if (source == null) + { + throw new ArgumentNullException("source"); + } + if (!File.Exists(source)) + { + throw new FileNotFoundException("source"); + } + if (destination == null) + { + throw new ArgumentNullException("destination"); + } + return JPEGCrop(source, destination, rect.Left, rect.Top, rect.Right, rect.Bottom); + } + + /// + /// Performs a lossless crop on a JPEG file. + /// + /// Source filename. + /// Destination filename. + /// Specifies the left position of the cropped rectangle. + /// Specifies the top position of the cropped rectangle. + /// Specifies the right position of the cropped rectangle. + /// Specifies the bottom position of the cropped rectangle. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// + /// does not exist. + /// + public static bool JPEGCrop(string source, string destination, int left, int top, int right, int bottom) + { + if (source == null) + { + throw new ArgumentNullException("source"); + } + if (!File.Exists(source)) + { + throw new FileNotFoundException("source"); + } + if (destination == null) + { + throw new ArgumentNullException("destination"); + } + return FreeImage.JPEGCrop(source, destination, left, top, right, bottom); + } + + /// + /// Converts a X11 color name into a corresponding RGB value. + /// + /// Name of the color to convert. + /// Red component. + /// Green component. + /// Blue component. + /// Returns true on success, false on failure. + /// is null. + public static bool LookupX11Color(string color, out byte red, out byte green, out byte blue) + { + if (color == null) + { + throw new ArgumentNullException("color"); + } + return FreeImage.LookupX11Color(color, out red, out green, out blue); + } + + /// + /// Converts a SVG color name into a corresponding RGB value. + /// + /// Name of the color to convert. + /// Red component. + /// Green component. + /// Blue component. + /// Returns true on success, false on failure. + /// is null. + public static bool LookupSVGColor(string color, out byte red, out byte green, out byte blue) + { + if (color == null) + { + throw new ArgumentNullException("color"); + } + return FreeImage.LookupSVGColor(color, out red, out green, out blue); + } + + /// + /// Creates a lookup table to be used with AdjustCurve() which + /// may adjusts brightness and contrast, correct gamma and invert the image with a + /// single call to AdjustCurve(). + /// + /// Output lookup table to be used with AdjustCurve(). + /// The size of is assumed to be 256. + /// Percentage brightness value where -100 <= brightness <= 100. + /// A value of 0 means no change, less than 0 will make the image darker and greater + /// than 0 will make the image brighter. + /// Percentage contrast value where -100 <= contrast <= 100. + /// A value of 0 means no change, less than 0 will decrease the contrast + /// and greater than 0 will increase the contrast of the image. + /// Gamma value to be used for gamma correction. + /// A value of 1.0 leaves the image alone, less than one darkens it, + /// and greater than one lightens it. + /// If set to true, the image will be inverted. + /// The number of adjustments applied to the resulting lookup table + /// compared to a blind lookup table. + /// is null. + /// is not 256. + public static int GetAdjustColorsLookupTable(byte[] lookUpTable, double brightness, double contrast, double gamma, bool invert) + { + if (lookUpTable == null) + { + throw new ArgumentNullException("lookUpTable"); + } + if (lookUpTable.Length != 256) + { + throw new ArgumentException("lookUpTable"); + } + return FreeImage.GetAdjustColorsLookupTable(lookUpTable, brightness, contrast, gamma, invert); + } + + /// + /// Adds a specified frame to the file specified using the specified parameters. + /// Use this method to save selected frames from an to a multiple-frame image. + /// + /// File to add this frame to. + /// A that contains the frame to add. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// Flags to enable or disable plugin-features. + /// + /// or is null. + /// + /// does not exist. + /// Saving the image failed. + public static void SaveAdd( + string filename, + FreeImageBitmap bitmap, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS loadFlags, + FREE_IMAGE_SAVE_FLAGS saveFlags) + { + if (filename == null) + { + throw new ArgumentNullException("filename"); + } + if (!File.Exists(filename)) + { + throw new FileNotFoundException("filename"); + } + if (bitmap == null) + { + throw new ArgumentNullException("bitmap"); + } + bitmap.EnsureNotDisposed(); + + FIBITMAP dib = bitmap.dib; + if (dib.IsNull) + throw new ArgumentNullException("bitmap"); + + FIMULTIBITMAP mpBitmap = + FreeImage.OpenMultiBitmapEx(filename, ref format, loadFlags, false, false, true); + + if (mpBitmap.IsNull) + throw new Exception(ErrorLoadingBitmap); + + FreeImage.AppendPage(mpBitmap, bitmap.dib); + + if (!FreeImage.CloseMultiBitmap(mpBitmap, saveFlags)) + throw new Exception(ErrorUnloadBitmap); + } + + /// + /// Adds a specified frame to the file specified using the specified parameters. + /// Use this method to save selected frames from an image to a multiple-frame image. + /// + /// File to add this frame to. + /// A that contains the frame to add. + /// The position of the inserted frame. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// Flags to enable or disable plugin-features. + /// + /// or is null. + /// + /// does not exist. + /// Saving the image failed. + /// is out of range. + public static void SaveAdd( + string filename, + FreeImageBitmap bitmap, + int insertPosition, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS loadFlags, + FREE_IMAGE_SAVE_FLAGS saveFlags) + { + if (filename == null) + { + throw new ArgumentNullException("filename"); + } + if (!File.Exists(filename)) + { + throw new FileNotFoundException("filename"); + } + if (bitmap == null) + { + throw new ArgumentNullException("bitmap"); + } + if (insertPosition < 0) + { + throw new ArgumentOutOfRangeException("insertPosition"); + } + bitmap.EnsureNotDisposed(); + + FIBITMAP dib = bitmap.dib; + if (dib.IsNull) + throw new ArgumentNullException("bitmap"); + + FIMULTIBITMAP mpBitmap = + FreeImage.OpenMultiBitmapEx(filename, ref format, loadFlags, false, false, true); + + if (mpBitmap.IsNull) + throw new Exception(ErrorLoadingBitmap); + + int pageCount = FreeImage.GetPageCount(mpBitmap); + + if (insertPosition > pageCount) + throw new ArgumentOutOfRangeException("insertPosition"); + + if (insertPosition == pageCount) + FreeImage.AppendPage(mpBitmap, bitmap.dib); + else + FreeImage.InsertPage(mpBitmap, insertPosition, bitmap.dib); + + if (!FreeImage.CloseMultiBitmap(mpBitmap, saveFlags)) + throw new Exception(ErrorUnloadBitmap); + } + + /// + /// Returns a new instance of the class which + /// has no public accessible constructor. + /// + /// A new instace of . + public static PropertyItem CreateNewPropertyItem() + { + return FreeImage.CreatePropertyItem(); + } + + #endregion + + #region Helper functions + + /// + /// Throws an exception in case the instance has already been disposed. + /// + private void EnsureNotDisposed() + { + lock (lockObject) + { + if (!this.disposed) + { + return; + } + } + throw new ObjectDisposedException(ToString()); + } + + /// + /// Tries to replace the wrapped with a new one. + /// In case the new dib is null or the same as the already + /// wrapped one, nothing will be changed and the result will + /// be false. + /// Otherwise the wrapped will be unloaded and replaced. + /// + /// The new dib. + /// Returns true on success, false on failure. + private bool ReplaceDib(FIBITMAP newDib) + { + bool result = false; + if ((dib != newDib) && (!newDib.IsNull)) + { + UnloadDib(); + dib = newDib; + AddMemoryPressure(); + result = true; + } + return result; + } + + /// + /// Unloads currently wrapped or unlocks the locked page + /// in case it came from a multipaged bitmap. + /// + private void UnloadDib() + { + if (!dib.IsNull) + { + long size = FreeImage.GetDIBSize(dib); + FreeImage.UnloadEx(ref dib); + if (size > 0L) + GC.RemoveMemoryPressure(size); + } + } + + /// + /// Informs the runtime about unmanaged allocoted memory. + /// + private void AddMemoryPressure() + { + long dataSize; + if ((dataSize = DataSize) > 0L) + GC.AddMemoryPressure(dataSize); + } + + /// + /// Opens the stream and reads the number of available pages. + /// Then loads the first page to this instance. + /// + private void LoadFromStream(Stream stream, FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags) + { + FIMULTIBITMAP mdib = FreeImage.OpenMultiBitmapFromStream(stream, ref format, flags); + if (mdib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + try + { + frameCount = FreeImage.GetPageCount(mdib); + } + finally + { + if (!FreeImage.CloseMultiBitmapEx(ref mdib)) + { + throw new Exception(ErrorUnloadBitmap); + } + } + + dib = FreeImage.LoadFromStream(stream, flags, ref format); + if (dib.IsNull) + { + throw new Exception(ErrorLoadingBitmap); + } + + saveInformation.loadFlags = flags; + originalFormat = format; + AddMemoryPressure(); + } + + #endregion + + #region Interfaces + + /// + /// Helper class to store informations for . + /// + private sealed class SaveInformation : ICloneable + { + public string filename; + public FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + public FREE_IMAGE_LOAD_FLAGS loadFlags = FREE_IMAGE_LOAD_FLAGS.DEFAULT; + public FREE_IMAGE_SAVE_FLAGS saveFlags = FREE_IMAGE_SAVE_FLAGS.DEFAULT; + + public object Clone() + { + return base.MemberwiseClone(); + } + } + + /// + /// Creates a deep copy of this . + /// + /// A deep copy of this . + public object Clone() + { + EnsureNotDisposed(); + FreeImageBitmap result = null; + FIBITMAP newDib = FreeImage.Clone(dib); + if (!dib.IsNull) + { + result = new FreeImageBitmap(newDib); + result.saveInformation = (SaveInformation)saveInformation.Clone(); + result.tag = tag; + result.originalFormat = originalFormat; + } + return result; + } + + /// + /// Performs application-defined tasks associated with freeing, + /// releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Performs application-defined tasks associated with freeing, + /// releasing, or resetting unmanaged resources. + /// + /// If true managed ressources are released. + protected virtual void Dispose(bool disposing) + { + // Only clean up once + lock (lockObject) + { + if (disposed) + { + return; + } + disposed = true; + } + + // Clean up managed resources + if (disposing) + { + if (stream != null) + { + if (disposeStream) + { + stream.Dispose(); + } + stream = null; + } + } + + tag = null; + saveInformation = null; + + // Clean up unmanaged resources + UnloadDib(); + } + + /// + /// Retrieves an object that can iterate through the individual scanlines in this . + /// + /// An for the . + /// The bitmaps's type is not supported. + IEnumerator IEnumerable.GetEnumerator() + { + return GetScanlines().GetEnumerator(); + } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + EnsureNotDisposed(); + using (MemoryStream memory = new MemoryStream(DataSize)) + { + if (!FreeImage.SaveToStream(dib, memory, FREE_IMAGE_FORMAT.FIF_TIFF, FREE_IMAGE_SAVE_FLAGS.TIFF_LZW)) + { + throw new SerializationException(); + } + memory.Capacity = (int)memory.Length; + info.AddValue("Bitmap Data", memory.GetBuffer()); + } + } + + #endregion + } +} + +namespace FreeImageAPI +{ + /// + /// Class handling non-bitmap related functions. + /// + public static class FreeImageEngine + { + #region Callback + + // Callback delegate + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly OutputMessageFunction outputMessageFunction; + + static FreeImageEngine() + { + // Check if FreeImage.dll is present and cancel setting the callbackfuntion if not + if (!IsAvailable) + { + return; + } + // Create a delegate (function pointer) to 'OnMessage' + outputMessageFunction = new OutputMessageFunction(OnMessage); + // Set the callback + FreeImage.SetOutputMessage(outputMessageFunction); + } + + /// + /// Internal callback + /// + private static void OnMessage(FREE_IMAGE_FORMAT fif, string message) + { + // Get a local copy of the multicast-delegate + OutputMessageFunction m = Message; + + // Check the local copy instead of the static instance + // to prevent a second thread from setting the delegate + // to null, which would cause a nullreference exception + if (m != null) + { + // Invoke the multicast-delegate + m.Invoke(fif, message); + } + } + + /// + /// Gets a value indicating if the FreeImage DLL is available or not. + /// + public static bool IsAvailable + { + get + { + return FreeImage.IsAvailable(); + } + } + + /// + /// Internal errors in FreeImage generate a logstring that can be + /// captured by this event. + /// + public static event OutputMessageFunction Message; + + #endregion + + /// + /// Gets a string containing the current version of the library. + /// + public static string Version + { + get + { + return FreeImage.GetVersion(); + } + } + + /// + /// Gets a string containing a standard copyright message. + /// + public static string CopyrightMessage + { + get + { + return FreeImage.GetCopyrightMessage(); + } + } + + /// + /// Gets whether the platform is using Little Endian. + /// + public static bool IsLittleEndian + { + get + { + return FreeImage.IsLittleEndian(); + } + } + } +} + +namespace FreeImageAPI.Plugins +{ + /// + /// Class representing a FreeImage format. + /// + public sealed class FreeImagePlugin + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly FREE_IMAGE_FORMAT fif; + + /// + /// Initializes a new instance of this class. + /// + /// The FreeImage format to wrap. + internal FreeImagePlugin(FREE_IMAGE_FORMAT fif) + { + this.fif = fif; + } + + /// + /// Gets the format of this instance. + /// + public FREE_IMAGE_FORMAT FIFormat + { + get + { + return fif; + } + } + + /// + /// Gets or sets whether this plugin is enabled. + /// + public bool Enabled + { + get + { + return (FreeImage.IsPluginEnabled(fif) == 1); + } + set + { + FreeImage.SetPluginEnabled(fif, value); + } + } + + /// + /// Gets a string describing the format. + /// + public string Format + { + get + { + return FreeImage.GetFormatFromFIF(fif); + } + } + + /// + /// Gets a comma-delimited file extension list describing the bitmap formats + /// this plugin can read and/or write. + /// + public string ExtentsionList + { + get + { + return FreeImage.GetFIFExtensionList(fif); + } + } + + /// + /// Gets a descriptive string that describes the bitmap formats + /// this plugin can read and/or write. + /// + public string Description + { + get + { + return FreeImage.GetFIFDescription(fif); + } + } + + /// + /// Returns a regular expression string that can be used by + /// a regular expression engine to identify the bitmap. + /// FreeImageQt makes use of this function. + /// + public string RegExpr + { + get + { + return FreeImage.GetFIFRegExpr(fif); + } + } + + /// + /// Gets whether this plugin can load bitmaps. + /// + public bool SupportsReading + { + get + { + return FreeImage.FIFSupportsReading(fif); + } + } + + /// + /// Gets whether this plugin can save bitmaps. + /// + public bool SupportsWriting + { + get + { + return FreeImage.FIFSupportsWriting(fif); + } + } + + /// + /// Checks whether this plugin can save a bitmap in the desired data type. + /// + /// The desired image type. + /// True if this plugin can save bitmaps as the desired type, else false. + public bool SupportsExportType(FREE_IMAGE_TYPE type) + { + return FreeImage.FIFSupportsExportType(fif, type); + } + + /// + /// Checks whether this plugin can save bitmaps in the desired bit depth. + /// + /// The desired bit depth. + /// True if this plugin can save bitmaps in the desired bit depth, else false. + public bool SupportsExportBPP(int bpp) + { + return FreeImage.FIFSupportsExportBPP(fif, bpp); + } + + /// + /// Gets whether this plugin can load or save an ICC profile. + /// + public bool SupportsICCProfiles + { + get + { + return FreeImage.FIFSupportsICCProfiles(fif); + } + } + + /// + /// Checks whether an extension is valid for this format. + /// + /// The desired extension. + /// True if the extension is valid for this format, false otherwise. + public bool ValidExtension(string extension) + { + return FreeImage.IsExtensionValidForFIF(fif, extension); + } + + /// + /// Checks whether an extension is valid for this format. + /// + /// The desired extension. + /// The string comparison type. + /// True if the extension is valid for this format, false otherwise. + public bool ValidExtension(string extension, StringComparison comparisonType) + { + return FreeImage.IsExtensionValidForFIF(fif, extension, comparisonType); + } + + /// + /// Checks whether a filename is valid for this format. + /// + /// The desired filename. + /// True if the filename is valid for this format, false otherwise. + public bool ValidFilename(string filename) + { + return FreeImage.IsFilenameValidForFIF(fif, filename); + } + + /// + /// Checks whether a filename is valid for this format. + /// + /// The desired filename. + /// The string comparison type. + /// True if the filename is valid for this format, false otherwise. + public bool ValidFilename(string filename, StringComparison comparisonType) + { + return FreeImage.IsFilenameValidForFIF(fif, filename, comparisonType); + } + + /// + /// Gets a descriptive string that describes the bitmap formats + /// this plugin can read and/or write. + /// + /// A descriptive string that describes the bitmap formats. + public override string ToString() + { + return Description; + } + } +} + +namespace FreeImageAPI.IO +{ + /// + /// Internal class wrapping stream io functions. + /// + /// + /// FreeImage can read files from a disk or a network drive but also allows the user to + /// implement their own loading or saving functions to load them directly from an ftp or web + /// server for example. + /// + /// In .NET streams are a common way to handle data. The FreeImageStreamIO class handles + /// the loading and saving from and to streams. It implements the funtions FreeImage needs + /// to load data from an an arbitrary source. + /// + /// The class is for internal use only. + /// + internal static class FreeImageStreamIO + { + /// + /// structure that can be used to read from streams via + /// . + /// + public static readonly FreeImageIO io; + + /// + /// Initializes a new instances which can be used to + /// create a FreeImage compatible structure. + /// + static FreeImageStreamIO() + { + io.readProc = new ReadProc(streamRead); + io.writeProc = new WriteProc(streamWrite); + io.seekProc = new SeekProc(streamSeek); + io.tellProc = new TellProc(streamTell); + } + + /// + /// Reads the requested data from the stream and writes it to the given address. + /// + static unsafe uint streamRead(IntPtr buffer, uint size, uint count, fi_handle handle) + { + Stream stream = handle.GetObject() as Stream; + if ((stream == null) || (!stream.CanRead)) + { + return 0; + } + uint readCount = 0; + byte* ptr = (byte*)buffer; + byte[] bufferTemp = new byte[size]; + int read; + while (readCount < count) + { + read = stream.Read(bufferTemp, 0, (int)size); + if (read != (int)size) + { + stream.Seek(-read, SeekOrigin.Current); + break; + } + for (int i = 0; i < read; i++, ptr++) + { + *ptr = bufferTemp[i]; + } + readCount++; + } + return (uint)readCount; + } + + /// + /// Reads the given data and writes it into the stream. + /// + static unsafe uint streamWrite(IntPtr buffer, uint size, uint count, fi_handle handle) + { + Stream stream = handle.GetObject() as Stream; + if ((stream == null) || (!stream.CanWrite)) + { + return 0; + } + uint writeCount = 0; + byte[] bufferTemp = new byte[size]; + byte* ptr = (byte*)buffer; + while (writeCount < count) + { + for (int i = 0; i < size; i++, ptr++) + { + bufferTemp[i] = *ptr; + } + try + { + stream.Write(bufferTemp, 0, bufferTemp.Length); + } + catch + { + return writeCount; + } + writeCount++; + } + return writeCount; + } + + /// + /// Moves the streams position. + /// + static int streamSeek(fi_handle handle, int offset, SeekOrigin origin) + { + Stream stream = handle.GetObject() as Stream; + if (stream == null) + { + return 1; + } + stream.Seek((long)offset, origin); + return 0; + } + + /// + /// Returns the streams current position + /// + static int streamTell(fi_handle handle) + { + Stream stream = handle.GetObject() as Stream; + if (stream == null) + { + return -1; + } + return (int)stream.Position; + } + } +} + +namespace FreeImageAPI.Metadata +{ + /// + /// Provides additional information specific for GIF files. This class cannot be inherited. + /// + public class GifInformation : MDM_ANIMATION + { + /// + /// Initializes a new instance of the class + /// with the specified . + /// + /// A reference to a instance. + public GifInformation(FreeImageBitmap bitmap) + : base(bitmap.Dib) + { + } + + /// + /// Gets or sets a value indicating whether this frame uses the + /// GIF image's global palette. If set to false, this + /// frame uses its local palette. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? UseGlobalPalette + { + get + { + byte? useGlobalPalette = GetTagValue("NoLocalPalette"); + return useGlobalPalette.HasValue ? (useGlobalPalette.Value != 0) : default(bool?); + } + set + { + byte? val = null; + if (value.HasValue) + { + val = (byte)(value.Value ? 1 : 0); + } + SetTagValue("NoLocalPalette", val); + } + } + + /// + /// Creates a global palette for the GIF image, intialized with all entries of the + /// current local palette. + /// The property will be set to true when + /// invoking this method. This effectively enables the newly created global palette. + /// + /// + /// The image does not have a palette. + /// + public void CreateGlobalPalette() + { + CreateGlobalPalette(new Palette(dib)); + } + + /// + /// Creates a global palette for the GIF image with the specified size, intialized + /// with the first entries of the current local palette. + /// The property will be set to true when + /// invoking this method. This effectively enables the newly created global palette. + /// + /// The size of the newly created global palette. + /// + /// is a null reference. + public void CreateGlobalPalette(int size) + { + CreateGlobalPalette(new Palette(dib), size); + } + + /// + /// Creates a global palette for the GIF image, intialized with the entries + /// of the specified palette. + /// The property will be set to true when + /// invoking this method. This effectively enables the newly created global palette. + /// + /// The palette that contains the initial values for + /// the newly created global palette. + /// + /// is a null reference. + public void CreateGlobalPalette(Palette palette) + { + if (palette == null) + { + throw new ArgumentNullException("palette"); + } + + GlobalPalette = palette; + UseGlobalPalette = true; + } + + /// + /// Creates a global palette for the GIF image with the specified size, intialized + /// with the first entries of the specified palette. + /// The property will be set to true when + /// invoking this method. This effectively enables the newly created global palette. + /// + /// The palette that contains the initial values for + /// the newly created global palette. + /// The size of the newly created global palette. + /// + /// is a null reference. + public void CreateGlobalPalette(Palette palette, int size) + { + if (palette == null) + { + throw new ArgumentNullException("palette"); + } + if (size <= 0) + { + throw new ArgumentOutOfRangeException("size"); + } + + Palette pal = new Palette(size); + pal.CopyFrom(palette); + GlobalPalette = palette; + UseGlobalPalette = true; + } + } +} + +namespace FreeImageAPI.Metadata +{ + /// + /// Class handling metadata of a FreeImage bitmap. + /// + public class ImageMetadata : IEnumerable, IComparable, IComparable + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly List data; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly FIBITMAP dib; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool hideEmptyModels; + + /// + /// Initializes a new instance based on the specified , + /// showing all known models. + /// + /// Handle to a FreeImage bitmap. + public ImageMetadata(FIBITMAP dib) : this(dib, false) { } + + /// + /// Initializes a new instance based on the specified , + /// showing or hiding empry models. + /// + /// Handle to a FreeImage bitmap. + /// When true, empty metadata models + /// will be hidden until a tag to this model is added. + public ImageMetadata(FIBITMAP dib, bool hideEmptyModels) + { + if (dib.IsNull) throw new ArgumentNullException("dib"); + data = new List(FreeImage.FREE_IMAGE_MDMODELS.Length); + this.dib = dib; + this.hideEmptyModels = hideEmptyModels; + + data.Add(new MDM_ANIMATION(dib)); + data.Add(new MDM_COMMENTS(dib)); + data.Add(new MDM_CUSTOM(dib)); + data.Add(new MDM_EXIF_EXIF(dib)); + data.Add(new MDM_EXIF_GPS(dib)); + data.Add(new MDM_INTEROP(dib)); + data.Add(new MDM_EXIF_MAIN(dib)); + data.Add(new MDM_MAKERNOTE(dib)); + data.Add(new MDM_GEOTIFF(dib)); + data.Add(new MDM_IPTC(dib)); + data.Add(new MDM_NODATA(dib)); + data.Add(new MDM_XMP(dib)); + } + + /// + /// Gets or sets the of the specified type. + /// In case the getter returns null the model is not contained + /// by the list. + /// null can be used calling the setter to destroy the model. + /// + /// Type of the model. + /// The object of the specified type. + public MetadataModel this[FREE_IMAGE_MDMODEL model] + { + get + { + for (int i = 0; i < data.Count; i++) + { + if (data[i].Model == model) + { + if (!data[i].Exists && hideEmptyModels) + { + return null; + } + return data[i]; + } + } + return null; + } + } + + /// + /// Gets or sets the at the specified index. + /// In case the getter returns null the model is not contained + /// by the list. + /// null can be used calling the setter to destroy the model. + /// + /// Index of the within + /// this instance. + /// The + /// object at the specified index. + public MetadataModel this[int index] + { + get + { + if (index < 0 || index >= data.Count) + { + throw new ArgumentOutOfRangeException("index"); + } + return (hideEmptyModels && !data[index].Exists) ? null : data[index]; + } + } + + /// + /// Returns a list of all visible + /// MetadataModels. + /// + public List List + { + get + { + if (hideEmptyModels) + { + List result = new List(); + for (int i = 0; i < data.Count; i++) + { + if (data[i].Exists) + { + result.Add(data[i]); + } + } + return result; + } + else + { + return data; + } + } + } + + /// + /// Adds new tag to the bitmap or updates its value in case it already exists. + /// will be used as key. + /// + /// The tag to add or update. + /// Returns true on success, false on failure. + /// + /// is null. + public bool AddTag(MetadataTag tag) + { + for (int i = 0; i < data.Count; i++) + { + if (tag.Model == data[i].Model) + { + return data[i].AddTag(tag); + } + } + return false; + } + + /// + /// Returns the number of visible + /// MetadataModels. + /// + public int Count + { + get + { + if (hideEmptyModels) + { + int count = 0; + for (int i = 0; i < data.Count; i++) + { + if (data[i].Exists) + { + count++; + } + } + return count; + } + else + { + return data.Count; + } + } + } + + /// + /// Gets or sets whether empty + /// MetadataModels are hidden. + /// + public bool HideEmptyModels + { + get + { + return hideEmptyModels; + } + set + { + hideEmptyModels = value; + } + } + + /// + /// Retrieves an object that can iterate through the individual + /// MetadataModels + /// in this . + /// + /// An for this . + public IEnumerator GetEnumerator() + { + if (hideEmptyModels) + { + List tempList = new List(data.Count); + for (int i = 0; i < data.Count; i++) + { + if (data[i].Exists) + { + tempList.Add(data[i]); + } + } + return tempList.GetEnumerator(); + } + else + { + return data.GetEnumerator(); + } + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is ImageMetadata)) + { + throw new ArgumentException("obj"); + } + return CompareTo((ImageMetadata)obj); + } + + /// + /// Compares this instance with a specified object. + /// + /// A to compare. + /// A signed number indicating the relative values of this instance + /// and . + public int CompareTo(ImageMetadata other) + { + return this.dib.CompareTo(other.dib); + } + } +} + +namespace FreeImageAPI.Plugins +{ + /// + /// Class representing own FreeImage-Plugins. + /// + /// + /// FreeImages itself is plugin based. Each supported format is integrated by a seperat plugin, + /// that handles loading, saving, descriptions, identifing ect. + /// And of course the user can create own plugins and use them in FreeImage. + /// To do that the above mentioned predefined methodes need to be implemented. + /// + /// The class below handles the creation of such a plugin. The class itself is abstract + /// as well as some core functions that need to be implemented. + /// The class can be used to enable or disable the plugin in FreeImage after regististration or + /// retrieve the formatid, assigned by FreeImage. + /// The class handles the callback functions, garbage collector and pointer operation to make + /// the implementation as user friendly as possible. + /// + /// How to: + /// There are two functions that need to be implemented: + /// and + /// . + /// is used by the constructor + /// of the abstract class. FreeImage wants a list of the implemented functions. Each function is + /// represented by a function pointer (a .NET ). In case a function + /// is not implemented FreeImage receives an empty delegate). To tell the constructor + /// which functions have been implemented the information is represented by a disjunction of + /// . + /// + /// For example: + /// return MethodFlags.LoadProc | MethodFlags.SaveProc; + /// + /// The above statement means that LoadProc and SaveProc have been implemented by the user. + /// Keep in mind, that each function has a standard implementation that has static return + /// values that may cause errors if listed in + /// without a real implementation. + /// + /// is used by some checks of FreeImage and + /// must be implemented. for example can be + /// implemented if the plugin supports reading, but it doesn't have to, the plugin could only + /// be used to save an already loaded bitmap in a special format. + /// + public abstract class LocalPlugin + { + /// + /// Struct containing function pointers. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private Plugin plugin; + + /// + /// Delegate for register callback by FreeImage. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private InitProc initProc; + + /// + /// The format id assiged to the plugin. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + + /// + /// When true the plugin was registered successfully else false. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected readonly bool registered = false; + + /// + /// A copy of the functions used to register. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected readonly MethodFlags implementedMethods; + + /// + /// MethodFlags defines values to fill a bitfield telling which + /// functions have been implemented by a plugin. + /// + [Flags] + protected enum MethodFlags + { + /// + /// No mothods implemented. + /// + None = 0x0, + + /// + /// DescriptionProc has been implemented. + /// + DescriptionProc = 0x1, + + /// + /// ExtensionListProc has been implemented. + /// + ExtensionListProc = 0x2, + + /// + /// RegExprProc has been implemented. + /// + RegExprProc = 0x4, + + /// + /// OpenProc has been implemented. + /// + OpenProc = 0x8, + + /// + /// CloseProc has been implemented. + /// + CloseProc = 0x10, + + /// + /// PageCountProc has been implemented. + /// + PageCountProc = 0x20, + + /// + /// PageCapabilityProc has been implemented. + /// + PageCapabilityProc = 0x40, + + /// + /// LoadProc has been implemented. + /// + LoadProc = 0x80, + + /// + /// SaveProc has been implemented. + /// + SaveProc = 0x100, + + /// + /// ValidateProc has been implemented. + /// + ValidateProc = 0x200, + + /// + /// MimeProc has been implemented. + /// + MimeProc = 0x400, + + /// + /// SupportsExportBPPProc has been implemented. + /// + SupportsExportBPPProc = 0x800, + + /// + /// SupportsExportTypeProc has been implemented. + /// + SupportsExportTypeProc = 0x1000, + + /// + /// SupportsICCProfilesProc has been implemented. + /// + SupportsICCProfilesProc = 0x2000 + } + + // Functions that must be implemented. + + /// + /// Function that returns a bitfield containing the + /// implemented methods. + /// + /// Bitfield of the implemented methods. + protected abstract MethodFlags GetImplementedMethods(); + + /// + /// Implementation of FormatProc + /// + /// A string containing the plugins format. + protected abstract string FormatProc(); + + // Functions that can be implemented. + + /// + /// Function that can be implemented. + /// + protected virtual string DescriptionProc() { return ""; } + /// + /// Function that can be implemented. + /// + protected virtual string ExtensionListProc() { return ""; } + /// + /// Function that can be implemented. + /// + protected virtual string RegExprProc() { return ""; } + /// + /// Function that can be implemented. + /// + protected virtual IntPtr OpenProc(ref FreeImageIO io, fi_handle handle, bool read) { return IntPtr.Zero; } + /// + /// Function that can be implemented. + /// + protected virtual void CloseProc(ref FreeImageIO io, fi_handle handle, IntPtr data) { } + /// + /// Function that can be implemented. + /// + protected virtual int PageCountProc(ref FreeImageIO io, fi_handle handle, IntPtr data) { return 0; } + /// + /// Function that can be implemented. + /// + protected virtual int PageCapabilityProc(ref FreeImageIO io, fi_handle handle, IntPtr data) { return 0; } + /// + /// Function that can be implemented. + /// + protected virtual FIBITMAP LoadProc(ref FreeImageIO io, fi_handle handle, int page, int flags, IntPtr data) { return FIBITMAP.Zero; } + /// + /// Function that can be implemented. + /// + protected virtual bool SaveProc(ref FreeImageIO io, FIBITMAP dib, fi_handle handle, int page, int flags, IntPtr data) { return false; } + /// + /// Function that can be implemented. + /// + protected virtual bool ValidateProc(ref FreeImageIO io, fi_handle handle) { return false; } + /// + /// Function that can be implemented. + /// + protected virtual string MimeProc() { return ""; } + /// + /// Function that can be implemented. + /// + protected virtual bool SupportsExportBPPProc(int bpp) { return false; } + /// + /// Function that can be implemented. + /// + protected virtual bool SupportsExportTypeProc(FREE_IMAGE_TYPE type) { return false; } + /// + /// Function that can be implemented. + /// + protected virtual bool SupportsICCProfilesProc() { return false; } + + /// + /// The constructor automatically registeres the plugin in FreeImage. + /// To do this it prepares a FreeImage defined structure with function pointers + /// to the implemented functions or null if not implemented. + /// Before registing the functions they are pinned in memory so the garbage collector + /// can't move them around in memory after we passed there addresses to FreeImage. + /// + public LocalPlugin() + { + implementedMethods = GetImplementedMethods(); + + if ((implementedMethods & MethodFlags.DescriptionProc) != 0) + { + plugin.descriptionProc = new DescriptionProc(DescriptionProc); + } + if ((implementedMethods & MethodFlags.ExtensionListProc) != 0) + { + plugin.extensionListProc = new ExtensionListProc(ExtensionListProc); + } + if ((implementedMethods & MethodFlags.RegExprProc) != 0) + { + plugin.regExprProc = new RegExprProc(RegExprProc); + } + if ((implementedMethods & MethodFlags.OpenProc) != 0) + { + plugin.openProc = new OpenProc(OpenProc); + } + if ((implementedMethods & MethodFlags.CloseProc) != 0) + { + plugin.closeProc = new CloseProc(CloseProc); + } + if ((implementedMethods & MethodFlags.PageCountProc) != 0) + { + plugin.pageCountProc = new PageCountProc(PageCountProc); + } + if ((implementedMethods & MethodFlags.PageCapabilityProc) != 0) + { + plugin.pageCapabilityProc = new PageCapabilityProc(PageCapabilityProc); + } + if ((implementedMethods & MethodFlags.LoadProc) != 0) + { + plugin.loadProc = new LoadProc(LoadProc); + } + if ((implementedMethods & MethodFlags.SaveProc) != 0) + { + plugin.saveProc = new SaveProc(SaveProc); + } + if ((implementedMethods & MethodFlags.ValidateProc) != 0) + { + plugin.validateProc = new ValidateProc(ValidateProc); + } + if ((implementedMethods & MethodFlags.MimeProc) != 0) + { + plugin.mimeProc = new MimeProc(MimeProc); + } + if ((implementedMethods & MethodFlags.SupportsExportBPPProc) != 0) + { + plugin.supportsExportBPPProc = new SupportsExportBPPProc(SupportsExportBPPProc); + } + if ((implementedMethods & MethodFlags.SupportsExportTypeProc) != 0) + { + plugin.supportsExportTypeProc = new SupportsExportTypeProc(SupportsExportTypeProc); + } + if ((implementedMethods & MethodFlags.SupportsICCProfilesProc) != 0) + { + plugin.supportsICCProfilesProc = new SupportsICCProfilesProc(SupportsICCProfilesProc); + } + + // FormatProc is always implemented + plugin.formatProc = new FormatProc(FormatProc); + + // InitProc is the register call back. + initProc = new InitProc(RegisterProc); + + // Register the plugin. The result will be saved and can be accessed later. + registered = FreeImage.RegisterLocalPlugin(initProc, null, null, null, null) != FREE_IMAGE_FORMAT.FIF_UNKNOWN; + if (registered) + { + PluginRepository.RegisterLocalPlugin(this); + } + } + + private void RegisterProc(ref Plugin plugin, int format_id) + { + // Copy the function pointers + plugin = this.plugin; + // Retrieve the format if assigned to this plugin by FreeImage. + format = (FREE_IMAGE_FORMAT)format_id; + } + + /// + /// Gets or sets if the plugin is enabled. + /// + public bool Enabled + { + get + { + if (registered) + { + return (FreeImage.IsPluginEnabled(format) > 0); + } + else + { + throw new ObjectDisposedException("plugin not registered"); + } + } + set + { + if (registered) + { + FreeImage.SetPluginEnabled(format, value); + } + else + { + throw new ObjectDisposedException("plugin not registered"); + } + } + } + + /// + /// Gets if the plugin was registered successfully. + /// + public bool Registered + { + get { return registered; } + } + + /// + /// Gets the FreeImage assigned to this plugin. + /// + public FREE_IMAGE_FORMAT Format + { + get + { + return format; + } + } + + /// + /// Reads from an unmanaged stream. + /// + protected unsafe int Read(FreeImageIO io, fi_handle handle, uint size, uint count, ref byte[] buffer) + { + fixed (byte* ptr = buffer) + { + return (int)io.readProc(new IntPtr(ptr), size, count, handle); + } + } + + /// + /// Reads a single byte from an unmanaged stream. + /// + protected unsafe int ReadByte(FreeImageIO io, fi_handle handle) + { + byte buffer = 0; + return (int)io.readProc(new IntPtr(&buffer), 1, 1, handle) > 0 ? buffer : -1; + } + + /// + /// Writes to an unmanaged stream. + /// + protected unsafe int Write(FreeImageIO io, fi_handle handle, uint size, uint count, ref byte[] buffer) + { + fixed (byte* ptr = buffer) + { + return (int)io.writeProc(new IntPtr(ptr), size, count, handle); + } + } + + /// + /// Writes a single byte to an unmanaged stream. + /// + protected unsafe int WriteByte(FreeImageIO io, fi_handle handle, byte value) + { + return (int)io.writeProc(new IntPtr(&value), 1, 1, handle); + } + + /// + /// Seeks in an unmanaged stream. + /// + protected int Seek(FreeImageIO io, fi_handle handle, int offset, SeekOrigin origin) + { + return io.seekProc(handle, offset, origin); + } + + /// + /// Retrieves the position of an unmanaged stream. + /// + protected int Tell(FreeImageIO io, fi_handle handle) + { + return io.tellProc(handle); + } + } +} + +namespace FreeImageAPI +{ + /// + /// Represents unmanaged memory, containing an array of a given structure. + /// + /// Structuretype represented by the instance. + /// + /// and can not be marshalled. + /// + /// Use instead of and + /// instead of . + /// + public unsafe class MemoryArray : IDisposable, ICloneable, ICollection, IEnumerable, IEquatable> where T : struct + { + /// + /// Baseaddress of the wrapped memory. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected byte* baseAddress; + + /// + /// Number of elements being wrapped. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected int length; + + /// + /// Size, in bytes, of each element. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly int size; + + /// + /// Array of T containing a single element. + /// The array is used as a workaround, because there are no pointer for generic types. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected T[] buffer; + + /// + /// Pointer to the element of buffer. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected byte* ptr; + + /// + /// Handle for pinning buffer. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected GCHandle handle; + + /// + /// Indicates whether the wrapped memory is handled like a bitfield. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected readonly bool isOneBit; + + /// + /// Indicates whther the wrapped memory is handles like 4-bit blocks. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected readonly bool isFourBit; + + /// + /// An object that can be used to synchronize access to the . + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected object syncRoot = null; + + static MemoryArray() + { + T[] dummy = new T[2]; + long marshalledSize = Marshal.SizeOf(typeof(T)); + long structureSize = + Marshal.UnsafeAddrOfPinnedArrayElement(dummy, 1).ToInt64() - + Marshal.UnsafeAddrOfPinnedArrayElement(dummy, 0).ToInt64(); + if (marshalledSize != structureSize) + { + throw new NotSupportedException( + "The desired type can not be handled, " + + "because its managed and unmanaged size in bytes are different."); + } + + size = (int)marshalledSize; + } + + /// + /// Initializes a new instance. + /// + protected MemoryArray() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Address of the memory block. + /// Length of the array. + /// + /// is null. + /// + /// is less or equal zero. + /// + /// The type is not supported. + public MemoryArray(IntPtr baseAddress, int length) + : this(baseAddress.ToPointer(), length) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Address of the memory block. + /// Length of the array. + /// + /// is null. + /// + /// is less or equal zero. + /// + /// The type is not supported. + public MemoryArray(void* baseAddress, int length) + { + if (typeof(T) == typeof(FI1BIT)) + { + isOneBit = true; + } + else if (typeof(T) == typeof(FI4BIT)) + { + isFourBit = true; + } + + if (baseAddress == null) + { + throw new ArgumentNullException("baseAddress"); + } + if (length < 1) + { + throw new ArgumentOutOfRangeException("length"); + } + + this.baseAddress = (byte*)baseAddress; + this.length = (int)length; + + if (!isOneBit && !isFourBit) + { + // Create an array containing a single element. + // Due to the fact, that it's not possible to create pointers + // of generic types, an array is used to obtain the memory + // address of an element of T. + this.buffer = new T[1]; + // The array is pinned immediately to prevent the GC from + // moving it to a different position in memory. + this.handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + // The array and its content have beed pinned, so that its address + // can be safely requested and stored for the whole lifetime + // of the instace. + this.ptr = (byte*)handle.AddrOfPinnedObject(); + } + } + + /// + /// Frees the allocated . + /// + ~MemoryArray() + { + Dispose(false); + } + + /// + /// Tests whether two specified structures are equivalent. + /// + /// The that is to the left of the equality operator. + /// The that is to the right of the equality operator. + /// + /// true if the two structures are equal; otherwise, false. + /// + public static bool operator ==(MemoryArray left, MemoryArray right) + { + if (object.ReferenceEquals(left, right)) + { + return true; + } + if (object.ReferenceEquals(right, null) || + object.ReferenceEquals(left, null) || + (left.length != right.length)) + { + return false; + } + if (left.baseAddress == right.baseAddress) + { + return true; + } + return FreeImage.CompareMemory(left.baseAddress, right.baseAddress, (uint)left.length); + } + + /// + /// Tests whether two specified structures are different. + /// + /// The that is to the left of the inequality operator. + /// The that is to the right of the inequality operator. + /// + /// true if the two structures are different; otherwise, false. + /// + public static bool operator !=(MemoryArray left, MemoryArray right) + { + return (!(left == right)); + } + + /// + /// Gets the value at the specified position. + /// + /// A 32-bit integer that represents the position + /// of the array element to get. + /// The value at the specified position. + /// + /// is outside the range of valid indexes + /// for the unmanaged array. + public T GetValue(int index) + { + if ((index >= this.length) || (index < 0)) + { + throw new ArgumentOutOfRangeException("index"); + } + + return GetValueInternal(index); + } + + private T GetValueInternal(int index) + { + EnsureNotDisposed(); + if (isOneBit) + { + return (T)(object)(FI1BIT)(((baseAddress[index / 8] & ((1 << (7 - (index % 8))))) == 0) ? 0 : 1); + } + else if (isFourBit) + { + return (T)(object)(FI4BIT)(((index % 2) == 0) ? (baseAddress[index / 2] >> 4) : (baseAddress[index / 2] & 0x0F)); + } + else + { + CopyMemory(ptr, baseAddress + (index * size), size); + return buffer[0]; + } + } + + /// + /// Sets a value to the element at the specified position. + /// + /// The new value for the specified element. + /// A 32-bit integer that represents the + /// position of the array element to set. + /// + /// is outside the range of valid indexes + /// for the unmanaged array. + public void SetValue(T value, int index) + { + if ((index >= this.length) || (index < 0)) + { + throw new ArgumentOutOfRangeException("index"); + } + SetValueInternal(value, index); + } + + private void SetValueInternal(T value, int index) + { + EnsureNotDisposed(); + if (isOneBit) + { + if ((FI1BIT)(object)value != 0) + { + baseAddress[index / 8] |= (byte)(1 << (7 - (index % 8))); + } + else + { + baseAddress[index / 8] &= (byte)(~(1 << (7 - (index % 8)))); + } + } + else if (isFourBit) + { + if ((index % 2) == 0) + { + baseAddress[index / 2] = (byte)((baseAddress[index / 2] & 0x0F) | ((FI4BIT)(object)value << 4)); + } + else + { + baseAddress[index / 2] = (byte)((baseAddress[index / 2] & 0xF0) | ((FI4BIT)(object)value & 0x0F)); + } + } + else + { + buffer[0] = value; + CopyMemory(baseAddress + (index * size), ptr, size); + } + } + + /// + /// Gets the values at the specified position and length. + /// + /// A 32-bit integer that represents the position + /// of the array elements to get. + /// A 32-bit integer that represents the length + /// of the array elements to get. + /// The values at the specified position and length. + /// + /// is outside the range of valid indexes + /// for the unmanaged array or is greater than the number of elements + /// from to the end of the unmanaged array. + public T[] GetValues(int index, int length) + { + EnsureNotDisposed(); + if ((index >= this.length) || (index < 0)) + { + throw new ArgumentOutOfRangeException("index"); + } + if (((index + length) > this.length) || (length < 1)) + { + throw new ArgumentOutOfRangeException("length"); + } + + T[] data = new T[length]; + if (isOneBit || isFourBit) + { + for (int i = 0; i < length; i++) + { + data[i] = GetValueInternal(i); + } + } + else + { + GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); + byte* dst = (byte*)Marshal.UnsafeAddrOfPinnedArrayElement(data, 0); + CopyMemory(dst, baseAddress + (size * index), size * length); + handle.Free(); + } + return data; + } + + /// + /// Sets the values at the specified position. + /// + /// An array containing the new values for the specified elements. + /// A 32-bit integer that represents the position + /// of the array elements to set. + /// + /// is a null reference (Nothing in Visual Basic). + /// + /// is outside the range of valid indexes + /// for the unmanaged array or is greater than the number of elements + /// from to the end of the array. + public void SetValues(T[] values, int index) + { + EnsureNotDisposed(); + if (values == null) + { + throw new ArgumentNullException("values"); + } + if ((index >= this.length) || (index < 0)) + { + throw new ArgumentOutOfRangeException("index"); + } + if ((index + values.Length) > this.length) + { + throw new ArgumentOutOfRangeException("values.Length"); + } + + if (isOneBit || isFourBit) + { + for (int i = 0; i != values.Length; ) + { + SetValueInternal(values[i++], index++); + } + } + else + { + GCHandle handle = GCHandle.Alloc(values, GCHandleType.Pinned); + byte* src = (byte*)Marshal.UnsafeAddrOfPinnedArrayElement(values, 0); + CopyMemory(baseAddress + (index * size), src, size * length); + handle.Free(); + } + } + + /// + /// Copies the entire array to a compatible one-dimensional , + /// starting at the specified index of the target array. + /// + /// The one-dimensional that is the destination + /// of the elements copied from . + /// The must have zero-based indexing. + /// The zero-based index in + /// at which copying begins. + public void CopyTo(Array array, int index) + { + EnsureNotDisposed(); + if (!(array is T[])) + { + throw new InvalidCastException("array"); + } + try + { + CopyTo((T[])array, 0, index, length); + } + catch (ArgumentOutOfRangeException ex) + { + throw new ArgumentException(ex.Message, ex); + } + } + + /// + /// Copies a range of elements from the unmanaged array starting at the specified + /// and pastes them to + /// starting at the specified . + /// The length and the indexes are specified as 32-bit integers. + /// + /// The array that receives the data. + /// A 32-bit integer that represents the index + /// in the unmanaged array at which copying begins. + /// A 32-bit integer that represents the index in + /// the destination array at which storing begins. + /// A 32-bit integer that represents the number of elements to copy. + /// + /// is a null reference (Nothing in Visual Basic). + /// + /// is outside the range of valid indexes + /// for the unmanaged array or is greater than the number of elements + /// from to the end of the unmanaged array + /// -or- + /// is outside the range of valid indexes + /// for the array or is greater than the number of elements + /// from to the end of the array. + /// + public void CopyTo(T[] array, int sourceIndex, int destinationIndex, int length) + { + EnsureNotDisposed(); + if (array == null) + { + throw new ArgumentNullException("array"); + } + if ((sourceIndex >= this.length) || (sourceIndex < 0)) + { + throw new ArgumentOutOfRangeException("sourceIndex"); + } + if ((destinationIndex >= array.Length) || (destinationIndex < 0)) + { + throw new ArgumentOutOfRangeException("destinationIndex"); + } + if ((sourceIndex + length > this.length) || + (destinationIndex + length > array.Length) || + (length < 1)) + { + throw new ArgumentOutOfRangeException("length"); + } + + if (isOneBit || isFourBit) + { + for (int i = 0; i != length; i++) + { + array[destinationIndex++] = GetValueInternal(sourceIndex++); + } + } + else + { + GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned); + byte* dst = (byte*)Marshal.UnsafeAddrOfPinnedArrayElement(array, destinationIndex); + CopyMemory(dst, baseAddress + (size * sourceIndex), size * length); + handle.Free(); + } + } + + /// + /// Copies a range of elements from the array starting at the specified + /// and pastes them to the unmanaged array + /// starting at the specified . + /// The length and the indexes are specified as 32-bit integers. + /// + /// The array that holds the data. + /// A 32-bit integer that represents the index + /// in the array at which copying begins. + /// A 32-bit integer that represents the index in + /// the unmanaged array at which storing begins. + /// A 32-bit integer that represents the number of elements to copy. + /// + /// is a null reference (Nothing in Visual Basic). + /// + /// is outside the range of valid indexes + /// for the array or is greater than the number of elements + /// from to the end of the array + /// -or- + /// is outside the range of valid indexes + /// for the unmanaged array or is greater than the number of elements + /// from to the end of the unmanaged array. + /// + public void CopyFrom(T[] array, int sourceIndex, int destinationIndex, int length) + { + EnsureNotDisposed(); + if (array == null) + { + throw new ArgumentNullException("array"); + } + if ((destinationIndex >= this.length) || (destinationIndex < 0)) + { + throw new ArgumentOutOfRangeException("destinationIndex"); + } + if ((sourceIndex >= array.Length) || (sourceIndex < 0)) + { + throw new ArgumentOutOfRangeException("sourceIndex"); + } + if ((destinationIndex + length > this.length) || + (sourceIndex + length > array.Length) || + (length < 1)) + { + throw new ArgumentOutOfRangeException("length"); + } + + if (isOneBit || isFourBit) + { + for (int i = 0; i != length; i++) + { + SetValueInternal(array[sourceIndex++], destinationIndex++); + } + } + else + { + GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned); + byte* src = (byte*)Marshal.UnsafeAddrOfPinnedArrayElement(array, sourceIndex); + CopyMemory(baseAddress + (size * destinationIndex), src, size * length); + handle.Free(); + } + } + + /// + /// Returns the represented block of memory as an array of . + /// + /// The represented block of memory. + public byte[] ToByteArray() + { + EnsureNotDisposed(); + byte[] result; + if (isOneBit) + { + result = new byte[(length + 7) / 8]; + } + else if (isFourBit) + { + result = new byte[(length + 3) / 4]; + } + else + { + result = new byte[size * length]; + } + fixed (byte* dst = result) + { + CopyMemory(dst, baseAddress, result.Length); + } + return result; + } + + /// + /// Gets or sets the value at the specified position in the array. + /// + /// A 32-bit integer that represents the position + /// of the array element to get. + /// The value at the specified position in the array. + /// + /// is outside the range of valid indexes + /// for the unmanaged array. + public T this[int index] + { + get + { + return GetValue(index); + } + set + { + SetValue(value, index); + } + } + + /// + /// Gets or sets the values of the unmanaged array. + /// + public T[] Data + { + get + { + return GetValues(0, length); + } + set + { + if (value == null) + { + throw new ArgumentNullException("value"); + } + if (value.Length != length) + { + throw new ArgumentOutOfRangeException("value.Lengt"); + } + SetValues(value, 0); + } + } + + /// + /// Gets the length of the unmanaged array. + /// + public int Length + { + get + { + EnsureNotDisposed(); + return length; + } + } + + /// + /// Gets the base address of the represented memory block. + /// + public IntPtr BaseAddress + { + get + { + EnsureNotDisposed(); + return new IntPtr(baseAddress); + } + } + + /// + /// Creates a shallow copy of the . + /// + /// A shallow copy of the . + public object Clone() + { + EnsureNotDisposed(); + return new MemoryArray(baseAddress, length); + } + + /// + /// Gets a 32-bit integer that represents the total number of elements + /// in the . + /// + public int Count + { + get { EnsureNotDisposed(); return length; } + } + + /// + /// Gets a value indicating whether access to the + /// is synchronized (thread safe). + /// + public bool IsSynchronized + { + get { EnsureNotDisposed(); return false; } + } + + /// + /// Gets an object that can be used to synchronize access to the . + /// + public object SyncRoot + { + get + { + EnsureNotDisposed(); + if (syncRoot == null) + { + System.Threading.Interlocked.CompareExchange(ref syncRoot, new object(), null); + } + return syncRoot; + } + } + + /// + /// Retrieves an object that can iterate through the individual + /// elements in this . + /// + /// An for the . + public IEnumerator GetEnumerator() + { + EnsureNotDisposed(); + T[] values = GetValues(0, length); + for (int i = 0; i != values.Length; i++) + { + yield return values[i]; + } + } + + /// + /// Retrieves an object that can iterate through the individual + /// elements in this . + /// + /// An for the . + IEnumerator IEnumerable.GetEnumerator() + { + EnsureNotDisposed(); + T[] values = GetValues(0, length); + for (int i = 0; i != values.Length; i++) + { + yield return values[i]; + } + } + + /// + /// Releases all ressources. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases allocated handles associated with this instance. + /// + /// true to release managed resources. + protected virtual void Dispose(bool disposing) + { + if (baseAddress != null) + { + if (handle.IsAllocated) + handle.Free(); + baseAddress = null; + buffer = null; + length = 0; + syncRoot = null; + } + } + + /// + /// Throws an if + /// this instance is disposed. + /// + protected virtual void EnsureNotDisposed() + { + if (baseAddress == null) + throw new ObjectDisposedException("This instance is disposed."); + } + + /// + /// Tests whether the specified structure is equivalent to this + /// structure. + /// + /// The structure to test. + /// true if is a + /// instance equivalent to this structure; otherwise, + /// false. + public override bool Equals(object obj) + { + EnsureNotDisposed(); + return ((obj is MemoryArray) && Equals((MemoryArray)obj)); + } + + /// + /// Tests whether the specified structure is equivalent to this + /// structure. + /// + /// The structure to test. + /// true if is equivalent to this + /// structure; otherwise, + /// false. + public bool Equals(MemoryArray other) + { + EnsureNotDisposed(); + return ((this.baseAddress == other.baseAddress) && (this.length == other.length)); + } + + /// + /// Serves as a hash function for a particular type. + /// + /// A hash code for the current . + public override int GetHashCode() + { + EnsureNotDisposed(); + return (int)baseAddress ^ length; + } + + /// + /// Copies a block of memory from one location to another. + /// + /// Pointer to the starting address of the copy destination. + /// Pointer to the starting address of the block of memory to be copied. + /// Size of the block of memory to copy, in bytes. + protected static unsafe void CopyMemory(byte* dest, byte* src, int len) + { + if (len >= 0x10) + { + do + { + *((int*)dest) = *((int*)src); + *((int*)(dest + 4)) = *((int*)(src + 4)); + *((int*)(dest + 8)) = *((int*)(src + 8)); + *((int*)(dest + 12)) = *((int*)(src + 12)); + dest += 0x10; + src += 0x10; + } + while ((len -= 0x10) >= 0x10); + } + if (len > 0) + { + if ((len & 8) != 0) + { + *((int*)dest) = *((int*)src); + *((int*)(dest + 4)) = *((int*)(src + 4)); + dest += 8; + src += 8; + } + if ((len & 4) != 0) + { + *((int*)dest) = *((int*)src); + dest += 4; + src += 4; + } + if ((len & 2) != 0) + { + *((short*)dest) = *((short*)src); + dest += 2; + src += 2; + } + if ((len & 1) != 0) + { + *dest = *src; + } + } + } + } +} + +namespace FreeImageAPI.Metadata +{ + /// + /// Base class that represents a collection of all tags contained in a metadata model. + /// + /// + /// The MetedataModel class is an abstract base class, which is inherited by + /// several derived classes, one for each existing metadata model. + /// + public abstract class MetadataModel : IEnumerable + { + /// + /// Handle to the encapsulated FreeImage-bitmap. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected readonly FIBITMAP dib; + + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + /// + /// is null. + protected MetadataModel(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + this.dib = dib; + } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public abstract FREE_IMAGE_MDMODEL Model + { + get; + } + + /// + /// Adds new tag to the bitmap or updates its value in case it already exists. + /// will be used as key. + /// + /// The tag to add or update. + /// Returns true on success, false on failure. + /// + /// is null. + /// + /// The tags model differs from this instances model. + public bool AddTag(MetadataTag tag) + { + if (tag == null) + { + throw new ArgumentNullException("tag"); + } + if (tag.Model != Model) + { + throw new ArgumentException("tag.Model"); + } + return tag.AddToImage(dib); + } + + /// + /// Adds a list of tags to the bitmap or updates their values in case they already exist. + /// will be used as key. + /// + /// A list of tags to add or update. + /// Returns the number of successfully added tags. + /// + /// is null. + public int AddTag(IEnumerable list) + { + if (list == null) + { + throw new ArgumentNullException("list"); + } + int count = 0; + foreach (MetadataTag tag in list) + { + if (tag.Model == Model && tag.AddToImage(dib)) + { + count++; + } + } + return count; + } + + /// + /// Removes the specified tag from the bitmap. + /// + /// The key of the tag. + /// Returns true on success, false on failure. + /// + /// is null. + public bool RemoveTag(string key) + { + if (key == null) + { + throw new ArgumentNullException("key"); + } + return FreeImage.SetMetadata(Model, dib, key, FITAG.Zero); + } + + /// + /// Destroys the metadata model + /// which will remove all tags of this model from the bitmap. + /// + /// Returns true on success, false on failure. + public bool DestoryModel() + { + return FreeImage.SetMetadata(Model, dib, null, FITAG.Zero); + } + + /// + /// Returns the specified metadata tag. + /// + /// The key of the tag. + /// The metadata tag. + /// + /// is null. + public MetadataTag GetTag(string key) + { + if (key == null) + { + throw new ArgumentNullException("key"); + } + MetadataTag tag; + return FreeImage.GetMetadata(Model, dib, key, out tag) ? tag : null; + } + + /// + /// Returns whether the specified tag exists. + /// + /// The key of the tag. + /// True in case the tag exists, else false. + /// + /// is null. + public bool TagExists(string key) + { + if (key == null) + { + throw new ArgumentNullException("key"); + } + MetadataTag tag; + return FreeImage.GetMetadata(Model, dib, key, out tag); + } + + /// + /// Returns a list of all metadata tags this instance represents. + /// + public List List + { + get + { + List list = new List((int)FreeImage.GetMetadataCount(Model, dib)); + MetadataTag tag; + FIMETADATA mdHandle = FreeImage.FindFirstMetadata(Model, dib, out tag); + if (!mdHandle.IsNull) + { + do + { + list.Add(tag); + } + while (FreeImage.FindNextMetadata(mdHandle, out tag)); + FreeImage.FindCloseMetadata(mdHandle); + } + return list; + } + } + + /// + /// Returns the tag at the given index. + /// + /// Index of the tag to return. + /// The tag at the given index. + protected MetadataTag GetTagFromIndex(int index) + { + if (index >= Count || index < 0) + { + throw new ArgumentOutOfRangeException("index"); + } + MetadataTag tag; + int count = 0; + FIMETADATA mdHandle = FreeImage.FindFirstMetadata(Model, dib, out tag); + if (!mdHandle.IsNull) + { + try + { + do + { + if (count++ == index) + { + break; + } + } + while (FreeImage.FindNextMetadata(mdHandle, out tag)); + } + finally + { + FreeImage.FindCloseMetadata(mdHandle); + } + } + return tag; + } + + /// + /// Returns the metadata tag at the given index. This operation is slow when accessing all tags. + /// + /// Index of the tag. + /// The metadata tag. + /// + /// is greater or equal Count + /// or index is less than zero. + public MetadataTag this[int index] + { + get + { + return GetTagFromIndex(index); + } + } + + /// + /// Retrieves an object that can iterate through the individual MetadataTags in this MetadataModel. + /// + /// An for the + /// . + public IEnumerator GetEnumerator() + { + return List.GetEnumerator(); + } + + /// + /// Returns the number of metadata tags this instance represents. + /// + public int Count + { + get { return (int)FreeImage.GetMetadataCount(Model, dib); } + } + + /// + /// Returns whether this model exists in the bitmaps metadata structure. + /// + public bool Exists + { + get + { + return Count > 0; + } + } + + /// + /// Searches for a pattern in each metadata tag and returns the result as a list. + /// + /// The regular expression to use for the search. + /// A bitfield that controls which fields should be searched in. + /// A list containing all found metadata tags. + /// + /// is null. + /// + /// is empty. + public List RegexSearch(string searchPattern, MD_SEARCH_FLAGS flags) + { + if (searchPattern == null) + { + throw new ArgumentNullException("searchString"); + } + if (searchPattern.Length == 0) + { + throw new ArgumentException("searchString is empty"); + } + List result = new List(Count); + Regex regex = new Regex(searchPattern); + List list = List; + foreach (MetadataTag tag in list) + { + if (((flags & MD_SEARCH_FLAGS.KEY) > 0) && regex.Match(tag.Key).Success) + { + result.Add(tag); + continue; + } + if (((flags & MD_SEARCH_FLAGS.DESCRIPTION) > 0) && regex.Match(tag.Description).Success) + { + result.Add(tag); + continue; + } + if (((flags & MD_SEARCH_FLAGS.TOSTRING) > 0) && regex.Match(tag.ToString()).Success) + { + result.Add(tag); + continue; + } + } + result.Capacity = result.Count; + return result; + } + + /// + /// Returns the value of the specified tag. + /// + /// Type of the tag's data. + /// The key of the tag. + /// The value of the specified tag. + protected T? GetTagValue(string key) where T : struct + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + MetadataTag tag = GetTag(key); + if (tag != null) + { + T[] value = tag.Value as T[]; + if ((value != null) && (value.Length != 0)) + { + return value[0]; + } + } + return null; + } + + /// + /// Returns an array containing the data of the specified tag. + /// + /// The type of the tag's data. + /// The key of the tag. + /// An array containing the data of the specified tag. + protected T[] GetTagArray(string key) where T : struct + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + MetadataTag tag = GetTag(key); + return (tag == null) ? null : tag.Value as T[]; + } + + /// + /// Returns the string contained by the specified tag. + /// + /// The key of the tag. + /// The string contained by the specified tag. + protected string GetTagText(string key) + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + MetadataTag tag = GetTag(key); + return (tag == null) ? null : tag.Value as string; + } + + /// + /// Returns an array containg the data of the specified tag + /// as unsigned 32bit integer. + /// + /// The key of the tag. + /// An array containg the data of the specified tag + /// as unsigned 32bit integer. + protected uint[] GetUInt32Array(string key) + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + uint[] result = null; + MetadataTag tag = GetTag(key); + if (tag != null) + { + object value = tag.Value; + if (value != null) + { + if (value is ushort[]) + { + ushort[] array = (ushort[])value; + result = new uint[array.Length]; + for (int i = 0, j = array.Length; i < j; i++) + { + result[i] = (uint)array[i]; + } + } + else if (value is uint[]) + { + result = (uint[])value; + } + } + } + return result; + } + + /// + /// Returns the value of the tag as unsigned 32bit integer. + /// + /// The key of the tag. + /// The value of the tag as unsigned 32bit integer. + protected uint? GetUInt32Value(string key) + { + uint[] value = GetUInt32Array(key); + return value == null ? default(uint?) : value[0]; + } + + /// + /// Sets the value of the specified tag. + /// + /// The type of the tag's data. + /// The key of the tag. + /// The new value of the specified tag or null. + protected void SetTagValue(string key, T? value) where T : struct + { + SetTagValue(key, value.HasValue ? new T[] { value.Value } : null); + } + + /// + /// Sets the value of the specified tag. + /// + /// The key of the tag. + /// The new value of the specified tag or null. + protected void SetTagValue(string key, object value) + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + if (value == null) + { + RemoveTag(key); + } + else + { + MetadataTag tag = GetTag(key); + if (tag == null) + { + tag = new MetadataTag(Model); + tag.Key = key; + tag.Value = value; + AddTag(tag); + } + else + { + tag.Value = value; + } + } + } + + /// + /// Sets the value of the specified tag as undefined. + /// + /// The key of the tag. + /// The new value of the specified tag or null. + protected void SetTagValueUndefined(string key, byte[] value) + { + if (string.IsNullOrEmpty(key)) + { + throw new ArgumentNullException("key"); + } + if (value == null) + { + RemoveTag(key); + } + else + { + MetadataTag tag = GetTag(key); + if (tag == null) + { + tag = new MetadataTag(Model); + tag.Key = key; + tag.SetValue(value, FREE_IMAGE_MDTYPE.FIDT_UNDEFINED); + AddTag(tag); + } + else + { + tag.Value = value; + } + } + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The string containing the . + /// The equivalent for the + /// specified . + protected static DirectionReference? ToDirectionType(string s) + { + if (string.IsNullOrEmpty(s)) + return null; + switch (s[0]) + { + case 'T': + return DirectionReference.TrueDirection; + case 'M': + return DirectionReference.MagneticDirection; + default: + return DirectionReference.Undefined; + } + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The to convert. + /// The equivalent for the + /// specified . + protected static string ToString(DirectionReference? type) + { + if (type.HasValue) + { + switch (type.Value) + { + case DirectionReference.TrueDirection: + return "T"; + case DirectionReference.MagneticDirection: + return "M"; + default: + return "\0"; + } + } + return null; + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The string containing the . + /// The equivalent for the + /// specified . + protected static VelocityUnit? ToUnitType(string s) + { + if (string.IsNullOrEmpty(s)) + return null; + switch (s[0]) + { + case 'K': + return VelocityUnit.Kilometers; + case 'M': + return VelocityUnit.Miles; + case 'N': + return VelocityUnit.Knots; + default: + return VelocityUnit.Undefinied; + } + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The to convert. + /// The equivalent for the + /// specified . + protected static string ToString(VelocityUnit? type) + { + if (type.HasValue) + { + switch (type.Value) + { + case VelocityUnit.Kilometers: + return "K"; + case VelocityUnit.Miles: + return "M"; + case VelocityUnit.Knots: + return "N"; + default: + return "\0"; + } + } + return null; + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The string containing the . + /// The equivalent for the + /// specified . + protected static LongitudeType? ToLongitudeType(string s) + { + if (string.IsNullOrEmpty(s)) + return null; + switch (s[0]) + { + case 'E': + return LongitudeType.East; + case 'W': + return LongitudeType.West; + default: + return LongitudeType.Undefined; + } + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The to convert. + /// The equivalent for the + /// specified . + protected static string ToString(LongitudeType? type) + { + if (type.HasValue) + { + switch (type.Value) + { + case LongitudeType.East: + return "E"; + case LongitudeType.West: + return "W"; + default: + return "\0"; + } + } + return null; + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The string containing the . + /// The equivalent for the + /// specified . + protected static LatitudeType? ToLatitudeType(string s) + { + if (string.IsNullOrEmpty(s)) + return null; + switch (s[0]) + { + case 'N': + return LatitudeType.North; + case 'S': + return LatitudeType.South; + default: + return LatitudeType.Undefined; + } + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The to convert. + /// The equivalent for the + /// specified . + protected static string ToString(LatitudeType? type) + { + if (type.HasValue) + { + switch (type.Value) + { + case LatitudeType.North: + return "N"; + case LatitudeType.South: + return "S"; + default: + return "\0"; + } + } + return null; + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The string containing the . + /// The equivalent for the + /// specified . + protected static InteroperabilityMode? ToInteroperabilityType(string s) + { + if (string.IsNullOrEmpty(s)) + return null; + if (s.StartsWith("R98")) + return InteroperabilityMode.R98; + if (s.StartsWith("THM")) + return InteroperabilityMode.THM; + return InteroperabilityMode.Undefined; + } + + /// + /// Returns the equivalent for the + /// specified . + /// + /// The to convert. + /// The equivalent for the + /// specified . + protected static string ToString(InteroperabilityMode? type) + { + if (type.HasValue) + { + switch (type.Value) + { + case InteroperabilityMode.R98: + return "R98"; + case InteroperabilityMode.THM: + return "THM"; + default: + return "\0\0\0"; + } + } + return null; + } + + /// + /// Specified different unit types. + /// + public enum VelocityUnit + { + /// + /// No or unknown type. + /// + Undefinied, + + /// + /// Kilometers per hour. + /// + Kilometers, + + /// + /// Miles per hour. + /// + Miles, + + /// + /// Knots. + /// + Knots, + } + + /// + /// Specifies different direction types. + /// + public enum DirectionReference + { + /// + /// No or unknown direction type. + /// + Undefined, + + /// + /// True direction. + /// + TrueDirection, + + /// + /// Magnatic direction. + /// + MagneticDirection, + } + + /// + /// Specifies the type of a latitude value. + /// + public enum LatitudeType + { + /// + /// No or unknown type. + /// + Undefined, + + /// + /// North. + /// + North, + + /// + /// South. + /// + South, + } + + /// + /// Specifies the type of a longitude value. + /// + public enum LongitudeType + { + /// + /// No or unknown type. + /// + Undefined, + + /// + /// East. + /// + East, + + /// + /// West. + /// + West, + } + + /// + /// Specifies different altitude types. + /// + public enum AltitudeType + { + /// + /// No or unknown type. + /// + Undefined, + + /// + /// East. + /// + AboveSeaLevel, + + /// + /// West. + /// + BelowSeaLevel, + } + + /// + /// Specifies interoperability types. + /// + public enum InteroperabilityMode + { + /// + /// No or unknown type. + /// + Undefined, + + /// + /// Indicates a file conforming to R98 file specification of Recommended + /// Exif Interoperability Rules (ExifR98) or to DCF basic file stipulated + /// by Design Rule for Camera File System. + /// + R98, + + /// + /// Indicates a file conforming to DCF thumbnail file stipulated by Design + /// rule for Camera File System. + /// + THM, + } + + /// + /// Specifies orientation of images. + /// + public enum ExifImageOrientation : ushort + { + /// + /// Undefinied orientation. + /// + Undefined, + + /// + /// TopLeft. + /// + TopLeft = 1, + + /// + /// TopRight. + /// + TopRight, + + /// + /// BottomRight. + /// + BottomRight, + + /// + /// BottomLeft. + /// + BottomLeft, + + /// + /// LeftTop. + /// + LeftTop, + + /// + /// RightTop. + /// + RightTop, + + /// + /// RightBottom. + /// + RightBottom, + + /// + /// LeftBottom. + /// + LeftBottom, + } + + /// + /// Converts the model of the MetadataModel object to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + return Model.ToString(); + } + } +} + + #region Metadata Models + +namespace FreeImageAPI.Metadata +{ + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_ANIMATION : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_ANIMATION(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_ANIMATION; } + } + + /// + /// Gets or sets the width of the entire canvas area, that each page is displayed in. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? LogicalWidth + { + get + { + return GetTagValue("LogicalWidth"); + } + set + { + SetTagValue("LogicalWidth", value); + } + } + + /// + /// Gets or sets the height of the entire canvas area, that each page is displayed in. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? LogicalHeight + { + get + { + return GetTagValue("LogicalHeight"); + } + set + { + SetTagValue("LogicalHeight", value); + } + } + + /// + /// Gets or sets the global palette of the GIF image. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public Palette GlobalPalette + { + get + { + MetadataTag mdtag = GetTag("GlobalPalette"); + return (mdtag == null) ? null : new Palette(mdtag); + } + set + { + SetTagValue("GlobalPalette", (value != null) ? null : value.Data); + } + } + + /// + /// Gets or sets the number of replays for the animation. + /// Use 0 (zero) to specify an infinte number of replays. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? LoopCount + { + get + { + return GetTagValue("Loop"); + } + set + { + SetTagValue("Loop", value); + } + } + + /// + /// Gets or sets the horizontal offset within the logical canvas area, this frame is to be displayed at. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? FrameLeft + { + get + { + return GetTagValue("FrameLeft"); + } + set + { + SetTagValue("FrameLeft", value); + } + } + + /// + /// Gets or sets the vertical offset within the logical canvas area, this frame is to be displayed at. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? FrameTop + { + get + { + return GetTagValue("FrameTop"); + } + set + { + SetTagValue("FrameTop", value); + } + } + + /// + /// Gets or sets a flag to supress saving the dib's attached palette + /// (making it use the global palette). The local palette is the palette used by a page. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? NoLocalPalette + { + get + { + byte? useGlobalPalette = GetTagValue("NoLocalPalette"); + return useGlobalPalette.HasValue ? (useGlobalPalette.Value != 0) : default(bool?); + } + set + { + byte? val = null; + if (value.HasValue) + { + val = (byte)(value.Value ? 1 : 0); + } + SetTagValue("NoLocalPalette", val); + } + } + + /// + /// Gets or sets a value indicating whether the image is interlaced. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? Interlaced + { + get + { + byte? useGlobalPalette = GetTagValue("Interlaced"); + return useGlobalPalette.HasValue ? (useGlobalPalette.Value != 0) : default(bool?); + } + set + { + byte? val = null; + if (value.HasValue) + { + val = (byte)(value.Value ? 1 : 0); + } + SetTagValue("Interlaced", val); + } + } + + /// + /// Gets or sets the amout of time in milliseconds this frame is to be displayed. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? FrameTime + { + get + { + return GetTagValue("FrameTime"); + } + set + { + SetTagValue("FrameTime", value); + } + } + + /// + /// Gets or sets this frame's disposal method. Generally, this method defines, how to + /// remove or replace a frame when the next frame has to be drawn. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public DisposalMethodType? DisposalMethod + { + get + { + return GetTagValue("DisposalMethod"); + } + set + { + SetTagValue("DisposalMethod", value); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_COMMENTS : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_COMMENTS(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_COMMENTS; } + } + + /// + /// Gets or sets the comment of the image. + /// Supported formats are JPEG, PNG and GIF. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Comment + { + get + { + return GetTagText("Comment"); + } + set + { + SetTagValue("Comment", value); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_CUSTOM : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_CUSTOM(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_CUSTOM; } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_EXIF_EXIF : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_EXIF_EXIF(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF; } + } + + /// + /// Gets or sets the version of this standard supported. + /// Constant length or 4. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] ExifVersion + { + get + { + return GetTagArray("ExifVersion"); + } + set + { + FreeImage.Resize(ref value, 4); + SetTagValueUndefined("ExifVersion", value); + } + } + + /// + /// Gets or sets the Flashpix format version supported by a FPXR file. + /// Constant length or 4. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] FlashpixVersion + { + get + { + return GetTagArray("FlashpixVersion"); + } + set + { + FreeImage.Resize(ref value, 4); + SetTagValueUndefined("FlashpixVersion", value); + } + } + + /// + /// Gets or sets the color space information tag. + /// See remarks for further information. + /// + /// + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 1 + /// sRGB (default) + /// + /// + /// 0xFFFF + /// uncalibrated + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? ColorSpace + { + get + { + return GetTagValue("ColorSpace"); + } + set + { + SetTagValue("ColorSpace", value); + } + } + + /// + /// Gets or sets the valid width of a compressed image. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? PixelXDimension + { + get + { + return GetUInt32Value("PixelXDimension"); + } + set + { + RemoveTag("PixelXDimension"); + if (value.HasValue) + { + SetTagValue("PixelXDimension", value.Value); + } + } + } + + /// + /// Gets or sets the valid height of a compressed image. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? PixelYDimension + { + get + { + return GetUInt32Value("PixelYDimension"); + } + set + { + RemoveTag("PixelYDimension"); + if (value.HasValue) + { + SetTagValue("PixelYDimension", value.Value); + } + } + } + + /// + /// Gets or sets components configuration. See remarks for further information. + /// Constant length of 4. + /// + /// + /// The channels of each component are arranged in order from the 1st component to the 4th. + /// For uncompressed data the data arrangement is given in the PhotometricInterpretation tag. + /// However, since PhotometricInterpretation can only express the order of Y,Cb and Cr, + /// this tag is provided for cases when compressed data uses components other than Y, Cb, + /// and Cr and to enable support of other sequences. + /// Default = 4 5 6 0 (if RGB uncompressed) + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// does not exist + /// + /// + /// 1 + /// Y + /// + /// + /// 2 + /// Cb + /// + /// + /// 3 + /// Cr + /// + /// + /// 4 + /// R + /// + /// + /// 5 + /// R + /// + /// + /// 6 + /// R + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public byte[] ComponentsConfiguration + { + get + { + return GetTagArray("ComponentsConfiguration"); + } + set + { + FreeImage.Resize(ref value, 4); + SetTagValueUndefined("ComponentsConfiguration", value); + } + } + + /// + /// Gets or sets compression mode used for a compressed image is indicated + /// in unit bits per pixel. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? CompressedBitsPerPixel + { + get + { + return GetTagValue("CompressedBitsPerPixel"); + } + set + { + SetTagValue("CompressedBitsPerPixel", value); + } + } + + /// + /// Gets or sets a tag for manufacturers of Exif writers to record any desired information. + /// The contents are up to the manufacturer, but this tag should not be used for any other + /// than its intended purpose. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] MakerNote + { + get + { + return GetTagArray("FlashpixVersion"); + } + set + { + SetTagValueUndefined("FlashpixVersion", value); + } + } + + /// + /// Gets or sets a tag for Exif users to write keywords or comments on the image besides + /// those in ImageDescription, and without the character code limitations of the ImageDescription tag. + /// Minimum length of 8. See remarks for further information. + /// + /// + /// The character code used in the UserComment tag is identified based on an ID code in a fixed 8-byte + /// area at the start of the tag data area. The unused portion of the area is padded with NULL. + /// The ID code for the UserComment area may be a Defined code such as JIS or ASCII, or may be Undefined. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public byte[] UserComment + { + get + { + return GetTagArray("UserComment"); + } + set + { + FreeImage.Resize(ref value, 8, int.MaxValue); + SetTagValueUndefined("UserComment", value); + } + } + + /// + /// Gets or sets the name of an audio file related to the image data. + /// The format is 8.3. + /// Constant length of 12 + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string RelatedSoundFile + { + get + { + string text = GetTagText("RelatedSoundFile"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + FreeImage.Resize(ref value, 12); + value += '\0'; + } + SetTagValue("RelatedSoundFile", value); + } + } + + /// + /// Gets or sets the date and time when the original image data was generated. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public DateTime? DateTimeOriginal + { + get + { + DateTime? result = null; + string text = GetTagText("DateTimeOriginal"); + if (text != null) + { + try + { + result = System.DateTime.ParseExact(text, "yyyy:MM:dd HH:mm:ss\0", null); + } + catch + { + } + } + return result; + } + set + { + string val = null; + if (value.HasValue) + { + try + { + val = value.Value.ToString("yyyy:MM:dd HH:mm:ss\0"); + } + catch + { + } + } + SetTagValue("DateTimeOriginal", val); + } + } + + /// + /// Gets or sets the date and time when the image was stored as digital data. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public DateTime? DateTimeDigitized + { + get + { + DateTime? result = null; + string text = GetTagText("DateTimeDigitized"); + if (text != null) + { + try + { + result = System.DateTime.ParseExact(text, "yyyy:MM:dd HH:mm:ss\0", null); + } + catch + { + } + } + return result; + } + set + { + string val = null; + if (value.HasValue) + { + try + { + val = value.Value.ToString("yyyy:MM:dd HH:mm:ss\0"); + } + catch + { + } + } + SetTagValue("DateTimeDigitized", val); + } + } + + /// + /// Gets or sets a tag used to record fractions of seconds for the DateTime tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SubsecTime + { + get + { + string text = GetTagText("SubsecTime"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("SubsecTime", value); + } + } + + /// + /// Gets or sets a tag used to record fractions of seconds for the DateTimeOriginal tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SubsecTimeOriginal + { + get + { + string text = GetTagText("SubsecTimeOriginal"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("SubsecTimeOriginal", value); + } + } + + /// + /// Gets or sets a tag used to record fractions of seconds for the DateTimeDigitized tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SubsecTimeDigitized + { + get + { + string text = GetTagText("SubsecTimeDigitized"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("SubsecTimeDigitized", value); + } + } + + /// + /// Gets or the exposure time, given in seconds (sec). + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? ExposureTime + { + get + { + return GetTagValue("ExposureTime"); + } + set + { + SetTagValue("ExposureTime", value); + } + } + + /// + /// Gets or the F number. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? FNumber + { + get + { + return GetTagValue("FNumber"); + } + set + { + SetTagValue("FNumber", value); + } + } + + /// + /// Gets or sets the class of the program used by the camera to set exposure when the + /// picture is taken. + /// See remarks for further information. + /// + /// + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// not defined + /// + /// + /// 1 + /// manual + /// + /// + /// 2 + /// normal program + /// + /// + /// 3 + /// aperture priority + /// + /// + /// 4 + /// shutter priority + /// + /// + /// 5 + /// create program + /// + /// + /// 6 + /// action program + /// + /// + /// 7 + /// portrait mode + /// + /// + /// 8 + /// landscape mode + /// + /// + /// others + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? ExposureProgram + { + get + { + return GetTagValue("ExposureProgram"); + } + set + { + SetTagValue("ExposureProgram", value); + } + } + + /// + /// Gets or sets the spectral sensitivity of each channel of the camera used. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SpectralSensitivity + { + get + { + string text = GetTagText("SpectralSensitivity"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("SpectralSensitivity", value); + } + } + + /// + /// Gets or sets the the ISO Speed and ISO Latitude of the camera or input device as + /// specified in ISO 12232. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort[] ISOSpeedRatings + { + get + { + return GetTagArray("ISOSpeedRatings"); + } + set + { + SetTagValue("ISOSpeedRatings", value); + } + } + + /// + /// Gets or sets the Opto-Electric Conversion Function (OECF) specified in ISO 14524. + /// OECF is the relationship between the camera optical input and the image values. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] OECF + { + get + { + return GetTagArray("OECF"); + } + set + { + SetTagValueUndefined("OECF", value); + } + } + + /// + /// Gets or sets the shutter speed. The unit is the APEX (Additive System of Photographic Exposure). + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIRational? ShutterSpeedValue + { + get + { + return GetTagValue("ShutterSpeedValue"); + } + set + { + SetTagValue("ShutterSpeedValue", value); + } + } + + /// + /// Gets or sets the lens aperture. The unit is the APEX value. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? ApertureValue + { + get + { + return GetTagValue("ApertureValue"); + } + set + { + SetTagValue("ApertureValue", value); + } + } + + /// + /// Gets or sets the value of brightness. The unit is the APEX value. + /// Ordinarily it is given in the range of -99.99 to 99.99. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIRational? BrightnessValue + { + get + { + return GetTagValue("BrightnessValue"); + } + set + { + SetTagValue("BrightnessValue", value); + } + } + + /// + /// Gets or sets the exposure bias. The unit is the APEX value. + /// Ordinarily it is given in the range of �99.99 to 99.99. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIRational? ExposureBiasValue + { + get + { + return GetTagValue("ExposureBiasValue"); + } + set + { + SetTagValue("ExposureBiasValue", value); + } + } + + /// + /// Gets or sets the smallest F number of the lens. The unit is the APEX value. + /// Ordinarily it is given in the range of 00.00 to 99.99, + /// but it is not limited to this range. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? MaxApertureValue + { + get + { + return GetTagValue("MaxApertureValue"); + } + set + { + SetTagValue("MaxApertureValue", value); + } + } + + /// + /// Gets or sets distance to the subject, given in meters. + /// Note that if the numerator of the recorded value is FFFFFFFF, infinity shall be indicated; + /// and if the numerator is 0, distance unknown shall be indicated. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? SubjectDistance + { + get + { + return GetTagValue("SubjectDistance"); + } + set + { + SetTagValue("SubjectDistance", value); + } + } + + /// + /// Gets or sets the metering mode. See remarks for further information. + /// + /// + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// unknown + /// + /// + /// 1 + /// average + /// + /// + /// 2 + /// center-weighted-average + /// + /// + /// 3 + /// spot + /// + /// + /// 4 + /// multi-spot + /// + /// + /// 5 + /// pattern + /// + /// + /// 6 + /// partial + /// + /// + /// other + /// reserved + /// + /// + /// 255 + /// other + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? MeteringMode + { + get + { + return GetTagValue("MeteringMode"); + } + set + { + SetTagValue("MeteringMode", value); + } + } + + /// + /// Gets or sets the kind of light source. + /// See remarks for further information. + /// + /// + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// unknown + /// + /// + /// 1 + /// daylight + /// + /// + /// 2 + /// fluorescent + /// + /// + /// 3 + /// tungsten + /// + /// + /// 4 + /// flash + /// + /// + /// 9 + /// fine weather + /// + /// + /// 10 + /// cloudy weather + /// + /// + /// 11 + /// shade + /// + /// + /// 12 + /// daylight fluorecent (D 5700 - 7100K) + /// + /// + /// 13 + /// day white fluorescent (N 4600 - 5400K) + /// + /// + /// 14 + /// cool white fluorescent (W 3900 - 4500K) + /// + /// + /// 15 + /// white fluorescent (WW 3200 - 3700K) + /// + /// + /// 17 + /// standard light A + /// + /// + /// 18 + /// standard light B + /// + /// + /// 19 + /// standard light C + /// + /// + /// 20 + /// D55 + /// + /// + /// 21 + /// D65 + /// + /// + /// 22 + /// D75 + /// + /// + /// 23 + /// D50 + /// + /// + /// 24 + /// ISO studio tungsten + /// + /// + /// 255 + /// other light source + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? LightSource + { + get + { + return GetTagValue("LightSource"); + } + set + { + SetTagValue("LightSource", value); + } + } + + /// + /// Gets or sets a value indicating the status of flash when the image was shot. + /// Bit 0 indicates the flash firing status, bits 1 and 2 indicate the flash return + /// status, bits 3 and 4 indicate the flash mode, bit 5 indicates whether the flash + /// function is present, and bit 6 indicates "red eye" mode. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? Flash + { + get + { + return GetTagValue("Flash"); + } + set + { + SetTagValue("Flash", value); + } + } + + /// + /// Gets or sets a value indicating the location and area of the main subject in + /// the overall scene. Variable length between 2 and 4. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort[] SubjectArea + { + get + { + return GetTagArray("SubjectArea"); + } + set + { + FreeImage.Resize(ref value, 2, 4); + SetTagValue("SubjectArea", value); + } + } + + /// + /// Gets or sets the actual focal length of the lens, in mm. + /// Conversion is not made to the focal length of a 35 mm film camera. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? FocalLength + { + get + { + return GetTagValue("FocalLength"); + } + set + { + SetTagValue("FocalLength", value); + } + } + + /// + /// Gets or sets the strobe energy at the time the image is captured, + /// as measured in Beam Candle Power Seconds (BCPS). + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? FlashEnergy + { + get + { + return GetTagValue("FlashEnergy"); + } + set + { + SetTagValue("FlashEnergy", value); + } + } + + /// + /// Gets or sets the camera or input device spatial frequency table and SFR values + /// in the direction of image width, image height, and diagonal direction, + /// as specified in ISO 12233. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] SpatialFrequencyResponse + { + get + { + return GetTagArray("SpatialFrequencyResponse"); + } + set + { + SetTagValueUndefined("SpatialFrequencyResponse", value); + } + } + + /// + /// Gets or sets the number of pixels in the image width (X) direction per + /// FocalPlaneResolutionUnit on the camera focal plane. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? FocalPlaneXResolution + { + get + { + return GetTagValue("FocalPlaneXResolution"); + } + set + { + SetTagValue("FocalPlaneXResolution", value); + } + } + + /// + /// Gets or sets the number of pixels in the image height (Y) direction per + /// FocalPlaneResolutionUnit on the camera focal plane. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? FocalPlaneYResolution + { + get + { + return GetTagValue("FocalPlaneYResolution"); + } + set + { + SetTagValue("FocalPlaneYResolution", value); + } + } + + /// + /// Gets or sets the unit for measuring FocalPlaneXResolution and FocalPlaneYResolution. + /// This value is the same as the ResolutionUnit. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? FocalPlaneResolutionUnit + { + get + { + return GetTagValue("FocalPlaneResolutionUnit"); + } + set + { + SetTagValue("FocalPlaneResolutionUnit", value); + } + } + + /// + /// Gets or sets the location of the main subject in the scene. + /// The value of this tag represents the pixel at the center of the main subject + /// relative to the left edge, prior to rotation processing as per the Rotation tag. + /// The first value indicates the X column number and second indicates the Y row number. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? SubjectLocation + { + get + { + return GetTagValue("SubjectLocation"); + } + set + { + SetTagValue("SubjectLocation", value); + } + } + + /// + /// Gets or sets the exposure index selected on the camera or input device at the + /// time the image was captured. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? ExposureIndex + { + get + { + return GetTagValue("ExposureIndex"); + } + set + { + SetTagValue("ExposureIndex", value); + } + } + + /// + /// Gets or sets the image sensor type on the camera or input device. + /// See remarks for further information. + /// + /// + /// The following values are defined: + /// + /// + /// ID + /// Description + /// + /// + /// 1 + /// not defined + /// + /// + /// 2 + /// one-chip color area sensor + /// + /// + /// 3 + /// two-chip color area sensor + /// + /// + /// 4 + /// three-chip color area sensor + /// + /// + /// 5 + /// color sequential area sensor + /// + /// + /// 7 + /// trilinear sensor + /// + /// + /// 8 + /// color sequential linear sensor + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? SensingMethod + { + get + { + return GetTagValue("SensingMethod"); + } + set + { + SetTagValue("SensingMethod", value); + } + } + + /// + /// Gets or sets the image source. If a DSC recorded the image, this tag value of this + /// tag always be set to 3, indicating that the image was recorded on a DSC. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte? FileSource + { + get + { + return GetTagValue("FileSource"); + } + set + { + SetTagValueUndefined("FileSource", value.HasValue ? new byte[] { value.Value } : null); + } + } + + /// + /// Gets or sets the type of scene. If a DSC recorded the image, this tag value shall + /// always be set to 1, indicating that the image was directly photographed. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte? SceneType + { + get + { + return GetTagValue("SceneType"); + } + set + { + SetTagValueUndefined("SceneType", value.HasValue ? new byte[] { value.Value } : null); + } + } + + /// + /// Gets or sets the color filter array (CFA) geometric pattern of the image sensor + /// when a one-chip color area sensor is used. It does not apply to all sensing methods. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] CFAPattern + { + get + { + return GetTagArray("CFAPattern"); + } + set + { + SetTagValueUndefined("CFAPattern", value); + } + } + + /// + /// Gets or sets the use of special processing on image data, such as rendering geared to output. + /// When special processing is performed, the reader is expected to disable or minimize any + /// further processing. See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// normal process + /// + /// + /// 1 + /// custom process + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? CustomRendered + { + get + { + return GetTagValue("CustomRendered"); + } + set + { + SetTagValue("CustomRendered", value); + } + } + + /// + /// Gets or sets the exposure mode set when the image was shot. + /// In auto-bracketing mode, the camera shoots a series of frames of the same scene + /// at different exposure settings. See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// auto exposure + /// + /// + /// 1 + /// manual exposure + /// + /// + /// 2 + /// auto bracket + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? ExposureMode + { + get + { + return GetTagValue("ExposureMode"); + } + set + { + SetTagValue("ExposureMode", value); + } + } + + /// + /// Gets or sets the white balance mode set when the image was shot. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// auto white balance + /// + /// + /// 1 + /// manual white balance + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? WhiteBalance + { + get + { + return GetTagValue("WhiteBalance"); + } + set + { + SetTagValue("WhiteBalance", value); + } + } + + /// + /// Gets or sets the digital zoom ratio when the image was shot. + /// If the numerator of the recorded value is 0, this indicates that digital zoom was not used. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? DigitalZoomRatio + { + get + { + return GetTagValue("DigitalZoomRatio"); + } + set + { + SetTagValue("DigitalZoomRatio", value); + } + } + + /// + /// Gets or sets the equivalent focal length assuming a 35mm film camera, in mm. + /// A value of 0 means the focal length is unknown. Note that this tag differs + /// from the FocalLength tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? FocalLengthIn35mmFilm + { + get + { + return GetTagValue("DigitalZoomRatio"); + } + set + { + SetTagValue("DigitalZoomRatio", value); + } + } + + /// + /// Gets or sets the type of scene that was shot. + /// It can also be used to record the mode in which the image was shot. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// standard + /// + /// + /// 1 + /// landscape + /// + /// + /// 2 + /// portrait + /// + /// + /// 3 + /// night scene + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? SceneCaptureType + { + get + { + return GetTagValue("SceneCaptureType"); + } + set + { + SetTagValue("SceneCaptureType", value); + } + } + + /// + /// Gets or sets the degree of overall image gain adjustment. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// none + /// + /// + /// 1 + /// low gain up + /// + /// + /// 2 + /// high gain up + /// + /// + /// 3 + /// low gain down + /// + /// + /// 4 + /// high gain down + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? GainControl + { + get + { + return GetTagValue("GainControl"); + } + set + { + SetTagValue("GainControl", value); + } + } + + /// + /// Gets or sets the direction of contrast processing applied by the camera + /// when the image was shot. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// normal + /// + /// + /// 1 + /// soft + /// + /// + /// 2 + /// hard + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? Contrast + { + get + { + return GetTagValue("Contrast"); + } + set + { + SetTagValue("Contrast", value); + } + } + + /// + /// Gets or sets the direction of saturation processing applied by the camera + /// when the image was shot. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// normal + /// + /// + /// 1 + /// low saturation + /// + /// + /// 2 + /// high saturation + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? Saturation + { + get + { + return GetTagValue("Saturation"); + } + set + { + SetTagValue("Saturation", value); + } + } + + /// + /// Gets or sets the direction of sharpness processing applied by the camera + /// when the image was shot. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// normal + /// + /// + /// 1 + /// soft + /// + /// + /// 2 + /// hard + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? Sharpness + { + get + { + return GetTagValue("Sharpness"); + } + set + { + SetTagValue("Sharpness", value); + } + } + + /// + /// Gets or sets information on the picture-taking conditions of a particular camera model. + /// The tag is used only to indicate the picture-taking conditions in the reader. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] DeviceSettingDescription + { + get + { + return GetTagArray("DeviceSettingDescription"); + } + set + { + SetTagValueUndefined("DeviceSettingDescription", value); + } + } + + /// + /// Gets or sets the distance to the subject. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 0 + /// unknown + /// + /// + /// 1 + /// macro + /// + /// + /// 2 + /// close view + /// + /// + /// 3 + /// distant view + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? SubjectDistanceRange + { + get + { + return GetTagValue("SubjectDistanceRange"); + } + set + { + SetTagValue("SubjectDistanceRange", value); + } + } + + /// + /// Gets or sets an identifier assigned uniquely to each image. + /// It is recorded as an ASCII string equivalent to hexadecimal notation and 128-bit fixed length. + /// Constant length of 32. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ImageUniqueID + { + get + { + string text = GetTagText("ImageUniqueID"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + FreeImage.Resize(ref value, 32); + value += '\0'; + } + SetTagValue("ImageUniqueID", value); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_EXIF_GPS : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_EXIF_GPS(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_EXIF_GPS; } + } + + /// + /// Gets or sets the GPS version ID. Constant length of 4. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] VersionID + { + get + { + return GetTagArray("GPSVersionID"); + } + set + { + FreeImage.Resize(ref value, 4); + SetTagValue("GPSVersionID", value); + } + } + + /// + /// Gets or sets a value indicating whether the + /// is north or south latitude. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public LatitudeType? LatitudeDirection + { + get + { + return ToLatitudeType(GetTagText("GPSLatitudeRef")); + } + set + { + SetTagValue("GPSLatitudeRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the latitude of the image. The latitude is expressed as three rational + /// values giving the degrees, minutes, and seconds, respectively. Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational[] Latitude + { + get + { + return GetTagArray("GPSLatitude"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("GPSLatitude", value); + } + } + + /// + /// Gets or sets a value indicating whether + /// is east or west longitude. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public LongitudeType? LongitudeDirection + { + get + { + return ToLongitudeType(GetTagText("GPSLongitudeRef")); + } + set + { + SetTagValue("GPSLongitudeRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the longitude of the image. The longitude is expressed as three rational + /// values giving the degrees, minutes, and seconds, respectively. Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational[] Longitude + { + get + { + return GetTagArray("GPSLongitude"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("GPSLongitude", value); + } + } + + /// + /// Gets a value indicating whether is sea level and the altitude + /// is above sea level. If the altitude is below sea level is + /// indicated as an absolute value. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public AltitudeType? AltitudeDirection + { + get + { + byte? flag = GetTagValue("GPSAltitudeRef"); + if (flag.HasValue) + { + switch (flag.Value) + { + case 0: + return AltitudeType.AboveSeaLevel; + case 1: + return AltitudeType.BelowSeaLevel; + default: + return AltitudeType.Undefined; + } + } + return null; + } + set + { + byte? val = null; + if (value.HasValue) + { + switch (value.Value) + { + case AltitudeType.AboveSeaLevel: + val = 0; + break; + + case AltitudeType.BelowSeaLevel: + val = 1; + break; + + default: + val = 2; + break; + } + } + SetTagValue("GPSAltitudeRef", val); + } + } + + /// + /// Gets or sets the altitude based on the reference in . + /// Altitude is expressed as one rational value. The reference unit is meters. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? Altitude + { + get + { + return GetTagValue("GPSAltitude"); + } + set + { + SetTagValue("GPSAltitude", value); + } + } + + /// + /// Gets or sets the sign of the . + /// + /// + /// This is a derived property. There is no metadata tag directly associated + /// with this property value. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public int? AltitudeSign + { + get + { + AltitudeType? seaLevel = AltitudeDirection; + if (seaLevel.HasValue) + { + return (seaLevel.Value == AltitudeType.BelowSeaLevel) ? -1 : 1; + } + return null; + } + set + { + if (value.HasValue) + { + AltitudeDirection = value.Value >= 0 ? AltitudeType.AboveSeaLevel : AltitudeType.BelowSeaLevel; + } + else + { + AltitudeDirection = null; + } + } + } + + /// + /// Gets or sets the signed altitude. + /// Altitude is expressed as one rational value. The reference unit is meters. + /// + /// + /// Altitude is too large to fit into a FIRational. + /// + /// + /// This is a derived property. There is no metadata tag directly associated + /// with this property value. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public FIRational? SignedAltitude + { + get + { + FIRational? result = null; + FIURational? altitude = Altitude; + if (altitude.HasValue) + { + int sign = AltitudeSign ?? 1; + if (((int)altitude.Value.Numerator < 0) || ((int)altitude.Value.Denominator < 0)) + throw new OverflowException(); + result = new FIRational((int)altitude.Value.Numerator * sign, (int)altitude.Value.Denominator); + } + return result; + } + set + { + FIURational? val = null; + if (value.HasValue) + { + if (value.Value < 0) + { + AltitudeSign = -1; + value = -value.Value; + } + else + { + AltitudeSign = 1; + } + val = new FIURational((uint)value.Value.Numerator, (uint)value.Value.Denominator); + } + Altitude = val; + } + } + + + /// + /// Gets or sets the time as UTC (Coordinated Universal Time). Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public TimeSpan? TimeStamp + { + get + { + FIURational[] stamp = GetTagArray("GPSTimeStamp"); + if ((stamp == null) || stamp.Length != 3) + { + return null; + } + else + { + return new TimeSpan((int)stamp[0], (int)stamp[1], (int)stamp[2]); + } + } + set + { + FIURational[] stamp = null; + if (value.HasValue) + { + TimeSpan span = value.Value; + stamp = new FIURational[3]; + stamp[0] = span.Hours; + stamp[1] = span.Minutes; + stamp[2] = span.Seconds; + } + SetTagValue("GPSTimeStamp", stamp); + } + } + + /// + /// Gets or sets the GPS satellites used for measurements. This tag can be used to describe + /// the number of satellites, their ID number, angle of elevation, azimuth, SNR and other + /// information in ASCII notation. The format is not specified. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Satellites + { + get + { + string result = GetTagText("GPSSatellites"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("GPSTimeStamp", value); + } + } + + /// + /// Gets or sets a value indicating the status of the GPS receiver when the image was recorded. + /// true indicates measurement was in progress; + /// false indicates measurement was Interoperability. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? Status + { + get + { + string text = GetTagText("GPSStatus"); + return string.IsNullOrEmpty(text) ? default(bool?) : text[0] == 'A'; + } + set + { + SetTagValue("GPSStatus", value.HasValue ? (value.Value ? "A\0" : "V\0") : null); + } + } + + /// + /// Gets or sets a value indicating the GPS measurement mode. + /// true indicates three-dimensional measurement; + /// false indicated two-dimensional measurement was in progress. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? MeasureMode3D + { + get + { + string text = GetTagText("GPSMeasureMode"); + return string.IsNullOrEmpty(text) ? default(bool?) : text[0] == '3'; + } + set + { + SetTagValue("GPSMeasureMode", value.HasValue ? (value.Value ? "3\0" : "2\0") : null); + } + } + + /// + /// Gets or sets the GPS DOP (data degree of precision). An HDOP value is written during + /// two-dimensional measurement, and PDOP during three-dimensional measurement. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? DOP + { + get + { + return GetTagValue("GPSDOP"); + } + set + { + SetTagValue("GPSDOP", value); + } + } + + /// + /// Gets or sets the unit used to express the GPS receiver of movement. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public VelocityUnit? SpeedUnit + { + get + { + return ToUnitType(GetTagText("GPSSpeedRef")); + } + set + { + SetTagValue("GPSSpeedRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the speed of GPS receiver movement. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational? Speed + { + get + { + return GetTagValue("GPSSpeed"); + } + set + { + SetTagValue("GPSSpeed", value); + } + } + + /// + /// Gets or sets the reference for giving the direction of GPS receiver movement. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public DirectionReference? TrackDirectionReference + { + get + { + return ToDirectionType(GetTagText("GPSTrackRef")); + } + set + { + SetTagValue("GPSTrackRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the direction of GPS receiver movement. + /// The range of values is from 0.00 to 359.99. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational? Track + { + get + { + return GetTagValue("GPSTrack"); + } + set + { + SetTagValue("GPSTrack", value); + } + } + + /// + /// Gets or sets the reference for giving the direction of GPS receiver movement. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public DirectionReference? ImageDirectionReference + { + get + { + return ToDirectionType(GetTagText("GPSImgDirectionRef")); + } + set + { + SetTagValue("GPSImgDirectionRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the direction of the image when it was captured. + /// The range of values is from 0.00 to 359.99. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational? ImageDirection + { + get + { + return GetTagValue("GPSImgDirection"); + } + set + { + SetTagValue("GPSImgDirection", value); + } + } + + /// + /// Gets or sets the geodetic survey data used by the GPS receiver. If the survey data + /// is restricted to Japan, the value of this tag is 'TOKYO' or 'WGS-84'. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string MapDatum + { + get + { + string result = GetTagText("GPSMapDatum"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + SetTagValue("GPSMapDatum", value + '\0'); + } + } + + /// + /// Gets or sets a value indicating whether the destination point + /// is north or south latitude. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public LatitudeType? DestinationLatitudeDirection + { + get + { + return ToLatitudeType(GetTagText("GPSDestLatitudeRef")); + } + set + { + SetTagValue("GPSDestLatitudeRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the latitude of the destination point. The latitude is expressed as three rational + /// values giving the degrees, minutes, and seconds, respectively. Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational[] DestinationLatitude + { + get + { + return GetTagArray("GPSDestLatitude"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("GPSDestLatitude", value); + } + } + + /// + /// Gets or sets a value indicating whether the destination point + /// is east or west longitude. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public LongitudeType? DestinationLongitudeDirection + { + get + { + return ToLongitudeType(GetTagText("GPSDestLongitudeRef")); + } + set + { + SetTagValue("GPSDestLongitudeRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the longitude of the destination point. The longitude is expressed as three rational + /// values giving the degrees, minutes, and seconds, respectively. Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational[] DestinationLongitude + { + get + { + return GetTagArray("GPSDestLongitude"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("GPSDestLongitude", value); + } + } + + /// + /// Gets or sets the reference used for giving the bearing to the destination point. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public DirectionReference? DestinationDirectionReference + { + get + { + return ToDirectionType(GetTagText("GPSDestBearingRef")); + } + set + { + SetTagValue("GPSDestBearingRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets the bearing to the destination point. + /// The range of values is from 0.00 to 359.99. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public FIURational? DestinationBearing + { + get + { + return GetTagValue("GPSDestBearing"); + } + set + { + SetTagValue("GPSDestBearing", value); + } + } + + /// + /// Gets or sets the unit used to express the distance to the destination point. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public VelocityUnit? DestinationUnit + { + get + { + return ToUnitType(GetTagText("GPSDestDistanceRef")); + } + set + { + SetTagValue("GPSDestDistanceRef", ToString(value) + '\0'); + } + } + + /// + /// Gets or sets a character string recording the name of the method used + /// for location finding. The first byte indicates the character code used, + /// and this is followed by the name of the method. Since the Type is not ASCII, + /// NULL termination is not necessary. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] ProcessingMethod + { + get + { + return GetTagArray("GPSProcessingMethod"); + } + set + { + SetTagValue("GPSProcessingMethod", value); + } + } + + /// + /// Gets or sets a character string recording the name of the GPS area. + /// The first byte indicates the character code used, and this is followed by + /// the name of the GPS area. Since the Type is not ASCII, NULL termination is + /// not necessary. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public byte[] AreaInformation + { + get + { + return GetTagArray("GPSAreaInformation"); + } + set + { + SetTagValue("GPSAreaInformation", value); + } + } + + /// + /// Gets or sets date and time information relative to UTC (Coordinated Universal Time). + /// + /// + /// This is a derived property. There is no metadata tag directly associated + /// with this property value. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public DateTime? DateTimeStamp + { + get + { + DateTime? date = DateStamp; + TimeSpan? time = TimeStamp; + if ((date == null) && (time == null)) + { + return null; + } + else + { + if (date == null) + { + date = DateTime.MinValue; + } + if (time == null) + { + time = TimeSpan.MinValue; + } + return date.Value.Add(time.Value); + } + } + set + { + if (value.HasValue) + { + DateStamp = value.Value.Date; + TimeStamp = value.Value.TimeOfDay; + } + else + { + DateStamp = null; + TimeStamp = null; + } + } + } + + /// + /// Gets or sets date information relative to UTC (Coordinated Universal Time). + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public DateTime? DateStamp + { + get + { + string stamp = GetTagText("GPSDateStamp"); + if (stamp != null) + { + try + { + return DateTime.ParseExact(stamp, "yyyy:MM:dd\0", null); + } + catch + { + } + } + return null; + } + set + { + string val = null; + if (value.HasValue) + { + try + { + val = value.Value.ToString("yyyy:MM:dd\0"); + } + catch + { + } + } + SetTagValue("GPSDateStamp", val); + } + } + + /// + /// Gets or sets a value indicating whether differential correction was applied to + /// the GPS receiver. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public bool? IsDifferential + { + get + { + ushort? value = GetTagValue("GPSDifferential"); + return value.HasValue ? (value != 0) : (default(bool?)); + } + set + { + SetTagValue("GPSDifferential", value.HasValue ? (object)(value.Value ? (ushort)1 : (ushort)0) : (null)); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_INTEROP : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_INTEROP(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_EXIF_INTEROP; } + } + + /// + /// Gets or sets the identification of the Interoperability rule. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public InteroperabilityMode? Identification + { + get + { + return ToInteroperabilityType(GetTagText("InteroperabilityIndex")); + } + set + { + SetTagValue("InteroperabilityIndex", ToString(value) + '\0'); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + /// This class is obsolete. Use class instead. + /// + [Obsolete("To be removed in future releases. Use MDM_EXIF_MAIN instead.")] + public class MDM_MAIN : MDM_EXIF_MAIN + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_MAIN(FIBITMAP dib) : base(dib) { } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_EXIF_MAIN : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_EXIF_MAIN(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN; } + } + + /// + /// Gets or sets the number of columns of image data, equal to the number + /// of pixels per row. In JPEG compressed data a JPEG marker is used + /// instead of this tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? ImageWidth + { + get + { + return GetUInt32Value("ImageWidth"); + } + set + { + RemoveTag("ImageWidth"); + if (value.HasValue) + { + SetTagValue("ImageWidth", value); + } + } + } + + /// + /// Gets or sets number of rows of image data. In JPEG compressed data a JPEG marker + /// is used instead of this tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? ImageHeight + { + get + { + return GetUInt32Value("ImageLength"); + } + set + { + RemoveTag("ImageLength"); + if (value.HasValue) + { + SetTagValue("ImageLength", value); + } + } + } + + /// + /// Gets or sets number of bits per image component. In this standard + /// each component of the image is 8 bits, so the value for this tag is 8. + /// Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort[] BitsPerSample + { + get + { + return GetTagArray("BitsPerSample"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("BitsPerSample", value); + } + } + + /// + /// Gets or sets compression scheme used for the image data. When a primary image + /// is JPEG compressed, this designation is not necessary and is omitted. + /// When thumbnails use JPEG compression, this tag value is set to 6. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? Compression + { + get + { + return GetTagValue("Compression"); + } + set + { + SetTagValue("Compression", value); + } + } + + /// + /// Gets or sets pixel composition. In JPEG compressed data a JPEG marker is + /// used instead of this tag. See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 2 + /// RGB + /// + /// + /// 6 + /// YCbCr + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? PhotometricInterpretation + { + get + { + return GetTagValue("PhotometricInterpretation"); + } + set + { + SetTagValue("PhotometricInterpretation", value); + } + } + + /// + /// Gets or sets the image orientation viewed in terms of rows and columns. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ExifImageOrientation? Orientation + { + get + { + return (ExifImageOrientation?)GetTagValue("Orientation"); + } + set + { + SetTagValue("Orientation", (ushort?)value); + } + } + + /// + /// Gets or sets the number of components per pixel. Since this standard applies + /// to RGB and YCbCr images, the value set for this tag is 3. In JPEG compressed + /// data a JPEG marker is used instead of this tag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort? SamplesPerPixel + { + get + { + return GetTagValue("SamplesPerPixel"); + } + set + { + SetTagValue("SamplesPerPixel", value); + } + } + + /// + /// Gets or sets a value that indicates whether pixel components are recorded in + /// chunky or planar format. In JPEG compressed files a JPEG marker is used instead + /// of this tag. If this field does not exist, the TIFF default of 1 (chunky) is assumed. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 1 + /// chunky format + /// + /// + /// 2 + /// planar format + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? PlanarConfiguration + { + get + { + return GetTagValue("PlanarConfiguration"); + } + set + { + SetTagValue("PlanarConfiguration", value); + } + } + + /// + /// Gets or sets the sampling ratio of chrominance components in relation to + /// the luminance component. In JPEG compressed dat a JPEG marker is used + /// instead of this tag. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// [2,1] + /// YCbCr4:2:2 + /// + /// + /// [2,2] + /// YCbCr4:2:0 + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort[] YCbCrSubSampling + { + get + { + return GetTagArray("YCbCrSubSampling"); + } + set + { + FreeImage.Resize(ref value, 2); + SetTagValue("YCbCrSubSampling", value); + } + } + + /// + /// Gets or sets position of chrominance components in relation to the luminance component. + /// See remarks for further information. + /// + /// + /// This field is designated only for JPEG compressed data or uncompressed YCbCr data. + /// The TIFF default is 1 (centered); but when Y:Cb:Cr = 4:2:2 it is recommended in + /// this standard that 2 (co-sited) be used to record data, in order to improve the + /// image quality when viewed on TV systems. + /// + /// When this field does not exist, the reader shall assume the TIFF default. + /// In the case of Y:Cb:Cr = 4:2:0, the TIFF default (centered) is recommended. + /// If the reader does not have the capability of supporting both kinds of YCbCrPositioning, + /// it shall follow the TIFF default regardless of the value in this field. + /// It is preferable that readers be able to support both centered and co-sited positioning. + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 1 + /// centered + /// + /// + /// 2 + /// co-sited + /// + /// + /// other + /// reserved + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? YCbCrPositioning + { + get + { + return GetTagValue("YCbCrPositioning"); + } + set + { + SetTagValue("YCbCrPositioning", value); + } + } + + /// + /// Gets or sets the number of pixels per + /// in the direction. When the image resolution is unknown, + /// 72 [dpi] is designated. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? XResolution + { + get + { + return GetTagValue("XResolution"); + } + set + { + SetTagValue("XResolution", value); + } + } + + /// + /// Gets or sets the number of pixels per + /// in the direction. When the image resolution is unknown, + /// 72 [dpi] is designated. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational? YResolution + { + get + { + return GetTagValue("YResolution"); + } + set + { + SetTagValue("YResolution", value); + } + } + + /// + /// Gets or sets the unit for measuring and . + /// The same unit is used for both and . + /// If the image resolution in unknown, 2 (inches) is designated. + /// See remarks for further information. + /// + /// + /// The following values are definied: + /// + /// + /// ID + /// Description + /// + /// + /// 2 + /// inches + /// + /// + /// 3 + /// YCbCr4:2:0 + /// + /// + /// other + /// centimeters + /// + /// + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort? ResolutionUnit + { + get + { + return GetTagValue("ResolutionUnit"); + } + set + { + SetTagValue("ResolutionUnit", value); + } + } + + /// + /// Gets or sets the byte offset of that strip. + /// It is recommended that this be selected so the number of strip bytes + /// does not exceed 64 Kbytes. + /// With JPEG compressed data this designation is not needed and is omitted. + /// Constant length of * StripsPerImage. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + /// + public uint[] StripOffsets + { + get + { + return GetUInt32Array("StripOffsets"); + } + set + { + RemoveTag("StripOffsets"); + if (value != null) + { + SetTagValue("StripOffsets", value); + } + } + } + + /// + /// Gets or sets number of rows per strip. This is the number of rows in the image of + /// one strip when an image is divided into strips. With JPEG compressed data this + /// designation is not needed and is omitted. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + /// + public uint? RowsPerStrip + { + get + { + return GetUInt32Value("RowsPerStrip"); + } + set + { + RemoveTag("RowsPerStrip"); + if (value.HasValue) + { + SetTagValue("RowsPerStrip", value); + } + } + } + + /// + /// Gets or sets the total number of bytes in each strip. + /// With JPEG compressed data this designation is not needed and is omitted. + /// Constant length of * StripsPerImage. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint[] StripByteCounts + { + get + { + return GetUInt32Array("StripByteCounts"); + } + set + { + RemoveTag("StripByteCounts"); + if (value != null) + { + SetTagValue("StripByteCounts", value); + } + } + } + + /// + /// Gets or sets the offset to the start byte (SOI) of JPEG compressed thumbnail data. + /// This is not used for primary image JPEG data. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? JPEGInterchangeFormat + { + get + { + return GetTagValue("JPEGInterchangeFormat"); + } + set + { + SetTagValue("JPEGInterchangeFormat", value); + } + } + + /// + /// Gets or sets the number of bytes of JPEG compressed thumbnail data. + /// + /// + /// This is not used for primary image JPEG data. + /// JPEG thumbnails are not divided but are recorded as a continuous + /// JPEG bitstream from SOI to EOI. APPn and COM markers should not be recorded. + /// Compressed thumbnails shall be recorded in no more than 64 Kbytes, + /// including all other data to be recorded in APP1. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public uint? JPEGInterchangeFormatLength + { + get + { + return GetTagValue("JPEGInterchangeFormatLength"); + } + set + { + SetTagValue("JPEGInterchangeFormatLength", value); + } + } + + /// + /// Gets or sets a transfer function for the image, described in tabular style. + /// Constant length of 3 * 256. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public ushort[] TransferFunction + { + get + { + return GetTagArray("TransferFunction"); + } + set + { + FreeImage.Resize(ref value, 3 * 256); + SetTagValue("TransferFunction", value); + } + } + + /// + /// Gets or sets the chromaticity of the white point of the image. + /// Constant length of 2. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational[] WhitePoint + { + get + { + return GetTagArray("WhitePoint"); + } + set + { + FreeImage.Resize(ref value, 2); + SetTagValue("WhitePoint", value); + } + } + + /// + /// Gets or sets the chromaticity of the three primary colors of the image. + /// Constant length of 6. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational[] PrimaryChromaticities + { + get + { + return GetTagArray("PrimaryChromaticities"); + } + set + { + FreeImage.Resize(ref value, 6); + SetTagValue("PrimaryChromaticities", value); + } + } + + /// + /// Gets or sets the matrix coefficients for transformation from RGB to YCbCr image data. + /// Constant length of 3. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational[] YCbCrCoefficients + { + get + { + return GetTagArray("YCbCrCoefficients"); + } + set + { + FreeImage.Resize(ref value, 3); + SetTagValue("PrimaryChromaticities", value); + } + } + + /// + /// Gets or sets the reference black point value and reference white point value. + /// Constant length of 6. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public FIURational[] ReferenceBlackWhite + { + get + { + return GetTagArray("ReferenceBlackWhite"); + } + set + { + FreeImage.Resize(ref value, 6); + SetTagValue("ReferenceBlackWhite", value); + } + } + + /// + /// Gets or sets the date and time of image creation. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public DateTime? DateTime + { + get + { + DateTime? result = null; + string text = GetTagText("DateTime"); + if (text != null) + { + try + { + result = System.DateTime.ParseExact(text, "yyyy:MM:dd HH:mm:ss\0", null); + } + catch + { + } + } + return result; + } + set + { + string val = null; + if (value.HasValue) + { + try + { + val = value.Value.ToString("yyyy:MM:dd HH:mm:ss\0"); + } + catch + { + } + } + SetTagValue("DateTime", val); + } + } + + /// + /// Gets or sets a string giving the title of the image. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ImageDescription + { + get + { + string result = GetTagText("ImageDescription"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("ImageDescription", value); + } + } + + /// + /// Gets or sets the manufacturer of the recording equipment. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Make + { + get + { + string result = GetTagText("Make"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("Make", value); + } + } + + /// + /// Gets or sets the model name or model number of the equipment. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string EquipmentModel + { + get + { + string result = GetTagText("Model"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("Model", value); + } + } + + /// + /// Gets or sets the name and version of the software or firmware of the camera + /// or image input device used to generate the image. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Software + { + get + { + string result = GetTagText("Software"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("Software", value); + } + } + + /// + /// Gets or sets the name of the camera owner, photographer or image creator. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Artist + { + get + { + string result = GetTagText("Artist"); + if (!string.IsNullOrEmpty(result)) + { + result = result.Substring(0, result.Length - 1); + } + return result; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("Artist", value); + } + } + + /// + /// Gets or sets the photographer and editor copyrights. + /// Constant length of 1-2. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string[] Copyright + { + get + { + string[] result = null; + string text = GetTagText("Copyright"); + if (!string.IsNullOrEmpty(text)) + { + result = text.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries); + } + return result; + } + set + { + string val = null; + if (value != null) + { + if (value.Length == 1) + { + if (value[0] != null) + { + val = value[0] + '\0'; + } + } + else if (value.Length == 2) + { + if ((value[0] != null) && (value[1] != null)) + { + val = value[0] + '\0' + value[1] + '\0'; + } + } + } + SetTagValue("Copyright", val); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_MAKERNOTE : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_MAKERNOTE(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_EXIF_MAKERNOTE; } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_GEOTIFF : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_GEOTIFF(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_GEOTIFF; } + } + + /// + /// Gets or sets the value of the GeoTIFF GeoASCIIParamsTag. + /// + /// + /// The GeoASCIIParamsTag is used to store all of the valued + /// GeoKeys, referenced by the property. Since keys + /// defined in the GeoKeyDirectoryTag use offsets into this tag, any special + /// comments may be placed at the beginning of this tag. + /// For the most part, the only keys that are valued are + /// Citation keys, giving documentation and references for obscure + /// projections, datums, etc. + /// + /// Special handling is required for -valued keys. While it + /// is true that TIFF 6.0 permits multiple NULL-delimited strings within a single + /// ASCII tag, the secondary strings might not appear in the output of naive + /// tiffdump programs. For this reason, the NULL delimiter of each ASCII key + /// value shall be converted to a "|" (pipe) character before being installed + /// back into the holding tag, so that a dump of the tag + /// will look like this. + /// + /// AsciiTag="first_value|second_value|etc...last_value|" + /// + /// A baseline GeoTIFF-reader must check for and convert the final "|" pipe + /// character of a key back into a NULL before returning it to the client + /// software. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public string GeoASCIIParams + { + get + { + string text = GetTagText("GeoASCIIParams"); + if (!string.IsNullOrEmpty(text)) + { + text = text.Substring(0, text.Length - 1); + } + return text; + } + set + { + if (value != null) + { + value += '\0'; + } + SetTagValue("GeoASCIIParams", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF GeoDoubleParamsTag. + /// + /// + /// The GeoDoubleParamsTag is used to store all of the valued + /// GeoKeys, referenced by the property. The meaning of + /// any value of this double array is determined from the GeoKeyDirectoryTag reference + /// pointing to it. values should first be converted to + /// and stored here. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public double[] GeoDoubleParams + { + get + { + return GetTagArray("GeoDoubleParams"); + } + set + { + SetTagValue("GeoDoubleParams", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF GeoKeyDirectoryTag. + /// + /// + /// The GeoKeyDirectoryTag may be used to store the GeoKey Directory, which defines and + /// references the GeoKeys. + /// + /// The tag is an array of unsigned values, which are primarily + /// grouped into blocks of 4. The first 4 values are special, and contain GeoKey directory + /// header information. The header values consist of the following information, in order: + /// + /// Header={KeyDirectoryVersion, KeyRevision, MinorRevision, NumberOfKeys} + /// + /// where + /// + /// KeyDirectoryVersion indicates the current version of Key implementation, and will + /// only change if this Tag's Key structure is changed. (Similar to the TIFFVersion (42)). + /// The current DirectoryVersion number is 1. This value will most likely never change, + /// and may be used to ensure that this is a valid Key-implementation. + /// + /// KeyRevision indicates what revision of Key-Sets are used. + /// + /// MinorRevision indicates what set of Key-Codes are used. The complete revision number + /// is denoted <KeyRevision>.<MinorRevision>. + /// + /// NumberOfKeys indicates how many Keys are defined by the rest of this Tag. + /// + /// This header is immediately followed by a collection of <NumberOfKeys> KeyEntry + /// sets, each of which is also 4- long. Each KeyEntry is modeled on the + /// TIFFEntry format of the TIFF directory header, and is of the form: + /// + /// KeyEntry = { KeyID, TIFFTagLocation, Count, Value_Offset } + /// + /// where + /// + /// KeyID gives the Key-ID value of the Key (identical in function to TIFF tag ID, + /// but completely independent of TIFF tag-space), + /// + /// TIFFTagLocation indicates which TIFF tag contains the value(s) of the Key: if + /// TIFFTagLocation is 0, then the value is , and is contained in the + /// Value_Offset entry. Otherwise, the type (format) of the value is implied by the + /// TIFF-Type of the tag containing the value. + /// + /// Count indicates the number of values in this key. + /// + /// Value_Offset Value_Offset indicates the index-offset into the TagArray indicated + /// by TIFFTagLocation, if it is nonzero. If TIFFTagLocation is 0 (zero) , then Value_Offset + /// contains the actual () value of the Key, and Count=1 is implied. + /// Note that the offset is not a byte-offset, but rather an index based on the natural data + /// type of the specified tag array. + /// + /// Following the KeyEntry definitions, the KeyDirectory tag may also contain additional + /// values. For example, if a key requires multiple values, they shall + /// be placed at the end of this tag, and the KeyEntry will set + /// TIFFTagLocation=GeoKeyDirectoryTag, with the Value_Offset pointing to the location of the + /// value(s). + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public ushort[] GeoKeyDirectory + { + get + { + return GetTagArray("GeoKeyDirectory"); + } + set + { + SetTagValue("GeoKeyDirectory", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF ModelPixelScaleTag. + /// + /// + /// The ModelPixelScaleTag tag may be used to specify the size of raster pixel spacing + /// in the model space units, when the raster space can be embedded in the model space + /// coordinate system without rotation, and consists of the following 3 values: + /// + /// ModelPixelScaleTag = (ScaleX, ScaleY, ScaleZ) + /// + /// where ScaleX and ScaleY give the horizontal and vertical spacing of + /// raster pixels. The ScaleZ is primarily used to map the pixel value of a + /// digital elevation model into the correct Z-scale, and so for most other purposes + /// this value should be zero (since most model spaces are 2-D, with Z=0). + /// + /// A single tiepoint in the tag, together with this tag, + /// completely determine the relationship between raster and model space; thus they + /// comprise the two tags which Baseline GeoTIFF files most often will use to place a + /// raster image into a "standard position" in model space. + /// + /// Like the tag, this tag information is independent of the + /// XPosition, YPosition, Resolution and Orientation tags of the standard TIFF 6.0 spec. + /// However, simple reversals of orientation between raster and model space + /// (e.g. horizontal or vertical flips) may be indicated by reversal of sign in the + /// corresponding component of the ModelPixelScaleTag. GeoTIFF compliant readers must + /// honor this signreversal convention. + /// + /// This tag must not be used if the raster image requires rotation or shearing to place + /// it into the standard model space. In such cases the transformation shall be defined + /// with the more general . + /// + ///
Naming differences + /// In the native FreeImage library and thus, in the FreeImage API documentation, this + /// property's key is named GeoPixelScale. Since the GeoTIFF specification + /// as well as Java's EXIFTIFFTagSet class call this tag + /// , this property was renamed accordingly. + /// However, when accessing this property's tag by its object, + /// the native FreeImage tag key GeoPixelScale must be used. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public double[] ModelPixelScale + { + get + { + return GetTagArray("GeoPixelScale"); + } + set + { + SetTagValue("GeoPixelScale", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF GeoTiePointsTag. + /// + /// + /// The GeoTiePointsTag stores raster -> model tiepoint pairs in the order + /// + /// ModelTiePoints = (...,I,J,K, X,Y,Z...), + /// + /// where (I,J,K) is the point at location (I,J) in raster space with + /// pixel-value K, and (X,Y,Z) is a vector in model space. In most cases + /// the model space is only two-dimensional, in which case both K and Z should be set + /// to zero; this third dimension is provided in anticipation of future support for 3D + /// digital elevation models and vertical coordinate systems. + /// + /// A raster image may be georeferenced simply by specifying its location, size and + /// orientation in the model coordinate space M. This may be done by specifying the + /// location of three of the four bounding corner points. However, tiepoints are only + /// to be considered exact at the points specified; thus defining such a set of + /// bounding tiepoints does not imply that the model space locations of the interior + /// of the image may be exactly computed by a linear interpolation of these tiepoints. + /// + /// However, since the relationship between the Raster space and the model space will + /// often be an exact, affine transformation, this relationship can be defined using + /// one set of tiepoints and the , described below, which + /// gives the vertical and horizontal raster grid cell size, specified in model units. + /// + /// If possible, the first tiepoint placed in this tag shall be the one establishing + /// the location of the point (0,0) in raster space. However, if this is not possible + /// (for example, if (0,0) is goes to a part of model space in which the projection is + /// ill-defined), then there is no particular order in which the tiepoints need be + /// listed. + /// + /// For orthorectification or mosaicking applications a large number of tiepoints may + /// be specified on a mesh over the raster image. However, the definition of associated + /// grid interpolation methods is not in the scope of the current GeoTIFF spec. + /// + ///
Naming differences + /// In the native FreeImage library and thus, in the FreeImage API documentation, this + /// property's key is named GeoTiePoints. Since the GeoTIFF specification + /// as well as Java's EXIFTIFFTagSet class call this tag + /// , this property was renamed accordingly. + /// However, when accessing this property's tag by its object, + /// the native FreeImage tag key GeoTiePoints must be used. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public double[] ModelTiePoints + { + get + { + return GetTagArray("GeoTiePoints"); + } + set + { + SetTagValue("GeoTiePoints", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF ModelTransformationMatrixTag. + /// + /// + /// This tag may be used to specify the transformation matrix between the raster space + /// (and its dependent pixel-value space) and the (possibly 3D) model space. + /// + ///
Naming differences + /// In the native FreeImage library and thus, in the FreeImage API documentation, this + /// property's key is named GeoTransformationMatrix. Since the GeoTIFF specification + /// as well as Java's EXIFTIFFTagSet class call this tag + /// , this property was renamed accordingly. + /// However, when accessing this property's tag by its object, + /// the native FreeImage tag key GeoTransformationMatrix must be used. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public double[] ModelTransformationMatrix + { + get + { + return GetTagArray("GeoTransformationMatrix"); + } + set + { + SetTagValue("GeoTransformationMatrix", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF IntergraphTransformationMatrixTag. + /// + /// + /// The IntergraphTransformationMatrixTag conflicts with an internal software implementation + /// at Intergraph, and so its use is no longer encouraged. A GeoTIFF reader should look first + /// for the new tag, and only if it is not found should it check for this older tag. If found, + /// it should only consider it to be contain valid GeoTIFF matrix information if the tag-count + /// is 16; the Intergraph version uses 17 values. + /// + ///
Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + ///
+ public double[] IntergraphTransformationMatrix + { + get + { + return GetTagArray("Intergraph TransformationMatrix"); + } + set + { + SetTagValue("Intergraph TransformationMatrix", value); + } + } + + /// + /// Gets or sets the value of the GeoTIFF JPLCartoIFDOffsetTag. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public uint? JPLCartoIFDOffset + { + get + { + return GetTagValue("JPL Carto IFD offset"); + } + set + { + SetTagValue("JPL Carto IFD offset", value); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_IPTC : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_IPTC(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_IPTC; } + } + + /// + /// Gets the Application Record Version. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public short? ApplicationRecordVersion + { + get + { + return GetTagValue("ApplicationRecordVersion"); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Type Reference. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectTypeReference + { + get + { + return GetTagText("ObjectTypeReference"); + } + set + { + SetTagValue("ObjectTypeReference", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Attribute Reference. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectAttributeReference + { + get + { + return GetTagText("ObjectAttributeReference"); + } + set + { + SetTagValue("ObjectAttributeReference", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Name. + /// This is also referred to as Title. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectName + { + get + { + return GetTagText("ObjectName"); + } + set + { + SetTagValue("ObjectName", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Edit Status. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string EditStatus + { + get + { + return GetTagText("EditStatus"); + } + set + { + SetTagValue("EditStatus", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Editorial Update. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string EditorialUpdate + { + get + { + return GetTagText("EditorialUpdate"); + } + set + { + SetTagValue("EditorialUpdate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Urgency. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Urgency + { + get + { + return GetTagText("Urgency"); + } + set + { + SetTagValue("Urgency", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Subject Reference. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SubjectReference + { + get + { + return GetTagText("SubjectReference"); + } + set + { + SetTagValue("SubjectReference", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Category. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Category + { + get + { + return GetTagText("Category"); + } + set + { + SetTagValue("Category", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Supplemental Categories. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SupplementalCategories + { + get + { + return GetTagText("SupplementalCategories"); + } + set + { + SetTagValue("SupplementalCategories", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Fixture Identifier. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string FixtureIdentifier + { + get + { + return GetTagText("FixtureIdentifier"); + } + set + { + SetTagValue("FixtureIdentifier", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Keywords. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Keywords + { + get + { + return GetTagText("Keywords"); + } + set + { + SetTagValue("Keywords", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Content Location Code. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ContentLocationCode + { + get + { + return GetTagText("ContentLocationCode"); + } + set + { + SetTagValue("ContentLocationCode", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Content Location Name. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ContentLocationName + { + get + { + return GetTagText("ContentLocationName"); + } + set + { + SetTagValue("ContentLocationName", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Release Date. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ReleaseDate + { + get + { + return GetTagText("ReleaseDate"); + } + set + { + SetTagValue("ReleaseDate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Release Time. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ReleaseTime + { + get + { + return GetTagText("ReleaseTime"); + } + set + { + SetTagValue("ReleaseTime", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Expiration Date. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ExpirationDate + { + get + { + return GetTagText("ExpirationDate"); + } + set + { + SetTagValue("ExpirationDate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Expiration Time. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ExpirationTime + { + get + { + return GetTagText("ExpirationTime"); + } + set + { + SetTagValue("ExpirationTime", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Special Instructions. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SpecialInstructions + { + get + { + return GetTagText("SpecialInstructions"); + } + set + { + SetTagValue("SpecialInstructions", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Action Advised. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ActionAdvised + { + get + { + return GetTagText("ActionAdvised"); + } + set + { + SetTagValue("ActionAdvised", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Reference Service. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ReferenceService + { + get + { + return GetTagText("ReferenceService"); + } + set + { + SetTagValue("ReferenceService", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Reference Date. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ReferenceDate + { + get + { + return GetTagText("ReferenceDate"); + } + set + { + SetTagValue("ReferenceDate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Reference Number. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ReferenceNumber + { + get + { + return GetTagText("ReferenceNumber"); + } + set + { + SetTagValue("ReferenceNumber", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Date Created. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string DateCreated + { + get + { + return GetTagText("DateCreated"); + } + set + { + SetTagValue("DateCreated", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Time Created. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string TimeCreated + { + get + { + return GetTagText("TimeCreated"); + } + set + { + SetTagValue("TimeCreated", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Digital Creation Date. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string DigitalCreationDate + { + get + { + return GetTagText("DigitalCreationDate"); + } + set + { + SetTagValue("DigitalCreationDate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Digital Creation Time. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string DigitalCreationTime + { + get + { + return GetTagText("DigitalCreationTime"); + } + set + { + SetTagValue("DigitalCreationTime", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Originating Program. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string OriginatingProgram + { + get + { + return GetTagText("OriginatingProgram"); + } + set + { + SetTagValue("OriginatingProgram", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Program Version. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ProgramVersion + { + get + { + return GetTagText("ProgramVersion"); + } + set + { + SetTagValue("ProgramVersion", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Cycle. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectCycle + { + get + { + return GetTagText("ObjectCycle"); + } + set + { + SetTagValue("ObjectCycle", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag By Line. + /// This is the author's name. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ByLine + { + get + { + return GetTagText("By-line"); + } + set + { + SetTagValue("By-line", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag By Line Title. + /// This is the author's position. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ByLineTitle + { + get + { + return GetTagText("By-lineTitle"); + } + set + { + SetTagValue("By-lineTitle", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag City. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string City + { + get + { + return GetTagText("City"); + } + set + { + SetTagValue("City", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Sub Location. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SubLocation + { + get + { + return GetTagText("SubLocation"); + } + set + { + SetTagValue("SubLocation", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Province State. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ProvinceState + { + get + { + return GetTagText("ProvinceState"); + } + set + { + SetTagValue("ProvinceState", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Country Primary Location Code. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string CountryPrimaryLocationCode + { + get + { + return GetTagText("Country-PrimaryLocationCode"); + } + set + { + SetTagValue("Country-PrimaryLocationCode", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Country Primary Location Name. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string CountryPrimaryLocationName + { + get + { + return GetTagText("Country-PrimaryLocationName"); + } + set + { + SetTagValue("Country-PrimaryLocationName", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Original Transmission Reference. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string OriginalTransmissionReference + { + get + { + return GetTagText("OriginalTransmissionReference"); + } + set + { + SetTagValue("OriginalTransmissionReference", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Headline. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Headline + { + get + { + return GetTagText("Headline"); + } + set + { + SetTagValue("Headline", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Credit. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Credit + { + get + { + return GetTagText("Credit"); + } + set + { + SetTagValue("Credit", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Source. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Source + { + get + { + return GetTagText("Source"); + } + set + { + SetTagValue("Source", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Copyright Notice. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string CopyrightNotice + { + get + { + return GetTagText("CopyrightNotice"); + } + set + { + SetTagValue("CopyrightNotice", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Contact. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Contact + { + get + { + return GetTagText("Contact"); + } + set + { + SetTagValue("Contact", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Caption Abstract. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string CaptionAbstract + { + get + { + return GetTagText("CaptionAbstract"); + } + set + { + SetTagValue("CaptionAbstract", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Writer Editor. + /// This is also referred to as Caption Writer. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string WriterEditor + { + get + { + return GetTagText("WriterEditor"); + } + set + { + SetTagValue("WriterEditor", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Rasterized Caption. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string RasterizedCaption + { + get + { + return GetTagText("RasterizedCaption"); + } + set + { + SetTagValue("RasterizedCaption", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Image Type. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ImageType + { + get + { + return GetTagText("ImageType"); + } + set + { + SetTagValue("ImageType", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Image Orientation. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ImageOrientation + { + get + { + return GetTagText("ImageOrientation"); + } + set + { + SetTagValue("ImageOrientation", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Language Identifier. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string LanguageIdentifier + { + get + { + return GetTagText("LanguageIdentifier"); + } + set + { + SetTagValue("LanguageIdentifier", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Audio Type. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string AudioType + { + get + { + return GetTagText("AudioType"); + } + set + { + SetTagValue("AudioType", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Audio Sampling Rate. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string AudioSamplingRate + { + get + { + return GetTagText("AudioSamplingRate"); + } + set + { + SetTagValue("AudioSamplingRate", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Audio Sampling Resolution. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string AudioSamplingResolution + { + get + { + return GetTagText("AudioSamplingResolution"); + } + set + { + SetTagValue("AudioSamplingResolution", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Audio Duration. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string AudioDuration + { + get + { + return GetTagText("AudioDuration"); + } + set + { + SetTagValue("AudioDuration", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Audio Outcue. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string AudioOutcue + { + get + { + return GetTagText("AudioOutcue"); + } + set + { + SetTagValue("AudioOutcue", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Job I D. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string JobID + { + get + { + return GetTagText("JobID"); + } + set + { + SetTagValue("JobID", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Master Document I D. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string MasterDocumentID + { + get + { + return GetTagText("MasterDocumentID"); + } + set + { + SetTagValue("MasterDocumentID", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Short Document I D. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ShortDocumentID + { + get + { + return GetTagText("ShortDocumentID"); + } + set + { + SetTagValue("ShortDocumentID", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Unique Document I D. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string UniqueDocumentID + { + get + { + return GetTagText("UniqueDocumentID"); + } + set + { + SetTagValue("UniqueDocumentID", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Owner I D. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string OwnerID + { + get + { + return GetTagText("OwnerID"); + } + set + { + SetTagValue("OwnerID", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Preview File Format. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectPreviewFileFormat + { + get + { + return GetTagText("ObjectPreviewFileFormat"); + } + set + { + SetTagValue("ObjectPreviewFileFormat", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Preview File Version. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectPreviewFileVersion + { + get + { + return GetTagText("ObjectPreviewFileVersion"); + } + set + { + SetTagValue("ObjectPreviewFileVersion", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Object Preview Data. + /// This is also referred to as Audio Outcue. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ObjectPreviewData + { + get + { + return GetTagText("ObjectPreviewData"); + } + set + { + SetTagValue("ObjectPreviewData", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Prefs. + /// This is also referred to as photo-mechanic preferences. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Prefs + { + get + { + return GetTagText("Prefs"); + } + set + { + SetTagValue("Prefs", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Classify State. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ClassifyState + { + get + { + return GetTagText("ClassifyState"); + } + set + { + SetTagValue("ClassifyState", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Similarity Index. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string SimilarityIndex + { + get + { + return GetTagText("SimilarityIndex"); + } + set + { + SetTagValue("SimilarityIndex", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Document Notes. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string DocumentNotes + { + get + { + return GetTagText("DocumentNotes"); + } + set + { + SetTagValue("DocumentNotes", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Document History. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string DocumentHistory + { + get + { + return GetTagText("DocumentHistory"); + } + set + { + SetTagValue("DocumentHistory", value); + } + } + + /// + /// Gets or sets the value of the IPTC/NAA tag Exif Camera Info. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string ExifCameraInfo + { + get + { + return GetTagText("ExifCameraInfo"); + } + set + { + SetTagValue("ExifCameraInfo", value); + } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_NODATA : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_NODATA(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_NODATA; } + } + } + + /// + /// Represents a collection of all tags contained in the metadata model + /// . + /// + public class MDM_XMP : MetadataModel + { + /// + /// Initializes a new instance of this class. + /// + /// Handle to a FreeImage bitmap. + public MDM_XMP(FIBITMAP dib) : base(dib) { } + + /// + /// Retrieves the datamodel that this instance represents. + /// + public override FREE_IMAGE_MDMODEL Model + { + get { return FREE_IMAGE_MDMODEL.FIMD_XMP; } + } + + /// + /// Gets or sets the XMP XML content. + /// + /// + /// Handling of null values + /// A null value indicates, that the corresponding metadata tag is not + /// present in the metadata model. + /// Setting this property's value to a non-null reference creates the + /// metadata tag if necessary. + /// Setting this property's value to a null reference deletes the + /// metadata tag from the metadata model. + /// + public string Xml + { + get + { + return GetTagText("XMLPacket"); + } + set + { + SetTagValue("XMLPacket", value); + } + } + + /// + /// Gets an initialized to read the XMP XML content. + /// Returns null, if the metadata tag XMLPacket is not present in + /// this model. + /// + public XmlReader XmlReader + { + get + { + string xmlString = Xml; + if (xmlString == null) + { + return null; + } + else + { + MemoryStream stream = new MemoryStream(); + StreamWriter writer = new StreamWriter(stream); + writer.Write(xmlString); + return XmlReader.Create(stream); + } + } + } + } +} + + #endregion + +namespace FreeImageAPI.Metadata +{ + /// + /// Manages metadata objects and operations. + /// + public sealed class MetadataTag : IComparable, IComparable, ICloneable, IEquatable, IDisposable + { + /// + /// The encapsulated FreeImage-tag. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + internal FITAG tag; + + /// + /// The metadata model of . + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private FREE_IMAGE_MDMODEL model; + + /// + /// Indicates whether this instance has already been disposed. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool disposed = false; + + /// + /// Indicates whether this instance was created by FreeImage or + /// by the user. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool selfCreated; + + /// + /// List linking metadata-model and Type. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly Dictionary idList; + + /// + /// List linking Type and metadata-model. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly Dictionary typeList; + + /// + /// Initializes a new instance of this class. + /// + private MetadataTag() + { + } + + /// + /// Initializes a new instance of this class. + /// + /// The new model the tag should be of. + public MetadataTag(FREE_IMAGE_MDMODEL model) + { + this.model = model; + tag = FreeImage.CreateTag(); + selfCreated = true; + + if (model == FREE_IMAGE_MDMODEL.FIMD_XMP) + { + Key = "XMLPacket"; + } + } + + /// + /// Initializes a new instance of this class. + /// + /// The to represent. + /// The bitmap was extracted from. + public MetadataTag(FITAG tag, FIBITMAP dib) + { + if (tag.IsNull) + { + throw new ArgumentNullException("tag"); + } + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + this.tag = tag; + model = GetModel(dib, tag); + selfCreated = false; + + if (model == FREE_IMAGE_MDMODEL.FIMD_XMP) + { + Key = "XMLPacket"; + } + } + + /// + /// Initializes a new instance of this class. + /// + /// The to represent. + /// The model of . + public MetadataTag(FITAG tag, FREE_IMAGE_MDMODEL model) + { + if (tag.IsNull) + { + throw new ArgumentNullException("tag"); + } + this.tag = tag; + this.model = model; + selfCreated = false; + + if (model == FREE_IMAGE_MDMODEL.FIMD_XMP) + { + Key = "XMLPacket"; + } + } + + static MetadataTag() + { + idList = new Dictionary(); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_BYTE, typeof(byte)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_SHORT, typeof(ushort)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_LONG, typeof(uint)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_RATIONAL, typeof(FIURational)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_SBYTE, typeof(sbyte)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_UNDEFINED, typeof(byte)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_SSHORT, typeof(short)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_SLONG, typeof(int)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_SRATIONAL, typeof(FIRational)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_FLOAT, typeof(float)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_DOUBLE, typeof(double)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_IFD, typeof(uint)); + idList.Add(FREE_IMAGE_MDTYPE.FIDT_PALETTE, typeof(RGBQUAD)); + + typeList = new Dictionary(); + typeList.Add(typeof(ushort), FREE_IMAGE_MDTYPE.FIDT_SHORT); + typeList.Add(typeof(ushort[]), FREE_IMAGE_MDTYPE.FIDT_SHORT); + typeList.Add(typeof(string), FREE_IMAGE_MDTYPE.FIDT_ASCII); + typeList.Add(typeof(uint), FREE_IMAGE_MDTYPE.FIDT_LONG); + typeList.Add(typeof(uint[]), FREE_IMAGE_MDTYPE.FIDT_LONG); + typeList.Add(typeof(FIURational), FREE_IMAGE_MDTYPE.FIDT_RATIONAL); + typeList.Add(typeof(FIURational[]), FREE_IMAGE_MDTYPE.FIDT_RATIONAL); + typeList.Add(typeof(sbyte), FREE_IMAGE_MDTYPE.FIDT_SBYTE); + typeList.Add(typeof(sbyte[]), FREE_IMAGE_MDTYPE.FIDT_SBYTE); + typeList.Add(typeof(byte), FREE_IMAGE_MDTYPE.FIDT_BYTE); + typeList.Add(typeof(byte[]), FREE_IMAGE_MDTYPE.FIDT_BYTE); + typeList.Add(typeof(short), FREE_IMAGE_MDTYPE.FIDT_SSHORT); + typeList.Add(typeof(short[]), FREE_IMAGE_MDTYPE.FIDT_SSHORT); + typeList.Add(typeof(int), FREE_IMAGE_MDTYPE.FIDT_SLONG); + typeList.Add(typeof(int[]), FREE_IMAGE_MDTYPE.FIDT_SLONG); + typeList.Add(typeof(FIRational), FREE_IMAGE_MDTYPE.FIDT_SRATIONAL); + typeList.Add(typeof(FIRational[]), FREE_IMAGE_MDTYPE.FIDT_SRATIONAL); + typeList.Add(typeof(float), FREE_IMAGE_MDTYPE.FIDT_FLOAT); + typeList.Add(typeof(float[]), FREE_IMAGE_MDTYPE.FIDT_FLOAT); + typeList.Add(typeof(double), FREE_IMAGE_MDTYPE.FIDT_DOUBLE); + typeList.Add(typeof(double[]), FREE_IMAGE_MDTYPE.FIDT_DOUBLE); + typeList.Add(typeof(RGBQUAD), FREE_IMAGE_MDTYPE.FIDT_PALETTE); + typeList.Add(typeof(RGBQUAD[]), FREE_IMAGE_MDTYPE.FIDT_PALETTE); + } + + /// + /// Releases all resources used by the instance. + /// + ~MetadataTag() + { + Dispose(); + } + + /// + /// Determines whether two specified objects have the same value. + /// + /// A or a null reference (Nothing in Visual Basic). + /// A or a null reference (Nothing in Visual Basic). + /// + /// true if the value of left is the same as the value of right; otherwise, false. + /// + public static bool operator ==(MetadataTag left, MetadataTag right) + { + // Check whether both are null + if ((object)left == (object)right) + { + return true; + } + else if ((object)left == null || (object)right == null) + { + return false; + } + left.CheckDisposed(); + right.CheckDisposed(); + // Check all properties + if ((left.Key != right.Key) || + (left.ID != right.ID) || + (left.Description != right.Description) || + (left.Count != right.Count) || + (left.Length != right.Length) || + (left.Model != right.Model) || + (left.Type != right.Type)) + { + return false; + } + if (left.Length == 0) + { + return true; + } + IntPtr ptr1 = FreeImage.GetTagValue(left.tag); + IntPtr ptr2 = FreeImage.GetTagValue(right.tag); + return FreeImage.CompareMemory(ptr1, ptr2, left.Length); + } + + /// + /// Determines whether two specified objects have different values. + /// + /// A or a null reference (Nothing in Visual Basic). + /// A or a null reference (Nothing in Visual Basic). + /// + /// true if the value of left is different from the value of right; otherwise, false. + /// + public static bool operator !=(MetadataTag left, MetadataTag right) + { + return !(left == right); + } + + /// + /// Extracts the value of a instance to a handle. + /// + /// A instance. + /// A new instance of initialized to . + public static implicit operator FITAG(MetadataTag value) + { + return value.tag; + } + + private static FREE_IMAGE_MDMODEL GetModel(FIBITMAP dib, FITAG tag) + { + FITAG value; + foreach (FREE_IMAGE_MDMODEL model in FreeImage.FREE_IMAGE_MDMODELS) + { + FIMETADATA mData = FreeImage.FindFirstMetadata(model, dib, out value); + if (mData.IsNull) + { + continue; + } + try + { + do + { + if (value == tag) + { + return model; + } + } + while (FreeImage.FindNextMetadata(mData, out value)); + } + finally + { + if (!mData.IsNull) + { + FreeImage.FindCloseMetadata(mData); + } + } + } + throw new ArgumentException("'tag' is no metadata object of 'dib'"); + } + + /// + /// Gets the model of the metadata. + /// + public FREE_IMAGE_MDMODEL Model + { + get { CheckDisposed(); return model; } + } + + /// + /// Gets or sets the key of the metadata. + /// + public string Key + { + get { CheckDisposed(); return FreeImage.GetTagKey(tag); } + set + { + CheckDisposed(); + if ((model != FREE_IMAGE_MDMODEL.FIMD_XMP) || (value == "XMLPacket")) + { + FreeImage.SetTagKey(tag, value); + } + } + } + + /// + /// Gets or sets the description of the metadata. + /// + public string Description + { + get { CheckDisposed(); return FreeImage.GetTagDescription(tag); } + set { CheckDisposed(); FreeImage.SetTagDescription(tag, value); } + } + + /// + /// Gets or sets the ID of the metadata. + /// + public ushort ID + { + get { CheckDisposed(); return FreeImage.GetTagID(tag); } + set { CheckDisposed(); FreeImage.SetTagID(tag, value); } + } + + /// + /// Gets the type of the metadata. + /// + public FREE_IMAGE_MDTYPE Type + { + get { CheckDisposed(); return FreeImage.GetTagType(tag); } + internal set { FreeImage.SetTagType(tag, value); } + } + + /// + /// Gets the number of elements the metadata object contains. + /// + public uint Count + { + get { CheckDisposed(); return FreeImage.GetTagCount(tag); } + private set { FreeImage.SetTagCount(tag, value); } + } + + /// + /// Gets the length of the value in bytes. + /// + public uint Length + { + get { CheckDisposed(); return FreeImage.GetTagLength(tag); } + private set { FreeImage.SetTagLength(tag, value); } + } + + private unsafe byte[] GetData() + { + uint length = Length; + byte[] value = new byte[length]; + byte* ptr = (byte*)FreeImage.GetTagValue(tag); + for (int i = 0; i < length; i++) + { + value[i] = ptr[i]; + } + return value; + } + + /// + /// Gets or sets the value of the metadata. + /// + public object Value + { + get + { + unsafe + { + CheckDisposed(); + int cnt = (int)Count; + + if (Type == FREE_IMAGE_MDTYPE.FIDT_ASCII) + { + byte* value = (byte*)FreeImage.GetTagValue(tag); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < cnt; i++) + { + sb.Append(Convert.ToChar(value[i])); + } + return sb.ToString(); + } + else if (Type == FREE_IMAGE_MDTYPE.FIDT_NOTYPE) + { + return null; + } + + Array array = Array.CreateInstance(idList[Type], Count); + void* src = (void*)FreeImage.GetTagValue(tag); + FreeImage.CopyMemory(array, src, Length); + return array; + } + } + set + { + SetValue(value); + } + } + + /// + /// Sets the value of the metadata. + /// In case value is of byte or byte[] is assumed. + /// In case value is of uint or uint[] is assumed. + /// + /// New data of the metadata. + /// True on success, false on failure. + /// + /// The data format is not supported. + /// + /// is null. + public bool SetValue(object value) + { + Type type = value.GetType(); + if (!typeList.ContainsKey(type)) + { + throw new NotSupportedException("The type of value is not supported"); + } + return SetValue(value, typeList[type]); + } + + /// + /// Sets the value of the metadata. + /// + /// New data of the metadata. + /// Type of the data. + /// True on success, false on failure. + /// + /// The data type is not supported. + /// + /// is null. + /// + /// and to not fit. + public bool SetValue(object value, FREE_IMAGE_MDTYPE type) + { + CheckDisposed(); + if ((!value.GetType().IsArray) && (!(value is string))) + { + Array array = Array.CreateInstance(value.GetType(), 1); + array.SetValue(value, 0); + return SetArrayValue(array, type); + } + return SetArrayValue(value, type); + } + + /// + /// Sets the value of this tag to the value of + /// using the given type. + /// + /// New value of the tag. + /// Data-type of the tag. + /// + /// + /// is a null reference. + /// + /// + /// is FIDT_ASCII and + /// is not String. + /// is not FIDT_ASCII and + /// is not Array. + /// + /// is FIDT_NOTYPE. + private unsafe bool SetArrayValue(object value, FREE_IMAGE_MDTYPE type) + { + if (value == null) + { + throw new ArgumentNullException("value"); + } + + byte[] data = null; + + if (type == FREE_IMAGE_MDTYPE.FIDT_ASCII) + { + string tempValue = value as string; + if (tempValue == null) + { + throw new ArgumentException("value"); + } + Type = type; + Length = Count = (uint)tempValue.Length; + data = new byte[Length]; + + for (int i = 0; i < tempValue.Length; i++) + { + data[i] = (byte)tempValue[i]; + } + } + else if (type == FREE_IMAGE_MDTYPE.FIDT_NOTYPE) + { + throw new NotSupportedException("type is not supported."); + } + else + { + Array array = value as Array; + if (array == null) + { + throw new ArgumentException("value"); + } + + if (array.Length != 0) + if (!CheckType(array.GetValue(0).GetType(), type)) + throw new ArgumentException("The type of value is incorrect."); + + Type = type; + Count = (uint)array.Length; + Length = (uint)(array.Length * Marshal.SizeOf(idList[type])); + data = new byte[Length]; + FreeImage.CopyMemory(data, array, Length); + } + + return FreeImage.SetTagValue(tag, data); + } + + private static bool CheckType(Type dataType, FREE_IMAGE_MDTYPE type) + { + if (dataType != null) + switch (type) + { + case FREE_IMAGE_MDTYPE.FIDT_ASCII: + return dataType == typeof(string); + case FREE_IMAGE_MDTYPE.FIDT_BYTE: + return dataType == typeof(byte); + case FREE_IMAGE_MDTYPE.FIDT_DOUBLE: + return dataType == typeof(double); + case FREE_IMAGE_MDTYPE.FIDT_FLOAT: + return dataType == typeof(float); + case FREE_IMAGE_MDTYPE.FIDT_IFD: + return dataType == typeof(uint); + case FREE_IMAGE_MDTYPE.FIDT_LONG: + return dataType == typeof(uint); + case FREE_IMAGE_MDTYPE.FIDT_NOTYPE: + return false; + case FREE_IMAGE_MDTYPE.FIDT_PALETTE: + return dataType == typeof(RGBQUAD); + case FREE_IMAGE_MDTYPE.FIDT_RATIONAL: + return dataType == typeof(FIURational); + case FREE_IMAGE_MDTYPE.FIDT_SBYTE: + return dataType == typeof(sbyte); + case FREE_IMAGE_MDTYPE.FIDT_SHORT: + return dataType == typeof(ushort); + case FREE_IMAGE_MDTYPE.FIDT_SLONG: + return dataType == typeof(int); + case FREE_IMAGE_MDTYPE.FIDT_SRATIONAL: + return dataType == typeof(FIRational); + case FREE_IMAGE_MDTYPE.FIDT_SSHORT: + return dataType == typeof(short); + case FREE_IMAGE_MDTYPE.FIDT_UNDEFINED: + return dataType == typeof(byte); + } + return false; + } + + /// + /// Add this metadata to an image. + /// + /// Handle to a FreeImage bitmap. + /// True on success, false on failure. + public bool AddToImage(FIBITMAP dib) + { + CheckDisposed(); + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (Key == null) + { + throw new ArgumentNullException("Key"); + } + if (!selfCreated) + { + tag = FreeImage.CloneTag(tag); + if (tag.IsNull) + { + throw new Exception("FreeImage.CloneTag() failed."); + } + selfCreated = true; + } + if (!FreeImage.SetMetadata(Model, dib, Key, tag)) + { + return false; + } + FREE_IMAGE_MDMODEL _model = Model; + string _key = Key; + selfCreated = false; + FreeImage.DeleteTag(tag); + return FreeImage.GetMetadata(_model, dib, _key, out tag); + } + + /// + /// Gets a .NET PropertyItem for this metadata tag. + /// + /// The .NET PropertyItem. + public unsafe System.Drawing.Imaging.PropertyItem GetPropertyItem() + { + System.Drawing.Imaging.PropertyItem item = FreeImage.CreatePropertyItem(); + item.Id = ID; + item.Len = (int)Length; + item.Type = (short)Type; + FreeImage.CopyMemory(item.Value = new byte[item.Len], FreeImage.GetTagValue(tag), item.Len); + return item; + } + + /// + /// Converts the value of the object + /// to its equivalent string representation. + /// + /// The string representation of the value of this instance. + public override string ToString() + { + CheckDisposed(); + string fiString = FreeImage.TagToString(model, tag, 0); + + if (String.IsNullOrEmpty(fiString)) + { + return tag.ToString(); + } + else + { + return fiString; + } + } + + /// + /// Creates a deep copy of this . + /// + /// A deep copy of this . + public object Clone() + { + CheckDisposed(); + MetadataTag clone = new MetadataTag(); + clone.model = model; + clone.tag = FreeImage.CloneTag(tag); + clone.selfCreated = true; + return clone; + } + + /// + /// Tests whether the specified object is a instance + /// and is equivalent to this instance. + /// + /// The object to test. + /// true if is a instance + /// equivalent to this instance; otherwise, false. + public override bool Equals(object obj) + { + return ((obj is MetadataTag) && (Equals((MetadataTag)obj))); + } + + /// + /// Tests whether the specified instance is equivalent to this instance. + /// + /// A instance to compare to this instance. + /// true if equivalent to this instance; + /// otherwise, false. + public bool Equals(MetadataTag other) + { + return (this == other); + } + + /// + /// Returns a hash code for this structure. + /// + /// An integer value that specifies the hash code for this . + public override int GetHashCode() + { + return tag.GetHashCode(); + } + + /// + /// Compares this instance with a specified . + /// + /// An object to compare with this instance. + /// A 32-bit signed integer indicating the lexical relationship between the two comparands. + /// is not a . + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + if (!(obj is MetadataTag)) + { + throw new ArgumentException("obj"); + } + return CompareTo((MetadataTag)obj); + } + + /// + /// Compares the current instance with another object of the same type. + /// + /// An object to compare with this instance. + /// A 32-bit signed integer that indicates the relative order of the objects being compared. + public int CompareTo(MetadataTag other) + { + CheckDisposed(); + other.CheckDisposed(); + return tag.CompareTo(other.tag); + } + + /// + /// Releases all resources used by the instance. + /// + public void Dispose() + { + if (!disposed) + { + disposed = true; + if (selfCreated) + { + FreeImage.DeleteTag(tag); + tag = FITAG.Zero; + } + } + } + + /// + /// Gets whether this instance has already been disposed. + /// + public bool Disposed + { + get { return disposed; } + } + + /// + /// Throwns an in case + /// this instance has already been disposed. + /// + private void CheckDisposed() + { + if (disposed) + { + throw new ObjectDisposedException("The object has already been disposed."); + } + } + } +} + +namespace FreeImageAPI +{ + /// + /// Provides methods for working with the standard bitmap palette. + /// + public sealed class Palette : MemoryArray + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private GCHandle paletteHandle; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private RGBQUAD[] array; + + /// + /// Initializes a new instance for the given FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// is null. + /// is not + /// -or- + /// has more than 8bpp. + public Palette(FIBITMAP dib) + : base(FreeImage.GetPalette(dib), (int)FreeImage.GetColorsUsed(dib)) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (FreeImage.GetImageType(dib) != FREE_IMAGE_TYPE.FIT_BITMAP) + { + throw new ArgumentException("dib"); + } + if (FreeImage.GetBPP(dib) > 8u) + { + throw new ArgumentException("dib"); + } + } + + /// + /// Initializes a new instance for the given FITAG that contains + /// a palette. + /// + /// The tag containing the palette. + /// is null. + /// is not + /// . + public Palette(FITAG tag) + : base(FreeImage.GetTagValue(tag), (int)FreeImage.GetTagCount(tag)) + { + if (FreeImage.GetTagType(tag) != FREE_IMAGE_MDTYPE.FIDT_PALETTE) + { + throw new ArgumentException("tag"); + } + } + + /// + /// Initializes a new instance for the given MetadataTag that contains + /// a palette. + /// + /// The tag containing the palette. + /// is null. + /// is not + /// . + public Palette(MetadataTag tag) + : base(FreeImage.GetTagValue(tag.tag), (int)tag.Count) + { + if (FreeImage.GetTagType(tag) != FREE_IMAGE_MDTYPE.FIDT_PALETTE) + { + throw new ArgumentException("tag"); + } + } + + /// + /// Initializes a new instance for the given array of that contains + /// a palette. + /// + /// A RGBQUAD array containing the palette data to initialize this instance. + public Palette(RGBQUAD[] palette) + { + unsafe + { + this.array = (RGBQUAD[])palette.Clone(); + this.paletteHandle = GCHandle.Alloc(array, GCHandleType.Pinned); + + base.baseAddress = (byte*)this.paletteHandle.AddrOfPinnedObject(); + base.length = (int)this.array.Length; + + // Create an array containing a single element. + // Due to the fact, that it's not possible to create pointers + // of generic types, an array is used to obtain the memory + // address of an element of T. + base.buffer = new RGBQUAD[1]; + // The array is pinned immediately to prevent the GC from + // moving it to a different position in memory. + base.handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + // The array and its content have beed pinned, so that its address + // can be safely requested and stored for the whole lifetime + // of the instace. + base.ptr = (byte*)base.handle.AddrOfPinnedObject(); + } + } + + /// + /// Initializes a new instance for the given array of that contains + /// a palette. + /// + /// A Color array containing the palette data to initialize this instance. + public Palette(Color[] palette) + : this(RGBQUAD.ToRGBQUAD(palette)) + { + } + + /// + /// Initializes a new instance with the specified size. + /// + /// The size of the palette. + public Palette(int size) + : this(new RGBQUAD[size]) + { + } + + /// + /// Gets or sets the palette through an array of . + /// + public RGBQUAD[] AsArray + { + get + { + return Data; + } + set + { + Data = value; + } + } + + /// + /// Get an array of that the block of memory represents. + /// This property is used for internal palette operations. + /// + internal unsafe Color[] ColorData + { + get + { + EnsureNotDisposed(); + Color[] data = new Color[length]; + for (int i = 0; i < length; i++) + { + data[i] = Color.FromArgb((int)(((uint*)baseAddress)[i] | 0xFF000000)); + } + return data; + } + } + + /// + /// Returns the palette as an array of . + /// + /// The palette as an array of . + public RGBQUAD[] ToArray() + { + return Data; + } + + /// + /// Creates a linear palette based on the provided . + /// + /// The used to colorize the palette. + /// + /// Only call this method on linear palettes. + /// + public void Colorize(Color color) + { + Colorize(color, 0.5d); + } + + /// + /// Creates a linear palette based on the provided . + /// + /// The used to colorize the palette. + /// The position of the color within the new palette. + /// 0 < < 1. + /// + /// Only call this method on linear palettes. + /// + public void Colorize(Color color, double splitSize) + { + Colorize(color, (int)(length * splitSize)); + } + + /// + /// Creates a linear palette based on the provided . + /// + /// The used to colorize the palette. + /// The position of the color within the new palette. + /// 0 < < . + /// + /// Only call this method on linear palettes. + /// + public void Colorize(Color color, int splitSize) + { + EnsureNotDisposed(); + if (splitSize < 1 || splitSize >= length) + { + throw new ArgumentOutOfRangeException("splitSize"); + } + + RGBQUAD[] pal = new RGBQUAD[length]; + + double red = color.R; + double green = color.G; + double blue = color.B; + + int i = 0; + double r, g, b; + + r = red / splitSize; + g = green / splitSize; + b = blue / splitSize; + + for (; i <= splitSize; i++) + { + pal[i].rgbRed = (byte)(i * r); + pal[i].rgbGreen = (byte)(i * g); + pal[i].rgbBlue = (byte)(i * b); + } + + r = (255 - red) / (length - splitSize); + g = (255 - green) / (length - splitSize); + b = (255 - blue) / (length - splitSize); + + for (; i < length; i++) + { + pal[i].rgbRed = (byte)(red + ((i - splitSize) * r)); + pal[i].rgbGreen = (byte)(green + ((i - splitSize) * g)); + pal[i].rgbBlue = (byte)(blue + ((i - splitSize) * b)); + } + + Data = pal; + } + + /// + /// Creates a linear grayscale palette. + /// + public void CreateGrayscalePalette() + { + Colorize(Color.White, length - 1); + } + + /// + /// Creates a linear grayscale palette. + /// + /// true to create an inverse grayscale palette. + public void CreateGrayscalePalette(bool inverse) + { + Colorize(Color.White, inverse ? 0 : length - 1); + } + + /// + /// Creates a linear palette with the specified . + /// + /// + /// A linear grayscale palette contains all shades of colors from + /// black to white. This method creates a similar palette with the white + /// color being replaced by the specified color. + /// + /// The used to create the palette. + /// true to create an inverse palette. + public void CreateGrayscalePalette(Color color, bool inverse) + { + Colorize(color, inverse ? 0 : length - 1); + } + + /// + /// Reverses the palette. + /// + public void Reverse() + { + EnsureNotDisposed(); + if (array != null) + { + Array.Reverse(array); + } + else + { + RGBQUAD[] localArray = Data; + Array.Reverse(localArray); + Data = localArray; + } + } + + /// + /// Copies the values from the specified to this instance. + /// + /// The palette to copy from. + /// + /// is a null reference. + public void CopyFrom(Palette palette) + { + EnsureNotDisposed(); + if (palette == null) + { + throw new ArgumentNullException("palette"); + } + CopyFrom(palette.Data, 0, 0, Math.Min(palette.Length, this.Length)); + } + + /// + /// Copies the values from the specified to this instance, + /// starting at the specified . + /// + /// The palette to copy from. + /// The position in this instance where the values + /// will be copied to. + /// + /// is a null reference. + /// + /// is outside the range of valid indexes. + public void CopyFrom(Palette palette, int offset) + { + EnsureNotDisposed(); + CopyFrom(palette.Data, 0, offset, Math.Min(palette.Length, this.Length - offset)); + } + + /// + /// Saves this to the specified file. + /// + /// + /// A string that contains the name of the file to which to save this . + /// + public void Save(string filename) + { + using (Stream stream = new FileStream(filename, FileMode.Create, FileAccess.Write)) + { + Save(stream); + } + } + + /// + /// Saves this to the specified stream. + /// + /// + /// The where the image will be saved. + /// + public void Save(Stream stream) + { + Save(new BinaryWriter(stream)); + } + + /// + /// Saves this using the specified writer. + /// + /// + /// The used to save the image. + /// + public void Save(BinaryWriter writer) + { + EnsureNotDisposed(); + writer.Write(ToByteArray()); + } + + /// + /// Loads a palette from the specified file. + /// + /// The name of the palette file. + public void Load(string filename) + { + using (Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read)) + { + Load(stream); + } + } + + /// + /// Loads a palette from the specified stream. + /// + /// The stream to load the palette from. + public void Load(Stream stream) + { + Load(new BinaryReader(stream)); + } + + /// + /// Loads a palette from the reader. + /// + /// The reader to load the palette from. + public void Load(BinaryReader reader) + { + EnsureNotDisposed(); + unsafe + { + int size = length * sizeof(RGBQUAD); + byte[] data = reader.ReadBytes(size); + fixed (byte* src = data) + { + CopyMemory(baseAddress, src, data.Length); + } + } + } + + /// + /// Releases allocated handles associated with this instance. + /// + /// true to release managed resources. + protected override void Dispose(bool disposing) + { + if (paletteHandle.IsAllocated) + paletteHandle.Free(); + array = null; + + base.Dispose(disposing); + } + } +} + +namespace FreeImageAPI.Plugins +{ + /// + /// Class representing all registered in FreeImage. + /// + public static class PluginRepository + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly List plugins = null; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private static readonly List localPlugins = null; + + static PluginRepository() + { + plugins = new List(FreeImage.GetFIFCount()); + localPlugins = new List(0); + for (int i = 0; i < plugins.Capacity; i++) + { + plugins.Add(new FreeImagePlugin((FREE_IMAGE_FORMAT)i)); + } + } + + /// + /// Adds local plugin to this class. + /// + /// The registered plugin. + internal static void RegisterLocalPlugin(LocalPlugin localPlugin) + { + FreeImagePlugin plugin = new FreeImagePlugin(localPlugin.Format); + plugins.Add(plugin); + localPlugins.Add(plugin); + } + + /// + /// Returns an instance of , representing the given format. + /// + /// The representing format. + /// An instance of . + public static FreeImagePlugin Plugin(FREE_IMAGE_FORMAT fif) + { + return Plugin((int)fif); + } + + /// + /// Returns an instance of , + /// representing the format at the given index. + /// + /// The index of the representing format. + /// An instance of . + public static FreeImagePlugin Plugin(int index) + { + return (index >= 0) ? plugins[index] : null; + } + + /// + /// Returns an instance of . + /// is searched in: + /// Format, RegExpr, + /// ValidExtension and ValidFilename. + /// + /// The expression to search for. + /// An instance of . + public static FreeImagePlugin Plugin(string expression) + { + FreeImagePlugin result = null; + expression = expression.ToLower(); + + foreach (FreeImagePlugin plugin in plugins) + { + if (plugin.Format.ToLower().Contains(expression) || + plugin.RegExpr.ToLower().Contains(expression) || + plugin.ValidExtension(expression, StringComparison.CurrentCultureIgnoreCase) || + plugin.ValidFilename(expression, StringComparison.CurrentCultureIgnoreCase)) + { + result = plugin; + break; + } + } + + return result; + } + + /// + /// Returns an instance of for the given format. + /// + /// The format of the Plugin. + /// An instance of . + public static FreeImagePlugin PluginFromFormat(string format) + { + return Plugin(FreeImage.GetFIFFromFormat(format)); + } + + /// + /// Returns an instance of for the given filename. + /// + /// The valid filename for the plugin. + /// An instance of . + public static FreeImagePlugin PluginFromFilename(string filename) + { + return Plugin(FreeImage.GetFIFFromFilename(filename)); + } + + /// + /// Returns an instance of for the given mime. + /// + /// The valid mime for the plugin. + /// An instance of . + public static FreeImagePlugin PluginFromMime(string mime) + { + return Plugin(FreeImage.GetFIFFromMime(mime)); + } + + /// + /// Gets the number of registered plugins. + /// + public static int FIFCount + { + get + { + return FreeImage.GetFIFCount(); + } + } + + /// + /// Gets a readonly collection of all plugins. + /// + public static ReadOnlyCollection PluginList + { + get + { + return plugins.AsReadOnly(); + } + } + + /// + /// Gets a list of plugins that are only able to + /// read but not to write. + /// + public static List ReadOnlyPlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (p.SupportsReading && !p.SupportsWriting) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Gets a list of plugins that are only able to + /// write but not to read. + /// + public static List WriteOnlyPlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (!p.SupportsReading && p.SupportsWriting) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Gets a list of plugins that are not able to + /// read or write. + /// + public static List StupidPlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (!p.SupportsReading && !p.SupportsWriting) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Gets a list of plugins that are able to read. + /// + public static List ReadablePlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (p.SupportsReading) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Gets a list of plugins that are able to write. + /// + public static List WriteablePlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (p.SupportsWriting) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Gets a list of local plugins. + /// + public static ReadOnlyCollection LocalPlugins + { + get + { + return localPlugins.AsReadOnly(); + } + } + + /// + /// Gets a list of built-in plugins. + /// + public static List BuiltInPlugins + { + get + { + List list = new List(); + foreach (FreeImagePlugin p in plugins) + { + if (!localPlugins.Contains(p)) + { + list.Add(p); + } + } + return list; + } + } + + /// + /// Windows or OS/2 Bitmap File (*.BMP) + /// + public static FreeImagePlugin BMP { get { return plugins[0]; } } + + /// + /// Independent JPEG Group (*.JPG, *.JIF, *.JPEG, *.JPE) + /// + public static FreeImagePlugin ICO { get { return plugins[1]; } } + + /// + /// Independent JPEG Group (*.JPG, *.JIF, *.JPEG, *.JPE) + /// + public static FreeImagePlugin JPEG { get { return plugins[2]; } } + + /// + /// JPEG Network Graphics (*.JNG) + /// + public static FreeImagePlugin JNG { get { return plugins[3]; } } + + /// + /// Commodore 64 Koala format (*.KOA) + /// + public static FreeImagePlugin KOALA { get { return plugins[4]; } } + + /// + /// Amiga IFF (*.IFF, *.LBM) + /// + public static FreeImagePlugin LBM { get { return plugins[5]; } } + + /// + /// Amiga IFF (*.IFF, *.LBM) + /// + public static FreeImagePlugin IFF { get { return plugins[5]; } } + + /// + /// Multiple Network Graphics (*.MNG) + /// + public static FreeImagePlugin MNG { get { return plugins[6]; } } + + /// + /// Portable Bitmap (ASCII) (*.PBM) + /// + public static FreeImagePlugin PBM { get { return plugins[7]; } } + + /// + /// Portable Bitmap (BINARY) (*.PBM) + /// + public static FreeImagePlugin PBMRAW { get { return plugins[8]; } } + + /// + /// Kodak PhotoCD (*.PCD) + /// + public static FreeImagePlugin PCD { get { return plugins[9]; } } + + /// + /// Zsoft Paintbrush PCX bitmap format (*.PCX) + /// + public static FreeImagePlugin PCX { get { return plugins[10]; } } + + /// + /// Portable Graymap (ASCII) (*.PGM) + /// + public static FreeImagePlugin PGM { get { return plugins[11]; } } + + /// + /// Portable Graymap (BINARY) (*.PGM) + /// + public static FreeImagePlugin PGMRAW { get { return plugins[12]; } } + + /// + /// Portable Network Graphics (*.PNG) + /// + public static FreeImagePlugin PNG { get { return plugins[13]; } } + + /// + /// Portable Pixelmap (ASCII) (*.PPM) + /// + public static FreeImagePlugin PPM { get { return plugins[14]; } } + + /// + /// Portable Pixelmap (BINARY) (*.PPM) + /// + public static FreeImagePlugin PPMRAW { get { return plugins[15]; } } + + /// + /// Sun Rasterfile (*.RAS) + /// + public static FreeImagePlugin RAS { get { return plugins[16]; } } + + /// + /// truevision Targa files (*.TGA, *.TARGA) + /// + public static FreeImagePlugin TARGA { get { return plugins[17]; } } + + /// + /// Tagged Image File Format (*.TIF, *.TIFF) + /// + public static FreeImagePlugin TIFF { get { return plugins[18]; } } + + /// + /// Wireless Bitmap (*.WBMP) + /// + public static FreeImagePlugin WBMP { get { return plugins[19]; } } + + /// + /// Adobe Photoshop (*.PSD) + /// + public static FreeImagePlugin PSD { get { return plugins[20]; } } + + /// + /// Dr. Halo (*.CUT) + /// + public static FreeImagePlugin CUT { get { return plugins[21]; } } + + /// + /// X11 Bitmap Format (*.XBM) + /// + public static FreeImagePlugin XBM { get { return plugins[22]; } } + + /// + /// X11 Pixmap Format (*.XPM) + /// + public static FreeImagePlugin XPM { get { return plugins[23]; } } + + /// + /// DirectDraw Surface (*.DDS) + /// + public static FreeImagePlugin DDS { get { return plugins[24]; } } + + /// + /// Graphics Interchange Format (*.GIF) + /// + public static FreeImagePlugin GIF { get { return plugins[25]; } } + + /// + /// High Dynamic Range (*.HDR) + /// + public static FreeImagePlugin HDR { get { return plugins[26]; } } + + /// + /// Raw Fax format CCITT G3 (*.G3) + /// + public static FreeImagePlugin FAXG3 { get { return plugins[27]; } } + + /// + /// Silicon Graphics SGI image format (*.SGI) + /// + public static FreeImagePlugin SGI { get { return plugins[28]; } } + + /// + /// OpenEXR format (*.EXR) + /// + public static FreeImagePlugin EXR { get { return plugins[29]; } } + + /// + /// JPEG-2000 format (*.J2K, *.J2C) + /// + public static FreeImagePlugin J2K { get { return plugins[30]; } } + + /// + /// JPEG-2000 format (*.JP2) + /// + public static FreeImagePlugin JP2 { get { return plugins[31]; } } + + /// + /// Portable FloatMap (*.PFM) + /// + public static FreeImagePlugin PFM { get { return plugins[32]; } } + + /// + /// Macintosh PICT (*.PICT) + /// + public static FreeImagePlugin PICT { get { return plugins[33]; } } + + /// + /// RAW camera image (*.*) + /// + public static FreeImagePlugin RAW { get { return plugins[34]; } } + } +} + +namespace FreeImageAPI +{ + /// + /// Provides methods for working with generic bitmap scanlines. + /// + /// Type of the bitmaps' scanlines. + public sealed class Scanline : MemoryArray where T : struct + { + /// + /// Initializes a new instance based on the specified FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + public Scanline(FIBITMAP dib) + : this(dib, 0) + { + } + + /// + /// Initializes a new instance based on the specified FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// Index of the zero based scanline. + public Scanline(FIBITMAP dib, int scanline) + : this(dib, scanline, (int)(typeof(T) == typeof(FI1BIT) ? + FreeImage.GetBPP(dib) * FreeImage.GetWidth(dib) : + typeof(T) == typeof(FI4BIT) ? + FreeImage.GetBPP(dib) * FreeImage.GetWidth(dib) / 4 : + (FreeImage.GetBPP(dib) * FreeImage.GetWidth(dib)) / (Marshal.SizeOf(typeof(T)) * 8))) + { + } + + internal Scanline(FIBITMAP dib, int scanline, int length) + : base(FreeImage.GetScanLine(dib, scanline), length) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if ((scanline < 0) || (scanline >= FreeImage.GetHeight(dib))) + { + throw new ArgumentOutOfRangeException("scanline"); + } + } + } +} + +namespace FreeImageAPI.IO +{ + /// + /// Class wrapping streams, implementing a buffer for read data, + /// so that seek operations can be made. + /// + /// + /// FreeImage can load bitmaps from arbitrary sources. + /// .NET works with different streams like File- or NetConnection-strams. + /// NetConnection streams, which are used to load files from web servers, + /// for example cannot seek. + /// But FreeImage frequently uses the seek operation when loading bitmaps. + /// StreamWrapper wrapps a stream and makes it seekable by caching all read + /// data into an internal MemoryStream to jump back- and forward. + /// StreamWapper is for internal use and only for loading from streams. + /// + internal class StreamWrapper : Stream + { + /// + /// The stream to wrap + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly Stream stream; + + /// + /// The caching stream + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private MemoryStream memoryStream = new MemoryStream(); + + /// + /// Indicates if the wrapped stream reached its end + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool eos = false; + + /// + /// Tells the wrapper to block readings or not + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool blocking = false; + + /// + /// Indicates if the wrapped stream is disposed or not + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private bool disposed = false; + + /// + /// Initializes a new instance based on the specified . + /// + /// The stream to wrap. + /// When true the wrapper always tries to read the requested + /// amount of data from the wrapped stream. + public StreamWrapper(Stream stream, bool blocking) + { + if (!stream.CanRead) + { + throw new ArgumentException("stream is not capable of reading."); + } + this.stream = stream; + this.blocking = blocking; + } + + /// + /// Releases all resources used by the instance. + /// + ~StreamWrapper() + { + Dispose(false); + } + + // The wrapper only accepts readable streams + public override bool CanRead + { + get { checkDisposed(); return true; } + } + + // We implement that feature + public override bool CanSeek + { + get { checkDisposed(); return true; } + } + + // The wrapper is readonly + public override bool CanWrite + { + get { checkDisposed(); return false; } + } + + // Just forward it + public override void Flush() + { + checkDisposed(); + stream.Flush(); + } + + // Calling this property will cause the wrapper to read the stream + // to its end and cache it completely. + public override long Length + { + get + { + checkDisposed(); + if (!eos) + { + Fill(); + } + return memoryStream.Length; + } + } + + // Gets or sets the current position + public override long Position + { + get + { + checkDisposed(); + return memoryStream.Position; + } + set + { + checkDisposed(); + Seek(value, SeekOrigin.Begin); + } + } + + // Implements the reading feature + public override int Read(byte[] buffer, int offset, int count) + { + checkDisposed(); + // total bytes read from memory-stream + int memoryBytes = 0; + // total bytes read from the original stream + int streamBytes = 0; + memoryBytes = memoryStream.Read(buffer, offset, count); + if ((count > memoryBytes) && (!eos)) + { + // read the rest from the original stream (can be 0 bytes) + do + { + int read = stream.Read( + buffer, + offset + memoryBytes + streamBytes, + count - memoryBytes - streamBytes); + streamBytes += read; + if (read == 0) + { + eos = true; + break; + } + if (!blocking) + { + break; + } + } while ((memoryBytes + streamBytes) < count); + // copy the bytes from the original stream into the memory stream + // if 0 bytes were read we write 0 so the memory-stream is not changed + memoryStream.Write(buffer, offset + memoryBytes, streamBytes); + } + return memoryBytes + streamBytes; + } + + // Implements the seeking feature + public override long Seek(long offset, SeekOrigin origin) + { + checkDisposed(); + long newPosition = 0L; + // get new position + switch (origin) + { + case SeekOrigin.Begin: + newPosition = offset; + break; + case SeekOrigin.Current: + newPosition = memoryStream.Position + offset; + break; + case SeekOrigin.End: + // to seek from the end have have to read to the end first + if (!eos) + { + Fill(); + } + newPosition = memoryStream.Length + offset; + break; + default: + throw new ArgumentOutOfRangeException("origin"); + } + // in case the new position is beyond the memory-streams end + // and the original streams end hasn't been reached + // the original stream is read until either the stream ends or + // enough bytes have been read + if ((newPosition > memoryStream.Length) && (!eos)) + { + memoryStream.Position = memoryStream.Length; + int bytesToRead = (int)(newPosition - memoryStream.Length); + byte[] buffer = new byte[1024]; + do + { + bytesToRead -= Read(buffer, 0, (bytesToRead >= buffer.Length) ? buffer.Length : bytesToRead); + } while ((bytesToRead > 0) && (!eos)); + } + memoryStream.Position = (newPosition <= memoryStream.Length) ? newPosition : memoryStream.Length; + return 0; + } + + // No write-support + public override void SetLength(long value) + { + throw new Exception("The method or operation is not implemented."); + } + + // No write-support + public override void Write(byte[] buffer, int offset, int count) + { + throw new Exception("The method or operation is not implemented."); + } + + public void Reset() + { + checkDisposed(); + Position = 0; + } + + // Reads the wrapped stream until its end. + private void Fill() + { + if (!eos) + { + memoryStream.Position = memoryStream.Length; + int bytesRead = 0; + byte[] buffer = new byte[1024]; + do + { + bytesRead = stream.Read(buffer, 0, buffer.Length); + memoryStream.Write(buffer, 0, bytesRead); + } while (bytesRead != 0); + eos = true; + } + } + + public new void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private new void Dispose(bool disposing) + { + if (!disposed) + { + disposed = true; + if (disposing) + { + if (memoryStream != null) + { + memoryStream.Dispose(); + } + } + } + } + + public bool Disposed + { + get { return disposed; } + } + + private void checkDisposed() + { + if (disposed) throw new ObjectDisposedException("StreamWrapper"); + } + } +} + + #endregion + + #region Enums + +namespace FreeImageAPI +{ + /// + /// Enumeration used for color conversions. + /// FREE_IMAGE_COLOR_DEPTH contains several colors to convert to. + /// The default value 'FICD_AUTO'. + /// + [System.Flags] + public enum FREE_IMAGE_COLOR_DEPTH + { + /// + /// Unknown. + /// + FICD_UNKNOWN = 0, + /// + /// Auto selected by the used algorithm. + /// + FICD_AUTO = FICD_UNKNOWN, + /// + /// 1-bit. + /// + FICD_01_BPP = 1, + /// + /// 1-bit using dithering. + /// + FICD_01_BPP_DITHER = FICD_01_BPP, + /// + /// 1-bit using threshold. + /// + FICD_01_BPP_THRESHOLD = FICD_01_BPP | 2, + /// + /// 4-bit. + /// + FICD_04_BPP = 4, + /// + /// 8-bit. + /// + FICD_08_BPP = 8, + /// + /// 16-bit 555 (1 bit remains unused). + /// + FICD_16_BPP_555 = FICD_16_BPP | 2, + /// + /// 16-bit 565 (all bits are used). + /// + FICD_16_BPP = 16, + /// + /// 24-bit. + /// + FICD_24_BPP = 24, + /// + /// 32-bit. + /// + FICD_32_BPP = 32, + /// + /// Reorder palette (make it linear). Only affects 1-, 4- and 8-bit images. + /// The palette is only reordered in case the image is greyscale + /// (all palette entries have the same red, green and blue value). + /// + FICD_REORDER_PALETTE = 1024, + /// + /// Converts the image to greyscale. + /// + FICD_FORCE_GREYSCALE = 2048, + /// + /// Flag to mask out all non color depth flags. + /// + FICD_COLOR_MASK = FICD_01_BPP | FICD_04_BPP | FICD_08_BPP | FICD_16_BPP | FICD_24_BPP | FICD_32_BPP + } +} + +namespace FreeImageAPI +{ + /// + /// List of combinable compare modes. + /// + [System.Flags] + public enum FREE_IMAGE_COMPARE_FLAGS + { + /// + /// Compare headers. + /// + HEADER = 0x1, + /// + /// Compare palettes. + /// + PALETTE = 0x2, + /// + /// Compare pixel data. + /// + DATA = 0x4, + /// + /// Compare meta data. + /// + METADATA = 0x8, + /// + /// Compare everything. + /// + COMPLETE = (HEADER | PALETTE | DATA | METADATA) + } +} + +namespace FreeImageAPI +{ + /// + /// Flags for copying data from a bitmap to another. + /// + public enum FREE_IMAGE_METADATA_COPY + { + /// + /// Exisiting metadata will remain unchanged. + /// + KEEP_EXISITNG = 0x0, + /// + /// Existing metadata will be cleared. + /// + CLEAR_EXISTING = 0x1, + /// + /// Existing metadata will be overwritten. + /// + REPLACE_EXISTING = 0x2 + } +} + +namespace FreeImageAPI +{ + /// + /// List different search modes. + /// + [System.Flags] + public enum MD_SEARCH_FLAGS + { + /// + /// The key of the metadata. + /// + KEY = 0x1, + /// + /// The description of the metadata + /// + DESCRIPTION = 0x2, + /// + /// The ToString value of the metadata + /// + TOSTRING = 0x4, + } +} + + #endregion + +namespace FreeImageAPI +{ + /// + /// Static class importing functions from the FreeImage library + /// and providing additional functions. + /// + public static partial class FreeImage + { + #region Constants + + /// + /// Array containing all 'FREE_IMAGE_MDMODEL's. + /// + public static readonly FREE_IMAGE_MDMODEL[] FREE_IMAGE_MDMODELS = + (FREE_IMAGE_MDMODEL[])Enum.GetValues(typeof(FREE_IMAGE_MDMODEL)); + + /// + /// Stores handles used to read from streams. + /// + private static Dictionary streamHandles = + new Dictionary(); + + /// + /// Version of the wrapper library. + /// + private static Version WrapperVersion; + + private const int DIB_RGB_COLORS = 0; + private const int DIB_PAL_COLORS = 1; + private const int CBM_INIT = 0x4; + + /// + /// An uncompressed format. + /// + public const int BI_RGB = 0; + + /// + /// A run-length encoded (RLE) format for bitmaps with 8 bpp. The compression format is a 2-byte + /// format consisting of a count byte followed by a byte containing a color index. + /// + public const int BI_RLE8 = 1; + + /// + /// An RLE format for bitmaps with 4 bpp. The compression format is a 2-byte format consisting + /// of a count byte followed by two word-length color indexes. + /// + public const int BI_RLE4 = 2; + + /// + /// Specifies that the bitmap is not compressed and that the color table consists of three + /// DWORD color masks that specify the red, green, and blue components, respectively, + /// of each pixel. This is valid when used with 16- and 32-bpp bitmaps. + /// + public const int BI_BITFIELDS = 3; + + /// + /// Windows 98/Me, Windows 2000/XP: Indicates that the image is a JPEG image. + /// + public const int BI_JPEG = 4; + + /// + /// Windows 98/Me, Windows 2000/XP: Indicates that the image is a PNG image. + /// + public const int BI_PNG = 5; + + #endregion + + #region General functions + + /// + /// Returns the internal version of this FreeImage .NET wrapper. + /// + /// The internal version of this FreeImage .NET wrapper. + public static Version GetWrapperVersion() + { + if (WrapperVersion == null) + { + try + { + object[] attributes = Assembly.GetAssembly(typeof(FreeImage)) + .GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false); + if ((attributes != null) && (attributes.Length != 0)) + { + AssemblyFileVersionAttribute attribute = + attributes[0] as AssemblyFileVersionAttribute; + if ((attribute != null) && (attribute.Version != null)) + { + return (WrapperVersion = new Version(attribute.Version)); + } + } + } + catch + { + + } + + WrapperVersion = new Version(); + } + + return WrapperVersion; + } + + /// + /// Returns the version of the native FreeImage library. + /// + /// The version of the native FreeImage library. + public static Version GetNativeVersion() + { + return new Version(GetVersion()); + } + + /// + /// Returns a value indicating if the FreeImage library is available or not. + /// See remarks for further details. + /// + /// false if the file is not available or out of date; + /// true, otherwise. + /// + /// The FreeImage.NET library is a wrapper for the native C++ library + /// (FreeImage.dll ... dont mix ist up with this library FreeImageNet.dll). + /// The native library must be either in the same folder as the program's + /// executable or in a folder contained in the envirent variable PATH + /// (for example %WINDIR%\System32). + /// Further more must both libraries, including the program itself, + /// be the same architecture (x86 or x64). + /// + public static bool IsAvailable() + { + try + { + // Call a static fast executing function + Version nativeVersion = new Version(GetVersion()); + Version wrapperVersion = GetWrapperVersion(); + // No exception thrown, the library seems to be present + return + (nativeVersion.Major >= wrapperVersion.Major) && + (nativeVersion.Minor >= wrapperVersion.Minor) && + (nativeVersion.Build >= wrapperVersion.Build); + } + catch (DllNotFoundException) + { + return false; + } + catch (EntryPointNotFoundException) + { + return false; + } + catch (BadImageFormatException) + { + return false; + } + } + + #endregion + + #region Bitmap management functions + + /// + /// Creates a new bitmap in memory. + /// + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new Bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// Handle to a FreeImage bitmap. + public static FIBITMAP Allocate(int width, int height, int bpp) + { + return Allocate(width, height, bpp, 0, 0, 0); + } + + /// + /// Creates a new bitmap in memory. + /// + /// Type of the image. + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new Bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// Handle to a FreeImage bitmap. + public static FIBITMAP AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp) + { + return AllocateT(type, width, height, bpp, 0, 0, 0); + } + + /// + /// Allocates a new image of the specified width, height and bit depth and optionally + /// fills it with the specified color. See remarks for further details. + /// + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmaps. + /// The color to fill the bitmap with or null. + /// Options to enable or disable function-features. + /// The palette of the bitmap or null. + /// Handle to a FreeImage bitmap. + /// + /// This function is an extension to , which additionally supports + /// specifying a palette to be set for the newly create image, as well as specifying a + /// background color, the newly created image should initially be filled with. + /// + /// Basically, this function internally relies on function , followed by a + /// call to . This is why both parameters + /// and behave the same as it is + /// documented for function . + /// So, please refer to the documentation of to + /// learn more about parameters and . + /// + /// The palette specified through parameter is only copied to the + /// newly created image, if the desired bit depth is smaller than or equal to 8 bits per pixel. + /// In other words, the parameter is only taken into account for + /// palletized images. So, for an 8-bit image, the length is 256, for an 4-bit image it is 16 + /// and it is 2 for a 1-bit image. In other words, this function does not support partial palettes. + /// + /// However, specifying a palette is not necesarily needed, even for palletized images. This + /// function is capable of implicitly creating a palette, if is null. + /// If the specified background color is a greyscale value (red = green = blue) or if option + /// is specified, a greyscale palette + /// is created. For a 1-bit image, only if the specified background color is either black or white, + /// a monochrome palette, consisting of black and white only is created. In any case, the darker + /// colors are stored at the smaller palette indices. + /// + /// If the specified background color is not a greyscale value, or is neither black nor white + /// for a 1-bit image, solely this specified color is injected into the otherwise black-initialized + /// palette. For this operation, option + /// is implicit, so the specified is applied to the palette entry, + /// specified by the background color's field. + /// The image is then filled with this palette index. + /// + /// This function returns a newly created image as function does, if both + /// parameters and are null. + /// If only is null, the palette pointed to by + /// parameter is initially set for the new image, if a palletized + /// image of type is created. + /// However, in the latter case, this function returns an image, whose + /// pixels are all initialized with zeros so, the image will be filled with the color of the + /// first palette entry. + /// + public static FIBITMAP AllocateEx(int width, int height, int bpp, + RGBQUAD? color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette) + { + return AllocateEx(width, height, bpp, color, options, palette, 0, 0, 0); + } + + /// + /// Allocates a new image of the specified width, height and bit depth and optionally + /// fills it with the specified color. See remarks for further details. + /// + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmaps. + /// The color to fill the bitmap with or null. + /// Options to enable or disable function-features. + /// The palette of the bitmap or null. + /// Red part of the color layout. + /// eg: 0xFF0000 + /// Green part of the color layout. + /// eg: 0x00FF00 + /// Blue part of the color layout. + /// eg: 0x0000FF + /// Handle to a FreeImage bitmap. + /// + /// This function is an extension to , which additionally supports + /// specifying a palette to be set for the newly create image, as well as specifying a + /// background color, the newly created image should initially be filled with. + /// + /// Basically, this function internally relies on function , followed by a + /// call to . This is why both parameters + /// and behave the same as it is + /// documented for function . + /// So, please refer to the documentation of to + /// learn more about parameters and . + /// + /// The palette specified through parameter is only copied to the + /// newly created image, if the desired bit depth is smaller than or equal to 8 bits per pixel. + /// In other words, the parameter is only taken into account for + /// palletized images. So, for an 8-bit image, the length is 256, for an 4-bit image it is 16 + /// and it is 2 for a 1-bit image. In other words, this function does not support partial palettes. + /// + /// However, specifying a palette is not necesarily needed, even for palletized images. This + /// function is capable of implicitly creating a palette, if is null. + /// If the specified background color is a greyscale value (red = green = blue) or if option + /// is specified, a greyscale palette + /// is created. For a 1-bit image, only if the specified background color is either black or white, + /// a monochrome palette, consisting of black and white only is created. In any case, the darker + /// colors are stored at the smaller palette indices. + /// + /// If the specified background color is not a greyscale value, or is neither black nor white + /// for a 1-bit image, solely this specified color is injected into the otherwise black-initialized + /// palette. For this operation, option + /// is implicit, so the specified is applied to the palette entry, + /// specified by the background color's field. + /// The image is then filled with this palette index. + /// + /// This function returns a newly created image as function does, if both + /// parameters and are null. + /// If only is null, the palette pointed to by + /// parameter is initially set for the new image, if a palletized + /// image of type is created. + /// However, in the latter case, this function returns an image, whose + /// pixels are all initialized with zeros so, the image will be filled with the color of the + /// first palette entry. + /// + public static FIBITMAP AllocateEx(int width, int height, int bpp, + RGBQUAD? color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette, + uint red_mask, uint green_mask, uint blue_mask) + { + if ((palette != null) && (bpp <= 8) && (palette.Length < (1 << bpp))) + return FIBITMAP.Zero; + + if (color.HasValue) + { + GCHandle handle = new GCHandle(); + try + { + RGBQUAD[] buffer = new RGBQUAD[] { color.Value }; + handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + return AllocateEx(width, height, bpp, handle.AddrOfPinnedObject(), + options, palette, red_mask, green_mask, blue_mask); + } + finally + { + if (handle.IsAllocated) + handle.Free(); + } + } + else + { + return AllocateEx(width, height, bpp, IntPtr.Zero, + options, palette, red_mask, green_mask, blue_mask); + } + } + + /// + /// Allocates a new image of the specified type, width, height and bit depth and optionally + /// fills it with the specified color. See remarks for further details. + /// + /// The type of the specified color. + /// Type of the image. + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// The color to fill the bitmap with or null. + /// Options to enable or disable function-features. + /// The palette of the bitmap or null. + /// Handle to a FreeImage bitmap. + /// + /// This function is an extension to , which additionally supports + /// specifying a palette to be set for the newly create image, as well as specifying a + /// background color, the newly created image should initially be filled with. + /// + /// Basically, this function internally relies on function , followed by a + /// call to . This is why both parameters + /// and behave the same as it is + /// documented for function . So, please refer to the + /// documentation of to learn more about parameters color and options. + /// + /// The palette specified through parameter palette is only copied to the newly created + /// image, if its image type is and the desired bit + /// depth is smaller than or equal to 8 bits per pixel. In other words, the + /// palette is only taken into account for palletized images. However, if the preceding conditions + /// match and if is not null, the palette is assumed to be at + /// least as large as the size of a fully populated palette for the desired bit depth. + /// So, for an 8-bit image, this length is 256, for an 4-bit image it is 16 and it is + /// 2 for a 1-bit image. In other words, this function does not support partial palettes. + /// + /// However, specifying a palette is not necesarily needed, even for palletized images. This + /// function is capable of implicitly creating a palette, if is null. + /// If the specified background color is a greyscale value (red = green = blue) or if option + /// is specified, a greyscale palette + /// is created. For a 1-bit image, only if the specified background color is either black or white, + /// a monochrome palette, consisting of black and white only is created. In any case, the darker + /// colors are stored at the smaller palette indices. + /// + /// If the specified background color is not a greyscale value, or is neither black nor white + /// for a 1-bit image, solely this specified color is injected into the otherwise black-initialized + /// palette. For this operation, option + /// is implicit, so the specified color is applied to the palette entry, specified by the + /// background color's field. The image is then filled with + /// this palette index. + /// + /// This function returns a newly created image as function does, if both + /// parameters and are null. + /// If only is null, the palette pointed to by + /// parameter is initially set for the new image, if a palletized + /// image of type is created. + /// However, in the latter case, this function returns an image, whose + /// pixels are all initialized with zeros so, the image will be filled with the color of the + /// first palette entry. + /// + public static FIBITMAP AllocateExT(FREE_IMAGE_TYPE type, int width, int height, int bpp, + T? color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette) where T : struct + { + return AllocateExT(type, width, height, bpp, color, options, palette, 0, 0, 0); + } + + /// + /// Allocates a new image of the specified type, width, height and bit depth and optionally + /// fills it with the specified color. See remarks for further details. + /// + /// The type of the specified color. + /// Type of the image. + /// Width of the new bitmap. + /// Height of the new bitmap. + /// Bit depth of the new bitmap. + /// Supported pixel depth: 1-, 4-, 8-, 16-, 24-, 32-bit per pixel for standard bitmap + /// The color to fill the bitmap with or null. + /// Options to enable or disable function-features. + /// The palette of the bitmap or null. + /// Red part of the color layout. + /// eg: 0xFF0000 + /// Green part of the color layout. + /// eg: 0x00FF00 + /// Blue part of the color layout. + /// eg: 0x0000FF + /// Handle to a FreeImage bitmap. + /// + /// This function is an extension to , which additionally supports + /// specifying a palette to be set for the newly create image, as well as specifying a + /// background color, the newly created image should initially be filled with. + /// + /// Basically, this function internally relies on function , followed by a + /// call to . This is why both parameters + /// and behave the same as it is + /// documented for function . So, please refer to the + /// documentation of to learn more about parameters color and options. + /// + /// The palette specified through parameter palette is only copied to the newly created + /// image, if its image type is and the desired bit + /// depth is smaller than or equal to 8 bits per pixel. In other words, the + /// palette is only taken into account for palletized images. However, if the preceding conditions + /// match and if is not null, the palette is assumed to be at + /// least as large as the size of a fully populated palette for the desired bit depth. + /// So, for an 8-bit image, this length is 256, for an 4-bit image it is 16 and it is + /// 2 for a 1-bit image. In other words, this function does not support partial palettes. + /// + /// However, specifying a palette is not necesarily needed, even for palletized images. This + /// function is capable of implicitly creating a palette, if is null. + /// If the specified background color is a greyscale value (red = green = blue) or if option + /// is specified, a greyscale palette + /// is created. For a 1-bit image, only if the specified background color is either black or white, + /// a monochrome palette, consisting of black and white only is created. In any case, the darker + /// colors are stored at the smaller palette indices. + /// + /// If the specified background color is not a greyscale value, or is neither black nor white + /// for a 1-bit image, solely this specified color is injected into the otherwise black-initialized + /// palette. For this operation, option + /// is implicit, so the specified color is applied to the palette entry, specified by the + /// background color's field. The image is then filled with + /// this palette index. + /// + /// This function returns a newly created image as function does, if both + /// parameters and are null. + /// If only is null, the palette pointed to by + /// parameter is initially set for the new image, if a palletized + /// image of type is created. + /// However, in the latter case, this function returns an image, whose + /// pixels are all initialized with zeros so, the image will be filled with the color of the + /// first palette entry. + /// + public static FIBITMAP AllocateExT(FREE_IMAGE_TYPE type, int width, int height, int bpp, + T? color, FREE_IMAGE_COLOR_OPTIONS options, RGBQUAD[] palette, + uint red_mask, uint green_mask, uint blue_mask) where T : struct + { + if ((palette != null) && (bpp <= 8) && (palette.Length < (1 << bpp))) + return FIBITMAP.Zero; + + if (!CheckColorType(type, color)) + return FIBITMAP.Zero; + + if (color.HasValue) + { + GCHandle handle = new GCHandle(); + try + { + T[] buffer = new T[] { color.Value }; + handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + return AllocateExT(type, width, height, bpp, handle.AddrOfPinnedObject(), + options, palette, red_mask, green_mask, blue_mask); + } + finally + { + if (handle.IsAllocated) + handle.Free(); + } + } + else + { + return AllocateExT(type, width, height, bpp, IntPtr.Zero, + options, palette, red_mask, green_mask, blue_mask); + } + } + + /// + /// Converts a FreeImage bitmap to a .NET . + /// + /// Handle to a FreeImage bitmap. + /// The converted .NET . + /// Copying metadata has been disabled until a proper way + /// of reading and storing metadata in a .NET bitmap is found. + /// + /// is null. + /// + /// The image type of is not FIT_BITMAP. + public static Bitmap GetBitmap(FIBITMAP dib) + { + return GetBitmap(dib, true); + } + + /// + /// Converts a FreeImage bitmap to a .NET . + /// + /// Handle to a FreeImage bitmap. + /// When true existing metadata will be copied. + /// The converted .NET . + /// Copying metadata has been disabled until a proper way + /// of reading and storing metadata in a .NET bitmap is found. + /// + /// is null. + /// + /// The image type of is not FIT_BITMAP. + internal static Bitmap GetBitmap(FIBITMAP dib, bool copyMetadata) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (GetImageType(dib) != FREE_IMAGE_TYPE.FIT_BITMAP) + { + throw new ArgumentException("Only bitmaps with type of FIT_BITMAP can be converted."); + } + + PixelFormat format = GetPixelFormat(dib); + + if ((format == PixelFormat.Undefined) && (GetBPP(dib) == 16u)) + { + throw new ArgumentException("Only 16bit 555 and 565 are supported."); + } + + int height = (int)GetHeight(dib); + int width = (int)GetWidth(dib); + int pitch = (int)GetPitch(dib); + + Bitmap result = new Bitmap(width, height, format); + BitmapData data; + // Locking the complete bitmap in writeonly mode + data = result.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, format); + // Writing the bitmap data directly into the new created .NET bitmap. + ConvertToRawBits(data.Scan0, dib, pitch, GetBPP(dib), + GetRedMask(dib), GetGreenMask(dib), GetBlueMask(dib), true); + // Unlock the bitmap + result.UnlockBits(data); + // Apply the bitmaps resolution + result.SetResolution(GetResolutionX(dib), GetResolutionY(dib)); + // Check whether the bitmap has a palette + if (GetPalette(dib) != IntPtr.Zero) + { + // Get the bitmaps palette to apply changes + ColorPalette palette = result.Palette; + // Get the orgininal palette + Color[] colorPalette = new Palette(dib).ColorData; + // Get the maximum number of palette entries to copy + int entriesToCopy = Math.Min(colorPalette.Length, palette.Entries.Length); + + // Check whether the bitmap is transparent + if (IsTransparent(dib)) + { + byte[] transTable = GetTransparencyTableEx(dib); + int i = 0; + int maxEntriesWithTrans = Math.Min(entriesToCopy, transTable.Length); + // Copy palette entries and include transparency + for (; i < maxEntriesWithTrans; i++) + { + palette.Entries[i] = Color.FromArgb(transTable[i], colorPalette[i]); + } + // Copy palette entries and that have no transparancy + for (; i < entriesToCopy; i++) + { + palette.Entries[i] = Color.FromArgb(0xFF, colorPalette[i]); + } + } + else + { + for (int i = 0; i < entriesToCopy; i++) + { + palette.Entries[i] = colorPalette[i]; + } + } + + // Set the bitmaps palette + result.Palette = palette; + } + // Copy metadata + if (copyMetadata) + { + try + { + List list = new List(); + // Get a list of all types + FITAG tag; + FIMETADATA mData; + foreach (FREE_IMAGE_MDMODEL model in FREE_IMAGE_MDMODELS) + { + // Get a unique search handle + mData = FindFirstMetadata(model, dib, out tag); + // Check if metadata exists for this type + if (mData.IsNull) continue; + do + { + PropertyItem propItem = CreatePropertyItem(); + propItem.Len = (int)GetTagLength(tag); + propItem.Id = (int)GetTagID(tag); + propItem.Type = (short)GetTagType(tag); + byte[] buffer = new byte[propItem.Len]; + + unsafe + { + byte* src = (byte*)GetTagValue(tag); + fixed (byte* dst = buffer) + { + CopyMemory(dst, src, (uint)propItem.Len); + } + } + + propItem.Value = buffer; + list.Add(propItem); + } + while (FindNextMetadata(mData, out tag)); + FindCloseMetadata(mData); + } + foreach (PropertyItem propItem in list) + { + result.SetPropertyItem(propItem); + } + } + catch + { + } + } + return result; + } + + /// + /// Converts an .NET into a FreeImage bitmap. + /// + /// The to convert. + /// Handle to a FreeImage bitmap. + /// Copying metadata has been disabled until a proper way + /// of reading and storing metadata in a .NET bitmap is found. + /// + /// is null. + /// + /// The bitmaps pixelformat is invalid. + public static FIBITMAP CreateFromBitmap(Bitmap bitmap) + { + return CreateFromBitmap(bitmap, false); + } + + /// + /// Converts an .NET into a FreeImage bitmap. + /// + /// The to convert. + /// When true existing metadata will be copied. + /// Handle to a FreeImage bitmap. + /// Copying metadata has been disabled until a proper way + /// of reading and storing metadata in a .NET bitmap is found. + /// + /// is null. + /// + /// The bitmaps pixelformat is invalid. + internal static FIBITMAP CreateFromBitmap(Bitmap bitmap, bool copyMetadata) + { + if (bitmap == null) + { + throw new ArgumentNullException("bitmap"); + } + uint bpp, red_mask, green_mask, blue_mask; + FREE_IMAGE_TYPE type; + if (!GetFormatParameters(bitmap.PixelFormat, out type, out bpp, out red_mask, out green_mask, out blue_mask)) + { + throw new ArgumentException("The bitmaps pixelformat is invalid."); + } + + // Locking the complete bitmap in readonly mode + BitmapData data = bitmap.LockBits( + new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat); + // Copying the bitmap data directly from the .NET bitmap + FIBITMAP result = ConvertFromRawBits( + data.Scan0, + type, + data.Width, + data.Height, + data.Stride, + bpp, + red_mask, + green_mask, + blue_mask, + true); + bitmap.UnlockBits(data); + // Handle palette + if (GetPalette(result) != IntPtr.Zero) + { + Palette palette = new Palette(result); + Color[] colors = bitmap.Palette.Entries; + // Only copy available palette entries + int entriesToCopy = Math.Min(palette.Length, colors.Length); + byte[] transTable = new byte[entriesToCopy]; + for (int i = 0; i < entriesToCopy; i++) + { + RGBQUAD color = (RGBQUAD)colors[i]; + color.rgbReserved = 0x00; + palette[i] = color; + transTable[i] = colors[i].A; + } + if ((bitmap.Flags & (int)ImageFlags.HasAlpha) != 0) + { + FreeImage.SetTransparencyTable(result, transTable); + } + } + // Handle meta data + // Disabled + //if (copyMetadata) + //{ + // foreach (PropertyItem propItem in bitmap.PropertyItems) + // { + // FITAG tag = CreateTag(); + // SetTagLength(tag, (uint)propItem.Len); + // SetTagID(tag, (ushort)propItem.Id); + // SetTagType(tag, (FREE_IMAGE_MDTYPE)propItem.Type); + // SetTagValue(tag, propItem.Value); + // SetMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, result, "", tag); + // } + //} + return result; + } + + /// + /// Converts a raw bitmap to a FreeImage bitmap. + /// + /// Array of bytes containing the raw bitmap. + /// The type of the raw bitmap. + /// The width in pixels of the raw bitmap. + /// The height in pixels of the raw bitmap. + /// Defines the total width of a scanline in the raw bitmap, + /// including padding bytes. + /// The bit depth (bits per pixel) of the raw bitmap. + /// The bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap is stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + /// Handle to a FreeImage bitmap. + public static unsafe FIBITMAP ConvertFromRawBits( + byte[] bits, + FREE_IMAGE_TYPE type, + int width, + int height, + int pitch, + uint bpp, + uint red_mask, + uint green_mask, + uint blue_mask, + bool topdown) + { + fixed (byte* ptr = bits) + { + return ConvertFromRawBits( + (IntPtr)ptr, + type, + width, + height, + pitch, + bpp, + red_mask, + green_mask, + blue_mask, + topdown); + } + } + + /// + /// Converts a raw bitmap to a FreeImage bitmap. + /// + /// Pointer to the memory block containing the raw bitmap. + /// The type of the raw bitmap. + /// The width in pixels of the raw bitmap. + /// The height in pixels of the raw bitmap. + /// Defines the total width of a scanline in the raw bitmap, + /// including padding bytes. + /// The bit depth (bits per pixel) of the raw bitmap. + /// The bit mask describing the bits used to store a single + /// pixel's red component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's green component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// The bit mask describing the bits used to store a single + /// pixel's blue component in the raw bitmap. This is only applied to 16-bpp raw bitmaps. + /// If true, the raw bitmap is stored in top-down order (top-left pixel first) + /// and in bottom-up order (bottom-left pixel first) otherwise. + /// Handle to a FreeImage bitmap. + public static unsafe FIBITMAP ConvertFromRawBits( + IntPtr bits, + FREE_IMAGE_TYPE type, + int width, + int height, + int pitch, + uint bpp, + uint red_mask, + uint green_mask, + uint blue_mask, + bool topdown) + { + byte* addr = (byte*)bits; + if ((addr == null) || (width <= 0) || (height <= 0)) + { + return FIBITMAP.Zero; + } + + FIBITMAP dib = AllocateT(type, width, height, (int)bpp, red_mask, green_mask, blue_mask); + if (dib != FIBITMAP.Zero) + { + if (topdown) + { + for (int i = height - 1; i >= 0; --i) + { + CopyMemory((byte*)GetScanLine(dib, i), addr, (int)GetLine(dib)); + addr += pitch; + } + } + else + { + for (int i = 0; i < height; ++i) + { + CopyMemory((byte*)GetScanLine(dib, i), addr, (int)GetLine(dib)); + addr += pitch; + } + } + } + return dib; + } + + /// + /// Saves a .NET to a file. + /// + /// The .NET to save. + /// Name of the file to save to. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// The bitmaps pixelformat is invalid. + public static bool SaveBitmap(Bitmap bitmap, string filename) + { + return SaveBitmap( + bitmap, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Saves a .NET to a file. + /// + /// The .NET to save. + /// Name of the file to save to. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// The bitmaps pixelformat is invalid. + public static bool SaveBitmap(Bitmap bitmap, string filename, FREE_IMAGE_SAVE_FLAGS flags) + { + return SaveBitmap( + bitmap, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + flags); + } + + /// + /// Saves a .NET to a file. + /// + /// The .NET to save. + /// Name of the file to save to. + /// Format of the bitmap. If the format should be taken from the + /// filename use . + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// The bitmaps pixelformat is invalid. + public static bool SaveBitmap( + Bitmap bitmap, + string filename, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags) + { + FIBITMAP dib = CreateFromBitmap(bitmap); + bool result = SaveEx(dib, filename, format, flags); + Unload(dib); + return result; + } + + /// + /// Loads a FreeImage bitmap. + /// The file will be loaded with default loading flags. + /// + /// The complete name of the file to load. + /// Handle to a FreeImage bitmap. + /// + /// does not exists. + public static FIBITMAP LoadEx(string filename) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return LoadEx(filename, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// Load flags can be provided by the flags parameter. + /// + /// The complete name of the file to load. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + /// + /// does not exists. + public static FIBITMAP LoadEx(string filename, FREE_IMAGE_LOAD_FLAGS flags) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return LoadEx(filename, flags, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// In case the loading format is the files + /// real format is being analysed. If no plugin can read the file, format remains + /// and 0 is returned. + /// The file will be loaded with default loading flags. + /// + /// The complete name of the file to load. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadEx it will be returned in format. + /// Handle to a FreeImage bitmap. + /// + /// does not exists. + public static FIBITMAP LoadEx(string filename, ref FREE_IMAGE_FORMAT format) + { + return LoadEx(filename, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// In case the loading format is the files + /// real format is being analysed. If no plugin can read the file, format remains + /// and 0 is returned. + /// Load flags can be provided by the flags parameter. + /// + /// The complete name of the file to load. + /// Flags to enable or disable plugin-features. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadEx it will be returned in format. + /// + /// Handle to a FreeImage bitmap. + /// + /// does not exists. + public static FIBITMAP LoadEx(string filename, FREE_IMAGE_LOAD_FLAGS flags, ref FREE_IMAGE_FORMAT format) + { + // check if file exists + if (!File.Exists(filename)) + { + throw new FileNotFoundException(filename + " could not be found."); + } + FIBITMAP dib = new FIBITMAP(); + if (format == FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + // query all plugins to see if one can read the file + format = GetFileType(filename, 0); + } + // check if the plugin is capable of loading files + if (FIFSupportsReading(format)) + { + dib = Load(format, filename, flags); + } + return dib; + } + + /// + /// Loads a .NET from a file. + /// + /// Name of the file to be loaded. + /// Format of the image. If the format should be taken from the + /// filename use . + /// Flags to enable or disable plugin-features. + /// The loaded .NET . + /// + /// does not exists. + /// + /// The image type of the image is not . + public static Bitmap LoadBitmap(string filename, FREE_IMAGE_LOAD_FLAGS flags, ref FREE_IMAGE_FORMAT format) + { + FIBITMAP dib = LoadEx(filename, flags, ref format); + Bitmap result = GetBitmap(dib, true); + Unload(dib); + return result; + } + + /// + /// Deletes a previously loaded FreeImage bitmap from memory and resets the handle to 0. + /// + /// Handle to a FreeImage bitmap. + public static void UnloadEx(ref FIBITMAP dib) + { + if (!dib.IsNull) + { + Unload(dib); + dib.SetNull(); + } + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// The format is taken off the filename. + /// If no suitable format was found false will be returned. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx(FIBITMAP dib, string filename) + { + return SaveEx( + ref dib, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// In case the loading format is + /// the format is taken off the filename. + /// If no suitable format was found false will be returned. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Format of the image. If the format should be taken from the + /// filename use . + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + FIBITMAP dib, + string filename, + FREE_IMAGE_FORMAT format) + { + return SaveEx( + ref dib, + filename, + format, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// The format is taken off the filename. + /// If no suitable format was found false will be returned. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// When true the structure will be unloaded on success. + /// If the function failed and returned false, the bitmap was not unloaded. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + ref FIBITMAP dib, + string filename, + bool unloadSource) + { + return SaveEx( + ref dib, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + unloadSource); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// The format is taken off the filename. + /// If no suitable format was found false will be returned. + /// Save flags can be provided by the flags parameter. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + FIBITMAP dib, + string filename, + FREE_IMAGE_SAVE_FLAGS flags) + { + return SaveEx( + ref dib, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + flags, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// The format is taken off the filename. + /// If no suitable format was found false will be returned. + /// Save flags can be provided by the flags parameter. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Flags to enable or disable plugin-features. + /// When true the structure will be unloaded on success. + /// If the function failed and returned false, the bitmap was not unloaded. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + ref FIBITMAP dib, + string filename, + FREE_IMAGE_SAVE_FLAGS flags, + bool unloadSource) + { + return SaveEx( + ref dib, + filename, + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + flags, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + unloadSource); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// In case the loading format is + /// the format is taken off the filename. + /// If no suitable format was found false will be returned. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Format of the image. If the format should be taken from the + /// filename use . + /// When true the structure will be unloaded on success. + /// If the function failed and returned false, the bitmap was not unloaded. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + ref FIBITMAP dib, + string filename, + FREE_IMAGE_FORMAT format, + bool unloadSource) + { + return SaveEx( + ref dib, + filename, + format, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + unloadSource); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// In case the loading format is + /// the format is taken off the filename. + /// If no suitable format was found false will be returned. + /// Save flags can be provided by the flags parameter. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Format of the image. If the format should be taken from the + /// filename use . + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + /// + /// or is null. + public static bool SaveEx( + FIBITMAP dib, + string filename, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags) + { + return SaveEx( + ref dib, + filename, + format, + flags, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a file. + /// In case the loading format is + /// the format is taken off the filename. + /// If no suitable format was found false will be returned. + /// Save flags can be provided by the flags parameter. + /// The bitmaps color depth can be set by 'colorDepth'. + /// If set to a suitable color depth + /// will be taken if available. + /// + /// Handle to a FreeImage bitmap. + /// The complete name of the file to save to. + /// The extension will be corrected if it is no valid extension for the + /// selected format or if no extension was specified. + /// Format of the image. If the format should be taken from the + /// filename use . + /// Flags to enable or disable plugin-features. + /// The new color depth of the bitmap. + /// Set to if Save should take the + /// best suitable color depth. + /// If a color depth is selected that the provided format cannot write an + /// error-message will be thrown. + /// When true the structure will be unloaded on success. + /// If the function failed and returned false, the bitmap was not unloaded. + /// Returns true on success, false on failure. + /// + /// A direct color conversion failed. + /// + /// or is null. + public static bool SaveEx( + ref FIBITMAP dib, + string filename, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags, + FREE_IMAGE_COLOR_DEPTH colorDepth, + bool unloadSource) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (filename == null) + { + throw new ArgumentNullException("filename"); + } + bool result = false; + // Gets format from filename if the format is unknown + if (format == FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + format = GetFIFFromFilename(filename); + } + if (format != FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + // Checks writing support + if (FIFSupportsWriting(format) && FIFSupportsExportType(format, GetImageType(dib))) + { + // Check valid filename and correct it if needed + if (!IsFilenameValidForFIF(format, filename)) + { + string extension = GetPrimaryExtensionFromFIF(format); + filename = Path.ChangeExtension(filename, extension); + } + + FIBITMAP dibToSave = PrepareBitmapColorDepth(dib, format, colorDepth); + try + { + result = Save(format, dibToSave, filename, flags); + } + finally + { + // Always unload a temporary created bitmap. + if (dibToSave != dib) + { + UnloadEx(ref dibToSave); + } + // On success unload the bitmap + if (result && unloadSource) + { + UnloadEx(ref dib); + } + } + } + } + return result; + } + + /// + /// Loads a FreeImage bitmap. + /// The stream must be set to the correct position before calling LoadFromStream. + /// + /// The stream to read from. + /// Handle to a FreeImage bitmap. + /// + /// is null. + /// + /// is not capable of reading. + public static FIBITMAP LoadFromStream(Stream stream) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return LoadFromStream(stream, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// The stream must be set to the correct position before calling LoadFromStream. + /// + /// The stream to read from. + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage bitmap. + /// + /// is null. + /// + /// is not capable of reading. + public static FIBITMAP LoadFromStream(Stream stream, FREE_IMAGE_LOAD_FLAGS flags) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return LoadFromStream(stream, flags, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// In case the loading format is the + /// bitmaps real format is being analysed. + /// The stream must be set to the correct position before calling LoadFromStream. + /// + /// The stream to read from. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadFromStream it will be returned in format. + /// Handle to a FreeImage bitmap. + /// + /// is null. + /// + /// is not capable of reading. + public static FIBITMAP LoadFromStream(Stream stream, ref FREE_IMAGE_FORMAT format) + { + return LoadFromStream(stream, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + } + + /// + /// Loads a FreeImage bitmap. + /// In case the loading format is + /// the bitmaps real format is being analysed. + /// The stream must be set to the correct position before calling LoadFromStream. + /// + /// The stream to read from. + /// Flags to enable or disable plugin-features. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadFromStream it will be returned in format. + /// Handle to a FreeImage bitmap. + /// + /// is null. + /// + /// is not capable of reading. + public static FIBITMAP LoadFromStream( + Stream stream, + FREE_IMAGE_LOAD_FLAGS flags, + ref FREE_IMAGE_FORMAT format) + { + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + if (!stream.CanRead) + { + throw new ArgumentException("stream is not capable of reading."); + } + // Wrap the source stream if it is unable to seek (which is required by FreeImage) + stream = (stream.CanSeek) ? stream : new StreamWrapper(stream, true); + + stream.Position = 0L; + if (format == FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + // Get the format of the bitmap + format = GetFileTypeFromStream(stream); + // Restore the streams position + stream.Position = 0L; + } + if (!FIFSupportsReading(format)) + { + return FIBITMAP.Zero; + } + // Create a 'FreeImageIO' structure for calling 'LoadFromHandle' + // using the internal structure 'FreeImageStreamIO'. + FreeImageIO io = FreeImageStreamIO.io; + using (fi_handle handle = new fi_handle(stream)) + { + return LoadFromHandle(format, ref io, handle, flags); + } + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format) + { + return SaveToStream( + ref dib, + stream, + format, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// When true the structure will be unloaded on success. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + ref FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format, + bool unloadSource) + { + return SaveToStream( + ref dib, + stream, + format, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + unloadSource); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags) + { + return SaveToStream( + ref dib, + stream, + format, + flags, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// When true the structure will be unloaded on success. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + ref FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags, + bool unloadSource) + { + return SaveToStream( + ref dib, stream, + format, + flags, + FREE_IMAGE_COLOR_DEPTH.FICD_AUTO, + unloadSource); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// The new color depth of the bitmap. + /// Set to if SaveToStream should + /// take the best suitable color depth. + /// If a color depth is selected that the provided format cannot write an + /// error-message will be thrown. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags, + FREE_IMAGE_COLOR_DEPTH colorDepth) + { + return SaveToStream( + ref dib, + stream, + format, + flags, + colorDepth, + false); + } + + /// + /// Saves a previously loaded FreeImage bitmap to a stream. + /// The stream must be set to the correct position before calling SaveToStream. + /// + /// Handle to a FreeImage bitmap. + /// The stream to write to. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// The new color depth of the bitmap. + /// Set to if SaveToStream should + /// take the best suitable color depth. + /// If a color depth is selected that the provided format cannot write an + /// error-message will be thrown. + /// When true the structure will be unloaded on success. + /// Returns true on success, false on failure. + /// + /// or is null. + /// + /// cannot write. + public static bool SaveToStream( + ref FIBITMAP dib, + Stream stream, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_SAVE_FLAGS flags, + FREE_IMAGE_COLOR_DEPTH colorDepth, + bool unloadSource) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + if (!stream.CanWrite) + { + throw new ArgumentException("stream is not capable of writing."); + } + if ((!FIFSupportsWriting(format)) || (!FIFSupportsExportType(format, GetImageType(dib)))) + { + return false; + } + + FIBITMAP dibToSave = PrepareBitmapColorDepth(dib, format, colorDepth); + bool result = false; + + try + { + // Create a 'FreeImageIO' structure for calling 'SaveToHandle' + FreeImageIO io = FreeImageStreamIO.io; + + using (fi_handle handle = new fi_handle(stream)) + { + result = SaveToHandle(format, dibToSave, ref io, handle, flags); + } + } + finally + { + // Always unload a temporary created bitmap. + if (dibToSave != dib) + { + UnloadEx(ref dibToSave); + } + // On success unload the bitmap + if (result && unloadSource) + { + UnloadEx(ref dib); + } + } + + return result; + } + + #endregion + + #region Plugin functions + + /// + /// Checks if an extension is valid for a certain format. + /// + /// The desired format. + /// The desired extension. + /// True if the extension is valid for the given format, false otherwise. + /// + /// is null. + public static bool IsExtensionValidForFIF(FREE_IMAGE_FORMAT fif, string extension) + { + return IsExtensionValidForFIF(fif, extension, StringComparison.CurrentCultureIgnoreCase); + } + + /// + /// Checks if an extension is valid for a certain format. + /// + /// The desired format. + /// The desired extension. + /// The string comparison type. + /// True if the extension is valid for the given format, false otherwise. + /// + /// is null. + public static bool IsExtensionValidForFIF(FREE_IMAGE_FORMAT fif, string extension, StringComparison comparisonType) + { + if (extension == null) + { + throw new ArgumentNullException("extension"); + } + bool result = false; + // Split up the string and compare each with the given extension + string tempList = GetFIFExtensionList(fif); + if (tempList != null) + { + string[] extensionList = tempList.Split(','); + foreach (string ext in extensionList) + { + if (extension.Equals(ext, comparisonType)) + { + result = true; + break; + } + } + } + return result; + } + + /// + /// Checks if a filename is valid for a certain format. + /// + /// The desired format. + /// The desired filename. + /// True if the filename is valid for the given format, false otherwise. + /// + /// is null. + public static bool IsFilenameValidForFIF(FREE_IMAGE_FORMAT fif, string filename) + { + return IsFilenameValidForFIF(fif, filename, StringComparison.CurrentCultureIgnoreCase); + } + + /// + /// Checks if a filename is valid for a certain format. + /// + /// The desired format. + /// The desired filename. + /// The string comparison type. + /// True if the filename is valid for the given format, false otherwise. + /// + /// is null. + public static bool IsFilenameValidForFIF(FREE_IMAGE_FORMAT fif, string filename, StringComparison comparisonType) + { + if (filename == null) + { + throw new ArgumentNullException("filename"); + } + bool result = false; + // Extract the filenames extension if it exists + string extension = Path.GetExtension(filename); + if (extension.Length != 0) + { + extension = extension.Remove(0, 1); + result = IsExtensionValidForFIF(fif, extension, comparisonType); + } + return result; + } + + /// + /// This function returns the primary (main or most commonly used?) extension of a certain + /// image format (fif). This is done by returning the first of all possible extensions + /// returned by GetFIFExtensionList(). + /// That assumes, that the plugin returns the extensions in ordered form. + /// The image format to obtain the primary extension for. + /// The primary extension of the specified image format. + public static string GetPrimaryExtensionFromFIF(FREE_IMAGE_FORMAT fif) + { + string result = null; + string extensions = GetFIFExtensionList(fif); + if (extensions != null) + { + int position = extensions.IndexOf(','); + if (position < 0) + { + result = extensions; + } + else + { + result = extensions.Substring(0, position); + } + } + return result; + } + + #endregion + + #region Multipage functions + + /// + /// Loads a FreeImage multi-paged bitmap. + /// + /// The complete name of the file to load. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx(string filename) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return OpenMultiBitmapEx( + filename, + ref format, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + false, + false, + false); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// + /// The complete name of the file to load. + /// When true performance is increased at the cost of memory. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx(string filename, bool keep_cache_in_memory) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return OpenMultiBitmapEx( + filename, + ref format, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + false, + false, + keep_cache_in_memory); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// + /// The complete name of the file to load. + /// When true the bitmap will be loaded read only. + /// When true performance is increased at the cost of memory. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx( + string filename, + bool read_only, + bool keep_cache_in_memory) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return OpenMultiBitmapEx( + filename, + ref format, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + false, + read_only, + keep_cache_in_memory); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// + /// The complete name of the file to load. + /// When true a new bitmap is created. + /// When true the bitmap will be loaded read only. + /// When true performance is increased at the cost of memory. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx( + string filename, + bool create_new, + bool read_only, + bool keep_cache_in_memory) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return OpenMultiBitmapEx( + filename, + ref format, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + create_new, + read_only, + keep_cache_in_memory); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// In case the loading format is the files real + /// format is being analysed. If no plugin can read the file, format remains + /// and 0 is returned. + /// + /// The complete name of the file to load. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadEx it will be returned in format. + /// When true a new bitmap is created. + /// When true the bitmap will be loaded read only. + /// When true performance is increased at the cost of memory. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx( + string filename, + ref FREE_IMAGE_FORMAT format, + bool create_new, + bool read_only, + bool keep_cache_in_memory) + { + return OpenMultiBitmapEx( + filename, + ref format, + FREE_IMAGE_LOAD_FLAGS.DEFAULT, + create_new, + read_only, + keep_cache_in_memory); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// In case the loading format is the files + /// real format is being analysed. If no plugin can read the file, format remains + /// and 0 is returned. + /// Load flags can be provided by the flags parameter. + /// + /// The complete name of the file to load. + /// Format of the image. If the format is unknown use + /// . + /// In case a suitable format was found by LoadEx it will be returned in format. + /// Flags to enable or disable plugin-features. + /// When true a new bitmap is created. + /// When true the bitmap will be loaded read only. + /// When true performance is increased at the cost of memory. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// does not exists while opening. + public static FIMULTIBITMAP OpenMultiBitmapEx( + string filename, + ref FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS flags, + bool create_new, + bool read_only, + bool keep_cache_in_memory) + { + if (!File.Exists(filename) && !create_new) + { + throw new FileNotFoundException(filename + " could not be found."); + } + if (format == FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + // Check if a plugin can read the data + format = GetFileType(filename, 0); + } + FIMULTIBITMAP dib = new FIMULTIBITMAP(); + if (FIFSupportsReading(format)) + { + dib = OpenMultiBitmap(format, filename, create_new, read_only, keep_cache_in_memory, flags); + } + return dib; + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// + /// The stream to load the bitmap from. + /// Handle to a FreeImage multi-paged bitmap. + public static FIMULTIBITMAP OpenMultiBitmapFromStream(Stream stream) + { + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + return OpenMultiBitmapFromStream(stream, ref format, FREE_IMAGE_LOAD_FLAGS.DEFAULT); + } + + /// + /// Loads a FreeImage multi-paged bitmap. + /// In case the loading format is the files + /// real format is being analysed. If no plugin can read the file, format remains + /// and 0 is returned. + /// Load flags can be provided by the flags parameter. + /// + /// The stream to load the bitmap from. + /// Format of the image. If the format is unknown use + /// . + /// Flags to enable or disable plugin-features. + /// Handle to a FreeImage multi-paged bitmap. + public static FIMULTIBITMAP OpenMultiBitmapFromStream(Stream stream, ref FREE_IMAGE_FORMAT format, FREE_IMAGE_LOAD_FLAGS flags) + { + if (stream == null) + return FIMULTIBITMAP.Zero; + + if (!stream.CanSeek) + stream = new StreamWrapper(stream, true); + + FIMULTIBITMAP mdib = FIMULTIBITMAP.Zero; + FreeImageIO io = FreeImageStreamIO.io; + fi_handle handle = new fi_handle(stream); + + try + { + if (format == FREE_IMAGE_FORMAT.FIF_UNKNOWN) + { + format = GetFileTypeFromHandle(ref io, handle, checked((int)stream.Length)); + } + + mdib = OpenMultiBitmapFromHandle(format, ref io, handle, flags); + + if (mdib.IsNull) + { + handle.Dispose(); + } + else + { + lock (streamHandles) + { + streamHandles.Add(mdib, handle); + } + } + + return mdib; + } + catch + { + if (!mdib.IsNull) + CloseMultiBitmap(mdib, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + + if (handle != null) + handle.Dispose(); + + throw; + } + } + + /// + /// Closes a previously opened multi-page bitmap and, when the bitmap was not opened read-only, applies any changes made to it. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + public static bool CloseMultiBitmap(FIMULTIBITMAP bitmap, FREE_IMAGE_SAVE_FLAGS flags) + { + if (CloseMultiBitmap_(bitmap, flags)) + { + fi_handle handle; + lock (streamHandles) + { + if (streamHandles.TryGetValue(bitmap, out handle)) + { + streamHandles.Remove(bitmap); + handle.Dispose(); + } + } + return true; + } + return false; + } + + /// + /// Closes a previously opened multi-page bitmap and, when the bitmap was not opened read-only, + /// applies any changes made to it. + /// On success the handle will be reset to null. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Returns true on success, false on failure. + public static bool CloseMultiBitmapEx(ref FIMULTIBITMAP bitmap) + { + return CloseMultiBitmapEx(ref bitmap, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + /// + /// Closes a previously opened multi-page bitmap and, when the bitmap was not opened read-only, + /// applies any changes made to it. + /// On success the handle will be reset to null. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Flags to enable or disable plugin-features. + /// Returns true on success, false on failure. + public static bool CloseMultiBitmapEx(ref FIMULTIBITMAP bitmap, FREE_IMAGE_SAVE_FLAGS flags) + { + bool result = false; + if (!bitmap.IsNull) + { + if (CloseMultiBitmap(bitmap, flags)) + { + bitmap.SetNull(); + result = true; + } + } + return result; + } + + /// + /// Retrieves the number of pages that are locked in a multi-paged bitmap. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// Number of locked pages. + /// + /// is null. + public static int GetLockedPageCount(FIMULTIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + int result = 0; + GetLockedPageNumbers(dib, null, ref result); + return result; + } + + /// + /// Retrieves a list locked pages of a multi-paged bitmap. + /// + /// Handle to a FreeImage multi-paged bitmap. + /// List containing the indexes of the locked pages. + /// + /// is null. + public static int[] GetLockedPages(FIMULTIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + // Get the number of pages and create an array to save the information + int count = 0; + int[] result = null; + // Get count + if (GetLockedPageNumbers(dib, result, ref count)) + { + result = new int[count]; + // Fill array + if (!GetLockedPageNumbers(dib, result, ref count)) + { + result = null; + } + } + return result; + } + + /// + /// Loads a FreeImage multi-paged bitmap from a stream and returns the + /// FreeImage memory stream used as temporary buffer. + /// The bitmap can not be modified by calling + /// , + /// , + /// or + /// . + /// + /// The stream to read from. + /// Format of the image. + /// Flags to enable or disable plugin-features. + /// The temporary memory buffer used to load the bitmap. + /// Handle to a FreeImage multi-paged bitmap. + /// + /// is null. + /// + /// can not read. + public static FIMULTIBITMAP LoadMultiBitmapFromStream( + Stream stream, + FREE_IMAGE_FORMAT format, + FREE_IMAGE_LOAD_FLAGS flags, + out FIMEMORY memory) + { + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + if (!stream.CanRead) + { + throw new ArgumentException("stream"); + } + const int blockSize = 1024; + int bytesRead; + byte[] buffer = new byte[blockSize]; + + stream = stream.CanSeek ? stream : new StreamWrapper(stream, true); + memory = OpenMemory(IntPtr.Zero, 0); + + do + { + bytesRead = stream.Read(buffer, 0, blockSize); + WriteMemory(buffer, (uint)blockSize, (uint)1, memory); + } + while (bytesRead == blockSize); + + return LoadMultiBitmapFromMemory(format, memory, flags); + } + + #endregion + + #region Filetype functions + + /// + /// Orders FreeImage to analyze the bitmap signature. + /// In case the stream is not seekable, the stream will have been used + /// and must be recreated for loading. + /// + /// Name of the stream to analyze. + /// Type of the bitmap. + /// + /// is null. + /// + /// can not read. + public static FREE_IMAGE_FORMAT GetFileTypeFromStream(Stream stream) + { + if (stream == null) + { + throw new ArgumentNullException("stream"); + } + if (!stream.CanRead) + { + throw new ArgumentException("stream is not capable of reading."); + } + // Wrap the stream if it cannot seek + stream = (stream.CanSeek) ? stream : new StreamWrapper(stream, true); + // Create a 'FreeImageIO' structure for the stream + FreeImageIO io = FreeImageStreamIO.io; + using (fi_handle handle = new fi_handle(stream)) + { + return GetFileTypeFromHandle(ref io, handle, 0); + } + } + + #endregion + + #region Pixel access functions + + /// + /// Retrieves an hBitmap for a FreeImage bitmap. + /// Call FreeHbitmap(IntPtr) to free the handle. + /// + /// Handle to a FreeImage bitmap. + /// A reference device context. + /// Use IntPtr.Zero if no reference is available. + /// When true dib will be unloaded if the function succeeded. + /// The hBitmap for the FreeImage bitmap. + /// + /// is null. + public static unsafe IntPtr GetHbitmap(FIBITMAP dib, IntPtr hdc, bool unload) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + IntPtr hBitmap = IntPtr.Zero; + bool release = false; + IntPtr ppvBits = IntPtr.Zero; + // Check if we have destination + if (release = (hdc == IntPtr.Zero)) + { + // We don't so request dc + hdc = GetDC(IntPtr.Zero); + } + if (hdc != IntPtr.Zero) + { + // Get pointer to the infoheader of the bitmap + IntPtr info = GetInfo(dib); + // Create a bitmap in the dc + hBitmap = CreateDIBSection(hdc, info, DIB_RGB_COLORS, out ppvBits, IntPtr.Zero, 0); + if (hBitmap != IntPtr.Zero && ppvBits != IntPtr.Zero) + { + // Copy the data into the dc + CopyMemory(ppvBits, GetBits(dib), (GetHeight(dib) * GetPitch(dib))); + // Success: we unload the bitmap + if (unload) + { + Unload(dib); + } + } + // We have to release the dc + if (release) + { + ReleaseDC(IntPtr.Zero, hdc); + } + } + return hBitmap; + } + + /// + /// Returns an HBITMAP created by the CreateDIBitmap() function which in turn + /// has always the same color depth as the reference DC, which may be provided + /// through . The desktop DC will be used, + /// if IntPtr.Zero DC is specified. + /// Call to free the handle. + /// + /// Handle to a FreeImage bitmap. + /// Handle to a device context. + /// When true the structure will be unloaded on success. + /// If the function failed and returned false, the bitmap was not unloaded. + /// If the function succeeds, the return value is a handle to the + /// compatible bitmap. If the function fails, the return value is . + /// + /// is null. + public static IntPtr GetBitmapForDevice(FIBITMAP dib, IntPtr hdc, bool unload) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + IntPtr hbitmap = IntPtr.Zero; + bool release = false; + if (release = (hdc == IntPtr.Zero)) + { + hdc = GetDC(IntPtr.Zero); + } + if (hdc != IntPtr.Zero) + { + hbitmap = CreateDIBitmap( + hdc, + GetInfoHeader(dib), + CBM_INIT, + GetBits(dib), + GetInfo(dib), + DIB_RGB_COLORS); + if (unload) + { + Unload(dib); + } + if (release) + { + ReleaseDC(IntPtr.Zero, hdc); + } + } + return hbitmap; + } + + /// + /// Creates a FreeImage DIB from a Device Context/Compatible Bitmap. + /// + /// Handle to the bitmap. + /// Handle to a device context. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public unsafe static FIBITMAP CreateFromHbitmap(IntPtr hbitmap, IntPtr hdc) + { + if (hbitmap == IntPtr.Zero) + { + throw new ArgumentNullException("hbitmap"); + } + + FIBITMAP dib = new FIBITMAP(); + BITMAP bm; + uint colors; + bool release; + + if (GetObject(hbitmap, sizeof(BITMAP), (IntPtr)(&bm)) != 0) + { + dib = Allocate(bm.bmWidth, bm.bmHeight, bm.bmBitsPixel, 0, 0, 0); + if (!dib.IsNull) + { + colors = GetColorsUsed(dib); + if (release = (hdc == IntPtr.Zero)) + { + hdc = GetDC(IntPtr.Zero); + } + if (GetDIBits( + hdc, + hbitmap, + 0, + (uint)bm.bmHeight, + GetBits(dib), + GetInfo(dib), + DIB_RGB_COLORS) != 0) + { + if (colors != 0) + { + BITMAPINFOHEADER* bmih = (BITMAPINFOHEADER*)GetInfo(dib); + bmih[0].biClrImportant = bmih[0].biClrUsed = colors; + } + } + else + { + UnloadEx(ref dib); + } + if (release) + { + ReleaseDC(IntPtr.Zero, hdc); + } + } + } + + return dib; + } + + /// + /// Frees a bitmap handle. + /// + /// Handle to a bitmap. + /// True on success, false on failure. + public static bool FreeHbitmap(IntPtr hbitmap) + { + return DeleteObject(hbitmap); + } + + #endregion + + #region Bitmap information functions + + /// + /// Retrieves a DIB's resolution in X-direction measured in 'dots per inch' (DPI) and not in + /// 'dots per meter'. + /// + /// Handle to a FreeImage bitmap. + /// The resolution in 'dots per inch'. + /// + /// is null. + public static uint GetResolutionX(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + return (uint)(0.5d + 0.0254d * GetDotsPerMeterX(dib)); + } + + /// + /// Retrieves a DIB's resolution in Y-direction measured in 'dots per inch' (DPI) and not in + /// 'dots per meter'. + /// + /// Handle to a FreeImage bitmap. + /// The resolution in 'dots per inch'. + /// + /// is null. + public static uint GetResolutionY(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + return (uint)(0.5d + 0.0254d * GetDotsPerMeterY(dib)); + } + + /// + /// Sets a DIB's resolution in X-direction measured in 'dots per inch' (DPI) and not in + /// 'dots per meter'. + /// + /// Handle to a FreeImage bitmap. + /// The new resolution in 'dots per inch'. + /// + /// is null. + public static void SetResolutionX(FIBITMAP dib, uint res) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + SetDotsPerMeterX(dib, (uint)((double)res / 0.0254d + 0.5d)); + } + + /// + /// Sets a DIB's resolution in Y-direction measured in 'dots per inch' (DPI) and not in + /// 'dots per meter'. + /// + /// Handle to a FreeImage bitmap. + /// The new resolution in 'dots per inch'. + /// + /// is null. + public static void SetResolutionY(FIBITMAP dib, uint res) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + SetDotsPerMeterY(dib, (uint)((double)res / 0.0254d + 0.5d)); + } + + /// + /// Returns whether the image is a greyscale image or not. + /// The function scans all colors in the bitmaps palette for entries where + /// red, green and blue are not all the same (not a grey color). + /// Supports 1-, 4- and 8-bit bitmaps. + /// + /// Handle to a FreeImage bitmap. + /// True if the image is a greyscale image, else false. + /// + /// is null. + public static unsafe bool IsGreyscaleImage(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + bool result = true; + uint bpp = GetBPP(dib); + switch (bpp) + { + case 1: + case 4: + case 8: + RGBQUAD* palette = (RGBQUAD*)GetPalette(dib); + uint paletteLength = GetColorsUsed(dib); + for (int i = 0; i < paletteLength; i++) + { + if (palette[i].rgbRed != palette[i].rgbGreen || + palette[i].rgbRed != palette[i].rgbBlue) + { + result = false; + break; + } + } + break; + default: + result = false; + break; + } + return result; + } + + /// + /// Returns a structure that represents the palette of a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// A structure representing the bitmaps palette. + /// + /// is null. + public static Palette GetPaletteEx(FIBITMAP dib) + { + return new Palette(dib); + } + + /// + /// Returns the structure of a FreeImage bitmap. + /// The structure is a copy, so changes will have no effect on + /// the bitmap itself. + /// + /// Handle to a FreeImage bitmap. + /// structure of the bitmap. + /// + /// is null. + public static unsafe BITMAPINFOHEADER GetInfoHeaderEx(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + return *(BITMAPINFOHEADER*)GetInfoHeader(dib); + } + + /// + /// Returns the structure of a FreeImage bitmap. + /// The structure is a copy, so changes will have no effect on + /// the bitmap itself. + /// + /// Handle to a FreeImage bitmap. + /// structure of the bitmap. + /// + /// is null. + public static BITMAPINFO GetInfoEx(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + BITMAPINFO result = new BITMAPINFO(); + result.bmiHeader = GetInfoHeaderEx(dib); + IntPtr ptr = GetPalette(dib); + if (ptr == IntPtr.Zero) + { + result.bmiColors = new RGBQUAD[0]; + } + else + { + result.bmiColors = new MemoryArray(ptr, (int)result.bmiHeader.biClrUsed).Data; + } + return result; + } + + /// + /// Returns the pixelformat of the bitmap. + /// + /// Handle to a FreeImage bitmap. + /// of the bitmap. + /// + /// is null. + public static PixelFormat GetPixelFormat(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + + PixelFormat result = PixelFormat.Undefined; + + if (GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) + { + switch (GetBPP(dib)) + { + case 1: + result = PixelFormat.Format1bppIndexed; + break; + case 4: + result = PixelFormat.Format4bppIndexed; + break; + case 8: + result = PixelFormat.Format8bppIndexed; + break; + case 16: + if ((GetBlueMask(dib) == FI16_565_BLUE_MASK) && + (GetGreenMask(dib) == FI16_565_GREEN_MASK) && + (GetRedMask(dib) == FI16_565_RED_MASK)) + { + result = PixelFormat.Format16bppRgb565; + } + if ((GetBlueMask(dib) == FI16_555_BLUE_MASK) && + (GetGreenMask(dib) == FI16_555_GREEN_MASK) && + (GetRedMask(dib) == FI16_555_RED_MASK)) + { + result = PixelFormat.Format16bppRgb555; + } + break; + case 24: + result = PixelFormat.Format24bppRgb; + break; + case 32: + result = PixelFormat.Format32bppArgb; + break; + } + } + return result; + } + + /// + /// Retrieves all parameters needed to create a new FreeImage bitmap from + /// the format of a .NET . + /// + /// The + /// of the .NET . + /// Returns the type used for the new bitmap. + /// Returns the color depth for the new bitmap. + /// Returns the red_mask for the new bitmap. + /// Returns the green_mask for the new bitmap. + /// Returns the blue_mask for the new bitmap. + /// True in case a matching conversion exists; else false. + /// + public static bool GetFormatParameters( + PixelFormat format, + out FREE_IMAGE_TYPE type, + out uint bpp, + out uint red_mask, + out uint green_mask, + out uint blue_mask) + { + bool result = false; + type = FREE_IMAGE_TYPE.FIT_UNKNOWN; + bpp = 0; + red_mask = 0; + green_mask = 0; + blue_mask = 0; + switch (format) + { + case PixelFormat.Format1bppIndexed: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 1; + result = true; + break; + case PixelFormat.Format4bppIndexed: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 4; + result = true; + break; + case PixelFormat.Format8bppIndexed: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 8; + result = true; + break; + case PixelFormat.Format16bppRgb565: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 16; + red_mask = FI16_565_RED_MASK; + green_mask = FI16_565_GREEN_MASK; + blue_mask = FI16_565_BLUE_MASK; + result = true; + break; + case PixelFormat.Format16bppRgb555: + case PixelFormat.Format16bppArgb1555: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 16; + red_mask = FI16_555_RED_MASK; + green_mask = FI16_555_GREEN_MASK; + blue_mask = FI16_555_BLUE_MASK; + result = true; + break; + case PixelFormat.Format24bppRgb: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 24; + red_mask = FI_RGBA_RED_MASK; + green_mask = FI_RGBA_GREEN_MASK; + blue_mask = FI_RGBA_BLUE_MASK; + result = true; + break; + case PixelFormat.Format32bppRgb: + case PixelFormat.Format32bppArgb: + case PixelFormat.Format32bppPArgb: + type = FREE_IMAGE_TYPE.FIT_BITMAP; + bpp = 32; + red_mask = FI_RGBA_RED_MASK; + green_mask = FI_RGBA_GREEN_MASK; + blue_mask = FI_RGBA_BLUE_MASK; + result = true; + break; + case PixelFormat.Format16bppGrayScale: + type = FREE_IMAGE_TYPE.FIT_UINT16; + bpp = 16; + result = true; + break; + case PixelFormat.Format48bppRgb: + type = FREE_IMAGE_TYPE.FIT_RGB16; + bpp = 48; + result = true; + break; + case PixelFormat.Format64bppArgb: + case PixelFormat.Format64bppPArgb: + type = FREE_IMAGE_TYPE.FIT_RGBA16; + bpp = 64; + result = true; + break; + } + return result; + } + + /// + /// Returns the for the specified + /// . + /// + /// The + /// for which to return the corresponding . + /// The for the specified + /// + public static FREE_IMAGE_FORMAT GetFormat(ImageFormat imageFormat) + { + if (imageFormat != null) + { + if (imageFormat.Equals(ImageFormat.Bmp)) + return FREE_IMAGE_FORMAT.FIF_BMP; + if (imageFormat.Equals(ImageFormat.Gif)) + return FREE_IMAGE_FORMAT.FIF_GIF; + if (imageFormat.Equals(ImageFormat.Icon)) + return FREE_IMAGE_FORMAT.FIF_ICO; + if (imageFormat.Equals(ImageFormat.Jpeg)) + return FREE_IMAGE_FORMAT.FIF_JPEG; + if (imageFormat.Equals(ImageFormat.Png)) + return FREE_IMAGE_FORMAT.FIF_PNG; + if (imageFormat.Equals(ImageFormat.Tiff)) + return FREE_IMAGE_FORMAT.FIF_TIFF; + } + return FREE_IMAGE_FORMAT.FIF_UNKNOWN; + } + + /// + /// Retrieves all parameters needed to create a new FreeImage bitmap from + /// raw bits . + /// + /// The + /// of the data in memory. + /// The color depth for the data. + /// Returns the red_mask for the data. + /// Returns the green_mask for the data. + /// Returns the blue_mask for the data. + /// True in case a matching conversion exists; else false. + /// + public static bool GetTypeParameters( + FREE_IMAGE_TYPE type, + int bpp, + out uint red_mask, + out uint green_mask, + out uint blue_mask) + { + bool result = false; + red_mask = 0; + green_mask = 0; + blue_mask = 0; + switch (type) + { + case FREE_IMAGE_TYPE.FIT_BITMAP: + switch (bpp) + { + case 1: + case 4: + case 8: + result = true; + break; + case 16: + result = true; + red_mask = FI16_555_RED_MASK; + green_mask = FI16_555_GREEN_MASK; + blue_mask = FI16_555_BLUE_MASK; + break; + case 24: + case 32: + result = true; + red_mask = FI_RGBA_RED_MASK; + green_mask = FI_RGBA_GREEN_MASK; + blue_mask = FI_RGBA_BLUE_MASK; + break; + } + break; + case FREE_IMAGE_TYPE.FIT_UNKNOWN: + break; + default: + result = true; + break; + } + return result; + } + + /// + /// Compares two FreeImage bitmaps. + /// + /// The first bitmap to compare. + /// The second bitmap to compare. + /// Determines which components of the bitmaps will be compared. + /// True in case both bitmaps match the compare conditions, false otherwise. + public static bool Compare(FIBITMAP dib1, FIBITMAP dib2, FREE_IMAGE_COMPARE_FLAGS flags) + { + // Check whether one bitmap is null + if (dib1.IsNull ^ dib2.IsNull) + { + return false; + } + // Check whether both pointers are the same + if (dib1 == dib2) + { + return true; + } + if (((flags & FREE_IMAGE_COMPARE_FLAGS.HEADER) > 0) && (!CompareHeader(dib1, dib2))) + { + return false; + } + if (((flags & FREE_IMAGE_COMPARE_FLAGS.PALETTE) > 0) && (!ComparePalette(dib1, dib2))) + { + return false; + } + if (((flags & FREE_IMAGE_COMPARE_FLAGS.DATA) > 0) && (!CompareData(dib1, dib2))) + { + return false; + } + if (((flags & FREE_IMAGE_COMPARE_FLAGS.METADATA) > 0) && (!CompareMetadata(dib1, dib2))) + { + return false; + } + return true; + } + + private static unsafe bool CompareHeader(FIBITMAP dib1, FIBITMAP dib2) + { + IntPtr i1 = GetInfoHeader(dib1); + IntPtr i2 = GetInfoHeader(dib2); + return CompareMemory((void*)i1, (void*)i2, sizeof(BITMAPINFOHEADER)); + } + + private static unsafe bool ComparePalette(FIBITMAP dib1, FIBITMAP dib2) + { + IntPtr pal1 = GetPalette(dib1), pal2 = GetPalette(dib2); + bool hasPalette1 = pal1 != IntPtr.Zero; + bool hasPalette2 = pal2 != IntPtr.Zero; + if (hasPalette1 ^ hasPalette2) + { + return false; + } + if (!hasPalette1) + { + return true; + } + uint colors = GetColorsUsed(dib1); + if (colors != GetColorsUsed(dib2)) + { + return false; + } + return CompareMemory((void*)pal1, (void*)pal2, sizeof(RGBQUAD) * colors); + } + + private static unsafe bool CompareData(FIBITMAP dib1, FIBITMAP dib2) + { + uint width = GetWidth(dib1); + if (width != GetWidth(dib2)) + { + return false; + } + uint height = GetHeight(dib1); + if (height != GetHeight(dib2)) + { + return false; + } + uint bpp = GetBPP(dib1); + if (bpp != GetBPP(dib2)) + { + return false; + } + if (GetColorType(dib1) != GetColorType(dib2)) + { + return false; + } + FREE_IMAGE_TYPE type = GetImageType(dib1); + if (type != GetImageType(dib2)) + { + return false; + } + if (GetRedMask(dib1) != GetRedMask(dib2)) + { + return false; + } + if (GetGreenMask(dib1) != GetGreenMask(dib2)) + { + return false; + } + if (GetBlueMask(dib1) != GetBlueMask(dib2)) + { + return false; + } + + byte* ptr1, ptr2; + int fullBytes; + int shift; + uint line = GetLine(dib1); + + if (type == FREE_IMAGE_TYPE.FIT_BITMAP) + { + switch (bpp) + { + case 32: + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (!CompareMemory(ptr1, ptr2, line)) + { + return false; + } + } + break; + case 24: + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (!CompareMemory(ptr1, ptr2, line)) + { + return false; + } + } + break; + case 16: + short* sPtr1, sPtr2; + short mask = (short)(GetRedMask(dib1) | GetGreenMask(dib1) | GetBlueMask(dib1)); + if (mask == -1) + { + for (int i = 0; i < height; i++) + { + sPtr1 = (short*)GetScanLine(dib1, i); + sPtr2 = (short*)GetScanLine(dib2, i); + if (!CompareMemory(sPtr1, sPtr1, line)) + { + return false; + } + } + } + else + { + for (int i = 0; i < height; i++) + { + sPtr1 = (short*)GetScanLine(dib1, i); + sPtr2 = (short*)GetScanLine(dib2, i); + for (int x = 0; x < width; x++) + { + if ((sPtr1[x] & mask) != (sPtr2[x] & mask)) + { + return false; + } + } + } + } + break; + case 8: + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (!CompareMemory(ptr1, ptr2, line)) + { + return false; + } + } + break; + case 4: + fullBytes = (int)width / 2; + shift = (width % 2) == 0 ? 8 : 4; + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (fullBytes != 0) + { + if (!CompareMemory(ptr1, ptr2, fullBytes)) + { + return false; + } + ptr1 += fullBytes; + ptr2 += fullBytes; + } + if (shift != 8) + { + if ((ptr1[0] >> shift) != (ptr2[0] >> shift)) + { + return false; + } + } + } + break; + case 1: + fullBytes = (int)width / 8; + shift = 8 - ((int)width % 8); + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (fullBytes != 0) + { + if (!CompareMemory(ptr1, ptr2, fullBytes)) + { + return false; + } + ptr1 += fullBytes; + ptr2 += fullBytes; + } + if (shift != 8) + { + if ((ptr1[0] >> shift) != (ptr2[0] >> shift)) + { + return false; + } + } + } + break; + default: + throw new NotSupportedException("Only 1, 4, 8, 16, 24 and 32 bpp bitmaps are supported."); + } + } + else + { + for (int i = 0; i < height; i++) + { + ptr1 = (byte*)GetScanLine(dib1, i); + ptr2 = (byte*)GetScanLine(dib2, i); + if (!CompareMemory(ptr1, ptr2, line)) + { + return false; + } + } + } + return true; + } + + private static bool CompareMetadata(FIBITMAP dib1, FIBITMAP dib2) + { + MetadataTag tag1, tag2; + + foreach (FREE_IMAGE_MDMODEL metadataModel in FREE_IMAGE_MDMODELS) + { + if (GetMetadataCount(metadataModel, dib1) != + GetMetadataCount(metadataModel, dib2)) + { + return false; + } + if (GetMetadataCount(metadataModel, dib1) == 0) + { + continue; + } + + FIMETADATA mdHandle = FindFirstMetadata(metadataModel, dib1, out tag1); + if (mdHandle.IsNull) + { + continue; + } + do + { + if ((!GetMetadata(metadataModel, dib2, tag1.Key, out tag2)) || (tag1 != tag2)) + { + FindCloseMetadata(mdHandle); + return false; + } + } + while (FindNextMetadata(mdHandle, out tag1)); + FindCloseMetadata(mdHandle); + } + + return true; + } + + /// + /// Returns the FreeImage bitmap's transparency table. + /// The array is empty in case the bitmap has no transparency table. + /// + /// Handle to a FreeImage bitmap. + /// The FreeImage bitmap's transparency table. + /// + /// is null. + public static unsafe byte[] GetTransparencyTableEx(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + uint count = GetTransparencyCount(dib); + byte[] result = new byte[count]; + byte* ptr = (byte*)GetTransparencyTable(dib); + fixed (byte* dst = result) + { + CopyMemory(dst, ptr, count); + } + return result; + } + + /// + /// Set the FreeImage bitmap's transparency table. Only affects palletised bitmaps. + /// + /// Handle to a FreeImage bitmap. + /// The FreeImage bitmap's new transparency table. + /// + /// or is null. + public static void SetTransparencyTable(FIBITMAP dib, byte[] table) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + if (table == null) + { + throw new ArgumentNullException("table"); + } + SetTransparencyTable(dib, table, table.Length); + } + + /// + /// This function returns the number of unique colors actually used by the + /// specified 1-, 4-, 8-, 16-, 24- or 32-bit image. This might be different from + /// what function FreeImage_GetColorsUsed() returns, which actually returns the + /// palette size for palletised images. Works for + /// type images only. + /// + /// Handle to a FreeImage bitmap. + /// Returns the number of unique colors used by the image specified or + /// zero, if the image type cannot be handled. + /// + /// is null. + public static unsafe int GetUniqueColors(FIBITMAP dib) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + + int result = 0; + + if (GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) + { + BitArray bitArray; + int uniquePalEnts; + int hashcode; + byte[] lut; + int width = (int)GetWidth(dib); + int height = (int)GetHeight(dib); + + switch (GetBPP(dib)) + { + case 1: + + result = 1; + lut = CreateShrunkenPaletteLUT(dib, out uniquePalEnts); + if (uniquePalEnts == 1) + { + break; + } + + if ((*(byte*)GetScanLine(dib, 0) & 0x80) == 0) + { + for (int y = 0; y < height; y++) + { + byte* scanline = (byte*)GetScanLine(dib, y); + int mask = 0x80; + for (int x = 0; x < width; x++) + { + if ((scanline[x / 8] & mask) > 0) + { + return 2; + } + mask = (mask == 0x1) ? 0x80 : (mask >> 1); + } + } + } + else + { + for (int y = 0; y < height; y++) + { + byte* scanline = (byte*)GetScanLine(dib, y); + int mask = 0x80; + for (int x = 0; x < width; x++) + { + if ((scanline[x / 8] & mask) == 0) + { + return 2; + } + mask = (mask == 0x1) ? 0x80 : (mask >> 1); + } + } + } + break; + + case 4: + + bitArray = new BitArray(0x10); + lut = CreateShrunkenPaletteLUT(dib, out uniquePalEnts); + if (uniquePalEnts == 1) + { + result = 1; + break; + } + + for (int y = 0; (y < height) && (result < uniquePalEnts); y++) + { + byte* scanline = (byte*)GetScanLine(dib, y); + bool top = true; + for (int x = 0; (x < width) && (result < uniquePalEnts); x++) + { + if (top) + { + hashcode = lut[scanline[x / 2] >> 4]; + } + else + { + hashcode = lut[scanline[x / 2] & 0xF]; + } + top = !top; + if (!bitArray[hashcode]) + { + bitArray[hashcode] = true; + result++; + } + } + } + break; + + case 8: + + bitArray = new BitArray(0x100); + lut = CreateShrunkenPaletteLUT(dib, out uniquePalEnts); + if (uniquePalEnts == 1) + { + result = 1; + break; + } + + for (int y = 0; (y < height) && (result < uniquePalEnts); y++) + { + byte* scanline = (byte*)GetScanLine(dib, y); + for (int x = 0; (x < width) && (result < uniquePalEnts); x++) + { + hashcode = lut[scanline[x]]; + if (!bitArray[hashcode]) + { + bitArray[hashcode] = true; + result++; + } + } + } + break; + + case 16: + + bitArray = new BitArray(0x10000); + + for (int y = 0; y < height; y++) + { + short* scanline = (short*)GetScanLine(dib, y); + for (int x = 0; x < width; x++, scanline++) + { + hashcode = *scanline; + if (!bitArray[hashcode]) + { + bitArray[hashcode] = true; + result++; + } + } + } + break; + + case 24: + + bitArray = new BitArray(0x1000000); + + for (int y = 0; y < height; y++) + { + byte* scanline = (byte*)GetScanLine(dib, y); + for (int x = 0; x < width; x++, scanline += 3) + { + hashcode = *((int*)scanline) & 0x00FFFFFF; + if (!bitArray[hashcode]) + { + bitArray[hashcode] = true; + result++; + } + } + } + break; + + case 32: + + bitArray = new BitArray(0x1000000); + + for (int y = 0; y < height; y++) + { + int* scanline = (int*)GetScanLine(dib, y); + for (int x = 0; x < width; x++, scanline++) + { + hashcode = *scanline & 0x00FFFFFF; + if (!bitArray[hashcode]) + { + bitArray[hashcode] = true; + result++; + } + } + } + break; + } + } + return result; + } + + /// + /// Verifies whether the FreeImage bitmap is 16bit 555. + /// + /// The FreeImage bitmap to verify. + /// true if the bitmap is RGB16-555; otherwise false. + public static bool IsRGB555(FIBITMAP dib) + { + return ((GetRedMask(dib) == FI16_555_RED_MASK) && + (GetGreenMask(dib) == FI16_555_GREEN_MASK) && + (GetBlueMask(dib) == FI16_555_BLUE_MASK)); + } + + /// + /// Verifies whether the FreeImage bitmap is 16bit 565. + /// + /// The FreeImage bitmap to verify. + /// true if the bitmap is RGB16-565; otherwise false. + public static bool IsRGB565(FIBITMAP dib) + { + return ((GetRedMask(dib) == FI16_565_RED_MASK) && + (GetGreenMask(dib) == FI16_565_GREEN_MASK) && + (GetBlueMask(dib) == FI16_565_BLUE_MASK)); + } + + #endregion + + #region ICC profile functions + + /// + /// Creates a new ICC-Profile for a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The data of the new ICC-Profile. + /// The new ICC-Profile of the bitmap. + /// + /// is null. + public static FIICCPROFILE CreateICCProfileEx(FIBITMAP dib, byte[] data) + { + return new FIICCPROFILE(dib, data); + } + + /// + /// Creates a new ICC-Profile for a FreeImage bitmap. + /// + /// Handle to a FreeImage bitmap. + /// The data of the new ICC-Profile. + /// The number of bytes of to use. + /// The new ICC-Profile of the FreeImage bitmap. + /// + /// is null. + public static FIICCPROFILE CreateICCProfileEx(FIBITMAP dib, byte[] data, int size) + { + return new FIICCPROFILE(dib, data, size); + } + + #endregion + + #region Conversion functions + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion) + { + return ConvertColorDepth( + dib, + conversion, + 128, + FREE_IMAGE_DITHER.FID_FS, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + false); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// When true the structure will be unloaded on success. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + bool unloadSource) + { + return ConvertColorDepth( + dib, + conversion, + 128, + FREE_IMAGE_DITHER.FID_FS, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + unloadSource); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Threshold value when converting with + /// . + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + byte threshold) + { + return ConvertColorDepth( + dib, + conversion, + threshold, + FREE_IMAGE_DITHER.FID_FS, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + false); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Dither algorithm when converting + /// with . + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + FREE_IMAGE_DITHER ditherMethod) + { + return ConvertColorDepth( + dib, + conversion, + 128, + ditherMethod, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + false); + } + + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// The quantization algorithm for conversion to 8-bit color depth. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + FREE_IMAGE_QUANTIZE quantizationMethod) + { + return ConvertColorDepth( + dib, + conversion, + 128, + FREE_IMAGE_DITHER.FID_FS, + quantizationMethod, + false); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Threshold value when converting with + /// . + /// When true the structure will be unloaded on success. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + byte threshold, + bool unloadSource) + { + return ConvertColorDepth( + dib, + conversion, + threshold, + FREE_IMAGE_DITHER.FID_FS, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + unloadSource); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Dither algorithm when converting with + /// . + /// When true the structure will be unloaded on success. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + FREE_IMAGE_DITHER ditherMethod, + bool unloadSource) + { + return ConvertColorDepth( + dib, + conversion, + 128, + ditherMethod, + FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, + unloadSource); + } + + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// The quantization algorithm for conversion to 8-bit color depth. + /// When true the structure will be unloaded on success. + /// Handle to a FreeImage bitmap. + /// + /// is null. + public static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + FREE_IMAGE_QUANTIZE quantizationMethod, + bool unloadSource) + { + return ConvertColorDepth( + dib, + conversion, + 128, + FREE_IMAGE_DITHER.FID_FS, + quantizationMethod, + unloadSource); + } + + /// + /// Converts a FreeImage bitmap from one color depth to another. + /// If the conversion fails the original FreeImage bitmap is returned. + /// + /// Handle to a FreeImage bitmap. + /// The desired output format. + /// Threshold value when converting with + /// . + /// Dither algorithm when converting with + /// . + /// The quantization algorithm for conversion to 8-bit color depth. + /// When true the structure will be unloaded on success. + /// Handle to a FreeImage bitmap. + /// + /// is null. + internal static FIBITMAP ConvertColorDepth( + FIBITMAP dib, + FREE_IMAGE_COLOR_DEPTH conversion, + byte threshold, + FREE_IMAGE_DITHER ditherMethod, + FREE_IMAGE_QUANTIZE quantizationMethod, + bool unloadSource) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + + FIBITMAP result = new FIBITMAP(); + FIBITMAP dibTemp = new FIBITMAP(); + uint bpp = GetBPP(dib); + bool reorderPalette = ((conversion & FREE_IMAGE_COLOR_DEPTH.FICD_REORDER_PALETTE) > 0); + bool forceGreyscale = ((conversion & FREE_IMAGE_COLOR_DEPTH.FICD_FORCE_GREYSCALE) > 0); + + if (GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) + { + switch (conversion & (FREE_IMAGE_COLOR_DEPTH)0xFF) + { + case FREE_IMAGE_COLOR_DEPTH.FICD_01_BPP_THRESHOLD: + + if (bpp != 1) + { + if (forceGreyscale) + { + result = Threshold(dib, threshold); + } + else + { + dibTemp = ConvertTo24Bits(dib); + result = ColorQuantizeEx(dibTemp, quantizationMethod, 2, null, 1); + Unload(dibTemp); + } + } + else + { + bool isGreyscale = IsGreyscaleImage(dib); + if ((forceGreyscale && (!isGreyscale)) || + (reorderPalette && isGreyscale)) + { + result = Threshold(dib, threshold); + } + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_01_BPP_DITHER: + + if (bpp != 1) + { + if (forceGreyscale) + { + result = Dither(dib, ditherMethod); + } + else + { + dibTemp = ConvertTo24Bits(dib); + result = ColorQuantizeEx(dibTemp, quantizationMethod, 2, null, 1); + Unload(dibTemp); + } + } + else + { + bool isGreyscale = IsGreyscaleImage(dib); + if ((forceGreyscale && (!isGreyscale)) || + (reorderPalette && isGreyscale)) + { + result = Dither(dib, ditherMethod); + } + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_04_BPP: + + if (bpp != 4) + { + // Special case when 1bpp and FIC_PALETTE + if (forceGreyscale || + ((bpp == 1) && (GetColorType(dib) == FREE_IMAGE_COLOR_TYPE.FIC_PALETTE))) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo4Bits(dibTemp); + Unload(dibTemp); + } + else + { + dibTemp = ConvertTo24Bits(dib); + result = ColorQuantizeEx(dibTemp, quantizationMethod, 16, null, 4); + Unload(dibTemp); + } + } + else + { + bool isGreyscale = IsGreyscaleImage(dib); + if ((forceGreyscale && (!isGreyscale)) || + (reorderPalette && isGreyscale)) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo4Bits(dibTemp); + Unload(dibTemp); + } + } + + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP: + + if (bpp != 8) + { + if (forceGreyscale) + { + result = ConvertToGreyscale(dib); + } + else + { + dibTemp = ConvertTo24Bits(dib); + result = ColorQuantize(dibTemp, quantizationMethod); + Unload(dibTemp); + } + } + else + { + bool isGreyscale = IsGreyscaleImage(dib); + if ((forceGreyscale && (!isGreyscale)) || (reorderPalette && isGreyscale)) + { + result = ConvertToGreyscale(dib); + } + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_16_BPP_555: + + if (forceGreyscale) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo16Bits555(dibTemp); + Unload(dibTemp); + } + else if (bpp != 16 || GetRedMask(dib) != FI16_555_RED_MASK || GetGreenMask(dib) != FI16_555_GREEN_MASK || GetBlueMask(dib) != FI16_555_BLUE_MASK) + { + result = ConvertTo16Bits555(dib); + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_16_BPP: + + if (forceGreyscale) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo16Bits565(dibTemp); + Unload(dibTemp); + } + else if (bpp != 16 || GetRedMask(dib) != FI16_565_RED_MASK || GetGreenMask(dib) != FI16_565_GREEN_MASK || GetBlueMask(dib) != FI16_565_BLUE_MASK) + { + result = ConvertTo16Bits565(dib); + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_24_BPP: + + if (forceGreyscale) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo24Bits(dibTemp); + Unload(dibTemp); + } + else if (bpp != 24) + { + result = ConvertTo24Bits(dib); + } + break; + + case FREE_IMAGE_COLOR_DEPTH.FICD_32_BPP: + + if (forceGreyscale) + { + dibTemp = ConvertToGreyscale(dib); + result = ConvertTo32Bits(dibTemp); + Unload(dibTemp); + } + else if (bpp != 32) + { + result = ConvertTo32Bits(dib); + } + break; + } + } + + if (result.IsNull) + { + return dib; + } + if (unloadSource) + { + Unload(dib); + } + + return result; + } + + /// + /// ColorQuantizeEx is an extension to the + /// method that provides additional options used to quantize a 24-bit image to any + /// number of colors (up to 256), as well as quantize a 24-bit image using a + /// provided palette. + /// + /// Handle to a FreeImage bitmap. + /// Specifies the color reduction algorithm to be used. + /// Size of the desired output palette. + /// The provided palette. + /// true to create a bitmap with the smallest possible + /// color depth for the specified . + /// Handle to a FreeImage bitmap. + public static FIBITMAP ColorQuantizeEx(FIBITMAP dib, FREE_IMAGE_QUANTIZE quantize, int PaletteSize, RGBQUAD[] ReservePalette, bool minColorDepth) + { + FIBITMAP result; + if (minColorDepth) + { + int bpp; + if (PaletteSize >= 256) + bpp = 8; + else if (PaletteSize > 2) + bpp = 4; + else + bpp = 1; + result = ColorQuantizeEx(dib, quantize, PaletteSize, ReservePalette, bpp); + } + else + { + result = ColorQuantizeEx(dib, quantize, PaletteSize, ReservePalette, 8); + } + return result; + } + + /// + /// ColorQuantizeEx is an extension to the + /// method that provides additional options used to quantize a 24-bit image to any + /// number of colors (up to 256), as well as quantize a 24-bit image using a + /// partial or full provided palette. + /// + /// Handle to a FreeImage bitmap. + /// Specifies the color reduction algorithm to be used. + /// Size of the desired output palette. + /// The provided palette. + /// The desired color depth of the created image. + /// Handle to a FreeImage bitmap. + public static FIBITMAP ColorQuantizeEx(FIBITMAP dib, FREE_IMAGE_QUANTIZE quantize, int PaletteSize, RGBQUAD[] ReservePalette, int bpp) + { + unsafe + { + FIBITMAP result = FIBITMAP.Zero; + FIBITMAP temp = FIBITMAP.Zero; + int reservedSize = (ReservePalette == null) ? 0 : ReservePalette.Length; + + if (bpp == 8) + { + result = ColorQuantizeEx(dib, quantize, PaletteSize, reservedSize, ReservePalette); + } + else if (bpp == 4) + { + temp = ColorQuantizeEx(dib, quantize, Math.Min(16, PaletteSize), reservedSize, ReservePalette); + if (!temp.IsNull) + { + result = Allocate((int)GetWidth(temp), (int)GetHeight(temp), 4, 0, 0, 0); + CloneMetadata(result, temp); + CopyMemory(GetPalette(result), GetPalette(temp), sizeof(RGBQUAD) * 16); + + for (int y = (int)GetHeight(temp) - 1; y >= 0; y--) + { + Scanline srcScanline = new Scanline(temp, y); + Scanline dstScanline = new Scanline(result, y); + + for (int x = (int)GetWidth(temp) - 1; x >= 0; x--) + { + dstScanline[x] = srcScanline[x]; + } + } + } + } + else if (bpp == 1) + { + temp = ColorQuantizeEx(dib, quantize, 2, reservedSize, ReservePalette); + if (!temp.IsNull) + { + result = Allocate((int)GetWidth(temp), (int)GetHeight(temp), 1, 0, 0, 0); + CloneMetadata(result, temp); + CopyMemory(GetPalette(result), GetPalette(temp), sizeof(RGBQUAD) * 2); + + for (int y = (int)GetHeight(temp) - 1; y >= 0; y--) + { + Scanline srcScanline = new Scanline(temp, y); + Scanline dstScanline = new Scanline(result, y); + + for (int x = (int)GetWidth(temp) - 1; x >= 0; x--) + { + dstScanline[x] = srcScanline[x]; + } + } + } + } + + UnloadEx(ref temp); + return result; + } + } + + #endregion + + #region Metadata + + /// + /// Copies metadata from one FreeImage bitmap to another. + /// + /// Source FreeImage bitmap containing the metadata. + /// FreeImage bitmap to copy the metadata to. + /// Flags to switch different copy modes. + /// Returns -1 on failure else the number of copied tags. + /// + /// or is null. + public static int CloneMetadataEx(FIBITMAP src, FIBITMAP dst, FREE_IMAGE_METADATA_COPY flags) + { + if (src.IsNull) + { + throw new ArgumentNullException("src"); + } + if (dst.IsNull) + { + throw new ArgumentNullException("dst"); + } + + FITAG tag = new FITAG(), tag2 = new FITAG(); + int copied = 0; + + // Clear all existing metadata + if ((flags & FREE_IMAGE_METADATA_COPY.CLEAR_EXISTING) > 0) + { + foreach (FREE_IMAGE_MDMODEL model in FREE_IMAGE_MDMODELS) + { + if (!SetMetadata(model, dst, null, tag)) + { + return -1; + } + } + } + + bool keep = !((flags & FREE_IMAGE_METADATA_COPY.REPLACE_EXISTING) > 0); + + foreach (FREE_IMAGE_MDMODEL model in FREE_IMAGE_MDMODELS) + { + FIMETADATA mData = FindFirstMetadata(model, src, out tag); + if (mData.IsNull) continue; + do + { + string key = GetTagKey(tag); + if (!(keep && GetMetadata(model, dst, key, out tag2))) + { + if (SetMetadata(model, dst, key, tag)) + { + copied++; + } + } + } + while (FindNextMetadata(mData, out tag)); + FindCloseMetadata(mData); + } + + return copied; + } + + /// + /// Returns the comment of a JPEG, PNG or GIF image. + /// + /// Handle to a FreeImage bitmap. + /// Comment of the FreeImage bitmp, or null in case no comment exists. + /// + /// is null. + public static string GetImageComment(FIBITMAP dib) + { + string result = null; + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + FITAG tag; + if (GetMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, "Comment", out tag)) + { + MetadataTag metadataTag = new MetadataTag(tag, FREE_IMAGE_MDMODEL.FIMD_COMMENTS); + result = metadataTag.Value as string; + } + return result; + } + + /// + /// Sets the comment of a JPEG, PNG or GIF image. + /// + /// Handle to a FreeImage bitmap. + /// New comment of the FreeImage bitmap. + /// Use null to remove the comment. + /// Returns true on success, false on failure. + /// + /// is null. + public static bool SetImageComment(FIBITMAP dib, string comment) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + bool result; + if (comment != null) + { + FITAG tag = CreateTag(); + MetadataTag metadataTag = new MetadataTag(tag, FREE_IMAGE_MDMODEL.FIMD_COMMENTS); + metadataTag.Value = comment; + result = SetMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, "Comment", tag); + DeleteTag(tag); + } + else + { + result = SetMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, "Comment", FITAG.Zero); + } + return result; + } + + /// + /// Retrieve a metadata attached to a FreeImage bitmap. + /// + /// The metadata model to look for. + /// Handle to a FreeImage bitmap. + /// The metadata field name. + /// A structure returned by the function. + /// Returns true on success, false on failure. + /// + /// is null. + public static bool GetMetadata( + FREE_IMAGE_MDMODEL model, + FIBITMAP dib, + string key, + out MetadataTag tag) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + + FITAG _tag; + bool result; + if (GetMetadata(model, dib, key, out _tag)) + { + tag = new MetadataTag(_tag, model); + result = true; + } + else + { + tag = null; + result = false; + } + return result; + } + + /// + /// Attach a new metadata tag to a FreeImage bitmap. + /// + /// The metadata model used to store the tag. + /// Handle to a FreeImage bitmap. + /// The tag field name. + /// The to be attached. + /// Returns true on success, false on failure. + /// + /// is null. + public static bool SetMetadata( + FREE_IMAGE_MDMODEL model, + FIBITMAP dib, + string key, + MetadataTag tag) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + return SetMetadata(model, dib, key, tag.tag); + } + + /// + /// Provides information about the first instance of a tag that matches the metadata model. + /// + /// The model to match. + /// Handle to a FreeImage bitmap. + /// Tag that matches the metadata model. + /// Unique search handle that can be used to call FindNextMetadata or FindCloseMetadata. + /// Null if the metadata model does not exist. + /// + /// is null. + public static FIMETADATA FindFirstMetadata( + FREE_IMAGE_MDMODEL model, + FIBITMAP dib, + out MetadataTag tag) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + FITAG _tag; + FIMETADATA result = FindFirstMetadata(model, dib, out _tag); + if (result.IsNull) + { + tag = null; + return result; + } + tag = new MetadataTag(_tag, model); + if (metaDataSearchHandler.ContainsKey(result)) + { + metaDataSearchHandler[result] = model; + } + else + { + metaDataSearchHandler.Add(result, model); + } + return result; + } + + /// + /// Find the next tag, if any, that matches the metadata model argument in a previous call + /// to FindFirstMetadata, and then alters the tag object contents accordingly. + /// + /// Unique search handle provided by FindFirstMetadata. + /// Tag that matches the metadata model. + /// Returns true on success, false on failure. + public static bool FindNextMetadata(FIMETADATA mdhandle, out MetadataTag tag) + { + FITAG _tag; + bool result; + if (FindNextMetadata(mdhandle, out _tag)) + { + tag = new MetadataTag(_tag, metaDataSearchHandler[mdhandle]); + result = true; + } + else + { + tag = null; + result = false; + } + return result; + } + + /// + /// Closes the specified metadata search handle and releases associated resources. + /// + /// The handle to close. + public static void FindCloseMetadata(FIMETADATA mdhandle) + { + if (metaDataSearchHandler.ContainsKey(mdhandle)) + { + metaDataSearchHandler.Remove(mdhandle); + } + FindCloseMetadata_(mdhandle); + } + + /// + /// This dictionary links FIMETADATA handles and FREE_IMAGE_MDMODEL models. + /// + private static Dictionary metaDataSearchHandler + = new Dictionary(1); + + #endregion + + #region Rotation and Flipping + + /// + /// This function rotates a 1-, 8-bit greyscale or a 24-, 32-bit color image by means of 3 shears. + /// 1-bit images rotation is limited to integer multiple of 90�. + /// null is returned for other values. + /// + /// Handle to a FreeImage bitmap. + /// The angle of rotation. + /// Handle to a FreeImage bitmap. + public static FIBITMAP Rotate(FIBITMAP dib, double angle) + { + return Rotate(dib, angle, IntPtr.Zero); + } + + /// + /// This function rotates a 1-, 8-bit greyscale or a 24-, 32-bit color image by means of 3 shears. + /// 1-bit images rotation is limited to integer multiple of 90�. + /// null is returned for other values. + /// + /// The type of the color to use as background. + /// Handle to a FreeImage bitmap. + /// The angle of rotation. + /// The color used used to fill the bitmap's background. + /// Handle to a FreeImage bitmap. + public static FIBITMAP Rotate(FIBITMAP dib, double angle, T? backgroundColor) where T : struct + { + if (backgroundColor.HasValue) + { + GCHandle handle = new GCHandle(); + try + { + T[] buffer = new T[] { backgroundColor.Value }; + handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + return Rotate(dib, angle, handle.AddrOfPinnedObject()); + } + finally + { + if (handle.IsAllocated) + handle.Free(); + } + } + else + { + return Rotate(dib, angle, IntPtr.Zero); + } + } + + /// + /// Rotates a 4-bit color FreeImage bitmap. + /// Allowed values for are 90, 180 and 270. + /// In case is 0 or 360 a clone is returned. + /// 0 is returned for other values or in case the rotation fails. + /// + /// Handle to a FreeImage bitmap. + /// The angle of rotation. + /// Handle to a FreeImage bitmap. + /// + /// This function is kind of temporary due to FreeImage's lack of + /// rotating 4-bit images. It's particularly used by 's + /// method RotateFlip. This function will be removed as soon as FreeImage + /// supports rotating 4-bit images. + /// + /// + /// is null. + public static unsafe FIBITMAP Rotate4bit(FIBITMAP dib, double angle) + { + if (dib.IsNull) + { + throw new ArgumentNullException("dib"); + } + + FIBITMAP result = new FIBITMAP(); + int ang = (int)angle; + + if ((GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) && + (GetBPP(dib) == 4) && + ((ang % 90) == 0)) + { + int width, height, xOrg, yOrg; + Scanline[] src, dst; + width = (int)GetWidth(dib); + height = (int)GetHeight(dib); + byte index = 0; + switch (ang) + { + case 90: + result = Allocate(height, width, 4, 0, 0, 0); + if (result.IsNull) + { + break; + } + CopyPalette(dib, result); + src = Get04BitScanlines(dib); + dst = Get04BitScanlines(result); + for (int y = 0; y < width; y++) + { + yOrg = height - 1; + for (int x = 0; x < height; x++, yOrg--) + { + index = src[yOrg][y]; + dst[y][x] = index; + } + } + break; + case 180: + result = Allocate(width, height, 4, 0, 0, 0); + if (result.IsNull) + { + break; + } + CopyPalette(dib, result); + src = Get04BitScanlines(dib); + dst = Get04BitScanlines(result); + + yOrg = height - 1; + for (int y = 0; y < height; y++, yOrg--) + { + xOrg = width - 1; + for (int x = 0; x < width; x++, xOrg--) + { + index = src[yOrg][xOrg]; + dst[y][x] = index; + } + } + break; + case 270: + result = Allocate(height, width, 4, 0, 0, 0); + if (result.IsNull) + { + break; + } + CopyPalette(dib, result); + src = Get04BitScanlines(dib); + dst = Get04BitScanlines(result); + xOrg = width - 1; + for (int y = 0; y < width; y++, xOrg--) + { + for (int x = 0; x < height; x++) + { + index = src[x][xOrg]; + dst[y][x] = index; + } + } + break; + case 0: + case 360: + result = Clone(dib); + break; + } + } + return result; + } + + #endregion + + #region Upsampling / downsampling + + /// + /// Enlarges or shrinks the FreeImage bitmap selectively per side and fills newly added areas + /// with the specified background color. See remarks for further details. + /// + /// The type of the specified color. + /// Handle to a FreeImage bitmap. + /// The number of pixels, the image should be enlarged on its left side. + /// Negative values shrink the image on its left side. + /// The number of pixels, the image should be enlarged on its top side. + /// Negative values shrink the image on its top side. + /// The number of pixels, the image should be enlarged on its right side. + /// Negative values shrink the image on its right side. + /// The number of pixels, the image should be enlarged on its bottom side. + /// Negative values shrink the image on its bottom side. + /// The color, the enlarged sides of the image should be filled with. + /// Options that affect the color search process for palletized images. + /// Handle to a FreeImage bitmap. + /// + /// This function enlarges or shrinks an image selectively per side. + /// The main purpose of this function is to add borders to an image. + /// To add a border to any of the image's sides, a positive integer value must be passed in + /// any of the parameters , , + /// or . This value represents the border's + /// width in pixels. Newly created parts of the image (the border areas) are filled with the + /// specified . + /// Specifying a negative integer value for a certain side, will shrink or crop the image on + /// this side. Consequently, specifying zero for a certain side will not change the image's + /// extension on that side. + /// + /// So, calling this function with all parameters , , + /// and set to zero, is + /// effectively the same as calling function ; setting all parameters + /// , , and + /// to value equal to or smaller than zero, my easily be substituted + /// by a call to function . Both these cases produce a new image, which is + /// guaranteed not to be larger than the input image. Thus, since the specified + /// is not needed in these cases, + /// may be null. + /// + /// Both parameters and work according to + /// function . So, please refer to the documentation of + /// to learn more about parameters + /// and . For palletized images, the palette of the input image is + /// transparently copied to the newly created enlarged or shrunken image, so any color look-ups + /// are performed on this palette. + /// + /// + /// // create a white color
+ /// RGBQUAD c;
+ /// c.rgbRed = 0xFF;
+ /// c.rgbGreen = 0xFF;
+ /// c.rgbBlue = 0xFF;
+ /// c.rgbReserved = 0x00;
+ ///
+ /// // add a white, symmetric 10 pixel wide border to the image
+ /// dib2 = FreeImage_EnlargeCanvas(dib, 10, 10, 10, 10, c, FREE_IMAGE_COLOR_OPTIONS.FICO_RGB);
+ ///
+ /// // add white, 20 pixel wide stripes to the top and bottom side of the image
+ /// dib3 = FreeImage_EnlargeCanvas(dib, 0, 20, 0, 20, c, FREE_IMAGE_COLOR_OPTIONS.FICO_RGB);
+ ///
+ /// // add white, 30 pixel wide stripes to the right side of the image and
+ /// // cut off the 40 leftmost pixel columns
+ /// dib3 = FreeImage_EnlargeCanvas(dib, -40, 0, 30, 0, c, FREE_IMAGE_COLOR_OPTIONS.FICO_RGB);
+ ///
+ public static FIBITMAP EnlargeCanvas(FIBITMAP dib, int left, int top, int right, int bottom, + T? color, FREE_IMAGE_COLOR_OPTIONS options) where T : struct + { + if (dib.IsNull) + return FIBITMAP.Zero; + + if (!CheckColorType(GetImageType(dib), color)) + return FIBITMAP.Zero; + + if (color.HasValue) + { + GCHandle handle = new GCHandle(); + try + { + T[] buffer = new T[] { color.Value }; + handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + return EnlargeCanvas(dib, left, top, right, bottom, handle.AddrOfPinnedObject(), options); + } + finally + { + if (handle.IsAllocated) + handle.Free(); + } + } + else + { + return EnlargeCanvas(dib, left, top, right, bottom, IntPtr.Zero, options); + } + } + + #endregion + + #region Color + + /// + /// Sets all pixels of the specified image to the color provided through the + /// parameter. See remarks for further details. + /// + /// The type of the specified color. + /// Handle to a FreeImage bitmap. + /// The color to fill the bitmap with. See remarks for further details. + /// Options that affect the color search process for palletized images. + /// true on success, false on failure. + /// + /// This function sets all pixels of an image to the color provided through + /// the parameter. is used for standard type images. + /// For non standard type images the underlaying structure is used. + /// + /// So, must be of type , if the image to be filled is of type + /// and must be a structure if the + /// image is of type and so on. + /// + /// However, the fill color is always specified through a structure + /// for all images of type . + /// So, for 32- and 24-bit images, the red, green and blue members of the + /// structure are directly used for the image's red, green and blue channel respectively. + /// Although alpha transparent colors are + /// supported, the alpha channel of a 32-bit image never gets modified by this function. + /// A fill color with an alpha value smaller than 255 gets blended with the image's actual + /// background color, which is determined from the image's bottom-left pixel. + /// So, currently using alpha enabled colors, assumes the image to be unicolor before the + /// fill operation. However, the field is only taken into account, + /// if option has been specified. + /// + /// For 16-bit images, the red-, green- and blue components of the specified color are + /// transparently translated into either the 16-bit 555 or 565 representation. This depends + /// on the image's actual red- green- and blue masks. + /// + /// Special attention must be payed for palletized images. Generally, the RGB color specified + /// is looked up in the image's palette. The found palette index is then used to fill the image. + /// There are some option flags, that affect this lookup process: + /// + /// + /// Value + /// Meaning + /// + /// + /// + /// + /// Uses the color, that is nearest to the specified color. + /// This is the default behavior and should always find a + /// color in the palette. However, the visual result may + /// far from what was expected and mainly depends on the + /// image's palette. + /// + /// + /// + /// + /// + /// Searches the image's palette for the specified color + /// but only uses the returned palette index, if the specified + /// color exactly matches the palette entry. Of course, + /// depending on the image's actual palette entries, this + /// operation may fail. In this case, the function falls back + /// to option + /// and uses the RGBQUAD's rgbReserved member (or its low nibble for 4-bit images + /// or its least significant bit (LSB) for 1-bit images) as + /// the palette index used for the fill operation. + /// + /// + /// + /// + /// + /// Does not perform any color lookup from the palette, but + /// uses the RGBQUAD's alpha channel member rgbReserved as + /// the palette index to be used for the fill operation. + /// However, for 4-bit images, only the low nibble of the + /// rgbReserved member are used and for 1-bit images, only + /// the least significant bit (LSB) is used. + /// + /// + /// + /// + public static bool FillBackground(FIBITMAP dib, T color, FREE_IMAGE_COLOR_OPTIONS options) + where T : struct + { + if (dib.IsNull) + return false; + + if (!CheckColorType(GetImageType(dib), color)) + return false; + + GCHandle handle = new GCHandle(); + try + { + T[] buffer = new T[] { color }; + handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + return FillBackground(dib, handle.AddrOfPinnedObject(), options); + } + finally + { + if (handle.IsAllocated) + handle.Free(); + } + } + + #endregion + + #region Wrapper functions + + /// + /// Returns the next higher possible color depth. + /// + /// Color depth to increase. + /// The next higher color depth or 0 if there is no valid color depth. + internal static int GetNextColorDepth(int bpp) + { + int result = 0; + switch (bpp) + { + case 1: + result = 4; + break; + case 4: + result = 8; + break; + case 8: + result = 16; + break; + case 16: + result = 24; + break; + case 24: + result = 32; + break; + } + return result; + } + + /// + /// Returns the next lower possible color depth. + /// + /// Color depth to decrease. + /// The next lower color depth or 0 if there is no valid color depth. + internal static int GetPrevousColorDepth(int bpp) + { + int result = 0; + switch (bpp) + { + case 32: + result = 24; + break; + case 24: + result = 16; + break; + case 16: + result = 8; + break; + case 8: + result = 4; + break; + case 4: + result = 1; + break; + } + return result; + } + + /// + /// Reads a null-terminated c-string. + /// + /// Pointer to the first char of the string. + /// The converted string. + internal static unsafe string PtrToStr(byte* ptr) + { + string result = null; + if (ptr != null) + { + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + + while (*ptr != 0) + { + sb.Append((char)(*(ptr++))); + } + result = sb.ToString(); + } + return result; + } + + internal static unsafe byte[] CreateShrunkenPaletteLUT(FIBITMAP dib, out int uniqueColors) + { + byte[] result = null; + uniqueColors = 0; + + if ((!dib.IsNull) && (GetImageType(dib) == FREE_IMAGE_TYPE.FIT_BITMAP) && (GetBPP(dib) <= 8)) + { + int size = (int)GetColorsUsed(dib); + List newPalette = new List(size); + List lut = new List(size); + RGBQUAD* palette = (RGBQUAD*)GetPalette(dib); + RGBQUAD color; + int index; + + for (int i = 0; i < size; i++) + { + color = palette[i]; + color.rgbReserved = 255; // ignore alpha + + index = newPalette.IndexOf(color); + if (index < 0) + { + newPalette.Add(color); + lut.Add((byte)(newPalette.Count - 1)); + } + else + { + lut.Add((byte)index); + } + } + result = lut.ToArray(); + uniqueColors = newPalette.Count; + } + return result; + } + + internal static PropertyItem CreatePropertyItem() + { + return (PropertyItem)Activator.CreateInstance(typeof(PropertyItem), true); + } + + private static unsafe void CopyPalette(FIBITMAP src, FIBITMAP dst) + { + RGBQUAD* orgPal = (RGBQUAD*)GetPalette(src); + RGBQUAD* newPal = (RGBQUAD*)GetPalette(dst); + uint size = (uint)(sizeof(RGBQUAD) * GetColorsUsed(src)); + CopyMemory(newPal, orgPal, size); + } + + private static unsafe Scanline[] Get04BitScanlines(FIBITMAP dib) + { + int height = (int)GetHeight(dib); + Scanline[] array = new Scanline[height]; + for (int i = 0; i < height; i++) + { + array[i] = new Scanline(dib, i); + } + return array; + } + + /// + /// Changes a bitmaps color depth. + /// Used by SaveEx and SaveToStream. + /// + private static FIBITMAP PrepareBitmapColorDepth(FIBITMAP dibToSave, FREE_IMAGE_FORMAT format, FREE_IMAGE_COLOR_DEPTH colorDepth) + { + FREE_IMAGE_TYPE type = GetImageType(dibToSave); + if (type == FREE_IMAGE_TYPE.FIT_BITMAP) + { + int bpp = (int)GetBPP(dibToSave); + int targetBpp = (int)(colorDepth & FREE_IMAGE_COLOR_DEPTH.FICD_COLOR_MASK); + + if (colorDepth != FREE_IMAGE_COLOR_DEPTH.FICD_AUTO) + { + // A fix colordepth was chosen + if (FIFSupportsExportBPP(format, targetBpp)) + { + dibToSave = ConvertColorDepth(dibToSave, colorDepth, false); + } + else + { + throw new ArgumentException("FreeImage\n\nFreeImage Library plugin " + + GetFormatFromFIF(format) + " is unable to write images with a color depth of " + + targetBpp + " bpp."); + } + } + else + { + // Auto selection was chosen + if (!FIFSupportsExportBPP(format, bpp)) + { + // The color depth is not supported + int bppUpper = bpp; + int bppLower = bpp; + // Check from the bitmaps current color depth in both directions + do + { + bppUpper = GetNextColorDepth(bppUpper); + if (FIFSupportsExportBPP(format, bppUpper)) + { + dibToSave = ConvertColorDepth(dibToSave, (FREE_IMAGE_COLOR_DEPTH)bppUpper, false); + break; + } + bppLower = GetPrevousColorDepth(bppLower); + if (FIFSupportsExportBPP(format, bppLower)) + { + dibToSave = ConvertColorDepth(dibToSave, (FREE_IMAGE_COLOR_DEPTH)bppLower, false); + break; + } + } while (!((bppLower == 0) && (bppUpper == 0))); + } + } + } + return dibToSave; + } + + /// + /// Compares blocks of memory. + /// + /// A pointer to a block of memory to compare. + /// A pointer to a block of memory to compare. + /// Specifies the number of bytes to be compared. + /// true, if all bytes compare as equal, false otherwise. + public static unsafe bool CompareMemory(void* buf1, void* buf2, uint length) + { + return (length == RtlCompareMemory(buf1, buf2, length)); + } + + /// + /// Compares blocks of memory. + /// + /// A pointer to a block of memory to compare. + /// A pointer to a block of memory to compare. + /// Specifies the number of bytes to be compared. + /// true, if all bytes compare as equal, false otherwise. + public static unsafe bool CompareMemory(void* buf1, void* buf2, long length) + { + return (length == RtlCompareMemory(buf1, buf2, checked((uint)length))); + } + + /// + /// Compares blocks of memory. + /// + /// A pointer to a block of memory to compare. + /// A pointer to a block of memory to compare. + /// Specifies the number of bytes to be compared. + /// true, if all bytes compare as equal, false otherwise. + public static unsafe bool CompareMemory(IntPtr buf1, IntPtr buf2, uint length) + { + return (length == RtlCompareMemory(buf1.ToPointer(), buf2.ToPointer(), length)); + } + + /// + /// Compares blocks of memory. + /// + /// A pointer to a block of memory to compare. + /// A pointer to a block of memory to compare. + /// Specifies the number of bytes to be compared. + /// true, if all bytes compare as equal, false otherwise. + public static unsafe bool CompareMemory(IntPtr buf1, IntPtr buf2, long length) + { + return (length == RtlCompareMemory(buf1.ToPointer(), buf2.ToPointer(), checked((uint)length))); + } + + /// + /// Moves a block of memory from one location to another. + /// + /// A pointer to the starting address of the move destination. + /// A pointer to the starting address of the block of memory to be moved. + /// The size of the block of memory to move, in bytes. + public static unsafe void MoveMemory(void* dst, void* src, long size) + { + MoveMemory(dst, src, checked((uint)size)); + } + + /// + /// Moves a block of memory from one location to another. + /// + /// A pointer to the starting address of the move destination. + /// A pointer to the starting address of the block of memory to be moved. + /// The size of the block of memory to move, in bytes. + public static unsafe void MoveMemory(IntPtr dst, IntPtr src, uint size) + { + MoveMemory(dst.ToPointer(), src.ToPointer(), size); + } + + /// + /// Moves a block of memory from one location to another. + /// + /// A pointer to the starting address of the move destination. + /// A pointer to the starting address of the block of memory to be moved. + /// The size of the block of memory to move, in bytes. + public static unsafe void MoveMemory(IntPtr dst, IntPtr src, long size) + { + MoveMemory(dst.ToPointer(), src.ToPointer(), checked((uint)size)); + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(byte* dest, byte* src, int len) + { + if (len >= 0x10) + { + do + { + *((int*)dest) = *((int*)src); + *((int*)(dest + 4)) = *((int*)(src + 4)); + *((int*)(dest + 8)) = *((int*)(src + 8)); + *((int*)(dest + 12)) = *((int*)(src + 12)); + dest += 0x10; + src += 0x10; + } + while ((len -= 0x10) >= 0x10); + } + if (len > 0) + { + if ((len & 8) != 0) + { + *((int*)dest) = *((int*)src); + *((int*)(dest + 4)) = *((int*)(src + 4)); + dest += 8; + src += 8; + } + if ((len & 4) != 0) + { + *((int*)dest) = *((int*)src); + dest += 4; + src += 4; + } + if ((len & 2) != 0) + { + *((short*)dest) = *((short*)src); + dest += 2; + src += 2; + } + if ((len & 1) != 0) + { + *dest = *src; + } + } + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(byte* dest, byte* src, long len) + { + CopyMemory(dest, src, checked((int)len)); + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(void* dest, void* src, long len) + { + CopyMemory((byte*)dest, (byte*)src, checked((int)len)); + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(void* dest, void* src, int len) + { + CopyMemory((byte*)dest, (byte*)src, len); + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(IntPtr dest, IntPtr src, int len) + { + CopyMemory((byte*)dest, (byte*)src, len); + } + + /// + /// Copies a block of memory from one location to another. + /// + /// A pointer to the starting address of the copied block's destination. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + /// + /// CopyMemory runs faster than . + /// However, if both blocks overlap the result is undefined. + /// + public static unsafe void CopyMemory(IntPtr dest, IntPtr src, long len) + { + CopyMemory((byte*)dest, (byte*)src, checked((int)len)); + } + + /// + /// Copies a block of memory into an array. + /// + /// An array used as the destination of the copy process. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(Array dest, void* src, int len) + { + GCHandle handle = GCHandle.Alloc(dest, GCHandleType.Pinned); + try + { + CopyMemory((byte*)handle.AddrOfPinnedObject(), (byte*)src, len); + } + finally + { + handle.Free(); + } + } + + /// + /// Copies a block of memory into an array. + /// + /// An array used as the destination of the copy process. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(Array dest, void* src, long len) + { + CopyMemory(dest, (byte*)src, checked((int)len)); + } + + /// + /// Copies a block of memory into an array. + /// + /// An array used as the destination of the copy process. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(Array dest, IntPtr src, int len) + { + CopyMemory(dest, (byte*)src, len); + } + + /// + /// Copies a block of memory into an array. + /// + /// An array used as the destination of the copy process. + /// A pointer to the starting address of the block of memory to copy. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(Array dest, IntPtr src, long len) + { + CopyMemory(dest, (byte*)src, checked((int)len)); + } + + /// + /// Copies the content of an array to a memory location. + /// + /// A pointer to the starting address of the copied block's destination. + /// An array used as the source of the copy process. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(void* dest, Array src, int len) + { + GCHandle handle = GCHandle.Alloc(src, GCHandleType.Pinned); + try + { + CopyMemory((byte*)dest, (byte*)handle.AddrOfPinnedObject(), len); + } + finally + { + handle.Free(); + } + } + + /// + /// Copies the content of an array to a memory location. + /// + /// A pointer to the starting address of the copied block's destination. + /// An array used as the source of the copy process. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(void* dest, Array src, long len) + { + CopyMemory((byte*)dest, src, checked((int)len)); + } + + /// + /// Copies the content of an array to a memory location. + /// + /// A pointer to the starting address of the copied block's destination. + /// An array used as the source of the copy process. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(IntPtr dest, Array src, int len) + { + CopyMemory((byte*)dest, src, len); + } + + /// + /// Copies the content of an array to a memory location. + /// + /// A pointer to the starting address of the copied block's destination. + /// An array used as the source of the copy process. + /// The size of the block of memory to copy, in bytes. + public static unsafe void CopyMemory(IntPtr dest, Array src, long len) + { + CopyMemory((byte*)dest, src, checked((int)len)); + } + + /// + /// Copies the content of one array into another array. + /// + /// An array used as the destination of the copy process. + /// An array used as the source of the copy process. + /// The size of the content to copy, in bytes. + public static unsafe void CopyMemory(Array dest, Array src, int len) + { + GCHandle dHandle = GCHandle.Alloc(dest, GCHandleType.Pinned); + try + { + GCHandle sHandle = GCHandle.Alloc(src, GCHandleType.Pinned); + try + { + CopyMemory((byte*)dHandle.AddrOfPinnedObject(), (byte*)sHandle.AddrOfPinnedObject(), len); + } + finally + { + sHandle.Free(); + } + } + finally + { + dHandle.Free(); + } + } + + /// + /// Copies the content of one array into another array. + /// + /// An array used as the destination of the copy process. + /// An array used as the source of the copy process. + /// The size of the content to copy, in bytes. + public static unsafe void CopyMemory(Array dest, Array src, long len) + { + CopyMemory(dest, src, checked((int)len)); + } + + internal static string ColorToString(Color color) + { + return string.Format( + System.Globalization.CultureInfo.CurrentCulture, + "{{Name={0}, ARGB=({1}, {2}, {3}, {4})}}", + new object[] { color.Name, color.A, color.R, color.G, color.B }); + } + + internal static void Resize(ref string str, int length) + { + if ((str != null) && (length >= 0) && (str.Length != length)) + { + char[] chars = str.ToCharArray(); + Array.Resize(ref chars, length); + str = new string(chars); + } + } + + internal static void Resize(ref string str, int min, int max) + { + if ((str != null) && (min >= 0) && (max >= 0) && (min <= max)) + { + if (str.Length < min) + { + char[] chars = str.ToCharArray(); + Array.Resize(ref chars, min); + str = new string(chars); + } + else if (str.Length > max) + { + char[] chars = str.ToCharArray(); + Array.Resize(ref chars, max); + str = new string(chars); + } + } + } + + internal static void Resize(ref T[] array, int length) + { + if ((array != null) && (length >= 0) && (array.Length != length)) + { + Array.Resize(ref array, length); + } + } + + internal static void Resize(ref T[] array, int min, int max) + { + if ((array != null) && (min >= 0) && (max >= 0) && (min <= max)) + { + if (array.Length < min) + { + Array.Resize(ref array, min); + } + else if (array.Length > max) + { + Array.Resize(ref array, max); + } + } + } + + internal static bool CheckColorType(FREE_IMAGE_TYPE imageType, T color) + { + Type type = typeof(T); + bool result; + switch (imageType) + { + case FREE_IMAGE_TYPE.FIT_BITMAP: + result = (type == typeof(RGBQUAD)); break; + case FREE_IMAGE_TYPE.FIT_COMPLEX: + result = (type == typeof(FICOMPLEX)); break; + case FREE_IMAGE_TYPE.FIT_DOUBLE: + result = (type == typeof(double)); break; + case FREE_IMAGE_TYPE.FIT_FLOAT: + result = (type == typeof(float)); break; + case FREE_IMAGE_TYPE.FIT_INT16: + result = (type == typeof(Int16)); break; + case FREE_IMAGE_TYPE.FIT_INT32: + result = (type == typeof(Int32)); break; + case FREE_IMAGE_TYPE.FIT_RGB16: + result = (type == typeof(FIRGB16)); break; + case FREE_IMAGE_TYPE.FIT_RGBA16: + result = (type == typeof(FIRGBA16)); break; + case FREE_IMAGE_TYPE.FIT_RGBAF: + result = (type == typeof(FIRGBAF)); break; + case FREE_IMAGE_TYPE.FIT_RGBF: + result = (type == typeof(FIRGBF)); break; + case FREE_IMAGE_TYPE.FIT_UINT16: + result = (type == typeof(UInt16)); break; + case FREE_IMAGE_TYPE.FIT_UINT32: + result = (type == typeof(UInt32)); break; + default: + result = false; break; + } + return result; + } + + #endregion + + #region Dll-Imports + + /// + /// Retrieves a handle to a display device context (DC) for the client area of a specified window + /// or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC. + /// + /// Handle to the window whose DC is to be retrieved. + /// If this value is IntPtr.Zero, GetDC retrieves the DC for the entire screen. + /// If the function succeeds, the return value is a handle to the DC for the specified window's client area. + /// If the function fails, the return value is NULL. + [DllImport("user32.dll")] + private static extern IntPtr GetDC(IntPtr hWnd); + + /// + /// Releases a device context (DC), freeing it for use by other applications. + /// The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs. + /// It has no effect on class or private DCs. + /// + /// Handle to the window whose DC is to be released. + /// Handle to the DC to be released. + /// Returns true on success, false on failure. + [DllImport("user32.dll")] + private static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC); + + /// + /// Creates a DIB that applications can write to directly. + /// The function gives you a pointer to the location of the bitmap bit values. + /// You can supply a handle to a file-mapping object that the function will use to create the bitmap, + /// or you can let the system allocate the memory for the bitmap. + /// + /// Handle to a device context. + /// Pointer to a BITMAPINFO structure that specifies various attributes of the DIB, + /// including the bitmap dimensions and colors. + /// Specifies the type of data contained in the bmiColors array member of the BITMAPINFO structure + /// pointed to by pbmi (either logical palette indexes or literal RGB values). + /// Pointer to a variable that receives a pointer to the location of the DIB bit values. + /// Handle to a file-mapping object that the function will use to create the DIB. + /// This parameter can be NULL. + /// Specifies the offset from the beginning of the file-mapping object referenced by hSection + /// where storage for the bitmap bit values is to begin. This value is ignored if hSection is NULL. + /// If the function succeeds, the return value is a handle to the newly created DIB, + /// and *ppvBits points to the bitmap bit values. If the function fails, the return value is NULL, and *ppvBits is NULL. + [DllImport("gdi32.dll")] + private static extern IntPtr CreateDIBSection( + IntPtr hdc, + [In] IntPtr pbmi, + uint iUsage, + out IntPtr ppvBits, + IntPtr hSection, + uint dwOffset); + + /// + /// Deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object. + /// After the object is deleted, the specified handle is no longer valid. + /// + /// Handle to a logical pen, brush, font, bitmap, region, or palette. + /// Returns true on success, false on failure. + [DllImport("gdi32.dll")] + private static extern bool DeleteObject(IntPtr hObject); + + /// + /// Creates a compatible bitmap (DDB) from a DIB and, optionally, sets the bitmap bits. + /// + /// Handle to a device context. + /// Pointer to a bitmap information header structure. + /// Specifies how the system initializes the bitmap bits - (use 4). + /// Pointer to an array of bytes containing the initial bitmap data. + /// Pointer to a BITMAPINFO structure that describes the dimensions + /// and color format of the array pointed to by the lpbInit parameter. + /// Specifies whether the bmiColors member of the BITMAPINFO structure + /// was initialized - (use 0). + /// Handle to a DIB or null on failure. + [DllImport("gdi32.dll")] + private static extern IntPtr CreateDIBitmap( + IntPtr hdc, + IntPtr lpbmih, + uint fdwInit, + IntPtr lpbInit, + IntPtr lpbmi, + uint fuUsage); + + /// + /// Retrieves information for the specified graphics object. + /// + /// Handle to the graphics object of interest. + /// Specifies the number of bytes of information to + /// be written to the buffer. + /// Pointer to a buffer that receives the information + /// about the specified graphics object. + /// 0 on failure. + [DllImport("gdi32.dll")] + private static extern int GetObject(IntPtr hgdiobj, int cbBuffer, IntPtr lpvObject); + + /// + /// Retrieves the bits of the specified compatible bitmap and copies them into a buffer + /// as a DIB using the specified format. + /// + /// Handle to the device context. + /// Handle to the bitmap. This must be a compatible bitmap (DDB). + /// Specifies the first scan line to retrieve. + /// Specifies the number of scan lines to retrieve. + /// Pointer to a buffer to receive the bitmap data. + /// Pointer to a BITMAPINFO structure that specifies the desired + /// format for the DIB data. + /// Specifies the format of the bmiColors member of the + /// BITMAPINFO structure - (use 0). + /// 0 on failure. + [DllImport("gdi32.dll")] + private static extern unsafe int GetDIBits( + IntPtr hdc, + IntPtr hbmp, + uint uStartScan, + uint cScanLines, + IntPtr lpvBits, + IntPtr lpbmi, + uint uUsage); + + /// + /// Moves a block of memory from one location to another. + /// + /// Pointer to the starting address of the move destination. + /// Pointer to the starting address of the block of memory to be moved. + /// Size of the block of memory to move, in bytes. + [DllImport("Kernel32.dll", EntryPoint = "RtlMoveMemory", SetLastError = false)] + public static unsafe extern void MoveMemory(void* dst, void* src, uint size); + + /// + /// The RtlCompareMemory routine compares blocks of memory + /// and returns the number of bytes that are equivalent. + /// + /// A pointer to a block of memory to compare. + /// A pointer to a block of memory to compare. + /// Specifies the number of bytes to be compared. + /// RtlCompareMemory returns the number of bytes that compare as equal. + /// If all bytes compare as equal, the input Length is returned. + [DllImport("ntdll.dll", EntryPoint = "RtlCompareMemory", SetLastError = false)] + internal static unsafe extern uint RtlCompareMemory(void* buf1, void* buf2, uint count); + + #endregion + } +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/ImageManager.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/ImageManager.cs new file mode 100644 index 0000000..83f4be4 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/ImageManager.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; + +namespace FreeImageNETUnitTest +{ + internal enum ImageType : byte + { + Even, + Odd, + JPEG, + Metadata, + Multipaged + } + + internal enum ImageColorType : byte + { + Type_01_Dither, + Type_01_Threshold, + Type_04, + Type_04_Greyscale_MinIsBlack, + Type_04_Greyscale_Unordered, + Type_08, + Type_08_Greyscale_MinIsBlack, + Type_08_Greyscale_Unordered, + Type_16_555, + Type_16_565, + Type_24, + Type_32, + } + + internal class ImageManager + { + public readonly string baseDirectory = null; + + public ImageManager() + : this(new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.Parent.FullName + @"\UnitTestData\Images\") + { + } + + public ImageManager(string baseDirectory) + { + if (!Directory.Exists(baseDirectory)) + throw new DirectoryNotFoundException(); + this.baseDirectory = baseDirectory; + } + + public string GetBitmapPath(ImageType type, ImageColorType colorType) + { + string filename = null; + + switch (type) + { + case ImageType.Even: + switch (colorType) + { + case ImageColorType.Type_01_Dither: + filename = baseDirectory + @"Even\Image_01_dither.tif"; + break; + case ImageColorType.Type_01_Threshold: + filename = baseDirectory + @"Even\Image_01_threshold.tif"; + break; + case ImageColorType.Type_04: + filename = baseDirectory + @"Even\Image_04.tif"; + break; + case ImageColorType.Type_04_Greyscale_MinIsBlack: + filename = baseDirectory + @"Even\Image_04_gs_minisblack.tif"; + break; + case ImageColorType.Type_04_Greyscale_Unordered: + filename = baseDirectory + @"Even\Image_04_gs_unordered.tif"; + break; + case ImageColorType.Type_08: + filename = baseDirectory + @"Even\Image_08.tif"; + break; + case ImageColorType.Type_08_Greyscale_MinIsBlack: + filename = baseDirectory + @"Even\Image_08_gs_minisblack.tif"; + break; + case ImageColorType.Type_08_Greyscale_Unordered: + filename = baseDirectory + @"Even\Image_08_gs_unordered.tif"; + break; + case ImageColorType.Type_16_555: + filename = baseDirectory + @"Even\Image_16_555.bmp"; + break; + case ImageColorType.Type_16_565: + filename = baseDirectory + @"Even\Image_16_565.bmp"; + break; + case ImageColorType.Type_24: + filename = baseDirectory + @"Even\Image_24.tif"; + break; + case ImageColorType.Type_32: + filename = baseDirectory + @"Even\Image_32.tif"; + break; + } + break; + case ImageType.Odd: + switch (colorType) + { + case ImageColorType.Type_01_Dither: + filename = baseDirectory + @"Odd\Image_01_dither.tif"; + break; + case ImageColorType.Type_01_Threshold: + filename = baseDirectory + @"Odd\Image_01_threshold.tif"; + break; + case ImageColorType.Type_04: + filename = baseDirectory + @"Odd\Image_04.tif"; + break; + case ImageColorType.Type_04_Greyscale_MinIsBlack: + filename = baseDirectory + @"Odd\Image_04_gs_minisblack.tif"; + break; + case ImageColorType.Type_04_Greyscale_Unordered: + filename = baseDirectory + @"Odd\Image_04_gs_unordered.tif"; + break; + case ImageColorType.Type_08: + filename = baseDirectory + @"Odd\Image_08.tif"; + break; + case ImageColorType.Type_08_Greyscale_MinIsBlack: + filename = baseDirectory + @"Odd\Image_08_gs_minisblack.tif"; + break; + case ImageColorType.Type_08_Greyscale_Unordered: + filename = baseDirectory + @"Odd\Image_08_gs_unordered.tif"; + break; + case ImageColorType.Type_16_555: + filename = baseDirectory + @"Odd\Image_16_555.bmp"; + break; + case ImageColorType.Type_16_565: + filename = baseDirectory + @"Odd\Image_16_565.bmp"; + break; + case ImageColorType.Type_24: + filename = baseDirectory + @"Odd\Image_24.tif"; + break; + } + break; + case ImageType.JPEG: + filename = baseDirectory + @"JPEG\Image.jpg"; + break; + case ImageType.Metadata: + filename = baseDirectory + @"Metadata\exif.jpg"; + break; + case ImageType.Multipaged: + filename = baseDirectory + @"Multipaged\Image.tif"; + break; + } + return filename; + } + + public FreeImageAPI.FIBITMAP GetBitmap(ImageType type, ImageColorType colorType) + { + FreeImageAPI.FIBITMAP result = new FreeImageAPI.FIBITMAP(); + string filename = GetBitmapPath(type, colorType); + if (!String.IsNullOrEmpty(filename) && File.Exists(filename)) + result = FreeImageAPI.FreeImage.LoadEx(filename); + return result; + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/NUnit.txt b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/NUnit.txt new file mode 100644 index 0000000..ce0d58e --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/NUnit.txt @@ -0,0 +1,14 @@ +NUnit 2.x is needed for FreeImage .NET wrapper unit tests. It can be +downloaded from http://www.nunit.org/ + +After installing NUnit, double click on the NUnit project file +FreeImage.NET.nunit located in the FreeImage .NET wrapper Source folder +to load the project. + +The FreeImage .NET wrapper unit test project UnitTest.csproj, located +under Source\UnitTest, must be compiled in 'Debug' mode prior to opening +the NUnit project. + +The FreeImage .NET wrapper unit test project UnitTest.csproj currently +relies on the FreeImage .NET wrapper single source file, created by the +Source File Merger, located in the Source\SourceFileMerger folder. \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/Properties/AssemblyInfo.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2d0f3fb --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("FreeImageAPI.Properties")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("DataGis")] +[assembly: AssemblyProduct("FreeImageAPI.Properties")] +[assembly: AssemblyCopyright("Copyright © DataGis 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("51678252-9a4b-492d-96c9-37ebe08d1f29")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/UnitTest.2005.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/UnitTest.2005.csproj new file mode 100644 index 0000000..86c5b76 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/UnitTest.2005.csproj @@ -0,0 +1,105 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC} + Exe + Properties + FreeImageAPI + UnitTest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + 659,660,661 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + 659,660,661 + true + false + + + true + bin\Debug\ + DEBUG;TRACE + true + 659,660,661 + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + true + 659,660,661 + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + true + 659,660,661 + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + true + 659,660,661 + + + x64 + false + prompt + + + + False + ..\..\..\..\..\..\..\Programme\NUnit 2.4.8\bin\nunit.framework.dll + + + + + + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/UnitTest.cs b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/UnitTest.cs new file mode 100644 index 0000000..98fad61 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/UnitTest.cs @@ -0,0 +1,5555 @@ +using System; +using System.Drawing; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using System.IO; +using System.Drawing.Imaging; +using System.Net; +using FreeImageNETUnitTest; +using System.Reflection; +using System.Threading; +using System.Runtime.Serialization.Formatters.Binary; +using System.Collections; +using FreeImageAPI; +using FreeImageAPI.IO; +using FreeImageAPI.Metadata; +using FreeImageAPI.Plugins; +using NUnit.Framework; + +namespace FreeImageNETUnitTest +{ + [TestFixture] + public class ImportedFunctionsTest + { + ImageManager iManager = new ImageManager(); + FIBITMAP dib; + string freeImageCallback = null; + + [TestFixtureSetUp] + public void Init() + { + FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message); + } + + [TestFixtureTearDown] + public void DeInit() + { + FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message); + } + + [SetUp] + public void InitEachTime() + { + } + + [TearDown] + public void DeInitEachTime() + { + } + + void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message) + { + freeImageCallback = message; + } + + [Test] + public void FreeImage_GetVersion() + { + string version = FreeImage.GetVersion(); + Assert.IsNotEmpty(version); + } + + [Test] + public void FreeImage_GetCopyrightMessage() + { + string copyright = FreeImage.GetCopyrightMessage(); + Assert.IsNotEmpty(copyright); + } + + [Test] + public void FreeImage_OutputMessageProc_SetOutputMessage() + { + Assert.IsNull(freeImageCallback); + FreeImage.SetOutputMessage(new OutputMessageFunction(FreeImage_Message)); + FreeImage.OutputMessageProc(FREE_IMAGE_FORMAT.FIF_UNKNOWN, "unit test"); + FreeImage.SetOutputMessage(null); + Assert.IsNotNull(freeImageCallback); + freeImageCallback = null; + } + + [Test] + public void FreeImage_Allocate() + { + dib = FreeImage.Allocate( + 133, + 77, + 8, + FreeImage.FI_RGBA_RED_MASK, + FreeImage.FI_RGBA_GREEN_MASK, + FreeImage.FI_RGBA_BLUE_MASK); + + Assert.That(!dib.IsNull); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_AllocateT() + { + dib = FreeImage.AllocateT(FREE_IMAGE_TYPE.FIT_RGBA16, 31, 555, 64, 0, 0, 0); + + Assert.That(!dib.IsNull); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Clone() + { + dib = FreeImage.Allocate(1, 1, 32, 0, 0, 0); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.Clone(dib); + Assert.AreNotEqual(0, temp); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Load() + { + Assert.That(dib.IsNull); + dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, iManager.baseDirectory + @"JPEG\Image.jpg", FREE_IMAGE_LOAD_FLAGS.DEFAULT); + Assert.That(!dib.IsNull); + FreeImage.UnloadEx(ref dib); + Assert.That(dib.IsNull); + } + + [Test] + public void FreeImage_Unload() + { + Assert.That(dib.IsNull); + dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, iManager.baseDirectory + @"JPEG\Image.jpg", FREE_IMAGE_LOAD_FLAGS.DEFAULT); + Assert.IsNotNull(dib); + FreeImage.Unload(dib); + dib.SetNull(); + } + + [Test] + public void FreeImage_LoadFromHandle() + { + byte[] data = File.ReadAllBytes(iManager.GetBitmapPath(ImageType.Even, ImageColorType.Type_16_555)); + MemoryStream mStream = new MemoryStream(data); + FreeImageIO io = FreeImageStreamIO.io; + + using (fi_handle handle = new fi_handle(mStream)) + { + dib = FreeImage.LoadFromHandle(FREE_IMAGE_FORMAT.FIF_BMP, ref io, handle, FREE_IMAGE_LOAD_FLAGS.DEFAULT); + Assert.That(!dib.IsNull); + + FreeImage.UnloadEx(ref dib); + } + } + + [Test] + public void FreeImage_Save() + { + string filename = @"test.bmp"; + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08); + Assert.That(!dib.IsNull); + + Assert.IsTrue(FreeImage.Save(FREE_IMAGE_FORMAT.FIF_BMP, dib, filename, FREE_IMAGE_SAVE_FLAGS.DEFAULT)); + Assert.IsTrue(File.Exists(filename)); + File.Delete(filename); + Assert.IsFalse(File.Exists(filename)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SaveToHandle() + { + FreeImageIO io = new FreeImageIO(); + FreeImage.SaveToHandle(FREE_IMAGE_FORMAT.FIF_BMP, dib, ref io, new fi_handle(), FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + [Test] + public void FreeImage_Memory() + { + dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); + Assert.That(!dib.IsNull); + FIMEMORY mem = FreeImage.OpenMemory(IntPtr.Zero, 0); + Assert.AreNotEqual(0, mem); + FreeImage.SaveToMemory(FREE_IMAGE_FORMAT.FIF_TIFF, dib, mem, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + Assert.AreNotEqual(0, FreeImage.TellMemory(mem)); + Assert.IsTrue(FreeImage.SeekMemory(mem, 0, System.IO.SeekOrigin.Begin)); + + FIBITMAP temp = FreeImage.LoadFromMemory(FREE_IMAGE_FORMAT.FIF_TIFF, mem, FREE_IMAGE_LOAD_FLAGS.DEFAULT); + Assert.AreNotEqual(0, temp); + FreeImage.UnloadEx(ref temp); + + uint size = 0; + byte[] ptr = new byte[1]; + IntPtr buffer = IntPtr.Zero; + Assert.IsTrue(FreeImage.AcquireMemory(mem, ref buffer, ref size)); + Assert.AreNotEqual(IntPtr.Zero, ptr); + Assert.AreNotEqual(0, size); + + Assert.AreEqual(1, FreeImage.WriteMemory(ptr, 1, 1, mem)); + FreeImage.SeekMemory(mem, 1, System.IO.SeekOrigin.Begin); + Assert.AreEqual(1, FreeImage.TellMemory(mem)); + Assert.AreEqual(2, FreeImage.ReadMemory(ptr, 1, 2, mem)); + FreeImage.CloseMemory(mem); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_RegisterLocalPlugin() + { + InitProc proc = null; + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.RegisterLocalPlugin(proc, "", "", "", "")); + } + + [Test] + public void FreeImage_RegisterExternalPlugin() + { + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.RegisterExternalPlugin("", "", "", "", "")); + } + + [Test] + public void FreeImage_GetFIFCount() + { + Assert.AreNotEqual(0, FreeImage.GetFIFCount()); + } + + [Test] + public void FreeImage_SetPluginEnabled_IsPluginEnabled() + { + FreeImage.SetPluginEnabled(FREE_IMAGE_FORMAT.FIF_PNG, false); + Assert.AreEqual(0, FreeImage.IsPluginEnabled(FREE_IMAGE_FORMAT.FIF_PNG)); + FreeImage.SetPluginEnabled(FREE_IMAGE_FORMAT.FIF_PNG, true); + Assert.AreEqual(1, FreeImage.IsPluginEnabled(FREE_IMAGE_FORMAT.FIF_PNG)); + } + + [Test] + public void FreeImage_GetFIFFromFormat() + { + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.GetFIFFromFormat("")); + Assert.AreNotEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.GetFIFFromFormat("TIFF")); + } + + [Test] + public void FreeImage_GetFIFFromMime() + { + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.GetFIFFromMime("")); + Assert.AreNotEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.GetFIFFromMime("image/jpeg")); + } + + [Test] + public void FreeImage_GetFormatFromFIF() + { + Assert.IsNotEmpty(FreeImage.GetFormatFromFIF(FREE_IMAGE_FORMAT.FIF_JNG)); + } + + [Test] + public void FreeImage_GetFIFExtensionList() + { + Assert.IsNotEmpty(FreeImage.GetFIFExtensionList(FREE_IMAGE_FORMAT.FIF_PGM)); + } + + [Test] + public void FreeImage_GetFIFDescription() + { + Assert.IsNotEmpty(FreeImage.GetFIFDescription(FREE_IMAGE_FORMAT.FIF_PBM)); + } + + [Test] + public void FreeImage_GetFIFRegExpr() + { + Assert.IsNotEmpty(FreeImage.GetFIFRegExpr(FREE_IMAGE_FORMAT.FIF_JPEG)); + } + + [Test] + public void FreeImage_GetFIFMimeType() + { + Assert.IsNotEmpty(FreeImage.GetFIFMimeType(FREE_IMAGE_FORMAT.FIF_ICO)); + } + + [Test] + public void FreeImage_GetFIFFromFilename() + { + Assert.AreNotEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.GetFIFFromFilename("test.bmp")); + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.GetFIFFromFilename("test.000")); + } + + [Test] + public void FreeImage_FIFSupportsReading() + { + Assert.IsTrue(FreeImage.FIFSupportsReading(FREE_IMAGE_FORMAT.FIF_TIFF)); + } + + [Test] + public void FreeImage_FIFSupportsWriting() + { + Assert.IsTrue(FreeImage.FIFSupportsWriting(FREE_IMAGE_FORMAT.FIF_GIF)); + } + + [Test] + public void FreeImage_FIFSupportsExportBPP() + { + Assert.IsTrue(FreeImage.FIFSupportsExportBPP(FREE_IMAGE_FORMAT.FIF_BMP, 32)); + Assert.IsFalse(FreeImage.FIFSupportsExportBPP(FREE_IMAGE_FORMAT.FIF_GIF, 32)); + } + + [Test] + public void FreeImage_FIFSupportsExportType() + { + Assert.IsTrue(FreeImage.FIFSupportsExportType(FREE_IMAGE_FORMAT.FIF_BMP, FREE_IMAGE_TYPE.FIT_BITMAP)); + Assert.IsFalse(FreeImage.FIFSupportsExportType(FREE_IMAGE_FORMAT.FIF_BMP, FREE_IMAGE_TYPE.FIT_COMPLEX)); + } + + [Test] + public void FreeImage_FIFSupportsICCProfiles() + { + Assert.IsTrue(FreeImage.FIFSupportsICCProfiles(FREE_IMAGE_FORMAT.FIF_JPEG)); + Assert.IsFalse(FreeImage.FIFSupportsICCProfiles(FREE_IMAGE_FORMAT.FIF_BMP)); + } + + [Test] + public void FreeImage_MultiBitmap() + { + FIBITMAP temp; + FIMULTIBITMAP mdib = FreeImage.OpenMultiBitmap( + FREE_IMAGE_FORMAT.FIF_TIFF, + @"test.tif", + true, + false, + true, + FREE_IMAGE_LOAD_FLAGS.DEFAULT); + Assert.AreNotEqual(0, mdib); + Assert.AreEqual(0, FreeImage.GetPageCount(mdib)); + dib = FreeImage.Allocate(10, 10, 8, 0, 0, 0); + FreeImage.AppendPage(mdib, dib); + Assert.AreEqual(1, FreeImage.GetPageCount(mdib)); + FreeImage.AppendPage(mdib, dib); + Assert.AreEqual(2, FreeImage.GetPageCount(mdib)); + FreeImage.AppendPage(mdib, dib); + Assert.AreEqual(3, FreeImage.GetPageCount(mdib)); + FreeImage.CloseMultiBitmapEx(ref mdib); + FreeImage.UnloadEx(ref dib); + mdib.SetNull(); + mdib = FreeImage.OpenMultiBitmap(FREE_IMAGE_FORMAT.FIF_TIFF, @"test.tif", false, false, true, FREE_IMAGE_LOAD_FLAGS.DEFAULT); + Assert.AreNotEqual(0, mdib); + Assert.AreEqual(3, FreeImage.GetPageCount(mdib)); + dib = FreeImage.LockPage(mdib, 1); + temp = FreeImage.LockPage(mdib, 2); + + int[] pages = null; + int count = 0; + FreeImage.GetLockedPageNumbers(mdib, pages, ref count); + Assert.AreEqual(2, count); + pages = new int[count]; + FreeImage.GetLockedPageNumbers(mdib, pages, ref count); + Assert.AreEqual(2, pages.Length); + FreeImage.UnlockPage(mdib, dib, false); + FreeImage.UnlockPage(mdib, temp, true); + dib.SetNull(); + Assert.IsTrue(FreeImage.MovePage(mdib, 0, 1)); + FreeImage.CloseMultiBitmapEx(ref mdib); + Assert.IsTrue(System.IO.File.Exists("test.tif")); + System.IO.File.Delete("test.tif"); + } + + [Test] + public void FreeImage_GetFileType() + { + Assert.AreNotEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.GetFileType(iManager.GetBitmapPath(ImageType.Even, ImageColorType.Type_08_Greyscale_Unordered), 0)); + } + + [Test] + public void FreeImage_GetFileTypeFromHandle() + { + FreeImageIO io = FreeImageStreamIO.io; + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.GetFileTypeFromHandle(ref io, new fi_handle(), 0)); + } + + [Test] + public void FreeImage_GetFileTypeFromMemory() + { + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_UNKNOWN, FreeImage.GetFileTypeFromMemory(new FIMEMORY(), 0)); + } + + [Test] + public void FreeImage_IsLittleEndian() + { + Assert.IsTrue(FreeImage.IsLittleEndian()); + } + + [Test] + public void FreeImage_LookupX11Color() + { + byte red, green, blue; + FreeImage.LookupX11Color("lawngreen", out red, out green, out blue); + Assert.AreEqual(124, red); + Assert.AreEqual(252, green); + Assert.AreEqual(0, blue); + } + + [Test] + public void FreeImage_LookupSVGColor() + { + byte red, green, blue; + FreeImage.LookupX11Color("orchid", out red, out green, out blue); + Assert.AreEqual(218, red); + Assert.AreEqual(112, green); + Assert.AreEqual(214, blue); + } + + [Test] + public void FreeImage_GetBits() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_01_Threshold); + Assert.That(!dib.IsNull); + Assert.AreNotEqual(IntPtr.Zero, FreeImage.GetBits(dib)); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetScanLine() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_04_Greyscale_MinIsBlack); + Assert.That(!dib.IsNull); + Assert.AreNotEqual(IntPtr.Zero, FreeImage.GetScanLine(dib, 0)); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetPixelIndex_SetPixelIndex() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_04_Greyscale_Unordered); + Assert.That(!dib.IsNull); + byte index_old, index_new; + Assert.IsTrue(FreeImage.GetPixelIndex(dib, 31, 10, out index_old)); + index_new = index_old == byte.MaxValue ? (byte)0 : (byte)(index_old + 1); + Assert.IsTrue(FreeImage.SetPixelIndex(dib, 31, 10, ref index_new)); + Assert.IsTrue(FreeImage.GetPixelIndex(dib, 31, 10, out index_old)); + Assert.AreEqual(index_new, index_old); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetPixelColor_SetPixelColor() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + RGBQUAD value_old, value_new; + Assert.IsTrue(FreeImage.GetPixelColor(dib, 77, 61, out value_old)); + value_new = (value_old == (RGBQUAD)Color.White) ? Color.Black : Color.White; + Assert.IsTrue(FreeImage.SetPixelColor(dib, 77, 61, ref value_new)); + Assert.IsTrue(FreeImage.GetPixelColor(dib, 77, 61, out value_old)); + Assert.AreEqual(value_new, value_old); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Bitmap_information_functions() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_08_Greyscale_MinIsBlack); + Assert.That(!dib.IsNull); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_BITMAP, FreeImage.GetImageType(dib)); + Assert.AreNotEqual(0, FreeImage.GetColorsUsed(dib)); + Assert.AreEqual(8, FreeImage.GetBPP(dib)); + Assert.AreNotEqual(0, FreeImage.GetWidth(dib)); + Assert.AreNotEqual(0, FreeImage.GetHeight(dib)); + Assert.AreNotEqual(0, FreeImage.GetLine(dib)); + Assert.AreNotEqual(0, FreeImage.GetPitch(dib)); + Assert.AreNotEqual(0, FreeImage.GetDIBSize(dib)); + Assert.AreNotEqual(IntPtr.Zero, FreeImage.GetPalette(dib)); + FreeImage.SetDotsPerMeterX(dib, 1234); + FreeImage.SetDotsPerMeterY(dib, 4321); + Assert.AreEqual(1234, FreeImage.GetDotsPerMeterX(dib)); + Assert.AreEqual(4321, FreeImage.GetDotsPerMeterY(dib)); + Assert.AreNotEqual(IntPtr.Zero, FreeImage.GetInfoHeader(dib)); + Assert.AreNotEqual(IntPtr.Zero, FreeImage.GetInfo(dib)); + Assert.AreEqual(FREE_IMAGE_COLOR_TYPE.FIC_MINISBLACK, FreeImage.GetColorType(dib)); + Assert.AreEqual(0, FreeImage.GetRedMask(dib)); + Assert.AreEqual(0, FreeImage.GetGreenMask(dib)); + Assert.AreEqual(0, FreeImage.GetBlueMask(dib)); + Assert.AreEqual(0, FreeImage.GetTransparencyCount(dib)); + Assert.AreNotEqual(IntPtr.Zero, FreeImage.GetTransparencyTable(dib)); + FreeImage.SetTransparent(dib, false); + FreeImage.SetTransparencyTable(dib, new byte[] { }); + Assert.IsTrue(FreeImage.IsTransparent(dib)); + Assert.IsFalse(FreeImage.HasBackgroundColor(dib)); + RGBQUAD rgb = Color.Teal; + Assert.IsTrue(FreeImage.SetBackgroundColor(dib, ref rgb)); + Assert.IsTrue(FreeImage.GetBackgroundColor(dib, out rgb)); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetICCProfile() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + new FIICCPROFILE(dib, new byte[] { 0xFF, 0xAA, 0x00, 0x33 }); + FIICCPROFILE p = FreeImage.GetICCProfileEx(dib); + Assert.AreEqual(4, p.Size); + Assert.AreEqual(0xAA, p.Data[1]); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_CreateICCProfile() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + byte[] data = new byte[256]; + Assert.AreNotEqual(IntPtr.Zero, FreeImage.CreateICCProfile(dib, data, 256)); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_DestroyICCProfile() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + FreeImage.DestroyICCProfile(dib); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertTo4Bits() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ConvertTo4Bits(dib); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(4, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertTo8Bits() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ConvertTo8Bits(dib); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(8, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertToGreyscale() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ConvertToGreyscale(dib); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(8, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertTo16Bits555() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ConvertTo16Bits555(dib); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(16, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertTo16Bits565() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ConvertTo16Bits565(dib); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(16, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertTo24Bits() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ConvertTo24Bits(dib); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(24, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertTo32Bits() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ConvertTo32Bits(dib); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(32, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ColorQuantize() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ColorQuantize(dib, FREE_IMAGE_QUANTIZE.FIQ_WUQUANT); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(8, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ColorQuantizeEx() + { + FIBITMAP paletteDib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08); + Assert.IsFalse(paletteDib.IsNull); + Palette palette = FreeImage.GetPaletteEx(paletteDib); + RGBQUAD[] table = palette.Data; + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.ColorQuantizeEx(dib, FREE_IMAGE_QUANTIZE.FIQ_WUQUANT, (int)palette.Length, (int)palette.Length, table); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(8, FreeImage.GetBPP(temp)); + + FreeImage.UnloadEx(ref paletteDib); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Threshold() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.Threshold(dib, 128); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(1, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Dither() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.Dither(dib, FREE_IMAGE_DITHER.FID_FS); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(1, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_RawBits() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + IntPtr buffer = Marshal.AllocHGlobal((int)FreeImage.GetDIBSize(dib)); + FreeImage.ConvertToRawBits( + buffer, + dib, + (int)FreeImage.GetPitch(dib), + FreeImage.GetBPP(dib), + FreeImage.GetRedMask(dib), + FreeImage.GetGreenMask(dib), + FreeImage.GetBlueMask(dib), + true); + FIBITMAP temp = FreeImage.ConvertFromRawBits( + buffer, + (int)FreeImage.GetWidth(dib), + (int)FreeImage.GetHeight(dib), + (int)FreeImage.GetPitch(dib), + FreeImage.GetBPP(dib), + FreeImage.GetRedMask(dib), + FreeImage.GetGreenMask(dib), + FreeImage.GetBlueMask(dib), + true); + + Assert.AreNotEqual(0, temp); + + Marshal.FreeHGlobal(buffer); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertToRGBF() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ConvertToRGBF(dib); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_RGBF, FreeImage.GetImageType(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertToStandardType() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_04_Greyscale_MinIsBlack); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ConvertToStandardType(dib, true); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(FREE_IMAGE_COLOR_TYPE.FIC_PALETTE, FreeImage.GetColorType(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertToType() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08_Greyscale_Unordered); + Assert.That(!dib.IsNull); + FIBITMAP temp = FreeImage.ConvertToType(dib, FREE_IMAGE_TYPE.FIT_UINT32, true); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_UINT32, FreeImage.GetImageType(temp)); + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ToneMapping() + { + FIBITMAP temp; + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + FIBITMAP rgbf = FreeImage.ConvertToRGBF(dib); + Assert.AreNotEqual(0, rgbf); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_RGBF, FreeImage.GetImageType(rgbf)); + Assert.AreEqual(96, FreeImage.GetBPP(rgbf)); + + temp = FreeImage.ToneMapping(rgbf, FREE_IMAGE_TMO.FITMO_REINHARD05, 1f, 1.1f); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(24, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + + FreeImage.UnloadEx(ref rgbf); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_TmoDrago03() + { + FIBITMAP temp; + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + FIBITMAP rgbf = FreeImage.ConvertToRGBF(dib); + Assert.AreNotEqual(0, rgbf); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_RGBF, FreeImage.GetImageType(rgbf)); + Assert.AreEqual(96, FreeImage.GetBPP(rgbf)); + + temp = FreeImage.TmoDrago03(rgbf, 1f, 1.2f); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(24, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + + FreeImage.UnloadEx(ref rgbf); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_TmoReinhard05() + { + FIBITMAP temp; + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + FIBITMAP rgbf = FreeImage.ConvertToRGBF(dib); + Assert.AreNotEqual(0, rgbf); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_RGBF, FreeImage.GetImageType(rgbf)); + Assert.AreEqual(96, FreeImage.GetBPP(rgbf)); + + temp = FreeImage.TmoReinhard05(rgbf, 0f, 0.25f); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(24, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + + FreeImage.UnloadEx(ref rgbf); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_TmoFattal02() + { + FIBITMAP temp; + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + FIBITMAP rgbf = FreeImage.ConvertToRGBF(dib); + Assert.AreNotEqual(0, rgbf); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_RGBF, FreeImage.GetImageType(rgbf)); + Assert.AreEqual(96, FreeImage.GetBPP(rgbf)); + + temp = FreeImage.TmoFattal02(rgbf, 1f, 0.79f); + Assert.AreNotEqual(0, temp); + Assert.AreEqual(24, FreeImage.GetBPP(temp)); + FreeImage.UnloadEx(ref temp); + + FreeImage.UnloadEx(ref rgbf); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ZLibCompress_ZLibUncompress() + { + Random rand = new Random(DateTime.Now.Millisecond); + byte[] source = new byte[10240]; + byte[] compressed = new byte[(int)(10355f * 1.01 + 12f)]; + byte[] uncompressed = new byte[10240]; + rand.NextBytes(source); + Assert.AreNotEqual(0, FreeImage.ZLibCompress(compressed, (uint)compressed.Length, source, (uint)source.Length)); + Assert.AreNotEqual(0, FreeImage.ZLibUncompress(uncompressed, (uint)source.Length, compressed, (uint)compressed.Length)); + for (int i = 0; i < source.Length; i++) + if (source[i] != uncompressed[i]) + Assert.Fail(); + } + + [Test] + public void FreeImage_ZLibGZip_ZLibGUnzip() + { + Random rand = new Random(DateTime.Now.Millisecond); + byte[] source = new byte[10240]; + byte[] compressed = new byte[(int)(10355f * 1.01 + 24f)]; + byte[] uncompressed = new byte[10240]; + rand.NextBytes(source); + Assert.AreNotEqual(0, FreeImage.ZLibGZip(compressed, (uint)compressed.Length, source, (uint)source.Length)); + Assert.AreNotEqual(0, FreeImage.ZLibGUnzip(uncompressed, (uint)source.Length, compressed, (uint)compressed.Length)); + for (int i = 0; i < source.Length; i++) + if (source[i] != uncompressed[i]) + Assert.Fail(); + } + + [Test] + public void FreeImage_ZLibCRC32() + { + byte[] buffer = new byte[0]; + Assert.AreEqual(0xFEBCA008, FreeImage.ZLibCRC32(0xFEBCA008, buffer, 0)); + } + + [Test] + public void FreeImage_CreateTag() + { + FITAG tag = FreeImage.CreateTag(); + Assert.AreNotEqual(0, tag); + FITAG tag_clone = FreeImage.CloneTag(tag); + Assert.AreNotEqual(0, tag_clone); + FreeImage.DeleteTag(tag); + FreeImage.DeleteTag(tag_clone); + } + + [Test] + public void FreeImage_Tag_accessors() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + Assert.IsTrue(FreeImage.FindNextMetadata(mData, out tag)); + Assert.AreNotEqual(0, tag); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetTagKey() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.GetTagKey(tag); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetTagDescription() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.GetTagDescription(tag); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetTagID() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.GetTagID(tag); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetTagType() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.GetTagType(tag); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetTagCount() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.GetTagCount(tag); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetTagLength() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.GetTagLength(tag); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetTagValue() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.GetTagValue(tag); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetTagKey() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.SetTagKey(tag, ""); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetTagDescription() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.SetTagDescription(tag, ""); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetTagID() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.SetTagID(tag, 44); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetTagType() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.SetTagType(tag, FREE_IMAGE_MDTYPE.FIDT_ASCII); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetTagCount() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.SetTagCount(tag, 3); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetTagLength() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + FreeImage.SetTagLength(tag, 6); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetTagValue() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + int length = (int)FreeImage.GetTagLength(tag); + FREE_IMAGE_MDTYPE type = FreeImage.GetTagType(tag); + int count = (int)FreeImage.GetTagCount(tag); + + byte[] buffer = new byte[length * count]; + + FreeImage.SetTagValue(tag, buffer); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetMetadataCount() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + Assert.AreNotEqual(0, FreeImage.GetMetadataCount(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib)); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_TagToString() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + + FITAG tag; + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, dib, out tag); + Assert.AreNotEqual(0, mData); + Assert.AreNotEqual(0, tag); + + Assert.IsNotEmpty(FreeImage.TagToString(FREE_IMAGE_MDMODEL.FIMD_EXIF_EXIF, tag, 0)); + + FreeImage.FindCloseMetadata(mData); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_RotateClassic() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.RotateClassic(dib, 45d); + Assert.AreNotEqual(0, temp); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_RotateEx() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.RotateEx(dib, 261d, 0d, 33d, 51d, 9d, true); + Assert.AreNotEqual(0, temp); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_FlipHorizontal() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + Assert.IsTrue(FreeImage.FlipHorizontal(dib)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_FlipVertical() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + Assert.IsTrue(FreeImage.FlipVertical(dib)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_JPEGTransform() + { + string filename = iManager.GetBitmapPath(ImageType.JPEG, ImageColorType.Type_24); + string filenameOut = filename + ".out.jpg"; + Assert.IsTrue(File.Exists(filename)); + + Assert.IsTrue(FreeImage.JPEGTransform(filename, filenameOut, FREE_IMAGE_JPEG_OPERATION.FIJPEG_OP_FLIP_V, false)); + Assert.IsTrue(File.Exists(filenameOut)); + + FIBITMAP temp = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, filenameOut, FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE); + Assert.AreNotEqual(0, temp); + + File.Delete(filenameOut); + Assert.IsFalse(File.Exists(filenameOut)); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Rescale() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_16_555); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.Rescale(dib, 100, 100, FREE_IMAGE_FILTER.FILTER_BICUBIC); + Assert.AreNotEqual(0, temp); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_MakeThumbnail() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_16_555); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.MakeThumbnail(dib, 50, false); + Assert.AreNotEqual(0, temp); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_AdjustCurve() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + byte[] lut = new byte[256]; + Assert.IsTrue(FreeImage.AdjustCurve(dib, lut, FREE_IMAGE_COLOR_CHANNEL.FICC_GREEN)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_AdjustGamma() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + Assert.IsTrue(FreeImage.AdjustGamma(dib, 1.3d)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_AdjustBrightness() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + Assert.IsTrue(FreeImage.AdjustBrightness(dib, 1.3d)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_AdjustContrast() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + Assert.IsTrue(FreeImage.AdjustContrast(dib, 1.3d)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Invert() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_16_555); + Assert.That(!dib.IsNull); + + Assert.IsTrue(FreeImage.Invert(dib)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetHistogram() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + int[] histo = new int[256]; + Assert.IsTrue(FreeImage.GetHistogram(dib, histo, FREE_IMAGE_COLOR_CHANNEL.FICC_RED)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetChannel() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.GetChannel(dib, FREE_IMAGE_COLOR_CHANNEL.FICC_GREEN); + Assert.AreNotEqual(0, temp); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetChannel() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + FIBITMAP dib8 = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08_Greyscale_MinIsBlack); + Assert.AreNotEqual(0, dib8); + Assert.AreEqual(FreeImage.GetWidth(dib), FreeImage.GetWidth(dib8)); + Assert.AreEqual(FreeImage.GetHeight(dib), FreeImage.GetHeight(dib8)); + + Assert.IsTrue(FreeImage.SetChannel(dib, dib8, FREE_IMAGE_COLOR_CHANNEL.FICC_BLUE)); + + FreeImage.UnloadEx(ref dib8); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetComplexChannel() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.ConvertToType(dib, FREE_IMAGE_TYPE.FIT_COMPLEX, true); + Assert.AreNotEqual(0, temp); + + FIBITMAP temp2 = FreeImage.GetComplexChannel(temp, FREE_IMAGE_COLOR_CHANNEL.FICC_IMAG); + Assert.AreNotEqual(0, temp2); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref temp2); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetComplexChannel() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08_Greyscale_Unordered); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.ConvertToType(dib, FREE_IMAGE_TYPE.FIT_COMPLEX, true); + Assert.AreNotEqual(0, temp); + + FIBITMAP temp2 = FreeImage.GetComplexChannel(temp, FREE_IMAGE_COLOR_CHANNEL.FICC_IMAG); + Assert.AreNotEqual(0, temp2); + + Assert.IsTrue(FreeImage.SetComplexChannel(temp, temp2, FREE_IMAGE_COLOR_CHANNEL.FICC_IMAG)); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref temp2); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Copy() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08_Greyscale_MinIsBlack); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.Copy(dib, 5, 9, 44, 2); + Assert.AreNotEqual(0, temp); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Paste() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08_Greyscale_MinIsBlack); + Assert.That(!dib.IsNull); + + FIBITMAP temp = FreeImage.Allocate(3, 3, 8, 0, 0, 0); + Assert.IsTrue(FreeImage.Paste(dib, temp, 31, 3, 256)); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Composite() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08_Greyscale_MinIsBlack); + Assert.That(!dib.IsNull); + RGBQUAD rgbq = new RGBQUAD(); + + FIBITMAP temp = FreeImage.Composite(dib, false, ref rgbq, new FIBITMAP()); + Assert.AreNotEqual(0, temp); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_JPEGCrop() + { + string filename = iManager.GetBitmapPath(ImageType.JPEG, ImageColorType.Type_01_Dither); + Assert.IsTrue(File.Exists(filename)); + string filenameOut = filename + ".out.jpg"; + + Assert.IsTrue(FreeImage.JPEGCrop(filename, filenameOut, 3, 2, 1, 5)); + Assert.IsTrue(File.Exists(filenameOut)); + + FIBITMAP temp = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, filenameOut, FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE); + Assert.AreNotEqual(0, temp); + + File.Delete(filenameOut); + Assert.IsFalse(File.Exists(filenameOut)); + + FreeImage.UnloadEx(ref temp); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_PreMultiplyWithAlpha() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.IsFalse(dib.IsNull); + + Assert.IsTrue(FreeImage.PreMultiplyWithAlpha(dib)); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_MultigridPoissonSolver() + { + dib = FreeImage.AllocateT(FREE_IMAGE_TYPE.FIT_FLOAT, 10, 10, 32, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + FIBITMAP dib2 = FreeImage.MultigridPoissonSolver(dib, 2); + + FreeImage.UnloadEx(ref dib); + FreeImage.UnloadEx(ref dib2); + } + + [Test] + public void FreeImage_GetAdjustColorsLookupTable() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.IsFalse(dib.IsNull); + + byte[] lut = new byte[256]; + FreeImage.GetAdjustColorsLookupTable(lut, 55d, 0d, 2.1d, false); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_AdjustColors() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.IsFalse(dib.IsNull); + + Assert.IsTrue(FreeImage.AdjustColors(dib, -4d, 22d, 1.1d, false)); + + FreeImage.UnloadEx(ref dib); + } + + [Ignore] + public void FreeImage_ApplyColorMapping() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + FreeImage_ApplyColorMapping2(dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + FreeImage_ApplyColorMapping2(dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + FreeImage_ApplyColorMapping2(dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + FreeImage_ApplyColorMapping2(dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + FreeImage_ApplyColorMapping2(dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + FreeImage_ApplyColorMapping2(dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + FreeImage_ApplyColorMapping2(dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + FreeImage_ApplyColorMapping2(dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + FreeImage_ApplyColorMapping2(dib); + } + + private void FreeImage_ApplyColorMapping2(FIBITMAP dib) + { + Assert.IsFalse(dib.IsNull); + + Scanline rgbqa = new Scanline(dib, 0); + + RGBQUAD[] src = new RGBQUAD[1]; + RGBQUAD[] dst = new RGBQUAD[1]; + src[0] = rgbqa[0]; + dst[0].Color = src[0].Color == Color.White ? Color.Thistle : Color.White; + + uint count = FreeImage.ApplyColorMapping(dib, src, dst, 1, true, false); // Memory + Assert.That(count > 0); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SwapColors() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_08); + Assert.IsFalse(dib.IsNull); + + RGBQUAD src = new RGBQUAD(Color.FromArgb(93, 119, 170)); + RGBQUAD dst = new RGBQUAD(Color.FromArgb(90, 130, 148)); + + uint count = FreeImage.SwapColors(dib, ref src, ref dst, true); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ApplyPaletteIndexMapping() + { + // alle farbtiefen + + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_04); + Assert.IsFalse(dib.IsNull); + + byte[] src = { 0, 3, 1 }; + byte[] dst = { 3, 1, 0 }; + + uint count = FreeImage.ApplyPaletteIndexMapping(dib, src, dst, 3, false); + Assert.That(count > 0); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SwapPaletteIndices() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_04); + Assert.IsFalse(dib.IsNull); + + byte src = 0; + byte dst = 3; + + uint count = FreeImage.SwapPaletteIndices(dib, ref src, ref dst); + Assert.That(count > 0); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetTransparentIndex() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_04); + Assert.IsFalse(dib.IsNull); + + FreeImage.SetTransparentIndex(dib, 0); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetTransparentIndex() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_04); + Assert.IsFalse(dib.IsNull); + + int i = FreeImage.GetTransparentIndex(dib); + + FreeImage.UnloadEx(ref dib); + } + } + + [TestFixture] + public class ImportedStructsTest + { + ImageManager iManager = new ImageManager(); + FIBITMAP dib = new FIBITMAP(); + string freeImageCallback = null; + + [TestFixtureSetUp] + public void Init() + { + FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message); + } + + [TestFixtureTearDown] + public void DeInit() + { + FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message); + } + + [SetUp] + public void InitEachTime() + { + } + + [TearDown] + public void DeInitEachTime() + { + } + + void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message) + { + freeImageCallback = message; + } + + public bool EqualColors(Color color1, Color color2) + { + if (color1.A != color2.A) return false; + if (color1.R != color2.R) return false; + if (color1.G != color2.G) return false; + if (color1.B != color2.B) return false; + return true; + } + + [Test] + public void RGBQUAD() + { + RGBQUAD rgbq = new RGBQUAD(); + Assert.AreEqual(0, rgbq.rgbBlue); + Assert.AreEqual(0, rgbq.rgbGreen); + Assert.AreEqual(0, rgbq.rgbRed); + Assert.AreEqual(0, rgbq.rgbReserved); + + rgbq = new RGBQUAD(Color.Chartreuse); + Assert.That(EqualColors(Color.Chartreuse, rgbq.Color)); + + rgbq = new RGBQUAD(Color.FromArgb(133, 83, 95, 173)); + Assert.AreEqual(173, rgbq.rgbBlue); + Assert.AreEqual(95, rgbq.rgbGreen); + Assert.AreEqual(83, rgbq.rgbRed); + Assert.AreEqual(133, rgbq.rgbReserved); + + rgbq.Color = Color.Crimson; + Assert.That(EqualColors(Color.Crimson, rgbq.Color)); + + rgbq.Color = Color.MidnightBlue; + Assert.That(EqualColors(Color.MidnightBlue, rgbq.Color)); + + rgbq.Color = Color.White; + Assert.AreEqual(255, rgbq.rgbBlue); + Assert.AreEqual(255, rgbq.rgbGreen); + Assert.AreEqual(255, rgbq.rgbRed); + Assert.AreEqual(255, rgbq.rgbReserved); + + rgbq.Color = Color.Black; + Assert.AreEqual(0, rgbq.rgbBlue); + Assert.AreEqual(0, rgbq.rgbGreen); + Assert.AreEqual(0, rgbq.rgbRed); + Assert.AreEqual(255, rgbq.rgbReserved); + + rgbq = Color.DarkGoldenrod; + Color color = rgbq; + Assert.That(EqualColors(Color.DarkGoldenrod, color)); + } + + [Test] + public void RGBTRIPLE() + { + RGBTRIPLE rgbt = new RGBTRIPLE(); + Assert.AreEqual(0, rgbt.rgbtBlue); + Assert.AreEqual(0, rgbt.rgbtGreen); + Assert.AreEqual(0, rgbt.rgbtRed); + + rgbt = new RGBTRIPLE(Color.Chartreuse); + Assert.That(EqualColors(Color.Chartreuse, rgbt.Color)); + + rgbt = new RGBTRIPLE(Color.FromArgb(133, 83, 95, 173)); + Assert.AreEqual(173, rgbt.rgbtBlue); + Assert.AreEqual(95, rgbt.rgbtGreen); + Assert.AreEqual(83, rgbt.rgbtRed); + + rgbt.Color = Color.Crimson; + Assert.That(EqualColors(Color.Crimson, rgbt.Color)); + + rgbt.Color = Color.MidnightBlue; + Assert.That(EqualColors(Color.MidnightBlue, rgbt.Color)); + + rgbt.Color = Color.White; + Assert.AreEqual(255, rgbt.rgbtBlue); + Assert.AreEqual(255, rgbt.rgbtGreen); + Assert.AreEqual(255, rgbt.rgbtRed); + + rgbt.Color = Color.Black; + Assert.AreEqual(0, rgbt.rgbtBlue); + Assert.AreEqual(0, rgbt.rgbtGreen); + Assert.AreEqual(0, rgbt.rgbtRed); + + rgbt = Color.DarkGoldenrod; + Color color = rgbt; + Assert.That(EqualColors(Color.DarkGoldenrod, color)); + } + + [Test] + public void FIRGB16() + { + FIRGB16 rgb = new FIRGB16(); + Assert.AreEqual(0 * 256, rgb.blue); + Assert.AreEqual(0 * 256, rgb.green); + Assert.AreEqual(0 * 256, rgb.red); + + rgb = new FIRGB16(Color.Chartreuse); + Assert.That(EqualColors(Color.Chartreuse, rgb.Color)); + + rgb = new FIRGB16(Color.FromArgb(133, 83, 95, 173)); + Assert.AreEqual(173 * 256, rgb.blue); + Assert.AreEqual(95 * 256, rgb.green); + Assert.AreEqual(83 * 256, rgb.red); + + rgb.Color = Color.Crimson; + Assert.That(EqualColors(Color.Crimson, rgb.Color)); + + rgb.Color = Color.MidnightBlue; + Assert.That(EqualColors(Color.MidnightBlue, rgb.Color)); + + rgb.Color = Color.White; + Assert.AreEqual(255 * 256, rgb.blue); + Assert.AreEqual(255 * 256, rgb.green); + Assert.AreEqual(255 * 256, rgb.red); + + rgb.Color = Color.Black; + Assert.AreEqual(0 * 256, rgb.blue); + Assert.AreEqual(0 * 256, rgb.green); + Assert.AreEqual(0 * 256, rgb.red); + + rgb = Color.DarkGoldenrod; + Color color = rgb; + Assert.That(EqualColors(Color.DarkGoldenrod, color)); + } + + [Test] + public void FIRGBA16() + { + FIRGBA16 rgb = new FIRGBA16(); + Assert.AreEqual(0 * 256, rgb.blue); + Assert.AreEqual(0 * 256, rgb.green); + Assert.AreEqual(0 * 256, rgb.red); + Assert.AreEqual(0 * 256, rgb.alpha); + + rgb = new FIRGBA16(Color.Chartreuse); + Assert.That(EqualColors(Color.Chartreuse, rgb.Color)); + + rgb = new FIRGBA16(Color.FromArgb(133, 83, 95, 173)); + Assert.AreEqual(173 * 256, rgb.blue); + Assert.AreEqual(95 * 256, rgb.green); + Assert.AreEqual(83 * 256, rgb.red); + Assert.AreEqual(133 * 256, rgb.alpha); + + rgb.Color = Color.Crimson; + Assert.That(EqualColors(Color.Crimson, rgb.Color)); + + rgb.Color = Color.MidnightBlue; + Assert.That(EqualColors(Color.MidnightBlue, rgb.Color)); + + rgb.Color = Color.White; + Assert.AreEqual(255 * 256, rgb.blue); + Assert.AreEqual(255 * 256, rgb.green); + Assert.AreEqual(255 * 256, rgb.red); + Assert.AreEqual(255 * 256, rgb.alpha); + + rgb.Color = Color.Black; + Assert.AreEqual(0 * 256, rgb.blue); + Assert.AreEqual(0 * 256, rgb.green); + Assert.AreEqual(0 * 256, rgb.red); + Assert.AreEqual(255 * 256, rgb.alpha); + + rgb = Color.DarkGoldenrod; + Color color = rgb; + Assert.That(EqualColors(Color.DarkGoldenrod, color)); + } + + [Test] + public void FIRGBF() + { + FIRGBF rgb = new FIRGBF(); + Assert.AreEqual(0 / 255f, rgb.blue); + Assert.AreEqual(0 / 255f, rgb.green); + Assert.AreEqual(0 / 255f, rgb.red); + + rgb = new FIRGBF(Color.Chartreuse); + Assert.That(EqualColors(Color.Chartreuse, rgb.Color)); + + rgb = new FIRGBF(Color.FromArgb(133, 83, 95, 173)); + Assert.AreEqual(173 / 255f, rgb.blue); + Assert.AreEqual(95 / 255f, rgb.green); + Assert.AreEqual(83 / 255f, rgb.red); + + rgb.Color = Color.Crimson; + Assert.That(EqualColors(Color.Crimson, rgb.Color)); + + rgb.Color = Color.MidnightBlue; + Assert.That(EqualColors(Color.MidnightBlue, rgb.Color)); + + rgb.Color = Color.White; + Assert.AreEqual(255 / 255f, rgb.blue); + Assert.AreEqual(255 / 255f, rgb.green); + Assert.AreEqual(255 / 255f, rgb.red); + + rgb.Color = Color.Black; + Assert.AreEqual(0 / 255f, rgb.blue); + Assert.AreEqual(0 / 255f, rgb.green); + Assert.AreEqual(0 / 255f, rgb.red); + + rgb = Color.DarkGoldenrod; + Color color = rgb; + Assert.That(EqualColors(Color.DarkGoldenrod, color)); + } + + [Test] + public void FIRGBAF() + { + FIRGBAF rgb = new FIRGBAF(); + Assert.AreEqual(0 / 255f, rgb.blue); + Assert.AreEqual(0 / 255f, rgb.green); + Assert.AreEqual(0 / 255f, rgb.red); + Assert.AreEqual(0 / 255f, rgb.alpha); + + rgb = new FIRGBAF(Color.Chartreuse); + Assert.That(EqualColors(Color.Chartreuse, rgb.Color)); + + rgb = new FIRGBAF(Color.FromArgb(133, 83, 95, 173)); + Assert.AreEqual(173 / 255f, rgb.blue); + Assert.AreEqual(95 / 255f, rgb.green); + Assert.AreEqual(83 / 255f, rgb.red); + Assert.AreEqual(133 / 255f, rgb.alpha); + + rgb.Color = Color.Crimson; + Assert.That(EqualColors(Color.Crimson, rgb.Color)); + + rgb.Color = Color.MidnightBlue; + Assert.That(EqualColors(Color.MidnightBlue, rgb.Color)); + + rgb.Color = Color.White; + Assert.AreEqual(255 / 255f, rgb.blue); + Assert.AreEqual(255 / 255f, rgb.green); + Assert.AreEqual(255 / 255f, rgb.red); + Assert.AreEqual(255 / 255f, rgb.alpha); + + rgb.Color = Color.Black; + Assert.AreEqual(0 / 255f, rgb.blue); + Assert.AreEqual(0 / 255f, rgb.green); + Assert.AreEqual(0 / 255f, rgb.red); + Assert.AreEqual(255 / 255f, rgb.alpha); + + rgb = Color.DarkGoldenrod; + Color color = rgb; + Assert.That(EqualColors(Color.DarkGoldenrod, color)); + } + + [Ignore] + public void FICOMPLEX() + { + } + + [Test] + public void FIBITMAP() + { + FIBITMAP var = new FIBITMAP(); + Assert.IsTrue(var.IsNull); + } + + [Test] + public void fi_handle() + { + fi_handle var = new fi_handle(); + Assert.IsTrue(var.IsNull); + + string test = "hello word!"; + using (var = new fi_handle(test)) + { + Assert.IsFalse(var.IsNull); + + object obj = var.GetObject(); + Assert.That(obj is string); + Assert.AreSame(obj, test); + } + } + + [Test] + public void FIICCPROFILE() + { + Random rand = new Random(DateTime.Now.Millisecond); + FIICCPROFILE var = new FIICCPROFILE(); + Assert.AreEqual(0, var.Data.Length); + Assert.AreEqual(IntPtr.Zero, var.DataPointer); + Assert.AreEqual(0, var.Size); + + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + byte[] data = new byte[512]; + rand.NextBytes(data); + + var = FreeImage.GetICCProfileEx(dib); + Assert.AreEqual(0, var.Size); + + var = new FIICCPROFILE(dib, data, 256); + Assert.AreEqual(256, var.Data.Length); + Assert.AreNotEqual(IntPtr.Zero, var.DataPointer); + Assert.AreEqual(256, var.Size); + byte[] dataComp = var.Data; + for (int i = 0; i < data.Length && i < dataComp.Length; i++) + if (data[i] != dataComp[i]) + Assert.Fail(); + + FreeImage.DestroyICCProfile(dib); + var = FreeImage.GetICCProfileEx(dib); + Assert.AreEqual(0, var.Size); + + var = new FIICCPROFILE(dib, data); + Assert.AreEqual(512, var.Data.Length); + Assert.AreNotEqual(IntPtr.Zero, var.DataPointer); + Assert.AreEqual(512, var.Size); + dataComp = var.Data; + for (int i = 0; i < data.Length && i < dataComp.Length; i++) + if (data[i] != dataComp[i]) + Assert.Fail(); + + var = FreeImage.GetICCProfileEx(dib); + Assert.AreEqual(512, var.Data.Length); + Assert.AreNotEqual(IntPtr.Zero, var.DataPointer); + Assert.AreEqual(512, var.Size); + + FreeImage.DestroyICCProfile(dib); + var = FreeImage.GetICCProfileEx(dib); + Assert.AreEqual(0, var.Size); + + FreeImage.UnloadEx(ref dib); + } + } + + [TestFixture] + public class WrapperStructsTest + { + ImageManager iManager = new ImageManager(); + FIBITMAP dib = new FIBITMAP(); + string freeImageCallback = null; + + [TestFixtureSetUp] + public void Init() + { + FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message); + } + + [TestFixtureTearDown] + public void DeInit() + { + FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message); + } + + [SetUp] + public void InitEachTime() + { + } + + [TearDown] + public void DeInitEachTime() + { + } + + void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message) + { + freeImageCallback = message; + } + + public bool EqualColors(Color color1, Color color2) + { + if (color1.A != color2.A) return false; + if (color1.R != color2.R) return false; + if (color1.G != color2.G) return false; + if (color1.B != color2.B) return false; + return true; + } + + [Test] + public void FIRational() + { + FIRational rational1 = new FIRational(); + FIRational rational2 = new FIRational(); + FIRational rational3 = new FIRational(); + + // + // Constructors + // + + Assert.That(rational1.Numerator == 0); + Assert.That(rational1.Denominator == 0); + + rational1 = new FIRational(412, 33); + Assert.That(rational1.Numerator == 412); + Assert.That(rational1.Denominator == 33); + + rational2 = new FIRational(rational1); + Assert.That(rational2.Numerator == 412); + Assert.That(rational2.Denominator == 33); + + rational3 = new FIRational(5.75m); + Assert.That(rational3.Numerator == 23); + Assert.That(rational3.Denominator == 4); + + // + // == != + // + + rational1 = new FIRational(421, 51); + rational2 = rational1; + Assert.That(rational1 == rational2); + Assert.That(!(rational1 != rational2)); + + rational2 = new FIRational(1, 7); + Assert.That(rational1 != rational2); + Assert.That(!(rational1 == rational2)); + + // + // > >= < <= + // + + rational1 = new FIRational(51, 4); + rational2 = new FIRational(27, 9); + Assert.That(rational1 != rational2); + Assert.That(rational1 > rational2); + Assert.That(rational1 >= rational2); + + rational1 = new FIRational(-412, 4); + Assert.That(rational1 != rational2); + Assert.That(rational1 < rational2); + Assert.That(rational1 <= rational2); + + // + // + / - + // + + rational1 = new FIRational(41, 3); + rational2 = new FIRational(612, 412); + rational3 = rational1 - rational2; + Assert.That((rational3 + rational2) == rational1); + + rational1 = new FIRational(-7852, 63); + rational2 = new FIRational(666111, -7654); + rational3 = rational1 - rational2; + Assert.That((rational3 + rational2) == rational1); + + rational1 = new FIRational(-513, 88); + rational2 = new FIRational(413, 5); + rational3 = rational1 - rational2; + Assert.That((rational3 + rational2) == rational1); + + rational1 = new FIRational(-513, 88); + rational2 = new FIRational(413, 5); + rational3 = rational1 - rational2; + Assert.That((rational3 + rational2) == rational1); + + rational1 = new FIRational(7531, 23144); + rational2 = new FIRational(-412, 78777); + rational3 = rational1 - rational2; + Assert.That((rational3 + rational2) == rational1); + + rational1 = new FIRational(513, -42123); + rational2 = new FIRational(-42, 77); + rational3 = rational1 - rational2; + Assert.That((rational3 + rational2) == rational1); + + rational1 = new FIRational(44, 11); + rational1 = -rational1; + Assert.That(rational1.Numerator == -4 && rational1.Denominator == 1); + + // + // % + // + + rational1 = new FIRational(23, 8); + rational2 = new FIRational(77, 777); + Assert.That((rational1 % rational2) == 0); + + rational2 = -rational2; + Assert.That((rational1 % rational2) == 0); + + rational2 = new FIRational(7, 4); + rational3 = new FIRational(9, 8); + Assert.That((rational1 % rational2) == rational3); + + rational2 = -rational2; + Assert.That((rational1 % rational2) == rational3); + + // + // ~ + // + + rational1 = new FIRational(41, 77); + rational1 = ~rational1; + Assert.That(rational1.Numerator == 77 && rational1.Denominator == 41); + + // + // - + // + + rational1 = new FIRational(52, 4); + rational1 = -rational1; + Assert.That(rational1 < 0); + + // + // ++ -- + // + + rational1 = new FIRational(5, 3); + rational1++; + rational2 = new FIRational(8, 3); + Assert.That(rational1 == rational2); + + rational1 = new FIRational(41, -43); + rational1++; + Assert.That(rational1 > 0.0f); + + rational1--; + Assert.That(rational1 == new FIRational(41, -43)); + + rational1 = new FIRational(8134, 312); + Assert.That(rational1 != 26); + + // + // Direct assigns + // + + rational1 = (FIRational)0.75m; + Assert.That(rational1.Numerator == 3 && rational1.Denominator == 4); + rational1 = (FIRational)0.33; + Assert.That(rational1.Numerator == 33 && rational1.Denominator == 100); + rational1 = (FIRational)62.975m; + Assert.That(((decimal)rational1.Numerator / (decimal)rational1.Denominator) == 62.975m); + rational1 = (FIRational)(-73.0975m); + Assert.That(((decimal)rational1.Numerator / (decimal)rational1.Denominator) == -73.0975m); + rational1 = (FIRational)(7m / 9m); + Assert.That(rational1.Numerator == 7 && rational1.Denominator == 9); + rational1 = (FIRational)(-15m / 9m); + Assert.That(rational1.Numerator == -5 && rational1.Denominator == 3); + rational1 = (FIRational)(0.7777m); + Assert.That(rational1.Denominator != 9); + + // + // Properties + // + + rational1 = new FIRational(515, 5); + Assert.That(rational1.IsInteger); + + rational1 = new FIRational(876, 77); + Assert.That(rational1.Truncate() == (876 / 77)); + + // + // Special cases + // + + rational1 = new FIRational(0, 10000); + Assert.That(rational1 == 0m); + + rational1 = new FIRational(10000, 0); + Assert.That(rational1 == 0f); + + rational1 = new FIRational(0, 0); + Assert.That(rational1 == 0d); + + rational1 = new FIRational(-1, 0); + Assert.That(rational1 == 0); + + rational1 = new FIRational(0, -1); + Assert.That(rational1 == 0); + } + + [Ignore] + public void StreamWrapper() + { + string url = @"http://freeimage.sourceforge.net/images/logo.jpg"; + + // + // Non blocking + // + + HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); + Assert.IsNotNull(req); + + req.Timeout = 1000; + HttpWebResponse resp; + try + { + resp = (HttpWebResponse)req.GetResponse(); + } + catch + { + return; + } + Assert.IsNotNull(resp); + + Stream stream = resp.GetResponseStream(); + Assert.IsNotNull(stream); + + StreamWrapper wrapper = new StreamWrapper(stream, false); + Assert.IsNotNull(wrapper); + Assert.IsTrue(wrapper.CanRead && wrapper.CanSeek && !wrapper.CanWrite); + + byte[] buffer = new byte[1024 * 100]; + int read; + int count = 0; + + do + { + read = wrapper.Read(buffer, count, buffer.Length - count); + count += read; + } while (read != 0); + + Assert.AreEqual(7972, count); + Assert.AreEqual(7972, wrapper.Length); + + wrapper.Position = 0; + Assert.AreEqual(0, wrapper.Position); + + byte[] test = new byte[buffer.Length]; + int countTest = 0; + + do + { + read = wrapper.Read(test, countTest, test.Length - countTest); + countTest += read; + } while (read != 0); + + Assert.AreEqual(count, countTest); + + for (int i = 0; i < countTest; i++) + if (buffer[i] != test[i]) + Assert.Fail(); + + resp.Close(); + wrapper.Dispose(); + stream.Dispose(); + + // + // Blocking + // + + req = (HttpWebRequest)HttpWebRequest.Create(url); + Assert.IsNotNull(req); + + resp = (HttpWebResponse)req.GetResponse(); + Assert.IsNotNull(resp); + + stream = resp.GetResponseStream(); + Assert.IsNotNull(stream); + + wrapper = new StreamWrapper(stream, true); + Assert.IsNotNull(wrapper); + Assert.IsTrue(wrapper.CanRead && wrapper.CanSeek && !wrapper.CanWrite); + + buffer = new byte[1024 * 100]; + count = 0; + + count = wrapper.Read(buffer, 0, buffer.Length); + Assert.AreEqual(7972, count); + + resp.Close(); + stream.Dispose(); + wrapper.Dispose(); + + // + // Position & Read byte + // + + buffer = new byte[] { 0x00, 0x01, 0x02, 0xFF, 0xFE, 0xFD }; + stream = new MemoryStream(buffer); + wrapper = new StreamWrapper(stream, false); + + Assert.That(0x00 == wrapper.ReadByte()); + Assert.That(0x01 == wrapper.ReadByte()); + Assert.That(0x02 == wrapper.ReadByte()); + Assert.That(0xFF == wrapper.ReadByte()); + Assert.That(0xFE == wrapper.ReadByte()); + Assert.That(0xFD == wrapper.ReadByte()); + Assert.That(-1 == wrapper.ReadByte()); + + Assert.That(wrapper.Length == buffer.Length); + + wrapper.Seek(0, SeekOrigin.Begin); + Assert.That(0x00 == wrapper.ReadByte()); + wrapper.Seek(3, SeekOrigin.Begin); + Assert.That(0xFF == wrapper.ReadByte()); + wrapper.Seek(0, SeekOrigin.End); + Assert.That(-1 == wrapper.ReadByte()); + wrapper.Seek(-2, SeekOrigin.End); + Assert.That(0xFE == wrapper.ReadByte()); + wrapper.Seek(0, SeekOrigin.Begin); + Assert.That(0x00 == wrapper.ReadByte()); + wrapper.Seek(2, SeekOrigin.Current); + Assert.That(0xFF == wrapper.ReadByte()); + wrapper.Seek(1, SeekOrigin.Current); + Assert.That(0xFD == wrapper.ReadByte()); + Assert.That(wrapper.Position != 0); + wrapper.Reset(); + Assert.That(wrapper.Position == 0); + + wrapper.Dispose(); + stream.Position = 0; + wrapper = new StreamWrapper(stream, false); + + wrapper.Seek(10, SeekOrigin.Begin); + Assert.That(wrapper.Position == buffer.Length); + + wrapper.Dispose(); + stream.Dispose(); + } + + [Ignore] + public void LocalPlugin() + { + } + + [Test] + public void FreeImageStreamIO() + { + Random rand = new Random(); + byte[] bBuffer = new byte[256]; + IntPtr buffer = Marshal.AllocHGlobal(256); + + MemoryStream stream = new MemoryStream(); + Assert.IsNotNull(stream); + using (fi_handle handle = new fi_handle(stream)) + { + + FreeImageIO io = FreeImageAPI.IO.FreeImageStreamIO.io; + Assert.IsNotNull(io.readProc); + Assert.IsNotNull(io.writeProc); + Assert.IsNotNull(io.seekProc); + Assert.IsNotNull(io.tellProc); + + // + // Procs + // + + rand.NextBytes(bBuffer); + + stream.Write(bBuffer, 0, bBuffer.Length); + Assert.That(io.tellProc(handle) == stream.Position); + Assert.That(io.seekProc(handle, 0, SeekOrigin.Begin) == 0); + Assert.That(io.tellProc(handle) == 0); + Assert.That(io.tellProc(handle) == stream.Position); + + // Read one block + Assert.That(io.readProc(buffer, (uint)bBuffer.Length, 1, handle) == 1); + for (int i = 0; i < bBuffer.Length; i++) + Assert.That(Marshal.ReadByte(buffer, i) == bBuffer[i]); + + Assert.That(io.tellProc(handle) == stream.Position); + Assert.That(io.seekProc(handle, 0, SeekOrigin.Begin) == 0); + Assert.That(io.tellProc(handle) == stream.Position); + + // Read 1 byte block + Assert.That(io.readProc(buffer, 1, (uint)bBuffer.Length, handle) == bBuffer.Length); + for (int i = 0; i < bBuffer.Length; i++) + Assert.That(Marshal.ReadByte(buffer, i) == bBuffer[i]); + + Assert.That(io.tellProc(handle) == stream.Position); + Assert.That(io.seekProc(handle, 0, SeekOrigin.Begin) == 0); + Assert.That(io.tellProc(handle) == stream.Position); + + rand.NextBytes(bBuffer); + for (int i = 0; i < bBuffer.Length; i++) + Marshal.WriteByte(buffer, i, bBuffer[i]); + + // Write one block + + Assert.That(io.writeProc(buffer, (uint)bBuffer.Length, 1, handle) == 1); + for (int i = 0; i < bBuffer.Length; i++) + Assert.That(Marshal.ReadByte(buffer, i) == bBuffer[i]); + Assert.That(io.tellProc(handle) == stream.Position); + + Assert.That(io.seekProc(handle, 0, SeekOrigin.Begin) == 0); + Assert.That(io.tellProc(handle) == 0); + + // write 1 byte block + + Assert.That(io.writeProc(buffer, 1, (uint)bBuffer.Length, handle) == bBuffer.Length); + for (int i = 0; i < bBuffer.Length; i++) + Assert.That(Marshal.ReadByte(buffer, i) == bBuffer[i]); + Assert.That(io.tellProc(handle) == stream.Position); + + // Seek and tell + + Assert.That(io.seekProc(handle, 0, SeekOrigin.Begin) == 0); + Assert.That(io.tellProc(handle) == 0); + + Assert.That(io.seekProc(handle, 127, SeekOrigin.Current) == 0); + Assert.That(io.tellProc(handle) == 127); + + Assert.That(io.seekProc(handle, 0, SeekOrigin.End) == 0); + Assert.That(io.tellProc(handle) == 256); + + Marshal.FreeHGlobal(buffer); + stream.Dispose(); + } + } + + [Test] + public void MetadataTag() + { + FITAG tag; + MetadataTag metaTag; + + Random rand = new Random(); + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.IsFalse(dib.IsNull); + + Assert.That(FreeImage.GetMetadataCount(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, dib) > 0); + + FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, dib, out tag); + Assert.IsFalse(tag.IsNull); + Assert.IsFalse(mData.IsNull); + + // + // Constructors + // + + metaTag = new MetadataTag(tag, dib); + Assert.That(metaTag.Model == FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN); + + metaTag = new MetadataTag(tag, FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN); + Assert.That(metaTag.Model == FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN); + + // + // Properties + // + + metaTag.ID = ushort.MinValue; + Assert.That(metaTag.ID == ushort.MinValue); + + metaTag.ID = ushort.MaxValue; + Assert.That(metaTag.ID == ushort.MaxValue); + + metaTag.ID = ushort.MaxValue / 2; + Assert.That(metaTag.ID == ushort.MaxValue / 2); + + metaTag.Description = ""; + Assert.That(metaTag.Description == ""); + + metaTag.Description = "A"; + Assert.That(metaTag.Description == "A"); + + metaTag.Description = "ABCDEFG"; + Assert.That(metaTag.Description == "ABCDEFG"); + + metaTag.Key = ""; + Assert.That(metaTag.Key == ""); + + metaTag.Key = "A"; + Assert.That(metaTag.Key == "A"); + + metaTag.Key = "ABCDEFG"; + Assert.That(metaTag.Key == "ABCDEFG"); + + // + // SetValue + // + + try + { + metaTag.SetValue(null, FREE_IMAGE_MDTYPE.FIDT_ASCII); + Assert.Fail(); + } + catch + { + } + + // + // FREE_IMAGE_MDTYPE.FIDT_ASCII + // + + string testString = ""; + + Assert.IsTrue(metaTag.SetValue(testString, FREE_IMAGE_MDTYPE.FIDT_ASCII)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((string)metaTag.Value).Length == 0); + + testString = "X"; + + Assert.IsTrue(metaTag.SetValue(testString, FREE_IMAGE_MDTYPE.FIDT_ASCII)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((string)metaTag.Value).Length == testString.Length); + Assert.That(((string)metaTag.Value) == testString); + + testString = "TEST-STRING"; + + Assert.IsTrue(metaTag.SetValue(testString, FREE_IMAGE_MDTYPE.FIDT_ASCII)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((string)metaTag.Value).Length == testString.Length); + Assert.That(((string)metaTag.Value) == testString); + + // + // FREE_IMAGE_MDTYPE.FIDT_BYTE + // + + byte testByte; + byte[] testByteArray; + + Assert.IsTrue(metaTag.SetValue(byte.MinValue, FREE_IMAGE_MDTYPE.FIDT_BYTE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((byte[])metaTag.Value).Length == 1); + Assert.That(((byte[])metaTag.Value)[0] == byte.MinValue); + + Assert.IsTrue(metaTag.SetValue(byte.MaxValue, FREE_IMAGE_MDTYPE.FIDT_BYTE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((byte[])metaTag.Value).Length == 1); + Assert.That(((byte[])metaTag.Value)[0] == byte.MaxValue); + + for (int i = 0; i < 10; i++) + { + testByte = (byte)rand.Next(byte.MinValue, byte.MaxValue); + testByteArray = new byte[rand.Next(0, 31)]; + + for (int j = 0; j < testByteArray.Length; j++) + testByteArray[j] = (byte)rand.Next(); + + Assert.IsTrue(metaTag.SetValue(testByte, FREE_IMAGE_MDTYPE.FIDT_BYTE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((byte[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 1); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_BYTE); + Assert.That(((byte[])metaTag.Value)[0] == testByte); + + Assert.IsTrue(metaTag.SetValue(testByteArray, FREE_IMAGE_MDTYPE.FIDT_BYTE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((byte[])metaTag.Value).Length == testByteArray.Length); + Assert.That(metaTag.Count == testByteArray.Length); + Assert.That(metaTag.Length == testByteArray.Length * 1); + + byte[] value = (byte[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testByteArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_DOUBLE + // + + double testDouble; + double[] testDoubleArray; + + Assert.IsTrue(metaTag.SetValue(double.MinValue, FREE_IMAGE_MDTYPE.FIDT_DOUBLE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((double[])metaTag.Value).Length == 1); + Assert.That(((double[])metaTag.Value)[0] == double.MinValue); + + Assert.IsTrue(metaTag.SetValue(double.MaxValue, FREE_IMAGE_MDTYPE.FIDT_DOUBLE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((double[])metaTag.Value).Length == 1); + Assert.That(((double[])metaTag.Value)[0] == double.MaxValue); + + for (int i = 0; i < 10; i++) + { + testDouble = (double)rand.NextDouble(); + testDoubleArray = new double[rand.Next(0, 31)]; + + for (int j = 0; j < testDoubleArray.Length; j++) + testDoubleArray[j] = rand.NextDouble(); + + Assert.IsTrue(metaTag.SetValue(testDouble, FREE_IMAGE_MDTYPE.FIDT_DOUBLE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((double[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 8); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_DOUBLE); + Assert.That(((double[])metaTag.Value)[0] == testDouble); + + Assert.IsTrue(metaTag.SetValue(testDoubleArray, FREE_IMAGE_MDTYPE.FIDT_DOUBLE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((double[])metaTag.Value).Length == testDoubleArray.Length); + Assert.That(metaTag.Count == testDoubleArray.Length); + Assert.That(metaTag.Length == testDoubleArray.Length * 8); + + double[] value = (double[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testDoubleArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_FLOAT + // + + float testfloat; + float[] testFloatArray; + + Assert.IsTrue(metaTag.SetValue(float.MinValue, FREE_IMAGE_MDTYPE.FIDT_FLOAT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((float[])metaTag.Value).Length == 1); + Assert.That(((float[])metaTag.Value)[0] == float.MinValue); + + Assert.IsTrue(metaTag.SetValue(float.MaxValue, FREE_IMAGE_MDTYPE.FIDT_FLOAT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((float[])metaTag.Value).Length == 1); + Assert.That(((float[])metaTag.Value)[0] == float.MaxValue); + + for (int i = 0; i < 10; i++) + { + testfloat = (float)rand.NextDouble(); + testFloatArray = new float[rand.Next(0, 31)]; + + for (int j = 0; j < testFloatArray.Length; j++) + testFloatArray[j] = (float)rand.NextDouble(); + + Assert.IsTrue(metaTag.SetValue(testfloat, FREE_IMAGE_MDTYPE.FIDT_FLOAT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((float[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 4); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_FLOAT); + Assert.That(((float[])metaTag.Value)[0] == testfloat); + + Assert.IsTrue(metaTag.SetValue(testFloatArray, FREE_IMAGE_MDTYPE.FIDT_FLOAT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((float[])metaTag.Value).Length == testFloatArray.Length); + Assert.That(metaTag.Count == testFloatArray.Length); + Assert.That(metaTag.Length == testFloatArray.Length * 4); + + float[] value = (float[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testFloatArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_IFD + // + + uint testUint; + uint[] testUintArray; + + Assert.IsTrue(metaTag.SetValue(uint.MinValue, FREE_IMAGE_MDTYPE.FIDT_IFD)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((uint[])metaTag.Value).Length == 1); + Assert.That(((uint[])metaTag.Value)[0] == uint.MinValue); + + Assert.IsTrue(metaTag.SetValue(uint.MaxValue, FREE_IMAGE_MDTYPE.FIDT_IFD)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((uint[])metaTag.Value).Length == 1); + Assert.That(((uint[])metaTag.Value)[0] == uint.MaxValue); + + for (int i = 0; i < 10; i++) + { + testUint = (uint)rand.NextDouble(); + testUintArray = new uint[rand.Next(0, 31)]; + + for (int j = 0; j < testUintArray.Length; j++) + testUintArray[j] = (uint)rand.Next(); + + Assert.IsTrue(metaTag.SetValue(testUint, FREE_IMAGE_MDTYPE.FIDT_IFD)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((uint[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 4); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_IFD); + Assert.That(((uint[])metaTag.Value)[0] == testUint); + + Assert.IsTrue(metaTag.SetValue(testUintArray, FREE_IMAGE_MDTYPE.FIDT_IFD)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((uint[])metaTag.Value).Length == testUintArray.Length); + Assert.That(metaTag.Count == testUintArray.Length); + Assert.That(metaTag.Length == testUintArray.Length * 4); + + uint[] value = (uint[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testUintArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_LONG + // + + Assert.IsTrue(metaTag.SetValue(uint.MinValue, FREE_IMAGE_MDTYPE.FIDT_LONG)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((uint[])metaTag.Value).Length == 1); + Assert.That(((uint[])metaTag.Value)[0] == uint.MinValue); + + Assert.IsTrue(metaTag.SetValue(uint.MaxValue, FREE_IMAGE_MDTYPE.FIDT_LONG)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((uint[])metaTag.Value).Length == 1); + Assert.That(((uint[])metaTag.Value)[0] == uint.MaxValue); + + for (int i = 0; i < 10; i++) + { + testUint = (uint)rand.NextDouble(); + testUintArray = new uint[rand.Next(0, 31)]; + + for (int j = 0; j < testUintArray.Length; j++) + testUintArray[j] = (uint)rand.Next(); + + Assert.IsTrue(metaTag.SetValue(testUint, FREE_IMAGE_MDTYPE.FIDT_LONG)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((uint[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 4); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_LONG); + Assert.That(((uint[])metaTag.Value)[0] == testUint); + + Assert.IsTrue(metaTag.SetValue(testUintArray, FREE_IMAGE_MDTYPE.FIDT_LONG)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((uint[])metaTag.Value).Length == testUintArray.Length); + Assert.That(metaTag.Count == testUintArray.Length); + Assert.That(metaTag.Length == testUintArray.Length * 4); + + uint[] value = (uint[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testUintArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_NOTYPE + // + + try + { + metaTag.SetValue(new object(), FREE_IMAGE_MDTYPE.FIDT_NOTYPE); + Assert.Fail(); + } + catch (NotSupportedException) + { + } + + // + // FREE_IMAGE_MDTYPE.FIDT_PALETTE + // + + RGBQUAD testRGBQUAD; + RGBQUAD[] testRGBQUADArray; + + for (int i = 0; i < 10; i++) + { + testRGBQUAD = new RGBQUAD(Color.FromArgb(rand.Next())); + testRGBQUADArray = new RGBQUAD[rand.Next(0, 31)]; + + for (int j = 0; j < testRGBQUADArray.Length; j++) + testRGBQUADArray[j] = new RGBQUAD(Color.FromArgb(rand.Next())); + + Assert.IsTrue(metaTag.SetValue(testRGBQUAD, FREE_IMAGE_MDTYPE.FIDT_PALETTE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((RGBQUAD[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 4); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_PALETTE); + Assert.That(((RGBQUAD[])metaTag.Value)[0] == testRGBQUAD); + + Assert.IsTrue(metaTag.SetValue(testRGBQUADArray, FREE_IMAGE_MDTYPE.FIDT_PALETTE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((RGBQUAD[])metaTag.Value).Length == testRGBQUADArray.Length); + Assert.That(metaTag.Count == testRGBQUADArray.Length); + Assert.That(metaTag.Length == testRGBQUADArray.Length * 4); + + RGBQUAD[] value = (RGBQUAD[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testRGBQUADArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_RATIONAL + // + + FIURational testFIURational; + FIURational[] testFIURationalArray; + + for (int i = 0; i < 10; i++) + { + testFIURational = new FIURational((uint)rand.Next(), (uint)rand.Next()); + testFIURationalArray = new FIURational[rand.Next(0, 31)]; + + for (int j = 0; j < testFIURationalArray.Length; j++) + testFIURationalArray[j] = new FIURational((uint)rand.Next(), (uint)rand.Next()); + + Assert.IsTrue(metaTag.SetValue(testFIURational, FREE_IMAGE_MDTYPE.FIDT_RATIONAL)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((FIURational[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 8); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_RATIONAL); + Assert.That(((FIURational[])metaTag.Value)[0] == testFIURational); + + Assert.IsTrue(metaTag.SetValue(testFIURationalArray, FREE_IMAGE_MDTYPE.FIDT_RATIONAL)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((FIURational[])metaTag.Value).Length == testFIURationalArray.Length); + Assert.That(metaTag.Count == testFIURationalArray.Length); + Assert.That(metaTag.Length == testFIURationalArray.Length * 8); + + FIURational[] value = (FIURational[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testFIURationalArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_SBYTE + // + + sbyte testSByte; + sbyte[] testSByteArray; + + Assert.IsTrue(metaTag.SetValue(sbyte.MinValue, FREE_IMAGE_MDTYPE.FIDT_SBYTE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((sbyte[])metaTag.Value).Length == 1); + Assert.That(((sbyte[])metaTag.Value)[0] == sbyte.MinValue); + + Assert.IsTrue(metaTag.SetValue(sbyte.MaxValue, FREE_IMAGE_MDTYPE.FIDT_SBYTE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((sbyte[])metaTag.Value).Length == 1); + Assert.That(((sbyte[])metaTag.Value)[0] == sbyte.MaxValue); + + for (int i = 0; i < 10; i++) + { + testSByte = (sbyte)rand.Next(sbyte.MinValue, sbyte.MaxValue); + testSByteArray = new sbyte[rand.Next(0, 31)]; + + for (int j = 0; j < testSByteArray.Length; j++) + testSByteArray[j] = (sbyte)rand.Next(); + + Assert.IsTrue(metaTag.SetValue(testSByte, FREE_IMAGE_MDTYPE.FIDT_SBYTE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((sbyte[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 1); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_SBYTE); + Assert.That(((sbyte[])metaTag.Value)[0] == testSByte); + + Assert.IsTrue(metaTag.SetValue(testSByteArray, FREE_IMAGE_MDTYPE.FIDT_SBYTE)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((sbyte[])metaTag.Value).Length == testSByteArray.Length); + Assert.That(metaTag.Count == testSByteArray.Length); + Assert.That(metaTag.Length == testSByteArray.Length * 1); + + sbyte[] value = (sbyte[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testSByteArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_SHORT + // + + ushort testUShort; + ushort[] testUShortArray; + + Assert.IsTrue(metaTag.SetValue(ushort.MinValue, FREE_IMAGE_MDTYPE.FIDT_SHORT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((ushort[])metaTag.Value).Length == 1); + Assert.That(((ushort[])metaTag.Value)[0] == ushort.MinValue); + + Assert.IsTrue(metaTag.SetValue(ushort.MaxValue, FREE_IMAGE_MDTYPE.FIDT_SHORT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((ushort[])metaTag.Value).Length == 1); + Assert.That(((ushort[])metaTag.Value)[0] == ushort.MaxValue); + + for (int i = 0; i < 10; i++) + { + testUShort = (ushort)rand.Next(ushort.MinValue, sbyte.MaxValue); + testUShortArray = new ushort[rand.Next(0, 31)]; + + for (int j = 0; j < testUShortArray.Length; j++) + testUShortArray[j] = (ushort)rand.Next(); + + Assert.IsTrue(metaTag.SetValue(testUShort, FREE_IMAGE_MDTYPE.FIDT_SHORT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((ushort[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 2); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_SHORT); + Assert.That(((ushort[])metaTag.Value)[0] == testUShort); + + Assert.IsTrue(metaTag.SetValue(testUShortArray, FREE_IMAGE_MDTYPE.FIDT_SHORT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((ushort[])metaTag.Value).Length == testUShortArray.Length); + Assert.That(metaTag.Count == testUShortArray.Length); + Assert.That(metaTag.Length == testUShortArray.Length * 2); + + ushort[] value = (ushort[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testUShortArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_SLONG + // + + int testInt; + int[] testIntArray; + + Assert.IsTrue(metaTag.SetValue(int.MinValue, FREE_IMAGE_MDTYPE.FIDT_SLONG)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((int[])metaTag.Value).Length == 1); + Assert.That(((int[])metaTag.Value)[0] == int.MinValue); + + Assert.IsTrue(metaTag.SetValue(int.MaxValue, FREE_IMAGE_MDTYPE.FIDT_SLONG)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((int[])metaTag.Value).Length == 1); + Assert.That(((int[])metaTag.Value)[0] == int.MaxValue); + + for (int i = 0; i < 10; i++) + { + testInt = (int)rand.NextDouble(); + testIntArray = new int[rand.Next(0, 31)]; + + for (int j = 0; j < testIntArray.Length; j++) + testIntArray[j] = rand.Next(); + + Assert.IsTrue(metaTag.SetValue(testInt, FREE_IMAGE_MDTYPE.FIDT_SLONG)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((int[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 4); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_SLONG); + Assert.That(((int[])metaTag.Value)[0] == testInt); + + Assert.IsTrue(metaTag.SetValue(testIntArray, FREE_IMAGE_MDTYPE.FIDT_SLONG)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((int[])metaTag.Value).Length == testIntArray.Length); + Assert.That(metaTag.Count == testIntArray.Length); + Assert.That(metaTag.Length == testIntArray.Length * 4); + + int[] value = (int[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testIntArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_SRATIONAL + // + + FIRational testFIRational; + FIRational[] testFIRationalArray; + + for (int i = 0; i < 10; i++) + { + testFIRational = new FIRational(rand.Next(), rand.Next()); + testFIRationalArray = new FIRational[rand.Next(0, 31)]; + + for (int j = 0; j < testFIRationalArray.Length; j++) + testFIRationalArray[j] = new FIRational(rand.Next(), rand.Next()); + + Assert.IsTrue(metaTag.SetValue(testFIRational, FREE_IMAGE_MDTYPE.FIDT_SRATIONAL)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((FIRational[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 8); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_SRATIONAL); + Assert.That(((FIRational[])metaTag.Value)[0] == testFIRational); + + Assert.IsTrue(metaTag.SetValue(testFIRationalArray, FREE_IMAGE_MDTYPE.FIDT_SRATIONAL)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((FIRational[])metaTag.Value).Length == testFIRationalArray.Length); + Assert.That(metaTag.Count == testFIRationalArray.Length); + Assert.That(metaTag.Length == testFIRationalArray.Length * 8); + + FIRational[] value = (FIRational[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testFIRationalArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_SSHORT + // + + short testShort; + short[] testShortArray; + + Assert.IsTrue(metaTag.SetValue(short.MinValue, FREE_IMAGE_MDTYPE.FIDT_SSHORT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((short[])metaTag.Value).Length == 1); + Assert.That(((short[])metaTag.Value)[0] == short.MinValue); + + Assert.IsTrue(metaTag.SetValue(short.MaxValue, FREE_IMAGE_MDTYPE.FIDT_SSHORT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((short[])metaTag.Value).Length == 1); + Assert.That(((short[])metaTag.Value)[0] == short.MaxValue); + + for (int i = 0; i < 10; i++) + { + testShort = (short)rand.Next(short.MinValue, short.MaxValue); + testShortArray = new short[rand.Next(0, 31)]; + + for (int j = 0; j < testShortArray.Length; j++) + testShortArray[j] = (short)rand.Next(); + + Assert.IsTrue(metaTag.SetValue(testShort, FREE_IMAGE_MDTYPE.FIDT_SSHORT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((short[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 2); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_SSHORT); + Assert.That(((short[])metaTag.Value)[0] == testShort); + + Assert.IsTrue(metaTag.SetValue(testShortArray, FREE_IMAGE_MDTYPE.FIDT_SSHORT)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((short[])metaTag.Value).Length == testShortArray.Length); + Assert.That(metaTag.Count == testShortArray.Length); + Assert.That(metaTag.Length == testShortArray.Length * 2); + + short[] value = (short[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testShortArray[j] == value[j]); + } + + // + // FREE_IMAGE_MDTYPE.FIDT_UNDEFINED + // + + Assert.IsTrue(metaTag.SetValue(byte.MinValue, FREE_IMAGE_MDTYPE.FIDT_UNDEFINED)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((byte[])metaTag.Value).Length == 1); + Assert.That(((byte[])metaTag.Value)[0] == byte.MinValue); + + Assert.IsTrue(metaTag.SetValue(byte.MaxValue, FREE_IMAGE_MDTYPE.FIDT_UNDEFINED)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((byte[])metaTag.Value).Length == 1); + Assert.That(((byte[])metaTag.Value)[0] == byte.MaxValue); + + for (int i = 0; i < 10; i++) + { + testByte = (byte)rand.Next(byte.MinValue, byte.MaxValue); + testByteArray = new byte[rand.Next(0, 31)]; + + for (int j = 0; j < testByteArray.Length; j++) + testByteArray[j] = (byte)rand.Next(); + + Assert.IsTrue(metaTag.SetValue(testByte, FREE_IMAGE_MDTYPE.FIDT_UNDEFINED)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((byte[])metaTag.Value).Length == 1); + Assert.That(metaTag.Count == 1); + Assert.That(metaTag.Length == 1); + Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_UNDEFINED); + Assert.That(((byte[])metaTag.Value)[0] == testByte); + + Assert.IsTrue(metaTag.SetValue(testByteArray, FREE_IMAGE_MDTYPE.FIDT_UNDEFINED)); + Assert.IsNotNull(metaTag.Value); + Assert.That(((byte[])metaTag.Value).Length == testByteArray.Length); + Assert.That(metaTag.Count == testByteArray.Length); + Assert.That(metaTag.Length == testByteArray.Length * 1); + + byte[] value = (byte[])metaTag.Value; + + for (int j = 0; j < value.Length; j++) + Assert.That(testByteArray[j] == value[j]); + } + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void MetadataModel() + { + MetadataTag tag; + dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + MetadataModel model = new MDM_GEOTIFF(dib); + Assert.AreEqual(0, model.Count); + Assert.IsFalse(model.Exists); + Assert.IsEmpty(model.List); + Assert.AreEqual(model.Model, FREE_IMAGE_MDMODEL.FIMD_GEOTIFF); + Assert.IsTrue(model.DestoryModel()); + foreach (MetadataTag m in model) Assert.Fail(); + + tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_GEOTIFF); + tag.Key = "KEY"; + tag.Value = 54321f; + Assert.IsTrue(model.AddTag(tag)); + + Assert.AreEqual(1, model.Count); + Assert.IsTrue(model.Exists); + Assert.IsNotEmpty(model.List); + Assert.AreEqual(model.Model, FREE_IMAGE_MDMODEL.FIMD_GEOTIFF); + + Assert.IsTrue(model.DestoryModel()); + Assert.AreEqual(0, model.Count); + Assert.IsFalse(model.Exists); + Assert.IsEmpty(model.List); + Assert.AreEqual(model.Model, FREE_IMAGE_MDMODEL.FIMD_GEOTIFF); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void ImageMetadata() + { + ImageMetadata metadata; + List modelList; + MetadataTag tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS); + tag.Key = "KEY"; + tag.ID = 11; + tag.Value = new double[] { 0d, 41d, -523d, -0.41d }; + + dib = FreeImage.Allocate(1, 1, 1, 1, 0, 0); + Assert.IsFalse(dib.IsNull); + + metadata = new ImageMetadata(dib, true); + Assert.AreEqual(0, metadata.Count); + Assert.IsTrue(metadata.HideEmptyModels); + Assert.IsEmpty(metadata.List); + + metadata = new ImageMetadata(dib, false); + Assert.AreEqual(FreeImage.FREE_IMAGE_MDMODELS.Length, metadata.Count); + Assert.IsFalse(metadata.HideEmptyModels); + Assert.IsNotEmpty(metadata.List); + + metadata.HideEmptyModels = true; + metadata.AddTag(tag); + + Assert.AreEqual(1, metadata.Count); + Assert.IsNotEmpty(metadata.List); + + modelList = metadata.List; + Assert.AreEqual(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, modelList[0].Model); + + System.Collections.IEnumerator enumerator = metadata.GetEnumerator(); + Assert.IsTrue(enumerator.MoveNext()); + Assert.IsNotNull((MetadataModel)enumerator.Current); + Assert.IsFalse(enumerator.MoveNext()); + + FreeImage.UnloadEx(ref dib); + } + } + + [TestFixture] + public class WrapperFunctionsTest + { + ImageManager iManager = new ImageManager(); + FIBITMAP dib = new FIBITMAP(); + string freeImageCallback = null; + + [TestFixtureSetUp] + public void Init() + { + FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message); + } + + [TestFixtureTearDown] + public void DeInit() + { + FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message); + } + + [SetUp] + public void InitEachTime() + { + } + + [TearDown] + public void DeInitEachTime() + { + } + + void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message) + { + freeImageCallback = message; + } + + public bool EqualColors(Color color1, Color color2) + { + if (color1.A != color2.A) return false; + if (color1.R != color2.R) return false; + if (color1.G != color2.G) return false; + if (color1.B != color2.B) return false; + return true; + } + + // + // Tests + // + + [Test] + public void FreeImage_GetWrapperVersion() + { + //Assert.That(FreeImage.GetWrapperVersion() == + // String.Format("{0}.{1}.{2}", + // FreeImage.FREEIMAGE_MAJOR_VERSION, + // FreeImage.FREEIMAGE_MINOR_VERSION, + // FreeImage.FREEIMAGE_RELEASE_SERIAL)); + } + + [Test] + public void FreeImage_IsAvailable() + { + Assert.IsTrue(FreeImage.IsAvailable()); + } + + [Test] + public void FreeImage_GetBitmap() + { + Bitmap bitmap = null; + + try + { + bitmap = FreeImage.GetBitmap(new FIBITMAP()); + } + catch + { + } + Assert.IsNull(bitmap); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + + bitmap = FreeImage.GetBitmap(dib); + Assert.IsNotNull(bitmap); + Assert.AreEqual((int)FreeImage.GetHeight(dib), bitmap.Height); + Assert.AreEqual((int)FreeImage.GetWidth(dib), bitmap.Width); + + bitmap.Dispose(); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_CreateFromBitmap() + { + Bitmap bitmap = (Bitmap)Bitmap.FromFile(iManager.GetBitmapPath(ImageType.Odd, ImageColorType.Type_24)); + Assert.IsNotNull(bitmap); + + dib = FreeImage.CreateFromBitmap(bitmap); + Assert.That(!dib.IsNull); + + Assert.AreEqual((int)FreeImage.GetHeight(dib), bitmap.Height); + Assert.AreEqual((int)FreeImage.GetWidth(dib), bitmap.Width); + + bitmap.Dispose(); + FreeImage.UnloadEx(ref dib); + + try + { + dib = FreeImage.CreateFromBitmap(null); + Assert.Fail(); + } + catch + { + } + } + + [Test] + public void FreeImage_SaveBitmap() + { + Bitmap bitmap = (Bitmap)Bitmap.FromFile(iManager.GetBitmapPath(ImageType.Odd, ImageColorType.Type_24)); + Assert.IsNotNull(bitmap); + + Assert.IsTrue(FreeImage.SaveBitmap(bitmap, @"test.png", FREE_IMAGE_FORMAT.FIF_PNG, FREE_IMAGE_SAVE_FLAGS.DEFAULT)); + bitmap.Dispose(); + + Assert.IsTrue(File.Exists(@"test.png")); + + dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_PNG, @"test.png", FREE_IMAGE_LOAD_FLAGS.DEFAULT); + Assert.That(!dib.IsNull); + + FreeImage.UnloadEx(ref dib); + + File.Delete(@"test.png"); + Assert.IsFalse(File.Exists(@"test.png")); + bitmap.Dispose(); + } + + [Test] + public void FreeImage_LoadEx() + { + dib = FreeImage.LoadEx(iManager.GetBitmapPath(ImageType.Odd, ImageColorType.Type_16_555)); + Assert.That(!dib.IsNull); + FreeImage.UnloadEx(ref dib); + + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_TIFF; + + dib = FreeImage.LoadEx(iManager.GetBitmapPath(ImageType.Odd, ImageColorType.Type_16_565), ref format); + Assert.That(dib.IsNull); + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_TIFF, format); + FreeImage.UnloadEx(ref dib); + + format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + dib = FreeImage.LoadEx(iManager.GetBitmapPath(ImageType.JPEG, ImageColorType.Type_16_565), + FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + Assert.That(!dib.IsNull); + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_JPEG, format); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_UnloadEx() + { + Assert.That(dib.IsNull); + FreeImage.UnloadEx(ref dib); + Assert.That(dib.IsNull); + + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_16_555); + Assert.That(!dib.IsNull); + + FreeImage.UnloadEx(ref dib); + Assert.That(dib.IsNull); + } + + [Test] + public void FreeImage_SaveEx() + { + FREE_IMAGE_FORMAT format; + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08); + Assert.That(!dib.IsNull); + + Assert.IsTrue(FreeImage.SaveEx(dib, @"test.png")); + Assert.IsTrue(File.Exists(@"test.png")); + format = FreeImage.GetFileType(@"test.png", 0); + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_PNG, format); + File.Delete(@"test.png"); + Assert.IsFalse(File.Exists(@"test.png")); + + Assert.IsTrue(FreeImage.SaveEx(ref dib, @"test.tiff", FREE_IMAGE_SAVE_FLAGS.DEFAULT, false)); + Assert.IsTrue(File.Exists(@"test.tiff")); + format = FreeImage.GetFileType(@"test.tiff", 0); + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_TIFF, format); + File.Delete(@"test.tiff"); + Assert.IsFalse(File.Exists(@"test.tiff")); + + Assert.IsTrue(FreeImage.SaveEx( + ref dib, + @"test.gif", + FREE_IMAGE_FORMAT.FIF_UNKNOWN, + FREE_IMAGE_SAVE_FLAGS.DEFAULT, + FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP, + false)); + + Assert.IsTrue(File.Exists(@"test.gif")); + format = FreeImage.GetFileType(@"test.gif", 0); + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_GIF, format); + File.Delete(@"test.gif"); + Assert.IsFalse(File.Exists(@"test.gif")); + + Assert.IsFalse(FreeImage.SaveEx(dib, @"")); + Assert.IsFalse(FreeImage.SaveEx(dib, @"test.test")); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_LoadFromStream() + { + FREE_IMAGE_FORMAT format; + FileStream fStream; + + fStream = new FileStream(iManager.GetBitmapPath(ImageType.Odd, ImageColorType.Type_16_565), FileMode.Open); + Assert.IsNotNull(fStream); + + dib = FreeImage.LoadFromStream(fStream); + Assert.That(!dib.IsNull); + Assert.That(FreeImage.GetBPP(dib) == 16); + Assert.That(FreeImage.GetGreenMask(dib) == FreeImage.FI16_565_GREEN_MASK); + + FreeImage.UnloadEx(ref dib); + fStream.Close(); + + fStream = new FileStream(iManager.GetBitmapPath(ImageType.Metadata, ImageColorType.Type_01_Dither), FileMode.Open); + Assert.IsNotNull(fStream); + + format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + dib = FreeImage.LoadFromStream(fStream, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + Assert.That(!dib.IsNull); + Assert.That(FreeImage.GetBPP(dib) == 24); + Assert.That(format == FREE_IMAGE_FORMAT.FIF_JPEG); + FreeImage.UnloadEx(ref dib); + fStream.Close(); + + fStream = new FileStream(iManager.GetBitmapPath(ImageType.Even, ImageColorType.Type_32), FileMode.Open); + format = FREE_IMAGE_FORMAT.FIF_TIFF; + dib = FreeImage.LoadFromStream(fStream, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref format); + Assert.That(!dib.IsNull); + Assert.That(FreeImage.GetBPP(dib) == 32); + Assert.That(format == FREE_IMAGE_FORMAT.FIF_TIFF); + + FreeImage.UnloadEx(ref dib); + + Assert.That(dib.IsNull); + dib = FreeImage.LoadFromStream(new MemoryStream(new byte[] { })); + Assert.That(dib.IsNull); + + format = FREE_IMAGE_FORMAT.FIF_BMP; + fStream.Position = 0; + dib = FreeImage.LoadFromStream(fStream, ref format); + Assert.That(dib.IsNull); + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_BMP, format); + + fStream.Close(); + } + + [Test] + public void FreeImage_SaveToStream() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_08_Greyscale_MinIsBlack); + Assert.That(!dib.IsNull); + + Stream stream = new FileStream(@"out_stream.bmp", FileMode.Create); + Assert.IsNotNull(stream); + + Assert.IsTrue(FreeImage.SaveEx(ref dib, @"out_file.bmp", FREE_IMAGE_FORMAT.FIF_BMP, false)); + Assert.IsTrue(FreeImage.SaveToStream(dib, stream, FREE_IMAGE_FORMAT.FIF_BMP)); + stream.Flush(); + stream.Dispose(); + + Assert.IsTrue(File.Exists(@"out_stream.bmp")); + Assert.IsTrue(File.Exists(@"out_file.bmp")); + byte[] buffer1 = File.ReadAllBytes(@"out_stream.bmp"); + byte[] buffer2 = File.ReadAllBytes(@"out_file.bmp"); + Assert.AreEqual(buffer1.Length, buffer2.Length); + for (int i = 0; i < buffer1.Length; i++) + if (buffer1[i] != buffer2[i]) + Assert.Fail(); + + File.Delete(@"out_stream.bmp"); + File.Delete(@"out_file.bmp"); + Assert.IsFalse(File.Exists(@"out_stream.bmp")); + Assert.IsFalse(File.Exists(@"out_file.bmp")); + + stream = new MemoryStream(); + Assert.IsFalse(FreeImage.SaveToStream(dib, stream, FREE_IMAGE_FORMAT.FIF_FAXG3)); + stream.Dispose(); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_IsExtensionValidForFIF() + { + Assert.IsTrue(FreeImage.IsExtensionValidForFIF(FREE_IMAGE_FORMAT.FIF_BMP, "bmp", StringComparison.CurrentCultureIgnoreCase)); + Assert.IsTrue(FreeImage.IsExtensionValidForFIF(FREE_IMAGE_FORMAT.FIF_BMP, "BMP", StringComparison.CurrentCultureIgnoreCase)); + Assert.IsFalse(FreeImage.IsExtensionValidForFIF(FREE_IMAGE_FORMAT.FIF_BMP, "DUMMY", StringComparison.CurrentCultureIgnoreCase)); + Assert.IsTrue(FreeImage.IsExtensionValidForFIF(FREE_IMAGE_FORMAT.FIF_PCX, "pcx", StringComparison.CurrentCultureIgnoreCase)); + Assert.IsTrue(FreeImage.IsExtensionValidForFIF(FREE_IMAGE_FORMAT.FIF_TIFF, "tif", StringComparison.CurrentCultureIgnoreCase)); + Assert.IsTrue(FreeImage.IsExtensionValidForFIF(FREE_IMAGE_FORMAT.FIF_TIFF, "TIFF", StringComparison.CurrentCultureIgnoreCase)); + Assert.IsFalse(FreeImage.IsExtensionValidForFIF(FREE_IMAGE_FORMAT.FIF_ICO, "ICO", StringComparison.CurrentCulture)); + } + + [Test] + public void FreeImage_IsFilenameValidForFIF() + { + Assert.IsTrue(FreeImage.IsFilenameValidForFIF(FREE_IMAGE_FORMAT.FIF_JPEG, "file.jpg")); + Assert.IsTrue(FreeImage.IsFilenameValidForFIF(FREE_IMAGE_FORMAT.FIF_JPEG, "file.jpeg")); + Assert.IsFalse(FreeImage.IsFilenameValidForFIF(FREE_IMAGE_FORMAT.FIF_JPEG, "file.bmp")); + Assert.IsTrue(FreeImage.IsFilenameValidForFIF(FREE_IMAGE_FORMAT.FIF_GIF, "file.gif")); + Assert.IsTrue(FreeImage.IsFilenameValidForFIF(FREE_IMAGE_FORMAT.FIF_GIF, "file.GIF")); + Assert.IsTrue(FreeImage.IsFilenameValidForFIF(FREE_IMAGE_FORMAT.FIF_GIF, "file.GIF", StringComparison.CurrentCultureIgnoreCase)); + Assert.IsFalse(FreeImage.IsFilenameValidForFIF(FREE_IMAGE_FORMAT.FIF_GIF, "file.txt")); + Assert.IsFalse(FreeImage.IsFilenameValidForFIF(FREE_IMAGE_FORMAT.FIF_UNKNOWN, "file.jpg")); + Assert.IsFalse(FreeImage.IsFilenameValidForFIF(FREE_IMAGE_FORMAT.FIF_UNKNOWN, "file.bmp")); + Assert.IsFalse(FreeImage.IsFilenameValidForFIF(FREE_IMAGE_FORMAT.FIF_UNKNOWN, "file.tif")); + } + + [Test] + public void FreeImage_GetPrimaryExtensionFromFIF() + { + Assert.AreEqual("gif", FreeImage.GetPrimaryExtensionFromFIF(FREE_IMAGE_FORMAT.FIF_GIF)); + Assert.AreEqual("tif", FreeImage.GetPrimaryExtensionFromFIF(FREE_IMAGE_FORMAT.FIF_TIFF)); + Assert.AreNotEqual("tiff", FreeImage.GetPrimaryExtensionFromFIF(FREE_IMAGE_FORMAT.FIF_TIFF)); + Assert.AreEqual("psd", FreeImage.GetPrimaryExtensionFromFIF(FREE_IMAGE_FORMAT.FIF_PSD)); + Assert.AreEqual("iff", FreeImage.GetPrimaryExtensionFromFIF(FREE_IMAGE_FORMAT.FIF_IFF)); + Assert.IsNull(FreeImage.GetPrimaryExtensionFromFIF(FREE_IMAGE_FORMAT.FIF_UNKNOWN)); + } + + [Test] + public void FreeImage_OpenMultiBitmapEx() + { + FIMULTIBITMAP dib = FreeImage.OpenMultiBitmapEx(iManager.GetBitmapPath(ImageType.Multipaged, ImageColorType.Type_01_Dither)); + Assert.IsFalse(dib.IsNull); + Assert.AreEqual(4, FreeImage.GetPageCount(dib)); + FreeImage.CloseMultiBitmap(dib, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + + FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN; + dib = FreeImage.OpenMultiBitmapEx( + iManager.GetBitmapPath(ImageType.Multipaged, ImageColorType.Type_04), ref format, FREE_IMAGE_LOAD_FLAGS.DEFAULT, + false, true, true); + Assert.IsFalse(dib.IsNull); + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_TIFF, format); + FreeImage.CloseMultiBitmap(dib, FREE_IMAGE_SAVE_FLAGS.DEFAULT); + } + + [Test] + public void FreeImage_GetLockedPageCount() + { + FIMULTIBITMAP dib = FreeImage.OpenMultiBitmapEx(iManager.GetBitmapPath(ImageType.Multipaged, ImageColorType.Type_01_Dither)); + FIBITMAP page1, page2, page3; + Assert.IsFalse(dib.IsNull); + Assert.AreEqual(4, FreeImage.GetPageCount(dib)); + Assert.AreEqual(0, FreeImage.GetLockedPageCount(dib)); + + page1 = FreeImage.LockPage(dib, 0); + Assert.AreEqual(1, FreeImage.GetLockedPageCount(dib)); + + page2 = FreeImage.LockPage(dib, 1); + Assert.AreEqual(2, FreeImage.GetLockedPageCount(dib)); + + page3 = FreeImage.LockPage(dib, 2); + Assert.AreEqual(3, FreeImage.GetLockedPageCount(dib)); + + FreeImage.UnlockPage(dib, page3, true); + Assert.AreEqual(2, FreeImage.GetLockedPageCount(dib)); + + FreeImage.UnlockPage(dib, page2, true); + Assert.AreEqual(1, FreeImage.GetLockedPageCount(dib)); + + FreeImage.UnlockPage(dib, page1, true); + Assert.AreEqual(0, FreeImage.GetLockedPageCount(dib)); + + FreeImage.CloseMultiBitmapEx(ref dib); + } + + [Test] + public void FreeImage_GetLockedPages() + { + FIMULTIBITMAP dib = FreeImage.OpenMultiBitmapEx(iManager.GetBitmapPath(ImageType.Multipaged, ImageColorType.Type_01_Dither)); + FIBITMAP page1, page2, page3; + int[] lockedList; + Assert.IsFalse(dib.IsNull); + Assert.AreEqual(4, FreeImage.GetPageCount(dib)); + Assert.AreEqual(0, FreeImage.GetLockedPageCount(dib)); + + page1 = FreeImage.LockPage(dib, 0); + Assert.AreEqual(1, FreeImage.GetLockedPageCount(dib)); + lockedList = FreeImage.GetLockedPages(dib); + Assert.Contains(0, lockedList); + + page2 = FreeImage.LockPage(dib, 1); + Assert.AreEqual(2, FreeImage.GetLockedPageCount(dib)); + lockedList = FreeImage.GetLockedPages(dib); + Assert.Contains(0, lockedList); + Assert.Contains(1, lockedList); + + page3 = FreeImage.LockPage(dib, 3); + Assert.AreEqual(3, FreeImage.GetLockedPageCount(dib)); + lockedList = FreeImage.GetLockedPages(dib); + Assert.Contains(0, lockedList); + Assert.Contains(1, lockedList); + Assert.Contains(3, lockedList); + + FreeImage.UnlockPage(dib, page2, true); + Assert.AreEqual(2, FreeImage.GetLockedPageCount(dib)); + lockedList = FreeImage.GetLockedPages(dib); + Assert.Contains(0, lockedList); + Assert.Contains(3, lockedList); + + FreeImage.UnlockPage(dib, page1, true); + Assert.AreEqual(1, FreeImage.GetLockedPageCount(dib)); + lockedList = FreeImage.GetLockedPages(dib); + Assert.Contains(3, lockedList); + + FreeImage.UnlockPage(dib, page3, true); + Assert.AreEqual(0, FreeImage.GetLockedPageCount(dib)); + lockedList = FreeImage.GetLockedPages(dib); + Assert.AreEqual(0, lockedList.Length); + + FreeImage.CloseMultiBitmapEx(ref dib); + } + + [Test] + public void FreeImage_GetFileTypeFromStream() + { + FileStream fStream = new FileStream(iManager.GetBitmapPath(ImageType.JPEG, ImageColorType.Type_01_Dither), FileMode.Open); + Assert.IsNotNull(fStream); + + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_JPEG, FreeImage.GetFileTypeFromStream(fStream)); + fStream.Dispose(); + + fStream = new FileStream(iManager.GetBitmapPath(ImageType.Odd, ImageColorType.Type_16_565), FileMode.Open); + Assert.AreEqual(FREE_IMAGE_FORMAT.FIF_BMP, FreeImage.GetFileTypeFromStream(fStream)); + fStream.Close(); + } + + [Test] + public void FreeImage_GetHbitmap() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.IsFalse(dib.IsNull); + + IntPtr hBitmap = FreeImage.GetHbitmap(dib, IntPtr.Zero, false); + Bitmap bitmap = Bitmap.FromHbitmap(hBitmap); + Assert.IsNotNull(bitmap); + Assert.AreEqual(FreeImage.GetWidth(dib), bitmap.Width); + Assert.AreEqual(FreeImage.GetHeight(dib), bitmap.Height); + + bitmap.Dispose(); + FreeImage.FreeHbitmap(hBitmap); + FreeImage.UnloadEx(ref dib); + + try + { + hBitmap = FreeImage.GetHbitmap(dib, IntPtr.Zero, false); + Assert.Fail(); + } + catch + { + } + } + + [Test] + public void FreeImage_GetResolutionX() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.IsFalse(dib.IsNull); + + Assert.AreEqual(72, FreeImage.GetResolutionX(dib)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetResolutionY() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.IsFalse(dib.IsNull); + + Assert.AreEqual(72, FreeImage.GetResolutionY(dib)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetResolutionX() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.IsFalse(dib.IsNull); + + Assert.AreEqual(72, FreeImage.GetResolutionX(dib)); + + FreeImage.SetResolutionX(dib, 12u); + Assert.AreEqual(12, FreeImage.GetResolutionX(dib)); + + FreeImage.SetResolutionX(dib, 1u); + Assert.AreEqual(1, FreeImage.GetResolutionX(dib)); + + FreeImage.SetResolutionX(dib, 66u); + Assert.AreEqual(66, FreeImage.GetResolutionX(dib)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetResolutionY() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24); + Assert.IsFalse(dib.IsNull); + + Assert.AreEqual(72, FreeImage.GetResolutionY(dib)); + + FreeImage.SetResolutionY(dib, 12u); + Assert.AreEqual(12, FreeImage.GetResolutionY(dib)); + + FreeImage.SetResolutionY(dib, 1u); + Assert.AreEqual(1, FreeImage.GetResolutionY(dib)); + + FreeImage.SetResolutionY(dib, 66u); + Assert.AreEqual(66, FreeImage.GetResolutionY(dib)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_IsGreyscaleImage() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.IsFalse(FreeImage.IsGreyscaleImage(dib)); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_04_Greyscale_Unordered); + Assert.IsTrue(FreeImage.IsGreyscaleImage(dib)); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_04_Greyscale_MinIsBlack); + Assert.IsTrue(FreeImage.IsGreyscaleImage(dib)); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetPaletteEx() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Palette palette = null; + + try + { + palette = FreeImage.GetPaletteEx(dib); + Assert.Fail(); + } + catch + { + } + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_08_Greyscale_MinIsBlack); + try + { + palette = FreeImage.GetPaletteEx(dib); + } + catch + { + Assert.Fail(); + } + Assert.AreEqual(256, palette.Length); + for (int index = 0; index < 256; index++) + { + Assert.AreEqual(index, palette[index].rgbRed); + Assert.AreEqual(index, palette[index].rgbGreen); + Assert.AreEqual(index, palette[index].rgbBlue); + } + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetInfoHeaderEx() + { + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_04); + Assert.IsFalse(dib.IsNull); + + BITMAPINFOHEADER iHeader = FreeImage.GetInfoHeaderEx(dib); + Assert.AreEqual(4, iHeader.biBitCount); + Assert.AreEqual(FreeImage.GetWidth(dib), iHeader.biWidth); + Assert.AreEqual(FreeImage.GetHeight(dib), iHeader.biHeight); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_01_Dither); + Assert.IsFalse(dib.IsNull); + + iHeader = FreeImage.GetInfoHeaderEx(dib); + Assert.AreEqual(1, iHeader.biBitCount); + Assert.AreEqual(FreeImage.GetWidth(dib), iHeader.biWidth); + Assert.AreEqual(FreeImage.GetHeight(dib), iHeader.biHeight); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.IsFalse(dib.IsNull); + + iHeader = FreeImage.GetInfoHeaderEx(dib); + Assert.AreEqual(24, iHeader.biBitCount); + Assert.AreEqual(FreeImage.GetWidth(dib), iHeader.biWidth); + Assert.AreEqual(FreeImage.GetHeight(dib), iHeader.biHeight); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetInfoEx() + { + BITMAPINFO info; + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_01_Dither); + Assert.That(!dib.IsNull); + info = FreeImage.GetInfoEx(dib); + Assert.AreEqual(FreeImage.GetBPP(dib), info.bmiHeader.biBitCount); + Assert.AreEqual(FreeImage.GetWidth(dib), info.bmiHeader.biWidth); + Assert.AreEqual(FreeImage.GetHeight(dib), info.bmiHeader.biHeight); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_04_Greyscale_MinIsBlack); + Assert.That(!dib.IsNull); + info = FreeImage.GetInfoEx(dib); + Assert.AreEqual(FreeImage.GetBPP(dib), info.bmiHeader.biBitCount); + Assert.AreEqual(FreeImage.GetWidth(dib), info.bmiHeader.biWidth); + Assert.AreEqual(FreeImage.GetHeight(dib), info.bmiHeader.biHeight); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_08_Greyscale_Unordered); + Assert.That(!dib.IsNull); + info = FreeImage.GetInfoEx(dib); + Assert.AreEqual(FreeImage.GetBPP(dib), info.bmiHeader.biBitCount); + Assert.AreEqual(FreeImage.GetWidth(dib), info.bmiHeader.biWidth); + Assert.AreEqual(FreeImage.GetHeight(dib), info.bmiHeader.biHeight); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_16_555); + Assert.That(!dib.IsNull); + info = FreeImage.GetInfoEx(dib); + Assert.AreEqual(FreeImage.GetBPP(dib), info.bmiHeader.biBitCount); + Assert.AreEqual(FreeImage.GetWidth(dib), info.bmiHeader.biWidth); + Assert.AreEqual(FreeImage.GetHeight(dib), info.bmiHeader.biHeight); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_16_565); + Assert.That(!dib.IsNull); + info = FreeImage.GetInfoEx(dib); + Assert.AreEqual(FreeImage.GetBPP(dib), info.bmiHeader.biBitCount); + Assert.AreEqual(FreeImage.GetWidth(dib), info.bmiHeader.biWidth); + Assert.AreEqual(FreeImage.GetHeight(dib), info.bmiHeader.biHeight); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_24); + Assert.That(!dib.IsNull); + info = FreeImage.GetInfoEx(dib); + Assert.AreEqual(FreeImage.GetBPP(dib), info.bmiHeader.biBitCount); + Assert.AreEqual(FreeImage.GetWidth(dib), info.bmiHeader.biWidth); + Assert.AreEqual(FreeImage.GetHeight(dib), info.bmiHeader.biHeight); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.That(!dib.IsNull); + info = FreeImage.GetInfoEx(dib); + Assert.AreEqual(FreeImage.GetBPP(dib), info.bmiHeader.biBitCount); + Assert.AreEqual(FreeImage.GetWidth(dib), info.bmiHeader.biWidth); + Assert.AreEqual(FreeImage.GetHeight(dib), info.bmiHeader.biHeight); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetPixelFormat() + { + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_01_Threshold); + Assert.IsFalse(dib.IsNull); + + Assert.AreEqual(PixelFormat.Format1bppIndexed, FreeImage.GetPixelFormat(dib)); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_04_Greyscale_Unordered); + Assert.IsFalse(dib.IsNull); + + Assert.AreEqual(PixelFormat.Format4bppIndexed, FreeImage.GetPixelFormat(dib)); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_16_555); + Assert.IsFalse(dib.IsNull); + + Assert.AreEqual(PixelFormat.Format16bppRgb555, FreeImage.GetPixelFormat(dib)); + FreeImage.UnloadEx(ref dib); + + dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_16_565); + Assert.IsFalse(dib.IsNull); + + Assert.AreEqual(PixelFormat.Format16bppRgb565, FreeImage.GetPixelFormat(dib)); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetFormatParameters() + { + uint bpp, red, green, blue; + FREE_IMAGE_TYPE type; + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format16bppArgb1555, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(16, bpp); + Assert.AreEqual(red, FreeImage.FI16_555_RED_MASK); + Assert.AreEqual(green, FreeImage.FI16_555_GREEN_MASK); + Assert.AreEqual(blue, FreeImage.FI16_555_BLUE_MASK); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_BITMAP); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format16bppGrayScale, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(16, bpp); + Assert.AreEqual(red, 0); + Assert.AreEqual(green, 0); + Assert.AreEqual(blue, 0); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_UINT16); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format16bppRgb555, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(16, bpp); + Assert.AreEqual(red, FreeImage.FI16_555_RED_MASK); + Assert.AreEqual(green, FreeImage.FI16_555_GREEN_MASK); + Assert.AreEqual(blue, FreeImage.FI16_555_BLUE_MASK); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_BITMAP); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format16bppRgb565, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(16, bpp); + Assert.AreEqual(red, FreeImage.FI16_565_RED_MASK); + Assert.AreEqual(green, FreeImage.FI16_565_GREEN_MASK); + Assert.AreEqual(blue, FreeImage.FI16_565_BLUE_MASK); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_BITMAP); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format1bppIndexed, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(1, bpp); + Assert.AreEqual(red, 0); + Assert.AreEqual(green, 0); + Assert.AreEqual(blue, 0); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_BITMAP); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format24bppRgb, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(24, bpp); + Assert.AreEqual(red, FreeImage.FI_RGBA_RED_MASK); + Assert.AreEqual(green, FreeImage.FI_RGBA_GREEN_MASK); + Assert.AreEqual(blue, FreeImage.FI_RGBA_BLUE_MASK); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_BITMAP); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format32bppArgb, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(32, bpp); + Assert.AreEqual(red, FreeImage.FI_RGBA_RED_MASK); + Assert.AreEqual(green, FreeImage.FI_RGBA_GREEN_MASK); + Assert.AreEqual(blue, FreeImage.FI_RGBA_BLUE_MASK); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_BITMAP); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format32bppPArgb, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(32, bpp); + Assert.AreEqual(red, FreeImage.FI_RGBA_RED_MASK); + Assert.AreEqual(green, FreeImage.FI_RGBA_GREEN_MASK); + Assert.AreEqual(blue, FreeImage.FI_RGBA_BLUE_MASK); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_BITMAP); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format32bppRgb, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(32, bpp); + Assert.AreEqual(red, FreeImage.FI_RGBA_RED_MASK); + Assert.AreEqual(green, FreeImage.FI_RGBA_GREEN_MASK); + Assert.AreEqual(blue, FreeImage.FI_RGBA_BLUE_MASK); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_BITMAP); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format48bppRgb, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(48, bpp); + Assert.AreEqual(red, 0); + Assert.AreEqual(green, 0); + Assert.AreEqual(blue, 0); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_RGB16); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format4bppIndexed, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(4, bpp); + Assert.AreEqual(red, 0); + Assert.AreEqual(green, 0); + Assert.AreEqual(blue, 0); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_BITMAP); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format64bppArgb, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(64, bpp); + Assert.AreEqual(red, 0); + Assert.AreEqual(green, 0); + Assert.AreEqual(blue, 0); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_RGBA16); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format64bppPArgb, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(64, bpp); + Assert.AreEqual(red, 0); + Assert.AreEqual(green, 0); + Assert.AreEqual(blue, 0); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_RGBA16); + + Assert.IsTrue(FreeImage.GetFormatParameters(PixelFormat.Format8bppIndexed, out type, out bpp, out red, out green, out blue)); + Assert.AreEqual(8, bpp); + Assert.AreEqual(red, 0); + Assert.AreEqual(green, 0); + Assert.AreEqual(blue, 0); + Assert.AreEqual(type, FREE_IMAGE_TYPE.FIT_BITMAP); + } + + [Test] + public void FreeImage_Compare() + { + FIBITMAP dib2; + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_01_Dither); + Assert.IsFalse(dib.IsNull); + dib2 = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_01_Threshold); + Assert.IsFalse(dib2.IsNull); + + Assert.IsFalse(FreeImage.Compare(dib, dib2, FREE_IMAGE_COMPARE_FLAGS.COMPLETE)); + Assert.IsTrue(FreeImage.Compare(dib, dib2, FREE_IMAGE_COMPARE_FLAGS.HEADER)); + + FreeImage.UnloadEx(ref dib); + FreeImage.UnloadEx(ref dib2); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_04_Greyscale_MinIsBlack); + dib2 = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_04_Greyscale_Unordered); + + Assert.IsFalse(FreeImage.Compare(dib, dib2, FREE_IMAGE_COMPARE_FLAGS.COMPLETE)); + + FreeImage.UnloadEx(ref dib); + FreeImage.UnloadEx(ref dib2); + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + dib2 = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_32); + Assert.IsTrue(FreeImage.Compare(dib, dib2, FREE_IMAGE_COMPARE_FLAGS.COMPLETE)); + + FreeImage.UnloadEx(ref dib); + FreeImage.UnloadEx(ref dib2); + + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.IsFalse(dib.IsNull); + dib2 = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.IsFalse(dib2.IsNull); + + Assert.IsTrue(FreeImage.Compare(dib, dib2, FREE_IMAGE_COMPARE_FLAGS.COMPLETE)); + + FreeImage.UnloadEx(ref dib); + FreeImage.UnloadEx(ref dib2); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_16_555); + Assert.IsFalse(dib.IsNull); + dib2 = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_16_555); + Assert.IsFalse(dib2.IsNull); + + Assert.IsTrue(FreeImage.Compare(dib, dib2, FREE_IMAGE_COMPARE_FLAGS.COMPLETE)); + + FreeImage.UnloadEx(ref dib); + FreeImage.UnloadEx(ref dib2); + + dib = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_16_565); + Assert.IsFalse(dib.IsNull); + dib2 = iManager.GetBitmap(ImageType.Even, ImageColorType.Type_16_565); + Assert.IsFalse(dib2.IsNull); + + Assert.IsTrue(FreeImage.Compare(dib, dib2, FREE_IMAGE_COMPARE_FLAGS.COMPLETE)); + + FreeImage.UnloadEx(ref dib); + FreeImage.UnloadEx(ref dib2); + } + + [Test] + public void FreeImage_CreateICCProfileEx() + { + FIICCPROFILE prof; + byte[] data = new byte[173]; + Random rand = new Random(DateTime.Now.Millisecond); + dib = FreeImage.AllocateT(FREE_IMAGE_TYPE.FIT_BITMAP, 1, 1, 1, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + prof = FreeImage.GetICCProfileEx(dib); + Assert.That(prof.DataPointer == IntPtr.Zero); + + rand.NextBytes(data); + prof = FreeImage.CreateICCProfileEx(dib, data); + Assert.That(prof.Size == data.Length); + for (int i = 0; i < data.Length; i++) + if (prof.Data[i] != data[i]) + Assert.Fail(); + + FreeImage.DestroyICCProfile(dib); + prof = FreeImage.GetICCProfileEx(dib); + Assert.That(prof.DataPointer == IntPtr.Zero); + + FreeImage.CreateICCProfileEx(dib, new byte[0], 0); + prof = FreeImage.GetICCProfileEx(dib); + Assert.That(prof.DataPointer == IntPtr.Zero); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_ConvertColorDepth() + { + int bpp = 1; + FIBITMAP dib2; + + dib = FreeImage.AllocateT(FREE_IMAGE_TYPE.FIT_BITMAP, 80, 80, 1, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + do + { + dib2 = FreeImage.ConvertColorDepth(dib, (FREE_IMAGE_COLOR_DEPTH)bpp); + Assert.IsFalse(dib2.IsNull); + Assert.AreEqual(bpp, FreeImage.GetBPP(dib2)); + if (dib != dib2) + FreeImage.UnloadEx(ref dib2); + } while (0 != (bpp = FreeImage.GetNextColorDepth(bpp))); + + FreeImage.UnloadEx(ref dib); + + dib = FreeImage.AllocateT(FREE_IMAGE_TYPE.FIT_BITMAP, 80, 80, 32, + FreeImage.FI_RGBA_RED_MASK, FreeImage.FI_RGBA_GREEN_MASK, FreeImage.FI_RGBA_BLUE_MASK); + Assert.IsFalse(dib.IsNull); + bpp = 32; + + do + { + dib2 = FreeImage.ConvertColorDepth(dib, (FREE_IMAGE_COLOR_DEPTH)bpp); + Assert.IsFalse(dib2.IsNull); + Assert.AreEqual(bpp, FreeImage.GetBPP(dib2)); + if (dib != dib2) + FreeImage.UnloadEx(ref dib2); + } while (0 != (bpp = FreeImage.GetPrevousColorDepth(bpp))); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetNextColorDepth() + { + Assert.AreEqual(0, FreeImage.GetNextColorDepth(5)); + Assert.AreEqual(0, FreeImage.GetNextColorDepth(0)); + Assert.AreEqual(4, FreeImage.GetNextColorDepth(1)); + Assert.AreEqual(8, FreeImage.GetNextColorDepth(4)); + Assert.AreEqual(16, FreeImage.GetNextColorDepth(8)); + Assert.AreEqual(24, FreeImage.GetNextColorDepth(16)); + Assert.AreEqual(32, FreeImage.GetNextColorDepth(24)); + Assert.AreEqual(0, FreeImage.GetNextColorDepth(32)); + } + + [Test] + public void FreeImage_GetPrevousColorDepth() + { + Assert.AreEqual(0, FreeImage.GetNextColorDepth(5)); + Assert.AreEqual(0, FreeImage.GetNextColorDepth(0)); + Assert.AreEqual(4, FreeImage.GetNextColorDepth(1)); + Assert.AreEqual(8, FreeImage.GetNextColorDepth(4)); + Assert.AreEqual(16, FreeImage.GetNextColorDepth(8)); + Assert.AreEqual(24, FreeImage.GetNextColorDepth(16)); + Assert.AreEqual(32, FreeImage.GetNextColorDepth(24)); + Assert.AreEqual(0, FreeImage.GetNextColorDepth(32)); + } + + [Test] + public unsafe void FreeImage_PtrToStr() + { + string testString; + string resString; + IntPtr buffer; + int index; + + testString = "Test string"; + buffer = Marshal.AllocHGlobal(testString.Length + 1); + + for (index = 0; index < testString.Length; index++) + { + Marshal.WriteByte(buffer, index, (byte)testString[index]); + } + Marshal.WriteByte(buffer, index, (byte)0); + + resString = FreeImage.PtrToStr((byte*)buffer); + Assert.That(resString == testString); + + Marshal.FreeHGlobal(buffer); + + testString = @"äöü?=§%/!)§(%&)(§"; + buffer = Marshal.AllocHGlobal(testString.Length + 1); + + for (index = 0; index < testString.Length; index++) + { + Marshal.WriteByte(buffer, index, (byte)testString[index]); + } + Marshal.WriteByte(buffer, index, (byte)0); + + resString = FreeImage.PtrToStr((byte*)buffer); + Assert.That(resString == testString); + + Marshal.FreeHGlobal(buffer); + } + + [Test] + public void FreeImage_CopyMetadata() + { + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.IsFalse(dib.IsNull); + int mdCount = 0; + + FIBITMAP dib2 = FreeImage.Allocate(1, 1, 1, 0, 0, 0); + Assert.IsFalse(dib2.IsNull); + + FREE_IMAGE_MDMODEL[] modelList = (FREE_IMAGE_MDMODEL[])Enum.GetValues(typeof(FREE_IMAGE_MDMODEL)); + FITAG tag, tag2; + FIMETADATA mdHandle; + + foreach (FREE_IMAGE_MDMODEL model in modelList) + { + mdHandle = FreeImage.FindFirstMetadata(model, dib2, out tag); + Assert.IsTrue(mdHandle.IsNull); + mdCount += (int)FreeImage.GetMetadataCount(model, dib); + } + + Assert.AreEqual(mdCount, FreeImage.CloneMetadataEx(dib, dib2, FREE_IMAGE_METADATA_COPY.CLEAR_EXISTING)); + + foreach (FREE_IMAGE_MDMODEL model in modelList) + { + mdHandle = FreeImage.FindFirstMetadata(model, dib, out tag); + if (!mdHandle.IsNull) + { + do + { + Assert.IsTrue(FreeImage.GetMetadata(model, dib2, FreeImage.GetTagKey(tag), out tag2)); + Assert.That(FreeImage.GetTagCount(tag) == FreeImage.GetTagCount(tag2)); + Assert.That(FreeImage.GetTagDescription(tag) == FreeImage.GetTagDescription(tag2)); + Assert.That(FreeImage.GetTagID(tag) == FreeImage.GetTagID(tag2)); + Assert.That(FreeImage.GetTagKey(tag) == FreeImage.GetTagKey(tag2)); + Assert.That(FreeImage.GetTagLength(tag) == FreeImage.GetTagLength(tag2)); + Assert.That(FreeImage.GetTagType(tag) == FreeImage.GetTagType(tag2)); + } + while (FreeImage.FindNextMetadata(mdHandle, out tag)); + FreeImage.FindCloseMetadata(mdHandle); + } + } + + Assert.AreEqual(0, FreeImage.CloneMetadataEx(dib, dib2, FREE_IMAGE_METADATA_COPY.KEEP_EXISITNG)); + + foreach (FREE_IMAGE_MDMODEL model in modelList) + { + mdHandle = FreeImage.FindFirstMetadata(model, dib, out tag); + if (!mdHandle.IsNull) + { + do + { + Assert.IsTrue(FreeImage.GetMetadata(model, dib2, FreeImage.GetTagKey(tag), out tag2)); + Assert.AreEqual(FreeImage.GetTagCount(tag), FreeImage.GetTagCount(tag2)); + Assert.AreEqual(FreeImage.GetTagDescription(tag), FreeImage.GetTagDescription(tag2)); + Assert.AreEqual(FreeImage.GetTagID(tag), FreeImage.GetTagID(tag2)); + Assert.AreEqual(FreeImage.GetTagKey(tag), FreeImage.GetTagKey(tag2)); + Assert.AreEqual(FreeImage.GetTagLength(tag), FreeImage.GetTagLength(tag2)); + Assert.AreEqual(FreeImage.GetTagType(tag), FreeImage.GetTagType(tag2)); + } + while (FreeImage.FindNextMetadata(mdHandle, out tag)); + FreeImage.FindCloseMetadata(mdHandle); + } + } + + const string newTagDescription = "NEW_TAG_DESCRIPTION"; + + Assert.IsTrue(FreeImage.GetMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, dib, "Copyright", out tag)); + Assert.IsTrue(FreeImage.SetTagDescription(tag, newTagDescription)); + Assert.AreEqual(mdCount, FreeImage.CloneMetadataEx(dib, dib2, FREE_IMAGE_METADATA_COPY.REPLACE_EXISTING)); + Assert.IsTrue(FreeImage.GetMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, dib2, "Copyright", out tag2)); + Assert.AreEqual(newTagDescription, FreeImage.GetTagDescription(tag2)); + + FreeImage.UnloadEx(ref dib2); + FreeImage.UnloadEx(ref dib); + + dib2 = FreeImage.Allocate(1, 1, 1, 0, 0, 0); + dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); + + Assert.AreEqual(0, FreeImage.CloneMetadataEx(dib, dib2, FREE_IMAGE_METADATA_COPY.CLEAR_EXISTING)); + + FreeImage.UnloadEx(ref dib2); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetImageComment() + { + dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + const string comment = "C O M M E N T"; + + Assert.IsNull(FreeImage.GetImageComment(dib)); + Assert.IsTrue(FreeImage.SetImageComment(dib, comment)); + Assert.AreEqual(comment, FreeImage.GetImageComment(dib)); + Assert.IsTrue(FreeImage.SetImageComment(dib, null)); + Assert.IsNull(FreeImage.GetImageComment(dib)); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetImageComment() + { + dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + const string comment = "C O M M E N T"; + + Assert.IsNull(FreeImage.GetImageComment(dib)); + Assert.IsTrue(FreeImage.SetImageComment(dib, comment)); + Assert.AreEqual(comment, FreeImage.GetImageComment(dib)); + Assert.IsTrue(FreeImage.SetImageComment(dib, null)); + Assert.IsNull(FreeImage.GetImageComment(dib)); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetMetadata() + { + MetadataTag tag; + + dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); + Assert.IsFalse(dib.IsNull); + + Assert.IsFalse(FreeImage.GetMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, dib, "~~~~~", out tag)); + Assert.IsNull(tag); + + Assert.IsTrue(FreeImage.GetMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, dib, "Artist", out tag)); + Assert.IsFalse(tag.tag.IsNull); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetMetadata() + { + MetadataTag tag; + Random rand = new Random(); + + dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + ushort value = (ushort)rand.Next(); + + tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_CUSTOM); + tag.ID = value; + + Assert.IsTrue(FreeImage.SetMetadata(FREE_IMAGE_MDMODEL.FIMD_CUSTOM, dib, "~~~~~", tag)); + Assert.IsTrue(FreeImage.GetMetadata(FREE_IMAGE_MDMODEL.FIMD_CUSTOM, dib, "~~~~~", out tag)); + Assert.AreEqual(value, tag.ID); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_FindFirstMetadata() + { + MetadataTag tag; + FIMETADATA mdHandle; + dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + FREE_IMAGE_MDMODEL[] models = (FREE_IMAGE_MDMODEL[])Enum.GetValues(typeof(FREE_IMAGE_MDMODEL)); + foreach (FREE_IMAGE_MDMODEL model in models) + { + mdHandle = FreeImage.FindFirstMetadata(model, dib, out tag); + Assert.IsTrue(mdHandle.IsNull); + } + + tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS); + tag.Key = "KEY"; + tag.Value = 12345; + tag.AddToImage(dib); + + mdHandle = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, out tag); + Assert.IsFalse(mdHandle.IsNull); + + FreeImage.FindCloseMetadata(mdHandle); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_FindNextMetadata() + { + MetadataTag tag; + FIMETADATA mdHandle; + dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + FREE_IMAGE_MDMODEL[] models = (FREE_IMAGE_MDMODEL[])Enum.GetValues(typeof(FREE_IMAGE_MDMODEL)); + foreach (FREE_IMAGE_MDMODEL model in models) + { + mdHandle = FreeImage.FindFirstMetadata(model, dib, out tag); + Assert.IsTrue(mdHandle.IsNull); + } + + tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS); + tag.Key = "KEY1"; + tag.Value = 12345; + tag.AddToImage(dib); + + tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS); + tag.Key = "KEY2"; + tag.Value = 54321; + tag.AddToImage(dib); + + mdHandle = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, out tag); + Assert.IsFalse(mdHandle.IsNull); + + Assert.IsTrue(FreeImage.FindNextMetadata(mdHandle, out tag)); + Assert.IsFalse(FreeImage.FindNextMetadata(mdHandle, out tag)); + + FreeImage.FindCloseMetadata(mdHandle); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_SetGetTransparencyTableEx() + { + dib = FreeImage.Allocate(10, 10, 6, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + byte[] transTable = FreeImage.GetTransparencyTableEx(dib); + Assert.That(transTable.Length == 0); + + Random rand = new Random(); + transTable = new byte[rand.Next(0, 255)]; + int length = transTable.Length; + + for (int i = 0; i < transTable.Length; i++) + transTable[i] = (byte)i; + + FreeImage.SetTransparencyTable(dib, transTable); + transTable = null; + transTable = FreeImage.GetTransparencyTableEx(dib); + Assert.That(transTable.Length == length); + for (int i = 0; i < transTable.Length; i++) + Assert.That(transTable[i] == i); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_GetUniqueColors() + { + Palette palette; + + // + // 1bpp + // + + dib = FreeImage.Allocate(10, 1, 1, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + palette = new Palette(dib); + palette[0] = Color.FromArgb(43, 255, 255, 255); + palette[1] = Color.FromArgb(222, 0, 0, 0); + + Scanline sl1bit = new Scanline(dib, 0); + for (int x = 0; x < sl1bit.Length; x++) + { + sl1bit[x] = 0; + } + + Assert.AreEqual(1, FreeImage.GetUniqueColors(dib)); + + sl1bit[5] = 1; + Assert.AreEqual(2, FreeImage.GetUniqueColors(dib)); + + palette[1] = Color.FromArgb(222, 255, 255, 255); + Assert.AreEqual(1, FreeImage.GetUniqueColors(dib)); + + sl1bit[5] = 0; + Assert.AreEqual(1, FreeImage.GetUniqueColors(dib)); + + FreeImage.UnloadEx(ref dib); + + // + // 4bpp + // + + dib = FreeImage.Allocate(10, 1, 4, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + palette = new Palette(dib); + palette[0] = new RGBQUAD(Color.FromArgb(43, 255, 255, 255)); + palette[1] = new RGBQUAD(Color.FromArgb(222, 51, 2, 211)); + palette[2] = new RGBQUAD(Color.FromArgb(29, 25, 31, 52)); + palette[3] = new RGBQUAD(Color.FromArgb(173, 142, 61, 178)); + palette[4] = new RGBQUAD(Color.FromArgb(143, 41, 67, 199)); + palette[5] = new RGBQUAD(Color.FromArgb(2, 0, 2, 221)); + + Scanline sl4bit = new Scanline(dib, 0); + + for (int x = 0; x < sl4bit.Length; x++) + { + sl4bit[x] = 0; + } + + Assert.AreEqual(1, FreeImage.GetUniqueColors(dib)); + + sl4bit[1] = 1; + Assert.AreEqual(2, FreeImage.GetUniqueColors(dib)); + + sl4bit[2] = 1; + Assert.AreEqual(2, FreeImage.GetUniqueColors(dib)); + + sl4bit[3] = 2; + Assert.AreEqual(3, FreeImage.GetUniqueColors(dib)); + + sl4bit[4] = 3; + Assert.AreEqual(4, FreeImage.GetUniqueColors(dib)); + + sl4bit[5] = 4; + Assert.AreEqual(5, FreeImage.GetUniqueColors(dib)); + + sl4bit[6] = 5; + Assert.AreEqual(6, FreeImage.GetUniqueColors(dib)); + + sl4bit[7] = 6; + Assert.AreEqual(7, FreeImage.GetUniqueColors(dib)); + + sl4bit[8] = 7; + Assert.AreEqual(7, FreeImage.GetUniqueColors(dib)); + + sl4bit[9] = 7; + Assert.AreEqual(7, FreeImage.GetUniqueColors(dib)); + + FreeImage.UnloadEx(ref dib); + + // + // 8bpp + // + + dib = FreeImage.Allocate(10, 1, 8, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + palette = new Palette(dib); + palette[0] = new RGBQUAD(Color.FromArgb(43, 255, 255, 255)); + palette[1] = new RGBQUAD(Color.FromArgb(222, 51, 2, 211)); + palette[2] = new RGBQUAD(Color.FromArgb(29, 25, 31, 52)); + palette[3] = new RGBQUAD(Color.FromArgb(173, 142, 61, 178)); + palette[4] = new RGBQUAD(Color.FromArgb(143, 41, 67, 199)); + palette[5] = new RGBQUAD(Color.FromArgb(2, 0, 2, 221)); + + Scanline sl8bit = new Scanline(dib, 0); + + for (int x = 0; x < sl8bit.Length; x++) + { + sl8bit[x] = 0; + } + + Assert.AreEqual(1, FreeImage.GetUniqueColors(dib)); + + sl8bit[1] = 1; + Assert.AreEqual(2, FreeImage.GetUniqueColors(dib)); + + sl8bit[2] = 2; + Assert.AreEqual(3, FreeImage.GetUniqueColors(dib)); + + sl8bit[3] = 3; + Assert.AreEqual(4, FreeImage.GetUniqueColors(dib)); + + sl8bit[4] = 4; + Assert.AreEqual(5, FreeImage.GetUniqueColors(dib)); + + sl8bit[5] = 6; + Assert.AreEqual(6, FreeImage.GetUniqueColors(dib)); + + sl8bit[5] = 7; + Assert.AreEqual(6, FreeImage.GetUniqueColors(dib)); + + sl8bit[5] = 8; + Assert.AreEqual(6, FreeImage.GetUniqueColors(dib)); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_CreateShrunkenPaletteLUT() + { + Random rand = new Random(); + dib = FreeImage.Allocate(1, 1, 8, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + Palette palette = new Palette(dib); + byte[] lut; + int colors; + + for (int x = 0; x < palette.Length; x++) + { + palette[x] = 0xFF000000; + } + + lut = FreeImage.CreateShrunkenPaletteLUT(dib, out colors); + Assert.AreEqual(1, colors); + + for (int x = 0; x < palette.Length; x++) + { + Assert.AreEqual(0, lut[x]); + } + + palette[1] = 0x00000001; + lut = FreeImage.CreateShrunkenPaletteLUT(dib, out colors); + Assert.AreEqual(2, colors); + + Assert.AreEqual(0, lut[0]); + Assert.AreEqual(1, lut[1]); + + for (int x = 2; x < palette.Length; x++) + { + Assert.AreEqual(0, lut[x]); + } + + for (int x = 0; x < palette.Length; x++) + { + palette[x] = (uint)x; + } + + lut = FreeImage.CreateShrunkenPaletteLUT(dib, out colors); + Assert.AreEqual(256, colors); + + for (int x = 0; x < palette.Length; x++) + { + Assert.AreEqual(x, lut[x]); + } + + uint[] testColors = new uint[] { 0xFF4F387C, 0xFF749178, 0xFF84D51A, 0xFF746B71, 0x74718163, 0x91648106 }; + palette[0] = testColors[0]; + palette[1] = testColors[1]; + palette[2] = testColors[2]; + palette[3] = testColors[3]; + palette[4] = testColors[4]; + palette[5] = testColors[5]; + + for (int x = testColors.Length; x < palette.Length; x++) + { + palette[x] = testColors[rand.Next(0, testColors.Length - 1)]; + } + + lut = FreeImage.CreateShrunkenPaletteLUT(dib, out colors); + Assert.AreEqual(testColors.Length, colors); + + FreeImage.UnloadEx(ref dib); + } + + [Test] + public void FreeImage_Rotate4bit() + { + Palette orgPal, rotPal; + FIBITMAP rotated; + byte index; + dib = FreeImage.Allocate(2, 3, 4, 0, 0, 0); + Assert.IsFalse(dib.IsNull); + + index = 1; if (!FreeImage.SetPixelIndex(dib, 0, 0, ref index)) throw new Exception(); + index = 2; if (!FreeImage.SetPixelIndex(dib, 1, 0, ref index)) throw new Exception(); + index = 3; if (!FreeImage.SetPixelIndex(dib, 0, 1, ref index)) throw new Exception(); + index = 4; if (!FreeImage.SetPixelIndex(dib, 1, 1, ref index)) throw new Exception(); + index = 5; if (!FreeImage.SetPixelIndex(dib, 0, 2, ref index)) throw new Exception(); + index = 6; if (!FreeImage.SetPixelIndex(dib, 1, 2, ref index)) throw new Exception(); + + // + // 90 deg + // + + rotated = FreeImage.Rotate4bit(dib, 90d); + Assert.IsFalse(rotated.IsNull); + Assert.AreEqual(3, FreeImage.GetWidth(rotated)); + Assert.AreEqual(2, FreeImage.GetHeight(rotated)); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_BITMAP, FreeImage.GetImageType(rotated)); + Assert.AreEqual(4, FreeImage.GetBPP(rotated)); + orgPal = new Palette(dib); + rotPal = new Palette(rotated); + Assert.IsNotNull(orgPal); + Assert.IsNotNull(rotPal); + Assert.AreEqual(orgPal.Length, rotPal.Length); + for (int i = 0; i < orgPal.Length; i++) + { + Assert.AreEqual(orgPal[i], rotPal[i]); + } + + FreeImage.GetPixelIndex(rotated, 0, 0, out index); + Assert.AreEqual(5, index); + FreeImage.GetPixelIndex(rotated, 1, 0, out index); + Assert.AreEqual(3, index); + FreeImage.GetPixelIndex(rotated, 2, 0, out index); + Assert.AreEqual(1, index); + FreeImage.GetPixelIndex(rotated, 0, 1, out index); + Assert.AreEqual(6, index); + FreeImage.GetPixelIndex(rotated, 1, 1, out index); + Assert.AreEqual(4, index); + FreeImage.GetPixelIndex(rotated, 2, 1, out index); + Assert.AreEqual(2, index); + FreeImage.UnloadEx(ref rotated); + + // + // 180 deg + // + + rotated = FreeImage.Rotate4bit(dib, 180d); + Assert.IsFalse(rotated.IsNull); + Assert.AreEqual(FreeImage.GetWidth(dib), FreeImage.GetWidth(rotated)); + Assert.AreEqual(FreeImage.GetHeight(dib), FreeImage.GetHeight(rotated)); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_BITMAP, FreeImage.GetImageType(rotated)); + Assert.AreEqual(4, FreeImage.GetBPP(rotated)); + orgPal = new Palette(dib); + rotPal = new Palette(rotated); + Assert.IsNotNull(orgPal); + Assert.IsNotNull(rotPal); + Assert.AreEqual(orgPal.Length, rotPal.Length); + for (int i = 0; i < orgPal.Length; i++) + { + Assert.AreEqual(orgPal[i], rotPal[i]); + } + + FreeImage.GetPixelIndex(rotated, 0, 0, out index); + Assert.AreEqual(6, index); + FreeImage.GetPixelIndex(rotated, 1, 0, out index); + Assert.AreEqual(5, index); + FreeImage.GetPixelIndex(rotated, 0, 1, out index); + Assert.AreEqual(4, index); + FreeImage.GetPixelIndex(rotated, 1, 1, out index); + Assert.AreEqual(3, index); + FreeImage.GetPixelIndex(rotated, 0, 2, out index); + Assert.AreEqual(2, index); + FreeImage.GetPixelIndex(rotated, 1, 2, out index); + Assert.AreEqual(1, index); + FreeImage.UnloadEx(ref rotated); + + // + // 270 deg + // + + rotated = FreeImage.Rotate4bit(dib, 270d); + Assert.IsFalse(rotated.IsNull); + Assert.AreEqual(3, FreeImage.GetWidth(rotated)); + Assert.AreEqual(2, FreeImage.GetHeight(rotated)); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_BITMAP, FreeImage.GetImageType(rotated)); + Assert.AreEqual(4, FreeImage.GetBPP(rotated)); + orgPal = new Palette(dib); + rotPal = new Palette(rotated); + Assert.IsNotNull(orgPal); + Assert.IsNotNull(rotPal); + Assert.AreEqual(orgPal.Length, rotPal.Length); + for (int i = 0; i < orgPal.Length; i++) + { + Assert.AreEqual(orgPal[i], rotPal[i]); + } + + FreeImage.GetPixelIndex(rotated, 0, 0, out index); + Assert.AreEqual(2, index); + FreeImage.GetPixelIndex(rotated, 1, 0, out index); + Assert.AreEqual(4, index); + FreeImage.GetPixelIndex(rotated, 2, 0, out index); + Assert.AreEqual(6, index); + FreeImage.GetPixelIndex(rotated, 0, 1, out index); + Assert.AreEqual(1, index); + FreeImage.GetPixelIndex(rotated, 1, 1, out index); + Assert.AreEqual(3, index); + FreeImage.GetPixelIndex(rotated, 2, 1, out index); + Assert.AreEqual(5, index); + FreeImage.UnloadEx(ref rotated); + + FreeImage.UnloadEx(ref dib); + } + } + + [TestFixture] + public class FreeImageBitmapTest + { + ImageManager iManager = new ImageManager(); + FIBITMAP dib = new FIBITMAP(); + string freeImageCallback = null; + + [TestFixtureSetUp] + public void Init() + { + FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message); + } + + [TestFixtureTearDown] + public void DeInit() + { + FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message); + } + + [SetUp] + public void InitEachTime() + { + } + + [TearDown] + public void DeInitEachTime() + { + } + + void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message) + { + freeImageCallback = message; + } + + [Test] + public void FreeImageBitmapConstructors() + { + Image bitmap; + FreeImageBitmap fib, fib2; + Stream stream; + Graphics g; + string filename = iManager.GetBitmapPath(ImageType.Odd, ImageColorType.Type_24); + Assert.IsNotNull(filename); + Assert.IsTrue(File.Exists(filename)); + + bitmap = new Bitmap(filename); + Assert.IsNotNull(bitmap); + + fib = new FreeImageBitmap(bitmap); + Assert.AreEqual(bitmap.Width, fib.Width); + Assert.AreEqual(bitmap.Height, fib.Height); + fib.Dispose(); + fib.Dispose(); + + fib = new FreeImageBitmap(bitmap, new Size(100, 100)); + Assert.AreEqual(100, fib.Width); + Assert.AreEqual(100, fib.Height); + fib.Dispose(); + bitmap.Dispose(); + + fib = new FreeImageBitmap(filename); + fib.Dispose(); + + fib = new FreeImageBitmap(filename, FREE_IMAGE_LOAD_FLAGS.DEFAULT); + fib.Dispose(); + + fib = new FreeImageBitmap(filename, FREE_IMAGE_FORMAT.FIF_UNKNOWN); + fib.Dispose(); + + fib = new FreeImageBitmap(filename, FREE_IMAGE_FORMAT.FIF_UNKNOWN, FREE_IMAGE_LOAD_FLAGS.DEFAULT); + fib.Dispose(); + + stream = new FileStream(filename, FileMode.Open); + Assert.IsNotNull(stream); + + fib = new FreeImageBitmap(stream); + fib.Dispose(); + stream.Seek(0, SeekOrigin.Begin); + + fib = new FreeImageBitmap(stream, FREE_IMAGE_FORMAT.FIF_UNKNOWN); + fib.Dispose(); + stream.Seek(0, SeekOrigin.Begin); + + fib = new FreeImageBitmap(stream, FREE_IMAGE_LOAD_FLAGS.DEFAULT); + fib.Dispose(); + stream.Seek(0, SeekOrigin.Begin); + + fib = new FreeImageBitmap(stream, FREE_IMAGE_FORMAT.FIF_UNKNOWN, FREE_IMAGE_LOAD_FLAGS.DEFAULT); + fib.Dispose(); + stream.Dispose(); + + fib = new FreeImageBitmap(100, 100); + Assert.AreEqual(24, fib.ColorDepth); + Assert.AreEqual(100, fib.Width); + Assert.AreEqual(100, fib.Height); + fib.Dispose(); + + using (bitmap = new Bitmap(filename)) + { + Assert.IsNotNull(bitmap); + using (g = Graphics.FromImage(bitmap)) + { + Assert.IsNotNull(g); + fib = new FreeImageBitmap(100, 100, g); + } + } + fib.Dispose(); + + fib = new FreeImageBitmap(100, 100, PixelFormat.Format1bppIndexed); + Assert.AreEqual(PixelFormat.Format1bppIndexed, fib.PixelFormat); + Assert.AreEqual(100, fib.Width); + Assert.AreEqual(100, fib.Height); + fib.Dispose(); + + fib = new FreeImageBitmap(100, 100, PixelFormat.Format4bppIndexed); + Assert.AreEqual(PixelFormat.Format4bppIndexed, fib.PixelFormat); + Assert.AreEqual(100, fib.Width); + Assert.AreEqual(100, fib.Height); + fib.Dispose(); + + fib = new FreeImageBitmap(100, 100, PixelFormat.Format8bppIndexed); + Assert.AreEqual(PixelFormat.Format8bppIndexed, fib.PixelFormat); + Assert.AreEqual(100, fib.Width); + Assert.AreEqual(100, fib.Height); + fib.Dispose(); + + fib = new FreeImageBitmap(100, 100, PixelFormat.Format16bppRgb555); + Assert.AreEqual(PixelFormat.Format16bppRgb555, fib.PixelFormat); + Assert.AreEqual(100, fib.Width); + Assert.AreEqual(100, fib.Height); + fib.Dispose(); + + fib = new FreeImageBitmap(100, 100, PixelFormat.Format16bppRgb565); + Assert.AreEqual(PixelFormat.Format16bppRgb565, fib.PixelFormat); + Assert.AreEqual(100, fib.Width); + Assert.AreEqual(100, fib.Height); + fib.Dispose(); + + fib = new FreeImageBitmap(100, 100, PixelFormat.Format24bppRgb); + Assert.AreEqual(PixelFormat.Format24bppRgb, fib.PixelFormat); + Assert.AreEqual(100, fib.Width); + Assert.AreEqual(100, fib.Height); + fib.Dispose(); + + fib = new FreeImageBitmap(100, 100, PixelFormat.Format32bppArgb); + Assert.AreEqual(PixelFormat.Format32bppArgb, fib.PixelFormat); + Assert.AreEqual(100, fib.Width); + Assert.AreEqual(100, fib.Height); + + stream = new MemoryStream(); + BinaryFormatter formatter = new BinaryFormatter(); + + formatter.Serialize(stream, fib); + Assert.Greater(stream.Length, 0); + stream.Position = 0; + + fib2 = formatter.Deserialize(stream) as FreeImageBitmap; + stream.Dispose(); + fib.Dispose(); + fib2.Dispose(); + + fib = new FreeImageBitmap(filename); + fib2 = new FreeImageBitmap(fib); + fib2.Dispose(); + + fib2 = new FreeImageBitmap(fib, new Size(31, 22)); + Assert.AreEqual(31, fib2.Width); + Assert.AreEqual(22, fib2.Height); + fib2.Dispose(); + fib.Dispose(); + + dib = FreeImage.Allocate(1000, 800, 24, 0xFF0000, 0xFF00, 0xFF); + Assert.IsFalse(dib.IsNull); + + fib = new FreeImageBitmap(1000, 800, -(int)FreeImage.GetPitch(dib), FreeImage.GetPixelFormat(dib), FreeImage.GetScanLine(dib, 0)); + fib.Dispose(); + FreeImage.UnloadEx(ref dib); + } + + [Test] + public unsafe void Properties() + { + string filename = iManager.GetBitmapPath(ImageType.Even, ImageColorType.Type_32); + Assert.IsNotNull(filename); + Assert.IsTrue(File.Exists(filename)); + + FreeImageBitmap fib = new FreeImageBitmap(filename); + Assert.IsFalse(fib.HasPalette); + + try + { + Palette palette = fib.Palette; + Assert.Fail(); + } + catch + { + } + + Assert.IsFalse(fib.HasBackgroundColor); + fib.BackgroundColor = Color.LightSeaGreen; + Assert.IsTrue(fib.HasBackgroundColor); + Assert.That( + Color.LightSeaGreen.B == fib.BackgroundColor.Value.B && + Color.LightSeaGreen.G == fib.BackgroundColor.Value.G && + Color.LightSeaGreen.R == fib.BackgroundColor.Value.R); + fib.BackgroundColor = null; + Assert.IsFalse(fib.HasBackgroundColor); + fib.Dispose(); + + fib = new FreeImageBitmap(100, 100, PixelFormat.Format1bppIndexed); + ImageFlags flags = (ImageFlags)fib.Flags; + Assert.That((flags & ImageFlags.ColorSpaceRgb) == ImageFlags.ColorSpaceRgb); + Assert.That((flags & ImageFlags.HasAlpha) != ImageFlags.HasAlpha); + Assert.That((flags & ImageFlags.HasRealDpi) != ImageFlags.HasRealDpi); + Assert.That((flags & ImageFlags.HasTranslucent) != ImageFlags.HasTranslucent); + fib.Dispose(); + + dib = FreeImage.Allocate(100, 100, 32, 0xFF0000, 0xFF00, 0xFF); + FIICCPROFILE* prof = (FIICCPROFILE*)FreeImage.CreateICCProfile(dib, new byte[] { 0, 1, 2, 3 }, 4); + fib = new FreeImageBitmap(dib); + Scanline sc = (Scanline)fib.GetScanline(0); + RGBQUAD rgbq = sc[0]; + rgbq.rgbReserved = 127; + sc[0] = rgbq; + flags = (ImageFlags)fib.Flags; + Assert.That((flags & ImageFlags.HasAlpha) == ImageFlags.HasAlpha); + Assert.That((flags & ImageFlags.HasRealDpi) != ImageFlags.HasRealDpi); + Assert.That((flags & ImageFlags.HasTranslucent) == ImageFlags.HasTranslucent); + fib.Dispose(); + fib = null; + GC.Collect(2, GCCollectionMode.Forced); + GC.WaitForPendingFinalizers(); + + fib = new FreeImageBitmap(iManager.GetBitmapPath(ImageType.Metadata, ImageColorType.Type_01_Dither)); + int[] propList = fib.PropertyIdList; + Assert.IsNotNull(propList); + Assert.Greater(propList.Length, 0); + PropertyItem[] propItemList = fib.PropertyItems; + Assert.IsNotNull(propItemList); + Assert.Greater(propItemList.Length, 0); + Assert.IsNotNull(fib.RawFormat); + fib.Dispose(); + + fib = new FreeImageBitmap(iManager.GetBitmapPath(ImageType.Multipaged, ImageColorType.Type_01_Dither)); + Assert.Greater(fib.FrameCount, 1); + fib.Dispose(); + } + + [Test] + public void GetBounds() + { + Random rand = new Random(); + int height = rand.Next(1, 100), width = rand.Next(1, 100); + FreeImageBitmap fib = new FreeImageBitmap(width, height, PixelFormat.Format24bppRgb); + + Assert.AreEqual(fib.VerticalResolution, fib.HorizontalResolution); + GraphicsUnit unit; + RectangleF rect; + + unit = GraphicsUnit.Display; + rect = fib.GetBounds(ref unit); + + Assert.AreEqual(GraphicsUnit.Pixel, unit); + Assert.AreEqual(width, (int)rect.Width); + Assert.AreEqual(height, (int)rect.Height); + fib.Dispose(); + } + + [Test] + public void GetPropertyItem() + { + FreeImageBitmap fib = new FreeImageBitmap(iManager.GetBitmapPath(ImageType.Metadata, ImageColorType.Type_01_Dither)); + int[] list = fib.PropertyIdList; + Assert.IsNotNull(list); + Assert.Greater(list.Length, 0); + + for (int i = 0; i < list.Length; i++) + { + PropertyItem item = fib.GetPropertyItem(list[i]); + Assert.IsNotNull(item); + } + fib.Dispose(); + } + + [Test] + public void RemovePropertyItem() + { + FreeImageBitmap fib = new FreeImageBitmap(iManager.GetBitmapPath(ImageType.Metadata, ImageColorType.Type_01_Dither)); + Random rand = new Random(); + int[] list = fib.PropertyIdList; + int length = list.Length; + Assert.Greater(list.Length, 0); + + int id = list[rand.Next(0, list.Length - 1)]; + Assert.IsNotNull(fib.GetPropertyItem(id)); + fib.RemovePropertyItem(id); + list = fib.PropertyIdList; + Assert.That((list.Length + 1) == length); + fib.Dispose(); + } + + [Test] + public unsafe void RotateFlip() + { + FreeImageBitmap fib = new FreeImageBitmap(2, 2, PixelFormat.Format32bppArgb); + + ResetRotateBitmap(fib); + fib.RotateFlip(RotateFlipType.RotateNoneFlipX); + Assert.AreEqual(0x00000002, ((int*)fib.GetScanlinePointer(0))[0]); + Assert.AreEqual(0x00000001, ((int*)fib.GetScanlinePointer(0))[1]); + Assert.AreEqual(0x00000004, ((int*)fib.GetScanlinePointer(1))[0]); + Assert.AreEqual(0x00000003, ((int*)fib.GetScanlinePointer(1))[1]); + + ResetRotateBitmap(fib); + fib.RotateFlip(RotateFlipType.RotateNoneFlipY); + Assert.AreEqual(0x00000003, ((int*)fib.GetScanlinePointer(0))[0]); + Assert.AreEqual(0x00000004, ((int*)fib.GetScanlinePointer(0))[1]); + Assert.AreEqual(0x00000001, ((int*)fib.GetScanlinePointer(1))[0]); + Assert.AreEqual(0x00000002, ((int*)fib.GetScanlinePointer(1))[1]); + + ResetRotateBitmap(fib); + fib.RotateFlip(RotateFlipType.RotateNoneFlipXY); + Assert.AreEqual(0x00000004, ((int*)fib.GetScanlinePointer(0))[0]); + Assert.AreEqual(0x00000003, ((int*)fib.GetScanlinePointer(0))[1]); + Assert.AreEqual(0x00000002, ((int*)fib.GetScanlinePointer(1))[0]); + Assert.AreEqual(0x00000001, ((int*)fib.GetScanlinePointer(1))[1]); + + ResetRotateBitmap(fib); + fib.RotateFlip(RotateFlipType.Rotate90FlipNone); + Assert.AreEqual(0x00000003, ((int*)fib.GetScanlinePointer(0))[0]); + Assert.AreEqual(0x00000001, ((int*)fib.GetScanlinePointer(0))[1]); + Assert.AreEqual(0x00000004, ((int*)fib.GetScanlinePointer(1))[0]); + Assert.AreEqual(0x00000002, ((int*)fib.GetScanlinePointer(1))[1]); + + ResetRotateBitmap(fib); + fib.RotateFlip(RotateFlipType.Rotate90FlipX); + Assert.AreEqual(0x00000001, ((int*)fib.GetScanlinePointer(0))[0]); + Assert.AreEqual(0x00000003, ((int*)fib.GetScanlinePointer(0))[1]); + Assert.AreEqual(0x00000002, ((int*)fib.GetScanlinePointer(1))[0]); + Assert.AreEqual(0x00000004, ((int*)fib.GetScanlinePointer(1))[1]); + + ResetRotateBitmap(fib); + fib.RotateFlip(RotateFlipType.Rotate90FlipY); + Assert.AreEqual(0x00000004, ((int*)fib.GetScanlinePointer(0))[0]); + Assert.AreEqual(0x00000002, ((int*)fib.GetScanlinePointer(0))[1]); + Assert.AreEqual(0x00000003, ((int*)fib.GetScanlinePointer(1))[0]); + Assert.AreEqual(0x00000001, ((int*)fib.GetScanlinePointer(1))[1]); + + fib.Dispose(); + } + + private unsafe void ResetRotateBitmap(FreeImageBitmap fib) + { + ((int*)fib.GetScanlinePointer(0))[0] = 0x00000001; + ((int*)fib.GetScanlinePointer(0))[1] = 0x00000002; + ((int*)fib.GetScanlinePointer(1))[0] = 0x00000003; + ((int*)fib.GetScanlinePointer(1))[1] = 0x00000004; + } + + [Test] + public unsafe void GetSetPixel() + { + Random rand = new Random(); + FreeImageBitmap fib = new FreeImageBitmap(2, 1, PixelFormat.Format1bppIndexed); + Palette palette = fib.Palette; + for (int i = 0; i < palette.Length; i++) + { + palette[i] = (uint)rand.Next(int.MinValue, int.MaxValue); + fib.SetPixel(i, 0, palette[i]); + } + for (int i = 0; i < palette.Length; i++) + { + Assert.AreEqual(fib.GetPixel(i, 0), palette[i].Color); + } + fib.Dispose(); + + fib = new FreeImageBitmap(16, 1, PixelFormat.Format4bppIndexed); + palette = fib.Palette; + for (int i = 0; i < palette.Length; i++) + { + palette[i] = (uint)rand.Next(int.MinValue, int.MaxValue); + fib.SetPixel(i, 0, palette[i]); + } + for (int i = 0; i < palette.Length; i++) + { + Assert.AreEqual(fib.GetPixel(i, 0), palette[i].Color); + } + fib.Dispose(); + + fib = new FreeImageBitmap(256, 1, PixelFormat.Format8bppIndexed); + palette = fib.Palette; + for (int i = 0; i < palette.Length; i++) + { + palette[i] = (uint)rand.Next(int.MinValue, int.MaxValue); + fib.SetPixel(i, 0, palette[i]); + } + for (int i = 0; i < palette.Length; i++) + { + Assert.AreEqual(fib.GetPixel(i, 0), palette[i].Color); + } + fib.Dispose(); + + fib = new FreeImageBitmap(1000, 1, PixelFormat.Format16bppRgb555); + for (int i = 0; i < 1000; i++) + { + Color orgColor = Color.FromArgb(rand.Next(int.MinValue, int.MaxValue)); + fib.SetPixel(i, 0, orgColor); + Color newColor = fib.GetPixel(i, 0); + Assert.That(Math.Abs(orgColor.B - newColor.B) <= 8); + Assert.That(Math.Abs(orgColor.G - newColor.G) <= 8); + Assert.That(Math.Abs(orgColor.R - newColor.R) <= 8); + } + fib.Dispose(); + + fib = new FreeImageBitmap(1000, 1, PixelFormat.Format24bppRgb); + for (int i = 0; i < 1000; i++) + { + Color orgColor = Color.FromArgb(rand.Next(int.MinValue, int.MaxValue)); + fib.SetPixel(i, 0, orgColor); + Color newColor = fib.GetPixel(i, 0); + Assert.AreEqual(orgColor.B, newColor.B); + Assert.AreEqual(orgColor.G, newColor.G); + Assert.AreEqual(orgColor.R, newColor.R); + } + fib.Dispose(); + + fib = new FreeImageBitmap(1000, 1, PixelFormat.Format32bppArgb); + for (int i = 0; i < 1000; i++) + { + Color orgColor = Color.FromArgb(rand.Next(int.MinValue, int.MaxValue)); + fib.SetPixel(i, 0, orgColor); + Color newColor = fib.GetPixel(i, 0); + Assert.AreEqual(orgColor.B, newColor.B); + Assert.AreEqual(orgColor.G, newColor.G); + Assert.AreEqual(orgColor.R, newColor.R); + Assert.AreEqual(orgColor.A, newColor.A); + } + fib.Dispose(); + } + + [Test] + public void SaveAdd() + { + string filename = @"saveadd.tif"; + FreeImageBitmap fib = new FreeImageBitmap(100, 100, PixelFormat.Format24bppRgb); + try + { + fib.SaveAdd(); + Assert.Fail(); + } + catch { } + Assert.IsFalse(File.Exists(filename)); + fib.Save(filename); + fib.AdjustBrightness(0.3d); + fib.SaveAdd(); + FreeImageBitmap other = new FreeImageBitmap(100, 100, PixelFormat.Format24bppRgb); + foreach (Scanline scanline in other) + { + for (int i = 0; i < scanline.Length; i++) + { + scanline[i] = new RGBTRIPLE(Color.FromArgb(0x339955)); + } + } + fib.SaveAdd(other); + other.SaveAdd(filename); + other.Dispose(); + fib.Dispose(); + + fib = new FreeImageBitmap(filename); + Assert.AreEqual(4, fib.FrameCount); + fib.Dispose(); + File.Delete(filename); + Assert.IsFalse(File.Exists(filename)); + } + + [Test] + public void Clone() + { + FreeImageBitmap fib = new FreeImageBitmap(iManager.GetBitmapPath(ImageType.Even, ImageColorType.Type_24)); + object obj = new object(); + fib.Tag = obj; + FreeImageBitmap clone = fib.Clone() as FreeImageBitmap; + Assert.IsNotNull(clone); + Assert.AreEqual(fib.Width, clone.Width); + Assert.AreEqual(fib.Height, clone.Height); + Assert.AreEqual(fib.ColorDepth, clone.ColorDepth); + Assert.AreSame(fib.Tag, clone.Tag); + Assert.AreEqual(fib.ImageFormat, clone.ImageFormat); + clone.Dispose(); + fib.Dispose(); + } + + [Ignore] + public void LockBits() + { + } + + [Ignore] + public void UnlockBits() + { + } + + [Test] + public void GetTypeConvertedInstance() + { + using (FreeImageBitmap fib = new FreeImageBitmap(10, 10, PixelFormat.Format8bppIndexed)) + { + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_BITMAP, fib.ImageType); + using (FreeImageBitmap conv = fib.GetTypeConvertedInstance(FREE_IMAGE_TYPE.FIT_DOUBLE, true)) + { + Assert.IsNotNull(conv); + Assert.AreEqual(FREE_IMAGE_TYPE.FIT_DOUBLE, conv.ImageType); + } + } + } + + [Test] + public void GetColorConvertedInstance() + { + using (FreeImageBitmap fib = new FreeImageBitmap(10, 10, PixelFormat.Format32bppArgb)) + { + Assert.AreEqual(32, fib.ColorDepth); + using (FreeImageBitmap conv = fib.GetColorConvertedInstance(FREE_IMAGE_COLOR_DEPTH.FICD_24_BPP)) + { + Assert.IsNotNull(conv); + Assert.AreEqual(24, conv.ColorDepth); + } + } + } + + [Test] + public void GetScaledInstance() + { + using (FreeImageBitmap fib = new FreeImageBitmap(100, 80, PixelFormat.Format32bppArgb)) + { + Assert.AreEqual(100, fib.Width); + Assert.AreEqual(80, fib.Height); + using (FreeImageBitmap conv = fib.GetScaledInstance(80, 60, FREE_IMAGE_FILTER.FILTER_BICUBIC)) + { + Assert.IsNotNull(conv); + Assert.AreEqual(80, conv.Width); + Assert.AreEqual(60, conv.Height); + } + } + } + + [Test] + public unsafe void GetRotatedInstance() + { + using (FreeImageBitmap fib = new FreeImageBitmap(2, 2, PixelFormat.Format32bppArgb)) + { + ((int*)fib.GetScanlinePointer(0))[0] = 0x1; + ((int*)fib.GetScanlinePointer(0))[1] = 0x2; + ((int*)fib.GetScanlinePointer(1))[0] = 0x3; + ((int*)fib.GetScanlinePointer(1))[1] = 0x4; + using (FreeImageBitmap conv = fib.GetRotatedInstance(90d)) + { + Assert.IsNotNull(conv); + Assert.AreEqual(((int*)conv.GetScanlinePointer(0))[0], 0x3); + Assert.AreEqual(((int*)conv.GetScanlinePointer(0))[1], 0x1); + Assert.AreEqual(((int*)conv.GetScanlinePointer(1))[0], 0x4); + Assert.AreEqual(((int*)conv.GetScanlinePointer(1))[1], 0x2); + } + } + } + + [Test] + public void GetScanline() + { + FreeImageBitmap fib; + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format1bppIndexed); + Scanline scanline1 = (Scanline)fib.GetScanline(0); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format4bppIndexed); + Scanline scanline2 = (Scanline)fib.GetScanline(0); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format8bppIndexed); + Scanline scanline3 = (Scanline)fib.GetScanline(0); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format16bppRgb555); + Scanline scanline4 = (Scanline)fib.GetScanline(0); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format16bppRgb565); + Scanline scanline5 = (Scanline)fib.GetScanline(0); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format24bppRgb); + Scanline scanline6 = (Scanline)fib.GetScanline(0); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format32bppArgb); + Scanline scanline7 = (Scanline)fib.GetScanline(0); + fib.Dispose(); + } + + [Test] + public void GetScanlines() + { + FreeImageBitmap fib; + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format1bppIndexed); + IList> scanline01 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format4bppIndexed); + IList> scanline02 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format8bppIndexed); + IList> scanline03 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format16bppRgb555); + IList> scanline04 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format16bppRgb565); + IList> scanline05 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format24bppRgb); + IList> scanline06 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, PixelFormat.Format32bppArgb); + IList> scanline07 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_COMPLEX); + IList> scanline08 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_DOUBLE); + IList> scanline09 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_FLOAT); + IList> scanline10 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_INT16); + IList> scanline11 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_INT32); + IList> scanline12 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_RGB16); + IList> scanline13 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_RGBA16); + IList> scanline14 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_RGBAF); + IList> scanline15 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_RGBF); + IList> scanline16 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_UINT16); + IList> scanline17 = (IList>)fib.GetScanlines(); + fib.Dispose(); + + fib = new FreeImageBitmap(10, 10, FREE_IMAGE_TYPE.FIT_UINT32); + IList> scanline18 = (IList>)fib.GetScanlines(); + fib.Dispose(); + } + + [Test] + public void Operators() + { + FreeImageBitmap fib1 = null, fib2 = null; + Assert.IsTrue(fib1 == fib2); + Assert.IsFalse(fib1 != fib2); + Assert.IsTrue(fib1 == null); + Assert.IsFalse(fib1 != null); + + fib1 = new FreeImageBitmap(10, 10, PixelFormat.Format24bppRgb); + Assert.IsFalse(fib1 == fib2); + Assert.IsTrue(fib1 != fib2); + + fib2 = fib1; + fib1 = null; + Assert.IsFalse(fib1 == fib2); + Assert.IsTrue(fib1 != fib2); + + fib1 = new FreeImageBitmap(10, 9, PixelFormat.Format24bppRgb); + Assert.IsFalse(fib1 == fib2); + Assert.IsTrue(fib1 != fib2); + + fib2.Dispose(); + fib2 = fib1; + + Assert.IsTrue(fib1 == fib2); + Assert.IsFalse(fib1 != fib2); + + fib2 = fib1.Clone() as FreeImageBitmap; + Assert.IsTrue(fib1 == fib2); + Assert.IsFalse(fib1 != fib2); + + fib1.Dispose(); + fib2.Dispose(); + } + } + + public class Program + { + static ImageManager iManager = new ImageManager(); + static ImportedFunctionsTest ift = new ImportedFunctionsTest(); + static ImportedStructsTest ist = new ImportedStructsTest(); + static WrapperStructsTest wst = new WrapperStructsTest(); + static WrapperFunctionsTest wft = new WrapperFunctionsTest(); + static FreeImageBitmapTest fib = new FreeImageBitmapTest(); + + public static void Main() + { + List classList = new List(5); + classList.Add(new TestClass(ift)); + classList.Add(new TestClass(ist)); + classList.Add(new TestClass(wst)); + classList.Add(new TestClass(wft)); + classList.Add(new TestClass(fib)); + + for (int i = 0; i < 10000; ) + { + for (int j = 0; j < classList.Count; j++) + classList[j].ExecuteTests(); + Console.WriteLine("Loop {0}", ++i); + //GC.Collect(); + } + } + } + + public class TestClass + { + private object classMember = null; + + private MethodInfo classSetUp = null; + private MethodInfo classTearDown = null; + + private MethodInfo testSetUp = null; + private MethodInfo testTearDown = null; + + private List methodList = null; + + private static object[] parameters = { }; + + public TestClass(object classMember) + { + this.classMember = classMember; + MethodInfo[] infos = classMember.GetType().GetMethods(System.Reflection.BindingFlags.Public | BindingFlags.Instance); + methodList = new List(infos.Length); + + foreach (MethodInfo info in infos) + { + object[] attributes = info.GetCustomAttributes(false); + foreach (Attribute attribute in attributes) + { + if (attribute.GetType() == typeof(TestAttribute)) + { + methodList.Add(info); + break; + } + else if (attribute.GetType() == typeof(TestFixtureSetUpAttribute)) + { + classSetUp = info; + break; + } + else if (attribute.GetType() == typeof(TestFixtureTearDownAttribute)) + { + classTearDown = info; + break; + } + else if (attribute.GetType() == typeof(SetUpAttribute)) + { + testSetUp = info; + break; + } + else if (attribute.GetType() == typeof(TearDownAttribute)) + { + testTearDown = info; + break; + } + } + } + } + + public void ExecuteTests() + { + if (classSetUp != null) + classSetUp.Invoke(classMember, parameters); + + foreach (MethodInfo method in methodList) + { + if (testSetUp != null) + testSetUp.Invoke(classMember, parameters); + + try + { + Console.WriteLine(method.ToString()); + method.Invoke(classMember, parameters); + } + catch (Exception ex) + { + while (ex.InnerException != null) + ex = ex.InnerException; + Console.WriteLine(ex.ToString()); + Environment.Exit(99); + } + + if (testTearDown != null) + testTearDown.Invoke(classMember, parameters); + } + + if (classTearDown != null) + classTearDown.Invoke(classMember, parameters); + } + } +} \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/UnitTest.csproj b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/UnitTest.csproj new file mode 100644 index 0000000..bc1c58c --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/UnitTest/UnitTest.csproj @@ -0,0 +1,110 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {FC7B3A04-FACE-4F07-9CFD-8C6ED06E3CDC} + Exe + Properties + FreeImageAPI + UnitTest + + + 2.0 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + 659,660,661 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + 659,660,661 + true + false + + + true + bin\Debug\ + DEBUG;TRACE + true + 659,660,661 + full + x86 + false + prompt + + + bin\Release\ + TRACE + true + true + 659,660,661 + + + x86 + false + prompt + + + true + bin\Debug\ + DEBUG;TRACE + true + 659,660,661 + full + x64 + false + prompt + + + bin\Release\ + TRACE + true + true + 659,660,661 + + + x64 + false + prompt + + + + False + ..\..\..\..\..\..\..\Programme\NUnit 2.4.8\bin\nunit.framework.dll + + + + + + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Whats_New.NET.txt b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Whats_New.NET.txt new file mode 100644 index 0000000..e13ec6c --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/Whats_New.NET.txt @@ -0,0 +1,124 @@ +What's New for FreeImage.NET + +* : fixed +- : removed +! : changed ++ : added + +Month Day, 2011 - 3.15.2.0 ++ [Herve Drolon] added missing save flags JPEG_OPTIMIZE, JPEG_BASELINE +* [raburton] fixed FreeImageBitmap constructor with initialisation of X/Y resolution + +July 25th, 2011 - 3.15.1.0 ++ [Herve Drolon] added VS 2008 project files +* [Stefan Wetter] fixed FreeImage.IsAvailable method returning false in case the wrapper was out of date +* [Herve Drolon] fixed FreeImage.GetBitmap returning false with dib without resolution info +* [cclouston] fixed EnlargeCanvas returning always NULL + +December 21, 2009 - 3.13.1.1 +* [Carsten Klein] Fixed a threading bug in OpenMultiBitmapFromStream and CloseMultiBitmap. Access to the streamHandles Dictionary is now thread safe. + +September 15, 2009 - 3.13.0.1 ++ [Jean-Philippe Goerke] Added PFM, PICT and RAW file formats. ++ [Jean-Philippe Goerke] Added loading flag JPEG_EXIFROTATE. ++ [Jean-Philippe Goerke] Added method GetNativeVersion() to the FreeImage class. +! [Jean-Philippe Goerke] Changed FreeImage.IsAvailable() now returning false in case the native library is out of date or unusable. +- [Jean-Philippe Goerke] Removed FREEIMAGE_MAJOR_VERSION, FREEIMAGE_MINOR_VERSION and FREEIMAGE_RELEASE_SERIAL constants from class FreeImage. ++ [Jean-Philippe Goerke] Added enumeration FREE_IMAGE_COLOR_OPTIONS. ++ [Jean-Philippe Goerke] Added new overloads for FreeImage.Allocate() and FreeImage.AllocateT(). ++ [Jean-Philippe Goerke] Added methods AllocateEx(), AllocateExT(), FillBackground() and EnlargeCanvas() to class FreeImage. ++ [Jean-Philippe Goerke] Added methods FillBackground(), EnlargeCanvas() and GetEnlargedInstance() to class FreeImageBitmap. +- [Jean-Philippe Goerke] Removed unused ConvertLineXtoY() methods. +* [kruno13] Fixed a bug in the FreeImageBitmap constructors. +- [Jean-Philippe Goerke] Removed unneeded GCHandles used with delegates. ++ [Jean-Philippe Goerke] Added overloaded method OpenMultiBitmapFromStream to class FreeImage. ++ [Jean-Philippe Goerke] FreeImageBitmap now supports loading multipage bitmaps from streams. Warning: The stream must remain open for the bitmap's lifetime. +* [mshanke] Fixed some IPTC metadata incorrect namings. +! [Jean-Philippe Goerke] Method FreeImage.RotateClassic is now deprecated. ++ [Jean-Philippe Goerke] Added method Rotate() to the FreeImage class. +! [Jean-Philippe Goerke] FreeImageBitmap now uses the method Rotate instead of RotateClassic. + +April 20, 2009 - 1.10 +! [Jean-Philippe Goerke] Updated wrapper-version to 1.10 including some minor changes. + +February 27, 2009 - 1.09 ++ [Jean-Philippe Goerke] Help file creation now uses the Version Builder plugin of Sandcastle Help File Builder to generate an MSDN-like Version Information paragraph in the help file. ++ [Jean-Philippe Goerke] Added new metadata model class MDM_EXIF_MAIN to replace MDM_MAIN. Class MDM_MAIN still exists but is marked obsolete and will be removed in a future release. ++ [Jean-Philippe Goerke] Added various properties to access the value of metadata tags directly to all MDM_* classes expect MDM_CUSTOM, MDM_NODATA and MDM_MAKERNOTE. +! [Jean-Philippe Goerke] Now classes deriving from MetadataModel, expect obsoltete class MDM_MAIN, are no longer sealed. +! [Jean-Philippe Goerke] Class GifInformation now derives from MDM_ANIMATION. Moved properties into base class MDM_ANIMATION. ++ [Jean-Philippe Goerke] Added enumerations AltitudeType, DirectionReference, InteroperabilityMode, LatitudeType, LongitudeType, ImageOrientation and VelocityUnit to class MetadataModel. +* [Jean-Philippe Goerke] Fixed a bug in MetadataTag.Count, MetadataTag.Length and MetadataTag.Value. ++ [Jean-Philippe Goerke] Added attribute DebuggerBrowsable(DebuggerBrowsableState.Never) to some protected and private fields. + +February 23, 2009 - 1.08 +! [Jean-Philippe Goerke] FreeImage.NET now uses Sandcastle Help File Builder 1.8.0.1 ++ [Jean-Philippe Goerke] Added new Sandcastle Help File Builder project file FreeImage.NET.shfbproj. +* [headkaze] Fixed a bug in FreeImage.CreateFromBitmap, which now incorporates any transparency information from palletized .NET Bitmaps. ++ [Jean-Philippe Goerke] Added new overloaded method CreateGlobalPalette() to class GifInformation to create global palettes from local palettes. +! [Jean-Philippe Goerke] Renamed internal method FreeImage.SetTransparencyTable_ to FreeImage.SetTransparencyTable. ++ [Jean-Philippe Goerke] Added attribute DebuggerBrowsable(DebuggerBrowsableState.Never) to many protected and private fields. + +February 20, 2009 - 1.07 +* [Jean-Philippe Goerke] Fixed a bug in FreeImage.IsFilenameValidForFIF and FreeImage.IsExtensionValidForFIF. +* [Jean-Philippe Goerke] Fixed a bug in FreeImage.SaveEx that could prevent saving supported non-bitmap types. +* [Jean-Philippe Goerke] Fixed a small bug in FreeImage.CompareData. ++ [Jean-Philippe Goerke] Added two overloads of ColorQuantizeEx() in class FreeImage to return images with a color depth smaller than 8. +! [Jean-Philippe Goerke] Updated FreeImage.ConvertColorDepth to support 1- and 4-bpp color conversions (FreeImage_ConvertTo4Bits only creates grayscale results). +* [headkaze] Fixed a bug in FreeImage.GetBitmap, which now adds any transparency information to palletized .NET Bitmaps. +* [headkaze] Fixed a bug in FreeImage.GetBitmap and FreeImage.CreateFromBitmap to support palettes with sizes different from 2, 16 and 256 entries. +! [Jean-Philippe Goerke] Improved handling of multipage bitmaps in FreeImageBitmap class. ++ [Jean-Philippe Goerke] Added new overloads for FreeImageBitmap.SaveAdd() to allow inserting frames at a specified page index. ++ [Jean-Philippe Goerke] Added new class GifInformation which provides access to GIF format specific metadata (GlobalPalette, Animation, etc.). ++ [Jean-Philippe Goerke] Added enumeration DisposalMethodType. +! [Jean-Philippe Goerke] Updated class MemoryArray, which now is Disposable and has a new static constructor. +! [Jean-Philippe Goerke] Removed code using reflection from class ImageMetadata. ++ [Jean-Philippe Goerke] Added new ctor(FITAG) and ctor(MetadataTag) to class Palette to support palettes stored in metadata tags. ++ [Jean-Philippe Goerke] Added new ctor(RGBQUAD[]), ctor(Color[]) and ctor(int) to create new stand-alone palettes to class Palette. ++ [Jean-Philippe Goerke] Added overloaded CreateGrayscalePalette(), Reverse() and CopyFrom() to class Palette. +! [Jean-Philippe Goerke] Changed the behavior of MetadataTag.Value. byte and byte[] are now stored as FREE_IMAGE_MDTYPE.FIDT_BYTE instead of FREE_IMAGE_MDTYPE.FIDT_UNDEFINED. ++ [Jean-Philippe Goerke] Added a type check to MetadataTag.SetValue(object), MetadataTag.SetValue(object, FREE_IMAGE_MDTYPE) and the setter of MetadataTag.Value. + +November 18, 2008 - 1.06 +* [Jean-Philippe Goerke] Fixed a bug in FreeImage.SaveEx. +! [Jean-Philippe Goerke] Improved method FreeImage.IsFilenameValidForFIF. + +November 5, 2008 - 1.05 +! [Jean-Philippe Goerke] Updated documentation of FreeImage.ConvertFromRawBits and FreeImage.ConvertToRawBits. ++ [Jean-Philippe Goerke] Added new overload ConvertFromRawBits(byte[],int,int,int,uint,uint,uint,uint,bool) to the FreeImage class. ++ [Jean-Philippe Goerke] Added new overload ConvertFromRawBits(byte[],FREE_IMAGE_TYPE,int,int,int,uint,uint,uint,uint bool) to the FreeImage class. ++ [Jean-Philippe Goerke] Added new overload ConvertToRawBits(byte[],FIBITMAP,int,uint,uint,uint,uint,bool) to the FreeImage class. +! [Jean-Philippe Goerke] Improved method FreeImage.CreatePropertyItem. ++ [Jean-Philippe Goerke] Added overloads for CopyMemory to class FreeImage which support direct usage of arrays. +! [Jean-Philippe Goerke] Replaced calls to FreeImage.MoveMemory with FreeImage.CopyMemory. +! [Jean-Philippe Goerke] Class FreeImageBitmap now derives from MarshalByRefObject. ++ [Jean-Philippe Goerke] Added new ctor(int,int,int,PixelFormat,byte[]) and ctor(int,int,int,int,FREE_IMAGE_TYPE,byte[]) to the FreeImageBitmap class. + +August 29, 2008 - 1.04 ++ [Jean-Philippe Goerke] Added new target architectures x86 and x64 to the Visual Studio 2005 solution and project files. ++ [Jean-Philippe Goerke] Added static readonly field Zero to FIBITMAP, FIMEMORY, FIMETADATA, FIMULTIBITMAP and FITAG. +! [Jean-Philippe Goerke] Changed CreateFromBitmap to handle all formats contained by System.Drawing.Imaging.PixelFormat. ++ [Jean-Philippe Goerke] Added overload for ConvertFromRawBits to class FreeImage which supports creating images of any FREE_IMAGE_TYPE from raw bits. ++ [Jean-Philippe Goerke] Added method GetTypeParameters to class FreeImage. +! [Jean-Philippe Goerke] Both constructors FreeImageBitmap.ctor(int,int,PixelFormat) and FreeImageBitmap.ctor(int,int,int,PixelFormat,IntPtr) now work with all formats defined in PixelFormat. ++ [Jean-Philippe Goerke] Added new constructor FreeImageBitmap.ctor(int,int,int,int,FREE_IMAGE_TYPE,IntPtr) to FreeImageBitmap class. + +August 18, 2008 - 1.03 +* [Eric T. Wilson] Added GC.AddMemoryPressure and GC.RemoveMemoryPressure to FreeImageBitmap class. ++ [Eric T. Wilson] Added ToBitmap method to FreeImageBitmap class. +! [Eric T. Wilson] Changed implicit conversion operators to and from System.Drawing.Bitmap to explicit operators. +- [Eric T. Wilson] Removed Message event from FreeImage class. Use event FreeImageEngine.Message instead. +- [Eric T. Wilson] Removed contructors ctor(int) and ctor(IntPtr) from FIBITMAP, FIMULTIBITMAP, FIMEMORY, FIMETADATA and FITAG. +- [Eric T. Wilson] Removed implicit conversion operators from and to int and IntPtr from FIBITMAP, FIMULTIBITMAP, FIMEMORY, FIMETADATA and FITAG. ++ [Jean-Philippe Goerke] Added SetNull method to FIBITMAP, FIMULTIBITMAP, FIMEMORY, FIMETADATA and FITAG. +! [Jean-Philippe Goerke] Changed handling of multipage images in FreeImageBitmap: As with System.Drawing.Bitmap, any changes applied to an active frame are no longer written back to the multipage image loaded. +* [Jean-Philippe Goerke] Fixed a bug in FreeImage.SaveToStream(ref FIBITMAP, Stream, FREE_IMAGE_FORMAT, FREE_IMAGE_SAVE_FLAGS, FREE_IMAGE_COLOR_DEPTH, bool): changed catch block into a finally block. + +July 25, 2008 - 1.02 ++ [Jean-Philippe Goerke] Improved handling of XMP metadata in MetadataTag.cs: Key is now set to "XMLPacket" not changeable if Model is FREE_IMAGE_MDMODEL.FIMD_XMP. + +July 01, 2008 - 1.01 ++ [Jean-Philippe Goerke] Added methods Quantize and GetQuantizedInstance to the FreeImageBitmap class. + +November 12, 2007 - 1.00 ++ [Jean-Philippe Goerke] Initial release. diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/clean.bat b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/clean.bat new file mode 100644 index 0000000..e359a24 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImage.NET/cs/clean.bat @@ -0,0 +1,48 @@ +@ECHO OFF + +rd "Library\bin" /s /q +rd "Library\obj" /s /q + +rd "Samples\Sample 01 - Loading and saving\bin" /s /q +rd "Samples\Sample 01 - Loading and saving\obj" /s /q + +rd "Samples\Sample 02 - Multipaged bitmaps\bin" /s /q +rd "Samples\Sample 02 - Multipaged bitmaps\obj" /s /q + +rd "Samples\Sample 03 - Allocating\bin" /s /q +rd "Samples\Sample 03 - Allocating\obj" /s /q + +rd "Samples\Sample 04 - Getting bitmap informations\bin" /s /q +rd "Samples\Sample 04 - Getting bitmap informations\obj" /s /q + +rd "Samples\Sample 05 - Working with pixels\bin" /s /q +rd "Samples\Sample 05 - Working with pixels\obj" /s /q + +rd "Samples\Sample 06 - Converting\bin" /s /q +rd "Samples\Sample 06 - Converting\obj" /s /q + +rd "Samples\Sample 07 - ICC Profiles\bin" /s /q +rd "Samples\Sample 07 - ICC Profiles\obj" /s /q + +rd "Samples\Sample 08 - Creating a plugin\bin" /s /q +rd "Samples\Sample 08 - Creating a plugin\obj" /s /q + +rd "Samples\Sample 09 - Working with streams\bin" /s /q +rd "Samples\Sample 09 - Working with streams\obj" /s /q + +rd "Samples\Sample 10 - Metadata\bin" /s /q +rd "Samples\Sample 10 - Metadata\obj" /s /q + +rd "Samples\Sample 11 - Using the FreeImageBitmap class\bin" /s /q +rd "Samples\Sample 11 - Using the FreeImageBitmap class\obj" /s /q + +rd "SourceFileMerger\bin" /s /q +rd "SourceFileMerger\obj" /s /q + +rd "UnitTest\bin" /s /q +rd "UnitTest\obj" /s /q + +del "FreeImage.net.VisualState.xml" +del "TestResult.xml" +del *.suo /A:H /S /Q +del *.user /S /Q \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2005.sln b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2005.sln new file mode 100644 index 0000000..ffcbff1 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2005.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeImagePlus", "FreeImagePlus.2005.vcproj", "{94F36908-A4E2-4533-939D-64FF6EADA5A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Debug|Win32.ActiveCfg = Debug|Win32 + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Debug|Win32.Build.0 = Debug|Win32 + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Release|Win32.ActiveCfg = Release|Win32 + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2005.vcproj b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2005.vcproj new file mode 100644 index 0000000..538589b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2005.vcproj @@ -0,0 +1,480 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2008.sln b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2008.sln new file mode 100644 index 0000000..68c87e1 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2008.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeImagePlus", "FreeImagePlus.2008.vcproj", "{94F36908-A4E2-4533-939D-64FF6EADA5A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Debug|Win32.ActiveCfg = Debug|Win32 + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Debug|Win32.Build.0 = Debug|Win32 + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Release|Win32.ActiveCfg = Release|Win32 + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2008.vcproj b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2008.vcproj new file mode 100644 index 0000000..7a7e6c2 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2008.vcproj @@ -0,0 +1,478 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2013.sln b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2013.sln new file mode 100644 index 0000000..865555c --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2013.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2013 for Windows Desktop +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeImagePlus", "FreeImagePlus.2013.vcxproj", "{94F36908-A4E2-4533-939D-64FF6EADA5A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Debug|Win32.ActiveCfg = Debug|Win32 + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Debug|Win32.Build.0 = Debug|Win32 + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Release|Win32.ActiveCfg = Release|Win32 + {94F36908-A4E2-4533-939D-64FF6EADA5A1}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2013.vcxproj b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2013.vcxproj new file mode 100644 index 0000000..ba9b5b9 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2013.vcxproj @@ -0,0 +1,306 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + FreeImagePlus + {94F36908-A4E2-4533-939D-64FF6EADA5A1} + FreeImagePlus + + + + DynamicLibrary + v120 + false + MultiByte + + + DynamicLibrary + v120 + false + MultiByte + + + DynamicLibrary + v120 + false + MultiByte + + + DynamicLibrary + v120 + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>12.0.21005.1 + + + .\$(Platform)\$(Configuration)\ + .\$(Platform)\$(Configuration)\ + false + false + + + .\$(Platform)\$(Configuration)\ + .\$(Platform)\$(Configuration)\ + false + false + + + .\$(Platform)\$(Configuration)\ + .\$(Platform)\$(Configuration)\ + true + false + $(ProjectName)d + + + .\$(Platform)\$(Configuration)\ + .\$(Platform)\$(Configuration)\ + true + false + $(ProjectName)d + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/FreeImagePlus.tlb + + + + MaxSpeed + OnlyExplicitInline + true + Speed + true + true + .;../../Source;%(AdditionalIncludeDirectories) + NDEBUG;WIN32;_WINDOWS;_USRDLL;FIP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + true + MultiThreaded + false + true + NotUsing + Level3 + true + Default + false + None + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + true + false + + MachineX86 + true + true + UseLinkTimeCodeGeneration + + + mkdir dist\x32 +copy $(OutDir)$(TargetName).dll dist\x32 +copy $(OutDir)$(TargetName).lib dist\x32 +copy FreeImagePlus.h dist\x32 + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + .\Release/FreeImagePlus.tlb + + + + Full + OnlyExplicitInline + true + Speed + true + .;../../Source;%(AdditionalIncludeDirectories) + NDEBUG;WIN32;_WINDOWS;_USRDLL;FIP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + true + MultiThreaded + false + true + NotUsing + Level3 + true + Default + false + None + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + true + false + + MachineX64 + true + true + UseLinkTimeCodeGeneration + + + mkdir dist\x64 +copy $(OutDir)$(TargetName).dll dist\x64 +copy $(OutDir)$(TargetName).lib dist\x64 +copy FreeImagePlus.h dist\x64 + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Debug/FreeImagePlus.tlb + + + + Disabled + .;../../Source;%(AdditionalIncludeDirectories) + _DEBUG;WIN32;_WINDOWS;_USRDLL;FIP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotUsing + Level3 + true + Default + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + true + true + false + + MachineX86 + + + mkdir dist\x32 +copy $(OutDir)$(TargetName).dll dist\x32 +copy $(OutDir)$(TargetName).lib dist\x32 +copy FreeImagePlus.h dist\x32 + + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + .\Debug/FreeImagePlus.tlb + + + + Disabled + .;../../Source;%(AdditionalIncludeDirectories) + _DEBUG;WIN32;_WINDOWS;_USRDLL;FIP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + NotUsing + Level3 + true + Default + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + true + true + false + + MachineX64 + + + mkdir dist\x64 +copy $(OutDir)$(TargetName).dll dist\x64 +copy $(OutDir)$(TargetName).lib dist\x64 +copy FreeImagePlus.h dist\x64 + + + + + + + + + + + + + + + + + + + + + + + {b39ed2b3-d53a-4077-b957-930979a3577d} + false + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2013.vcxproj.filters b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2013.vcxproj.filters new file mode 100644 index 0000000..670b45b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.2013.vcxproj.filters @@ -0,0 +1,53 @@ + + + + + {89854f66-f6c5-4c88-bcc7-6141f29b56a1} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {76efef1d-9bed-435d-b007-8156aca779dc} + h;hpp;hxx;hm;inl + + + {b0cfb0e2-0615-4c08-8674-2678f135b147} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + + + Header Files + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.h b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.h new file mode 100644 index 0000000..571010f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.h @@ -0,0 +1,1713 @@ +// ========================================================== +// FreeImagePlus 3 +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#ifndef FREEIMAGEPLUS_H +#define FREEIMAGEPLUS_H + +#ifdef _WIN32 +#include +#endif // _WIN32 +#include "FreeImage.h" + + +// Compiler options --------------------------------------------------------- + +#if defined(FREEIMAGE_LIB) + #define FIP_API + #define FIP_CALLCONV +#else + #if defined(_WIN32) || defined(__WIN32__) + #define WIN32_LEAN_AND_MEAN + #define FIP_CALLCONV __stdcall + // The following ifdef block is the standard way of creating macros which make exporting + // from a DLL simpler. All files within this DLL are compiled with the FIP_EXPORTS + // symbol defined on the command line. this symbol should not be defined on any project + // that uses this DLL. This way any other project whose source files include this file see + // FIP_API functions as being imported from a DLL, wheras this DLL sees symbols + // defined with this macro as being exported. + #ifdef FIP_EXPORTS + #define FIP_API __declspec(dllexport) + #else + #define FIP_API __declspec(dllimport) + #endif // FIP_EXPORTS + #else + // try the gcc visibility support (see http://gcc.gnu.org/wiki/Visibility) + #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) + #ifndef GCC_HASCLASSVISIBILITY + #define GCC_HASCLASSVISIBILITY + #endif + #endif + #define FIP_CALLCONV + #if defined(GCC_HASCLASSVISIBILITY) + #define FIP_API __attribute__ ((visibility("default"))) + #else + #define FIP_API + #endif + #endif // WIN32 / !WIN32 +#endif // FREEIMAGE_LIB + +/////////////////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------- + +/** Abstract base class for all objects used by the library. + @version FreeImage 3 + @author Hervé Drolon +*/ + +class FIP_API fipObject +{ +public: + /// Destructor + virtual ~fipObject(){}; + + /**@name Information functions */ + //@{ + /// Returns TRUE if the object is allocated, FALSE otherwise + virtual BOOL isValid() const = 0; + //@} +}; + +// ---------------------------------------------------------- + +class fipMemoryIO; +class fipMultiPage; +class fipTag; + +/** A class used to manage all photo related images and all image types used by the library. + + fipImage encapsulates the FIBITMAP format. It relies on the FreeImage library, especially for + loading / saving images and for bit depth conversion. + @version FreeImage 3 + @author Hervé Drolon +*/ + +class FIP_API fipImage : public fipObject +{ +protected: + /// DIB data + FIBITMAP *_dib; + /// Original (or last saved) fif format if available, FIF_UNKNOWN otherwise + FREE_IMAGE_FORMAT _fif; + /// TRUE whenever the display need to be refreshed + mutable BOOL _bHasChanged; + +public: + friend class fipMultiPage; + +public: + + /**@name Creation & Destruction */ + //@{ + /** + Constructor + @see FreeImage_AllocateT + */ + fipImage(FREE_IMAGE_TYPE image_type = FIT_BITMAP, unsigned width = 0, unsigned height = 0, unsigned bpp = 0); + /// Destructor + virtual ~fipImage(); + /** + Image allocator + @see FreeImage_AllocateT + */ + BOOL setSize(FREE_IMAGE_TYPE image_type, unsigned width, unsigned height, unsigned bpp, unsigned red_mask = 0, unsigned green_mask = 0, unsigned blue_mask = 0); + /// Destroy image data + virtual void clear(); + //@} + + /**@name Copying */ + //@{ + /** + Copy constructor + @see FreeImage_Clone + */ + fipImage(const fipImage& src); + /** + Copy constructor + @see FreeImage_Clone + */ + fipImage& operator=(const fipImage& src); + /** + Assignement operator
+ Copy the input pointer and manage its destruction + @see operator FIBITMAP*() + */ + fipImage& operator=(FIBITMAP *dib); + + + /** + @brief Copy a sub part of the current image and returns it as a fipImage object. + + This method works with any bitmap type. + @param dst Output subimage + @param left Specifies the left position of the cropped rectangle. + @param top Specifies the top position of the cropped rectangle. + @param right Specifies the right position of the cropped rectangle. + @param bottom Specifies the bottom position of the cropped rectangle. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Copy + */ + BOOL copySubImage(fipImage& dst, int left, int top, int right, int bottom) const; + + /** + @brief Alpha blend or combine a sub part image with the current image. + + The bit depth of dst bitmap must be greater than or equal to the bit depth of src. + Upper promotion of src is done internally. Supported bit depth equals to 4, 8, 16, 24 or 32. + @param src Source subimage + @param left Specifies the left position of the sub image. + @param top Specifies the top position of the sub image. + @param alpha Alpha blend factor. The source and destination images are alpha blended if + alpha = 0..255. If alpha > 255, then the source image is combined to the destination image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Paste + */ + BOOL pasteSubImage(fipImage& src, int left, int top, int alpha = 256); + + /** + @brief Crop a sub part of the current image and update it accordingly. + + This method works with any bitmap type. + @param left Specifies the left position of the cropped rectangle. + @param top Specifies the top position of the cropped rectangle. + @param right Specifies the right position of the cropped rectangle. + @param bottom Specifies the bottom position of the cropped rectangle. + @return Returns TRUE if successful, FALSE otherwise. + */ + BOOL crop(int left, int top, int right, int bottom); + + //@} + + /** @name File type identification + */ + //@{ + /** + @brief Identifies an image from disk, given its file name + @param lpszPathName Path and file name of the image to identify. + @return Returns the found FreeImage format if successful, returns FIF_UNKNOWN otherwise. + @see FreeImage_GetFileType, FreeImage_GetFIFFromFilename, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIF(const char* lpszPathName); + + /** + UNICODE version of identifyFIF (this function only works under WIN32 and does nothing on other OS) + @see FreeImage_GetFileTypeU, FreeImage_GetFIFFromFilenameU, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIFU(const wchar_t* lpszPathName); + + /** + @brief Identifies an image using the specified FreeImageIO struct and fi_handle. + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @return Returns the found FreeImage format if successful, returns FIF_UNKNOWN otherwise. + @see FreeImage_GetFileTypeFromHandle, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIFFromHandle(FreeImageIO *io, fi_handle handle); + + /** + @brief Identifies an image using the specified memory stream. + @param hmem FreeImage memory stream + @return Returns the found FreeImage format if successful, returns FIF_UNKNOWN otherwise. + @see FreeImage_GetFileTypeFromMemory, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIFFromMemory(FIMEMORY *hmem); + + //@} + + + /** @name Loading & Saving + * Loading and saving is handled by the FreeImage library. + */ + //@{ + /** + @brief Loads an image from disk, given its file name and an optional flag. + @param lpszPathName Path and file name of the image to load. + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Load, FreeImage documentation + */ + BOOL load(const char* lpszPathName, int flag = 0); + + /** + UNICODE version of load (this function only works under WIN32 and does nothing on other OS) + @see load + */ + BOOL loadU(const wchar_t* lpszPathName, int flag = 0); + + /** + @brief Loads an image using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_LoadFromHandle, FreeImage documentation + */ + BOOL loadFromHandle(FreeImageIO *io, fi_handle handle, int flag = 0); + + /** + @brief Loads an image using the specified memory stream and an optional flag. + @param memIO FreeImage memory stream + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_LoadFromMemory, FreeImage documentation + */ + BOOL loadFromMemory(fipMemoryIO& memIO, int flag = 0); + + /** + @brief Saves an image to disk, given its file name and an optional flag. + @param lpszPathName Path and file name of the image to save. + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Save, FreeImage documentation + */ + BOOL save(const char* lpszPathName, int flag = 0) const; + + /** + UNICODE version of save (this function only works under WIN32 and does nothing on other OS) + @see save + */ + BOOL saveU(const wchar_t* lpszPathName, int flag = 0) const; + + /** + @brief Saves an image using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param fif Format identifier (FreeImage format) + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveToHandle, FreeImage documentation + */ + BOOL saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flag = 0) const; + + /** + @brief Saves an image using the specified memory stream and an optional flag. + @param fif Format identifier (FreeImage format) + @param memIO FreeImage memory stream + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveToMemory, FreeImage documentation + */ + BOOL saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flag = 0) const; + + //@} + + /** @name Information functions + * Accessors to the DIB BITMAPINFO structure. + */ + //@{ + + /** + Returns the data type of the image + @see FreeImage_GetImageType + */ + FREE_IMAGE_TYPE getImageType() const; + + /** + Returns the image width in pixels + @see FreeImage_GetWidth + */ + unsigned getWidth() const; + + /** + Returns the image height in pixels + @see FreeImage_GetHeight + */ + unsigned getHeight() const; + + /** + Returns the width of the bitmap in bytes rounded to the nearest DWORD. + @see FreeImage_GetPitch + */ + unsigned getScanWidth() const; + + /** + Returns a pointer to the FIBITMAP data. Used for direct access from FREEIMAGE functions + or from your own low level C functions.
+ Sample use :
+
+	fipImage src, dst;
+	src.load("test.png");
+	dst = FreeImage_ConvertTo8Bits(src);
+	FreeImage_Save(FIF_TIFF, dst, "test.tif", 0);
+	
+ @see operator=(FIBITMAP *dib) + */ + operator FIBITMAP*() { + return _dib; + } + + /// Returns TRUE if the image is allocated, FALSE otherwise + BOOL isValid() const; + + /** + Returns a pointer to the bitmap's BITMAPINFO header. + @see FreeImage_GetInfo + */ + BITMAPINFO* getInfo() const; + + /** + Returns a pointer to the bitmap's BITMAPINFOHEADER. + @see FreeImage_GetInfoHeader + */ + BITMAPINFOHEADER* getInfoHeader() const; + + /** + Returns the size of the bitmap in bytes. + The size of the bitmap is the BITMAPINFOHEADER + the size of the palette + the size of the bitmap data. + @see FreeImage_GetDIBSize + */ + unsigned getImageSize() const; + + /** + Returns the memory footprint of a bitmap, in bytes. + @see FreeImage_GetMemorySize + */ + unsigned getImageMemorySize() const; + + /** + Returns the bitdepth of the bitmap.
+ When the image type is FIT_BITMAP, valid bitdepth can be 1, 4, 8, 16, 24 or 32. + @see FreeImage_GetBPP, getImageType + */ + unsigned getBitsPerPixel() const; + + /** + Returns the width of the bitmap in bytes.
+ This is not the size of the scanline. + @see FreeImage_GetLine, getScanWidth + */ + unsigned getLine() const; + + /** + Returns the bitmap resolution along the X axis, in pixels / cm + @see FreeImage_GetDotsPerMeterX + */ + double getHorizontalResolution() const; + + /** + Returns the bitmap resolution along the Y axis, in pixels / cm + @see FreeImage_GetDotsPerMeterY + */ + double getVerticalResolution() const; + + /** + set the bitmap resolution along the X axis, in pixels / cm + @see FreeImage_GetInfoHeader + */ + void setHorizontalResolution(double value); + + /** + set the bitmap resolution along the Y axis, in pixels / cm + @see FreeImage_GetInfoHeader + */ + void setVerticalResolution(double value); + + //@} + + /**@name Palette operations */ + //@{ + /** + Returns a pointer to the bitmap's palette. If the bitmap doesn't have a palette, getPalette returns NULL. + @see FreeImage_GetPalette + */ + RGBQUAD* getPalette() const; + + /** + Returns the palette size in bytes. + @see FreeImage_GetColorsUsed + */ + unsigned getPaletteSize() const; + + /** + Retrieves the number of colours used in the bitmap. If the bitmap is non-palletised, 0 is returned. + @see FreeImage_GetColorsUsed + */ + unsigned getColorsUsed() const; + + /** + Investigates the colour type of the bitmap. + @see FreeImage_GetColorType, FREE_IMAGE_COLOR_TYPE + */ + FREE_IMAGE_COLOR_TYPE getColorType() const; + + /** + Returns TRUE if the bitmap is a 8-bit bitmap with a greyscale palette, FALSE otherwise + @see FreeImage_GetBPP, FreeImage_GetColorType + */ + BOOL isGrayscale() const; + //@} + + /**@name Thumbnail access */ + //@{ + + /** + Retrieves a copy the thumbnail possibly attached to the bitmap + @return Returns TRUE if the thumbnail is present in the bitmap and successfuly retrieved, returns FALSE otherwise + @see FreeImage_GetThumbnail + */ + BOOL getThumbnail(fipImage& image) const; + + /** + Attach a thumbnail to the bitmap + @return Returns TRUE if the thumbnail was successfuly set, returns FALSE otherwise + @see FreeImage_SetThumbnail + */ + BOOL setThumbnail(const fipImage& image); + + /** + Check if the image has an embedded thumbnail + @return Returns TRUE if a thumbnail is present in the bitmap, returns FALSE otherwise + @see FreeImage_GetThumbnail + */ + BOOL hasThumbnail() const; + + /** + Clear the thumbnail possibly attached to the bitmap + @return Returns TRUE if successful, returns FALSe otherwise + @see FreeImage_SetThumbnail + */ + BOOL clearThumbnail(); + + //@} + + /**@name Pixel access */ + //@{ + + /** @brief Returns a pointer to the bitmap bits. + + It is up to you to interpret these bytes correctly, + according to the results of FreeImage_GetBPP and + GetRedMask, FreeImage_GetGreenMask and FreeImage_GetBlueMask.
+ Use this function with getScanWidth to iterates through the pixels. + @see FreeImage_GetBits + */ + BYTE* accessPixels() const; + + /** @brief Returns a pointer to the start of the given scanline in the bitmap’s data-bits. + This pointer can be cast according to the result returned by getImageType.
+ Use this function with getScanWidth to iterates through the pixels. + @see FreeImage_GetScanLine, FreeImage documentation + */ + BYTE* getScanLine(unsigned scanline) const; + + /** + Get the pixel index of a 1-, 4- or 8-bit palettized image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel index (returned value) + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetPixelIndex + */ + BOOL getPixelIndex(unsigned x, unsigned y, BYTE *value) const; + + /** + Get the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel color (returned value) + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetPixelColor + */ + BOOL getPixelColor(unsigned x, unsigned y, RGBQUAD *value) const; + + /** + Set the pixel index of a 1-, 4- or 8-bit palettized image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel index + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetPixelIndex + */ + BOOL setPixelIndex(unsigned x, unsigned y, BYTE *value); + + /** + Set the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel color + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetPixelColor + */ + BOOL setPixelColor(unsigned x, unsigned y, RGBQUAD *value); + + //@} + + /** @name Conversion routines + * Bitmaps are always loaded in their default bit depth. If you want the bitmap to be stored in another bit depth, the class provides several conversion functions. + */ + //@{ + /** + Converts an image to a type supported by FreeImage. + @param image_type New image type + @param scale_linear TRUE if image pixels must be scaled linearly when converting to a standard bitmap + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToType, FreeImage_ConvertToStandardType + */ + BOOL convertToType(FREE_IMAGE_TYPE image_type, BOOL scale_linear = TRUE); + + /** + Converts the bitmap to 1 bit using a threshold T. + @param T Threshold value in [0..255] + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Threshold + */ + BOOL threshold(BYTE T); + + /** + Converts a 8-bit image to a monochrome 1-bit image using a dithering algorithm. + @param algorithm Dithering algorithm to use. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Dither, FREE_IMAGE_DITHER + */ + BOOL dither(FREE_IMAGE_DITHER algorithm); + + /** + Converts the bitmap to 4 bits. Unless the bitmap is a 1-bit palettized bitmap, colour values are converted to greyscale. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo4Bits + */ + BOOL convertTo4Bits(); + + /** + Converts the bitmap to 8 bits. If the bitmap is 24 or 32-bit RGB, the colour values are converted to greyscale. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo8Bits + */ + BOOL convertTo8Bits(); + + /** + Converts the bitmap to 8 bits.
+ For palletized bitmaps, the color map is converted to a greyscale ramp. + @see FreeImage_ConvertToGreyscale + @return Returns TRUE if successful, FALSE otherwise. + */ + BOOL convertToGrayscale(); + + /** + Quantizes a full colour 24-bit bitmap to a palletised 8-bit bitmap.
+ The quantize parameter specifies which colour reduction algorithm should be used. + @param algorithm Color quantization algorithm to use. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ColorQuantize, FREE_IMAGE_QUANTIZE + */ + BOOL colorQuantize(FREE_IMAGE_QUANTIZE algorithm); + + /** + Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 5 bits green, 5 bits blue and 1 unused bit. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo16Bits555 + */ + BOOL convertTo16Bits555(); + + /** + Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 6 bits green and 5 bits blue. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo16Bits565 + */ + BOOL convertTo16Bits565(); + + /** + Converts the bitmap to 24 bits. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo24Bits + */ + BOOL convertTo24Bits(); + + /** + Converts the bitmap to 32 bits. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo32Bits + */ + BOOL convertTo32Bits(); + + /** + Converts the bitmap to a 32-bit float image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToFloat + */ + BOOL convertToFloat(); + + /** + Converts the bitmap to a 96-bit RGBF image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGBF + */ + BOOL convertToRGBF(); + + /** + Converts the bitmap to a 128-bit RGBAF image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGBAF + */ + BOOL convertToRGBAF(); + + /** + Converts the bitmap to a 16-bit unsigned short image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToUINT16 + */ + BOOL convertToUINT16(); + + /** + Converts the bitmap to a 48-bit RGB16 image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGB16 + */ + BOOL convertToRGB16(); + + /** + Converts the bitmap to a 64-bit RGBA16 image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGBA16 + */ + BOOL convertToRGBA16(); + + /** + Converts a High Dynamic Range image (48-bit RGB or 96-bit RGB Float) to a 24-bit RGB image. + @param tmo Tone mapping operator + @param first_param First tone mapping algorithm parameter (algorithm dependant) + @param second_param Second tone mapping algorithm parameter (algorithm dependant) + @param third_param Third tone mapping algorithm parameter (algorithm dependant) + @param fourth_param Fourth tone mapping algorithm parameter (algorithm dependant) + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ToneMapping, FreeImage_TmoReinhard05Ex + */ + BOOL toneMapping(FREE_IMAGE_TMO tmo, double first_param = 0, double second_param = 0, double third_param = 1, double fourth_param = 0); + + //@} + + /** @name Transparency support: background colour and alpha channel */ + //@{ + + /** + Returns TRUE if the image is transparent, returns FALSE otherwise + @see FreeImage_IsTransparent + */ + BOOL isTransparent() const; + + /** + 8-bit transparency : get the number of transparent colors. + @return Returns the number of transparent colors in a palletised bitmap. + @see FreeImage_GetTransparencyCount + */ + unsigned getTransparencyCount() const; + + /** + 8-bit transparency : get the bitmap’s transparency table. + @return Returns a pointer to the bitmap’s transparency table. + @see FreeImage_GetTransparencyTable + */ + BYTE* getTransparencyTable() const; + + /** + 8-bit transparency : set the bitmap’s transparency table. + @see FreeImage_SetTransparencyTable + */ + void setTransparencyTable(BYTE *table, int count); + + /** + Returns TRUE when the image has a file background color, FALSE otherwise. + @see FreeImage_HasBackgroundColor + */ + BOOL hasFileBkColor() const; + + /** + @brief Retrieves the file background color of an image. + + For 8-bit images, the color index + in the palette is returned in the rgbReserved member of the bkcolor parameter. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetBackgroundColor + */ + BOOL getFileBkColor(RGBQUAD *bkcolor) const; + + /** + @brief Set the file background color of an image. + + When saving an image to PNG, this background color is transparently saved to the PNG file. + When the bkcolor parameter is NULL, the background color is removed from the image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetBackgroundColor + */ + BOOL setFileBkColor(RGBQUAD *bkcolor); + //@} + + /**@name Channel processing support */ + //@{ + /** @brief Retrieves the red, green, blue or alpha channel of a 24- or 32-bit BGR[A] image. + @param image Output image to be extracted + @param channel Color channel to extract + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetChannel, FREE_IMAGE_COLOR_CHANNEL + */ + BOOL getChannel(fipImage& image, FREE_IMAGE_COLOR_CHANNEL channel) const; + + /** + @brief Insert a 8-bit dib into a 24- or 32-bit image. + @param image Input 8-bit image to insert + @param channel Color channel to replace + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetChannel, FREE_IMAGE_COLOR_CHANNEL + */ + BOOL setChannel(fipImage& image, FREE_IMAGE_COLOR_CHANNEL channel); + + /** @brief Split a 24-bit RGB image into 3 greyscale images corresponding to the red, green and blue channels. + @param RedChannel Output red channel. + @param GreenChannel Output green channel. + @param BlueChannel Output blue channel. + @return Returns FALSE if the dib isn't a valid image, if it's not a 24-bit image or if + one of the output channel can't be allocated. Returns TRUE otherwise. + @see FreeImage_GetChannel + */ + BOOL splitChannels(fipImage& RedChannel, fipImage& GreenChannel, fipImage& BlueChannel); + + /** @brief Builds a 24-bit RGB image given its red, green and blue channel. + @param red Input red channel. + @param green Input green channel. + @param blue Input blue channel. + @return Returns FALSE if the dib can't be allocated, if the input channels are not 8-bit images. Returns TRUE otherwise. + @see FreeImage_SetChannel + */ + BOOL combineChannels(fipImage& red, fipImage& green, fipImage& blue); + //@} + + /**@name Rotation and flipping */ + //@{ + /** + Image translation and rotation using B-Splines. + @param angle Image rotation angle, in degree + @param x_shift Image horizontal shift + @param y_shift Image vertical shift + @param x_origin Origin of the x-axis + @param y_origin Origin of the y-axis + @param use_mask Whether or not to mask the image. Image mirroring is applied when use_mask is set to FALSE + @return Returns the translated & rotated dib if successful, returns NULL otherwise + @see FreeImage_RotateEx + */ + BOOL rotateEx(double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask); + + /** + Image rotation by means of three shears. + @param angle Image rotation angle, in degree + @param bkcolor Background color (image type dependent), default to black background + @return Returns rotated dib if successful, returns NULL otherwise + @see FreeImage_Rotate + */ + BOOL rotate(double angle, const void *bkcolor = NULL); + + /** + Flip the image horizontally along the vertical axis + @see FreeImage_FlipHorizontal + */ + BOOL flipHorizontal(); + + /** + Flip the image vertically along the horizontal axis + @see FreeImage_FlipVertical + */ + BOOL flipVertical(); + //@} + + /**@name Color manipulation routines */ + //@{ + /** + Inverts each pixel data. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Invert + */ + BOOL invert(); + + /** @brief Perfoms an histogram transformation on a 8, 24 or 32-bit image + according to the values of a lookup table (LUT). + + The transformation is done as follows.
+ Image 8-bit : if the image has a color palette, the LUT is applied to this palette, + otherwise, it is applied to the grey values.
+ Image 24-bit & 32-bit : if channel == IPL_CC_RGB, the same LUT is applied to each color + plane (R,G, and B). Otherwise, the LUT is applied to the specified channel only. + @param LUT Lookup table. The size of 'LUT' is assumed to be 256. + @param channel The color channel to be processed (only used with 24 & 32-bit DIB). + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_AdjustCurve, FREE_IMAGE_COLOR_CHANNEL + */ + BOOL adjustCurve(BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel); + + /** @brief Performs gamma correction on a 8, 24 or 32-bit image. + @param gamma Gamma value to use. A value of 1.0 leaves the image alone, + less than one darkens it, and greater than one lightens it. + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_AdjustGamma, adjustCurve + */ + BOOL adjustGamma(double gamma); + + /** @brief Adjusts the brightness of a 8, 24 or 32-bit image by a certain amount. + @param percentage Where -100 <= percentage <= 100
+ A value 0 means no change, less than 0 will make the image darker + and greater than 0 will make the image brighter. + @return Returns TRUE if the operation was succesful, FALSE otherwise + @see FreeImage_AdjustBrightness, adjustCurve + */ + BOOL adjustBrightness(double percentage); + + /** @brief Adjusts the contrast of a 8, 24 or 32-bit image by a certain amount. + @param percentage Where -100 <= percentage <= 100
+ A value 0 means no change, less than 0 will decrease the contrast + and greater than 0 will increase the contrast of the image. + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_AdjustContrast, adjustCurve + */ + BOOL adjustContrast(double percentage); + + /** + Adjusts an image's brightness, contrast and gamma within a single operation. + If more than one of these image display properties need to be adjusted, + using this function should be preferred over calling each adjustment function separately. + That's particularly true for huge images or if performance is an issue. + @see adjustBrightness + @see adjustContrast + @see adjustGamma + @see FreeImage_AdjustColors + */ + BOOL adjustBrightnessContrastGamma(double brightness, double contrast, double gamma); + + /** @brief Computes image histogram + + For 24-bit and 32-bit images, histogram can be computed from red, green, blue and + black channels. For 8-bit images, histogram is computed from the black channel. Other + bit depth is not supported. + @param histo pointer to an histogram array. Size of this array is assumed to be 256. + @param channel Color channel to use + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_GetHistogram + */ + BOOL getHistogram(DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel = FICC_BLACK) const; + //@} + + /**@name Upsampling / downsampling */ + //@{ + + /** @brief Rescale the image to a new width / height. + + @param new_width New image width + @param new_height New image height + @param filter The filter parameter specifies which resampling filter should be used. + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_Rescale, FREE_IMAGE_FILTER + */ + BOOL rescale(unsigned new_width, unsigned new_height, FREE_IMAGE_FILTER filter); + + /** @brief Creates a thumbnail image keeping aspect ratio + + @param max_size Maximum width or height in pixel units + @param convert When set to TRUE, converts the image to a standard type + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_MakeThumbnail + */ + BOOL makeThumbnail(unsigned max_size, BOOL convert = TRUE); + //@} + + /**@name Image status */ + //@{ + /** + Set the image status as 'modified'.
+ When using the fipWinImage class, the image status is used to refresh the display. + It is changed to FALSE whenever the display has just been refreshed. + @param bStatus TRUE if the image should be marked as modified, FALSE otherwise + @see isModified + */ + void setModified(BOOL bStatus = TRUE) { + _bHasChanged = bStatus; + } + + /** + Get the image status + @return Returns TRUE if the image is marked as modified, FALSE otherwise + @see setModified + */ + BOOL isModified() { + return _bHasChanged; + } + //@} + + /**@name Metadata */ + //@{ + /** + Returns the number of tags contained in the model metadata model + attached to the dib + @param model Metadata model to look for + */ + unsigned getMetadataCount(FREE_IMAGE_MDMODEL model) const; + /** + Retrieve a metadata attached to the dib + @param model Metadata model to look for + @param key Metadata field name + @param tag Returned tag + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_GetMetadata + */ + BOOL getMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag& tag) const; + /** + Attach a new FreeImage tag to the dib.
+ Sample use :
+
+	fipImage image;
+	// ...
+	fipTag tag;
+	tag.setKeyValue("Caption/Abstract", "my caption");
+	image.setMetadata(FIMD_IPTC, tag.getKey(), tag);
+	tag.setKeyValue("Keywords", "FreeImage;Library;Images;Compression");
+	image.setMetadata(FIMD_IPTC, tag.getKey(), tag);
+	
+ + @param model Metadata model used to store the tag + @param key Tag field name + @param tag Tag to be attached + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_SetMetadata + */ + BOOL setMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag& tag); + //@} + + + protected: + /**@name Internal use */ + //@{ + BOOL replace(FIBITMAP *new_dib); + //@} + +}; + +// ---------------------------------------------------------- + +/** A class designed for MS Windows (TM) platforms. + + fipWinImage provides methods used to : +
    +
  • Display a DIB on the screen +
  • Copy / Paste a DIB to/from Windows devices (HANDLE, HBITMAP, Clipboard) +
  • Capture a window (HWND) and convert it to an image +
+ @version FreeImage 3 + @author Hervé Drolon +*/ +#ifdef _WIN32 + +class FIP_API fipWinImage : public fipImage +{ +public: + /**@name Creation & Destruction */ + //@{ + /// Constructor + fipWinImage(FREE_IMAGE_TYPE image_type = FIT_BITMAP, unsigned width = 0, unsigned height = 0, unsigned bpp = 0); + + /// Destructor + virtual ~fipWinImage(); + + /// Destroy image data + virtual void clear(); + + /// Returns TRUE if the image is allocated, FALSE otherwise + BOOL isValid() const; + //@} + + /**@name Copying */ + //@{ + + /** + Copy constructor. + Delete internal _display_dib data and copy the base class image data. + Tone mapping parameters are left unchanged. + @see FreeImage_Clone + */ + fipWinImage& operator=(const fipImage& src); + + /** + Copy constructor + Delete internal _display_dib data and copy tone mapping parameters. + Copy also the base class image data. + @see FreeImage_Clone + */ + fipWinImage& operator=(const fipWinImage& src); + + /** Clone function used for clipboard copy.
+ Convert the FIBITMAP image to a DIB, + and transfer the DIB in a global bitmap handle.
+ For non standard bitmaps, the BITMAPINFOHEADER->biCompression field is set to 0xFF + FreeImage_GetImageType(_dib), + in order to recognize the bitmap as non standard. + */ + HANDLE copyToHandle() const; + + /** Copy constructor used for clipboard paste.
+ Converts a global object to a FIBITMAP. The clipboard format must be CF_DIB.
+ When the BITMAPINFOHEADER->biCompression field is set to 0xFF + [one of the predefined FREE_IMAGE_TYPE], + the bitmap is recognized as non standard and correctly copied. + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL copyFromHandle(HANDLE hMem); + + /** Copy constructor.
+ Converts a HBITMAP object to a FIBITMAP. + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL copyFromBitmap(HBITMAP hbmp); + //@} + + /**@name Clipboard operations */ + //@{ + /** + Clipboard copy. + @param hWndNewOwner Handle to the window to be associated with the open clipboard. + In MFC, you can use AfxGetApp()->m_pMainWnd->GetSafeHwnd(). + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL copyToClipboard(HWND hWndNewOwner) const; + + /** + Retrieves data from the clipboard. The clipboard format must be CF_DIB. + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL pasteFromClipboard(); + //@} + + /**@name Screen capture */ + //@{ + /** Capture a window and convert it to an image + @param hWndApplicationWindow Handle to the application main window + @param hWndSelectedWindow Handle to the window to be captured + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL captureWindow(HWND hWndApplicationWindow, HWND hWndSelectedWindow); + //@} + + + /**@name Painting operations */ + //@{ + + /** @brief Draw (stretch) the image on a HDC, using StretchDIBits. + + When the image is transparent or has a file background, this function composite + the foreground image against a checkerboard background image. + @param hDC Handle to the device context + @param rcDest Destination rectangle + @see FreeImage_Composite + */ + void draw(HDC hDC, RECT& rcDest) const { + drawEx(hDC, rcDest, FALSE, NULL, NULL); + } + + /** @brief Draw (stretch) the image on a HDC, using StretchDIBits. + + When the image is transparent or has a file background, this function can composite + the foreground image against a checkerboard background image, against a single background color or + against a user background image.
+ When the image is a High Dynamic Range image (48-bit or RGB float), this function will apply a + tone mapping operator before drawing the image.
+ The original image (located in the fipImage class) will not be affected by any of the operations + that could be done in order to display it. + @param hDC Handle to the device context + @param rcDest Destination rectangle + @param useFileBkg When set to TRUE, the function uses the file color background if there is one + @param appBkColor When a color is given, the function uses it as the background color + @param bg When a FIBITMAP is given, the function uses it as the background image + @see FreeImage_Composite + @see setToneMappingOperator + */ + void drawEx(HDC hDC, RECT& rcDest, BOOL useFileBkg = FALSE, RGBQUAD *appBkColor = NULL, FIBITMAP *bg = NULL) const; + + /** + Select a tone mapping algorithm used for drawing and set the image as modified + so that the display will be refreshed. + @param tmo Tone mapping operator + @param first_param First tone mapping algorithm parameter + @param second_param Second tone mapping algorithm parameter + @param third_param Third tone mapping algorithm parameter + @param fourth_param Fourth tone mapping algorithm parameter + @see FreeImage_ToneMapping + */ + void setToneMappingOperator(FREE_IMAGE_TMO tmo, double first_param = 0, double second_param = 0, double third_param = 1, double fourth_param = 0); + + /** + Get the tone mapping algorithm used for drawing, with its parameters. + @param tmo Tone mapping operator + @param first_param First tone mapping algorithm parameter + @param second_param Second tone mapping algorithm parameter + @param third_param Third tone mapping algorithm parameter + @param fourth_param Fourth tone mapping algorithm parameter + @see FreeImage_ToneMapping + */ + void getToneMappingOperator(FREE_IMAGE_TMO *tmo, double *first_param, double *second_param, double *third_param, double *fourth_param) const; + + //@} + +protected: + /// DIB used for display (this allow to display non-standard bitmaps) + mutable FIBITMAP *_display_dib; + /// remember to delete _display_dib + mutable BOOL _bDeleteMe; + /// tone mapping operator + FREE_IMAGE_TMO _tmo; + /// first tone mapping algorithm parameter + double _tmo_param_1; + /// second tone mapping algorithm parameter + double _tmo_param_2; + /// third tone mapping algorithm parameter + double _tmo_param_3; + /// fourth tone mapping algorithm parameter + double _tmo_param_4; +}; + +#endif // _WIN32 + +// ---------------------------------------------------------- + +/** Memory handle + + fipMemoryIO is a class that allows you to load / save images from / to a memory stream. + @version FreeImage 3 + @author Hervé Drolon +*/ +class FIP_API fipMemoryIO : public fipObject +{ +protected: + /// Pointer to a memory stream + FIMEMORY *_hmem; + +public : + /** Constructor. + Wrap a memory buffer containing image data.
+ The memory buffer is read only and has to be freed by the user + when no longer in use.
+ When default arguments are used, open a memory file as read/write. + @param data Pointer to the memory buffer + @param size_in_bytes Buffer size in bytes + @see FreeImage_OpenMemory + */ + fipMemoryIO(BYTE *data = NULL, DWORD size_in_bytes = 0); + + /** Destructor. + Free any allocated memory + @see FreeImage_CloseMemory + */ + virtual ~fipMemoryIO(); + + /** Destructor. + Free any allocated memory and invalidate the stream + @see FreeImage_CloseMemory + */ + void close(); + + /** Returns TRUE if the internal memory buffer is a valid buffer, returns FALSE otherwise + */ + BOOL isValid() const; + + /** Returns the buffer image format + @see FreeImage_GetFileTypeFromMemory + */ + FREE_IMAGE_FORMAT getFileType() const; + + /** + Returns a pointer to the FIMEMORY data. Used for direct access from FREEIMAGE functions + or from your own low level C functions. + */ + operator FIMEMORY*() { + return _hmem; + } + + /**@name Memory IO routines */ + //@{ + /** + Loads a dib from a memory stream + @param fif Format identifier (FreeImage format) + @param flags The signification of this flag depends on the image to be loaded. + @return Returns the loaded dib if successful, returns NULL otherwise + @see FreeImage_LoadFromMemory + */ + FIBITMAP* load(FREE_IMAGE_FORMAT fif, int flags = 0) const; + /** + Loads a multi-page bitmap from a memory stream + @param fif Format identifier (FreeImage format) + @param flags The signification of this flag depends on the multi-page to be loaded. + @return Returns the loaded multi-page if successful, returns NULL otherwise + @see FreeImage_LoadMultiBitmapFromMemory + */ + FIMULTIBITMAP* loadMultiPage(FREE_IMAGE_FORMAT fif, int flags = 0) const; + /** + Saves a dib to a memory stream + @param fif Format identifier (FreeImage format) + @param dib Image to be saved + @param flags The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SaveToMemory + */ + BOOL save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, int flags = 0); + /** + Saves a multi-page bitmap to a memory stream + @param fif Format identifier (FreeImage format) + @param bitmap Multi-page image to be saved + @param flags The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SaveMultiBitmapToMemory + */ + BOOL saveMultiPage(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, int flags = 0); + /** + Reads data from a memory stream + @param buffer Storage location for data + @param size Item size in bytes + @param count Maximum number of items to be read + @return Returns the number of full items actually read, which may be less than count if an error occurs + @see FreeImage_ReadMemory + */ + unsigned read(void *buffer, unsigned size, unsigned count) const; + /** + Writes data to a memory stream + @param buffer Pointer to data to be written + @param size Item size in bytes + @param count Maximum number of items to be written + @return Returns the number of full items actually written, which may be less than count if an error occurs + @see FreeImage_WriteMemory + */ + unsigned write(const void *buffer, unsigned size, unsigned count); + /** + Gets the current position of a memory pointer + @see FreeImage_TellMemory + */ + long tell() const; + /** + Moves the memory pointer to a specified location + @see FreeImage_SeekMemory + */ + BOOL seek(long offset, int origin); + /** + Provides a direct buffer access to a memory stream + @param data Pointer to the memory buffer (returned value) + @param size_in_bytes Buffer size in bytes (returned value) + @see FreeImage_AcquireMemory + */ + BOOL acquire(BYTE **data, DWORD *size_in_bytes); + //@} + +private: + /// Disable copy + fipMemoryIO(const fipMemoryIO& src); + /// Disable copy + fipMemoryIO& operator=(const fipMemoryIO& src); + +}; + +// ---------------------------------------------------------- + +/** Multi-page file stream + + fipMultiPage encapsulates the multi-page API. It supports reading/writing + multi-page TIFF, ICO and GIF files. +*/ +class FIP_API fipMultiPage : public fipObject +{ +protected: + /// Pointer to a multi-page file stream + FIMULTIBITMAP *_mpage; + /// TRUE when using a memory cache, FALSE otherwise + BOOL _bMemoryCache; + +public: + /** + Constructor + @param keep_cache_in_memory When it is TRUE, all gathered bitmap data in the page manipulation process is kept in memory, otherwise it is lazily flushed to a temporary file on the hard disk in 64 Kb blocks. + */ + fipMultiPage(BOOL keep_cache_in_memory = FALSE); + + /** + Destructor + Close the file stream if not already done. + */ + virtual ~fipMultiPage(); + + /// Returns TRUE if the multi-page stream is opened + BOOL isValid() const; + + /** + Returns a pointer to the FIMULTIBITMAP data. Used for direct access from FREEIMAGE functions + or from your own low level C functions. + */ + operator FIMULTIBITMAP*() { + return _mpage; + } + + /** + Open a multi-page file stream + @param lpszPathName Name of the multi-page bitmap file + @param create_new When TRUE, it means that a new bitmap will be created rather than an existing one being opened + @param read_only When TRUE the bitmap is opened read-only + @param flags Load flags. The signification of this flag depends on the image to be loaded. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_OpenMultiBitmap + */ + BOOL open(const char* lpszPathName, BOOL create_new, BOOL read_only, int flags = 0); + + /** + Open a multi-page memory stream as read/write. + @param memIO Memory stream. The memory stream MUST BE a wrapped user buffer. + @param flags Load flags. The signification of this flag depends on the image to be loaded. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_LoadMultiBitmapFromMemory + */ + BOOL open(fipMemoryIO& memIO, int flags = 0); + + /** + Open a multi-page image as read/write, using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_OpenMultiBitmapFromHandle + */ + BOOL open(FreeImageIO *io, fi_handle handle, int flags = 0); + + /** + Close a file stream + @param flags Save flags. The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_CloseMultiBitmap + */ + BOOL close(int flags = 0); + + /** + Saves a multi-page image using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param fif Format identifier (FreeImage format) + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the multi-page image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveMultiBitmapToHandle, FreeImage documentation + */ + BOOL saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags = 0) const; + + /** + Saves a multi-page image using the specified memory stream and an optional flag. + @param fif Format identifier (FreeImage format) + @param memIO FreeImage memory stream + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveMultiBitmapToMemory, FreeImage documentation + */ + BOOL saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flags = 0) const; + + /** + Returns the number of pages currently available in the multi-paged bitmap + @see FreeImage_GetPageCount + */ + int getPageCount() const; + + /** + Appends a new page to the end of the bitmap + @param image Image to append + @see FreeImage_AppendPage + */ + void appendPage(fipImage& image); + + /** + Inserts a new page before the given position in the bitmap + @param page Page number. Page has to be a number smaller than the current number of pages available in the bitmap. + @param image Image to insert + @see FreeImage_InsertPage + */ + void insertPage(int page, fipImage& image); + + /** + Deletes the page on the given position + @param page Page number + @see FreeImage_DeletePage + */ + void deletePage(int page); + + /** + Moves the source page to the position of the target page. + @param target Target page position + @param source Source page position + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_MovePage + */ + BOOL movePage(int target, int source); + + /** + Locks a page in memory for editing. You must call unlockPage to free the page
+ Usage :
+
+	fipMultiPage mpage;
+	// ...
+	fipImage image;		// You must declare this before
+	image = mpage.lockPage(2);
+	if(image.isValid()) {
+	  // ...
+	  mpage.unlockPage(image, TRUE);
+	}
+	
+ @param page Page number + @return Returns the page if successful, returns NULL otherwise + @see FreeImage_LockPage + */ + FIBITMAP* lockPage(int page); + + /** + Unlocks a previously locked page and gives it back to the multi-page engine + @param image Page to unlock + @param changed When TRUE, the page is marked changed and the new page data is applied in the multi-page bitmap. + @see FreeImage_UnlockPage + */ + void unlockPage(fipImage& image, BOOL changed); + + /** + Returns an array of page-numbers that are currently locked in memory. + When the pages parameter is NULL, the size of the array is returned in the count variable. + You can then allocate the array of the desired size and call + getLockedPageNumbers again to populate the array. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_GetLockedPageNumbers + */ + BOOL getLockedPageNumbers(int *pages, int *count) const; +}; + +// ---------------------------------------------------------- + +/** +FreeImage Tag + +FreeImage uses this structure to store metadata information. +*/ +class FIP_API fipTag : public fipObject +{ +protected: + /// Pointer to a FreeImage tag + FITAG *_tag; + +public: + /**@name Creation & Destruction */ + //@{ + /** + Constructor + @see FreeImage_CreateTag + */ + fipTag(); + /** + Destructor + @see FreeImage_DeleteTag + */ + virtual ~fipTag(); + /** + Construct a FIDT_ASCII tag (ASCII string).
+ This method is useful to store comments or IPTC tags. + @param name Field name + @param value Field value + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_CreateTag + */ + BOOL setKeyValue(const char *key, const char *value); + + //@} + + /**@name Copying */ + //@{ + /** + Copy constructor + @see FreeImage_CloneTag + */ + fipTag(const fipTag& tag); + /** + Copy constructor + @see FreeImage_CloneTag + */ + fipTag& operator=(const fipTag& tag); + /** + Assignement operator
+ Copy the input pointer and manage its destruction + @see operator FITAG*() + */ + fipTag& operator=(FITAG *tag); + //@} + + /** + Returns a pointer to the FITAG data. Used for direct access from FREEIMAGE functions + or from your own low level C functions. + @see operator=(FITAG *tag) + */ + operator FITAG*() { + return _tag; + } + + /// Returns TRUE if the tag is allocated, FALSE otherwise + BOOL isValid() const; + + /**@name Tag accessors */ + //@{ + /** + Returns the tag field name (unique inside a metadata model). + @see FreeImage_GetTagKey + */ + const char *getKey() const; + /** + Returns the tag description if available, returns NULL otherwise + @see FreeImage_GetTagDescription + */ + const char *getDescription() const; + /** + Returns the tag ID if available, returns 0 otherwise + @see FreeImage_GetTagID + */ + WORD getID() const; + /** + Returns the tag data type + @see FreeImage_GetTagType + */ + FREE_IMAGE_MDTYPE getType() const; + /** + Returns the number of components in the tag (in tag type units) + @see FreeImage_GetTagCount + */ + DWORD getCount() const; + /** + Returns the length of the tag value in bytes + @see FreeImage_GetTagLength + */ + DWORD getLength() const; + /** + Returns the tag value + @see FreeImage_GetTagValue + */ + const void *getValue() const; + /** + Set the tag field name + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagKey + */ + BOOL setKey(const char *key); + /** + Set the (usually optional) tag description + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagDescription + */ + BOOL setDescription(const char *description); + /** + Set the (usually optional) tad ID + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagID + */ + BOOL setID(WORD id); + /** + Set the tag data type + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagType + */ + BOOL setType(FREE_IMAGE_MDTYPE type); + /** + Set the number of data in the tag + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagCount + */ + BOOL setCount(DWORD count); + /** + Set the length of the tag value, in bytes + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagLength + */ + BOOL setLength(DWORD length); + /** + Set the tag value + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagValue + */ + BOOL setValue(const void *value); + + //@} + + /** + Converts a FreeImage tag structure to a string that represents the interpreted tag value + @param model Metadata model specification (metadata model from which the tag was extracted) + @param Make Camera model (not used yet) + */ + const char* toString(FREE_IMAGE_MDMODEL model, char *Make = NULL) const; + +}; + +/** +Metadata iterator + +Usage :
+
+fipImage image;
+// ...
+fipTag tag;
+fipMetadataFind finder;
+if( finder.findFirstMetadata(FIMD_EXIF_MAIN, image, tag) ) {
+  do {
+    // process the tag
+	cout << tag.getKey() << "\n";
+
+  } while( finder.findNextMetadata(tag) );
+}
+// the class can be called again with another metadata model
+if( finder.findFirstMetadata(FIMD_EXIF_EXIF, image, tag) ) {
+  do {
+    // process the tag
+	cout << tag.getKey() << "\n";
+
+  } while( finder.findNextMetadata(tag) );
+}
+
+*/ +class FIP_API fipMetadataFind : public fipObject +{ +protected: + /// Pointer to a search handle + FIMETADATA *_mdhandle; + +public: + /// Returns TRUE if the search handle is allocated, FALSE otherwise + BOOL isValid() const; + + /// Constructor + fipMetadataFind(); + /** + Destructor + @see FreeImage_FindCloseMetadata + */ + virtual ~fipMetadataFind(); + /** + Provides information about the first instance of a tag that matches + the metadata model specified in the model argument. + @param model Metadata model + @param image Input image + @param tag Returned tag + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_FindFirstMetadata + */ + BOOL findFirstMetadata(FREE_IMAGE_MDMODEL model, fipImage& image, fipTag& tag); + /** + Find the next tag, if any, that matches the metadata model argument + in a previous call to findFirstMetadata + @param tag Returned tag + @return Returns TRUE if successful, returns FALSE otherwise, indicating that no more matching tags could be found + @see FreeImage_FindNextMetadata + */ + BOOL findNextMetadata(fipTag& tag); + +}; + +#endif // FREEIMAGEPLUS_H diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.rc b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.rc new file mode 100644 index 0000000..740b570 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.rc @@ -0,0 +1,44 @@ +#include + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 3,17,0,0 + PRODUCTVERSION 3,17,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e2" + BEGIN + VALUE "Comments", "FreeImage is an Open Source library project for developers who would like to support popular graphics image formats like PNG, BMP, JPEG, TIFF and others as needed by today's multimedia applications.\0" + VALUE "CompanyName", "FreeImage\0" + VALUE "FileDescription", "FreeImagePlus library\0" + VALUE "FileVersion", "3, 17, 0, 0\0" + VALUE "InternalName", "FreeImagePlus\0" + VALUE "LegalCopyright", "Copyright © 2003-2015 by FreeImage\0" + VALUE "LegalTrademarks", "See http://freeimage.sourceforge.net\0" + VALUE "OriginalFilename", "FreeImagePlus.dll\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "FreeImagePlus\0" + VALUE "ProductVersion", "3, 17, 0, 0\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1250 + END +END + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/WhatsNew_FIP.txt b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/WhatsNew_FIP.txt new file mode 100644 index 0000000..15a6877 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/WhatsNew_FIP.txt @@ -0,0 +1,184 @@ +What's New for FreeImagePlus + +* : fixed +- : removed +! : changed ++ : added + +March 01st, 2015 ++ [Herve Drolon] added fipImage::convertToRGBAF ++ [Herve Drolon] added fipImage::convertToRGBA16 ++ [Herve Drolon] added fipImage::getImageMemorySize +* [Herve Drolon] fixed returnd type of fipImage::getImageSize from LONG to unsigned + +July 17th, 2011 ++ [Herve Drolon] added fipImage::convertToRGB16 + +February 26th, 2011 ++ [Herve Drolon] added fipImage::convertToFloat + +November 14th, 2010 ++ [Herve Drolon] added getThumbnail, setThumbnail, hasThumbnail, clearThumbnail to fipImage + +November 7th, 2010 ++ [Herve Drolon] added fipImage::convertToUINT16 + +October 9th, 2010 +* [Herve Drolon] fixed fipWinImage::setToneMappingOperator when displaying RGBA HDR images + +April 18th, 2010 ++ [Herve Drolon] added new multi-page functions + added fipMemoryIO:close + added fipMemoryIO:loadMultiPage + added fipMemoryIO:saveMultiPage + added fipMultiPage:FIMULTIBITMAP* + added fipMultiPage:open(FreeImageIO *io, fi_handle handle, int flags = 0) + added fipMultiPage:saveToHandle + added fipMultiPage:saveToMemory + +October 24th, 2009 +! [Herve Drolon] fixed the '65535' width/height/pitch size limitation (need recompilation as several prototypes changed) + +September 1rd, 2009 +! [Herve Drolon] changed prototypes for fipWinImage::setToneMappingOperator and fipWinImage::getToneMappingOperator +! [Herve Drolon] changed prototype for fipImage::toneMapping +! [Herve Drolon] changed prototype for fipImage::rotate (now support optional supplied background color) ++ [Herve Drolon] added FreeImage_TmoReinhard05Ex capability to fipImage & fipWinImage + +August 11th, 2009 +* [Mihail Naydenov] fixed fipImage::operator=(FIBITMAP *dib) for cases where dib == _dib + +July 10th, 2009 ++ [Herve Drolon] added fipImage::adjustBrightnessContrastGamma(double brightness, double contrast, double gamma) + +October 27th, 2008 ++ [Herve Drolon] added FIF static identification functions to fipImage + +August 3rd, 2008 +* [dimitriy.b] fixed warnings about "non virtual destructor with virtual class members" with gcc 4.1.2 +* [Herve Drolon] fixed display of RGBAF EXR images in fipWinImage::drawEx + +October 10th, 2007 +* [Terry Russell] fixed a memory leak in fipWinImage::captureWindow + +January 20th, 2007 ++ [Herve Drolon] added support for 64-bit RGBA images + +January 11th, 2007 ++ [Herve Drolon] added setKeyValue method (a ASCII tag constructor) to fipTag ++ [Herve Drolon] added PSD format support to fipMultiPage::open + +October 30th, 2006 - 3.9.2 ++ [Herve Drolon] added BOOL fipMultiPage::open(fipMemoryIO& memIO, int flags) ++ [Herve Drolon] added fipMemoryIO::operator FIMEMORY*() +* [Herve Drolon] fixed missing 'isValid' method in fipMetadataFind + +July 16th, 2006 - 3.9.1 +* [Herve Drolon] fixed a bug in fipWinImage::copyFromBitmap occuring with palettized images + +July 6th, 2006 - 3.9.0 +! [Herve Drolon] renamed fipMemoryIO::read to fipMemoryIO::load +! [Herve Drolon] renamed fipMemoryIO::write to fipMemoryIO::save ++ [Herve Drolon] added fipMemoryIO::read (wrapper for FreeImage_ReadMemory) ++ [Herve Drolon] added fipMemoryIO::write (wrapper for FreeImage_WriteMemory) ++ [Herve Drolon] added version info to the DLL ++ [Herve Drolon] added fipImage::crop ++ [Herve Drolon] added support for most image types to fipImage::rescale ++ [Herve Drolon] added fipImage::makeThumbnail ++ [Herve Drolon] added fipTag ++ [Herve Drolon] added fipMetadataFind +* [Sandor Szalacsi] improved fipWinWimage::drawEx behavior with non transparent PNG having a file background +* [Herve Drolon] fixed a bug in fipWinImage::setToneMappingOperator +* [Conrado PLG] added const keyword to fip methods +* [Conrado PLG] made the copy constructors of fipMemoryIO private + +September 5, 2005 - 3.8.0 +[Herve Drolon] +! fipImage::convertToGrayscale now uses FreeImage_ConvertToGreyscale +! fipWinImage::captureWindow now converts 32-bit images to 24-bit ++ added UNICODE function fipImage::loadU ++ added UNICODE function fipImage::saveU ++ added load flags to fipMultiPage::open ++ fipWinImage::copyTo/FromHandle now work with non-standard bitmap types ++ added copy constructors to fipWinImage ++ added fipImage::clear() and fipWinImage::clear() +* fixed a bug in fipWinWimage::drawEx with non transparent PNG having a file background +* fixed fipMultiPage not reading GIF files +* fixed a bug in fipImage::rescale whan handling FIT_UINT16 bitmaps + +May 3rd, 2005 +[Herve Drolon] ++ added accessors fipImage::setModified and fipImage::isModified ++ added fipImage::convertToRGBF ++ added fipImage::toneMapping ++ added tone mapping functions to fipWinImage (see get/setToneMappingOperator) ++ added tone mapping capabilities to fipWinImage::drawEx + +January 5th, 2005 +[Herve Drolon] +! changed the prototype of get/set Resolution functions + +December 19th, 2004 +[Herve Drolon] +! updated fipImage::rotate to handle 1-bit images + +November 18th, 2004 +[Herve Drolon] ++ added fipImage::convertTo4Bits + +August 18th, 2004 +[Herve Drolon] +- removed fipInternetIO +- removed copy constructor fipImage::fipImage(const FIBITMAP*) +- removed copy constructor fipWinImage::fipWinImage(const FIBITMAP*) +! fipMemoryIO rewritten. It now wraps the FreeImage memory stream API +! fipGenericImage is now called fipObject ++ added fipImage::loadFromMemory ++ added fipImage::saveToMemory ++ added fipMultiPage + +March, 17th, 2004 +[Herve Drolon] +! fipImage::setSize now accepts color masks +* fixed fipWinImage::copyFromHandle not working with DIB having color masks + +February 11th, 2004 +[Herve Drolon] +- removed fipImage::getRedChannel +- removed fipImage::getGreenChannel +- removed fipImage::getBlueChannel +- removed fipImage::getAlphaChannel +- removed fipImage::setAlphaChannel ++ added fipImage::setChannel ++ added fipImage::isTransparent ++ added fipImage::getTransparencyCount ++ added fipImage::getTransparencyTable ++ added fipImage::setTransparencyTable ++ added fipImage::hasFileBkColor ++ added fipImage::getFileBkColor ++ added fipImage::setFileBkColor ++ added fipWinImage::drawEx +! fipWinImage::draw now works with transparent images + +January 26th, 2004 +[Herve Drolon] ++ added fipMemoryIO ++ added fipInternetIO (WIN32 only) ++ added fipImage::getImageType ++ added fipImage::convertToType ++ added fipWinImage::copyToClipboard ++ added fipWinImage::pasteFromClipboard ++ added fipWinImage::captureWindow + +! changed fipImage constructor +! fipWinImage::copyFromHandle now returns a BOOL +! fipWinImage::copyFromBitmap now returns a BOOL + +November 2, 2003 ++ [Herve Drolon] added fipImage::getScanLine + +October 20, 2003 +* [Dennis Lim] fixed a bug in fipImage constructor +! [Herve Drolon] fixed a bug with fipImage::saveToHandle prototype + +September 8th 2003 - Wrapper for FreeImage 3.0.0 diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/clean.bat b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/clean.bat new file mode 100644 index 0000000..65a5e36 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/clean.bat @@ -0,0 +1,26 @@ +del dist\*.dll /s /q +del dist\*.lib /s /q +del dist\*.h /s /q +del *.ncb /s /q +del *.plg /s /q +del *.opt /s /q +del *.suo /s /q /a:h +del *.user /s /q +del *.log /s /q +del *.sdf /s /q +del test\page*.tiff +del test\*.png +del test\mpage*.tif +del test\clone*.tif +del test\redirect-stream.tif +rd dist\x64 /s /q +rd dist\x32 /s /q +rd Release /s /q +rd Debug /s /q +rd x64 /s /q +rd Win32 /s /q +rd test\x64 /s /q +rd test\Win32 /s /q +rd test\Debug /s /q +rd test\Release /s /q + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/delete.me b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/delete.me new file mode 100644 index 0000000..e69de29 diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x32/FreeImagePlus.dll b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x32/FreeImagePlus.dll new file mode 100644 index 0000000..90977a4 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x32/FreeImagePlus.dll differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x32/FreeImagePlus.h b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x32/FreeImagePlus.h new file mode 100644 index 0000000..571010f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x32/FreeImagePlus.h @@ -0,0 +1,1713 @@ +// ========================================================== +// FreeImagePlus 3 +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#ifndef FREEIMAGEPLUS_H +#define FREEIMAGEPLUS_H + +#ifdef _WIN32 +#include +#endif // _WIN32 +#include "FreeImage.h" + + +// Compiler options --------------------------------------------------------- + +#if defined(FREEIMAGE_LIB) + #define FIP_API + #define FIP_CALLCONV +#else + #if defined(_WIN32) || defined(__WIN32__) + #define WIN32_LEAN_AND_MEAN + #define FIP_CALLCONV __stdcall + // The following ifdef block is the standard way of creating macros which make exporting + // from a DLL simpler. All files within this DLL are compiled with the FIP_EXPORTS + // symbol defined on the command line. this symbol should not be defined on any project + // that uses this DLL. This way any other project whose source files include this file see + // FIP_API functions as being imported from a DLL, wheras this DLL sees symbols + // defined with this macro as being exported. + #ifdef FIP_EXPORTS + #define FIP_API __declspec(dllexport) + #else + #define FIP_API __declspec(dllimport) + #endif // FIP_EXPORTS + #else + // try the gcc visibility support (see http://gcc.gnu.org/wiki/Visibility) + #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) + #ifndef GCC_HASCLASSVISIBILITY + #define GCC_HASCLASSVISIBILITY + #endif + #endif + #define FIP_CALLCONV + #if defined(GCC_HASCLASSVISIBILITY) + #define FIP_API __attribute__ ((visibility("default"))) + #else + #define FIP_API + #endif + #endif // WIN32 / !WIN32 +#endif // FREEIMAGE_LIB + +/////////////////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------- + +/** Abstract base class for all objects used by the library. + @version FreeImage 3 + @author Hervé Drolon +*/ + +class FIP_API fipObject +{ +public: + /// Destructor + virtual ~fipObject(){}; + + /**@name Information functions */ + //@{ + /// Returns TRUE if the object is allocated, FALSE otherwise + virtual BOOL isValid() const = 0; + //@} +}; + +// ---------------------------------------------------------- + +class fipMemoryIO; +class fipMultiPage; +class fipTag; + +/** A class used to manage all photo related images and all image types used by the library. + + fipImage encapsulates the FIBITMAP format. It relies on the FreeImage library, especially for + loading / saving images and for bit depth conversion. + @version FreeImage 3 + @author Hervé Drolon +*/ + +class FIP_API fipImage : public fipObject +{ +protected: + /// DIB data + FIBITMAP *_dib; + /// Original (or last saved) fif format if available, FIF_UNKNOWN otherwise + FREE_IMAGE_FORMAT _fif; + /// TRUE whenever the display need to be refreshed + mutable BOOL _bHasChanged; + +public: + friend class fipMultiPage; + +public: + + /**@name Creation & Destruction */ + //@{ + /** + Constructor + @see FreeImage_AllocateT + */ + fipImage(FREE_IMAGE_TYPE image_type = FIT_BITMAP, unsigned width = 0, unsigned height = 0, unsigned bpp = 0); + /// Destructor + virtual ~fipImage(); + /** + Image allocator + @see FreeImage_AllocateT + */ + BOOL setSize(FREE_IMAGE_TYPE image_type, unsigned width, unsigned height, unsigned bpp, unsigned red_mask = 0, unsigned green_mask = 0, unsigned blue_mask = 0); + /// Destroy image data + virtual void clear(); + //@} + + /**@name Copying */ + //@{ + /** + Copy constructor + @see FreeImage_Clone + */ + fipImage(const fipImage& src); + /** + Copy constructor + @see FreeImage_Clone + */ + fipImage& operator=(const fipImage& src); + /** + Assignement operator
+ Copy the input pointer and manage its destruction + @see operator FIBITMAP*() + */ + fipImage& operator=(FIBITMAP *dib); + + + /** + @brief Copy a sub part of the current image and returns it as a fipImage object. + + This method works with any bitmap type. + @param dst Output subimage + @param left Specifies the left position of the cropped rectangle. + @param top Specifies the top position of the cropped rectangle. + @param right Specifies the right position of the cropped rectangle. + @param bottom Specifies the bottom position of the cropped rectangle. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Copy + */ + BOOL copySubImage(fipImage& dst, int left, int top, int right, int bottom) const; + + /** + @brief Alpha blend or combine a sub part image with the current image. + + The bit depth of dst bitmap must be greater than or equal to the bit depth of src. + Upper promotion of src is done internally. Supported bit depth equals to 4, 8, 16, 24 or 32. + @param src Source subimage + @param left Specifies the left position of the sub image. + @param top Specifies the top position of the sub image. + @param alpha Alpha blend factor. The source and destination images are alpha blended if + alpha = 0..255. If alpha > 255, then the source image is combined to the destination image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Paste + */ + BOOL pasteSubImage(fipImage& src, int left, int top, int alpha = 256); + + /** + @brief Crop a sub part of the current image and update it accordingly. + + This method works with any bitmap type. + @param left Specifies the left position of the cropped rectangle. + @param top Specifies the top position of the cropped rectangle. + @param right Specifies the right position of the cropped rectangle. + @param bottom Specifies the bottom position of the cropped rectangle. + @return Returns TRUE if successful, FALSE otherwise. + */ + BOOL crop(int left, int top, int right, int bottom); + + //@} + + /** @name File type identification + */ + //@{ + /** + @brief Identifies an image from disk, given its file name + @param lpszPathName Path and file name of the image to identify. + @return Returns the found FreeImage format if successful, returns FIF_UNKNOWN otherwise. + @see FreeImage_GetFileType, FreeImage_GetFIFFromFilename, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIF(const char* lpszPathName); + + /** + UNICODE version of identifyFIF (this function only works under WIN32 and does nothing on other OS) + @see FreeImage_GetFileTypeU, FreeImage_GetFIFFromFilenameU, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIFU(const wchar_t* lpszPathName); + + /** + @brief Identifies an image using the specified FreeImageIO struct and fi_handle. + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @return Returns the found FreeImage format if successful, returns FIF_UNKNOWN otherwise. + @see FreeImage_GetFileTypeFromHandle, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIFFromHandle(FreeImageIO *io, fi_handle handle); + + /** + @brief Identifies an image using the specified memory stream. + @param hmem FreeImage memory stream + @return Returns the found FreeImage format if successful, returns FIF_UNKNOWN otherwise. + @see FreeImage_GetFileTypeFromMemory, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIFFromMemory(FIMEMORY *hmem); + + //@} + + + /** @name Loading & Saving + * Loading and saving is handled by the FreeImage library. + */ + //@{ + /** + @brief Loads an image from disk, given its file name and an optional flag. + @param lpszPathName Path and file name of the image to load. + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Load, FreeImage documentation + */ + BOOL load(const char* lpszPathName, int flag = 0); + + /** + UNICODE version of load (this function only works under WIN32 and does nothing on other OS) + @see load + */ + BOOL loadU(const wchar_t* lpszPathName, int flag = 0); + + /** + @brief Loads an image using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_LoadFromHandle, FreeImage documentation + */ + BOOL loadFromHandle(FreeImageIO *io, fi_handle handle, int flag = 0); + + /** + @brief Loads an image using the specified memory stream and an optional flag. + @param memIO FreeImage memory stream + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_LoadFromMemory, FreeImage documentation + */ + BOOL loadFromMemory(fipMemoryIO& memIO, int flag = 0); + + /** + @brief Saves an image to disk, given its file name and an optional flag. + @param lpszPathName Path and file name of the image to save. + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Save, FreeImage documentation + */ + BOOL save(const char* lpszPathName, int flag = 0) const; + + /** + UNICODE version of save (this function only works under WIN32 and does nothing on other OS) + @see save + */ + BOOL saveU(const wchar_t* lpszPathName, int flag = 0) const; + + /** + @brief Saves an image using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param fif Format identifier (FreeImage format) + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveToHandle, FreeImage documentation + */ + BOOL saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flag = 0) const; + + /** + @brief Saves an image using the specified memory stream and an optional flag. + @param fif Format identifier (FreeImage format) + @param memIO FreeImage memory stream + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveToMemory, FreeImage documentation + */ + BOOL saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flag = 0) const; + + //@} + + /** @name Information functions + * Accessors to the DIB BITMAPINFO structure. + */ + //@{ + + /** + Returns the data type of the image + @see FreeImage_GetImageType + */ + FREE_IMAGE_TYPE getImageType() const; + + /** + Returns the image width in pixels + @see FreeImage_GetWidth + */ + unsigned getWidth() const; + + /** + Returns the image height in pixels + @see FreeImage_GetHeight + */ + unsigned getHeight() const; + + /** + Returns the width of the bitmap in bytes rounded to the nearest DWORD. + @see FreeImage_GetPitch + */ + unsigned getScanWidth() const; + + /** + Returns a pointer to the FIBITMAP data. Used for direct access from FREEIMAGE functions + or from your own low level C functions.
+ Sample use :
+
+	fipImage src, dst;
+	src.load("test.png");
+	dst = FreeImage_ConvertTo8Bits(src);
+	FreeImage_Save(FIF_TIFF, dst, "test.tif", 0);
+	
+ @see operator=(FIBITMAP *dib) + */ + operator FIBITMAP*() { + return _dib; + } + + /// Returns TRUE if the image is allocated, FALSE otherwise + BOOL isValid() const; + + /** + Returns a pointer to the bitmap's BITMAPINFO header. + @see FreeImage_GetInfo + */ + BITMAPINFO* getInfo() const; + + /** + Returns a pointer to the bitmap's BITMAPINFOHEADER. + @see FreeImage_GetInfoHeader + */ + BITMAPINFOHEADER* getInfoHeader() const; + + /** + Returns the size of the bitmap in bytes. + The size of the bitmap is the BITMAPINFOHEADER + the size of the palette + the size of the bitmap data. + @see FreeImage_GetDIBSize + */ + unsigned getImageSize() const; + + /** + Returns the memory footprint of a bitmap, in bytes. + @see FreeImage_GetMemorySize + */ + unsigned getImageMemorySize() const; + + /** + Returns the bitdepth of the bitmap.
+ When the image type is FIT_BITMAP, valid bitdepth can be 1, 4, 8, 16, 24 or 32. + @see FreeImage_GetBPP, getImageType + */ + unsigned getBitsPerPixel() const; + + /** + Returns the width of the bitmap in bytes.
+ This is not the size of the scanline. + @see FreeImage_GetLine, getScanWidth + */ + unsigned getLine() const; + + /** + Returns the bitmap resolution along the X axis, in pixels / cm + @see FreeImage_GetDotsPerMeterX + */ + double getHorizontalResolution() const; + + /** + Returns the bitmap resolution along the Y axis, in pixels / cm + @see FreeImage_GetDotsPerMeterY + */ + double getVerticalResolution() const; + + /** + set the bitmap resolution along the X axis, in pixels / cm + @see FreeImage_GetInfoHeader + */ + void setHorizontalResolution(double value); + + /** + set the bitmap resolution along the Y axis, in pixels / cm + @see FreeImage_GetInfoHeader + */ + void setVerticalResolution(double value); + + //@} + + /**@name Palette operations */ + //@{ + /** + Returns a pointer to the bitmap's palette. If the bitmap doesn't have a palette, getPalette returns NULL. + @see FreeImage_GetPalette + */ + RGBQUAD* getPalette() const; + + /** + Returns the palette size in bytes. + @see FreeImage_GetColorsUsed + */ + unsigned getPaletteSize() const; + + /** + Retrieves the number of colours used in the bitmap. If the bitmap is non-palletised, 0 is returned. + @see FreeImage_GetColorsUsed + */ + unsigned getColorsUsed() const; + + /** + Investigates the colour type of the bitmap. + @see FreeImage_GetColorType, FREE_IMAGE_COLOR_TYPE + */ + FREE_IMAGE_COLOR_TYPE getColorType() const; + + /** + Returns TRUE if the bitmap is a 8-bit bitmap with a greyscale palette, FALSE otherwise + @see FreeImage_GetBPP, FreeImage_GetColorType + */ + BOOL isGrayscale() const; + //@} + + /**@name Thumbnail access */ + //@{ + + /** + Retrieves a copy the thumbnail possibly attached to the bitmap + @return Returns TRUE if the thumbnail is present in the bitmap and successfuly retrieved, returns FALSE otherwise + @see FreeImage_GetThumbnail + */ + BOOL getThumbnail(fipImage& image) const; + + /** + Attach a thumbnail to the bitmap + @return Returns TRUE if the thumbnail was successfuly set, returns FALSE otherwise + @see FreeImage_SetThumbnail + */ + BOOL setThumbnail(const fipImage& image); + + /** + Check if the image has an embedded thumbnail + @return Returns TRUE if a thumbnail is present in the bitmap, returns FALSE otherwise + @see FreeImage_GetThumbnail + */ + BOOL hasThumbnail() const; + + /** + Clear the thumbnail possibly attached to the bitmap + @return Returns TRUE if successful, returns FALSe otherwise + @see FreeImage_SetThumbnail + */ + BOOL clearThumbnail(); + + //@} + + /**@name Pixel access */ + //@{ + + /** @brief Returns a pointer to the bitmap bits. + + It is up to you to interpret these bytes correctly, + according to the results of FreeImage_GetBPP and + GetRedMask, FreeImage_GetGreenMask and FreeImage_GetBlueMask.
+ Use this function with getScanWidth to iterates through the pixels. + @see FreeImage_GetBits + */ + BYTE* accessPixels() const; + + /** @brief Returns a pointer to the start of the given scanline in the bitmap’s data-bits. + This pointer can be cast according to the result returned by getImageType.
+ Use this function with getScanWidth to iterates through the pixels. + @see FreeImage_GetScanLine, FreeImage documentation + */ + BYTE* getScanLine(unsigned scanline) const; + + /** + Get the pixel index of a 1-, 4- or 8-bit palettized image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel index (returned value) + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetPixelIndex + */ + BOOL getPixelIndex(unsigned x, unsigned y, BYTE *value) const; + + /** + Get the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel color (returned value) + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetPixelColor + */ + BOOL getPixelColor(unsigned x, unsigned y, RGBQUAD *value) const; + + /** + Set the pixel index of a 1-, 4- or 8-bit palettized image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel index + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetPixelIndex + */ + BOOL setPixelIndex(unsigned x, unsigned y, BYTE *value); + + /** + Set the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel color + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetPixelColor + */ + BOOL setPixelColor(unsigned x, unsigned y, RGBQUAD *value); + + //@} + + /** @name Conversion routines + * Bitmaps are always loaded in their default bit depth. If you want the bitmap to be stored in another bit depth, the class provides several conversion functions. + */ + //@{ + /** + Converts an image to a type supported by FreeImage. + @param image_type New image type + @param scale_linear TRUE if image pixels must be scaled linearly when converting to a standard bitmap + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToType, FreeImage_ConvertToStandardType + */ + BOOL convertToType(FREE_IMAGE_TYPE image_type, BOOL scale_linear = TRUE); + + /** + Converts the bitmap to 1 bit using a threshold T. + @param T Threshold value in [0..255] + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Threshold + */ + BOOL threshold(BYTE T); + + /** + Converts a 8-bit image to a monochrome 1-bit image using a dithering algorithm. + @param algorithm Dithering algorithm to use. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Dither, FREE_IMAGE_DITHER + */ + BOOL dither(FREE_IMAGE_DITHER algorithm); + + /** + Converts the bitmap to 4 bits. Unless the bitmap is a 1-bit palettized bitmap, colour values are converted to greyscale. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo4Bits + */ + BOOL convertTo4Bits(); + + /** + Converts the bitmap to 8 bits. If the bitmap is 24 or 32-bit RGB, the colour values are converted to greyscale. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo8Bits + */ + BOOL convertTo8Bits(); + + /** + Converts the bitmap to 8 bits.
+ For palletized bitmaps, the color map is converted to a greyscale ramp. + @see FreeImage_ConvertToGreyscale + @return Returns TRUE if successful, FALSE otherwise. + */ + BOOL convertToGrayscale(); + + /** + Quantizes a full colour 24-bit bitmap to a palletised 8-bit bitmap.
+ The quantize parameter specifies which colour reduction algorithm should be used. + @param algorithm Color quantization algorithm to use. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ColorQuantize, FREE_IMAGE_QUANTIZE + */ + BOOL colorQuantize(FREE_IMAGE_QUANTIZE algorithm); + + /** + Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 5 bits green, 5 bits blue and 1 unused bit. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo16Bits555 + */ + BOOL convertTo16Bits555(); + + /** + Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 6 bits green and 5 bits blue. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo16Bits565 + */ + BOOL convertTo16Bits565(); + + /** + Converts the bitmap to 24 bits. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo24Bits + */ + BOOL convertTo24Bits(); + + /** + Converts the bitmap to 32 bits. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo32Bits + */ + BOOL convertTo32Bits(); + + /** + Converts the bitmap to a 32-bit float image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToFloat + */ + BOOL convertToFloat(); + + /** + Converts the bitmap to a 96-bit RGBF image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGBF + */ + BOOL convertToRGBF(); + + /** + Converts the bitmap to a 128-bit RGBAF image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGBAF + */ + BOOL convertToRGBAF(); + + /** + Converts the bitmap to a 16-bit unsigned short image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToUINT16 + */ + BOOL convertToUINT16(); + + /** + Converts the bitmap to a 48-bit RGB16 image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGB16 + */ + BOOL convertToRGB16(); + + /** + Converts the bitmap to a 64-bit RGBA16 image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGBA16 + */ + BOOL convertToRGBA16(); + + /** + Converts a High Dynamic Range image (48-bit RGB or 96-bit RGB Float) to a 24-bit RGB image. + @param tmo Tone mapping operator + @param first_param First tone mapping algorithm parameter (algorithm dependant) + @param second_param Second tone mapping algorithm parameter (algorithm dependant) + @param third_param Third tone mapping algorithm parameter (algorithm dependant) + @param fourth_param Fourth tone mapping algorithm parameter (algorithm dependant) + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ToneMapping, FreeImage_TmoReinhard05Ex + */ + BOOL toneMapping(FREE_IMAGE_TMO tmo, double first_param = 0, double second_param = 0, double third_param = 1, double fourth_param = 0); + + //@} + + /** @name Transparency support: background colour and alpha channel */ + //@{ + + /** + Returns TRUE if the image is transparent, returns FALSE otherwise + @see FreeImage_IsTransparent + */ + BOOL isTransparent() const; + + /** + 8-bit transparency : get the number of transparent colors. + @return Returns the number of transparent colors in a palletised bitmap. + @see FreeImage_GetTransparencyCount + */ + unsigned getTransparencyCount() const; + + /** + 8-bit transparency : get the bitmap’s transparency table. + @return Returns a pointer to the bitmap’s transparency table. + @see FreeImage_GetTransparencyTable + */ + BYTE* getTransparencyTable() const; + + /** + 8-bit transparency : set the bitmap’s transparency table. + @see FreeImage_SetTransparencyTable + */ + void setTransparencyTable(BYTE *table, int count); + + /** + Returns TRUE when the image has a file background color, FALSE otherwise. + @see FreeImage_HasBackgroundColor + */ + BOOL hasFileBkColor() const; + + /** + @brief Retrieves the file background color of an image. + + For 8-bit images, the color index + in the palette is returned in the rgbReserved member of the bkcolor parameter. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetBackgroundColor + */ + BOOL getFileBkColor(RGBQUAD *bkcolor) const; + + /** + @brief Set the file background color of an image. + + When saving an image to PNG, this background color is transparently saved to the PNG file. + When the bkcolor parameter is NULL, the background color is removed from the image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetBackgroundColor + */ + BOOL setFileBkColor(RGBQUAD *bkcolor); + //@} + + /**@name Channel processing support */ + //@{ + /** @brief Retrieves the red, green, blue or alpha channel of a 24- or 32-bit BGR[A] image. + @param image Output image to be extracted + @param channel Color channel to extract + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetChannel, FREE_IMAGE_COLOR_CHANNEL + */ + BOOL getChannel(fipImage& image, FREE_IMAGE_COLOR_CHANNEL channel) const; + + /** + @brief Insert a 8-bit dib into a 24- or 32-bit image. + @param image Input 8-bit image to insert + @param channel Color channel to replace + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetChannel, FREE_IMAGE_COLOR_CHANNEL + */ + BOOL setChannel(fipImage& image, FREE_IMAGE_COLOR_CHANNEL channel); + + /** @brief Split a 24-bit RGB image into 3 greyscale images corresponding to the red, green and blue channels. + @param RedChannel Output red channel. + @param GreenChannel Output green channel. + @param BlueChannel Output blue channel. + @return Returns FALSE if the dib isn't a valid image, if it's not a 24-bit image or if + one of the output channel can't be allocated. Returns TRUE otherwise. + @see FreeImage_GetChannel + */ + BOOL splitChannels(fipImage& RedChannel, fipImage& GreenChannel, fipImage& BlueChannel); + + /** @brief Builds a 24-bit RGB image given its red, green and blue channel. + @param red Input red channel. + @param green Input green channel. + @param blue Input blue channel. + @return Returns FALSE if the dib can't be allocated, if the input channels are not 8-bit images. Returns TRUE otherwise. + @see FreeImage_SetChannel + */ + BOOL combineChannels(fipImage& red, fipImage& green, fipImage& blue); + //@} + + /**@name Rotation and flipping */ + //@{ + /** + Image translation and rotation using B-Splines. + @param angle Image rotation angle, in degree + @param x_shift Image horizontal shift + @param y_shift Image vertical shift + @param x_origin Origin of the x-axis + @param y_origin Origin of the y-axis + @param use_mask Whether or not to mask the image. Image mirroring is applied when use_mask is set to FALSE + @return Returns the translated & rotated dib if successful, returns NULL otherwise + @see FreeImage_RotateEx + */ + BOOL rotateEx(double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask); + + /** + Image rotation by means of three shears. + @param angle Image rotation angle, in degree + @param bkcolor Background color (image type dependent), default to black background + @return Returns rotated dib if successful, returns NULL otherwise + @see FreeImage_Rotate + */ + BOOL rotate(double angle, const void *bkcolor = NULL); + + /** + Flip the image horizontally along the vertical axis + @see FreeImage_FlipHorizontal + */ + BOOL flipHorizontal(); + + /** + Flip the image vertically along the horizontal axis + @see FreeImage_FlipVertical + */ + BOOL flipVertical(); + //@} + + /**@name Color manipulation routines */ + //@{ + /** + Inverts each pixel data. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Invert + */ + BOOL invert(); + + /** @brief Perfoms an histogram transformation on a 8, 24 or 32-bit image + according to the values of a lookup table (LUT). + + The transformation is done as follows.
+ Image 8-bit : if the image has a color palette, the LUT is applied to this palette, + otherwise, it is applied to the grey values.
+ Image 24-bit & 32-bit : if channel == IPL_CC_RGB, the same LUT is applied to each color + plane (R,G, and B). Otherwise, the LUT is applied to the specified channel only. + @param LUT Lookup table. The size of 'LUT' is assumed to be 256. + @param channel The color channel to be processed (only used with 24 & 32-bit DIB). + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_AdjustCurve, FREE_IMAGE_COLOR_CHANNEL + */ + BOOL adjustCurve(BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel); + + /** @brief Performs gamma correction on a 8, 24 or 32-bit image. + @param gamma Gamma value to use. A value of 1.0 leaves the image alone, + less than one darkens it, and greater than one lightens it. + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_AdjustGamma, adjustCurve + */ + BOOL adjustGamma(double gamma); + + /** @brief Adjusts the brightness of a 8, 24 or 32-bit image by a certain amount. + @param percentage Where -100 <= percentage <= 100
+ A value 0 means no change, less than 0 will make the image darker + and greater than 0 will make the image brighter. + @return Returns TRUE if the operation was succesful, FALSE otherwise + @see FreeImage_AdjustBrightness, adjustCurve + */ + BOOL adjustBrightness(double percentage); + + /** @brief Adjusts the contrast of a 8, 24 or 32-bit image by a certain amount. + @param percentage Where -100 <= percentage <= 100
+ A value 0 means no change, less than 0 will decrease the contrast + and greater than 0 will increase the contrast of the image. + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_AdjustContrast, adjustCurve + */ + BOOL adjustContrast(double percentage); + + /** + Adjusts an image's brightness, contrast and gamma within a single operation. + If more than one of these image display properties need to be adjusted, + using this function should be preferred over calling each adjustment function separately. + That's particularly true for huge images or if performance is an issue. + @see adjustBrightness + @see adjustContrast + @see adjustGamma + @see FreeImage_AdjustColors + */ + BOOL adjustBrightnessContrastGamma(double brightness, double contrast, double gamma); + + /** @brief Computes image histogram + + For 24-bit and 32-bit images, histogram can be computed from red, green, blue and + black channels. For 8-bit images, histogram is computed from the black channel. Other + bit depth is not supported. + @param histo pointer to an histogram array. Size of this array is assumed to be 256. + @param channel Color channel to use + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_GetHistogram + */ + BOOL getHistogram(DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel = FICC_BLACK) const; + //@} + + /**@name Upsampling / downsampling */ + //@{ + + /** @brief Rescale the image to a new width / height. + + @param new_width New image width + @param new_height New image height + @param filter The filter parameter specifies which resampling filter should be used. + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_Rescale, FREE_IMAGE_FILTER + */ + BOOL rescale(unsigned new_width, unsigned new_height, FREE_IMAGE_FILTER filter); + + /** @brief Creates a thumbnail image keeping aspect ratio + + @param max_size Maximum width or height in pixel units + @param convert When set to TRUE, converts the image to a standard type + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_MakeThumbnail + */ + BOOL makeThumbnail(unsigned max_size, BOOL convert = TRUE); + //@} + + /**@name Image status */ + //@{ + /** + Set the image status as 'modified'.
+ When using the fipWinImage class, the image status is used to refresh the display. + It is changed to FALSE whenever the display has just been refreshed. + @param bStatus TRUE if the image should be marked as modified, FALSE otherwise + @see isModified + */ + void setModified(BOOL bStatus = TRUE) { + _bHasChanged = bStatus; + } + + /** + Get the image status + @return Returns TRUE if the image is marked as modified, FALSE otherwise + @see setModified + */ + BOOL isModified() { + return _bHasChanged; + } + //@} + + /**@name Metadata */ + //@{ + /** + Returns the number of tags contained in the model metadata model + attached to the dib + @param model Metadata model to look for + */ + unsigned getMetadataCount(FREE_IMAGE_MDMODEL model) const; + /** + Retrieve a metadata attached to the dib + @param model Metadata model to look for + @param key Metadata field name + @param tag Returned tag + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_GetMetadata + */ + BOOL getMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag& tag) const; + /** + Attach a new FreeImage tag to the dib.
+ Sample use :
+
+	fipImage image;
+	// ...
+	fipTag tag;
+	tag.setKeyValue("Caption/Abstract", "my caption");
+	image.setMetadata(FIMD_IPTC, tag.getKey(), tag);
+	tag.setKeyValue("Keywords", "FreeImage;Library;Images;Compression");
+	image.setMetadata(FIMD_IPTC, tag.getKey(), tag);
+	
+ + @param model Metadata model used to store the tag + @param key Tag field name + @param tag Tag to be attached + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_SetMetadata + */ + BOOL setMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag& tag); + //@} + + + protected: + /**@name Internal use */ + //@{ + BOOL replace(FIBITMAP *new_dib); + //@} + +}; + +// ---------------------------------------------------------- + +/** A class designed for MS Windows (TM) platforms. + + fipWinImage provides methods used to : +
    +
  • Display a DIB on the screen +
  • Copy / Paste a DIB to/from Windows devices (HANDLE, HBITMAP, Clipboard) +
  • Capture a window (HWND) and convert it to an image +
+ @version FreeImage 3 + @author Hervé Drolon +*/ +#ifdef _WIN32 + +class FIP_API fipWinImage : public fipImage +{ +public: + /**@name Creation & Destruction */ + //@{ + /// Constructor + fipWinImage(FREE_IMAGE_TYPE image_type = FIT_BITMAP, unsigned width = 0, unsigned height = 0, unsigned bpp = 0); + + /// Destructor + virtual ~fipWinImage(); + + /// Destroy image data + virtual void clear(); + + /// Returns TRUE if the image is allocated, FALSE otherwise + BOOL isValid() const; + //@} + + /**@name Copying */ + //@{ + + /** + Copy constructor. + Delete internal _display_dib data and copy the base class image data. + Tone mapping parameters are left unchanged. + @see FreeImage_Clone + */ + fipWinImage& operator=(const fipImage& src); + + /** + Copy constructor + Delete internal _display_dib data and copy tone mapping parameters. + Copy also the base class image data. + @see FreeImage_Clone + */ + fipWinImage& operator=(const fipWinImage& src); + + /** Clone function used for clipboard copy.
+ Convert the FIBITMAP image to a DIB, + and transfer the DIB in a global bitmap handle.
+ For non standard bitmaps, the BITMAPINFOHEADER->biCompression field is set to 0xFF + FreeImage_GetImageType(_dib), + in order to recognize the bitmap as non standard. + */ + HANDLE copyToHandle() const; + + /** Copy constructor used for clipboard paste.
+ Converts a global object to a FIBITMAP. The clipboard format must be CF_DIB.
+ When the BITMAPINFOHEADER->biCompression field is set to 0xFF + [one of the predefined FREE_IMAGE_TYPE], + the bitmap is recognized as non standard and correctly copied. + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL copyFromHandle(HANDLE hMem); + + /** Copy constructor.
+ Converts a HBITMAP object to a FIBITMAP. + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL copyFromBitmap(HBITMAP hbmp); + //@} + + /**@name Clipboard operations */ + //@{ + /** + Clipboard copy. + @param hWndNewOwner Handle to the window to be associated with the open clipboard. + In MFC, you can use AfxGetApp()->m_pMainWnd->GetSafeHwnd(). + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL copyToClipboard(HWND hWndNewOwner) const; + + /** + Retrieves data from the clipboard. The clipboard format must be CF_DIB. + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL pasteFromClipboard(); + //@} + + /**@name Screen capture */ + //@{ + /** Capture a window and convert it to an image + @param hWndApplicationWindow Handle to the application main window + @param hWndSelectedWindow Handle to the window to be captured + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL captureWindow(HWND hWndApplicationWindow, HWND hWndSelectedWindow); + //@} + + + /**@name Painting operations */ + //@{ + + /** @brief Draw (stretch) the image on a HDC, using StretchDIBits. + + When the image is transparent or has a file background, this function composite + the foreground image against a checkerboard background image. + @param hDC Handle to the device context + @param rcDest Destination rectangle + @see FreeImage_Composite + */ + void draw(HDC hDC, RECT& rcDest) const { + drawEx(hDC, rcDest, FALSE, NULL, NULL); + } + + /** @brief Draw (stretch) the image on a HDC, using StretchDIBits. + + When the image is transparent or has a file background, this function can composite + the foreground image against a checkerboard background image, against a single background color or + against a user background image.
+ When the image is a High Dynamic Range image (48-bit or RGB float), this function will apply a + tone mapping operator before drawing the image.
+ The original image (located in the fipImage class) will not be affected by any of the operations + that could be done in order to display it. + @param hDC Handle to the device context + @param rcDest Destination rectangle + @param useFileBkg When set to TRUE, the function uses the file color background if there is one + @param appBkColor When a color is given, the function uses it as the background color + @param bg When a FIBITMAP is given, the function uses it as the background image + @see FreeImage_Composite + @see setToneMappingOperator + */ + void drawEx(HDC hDC, RECT& rcDest, BOOL useFileBkg = FALSE, RGBQUAD *appBkColor = NULL, FIBITMAP *bg = NULL) const; + + /** + Select a tone mapping algorithm used for drawing and set the image as modified + so that the display will be refreshed. + @param tmo Tone mapping operator + @param first_param First tone mapping algorithm parameter + @param second_param Second tone mapping algorithm parameter + @param third_param Third tone mapping algorithm parameter + @param fourth_param Fourth tone mapping algorithm parameter + @see FreeImage_ToneMapping + */ + void setToneMappingOperator(FREE_IMAGE_TMO tmo, double first_param = 0, double second_param = 0, double third_param = 1, double fourth_param = 0); + + /** + Get the tone mapping algorithm used for drawing, with its parameters. + @param tmo Tone mapping operator + @param first_param First tone mapping algorithm parameter + @param second_param Second tone mapping algorithm parameter + @param third_param Third tone mapping algorithm parameter + @param fourth_param Fourth tone mapping algorithm parameter + @see FreeImage_ToneMapping + */ + void getToneMappingOperator(FREE_IMAGE_TMO *tmo, double *first_param, double *second_param, double *third_param, double *fourth_param) const; + + //@} + +protected: + /// DIB used for display (this allow to display non-standard bitmaps) + mutable FIBITMAP *_display_dib; + /// remember to delete _display_dib + mutable BOOL _bDeleteMe; + /// tone mapping operator + FREE_IMAGE_TMO _tmo; + /// first tone mapping algorithm parameter + double _tmo_param_1; + /// second tone mapping algorithm parameter + double _tmo_param_2; + /// third tone mapping algorithm parameter + double _tmo_param_3; + /// fourth tone mapping algorithm parameter + double _tmo_param_4; +}; + +#endif // _WIN32 + +// ---------------------------------------------------------- + +/** Memory handle + + fipMemoryIO is a class that allows you to load / save images from / to a memory stream. + @version FreeImage 3 + @author Hervé Drolon +*/ +class FIP_API fipMemoryIO : public fipObject +{ +protected: + /// Pointer to a memory stream + FIMEMORY *_hmem; + +public : + /** Constructor. + Wrap a memory buffer containing image data.
+ The memory buffer is read only and has to be freed by the user + when no longer in use.
+ When default arguments are used, open a memory file as read/write. + @param data Pointer to the memory buffer + @param size_in_bytes Buffer size in bytes + @see FreeImage_OpenMemory + */ + fipMemoryIO(BYTE *data = NULL, DWORD size_in_bytes = 0); + + /** Destructor. + Free any allocated memory + @see FreeImage_CloseMemory + */ + virtual ~fipMemoryIO(); + + /** Destructor. + Free any allocated memory and invalidate the stream + @see FreeImage_CloseMemory + */ + void close(); + + /** Returns TRUE if the internal memory buffer is a valid buffer, returns FALSE otherwise + */ + BOOL isValid() const; + + /** Returns the buffer image format + @see FreeImage_GetFileTypeFromMemory + */ + FREE_IMAGE_FORMAT getFileType() const; + + /** + Returns a pointer to the FIMEMORY data. Used for direct access from FREEIMAGE functions + or from your own low level C functions. + */ + operator FIMEMORY*() { + return _hmem; + } + + /**@name Memory IO routines */ + //@{ + /** + Loads a dib from a memory stream + @param fif Format identifier (FreeImage format) + @param flags The signification of this flag depends on the image to be loaded. + @return Returns the loaded dib if successful, returns NULL otherwise + @see FreeImage_LoadFromMemory + */ + FIBITMAP* load(FREE_IMAGE_FORMAT fif, int flags = 0) const; + /** + Loads a multi-page bitmap from a memory stream + @param fif Format identifier (FreeImage format) + @param flags The signification of this flag depends on the multi-page to be loaded. + @return Returns the loaded multi-page if successful, returns NULL otherwise + @see FreeImage_LoadMultiBitmapFromMemory + */ + FIMULTIBITMAP* loadMultiPage(FREE_IMAGE_FORMAT fif, int flags = 0) const; + /** + Saves a dib to a memory stream + @param fif Format identifier (FreeImage format) + @param dib Image to be saved + @param flags The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SaveToMemory + */ + BOOL save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, int flags = 0); + /** + Saves a multi-page bitmap to a memory stream + @param fif Format identifier (FreeImage format) + @param bitmap Multi-page image to be saved + @param flags The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SaveMultiBitmapToMemory + */ + BOOL saveMultiPage(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, int flags = 0); + /** + Reads data from a memory stream + @param buffer Storage location for data + @param size Item size in bytes + @param count Maximum number of items to be read + @return Returns the number of full items actually read, which may be less than count if an error occurs + @see FreeImage_ReadMemory + */ + unsigned read(void *buffer, unsigned size, unsigned count) const; + /** + Writes data to a memory stream + @param buffer Pointer to data to be written + @param size Item size in bytes + @param count Maximum number of items to be written + @return Returns the number of full items actually written, which may be less than count if an error occurs + @see FreeImage_WriteMemory + */ + unsigned write(const void *buffer, unsigned size, unsigned count); + /** + Gets the current position of a memory pointer + @see FreeImage_TellMemory + */ + long tell() const; + /** + Moves the memory pointer to a specified location + @see FreeImage_SeekMemory + */ + BOOL seek(long offset, int origin); + /** + Provides a direct buffer access to a memory stream + @param data Pointer to the memory buffer (returned value) + @param size_in_bytes Buffer size in bytes (returned value) + @see FreeImage_AcquireMemory + */ + BOOL acquire(BYTE **data, DWORD *size_in_bytes); + //@} + +private: + /// Disable copy + fipMemoryIO(const fipMemoryIO& src); + /// Disable copy + fipMemoryIO& operator=(const fipMemoryIO& src); + +}; + +// ---------------------------------------------------------- + +/** Multi-page file stream + + fipMultiPage encapsulates the multi-page API. It supports reading/writing + multi-page TIFF, ICO and GIF files. +*/ +class FIP_API fipMultiPage : public fipObject +{ +protected: + /// Pointer to a multi-page file stream + FIMULTIBITMAP *_mpage; + /// TRUE when using a memory cache, FALSE otherwise + BOOL _bMemoryCache; + +public: + /** + Constructor + @param keep_cache_in_memory When it is TRUE, all gathered bitmap data in the page manipulation process is kept in memory, otherwise it is lazily flushed to a temporary file on the hard disk in 64 Kb blocks. + */ + fipMultiPage(BOOL keep_cache_in_memory = FALSE); + + /** + Destructor + Close the file stream if not already done. + */ + virtual ~fipMultiPage(); + + /// Returns TRUE if the multi-page stream is opened + BOOL isValid() const; + + /** + Returns a pointer to the FIMULTIBITMAP data. Used for direct access from FREEIMAGE functions + or from your own low level C functions. + */ + operator FIMULTIBITMAP*() { + return _mpage; + } + + /** + Open a multi-page file stream + @param lpszPathName Name of the multi-page bitmap file + @param create_new When TRUE, it means that a new bitmap will be created rather than an existing one being opened + @param read_only When TRUE the bitmap is opened read-only + @param flags Load flags. The signification of this flag depends on the image to be loaded. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_OpenMultiBitmap + */ + BOOL open(const char* lpszPathName, BOOL create_new, BOOL read_only, int flags = 0); + + /** + Open a multi-page memory stream as read/write. + @param memIO Memory stream. The memory stream MUST BE a wrapped user buffer. + @param flags Load flags. The signification of this flag depends on the image to be loaded. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_LoadMultiBitmapFromMemory + */ + BOOL open(fipMemoryIO& memIO, int flags = 0); + + /** + Open a multi-page image as read/write, using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_OpenMultiBitmapFromHandle + */ + BOOL open(FreeImageIO *io, fi_handle handle, int flags = 0); + + /** + Close a file stream + @param flags Save flags. The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_CloseMultiBitmap + */ + BOOL close(int flags = 0); + + /** + Saves a multi-page image using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param fif Format identifier (FreeImage format) + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the multi-page image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveMultiBitmapToHandle, FreeImage documentation + */ + BOOL saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags = 0) const; + + /** + Saves a multi-page image using the specified memory stream and an optional flag. + @param fif Format identifier (FreeImage format) + @param memIO FreeImage memory stream + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveMultiBitmapToMemory, FreeImage documentation + */ + BOOL saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flags = 0) const; + + /** + Returns the number of pages currently available in the multi-paged bitmap + @see FreeImage_GetPageCount + */ + int getPageCount() const; + + /** + Appends a new page to the end of the bitmap + @param image Image to append + @see FreeImage_AppendPage + */ + void appendPage(fipImage& image); + + /** + Inserts a new page before the given position in the bitmap + @param page Page number. Page has to be a number smaller than the current number of pages available in the bitmap. + @param image Image to insert + @see FreeImage_InsertPage + */ + void insertPage(int page, fipImage& image); + + /** + Deletes the page on the given position + @param page Page number + @see FreeImage_DeletePage + */ + void deletePage(int page); + + /** + Moves the source page to the position of the target page. + @param target Target page position + @param source Source page position + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_MovePage + */ + BOOL movePage(int target, int source); + + /** + Locks a page in memory for editing. You must call unlockPage to free the page
+ Usage :
+
+	fipMultiPage mpage;
+	// ...
+	fipImage image;		// You must declare this before
+	image = mpage.lockPage(2);
+	if(image.isValid()) {
+	  // ...
+	  mpage.unlockPage(image, TRUE);
+	}
+	
+ @param page Page number + @return Returns the page if successful, returns NULL otherwise + @see FreeImage_LockPage + */ + FIBITMAP* lockPage(int page); + + /** + Unlocks a previously locked page and gives it back to the multi-page engine + @param image Page to unlock + @param changed When TRUE, the page is marked changed and the new page data is applied in the multi-page bitmap. + @see FreeImage_UnlockPage + */ + void unlockPage(fipImage& image, BOOL changed); + + /** + Returns an array of page-numbers that are currently locked in memory. + When the pages parameter is NULL, the size of the array is returned in the count variable. + You can then allocate the array of the desired size and call + getLockedPageNumbers again to populate the array. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_GetLockedPageNumbers + */ + BOOL getLockedPageNumbers(int *pages, int *count) const; +}; + +// ---------------------------------------------------------- + +/** +FreeImage Tag + +FreeImage uses this structure to store metadata information. +*/ +class FIP_API fipTag : public fipObject +{ +protected: + /// Pointer to a FreeImage tag + FITAG *_tag; + +public: + /**@name Creation & Destruction */ + //@{ + /** + Constructor + @see FreeImage_CreateTag + */ + fipTag(); + /** + Destructor + @see FreeImage_DeleteTag + */ + virtual ~fipTag(); + /** + Construct a FIDT_ASCII tag (ASCII string).
+ This method is useful to store comments or IPTC tags. + @param name Field name + @param value Field value + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_CreateTag + */ + BOOL setKeyValue(const char *key, const char *value); + + //@} + + /**@name Copying */ + //@{ + /** + Copy constructor + @see FreeImage_CloneTag + */ + fipTag(const fipTag& tag); + /** + Copy constructor + @see FreeImage_CloneTag + */ + fipTag& operator=(const fipTag& tag); + /** + Assignement operator
+ Copy the input pointer and manage its destruction + @see operator FITAG*() + */ + fipTag& operator=(FITAG *tag); + //@} + + /** + Returns a pointer to the FITAG data. Used for direct access from FREEIMAGE functions + or from your own low level C functions. + @see operator=(FITAG *tag) + */ + operator FITAG*() { + return _tag; + } + + /// Returns TRUE if the tag is allocated, FALSE otherwise + BOOL isValid() const; + + /**@name Tag accessors */ + //@{ + /** + Returns the tag field name (unique inside a metadata model). + @see FreeImage_GetTagKey + */ + const char *getKey() const; + /** + Returns the tag description if available, returns NULL otherwise + @see FreeImage_GetTagDescription + */ + const char *getDescription() const; + /** + Returns the tag ID if available, returns 0 otherwise + @see FreeImage_GetTagID + */ + WORD getID() const; + /** + Returns the tag data type + @see FreeImage_GetTagType + */ + FREE_IMAGE_MDTYPE getType() const; + /** + Returns the number of components in the tag (in tag type units) + @see FreeImage_GetTagCount + */ + DWORD getCount() const; + /** + Returns the length of the tag value in bytes + @see FreeImage_GetTagLength + */ + DWORD getLength() const; + /** + Returns the tag value + @see FreeImage_GetTagValue + */ + const void *getValue() const; + /** + Set the tag field name + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagKey + */ + BOOL setKey(const char *key); + /** + Set the (usually optional) tag description + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagDescription + */ + BOOL setDescription(const char *description); + /** + Set the (usually optional) tad ID + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagID + */ + BOOL setID(WORD id); + /** + Set the tag data type + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagType + */ + BOOL setType(FREE_IMAGE_MDTYPE type); + /** + Set the number of data in the tag + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagCount + */ + BOOL setCount(DWORD count); + /** + Set the length of the tag value, in bytes + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagLength + */ + BOOL setLength(DWORD length); + /** + Set the tag value + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagValue + */ + BOOL setValue(const void *value); + + //@} + + /** + Converts a FreeImage tag structure to a string that represents the interpreted tag value + @param model Metadata model specification (metadata model from which the tag was extracted) + @param Make Camera model (not used yet) + */ + const char* toString(FREE_IMAGE_MDMODEL model, char *Make = NULL) const; + +}; + +/** +Metadata iterator + +Usage :
+
+fipImage image;
+// ...
+fipTag tag;
+fipMetadataFind finder;
+if( finder.findFirstMetadata(FIMD_EXIF_MAIN, image, tag) ) {
+  do {
+    // process the tag
+	cout << tag.getKey() << "\n";
+
+  } while( finder.findNextMetadata(tag) );
+}
+// the class can be called again with another metadata model
+if( finder.findFirstMetadata(FIMD_EXIF_EXIF, image, tag) ) {
+  do {
+    // process the tag
+	cout << tag.getKey() << "\n";
+
+  } while( finder.findNextMetadata(tag) );
+}
+
+*/ +class FIP_API fipMetadataFind : public fipObject +{ +protected: + /// Pointer to a search handle + FIMETADATA *_mdhandle; + +public: + /// Returns TRUE if the search handle is allocated, FALSE otherwise + BOOL isValid() const; + + /// Constructor + fipMetadataFind(); + /** + Destructor + @see FreeImage_FindCloseMetadata + */ + virtual ~fipMetadataFind(); + /** + Provides information about the first instance of a tag that matches + the metadata model specified in the model argument. + @param model Metadata model + @param image Input image + @param tag Returned tag + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_FindFirstMetadata + */ + BOOL findFirstMetadata(FREE_IMAGE_MDMODEL model, fipImage& image, fipTag& tag); + /** + Find the next tag, if any, that matches the metadata model argument + in a previous call to findFirstMetadata + @param tag Returned tag + @return Returns TRUE if successful, returns FALSE otherwise, indicating that no more matching tags could be found + @see FreeImage_FindNextMetadata + */ + BOOL findNextMetadata(fipTag& tag); + +}; + +#endif // FREEIMAGEPLUS_H diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x32/FreeImagePlus.lib b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x32/FreeImagePlus.lib new file mode 100644 index 0000000..30771ff Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x32/FreeImagePlus.lib differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x64/FreeImagePlus.dll b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x64/FreeImagePlus.dll new file mode 100644 index 0000000..e423fee Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x64/FreeImagePlus.dll differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x64/FreeImagePlus.h b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x64/FreeImagePlus.h new file mode 100644 index 0000000..571010f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x64/FreeImagePlus.h @@ -0,0 +1,1713 @@ +// ========================================================== +// FreeImagePlus 3 +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#ifndef FREEIMAGEPLUS_H +#define FREEIMAGEPLUS_H + +#ifdef _WIN32 +#include +#endif // _WIN32 +#include "FreeImage.h" + + +// Compiler options --------------------------------------------------------- + +#if defined(FREEIMAGE_LIB) + #define FIP_API + #define FIP_CALLCONV +#else + #if defined(_WIN32) || defined(__WIN32__) + #define WIN32_LEAN_AND_MEAN + #define FIP_CALLCONV __stdcall + // The following ifdef block is the standard way of creating macros which make exporting + // from a DLL simpler. All files within this DLL are compiled with the FIP_EXPORTS + // symbol defined on the command line. this symbol should not be defined on any project + // that uses this DLL. This way any other project whose source files include this file see + // FIP_API functions as being imported from a DLL, wheras this DLL sees symbols + // defined with this macro as being exported. + #ifdef FIP_EXPORTS + #define FIP_API __declspec(dllexport) + #else + #define FIP_API __declspec(dllimport) + #endif // FIP_EXPORTS + #else + // try the gcc visibility support (see http://gcc.gnu.org/wiki/Visibility) + #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) + #ifndef GCC_HASCLASSVISIBILITY + #define GCC_HASCLASSVISIBILITY + #endif + #endif + #define FIP_CALLCONV + #if defined(GCC_HASCLASSVISIBILITY) + #define FIP_API __attribute__ ((visibility("default"))) + #else + #define FIP_API + #endif + #endif // WIN32 / !WIN32 +#endif // FREEIMAGE_LIB + +/////////////////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------- + +/** Abstract base class for all objects used by the library. + @version FreeImage 3 + @author Hervé Drolon +*/ + +class FIP_API fipObject +{ +public: + /// Destructor + virtual ~fipObject(){}; + + /**@name Information functions */ + //@{ + /// Returns TRUE if the object is allocated, FALSE otherwise + virtual BOOL isValid() const = 0; + //@} +}; + +// ---------------------------------------------------------- + +class fipMemoryIO; +class fipMultiPage; +class fipTag; + +/** A class used to manage all photo related images and all image types used by the library. + + fipImage encapsulates the FIBITMAP format. It relies on the FreeImage library, especially for + loading / saving images and for bit depth conversion. + @version FreeImage 3 + @author Hervé Drolon +*/ + +class FIP_API fipImage : public fipObject +{ +protected: + /// DIB data + FIBITMAP *_dib; + /// Original (or last saved) fif format if available, FIF_UNKNOWN otherwise + FREE_IMAGE_FORMAT _fif; + /// TRUE whenever the display need to be refreshed + mutable BOOL _bHasChanged; + +public: + friend class fipMultiPage; + +public: + + /**@name Creation & Destruction */ + //@{ + /** + Constructor + @see FreeImage_AllocateT + */ + fipImage(FREE_IMAGE_TYPE image_type = FIT_BITMAP, unsigned width = 0, unsigned height = 0, unsigned bpp = 0); + /// Destructor + virtual ~fipImage(); + /** + Image allocator + @see FreeImage_AllocateT + */ + BOOL setSize(FREE_IMAGE_TYPE image_type, unsigned width, unsigned height, unsigned bpp, unsigned red_mask = 0, unsigned green_mask = 0, unsigned blue_mask = 0); + /// Destroy image data + virtual void clear(); + //@} + + /**@name Copying */ + //@{ + /** + Copy constructor + @see FreeImage_Clone + */ + fipImage(const fipImage& src); + /** + Copy constructor + @see FreeImage_Clone + */ + fipImage& operator=(const fipImage& src); + /** + Assignement operator
+ Copy the input pointer and manage its destruction + @see operator FIBITMAP*() + */ + fipImage& operator=(FIBITMAP *dib); + + + /** + @brief Copy a sub part of the current image and returns it as a fipImage object. + + This method works with any bitmap type. + @param dst Output subimage + @param left Specifies the left position of the cropped rectangle. + @param top Specifies the top position of the cropped rectangle. + @param right Specifies the right position of the cropped rectangle. + @param bottom Specifies the bottom position of the cropped rectangle. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Copy + */ + BOOL copySubImage(fipImage& dst, int left, int top, int right, int bottom) const; + + /** + @brief Alpha blend or combine a sub part image with the current image. + + The bit depth of dst bitmap must be greater than or equal to the bit depth of src. + Upper promotion of src is done internally. Supported bit depth equals to 4, 8, 16, 24 or 32. + @param src Source subimage + @param left Specifies the left position of the sub image. + @param top Specifies the top position of the sub image. + @param alpha Alpha blend factor. The source and destination images are alpha blended if + alpha = 0..255. If alpha > 255, then the source image is combined to the destination image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Paste + */ + BOOL pasteSubImage(fipImage& src, int left, int top, int alpha = 256); + + /** + @brief Crop a sub part of the current image and update it accordingly. + + This method works with any bitmap type. + @param left Specifies the left position of the cropped rectangle. + @param top Specifies the top position of the cropped rectangle. + @param right Specifies the right position of the cropped rectangle. + @param bottom Specifies the bottom position of the cropped rectangle. + @return Returns TRUE if successful, FALSE otherwise. + */ + BOOL crop(int left, int top, int right, int bottom); + + //@} + + /** @name File type identification + */ + //@{ + /** + @brief Identifies an image from disk, given its file name + @param lpszPathName Path and file name of the image to identify. + @return Returns the found FreeImage format if successful, returns FIF_UNKNOWN otherwise. + @see FreeImage_GetFileType, FreeImage_GetFIFFromFilename, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIF(const char* lpszPathName); + + /** + UNICODE version of identifyFIF (this function only works under WIN32 and does nothing on other OS) + @see FreeImage_GetFileTypeU, FreeImage_GetFIFFromFilenameU, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIFU(const wchar_t* lpszPathName); + + /** + @brief Identifies an image using the specified FreeImageIO struct and fi_handle. + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @return Returns the found FreeImage format if successful, returns FIF_UNKNOWN otherwise. + @see FreeImage_GetFileTypeFromHandle, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIFFromHandle(FreeImageIO *io, fi_handle handle); + + /** + @brief Identifies an image using the specified memory stream. + @param hmem FreeImage memory stream + @return Returns the found FreeImage format if successful, returns FIF_UNKNOWN otherwise. + @see FreeImage_GetFileTypeFromMemory, FreeImage documentation + */ + static FREE_IMAGE_FORMAT identifyFIFFromMemory(FIMEMORY *hmem); + + //@} + + + /** @name Loading & Saving + * Loading and saving is handled by the FreeImage library. + */ + //@{ + /** + @brief Loads an image from disk, given its file name and an optional flag. + @param lpszPathName Path and file name of the image to load. + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Load, FreeImage documentation + */ + BOOL load(const char* lpszPathName, int flag = 0); + + /** + UNICODE version of load (this function only works under WIN32 and does nothing on other OS) + @see load + */ + BOOL loadU(const wchar_t* lpszPathName, int flag = 0); + + /** + @brief Loads an image using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_LoadFromHandle, FreeImage documentation + */ + BOOL loadFromHandle(FreeImageIO *io, fi_handle handle, int flag = 0); + + /** + @brief Loads an image using the specified memory stream and an optional flag. + @param memIO FreeImage memory stream + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_LoadFromMemory, FreeImage documentation + */ + BOOL loadFromMemory(fipMemoryIO& memIO, int flag = 0); + + /** + @brief Saves an image to disk, given its file name and an optional flag. + @param lpszPathName Path and file name of the image to save. + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Save, FreeImage documentation + */ + BOOL save(const char* lpszPathName, int flag = 0) const; + + /** + UNICODE version of save (this function only works under WIN32 and does nothing on other OS) + @see save + */ + BOOL saveU(const wchar_t* lpszPathName, int flag = 0) const; + + /** + @brief Saves an image using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param fif Format identifier (FreeImage format) + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveToHandle, FreeImage documentation + */ + BOOL saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flag = 0) const; + + /** + @brief Saves an image using the specified memory stream and an optional flag. + @param fif Format identifier (FreeImage format) + @param memIO FreeImage memory stream + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveToMemory, FreeImage documentation + */ + BOOL saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flag = 0) const; + + //@} + + /** @name Information functions + * Accessors to the DIB BITMAPINFO structure. + */ + //@{ + + /** + Returns the data type of the image + @see FreeImage_GetImageType + */ + FREE_IMAGE_TYPE getImageType() const; + + /** + Returns the image width in pixels + @see FreeImage_GetWidth + */ + unsigned getWidth() const; + + /** + Returns the image height in pixels + @see FreeImage_GetHeight + */ + unsigned getHeight() const; + + /** + Returns the width of the bitmap in bytes rounded to the nearest DWORD. + @see FreeImage_GetPitch + */ + unsigned getScanWidth() const; + + /** + Returns a pointer to the FIBITMAP data. Used for direct access from FREEIMAGE functions + or from your own low level C functions.
+ Sample use :
+
+	fipImage src, dst;
+	src.load("test.png");
+	dst = FreeImage_ConvertTo8Bits(src);
+	FreeImage_Save(FIF_TIFF, dst, "test.tif", 0);
+	
+ @see operator=(FIBITMAP *dib) + */ + operator FIBITMAP*() { + return _dib; + } + + /// Returns TRUE if the image is allocated, FALSE otherwise + BOOL isValid() const; + + /** + Returns a pointer to the bitmap's BITMAPINFO header. + @see FreeImage_GetInfo + */ + BITMAPINFO* getInfo() const; + + /** + Returns a pointer to the bitmap's BITMAPINFOHEADER. + @see FreeImage_GetInfoHeader + */ + BITMAPINFOHEADER* getInfoHeader() const; + + /** + Returns the size of the bitmap in bytes. + The size of the bitmap is the BITMAPINFOHEADER + the size of the palette + the size of the bitmap data. + @see FreeImage_GetDIBSize + */ + unsigned getImageSize() const; + + /** + Returns the memory footprint of a bitmap, in bytes. + @see FreeImage_GetMemorySize + */ + unsigned getImageMemorySize() const; + + /** + Returns the bitdepth of the bitmap.
+ When the image type is FIT_BITMAP, valid bitdepth can be 1, 4, 8, 16, 24 or 32. + @see FreeImage_GetBPP, getImageType + */ + unsigned getBitsPerPixel() const; + + /** + Returns the width of the bitmap in bytes.
+ This is not the size of the scanline. + @see FreeImage_GetLine, getScanWidth + */ + unsigned getLine() const; + + /** + Returns the bitmap resolution along the X axis, in pixels / cm + @see FreeImage_GetDotsPerMeterX + */ + double getHorizontalResolution() const; + + /** + Returns the bitmap resolution along the Y axis, in pixels / cm + @see FreeImage_GetDotsPerMeterY + */ + double getVerticalResolution() const; + + /** + set the bitmap resolution along the X axis, in pixels / cm + @see FreeImage_GetInfoHeader + */ + void setHorizontalResolution(double value); + + /** + set the bitmap resolution along the Y axis, in pixels / cm + @see FreeImage_GetInfoHeader + */ + void setVerticalResolution(double value); + + //@} + + /**@name Palette operations */ + //@{ + /** + Returns a pointer to the bitmap's palette. If the bitmap doesn't have a palette, getPalette returns NULL. + @see FreeImage_GetPalette + */ + RGBQUAD* getPalette() const; + + /** + Returns the palette size in bytes. + @see FreeImage_GetColorsUsed + */ + unsigned getPaletteSize() const; + + /** + Retrieves the number of colours used in the bitmap. If the bitmap is non-palletised, 0 is returned. + @see FreeImage_GetColorsUsed + */ + unsigned getColorsUsed() const; + + /** + Investigates the colour type of the bitmap. + @see FreeImage_GetColorType, FREE_IMAGE_COLOR_TYPE + */ + FREE_IMAGE_COLOR_TYPE getColorType() const; + + /** + Returns TRUE if the bitmap is a 8-bit bitmap with a greyscale palette, FALSE otherwise + @see FreeImage_GetBPP, FreeImage_GetColorType + */ + BOOL isGrayscale() const; + //@} + + /**@name Thumbnail access */ + //@{ + + /** + Retrieves a copy the thumbnail possibly attached to the bitmap + @return Returns TRUE if the thumbnail is present in the bitmap and successfuly retrieved, returns FALSE otherwise + @see FreeImage_GetThumbnail + */ + BOOL getThumbnail(fipImage& image) const; + + /** + Attach a thumbnail to the bitmap + @return Returns TRUE if the thumbnail was successfuly set, returns FALSE otherwise + @see FreeImage_SetThumbnail + */ + BOOL setThumbnail(const fipImage& image); + + /** + Check if the image has an embedded thumbnail + @return Returns TRUE if a thumbnail is present in the bitmap, returns FALSE otherwise + @see FreeImage_GetThumbnail + */ + BOOL hasThumbnail() const; + + /** + Clear the thumbnail possibly attached to the bitmap + @return Returns TRUE if successful, returns FALSe otherwise + @see FreeImage_SetThumbnail + */ + BOOL clearThumbnail(); + + //@} + + /**@name Pixel access */ + //@{ + + /** @brief Returns a pointer to the bitmap bits. + + It is up to you to interpret these bytes correctly, + according to the results of FreeImage_GetBPP and + GetRedMask, FreeImage_GetGreenMask and FreeImage_GetBlueMask.
+ Use this function with getScanWidth to iterates through the pixels. + @see FreeImage_GetBits + */ + BYTE* accessPixels() const; + + /** @brief Returns a pointer to the start of the given scanline in the bitmap’s data-bits. + This pointer can be cast according to the result returned by getImageType.
+ Use this function with getScanWidth to iterates through the pixels. + @see FreeImage_GetScanLine, FreeImage documentation + */ + BYTE* getScanLine(unsigned scanline) const; + + /** + Get the pixel index of a 1-, 4- or 8-bit palettized image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel index (returned value) + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetPixelIndex + */ + BOOL getPixelIndex(unsigned x, unsigned y, BYTE *value) const; + + /** + Get the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel color (returned value) + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetPixelColor + */ + BOOL getPixelColor(unsigned x, unsigned y, RGBQUAD *value) const; + + /** + Set the pixel index of a 1-, 4- or 8-bit palettized image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel index + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetPixelIndex + */ + BOOL setPixelIndex(unsigned x, unsigned y, BYTE *value); + + /** + Set the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access). + @param x Pixel position in horizontal direction + @param y Pixel position in vertical direction + @param value Pixel color + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetPixelColor + */ + BOOL setPixelColor(unsigned x, unsigned y, RGBQUAD *value); + + //@} + + /** @name Conversion routines + * Bitmaps are always loaded in their default bit depth. If you want the bitmap to be stored in another bit depth, the class provides several conversion functions. + */ + //@{ + /** + Converts an image to a type supported by FreeImage. + @param image_type New image type + @param scale_linear TRUE if image pixels must be scaled linearly when converting to a standard bitmap + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToType, FreeImage_ConvertToStandardType + */ + BOOL convertToType(FREE_IMAGE_TYPE image_type, BOOL scale_linear = TRUE); + + /** + Converts the bitmap to 1 bit using a threshold T. + @param T Threshold value in [0..255] + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Threshold + */ + BOOL threshold(BYTE T); + + /** + Converts a 8-bit image to a monochrome 1-bit image using a dithering algorithm. + @param algorithm Dithering algorithm to use. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Dither, FREE_IMAGE_DITHER + */ + BOOL dither(FREE_IMAGE_DITHER algorithm); + + /** + Converts the bitmap to 4 bits. Unless the bitmap is a 1-bit palettized bitmap, colour values are converted to greyscale. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo4Bits + */ + BOOL convertTo4Bits(); + + /** + Converts the bitmap to 8 bits. If the bitmap is 24 or 32-bit RGB, the colour values are converted to greyscale. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo8Bits + */ + BOOL convertTo8Bits(); + + /** + Converts the bitmap to 8 bits.
+ For palletized bitmaps, the color map is converted to a greyscale ramp. + @see FreeImage_ConvertToGreyscale + @return Returns TRUE if successful, FALSE otherwise. + */ + BOOL convertToGrayscale(); + + /** + Quantizes a full colour 24-bit bitmap to a palletised 8-bit bitmap.
+ The quantize parameter specifies which colour reduction algorithm should be used. + @param algorithm Color quantization algorithm to use. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ColorQuantize, FREE_IMAGE_QUANTIZE + */ + BOOL colorQuantize(FREE_IMAGE_QUANTIZE algorithm); + + /** + Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 5 bits green, 5 bits blue and 1 unused bit. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo16Bits555 + */ + BOOL convertTo16Bits555(); + + /** + Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 6 bits green and 5 bits blue. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo16Bits565 + */ + BOOL convertTo16Bits565(); + + /** + Converts the bitmap to 24 bits. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo24Bits + */ + BOOL convertTo24Bits(); + + /** + Converts the bitmap to 32 bits. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertTo32Bits + */ + BOOL convertTo32Bits(); + + /** + Converts the bitmap to a 32-bit float image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToFloat + */ + BOOL convertToFloat(); + + /** + Converts the bitmap to a 96-bit RGBF image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGBF + */ + BOOL convertToRGBF(); + + /** + Converts the bitmap to a 128-bit RGBAF image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGBAF + */ + BOOL convertToRGBAF(); + + /** + Converts the bitmap to a 16-bit unsigned short image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToUINT16 + */ + BOOL convertToUINT16(); + + /** + Converts the bitmap to a 48-bit RGB16 image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGB16 + */ + BOOL convertToRGB16(); + + /** + Converts the bitmap to a 64-bit RGBA16 image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ConvertToRGBA16 + */ + BOOL convertToRGBA16(); + + /** + Converts a High Dynamic Range image (48-bit RGB or 96-bit RGB Float) to a 24-bit RGB image. + @param tmo Tone mapping operator + @param first_param First tone mapping algorithm parameter (algorithm dependant) + @param second_param Second tone mapping algorithm parameter (algorithm dependant) + @param third_param Third tone mapping algorithm parameter (algorithm dependant) + @param fourth_param Fourth tone mapping algorithm parameter (algorithm dependant) + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_ToneMapping, FreeImage_TmoReinhard05Ex + */ + BOOL toneMapping(FREE_IMAGE_TMO tmo, double first_param = 0, double second_param = 0, double third_param = 1, double fourth_param = 0); + + //@} + + /** @name Transparency support: background colour and alpha channel */ + //@{ + + /** + Returns TRUE if the image is transparent, returns FALSE otherwise + @see FreeImage_IsTransparent + */ + BOOL isTransparent() const; + + /** + 8-bit transparency : get the number of transparent colors. + @return Returns the number of transparent colors in a palletised bitmap. + @see FreeImage_GetTransparencyCount + */ + unsigned getTransparencyCount() const; + + /** + 8-bit transparency : get the bitmap’s transparency table. + @return Returns a pointer to the bitmap’s transparency table. + @see FreeImage_GetTransparencyTable + */ + BYTE* getTransparencyTable() const; + + /** + 8-bit transparency : set the bitmap’s transparency table. + @see FreeImage_SetTransparencyTable + */ + void setTransparencyTable(BYTE *table, int count); + + /** + Returns TRUE when the image has a file background color, FALSE otherwise. + @see FreeImage_HasBackgroundColor + */ + BOOL hasFileBkColor() const; + + /** + @brief Retrieves the file background color of an image. + + For 8-bit images, the color index + in the palette is returned in the rgbReserved member of the bkcolor parameter. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetBackgroundColor + */ + BOOL getFileBkColor(RGBQUAD *bkcolor) const; + + /** + @brief Set the file background color of an image. + + When saving an image to PNG, this background color is transparently saved to the PNG file. + When the bkcolor parameter is NULL, the background color is removed from the image. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetBackgroundColor + */ + BOOL setFileBkColor(RGBQUAD *bkcolor); + //@} + + /**@name Channel processing support */ + //@{ + /** @brief Retrieves the red, green, blue or alpha channel of a 24- or 32-bit BGR[A] image. + @param image Output image to be extracted + @param channel Color channel to extract + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_GetChannel, FREE_IMAGE_COLOR_CHANNEL + */ + BOOL getChannel(fipImage& image, FREE_IMAGE_COLOR_CHANNEL channel) const; + + /** + @brief Insert a 8-bit dib into a 24- or 32-bit image. + @param image Input 8-bit image to insert + @param channel Color channel to replace + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SetChannel, FREE_IMAGE_COLOR_CHANNEL + */ + BOOL setChannel(fipImage& image, FREE_IMAGE_COLOR_CHANNEL channel); + + /** @brief Split a 24-bit RGB image into 3 greyscale images corresponding to the red, green and blue channels. + @param RedChannel Output red channel. + @param GreenChannel Output green channel. + @param BlueChannel Output blue channel. + @return Returns FALSE if the dib isn't a valid image, if it's not a 24-bit image or if + one of the output channel can't be allocated. Returns TRUE otherwise. + @see FreeImage_GetChannel + */ + BOOL splitChannels(fipImage& RedChannel, fipImage& GreenChannel, fipImage& BlueChannel); + + /** @brief Builds a 24-bit RGB image given its red, green and blue channel. + @param red Input red channel. + @param green Input green channel. + @param blue Input blue channel. + @return Returns FALSE if the dib can't be allocated, if the input channels are not 8-bit images. Returns TRUE otherwise. + @see FreeImage_SetChannel + */ + BOOL combineChannels(fipImage& red, fipImage& green, fipImage& blue); + //@} + + /**@name Rotation and flipping */ + //@{ + /** + Image translation and rotation using B-Splines. + @param angle Image rotation angle, in degree + @param x_shift Image horizontal shift + @param y_shift Image vertical shift + @param x_origin Origin of the x-axis + @param y_origin Origin of the y-axis + @param use_mask Whether or not to mask the image. Image mirroring is applied when use_mask is set to FALSE + @return Returns the translated & rotated dib if successful, returns NULL otherwise + @see FreeImage_RotateEx + */ + BOOL rotateEx(double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask); + + /** + Image rotation by means of three shears. + @param angle Image rotation angle, in degree + @param bkcolor Background color (image type dependent), default to black background + @return Returns rotated dib if successful, returns NULL otherwise + @see FreeImage_Rotate + */ + BOOL rotate(double angle, const void *bkcolor = NULL); + + /** + Flip the image horizontally along the vertical axis + @see FreeImage_FlipHorizontal + */ + BOOL flipHorizontal(); + + /** + Flip the image vertically along the horizontal axis + @see FreeImage_FlipVertical + */ + BOOL flipVertical(); + //@} + + /**@name Color manipulation routines */ + //@{ + /** + Inverts each pixel data. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_Invert + */ + BOOL invert(); + + /** @brief Perfoms an histogram transformation on a 8, 24 or 32-bit image + according to the values of a lookup table (LUT). + + The transformation is done as follows.
+ Image 8-bit : if the image has a color palette, the LUT is applied to this palette, + otherwise, it is applied to the grey values.
+ Image 24-bit & 32-bit : if channel == IPL_CC_RGB, the same LUT is applied to each color + plane (R,G, and B). Otherwise, the LUT is applied to the specified channel only. + @param LUT Lookup table. The size of 'LUT' is assumed to be 256. + @param channel The color channel to be processed (only used with 24 & 32-bit DIB). + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_AdjustCurve, FREE_IMAGE_COLOR_CHANNEL + */ + BOOL adjustCurve(BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel); + + /** @brief Performs gamma correction on a 8, 24 or 32-bit image. + @param gamma Gamma value to use. A value of 1.0 leaves the image alone, + less than one darkens it, and greater than one lightens it. + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_AdjustGamma, adjustCurve + */ + BOOL adjustGamma(double gamma); + + /** @brief Adjusts the brightness of a 8, 24 or 32-bit image by a certain amount. + @param percentage Where -100 <= percentage <= 100
+ A value 0 means no change, less than 0 will make the image darker + and greater than 0 will make the image brighter. + @return Returns TRUE if the operation was succesful, FALSE otherwise + @see FreeImage_AdjustBrightness, adjustCurve + */ + BOOL adjustBrightness(double percentage); + + /** @brief Adjusts the contrast of a 8, 24 or 32-bit image by a certain amount. + @param percentage Where -100 <= percentage <= 100
+ A value 0 means no change, less than 0 will decrease the contrast + and greater than 0 will increase the contrast of the image. + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_AdjustContrast, adjustCurve + */ + BOOL adjustContrast(double percentage); + + /** + Adjusts an image's brightness, contrast and gamma within a single operation. + If more than one of these image display properties need to be adjusted, + using this function should be preferred over calling each adjustment function separately. + That's particularly true for huge images or if performance is an issue. + @see adjustBrightness + @see adjustContrast + @see adjustGamma + @see FreeImage_AdjustColors + */ + BOOL adjustBrightnessContrastGamma(double brightness, double contrast, double gamma); + + /** @brief Computes image histogram + + For 24-bit and 32-bit images, histogram can be computed from red, green, blue and + black channels. For 8-bit images, histogram is computed from the black channel. Other + bit depth is not supported. + @param histo pointer to an histogram array. Size of this array is assumed to be 256. + @param channel Color channel to use + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_GetHistogram + */ + BOOL getHistogram(DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel = FICC_BLACK) const; + //@} + + /**@name Upsampling / downsampling */ + //@{ + + /** @brief Rescale the image to a new width / height. + + @param new_width New image width + @param new_height New image height + @param filter The filter parameter specifies which resampling filter should be used. + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_Rescale, FREE_IMAGE_FILTER + */ + BOOL rescale(unsigned new_width, unsigned new_height, FREE_IMAGE_FILTER filter); + + /** @brief Creates a thumbnail image keeping aspect ratio + + @param max_size Maximum width or height in pixel units + @param convert When set to TRUE, converts the image to a standard type + @return Returns TRUE if the operation was successful, FALSE otherwise + @see FreeImage_MakeThumbnail + */ + BOOL makeThumbnail(unsigned max_size, BOOL convert = TRUE); + //@} + + /**@name Image status */ + //@{ + /** + Set the image status as 'modified'.
+ When using the fipWinImage class, the image status is used to refresh the display. + It is changed to FALSE whenever the display has just been refreshed. + @param bStatus TRUE if the image should be marked as modified, FALSE otherwise + @see isModified + */ + void setModified(BOOL bStatus = TRUE) { + _bHasChanged = bStatus; + } + + /** + Get the image status + @return Returns TRUE if the image is marked as modified, FALSE otherwise + @see setModified + */ + BOOL isModified() { + return _bHasChanged; + } + //@} + + /**@name Metadata */ + //@{ + /** + Returns the number of tags contained in the model metadata model + attached to the dib + @param model Metadata model to look for + */ + unsigned getMetadataCount(FREE_IMAGE_MDMODEL model) const; + /** + Retrieve a metadata attached to the dib + @param model Metadata model to look for + @param key Metadata field name + @param tag Returned tag + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_GetMetadata + */ + BOOL getMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag& tag) const; + /** + Attach a new FreeImage tag to the dib.
+ Sample use :
+
+	fipImage image;
+	// ...
+	fipTag tag;
+	tag.setKeyValue("Caption/Abstract", "my caption");
+	image.setMetadata(FIMD_IPTC, tag.getKey(), tag);
+	tag.setKeyValue("Keywords", "FreeImage;Library;Images;Compression");
+	image.setMetadata(FIMD_IPTC, tag.getKey(), tag);
+	
+ + @param model Metadata model used to store the tag + @param key Tag field name + @param tag Tag to be attached + @return Returns TRUE if the operation was succesfull, FALSE otherwise + @see FreeImage_SetMetadata + */ + BOOL setMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag& tag); + //@} + + + protected: + /**@name Internal use */ + //@{ + BOOL replace(FIBITMAP *new_dib); + //@} + +}; + +// ---------------------------------------------------------- + +/** A class designed for MS Windows (TM) platforms. + + fipWinImage provides methods used to : +
    +
  • Display a DIB on the screen +
  • Copy / Paste a DIB to/from Windows devices (HANDLE, HBITMAP, Clipboard) +
  • Capture a window (HWND) and convert it to an image +
+ @version FreeImage 3 + @author Hervé Drolon +*/ +#ifdef _WIN32 + +class FIP_API fipWinImage : public fipImage +{ +public: + /**@name Creation & Destruction */ + //@{ + /// Constructor + fipWinImage(FREE_IMAGE_TYPE image_type = FIT_BITMAP, unsigned width = 0, unsigned height = 0, unsigned bpp = 0); + + /// Destructor + virtual ~fipWinImage(); + + /// Destroy image data + virtual void clear(); + + /// Returns TRUE if the image is allocated, FALSE otherwise + BOOL isValid() const; + //@} + + /**@name Copying */ + //@{ + + /** + Copy constructor. + Delete internal _display_dib data and copy the base class image data. + Tone mapping parameters are left unchanged. + @see FreeImage_Clone + */ + fipWinImage& operator=(const fipImage& src); + + /** + Copy constructor + Delete internal _display_dib data and copy tone mapping parameters. + Copy also the base class image data. + @see FreeImage_Clone + */ + fipWinImage& operator=(const fipWinImage& src); + + /** Clone function used for clipboard copy.
+ Convert the FIBITMAP image to a DIB, + and transfer the DIB in a global bitmap handle.
+ For non standard bitmaps, the BITMAPINFOHEADER->biCompression field is set to 0xFF + FreeImage_GetImageType(_dib), + in order to recognize the bitmap as non standard. + */ + HANDLE copyToHandle() const; + + /** Copy constructor used for clipboard paste.
+ Converts a global object to a FIBITMAP. The clipboard format must be CF_DIB.
+ When the BITMAPINFOHEADER->biCompression field is set to 0xFF + [one of the predefined FREE_IMAGE_TYPE], + the bitmap is recognized as non standard and correctly copied. + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL copyFromHandle(HANDLE hMem); + + /** Copy constructor.
+ Converts a HBITMAP object to a FIBITMAP. + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL copyFromBitmap(HBITMAP hbmp); + //@} + + /**@name Clipboard operations */ + //@{ + /** + Clipboard copy. + @param hWndNewOwner Handle to the window to be associated with the open clipboard. + In MFC, you can use AfxGetApp()->m_pMainWnd->GetSafeHwnd(). + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL copyToClipboard(HWND hWndNewOwner) const; + + /** + Retrieves data from the clipboard. The clipboard format must be CF_DIB. + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL pasteFromClipboard(); + //@} + + /**@name Screen capture */ + //@{ + /** Capture a window and convert it to an image + @param hWndApplicationWindow Handle to the application main window + @param hWndSelectedWindow Handle to the window to be captured + @return Returns TRUE if successful, returns FALSE otherwise + */ + BOOL captureWindow(HWND hWndApplicationWindow, HWND hWndSelectedWindow); + //@} + + + /**@name Painting operations */ + //@{ + + /** @brief Draw (stretch) the image on a HDC, using StretchDIBits. + + When the image is transparent or has a file background, this function composite + the foreground image against a checkerboard background image. + @param hDC Handle to the device context + @param rcDest Destination rectangle + @see FreeImage_Composite + */ + void draw(HDC hDC, RECT& rcDest) const { + drawEx(hDC, rcDest, FALSE, NULL, NULL); + } + + /** @brief Draw (stretch) the image on a HDC, using StretchDIBits. + + When the image is transparent or has a file background, this function can composite + the foreground image against a checkerboard background image, against a single background color or + against a user background image.
+ When the image is a High Dynamic Range image (48-bit or RGB float), this function will apply a + tone mapping operator before drawing the image.
+ The original image (located in the fipImage class) will not be affected by any of the operations + that could be done in order to display it. + @param hDC Handle to the device context + @param rcDest Destination rectangle + @param useFileBkg When set to TRUE, the function uses the file color background if there is one + @param appBkColor When a color is given, the function uses it as the background color + @param bg When a FIBITMAP is given, the function uses it as the background image + @see FreeImage_Composite + @see setToneMappingOperator + */ + void drawEx(HDC hDC, RECT& rcDest, BOOL useFileBkg = FALSE, RGBQUAD *appBkColor = NULL, FIBITMAP *bg = NULL) const; + + /** + Select a tone mapping algorithm used for drawing and set the image as modified + so that the display will be refreshed. + @param tmo Tone mapping operator + @param first_param First tone mapping algorithm parameter + @param second_param Second tone mapping algorithm parameter + @param third_param Third tone mapping algorithm parameter + @param fourth_param Fourth tone mapping algorithm parameter + @see FreeImage_ToneMapping + */ + void setToneMappingOperator(FREE_IMAGE_TMO tmo, double first_param = 0, double second_param = 0, double third_param = 1, double fourth_param = 0); + + /** + Get the tone mapping algorithm used for drawing, with its parameters. + @param tmo Tone mapping operator + @param first_param First tone mapping algorithm parameter + @param second_param Second tone mapping algorithm parameter + @param third_param Third tone mapping algorithm parameter + @param fourth_param Fourth tone mapping algorithm parameter + @see FreeImage_ToneMapping + */ + void getToneMappingOperator(FREE_IMAGE_TMO *tmo, double *first_param, double *second_param, double *third_param, double *fourth_param) const; + + //@} + +protected: + /// DIB used for display (this allow to display non-standard bitmaps) + mutable FIBITMAP *_display_dib; + /// remember to delete _display_dib + mutable BOOL _bDeleteMe; + /// tone mapping operator + FREE_IMAGE_TMO _tmo; + /// first tone mapping algorithm parameter + double _tmo_param_1; + /// second tone mapping algorithm parameter + double _tmo_param_2; + /// third tone mapping algorithm parameter + double _tmo_param_3; + /// fourth tone mapping algorithm parameter + double _tmo_param_4; +}; + +#endif // _WIN32 + +// ---------------------------------------------------------- + +/** Memory handle + + fipMemoryIO is a class that allows you to load / save images from / to a memory stream. + @version FreeImage 3 + @author Hervé Drolon +*/ +class FIP_API fipMemoryIO : public fipObject +{ +protected: + /// Pointer to a memory stream + FIMEMORY *_hmem; + +public : + /** Constructor. + Wrap a memory buffer containing image data.
+ The memory buffer is read only and has to be freed by the user + when no longer in use.
+ When default arguments are used, open a memory file as read/write. + @param data Pointer to the memory buffer + @param size_in_bytes Buffer size in bytes + @see FreeImage_OpenMemory + */ + fipMemoryIO(BYTE *data = NULL, DWORD size_in_bytes = 0); + + /** Destructor. + Free any allocated memory + @see FreeImage_CloseMemory + */ + virtual ~fipMemoryIO(); + + /** Destructor. + Free any allocated memory and invalidate the stream + @see FreeImage_CloseMemory + */ + void close(); + + /** Returns TRUE if the internal memory buffer is a valid buffer, returns FALSE otherwise + */ + BOOL isValid() const; + + /** Returns the buffer image format + @see FreeImage_GetFileTypeFromMemory + */ + FREE_IMAGE_FORMAT getFileType() const; + + /** + Returns a pointer to the FIMEMORY data. Used for direct access from FREEIMAGE functions + or from your own low level C functions. + */ + operator FIMEMORY*() { + return _hmem; + } + + /**@name Memory IO routines */ + //@{ + /** + Loads a dib from a memory stream + @param fif Format identifier (FreeImage format) + @param flags The signification of this flag depends on the image to be loaded. + @return Returns the loaded dib if successful, returns NULL otherwise + @see FreeImage_LoadFromMemory + */ + FIBITMAP* load(FREE_IMAGE_FORMAT fif, int flags = 0) const; + /** + Loads a multi-page bitmap from a memory stream + @param fif Format identifier (FreeImage format) + @param flags The signification of this flag depends on the multi-page to be loaded. + @return Returns the loaded multi-page if successful, returns NULL otherwise + @see FreeImage_LoadMultiBitmapFromMemory + */ + FIMULTIBITMAP* loadMultiPage(FREE_IMAGE_FORMAT fif, int flags = 0) const; + /** + Saves a dib to a memory stream + @param fif Format identifier (FreeImage format) + @param dib Image to be saved + @param flags The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SaveToMemory + */ + BOOL save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, int flags = 0); + /** + Saves a multi-page bitmap to a memory stream + @param fif Format identifier (FreeImage format) + @param bitmap Multi-page image to be saved + @param flags The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SaveMultiBitmapToMemory + */ + BOOL saveMultiPage(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, int flags = 0); + /** + Reads data from a memory stream + @param buffer Storage location for data + @param size Item size in bytes + @param count Maximum number of items to be read + @return Returns the number of full items actually read, which may be less than count if an error occurs + @see FreeImage_ReadMemory + */ + unsigned read(void *buffer, unsigned size, unsigned count) const; + /** + Writes data to a memory stream + @param buffer Pointer to data to be written + @param size Item size in bytes + @param count Maximum number of items to be written + @return Returns the number of full items actually written, which may be less than count if an error occurs + @see FreeImage_WriteMemory + */ + unsigned write(const void *buffer, unsigned size, unsigned count); + /** + Gets the current position of a memory pointer + @see FreeImage_TellMemory + */ + long tell() const; + /** + Moves the memory pointer to a specified location + @see FreeImage_SeekMemory + */ + BOOL seek(long offset, int origin); + /** + Provides a direct buffer access to a memory stream + @param data Pointer to the memory buffer (returned value) + @param size_in_bytes Buffer size in bytes (returned value) + @see FreeImage_AcquireMemory + */ + BOOL acquire(BYTE **data, DWORD *size_in_bytes); + //@} + +private: + /// Disable copy + fipMemoryIO(const fipMemoryIO& src); + /// Disable copy + fipMemoryIO& operator=(const fipMemoryIO& src); + +}; + +// ---------------------------------------------------------- + +/** Multi-page file stream + + fipMultiPage encapsulates the multi-page API. It supports reading/writing + multi-page TIFF, ICO and GIF files. +*/ +class FIP_API fipMultiPage : public fipObject +{ +protected: + /// Pointer to a multi-page file stream + FIMULTIBITMAP *_mpage; + /// TRUE when using a memory cache, FALSE otherwise + BOOL _bMemoryCache; + +public: + /** + Constructor + @param keep_cache_in_memory When it is TRUE, all gathered bitmap data in the page manipulation process is kept in memory, otherwise it is lazily flushed to a temporary file on the hard disk in 64 Kb blocks. + */ + fipMultiPage(BOOL keep_cache_in_memory = FALSE); + + /** + Destructor + Close the file stream if not already done. + */ + virtual ~fipMultiPage(); + + /// Returns TRUE if the multi-page stream is opened + BOOL isValid() const; + + /** + Returns a pointer to the FIMULTIBITMAP data. Used for direct access from FREEIMAGE functions + or from your own low level C functions. + */ + operator FIMULTIBITMAP*() { + return _mpage; + } + + /** + Open a multi-page file stream + @param lpszPathName Name of the multi-page bitmap file + @param create_new When TRUE, it means that a new bitmap will be created rather than an existing one being opened + @param read_only When TRUE the bitmap is opened read-only + @param flags Load flags. The signification of this flag depends on the image to be loaded. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_OpenMultiBitmap + */ + BOOL open(const char* lpszPathName, BOOL create_new, BOOL read_only, int flags = 0); + + /** + Open a multi-page memory stream as read/write. + @param memIO Memory stream. The memory stream MUST BE a wrapped user buffer. + @param flags Load flags. The signification of this flag depends on the image to be loaded. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_LoadMultiBitmapFromMemory + */ + BOOL open(fipMemoryIO& memIO, int flags = 0); + + /** + Open a multi-page image as read/write, using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the image to be read. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_OpenMultiBitmapFromHandle + */ + BOOL open(FreeImageIO *io, fi_handle handle, int flags = 0); + + /** + Close a file stream + @param flags Save flags. The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_CloseMultiBitmap + */ + BOOL close(int flags = 0); + + /** + Saves a multi-page image using the specified FreeImageIO struct and fi_handle, and an optional flag. + @param fif Format identifier (FreeImage format) + @param io FreeImageIO structure + @param handle FreeImage fi_handle + @param flag The signification of this flag depends on the multi-page image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveMultiBitmapToHandle, FreeImage documentation + */ + BOOL saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags = 0) const; + + /** + Saves a multi-page image using the specified memory stream and an optional flag. + @param fif Format identifier (FreeImage format) + @param memIO FreeImage memory stream + @param flag The signification of this flag depends on the image to be saved. + @return Returns TRUE if successful, FALSE otherwise. + @see FreeImage_SaveMultiBitmapToMemory, FreeImage documentation + */ + BOOL saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flags = 0) const; + + /** + Returns the number of pages currently available in the multi-paged bitmap + @see FreeImage_GetPageCount + */ + int getPageCount() const; + + /** + Appends a new page to the end of the bitmap + @param image Image to append + @see FreeImage_AppendPage + */ + void appendPage(fipImage& image); + + /** + Inserts a new page before the given position in the bitmap + @param page Page number. Page has to be a number smaller than the current number of pages available in the bitmap. + @param image Image to insert + @see FreeImage_InsertPage + */ + void insertPage(int page, fipImage& image); + + /** + Deletes the page on the given position + @param page Page number + @see FreeImage_DeletePage + */ + void deletePage(int page); + + /** + Moves the source page to the position of the target page. + @param target Target page position + @param source Source page position + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_MovePage + */ + BOOL movePage(int target, int source); + + /** + Locks a page in memory for editing. You must call unlockPage to free the page
+ Usage :
+
+	fipMultiPage mpage;
+	// ...
+	fipImage image;		// You must declare this before
+	image = mpage.lockPage(2);
+	if(image.isValid()) {
+	  // ...
+	  mpage.unlockPage(image, TRUE);
+	}
+	
+ @param page Page number + @return Returns the page if successful, returns NULL otherwise + @see FreeImage_LockPage + */ + FIBITMAP* lockPage(int page); + + /** + Unlocks a previously locked page and gives it back to the multi-page engine + @param image Page to unlock + @param changed When TRUE, the page is marked changed and the new page data is applied in the multi-page bitmap. + @see FreeImage_UnlockPage + */ + void unlockPage(fipImage& image, BOOL changed); + + /** + Returns an array of page-numbers that are currently locked in memory. + When the pages parameter is NULL, the size of the array is returned in the count variable. + You can then allocate the array of the desired size and call + getLockedPageNumbers again to populate the array. + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_GetLockedPageNumbers + */ + BOOL getLockedPageNumbers(int *pages, int *count) const; +}; + +// ---------------------------------------------------------- + +/** +FreeImage Tag + +FreeImage uses this structure to store metadata information. +*/ +class FIP_API fipTag : public fipObject +{ +protected: + /// Pointer to a FreeImage tag + FITAG *_tag; + +public: + /**@name Creation & Destruction */ + //@{ + /** + Constructor + @see FreeImage_CreateTag + */ + fipTag(); + /** + Destructor + @see FreeImage_DeleteTag + */ + virtual ~fipTag(); + /** + Construct a FIDT_ASCII tag (ASCII string).
+ This method is useful to store comments or IPTC tags. + @param name Field name + @param value Field value + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_CreateTag + */ + BOOL setKeyValue(const char *key, const char *value); + + //@} + + /**@name Copying */ + //@{ + /** + Copy constructor + @see FreeImage_CloneTag + */ + fipTag(const fipTag& tag); + /** + Copy constructor + @see FreeImage_CloneTag + */ + fipTag& operator=(const fipTag& tag); + /** + Assignement operator
+ Copy the input pointer and manage its destruction + @see operator FITAG*() + */ + fipTag& operator=(FITAG *tag); + //@} + + /** + Returns a pointer to the FITAG data. Used for direct access from FREEIMAGE functions + or from your own low level C functions. + @see operator=(FITAG *tag) + */ + operator FITAG*() { + return _tag; + } + + /// Returns TRUE if the tag is allocated, FALSE otherwise + BOOL isValid() const; + + /**@name Tag accessors */ + //@{ + /** + Returns the tag field name (unique inside a metadata model). + @see FreeImage_GetTagKey + */ + const char *getKey() const; + /** + Returns the tag description if available, returns NULL otherwise + @see FreeImage_GetTagDescription + */ + const char *getDescription() const; + /** + Returns the tag ID if available, returns 0 otherwise + @see FreeImage_GetTagID + */ + WORD getID() const; + /** + Returns the tag data type + @see FreeImage_GetTagType + */ + FREE_IMAGE_MDTYPE getType() const; + /** + Returns the number of components in the tag (in tag type units) + @see FreeImage_GetTagCount + */ + DWORD getCount() const; + /** + Returns the length of the tag value in bytes + @see FreeImage_GetTagLength + */ + DWORD getLength() const; + /** + Returns the tag value + @see FreeImage_GetTagValue + */ + const void *getValue() const; + /** + Set the tag field name + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagKey + */ + BOOL setKey(const char *key); + /** + Set the (usually optional) tag description + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagDescription + */ + BOOL setDescription(const char *description); + /** + Set the (usually optional) tad ID + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagID + */ + BOOL setID(WORD id); + /** + Set the tag data type + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagType + */ + BOOL setType(FREE_IMAGE_MDTYPE type); + /** + Set the number of data in the tag + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagCount + */ + BOOL setCount(DWORD count); + /** + Set the length of the tag value, in bytes + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagLength + */ + BOOL setLength(DWORD length); + /** + Set the tag value + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_SetTagValue + */ + BOOL setValue(const void *value); + + //@} + + /** + Converts a FreeImage tag structure to a string that represents the interpreted tag value + @param model Metadata model specification (metadata model from which the tag was extracted) + @param Make Camera model (not used yet) + */ + const char* toString(FREE_IMAGE_MDMODEL model, char *Make = NULL) const; + +}; + +/** +Metadata iterator + +Usage :
+
+fipImage image;
+// ...
+fipTag tag;
+fipMetadataFind finder;
+if( finder.findFirstMetadata(FIMD_EXIF_MAIN, image, tag) ) {
+  do {
+    // process the tag
+	cout << tag.getKey() << "\n";
+
+  } while( finder.findNextMetadata(tag) );
+}
+// the class can be called again with another metadata model
+if( finder.findFirstMetadata(FIMD_EXIF_EXIF, image, tag) ) {
+  do {
+    // process the tag
+	cout << tag.getKey() << "\n";
+
+  } while( finder.findNextMetadata(tag) );
+}
+
+*/ +class FIP_API fipMetadataFind : public fipObject +{ +protected: + /// Pointer to a search handle + FIMETADATA *_mdhandle; + +public: + /// Returns TRUE if the search handle is allocated, FALSE otherwise + BOOL isValid() const; + + /// Constructor + fipMetadataFind(); + /** + Destructor + @see FreeImage_FindCloseMetadata + */ + virtual ~fipMetadataFind(); + /** + Provides information about the first instance of a tag that matches + the metadata model specified in the model argument. + @param model Metadata model + @param image Input image + @param tag Returned tag + @return Returns TRUE if successful, returns FALSE otherwise + @see FreeImage_FindFirstMetadata + */ + BOOL findFirstMetadata(FREE_IMAGE_MDMODEL model, fipImage& image, fipTag& tag); + /** + Find the next tag, if any, that matches the metadata model argument + in a previous call to findFirstMetadata + @param tag Returned tag + @return Returns TRUE if successful, returns FALSE otherwise, indicating that no more matching tags could be found + @see FreeImage_FindNextMetadata + */ + BOOL findNextMetadata(fipTag& tag); + +}; + +#endif // FREEIMAGEPLUS_H diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x64/FreeImagePlus.lib b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x64/FreeImagePlus.lib new file mode 100644 index 0000000..6b52f0e Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/dist/x64/FreeImagePlus.lib differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/FreeImagePlus.dox b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/FreeImagePlus.dox new file mode 100644 index 0000000..8c32d39 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/FreeImagePlus.dox @@ -0,0 +1,1709 @@ +# Doxyfile 1.7.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = FreeImagePlus + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = "- FreeImage 3.15.1" + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = D:/Projects/FreeImage/Wrapper/FreeImagePlus/ + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = YES + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = YES + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = D:\Projects\FreeImage\Wrapper\FreeImagePlus\doc\doxygen.log + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = D:/Projects/FreeImage/Source/FreeImage.h \ + D:/Projects/FreeImage/Wrapper/FreeImagePlus/FreeImagePlus.h + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.h + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is adviced to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = YES + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the +# mathjax.org site, so you can quickly see the result without installing +# MathJax, but it is strongly recommended to install a local copy of MathJax +# before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = NO + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = _WIN32 + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will write a font called Helvetica to the output +# directory and reference it in all dot files that doxygen generates. +# When you want a differently looking font you can specify the font name +# using DOT_FONTNAME. You need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/footer.html b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/footer.html new file mode 100644 index 0000000..ed36a62 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/footer.html @@ -0,0 +1,7 @@ +
+

+
+

+ + + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/freeimage.png b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/freeimage.png new file mode 100644 index 0000000..4fa7923 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/freeimage.png differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/freeimagedoc.jpg b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/freeimagedoc.jpg new file mode 100644 index 0000000..0a31440 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/freeimagedoc.jpg differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/index.html b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/index.html new file mode 100644 index 0000000..108c46b --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/doc/index.html @@ -0,0 +1,43 @@ + + + + +FreeImagePlus: Main Page + + + + + +
+
+ + + + + + +
+
FreeImagePlus - FreeImage 3.15.1
+
+
+ +
+
+
+
FreeImagePlus Documentation
+
+
+
+

+
+

+

A C++ wrapper for FreeImage 3

+ + + diff --git a/freeimage241/Source/FreeImageIO.h b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/FreeImagePlus.cpp similarity index 60% rename from freeimage241/Source/FreeImageIO.h rename to #ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/FreeImagePlus.cpp index b157427..efb8fe9 100644 --- a/freeimage241/Source/FreeImageIO.h +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/FreeImagePlus.cpp @@ -1,10 +1,10 @@ // ========================================================== -// Input/Output functions +// FreeImagePlus.cpp : Defines the entry point for the DLL application. // // Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) +// - Hervé Drolon (drolon@infonie.fr) // -// This file is part of FreeImage +// This file is part of FreeImage 3 // // COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES @@ -19,15 +19,28 @@ // Use at your own risk! // ========================================================== -#ifndef FREEIMAGEIO_H -#define FREEIMAGEIO_H +#ifdef _WIN32 +#include +#endif // _WIN32 -#ifndef FREEIMAGE_H -#include "FreeImage.h" -#endif +#include "FreeImagePlus.h" -// ---------------------------------------------------------- +//---------------------------------------------------------------------- -void SetDefaultIO(FreeImageIO *io); +#ifdef _WIN32 -#endif // !FREEIMAGEIO_H +BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + + +#endif // _WIN32 diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipImage.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipImage.cpp new file mode 100644 index 0000000..0ce5688 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipImage.cpp @@ -0,0 +1,974 @@ +// ========================================================== +// fipImage class implementation +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "FreeImagePlus.h" + +/////////////////////////////////////////////////////////////////// +// Protected functions + +BOOL fipImage::replace(FIBITMAP *new_dib) { + if(new_dib == NULL) + return FALSE; + if(_dib) + FreeImage_Unload(_dib); + _dib = new_dib; + _bHasChanged = TRUE; + return TRUE; +} + +/////////////////////////////////////////////////////////////////// +// Creation & Destruction + +fipImage::fipImage(FREE_IMAGE_TYPE image_type, unsigned width, unsigned height, unsigned bpp) { + _dib = NULL; + _bHasChanged = FALSE; + if(width && height && bpp) + setSize(image_type, width, height, bpp); +} + +fipImage::~fipImage() { + if(_dib) { + FreeImage_Unload(_dib); + _dib = NULL; + } +} + +BOOL fipImage::setSize(FREE_IMAGE_TYPE image_type, unsigned width, unsigned height, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask) { + if(_dib) { + FreeImage_Unload(_dib); + } + if((_dib = FreeImage_AllocateT(image_type, width, height, bpp, red_mask, green_mask, blue_mask)) == NULL) + return FALSE; + + if(image_type == FIT_BITMAP) { + // Create palette if needed + switch(bpp) { + case 1: + case 4: + case 8: + RGBQUAD *pal = FreeImage_GetPalette(_dib); + for(unsigned i = 0; i < FreeImage_GetColorsUsed(_dib); i++) { + pal[i].rgbRed = i; + pal[i].rgbGreen = i; + pal[i].rgbBlue = i; + } + break; + } + } + + _bHasChanged = TRUE; + + return TRUE; +} + +void fipImage::clear() { + if(_dib) { + FreeImage_Unload(_dib); + _dib = NULL; + } + _bHasChanged = TRUE; +} + +/////////////////////////////////////////////////////////////////// +// Copying + +fipImage::fipImage(const fipImage& Image) { + _dib = NULL; + _fif = FIF_UNKNOWN; + FIBITMAP *clone = FreeImage_Clone((FIBITMAP*)Image._dib); + replace(clone); +} + +fipImage& fipImage::operator=(const fipImage& Image) { + if(this != &Image) { + FIBITMAP *clone = FreeImage_Clone((FIBITMAP*)Image._dib); + replace(clone); + } + return *this; +} + +fipImage& fipImage::operator=(FIBITMAP *dib) { + if(_dib != dib) { + replace(dib); + } + return *this; +} + +BOOL fipImage::copySubImage(fipImage& dst, int left, int top, int right, int bottom) const { + if(_dib) { + dst = FreeImage_Copy(_dib, left, top, right, bottom); + return dst.isValid(); + } + return FALSE; +} + +BOOL fipImage::pasteSubImage(fipImage& src, int left, int top, int alpha) { + if(_dib) { + BOOL bResult = FreeImage_Paste(_dib, src._dib, left, top, alpha); + _bHasChanged = TRUE; + return bResult; + } + return FALSE; +} + +BOOL fipImage::crop(int left, int top, int right, int bottom) { + if(_dib) { + FIBITMAP *dst = FreeImage_Copy(_dib, left, top, right, bottom); + return replace(dst); + } + return FALSE; +} + + +/////////////////////////////////////////////////////////////////// +// Information functions + +FREE_IMAGE_TYPE fipImage::getImageType() const { + return FreeImage_GetImageType(_dib); +} + +unsigned fipImage::getWidth() const { + return FreeImage_GetWidth(_dib); +} + +unsigned fipImage::getHeight() const { + return FreeImage_GetHeight(_dib); +} + +unsigned fipImage::getScanWidth() const { + return FreeImage_GetPitch(_dib); +} + +BOOL fipImage::isValid() const { + return (_dib != NULL) ? TRUE:FALSE; +} + +BITMAPINFO* fipImage::getInfo() const { + return FreeImage_GetInfo(_dib); +} + +BITMAPINFOHEADER* fipImage::getInfoHeader() const { + return FreeImage_GetInfoHeader(_dib); +} + +unsigned fipImage::getImageSize() const { + return FreeImage_GetDIBSize(_dib); +} + +unsigned fipImage::getImageMemorySize() const { + return FreeImage_GetMemorySize(_dib); +} + +unsigned fipImage::getBitsPerPixel() const { + return FreeImage_GetBPP(_dib); +} + +unsigned fipImage::getLine() const { + return FreeImage_GetLine(_dib); +} + +double fipImage::getHorizontalResolution() const { + return (FreeImage_GetDotsPerMeterX(_dib) / (double)100); +} + +double fipImage::getVerticalResolution() const { + return (FreeImage_GetDotsPerMeterY(_dib) / (double)100); +} + +void fipImage::setHorizontalResolution(double value) { + FreeImage_SetDotsPerMeterX(_dib, (unsigned)(value * 100 + 0.5)); +} + +void fipImage::setVerticalResolution(double value) { + FreeImage_SetDotsPerMeterY(_dib, (unsigned)(value * 100 + 0.5)); +} + + +/////////////////////////////////////////////////////////////////// +// Palette operations + +RGBQUAD* fipImage::getPalette() const { + return FreeImage_GetPalette(_dib); +} + +unsigned fipImage::getPaletteSize() const { + return FreeImage_GetColorsUsed(_dib) * sizeof(RGBQUAD); +} + +unsigned fipImage::getColorsUsed() const { + return FreeImage_GetColorsUsed(_dib); +} + +FREE_IMAGE_COLOR_TYPE fipImage::getColorType() const { + return FreeImage_GetColorType(_dib); +} + +BOOL fipImage::isGrayscale() const { + return ((FreeImage_GetBPP(_dib) == 8) && (FreeImage_GetColorType(_dib) != FIC_PALETTE)); +} + +/////////////////////////////////////////////////////////////////// +// Thumbnail access + +BOOL fipImage::getThumbnail(fipImage& image) const { + image = FreeImage_Clone( FreeImage_GetThumbnail(_dib) ); + return image.isValid(); +} + +BOOL fipImage::setThumbnail(const fipImage& image) { + return FreeImage_SetThumbnail(_dib, (FIBITMAP*)image._dib); +} + +BOOL fipImage::hasThumbnail() const { + return (FreeImage_GetThumbnail(_dib) != NULL); +} + +BOOL fipImage::clearThumbnail() { + return FreeImage_SetThumbnail(_dib, NULL); +} + + +/////////////////////////////////////////////////////////////////// +// Pixel access + +BYTE* fipImage::accessPixels() const { + return FreeImage_GetBits(_dib); +} + +BYTE* fipImage::getScanLine(unsigned scanline) const { + if(scanline < FreeImage_GetHeight(_dib)) { + return FreeImage_GetScanLine(_dib, scanline); + } + return NULL; +} + +BOOL fipImage::getPixelIndex(unsigned x, unsigned y, BYTE *value) const { + return FreeImage_GetPixelIndex(_dib, x, y, value); +} + +BOOL fipImage::getPixelColor(unsigned x, unsigned y, RGBQUAD *value) const { + return FreeImage_GetPixelColor(_dib, x, y, value); +} + +BOOL fipImage::setPixelIndex(unsigned x, unsigned y, BYTE *value) { + _bHasChanged = TRUE; + return FreeImage_SetPixelIndex(_dib, x, y, value); +} + +BOOL fipImage::setPixelColor(unsigned x, unsigned y, RGBQUAD *value) { + _bHasChanged = TRUE; + return FreeImage_SetPixelColor(_dib, x, y, value); +} + +/////////////////////////////////////////////////////////////////// +// File type identification + +FREE_IMAGE_FORMAT fipImage::identifyFIF(const char* lpszPathName) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + + // check the file signature and get its format + // (the second argument is currently not used by FreeImage) + fif = FreeImage_GetFileType(lpszPathName, 0); + if(fif == FIF_UNKNOWN) { + // no signature ? + // try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilename(lpszPathName); + } + + return fif; +} + +FREE_IMAGE_FORMAT fipImage::identifyFIFU(const wchar_t* lpszPathName) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + + // check the file signature and get its format + // (the second argument is currently not used by FreeImage) + fif = FreeImage_GetFileTypeU(lpszPathName, 0); + if(fif == FIF_UNKNOWN) { + // no signature ? + // try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilenameU(lpszPathName); + } + + return fif; +} + +FREE_IMAGE_FORMAT fipImage::identifyFIFFromHandle(FreeImageIO *io, fi_handle handle) { + if(io && handle) { + // check the file signature and get its format + return FreeImage_GetFileTypeFromHandle(io, handle, 16); + } + return FIF_UNKNOWN; +} + +FREE_IMAGE_FORMAT fipImage::identifyFIFFromMemory(FIMEMORY *hmem) { + if(hmem != NULL) { + return FreeImage_GetFileTypeFromMemory(hmem, 0); + } + return FIF_UNKNOWN; +} + + +/////////////////////////////////////////////////////////////////// +// Loading & Saving + +BOOL fipImage::load(const char* lpszPathName, int flag) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + + // check the file signature and get its format + // (the second argument is currently not used by FreeImage) + fif = FreeImage_GetFileType(lpszPathName, 0); + if(fif == FIF_UNKNOWN) { + // no signature ? + // try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilename(lpszPathName); + } + // check that the plugin has reading capabilities ... + if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) { + // Free the previous dib + if(_dib) { + FreeImage_Unload(_dib); + } + // Load the file + _dib = FreeImage_Load(fif, lpszPathName, flag); + _bHasChanged = TRUE; + if(_dib == NULL) + return FALSE; + return TRUE; + } + return FALSE; +} + +BOOL fipImage::loadU(const wchar_t* lpszPathName, int flag) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + + // check the file signature and get its format + // (the second argument is currently not used by FreeImage) + fif = FreeImage_GetFileTypeU(lpszPathName, 0); + if(fif == FIF_UNKNOWN) { + // no signature ? + // try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilenameU(lpszPathName); + } + // check that the plugin has reading capabilities ... + if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) { + // Free the previous dib + if(_dib) { + FreeImage_Unload(_dib); + } + // Load the file + _dib = FreeImage_LoadU(fif, lpszPathName, flag); + _bHasChanged = TRUE; + if(_dib == NULL) + return FALSE; + return TRUE; + } + return FALSE; +} + +BOOL fipImage::loadFromHandle(FreeImageIO *io, fi_handle handle, int flag) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + + // check the file signature and get its format + fif = FreeImage_GetFileTypeFromHandle(io, handle, 16); + if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) { + // Free the previous dib + if(_dib) { + FreeImage_Unload(_dib); + } + // Load the file + _dib = FreeImage_LoadFromHandle(fif, io, handle, flag); + _bHasChanged = TRUE; + if(_dib == NULL) + return FALSE; + return TRUE; + } + return FALSE; +} + +BOOL fipImage::loadFromMemory(fipMemoryIO& memIO, int flag) { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + + // check the file signature and get its format + fif = memIO.getFileType(); + if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) { + // Free the previous dib + if(_dib) { + FreeImage_Unload(_dib); + } + // Load the file + _dib = memIO.load(fif, flag); + _bHasChanged = TRUE; + if(_dib == NULL) + return FALSE; + return TRUE; + } + return FALSE; +} + +BOOL fipImage::save(const char* lpszPathName, int flag) const { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + BOOL bSuccess = FALSE; + + // Try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilename(lpszPathName); + if(fif != FIF_UNKNOWN ) { + // Check that the dib can be saved in this format + BOOL bCanSave; + + FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(_dib); + if(image_type == FIT_BITMAP) { + // standard bitmap type + WORD bpp = FreeImage_GetBPP(_dib); + bCanSave = (FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp)); + } else { + // special bitmap type + bCanSave = FreeImage_FIFSupportsExportType(fif, image_type); + } + + if(bCanSave) { + bSuccess = FreeImage_Save(fif, _dib, lpszPathName, flag); + return bSuccess; + } + } + return bSuccess; +} + +BOOL fipImage::saveU(const wchar_t* lpszPathName, int flag) const { + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + BOOL bSuccess = FALSE; + + // Try to guess the file format from the file extension + fif = FreeImage_GetFIFFromFilenameU(lpszPathName); + if(fif != FIF_UNKNOWN ) { + // Check that the dib can be saved in this format + BOOL bCanSave; + + FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(_dib); + if(image_type == FIT_BITMAP) { + // standard bitmap type + WORD bpp = FreeImage_GetBPP(_dib); + bCanSave = (FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp)); + } else { + // special bitmap type + bCanSave = FreeImage_FIFSupportsExportType(fif, image_type); + } + + if(bCanSave) { + bSuccess = FreeImage_SaveU(fif, _dib, lpszPathName, flag); + return bSuccess; + } + } + return bSuccess; +} + +BOOL fipImage::saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flag) const { + BOOL bSuccess = FALSE; + + if(fif != FIF_UNKNOWN ) { + // Check that the dib can be saved in this format + BOOL bCanSave; + + FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(_dib); + if(image_type == FIT_BITMAP) { + // standard bitmap type + WORD bpp = FreeImage_GetBPP(_dib); + bCanSave = (FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp)); + } else { + // special bitmap type + bCanSave = FreeImage_FIFSupportsExportType(fif, image_type); + } + + if(bCanSave) { + bSuccess = FreeImage_SaveToHandle(fif, _dib, io, handle, flag); + return bSuccess; + } + } + return bSuccess; +} + +BOOL fipImage::saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flag) const { + BOOL bSuccess = FALSE; + + if(fif != FIF_UNKNOWN ) { + // Check that the dib can be saved in this format + BOOL bCanSave; + + FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(_dib); + if(image_type == FIT_BITMAP) { + // standard bitmap type + WORD bpp = FreeImage_GetBPP(_dib); + bCanSave = (FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp)); + } else { + // special bitmap type + bCanSave = FreeImage_FIFSupportsExportType(fif, image_type); + } + + if(bCanSave) { + bSuccess = memIO.save(fif, _dib, flag); + return bSuccess; + } + } + return bSuccess; +} + +/////////////////////////////////////////////////////////////////// +// Conversion routines + +BOOL fipImage::convertToType(FREE_IMAGE_TYPE image_type, BOOL scale_linear) { + if(_dib) { + FIBITMAP *dib = FreeImage_ConvertToType(_dib, image_type, scale_linear); + return replace(dib); + } + return FALSE; +} + +BOOL fipImage::threshold(BYTE T) { + if(_dib) { + FIBITMAP *dib1 = FreeImage_Threshold(_dib, T); + return replace(dib1); + } + return FALSE; +} + +BOOL fipImage::convertTo4Bits() { + if(_dib) { + FIBITMAP *dib4 = FreeImage_ConvertTo4Bits(_dib); + return replace(dib4); + } + return FALSE; +} + +BOOL fipImage::convertTo8Bits() { + if(_dib) { + FIBITMAP *dib8 = FreeImage_ConvertTo8Bits(_dib); + return replace(dib8); + } + return FALSE; +} + +BOOL fipImage::convertTo16Bits555() { + if(_dib) { + FIBITMAP *dib16_555 = FreeImage_ConvertTo16Bits555(_dib); + return replace(dib16_555); + } + return FALSE; +} + +BOOL fipImage::convertTo16Bits565() { + if(_dib) { + FIBITMAP *dib16_565 = FreeImage_ConvertTo16Bits565(_dib); + return replace(dib16_565); + } + return FALSE; +} + +BOOL fipImage::convertTo24Bits() { + if(_dib) { + FIBITMAP *dibRGB = FreeImage_ConvertTo24Bits(_dib); + return replace(dibRGB); + } + return FALSE; +} + +BOOL fipImage::convertTo32Bits() { + if(_dib) { + FIBITMAP *dib32 = FreeImage_ConvertTo32Bits(_dib); + return replace(dib32); + } + return FALSE; +} + +BOOL fipImage::convertToGrayscale() { + if(_dib) { + FIBITMAP *dib8 = FreeImage_ConvertToGreyscale(_dib); + return replace(dib8); + } + return FALSE; +} + +BOOL fipImage::colorQuantize(FREE_IMAGE_QUANTIZE algorithm) { + if(_dib) { + FIBITMAP *dib8 = FreeImage_ColorQuantize(_dib, algorithm); + return replace(dib8); + } + return FALSE; +} + +BOOL fipImage::dither(FREE_IMAGE_DITHER algorithm) { + if(_dib) { + FIBITMAP *dib = FreeImage_Dither(_dib, algorithm); + return replace(dib); + } + return FALSE; +} + +BOOL fipImage::convertToFloat() { + if(_dib) { + FIBITMAP *dib = FreeImage_ConvertToFloat(_dib); + return replace(dib); + } + return FALSE; +} + +BOOL fipImage::convertToRGBF() { + if(_dib) { + FIBITMAP *dib = FreeImage_ConvertToRGBF(_dib); + return replace(dib); + } + return FALSE; +} + +BOOL fipImage::convertToRGBAF() { + if(_dib) { + FIBITMAP *dib = FreeImage_ConvertToRGBAF(_dib); + return replace(dib); + } + return FALSE; +} + +BOOL fipImage::convertToUINT16() { + if(_dib) { + FIBITMAP *dib = FreeImage_ConvertToUINT16(_dib); + return replace(dib); + } + return FALSE; +} + +BOOL fipImage::convertToRGB16() { + if(_dib) { + FIBITMAP *dib = FreeImage_ConvertToRGB16(_dib); + return replace(dib); + } + return FALSE; +} + +BOOL fipImage::convertToRGBA16() { + if(_dib) { + FIBITMAP *dib = FreeImage_ConvertToRGBA16(_dib); + return replace(dib); + } + return FALSE; +} + +BOOL fipImage::toneMapping(FREE_IMAGE_TMO tmo, double first_param, double second_param, double third_param, double fourth_param) { + if(_dib) { + FIBITMAP *dst = NULL; + // Apply a tone mapping algorithm and convert to 24-bit + switch(tmo) { + case FITMO_REINHARD05: + dst = FreeImage_TmoReinhard05Ex(_dib, first_param, second_param, third_param, fourth_param); + break; + default: + dst = FreeImage_ToneMapping(_dib, tmo, first_param, second_param); + break; + } + + return replace(dst); + } + return FALSE; +} + +/////////////////////////////////////////////////////////////////// +// Transparency support: background colour and alpha channel + +BOOL fipImage::isTransparent() const { + return FreeImage_IsTransparent(_dib); +} + +unsigned fipImage::getTransparencyCount() const { + return FreeImage_GetTransparencyCount(_dib); +} + +BYTE* fipImage::getTransparencyTable() const { + return FreeImage_GetTransparencyTable(_dib); +} + +void fipImage::setTransparencyTable(BYTE *table, int count) { + FreeImage_SetTransparencyTable(_dib, table, count); + _bHasChanged = TRUE; +} + +BOOL fipImage::hasFileBkColor() const { + return FreeImage_HasBackgroundColor(_dib); +} + +BOOL fipImage::getFileBkColor(RGBQUAD *bkcolor) const { + return FreeImage_GetBackgroundColor(_dib, bkcolor); +} + +BOOL fipImage::setFileBkColor(RGBQUAD *bkcolor) { + _bHasChanged = TRUE; + return FreeImage_SetBackgroundColor(_dib, bkcolor); +} + +/////////////////////////////////////////////////////////////////// +// Channel processing support + +BOOL fipImage::getChannel(fipImage& image, FREE_IMAGE_COLOR_CHANNEL channel) const { + if(_dib) { + image = FreeImage_GetChannel(_dib, channel); + return image.isValid(); + } + return FALSE; +} + +BOOL fipImage::setChannel(fipImage& image, FREE_IMAGE_COLOR_CHANNEL channel) { + if(_dib) { + _bHasChanged = TRUE; + return FreeImage_SetChannel(_dib, image._dib, channel); + } + return FALSE; +} + +BOOL fipImage::splitChannels(fipImage& RedChannel, fipImage& GreenChannel, fipImage& BlueChannel) { + if(_dib) { + RedChannel = FreeImage_GetChannel(_dib, FICC_RED); + GreenChannel = FreeImage_GetChannel(_dib, FICC_GREEN); + BlueChannel = FreeImage_GetChannel(_dib, FICC_BLUE); + + return (RedChannel.isValid() && GreenChannel.isValid() && BlueChannel.isValid()); + } + return FALSE; +} + +BOOL fipImage::combineChannels(fipImage& red, fipImage& green, fipImage& blue) { + if(!_dib) { + int width = red.getWidth(); + int height = red.getHeight(); + _dib = FreeImage_Allocate(width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + } + + if(_dib) { + BOOL bResult = TRUE; + bResult &= FreeImage_SetChannel(_dib, red._dib, FICC_RED); + bResult &= FreeImage_SetChannel(_dib, green._dib, FICC_GREEN); + bResult &= FreeImage_SetChannel(_dib, blue._dib, FICC_BLUE); + + _bHasChanged = TRUE; + + return bResult; + } + return FALSE; +} + +/////////////////////////////////////////////////////////////////// +// Rotation and flipping + +BOOL fipImage::rotateEx(double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask) { + if(_dib) { + if(FreeImage_GetBPP(_dib) >= 8) { + FIBITMAP *rotated = FreeImage_RotateEx(_dib, angle, x_shift, y_shift, x_origin, y_origin, use_mask); + return replace(rotated); + } + } + return FALSE; +} + +BOOL fipImage::rotate(double angle, const void *bkcolor) { + if(_dib) { + switch(FreeImage_GetImageType(_dib)) { + case FIT_BITMAP: + switch(FreeImage_GetBPP(_dib)) { + case 1: + case 8: + case 24: + case 32: + break; + default: + return FALSE; + } + break; + + case FIT_UINT16: + case FIT_RGB16: + case FIT_RGBA16: + case FIT_FLOAT: + case FIT_RGBF: + case FIT_RGBAF: + break; + default: + return FALSE; + break; + } + + FIBITMAP *rotated = FreeImage_Rotate(_dib, angle, bkcolor); + return replace(rotated); + + } + return FALSE; +} + +BOOL fipImage::flipVertical() { + if(_dib) { + _bHasChanged = TRUE; + + return FreeImage_FlipVertical(_dib); + } + return FALSE; +} + +BOOL fipImage::flipHorizontal() { + if(_dib) { + _bHasChanged = TRUE; + + return FreeImage_FlipHorizontal(_dib); + } + return FALSE; +} + +/////////////////////////////////////////////////////////////////// +// Color manipulation routines + +BOOL fipImage::invert() { + if(_dib) { + _bHasChanged = TRUE; + + return FreeImage_Invert(_dib); + } + return FALSE; +} + +BOOL fipImage::adjustCurve(BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel) { + if(_dib) { + _bHasChanged = TRUE; + + return FreeImage_AdjustCurve(_dib, LUT, channel); + } + return FALSE; +} + +BOOL fipImage::adjustGamma(double gamma) { + if(_dib) { + _bHasChanged = TRUE; + + return FreeImage_AdjustGamma(_dib, gamma); + } + return FALSE; +} + +BOOL fipImage::adjustBrightness(double percentage) { + if(_dib) { + _bHasChanged = TRUE; + + return FreeImage_AdjustBrightness(_dib, percentage); + } + return FALSE; +} + +BOOL fipImage::adjustContrast(double percentage) { + if(_dib) { + _bHasChanged = TRUE; + + return FreeImage_AdjustContrast(_dib, percentage); + } + return FALSE; +} + +BOOL fipImage::adjustBrightnessContrastGamma(double brightness, double contrast, double gamma) { + if(_dib) { + _bHasChanged = TRUE; + + return FreeImage_AdjustColors(_dib, brightness, contrast, gamma, FALSE); + } + return FALSE; +} + +BOOL fipImage::getHistogram(DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel) const { + if(_dib) { + return FreeImage_GetHistogram(_dib, histo, channel); + } + return FALSE; +} + +/////////////////////////////////////////////////////////////////// +// Upsampling / downsampling routine + +BOOL fipImage::rescale(unsigned new_width, unsigned new_height, FREE_IMAGE_FILTER filter) { + if(_dib) { + switch(FreeImage_GetImageType(_dib)) { + case FIT_BITMAP: + case FIT_UINT16: + case FIT_RGB16: + case FIT_RGBA16: + case FIT_FLOAT: + case FIT_RGBF: + case FIT_RGBAF: + break; + default: + return FALSE; + break; + } + + // Perform upsampling / downsampling + FIBITMAP *dst = FreeImage_Rescale(_dib, new_width, new_height, filter); + return replace(dst); + } + return FALSE; +} + +BOOL fipImage::makeThumbnail(unsigned max_size, BOOL convert) { + if(_dib) { + switch(FreeImage_GetImageType(_dib)) { + case FIT_BITMAP: + case FIT_UINT16: + case FIT_RGB16: + case FIT_RGBA16: + case FIT_FLOAT: + case FIT_RGBF: + case FIT_RGBAF: + break; + default: + return FALSE; + break; + } + + // Perform downsampling + FIBITMAP *dst = FreeImage_MakeThumbnail(_dib, max_size, convert); + return replace(dst); + } + return FALSE; +} + +/////////////////////////////////////////////////////////////////// +// Metadata + +unsigned fipImage::getMetadataCount(FREE_IMAGE_MDMODEL model) const { + return FreeImage_GetMetadataCount(model, _dib); +} + +BOOL fipImage::getMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag& tag) const { + FITAG *searchedTag = NULL; + FreeImage_GetMetadata(model, _dib, key, &searchedTag); + if(searchedTag != NULL) { + tag = FreeImage_CloneTag(searchedTag); + return TRUE; + } else { + // clear the tag + tag = (FITAG*)NULL; + } + return FALSE; +} + +BOOL fipImage::setMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag& tag) { + return FreeImage_SetMetadata(model, _dib, key, tag); +} + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipMemoryIO.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipMemoryIO.cpp new file mode 100644 index 0000000..4a8fe80 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipMemoryIO.cpp @@ -0,0 +1,95 @@ +// ========================================================== +// fipMemoryIO class implementation +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "FreeImagePlus.h" +#include +#include +#include +#include +#include +#include + +fipMemoryIO::fipMemoryIO(BYTE *data, DWORD size_in_bytes) { + _hmem = FreeImage_OpenMemory(data, size_in_bytes); +} + +fipMemoryIO::~fipMemoryIO() { + if(_hmem != NULL) { + FreeImage_CloseMemory(_hmem); + } +} + +void fipMemoryIO::close() { + if(_hmem != NULL) { + FreeImage_CloseMemory(_hmem); + _hmem = NULL; + } +} + +BOOL fipMemoryIO::isValid() const { + return (_hmem != NULL); +} + +FREE_IMAGE_FORMAT fipMemoryIO::getFileType() const { + if(_hmem != NULL) { + return FreeImage_GetFileTypeFromMemory(_hmem, 0); + } + + return FIF_UNKNOWN; +} + +FIBITMAP* fipMemoryIO::load(FREE_IMAGE_FORMAT fif, int flags) const { + return FreeImage_LoadFromMemory(fif, _hmem, flags); +} + +FIMULTIBITMAP* fipMemoryIO::loadMultiPage(FREE_IMAGE_FORMAT fif, int flags) const { + return FreeImage_LoadMultiBitmapFromMemory(fif, _hmem, flags); +} + +BOOL fipMemoryIO::save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, int flags) { + return FreeImage_SaveToMemory(fif, dib, _hmem, flags); +} + +BOOL fipMemoryIO::saveMultiPage(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, int flags) { + return FreeImage_SaveMultiBitmapToMemory(fif, bitmap, _hmem, flags); +} + +unsigned fipMemoryIO::read(void *buffer, unsigned size, unsigned count) const { + return FreeImage_ReadMemory(buffer, size, count, _hmem); +} + +unsigned fipMemoryIO::write(const void *buffer, unsigned size, unsigned count) { + return FreeImage_WriteMemory(buffer, size, count, _hmem); +} + +long fipMemoryIO::tell() const { + return FreeImage_TellMemory(_hmem); +} + +BOOL fipMemoryIO::seek(long offset, int origin) { + return FreeImage_SeekMemory(_hmem, offset, origin); +} + +BOOL fipMemoryIO::acquire(BYTE **data, DWORD *size_in_bytes) { + return FreeImage_AcquireMemory(_hmem, data, size_in_bytes); +} + + diff --git a/freeimage241/Source/FreeImage/FreeImageIO.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipMetadataFind.cpp similarity index 50% rename from freeimage241/Source/FreeImage/FreeImageIO.cpp rename to #ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipMetadataFind.cpp index d64d704..57d01f6 100644 --- a/freeimage241/Source/FreeImage/FreeImageIO.cpp +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipMetadataFind.cpp @@ -1,10 +1,10 @@ // ========================================================== -// Input/Output functions +// fipMetadataFind class implementation // // Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) +// - Hervé Drolon (drolon@infonie.fr) // -// This file is part of FreeImage +// This file is part of FreeImage 3 // // COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES @@ -19,38 +19,36 @@ // Use at your own risk! // ========================================================== -#include +#include "FreeImagePlus.h" -#include "FreeImageIO.h" - -// ---------------------------------------------------------- - -unsigned -_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { - return fread(buffer, size, count, (FILE *)handle); +BOOL fipMetadataFind::isValid() const { + return (_mdhandle != NULL) ? TRUE : FALSE; } -unsigned -_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { - return fwrite(buffer, size, count, (FILE *)handle); +fipMetadataFind::fipMetadataFind() : _mdhandle(NULL) { } -int -_SeekProc(fi_handle handle, long offset, int origin) { - return fseek((FILE *)handle, offset, origin); +fipMetadataFind::~fipMetadataFind() { + FreeImage_FindCloseMetadata(_mdhandle); } -long -_TellProc(fi_handle handle) { - return ftell((FILE *)handle); +BOOL fipMetadataFind::findFirstMetadata(FREE_IMAGE_MDMODEL model, fipImage& image, fipTag& tag) { + FITAG *firstTag = NULL; + if(_mdhandle) FreeImage_FindCloseMetadata(_mdhandle); + _mdhandle = FreeImage_FindFirstMetadata(model, image, &firstTag); + if(_mdhandle) { + tag = FreeImage_CloneTag(firstTag); + return TRUE; + } + return FALSE; +} + +BOOL fipMetadataFind::findNextMetadata(fipTag& tag) { + FITAG *nextTag = NULL; + if( FreeImage_FindNextMetadata(_mdhandle, &nextTag) ) { + tag = FreeImage_CloneTag(nextTag); + return TRUE; + } + return FALSE; } -// ---------------------------------------------------------- - -void -SetDefaultIO(FreeImageIO *io) { - io->read_proc = _ReadProc; - io->seek_proc = _SeekProc; - io->tell_proc = _TellProc; - io->write_proc = _WriteProc; -} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipMultiPage.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipMultiPage.cpp new file mode 100644 index 0000000..cc33196 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipMultiPage.cpp @@ -0,0 +1,140 @@ +// ========================================================== +// fipMultiPage class implementation +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "FreeImagePlus.h" + +fipMultiPage::fipMultiPage(BOOL keep_cache_in_memory) : _mpage(NULL), _bMemoryCache(keep_cache_in_memory) { +} + +fipMultiPage::~fipMultiPage() { + if(_mpage) { + // close the stream + close(0); + } +} + +BOOL fipMultiPage::isValid() const { + return (NULL != _mpage) ? TRUE : FALSE; +} + +BOOL fipMultiPage::open(const char* lpszPathName, BOOL create_new, BOOL read_only, int flags) { + // try to guess the file format from the filename + FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(lpszPathName); + + // open the stream + _mpage = FreeImage_OpenMultiBitmap(fif, lpszPathName, create_new, read_only, _bMemoryCache, flags); + + return (NULL != _mpage ) ? TRUE : FALSE; +} + +BOOL fipMultiPage::open(fipMemoryIO& memIO, int flags) { + // try to guess the file format from the memory handle + FREE_IMAGE_FORMAT fif = memIO.getFileType(); + + // open the stream + _mpage = memIO.loadMultiPage(fif, flags); + + return (NULL != _mpage ) ? TRUE : FALSE; +} + +BOOL fipMultiPage::open(FreeImageIO *io, fi_handle handle, int flags) { + // try to guess the file format from the handle + FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromHandle(io, handle, 0); + + // open the stream + _mpage = FreeImage_OpenMultiBitmapFromHandle(fif, io, handle, flags); + + return (NULL != _mpage ) ? TRUE : FALSE; +} + +BOOL fipMultiPage::close(int flags) { + BOOL bSuccess = FALSE; + if(_mpage) { + // close the stream + bSuccess = FreeImage_CloseMultiBitmap(_mpage, flags); + _mpage = NULL; + } + + return bSuccess; +} + +BOOL fipMultiPage::saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags) const { + BOOL bSuccess = FALSE; + if(_mpage) { + bSuccess = FreeImage_SaveMultiBitmapToHandle(fif, _mpage, io, handle, flags); + } + + return bSuccess; +} + +BOOL fipMultiPage::saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flags) const { + BOOL bSuccess = FALSE; + if(_mpage) { + bSuccess = memIO.saveMultiPage(fif, _mpage, flags); + } + + return bSuccess; +} + +int fipMultiPage::getPageCount() const { + return _mpage ? FreeImage_GetPageCount(_mpage) : 0; +} + +void fipMultiPage::appendPage(fipImage& image) { + if(_mpage) { + FreeImage_AppendPage(_mpage, image); + } +} + +void fipMultiPage::insertPage(int page, fipImage& image) { + if(_mpage) { + FreeImage_InsertPage(_mpage, page, image); + } +} + +void fipMultiPage::deletePage(int page) { + if(_mpage) { + FreeImage_DeletePage(_mpage, page); + } +} + +BOOL fipMultiPage::movePage(int target, int source) { + return _mpage ? FreeImage_MovePage(_mpage, target, source) : FALSE; +} + +FIBITMAP* fipMultiPage::lockPage(int page) { + return _mpage ? FreeImage_LockPage(_mpage, page) : NULL; +} + +void fipMultiPage::unlockPage(fipImage& image, BOOL changed) { + if(_mpage) { + FreeImage_UnlockPage(_mpage, image, changed); + // clear the image so that it becomes invalid. + // this is possible because of the friend declaration + image._dib = NULL; + image._bHasChanged = FALSE; + } +} + +BOOL fipMultiPage::getLockedPageNumbers(int *pages, int *count) const { + return _mpage ? FreeImage_GetLockedPageNumbers(_mpage, pages, count) : FALSE; +} + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipTag.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipTag.cpp new file mode 100644 index 0000000..b00a095 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipTag.cpp @@ -0,0 +1,134 @@ +// ========================================================== +// fipTag class implementation +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include +#include "FreeImagePlus.h" + +fipTag::fipTag() { + _tag = FreeImage_CreateTag(); +} + +fipTag::~fipTag() { + FreeImage_DeleteTag(_tag); +} + +BOOL fipTag::setKeyValue(const char *key, const char *value) { + if(_tag) { + FreeImage_DeleteTag(_tag); + _tag = NULL; + } + // create a tag + _tag = FreeImage_CreateTag(); + if(_tag) { + BOOL bSuccess = TRUE; + // fill the tag + DWORD tag_length = (DWORD)(strlen(value) + 1); + bSuccess &= FreeImage_SetTagKey(_tag, key); + bSuccess &= FreeImage_SetTagLength(_tag, tag_length); + bSuccess &= FreeImage_SetTagCount(_tag, tag_length); + bSuccess &= FreeImage_SetTagType(_tag, FIDT_ASCII); + bSuccess &= FreeImage_SetTagValue(_tag, value); + return bSuccess; + } + return FALSE; +} + +fipTag::fipTag(const fipTag& tag) { + _tag = FreeImage_CloneTag(tag._tag); +} + +fipTag& fipTag::operator=(const fipTag& tag) { + if(this != &tag) { + if(_tag) FreeImage_DeleteTag(_tag); + _tag = FreeImage_CloneTag(tag._tag); + } + return *this; +} + +fipTag& fipTag::operator=(FITAG *tag) { + if(_tag) FreeImage_DeleteTag(_tag); + _tag = tag; + return *this; +} + +BOOL fipTag::isValid() const { + return (_tag != NULL) ? TRUE : FALSE; +} + +const char* fipTag::getKey() const { + return FreeImage_GetTagKey(_tag); +} + +const char* fipTag::getDescription() const { + return FreeImage_GetTagDescription(_tag); +} + +WORD fipTag::getID() const { + return FreeImage_GetTagID(_tag); +} + +FREE_IMAGE_MDTYPE fipTag::getType() const { + return FreeImage_GetTagType(_tag); +} + +DWORD fipTag::getCount() const { + return FreeImage_GetTagCount(_tag); +} + +DWORD fipTag::getLength() const { + return FreeImage_GetTagLength(_tag); +} + +const void* fipTag::getValue() const { + return FreeImage_GetTagValue(_tag); +} + +BOOL fipTag::setKey(const char *key) { + return FreeImage_SetTagKey(_tag, key); +} + +BOOL fipTag::setDescription(const char *description) { + return FreeImage_SetTagDescription(_tag, description); +} + +BOOL fipTag::setID(WORD id) { + return FreeImage_SetTagID(_tag, id); +} + +BOOL fipTag::setType(FREE_IMAGE_MDTYPE type) { + return FreeImage_SetTagType(_tag, type); +} + +BOOL fipTag::setCount(DWORD count) { + return FreeImage_SetTagCount(_tag, count); +} + +BOOL fipTag::setLength(DWORD length) { + return FreeImage_SetTagLength(_tag, length); +} + +BOOL fipTag::setValue(const void *value) { + return FreeImage_SetTagValue(_tag, value); +} + +const char* fipTag::toString(FREE_IMAGE_MDMODEL model, char *Make) const { + return FreeImage_TagToString(model, _tag, Make); +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipWinImage.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipWinImage.cpp new file mode 100644 index 0000000..092b655 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/src/fipWinImage.cpp @@ -0,0 +1,488 @@ +// ========================================================== +// fipWinImage class implementation +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#include "FreeImagePlus.h" + +#ifdef _WIN32 + +// marker used for clipboard copy / paste + +static inline void +SET_FREEIMAGE_MARKER(BITMAPINFOHEADER *bmih, FIBITMAP *dib) { + // Windows constants goes from 0L to 5L + // Add 0xFF to avoid conflicts + bmih->biCompression = 0xFF + FreeImage_GetImageType(dib); +} + +static inline FREE_IMAGE_TYPE +GET_FREEIMAGE_MARKER(BITMAPINFOHEADER *bmih) { + return (FREE_IMAGE_TYPE)(bmih->biCompression - 0xFF); +} + +/////////////////////////////////////////////////////////////////// +// Construction / Destruction + +fipWinImage::fipWinImage(FREE_IMAGE_TYPE image_type, unsigned width, unsigned height, unsigned bpp) : fipImage(image_type, width, height, bpp) { + _display_dib = NULL; + _bDeleteMe = FALSE; + // default tone mapping operator + _tmo = FITMO_DRAGO03; + _tmo_param_1 = 0; + _tmo_param_2 = 0; + _tmo_param_3 = 1; + _tmo_param_4 = 0; +} + +fipWinImage::~fipWinImage() { + if(_bDeleteMe) { + FreeImage_Unload(_display_dib); + } +} + +void fipWinImage::clear() { + // delete _display_dib + if(_bDeleteMe) { + FreeImage_Unload(_display_dib); + } + _display_dib = NULL; + _bDeleteMe = FALSE; + // delete base class data + fipImage::clear(); +} + +BOOL fipWinImage::isValid() const { + return fipImage::isValid(); +} + +/////////////////////////////////////////////////////////////////// +// Copying + +fipWinImage& fipWinImage::operator=(const fipImage& Image) { + // delete _display_dib + if(_bDeleteMe) { + FreeImage_Unload(_display_dib); + } + _display_dib = NULL; + _bDeleteMe = FALSE; + // clone the base class + fipImage::operator=(Image); + + return *this; +} + +fipWinImage& fipWinImage::operator=(const fipWinImage& Image) { + if(this != &Image) { + // delete _display_dib + if(_bDeleteMe) { + FreeImage_Unload(_display_dib); + } + _display_dib = NULL; + _bDeleteMe = FALSE; + // copy tmo data + _tmo = Image._tmo; + _tmo_param_1 = Image._tmo_param_1; + _tmo_param_2 = Image._tmo_param_2; + _tmo_param_3 = Image._tmo_param_3; + _tmo_param_4 = Image._tmo_param_4; + + // clone the base class + fipImage::operator=(Image); + } + return *this; +} + +HANDLE fipWinImage::copyToHandle() const { + HANDLE hMem = NULL; + + if(_dib) { + + // Get equivalent DIB size + long dib_size = sizeof(BITMAPINFOHEADER); + dib_size += FreeImage_GetColorsUsed(_dib) * sizeof(RGBQUAD); + dib_size += FreeImage_GetPitch(_dib) * FreeImage_GetHeight(_dib); + + // Allocate a DIB + hMem = GlobalAlloc(GHND, dib_size); + BYTE *dib = (BYTE*)GlobalLock(hMem); + + memset(dib, 0, dib_size); + + BYTE *p_dib = (BYTE*)dib; + + // Copy the BITMAPINFOHEADER + + BITMAPINFOHEADER *bih = FreeImage_GetInfoHeader(_dib); + memcpy(p_dib, bih, sizeof(BITMAPINFOHEADER)); + if(FreeImage_GetImageType(_dib) != FIT_BITMAP) { + // this hack is used to store the bitmap type in the biCompression member of the BITMAPINFOHEADER + SET_FREEIMAGE_MARKER((BITMAPINFOHEADER*)p_dib, _dib); + } + p_dib += sizeof(BITMAPINFOHEADER); + + // Copy the palette + + RGBQUAD *pal = FreeImage_GetPalette(_dib); + memcpy(p_dib, pal, FreeImage_GetColorsUsed(_dib) * sizeof(RGBQUAD)); + p_dib += FreeImage_GetColorsUsed(_dib) * sizeof(RGBQUAD); + + // Copy the bitmap + + BYTE *bits = FreeImage_GetBits(_dib); + memcpy(p_dib, bits, FreeImage_GetPitch(_dib) * FreeImage_GetHeight(_dib)); + + GlobalUnlock(hMem); + } + + return hMem; +} + +BOOL fipWinImage::copyFromHandle(HANDLE hMem) { + BYTE *lpVoid = NULL; + BITMAPINFOHEADER *pHead = NULL; + RGBQUAD *pPalette = NULL; + BYTE *bits = NULL; + DWORD bitfields[3] = {0, 0, 0}; + + // Get a pointer to the bitmap + lpVoid = (BYTE *)GlobalLock(hMem); + + // Get a pointer to the bitmap header + pHead = (BITMAPINFOHEADER *)lpVoid; + + // Get a pointer to the palette + if(pHead->biBitCount < 16) + pPalette = (RGBQUAD *)(((BYTE *)pHead) + sizeof(BITMAPINFOHEADER)); + + // Get a pointer to the pixels + bits = ((BYTE*)pHead + sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * pHead->biClrUsed); + + if(pHead->biCompression == BI_BITFIELDS) { + // Take into account the color masks that specify the red, green, and blue components (16- and 32-bit) + unsigned mask_size = 3 * sizeof(DWORD); + memcpy(&bitfields[0], bits, mask_size); + bits += mask_size; + } + + if(lpVoid) { + + // Allocate a new FIBITMAP + + FREE_IMAGE_TYPE image_type = FIT_BITMAP; + // Use a hack to decide if the clipboard contains non standard bitmaps ... + switch(GET_FREEIMAGE_MARKER(pHead)) { + case FIT_UINT16: + case FIT_INT16: + case FIT_UINT32: + case FIT_INT32: + case FIT_FLOAT: + case FIT_DOUBLE: + case FIT_COMPLEX: + case FIT_RGB16: + case FIT_RGBA16: + case FIT_RGBF: + case FIT_RGBAF: + image_type = GET_FREEIMAGE_MARKER(pHead); + break; + } + if(!setSize(image_type, (WORD)pHead->biWidth, (WORD)pHead->biHeight, pHead->biBitCount, bitfields[2], bitfields[1], bitfields[0])) { + GlobalUnlock(lpVoid); + return FALSE; + } + + // Copy the bitmap header + memcpy(FreeImage_GetInfoHeader(_dib), pHead, sizeof(BITMAPINFOHEADER)); + + + // Copy the palette + memcpy(FreeImage_GetPalette(_dib), pPalette, pHead->biClrUsed * sizeof(RGBQUAD)); + + // Copy the bitmap + memcpy(FreeImage_GetBits(_dib), bits, FreeImage_GetPitch(_dib) * FreeImage_GetHeight(_dib)); + + GlobalUnlock(lpVoid); + + return TRUE; + } + + return FALSE; +} + +BOOL fipWinImage::copyFromBitmap(HBITMAP hbmp) { + if(hbmp) { + int Success; + BITMAP bm; + // Get informations about the bitmap + GetObject(hbmp, sizeof(BITMAP), (LPSTR) &bm); + // Create the image + setSize(FIT_BITMAP, (WORD)bm.bmWidth, (WORD)bm.bmHeight, (WORD)bm.bmBitsPixel); + + // The GetDIBits function clears the biClrUsed and biClrImportant BITMAPINFO members (dont't know why) + // So we save these infos below. This is needed for palettized images only. + int nColors = FreeImage_GetColorsUsed(_dib); + + // Create a device context for the bitmap + HDC dc = GetDC(NULL); + // Copy the pixels + Success = GetDIBits(dc, // handle to DC + hbmp, // handle to bitmap + 0, // first scan line to set + FreeImage_GetHeight(_dib), // number of scan lines to copy + FreeImage_GetBits(_dib), // array for bitmap bits + FreeImage_GetInfo(_dib), // bitmap data buffer + DIB_RGB_COLORS // RGB + ); + if(Success == 0) { + FreeImage_OutputMessageProc(FIF_UNKNOWN, "Error : GetDIBits failed"); + ReleaseDC(NULL, dc); + return FALSE; + } + ReleaseDC(NULL, dc); + + // restore BITMAPINFO members + + FreeImage_GetInfoHeader(_dib)->biClrUsed = nColors; + FreeImage_GetInfoHeader(_dib)->biClrImportant = nColors; + + return TRUE; + } + + return FALSE; +} + +BOOL fipWinImage::copyToClipboard(HWND hWndNewOwner) const { + HANDLE hDIB = copyToHandle(); + + if(OpenClipboard(hWndNewOwner)) { + if(EmptyClipboard()) { + if(SetClipboardData(CF_DIB, hDIB) == NULL) { + MessageBox(hWndNewOwner, "Unable to set Clipboard data", "FreeImage", MB_ICONERROR); + CloseClipboard(); + return FALSE; + } + } + } + CloseClipboard(); + + return TRUE; +} + +BOOL fipWinImage::pasteFromClipboard() { + if(!IsClipboardFormatAvailable(CF_DIB)) + return FALSE; + + if(OpenClipboard(NULL)) { + HANDLE hDIB = GetClipboardData(CF_DIB); + copyFromHandle(hDIB); + CloseClipboard(); + return TRUE; + } + CloseClipboard(); + + return FALSE; +} + +/////////////////////////////////////////////////////////////////// +// Screen capture + +BOOL fipWinImage::captureWindow(HWND hWndApplicationWindow, HWND hWndSelectedWindow) { + int xScreen, yScreen, xshift, yshift; + RECT r; + + // Get window size + GetWindowRect(hWndSelectedWindow, &r); + + // Check if the window is out of the screen or maximixed + xshift = 0; + yshift = 0; + xScreen = GetSystemMetrics(SM_CXSCREEN); + yScreen = GetSystemMetrics(SM_CYSCREEN); + if(r.right > xScreen) + r.right = xScreen; + if(r.bottom > yScreen) + r.bottom = yScreen; + if(r.left < 0) { + xshift = -r.left; + r.left = 0; + } + if(r.top < 0){ + yshift = -r.top; + r.top = 0; + } + + int width = r.right - r.left; + int height = r.bottom - r.top; + + if(width <= 0 || height <= 0) + return FALSE; + + // Hide the application window. + ShowWindow(hWndApplicationWindow, SW_HIDE); + // Bring the window at the top most level + SetWindowPos(hWndSelectedWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + // Give enough time to refresh the window + Sleep(500); + + // Prepare the DCs + HDC dstDC = GetDC(NULL); + HDC srcDC = GetWindowDC(hWndSelectedWindow); // full window (GetDC(hWndSelectedWindow) = clientarea) + HDC memDC = CreateCompatibleDC(dstDC); + + // Copy the screen to the bitmap + HBITMAP bm = CreateCompatibleBitmap(dstDC, width, height); + HBITMAP oldbm = (HBITMAP)SelectObject(memDC, bm); + BitBlt(memDC, 0, 0, width, height, srcDC, xshift, yshift, SRCCOPY); + + // Redraw the application window. + ShowWindow(hWndApplicationWindow, SW_SHOW); + + // Restore the position + SetWindowPos(hWndSelectedWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + SetWindowPos(hWndApplicationWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + + // Convert the HBITMAP to a FIBITMAP + copyFromBitmap(bm); + + // Free objects + DeleteObject(SelectObject(memDC, oldbm)); + DeleteDC(memDC); + + // Convert 32-bit images to 24-bit + if(getBitsPerPixel() == 32) { + convertTo24Bits(); + } + + return TRUE; +} + + +/////////////////////////////////////////////////////////////////// +// Painting operations + +void fipWinImage::drawEx(HDC hDC, RECT& rcDest, BOOL useFileBkg, RGBQUAD *appBkColor, FIBITMAP *bg) const { + // Convert to a standard bitmap if needed + if(_bHasChanged) { + if(_bDeleteMe) { + FreeImage_Unload(_display_dib); + _display_dib = NULL; + _bDeleteMe = FALSE; + } + + FREE_IMAGE_TYPE image_type = getImageType(); + if(image_type == FIT_BITMAP) { + BOOL bHasBackground = FreeImage_HasBackgroundColor(_dib); + BOOL bIsTransparent = FreeImage_IsTransparent(_dib); + + if(!bIsTransparent && (!bHasBackground || !useFileBkg)) { + // Copy pointer + _display_dib = _dib; + } + else { + // Create the transparent / alpha blended image + _display_dib = FreeImage_Composite(_dib, useFileBkg, appBkColor, bg); + if(_display_dib) { + // Remember to delete _display_dib + _bDeleteMe = TRUE; + } else { + // Something failed: copy pointers + _display_dib = _dib; + } + } + } else { + // Convert to a standard dib for display + + if(image_type == FIT_COMPLEX) { + // Convert to type FIT_DOUBLE + FIBITMAP *dib_double = FreeImage_GetComplexChannel(_dib, FICC_MAG); + // Convert to a standard bitmap (linear scaling) + _display_dib = FreeImage_ConvertToStandardType(dib_double, TRUE); + // Free image of type FIT_DOUBLE + FreeImage_Unload(dib_double); + } else if((image_type == FIT_RGBF) || (image_type == FIT_RGBAF) || (image_type == FIT_RGB16)) { + // Apply a tone mapping algorithm and convert to 24-bit + switch(_tmo) { + case FITMO_REINHARD05: + _display_dib = FreeImage_TmoReinhard05Ex(_dib, _tmo_param_1, _tmo_param_2, _tmo_param_3, _tmo_param_4); + break; + default: + _display_dib = FreeImage_ToneMapping(_dib, _tmo, _tmo_param_1, _tmo_param_2); + break; + } + } else if(image_type == FIT_RGBA16) { + // Convert to 32-bit + FIBITMAP *dib32 = FreeImage_ConvertTo32Bits(_dib); + if(dib32) { + // Create the transparent / alpha blended image + _display_dib = FreeImage_Composite(dib32, useFileBkg, appBkColor, bg); + FreeImage_Unload(dib32); + } + } else { + // Other cases: convert to a standard bitmap (linear scaling) + _display_dib = FreeImage_ConvertToStandardType(_dib, TRUE); + } + // Remember to delete _display_dib + _bDeleteMe = TRUE; + } + + _bHasChanged = FALSE; + } + + // Draw the dib + SetStretchBltMode(hDC, COLORONCOLOR); + StretchDIBits(hDC, rcDest.left, rcDest.top, + rcDest.right-rcDest.left, rcDest.bottom-rcDest.top, + 0, 0, FreeImage_GetWidth(_display_dib), FreeImage_GetHeight(_display_dib), + FreeImage_GetBits(_display_dib), FreeImage_GetInfo(_display_dib), DIB_RGB_COLORS, SRCCOPY); + +} + +void fipWinImage::setToneMappingOperator(FREE_IMAGE_TMO tmo, double first_param, double second_param, double third_param, double fourth_param) { + // avoid costly operations if possible ... + if((_tmo != tmo) || (_tmo_param_1 != first_param) || (_tmo_param_2 != second_param) || (_tmo_param_3 != third_param) || (_tmo_param_4 != fourth_param)) { + _tmo = tmo; + _tmo_param_1 = first_param; + _tmo_param_2 = second_param; + _tmo_param_3 = third_param; + _tmo_param_4 = fourth_param; + + FREE_IMAGE_TYPE image_type = getImageType(); + switch(image_type) { + case FIT_RGBF: + case FIT_RGBAF: + case FIT_RGB16: + case FIT_RGBA16: + _bHasChanged = TRUE; + break; + default: + break; + } + } +} + +void fipWinImage::getToneMappingOperator(FREE_IMAGE_TMO *tmo, double *first_param, double *second_param, double *third_param, double *fourth_param) const { + *tmo = _tmo; + *first_param = _tmo_param_1; + *second_param = _tmo_param_2; + *third_param = _tmo_param_3; + *fourth_param = _tmo_param_4; +} + + +#endif // _WIN32 diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2005.sln b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2005.sln new file mode 100644 index 0000000..1a76773 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2005.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fipTest", "fipTest.2005.vcproj", "{39B399CB-50D7-43CF-9967-CBA4309C7034}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {39B399CB-50D7-43CF-9967-CBA4309C7034}.Debug|Win32.ActiveCfg = Debug|Win32 + {39B399CB-50D7-43CF-9967-CBA4309C7034}.Debug|Win32.Build.0 = Debug|Win32 + {39B399CB-50D7-43CF-9967-CBA4309C7034}.Release|Win32.ActiveCfg = Release|Win32 + {39B399CB-50D7-43CF-9967-CBA4309C7034}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2005.vcproj b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2005.vcproj new file mode 100644 index 0000000..d0ff7c1 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2005.vcproj @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2008.sln b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2008.sln new file mode 100644 index 0000000..cf7f9f6 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2008.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fipTest", "fipTest.2008.vcproj", "{66DCA866-A381-42D5-97FB-9792066C0F20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {66DCA866-A381-42D5-97FB-9792066C0F20}.Debug|Win32.ActiveCfg = Debug|Win32 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Debug|Win32.Build.0 = Debug|Win32 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Debug|x64.ActiveCfg = Debug|x64 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Debug|x64.Build.0 = Debug|x64 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Release|Win32.ActiveCfg = Release|Win32 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Release|Win32.Build.0 = Release|Win32 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Release|x64.ActiveCfg = Release|x64 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2008.vcproj b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2008.vcproj new file mode 100644 index 0000000..bbec75f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2008.vcproj @@ -0,0 +1,520 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2013.sln b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2013.sln new file mode 100644 index 0000000..a60d69a --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2013.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2013 for Windows Desktop +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fipTest", "fipTest.2013.vcxproj", "{66DCA866-A381-42D5-97FB-9792066C0F20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {66DCA866-A381-42D5-97FB-9792066C0F20}.Debug|Win32.ActiveCfg = Debug|Win32 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Debug|Win32.Build.0 = Debug|Win32 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Debug|x64.ActiveCfg = Debug|x64 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Debug|x64.Build.0 = Debug|x64 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Release|Win32.ActiveCfg = Release|Win32 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Release|Win32.Build.0 = Release|Win32 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Release|x64.ActiveCfg = Release|x64 + {66DCA866-A381-42D5-97FB-9792066C0F20}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2013.vcxproj b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2013.vcxproj new file mode 100644 index 0000000..0b9362d --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.2013.vcxproj @@ -0,0 +1,263 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + fipTest + {66DCA866-A381-42D5-97FB-9792066C0F20} + + + + Application + v120 + false + MultiByte + + + Application + v120 + false + MultiByte + + + Application + v120 + false + MultiByte + + + Application + v120 + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>12.0.21005.1 + + + .\$(Platform)\$(Configuration)\ + .\$(Platform)\$(Configuration)\ + true + + + .\$(Platform)\$(Configuration)\ + .\$(Platform)\$(Configuration)\ + false + + + .\$(Platform)\$(Configuration)\ + .\$(Platform)\$(Configuration)\ + true + + + .\$(Platform)\$(Configuration)\ + .\$(Platform)\$(Configuration)\ + false + + + + .\Debug/fipTest.tlb + + + + Disabled + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + NotUsing + Level3 + true + EditAndContinue + ..\..\..\Dist\x32 + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + FreeImaged.lib;FreeImagePlusd.lib;%(AdditionalDependencies) + true + true + Console + false + + MachineX86 + ..\..\..\Dist\x32;..\dist\x32 + false + + + copy ..\..\..\Dist\x32\FreeImaged.dll .\$(Platform)\$(Configuration)\ +copy ..\dist\x32\FreeImagePlusd.dll .\$(Platform)\$(Configuration)\ + + + + + + + .\Release/fipTest.tlb + + + + MaxSpeed + OnlyExplicitInline + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + NotUsing + Level3 + true + ..\..\..\Dist\x32 + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + FreeImage.lib;FreeImagePlus.lib;%(AdditionalDependencies) + true + Console + false + + MachineX86 + ..\..\..\Dist\x32;..\dist\x32 + false + + + + + X64 + .\Debug/fipTest.tlb + + + + Disabled + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + NotUsing + Level3 + true + ProgramDatabase + ..\..\..\Dist\x64 + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + FreeImaged.lib;FreeImagePlusd.lib;%(AdditionalDependencies) + true + true + Console + false + + MachineX64 + ..\..\..\Dist\x64;..\dist\x64 + false + + + + + X64 + .\Release/fipTest.tlb + + + + MaxSpeed + OnlyExplicitInline + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + NotUsing + Level3 + true + ..\..\..\Dist\x64 + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + FreeImage.lib;FreeImagePlus.lib;%(AdditionalDependencies) + true + Console + false + + MachineX64 + ..\..\..\Dist\x64;..\dist\x64 + false + + + + + Disabled + EnableFastChecks + Disabled + EnableFastChecks + MaxSpeed + MaxSpeed + + + Disabled + EnableFastChecks + Disabled + EnableFastChecks + MaxSpeed + MaxSpeed + + + Disabled + EnableFastChecks + Disabled + EnableFastChecks + MaxSpeed + MaxSpeed + + + + + + + + + + + \ No newline at end of file diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.cpp new file mode 100644 index 0000000..0501c6f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.cpp @@ -0,0 +1,76 @@ +// ========================================================== +// FreeImagePlus Test Script +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + + +#include "fipTest.h" + +using namespace std; + +// ---------------------------------------------------------- + +/** + FreeImage error handler + @param fif Format / Plugin responsible for the error + @param message Error message +*/ +void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { + cout << "\n*** "; + if(fif != FIF_UNKNOWN) { + cout << FreeImage_GetFormatFromFIF(fif) << " Format\n"; + } + cout << message; + cout << " ***\n"; +} + +// ---------------------------------------------------------- + +int main(int argc, char *argv[]) { + char *lpszTestFile = "test.jpg"; + char *lpszMultiPage = "test.tif"; + +#if defined(FREEIMAGE_LIB) || !defined(WIN32) + FreeImage_Initialise(); +#endif + + // initialize our own FreeImage error handler + + FreeImage_SetOutputMessage(FreeImageErrorHandler); + + // test memory IO + testMemIO(lpszTestFile); + + // test multipage IO + testMultiPage(lpszMultiPage); + + // test multipage memory IO + testMultiPageMemory(lpszMultiPage); + + // test multipage stream IO + testStreamMultiPage(lpszMultiPage); + +#if defined(FREEIMAGE_LIB) || !defined(WIN32) + FreeImage_DeInitialise(); +#endif + + return 0; +} + + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.h b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.h new file mode 100644 index 0000000..3b8d1de --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTest.h @@ -0,0 +1,79 @@ +// ========================================================== +// FreeImagePlus Test Script +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +#ifndef TEST_FREEIMAGEPLUS_API_H +#define TEST_FREEIMAGEPLUS_API_H + +#include "../FreeImagePlus.h" +#include +#include +#include + +#include + +// -------------------------------------------------------------------------- +// Memory IO test scripts + +/// Test saving to a memory stream +void testSaveMemIO(const char *lpszPathName); +/// Test loading from a buffer attached to a memory stream +void testLoadMemIO(const char *lpszPathName); +/// Test extracting a memory buffer from a memory stream +void testAcquireMemIO(const char *lpszPathName); +/// Test Loading / Saving from / to a memory stream using fipImage +void testImageMemIO(const char *lpszPathName); +/// Test the above functions +void testMemIO(const char *lpszPathName); + +// -------------------------------------------------------------------------- +// Multipage test scripts + +/// Test multipage loading & saving +BOOL testCloneMultiPage(const char *input, const char *output, int output_flag); +/// Test the above functions +void testMultiPage(const char *lpszMultiPage); + +// -------------------------------------------------------------------------- +// Multipage memory IO test scripts + +/// test FreeImage_LoadMultiBitmapFromMemory +BOOL testLoadMultiBitmapFromMemory(const char *lpszPathName); +/// test FreeImage_SaveMultiBitmapToMemory +BOOL testSaveMultiBitmapToMemory(const char *input, const char *output, int output_flag); +/// test FreeImage_LoadMultiBitmapFromMemory & FreeImage_SaveMultiBitmapToMemory +BOOL testMemoryStreamMultiPageOpenSave(const char *lpszPathName, char *output, int input_flag, int output_flag); +/// Test the above functions +void testMultiPageMemory(const char *lpszPathName); + +// -------------------------------------------------------------------------- +// Multipage IO test scripts + +/// test multipage stream (opening) +BOOL testStreamMultiPageOpen(const char *input, int flags); +/// test multipage stream (save as) +BOOL testStreamMultiPageSave(const char *input, const char *output, int input_flag, int output_flag); +/// test multipage stream (open, modify, save as) +BOOL testStreamMultiPageOpenSave(const char *input, const char *output, int input_flag, int output_flag); +/// Test the above functions +void testStreamMultiPage(const char *lpszPathName); + + +#endif // TEST_FREEIMAGEPLUS_API_H diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMPage.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMPage.cpp new file mode 100644 index 0000000..ec2572f --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMPage.cpp @@ -0,0 +1,87 @@ +// ========================================================== +// FreeImagePlus Test Script +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + + +#include "fipTest.h" + +using namespace std; + +// -------------------------------------------------------------------------- +// Multipage test scripts + +BOOL testCloneMultiPage(const char *input, const char *output, int output_flag) { + BOOL bSuccess = FALSE; + BOOL bMemoryCache = TRUE; + + fipMultiPage src(bMemoryCache); + fipMultiPage dst(bMemoryCache); + + // You MUST declare this before using it. + // We will use the assignement operator, i.e. operator=() + fipImage image; + + // Open src file (read-only, use memory cache) + bSuccess = src.open(input, FALSE, TRUE); + assert(bSuccess); + + if(src.isValid()) { + // Open dst file (creation, use memory cache) + bSuccess = dst.open(output, TRUE, FALSE); + assert(bSuccess); + + // Get src page count + int count = src.getPageCount(); + + // Clone src to dst + for(int page = 0; page < count; page++) { + // Load the bitmap at position 'page' + image = src.lockPage(page); + if(image.isValid()) { + // add a new bitmap to dst + dst.appendPage(image); + // Unload the bitmap (do not apply any change to src) + src.unlockPage(image, FALSE); + } + } + + // Close src + bSuccess = src.close(0); + assert(bSuccess); + + // Save and close dst + bSuccess = dst.close(output_flag); + assert(bSuccess); + + return TRUE; + } + + return FALSE; +} + +// ---------------------------------------------------------- + +void testMultiPage(const char *lpszMultiPage) { + cout << "testMultiPage ...\n"; + + testCloneMultiPage(lpszMultiPage, "clone.tif", 0); +} + + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMPageMemory.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMPageMemory.cpp new file mode 100644 index 0000000..352c9ff --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMPageMemory.cpp @@ -0,0 +1,277 @@ +// ========================================================== +// FreeImagePlus Test Script +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + + +#include "fipTest.h" + +using namespace std; + +// -------------------------------------------------------------------------- + +static BOOL +loadBuffer(const char *lpszPathName, BYTE **buffer, DWORD *length) { + struct stat file_info; + int result; + + // get data associated with lpszPathName + result = stat(lpszPathName, &file_info); + assert(result == 0); + if(result == 0) { + // allocate a memory buffer and load temporary data + *buffer = (BYTE*)malloc(file_info.st_size * sizeof(BYTE)); + if(*buffer) { + FILE *stream = fopen(lpszPathName, "rb"); + if(stream) { + *length = (DWORD)fread(*buffer, sizeof(BYTE), file_info.st_size, stream); + fclose(stream); + + return TRUE; + } + } + } + + return FALSE; +} + +static BOOL +extractPagesFromMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO) { + BOOL bMemoryCache = TRUE; + + char filename[256]; + fipImage image; + + // open the multipage bitmap stream as read-only + fipMultiPage src(bMemoryCache); + + src.open(memIO); + + if(src.isValid()) { + // get the page count + int count = src.getPageCount(); + // extract all pages + for(int page = 0; page < count; page++) { + // load the bitmap at position 'page' + image = src.lockPage(page); + if(image.isValid()) { + // save the page + sprintf(filename, "page%d.%s", page, FreeImage_GetFormatFromFIF(fif)); + image.save(filename, 0); + // Unload the bitmap (do not apply any change to src) + src.unlockPage(image, FALSE); + } else { + // an error occured: free the multipage bitmap handle (fipMultiPage destructor) and return + src.close(0); + return FALSE; + } + } + } + // make sure to close the multipage bitmap handle on exit (fipMultiPage destructor or direct call to src.close(0)) + return src.close(0); +} + +BOOL testLoadMultiBitmapFromMemory(const char *lpszPathName) { + BOOL bSuccess = FALSE; + + BYTE *buffer = NULL; + DWORD buffer_size = 0; + + // load source stream as a buffer, i.e. + // allocate a memory buffer and load temporary data + bSuccess = loadBuffer(lpszPathName, &buffer, &buffer_size); + assert(bSuccess); + + if(bSuccess) { + // attach the binary data to a memory stream + fipMemoryIO memIO(buffer, buffer_size); + + // get the file type + FREE_IMAGE_FORMAT fif = memIO.getFileType(); + + // extract pages + bSuccess = extractPagesFromMemory(fif, memIO); + assert(bSuccess); + + // close the memory stream (memIO destructor) + } + + // user is responsible for freeing the data + free(buffer); + + return bSuccess; +} + +// -------------------------------------------------------------------------- + +BOOL testSaveMultiBitmapToMemory(const char *input, const char *output, int output_flag) { + BOOL bSuccess; + + BOOL bCreateNew = FALSE; + BOOL bReadOnly = TRUE; + BOOL bMemoryCache = TRUE; + + // Open src file (read-only, use memory cache) + fipMultiPage src(bMemoryCache); + src.open(input, bCreateNew, bReadOnly, 0); + + if(src.isValid()) { + // open and allocate a memory stream + fipMemoryIO memIO; + + // save the file to memory + FREE_IMAGE_FORMAT fif = fipImage::identifyFIF(output); + bSuccess = src.saveToMemory(fif, memIO, output_flag); + assert(bSuccess); + + // src is no longer needed: close and free src file + src.close(0); + + // get the buffer from the memory stream + BYTE *mem_buffer = NULL; + DWORD size_in_bytes = 0; + + bSuccess = memIO.acquire(&mem_buffer, &size_in_bytes); + assert(bSuccess); + + // save the buffer in a file stream + FILE *stream = fopen(output, "wb"); + if(stream) { + fwrite(mem_buffer, sizeof(BYTE), size_in_bytes, stream); + fclose(stream); + } + + // close and free the memory stream (memIO destructor) + + return TRUE; + } + + return FALSE; +} + +BOOL testMemoryStreamMultiPageOpenSave(const char *lpszPathName, char *output, int input_flag, int output_flag) { + BOOL bSuccess = FALSE; + + BYTE *buffer = NULL; + DWORD buffer_size = 0; + + // load source stream as a buffer, i.e. + // allocate a memory buffer and load temporary data + bSuccess = loadBuffer(lpszPathName, &buffer, &buffer_size); + assert(bSuccess); + + // attach the binary data to a memory stream + fipMemoryIO src_stream(buffer, buffer_size); + assert(src_stream.isValid()); + + // open the multipage bitmap stream + fipMultiPage src; + src.open(src_stream, input_flag); + + // apply some modifications (everything being stored to the cache) ... + + if(src.isValid()) { + fipImage image; + + // get the page count + int count = src.getPageCount(); + assert(count > 2); + + // Load the bitmap at position '2' + image = src.lockPage(2); + if(image.isValid()) { + image.invert(); + // Unload the bitmap (apply change to src, modifications are stored to the cache) + src.unlockPage(image, TRUE); + } + + // delete page 0 (modifications are stored to the cache) + src.deletePage(0); + + // insert a new page at position '0' (modifications are stored to the cache) + image.load("test.jpg"); + src.insertPage(0, image); + } + + // save the modification into the output stream ... + + if(src.isValid()) { + // open and allocate a memory stream + fipMemoryIO dst_stream; + assert(dst_stream.isValid()); + + // save the file to memory + FREE_IMAGE_FORMAT fif = fipImage::identifyFIF(output); + src.saveToMemory(fif, dst_stream, output_flag); + + // src is no longer needed + // close and free the memory stream + src_stream.close(); + // close and free src file (nothing is done, the cache is cleared) + src.close(0); + + // at this point, the input buffer is no longer needed + // !!! user is responsible for freeing the initial source buffer !!! + free(buffer); buffer = NULL; + + // get the dst buffer from the memory stream + BYTE *dst_buffer = NULL; + DWORD size_in_bytes = 0; + + dst_stream.acquire(&dst_buffer, &size_in_bytes); + + // save the buffer in a file stream + FILE *stream = fopen(output, "wb"); + if(stream) { + fwrite(dst_buffer, sizeof(BYTE), size_in_bytes, stream); + fclose(stream); + } + + // close and free the memory stream (destructor is called) + + return TRUE; + } + + if(buffer) { + free(buffer); + } + + return FALSE; +} + +// -------------------------------------------------------------------------- + +void testMultiPageMemory(const char *lpszPathName) { + BOOL bSuccess; + + cout << "testMultiPageMemory ...\n"; + + // test FreeImage_LoadMultiBitmapFromMemory + bSuccess = testLoadMultiBitmapFromMemory(lpszPathName); + assert(bSuccess); + + // test FreeImage_SaveMultiBitmapToMemory + bSuccess = testSaveMultiBitmapToMemory(lpszPathName, "mpage-mstream.tif", 0); + assert(bSuccess); + + // test FreeImage_LoadMultiBitmapFromMemory & FreeImage_SaveMultiBitmapToMemory + bSuccess = testMemoryStreamMultiPageOpenSave(lpszPathName, "mpage-mstream-redirect.tif", 0, 0); + assert(bSuccess); + +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMPageStream.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMPageStream.cpp new file mode 100644 index 0000000..c76c90c --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMPageStream.cpp @@ -0,0 +1,222 @@ +// ========================================================== +// FreeImagePlus Test Script +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + + +#include "fipTest.h" + +using namespace std; + +// -------------------------------------------------------------------------- + +static unsigned DLL_CALLCONV +myReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { + return fread(buffer, size, count, (FILE *)handle); +} + +static unsigned DLL_CALLCONV +myWriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { + return fwrite(buffer, size, count, (FILE *)handle); +} + +static int DLL_CALLCONV +mySeekProc(fi_handle handle, long offset, int origin) { + return fseek((FILE *)handle, offset, origin); +} + +static long DLL_CALLCONV +myTellProc(fi_handle handle) { + return ftell((FILE *)handle); +} + +BOOL testStreamMultiPageOpen(const char *input, int flags) { + // initialize your own IO functions + + FreeImageIO io; + + io.read_proc = myReadProc; + io.write_proc = myWriteProc; + io.seek_proc = mySeekProc; + io.tell_proc = myTellProc; + + BOOL bSuccess = FALSE; + + // Open src stream in read-only mode + FILE *file = fopen(input, "r+b"); + if (file != NULL) { + fipMultiPage src; + + // Open the multi-page file + src.open(&io, (fi_handle)file, flags); + + if(src.isValid()) { + // get the page count + int count = src.getPageCount(); + assert(count > 1); + + // delete page 0 (modifications are stored to the cache) + src.deletePage(0); + + // Close src file (nothing is done, the cache is cleared) + bSuccess = src.close(0); + assert(bSuccess); + } + + // Close the src stream + fclose(file); + + return bSuccess; + } + + return bSuccess; +} + +BOOL testStreamMultiPageSave(const char *input, const char *output, int input_flag, int output_flag) { + // initialize your own IO functions + + FreeImageIO io; + + io.read_proc = myReadProc; + io.write_proc = myWriteProc; + io.seek_proc = mySeekProc; + io.tell_proc = myTellProc; + + BOOL bCreateNew = FALSE; + BOOL bReadOnly = TRUE; + BOOL bMemoryCache = TRUE; + + // Open src file (read-only, use memory cache) + fipMultiPage src(bMemoryCache); + src.open(input, bCreateNew, bReadOnly, input_flag); + + if(src.isValid()) { + // Open dst stream in read/write mode + FILE *file = fopen(output, "w+b"); + if (file != NULL) { + // Save the multi-page file to the stream + FREE_IMAGE_FORMAT fif = fipImage::identifyFIF(output); + BOOL bSuccess = src.saveToHandle(fif, &io, (fi_handle)file, output_flag); + assert(bSuccess); + + // Close the dst stream + fclose(file); + + // Close src file (or let the destructor close it) + return src.close(0); + + return TRUE; + } + + // Close src file (or let the destructor close it) + src.close(0); + } + + return FALSE; +} + +BOOL testStreamMultiPageOpenSave(const char *input, const char *output, int input_flag, int output_flag) { + // initialize your own IO functions + + FreeImageIO io; + + io.read_proc = myReadProc; + io.write_proc = myWriteProc; + io.seek_proc = mySeekProc; + io.tell_proc = myTellProc; + + BOOL bSuccess = FALSE; + + // Open src stream in read-only mode + FILE *src_file = fopen(input, "r+b"); + assert(src_file); + if (src_file != NULL) { + fipMultiPage src; + // Open the multi-page file + src.open(&io, (fi_handle)src_file, input_flag); + + if(src.isValid()) { + fipImage image; + + // get the page count + int count = src.getPageCount(); + assert(count > 2); + + // Load the bitmap at position '2' + image = src.lockPage(2); + if(image.isValid()) { + image.invert(); + // Unload the bitmap (apply change to src, modifications are stored to the cache) + src.unlockPage(image, TRUE); + } + + // delete page 0 (modifications are stored to the cache) + src.deletePage(0); + + // insert a new page at position '0' (modifications are stored to the cache) + image.load("test.jpg"); + src.insertPage(0, image); + + // Open dst stream in read/write mode + FILE *dst_file = fopen(output, "w+b"); + assert(dst_file); + if (dst_file != NULL) { + // Save the multi-page file to the stream (modifications are applied) + FREE_IMAGE_FORMAT fif = fipImage::identifyFIF(output); + BOOL bSuccess = src.saveToHandle(fif, &io, (fi_handle)dst_file, output_flag); + assert(bSuccess); + + // Close the dst stream + fclose(dst_file); + } + + // Close src file (nothing is done, the cache is cleared) + bSuccess = src.close(0); + assert(bSuccess); + } + + // Close the src stream + fclose(src_file); + + return bSuccess; + } + + return FALSE; +} + +// -------------------------------------------------------------------------- + +void testStreamMultiPage(const char *lpszPathName) { + BOOL bSuccess; + + cout << "testStreamMultiPage ...\n"; + + // test multipage stream (opening) + bSuccess = testStreamMultiPageOpen(lpszPathName, 0); + assert(bSuccess); + + // test multipage stream (save as) + bSuccess = testStreamMultiPageSave(lpszPathName, "clone-stream.tif", 0, 0); + assert(bSuccess); + + // test multipage stream (open, modify, save as) + bSuccess = testStreamMultiPageOpenSave(lpszPathName, "redirect-stream.tif", 0, 0); + assert(bSuccess); + +} diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMemIO.cpp b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMemIO.cpp new file mode 100644 index 0000000..3be469c --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/fipTestMemIO.cpp @@ -0,0 +1,182 @@ +// ========================================================== +// FreeImagePlus Test Script +// +// Design and implementation by +// - Hervé Drolon (drolon@infonie.fr) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + + +#include "fipTest.h" + +using namespace std; + +// -------------------------------------------------------------------------- +// Memory IO test scripts + +/** +Test saving to a memory stream +*/ +void testSaveMemIO(const char *lpszPathName) { + BOOL bSuccess = FALSE; + + // load a regular file + FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(lpszPathName); + FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, 0); + + // open a memory handle + fipMemoryIO memIO; + + // save the file to memory + bSuccess = memIO.save(fif, dib, 0); + assert(bSuccess == TRUE); + + // at this point, memIO contains the entire PNG data in memory. + // the amount of space used by the memory is equal to file_size + long file_size = memIO.tell(); + assert(file_size != 0); + + // its easy load an image from memory as well + + // seek to the start of the memory stream + memIO.seek(0L, SEEK_SET); + + // get the file type + FREE_IMAGE_FORMAT mem_fif = memIO.getFileType(); + + // load an image from the memory handle + FIBITMAP *check = memIO.load(mem_fif, 0); + assert(check != NULL); + + // save as a regular file + bSuccess = FreeImage_Save(FIF_PNG, check, "dump.png", PNG_DEFAULT); + assert(bSuccess == TRUE); + + FreeImage_Unload(check); + FreeImage_Unload(dib); + + // The memIO object will be destroyed automatically +} + +/** +Test loading from a buffer attached to a memory stream +*/ +void testLoadMemIO(const char *lpszPathName) { + struct stat buf; + int result; + BOOL bSuccess = FALSE; + + // get data associated with lpszPathName + result = stat(lpszPathName, &buf); + if(result == 0) { + // allocate a memory buffer and load temporary data + BYTE *mem_buffer = (BYTE*)malloc(buf.st_size * sizeof(BYTE)); + if(mem_buffer) { + FILE *stream = fopen(lpszPathName, "rb"); + if(stream) { + fread(mem_buffer, sizeof(BYTE), buf.st_size, stream); + fclose(stream); + + // attach the binary data to a memory stream + fipMemoryIO memIO(mem_buffer, buf.st_size); + + // get the file type + FREE_IMAGE_FORMAT fif = memIO.getFileType(); + + // load an image from the memory stream + FIBITMAP *check = memIO.load(fif, PNG_DEFAULT); + assert(check != NULL); + + // save as a regular file + bSuccess = FreeImage_Save(FIF_PNG, check, "blob.png", PNG_DEFAULT); + assert(bSuccess == TRUE); + + // close the stream (memIO is destroyed) + } + + // user is responsible for freeing the data + free(mem_buffer); + } + } +} + +/** +Test extracting a memory buffer from a memory stream +*/ +void testAcquireMemIO(const char *lpszPathName) { + BOOL bSuccess = FALSE; + + // load a regular file + FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(lpszPathName); + FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, 0); + + // open and allocate a memory stream + fipMemoryIO memIO; + + // save the file to memory + bSuccess = memIO.save(FIF_PNG, dib, PNG_DEFAULT); + assert(bSuccess == TRUE); + + // get the buffer from the memory stream + BYTE *mem_buffer = NULL; + DWORD size_in_bytes = 0; + + bSuccess = memIO.acquire(&mem_buffer, &size_in_bytes); + assert(bSuccess == TRUE); + + // save the buffer in a file stream + FILE *stream = fopen("buffer.png", "wb"); + if(stream) { + fwrite(mem_buffer, sizeof(BYTE), size_in_bytes, stream); + fclose(stream); + } + + // close and free the memory stream (memIO is destroyed) +} + +/** +Test Loading / Saving from / to a memory stream using fipImage +*/ +void testImageMemIO(const char *lpszPathName) { + BOOL bSuccess = FALSE; + + fipMemoryIO memIO; + fipImage image; + + // load a regular file + bSuccess = image.load(lpszPathName); + assert(bSuccess == TRUE); + if(bSuccess) { + // save the file to a memory stream + bSuccess = image.saveToMemory(FIF_PNG, memIO, PNG_DEFAULT); + assert(bSuccess); + + // load the file from the memory stream + memIO.seek(0L, SEEK_SET); + bSuccess = image.loadFromMemory(memIO, 0); + assert(bSuccess); + } +} + +void testMemIO(const char *lpszPathName) { + cout << "testMemIO ...\n"; + + testSaveMemIO(lpszPathName); + testLoadMemIO(lpszPathName); + testAcquireMemIO(lpszPathName); + testImageMemIO(lpszPathName); +} + diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/test.jpg b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/test.jpg new file mode 100644 index 0000000..c9e425d Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/test.jpg differ diff --git a/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/test.tif b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/test.tif new file mode 100644 index 0000000..886a7c9 Binary files /dev/null and b/#ThirdParty/FreeImage/Wrapper/FreeImagePlus/test/test.tif differ diff --git a/#ThirdParty/FreeImage/Wrapper/VB6/mfreeimage/MFreeImage.bas b/#ThirdParty/FreeImage/Wrapper/VB6/mfreeimage/MFreeImage.bas new file mode 100644 index 0000000..4fd3bd4 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/VB6/mfreeimage/MFreeImage.bas @@ -0,0 +1,12352 @@ +Attribute VB_Name = "MFreeImage" +'// ========================================================== +'// Visual Basic Wrapper for FreeImage 3 +'// Original FreeImage 3 functions and VB compatible derived functions +'// Design and implementation by +'// - Carsten Klein (cklein05@users.sourceforge.net) +'// +'// Main reference : Curland, Matthew., Advanced Visual Basic 6, Addison Wesley, ISBN 0201707128, (c) 2000 +'// Steve McMahon, creator of the excellent site vbAccelerator at http://www.vbaccelerator.com/ +'// MSDN Knowlede Base +'// +'// This file is part of FreeImage 3 +'// +'// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +'// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +'// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +'// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +'// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +'// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +'// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +'// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +'// THIS DISCLAIMER. +'// +'// Use at your own risk! +'// ========================================================== + +'// ========================================================== +'// CVS +'// $Revision: 2.23 $ +'// $Date: 2014/08/08 06:53:12 $ +'// $Id: MFreeImage.bas,v 2.23 2014/08/08 06:53:12 cklein05 Exp $ +'// ========================================================== + + +Option Explicit + + +'-------------------------------------------------------------------------------- +' Win32 API function, structure and constant declarations +'-------------------------------------------------------------------------------- + +Private Const ERROR_SUCCESS As Long = 0 + +'KERNEL32 +Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" ( _ + ByRef Destination As Any, _ + ByRef Source As Any, _ + ByVal Length As Long) + +Private Declare Function lstrlen Lib "kernel32.dll" Alias "lstrlenA" ( _ + ByVal lpString As Long) As Long + + +'OLEAUT32 +Private Declare Function OleCreatePictureIndirect Lib "oleaut32.dll" ( _ + ByRef lpPictDesc As PictDesc, _ + ByRef riid As Guid, _ + ByVal fOwn As Long, _ + ByRef lplpvObj As IPicture) As Long + +Private Declare Function SafeArrayAllocDescriptor Lib "oleaut32.dll" ( _ + ByVal cDims As Long, _ + ByRef ppsaOut As Long) As Long + +Private Declare Function SafeArrayDestroyDescriptor Lib "oleaut32.dll" ( _ + ByVal psa As Long) As Long + +Private Declare Sub SafeArrayDestroyData Lib "oleaut32.dll" ( _ + ByVal psa As Long) + +Private Declare Function OleTranslateColor Lib "oleaut32.dll" ( _ + ByVal clr As OLE_COLOR, _ + ByVal hPal As Long, _ + ByRef lpcolorref As Long) As Long + +Private Const CLR_INVALID As Long = &HFFFF& + + +'SAFEARRAY +Private Const FADF_AUTO As Long = (&H1) +Private Const FADF_FIXEDSIZE As Long = (&H10) + +Private Type SAVEARRAY1D + cDims As Integer + fFeatures As Integer + cbElements As Long + cLocks As Long + pvData As Long + cElements As Long + lLbound As Long +End Type + +Private Type SAVEARRAY2D + cDims As Integer + fFeatures As Integer + cbElements As Long + cLocks As Long + pvData As Long + cElements1 As Long + lLbound1 As Long + cElements2 As Long + lLbound2 As Long +End Type + + +'MSVBVM60 +Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" ( _ + ByRef Ptr() As Any) As Long + + +'USER32 +Private Declare Function ReleaseDC Lib "user32.dll" ( _ + ByVal hWnd As Long, _ + ByVal hDC As Long) As Long + +Private Declare Function GetDC Lib "user32.dll" ( _ + ByVal hWnd As Long) As Long + +Private Declare Function GetDesktopWindow Lib "user32.dll" () As Long + +Private Declare Function GetDCEx Lib "user32.dll" ( _ + ByVal hWnd As Long, _ + ByVal hrgnclip As Long, _ + ByVal fdwOptions As Long) As Long + +Private Const DCX_WINDOW As Long = &H1& + +Private Declare Function GetWindowRect Lib "user32.dll" ( _ + ByVal hWnd As Long, _ + ByRef lpRect As RECT) As Long + +Private Declare Function GetClientRect Lib "user32.dll" ( _ + ByVal hWnd As Long, _ + ByRef lpRect As RECT) As Long + +Private Declare Function DestroyIcon Lib "user32.dll" ( _ + ByVal hIcon As Long) As Long + +Private Declare Function CreateIconIndirect Lib "user32.dll" ( _ + ByRef piconinfo As ICONINFO) As Long + +Private Type RECT + Left As Long + Top As Long + Right As Long + Bottom As Long +End Type + +Private Type Guid + Data1 As Long + Data2 As Integer + Data3 As Integer + Data4(0 To 7) As Byte +End Type + +Private Type PictDesc + cbSizeofStruct As Long + picType As Long + hImage As Long + xExt As Long + yExt As Long +End Type + +Private Type BITMAP_API + bmType As Long + bmWidth As Long + bmHeight As Long + bmWidthBytes As Long + bmPlanes As Integer + bmBitsPixel As Integer + bmBits As Long +End Type + +Private Type ICONINFO + fIcon As Long + xHotspot As Long + yHotspot As Long + hBmMask As Long + hbmColor As Long +End Type + +Private Type BLENDFUNCTION + BlendOp As Byte + BlendFlags As Byte + SourceConstantAlpha As Byte + AlphaFormat As Byte +End Type + + +'GDI32 +Private Declare Function GetDeviceCaps Lib "gdi32.dll" ( _ + ByVal hDC As Long, _ + ByVal nIndex As Long) As Long + +Private Const HORZRES As Long = 8 +Private Const VERTRES As Long = 10 + +Private Declare Function GetStretchBltMode Lib "gdi32.dll" ( _ + ByVal hDC As Long) As Long + +Private Declare Function SetStretchBltMode Lib "gdi32.dll" ( _ + ByVal hDC As Long, _ + ByVal nStretchMode As Long) As Long + +Private Declare Function SetDIBitsToDevice Lib "gdi32.dll" ( _ + ByVal hDC As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByVal dx As Long, _ + ByVal dy As Long, _ + ByVal SrcX As Long, _ + ByVal SrcY As Long, _ + ByVal Scan As Long, _ + ByVal NumScans As Long, _ + ByVal Bits As Long, _ + ByVal BitsInfo As Long, _ + ByVal wUsage As Long) As Long + +Private Declare Function StretchDIBits Lib "gdi32.dll" ( _ + ByVal hDC As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByVal dx As Long, _ + ByVal dy As Long, _ + ByVal SrcX As Long, _ + ByVal SrcY As Long, _ + ByVal wSrcWidth As Long, _ + ByVal wSrcHeight As Long, _ + ByVal lpBits As Long, _ + ByVal lpBitsInfo As Long, _ + ByVal wUsage As Long, _ + ByVal dwRop As Long) As Long + +Private Declare Function CreateDIBitmap Lib "gdi32.dll" ( _ + ByVal hDC As Long, _ + ByVal lpInfoHeader As Long, _ + ByVal dwUsage As Long, _ + ByVal lpInitBits As Long, _ + ByVal lpInitInfo As Long, _ + ByVal wUsage As Long) As Long + +Private Declare Function CreateDIBSection Lib "gdi32.dll" ( _ + ByVal hDC As Long, _ + ByVal pbmi As Long, _ + ByVal iUsage As Long, _ + ByRef ppvBits As Long, _ + ByVal hSection As Long, _ + ByVal dwOffset As Long) As Long + +Private Const CBM_INIT As Long = &H4 + +Private Declare Function CreateCompatibleBitmap Lib "gdi32.dll" ( _ + ByVal hDC As Long, _ + ByVal nWidth As Long, _ + ByVal nHeight As Long) As Long + +Private Declare Function CreateCompatibleDC Lib "gdi32.dll" ( _ + ByVal hDC As Long) As Long + +Private Declare Function DeleteDC Lib "gdi32.dll" ( _ + ByVal hDC As Long) As Long + +Private Declare Function BitBlt Lib "gdi32.dll" ( _ + ByVal hDestDC As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByVal nWidth As Long, _ + ByVal nHeight As Long, _ + ByVal hSrcDC As Long, _ + ByVal XSrc As Long, _ + ByVal YSrc As Long, _ + ByVal dwRop As Long) As Long + +Private Declare Function GetDIBits Lib "gdi32.dll" ( _ + ByVal aHDC As Long, _ + ByVal hBitmap As Long, _ + ByVal nStartScan As Long, _ + ByVal nNumScans As Long, _ + ByVal lpBits As Long, _ + ByVal lpBI As Long, _ + ByVal wUsage As Long) As Long + +Private Declare Function GetObjectAPI Lib "gdi32.dll" Alias "GetObjectA" ( _ + ByVal hObject As Long, _ + ByVal nCount As Long, _ + ByRef lpObject As Any) As Long + +Private Declare Function SelectObject Lib "gdi32.dll" ( _ + ByVal hDC As Long, _ + ByVal hObject As Long) As Long + +Private Declare Function DeleteObject Lib "gdi32.dll" ( _ + ByVal hObject As Long) As Long + +Private Declare Function GetCurrentObject Lib "gdi32.dll" ( _ + ByVal hDC As Long, _ + ByVal uObjectType As Long) As Long + +Private Const OBJ_BITMAP As Long = 7 + + +'MSIMG32 +Private Declare Function AlphaBlend Lib "msimg32.dll" ( _ + ByVal hdcDest As Long, _ + ByVal nXOriginDest As Long, _ + ByVal nYOriginDest As Long, _ + ByVal nWidthDest As Long, _ + ByVal nHeightDest As Long, _ + ByVal hdcSrc As Long, _ + ByVal nXOriginSrc As Long, _ + ByVal nYOriginSrc As Long, _ + ByVal nWidthSrc As Long, _ + ByVal nHeightSrc As Long, _ + ByVal lBlendFunction As Long) As Long + +Private Const AC_SRC_OVER = &H0 +Private Const AC_SRC_ALPHA = &H1 + +Private Const BLACKONWHITE As Long = 1 +Private Const WHITEONBLACK As Long = 2 +Private Const COLORONCOLOR As Long = 3 + +Public Enum STRETCH_MODE + SM_BLACKONWHITE = BLACKONWHITE + SM_WHITEONBLACK = WHITEONBLACK + SM_COLORONCOLOR = COLORONCOLOR +End Enum + +Private Const SRCAND As Long = &H8800C6 +Private Const SRCCOPY As Long = &HCC0020 +Private Const SRCERASE As Long = &H440328 +Private Const SRCINVERT As Long = &H660046 +Private Const SRCPAINT As Long = &HEE0086 +Private Const CAPTUREBLT As Long = &H40000000 + +Public Enum RASTER_OPERATOR + ROP_SRCAND = SRCAND + ROP_SRCCOPY = SRCCOPY + ROP_SRCERASE = SRCERASE + ROP_SRCINVERT = SRCINVERT + ROP_SRCPAINT = SRCPAINT +End Enum + +Private Const DIB_PAL_COLORS As Long = 1 +Private Const DIB_RGB_COLORS As Long = 0 + +Public Enum DRAW_MODE + DM_DRAW_DEFAULT = &H0 + DM_MIRROR_NONE = DM_DRAW_DEFAULT + DM_MIRROR_VERTICAL = &H1 + DM_MIRROR_HORIZONTAL = &H2 + DM_MIRROR_BOTH = DM_MIRROR_VERTICAL Or DM_MIRROR_HORIZONTAL +End Enum + +Public Enum HISTOGRAM_ORIENTATION + HOR_TOP_DOWN = &H0 + HOR_BOTTOM_UP = &H1 +End Enum + +'-------------------------------------------------------------------------------- +' FreeImage 3 types, constants and enumerations +'-------------------------------------------------------------------------------- + +'FREEIMAGE + +' Version information +Public Const FREEIMAGE_MAJOR_VERSION As Long = 3 +Public Const FREEIMAGE_MINOR_VERSION As Long = 16 +Public Const FREEIMAGE_RELEASE_SERIAL As Long = 0 + +' Memory stream pointer operation flags +Public Const SEEK_SET As Long = 0 +Public Const SEEK_CUR As Long = 1 +Public Const SEEK_END As Long = 2 + +' Indexes for byte arrays, masks and shifts for treating pixels as words +' These coincide with the order of RGBQUAD and RGBTRIPLE +' Little Endian (x86 / MS Windows, Linux) : BGR(A) order +Public Const FI_RGBA_RED As Long = 2 +Public Const FI_RGBA_GREEN As Long = 1 +Public Const FI_RGBA_BLUE As Long = 0 +Public Const FI_RGBA_ALPHA As Long = 3 +Public Const FI_RGBA_RED_MASK As Long = &HFF0000 +Public Const FI_RGBA_GREEN_MASK As Long = &HFF00 +Public Const FI_RGBA_BLUE_MASK As Long = &HFF +Public Const FI_RGBA_ALPHA_MASK As Long = &HFF000000 +Public Const FI_RGBA_RED_SHIFT As Long = 16 +Public Const FI_RGBA_GREEN_SHIFT As Long = 8 +Public Const FI_RGBA_BLUE_SHIFT As Long = 0 +Public Const FI_RGBA_ALPHA_SHIFT As Long = 24 + +' The 16 bit macros only include masks and shifts, since each color element is not byte aligned +Public Const FI16_555_RED_MASK As Long = &H7C00 +Public Const FI16_555_GREEN_MASK As Long = &H3E0 +Public Const FI16_555_BLUE_MASK As Long = &H1F +Public Const FI16_555_RED_SHIFT As Long = 10 +Public Const FI16_555_GREEN_SHIFT As Long = 5 +Public Const FI16_555_BLUE_SHIFT As Long = 0 +Public Const FI16_565_RED_MASK As Long = &HF800 +Public Const FI16_565_GREEN_MASK As Long = &H7E0 +Public Const FI16_565_BLUE_MASK As Long = &H1F +Public Const FI16_565_RED_SHIFT As Long = 11 +Public Const FI16_565_GREEN_SHIFT As Long = 5 +Public Const FI16_565_BLUE_SHIFT As Long = 0 + +' ICC profile support +Public Const FIICC_DEFAULT As Long = &H0 +Public Const FIICC_COLOR_IS_CMYK As Long = &H1 + +Private Const FREE_IMAGE_ICC_COLOR_MODEL_MASK As Long = &H1 +Public Enum FREE_IMAGE_ICC_COLOR_MODEL + FIICC_COLOR_MODEL_RGB = &H0 + FIICC_COLOR_MODEL_CMYK = &H1 +End Enum + +' Load / Save flag constants +Public Const FIF_LOAD_NOPIXELS = &H8000 ' load the image header only (not supported by all plugins) + +Public Const BMP_DEFAULT As Long = 0 +Public Const BMP_SAVE_RLE As Long = 1 +Public Const CUT_DEFAULT As Long = 0 +Public Const DDS_DEFAULT As Long = 0 +Public Const EXR_DEFAULT As Long = 0 ' save data as half with piz-based wavelet compression +Public Const EXR_FLOAT As Long = &H1 ' save data as float instead of as half (not recommended) +Public Const EXR_NONE As Long = &H2 ' save with no compression +Public Const EXR_ZIP As Long = &H4 ' save with zlib compression, in blocks of 16 scan lines +Public Const EXR_PIZ As Long = &H8 ' save with piz-based wavelet compression +Public Const EXR_PXR24 As Long = &H10 ' save with lossy 24-bit float compression +Public Const EXR_B44 As Long = &H20 ' save with lossy 44% float compression - goes to 22% when combined with EXR_LC +Public Const EXR_LC As Long = &H40 ' save images with one luminance and two chroma channels, rather than as RGB (lossy compression) +Public Const FAXG3_DEFAULT As Long = 0 +Public Const GIF_DEFAULT As Long = 0 +Public Const GIF_LOAD256 As Long = 1 ' Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color +Public Const GIF_PLAYBACK As Long = 2 ''Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading +Public Const HDR_DEFAULT As Long = 0 +Public Const ICO_DEFAULT As Long = 0 +Public Const ICO_MAKEALPHA As Long = 1 ' convert to 32bpp and create an alpha channel from the AND-mask when loading +Public Const IFF_DEFAULT As Long = 0 +Public Const J2K_DEFAULT As Long = 0 ' save with a 16:1 rate +Public Const JP2_DEFAULT As Long = 0 ' save with a 16:1 rate +Public Const JPEG_DEFAULT As Long = 0 ' loading (see JPEG_FAST); saving (see JPEG_QUALITYGOOD|JPEG_SUBSAMPLING_420) +Public Const JPEG_FAST As Long = &H1 ' load the file as fast as possible, sacrificing some quality +Public Const JPEG_ACCURATE As Long = &H2 ' load the file with the best quality, sacrificing some speed +Public Const JPEG_CMYK As Long = &H4 ' load separated CMYK "as is" (use 'OR' to combine with other flags) +Public Const JPEG_EXIFROTATE As Long = &H8 ' load and rotate according to Exif 'Orientation' tag if available +Public Const JPEG_GREYSCALE As Long = &H10 ' load and convert to a 8-bit greyscale image +Public Const JPEG_QUALITYSUPERB As Long = &H80 ' save with superb quality (100:1) +Public Const JPEG_QUALITYGOOD As Long = &H100 ' save with good quality (75:1) +Public Const JPEG_QUALITYNORMAL As Long = &H200 ' save with normal quality (50:1) +Public Const JPEG_QUALITYAVERAGE As Long = &H400 ' save with average quality (25:1) +Public Const JPEG_QUALITYBAD As Long = &H800 ' save with bad quality (10:1) +Public Const JPEG_PROGRESSIVE As Long = &H2000 ' save as a progressive-JPEG (use 'OR' to combine with other save flags) +Public Const JPEG_SUBSAMPLING_411 As Long = &H1000 ' save with high 4x1 chroma subsampling (4:1:1) +Public Const JPEG_SUBSAMPLING_420 As Long = &H4000 ' save with medium 2x2 medium chroma subsampling (4:2:0) - default value +Public Const JPEG_SUBSAMPLING_422 As Long = &H8000 ' save with low 2x1 chroma subsampling (4:2:2) +Public Const JPEG_SUBSAMPLING_444 As Long = &H10000 ' save with no chroma subsampling (4:4:4) +Public Const JPEG_OPTIMIZE As Long = &H20000 ' on saving, compute optimal Huffman coding tables (can reduce a few percent of file size) +Public Const JPEG_BASELINE As Long = &H40000 ' save basic JPEG, without metadata or any markers +Public Const KOALA_DEFAULT As Long = 0 +Public Const LBM_DEFAULT As Long = 0 +Public Const MNG_DEFAULT As Long = 0 +Public Const PCD_DEFAULT As Long = 0 +Public Const PCD_BASE As Long = 1 ' load the bitmap sized 768 x 512 +Public Const PCD_BASEDIV4 As Long = 2 ' load the bitmap sized 384 x 256 +Public Const PCD_BASEDIV16 As Long = 3 ' load the bitmap sized 192 x 128 +Public Const PCX_DEFAULT As Long = 0 +Public Const PFM_DEFAULT As Long = 0 +Public Const PICT_DEFAULT As Long = 0 +Public Const PNG_DEFAULT As Long = 0 +Public Const PNG_IGNOREGAMMA As Long = 1 ' avoid gamma correction +Public Const PNG_Z_BEST_SPEED As Long = &H1 ' save using ZLib level 1 compression flag (default value is 6) +Public Const PNG_Z_DEFAULT_COMPRESSION As Long = &H6 ' save using ZLib level 6 compression flag (default recommended value) +Public Const PNG_Z_BEST_COMPRESSION As Long = &H9 ' save using ZLib level 9 compression flag (default value is 6) +Public Const PNG_Z_NO_COMPRESSION As Long = &H100 ' save without ZLib compression +Public Const PNG_INTERLACED As Long = &H200 ' save using Adam7 interlacing (use | to combine with other save flags) +Public Const PNM_DEFAULT As Long = 0 +Public Const PNM_SAVE_RAW As Long = 0 ' if set, the writer saves in RAW format (i.e. P4, P5 or P6) +Public Const PNM_SAVE_ASCII As Long = 1 ' if set, the writer saves in ASCII format (i.e. P1, P2 or P3) +Public Const PSD_DEFAULT As Long = 0 +Public Const PSD_CMYK As Long = 1 ' reads tags for separated CMYK (default is conversion to RGB) +Public Const PSD_LAB As Long = 2 ' reads tags for CIELab (default is conversion to RGB) +Public Const RAS_DEFAULT As Long = 0 +Public Const RAW_DEFAULT As Long = 0 ' load the file as linear RGB 48-bit +Public Const RAW_PREVIEW As Long = 1 ' try to load the embedded JPEG preview with included Exif Data or default to RGB 24-bit +Public Const RAW_DISPLAY As Long = 2 ' load the file as RGB 24-bit +Public Const RAW_HALFSIZE As Long = 4 ' load the file as half-size color image +Public Const RAW_UNPROCESSED As Long = 8 ' load the file as FIT_UINT16 raw Bayer image +Public Const SGI_DEFAULT As Long = 0 +Public Const TARGA_DEFAULT As Long = 0 +Public Const TARGA_LOAD_RGB888 As Long = 1 ' if set, the loader converts RGB555 and ARGB8888 -> RGB888 +Public Const TARGA_SAVE_RLE As Long = 2 ' if set, the writer saves with RLE compression +Public Const TIFF_DEFAULT As Long = 0 +Public Const TIFF_CMYK As Long = &H1 ' reads/stores tags for separated CMYK (use 'OR' to combine with compression flags) +Public Const TIFF_PACKBITS As Long = &H100 ' save using PACKBITS compression +Public Const TIFF_DEFLATE As Long = &H200 ' save using DEFLATE compression (a.k.a. ZLIB compression) +Public Const TIFF_ADOBE_DEFLATE As Long = &H400 ' save using ADOBE DEFLATE compression +Public Const TIFF_NONE As Long = &H800 ' save without any compression +Public Const TIFF_CCITTFAX3 As Long = &H1000 ' save using CCITT Group 3 fax encoding +Public Const TIFF_CCITTFAX4 As Long = &H2000 ' save using CCITT Group 4 fax encoding +Public Const TIFF_LZW As Long = &H4000 ' save using LZW compression +Public Const TIFF_JPEG As Long = &H8000 ' save using JPEG compression +Public Const TIFF_LOGLUV As Long = &H10000 ' save using LogLuv compression +Public Const WBMP_DEFAULT As Long = 0 +Public Const XBM_DEFAULT As Long = 0 +Public Const XPM_DEFAULT As Long = 0 +Public Const WEBP_DEFAULT As Long = 0 ' save with good quality (75:1) +Public Const WEBP_LOSSLESS As Long = &H100 ' save in lossless mode +Public Const JXR_DEFAULT As Long = 0 ' save with quality 80 and no chroma subsampling (4:4:4) +Public Const JXR_LOSSLESS As Long = &H64 ' save in lossless mode +Public Const JXR_PROGRESSIVE As Long = &H2000 ' save as a progressive-JXR (use Or to combine with other save flags) + +' I/O image format identifiers +Public Enum FREE_IMAGE_FORMAT + FIF_UNKNOWN = -1 + FIF_BMP = 0 + FIF_ICO = 1 + FIF_JPEG = 2 + FIF_JNG = 3 + FIF_KOALA = 4 + FIF_LBM = 5 + FIF_IFF = FIF_LBM + FIF_MNG = 6 + FIF_PBM = 7 + FIF_PBMRAW = 8 + FIF_PCD = 9 + FIF_PCX = 10 + FIF_PGM = 11 + FIF_PGMRAW = 12 + FIF_PNG = 13 + FIF_PPM = 14 + FIF_PPMRAW = 15 + FIF_RAS = 16 + FIF_TARGA = 17 + FIF_TIFF = 18 + FIF_WBMP = 19 + FIF_PSD = 20 + FIF_CUT = 21 + FIF_XBM = 22 + FIF_XPM = 23 + FIF_DDS = 24 + FIF_GIF = 25 + FIF_HDR = 26 + FIF_FAXG3 = 27 + FIF_SGI = 28 + FIF_EXR = 29 + FIF_J2K = 30 + FIF_JP2 = 31 + FIF_PFM = 32 + FIF_PICT = 33 + FIF_RAW = 34 + FIF_WEBP = 35 + FIF_JXR = 36 +End Enum + +' Image load options +Public Enum FREE_IMAGE_LOAD_OPTIONS + FILO_LOAD_NOPIXELS = FIF_LOAD_NOPIXELS ' load the image header only (not supported by all plugins) + FILO_LOAD_DEFAULT = 0 + FILO_GIF_DEFAULT = GIF_DEFAULT + FILO_GIF_LOAD256 = GIF_LOAD256 ' load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color + FILO_GIF_PLAYBACK = GIF_PLAYBACK ' 'play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading + FILO_ICO_DEFAULT = ICO_DEFAULT + FILO_ICO_MAKEALPHA = ICO_MAKEALPHA ' convert to 32bpp and create an alpha channel from the AND-mask when loading + FILO_JPEG_DEFAULT = JPEG_DEFAULT ' for loading this is a synonym for FILO_JPEG_FAST + FILO_JPEG_FAST = JPEG_FAST ' load the file as fast as possible, sacrificing some quality + FILO_JPEG_ACCURATE = JPEG_ACCURATE ' load the file with the best quality, sacrificing some speed + FILO_JPEG_CMYK = JPEG_CMYK ' load separated CMYK "as is" (use 'OR' to combine with other load flags) + FILO_JPEG_EXIFROTATE = JPEG_EXIFROTATE ' load and rotate according to Exif 'Orientation' tag if available + FILO_JPEG_GREYSCALE = JPEG_GREYSCALE ' load and convert to a 8-bit greyscale image + FILO_PCD_DEFAULT = PCD_DEFAULT + FILO_PCD_BASE = PCD_BASE ' load the bitmap sized 768 x 512 + FILO_PCD_BASEDIV4 = PCD_BASEDIV4 ' load the bitmap sized 384 x 256 + FILO_PCD_BASEDIV16 = PCD_BASEDIV16 ' load the bitmap sized 192 x 128 + FILO_PNG_DEFAULT = PNG_DEFAULT + FILO_PNG_IGNOREGAMMA = PNG_IGNOREGAMMA ' avoid gamma correction + FILO_PSD_CMYK = PSD_CMYK ' reads tags for separated CMYK (default is conversion to RGB) + FILO_PSD_LAB = PSD_LAB ' reads tags for CIELab (default is conversion to RGB) + FILO_RAW_DEFAULT = RAW_DEFAULT ' load the file as linear RGB 48-bit + FILO_RAW_PREVIEW = RAW_PREVIEW ' try to load the embedded JPEG preview with included Exif Data or default to RGB 24-bit + FILO_RAW_DISPLAY = RAW_DISPLAY ' load the file as RGB 24-bit + FILO_RAW_HALFSIZE = RAW_HALFSIZE ' load the file as half-size color image + FILO_RAW_UNPROCESSED = RAW_UNPROCESSED ' load the file as FIT_UINT16 raw Bayer image + FILO_TARGA_DEFAULT = TARGA_LOAD_RGB888 + FILO_TARGA_LOAD_RGB888 = TARGA_LOAD_RGB888 ' if set, the loader converts RGB555 and ARGB8888 -> RGB888 + FISO_TIFF_DEFAULT = TIFF_DEFAULT + FISO_TIFF_CMYK = TIFF_CMYK ' reads tags for separated CMYK +End Enum + +' Image save options +Public Enum FREE_IMAGE_SAVE_OPTIONS + FISO_SAVE_DEFAULT = 0 + FISO_BMP_DEFAULT = BMP_DEFAULT + FISO_BMP_SAVE_RLE = BMP_SAVE_RLE + FISO_EXR_DEFAULT = EXR_DEFAULT ' save data as half with piz-based wavelet compression + FISO_EXR_FLOAT = EXR_FLOAT ' save data as float instead of as half (not recommended) + FISO_EXR_NONE = EXR_NONE ' save with no compression + FISO_EXR_ZIP = EXR_ZIP ' save with zlib compression, in blocks of 16 scan lines + FISO_EXR_PIZ = EXR_PIZ ' save with piz-based wavelet compression + FISO_EXR_PXR24 = EXR_PXR24 ' save with lossy 24-bit float compression + FISO_EXR_B44 = EXR_B44 ' save with lossy 44% float compression - goes to 22% when combined with EXR_LC + FISO_EXR_LC = EXR_LC ' save images with one luminance and two chroma channels, rather than as RGB (lossy compression) + FISO_JPEG_DEFAULT = JPEG_DEFAULT ' for saving this is a synonym for FISO_JPEG_QUALITYGOOD + FISO_JPEG_QUALITYSUPERB = JPEG_QUALITYSUPERB ' save with superb quality (100:1) + FISO_JPEG_QUALITYGOOD = JPEG_QUALITYGOOD ' save with good quality (75:1) + FISO_JPEG_QUALITYNORMAL = JPEG_QUALITYNORMAL ' save with normal quality (50:1) + FISO_JPEG_QUALITYAVERAGE = JPEG_QUALITYAVERAGE ' save with average quality (25:1) + FISO_JPEG_QUALITYBAD = JPEG_QUALITYBAD ' save with bad quality (10:1) + FISO_JPEG_PROGRESSIVE = JPEG_PROGRESSIVE ' save as a progressive-JPEG (use 'OR' to combine with other save flags) + FISO_JPEG_SUBSAMPLING_411 = JPEG_SUBSAMPLING_411 ' save with high 4x1 chroma subsampling (4:1:1) + FISO_JPEG_SUBSAMPLING_420 = JPEG_SUBSAMPLING_420 ' save with medium 2x2 medium chroma subsampling (4:2:0) - default value + FISO_JPEG_SUBSAMPLING_422 = JPEG_SUBSAMPLING_422 ' save with low 2x1 chroma subsampling (4:2:2) + FISO_JPEG_SUBSAMPLING_444 = JPEG_SUBSAMPLING_444 ' save with no chroma subsampling (4:4:4) + FISO_JPEG_OPTIMIZE = JPEG_OPTIMIZE ' compute optimal Huffman coding tables (can reduce a few percent of file size) + FISO_JPEG_BASELINE = JPEG_BASELINE ' save basic JPEG, without metadata or any markers + FISO_PNG_Z_BEST_SPEED = PNG_Z_BEST_SPEED ' save using ZLib level 1 compression flag (default value is 6) + FISO_PNG_Z_DEFAULT_COMPRESSION = PNG_Z_DEFAULT_COMPRESSION ' save using ZLib level 6 compression flag (default recommended value) + FISO_PNG_Z_BEST_COMPRESSION = PNG_Z_BEST_COMPRESSION ' save using ZLib level 9 compression flag (default value is 6) + FISO_PNG_Z_NO_COMPRESSION = PNG_Z_NO_COMPRESSION ' save without ZLib compression + FISO_PNG_INTERLACED = PNG_INTERLACED ' save using Adam7 interlacing (use | to combine with other save flags) + FISO_PNM_DEFAULT = PNM_DEFAULT + FISO_PNM_SAVE_RAW = PNM_SAVE_RAW ' if set, the writer saves in RAW format (i.e. P4, P5 or P6) + FISO_PNM_SAVE_ASCII = PNM_SAVE_ASCII ' if set, the writer saves in ASCII format (i.e. P1, P2 or P3) + FISO_TARGA_SAVE_RLE = TARGA_SAVE_RLE ' if set, the writer saves with RLE compression + FISO_TIFF_DEFAULT = TIFF_DEFAULT + FISO_TIFF_CMYK = TIFF_CMYK ' stores tags for separated CMYK (use 'OR' to combine with compression flags) + FISO_TIFF_PACKBITS = TIFF_PACKBITS ' save using PACKBITS compression + FISO_TIFF_DEFLATE = TIFF_DEFLATE ' save using DEFLATE compression (a.k.a. ZLIB compression) + FISO_TIFF_ADOBE_DEFLATE = TIFF_ADOBE_DEFLATE ' save using ADOBE DEFLATE compression + FISO_TIFF_NONE = TIFF_NONE ' save without any compression + FISO_TIFF_CCITTFAX3 = TIFF_CCITTFAX3 ' save using CCITT Group 3 fax encoding + FISO_TIFF_CCITTFAX4 = TIFF_CCITTFAX4 ' save using CCITT Group 4 fax encoding + FISO_TIFF_LZW = TIFF_LZW ' save using LZW compression + FISO_TIFF_JPEG = TIFF_JPEG ' save using JPEG compression + FISO_TIFF_LOGLUV = TIFF_LOGLUV ' save using LogLuv compression + FISO_WEBP_LOSSLESS = WEBP_LOSSLESS ' save in lossless mode + FISO_JXR_LOSSLESS = JXR_LOSSLESS ' save in lossless mode + FISO_JXR_PROGRESSIVE = JXR_PROGRESSIVE ' save as a progressive-JXR (use Or to combine with other save flags) +End Enum + +' Image types used in FreeImage +Public Enum FREE_IMAGE_TYPE + FIT_UNKNOWN = 0 ' unknown type + FIT_BITMAP = 1 ' standard image : 1-, 4-, 8-, 16-, 24-, 32-bit + FIT_UINT16 = 2 ' array of unsigned short : unsigned 16-bit + FIT_INT16 = 3 ' array of short : signed 16-bit + FIT_UINT32 = 4 ' array of unsigned long : unsigned 32-bit + FIT_INT32 = 5 ' array of long : signed 32-bit + FIT_FLOAT = 6 ' array of float : 32-bit IEEE floating point + FIT_DOUBLE = 7 ' array of double : 64-bit IEEE floating point + FIT_COMPLEX = 8 ' array of FICOMPLEX : 2 x 64-bit IEEE floating point + FIT_RGB16 = 9 ' 48-bit RGB image : 3 x 16-bit + FIT_RGBA16 = 10 ' 64-bit RGBA image : 4 x 16-bit + FIT_RGBF = 11 ' 96-bit RGB float image : 3 x 32-bit IEEE floating point + FIT_RGBAF = 12 ' 128-bit RGBA float image : 4 x 32-bit IEEE floating point +End Enum + +' Image color types used in FreeImage +Public Enum FREE_IMAGE_COLOR_TYPE + FIC_MINISWHITE = 0 ' min value is white + FIC_MINISBLACK = 1 ' min value is black + FIC_RGB = 2 ' RGB color model + FIC_PALETTE = 3 ' color map indexed + FIC_RGBALPHA = 4 ' RGB color model with alpha channel + FIC_CMYK = 5 ' CMYK color model +End Enum + +' Color quantization algorithm constants +Public Enum FREE_IMAGE_QUANTIZE + FIQ_WUQUANT = 0 ' Xiaolin Wu color quantization algorithm + FIQ_NNQUANT = 1 ' NeuQuant neural-net quantization algorithm by Anthony Dekker +End Enum + +' Dithering algorithm constants +Public Enum FREE_IMAGE_DITHER + FID_FS = 0 ' Floyd & Steinberg error diffusion + FID_BAYER4x4 = 1 ' Bayer ordered dispersed dot dithering (order 2 dithering matrix) + FID_BAYER8x8 = 2 ' Bayer ordered dispersed dot dithering (order 3 dithering matrix) + FID_CLUSTER6x6 = 3 ' Ordered clustered dot dithering (order 3 - 6x6 matrix) + FID_CLUSTER8x8 = 4 ' Ordered clustered dot dithering (order 4 - 8x8 matrix) + FID_CLUSTER16x16 = 5 ' Ordered clustered dot dithering (order 8 - 16x16 matrix) + FID_BAYER16x16 = 6 ' Bayer ordered dispersed dot dithering (order 4 dithering matrix) +End Enum + +' Lossless JPEG transformation constants +Public Enum FREE_IMAGE_JPEG_OPERATION + FIJPEG_OP_NONE = 0 ' no transformation + FIJPEG_OP_FLIP_H = 1 ' horizontal flip + FIJPEG_OP_FLIP_V = 2 ' vertical flip + FIJPEG_OP_TRANSPOSE = 3 ' transpose across UL-to-LR axis + FIJPEG_OP_TRANSVERSE = 4 ' transpose across UR-to-LL axis + FIJPEG_OP_ROTATE_90 = 5 ' 90-degree clockwise rotation + FIJPEG_OP_ROTATE_180 = 6 ' 180-degree rotation + FIJPEG_OP_ROTATE_270 = 7 ' 270-degree clockwise (or 90 ccw) +End Enum + +' Tone mapping operator constants +Public Enum FREE_IMAGE_TMO + FITMO_DRAGO03 = 0 ' Adaptive logarithmic mapping (F. Drago, 2003) + FITMO_REINHARD05 = 1 ' Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005) + FITMO_FATTAL02 = 2 ' Gradient domain high dynamic range compression (R. Fattal, 2002) +End Enum + +' Up- / Downsampling filter constants +Public Enum FREE_IMAGE_FILTER + FILTER_BOX = 0 ' Box, pulse, Fourier window, 1st order (constant) b-spline + FILTER_BICUBIC = 1 ' Mitchell & Netravali's two-param cubic filter + FILTER_BILINEAR = 2 ' Bilinear filter + FILTER_BSPLINE = 3 ' 4th order (cubic) b-spline + FILTER_CATMULLROM = 4 ' Catmull-Rom spline, Overhauser spline + FILTER_LANCZOS3 = 5 ' Lanczos3 filter +End Enum + +' Color channel constants +Public Enum FREE_IMAGE_COLOR_CHANNEL + FICC_RGB = 0 ' Use red, green and blue channels + FICC_RED = 1 ' Use red channel + FICC_GREEN = 2 ' Use green channel + FICC_BLUE = 3 ' Use blue channel + FICC_ALPHA = 4 ' Use alpha channel + FICC_BLACK = 5 ' Use black channel + FICC_REAL = 6 ' Complex images: use real part + FICC_IMAG = 7 ' Complex images: use imaginary part + FICC_MAG = 8 ' Complex images: use magnitude + FICC_PHASE = 9 ' Complex images: use phase +End Enum + +' Tag data type information constants (based on TIFF specifications) +Public Enum FREE_IMAGE_MDTYPE + FIDT_NOTYPE = 0 ' placeholder + FIDT_BYTE = 1 ' 8-bit unsigned integer + FIDT_ASCII = 2 ' 8-bit bytes w/ last byte null + FIDT_SHORT = 3 ' 16-bit unsigned integer + FIDT_LONG = 4 ' 32-bit unsigned integer + FIDT_RATIONAL = 5 ' 64-bit unsigned fraction + FIDT_SBYTE = 6 ' 8-bit signed integer + FIDT_UNDEFINED = 7 ' 8-bit untyped data + FIDT_SSHORT = 8 ' 16-bit signed integer + FIDT_SLONG = 9 ' 32-bit signed integer + FIDT_SRATIONAL = 10 ' 64-bit signed fraction + FIDT_FLOAT = 11 ' 32-bit IEEE floating point + FIDT_DOUBLE = 12 ' 64-bit IEEE floating point + FIDT_IFD = 13 ' 32-bit unsigned integer (offset) + FIDT_PALETTE = 14 ' 32-bit RGBQUAD +End Enum + +' Metadata models supported by FreeImage +Public Enum FREE_IMAGE_MDMODEL + FIMD_NODATA = -1 ' + FIMD_COMMENTS = 0 ' single comment or keywords + FIMD_EXIF_MAIN = 1 ' Exif-TIFF metadata + FIMD_EXIF_EXIF = 2 ' Exif-specific metadata + FIMD_EXIF_GPS = 3 ' Exif GPS metadata + FIMD_EXIF_MAKERNOTE = 4 ' Exif maker note metadata + FIMD_EXIF_INTEROP = 5 ' Exif interoperability metadata + FIMD_IPTC = 6 ' IPTC/NAA metadata + FIMD_XMP = 7 ' Abobe XMP metadata + FIMD_GEOTIFF = 8 ' GeoTIFF metadata + FIMD_ANIMATION = 9 ' Animation metadata + FIMD_CUSTOM = 10 ' Used to attach other metadata types to a dib + FIMD_EXIF_RAW = 11 ' Exif metadata as a raw buffer +End Enum + +' These are the GIF_DISPOSAL metadata constants +Public Enum FREE_IMAGE_FRAME_DISPOSAL_METHODS + FIFD_GIF_DISPOSAL_UNSPECIFIED = 0 + FIFD_GIF_DISPOSAL_LEAVE = 1 + FIFD_GIF_DISPOSAL_BACKGROUND = 2 + FIFD_GIF_DISPOSAL_PREVIOUS = 3 +End Enum + +' Constants used in FreeImage_FillBackground and FreeImage_EnlargeCanvas +Public Enum FREE_IMAGE_COLOR_OPTIONS + FI_COLOR_IS_RGB_COLOR = &H0 ' RGBQUAD color is a RGB color (contains no valid alpha channel) + FI_COLOR_IS_RGBA_COLOR = &H1 ' RGBQUAD color is a RGBA color (contains a valid alpha channel) + FI_COLOR_FIND_EQUAL_COLOR = &H2 ' For palettized images: lookup equal RGB color from palette + FI_COLOR_ALPHA_IS_INDEX = &H4 ' The color's rgbReserved member (alpha) contains the palette index to be used +End Enum +Public Const FI_COLOR_PALETTE_SEARCH_MASK = _ + (FI_COLOR_FIND_EQUAL_COLOR Or FI_COLOR_ALPHA_IS_INDEX) ' Flag to test, if any color lookup is performed + +' The following enum constants are used by derived (wrapper) functions of the +' FreeImage 3 VB Wrapper +Public Enum FREE_IMAGE_CONVERSION_FLAGS + FICF_MONOCHROME = &H1 + FICF_MONOCHROME_THRESHOLD = FICF_MONOCHROME + FICF_MONOCHROME_DITHER = &H3 + FICF_GREYSCALE_4BPP = &H4 + FICF_PALLETISED_8BPP = &H8 + FICF_GREYSCALE_8BPP = FICF_PALLETISED_8BPP Or FICF_MONOCHROME + FICF_GREYSCALE = FICF_GREYSCALE_8BPP + FICF_RGB_15BPP = &HF + FICF_RGB_16BPP = &H10 + FICF_RGB_24BPP = &H18 + FICF_RGB_32BPP = &H20 + FICF_RGB_ALPHA = FICF_RGB_32BPP + FICF_KEEP_UNORDERED_GREYSCALE_PALETTE = &H0 + FICF_REORDER_GREYSCALE_PALETTE = &H1000 +End Enum + +Public Enum FREE_IMAGE_COLOR_DEPTH + FICD_AUTO = &H0 + FICD_MONOCHROME = &H1 + FICD_MONOCHROME_THRESHOLD = FICF_MONOCHROME + FICD_MONOCHROME_DITHER = &H3 + FICD_1BPP = FICD_MONOCHROME + FICD_4BPP = &H4 + FICD_8BPP = &H8 + FICD_15BPP = &HF + FICD_16BPP = &H10 + FICD_24BPP = &H18 + FICD_32BPP = &H20 +End Enum + +Public Enum FREE_IMAGE_ADJUST_MODE + AM_STRECH = &H1 + AM_DEFAULT = AM_STRECH + AM_ADJUST_BOTH = AM_STRECH + AM_ADJUST_WIDTH = &H2 + AM_ADJUST_HEIGHT = &H4 + AM_ADJUST_OPTIMAL_SIZE = &H8 +End Enum + +Public Enum FREE_IMAGE_MASK_FLAGS + FIMF_MASK_NONE = &H0 + FIMF_MASK_FULL_TRANSPARENCY = &H1 + FIMF_MASK_ALPHA_TRANSPARENCY = &H2 + FIMF_MASK_COLOR_TRANSPARENCY = &H4 + FIMF_MASK_FORCE_TRANSPARENCY = &H8 + FIMF_MASK_INVERSE_MASK = &H10 +End Enum + +Public Enum FREE_IMAGE_COLOR_FORMAT_FLAGS + FICFF_COLOR_RGB = &H1 + FICFF_COLOR_BGR = &H2 + FICFF_COLOR_PALETTE_INDEX = &H4 + + FICFF_COLOR_HAS_ALPHA = &H100 + + FICFF_COLOR_ARGB = FICFF_COLOR_RGB Or FICFF_COLOR_HAS_ALPHA + FICFF_COLOR_ABGR = FICFF_COLOR_BGR Or FICFF_COLOR_HAS_ALPHA + + FICFF_COLOR_FORMAT_ORDER_MASK = FICFF_COLOR_RGB Or FICFF_COLOR_BGR +End Enum + +Public Enum FREE_IMAGE_MASK_CREATION_OPTION_FLAGS + MCOF_CREATE_MASK_IMAGE = &H1 + MCOF_MODIFY_SOURCE_IMAGE = &H2 + MCOF_CREATE_AND_MODIFY = MCOF_CREATE_MASK_IMAGE Or MCOF_MODIFY_SOURCE_IMAGE +End Enum + +Public Enum FREE_IMAGE_TRANSPARENCY_STATE_FLAGS + FITSF_IGNORE_TRANSPARENCY = &H0 + FITSF_NONTRANSPARENT = &H1 + FITSF_TRANSPARENT = &H2 + FITSF_INCLUDE_ALPHA_TRANSPARENCY = &H4 +End Enum + +Public Enum FREE_IMAGE_ICON_TRANSPARENCY_OPTION_FLAGS + ITOF_NO_TRANSPARENCY = &H0 + ITOF_USE_TRANSPARENCY_INFO = &H1 + ITOF_USE_TRANSPARENCY_INFO_ONLY = ITOF_USE_TRANSPARENCY_INFO + ITOF_USE_COLOR_TRANSPARENCY = &H2 + ITOF_USE_COLOR_TRANSPARENCY_ONLY = ITOF_USE_COLOR_TRANSPARENCY + ITOF_USE_TRANSPARENCY_INFO_OR_COLOR = ITOF_USE_TRANSPARENCY_INFO Or ITOF_USE_COLOR_TRANSPARENCY + ITOF_USE_DEFAULT_TRANSPARENCY = ITOF_USE_TRANSPARENCY_INFO_OR_COLOR + ITOF_USE_COLOR_TOP_LEFT_PIXEL = &H0 + ITOF_USE_COLOR_FIRST_PIXEL = ITOF_USE_COLOR_TOP_LEFT_PIXEL + ITOF_USE_COLOR_TOP_RIGHT_PIXEL = &H20 + ITOF_USE_COLOR_BOTTOM_LEFT_PIXEL = &H40 + ITOF_USE_COLOR_BOTTOM_RIGHT_PIXEL = &H80 + ITOF_USE_COLOR_SPECIFIED = &H100 + ITOF_FORCE_TRANSPARENCY_INFO = &H400 +End Enum + +Private Const ITOF_USE_COLOR_BITMASK As Long = ITOF_USE_COLOR_TOP_RIGHT_PIXEL Or _ + ITOF_USE_COLOR_BOTTOM_LEFT_PIXEL Or _ + ITOF_USE_COLOR_BOTTOM_RIGHT_PIXEL Or _ + ITOF_USE_COLOR_SPECIFIED + +Public Type RGBQUAD + rgbBlue As Byte + rgbGreen As Byte + rgbRed As Byte + rgbReserved As Byte +End Type + +Public Type RGBTRIPLE + rgbtBlue As Byte + rgbtGreen As Byte + rgbtRed As Byte +End Type + +Public Type BITMAPINFOHEADER + biSize As Long + biWidth As Long + biHeight As Long + biPlanes As Integer + biBitCount As Integer + biCompression As Long + biSizeImage As Long + biXPelsPerMeter As Long + biYPelsPerMeter As Long + biClrUsed As Long + biClrImportant As Long +End Type + +Public Type BITMAPINFO + bmiHeader As BITMAPINFOHEADER + bmiColors(0) As RGBQUAD +End Type + +Public Const BI_RGB As Long = 0 +Public Const BI_RLE8 As Long = 1 +Public Const BI_RLE4 As Long = 2 +Public Const BI_BITFIELDS As Long = 3 +Public Const BI_JPEG As Long = 4 +Public Const BI_PNG As Long = 5 + +Public Type FIICCPROFILE + Flags As Integer ' info flag + Size As Long ' profile's size measured in bytes + Data As Long ' points to a block of contiguous memory containing the profile +End Type + +' 48-bit RGB +Public Type FIRGB16 + Red As Integer + Green As Integer + Blue As Integer +End Type + +' 64-bit RGBA +Public Type FIRGBA16 + Red As Integer + Green As Integer + Blue As Integer + Alpha As Integer +End Type + +' 96-bit RGB Float +Public Type FIRGBF + Red As Single + Green As Single + Blue As Single +End Type + +' 128-bit RGBA Float +Public Type FIRGBAF + Red As Single + Green As Single + Blue As Single + Alpha As Single +End Type + +' data structure for COMPLEX type (complex number) +Public Type FICOMPLEX + r As Double ' real part + i As Double ' imaginary part +End Type + +Public Type FITAG + Key As Long + Description As Long + Id As Integer + Type As Integer + Count As Long + Length As Long + Value As Long +End Type + +Public Type FIRATIONAL + Numerator As Variant + Denominator As Variant +End Type + +Public Type FREE_IMAGE_TAG + Model As FREE_IMAGE_MDMODEL + TagPtr As Long + Key As String + Description As String + Id As Long + Type As FREE_IMAGE_MDTYPE + Count As Long + Length As Long + StringValue As String + Palette() As RGBQUAD + RationalValue() As FIRATIONAL + Value As Variant +End Type + +Public Type FreeImageIO + read_proc As Long + write_proc As Long + seek_proc As Long + tell_proc As Long +End Type + +Public Type Plugin + format_proc As Long + description_proc As Long + extension_proc As Long + regexpr_proc As Long + open_proc As Long + close_proc As Long + pagecount_proc As Long + pagecapability_proc As Long + load_proc As Long + save_proc As Long + validate_proc As Long + mime_proc As Long + supports_export_bpp_proc As Long + supports_export_type_proc As Long + supports_icc_profiles_proc As Long +End Type + +' The following structures are used by derived (wrapper) functions of the +' FreeImage 3 VB Wrapper +Public Type ScanLineRGBTRIBLE + Data() As RGBTRIPLE +End Type + +Public Type ScanLinesRGBTRIBLE + Scanline() As ScanLineRGBTRIBLE +End Type + +'-------------------------------------------------------------------------------- +' FreeImage 3 function declarations +'-------------------------------------------------------------------------------- + +' The FreeImage 3 functions are declared in the same order as they are described +' in the FreeImage 3 API documentation (mostly). The documentation's outline is +' included as comments. + +' Initialization / Deinitialization functions +Public Declare Sub FreeImage_Initialise Lib "FreeImage.dll" Alias "_FreeImage_Initialise@4" ( _ + Optional ByVal LoadLocalPluginsOnly As Long) + +Public Declare Sub FreeImage_DeInitialise Lib "FreeImage.dll" Alias "_FreeImage_DeInitialise@0" () + + +' Version functions +Private Declare Function FreeImage_GetVersionInt Lib "FreeImage.dll" Alias "_FreeImage_GetVersion@0" () As Long + +Private Declare Function FreeImage_GetCopyrightMessageInt Lib "FreeImage.dll" Alias "_FreeImage_GetCopyrightMessage@0" () As Long + + +' Message output functions +Public Declare Sub FreeImage_SetOutputMessage Lib "FreeImage.dll" Alias "_FreeImage_SetOutputMessageStdCall@4" ( _ + ByVal omf As Long) + + +' Allocate / Clone / Unload functions +Public Declare Function FreeImage_Allocate Lib "FreeImage.dll" Alias "_FreeImage_Allocate@24" ( _ + ByVal Width As Long, _ + ByVal Height As Long, _ + ByVal BitsPerPixel As Long, _ + Optional ByVal RedMask As Long, _ + Optional ByVal GreenMask As Long, _ + Optional ByVal BlueMask As Long) As Long + +Public Declare Function FreeImage_AllocateT Lib "FreeImage.dll" Alias "_FreeImage_AllocateT@28" ( _ + ByVal ImageType As FREE_IMAGE_TYPE, _ + ByVal Width As Long, _ + ByVal Height As Long, _ + Optional ByVal BitsPerPixel As Long = 8, _ + Optional ByVal RedMask As Long, _ + Optional ByVal GreenMask As Long, _ + Optional ByVal BlueMask As Long) As Long + +Public Declare Function FreeImage_Clone Lib "FreeImage.dll" Alias "_FreeImage_Clone@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Sub FreeImage_Unload Lib "FreeImage.dll" Alias "_FreeImage_Unload@4" ( _ + ByVal Bitmap As Long) + + +' Header loading functions +Public Declare Function FreeImage_HasPixelsInt Lib "FreeImage.dll" Alias "_FreeImage_HasPixels@4" ( _ + ByVal Bitmap As Long) As Long + + +' Load / Save functions +Public Declare Function FreeImage_Load Lib "FreeImage.dll" Alias "_FreeImage_Load@12" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Filename As String, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS) As Long + +Private Declare Function FreeImage_LoadUInt Lib "FreeImage.dll" Alias "_FreeImage_LoadU@12" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Filename As Long, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS) As Long + +Public Declare Function FreeImage_LoadFromHandle Lib "FreeImage.dll" Alias "_FreeImage_LoadFromHandle@16" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal IO As Long, _ + ByVal Handle As Long, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS) As Long + +Private Declare Function FreeImage_SaveInt Lib "FreeImage.dll" Alias "_FreeImage_Save@16" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByVal Filename As String, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Long + +Private Declare Function FreeImage_SaveUInt Lib "FreeImage.dll" Alias "_FreeImage_SaveU@16" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByVal Filename As Long, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Long + +Private Declare Function FreeImage_SaveToHandleInt Lib "FreeImage.dll" Alias "_FreeImage_SaveToHandle@20" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByVal IO As Long, _ + ByVal Handle As Long, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Long + + +' Memory I/O stream functions +Public Declare Function FreeImage_OpenMemory Lib "FreeImage.dll" Alias "_FreeImage_OpenMemory@8" ( _ + Optional ByRef Data As Byte, _ + Optional ByVal SizeInBytes As Long) As Long + +Public Declare Function FreeImage_OpenMemoryByPtr Lib "FreeImage.dll" Alias "_FreeImage_OpenMemory@8" ( _ + Optional ByVal DataPtr As Long, _ + Optional ByVal SizeInBytes As Long) As Long + +Public Declare Sub FreeImage_CloseMemory Lib "FreeImage.dll" Alias "_FreeImage_CloseMemory@4" ( _ + ByVal Stream As Long) + +Public Declare Function FreeImage_LoadFromMemory Lib "FreeImage.dll" Alias "_FreeImage_LoadFromMemory@12" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Stream As Long, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS) As Long + +Private Declare Function FreeImage_SaveToMemoryInt Lib "FreeImage.dll" Alias "_FreeImage_SaveToMemory@16" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByVal Stream As Long, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Long + +Public Declare Function FreeImage_TellMemory Lib "FreeImage.dll" Alias "_FreeImage_TellMemory@4" ( _ + ByVal Stream As Long) As Long + +Private Declare Function FreeImage_SeekMemoryInt Lib "FreeImage.dll" Alias "_FreeImage_SeekMemory@12" ( _ + ByVal Stream As Long, _ + ByVal Offset As Long, _ + ByVal Origin As Long) As Long + +Private Declare Function FreeImage_AcquireMemoryInt Lib "FreeImage.dll" Alias "_FreeImage_AcquireMemory@12" ( _ + ByVal Stream As Long, _ + ByRef DataPtr As Long, _ + ByRef SizeInBytes As Long) As Long + +Public Declare Function FreeImage_ReadMemory Lib "FreeImage.dll" Alias "_FreeImage_ReadMemory@16" ( _ + ByVal BufferPtr As Long, _ + ByVal Size As Long, _ + ByVal Count As Long, _ + ByVal Stream As Long) As Long + +Public Declare Function FreeImage_WriteMemory Lib "FreeImage.dll" Alias "_FreeImage_WriteMemory@16" ( _ + ByVal BufferPtr As Long, _ + ByVal Size As Long, _ + ByVal Count As Long, _ + ByVal Stream As Long) As Long + +Public Declare Function FreeImage_LoadMultiBitmapFromMemory Lib "FreeImage.dll" Alias "_FreeImage_LoadMultiBitmapFromMemory@12" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Stream As Long, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS) As Long + +Public Declare Function FreeImage_SaveMultiBitmapToMemory Lib "FreeImage.dll" Alias "_FreeImage_SaveMultiBitmapToMemory@16" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByVal Stream As Long, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Long + + +' Plugin / Format functions +Public Declare Function FreeImage_RegisterLocalPlugin Lib "FreeImage.dll" Alias "_FreeImage_RegisterLocalPlugin@20" ( _ + ByVal InitProcAddress As Long, _ + Optional ByVal Format As String, _ + Optional ByVal Description As String, _ + Optional ByVal Extension As String, _ + Optional ByVal RegExpr As String) As FREE_IMAGE_FORMAT + +Public Declare Function FreeImage_RegisterExternalPlugin Lib "FreeImage.dll" Alias "_FreeImage_RegisterExternalPlugin@20" ( _ + ByVal Path As String, _ + Optional ByVal Format As String, _ + Optional ByVal Description As String, _ + Optional ByVal Extension As String, _ + Optional ByVal RegExpr As String) As FREE_IMAGE_FORMAT + +Public Declare Function FreeImage_GetFIFCount Lib "FreeImage.dll" Alias "_FreeImage_GetFIFCount@0" () As Long + +Public Declare Function FreeImage_SetPluginEnabled Lib "FreeImage.dll" Alias "_FreeImage_SetPluginEnabled@8" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Value As Long) As Long + +Public Declare Function FreeImage_IsPluginEnabled Lib "FreeImage.dll" Alias "_FreeImage_IsPluginEnabled@4" ( _ + ByVal Format As FREE_IMAGE_FORMAT) As Long + +Public Declare Function FreeImage_GetFIFFromFormat Lib "FreeImage.dll" Alias "_FreeImage_GetFIFFromFormat@4" ( _ + ByVal Format As String) As FREE_IMAGE_FORMAT + +Public Declare Function FreeImage_GetFIFFromMime Lib "FreeImage.dll" Alias "_FreeImage_GetFIFFromMime@4" ( _ + ByVal MimeType As String) As FREE_IMAGE_FORMAT + +Private Declare Function FreeImage_GetFormatFromFIFInt Lib "FreeImage.dll" Alias "_FreeImage_GetFormatFromFIF@4" ( _ + ByVal Format As FREE_IMAGE_FORMAT) As Long + +Private Declare Function FreeImage_GetFIFExtensionListInt Lib "FreeImage.dll" Alias "_FreeImage_GetFIFExtensionList@4" ( _ + ByVal Format As FREE_IMAGE_FORMAT) As Long + +Private Declare Function FreeImage_GetFIFDescriptionInt Lib "FreeImage.dll" Alias "_FreeImage_GetFIFDescription@4" ( _ + ByVal Format As FREE_IMAGE_FORMAT) As Long + +Private Declare Function FreeImage_GetFIFRegExprInt Lib "FreeImage.dll" Alias "_FreeImage_GetFIFRegExpr@4" ( _ + ByVal Format As FREE_IMAGE_FORMAT) As Long + +Private Declare Function FreeImage_GetFIFMimeTypeInt Lib "FreeImage.dll" Alias "_FreeImage_GetFIFMimeType@4" ( _ + ByVal Format As FREE_IMAGE_FORMAT) As Long + +Public Declare Function FreeImage_GetFIFFromFilename Lib "FreeImage.dll" Alias "_FreeImage_GetFIFFromFilename@4" ( _ + ByVal Filename As String) As FREE_IMAGE_FORMAT + +Private Declare Function FreeImage_GetFIFFromFilenameUInt Lib "FreeImage.dll" Alias "_FreeImage_GetFIFFromFilenameU@4" ( _ + ByVal Filename As Long) As FREE_IMAGE_FORMAT + +Private Declare Function FreeImage_FIFSupportsReadingInt Lib "FreeImage.dll" Alias "_FreeImage_FIFSupportsReading@4" ( _ + ByVal Format As FREE_IMAGE_FORMAT) As Long + +Private Declare Function FreeImage_FIFSupportsWritingInt Lib "FreeImage.dll" Alias "_FreeImage_FIFSupportsWriting@4" ( _ + ByVal Format As FREE_IMAGE_FORMAT) As Long + +Private Declare Function FreeImage_FIFSupportsExportBPPInt Lib "FreeImage.dll" Alias "_FreeImage_FIFSupportsExportBPP@8" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal BitsPerPixel As Long) As Long + +Private Declare Function FreeImage_FIFSupportsExportTypeInt Lib "FreeImage.dll" Alias "_FreeImage_FIFSupportsExportType@8" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal ImageType As FREE_IMAGE_TYPE) As Long + +Private Declare Function FreeImage_FIFSupportsICCProfilesInt Lib "FreeImage.dll" Alias "_FreeImage_FIFSupportsICCProfiles@4" ( _ + ByVal Format As FREE_IMAGE_FORMAT) As Long + +Private Declare Function FreeImage_FIFSupportsNoPixelsInt Lib "FreeImage.dll" Alias "_FreeImage_FIFSupportsNoPixels@4" ( _ + ByVal Format As FREE_IMAGE_FORMAT) As Long + + +' Multipaging functions +Private Declare Function FreeImage_OpenMultiBitmapInt Lib "FreeImage.dll" Alias "_FreeImage_OpenMultiBitmap@24" ( _ + ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Filename As String, _ + ByVal CreateNew As Long, _ + ByVal ReadOnly As Long, _ + ByVal KeepCacheInMemory As Long, _ + ByVal Flags As FREE_IMAGE_LOAD_OPTIONS) As Long + +Private Declare Function FreeImage_CloseMultiBitmapInt Lib "FreeImage.dll" Alias "_FreeImage_CloseMultiBitmap@8" ( _ + ByVal Bitmap As Long, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Long + +Public Declare Function FreeImage_GetPageCount Lib "FreeImage.dll" Alias "_FreeImage_GetPageCount@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Sub FreeImage_AppendPage Lib "FreeImage.dll" Alias "_FreeImage_AppendPage@8" ( _ + ByVal Bitmap As Long, _ + ByVal PageBitmap As Long) + +Public Declare Sub FreeImage_InsertPage Lib "FreeImage.dll" Alias "_FreeImage_InsertPage@12" ( _ + ByVal Bitmap As Long, _ + ByVal Page As Long, _ + ByVal PageBitmap As Long) + +Public Declare Sub FreeImage_DeletePage Lib "FreeImage.dll" Alias "_FreeImage_DeletePage@8" ( _ + ByVal Bitmap As Long, _ + ByVal Page As Long) + +Public Declare Function FreeImage_LockPage Lib "FreeImage.dll" Alias "_FreeImage_LockPage@8" ( _ + ByVal Bitmap As Long, _ + ByVal Page As Long) As Long + +Private Declare Sub FreeImage_UnlockPageInt Lib "FreeImage.dll" Alias "_FreeImage_UnlockPage@12" ( _ + ByVal Bitmap As Long, _ + ByVal PageBitmap As Long, _ + ByVal ApplyChanges As Long) + +Private Declare Function FreeImage_MovePageInt Lib "FreeImage.dll" Alias "_FreeImage_MovePage@12" ( _ + ByVal Bitmap As Long, _ + ByVal TargetPage As Long, _ + ByVal SourcePage As Long) As Long + +Private Declare Function FreeImage_GetLockedPageNumbersInt Lib "FreeImage.dll" Alias "_FreeImage_GetLockedPageNumbers@12" ( _ + ByVal Bitmap As Long, _ + ByRef PagesPtr As Long, _ + ByRef Count As Long) As Long + + +' Filetype request functions +Public Declare Function FreeImage_GetFileType Lib "FreeImage.dll" Alias "_FreeImage_GetFileType@8" ( _ + ByVal Filename As String, _ + Optional ByVal Size As Long) As FREE_IMAGE_FORMAT + +Private Declare Function FreeImage_GetFileTypeUInt Lib "FreeImage.dll" Alias "_FreeImage_GetFileTypeU@8" ( _ + ByVal Filename As Long, _ + Optional ByVal Size As Long) As FREE_IMAGE_FORMAT + +Public Declare Function FreeImage_GetFileTypeFromHandle Lib "FreeImage.dll" Alias "_FreeImage_GetFileTypeFromHandle@12" ( _ + ByVal IO As Long, _ + ByVal Handle As Long, _ + Optional ByVal Size As Long) As FREE_IMAGE_FORMAT + +Public Declare Function FreeImage_GetFileTypeFromMemory Lib "FreeImage.dll" Alias "_FreeImage_GetFileTypeFromMemory@8" ( _ + ByVal Stream As Long, _ + Optional ByVal Size As Long) As FREE_IMAGE_FORMAT + + +' Image type request functions +Public Declare Function FreeImage_GetImageType Lib "FreeImage.dll" Alias "_FreeImage_GetImageType@4" ( _ + ByVal Bitmap As Long) As FREE_IMAGE_TYPE + + +' FreeImage helper functions +Private Declare Function FreeImage_IsLittleEndianInt Lib "FreeImage.dll" Alias "_FreeImage_IsLittleEndian@0" () As Long + +Private Declare Function FreeImage_LookupX11ColorInt Lib "FreeImage.dll" Alias "_FreeImage_LookupX11Color@16" ( _ + ByVal Color As String, _ + ByRef Red As Long, _ + ByRef Green As Long, _ + ByRef Blue As Long) As Long + +Private Declare Function FreeImage_LookupSVGColorInt Lib "FreeImage.dll" Alias "_FreeImage_LookupSVGColor@16" ( _ + ByVal Color As String, _ + ByRef Red As Long, _ + ByRef Green As Long, _ + ByRef Blue As Long) As Long + + +' Pixel access functions +Public Declare Function FreeImage_GetBits Lib "FreeImage.dll" Alias "_FreeImage_GetBits@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetScanline Lib "FreeImage.dll" Alias "_FreeImage_GetScanLine@8" ( _ + ByVal Bitmap As Long, _ + ByVal Scanline As Long) As Long + +Private Declare Function FreeImage_GetPixelIndexInt Lib "FreeImage.dll" Alias "_FreeImage_GetPixelIndex@16" ( _ + ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As Byte) As Long + +Private Declare Function FreeImage_GetPixelColorInt Lib "FreeImage.dll" Alias "_FreeImage_GetPixelColor@16" ( _ + ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As RGBQUAD) As Long + +Private Declare Function FreeImage_GetPixelColorByLongInt Lib "FreeImage.dll" Alias "_FreeImage_GetPixelColor@16" ( _ + ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As Long) As Long + +Private Declare Function FreeImage_SetPixelIndexInt Lib "FreeImage.dll" Alias "_FreeImage_SetPixelIndex@16" ( _ + ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As Byte) As Long + +Private Declare Function FreeImage_SetPixelColorInt Lib "FreeImage.dll" Alias "_FreeImage_SetPixelColor@16" ( _ + ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As RGBQUAD) As Long + +Private Declare Function FreeImage_SetPixelColorByLongInt Lib "FreeImage.dll" Alias "_FreeImage_SetPixelColor@16" ( _ + ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As Long) As Long + + +' DIB info functions +Public Declare Function FreeImage_GetColorsUsed Lib "FreeImage.dll" Alias "_FreeImage_GetColorsUsed@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetBPP Lib "FreeImage.dll" Alias "_FreeImage_GetBPP@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetWidth Lib "FreeImage.dll" Alias "_FreeImage_GetWidth@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetHeight Lib "FreeImage.dll" Alias "_FreeImage_GetHeight@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetLine Lib "FreeImage.dll" Alias "_FreeImage_GetLine@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetPitch Lib "FreeImage.dll" Alias "_FreeImage_GetPitch@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetDIBSize Lib "FreeImage.dll" Alias "_FreeImage_GetDIBSize@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetPalette Lib "FreeImage.dll" Alias "_FreeImage_GetPalette@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetDotsPerMeterX Lib "FreeImage.dll" Alias "_FreeImage_GetDotsPerMeterX@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetDotsPerMeterY Lib "FreeImage.dll" Alias "_FreeImage_GetDotsPerMeterY@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Sub FreeImage_SetDotsPerMeterX Lib "FreeImage.dll" Alias "_FreeImage_SetDotsPerMeterX@8" ( _ + ByVal Bitmap As Long, _ + ByVal Resolution As Long) + +Public Declare Sub FreeImage_SetDotsPerMeterY Lib "FreeImage.dll" Alias "_FreeImage_SetDotsPerMeterY@8" ( _ + ByVal Bitmap As Long, _ + ByVal Resolution As Long) + +Public Declare Function FreeImage_GetInfoHeader Lib "FreeImage.dll" Alias "_FreeImage_GetInfoHeader@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetInfo Lib "FreeImage.dll" Alias "_FreeImage_GetInfo@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetColorType Lib "FreeImage.dll" Alias "_FreeImage_GetColorType@4" ( _ + ByVal Bitmap As Long) As FREE_IMAGE_COLOR_TYPE + +Private Declare Function FreeImage_HasRGBMasksInt Lib "FreeImage.dll" Alias "_FreeImage_HasRGBMasks@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetRedMask Lib "FreeImage.dll" Alias "_FreeImage_GetRedMask@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetGreenMask Lib "FreeImage.dll" Alias "_FreeImage_GetGreenMask@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetBlueMask Lib "FreeImage.dll" Alias "_FreeImage_GetBlueMask@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetTransparencyCount Lib "FreeImage.dll" Alias "_FreeImage_GetTransparencyCount@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_GetTransparencyTable Lib "FreeImage.dll" Alias "_FreeImage_GetTransparencyTable@4" ( _ + ByVal Bitmap As Long) As Long + +Private Declare Sub FreeImage_SetTransparentInt Lib "FreeImage.dll" Alias "_FreeImage_SetTransparent@8" ( _ + ByVal Bitmap As Long, _ + ByVal Value As Long) + +Public Declare Sub FreeImage_SetTransparencyTable Lib "FreeImage.dll" Alias "_FreeImage_SetTransparencyTable@12" ( _ + ByVal Bitmap As Long, _ + ByVal TransTablePtr As Long, _ + ByVal Count As Long) + +Private Declare Function FreeImage_IsTransparentInt Lib "FreeImage.dll" Alias "_FreeImage_IsTransparent@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_SetTransparentIndex Lib "FreeImage.dll" Alias "_FreeImage_SetTransparentIndex@8" ( _ + ByVal Bitmap As Long, _ + ByVal Index As Long) As Long + +Public Declare Function FreeImage_GetTransparentIndex Lib "FreeImage.dll" Alias "_FreeImage_GetTransparentIndex@4" ( _ + ByVal Bitmap As Long) As Long + +Private Declare Function FreeImage_HasBackgroundColorInt Lib "FreeImage.dll" Alias "_FreeImage_HasBackgroundColor@4" ( _ + ByVal Bitmap As Long) As Long + +Private Declare Function FreeImage_GetBackgroundColorInt Lib "FreeImage.dll" Alias "_FreeImage_GetBackgroundColor@8" ( _ + ByVal Bitmap As Long, _ + ByRef BackColor As RGBQUAD) As Long + +Private Declare Function FreeImage_GetBackgroundColorAsLongInt Lib "FreeImage.dll" Alias "_FreeImage_GetBackgroundColor@8" ( _ + ByVal Bitmap As Long, _ + ByRef BackColor As Long) As Long + +Private Declare Function FreeImage_SetBackgroundColorInt Lib "FreeImage.dll" Alias "_FreeImage_SetBackgroundColor@8" ( _ + ByVal Bitmap As Long, _ + ByRef BackColor As RGBQUAD) As Long + +Private Declare Function FreeImage_SetBackgroundColorAsLongInt Lib "FreeImage.dll" Alias "_FreeImage_SetBackgroundColor@8" ( _ + ByVal Bitmap As Long, _ + ByRef BackColor As Long) As Long + +Public Declare Function FreeImage_GetThumbnail Lib "FreeImage.dll" Alias "_FreeImage_GetThumbnail@4" ( _ + ByVal Bitmap As Long) As Long + +Private Declare Function FreeImage_SetThumbnailInt Lib "FreeImage.dll" Alias "_FreeImage_SetThumbnail@8" ( _ + ByVal Bitmap As Long, ByVal Thumbnail As Long) As Long + + +' ICC profile functions +Private Declare Function FreeImage_GetICCProfileInt Lib "FreeImage.dll" Alias "_FreeImage_GetICCProfile@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_CreateICCProfile Lib "FreeImage.dll" Alias "_FreeImage_CreateICCProfile@12" ( _ + ByVal Bitmap As Long, _ + ByRef Data As Long, _ + ByVal Size As Long) As Long + +Public Declare Sub FreeImage_DestroyICCProfile Lib "FreeImage.dll" Alias "_FreeImage_DestroyICCProfile@4" ( _ + ByVal Bitmap As Long) + + +' Line conversion functions +Public Declare Sub FreeImage_ConvertLine1To4 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine1To4@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine8To4 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine1To8@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine16To4_555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine16To4_555@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine16To4_565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine16To4_565@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine24To4 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine1To24@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine32To4 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine32To4@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine1To8 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine1To8@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine4To8 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine4To8@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine16To8_555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine16To8_555@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine16To8_565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine16To8_565@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine24To8 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine24To8@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine32To8 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine32To8@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine1To16_555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine1To16_555@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine4To16_555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine4To16_555@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine8To16_555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine8To16_555@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine16_565_To16_555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine16_565_To16_555@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine24To16_555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine24To16_555@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine32To16_555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine32To16_555@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine1To16_565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine1To16_565@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine4To16_565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine4To16_565@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine8To16_565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine8To16_565@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine16_555_To16_565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine16_555_To16_565@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine24To16_565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine24To16_565@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine32To16_565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine32To16_565@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine1To24 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine1To24@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine4To24 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine4To24@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine8To24 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine8To24@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine16To24_555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine16To24_555@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine16To24_565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine16To24_565@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine32To24 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine32To24@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine1To32 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine1To32@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine4To32 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine4To32@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine8To32 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine8To32@16" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long, _ + ByVal PalettePtr As Long) + +Public Declare Sub FreeImage_ConvertLine16To32_555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine16To32_555@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine16To32_565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine16To32_565@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + +Public Declare Sub FreeImage_ConvertLine24To32 Lib "FreeImage.dll" Alias "_FreeImage_ConvertLine24To32@12" ( _ + ByVal TargetPtr As Long, _ + ByVal SourcePtr As Long, _ + ByVal WidthInPixels As Long) + + +' Smart conversion functions +Public Declare Function FreeImage_ConvertTo4Bits Lib "FreeImage.dll" Alias "_FreeImage_ConvertTo4Bits@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_ConvertTo8Bits Lib "FreeImage.dll" Alias "_FreeImage_ConvertTo8Bits@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_ConvertToGreyscale Lib "FreeImage.dll" Alias "_FreeImage_ConvertToGreyscale@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_ConvertTo16Bits555 Lib "FreeImage.dll" Alias "_FreeImage_ConvertTo16Bits555@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_ConvertTo16Bits565 Lib "FreeImage.dll" Alias "_FreeImage_ConvertTo16Bits565@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_ConvertTo24Bits Lib "FreeImage.dll" Alias "_FreeImage_ConvertTo24Bits@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_ConvertTo32Bits Lib "FreeImage.dll" Alias "_FreeImage_ConvertTo32Bits@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_ColorQuantize Lib "FreeImage.dll" Alias "_FreeImage_ColorQuantize@8" ( _ + ByVal Bitmap As Long, _ + ByVal QuantizeMethod As FREE_IMAGE_QUANTIZE) As Long + +Private Declare Function FreeImage_ColorQuantizeExInt Lib "FreeImage.dll" Alias "_FreeImage_ColorQuantizeEx@20" ( _ + ByVal Bitmap As Long, _ + Optional ByVal QuantizeMethod As FREE_IMAGE_QUANTIZE = FIQ_WUQUANT, _ + Optional ByVal PaletteSize As Long = 256, _ + Optional ByVal ReserveSize As Long = 0, _ + Optional ByVal ReservePalettePtr As Long = 0) As Long + +Public Declare Function FreeImage_Threshold Lib "FreeImage.dll" Alias "_FreeImage_Threshold@8" ( _ + ByVal Bitmap As Long, _ + ByVal Threshold As Byte) As Long + +Public Declare Function FreeImage_Dither Lib "FreeImage.dll" Alias "_FreeImage_Dither@8" ( _ + ByVal Bitmap As Long, _ + ByVal DitherMethod As FREE_IMAGE_DITHER) As Long + +Private Declare Function FreeImage_ConvertFromRawBitsInt Lib "FreeImage.dll" Alias "_FreeImage_ConvertFromRawBits@36" ( _ + ByVal BitsPtr As Long, _ + ByVal Width As Long, _ + ByVal Height As Long, _ + ByVal Pitch As Long, _ + ByVal BitsPerPixel As Long, _ + ByVal RedMask As Long, _ + ByVal GreenMask As Long, _ + ByVal BlueMask As Long, _ + ByVal TopDown As Long) As Long + +Private Declare Function FreeImage_ConvertFromRawBitsExInt Lib "FreeImage.dll" Alias "_FreeImage_ConvertFromRawBitsEx@44" ( _ + ByVal CopySource As Long, _ + ByVal BitsPtr As Long, _ + ByVal ImageType As FREE_IMAGE_TYPE, _ + ByVal Width As Long, _ + ByVal Height As Long, _ + ByVal Pitch As Long, _ + ByVal BitsPerPixel As Long, _ + ByVal RedMask As Long, _ + ByVal GreenMask As Long, _ + ByVal BlueMask As Long, _ + ByVal TopDown As Long) As Long + +Private Declare Sub FreeImage_ConvertToRawBitsInt Lib "FreeImage.dll" Alias "_FreeImage_ConvertToRawBits@32" ( _ + ByVal BitsPtr As Long, _ + ByVal Bitmap As Long, _ + ByVal Pitch As Long, _ + ByVal BitsPerPixel As Long, _ + ByVal RedMask As Long, _ + ByVal GreenMask As Long, _ + ByVal BlueMask As Long, _ + ByVal TopDown As Long) + +Public Declare Function FreeImage_ConvertToFloat Lib "FreeImage.dll" Alias "_FreeImage_ConvertToFloat@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_ConvertToRGBF Lib "FreeImage.dll" Alias "_FreeImage_ConvertToRGBF@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_ConvertToUINT16 Lib "FreeImage.dll" Alias "_FreeImage_ConvertToUINT16@4" ( _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_ConvertToRGB16 Lib "FreeImage.dll" Alias "_FreeImage_ConvertToRGB16@4" ( _ + ByVal Bitmap As Long) As Long + +Private Declare Function FreeImage_ConvertToStandardTypeInt Lib "FreeImage.dll" Alias "_FreeImage_ConvertToStandardType@8" ( _ + ByVal Bitmap As Long, _ + ByVal ScaleLinear As Long) As Long + +Private Declare Function FreeImage_ConvertToTypeInt Lib "FreeImage.dll" Alias "_FreeImage_ConvertToType@12" ( _ + ByVal Bitmap As Long, _ + ByVal DestinationType As FREE_IMAGE_TYPE, _ + ByVal ScaleLinear As Long) As Long + + +' Tone mapping operators +Public Declare Function FreeImage_ToneMapping Lib "FreeImage.dll" Alias "_FreeImage_ToneMapping@24" ( _ + ByVal Bitmap As Long, _ + ByVal Operator As FREE_IMAGE_TMO, _ + Optional ByVal FirstArgument As Double, _ + Optional ByVal SecondArgument As Double) As Long + +Public Declare Function FreeImage_TmoDrago03 Lib "FreeImage.dll" Alias "_FreeImage_TmoDrago03@20" ( _ + ByVal Bitmap As Long, _ + Optional ByVal Gamma As Double = 2.2, _ + Optional ByVal Exposure As Double) As Long + +Public Declare Function FreeImage_TmoReinhard05 Lib "FreeImage.dll" Alias "_FreeImage_TmoReinhard05@20" ( _ + ByVal Bitmap As Long, _ + Optional ByVal Intensity As Double, _ + Optional ByVal Contrast As Double) As Long + +Public Declare Function FreeImage_TmoReinhard05Ex Lib "FreeImage.dll" Alias "_FreeImage_TmoReinhard05Ex@36" ( _ + ByVal Bitmap As Long, _ + Optional ByVal Intensity As Double, _ + Optional ByVal Contrast As Double, _ + Optional ByVal Adaptation As Double = 1, _ + Optional ByVal ColorCorrection As Double) As Long + +Public Declare Function FreeImage_TmoFattal02 Lib "FreeImage.dll" Alias "_FreeImage_TmoFattal02@20" ( _ + ByVal Bitmap As Long, _ + Optional ByVal ColorSaturation As Double = 0.5, _ + Optional ByVal Attenuation As Double = 0.85) As Long + + +' ZLib functions +Public Declare Function FreeImage_ZLibCompress Lib "FreeImage.dll" Alias "_FreeImage_ZLibCompress@16" ( _ + ByVal TargetPtr As Long, _ + ByVal TargetSize As Long, _ + ByVal SourcePtr As Long, _ + ByVal SourceSize As Long) As Long + +Public Declare Function FreeImage_ZLibUncompress Lib "FreeImage.dll" Alias "_FreeImage_ZLibUncompress@16" ( _ + ByVal TargetPtr As Long, _ + ByVal TargetSize As Long, _ + ByVal SourcePtr As Long, _ + ByVal SourceSize As Long) As Long + +Public Declare Function FreeImage_ZLibGZip Lib "FreeImage.dll" Alias "_FreeImage_ZLibGZip@16" ( _ + ByVal TargetPtr As Long, _ + ByVal TargetSize As Long, _ + ByVal SourcePtr As Long, _ + ByVal SourceSize As Long) As Long + +Public Declare Function FreeImage_ZLibGUnzip Lib "FreeImage.dll" Alias "_FreeImage_ZLibGUnzip@16" ( _ + ByVal TargetPtr As Long, _ + ByVal TargetSize As Long, _ + ByVal SourcePtr As Long, _ + ByVal SourceSize As Long) As Long + +Public Declare Function FreeImage_ZLibCRC32 Lib "FreeImage.dll" Alias "_FreeImage_ZLibCRC32@12" ( _ + ByVal CRC As Long, _ + ByVal SourcePtr As Long, _ + ByVal SourceSize As Long) As Long + + +'-------------------------------------------------------------------------------- +' Metadata functions +'-------------------------------------------------------------------------------- + +' tag creation / destruction +Private Declare Function FreeImage_CreateTag Lib "FreeImage.dll" Alias "_FreeImage_CreateTag@0" () As Long + +Private Declare Sub FreeImage_DeleteTag Lib "FreeImage.dll" Alias "_FreeImage_DeleteTag@4" ( _ + ByVal Tag As Long) + +Private Declare Function FreeImage_CloneTag Lib "FreeImage.dll" Alias "_FreeImage_CloneTag@4" ( _ + ByVal Tag As Long) As Long + + +' tag getters and setters (only those actually needed by wrapper functions) +Private Declare Function FreeImage_SetTagKey Lib "FreeImage.dll" Alias "_FreeImage_SetTagKey@8" ( _ + ByVal Tag As Long, _ + ByVal Key As String) As Long + +Private Declare Function FreeImage_SetTagValue Lib "FreeImage.dll" Alias "_FreeImage_SetTagValue@8" ( _ + ByVal Tag As Long, _ + ByVal ValuePtr As Long) As Long + + +' metadata iterators +Public Declare Function FreeImage_FindFirstMetadata Lib "FreeImage.dll" Alias "_FreeImage_FindFirstMetadata@12" ( _ + ByVal Model As FREE_IMAGE_MDMODEL, _ + ByVal Bitmap As Long, _ + ByRef Tag As Long) As Long + +Private Declare Function FreeImage_FindNextMetadataInt Lib "FreeImage.dll" Alias "_FreeImage_FindNextMetadata@8" ( _ + ByVal hFind As Long, _ + ByRef Tag As Long) As Long + +Public Declare Sub FreeImage_FindCloseMetadata Lib "FreeImage.dll" Alias "_FreeImage_FindCloseMetadata@4" ( _ + ByVal hFind As Long) + + +' metadata setters and getters +Private Declare Function FreeImage_SetMetadataInt Lib "FreeImage.dll" Alias "_FreeImage_SetMetadata@16" ( _ + ByVal Model As Long, _ + ByVal Bitmap As Long, _ + ByVal Key As String, _ + ByVal Tag As Long) As Long + +Private Declare Function FreeImage_GetMetadataInt Lib "FreeImage.dll" Alias "_FreeImage_GetMetadata@16" ( _ + ByVal Model As Long, _ + ByVal Bitmap As Long, _ + ByVal Key As String, _ + ByRef Tag As Long) As Long + +Private Declare Function FreeImage_SetMetadataKeyValueInt Lib "FreeImage.dll" Alias "_FreeImage_SetMetadataKeyValue@16" ( _ + ByVal Model As Long, _ + ByVal Bitmap As Long, _ + ByVal Key As String, _ + ByVal Tag As String) As Long + + +' metadata helper functions +Public Declare Function FreeImage_GetMetadataCount Lib "FreeImage.dll" Alias "_FreeImage_GetMetadataCount@8" ( _ + ByVal Model As Long, _ + ByVal Bitmap As Long) As Long + +Public Declare Function FreeImage_CloneMetadataInt Lib "FreeImage.dll" Alias "_FreeImage_CloneMetadata@8" ( _ + ByVal BitmapDst As Long, _ + ByVal BitmapSrc As Long) As Long + + +' tag to string conversion functions +Private Declare Function FreeImage_TagToStringInt Lib "FreeImage.dll" Alias "_FreeImage_TagToString@12" ( _ + ByVal Model As Long, _ + ByVal Tag As Long, _ + Optional ByVal Make As String = vbNullString) As Long + + +'-------------------------------------------------------------------------------- +' JPEG lossless transformation functions +'-------------------------------------------------------------------------------- + +Private Declare Function FreeImage_JPEGTransformInt Lib "FreeImage.dll" Alias "_FreeImage_JPEGTransform@16" ( _ + ByVal SourceFile As String, _ + ByVal DestFile As String, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + ByVal Perfect As Long) As Long + +Private Declare Function FreeImage_JPEGTransformUInt Lib "FreeImage.dll" Alias "_FreeImage_JPEGTransformU@16" ( _ + ByVal SourceFile As Long, _ + ByVal DestFile As Long, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + ByVal Perfect As Long) As Long + +Private Declare Function FreeImage_JPEGCropInt Lib "FreeImage.dll" Alias "_FreeImage_JPEGCrop@24" ( _ + ByVal SourceFile As String, _ + ByVal DestFile As String, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long) As Long + +Private Declare Function FreeImage_JPEGCropUInt Lib "FreeImage.dll" Alias "_FreeImage_JPEGCropU@24" ( _ + ByVal SourceFile As Long, _ + ByVal DestFile As Long, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long) As Long + +Private Declare Function FreeImage_JPEGTransformCombinedInt Lib "FreeImage.dll" Alias "_FreeImage_JPEGTransformCombined@32" ( _ + ByVal SourceFile As String, _ + ByVal DestFile As String, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + ByRef Left As Long, _ + ByRef Top As Long, _ + ByRef Right As Long, _ + ByRef Bottom As Long, _ + ByVal Perfect As Long) As Long + +Private Declare Function FreeImage_JPEGTransformCombinedUInt Lib "FreeImage.dll" Alias "_FreeImage_JPEGTransformCombinedU@32" ( _ + ByVal SourceFile As Long, _ + ByVal DestFile As Long, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + ByRef Left As Long, _ + ByRef Top As Long, _ + ByRef Right As Long, _ + ByRef Bottom As Long, _ + ByVal Perfect As Long) As Long + +Private Declare Function FreeImage_JPEGTransformCombinedFromMemoryInt Lib "FreeImage.dll" Alias "_FreeImage_JPEGTransformCombinedFromMemory@32" ( _ + ByVal SourceStream As Long, _ + ByVal DestStream As Long, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + ByRef Left As Long, _ + ByRef Top As Long, _ + ByRef Right As Long, _ + ByRef Bottom As Long, _ + ByVal Perfect As Long) As Long + + +'-------------------------------------------------------------------------------- +' Image manipulation toolkit functions +'-------------------------------------------------------------------------------- + +' rotation and flipping +Public Declare Function FreeImage_RotateClassic Lib "FreeImage.dll" Alias "_FreeImage_RotateClassic@12" ( _ + ByVal Bitmap As Long, _ + ByVal Angle As Double) As Long + +Public Declare Function FreeImage_Rotate Lib "FreeImage.dll" Alias "_FreeImage_Rotate@16" ( _ + ByVal Bitmap As Long, _ + ByVal Angle As Double, _ + Optional ByRef Color As Any = 0) As Long + +Private Declare Function FreeImage_RotateExInt Lib "FreeImage.dll" Alias "_FreeImage_RotateEx@48" ( _ + ByVal Bitmap As Long, _ + ByVal Angle As Double, _ + ByVal ShiftX As Double, _ + ByVal ShiftY As Double, _ + ByVal OriginX As Double, _ + ByVal OriginY As Double, _ + ByVal UseMask As Long) As Long + +Private Declare Function FreeImage_FlipHorizontalInt Lib "FreeImage.dll" Alias "_FreeImage_FlipHorizontal@4" ( _ + ByVal Bitmap As Long) As Long + +Private Declare Function FreeImage_FlipVerticalInt Lib "FreeImage.dll" Alias "_FreeImage_FlipVertical@4" ( _ + ByVal Bitmap As Long) As Long + + +' upsampling / downsampling +Public Declare Function FreeImage_Rescale Lib "FreeImage.dll" Alias "_FreeImage_Rescale@16" ( _ + ByVal Bitmap As Long, _ + ByVal Width As Long, _ + ByVal Height As Long, _ + ByVal Filter As FREE_IMAGE_FILTER) As Long + +Public Declare Function FreeImage_RescaleRect Lib "FreeImage.dll" Alias "_FreeImage_RescaleRect@32" ( _ + ByVal Bitmap As Long, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long, _ + ByVal Width As Long, _ + ByVal Height As Long, _ + ByVal Filter As FREE_IMAGE_FILTER) As Long + +Private Declare Function FreeImage_MakeThumbnailInt Lib "FreeImage.dll" Alias "_FreeImage_MakeThumbnail@12" ( _ + ByVal Bitmap As Long, _ + ByVal MaxPixelSize As Long, _ + Optional ByVal Convert As Long) As Long + + +' color manipulation functions (point operations) +Private Declare Function FreeImage_AdjustCurveInt Lib "FreeImage.dll" Alias "_FreeImage_AdjustCurve@12" ( _ + ByVal Bitmap As Long, _ + ByVal LookupTablePtr As Long, _ + ByVal Channel As FREE_IMAGE_COLOR_CHANNEL) As Long + +Private Declare Function FreeImage_AdjustGammaInt Lib "FreeImage.dll" Alias "_FreeImage_AdjustGamma@12" ( _ + ByVal Bitmap As Long, _ + ByVal Gamma As Double) As Long + +Private Declare Function FreeImage_AdjustBrightnessInt Lib "FreeImage.dll" Alias "_FreeImage_AdjustBrightness@12" ( _ + ByVal Bitmap As Long, _ + ByVal Percentage As Double) As Long + +Private Declare Function FreeImage_AdjustContrastInt Lib "FreeImage.dll" Alias "_FreeImage_AdjustContrast@12" ( _ + ByVal Bitmap As Long, _ + ByVal Percentage As Double) As Long + +Private Declare Function FreeImage_InvertInt Lib "FreeImage.dll" Alias "_FreeImage_Invert@4" ( _ + ByVal Bitmap As Long) As Long + +Private Declare Function FreeImage_GetHistogramInt Lib "FreeImage.dll" Alias "_FreeImage_GetHistogram@12" ( _ + ByVal Bitmap As Long, _ + ByRef HistogramPtr As Long, _ + Optional ByVal Channel As FREE_IMAGE_COLOR_CHANNEL = FICC_BLACK) As Long + +Private Declare Function FreeImage_GetAdjustColorsLookupTableInt Lib "FreeImage.dll" Alias "_FreeImage_GetAdjustColorsLookupTable@32" ( _ + ByVal LookupTablePtr As Long, _ + ByVal Brightness As Double, _ + ByVal Contrast As Double, _ + ByVal Gamma As Double, _ + ByVal Invert As Long) As Long + +Private Declare Function FreeImage_AdjustColorsInt Lib "FreeImage.dll" Alias "_FreeImage_AdjustColors@32" ( _ + ByVal Bitmap As Long, _ + ByVal Brightness As Double, _ + ByVal Contrast As Double, _ + ByVal Gamma As Double, _ + ByVal Invert As Long) As Long + +Private Declare Function FreeImage_ApplyColorMappingInt Lib "FreeImage.dll" Alias "_FreeImage_ApplyColorMapping@24" ( _ + ByVal Bitmap As Long, _ + ByVal SourceColorsPtr As Long, _ + ByVal DestinationColorsPtr As Long, _ + ByVal Count As Long, _ + ByVal IgnoreAlpha As Long, _ + ByVal Swap As Long) As Long + +Private Declare Function FreeImage_SwapColorsInt Lib "FreeImage.dll" Alias "_FreeImage_SwapColors@16" ( _ + ByVal Bitmap As Long, _ + ByRef ColorA As RGBQUAD, _ + ByRef ColorB As RGBQUAD, _ + ByVal IgnoreAlpha As Long) As Long + +Private Declare Function FreeImage_SwapColorsByLongInt Lib "FreeImage.dll" Alias "_FreeImage_SwapColors@16" ( _ + ByVal Bitmap As Long, _ + ByRef ColorA As Long, _ + ByRef ColorB As Long, _ + ByVal IgnoreAlpha As Long) As Long + +Private Declare Function FreeImage_ApplyPaletteIndexMappingInt Lib "FreeImage.dll" Alias "_FreeImage_ApplyPaletteIndexMapping@20" ( _ + ByVal Bitmap As Long, _ + ByVal SourceIndicesPtr As Long, _ + ByVal DestinationIndicesPtr As Long, _ + ByVal Count As Long, _ + ByVal Swap As Long) As Long + +Public Declare Function FreeImage_SwapPaletteIndices Lib "FreeImage.dll" Alias "_FreeImage_SwapPaletteIndices@12" ( _ + ByVal Bitmap As Long, _ + ByRef IndexA As Byte, _ + ByRef IndexB As Byte) As Long + +' channel processing functions +Public Declare Function FreeImage_GetChannel Lib "FreeImage.dll" Alias "_FreeImage_GetChannel@8" ( _ + ByVal Bitmap As Long, _ + ByVal Channel As FREE_IMAGE_COLOR_CHANNEL) As Long + +Private Declare Function FreeImage_SetChannelInt Lib "FreeImage.dll" Alias "_FreeImage_SetChannel@12" ( _ + ByVal BitmapDst As Long, _ + ByVal BitmapSrc As Long, _ + ByVal Channel As FREE_IMAGE_COLOR_CHANNEL) As Long + +Public Declare Function FreeImage_GetComplexChannel Lib "FreeImage.dll" Alias "_FreeImage_GetComplexChannel@8" ( _ + ByVal Bitmap As Long, _ + ByVal Channel As FREE_IMAGE_COLOR_CHANNEL) As Long + +Private Declare Function FreeImage_SetComplexChannelInt Lib "FreeImage.dll" Alias "_FreeImage_SetComplexChannel@12" ( _ + ByVal BitmapDst As Long, _ + ByVal BitmapSrc As Long, _ + ByVal Channel As FREE_IMAGE_COLOR_CHANNEL) As Long + + +' copy / paste / composite functions +Public Declare Function FreeImage_Copy Lib "FreeImage.dll" Alias "_FreeImage_Copy@20" ( _ + ByVal Bitmap As Long, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long) As Long + +Private Declare Function FreeImage_PasteInt Lib "FreeImage.dll" Alias "_FreeImage_Paste@20" ( _ + ByVal BitmapDst As Long, _ + ByVal BitmapSrc As Long, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Alpha As Long) As Long + +Public Declare Function FreeImage_Composite Lib "FreeImage.dll" Alias "_FreeImage_Composite@16" ( _ + ByVal Bitmap As Long, _ + Optional ByVal UseFileBackColor As Long, _ + Optional ByRef AppBackColor As Any, _ + Optional ByVal BackgroundBitmap As Long) As Long + +Private Declare Function FreeImage_PreMultiplyWithAlphaInt Lib "FreeImage.dll" Alias "_FreeImage_PreMultiplyWithAlpha@4" ( _ + ByVal Bitmap As Long) As Long + +' background filling functions +Public Declare Function FreeImage_FillBackground Lib "FreeImage.dll" Alias "_FreeImage_FillBackground@12" ( _ + ByVal Bitmap As Long, _ + ByRef Color As Any, _ + Optional ByVal Options As FREE_IMAGE_COLOR_OPTIONS = FI_COLOR_IS_RGB_COLOR) As Long + +Public Declare Function FreeImage_EnlargeCanvas Lib "FreeImage.dll" Alias "_FreeImage_EnlargeCanvas@28" ( _ + ByVal Bitmap As Long, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long, _ + ByRef Color As Any, _ + Optional ByVal Options As FREE_IMAGE_COLOR_OPTIONS = FI_COLOR_IS_RGB_COLOR) As Long + +Public Declare Function FreeImage_AllocateEx Lib "FreeImage.dll" Alias "_FreeImage_AllocateEx@36" ( _ + ByVal Width As Long, _ + ByVal Height As Long, _ + Optional ByVal BitsPerPixel As Long = 8, _ + Optional ByRef Color As Any, _ + Optional ByVal Options As FREE_IMAGE_COLOR_OPTIONS, _ + Optional ByVal PalettePtr As Long = 0, _ + Optional ByVal RedMask As Long = 0, _ + Optional ByVal GreenMask As Long = 0, _ + Optional ByVal BlueMask As Long = 0) As Long + +Public Declare Function FreeImage_AllocateExT Lib "FreeImage.dll" Alias "_FreeImage_AllocateExT@36" ( _ + ByVal ImageType As FREE_IMAGE_TYPE, _ + ByVal Width As Long, _ + ByVal Height As Long, _ + Optional ByVal BitsPerPixel As Long = 8, _ + Optional ByRef Color As Any, _ + Optional ByVal Options As FREE_IMAGE_COLOR_OPTIONS, _ + Optional ByVal PalettePtr As Long, _ + Optional ByVal RedMask As Long, _ + Optional ByVal GreenMask As Long, _ + Optional ByVal BlueMask As Long) As Long + +' miscellaneous algorithms +Public Declare Function FreeImage_MultigridPoissonSolver Lib "FreeImage.dll" Alias "_FreeImage_MultigridPoissonSolver@8" ( _ + ByVal LaplacianBitmap As Long, _ + Optional ByVal Cyles As Long = 3) As Long + + + +'-------------------------------------------------------------------------------- +' Initialization functions +'-------------------------------------------------------------------------------- + +Public Function FreeImage_IsAvailable(Optional ByRef Version As String) As Boolean + + On Error Resume Next + Version = FreeImage_GetVersion() + FreeImage_IsAvailable = (Err.Number = ERROR_SUCCESS) + On Error GoTo 0 + +End Function + + + +'-------------------------------------------------------------------------------- +' Error handling functions +'-------------------------------------------------------------------------------- + +Public Sub FreeImage_InitErrorHandler() + + ' Call this function once for using the FreeImage 3 error handling callback. + ' The 'FreeImage_ErrorHandler' function is called on each FreeImage 3 error. + + Call FreeImage_SetOutputMessage(AddressOf FreeImage_ErrorHandler) + +End Sub + +Private Sub FreeImage_ErrorHandler(ByVal Format As FREE_IMAGE_FORMAT, ByVal Message As Long) + +Dim strErrorMessage As String +Dim strImageFormat As String + + ' This function is called whenever the FreeImage 3 libraray throws an error. + ' Currently this function gets the error message and the format name of the + ' involved image type as VB string and prints both to the VB Debug console. Feel + ' free to modify this function to call an error handling routine of your own. + + strErrorMessage = pGetStringFromPointerA(Message) + strImageFormat = FreeImage_GetFormatFromFIF(Format) + + Debug.Print "[FreeImage] Error: " & strErrorMessage + Debug.Print " Image: " & strImageFormat + Debug.Print " Code: " & Format + +End Sub + + + +'-------------------------------------------------------------------------------- +' String returning functions wrappers +'-------------------------------------------------------------------------------- + +Public Function FreeImage_GetVersion() As String + + ' This function returns the version of the FreeImage 3 library + ' as VB String. + + FreeImage_GetVersion = pGetStringFromPointerA(FreeImage_GetVersionInt) + +End Function + +Public Function FreeImage_GetCopyrightMessage() As String + + ' This function returns the copyright message of the FreeImage 3 library + ' as VB String. + + FreeImage_GetCopyrightMessage = pGetStringFromPointerA(FreeImage_GetCopyrightMessageInt) + +End Function + +Public Function FreeImage_GetFormatFromFIF(ByVal Format As FREE_IMAGE_FORMAT) As String + + ' This function returns the result of the 'FreeImage_GetFormatFromFIF' function + ' as VB String. + + ' The parameter 'Format' works according to the FreeImage 3 API documentation. + + FreeImage_GetFormatFromFIF = pGetStringFromPointerA(FreeImage_GetFormatFromFIFInt(Format)) + +End Function + +Public Function FreeImage_GetFIFExtensionList(ByVal Format As FREE_IMAGE_FORMAT) As String + + ' This function returns the result of the 'FreeImage_GetFIFExtensionList' function + ' as VB String. + + ' The parameter 'Format' works according to the FreeImage 3 API documentation. + + FreeImage_GetFIFExtensionList = pGetStringFromPointerA(FreeImage_GetFIFExtensionListInt(Format)) + +End Function + +Public Function FreeImage_GetFIFDescription(ByVal Format As FREE_IMAGE_FORMAT) As String + + ' This function returns the result of the 'FreeImage_GetFIFDescription' function + ' as VB String. + + ' The parameter 'Format' works according to the FreeImage 3 API documentation. + + FreeImage_GetFIFDescription = pGetStringFromPointerA(FreeImage_GetFIFDescriptionInt(Format)) + +End Function + +Public Function FreeImage_GetFIFRegExpr(ByVal Format As FREE_IMAGE_FORMAT) As String + + ' This function returns the result of the 'FreeImage_GetFIFRegExpr' function + ' as VB String. + + ' The parameter 'Format' works according to the FreeImage 3 API documentation. + + FreeImage_GetFIFRegExpr = pGetStringFromPointerA(FreeImage_GetFIFRegExprInt(Format)) + +End Function + +Public Function FreeImage_GetFIFMimeType(ByVal Format As FREE_IMAGE_FORMAT) As String + + ' This function returns the result of the 'FreeImage_GetFIFMimeType' function + ' as VB String. + + ' The parameter 'Format' works according to the FreeImage 3 API documentation. + + FreeImage_GetFIFMimeType = pGetStringFromPointerA(FreeImage_GetFIFMimeTypeInt(Format)) + +End Function + +Public Function FreeImage_TagToString(ByVal Model As Long, _ + ByVal Tag As Long, _ + Optional ByVal Make As String) As String + + ' This function returns the result of the 'FreeImage_TagToString' function + ' as VB String. + + ' All parameters work according to the FreeImage 3 API documentation. + + FreeImage_TagToString = pGetStringFromPointerA(FreeImage_TagToStringInt(Model, Tag, Make)) + +End Function + + + +'-------------------------------------------------------------------------------- +' UNICODE dealing functions wrappers +'-------------------------------------------------------------------------------- + +Public Function FreeImage_LoadU(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Filename As String, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS) As Long + + ' This function is just a thin wrapper to ease the call to an + ' UNICODE function. Since VB's BSTR strings are actually UNICODE + ' strings, we just need to pass the pointer to the string data + ' returned by the (undocumented) function StrPtr(). + + FreeImage_LoadU = FreeImage_LoadUInt(Format, StrPtr(Filename), Flags) + +End Function + +Public Function FreeImage_SaveU(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByVal Filename As String, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Boolean + + ' This function is just a thin wrapper to ease the call to an + ' UNICODE function. Since VB's BSTR strings are actually UNICODE + ' strings, we just need to pass the pointer to the string data + ' returned by the (undocumented) function StrPtr(). + + FreeImage_SaveU = (FreeImage_SaveUInt(Format, Bitmap, StrPtr(Filename), Flags) = 1) + +End Function + +Public Function FreeImage_GetFileTypeU(ByVal Filename As String, _ + Optional ByVal Size As Long = 0) As FREE_IMAGE_FORMAT + + ' This function is just a thin wrapper to ease the call to an + ' UNICODE function. Since VB's BSTR strings are actually UNICODE + ' strings, we just need to pass the pointer to the string data + ' returned by the (undocumented) function StrPtr(). + + FreeImage_GetFileTypeU = FreeImage_GetFileTypeUInt(StrPtr(Filename), Size) + +End Function + +Public Function FreeImage_GetFIFFromFilenameU(ByVal Filename As String) As FREE_IMAGE_FORMAT + + ' This function is just a thin wrapper to ease the call to an + ' UNICODE function. Since VB's BSTR strings are actually UNICODE + ' strings, we just need to pass the pointer to the string data + ' returned by the (undocumented) function StrPtr(). + + FreeImage_GetFIFFromFilenameU = FreeImage_GetFIFFromFilenameUInt(StrPtr(Filename)) + +End Function + + + +'-------------------------------------------------------------------------------- +' Boolean returning functions wrappers +'-------------------------------------------------------------------------------- + +Public Function FreeImage_HasPixels(ByVal Bitmap As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_HasPixels = (FreeImage_HasPixelsInt(Bitmap) = 1) + +End Function + +Public Function FreeImage_HasRGBMasks(ByVal Bitmap As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_HasRGBMasks = (FreeImage_HasRGBMasksInt(Bitmap) = 1) + +End Function + + +Public Function FreeImage_Save(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByVal Filename As String, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_Save = (FreeImage_SaveInt(Format, Bitmap, Filename, Flags) = 1) + +End Function + +Public Function FreeImage_SaveToHandle(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByVal IO As Long, _ + ByVal Handle As Long, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SaveToHandle = (FreeImage_SaveToHandleInt(Format, Bitmap, IO, Handle, Flags) = 1) + +End Function + +Public Function FreeImage_IsTransparent(ByVal Bitmap As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_IsTransparent = (FreeImage_IsTransparentInt(Bitmap) = 1) + +End Function + +Public Sub FreeImage_SetTransparent(ByVal Bitmap As Long, ByVal Value As Boolean) + + If (Value) Then + Call FreeImage_SetTransparentInt(Bitmap, 1) + Else + Call FreeImage_SetTransparentInt(Bitmap, 0) + End If + +End Sub + +Public Function FreeImage_HasBackgroundColor(ByVal Bitmap As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_HasBackgroundColor = (FreeImage_HasBackgroundColorInt(Bitmap) = 1) + +End Function + +Public Function FreeImage_GetBackgroundColor(ByVal Bitmap As Long, _ + ByRef BackColor As RGBQUAD) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_GetBackgroundColor = (FreeImage_GetBackgroundColorInt(Bitmap, BackColor) = 1) + +End Function + +Public Function FreeImage_GetBackgroundColorAsLong(ByVal Bitmap As Long, _ + ByRef BackColor As Long) As Boolean + + ' This function gets the background color of an image as FreeImage_GetBackgroundColor() does but + ' provides it's result as a Long value. + + FreeImage_GetBackgroundColorAsLong = (FreeImage_GetBackgroundColorAsLongInt(Bitmap, BackColor) = 1) + +End Function + +Public Function FreeImage_GetBackgroundColorEx(ByVal Bitmap As Long, _ + ByRef Alpha As Byte, _ + ByRef Red As Byte, _ + ByRef Green As Byte, _ + ByRef Blue As Byte) As Boolean + +Dim bkcolor As RGBQUAD + + ' This function gets the background color of an image as FreeImage_GetBackgroundColor() does but + ' provides it's result as four different byte values, one for each color component. + + FreeImage_GetBackgroundColorEx = (FreeImage_GetBackgroundColorInt(Bitmap, bkcolor) = 1) + With bkcolor + Alpha = .rgbReserved + Red = .rgbRed + Green = .rgbGreen + Blue = .rgbBlue + End With + +End Function + +Public Function FreeImage_SetBackgroundColor(ByVal Bitmap As Long, _ + ByRef BackColor As RGBQUAD) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SetBackgroundColor = (FreeImage_SetBackgroundColorInt(Bitmap, BackColor) = 1) + +End Function + +Public Function FreeImage_SetBackgroundColorAsLong(ByVal Bitmap As Long, _ + ByVal BackColor As Long) As Boolean + + ' This function sets the background color of an image as FreeImage_SetBackgroundColor() does but + ' the color value to set must be provided as a Long value. + + FreeImage_SetBackgroundColorAsLong = (FreeImage_SetBackgroundColorAsLongInt(Bitmap, BackColor) = 1) + +End Function + +Public Function FreeImage_SetBackgroundColorEx(ByVal Bitmap As Long, _ + ByVal Alpha As Byte, _ + ByVal Red As Byte, _ + ByVal Green As Byte, _ + ByVal Blue As Byte) As Boolean + +Dim tColor As RGBQUAD + + ' This function sets the color at position (x|y) as FreeImage_SetPixelColor() does but + ' the color value to set must be provided four different byte values, one for each + ' color component. + + With tColor + .rgbReserved = Alpha + .rgbRed = Red + .rgbGreen = Green + .rgbBlue = Blue + End With + FreeImage_SetBackgroundColorEx = (FreeImage_SetBackgroundColorInt(Bitmap, tColor) = 1) + +End Function + +Public Function FreeImage_GetPixelIndex(ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As Byte) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_GetPixelIndex = (FreeImage_GetPixelIndexInt(Bitmap, x, y, Value) = 1) + +End Function + +Public Function FreeImage_GetPixelColor(ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As RGBQUAD) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_GetPixelColor = (FreeImage_GetPixelColorInt(Bitmap, x, y, Value) = 1) + +End Function + +Public Function FreeImage_GetPixelColorByLong(ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As Long) As Boolean + + ' This function gets the color at position (x|y) as FreeImage_GetPixelColor() does but + ' provides it's result as a Long value. + + FreeImage_GetPixelColorByLong = (FreeImage_GetPixelColorByLongInt(Bitmap, x, y, Value) = 1) + +End Function + +Public Function FreeImage_GetPixelColorEx(ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Alpha As Byte, _ + ByRef Red As Byte, _ + ByRef Green As Byte, _ + ByRef Blue As Byte) As Boolean + +Dim Value As RGBQUAD + + ' This function gets the color at position (x|y) as FreeImage_GetPixelColor() does but + ' provides it's result as four different byte values, one for each color component. + + FreeImage_GetPixelColorEx = (FreeImage_GetPixelColorInt(Bitmap, x, y, Value) = 1) + With Value + Alpha = .rgbReserved + Red = .rgbRed + Green = .rgbGreen + Blue = .rgbBlue + End With + +End Function + +Public Function FreeImage_SetPixelIndex(ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As Byte) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SetPixelIndex = (FreeImage_SetPixelIndexInt(Bitmap, x, y, Value) = 1) + +End Function + +Public Function FreeImage_SetPixelColor(ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As RGBQUAD) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SetPixelColor = (FreeImage_SetPixelColorInt(Bitmap, x, y, Value) = 1) + +End Function + +Public Function FreeImage_SetPixelColorByLong(ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByRef Value As Long) As Boolean + + ' This function sets the color at position (x|y) as FreeImage_SetPixelColor() does but + ' the color value to set must be provided as a Long value. + + FreeImage_SetPixelColorByLong = (FreeImage_SetPixelColorByLongInt(Bitmap, x, y, Value) = 1) + +End Function + +Public Function FreeImage_SetPixelColorEx(ByVal Bitmap As Long, _ + ByVal x As Long, _ + ByVal y As Long, _ + ByVal Alpha As Byte, _ + ByVal Red As Byte, _ + ByVal Green As Byte, _ + ByVal Blue As Byte) As Boolean + +Dim Value As RGBQUAD + + ' This function sets the color at position (x|y) as FreeImage_SetPixelColor() does but + ' the color value to set must be provided four different byte values, one for each + ' color component. + + With Value + .rgbReserved = Alpha + .rgbRed = Red + .rgbGreen = Green + .rgbBlue = Blue + End With + FreeImage_SetPixelColorEx = (FreeImage_SetPixelColorInt(Bitmap, x, y, Value) = 1) + +End Function + +Public Function FreeImage_FIFSupportsReading(ByVal Format As FREE_IMAGE_FORMAT) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FIFSupportsReading = (FreeImage_FIFSupportsReadingInt(Format) = 1) + +End Function + +Public Function FreeImage_FIFSupportsWriting(ByVal Format As FREE_IMAGE_FORMAT) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FIFSupportsWriting = (FreeImage_FIFSupportsWritingInt(Format) = 1) + +End Function + +Public Function FreeImage_FIFSupportsExportType(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal ImageType As FREE_IMAGE_TYPE) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FIFSupportsExportType = (FreeImage_FIFSupportsExportTypeInt(Format, ImageType) = 1) + +End Function + +Public Function FreeImage_FIFSupportsExportBPP(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal BitsPerPixel As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FIFSupportsExportBPP = (FreeImage_FIFSupportsExportBPPInt(Format, BitsPerPixel) = 1) + +End Function + +Public Function FreeImage_FIFSupportsICCProfiles(ByVal Format As FREE_IMAGE_FORMAT) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FIFSupportsICCProfiles = (FreeImage_FIFSupportsICCProfilesInt(Format) = 1) + +End Function + +Public Function FreeImage_FIFSupportsNoPixels(ByVal Format As FREE_IMAGE_FORMAT) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FIFSupportsNoPixels = (FreeImage_FIFSupportsNoPixelsInt(Format) = 1) + +End Function + +Public Function FreeImage_CloseMultiBitmap(ByVal Bitmap As Long, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_CloseMultiBitmap = (FreeImage_CloseMultiBitmapInt(Bitmap, Flags) = 1) + +End Function + +Public Function FreeImage_MovePage(ByVal Bitmap As Long, _ + ByVal TargetPage As Long, _ + ByVal SourcePage As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_MovePage = (FreeImage_MovePageInt(Bitmap, TargetPage, SourcePage) = 1) + +End Function + +Public Function FreeImage_GetLockedPageNumbers(ByVal Bitmap As Long, _ + ByRef PagesPtr As Long, _ + ByRef Count As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_GetLockedPageNumbers = (FreeImage_GetLockedPageNumbersInt(Bitmap, PagesPtr, Count) = 1) + +End Function + +Public Function FreeImage_SaveToMemory(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByVal Stream As Long, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SaveToMemory = (FreeImage_SaveToMemoryInt(Format, Bitmap, Stream, Flags) = 1) + +End Function + +Public Function FreeImage_AcquireMemory(ByVal Stream As Long, _ + ByRef DataPtr As Long, _ + ByRef SizeInBytes As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_AcquireMemory = (FreeImage_AcquireMemoryInt(Stream, DataPtr, SizeInBytes) = 1) + +End Function + +Public Function FreeImage_SeekMemory(ByVal Stream As Long, _ + ByVal Offset As Long, _ + ByVal Origin As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SeekMemory = (FreeImage_SeekMemoryInt(Stream, Offset, Origin) = 1) + +End Function + +Public Function FreeImage_IsLittleEndian() As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_IsLittleEndian = (FreeImage_IsLittleEndianInt() = 1) + +End Function + +Public Function FreeImage_LookupX11Color(ByVal Color As String, _ + ByRef Red As Long, _ + ByRef Green As Long, _ + ByRef Blue As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_LookupX11Color = (FreeImage_LookupX11ColorInt(Color, Red, Green, Blue) = 1) + +End Function + +Public Function FreeImage_LookupSVGColor(ByVal Color As String, _ + ByRef Red As Long, _ + ByRef Green As Long, _ + ByRef Blue As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_LookupSVGColor = (FreeImage_LookupSVGColorInt(Color, Red, Green, Blue) = 1) + +End Function + +Public Function FreeImage_FindNextMetadata(ByVal hFind As Long, _ + ByRef Tag As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FindNextMetadata = (FreeImage_FindNextMetadataInt(hFind, Tag) = 1) + +End Function + +Public Function FreeImage_CloneMetadata(ByVal BitmapDst As Long, _ + ByVal BitmapSrc As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_CloneMetadata = (FreeImage_CloneMetadataInt(BitmapDst, BitmapSrc) = 1) + +End Function + +Public Function FreeImage_GetMetadata(ByVal Model As Long, _ + ByVal Bitmap As Long, _ + ByVal Key As String, _ + ByVal Tag As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_GetMetadata = (FreeImage_GetMetadataInt(Model, Bitmap, Key, Tag) = 1) + +End Function + +Public Function FreeImage_SetMetadata(ByVal Model As Long, _ + ByVal Bitmap As Long, _ + ByVal Key As String, _ + ByVal Tag As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SetMetadata = (FreeImage_SetMetadataInt(Model, Bitmap, Key, Tag) = 1) + +End Function + +Public Function FreeImage_SetMetadataKeyValue(ByVal Model As Long, _ + ByVal Bitmap As Long, _ + ByVal Key As String, _ + ByVal Value As String) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SetMetadataKeyValue = (FreeImage_SetMetadataKeyValueInt(Model, Bitmap, Key, Value) = 1) + +End Function + +Public Function FreeImage_FlipHorizontal(ByVal Bitmap As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FlipHorizontal = (FreeImage_FlipHorizontalInt(Bitmap) = 1) + +End Function + +Public Function FreeImage_FlipVertical(ByVal Bitmap As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FlipVertical = (FreeImage_FlipVerticalInt(Bitmap) = 1) + +End Function + +Public Function FreeImage_JPEGTransform(ByVal SourceFile As String, _ + ByVal DestFile As String, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + Optional ByVal Perfect As Boolean = True) As Boolean + +Dim lPerfect As Long + + ' Thin wrapper function returning a real VB Boolean value + + If (Perfect) Then + lPerfect = 1 + End If + FreeImage_JPEGTransform = (FreeImage_JPEGTransformInt(SourceFile, DestFile, Operation, lPerfect) = 1) + +End Function + +Public Function FreeImage_JPEGTransformU(ByVal SourceFile As String, _ + ByVal DestFile As String, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + Optional ByVal Perfect As Boolean = True) As Boolean + +Dim lPerfect As Long + + ' Thin wrapper function returning a real VB Boolean value + + ' This function is also a thin wrapper to ease the call to an + ' UNICODE function. Since VB's BSTR strings are actually UNICODE + ' strings, we just need to pass the pointer to the string data + ' returned by the (undocumented) function StrPtr(). + + If (Perfect) Then + lPerfect = 1 + End If + FreeImage_JPEGTransformU = (FreeImage_JPEGTransformInt(StrPtr(SourceFile), StrPtr(DestFile), _ + Operation, lPerfect) = 1) + +End Function + +Public Function FreeImage_JPEGCrop(ByVal SourceFile As String, _ + ByVal DestFile As String, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_JPEGCrop = (FreeImage_JPEGCropInt(SourceFile, DestFile, Left, Top, Right, Bottom) = 1) + +End Function + +Public Function FreeImage_JPEGCropU(ByVal SourceFile As String, _ + ByVal DestFile As String, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + ' This function is also a thin wrapper to ease the call to an + ' UNICODE function. Since VB's BSTR strings are actually UNICODE + ' strings, we just need to pass the pointer to the string data + ' returned by the (undocumented) function StrPtr(). + + FreeImage_JPEGCropU = (FreeImage_JPEGCropInt(StrPtr(SourceFile), StrPtr(DestFile), Left, Top, _ + Right, Bottom) = 1) + +End Function + +Public Function FreeImage_JPEGTransformCombined(ByVal SourceFile As String, _ + ByVal DestFile As String, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long, _ + Optional ByVal Perfect As Boolean = True) As Boolean + +Dim lPerfect As Long + + ' Thin wrapper function returning a real VB Boolean value + + If (Perfect) Then + lPerfect = 1 + End If + FreeImage_JPEGTransformCombined = (FreeImage_JPEGTransformCombinedInt(SourceFile, DestFile, _ + Operation, Left, Top, Right, Bottom, lPerfect) = 1) + +End Function + +Public Function FreeImage_JPEGTransformCombinedU(ByVal SourceFile As String, _ + ByVal DestFile As String, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long, _ + Optional ByVal Perfect As Boolean = True) As Boolean + +Dim lPerfect As Long + + ' Thin wrapper function returning a real VB Boolean value + + ' This function is also a thin wrapper to ease the call to an + ' UNICODE function. Since VB's BSTR strings are actually UNICODE + ' strings, we just need to pass the pointer to the string data + ' returned by the (undocumented) function StrPtr(). + + If (Perfect) Then + lPerfect = 1 + End If + FreeImage_JPEGTransformCombinedU = (FreeImage_JPEGTransformCombinedUInt(StrPtr(SourceFile), _ + StrPtr(DestFile), Operation, Left, Top, Right, Bottom, lPerfect) = 1) + +End Function + +Public Function FreeImage_JPEGTransformCombinedFromMemory(ByVal SourceStream As Long, _ + ByVal DestStream As Long, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long, _ + Optional ByVal Perfect As Boolean = True) As Boolean + +Dim lPerfect As Long + + ' Thin wrapper function returning a real VB Boolean value + + If (Perfect) Then + lPerfect = 1 + End If + FreeImage_JPEGTransformCombinedFromMemory = (FreeImage_JPEGTransformCombinedFromMemoryInt(SourceStream, _ + DestStream, Operation, Left, Top, Right, Bottom, lPerfect) = 1) + +End Function + +Public Function FreeImage_AdjustCurve(ByVal Bitmap As Long, _ + ByVal LookupTablePtr As Long, _ + ByVal Channel As FREE_IMAGE_COLOR_CHANNEL) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_AdjustCurve = (FreeImage_AdjustCurveInt(Bitmap, LookupTablePtr, Channel) = 1) + +End Function + +Public Function FreeImage_AdjustGamma(ByVal Bitmap As Long, _ + ByVal Gamma As Double) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_AdjustGamma = (FreeImage_AdjustGammaInt(Bitmap, Gamma) = 1) + +End Function + +Public Function FreeImage_AdjustBrightness(ByVal Bitmap As Long, _ + ByVal Percentage As Double) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_AdjustBrightness = (FreeImage_AdjustBrightnessInt(Bitmap, Percentage) = 1) + +End Function + +Public Function FreeImage_AdjustContrast(ByVal Bitmap As Long, _ + ByVal Percentage As Double) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_AdjustContrast = (FreeImage_AdjustContrastInt(Bitmap, Percentage) = 1) + +End Function + +Public Function FreeImage_Invert(ByVal Bitmap As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_Invert = (FreeImage_InvertInt(Bitmap) = 1) + +End Function + +Public Function FreeImage_GetHistogram(ByVal Bitmap As Long, _ + ByRef HistogramPtr As Long, _ + Optional ByVal Channel As FREE_IMAGE_COLOR_CHANNEL = FICC_BLACK) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_GetHistogram = (FreeImage_GetHistogramInt(Bitmap, HistogramPtr, Channel) = 1) + +End Function + +Public Function FreeImage_AdjustColors(ByVal Bitmap As Long, _ + Optional ByVal Brightness As Double, _ + Optional ByVal Contrast As Double, _ + Optional ByVal Gamma As Double = 1, _ + Optional ByVal Invert As Boolean) As Boolean + +Dim lInvert As Long + + ' Thin wrapper function returning a real VB Boolean value + If (Invert) Then + lInvert = 1 + End If + FreeImage_AdjustColors = (FreeImage_AdjustColorsInt(Bitmap, Brightness, Contrast, Gamma, lInvert) = 1) + +End Function + +Public Function FreeImage_SetChannel(ByVal BitmapDst As Long, _ + ByVal BitmapSrc As Long, _ + ByVal Channel As FREE_IMAGE_COLOR_CHANNEL) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SetChannel = (FreeImage_SetChannelInt(BitmapDst, BitmapSrc, Channel) = 1) + +End Function + +Public Function FreeImage_SetComplexChannel(ByVal BitmapDst As Long, _ + ByVal BitmapSrc As Long, _ + ByVal Channel As FREE_IMAGE_COLOR_CHANNEL) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SetComplexChannel = (FreeImage_SetComplexChannelInt(BitmapDst, BitmapSrc, Channel) = 1) + +End Function + +Public Function FreeImage_Paste(ByVal BitmapDst As Long, _ + ByVal BitmapSrc As Long, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Alpha As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_Paste = (FreeImage_PasteInt(BitmapDst, BitmapSrc, Left, Top, Alpha) = 1) + +End Function + +Public Function FreeImage_PreMultiplyWithAlpha(ByVal Bitmap As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_PreMultiplyWithAlpha = (FreeImage_PreMultiplyWithAlphaInt(Bitmap) = 1) + +End Function + +Public Function FreeImage_FillBackgroundEx(ByVal Bitmap As Long, _ + ByRef Color As RGBQUAD, _ + Optional ByVal Options As FREE_IMAGE_COLOR_OPTIONS) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FillBackgroundEx = (FreeImage_FillBackground(Bitmap, Color, Options) = 1) + +End Function + +Public Function FreeImage_FillBackgroundByLong(ByVal Bitmap As Long, _ + ByRef Color As Long, _ + Optional ByVal Options As FREE_IMAGE_COLOR_OPTIONS) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_FillBackgroundByLong = (FreeImage_FillBackground(Bitmap, Color, Options) = 1) + +End Function + +Public Function FreeImage_SetThumbnail(ByVal Bitmap As Long, ByVal Thumbnail As Long) As Boolean + + ' Thin wrapper function returning a real VB Boolean value + + FreeImage_SetThumbnail = (FreeImage_SetThumbnailInt(Bitmap, Thumbnail) = 1) + +End Function + +Public Function FreeImage_OpenMultiBitmap(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Filename As String, _ + Optional ByVal CreateNew As Boolean, _ + Optional ByVal ReadOnly As Boolean, _ + Optional ByVal KeepCacheInMemory As Boolean, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS) As Long + + FreeImage_OpenMultiBitmap = FreeImage_OpenMultiBitmapInt(Format, Filename, IIf(CreateNew, 1, 0), _ + IIf(ReadOnly And Not CreateNew, 1, 0), IIf(KeepCacheInMemory, 1, 0), Flags) + +End Function + +Public Sub FreeImage_UnlockPage(ByVal Bitmap As Long, ByVal PageBitmap As Long, ByVal ApplyChanges As Boolean) + +Dim lApplyChanges As Long + + If (ApplyChanges) Then + lApplyChanges = 1 + End If + Call FreeImage_UnlockPageInt(Bitmap, PageBitmap, lApplyChanges) + +End Sub + +Public Function FreeImage_RotateEx(ByVal Bitmap As Long, _ + ByVal Angle As Double, _ + Optional ByVal ShiftX As Double, _ + Optional ByVal ShiftY As Double, _ + Optional ByVal OriginX As Double, _ + Optional ByVal OriginY As Double, _ + Optional ByVal UseMask As Boolean) As Long + +Dim lUseMask As Long + + If (UseMask) Then + lUseMask = 1 + End If + FreeImage_RotateEx = FreeImage_RotateExInt(Bitmap, Angle, ShiftX, ShiftY, OriginX, OriginY, lUseMask) + +End Function + +Public Function FreeImage_MakeThumbnail(ByVal Bitmap As Long, _ + ByVal MaxPixelSize As Long, _ + Optional ByVal Convert As Boolean) As Long + +Dim lConvert As Long + + If (Convert) Then + lConvert = 1 + End If + FreeImage_MakeThumbnail = FreeImage_MakeThumbnailInt(Bitmap, MaxPixelSize, lConvert) + +End Function + +Public Function FreeImage_GetAdjustColorsLookupTable(ByVal LookupTablePtr As Long, _ + Optional ByVal Brightness As Double, _ + Optional ByVal Contrast As Double, _ + Optional ByVal Gamma As Double, _ + Optional ByVal Invert As Boolean) As Long + +Dim lInvert As Long + + If (Invert) Then + lInvert = 1 + End If + FreeImage_GetAdjustColorsLookupTable = FreeImage_GetAdjustColorsLookupTableInt(LookupTablePtr, _ + Brightness, Contrast, Gamma, lInvert) + +End Function + +Public Function FreeImage_ApplyColorMapping(ByVal Bitmap As Long, _ + ByVal SourceColorsPtr As Long, _ + ByVal DestinationColorsPtr As Long, _ + ByVal Count As Long, _ + Optional ByVal IgnoreAlpha As Boolean = True, _ + Optional ByVal Swap As Boolean) As Long + +Dim lIgnoreAlpha As Long +Dim lSwap As Long + + If (IgnoreAlpha) Then + lIgnoreAlpha = 1 + End If + If (Swap) Then + lSwap = 1 + End If + FreeImage_ApplyColorMapping = FreeImage_ApplyColorMappingInt(Bitmap, SourceColorsPtr, _ + DestinationColorsPtr, Count, lIgnoreAlpha, lSwap) + +End Function + +Public Function FreeImage_SwapColors(ByVal Bitmap As Long, _ + ByRef ColorA As RGBQUAD, _ + ByRef ColorB As RGBQUAD, _ + Optional ByVal IgnoreAlpha As Boolean = True) As Long + +Dim lIgnoreAlpha As Long + + If (IgnoreAlpha) Then + lIgnoreAlpha = 1 + End If + FreeImage_SwapColors = FreeImage_SwapColorsInt(Bitmap, ColorA, ColorB, lIgnoreAlpha) + +End Function + +Public Function FreeImage_SwapColorsByLong(ByVal Bitmap As Long, _ + ByRef ColorA As Long, _ + ByRef ColorB As Long, _ + Optional ByVal IgnoreAlpha As Boolean = True) As Long + +Dim lIgnoreAlpha As Long + + If (IgnoreAlpha) Then + lIgnoreAlpha = 1 + End If + FreeImage_SwapColorsByLong = FreeImage_SwapColorsByLongInt(Bitmap, ColorA, ColorB, _ + lIgnoreAlpha) + +End Function + +Public Function FreeImage_ApplyPaletteIndexMapping(ByVal Bitmap As Long, _ + ByVal SourceIndicesPtr As Long, _ + ByVal DestinationIndicesPtr As Long, _ + ByVal Count As Long, _ + Optional ByVal Swap As Boolean) As Long + +Dim lSwap As Long + + If (Swap) Then + lSwap = 1 + End If + FreeImage_ApplyPaletteIndexMapping = FreeImage_ApplyPaletteIndexMappingInt(Bitmap, SourceIndicesPtr, _ + DestinationIndicesPtr, Count, lSwap) + +End Function + +Public Function FreeImage_ConvertFromRawBits(ByVal BitsPtr As Long, _ + ByVal Width As Long, _ + ByVal Height As Long, _ + ByVal Pitch As Long, _ + ByVal BitsPerPixel As Long, _ + Optional ByVal RedMask As Long, _ + Optional ByVal GreenMask As Long, _ + Optional ByVal BlueMask As Long, _ + Optional ByVal TopDown As Boolean) As Long + +Dim lTopDown As Long + + If (TopDown) Then + lTopDown = 1 + End If + FreeImage_ConvertFromRawBits = FreeImage_ConvertFromRawBitsInt(BitsPtr, Width, Height, Pitch, _ + BitsPerPixel, RedMask, GreenMask, BlueMask, lTopDown) + +End Function + +Public Function FreeImage_ConvertFromRawBitsEx(ByVal CopySource As Boolean, _ + ByVal BitsPtr As Long, _ + ByVal ImageType As FREE_IMAGE_TYPE, _ + ByVal Width As Long, _ + ByVal Height As Long, _ + ByVal Pitch As Long, _ + ByVal BitsPerPixel As Long, _ + Optional ByVal RedMask As Long, _ + Optional ByVal GreenMask As Long, _ + Optional ByVal BlueMask As Long, _ + Optional ByVal TopDown As Boolean) As Long + +Dim lCopySource As Long +Dim lTopDown As Long + + If (CopySource) Then + lCopySource = 1 + End If + If (TopDown) Then + lTopDown = 1 + End If + FreeImage_ConvertFromRawBitsEx = FreeImage_ConvertFromRawBitsExInt(lCopySource, BitsPtr, ImageType, _ + Width, Height, Pitch, BitsPerPixel, RedMask, GreenMask, BlueMask, lTopDown) + +End Function + +Public Sub FreeImage_ConvertToRawBits(ByVal BitsPtr As Long, _ + ByVal Bitmap As Long, _ + ByVal Pitch As Long, _ + ByVal BitsPerPixel As Long, _ + Optional ByVal RedMask As Long, _ + Optional ByVal GreenMask As Long, _ + Optional ByVal BlueMask As Long, _ + Optional ByVal TopDown As Boolean) + +Dim lTopDown As Long + + If (TopDown) Then + lTopDown = 1 + End If + Call FreeImage_ConvertToRawBitsInt(BitsPtr, Bitmap, Pitch, _ + BitsPerPixel, RedMask, GreenMask, BlueMask, lTopDown) + +End Sub + +Public Function FreeImage_ConvertToStandardType(ByVal Bitmap As Long, _ + Optional ByVal ScaleLinear As Boolean = True) As Long + + If (ScaleLinear) Then + FreeImage_ConvertToStandardType = FreeImage_ConvertToStandardTypeInt(Bitmap, 1) + Else + FreeImage_ConvertToStandardType = FreeImage_ConvertToStandardTypeInt(Bitmap, 0) + End If + +End Function + +Public Function FreeImage_ConvertToType(ByVal Bitmap As Long, _ + ByVal DestinationType As FREE_IMAGE_TYPE, _ + Optional ByVal ScaleLinear As Boolean = True) As Long + + If (ScaleLinear) Then + FreeImage_ConvertToType = FreeImage_ConvertToTypeInt(Bitmap, DestinationType, 1) + Else + FreeImage_ConvertToType = FreeImage_ConvertToTypeInt(Bitmap, DestinationType, 0) + End If + +End Function + + + +'-------------------------------------------------------------------------------- +' Color conversion helper functions +'-------------------------------------------------------------------------------- + +Public Function ConvertColor(ByVal Color As Long) As Long + + ' This helper function converts a VB-style color value (like vbRed), which + ' uses the ABGR format into a RGBQUAD compatible color value, using the ARGB + ' format, needed by FreeImage and vice versa. + + ConvertColor = ((Color And &HFF000000) Or _ + ((Color And &HFF&) * &H10000) Or _ + ((Color And &HFF00&)) Or _ + ((Color And &HFF0000) \ &H10000)) + +End Function + +Public Function ConvertOleColor(ByVal Color As OLE_COLOR) As Long + + ' This helper function converts an OLE_COLOR value (like vbButtonFace), which + ' uses the BGR format into a RGBQUAD compatible color value, using the ARGB + ' format, needed by FreeImage. + + ' This function generally ingnores the specified color's alpha value but, in + ' contrast to ConvertColor, also has support for system colors, which have the + ' format &H80bbggrr. + + ' You should not use this function to convert any color provided by FreeImage + ' in ARGB format into a VB-style ABGR color value. Use function ConvertColor + ' instead. + +Dim lColorRef As Long + + If (OleTranslateColor(Color, 0, lColorRef) = 0) Then + ConvertOleColor = ConvertColor(lColorRef) + End If + +End Function + + + +'-------------------------------------------------------------------------------- +' Extended functions derived from FreeImage 3 functions usually dealing +' with arrays +'-------------------------------------------------------------------------------- + +Public Sub FreeImage_UnloadEx(ByRef Bitmap As Long) + + ' Extended version of FreeImage_Unload, which additionally sets the + ' passed Bitmap handle to zero after unloading. + + If (Bitmap <> 0) Then + Call FreeImage_Unload(Bitmap) + Bitmap = 0 + End If + +End Sub + +Public Function FreeImage_GetPaletteEx(ByVal Bitmap As Long) As RGBQUAD() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long + + ' This function returns a VB style array of type RGBQUAD, containing + ' the palette data of the Bitmap. This array provides read and write access + ' to the actual palette data provided by FreeImage. This is done by + ' creating a VB array with an own SAFEARRAY descriptor making the + ' array point to the palette pointer returned by FreeImage_GetPalette(). + + ' This makes you use code like you would in C/C++: + + ' // this code assumes there is a bitmap loaded and + ' // present in a variable called ‘dib’ + ' if(FreeImage_GetBPP(Bitmap) == 8) { + ' // Build a greyscale palette + ' RGBQUAD *pal = FreeImage_GetPalette(Bitmap); + ' for (int i = 0; i < 256; i++) { + ' pal[i].rgbRed = i; + ' pal[i].rgbGreen = i; + ' pal[i].rgbBlue = i; + ' } + + ' As in C/C++ the array is only valid while the DIB is loaded and the + ' palette data remains where the pointer returned by FreeImage_GetPalette + ' has pointed to when this function was called. So, a good thing would + ' be, not to keep the returned array in scope over the lifetime of the + ' Bitmap. Best practise is, to use this function within another routine and + ' assign the return value (the array) to a local variable only. As soon + ' as this local variable goes out of scope (when the calling function + ' returns to it's caller), the array and the descriptor is automatically + ' cleaned up by VB. + + ' This function does not make a deep copy of the palette data, but only + ' wraps a VB array around the FreeImage palette data. So, it can be called + ' frequently "on demand" or somewhat "in place" without a significant + ' performance loss. + + ' To learn more about this technique I recommend reading chapter 2 (Leveraging + ' Arrays) of Matthew Curland's book "Advanced Visual Basic 6" + + ' The parameter 'Bitmap' works according to the FreeImage 3 API documentation. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the FreeImage_DestroyLockedArrayRGBQUAD() function. + + + If (Bitmap) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 4 ' size in bytes of RGBQUAD structure + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetColorsUsed(Bitmap) ' the number of elements in the array is + ' the number of used colors in the Bitmap + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetPalette(Bitmap) ' let the array point to the memory block, the + ' FreeImage palette pointer points to + End With + + ' allocate memory for an array descriptor + ' we cannot use the memory block used by tSA, since it is + ' released when tSA goes out of scope, leaving us with an + ' array with zeroed descriptor + ' we use nearly the same method that VB uses, so VB is able + ' to cleanup the array variable and it's descriptor; the + ' array data is not touched when cleaning up, since both AUTO + ' and FIXEDSIZE flags are set + Call SafeArrayAllocDescriptor(1, lpSA) + + ' copy our own array descriptor over the descriptor allocated + ' by SafeArrayAllocDescriptor; lpSA is a pointer to that memory + ' location + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + + ' the implicit variable named as the function is an array variable in VB + ' make it point to the allocated array descriptor + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetPaletteEx), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetPaletteExClone(ByVal Bitmap As Long) As RGBQUAD() + +Dim lColors As Long +Dim atPal() As RGBQUAD + + ' This function returns a redundant clone of a Bitmap's palette as a + ' VB style array of type RGBQUAD. + + ' The parameter 'Bitmap' works according to the FreeImage 3 API documentation. + + lColors = FreeImage_GetColorsUsed(Bitmap) + If (lColors > 0) Then + ReDim atPal(lColors - 1) + Call CopyMemory(atPal(0), ByVal FreeImage_GetPalette(Bitmap), lColors * 4) + Call pSwap(ByVal VarPtrArray(atPal), ByVal VarPtrArray(FreeImage_GetPaletteExClone)) + End If + +End Function + +Public Function FreeImage_GetPaletteExLong(ByVal Bitmap As Long) As Long() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long + + ' This function returns a VB style array of type Long, containing + ' the palette data of the Bitmap. This array provides read and write access + ' to the actual palette data provided by FreeImage. This is done by + ' creating a VB array with an own SAFEARRAY descriptor making the + ' array point to the palette pointer returned by FreeImage_GetPalette(). + + ' The function actually returns an array of type RGBQUAD with each + ' element packed into a Long. This is possible, since the RGBQUAD + ' structure is also four bytes in size. Palette data, stored in an + ' array of type Long may be passed ByRef to a function through an + ' optional paremeter. For an example have a look at function + ' FreeImage_ConvertColorDepth() + + ' This makes you use code like you would in C/C++: + + ' // this code assumes there is a bitmap loaded and + ' // present in a variable called ‘dib’ + ' if(FreeImage_GetBPP(Bitmap) == 8) { + ' // Build a greyscale palette + ' RGBQUAD *pal = FreeImage_GetPalette(Bitmap); + ' for (int i = 0; i < 256; i++) { + ' pal[i].rgbRed = i; + ' pal[i].rgbGreen = i; + ' pal[i].rgbBlue = i; + ' } + + ' As in C/C++ the array is only valid while the DIB is loaded and the + ' palette data remains where the pointer returned by FreeImage_GetPalette() + ' has pointed to when this function was called. So, a good thing would + ' be, not to keep the returned array in scope over the lifetime of the + ' Bitmap. Best practise is, to use this function within another routine and + ' assign the return value (the array) to a local variable only. As soon + ' as this local variable goes out of scope (when the calling function + ' returns to it's caller), the array and the descriptor is automatically + ' cleaned up by VB. + + ' This function does not make a deep copy of the palette data, but only + ' wraps a VB array around the FreeImage palette data. So, it can be called + ' frequently "on demand" or somewhat "in place" without a significant + ' performance loss. + + ' To learn more about this technique I recommend reading chapter 2 (Leveraging + ' Arrays) of Matthew Curland's book "Advanced Visual Basic 6" + + ' The parameter 'Bitmap' works according to the FreeImage 3 API documentation. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + + If (Bitmap) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 4 ' size in bytes of RGBQUAD structure + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetColorsUsed(Bitmap) ' the number of elements in the array is + ' the number of used colors in the Bitmap + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetPalette(Bitmap) ' let the array point to the memory block, the + ' FreeImage palette pointer points to + End With + + ' allocate memory for an array descriptor + ' we cannot use the memory block used by tSA, since it is + ' released when tSA goes out of scope, leaving us with an + ' array with zeroed descriptor + ' we use nearly the same method that VB uses, so VB is able + ' to cleanup the array variable and it's descriptor; the + ' array data is not touched when cleaning up, since both AUTO + ' and FIXEDSIZE flags are set + Call SafeArrayAllocDescriptor(1, lpSA) + + ' copy our own array descriptor over the descriptor allocated + ' by SafeArrayAllocDescriptor; lpSA is a pointer to that memory + ' location + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + + ' the implicit variable named as the function is an array variable in VB + ' make it point to the allocated array descriptor + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetPaletteExLong), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetPaletteExLongClone(ByVal Bitmap As Long) As Long() + +Dim lColors As Long +Dim alPal() As Long + + ' This function returns a redundant clone of a Bitmap's palette as a + ' VB style array of type Long. + + ' The parameter 'Bitmap' works according to the FreeImage 3 API documentation. + + lColors = FreeImage_GetColorsUsed(Bitmap) + If (lColors > 0) Then + ReDim alPal(lColors - 1) + Call CopyMemory(alPal(0), ByVal FreeImage_GetPalette(Bitmap), lColors * 4) + Call pSwap(ByVal VarPtrArray(alPal), ByVal VarPtrArray(FreeImage_GetPaletteExLongClone)) + End If + +End Function + +Public Function FreeImage_SetPalette(ByVal Bitmap As Long, ByRef Palette() As RGBQUAD) As Long + + ' This function sets the palette of a palletised bitmap using a RGBQUAD array. Does + ' nothing on high color bitmaps. + + ' This operation makes a deep copy of the provided palette data so, after this function + ' has returned, changes to the RGBQUAD array are no longer reflected by the bitmap's + ' palette. + + FreeImage_SetPalette = FreeImage_GetColorsUsed(Bitmap) + If (FreeImage_SetPalette > 0) Then + Call CopyMemory(ByVal FreeImage_GetPalette(Bitmap), Palette(0), FreeImage_SetPalette * 4) + End If + +End Function + +Public Function FreeImage_SetPaletteLong(ByVal Bitmap As Long, ByRef Palette() As Long) As Long + + ' This function sets the palette of a palletised bitmap using a RGBQUAD array. Does + ' nothing on high color bitmaps. + + ' This operation makes a deep copy of the provided palette data so, after this function + ' has returned, changes to the Long array are no longer reflected by the bitmap's + ' palette. + + FreeImage_SetPaletteLong = FreeImage_GetColorsUsed(Bitmap) + If (FreeImage_SetPaletteLong > 0) Then + Call CopyMemory(ByVal FreeImage_GetPalette(Bitmap), Palette(0), FreeImage_SetPaletteLong * 4) + End If + +End Function + +Public Function FreeImage_GetTransparencyTableEx(ByVal Bitmap As Long) As Byte() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long + + ' This function returns a VB style Byte array, containing the transparency + ' table of the Bitmap. This array provides read and write access to the actual + ' transparency table provided by FreeImage. This is done by creating a VB array + ' with an own SAFEARRAY descriptor making the array point to the transparency + ' table pointer returned by FreeImage_GetTransparencyTable(). + + ' This makes you use code like you would in C/C++: + + ' // this code assumes there is a bitmap loaded and + ' // present in a variable called ‘dib’ + ' if(FreeImage_GetBPP(Bitmap) == 8) { + ' // Remove transparency information + ' byte *transt = FreeImage_GetTransparencyTable(Bitmap); + ' for (int i = 0; i < 256; i++) { + ' transt[i].rgbRed = 255; + ' } + + ' As in C/C++ the array is only valid while the DIB is loaded and the transparency + ' table remains where the pointer returned by FreeImage_GetTransparencyTable() has + ' pointed to when this function was called. So, a good thing would be, not to keep + ' the returned array in scope over the lifetime of the DIB. Best practise is, to use + ' this function within another routine and assign the return value (the array) to a + ' local variable only. As soon as this local variable goes out of scope (when the + ' calling function returns to it's caller), the array and the descriptor is + ' automatically cleaned up by VB. + + ' This function does not make a deep copy of the transparency table, but only + ' wraps a VB array around the FreeImage transparency table. So, it can be called + ' frequently "on demand" or somewhat "in place" without a significant + ' performance loss. + + ' To learn more about this technique I recommend reading chapter 2 (Leveraging + ' Arrays) of Matthew Curland's book "Advanced Visual Basic 6" + + ' The parameter 'Bitmap' works according to the FreeImage 3 API documentation. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the FreeImage_DestroyLockedArray() function. + + + If (Bitmap) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 1 ' size in bytes of a byte element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetTransparencyCount(Bitmap) ' the number of elements in the array is + ' equal to the number transparency table entries + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetTransparencyTable(Bitmap) ' let the array point to the memory block, the + ' FreeImage transparency table pointer points to + End With + + ' allocate memory for an array descriptor + ' we cannot use the memory block used by tSA, since it is + ' released when tSA goes out of scope, leaving us with an + ' array with zeroed descriptor + ' we use nearly the same method that VB uses, so VB is able + ' to cleanup the array variable and it's descriptor; the + ' array data is not touched when cleaning up, since both AUTO + ' and FIXEDSIZE flags are set + Call SafeArrayAllocDescriptor(1, lpSA) + + ' copy our own array descriptor over the descriptor allocated + ' by SafeArrayAllocDescriptor(); lpSA is a pointer to that memory + ' location + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + + ' the implicit variable named as the function is an array variable in VB + ' make it point to the allocated array descriptor + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetTransparencyTableEx), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetTransparencyTableExClone(ByVal Bitmap As Long) As Byte() + +Dim abBuffer() As Byte +Dim lpTransparencyTable As Long +Dim lEntries As Long + + ' This function returns a copy of a DIB's transparency table as VB style + ' array of type Byte. So, the array provides read access only from the DIB's + ' point of view. + + ' The parameter 'Bitmap' works according to the FreeImage 3 API documentation. + + lpTransparencyTable = FreeImage_GetTransparencyTable(Bitmap) + If (lpTransparencyTable) Then + lEntries = FreeImage_GetTransparencyCount(Bitmap) + If (lEntries > 0) Then + ReDim abBuffer(lEntries - 1) + Call CopyMemory(abBuffer(0), ByVal lpTransparencyTable, lEntries) + Call pSwap(ByVal VarPtrArray(abBuffer), ByVal VarPtrArray( _ + FreeImage_GetTransparencyTableExClone)) + End If + End If + +End Function + +Public Sub FreeImage_SetTransparencyTableEx(ByVal Bitmap As Long, _ + ByRef Table() As Byte, _ + Optional ByRef Count As Long = -1) + + ' This function sets a DIB's transparency table to the contents of the + ' parameter table(). When the optional parameter Count is omitted, the + ' number of entries used is taken from the number of elements stored in + ' the array, but will never be never greater than 256. + + ' The parameter 'Bitmap' works according to the FreeImage 3 API documentation. + + If ((Count > UBound(Table) + 1) Or _ + (Count < 0)) Then + Count = UBound(Table) + 1 + End If + + If (Count > 256) Then + Count = 256 + End If + + Call FreeImage_SetTransparencyTable(Bitmap, VarPtr(Table(0)), Count) + +End Sub + +Public Function FreeImage_IsTransparencyTableTransparent(ByVal Bitmap As Long) As Boolean + +Dim abTransTable() As Byte +Dim i As Long + + ' This function checks whether a Bitmap's transparency table contains any transparent + ' colors or not. + + ' When an image has a transparency table and is transparent, what can be tested + ' with 'FreeImage_IsTransparent()', the image still may display opaque when there + ' are no transparent colors defined in the image's transparency table. This + ' function reads the Bitmap's transparency table directly to determine whether + ' there are transparent colors defined or not. + + ' The return value of this function does not relay on the image's transparency + ' setting but only on the image's transparency table + + If (Bitmap) Then + abTransTable = FreeImage_GetTransparencyTableEx(Bitmap) + For i = 0 To UBound(abTransTable) + FreeImage_IsTransparencyTableTransparent = (abTransTable(i) < 255) + If (FreeImage_IsTransparencyTableTransparent) Then + Exit For + End If + Next i + End If + +End Function + +Public Function FreeImage_GetAdjustColorsLookupTableEx(ByRef LookupTable() As Byte, _ + Optional ByVal Brightness As Double, _ + Optional ByVal Contrast As Double, _ + Optional ByVal Gamma As Double = 1, _ + Optional ByVal Invert As Boolean) As Long + + ' This function is an extended wrapper for FreeImage_GetAdjustColorsLookupTable(), which + ' takes a real VB style Byte array LUT() to receive the created lookup table. The LUT() + ' parameter must not be fixed sized or locked, since it is (re-)dimensioned in this + ' function to contain 256 entries. + + ' All parameters work according to the FreeImage 3 API documentation. + + ReDim LookupTable(255) + FreeImage_GetAdjustColorsLookupTableEx = _ + FreeImage_GetAdjustColorsLookupTable(VarPtr(LookupTable(0)), Brightness, Contrast, _ + Gamma, Invert) + +End Function + +Public Function FreeImage_ApplyColorMappingEx(ByVal Bitmap As Long, _ + ByRef SourceColors() As RGBQUAD, _ + ByRef DestinationColors() As RGBQUAD, _ + Optional ByRef Count As Long = -1, _ + Optional ByVal IgnoreAlpha As Boolean = True, _ + Optional ByVal Swap As Boolean) As Long + +Dim nsrc As Long +Dim ndst As Long + + ' This function is an extended wrapper for FreeImage_ApplyColorMapping(), which takes + ' real VB style RGBQUAD arrays for source and destination colors along with an optional + ' ByRef Count parameter. + + ' If 'Count' is omitted upon entry, the number of entries of the smaller of both arrays + ' is used for 'Count' and also passed back to the caller, due to this parameter's ByRef + ' nature. + + ' All other parameters work according to the FreeImage 3 API documentation. + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to map colors on a 'header-only' bitmap.") + End If + + nsrc = UBound(SourceColors) + 1 + ndst = UBound(DestinationColors) + 1 + If (Count = -1) Then + If (nsrc < ndst) Then + Count = nsrc + Else + Count = ndst + End If + Else + If (Count < nsrc) Then + Count = nsrc + End If + If (Count < ndst) Then + Count = ndst + End If + End If + + FreeImage_ApplyColorMappingEx = FreeImage_ApplyColorMapping(Bitmap, _ + VarPtr(SourceColors(0)), VarPtr(DestinationColors(0)), Count, IgnoreAlpha, Swap) + End If + +End Function + +Public Function FreeImage_ApplyPaletteIndexMappingEx(ByVal Bitmap As Long, _ + ByRef SourceIndices() As Byte, _ + ByRef DestinationIndices() As Byte, _ + Optional ByRef Count As Long = -1, _ + Optional ByVal Swap As Boolean) As Long + +Dim nsrc As Long +Dim ndst As Long +Dim lSwap As Long + + ' This function is an extended wrapper for FreeImage_ApplyIndexMapping(), which takes + ' real VB style Byte arrays for source and destination indices along with an optional + ' ByRef count parameter. + + ' If 'Count' is omitted upon entry, the number of entries of the smaller of both arrays + ' is used for 'Count' and also passed back to the caller, due to this parameter's ByRef + ' nature. + + ' All other parameters work according to the FreeImage 3 API documentation. + + + nsrc = UBound(SourceIndices) + 1 + ndst = UBound(DestinationIndices) + 1 + If (Count = -1) Then + If (nsrc < ndst) Then + Count = nsrc + Else + Count = ndst + End If + Else + If (Count < nsrc) Then + Count = nsrc + End If + If (Count < ndst) Then + Count = ndst + End If + End If + + If (Swap) Then + lSwap = 1 + End If + + FreeImage_ApplyPaletteIndexMappingEx = FreeImage_ApplyPaletteIndexMappingInt(Bitmap, _ + VarPtr(SourceIndices(0)), VarPtr(DestinationIndices(0)), Count, lSwap) + +End Function + +Public Function FreeImage_ConvertFromRawBitsArray(ByRef Bits() As Byte, _ + ByVal Width As Long, _ + ByVal Height As Long, _ + ByVal Pitch As Long, _ + ByVal BitsPerPixel As Long, _ + Optional ByVal RedMask As Long, _ + Optional ByVal GreenMask As Long, _ + Optional ByVal BlueMask As Long, _ + Optional ByVal TopDown As Boolean) As Long + + FreeImage_ConvertFromRawBitsArray = FreeImage_ConvertFromRawBits(VarPtr(Bits(0)), Width, Height, Pitch, _ + BitsPerPixel, RedMask, GreenMask, BlueMask, TopDown) + +End Function + +Public Sub FreeImage_ConvertToRawBitsArray(ByRef Bits() As Byte, _ + ByVal Bitmap As Long, _ + ByVal Pitch As Long, _ + ByVal BitsPerPixel As Long, _ + Optional ByVal RedMask As Long, _ + Optional ByVal GreenMask As Long, _ + Optional ByVal BlueMask As Long, _ + Optional ByVal TopDown As Boolean) + +Dim lHeight As Long + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to convert a 'header-only' bitmap.") + End If + + If (Pitch > 0) Then + lHeight = FreeImage_GetHeight(Bitmap) + ReDim Bits((Pitch * lHeight) - 1) + Call FreeImage_ConvertToRawBits(VarPtr(Bits(0)), Bitmap, Pitch, _ + BitsPerPixel, RedMask, GreenMask, BlueMask, TopDown) + End If + End If + +End Sub + +Public Function FreeImage_GetHistogramEx(ByVal Bitmap As Long, _ + Optional ByVal Channel As FREE_IMAGE_COLOR_CHANNEL = FICC_BLACK, _ + Optional ByRef Success As Boolean) As Long() + +Dim alResult() As Long + + ' This function returns a DIB's histogram data as VB style array of + ' type Long. Since histogram data is never modified directly, it seems + ' enough to return a clone of the data and no read/write accessible + ' array wrapped around the actual pointer. + + ' All parameters work according to the FreeImage 3 API documentation. + + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to get histogram of a 'header-only' bitmap.") + End If + + ReDim alResult(255) + Success = (FreeImage_GetHistogramInt(Bitmap, alResult(0), Channel) = 1) + If (Success) Then + Call pSwap(VarPtrArray(FreeImage_GetHistogramEx), VarPtrArray(alResult)) + End If + End If + +End Function + +Public Function FreeImage_AdjustCurveEx(ByVal Bitmap As Long, _ + ByRef LookupTable As Variant, _ + Optional ByVal Channel As FREE_IMAGE_COLOR_CHANNEL = FICC_BLACK) As Boolean + +Dim lpData As Long +Dim lSizeInBytes As Long + + ' This function extends the FreeImage function 'FreeImage_AdjustCurve' + ' to a more VB suitable function. The parameter 'LookupTable' may + ' either be an array of type Byte or may contain the pointer to a memory + ' block, what in VB is always the address of the memory block, since VB + ' actually doesn's support native pointers. + + ' In case of providing the memory block as an array, make sure, that the + ' array contains exactly 256 items. In case of providing an address of a + ' memory block, the size of the memory block is assumed to be 256 bytes + ' and it is up to the caller to ensure that it is large enough. + + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to adjust a 'header-only' bitmap.") + End If + + If (IsArray(LookupTable)) Then + lpData = pGetMemoryBlockPtrFromVariant(LookupTable, lSizeInBytes) + + ElseIf (IsNumeric(LookupTable)) Then + lSizeInBytes = 256 + lpData = CLng(LookupTable) + + End If + + If ((lpData <> 0) And (lSizeInBytes = 256)) Then + FreeImage_AdjustCurveEx = (FreeImage_AdjustCurveInt(Bitmap, lpData, Channel) = 1) + End If + End If + +End Function + +Public Function FreeImage_GetLockedPageNumbersEx(ByVal Bitmap As Long, _ + Optional ByRef Count As Long) As Long() + +Dim lpPages As Long +Dim alResult() As Long + + ' This function extends the FreeImage function FreeImage_GetLockedPageNumbers() + ' to a more VB suitable function. The original FreeImage parameter 'pages', which + ' is a pointer to an array of Long, containing all locked page numbers, was turned + ' into a return value, which is a real VB-style array of type Long. The original + ' Boolean return value, indicating if there are any locked pages, was dropped from + ' this function. The caller has to check the 'Count' parameter, which works according + ' to the FreeImage API documentation. + + ' This function returns an array of Longs, dimensioned from 0 to (Count - 1), that + ' contains the page numbers of all currently locked pages of 'BITMAP', if 'Count' is + ' greater than 0 after the function returns. If 'Count' is 0, there are no pages + ' locked and the function returns an uninitialized array. + + + If (FreeImage_GetLockedPageNumbersInt(Bitmap, lpPages, Count) = 1) Then + ReDim alResult(Count - 1) + Call CopyMemory(alResult(0), ByVal lpPages, Count * 4) + End If + +End Function + +' Memory and Stream functions + +Public Function FreeImage_GetFileTypeFromMemoryEx(ByRef Data As Variant, _ + Optional ByRef SizeInBytes As Long) As FREE_IMAGE_FORMAT + +Dim hStream As Long +Dim lDataPtr As Long + + ' This function extends the FreeImage function FreeImage_GetFileTypeFromMemory() + ' to a more VB suitable function. The parameter data of type Variant my + ' me either an array of type Byte, Integer or Long or may contain the pointer + ' to a memory block, what in VB is always the address of the memory block, + ' since VB actually doesn's support native pointers. + + ' In case of providing the memory block as an array, the SizeInBytes may + ' be omitted, zero or less than zero. Then, the size of the memory block + ' is calculated correctly. When SizeInBytes is given, it is up to the caller + ' to ensure, it is correct. + + ' In case of providing an address of a memory block, SizeInBytes must not + ' be omitted. + + + ' get both pointer and size in bytes of the memory block provided + ' through the Variant parameter 'data'. + lDataPtr = pGetMemoryBlockPtrFromVariant(Data, SizeInBytes) + + ' open the memory stream + hStream = FreeImage_OpenMemoryByPtr(lDataPtr, SizeInBytes) + If (hStream) Then + ' on success, detect image type + FreeImage_GetFileTypeFromMemoryEx = FreeImage_GetFileTypeFromMemory(hStream) + Call FreeImage_CloseMemory(hStream) + Else + FreeImage_GetFileTypeFromMemoryEx = FIF_UNKNOWN + End If + +End Function + +Public Function FreeImage_LoadFromMemoryEx(ByRef Data As Variant, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS, _ + Optional ByRef SizeInBytes As Long, _ + Optional ByRef Format As FREE_IMAGE_FORMAT) As Long + +Dim hStream As Long +Dim lDataPtr As Long + + ' This function loads a FreeImage bitmap from memory that has been passed + ' through parameter 'Data'. This parameter is of type Variant and may actually + ' be an array of type Byte, Integer or Long or may contain the address of an + ' arbitrary block of memory. + + ' The parameter 'SizeInBytes' specifies the size of the passed block of memory + ' in bytes. It may be omitted, if parameter 'Data' contains an array of type Byte, + ' Integer or Long upon entry. In that case, or if 'SizeInBytes' is zero or less + ' than zero, the size is determined directly from the array and also passed back + ' to the caller through parameter 'SizeInBytes'. + + ' The parameter 'Format' is an OUT only parameter that contains the image type + ' of the loaded image after the function returns. + + ' The parameter 'Flags' works according to the FreeImage API documentation. + + + ' get both pointer and size in bytes of the memory block provided + ' through the Variant parameter 'data'. + lDataPtr = pGetMemoryBlockPtrFromVariant(Data, SizeInBytes) + + ' open the memory stream + hStream = FreeImage_OpenMemoryByPtr(lDataPtr, SizeInBytes) + If (hStream) Then + ' on success, detect image type + Format = FreeImage_GetFileTypeFromMemory(hStream) + If (Format <> FIF_UNKNOWN) Then + ' load the image from memory stream only, if known image type + FreeImage_LoadFromMemoryEx = FreeImage_LoadFromMemory(Format, hStream, Flags) + End If + ' close the memory stream + Call FreeImage_CloseMemory(hStream) + End If + +End Function + +Public Function FreeImage_SaveToMemoryEx(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByRef Data() As Byte, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS, _ + Optional ByVal UnloadSource As Boolean) As Boolean + +Dim hStream As Long +Dim lpData As Long +Dim lSizeInBytes As Long + + ' This function saves a FreeImage bitmap into memory and returns it through + ' the byte array passed in parameter 'Data()'. It makes a deep copy of the memory + ' stream's byte buffer, into which the image has been saved. The memory stream + ' is closed properly before the function returns. + + ' The provided byte array 'Data()' must not be a fixed sized array. It will be + ' dimensioned to the size required to hold all the memory stream's data. + + ' The parameters 'Format', 'Bitmap' and 'Flags' work according to the FreeImage + ' API documentation. + + ' The optional 'UnloadSource' parameter is for unloading the original image + ' after it has been saved into memory. There is no need to clean up the DIB + ' at the caller's site. + + ' The function returns True on success and False otherwise. + + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to save a 'header-only' bitmap.") + End If + + hStream = FreeImage_OpenMemory() + If (hStream) Then + FreeImage_SaveToMemoryEx = FreeImage_SaveToMemory(Format, Bitmap, hStream, Flags) + If (FreeImage_SaveToMemoryEx) Then + If (FreeImage_AcquireMemoryInt(hStream, lpData, lSizeInBytes)) Then + On Error Resume Next + ReDim Data(lSizeInBytes - 1) + If (Err.Number = ERROR_SUCCESS) Then + On Error GoTo 0 + Call CopyMemory(Data(0), ByVal lpData, lSizeInBytes) + Else + On Error GoTo 0 + FreeImage_SaveToMemoryEx = False + End If + Else + FreeImage_SaveToMemoryEx = False + End If + End If + Call FreeImage_CloseMemory(hStream) + Else + FreeImage_SaveToMemoryEx = False + End If + + If (UnloadSource) Then + Call FreeImage_Unload(Bitmap) + End If + End If + +End Function + +Public Function FreeImage_SaveToMemoryEx2(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByRef Data() As Byte, _ + ByRef Stream As Long, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS, _ + Optional ByVal UnloadSource As Boolean) As Boolean + + ' This function saves a FreeImage bitmap into memory and returns it through + ' the byte array passed in parameter 'Data()'. In contrast to function + ' 'FreeImage_SaveToMemoryEx', it does not make a deep copy of the memory + ' stream's byte buffer, but directly wraps the array 'Data()' around the stream's + ' byte buffer by calling function 'FreeImage_AcquireMemoryEx'. As a result, the + ' memory stream must remain valid while the array 'Data()' is in use. In other + ' words, the stream must be maintained by the caller of this function. + + ' The provided byte array 'Data()' must not be a fixed sized array. It will be + ' dimensioned to the size required to hold all the memory stream's data. + + ' To reuse the caller's array variable that was passed through parameter 'Data()' + ' before it goes out of the caller's scope, it must first be destroyed by passing + ' it to the 'FreeImage_DestroyLockedArray' function. + + ' The parameter 'Stream' is an IN/OUT parameter, that keeps track of the memory + ' stream, the VB array 'Data()' is based on. This parameter may contain an + ' already opened FreeImage memory stream upon entry and will contain a valid + ' memory stream when the function returns. It is left up to the caller to close + ' this memory stream correctly. + + ' The array 'Data()' will no longer be valid and accessible after the stream has + ' been closed, so the stream should only be closed after the passed byte array + ' variable goes out of the caller's scope or is reused. + + ' The parameters 'Format', 'Bitmap' and 'Flags' work according to the FreeImage + ' API documentation. + + ' The optional 'UnloadSource' parameter is for unloading the original image + ' after it has been saved to memory. There is no need to clean up the DIB + ' at the caller's site. + + ' The function returns True on success and False otherwise. + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to save a 'header-only' bitmap.") + End If + + If (Stream = 0) Then + Stream = FreeImage_OpenMemory() + End If + If (Stream) Then + FreeImage_SaveToMemoryEx2 = FreeImage_SaveToMemory(Format, Bitmap, Stream, Flags) + If (FreeImage_SaveToMemoryEx2) Then + FreeImage_SaveToMemoryEx2 = FreeImage_AcquireMemoryEx(Stream, Data) + End If + + ' Do not close the memory stream, since the returned array Data() + ' directly points to the stream's data. The stream handle is passed back + ' to the caller through parameter 'Stream'. The caller must close + ' this stream after being done with the array. + Else + FreeImage_SaveToMemoryEx2 = False + End If + + If (UnloadSource) Then + Call FreeImage_Unload(Bitmap) + End If + End If + +End Function + +Public Function FreeImage_AcquireMemoryEx(ByVal Stream As Long, _ + ByRef Data() As Byte, _ + Optional ByRef SizeInBytes As Long) As Boolean + +Dim lpData As Long +Dim tSA As SAVEARRAY1D +Dim lpSA As Long + + ' This function wraps the byte array passed through parameter 'Data()' around the + ' memory acquired from the specified memory stream. After the function returns, + ' the array passed in 'Data()' points directly to the stream's data pointer and so, + ' provides full read and write access to the streams byte buffer. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + + If (Stream) Then + If (FreeImage_AcquireMemoryInt(Stream, lpData, SizeInBytes)) Then + With tSA + .cbElements = 1 ' one element is one byte + .cDims = 1 ' the array has only 1 dimension + .cElements = SizeInBytes ' the number of elements in the array is + ' the size in bytes of the memory block + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = lpData ' let the array point to the memory block + ' received by FreeImage_AcquireMemory + End With + + lpSA = pDeref(VarPtrArray(Data)) + If (lpSA = 0) Then + ' allocate memory for an array descriptor + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal VarPtrArray(Data), lpSA, 4) + Else + Call SafeArrayDestroyData(lpSA) + End If + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Else + FreeImage_AcquireMemoryEx = False + End If + Else + FreeImage_AcquireMemoryEx = False + End If + +End Function + +Public Function FreeImage_JPEGTransformCombinedFromMemoryEx(ByRef SourceData As Variant, _ + ByRef DestData() As Byte, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long, _ + Optional ByRef SourceSizeInBytes As Long, _ + Optional ByVal Perfect As Boolean = True) As Boolean + +Dim hSrcStream As Long +Dim lSrcDataPtr As Long +Dim hDstStream As Long +Dim lDstDataPtr As Long +Dim lDstSizeInBytes As Long +Dim lPerfect As Long +Dim lResult As Long + + ' This function performs a combination of lossless rotation or flipping and + ' lossless crop on a JPEG file. The source file is loaded from the memory + ' provided through parameter 'SourceData' and the result JPEG file is saved + ' to memory accessible by the byte array passed through parameter 'DestData()'. + + ' The source JPEG file is loaded from the memory that has been passed through + ' parameter 'SourceData'. This parameter is of type Variant and may actually + ' be an array of type Byte, Integer or Long or may contain the address of an + ' arbitrary block of memory. + + ' The parameter 'SourceSizeInBytes' specifies the size of the passed block of + ' memory in bytes. It may be omitted, if parameter 'SourceData' contains an array + ' of type Byte, Integer or Long upon entry. In that case, or if 'SizeInBytes' is + ' zero or less than zero, the size is determined directly from the array and also + ' passed back to the caller through parameter 'SourceSizeInBytes'. + + ' The result JPEG file function is saved to memory that is accessible through + ' the byte array passed in parameter 'DestData()' after the function returns. + ' It makes a deep copy of the memory stream's byte buffer, into which the image + ' has been saved. The memory stream is closed properly before the function + ' returns. + + ' The provided byte array 'DestData()' must not be a fixed sized array. It will + ' be dimensioned to the size required to hold all the memory stream's data. + + ' The parameters 'Operation', 'Left', 'Top', 'Right', 'Bottom' and 'Perfect' work + ' according to the FreeImage API documentation. + + + ' get both pointer and size in bytes of the memory block provided + ' through the Variant parameter 'SourceData'. + lSrcDataPtr = pGetMemoryBlockPtrFromVariant(SourceData, SourceSizeInBytes) + + ' open the source memory stream + hSrcStream = FreeImage_OpenMemoryByPtr(lSrcDataPtr, SourceSizeInBytes) + If (hSrcStream) Then + + ' open the destination memory stream + hDstStream = FreeImage_OpenMemory() + If (hDstStream) Then + + If (Perfect) Then + lPerfect = 1 + End If + + ' perform transformations + lResult = FreeImage_JPEGTransformCombinedFromMemoryInt(hSrcStream, hDstStream, _ + Operation, Left, Top, Right, Bottom, lPerfect) + + If (lResult = 1) Then + ' if the transformations succeeded, access the stream's byte buffer + If (FreeImage_AcquireMemoryInt(hDstStream, lDstDataPtr, lDstSizeInBytes)) Then + On Error Resume Next + ' redim the array + ReDim DestData(lDstSizeInBytes - 1) + If (Err.Number = ERROR_SUCCESS) Then + On Error GoTo 0 + ' and make a deep copy of the stream's byte buffer + Call CopyMemory(DestData(0), ByVal lDstDataPtr, lDstSizeInBytes) + Else + On Error GoTo 0 + lResult = 0 + End If + Else + lResult = 0 + End If + End If + + ' close the destination memory stream + Call FreeImage_CloseMemory(hDstStream) + End If + + ' close the source memory stream + Call FreeImage_CloseMemory(hSrcStream) + End If + + FreeImage_JPEGTransformCombinedFromMemoryEx = (lResult = 1) + +End Function + +Public Function FreeImage_JPEGTransformCombinedFromMemoryEx2(ByRef SourceData As Variant, _ + ByRef DestData() As Byte, _ + ByRef DestStream As Long, _ + ByVal Operation As FREE_IMAGE_JPEG_OPERATION, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long, _ + Optional ByRef SourceSizeInBytes As Long, _ + Optional ByVal Perfect As Boolean = True) As Boolean + +Dim hSrcStream As Long +Dim lSrcDataPtr As Long +Dim lPerfect As Long +Dim bResult As Boolean + + ' This function performs a combination of lossless rotation or flipping and + ' lossless crop on a JPEG file. The source file is loaded from the memory + ' provided through parameter 'SourceData' and the result JPEG file is saved + ' to memory accessible by the byte array passed through parameter 'DestData()'. + + ' The source JPEG file is loaded from the memory that has been passed through + ' parameter 'SourceData'. This parameter is of type Variant and may actually + ' be an array of type Byte, Integer or Long or may contain the address of an + ' arbitrary block of memory. + + ' The parameter 'SourceSizeInBytes' specifies the size of the passed block of + ' memory in bytes. It may be omitted, if parameter 'SourceData' contains an array + ' of type Byte, Integer or Long upon entry. In that case, or if 'SizeInBytes' is + ' zero or less than zero, the size is determined directly from the array and also + ' passed back to the caller through parameter 'SourceSizeInBytes'. + + ' The result JPEG file function is saved to memory that is accessible through the + ' the byte array passed in parameter 'DestData()' after the function returns. + ' In contrast to function 'FreeImage_JPEGTransformCombinedFromMemoryEx', it does + ' not make a deep copy of the memory stream's byte buffer, but directly wraps the + ' array 'DestData()' around the stream's byte buffer by calling function + ' 'FreeImage_AcquireMemoryEx'. As a result, the memory stream must remain valid + ' while the array 'Data()' is in use. In other words, the stream must be + ' maintained by the caller of this function. + + ' The provided byte array 'DestData()' must not be a fixed sized array. It will be + ' dimensioned to the size required to hold all the memory stream's data. + + ' To reuse the caller's array variable that was passed through parameter 'DestData()' + ' before it goes out of the caller's scope, it must first be destroyed by passing it + ' to the 'FreeImage_DestroyLockedArray' function. + + ' The parameter 'DestStream' is an IN/OUT parameter, that keeps track of the memory + ' stream, the VB array 'DestData()' is based on. This parameter may contain an + ' already opened FreeImage memory stream upon entry and will contain a valid + ' memory stream when the function returns. It is left up to the caller to close + ' this memory stream correctly. + + ' The array 'DestData()' will no longer be valid and accessible after the stream has + ' been closed, so the stream should only be closed after the passed byte array + ' variable goes out of the caller's scope or is reused. + + ' The parameters 'Operation', 'Left', 'Top', 'Right', 'Bottom' and 'Perfect' work + ' according to the FreeImage API documentation. + + + ' get both pointer and size in bytes of the memory block provided + ' through the Variant parameter 'SourceData'. + lSrcDataPtr = pGetMemoryBlockPtrFromVariant(SourceData, SourceSizeInBytes) + + ' open the source memory stream + hSrcStream = FreeImage_OpenMemoryByPtr(lSrcDataPtr, SourceSizeInBytes) + If (hSrcStream) Then + + If (DestStream = 0) Then + ' open the destination memory stream, only if no valid stream was provided + DestStream = FreeImage_OpenMemory() + End If + + If (DestStream) Then + + If (Perfect) Then + lPerfect = 1 + End If + + ' perform transformations + bResult = (FreeImage_JPEGTransformCombinedFromMemoryInt(hSrcStream, DestStream, _ + Operation, Left, Top, Right, Bottom, lPerfect) = 1) + + If (bResult) Then + ' if the transformations succeeded, access the stream's byte buffer + bResult = FreeImage_AcquireMemoryEx(DestStream, DestData) + End If + + ' Do not close the memory stream, since the returned array DestData() + ' directly points to the stream's data. The stream handle is passed back + ' to the caller through parameter 'DestStream'. The caller must close + ' this stream after being done with the array. + End If + + ' close the source memory stream + Call FreeImage_CloseMemory(hSrcStream) + End If + + FreeImage_JPEGTransformCombinedFromMemoryEx2 = bResult + +End Function + +Public Function FreeImage_ReadMemoryEx(ByRef Buffer As Variant, _ + ByVal Stream As Long, _ + Optional ByRef Count As Long, _ + Optional ByRef Size As Long) As Long + +Dim lBufferPtr As Long +Dim lSizeInBytes As Long +Dim lSize As Long +Dim lCount As Long + + ' This function is a wrapper for 'FreeImage_ReadMemory()' using VB style + ' arrays instead of a void pointer. + + ' The variant parameter 'Buffer' may be a Byte, Integer or Long array or + ' may contain a pointer to a memory block (the memory block's address). + + ' In the latter case, this function behaves exactly like + ' function 'FreeImage_ReadMemory()'. Then, 'Count' and 'Size' must be valid + ' upon entry. + + ' If 'Buffer' is an initialized (dimensioned) array, 'Count' and 'Size' may + ' be omitted. Then, the array's layout is used to determine 'Count' + ' and 'Size'. In that case, any provided value in 'Count' and 'Size' upon + ' entry will override these calculated values as long as they are not + ' exceeding the size of the array in 'Buffer'. + + ' If 'Buffer' is an uninitialized (not yet dimensioned) array of any valid + ' type (Byte, Integer or Long) and, at least 'Count' is specified, the + ' array in 'Buffer' is redimensioned by this function. If 'Buffer' is a + ' fixed-size or otherwise locked array, a runtime error (10) occurs. + ' If 'Size' is omitted, the array's element size is assumed to be the + ' desired value. + + ' As FreeImage's function 'FreeImage_ReadMemory()', this function returns + ' the number of items actually read. + + ' Example: (very freaky...) + ' + ' Dim alLongBuffer() As Long + ' Dim lRet as Long + ' + ' ' now reading 303 integers (2 byte) into an array of Longs + ' lRet = FreeImage_ReadMemoryEx(alLongBuffer, lMyStream, 303, 2) + ' + ' ' now, lRet contains 303 and UBound(alLongBuffer) is 151 since + ' ' we need at least 152 Longs (0..151) to store (303 * 2) = 606 bytes + ' ' so, the higest two bytes of alLongBuffer(151) contain only unset + ' ' bits. Got it? + + ' Remark: This function's parameter order differs from FreeImage's + ' original funtion 'FreeImage_ReadMemory()'! + + If (VarType(Buffer) And vbArray) Then + ' get both pointer and size in bytes of the memory block provided + ' through the Variant parameter 'Buffer'. + lBufferPtr = pGetMemoryBlockPtrFromVariant(Buffer, lSizeInBytes, lSize) + If (lBufferPtr = 0) Then + ' array is not initialized + If (Count > 0) Then + ' only if we have a 'Count' value, redim the array + If (Size <= 0) Then + ' if 'Size' is omitted, use array's element size + Size = lSize + End If + + Select Case lSize + + Case 2 + ' Remark: -Int(-a) == ceil(a); a > 0 + ReDim Buffer(-Int(-Count * Size / 2) - 1) As Integer + + Case 4 + ' Remark: -Int(-a) == ceil(a); a > 0 + ReDim Buffer(-Int(-Count * Size / 4) - 1) As Long + + Case Else + ReDim Buffer((Count * Size) - 1) As Byte + + End Select + lBufferPtr = pGetMemoryBlockPtrFromVariant(Buffer, lSizeInBytes, lSize) + End If + End If + If (lBufferPtr) Then + lCount = lSizeInBytes / lSize + If (Size <= 0) Then + ' use array's natural value for 'Size' when + ' omitted + Size = lSize + End If + If (Count <= 0) Then + ' use array's natural value for 'Count' when + ' omitted + Count = lCount + End If + If ((Size * Count) > (lSize * lCount)) Then + If (Size = lSize) Then + Count = lCount + Else + ' Remark: -Fix(-a) == floor(a); a > 0 + Count = -Fix(-lSizeInBytes / Size) + If (Count = 0) Then + Size = lSize + Count = lCount + End If + End If + End If + FreeImage_ReadMemoryEx = FreeImage_ReadMemory(lBufferPtr, Size, Count, Stream) + End If + + ElseIf (VarType(Buffer) = vbLong) Then + ' if Buffer is a Long, it specifies the address of a memory block + ' then, we do not know anything about its size, so assume that 'Size' + ' and 'Count' are correct and forward these directly to the FreeImage + ' call. + FreeImage_ReadMemoryEx = FreeImage_ReadMemory(CLng(Buffer), Size, Count, Stream) + + End If + +End Function + +Public Function FreeImage_WriteMemoryEx(ByRef Buffer As Variant, _ + ByVal Stream As Long, _ + Optional ByRef Count As Long, _ + Optional ByRef Size As Long) As Long + +Dim lBufferPtr As Long +Dim lSizeInBytes As Long +Dim lSize As Long +Dim lCount As Long + + ' This function is a wrapper for 'FreeImage_WriteMemory()' using VB style + ' arrays instead of a void pointer. + + ' The variant parameter 'Buffer' may be a Byte, Integer or Long array or + ' may contain a pointer to a memory block (the memory block's address). + + ' In the latter case, this function behaves exactly + ' like 'FreeImage_WriteMemory()'. Then, 'Count' and 'Size' must be valid + ' upon entry. + + ' If 'Buffer' is an initialized (dimensioned) array, 'Count' and 'Size' may + ' be omitted. Then, the array's layout is used to determine 'Count' + ' and 'Size'. In that case, any provided value in 'Count' and 'Size' upon + ' entry will override these calculated values as long as they are not + ' exceeding the size of the array in 'Buffer'. + + ' If 'Buffer' is an uninitialized (not yet dimensioned) array of any + ' type, the function will do nothing an returns 0. + + ' Remark: This function's parameter order differs from FreeImage's + ' original funtion 'FreeImage_ReadMemory()'! + + If (VarType(Buffer) And vbArray) Then + ' get both pointer and size in bytes of the memory block provided + ' through the Variant parameter 'Buffer'. + lBufferPtr = pGetMemoryBlockPtrFromVariant(Buffer, lSizeInBytes, lSize) + If (lBufferPtr) Then + lCount = lSizeInBytes / lSize + If (Size <= 0) Then + ' use array's natural value for 'Size' when + ' omitted + Size = lSize + End If + If (Count <= 0) Then + ' use array's natural value for 'Count' when + ' omitted + Count = lCount + End If + If ((Size * Count) > (lSize * lCount)) Then + If (Size = lSize) Then + Count = lCount + Else + ' Remark: -Fix(-a) == floor(a); a > 0 + Count = -Fix(-lSizeInBytes / Size) + If (Count = 0) Then + Size = lSize + Count = lCount + End If + End If + End If + FreeImage_WriteMemoryEx = FreeImage_WriteMemory(lBufferPtr, Size, Count, Stream) + End If + + ElseIf (VarType(Buffer) = vbLong) Then + ' if Buffer is a Long, it specifies the address of a memory block + ' then, we do not know anything about its size, so assume that 'Size' + ' and 'Count' are correct and forward these directly to the FreeImage + ' call. + FreeImage_WriteMemoryEx = FreeImage_WriteMemory(CLng(Buffer), Size, Count, Stream) + + End If + +End Function + +Public Function FreeImage_LoadMultiBitmapFromMemoryEx(ByRef Data As Variant, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS, _ + Optional ByRef SizeInBytes As Long, _ + Optional ByRef Format As FREE_IMAGE_FORMAT) As Long + +Dim hStream As Long +Dim lDataPtr As Long + + ' This function loads a FreeImage multipage bitmap from memory that has been + ' passed through parameter 'Data'. This parameter is of type Variant and may + ' actually be an array of type Byte, Integer or Long or may contain the + ' address of an arbitrary block of memory. + + ' The parameter 'SizeInBytes' specifies the size of the passed block of memory + ' in bytes. It may be omitted, if parameter 'Data' contains an array of type Byte, + ' Integer or Long upon entry. In that case, or if 'SizeInBytes' is zero or less + ' than zero, the size is determined directly from the array and also passed back + ' to the caller through parameter 'SizeInBytes'. + + ' The parameter 'Format' is an OUT only parameter that contains the image type + ' of the loaded image after the function returns. + + ' The parameter 'Flags' works according to the FreeImage API documentation. + + + ' get both pointer and size in bytes of the memory block provided + ' through the Variant parameter 'Data'. + lDataPtr = pGetMemoryBlockPtrFromVariant(Data, SizeInBytes) + + ' open the memory stream + hStream = FreeImage_OpenMemoryByPtr(lDataPtr, SizeInBytes) + If (hStream) Then + ' on success, detect image type + Format = FreeImage_GetFileTypeFromMemory(hStream) + If (Format <> FIF_UNKNOWN) Then + ' load the image from memory stream only, if known image type + FreeImage_LoadMultiBitmapFromMemoryEx = FreeImage_LoadMultiBitmapFromMemory(Format, _ + hStream, Flags) + End If + ' close the memory stream + Call FreeImage_CloseMemory(hStream) + End If + +End Function + +Public Function FreeImage_SaveMultiBitmapToMemoryEx(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByRef Data() As Byte, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS, _ + Optional ByVal UnloadSource As Boolean) As Boolean + +Dim hStream As Long +Dim lpData As Long +Dim lSizeInBytes As Long + + ' This function saves a FreeImage multipage bitmap into memory and returns it + ' through the byte array passed in parameter 'Data()'. It makes a deep copy of + ' the memory stream's byte buffer, into which the image has been saved. The + ' memory stream is closed properly before the function returns. + + ' The provided byte array 'Data()' must not be a fixed sized array. It will be + ' dimensioned to the size required to hold all the memory stream's data. + + ' The parameters 'Format', 'Bitmap' and 'Flags' work according to the FreeImage + ' API documentation. + + ' The optional 'UnloadSource' parameter is for unloading the original image + ' after it has been saved into memory. There is no need to clean up the DIB + ' at the caller's site. + + ' The function returns True on success and False otherwise. + + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to save a 'header-only' bitmap.") + End If + + hStream = FreeImage_OpenMemory() + If (hStream) Then + FreeImage_SaveMultiBitmapToMemoryEx = FreeImage_SaveMultiBitmapToMemory(Format, _ + Bitmap, hStream, Flags) + If (FreeImage_SaveMultiBitmapToMemoryEx) Then + If (FreeImage_AcquireMemoryInt(hStream, lpData, lSizeInBytes)) Then + On Error Resume Next + ReDim Data(lSizeInBytes - 1) + If (Err.Number = ERROR_SUCCESS) Then + On Error GoTo 0 + Call CopyMemory(Data(0), ByVal lpData, lSizeInBytes) + Else + On Error GoTo 0 + FreeImage_SaveMultiBitmapToMemoryEx = False + End If + Else + FreeImage_SaveMultiBitmapToMemoryEx = False + End If + End If + Call FreeImage_CloseMemory(hStream) + Else + FreeImage_SaveMultiBitmapToMemoryEx = False + End If + + If (UnloadSource) Then + Call FreeImage_CloseMultiBitmapInt(Bitmap) + End If + End If + +End Function + +Public Function FreeImage_SaveMultiBitmapToMemoryEx2(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Bitmap As Long, _ + ByRef Data() As Byte, _ + ByRef Stream As Long, _ + Optional ByVal Flags As FREE_IMAGE_SAVE_OPTIONS, _ + Optional ByVal UnloadSource As Boolean) As Boolean + + ' This function saves a FreeImage multipage bitmap into memory and returns it + ' through the byte array passed in parameter 'Data()'. In contrast to function + ' 'FreeImage_SaveToMemoryEx', it does not make a deep copy of the memory + ' stream's byte buffer, but directly wraps the array 'Data()' around the stream's + ' byte buffer by calling function 'FreeImage_AcquireMemoryEx'. As a result, the + ' memory stream must remain valid while the array 'Data()' is in use. In other + ' words, the stream must be maintained by the caller of this function. + + ' The provided byte array 'Data()' must not be a fixed sized array. It will be + ' dimensioned to the size required to hold all the memory stream's data. + + ' To reuse the caller's array variable that was passed through parameter 'Data()' + ' before it goes out of the caller's scope, it must first be destroyed by passing + ' it to the 'FreeImage_DestroyLockedArray' function. + + ' The parameter 'Stream' is an IN/OUT parameter, that keeps track of the memory + ' stream, the VB array 'Data()' is based on. This parameter may contain an + ' already opened FreeImage memory stream upon entry and will contain a valid + ' memory stream when the function returns. It is left up to the caller to close + ' this memory stream correctly. + + ' The array 'Data()' will no longer be valid and accessible after the stream has + ' been closed, so the stream should only be closed after the passed byte array + ' variable goes out of the caller's scope or is reused. + + ' The parameters 'Format', 'Bitmap' and 'Flags' work according to the FreeImage + ' API documentation. + + ' The optional 'UnloadSource' parameter is for unloading the original image + ' after it has been saved to memory. There is no need to clean up the DIB + ' at the caller's site. + + ' The function returns True on success and False otherwise. + + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to save a 'header-only' bitmap.") + End If + + If (Stream = 0) Then + Stream = FreeImage_OpenMemory() + End If + If (Stream) Then + FreeImage_SaveMultiBitmapToMemoryEx2 = _ + FreeImage_SaveMultiBitmapToMemory(Format, Bitmap, Stream, Flags) + If (FreeImage_SaveMultiBitmapToMemoryEx2) Then + FreeImage_SaveMultiBitmapToMemoryEx2 = FreeImage_AcquireMemoryEx(Stream, Data) + End If + + ' Do not close the memory stream, since the returned array Data() + ' directly points to the stream's data. The stream handle is passed back + ' to the caller through parameter 'Stream'. The caller must close + ' this stream after being done with the array. + Else + FreeImage_SaveMultiBitmapToMemoryEx2 = False + End If + + If (UnloadSource) Then + Call FreeImage_CloseMultiBitmapInt(Bitmap) + End If + End If + +End Function + + + +'-------------------------------------------------------------------------------- +' Tag accessing VB friendly helper functions +'-------------------------------------------------------------------------------- + +Public Function FreeImage_CreateTagEx(ByVal Model As FREE_IMAGE_MDMODEL, _ + Optional ByVal Key As String, _ + Optional ByVal TagType As FREE_IMAGE_MDTYPE = FIDT_NOTYPE, _ + Optional ByRef Value As Variant, _ + Optional ByRef Count As Long, _ + Optional ByVal Id As Long) As FREE_IMAGE_TAG + + ' This function is a wrapper for FreeImage_CreateTag() working with + ' the VB friendly FREE_IMAGE_TAG structure. So, the return value is + ' not a pointer to a FITAG structure but a FREE_IMAGE_TAG structure. + + ' In contrast to FreeImage's original FreeImage_CreateTag() function, the + ' parameter 'Model' must be specified, the parameters 'Key', 'TagType', + ' 'Value', 'Count' and 'Id' my be specified. + + ' The 'Model' is needed, since each FREE_IMAGE_TAG structure needs a + ' valid 'Model' member. + + ' All other parameters are optional and enable the caller to specify the tag's + ' values upon tag creation. Any parameter specified, is set to it's corresponding + ' member in the FREE_IMAGE_TAG structure. + + ' The caller should check the returned FREE_IMAGE_TAG structure's 'TagPtr' member. + ' If this function succeeded, the 'TagPtr' member is non zero. A value of zero + ' indicates an error condition sourced from FreeImage_CreateTag(). + + With FreeImage_CreateTagEx + .TagPtr = FreeImage_CreateTag() + If (.TagPtr <> 0) Then + .Model = Model + If (LenB(Key) > 0) Then + .Key = Key + End If + .Type = TagType + .Count = Count + .Id = Id + If (Not IsMissing(Value)) Then + .Value = Value + End If + Call pTagToTagPtr(FreeImage_CreateTagEx) + FreeImage_CreateTagEx = pGetTagFromTagPtr(Model, .TagPtr) + End If + End With + +End Function + +Public Function FreeImage_AppendTag(ByVal Bitmap As Long, _ + ByVal Model As FREE_IMAGE_MDMODEL, _ + Optional ByVal Key As String, _ + Optional ByVal TagType As FREE_IMAGE_MDTYPE = FIDT_NOTYPE, _ + Optional ByRef Value As Variant, _ + Optional ByRef Count As Long, _ + Optional ByVal Id As Long, _ + Optional ByVal OverwriteExisting As Boolean = True) As FREE_IMAGE_TAG + +Dim lpTag As Long + + ' This function is a shortcut wrapper for FreeImage_CreateTagEx() and + ' FreeImage_SetMetadataEx(). It creates a new tag as FreeImage_CreateTagEx() does + ' and appends it to the image's metadata model. + + ' The parameter 'Bitmap' specifies the image, the new tag should be appended to, + ' parameters 'Model', 'Key', 'TagType', 'Value', 'Count' and 'Id' are these, + ' FreeImage_CreateTagEx() has and are just forwarded unchanged. + + ' The boolean parameter 'OverwriteExisting' determines, whether to overwrite or + ' replace an already existing tag with the newly created. If the tag specified + ' by it's model and key already exists and 'OverwriteExisting' is False, an + ' empty FREE_IMAGE_TAG structure is returned. + + ' So, as with FreeImage_CreateTagEx(), the caller should check the returned + ' FREE_IMAGE_TAG structure's 'TagPtr' member. If this function succeeded, the + ' 'TagPtr' member is non zero. A value of zero indicates an error condition + ' sourced from either the FreeImage_CreateTag() function or may result from + ' an already existing tag that should not be overwritten. + + If ((FreeImage_GetMetadataInt(Model, Bitmap, Key, lpTag) = 0) Or _ + (OverwriteExisting)) Then + + FreeImage_AppendTag = FreeImage_CreateTagEx(Model, Key, TagType, Value, Count, Id) + If (FreeImage_AppendTag.TagPtr <> 0) Then + Call FreeImage_SetMetadataEx(Bitmap, FreeImage_AppendTag, Key, Model, True) + End If + End If + +End Function + +Public Function FreeImage_RemoveTag(ByVal Bitmap As Long, _ + ByVal Model As FREE_IMAGE_MDMODEL, _ + ByVal Key As String) As Boolean + + ' This function is a wrapper function, that removes a tag, that is actually + ' part of an image's metadata model. The tag named 'key' of the metadata + ' model specified in parameter 'Model' of the image 'Bitmap' will be removed. + + ' Removing a tag is actually done by calling FreeImage_SetMetadata() with + ' a NULL pointer for 'FITAG *tag' as described in the API documentation. + + ' The function returns the boolean value returned from FreeImage_SetMetadata(), + ' which is always TRUE when removing a tag in this fashion. So, this function's + ' caller has no feedback telling if the tag was really present and removed + ' successfully. + + ' Up to version 3.9.1 of FreeImage, there seems to be a bug in removing an + ' tag from an image's metadata model. Although the removed tag is not accessible + ' through FreeImage_GetMetadata() any more, iterations with + ' Freeimage_FindFirst/NextMetadata() will still return this tag an a NULL + ' pointer. + + ' This bug was reported on the Developers Forum. You can revisit the posting at: + ' http://sourceforge.net/forum/forum.php?thread_id=1536883&forum_id=36111 + + FreeImage_RemoveTag = (FreeImage_SetMetadataInt(Model, Bitmap, Key, 0) <> 0) + +End Function + +Public Function FreeImage_RemoveTagEx(ByVal Bitmap As Long, _ + ByRef Tag As FREE_IMAGE_TAG) As Boolean + + ' This function is a FREE_IMAGE_TAG based wrapper for FreeImage_RemoveTag() + + With Tag + FreeImage_RemoveTagEx = FreeImage_RemoveTag(Bitmap, .Model, .Key) + End With + +End Function + +Public Function FreeImage_TagExists(ByVal Bitmap As Long, _ + ByVal Model As FREE_IMAGE_MDMODEL, _ + Optional ByVal Key As String) As Boolean + +Dim lpTag As Long + + ' This function is a small helper function, returning a boolean value + ' that determines, whether a certain tag specified by metadata model + ' and key exists for an image specified by 'Bitmap'. + + FreeImage_TagExists = (FreeImage_GetMetadataInt(Model, Bitmap, Key, lpTag) <> 0) + +End Function + +Public Function FreeImage_TagExistsEx(ByVal Bitmap As Long, _ + ByRef Tag As FREE_IMAGE_TAG) As Boolean + + ' This function is a FREE_IMAGE_TAG based wrapper for FreeImage_TagExists() + + With Tag + FreeImage_TagExistsEx = FreeImage_TagExists(Bitmap, .Model, .Key) + End With + +End Function + +Public Sub FreeImage_DeleteTagEx(ByRef Tag As FREE_IMAGE_TAG) + + ' This function is a wrapper for FreeImage_DeleteTag() working with + ' the VB friendly FREE_IMAGE_TAG structure. So, the parameter 'Tag' + ' is not a pointer to a FITAG structure but a FREE_IMAGE_TAG structure. + + ' This function deletes the underlaying FreeImage FITAG structure, + ' specified the the member 'TagPtr' of the FREE_IMAGE_TAG structure + ' and also sets all other members of Tag to a null value. + + ' Do not get confused with the wrapper functions FreeImage_RemoveTag() + ' and FreeImage_RemoveTagEx(). These functions remove a tag from an + ' image's metadata model. This function only deletes of frees (a better + ' name would be 'FreeImage_FreeTag') a tag created with + ' FreeImage_CreateTagEx(). Do not delete any tags obtained from any other + ' function. + + With Tag + If (.TagPtr <> 0) Then + Call FreeImage_DeleteTag(.TagPtr) + End If + .TagPtr = 0 + .Count = 0 + .Description = vbNullString + .Id = 0 + .Key = vbNullString + .Length = 0 + .Model = FIMD_NODATA + Erase .Palette + Erase .RationalValue + .StringValue = vbNullString + .Type = FIDT_NOTYPE + .Value = Empty + End With + +End Sub + +Public Function FreeImage_CloneTagEx(ByRef Tag As FREE_IMAGE_TAG, _ + Optional ByVal Model As FREE_IMAGE_MDMODEL = FIMD_NODATA) As FREE_IMAGE_TAG + + ' This function is a thin wrapper for FreeImage_CloneTag() working with + ' the VB friendly FREE_IMAGE_TAG structure. The parameter 'Tag' works + ' according to the FreeImage API documentation expect that Tag is not a + ' pointer to a FITAG structure but a FREE_IMAGE_TAG structure. + + ' The additional optional paremeter 'Model' is needed, since the + ' transformation from a FreeImage FITAG structure to the VB friendly + ' FREE_IMAGE_TAG structure always need the model to be specified. + ' When 'Model' is missing (equal to FREE_IMAGE_TAG), the model to be + ' used is taken from the Tag's member 'Model' itself. + + ' See function FreeImage_FindNextMetadataEx() to learn more about the + ' optional parameter 'Model' + + ' Tags obtained from FreeImage_CloneTagEx() must be deleted with + ' FreeImage_DeleteTagEx() as long as they are not used with + ' FreeImage_SetMetadataEx() with the parameter 'RefreshTag' set to True. + + If (Tag.TagPtr <> 0) Then + If (Model = FIMD_NODATA) Then + Model = Tag.Model + End If + FreeImage_CloneTagEx = pGetTagFromTagPtr(Model, FreeImage_CloneTag(Tag.TagPtr)) + End If + +End Function + +Public Function FreeImage_RemoveMetadataModel(ByVal Bitmap As Long, _ + ByVal Model As FREE_IMAGE_MDMODEL) As Boolean + + ' This function removes a complete metadata model 'Model' from an image specified + ' by 'Bitmap'. + + If (Model <> FIMD_NODATA) Then + FreeImage_RemoveMetadataModel = (FreeImage_SetMetadataInt(Model, Bitmap, vbNullString, 0) <> 0) + End If + +End Function + +Public Function FreeImage_FindFirstMetadataEx(ByVal Model As FREE_IMAGE_MDMODEL, _ + ByVal Bitmap As Long, _ + ByRef Tag As FREE_IMAGE_TAG) As Long + + ' This function is a wrapper for FreeImage_FindFirstMetadata() working with + ' the VB friendly FREE_IMAGE_TAG structure. All parameters 'Bitmap', 'Tag', + ' and 'Model' as the function's return value work according to the + ' FreeImage API documentation expect that Tag is not a pointer to a FITAG + ' structure but a FREE_IMAGE_TAG structure. + + ' Tags obtained from FreeImage_GetMetadataEx() must not be deleted with + ' FreeImage_DeleteTagEx(). + + With Tag + FreeImage_FindFirstMetadataEx = FreeImage_FindFirstMetadata(Model, Bitmap, .TagPtr) + If (FreeImage_FindFirstMetadataEx <> 0) Then + Tag = pGetTagFromTagPtr(Model, .TagPtr) + End If + End With + +End Function + +Public Function FreeImage_FindNextMetadataEx(ByVal hFind As Long, _ + ByRef Tag As FREE_IMAGE_TAG, _ + Optional ByVal Model As FREE_IMAGE_MDMODEL = FIMD_NODATA) As Boolean + + ' This function is a wrapper for FreeImage_FindNextMetadataEx() working with + ' the VB friendly FREE_IMAGE_TAG structure. All parameters 'hFind' and 'Tag' + ' as the function's return value work according to the FreeImage API + ' documentation expect that Tag is not a pointer to a FITAG structure but a + ' FREE_IMAGE_TAG structure. + + ' The additional optional paremeter 'Model' is needed, since the VB friendly + ' FREE_IMAGE_TAG structure also contains the member 'StringValue'. This member + ' is filled with the result of FreeImage_TagToString() which always needs + ' the model to be specified. Since there should be no static oder global + ' variables id the FreeImage VB wrapper, the model must be known each time + ' a FreeImage FITAG structure is converted to a FREE_IMAGE_TAG structure. + ' (A global VB collection could be used to map the hFind to the model, + ' but we don't want any globals here) + + ' So, when 'Model' is missing (equal to FREE_IMAGE_TAG), the model to be used + ' is taken from the Tag's member 'Model' itself. This is useful when using this + ' function in a loop iterating all tags per model (what else would you do + ' with that function?). The Tag's member 'Model' is populated by + ' FreeImage_FindFirstMetadataEx() and remains valid during the whole loop, ready + ' to be used in this function. + + ' Tags obtained from FreeImage_GetMetadataEx() must not be deleted with + ' FreeImage_DeleteTagEx(). + + With Tag + FreeImage_FindNextMetadataEx = (FreeImage_FindNextMetadataInt(hFind, .TagPtr) <> 0) + If (FreeImage_FindNextMetadataEx) Then + If (Model = FIMD_NODATA) Then + Model = .Model + End If + Tag = pGetTagFromTagPtr(Model, .TagPtr) + End If + End With + +End Function + +Public Function FreeImage_GetAllMetadataTags(ByVal Model As FREE_IMAGE_MDMODEL, _ + ByVal Bitmap As Long, _ + ByRef Tag() As FREE_IMAGE_TAG) As Long + +Dim hMD As Long +Dim lpTag As Long +Dim i As Long + + ' This function is a helper function returning (through a ByRef parameter) + ' an array of FREE_IMAGE_TAG structures containing all the image's tags of + ' the metadata model specified by the 'Model' parameter. + + ' The parameter 'Tag()' must be an redimensionable array of FREE_IMAGE_TAG + ' and is redimensioned accordingly. The function returns the number of + ' tags stored in 'Tag()'. + + ' All tags obtained from FreeImage_GetAllMetadataTags() must not be deleted + ' with FreeImage_DeleteTagEx(). + + i = FreeImage_GetMetadataCount(Model, Bitmap) + If (i > 0) Then + ReDim Tag(i - 1) + FreeImage_GetAllMetadataTags = i + i = 0 + hMD = FreeImage_FindFirstMetadata(Model, Bitmap, lpTag) + If (hMD <> 0) Then + Do + Tag(i) = pGetTagFromTagPtr(Model, lpTag) + i = i + 1 + Loop While (FreeImage_FindNextMetadataInt(hMD, lpTag) <> 0) + Call FreeImage_FindCloseMetadata(hMD) + End If + End If + +End Function + +Public Function FreeImage_GetMetadataEx(ByVal Model As FREE_IMAGE_MDMODEL, _ + ByVal Bitmap As Long, _ + ByVal Key As String, _ + ByRef Tag As FREE_IMAGE_TAG) As Boolean + + ' This function is a wrapper for FreeImage_GetMetadata() working with + ' the VB friendly FREE_IMAGE_TAG structure. All parameters 'Bitmap', 'Tag', + ' 'Key' and 'Model' as well as the function's return value work according + ' to the FreeImage API documentation expect that Tag is not a pointer to + ' a FITAG structure but to a FREE_IMAGE_TAG structure. + + ' Tags obtained from FreeImage_GetMetadataEx() must not be deleted with + ' FreeImage_DeleteTagEx(). + + With Tag + If (FreeImage_GetMetadataInt(Model, Bitmap, Key, .TagPtr) <> 0) Then + Tag = pGetTagFromTagPtr(Model, .TagPtr) + FreeImage_GetMetadataEx = True + End If + End With + +End Function + +Public Function FreeImage_SetMetadataEx(ByVal Bitmap As Long, _ + ByRef Tag As FREE_IMAGE_TAG, _ + Optional ByVal Key As String, _ + Optional ByVal Model As FREE_IMAGE_MDMODEL = FIMD_NODATA, _ + Optional ByVal RefreshTag As Boolean) As Boolean + + ' This function is a wrapper for FreeImage_SetMetadata() using the wrapper's + ' VB friendly FREE_IMAGE_TAG structure as an replacement for the original + ' function's pointer to a FITAG structure. + + ' All parameters 'Bitmap', 'Tag', 'Key' and 'Model' as the function's return value + ' work according to the FreeImage API documentation expect that Tag is not a + ' pointer to a FITAG structure but a FREE_IMAGE_TAG structure. + + ' As with FreeImage_SetMetadata(), this function sould only be called with + ' new tags, created with FreeImage_CreateTagEx(), a wrapper function for + ' FreeImage_CreateTag() working with the VB friendly FREE_IMAGE_TAG structure. + + ' Normally, after a newly created tag must be deleted/freed with a call to + ' FreeImage_DeleteTagEx(), a wrapper function for FreeImage_DeleteTag() working + ' with the VB friendly FREE_IMAGE_TAG structure (bored already?), after + ' the tag was appended to an image's metadata model with + ' FreeImage_SetMetadataEx(). But... + + ' There is a wrapper specific additional boolean parameter 'RefreshTag', that + ' is similar to the parameter 'UnloadSource' found in many wrapper functions. + ' When 'RefreshTag' is True upon entry, the tag specified in the 'Tag' + ' parameter is deleted (the underlaying FITAG structure is deleted with + ' FreeImage_DeteleTag() and all other members of the FREE_IMAGE_TAG structure + ' are set to null values) and is reassigned with the tag, that is now part + ' of the image's metadata model. The tag now referenced in the 'Tag' + ' parameter must NOT be deleted any more by the caller of this function, since + ' this tag refers to the actual tag data stored with the image. This is like + ' a FREE_IMAGE_TAG structure obtained from FreeImage_GetMetadata() or + ' FreeImage_FindFirst/NextMetadata(). Any changes made to this FREE_IMAGE_TAG + ' structure may be applied to the image with a later call to + ' FreeImage_UpdateMetadata(). + + + With Tag + If (Model = FIMD_NODATA) Then + Model = .Model + End If + If (LenB(Key) = 0) Then + Key = .Key + End If + If (FreeImage_SetMetadataInt(Model, Bitmap, Key, .TagPtr) <> 0) Then + FreeImage_SetMetadataEx = True + End If + If (RefreshTag) Then + Call FreeImage_DeleteTagEx(Tag) + Call FreeImage_GetMetadataEx(Model, Bitmap, Key, Tag) + End If + End With + +End Function + +Public Function FreeImage_GetImageComment(ByVal Bitmap As Long) As String + +Dim tTag As FREE_IMAGE_TAG + + ' This function is a small wrapper around FreeImage_GetMetadata() that + ' returns the comment of a JPEG, PNG of GIF image. + + If (FreeImage_GetMetadataEx(FIMD_COMMENTS, Bitmap, "Comment", tTag)) Then + FreeImage_GetImageComment = tTag.Value + End If + +End Function + +Public Function FreeImage_SetImageComment(ByVal Bitmap As Long, _ + Optional ByVal Comment As String) As Boolean + +Dim tTag As FREE_IMAGE_TAG + + ' This function is a small wrapper around FreeImage_SetMetadata() that + ' sets the comment of a JPEG, PNG of GIF image. + + If (LenB(Comment) > 0) Then + tTag = FreeImage_AppendTag(Bitmap, FIMD_COMMENTS, "Comment", FIDT_ASCII, Comment) + FreeImage_SetImageComment = (tTag.TagPtr <> 0) + Else + Call FreeImage_RemoveMetadataModel(Bitmap, FIMD_COMMENTS) + FreeImage_SetImageComment = True + End If + +End Function + +Public Function FreeImage_CopyMetadata(ByVal BitmapSrc As Long, _ + ByVal BitmapDst As Long, _ + Optional ByVal ReplaceExisting As Boolean = True, _ + Optional ByVal Model As FREE_IMAGE_MDMODEL = FIMD_NODATA) As Long + +Dim hMDFind As Long +Dim lpTag As Long +Dim strKey As String +Dim bSetTag As Boolean + + ' This derived helper function copies several metadata tags from one + ' image to another. This is useful when cloning images explicitly with + ' FreeImage_Clone() or implicitly with FreeImage_ConvertColorDepth() or + ' with any of the FreeImage_RescaleXXX() functions. Whenever the "same" + ' image is represented by a new 'Bitmap' pointer, the image was internally + ' recreated. All of the data, associated with the image, like metadata, + ' DPI settings or ICC profiles are no more available in the new version of + ' the image. + + ' Setting the DPI for X and Y direction is quite easy with the wrapper + ' functions FreeImage_Get/SetResolutionX/Y(). This function makes it even + ' easier to keep track of all associated metadata tags for a cloned image! + + ' Both parameters 'BitmapSrc' and 'BitmapDst' specify the source and destination + ' image. Metadata is copied from 'BitmapSrc' to 'BitmapDst'. + + ' The optional parameter 'ReplaceExisting' determines whether existing tags + ' should be replaced or not. If there are no tags in 'BitmapDst' it is recommended, + ' to set 'ReplaceExisting' to True (or to omit it, since True is it's default + ' value) for better performance; when set to True, no tests for tag existence + ' in the destination image will be run. + + ' The optional parameter 'Model' may specify a certain metadata model to be + ' copied. If this parameter is omitted or set to any value not defined in the + ' FREE_IMAGE_MDMODEL enumeration, all metadata models will be copied + ' sequentially. + + ' This function returns the number of tags copied or zero when there are no tags + ' in the source image or an error occured. + + ' For the standard use case described above (keeping track of all metadata after + ' an image was cloned) the calling this function boils down to a very short form: + + ' lTagsCopied = FreeImage_CopyMetadata(hDibSrc, hDibDst) + + If ((BitmapSrc <> 0) And (BitmapDst <> 0)) Then + If ((Model >= FIMD_COMMENTS) And (Model <= FIMD_CUSTOM)) Then + hMDFind = FreeImage_FindFirstMetadata(Model, BitmapSrc, lpTag) + If (hMDFind) Then + Do + strKey = pGetStringFromPointerA(pDeref(pDeref(lpTag))) + bSetTag = ReplaceExisting + If (Not bSetTag) Then + bSetTag = (Not FreeImage_TagExists(BitmapDst, Model, strKey)) + End If + If (bSetTag) Then + If (FreeImage_SetMetadataInt(Model, BitmapDst, strKey, lpTag) <> 0) Then + FreeImage_CopyMetadata = FreeImage_CopyMetadata + 1 + End If + End If + Loop While (FreeImage_FindNextMetadata(hMDFind, lpTag)) + Call FreeImage_FindCloseMetadata(hMDFind) + End If + Else + For Model = FIMD_COMMENTS To FIMD_CUSTOM + FreeImage_CopyMetadata = FreeImage_CopyMetadata _ + + FreeImage_CopyMetadata(BitmapSrc, BitmapDst, _ + ReplaceExisting, Model) + Next Model + End If + End If + +End Function + +Public Function FreeImage_CloneMetadataEx(ByVal BitmapSrc As Long, _ + ByVal BitmapDst As Long, _ + Optional ByVal Model As FREE_IMAGE_MDMODEL = FIMD_NODATA) As Long + + ' This derived helper function copies several metadata tags from one + ' image to another. It is very similar to FreeImage_CopyMetadata(). + + ' The main difference is, that this function aims to create exactly the same + ' metadata layout in the destination image. In contrast to + ' FreeImage_CopyMetadata(), this function removes all metadata tags in the + ' desination image that are not part of the metadata set in the source image. + ' So, this function is particularly useful for destination images that may + ' have already some tags associated and you want to make shure, that it will + ' get exactly the same metadata set as the source image. + + ' This function will most likely be used in a end user application and should + ' be invoked through a menu command called: "Set/Apply Metadata From Source Image..." + + ' This function returns the number of tags copied or zero if there are no tags + ' in the source image or an error occured. + + If ((BitmapSrc <> 0) And (BitmapDst <> 0)) Then + If ((Model >= FIMD_COMMENTS) And (Model <= FIMD_CUSTOM)) Then + If (FreeImage_RemoveMetadataModel(BitmapDst, Model)) Then + FreeImage_CloneMetadataEx = FreeImage_CopyMetadata(BitmapSrc, BitmapDst, _ + True, Model) + End If + Else + For Model = FIMD_COMMENTS To FIMD_CUSTOM + FreeImage_CloneMetadataEx = FreeImage_CloneMetadataEx _ + + FreeImage_CloneMetadataEx(BitmapSrc, BitmapDst, _ + Model) + Next Model + End If + End If + +End Function + +Public Function FreeImage_TagFromPointer(ByVal Model As FREE_IMAGE_MDMODEL, _ + ByVal Tag As Long) As FREE_IMAGE_TAG + + ' This is a generic function that returns a VB wrapper Tag + ' structure (FREE_IMAGE_TAG) from a FreeImage FITAG *tag pointer. + + ' This function is still public due to legacy reasons. Since there are + ' functions like 'FreeImage_GetMetadataEx()', 'FreeImage_GetAllMetadataTags()' + ' or 'FreeImage_FindFirst/NextMetadataEx()', this function won't be needed + ' any more in most cases. + + FreeImage_TagFromPointer = pGetTagFromTagPtr(Model, Tag) + +End Function + +Public Function FreeImage_UpdateMetadata(ByRef Tag As FREE_IMAGE_TAG) As Boolean + + ' This function updates any changes made in a FREE_IMAGE_TAG + ' structure. + + FreeImage_UpdateMetadata = pTagToTagPtr(Tag) + +End Function + +Public Function FreeImage_UnsignedLong(ByVal Value As Long) As Variant + + ' This function converts a signed long (VB's Long data type) into + ' an unsigned long (not really supported by VB). + + ' Basically, this function checks, whether the positive range of + ' a signed long is sufficient to hold the value (indeed, it checks + ' the value since the range is obviously constant). If yes, + ' it returns a Variant with subtype Long ('Variant/Long' in VB's + ' watch window). In this case, the function did not make any real + ' changes at all. If not, the value is stored in a Currency variable, + ' which is able to store the whole range of an unsigned long. Then, + ' the function returns a Variant with subtype Currency + ' ('Variant/Currency' in VB's watch window). + + If (Value < 0) Then + Dim curTemp As Currency + Call CopyMemory(curTemp, Value, 4) + FreeImage_UnsignedLong = curTemp * 10000 + Else + FreeImage_UnsignedLong = Value + End If + +End Function + +Public Function FreeImage_UnsignedShort(ByVal Value As Integer) As Variant + + ' This function converts a signed short (VB's Integer data type) into + ' an unsigned short (not really supported by VB). + + ' Basically, this function checks, whether the positive range of + ' a signed short is sufficient to hold the value (indeed, it checks + ' the value since the range is obviously constant). If yes, + ' it returns a Variant with subtype Integer ('Variant/Integer' in VB's + ' watch window). In this case, the function did not make any real + ' changes at all. If not, the value is stored in a Long variable, + ' which is able to store the whole range of an unsigned short. Then, + ' the function returns a Variant with subtype Long + ' ('Variant/Long' in VB's watch window). + + If (Value < 0) Then + Dim lTemp As Long + Call CopyMemory(lTemp, Value, 2) + FreeImage_UnsignedShort = lTemp + Else + FreeImage_UnsignedShort = Value + End If + +End Function + +Public Function FreeImage_CreateRational(ByRef Numerator As Variant, _ + ByRef Denominator As Variant, _ + Optional ByVal NormalizeValue As Boolean = True) As FIRATIONAL + + ' This function creates an unsigned rational (FIDT_RATIONAL) value to be used with + ' FreeImage's metadata models. In the VB wrapper, any rational value is stored in a + ' structure (FIRATIONAL), containing both 'Numerator' and 'Denominator' members. The + ' rational's value is then defined as the fraction Numerator/Denominator. + + ' Both values 'Numerator' and 'Denominator' are actually ULONGs (unsigned longs), a + ' data type not supported by VB (a VB Long variable is always signed). Therefore, + ' 'Numerator' and 'Denominator' are typed as Variant. Whenever the range of a signed + ' long is sufficient to store the value (all values between 0 and 0x7FFFFFFF + ' (2147483647 decimal)), the Variant gets a Long subtype. If not, a Currency subtype is + ' used just to give you the mathematical correct value of the unsigned long. + + ' The optional parameter 'NormalizeValue' controls, whether the resulting fraction + ' should be normalized (cancelled down) or not. + + ' When calling this function, you can use hexadecimal constants for passing unsinged + ' longs via the parameters 'Numerator' and 'Denominator'. + + ' 2147483647 + ' Example: tRational = FreeImage_CreateRational(&HFFFFFFFF, 12345) -> ---------- + ' 12345 + + With FreeImage_CreateRational + .Numerator = FreeImage_UnsignedLong(Numerator) + .Denominator = FreeImage_UnsignedLong(Denominator) + End With + + If (NormalizeValue) Then + Call pNormalizeRational(FreeImage_CreateRational) + End If + +End Function + +Public Function FreeImage_CreateSignedRational(ByRef Numerator As Variant, _ + ByRef Denominator As Variant, _ + Optional ByVal NormalizeValue As Boolean = True) As FIRATIONAL + + ' This function creates a signed rational (FIDT_RATIONAL) value to be used with + ' FreeImage's metadata models. In the VB wrapper, any rational value is stored in a + ' structure (FIRATIONAL), containing both 'Numerator' and 'Denominator' members. The + ' rational's value is then defined as the fraction Numerator/Denominator. + + ' Both values 'Numerator' and 'Denominator' are actually LONGs (signed longs), the + ' same data type as a VB Long. Since, 'Numerator' and 'Denominator' are typed as + ' Variant, all possible values between -2,147,483,648 and + 2,147,483,647 are stored + ' in a Variant with subtype Long (cp. 'FreeImage_CreateRational()'). + + ' The optional parameter 'NormalizeValue' controls, whether the resulting fraction + ' should be normalized (cancelled down) or not. + + ' When calling this function, you can use hexadecimal constants for passing unsinged + ' longs via the parameters 'Numerator' and 'Denominator'. + + ' -1 1 + ' Example: tRational = FreeImage_CreateSignedRational(&HFFFFFFFF, 12345) -> ----- = - ----- + ' 12345 12345 + + With FreeImage_CreateSignedRational + .Numerator = CLng(Numerator) + .Denominator = CLng(Denominator) + End With + + If (NormalizeValue) Then + Call pNormalizeSRational(FreeImage_CreateSignedRational) + End If + +End Function + + + +'-------------------------------------------------------------------------------- +' Derived and hopefully useful functions +'-------------------------------------------------------------------------------- + +' Plugin and filename functions + +Public Function FreeImage_IsExtensionValidForFIF(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Extension As String, _ + Optional ByVal Compare As VbCompareMethod = vbBinaryCompare) As Boolean + + ' This function tests, whether a given filename extension is valid + ' for a certain image format (fif). + + FreeImage_IsExtensionValidForFIF = (InStr(1, _ + FreeImage_GetFIFExtensionList(Format) & ",", _ + Extension & ",", _ + Compare) > 0) + +End Function + +Public Function FreeImage_IsFilenameValidForFIF(ByVal Format As FREE_IMAGE_FORMAT, _ + ByVal Filename As String, _ + Optional ByVal Compare As VbCompareMethod = vbBinaryCompare) As Boolean + +Dim strExtension As String +Dim i As Long + + ' This function tests, whether a given complete filename is valid + ' for a certain image format (fif). + + i = InStrRev(Filename, ".") + If (i > 0) Then + strExtension = Mid$(Filename, i + 1) + FreeImage_IsFilenameValidForFIF = (InStr(1, _ + FreeImage_GetFIFExtensionList(Format) & ",", _ + strExtension & ",", _ + Compare) > 0) + End If + +End Function + +Public Function FreeImage_GetPrimaryExtensionFromFIF(ByVal Format As FREE_IMAGE_FORMAT) As String + +Dim strExtensionList As String +Dim i As Long + + ' This function returns the primary (main or most commonly used?) extension + ' of a certain image format (fif). This is done by returning the first of + ' all possible extensions returned by FreeImage_GetFIFExtensionList(). That + ' assumes, that the plugin returns the extensions in ordered form. If not, + ' in most cases it is even enough, to receive any extension. + + ' This function is primarily used by the function 'SavePictureEx'. + + strExtensionList = FreeImage_GetFIFExtensionList(Format) + i = InStr(strExtensionList, ",") + If (i > 0) Then + FreeImage_GetPrimaryExtensionFromFIF = Left$(strExtensionList, i - 1) + Else + FreeImage_GetPrimaryExtensionFromFIF = strExtensionList + End If + +End Function + +Public Function FreeImage_IsGreyscaleImage(ByVal Bitmap As Long) As Boolean + +Dim atRGB() As RGBQUAD +Dim i As Long + + ' This function returns a boolean value that is true, if the DIB is actually + ' a greyscale image. Here, the only test condition is, that each palette + ' entry must be a grey value, what means that each color component has the + ' same value (red = green = blue). + + ' The FreeImage libraray doesn't offer a function to determine if a DIB is + ' greyscale. The only thing you can do is to use the 'FreeImage_GetColorType' + ' function, that returns either FIC_MINISWHITE or FIC_MINISBLACK for + ' greyscale images. However, a DIB needs to have a ordered greyscale palette + ' (linear ramp or inverse linear ramp) to be judged as FIC_MINISWHITE or + ' FIC_MINISBLACK. DIB's with an unordered palette that are actually (visually) + ' greyscale, are said to be (color-)palletized. That's also true for any 4 bpp + ' image, since it will never have a palette that satifies the tests done + ' in the 'FreeImage_GetColorType' function. + + ' So, there is a chance to omit some color depth conversions, when displaying + ' an image in greyscale fashion. Maybe the problem will be solved in the + ' FreeImage library one day. + + Select Case FreeImage_GetBPP(Bitmap) + + Case 1, 4, 8 + atRGB = FreeImage_GetPaletteEx(Bitmap) + FreeImage_IsGreyscaleImage = True + For i = 0 To UBound(atRGB) + With atRGB(i) + If ((.rgbRed <> .rgbGreen) Or (.rgbRed <> .rgbBlue)) Then + FreeImage_IsGreyscaleImage = False + Exit For + End If + End With + Next i + + End Select + +End Function + +' Bitmap resolution functions + +Public Function FreeImage_GetResolutionX(ByVal Bitmap As Long) As Long + + ' This function gets a DIB's resolution in X-direction measured + ' in 'dots per inch' (DPI) and not in 'dots per meter'. + + FreeImage_GetResolutionX = Int(0.5 + 0.0254 * FreeImage_GetDotsPerMeterX(Bitmap)) + +End Function + +Public Sub FreeImage_SetResolutionX(ByVal Bitmap As Long, ByVal Resolution As Long) + + ' This function sets a DIB's resolution in X-direction measured + ' in 'dots per inch' (DPI) and not in 'dots per meter'. + + Call FreeImage_SetDotsPerMeterX(Bitmap, Int(Resolution / 0.0254 + 0.5)) + +End Sub + +Public Function FreeImage_GetResolutionY(ByVal Bitmap As Long) As Long + + ' This function gets a DIB's resolution in Y-direction measured + ' in 'dots per inch' (DPI) and not in 'dots per meter'. + + FreeImage_GetResolutionY = Int(0.5 + 0.0254 * FreeImage_GetDotsPerMeterY(Bitmap)) + +End Function + +Public Sub FreeImage_SetResolutionY(ByVal Bitmap As Long, ByVal Resolution As Long) + + ' This function sets a DIB's resolution in Y-direction measured + ' in 'dots per inch' (DPI) and not in 'dots per meter'. + + Call FreeImage_SetDotsPerMeterY(Bitmap, Int(Resolution / 0.0254 + 0.5)) + +End Sub + +' ICC Color Profile functions + +Public Function FreeImage_GetICCProfile(ByVal Bitmap As Long) As FIICCPROFILE + + ' This function is a wrapper for the FreeImage_GetICCProfile() function, returning + ' a real FIICCPROFILE structure. + + ' Since the original FreeImage function returns a pointer to the FIICCPROFILE + ' structure (FIICCPROFILE *), as with string returning functions, this wrapper is + ' needed as VB can't declare a function returning a pointer to anything. So, + ' analogous to string returning functions, FreeImage_GetICCProfile() is declared + ' private as FreeImage_GetICCProfileInt() and made publicly available with this + ' wrapper function. + + Call CopyMemory(FreeImage_GetICCProfile, _ + ByVal FreeImage_GetICCProfileInt(Bitmap), _ + LenB(FreeImage_GetICCProfile)) + +End Function + +Public Function FreeImage_GetICCProfileColorModel(ByVal Bitmap As Long) As FREE_IMAGE_ICC_COLOR_MODEL + + ' This function is a thin wrapper around FreeImage_GetICCProfile() returning + ' the color model in which the ICC color profile data is in, if there is actually + ' a ICC color profile available for the Bitmap specified. + + ' If there is NO color profile along with that bitmap, this function returns the color + ' model that should (or must) be used for any color profile data to be assigned to the + ' Bitmap. That depends on the bitmap's color type. + + If (FreeImage_HasICCProfile(Bitmap)) Then + FreeImage_GetICCProfileColorModel = (pDeref(FreeImage_GetICCProfileInt(Bitmap)) _ + And FREE_IMAGE_ICC_COLOR_MODEL_MASK) + Else + ' use FreeImage_GetColorType() to determine, whether this is a CMYK bitmap or not + If (FreeImage_GetColorType(Bitmap) = FIC_CMYK) Then + FreeImage_GetICCProfileColorModel = FIICC_COLOR_MODEL_CMYK + Else + FreeImage_GetICCProfileColorModel = FIICC_COLOR_MODEL_RGB + End If + End If + +End Function + +Public Function FreeImage_GetICCProfileSize(ByVal Bitmap As Long) As Long + + ' This function is a thin wrapper around FreeImage_GetICCProfile() returning + ' only the size in bytes of the ICC profile data for the Bitmap specified or zero, + ' if there is no ICC profile data for the Bitmap. + + FreeImage_GetICCProfileSize = pDeref(FreeImage_GetICCProfileInt(Bitmap) + 4) + +End Function + +Public Function FreeImage_GetICCProfileDataPointer(ByVal Bitmap As Long) As Long + + ' This function is a thin wrapper around FreeImage_GetICCProfile() returning + ' only the pointer (the address) of the ICC profile data for the Bitmap specified, + ' or zero if there is no ICC profile data for the Bitmap. + + FreeImage_GetICCProfileDataPointer = pDeref(FreeImage_GetICCProfileInt(Bitmap) + 8) + +End Function + +Public Function FreeImage_HasICCProfile(ByVal Bitmap As Long) As Boolean + + ' This function is a thin wrapper around FreeImage_GetICCProfile() returning + ' True, if there is an ICC color profile available for the Bitmap specified or + ' returns False otherwise. + + FreeImage_HasICCProfile = (FreeImage_GetICCProfileSize(Bitmap) <> 0) + +End Function + +' Bitmap Info functions + +Public Function FreeImage_GetInfoHeaderEx(ByVal Bitmap As Long) As BITMAPINFOHEADER + +Dim lpInfoHeader As Long + + ' This function is a wrapper around FreeImage_GetInfoHeader() and returns a fully + ' populated BITMAPINFOHEADER structure for a given bitmap. + + lpInfoHeader = FreeImage_GetInfoHeader(Bitmap) + If (lpInfoHeader) Then + Call CopyMemory(FreeImage_GetInfoHeaderEx, ByVal lpInfoHeader, LenB(FreeImage_GetInfoHeaderEx)) + End If + +End Function + +' Image color depth conversion wrapper + +Public Function FreeImage_ConvertColorDepth(ByVal Bitmap As Long, _ + ByVal Conversion As FREE_IMAGE_CONVERSION_FLAGS, _ + Optional ByVal UnloadSource As Boolean, _ + Optional ByVal Threshold As Byte = 128, _ + Optional ByVal DitherMethod As FREE_IMAGE_DITHER = FID_FS, _ + Optional ByVal QuantizeMethod As FREE_IMAGE_QUANTIZE = FIQ_WUQUANT) As Long + +Dim hDIBNew As Long +Dim hDIBTemp As Long +Dim lBPP As Long +Dim bForceLinearRamp As Boolean +Dim lpReservePalette As Long +Dim bAdjustReservePaletteSize As Boolean + + ' This function is an easy-to-use wrapper for color depth conversion, intended + ' to work around some tweaks in the FreeImage library. + + ' The parameters 'Threshold' and 'eDitherMode' control how thresholding or + ' dithering are performed. The 'QuantizeMethod' parameter determines, what + ' quantization algorithm will be used when converting to 8 bit color images. + + ' The 'Conversion' parameter, which can contain a single value or an OR'ed + ' combination of some of the FREE_IMAGE_CONVERSION_FLAGS enumeration values, + ' determines the desired output image format. + + ' The optional 'UnloadSource' parameter is for unloading the original image, so + ' you can "change" an image with this function rather than getting a new DIB + ' pointer. There is no more need for a second DIB variable at the caller's site. + + bForceLinearRamp = ((Conversion And FICF_REORDER_GREYSCALE_PALETTE) = 0) + lBPP = FreeImage_GetBPP(Bitmap) + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to convert a 'header-only' bitmap.") + End If + + Select Case (Conversion And (Not FICF_REORDER_GREYSCALE_PALETTE)) + + Case FICF_MONOCHROME_THRESHOLD + If (lBPP > 1) Then + hDIBNew = FreeImage_Threshold(Bitmap, Threshold) + End If + + Case FICF_MONOCHROME_DITHER + If (lBPP > 1) Then + hDIBNew = FreeImage_Dither(Bitmap, DitherMethod) + End If + + Case FICF_GREYSCALE_4BPP + If (lBPP <> 4) Then + ' If the color depth is 1 bpp and the we don't have a linear ramp palette + ' the bitmap is first converted to an 8 bpp greyscale bitmap with a linear + ' ramp palette and then to 4 bpp. + If ((lBPP = 1) And (FreeImage_GetColorType(Bitmap) = FIC_PALETTE)) Then + hDIBTemp = Bitmap + Bitmap = FreeImage_ConvertToGreyscale(Bitmap) + Call FreeImage_Unload(hDIBTemp) + End If + hDIBNew = FreeImage_ConvertTo4Bits(Bitmap) + Else + ' The bitmap is already 4 bpp but may not have a linear ramp. + ' If we force a linear ramp the bitmap is converted to 8 bpp with a linear ramp + ' and then back to 4 bpp. + If (((Not bForceLinearRamp) And (Not FreeImage_IsGreyscaleImage(Bitmap))) Or _ + (bForceLinearRamp And (FreeImage_GetColorType(Bitmap) = FIC_PALETTE))) Then + hDIBTemp = FreeImage_ConvertToGreyscale(Bitmap) + hDIBNew = FreeImage_ConvertTo4Bits(hDIBTemp) + Call FreeImage_Unload(hDIBTemp) + End If + End If + + Case FICF_GREYSCALE_8BPP + ' Convert, if the bitmap is not at 8 bpp or does not have a linear ramp palette. + If ((lBPP <> 8) Or (((Not bForceLinearRamp) And (Not FreeImage_IsGreyscaleImage(Bitmap))) Or _ + (bForceLinearRamp And (FreeImage_GetColorType(Bitmap) = FIC_PALETTE)))) Then + hDIBNew = FreeImage_ConvertToGreyscale(Bitmap) + End If + + Case FICF_PALLETISED_8BPP + ' note, that the FreeImage library only quantizes 24 bit images + ' do not convert any 8 bit images + If (lBPP <> 8) Then + ' images with a color depth of 24 bits can directly be + ' converted with the FreeImage_ColorQuantize function; + ' other images need to be converted to 24 bits first + If (lBPP = 24) Then + hDIBNew = FreeImage_ColorQuantize(Bitmap, QuantizeMethod) + Else + hDIBTemp = FreeImage_ConvertTo24Bits(Bitmap) + hDIBNew = FreeImage_ColorQuantize(hDIBTemp, QuantizeMethod) + Call FreeImage_Unload(hDIBTemp) + End If + End If + + Case FICF_RGB_15BPP + If (lBPP <> 15) Then + hDIBNew = FreeImage_ConvertTo16Bits555(Bitmap) + End If + + Case FICF_RGB_16BPP + If (lBPP <> 16) Then + hDIBNew = FreeImage_ConvertTo16Bits565(Bitmap) + End If + + Case FICF_RGB_24BPP + If (lBPP <> 24) Then + hDIBNew = FreeImage_ConvertTo24Bits(Bitmap) + End If + + Case FICF_RGB_32BPP + If (lBPP <> 32) Then + hDIBNew = FreeImage_ConvertTo32Bits(Bitmap) + End If + + End Select + + If (hDIBNew) Then + FreeImage_ConvertColorDepth = hDIBNew + If (UnloadSource) Then + Call FreeImage_Unload(Bitmap) + End If + Else + FreeImage_ConvertColorDepth = Bitmap + End If + + End If + +End Function + +Public Function FreeImage_ColorQuantizeEx(ByVal Bitmap As Long, _ + Optional ByVal QuantizeMethod As FREE_IMAGE_QUANTIZE = FIQ_WUQUANT, _ + Optional ByVal UnloadSource As Boolean, _ + Optional ByVal PaletteSize As Long = 256, _ + Optional ByVal ReserveSize As Long, _ + Optional ByRef ReservePalette As Variant = Null) As Long + +Dim hTmp As Long +Dim lpPalette As Long +Dim lBlockSize As Long +Dim lElementSize As Long + + ' This function is a more VB-friendly wrapper around FreeImage_ColorQuantizeEx, + ' which lets you specify the ReservePalette to be used not only as a pointer, but + ' also as a real VB-style array of type Long, where each Long item takes a color + ' in ARGB format (&HAARRGGBB). The native FreeImage function FreeImage_ColorQuantizeEx + ' is declared private and named FreeImage_ColorQuantizeExInt and so hidden from the + ' world outside the wrapper. + + ' In contrast to the FreeImage API documentation, ReservePalette is of type Variant + ' and may either be a pointer to palette data (pointer to an array of type RGBQUAD + ' == VarPtr(atMyPalette(0)) in VB) or an array of type Long, which then must contain + ' the palette data in ARGB format. You can receive palette data as an array Longs + ' from function FreeImage_GetPaletteExLong. + ' Although ReservePalette is of type Variant, arrays of type RGBQUAD can not be + ' passed, as long as RGBQUAD is not declared as a public type in a public object + ' module. So, when dealing with RGBQUAD arrays, you are stuck on VarPtr or may + ' use function FreeImage_GetPalettePtr, which is a more meaningfully named + ' convenience wrapper around VarPtr. + + ' The optional 'UnloadSource' parameter is for unloading the original image, so + ' you can "change" an image with this function rather than getting a new DIB + ' pointer. There is no more need for a second DIB variable at the caller's site. + + ' All other parameters work according to the FreeImage API documentation. + + ' Note: Currently, any provided ReservePalette is only used, if quantize is + ' FIQ_NNQUANT. This seems to be either a bug or an undocumented + ' limitation of the FreeImage library (up to version 3.11.0). + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to quantize a 'header-only' bitmap.") + End If + + If (FreeImage_GetBPP(Bitmap) <> 24) Then + hTmp = Bitmap + Bitmap = FreeImage_ConvertTo24Bits(Bitmap) + If (UnloadSource) Then + Call FreeImage_Unload(hTmp) + End If + UnloadSource = True + End If + + ' adjust PaletteSize + If (PaletteSize < 2) Then + PaletteSize = 2 + ElseIf (PaletteSize > 256) Then + PaletteSize = 256 + End If + + lpPalette = pGetMemoryBlockPtrFromVariant(ReservePalette, lBlockSize, lElementSize) + FreeImage_ColorQuantizeEx = FreeImage_ColorQuantizeExInt(Bitmap, QuantizeMethod, _ + PaletteSize, ReserveSize, lpPalette) + + If (UnloadSource) Then + Call FreeImage_Unload(Bitmap) + End If + End If + +End Function + +Public Function FreeImage_GetPalettePtr(ByRef Palette() As RGBQUAD) As Long + + ' Returns a pointer to an array of RGBQUAD. This is sometimes referred to as + ' a palette. + + FreeImage_GetPalettePtr = VarPtr(Palette(0)) + +End Function + + +' Image Rescale wrapper functions + +Public Function FreeImage_RescaleEx(ByVal Bitmap As Long, _ + Optional ByVal Width As Variant, _ + Optional ByVal Height As Variant, _ + Optional ByVal IsPercentValue As Boolean, _ + Optional ByVal UnloadSource As Boolean, _ + Optional ByVal Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC, _ + Optional ByVal ForceCloneCreation As Boolean) As Long + +Dim lNewWidth As Long +Dim lNewHeight As Long +Dim hDIBNew As Long + + ' This function is a easy-to-use wrapper for rescaling an image with the + ' FreeImage library. It returns a pointer to a new rescaled DIB provided + ' by FreeImage. + + ' The parameters 'Width', 'Height' and 'IsPercentValue' control + ' the size of the new image. Here, the function tries to fake something like + ' overloading known from Java. It depends on the parameter's data type passed + ' through the Variant, how the provided values for width and height are + ' actually interpreted. The following rules apply: + + ' In general, non integer values are either interpreted as percent values or + ' factors, the original image size will be multiplied with. The 'IsPercentValue' + ' parameter controls whether the values are percent values or factors. Integer + ' values are always considered to be the direct new image size, not depending on + ' the original image size. In that case, the 'IsPercentValue' parameter has no + ' effect. If one of the parameters is omitted, the image will not be resized in + ' that direction (either in width or height) and keeps it's original size. It is + ' possible to omit both, but that makes actually no sense. + + ' The following table shows some of possible data type and value combinations + ' that might by used with that function: (assume an original image sized 100x100 px) + + ' Parameter | Values | Values | Values | Values | Values | + ' ---------------------------------------------------------------------- + ' Width | 75.0 | 0.85 | 200 | 120 | 400.0 | + ' Height | 120.0 | 1.3 | 230 | - | 400.0 | + ' IsPercentValue | True | False | d.c. | d.c. | False | <- wrong option? + ' ---------------------------------------------------------------------- + ' Result Size | 75x120 | 85x130 | 200x230 | 120x100 |40000x40000 | + ' Remarks | percent | factor | direct | |maybe not | + ' |what you | + ' |wanted, | + ' |right? | + + ' The optional 'UnloadSource' parameter is for unloading the original image, so + ' you can "change" an image with this function rather than getting a new DIB + ' pointer. There is no more need for a second DIB variable at the caller's site. + + ' As of version 2.0 of the FreeImage VB wrapper, this function and all it's derived + ' functions like FreeImage_RescaleByPixel() or FreeImage_RescaleByPercent(), do NOT + ' return a clone of the image, if the new size desired is the same as the source + ' image's size. That behaviour can be forced by setting the new parameter + ' 'ForceCloneCreation' to True. Then, an image is also rescaled (and so + ' effectively cloned), if the new width and height is exactly the same as the source + ' image's width and height. + + ' Since this diversity may be confusing to VB developers, this function is also + ' callable through three different functions called 'FreeImage_RescaleByPixel', + ' 'FreeImage_RescaleByPercent' and 'FreeImage_RescaleByFactor'. + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to rescale a 'header-only' bitmap.") + End If + + If (Not IsMissing(Width)) Then + Select Case VarType(Width) + + Case vbDouble, vbSingle, vbDecimal, vbCurrency + lNewWidth = FreeImage_GetWidth(Bitmap) * Width + If (IsPercentValue) Then + lNewWidth = lNewWidth / 100 + End If + + Case Else + lNewWidth = Width + + End Select + End If + + If (Not IsMissing(Height)) Then + Select Case VarType(Height) + + Case vbDouble, vbSingle, vbDecimal + lNewHeight = FreeImage_GetHeight(Bitmap) * Height + If (IsPercentValue) Then + lNewHeight = lNewHeight / 100 + End If + + Case Else + lNewHeight = Height + + End Select + End If + + If ((lNewWidth > 0) And (lNewHeight > 0)) Then + If (ForceCloneCreation) Then + hDIBNew = FreeImage_Rescale(Bitmap, lNewWidth, lNewHeight, Filter) + + ElseIf ((lNewWidth <> FreeImage_GetWidth(Bitmap)) Or _ + (lNewHeight <> FreeImage_GetHeight(Bitmap))) Then + hDIBNew = FreeImage_Rescale(Bitmap, lNewWidth, lNewHeight, Filter) + + End If + + ElseIf (lNewWidth > 0) Then + If ((lNewWidth <> FreeImage_GetWidth(Bitmap)) Or _ + (ForceCloneCreation)) Then + lNewHeight = lNewWidth / (FreeImage_GetWidth(Bitmap) / FreeImage_GetHeight(Bitmap)) + hDIBNew = FreeImage_Rescale(Bitmap, lNewWidth, lNewHeight, Filter) + End If + + ElseIf (lNewHeight > 0) Then + If ((lNewHeight <> FreeImage_GetHeight(Bitmap)) Or _ + (ForceCloneCreation)) Then + lNewWidth = lNewHeight * (FreeImage_GetWidth(Bitmap) / FreeImage_GetHeight(Bitmap)) + hDIBNew = FreeImage_Rescale(Bitmap, lNewWidth, lNewHeight, Filter) + End If + + End If + + If (hDIBNew) Then + FreeImage_RescaleEx = hDIBNew + If (UnloadSource) Then + Call FreeImage_Unload(Bitmap) + End If + Else + FreeImage_RescaleEx = Bitmap + End If + End If + +End Function + +Public Function FreeImage_RescaleByPixel(ByVal Bitmap As Long, _ + Optional ByVal WidthInPixels As Long, _ + Optional ByVal HeightInPixels As Long, _ + Optional ByVal UnloadSource As Boolean, _ + Optional ByVal Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC, _ + Optional ByVal ForceCloneCreation As Boolean) As Long + + ' Thin wrapper for function 'FreeImage_RescaleEx' for removing method + ' overload fake. This function rescales the image directly to the size + ' specified by the 'WidthInPixels' and 'HeightInPixels' parameters. + + FreeImage_RescaleByPixel = FreeImage_RescaleEx(Bitmap, WidthInPixels, HeightInPixels, False, _ + UnloadSource, Filter, ForceCloneCreation) + +End Function + +Public Function FreeImage_RescaleByPercent(ByVal Bitmap As Long, _ + Optional ByVal WidthPercentage As Double, _ + Optional ByVal HeightPercentage As Double, _ + Optional ByVal UnloadSource As Boolean, _ + Optional ByVal Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC, _ + Optional ByVal ForceCloneCreation As Boolean) As Long + + ' Thin wrapper for function 'FreeImage_RescaleEx' for removing method + ' overload fake. This function rescales the image by a percent value + ' based on the image's original size. + + FreeImage_RescaleByPercent = FreeImage_RescaleEx(Bitmap, WidthPercentage, HeightPercentage, True, _ + UnloadSource, Filter, ForceCloneCreation) + +End Function + +Public Function FreeImage_RescaleByFactor(ByVal Bitmap As Long, _ + Optional ByVal WidthFactor As Double, _ + Optional ByVal HeightFactor As Double, _ + Optional ByVal UnloadSource As Boolean, _ + Optional ByVal Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC, _ + Optional ByVal ForceCloneCreation As Boolean) As Long + + ' Thin wrapper for function 'FreeImage_RescaleEx' for removing method + ' overload fake. This function rescales the image by a factor + ' based on the image's original size. + + FreeImage_RescaleByFactor = FreeImage_RescaleEx(Bitmap, WidthFactor, HeightFactor, False, _ + UnloadSource, Filter, ForceCloneCreation) + +End Function + +' Painting functions + +Public Function FreeImage_PaintDC(ByVal hDC As Long, _ + ByVal Bitmap As Long, _ + Optional ByVal XDst As Long, _ + Optional ByVal YDst As Long, _ + Optional ByVal XSrc As Long, _ + Optional ByVal YSrc As Long, _ + Optional ByVal Width As Long, _ + Optional ByVal Height As Long) As Long + + ' This function draws a FreeImage DIB directly onto a device context (DC). There + ' are many (selfexplaining?) parameters that control the visual result. + + ' Parameters 'XDst' and 'YDst' specify the point where the output should + ' be painted and 'XSrc', 'YSrc', 'Width' and 'Height' span a rectangle + ' in the source image 'Bitmap' that defines the area to be painted. + + ' If any of parameters 'Width' and 'Height' is zero, it is transparently substituted + ' by the width or height of teh bitmap to be drawn, resprectively. + + If ((hDC <> 0) And (Bitmap <> 0)) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to paint a 'header-only' bitmap.") + End If + + If (Width = 0) Then + Width = FreeImage_GetWidth(Bitmap) + End If + + If (Height = 0) Then + Height = FreeImage_GetHeight(Bitmap) + End If + + FreeImage_PaintDC = SetDIBitsToDevice(hDC, XDst, YDst - YSrc, Width, Height, XSrc, YSrc, 0, _ + Height, FreeImage_GetBits(Bitmap), FreeImage_GetInfo(Bitmap), DIB_RGB_COLORS) + End If + +End Function + +Public Function FreeImage_PaintDCEx(ByVal hDC As Long, _ + ByVal Bitmap As Long, _ + Optional ByVal XDst As Long, _ + Optional ByVal YDst As Long, _ + Optional ByVal WidthDst As Long, _ + Optional ByVal HeightDst As Long, _ + Optional ByVal XSrc As Long, _ + Optional ByVal YSrc As Long, _ + Optional ByVal WidthSrc As Long, _ + Optional ByVal HeightSrc As Long, _ + Optional ByVal DrawMode As DRAW_MODE = DM_DRAW_DEFAULT, _ + Optional ByVal RasterOperator As RASTER_OPERATOR = ROP_SRCCOPY, _ + Optional ByVal StretchMode As STRETCH_MODE = SM_COLORONCOLOR) As Long + +Dim eLastStretchMode As STRETCH_MODE + + ' This function draws a FreeImage DIB directly onto a device context (DC). There + ' are many (selfexplaining?) parameters that control the visual result. + + ' The main difference of this function compared to the 'FreeImage_PaintDC' is, + ' that this function supports both mirroring and stretching of the image to be + ' painted and so, is somewhat slower than 'FreeImage_PaintDC'. + + If ((hDC <> 0) And (Bitmap <> 0)) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to paint a 'header-only' bitmap.") + End If + + eLastStretchMode = GetStretchBltMode(hDC) + Call SetStretchBltMode(hDC, StretchMode) + + If (WidthSrc = 0) Then + WidthSrc = FreeImage_GetWidth(Bitmap) + End If + If (WidthDst = 0) Then + WidthDst = WidthSrc + End If + + If (HeightSrc = 0) Then + HeightSrc = FreeImage_GetHeight(Bitmap) + End If + If (HeightDst = 0) Then + HeightDst = HeightSrc + End If + + If (DrawMode And DM_MIRROR_VERTICAL) Then + YDst = YDst + HeightDst + HeightDst = -HeightDst + End If + + If (DrawMode And DM_MIRROR_HORIZONTAL) Then + XDst = XDst + WidthDst + WidthDst = -WidthDst + End If + + Call StretchDIBits(hDC, XDst, YDst, WidthDst, HeightDst, XSrc, YSrc, WidthSrc, HeightSrc, _ + FreeImage_GetBits(Bitmap), FreeImage_GetInfo(Bitmap), DIB_RGB_COLORS, _ + RasterOperator) + + ' restore last mode + Call SetStretchBltMode(hDC, eLastStretchMode) + End If + +End Function + +Public Function FreeImage_PaintTransparent(ByVal hDC As Long, _ + ByVal Bitmap As Long, _ + Optional ByVal XDst As Long = 0, _ + Optional ByVal YDst As Long = 0, _ + Optional ByVal WidthDst As Long, _ + Optional ByVal HeightDst As Long, _ + Optional ByVal XSrc As Long = 0, _ + Optional ByVal YSrc As Long = 0, _ + Optional ByVal WidthSrc As Long, _ + Optional ByVal HeightSrc As Long, _ + Optional ByVal Alpha As Byte = 255) As Long + +Dim lpPalette As Long +Dim bIsTransparent As Boolean + + ' This function paints a device independent bitmap to any device context and + ' thereby honors any transparency information associated with the bitmap. + ' Furthermore, through the 'Alpha' parameter, an overall transparency level + ' may be specified. + + ' For palletised images, any color set to be transparent in the transparency + ' table, will be transparent. For high color images, only 32-bit images may + ' have any transparency information associated in their alpha channel. Only + ' these may be painted with transparency by this function. + + ' Since this is a wrapper for the Windows GDI function AlphaBlend(), 31-bit + ' images, containing alpha (or per-pixel) transparency, must be 'premultiplied' + ' for alpha transparent regions to actually show transparent. See MSDN help + ' on the AlphaBlend() function. + + ' FreeImage also offers a function to premultiply 32-bit bitmaps with their alpha + ' channel, according to the needs of AlphaBlend(). Have a look at function + ' FreeImage_PreMultiplyWithAlpha(). + + ' Overall transparency level may be specified for all bitmaps in all color + ' depths supported by FreeImage. If needed, bitmaps are transparently converted + ' to 32-bit and unloaded after the paint operation. This is also true for palletised + ' bitmaps. + + ' Parameters 'hDC' and 'Bitmap' seem to be very self-explanatory. All other parameters + ' are optional. The group of '*Dest*' parameters span a rectangle on the destination + ' device context, used as drawing area for the bitmap. If these are omitted, the + ' bitmap will be drawn starting at position 0,0 in the bitmap's actual size. + ' The group of '*Src*' parameters span a rectangle on the source bitmap, used as + ' cropping area for the paint operation. If both rectangles differ in size in any + ' direction, the part of the image actually painted is stretched for to fit into + ' the drawing area. If any of the parameters '*Width' or '*Height' are omitted, + ' the bitmap's actual size (width or height) will be used. + + ' The 'Alpha' parameter specifies the overall transparency. It takes values in the + ' range from 0 to 255. Using 0 will paint the bitmap fully transparent, 255 will + ' paint the image fully opaque. The 'Alpha' value controls, how the non per-pixel + ' portions of the image will be drawn. + + If ((hDC <> 0) And (Bitmap <> 0)) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to paint a 'header-only' bitmap.") + End If + + ' get image width if not specified + If (WidthSrc = 0) Then + WidthSrc = FreeImage_GetWidth(Bitmap) + End If + If (WidthDst = 0) Then + WidthDst = WidthSrc + End If + + ' get image height if not specified + If (HeightSrc = 0) Then + HeightSrc = FreeImage_GetHeight(Bitmap) + End If + If (HeightDst = 0) Then + HeightDst = HeightSrc + End If + + lpPalette = FreeImage_GetPalette(Bitmap) + If (lpPalette) Then + + Dim lPaletteSize As Long + Dim alPalOrg(255) As Long + Dim alPalMod(255) As Long + Dim alPalMask(255) As Long + Dim abTT() As Byte + Dim i As Long + + lPaletteSize = FreeImage_GetColorsUsed(Bitmap) * 4 + Call CopyMemory(alPalOrg(0), ByVal lpPalette, lPaletteSize) + Call CopyMemory(alPalMod(0), ByVal lpPalette, lPaletteSize) + abTT = FreeImage_GetTransparencyTableEx(Bitmap) + + If ((Alpha = 255) And _ + (HeightDst >= HeightSrc) And (WidthDst >= WidthSrc)) Then + + ' create a mask palette and a modified version of the + ' original palette + For i = 0 To UBound(abTT) + If (abTT(i) = 0) Then + alPalMask(i) = &HFFFFFFFF ' white + alPalMod(i) = &H0 ' black + bIsTransparent = True + End If + Next i + + If (Not bIsTransparent) Then + + ' if there is no transparency in the image, paint it with + ' a single SRCCOPY + Call StretchDIBits(hDC, _ + XDst, YDst, WidthDst, HeightDst, _ + XSrc, YSrc, WidthSrc, HeightSrc, _ + FreeImage_GetBits(Bitmap), _ + FreeImage_GetInfo(Bitmap), _ + DIB_RGB_COLORS, SRCCOPY) + Else + + ' set mask palette and paint with SRCAND + Call CopyMemory(ByVal lpPalette, alPalMask(0), lPaletteSize) + Call StretchDIBits(hDC, _ + XDst, YDst, WidthDst, HeightDst, _ + XSrc, YSrc, WidthSrc, HeightSrc, _ + FreeImage_GetBits(Bitmap), _ + FreeImage_GetInfo(Bitmap), _ + DIB_RGB_COLORS, SRCAND) + + ' set mask modified and paint with SRCPAINT + Call CopyMemory(ByVal lpPalette, alPalMod(0), lPaletteSize) + Call StretchDIBits(hDC, _ + XDst, YDst, WidthDst, HeightDst, _ + XSrc, YSrc, WidthSrc, HeightSrc, _ + FreeImage_GetBits(Bitmap), _ + FreeImage_GetInfo(Bitmap), _ + DIB_RGB_COLORS, SRCPAINT) + + ' restore original palette + Call CopyMemory(ByVal lpPalette, alPalOrg(0), lPaletteSize) + End If + + ' we are done, do not paint with AlphaBlend() any more + Bitmap = 0 + Else + + ' create a premultiplied palette + ' since we have no real per pixel transparency in a palletized + ' image, we only need to set all transparent colors to zero. + For i = 0 To UBound(abTT) + If (abTT(i) = 0) Then + alPalMod(i) = 0 + End If + Next i + + ' set premultiplied palette and convert to 32 bits + Call CopyMemory(ByVal lpPalette, alPalMod(0), lPaletteSize) + Bitmap = FreeImage_ConvertTo32Bits(Bitmap) + + ' restore original palette + Call CopyMemory(ByVal lpPalette, alPalOrg(0), lPaletteSize) + End If + End If + + If (Bitmap) Then + Dim hMemDC As Long + Dim hBitmap As Long + Dim hBitmapOld As Long + Dim tBF As BLENDFUNCTION + Dim lBF As Long + + hMemDC = CreateCompatibleDC(0) + If (hMemDC) Then + hBitmap = FreeImage_GetBitmap(Bitmap, hMemDC) + hBitmapOld = SelectObject(hMemDC, hBitmap) + + With tBF + .BlendOp = AC_SRC_OVER + .SourceConstantAlpha = Alpha + If (FreeImage_GetBPP(Bitmap) = 32) Then + .AlphaFormat = AC_SRC_ALPHA + End If + End With + Call CopyMemory(lBF, tBF, 4) + + Call AlphaBlend(hDC, XDst, YDst, WidthDst, HeightDst, _ + hMemDC, XSrc, YSrc, WidthSrc, HeightSrc, _ + lBF) + + Call SelectObject(hMemDC, hBitmapOld) + Call DeleteObject(hBitmap) + Call DeleteDC(hMemDC) + If (lpPalette) Then + Call FreeImage_Unload(Bitmap) + End If + End If + End If + End If + +End Function + + +'-------------------------------------------------------------------------------- +' Pixel access functions +'-------------------------------------------------------------------------------- + +Public Function FreeImage_GetBitsEx(ByVal Bitmap As Long) As Byte() + +Dim tSA As SAVEARRAY2D +Dim lpSA As Long + + ' This function returns a two dimensional Byte array containing a DIB's + ' data-bits. This is done by wrapping a true VB array around the memory + ' block the returned pointer of FreeImage_GetBits() is pointing to. So, the + ' array returned provides full read and write acces to the image's data. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the FreeImage_DestroyLockedArray() function. + + If (Bitmap) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 1 ' size in bytes per array element + .cDims = 2 ' the array has 2 dimensions + .cElements1 = FreeImage_GetHeight(Bitmap) ' the number of elements in y direction (height of Bitmap) + .cElements2 = FreeImage_GetPitch(Bitmap) ' the number of elements in x direction (byte width of Bitmap) + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetBits(Bitmap) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' allocate memory for an array descriptor + ' we cannot use the memory block used by tSA, since it is + ' released when tSA goes out of scope, leaving us with an + ' array with zeroed descriptor + ' we use nearly the same method that VB uses, so VB is able + ' to cleanup the array variable and it's descriptor; the + ' array data is not touched when cleaning up, since both AUTO + ' and FIXEDSIZE flags are set + Call SafeArrayAllocDescriptor(2, lpSA) + + ' copy our own array descriptor over the descriptor allocated + ' by SafeArrayAllocDescriptor; lpSA is a pointer to that memory + ' location + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + + ' the implicit variable named like the function is an array + ' variable in VB + ' make it point to the allocated array descriptor + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetBitsEx), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetBitsExRGBTRIPLE(ByVal Bitmap As Long) As RGBTRIPLE() + +Dim tSA As SAVEARRAY2D +Dim lpSA As Long + + ' This function returns a two dimensional RGBTRIPLE array containing a DIB's + ' data-bits. This is done by wrapping a true VB array around the memory + ' block the returned pointer of 'FreeImage_GetBits' is pointing to. So, the + ' array returned provides full read and write acces to the image's data. + + ' This function only works with 24 bpp images and, since each FreeImage scanline + ' is aligned to a 32-bit boundary, only if the image's width in pixels multiplied + ' by three modulo four is zero. That means, that the image layout in memory must + ' "naturally" be aligned to a 32-bit boundary, since arrays do not support padding. + + ' So, the function only returns an initialized array, if this equotion is true: + ' (((ImageWidthPixels * 3) Mod 4) = 0) + + ' In other words, this is true for all images with no padding. + + ' For instance, only images with these widths will be suitable for this function: + ' 100, 104, 108, 112, 116, 120, 124, ... + + ' Have a look at the wrapper function 'FreeImage_GetScanlinesRGBTRIPLE()' to have + ' a way to work around that limitation. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + If (Bitmap) Then + + If (FreeImage_GetBPP(Bitmap) = 24) Then + If (((FreeImage_GetWidth(Bitmap) * 3) Mod 4) = 0) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 3 ' size in bytes per array element + .cDims = 2 ' the array has 2 dimensions + .cElements1 = FreeImage_GetHeight(Bitmap) ' the number of elements in y direction (height of Bitmap) + .cElements2 = FreeImage_GetWidth(Bitmap) ' the number of elements in x direction (byte width of Bitmap) + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetBits(Bitmap) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' allocate memory for an array descriptor + ' we cannot use the memory block used by tSA, since it is + ' released when tSA goes out of scope, leaving us with an + ' array with zeroed descriptor + ' we use nearly the same method that VB uses, so VB is able + ' to cleanup the array variable and it's descriptor; the + ' array data is not touched when cleaning up, since both AUTO + ' and FIXEDSIZE flags are set + Call SafeArrayAllocDescriptor(2, lpSA) + + ' copy our own array descriptor over the descriptor allocated + ' by SafeArrayAllocDescriptor; lpSA is a pointer to that memory + ' location + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + + ' the implicit variable named like the function is an array + ' variable in VB + ' make it point to the allocated array descriptor + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetBitsExRGBTRIPLE), lpSA, 4) + Else + + ' we could throw an error here + End If + Else + + ' we could throw an error here + End If + End If + +End Function + +Public Function FreeImage_GetBitsExRGBQUAD(ByVal Bitmap As Long) As RGBQUAD() + +Dim tSA As SAVEARRAY2D +Dim lpSA As Long + + ' This function returns a two dimensional RGBQUAD array containing a DIB's + ' data-bits. This is done by wrapping a true VB array around the memory + ' block the returned pointer of 'FreeImage_GetBits' is pointing to. So, the + ' array returned provides full read and write acces to the image's data. + + ' This function only works with 32 bpp images. Since each scanline must + ' "naturally" start at a 32-bit boundary if each pixel uses 32 bits, there + ' are no padding problems like these known with 'FreeImage_GetBitsExRGBTRIPLE', + ' so, this function is suitable for all 32 bpp images of any size. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + If (Bitmap) Then + + If (FreeImage_GetBPP(Bitmap) = 32) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 4 ' size in bytes per array element + .cDims = 2 ' the array has 2 dimensions + .cElements1 = FreeImage_GetHeight(Bitmap) ' the number of elements in y direction (height of Bitmap) + .cElements2 = FreeImage_GetWidth(Bitmap) ' the number of elements in x direction (byte width of Bitmap) + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetBits(Bitmap) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' allocate memory for an array descriptor + ' we cannot use the memory block used by tSA, since it is + ' released when tSA goes out of scope, leaving us with an + ' array with zeroed descriptor + ' we use nearly the same method that VB uses, so VB is able + ' to cleanup the array variable and it's descriptor; the + ' array data is not touched when cleaning up, since both AUTO + ' and FIXEDSIZE flags are set + Call SafeArrayAllocDescriptor(2, lpSA) + + ' copy our own array descriptor over the descriptor allocated + ' by SafeArrayAllocDescriptor; lpSA is a pointer to that memory + ' location + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + + ' the implicit variable named like the function is an array + ' variable in VB + ' make it point to the allocated array descriptor + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetBitsExRGBQUAD), lpSA, 4) + Else + + ' we could throw an error here + End If + End If + +End Function + +Public Function FreeImage_GetScanLinesRGBTRIPLE(ByVal Bitmap As Long, _ + ByRef Scanlines As ScanLinesRGBTRIBLE, _ + Optional ByVal Reverse As Boolean) As Long +Dim lHeight As Long +Dim i As Long + + ' still undocumented + ' for now, have a look at function FreeImage_GetBitsExRGBTRIPLE() + + If (Bitmap) Then + If (FreeImage_GetImageType(Bitmap) = FIT_BITMAP) Then + If (FreeImage_GetBPP(Bitmap) = 24) Then + + lHeight = FreeImage_GetHeight(Bitmap) + ReDim Scanlines.Scanline(lHeight - 1) + For i = 0 To lHeight - 1 + If (Not Reverse) Then + Scanlines.Scanline(i).Data = FreeImage_GetScanLineBITMAP24(Bitmap, i) + Else + Scanlines.Scanline(i).Data = FreeImage_GetScanLineBITMAP24(Bitmap, lHeight - i - 1) + End If + Next i + End If + End If + End If + + FreeImage_GetScanLinesRGBTRIPLE = lHeight + +End Function + +Public Function FreeImage_GetScanLineEx(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As Byte() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long + + ' This function returns a one dimensional Byte array containing a whole + ' scanline's data-bits. This is done by wrapping a true VB array around + ' the memory block the returned pointer of 'FreeImage_GetScanline' is + ' pointing to. So, the array returned provides full read and write acces + ' to the image's data. + + ' This is the most generic function of a complete function set dealing with + ' scanline data, since this function returns an array of type Byte. It is + ' up to the caller of the function to interpret these bytes correctly, + ' according to the results of FreeImage_GetBPP and FreeImage_GetImageType. + + ' You may consider using any of the non-generic functions named + ' 'FreeImage_GetScanLineXXX', that return an array of proper type, according + ' to the images bit depth and type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + If (Bitmap) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 1 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetLine(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' allocate memory for an array descriptor + ' we cannot use the memory block used by tSA, since it is + ' released when tSA goes out of scope, leaving us with an + ' array with zeroed descriptor + ' we use nearly the same method that VB uses, so VB is able + ' to cleanup the array variable and it's descriptor; the + ' array data is not touched when cleaning up, since both AUTO + ' and FIXEDSIZE flags are set + Call SafeArrayAllocDescriptor(1, lpSA) + + ' copy our own array descriptor over the descriptor allocated + ' by SafeArrayAllocDescriptor; lpSA is a pointer to that memory + ' location + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + + ' the implicit variable named like the function is an array + ' variable in VB + ' make it point to the allocated array descriptor + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineEx), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetScanLineBITMAP8(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As Byte() + + ' This function returns a one dimensional Byte array containing a whole + ' scanline's data-bits of a 8 bit bitmap image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' This function is just a thin wrapper for 'FreeImage_GetScanLineEx' but + ' includes checking of the image's bit depth and type, as all of the + ' non-generic scanline functions do. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + If (FreeImage_GetImageType(Bitmap) = FIT_BITMAP) Then + Select Case FreeImage_GetBPP(Bitmap) + + Case 1, 4, 8 + FreeImage_GetScanLineBITMAP8 = FreeImage_GetScanLineEx(Bitmap, Scanline) + + End Select + End If + +End Function + +Public Function FreeImage_GetScanLineBITMAP16(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As Integer() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long + + ' This function returns a one dimensional Integer array containing a whole + ' scanline's data-bits of a 16 bit bitmap image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + If (FreeImage_GetImageType(Bitmap) = FIT_BITMAP) Then + If (FreeImage_GetBPP(Bitmap) = 16) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 2 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineBITMAP16), lpSA, 4) + End If + End If + +End Function + +Public Function FreeImage_GetScanLineBITMAP24(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As RGBTRIPLE() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long + + ' This function returns a one dimensional RGBTRIPLE array containing a whole + ' scanline's data-bits of a 24 bit bitmap image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArrayRGBTRIPLE' function. + + If (FreeImage_GetImageType(Bitmap) = FIT_BITMAP) Then + If (FreeImage_GetBPP(Bitmap) = 24) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 3 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineBITMAP24), lpSA, 4) + End If + End If + +End Function + +Public Function FreeImage_GetScanLineBITMAP32(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As RGBQUAD() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long + + ' This function returns a one dimensional RGBQUAD array containing a whole + ' scanline's data-bits of a 32 bit bitmap image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArrayRGBQUAD' function. + + If (FreeImage_GetImageType(Bitmap) = FIT_BITMAP) Then + If (FreeImage_GetBPP(Bitmap) = 32) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 4 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineBITMAP32), lpSA, 4) + End If + End If + +End Function + +Public Function FreeImage_GetScanLineINT16(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As Integer() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long +Dim eImageType As FREE_IMAGE_TYPE + + ' This function returns a one dimensional Integer array containing a whole + ' scanline's data-bits of a FIT_INT16 or FIT_UINT16 image. This is done + ' by wrapping a true VB array around the memory block the returned pointer + ' of 'FreeImage_GetScanline' is pointing to. So, the array returned + ' provides full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' Since VB does not distinguish between signed and unsigned data types, both + ' image types FIT_INT16 and FIT_UINT16 are handled with this function. If 'Bitmap' + ' specifies an image of type FIT_UINT16, it is up to the caller to treat the + ' array's Integers as unsigned, although VB knows signed Integers only. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + eImageType = FreeImage_GetImageType(Bitmap) + If ((eImageType = FIT_INT16) Or _ + (eImageType = FIT_UINT16)) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 2 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineINT16), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetScanLineINT32(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As Long() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long +Dim eImageType As FREE_IMAGE_TYPE + + ' This function returns a one dimensional Long array containing a whole + ' scanline's data-bits of a FIT_INT32 or FIT_UINT32 image. This is done + ' by wrapping a true VB array around the memory block the returned pointer + ' of 'FreeImage_GetScanline' is pointing to. So, the array returned + ' provides full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' Since VB does not distinguish between signed and unsigned data types, both + ' image types FIT_INT32 and FIT_UINT32 are handled with this function. If 'Bitmap' + ' specifies an image of type FIT_UINT32, it is up to the caller to treat the + ' array's Longs as unsigned, although VB knows signed Longs only. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + eImageType = FreeImage_GetImageType(Bitmap) + If ((eImageType = FIT_INT32) Or _ + (eImageType = FIT_UINT32)) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 4 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineINT32), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetScanLineFLOAT(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As Single() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long +Dim eImageType As FREE_IMAGE_TYPE + + ' This function returns a one dimensional Single array containing a whole + ' scanline's data-bits of a FIT_FLOAT image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + eImageType = FreeImage_GetImageType(Bitmap) + If (eImageType = FIT_FLOAT) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 4 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineFLOAT), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetScanLineDOUBLE(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As Double() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long +Dim eImageType As FREE_IMAGE_TYPE + + ' This function returns a one dimensional Double array containing a whole + ' scanline's data-bits of a FIT_DOUBLE image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArray' function. + + eImageType = FreeImage_GetImageType(Bitmap) + If (eImageType = FIT_DOUBLE) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 8 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineDOUBLE), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetScanLineCOMPLEX(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As FICOMPLEX() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long +Dim eImageType As FREE_IMAGE_TYPE + + ' This function returns a one dimensional FICOMPLEX array containing a whole + ' scanline's data-bits of a FIT_COMPLEX image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArrayFICOMPLEX' function. + + eImageType = FreeImage_GetImageType(Bitmap) + If (eImageType = FIT_COMPLEX) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 16 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineCOMPLEX), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetScanLineRGB16(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As FIRGB16() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long +Dim eImageType As FREE_IMAGE_TYPE + + ' This function returns a one dimensional FIRGB16 array containing a whole + ' scanline's data-bits of a FIT_RGB16 image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArrayFIRGB16' function. + + eImageType = FreeImage_GetImageType(Bitmap) + If (eImageType = FIT_RGB16) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 6 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineRGB16), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetScanLineRGBA16(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As FIRGBA16() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long +Dim eImageType As FREE_IMAGE_TYPE + + ' This function returns a one dimensional FIRGBA16 array containing a whole + ' scanline's data-bits of a FIT_RGBA16 image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArrayFIRGBA16' function. + + eImageType = FreeImage_GetImageType(Bitmap) + If (eImageType = FIT_RGBA16) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 8 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineRGBA16), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetScanLineRGBF(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As FIRGBF() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long +Dim eImageType As FREE_IMAGE_TYPE + + ' This function returns a one dimensional FIRGBF array containing a whole + ' scanline's data-bits of a FIT_RGBF image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArrayFIRGBF' function. + + eImageType = FreeImage_GetImageType(Bitmap) + If (eImageType = FIT_RGBF) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 12 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineRGBF), lpSA, 4) + End If + +End Function + +Public Function FreeImage_GetScanLineRGBAF(ByVal Bitmap As Long, _ + ByVal Scanline As Long) As FIRGBAF() + +Dim tSA As SAVEARRAY1D +Dim lpSA As Long +Dim eImageType As FREE_IMAGE_TYPE + + ' This function returns a one dimensional FIRGBAF array containing a whole + ' scanline's data-bits of a FIT_RGBAF image. This is done by wrapping + ' a true VB array around the memory block the returned pointer of + ' 'FreeImage_GetScanline' is pointing to. So, the array returned provides + ' full read and write acces to the image's data. + + ' The function includes checking of the image's bit depth and type and + ' returns a non-initialized array if 'Bitmap' is an image of improper type. + + ' To reuse the caller's array variable, this function's result was assigned to, + ' before it goes out of scope, the caller's array variable must be destroyed with + ' the 'FreeImage_DestroyLockedArrayFIRGBAF' function. + + eImageType = FreeImage_GetImageType(Bitmap) + If (eImageType = FIT_RGBAF) Then + + ' create a proper SAVEARRAY descriptor + With tSA + .cbElements = 12 ' size in bytes per array element + .cDims = 1 ' the array has only 1 dimension + .cElements = FreeImage_GetWidth(Bitmap) ' the number of elements in the array + .fFeatures = FADF_AUTO Or FADF_FIXEDSIZE ' need AUTO and FIXEDSIZE for safety issues, + ' so the array can not be modified in size + ' or erased; according to Matthew Curland never + ' use FIXEDSIZE alone + .pvData = FreeImage_GetScanline(Bitmap, _ + Scanline) ' let the array point to the memory block, the + ' FreeImage scanline data pointer points to + End With + + ' For a complete source code documentation have a + ' look at the function 'FreeImage_GetScanLineEx' + Call SafeArrayAllocDescriptor(1, lpSA) + Call CopyMemory(ByVal lpSA, tSA, Len(tSA)) + Call CopyMemory(ByVal VarPtrArray(FreeImage_GetScanLineRGBAF), lpSA, 4) + End If + +End Function + +'-------------------------------------------------------------------------------- +' HBITMAP conversion functions +'-------------------------------------------------------------------------------- + +Public Function FreeImage_GetBitmap(ByVal Bitmap As Long, _ + Optional ByVal hDC As Long, _ + Optional ByVal UnloadSource As Boolean) As Long + +Dim bReleaseDC As Boolean +Dim ppvBits As Long + + ' This function returns an HBITMAP created by the CreateDIBSection() function which + ' in turn has the same color depth as the original DIB. A reference DC may be provided + ' through the 'hDC' parameter. The desktop DC will be used, if no reference DC is + ' specified. + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to create a bitmap from a 'header-only' bitmap.") + End If + + If (hDC = 0) Then + hDC = GetDC(0) + bReleaseDC = True + End If + If (hDC) Then + FreeImage_GetBitmap = CreateDIBSection(hDC, FreeImage_GetInfo(Bitmap), _ + DIB_RGB_COLORS, ppvBits, 0, 0) + If ((FreeImage_GetBitmap <> 0) And (ppvBits <> 0)) Then + Call CopyMemory(ByVal ppvBits, ByVal FreeImage_GetBits(Bitmap), _ + FreeImage_GetHeight(Bitmap) * FreeImage_GetPitch(Bitmap)) + End If + If (UnloadSource) Then + Call FreeImage_Unload(Bitmap) + End If + If (bReleaseDC) Then + Call ReleaseDC(0, hDC) + End If + End If + End If + +End Function + +Public Function FreeImage_GetBitmapForDevice(ByVal Bitmap As Long, _ + Optional ByVal hDC As Long, _ + Optional ByVal UnloadSource As Boolean) As Long + +Dim bReleaseDC As Boolean + + ' This function returns an HBITMAP created by the CreateDIBitmap() function which + ' in turn has always the same color depth as the reference DC, which may be provided + ' through the 'hDC' parameter. The desktop DC will be used, if no reference DC is + ' specified. + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to create a bitmap from a 'header-only' bitmap.") + End If + + If (hDC = 0) Then + hDC = GetDC(0) + bReleaseDC = True + End If + If (hDC) Then + FreeImage_GetBitmapForDevice = _ + CreateDIBitmap(hDC, FreeImage_GetInfoHeader(Bitmap), CBM_INIT, _ + FreeImage_GetBits(Bitmap), FreeImage_GetInfo(Bitmap), _ + DIB_RGB_COLORS) + If (UnloadSource) Then + Call FreeImage_Unload(Bitmap) + End If + If (bReleaseDC) Then + Call ReleaseDC(0, hDC) + End If + End If + End If + +End Function + +'-------------------------------------------------------------------------------- +' OlePicture conversion functions +'-------------------------------------------------------------------------------- + +Public Function FreeImage_GetOlePicture(ByVal Bitmap As Long, _ + Optional ByVal hDC As Long, _ + Optional ByVal UnloadSource As Boolean) As IPicture + +Dim hBitmap As Long +Dim tPicDesc As PictDesc +Dim tGuid As Guid +Dim cPictureDisp As IPictureDisp + + ' This function creates a VB Picture object (OlePicture) from a FreeImage DIB. + ' The original image need not remain valid nor loaded after the VB Picture + ' object has been created. + + ' The optional parameter 'hDC' determines the device context (DC) used for + ' transforming the device independent bitmap (DIB) to a device dependent + ' bitmap (DDB). This device context's color depth is responsible for this + ' transformation. This parameter may be null or omitted. In that case, the + ' windows desktop's device context will be used, what will be the desired + ' way in almost any cases. + + ' The optional 'UnloadSource' parameter is for unloading the original image + ' after the OlePicture has been created, so you can easily "switch" from a + ' FreeImage DIB to a VB Picture object. There is no need to unload the DIB + ' at the caller's site if this argument is True. + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to create a picture from a 'header-only' bitmap.") + End If + + hBitmap = FreeImage_GetBitmapForDevice(Bitmap, hDC, UnloadSource) + If (hBitmap) Then + ' fill tPictDesc structure with necessary parts + With tPicDesc + .cbSizeofStruct = Len(tPicDesc) + ' the vbPicTypeBitmap constant is not available in VBA environemnts + .picType = 1 'vbPicTypeBitmap + .hImage = hBitmap + End With + + ' fill in IDispatch Interface ID + With tGuid + .Data1 = &H20400 + .Data4(0) = &HC0 + .Data4(7) = &H46 + End With + + ' create a picture object + Call OleCreatePictureIndirect(tPicDesc, tGuid, True, cPictureDisp) + Set FreeImage_GetOlePicture = cPictureDisp + End If + End If + +End Function + +Public Function FreeImage_GetOlePictureIcon(ByVal hIcon As Long) As IPicture + +Dim tPicDesc As PictDesc +Dim tGuid As Guid +Dim cPictureDisp As IPictureDisp + + ' This function creates a VB Picture object (OlePicture) of type picTypeIcon + ' from FreeImage hIcon handle. The hIcon handle need not remain valid nor loaded + ' after the VB Picture object has been created. + + ' The optional 'UnloadSource' parameter is for destroying the hIcon image + ' after the OlePicture has been created, so you can easiely "switch" from a + ' hIcon handle to a VB Picture object. There is no need to unload the hIcon + ' at the caller's site if this argument is True. + + If (hIcon) Then + ' fill tPictDesc structure with necessary parts + With tPicDesc + .cbSizeofStruct = 12 + ' the vbPicTypeIcon constant is not available in VBA environemnts + .picType = 3 'vbPicTypeIcon + .hImage = hIcon + End With + + ' fill in IDispatch Interface ID + With tGuid + .Data1 = &H20400 + .Data4(0) = &HC0 + .Data4(7) = &H46 + End With + + ' create a picture object + Call OleCreatePictureIndirect(tPicDesc, tGuid, True, cPictureDisp) + Set FreeImage_GetOlePictureIcon = cPictureDisp + End If + +End Function + +Public Function FreeImage_GetOlePictureThumbnail(ByVal Bitmap As Long, _ + ByVal MaxPixelSize As Long, _ + Optional ByVal hDC As Long, _ + Optional ByVal UnloadSource As Boolean) As IPicture + +Dim hDIBThumbnail As Long + + ' This function is a IOlePicture aware wrapper for FreeImage_MakeThumbnail(). It + ' returns a VB Picture object instead of a FreeImage DIB. + + ' The optional 'UnloadSource' parameter is for unloading the original image + ' after the OlePicture has been created, so you can easiely "switch" from a + ' FreeImage DIB to a VB Picture object. There is no need to clean up the DIB + ' at the caller's site. + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to create a thumbnail picture from a 'header-only' bitmap.") + End If + + hDIBThumbnail = FreeImage_MakeThumbnail(Bitmap, MaxPixelSize) + Set FreeImage_GetOlePictureThumbnail = FreeImage_GetOlePicture(hDIBThumbnail, hDC, True) + + If (UnloadSource) Then + Call FreeImage_Unload(Bitmap) + End If + End If + +End Function + +Public Function FreeImage_CreateFromOlePicture(ByRef Picture As IPicture) As Long + +Dim hBitmap As Long +Dim tBM As BITMAP_API +Dim hDIB As Long +Dim hDC As Long +Dim lResult As Long +Dim nColors As Long +Dim lpInfo As Long + + ' Creates a FreeImage DIB from a VB Picture object (OlePicture). This function + ' returns a pointer to the DIB as, for instance, the FreeImage function + ' 'FreeImage_Load' does. So, this could be a real replacement for 'FreeImage_Load' + ' when working with VB Picture objects. + + If (Not Picture Is Nothing) Then + hBitmap = Picture.Handle + If (hBitmap) Then + lResult = GetObjectAPI(hBitmap, Len(tBM), tBM) + If (lResult) Then + hDIB = FreeImage_Allocate(tBM.bmWidth, _ + tBM.bmHeight, _ + tBM.bmBitsPixel) + If (hDIB) Then + ' The GetDIBits function clears the biClrUsed and biClrImportant BITMAPINFO + ' members (dont't know why). So we save these infos below. + ' This is needed for palletized images only. + nColors = FreeImage_GetColorsUsed(hDIB) + + hDC = GetDC(0) + lResult = GetDIBits(hDC, hBitmap, 0, _ + FreeImage_GetHeight(hDIB), _ + FreeImage_GetBits(hDIB), _ + FreeImage_GetInfo(hDIB), _ + DIB_RGB_COLORS) + If (lResult) Then + FreeImage_CreateFromOlePicture = hDIB + If (nColors) Then + ' restore BITMAPINFO members + ' FreeImage_GetInfo(Bitmap)->biClrUsed = nColors; + ' FreeImage_GetInfo(Bitmap)->biClrImportant = nColors; + lpInfo = FreeImage_GetInfo(hDIB) + Call CopyMemory(ByVal lpInfo + 32, nColors, 4) + Call CopyMemory(ByVal lpInfo + 36, nColors, 4) + End If + Else + Call FreeImage_Unload(hDIB) + End If + Call ReleaseDC(0, hDC) + End If + End If + End If + End If + +End Function + +Public Function FreeImage_CreateFromDC(ByVal hDC As Long, _ + Optional ByRef hBitmap As Long) As Long + +Dim tBM As BITMAP_API +Dim hDIB As Long +Dim lResult As Long +Dim nColors As Long +Dim lpInfo As Long + + ' Creates a FreeImage DIB from a Device Context/Compatible Bitmap. This + ' function returns a pointer to the DIB as, for instance, 'FreeImage_Load()' + ' does. So, this could be a real replacement for FreeImage_Load() or + ' 'FreeImage_CreateFromOlePicture()' when working with DCs and BITMAPs directly + + ' The 'hDC' parameter specifies a window device context (DC), the optional + ' parameter 'hBitmap' may specify a handle to a memory bitmap. When 'hBitmap' is + ' omitted, the bitmap currently selected into the given DC is used to create + ' the DIB. + + ' When 'hBitmap' is not missing but NULL (0), the function uses the DC's currently + ' selected bitmap. This bitmap's handle is stored in the ('ByRef'!) 'hBitmap' parameter + ' and so, is avaliable at the caller's site when the function returns. + + ' The DIB returned by this function is a copy of the image specified by 'hBitmap' or + ' the DC's current bitmap when 'hBitmap' is missing. The 'hDC' and also the 'hBitmap' + ' remain untouched in this function, there will be no objects destroyed or freed. + ' The caller is responsible to destroy or free the DC and BITMAP if necessary. + + ' first, check whether we got a hBitmap or not + If (hBitmap = 0) Then + ' if not, the parameter may be missing or is NULL so get the + ' DC's current bitmap + hBitmap = GetCurrentObject(hDC, OBJ_BITMAP) + End If + + lResult = GetObjectAPI(hBitmap, Len(tBM), tBM) + If (lResult) Then + hDIB = FreeImage_Allocate(tBM.bmWidth, _ + tBM.bmHeight, _ + tBM.bmBitsPixel) + If (hDIB) Then + ' The GetDIBits function clears the biClrUsed and biClrImportant BITMAPINFO + ' members (dont't know why). So we save these infos below. + ' This is needed for palletized images only. + nColors = FreeImage_GetColorsUsed(hDIB) + + lResult = GetDIBits(hDC, hBitmap, 0, _ + FreeImage_GetHeight(hDIB), _ + FreeImage_GetBits(hDIB), _ + FreeImage_GetInfo(hDIB), _ + DIB_RGB_COLORS) + + If (lResult) Then + FreeImage_CreateFromDC = hDIB + If (nColors) Then + ' restore BITMAPINFO members + ' FreeImage_GetInfo(Bitmap)->biClrUsed = nColors; + ' FreeImage_GetInfo(Bitmap)->biClrImportant = nColors; + lpInfo = FreeImage_GetInfo(hDIB) + Call CopyMemory(ByVal lpInfo + 32, nColors, 4) + Call CopyMemory(ByVal lpInfo + 36, nColors, 4) + End If + Else + Call FreeImage_Unload(hDIB) + End If + End If + End If + +End Function + +Public Function FreeImage_CreateFromImageContainer(ByRef Container As Object, _ + Optional ByVal IncludeDrawings As Boolean) As Long + + ' Creates a FreeImage DIB from a VB container control that has at least a + ' 'Picture' property. This function returns a pointer to the DIB as, for + ' instance, 'FreeImage_Load()' does. So, this could be a real replacement for + ' FreeImage_Load() or 'FreeImage_CreateFromOlePicture()' when working with + ' image hosting controls like Forms or PictureBoxes. + + ' The 'IncludeDrawings' parameter controls whether drawings, drawn with VB + ' methods like 'Container.Print()', 'Container.Line(x1, y1)-(x2, y2)' or + ' 'Container.Circle(x, y), radius' as the controls 'BackColor' should be included + ' into the newly created DIB. However, this only works, with control's that + ' have their 'AutoRedraw' property set to 'True'. + + ' To get the control's picture as well as it's BackColor and custom drawings, + ' this function uses the control's 'Image' property instead of the 'Picture' + ' property. + + ' This function treats Forms and PictureBox controls explicitly, since the + ' property sets and behaviours of these controls are publicly known. For any + ' other control, the function checks for the existence of an 'Image' and + ' 'AutoRedraw' property. If these are present and 'IncludeDrawings' is 'True', + ' the function uses the control's 'Image' property instead of the 'Picture' + ' property. This my be the case for UserControls. In any other case, the function + ' uses the control's 'Picture' property if present. If none of these properties + ' is present, a runtime error (5) is generated. + + ' Most of this function is actually implemented in the wrapper's private helper + ' function 'pGetIOlePictureFromContainer'. + + If (Not Container Is Nothing) Then + FreeImage_CreateFromImageContainer = FreeImage_CreateFromOlePicture( _ + pGetIOlePictureFromContainer(Container, _ + IncludeDrawings)) + End If + +End Function + +Public Function FreeImage_CreateFromScreen(Optional ByVal hWnd As Long, _ + Optional ByVal ClientAreaOnly As Boolean) As Long + +Dim hDC As Long +Dim lWidth As Long +Dim lHeight As Long +Dim hMemDC As Long +Dim hMemBMP As Long +Dim hMemOldBMP As Long +Dim tR As RECT + + ' Creates a FreeImage DIB from the screen which may either be the whole + ' desktop/screen or a certain window. A certain window may be specified + ' by it's window handle through the 'hWnd' parameter. By omitting this + ' parameter, the whole screen/desktop window will be captured. + + If (hWnd = 0) Then + hWnd = GetDesktopWindow() + hDC = GetDCEx(hWnd, 0, 0) + ' get desktop's width and height + lWidth = GetDeviceCaps(hDC, HORZRES) + lHeight = GetDeviceCaps(hDC, VERTRES) + + ElseIf (ClientAreaOnly) Then + ' get window's client area DC + hDC = GetDCEx(hWnd, 0, 0) + Call GetClientRect(hWnd, tR) + lWidth = tR.Right + lHeight = tR.Bottom + + Else + ' get window DC + hDC = GetDCEx(hWnd, 0, DCX_WINDOW) + Call GetWindowRect(hWnd, tR) + lWidth = tR.Right - tR.Left + lHeight = tR.Bottom - tR.Top + + End If + + ' create compatible memory DC and bitmap + hMemDC = CreateCompatibleDC(hDC) + hMemBMP = CreateCompatibleBitmap(hDC, lWidth, lHeight) + ' select compatible bitmap + hMemOldBMP = SelectObject(hMemDC, hMemBMP) + ' blit bits + Call BitBlt(hMemDC, 0, 0, lWidth, lHeight, hDC, 0, 0, SRCCOPY Or CAPTUREBLT) + + ' create FreeImage Bitmap from memory DC + FreeImage_CreateFromScreen = FreeImage_CreateFromDC(hMemDC, hMemBMP) + + ' clean up + Call SelectObject(hMemDC, hMemOldBMP) + Call DeleteObject(hMemBMP) + Call DeleteDC(hMemDC) + Call ReleaseDC(hWnd, hDC) + +End Function + +'-------------------------------------------------------------------------------- +' Microsoft Office / VBA PictureData supporting functions +'-------------------------------------------------------------------------------- + +Public Function FreeImage_GetPictureData(ByVal Bitmap As Long, _ + Optional ByVal UnloadSource As Boolean) As Byte() + +Const SIZE_OF_LONG = 4 +Const SIZE_OF_BITMAPINFOHEADER = 40 + +Dim abResult() As Byte +Dim lHeaderSize As Long +Dim lPaletteSize As Long +Dim lImageSize As Long +Dim lpInfo As Long +Dim lOffset As Long + + ' This function creates an Office PictureData Byte array from a FreeImage DIB. + ' The original image must not remain valid nor loaded after the PictureData + ' array has been created. + + ' The optional 'UnloadSource' parameter is for unloading the original image + ' after the PictureData Byte array has been created, so you can easily "switch" + ' from a FreeImage DIB to an Office PictureData Byte array. There is no need to + ' unload the DIB at the caller's site if this argument is True. + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to create a PictureData array from a 'header-only' bitmap.") + End If + + If (FreeImage_HasRGBMasks(Bitmap)) Then + lHeaderSize = 3 * SIZE_OF_LONG + End If + lHeaderSize = lHeaderSize + SIZE_OF_BITMAPINFOHEADER + lImageSize = FreeImage_GetHeight(Bitmap) * FreeImage_GetPitch(Bitmap) + lPaletteSize = FreeImage_GetColorsUsed(Bitmap) * 4 + + ReDim abResult(lHeaderSize + lPaletteSize + lImageSize - 1) + + ' Copy the BITMAPINFOHEADER into the result array. + lpInfo = FreeImage_GetInfo(Bitmap) + Call CopyMemory(abResult(0), ByVal lpInfo, lHeaderSize) + lOffset = lOffset + lHeaderSize + + If (lPaletteSize > 0) Then + ' Copy the image's palette (if any) into the result array. + Call CopyMemory(abResult(lOffset), ByVal FreeImage_GetPalette(Bitmap), lPaletteSize) + lOffset = lOffset + lPaletteSize + End If + + ' Copy the image's bits into the result array. + Call CopyMemory(abResult(lOffset), ByVal FreeImage_GetBits(Bitmap), lImageSize) + + Call pSwap(ByVal VarPtrArray(abResult), ByVal VarPtrArray(FreeImage_GetPictureData)) + + If (UnloadSource) Then + Call FreeImage_Unload(Bitmap) + End If + End If + +End Function + +Public Function FreeImage_CreateFromPictureData(ByRef PictureData() As Byte) As Long + +Dim tBMIH As BITMAPINFOHEADER +Dim lLength As Long +Dim hDIB As Long +Dim lPaletteSize As Long +Dim lOffset As Long +Dim alMasks() As Long + + ' Creates a FreeImage DIB from an Office PictureData Byte array. This function + ' returns a pointer to the DIB as, for instance, the FreeImage function + ' 'FreeImage_Load' does. So, this could be a real replacement for 'FreeImage_Load' + ' when working with PictureData arrays. + + lLength = UBound(PictureData) + 1 + If (lLength > Len(tBMIH)) Then + Call CopyMemory(tBMIH, PictureData(0), Len(tBMIH)) + With tBMIH + If (.biSize = 40) Then + lOffset = 40 + Select Case .biBitCount + + Case 0 + + Case 1, 4, 8 + If (.biClrUsed = 0) Then + lPaletteSize = 2 ^ .biBitCount * 4 + Else + lPaletteSize = .biClrUsed * 4 + End If + hDIB = FreeImage_Allocate(.biWidth, .biHeight, .biBitCount) + Call CopyMemory(ByVal FreeImage_GetPalette(hDIB), _ + PictureData(lOffset), lPaletteSize) + lOffset = lOffset + lPaletteSize + + Case 16 + If (.biCompression = BI_BITFIELDS) Then + ReDim alMasks(2) + Call CopyMemory(alMasks(0), PictureData(lOffset), 12) + lOffset = lOffset + 12 + hDIB = FreeImage_Allocate(.biWidth, .biHeight, .biBitCount, _ + alMasks(0), alMasks(1), alMasks(2)) + Else + hDIB = FreeImage_Allocate(.biWidth, .biHeight, .biBitCount, _ + FI16_555_RED_MASK, FI16_555_GREEN_MASK, FI16_555_BLUE_MASK) + End If + + Case 24, 32 + hDIB = FreeImage_Allocate(.biWidth, .biHeight, .biBitCount) + + End Select + + If (hDIB) Then + Call CopyMemory(ByVal FreeImage_GetBits(hDIB), _ + PictureData(lOffset), lLength - lOffset) + FreeImage_CreateFromPictureData = hDIB + End If + Else + ' ERROR: invalid or unsupported PictureData array + End If + End With + Else + ' ERROR: invalid or unsupported PictureData array + End If + +End Function + +Public Function FreeImage_CreateMask(ByVal hDIB As Long, _ + Optional ByVal eMaskCreationOptions As FREE_IMAGE_MASK_CREATION_OPTION_FLAGS = MCOF_CREATE_MASK_IMAGE, _ + Optional ByVal lBitDepth As Long = 1, _ + Optional ByVal eMaskOptions As FREE_IMAGE_MASK_FLAGS = FIMF_MASK_FULL_TRANSPARENCY, _ + Optional ByVal vntMaskColors As Variant, _ + Optional ByVal eMaskColorsFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal lColorTolerance As Long, _ + Optional ByVal lciMaskColorDst As Long = vbWhite, _ + Optional ByVal eMaskColorDstFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal lciUnmaskColorDst As Long = vbBlack, _ + Optional ByVal eUnmaskColorDstFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal vlciMaskColorSrc As Variant, _ + Optional ByVal eMaskColorSrcFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal vlciUnmaskColorSrc As Variant, _ + Optional ByVal eUnmaskColorSrcFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB) As Long + +Dim hDIBResult As Long +Dim lBitDepthSrc As Long +Dim lWidth As Long +Dim lHeight As Long + +Dim bMaskColors As Boolean +Dim bMaskTransparency As Boolean +Dim bMaskFullTransparency As Boolean +Dim bMaskAlphaTransparency As Boolean +Dim bInvertMask As Boolean +Dim bHaveMaskColorSrc As Boolean +Dim bHaveUnmaskColorSrc As Boolean +Dim bCreateMaskImage As Boolean +Dim bModifySourceImage As Boolean +Dim alcMaskColors() As Long +Dim lMaskColorsMaxIndex As Long + +Dim lciMaskColorSrc As Long +Dim lciUnmaskColorSrc As Long + +Dim alPaletteSrc() As Long +Dim abTransparencyTableSrc() As Byte +Dim abBitsBSrc() As Byte +Dim atBitsTSrc As ScanLinesRGBTRIBLE +Dim atBitsQSrc() As RGBQUAD +Dim abBitValues(7) As Byte +Dim abBitMasks(7) As Byte +Dim abBitShifts(7) As Byte + +Dim atPaletteDst() As RGBQUAD +Dim abBitsBDst() As Byte +Dim atBitsTDst As ScanLinesRGBTRIBLE +Dim atBitsQDst() As RGBQUAD + +Dim bMaskPixel As Boolean +Dim x As Long +Dim x2 As Long +Dim lPixelIndex As Long +Dim y As Long +Dim i As Long + + 'TODO: comment this function + + ' check for a proper bit depth of the destination (mask) image + If ((hDIB) And ((lBitDepth = 1) Or _ + (lBitDepth = 4) Or _ + (lBitDepth = 8) Or _ + (lBitDepth = 24) Or _ + (lBitDepth = 32))) Then + + If (Not FreeImage_HasPixels(hDIB)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to create a mask image from a 'header-only' bitmap.") + End If + + ' check for a proper bit depth of the source image + lBitDepthSrc = FreeImage_GetBPP(hDIB) + If ((lBitDepthSrc = 4) Or _ + (lBitDepthSrc = 8) Or _ + (lBitDepthSrc = 24) Or _ + (lBitDepthSrc = 32)) Then + + + ' get some information from eMaskCreationOptions + bCreateMaskImage = (eMaskCreationOptions And MCOF_CREATE_MASK_IMAGE) + bModifySourceImage = (eMaskCreationOptions And MCOF_MODIFY_SOURCE_IMAGE) + + + If (bCreateMaskImage) Then + + ' check mask color format + If (eMaskColorDstFormat And FICFF_COLOR_BGR) Then + ' if mask color is in BGR format, convert to RGB format + lciMaskColorDst = FreeImage_SwapColorLong(lciMaskColorDst) + + ElseIf (eMaskColorDstFormat And FICFF_COLOR_PALETTE_INDEX) Then + ' if mask color is specified as palette index, check, whether the + ' source image is a palletized image + Select Case lBitDepthSrc + + Case 1 + lciMaskColorDst = FreeImage_GetPaletteExLong(hDIB)(lciMaskColorDst And &H1) + + Case 4 + lciMaskColorDst = FreeImage_GetPaletteExLong(hDIB)(lciMaskColorDst And &HF) + + Case 8 + lciMaskColorDst = FreeImage_GetPaletteExLong(hDIB)(lciMaskColorDst And &HFF) + + End Select + End If + + ' check unmask color format + If (eUnmaskColorDstFormat And FICFF_COLOR_BGR) Then + ' if unmask color is in BGR format, convert to RGB format + lciUnmaskColorDst = FreeImage_SwapColorLong(lciUnmaskColorDst) + + ElseIf (eUnmaskColorDstFormat And FICFF_COLOR_PALETTE_INDEX) Then + ' if unmask color is specified as palette index, check, whether the + ' source image is a palletized image + Select Case lBitDepthSrc + + Case 1 + lciUnmaskColorDst = FreeImage_GetPaletteExLong(hDIB)(lciUnmaskColorDst And &H1) + + Case 4 + lciUnmaskColorDst = FreeImage_GetPaletteExLong(hDIB)(lciUnmaskColorDst And &HF) + + Case 8 + lciUnmaskColorDst = FreeImage_GetPaletteExLong(hDIB)(lciUnmaskColorDst And &HFF) + + End Select + End If + End If + + + If (bModifySourceImage) Then + + ' check, whether source image can be modified + bHaveMaskColorSrc = (Not IsMissing(vlciMaskColorSrc)) + bHaveUnmaskColorSrc = (Not IsMissing(vlciUnmaskColorSrc)) + + Select Case lBitDepthSrc + + Case 4, 8 + If (bHaveMaskColorSrc) Then + + ' get mask color as Long + lciMaskColorSrc = vlciMaskColorSrc + + If (eMaskColorSrcFormat And FICFF_COLOR_PALETTE_INDEX) Then + If (lBitDepthSrc = 4) Then + lciMaskColorSrc = (lciMaskColorSrc And &HF) + Else + lciMaskColorSrc = (lciMaskColorSrc And &HFF) + End If + Else + If (eMaskColorSrcFormat And FICFF_COLOR_BGR) Then + lciMaskColorSrc = FreeImage_SwapColorLong(lciMaskColorSrc, True) + End If + lciMaskColorSrc = FreeImage_SearchPalette(hDIB, lciMaskColorSrc) + bHaveMaskColorSrc = (lciMaskColorSrc <> -1) + End If + End If + + If (bHaveUnmaskColorSrc) Then + + ' get unmask color as Long + lciUnmaskColorSrc = vlciUnmaskColorSrc + + If (eUnmaskColorSrcFormat And FICFF_COLOR_PALETTE_INDEX) Then + If (lBitDepthSrc = 4) Then + lciUnmaskColorSrc = (lciUnmaskColorSrc And &HF) + Else + lciUnmaskColorSrc = (lciUnmaskColorSrc And &HFF) + End If + Else + If (eUnmaskColorSrcFormat And FICFF_COLOR_BGR) Then + lciUnmaskColorSrc = FreeImage_SwapColorLong(lciUnmaskColorSrc, True) + End If + lciUnmaskColorSrc = FreeImage_SearchPalette(hDIB, lciUnmaskColorSrc) + bHaveUnmaskColorSrc = (lciUnmaskColorSrc <> -1) + End If + End If + + ' check, if source image still can be modified in any way + bModifySourceImage = (bHaveMaskColorSrc Or bHaveUnmaskColorSrc) + + Case 24, 32 + If (bHaveMaskColorSrc) Then + + ' get mask color as Long + lciMaskColorSrc = vlciMaskColorSrc + + If (eMaskColorSrcFormat And FICFF_COLOR_BGR) Then + lciMaskColorSrc = FreeImage_SwapColorLong(lciMaskColorSrc, (lBitDepthSrc = 24)) + End If + End If + + If (bHaveUnmaskColorSrc) Then + + ' get unmask color as Long + lciUnmaskColorSrc = vlciUnmaskColorSrc + + If (eUnmaskColorSrcFormat And FICFF_COLOR_BGR) Then + lciUnmaskColorSrc = FreeImage_SwapColorLong(lciUnmaskColorSrc, (lBitDepthSrc = 24)) + End If + End If + + End Select + + End If + + + If ((bModifySourceImage) Or (bCreateMaskImage)) Then + + ' get some information from eMaskOptions + + ' check for inverse mask + bInvertMask = (eMaskOptions And FIMF_MASK_INVERSE_MASK) + + ' check for mask colors + bMaskColors = (eMaskOptions And FIMF_MASK_COLOR_TRANSPARENCY) + bMaskColors = bMaskColors And (Not IsMissing(vntMaskColors)) + If (bMaskColors) Then + ' validate specified mask colors; all mask colors are transferred to + ' an internal array of type Long + If (Not IsArray(vntMaskColors)) Then + ' color masking is only done when the single mask color is + ' a numeric (color) value + bMaskColors = IsNumeric(vntMaskColors) + If (bMaskColors) Then + ' this is not an array of mask colors but only a single + ' color; this is also transferred into an internal array + lMaskColorsMaxIndex = 0 + ReDim alcMaskColors(lMaskColorsMaxIndex) + alcMaskColors(lMaskColorsMaxIndex) = vntMaskColors + End If + Else + ' transfer all valid color values (numeric) into an internal + ' array + ReDim alcMaskColors(UBound(vntMaskColors)) + For i = LBound(vntMaskColors) To UBound(vntMaskColors) + bMaskColors = (IsNumeric(vntMaskColors(i))) + If (Not bMaskColors) Then + Exit For + Else + alcMaskColors(lMaskColorsMaxIndex) = vntMaskColors(i) + lMaskColorsMaxIndex = lMaskColorsMaxIndex + 1 + End If + Next i + If (bMaskColors) Then + lMaskColorsMaxIndex = lMaskColorsMaxIndex - 1 + End If + End If + End If + + ' check for transparency options + If ((FreeImage_IsTransparent(hDIB)) Or _ + ((eMaskOptions And FIMF_MASK_FORCE_TRANSPARENCY) > 0)) Then + bMaskFullTransparency = (eMaskOptions And FIMF_MASK_FULL_TRANSPARENCY) + bMaskAlphaTransparency = (eMaskOptions And FIMF_MASK_ALPHA_TRANSPARENCY) + bMaskTransparency = (bMaskFullTransparency Or bMaskAlphaTransparency) + End If + + ' get image dimension + lWidth = FreeImage_GetWidth(hDIB) + lHeight = FreeImage_GetHeight(hDIB) + + ' create proper accessors for the source image + Select Case lBitDepthSrc + + Case 4, 8 + ' images with a bit depth of 4 or 8 bits will both be + ' read through a byte array + abBitsBSrc = FreeImage_GetBitsEx(hDIB) + ' depending on where to get the transparency information from, + ' a palette or a transpareny table will be needed + If (bMaskColors) Then + alPaletteSrc = FreeImage_GetPaletteExLong(hDIB) + End If + If (bMaskTransparency) Then + abTransparencyTableSrc = FreeImage_GetTransparencyTableExClone(hDIB) + End If + + ' for 4 bit source images + If (lBitDepthSrc = 4) Then + ' two additional arrays need to be filled with values + ' to mask and shift nibbles to bytes + ' index 0 stands for the high nibble of the byte + abBitMasks(0) = &HF0 + abBitShifts(0) = &H10 ' a shift to right is implemented + ' as division in VB + ' index 1 stands for the low nibble of the byte + abBitMasks(1) = &HF + abBitShifts(1) = &H1 ' no shift needed for low nibble + End If + + Case 24 + ' images with a depth of 24 bits could not be used + ' through a two dimensional array in most cases, so get + ' an array of individual scanlines (see remarks concerning + ' pitch at function 'FreeImage_GetBitsExRGBTriple()') + Call FreeImage_GetScanLinesRGBTRIPLE(hDIB, atBitsTSrc) + + Case 32 + atBitsQSrc = FreeImage_GetBitsExRGBQUAD(hDIB) + + End Select + + + ' create mask image if needed + If (bCreateMaskImage) Then + + ' create mask image + hDIBResult = FreeImage_Allocate(lWidth, lHeight, lBitDepth) + ' if destination bit depth is 8 or below, a proper palette will + ' be needed, so create a palette where the unmask color is at + ' index 0 and the mask color is at index 1 + If (lBitDepth <= 8) Then + atPaletteDst = FreeImage_GetPaletteEx(hDIBResult) + Call CopyMemory(atPaletteDst(0), lciUnmaskColorDst, 4) + Call CopyMemory(atPaletteDst(1), lciMaskColorDst, 4) + End If + + ' create proper accessors for the new mask image + Select Case lBitDepth + + Case 1 + abBitsBDst = FreeImage_GetBitsEx(hDIBResult) + x = 1 + For i = 7 To 0 Step -1 + abBitValues(i) = x + x = x * 2 + Next i + + Case 4 + abBitsBDst = FreeImage_GetBitsEx(hDIBResult) + abBitValues(0) = &H10 + abBitValues(1) = &H1 + + Case 8 + abBitsBDst = FreeImage_GetBitsEx(hDIBResult) + + Case 24 + ' images with a depth of 24 bits could not be used + ' through a two dimensional array in most cases, so get + ' an array of individual scanlines (see remarks concerning + ' pitch at function 'FreeImage_GetBitsExRGBTriple()') + Call FreeImage_GetScanLinesRGBTRIPLE(hDIBResult, atBitsTDst) + + Case 32 + atBitsQDst = FreeImage_GetBitsExRGBQUAD(hDIBResult) + + End Select + End If + + ' walk the hole image + For y = 0 To lHeight - 1 + For x = 0 To lWidth - 1 + + ' should transparency information be considered to create + ' the mask? + If (bMaskTransparency) Then + + Select Case lBitDepthSrc + + Case 4 + x2 = x \ 2 + lPixelIndex = (abBitsBSrc(x2, y) And abBitMasks(x Mod 2)) \ abBitShifts(x Mod 2) + bMaskPixel = (abTransparencyTableSrc(lPixelIndex) = 0) + If (Not bMaskPixel) Then + bMaskPixel = ((abTransparencyTableSrc(lPixelIndex) < 255) And _ + (bMaskAlphaTransparency)) + End If + + Case 8 + bMaskPixel = (abTransparencyTableSrc(abBitsBSrc(x, y)) = 0) + If (Not bMaskPixel) Then + bMaskPixel = ((abTransparencyTableSrc(abBitsBSrc(x, y)) < 255) And _ + (bMaskAlphaTransparency)) + End If + + Case 24 + ' no transparency information in 24 bit images + ' reset bMaskPixel + bMaskPixel = False + + Case 32 + bMaskPixel = (atBitsQSrc(x, y).rgbReserved = 0) + If (Not bMaskPixel) Then + bMaskPixel = ((atBitsQSrc(x, y).rgbReserved < 255) And _ + (bMaskAlphaTransparency)) + End If + + End Select + Else + ' clear 'bMaskPixel' if no transparency information was checked + ' since the flag might be still True from the last loop + bMaskPixel = False + End If + + ' should color information be considered to create the mask? + ' do this only if the current pixel is not yet part of the mask + If ((bMaskColors) And (Not bMaskPixel)) Then + + Select Case lBitDepthSrc + + Case 4 + x2 = x \ 2 + lPixelIndex = (abBitsBSrc(x2, y) And abBitMasks(x Mod 2)) \ abBitShifts(x Mod 2) + If (eMaskColorsFormat And FICFF_COLOR_PALETTE_INDEX) Then + For i = 0 To lMaskColorsMaxIndex + If (lColorTolerance = 0) Then + bMaskPixel = (lPixelIndex = alcMaskColors(i)) + Else + bMaskPixel = (FreeImage_CompareColorsLongLong( _ + alPaletteSrc(lPixelIndex), _ + alPaletteSrc(alcMaskColors(i)), _ + lColorTolerance, _ + FICFF_COLOR_RGB, FICFF_COLOR_RGB) = 0) + End If + If (bMaskPixel) Then + Exit For + End If + Next i + Else + For i = 0 To lMaskColorsMaxIndex + bMaskPixel = (FreeImage_CompareColorsLongLong( _ + alPaletteSrc(lPixelIndex), _ + alcMaskColors(i), lColorTolerance, _ + FICFF_COLOR_RGB, _ + (eMaskColorsFormat And FICFF_COLOR_FORMAT_ORDER_MASK)) = 0) + If (bMaskPixel) Then + Exit For + End If + Next i + End If + + Case 8 + If (eMaskColorsFormat And FICFF_COLOR_PALETTE_INDEX) Then + For i = 0 To lMaskColorsMaxIndex + If (lColorTolerance = 0) Then + bMaskPixel = (abBitsBSrc(x, y) = alcMaskColors(i)) + Else + bMaskPixel = (FreeImage_CompareColorsLongLong( _ + alPaletteSrc(abBitsBSrc(x, y)), _ + alPaletteSrc(alcMaskColors(i)), _ + lColorTolerance, _ + FICFF_COLOR_RGB, FICFF_COLOR_RGB) = 0) + End If + If (bMaskPixel) Then + Exit For + End If + Next i + Else + For i = 0 To lMaskColorsMaxIndex + bMaskPixel = (FreeImage_CompareColorsLongLong( _ + alPaletteSrc(abBitsBSrc(x, y)), _ + alcMaskColors(i), lColorTolerance, _ + FICFF_COLOR_RGB, _ + (eMaskColorsFormat And FICFF_COLOR_FORMAT_ORDER_MASK)) = 0) + If (bMaskPixel) Then + Exit For + End If + Next i + End If + + Case 24 + For i = 0 To lMaskColorsMaxIndex + bMaskPixel = (FreeImage_CompareColorsRGBTRIPLELong( _ + atBitsTSrc.Scanline(y).Data(x), _ + alcMaskColors(i), lColorTolerance, _ + (eMaskColorsFormat And FICFF_COLOR_FORMAT_ORDER_MASK)) = 0) + If (bMaskPixel) Then + Exit For + End If + Next i + + Case 32 + For i = 0 To lMaskColorsMaxIndex + bMaskPixel = (FreeImage_CompareColorsRGBQUADLong( _ + atBitsQSrc(x, y), _ + alcMaskColors(i), lColorTolerance, _ + (eMaskColorsFormat And FICFF_COLOR_FORMAT_ORDER_MASK)) = 0) + If (bMaskPixel) Then + Exit For + End If + Next i + + End Select + + End If + + ' check whether a mask image needs to be created + If (bCreateMaskImage) Then + + ' write current pixel to destination (mask) image + Select Case lBitDepth + + Case 1 + x2 = x \ 8 + If ((bMaskPixel) Xor (bInvertMask)) Then + abBitsBDst(x2, y) = abBitsBDst(x2, y) Or abBitValues(x Mod 8) + End If + + Case 4 + x2 = x \ 2 + If ((bMaskPixel) Xor (bInvertMask)) Then + abBitsBDst(x2, y) = abBitsBDst(x2, y) Or abBitValues(x Mod 2) + End If + + Case 8 + If ((bMaskPixel) Xor (bInvertMask)) Then + abBitsBDst(x, y) = 1 + End If + + Case 24 + If ((bMaskPixel) Xor (bInvertMask)) Then + Call CopyMemory(atBitsTDst.Scanline(y).Data(x), lciMaskColorDst, 3) + Else + Call CopyMemory(atBitsTDst.Scanline(y).Data(x), lciUnmaskColorDst, 3) + End If + + Case 32 + If ((bMaskPixel) Xor (bInvertMask)) Then + Call CopyMemory(atBitsQDst(x, y), lciMaskColorDst, 4) + Else + Call CopyMemory(atBitsQDst(x, y), lciUnmaskColorDst, 4) + End If + + End Select + End If + + ' check whether a source image needs to be modified + If (bModifySourceImage) Then + + Select Case lBitDepthSrc + + Case 4 + x2 = x \ 2 + If ((bMaskPixel) Xor (bInvertMask)) Then + If (bHaveMaskColorSrc) Then + abBitsBSrc(x2, y) = _ + (abBitsBSrc(x2, y) And (Not abBitMasks(x Mod 2))) Or _ + (lciMaskColorSrc * abBitShifts(x Mod 2)) + End If + ElseIf (bHaveUnmaskColorSrc) Then + abBitsBSrc(x2, y) = _ + (abBitsBSrc(x2, y) And (Not abBitMasks(x Mod 2))) Or _ + (lciUnmaskColorSrc * abBitShifts(x Mod 2)) + End If + + Case 8 + If ((bMaskPixel) Xor (bInvertMask)) Then + If (bHaveMaskColorSrc) Then + abBitsBSrc(x, y) = lciMaskColorSrc + End If + ElseIf (bHaveUnmaskColorSrc) Then + abBitsBSrc(x, y) = lciUnmaskColorSrc + End If + + Case 24 + If ((bMaskPixel) Xor (bInvertMask)) Then + If (bHaveMaskColorSrc) Then + Call CopyMemory(atBitsTSrc.Scanline(y).Data(x), lciMaskColorSrc, 3) + End If + ElseIf (bHaveUnmaskColorSrc) Then + Call CopyMemory(atBitsTSrc.Scanline(y).Data(x), lciUnmaskColorSrc, 3) + End If + + Case 32 + If ((bMaskPixel) Xor (bInvertMask)) Then + If (bHaveMaskColorSrc) Then + Call CopyMemory(atBitsQSrc(x, y), lciMaskColorSrc, 4) + End If + ElseIf (bHaveUnmaskColorSrc) Then + Call CopyMemory(atBitsQSrc(x, y), lciUnmaskColorSrc, 4) + End If + + End Select + End If + + Next x + Next y + End If + End If + End If + + FreeImage_CreateMask = hDIBResult + +End Function + +Public Function FreeImage_CreateMaskImage(ByVal hDIB As Long, _ + Optional ByVal lBitDepth As Long = 1, _ + Optional ByVal eMaskOptions As FREE_IMAGE_MASK_FLAGS = FIMF_MASK_FULL_TRANSPARENCY, _ + Optional ByVal vntMaskColors As Variant, _ + Optional ByVal eMaskColorsFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal lColorTolerance As Long, _ + Optional ByVal lciMaskColor As Long = vbWhite, _ + Optional ByVal eMaskColorFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal lciUnmaskColor As Long = vbBlack, _ + Optional ByVal eUnmaskColorFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB) As Long + + 'TODO: comment this function + + FreeImage_CreateMaskImage = FreeImage_CreateMask(hDIB, MCOF_CREATE_MASK_IMAGE, _ + lBitDepth, eMaskOptions, _ + vntMaskColors, eMaskColorsFormat, _ + lColorTolerance, _ + lciMaskColor, eMaskColorFormat, _ + lciUnmaskColor, eUnmaskColorFormat) + +End Function + +Public Function FreeImage_CreateSimpleBWMaskImage(ByVal hDIB As Long, _ + Optional ByVal lBitDepth As Long = 1, _ + Optional ByVal eMaskOptions As FREE_IMAGE_MASK_FLAGS = FIMF_MASK_FULL_TRANSPARENCY, _ + Optional ByVal vntMaskColors As Variant, _ + Optional ByVal eMaskColorsFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal lColorTolerance As Long) As Long + + 'TODO: comment this function + + FreeImage_CreateSimpleBWMaskImage = FreeImage_CreateMask(hDIB, MCOF_CREATE_MASK_IMAGE, _ + lBitDepth, eMaskOptions, _ + vntMaskColors, eMaskColorsFormat, _ + lColorTolerance, _ + vbWhite, FICFF_COLOR_RGB, _ + vbBlack, FICFF_COLOR_RGB) + +End Function + +Public Function FreeImage_CreateMaskInPlace(ByVal hDIB As Long, _ + Optional ByVal lBitDepth As Long = 1, _ + Optional ByVal eMaskOptions As FREE_IMAGE_MASK_FLAGS = FIMF_MASK_FULL_TRANSPARENCY, _ + Optional ByVal vntMaskColors As Variant, _ + Optional ByVal eMaskColorsFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal lColorTolerance As Long, _ + Optional ByVal vlciMaskColor As Variant, _ + Optional ByVal eMaskColorFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal vlciUnmaskColor As Variant, _ + Optional ByVal eUnmaskColorFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB) As Long + + 'TODO: comment this function + + FreeImage_CreateMaskInPlace = FreeImage_CreateMask(hDIB, MCOF_MODIFY_SOURCE_IMAGE, _ + lBitDepth, eMaskOptions, _ + vntMaskColors, eMaskColorsFormat, _ + lColorTolerance, _ + , , , , _ + vlciMaskColor, eMaskColorFormat, _ + vlciUnmaskColor, eUnmaskColorFormat) + +End Function + +Public Function FreeImage_CreateSimpleBWMaskInPlace(ByVal hDIB As Long, _ + Optional ByVal lBitDepth As Long = 1, _ + Optional ByVal eMaskOptions As FREE_IMAGE_MASK_FLAGS = FIMF_MASK_FULL_TRANSPARENCY, _ + Optional ByVal vntMaskColors As Variant, _ + Optional ByVal eMaskColorsFormat As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal lColorTolerance As Long) As Long + + 'TODO: comment this function + + FreeImage_CreateSimpleBWMaskInPlace = FreeImage_CreateMask(hDIB, MCOF_MODIFY_SOURCE_IMAGE, _ + lBitDepth, eMaskOptions, _ + vntMaskColors, eMaskColorsFormat, _ + lColorTolerance, _ + , , , , _ + vbWhite, FICFF_COLOR_RGB, _ + vbBlack, FICFF_COLOR_RGB) + +End Function + +Public Function FreeImage_CreateMaskColors(ParamArray MaskColors() As Variant) As Variant + + ' this is just a FreeImage signed function that emulates VB's + ' builtin Array() function, that makes a variant array from + ' a ParamArray; so, a caller of the FreeImage_CreateMask() function + ' can specify all mask colors inline in the call statement + + ' hDibMask = FreeImage_CreateMask(hDib, 1, FIMF_MASK_COLOR_TRANSPARENCY, _ + ' FreeImage_CreateMaskColors(vbRed, vbGreen, vbBlack), _ + ' FICFF_COLOR_BGR, .... ) + + ' keep in mind, that VB colors (vbRed, vbBlue, etc.) are OLE colors that have + ' BRG format + + FreeImage_CreateMaskColors = MaskColors + +End Function + +Public Function FreeImage_SwapColorLong(ByVal Color As Long, _ + Optional ByVal IgnoreAlpha As Boolean) As Long + + ' This function swaps both color components Red (R) and Blue (B) in either + ' and RGB or BGR format color value stored in a Long value. This function is + ' used to convert from a RGB to a BGR color value and vice versa. + + If (Not IgnoreAlpha) Then + FreeImage_SwapColorLong = ((Color And &HFF000000) Or _ + ((Color And &HFF&) * &H10000) Or _ + (Color And &HFF00&) Or _ + ((Color And &HFF0000) \ &H10000)) + Else + FreeImage_SwapColorLong = (((Color And &HFF&) * &H10000) Or _ + (Color And &HFF00&) Or _ + ((Color And &HFF0000) \ &H10000)) + End If + +End Function + +Public Function FreeImage_CompareColorsLongLong(ByVal ColorA As Long, _ + ByVal ColorB As Long, _ + Optional ByVal Tolerance As Long, _ + Optional ByVal ColorTypeA As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_ARGB, _ + Optional ByVal ColorTypeB As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_ARGB) As Long + +Dim bFormatEqual As Boolean +Dim bAlphaEqual As Boolean + + ' This function compares two colors that both are specified as a 32 bit Long + ' value. + + ' Use both parameters 'ColorTypeA' and 'ColorTypeB' to specify each color's + ' format and 'Tolerance' to specify the matching tolerance. + + ' The function returns the result of the mathematical substraction + ' ColorA - ColorB, so if both colors are equal, the function returns NULL (0) + ' and any other value if both colors are different. Alpha transparency is taken into + ' account only if both colors are said to have an alpha transparency component by + ' both parameters 'ColorTypeA' and 'ColorTypeB'. If at least one of both colors + ' has no alpha transparency component, the comparison only includes the bits for + ' the red, green and blue component. + + ' The matching tolerance is applied to each color component (red, green, blue and + ' alpha) separately. So, when 'Tolerance' contains a value greater than zero, the + ' function returns NULL (0) when either both colors are exactly the same or the + ' differences of each corresponding color components are smaller or equal than + ' the given tolerance value. + + + If (((ColorTypeA And FICFF_COLOR_PALETTE_INDEX) Or _ + (ColorTypeB And FICFF_COLOR_PALETTE_INDEX)) = 0) Then + + bFormatEqual = ((ColorTypeA And FICFF_COLOR_FORMAT_ORDER_MASK) = _ + (ColorTypeB And FICFF_COLOR_FORMAT_ORDER_MASK)) + + bAlphaEqual = ((ColorTypeA And FICFF_COLOR_HAS_ALPHA) And _ + (ColorTypeB And FICFF_COLOR_HAS_ALPHA)) + + If (bFormatEqual) Then + If (bAlphaEqual) Then + FreeImage_CompareColorsLongLong = ColorA - ColorB + Else + FreeImage_CompareColorsLongLong = (ColorA And &HFFFFFF) - (ColorB And &HFFFFFF) + End If + Else + If (bAlphaEqual) Then + FreeImage_CompareColorsLongLong = ColorA - ((ColorB And &HFF000000) Or _ + ((ColorB And &HFF&) * &H10000) Or _ + (ColorB And &HFF00&) Or _ + ((ColorB And &HFF0000) \ &H10000)) + Else + FreeImage_CompareColorsLongLong = (ColorA And &HFFFFFF) - _ + (((ColorB And &HFF&) * &H10000) Or _ + (ColorB And &HFF00&) Or _ + ((ColorB And &HFF0000) \ &H10000)) + End If + End If + + If ((Tolerance > 0) And (FreeImage_CompareColorsLongLong <> 0)) Then + If (bFormatEqual) Then + If (Abs(((ColorA \ &H10000) And &HFF) - ((ColorB \ &H10000) And &HFF)) <= Tolerance) Then + If (Abs(((ColorA \ &H100) And &HFF) - ((ColorB \ &H100) And &HFF)) <= Tolerance) Then + If (Abs((ColorA And &HFF) - (ColorB And &HFF)) <= Tolerance) Then + If (bAlphaEqual) Then + If (Abs(((ColorA \ &H1000000) And &HFF) - _ + ((ColorB \ &H1000000) And &HFF)) <= Tolerance) Then + FreeImage_CompareColorsLongLong = 0 + End If + Else + FreeImage_CompareColorsLongLong = 0 + End If + End If + End If + End If + Else + If (Abs(((ColorA \ &H10000) And &HFF) - (ColorB And &HFF)) <= Tolerance) Then + If (Abs(((ColorA \ &H100) And &HFF) - ((ColorB \ &H100) And &HFF)) <= Tolerance) Then + If (Abs((ColorA And &HFF) - ((ColorB \ &H10000) And &HFF)) <= Tolerance) Then + If (bAlphaEqual) Then + If (Abs(((ColorA \ &H1000000) And &HFF) - _ + ((ColorB \ &H1000000) And &HFF)) <= Tolerance) Then + FreeImage_CompareColorsLongLong = 0 + End If + Else + FreeImage_CompareColorsLongLong = 0 + End If + End If + End If + End If + End If + End If + End If + +End Function + +Public Function FreeImage_CompareColorsRGBTRIPLELong(ByRef ColorA As RGBTRIPLE, _ + ByVal ColorB As Long, _ + Optional ByVal Tolerance As Long, _ + Optional ByVal ColorTypeB As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB) As Long + +Dim lcColorA As Long + + ' This is a function derived from 'FreeImage_CompareColorsLongLong()' to make color + ' comparisons between two colors whereby one color is provided as RGBTRIPLE and the + ' other color is provided as Long value. + + ' Have a look at the documentation of 'FreeImage_CompareColorsLongLong()' to learn + ' more about color comparisons. + + Call CopyMemory(lcColorA, ColorA, 3) + FreeImage_CompareColorsRGBTRIPLELong = FreeImage_CompareColorsLongLong(lcColorA, ColorB, _ + Tolerance, FICFF_COLOR_RGB, ColorTypeB) + +End Function + +Public Function FreeImage_CompareColorsRGBQUADLong(ByRef ColorA As RGBQUAD, _ + ByVal ColorB As Long, _ + Optional ByVal Tolerance As Long, _ + Optional ByVal ColorTypeB As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_ARGB) As Long + +Dim lcColorA As Long + + ' This is a function derived from 'FreeImage_CompareColorsLongLong()' to make color + ' comparisons between two colors whereby one color is provided as RGBQUAD and the + ' other color is provided as Long value. + + ' Have a look at the documentation of 'FreeImage_CompareColorsLongLong()' to learn + ' more about color comparisons. + + Call CopyMemory(lcColorA, ColorA, 4) + FreeImage_CompareColorsRGBQUADLong = FreeImage_CompareColorsLongLong(lcColorA, ColorB, _ + Tolerance, FICFF_COLOR_ARGB, ColorTypeB) + +End Function + +Public Function FreeImage_SearchPalette(ByVal Bitmap As Long, _ + ByVal Color As Long, _ + Optional ByVal Tolerance As Long, _ + Optional ByVal ColorType As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal TransparencyState As FREE_IMAGE_TRANSPARENCY_STATE_FLAGS = FITSF_IGNORE_TRANSPARENCY) As Long + +Dim abTransparencyTable() As Byte +Dim alPalette() As Long +Dim i As Long + + ' This function searches an image's color palette for a certain color specified as a + ' 32 bit Long value in either RGB or BGR format. + + ' A search tolerance may be specified in the 'Tolerance' parameter. + + ' If no transparency tabe was found for the specified image, transparency information will + ' be ignored during the search. Then, the function behaves as if FITSF_IGNORE_TRANSPARENCY + ' was specified for parameter TransparencyState. + + ' Use the 'TransparencyState' parameter to control, how the transparency state of + ' the found palette entry affects the result. These values may be used: + + ' FITSF_IGNORE_TRANSPARENCY: Returns the index of the first palette entry which + ' matches the red, green and blue components. + ' + ' FITSF_NONTRANSPARENT: Returns the index of the first palette entry which + ' matches the red, green and blue components and is + ' nontransparent (fully opaque). + ' + ' FITSF_TRANSPARENT: Returns the index of the first palette entry which + ' matches the red, green and blue components and is + ' fully transparent. + ' + ' FITSF_INCLUDE_ALPHA_TRANSPARENCY: Returns the index of the first palette entry which + ' matches the red, green and blue components as well + ' as the alpha transparency. + + ' When alpha transparency should be included in the palette search ('FITSF_INCLUDE_ALPHA_TRANSPARENCY'), + ' the alpha transparency of the color searched is taken from the left most byte of 'Color' + ' (Color is either in format ARGB or ABGR). The the alpha transparency of the palette entry + ' actually comes from the image's transparency table rather than from the palette, since palettes + ' do not contain transparency information. + + If (FreeImage_GetImageType(Bitmap) = FIT_BITMAP) Then + Select Case FreeImage_GetColorType(Bitmap) + + Case FIC_PALETTE, FIC_MINISBLACK, FIC_MINISWHITE + FreeImage_SearchPalette = -1 + alPalette = FreeImage_GetPaletteExLong(Bitmap) + If (FreeImage_GetTransparencyCount(Bitmap) > UBound(alPalette)) Then + abTransparencyTable = FreeImage_GetTransparencyTableExClone(Bitmap) + Else + TransparencyState = FITSF_IGNORE_TRANSPARENCY + End If + For i = 0 To UBound(alPalette) + If (FreeImage_CompareColorsLongLong(Color, alPalette(i), _ + Tolerance, _ + ColorType, FICFF_COLOR_RGB) = 0) Then + Select Case TransparencyState + + Case FITSF_IGNORE_TRANSPARENCY + FreeImage_SearchPalette = i + Exit For + + Case FITSF_NONTRANSPARENT + If (abTransparencyTable(i) = 255) Then + FreeImage_SearchPalette = i + Exit For + End If + + Case FITSF_TRANSPARENT + If (abTransparencyTable(i) = 0) Then + FreeImage_SearchPalette = i + Exit For + End If + + Case FITSF_INCLUDE_ALPHA_TRANSPARENCY + If (abTransparencyTable(i) = ((Color And &HFF000000) \ 1000000)) Then + FreeImage_SearchPalette = i + Exit For + End If + + End Select + End If + Next i + + Case Else + FreeImage_SearchPalette = -1 + + End Select + Else + FreeImage_SearchPalette = -1 + End If + +End Function + +Public Function FreeImage_GetIcon(ByVal hDIB As Long, _ + Optional ByVal eTransparencyOptions As FREE_IMAGE_ICON_TRANSPARENCY_OPTION_FLAGS = ITOF_USE_DEFAULT_TRANSPARENCY, _ + Optional ByVal lciTransparentColor As Long, _ + Optional ByVal eTransparentColorType As FREE_IMAGE_COLOR_FORMAT_FLAGS = FICFF_COLOR_RGB, _ + Optional ByVal hDC As Long, _ + Optional ByVal UnloadSource As Boolean) As Long + +Dim tIconInfo As ICONINFO +Dim bReleaseDC As Boolean +Dim bModifySourceImage As Boolean +Dim eMaskFlags As FREE_IMAGE_MASK_FLAGS +Dim lBitDepth As Long +Dim bPixelIndex As Byte +Dim hDIBSrc As Long +Dim hDIBMask As Long +Dim hBMPMask As Long +Dim hBmp As Long + + ' The optional 'UnloadSource' parameter is for unloading the original image + ' after the OlePicture has been created, so you can easiely "switch" from a + ' FreeImage DIB to a VB Picture object. There is no need to clean up the DIB + ' at the caller's site. + + If (hDIB) Then + + If (Not FreeImage_HasPixels(hDIB)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to create an icon from a 'header-only' bitmap.") + End If + + lBitDepth = FreeImage_GetBPP(hDIB) + + ' check whether the image supports transparency + Select Case lBitDepth + + Case 4, 8 + If (eTransparencyOptions And ITOF_USE_TRANSPARENCY_INFO) Then + If (FreeImage_IsTransparent(hDIB)) Then + eMaskFlags = FIMF_MASK_FULL_TRANSPARENCY + ElseIf (eTransparencyOptions And ITOF_FORCE_TRANSPARENCY_INFO) Then + If (FreeImage_IsTransparencyTableTransparent(hDIB)) Then + eMaskFlags = (FIMF_MASK_FULL_TRANSPARENCY And _ + FIMF_MASK_FORCE_TRANSPARENCY) + End If + End If + End If + If ((eMaskFlags = FIMF_MASK_NONE) And _ + (eTransparencyOptions And ITOF_USE_COLOR_TRANSPARENCY)) Then + + eMaskFlags = FIMF_MASK_COLOR_TRANSPARENCY + + Select Case (eTransparencyOptions And ITOF_USE_COLOR_BITMASK) + + Case ITOF_USE_COLOR_TOP_LEFT_PIXEL + Call FreeImage_GetPixelIndex(hDIB, _ + 0, FreeImage_GetHeight(hDIB) - 1, _ + bPixelIndex) + lciTransparentColor = bPixelIndex + eTransparentColorType = FICFF_COLOR_PALETTE_INDEX + + Case ITOF_USE_COLOR_TOP_RIGHT_PIXEL + Call FreeImage_GetPixelIndex(hDIB, _ + FreeImage_GetWidth(hDIB) - 1, FreeImage_GetHeight(hDIB) - 1, _ + bPixelIndex) + lciTransparentColor = bPixelIndex + eTransparentColorType = FICFF_COLOR_PALETTE_INDEX + + Case ITOF_USE_COLOR_BOTTOM_LEFT_PIXEL + Call FreeImage_GetPixelIndex(hDIB, _ + 0, 0, _ + bPixelIndex) + lciTransparentColor = bPixelIndex + eTransparentColorType = FICFF_COLOR_PALETTE_INDEX + + Case ITOF_USE_COLOR_BOTTOM_RIGHT_PIXEL + Call FreeImage_GetPixelIndex(hDIB, _ + FreeImage_GetWidth(hDIB) - 1, 0, _ + bPixelIndex) + lciTransparentColor = bPixelIndex + eTransparentColorType = FICFF_COLOR_PALETTE_INDEX + + End Select + End If + + bModifySourceImage = True + + Case 24, 32 + If ((lBitDepth = 32) And _ + (eTransparencyOptions And ITOF_USE_TRANSPARENCY_INFO)) Then + If (FreeImage_IsTransparent(hDIB)) Then + eMaskFlags = FIMF_MASK_FULL_TRANSPARENCY + End If + End If + If ((eMaskFlags = FIMF_MASK_NONE) And _ + (eTransparencyOptions And ITOF_USE_COLOR_TRANSPARENCY)) Then + + eMaskFlags = FIMF_MASK_COLOR_TRANSPARENCY + + Select Case (eTransparencyOptions And ITOF_USE_COLOR_BITMASK) + + Case ITOF_USE_COLOR_TOP_LEFT_PIXEL + Call FreeImage_GetPixelColorByLong(hDIB, _ + FreeImage_GetHeight(hDIB) - 1, 0, _ + lciTransparentColor) + eTransparentColorType = FICFF_COLOR_RGB + + Case ITOF_USE_COLOR_TOP_RIGHT_PIXEL + Call FreeImage_GetPixelColorByLong(hDIB, _ + FreeImage_GetHeight(hDIB) - 1, FreeImage_GetWidth(hDIB) - 1, _ + lciTransparentColor) + eTransparentColorType = FICFF_COLOR_RGB + + Case ITOF_USE_COLOR_BOTTOM_LEFT_PIXEL + Call FreeImage_GetPixelColorByLong(hDIB, _ + 0, 0, _ + lciTransparentColor) + eTransparentColorType = FICFF_COLOR_RGB + + Case ITOF_USE_COLOR_BOTTOM_RIGHT_PIXEL + Call FreeImage_GetPixelColorByLong(hDIB, _ + 0, FreeImage_GetWidth(hDIB) - 1, _ + lciTransparentColor) + eTransparentColorType = FICFF_COLOR_RGB + + End Select + End If + + bModifySourceImage = (lBitDepth = 24) + + End Select + + + If (bModifySourceImage) Then + hDIBSrc = FreeImage_Clone(hDIB) + hDIBMask = FreeImage_CreateMask(hDIBSrc, MCOF_CREATE_AND_MODIFY, _ + 1, eMaskFlags, _ + lciTransparentColor, eTransparentColorType, _ + , , , , , _ + FreeImage_SearchPalette(hDIBSrc, 0, , , _ + FITSF_NONTRANSPARENT), _ + FICFF_COLOR_PALETTE_INDEX) + Else + hDIBSrc = hDIB + hDIBMask = FreeImage_CreateMaskImage(hDIB, 1, FIMF_MASK_FULL_TRANSPARENCY) + End If + + If (hDC = 0) Then + hDC = GetDC(0) + bReleaseDC = True + End If + + hBmp = CreateDIBitmap(hDC, _ + FreeImage_GetInfoHeader(hDIBSrc), _ + CBM_INIT, _ + FreeImage_GetBits(hDIBSrc), _ + FreeImage_GetInfo(hDIBSrc), _ + DIB_RGB_COLORS) + + + hBMPMask = CreateDIBitmap(hDC, _ + FreeImage_GetInfoHeader(hDIBMask), _ + CBM_INIT, _ + FreeImage_GetBits(hDIBMask), _ + FreeImage_GetInfo(hDIBMask), _ + DIB_RGB_COLORS) + + If (bModifySourceImage) Then + Call FreeImage_Unload(hDIBSrc) + End If + + If (UnloadSource) Then + Call FreeImage_Unload(hDIB) + End If + + + If ((hBmp <> 0) And (hBMPMask <> 0)) Then + + With tIconInfo + .fIcon = True + .hBmMask = hBMPMask + .hbmColor = hBmp + End With + + FreeImage_GetIcon = CreateIconIndirect(tIconInfo) + End If + + If (bReleaseDC) Then + Call ReleaseDC(0, hDC) + End If + End If + +End Function + +Public Function FreeImage_AdjustPictureBox(ByRef Control As Object, _ + Optional ByVal Mode As FREE_IMAGE_ADJUST_MODE = AM_DEFAULT, _ + Optional ByVal Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC) As IPicture + +Dim tR As RECT +Dim hDIB As Long +Dim hDIBTemp As Long +Dim lNewWidth As Long +Dim lNewHeight As Long + +Const vbObjectOrWithBlockVariableNotSet As Long = 91 + + ' This function adjusts an already loaded picture in a VB PictureBox + ' control in size. This is done by converting the picture to a Bitmap + ' by FreeImage_CreateFromOlePicture. After resizing the Bitmap it is + ' converted back to a Ole Picture object and re-assigned to the + ' PictureBox control. + + ' The Control paramater is actually of type Object so any object or control + ' providing Picture, hWnd, Width and Height properties can be used instead + ' of a PictureBox control + + ' This may be useful when using compile time provided images in VB like + ' logos or backgrounds that need to be resized during runtime. Using + ' FreeImage's sophisticated rescaling methods is a much better aproach + ' than using VB's stretchable Image control. + + ' One reason for resizing a usually fixed size logo or background image + ' may be the following scenario: + + ' When running on a Windows machine using smaller or bigger fonts (what can + ' be configured in the control panel by using different dpi fonts), the + ' operation system automatically adjusts the sizes of Forms, Labels, + ' TextBoxes, Frames and even PictureBoxes. So, the hole VB application is + ' perfectly adapted to these font metrics with the exception of compile time + ' provided images. Although the PictureBox control is resized, the containing + ' image remains untouched. This problem could be solved with this function. + + ' This function is also wrapped by the function 'AdjustPicture', giving you + ' a more VB common function name. + + + If (Not Control Is Nothing) Then + Call GetClientRect(Control.hWnd, tR) + If ((tR.Right <> Control.Picture.Width) Or _ + (tR.Bottom <> Control.Picture.Height)) Then + hDIB = FreeImage_CreateFromOlePicture(Control.Picture) + If (hDIB) Then + If (Mode = AM_ADJUST_OPTIMAL_SIZE) Then + If (Control.Picture.Width >= Control.Picture.Height) Then + Mode = AM_ADJUST_WIDTH + Else + Mode = AM_ADJUST_HEIGHT + End If + End If + + Select Case Mode + + Case AM_STRECH + lNewWidth = tR.Right + lNewHeight = tR.Bottom + + Case AM_ADJUST_WIDTH + lNewWidth = tR.Right + lNewHeight = lNewWidth / (Control.Picture.Width / Control.Picture.Height) + + Case AM_ADJUST_HEIGHT + lNewHeight = tR.Bottom + lNewWidth = lNewHeight * (Control.Picture.Width / Control.Picture.Height) + + End Select + + hDIBTemp = hDIB + hDIB = FreeImage_Rescale(hDIB, lNewWidth, lNewHeight, Filter) + Call FreeImage_Unload(hDIBTemp) + Set Control.Picture = FreeImage_GetOlePicture(hDIB, , True) + Set FreeImage_AdjustPictureBox = Control.Picture + End If + End If + Else + Call Err.Raise(vbObjectOrWithBlockVariableNotSet) + End If + +End Function + +Public Function AdjustPicture(ByRef Control As Object, _ + Optional ByRef Mode As FREE_IMAGE_ADJUST_MODE = AM_DEFAULT, _ + Optional ByRef Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC) As IPicture + + ' This function is a more VB friendly signed wrapper for + ' the FreeImage_AdjustPictureBox function. + + Set AdjustPicture = FreeImage_AdjustPictureBox(Control, Mode, Filter) + +End Function + +Public Function FreeImage_LoadEx(ByVal Filename As String, _ + Optional ByVal Options As FREE_IMAGE_LOAD_OPTIONS, _ + Optional ByVal Width As Variant, _ + Optional ByVal Height As Variant, _ + Optional ByVal InPercent As Boolean, _ + Optional ByVal Filter As FREE_IMAGE_FILTER, _ + Optional ByRef Format As FREE_IMAGE_FORMAT) As Long + +Const vbInvalidPictureError As Long = 481 + + ' The function provides all image formats, the FreeImage library can read. The + ' image format is determined from the image file to load, the optional parameter + ' 'Format' is an OUT parameter that will contain the image format that has + ' been loaded. + + ' The parameters 'Width', 'Height', 'InPercent' and 'Filter' make it possible + ' to "load" the image in a resized version. 'Width', 'Height' specify the desired + ' width and height, 'Filter' determines, what image filter should be used + ' on the resizing process. + + ' The parameters 'Width', 'Height', 'InPercent' and 'Filter' map directly to the + ' according parameters of the 'FreeImage_RescaleEx' function. So, read the + ' documentation of the 'FreeImage_RescaleEx' for a complete understanding of the + ' usage of these parameters. + + + Format = FreeImage_GetFileType(Filename) + If (Format <> FIF_UNKNOWN) Then + If (FreeImage_FIFSupportsReading(Format)) Then + FreeImage_LoadEx = FreeImage_Load(Format, Filename, Options) + If (FreeImage_LoadEx) Then + + If ((Not IsMissing(Width)) Or _ + (Not IsMissing(Height))) Then + FreeImage_LoadEx = FreeImage_RescaleEx(FreeImage_LoadEx, Width, Height, _ + InPercent, True, Filter) + End If + Else + Call Err.Raise(vbInvalidPictureError) + End If + Else + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "FreeImage Library plugin '" & FreeImage_GetFormatFromFIF(Format) & "' " & _ + "does not support reading.") + End If + Else + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "The file specified has an unknown image format.") + End If + +End Function + +Public Function LoadPictureEx(Optional ByRef Filename As Variant, _ + Optional ByRef Options As FREE_IMAGE_LOAD_OPTIONS, _ + Optional ByRef Width As Variant, _ + Optional ByRef Height As Variant, _ + Optional ByRef InPercent As Boolean, _ + Optional ByRef Filter As FREE_IMAGE_FILTER, _ + Optional ByRef Format As FREE_IMAGE_FORMAT) As IPicture + +Dim hDIB As Long + + ' This function is an extended version of the VB method 'LoadPicture'. As + ' the VB version it takes a filename parameter to load the image and throws + ' the same errors in most cases. + + ' This function now is only a thin wrapper for the FreeImage_LoadEx() wrapper + ' function (as compared to releases of this wrapper prior to version 1.8). So, + ' have a look at this function's discussion of the parameters. + + ' However, we do mask out the FILO_LOAD_NOPIXELS load option, since this + ' function shall create a VB Picture object, which does not support + ' FreeImage's header-only loading option. + + + If (Not IsMissing(Filename)) Then + hDIB = FreeImage_LoadEx(Filename, (Options And (Not FILO_LOAD_NOPIXELS)), _ + Width, Height, InPercent, Filter, Format) + Set LoadPictureEx = FreeImage_GetOlePicture(hDIB, , True) + End If + +End Function + +Public Function FreeImage_SaveEx(ByVal Bitmap As Long, _ + ByVal Filename As String, _ + Optional ByVal Format As FREE_IMAGE_FORMAT = FIF_UNKNOWN, _ + Optional ByVal Options As FREE_IMAGE_SAVE_OPTIONS, _ + Optional ByVal ColorDepth As FREE_IMAGE_COLOR_DEPTH, _ + Optional ByVal Width As Variant, _ + Optional ByVal Height As Variant, _ + Optional ByVal InPercent As Boolean, _ + Optional ByVal Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC, _ + Optional ByVal UnloadSource As Boolean) As Boolean + +Dim hDIBRescale As Long +Dim bConvertedOnRescale As Boolean +Dim bIsNewDIB As Boolean +Dim lBPP As Long +Dim lBPPOrg As Long +Dim strExtension As String + + ' This function is an easy to use replacement for FreeImage's FreeImage_Save() + ' function which supports inline size- and color conversions as well as an + ' auto image format detection algorithm that determines the desired image format + ' by the given filename. An even more sophisticated algorithm may auto-detect + ' the proper color depth for a explicitly given or auto-detected image format. + + ' The function provides all image formats, and save options, the FreeImage + ' library can write. The optional parameter 'Format' may contain the desired + ' image format. When omitted, the function tries to get the image format from + ' the filename extension. + + ' The optional parameter 'ColorDepth' may contain the desired color depth for + ' the saved image. This can be either any value of the FREE_IMAGE_COLOR_DEPTH + ' enumeration or the value FICD_AUTO what is the default value of the parameter. + ' When 'ColorDepth' is FICD_AUTO, the function tries to get the most suitable + ' color depth for the specified image format if the image's current color depth + ' is not supported by the specified image format. Therefore, the function + ' firstly reduces the color depth step by step until a proper color depth is + ' found since an incremention would only increase the file's size with no + ' quality benefit. Only when there is no lower color depth is found for the + ' image format, the function starts to increase the color depth. + + ' Keep in mind that an explicitly specified color depth that is not supported + ' by the image format results in a runtime error. For example, when saving + ' a 24 bit image as GIF image, a runtime error occurs. + + ' The function checks, whether the given filename has a valid extension or + ' not. If not, the "primary" extension for the used image format will be + ' appended to the filename. The parameter 'Filename' remains untouched in + ' this case. + + ' To learn more about the "primary" extension, read the documentation for + ' the 'FreeImage_GetPrimaryExtensionFromFIF' function. + + ' The parameters 'Width', 'Height', 'InPercent' and 'Filter' make it possible + ' to save the image in a resized version. 'Width', 'Height' specify the desired + ' width and height, 'Filter' determines, what image filter should be used + ' on the resizing process. Since FreeImage_SaveEx relies on FreeImage_RescaleEx, + ' please refer to the documentation of FreeImage_RescaleEx to learn more + ' about these four parameters. + + ' The optional 'UnloadSource' parameter is for unloading the saved image, so + ' you can save and unload an image with this function in one operation. + ' CAUTION: at current, the image is unloaded, even if the image was not + ' saved correctly! + + + If (Bitmap) Then + + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to save 'header-only' bitmaps.") + End If + + If ((Not IsMissing(Width)) Or _ + (Not IsMissing(Height))) Then + + lBPP = FreeImage_GetBPP(Bitmap) + hDIBRescale = FreeImage_RescaleEx(Bitmap, Width, Height, InPercent, UnloadSource, Filter) + bIsNewDIB = (hDIBRescale <> Bitmap) + Bitmap = hDIBRescale + bConvertedOnRescale = (lBPP <> FreeImage_GetBPP(Bitmap)) + End If + + If (Format = FIF_UNKNOWN) Then + Format = FreeImage_GetFIFFromFilename(Filename) + End If + If (Format <> FIF_UNKNOWN) Then + If ((FreeImage_FIFSupportsWriting(Format)) And _ + (FreeImage_FIFSupportsExportType(Format, FIT_BITMAP))) Then + + If (Not FreeImage_IsFilenameValidForFIF(Format, Filename)) Then + strExtension = "." & FreeImage_GetPrimaryExtensionFromFIF(Format) + End If + + ' check color depth + If (ColorDepth <> FICD_AUTO) Then + ' mask out bit 1 (0x02) for the case ColorDepth is FICD_MONOCHROME_DITHER (0x03) + ' FREE_IMAGE_COLOR_DEPTH values are true bit depths in general expect FICD_MONOCHROME_DITHER + ' by masking out bit 1, 'FreeImage_FIFSupportsExportBPP()' tests for bitdepth 1 + ' what is correct again for dithered images. + ColorDepth = (ColorDepth And (Not &H2)) + If (Not FreeImage_FIFSupportsExportBPP(Format, ColorDepth)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "FreeImage Library plugin '" & FreeImage_GetFormatFromFIF(Format) & "' " & _ + "is unable to write images with a color depth " & _ + "of " & ColorDepth & " bpp.") + + ElseIf (FreeImage_GetBPP(Bitmap) <> ColorDepth) Then + Bitmap = FreeImage_ConvertColorDepth(Bitmap, ColorDepth, (UnloadSource Or bIsNewDIB)) + bIsNewDIB = True + + End If + Else + + If (lBPP = 0) Then + lBPP = FreeImage_GetBPP(Bitmap) + End If + + If (Not FreeImage_FIFSupportsExportBPP(Format, lBPP)) Then + lBPPOrg = lBPP + Do + lBPP = pGetPreviousColorDepth(lBPP) + Loop While ((Not FreeImage_FIFSupportsExportBPP(Format, lBPP)) Or _ + (lBPP = 0)) + If (lBPP = 0) Then + lBPP = lBPPOrg + Do + lBPP = pGetNextColorDepth(lBPP) + Loop While ((Not FreeImage_FIFSupportsExportBPP(Format, lBPP)) Or _ + (lBPP = 0)) + End If + + If (lBPP <> 0) Then + Bitmap = FreeImage_ConvertColorDepth(Bitmap, lBPP, (UnloadSource Or bIsNewDIB)) + bIsNewDIB = True + End If + + ElseIf (bConvertedOnRescale) Then + ' restore original color depth + ' always unload current DIB here, since 'bIsNewDIB' is True + Bitmap = FreeImage_ConvertColorDepth(Bitmap, lBPP, True) + + End If + End If + + FreeImage_SaveEx = FreeImage_Save(Format, Bitmap, Filename & strExtension, Options) + If ((bIsNewDIB) Or (UnloadSource)) Then + Call FreeImage_Unload(Bitmap) + End If + Else + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "FreeImage Library plugin '" & FreeImage_GetFormatFromFIF(Format) & "' " & _ + "is unable to write images of the image format requested.") + End If + Else + ' unknown image format error + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unknown image format. Neither an explicit image format " & _ + "was specified nor any known image format was determined " & _ + "from the filename specified.") + End If + End If + +End Function + +Public Function SavePictureEx(ByRef Picture As IPicture, _ + ByRef Filename As String, _ + Optional ByRef Format As FREE_IMAGE_FORMAT, _ + Optional ByRef Options As FREE_IMAGE_SAVE_OPTIONS, _ + Optional ByRef ColorDepth As FREE_IMAGE_COLOR_DEPTH, _ + Optional ByRef Width As Variant, _ + Optional ByRef Height As Variant, _ + Optional ByRef InPercent As Boolean, _ + Optional ByRef Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC) As Boolean + +Dim hDIB As Long + +Const vbObjectOrWithBlockVariableNotSet As Long = 91 +Const vbInvalidPictureError As Long = 481 + + ' This function is an extended version of the VB method 'SavePicture'. As + ' the VB version it takes a Picture object and a filename parameter to + ' save the image and throws the same errors in most cases. + + ' This function now is only a thin wrapper for the FreeImage_SaveEx() wrapper + ' function (as compared to releases of this wrapper prior to version 1.8). So, + ' have a look at this function's discussion of the parameters. + + + If (Not Picture Is Nothing) Then + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + SavePictureEx = FreeImage_SaveEx(hDIB, Filename, Format, Options, _ + ColorDepth, Width, Height, InPercent, _ + FILTER_BICUBIC, True) + Else + Call Err.Raise(vbInvalidPictureError) + End If + Else + Call Err.Raise(vbObjectOrWithBlockVariableNotSet) + End If + +End Function + +Public Function SaveImageContainerEx(ByRef Container As Object, _ + ByRef Filename As String, _ + Optional ByVal IncludeDrawings As Boolean, _ + Optional ByRef Format As FREE_IMAGE_FORMAT, _ + Optional ByRef Options As FREE_IMAGE_SAVE_OPTIONS, _ + Optional ByRef ColorDepth As FREE_IMAGE_COLOR_DEPTH, _ + Optional ByRef Width As Variant, _ + Optional ByRef Height As Variant, _ + Optional ByRef InPercent As Boolean, _ + Optional ByRef Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC) As Long + + ' This function is an extended version of the VB method 'SavePicture'. As + ' the VB version it takes an image hosting control and a filename parameter to + ' save the image and throws the same errors in most cases. + + ' This function merges the functionality of both wrapper functions + ' 'SavePictureEx()' and 'FreeImage_CreateFromImageContainer()'. Basically this + ' function is identical to 'SavePictureEx' expect that is does not take a + ' IOlePicture (IPicture) object but a VB image hosting container control. + + ' Please, refer to each of this two function's inline documentation for a + ' more detailed description. + + Call SavePictureEx(pGetIOlePictureFromContainer(Container, IncludeDrawings), _ + Filename, Format, Options, ColorDepth, Width, Height, InPercent, Filter) + +End Function + +Public Function FreeImage_OpenMultiBitmapEx(ByVal Filename As String, _ + Optional ByVal ReadOnly As Boolean, _ + Optional ByVal KeepCacheInMemory As Boolean, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS, _ + Optional ByRef Format As FREE_IMAGE_FORMAT) As Long + + Format = FreeImage_GetFileType(Filename) + If (Format <> FIF_UNKNOWN) Then + Select Case Format + + Case FIF_TIFF, FIF_GIF, FIF_ICO + FreeImage_OpenMultiBitmapEx = FreeImage_OpenMultiBitmap(Format, Filename, False, _ + ReadOnly, KeepCacheInMemory, Flags) + + Case Else + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "FreeImage Library plugin '" & FreeImage_GetFormatFromFIF(Format) & "' " & _ + "does not have any support for multi-page bitmaps.") + End Select + Else + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "The file specified has an unknown image format.") + End If + +End Function + +Public Function FreeImage_CreateMultiBitmapEx(ByVal Filename As String, _ + Optional ByVal KeepCacheInMemory As Boolean, _ + Optional ByVal Flags As FREE_IMAGE_LOAD_OPTIONS, _ + Optional ByRef Format As FREE_IMAGE_FORMAT) As Long + + If (Format = FIF_UNKNOWN) Then + Format = FreeImage_GetFIFFromFilename(Filename) + End If + + If (Format <> FIF_UNKNOWN) Then + Select Case Format + + Case FIF_TIFF, FIF_GIF, FIF_ICO + FreeImage_CreateMultiBitmapEx = FreeImage_OpenMultiBitmap(Format, Filename, True, _ + False, KeepCacheInMemory, Flags) + + Case Else + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "FreeImage Library plugin '" & _ + FreeImage_GetFormatFromFIF(Format) & "' " & _ + "does not have any support for multi-page bitmaps.") + End Select + Else + ' unknown image format error + Call Err.Raise(5, _ + "MFreeImage", _ + Error$(5) & vbCrLf & vbCrLf & _ + "Unknown image format. Neither an explicit image format " & _ + "was specified nor any known image format was determined " & _ + "from the filename specified.") + End If + +End Function + + + +'-------------------------------------------------------------------------------- +' OlePicture aware toolkit, rescale and conversion functions +'-------------------------------------------------------------------------------- + +Public Function FreeImage_RescaleIOP(ByRef Picture As IPicture, _ + Optional ByVal Width As Variant, _ + Optional ByVal Height As Variant, _ + Optional ByVal IsPercentValue As Boolean, _ + Optional ByVal Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC, _ + Optional ByVal ForceCloneCreation As Boolean) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for wrapper function FreeImage_RescaleEx() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + hDIB = FreeImage_RescaleEx(hDIB, Width, Height, IsPercentValue, _ + True, Filter, ForceCloneCreation) + Set FreeImage_RescaleIOP = FreeImage_GetOlePicture(hDIB, , True) + End If + +End Function + +Public Function FreeImage_RescaleByPixelIOP(ByRef Picture As IPicture, _ + Optional ByVal WidthInPixels As Long, _ + Optional ByVal HeightInPixels As Long, _ + Optional ByVal Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC, _ + Optional ByVal ForceCloneCreation As Boolean) As IPicture + + ' Thin wrapper for function 'FreeImage_RescaleExIOP' for removing method + ' overload fake. This function rescales the image directly to the size + ' specified by the 'WidthInPixels' and 'HeightInPixels' parameters. + + Set FreeImage_RescaleByPixelIOP = FreeImage_RescaleIOP(Picture, WidthInPixels, HeightInPixels, _ + False, Filter, ForceCloneCreation) + +End Function + +Public Function FreeImage_RescaleByPercentIOP(ByRef Picture As IPicture, _ + Optional ByVal WidthPercentage As Double, _ + Optional ByVal HeightPercentage As Double, _ + Optional ByVal Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC, _ + Optional ByVal ForceCloneCreation As Boolean) As IPicture + + ' Thin wrapper for function 'FreeImage_RescaleExIOP' for removing method + ' overload fake. This function rescales the image by a percent value + ' based on the image's original size. + + Set FreeImage_RescaleByPercentIOP = FreeImage_RescaleIOP(Picture, WidthPercentage, HeightPercentage, _ + True, Filter, ForceCloneCreation) + +End Function + +Public Function FreeImage_RescaleByFactorIOP(ByRef Picture As IPicture, _ + Optional ByVal WidthFactor As Double, _ + Optional ByVal HeightFactor As Double, _ + Optional ByVal Filter As FREE_IMAGE_FILTER = FILTER_BICUBIC, _ + Optional ByVal ForceCloneCreation As Boolean) As IPicture + + ' Thin wrapper for function 'FreeImage_RescaleExIOP' for removing method + ' overload fake. This function rescales the image by a factor + ' based on the image's original size. + + Set FreeImage_RescaleByFactorIOP = FreeImage_RescaleIOP(Picture, WidthFactor, HeightFactor, _ + False, Filter, ForceCloneCreation) + +End Function + +Public Function FreeImage_MakeThumbnailIOP(ByRef Picture As IPicture, _ + ByVal MaxPixelSize As Long, _ + Optional ByVal Convert As Boolean) As IPicture + +Dim hDIB As Long +Dim hDIBThumbnail As Long + + ' IOlePicture based wrapper for wrapper function FreeImage_MakeThumbnail() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + hDIBThumbnail = FreeImage_MakeThumbnail(hDIB, MaxPixelSize, Convert) + If (hDIBThumbnail) Then + Set FreeImage_MakeThumbnailIOP = FreeImage_GetOlePicture(hDIBThumbnail, , True) + End If + Call FreeImage_Unload(hDIB) + End If + +End Function + +Public Function FreeImage_ConvertColorDepthIOP(ByRef Picture As IPicture, _ + ByVal Conversion As FREE_IMAGE_CONVERSION_FLAGS, _ + Optional ByVal Threshold As Byte = 128, _ + Optional ByVal DitherMethod As FREE_IMAGE_DITHER = FID_FS, _ + Optional ByVal QuantizeMethod As FREE_IMAGE_QUANTIZE = FIQ_WUQUANT) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for wrapper function FreeImage_ConvertColorDepth() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + hDIB = FreeImage_ConvertColorDepth(hDIB, Conversion, True, Threshold, _ + DitherMethod, QuantizeMethod) + Set FreeImage_ConvertColorDepthIOP = FreeImage_GetOlePicture(hDIB, , True) + End If + +End Function + +Public Function FreeImage_ColorQuantizeExIOP(ByRef Picture As IPicture, _ + Optional ByVal QuantizeMethod As FREE_IMAGE_QUANTIZE = FIQ_WUQUANT, _ + Optional ByVal PaletteSize As Long = 256, _ + Optional ByVal ReserveSize As Long, _ + Optional ByRef ReservePalette As Variant = Null) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for wrapper function FreeImage_ColorQuantizeEx() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + hDIB = FreeImage_ColorQuantizeEx(hDIB, QuantizeMethod, True, PaletteSize, _ + ReserveSize, ReservePalette) + Set FreeImage_ColorQuantizeExIOP = FreeImage_GetOlePicture(hDIB, , True) + End If + +End Function + +Public Function FreeImage_RotateClassicIOP(ByRef Picture As IPicture, _ + ByVal Angle As Double) As IPicture + +Dim hDIB As Long +Dim hDIBNew As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_RotateClassic() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Select Case FreeImage_GetBPP(hDIB) + + Case 1, 8, 24, 32 + hDIBNew = FreeImage_RotateClassic(hDIB, Angle) + Set FreeImage_RotateClassicIOP = FreeImage_GetOlePicture(hDIBNew, , True) + + End Select + Call FreeImage_Unload(hDIB) + End If + +End Function + +Public Function FreeImage_RotateIOP(ByRef Picture As IPicture, _ + ByVal Angle As Double, _ + Optional ByVal ColorPtr As Long) As IPicture + +Dim hDIB As Long +Dim hDIBNew As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_Rotate() + + ' The optional ColorPtr parameter takes a pointer to (e.g. the address of) an + ' RGB color value. So, all these assignments are valid for ColorPtr: + ' + ' Dim tColor As RGBQUAD + ' + ' VarPtr(tColor) + ' VarPtr(&H33FF80) + ' VarPtr(vbWhite) ' However, the VB color constants are in BGR format! + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Select Case FreeImage_GetBPP(hDIB) + + Case 1, 8, 24, 32 + hDIBNew = FreeImage_Rotate(hDIB, Angle, ByVal ColorPtr) + Set FreeImage_RotateIOP = FreeImage_GetOlePicture(hDIBNew, , True) + + End Select + Call FreeImage_Unload(hDIB) + End If + +End Function + +Public Function FreeImage_RotateExIOP(ByRef Picture As IPicture, _ + ByVal Angle As Double, _ + Optional ByVal ShiftX As Double, _ + Optional ByVal ShiftY As Double, _ + Optional ByVal OriginX As Double, _ + Optional ByVal OriginY As Double, _ + Optional ByVal UseMask As Boolean) As IPicture + +Dim hDIB As Long +Dim hDIBNew As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_RotateEx() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Select Case FreeImage_GetBPP(hDIB) + + Case 8, 24, 32 + hDIBNew = FreeImage_RotateEx(hDIB, Angle, ShiftX, ShiftY, OriginX, OriginY, UseMask) + Set FreeImage_RotateExIOP = FreeImage_GetOlePicture(hDIBNew, , True) + + End Select + Call FreeImage_Unload(hDIB) + End If + +End Function + +Public Function FreeImage_FlipHorizontalIOP(ByRef Picture As IPicture) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_FlipHorizontal() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Call FreeImage_FlipHorizontalInt(hDIB) + Set FreeImage_FlipHorizontalIOP = FreeImage_GetOlePicture(hDIB, , True) + End If + +End Function + +Public Function FreeImage_FlipVerticalIOP(ByRef Picture As IPicture) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_FlipVertical() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Call FreeImage_FlipVerticalInt(hDIB) + Set FreeImage_FlipVerticalIOP = FreeImage_GetOlePicture(hDIB, , True) + End If + +End Function + +Public Function FreeImage_AdjustCurveIOP(ByRef Picture As IPicture, _ + ByRef LookupTable As Variant, _ + Optional ByVal Channel As FREE_IMAGE_COLOR_CHANNEL = FICC_BLACK) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_AdjustCurve() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Select Case FreeImage_GetBPP(hDIB) + + Case 8, 24, 32 + Call FreeImage_AdjustCurveEx(hDIB, LookupTable, Channel) + Set FreeImage_AdjustCurveIOP = FreeImage_GetOlePicture(hDIB, , True) + + End Select + End If + +End Function + +Public Function FreeImage_AdjustGammaIOP(ByRef Picture As IPicture, _ + ByVal Gamma As Double) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_AdjustGamma() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Select Case FreeImage_GetBPP(hDIB) + + Case 8, 24, 32 + Call FreeImage_AdjustGammaInt(hDIB, Gamma) + Set FreeImage_AdjustGammaIOP = FreeImage_GetOlePicture(hDIB, , True) + + End Select + End If + +End Function + +Public Function FreeImage_AdjustBrightnessIOP(ByRef Picture As IPicture, _ + ByVal Percentage As Double) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_AdjustBrightness() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Select Case FreeImage_GetBPP(hDIB) + + Case 8, 24, 32 + Call FreeImage_AdjustBrightnessInt(hDIB, Percentage) + Set FreeImage_AdjustBrightnessIOP = FreeImage_GetOlePicture(hDIB, , True) + + End Select + End If + +End Function + +Public Function FreeImage_AdjustContrastIOP(ByRef Picture As IPicture, _ + ByVal Percentage As Double) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_AdjustContrast() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Select Case FreeImage_GetBPP(hDIB) + + Case 8, 24, 32 + Call FreeImage_AdjustContrastInt(hDIB, Percentage) + Set FreeImage_AdjustContrastIOP = FreeImage_GetOlePicture(hDIB, , True) + + End Select + End If + +End Function + +Public Function FreeImage_InvertIOP(ByRef Picture As IPicture) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_Invert() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Call FreeImage_InvertInt(hDIB) + Set FreeImage_InvertIOP = FreeImage_GetOlePicture(hDIB, , True) + End If + +End Function + +Public Function FreeImage_GetChannelIOP(ByRef Picture As IPicture, _ + ByVal Channel As FREE_IMAGE_COLOR_CHANNEL) As IPicture + +Dim hDIB As Long +Dim hDIBNew As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_GetChannel() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Select Case FreeImage_GetBPP(hDIB) + + Case 24, 32 + hDIBNew = FreeImage_GetChannel(hDIB, Channel) + Set FreeImage_GetChannelIOP = FreeImage_GetOlePicture(hDIBNew, , True) + + End Select + Call FreeImage_Unload(hDIB) + End If + +End Function + +Public Function FreeImage_SetChannelIOP(ByRef Picture As IPicture, _ + ByVal BitmapSrc As Long, _ + ByVal Channel As FREE_IMAGE_COLOR_CHANNEL) As IPicture + +Dim hDIB As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_SetChannel() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + Select Case FreeImage_GetBPP(hDIB) + + Case 24, 32 + If (FreeImage_SetChannel(hDIB, BitmapSrc, Channel)) Then + Set FreeImage_SetChannelIOP = FreeImage_GetOlePicture(hDIB, , True) + End If + + End Select + Call FreeImage_Unload(hDIB) + End If + +End Function + +Public Function FreeImage_CopyIOP(ByRef Picture As IPicture, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Right As Long, _ + ByVal Bottom As Long) As IPicture + +Dim hDIB As Long +Dim hDIBNew As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_Copy() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + hDIBNew = FreeImage_Copy(hDIB, Left, Top, Right, Bottom) + Call FreeImage_Unload(hDIB) + Set FreeImage_CopyIOP = FreeImage_GetOlePicture(hDIBNew, , True) + End If + +End Function + +Public Function FreeImage_PasteIOP(ByRef PictureDst As IPicture, _ + ByRef PictureSrc As IPicture, _ + ByVal Left As Long, _ + ByVal Top As Long, _ + ByVal Alpha As Long, _ + Optional ByVal KeepOriginalDestImage As Boolean) As IPicture + +Dim hDIBDst As Long +Dim hDIBSrc As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_Paste() + + hDIBDst = FreeImage_CreateFromOlePicture(PictureDst) + If (hDIBDst) Then + hDIBSrc = FreeImage_CreateFromOlePicture(PictureSrc) + If (hDIBSrc) Then + If FreeImage_Paste(hDIBDst, hDIBSrc, Left, Top, Alpha) Then + Set FreeImage_PasteIOP = FreeImage_GetOlePicture(hDIBDst, , True) + If (Not KeepOriginalDestImage) Then + Set PictureDst = FreeImage_PasteIOP + End If + End If + Call FreeImage_Unload(hDIBSrc) + End If + End If + +End Function + +Public Function FreeImage_CompositeIOP(ByRef Picture As IPicture, _ + Optional ByVal UseFileBackColor As Boolean, _ + Optional ByVal AppBackColor As OLE_COLOR, _ + Optional ByRef BackgroundPicture As IPicture) As IPicture + +Dim hDIB As Long +Dim hDIBbg As Long +Dim hDIBResult As Long +Dim lUseFileBackColor As Long + + ' IOlePicture based wrapper for FreeImage function FreeImage_Composite() + + hDIB = FreeImage_CreateFromOlePicture(Picture) + If (hDIB) Then + + If (UseFileBackColor) Then + lUseFileBackColor = 1 + End If + + hDIBbg = FreeImage_CreateFromOlePicture(BackgroundPicture) + + hDIBResult = FreeImage_Composite(hDIB, lUseFileBackColor, ConvertColor(AppBackColor), hDIBbg) + If (hDIBResult) Then + Set FreeImage_CompositeIOP = FreeImage_GetOlePicture(hDIBResult, , True) + End If + + Call FreeImage_Unload(hDIB) + If (hDIBbg) Then + Call FreeImage_Unload(hDIBbg) + End If + End If + +End Function + + +'-------------------------------------------------------------------------------- +' VB-coded Toolkit functions +'-------------------------------------------------------------------------------- + +Public Function FreeImage_GetColorizedPalette(ByVal Color As OLE_COLOR, _ + Optional ByVal SplitValue As Variant = 0.5) As RGBQUAD() + +Dim atPalette(255) As RGBQUAD +Dim lSplitIndex As Long +Dim lSplitIndexInv As Long +Dim lRed As Long +Dim lGreen As Long +Dim lBlue As Long +Dim i As Long + + ' compute the split index + Select Case VarType(SplitValue) + + Case vbByte, vbInteger, vbLong + lSplitIndex = SplitValue + + Case vbDouble, vbSingle, vbDecimal + lSplitIndex = 256 * SplitValue + + Case Else + lSplitIndex = 128 + + End Select + + ' check ranges of split index + If (lSplitIndex < 0) Then + lSplitIndex = 0 + ElseIf (lSplitIndex > 255) Then + lSplitIndex = 255 + End If + lSplitIndexInv = 256 - lSplitIndex + + ' extract color components red, green and blue + lRed = (Color And &HFF) + lGreen = ((Color \ &H100&) And &HFF) + lBlue = ((Color \ &H10000) And &HFF) + + For i = 0 To lSplitIndex - 1 + With atPalette(i) + .rgbRed = (lRed / lSplitIndex) * i + .rgbGreen = (lGreen / lSplitIndex) * i + .rgbBlue = (lBlue / lSplitIndex) * i + End With + Next i + For i = lSplitIndex To 255 + With atPalette(i) + .rgbRed = lRed + ((255 - lRed) / lSplitIndexInv) * (i - lSplitIndex) + .rgbGreen = lGreen + ((255 - lGreen) / lSplitIndexInv) * (i - lSplitIndex) + .rgbBlue = lBlue + ((255 - lBlue) / lSplitIndexInv) * (i - lSplitIndex) + End With + Next i + + FreeImage_GetColorizedPalette = atPalette + +End Function + +Public Function FreeImage_Colorize(ByVal Bitmap As Long, _ + ByVal Color As OLE_COLOR, _ + Optional ByVal SplitValue As Variant = 0.5) As Long + + If (Bitmap) Then + If (Not FreeImage_HasPixels(Bitmap)) Then + Call Err.Raise(5, "MFreeImage", Error$(5) & vbCrLf & vbCrLf & _ + "Unable to colorize a 'header-only' bitmap.") + End If + FreeImage_Colorize = FreeImage_ConvertToGreyscale(Bitmap) + Call FreeImage_SetPalette(FreeImage_Colorize, _ + FreeImage_GetColorizedPalette(Color, SplitValue)) + End If + +End Function + +Public Function FreeImage_Sepia(ByVal Bitmap As Long, _ + Optional ByVal SplitValue As Variant = 0.5) As Long + + FreeImage_Sepia = FreeImage_Colorize(Bitmap, &H658AA2, SplitValue) ' RGB(162, 138, 101) + +End Function + + +'-------------------------------------------------------------------------------- +' Compression functions wrappers +'-------------------------------------------------------------------------------- + +Public Function FreeImage_ZLibCompressEx(ByRef Target As Variant, _ + Optional ByRef TargetSize As Long, _ + Optional ByRef Source As Variant, _ + Optional ByVal SourceSize As Long, _ + Optional ByVal Offset As Long) As Long + +Dim lSourceDataPtr As Long +Dim lTargetDataPtr As Long +Dim bTargetCreated As Boolean + + ' This function is a more VB friendly wrapper for compressing data with + ' the 'FreeImage_ZLibCompress' function. + + ' The parameter 'Target' may either be a VB style array of Byte, Integer + ' or Long or a pointer to a memory block. If 'Target' is a pointer to a + ' memory block (when it contains an address), 'TargetSize' must be + ' specified and greater than zero. If 'Target' is an initialized array, + ' the whole array will be used to store compressed data when 'TargetSize' + ' is missing or below or equal to zero. If 'TargetSize' is specified, only + ' the first TargetSize bytes of the array will be used. + ' In each case, all rules according to the FreeImage API documentation + ' apply, what means that the target buffer must be at least 0.1% greater + ' than the source buffer plus 12 bytes. + ' If 'Target' is an uninitialized array, the contents of 'TargetSize' + ' will be ignored and the size of the array 'Target' will be handled + ' internally. When the function returns, 'Target' will be initialized + ' as an array of Byte and sized correctly to hold all the compressed + ' data. + + ' Nearly all, that is true for the parameters 'Target' and 'TargetSize', + ' is also true for 'Source' and 'SourceSize', expect that 'Source' should + ' never be an uninitialized array. In that case, the function returns + ' immediately. + + ' The optional parameter 'Offset' may contain a number of bytes to remain + ' untouched at the beginning of 'Target', when an uninitialized array is + ' provided through 'Target'. When 'Target' is either a pointer or an + ' initialized array, 'Offset' will be ignored. This parameter is currently + ' used by 'FreeImage_ZLibCompressVB' to store the length of the uncompressed + ' data at the first four bytes of 'Target'. + + + ' get the pointer and the size in bytes of the source + ' memory block + lSourceDataPtr = pGetMemoryBlockPtrFromVariant(Source, SourceSize) + If (lSourceDataPtr) Then + ' when we got a valid pointer, get the pointer and the size in bytes + ' of the target memory block + lTargetDataPtr = pGetMemoryBlockPtrFromVariant(Target, TargetSize) + If (lTargetDataPtr = 0) Then + ' if 'Target' is a null pointer, we will initialized it as an array + ' of bytes; here we will take 'Offset' into account + ReDim Target(SourceSize + Int(SourceSize * 0.1) + _ + 12 + Offset) As Byte + ' get pointer and size in bytes (will never be a null pointer) + lTargetDataPtr = pGetMemoryBlockPtrFromVariant(Target, TargetSize) + ' adjust according to 'Offset' + lTargetDataPtr = lTargetDataPtr + Offset + TargetSize = TargetSize - Offset + bTargetCreated = True + End If + + ' compress source data + FreeImage_ZLibCompressEx = FreeImage_ZLibCompress(lTargetDataPtr, _ + TargetSize, _ + lSourceDataPtr, _ + SourceSize) + + ' the function returns the number of bytes needed to store the + ' compressed data or zero on failure + If (FreeImage_ZLibCompressEx) Then + If (bTargetCreated) Then + ' when we created the array, we need to adjust it's size + ' according to the length of the compressed data + ReDim Preserve Target(FreeImage_ZLibCompressEx - 1 + Offset) + End If + End If + End If + +End Function + +Public Function FreeImage_ZLibUncompressEx(ByRef Target As Variant, _ + Optional ByRef TargetSize As Long, _ + Optional ByRef Source As Variant, _ + Optional ByVal SourceSize As Long) As Long + +Dim lSourceDataPtr As Long +Dim lTargetDataPtr As Long + + ' This function is a more VB friendly wrapper for compressing data with + ' the 'FreeImage_ZLibUncompress' function. + + ' The parameter 'Target' may either be a VB style array of Byte, Integer + ' or Long or a pointer to a memory block. If 'Target' is a pointer to a + ' memory block (when it contains an address), 'TargetSize' must be + ' specified and greater than zero. If 'Target' is an initialized array, + ' the whole array will be used to store uncompressed data when 'TargetSize' + ' is missing or below or equal to zero. If 'TargetSize' is specified, only + ' the first TargetSize bytes of the array will be used. + ' In each case, all rules according to the FreeImage API documentation + ' apply, what means that the target buffer must be at least as large, to + ' hold all the uncompressed data. + ' Unlike the function 'FreeImage_ZLibCompressEx', 'Target' can not be + ' an uninitialized array, since the size of the uncompressed data can + ' not be determined by the ZLib functions, but must be specified by a + ' mechanism outside the FreeImage compression functions' scope. + + ' Nearly all, that is true for the parameters 'Target' and 'TargetSize', + ' is also true for 'Source' and 'SourceSize'. + + + ' get the pointer and the size in bytes of the source + ' memory block + lSourceDataPtr = pGetMemoryBlockPtrFromVariant(Source, SourceSize) + If (lSourceDataPtr) Then + ' when we got a valid pointer, get the pointer and the size in bytes + ' of the target memory block + lTargetDataPtr = pGetMemoryBlockPtrFromVariant(Target, TargetSize) + If (lTargetDataPtr) Then + ' if we do not have a null pointer, uncompress the data + FreeImage_ZLibUncompressEx = FreeImage_ZLibUncompress(lTargetDataPtr, _ + TargetSize, _ + lSourceDataPtr, _ + SourceSize) + End If + End If + +End Function + +Public Function FreeImage_ZLibGZipEx(ByRef Target As Variant, _ + Optional ByRef TargetSize As Long, _ + Optional ByRef Source As Variant, _ + Optional ByVal SourceSize As Long, _ + Optional ByVal Offset As Long) As Long + +Dim lSourceDataPtr As Long +Dim lTargetDataPtr As Long +Dim bTargetCreated As Boolean + + ' This function is a more VB friendly wrapper for compressing data with + ' the 'FreeImage_ZLibGZip' function. + + ' The parameter 'Target' may either be a VB style array of Byte, Integer + ' or Long or a pointer to a memory block. If 'Target' is a pointer to a + ' memory block (when it contains an address), 'TargetSize' must be + ' specified and greater than zero. If 'Target' is an initialized array, + ' the whole array will be used to store compressed data when 'TargetSize' + ' is missing or below or equal to zero. If 'TargetSize' is specified, only + ' the first TargetSize bytes of the array will be used. + ' In each case, all rules according to the FreeImage API documentation + ' apply, what means that the target buffer must be at least 0.1% greater + ' than the source buffer plus 24 bytes. + ' If 'Target' is an uninitialized array, the contents of 'TargetSize' + ' will be ignored and the size of the array 'Target' will be handled + ' internally. When the function returns, 'Target' will be initialized + ' as an array of Byte and sized correctly to hold all the compressed + ' data. + + ' Nearly all, that is true for the parameters 'Target' and 'TargetSize', + ' is also true for 'Source' and 'SourceSize', expect that 'Source' should + ' never be an uninitialized array. In that case, the function returns + ' immediately. + + ' The optional parameter 'Offset' may contain a number of bytes to remain + ' untouched at the beginning of 'Target', when an uninitialized array is + ' provided through 'Target'. When 'Target' is either a pointer or an + ' initialized array, 'Offset' will be ignored. This parameter is currently + ' used by 'FreeImage_ZLibGZipVB' to store the length of the uncompressed + ' data at the first four bytes of 'Target'. + + + ' get the pointer and the size in bytes of the source + ' memory block + lSourceDataPtr = pGetMemoryBlockPtrFromVariant(Source, SourceSize) + If (lSourceDataPtr) Then + ' when we got a valid pointer, get the pointer and the size in bytes + ' of the target memory block + lTargetDataPtr = pGetMemoryBlockPtrFromVariant(Target, TargetSize) + If (lTargetDataPtr = 0) Then + ' if 'Target' is a null pointer, we will initialized it as an array + ' of bytes; here we will take 'Offset' into account + ReDim Target(SourceSize + Int(SourceSize * 0.1) + _ + 24 + Offset) As Byte + ' get pointer and size in bytes (will never be a null pointer) + lTargetDataPtr = pGetMemoryBlockPtrFromVariant(Target, TargetSize) + ' adjust according to 'Offset' + lTargetDataPtr = lTargetDataPtr + Offset + TargetSize = TargetSize - Offset + bTargetCreated = True + End If + + ' compress source data + FreeImage_ZLibGZipEx = FreeImage_ZLibGZip(lTargetDataPtr, _ + TargetSize, _ + lSourceDataPtr, _ + SourceSize) + + ' the function returns the number of bytes needed to store the + ' compressed data or zero on failure + If (FreeImage_ZLibGZipEx) Then + If (bTargetCreated) Then + ' when we created the array, we need to adjust it's size + ' according to the length of the compressed data + ReDim Preserve Target(FreeImage_ZLibGZipEx - 1 + Offset) + End If + End If + End If + +End Function + +Public Function FreeImage_ZLibCRC32Ex(ByVal CRC As Long, _ + Optional ByRef Source As Variant, _ + Optional ByVal SourceSize As Long) As Long + +Dim lSourceDataPtr As Long + + ' This function is a more VB friendly wrapper for compressing data with + ' the 'FreeImage_ZLibCRC32' function. + + ' The parameter 'Source' may either be a VB style array of Byte, Integer + ' or Long or a pointer to a memory block. If 'Source' is a pointer to a + ' memory block (when it contains an address), 'SourceSize' must be + ' specified and greater than zero. If 'Source' is an initialized array, + ' the whole array will be used to calculate the new CRC when 'SourceSize' + ' is missing or below or equal to zero. If 'SourceSize' is specified, only + ' the first SourceSize bytes of the array will be used. + + + ' get the pointer and the size in bytes of the source + ' memory block + lSourceDataPtr = pGetMemoryBlockPtrFromVariant(Source, SourceSize) + If (lSourceDataPtr) Then + ' if we do not have a null pointer, calculate the CRC including 'crc' + FreeImage_ZLibCRC32Ex = FreeImage_ZLibCRC32(CRC, _ + lSourceDataPtr, _ + SourceSize) + End If + +End Function + +Public Function FreeImage_ZLibGUnzipEx(ByRef Target As Variant, _ + Optional ByRef TargetSize As Long, _ + Optional ByRef Source As Variant, _ + Optional ByVal SourceSize As Long) As Long + +Dim lSourceDataPtr As Long +Dim lTargetDataPtr As Long + + ' This function is a more VB friendly wrapper for compressing data with + ' the 'FreeImage_ZLibGUnzip' function. + + ' The parameter 'Target' may either be a VB style array of Byte, Integer + ' or Long or a pointer to a memory block. If 'Target' is a pointer to a + ' memory block (when it contains an address), 'TargetSize' must be + ' specified and greater than zero. If 'Target' is an initialized array, + ' the whole array will be used to store uncompressed data when 'TargetSize' + ' is missing or below or equal to zero. If 'TargetSize' is specified, only + ' the first TargetSize bytes of the array will be used. + ' In each case, all rules according to the FreeImage API documentation + ' apply, what means that the target buffer must be at least as large, to + ' hold all the uncompressed data. + ' Unlike the function 'FreeImage_ZLibGZipEx', 'Target' can not be + ' an uninitialized array, since the size of the uncompressed data can + ' not be determined by the ZLib functions, but must be specified by a + ' mechanism outside the FreeImage compression functions' scope. + + ' Nearly all, that is true for the parameters 'Target' and 'TargetSize', + ' is also true for 'Source' and 'SourceSize'. + + + ' get the pointer and the size in bytes of the source + ' memory block + lSourceDataPtr = pGetMemoryBlockPtrFromVariant(Source, SourceSize) + If (lSourceDataPtr) Then + ' when we got a valid pointer, get the pointer and the size in bytes + ' of the target memory block + lTargetDataPtr = pGetMemoryBlockPtrFromVariant(Target, TargetSize) + If (lTargetDataPtr) Then + ' if we do not have a null pointer, uncompress the data + FreeImage_ZLibGUnzipEx = FreeImage_ZLibGUnzip(lTargetDataPtr, _ + TargetSize, _ + lSourceDataPtr, _ + SourceSize) + End If + End If + +End Function + +Public Function FreeImage_ZLibCompressVB(ByRef Data() As Byte, _ + Optional ByVal IncludeSize As Boolean = True) As Byte() + +Dim lOffset As Long +Dim lArrayDataPtr As Long + + ' This function is another, even more VB friendly wrapper for the FreeImage + ' 'FreeImage_ZLibCompress' function, that uses the 'FreeImage_ZLibCompressEx' + ' function. This function is very easy to use, since it deals only with VB + ' style Byte arrays. + + ' The parameter 'Data()' is a Byte array, providing the uncompressed source + ' data, that will be compressed. + + ' The optional parameter 'IncludeSize' determines whether the size of the + ' uncompressed data should be stored in the first four bytes of the returned + ' byte buffer containing the compressed data or not. When 'IncludeSize' is + ' True, the size of the uncompressed source data will be stored. This works + ' in conjunction with the corresponding 'FreeImage_ZLibUncompressVB' function. + + ' The function returns a VB style Byte array containing the compressed data. + + + ' start population the memory block with compressed data + ' at offset 4 bytes, when the unclompressed size should + ' be included + If (IncludeSize) Then + lOffset = 4 + End If + + Call FreeImage_ZLibCompressEx(FreeImage_ZLibCompressVB, , Data, , lOffset) + + If (IncludeSize) Then + ' get the pointer actual pointing to the array data of + ' the Byte array 'FreeImage_ZLibCompressVB' + lArrayDataPtr = pDeref(pDeref(VarPtrArray(FreeImage_ZLibCompressVB)) + 12) + + ' copy uncompressed size into the first 4 bytes + Call CopyMemory(ByVal lArrayDataPtr, UBound(Data) + 1, 4) + End If + +End Function + +Public Function FreeImage_ZLibUncompressVB(ByRef Data() As Byte, _ + Optional ByVal SizeIncluded As Boolean = True, _ + Optional ByVal SizeNeeded As Long) As Byte() + +Dim abBuffer() As Byte + + ' This function is another, even more VB friendly wrapper for the FreeImage + ' 'FreeImage_ZLibUncompress' function, that uses the 'FreeImage_ZLibUncompressEx' + ' function. This function is very easy to use, since it deals only with VB + ' style Byte arrays. + + ' The parameter 'Data()' is a Byte array, providing the compressed source + ' data that will be uncompressed either withthe size of the uncompressed + ' data included or not. + + ' When the optional parameter 'SizeIncluded' is True, the function assumes, + ' that the first four bytes contain the size of the uncompressed data as a + ' Long value. In that case, 'SizeNeeded' will be ignored. + + ' When the size of the uncompressed data is not included in the buffer 'Data()' + ' containing the compressed data, the optional parameter 'SizeNeeded' must + ' specify the size in bytes needed to hold all the uncompressed data. + + ' The function returns a VB style Byte array containing the uncompressed data. + + + If (SizeIncluded) Then + ' get uncompressed size from the first 4 bytes and allocate + ' buffer accordingly + Call CopyMemory(SizeNeeded, Data(0), 4) + ReDim abBuffer(SizeNeeded - 1) + Call FreeImage_ZLibUncompressEx(abBuffer, , VarPtr(Data(4)), UBound(Data) - 3) + Call pSwap(VarPtrArray(FreeImage_ZLibUncompressVB), VarPtrArray(abBuffer)) + + ElseIf (SizeNeeded) Then + ' no size included in compressed data, so just forward the + ' call to 'FreeImage_ZLibUncompressEx' and trust on SizeNeeded + ReDim abBuffer(SizeNeeded - 1) + Call FreeImage_ZLibUncompressEx(abBuffer, , Data) + Call pSwap(VarPtrArray(FreeImage_ZLibUncompressVB), VarPtrArray(abBuffer)) + + End If + +End Function + +Public Function FreeImage_ZLibGZipVB(ByRef Data() As Byte, _ + Optional ByVal IncludeSize As Boolean = True) As Byte() + +Dim lOffset As Long +Dim lArrayDataPtr As Long + + ' This function is another, even more VB friendly wrapper for the FreeImage + ' 'FreeImage_ZLibGZip' function, that uses the 'FreeImage_ZLibGZipEx' + ' function. This function is very easy to use, since it deals only with VB + ' style Byte arrays. + + ' The parameter 'Data()' is a Byte array, providing the uncompressed source + ' data that will be compressed. + + ' The optional parameter 'IncludeSize' determines whether the size of the + ' uncompressed data should be stored in the first four bytes of the returned + ' byte buffer containing the compressed data or not. When 'IncludeSize' is + ' True, the size of the uncompressed source data will be stored. This works + ' in conjunction with the corresponding 'FreeImage_ZLibGUnzipVB' function. + + ' The function returns a VB style Byte array containing the compressed data. + + + ' start population the memory block with compressed data + ' at offset 4 bytes, when the unclompressed size should + ' be included + If (IncludeSize) Then + lOffset = 4 + End If + + Call FreeImage_ZLibGZipEx(FreeImage_ZLibGZipVB, , Data, , lOffset) + + If (IncludeSize) Then + ' get the pointer actual pointing to the array data of + ' the Byte array 'FreeImage_ZLibCompressVB' + lArrayDataPtr = pDeref(pDeref(VarPtrArray(FreeImage_ZLibGZipVB)) + 12) + + ' copy uncompressed size into the first 4 bytes + Call CopyMemory(ByVal lArrayDataPtr, UBound(Data) + 1, 4) + End If + +End Function + +Public Function FreeImage_ZLibGUnzipVB(ByRef Data() As Byte, _ + Optional ByVal SizeIncluded As Boolean = True, _ + Optional ByVal SizeNeeded As Long) As Byte() + +Dim abBuffer() As Byte + + ' This function is another, even more VB friendly wrapper for the FreeImage + ' 'FreeImage_ZLibGUnzip' function, that uses the 'FreeImage_ZLibGUnzipEx' + ' function. This function is very easy to use, since it deals only with VB + ' style Byte arrays. + + ' The parameter 'Data()' is a Byte array, providing the compressed source + ' data that will be uncompressed either withthe size of the uncompressed + ' data included or not. + + ' When the optional parameter 'SizeIncluded' is True, the function assumes, + ' that the first four bytes contain the size of the uncompressed data as a + ' Long value. In that case, 'SizeNeeded' will be ignored. + + ' When the size of the uncompressed data is not included in the buffer 'Data()' + ' containing the compressed data, the optional parameter 'SizeNeeded' must + ' specify the size in bytes needed to hold all the uncompressed data. + + ' The function returns a VB style Byte array containing the uncompressed data. + + + If (SizeIncluded) Then + ' get uncompressed size from the first 4 bytes and allocate + ' buffer accordingly + Call CopyMemory(SizeNeeded, Data(0), 4) + ReDim abBuffer(SizeNeeded - 1) + Call FreeImage_ZLibGUnzipEx(abBuffer, , VarPtr(Data(4)), UBound(Data) - 3) + Call pSwap(VarPtrArray(FreeImage_ZLibGUnzipVB), VarPtrArray(abBuffer)) + + ElseIf (SizeNeeded) Then + ' no size included in compressed data, so just forward the + ' call to 'FreeImage_ZLibUncompressEx' and trust on SizeNeeded + ReDim abBuffer(SizeNeeded - 1) + Call FreeImage_ZLibGUnzipEx(abBuffer, , Data) + Call pSwap(VarPtrArray(FreeImage_ZLibGUnzipVB), VarPtrArray(abBuffer)) + + End If + +End Function + + +'-------------------------------------------------------------------------------- +' Public functions to destroy custom safearrays +'-------------------------------------------------------------------------------- + +Public Function FreeImage_DestroyLockedArray(ByRef Data As Variant) As Long + +Dim lpArrayPtr As Long + + ' This function destroys an array, that was self created with a custom + ' array descriptor of type ('fFeatures' member) 'FADF_AUTO Or FADF_FIXEDSIZE'. + ' Such arrays are returned by mostly all of the array-dealing wrapper + ' functions. Since these should not destroy the actual array data, when + ' going out of scope, they are craeted as 'FADF_FIXEDSIZE'.' + + ' So, VB sees them as fixed or temporarily locked, when you try to manipulate + ' the array's dimensions. There will occur some strange effects, you should + ' know about: + + ' 1. When trying to 'ReDim' the array, this run-time error will occur: + ' Error #10, 'This array is fixed or temporarily locked' + + ' 2. When trying to assign another array to the array variable, this + ' run-time error will occur: + ' Error #13, 'Type mismatch' + + ' 3. The 'Erase' statement has no effect on the array + + ' Although VB clears up these arrays correctly, when the array variable + ' goes out of scope, you have to destroy the array manually, when you want + ' to reuse the array variable in current scope. + + ' For an example assume, that you want do walk all scanlines in an image: + + ' For i = 0 To FreeImage_GetHeight(Bitmap) + ' + ' ' assign scanline-array to array variable + ' abByte = FreeImage_GetScanLineEx(Bitmap, i) + ' + ' ' do some work on it... + ' + ' ' destroy the array (only the array, not the actual data) + ' Call FreeImage_DestroyLockedArray(dbByte) + ' Next i + + ' The function returns zero on success and any other value on failure + + ' !! Attention !! + ' This function uses a Variant parameter for passing the array to be + ' destroyed. Since VB does not allow to pass an array of non public + ' structures through a Variant parameter, this function can not be used + ' with arrays of cutom type. + + ' You will get this compiler error: "Only public user defined types defined + ' in public object modules can be used as parameters or return types for + ' public procedures of class modules or as fields of public user defined types" + + ' So, there is a function in the wrapper called 'FreeImage_DestroyLockedArrayByPtr' + ' that takes a pointer to the array variable which can be used to work around + ' that VB limitation and furthermore can be used for any of these self-created + ' arrays. To get the array variable's pointer, a declared version of the + ' VB 'VarPtr' function can be used which works for all types of arrays expect + ' String arrays. Declare this function like this in your code: + + ' Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" ( _ + ByRef Ptr() As Any) As Long + + ' Then an array could be destroyed by calling the 'FreeImage_DestroyLockedArrayByPtr' + ' function like this: + + ' lResult = FreeImage_DestroyLockedArrayByPtr(VarPtrArray(MyLockedArray)) + + ' Additionally there are some handy wrapper functions available, one for each + ' commonly used structure in FreeImage like RGBTRIPLE, RGBQUAD, FICOMPLEX etc. + + + ' Currently, these functions do return 'FADF_AUTO Or FADF_FIXEDSIZE' arrays + ' that must be destroyed using this or any of it's derived functions: + + ' FreeImage_GetPaletteEx() with FreeImage_DestroyLockedArrayRGBQUAD() + ' FreeImage_GetPaletteLong() with FreeImage_DestroyLockedArray() + ' FreeImage_SaveToMemoryEx2() with FreeImage_DestroyLockedArray() + ' FreeImage_AcquireMemoryEx() with FreeImage_DestroyLockedArray() + ' FreeImage_GetScanLineEx() with FreeImage_DestroyLockedArray() + ' FreeImage_GetScanLineBITMAP8() with FreeImage_DestroyLockedArray() + ' FreeImage_GetScanLineBITMAP16() with FreeImage_DestroyLockedArray() + ' FreeImage_GetScanLineBITMAP24() with FreeImage_DestroyLockedArrayRGBTRIPLE() + ' FreeImage_GetScanLineBITMAP32() with FreeImage_DestroyLockedArrayRGBQUAD() + ' FreeImage_GetScanLineINT16() with FreeImage_DestroyLockedArray() + ' FreeImage_GetScanLineINT32() with FreeImage_DestroyLockedArray() + ' FreeImage_GetScanLineFLOAT() with FreeImage_DestroyLockedArray() + ' FreeImage_GetScanLineDOUBLE() with FreeImage_DestroyLockedArray() + ' FreeImage_GetScanLineCOMPLEX() with FreeImage_DestroyLockedArrayFICOMPLEX() + ' FreeImage_GetScanLineRGB16() with FreeImage_DestroyLockedArrayFIRGB16() + ' FreeImage_GetScanLineRGBA16() with FreeImage_DestroyLockedArrayFIRGBA16() + ' FreeImage_GetScanLineRGBF() with FreeImage_DestroyLockedArrayFIRGBF() + ' FreeImage_GetScanLineRGBAF() with FreeImage_DestroyLockedArrayFIRGBAF() + + + ' ensure, this is an array + If (VarType(Data) And vbArray) Then + + ' data is a VB array, what means a SAFEARRAY in C/C++, that is + ' passed through a ByRef Variant variable, that is a pointer to + ' a VARIANTARG structure + + ' the VARIANTARG structure looks like this: + + ' typedef struct tagVARIANT VARIANTARG; + ' struct tagVARIANT + ' { + ' Union + ' { + ' struct __tagVARIANT + ' { + ' VARTYPE vt; + ' WORD wReserved1; + ' WORD wReserved2; + ' WORD wReserved3; + ' Union + ' { + ' [...] + ' SAFEARRAY *parray; // used when not VT_BYREF + ' [...] + ' SAFEARRAY **pparray; // used when VT_BYREF + ' [...] + + ' the data element (SAFEARRAY) has an offset of 8, since VARTYPE + ' and WORD both have a length of 2 bytes; the pointer to the + ' VARIANTARG structure is the VarPtr of the Variant variable in VB + + ' getting the contents of the data element (in C/C++: *(data + 8)) + lpArrayPtr = pDeref(VarPtr(Data) + 8) + + ' call the 'FreeImage_DestroyLockedArrayByPtr' function to destroy + ' the array properly + Call FreeImage_DestroyLockedArrayByPtr(lpArrayPtr) + Else + + FreeImage_DestroyLockedArray = -1 + End If + +End Function + +Public Function FreeImage_DestroyLockedArrayByPtr(ByVal ArrayPtr As Long) As Long + +Dim lpSA As Long + + ' This function destroys a self-created array with a custom array + ' descriptor by a pointer to the array variable. + + ' dereference the pointer once (in C/C++: *ArrayPtr) + lpSA = pDeref(ArrayPtr) + ' now 'lpSA' is a pointer to the actual SAFEARRAY structure + ' and could be a null pointer when the array is not initialized + ' then, we have nothing to do here but return (-1) to indicate + ' an "error" + If (lpSA) Then + + ' destroy the array descriptor + Call SafeArrayDestroyDescriptor(lpSA) + + ' make 'lpSA' a null pointer, that is an uninitialized array; + ' keep in mind, that we here use 'ArrayPtr' as a ByVal argument, + ' since 'ArrayPtr' is a pointer to lpSA (the address of lpSA); + ' we need to zero these four bytes, 'ArrayPtr' points to + Call CopyMemory(ByVal ArrayPtr, 0&, 4) + Else + + ' the array is already uninitialized, so return an "error" value + FreeImage_DestroyLockedArrayByPtr = -1 + End If + +End Function + +Public Function FreeImage_DestroyLockedArrayRGBTRIPLE(ByRef Data() As RGBTRIPLE) As Long + + ' This function is a thin wrapper for 'FreeImage_DestroyLockedArrayByPtr' + ' for destroying arrays of type 'RGBTRIPLE'. + + FreeImage_DestroyLockedArrayRGBTRIPLE = FreeImage_DestroyLockedArrayByPtr(VarPtrArray(Data)) + +End Function + +Public Function FreeImage_DestroyLockedArrayRGBQUAD(ByRef Data() As RGBQUAD) As Long + + ' This function is a thin wrapper for 'FreeImage_DestroyLockedArrayByPtr' + ' for destroying arrays of type 'RGBQUAD'. + + FreeImage_DestroyLockedArrayRGBQUAD = FreeImage_DestroyLockedArrayByPtr(VarPtrArray(Data)) + +End Function + +Public Function FreeImage_DestroyLockedArrayFICOMPLEX(ByRef Data() As FICOMPLEX) As Long + + ' This function is a thin wrapper for 'FreeImage_DestroyLockedArrayByPtr' + ' for destroying arrays of type 'FICOMPLEX'. + + FreeImage_DestroyLockedArrayFICOMPLEX = FreeImage_DestroyLockedArrayByPtr(VarPtrArray(Data)) + +End Function + +Public Function FreeImage_DestroyLockedArrayFIRGB16(ByRef Data() As FIRGB16) As Long + + ' This function is a thin wrapper for 'FreeImage_DestroyLockedArrayByPtr' + ' for destroying arrays of type 'FIRGB16'. + + FreeImage_DestroyLockedArrayFIRGB16 = FreeImage_DestroyLockedArrayByPtr(VarPtrArray(Data)) + +End Function + +Public Function FreeImage_DestroyLockedArrayFIRGBA16(ByRef Data() As FIRGBA16) As Long + + ' This function is a thin wrapper for 'FreeImage_DestroyLockedArrayByPtr' + ' for destroying arrays of type 'FIRGBA16'. + + FreeImage_DestroyLockedArrayFIRGBA16 = FreeImage_DestroyLockedArrayByPtr(VarPtrArray(Data)) + +End Function + +Public Function FreeImage_DestroyLockedArrayFIRGBF(ByRef Data() As FIRGBF) As Long + + ' This function is a thin wrapper for 'FreeImage_DestroyLockedArrayByPtr' + ' for destroying arrays of type 'FIRGBF'. + + FreeImage_DestroyLockedArrayFIRGBF = FreeImage_DestroyLockedArrayByPtr(VarPtrArray(Data)) + +End Function + +Public Function FreeImage_DestroyLockedArrayFIRGBAF(ByRef Data() As FIRGBAF) As Long + + ' This function is a thin wrapper for 'FreeImage_DestroyLockedArrayByPtr' + ' for destroying arrays of type 'FIRGBAF'. + + FreeImage_DestroyLockedArrayFIRGBAF = FreeImage_DestroyLockedArrayByPtr(VarPtrArray(Data)) + +End Function + + + +'-------------------------------------------------------------------------------- +' Private IOlePicture related helper functions +'-------------------------------------------------------------------------------- + +Private Function pGetIOlePictureFromContainer(ByRef Container As Object, _ + Optional ByVal IncludeDrawings As Boolean) As IPicture + + ' Returns a VB IOlePicture object (IPicture) from a VB image hosting control. + ' See the inline documentation of function 'FreeImage_CreateFromImageContainer' + ' for a detailed description of this helper function. + + If (Not Container Is Nothing) Then + + Select Case TypeName(Container) + + Case "PictureBox", "Form" + If (IncludeDrawings) Then + If (Not Container.AutoRedraw) Then + Call Err.Raise(5, _ + "MFreeImage", _ + Error$(5) & vbCrLf & vbCrLf & _ + "Custom drawings can only be included into the DIB when " & _ + "the container's 'AutoRedraw' property is set to True.") + Exit Function + End If + Set pGetIOlePictureFromContainer = Container.Image + Else + Set pGetIOlePictureFromContainer = Container.Picture + End If + + Case Else + + Dim bHasPicture As Boolean + Dim bHasImage As Boolean + Dim bIsAutoRedraw As Boolean + + On Error Resume Next + bHasPicture = (Container.Picture <> 0) + bHasImage = (Container.Image <> 0) + bIsAutoRedraw = Container.AutoRedraw + On Error GoTo 0 + + If ((IncludeDrawings) And _ + (bHasImage) And _ + (bIsAutoRedraw)) Then + Set pGetIOlePictureFromContainer = Container.Image + + ElseIf (bHasPicture) Then + Set pGetIOlePictureFromContainer = Container.Picture + + Else + Call Err.Raise(5, _ + "MFreeImage", _ + Error$(5) & vbCrLf & vbCrLf & _ + "Cannot create DIB from container control. Container " & _ + "control has no 'Picture' property.") + + End If + + End Select + + End If + +End Function + + + +'-------------------------------------------------------------------------------- +' Private image and color helper functions +'-------------------------------------------------------------------------------- + +Private Function pGetPreviousColorDepth(ByVal bpp As Long) As Long + + ' This function returns the 'previous' color depth of a given + ' color depth. Here, 'previous' means the next smaller color + ' depth. + + Select Case bpp + + Case 32 + pGetPreviousColorDepth = 24 + + Case 24 + pGetPreviousColorDepth = 16 + + Case 16 + pGetPreviousColorDepth = 15 + + Case 15 + pGetPreviousColorDepth = 8 + + Case 8 + pGetPreviousColorDepth = 4 + + Case 4 + pGetPreviousColorDepth = 1 + + End Select + +End Function + +Private Function pGetNextColorDepth(ByVal bpp As Long) As Long + + ' This function returns the 'next' color depth of a given + ' color depth. Here, 'next' means the next greater color + ' depth. + + Select Case bpp + + Case 1 + pGetNextColorDepth = 4 + + Case 4 + pGetNextColorDepth = 8 + + Case 8 + pGetNextColorDepth = 15 + + Case 15 + pGetNextColorDepth = 16 + + Case 16 + pGetNextColorDepth = 24 + + Case 24 + pGetNextColorDepth = 32 + + End Select + +End Function + + + +'-------------------------------------------------------------------------------- +' Private metadata helper functions +'-------------------------------------------------------------------------------- + +Private Function pGetTagFromTagPtr(ByVal Model As FREE_IMAGE_MDMODEL, _ + ByVal TagPtr As Long) As FREE_IMAGE_TAG + +Dim tTag As FITAG +Dim lTemp As Long +Dim i As Long + + ' This function converts data stored in a real FreeImage tag + ' pointer (FITAG **tag) into a VB friendly structure FREE_IMAGE_TAG. + + If (TagPtr <> 0) Then + + ' this is like (only like!) tTag tag = (FITAG) TagPtr; in C/C++ + ' we copy Len(tTag) bytes from the address in TagPtr in to a + ' private FITAG structure tTag so we have easy access to all + ' FITAG members + Call CopyMemory(tTag, ByVal pDeref(TagPtr), Len(tTag)) + + With pGetTagFromTagPtr + + ' first fill all members expect 'Value' in our + ' VB friendly FREE_IMAGE_TAG structure + + ' since we use this VB friendly FREE_IMAGE_TAG structure + ' for later tag modification too, we also need to store the + ' tag model and the pointer to the actual FreeImage FITAG + ' structure + .Model = Model + .TagPtr = TagPtr + + ' although FITAG's 'count' and 'length' members are + ' unsigned longs, we do not expect values greater + ' than 2,147,483,647, so we store them in normal VB + ' signed longs + .Count = tTag.Count + .Length = tTag.Length + + ' strings are stored as pointers to the actual string + ' data in FITAG + .Description = pGetStringFromPointerA(tTag.Description) + .Key = pGetStringFromPointerA(tTag.Key) + + ' FITAG's 'id' and 'type' members are unsigned shorts; + ' first of all 'id' may exceed the range of a signed + ' short (Integer data type in VB), so we store them in + ' signed longs and use CopyMemory for to keep the + ' unsigned bit layout + Call CopyMemory(.Id, tTag.Id, 2) + Call CopyMemory(.Type, tTag.Type, 2) + + ' StringValue is the result of FreeImage_TagToString(); we + ' also store this tag representation in our structure + .StringValue = FreeImage_TagToString(Model, TagPtr) + + ' now comes the hard part, getting the tag's value + + Select Case .Type + + Case FIDT_BYTE, _ + FIDT_UNDEFINED + If (.Count > 1) Then + Dim abBytes() As Byte + ' for a byte array, just redim a VB Byte array and + ' copy Count bytes from the pointer + ReDim abBytes(.Count - 1) + Call CopyMemory(abBytes(0), ByVal tTag.Value, .Count) + .Value = abBytes + Else + ' copy a single byte into a Long and assign + ' with CByte() + Call CopyMemory(lTemp, ByVal tTag.Value, 1) + .Value = CByte(lTemp) + End If + + Case FIDT_ASCII + ' for an ASCII string, 'value' is just a pointer to the + ' string's actual data + .Value = pGetStringFromPointerA(tTag.Value) + + Case FIDT_SHORT + Dim iTemp As Integer + If (.Count > 1) Then + ' for a unsigned long array, first redim Value to + ' proper size + ReDim .Value(.Count - 1) + ' iterate over all items + For i = 0 To .Count - 1 + ' copy each value into a Long and + ' assign with FreeImage_UnsignedShort() to the + ' corresponding item in the (Variant) Value array + Call CopyMemory(iTemp, ByVal tTag.Value + i * 2, 2) + .Value(i) = FreeImage_UnsignedShort(iTemp) + Next i + Else + ' copy a single byte into a Long and assign + ' with FreeImgage_UnsignedShort() + Call CopyMemory(iTemp, ByVal tTag.Value, 2) + ' this works although FreeImage_UnsignedShort() takes + ' an Integer parameter since lTemp was 0 before and + ' we copied only 2 bytes so, VB's implicit conversion + ' to Integer will never produce an overflow + .Value = FreeImage_UnsignedShort(iTemp) + End If + + Case FIDT_LONG, _ + FIDT_IFD + If (.Count > 1) Then + ' for a unsigned long array, first redim Value to + ' proper size + ReDim .Value(.Count - 1) + ' iterate over all items + For i = 0 To .Count - 1 + ' copy each value into a (signed) Long and + ' assign with FreeImage_UnsignedLong() to the + ' corresponding item in the (Variant) Value array + Call CopyMemory(lTemp, ByVal tTag.Value + i * 4, 4) + .Value(i) = FreeImage_UnsignedLong(lTemp) + Next i + Else + ' copy a single unsigned long into a (signed) Long and + ' assign with FreeImage_UnsignedLong() + Call CopyMemory(lTemp, ByVal tTag.Value, 2) + .Value = FreeImage_UnsignedLong(lTemp) + End If + + Case FIDT_RATIONAL, _ + FIDT_SRATIONAL + ' rational values are always stored in the FREE_IMAGE_TAG + ' structure's FIRATIONAL array 'RationalValue' so, allocate + ' enough space in both the 'Value' and 'RationalValue' + ' members to hold 'Count' items + ReDim .Value(.Count - 1) + ReDim .RationalValue(.Count - 1) + For i = 0 To .Count - 1 + ' iterate over all items + With .RationalValue(i) + ' for each item, copy both numerator and denominator + ' into a (signed) Long and assign it to the corresponding + ' member of the FIRATIONAL structure so, we first assume + ' havinge a signed rational (FIDT_SRATIONAL) here + Call CopyMemory(lTemp, ByVal tTag.Value + i * 8, 4) + .Numerator = lTemp + Call CopyMemory(lTemp, ByVal tTag.Value + i * 8 + 4, 4) + .Denominator = lTemp + End With + ' if we have an unsigned rational (FIDT_RATIONAL), convert + ' numerator and denominator + If (.Type = FIDT_RATIONAL) Then + ' convert with FreeImage_UnsignedLong() + With .RationalValue(i) + .Numerator = FreeImage_UnsignedLong(.Numerator) + .Denominator = FreeImage_UnsignedLong(.Denominator) + End With + ' normalze the unsigned rational value + Call pNormalizeRational(.RationalValue(i)) + Else + ' normalze the signed rational value + Call pNormalizeSRational(.RationalValue(i)) + End If + ' store the current fraction's value (maybe only approximated) in + ' the 'Value' member of the FREE_IMAGE_TAG structure, if the + ' denominator is not zero + If (.RationalValue(i).Denominator <> 0) Then + .Value(i) = .RationalValue(i).Numerator / .RationalValue(i).Denominator + End If + Next i + + Case FIDT_SBYTE + If (.Count > 1) Then + ' for a signed byte array, first redim Value to + ' proper size + ReDim .Value(.Count - 1) + ' iterate over all items + For i = 0 To .Count - 1 + ' copy each signed byte value into a Long and + ' check, whether it is negative (bit 7 set) + Call CopyMemory(lTemp, ByVal tTag.Value, 1) + If (lTemp And 128) Then + ' if negative, calculate the negative value + ' and store it in an Integer + .Value(i) = CInt(-256 - (Not (lTemp - 1))) + Else + ' if positive, assign to Value as byte + .Value(i) = CByte(lTemp) + End If + Next i + Else + ' copy a single signed byte into a Long and + ' check, whether it is negative (bit 7 set) + Call CopyMemory(lTemp, ByVal tTag.Value, 1) + If (lTemp And 128) Then + ' if negative, calculate the negative value + ' and store it in an Integer + .Value = CInt(-256 - (Not (lTemp - 1))) + Else + ' if positive, assign to Value as byte + .Value = CByte(lTemp) + End If + End If + + Case FIDT_SSHORT + If (.Count > 1) Then + Dim aiSShorts() As Integer + ' for a signed short array, just redim a VB Integer array and + ' copy Count bytes from the pointer + ReDim aiSShorts(.Count - 1) + Call CopyMemory(aiSShorts(0), ByVal tTag.Value, .Count * 2) + .Value = aiSShorts + Else + ' copy a single signed short into a Long and assign + ' with CInt() + Call CopyMemory(lTemp, ByVal tTag.Value, 2) + .Value = CInt(lTemp) + End If + + Case FIDT_SLONG + If (.Count > 1) Then + Dim alSLongs() As Long + ' for a signed long array, just redim a VB Long array and + ' copy Count bytes from the pointer + ReDim alSLongs(.Count - 1) + Call CopyMemory(alSLongs(0), ByVal tTag.Value, .Count * 4) + .Value = alSLongs + Else + ' copy a single signed long into a Long and assign + ' directly + Call CopyMemory(lTemp, ByVal tTag.Value, 4) + .Value = lTemp + End If + + Case FIDT_FLOAT + If (.Count > 1) Then + Dim asngFloats() As Single + ' for a float array, just redim a VB Single array and + ' copy Count bytes from the pointer + ReDim asngFloats(.Count - 1) + Call CopyMemory(asngFloats(0), ByVal tTag.Value, .Count * 4) + .Value = asngFloats + Else + Dim sngFloat As Single + ' copy a single float into a Single and assign + ' directly + Call CopyMemory(sngFloat, ByVal tTag.Value, 4) + .Value = sngFloat + End If + + Case FIDT_DOUBLE + If (.Count > 1) Then + Dim adblDoubles() As Double + ' for a double array, just redim a VB Double array and + ' copy Count bytes from the pointer + ReDim adblDoubles(.Count - 1) + Call CopyMemory(adblDoubles(0), ByVal tTag.Value, .Count * 8) + .Value = adblDoubles + Else + Dim dblDouble As Double + ' copy a single double into a Double and assign + ' directly + Call CopyMemory(dblDouble, ByVal tTag.Value, 8) + .Value = dblDouble + End If + + Case FIDT_PALETTE + ' copy 'Count' palette entries (RGBQUAD) form the value + ' pointer into the proper dimensioned array of RGBQUAD + ReDim .Palette(.Count - 1) + For i = 0 To .Count - 1 + Call CopyMemory(.Palette(i), ByVal tTag.Value + i * 4, 4) + Next i + + End Select + + End With + End If + +End Function + +Private Sub pNormalizeRational(ByRef Value As FIRATIONAL) + +Dim vntCommon As Long + + ' This function normalizes an unsigned fraction stored in a FIRATIONAL + ' structure by cancelling down the fraction. This is commonly done + ' by dividing both numerator and denominator by their greates + ' common divisor (gcd). + ' Does nothing if any of numerator and denominator is 1 or 0. + + With Value + If ((.Numerator <> 1) And (.Denominator <> 1) And _ + (.Numerator <> 0) And (.Denominator <> 0)) Then + vntCommon = gcd(.Numerator, .Denominator) + If (vntCommon <> 1) Then + ' convert values back to an unsigned long (may + ' result in a subtype Currency if the range of the + ' VB Long is insufficient for storing the value!) + .Numerator = FreeImage_UnsignedLong(.Numerator / vntCommon) + .Denominator = FreeImage_UnsignedLong(.Denominator / vntCommon) + End If + End If + End With + +End Sub + +Private Sub pNormalizeSRational(ByRef Value As FIRATIONAL) + +Dim lCommon As Long + + ' This function normalizes a signed fraction stored in a FIRATIONAL + ' structure by cancelling down the fraction. This is commonly done + ' by dividing both numerator and denominator by their greates + ' common divisor (gcd). + ' Does nothing if any of numerator and denominator is 1 or 0. + + With Value + If ((.Numerator <> 1) And (.Denominator <> 1) And _ + (.Numerator <> 0) And (.Denominator <> 0)) Then + lCommon = gcd(.Numerator, .Denominator) + If (lCommon <> 1) Then + ' using the CLng() function for not to get + ' a subtype Double here + .Numerator = CLng(.Numerator / lCommon) + .Denominator = CLng(.Denominator / lCommon) + End If + End If + + ' adjust the position of the negative sign if one is present: + ' it should preceed the numerator, not the denominator + If (.Denominator < 0) Then + .Denominator = -.Denominator + .Numerator = -.Numerator + End If + End With + +End Sub + +Private Function gcd(ByVal a As Variant, ByVal b As Variant) As Variant + +Dim vntTemp As Variant + + ' calculate greatest common divisor + + Do While (b) + vntTemp = b + ' calculate b = a % b (modulo) + ' this could be just: + ' b = a Mod b + ' but VB's Mod operator fails for unsigned + ' long values stored in currency variables + ' so, we use the mathematical definition of + ' the modulo operator taken from Wikipedia. + b = a - floor(a / b) * b + a = vntTemp + Loop + gcd = a + +End Function + +Private Function floor(ByRef a As Variant) As Variant + + ' This is a VB version of the floor() function. + If (a < 0) Then + floor = VBA.Int(a) + Else + floor = -VBA.Fix(-a) + End If + +End Function + +Private Function pTagToTagPtr(ByRef Tag As FREE_IMAGE_TAG) As Boolean + +Dim tTagSave As FITAG +Dim lpTag As Long +Dim abValueBuffer() As Byte +Dim lLength As Long +Dim lCount As Long + + ' This function converts tag data stored in a VB friendly structure + ' FREE_IMAGE_TAG into a real FreeImage tag pointer (FITAG **tag). + + ' This function is called, whenever tag data should be updated for an + ' image, since the FreeImage's tag pointer remains valid during the + ' whole lifetime of a DIB. So, changes written to that pointer (or + ' even better, the FITAG structure at the address, the pointer points + ' to), are real updates to the image's tag. + + With Tag + + lpTag = pDeref(.TagPtr) + + ' save current (FITAG) tag for an optional 'undo' operation + ' invoked on failure + Call CopyMemory(tTagSave, ByVal lpTag, Len(tTagSave)) + + ' set tag id + Call CopyMemory(ByVal lpTag + 8, .Id, 2) + ' set tag type + Call CopyMemory(ByVal lpTag + 10, .Type, 2) + ' set tag key (use native FreeImage function to handle + ' memory allocation) + Call FreeImage_SetTagKey(.TagPtr, .Key) + + ' here, we update the tag's value + ' generally, we create a plain byte buffer containing all the + ' value's data and use FreeImage_SetTagValue() with the + ' const void *value pointer set to the byte buffer's address. + + ' the variable abValueBuffer is our byte buffer that is, + ' depending on the FreeImage tag data type, allocated and filled + ' accordingly + ' The variables 'lLength' and 'lCount' are set up correctly for + ' each data type and will be filled into the FITAG structure + ' before calling FreeImage_SetTagValue(); after all, the VB + ' Tag structure's (FREE_IMAGE_TAG) 'Count' and 'Length' members + ' are updated with 'lLength' and 'lCount'. + + Select Case .Type + + Case FIDT_ASCII + ' use StrConv() to get an ASCII byte array from a VB String (BSTR) + abValueBuffer = StrConv(.Value, vbFromUnicode) + ' according to FreeImage's source code, both 'count' and 'length' + ' must be the length of the string + lCount = Len(.Value) + lLength = lCount + + Case FIDT_PALETTE + ' ensure, that there are at least 'Count' entries in the + ' palette array + lCount = .Count + If (UBound(.Palette) + 1 < lCount) Then + ' if not, adjust Count + lCount = UBound(.Palette) + 1 + End If + ' 4 bytes per element + lLength = lCount * 4 + ' allocate buffer and copy data from Palatte array + ReDim abValueBuffer(lLength - 1) + Call CopyMemory(abValueBuffer(0), .Palette(LBound(.Palette)), lLength) + + Case FIDT_RATIONAL, _ + FIDT_SRATIONAL + ' we use a helper function to get a byte buffer for any type of + ' rational value + lCount = pGetRationalValueBuffer(.RationalValue, abValueBuffer) + If (lCount > .Count) Then + lCount = .Count + End If + ' eight bytes per element (2 longs) + lLength = lCount * 8 + + Case Else + ' we use a helper function to get a byte buffer for any other type + lCount = pGetValueBuffer(.Value, .Type, lLength, abValueBuffer) + If (lCount > .Count) Then + lCount = .Count + End If + ' lLength was used as an OUT parameter when calling pGetValueBuffer + ' it now contains the size of one element in bytes so, multiply with + ' lCount to get the total length + lLength = lLength * lCount + + End Select + + ' set tag length + Call CopyMemory(ByVal lpTag + 16, lLength, 4) + ' set tag count + Call CopyMemory(ByVal lpTag + 12, lCount, 4) + + If (FreeImage_SetTagValue(.TagPtr, VarPtr(abValueBuffer(0))) <> 0) Then + + ' update Tag's members + ' update Count + .Count = lCount + ' update Length + .Length = lLength + ' update StringValue + .StringValue = FreeImage_TagToString(.Model, .TagPtr) + pTagToTagPtr = True + Else + + ' restore saved (FITAG) tag values on failure + Call CopyMemory(ByVal lpTag, tTagSave, Len(tTagSave)) + End If + + End With + +End Function + +Private Function pGetValueBuffer(ByRef Value As Variant, _ + ByVal MetaDataVarType As FREE_IMAGE_MDTYPE, _ + ByRef ElementSize As Long, _ + ByRef Buffer() As Byte) As Long + +Dim lElementCount As Long +Dim bIsArray As Boolean +Dim abValueBuffer(7) As Byte +Dim cBytes As Long +Dim i As Long + + ' This function copies any value provided in the Variant 'Value' + ' parameter into the byte array Buffer. 'Value' may contain an + ' array as well. The values in the byte buffer are aligned to fit + ' the FreeImage data type for tag values specified in + ' 'MetaDataVarType'. For integer values, it does not matter, in + ' which VB data type the values are provided. For example, it is + ' possible to transform a provided byte array into a unsigned long + ' array. + + ' The parameter 'ElementSize' is an OUT value, providing the actual + ' size per element in the byte buffer in bytes to the caller. + + ' This function works for the types FIDT_BYTE, FIDT_SHORT, FIDT_LONG, + ' FIDT_SBYTE , FIDT_SSHORT, FIDT_SLONG, FIDT_FLOAT, FIDT_DOUBLE + ' and FIDT_IFD + + ElementSize = pGetElementSize(MetaDataVarType) + If (Not IsArray(Value)) Then + lElementCount = 1 + Else + On Error Resume Next + lElementCount = UBound(Value) - LBound(Value) + 1 + On Error GoTo 0 + bIsArray = True + End If + + If (lElementCount > 0) Then + ReDim Buffer((lElementCount * ElementSize) - 1) + + If (Not bIsArray) Then + cBytes = pGetVariantAsByteBuffer(Value, abValueBuffer) + If (cBytes > ElementSize) Then + cBytes = ElementSize + End If + Call CopyMemory(Buffer(0), abValueBuffer(0), cBytes) + Else + For i = LBound(Value) To UBound(Value) + cBytes = pGetVariantAsByteBuffer(Value(i), abValueBuffer) + If (cBytes > ElementSize) Then + cBytes = ElementSize + End If + Call CopyMemory(Buffer(0 + (i * ElementSize)), abValueBuffer(0), cBytes) + Next i + End If + + pGetValueBuffer = lElementCount + End If + +End Function + +Private Function pGetRationalValueBuffer(ByRef RationalValues() As FIRATIONAL, _ + ByRef Buffer() As Byte) As Long + +Dim lElementCount As Long +Dim abValueBuffer(7) As Byte +Dim cBytes As Long +Dim i As Long + + ' This function copies a number of elements from the FIRATIONAL array + ' 'RationalValues' into the byte buffer 'Buffer'. + + ' From the caller's point of view, this function is the same as + ' 'pGetValueBuffer', except, it only works for arrays of FIRATIONAL. + + ' This function works for the types FIDT_RATIONAL and FIDT_SRATIONAL. + + lElementCount = UBound(RationalValues) - LBound(RationalValues) + 1 + ReDim Buffer(lElementCount * 8 + 1) + + For i = LBound(RationalValues) To UBound(RationalValues) + cBytes = pGetVariantAsByteBuffer(RationalValues(i).Numerator, abValueBuffer) + If (cBytes > 4) Then + cBytes = 4 + End If + Call CopyMemory(Buffer(0 + (i * 8)), abValueBuffer(0), cBytes) + + cBytes = pGetVariantAsByteBuffer(RationalValues(i).Denominator, abValueBuffer) + If (cBytes > 4) Then + cBytes = 4 + End If + Call CopyMemory(Buffer(4 + (i * 8)), abValueBuffer(0), cBytes) + Next i + + pGetRationalValueBuffer = lElementCount + +End Function + +Private Function pGetVariantAsByteBuffer(ByRef Value As Variant, _ + ByRef Buffer() As Byte) As Long + +Dim lLength As Long + + ' This function fills a byte buffer 'Buffer' with data taken + ' from a Variant parameter. Depending on the Variant's type and, + ' width, it copies N (lLength) bytes into the buffer starting + ' at the buffer's first byte at Buffer(0). The function returns + ' the number of bytes copied. + + ' It is much easier to assign the Variant to a variable of + ' the proper native type first, since gathering a Variant's + ' actual value is a hard job to implement for each subtype. + + Select Case VarType(Value) + + Case vbByte + Buffer(0) = Value + lLength = 1 + + Case vbInteger + Dim iInteger As Integer + iInteger = Value + lLength = 2 + Call CopyMemory(Buffer(0), iInteger, lLength) + + Case vbLong + Dim lLong As Long + lLong = Value + lLength = 4 + Call CopyMemory(Buffer(0), lLong, lLength) + + Case vbCurrency + Dim cCurrency As Currency + ' since the Currency data type is a so called scaled + ' integer, we have to divide by 10.000 first to get the + ' proper bit layout. + cCurrency = Value / 10000 + lLength = 8 + Call CopyMemory(Buffer(0), cCurrency, lLength) + + Case vbSingle + Dim sSingle As Single + sSingle = Value + lLength = 4 + Call CopyMemory(Buffer(0), sSingle, lLength) + + Case vbDouble + Dim dblDouble As Double + dblDouble = Value + lLength = 8 + Call CopyMemory(Buffer(0), dblDouble, lLength) + + End Select + + pGetVariantAsByteBuffer = lLength + +End Function + +Private Function pGetElementSize(ByVal vt As FREE_IMAGE_MDTYPE) As Long + + ' This function returns the width in bytes for any of the + ' FreeImage metadata tag data types. + + Select Case vt + + Case FIDT_BYTE, _ + FIDT_SBYTE, _ + FIDT_UNDEFINED, _ + FIDT_ASCII + pGetElementSize = 1 + + Case FIDT_SHORT, _ + FIDT_SSHORT + pGetElementSize = 2 + + Case FIDT_LONG, _ + FIDT_SLONG, _ + FIDT_FLOAT, _ + FIDT_PALETTE, _ + FIDT_IFD + pGetElementSize = 4 + + Case Else + pGetElementSize = 8 + + End Select + +End Function + + + +'-------------------------------------------------------------------------------- +' Private pointer manipulation helper functions +'-------------------------------------------------------------------------------- + +Private Function pGetStringFromPointerA(ByRef Ptr As Long) As String + +Dim abBuffer() As Byte +Dim lLength As Long + + ' This function creates and returns a VB BSTR variable from + ' a C/C++ style string pointer by making a redundant deep + ' copy of the string's characters. + + If (Ptr) Then + ' get the length of the ANSI string pointed to by ptr + lLength = lstrlen(Ptr) + If (lLength) Then + ' copy characters to a byte array + ReDim abBuffer(lLength - 1) + Call CopyMemory(abBuffer(0), ByVal Ptr, lLength) + ' convert from byte array to unicode BSTR + pGetStringFromPointerA = StrConv(abBuffer, vbUnicode) + End If + End If + +End Function + +Private Function pDeref(ByVal Ptr As Long) As Long + + ' This function dereferences a pointer and returns the + ' contents as it's return value. + + ' in C/C++ this would be: + ' return *(ptr); + + Call CopyMemory(pDeref, ByVal Ptr, 4) + +End Function + +Private Sub pSwap(ByVal lpSrc As Long, _ + ByVal lpDst As Long) + +Dim lpTmp As Long + + ' This function swaps two DWORD memory blocks pointed to + ' by lpSrc and lpDst, whereby lpSrc and lpDst are actually + ' no pointer types but contain the pointer's address. + + ' in C/C++ this would be: + ' void pSwap(int lpSrc, int lpDst) { + ' int tmp = *(int*)lpSrc; + ' *(int*)lpSrc = *(int*)lpDst; + ' *(int*)lpDst = tmp; + ' } + + Call CopyMemory(lpTmp, ByVal lpSrc, 4) + Call CopyMemory(ByVal lpSrc, ByVal lpDst, 4) + Call CopyMemory(ByVal lpDst, lpTmp, 4) + +End Sub + +Private Function pGetMemoryBlockPtrFromVariant(ByRef Data As Variant, _ + Optional ByRef SizeInBytes As Long, _ + Optional ByRef ElementSize As Long) As Long + + ' This function returns the pointer to the memory block provided through + ' the Variant parameter 'data', which could be either a Byte, Integer or + ' Long array or the address of the memory block itself. In the last case, + ' the parameter 'SizeInBytes' must not be omitted or zero, since it's + ' correct value (the size of the memory block) can not be determined by + ' the address only. So, the function fails, if 'SizeInBytes' is omitted + ' or zero and 'data' is not an array but contains a Long value (the address + ' of a memory block) by returning Null. + + ' If 'data' contains either a Byte, Integer or Long array, the pointer to + ' the actual array data is returned. The parameter 'SizeInBytes' will + ' be adjusted correctly, if it was less or equal zero upon entry. + + ' The function returns Null (zero) if there was no supported memory block + ' provided. + + ' do we have an array? + If (VarType(Data) And vbArray) Then + Select Case (VarType(Data) And (Not vbArray)) + + Case vbByte + ElementSize = 1 + pGetMemoryBlockPtrFromVariant = pGetArrayPtrFromVariantArray(Data) + If (pGetMemoryBlockPtrFromVariant) Then + If (SizeInBytes <= 0) Then + SizeInBytes = (UBound(Data) + 1) + + ElseIf (SizeInBytes > (UBound(Data) + 1)) Then + SizeInBytes = (UBound(Data) + 1) + + End If + End If + + Case vbInteger + ElementSize = 2 + pGetMemoryBlockPtrFromVariant = pGetArrayPtrFromVariantArray(Data) + If (pGetMemoryBlockPtrFromVariant) Then + If (SizeInBytes <= 0) Then + SizeInBytes = (UBound(Data) + 1) * 2 + + ElseIf (SizeInBytes > ((UBound(Data) + 1) * 2)) Then + SizeInBytes = (UBound(Data) + 1) * 2 + + End If + End If + + Case vbLong + ElementSize = 4 + pGetMemoryBlockPtrFromVariant = pGetArrayPtrFromVariantArray(Data) + If (pGetMemoryBlockPtrFromVariant) Then + If (SizeInBytes <= 0) Then + SizeInBytes = (UBound(Data) + 1) * 4 + + ElseIf (SizeInBytes > ((UBound(Data) + 1) * 4)) Then + SizeInBytes = (UBound(Data) + 1) * 4 + + End If + End If + + End Select + Else + ElementSize = 1 + If ((VarType(Data) = vbLong) And _ + (SizeInBytes >= 0)) Then + pGetMemoryBlockPtrFromVariant = Data + End If + End If + +End Function + +Private Function pGetArrayPtrFromVariantArray(ByRef Data As Variant) As Long + +Dim eVarType As VbVarType +Dim lDataPtr As Long + + ' This function returns a pointer to the first array element of + ' a VB array (SAFEARRAY) that is passed through a Variant type + ' parameter. (Don't try this at home...) + + ' cache VarType in variable + eVarType = VarType(Data) + + ' ensure, this is an array + If (eVarType And vbArray) Then + + ' data is a VB array, what means a SAFEARRAY in C/C++, that is + ' passed through a ByRef Variant variable, that is a pointer to + ' a VARIANTARG structure + + ' the VARIANTARG structure looks like this: + + ' typedef struct tagVARIANT VARIANTARG; + ' struct tagVARIANT + ' { + ' Union + ' { + ' struct __tagVARIANT + ' { + ' VARTYPE vt; + ' WORD wReserved1; + ' WORD wReserved2; + ' WORD wReserved3; + ' Union + ' { + ' [...] + ' SAFEARRAY *parray; // used when not VT_BYREF + ' [...] + ' SAFEARRAY **pparray; // used when VT_BYREF + ' [...] + + ' the data element (SAFEARRAY) has an offset of 8, since VARTYPE + ' and WORD both have a length of 2 bytes; the pointer to the + ' VARIANTARG structure is the VarPtr of the Variant variable in VB + + ' getting the contents of the data element (in C/C++: *(data + 8)) + lDataPtr = pDeref(VarPtr(Data) + 8) + + ' dereference the pointer again (in C/C++: *(lDataPtr)) + lDataPtr = pDeref(lDataPtr) + + ' test, whether 'lDataPtr' now is a Null pointer + ' in that case, the array is not yet initialized and so we can't dereference + ' it another time since we have no permisson to acces address 0 + + ' the contents of 'lDataPtr' may be Null now in case of an uninitialized + ' array; then we can't access any of the SAFEARRAY members since the array + ' variable doesn't event point to a SAFEARRAY structure, so we will return + ' the null pointer + + If (lDataPtr) Then + ' the contents of lDataPtr now is a pointer to the SAFEARRAY structure + + ' the SAFEARRAY structure looks like this: + + ' typedef struct FARSTRUCT tagSAFEARRAY { + ' unsigned short cDims; // Count of dimensions in this array. + ' unsigned short fFeatures; // Flags used by the SafeArray + ' // routines documented below. + ' #if defined(WIN32) + ' unsigned long cbElements; // Size of an element of the array. + ' // Does not include size of + ' // pointed-to data. + ' unsigned long cLocks; // Number of times the array has been + ' // locked without corresponding unlock. + ' #Else + ' unsigned short cbElements; + ' unsigned short cLocks; + ' unsigned long handle; // Used on Macintosh only. + ' #End If + ' void HUGEP* pvData; // Pointer to the data. + ' SAFEARRAYBOUND rgsabound[1]; // One bound for each dimension. + ' } SAFEARRAY; + + ' since we live in WIN32, the pvData element has an offset + ' of 12 bytes from the base address of the structure, + ' so dereference the pvData pointer, what indeed is a pointer + ' to the actual array (in C/C++: *(lDataPtr + 12)) + lDataPtr = pDeref(lDataPtr + 12) + End If + + ' return this value + pGetArrayPtrFromVariantArray = lDataPtr + + ' a more shorter form of this function would be: + ' (doesn't work for uninitialized arrays, but will likely crash!) + 'pGetArrayPtrFromVariantArray = pDeref(pDeref(pDeref(VarPtr(data) + 8)) + 12) + End If + +End Function + + +#If (False) Then + +' Enum STRETCH_MODE +Const STRETCH_MODE = 1 +Const SM_BLACKONWHITE = 1 +Const SM_WHITEONBLACK = 1 +Const SM_COLORONCOLOR = 1 + +' Enum RASTER_OPERATOR +Const RASTER_OPERATOR = 1 +Const ROP_SRCAND = 1 +Const ROP_SRCCOPY = 1 +Const ROP_SRCERASE = 1 +Const ROP_SRCINVERT = 1 +Const ROP_SRCPAINT = 1 + +' Enum DRAW_MODE +Const DRAW_MODE = 1 +Const DM_DRAW_DEFAULT = 1 +Const DM_MIRROR_NONE = 1 +Const DM_MIRROR_VERTICAL = 1 +Const DM_MIRROR_HORIZONTAL = 1 +Const DM_MIRROR_BOTH = 1 + +' Enum HISTOGRAM_ORIENTATION +Const HISTOGRAM_ORIENTATION = 1 +Const HOR_TOP_DOWN = 1 +Const HOR_BOTTOM_UP = 1 + +' Enum FREE_IMAGE_ICC_COLOR_MODEL +Const FREE_IMAGE_ICC_COLOR_MODEL = 1 +Const FIICC_COLOR_MODEL_RGB = 1 +Const FIICC_COLOR_MODEL_CMYK = 1 + +' Enum FREE_IMAGE_FORMAT +Const FREE_IMAGE_FORMAT = 1 +Const FIF_UNKNOWN = 1 +Const FIF_BMP = 1 +Const FIF_ICO = 1 +Const FIF_JPEG = 1 +Const FIF_JNG = 1 +Const FIF_KOALA = 1 +Const FIF_LBM = 1 +Const FIF_IFF = 1 +Const FIF_MNG = 1 +Const FIF_PBM = 1 +Const FIF_PBMRAW = 1 +Const FIF_PCD = 1 +Const FIF_PCX = 1 +Const FIF_PGM = 1 +Const FIF_PGMRAW = 1 +Const FIF_PNG = 1 +Const FIF_PPM = 1 +Const FIF_PPMRAW = 1 +Const FIF_RAS = 1 +Const FIF_TARGA = 1 +Const FIF_TIFF = 1 +Const FIF_WBMP = 1 +Const FIF_PSD = 1 +Const FIF_CUT = 1 +Const FIF_XBM = 1 +Const FIF_XPM = 1 +Const FIF_DDS = 1 +Const FIF_GIF = 1 +Const FIF_HDR = 1 +Const FIF_FAXG3 = 1 +Const FIF_SGI = 1 +Const FIF_EXR = 1 +Const FIF_J2K = 1 +Const FIF_JP2 = 1 +Const FIF_PFM = 1 +Const FIF_PICT = 1 +Const FIF_RAW = 1 +Const FIF_WEBP = 1 +Const FIF_JXR = 1 + +' Enum FREE_IMAGE_LOAD_OPTIONS +Const FREE_IMAGE_LOAD_OPTIONS = 1 +Const FILO_LOAD_NOPIXELS = 1 +Const FILO_LOAD_DEFAULT = 1 +Const FILO_GIF_DEFAULT = 1 +Const FILO_GIF_LOAD256 = 1 +Const FILO_GIF_PLAYBACK = 1 +Const FILO_ICO_DEFAULT = 1 +Const FILO_ICO_MAKEALPHA = 1 +Const FILO_JPEG_DEFAULT = 1 +Const FILO_JPEG_FAST = 1 +Const FILO_JPEG_ACCURATE = 1 +Const FILO_JPEG_CMYK = 1 +Const FILO_JPEG_EXIFROTATE = 1 +Const FILO_JPEG_GREYSCALE = 1 +Const FILO_PCD_DEFAULT = 1 +Const FILO_PCD_BASE = 1 +Const FILO_PCD_BASEDIV4 = 1 +Const FILO_PCD_BASEDIV16 = 1 +Const FILO_PNG_DEFAULT = 1 +Const FILO_PNG_IGNOREGAMMA = 1 +Const FILO_PSD_CMYK = 1 +Const FILO_PSD_LAB = 1 +Const FILO_RAW_DEFAULT = 1 +Const FILO_RAW_PREVIEW = 1 +Const FILO_RAW_DISPLAY = 1 +Const FILO_RAW_HALFSIZE = 1 +Const FILO_TARGA_DEFAULT = 1 +Const FILO_TARGA_LOAD_RGB888 = 1 +Const FISO_TIFF_DEFAULT = 1 +Const FISO_TIFF_CMYK = 1 + +' Enum FREE_IMAGE_SAVE_OPTIONS +Const FREE_IMAGE_SAVE_OPTIONS = 1 +Const FISO_SAVE_DEFAULT = 1 +Const FISO_BMP_DEFAULT = 1 +Const FISO_BMP_SAVE_RLE = 1 +Const FISO_EXR_DEFAULT = 1 +Const FISO_EXR_FLOAT = 1 +Const FISO_EXR_NONE = 1 +Const FISO_EXR_ZIP = 1 +Const FISO_EXR_PIZ = 1 +Const FISO_EXR_PXR24 = 1 +Const FISO_EXR_B44 = 1 +Const FISO_EXR_LC = 1 +Const FISO_JPEG_DEFAULT = 1 +Const FISO_JPEG_QUALITYSUPERB = 1 +Const FISO_JPEG_QUALITYGOOD = 1 +Const FISO_JPEG_QUALITYNORMAL = 1 +Const FISO_JPEG_QUALITYAVERAGE = 1 +Const FISO_JPEG_QUALITYBAD = 1 +Const FISO_JPEG_PROGRESSIVE = 1 +Const FISO_JPEG_SUBSAMPLING_411 = 1 +Const FISO_JPEG_SUBSAMPLING_420 = 1 +Const FISO_JPEG_SUBSAMPLING_422 = 1 +Const FISO_JPEG_SUBSAMPLING_444 = 1 +Const FISO_JPEG_OPTIMIZE = 1 +Const FISO_JPEG_BASELINE = 1 +Const FISO_PNG_Z_BEST_SPEED = 1 +Const FISO_PNG_Z_DEFAULT_COMPRESSION = 1 +Const FISO_PNG_Z_BEST_COMPRESSION = 1 +Const FISO_PNG_Z_NO_COMPRESSION = 1 +Const FISO_PNG_INTERLACED = 1 +Const FISO_PNM_DEFAULT = 1 +Const FISO_PNM_SAVE_RAW = 1 +Const FISO_PNM_SAVE_ASCII = 1 +Const FISO_TARGA_SAVE_RLE = 1 +Const FISO_TIFF_DEFAULT = 1 +Const FISO_TIFF_CMYK = 1 +Const FISO_TIFF_PACKBITS = 1 +Const FISO_TIFF_DEFLATE = 1 +Const FISO_TIFF_ADOBE_DEFLATE = 1 +Const FISO_TIFF_NONE = 1 +Const FISO_TIFF_CCITTFAX3 = 1 +Const FISO_TIFF_CCITTFAX4 = 1 +Const FISO_TIFF_LZW = 1 +Const FISO_TIFF_JPEG = 1 +Const FISO_TIFF_LOGLUV = 1 +Const FISO_WEBP_LOSSLESS = 1 +Const FISO_JXR_LOSSLESS = 1 +Const FISO_JXR_PROGRESSIVE = 1 + +' Enum FREE_IMAGE_TYPE +Const FREE_IMAGE_TYPE = 1 +Const FIT_UNKNOWN = 1 +Const FIT_BITMAP = 1 +Const FIT_UINT16 = 1 +Const FIT_INT16 = 1 +Const FIT_UINT32 = 1 +Const FIT_INT32 = 1 +Const FIT_FLOAT = 1 +Const FIT_DOUBLE = 1 +Const FIT_COMPLEX = 1 +Const FIT_RGB16 = 1 +Const FIT_RGBA16 = 1 +Const FIT_RGBF = 1 +Const FIT_RGBAF = 1 + +' Enum FREE_IMAGE_COLOR_TYPE +Const FREE_IMAGE_COLOR_TYPE = 1 +Const FIC_MINISWHITE = 1 +Const FIC_MINISBLACK = 1 +Const FIC_RGB = 1 +Const FIC_PALETTE = 1 +Const FIC_RGBALPHA = 1 +Const FIC_CMYK = 1 + +' Enum FREE_IMAGE_QUANTIZE +Const FREE_IMAGE_QUANTIZE = 1 +Const FIQ_WUQUANT = 1 +Const FIQ_NNQUANT = 1 + +' Enum FREE_IMAGE_DITHER +Const FREE_IMAGE_DITHER = 1 +Const FID_FS = 1 +Const FID_BAYER4x4 = 1 +Const FID_BAYER8x8 = 1 +Const FID_CLUSTER6x6 = 1 +Const FID_CLUSTER8x8 = 1 +Const FID_CLUSTER16x16 = 1 +Const FID_BAYER16x16 = 1 + +' Enum FREE_IMAGE_JPEG_OPERATION +Const FREE_IMAGE_JPEG_OPERATION = 1 +Const FIJPEG_OP_NONE = 1 +Const FIJPEG_OP_FLIP_H = 1 +Const FIJPEG_OP_FLIP_V = 1 +Const FIJPEG_OP_TRANSPOSE = 1 +Const FIJPEG_OP_TRANSVERSE = 1 +Const FIJPEG_OP_ROTATE_90 = 1 +Const FIJPEG_OP_ROTATE_180 = 1 +Const FIJPEG_OP_ROTATE_270 = 1 + +' Enum FREE_IMAGE_TMO +Const FREE_IMAGE_TMO = 1 +Const FITMO_DRAGO03 = 1 +Const FITMO_REINHARD05 = 1 +Const FITMO_FATTAL02 = 1 + +' Enum FREE_IMAGE_FILTER +Const FREE_IMAGE_FILTER = 1 +Const FILTER_BOX = 1 +Const FILTER_BICUBIC = 1 +Const FILTER_BILINEAR = 1 +Const FILTER_BSPLINE = 1 +Const FILTER_CATMULLROM = 1 +Const FILTER_LANCZOS3 = 1 + +' Enum FREE_IMAGE_COLOR_CHANNEL +Const FREE_IMAGE_COLOR_CHANNEL = 1 +Const FICC_RGB = 1 +Const FICC_RED = 1 +Const FICC_GREEN = 1 +Const FICC_BLUE = 1 +Const FICC_ALPHA = 1 +Const FICC_BLACK = 1 +Const FICC_REAL = 1 +Const FICC_IMAG = 1 +Const FICC_MAG = 1 +Const FICC_PHASE = 1 + +' Enum FREE_IMAGE_MDTYPE +Const FREE_IMAGE_MDTYPE = 1 +Const FIDT_NOTYPE = 1 +Const FIDT_BYTE = 1 +Const FIDT_ASCII = 1 +Const FIDT_SHORT = 1 +Const FIDT_LONG = 1 +Const FIDT_RATIONAL = 1 +Const FIDT_SBYTE = 1 +Const FIDT_UNDEFINED = 1 +Const FIDT_SSHORT = 1 +Const FIDT_SLONG = 1 +Const FIDT_SRATIONAL = 1 +Const FIDT_FLOAT = 1 +Const FIDT_DOUBLE = 1 +Const FIDT_IFD = 1 +Const FIDT_PALETTE = 1 + +' Enum FREE_IMAGE_MDMODEL +Const FREE_IMAGE_MDMODEL = 1 +Const FIMD_NODATA = 1 +Const FIMD_COMMENTS = 1 +Const FIMD_EXIF_MAIN = 1 +Const FIMD_EXIF_EXIF = 1 +Const FIMD_EXIF_GPS = 1 +Const FIMD_EXIF_MAKERNOTE = 1 +Const FIMD_EXIF_INTEROP = 1 +Const FIMD_IPTC = 1 +Const FIMD_XMP = 1 +Const FIMD_GEOTIFF = 1 +Const FIMD_ANIMATION = 1 +Const FIMD_CUSTOM = 1 +Const FIMD_EXIF_RAW = 1 + +' Enum FREE_IMAGE_FRAME_DISPOSAL_METHODS +Const FREE_IMAGE_FRAME_DISPOSAL_METHODS = 1 +Const FIFD_GIF_DISPOSAL_UNSPECIFIED = 1 +Const FIFD_GIF_DISPOSAL_LEAVE = 1 +Const FIFD_GIF_DISPOSAL_BACKGROUND = 1 +Const FIFD_GIF_DISPOSAL_PREVIOUS = 1 + +' Enum FREE_IMAGE_COLOR_OPTIONS +Const FREE_IMAGE_COLOR_OPTIONS = 1 +Const FI_COLOR_IS_RGB_COLOR = 1 +Const FI_COLOR_IS_RGBA_COLOR = 1 +Const FI_COLOR_FIND_EQUAL_COLOR = 1 +Const FI_COLOR_ALPHA_IS_INDEX = 1 + +' Enum FREE_IMAGE_CONVERSION_FLAGS +Const FREE_IMAGE_CONVERSION_FLAGS = 1 +Const FICF_MONOCHROME = 1 +Const FICF_MONOCHROME_THRESHOLD = 1 +Const FICF_MONOCHROME_DITHER = 1 +Const FICF_GREYSCALE_4BPP = 1 +Const FICF_PALLETISED_8BPP = 1 +Const FICF_GREYSCALE_8BPP = 1 +Const FICF_GREYSCALE = 1 +Const FICF_RGB_15BPP = 1 +Const FICF_RGB_16BPP = 1 +Const FICF_RGB_24BPP = 1 +Const FICF_RGB_32BPP = 1 +Const FICF_RGB_ALPHA = 1 +Const FICF_KEEP_UNORDERED_GREYSCALE_PALETTE = 1 +Const FICF_REORDER_GREYSCALE_PALETTE = 1 + +' Enum FREE_IMAGE_COLOR_DEPTH +Const FREE_IMAGE_COLOR_DEPTH = 1 +Const FICD_AUTO = 1 +Const FICD_MONOCHROME = 1 +Const FICD_MONOCHROME_THRESHOLD = 1 +Const FICD_MONOCHROME_DITHER = 1 +Const FICD_1BPP = 1 +Const FICD_4BPP = 1 +Const FICD_8BPP = 1 +Const FICD_15BPP = 1 +Const FICD_16BPP = 1 +Const FICD_24BPP = 1 +Const FICD_32BPP = 1 + +' Enum FREE_IMAGE_ADJUST_MODE +Const FREE_IMAGE_ADJUST_MODE = 1 +Const AM_STRECH = 1 +Const AM_DEFAULT = 1 +Const AM_ADJUST_BOTH = 1 +Const AM_ADJUST_WIDTH = 1 +Const AM_ADJUST_HEIGHT = 1 +Const AM_ADJUST_OPTIMAL_SIZE = 1 + +' Enum FREE_IMAGE_MASK_FLAGS +Const FREE_IMAGE_MASK_FLAGS = 1 +Const FIMF_MASK_NONE = 1 +Const FIMF_MASK_FULL_TRANSPARENCY = 1 +Const FIMF_MASK_ALPHA_TRANSPARENCY = 1 +Const FIMF_MASK_COLOR_TRANSPARENCY = 1 +Const FIMF_MASK_FORCE_TRANSPARENCY = 1 +Const FIMF_MASK_INVERSE_MASK = 1 + +' Enum FREE_IMAGE_MASK_CREATION_OPTION_FLAGS +Const FREE_IMAGE_MASK_CREATION_OPTION_FLAGS = 1 +Const MCOF_CREATE_MASK_IMAGE = 1 +Const MCOF_MODIFY_SOURCE_IMAGE = 1 +Const MCOF_CREATE_AND_MODIFY = 1 + +' Enum FREE_IMAGE_TRANSPARENCY_STATE_FLAGS +Const FREE_IMAGE_TRANSPARENCY_STATE_FLAGS = 1 +Const FITSF_IGNORE_TRANSPARENCY = 1 +Const FITSF_NONTRANSPARENT = 1 +Const FITSF_TRANSPARENT = 1 +Const FITSF_INCLUDE_ALPHA_TRANSPARENCY = 1 + +' Enum FREE_IMAGE_ICON_TRANSPARENCY_OPTION_FLAGS +Const FREE_IMAGE_ICON_TRANSPARENCY_OPTION_FLAGS = 1 +Const ITOF_NO_TRANSPARENCY = 1 +Const ITOF_USE_TRANSPARENCY_INFO = 1 +Const ITOF_USE_TRANSPARENCY_INFO_ONLY = 1 +Const ITOF_USE_COLOR_TRANSPARENCY = 1 +Const ITOF_USE_COLOR_TRANSPARENCY_ONLY = 1 +Const ITOF_USE_TRANSPARENCY_INFO_OR_COLOR = 1 +Const ITOF_USE_DEFAULT_TRANSPARENCY = 1 +Const ITOF_USE_COLOR_TOP_LEFT_PIXEL = 1 +Const ITOF_USE_COLOR_FIRST_PIXEL = 1 +Const ITOF_USE_COLOR_TOP_RIGHT_PIXEL = 1 +Const ITOF_USE_COLOR_BOTTOM_LEFT_PIXEL = 1 +Const ITOF_USE_COLOR_BOTTOM_RIGHT_PIXEL = 1 +Const ITOF_USE_COLOR_SPECIFIED = 1 +Const ITOF_FORCE_TRANSPARENCY_INFO = 1 + +#End If diff --git a/#ThirdParty/FreeImage/Wrapper/VB6/mfreeimage/WhatsNew_VB.txt b/#ThirdParty/FreeImage/Wrapper/VB6/mfreeimage/WhatsNew_VB.txt new file mode 100644 index 0000000..f71652e --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/VB6/mfreeimage/WhatsNew_VB.txt @@ -0,0 +1,666 @@ +What's New for FreeImage VB Wrapper + +* : fixed +- : removed +! : changed ++ : added + +August 08, 2014 - 2.24 (3.16.0) +- [Carsten Klein] removed declaration of Win32 API function FillMemory ++ [Carsten Klein] added load flag RAW_UNPROCESSED and corresponding FILO_RAW_UNPROCESSED ++ [Carsten Klein] added function FreeImage_SetMetadataKeyValue +! [Carsten Klein] changed name of function FreeImage_ConvertFromRawBitsEx to FreeImage_ConvertFromRawBitsArray: naming conflict with new C/C++ function FreeImage_ConvertFromRawBitsEx +! [Carsten Klein] changed name of function FreeImage_ConvertToRawBitsEx to FreeImage_ConvertToRawBitsArray: no naming conflict, but tried to keep To and From functions together ++ [Carsten Klein] added function FreeImage_ConvertFromRawBitsEx + +March 17, 2014 - 2.22 (3.16.0) +* [Carsten Klein] renamed parameter 'Perfect' to 'Bottom' of functions FreeImage_JPEGCrop[U] to match native function declaration +! [Carsten Klein] changed default value of optional parameter 'Perfect' to True for functions FreeImage_JPEGTransform[U] +* [Carsten Klein] renamed function FreeImage_ApplyIndexMapping[Ex] to FreeImage_ApplyPaletteIndexMapping[Ex] (declarations and implementations) ++ [Carsten Klein] added functions FreeImage_JPEGTransformCombined[U] (declarations and implementations) ++ [Carsten Klein] added function FreeImage_JPEGTransformCombinedFromMemory (declarations and implementations) ++ [Carsten Klein] added wrapper functions FreeImage_JPEGTransformCombinedFromMemoryEx[2] working with more VB compatible memory representations (Variant and Byte array) +! [Carsten Klein] enhanced documentation of extended memory stream functions FreeImage_[Load|Save][MultiBitmap][From|To]MemoryEx[2] + +March 10, 2014 - 2.21 (3.16.0) ++ [Carsten Klein] added support for the new JPEG-XR image format + +October 10, 2013 - 2.20 (3.16.0) +* [Carsten Klein] prevented a potential 'Division by zero' error in private helper function pGetTagFromTagPtr. Thanks to Bob Weiss for pointing that out. ++ [Carsten Klein] added support for the new Google WebP image format +! [Carsten Klein] refactored and centralized all VB6 IDE tweaking constant definitions into one single '#If False' block at the end of the file +! [Carsten Klein] changed constants FREEIMAGE_MINOR_VERSION and FREEIMAGE_RELEASE_SERIAL to match current version 3.16.0 +- [Carsten Klein] removed change log entries from source file MFreeImage.bas +- [Carsten Klein] removed block 'General notes' form source file MFreeImage.bas + +March 14, 2013 - 2.19 (3.15.4) +* [Jørgen Hartmann] fixed coordinate calculation in FreeImage_PaintDCEx applied for horizontal and/or vertical mirroring, which now works correctly for all XDst and YDst coordinates. + +November 13, 2012 - 2.18 (3.15.4) ++ [Carsten Klein] added function declaration FreeImage_HasRGBMasksInt and a real VB Boolean returning function FreeImage_HasRGBMasks. +- [Carsten Klein] removed members red, green and blue from BITMAPINFOHEADER struct: these were intended for debugging purposes only and could couse a GPF in FreeImage_GetInfoHeaderEx. +* [Carsten Klein] fixed a bug in FreeImage_GetPictureData introduced in version 2.17. +* [Carsten Klein] fixed a bug with declaration of FreeImage_Rotate: added default value 0 for Optional ByRef ... As Any parameter 'Color'. + +October 1, 2012 - 2.17 (3.15.4) +- [Carsten Klein] removed temporary workaround for 16-bit standard type bitmaps introduced in version 2.15, which temporarily stored RGB masks directly after the BITMAPINFO structure, when creating a HBITMAP. +* [Carsten Klein] fixed a potential overflow bug in both pNormalizeRational and pNormalizeSRational: these now do nothing if any of numerator and denominator is either 1 or 0 (zero). ++ [Carsten Klein] added load flag JPEG_GREYSCALE as well as the enum constant FILO_JPEG_GREYSCALE. +! [Carsten Klein] changed constant FREEIMAGE_RELEASE_SERIAL to 4 to match current version 3.15.4 + +March 19, 2012 - 2.16 (3.15.3) +! [Carsten Klein] changed constant FREEIMAGE_RELEASE_SERIAL to 3 to match current version 3.15.3 + +March 12, 2012 - 2.15 (3.15.2) ++ [Carsten Klein] added function FreeImage_ConvertToUINT16. ++ [Carsten Klein] added function FreeImage_ConvertToRGB16. ++ [Carsten Klein] added function FreeImage_GetThumbnail. ++ [Carsten Klein] added function declaration FreeImage_SetThumbnailInt and a real VB Boolean returning function FreeImage_SetThumbnail. ++ [Carsten Klein] added RAW_HALFSIZE load flag as well as the enum constant FILO_RAW_HALFSIZE. ++ [Carsten Klein] added wrapper function FreeImage_GetPictureData, which returns a byte array suitable for assigning to an Office image control's PictureData property. ++ [Carsten Klein] added wrapper function FreeImage_CreateFromPictureData, which creates a FreeImage bitmap from a PictureData byte array. ++ [Carsten Klein] added new save flag JPEG_BASELINE (also added FISO_JPEG_BASELINE to enumeration FREE_IMAGE_SAVE_OPTIONS). ++ [Carsten Klein] added a workaround for providing valid BITMAPINFO structures for non 555 16-bpp images to Windows API functions like CreateDIBSection, CreateDIBBitmap, StretchDIBits or SetDIBitsToDevice. +! [Carsten Klein] changed constants FREEIMAGE_MINOR_VERSION and FREEIMAGE_RELEASE_SERIAL: set to 15 and 2 respectively to match current version 3.15.2 + +March 13, 2011 - 2.14 (3.14.1) +* [Glenn Thorpe] fixed a typo error with the call to FreeImage_HasPixels inside FreeImage_CreateMask. + +August 11, 2010 - 2.13 (3.14.1) ++ [Carsten Klein] added PSD load flags PSD_CMYK and PSD_LAB as well as the enum constants FILO_PSD_CYMK and FILO_PSD_LAB. ++ [Carsten Klein] added TIFF_LOGLUV save flag as well as the enum constant FISO_TIFF_LOGLUV. + +July 20, 2010 - 2.12 (3.14.1) ++ [Carsten Klein] added support for the new EXIF_RAW metadata model by adding enum constant FIMD_EXIF_RAW. ++ [Carsten Klein] added the new FIF_LOAD_NOPIXELS flag as well as the enum constant FILO_LOAD_NOPIXELS. ++ [Carsten Klein] added function declaration FreeImage_HasPixelsInt and a real VB Boolean returning function FreeImage_HasPixels. ++ [Carsten Klein] added function declaration FreeImage_FIFSupportsNoPixelsInt and a real VB Boolean returning function FreeImage_FIFSupportsNoPixels. + +June 20, 2010 - 2.11 (3.14.0) ++ [Carsten Klein] added new save flag JPEG_OPTIMIZE (also added FISO_JPEG_OPTIMIZE to enumeration FREE_IMAGE_SAVE_OPTIONS). + +April 20, 2010 - 2.10 (3.14.0) ++ [Carsten Klein] added new save flag TARGA_SAVE_RLE (also added FISO_TARGA_SAVE_RLE to enumeration FREE_IMAGE_SAVE_OPTIONS). +! [Carsten Klein] changed constants FREEIMAGE_MINOR_VERSION and FREEIMAGE_RELEASE_SERIAL: set to 14 and 0 respectively to match current version 3.14.0 ++ [Carsten Klein] added function FreeImage_ConvertToFloat. ++ [Carsten Klein] added function FreeImage_SaveMultiBitmapToMemory. ++ [Carsten Klein] added wrapper functions FreeImage_SaveMultiBitmapToMemoryEx and FreeImage_SaveMultiBitmapToMemoryEx2. ++ [Carsten Klein] added wrapper function FreeImage_OpenMultiBitmapEx, which only opens existing files, but has support for automatic image format detection. ++ [Carsten Klein] added wrapper function FreeImage_CreateMultiBitmapEx, which only creates new (empty) multi-page bitmaps with support for automatic image format detection. +* [Carsten Klein] fixed a bug in FreeImage_LoadEx: now uses the file specified for format detection rather than the filename extension. ++ [Carsten Klein] improved error messages in function FreeImage_LoadEx. +* [Carsten Klein] fixed a bug in FreeImage_AcquireMemoryEx: no more crashes when passing an uninitialized array. ++ [Carsten Klein] added thin wrapper functions, enabling proper handling of Boolean parameters: ++ added wrapper function FreeImage_OpenMultiBitmap ++ added wrapper function FreeImage_UnlockPage ++ added wrapper function FreeImage_RotateEx ++ added wrapper function FreeImage_MakeThumbnail ++ added wrapper function FreeImage_GetAdjustColorsLookupTable ++ added wrapper function FreeImage_ApplyColorMapping ++ added wrapper function FreeImage_SwapColors ++ added wrapper function FreeImage_SwapColorsByLong ++ added wrapper function FreeImage_ApplyIndexMapping ++ added wrapper function FreeImage_SetTransparent ++ added wrapper function FreeImage_ConvertFromRawBits ++ added wrapper function FreeImage_ConvertToRawBits ++ added wrapper function FreeImage_ConvertToStandardType ++ added wrapper function FreeImage_ConvertToType +! [Carsten Klein] changed the parameter names of most functions. +! [Carsten Klein] changed signature of functions FreeImage_ConvertFromRawBits and FreeImage_ConvertToRawBits: 'ByRef Bits As Long' is now 'ByVal BitsPtr As Long'. ++ [Carsten Klein] added wrapper functions FreeImage_ConvertFromRawBitsEx and FreeImage_ConvertToRawBitsEx. +* [Carsten Klein] fixed a bug in declaration of function FreeImage_TmoReinhard05Ex: parameters 'Adaption' and 'ColorCorrection' are now passed by value. +- [Carsten Klein] removed half-implemented function FreeImage_SetChannelEx. ++ [Carsten Klein] added wrapper function FreeImage_SetChannelIOP. +- [Carsten Klein] removed needless default values of optional parameters. +- [Carsten Klein] removed function declaration FreeImage_CompositeByLong: replaced by declaration FreeImage_Composite. +! [Carsten Klein] changed function declaration FreeImage_Composite: application back color is now passed as ByRef ... As Any and so takes both RGBQUAD and Long valus. ++ [Carsten Klein] added wrapper function FreeImage_UnloadEx, which additionally sets the ByRef-passed Bitmap handle to zero after unloading. ++ [Carsten Klein] added wrapper functions ConvertColor and ConvertOleColor to convert VB-style BGR colors into RGB color values. + +February 9, 2010 - 2.9.1 (3.13.1) +* [Carsten Klein] fixed a bug in FreeImage_GetBackgroundColorAsLong: parameter 'bkcolor' is now properly passed ByRef. + +February 9, 2010 - 2.9 (3.13.1) +* [Carsten Klein] fixed a syntax typo + +February 8, 2010 - 2.8 (3.13.1) +* [Mike Weir] fixed a bug in function FreeImage_ApplyColorMappingEx: now properly includes all specified mapping entries +* [Carsten Klein] fixed a bug in function FreeImage_ApplyIndexMappingEx: now properly includes all specified mapping entries +* [Mike Weir] fixed a bug in function FreeImage_RescaleEx: now also rescales the image, if either the new width or height matches the image's current size +* [WinAnd / Carsten Klein] fixed a bug in function FreeImage_GetTransparencyTableExClone: returns an uninitialized array if there is no transparency table +* [WinAnd / Carsten Klein] fixed a bug in function FreeImage_SearchPalette: no longer crashes if there is no transparency table + +December 21, 2009 - 2.7 (3.13.1) +! [Carsten Klein] changed constant FREEIMAGE_RELEASE_SERIAL: set to 1 to match current version 3.13.1 + +December 18, 2009 - 2.6 (3.13.0) +- [Carsten Klein] removed usage of constants vbPicTypeBitmap and vbPicTypeIcon: these are not available in VBA environments like Excel, Access or Outlook. + +September 08, 2009 - 2.5 (3.13.0) +! [Carsten Klein] changed constant FREEIMAGE_MINOR_VERSION: set to 13 to match current version 3.13.0 ++ [Carsten Klein] added load flag constant JPEG_EXIFROTATE and new member FILO_JPEG_EXIFROTATE to enumeration FREE_IMAGE_LOAD_OPTIONS. ++ [Carsten Klein] added support for the PFM image format. ++ [Carsten Klein] added support for the PICT and RAW image formats. ++ [Carsten Klein] added UNICODE functions FreeImage_JPEGTransformU and FreeImage_JPEGCropU. ++ [Carsten Klein] added enumeration FREE_IMAGE_COLOR_OPTIONS, which contains options to specify colors, used with FreeImage_FillBackground and FreeImage_EnlargeCanvas. ++ [Carsten Klein] added function FreeImage_FillBackground: although this returns BOOL in C/C++, the VB version only returns a Long. ++ [Carsten Klein] added wrapper functions FreeImage_FillBackgroundEx and FreeImage_FillBackgroundByLong, taking an RGBQUAD and a Long 'Color' argument respectively and return a true VB Boolean. ++ [Carsten Klein] added function FreeImage_EnlargeCanvas. ++ [Carsten Klein] added functions FreeImage_AllocateEx and FreeImage_AllocateExT. ++ [Carsten Klein] added function FreeImage_TmoReinhard05Ex. ++ [Carsten Klein] added function FreeImage_Rotate. ++ [Carsten Klein] added wrapper function FreeImage_RotateIOP. + +March 18, 2009 - 2.4.2 (3.11.0) ++ [Carsten Klein] added enumeration FREE_IMAGE_FRAME_DISPOSAL_METHODS, which provides the frame disposal options needed to create animated GIF files. + +July 29, 2008 - 2.4.1 (3.11.0) +* [Carsten Klein] minor documentation updates +! [Carsten Klein] renamed member FICF_PALETTISED_8BPP of enumeration FREE_IMAGE_CONVERSION_FLAGS into FICF_PALLETISED_8BPP. + +June 30, 2008 - 2.4 (3.11.0) +* [Carsten Klein] fixed some minor issues in FreeImage_PaintTransparent() + +June 06, 2008 - 2.3 (3.11.0) ++ [Carsten Klein] added new compression flags to the JPEG and PNG plugins +! [Carsten Klein] renamed wrapper function FreeImage_CloneMetadata() to FreeImage_CloneMetadataEx(): now, there is a native function called FreeImage_CloneMetadata(). ++ [Carsten Klein] added private and internal function declaration for FreeImage_CloneMetadata() along with it's public Boolean returning wrapper function. +- [Carsten Klein] removed the FreeImage_ColorQuantizeEx() stuff from both functions FreeImage_ConvertColorDepth() and FreeImage_ConvertColorDepthIOP(): removed parameters PaletteSize, ReserveSize and ReservePalette. +- [Carsten Klein] changed declaration of FreeImage_ColorQuantizeEx() to be a internal function private to the wrapper with an 'Int' appendix. ++ [Carsten Klein] added two more VB-friendly public wrapper functions FreeImage_ColorQuantizeEx() and FreeImage_ColorQuantizeExIOP(). ++ [Carsten Klein] added wrapper function FreeImage_GetPalettePtr(): gets the pointer to a specified array of RGBQUADs: intended to be used together with any of the ColorQuantizeEx functions. +! [Carsten Klein] changed constant FREEIMAGE_MINOR_VERSION: set to 11 to match current version 3.11.0 + +December 14, 2007 - 2.2.1 (3.10.0) ++ [Carsten Klein] added constants for member 'biCompression' in BITMAPINFOHEADER struct ++ [Carsten Klein] added wrapper function FreeImage_GetInfoHeaderEx(), which returns a fully populated BITMAPINFOHEADER struct for a bitmap. +* [Carsten Klein] fixed a bug in FreeImage_GetFileTypeFromMemoryEx(): now calls FreeImage_CloseMemory() releasing the hStream to prevent memory leaks. ++ [Carsten Klein] added wrapper function FreeImage_GetColorizedPalette(): returns a colorized greyscale palettte. ++ [Carsten Klein] added wrapper function FreeImage_Colorize(): applies a colorized greyscale palettte obtained from FreeImage_GetColorizedPalette() to a bitmap. ++ [Carsten Klein] added wrapper function FreeImage_Sepia(): calls FreeImage_Colorize() with proper parameters to apply a so called sepia palette to a bitmap. + +December 12, 2007 - 2.2 (3.10.0) +* [Carsten Klein] Fixed a small bug in FreeImage_PaintTransparent, which now calls function FreeImage_ConvertTo32Bits instead of FreeImage_ConvertTo32Bits2. + +November 15, 2007 - 2.1 (3.10.0) +* [Carsten Klein] adjusted page numbers of the API documentation in FreeImage function declarations to match FreeImage 3.10.0 API documentation +- [Carsten Klein] removed parameter 'bUnloadSource' from function FreeImage_GetOlePictureIcon(): an hIcon should not be destroyed if OleCreatePictureIndirect() is called with fOwn = True. +! [Carsten Klein] refactored FreeImage_GetOlePicture(): now relies on FreeImage_GetBitmap(). + +November 10, 2007 - 2.0.8 (3.10.0) +! [Carsten Klein] changed declaration of FreeImage_SetOutputMessage(): now points transparently to the __stdcall version of this function in the library. ++ [Carsten Klein] added function declaraton for FreeImage_MultigridPoissonSolver(). ++ [Carsten Klein] added function declaraton for FreeImage_GetTransparentIndex() and FreeImage_SetTransparentIndex(). ++ [Carsten Klein] added private and internal function declaraton for FreeImage_AdjustColors() along with it's public Boolean returning wrapper function. ++ [Carsten Klein] added function declaraton for FreeImage_GetAdjustColorsLookupTable(). ++ [Carsten Klein] added wrapper function FreeImage_GetAdjustColorsLookupTableEx(): this takes a real VB style Byte array ton receive the lookup table created. ++ [Carsten Klein] added function declaraton for FreeImage_ApplyColorMapping(). ++ [Carsten Klein] added wrapper function FreeImage_ApplyColorMappingEx(): this takes a real VB style RGBQUAD array. ++ [Carsten Klein] added function declaratons for FreeImage_SwapColors() and FreeImage_SwapColorsByLong(). ++ [Carsten Klein] added function declaraton for FreeImage_ApplyIndexMapping(). ++ [Carsten Klein] added wrapper function FreeImage_ApplyIndexMappingEx(): this takes a real VB style Byte array. ++ [Carsten Klein] added function declaraton for FreeImage_SwapPaletteIndices(). + +November 05, 2007 - 2.0.7 (3.10.0) ++ [Carsten Klein] added 4 bit color depth to both function pGetNextColorDepth() and pGetPrevousColorDepth() +- [Carsten Klein] removed member FICF_PREPARE_RESCALE from enumeration FREE_IMAGE_CONVERSION_FLAGS +- [Carsten Klein] removed all references to FICF_PREPARE_RESCALE: Converting color depth before rescaling an image is no longer performed by the wrapper. Since FreeImage now transparently converts color depth on rescaling, doing this in the wrapper is no longer needed. +! [Carsten Klein] refactored wrapper function FreeImage_ConvertColorDepth(): removed case FICF_PREPARE_RESCALE; is now more similar to C# wrapper's version of this function. +! [Carsten Klein] refactored wrapper function FreeImage_SaveEx(): removed case FICF_PREPARE_RESCALE; is now more similar to C# wrapper's version of this function. + +September 14, 2007 - 2.0.6 (3.10.0) ++ [Carsten Klein] added function declaration and Boolean wrapper function for FreeImage_PreMultiplyWithAlpha(). + +July 26, 2007 - 2.0.5 (3.10.0) ++ [Carsten Klein] added wrapper function FreeImage_GetBitmap(): returns an HBITMAP created by the CreateDIBSection() function and so has the same color depth as the original DIB. ++ [Carsten Klein] added wrapper function FreeImage_GetBitmapForDevice(): returns an HBITMAP created by the CreateDIBitmap() function and so has the same color depth as the specified reference DC or as the desktop, if the 'hDC' parameter was omitted. +- [Carsten Klein] removed function declaration for GetWindowDC(): this function is no longer used. +* [Carsten Klein] fixed a bug in wrapper function FreeImage_IsExtensionValidForFIF(): string comparison now includes a comma. +* [Carsten Klein] fixed a bug in wrapper function FreeImage_IsFilenameValidForFIF(): string comparison now includes a comma. + +July 25, 2007 - 2.0.4 (3.10.0) +* [Carsten Klein] fixed a bug in function FreeImage_GetPaletteExClone(): now actually returns the palette as RGBQUAD array plus some other minor improvements ++ [Carsten Klein] added wrapper function FreeImage_GetPaletteExLongClone(): this function returns a VB style Byte array that is only wrapped around FreeImage's pointer to a DIB's transparency table. ++ [Carsten Klein] added wrapper function FreeImage_GetTransparencyTableEx(): this function returns a VB style Byte array that is only wrapped around FreeImage's pointer to a DIB's transparency table. +! [Carsten Klein] changed name of wrapper function FreeImage_GetTransparencyTableEx(): this function is now named FreeImage_GetTransparencyTableExClone(), since it actually returns a clone (deep copy) of an image's transparency table (compare with FreeImage_GetPaletteExClone()). ++ [Carsten Klein] added wrapper function FreeImage_SetPalette(): sets an image's palette through a VB style RGBQUAD array. ++ [Carsten Klein] added wrapper function FreeImage_SetPaletteLong(): sets an image's palette through a VB style Long array. ++ [Carsten Klein] added function declaration for CreateDIBsection() ++ [Carsten Klein] added function declaration for DeleteDC() +* [Carsten Klein] fixed a bug in wrapper function FreeImage_CreateFromScreen(): now the memory DC is deleted with the DeleteDC() function and no longer with the DeleteObject() function. + +July 05, 2007 - 2.0.3 (3.10.0) ++ [Carsten Klein] added wrapper function FreeImage_GetFileTypeFromMemoryEx(): more VB friendly version of FreeImage_GetFileTypeFromMemory() which may take an array rather than a FIMEMORY stream. + +May 21, 2007 - 2.0.2 (3.10.0) +! [Carsten Klein] changed constant FREEIMAGE_MINOR_VERSION: set to 10 to match current version 3.10.0 +! [Carsten Klein] changed constant FREEIMAGE_RELEASE_SERIAL: set to 0 to match current version 3.10.0 ++ [Carsten Klein] added image format constants FIF_EXR, FIF_J2K and FIF_JP2 to enumeration FREE_IMAGE_FORMAT. ++ [Carsten Klein] added tone mapping operator constant FITMO_FATTAL02 to enumeration FREE_IMAGE_TMO. ++ [Carsten Klein] added save option constants J2K_DEFAULT and JP2_DEFAULT for JPEG2000 format. ++ [Carsten Klein] added save option constants EXR_DEFAULT, EXR_FLOAT, EXR_NONE, EXR_ZIP, EXR_PIZ, EXR_PXR24, EXR_B44 and EXR_LC for EXR format. ++ [Carsten Klein] added save option constants for EXR format to enumeration FREE_IMAGE_SAVE_OPTIONS. ++ [Carsten Klein] added declared function FreeImage_TmoFattal02(): adds support for Gradient domain high dynamic range compression (R. Fattal, 2002) + +February 24, 2007 - 2.0.1 (3.9.3) +* [Carsten Klein] fixed a bug in function FreeImage_CreateFromScreen(): now size of image created is according to window to be captured if parameter 'hwnd' <> 0. ++ [Carsten Klein] added parameter 'bClientAreaOnly' to function FreeImage_CreateFromScreen(). ++ [Carsten Klein] added blitting option 'CAPTUREBLT' when calling function BitBlt() in function FreeImage_CreateFromScreen(). +- [Carsten Klein] removed unused variable 'hDIB' from functions FreeImage_CreateFromScreen() and FreeImage_LoadEx(). Thanks to Bruce Rusk for pointing that out. + +February 16, 2007 - 2.0 (3.9.3) +! [Carsten Klein] changed constant FREEIMAGE_RELEASE_SERIAL: set to 3 to match current version 3.9.3 +! [Carsten Klein] changed JPEG load/save flag option values: changed constants and both enumerations FREE_IMAGE_LOAD_OPTIONS and FREE_IMAGE_SAVE_OPTIONS. ++ [Carsten Klein] added ICC Color Profile support: +! changed signature of declared function FreeImage_GetICCProfile(): is now declared 'Private' and suffixed with '...Int()'. ++ added wrapper function FreeImage_GetICCProfile(): is the public wrapper function for private function FreeImage_GetICCProfileInt(), returing a real FIICCPROFILE structure. ++ added constant FREE_IMAGE_ICC_COLOR_MODEL_MASK. ++ added enumeration FREE_IMAGE_ICC_COLOR_MODEL. ++ added wrapper function FreeImage_GetICCProfileColorModel(): returns the color profile's color model (FIICCPROFILE.flags member). ++ added wrapper function FreeImage_GetICCProfileSize(): returns the color profile data's size in bytes. ++ added wrapper function FreeImage_GetICCProfileDataPointer(): returns the pointer to the color profile data. ++ added wrapper function FreeImage_HasICCProfile(): returns whether a color profile is available for a dib or not. +! [Carsten Klein] changed behaviour of wrapper function FreeImage_RescaleEx() and all it's derived functions: no clone is returned if the actual and desired image size are the same. ++ [Carsten Klein] added parameter 'bForceCloneCreation' to wrapper function FreeImage_RescaleEx() and all it's derived functions. + +January 09, 2007 - 1.9.4 (3.9.2) +! [Carsten Klein] changed scope of declared function FreeImage_GetFileTypeUInt(): is now private according to all other '...Int' functions wrapped by a VB-friendly function. +! [Carsten Klein] changed scope of declared function FreeImage_GetFIFFromFilenameUInt(): is now private according to all other '...Int' functions wrapped by a VB-friendly function. +! [Carsten Klein] changed signature of declared functions FreeImage_GetBackgroundColorInt() and FreeImage_SetBackgroundColorInt(): now both have a 'ByRef bkcolor As RGBQUAD' parameter instead of 'ByVal bkcolor As Long'. ++ [Carsten Klein] added declared functions FreeImage_GetBackgroundColorAsLongInt(): this has a 'ByRef bkcolor As Long' parameter and provides the background color as a Long value. ++ [Carsten Klein] added declared functions FreeImage_SetBackgroundColorAsLongInt(): this has a 'ByRef bkcolor As Long' parameter and takes the background color as a Long value. +! [Carsten Klein] changed signature of wrapper functions FreeImage_GetBackgroundColor() and FreeImage_SetBackgroundColor(): now both have a 'ByRef bkcolor As RGBQUAD' parameter instead of 'ByVal bkcolor As Long'. ++ [Carsten Klein] added wrapper functions FreeImage_GetBackgroundColorAsLong() and FreeImage_SetBackgroundColorAsLong(): both have a 'ByRef bkcolor As Long' parameter and so offer getting and setting the background color through a Long value. ++ [Carsten Klein] added wrapper functions FreeImage_GetBackgroundColorEx() and FreeImage_SetBackgroundColorEx(): both both take 4 ByRef Byte parameters 'Alpha', 'Red', 'Green' and 'Blue', one for each color component. + +January 05, 2007 - 1.9.3 (3.9.2) ++ [Carsten Klein] added wrapper function FreeImage_GetLockedPageNumbersEx(): this returns a real VB-style array of Longs containing the page numbers of all locked pages. + +January 02, 2007 - 1.9.2 (3.9.2) +* [Carsten Klein] fixed a bug in inline description of function FreeImage_GetPaletteEx(): now tells to use function FreeImage_DestroyLockedArrayRGBQUAD() to free an array returned by this function. +* [Carsten Klein] fixed some minor bugs in inline documentation. +* [Carsten Klein] fixed a serious bug in function FreeImage_SaveEx(): parameter 'bUnloadSource' is now interpreted correctly under all circumstances. +* [Carsten Klein] fixed some minor issues in function FreeImage_SaveEx(). + +December 29, 2006 - 1.9.1 (3.9.2) ++ [Carsten Klein] added enumeration item FID_BAYER16x16: now supports Bayer ordered dispersed dot dithering (order 4 dithering matrix). + +October 31, 2006 - 1.9 (3.9.2) +* [Carsten Klein] adjusted page numbers of the API documentation in header comments in FreeImage function declarations to match FreeImage 3.9.2 API documentation +! [Carsten Klein] changed constant FREEIMAGE_RELEASE_SERIAL: set to 2 to match current version 3.9.2 ++ [Carsten Klein] added function declaration for FreeImage_JPEGCrop(): added both declaration and Boolean returning wrapper function. +! [Carsten Klein] changed data type of all occurences of parameter 'Flags' from Long to either FREE_IMAGE_LOAD_OPTIONS or FREE_IMAGE_SAVE_OPTIONS enum. This is true for declared funcitons as well as for wrapper functions. ++ [Carsten Klein] added function declaration for FreeImage_LoadMultiBitmapFromMemory(). ++ [Carsten Klein] added wrapper function FreeImage_LoadMultiBitmapFromMemoryEx(): this is dealing with a VB style array (SAFEARRAY) like FreeImage_LoadFromMemoryEx() does. + +October 30, 2006 - 1.8 (3.9.1) +* [Carsten Klein] fixed a memory leak in wrapper function SavePictureEx(). Thanks to Roogames for reporting that bug. +! [Carsten Klein] changed return type of wrapper function SavePictureEx() to Boolean. ++ [Carsten Klein] added wrapper function FreeImage_SaveEx() which brings all the features, as there are inline size- and color conversion and format guessing, so far only known from SavePictureEx() for DIBs. +! [Carsten Klein] changed wrapper function SavePictureEx(): now this is only a thin wrapper for function FreeImage_SaveEx(). ++ [Carsten Klein] added enumeration FREE_IMAGE_LOAD_OPTIONS. +- [Carsten Klein] refactored enumeration FREE_IMAGE_SAVE_OPTIONS: removed unnecessary items from enumeration. +! [Carsten Klein] changed wrapper function LoadPictureEx(): added parameter 'Options' (enum FREE_IMAGE_LOAD_OPTIONS) to specify image loading options (called 'flags' in FreeImage). ++ [Carsten Klein] added wrapper function FreeImage_LoadEx() which brings all the features, as there are inline size- and color conversion and format guessing, so far only known from LoadPictureEx() for DIBs. +! [Carsten Klein] changed wrapper function LoadPictureEx(): now this is only a thin wrapper for function FreeImage_LoadEx(). + +October 13, 2006 - 1.7.2 (3.9.1) ++ [Carsten Klein] added User32 function GetDesktopWindow() ++ added User32 function GetWindowDC() +- [Carsten Klein] removed unused constants DI_MASK, DI_IMAGE and DI_NORMAL ++ added GDI32 function GetDeviceCaps() with constants HORZRES and VERTRES ++ added GDI32 function SelectObject() ++ added GDI32 function DeleteObject() ++ added GDI32 function CreateCompatibleBitmap() ++ added GDI32 function CreateCompatibleDC() ++ added GDI32 function BitBlt() ++ [Carsten Klein] added wrapper function FreeImage_CreateFromScreen(): this function lets you capture the whole screen or any certain window + +October 10, 2006 - 1.7.1 (3.9.1) +! [Carsten Klein] changed parameter name 'Page' into 'hPageDib' in declared function FreeImage_UnlockPage(). 'hPageDib' must be the (dib-)handle obtained from FreeImage_LockPage() and not the page number. Now, the declaration is less confusing. Thanks to Ender Wiggin. + +August 4, 2006 - 1.7 (3.9.1) +* [Carsten Klein] fixed a bug in pGetTagFromTagPtr(): removed overflow error when converting unsigned short tags (FIDT_SHORT) with values between 32768 and 65535. Thanks to André Hendriks. +! [Carsten Klein] changed constant FREEIMAGE_RELEASE_SERIAL: set to 1 to match current version 3.9.1 + +July 17, 2006 - 1.6 (3.9.0) ++ [Carsten Klein] added more public wrapper functions for tag copying and cloning: ++ added function FreeImage_CopyMetadata() ++ added function FreeImage_CloneMetadata() +- [Carsten Klein] removed dead API functions, dead structures and dead variables +* [Carsten Klein] fixed a bug in FreeImage_ConvertColorDepth(): now color images are converted to 24 bits when used with FICF_PREPARE_RESCALE, all others to 8 bit + +July 16, 2006 - 1.5.6 (3.9.0) ++ [Carsten Klein] added more public wrapper functions for VB friendly tag access: these functions deal with a FREE_IMAGE_TAG structure instead of FreeImage's Tag pointer. ++ added function FreeImage_SetMetadataEx() ++ added function FreeImage_CreateTagEx() ++ added function FreeImage_AppendTag() ++ added function FreeImage_RemoveTag() ++ added function FreeImage_RemoveTagEx() ++ added function FreeImage_TagExists() ++ added function FreeImage_TagExistsEx() ++ added function FreeImage_DeleteTagEx() ++ added function FreeImage_CloneTagEx() ++ added function FreeImage_RemoveMetadataModel() ++ added function FreeImage_UpdateMetadata() ++ added function FreeImage_UnsignedLong() ++ added function FreeImage_UnsignedShort() ++ added function FreeImage_CreateRational() ++ added function FreeImage_CreateSignedRational() ++ added function FreeImage_GetImageComment() ++ added function FreeImage_SetImageComment() ++ [Carsten Klein] added some private helper functions to leverage tag updating: ++ added helper function pTagToTagPtr() ++ added helper function pGetValueBuffer() ++ added helper function pGetRationalValueBuffer() ++ added helper function pGetVariantAsByteBuffer() ++ added helper function pGetElementSize() + +July 5, 2006 - 1.5.5 (3.9.0) +! [Carsten Klein] changed function signature of FreeImage_FindNextMetadataEx(): optional parameter 'Model' is now present; see the function's inline documentation + +June 30, 2006 - 1.5.4 (3.9.0) +* [Carsten Klein] fixed bug in functions creating a FreeImage DIB from a windows hBitmap: workaround for palettized bitmaps is now implemented +* fixed function FreeImage_CreateFromOLEPicture() +* fixed function FreeImage_CreateFromDC() + +June 22, 2006 - 1.5.3 (3.9.0) +! [Carsten Klein] changed function declaration of FreeImage_GetMetadataInt(): parameter 'model' is now 'ByVal' and Tag is a Long pointer +! [Carsten Klein] changed function declaration of FreeImage_SetMetadataInt(): parameter 'model' is now 'ByVal' and Tag is a Long pointer +! [Carsten Klein] changed function declaration of FreeImage_GetMetadata(): parameter Tag is a Long pointer now +! [Carsten Klein] changed function declaration of FreeImage_SetMetadata(): parameter Tag is a Long pointer now ++ [Carsten Klein] added function declarations for tag creation and destruction: ++ added declaration for function FreeImage_CreateTag() ++ added declaration for procedure FreeImage_DeleteTag() ++ added declaration for function FreeImage_CloneTag() ++ [Carsten Klein] added new items to structure FREE_IMAGE_TAG: ++ added item 'Model As FREE_IMAGE_MDMODEL' ++ added item 'TagPtr As Long' ++ [Carsten Klein] added wrapper functions for more VB friendly Tag access: these functions deal with a FREE_IMAGE_TAG structure instead of FreeImage's Tag pointer. ++ added function FreeImage_FindFirstMetadataEx() ++ added function FreeImage_FindNextMetadataEx() ++ added function FreeImage_GetAllMetadataTags() ++ added function FreeImage_GetMetadataEx() +* [Carsten Klein] fixed and adjusted page numbers of the API documentation in header comments in FreeImage function declarations +- [Carsten Klein] removed workaround for thresholding and dithering non-MINISBLACK 8 bit images in function FreeImage_ConvertColorDepth(): was fixed in FreeImage 3.9.0 +* [Carsten Klein] fixed all pending issues in function FreeImage_PaintDC(): is now in production state + +June 14, 2006 - 1.5.2 (3.9.0) +! [Carsten Klein] changed signature of function FreeImage_CreateMask() ++ [Carsten Klein] added function FreeImage_CreateMaskImage(): this creates a monochrome mask from a source image ++ [Carsten Klein] added function FreeImage_CreateMaskInPlace(): this creates a monochrome mask from a source image ++ [Carsten Klein] added enumeration FREE_IMAGE_ICON_TRANSPARENCY_OPTION_FLAGS ++ [Carsten Klein] added wrapper function FreeImage_CreateSimpleBWMaskImage(): wrapper for FreeImage_CreateMaskImage() with reduced number of parameters; creates a b/w mask ++ [Carsten Klein] added wrapper function FreeImage_CreateSimpleBWMaskInPlace(): wrapper for FreeImage_CreateMaskInPlace() with reduced number of parameters; creates a b/w mask ++ [Carsten Klein] added function declaration for FreeImage_MakeThumbnail() ++ [Carsten Klein] added function for FreeImage_GetOlePictureThumbnail() ++ [Carsten Klein] added function for FreeImage_MakeThumbnailIOP() ++ [Carsten Klein] documented function FreeImage_ReadMemoryEx() ++ [Carsten Klein] documented function FreeImage_WriteMemoryEx() +! [Carsten Klein] divided FreeImage_TagFromPointer into an interface only function with a private helper function pGetTagFromTagPtr(): ++ added helper function pGetTagFromTagPtr() +! [Carsten Klein] added private helper functions to leverage the FIDT_RATIONAL and FIDT_SRATIONAL data type: ++ added helper function pNormalizeRational() ++ added helper function pNormalizeSRational() ++ added helper function gcd() ++ added helper function floor() +! [Carsten Klein] changed name of structure 'FITAG_int' to 'FITAG': is now as in FreeImage library +! [Carsten Klein] changed name of structure 'FITAG' to 'FREE_IMAGE_TAG': this new structure plays an important role in the wrapper's new VB friendly tag accessing concept +! [Carsten Klein] changed function declaration of FreeImage_GetMetadataCount(): parameter 'model' is now 'ByVal' +! [Carsten Klein] changed function declaration of FreeImage_TagToString(): parameter 'model' is now 'ByVal' and function returns a Long +! [Carsten Klein] renamed function declaration of FreeImage_TagToString() to FreeImage_TagToStringInt(): function is now Private and wrapped by a VB String returning function ++ [Carsten Klein] added wrapper function FreeImage_TagToString() returning a real VB String ++ [Carsten Klein] added structure FIRATIONAL: structure to hold an image tag's rational value ++ [Carsten Klein] added new items to structure FREE_IMAGE_TAG: ++ added item 'StringValue As String' ++ added item 'Palette() As RGBQUAD' ++ added item 'RationalValue() As FIRATIONAL' + +June 13, 2006 - 1.5.1 (3.9.0) +! [Carsten Klein] changed version constant 'FREEIMAGE_MINOR_VERSION' to 9 to meet version 3.9.0 +* [Carsten Klein] fixed and adjusted page numbers of the API documentation in header comments in FreeImage function declarations to match FreeImage 3.9.0 API documentation ++ [Carsten Klein] added function declaration for new Memory I/O functions in 3.9.0 ++ added declaration FreeImage_ReadMemory() ++ added declaration FreeImage_WriteMemory() +! [Carsten Klein] changed/added optional parameter 'element_size' to private function pGetMemoryBlockPtrFromVariant(): caller now can get size in bytes one array element ++ [Carsten Klein] added wrapper functions for new Memory I/O functions in 3.9.0 ++ added function FreeImage_ReadMemoryEx() ++ added function FreeImage_WriteMemoryEx() ++ [Carsten Klein] added constants and updated enumerations for new 3.9.0 file formats 'FAXG3' and 'SGI' ++ [Carsten Klein] added Windows GDI icon related declarations: ++ added function declaration for CreateIconIndirect() ++ added function declaration for DestroyIcon() ++ added structure ICONINFO ++ [Carsten Klein] added function FreeImage_GetIcon(): returns a hIcon handle ++ [Carsten Klein] added function FreeImage_GetOlePictureIcon(): returns a VB Picture object of type vbPicTypeIcon ++ [Carsten Klein] added enumeration FREE_IMAGE_MASK_FLAGS ++ [Carsten Klein] added function FreeImage_CreateMaskColors(): returns an array filled with items from an argument list; synonym for VB's Array() function ++ [Carsten Klein] added enumeration FREE_IMAGE_teMask(): this creates a monochrome mask from a source image ++ [Carsten Klein] added function FreeImage_CreaMASK_CREATION_OPTION_FLAGS + +June 12, 2006 - 1.5 (3.8.0) +* [Carsten Klein] fixed bug in wrapper function FreeImage_PaintDCEx(): now handles boolean test correctly: 'If ((hDC <> 0) And (hDIB <> 0)) Then -> Thanks to ender_wiggin for reporting that bug. ++ [Carsten Klein] added private function pGetIOlePictureFromContainer(): used to get IPicture from image hosting control (Form, PictureBox) including custom drawings ++ [Carsten Klein] added wrapper function FreeImage_CreateFromImageContainer(): used to create FreeImage DIB from image hosting control (Form, PictureBox) including custom drawings ++ [Carsten Klein] added wrapper function SaveImageContainerEx(): derivate of wrapper function 'SavePictureEx()': saves content of image hosting control (Form, PictureBox) including custom drawings + +February 27, 2006 - 1.4.8 (3.8.0) ++ [Carsten Klein] added inline documentation for these wrapper functions: ++ documented function FreeImage_CompareColorsLongLong() ++ documented function FreeImage_CompareColorsRGBTRIPLELong() ++ documented function FreeImage_CompareColorsRGBQUADLong() ++ documented function FreeImage_SearchPalette() +! [Carsten Klein] changed and updated general remarks in section "General notes on implementation and design" +! [Carsten Klein] changed all function declarations of FreeImage functions that return a BOOL in C/C++: see "Functions returning Booleans" in section "General notes on implementation and design" +! [Carsten Klein] changed all function signatures of functions that are derived from or extend FreeImage BOOL functions: see "Functions returning Booleans" in section "General notes on implementation and design" ++ [Carsten Klein] added wrapper functions for all FreeImage functions that return a BOOL in C/C++: see "Functions returning Booleans" in section "General notes on implementation and design" ++ [Carsten Klein] added wrapper function FreeImage_CreateFromDC(): creates an DIB from a DC. Thanks to Evan (wxforecaster) for this suggestion. ++ [Carsten Klein] added declaration of GDI function GetCurrentObject() and constant OBJ_BITMAP ++ [Carsten Klein] added wrapper function FreeImage_IsAvailable(): used to test for existence of FreeImage Library (FreeImage.dll) + +February 9, 2006 - 1.4.7 (3.8.0) ++ [Carsten Klein] added private helper function pGetPreviousColorDepth() ++ [Carsten Klein] added private helper function pGetNextColorDepth() +! [Carsten Klein] changed/extended signature of wrapper function SavePictureEx(): now includes a parameter 'ColorDepth' ++ [Carsten Klein] added enumeration FREE_IMAGE_COLOR_DEPTH ++ [Carsten Klein] added error handling capabilities to wrapper function SavePictureEx() ++ [Carsten Klein] added/updated inline documentation of wrapper function SavePictureEx() + +October 31, 2005 - 1.4.6 (3.8.0) ++ [Carsten Klein] added wrapper function FreeImage_SwapColorLong(): this converts from a RGB to a BGR color value stored in a Long and vice versa + +October 27, 2005 - 1.4.5 (3.8.0) ++ [Carsten Klein] added function FreeImage_IsTransparencyTableTransparent(): checks for transparency directly on the transparency table + +October 13, 2005 - 1.4.4 (3.8.0) ++ [Carsten Klein] added some functions to compare colors in different formats and with tolerance: ++ added function FreeImage_CompareColorsLongLong() ++ added function FreeImage_CompareColorsRGBTRIPLELong() ++ added function FreeImage_CompareColorsRGBQUADLong() ++ [Carsten Klein] added enumeration FREE_IMAGE_COLOR_FORMAT_FLAGS ++ [Carsten Klein] added enumeration FREE_IMAGE_TRANSPARENCY_STATE_FLAGS ++ [Carsten Klein] added function FreeImage_SearchPalette(): to search the palette index for a given color + +October 13, 2005 - 1.4.3 (3.8.0) ++ [Carsten Klein] added additional function declaration FreeImage_SetPixelColorByLong(): now color values may be provided in a long value ++ [Carsten Klein] added additional function declaration FreeImage_GetPixelColorByLong(): now color values may be received in a long value ++ [Carsten Klein] added function FreeImage_SetPixelColorEx(): color values may be provided by four different byte values ++ [Carsten Klein] added function FreeImage_GetPixelColorEx(): color values are returned through four different byte values + +October 11, 2005 - 1.4.2 (3.8.0) +* [Carsten Klein] fixed bug in wrapper function FreeImage_GetBitsExRGBQUAD(): now tests for and works with 32 bit images + +October 10, 2005 - 1.4.1 (3.8.0) +* [Carsten Klein] fixed serious bug in FreeImage_GetBitsEx...() functions: created custom array descriptor now really has two dimensions +* fixed wrapper function FreeImage_GetBitsEx() +* fixed wrapper function FreeImage_GetBitsExRGBTRIPLE() +* fixed wrapper function FreeImage_GetBitsExRGBQUAD() + +September 9, 2005 - 1.4 (3.8.0) +! [Carsten Klein] changed wrapper function FreeImage_ConvertColorDepth(): now uses FreeImage_ConvertToGreyscale ++ [Carsten Klein] added version numbers to change log ++ [Carsten Klein] added comments to IOlePicture aware toolkit and conversion functions +* [Carsten Klein] fixed and adjusted page numbers of the API documentation in header comments in FreeImage function declarations + +September 8, 2005 - 1.3.5 +! [Carsten Klein] changed version constant 'FREEIMAGE_MINOR_VERSION' to 8 to meet version 3.8.0 ++ [Carsten Klein] added function declarations for UNICODE dealing functions with additional token 'Int' appended: ++ added function FreeImage_LoadUInt() ++ added function FreeImage_SaveUInt() ++ added function FreeImage_GetFileTypeUInt() ++ added function FreeImage_GetFIFFromFilenameUInt() ++ [Carsten Klein] added wrapper functions to ease the use of UNICODE dealing functions: ++ added function FreeImage_LoadU() ++ added function FreeImage_SaveU() ++ added function FreeImage_GetFileTypeU() ++ added function FreeImage_GetFIFFromFilenameU() ++ [Carsten Klein] added function declaration for FreeImage_ConvertToGreyscale() + +July 18, 2005 - 1.3.4 +! [Carsten Klein] changed inline comments in these wrapper functions: +! changed FreeImage_GetBitsEx(): mixed up width and height in SAFEAARAY creation +! changed FreeImage_GetBitsExRGBTRIPLE(): mixed up width and height in SAFEAARAY creation +! changed FreeImage_GetBitsExRGBQUAD(): mixed up width and height in SAFEAARAY creation ++ [Carsten Klein] added wrapper function FreeImage_GetScanLinesRGBTRIPLE(): + +June 30, 2005 - 1.3.3 ++ [Carsten Klein] added Kernel32 function FillMemory() + +June 24, 2005 - 1.3.2 ++ [Carsten Klein] added pixel access functions FreeImage_GetBitsExRGBTRIPLE() and FreeImage_GetBitsExRGBQUAD() ++ [Carsten Klein] added IOlePicture based wrapper function FreeImage_ConvertColorDepthIOP() ++ [Carsten Klein] added IOlePicture based wrapper functions for FreeImage_RescaleIOP(): ++ added function FreeImage_FreeImage_RescaleByPixelIOP() ++ added function FreeImage_FreeImage_RescaleByPercentIOP() ++ added function FreeImage_FreeImage_RescaleByFactorIOP() ++ [Carsten Klein] added IOlePicture based wrapper function FreeImage_RescaleIOP() +* [Carsten Klein] fixed a bug in FreeImage_GetOlePicture(): now OlePictures returned through IPicture may be used directly by other functions accepting IPicture types without any assignment to IPictureDisp + +June 24, 2005 - 1.3.1 +! [Carsten Klein] changed inproper function declaration of function FreeImage_AdjustCurve(): now parameter 'LUT' is passed ByVal ++ [Carsten Klein] added wrapper function FreeImage_AdjustCurveEx() ++ [Carsten Klein] added IOlePicture based wrapper functions for FreeImage toolkit functions: ++ added function FreeImage_RotateClassicIOP() ++ added function FreeImage_RotateExIOP() ++ added function FreeImage_FlipHorizontalIOP() ++ added function FreeImage_FlipVerticalIOP() ++ added function FreeImage_AdjustCurveIOP() ++ added function FreeImage_AdjustGammaIOP() ++ added function FreeImage_AdjustBrightnessIOP() ++ added function FreeImage_AdjustContrastIOP() ++ added function FreeImage_InvertIOP() ++ added function FreeImage_GetChannelIOP() ++ added function FreeImage_CopyIOP() ++ added function FreeImage_PasteIOP() + +June 22, 2005 - 1.3 ++ [Carsten Klein] added inline comments and documentation for pixel access functions + +June 18, 2005 - 1.2.9 ++ [Carsten Klein] added function FreeImage_GetBitsEx() ++ [Carsten Klein] added structure SAFEARRAY2D to create 2 dimensional custom arrays ++ [Carsten Klein] added function declarations for converting scanlines to 4 bpp: ++ added declaration for FreeImage_ConvertLine1To4() ++ added declaration for FreeImage_ConvertLine8To4() ++ added declaration for FreeImage_ConvertLine16To4_555() ++ added declaration for FreeImage_ConvertLine16To4_565() ++ added declaration for FreeImage_ConvertLine24To4() ++ added declaration for FreeImage_ConvertLine32To4() + +June 16, 2005 - 1.2.8 +! [Carsten Klein] changed inproper function declaration for all functions FreeImage_ConvertLineXXXX(): now parameters 'target' and 'Source' are passed ByVal + +June 15, 2005 - 1.2.7 ++ [Carsten Klein] added function FreeImage_DestroyLockedArrayByPtr() to destroy a locked array by it's pointer (VB can't pass a array of structures through a Variant type) ++ [Carsten Klein] added some wrapper functions for FreeImage_DestroyLockedArrayByPtr() for common FreeImage structures: ++ added function FreeImage_DestroyLockedArrayRGBTRIPLE() ++ added function FreeImage_DestroyLockedArrayRGBQUAD() ++ added function FreeImage_DestroyLockedArrayFICOMPLEX() ++ added function FreeImage_DestroyLockedArrayFIRGB16() ++ added function FreeImage_DestroyLockedArrayFIRGBA16() ++ added function FreeImage_DestroyLockedArrayFIRGBF() ++ added function FreeImage_DestroyLockedArrayFIRGBAF() ++ [Carsten Klein] added functions to return scanlines as VB style arrays in all supported FreeImage formats: ++ added function FreeImage_GetScanLineBITMAP8() ++ added function FreeImage_GetScanLineBITMAP16() ++ added function FreeImage_GetScanLineBITMAP24() ++ added function FreeImage_GetScanLineBITMAP32() ++ added function FreeImage_GetScanLineINT16() ++ added function FreeImage_GetScanLineINT32() ++ added function FreeImage_GetScanLineFLOAT() ++ added function FreeImage_GetScanLineDOUBLE() ++ added function FreeImage_GetScanLineCOMPLEX() ++ added function FreeImage_GetScanLineRGB16() ++ added function FreeImage_GetScanLineRGBA16() ++ added function FreeImage_GetScanLineRGBF() ++ added function FreeImage_GetScanLineRGBAF() + +June 14, 2005 - 1.2.6 +! [Carsten Klein] updated documentation on array-dealing functions using arrays with custom array descriptors ++ [Carsten Klein] added function FreeImage_DestroyLockedArray() to destroy a self created array 'FADF_AUTO Or FADF_FIXEDSIZE' array ++ [Carsten Klein] added function FreeImage_GetPaletteExLong() to return palette data in an array of type Long ++ [Carsten Klein] added parameters 'lPaletteSize', 'vntReservePalette' and 'lReserveSize' to FreeImage_ConvertColorDepth() + +June 13, 2005 - 1.2.5 +* [Carsten Klein] fixed a bug in helper function pGetMemoryBlockPtrFromVariant(): now 'size_in_bytes' will never exceed the size of an array provided + +June 12, 2005 - 1.2.4 ++ [Carsten Klein] added ZLib compression function wrappers dealing with VB style arrays: ++ added function FreeImage_ZLibCompressVB() ++ added function FreeImage_ZLibUncompressVB() ++ added function FreeImage_ZLibGZipVB() ++ added function FreeImage_ZLibGUnzipVB() + +June 10, 2005 - 1.2.3 ++ [Carsten Klein] added ZLib compression function wrappers dealing with VB style arrays: ++ added function FreeImage_ZLibCompressEx() ++ added function FreeImage_ZLibUncompressEx() ++ added function FreeImage_ZLibGZipEx() ++ added function FreeImage_ZLibCRC32Ex() ++ added function FreeImage_ZLibGUnzipEx() ++ [Carsten Klein] added more VB friendly ZLib compression function wrappers: ++ added function FreeImage_ZLibCompressVB() ++ added function FreeImage_ZLibUncompressVB() ++ added function FreeImage_ZLibGZipVB() ++ added function FreeImage_ZLibGUnzipVB() +! [Carsten Klein] fixed wrong function declaration of functions FreeImage_ZLibGUnzip(): alias was '_FreeImage_ZLibZlibGUnzip@16' (double ZLib) +! [Carsten Klein] fixed function pGetArrayPtrFromVariantArray() that now can deal with uninitialized arrays +! fixed function pGetMemoryBlockPtrFromVariant() that now can deal with uninitialized arrays +! [Carsten Klein] fixed wrong function declaration of functions FreeImage_AdjustBrightness(): ...@8 -> ...@12 +! fixed wrong function declaration of functions FreeImage_AdjustContrast(): ...@8 -> ...@12 +! fixed wrong function declaration of functions FreeImage_AdjustGamma(): ...@8 -> ...@12 +! fixed wrong function declaration of functions FreeImage_RotateClassic(): ...@8 -> ...@12 +! fixed wrong function declaration of functions FreeImage_RotateEx(): ...@28 -> ...@48 + +June 9, 2005 - 1.2.2 +! [Carsten Klein] fixed wrong function declaration of function FreeImage_OpenMultiBitmap(): added parameter 'flags' (...@20 -> ...@24) + +June 8, 2005 - 1.2.1 +! [Carsten Klein] refactored function FreeImage_LoadFromMemoryEx(): now using pGetMemoryBlockPtrFromVariant() ++ [Carsten Klein] added private function pGetMemoryBlockPtrFromVariant() to get poiner and size of a memory block from a Variant parameter +! [Carsten Klein] changed declaration of ZLib related functions: 'target' and 'Source' are now 'ByVal Long' + +June 7, 2005 - 1.2 ++ [Carsten Klein] added some more inline comments and documentation ++ [Carsten Klein] added optional parameter 'bUnloadSource' to function FreeImage_SaveToMemoryEx() ++ added optional parameter 'bUnloadSource' to function FreeImage_SaveToMemoryEx2() ++ [Carsten Klein] added optional parameter 'InPercent' to function SavePictureEx() +! implemented the capability to resize the image on saving in function SavePictureEx() ++ [Carsten Klein] added parameters 'InPercent' and 'Format' to function LoadPictureEx() +* [Carsten Klein] fixed wrong function declaration of function FreeImage_JPEGTransform() (...@12 -> ...@16) + +June 6, 2005 - 1.1.2 ++ [Carsten Klein] added some more inline comments and documentation + +May 30, 2005 - 1.1.1 +* [Carsten Klein] fixed percent calculating bug in function FreeImage_RescaleEx() +! changed behaviour of parameter 'bIsPercentValue' -> it now has no effect on integer values ++ added function FreeImage_RescaleByPixel() to avoid confusion with overloading ++ added function FreeImage_RescaleByPercent() to avoid confusion with overloading ++ added function FreeImage_RescaleByFactor() to avoid confusion with overloading +! [Carsten Klein] changed name of parameter 'bUnloadDIB' to 'bUnloadSource' of function FreeImage_GetOlePicture() ++ [Carsten Klein] added some more inline comments and documentation +* [Carsten Klein] fixed a potential runtime error in function FreeImage_SetTransparencyTableEx(): 'Count' will no longer exceed 256 + +May 24, 2005 - 1.1 ++ [Carsten Klein] added a new VB wrapper diff --git a/#ThirdParty/FreeImage/Wrapper/VB6/test/SimpleTest.frm b/#ThirdParty/FreeImage/Wrapper/VB6/test/SimpleTest.frm new file mode 100644 index 0000000..1847542 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/VB6/test/SimpleTest.frm @@ -0,0 +1,45 @@ +VERSION 5.00 +Begin VB.Form SimpleTest + Caption = "SimpleTest" + ClientHeight = 1035 + ClientLeft = 60 + ClientTop = 345 + ClientWidth = 2325 + LinkTopic = "Form1" + ScaleHeight = 1035 + ScaleWidth = 2325 + StartUpPosition = 3 'Windows Default + Begin VB.CommandButton btnTest + Caption = "Test" + Height = 495 + Left = 240 + TabIndex = 0 + Top = 240 + Width = 1575 + End +End +Attribute VB_Name = "SimpleTest" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = False +Option Explicit +' NOTE : +' To run this test program, you will have to copy the FreeImage.dll file +' in this directory. +' Change also the "test.tif" file name with a path to any tif file on your +' hard disk +' +Private Sub btnTest_Click() + Dim dib As Long + Dim bOK As Long + ' Load a tif image + dib = FreeImage_Load(FIF_TIFF, "test.tif", 0) + + ' Save this image as PNG + bOK = FreeImage_Save(FIF_PNG, dib, "test.png", 0) + + ' Unload the dib + FreeImage_Unload (dib) + +End Sub diff --git a/#ThirdParty/FreeImage/Wrapper/VB6/test/SimpleTest.vbp b/#ThirdParty/FreeImage/Wrapper/VB6/test/SimpleTest.vbp new file mode 100644 index 0000000..8ee5610 --- /dev/null +++ b/#ThirdParty/FreeImage/Wrapper/VB6/test/SimpleTest.vbp @@ -0,0 +1,38 @@ +Type=Exe +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\WINNT\system32\stdole2.tlb#OLE Automation +Form=SimpleTest.frm +Module=FreeImage; ..\modFreeImage.bas +IconForm="SimpleTest" +Startup="SimpleTest" +HelpFile="" +Title="SimpleTest" +ExeName32="SimpleTest.exe" +Command32="" +Name="TestFreeImage" +HelpContextID="0" +CompatibleMode="0" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +VersionCompanyName="HDN" +CompilationType=0 +OptimizationType=0 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=0 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=0 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 +DebugStartupOption=0 + +[MS Transaction Server] +AutoRefresh=1 diff --git a/freeimage241/license-fi.txt b/#ThirdParty/FreeImage/license-fi.txt similarity index 99% rename from freeimage241/license-fi.txt rename to #ThirdParty/FreeImage/license-fi.txt index 479fb4d..03b666c 100644 --- a/freeimage241/license-fi.txt +++ b/#ThirdParty/FreeImage/license-fi.txt @@ -1,142 +1,142 @@ -FreeImage Public License - Version 1.0 ---------------------------------------------- - -1. Definitions. - -1.1. "Contributor" means each entity that creates or contributes to the creation of Modifications. - -1.2. "Contributor Version" means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. - -1.3. "Covered Code" means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. - -1.4. "Electronic Distribution Mechanism" means a mechanism generally accepted in the software development community for the electronic transfer of data. - -1.5. "Executable" means Covered Code in any form other than Source Code. - -1.6. "Initial Developer" means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. - -1.7. "Larger Work" means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. - -1.8. "License" means this document. - -1.9. "Modifications" means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a -Modification is: - -A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. - -B. Any new file that contains any part of the Original Code or previous Modifications. - -1.10. "Original Code" means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. - -1.11. "Source Code" means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control -compilation and installation of an Executable, or a list of source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. - -1.12. "You" means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the -direction or management of such entity, whether by contract or otherwise, or (b) ownership of fifty percent (50%) or more of the outstanding shares or beneficial ownership of such entity. - -2. Source Code License. - -2.1. The Initial Developer Grant. -The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: - -(a) to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, or as part of a Larger Work; and - -(b) under patents now or hereafter owned or controlled by Initial Developer, to make, have made, use and sell ("Utilize") the Original Code (or portions thereof), but solely to the extent that -any such patent is reasonably necessary to enable You to Utilize the Original Code (or portions thereof) and not to any greater extent that may be necessary to Utilize further Modifications or -combinations. - -2.2. Contributor Grant. -Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: - -(a) to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code or as part of a Larger Work; and - -(b) under patents now or hereafter owned or controlled by Contributor, to Utilize the Contributor Version (or portions thereof), but solely to the extent that any such patent is reasonably necessary to enable You to Utilize the Contributor Version (or portions thereof), and not to any greater extent that -may be necessary to Utilize further Modifications or combinations. - -3. Distribution Obligations. - -3.1. Application of License. -The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or -restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. - -3.2. Availability of Source Code. -Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. - -3.3. Description of Modifications. -You must cause all Covered Code to which you contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. - -3.4. Intellectual Property Matters - -(a) Third Party Claims. -If You have knowledge that a party claims an intellectual property right in particular functionality or code (or its utilization under this License), you must include a text file with the source code distribution titled "LEGAL" which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If you obtain such knowledge after You make Your Modification available as described in Section 3.2, You shall promptly modify the LEGAL file in all copies You make -available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. - -(b) Contributor APIs. -If Your Modification is an application programming interface and You own or control patents which are reasonably necessary to implement that API, you must also include this information in the LEGAL file. - -3.5. Required Notices. -You must duplicate the notice in Exhibit A in each file of the Source Code, and this License in any documentation for the Source Code, where You describe recipients' rights relating to Covered Code. If You created one or more Modification(s), You may add your name as a Contributor to the notice described in Exhibit A. If it is not possible to put such notice in a particular Source Code file due to its -structure, then you must include such notice in a location (such as a relevant directory file) where a user would be likely to look for such a notice. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or -liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of -warranty, support, indemnity or liability terms You offer. - -3.6. Distribution of Executable Versions. -You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You -describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code under a license of Your choice, which may contain terms different from this License, -provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. - -3.7. Larger Works. -You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. - -4. Inability to Comply Due to Statute or Regulation. - -If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. - -5. Application of this License. - -This License applies to code to which the Initial Developer has attached the notice in Exhibit A, and to related Covered Code. - -6. Versions of the License. - -6.1. New Versions. -Floris van den Berg may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. - -6.2. Effect of New Versions. -Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Floris van den Berg -No one other than Floris van den Berg has the right to modify the terms applicable to Covered Code created under this License. - -6.3. Derivative Works. -If you create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), you must (a) rename Your license so that the phrases "FreeImage", `FreeImage Public License", "FIPL", or any confusingly similar phrase do not appear anywhere in your license and (b) otherwise make it clear that your version of the license contains terms which differ from the FreeImage Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) - -7. DISCLAIMER OF WARRANTY. - -COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. - -8. TERMINATION. - -This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. - -9. LIMITATION OF LIABILITY. - -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE -EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. - -10. U.S. GOVERNMENT END USERS. - -The Covered Code is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. - -11. MISCELLANEOUS. - -This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by Dutch law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in, the The Netherlands: (a) unless otherwise agreed in writing, all disputes relating to this License (excepting any dispute relating to intellectual property rights) shall be subject to final and binding arbitration, with the losing party paying all costs of arbitration; (b) any arbitration relating to this Agreement shall be held in Almelo, The Netherlands; and (c) any litigation relating to this Agreement shall be subject to the jurisdiction of the court of Almelo, The Netherlands with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys fees and expenses. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. - -12. RESPONSIBILITY FOR CLAIMS. - -Except in cases where another Contributor has failed to comply with Section 3.4, You are responsible for damages arising, directly or indirectly, out of Your utilization of rights under this License, based -on the number of copies of Covered Code you made available, the revenues you received from utilizing such rights, and other relevant factors. You agree to work with affected parties to distribute -responsibility on an equitable basis. - -EXHIBIT A. - -"The contents of this file are subject to the FreeImage Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://home.wxs.nl/~flvdberg/freeimage-license.txt - +FreeImage Public License - Version 1.0 +--------------------------------------------- + +1. Definitions. + +1.1. "Contributor" means each entity that creates or contributes to the creation of Modifications. + +1.2. "Contributor Version" means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. + +1.3. "Covered Code" means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. + +1.4. "Electronic Distribution Mechanism" means a mechanism generally accepted in the software development community for the electronic transfer of data. + +1.5. "Executable" means Covered Code in any form other than Source Code. + +1.6. "Initial Developer" means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. + +1.7. "Larger Work" means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. + +1.8. "License" means this document. + +1.9. "Modifications" means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a +Modification is: + +A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. + +B. Any new file that contains any part of the Original Code or previous Modifications. + +1.10. "Original Code" means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. + +1.11. "Source Code" means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control +compilation and installation of an Executable, or a list of source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. + +1.12. "You" means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or otherwise, or (b) ownership of fifty percent (50%) or more of the outstanding shares or beneficial ownership of such entity. + +2. Source Code License. + +2.1. The Initial Developer Grant. +The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: + +(a) to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, or as part of a Larger Work; and + +(b) under patents now or hereafter owned or controlled by Initial Developer, to make, have made, use and sell ("Utilize") the Original Code (or portions thereof), but solely to the extent that +any such patent is reasonably necessary to enable You to Utilize the Original Code (or portions thereof) and not to any greater extent that may be necessary to Utilize further Modifications or +combinations. + +2.2. Contributor Grant. +Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: + +(a) to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code or as part of a Larger Work; and + +(b) under patents now or hereafter owned or controlled by Contributor, to Utilize the Contributor Version (or portions thereof), but solely to the extent that any such patent is reasonably necessary to enable You to Utilize the Contributor Version (or portions thereof), and not to any greater extent that +may be necessary to Utilize further Modifications or combinations. + +3. Distribution Obligations. + +3.1. Application of License. +The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or +restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. + +3.2. Availability of Source Code. +Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. + +3.3. Description of Modifications. +You must cause all Covered Code to which you contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. + +3.4. Intellectual Property Matters + +(a) Third Party Claims. +If You have knowledge that a party claims an intellectual property right in particular functionality or code (or its utilization under this License), you must include a text file with the source code distribution titled "LEGAL" which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If you obtain such knowledge after You make Your Modification available as described in Section 3.2, You shall promptly modify the LEGAL file in all copies You make +available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. + +(b) Contributor APIs. +If Your Modification is an application programming interface and You own or control patents which are reasonably necessary to implement that API, you must also include this information in the LEGAL file. + +3.5. Required Notices. +You must duplicate the notice in Exhibit A in each file of the Source Code, and this License in any documentation for the Source Code, where You describe recipients' rights relating to Covered Code. If You created one or more Modification(s), You may add your name as a Contributor to the notice described in Exhibit A. If it is not possible to put such notice in a particular Source Code file due to its +structure, then you must include such notice in a location (such as a relevant directory file) where a user would be likely to look for such a notice. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or +liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of +warranty, support, indemnity or liability terms You offer. + +3.6. Distribution of Executable Versions. +You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You +describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code under a license of Your choice, which may contain terms different from this License, +provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. + +3.7. Larger Works. +You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + +If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. + +5. Application of this License. + +This License applies to code to which the Initial Developer has attached the notice in Exhibit A, and to related Covered Code. + +6. Versions of the License. + +6.1. New Versions. +Floris van den Berg may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. + +6.2. Effect of New Versions. +Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Floris van den Berg +No one other than Floris van den Berg has the right to modify the terms applicable to Covered Code created under this License. + +6.3. Derivative Works. +If you create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), you must (a) rename Your license so that the phrases "FreeImage", `FreeImage Public License", "FIPL", or any confusingly similar phrase do not appear anywhere in your license and (b) otherwise make it clear that your version of the license contains terms which differ from the FreeImage Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) + +7. DISCLAIMER OF WARRANTY. + +COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +8. TERMINATION. + +This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. + +9. LIMITATION OF LIABILITY. + +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + +The Covered Code is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. + +11. MISCELLANEOUS. + +This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by Dutch law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in, the The Netherlands: (a) unless otherwise agreed in writing, all disputes relating to this License (excepting any dispute relating to intellectual property rights) shall be subject to final and binding arbitration, with the losing party paying all costs of arbitration; (b) any arbitration relating to this Agreement shall be held in Almelo, The Netherlands; and (c) any litigation relating to this Agreement shall be subject to the jurisdiction of the court of Almelo, The Netherlands with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys fees and expenses. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. + +12. RESPONSIBILITY FOR CLAIMS. + +Except in cases where another Contributor has failed to comply with Section 3.4, You are responsible for damages arising, directly or indirectly, out of Your utilization of rights under this License, based +on the number of copies of Covered Code you made available, the revenues you received from utilizing such rights, and other relevant factors. You agree to work with affected parties to distribute +responsibility on an equitable basis. + +EXHIBIT A. + +"The contents of this file are subject to the FreeImage Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://home.wxs.nl/~flvdberg/freeimage-license.txt + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. \ No newline at end of file diff --git a/#ThirdParty/FreeImage/license-gplv2.txt b/#ThirdParty/FreeImage/license-gplv2.txt new file mode 100644 index 0000000..6020906 --- /dev/null +++ b/#ThirdParty/FreeImage/license-gplv2.txt @@ -0,0 +1,126 @@ +GNU General Public License, version 2 (GPL-2.0) +[OSI Approved License] +The GNU General Public License (GPL-2.0) +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + Copyright (C) + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + + signature of Ty Coon, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. diff --git a/#ThirdParty/FreeImage/license-gplv3.txt b/#ThirdParty/FreeImage/license-gplv3.txt new file mode 100644 index 0000000..5ec7b1a --- /dev/null +++ b/#ThirdParty/FreeImage/license-gplv3.txt @@ -0,0 +1,228 @@ +GNU General Public License, version 3 (GPL-3.0) +[OSI Approved License] +GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. +Preamble + +The GNU General Public License is a free, copyleft license for software and other kinds of works. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. +TERMS AND CONDITIONS +0. Definitions. + +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on the Program. + +To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. +1. Source Code. + +The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. + +A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. +2. Basic Permissions. + +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. +3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. +4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. +5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. +6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. +7. Additional Terms. + +“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. +8. Termination. + +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. +9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. +10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. +11. Patents. + +A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. +12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. +13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. +14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. +15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: + + Copyright (C) + + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . + +The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . diff --git a/#ThirdParty/ddraw.lib b/#ThirdParty/ddraw.lib new file mode 100644 index 0000000..be1c984 Binary files /dev/null and b/#ThirdParty/ddraw.lib differ diff --git a/#ThirdParty/dsound.lib b/#ThirdParty/dsound.lib new file mode 100644 index 0000000..e20009b Binary files /dev/null and b/#ThirdParty/dsound.lib differ diff --git a/#ThirdParty/dxguid.lib b/#ThirdParty/dxguid.lib new file mode 100644 index 0000000..3e7727e Binary files /dev/null and b/#ThirdParty/dxguid.lib differ diff --git a/fmodapi375win/README.TXT b/#ThirdParty/fmodapi375win/README.TXT similarity index 100% rename from fmodapi375win/README.TXT rename to #ThirdParty/fmodapi375win/README.TXT diff --git a/fmodapi375win/api/delphi/fmod.dcu b/#ThirdParty/fmodapi375win/api/delphi/fmod.dcu similarity index 100% rename from fmodapi375win/api/delphi/fmod.dcu rename to #ThirdParty/fmodapi375win/api/delphi/fmod.dcu diff --git a/fmodapi375win/api/delphi/fmod.pas b/#ThirdParty/fmodapi375win/api/delphi/fmod.pas similarity index 100% rename from fmodapi375win/api/delphi/fmod.pas rename to #ThirdParty/fmodapi375win/api/delphi/fmod.pas diff --git a/fmodapi375win/api/delphi/fmoddyn.pas b/#ThirdParty/fmodapi375win/api/delphi/fmoddyn.pas similarity index 100% rename from fmodapi375win/api/delphi/fmoddyn.pas rename to #ThirdParty/fmodapi375win/api/delphi/fmoddyn.pas diff --git a/fmodapi375win/api/delphi/fmoderrors.dcu b/#ThirdParty/fmodapi375win/api/delphi/fmoderrors.dcu similarity index 100% rename from fmodapi375win/api/delphi/fmoderrors.dcu rename to #ThirdParty/fmodapi375win/api/delphi/fmoderrors.dcu diff --git a/fmodapi375win/api/delphi/fmoderrors.pas b/#ThirdParty/fmodapi375win/api/delphi/fmoderrors.pas similarity index 100% rename from fmodapi375win/api/delphi/fmoderrors.pas rename to #ThirdParty/fmodapi375win/api/delphi/fmoderrors.pas diff --git a/fmodapi375win/api/delphi/fmodpresets.pas b/#ThirdParty/fmodapi375win/api/delphi/fmodpresets.pas similarity index 100% rename from fmodapi375win/api/delphi/fmodpresets.pas rename to #ThirdParty/fmodapi375win/api/delphi/fmodpresets.pas diff --git a/fmodapi375win/api/delphi/fmodtypes.dcu b/#ThirdParty/fmodapi375win/api/delphi/fmodtypes.dcu similarity index 100% rename from fmodapi375win/api/delphi/fmodtypes.dcu rename to #ThirdParty/fmodapi375win/api/delphi/fmodtypes.dcu diff --git a/fmodapi375win/api/delphi/fmodtypes.pas b/#ThirdParty/fmodapi375win/api/delphi/fmodtypes.pas similarity index 100% rename from fmodapi375win/api/delphi/fmodtypes.pas rename to #ThirdParty/fmodapi375win/api/delphi/fmodtypes.pas diff --git a/#ThirdParty/fmodapi375win/api/fmod.dll b/#ThirdParty/fmodapi375win/api/fmod.dll new file mode 100644 index 0000000..6b0e379 Binary files /dev/null and b/#ThirdParty/fmodapi375win/api/fmod.dll differ diff --git a/fmodapi375win/api/fmod64.dll b/#ThirdParty/fmodapi375win/api/fmod64.dll similarity index 100% rename from fmodapi375win/api/fmod64.dll rename to #ThirdParty/fmodapi375win/api/fmod64.dll diff --git a/fmodapi375win/api/inc/fmod.h b/#ThirdParty/fmodapi375win/api/inc/fmod.h similarity index 100% rename from fmodapi375win/api/inc/fmod.h rename to #ThirdParty/fmodapi375win/api/inc/fmod.h diff --git a/fmodapi375win/api/inc/fmod_errors.h b/#ThirdParty/fmodapi375win/api/inc/fmod_errors.h similarity index 100% rename from fmodapi375win/api/inc/fmod_errors.h rename to #ThirdParty/fmodapi375win/api/inc/fmod_errors.h diff --git a/fmodapi375win/api/inc/fmoddyn.h b/#ThirdParty/fmodapi375win/api/inc/fmoddyn.h similarity index 100% rename from fmodapi375win/api/inc/fmoddyn.h rename to #ThirdParty/fmodapi375win/api/inc/fmoddyn.h diff --git a/fmodapi375win/api/inc/wincompat.h b/#ThirdParty/fmodapi375win/api/inc/wincompat.h similarity index 100% rename from fmodapi375win/api/inc/wincompat.h rename to #ThirdParty/fmodapi375win/api/inc/wincompat.h diff --git a/fmodapi375win/api/lib/fmod64vc.lib b/#ThirdParty/fmodapi375win/api/lib/fmod64vc.lib similarity index 100% rename from fmodapi375win/api/lib/fmod64vc.lib rename to #ThirdParty/fmodapi375win/api/lib/fmod64vc.lib diff --git a/fmodapi375win/api/lib/fmodbc.lib b/#ThirdParty/fmodapi375win/api/lib/fmodbc.lib similarity index 100% rename from fmodapi375win/api/lib/fmodbc.lib rename to #ThirdParty/fmodapi375win/api/lib/fmodbc.lib diff --git a/fmodapi375win/api/lib/fmodlcc.lib b/#ThirdParty/fmodapi375win/api/lib/fmodlcc.lib similarity index 100% rename from fmodapi375win/api/lib/fmodlcc.lib rename to #ThirdParty/fmodapi375win/api/lib/fmodlcc.lib diff --git a/fmodapi375win/api/lib/fmodvc.lib b/#ThirdParty/fmodapi375win/api/lib/fmodvc.lib similarity index 100% rename from fmodapi375win/api/lib/fmodvc.lib rename to #ThirdParty/fmodapi375win/api/lib/fmodvc.lib diff --git a/fmodapi375win/api/lib/fmodwc.lib b/#ThirdParty/fmodapi375win/api/lib/fmodwc.lib similarity index 100% rename from fmodapi375win/api/lib/fmodwc.lib rename to #ThirdParty/fmodapi375win/api/lib/fmodwc.lib diff --git a/fmodapi375win/api/lib/libfmod.a b/#ThirdParty/fmodapi375win/api/lib/libfmod.a similarity index 100% rename from fmodapi375win/api/lib/libfmod.a rename to #ThirdParty/fmodapi375win/api/lib/libfmod.a diff --git a/fmodapi375win/api/vb/fmod.bas b/#ThirdParty/fmodapi375win/api/vb/fmod.bas similarity index 100% rename from fmodapi375win/api/vb/fmod.bas rename to #ThirdParty/fmodapi375win/api/vb/fmod.bas diff --git a/fmodapi375win/documentation/FMOD.chm b/#ThirdParty/fmodapi375win/documentation/FMOD.chm similarity index 100% rename from fmodapi375win/documentation/FMOD.chm rename to #ThirdParty/fmodapi375win/documentation/FMOD.chm diff --git a/fmodapi375win/documentation/Revision.txt b/#ThirdParty/fmodapi375win/documentation/Revision.txt similarity index 100% rename from fmodapi375win/documentation/Revision.txt rename to #ThirdParty/fmodapi375win/documentation/Revision.txt diff --git a/fmodapi375win/media/canyon.mid b/#ThirdParty/fmodapi375win/media/canyon.mid similarity index 100% rename from fmodapi375win/media/canyon.mid rename to #ThirdParty/fmodapi375win/media/canyon.mid diff --git a/fmodapi375win/media/chimes.wav b/#ThirdParty/fmodapi375win/media/chimes.wav similarity index 100% rename from fmodapi375win/media/chimes.wav rename to #ThirdParty/fmodapi375win/media/chimes.wav diff --git a/fmodapi375win/media/drumloop.wav b/#ThirdParty/fmodapi375win/media/drumloop.wav similarity index 100% rename from fmodapi375win/media/drumloop.wav rename to #ThirdParty/fmodapi375win/media/drumloop.wav diff --git a/fmodapi375win/media/footsteps.fsb b/#ThirdParty/fmodapi375win/media/footsteps.fsb similarity index 100% rename from fmodapi375win/media/footsteps.fsb rename to #ThirdParty/fmodapi375win/media/footsteps.fsb diff --git a/fmodapi375win/media/invtro94.s3m b/#ThirdParty/fmodapi375win/media/invtro94.s3m similarity index 100% rename from fmodapi375win/media/invtro94.s3m rename to #ThirdParty/fmodapi375win/media/invtro94.s3m diff --git a/fmodapi375win/media/jaguar.wav b/#ThirdParty/fmodapi375win/media/jaguar.wav similarity index 100% rename from fmodapi375win/media/jaguar.wav rename to #ThirdParty/fmodapi375win/media/jaguar.wav diff --git a/fmodapi375win/media/jbtennis.wav b/#ThirdParty/fmodapi375win/media/jbtennis.wav similarity index 100% rename from fmodapi375win/media/jbtennis.wav rename to #ThirdParty/fmodapi375win/media/jbtennis.wav diff --git a/fmodapi375win/media/jules.mp3 b/#ThirdParty/fmodapi375win/media/jules.mp3 similarity index 100% rename from fmodapi375win/media/jules.mp3 rename to #ThirdParty/fmodapi375win/media/jules.mp3 diff --git a/fmodapi375win/samples/3d/3d.dsp b/#ThirdParty/fmodapi375win/samples/3d/3d.dsp similarity index 100% rename from fmodapi375win/samples/3d/3d.dsp rename to #ThirdParty/fmodapi375win/samples/3d/3d.dsp diff --git a/fmodapi375win/samples/3d/3d.exe b/#ThirdParty/fmodapi375win/samples/3d/3d.exe similarity index 100% rename from fmodapi375win/samples/3d/3d.exe rename to #ThirdParty/fmodapi375win/samples/3d/3d.exe diff --git a/fmodapi375win/samples/3d/Main.cpp b/#ThirdParty/fmodapi375win/samples/3d/Main.cpp similarity index 100% rename from fmodapi375win/samples/3d/Main.cpp rename to #ThirdParty/fmodapi375win/samples/3d/Main.cpp diff --git a/fmodapi375win/samples/3d/watcom.bat b/#ThirdParty/fmodapi375win/samples/3d/watcom.bat similarity index 100% rename from fmodapi375win/samples/3d/watcom.bat rename to #ThirdParty/fmodapi375win/samples/3d/watcom.bat diff --git a/fmodapi375win/samples/cdda/Main.cpp b/#ThirdParty/fmodapi375win/samples/cdda/Main.cpp similarity index 100% rename from fmodapi375win/samples/cdda/Main.cpp rename to #ThirdParty/fmodapi375win/samples/cdda/Main.cpp diff --git a/fmodapi375win/samples/cdda/cdda.dsp b/#ThirdParty/fmodapi375win/samples/cdda/cdda.dsp similarity index 100% rename from fmodapi375win/samples/cdda/cdda.dsp rename to #ThirdParty/fmodapi375win/samples/cdda/cdda.dsp diff --git a/fmodapi375win/samples/cdda/cdda.exe b/#ThirdParty/fmodapi375win/samples/cdda/cdda.exe similarity index 100% rename from fmodapi375win/samples/cdda/cdda.exe rename to #ThirdParty/fmodapi375win/samples/cdda/cdda.exe diff --git a/fmodapi375win/samples/cdda/watcom.bat b/#ThirdParty/fmodapi375win/samples/cdda/watcom.bat similarity index 100% rename from fmodapi375win/samples/cdda/watcom.bat rename to #ThirdParty/fmodapi375win/samples/cdda/watcom.bat diff --git a/fmodapi375win/samples/cddarip/Main.cpp b/#ThirdParty/fmodapi375win/samples/cddarip/Main.cpp similarity index 100% rename from fmodapi375win/samples/cddarip/Main.cpp rename to #ThirdParty/fmodapi375win/samples/cddarip/Main.cpp diff --git a/fmodapi375win/samples/cddarip/cddarip.dsp b/#ThirdParty/fmodapi375win/samples/cddarip/cddarip.dsp similarity index 100% rename from fmodapi375win/samples/cddarip/cddarip.dsp rename to #ThirdParty/fmodapi375win/samples/cddarip/cddarip.dsp diff --git a/fmodapi375win/samples/cddarip/cddarip.exe b/#ThirdParty/fmodapi375win/samples/cddarip/cddarip.exe similarity index 100% rename from fmodapi375win/samples/cddarip/cddarip.exe rename to #ThirdParty/fmodapi375win/samples/cddarip/cddarip.exe diff --git a/fmodapi375win/samples/cddarip/watcom.bat b/#ThirdParty/fmodapi375win/samples/cddarip/watcom.bat similarity index 100% rename from fmodapi375win/samples/cddarip/watcom.bat rename to #ThirdParty/fmodapi375win/samples/cddarip/watcom.bat diff --git a/fmodapi375win/samples/dsp/Main.cpp b/#ThirdParty/fmodapi375win/samples/dsp/Main.cpp similarity index 100% rename from fmodapi375win/samples/dsp/Main.cpp rename to #ThirdParty/fmodapi375win/samples/dsp/Main.cpp diff --git a/fmodapi375win/samples/dsp/dsp.dsp b/#ThirdParty/fmodapi375win/samples/dsp/dsp.dsp similarity index 100% rename from fmodapi375win/samples/dsp/dsp.dsp rename to #ThirdParty/fmodapi375win/samples/dsp/dsp.dsp diff --git a/fmodapi375win/samples/dsp/dsp.exe b/#ThirdParty/fmodapi375win/samples/dsp/dsp.exe similarity index 100% rename from fmodapi375win/samples/dsp/dsp.exe rename to #ThirdParty/fmodapi375win/samples/dsp/dsp.exe diff --git a/fmodapi375win/samples/dsp/watcom.bat b/#ThirdParty/fmodapi375win/samples/dsp/watcom.bat similarity index 100% rename from fmodapi375win/samples/dsp/watcom.bat rename to #ThirdParty/fmodapi375win/samples/dsp/watcom.bat diff --git a/fmodapi375win/samples/fmod/Main.c b/#ThirdParty/fmodapi375win/samples/fmod/Main.c similarity index 100% rename from fmodapi375win/samples/fmod/Main.c rename to #ThirdParty/fmodapi375win/samples/fmod/Main.c diff --git a/fmodapi375win/samples/fmod/fmod.exe b/#ThirdParty/fmodapi375win/samples/fmod/fmod.exe similarity index 100% rename from fmodapi375win/samples/fmod/fmod.exe rename to #ThirdParty/fmodapi375win/samples/fmod/fmod.exe diff --git a/fmodapi375win/samples/fmod/fmod.ico b/#ThirdParty/fmodapi375win/samples/fmod/fmod.ico similarity index 100% rename from fmodapi375win/samples/fmod/fmod.ico rename to #ThirdParty/fmodapi375win/samples/fmod/fmod.ico diff --git a/fmodapi375win/samples/fmod/fmod.rc b/#ThirdParty/fmodapi375win/samples/fmod/fmod.rc similarity index 100% rename from fmodapi375win/samples/fmod/fmod.rc rename to #ThirdParty/fmodapi375win/samples/fmod/fmod.rc diff --git a/fmodapi375win/samples/fmod/fmodsample.dsp b/#ThirdParty/fmodapi375win/samples/fmod/fmodsample.dsp similarity index 100% rename from fmodapi375win/samples/fmod/fmodsample.dsp rename to #ThirdParty/fmodapi375win/samples/fmod/fmodsample.dsp diff --git a/fmodapi375win/samples/fmod/lowpass.c b/#ThirdParty/fmodapi375win/samples/fmod/lowpass.c similarity index 100% rename from fmodapi375win/samples/fmod/lowpass.c rename to #ThirdParty/fmodapi375win/samples/fmod/lowpass.c diff --git a/fmodapi375win/samples/fmod/lowpass.h b/#ThirdParty/fmodapi375win/samples/fmod/lowpass.h similarity index 100% rename from fmodapi375win/samples/fmod/lowpass.h rename to #ThirdParty/fmodapi375win/samples/fmod/lowpass.h diff --git a/fmodapi375win/samples/fmod/resource.h b/#ThirdParty/fmodapi375win/samples/fmod/resource.h similarity index 100% rename from fmodapi375win/samples/fmod/resource.h rename to #ThirdParty/fmodapi375win/samples/fmod/resource.h diff --git a/fmodapi375win/samples/fmod/reverb.c b/#ThirdParty/fmodapi375win/samples/fmod/reverb.c similarity index 100% rename from fmodapi375win/samples/fmod/reverb.c rename to #ThirdParty/fmodapi375win/samples/fmod/reverb.c diff --git a/fmodapi375win/samples/fmod/reverb.h b/#ThirdParty/fmodapi375win/samples/fmod/reverb.h similarity index 100% rename from fmodapi375win/samples/fmod/reverb.h rename to #ThirdParty/fmodapi375win/samples/fmod/reverb.h diff --git a/fmodapi375win/samples/fmod/sdriver.c b/#ThirdParty/fmodapi375win/samples/fmod/sdriver.c similarity index 100% rename from fmodapi375win/samples/fmod/sdriver.c rename to #ThirdParty/fmodapi375win/samples/fmod/sdriver.c diff --git a/fmodapi375win/samples/fmod/sdriver.h b/#ThirdParty/fmodapi375win/samples/fmod/sdriver.h similarity index 100% rename from fmodapi375win/samples/fmod/sdriver.h rename to #ThirdParty/fmodapi375win/samples/fmod/sdriver.h diff --git a/fmodapi375win/samples/fsb/Main.cpp b/#ThirdParty/fmodapi375win/samples/fsb/Main.cpp similarity index 100% rename from fmodapi375win/samples/fsb/Main.cpp rename to #ThirdParty/fmodapi375win/samples/fsb/Main.cpp diff --git a/fmodapi375win/samples/fsb/fsb.dsp b/#ThirdParty/fmodapi375win/samples/fsb/fsb.dsp similarity index 100% rename from fmodapi375win/samples/fsb/fsb.dsp rename to #ThirdParty/fmodapi375win/samples/fsb/fsb.dsp diff --git a/fmodapi375win/samples/fsb/fsb.exe b/#ThirdParty/fmodapi375win/samples/fsb/fsb.exe similarity index 100% rename from fmodapi375win/samples/fsb/fsb.exe rename to #ThirdParty/fmodapi375win/samples/fsb/fsb.exe diff --git a/fmodapi375win/samples/fsb/watcom.bat b/#ThirdParty/fmodapi375win/samples/fsb/watcom.bat similarity index 100% rename from fmodapi375win/samples/fsb/watcom.bat rename to #ThirdParty/fmodapi375win/samples/fsb/watcom.bat diff --git a/fmodapi375win/samples/multiple/Main.cpp b/#ThirdParty/fmodapi375win/samples/multiple/Main.cpp similarity index 100% rename from fmodapi375win/samples/multiple/Main.cpp rename to #ThirdParty/fmodapi375win/samples/multiple/Main.cpp diff --git a/fmodapi375win/samples/multiple/multiple.dsp b/#ThirdParty/fmodapi375win/samples/multiple/multiple.dsp similarity index 100% rename from fmodapi375win/samples/multiple/multiple.dsp rename to #ThirdParty/fmodapi375win/samples/multiple/multiple.dsp diff --git a/fmodapi375win/samples/multiple/multiple.exe b/#ThirdParty/fmodapi375win/samples/multiple/multiple.exe similarity index 100% rename from fmodapi375win/samples/multiple/multiple.exe rename to #ThirdParty/fmodapi375win/samples/multiple/multiple.exe diff --git a/fmodapi375win/samples/multiple/watcom.bat b/#ThirdParty/fmodapi375win/samples/multiple/watcom.bat similarity index 100% rename from fmodapi375win/samples/multiple/watcom.bat rename to #ThirdParty/fmodapi375win/samples/multiple/watcom.bat diff --git a/fmodapi375win/samples/netstream/Main.cpp b/#ThirdParty/fmodapi375win/samples/netstream/Main.cpp similarity index 100% rename from fmodapi375win/samples/netstream/Main.cpp rename to #ThirdParty/fmodapi375win/samples/netstream/Main.cpp diff --git a/fmodapi375win/samples/netstream/netstream.dsp b/#ThirdParty/fmodapi375win/samples/netstream/netstream.dsp similarity index 100% rename from fmodapi375win/samples/netstream/netstream.dsp rename to #ThirdParty/fmodapi375win/samples/netstream/netstream.dsp diff --git a/fmodapi375win/samples/netstream/netstream.exe b/#ThirdParty/fmodapi375win/samples/netstream/netstream.exe similarity index 100% rename from fmodapi375win/samples/netstream/netstream.exe rename to #ThirdParty/fmodapi375win/samples/netstream/netstream.exe diff --git a/fmodapi375win/samples/netstream/watcom.bat b/#ThirdParty/fmodapi375win/samples/netstream/watcom.bat similarity index 100% rename from fmodapi375win/samples/netstream/watcom.bat rename to #ThirdParty/fmodapi375win/samples/netstream/watcom.bat diff --git a/fmodapi375win/samples/record/Main.cpp b/#ThirdParty/fmodapi375win/samples/record/Main.cpp similarity index 100% rename from fmodapi375win/samples/record/Main.cpp rename to #ThirdParty/fmodapi375win/samples/record/Main.cpp diff --git a/fmodapi375win/samples/record/record.dsp b/#ThirdParty/fmodapi375win/samples/record/record.dsp similarity index 100% rename from fmodapi375win/samples/record/record.dsp rename to #ThirdParty/fmodapi375win/samples/record/record.dsp diff --git a/fmodapi375win/samples/record/record.exe b/#ThirdParty/fmodapi375win/samples/record/record.exe similarity index 100% rename from fmodapi375win/samples/record/record.exe rename to #ThirdParty/fmodapi375win/samples/record/record.exe diff --git a/fmodapi375win/samples/record/watcom.bat b/#ThirdParty/fmodapi375win/samples/record/watcom.bat similarity index 100% rename from fmodapi375win/samples/record/watcom.bat rename to #ThirdParty/fmodapi375win/samples/record/watcom.bat diff --git a/fmodapi375win/samples/simple/Main.cpp b/#ThirdParty/fmodapi375win/samples/simple/Main.cpp similarity index 100% rename from fmodapi375win/samples/simple/Main.cpp rename to #ThirdParty/fmodapi375win/samples/simple/Main.cpp diff --git a/fmodapi375win/samples/simple/simple.dsp b/#ThirdParty/fmodapi375win/samples/simple/simple.dsp similarity index 100% rename from fmodapi375win/samples/simple/simple.dsp rename to #ThirdParty/fmodapi375win/samples/simple/simple.dsp diff --git a/fmodapi375win/samples/simple/simple.exe b/#ThirdParty/fmodapi375win/samples/simple/simple.exe similarity index 100% rename from fmodapi375win/samples/simple/simple.exe rename to #ThirdParty/fmodapi375win/samples/simple/simple.exe diff --git a/fmodapi375win/samples/simple/watcom.bat b/#ThirdParty/fmodapi375win/samples/simple/watcom.bat similarity index 100% rename from fmodapi375win/samples/simple/watcom.bat rename to #ThirdParty/fmodapi375win/samples/simple/watcom.bat diff --git a/fmodapi375win/samples/simplest/Main.cpp b/#ThirdParty/fmodapi375win/samples/simplest/Main.cpp similarity index 100% rename from fmodapi375win/samples/simplest/Main.cpp rename to #ThirdParty/fmodapi375win/samples/simplest/Main.cpp diff --git a/fmodapi375win/samples/simplest/Simplest.dsp b/#ThirdParty/fmodapi375win/samples/simplest/Simplest.dsp similarity index 100% rename from fmodapi375win/samples/simplest/Simplest.dsp rename to #ThirdParty/fmodapi375win/samples/simplest/Simplest.dsp diff --git a/fmodapi375win/samples/simplest/WATCOM.BAT b/#ThirdParty/fmodapi375win/samples/simplest/WATCOM.BAT similarity index 100% rename from fmodapi375win/samples/simplest/WATCOM.BAT rename to #ThirdParty/fmodapi375win/samples/simplest/WATCOM.BAT diff --git a/fmodapi375win/samples/simplest/simplest.exe b/#ThirdParty/fmodapi375win/samples/simplest/simplest.exe similarity index 100% rename from fmodapi375win/samples/simplest/simplest.exe rename to #ThirdParty/fmodapi375win/samples/simplest/simplest.exe diff --git a/fmodapi375win/samples/stream/Main.cpp b/#ThirdParty/fmodapi375win/samples/stream/Main.cpp similarity index 100% rename from fmodapi375win/samples/stream/Main.cpp rename to #ThirdParty/fmodapi375win/samples/stream/Main.cpp diff --git a/fmodapi375win/samples/stream/WATCOM.BAT b/#ThirdParty/fmodapi375win/samples/stream/WATCOM.BAT similarity index 100% rename from fmodapi375win/samples/stream/WATCOM.BAT rename to #ThirdParty/fmodapi375win/samples/stream/WATCOM.BAT diff --git a/fmodapi375win/samples/stream/runme.bat b/#ThirdParty/fmodapi375win/samples/stream/runme.bat similarity index 100% rename from fmodapi375win/samples/stream/runme.bat rename to #ThirdParty/fmodapi375win/samples/stream/runme.bat diff --git a/fmodapi375win/samples/stream/stream.dsp b/#ThirdParty/fmodapi375win/samples/stream/stream.dsp similarity index 100% rename from fmodapi375win/samples/stream/stream.dsp rename to #ThirdParty/fmodapi375win/samples/stream/stream.dsp diff --git a/fmodapi375win/samples/stream/stream.exe b/#ThirdParty/fmodapi375win/samples/stream/stream.exe similarity index 100% rename from fmodapi375win/samples/stream/stream.exe rename to #ThirdParty/fmodapi375win/samples/stream/stream.exe diff --git a/fmodapi375win/samples/userstream/Main.cpp b/#ThirdParty/fmodapi375win/samples/userstream/Main.cpp similarity index 100% rename from fmodapi375win/samples/userstream/Main.cpp rename to #ThirdParty/fmodapi375win/samples/userstream/Main.cpp diff --git a/fmodapi375win/samples/userstream/WATCOM.BAT b/#ThirdParty/fmodapi375win/samples/userstream/WATCOM.BAT similarity index 100% rename from fmodapi375win/samples/userstream/WATCOM.BAT rename to #ThirdParty/fmodapi375win/samples/userstream/WATCOM.BAT diff --git a/fmodapi375win/samples/userstream/userstream.dsp b/#ThirdParty/fmodapi375win/samples/userstream/userstream.dsp similarity index 100% rename from fmodapi375win/samples/userstream/userstream.dsp rename to #ThirdParty/fmodapi375win/samples/userstream/userstream.dsp diff --git a/fmodapi375win/samples/userstream/userstream.exe b/#ThirdParty/fmodapi375win/samples/userstream/userstream.exe similarity index 100% rename from fmodapi375win/samples/userstream/userstream.exe rename to #ThirdParty/fmodapi375win/samples/userstream/userstream.exe diff --git a/fmodapi375win/samplesdelphi/3d1/Ex3d1.dpr b/#ThirdParty/fmodapi375win/samplesdelphi/3d1/Ex3d1.dpr similarity index 100% rename from fmodapi375win/samplesdelphi/3d1/Ex3d1.dpr rename to #ThirdParty/fmodapi375win/samplesdelphi/3d1/Ex3d1.dpr diff --git a/fmodapi375win/samplesdelphi/FMod/about.dfm b/#ThirdParty/fmodapi375win/samplesdelphi/FMod/about.dfm similarity index 100% rename from fmodapi375win/samplesdelphi/FMod/about.dfm rename to #ThirdParty/fmodapi375win/samplesdelphi/FMod/about.dfm diff --git a/fmodapi375win/samplesdelphi/FMod/about.pas b/#ThirdParty/fmodapi375win/samplesdelphi/FMod/about.pas similarity index 100% rename from fmodapi375win/samplesdelphi/FMod/about.pas rename to #ThirdParty/fmodapi375win/samplesdelphi/FMod/about.pas diff --git a/fmodapi375win/samplesdelphi/FMod/config.dfm b/#ThirdParty/fmodapi375win/samplesdelphi/FMod/config.dfm similarity index 100% rename from fmodapi375win/samplesdelphi/FMod/config.dfm rename to #ThirdParty/fmodapi375win/samplesdelphi/FMod/config.dfm diff --git a/fmodapi375win/samplesdelphi/FMod/config.pas b/#ThirdParty/fmodapi375win/samplesdelphi/FMod/config.pas similarity index 100% rename from fmodapi375win/samplesdelphi/FMod/config.pas rename to #ThirdParty/fmodapi375win/samplesdelphi/FMod/config.pas diff --git a/fmodapi375win/samplesdelphi/FMod/main.dfm b/#ThirdParty/fmodapi375win/samplesdelphi/FMod/main.dfm similarity index 100% rename from fmodapi375win/samplesdelphi/FMod/main.dfm rename to #ThirdParty/fmodapi375win/samplesdelphi/FMod/main.dfm diff --git a/fmodapi375win/samplesdelphi/FMod/main.pas b/#ThirdParty/fmodapi375win/samplesdelphi/FMod/main.pas similarity index 100% rename from fmodapi375win/samplesdelphi/FMod/main.pas rename to #ThirdParty/fmodapi375win/samplesdelphi/FMod/main.pas diff --git a/fmodapi375win/samplesdelphi/FMod/spectrum.pas b/#ThirdParty/fmodapi375win/samplesdelphi/FMod/spectrum.pas similarity index 100% rename from fmodapi375win/samplesdelphi/FMod/spectrum.pas rename to #ThirdParty/fmodapi375win/samplesdelphi/FMod/spectrum.pas diff --git a/fmodapi375win/samplesdelphi/FMod/testbed.dpr b/#ThirdParty/fmodapi375win/samplesdelphi/FMod/testbed.dpr similarity index 100% rename from fmodapi375win/samplesdelphi/FMod/testbed.dpr rename to #ThirdParty/fmodapi375win/samplesdelphi/FMod/testbed.dpr diff --git a/fmodapi375win/samplesdelphi/FMod/testbed.res b/#ThirdParty/fmodapi375win/samplesdelphi/FMod/testbed.res similarity index 100% rename from fmodapi375win/samplesdelphi/FMod/testbed.res rename to #ThirdParty/fmodapi375win/samplesdelphi/FMod/testbed.res diff --git a/fmodapi375win/samplesdelphi/Readme.txt b/#ThirdParty/fmodapi375win/samplesdelphi/Readme.txt similarity index 100% rename from fmodapi375win/samplesdelphi/Readme.txt rename to #ThirdParty/fmodapi375win/samplesdelphi/Readme.txt diff --git a/fmodapi375win/samplesdelphi/Simple/simple.dpr b/#ThirdParty/fmodapi375win/samplesdelphi/Simple/simple.dpr similarity index 100% rename from fmodapi375win/samplesdelphi/Simple/simple.dpr rename to #ThirdParty/fmodapi375win/samplesdelphi/Simple/simple.dpr diff --git a/fmodapi375win/samplesdelphi/Simplest/simplest.dpr b/#ThirdParty/fmodapi375win/samplesdelphi/Simplest/simplest.dpr similarity index 100% rename from fmodapi375win/samplesdelphi/Simplest/simplest.dpr rename to #ThirdParty/fmodapi375win/samplesdelphi/Simplest/simplest.dpr diff --git a/fmodapi375win/samplesdelphi/Stream1/stream1.dpr b/#ThirdParty/fmodapi375win/samplesdelphi/Stream1/stream1.dpr similarity index 100% rename from fmodapi375win/samplesdelphi/Stream1/stream1.dpr rename to #ThirdParty/fmodapi375win/samplesdelphi/Stream1/stream1.dpr diff --git a/fmodapi375win/samplesdelphi/simplegui/main.dfm b/#ThirdParty/fmodapi375win/samplesdelphi/simplegui/main.dfm similarity index 100% rename from fmodapi375win/samplesdelphi/simplegui/main.dfm rename to #ThirdParty/fmodapi375win/samplesdelphi/simplegui/main.dfm diff --git a/fmodapi375win/samplesdelphi/simplegui/main.pas b/#ThirdParty/fmodapi375win/samplesdelphi/simplegui/main.pas similarity index 100% rename from fmodapi375win/samplesdelphi/simplegui/main.pas rename to #ThirdParty/fmodapi375win/samplesdelphi/simplegui/main.pas diff --git a/fmodapi375win/samplesdelphi/simplegui/simple.dpr b/#ThirdParty/fmodapi375win/samplesdelphi/simplegui/simple.dpr similarity index 100% rename from fmodapi375win/samplesdelphi/simplegui/simple.dpr rename to #ThirdParty/fmodapi375win/samplesdelphi/simplegui/simple.dpr diff --git a/fmodapi375win/samplesdelphi/stream2/stream2.dpr b/#ThirdParty/fmodapi375win/samplesdelphi/stream2/stream2.dpr similarity index 100% rename from fmodapi375win/samplesdelphi/stream2/stream2.dpr rename to #ThirdParty/fmodapi375win/samplesdelphi/stream2/stream2.dpr diff --git a/fmodapi375win/samplesvb/simplest/Form1.frm b/#ThirdParty/fmodapi375win/samplesvb/simplest/Form1.frm similarity index 100% rename from fmodapi375win/samplesvb/simplest/Form1.frm rename to #ThirdParty/fmodapi375win/samplesvb/simplest/Form1.frm diff --git a/fmodapi375win/samplesvb/simplest/Project1.vbp b/#ThirdParty/fmodapi375win/samplesvb/simplest/Project1.vbp similarity index 100% rename from fmodapi375win/samplesvb/simplest/Project1.vbp rename to #ThirdParty/fmodapi375win/samplesvb/simplest/Project1.vbp diff --git a/fmodapi375win/tools/FSBANK.HLP b/#ThirdParty/fmodapi375win/tools/FSBANK.HLP similarity index 100% rename from fmodapi375win/tools/FSBANK.HLP rename to #ThirdParty/fmodapi375win/tools/FSBANK.HLP diff --git a/fmodapi375win/tools/asioconfig.exe b/#ThirdParty/fmodapi375win/tools/asioconfig.exe similarity index 100% rename from fmodapi375win/tools/asioconfig.exe rename to #ThirdParty/fmodapi375win/tools/asioconfig.exe diff --git a/fmodapi375win/tools/fsbank.exe b/#ThirdParty/fmodapi375win/tools/fsbank.exe similarity index 100% rename from fmodapi375win/tools/fsbank.exe rename to #ThirdParty/fmodapi375win/tools/fsbank.exe diff --git a/fmodapi375win/tools/fsbankcl.exe b/#ThirdParty/fmodapi375win/tools/fsbankcl.exe similarity index 100% rename from fmodapi375win/tools/fsbankcl.exe rename to #ThirdParty/fmodapi375win/tools/fsbankcl.exe diff --git a/fmodapi375win/tools/fsbanklib/drumloop.wav b/#ThirdParty/fmodapi375win/tools/fsbanklib/drumloop.wav similarity index 100% rename from fmodapi375win/tools/fsbanklib/drumloop.wav rename to #ThirdParty/fmodapi375win/tools/fsbanklib/drumloop.wav diff --git a/fmodapi375win/tools/fsbanklib/example.cpp b/#ThirdParty/fmodapi375win/tools/fsbanklib/example.cpp similarity index 100% rename from fmodapi375win/tools/fsbanklib/example.cpp rename to #ThirdParty/fmodapi375win/tools/fsbanklib/example.cpp diff --git a/fmodapi375win/tools/fsbanklib/example.dsp b/#ThirdParty/fmodapi375win/tools/fsbanklib/example.dsp similarity index 100% rename from fmodapi375win/tools/fsbanklib/example.dsp rename to #ThirdParty/fmodapi375win/tools/fsbanklib/example.dsp diff --git a/fmodapi375win/tools/fsbanklib/fsbanklib.chm b/#ThirdParty/fmodapi375win/tools/fsbanklib/fsbanklib.chm similarity index 100% rename from fmodapi375win/tools/fsbanklib/fsbanklib.chm rename to #ThirdParty/fmodapi375win/tools/fsbanklib/fsbanklib.chm diff --git a/fmodapi375win/tools/fsbanklib/fsbanklib.h b/#ThirdParty/fmodapi375win/tools/fsbanklib/fsbanklib.h similarity index 100% rename from fmodapi375win/tools/fsbanklib/fsbanklib.h rename to #ThirdParty/fmodapi375win/tools/fsbanklib/fsbanklib.h diff --git a/fmodapi375win/tools/fsbanklib/fsbanklib.txt b/#ThirdParty/fmodapi375win/tools/fsbanklib/fsbanklib.txt similarity index 100% rename from fmodapi375win/tools/fsbanklib/fsbanklib.txt rename to #ThirdParty/fmodapi375win/tools/fsbanklib/fsbanklib.txt diff --git a/fmodapi375win/tools/fsbanklib/fsbanklibMT.lib b/#ThirdParty/fmodapi375win/tools/fsbanklib/fsbanklibMT.lib similarity index 100% rename from fmodapi375win/tools/fsbanklib/fsbanklibMT.lib rename to #ThirdParty/fmodapi375win/tools/fsbanklib/fsbanklibMT.lib diff --git a/fmodapi375win/tools/fsbanklib/fsbanklibMTD.lib b/#ThirdParty/fmodapi375win/tools/fsbanklib/fsbanklibMTD.lib similarity index 100% rename from fmodapi375win/tools/fsbanklib/fsbanklibMTD.lib rename to #ThirdParty/fmodapi375win/tools/fsbanklib/fsbanklibMTD.lib diff --git a/fmodapi375win/tools/fsbanklib/jbtennis.wav b/#ThirdParty/fmodapi375win/tools/fsbanklib/jbtennis.wav similarity index 100% rename from fmodapi375win/tools/fsbanklib/jbtennis.wav rename to #ThirdParty/fmodapi375win/tools/fsbanklib/jbtennis.wav diff --git a/fmodapi375win/tools/readme.txt b/#ThirdParty/fmodapi375win/tools/readme.txt similarity index 100% rename from fmodapi375win/tools/readme.txt rename to #ThirdParty/fmodapi375win/tools/readme.txt diff --git a/#ThirdParty/libSDL/BUGS.txt b/#ThirdParty/libSDL/BUGS.txt new file mode 100644 index 0000000..7ef5538 --- /dev/null +++ b/#ThirdParty/libSDL/BUGS.txt @@ -0,0 +1,16 @@ + +Bugs are now managed in the SDL bug tracker, here: + + http://bugzilla.libsdl.org/ + +You may report bugs there, and search to see if a given issue has already + been reported, discussed, and maybe even fixed. + + +You may also find help on the SDL mailing list. Subscription information: + + http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org + +Bug reports are welcome here, but we really appreciate if you use Bugzilla, as + bugs discussed on the mailing list may be forgotten or missed. + diff --git a/#ThirdParty/libSDL/COPYING.txt b/#ThirdParty/libSDL/COPYING.txt new file mode 100644 index 0000000..04f14ee --- /dev/null +++ b/#ThirdParty/libSDL/COPYING.txt @@ -0,0 +1,20 @@ + +Simple DirectMedia Layer +Copyright (C) 1997-2016 Sam Lantinga + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + diff --git a/#ThirdParty/libSDL/README-SDL.txt b/#ThirdParty/libSDL/README-SDL.txt new file mode 100644 index 0000000..0630395 --- /dev/null +++ b/#ThirdParty/libSDL/README-SDL.txt @@ -0,0 +1,13 @@ + +Please distribute this file with the SDL runtime environment: + +The Simple DirectMedia Layer (SDL for short) is a cross-platform library +designed to make it easy to write multi-media software, such as games and +emulators. + +The Simple DirectMedia Layer library source code is available from: +http://www.libsdl.org/ + +This library is distributed under the terms of the zlib license: +http://www.zlib.net/zlib_license.html + diff --git a/#ThirdParty/libSDL/README.txt b/#ThirdParty/libSDL/README.txt new file mode 100644 index 0000000..84c335c --- /dev/null +++ b/#ThirdParty/libSDL/README.txt @@ -0,0 +1,21 @@ + + Simple DirectMedia Layer + + (SDL) + + Version 2.0 + +--- +http://www.libsdl.org/ + +Simple DirectMedia Layer is a cross-platform development library designed +to provide low level access to audio, keyboard, mouse, joystick, and graphics +hardware via OpenGL and Direct3D. It is used by video playback software, +emulators, and popular games including Valve's award winning catalog +and many Humble Bundle games. + +More extensive documentation is available in the docs directory, starting +with README.md + +Enjoy! + Sam Lantinga (slouken@libsdl.org) diff --git a/#ThirdParty/libSDL/WhatsNew.txt b/#ThirdParty/libSDL/WhatsNew.txt new file mode 100644 index 0000000..698ebf7 --- /dev/null +++ b/#ThirdParty/libSDL/WhatsNew.txt @@ -0,0 +1,199 @@ + +This is a list of major changes in SDL's version history. + +--------------------------------------------------------------------------- +2.0.4: +--------------------------------------------------------------------------- + +General: +* Added support for web applications using Emscripten, see docs/README-emscripten.md for more information +* Added support for web applications using Native Client (NaCl), see docs/README-nacl.md for more information +* Added an API to queue audio instead of using the audio callback: + SDL_QueueAudio(), SDL_GetQueuedAudioSize(), SDL_ClearQueuedAudio() +* Added events for audio device hot plug support: + SDL_AUDIODEVICEADDED, SDL_AUDIODEVICEREMOVED +* Added SDL_PointInRect() +* Added SDL_HasAVX2() to detect CPUs with AVX2 support +* Added SDL_SetWindowHitTest() to let apps treat parts of their SDL window like traditional window decorations (drag areas, resize areas) +* Added SDL_GetGrabbedWindow() to get the window that currently has input grab, if any +* Added SDL_RenderIsClipEnabled() to tell whether clipping is currently enabled in a renderer +* Added SDL_CaptureMouse() to capture the mouse to get events while the mouse is not in your window +* Added SDL_WarpMouseGlobal() to warp the mouse cursor in global screen space +* Added SDL_GetGlobalMouseState() to get the current mouse state outside of an SDL window +* Added a direction field to mouse wheel events to tell whether they are flipped (natural) or not +* Added GL_CONTEXT_RELEASE_BEHAVIOR GL attribute (maps to [WGL|GLX]_ARB_context_flush_control extension) +* Added EGL_KHR_create_context support to allow OpenGL ES version selection on some platforms +* Added NV12 and NV21 YUV texture support for OpenGL and OpenGL ES 2.0 renderers +* Added a Vivante video driver that is used on various SoC platforms +* Added an event SDL_RENDER_DEVICE_RESET that is sent from the D3D renderers when the D3D device is lost, and from Android's event loop when the GLES context had to be recreated +* Added a hint SDL_HINT_NO_SIGNAL_HANDLERS to disable SDL's built in signal handling +* Added a hint SDL_HINT_THREAD_STACK_SIZE to set the stack size of SDL's threads +* Added SDL_sqrtf(), SDL_tan(), and SDL_tanf() to the stdlib routines +* Improved support for WAV and BMP files with unusual chunks in them +* Renamed SDL_assert_data to SDL_AssertData and SDL_assert_state to SDL_AssertState +* Added a hint SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN to prevent window interaction while cursor is hidden +* Added SDL_GetDisplayDPI() to get the DPI information for a display +* Added SDL_JoystickCurrentPowerLevel() to get the battery level of a joystick +* Added SDL_JoystickFromInstanceID(), as a helper function, to get the SDL_Joystick* that an event is referring to. +* Added SDL_GameControllerFromInstanceID(), as a helper function, to get the SDL_GameController* that an event is referring to. + +Windows: +* Added support for Windows Phone 8.1 and Windows 10/UWP (Universal Windows Platform) +* Timer resolution is now 1 ms by default, adjustable with the SDL_HINT_TIMER_RESOLUTION hint +* SDLmain no longer depends on the C runtime, so you can use the same .lib in both Debug and Release builds +* Added SDL_SetWindowsMessageHook() to set a function to be called for every windows message before TranslateMessage() +* Added a hint SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP to control whether SDL_PumpEvents() processes the Windows message loop +* You can distinguish between real mouse and touch events by looking for SDL_TOUCH_MOUSEID in the mouse event "which" field +* SDL_SysWMinfo now contains the window HDC +* Added support for Unicode command line options +* Prevent beeping when Alt-key combos are pressed +* SDL_SetTextInputRect() re-positions the OS-rendered IME +* Added a hint SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 to prevent generating SDL_WINDOWEVENT_CLOSE events when Alt-F4 is pressed +* Added a hint SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING to use the old axis and button mapping for XInput devices (deprecated) + +Mac OS X: +* Implemented drag-and-drop support +* Improved joystick hot-plug detection +* The SDL_WINDOWEVENT_EXPOSED window event is triggered in the appropriate situations +* Fixed relative mouse mode when the application loses/regains focus +* Fixed bugs related to transitioning to and from Spaces-aware fullscreen-desktop mode +* Fixed the refresh rate of display modes +* SDL_SysWMInfo is now ARC-compatible +* Added a hint SDL_HINT_MAC_BACKGROUND_APP to prevent forcing the application to become a foreground process + +Linux: +* Enabled building with Mir and Wayland support by default. +* Added IBus IME support +* Added a hint SDL_HINT_IME_INTERNAL_EDITING to control whether IBus should handle text editing internally instead of sending SDL_TEXTEDITING events +* Added a hint SDL_HINT_VIDEO_X11_NET_WM_PING to allow disabling _NET_WM_PING protocol handling in SDL_CreateWindow() +* Added support for multiple audio devices when using Pulseaudio +* Fixed duplicate mouse events when using relative mouse motion + +iOS: +* Added support for iOS 8 +* The SDL_WINDOW_ALLOW_HIGHDPI window flag now enables high-dpi support, and SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() gets the window resolution in pixels +* SDL_GetWindowSize() and display mode sizes are in the "DPI-independent points" / "screen coordinates" coordinate space rather than pixels (matches OS X behavior) +* Added native resolution support for the iPhone 6 Plus +* Added support for MFi game controllers +* Added support for the hint SDL_HINT_ACCELEROMETER_AS_JOYSTICK +* Added sRGB OpenGL ES context support on iOS 7+ +* Added support for SDL_DisableScreenSaver(), SDL_EnableScreenSaver() and the hint SDL_HINT_VIDEO_ALLOW_SCREENSAVER +* SDL_SysWMinfo now contains the OpenGL ES framebuffer and color renderbuffer objects used by the window's active GLES view +* Fixed various rotation and orientation issues +* Fixed memory leaks + +Android: +* Added a hint SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH to prevent mouse events from being registered as touch events +* Added hints SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION and SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION +* Added support for SDL_DisableScreenSaver(), SDL_EnableScreenSaver() and the hint SDL_HINT_VIDEO_ALLOW_SCREENSAVER +* Added support for SDL_ShowMessageBox() and SDL_ShowSimpleMessageBox() + +Raspberry Pi: +* Added support for the Raspberry Pi 2 + + +--------------------------------------------------------------------------- +2.0.3: +--------------------------------------------------------------------------- + +Mac OS X: +* Fixed creating an OpenGL context by default on Mac OS X 10.6 + + +--------------------------------------------------------------------------- +2.0.2: +--------------------------------------------------------------------------- +General: +* Added SDL_GL_ResetAttributes() to reset OpenGL attributes to default values +* Added an API to load a database of game controller mappings from a file: + SDL_GameControllerAddMappingsFromFile(), SDL_GameControllerAddMappingsFromRW() +* Added game controller mappings for the PS4 and OUYA controllers +* Added SDL_GetDefaultAssertionHandler() and SDL_GetAssertionHandler() +* Added SDL_DetachThread() +* Added SDL_HasAVX() to determine if the CPU has AVX features +* Added SDL_vsscanf(), SDL_acos(), and SDL_asin() to the stdlib routines +* EGL can now create/manage OpenGL and OpenGL ES 1.x/2.x contexts, and share + them using SDL_GL_SHARE_WITH_CURRENT_CONTEXT +* Added a field "clicks" to the mouse button event which records whether the event is a single click, double click, etc. +* The screensaver is now disabled by default, and there is a hint SDL_HINT_VIDEO_ALLOW_SCREENSAVER that can change that behavior. +* Added a hint SDL_HINT_MOUSE_RELATIVE_MODE_WARP to specify whether mouse relative mode should be emulated using mouse warping. +* testgl2 does not need to link with libGL anymore +* Added testgles2 test program to demonstrate working with OpenGL ES 2.0 +* Added controllermap test program to visually map a game controller + +Windows: +* Support for OpenGL ES 2.x contexts using either WGL or EGL (natively via + the driver or emulated through ANGLE) +* Added a hint SDL_HINT_VIDEO_WIN_D3DCOMPILER to specify which D3D shader compiler to use for OpenGL ES 2 support through ANGLE +* Added a hint SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT that is useful when creating multiple windows that should share the same OpenGL context. +* Added an event SDL_RENDER_TARGETS_RESET that is sent when D3D9 render targets are reset after the device has been restored. + +Mac OS X: +* Added a hint SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK to control whether Ctrl+click should be treated as a right click on Mac OS X. This is off by default. + +Linux: +* Fixed fullscreen and focused behavior when receiving NotifyGrab events +* Added experimental Wayland and Mir support, disabled by default + +Android: +* Joystick support (minimum SDK version required to build SDL is now 12, + the required runtime version remains at 10, but on such devices joystick + support won't be available). +* Hotplugging support for joysticks +* Added a hint SDL_HINT_ACCELEROMETER_AS_JOYSTICK to control whether the accelerometer should be listed as a 3 axis joystick, which it will by default. + + +--------------------------------------------------------------------------- +2.0.1: +--------------------------------------------------------------------------- + +General: +* Added an API to get common filesystem paths in SDL_filesystem.h: + SDL_GetBasePath(), SDL_GetPrefPath() +* Added an API to do optimized YV12 and IYUV texture updates: + SDL_UpdateYUVTexture() +* Added an API to get the amount of RAM on the system: + SDL_GetSystemRAM() +* Added a macro to perform timestamp comparisons with SDL_GetTicks(): + SDL_TICKS_PASSED() +* Dramatically improved OpenGL ES 2.0 rendering performance +* Added OpenGL attribute SDL_GL_FRAMEBUFFER_SRGB_CAPABLE + +Windows: +* Created a static library configuration for the Visual Studio 2010 project +* Added a hint to create the Direct3D device with support for multi-threading: + SDL_HINT_RENDER_DIRECT3D_THREADSAFE +* Added a function to get the D3D9 adapter index for a display: + SDL_Direct3D9GetAdapterIndex() +* Added a function to get the D3D9 device for a D3D9 renderer: + SDL_RenderGetD3D9Device() +* Fixed building SDL with the mingw32 toolchain (mingw-w64 is preferred) +* Fixed crash when using two XInput controllers at the same time +* Fixed detecting a mixture of XInput and DirectInput controllers +* Fixed clearing a D3D render target larger than the window +* Improved support for format specifiers in SDL_snprintf() + +Mac OS X: +* Added support for retina displays: + Create your window with the SDL_WINDOW_ALLOW_HIGHDPI flag, and then use SDL_GL_GetDrawableSize() to find the actual drawable size. You are responsible for scaling mouse and drawing coordinates appropriately. +* Fixed mouse warping in fullscreen mode +* Right mouse click is emulated by holding the Ctrl key while left clicking + +Linux: +* Fixed float audio support with the PulseAudio driver +* Fixed missing line endpoints in the OpenGL renderer on some drivers +* X11 symbols are no longer defined to avoid collisions when linking statically + +iOS: +* Fixed status bar visibility on iOS 7 +* Flipped the accelerometer Y axis to match expected values + +Android: +IMPORTANT: You MUST get the updated SDLActivity.java to match C code +* Moved EGL initialization to native code +* Fixed the accelerometer axis rotation relative to the device rotation +* Fixed race conditions when handling the EGL context on pause/resume +* Touch devices are available for enumeration immediately after init + +Raspberry Pi: +* Added support for the Raspberry Pi, see README-raspberrypi.txt for details diff --git a/#ThirdParty/libSDL/Wiki.url b/#ThirdParty/libSDL/Wiki.url new file mode 100644 index 0000000..8b77ceb --- /dev/null +++ b/#ThirdParty/libSDL/Wiki.url @@ -0,0 +1,5 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,2 +[InternetShortcut] +IDList= +URL=http://wiki.libsdl.org/FrontPage diff --git a/#ThirdParty/libSDL/docs/README-android.md b/#ThirdParty/libSDL/docs/README-android.md new file mode 100644 index 0000000..a4b3821 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-android.md @@ -0,0 +1,464 @@ +Android +================================================================================ + +Requirements: + +Android SDK (version 12 or later) +http://developer.android.com/sdk/index.html + +Android NDK r7 or later +http://developer.android.com/tools/sdk/ndk/index.html + +Minimum API level supported by SDL: 10 (Android 2.3.3) +Joystick support is available for API level >=12 devices. + +================================================================================ + How the port works +================================================================================ + +- Android applications are Java-based, optionally with parts written in C +- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to + the SDL library +- This means that your application C code must be placed inside an Android + Java project, along with some C support code that communicates with Java +- This eventually produces a standard Android .apk package + +The Android Java code implements an "Activity" and can be found in: +android-project/src/org/libsdl/app/SDLActivity.java + +The Java code loads your game code, the SDL shared library, and +dispatches to native functions implemented in the SDL library: +src/core/android/SDL_android.c + +Your project must include some glue code that starts your main() routine: +src/main/android/SDL_android_main.c + + +================================================================================ + Building an app +================================================================================ + +For simple projects you can use the script located at build-scripts/androidbuild.sh + +There's two ways of using it: + + androidbuild.sh com.yourcompany.yourapp < sources.list + androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c + +sources.list should be a text file with a source file name in each line +Filenames should be specified relative to the current directory, for example if +you are in the build-scripts directory and want to create the testgles.c test, you'll +run: + + ./androidbuild.sh org.libsdl.testgles ../test/testgles.c + +One limitation of this script is that all sources provided will be aggregated into +a single directory, thus all your source files should have a unique name. + +Once the project is complete the script will tell you where the debug APK is located. +If you want to create a signed release APK, you can use the project created by this +utility to generate it. + +Finally, a word of caution: re running androidbuild.sh wipes any changes you may have +done in the build directory for the app! + + +For more complex projects, follow these instructions: + +1. Copy the android-project directory wherever you want to keep your projects + and rename it to the name of your project. +2. Move or symlink this SDL directory into the /jni directory +3. Edit /jni/src/Android.mk to include your source files +4. Run 'ndk-build' (a script provided by the NDK). This compiles the C source + +If you want to use the Eclipse IDE, skip to the Eclipse section below. + +5. Create /local.properties and use that to point to the Android SDK directory, by writing a line with the following form: + + sdk.dir=PATH_TO_ANDROID_SDK + +6. Run 'ant debug' in android/project. This compiles the .java and eventually + creates a .apk with the native code embedded +7. 'ant debug install' will push the apk to the device or emulator (if connected) + +Here's an explanation of the files in the Android project, so you can customize them: + + android-project/ + AndroidManifest.xml - package manifest. Among others, it contains the class name + of the main Activity and the package name of the application. + build.properties - empty + build.xml - build description file, used by ant. The actual application name + is specified here. + default.properties - holds the target ABI for the application, android-10 and up + project.properties - holds the target ABI for the application, android-10 and up + local.properties - holds the SDK path, you should change this to the path to your SDK + jni/ - directory holding native code + jni/Android.mk - Android makefile that can call recursively the Android.mk files + in all subdirectories + jni/SDL/ - (symlink to) directory holding the SDL library files + jni/SDL/Android.mk - Android makefile for creating the SDL shared library + jni/src/ - directory holding your C/C++ source + jni/src/Android.mk - Android makefile that you should customize to include your + source code and any library references + res/ - directory holding resources for your application + res/drawable-* - directories holding icons for different phone hardware. Could be + one dir called "drawable". + res/layout/main.xml - Usually contains a file main.xml, which declares the screen layout. + We don't need it because we use the SDL video output. + res/values/strings.xml - strings used in your application, including the application name + shown on the phone. + src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding + to SDL. Be very careful changing this, as the SDL library relies + on this implementation. + + +================================================================================ + Build an app with static linking of libSDL +================================================================================ + +This build uses the Android NDK module system. + +Instructions: +1. Copy the android-project directory wherever you want to keep your projects + and rename it to the name of your project. +2. Rename /jni/src/Android_static.mk to /jni/src/Android.mk + (overwrite the existing one) +3. Edit /jni/src/Android.mk to include your source files +4. create and export an environment variable named NDK_MODULE_PATH that points + to the parent directory of this SDL directory. e.g.: + + export NDK_MODULE_PATH="$PWD"/.. + +5. Edit /src/org/libsdl/app/SDLActivity.java and remove the call to + System.loadLibrary("SDL2"). +6. Run 'ndk-build' (a script provided by the NDK). This compiles the C source + + +================================================================================ + Customizing your application name +================================================================================ + +To customize your application name, edit AndroidManifest.xml and replace +"org.libsdl.app" with an identifier for your product package. + +Then create a Java class extending SDLActivity and place it in a directory +under src matching your package, e.g. + + src/com/gamemaker/game/MyGame.java + +Here's an example of a minimal class file: + + --- MyGame.java -------------------------- + package com.gamemaker.game; + + import org.libsdl.app.SDLActivity; + + /** + * A sample wrapper class that just calls SDLActivity + */ + + public class MyGame extends SDLActivity { } + + ------------------------------------------ + +Then replace "SDLActivity" in AndroidManifest.xml with the name of your +class, .e.g. "MyGame" + +================================================================================ + Customizing your application icon +================================================================================ + +Conceptually changing your icon is just replacing the "ic_launcher.png" files in +the drawable directories under the res directory. There are four directories for +different screen sizes. These can be replaced with one dir called "drawable", +containing an icon file "ic_launcher.png" with dimensions 48x48 or 72x72. + +You may need to change the name of your icon in AndroidManifest.xml to match +this icon filename. + +================================================================================ + Loading assets +================================================================================ + +Any files you put in the "assets" directory of your android-project directory +will get bundled into the application package and you can load them using the +standard functions in SDL_rwops.h. + +There are also a few Android specific functions that allow you to get other +useful paths for saving and loading data: +* SDL_AndroidGetInternalStoragePath() +* SDL_AndroidGetExternalStorageState() +* SDL_AndroidGetExternalStoragePath() + +See SDL_system.h for more details on these functions. + +The asset packaging system will, by default, compress certain file extensions. +SDL includes two asset file access mechanisms, the preferred one is the so +called "File Descriptor" method, which is faster and doesn't involve the Dalvik +GC, but given this method does not work on compressed assets, there is also the +"Input Stream" method, which is automatically used as a fall back by SDL. You +may want to keep this fact in mind when building your APK, specially when large +files are involved. +For more information on which extensions get compressed by default and how to +disable this behaviour, see for example: + +http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/ + +================================================================================ + Pause / Resume behaviour +================================================================================ + +If SDL is compiled with SDL_ANDROID_BLOCK_ON_PAUSE defined (the default), +the event loop will block itself when the app is paused (ie, when the user +returns to the main Android dashboard). Blocking is better in terms of battery +use, and it allows your app to spring back to life instantaneously after resume +(versus polling for a resume message). + +Upon resume, SDL will attempt to restore the GL context automatically. +In modern devices (Android 3.0 and up) this will most likely succeed and your +app can continue to operate as it was. + +However, there's a chance (on older hardware, or on systems under heavy load), +where the GL context can not be restored. In that case you have to listen for +a specific message, (which is not yet implemented!) and restore your textures +manually or quit the app (which is actually the kind of behaviour you'll see +under iOS, if the OS can not restore your GL context it will just kill your app) + +================================================================================ + Threads and the Java VM +================================================================================ + +For a quick tour on how Linux native threads interoperate with the Java VM, take +a look here: http://developer.android.com/guide/practices/jni.html + +If you want to use threads in your SDL app, it's strongly recommended that you +do so by creating them using SDL functions. This way, the required attach/detach +handling is managed by SDL automagically. If you have threads created by other +means and they make calls to SDL functions, make sure that you call +Android_JNI_SetupThread() before doing anything else otherwise SDL will attach +your thread automatically anyway (when you make an SDL call), but it'll never +detach it. + +================================================================================ + Using STL +================================================================================ + +You can use STL in your project by creating an Application.mk file in the jni +folder and adding the following line: + + APP_STL := stlport_static + +For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation. + +================================================================================ + Additional documentation +================================================================================ + +The documentation in the NDK docs directory is very helpful in understanding the +build process and how to work with native code on the Android platform. + +The best place to start is with docs/OVERVIEW.TXT + + +================================================================================ + Using Eclipse +================================================================================ + +First make sure that you've installed Eclipse and the Android extensions as described here: + http://developer.android.com/tools/sdk/eclipse-adt.html + +Once you've copied the SDL android project and customized it, you can create an Eclipse project from it: + * File -> New -> Other + * Select the Android -> Android Project wizard and click Next + * Enter the name you'd like your project to have + * Select "Create project from existing source" and browse for your project directory + * Make sure the Build Target is set to Android 3.1 (API 12) + * Click Finish + + +================================================================================ + Using the emulator +================================================================================ + +There are some good tips and tricks for getting the most out of the +emulator here: http://developer.android.com/tools/devices/emulator.html + +Especially useful is the info on setting up OpenGL ES 2.0 emulation. + +Notice that this software emulator is incredibly slow and needs a lot of disk space. +Using a real device works better. + +================================================================================ + Troubleshooting +================================================================================ + +You can create and run an emulator from the Eclipse IDE: + * Window -> Android SDK and AVD Manager + +You can see if adb can see any devices with the following command: + + adb devices + +You can see the output of log messages on the default device with: + + adb logcat + +You can push files to the device with: + + adb push local_file remote_path_and_file + +You can push files to the SD Card at /sdcard, for example: + + adb push moose.dat /sdcard/moose.dat + +You can see the files on the SD card with a shell command: + + adb shell ls /sdcard/ + +You can start a command shell on the default device with: + + adb shell + +You can remove the library files of your project (and not the SDL lib files) with: + + ndk-build clean + +You can do a build with the following command: + + ndk-build + +You can see the complete command line that ndk-build is using by passing V=1 on the command line: + + ndk-build V=1 + +If your application crashes in native code, you can use addr2line to convert the +addresses in the stack trace to lines in your code. + +For example, if your crash looks like this: + + I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0 + I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4 + I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c + I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c + I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030 + I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so + I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so + I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so + I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so + +You can see that there's a crash in the C library being called from the main code. +I run addr2line with the debug version of my code: + + arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so + +and then paste in the number after "pc" in the call stack, from the line that I care about: +000014bc + +I get output from addr2line showing that it's in the quit function, in testspriteminimal.c, on line 23. + +You can add logging to your code to help show what's happening: + + #include + + __android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x); + +If you need to build without optimization turned on, you can create a file called +"Application.mk" in the jni directory, with the following line in it: + + APP_OPTIM := debug + + +================================================================================ + Memory debugging +================================================================================ + +The best (and slowest) way to debug memory issues on Android is valgrind. +Valgrind has support for Android out of the box, just grab code using: + + svn co svn://svn.valgrind.org/valgrind/trunk valgrind + +... and follow the instructions in the file README.android to build it. + +One thing I needed to do on Mac OS X was change the path to the toolchain, +and add ranlib to the environment variables: +export RANLIB=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-ranlib + +Once valgrind is built, you can create a wrapper script to launch your +application with it, changing org.libsdl.app to your package identifier: + + --- start_valgrind_app ------------------- + #!/system/bin/sh + export TMPDIR=/data/data/org.libsdl.app + exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $* + ------------------------------------------ + +Then push it to the device: + + adb push start_valgrind_app /data/local + +and make it executable: + + adb shell chmod 755 /data/local/start_valgrind_app + +and tell Android to use the script to launch your application: + + adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app" + +If the setprop command says "could not set property", it's likely that +your package name is too long and you should make it shorter by changing +AndroidManifest.xml and the path to your class file in android-project/src + +You can then launch your application normally and waaaaaaaiiittt for it. +You can monitor the startup process with the logcat command above, and +when it's done (or even while it's running) you can grab the valgrind +output file: + + adb pull /sdcard/valgrind.log + +When you're done instrumenting with valgrind, you can disable the wrapper: + + adb shell setprop wrap.org.libsdl.app "" + +================================================================================ + Why is API level 10 the minimum required? +================================================================================ + +API level 10 is the minimum required level at runtime (that is, on the device) +because SDL requires some functionality for running not +available on older devices. Since the incorporation of joystick support into SDL, +the minimum SDK required to *build* SDL is version 12. Devices running API levels +10-11 are still supported, only with the joystick functionality disabled. + +Support for native OpenGL ES and ES2 applications was introduced in the NDK for +API level 4 and 8. EGL was made a stable API in the NDK for API level 9, which +has since then been obsoleted, with the recommendation to developers to bump the +required API level to 10. +As of this writing, according to http://developer.android.com/about/dashboards/index.html +about 90% of the Android devices accessing Google Play support API level 10 or +higher (March 2013). + +================================================================================ + A note regarding the use of the "dirty rectangles" rendering technique +================================================================================ + +If your app uses a variation of the "dirty rectangles" rendering technique, +where you only update a portion of the screen on each frame, you may notice a +variety of visual glitches on Android, that are not present on other platforms. +This is caused by SDL's use of EGL as the support system to handle OpenGL ES/ES2 +contexts, in particular the use of the eglSwapBuffers function. As stated in the +documentation for the function "The contents of ancillary buffers are always +undefined after calling eglSwapBuffers". +Setting the EGL_SWAP_BEHAVIOR attribute of the surface to EGL_BUFFER_PRESERVED +is not possible for SDL as it requires EGL 1.4, available only on the API level +17+, so the only workaround available on this platform is to redraw the entire +screen each frame. + +Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html + +================================================================================ + Known issues +================================================================================ + +- The number of buttons reported for each joystick is hardcoded to be 36, which +is the current maximum number of buttons Android can report. + diff --git a/#ThirdParty/libSDL/docs/README-cmake.md b/#ThirdParty/libSDL/docs/README-cmake.md new file mode 100644 index 0000000..5b440c5 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-cmake.md @@ -0,0 +1,32 @@ +CMake +================================================================================ +(www.cmake.org) + +SDL's build system was traditionally based on autotools. Over time, this +approach has suffered from several issues across the different supported +platforms. +To solve these problems, a new build system based on CMake is under development. +It works in parallel to the legacy system, so users can experiment with it +without complication. +While still experimental, the build system should be usable on the following +platforms: + +* FreeBSD +* Linux +* VS.NET 2010 +* MinGW and Msys +* OS X with support for XCode + + +================================================================================ +Usage +================================================================================ + +Assuming the source for SDL is located at ~/sdl + + cd ~ + mkdir build + cd build + cmake ../sdl + +This will build the static and dynamic versions of SDL in the ~/build directory. diff --git a/#ThirdParty/libSDL/docs/README-directfb.md b/#ThirdParty/libSDL/docs/README-directfb.md new file mode 100644 index 0000000..7df8bb8 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-directfb.md @@ -0,0 +1,107 @@ +DirectFB +======== + +Supports: + +- Hardware YUV overlays +- OpenGL - software only +- 2D/3D accelerations (depends on directfb driver) +- multiple displays +- windows + +What you need: + +* DirectFB 1.0.1, 1.2.x, 1.3.0 +* Kernel-Framebuffer support: required: vesafb, radeonfb .... +* Mesa 7.0.x - optional for OpenGL + +/etc/directfbrc + +This file should contain the following lines to make +your joystick work and avoid crashes: +------------------------ +disable-module=joystick +disable-module=cle266 +disable-module=cyber5k +no-linux-input-grab +------------------------ + +To disable to use x11 backend when DISPLAY variable is found use + +export SDL_DIRECTFB_X11_CHECK=0 + +To disable the use of linux input devices, i.e. multimice/multikeyboard support, +use + +export SDL_DIRECTFB_LINUX_INPUT=0 + +To use hardware accelerated YUV-overlays for YUV-textures, use: + +export SDL_DIRECTFB_YUV_DIRECT=1 + +This is disabled by default. It will only support one +YUV texture, namely the first. Every other YUV texture will be +rendered in software. + +In addition, you may use (directfb-1.2.x) + +export SDL_DIRECTFB_YUV_UNDERLAY=1 + +to make the YUV texture an underlay. This will make the cursor to +be shown. + +Simple Window Manager +===================== + +The driver has support for a very, very basic window manager you may +want to use when running with "wm=default". Use + +export SDL_DIRECTFB_WM=1 + +to enable basic window borders. In order to have the window title rendered, +you need to have the following font installed: + +/usr/share/fonts/truetype/freefont/FreeSans.ttf + +OpenGL Support +============== + +The following instructions will give you *software* OpenGL. However this +works at least on all directfb supported platforms. + +As of this writing 20100802 you need to pull Mesa from git and do the following: + +------------------------ +git clone git://anongit.freedesktop.org/git/mesa/mesa +cd mesa +git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a +------------------------ + +Edit configs/linux-directfb so that the Directories-section looks like +------------------------ +# Directories +SRC_DIRS = mesa glu +GLU_DIRS = sgi +DRIVER_DIRS = directfb +PROGRAM_DIRS = +------------------------ + +make linux-directfb +make + +echo Installing - please enter sudo pw. + +sudo make install INSTALL_DIR=/usr/local/dfb_GL +cd src/mesa/drivers/directfb +make +sudo make install INSTALL_DIR=/usr/local/dfb_GL +------------------------ + +To run the SDL - testprograms: + +export SDL_VIDEODRIVER=directfb +export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib +export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7 + +./testgl + diff --git a/#ThirdParty/libSDL/docs/README-dynapi.md b/#ThirdParty/libSDL/docs/README-dynapi.md new file mode 100644 index 0000000..bfaecb3 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-dynapi.md @@ -0,0 +1,130 @@ +Dynamic API +================================================================================ +Originally posted by Ryan at: + https://plus.google.com/103391075724026391227/posts/TB8UfnDYu4U + +Background: + +- The Steam Runtime has (at least in theory) a really kick-ass build of SDL2, + but developers are shipping their own SDL2 with individual Steam games. + These games might stop getting updates, but a newer SDL2 might be needed later. + Certainly we'll always be fixing bugs in SDL, even if a new video target isn't + ever needed, and these fixes won't make it to a game shipping its own SDL. +- Even if we replace the SDL2 in those games with a compatible one, that is to + say, edit a developer's Steam depot (yuck!), there are developers that are + statically linking SDL2 that we can't do this for. We can't even force the + dynamic loader to ignore their SDL2 in this case, of course. +- If you don't ship an SDL2 with the game in some form, people that disabled the + Steam Runtime, or just tried to run the game from the command line instead of + Steam might find themselves unable to run the game, due to a missing dependency. +- If you want to ship on non-Steam platforms like GOG or Humble Bundle, or target + generic Linux boxes that may or may not have SDL2 installed, you have to ship + the library or risk a total failure to launch. So now, you might have to have + a non-Steam build plus a Steam build (that is, one with and one without SDL2 + included), which is inconvenient if you could have had one universal build + that works everywhere. +- We like the zlib license, but the biggest complaint from the open source + community about the license change is the static linking. The LGPL forced this + as a legal, not technical issue, but zlib doesn't care. Even those that aren't + concerned about the GNU freedoms found themselves solving the same problems: + swapping in a newer SDL to an older game often times can save the day. + Static linking stops this dead. + +So here's what we did: + +SDL now has, internally, a table of function pointers. So, this is what SDL_Init +now looks like: + + UInt32 SDL_Init(Uint32 flags) + { + return jump_table.SDL_Init(flags); + } + +Except that is all done with a bunch of macro magic so we don't have to maintain +every one of these. + +What is jump_table.SDL_init()? Eventually, that's a function pointer of the real +SDL_Init() that you've been calling all this time. But at startup, it looks more +like this: + + Uint32 SDL_Init_DEFAULT(Uint32 flags) + { + SDL_InitDynamicAPI(); + return jump_table.SDL_Init(flags); + } + +SDL_InitDynamicAPI() fills in jump_table with all the actual SDL function +pointers, which means that this _DEFAULT function never gets called again. +First call to any SDL function sets the whole thing up. + +So you might be asking, what was the value in that? Isn't this what the operating +system's dynamic loader was supposed to do for us? Yes, but now we've got this +level of indirection, we can do things like this: + + export SDL_DYNAMIC_API=/my/actual/libSDL-2.0.so.0 + ./MyGameThatIsStaticallyLinkedToSDL2 + +And now, this game that is staticallly linked to SDL, can still be overridden +with a newer, or better, SDL. The statically linked one will only be used as +far as calling into the jump table in this case. But in cases where no override +is desired, the statically linked version will provide its own jump table, +and everyone is happy. + +So now: +- Developers can statically link SDL, and users can still replace it. + (We'd still rather you ship a shared library, though!) +- Developers can ship an SDL with their game, Valve can override it for, say, + new features on SteamOS, or distros can override it for their own needs, + but it'll also just work in the default case. +- Developers can ship the same package to everyone (Humble Bundle, GOG, etc), + and it'll do the right thing. +- End users (and Valve) can update a game's SDL in almost any case, + to keep abandoned games running on newer platforms. +- Everyone develops with SDL exactly as they have been doing all along. + Same headers, same ABI. Just get the latest version to enable this magic. + + +A little more about SDL_InitDynamicAPI(): + +Internally, InitAPI does some locking to make sure everything waits until a +single thread initializes everything (although even SDL_CreateThread() goes +through here before spinning a thread, too), and then decides if it should use +an external SDL library. If not, it sets up the jump table using the current +SDL's function pointers (which might be statically linked into a program, or in +a shared library of its own). If so, it loads that library and looks for and +calls a single function: + + SInt32 SDL_DYNAPI_entry(Uint32 version, void *table, Uint32 tablesize); + +That function takes a version number (more on that in a moment), the address of +the jump table, and the size, in bytes, of the table. +Now, we've got policy here: this table's layout never changes; new stuff gets +added to the end. Therefore SDL_DYNAPI_entry() knows that it can provide all +the needed functions if tablesize <= sizeof its own jump table. If tablesize is +bigger (say, SDL 2.0.4 is trying to load SDL 2.0.3), then we know to abort, but +if it's smaller, we know we can provide the entire API that the caller needs. + +The version variable is a failsafe switch. +Right now it's always 1. This number changes when there are major API changes +(so we know if the tablesize might be smaller, or entries in it have changed). +Right now SDL_DYNAPI_entry gives up if the version doesn't match, but it's not +inconceivable to have a small dispatch library that only supplies this one +function and loads different, otherwise-incompatible SDL libraries and has the +right one initialize the jump table based on the version. For something that +must generically catch lots of different versions of SDL over time, like the +Steam Client, this isn't a bad option. + +Finally, I'm sure some people are reading this and thinking, +"I don't want that overhead in my project!" +To which I would point out that the extra function call through the jump table +probably wouldn't even show up in a profile, but lucky you: this can all be +disabled. You can build SDL without this if you absolutely must, but we would +encourage you not to do that. However, on heavily locked down platforms like +iOS, or maybe when debugging, it makes sense to disable it. The way this is +designed in SDL, you just have to change one #define, and the entire system +vaporizes out, and SDL functions exactly like it always did. Most of it is +macro magic, so the system is contained to one C file and a few headers. +However, this is on by default and you have to edit a header file to turn it +off. Our hopes is that if we make it easy to disable, but not too easy, +everyone will ultimately be able to get what they want, but we've gently +nudged everyone towards what we think is the best solution. diff --git a/#ThirdParty/libSDL/docs/README-emscripten.md b/#ThirdParty/libSDL/docs/README-emscripten.md new file mode 100644 index 0000000..62012db --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-emscripten.md @@ -0,0 +1,37 @@ +Emscripten +================================================================================ + +Build: + + $ mkdir build + $ cd build + $ emconfigure ../configure --host=asmjs-unknown-emscripten --disable-assembly --disable-threads --enable-cpuinfo=false CFLAGS="-O2" + $ emmake make + +Or with cmake: + + $ mkdir build + $ cd build + $ emcmake cmake .. + $ emmake make + +To build one of the tests: + + $ cd test/ + $ emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html + +Uses GLES2 renderer or software + +tests: https://dl.dropboxusercontent.com/u/17360362/SDL2-em/index.html + +Some other SDL2 libraries can be easily built (assuming SDL2 is installed somewhere): + +SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/): + + $ EMCONFIGURE_JS=1 emconfigure ../configure + build as usual... + +SDL_gfx (http://cms.ferzkopp.net/index.php/software/13-sdl-gfx): + + $ EMCONFIGURE_JS=1 emconfigure ../configure --disable-mmx + build as usual... diff --git a/#ThirdParty/libSDL/docs/README-gesture.md b/#ThirdParty/libSDL/docs/README-gesture.md new file mode 100644 index 0000000..7e9f95b --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-gesture.md @@ -0,0 +1,71 @@ +Dollar Gestures +=========================================================================== +SDL provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures. + +Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up. + +Dollar gestures are assigned an Id based on a hash function. This is guaranteed to remain constant for a given gesture. There is a (small) chance that two different gestures will be assigned the same ID. In this case, simply re-recording one of the gestures should result in a different ID. + +Recording: +---------- +To begin recording on a touch device call: +SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch device you wish to record on, or -1 to record on all connected devices. + +Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event. +A SDL_DOLLARRECORD event is a dgesture with the following fields: + +* event.dgesture.touchId - the Id of the touch used to record the gesture. +* event.dgesture.gestureId - the unique id of the recorded gesture. + + +Performing: +----------- +As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields: + +* event.dgesture.touchId - the Id of the touch which performed the gesture. +* event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke. +* event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match. +* event.dgesture.numFingers - the number of fingers used to draw the stroke. + +Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed). + + + +Saving: +------- +To save a template, call SDL_SaveDollarTemplate(gestureId, dst) where gestureId is the id of the gesture you want to save, and dst is an SDL_RWops pointer to the file where the gesture will be stored. + +To save all currently loaded templates, call SDL_SaveAllDollarTemplates(dst) where dst is an SDL_RWops pointer to the file where the gesture will be stored. + +Both functions return the number of gestures successfully saved. + + +Loading: +-------- +To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file. + +SDL_LoadDollarTemplates returns the number of templates successfully loaded. + + + +=========================================================================== +Multi Gestures +=========================================================================== +SDL provides simple support for pinch/rotate/swipe gestures. +Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields: + +* event.mgesture.touchId - the Id of the touch on which the gesture was performed. +* event.mgesture.x - the normalized x coordinate of the gesture. (0..1) +* event.mgesture.y - the normalized y coordinate of the gesture. (0..1) +* event.mgesture.dTheta - the amount that the fingers rotated during this motion. +* event.mgesture.dDist - the amount that the fingers pinched during this motion. +* event.mgesture.numFingers - the number of fingers used in the gesture. + + +=========================================================================== +Notes +=========================================================================== +For a complete example see test/testgesture.c + +Please direct questions/comments to: + jim.tla+sdl_touch@gmail.com diff --git a/#ThirdParty/libSDL/docs/README-hg.md b/#ThirdParty/libSDL/docs/README-hg.md new file mode 100644 index 0000000..6e18bab --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-hg.md @@ -0,0 +1,25 @@ +Mercurial +========= + +The latest development version of SDL is available via Mercurial. +Mercurial allows you to get up-to-the-minute fixes and enhancements; +as a developer works on a source tree, you can use "hg" to mirror that +source tree instead of waiting for an official release. Please look +at the Mercurial website ( http://mercurial.selenic.com/ ) for more +information on using hg, where you can also download software for +Mac OS X, Windows, and Unix systems. + + hg clone http://hg.libsdl.org/SDL + +If you are building SDL with an IDE, you will need to copy the file +include/SDL_config.h.default to include/SDL_config.h before building. + +If you are building SDL via configure, you will need to run autogen.sh +before running configure. + +There is a web interface to the subversion repository at: + http://hg.libsdl.org/SDL/ + +There is an RSS feed available at that URL, for those that want to +track commits in real time. + diff --git a/#ThirdParty/libSDL/docs/README-ios.md b/#ThirdParty/libSDL/docs/README-ios.md new file mode 100644 index 0000000..a0afffb --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-ios.md @@ -0,0 +1,266 @@ +iOS +====== + +============================================================================== +Building the Simple DirectMedia Layer for iOS 5.1+ +============================================================================== + +Requirements: Mac OS X 10.8 or later and the iOS 7+ SDK. + +Instructions: +1. Open SDL.xcodeproj (located in Xcode-iOS/SDL) in Xcode. +2. Select your desired target, and hit build. + +There are three build targets: +- libSDL.a: + Build SDL as a statically linked library +- testsdl: + Build a test program (there are known test failures which are fine) +- Template: + Package a project template together with the SDL for iPhone static libraries and copies of the SDL headers. The template includes proper references to the SDL library and headers, skeleton code for a basic SDL program, and placeholder graphics for the application icon and startup screen. + + +============================================================================== +Build SDL for iOS from the command line +============================================================================== + +1. cd (PATH WHERE THE SDL CODE IS)/build-scripts +2. ./iosbuild.sh + +If everything goes fine, you should see a build/ios directory, inside there's +two directories "lib" and "include". +"include" contains a copy of the SDL headers that you'll need for your project, +make sure to configure XCode to look for headers there. +"lib" contains find two files, libSDL2.a and libSDL2main.a, you have to add both +to your XCode project. These libraries contain three architectures in them, +armv6 for legacy devices, armv7, and i386 (for the simulator). +By default, iosbuild.sh will autodetect the SDK version you have installed using +xcodebuild -showsdks, and build for iOS >= 3.0, you can override this behaviour +by setting the MIN_OS_VERSION variable, ie: + +MIN_OS_VERSION=4.2 ./iosbuild.sh + +============================================================================== +Using the Simple DirectMedia Layer for iOS +============================================================================== + +FIXME: This needs to be updated for the latest methods + +Here is the easiest method: +1. Build the SDL library (libSDL2.a) and the iPhone SDL Application template. +2. Install the iPhone SDL Application template by copying it to one of Xcode's template directories. I recommend creating a directory called "SDL" in "/Developer/Platforms/iOS.platform/Developer/Library/Xcode/Project Templates/" and placing it there. +3. Start a new project using the template. The project should be immediately ready for use with SDL. + +Here is a more manual method: +1. Create a new iOS view based application. +2. Build the SDL static library (libSDL2.a) for iOS and include them in your project. Xcode will ignore the library that is not currently of the correct architecture, hence your app will work both on iOS and in the iOS Simulator. +3. Include the SDL header files in your project. +4. Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iOS provides its own UIApplicationDelegate. Remove MainWindow.xib -- SDL for iOS produces its user interface programmatically. +5. Delete the contents of main.m and program your app as a regular SDL program instead. You may replace main.m with your own main.c, but you must tell Xcode not to use the project prefix file, as it includes Objective-C code. + +============================================================================== +Notes -- Retina / High-DPI and window sizes +============================================================================== + +Window and display mode sizes in SDL are in "screen coordinates" (or "points", +in Apple's terminology) rather than in pixels. On iOS this means that a window +created on an iPhone 6 will have a size in screen coordinates of 375 x 667, +rather than a size in pixels of 750 x 1334. All iOS apps are expected to +size their content based on screen coordinates / points rather than pixels, +as this allows different iOS devices to have different pixel densities +(Retina versus non-Retina screens, etc.) without apps caring too much. + +By default SDL will not use the full pixel density of the screen on +Retina/high-dpi capable devices. Use the SDL_WINDOW_ALLOW_HIGHDPI flag when +creating your window to enable high-dpi support. + +When high-dpi support is enabled, SDL_GetWindowSize and display mode sizes +will still be in "screen coordinates" rather than pixels, but the window will +have a much greater pixel density when the device supports it, and the +SDL_GL_GetDrawableSize or SDL_GetRendererOutputSize functions (depending on +whether raw OpenGL or the SDL_Render API is used) can be queried to determine +the size in pixels of the drawable screen framebuffer. + +Some OpenGL ES functions such as glViewport expect sizes in pixels rather than +sizes in screen coordinates. When doing 2D rendering with OpenGL ES, an +orthographic projection matrix using the size in screen coordinates +(SDL_GetWindowSize) can be used in order to display content at the same scale +no matter whether a Retina device is used or not. + +============================================================================== +Notes -- Application events +============================================================================== + +On iOS the application goes through a fixed life cycle and you will get +notifications of state changes via application events. When these events +are delivered you must handle them in an event callback because the OS may +not give you any processing time after the events are delivered. + +e.g. + + int HandleAppEvents(void *userdata, SDL_Event *event) + { + switch (event->type) + { + case SDL_APP_TERMINATING: + /* Terminate the app. + Shut everything down before returning from this function. + */ + return 0; + case SDL_APP_LOWMEMORY: + /* You will get this when your app is paused and iOS wants more memory. + Release as much memory as possible. + */ + return 0; + case SDL_APP_WILLENTERBACKGROUND: + /* Prepare your app to go into the background. Stop loops, etc. + This gets called when the user hits the home button, or gets a call. + */ + return 0; + case SDL_APP_DIDENTERBACKGROUND: + /* This will get called if the user accepted whatever sent your app to the background. + If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops. + When you get this, you have 5 seconds to save all your state or the app will be terminated. + Your app is NOT active at this point. + */ + return 0; + case SDL_APP_WILLENTERFOREGROUND: + /* This call happens when your app is coming back to the foreground. + Restore all your state here. + */ + return 0; + case SDL_APP_DIDENTERFOREGROUND: + /* Restart your loops here. + Your app is interactive and getting CPU again. + */ + return 0; + default: + /* No special processing, add it to the event queue */ + return 1; + } + } + + int main(int argc, char *argv[]) + { + SDL_SetEventFilter(HandleAppEvents, NULL); + + ... run your main loop + + return 0; + } + + +============================================================================== +Notes -- Accelerometer as Joystick +============================================================================== + +SDL for iPhone supports polling the built in accelerometer as a joystick device. For an example on how to do this, see the accelerometer.c in the demos directory. + +The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_JoystickGetAxis reports joystick values as signed integers. Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver. To convert SDL_JoystickGetAxis reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF. + +============================================================================== +Notes -- OpenGL ES +============================================================================== + +Your SDL application for iOS uses OpenGL ES for video by default. + +OpenGL ES for iOS supports several display pixel formats, such as RGBA8 and RGB565, which provide a 32 bit and 16 bit color buffer respectively. By default, the implementation uses RGB565, but you may use RGBA8 by setting each color component to 8 bits in SDL_GL_SetAttribute. + +If your application doesn't use OpenGL's depth buffer, you may find significant performance improvement by setting SDL_GL_DEPTH_SIZE to 0. + +Finally, if your application completely redraws the screen each frame, you may find significant performance improvement by setting the attribute SDL_GL_RETAINED_BACKING to 0. + +OpenGL ES on iOS doesn't use the traditional system-framebuffer setup provided in other operating systems. Special care must be taken because of this: + +- The drawable Renderbuffer must be bound to the GL_RENDERBUFFER binding point when SDL_GL_SwapWindow is called. +- The drawable Framebuffer Object must be bound while rendering to the screen and when SDL_GL_SwapWindow is called. +- If multisample antialiasing (MSAA) is used and glReadPixels is used on the screen, the drawable framebuffer must be resolved to the MSAA resolve framebuffer (via glBlitFramebuffer or glResolveMultisampleFramebufferAPPLE), and the MSAA resolve framebuffer must be bound to the GL_READ_FRAMEBUFFER binding point, before glReadPixels is called. + +The above objects can be obtained via SDL_GetWindowWMInfo (in SDL_syswm.h). + +============================================================================== +Notes -- Keyboard +============================================================================== + +The SDL keyboard API has been extended to support on-screen keyboards: + +void SDL_StartTextInput() + -- enables text events and reveals the onscreen keyboard. + +void SDL_StopTextInput() + -- disables text events and hides the onscreen keyboard. + +SDL_bool SDL_IsTextInputActive() + -- returns whether or not text events are enabled (and the onscreen keyboard is visible) + + +============================================================================== +Notes -- Reading and Writing files +============================================================================== + +Each application installed on iPhone resides in a sandbox which includes its own Application Home directory. Your application may not access files outside this directory. + +Once your application is installed its directory tree looks like: + + MySDLApp Home/ + MySDLApp.app + Documents/ + Library/ + Preferences/ + tmp/ + +When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences". + +More information on this subject is available here: +http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html + +============================================================================== +Notes -- iPhone SDL limitations +============================================================================== + +Windows: + Full-size, single window applications only. You cannot create multi-window SDL applications for iPhone OS. The application window will fill the display, though you have the option of turning on or off the menu-bar (pass SDL_CreateWindow the flag SDL_WINDOW_BORDERLESS). + +Textures: + The optimal texture formats on iOS are SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, and SDL_PIXELFORMAT_RGB24 pixel formats. + +Loading Shared Objects: + This is disabled by default since it seems to break the terms of the iOS SDK agreement for iOS versions prior to iOS 8. It can be re-enabled in SDL_config_iphoneos.h. + +============================================================================== +Game Center +============================================================================== + +Game Center integration might require that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using: + + int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam); + +This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run. + +e.g. + + extern "C" + void ShowFrame(void*) + { + ... do event handling, frame logic and rendering ... + } + + int main(int argc, char *argv[]) + { + ... initialize game ... + + #if __IPHONEOS__ + // Initialize the Game Center for scoring and matchmaking + InitGameCenter(); + + // Set up the game to run in the window animation callback on iOS + // so that Game Center and so forth works correctly. + SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL); + #else + while ( running ) { + ShowFrame(0); + DelayFrame(); + } + #endif + return 0; + } diff --git a/#ThirdParty/libSDL/docs/README-linux.md b/#ThirdParty/libSDL/docs/README-linux.md new file mode 100644 index 0000000..fddabf5 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-linux.md @@ -0,0 +1,82 @@ +Linux +================================================================================ + +By default SDL will only link against glibc, the rest of the features will be +enabled dynamically at runtime depending on the available features on the target +system. So, for example if you built SDL with Xinerama support and the target +system does not have the Xinerama libraries installed, it will be disabled +at runtime, and you won't get a missing library error, at least with the +default configuration parameters. + + +================================================================================ +Build Dependencies +================================================================================ + +Ubuntu 13.04, all available features enabled: + +sudo apt-get install build-essential mercurial make cmake autoconf automake \ +libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev \ +libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev \ +libxss-dev libgl1-mesa-dev libesd0-dev libdbus-1-dev libudev-dev \ +libgles1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev + +Ubuntu 14.04 can also add "libwayland-dev libmirclient-dev libxkbcommon-dev" +to that command line for Wayland and Mir support. + +NOTES: +- This includes all the audio targets except arts, because Ubuntu pulled the + artsc0-dev package, but in theory SDL still supports it. +- DirectFB isn't included because the configure script (currently) fails to find + it at all. You can do "sudo apt-get install libdirectfb-dev" and fix the + configure script to include DirectFB support. Send patches. :) + + +================================================================================ +Joystick does not work +================================================================================ + +If you compiled or are using a version of SDL with udev support (and you should!) +there's a few issues that may cause SDL to fail to detect your joystick. To +debug this, start by installing the evtest utility. On Ubuntu/Debian: + + sudo apt-get install evtest + +Then run: + + sudo evtest + +You'll hopefully see your joystick listed along with a name like "/dev/input/eventXX" +Now run: + + cat /dev/input/event/XX + +If you get a permission error, you need to set a udev rule to change the mode of +your device (see below) + +Also, try: + + sudo udevadm info --query=all --name=input/eventXX + +If you see a line stating ID_INPUT_JOYSTICK=1, great, if you don't see it, +you need to set up an udev rule to force this variable. + +A combined rule for the Saitek Pro Flight Rudder Pedals to fix both issues looks +like: + + SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1" + SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1" + +You can set up similar rules for your device by changing the values listed in +idProduct and idVendor. To obtain these values, try: + + sudo udevadm info -a --name=input/eventXX | grep idVendor + sudo udevadm info -a --name=input/eventXX | grep idProduct + +If multiple values come up for each of these, the one you want is the first one of each. + +On other systems which ship with an older udev (such as CentOS), you may need +to set up a rule such as: + + SUBSYSTEM=="input", ENV{ID_CLASS}=="joystick", ENV{ID_INPUT_JOYSTICK}="1" + diff --git a/#ThirdParty/libSDL/docs/README-macosx.md b/#ThirdParty/libSDL/docs/README-macosx.md new file mode 100644 index 0000000..747e1e6 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-macosx.md @@ -0,0 +1,230 @@ +Mac OS X +============================================================================== + +These instructions are for people using Apple's Mac OS X (pronounced +"ten"). + +From the developer's point of view, OS X is a sort of hybrid Mac and +Unix system, and you have the option of using either traditional +command line tools or Apple's IDE Xcode. + +To build SDL using the command line, use the standard configure and make +process: + + ./configure + make + sudo make install + +You can also build SDL as a Universal library (a single binary for both +32-bit and 64-bit Intel architectures), on Mac OS X 10.7 and newer, by using +the gcc-fat.sh script in build-scripts: + + mkdir mybuild + cd mybuild + CC=$PWD/../build-scripts/gcc-fat.sh CXX=$PWD/../build-scripts/g++fat.sh ../configure + make + sudo make install + +This script builds SDL with 10.5 ABI compatibility on i386 and 10.6 +ABI compatibility on x86_64 architectures. For best compatibility you +should compile your application the same way. + +Please note that building SDL requires at least Xcode 4.6 and the 10.7 SDK +(even if you target back to 10.5 systems). PowerPC support for Mac OS X has +been officially dropped as of SDL 2.0.2. + +To use the library once it's built, you essential have two possibilities: +use the traditional autoconf/automake/make method, or use Xcode. + +============================================================================== +Caveats for using SDL with Mac OS X +============================================================================== + +Some things you have to be aware of when using SDL on Mac OS X: + +- If you register your own NSApplicationDelegate (using [NSApp setDelegate:]), + SDL will not register its own. This means that SDL will not terminate using + SDL_Quit if it receives a termination request, it will terminate like a + normal app, and it will not send a SDL_DROPFILE when you request to open a + file with the app. To solve these issues, put the following code in your + NSApplicationDelegate implementation: + + + - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender + { + if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_QUIT; + SDL_PushEvent(&event); + } + + return NSTerminateCancel; + } + + - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename + { + if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_DROPFILE; + event.drop.file = SDL_strdup([filename UTF8String]); + return (SDL_PushEvent(&event) > 0); + } + + return NO; + } + +============================================================================== +Using the Simple DirectMedia Layer with a traditional Makefile +============================================================================== + +An existing autoconf/automake build system for your SDL app has good chances +to work almost unchanged on OS X. However, to produce a "real" Mac OS X binary +that you can distribute to users, you need to put the generated binary into a +so called "bundle", which basically is a fancy folder with a name like +"MyCoolGame.app". + +To get this build automatically, add something like the following rule to +your Makefile.am: + +bundle_contents = APP_NAME.app/Contents +APP_NAME_bundle: EXE_NAME + mkdir -p $(bundle_contents)/MacOS + mkdir -p $(bundle_contents)/Resources + echo "APPL????" > $(bundle_contents)/PkgInfo + $(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/ + +You should replace EXE_NAME with the name of the executable. APP_NAME is what +will be visible to the user in the Finder. Usually it will be the same +as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME +usually is "TestGame". You might also want to use @PACKAGE@ to use the package +name as specified in your configure.in file. + +If your project builds more than one application, you will have to do a bit +more. For each of your target applications, you need a separate rule. + +If you want the created bundles to be installed, you may want to add this +rule to your Makefile.am: + +install-exec-hook: APP_NAME_bundle + rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app + mkdir -p $(DESTDIR)$(prefix)/Applications/ + cp -r $< /$(DESTDIR)$(prefix)Applications/ + +This rule takes the Bundle created by the rule from step 3 and installs them +into $(DESTDIR)$(prefix)/Applications/. + +Again, if you want to install multiple applications, you will have to augment +the make rule accordingly. + + +But beware! That is only part of the story! With the above, you end up with +a bare bone .app bundle, which is double clickable from the Finder. But +there are some more things you should do before shipping your product... + +1) The bundle right now probably is dynamically linked against SDL. That + means that when you copy it to another computer, *it will not run*, + unless you also install SDL on that other computer. A good solution + for this dilemma is to static link against SDL. On OS X, you can + achieve that by linking against the libraries listed by + sdl-config --static-libs + instead of those listed by + sdl-config --libs + Depending on how exactly SDL is integrated into your build systems, the + way to achieve that varies, so I won't describe it here in detail +2) Add an 'Info.plist' to your application. That is a special XML file which + contains some meta-information about your application (like some copyright + information, the version of your app, the name of an optional icon file, + and other things). Part of that information is displayed by the Finder + when you click on the .app, or if you look at the "Get Info" window. + More information about Info.plist files can be found on Apple's homepage. + + +As a final remark, let me add that I use some of the techniques (and some +variations of them) in Exult and ScummVM; both are available in source on +the net, so feel free to take a peek at them for inspiration! + + +============================================================================== +Using the Simple DirectMedia Layer with Xcode +============================================================================== + +These instructions are for using Apple's Xcode IDE to build SDL applications. + +- First steps + +The first thing to do is to unpack the Xcode.tar.gz archive in the +top level SDL directory (where the Xcode.tar.gz archive resides). +Because Stuffit Expander will unpack the archive into a subdirectory, +you should unpack the archive manually from the command line: + cd [path_to_SDL_source] + tar zxf Xcode.tar.gz +This will create a new folder called Xcode, which you can browse +normally from the Finder. + +- Building the Framework + +The SDL Library is packaged as a framework bundle, an organized +relocatable folder hierarchy of executable code, interface headers, +and additional resources. For practical purposes, you can think of a +framework as a more user and system-friendly shared library, whose library +file behaves more or less like a standard UNIX shared library. + +To build the framework, simply open the framework project and build it. +By default, the framework bundle "SDL.framework" is installed in +/Library/Frameworks. Therefore, the testers and project stationary expect +it to be located there. However, it will function the same in any of the +following locations: + + ~/Library/Frameworks + /Local/Library/Frameworks + /System/Library/Frameworks + +- Build Options + There are two "Build Styles" (See the "Targets" tab) for SDL. + "Deployment" should be used if you aren't tweaking the SDL library. + "Development" should be used to debug SDL apps or the library itself. + +- Building the Testers + Open the SDLTest project and build away! + +- Using the Project Stationary + Copy the stationary to the indicated folders to access it from + the "New Project" and "Add target" menus. What could be easier? + +- Setting up a new project by hand + Some of you won't want to use the Stationary so I'll give some tips: + * Create a new "Cocoa Application" + * Add src/main/macosx/SDLMain.m , .h and .nib to your project + * Remove "main.c" from your project + * Remove "MainMenu.nib" from your project + * Add "$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path + * Add "$(HOME)/Library/Frameworks" to the frameworks search path + * Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS" + * Set the "Main Nib File" under "Application Settings" to "SDLMain.nib" + * Add your files + * Clean and build + +- Building from command line + Use pbxbuild in the same directory as your .pbproj file + +- Running your app + You can send command line args to your app by either invoking it from + the command line (in *.app/Contents/MacOS) or by entering them in the + "Executables" panel of the target settings. + +- Implementation Notes + Some things that may be of interest about how it all works... + * Working directory + As defined in the SDL_main.m file, the working directory of your SDL app + is by default set to its parent. You may wish to change this to better + suit your needs. + * You have a Cocoa App! + Your SDL app is essentially a Cocoa application. When your app + starts up and the libraries finish loading, a Cocoa procedure is called, + which sets up the working directory and calls your main() method. + You are free to modify your Cocoa app with generally no consequence + to SDL. You cannot, however, easily change the SDL window itself. + Functionality may be added in the future to help this. + + +Known bugs are listed in the file "BUGS" diff --git a/#ThirdParty/libSDL/docs/README-nacl.md b/#ThirdParty/libSDL/docs/README-nacl.md new file mode 100644 index 0000000..4c9432b --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-nacl.md @@ -0,0 +1,103 @@ +Native Client +================================================================================ + +Requirements: + +* Native Client SDK (https://developer.chrome.com/native-client), + (tested with Pepper version 33 or higher). + +The SDL backend for Chrome's Native Client has been tested only with the PNaCl +toolchain, which generates binaries designed to run on ARM and x86_32/64 +platforms. This does not mean it won't work with the other toolchains! + +================================================================================ +Building SDL for NaCl +================================================================================ + +Set up the right environment variables (see naclbuild.sh), then configure SDL with: + + configure --host=pnacl --prefix some/install/destination + +Then "make". + +As an example of how to create a deployable app a Makefile project is provided +in test/nacl/Makefile, which includes some monkey patching of the common.mk file +provided by NaCl, without which linking properly to SDL won't work (the search +path can't be modified externally, so the linker won't find SDL's binaries unless +you dump them into the SDK path, which is inconvenient). +Also provided in test/nacl is the required support file, such as index.html, +manifest.json, etc. +SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure. +This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem), +hiding the asynchronous nature of the browser behind the scenes...which is not the +same as making it disappear! + + +================================================================================ +Running tests +================================================================================ + +Due to the nature of NaCl programs, building and running SDL tests is not as +straightforward as one would hope. The script naclbuild.sh in build-scripts +automates the process and should serve as a guide for users of SDL trying to build +their own applications. + +Basic usage: + + ./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35) + +This will build testgles2.c by default. + +If you want to build a different test, for example testrendercopyex.c: + + SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35 + +Once the build finishes, you have to serve the contents with a web server (the +script will give you instructions on how to do that with Python). + +================================================================================ +RWops and nacl_io +================================================================================ + +SDL_RWops work transparently with nacl_io. Two functions control the mount points: + + int mount(const char* source, const char* target, + const char* filesystemtype, + unsigned long mountflags, const void *data); + int umount(const char *target); + + For convenience, SDL will by default mount an httpfs tree at / before calling +the app's main function. Such setting can be overridden by calling: + + umount("/"); + +And then mounting a different filesystem at / + +It's important to consider that the asynchronous nature of file operations on a +browser is hidden from the application, effectively providing the developer with +a set of blocking file operations just like you get in a regular desktop +environment, which eases the job of porting to Native Client, but also introduces +a set of challenges of its own, in particular when big file sizes and slow +connections are involved. + +For more information on how nacl_io and mount points work, see: + + https://developer.chrome.com/native-client/devguide/coding/nacl_io + https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h + +To be able to save into the directory "/save/" (like backup of game) : + + mount("", "/save", "html5fs", 0, "type=PERSISTENT"); + +And add to manifest.json : + + "permissions": [ + "unlimitedStorage" + ] + +================================================================================ +TODO - Known Issues +================================================================================ +* Testing of all systems with a real application (something other than SDL's tests) +* Key events don't seem to work properly + diff --git a/#ThirdParty/libSDL/docs/README-pandora.md b/#ThirdParty/libSDL/docs/README-pandora.md new file mode 100644 index 0000000..e50e0c2 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-pandora.md @@ -0,0 +1,17 @@ +Pandora +===================================================================== + +( http://openpandora.org/ ) +- A pandora specific video driver was written to allow SDL 2.0 with OpenGL ES +support to work on the pandora under the framebuffer. This driver do not have +input support for now, so if you use it you will have to add your own control code. +The video driver name is "pandora" so if you have problem running it from +the framebuffer, try to set the following variable before starting your application : +"export SDL_VIDEODRIVER=pandora" + +- OpenGL ES support was added to the x11 driver, so it's working like the normal +x11 driver one with OpenGLX support, with SDL input event's etc.. + + +David Carré (Cpasjuste) +cpasjuste@gmail.com diff --git a/#ThirdParty/libSDL/docs/README-platforms.md b/#ThirdParty/libSDL/docs/README-platforms.md new file mode 100644 index 0000000..14454ec --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-platforms.md @@ -0,0 +1,8 @@ +Platforms +========= + +We maintain the list of supported platforms on our wiki now, and how to +build and install SDL for those platforms: + + https://wiki.libsdl.org/Installation + diff --git a/#ThirdParty/libSDL/docs/README-porting.md b/#ThirdParty/libSDL/docs/README-porting.md new file mode 100644 index 0000000..f13f83b --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-porting.md @@ -0,0 +1,64 @@ +Porting +======= + +* Porting To A New Platform + + The first thing you have to do when porting to a new platform, is look at +include/SDL_platform.h and create an entry there for your operating system. +The standard format is __PLATFORM__, where PLATFORM is the name of the OS. +Ideally SDL_platform.h will be able to auto-detect the system it's building +on based on C preprocessor symbols. + +There are two basic ways of building SDL at the moment: + +1. The "UNIX" way: ./configure; make; make install + + If you have a GNUish system, then you might try this. Edit configure.in, + take a look at the large section labelled: + "Set up the configuration based on the host platform!" + Add a section for your platform, and then re-run autogen.sh and build! + +2. Using an IDE: + + If you're using an IDE or other non-configure build system, you'll probably + want to create a custom SDL_config.h for your platform. Edit SDL_config.h, + add a section for your platform, and create a custom SDL_config_{platform}.h, + based on SDL_config.h.minimal and SDL_config.h.in + + Add the top level include directory to the header search path, and then add + the following sources to the project: + src/*.c + src/atomic/*.c + src/audio/*.c + src/cpuinfo/*.c + src/events/*.c + src/file/*.c + src/haptic/*.c + src/joystick/*.c + src/power/*.c + src/render/*.c + src/stdlib/*.c + src/thread/*.c + src/timer/*.c + src/video/*.c + src/audio/disk/*.c + src/audio/dummy/*.c + src/filesystem/dummy/*.c + src/video/dummy/*.c + src/haptic/dummy/*.c + src/joystick/dummy/*.c + src/main/dummy/*.c + src/thread/generic/*.c + src/timer/dummy/*.c + src/loadso/dummy/*.c + + +Once you have a working library without any drivers, you can go back to each +of the major subsystems and start implementing drivers for your platform. + +If you have any questions, don't hesitate to ask on the SDL mailing list: + http://www.libsdl.org/mailing-list.php + +Enjoy! + Sam Lantinga (slouken@libsdl.org) + diff --git a/#ThirdParty/libSDL/docs/README-psp.md b/#ThirdParty/libSDL/docs/README-psp.md new file mode 100644 index 0000000..41fc904 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-psp.md @@ -0,0 +1,19 @@ +PSP +====== +SDL port for the Sony PSP contributed by + Captian Lex + +Credit to + Marcus R.Brown,Jim Paris,Matthew H for the original SDL 1.2 for PSP + Geecko for his PSP GU lib "Glib2d" + +Building +-------- +To build for the PSP, make sure psp-config is in the path and run: + make -f Makefile.psp + + + +To Do +------ +PSP Screen Keyboard diff --git a/#ThirdParty/libSDL/docs/README-raspberrypi.md b/#ThirdParty/libSDL/docs/README-raspberrypi.md new file mode 100644 index 0000000..ade3c81 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-raspberrypi.md @@ -0,0 +1,178 @@ +Raspberry Pi +================================================================================ + +Requirements: + +Raspbian (other Linux distros may work as well). + +================================================================================ + Features +================================================================================ + +* Works without X11 +* Hardware accelerated OpenGL ES 2.x +* Sound via ALSA +* Input (mouse/keyboard/joystick) via EVDEV +* Hotplugging of input devices via UDEV + + +================================================================================ + Raspbian Build Dependencies +================================================================================ + +sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev + +You also need the VideoCore binary stuff that ships in /opt/vc for EGL and +OpenGL ES 2.x, it usually comes pre installed, but in any case: + +sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev + +================================================================================ + Cross compiling from x86 Linux +================================================================================ + +To cross compile SDL for Raspbian from your desktop machine, you'll need a +Raspbian system root and the cross compilation tools. We'll assume these tools +will be placed in /opt/rpi-tools + + sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools + +You'll also need a Rasbian binary image. +Get it from: http://downloads.raspberrypi.org/raspbian_latest +After unzipping, you'll get file with a name like: -wheezy-raspbian.img +Let's assume the sysroot will be built in /opt/rpi-sysroot. + + export SYSROOT=/opt/rpi-sysroot + sudo kpartx -a -v .img + sudo mount -o loop /dev/mapper/loop0p2 /mnt + sudo cp -r /mnt $SYSROOT + sudo apt-get install qemu binfmt-support qemu-user-static + sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin + sudo mount --bind /dev $SYSROOT/dev + sudo mount --bind /proc $SYSROOT/proc + sudo mount --bind /sys $SYSROOT/sys + +Now, before chrooting into the ARM sysroot, you'll need to apply a workaround, +edit $SYSROOT/etc/ld.so.preload and comment out all lines in it. + + sudo chroot $SYSROOT + apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev + exit + sudo umount $SYSROOT/dev + sudo umount $SYSROOT/proc + sudo umount $SYSROOT/sys + sudo umount /mnt + +There's one more fix required, as the libdl.so symlink uses an absolute path +which doesn't quite work in our setup. + + sudo rm -rf $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so + sudo ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so + +The final step is compiling SDL itself. + + export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux" + cd + mkdir -p build;cd build + LDFLAGS="-L$SYSROOT/opt/vc/lib" ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd + make + make install + +To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths: + + perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config + +================================================================================ + Apps don't work or poor video/audio performance +================================================================================ + +If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to +update the RPi's firmware. Note that doing so will fix these problems, but it +will also render the CMA - Dynamic Memory Split functionality useless. + +Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too +low in general, specially if a 1080p TV is hooked up. + +See here how to configure this setting: http://elinux.org/RPiconfig + +Using a fixed gpu_mem=128 is the best option (specially if you updated the +firmware, using CMA probably won't work, at least it's the current case). + +================================================================================ + No input +================================================================================ + +Make sure you belong to the "input" group. + + sudo usermod -aG input `whoami` + +================================================================================ + No HDMI Audio +================================================================================ + +If you notice that ALSA works but there's no audio over HDMI, try adding: + + hdmi_drive=2 + +to your config.txt file and reboot. + +Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062 + +================================================================================ + Text Input API support +================================================================================ + +The Text Input API is supported, with translation of scan codes done via the +kernel symbol tables. For this to work, SDL needs access to a valid console. +If you notice there's no SDL_TEXTINPUT message being emitted, double check that +your app has read access to one of the following: + +* /proc/self/fd/0 +* /dev/tty +* /dev/tty[0...6] +* /dev/vc/0 +* /dev/console + +This is usually not a problem if you run from the physical terminal (as opposed +to running from a pseudo terminal, such as via SSH). If running from a PTS, a +quick workaround is to run your app as root or add yourself to the tty group, +then re login to the system. + + sudo usermod -aG tty `whoami` + +The keyboard layout used by SDL is the same as the one the kernel uses. +To configure the layout on Raspbian: + + sudo dpkg-reconfigure keyboard-configuration + +To configure the locale, which controls which keys are interpreted as letters, +this determining the CAPS LOCK behavior: + + sudo dpkg-reconfigure locales + +================================================================================ + OpenGL problems +================================================================================ + +If you have desktop OpenGL headers installed at build time in your RPi or cross +compilation environment, support for it will be built in. However, the chipset +does not actually have support for it, which causes issues in certain SDL apps +since the presence of OpenGL support supersedes the ES/ES2 variants. +The workaround is to disable OpenGL at configuration time: + + ./configure --disable-video-opengl + +Or if the application uses the Render functions, you can use the SDL_RENDER_DRIVER +environment variable: + + export SDL_RENDER_DRIVER=opengles2 + +================================================================================ + Notes +================================================================================ + +* When launching apps remotely (via SSH), SDL can prevent local keystrokes from + leaking into the console only if it has root privileges. Launching apps locally + does not suffer from this issue. + + diff --git a/#ThirdParty/libSDL/docs/README-touch.md b/#ThirdParty/libSDL/docs/README-touch.md new file mode 100644 index 0000000..e76e2d3 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-touch.md @@ -0,0 +1,86 @@ +Touch +=========================================================================== +System Specific Notes +=========================================================================== +Linux: +The linux touch system is currently based off event streams, and proc/bus/devices. The active user must be given permissions to read /dev/input/TOUCHDEVICE, where TOUCHDEVICE is the event stream for your device. Currently only Wacom tablets are supported. If you have an unsupported tablet contact me at jim.tla+sdl_touch@gmail.com and I will help you get support for it. + +Mac: +The Mac and iPhone APIs are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do. + +iPhone: +Works out of box. + +Windows: +Unfortunately there is no windows support as of yet. Support for Windows 7 is planned, but we currently have no way to test. If you have a Windows 7 WM_TOUCH supported device, and are willing to help test please contact me at jim.tla+sdl_touch@gmail.com + +=========================================================================== +Events +=========================================================================== +SDL_FINGERDOWN: +Sent when a finger (or stylus) is placed on a touch device. +Fields: +* event.tfinger.touchId - the Id of the touch device. +* event.tfinger.fingerId - the Id of the finger which just went down. +* event.tfinger.x - the x coordinate of the touch (0..1) +* event.tfinger.y - the y coordinate of the touch (0..1) +* event.tfinger.pressure - the pressure of the touch (0..1) + +SDL_FINGERMOTION: +Sent when a finger (or stylus) is moved on the touch device. +Fields: +Same as SDL_FINGERDOWN but with additional: +* event.tfinger.dx - change in x coordinate during this motion event. +* event.tfinger.dy - change in y coordinate during this motion event. + +SDL_FINGERUP: +Sent when a finger (or stylus) is lifted from the touch device. +Fields: +Same as SDL_FINGERDOWN. + + +=========================================================================== +Functions +=========================================================================== +SDL provides the ability to access the underlying Finger structures. +These structures should _never_ be modified. + +The following functions are included from SDL_touch.h + +To get a SDL_TouchID call SDL_GetTouchDevice(index). +This returns a SDL_TouchID. +IMPORTANT: If the touch has been removed, or there is no touch with the given ID, SDL_GetTouchID will return 0. Be sure to check for this! + +The number of touch devices can be queried with SDL_GetNumTouchDevices(). + +A SDL_TouchID may be used to get pointers to SDL_Finger. + +SDL_GetNumTouchFingers(touchID) may be used to get the number of fingers currently down on the device. + +The most common reason to access SDL_Finger is to query the fingers outside the event. In most cases accessing the fingers is using the event. This would be accomplished by code like the following: + + float x = event.tfinger.x; + float y = event.tfinger.y; + + + +To get a SDL_Finger, call SDL_GetTouchFinger(touchID,index), where touchID is a SDL_TouchID, and index is the requested finger. +This returns a SDL_Finger*, or NULL if the finger does not exist, or has been removed. +A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the SDL_FINGERUP event is polled. +As a result, be very careful to check for NULL return values. + +A SDL_Finger has the following fields: +* x,y,pressure: + The current coordinates of the touch. +* pressure: + The pressure of the touch. + + +=========================================================================== +Notes +=========================================================================== +For a complete example see test/testgesture.c + +Please direct questions/comments to: + jim.tla+sdl_touch@gmail.com + (original author, API was changed since) diff --git a/#ThirdParty/libSDL/docs/README-wince.md b/#ThirdParty/libSDL/docs/README-wince.md new file mode 100644 index 0000000..c543ed6 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-wince.md @@ -0,0 +1,10 @@ +WinCE +===== + +Windows CE is no longer supported by SDL. + +We have left the CE support in SDL 1.2 for those that must have it, and we +have support for Windows Phone 8 and WinRT in SDL2, as of SDL 2.0.3. + +--ryan. + diff --git a/#ThirdParty/libSDL/docs/README-windows.md b/#ThirdParty/libSDL/docs/README-windows.md new file mode 100644 index 0000000..076b155 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-windows.md @@ -0,0 +1,41 @@ +Windows +================================================================================ + +================================================================================ +OpenGL ES 2.x support +================================================================================ + +SDL has support for OpenGL ES 2.x under Windows via two alternative +implementations. +The most straightforward method consists in running your app in a system with +a graphic card paired with a relatively recent (as of November of 2013) driver +which supports the WGL_EXT_create_context_es2_profile extension. Vendors known +to ship said extension on Windows currently include nVidia and Intel. + +The other method involves using the ANGLE library (https://code.google.com/p/angleproject/) +If an OpenGL ES 2.x context is requested and no WGL_EXT_create_context_es2_profile +extension is found, SDL will try to load the libEGL.dll library provided by +ANGLE. +To obtain the ANGLE binaries, you can either compile from source from +https://chromium.googlesource.com/angle/angle or copy the relevant binaries from +a recent Chrome/Chromium install for Windows. The files you need are: + + * libEGL.dll + * libGLESv2.dll + * d3dcompiler_46.dll (supports Windows Vista or later, better shader compiler) + or... + * d3dcompiler_43.dll (supports Windows XP or later) + +If you compile ANGLE from source, you can configure it so it does not need the +d3dcompiler_* DLL at all (for details on this, see their documentation). +However, by default SDL will try to preload the d3dcompiler_46.dll to +comply with ANGLE's requirements. If you wish SDL to preload d3dcompiler_43.dll (to +support Windows XP) or to skip this step at all, you can use the +SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details). + +Known Bugs: + + * SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears + that there's a bug in the library which prevents the window contents from + refreshing if this is set to anything other than the default value. + diff --git a/#ThirdParty/libSDL/docs/README-winrt.md b/#ThirdParty/libSDL/docs/README-winrt.md new file mode 100644 index 0000000..741def6 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README-winrt.md @@ -0,0 +1,468 @@ +WinRT +===== + +This port allows SDL applications to run on Microsoft's platforms that require +use of "Windows Runtime", aka. "WinRT", APIs. WinRT apps are currently +full-screen only, and run in what Microsoft sometimes refers to as their +"Modern" (formerly, "Metro"), environment. For Windows 8.x, Microsoft may also +refer to them as "Windows Store" apps, due to them being distributed, +primarily, via a Microsoft-run online store (of the same name). + +Some of the operating systems that include WinRT, are: + +* Windows 10, via its Universal Windows Platform (UWP) APIs +* Windows 8.x +* Windows RT 8.x (aka. Windows 8.x for ARM processors) +* Windows Phone 8.x + + +Requirements +------------ + +* Microsoft Visual C++ (aka Visual Studio), either 2015, 2013, or 2012 + - Free, "Community" or "Express" editions may be used, so long as they + include support for either "Windows Store" or "Windows Phone" apps. + "Express" versions marked as supporting "Windows Desktop" development + typically do not include support for creating WinRT apps, to note. + (The "Community" editions of Visual C++ do, however, support both + desktop/Win32 and WinRT development). + - Visual C++ 2012 can only build apps that target versions 8.0 of Windows, + or Windows Phone. 8.0-targetted apps will run on devices running 8.1 + editions of Windows, however they will not be able to take advantage of + 8.1-specific features. + - Visual C++ 2013 cannot create app projects that target Windows 8.0. + Visual C++ 2013 Update 4, can create app projects for Windows Phone 8.0, + Windows Phone 8.1, and Windows 8.1, but not Windows 8.0. An optional + Visual Studio add-in, "Tools for Maintaining Store apps for Windows 8", + allows Visual C++ 2013 to load and build Windows 8.0 projects that were + created with Visual C++ 2012, so long as Visual C++ 2012 is installed + on the same machine. More details on targeting different versions of + Windows can found at the following web pages: + - [Develop apps by using Visual Studio 2013](http://msdn.microsoft.com/en-us/library/windows/apps/br211384.aspx) + - [To add the Tools for Maintaining Store apps for Windows 8](http://msdn.microsoft.com/en-us/library/windows/apps/dn263114.aspx#AddMaintenanceTools) +* A valid Microsoft account - This requirement is not imposed by SDL, but + rather by Microsoft's Visual C++ toolchain. This is required to launch or + debug apps. + + +Status +------ + +Here is a rough list of what works, and what doens't: + +* What works: + * compilation via Visual C++ 2012 through 2015 + * compile-time platform detection for SDL programs. The C/C++ #define, + `__WINRT__`, will be set to 1 (by SDL) when compiling for WinRT. + * GPU-accelerated 2D rendering, via SDL_Renderer. + * OpenGL ES 2, via the ANGLE library (included separately from SDL) + * software rendering, via either SDL_Surface (optionally in conjunction with + SDL_GetWindowSurface() and SDL_UpdateWindowSurface()) or via the + SDL_Renderer APIs + * threads + * timers (via SDL_GetTicks(), SDL_AddTimer(), SDL_GetPerformanceCounter(), + SDL_GetPerformanceFrequency(), etc.) + * file I/O via SDL_RWops + * mouse input (unsupported on Windows Phone) + * audio, via a modified version of SDL's XAudio2 backend + * .DLL file loading. Libraries *MUST* be packaged inside applications. Loading + anything outside of the app is not supported. + * system path retrieval via SDL's filesystem APIs + * game controllers. Support is provided via the SDL_Joystick and + SDL_GameController APIs, and is backed by Microsoft's XInput API. + * multi-touch input + * app events. SDL_APP_WILLENTER* and SDL_APP_DIDENTER* events get sent out as + appropriate. + * window events + * using Direct3D 11.x APIs outside of SDL. Non-XAML / Direct3D-only apps can + choose to render content directly via Direct3D, using SDL to manage the + internal WinRT window, as well as input and audio. (Use + SDL_GetWindowWMInfo() to get the WinRT 'CoreWindow', and pass it into + IDXGIFactory2::CreateSwapChainForCoreWindow() as appropriate.) + +* What partially works: + * keyboard input. Most of WinRT's documented virtual keys are supported, as + well as many keys with documented hardware scancodes. + * SDLmain. WinRT uses a different signature for each app's main() function. + SDL-based apps that use this port must compile in SDL_winrt_main_NonXAML.cpp + (in `SDL\src\main\winrt\`) directly in order for their C-style main() + functions to be called. + +* What doesn't work: + * compilation with anything other than Visual C++ + * programmatically-created custom cursors. These don't appear to be supported + by WinRT. Different OS-provided cursors can, however, be created via + SDL_CreateSystemCursor() (unsupported on Windows Phone) + * SDL_WarpMouseInWindow() or SDL_WarpMouseGlobal(). This are not currently + supported by WinRT itself. + * joysticks and game controllers that aren't supported by Microsoft's XInput + API. + * turning off VSync when rendering on Windows Phone. Attempts to turn VSync + off on Windows Phone result either in Direct3D not drawing anything, or it + forcing VSync back on. As such, SDL_RENDERER_PRESENTVSYNC will always get + turned-on on Windows Phone. This limitation is not present in non-Phone + WinRT (such as Windows 8.x), where turning off VSync appears to work. + * probably anything else that's not listed as supported + + + +Upgrade Notes +------------- + +#### SDL_GetPrefPath() usage when upgrading WinRT apps from SDL 2.0.3 + +SDL 2.0.4 fixes two bugs found in the WinRT version of SDL_GetPrefPath(). +The fixes may affect older, SDL 2.0.3-based apps' save data. Please note +that these changes only apply to SDL-based WinRT apps, and not to apps for +any other platform. + +1. SDL_GetPrefPath() would return an invalid path, one in which the path's + directory had not been created. Attempts to create files there + (via fopen(), for example), would fail, unless that directory was + explicitly created beforehand. + +2. SDL_GetPrefPath(), for non-WinPhone-based apps, would return a path inside + a WinRT 'Roaming' folder, the contents of which get automatically + synchronized across multiple devices. This process can occur while an + application runs, and can cause existing save-data to be overwritten + at unexpected times, with data from other devices. (Windows Phone apps + written with SDL 2.0.3 did not utilize a Roaming folder, due to API + restrictions in Windows Phone 8.0). + + +SDL_GetPrefPath(), starting with SDL 2.0.4, addresses these by: + +1. making sure that SDL_GetPrefPath() returns a directory in which data + can be written to immediately, without first needing to create directories. + +2. basing SDL_GetPrefPath() off of a different, non-Roaming folder, the + contents of which do not automatically get synchronized across devices + (and which require less work to use safely, in terms of data integrity). + +Apps that wish to get their Roaming folder's path can do so either by using +SDL_WinRTGetFSPathUTF8(), SDL_WinRTGetFSPathUNICODE() (which returns a +UCS-2/wide-char string), or directly through the WinRT class, +Windows.Storage.ApplicationData. + + + +Setup, High-Level Steps +----------------------- + +The steps for setting up a project for an SDL/WinRT app looks like the +following, at a high-level: + +1. create a new Visual C++ project using Microsoft's template for a, + "Direct3D App". +2. remove most of the files from the project. +3. make your app's project directly reference SDL/WinRT's own Visual C++ + project file, via use of Visual C++'s "References" dialog. This will setup + the linker, and will copy SDL's .dll files to your app's final output. +4. adjust your app's build settings, at minimum, telling it where to find SDL's + header files. +5. add a file that contains a WinRT-appropriate main function. +6. add SDL-specific app code. +7. build and run your app. + + +Setup, Detailed Steps +--------------------- + +### 1. Create a new project ### + +Create a new project using one of Visual C++'s templates for a plain, non-XAML, +"Direct3D App" (XAML support for SDL/WinRT is not yet ready for use). If you +don't see one of these templates, in Visual C++'s 'New Project' dialog, try +using the textbox titled, 'Search Installed Templates' to look for one. + + +### 2. Remove unneeded files from the project ### + +In the new project, delete any file that has one of the following extensions: + +- .cpp +- .h +- .hlsl + +When you are done, you should be left with a few files, each of which will be a +necessary part of your app's project. These files will consist of: + +- an .appxmanifest file, which contains metadata on your WinRT app. This is + similar to an Info.plist file on iOS, or an AndroidManifest.xml on Android. +- a few .png files, one of which is a splash screen (displayed when your app + launches), others are app icons. +- a .pfx file, used for code signing purposes. + + +### 3. Add references to SDL's project files ### + +SDL/WinRT can be built in multiple variations, spanning across three different +CPU architectures (x86, x64, and ARM) and two different configurations +(Debug and Release). WinRT and Visual C++ do not currently provide a means +for combining multiple variations of one library into a single file. +Furthermore, it does not provide an easy means for copying pre-built .dll files +into your app's final output (via Post-Build steps, for example). It does, +however, provide a system whereby an app can reference the MSVC projects of +libraries such that, when the app is built: + +1. each library gets built for the appropriate CPU architecture(s) and WinRT + platform(s). +2. each library's output, such as .dll files, get copied to the app's build + output. + +To set this up for SDL/WinRT, you'll need to run through the following steps: + +1. open up the Solution Explorer inside Visual C++ (under the "View" menu, then + "Solution Explorer") +2. right click on your app's solution. +3. navigate to "Add", then to "Existing Project..." +4. find SDL/WinRT's Visual C++ project file and open it. Different project + files exist for different WinRT platforms. All of them are in SDL's + source distribution, in the following directories: + * `VisualC-WinRT/UWP_VS2015/` - for Windows 10 / UWP apps + * `VisualC-WinRT/WinPhone81_VS2013/` - for Windows Phone 8.1 apps + * `VisualC-WinRT/WinRT80_VS2012/` - for Windows 8.0 apps + * `VisualC-WinRT/WinRT81_VS2013/` - for Windows 8.1 apps +5. once the project has been added, right-click on your app's project and + select, "References..." +6. click on the button titled, "Add New Reference..." +7. check the box next to SDL +8. click OK to close the dialog +9. SDL will now show up in the list of references. Click OK to close that + dialog. + +Your project is now linked to SDL's project, insofar that when the app is +built, SDL will be built as well, with its build output getting included with +your app. + + +### 4. Adjust Your App's Build Settings ### + +Some build settings need to be changed in your app's project. This guide will +outline the following: + +- making sure that the compiler knows where to find SDL's header files +- **Optional for C++, but NECESSARY for compiling C code:** telling the + compiler not to use Microsoft's C++ extensions for WinRT development. +- **Optional:** telling the compiler not generate errors due to missing + precompiled header files. + +To change these settings: + +1. right-click on the project +2. choose "Properties" +3. in the drop-down box next to "Configuration", choose, "All Configurations" +4. in the drop-down box next to "Platform", choose, "All Platforms" +5. in the left-hand list, expand the "C/C++" section +6. select "General" +7. edit the "Additional Include Directories" setting, and add a path to SDL's + "include" directory +8. **Optional: to enable compilation of C code:** change the setting for + "Consume Windows Runtime Extension" from "Yes (/ZW)" to "No". If you're + working with a completely C++ based project, this step can usually be + omitted. +9. **Optional: to disable precompiled headers (which can produce + 'stdafx.h'-related build errors, if setup incorrectly:** in the left-hand + list, select "Precompiled Headers", then change the setting for "Precompiled + Header" from "Use (/Yu)" to "Not Using Precompiled Headers". +10. close the dialog, saving settings, by clicking the "OK" button + + +### 5. Add a WinRT-appropriate main function to the app. ### + +C/C++-based WinRT apps do contain a `main` function that the OS will invoke when +the app starts launching. The parameters of WinRT main functions are different +than those found on other platforms, Win32 included. SDL/WinRT provides a +platform-appropriate main function that will perform these actions, setup key +portions of the app, then invoke a classic, C/C++-style main function (that take +in "argc" and "argv" parameters). The code for this file is contained inside +SDL's source distribution, under `src/main/winrt/SDL_winrt_main_NonXAML.cpp`. +You'll need to add this file, or a copy of it, to your app's project, and make +sure it gets compiled using a Microsoft-specific set of C++ extensions called +C++/CX. + +**NOTE: C++/CX compilation is currently required in at least one file of your +app's project. This is to make sure that Visual C++'s linker builds a 'Windows +Metadata' file (.winmd) for your app. Not doing so can lead to build errors.** + +To include `SDL_winrt_main_NonXAML.cpp`: + +1. right-click on your project (again, in Visual C++'s Solution Explorer), + navigate to "Add", then choose "Existing Item...". +2. open `SDL_winrt_main_NonXAML.cpp`, which is found inside SDL's source + distribution, under `src/main/winrt/`. Make sure that the open-file dialog + closes, either by double-clicking on the file, or single-clicking on it and + then clicking Add. +3. right-click on the file (as listed in your project), then click on + "Properties...". +4. in the drop-down box next to "Configuration", choose, "All Configurations" +5. in the drop-down box next to "Platform", choose, "All Platforms" +6. in the left-hand list, click on "C/C++" +7. change the setting for "Consume Windows Runtime Extension" to "Yes (/ZW)". +8. click the OK button. This will close the dialog. + + +### 6. Add app code and assets ### + +At this point, you can add in SDL-specific source code. Be sure to include a +C-style main function (ie: `int main(int argc, char *argv[])`). From there you +should be able to create a single `SDL_Window` (WinRT apps can only have one +window, at present), as well as an `SDL_Renderer`. Direct3D will be used to +draw content. Events are received via SDL's usual event functions +(`SDL_PollEvent`, etc.) If you have a set of existing source files and assets, +you can start adding them to the project now. If not, or if you would like to +make sure that you're setup correctly, some short and simple sample code is +provided below. + + +#### 6.A. ... when creating a new app #### + +If you are creating a new app (rather than porting an existing SDL-based app), +or if you would just like a simple app to test SDL/WinRT with before trying to +get existing code working, some working SDL/WinRT code is provided below. To +set this up: + +1. right click on your app's project +2. select Add, then New Item. An "Add New Item" dialog will show up. +3. from the left-hand list, choose "Visual C++" +4. from the middle/main list, choose "C++ File (.cpp)" +5. near the bottom of the dialog, next to "Name:", type in a name for your +source file, such as, "main.cpp". +6. click on the Add button. This will close the dialog, add the new file to +your project, and open the file in Visual C++'s text editor. +7. Copy and paste the following code into the new file, then save it. + + + #include + + int main(int argc, char **argv) + { + SDL_DisplayMode mode; + SDL_Window * window = NULL; + SDL_Renderer * renderer = NULL; + SDL_Event evt; + + if (SDL_Init(SDL_INIT_VIDEO) != 0) { + return 1; + } + + if (SDL_GetCurrentDisplayMode(0, &mode) != 0) { + return 1; + } + + if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) { + return 1; + } + + while (1) { + while (SDL_PollEvent(&evt)) { + } + + SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + } + } + + +#### 6.B. Adding code and assets #### + +If you have existing code and assets that you'd like to add, you should be able +to add them now. The process for adding a set of files is as such. + +1. right click on the app's project +2. select Add, then click on "New Item..." +3. open any source, header, or asset files as appropriate. Support for C and +C++ is available. + +Do note that WinRT only supports a subset of the APIs that are available to +Win32-based apps. Many portions of the Win32 API and the C runtime are not +available. + +A list of unsupported C APIs can be found at + + +General information on using the C runtime in WinRT can be found at + + +A list of supported Win32 APIs for WinRT apps can be found at +. To note, +the list of supported Win32 APIs for Windows Phone 8.0 is different. +That list can be found at + + + +### 7. Build and run your app ### + +Your app project should now be setup, and you should be ready to build your app. +To run it on the local machine, open the Debug menu and choose "Start +Debugging". This will build your app, then run your app full-screen. To switch +out of your app, press the Windows key. Alternatively, you can choose to run +your app in a window. To do this, before building and running your app, find +the drop-down menu in Visual C++'s toolbar that says, "Local Machine". Expand +this by clicking on the arrow on the right side of the list, then click on +Simulator. Once you do that, any time you build and run the app, the app will +launch in window, rather than full-screen. + + +#### 7.A. Running apps on older, ARM-based, "Windows RT" devices #### + +**These instructions do not include Windows Phone, despite Windows Phone +typically running on ARM processors.** They are specifically for devices +that use the "Windows RT" operating system, which was a modified version of +Windows 8.x that ran primarily on ARM-based tablet computers. + +To build and run the app on ARM-based, "Windows RT" devices, you'll need to: + +- install Microsoft's "Remote Debugger" on the device. Visual C++ installs and + debugs ARM-based apps via IP networks. +- change a few options on the development machine, both to make sure it builds + for ARM (rather than x86 or x64), and to make sure it knows how to find the + Windows RT device (on the network). + +Microsoft's Remote Debugger can be found at +. Please note +that separate versions of this debugger exist for different versions of Visual +C++, one each for MSVC 2015, 2013, and 2012. + +To setup Visual C++ to launch your app on an ARM device: + +1. make sure the Remote Debugger is running on your ARM device, and that it's on + the same IP network as your development machine. +2. from Visual C++'s toolbar, find a drop-down menu that says, "Win32". Click + it, then change the value to "ARM". +3. make sure Visual C++ knows the hostname or IP address of the ARM device. To + do this: + 1. open the app project's properties + 2. select "Debugging" + 3. next to "Machine Name", enter the hostname or IP address of the ARM + device + 4. if, and only if, you've turned off authentication in the Remote Debugger, + then change the setting for "Require Authentication" to No + 5. click "OK" +4. build and run the app (from Visual C++). The first time you do this, a + prompt will show up on the ARM device, asking for a Microsoft Account. You + do, unfortunately, need to log in here, and will need to follow the + subsequent registration steps in order to launch the app. After you do so, + if the app didn't already launch, try relaunching it again from within Visual + C++. + + +Troubleshooting +--------------- + +#### Build fails with message, "error LNK2038: mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker'" + +Try adding the following to your linker flags. In MSVC, this can be done by +right-clicking on the app project, navigating to Configuration Properties -> +Linker -> Command Line, then adding them to the Additional Options +section. + +* For Release builds / MSVC-Configurations, add: + + /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib + +* For Debug builds / MSVC-Configurations, add: + + /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib + diff --git a/#ThirdParty/libSDL/docs/README.md b/#ThirdParty/libSDL/docs/README.md new file mode 100644 index 0000000..4e31069 --- /dev/null +++ b/#ThirdParty/libSDL/docs/README.md @@ -0,0 +1,63 @@ +Simple DirectMedia Layer {#mainpage} +======================== + + (SDL) + + Version 2.0 + +--- +http://www.libsdl.org/ + +Simple DirectMedia Layer is a cross-platform development library designed +to provide low level access to audio, keyboard, mouse, joystick, and graphics +hardware via OpenGL and Direct3D. It is used by video playback software, +emulators, and popular games including Valve's award winning catalog +and many Humble Bundle games. + +SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. +Support for other platforms may be found in the source code. + +SDL is written in C, works natively with C++, and there are bindings +available for several other languages, including C# and Python. + +This library is distributed under the zlib license, which can be found +in the file "COPYING.txt". + +The best way to learn how to use SDL is to check out the header files in +the "include" subdirectory and the programs in the "test" subdirectory. +The header files and test programs are well commented and always up to date. + +More documentation and FAQs are available online at [the wiki](http://wiki.libsdl.org/) + +- [Android](README-android.md) +- [CMake](README-cmake.md) +- [DirectFB](README-directfb.md) +- [DynAPI](README-dynapi.md) +- [Emscripten](README-emscripten.md) +- [Gesture](README-gesture.md) +- [Mercurial](README-hg.md) +- [iOS](README-ios.md) +- [Linux](README-linux.md) +- [OS X](README-macosx.md) +- [Native Client](README-nacl.md) +- [Pandora](README-pandora.md) +- [Supported Platforms](README-platforms.md) +- [Porting information](README-porting.md) +- [PSP](README-psp.md) +- [Raspberry Pi](README-raspberrypi.md) +- [Touch](README-touch.md) +- [WinCE](README-wince.md) +- [Windows](README-windows.md) +- [WinRT](README-winrt.md) + +If you need help with the library, or just want to discuss SDL related +issues, you can join the [developers mailing list](http://www.libsdl.org/mailing-list.php) + +If you want to report bugs or contribute patches, please submit them to +[bugzilla](http://bugzilla.libsdl.org/) + +Enjoy! + + +Sam Lantinga + diff --git a/#ThirdParty/libSDL/docs/doxyfile b/#ThirdParty/libSDL/docs/doxyfile new file mode 100644 index 0000000..baf1c98 --- /dev/null +++ b/#ThirdParty/libSDL/docs/doxyfile @@ -0,0 +1,1560 @@ +# Doxyfile 1.5.9 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = SDL + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 2.0 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = ./output + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = YES + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = YES + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = "defined=\"\def\"" \ + "discussion=\"\par Discussion:\n\"" + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. Note that for custom extensions you also need to set +# FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = YES + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = YES + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = YES + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = ./doxygen_warn.txt + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = . ../include + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.vhd \ + *.vhdl \ + *.h.in \ + *.h.default \ + *.md + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = ../include/SDL_opengles2_gl2ext.h \ + ../include/SDL_opengles2_gl2platform.h \ + ../include/SDL_opengles2_khrplatform.h \ + ../include/SDL_opengl_glext.h \ + ../include/SDL_opengles2_gl2.h \ + ../include/SDL_opengles2.h \ + ../include/SDL_opengles.h \ + ../include/SDL_opengl.h \ + ../include/SDL_egl.h \ + + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = YES + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = SDL_ \ + SDL + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = YES + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "SDL 2.0 Doxygen" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.libsdl.sdl20 + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = ./sdl20.chm + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = YES + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 1 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to FRAME, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values +# for this tag are: HIERARCHIES, which will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list; +# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which +# disables this behavior completely. For backwards compatibility with previous +# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE +# respectively. + +GENERATE_TREEVIEW = ALL + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = DOXYGEN_SHOULD_IGNORE_THIS=1 \ + DECLSPEC= \ + SDLCALL= \ + _WIN32=1 + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = ./SDL.tag + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = c:\Perl\bin\perl.exe + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 60 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 2 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = YES + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Options related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/#ThirdParty/libSDL/include/SDL.h b/#ThirdParty/libSDL/include/SDL.h new file mode 100644 index 0000000..7647b51 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL.h @@ -0,0 +1,132 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL.h + * + * Main include header for the SDL library + */ + + +#ifndef _SDL_H +#define _SDL_H + +#include "SDL_main.h" +#include "SDL_stdinc.h" +#include "SDL_assert.h" +#include "SDL_atomic.h" +#include "SDL_audio.h" +#include "SDL_clipboard.h" +#include "SDL_cpuinfo.h" +#include "SDL_endian.h" +#include "SDL_error.h" +#include "SDL_events.h" +#include "SDL_filesystem.h" +#include "SDL_joystick.h" +#include "SDL_gamecontroller.h" +#include "SDL_haptic.h" +#include "SDL_hints.h" +#include "SDL_loadso.h" +#include "SDL_log.h" +#include "SDL_messagebox.h" +#include "SDL_mutex.h" +#include "SDL_power.h" +#include "SDL_render.h" +#include "SDL_rwops.h" +#include "SDL_system.h" +#include "SDL_thread.h" +#include "SDL_timer.h" +#include "SDL_version.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* As of version 0.5, SDL is loaded dynamically into the application */ + +/** + * \name SDL_INIT_* + * + * These are the flags which may be passed to SDL_Init(). You should + * specify the subsystems which you will be using in your application. + */ +/* @{ */ +#define SDL_INIT_TIMER 0x00000001 +#define SDL_INIT_AUDIO 0x00000010 +#define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ +#define SDL_INIT_JOYSTICK 0x00000200 /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ +#define SDL_INIT_HAPTIC 0x00001000 +#define SDL_INIT_GAMECONTROLLER 0x00002000 /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ +#define SDL_INIT_EVENTS 0x00004000 +#define SDL_INIT_NOPARACHUTE 0x00100000 /**< compatibility; this flag is ignored. */ +#define SDL_INIT_EVERYTHING ( \ + SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ + SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ + ) +/* @} */ + +/** + * This function initializes the subsystems specified by \c flags + */ +extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); + +/** + * This function initializes specific SDL subsystems + * + * Subsystem initialization is ref-counted, you must call + * SDL_QuitSubSystem for each SDL_InitSubSystem to correctly + * shutdown a subsystem manually (or call SDL_Quit to force shutdown). + * If a subsystem is already loaded then this call will + * increase the ref-count and return. + */ +extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); + +/** + * This function cleans up specific SDL subsystems + */ +extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); + +/** + * This function returns a mask of the specified subsystems which have + * previously been initialized. + * + * If \c flags is 0, it returns a mask of all initialized subsystems. + */ +extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); + +/** + * This function cleans up all initialized subsystems. You should + * call it upon all exit conditions. + */ +extern DECLSPEC void SDLCALL SDL_Quit(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_H */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_assert.h b/#ThirdParty/libSDL/include/SDL_assert.h new file mode 100644 index 0000000..402981f --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_assert.h @@ -0,0 +1,289 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_assert_h +#define _SDL_assert_h + +#include "SDL_config.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SDL_ASSERT_LEVEL +#ifdef SDL_DEFAULT_ASSERT_LEVEL +#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL +#elif defined(_DEBUG) || defined(DEBUG) || \ + (defined(__GNUC__) && !defined(__OPTIMIZE__)) +#define SDL_ASSERT_LEVEL 2 +#else +#define SDL_ASSERT_LEVEL 1 +#endif +#endif /* SDL_ASSERT_LEVEL */ + +/* +These are macros and not first class functions so that the debugger breaks +on the assertion line and not in some random guts of SDL, and so each +assert can have unique static variables associated with it. +*/ + +#if defined(_MSC_VER) +/* Don't include intrin.h here because it contains C++ code */ + extern void __cdecl __debugbreak(void); + #define SDL_TriggerBreakpoint() __debugbreak() +#elif (!defined(__NACL__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) +#elif defined(HAVE_SIGNAL_H) + #include + #define SDL_TriggerBreakpoint() raise(SIGTRAP) +#else + /* How do we trigger breakpoints on this platform? */ + #define SDL_TriggerBreakpoint() +#endif + +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ +# define SDL_FUNCTION __func__ +#elif ((__GNUC__ >= 2) || defined(_MSC_VER)) +# define SDL_FUNCTION __FUNCTION__ +#else +# define SDL_FUNCTION "???" +#endif +#define SDL_FILE __FILE__ +#define SDL_LINE __LINE__ + +/* +sizeof (x) makes the compiler still parse the expression even without +assertions enabled, so the code is always checked at compile time, but +doesn't actually generate code for it, so there are no side effects or +expensive checks at run time, just the constant size of what x WOULD be, +which presumably gets optimized out as unused. +This also solves the problem of... + + int somevalue = blah(); + SDL_assert(somevalue == 1); + +...which would cause compiles to complain that somevalue is unused if we +disable assertions. +*/ + +/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking + this condition isn't constant. And looks like an owl's face! */ +#ifdef _MSC_VER /* stupid /W4 warnings. */ +#define SDL_NULL_WHILE_LOOP_CONDITION (0,0) +#else +#define SDL_NULL_WHILE_LOOP_CONDITION (0) +#endif + +#define SDL_disabled_assert(condition) \ + do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) + +typedef enum +{ + SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */ + SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */ + SDL_ASSERTION_ABORT, /**< Terminate the program. */ + SDL_ASSERTION_IGNORE, /**< Ignore the assert. */ + SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */ +} SDL_AssertState; + +typedef struct SDL_AssertData +{ + int always_ignore; + unsigned int trigger_count; + const char *condition; + const char *filename; + int linenum; + const char *function; + const struct SDL_AssertData *next; +} SDL_AssertData; + +#if (SDL_ASSERT_LEVEL > 0) + +/* Never call this directly. Use the SDL_assert* macros. */ +extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, + const char *, + const char *, int) +#if defined(__clang__) +#if __has_feature(attribute_analyzer_noreturn) +/* this tells Clang's static analysis that we're a custom assert function, + and that the analyzer should assume the condition was always true past this + SDL_assert test. */ + __attribute__((analyzer_noreturn)) +#endif +#endif +; + +/* the do {} while(0) avoids dangling else problems: + if (x) SDL_assert(y); else blah(); + ... without the do/while, the "else" could attach to this macro's "if". + We try to handle just the minimum we need here in a macro...the loop, + the static vars, and break points. The heavy lifting is handled in + SDL_ReportAssertion(), in SDL_assert.c. +*/ +#define SDL_enabled_assert(condition) \ + do { \ + while ( !(condition) ) { \ + static struct SDL_AssertData sdl_assert_data = { \ + 0, 0, #condition, 0, 0, 0, 0 \ + }; \ + const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ + if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ + continue; /* go again. */ \ + } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \ + SDL_TriggerBreakpoint(); \ + } \ + break; /* not retrying. */ \ + } \ + } while (SDL_NULL_WHILE_LOOP_CONDITION) + +#endif /* enabled assertions support code */ + +/* Enable various levels of assertions. */ +#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */ +# define SDL_assert(condition) SDL_disabled_assert(condition) +# define SDL_assert_release(condition) SDL_disabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 1 /* release settings. */ +# define SDL_assert(condition) SDL_disabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 2 /* normal settings. */ +# define SDL_assert(condition) SDL_enabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */ +# define SDL_assert(condition) SDL_enabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition) +#else +# error Unknown assertion level. +#endif + +/* this assertion is never disabled at any level. */ +#define SDL_assert_always(condition) SDL_enabled_assert(condition) + + +typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)( + const SDL_AssertData* data, void* userdata); + +/** + * \brief Set an application-defined assertion handler. + * + * This allows an app to show its own assertion UI and/or force the + * response to an assertion failure. If the app doesn't provide this, SDL + * will try to do the right thing, popping up a system-specific GUI dialog, + * and probably minimizing any fullscreen windows. + * + * This callback may fire from any thread, but it runs wrapped in a mutex, so + * it will only fire from one thread at a time. + * + * Setting the callback to NULL restores SDL's original internal handler. + * + * This callback is NOT reset to SDL's internal handler upon SDL_Quit()! + * + * \return SDL_AssertState value of how to handle the assertion failure. + * + * \param handler Callback function, called when an assertion fails. + * \param userdata A pointer passed to the callback as-is. + */ +extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( + SDL_AssertionHandler handler, + void *userdata); + +/** + * \brief Get the default assertion handler. + * + * This returns the function pointer that is called by default when an + * assertion is triggered. This is an internal function provided by SDL, + * that is used for assertions when SDL_SetAssertionHandler() hasn't been + * used to provide a different function. + * + * \return The default SDL_AssertionHandler that is called when an assert triggers. + */ +extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void); + +/** + * \brief Get the current assertion handler. + * + * This returns the function pointer that is called when an assertion is + * triggered. This is either the value last passed to + * SDL_SetAssertionHandler(), or if no application-specified function is + * set, is equivalent to calling SDL_GetDefaultAssertionHandler(). + * + * \param puserdata Pointer to a void*, which will store the "userdata" + * pointer that was passed to SDL_SetAssertionHandler(). + * This value will always be NULL for the default handler. + * If you don't care about this data, it is safe to pass + * a NULL pointer to this function to ignore it. + * \return The SDL_AssertionHandler that is called when an assert triggers. + */ +extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata); + +/** + * \brief Get a list of all assertion failures. + * + * Get all assertions triggered since last call to SDL_ResetAssertionReport(), + * or the start of the program. + * + * The proper way to examine this data looks something like this: + * + * + * const SDL_AssertData *item = SDL_GetAssertionReport(); + * while (item) { + * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", + * item->condition, item->function, item->filename, + * item->linenum, item->trigger_count, + * item->always_ignore ? "yes" : "no"); + * item = item->next; + * } + * + * + * \return List of all assertions. + * \sa SDL_ResetAssertionReport + */ +extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void); + +/** + * \brief Reset the list of all assertion failures. + * + * Reset list of all assertions triggered. + * + * \sa SDL_GetAssertionReport + */ +extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); + + +/* these had wrong naming conventions until 2.0.4. Please update your app! */ +#define SDL_assert_state SDL_AssertState +#define SDL_assert_data SDL_AssertData + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_assert_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_atomic.h b/#ThirdParty/libSDL/include/SDL_atomic.h new file mode 100644 index 0000000..56aa81d --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_atomic.h @@ -0,0 +1,268 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_atomic.h + * + * Atomic operations. + * + * IMPORTANT: + * If you are not an expert in concurrent lockless programming, you should + * only be using the atomic lock and reference counting functions in this + * file. In all other cases you should be protecting your data structures + * with full mutexes. + * + * The list of "safe" functions to use are: + * SDL_AtomicLock() + * SDL_AtomicUnlock() + * SDL_AtomicIncRef() + * SDL_AtomicDecRef() + * + * Seriously, here be dragons! + * ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + * + * You can find out a little more about lockless programming and the + * subtle issues that can arise here: + * http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx + * + * There's also lots of good information here: + * http://www.1024cores.net/home/lock-free-algorithms + * http://preshing.com/ + * + * These operations may or may not actually be implemented using + * processor specific atomic operations. When possible they are + * implemented as true processor specific atomic operations. When that + * is not possible the are implemented using locks that *do* use the + * available atomic operations. + * + * All of the atomic operations that modify memory are full memory barriers. + */ + +#ifndef _SDL_atomic_h_ +#define _SDL_atomic_h_ + +#include "SDL_stdinc.h" +#include "SDL_platform.h" + +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name SDL AtomicLock + * + * The atomic locks are efficient spinlocks using CPU instructions, + * but are vulnerable to starvation and can spin forever if a thread + * holding a lock has been terminated. For this reason you should + * minimize the code executed inside an atomic lock and never do + * expensive things like API or system calls while holding them. + * + * The atomic locks are not safe to lock recursively. + * + * Porting Note: + * The spin lock functions and type are required and can not be + * emulated because they are used in the atomic emulation code. + */ +/* @{ */ + +typedef int SDL_SpinLock; + +/** + * \brief Try to lock a spin lock by setting it to a non-zero value. + * + * \param lock Points to the lock. + * + * \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock); + +/** + * \brief Lock a spin lock by setting it to a non-zero value. + * + * \param lock Points to the lock. + */ +extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); + +/** + * \brief Unlock a spin lock by setting it to 0. Always returns immediately + * + * \param lock Points to the lock. + */ +extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); + +/* @} *//* SDL AtomicLock */ + + +/** + * The compiler barrier prevents the compiler from reordering + * reads and writes to globally visible variables across the call. + */ +#if defined(_MSC_VER) && (_MSC_VER > 1200) +void _ReadWriteBarrier(void); +#pragma intrinsic(_ReadWriteBarrier) +#define SDL_CompilerBarrier() _ReadWriteBarrier() +#elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) +/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */ +#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") +#else +#define SDL_CompilerBarrier() \ +{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); } +#endif + +/** + * Memory barriers are designed to prevent reads and writes from being + * reordered by the compiler and being seen out of order on multi-core CPUs. + * + * A typical pattern would be for thread A to write some data and a flag, + * and for thread B to read the flag and get the data. In this case you + * would insert a release barrier between writing the data and the flag, + * guaranteeing that the data write completes no later than the flag is + * written, and you would insert an acquire barrier between reading the + * flag and reading the data, to ensure that all the reads associated + * with the flag have completed. + * + * In this pattern you should always see a release barrier paired with + * an acquire barrier and you should gate the data reads/writes with a + * single flag variable. + * + * For more information on these semantics, take a look at the blog post: + * http://preshing.com/20120913/acquire-and-release-semantics + */ +#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory") +#elif defined(__GNUC__) && defined(__arm__) +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") +#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) +#ifdef __thumb__ +/* The mcr instruction isn't available in thumb mode, use real functions */ +extern DECLSPEC void SDLCALL SDL_MemoryBarrierRelease(); +extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquire(); +#else +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") +#endif /* __thumb__ */ +#else +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") +#endif /* __GNUC__ && __arm__ */ +#else +#if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) +/* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */ +#include +#define SDL_MemoryBarrierRelease() __machine_rel_barrier() +#define SDL_MemoryBarrierAcquire() __machine_acq_barrier() +#else +/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */ +#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier() +#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier() +#endif +#endif + +/** + * \brief A type representing an atomic integer value. It is a struct + * so people don't accidentally use numeric operations on it. + */ +typedef struct { int value; } SDL_atomic_t; + +/** + * \brief Set an atomic variable to a new value if it is currently an old value. + * + * \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. + * + * \note If you don't know what this function is for, you shouldn't use it! +*/ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval); + +/** + * \brief Set an atomic variable to a value. + * + * \return The previous value of the atomic variable. + */ +extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v); + +/** + * \brief Get the value of an atomic variable + */ +extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); + +/** + * \brief Add to an atomic variable. + * + * \return The previous value of the atomic variable. + * + * \note This same style can be used for any number operation + */ +extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v); + +/** + * \brief Increment an atomic variable used as a reference count. + */ +#ifndef SDL_AtomicIncRef +#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1) +#endif + +/** + * \brief Decrement an atomic variable used as a reference count. + * + * \return SDL_TRUE if the variable reached zero after decrementing, + * SDL_FALSE otherwise + */ +#ifndef SDL_AtomicDecRef +#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1) +#endif + +/** + * \brief Set a pointer to a new value if it is currently an old value. + * + * \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise. + * + * \note If you don't know what this function is for, you shouldn't use it! +*/ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval); + +/** + * \brief Set a pointer to a value atomically. + * + * \return The previous value of the pointer. + */ +extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v); + +/** + * \brief Get the value of a pointer atomically. + */ +extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + +#include "close_code.h" + +#endif /* _SDL_atomic_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_audio.h b/#ThirdParty/libSDL/include/SDL_audio.h new file mode 100644 index 0000000..4f65521 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_audio.h @@ -0,0 +1,605 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_audio.h + * + * Access to the raw audio mixing buffer for the SDL library. + */ + +#ifndef _SDL_audio_h +#define _SDL_audio_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_endian.h" +#include "SDL_mutex.h" +#include "SDL_thread.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Audio format flags. + * + * These are what the 16 bits in SDL_AudioFormat currently mean... + * (Unspecified bits are always zero). + * + * \verbatim + ++-----------------------sample is signed if set + || + || ++-----------sample is bigendian if set + || || + || || ++---sample is float if set + || || || + || || || +---sample bit size---+ + || || || | | + 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 + \endverbatim + * + * There are macros in SDL 2.0 and later to query these bits. + */ +typedef Uint16 SDL_AudioFormat; + +/** + * \name Audio flags + */ +/* @{ */ + +#define SDL_AUDIO_MASK_BITSIZE (0xFF) +#define SDL_AUDIO_MASK_DATATYPE (1<<8) +#define SDL_AUDIO_MASK_ENDIAN (1<<12) +#define SDL_AUDIO_MASK_SIGNED (1<<15) +#define SDL_AUDIO_BITSIZE(x) (x & SDL_AUDIO_MASK_BITSIZE) +#define SDL_AUDIO_ISFLOAT(x) (x & SDL_AUDIO_MASK_DATATYPE) +#define SDL_AUDIO_ISBIGENDIAN(x) (x & SDL_AUDIO_MASK_ENDIAN) +#define SDL_AUDIO_ISSIGNED(x) (x & SDL_AUDIO_MASK_SIGNED) +#define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x)) +#define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x)) +#define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x)) + +/** + * \name Audio format flags + * + * Defaults to LSB byte order. + */ +/* @{ */ +#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ +#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ +#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ +#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */ +#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */ +#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ +#define AUDIO_U16 AUDIO_U16LSB +#define AUDIO_S16 AUDIO_S16LSB +/* @} */ + +/** + * \name int32 support + */ +/* @{ */ +#define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */ +#define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */ +#define AUDIO_S32 AUDIO_S32LSB +/* @} */ + +/** + * \name float32 support + */ +/* @{ */ +#define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */ +#define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */ +#define AUDIO_F32 AUDIO_F32LSB +/* @} */ + +/** + * \name Native audio byte ordering + */ +/* @{ */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define AUDIO_U16SYS AUDIO_U16LSB +#define AUDIO_S16SYS AUDIO_S16LSB +#define AUDIO_S32SYS AUDIO_S32LSB +#define AUDIO_F32SYS AUDIO_F32LSB +#else +#define AUDIO_U16SYS AUDIO_U16MSB +#define AUDIO_S16SYS AUDIO_S16MSB +#define AUDIO_S32SYS AUDIO_S32MSB +#define AUDIO_F32SYS AUDIO_F32MSB +#endif +/* @} */ + +/** + * \name Allow change flags + * + * Which audio format changes are allowed when opening a device. + */ +/* @{ */ +#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001 +#define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002 +#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004 +#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE) +/* @} */ + +/* @} *//* Audio flags */ + +/** + * This function is called when the audio device needs more data. + * + * \param userdata An application-specific parameter saved in + * the SDL_AudioSpec structure + * \param stream A pointer to the audio data buffer. + * \param len The length of that buffer in bytes. + * + * Once the callback returns, the buffer will no longer be valid. + * Stereo samples are stored in a LRLRLR ordering. + * + * You can choose to avoid callbacks and use SDL_QueueAudio() instead, if + * you like. Just open your audio device with a NULL callback. + */ +typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream, + int len); + +/** + * The calculated values in this structure are calculated by SDL_OpenAudio(). + */ +typedef struct SDL_AudioSpec +{ + int freq; /**< DSP frequency -- samples per second */ + SDL_AudioFormat format; /**< Audio data format */ + Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */ + Uint8 silence; /**< Audio buffer silence value (calculated) */ + Uint16 samples; /**< Audio buffer size in samples (power of 2) */ + Uint16 padding; /**< Necessary for some compile environments */ + Uint32 size; /**< Audio buffer size in bytes (calculated) */ + SDL_AudioCallback callback; /**< Callback that feeds the audio device (NULL to use SDL_QueueAudio()). */ + void *userdata; /**< Userdata passed to callback (ignored for NULL callbacks). */ +} SDL_AudioSpec; + + +struct SDL_AudioCVT; +typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt, + SDL_AudioFormat format); + +/** + * A structure to hold a set of audio conversion filters and buffers. + */ +#ifdef __GNUC__ +/* This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't + pad it out to 88 bytes to guarantee ABI compatibility between compilers. + vvv + The next time we rev the ABI, make sure to size the ints and add padding. +*/ +#define SDL_AUDIOCVT_PACKED __attribute__((packed)) +#else +#define SDL_AUDIOCVT_PACKED +#endif +/* */ +typedef struct SDL_AudioCVT +{ + int needed; /**< Set to 1 if conversion possible */ + SDL_AudioFormat src_format; /**< Source audio format */ + SDL_AudioFormat dst_format; /**< Target audio format */ + double rate_incr; /**< Rate conversion increment */ + Uint8 *buf; /**< Buffer to hold entire audio data */ + int len; /**< Length of original audio buffer */ + int len_cvt; /**< Length of converted audio buffer */ + int len_mult; /**< buffer must be len*len_mult big */ + double len_ratio; /**< Given len, final size is len*len_ratio */ + SDL_AudioFilter filters[10]; /**< Filter list */ + int filter_index; /**< Current audio conversion function */ +} SDL_AUDIOCVT_PACKED SDL_AudioCVT; + + +/* Function prototypes */ + +/** + * \name Driver discovery functions + * + * These functions return the list of built in audio drivers, in the + * order that they are normally initialized by default. + */ +/* @{ */ +extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); +extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); +/* @} */ + +/** + * \name Initialization and cleanup + * + * \internal These functions are used internally, and should not be used unless + * you have a specific need to specify the audio driver you want to + * use. You should normally use SDL_Init() or SDL_InitSubSystem(). + */ +/* @{ */ +extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); +extern DECLSPEC void SDLCALL SDL_AudioQuit(void); +/* @} */ + +/** + * This function returns the name of the current audio driver, or NULL + * if no driver has been initialized. + */ +extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); + +/** + * This function opens the audio device with the desired parameters, and + * returns 0 if successful, placing the actual hardware parameters in the + * structure pointed to by \c obtained. If \c obtained is NULL, the audio + * data passed to the callback function will be guaranteed to be in the + * requested format, and will be automatically converted to the hardware + * audio format if necessary. This function returns -1 if it failed + * to open the audio device, or couldn't set up the audio thread. + * + * When filling in the desired audio spec structure, + * - \c desired->freq should be the desired audio frequency in samples-per- + * second. + * - \c desired->format should be the desired audio format. + * - \c desired->samples is the desired size of the audio buffer, in + * samples. This number should be a power of two, and may be adjusted by + * the audio driver to a value more suitable for the hardware. Good values + * seem to range between 512 and 8096 inclusive, depending on the + * application and CPU speed. Smaller values yield faster response time, + * but can lead to underflow if the application is doing heavy processing + * and cannot fill the audio buffer in time. A stereo sample consists of + * both right and left channels in LR ordering. + * Note that the number of samples is directly related to time by the + * following formula: \code ms = (samples*1000)/freq \endcode + * - \c desired->size is the size in bytes of the audio buffer, and is + * calculated by SDL_OpenAudio(). + * - \c desired->silence is the value used to set the buffer to silence, + * and is calculated by SDL_OpenAudio(). + * - \c desired->callback should be set to a function that will be called + * when the audio device is ready for more data. It is passed a pointer + * to the audio buffer, and the length in bytes of the audio buffer. + * This function usually runs in a separate thread, and so you should + * protect data structures that it accesses by calling SDL_LockAudio() + * and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL + * pointer here, and call SDL_QueueAudio() with some frequency, to queue + * more audio samples to be played. + * - \c desired->userdata is passed as the first parameter to your callback + * function. If you passed a NULL callback, this value is ignored. + * + * The audio device starts out playing silence when it's opened, and should + * be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready + * for your audio callback function to be called. Since the audio driver + * may modify the requested size of the audio buffer, you should allocate + * any local mixing buffers after you open the audio device. + */ +extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, + SDL_AudioSpec * obtained); + +/** + * SDL Audio Device IDs. + * + * A successful call to SDL_OpenAudio() is always device id 1, and legacy + * SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls + * always returns devices >= 2 on success. The legacy calls are good both + * for backwards compatibility and when you don't care about multiple, + * specific, or capture devices. + */ +typedef Uint32 SDL_AudioDeviceID; + +/** + * Get the number of available devices exposed by the current driver. + * Only valid after a successfully initializing the audio subsystem. + * Returns -1 if an explicit list of devices can't be determined; this is + * not an error. For example, if SDL is set up to talk to a remote audio + * server, it can't list every one available on the Internet, but it will + * still allow a specific host to be specified to SDL_OpenAudioDevice(). + * + * In many common cases, when this function returns a value <= 0, it can still + * successfully open the default device (NULL for first argument of + * SDL_OpenAudioDevice()). + */ +extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture); + +/** + * Get the human-readable name of a specific audio device. + * Must be a value between 0 and (number of audio devices-1). + * Only valid after a successfully initializing the audio subsystem. + * The values returned by this function reflect the latest call to + * SDL_GetNumAudioDevices(); recall that function to redetect available + * hardware. + * + * The string returned by this function is UTF-8 encoded, read-only, and + * managed internally. You are not to free it. If you need to keep the + * string for any length of time, you should make your own copy of it, as it + * will be invalid next time any of several other SDL functions is called. + */ +extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, + int iscapture); + + +/** + * Open a specific audio device. Passing in a device name of NULL requests + * the most reasonable default (and is equivalent to calling SDL_OpenAudio()). + * + * The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but + * some drivers allow arbitrary and driver-specific strings, such as a + * hostname/IP address for a remote audio server, or a filename in the + * diskaudio driver. + * + * \return 0 on error, a valid device ID that is >= 2 on success. + * + * SDL_OpenAudio(), unlike this function, always acts on device ID 1. + */ +extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char + *device, + int iscapture, + const + SDL_AudioSpec * + desired, + SDL_AudioSpec * + obtained, + int + allowed_changes); + + + +/** + * \name Audio state + * + * Get the current audio state. + */ +/* @{ */ +typedef enum +{ + SDL_AUDIO_STOPPED = 0, + SDL_AUDIO_PLAYING, + SDL_AUDIO_PAUSED +} SDL_AudioStatus; +extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); + +extern DECLSPEC SDL_AudioStatus SDLCALL +SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); +/* @} *//* Audio State */ + +/** + * \name Pause audio functions + * + * These functions pause and unpause the audio callback processing. + * They should be called with a parameter of 0 after opening the audio + * device to start playing sound. This is so you can safely initialize + * data for your callback function after opening the audio device. + * Silence will be written to the audio device during the pause. + */ +/* @{ */ +extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); +extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, + int pause_on); +/* @} *//* Pause audio functions */ + +/** + * This function loads a WAVE from the data source, automatically freeing + * that source if \c freesrc is non-zero. For example, to load a WAVE file, + * you could do: + * \code + * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); + * \endcode + * + * If this function succeeds, it returns the given SDL_AudioSpec, + * filled with the audio data format of the wave data, and sets + * \c *audio_buf to a malloc()'d buffer containing the audio data, + * and sets \c *audio_len to the length of that audio buffer, in bytes. + * You need to free the audio buffer with SDL_FreeWAV() when you are + * done with it. + * + * This function returns NULL and sets the SDL error message if the + * wave file cannot be opened, uses an unknown data format, or is + * corrupt. Currently raw and MS-ADPCM WAVE files are supported. + */ +extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, + int freesrc, + SDL_AudioSpec * spec, + Uint8 ** audio_buf, + Uint32 * audio_len); + +/** + * Loads a WAV from a file. + * Compatibility convenience function. + */ +#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ + SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) + +/** + * This function frees data previously allocated with SDL_LoadWAV_RW() + */ +extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf); + +/** + * This function takes a source format and rate and a destination format + * and rate, and initializes the \c cvt structure with information needed + * by SDL_ConvertAudio() to convert a buffer of audio data from one format + * to the other. + * + * \return -1 if the format conversion is not supported, 0 if there's + * no conversion needed, or 1 if the audio filter is set up. + */ +extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, + SDL_AudioFormat src_format, + Uint8 src_channels, + int src_rate, + SDL_AudioFormat dst_format, + Uint8 dst_channels, + int dst_rate); + +/** + * Once you have initialized the \c cvt structure using SDL_BuildAudioCVT(), + * created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of + * audio data in the source format, this function will convert it in-place + * to the desired format. + * + * The data conversion may expand the size of the audio data, so the buffer + * \c cvt->buf should be allocated after the \c cvt structure is initialized by + * SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long. + */ +extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt); + +#define SDL_MIX_MAXVOLUME 128 +/** + * This takes two audio buffers of the playing audio format and mixes + * them, performing addition, volume adjustment, and overflow clipping. + * The volume ranges from 0 - 128, and should be set to ::SDL_MIX_MAXVOLUME + * for full audio volume. Note this does not change hardware volume. + * This is provided for convenience -- you can mix your own audio data. + */ +extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src, + Uint32 len, int volume); + +/** + * This works like SDL_MixAudio(), but you specify the audio format instead of + * using the format of audio device 1. Thus it can be used when no audio + * device is open at all. + */ +extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, + const Uint8 * src, + SDL_AudioFormat format, + Uint32 len, int volume); + +/** + * Queue more audio on non-callback devices. + * + * SDL offers two ways to feed audio to the device: you can either supply a + * callback that SDL triggers with some frequency to obtain more audio + * (pull method), or you can supply no callback, and then SDL will expect + * you to supply data at regular intervals (push method) with this function. + * + * There are no limits on the amount of data you can queue, short of + * exhaustion of address space. Queued data will drain to the device as + * necessary without further intervention from you. If the device needs + * audio but there is not enough queued, it will play silence to make up + * the difference. This means you will have skips in your audio playback + * if you aren't routinely queueing sufficient data. + * + * This function copies the supplied data, so you are safe to free it when + * the function returns. This function is thread-safe, but queueing to the + * same device from two threads at once does not promise which buffer will + * be queued first. + * + * You may not queue audio on a device that is using an application-supplied + * callback; doing so returns an error. You have to use the audio callback + * or queue audio with this function, but not both. + * + * You should not call SDL_LockAudio() on the device before queueing; SDL + * handles locking internally for this function. + * + * \param dev The device ID to which we will queue audio. + * \param data The data to queue to the device for later playback. + * \param len The number of bytes (not samples!) to which (data) points. + * \return zero on success, -1 on error. + * + * \sa SDL_GetQueuedAudioSize + * \sa SDL_ClearQueuedAudio + */ +extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len); + +/** + * Get the number of bytes of still-queued audio. + * + * This is the number of bytes that have been queued for playback with + * SDL_QueueAudio(), but have not yet been sent to the hardware. + * + * Once we've sent it to the hardware, this function can not decide the exact + * byte boundary of what has been played. It's possible that we just gave the + * hardware several kilobytes right before you called this function, but it + * hasn't played any of it yet, or maybe half of it, etc. + * + * You may not queue audio on a device that is using an application-supplied + * callback; calling this function on such a device always returns 0. + * You have to use the audio callback or queue audio with SDL_QueueAudio(), + * but not both. + * + * You should not call SDL_LockAudio() on the device before querying; SDL + * handles locking internally for this function. + * + * \param dev The device ID of which we will query queued audio size. + * \return Number of bytes (not samples!) of queued audio. + * + * \sa SDL_QueueAudio + * \sa SDL_ClearQueuedAudio + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev); + +/** + * Drop any queued audio data waiting to be sent to the hardware. + * + * Immediately after this call, SDL_GetQueuedAudioSize() will return 0 and + * the hardware will start playing silence if more audio isn't queued. + * + * This will not prevent playback of queued audio that's already been sent + * to the hardware, as we can not undo that, so expect there to be some + * fraction of a second of audio that might still be heard. This can be + * useful if you want to, say, drop any pending music during a level change + * in your game. + * + * You may not queue audio on a device that is using an application-supplied + * callback; calling this function on such a device is always a no-op. + * You have to use the audio callback or queue audio with SDL_QueueAudio(), + * but not both. + * + * You should not call SDL_LockAudio() on the device before clearing the + * queue; SDL handles locking internally for this function. + * + * This function always succeeds and thus returns void. + * + * \param dev The device ID of which to clear the audio queue. + * + * \sa SDL_QueueAudio + * \sa SDL_GetQueuedAudioSize + */ +extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev); + + +/** + * \name Audio lock functions + * + * The lock manipulated by these functions protects the callback function. + * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that + * the callback function is not running. Do not call these from the callback + * function or you will cause deadlock. + */ +/* @{ */ +extern DECLSPEC void SDLCALL SDL_LockAudio(void); +extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev); +extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); +extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); +/* @} *//* Audio lock functions */ + +/** + * This function shuts down audio processing and closes the audio device. + */ +extern DECLSPEC void SDLCALL SDL_CloseAudio(void); +extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_audio_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_bits.h b/#ThirdParty/libSDL/include/SDL_bits.h new file mode 100644 index 0000000..528da2e --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_bits.h @@ -0,0 +1,97 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_bits.h + * + * Functions for fiddling with bits and bitmasks. + */ + +#ifndef _SDL_bits_h +#define _SDL_bits_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_bits.h + */ + +/** + * Get the index of the most significant bit. Result is undefined when called + * with 0. This operation can also be stated as "count leading zeroes" and + * "log base 2". + * + * \return Index of the most significant bit, or -1 if the value is 0. + */ +SDL_FORCE_INLINE int +SDL_MostSignificantBitIndex32(Uint32 x) +{ +#if defined(__GNUC__) && __GNUC__ >= 4 + /* Count Leading Zeroes builtin in GCC. + * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html + */ + if (x == 0) { + return -1; + } + return 31 - __builtin_clz(x); +#else + /* Based off of Bit Twiddling Hacks by Sean Eron Anderson + * , released in the public domain. + * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog + */ + const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; + const int S[] = {1, 2, 4, 8, 16}; + + int msbIndex = 0; + int i; + + if (x == 0) { + return -1; + } + + for (i = 4; i >= 0; i--) + { + if (x & b[i]) + { + x >>= S[i]; + msbIndex |= S[i]; + } + } + + return msbIndex; +#endif +} + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_bits_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_blendmode.h b/#ThirdParty/libSDL/include/SDL_blendmode.h new file mode 100644 index 0000000..56d8ad6 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_blendmode.h @@ -0,0 +1,63 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_blendmode.h + * + * Header file declaring the SDL_BlendMode enumeration + */ + +#ifndef _SDL_blendmode_h +#define _SDL_blendmode_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The blend mode used in SDL_RenderCopy() and drawing operations. + */ +typedef enum +{ + SDL_BLENDMODE_NONE = 0x00000000, /**< no blending + dstRGBA = srcRGBA */ + SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending + dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) + dstA = srcA + (dstA * (1-srcA)) */ + SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending + dstRGB = (srcRGB * srcA) + dstRGB + dstA = dstA */ + SDL_BLENDMODE_MOD = 0x00000004 /**< color modulate + dstRGB = srcRGB * dstRGB + dstA = dstA */ +} SDL_BlendMode; + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_blendmode_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_clipboard.h b/#ThirdParty/libSDL/include/SDL_clipboard.h new file mode 100644 index 0000000..a5556f2 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_clipboard.h @@ -0,0 +1,71 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_clipboard.h + * + * Include file for SDL clipboard handling + */ + +#ifndef _SDL_clipboard_h +#define _SDL_clipboard_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * \brief Put UTF-8 text into the clipboard + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); + +/** + * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() + * + * \sa SDL_SetClipboardText() + */ +extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); + +/** + * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_clipboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_config.h b/#ThirdParty/libSDL/include/SDL_config.h new file mode 100644 index 0000000..890986c --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_config.h @@ -0,0 +1,221 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_config_windows_h +#define _SDL_config_windows_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ + +#ifdef _WIN64 +# define SIZEOF_VOIDP 8 +#else +# define SIZEOF_VOIDP 4 +#endif + +#define HAVE_DDRAW_H 1 +#define HAVE_DINPUT_H 1 +#define HAVE_DSOUND_H 1 +#define HAVE_DXGI_H 1 +#define HAVE_XINPUT_H 1 + +/* This is disabled by default to avoid C runtime dependencies and manifest requirements */ +#ifdef HAVE_LIBC +/* Useful headers */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE__LTOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_CEIL 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#if _MSC_VER >= 1800 +#define HAVE_STRTOLL 1 +#define HAVE_VSSCANF 1 +#define HAVE_COPYSIGN 1 +#define HAVE_SCALBN 1 +#endif +#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) +#define HAVE_M_PI 1 +#endif +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#endif + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_DSOUND 1 +#define SDL_AUDIO_DRIVER_XAUDIO2 1 +#define SDL_AUDIO_DRIVER_WINMM 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_DINPUT 1 +#define SDL_JOYSTICK_XINPUT 1 +#define SDL_HAPTIC_DINPUT 1 +#define SDL_HAPTIC_XINPUT 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WINDOWS 1 + +/* Enable various threading systems */ +#define SDL_THREAD_WINDOWS 1 + +/* Enable various timer systems */ +#define SDL_TIMER_WINDOWS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_WINDOWS 1 + +#ifndef SDL_VIDEO_RENDER_D3D +#define SDL_VIDEO_RENDER_D3D 1 +#endif +#ifndef SDL_VIDEO_RENDER_D3D11 +#define SDL_VIDEO_RENDER_D3D11 0 +#endif + +/* Enable OpenGL support */ +#ifndef SDL_VIDEO_OPENGL +#define SDL_VIDEO_OPENGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_WGL +#define SDL_VIDEO_OPENGL_WGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_ES2 +#define SDL_VIDEO_OPENGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_EGL +#define SDL_VIDEO_OPENGL_EGL 1 +#endif + + +/* Enable system power support */ +#define SDL_POWER_WINDOWS 1 + +/* Enable filesystem support */ +#define SDL_FILESYSTEM_WINDOWS 1 + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* _SDL_config_windows_h */ diff --git a/#ThirdParty/libSDL/include/SDL_cpuinfo.h b/#ThirdParty/libSDL/include/SDL_cpuinfo.h new file mode 100644 index 0000000..d0ba47b --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_cpuinfo.h @@ -0,0 +1,161 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_cpuinfo.h + * + * CPU feature detection for SDL. + */ + +#ifndef _SDL_cpuinfo_h +#define _SDL_cpuinfo_h + +#include "SDL_stdinc.h" + +/* Need to do this here because intrin.h has C++ code in it */ +/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ +#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) +#include +#ifndef _WIN64 +#define __MMX__ +#define __3dNOW__ +#endif +#define __SSE__ +#define __SSE2__ +#elif defined(__MINGW64_VERSION_MAJOR) +#include +#else +#ifdef __ALTIVEC__ +#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) +#include +#undef pixel +#endif +#endif +#ifdef __MMX__ +#include +#endif +#ifdef __3dNOW__ +#include +#endif +#ifdef __SSE__ +#include +#endif +#ifdef __SSE2__ +#include +#endif +#endif + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is a guess for the cacheline size used for padding. + * Most x86 processors have a 64 byte cache line. + * The 64-bit PowerPC processors have a 128 byte cache line. + * We'll use the larger value to be generally safe. + */ +#define SDL_CACHELINE_SIZE 128 + +/** + * This function returns the number of CPU cores available. + */ +extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); + +/** + * This function returns the L1 cache line size of the CPU + * + * This is useful for determining multi-threaded structure padding + * or SIMD prefetch sizes. + */ +extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); + +/** + * This function returns true if the CPU has the RDTSC instruction. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); + +/** + * This function returns true if the CPU has AltiVec features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); + +/** + * This function returns true if the CPU has MMX features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); + +/** + * This function returns true if the CPU has 3DNow! features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); + +/** + * This function returns true if the CPU has SSE features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); + +/** + * This function returns true if the CPU has SSE2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); + +/** + * This function returns true if the CPU has SSE3 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); + +/** + * This function returns true if the CPU has SSE4.1 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); + +/** + * This function returns true if the CPU has SSE4.2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); + +/** + * This function returns true if the CPU has AVX features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); + +/** + * This function returns true if the CPU has AVX2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void); + +/** + * This function returns the amount of RAM configured in the system, in MB. + */ +extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_cpuinfo_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_egl.h b/#ThirdParty/libSDL/include/SDL_egl.h new file mode 100644 index 0000000..bea2a6c --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_egl.h @@ -0,0 +1,1673 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_egl.h + * + * This is a simple file to encapsulate the EGL API headers. + */ +#ifndef _MSC_VER + +#include +#include + +#else /* _MSC_VER */ + +/* EGL headers for Visual Studio */ + +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. +* +* $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ +* +* Adopters may modify this file to suit their platform. Adopters are +* encouraged to submit platform specific modifications to the Khronos +* group so that they can be included in future versions of this file. +* Please submit changes by sending them to the public Khronos Bugzilla +* (http://khronos.org/bugzilla) by filing a bug against product +* "Khronos (general)" component "Registry". +* +* A predefined template which fills in some of the bug fields can be +* reached using http://tinyurl.com/khrplatform-h-bugreport, but you +* must create a Bugzilla login first. +* +* +* See the Implementer's Guidelines for information about where this file +* should be located on your system and for more details of its use: +* http://www.khronos.org/registry/implementers_guide.pdf +* +* This file should be included as +* #include +* by Khronos client API header files that use its types and defines. +* +* The types in khrplatform.h should only be used to define API-specific types. +* +* Types defined in khrplatform.h: +* khronos_int8_t signed 8 bit +* khronos_uint8_t unsigned 8 bit +* khronos_int16_t signed 16 bit +* khronos_uint16_t unsigned 16 bit +* khronos_int32_t signed 32 bit +* khronos_uint32_t unsigned 32 bit +* khronos_int64_t signed 64 bit +* khronos_uint64_t unsigned 64 bit +* khronos_intptr_t signed same number of bits as a pointer +* khronos_uintptr_t unsigned same number of bits as a pointer +* khronos_ssize_t signed size +* khronos_usize_t unsigned size +* khronos_float_t signed 32 bit floating point +* khronos_time_ns_t unsigned 64 bit time in nanoseconds +* khronos_utime_nanoseconds_t unsigned time interval or absolute time in +* nanoseconds +* khronos_stime_nanoseconds_t signed time interval in nanoseconds +* khronos_boolean_enum_t enumerated boolean type. This should +* only be used as a base type when a client API's boolean type is +* an enum. Client APIs which use an integer or other type for +* booleans cannot use this as the base type for their boolean. +* +* Tokens defined in khrplatform.h: +* +* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. +* +* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. +* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. +* +* Calling convention macros defined in this file: +* KHRONOS_APICALL +* KHRONOS_APIENTRY +* KHRONOS_APIATTRIBUTES +* +* These may be used in function prototypes as: +* +* KHRONOS_APICALL void KHRONOS_APIENTRY funcname( +* int arg1, +* int arg2) KHRONOS_APIATTRIBUTES; +*/ + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APICALL +*------------------------------------------------------------------------- +* This precedes the return type of the function in the function prototype. +*/ +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APIENTRY +*------------------------------------------------------------------------- +* This follows the return type of the function and precedes the function +* name in the function prototype. +*/ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) +/* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APIATTRIBUTES +*------------------------------------------------------------------------- +* This follows the closing parenthesis of the function prototype arguments. +*/ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- +* basic type definitions +*-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* +* Using +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* +* Using +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* +* Win32 +*/ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* +* Sun or Digital +*/ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* +* Hypothetical platform with no float or int64 support +*/ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* +* Generic fallback +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* +* Types that are (so far) the same on all platforms +*/ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* +* Types that differ between LLP64 and LP64 architectures - in LLP64, +* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears +* to be the only LLP64 architecture in current use. +*/ +#ifdef _WIN64 +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* +* Float type +*/ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types +* +* These types can be used to represent a time interval in nanoseconds or +* an absolute Unadjusted System Time. Unadjusted System Time is the number +* of nanoseconds since some arbitrary system event (e.g. since the last +* time the system booted). The Unadjusted System Time is an unsigned +* 64 bit value that wraps back to 0 every 584 years. Time intervals +* may be either signed or unsigned. +*/ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* +* Dummy value used to pad enum types to 32 bits. +*/ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* +* Enumerated boolean type +* +* Values other than zero should be considered to be true. Therefore +* comparisons should not be made against KHRONOS_TRUE. +*/ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ + + +#ifndef __eglplatform_h_ +#define __eglplatform_h_ + +/* +** Copyright (c) 2007-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Platform-specific types and definitions for egl.h +* $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $ +* +* Adopters may modify khrplatform.h and this file to suit their platform. +* You are encouraged to submit all modifications to the Khronos group so that +* they can be included in future versions of this file. Please submit changes +* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) +* by filing a bug against product "EGL" component "Registry". +*/ + +/*#include */ + +/* Macros used in EGL function prototype declarations. +* +* EGL functions should be prototyped as: +* +* EGLAPI return-type EGLAPIENTRY eglFunction(arguments); +* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); +* +* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h +*/ + +#ifndef EGLAPI +#define EGLAPI KHRONOS_APICALL +#endif + +#ifndef EGLAPIENTRY +#define EGLAPIENTRY KHRONOS_APIENTRY +#endif +#define EGLAPIENTRYP EGLAPIENTRY* + +/* The types NativeDisplayType, NativeWindowType, and NativePixmapType +* are aliases of window-system-dependent types, such as X Display * or +* Windows Device Context. They must be defined in platform-specific +* code below. The EGL-prefixed versions of Native*Type are the same +* types, renamed in EGL 1.3 so all types in the API start with "EGL". +* +* Khronos STRONGLY RECOMMENDS that you use the default definitions +* provided below, since these changes affect both binary and source +* portability of applications using EGL running on different EGL +* implementations. +*/ + +#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include + +#if __WINRT__ +#include +typedef IUnknown * EGLNativeWindowType; +typedef IUnknown * EGLNativePixmapType; +typedef IUnknown * EGLNativeDisplayType; +#else +typedef HDC EGLNativeDisplayType; +typedef HBITMAP EGLNativePixmapType; +typedef HWND EGLNativeWindowType; +#endif + +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ + +typedef int EGLNativeDisplayType; +typedef void *EGLNativeWindowType; +typedef void *EGLNativePixmapType; + +#elif defined(WL_EGL_PLATFORM) + +typedef struct wl_display *EGLNativeDisplayType; +typedef struct wl_egl_pixmap *EGLNativePixmapType; +typedef struct wl_egl_window *EGLNativeWindowType; + +#elif defined(__GBM__) + +typedef struct gbm_device *EGLNativeDisplayType; +typedef struct gbm_bo *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(__ANDROID__) /* Android */ + +struct ANativeWindow; +struct egl_native_pixmap_t; + +typedef struct ANativeWindow *EGLNativeWindowType; +typedef struct egl_native_pixmap_t *EGLNativePixmapType; +typedef void *EGLNativeDisplayType; + +#elif defined(MIR_EGL_PLATFORM) + +#include +typedef MirEGLNativeDisplayType EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef MirEGLNativeWindowType EGLNativeWindowType; + +#elif defined(__unix__) + +#ifdef MESA_EGL_NO_X11_HEADERS + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#else + +/* X11 (tentative) */ +#include +#include + +typedef Display *EGLNativeDisplayType; +typedef Pixmap EGLNativePixmapType; +typedef Window EGLNativeWindowType; + +#endif /* MESA_EGL_NO_X11_HEADERS */ + +#else +#error "Platform not recognized" +#endif + +/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ +typedef EGLNativeDisplayType NativeDisplayType; +typedef EGLNativePixmapType NativePixmapType; +typedef EGLNativeWindowType NativeWindowType; + + +/* Define EGLint. This must be a signed integral type large enough to contain +* all legal attribute names and values passed into and out of EGL, whether +* their type is boolean, bitmask, enumerant (symbolic constant), integer, +* handle, or other. While in general a 32-bit integer will suffice, if +* handles are 64 bit types, then EGLint should be defined as a signed 64-bit +* integer type. +*/ +typedef khronos_int32_t EGLint; + +#endif /* __eglplatform_h */ + +#ifndef __egl_h_ +#define __egl_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2015 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 31566 $ on $Date: 2015-06-23 08:48:48 -0700 (Tue, 23 Jun 2015) $ +*/ + +/*#include */ + +/* Generated on date 20150623 */ + +/* Generated C header for: + * API: egl + * Versions considered: .* + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef EGL_VERSION_1_0 +#define EGL_VERSION_1_0 1 +typedef unsigned int EGLBoolean; +typedef void *EGLDisplay; +typedef void *EGLConfig; +typedef void *EGLSurface; +typedef void *EGLContext; +typedef void (*__eglMustCastToProperFunctionPointerType)(void); +#define EGL_ALPHA_SIZE 0x3021 +#define EGL_BAD_ACCESS 0x3002 +#define EGL_BAD_ALLOC 0x3003 +#define EGL_BAD_ATTRIBUTE 0x3004 +#define EGL_BAD_CONFIG 0x3005 +#define EGL_BAD_CONTEXT 0x3006 +#define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DISPLAY 0x3008 +#define EGL_BAD_MATCH 0x3009 +#define EGL_BAD_NATIVE_PIXMAP 0x300A +#define EGL_BAD_NATIVE_WINDOW 0x300B +#define EGL_BAD_PARAMETER 0x300C +#define EGL_BAD_SURFACE 0x300D +#define EGL_BLUE_SIZE 0x3022 +#define EGL_BUFFER_SIZE 0x3020 +#define EGL_CONFIG_CAVEAT 0x3027 +#define EGL_CONFIG_ID 0x3028 +#define EGL_CORE_NATIVE_ENGINE 0x305B +#define EGL_DEPTH_SIZE 0x3025 +#define EGL_DONT_CARE ((EGLint)-1) +#define EGL_DRAW 0x3059 +#define EGL_EXTENSIONS 0x3055 +#define EGL_FALSE 0 +#define EGL_GREEN_SIZE 0x3023 +#define EGL_HEIGHT 0x3056 +#define EGL_LARGEST_PBUFFER 0x3058 +#define EGL_LEVEL 0x3029 +#define EGL_MAX_PBUFFER_HEIGHT 0x302A +#define EGL_MAX_PBUFFER_PIXELS 0x302B +#define EGL_MAX_PBUFFER_WIDTH 0x302C +#define EGL_NATIVE_RENDERABLE 0x302D +#define EGL_NATIVE_VISUAL_ID 0x302E +#define EGL_NATIVE_VISUAL_TYPE 0x302F +#define EGL_NONE 0x3038 +#define EGL_NON_CONFORMANT_CONFIG 0x3051 +#define EGL_NOT_INITIALIZED 0x3001 +#define EGL_NO_CONTEXT ((EGLContext)0) +#define EGL_NO_DISPLAY ((EGLDisplay)0) +#define EGL_NO_SURFACE ((EGLSurface)0) +#define EGL_PBUFFER_BIT 0x0001 +#define EGL_PIXMAP_BIT 0x0002 +#define EGL_READ 0x305A +#define EGL_RED_SIZE 0x3024 +#define EGL_SAMPLES 0x3031 +#define EGL_SAMPLE_BUFFERS 0x3032 +#define EGL_SLOW_CONFIG 0x3050 +#define EGL_STENCIL_SIZE 0x3026 +#define EGL_SUCCESS 0x3000 +#define EGL_SURFACE_TYPE 0x3033 +#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 +#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 +#define EGL_TRANSPARENT_RED_VALUE 0x3037 +#define EGL_TRANSPARENT_RGB 0x3052 +#define EGL_TRANSPARENT_TYPE 0x3034 +#define EGL_TRUE 1 +#define EGL_VENDOR 0x3053 +#define EGL_VERSION 0x3054 +#define EGL_WIDTH 0x3057 +#define EGL_WINDOW_BIT 0x0004 +EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); +EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); +EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); +EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void); +EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw); +EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id); +EGLAPI EGLint EGLAPIENTRY eglGetError (void); +EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname); +EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor); +EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); +EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); +#endif /* EGL_VERSION_1_0 */ + +#ifndef EGL_VERSION_1_1 +#define EGL_VERSION_1_1 1 +#define EGL_BACK_BUFFER 0x3084 +#define EGL_BIND_TO_TEXTURE_RGB 0x3039 +#define EGL_BIND_TO_TEXTURE_RGBA 0x303A +#define EGL_CONTEXT_LOST 0x300E +#define EGL_MIN_SWAP_INTERVAL 0x303B +#define EGL_MAX_SWAP_INTERVAL 0x303C +#define EGL_MIPMAP_TEXTURE 0x3082 +#define EGL_MIPMAP_LEVEL 0x3083 +#define EGL_NO_TEXTURE 0x305C +#define EGL_TEXTURE_2D 0x305F +#define EGL_TEXTURE_FORMAT 0x3080 +#define EGL_TEXTURE_RGB 0x305D +#define EGL_TEXTURE_RGBA 0x305E +#define EGL_TEXTURE_TARGET 0x3081 +EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval); +#endif /* EGL_VERSION_1_1 */ + +#ifndef EGL_VERSION_1_2 +#define EGL_VERSION_1_2 1 +typedef unsigned int EGLenum; +typedef void *EGLClientBuffer; +#define EGL_ALPHA_FORMAT 0x3088 +#define EGL_ALPHA_FORMAT_NONPRE 0x308B +#define EGL_ALPHA_FORMAT_PRE 0x308C +#define EGL_ALPHA_MASK_SIZE 0x303E +#define EGL_BUFFER_PRESERVED 0x3094 +#define EGL_BUFFER_DESTROYED 0x3095 +#define EGL_CLIENT_APIS 0x308D +#define EGL_COLORSPACE 0x3087 +#define EGL_COLORSPACE_sRGB 0x3089 +#define EGL_COLORSPACE_LINEAR 0x308A +#define EGL_COLOR_BUFFER_TYPE 0x303F +#define EGL_CONTEXT_CLIENT_TYPE 0x3097 +#define EGL_DISPLAY_SCALING 10000 +#define EGL_HORIZONTAL_RESOLUTION 0x3090 +#define EGL_LUMINANCE_BUFFER 0x308F +#define EGL_LUMINANCE_SIZE 0x303D +#define EGL_OPENGL_ES_BIT 0x0001 +#define EGL_OPENVG_BIT 0x0002 +#define EGL_OPENGL_ES_API 0x30A0 +#define EGL_OPENVG_API 0x30A1 +#define EGL_OPENVG_IMAGE 0x3096 +#define EGL_PIXEL_ASPECT_RATIO 0x3092 +#define EGL_RENDERABLE_TYPE 0x3040 +#define EGL_RENDER_BUFFER 0x3086 +#define EGL_RGB_BUFFER 0x308E +#define EGL_SINGLE_BUFFER 0x3085 +#define EGL_SWAP_BEHAVIOR 0x3093 +#define EGL_UNKNOWN ((EGLint)-1) +#define EGL_VERTICAL_RESOLUTION 0x3091 +EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api); +EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); +#endif /* EGL_VERSION_1_2 */ + +#ifndef EGL_VERSION_1_3 +#define EGL_VERSION_1_3 1 +#define EGL_CONFORMANT 0x3042 +#define EGL_CONTEXT_CLIENT_VERSION 0x3098 +#define EGL_MATCH_NATIVE_PIXMAP 0x3041 +#define EGL_OPENGL_ES2_BIT 0x0004 +#define EGL_VG_ALPHA_FORMAT 0x3088 +#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B +#define EGL_VG_ALPHA_FORMAT_PRE 0x308C +#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 +#define EGL_VG_COLORSPACE 0x3087 +#define EGL_VG_COLORSPACE_sRGB 0x3089 +#define EGL_VG_COLORSPACE_LINEAR 0x308A +#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 +#endif /* EGL_VERSION_1_3 */ + +#ifndef EGL_VERSION_1_4 +#define EGL_VERSION_1_4 1 +#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) +#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 +#define EGL_MULTISAMPLE_RESOLVE 0x3099 +#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A +#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B +#define EGL_OPENGL_API 0x30A2 +#define EGL_OPENGL_BIT 0x0008 +#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 +EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void); +#endif /* EGL_VERSION_1_4 */ + +#ifndef EGL_VERSION_1_5 +#define EGL_VERSION_1_5 1 +typedef void *EGLSync; +typedef intptr_t EGLAttrib; +typedef khronos_utime_nanoseconds_t EGLTime; +typedef void *EGLImage; +#define EGL_CONTEXT_MAJOR_VERSION 0x3098 +#define EGL_CONTEXT_MINOR_VERSION 0x30FB +#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD +#define EGL_NO_RESET_NOTIFICATION 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 +#define EGL_OPENGL_ES3_BIT 0x00000040 +#define EGL_CL_EVENT_HANDLE 0x309C +#define EGL_SYNC_CL_EVENT 0x30FE +#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 +#define EGL_SYNC_TYPE 0x30F7 +#define EGL_SYNC_STATUS 0x30F1 +#define EGL_SYNC_CONDITION 0x30F8 +#define EGL_SIGNALED 0x30F2 +#define EGL_UNSIGNALED 0x30F3 +#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 +#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull +#define EGL_TIMEOUT_EXPIRED 0x30F5 +#define EGL_CONDITION_SATISFIED 0x30F6 +#define EGL_NO_SYNC ((EGLSync)0) +#define EGL_SYNC_FENCE 0x30F9 +#define EGL_GL_COLORSPACE 0x309D +#define EGL_GL_COLORSPACE_SRGB 0x3089 +#define EGL_GL_COLORSPACE_LINEAR 0x308A +#define EGL_GL_RENDERBUFFER 0x30B9 +#define EGL_GL_TEXTURE_2D 0x30B1 +#define EGL_GL_TEXTURE_LEVEL 0x30BC +#define EGL_GL_TEXTURE_3D 0x30B2 +#define EGL_GL_TEXTURE_ZOFFSET 0x30BD +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 +#define EGL_IMAGE_PRESERVED 0x30D2 +#define EGL_NO_IMAGE ((EGLImage)0) +EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); +EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image); +EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags); +#endif /* EGL_VERSION_1_5 */ + +#ifdef __cplusplus +} +#endif + +#endif /* __egl_h_ */ + + + +#ifndef __eglext_h_ +#define __eglext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2015 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 31566 $ on $Date: 2015-06-23 08:48:48 -0700 (Tue, 23 Jun 2015) $ +*/ + +/*#include */ + +#define EGL_EGLEXT_VERSION 20150623 + +/* Generated C header for: + * API: egl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: egl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef EGL_KHR_cl_event +#define EGL_KHR_cl_event 1 +#define EGL_CL_EVENT_HANDLE_KHR 0x309C +#define EGL_SYNC_CL_EVENT_KHR 0x30FE +#define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF +#endif /* EGL_KHR_cl_event */ + +#ifndef EGL_KHR_cl_event2 +#define EGL_KHR_cl_event2 1 +typedef void *EGLSyncKHR; +typedef intptr_t EGLAttribKHR; +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); +#endif +#endif /* EGL_KHR_cl_event2 */ + +#ifndef EGL_KHR_client_get_all_proc_addresses +#define EGL_KHR_client_get_all_proc_addresses 1 +#endif /* EGL_KHR_client_get_all_proc_addresses */ + +#ifndef EGL_KHR_config_attribs +#define EGL_KHR_config_attribs 1 +#define EGL_CONFORMANT_KHR 0x3042 +#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 +#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 +#endif /* EGL_KHR_config_attribs */ + +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 +#endif /* EGL_KHR_create_context */ + +#ifndef EGL_KHR_create_context_no_error +#define EGL_KHR_create_context_no_error 1 +#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3 +#endif /* EGL_KHR_create_context_no_error */ + +#ifndef EGL_KHR_fence_sync +#define EGL_KHR_fence_sync 1 +typedef khronos_utime_nanoseconds_t EGLTimeKHR; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 +#define EGL_SYNC_CONDITION_KHR 0x30F8 +#define EGL_SYNC_FENCE_KHR 0x30F9 +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_fence_sync */ + +#ifndef EGL_KHR_get_all_proc_addresses +#define EGL_KHR_get_all_proc_addresses 1 +#endif /* EGL_KHR_get_all_proc_addresses */ + +#ifndef EGL_KHR_gl_colorspace +#define EGL_KHR_gl_colorspace 1 +#define EGL_GL_COLORSPACE_KHR 0x309D +#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 +#define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A +#endif /* EGL_KHR_gl_colorspace */ + +#ifndef EGL_KHR_gl_renderbuffer_image +#define EGL_KHR_gl_renderbuffer_image 1 +#define EGL_GL_RENDERBUFFER_KHR 0x30B9 +#endif /* EGL_KHR_gl_renderbuffer_image */ + +#ifndef EGL_KHR_gl_texture_2D_image +#define EGL_KHR_gl_texture_2D_image 1 +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 +#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC +#endif /* EGL_KHR_gl_texture_2D_image */ + +#ifndef EGL_KHR_gl_texture_3D_image +#define EGL_KHR_gl_texture_3D_image 1 +#define EGL_GL_TEXTURE_3D_KHR 0x30B2 +#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD +#endif /* EGL_KHR_gl_texture_3D_image */ + +#ifndef EGL_KHR_gl_texture_cubemap_image +#define EGL_KHR_gl_texture_cubemap_image 1 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 +#endif /* EGL_KHR_gl_texture_cubemap_image */ + +#ifndef EGL_KHR_image +#define EGL_KHR_image 1 +typedef void *EGLImageKHR; +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 +#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); +#endif +#endif /* EGL_KHR_image */ + +#ifndef EGL_KHR_image_base +#define EGL_KHR_image_base 1 +#define EGL_IMAGE_PRESERVED_KHR 0x30D2 +#endif /* EGL_KHR_image_base */ + +#ifndef EGL_KHR_image_pixmap +#define EGL_KHR_image_pixmap 1 +#endif /* EGL_KHR_image_pixmap */ + +#ifndef EGL_KHR_lock_surface +#define EGL_KHR_lock_surface 1 +#define EGL_READ_SURFACE_BIT_KHR 0x0001 +#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 +#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 +#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 +#define EGL_MATCH_FORMAT_KHR 0x3043 +#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 +#define EGL_FORMAT_RGB_565_KHR 0x30C1 +#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 +#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 +#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 +#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 +#define EGL_BITMAP_POINTER_KHR 0x30C6 +#define EGL_BITMAP_PITCH_KHR 0x30C7 +#define EGL_BITMAP_ORIGIN_KHR 0x30C8 +#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 +#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA +#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB +#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC +#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD +#define EGL_LOWER_LEFT_KHR 0x30CE +#define EGL_UPPER_LEFT_KHR 0x30CF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface); +#endif +#endif /* EGL_KHR_lock_surface */ + +#ifndef EGL_KHR_lock_surface2 +#define EGL_KHR_lock_surface2 1 +#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 +#endif /* EGL_KHR_lock_surface2 */ + +#ifndef EGL_KHR_lock_surface3 +#define EGL_KHR_lock_surface3 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#endif +#endif /* EGL_KHR_lock_surface3 */ + +#ifndef EGL_KHR_partial_update +#define EGL_KHR_partial_update 1 +#define EGL_BUFFER_AGE_KHR 0x313D +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETDAMAGEREGIONKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_KHR_partial_update */ + +#ifndef EGL_KHR_platform_android +#define EGL_KHR_platform_android 1 +#define EGL_PLATFORM_ANDROID_KHR 0x3141 +#endif /* EGL_KHR_platform_android */ + +#ifndef EGL_KHR_platform_gbm +#define EGL_KHR_platform_gbm 1 +#define EGL_PLATFORM_GBM_KHR 0x31D7 +#endif /* EGL_KHR_platform_gbm */ + +#ifndef EGL_KHR_platform_wayland +#define EGL_KHR_platform_wayland 1 +#define EGL_PLATFORM_WAYLAND_KHR 0x31D8 +#endif /* EGL_KHR_platform_wayland */ + +#ifndef EGL_KHR_platform_x11 +#define EGL_KHR_platform_x11 1 +#define EGL_PLATFORM_X11_KHR 0x31D5 +#define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 +#endif /* EGL_KHR_platform_x11 */ + +#ifndef EGL_KHR_reusable_sync +#define EGL_KHR_reusable_sync 1 +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_STATUS_KHR 0x30F1 +#define EGL_SIGNALED_KHR 0x30F2 +#define EGL_UNSIGNALED_KHR 0x30F3 +#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 +#define EGL_CONDITION_SATISFIED_KHR 0x30F6 +#define EGL_SYNC_TYPE_KHR 0x30F7 +#define EGL_SYNC_REUSABLE_KHR 0x30FA +#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 +#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull +#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_reusable_sync */ + +#ifndef EGL_KHR_stream +#define EGL_KHR_stream 1 +typedef void *EGLStreamKHR; +typedef khronos_uint64_t EGLuint64KHR; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) +#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 +#define EGL_PRODUCER_FRAME_KHR 0x3212 +#define EGL_CONSUMER_FRAME_KHR 0x3213 +#define EGL_STREAM_STATE_KHR 0x3214 +#define EGL_STREAM_STATE_CREATED_KHR 0x3215 +#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 +#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 +#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 +#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 +#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A +#define EGL_BAD_STREAM_KHR 0x321B +#define EGL_BAD_STATE_KHR 0x321C +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_stream */ + +#ifndef EGL_KHR_stream_consumer_gltexture +#define EGL_KHR_stream_consumer_gltexture 1 +#ifdef EGL_KHR_stream +#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_consumer_gltexture */ + +#ifndef EGL_KHR_stream_cross_process_fd +#define EGL_KHR_stream_cross_process_fd 1 +typedef int EGLNativeFileDescriptorKHR; +#ifdef EGL_KHR_stream +#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) +typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_cross_process_fd */ + +#ifndef EGL_KHR_stream_fifo +#define EGL_KHR_stream_fifo 1 +#ifdef EGL_KHR_stream +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC +#define EGL_STREAM_TIME_NOW_KHR 0x31FD +#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE +#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_fifo */ + +#ifndef EGL_KHR_stream_producer_aldatalocator +#define EGL_KHR_stream_producer_aldatalocator 1 +#ifdef EGL_KHR_stream +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_producer_aldatalocator */ + +#ifndef EGL_KHR_stream_producer_eglsurface +#define EGL_KHR_stream_producer_eglsurface 1 +#ifdef EGL_KHR_stream +#define EGL_STREAM_BIT_KHR 0x0800 +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_producer_eglsurface */ + +#ifndef EGL_KHR_surfaceless_context +#define EGL_KHR_surfaceless_context 1 +#endif /* EGL_KHR_surfaceless_context */ + +#ifndef EGL_KHR_swap_buffers_with_damage +#define EGL_KHR_swap_buffers_with_damage 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_KHR_swap_buffers_with_damage */ + +#ifndef EGL_KHR_vg_parent_image +#define EGL_KHR_vg_parent_image 1 +#define EGL_VG_PARENT_IMAGE_KHR 0x30BA +#endif /* EGL_KHR_vg_parent_image */ + +#ifndef EGL_KHR_wait_sync +#define EGL_KHR_wait_sync 1 +typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif +#endif /* EGL_KHR_wait_sync */ + +#ifndef EGL_ANDROID_blob_cache +#define EGL_ANDROID_blob_cache 1 +typedef khronos_ssize_t EGLsizeiANDROID; +typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); +typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); +typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif +#endif /* EGL_ANDROID_blob_cache */ + +#ifndef EGL_ANDROID_framebuffer_target +#define EGL_ANDROID_framebuffer_target 1 +#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 +#endif /* EGL_ANDROID_framebuffer_target */ + +#ifndef EGL_ANDROID_image_native_buffer +#define EGL_ANDROID_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_ANDROID 0x3140 +#endif /* EGL_ANDROID_image_native_buffer */ + +#ifndef EGL_ANDROID_native_fence_sync +#define EGL_ANDROID_native_fence_sync 1 +#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 +#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 +#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 +#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 +typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync); +#endif +#endif /* EGL_ANDROID_native_fence_sync */ + +#ifndef EGL_ANDROID_recordable +#define EGL_ANDROID_recordable 1 +#define EGL_RECORDABLE_ANDROID 0x3142 +#endif /* EGL_ANDROID_recordable */ + +#ifndef EGL_ANGLE_d3d_share_handle_client_buffer +#define EGL_ANGLE_d3d_share_handle_client_buffer 1 +#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 +#endif /* EGL_ANGLE_d3d_share_handle_client_buffer */ + +#ifndef EGL_ANGLE_device_d3d +#define EGL_ANGLE_device_d3d 1 +#define EGL_D3D9_DEVICE_ANGLE 0x33A0 +#define EGL_D3D11_DEVICE_ANGLE 0x33A1 +#endif /* EGL_ANGLE_device_d3d */ + +#ifndef EGL_ANGLE_query_surface_pointer +#define EGL_ANGLE_query_surface_pointer 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#endif +#endif /* EGL_ANGLE_query_surface_pointer */ + +#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle +#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 +#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ + +#ifndef EGL_ANGLE_window_fixed_size +#define EGL_ANGLE_window_fixed_size 1 +#define EGL_FIXED_SIZE_ANGLE 0x3201 +#endif /* EGL_ANGLE_window_fixed_size */ + +#ifndef EGL_ARM_pixmap_multisample_discard +#define EGL_ARM_pixmap_multisample_discard 1 +#define EGL_DISCARD_SAMPLES_ARM 0x3286 +#endif /* EGL_ARM_pixmap_multisample_discard */ + +#ifndef EGL_EXT_buffer_age +#define EGL_EXT_buffer_age 1 +#define EGL_BUFFER_AGE_EXT 0x313D +#endif /* EGL_EXT_buffer_age */ + +#ifndef EGL_EXT_client_extensions +#define EGL_EXT_client_extensions 1 +#endif /* EGL_EXT_client_extensions */ + +#ifndef EGL_EXT_create_context_robustness +#define EGL_EXT_create_context_robustness 1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 +#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF +#endif /* EGL_EXT_create_context_robustness */ + +#ifndef EGL_EXT_device_base +#define EGL_EXT_device_base 1 +typedef void *EGLDeviceEXT; +#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0)) +#define EGL_BAD_DEVICE_EXT 0x322B +#define EGL_DEVICE_EXT 0x322C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +#endif +#endif /* EGL_EXT_device_base */ + +#ifndef EGL_EXT_device_drm +#define EGL_EXT_device_drm 1 +#define EGL_DRM_DEVICE_FILE_EXT 0x3233 +#endif /* EGL_EXT_device_drm */ + +#ifndef EGL_EXT_device_enumeration +#define EGL_EXT_device_enumeration 1 +#endif /* EGL_EXT_device_enumeration */ + +#ifndef EGL_EXT_device_openwf +#define EGL_EXT_device_openwf 1 +#define EGL_OPENWF_DEVICE_ID_EXT 0x3237 +#endif /* EGL_EXT_device_openwf */ + +#ifndef EGL_EXT_device_query +#define EGL_EXT_device_query 1 +#endif /* EGL_EXT_device_query */ + +#ifndef EGL_EXT_image_dma_buf_import +#define EGL_EXT_image_dma_buf_import 1 +#define EGL_LINUX_DMA_BUF_EXT 0x3270 +#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 +#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 +#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 +#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B +#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C +#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E +#define EGL_ITU_REC601_EXT 0x327F +#define EGL_ITU_REC709_EXT 0x3280 +#define EGL_ITU_REC2020_EXT 0x3281 +#define EGL_YUV_FULL_RANGE_EXT 0x3282 +#define EGL_YUV_NARROW_RANGE_EXT 0x3283 +#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 +#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 +#endif /* EGL_EXT_image_dma_buf_import */ + +#ifndef EGL_EXT_multiview_window +#define EGL_EXT_multiview_window 1 +#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 +#endif /* EGL_EXT_multiview_window */ + +#ifndef EGL_EXT_output_base +#define EGL_EXT_output_base 1 +typedef void *EGLOutputLayerEXT; +typedef void *EGLOutputPortEXT; +#define EGL_NO_OUTPUT_LAYER_EXT ((EGLOutputLayerEXT)0) +#define EGL_NO_OUTPUT_PORT_EXT ((EGLOutputPortEXT)0) +#define EGL_BAD_OUTPUT_LAYER_EXT 0x322D +#define EGL_BAD_OUTPUT_PORT_EXT 0x322E +#define EGL_SWAP_INTERVAL_EXT 0x322F +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputLayersEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); +EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputPortsEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); +EGLAPI EGLBoolean EGLAPIENTRY eglOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryOutputLayerStringEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryOutputPortStringEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); +#endif +#endif /* EGL_EXT_output_base */ + +#ifndef EGL_EXT_output_drm +#define EGL_EXT_output_drm 1 +#define EGL_DRM_CRTC_EXT 0x3234 +#define EGL_DRM_PLANE_EXT 0x3235 +#define EGL_DRM_CONNECTOR_EXT 0x3236 +#endif /* EGL_EXT_output_drm */ + +#ifndef EGL_EXT_output_openwf +#define EGL_EXT_output_openwf 1 +#define EGL_OPENWF_PIPELINE_ID_EXT 0x3238 +#define EGL_OPENWF_PORT_ID_EXT 0x3239 +#endif /* EGL_EXT_output_openwf */ + +#ifndef EGL_EXT_platform_base +#define EGL_EXT_platform_base 1 +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); +#endif +#endif /* EGL_EXT_platform_base */ + +#ifndef EGL_EXT_platform_device +#define EGL_EXT_platform_device 1 +#define EGL_PLATFORM_DEVICE_EXT 0x313F +#endif /* EGL_EXT_platform_device */ + +#ifndef EGL_EXT_platform_wayland +#define EGL_EXT_platform_wayland 1 +#define EGL_PLATFORM_WAYLAND_EXT 0x31D8 +#endif /* EGL_EXT_platform_wayland */ + +#ifndef EGL_EXT_platform_x11 +#define EGL_EXT_platform_x11 1 +#define EGL_PLATFORM_X11_EXT 0x31D5 +#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 +#endif /* EGL_EXT_platform_x11 */ + +#ifndef EGL_EXT_protected_surface +#define EGL_EXT_protected_surface 1 +#define EGL_PROTECTED_CONTENT_EXT 0x32C0 +#endif /* EGL_EXT_protected_surface */ + +#ifndef EGL_EXT_stream_consumer_egloutput +#define EGL_EXT_stream_consumer_egloutput 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerOutputEXT (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); +#endif +#endif /* EGL_EXT_stream_consumer_egloutput */ + +#ifndef EGL_EXT_swap_buffers_with_damage +#define EGL_EXT_swap_buffers_with_damage 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_EXT_swap_buffers_with_damage */ + +#ifndef EGL_EXT_yuv_surface +#define EGL_EXT_yuv_surface 1 +#define EGL_YUV_ORDER_EXT 0x3301 +#define EGL_YUV_NUMBER_OF_PLANES_EXT 0x3311 +#define EGL_YUV_SUBSAMPLE_EXT 0x3312 +#define EGL_YUV_DEPTH_RANGE_EXT 0x3317 +#define EGL_YUV_CSC_STANDARD_EXT 0x330A +#define EGL_YUV_PLANE_BPP_EXT 0x331A +#define EGL_YUV_BUFFER_EXT 0x3300 +#define EGL_YUV_ORDER_YUV_EXT 0x3302 +#define EGL_YUV_ORDER_YVU_EXT 0x3303 +#define EGL_YUV_ORDER_YUYV_EXT 0x3304 +#define EGL_YUV_ORDER_UYVY_EXT 0x3305 +#define EGL_YUV_ORDER_YVYU_EXT 0x3306 +#define EGL_YUV_ORDER_VYUY_EXT 0x3307 +#define EGL_YUV_ORDER_AYUV_EXT 0x3308 +#define EGL_YUV_SUBSAMPLE_4_2_0_EXT 0x3313 +#define EGL_YUV_SUBSAMPLE_4_2_2_EXT 0x3314 +#define EGL_YUV_SUBSAMPLE_4_4_4_EXT 0x3315 +#define EGL_YUV_DEPTH_RANGE_LIMITED_EXT 0x3318 +#define EGL_YUV_DEPTH_RANGE_FULL_EXT 0x3319 +#define EGL_YUV_CSC_STANDARD_601_EXT 0x330B +#define EGL_YUV_CSC_STANDARD_709_EXT 0x330C +#define EGL_YUV_CSC_STANDARD_2020_EXT 0x330D +#define EGL_YUV_PLANE_BPP_0_EXT 0x331B +#define EGL_YUV_PLANE_BPP_8_EXT 0x331C +#define EGL_YUV_PLANE_BPP_10_EXT 0x331D +#endif /* EGL_EXT_yuv_surface */ + +#ifndef EGL_HI_clientpixmap +#define EGL_HI_clientpixmap 1 +struct EGLClientPixmapHI { + void *pData; + EGLint iWidth; + EGLint iHeight; + EGLint iStride; +}; +#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); +#endif +#endif /* EGL_HI_clientpixmap */ + +#ifndef EGL_HI_colorformats +#define EGL_HI_colorformats 1 +#define EGL_COLOR_FORMAT_HI 0x8F70 +#define EGL_COLOR_RGB_HI 0x8F71 +#define EGL_COLOR_RGBA_HI 0x8F72 +#define EGL_COLOR_ARGB_HI 0x8F73 +#endif /* EGL_HI_colorformats */ + +#ifndef EGL_IMG_context_priority +#define EGL_IMG_context_priority 1 +#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 +#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 +#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 +#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 +#endif /* EGL_IMG_context_priority */ + +#ifndef EGL_MESA_drm_image +#define EGL_MESA_drm_image 1 +#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 +#define EGL_DRM_BUFFER_USE_MESA 0x31D1 +#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 +#define EGL_DRM_BUFFER_MESA 0x31D3 +#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 +#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 +#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif +#endif /* EGL_MESA_drm_image */ + +#ifndef EGL_MESA_image_dma_buf_export +#define EGL_MESA_image_dma_buf_export 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageQueryMESA (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); +#endif +#endif /* EGL_MESA_image_dma_buf_export */ + +#ifndef EGL_MESA_platform_gbm +#define EGL_MESA_platform_gbm 1 +#define EGL_PLATFORM_GBM_MESA 0x31D7 +#endif /* EGL_MESA_platform_gbm */ + +#ifndef EGL_NOK_swap_region +#define EGL_NOK_swap_region 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#endif +#endif /* EGL_NOK_swap_region */ + +#ifndef EGL_NOK_swap_region2 +#define EGL_NOK_swap_region2 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#endif +#endif /* EGL_NOK_swap_region2 */ + +#ifndef EGL_NOK_texture_from_pixmap +#define EGL_NOK_texture_from_pixmap 1 +#define EGL_Y_INVERTED_NOK 0x307F +#endif /* EGL_NOK_texture_from_pixmap */ + +#ifndef EGL_NV_3dvision_surface +#define EGL_NV_3dvision_surface 1 +#define EGL_AUTO_STEREO_NV 0x3136 +#endif /* EGL_NV_3dvision_surface */ + +#ifndef EGL_NV_coverage_sample +#define EGL_NV_coverage_sample 1 +#define EGL_COVERAGE_BUFFERS_NV 0x30E0 +#define EGL_COVERAGE_SAMPLES_NV 0x30E1 +#endif /* EGL_NV_coverage_sample */ + +#ifndef EGL_NV_coverage_sample_resolve +#define EGL_NV_coverage_sample_resolve 1 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 +#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 +#endif /* EGL_NV_coverage_sample_resolve */ + +#ifndef EGL_NV_cuda_event +#define EGL_NV_cuda_event 1 +#define EGL_CUDA_EVENT_HANDLE_NV 0x323B +#define EGL_SYNC_CUDA_EVENT_NV 0x323C +#define EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D +#endif /* EGL_NV_cuda_event */ + +#ifndef EGL_NV_depth_nonlinear +#define EGL_NV_depth_nonlinear 1 +#define EGL_DEPTH_ENCODING_NV 0x30E2 +#define EGL_DEPTH_ENCODING_NONE_NV 0 +#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 +#endif /* EGL_NV_depth_nonlinear */ + +#ifndef EGL_NV_device_cuda +#define EGL_NV_device_cuda 1 +#define EGL_CUDA_DEVICE_NV 0x323A +#endif /* EGL_NV_device_cuda */ + +#ifndef EGL_NV_native_query +#define EGL_NV_native_query 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#endif +#endif /* EGL_NV_native_query */ + +#ifndef EGL_NV_post_convert_rounding +#define EGL_NV_post_convert_rounding 1 +#endif /* EGL_NV_post_convert_rounding */ + +#ifndef EGL_NV_post_sub_buffer +#define EGL_NV_post_sub_buffer 1 +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif +#endif /* EGL_NV_post_sub_buffer */ + +#ifndef EGL_NV_stream_sync +#define EGL_NV_stream_sync 1 +#define EGL_SYNC_NEW_FRAME_NV 0x321F +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); +#endif +#endif /* EGL_NV_stream_sync */ + +#ifndef EGL_NV_sync +#define EGL_NV_sync 1 +typedef void *EGLSyncNV; +typedef khronos_utime_nanoseconds_t EGLTimeNV; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 +#define EGL_SYNC_STATUS_NV 0x30E7 +#define EGL_SIGNALED_NV 0x30E8 +#define EGL_UNSIGNALED_NV 0x30E9 +#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 +#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull +#define EGL_ALREADY_SIGNALED_NV 0x30EA +#define EGL_TIMEOUT_EXPIRED_NV 0x30EB +#define EGL_CONDITION_SATISFIED_NV 0x30EC +#define EGL_SYNC_TYPE_NV 0x30ED +#define EGL_SYNC_CONDITION_NV 0x30EE +#define EGL_SYNC_FENCE_NV 0x30EF +#define EGL_NO_SYNC_NV ((EGLSyncNV)0) +typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); +EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_NV_sync */ + +#ifndef EGL_NV_system_time +#define EGL_NV_system_time 1 +typedef khronos_utime_nanoseconds_t EGLuint64NV; +#ifdef KHRONOS_SUPPORT_INT64 +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void); +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_NV_system_time */ + +#ifndef EGL_TIZEN_image_native_buffer +#define EGL_TIZEN_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_TIZEN 0x32A0 +#endif /* EGL_TIZEN_image_native_buffer */ + +#ifndef EGL_TIZEN_image_native_surface +#define EGL_TIZEN_image_native_surface 1 +#define EGL_NATIVE_SURFACE_TIZEN 0x32A1 +#endif /* EGL_TIZEN_image_native_surface */ + +#ifdef __cplusplus +} +#endif + +#endif /* __eglext_h_ */ + + +#endif /* _MSC_VER */ diff --git a/#ThirdParty/libSDL/include/SDL_endian.h b/#ThirdParty/libSDL/include/SDL_endian.h new file mode 100644 index 0000000..9100b10 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_endian.h @@ -0,0 +1,239 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_endian.h + * + * Functions for reading and writing endian-specific values + */ + +#ifndef _SDL_endian_h +#define _SDL_endian_h + +#include "SDL_stdinc.h" + +/** + * \name The two types of endianness + */ +/* @{ */ +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 +/* @} */ + +#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ +#ifdef __linux__ +#include +#define SDL_BYTEORDER __BYTE_ORDER +#else /* __linux__ */ +#if defined(__hppa__) || \ + defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ + (defined(__MIPS__) && defined(__MISPEB__)) || \ + defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ + defined(__sparc__) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#endif +#endif /* __linux__ */ +#endif /* !SDL_BYTEORDER */ + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_endian.h + */ +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + int result; + + __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); + return (Uint16)result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#else +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("bswap %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("bswapl %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + Uint32 result; + + __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); + __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); + __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); + return result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#else +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | + ((x >> 8) & 0x0000FF00) | (x >> 24))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + union + { + struct + { + Uint32 a, b; + } s; + Uint64 u; + } v; + v.u = x; + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), + "1"(v.s. + b)); + return v.u; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + __asm__("bswapq %0": "=r"(x):"0"(x)); + return x; +} +#else +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + Uint32 hi, lo; + + /* Separate into high and low 32-bit values and swap them */ + lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x >>= 32; + hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x = SDL_Swap32(lo); + x <<= 32; + x |= SDL_Swap32(hi); + return (x); +} +#endif + + +SDL_FORCE_INLINE float +SDL_SwapFloat(float x) +{ + union + { + float f; + Uint32 ui32; + } swapper; + swapper.f = x; + swapper.ui32 = SDL_Swap32(swapper.ui32); + return swapper.f; +} + + +/** + * \name Swap to native + * Byteswap item from the specified endianness to the native endianness. + */ +/* @{ */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) +#define SDL_SwapFloatLE(X) (X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) +#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) +#else +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) +#define SDL_SwapFloatBE(X) (X) +#endif +/* @} *//* Swap to native */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_endian_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_error.h b/#ThirdParty/libSDL/include/SDL_error.h new file mode 100644 index 0000000..2f3b4b5 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_error.h @@ -0,0 +1,76 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_error.h + * + * Simple error message routines for SDL. + */ + +#ifndef _SDL_error_h +#define _SDL_error_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Public functions */ +/* SDL_SetError() unconditionally returns -1. */ +extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); +extern DECLSPEC const char *SDLCALL SDL_GetError(void); +extern DECLSPEC void SDLCALL SDL_ClearError(void); + +/** + * \name Internal error functions + * + * \internal + * Private error reporting function - used internally. + */ +/* @{ */ +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) +#define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) +typedef enum +{ + SDL_ENOMEM, + SDL_EFREAD, + SDL_EFWRITE, + SDL_EFSEEK, + SDL_UNSUPPORTED, + SDL_LASTERROR +} SDL_errorcode; +/* SDL_Error() unconditionally returns -1. */ +extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); +/* @} *//* Internal error functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_error_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_events.h b/#ThirdParty/libSDL/include/SDL_events.h new file mode 100644 index 0000000..1437f4c --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_events.h @@ -0,0 +1,750 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_events.h + * + * Include file for SDL event handling. + */ + +#ifndef _SDL_events_h +#define _SDL_events_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_keyboard.h" +#include "SDL_mouse.h" +#include "SDL_joystick.h" +#include "SDL_gamecontroller.h" +#include "SDL_quit.h" +#include "SDL_gesture.h" +#include "SDL_touch.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* General keyboard/mouse state definitions */ +#define SDL_RELEASED 0 +#define SDL_PRESSED 1 + +/** + * \brief The types of events that can be delivered. + */ +typedef enum +{ + SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */ + + /* Application events */ + SDL_QUIT = 0x100, /**< User-requested quit */ + + /* These application events have special meaning on iOS, see README-ios.md for details */ + SDL_APP_TERMINATING, /**< The application is being terminated by the OS + Called on iOS in applicationWillTerminate() + Called on Android in onDestroy() + */ + SDL_APP_LOWMEMORY, /**< The application is low on memory, free memory if possible. + Called on iOS in applicationDidReceiveMemoryWarning() + Called on Android in onLowMemory() + */ + SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background + Called on iOS in applicationWillResignActive() + Called on Android in onPause() + */ + SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time + Called on iOS in applicationDidEnterBackground() + Called on Android in onPause() + */ + SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground + Called on iOS in applicationWillEnterForeground() + Called on Android in onResume() + */ + SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive + Called on iOS in applicationDidBecomeActive() + Called on Android in onResume() + */ + + /* Window events */ + SDL_WINDOWEVENT = 0x200, /**< Window state change */ + SDL_SYSWMEVENT, /**< System specific event */ + + /* Keyboard events */ + SDL_KEYDOWN = 0x300, /**< Key pressed */ + SDL_KEYUP, /**< Key released */ + SDL_TEXTEDITING, /**< Keyboard text editing (composition) */ + SDL_TEXTINPUT, /**< Keyboard text input */ + SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an + input language or keyboard layout change. + */ + + /* Mouse events */ + SDL_MOUSEMOTION = 0x400, /**< Mouse moved */ + SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ + SDL_MOUSEBUTTONUP, /**< Mouse button released */ + SDL_MOUSEWHEEL, /**< Mouse wheel motion */ + + /* Joystick events */ + SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */ + SDL_JOYBALLMOTION, /**< Joystick trackball motion */ + SDL_JOYHATMOTION, /**< Joystick hat position change */ + SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ + SDL_JOYBUTTONUP, /**< Joystick button released */ + SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */ + SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */ + + /* Game controller events */ + SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */ + SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */ + SDL_CONTROLLERBUTTONUP, /**< Game controller button released */ + SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */ + SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */ + SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */ + + /* Touch events */ + SDL_FINGERDOWN = 0x700, + SDL_FINGERUP, + SDL_FINGERMOTION, + + /* Gesture events */ + SDL_DOLLARGESTURE = 0x800, + SDL_DOLLARRECORD, + SDL_MULTIGESTURE, + + /* Clipboard events */ + SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */ + + /* Drag and drop events */ + SDL_DROPFILE = 0x1000, /**< The system requests a file open */ + + /* Audio hotplug events */ + SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */ + SDL_AUDIODEVICEREMOVED, /**< An audio device has been removed. */ + + /* Render events */ + SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */ + SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */ + + /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, + * and should be allocated with SDL_RegisterEvents() + */ + SDL_USEREVENT = 0x8000, + + /** + * This last event is only for bounding internal arrays + */ + SDL_LASTEVENT = 0xFFFF +} SDL_EventType; + +/** + * \brief Fields shared by every event + */ +typedef struct SDL_CommonEvent +{ + Uint32 type; + Uint32 timestamp; +} SDL_CommonEvent; + +/** + * \brief Window state change event data (event.window.*) + */ +typedef struct SDL_WindowEvent +{ + Uint32 type; /**< ::SDL_WINDOWEVENT */ + Uint32 timestamp; + Uint32 windowID; /**< The associated window */ + Uint8 event; /**< ::SDL_WindowEventID */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint32 data1; /**< event dependent data */ + Sint32 data2; /**< event dependent data */ +} SDL_WindowEvent; + +/** + * \brief Keyboard button event structure (event.key.*) + */ +typedef struct SDL_KeyboardEvent +{ + Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ + Uint32 timestamp; + Uint32 windowID; /**< The window with keyboard focus, if any */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 repeat; /**< Non-zero if this is a key repeat */ + Uint8 padding2; + Uint8 padding3; + SDL_Keysym keysym; /**< The key that was pressed or released */ +} SDL_KeyboardEvent; + +#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32) +/** + * \brief Keyboard text editing event structure (event.edit.*) + */ +typedef struct SDL_TextEditingEvent +{ + Uint32 type; /**< ::SDL_TEXTEDITING */ + Uint32 timestamp; + Uint32 windowID; /**< The window with keyboard focus, if any */ + char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ + Sint32 start; /**< The start cursor of selected editing text */ + Sint32 length; /**< The length of selected editing text */ +} SDL_TextEditingEvent; + + +#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32) +/** + * \brief Keyboard text input event structure (event.text.*) + */ +typedef struct SDL_TextInputEvent +{ + Uint32 type; /**< ::SDL_TEXTINPUT */ + Uint32 timestamp; + Uint32 windowID; /**< The window with keyboard focus, if any */ + char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ +} SDL_TextInputEvent; + +/** + * \brief Mouse motion event structure (event.motion.*) + */ +typedef struct SDL_MouseMotionEvent +{ + Uint32 type; /**< ::SDL_MOUSEMOTION */ + Uint32 timestamp; + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Uint32 state; /**< The current button state */ + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ + Sint32 xrel; /**< The relative motion in the X direction */ + Sint32 yrel; /**< The relative motion in the Y direction */ +} SDL_MouseMotionEvent; + +/** + * \brief Mouse button event structure (event.button.*) + */ +typedef struct SDL_MouseButtonEvent +{ + Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ + Uint32 timestamp; + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Uint8 button; /**< The mouse button index */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */ + Uint8 padding1; + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ +} SDL_MouseButtonEvent; + +/** + * \brief Mouse wheel event structure (event.wheel.*) + */ +typedef struct SDL_MouseWheelEvent +{ + Uint32 type; /**< ::SDL_MOUSEWHEEL */ + Uint32 timestamp; + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */ + Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */ + Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */ +} SDL_MouseWheelEvent; + +/** + * \brief Joystick axis motion event structure (event.jaxis.*) + */ +typedef struct SDL_JoyAxisEvent +{ + Uint32 type; /**< ::SDL_JOYAXISMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 axis; /**< The joystick axis index */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 value; /**< The axis value (range: -32768 to 32767) */ + Uint16 padding4; +} SDL_JoyAxisEvent; + +/** + * \brief Joystick trackball motion event structure (event.jball.*) + */ +typedef struct SDL_JoyBallEvent +{ + Uint32 type; /**< ::SDL_JOYBALLMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 ball; /**< The joystick trackball index */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 xrel; /**< The relative motion in the X direction */ + Sint16 yrel; /**< The relative motion in the Y direction */ +} SDL_JoyBallEvent; + +/** + * \brief Joystick hat position change event structure (event.jhat.*) + */ +typedef struct SDL_JoyHatEvent +{ + Uint32 type; /**< ::SDL_JOYHATMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 hat; /**< The joystick hat index */ + Uint8 value; /**< The hat position value. + * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP + * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT + * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN + * + * Note that zero means the POV is centered. + */ + Uint8 padding1; + Uint8 padding2; +} SDL_JoyHatEvent; + +/** + * \brief Joystick button event structure (event.jbutton.*) + */ +typedef struct SDL_JoyButtonEvent +{ + Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 button; /**< The joystick button index */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 padding1; + Uint8 padding2; +} SDL_JoyButtonEvent; + +/** + * \brief Joystick device event structure (event.jdevice.*) + */ +typedef struct SDL_JoyDeviceEvent +{ + Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */ + Uint32 timestamp; + Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */ +} SDL_JoyDeviceEvent; + + +/** + * \brief Game controller axis motion event structure (event.caxis.*) + */ +typedef struct SDL_ControllerAxisEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 value; /**< The axis value (range: -32768 to 32767) */ + Uint16 padding4; +} SDL_ControllerAxisEvent; + + +/** + * \brief Game controller button event structure (event.cbutton.*) + */ +typedef struct SDL_ControllerButtonEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 button; /**< The controller button (SDL_GameControllerButton) */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 padding1; + Uint8 padding2; +} SDL_ControllerButtonEvent; + + +/** + * \brief Controller device event structure (event.cdevice.*) + */ +typedef struct SDL_ControllerDeviceEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */ + Uint32 timestamp; + Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */ +} SDL_ControllerDeviceEvent; + +/** + * \brief Audio device event structure (event.adevice.*) + */ +typedef struct SDL_AudioDeviceEvent +{ + Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */ + Uint32 timestamp; + Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */ + Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; +} SDL_AudioDeviceEvent; + + +/** + * \brief Touch finger event structure (event.tfinger.*) + */ +typedef struct SDL_TouchFingerEvent +{ + Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */ + Uint32 timestamp; + SDL_TouchID touchId; /**< The touch device id */ + SDL_FingerID fingerId; + float x; /**< Normalized in the range 0...1 */ + float y; /**< Normalized in the range 0...1 */ + float dx; /**< Normalized in the range -1...1 */ + float dy; /**< Normalized in the range -1...1 */ + float pressure; /**< Normalized in the range 0...1 */ +} SDL_TouchFingerEvent; + + +/** + * \brief Multiple Finger Gesture Event (event.mgesture.*) + */ +typedef struct SDL_MultiGestureEvent +{ + Uint32 type; /**< ::SDL_MULTIGESTURE */ + Uint32 timestamp; + SDL_TouchID touchId; /**< The touch device index */ + float dTheta; + float dDist; + float x; + float y; + Uint16 numFingers; + Uint16 padding; +} SDL_MultiGestureEvent; + + +/** + * \brief Dollar Gesture Event (event.dgesture.*) + */ +typedef struct SDL_DollarGestureEvent +{ + Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */ + Uint32 timestamp; + SDL_TouchID touchId; /**< The touch device id */ + SDL_GestureID gestureId; + Uint32 numFingers; + float error; + float x; /**< Normalized center of gesture */ + float y; /**< Normalized center of gesture */ +} SDL_DollarGestureEvent; + + +/** + * \brief An event used to request a file open by the system (event.drop.*) + * This event is enabled by default, you can disable it with SDL_EventState(). + * \note If this event is enabled, you must free the filename in the event. + */ +typedef struct SDL_DropEvent +{ + Uint32 type; /**< ::SDL_DROPFILE */ + Uint32 timestamp; + char *file; /**< The file name, which should be freed with SDL_free() */ +} SDL_DropEvent; + + +/** + * \brief The "quit requested" event + */ +typedef struct SDL_QuitEvent +{ + Uint32 type; /**< ::SDL_QUIT */ + Uint32 timestamp; +} SDL_QuitEvent; + +/** + * \brief OS Specific event + */ +typedef struct SDL_OSEvent +{ + Uint32 type; /**< ::SDL_QUIT */ + Uint32 timestamp; +} SDL_OSEvent; + +/** + * \brief A user-defined event type (event.user.*) + */ +typedef struct SDL_UserEvent +{ + Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */ + Uint32 timestamp; + Uint32 windowID; /**< The associated window if any */ + Sint32 code; /**< User defined event code */ + void *data1; /**< User defined data pointer */ + void *data2; /**< User defined data pointer */ +} SDL_UserEvent; + + +struct SDL_SysWMmsg; +typedef struct SDL_SysWMmsg SDL_SysWMmsg; + +/** + * \brief A video driver dependent system event (event.syswm.*) + * This event is disabled by default, you can enable it with SDL_EventState() + * + * \note If you want to use this event, you should include SDL_syswm.h. + */ +typedef struct SDL_SysWMEvent +{ + Uint32 type; /**< ::SDL_SYSWMEVENT */ + Uint32 timestamp; + SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */ +} SDL_SysWMEvent; + +/** + * \brief General event structure + */ +typedef union SDL_Event +{ + Uint32 type; /**< Event type, shared with all events */ + SDL_CommonEvent common; /**< Common event data */ + SDL_WindowEvent window; /**< Window event data */ + SDL_KeyboardEvent key; /**< Keyboard event data */ + SDL_TextEditingEvent edit; /**< Text editing event data */ + SDL_TextInputEvent text; /**< Text input event data */ + SDL_MouseMotionEvent motion; /**< Mouse motion event data */ + SDL_MouseButtonEvent button; /**< Mouse button event data */ + SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */ + SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */ + SDL_JoyBallEvent jball; /**< Joystick ball event data */ + SDL_JoyHatEvent jhat; /**< Joystick hat event data */ + SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ + SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ + SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */ + SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */ + SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */ + SDL_AudioDeviceEvent adevice; /**< Audio device event data */ + SDL_QuitEvent quit; /**< Quit request event data */ + SDL_UserEvent user; /**< Custom event data */ + SDL_SysWMEvent syswm; /**< System dependent window event data */ + SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ + SDL_MultiGestureEvent mgesture; /**< Gesture event data */ + SDL_DollarGestureEvent dgesture; /**< Gesture event data */ + SDL_DropEvent drop; /**< Drag and drop event data */ + + /* This is necessary for ABI compatibility between Visual C++ and GCC + Visual C++ will respect the push pack pragma and use 52 bytes for + this structure, and GCC will use the alignment of the largest datatype + within the union, which is 8 bytes. + + So... we'll add padding to force the size to be 56 bytes for both. + */ + Uint8 padding[56]; +} SDL_Event; + + +/* Function prototypes */ + +/** + * Pumps the event loop, gathering events from the input devices. + * + * This function updates the event queue and internal input device state. + * + * This should only be run in the thread that sets the video mode. + */ +extern DECLSPEC void SDLCALL SDL_PumpEvents(void); + +/* @{ */ +typedef enum +{ + SDL_ADDEVENT, + SDL_PEEKEVENT, + SDL_GETEVENT +} SDL_eventaction; + +/** + * Checks the event queue for messages and optionally returns them. + * + * If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to + * the back of the event queue. + * + * If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front + * of the event queue, within the specified minimum and maximum type, + * will be returned and will not be removed from the queue. + * + * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front + * of the event queue, within the specified minimum and maximum type, + * will be returned and will be removed from the queue. + * + * \return The number of events actually stored, or -1 if there was an error. + * + * This function is thread-safe. + */ +extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, + SDL_eventaction action, + Uint32 minType, Uint32 maxType); +/* @} */ + +/** + * Checks to see if certain event types are in the event queue. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type); +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType); + +/** + * This function clears events from the event queue + * This function only affects currently queued events. If you want to make + * sure that all pending OS events are flushed, you can call SDL_PumpEvents() + * on the main thread immediately before the flush call. + */ +extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type); +extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); + +/** + * \brief Polls for currently pending events. + * + * \return 1 if there are any pending events, or 0 if there are none available. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event); + +/** + * \brief Waits indefinitely for the next available event. + * + * \return 1, or 0 if there was an error while waiting for events. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event); + +/** + * \brief Waits until the specified timeout (in milliseconds) for the next + * available event. + * + * \return 1, or 0 if there was an error while waiting for events. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + * \param timeout The timeout (in milliseconds) to wait for next event. + */ +extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event, + int timeout); + +/** + * \brief Add an event to the event queue. + * + * \return 1 on success, 0 if the event was filtered, or -1 if the event queue + * was full or there was some other error. + */ +extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event); + +typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event); + +/** + * Sets up a filter to process all events before they change internal state and + * are posted to the internal event queue. + * + * The filter is prototyped as: + * \code + * int SDL_EventFilter(void *userdata, SDL_Event * event); + * \endcode + * + * If the filter returns 1, then the event will be added to the internal queue. + * If it returns 0, then the event will be dropped from the queue, but the + * internal state will still be updated. This allows selective filtering of + * dynamically arriving events. + * + * \warning Be very careful of what you do in the event filter function, as + * it may run in a different thread! + * + * There is one caveat when dealing with the ::SDL_QuitEvent event type. The + * event filter is only called when the window manager desires to close the + * application window. If the event filter returns 1, then the window will + * be closed, otherwise the window will remain open if possible. + * + * If the quit event is generated by an interrupt signal, it will bypass the + * internal queue and be delivered to the application at the next event poll. + */ +extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, + void *userdata); + +/** + * Return the current event filter - can be used to "chain" filters. + * If there is no event filter set, this function returns SDL_FALSE. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter, + void **userdata); + +/** + * Add a function which is called when an event is added to the queue. + */ +extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, + void *userdata); + +/** + * Remove an event watch function added with SDL_AddEventWatch() + */ +extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, + void *userdata); + +/** + * Run the filter function on the current event queue, removing any + * events for which the filter returns 0. + */ +extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, + void *userdata); + +/* @{ */ +#define SDL_QUERY -1 +#define SDL_IGNORE 0 +#define SDL_DISABLE 0 +#define SDL_ENABLE 1 + +/** + * This function allows you to set the state of processing certain events. + * - If \c state is set to ::SDL_IGNORE, that event will be automatically + * dropped from the event queue and will not event be filtered. + * - If \c state is set to ::SDL_ENABLE, that event will be processed + * normally. + * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the + * current processing state of the specified event. + */ +extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); +/* @} */ +#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY) + +/** + * This function allocates a set of user-defined events, and returns + * the beginning event number for that set of events. + * + * If there aren't enough user-defined events left, this function + * returns (Uint32)-1 + */ +extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_events_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_filesystem.h b/#ThirdParty/libSDL/include/SDL_filesystem.h new file mode 100644 index 0000000..02999ed --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_filesystem.h @@ -0,0 +1,136 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_filesystem.h + * + * \brief Include file for filesystem SDL API functions + */ + +#ifndef _SDL_filesystem_h +#define _SDL_filesystem_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Get the path where the application resides. + * + * Get the "base path". This is the directory where the application was run + * from, which is probably the installation directory, and may or may not + * be the process's current working directory. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * Some platforms can't determine the application's path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \return String of base dir in UTF-8 encoding, or NULL on error. + * + * \sa SDL_GetPrefPath + */ +extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); + +/** + * \brief Get the user-and-app-specific path where files can be written. + * + * Get the "pref dir". This is meant to be where users can write personal + * files (preferences and save games, etc) that are specific to your + * application. This directory is unique per user, per application. + * + * This function will decide the appropriate location in the native filesystem, + * create the directory if necessary, and return a string of the absolute + * path to the directory in UTF-8 encoding. + * + * On Windows, the string might look like: + * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" + * + * On Linux, the string might look like: + * "/home/bob/.local/share/My Program Name/" + * + * On Mac OS X, the string might look like: + * "/Users/bob/Library/Application Support/My Program Name/" + * + * (etc.) + * + * You specify the name of your organization (if it's not a real organization, + * your name or an Internet domain you own might do) and the name of your + * application. These should be untranslated proper names. + * + * Both the org and app strings may become part of a directory name, so + * please follow these rules: + * + * - Try to use the same org string (including case-sensitivity) for + * all your applications that use this function. + * - Always use a unique app string for each one, and make sure it never + * changes for an app once you've decided on it. + * - Unicode characters are legal, as long as it's UTF-8 encoded, but... + * - ...only use letters, numbers, and spaces. Avoid punctuation like + * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * You should assume the path returned by this function is the only safe + * place to write files (and that SDL_GetBasePath(), while it might be + * writable, or even the parent of the returned path, aren't where you + * should be writing things). + * + * Some platforms can't determine the pref path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \param org The name of your organization. + * \param app The name of your application. + * \return UTF-8 string of user dir in platform-dependent notation. NULL + * if there's a problem (creating directory failed, etc). + * + * \sa SDL_GetBasePath + */ +extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_filesystem_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_gamecontroller.h b/#ThirdParty/libSDL/include/SDL_gamecontroller.h new file mode 100644 index 0000000..42087ee --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_gamecontroller.h @@ -0,0 +1,323 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_gamecontroller.h + * + * Include file for SDL game controller event handling + */ + +#ifndef _SDL_gamecontroller_h +#define _SDL_gamecontroller_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_rwops.h" +#include "SDL_joystick.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_gamecontroller.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system + * for game controllers, and load appropriate drivers. + * + * If you would like to receive controller updates while the application + * is in the background, you should set the following hint before calling + * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + */ + +/* The gamecontroller structure used to identify an SDL game controller */ +struct _SDL_GameController; +typedef struct _SDL_GameController SDL_GameController; + + +typedef enum +{ + SDL_CONTROLLER_BINDTYPE_NONE = 0, + SDL_CONTROLLER_BINDTYPE_BUTTON, + SDL_CONTROLLER_BINDTYPE_AXIS, + SDL_CONTROLLER_BINDTYPE_HAT +} SDL_GameControllerBindType; + +/** + * Get the SDL joystick layer binding for this controller button/axis mapping + */ +typedef struct SDL_GameControllerButtonBind +{ + SDL_GameControllerBindType bindType; + union + { + int button; + int axis; + struct { + int hat; + int hat_mask; + } hat; + } value; + +} SDL_GameControllerButtonBind; + + +/** + * To count the number of game controllers in the system for the following: + * int nJoysticks = SDL_NumJoysticks(); + * int nGameControllers = 0; + * for ( int i = 0; i < nJoysticks; i++ ) { + * if ( SDL_IsGameController(i) ) { + * nGameControllers++; + * } + * } + * + * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is: + * guid,name,mappings + * + * Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones. + * Under Windows there is a reserved GUID of "xinput" that covers any XInput devices. + * The mapping format for joystick is: + * bX - a joystick button, index X + * hX.Y - hat X with value Y + * aX - axis X of the joystick + * Buttons can be used as a controller axis and vice versa. + * + * This string shows an example of a valid mapping for a controller + * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", + * + */ + +/** + * Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform() + * A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt + * + * If \c freerw is non-zero, the stream will be closed after being read. + * + * \return number of mappings added, -1 on error + */ +extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW( SDL_RWops * rw, int freerw ); + +/** + * Load a set of mappings from a file, filtered by the current SDL_GetPlatform() + * + * Convenience macro. + */ +#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1) + +/** + * Add or update an existing mapping configuration + * + * \return 1 if mapping is added, 0 if updated, -1 on error + */ +extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping( const char* mappingString ); + +/** + * Get a mapping string for a GUID + * + * \return the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available + */ +extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid ); + +/** + * Get a mapping string for an open GameController + * + * \return the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available + */ +extern DECLSPEC char * SDLCALL SDL_GameControllerMapping( SDL_GameController * gamecontroller ); + +/** + * Is the joystick on this index supported by the game controller interface? + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index); + + +/** + * Get the implementation dependent name of a game controller. + * This can be called before any controllers are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); + +/** + * Open a game controller for use. + * The index passed as an argument refers to the N'th game controller on the system. + * This index is not the value which will identify this controller in future + * controller events. The joystick's instance id (::SDL_JoystickID) will be + * used there instead. + * + * \return A controller identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index); + +/** + * Return the SDL_GameController associated with an instance id. + */ +extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid); + +/** + * Return the name for this currently opened controller + */ +extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); + +/** + * Returns SDL_TRUE if the controller has been opened and currently connected, + * or SDL_FALSE if it has not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller); + +/** + * Get the underlying joystick object used by a controller + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); + +/** + * Enable/disable controller event polling. + * + * If controller events are disabled, you must call SDL_GameControllerUpdate() + * yourself and check the state of the controller when you want controller + * information. + * + * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); + +/** + * Update the current state of the open game controllers. + * + * This is called automatically by the event loop if any game controller + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); + + +/** + * The list of axes available from a controller + */ +typedef enum +{ + SDL_CONTROLLER_AXIS_INVALID = -1, + SDL_CONTROLLER_AXIS_LEFTX, + SDL_CONTROLLER_AXIS_LEFTY, + SDL_CONTROLLER_AXIS_RIGHTX, + SDL_CONTROLLER_AXIS_RIGHTY, + SDL_CONTROLLER_AXIS_TRIGGERLEFT, + SDL_CONTROLLER_AXIS_TRIGGERRIGHT, + SDL_CONTROLLER_AXIS_MAX +} SDL_GameControllerAxis; + +/** + * turn this string into a axis mapping + */ +extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString); + +/** + * turn this axis enum into a string mapping + */ +extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis); + +/** + * Get the SDL joystick layer binding for this controller button mapping + */ +extern DECLSPEC SDL_GameControllerButtonBind SDLCALL +SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller, + SDL_GameControllerAxis axis); + +/** + * Get the current state of an axis control on a game controller. + * + * The state is a value ranging from -32768 to 32767 (except for the triggers, + * which range from 0 to 32767). + * + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL +SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, + SDL_GameControllerAxis axis); + +/** + * The list of buttons available from a controller + */ +typedef enum +{ + SDL_CONTROLLER_BUTTON_INVALID = -1, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + SDL_CONTROLLER_BUTTON_MAX +} SDL_GameControllerButton; + +/** + * turn this string into a button mapping + */ +extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString); + +/** + * turn this button enum into a string mapping + */ +extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button); + +/** + * Get the SDL joystick layer binding for this controller button mapping + */ +extern DECLSPEC SDL_GameControllerButtonBind SDLCALL +SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller, + SDL_GameControllerButton button); + + +/** + * Get the current state of a button on a game controller. + * + * The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, + SDL_GameControllerButton button); + +/** + * Close a controller previously opened with SDL_GameControllerOpen(). + */ +extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_gamecontroller_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_gesture.h b/#ThirdParty/libSDL/include/SDL_gesture.h new file mode 100644 index 0000000..3c29ca7 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_gesture.h @@ -0,0 +1,87 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_gesture.h + * + * Include file for SDL gesture event handling. + */ + +#ifndef _SDL_gesture_h +#define _SDL_gesture_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "SDL_touch.h" + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef Sint64 SDL_GestureID; + +/* Function prototypes */ + +/** + * \brief Begin Recording a gesture on the specified touch, or all touches (-1) + * + * + */ +extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); + + +/** + * \brief Save all currently loaded Dollar Gesture templates + * + * + */ +extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); + +/** + * \brief Save a currently loaded Dollar Gesture template + * + * + */ +extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); + + +/** + * \brief Load Dollar Gesture templates from a file + * + * + */ +extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_gesture_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_haptic.h b/#ThirdParty/libSDL/include/SDL_haptic.h new file mode 100644 index 0000000..b36d78b --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_haptic.h @@ -0,0 +1,1223 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_haptic.h + * + * \brief The SDL Haptic subsystem allows you to control haptic (force feedback) + * devices. + * + * The basic usage is as follows: + * - Initialize the Subsystem (::SDL_INIT_HAPTIC). + * - Open a Haptic Device. + * - SDL_HapticOpen() to open from index. + * - SDL_HapticOpenFromJoystick() to open from an existing joystick. + * - Create an effect (::SDL_HapticEffect). + * - Upload the effect with SDL_HapticNewEffect(). + * - Run the effect with SDL_HapticRunEffect(). + * - (optional) Free the effect with SDL_HapticDestroyEffect(). + * - Close the haptic device with SDL_HapticClose(). + * + * \par Simple rumble example: + * \code + * SDL_Haptic *haptic; + * + * // Open the device + * haptic = SDL_HapticOpen( 0 ); + * if (haptic == NULL) + * return -1; + * + * // Initialize simple rumble + * if (SDL_HapticRumbleInit( haptic ) != 0) + * return -1; + * + * // Play effect at 50% strength for 2 seconds + * if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0) + * return -1; + * SDL_Delay( 2000 ); + * + * // Clean up + * SDL_HapticClose( haptic ); + * \endcode + * + * \par Complete example: + * \code + * int test_haptic( SDL_Joystick * joystick ) { + * SDL_Haptic *haptic; + * SDL_HapticEffect effect; + * int effect_id; + * + * // Open the device + * haptic = SDL_HapticOpenFromJoystick( joystick ); + * if (haptic == NULL) return -1; // Most likely joystick isn't haptic + * + * // See if it can do sine waves + * if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0) { + * SDL_HapticClose(haptic); // No sine effect + * return -1; + * } + * + * // Create the effect + * memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default + * effect.type = SDL_HAPTIC_SINE; + * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates + * effect.periodic.direction.dir[0] = 18000; // Force comes from south + * effect.periodic.period = 1000; // 1000 ms + * effect.periodic.magnitude = 20000; // 20000/32767 strength + * effect.periodic.length = 5000; // 5 seconds long + * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength + * effect.periodic.fade_length = 1000; // Takes 1 second to fade away + * + * // Upload the effect + * effect_id = SDL_HapticNewEffect( haptic, &effect ); + * + * // Test the effect + * SDL_HapticRunEffect( haptic, effect_id, 1 ); + * SDL_Delay( 5000); // Wait for the effect to finish + * + * // We destroy the effect, although closing the device also does this + * SDL_HapticDestroyEffect( haptic, effect_id ); + * + * // Close the device + * SDL_HapticClose(haptic); + * + * return 0; // Success + * } + * \endcode + */ + +#ifndef _SDL_haptic_h +#define _SDL_haptic_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_joystick.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * \typedef SDL_Haptic + * + * \brief The haptic structure used to identify an SDL haptic. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticOpenFromJoystick + * \sa SDL_HapticClose + */ +struct _SDL_Haptic; +typedef struct _SDL_Haptic SDL_Haptic; + + +/** + * \name Haptic features + * + * Different haptic features a device can have. + */ +/* @{ */ + +/** + * \name Haptic effects + */ +/* @{ */ + +/** + * \brief Constant effect supported. + * + * Constant haptic effect. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_CONSTANT (1<<0) + +/** + * \brief Sine wave effect supported. + * + * Periodic haptic effect that simulates sine waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SINE (1<<1) + +/** + * \brief Left/Right effect supported. + * + * Haptic effect for direct control over high/low frequency motors. + * + * \sa SDL_HapticLeftRight + * \warning this value was SDL_HAPTIC_SQUARE right before 2.0.0 shipped. Sorry, + * we ran out of bits, and this is important for XInput devices. + */ +#define SDL_HAPTIC_LEFTRIGHT (1<<2) + +/* !!! FIXME: put this back when we have more bits in 2.1 */ +/* #define SDL_HAPTIC_SQUARE (1<<2) */ + +/** + * \brief Triangle wave effect supported. + * + * Periodic haptic effect that simulates triangular waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_TRIANGLE (1<<3) + +/** + * \brief Sawtoothup wave effect supported. + * + * Periodic haptic effect that simulates saw tooth up waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SAWTOOTHUP (1<<4) + +/** + * \brief Sawtoothdown wave effect supported. + * + * Periodic haptic effect that simulates saw tooth down waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SAWTOOTHDOWN (1<<5) + +/** + * \brief Ramp effect supported. + * + * Ramp haptic effect. + * + * \sa SDL_HapticRamp + */ +#define SDL_HAPTIC_RAMP (1<<6) + +/** + * \brief Spring effect supported - uses axes position. + * + * Condition haptic effect that simulates a spring. Effect is based on the + * axes position. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_SPRING (1<<7) + +/** + * \brief Damper effect supported - uses axes velocity. + * + * Condition haptic effect that simulates dampening. Effect is based on the + * axes velocity. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_DAMPER (1<<8) + +/** + * \brief Inertia effect supported - uses axes acceleration. + * + * Condition haptic effect that simulates inertia. Effect is based on the axes + * acceleration. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_INERTIA (1<<9) + +/** + * \brief Friction effect supported - uses axes movement. + * + * Condition haptic effect that simulates friction. Effect is based on the + * axes movement. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_FRICTION (1<<10) + +/** + * \brief Custom effect is supported. + * + * User defined custom haptic effect. + */ +#define SDL_HAPTIC_CUSTOM (1<<11) + +/* @} *//* Haptic effects */ + +/* These last few are features the device has, not effects */ + +/** + * \brief Device can set global gain. + * + * Device supports setting the global gain. + * + * \sa SDL_HapticSetGain + */ +#define SDL_HAPTIC_GAIN (1<<12) + +/** + * \brief Device can set autocenter. + * + * Device supports setting autocenter. + * + * \sa SDL_HapticSetAutocenter + */ +#define SDL_HAPTIC_AUTOCENTER (1<<13) + +/** + * \brief Device can be queried for effect status. + * + * Device can be queried for effect status. + * + * \sa SDL_HapticGetEffectStatus + */ +#define SDL_HAPTIC_STATUS (1<<14) + +/** + * \brief Device can be paused. + * + * \sa SDL_HapticPause + * \sa SDL_HapticUnpause + */ +#define SDL_HAPTIC_PAUSE (1<<15) + + +/** + * \name Direction encodings + */ +/* @{ */ + +/** + * \brief Uses polar coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_POLAR 0 + +/** + * \brief Uses cartesian coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_CARTESIAN 1 + +/** + * \brief Uses spherical coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_SPHERICAL 2 + +/* @} *//* Direction encodings */ + +/* @} *//* Haptic features */ + +/* + * Misc defines. + */ + +/** + * \brief Used to play a device an infinite number of times. + * + * \sa SDL_HapticRunEffect + */ +#define SDL_HAPTIC_INFINITY 4294967295U + + +/** + * \brief Structure that represents a haptic direction. + * + * This is the direction where the force comes from, + * instead of the direction in which the force is exerted. + * + * Directions can be specified by: + * - ::SDL_HAPTIC_POLAR : Specified by polar coordinates. + * - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. + * - ::SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates. + * + * Cardinal directions of the haptic device are relative to the positioning + * of the device. North is considered to be away from the user. + * + * The following diagram represents the cardinal directions: + * \verbatim + .--. + |__| .-------. + |=.| |.-----.| + |--| || || + | | |'-----'| + |__|~')_____(' + [ COMPUTER ] + + + North (0,-1) + ^ + | + | + (-1,0) West <----[ HAPTIC ]----> East (1,0) + | + | + v + South (0,1) + + + [ USER ] + \|||/ + (o o) + ---ooO-(_)-Ooo--- + \endverbatim + * + * If type is ::SDL_HAPTIC_POLAR, direction is encoded by hundredths of a + * degree starting north and turning clockwise. ::SDL_HAPTIC_POLAR only uses + * the first \c dir parameter. The cardinal directions would be: + * - North: 0 (0 degrees) + * - East: 9000 (90 degrees) + * - South: 18000 (180 degrees) + * - West: 27000 (270 degrees) + * + * If type is ::SDL_HAPTIC_CARTESIAN, direction is encoded by three positions + * (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses + * the first three \c dir parameters. The cardinal directions would be: + * - North: 0,-1, 0 + * - East: 1, 0, 0 + * - South: 0, 1, 0 + * - West: -1, 0, 0 + * + * The Z axis represents the height of the effect if supported, otherwise + * it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you + * can use any multiple you want, only the direction matters. + * + * If type is ::SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. + * The first two \c dir parameters are used. The \c dir parameters are as + * follows (all values are in hundredths of degrees): + * - Degrees from (1, 0) rotated towards (0, 1). + * - Degrees towards (0, 0, 1) (device needs at least 3 axes). + * + * + * Example of force coming from the south with all encodings (force coming + * from the south means the user will have to pull the stick to counteract): + * \code + * SDL_HapticDirection direction; + * + * // Cartesian directions + * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding. + * direction.dir[0] = 0; // X position + * direction.dir[1] = 1; // Y position + * // Assuming the device has 2 axes, we don't need to specify third parameter. + * + * // Polar directions + * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding. + * direction.dir[0] = 18000; // Polar only uses first parameter + * + * // Spherical coordinates + * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding + * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters. + * \endcode + * + * \sa SDL_HAPTIC_POLAR + * \sa SDL_HAPTIC_CARTESIAN + * \sa SDL_HAPTIC_SPHERICAL + * \sa SDL_HapticEffect + * \sa SDL_HapticNumAxes + */ +typedef struct SDL_HapticDirection +{ + Uint8 type; /**< The type of encoding. */ + Sint32 dir[3]; /**< The encoded direction. */ +} SDL_HapticDirection; + + +/** + * \brief A structure containing a template for a Constant effect. + * + * The struct is exclusive to the ::SDL_HAPTIC_CONSTANT effect. + * + * A constant effect applies a constant force in the specified direction + * to the joystick. + * + * \sa SDL_HAPTIC_CONSTANT + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticConstant +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_CONSTANT */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Constant */ + Sint16 level; /**< Strength of the constant effect. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticConstant; + +/** + * \brief A structure containing a template for a Periodic effect. + * + * The struct handles the following effects: + * - ::SDL_HAPTIC_SINE + * - ::SDL_HAPTIC_LEFTRIGHT + * - ::SDL_HAPTIC_TRIANGLE + * - ::SDL_HAPTIC_SAWTOOTHUP + * - ::SDL_HAPTIC_SAWTOOTHDOWN + * + * A periodic effect consists in a wave-shaped effect that repeats itself + * over time. The type determines the shape of the wave and the parameters + * determine the dimensions of the wave. + * + * Phase is given by hundredth of a degree meaning that giving the phase a value + * of 9000 will displace it 25% of its period. Here are sample values: + * - 0: No phase displacement. + * - 9000: Displaced 25% of its period. + * - 18000: Displaced 50% of its period. + * - 27000: Displaced 75% of its period. + * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred. + * + * Examples: + * \verbatim + SDL_HAPTIC_SINE + __ __ __ __ + / \ / \ / \ / + / \__/ \__/ \__/ + + SDL_HAPTIC_SQUARE + __ __ __ __ __ + | | | | | | | | | | + | |__| |__| |__| |__| | + + SDL_HAPTIC_TRIANGLE + /\ /\ /\ /\ /\ + / \ / \ / \ / \ / + / \/ \/ \/ \/ + + SDL_HAPTIC_SAWTOOTHUP + /| /| /| /| /| /| /| + / | / | / | / | / | / | / | + / |/ |/ |/ |/ |/ |/ | + + SDL_HAPTIC_SAWTOOTHDOWN + \ |\ |\ |\ |\ |\ |\ | + \ | \ | \ | \ | \ | \ | \ | + \| \| \| \| \| \| \| + \endverbatim + * + * \sa SDL_HAPTIC_SINE + * \sa SDL_HAPTIC_LEFTRIGHT + * \sa SDL_HAPTIC_TRIANGLE + * \sa SDL_HAPTIC_SAWTOOTHUP + * \sa SDL_HAPTIC_SAWTOOTHDOWN + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticPeriodic +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_SINE, ::SDL_HAPTIC_LEFTRIGHT, + ::SDL_HAPTIC_TRIANGLE, ::SDL_HAPTIC_SAWTOOTHUP or + ::SDL_HAPTIC_SAWTOOTHDOWN */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Periodic */ + Uint16 period; /**< Period of the wave. */ + Sint16 magnitude; /**< Peak value; if negative, equivalent to 180 degrees extra phase shift. */ + Sint16 offset; /**< Mean value of the wave. */ + Uint16 phase; /**< Positive phase shift given by hundredth of a degree. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticPeriodic; + +/** + * \brief A structure containing a template for a Condition effect. + * + * The struct handles the following effects: + * - ::SDL_HAPTIC_SPRING: Effect based on axes position. + * - ::SDL_HAPTIC_DAMPER: Effect based on axes velocity. + * - ::SDL_HAPTIC_INERTIA: Effect based on axes acceleration. + * - ::SDL_HAPTIC_FRICTION: Effect based on axes movement. + * + * Direction is handled by condition internals instead of a direction member. + * The condition effect specific members have three parameters. The first + * refers to the X axis, the second refers to the Y axis and the third + * refers to the Z axis. The right terms refer to the positive side of the + * axis and the left terms refer to the negative side of the axis. Please + * refer to the ::SDL_HapticDirection diagram for which side is positive and + * which is negative. + * + * \sa SDL_HapticDirection + * \sa SDL_HAPTIC_SPRING + * \sa SDL_HAPTIC_DAMPER + * \sa SDL_HAPTIC_INERTIA + * \sa SDL_HAPTIC_FRICTION + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticCondition +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_SPRING, ::SDL_HAPTIC_DAMPER, + ::SDL_HAPTIC_INERTIA or ::SDL_HAPTIC_FRICTION */ + SDL_HapticDirection direction; /**< Direction of the effect - Not used ATM. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Condition */ + Uint16 right_sat[3]; /**< Level when joystick is to the positive side; max 0xFFFF. */ + Uint16 left_sat[3]; /**< Level when joystick is to the negative side; max 0xFFFF. */ + Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */ + Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */ + Uint16 deadband[3]; /**< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. */ + Sint16 center[3]; /**< Position of the dead zone. */ +} SDL_HapticCondition; + +/** + * \brief A structure containing a template for a Ramp effect. + * + * This struct is exclusively for the ::SDL_HAPTIC_RAMP effect. + * + * The ramp effect starts at start strength and ends at end strength. + * It augments in linear fashion. If you use attack and fade with a ramp + * the effects get added to the ramp effect making the effect become + * quadratic instead of linear. + * + * \sa SDL_HAPTIC_RAMP + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticRamp +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_RAMP */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Ramp */ + Sint16 start; /**< Beginning strength level. */ + Sint16 end; /**< Ending strength level. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticRamp; + +/** + * \brief A structure containing a template for a Left/Right effect. + * + * This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect. + * + * The Left/Right effect is used to explicitly control the large and small + * motors, commonly found in modern game controllers. One motor is high + * frequency, the other is low frequency. + * + * \sa SDL_HAPTIC_LEFTRIGHT + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticLeftRight +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_LEFTRIGHT */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + + /* Rumble */ + Uint16 large_magnitude; /**< Control of the large controller motor. */ + Uint16 small_magnitude; /**< Control of the small controller motor. */ +} SDL_HapticLeftRight; + +/** + * \brief A structure containing a template for the ::SDL_HAPTIC_CUSTOM effect. + * + * A custom force feedback effect is much like a periodic effect, where the + * application can define its exact shape. You will have to allocate the + * data yourself. Data should consist of channels * samples Uint16 samples. + * + * If channels is one, the effect is rotated using the defined direction. + * Otherwise it uses the samples in data for the different axes. + * + * \sa SDL_HAPTIC_CUSTOM + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticCustom +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_CUSTOM */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Custom */ + Uint8 channels; /**< Axes to use, minimum of one. */ + Uint16 period; /**< Sample periods. */ + Uint16 samples; /**< Amount of samples. */ + Uint16 *data; /**< Should contain channels*samples items. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticCustom; + +/** + * \brief The generic template for any haptic effect. + * + * All values max at 32767 (0x7FFF). Signed values also can be negative. + * Time values unless specified otherwise are in milliseconds. + * + * You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767 + * value. Neither delay, interval, attack_length nor fade_length support + * ::SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends. + * + * Additionally, the ::SDL_HAPTIC_RAMP effect does not support a duration of + * ::SDL_HAPTIC_INFINITY. + * + * Button triggers may not be supported on all devices, it is advised to not + * use them if possible. Buttons start at index 1 instead of index 0 like + * the joystick. + * + * If both attack_length and fade_level are 0, the envelope is not used, + * otherwise both values are used. + * + * Common parts: + * \code + * // Replay - All effects have this + * Uint32 length; // Duration of effect (ms). + * Uint16 delay; // Delay before starting effect. + * + * // Trigger - All effects have this + * Uint16 button; // Button that triggers effect. + * Uint16 interval; // How soon before effect can be triggered again. + * + * // Envelope - All effects except condition effects have this + * Uint16 attack_length; // Duration of the attack (ms). + * Uint16 attack_level; // Level at the start of the attack. + * Uint16 fade_length; // Duration of the fade out (ms). + * Uint16 fade_level; // Level at the end of the fade. + * \endcode + * + * + * Here we have an example of a constant effect evolution in time: + * \verbatim + Strength + ^ + | + | effect level --> _________________ + | / \ + | / \ + | / \ + | / \ + | attack_level --> | \ + | | | <--- fade_level + | + +--------------------------------------------------> Time + [--] [---] + attack_length fade_length + + [------------------][-----------------------] + delay length + \endverbatim + * + * Note either the attack_level or the fade_level may be above the actual + * effect level. + * + * \sa SDL_HapticConstant + * \sa SDL_HapticPeriodic + * \sa SDL_HapticCondition + * \sa SDL_HapticRamp + * \sa SDL_HapticLeftRight + * \sa SDL_HapticCustom + */ +typedef union SDL_HapticEffect +{ + /* Common for all force feedback effects */ + Uint16 type; /**< Effect type. */ + SDL_HapticConstant constant; /**< Constant effect. */ + SDL_HapticPeriodic periodic; /**< Periodic effect. */ + SDL_HapticCondition condition; /**< Condition effect. */ + SDL_HapticRamp ramp; /**< Ramp effect. */ + SDL_HapticLeftRight leftright; /**< Left/Right effect. */ + SDL_HapticCustom custom; /**< Custom effect. */ +} SDL_HapticEffect; + + +/* Function prototypes */ +/** + * \brief Count the number of haptic devices attached to the system. + * + * \return Number of haptic devices detected on the system. + */ +extern DECLSPEC int SDLCALL SDL_NumHaptics(void); + +/** + * \brief Get the implementation dependent name of a Haptic device. + * + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + * + * \param device_index Index of the device to get its name. + * \return Name of the device or NULL on error. + * + * \sa SDL_NumHaptics + */ +extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index); + +/** + * \brief Opens a Haptic device for usage. + * + * The index passed as an argument refers to the N'th Haptic device on this + * system. + * + * When opening a haptic device, its gain will be set to maximum and + * autocenter will be disabled. To modify these values use + * SDL_HapticSetGain() and SDL_HapticSetAutocenter(). + * + * \param device_index Index of the device to open. + * \return Device identifier or NULL on error. + * + * \sa SDL_HapticIndex + * \sa SDL_HapticOpenFromMouse + * \sa SDL_HapticOpenFromJoystick + * \sa SDL_HapticClose + * \sa SDL_HapticSetGain + * \sa SDL_HapticSetAutocenter + * \sa SDL_HapticPause + * \sa SDL_HapticStopAll + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index); + +/** + * \brief Checks if the haptic device at index has been opened. + * + * \param device_index Index to check to see if it has been opened. + * \return 1 if it has been opened or 0 if it hasn't. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticIndex + */ +extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index); + +/** + * \brief Gets the index of a haptic device. + * + * \param haptic Haptic device to get the index of. + * \return The index of the haptic device or -1 on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticOpened + */ +extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic); + +/** + * \brief Gets whether or not the current mouse has haptic capabilities. + * + * \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't. + * + * \sa SDL_HapticOpenFromMouse + */ +extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void); + +/** + * \brief Tries to open a haptic device from the current mouse. + * + * \return The haptic device identifier or NULL on error. + * + * \sa SDL_MouseIsHaptic + * \sa SDL_HapticOpen + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void); + +/** + * \brief Checks to see if a joystick has haptic features. + * + * \param joystick Joystick to test for haptic capabilities. + * \return 1 if the joystick is haptic, 0 if it isn't + * or -1 if an error ocurred. + * + * \sa SDL_HapticOpenFromJoystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick); + +/** + * \brief Opens a Haptic device for usage from a Joystick device. + * + * You must still close the haptic device separately. It will not be closed + * with the joystick. + * + * When opening from a joystick you should first close the haptic device before + * closing the joystick device. If not, on some implementations the haptic + * device will also get unallocated and you'll be unable to use force feedback + * on that device. + * + * \param joystick Joystick to create a haptic device from. + * \return A valid haptic device identifier on success or NULL on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticClose + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick * + joystick); + +/** + * \brief Closes a Haptic device previously opened with SDL_HapticOpen(). + * + * \param haptic Haptic device to close. + */ +extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic); + +/** + * \brief Returns the number of effects a haptic device can store. + * + * On some platforms this isn't fully supported, and therefore is an + * approximation. Always check to see if your created effect was actually + * created and do not rely solely on SDL_HapticNumEffects(). + * + * \param haptic The haptic device to query effect max. + * \return The number of effects the haptic device can store or + * -1 on error. + * + * \sa SDL_HapticNumEffectsPlaying + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic); + +/** + * \brief Returns the number of effects a haptic device can play at the same + * time. + * + * This is not supported on all platforms, but will always return a value. + * Added here for the sake of completeness. + * + * \param haptic The haptic device to query maximum playing effects. + * \return The number of effects the haptic device can play at the same time + * or -1 on error. + * + * \sa SDL_HapticNumEffects + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic); + +/** + * \brief Gets the haptic device's supported features in bitwise manner. + * + * Example: + * \code + * if (SDL_HapticQuery(haptic) & SDL_HAPTIC_CONSTANT) { + * printf("We have constant haptic effect!"); + * } + * \endcode + * + * \param haptic The haptic device to query. + * \return Haptic features in bitwise manner (OR'd). + * + * \sa SDL_HapticNumEffects + * \sa SDL_HapticEffectSupported + */ +extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic); + + +/** + * \brief Gets the number of haptic axes the device has. + * + * \sa SDL_HapticDirection + */ +extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic); + +/** + * \brief Checks to see if effect is supported by haptic. + * + * \param haptic Haptic device to check on. + * \param effect Effect to check to see if it is supported. + * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * + * \sa SDL_HapticQuery + * \sa SDL_HapticNewEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic, + SDL_HapticEffect * + effect); + +/** + * \brief Creates a new haptic effect on the device. + * + * \param haptic Haptic device to create the effect on. + * \param effect Properties of the effect to create. + * \return The id of the effect on success or -1 on error. + * + * \sa SDL_HapticUpdateEffect + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic, + SDL_HapticEffect * effect); + +/** + * \brief Updates the properties of an effect. + * + * Can be used dynamically, although behaviour when dynamically changing + * direction may be strange. Specifically the effect may reupload itself + * and start playing from the start. You cannot change the type either when + * running SDL_HapticUpdateEffect(). + * + * \param haptic Haptic device that has the effect. + * \param effect Effect to update. + * \param data New effect properties to use. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticNewEffect + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic, + int effect, + SDL_HapticEffect * data); + +/** + * \brief Runs the haptic effect on its associated haptic device. + * + * If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over + * repeating the envelope (attack and fade) every time. If you only want the + * effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length + * parameter. + * + * \param haptic Haptic device to run the effect on. + * \param effect Identifier of the haptic effect to run. + * \param iterations Number of iterations to run the effect. Use + * ::SDL_HAPTIC_INFINITY for infinity. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticStopEffect + * \sa SDL_HapticDestroyEffect + * \sa SDL_HapticGetEffectStatus + */ +extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic, + int effect, + Uint32 iterations); + +/** + * \brief Stops the haptic effect on its associated haptic device. + * + * \param haptic Haptic device to stop the effect on. + * \param effect Identifier of the effect to stop. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic, + int effect); + +/** + * \brief Destroys a haptic effect on the device. + * + * This will stop the effect if it's running. Effects are automatically + * destroyed when the device is closed. + * + * \param haptic Device to destroy the effect on. + * \param effect Identifier of the effect to destroy. + * + * \sa SDL_HapticNewEffect + */ +extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic, + int effect); + +/** + * \brief Gets the status of the current effect on the haptic device. + * + * Device must support the ::SDL_HAPTIC_STATUS feature. + * + * \param haptic Haptic device to query the effect status on. + * \param effect Identifier of the effect to query its status. + * \return 0 if it isn't playing, 1 if it is playing or -1 on error. + * + * \sa SDL_HapticRunEffect + * \sa SDL_HapticStopEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic, + int effect); + +/** + * \brief Sets the global gain of the device. + * + * Device must support the ::SDL_HAPTIC_GAIN feature. + * + * The user may specify the maximum gain by setting the environment variable + * SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to + * SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the + * maximum. + * + * \param haptic Haptic device to set the gain on. + * \param gain Value to set the gain to, should be between 0 and 100. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain); + +/** + * \brief Sets the global autocenter of the device. + * + * Autocenter should be between 0 and 100. Setting it to 0 will disable + * autocentering. + * + * Device must support the ::SDL_HAPTIC_AUTOCENTER feature. + * + * \param haptic Haptic device to set autocentering on. + * \param autocenter Value to set autocenter to, 0 disables autocentering. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic, + int autocenter); + +/** + * \brief Pauses a haptic device. + * + * Device must support the ::SDL_HAPTIC_PAUSE feature. Call + * SDL_HapticUnpause() to resume playback. + * + * Do not modify the effects nor add new ones while the device is paused. + * That can cause all sorts of weird errors. + * + * \param haptic Haptic device to pause. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticUnpause + */ +extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic); + +/** + * \brief Unpauses a haptic device. + * + * Call to unpause after SDL_HapticPause(). + * + * \param haptic Haptic device to unpause. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticPause + */ +extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic); + +/** + * \brief Stops all the currently playing effects on a haptic device. + * + * \param haptic Haptic device to stop. + * \return 0 on success or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic); + +/** + * \brief Checks to see if rumble is supported on a haptic device. + * + * \param haptic Haptic device to check to see if it supports rumble. + * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic); + +/** + * \brief Initializes the haptic device for simple rumble playback. + * + * \param haptic Haptic device to initialize for simple rumble playback. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic); + +/** + * \brief Runs simple rumble on a haptic device + * + * \param haptic Haptic device to play rumble effect on. + * \param strength Strength of the rumble to play as a 0-1 float value. + * \param length Length of the rumble to play in milliseconds. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length ); + +/** + * \brief Stops the simple rumble on a haptic device. + * + * \param haptic Haptic to stop the rumble on. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_haptic_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_hints.h b/#ThirdParty/libSDL/include/SDL_hints.h new file mode 100644 index 0000000..3bd5435 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_hints.h @@ -0,0 +1,711 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_hints.h + * + * Official documentation for SDL configuration variables + * + * This file contains functions to set and get configuration hints, + * as well as listing each of them alphabetically. + * + * The convention for naming hints is SDL_HINT_X, where "SDL_X" is + * the environment variable that can be used to override the default. + * + * In general these hints are just that - they may or may not be + * supported or applicable on any given platform, but they provide + * a way for an application or user to give the library a hint as + * to how they would like the library to work. + */ + +#ifndef _SDL_hints_h +#define _SDL_hints_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief A variable controlling how 3D acceleration is used to accelerate the SDL screen surface. + * + * SDL can try to accelerate the SDL screen surface by using streaming + * textures with a 3D rendering engine. This variable controls whether and + * how this is done. + * + * This variable can be set to the following values: + * "0" - Disable 3D acceleration + * "1" - Enable 3D acceleration, using the default renderer. + * "X" - Enable 3D acceleration, using X where X is one of the valid rendering drivers. (e.g. "direct3d", "opengl", etc.) + * + * By default SDL tries to make a best guess for each platform whether + * to use acceleration or not. + */ +#define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION" + +/** + * \brief A variable specifying which render driver to use. + * + * If the application doesn't pick a specific renderer to use, this variable + * specifies the name of the preferred renderer. If the preferred renderer + * can't be initialized, the normal default renderer is used. + * + * This variable is case insensitive and can be set to the following values: + * "direct3d" + * "opengl" + * "opengles2" + * "opengles" + * "software" + * + * The default varies by platform, but it's the first one in the list that + * is available on the current platform. + */ +#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER" + +/** + * \brief A variable controlling whether the OpenGL render driver uses shaders if they are available. + * + * This variable can be set to the following values: + * "0" - Disable shaders + * "1" - Enable shaders + * + * By default shaders are used if OpenGL supports them. + */ +#define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS" + +/** + * \brief A variable controlling whether the Direct3D device is initialized for thread-safe operations. + * + * This variable can be set to the following values: + * "0" - Thread-safety is not enabled (faster) + * "1" - Thread-safety is enabled + * + * By default the Direct3D device is created with thread-safety disabled. + */ +#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE" + +/** + * \brief A variable controlling whether to enable Direct3D 11+'s Debug Layer. + * + * This variable does not have any effect on the Direct3D 9 based renderer. + * + * This variable can be set to the following values: + * "0" - Disable Debug Layer use + * "1" - Enable Debug Layer use + * + * By default, SDL does not use Direct3D Debug Layer. + */ +#define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_RENDER_DIRECT3D11_DEBUG" + +/** + * \brief A variable controlling the scaling quality + * + * This variable can be set to the following values: + * "0" or "nearest" - Nearest pixel sampling + * "1" or "linear" - Linear filtering (supported by OpenGL and Direct3D) + * "2" or "best" - Currently this is the same as "linear" + * + * By default nearest pixel sampling is used + */ +#define SDL_HINT_RENDER_SCALE_QUALITY "SDL_RENDER_SCALE_QUALITY" + +/** + * \brief A variable controlling whether updates to the SDL screen surface should be synchronized with the vertical refresh, to avoid tearing. + * + * This variable can be set to the following values: + * "0" - Disable vsync + * "1" - Enable vsync + * + * By default SDL does not sync screen surface updates with vertical refresh. + */ +#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" + +/** + * \brief A variable controlling whether the screensaver is enabled. + * + * This variable can be set to the following values: + * "0" - Disable screensaver + * "1" - Enable screensaver + * + * By default SDL will disable the screensaver. + */ +#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER "SDL_VIDEO_ALLOW_SCREENSAVER" + +/** + * \brief A variable controlling whether the X11 VidMode extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable XVidMode + * "1" - Enable XVidMode + * + * By default SDL will use XVidMode if it is available. + */ +#define SDL_HINT_VIDEO_X11_XVIDMODE "SDL_VIDEO_X11_XVIDMODE" + +/** + * \brief A variable controlling whether the X11 Xinerama extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable Xinerama + * "1" - Enable Xinerama + * + * By default SDL will use Xinerama if it is available. + */ +#define SDL_HINT_VIDEO_X11_XINERAMA "SDL_VIDEO_X11_XINERAMA" + +/** + * \brief A variable controlling whether the X11 XRandR extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable XRandR + * "1" - Enable XRandR + * + * By default SDL will not use XRandR because of window manager issues. + */ +#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR" + +/** + * \brief A variable controlling whether the X11 _NET_WM_PING protocol should be supported. + * + * This variable can be set to the following values: + * "0" - Disable _NET_WM_PING + * "1" - Enable _NET_WM_PING + * + * By default SDL will use _NET_WM_PING, but for applications that know they + * will not always be able to respond to ping requests in a timely manner they can + * turn it off to avoid the window manager thinking the app is hung. + * The hint is checked in CreateWindow. + */ +#define SDL_HINT_VIDEO_X11_NET_WM_PING "SDL_VIDEO_X11_NET_WM_PING" + +/** + * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden + * + * This variable can be set to the following values: + * "0" - The window frame is not interactive when the cursor is hidden (no move, resize, etc) + * "1" - The window frame is interactive when the cursor is hidden + * + * By default SDL will allow interaction with the window frame when the cursor is hidden + */ +#define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN" + +/** + * \brief A variable controlling whether the windows message loop is processed by SDL + * + * This variable can be set to the following values: + * "0" - The window message loop is not run + * "1" - The window message loop is processed in SDL_PumpEvents() + * + * By default SDL will process the windows message loop + */ +#define SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP "SDL_WINDOWS_ENABLE_MESSAGELOOP" + +/** + * \brief A variable controlling whether grabbing input grabs the keyboard + * + * This variable can be set to the following values: + * "0" - Grab will affect only the mouse + * "1" - Grab will affect mouse and keyboard + * + * By default SDL will not grab the keyboard so system shortcuts still work. + */ +#define SDL_HINT_GRAB_KEYBOARD "SDL_GRAB_KEYBOARD" + +/** +* \brief A variable controlling whether relative mouse mode is implemented using mouse warping +* +* This variable can be set to the following values: +* "0" - Relative mouse mode uses raw input +* "1" - Relative mouse mode uses mouse warping +* +* By default SDL will use raw input for relative mouse mode +*/ +#define SDL_HINT_MOUSE_RELATIVE_MODE_WARP "SDL_MOUSE_RELATIVE_MODE_WARP" + +/** + * \brief Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true. + * + */ +#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" + +/** + * \brief A variable controlling whether the idle timer is disabled on iOS. + * + * When an iOS app does not receive touches for some time, the screen is + * dimmed automatically. For games where the accelerometer is the only input + * this is problematic. This functionality can be disabled by setting this + * hint. + * + * As of SDL 2.0.4, SDL_EnableScreenSaver and SDL_DisableScreenSaver accomplish + * the same thing on iOS. They should be preferred over this hint. + * + * This variable can be set to the following values: + * "0" - Enable idle timer + * "1" - Disable idle timer + */ +#define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED" + +/** + * \brief A variable controlling which orientations are allowed on iOS. + * + * In some circumstances it is necessary to be able to explicitly control + * which UI orientations are allowed. + * + * This variable is a space delimited list of the following values: + * "LandscapeLeft", "LandscapeRight", "Portrait" "PortraitUpsideDown" + */ +#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS" + +/** + * \brief A variable controlling whether the Android / iOS built-in + * accelerometer should be listed as a joystick device, rather than listing + * actual joysticks only. + * + * This variable can be set to the following values: + * "0" - List only real joysticks and accept input from them + * "1" - List real joysticks along with the accelerometer as if it were a 3 axis joystick (the default). + */ +#define SDL_HINT_ACCELEROMETER_AS_JOYSTICK "SDL_ACCELEROMETER_AS_JOYSTICK" + + +/** + * \brief A variable that lets you disable the detection and use of Xinput gamepad devices + * + * The variable can be set to the following values: + * "0" - Disable XInput detection (only uses direct input) + * "1" - Enable XInput detection (the default) + */ +#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED" + + +/** + * \brief A variable that causes SDL to use the old axis and button mapping for XInput devices. + * + * This hint is for backwards compatibility only and will be removed in SDL 2.1 + * + * The default value is "0". This hint must be set before SDL_Init() + */ +#define SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING "SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING" + + +/** + * \brief A variable that lets you manually hint extra gamecontroller db entries + * + * The variable should be newline delimited rows of gamecontroller config data, see SDL_gamecontroller.h + * + * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) + * You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping() + */ +#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG" + + +/** + * \brief A variable that lets you enable joystick (and gamecontroller) events even when your app is in the background. + * + * The variable can be set to the following values: + * "0" - Disable joystick & gamecontroller input events when the + * application is in the background. + * "1" - Enable joystick & gamecontroller input events when the + * application is in the background. + * + * The default value is "0". This hint may be set at any time. + */ +#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS" + + +/** + * \brief If set to "0" then never set the top most bit on a SDL Window, even if the video mode expects it. + * This is a debugging aid for developers and not expected to be used by end users. The default is "1" + * + * This variable can be set to the following values: + * "0" - don't allow topmost + * "1" - allow topmost + */ +#define SDL_HINT_ALLOW_TOPMOST "SDL_ALLOW_TOPMOST" + + +/** + * \brief A variable that controls the timer resolution, in milliseconds. + * + * The higher resolution the timer, the more frequently the CPU services + * timer interrupts, and the more precise delays are, but this takes up + * power and CPU time. This hint is only used on Windows 7 and earlier. + * + * See this blog post for more information: + * http://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ + * + * If this variable is set to "0", the system timer resolution is not set. + * + * The default value is "1". This hint may be set at any time. + */ +#define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION" + + + +/** +* \brief A string specifying SDL's threads stack size in bytes or "0" for the backend's default size +* +* Use this hint in case you need to set SDL's threads stack size to other than the default. +* This is specially useful if you build SDL against a non glibc libc library (such as musl) which +* provides a relatively small default thread stack size (a few kilobytes versus the default 8MB glibc uses). +* Support for this hint is currently available only in the pthread backend. +*/ +#define SDL_HINT_THREAD_STACK_SIZE "SDL_THREAD_STACK_SIZE" + +/** + * \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS) + */ +#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED" + +/** + * \brief A variable that determines whether ctrl+click should generate a right-click event on Mac + * + * If present, holding ctrl while left clicking will generate a right click + * event when on Mac. + */ +#define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK" + +/** +* \brief A variable specifying which shader compiler to preload when using the Chrome ANGLE binaries +* +* SDL has EGL and OpenGL ES2 support on Windows via the ANGLE project. It +* can use two different sets of binaries, those compiled by the user from source +* or those provided by the Chrome browser. In the later case, these binaries require +* that SDL loads a DLL providing the shader compiler. +* +* This variable can be set to the following values: +* "d3dcompiler_46.dll" - default, best for Vista or later. +* "d3dcompiler_43.dll" - for XP support. +* "none" - do not load any library, useful if you compiled ANGLE from source and included the compiler in your binaries. +* +*/ +#define SDL_HINT_VIDEO_WIN_D3DCOMPILER "SDL_VIDEO_WIN_D3DCOMPILER" + +/** +* \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p"). +* +* If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has +* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly +* created SDL_Window: +* +* 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is +* needed for example when sharing an OpenGL context across multiple windows. +* +* 2. The flag SDL_WINDOW_OPENGL will be set on the new window so it can be used for +* OpenGL rendering. +* +* This variable can be set to the following values: +* The address (as a string "%p") of the SDL_Window* that new windows created with SDL_CreateWindowFrom() should +* share a pixel format with. +*/ +#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT" + +/** + * \brief A URL to a WinRT app's privacy policy + * + * All network-enabled WinRT apps must make a privacy policy available to its + * users. On Windows 8, 8.1, and RT, Microsoft mandates that this policy be + * be available in the Windows Settings charm, as accessed from within the app. + * SDL provides code to add a URL-based link there, which can point to the app's + * privacy policy. + * + * To setup a URL to an app's privacy policy, set SDL_HINT_WINRT_PRIVACY_POLICY_URL + * before calling any SDL_Init functions. The contents of the hint should + * be a valid URL. For example, "http://www.example.com". + * + * The default value is "", which will prevent SDL from adding a privacy policy + * link to the Settings charm. This hint should only be set during app init. + * + * The label text of an app's "Privacy Policy" link may be customized via another + * hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. + * + * Please note that on Windows Phone, Microsoft does not provide standard UI + * for displaying a privacy policy link, and as such, SDL_HINT_WINRT_PRIVACY_POLICY_URL + * will not get used on that platform. Network-enabled phone apps should display + * their privacy policy through some other, in-app means. + */ +#define SDL_HINT_WINRT_PRIVACY_POLICY_URL "SDL_WINRT_PRIVACY_POLICY_URL" + +/** \brief Label text for a WinRT app's privacy policy link + * + * Network-enabled WinRT apps must include a privacy policy. On Windows 8, 8.1, and RT, + * Microsoft mandates that this policy be available via the Windows Settings charm. + * SDL provides code to add a link there, with its label text being set via the + * optional hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. + * + * Please note that a privacy policy's contents are not set via this hint. A separate + * hint, SDL_HINT_WINRT_PRIVACY_POLICY_URL, is used to link to the actual text of the + * policy. + * + * The contents of this hint should be encoded as a UTF8 string. + * + * The default value is "Privacy Policy". This hint should only be set during app + * initialization, preferably before any calls to SDL_Init. + * + * For additional information on linking to a privacy policy, see the documentation for + * SDL_HINT_WINRT_PRIVACY_POLICY_URL. + */ +#define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_WINRT_PRIVACY_POLICY_LABEL" + +/** \brief Allows back-button-press events on Windows Phone to be marked as handled + * + * Windows Phone devices typically feature a Back button. When pressed, + * the OS will emit back-button-press events, which apps are expected to + * handle in an appropriate manner. If apps do not explicitly mark these + * events as 'Handled', then the OS will invoke its default behavior for + * unhandled back-button-press events, which on Windows Phone 8 and 8.1 is to + * terminate the app (and attempt to switch to the previous app, or to the + * device's home screen). + * + * Setting the SDL_HINT_WINRT_HANDLE_BACK_BUTTON hint to "1" will cause SDL + * to mark back-button-press events as Handled, if and when one is sent to + * the app. + * + * Internally, Windows Phone sends back button events as parameters to + * special back-button-press callback functions. Apps that need to respond + * to back-button-press events are expected to register one or more + * callback functions for such, shortly after being launched (during the + * app's initialization phase). After the back button is pressed, the OS + * will invoke these callbacks. If the app's callback(s) do not explicitly + * mark the event as handled by the time they return, or if the app never + * registers one of these callback, the OS will consider the event + * un-handled, and it will apply its default back button behavior (terminate + * the app). + * + * SDL registers its own back-button-press callback with the Windows Phone + * OS. This callback will emit a pair of SDL key-press events (SDL_KEYDOWN + * and SDL_KEYUP), each with a scancode of SDL_SCANCODE_AC_BACK, after which + * it will check the contents of the hint, SDL_HINT_WINRT_HANDLE_BACK_BUTTON. + * If the hint's value is set to "1", the back button event's Handled + * property will get set to 'true'. If the hint's value is set to something + * else, or if it is unset, SDL will leave the event's Handled property + * alone. (By default, the OS sets this property to 'false', to note.) + * + * SDL apps can either set SDL_HINT_WINRT_HANDLE_BACK_BUTTON well before a + * back button is pressed, or can set it in direct-response to a back button + * being pressed. + * + * In order to get notified when a back button is pressed, SDL apps should + * register a callback function with SDL_AddEventWatch(), and have it listen + * for SDL_KEYDOWN events that have a scancode of SDL_SCANCODE_AC_BACK. + * (Alternatively, SDL_KEYUP events can be listened-for. Listening for + * either event type is suitable.) Any value of SDL_HINT_WINRT_HANDLE_BACK_BUTTON + * set by such a callback, will be applied to the OS' current + * back-button-press event. + * + * More details on back button behavior in Windows Phone apps can be found + * at the following page, on Microsoft's developer site: + * http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx + */ +#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_WINRT_HANDLE_BACK_BUTTON" + +/** + * \brief A variable that dictates policy for fullscreen Spaces on Mac OS X. + * + * This hint only applies to Mac OS X. + * + * The variable can be set to the following values: + * "0" - Disable Spaces support (FULLSCREEN_DESKTOP won't use them and + * SDL_WINDOW_RESIZABLE windows won't offer the "fullscreen" + * button on their titlebars). + * "1" - Enable Spaces support (FULLSCREEN_DESKTOP will use them and + * SDL_WINDOW_RESIZABLE windows will offer the "fullscreen" + * button on their titlebars). + * + * The default value is "1". Spaces are disabled regardless of this hint if + * the OS isn't at least Mac OS X Lion (10.7). This hint must be set before + * any windows are created. + */ +#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES" + +/** +* \brief When set don't force the SDL app to become a foreground process +* +* This hint only applies to Mac OS X. +* +*/ +#define SDL_HINT_MAC_BACKGROUND_APP "SDL_MAC_BACKGROUND_APP" + +/** + * \brief Android APK expansion main file version. Should be a string number like "1", "2" etc. + * + * Must be set together with SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION. + * + * If both hints were set then SDL_RWFromFile() will look into expansion files + * after a given relative path was not found in the internal storage and assets. + * + * By default this hint is not set and the APK expansion files are not searched. + */ +#define SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION" + +/** + * \brief Android APK expansion patch file version. Should be a string number like "1", "2" etc. + * + * Must be set together with SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION. + * + * If both hints were set then SDL_RWFromFile() will look into expansion files + * after a given relative path was not found in the internal storage and assets. + * + * By default this hint is not set and the APK expansion files are not searched. + */ +#define SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION" + +/** + * \brief A variable to control whether certain IMEs should handle text editing internally instead of sending SDL_TEXTEDITING events. + * + * The variable can be set to the following values: + * "0" - SDL_TEXTEDITING events are sent, and it is the application's + * responsibility to render the text from these events and + * differentiate it somehow from committed text. (default) + * "1" - If supported by the IME then SDL_TEXTEDITING events are not sent, + * and text that is being composed will be rendered in its own UI. + */ +#define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING" + + /** + * \brief A variable to control whether mouse and touch events are to be treated together or separately + * + * The variable can be set to the following values: + * "0" - Mouse events will be handled as touch events, and touch will raise fake mouse + * events. This is the behaviour of SDL <= 2.0.3. (default) + * "1" - Mouse events will be handled separately from pure touch events. + * + * The value of this hint is used at runtime, so it can be changed at any time. + */ +#define SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH" + +/** + * \brief override the binding element for keyboard inputs for Emscripten builds + * + * This hint only applies to the emscripten platform + * + * The variable can be one of + * "#window" - The javascript window object (this is the default) + * "#document" - The javascript document object + * "#screen" - the javascript window.screen object + * "#canvas" - the WebGL canvas element + * any other string without a leading # sign applies to the element on the page with that ID. + */ +#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT" + +/** + * \brief Tell SDL not to catch the SIGINT or SIGTERM signals. + * + * This hint only applies to Unix-like platforms. + * + * The variable can be set to the following values: + * "0" - SDL will install a SIGINT and SIGTERM handler, and when it + * catches a signal, convert it into an SDL_QUIT event. + * "1" - SDL will not install a signal handler at all. + */ +#define SDL_HINT_NO_SIGNAL_HANDLERS "SDL_NO_SIGNAL_HANDLERS" + +/** + * \brief Tell SDL not to generate window-close events for Alt+F4 on Windows. + * + * The variable can be set to the following values: + * "0" - SDL will generate a window-close event when it sees Alt+F4. + * "1" - SDL will only do normal key handling for Alt+F4. + */ +#define SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 "SDL_WINDOWS_NO_CLOSE_ON_ALT_F4" + +/** + * \brief An enumeration of hint priorities + */ +typedef enum +{ + SDL_HINT_DEFAULT, + SDL_HINT_NORMAL, + SDL_HINT_OVERRIDE +} SDL_HintPriority; + + +/** + * \brief Set a hint with a specific priority + * + * The priority controls the behavior when setting a hint that already + * has a value. Hints will replace existing hints of their priority and + * lower. Environment variables are considered to have override priority. + * + * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, + const char *value, + SDL_HintPriority priority); + +/** + * \brief Set a hint with normal priority + * + * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, + const char *value); + +/** + * \brief Get a hint + * + * \return The string value of a hint variable. + */ +extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); + +/** + * \brief Add a function to watch a particular hint + * + * \param name The hint to watch + * \param callback The function to call when the hint value changes + * \param userdata A pointer to pass to the callback function + */ +typedef void (*SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue); +extern DECLSPEC void SDLCALL SDL_AddHintCallback(const char *name, + SDL_HintCallback callback, + void *userdata); + +/** + * \brief Remove a function watching a particular hint + * + * \param name The hint being watched + * \param callback The function being called when the hint value changes + * \param userdata A pointer being passed to the callback function + */ +extern DECLSPEC void SDLCALL SDL_DelHintCallback(const char *name, + SDL_HintCallback callback, + void *userdata); + +/** + * \brief Clear all hints + * + * This function is called during SDL_Quit() to free stored hints. + */ +extern DECLSPEC void SDLCALL SDL_ClearHints(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_hints_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_joystick.h b/#ThirdParty/libSDL/include/SDL_joystick.h new file mode 100644 index 0000000..266f3b3 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_joystick.h @@ -0,0 +1,273 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_joystick.h + * + * Include file for SDL joystick event handling + * + * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks, with the exact joystick + * behind a device_index changing as joysticks are plugged and unplugged. + * + * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted + * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in. + * + * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of + * the device (a X360 wired controller for example). This identifier is platform dependent. + * + * + */ + +#ifndef _SDL_joystick_h +#define _SDL_joystick_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_joystick.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + * for joysticks, and load appropriate drivers. + * + * If you would like to receive joystick updates while the application + * is in the background, you should set the following hint before calling + * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + */ + +/* The joystick structure used to identify an SDL joystick */ +struct _SDL_Joystick; +typedef struct _SDL_Joystick SDL_Joystick; + +/* A structure that encodes the stable unique id for a joystick device */ +typedef struct { + Uint8 data[16]; +} SDL_JoystickGUID; + +typedef Sint32 SDL_JoystickID; + +typedef enum +{ + SDL_JOYSTICK_POWER_UNKNOWN = -1, + SDL_JOYSTICK_POWER_EMPTY, + SDL_JOYSTICK_POWER_LOW, + SDL_JOYSTICK_POWER_MEDIUM, + SDL_JOYSTICK_POWER_FULL, + SDL_JOYSTICK_POWER_WIRED, + SDL_JOYSTICK_POWER_MAX +} SDL_JoystickPowerLevel; + +/* Function prototypes */ +/** + * Count the number of joysticks attached to the system right now + */ +extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); + +/** + * Get the implementation dependent name of a joystick. + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index); + +/** + * Open a joystick for use. + * The index passed as an argument refers to the N'th joystick on the system. + * This index is not the value which will identify this joystick in future + * joystick events. The joystick's instance id (::SDL_JoystickID) will be used + * there instead. + * + * \return A joystick identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); + +/** + * Return the SDL_Joystick associated with an instance id. + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID joyid); + +/** + * Return the name for this currently opened joystick. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick); + +/** + * Return the GUID for the joystick at this index + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index); + +/** + * Return the GUID for this opened joystick + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick); + +/** + * Return a string representation for this guid. pszGUID must point to at least 33 bytes + * (32 for the string plus a NULL terminator). + */ +extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID); + +/** + * convert a string into a joystick formatted guid + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID); + +/** + * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick); + +/** + * Get the instance ID of an opened joystick or -1 if the joystick is invalid. + */ +extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick); + +/** + * Get the number of general axis controls on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick); + +/** + * Get the number of trackballs on a joystick. + * + * Joystick trackballs have only relative motion events associated + * with them and their state cannot be polled. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick); + +/** + * Get the number of POV hats on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick); + +/** + * Get the number of buttons on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick); + +/** + * Update the current state of the open joysticks. + * + * This is called automatically by the event loop if any joystick + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); + +/** + * Enable/disable joystick event polling. + * + * If joystick events are disabled, you must call SDL_JoystickUpdate() + * yourself and check the state of the joystick when you want joystick + * information. + * + * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); + +/** + * Get the current state of an axis control on a joystick. + * + * The state is a value ranging from -32768 to 32767. + * + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, + int axis); + +/** + * \name Hat positions + */ +/* @{ */ +#define SDL_HAT_CENTERED 0x00 +#define SDL_HAT_UP 0x01 +#define SDL_HAT_RIGHT 0x02 +#define SDL_HAT_DOWN 0x04 +#define SDL_HAT_LEFT 0x08 +#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) +#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) +#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) +#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) +/* @} */ + +/** + * Get the current state of a POV hat on a joystick. + * + * The hat indices start at index 0. + * + * \return The return value is one of the following positions: + * - ::SDL_HAT_CENTERED + * - ::SDL_HAT_UP + * - ::SDL_HAT_RIGHT + * - ::SDL_HAT_DOWN + * - ::SDL_HAT_LEFT + * - ::SDL_HAT_RIGHTUP + * - ::SDL_HAT_RIGHTDOWN + * - ::SDL_HAT_LEFTUP + * - ::SDL_HAT_LEFTDOWN + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick, + int hat); + +/** + * Get the ball axis change since the last poll. + * + * \return 0, or -1 if you passed it invalid parameters. + * + * The ball indices start at index 0. + */ +extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick, + int ball, int *dx, int *dy); + +/** + * Get the current state of a button on a joystick. + * + * The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick, + int button); + +/** + * Close a joystick previously opened with SDL_JoystickOpen(). + */ +extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick); + +/** + * Return the battery level of this joystick + */ +extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_joystick_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_keyboard.h b/#ThirdParty/libSDL/include/SDL_keyboard.h new file mode 100644 index 0000000..bbba0f0 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_keyboard.h @@ -0,0 +1,217 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_keyboard.h + * + * Include file for SDL keyboard event handling + */ + +#ifndef _SDL_keyboard_h +#define _SDL_keyboard_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_keycode.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The SDL keysym structure, used in key events. + * + * \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event. + */ +typedef struct SDL_Keysym +{ + SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ + SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */ + Uint16 mod; /**< current key modifiers */ + Uint32 unused; +} SDL_Keysym; + +/* Function prototypes */ + +/** + * \brief Get the window which currently has keyboard focus. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); + +/** + * \brief Get a snapshot of the current state of the keyboard. + * + * \param numkeys if non-NULL, receives the length of the returned array. + * + * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. + * + * \b Example: + * \code + * const Uint8 *state = SDL_GetKeyboardState(NULL); + * if ( state[SDL_SCANCODE_RETURN] ) { + * printf(" is pressed.\n"); + * } + * \endcode + */ +extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); + +/** + * \brief Get the current key modifier state for the keyboard. + */ +extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); + +/** + * \brief Set the current key modifier state for the keyboard. + * + * \note This does not change the keyboard state, only the key modifier flags. + */ +extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); + +/** + * \brief Get the key code corresponding to the given scancode according + * to the current keyboard layout. + * + * See ::SDL_Keycode for details. + * + * \sa SDL_GetKeyName() + */ +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); + +/** + * \brief Get the scancode corresponding to the given key code according to the + * current keyboard layout. + * + * See ::SDL_Scancode for details. + * + * \sa SDL_GetScancodeName() + */ +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); + +/** + * \brief Get a human-readable name for a scancode. + * + * \return A pointer to the name for the scancode. + * If the scancode doesn't have a name, this function returns + * an empty string (""). + * + * \sa SDL_Scancode + */ +extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); + +/** + * \brief Get a scancode from a human-readable name + * + * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized + * + * \sa SDL_Scancode + */ +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); + +/** + * \brief Get a human-readable name for a key. + * + * \return A pointer to a UTF-8 string that stays valid at least until the next + * call to this function. If you need it around any longer, you must + * copy it. If the key doesn't have a name, this function returns an + * empty string (""). + * + * \sa SDL_Key + */ +extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); + +/** + * \brief Get a key code from a human-readable name + * + * \return key code, or SDLK_UNKNOWN if the name wasn't recognized + * + * \sa SDL_Keycode + */ +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); + +/** + * \brief Start accepting Unicode text input events. + * This function will show the on-screen keyboard if supported. + * + * \sa SDL_StopTextInput() + * \sa SDL_SetTextInputRect() + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC void SDLCALL SDL_StartTextInput(void); + +/** + * \brief Return whether or not Unicode text input events are enabled. + * + * \sa SDL_StartTextInput() + * \sa SDL_StopTextInput() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void); + +/** + * \brief Stop receiving any text input events. + * This function will hide the on-screen keyboard if supported. + * + * \sa SDL_StartTextInput() + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC void SDLCALL SDL_StopTextInput(void); + +/** + * \brief Set the rectangle used to type Unicode text inputs. + * This is used as a hint for IME and on-screen keyboard placement. + * + * \sa SDL_StartTextInput() + */ +extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); + +/** + * \brief Returns whether the platform has some screen keyboard support. + * + * \return SDL_TRUE if some keyboard support is available else SDL_FALSE. + * + * \note Not all screen keyboard functions are supported on all platforms. + * + * \sa SDL_IsScreenKeyboardShown() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void); + +/** + * \brief Returns whether the screen keyboard is shown for given window. + * + * \param window The window for which screen keyboard should be queried. + * + * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE. + * + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_keyboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_keycode.h b/#ThirdParty/libSDL/include/SDL_keycode.h new file mode 100644 index 0000000..7be9635 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_keycode.h @@ -0,0 +1,341 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_keycode.h + * + * Defines constants which identify keyboard keys and modifiers. + */ + +#ifndef _SDL_keycode_h +#define _SDL_keycode_h + +#include "SDL_stdinc.h" +#include "SDL_scancode.h" + +/** + * \brief The SDL virtual key representation. + * + * Values of this type are used to represent keyboard keys using the current + * layout of the keyboard. These values include Unicode values representing + * the unmodified character that would be generated by pressing the key, or + * an SDLK_* constant for those keys that do not generate characters. + */ +typedef Sint32 SDL_Keycode; + +#define SDLK_SCANCODE_MASK (1<<30) +#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) + +enum +{ + SDLK_UNKNOWN = 0, + + SDLK_RETURN = '\r', + SDLK_ESCAPE = '\033', + SDLK_BACKSPACE = '\b', + SDLK_TAB = '\t', + SDLK_SPACE = ' ', + SDLK_EXCLAIM = '!', + SDLK_QUOTEDBL = '"', + SDLK_HASH = '#', + SDLK_PERCENT = '%', + SDLK_DOLLAR = '$', + SDLK_AMPERSAND = '&', + SDLK_QUOTE = '\'', + SDLK_LEFTPAREN = '(', + SDLK_RIGHTPAREN = ')', + SDLK_ASTERISK = '*', + SDLK_PLUS = '+', + SDLK_COMMA = ',', + SDLK_MINUS = '-', + SDLK_PERIOD = '.', + SDLK_SLASH = '/', + SDLK_0 = '0', + SDLK_1 = '1', + SDLK_2 = '2', + SDLK_3 = '3', + SDLK_4 = '4', + SDLK_5 = '5', + SDLK_6 = '6', + SDLK_7 = '7', + SDLK_8 = '8', + SDLK_9 = '9', + SDLK_COLON = ':', + SDLK_SEMICOLON = ';', + SDLK_LESS = '<', + SDLK_EQUALS = '=', + SDLK_GREATER = '>', + SDLK_QUESTION = '?', + SDLK_AT = '@', + /* + Skip uppercase letters + */ + SDLK_LEFTBRACKET = '[', + SDLK_BACKSLASH = '\\', + SDLK_RIGHTBRACKET = ']', + SDLK_CARET = '^', + SDLK_UNDERSCORE = '_', + SDLK_BACKQUOTE = '`', + SDLK_a = 'a', + SDLK_b = 'b', + SDLK_c = 'c', + SDLK_d = 'd', + SDLK_e = 'e', + SDLK_f = 'f', + SDLK_g = 'g', + SDLK_h = 'h', + SDLK_i = 'i', + SDLK_j = 'j', + SDLK_k = 'k', + SDLK_l = 'l', + SDLK_m = 'm', + SDLK_n = 'n', + SDLK_o = 'o', + SDLK_p = 'p', + SDLK_q = 'q', + SDLK_r = 'r', + SDLK_s = 's', + SDLK_t = 't', + SDLK_u = 'u', + SDLK_v = 'v', + SDLK_w = 'w', + SDLK_x = 'x', + SDLK_y = 'y', + SDLK_z = 'z', + + SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK), + + SDLK_F1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1), + SDLK_F2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2), + SDLK_F3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3), + SDLK_F4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4), + SDLK_F5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5), + SDLK_F6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6), + SDLK_F7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7), + SDLK_F8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8), + SDLK_F9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9), + SDLK_F10 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10), + SDLK_F11 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11), + SDLK_F12 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12), + + SDLK_PRINTSCREEN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN), + SDLK_SCROLLLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK), + SDLK_PAUSE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE), + SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT), + SDLK_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME), + SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP), + SDLK_DELETE = '\177', + SDLK_END = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END), + SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN), + SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT), + SDLK_LEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT), + SDLK_DOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN), + SDLK_UP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP), + + SDLK_NUMLOCKCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR), + SDLK_KP_DIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE), + SDLK_KP_MULTIPLY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY), + SDLK_KP_MINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS), + SDLK_KP_PLUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS), + SDLK_KP_ENTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER), + SDLK_KP_1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1), + SDLK_KP_2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2), + SDLK_KP_3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3), + SDLK_KP_4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4), + SDLK_KP_5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5), + SDLK_KP_6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6), + SDLK_KP_7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7), + SDLK_KP_8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8), + SDLK_KP_9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9), + SDLK_KP_0 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0), + SDLK_KP_PERIOD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD), + + SDLK_APPLICATION = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION), + SDLK_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER), + SDLK_KP_EQUALS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS), + SDLK_F13 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13), + SDLK_F14 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14), + SDLK_F15 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15), + SDLK_F16 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16), + SDLK_F17 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17), + SDLK_F18 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18), + SDLK_F19 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19), + SDLK_F20 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20), + SDLK_F21 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21), + SDLK_F22 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22), + SDLK_F23 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23), + SDLK_F24 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24), + SDLK_EXECUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE), + SDLK_HELP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP), + SDLK_MENU = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU), + SDLK_SELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT), + SDLK_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP), + SDLK_AGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN), + SDLK_UNDO = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO), + SDLK_CUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT), + SDLK_COPY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY), + SDLK_PASTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE), + SDLK_FIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND), + SDLK_MUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE), + SDLK_VOLUMEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP), + SDLK_VOLUMEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN), + SDLK_KP_COMMA = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA), + SDLK_KP_EQUALSAS400 = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400), + + SDLK_ALTERASE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE), + SDLK_SYSREQ = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ), + SDLK_CANCEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL), + SDLK_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR), + SDLK_PRIOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR), + SDLK_RETURN2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2), + SDLK_SEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR), + SDLK_OUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT), + SDLK_OPER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER), + SDLK_CLEARAGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN), + SDLK_CRSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL), + SDLK_EXSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL), + + SDLK_KP_00 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00), + SDLK_KP_000 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000), + SDLK_THOUSANDSSEPARATOR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR), + SDLK_DECIMALSEPARATOR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR), + SDLK_CURRENCYUNIT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT), + SDLK_CURRENCYSUBUNIT = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT), + SDLK_KP_LEFTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN), + SDLK_KP_RIGHTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN), + SDLK_KP_LEFTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE), + SDLK_KP_RIGHTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE), + SDLK_KP_TAB = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB), + SDLK_KP_BACKSPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE), + SDLK_KP_A = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A), + SDLK_KP_B = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B), + SDLK_KP_C = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C), + SDLK_KP_D = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D), + SDLK_KP_E = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E), + SDLK_KP_F = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F), + SDLK_KP_XOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR), + SDLK_KP_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER), + SDLK_KP_PERCENT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT), + SDLK_KP_LESS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS), + SDLK_KP_GREATER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER), + SDLK_KP_AMPERSAND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND), + SDLK_KP_DBLAMPERSAND = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND), + SDLK_KP_VERTICALBAR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR), + SDLK_KP_DBLVERTICALBAR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR), + SDLK_KP_COLON = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON), + SDLK_KP_HASH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH), + SDLK_KP_SPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE), + SDLK_KP_AT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT), + SDLK_KP_EXCLAM = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM), + SDLK_KP_MEMSTORE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE), + SDLK_KP_MEMRECALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL), + SDLK_KP_MEMCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR), + SDLK_KP_MEMADD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD), + SDLK_KP_MEMSUBTRACT = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT), + SDLK_KP_MEMMULTIPLY = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY), + SDLK_KP_MEMDIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE), + SDLK_KP_PLUSMINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS), + SDLK_KP_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR), + SDLK_KP_CLEARENTRY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY), + SDLK_KP_BINARY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY), + SDLK_KP_OCTAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL), + SDLK_KP_DECIMAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL), + SDLK_KP_HEXADECIMAL = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL), + + SDLK_LCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL), + SDLK_LSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT), + SDLK_LALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT), + SDLK_LGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI), + SDLK_RCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL), + SDLK_RSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT), + SDLK_RALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT), + SDLK_RGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI), + + SDLK_MODE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE), + + SDLK_AUDIONEXT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIONEXT), + SDLK_AUDIOPREV = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPREV), + SDLK_AUDIOSTOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOSTOP), + SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPLAY), + SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOMUTE), + SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIASELECT), + SDLK_WWW = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WWW), + SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MAIL), + SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALCULATOR), + SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COMPUTER), + SDLK_AC_SEARCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH), + SDLK_AC_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME), + SDLK_AC_BACK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK), + SDLK_AC_FORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD), + SDLK_AC_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP), + SDLK_AC_REFRESH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH), + SDLK_AC_BOOKMARKS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS), + + SDLK_BRIGHTNESSDOWN = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSDOWN), + SDLK_BRIGHTNESSUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSUP), + SDLK_DISPLAYSWITCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DISPLAYSWITCH), + SDLK_KBDILLUMTOGGLE = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMTOGGLE), + SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMDOWN), + SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMUP), + SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EJECT), + SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP) +}; + +/** + * \brief Enumeration of valid key mods (possibly OR'd together). + */ +typedef enum +{ + KMOD_NONE = 0x0000, + KMOD_LSHIFT = 0x0001, + KMOD_RSHIFT = 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LGUI = 0x0400, + KMOD_RGUI = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000 +} SDL_Keymod; + +#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) +#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) +#define KMOD_ALT (KMOD_LALT|KMOD_RALT) +#define KMOD_GUI (KMOD_LGUI|KMOD_RGUI) + +#endif /* _SDL_keycode_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_loadso.h b/#ThirdParty/libSDL/include/SDL_loadso.h new file mode 100644 index 0000000..3d540bd --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_loadso.h @@ -0,0 +1,81 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_loadso.h + * + * System dependent library loading routines + * + * Some things to keep in mind: + * \li These functions only work on C function names. Other languages may + * have name mangling and intrinsic language support that varies from + * compiler to compiler. + * \li Make sure you declare your function pointers with the same calling + * convention as the actual library function. Your code will crash + * mysteriously if you do not do this. + * \li Avoid namespace collisions. If you load a symbol from the library, + * it is not defined whether or not it goes into the global symbol + * namespace for the application. If it does and it conflicts with + * symbols in your code or other shared libraries, you will not get + * the results you expect. :) + */ + +#ifndef _SDL_loadso_h +#define _SDL_loadso_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This function dynamically loads a shared object and returns a pointer + * to the object handle (or NULL if there was an error). + * The 'sofile' parameter is a system dependent name of the object file. + */ +extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); + +/** + * Given an object handle, this function looks up the address of the + * named function in the shared object and returns it. This address + * is no longer valid after calling SDL_UnloadObject(). + */ +extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, + const char *name); + +/** + * Unload a shared object from memory. + */ +extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_loadso_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_log.h b/#ThirdParty/libSDL/include/SDL_log.h new file mode 100644 index 0000000..09be110 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_log.h @@ -0,0 +1,211 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_log.h + * + * Simple log messages with categories and priorities. + * + * By default logs are quiet, but if you're debugging SDL you might want: + * + * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN); + * + * Here's where the messages go on different platforms: + * Windows: debug output stream + * Android: log output + * Others: standard error output (stderr) + */ + +#ifndef _SDL_log_h +#define _SDL_log_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * \brief The maximum size of a log message + * + * Messages longer than the maximum size will be truncated + */ +#define SDL_MAX_LOG_MESSAGE 4096 + +/** + * \brief The predefined log categories + * + * By default the application category is enabled at the INFO level, + * the assert category is enabled at the WARN level, test is enabled + * at the VERBOSE level and all other categories are enabled at the + * CRITICAL level. + */ +enum +{ + SDL_LOG_CATEGORY_APPLICATION, + SDL_LOG_CATEGORY_ERROR, + SDL_LOG_CATEGORY_ASSERT, + SDL_LOG_CATEGORY_SYSTEM, + SDL_LOG_CATEGORY_AUDIO, + SDL_LOG_CATEGORY_VIDEO, + SDL_LOG_CATEGORY_RENDER, + SDL_LOG_CATEGORY_INPUT, + SDL_LOG_CATEGORY_TEST, + + /* Reserved for future SDL library use */ + SDL_LOG_CATEGORY_RESERVED1, + SDL_LOG_CATEGORY_RESERVED2, + SDL_LOG_CATEGORY_RESERVED3, + SDL_LOG_CATEGORY_RESERVED4, + SDL_LOG_CATEGORY_RESERVED5, + SDL_LOG_CATEGORY_RESERVED6, + SDL_LOG_CATEGORY_RESERVED7, + SDL_LOG_CATEGORY_RESERVED8, + SDL_LOG_CATEGORY_RESERVED9, + SDL_LOG_CATEGORY_RESERVED10, + + /* Beyond this point is reserved for application use, e.g. + enum { + MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, + MYAPP_CATEGORY_AWESOME2, + MYAPP_CATEGORY_AWESOME3, + ... + }; + */ + SDL_LOG_CATEGORY_CUSTOM +}; + +/** + * \brief The predefined log priorities + */ +typedef enum +{ + SDL_LOG_PRIORITY_VERBOSE = 1, + SDL_LOG_PRIORITY_DEBUG, + SDL_LOG_PRIORITY_INFO, + SDL_LOG_PRIORITY_WARN, + SDL_LOG_PRIORITY_ERROR, + SDL_LOG_PRIORITY_CRITICAL, + SDL_NUM_LOG_PRIORITIES +} SDL_LogPriority; + + +/** + * \brief Set the priority of all log categories + */ +extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority); + +/** + * \brief Set the priority of a particular log category + */ +extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category, + SDL_LogPriority priority); + +/** + * \brief Get the priority of a particular log category + */ +extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); + +/** + * \brief Reset all priorities to default. + * + * \note This is called in SDL_Quit(). + */ +extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void); + +/** + * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO + */ +extern DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE + */ +extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_DEBUG + */ +extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_INFO + */ +extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_WARN + */ +extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_ERROR + */ +extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL + */ +extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with the specified category and priority. + */ +extern DECLSPEC void SDLCALL SDL_LogMessage(int category, + SDL_LogPriority priority, + SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3); + +/** + * \brief Log a message with the specified category and priority. + */ +extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, + SDL_LogPriority priority, + const char *fmt, va_list ap); + +/** + * \brief The prototype for the log output function + */ +typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); + +/** + * \brief Get the current log output function. + */ +extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata); + +/** + * \brief This function allows you to replace the default log output + * function with one of your own. + */ +extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_log_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_main.h b/#ThirdParty/libSDL/include/SDL_main.h new file mode 100644 index 0000000..9ce3754 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_main.h @@ -0,0 +1,161 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_main_h +#define _SDL_main_h + +#include "SDL_stdinc.h" + +/** + * \file SDL_main.h + * + * Redefine main() on some platforms so that it is called by SDL. + */ + +#ifndef SDL_MAIN_HANDLED +#if defined(__WIN32__) +/* On Windows SDL provides WinMain(), which parses the command line and passes + the arguments to your main function. + + If you provide your own WinMain(), you may define SDL_MAIN_HANDLED + */ +#define SDL_MAIN_AVAILABLE + +#elif defined(__WINRT__) +/* On WinRT, SDL provides a main function that initializes CoreApplication, + creating an instance of IFrameworkView in the process. + + Please note that #include'ing SDL_main.h is not enough to get a main() + function working. In non-XAML apps, the file, + src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled + into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be + called, with a pointer to the Direct3D-hosted XAML control passed in. +*/ +#define SDL_MAIN_NEEDED + +#elif defined(__IPHONEOS__) +/* On iOS SDL provides a main function that creates an application delegate + and starts the iOS application run loop. + + See src/video/uikit/SDL_uikitappdelegate.m for more details. + */ +#define SDL_MAIN_NEEDED + +#elif defined(__ANDROID__) +/* On Android SDL provides a Java class in SDLActivity.java that is the + main activity entry point. + + See README-android.txt for more details on extending that class. + */ +#define SDL_MAIN_NEEDED + +#elif defined(__NACL__) +/* On NACL we use ppapi_simple to set up the application helper code, + then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before + starting the user main function. + All user code is run in a separate thread by ppapi_simple, thus + allowing for blocking io to take place via nacl_io +*/ +#define SDL_MAIN_NEEDED + +#endif +#endif /* SDL_MAIN_HANDLED */ + +#ifdef __cplusplus +#define C_LINKAGE "C" +#else +#define C_LINKAGE +#endif /* __cplusplus */ + +/** + * \file SDL_main.h + * + * The application's main() function must be called with C linkage, + * and should be declared like this: + * \code + * #ifdef __cplusplus + * extern "C" + * #endif + * int main(int argc, char *argv[]) + * { + * } + * \endcode + */ + +#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) +#define main SDL_main +#endif + +/** + * The prototype for the application's main() function + */ +extern C_LINKAGE int SDL_main(int argc, char *argv[]); + + +#include "begin_code.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This is called by the real SDL main function to let the rest of the + * library know that initialization was done properly. + * + * Calling this yourself without knowing what you're doing can cause + * crashes and hard to diagnose problems with your application. + */ +extern DECLSPEC void SDLCALL SDL_SetMainReady(void); + +#ifdef __WIN32__ + +/** + * This can be called to set the application class at startup + */ +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, + void *hInst); +extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); + +#endif /* __WIN32__ */ + + +#ifdef __WINRT__ + +/** + * \brief Initializes and launches an SDL/WinRT application. + * + * \param mainFunction The SDL app's C-style main(). + * \param reserved Reserved for future use; should be NULL + * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more + * information on the failure. + */ +extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * reserved); + +#endif /* __WINRT__ */ + + +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_main_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_messagebox.h b/#ThirdParty/libSDL/include/SDL_messagebox.h new file mode 100644 index 0000000..ec370db --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_messagebox.h @@ -0,0 +1,144 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_messagebox_h +#define _SDL_messagebox_h + +#include "SDL_stdinc.h" +#include "SDL_video.h" /* For SDL_Window */ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief SDL_MessageBox flags. If supported will display warning icon, etc. + */ +typedef enum +{ + SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */ + SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */ + SDL_MESSAGEBOX_INFORMATION = 0x00000040 /**< informational dialog */ +} SDL_MessageBoxFlags; + +/** + * \brief Flags for SDL_MessageBoxButtonData. + */ +typedef enum +{ + SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */ + SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */ +} SDL_MessageBoxButtonFlags; + +/** + * \brief Individual button data. + */ +typedef struct +{ + Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */ + int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */ + const char * text; /**< The UTF-8 button text */ +} SDL_MessageBoxButtonData; + +/** + * \brief RGB value used in a message box color scheme + */ +typedef struct +{ + Uint8 r, g, b; +} SDL_MessageBoxColor; + +typedef enum +{ + SDL_MESSAGEBOX_COLOR_BACKGROUND, + SDL_MESSAGEBOX_COLOR_TEXT, + SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, + SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, + SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, + SDL_MESSAGEBOX_COLOR_MAX +} SDL_MessageBoxColorType; + +/** + * \brief A set of colors to use for message box dialogs + */ +typedef struct +{ + SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX]; +} SDL_MessageBoxColorScheme; + +/** + * \brief MessageBox structure containing title, text, window, etc. + */ +typedef struct +{ + Uint32 flags; /**< ::SDL_MessageBoxFlags */ + SDL_Window *window; /**< Parent window, can be NULL */ + const char *title; /**< UTF-8 title */ + const char *message; /**< UTF-8 message text */ + + int numbuttons; + const SDL_MessageBoxButtonData *buttons; + + const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */ +} SDL_MessageBoxData; + +/** + * \brief Create a modal message box. + * + * \param messageboxdata The SDL_MessageBoxData structure with title, text, etc. + * \param buttonid The pointer to which user id of hit button should be copied. + * + * \return -1 on error, otherwise 0 and buttonid contains user id of button + * hit or -1 if dialog was closed. + * + * \note This function should be called on the thread that created the parent + * window, or on the main thread if the messagebox has no parent. It will + * block execution of that thread until the user clicks a button or + * closes the messagebox. + */ +extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); + +/** + * \brief Create a simple modal message box + * + * \param flags ::SDL_MessageBoxFlags + * \param title UTF-8 title text + * \param message UTF-8 message text + * \param window The parent window, or NULL for no parent + * + * \return 0 on success, -1 on error + * + * \sa SDL_ShowMessageBox + */ +extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_messagebox_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_mouse.h b/#ThirdParty/libSDL/include/SDL_mouse.h new file mode 100644 index 0000000..ea9622f --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_mouse.h @@ -0,0 +1,300 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_mouse.h + * + * Include file for SDL mouse event handling. + */ + +#ifndef _SDL_mouse_h +#define _SDL_mouse_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */ + +/** + * \brief Cursor types for SDL_CreateSystemCursor. + */ +typedef enum +{ + SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */ + SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */ + SDL_SYSTEM_CURSOR_WAIT, /**< Wait */ + SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */ + SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */ + SDL_SYSTEM_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */ + SDL_SYSTEM_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */ + SDL_SYSTEM_CURSOR_SIZEWE, /**< Double arrow pointing west and east */ + SDL_SYSTEM_CURSOR_SIZENS, /**< Double arrow pointing north and south */ + SDL_SYSTEM_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */ + SDL_SYSTEM_CURSOR_NO, /**< Slashed circle or crossbones */ + SDL_SYSTEM_CURSOR_HAND, /**< Hand */ + SDL_NUM_SYSTEM_CURSORS +} SDL_SystemCursor; + +/** + * \brief Scroll direction types for the Scroll event + */ +typedef enum +{ + SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */ + SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */ +} SDL_MouseWheelDirection; + +/* Function prototypes */ + +/** + * \brief Get the window which currently has mouse focus. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); + +/** + * \brief Retrieve the current state of the mouse. + * + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse cursor position relative to the focus window for the currently + * selected mouse. You can pass NULL for either x or y. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y); + +/** + * \brief Get the current state of the mouse, in relation to the desktop + * + * This works just like SDL_GetMouseState(), but the coordinates will be + * reported relative to the top-left of the desktop. This can be useful if + * you need to track the mouse outside of a specific window and + * SDL_CaptureMouse() doesn't fit your needs. For example, it could be + * useful if you need to track the mouse while dragging a window, where + * coordinates relative to a window might not be in sync at all times. + * + * \note SDL_GetMouseState() returns the mouse position as SDL understands + * it from the last pump of the event queue. This function, however, + * queries the OS for the current mouse position, and as such, might + * be a slightly less efficient function. Unless you know what you're + * doing and have a good reason to use this function, you probably want + * SDL_GetMouseState() instead. + * + * \param x Returns the current X coord, relative to the desktop. Can be NULL. + * \param y Returns the current Y coord, relative to the desktop. Can be NULL. + * \return The current button state as a bitmask, which can be tested using the SDL_BUTTON(X) macros. + * + * \sa SDL_GetMouseState + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetGlobalMouseState(int *x, int *y); + +/** + * \brief Retrieve the relative state of the mouse. + * + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse deltas since the last call to SDL_GetRelativeMouseState(). + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); + +/** + * \brief Moves the mouse to the given position within the window. + * + * \param window The window to move the mouse into, or NULL for the current mouse focus + * \param x The x coordinate within the window + * \param y The y coordinate within the window + * + * \note This function generates a mouse motion event + */ +extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, + int x, int y); + +/** + * \brief Moves the mouse to the given position in global screen space. + * + * \param x The x coordinate + * \param y The y coordinate + * \return 0 on success, -1 on error (usually: unsupported by a platform). + * + * \note This function generates a mouse motion event + */ +extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y); + +/** + * \brief Set relative mouse mode. + * + * \param enabled Whether or not to enable relative mode + * + * \return 0 on success, or -1 if relative mode is not supported. + * + * While the mouse is in relative mode, the cursor is hidden, and the + * driver will try to report continuous motion in the current window. + * Only relative motion events will be delivered, the mouse position + * will not change. + * + * \note This function will flush any pending mouse motion. + * + * \sa SDL_GetRelativeMouseMode() + */ +extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); + +/** + * \brief Capture the mouse, to track input outside an SDL window. + * + * \param enabled Whether or not to enable capturing + * + * Capturing enables your app to obtain mouse events globally, instead of + * just within your window. Not all video targets support this function. + * When capturing is enabled, the current window will get all mouse events, + * but unlike relative mode, no change is made to the cursor and it is + * not restrained to your window. + * + * This function may also deny mouse input to other windows--both those in + * your application and others on the system--so you should use this + * function sparingly, and in small bursts. For example, you might want to + * track the mouse while the user is dragging something, until the user + * releases a mouse button. It is not recommended that you capture the mouse + * for long periods of time, such as the entire time your app is running. + * + * While captured, mouse events still report coordinates relative to the + * current (foreground) window, but those coordinates may be outside the + * bounds of the window (including negative values). Capturing is only + * allowed for the foreground window. If the window loses focus while + * capturing, the capture will be disabled automatically. + * + * While capturing is enabled, the current window will have the + * SDL_WINDOW_MOUSE_CAPTURE flag set. + * + * \return 0 on success, or -1 if not supported. + */ +extern DECLSPEC int SDLCALL SDL_CaptureMouse(SDL_bool enabled); + +/** + * \brief Query whether relative mouse mode is enabled. + * + * \sa SDL_SetRelativeMouseMode() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); + +/** + * \brief Create a cursor, using the specified bitmap data and + * mask (in MSB format). + * + * The cursor width must be a multiple of 8 bits. + * + * The cursor is created in black and white according to the following: + * + * + * + * + * + * + *
data mask resulting pixel on screen
0 1 White
1 1 Black
0 0 Transparent
1 0 Inverted color if possible, black + * if not.
+ * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, + const Uint8 * mask, + int w, int h, int hot_x, + int hot_y); + +/** + * \brief Create a color cursor. + * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, + int hot_x, + int hot_y); + +/** + * \brief Create a system cursor. + * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id); + +/** + * \brief Set the active cursor. + */ +extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor); + +/** + * \brief Return the active cursor. + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); + +/** + * \brief Return the default cursor. + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void); + +/** + * \brief Frees a cursor created with SDL_CreateCursor(). + * + * \sa SDL_CreateCursor() + */ +extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); + +/** + * \brief Toggle whether or not the cursor is shown. + * + * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current + * state. + * + * \return 1 if the cursor is shown, or 0 if the cursor is hidden. + */ +extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); + +/** + * Used as a mask when testing buttons in buttonstate. + * - Button 1: Left mouse button + * - Button 2: Middle mouse button + * - Button 3: Right mouse button + */ +#define SDL_BUTTON(X) (1 << ((X)-1)) +#define SDL_BUTTON_LEFT 1 +#define SDL_BUTTON_MIDDLE 2 +#define SDL_BUTTON_RIGHT 3 +#define SDL_BUTTON_X1 4 +#define SDL_BUTTON_X2 5 +#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) +#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) +#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) +#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) +#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_mutex.h b/#ThirdParty/libSDL/include/SDL_mutex.h new file mode 100644 index 0000000..b7e3973 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_mutex.h @@ -0,0 +1,251 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_mutex_h +#define _SDL_mutex_h + +/** + * \file SDL_mutex.h + * + * Functions to provide thread synchronization primitives. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Synchronization functions which can time out return this value + * if they time out. + */ +#define SDL_MUTEX_TIMEDOUT 1 + +/** + * This is the timeout value which corresponds to never time out. + */ +#define SDL_MUTEX_MAXWAIT (~(Uint32)0) + + +/** + * \name Mutex functions + */ +/* @{ */ + +/* The SDL mutex structure, defined in SDL_sysmutex.c */ +struct SDL_mutex; +typedef struct SDL_mutex SDL_mutex; + +/** + * Create a mutex, initialized unlocked. + */ +extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); + +/** + * Lock the mutex. + * + * \return 0, or -1 on error. + */ +#define SDL_mutexP(m) SDL_LockMutex(m) +extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); + +/** + * Try to lock the mutex + * + * \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); + +/** + * Unlock the mutex. + * + * \return 0, or -1 on error. + * + * \warning It is an error to unlock a mutex that has not been locked by + * the current thread, and doing so results in undefined behavior. + */ +#define SDL_mutexV(m) SDL_UnlockMutex(m) +extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); + +/** + * Destroy a mutex. + */ +extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); + +/* @} *//* Mutex functions */ + + +/** + * \name Semaphore functions + */ +/* @{ */ + +/* The SDL semaphore structure, defined in SDL_syssem.c */ +struct SDL_semaphore; +typedef struct SDL_semaphore SDL_sem; + +/** + * Create a semaphore, initialized with value, returns NULL on failure. + */ +extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); + +/** + * Destroy a semaphore. + */ +extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem); + +/** + * This function suspends the calling thread until the semaphore pointed + * to by \c sem has a positive count. It then atomically decreases the + * semaphore count. + */ +extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem); + +/** + * Non-blocking variant of SDL_SemWait(). + * + * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would + * block, and -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); + +/** + * Variant of SDL_SemWait() with a timeout in milliseconds. + * + * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not + * succeed in the allotted time, and -1 on error. + * + * \warning On some platforms this function is implemented by looping with a + * delay of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); + +/** + * Atomically increases the semaphore's count (not blocking). + * + * \return 0, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); + +/** + * Returns the current count of the semaphore. + */ +extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); + +/* @} *//* Semaphore functions */ + + +/** + * \name Condition variable functions + */ +/* @{ */ + +/* The SDL condition variable structure, defined in SDL_syscond.c */ +struct SDL_cond; +typedef struct SDL_cond SDL_cond; + +/** + * Create a condition variable. + * + * Typical use of condition variables: + * + * Thread A: + * SDL_LockMutex(lock); + * while ( ! condition ) { + * SDL_CondWait(cond, lock); + * } + * SDL_UnlockMutex(lock); + * + * Thread B: + * SDL_LockMutex(lock); + * ... + * condition = true; + * ... + * SDL_CondSignal(cond); + * SDL_UnlockMutex(lock); + * + * There is some discussion whether to signal the condition variable + * with the mutex locked or not. There is some potential performance + * benefit to unlocking first on some platforms, but there are some + * potential race conditions depending on how your code is structured. + * + * In general it's safer to signal the condition variable while the + * mutex is locked. + */ +extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); + +/** + * Destroy a condition variable. + */ +extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond); + +/** + * Restart one of the threads that are waiting on the condition variable. + * + * \return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); + +/** + * Restart all threads that are waiting on the condition variable. + * + * \return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); + +/** + * Wait on the condition variable, unlocking the provided mutex. + * + * \warning The mutex must be locked before entering this function! + * + * The mutex is re-locked once the condition variable is signaled. + * + * \return 0 when it is signaled, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); + +/** + * Waits for at most \c ms milliseconds, and returns 0 if the condition + * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not + * signaled in the allotted time, and -1 on error. + * + * \warning On some platforms this function is implemented by looping with a + * delay of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, + SDL_mutex * mutex, Uint32 ms); + +/* @} *//* Condition variable functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mutex_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_name.h b/#ThirdParty/libSDL/include/SDL_name.h new file mode 100644 index 0000000..06cd4a5 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_name.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDLname_h_ +#define _SDLname_h_ + +#if defined(__STDC__) || defined(__cplusplus) +#define NeedFunctionPrototypes 1 +#endif + +#define SDL_NAME(X) SDL_##X + +#endif /* _SDLname_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_opengl.h b/#ThirdParty/libSDL/include/SDL_opengl.h new file mode 100644 index 0000000..780919b --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_opengl.h @@ -0,0 +1,2176 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_opengl.h + * + * This is a simple file to encapsulate the OpenGL API headers. + */ + +/** + * \def NO_SDL_GLEXT + * + * Define this if you have your own version of glext.h and want to disable the + * version included in SDL_opengl.h. + */ + +#ifndef _SDL_opengl_h +#define _SDL_opengl_h + +#include "SDL_config.h" + +#ifndef __IPHONEOS__ /* No OpenGL on iOS. */ + +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef __gl_h_ +#define __gl_h_ + +#if defined(USE_MGL_NAMESPACE) +#include "gl_mangle.h" +#endif + + +/********************************************************************** + * Begin system-specific stuff. + */ + +#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) +#define __WIN32__ +#endif + +#if defined(__WIN32__) && !defined(__CYGWIN__) +# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define GLAPI __declspec(dllexport) +# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define GLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define GLAPI extern +# endif /* _STATIC_MESA support */ +# if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ +# define GLAPIENTRY +# else +# define GLAPIENTRY __stdcall +# endif +#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ +# define GLAPI extern +# define GLAPIENTRY __stdcall +#elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define GLAPI __attribute__((visibility("default"))) +# define GLAPIENTRY +#endif /* WIN32 && !CYGWIN */ + +/* + * WINDOWS: Include windows.h here to define APIENTRY. + * It is also useful when applications include this file by + * including only glut.h, since glut.h depends on windows.h. + * Applications needing to include windows.h with parms other + * than "WIN32_LEAN_AND_MEAN" may include windows.h before + * glut.h or gl.h. + */ +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#ifndef NOMINMAX /* don't define min() and max(). */ +#define NOMINMAX +#endif +#include +#endif + +#ifndef GLAPI +#define GLAPI extern +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY +#endif + +#ifndef APIENTRY +#define APIENTRY GLAPIENTRY +#endif + +/* "P" suffix to be used for a pointer to a function */ +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif + +#ifndef GLAPIENTRYP +#define GLAPIENTRYP GLAPIENTRY * +#endif + +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export on +#endif + +/* + * End system-specific stuff. + **********************************************************************/ + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define GL_VERSION_1_1 1 +#define GL_VERSION_1_2 1 +#define GL_VERSION_1_3 1 +#define GL_ARB_imaging 1 + + +/* + * Datatypes + */ +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef void GLvoid; +typedef signed char GLbyte; /* 1-byte signed */ +typedef short GLshort; /* 2-byte signed */ +typedef int GLint; /* 4-byte signed */ +typedef unsigned char GLubyte; /* 1-byte unsigned */ +typedef unsigned short GLushort; /* 2-byte unsigned */ +typedef unsigned int GLuint; /* 4-byte unsigned */ +typedef int GLsizei; /* 4-byte signed */ +typedef float GLfloat; /* single precision float */ +typedef float GLclampf; /* single precision float in [0,1] */ +typedef double GLdouble; /* double precision float */ +typedef double GLclampd; /* double precision float in [0,1] */ + + + +/* + * Constants + */ + +/* Boolean values */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* Data types */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A + +/* Primitives */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 + +/* Vertex Arrays */ +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D + +/* Matrix Mode */ +#define GL_MATRIX_MODE 0x0BA0 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +/* Points */ +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_POINT_SIZE_RANGE 0x0B12 + +/* Lines */ +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_WIDTH_RANGE 0x0B22 + +/* Polygons */ +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 + +/* Display Lists */ +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_LIST_MODE 0x0B30 + +/* Depth buffer */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_BITS 0x0D56 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_COMPONENT 0x1902 + +/* Lighting */ +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_SHININESS 0x1601 +#define GL_EMISSION 0x1600 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_SHADE_MODEL 0x0B54 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_NORMALIZE 0x0BA1 + +/* User clipping planes */ +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 + +/* Accumulation buffer */ +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_ACCUM 0x0100 +#define GL_ADD 0x0104 +#define GL_LOAD 0x0101 +#define GL_MULT 0x0103 +#define GL_RETURN 0x0102 + +/* Alpha testing */ +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_ALPHA_TEST_FUNC 0x0BC1 + +/* Blending */ +#define GL_BLEND 0x0BE2 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND_DST 0x0BE0 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 + +/* Render Mode */ +#define GL_FEEDBACK 0x1C01 +#define GL_RENDER 0x1C00 +#define GL_SELECT 0x1C02 + +/* Feedback */ +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 + +/* Selection */ +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 + +/* Fog */ +#define GL_FOG 0x0B60 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_COLOR 0x0B66 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_LINEAR 0x2601 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 + +/* Logic Ops */ +#define GL_LOGIC_OP 0x0BF1 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_CLEAR 0x1500 +#define GL_SET 0x150F +#define GL_COPY 0x1503 +#define GL_COPY_INVERTED 0x150C +#define GL_NOOP 0x1505 +#define GL_INVERT 0x150A +#define GL_AND 0x1501 +#define GL_NAND 0x150E +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_XOR 0x1506 +#define GL_EQUIV 0x1509 +#define GL_AND_REVERSE 0x1502 +#define GL_AND_INVERTED 0x1504 +#define GL_OR_REVERSE 0x150B +#define GL_OR_INVERTED 0x150D + +/* Stencil */ +#define GL_STENCIL_BITS 0x0D57 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_INDEX 0x1901 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 + +/* Buffers, Pixel Drawing/Reading */ +#define GL_NONE 0 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +/*GL_FRONT 0x0404 */ +/*GL_BACK 0x0405 */ +/*GL_FRONT_AND_BACK 0x0408 */ +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_COLOR_INDEX 0x1900 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_ALPHA_BITS 0x0D55 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_INDEX_BITS 0x0D51 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_READ_BUFFER 0x0C02 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_BITMAP 0x1A00 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_DITHER 0x0BD0 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 + +/* Implementation limits */ +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B + +/* Gets */ +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_MODE 0x0C30 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_RENDER_MODE 0x0C40 +#define GL_RGBA_MODE 0x0C31 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_VIEWPORT 0x0BA2 + +/* Evaluators */ +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 + +/* Hints */ +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* Scissor box */ +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 + +/* Pixel Mode / Transfer */ +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 + +/* Texture mapping */ +#define GL_TEXTURE_ENV 0x2300 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_BORDER 0x1005 +#define GL_TEXTURE_COMPONENTS 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_LINEAR 0x2400 +#define GL_EYE_PLANE 0x2502 +#define GL_SPHERE_MAP 0x2402 +#define GL_DECAL 0x2101 +#define GL_MODULATE 0x2100 +#define GL_NEAREST 0x2600 +#define GL_REPEAT 0x2901 +#define GL_CLAMP 0x2900 +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 + +/* Utility */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* Errors */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 + +/* glPush/PopAttrib bits */ +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0x000FFFFF + + +/* OpenGL 1.1 */ +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF +#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF + + + +/* + * Miscellaneous + */ + +GLAPI void GLAPIENTRY glClearIndex( GLfloat c ); + +GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glClear( GLbitfield mask ); + +GLAPI void GLAPIENTRY glIndexMask( GLuint mask ); + +GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); + +GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref ); + +GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); + +GLAPI void GLAPIENTRY glLogicOp( GLenum opcode ); + +GLAPI void GLAPIENTRY glCullFace( GLenum mode ); + +GLAPI void GLAPIENTRY glFrontFace( GLenum mode ); + +GLAPI void GLAPIENTRY glPointSize( GLfloat size ); + +GLAPI void GLAPIENTRY glLineWidth( GLfloat width ); + +GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern ); + +GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode ); + +GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); + +GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask ); + +GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask ); + +GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag ); + +GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag ); + +GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); + +GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); + +GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); + +GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glReadBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glEnable( GLenum cap ); + +GLAPI void GLAPIENTRY glDisable( GLenum cap ); + +GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap ); + + +GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */ + +GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */ + + +GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); + +GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params ); + +GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params ); + +GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask ); + +GLAPI void GLAPIENTRY glPopAttrib( void ); + + +GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */ + +GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */ + + +GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); + +GLAPI GLenum GLAPIENTRY glGetError( void ); + +GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name ); + +GLAPI void GLAPIENTRY glFinish( void ); + +GLAPI void GLAPIENTRY glFlush( void ); + +GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode ); + + +/* + * Depth Buffer + */ + +GLAPI void GLAPIENTRY glClearDepth( GLclampd depth ); + +GLAPI void GLAPIENTRY glDepthFunc( GLenum func ); + +GLAPI void GLAPIENTRY glDepthMask( GLboolean flag ); + +GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val ); + + +/* + * Accumulation Buffer + */ + +GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); + +GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value ); + + +/* + * Transformation + */ + +GLAPI void GLAPIENTRY glMatrixMode( GLenum mode ); + +GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glViewport( GLint x, GLint y, + GLsizei width, GLsizei height ); + +GLAPI void GLAPIENTRY glPushMatrix( void ); + +GLAPI void GLAPIENTRY glPopMatrix( void ); + +GLAPI void GLAPIENTRY glLoadIdentity( void ); + +GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glRotated( GLdouble angle, + GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRotatef( GLfloat angle, + GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); + + +/* + * Display Lists + */ + +GLAPI GLboolean GLAPIENTRY glIsList( GLuint list ); + +GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range ); + +GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range ); + +GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode ); + +GLAPI void GLAPIENTRY glEndList( void ); + +GLAPI void GLAPIENTRY glCallList( GLuint list ); + +GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type, + const GLvoid *lists ); + +GLAPI void GLAPIENTRY glListBase( GLuint base ); + + +/* + * Drawing Functions + */ + +GLAPI void GLAPIENTRY glBegin( GLenum mode ); + +GLAPI void GLAPIENTRY glEnd( void ); + + +GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex2iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex3iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex4iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); +GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); +GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); +GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); +GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); + +GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glNormal3iv( const GLint *v ); +GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glIndexd( GLdouble c ); +GLAPI void GLAPIENTRY glIndexf( GLfloat c ); +GLAPI void GLAPIENTRY glIndexi( GLint c ); +GLAPI void GLAPIENTRY glIndexs( GLshort c ); +GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c ); +GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c ); +GLAPI void GLAPIENTRY glIndexiv( const GLint *c ); +GLAPI void GLAPIENTRY glIndexsv( const GLshort *c ); +GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); +GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); +GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); +GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue ); +GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); +GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); +GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); +GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); + +GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green, + GLbyte blue, GLbyte alpha ); +GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green, + GLdouble blue, GLdouble alpha ); +GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ); +GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green, + GLint blue, GLint alpha ); +GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green, + GLshort blue, GLshort alpha ); +GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); +GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green, + GLuint blue, GLuint alpha ); +GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green, + GLushort blue, GLushort alpha ); + + +GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor3iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor3sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor3usv( const GLushort *v ); + +GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor4iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor4sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor4usv( const GLushort *v ); + + +GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s ); +GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s ); +GLAPI void GLAPIENTRY glTexCoord1i( GLint s ); +GLAPI void GLAPIENTRY glTexCoord1s( GLshort s ); + +GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t ); +GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t ); +GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t ); +GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); +GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); +GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); +GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); +GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); +GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); +GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); +GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); +GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); +GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); + + +GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); +GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); +GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 ); +GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); + + +/* + * Vertex Arrays (1.1) + */ + +GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params ); + +GLAPI void GLAPIENTRY glArrayElement( GLint i ); + +GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); + +GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride, + const GLvoid *pointer ); + +/* + * Lighting + */ + +GLAPI void GLAPIENTRY glShadeModel( GLenum mode ); + +GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname, + GLfloat *params ); +GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode ); + + +/* + * Raster functions + */ + +GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); + +GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize, + const GLfloat *values ); +GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize, + const GLuint *values ); +GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize, + const GLushort *values ); + +GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); +GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); +GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); + +GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ); + +GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid *pixels ); + +GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type ); + +/* + * Stenciling + */ + +GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); + +GLAPI void GLAPIENTRY glStencilMask( GLuint mask ); + +GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); + +GLAPI void GLAPIENTRY glClearStencil( GLint s ); + + + +/* + * Texture mapping + */ + +GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); +GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); +GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); +GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target, + GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target, + GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid *pixels ); + + +/* 1.1 functions */ + +GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures ); + +GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); + +GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture ); + +GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n, + const GLuint *textures, + const GLclampf *priorities ); + +GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n, + const GLuint *textures, + GLboolean *residences ); + +GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture ); + + +GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level, + GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + + +/* + * Evaluators + */ + +GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, + GLint stride, + GLint order, const GLdouble *points ); +GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, + GLint stride, + GLint order, const GLfloat *points ); + +GLAPI void GLAPIENTRY glMap2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ); +GLAPI void GLAPIENTRY glMap2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ); + +GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); +GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); +GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); + +GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u ); +GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u ); + +GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); +GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); + +GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); +GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); + +GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ); +GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ); + +GLAPI void GLAPIENTRY glEvalPoint1( GLint i ); + +GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j ); + +GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); + +GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + + +/* + * Fog + */ + +GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param ); + +GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params ); + +GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params ); + + +/* + * Selection and Feedback + */ + +GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); + +GLAPI void GLAPIENTRY glPassThrough( GLfloat token ); + +GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); + +GLAPI void GLAPIENTRY glInitNames( void ); + +GLAPI void GLAPIENTRY glLoadName( GLuint name ); + +GLAPI void GLAPIENTRY glPushName( GLuint name ); + +GLAPI void GLAPIENTRY glPopName( void ); + + + +/* + * OpenGL 1.2 + */ + +#define GL_RESCALE_NORMAL 0x803A +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_TEXTURE_BINDING_3D 0x806A + +GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start, + GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels); + +GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height ); + +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + + +/* + * GL_ARB_imaging + */ + +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_BLEND_EQUATION 0x8009 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_COLOR 0x8005 + + +GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, + GLenum type, const GLvoid *table ); + +GLAPI void GLAPIENTRY glColorSubTable( GLenum target, + GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *data ); + +GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname, + const GLint *params); + +GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params); + +GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *table ); + +GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glBlendEquation( GLenum mode ); + +GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width, + GLenum internalformat, GLboolean sink ); + +GLAPI void GLAPIENTRY glResetHistogram( GLenum target ); + +GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset, + GLenum format, GLenum type, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat, + GLboolean sink ); + +GLAPI void GLAPIENTRY glResetMinmax( GLenum target ); + +GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset, + GLenum format, GLenum types, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target, + GLenum internalformat, GLsizei width, GLenum format, GLenum type, + const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname, + GLfloat params ); + +GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); + +GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname, + GLint params ); + +GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width, + GLsizei height); + +GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format, + GLenum type, GLvoid *image ); + +GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column ); + +GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, + GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); + + + + +/* + * OpenGL 1.3 + */ + +/* multitexture */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +/* texture_cube_map */ +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +/* texture_compression */ +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +/* multisample */ +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +/* transpose_matrix */ +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +/* texture_env_combine */ +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +/* texture_env_dot3 */ +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +/* texture_border_clamp */ +#define GL_CLAMP_TO_BORDER 0x812D + +GLAPI void GLAPIENTRY glActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img ); + +GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v ); + + +GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble m[16] ); + +GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat m[16] ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble m[16] ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] ); + +GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert ); + + +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); + + + +/* + * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) + */ +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + +GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s); +GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s); +GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s); +GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s); +GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); +GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); +GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); +GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); +GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); +GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); + +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +#endif /* GL_ARB_multitexture */ + + + +/* + * Define this token if you want "old-style" header file behaviour (extensions + * defined in gl.h). Otherwise, extensions will be included from glext.h. + */ +#if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY) +#include "SDL_opengl_glext.h" +#endif /* GL_GLEXT_LEGACY */ + + + +/* + * ???. GL_MESA_packed_depth_stencil + * XXX obsolete + */ +#ifndef GL_MESA_packed_depth_stencil +#define GL_MESA_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_MESA 0x8750 +#define GL_UNSIGNED_INT_24_8_MESA 0x8751 +#define GL_UNSIGNED_INT_8_24_REV_MESA 0x8752 +#define GL_UNSIGNED_SHORT_15_1_MESA 0x8753 +#define GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754 + +#endif /* GL_MESA_packed_depth_stencil */ + + +#ifndef GL_ATI_blend_equation_separate +#define GL_ATI_blend_equation_separate 1 + +#define GL_ALPHA_BLEND_EQUATION_ATI 0x883D + +GLAPI void GLAPIENTRY glBlendEquationSeparateATI( GLenum modeRGB, GLenum modeA ); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLenum modeA); + +#endif /* GL_ATI_blend_equation_separate */ + + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +typedef void* GLeglImageOES; +#endif + +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GLAPI void APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#endif + + +/** + ** NOTE!!!!! If you add new functions to this file, or update + ** glext.h be sure to regenerate the gl_mangle.h file. See comments + ** in that file for details. + **/ + + + +/********************************************************************** + * Begin system-specific stuff + */ +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export off +#endif + +/* + * End system-specific stuff + **********************************************************************/ + + +#ifdef __cplusplus +} +#endif + +#endif /* __gl_h_ */ + +#endif /* !__IPHONEOS__ */ + +#endif /* _SDL_opengl_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_opengl_glext.h b/#ThirdParty/libSDL/include/SDL_opengl_glext.h new file mode 100644 index 0000000..cd3869f --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_opengl_glext.h @@ -0,0 +1,11177 @@ +#ifndef __glext_h_ +#define __glext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 26745 $ on $Date: 2014-05-21 03:12:26 -0700 (Wed, 21 May 2014) $ +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +#define GL_GLEXT_VERSION 20140521 + +/* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_2 */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#include +#ifdef __MACOSX__ +typedef long GLsizeiptr; +typedef long GLintptr; +#else +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; +#endif +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +typedef unsigned short GLhalf; +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +typedef struct __GLsync *GLsync; +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif +typedef uint64_t GLuint64; +typedef int64_t GLint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_DISPLAY_LIST 0x82E7 +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_VERSION_4_4 +#define GL_VERSION_4_4 1 +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLEAR_TEXTURE 0x9365 +#define GL_LOCATION_COMPONENT 0x934A +#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B +#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C +#define GL_QUERY_BUFFER 0x9192 +#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#define GL_QUERY_BUFFER_BINDING 0x9193 +#define GL_QUERY_RESULT_NO_WAIT 0x9194 +#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 +typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); +GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#endif +#endif /* GL_VERSION_4_4 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_bindless_texture +#define GL_ARB_bindless_texture 1 +typedef uint64_t GLuint64EXT; +#define GL_UNSIGNED_INT64_ARB 0x140F +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_ARB_bindless_texture */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +#endif /* GL_ARB_buffer_storage */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +struct _cl_context; +struct _cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#endif +#endif /* GL_ARB_cl_event */ + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#endif /* GL_ARB_clear_buffer_object */ + +#ifndef GL_ARB_clear_texture +#define GL_ARB_clear_texture 1 +#endif /* GL_ARB_clear_texture */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif +#endif /* GL_ARB_color_buffer_float */ + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_compute_variable_group_size +#define GL_ARB_compute_variable_group_size 1 +#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 +#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB +#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 +#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#endif +#endif /* GL_ARB_compute_variable_group_size */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif /* GL_ARB_depth_texture */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ARB_draw_buffers */ + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif /* GL_ARB_draw_buffers_blend */ + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_ARB_draw_instanced */ + +#ifndef GL_ARB_enhanced_layouts +#define GL_ARB_enhanced_layouts 1 +#endif /* GL_ARB_enhanced_layouts */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif +#endif /* GL_ARB_fragment_program */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_KHR_context_flush_control +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_ARB_geometry_shader4 */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +typedef unsigned short GLhalfARB; +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif +#endif /* GL_ARB_imaging */ + +#ifndef GL_ARB_indirect_parameters +#define GL_ARB_indirect_parameters 1 +#define GL_PARAMETER_BUFFER_ARB 0x80EE +#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_ARB_indirect_parameters */ + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif +#endif /* GL_ARB_instanced_arrays */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_ARB_matrix_palette */ + +#ifndef GL_ARB_multi_bind +#define GL_ARB_multi_bind 1 +#endif /* GL_ARB_multi_bind */ + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); +#endif +#endif /* GL_ARB_multisample */ + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif +#endif /* GL_ARB_multitexture */ + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_ARB_occlusion_query */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_ARB_point_parameters */ + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_query_buffer_object +#define GL_ARB_query_buffer_object 1 +#endif /* GL_ARB_query_buffer_object */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif +#endif /* GL_ARB_sample_shading */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_seamless_cubemap_per_texture +#define GL_ARB_seamless_cubemap_per_texture 1 +#endif /* GL_ARB_seamless_cubemap_per_texture */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_draw_parameters +#define GL_ARB_shader_draw_parameters 1 +#endif /* GL_ARB_shader_draw_parameters */ + +#ifndef GL_ARB_shader_group_vote +#define GL_ARB_shader_group_vote 1 +#endif /* GL_ARB_shader_group_vote */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif +typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif +#endif /* GL_ARB_shader_objects */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_shading_language_include */ + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ + +#ifndef GL_ARB_sparse_texture +#define GL_ARB_sparse_texture 1 +#define GL_TEXTURE_SPARSE_ARB 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 +#define GL_MIN_SPARSE_LEVEL_ARB 0x919B +#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +#endif +#endif /* GL_ARB_sparse_texture */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_ARB_texture_buffer_object */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); +#endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirror_clamp_to_edge +#define GL_ARB_texture_mirror_clamp_to_edge 1 +#endif /* GL_ARB_texture_mirror_clamp_to_edge */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_stencil8 +#define GL_ARB_texture_stencil8 1 +#endif /* GL_ARB_texture_stencil8 */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif +#endif /* GL_ARB_transpose_matrix */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif +#endif /* GL_ARB_vertex_blend */ + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef __MACOSX__ /* The OS X headers haven't caught up with Khronos yet */ +typedef long GLsizeiptrARB; +typedef long GLintptrARB; +#else +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; +#endif +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_ARB_vertex_buffer_object */ + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); +#endif +#endif /* GL_ARB_vertex_program */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif +#endif /* GL_ARB_vertex_shader */ + +#ifndef GL_ARB_vertex_type_10f_11f_11f_rev +#define GL_ARB_vertex_type_10f_11f_11f_rev 1 +#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +typedef GLint GLfixed; +#define GL_FIXED_OES 0x140C +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); +GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#endif +#endif /* GL_OES_single_precision */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif +#endif /* GL_3DFX_tbuffer */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif +#endif /* GL_AMD_debug_output */ + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_AMD_draw_buffers_blend */ + +#ifndef GL_AMD_gcn_shader +#define GL_AMD_gcn_shader 1 +#endif /* GL_AMD_gcn_shader */ + +#ifndef GL_AMD_gpu_shader_int64 +#define GL_AMD_gpu_shader_int64 1 +typedef int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_AMD_gpu_shader_int64 */ + +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 +typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); +#endif +#endif /* GL_AMD_interleaved_elements */ + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#endif +#endif /* GL_AMD_multi_draw_indirect */ + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif +#endif /* GL_AMD_name_gen_delete */ + +#ifndef GL_AMD_occlusion_query_event +#define GL_AMD_occlusion_query_event 1 +#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F +#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 +#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 +#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 +#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 +#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); +#endif +#endif /* GL_AMD_occlusion_query_event */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif +#endif /* GL_AMD_sample_positions */ + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifndef GL_AMD_shader_atomic_counter_ops +#define GL_AMD_shader_atomic_counter_ops 1 +#endif /* GL_AMD_shader_atomic_counter_ops */ + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif +#endif /* GL_AMD_stencil_operation_extended */ + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ + +#ifndef GL_AMD_transform_feedback4 +#define GL_AMD_transform_feedback4 1 +#define GL_STREAM_RASTERIZATION_AMD 0x91A0 +#endif /* GL_AMD_transform_feedback4 */ + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif +#endif /* GL_AMD_vertex_shader_tessellator */ + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif +#endif /* GL_APPLE_element_array */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif +#endif /* GL_APPLE_fence */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_APPLE_flush_buffer_range */ + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif +#endif /* GL_APPLE_object_purgeable */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_APPLE_texture_range */ + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif +#endif /* GL_APPLE_vertex_array_object */ + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif +#endif /* GL_APPLE_vertex_array_range */ + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif +#endif /* GL_APPLE_vertex_program_evaluators */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ATI_draw_buffers */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif +#endif /* GL_ATI_element_array */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif +#endif /* GL_ATI_envmap_bumpmap */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif +#endif /* GL_ATI_fragment_shader */ + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif +#endif /* GL_ATI_map_object_buffer */ + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_pn_triangles */ + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif +#endif /* GL_ATI_separate_stencil */ + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_array_object */ + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_attrib_array_object */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_vertex_streams */ + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif +#endif /* GL_EXT_bindable_uniform */ + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif +#endif /* GL_EXT_blend_color */ + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_EXT_blend_equation_separate */ + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_EXT_blend_func_separate */ + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif +#endif /* GL_EXT_color_subtable */ + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif +#endif /* GL_EXT_compiled_vertex_array */ + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#endif +#endif /* GL_EXT_convolution */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_coordinate_frame */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_copy_texture */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#endif +#endif /* GL_EXT_draw_buffers2 */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#endif +#endif /* GL_EXT_draw_range_elements */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_framebuffer_multisample */ + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif +#endif /* GL_EXT_geometry_shader4 */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif +#endif /* GL_EXT_index_func */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_index_material */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif /* GL_EXT_misc_attribute */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_paletted_texture */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_pixel_transform */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_EXT_point_parameters */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif +#endif /* GL_EXT_polygon_offset */ + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ + +#ifndef GL_EXT_shader_image_load_formatted +#define GL_EXT_shader_image_load_formatted 1 +#endif /* GL_EXT_shader_image_load_formatted */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif +#endif /* GL_EXT_shader_image_load_store */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif +#endif /* GL_EXT_stencil_clear_tag */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif +#endif /* GL_EXT_stencil_two_side */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_subtexture */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif +#endif /* GL_EXT_texture_integer */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif +#endif /* GL_EXT_texture_object */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#define GL_TIME_ELAPSED_EXT 0x88BF +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif +#endif /* GL_EXT_transform_feedback */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_vertex_weighting */ + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif +#endif /* GL_EXT_x11_sync_object */ + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif +#endif /* GL_GREMEDY_frame_terminator */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); +#endif +#endif /* GL_GREMEDY_string_marker */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_HP_image_transform */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#endif +#endif /* GL_IBM_multimode_draw_arrays */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#endif +#endif /* GL_IBM_vertex_array_lists */ + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_INGR_blend_func_separate */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ + +#ifndef GL_INTEL_fragment_shader_ordering +#define GL_INTEL_fragment_shader_ordering 1 +#endif /* GL_INTEL_fragment_shader_ordering */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#endif +#endif /* GL_INTEL_map_texture */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NVX_gpu_memory_info +#define GL_NVX_gpu_memory_info 1 +#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 +#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 +#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 +#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A +#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B +#endif /* GL_NVX_gpu_memory_info */ + +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GLAPI void APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif +#endif /* GL_NV_fragment_program */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif +#endif /* GL_NV_gpu_program5 */ + +#ifndef GL_NV_gpu_program5_mem_extended +#define GL_NV_gpu_program5_mem_extended 1 +#endif /* GL_NV_gpu_program5_mem_extended */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#endif /* GL_NV_multisample_coverage */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_occlusion_query */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif +#endif /* GL_NV_pixel_data_range */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_NV_present_video */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_shader_thread_group +#define GL_NV_shader_thread_group 1 +#define GL_WARP_SIZE_NV 0x9339 +#define GL_WARPS_PER_SM_NV 0x933A +#define GL_SM_COUNT_NV 0x933B +#endif /* GL_NV_shader_thread_group */ + +#ifndef GL_NV_shader_thread_shuffle +#define GL_NV_shader_thread_shuffle 1 +#endif /* GL_NV_shader_thread_shuffle */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif +#endif /* GL_NV_texture_multisample */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif +#endif /* GL_NV_transform_feedback */ + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif +#endif /* GL_NV_transform_feedback2 */ + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif +#endif /* GL_NV_vdpau_interop */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); +#endif +#endif /* GL_NV_vertex_array_range */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif +#endif /* GL_NV_vertex_program */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_vertex_program4 */ + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif +#endif /* GL_NV_video_capture */ + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif +#endif /* GL_PGI_misc_hints */ + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_detail_texture */ + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif +#endif /* GL_SGIS_fog_function */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif +#endif /* GL_SGIS_multisample */ + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif +#endif /* GL_SGIS_pixel_texture */ + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_SGIS_point_parameters */ + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_sharpen_texture */ + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_SGIS_texture4D */ + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif +#endif /* GL_SGIS_texture_color_mask */ + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif +#endif /* GL_SGIS_texture_filter4 */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif +#endif /* GL_SGIX_async */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif +#endif /* GL_SGIX_flush_raster */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif +#endif /* GL_SGIX_fragment_lighting */ + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif +#endif /* GL_SGIX_framezoom */ + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); +#endif +#endif /* GL_SGIX_igloo_interface */ + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif +#endif /* GL_SGIX_instruments */ + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_list_priority */ + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif +#endif /* GL_SGIX_pixel_texture */ + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif +#endif /* GL_SGIX_polynomial_ffd */ + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif +#endif /* GL_SGIX_reference_plane */ + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_sprite */ + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif +#endif /* GL_SGIX_tag_sample_buffer */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_SGI_color_table */ + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif +#endif /* GL_SUNX_constant_data */ + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif +#endif /* GL_SUN_global_alpha */ + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif +#endif /* GL_SUN_mesh_array */ + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); +#endif +#endif /* GL_SUN_triangle_list */ + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif +#endif /* GL_SUN_vertex */ + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/#ThirdParty/libSDL/include/SDL_opengles.h b/#ThirdParty/libSDL/include/SDL_opengles.h new file mode 100644 index 0000000..bcc1277 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_opengles.h @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_opengles.h + * + * This is a simple file to encapsulate the OpenGL ES 1.X API headers. + */ + +#ifdef __IPHONEOS__ +#include +#include +#else +#include +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif diff --git a/#ThirdParty/libSDL/include/SDL_opengles2.h b/#ThirdParty/libSDL/include/SDL_opengles2.h new file mode 100644 index 0000000..edcd1a2 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_opengles2.h @@ -0,0 +1,50 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_opengles2.h + * + * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. + */ +#ifndef _MSC_VER + +#ifdef __IPHONEOS__ +#include +#include +#else +#include +#include +#include +#endif + +#else /* _MSC_VER */ + +/* OpenGL ES2 headers for Visual Studio */ +#include "SDL_opengles2_khrplatform.h" +#include "SDL_opengles2_gl2platform.h" +#include "SDL_opengles2_gl2.h" +#include "SDL_opengles2_gl2ext.h" + +#endif /* _MSC_VER */ + +#ifndef APIENTRY +#define APIENTRY GL_APIENTRY +#endif diff --git a/#ThirdParty/libSDL/include/SDL_opengles2_gl2.h b/#ThirdParty/libSDL/include/SDL_opengles2_gl2.h new file mode 100644 index 0000000..c62fb0a --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_opengles2_gl2.h @@ -0,0 +1,621 @@ +#ifndef __gl2_h_ +#define __gl2_h_ + +/* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -0800 #$ */ + +/*#include */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/*------------------------------------------------------------------------- + * Data type definitions + *-----------------------------------------------------------------------*/ + +typedef void GLvoid; +typedef char GLchar; +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef khronos_int8_t GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; + +/* GL types for handling large vertex buffer objects */ +typedef khronos_intptr_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; + +/* OpenGL ES core versions */ +#define GL_ES_VERSION_2_0 1 + +/* ClearBufferMask */ +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 + +/* Boolean */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* BeginMode */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 + +/* AlphaFunction (not supported in ES20) */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* BlendingFactorDest */ +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 + +/* BlendingFactorSrc */ +/* GL_ZERO */ +/* GL_ONE */ +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +/* GL_SRC_ALPHA */ +/* GL_ONE_MINUS_SRC_ALPHA */ +/* GL_DST_ALPHA */ +/* GL_ONE_MINUS_DST_ALPHA */ + +/* BlendEquationSeparate */ +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ +#define GL_BLEND_EQUATION_ALPHA 0x883D + +/* BlendSubtract */ +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B + +/* Separate Blend Functions */ +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 + +/* Buffer Objects */ +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 + +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 + +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 + +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 + +/* CullFaceMode */ +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 + +/* DepthFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* EnableCap */ +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 + +/* ErrorCode */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 + +/* FrontFaceDirection */ +#define GL_CW 0x0900 +#define GL_CCW 0x0901 + +/* GetPName */ +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +/* GL_SCISSOR_TEST */ +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +/* GL_POLYGON_OFFSET_FILL */ +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB + +/* GetTextureParameter */ +/* GL_TEXTURE_MAG_FILTER */ +/* GL_TEXTURE_MIN_FILTER */ +/* GL_TEXTURE_WRAP_S */ +/* GL_TEXTURE_WRAP_T */ + +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 + +/* HintMode */ +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* HintTarget */ +#define GL_GENERATE_MIPMAP_HINT 0x8192 + +/* DataType */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C + +/* PixelFormat */ +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +/* PixelType */ +/* GL_UNSIGNED_BYTE */ +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 + +/* Shaders */ +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D + +/* StencilFunction */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 + +/* StencilOp */ +/* GL_ZERO */ +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 + +/* StringName */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* TextureMagFilter */ +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 + +/* TextureMinFilter */ +/* GL_NEAREST */ +/* GL_LINEAR */ +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 + +/* TextureParameterName */ +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 + +/* TextureTarget */ +/* GL_TEXTURE_2D */ +#define GL_TEXTURE 0x1702 + +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C + +/* TextureUnit */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 + +/* TextureWrapMode */ +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 + +/* Uniform Types */ +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 + +/* Vertex Arrays */ +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F + +/* Read Format */ +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B + +/* Shader Source */ +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA + +/* Shader Binary */ +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 + +/* Shader Precision-Specified Types */ +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 + +/* Framebuffer Object. */ +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 + +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 + +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 + +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 + +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 + +#define GL_NONE 0 + +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD + +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 + +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 + +/*------------------------------------------------------------------------- + * GL core functions. + *-----------------------------------------------------------------------*/ + +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); +GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); + +#ifdef __cplusplus +} +#endif + +#endif /* __gl2_h_ */ + diff --git a/#ThirdParty/libSDL/include/SDL_opengles2_gl2ext.h b/#ThirdParty/libSDL/include/SDL_opengles2_gl2ext.h new file mode 100644 index 0000000..e8ca8b1 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_opengles2_gl2ext.h @@ -0,0 +1,2050 @@ +#ifndef __gl2ext_h_ +#define __gl2ext_h_ + +/* $Revision: 22801 $ on $Date:: 2013-08-21 03:20:48 -0700 #$ */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +#ifndef GL_APIENTRYP +# define GL_APIENTRYP GL_APIENTRY* +#endif + +/* New types shared by several extensions */ + +#ifndef __gl3_h_ +/* These are defined with respect to in the + * Apple extension spec, but they are also used by non-APPLE + * extensions, and in the Khronos header we use the Khronos + * portable types in khrplatform.h, which must be defined. + */ +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + + +/*------------------------------------------------------------------------* + * OES extension tokens + *------------------------------------------------------------------------*/ + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_ETC1_RGB8_OES 0x8D64 +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_DEPTH_COMPONENT24_OES 0x81A6 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#endif + +/* GL_OES_depth_texture */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +typedef void* GLeglImageOES; +#endif + +/* GL_OES_EGL_image_external */ +#ifndef GL_OES_EGL_image_external +/* GLeglImageOES defined in GL_OES_EGL_image already. */ +#define GL_TEXTURE_EXTERNAL_OES 0x8D65 +#define GL_SAMPLER_EXTERNAL_OES 0x8D66 +#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 +#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 +#endif + +/* GL_OES_element_index_uint */ +#ifndef GL_OES_element_index_uint +#define GL_UNSIGNED_INT 0x1405 +#endif + +/* GL_OES_get_program_binary */ +#ifndef GL_OES_get_program_binary +#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE +#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_WRITE_ONLY_OES 0x88B9 +#define GL_BUFFER_ACCESS_OES 0x88BB +#define GL_BUFFER_MAPPED_OES 0x88BC +#define GL_BUFFER_MAP_POINTER_OES 0x88BD +#endif + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_ALPHA8_OES 0x803C +#define GL_DEPTH_COMPONENT16_OES 0x81A5 +/* reuse GL_DEPTH_COMPONENT24_OES */ +/* reuse GL_DEPTH24_STENCIL8_OES */ +/* reuse GL_DEPTH_COMPONENT32_OES */ +#define GL_LUMINANCE4_ALPHA4_OES 0x8043 +#define GL_LUMINANCE8_ALPHA8_OES 0x8045 +#define GL_LUMINANCE8_OES 0x8040 +#define GL_RGBA4_OES 0x8056 +#define GL_RGB5_A1_OES 0x8057 +#define GL_RGB565_OES 0x8D62 +/* reuse GL_RGB8_OES */ +/* reuse GL_RGBA8_OES */ +/* reuse GL_RGB10_EXT */ +/* reuse GL_RGB10_A2_EXT */ +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_RGB8_OES 0x8051 +#define GL_RGBA8_OES 0x8058 +#endif + +/* GL_OES_standard_derivatives */ +#ifndef GL_OES_standard_derivatives +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_STENCIL_INDEX1_OES 0x8D46 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_STENCIL_INDEX4_OES 0x8D47 +#endif + +#ifndef GL_OES_surfaceless_context +#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 +#endif + +/* GL_OES_texture_3D */ +#ifndef GL_OES_texture_3D +#define GL_TEXTURE_WRAP_R_OES 0x8072 +#define GL_TEXTURE_3D_OES 0x806F +#define GL_TEXTURE_BINDING_3D_OES 0x806A +#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 +#define GL_SAMPLER_3D_OES 0x8B5F +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 +#endif + +/* GL_OES_texture_float */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_texture_float_linear */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_texture_half_float */ +#ifndef GL_OES_texture_half_float +#define GL_HALF_FLOAT_OES 0x8D61 +#endif + +/* GL_OES_texture_half_float_linear */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_texture_npot */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_vertex_array_object */ +#ifndef GL_OES_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 +#endif + +/* GL_OES_vertex_half_float */ +/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */ + +/* GL_OES_vertex_type_10_10_10_2 */ +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 +#define GL_INT_10_10_10_2_OES 0x8DF7 +#endif + +/*------------------------------------------------------------------------* + * KHR extension tokens + *------------------------------------------------------------------------*/ + +#ifndef GL_KHR_debug +typedef void (GL_APIENTRYP GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 +#define GL_DEBUG_SOURCE_API_KHR 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A +#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B +#define GL_DEBUG_TYPE_ERROR_KHR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 +#define GL_DEBUG_TYPE_OTHER_KHR 0x8251 +#define GL_DEBUG_TYPE_MARKER_KHR 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D +#define GL_BUFFER_KHR 0x82E0 +#define GL_SHADER_KHR 0x82E1 +#define GL_PROGRAM_KHR 0x82E2 +#define GL_QUERY_KHR 0x82E3 +/* PROGRAM_PIPELINE only in GL */ +#define GL_SAMPLER_KHR 0x82E6 +/* DISPLAY_LIST only in GL */ +#define GL_MAX_LABEL_LENGTH_KHR 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 +#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148 +#define GL_DEBUG_OUTPUT_KHR 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 +#define GL_STACK_OVERFLOW_KHR 0x0503 +#define GL_STACK_UNDERFLOW_KHR 0x0504 +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + +/*------------------------------------------------------------------------* + * AMD extension tokens + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_3DC_X_AMD 0x87F9 +#define GL_3DC_XY_AMD 0x87FA +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#endif + +/* GL_AMD_performance_monitor */ +#ifndef GL_AMD_performance_monitor +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +#endif + +/* GL_AMD_program_binary_Z400 */ +#ifndef GL_AMD_program_binary_Z400 +#define GL_Z400_BINARY_AMD 0x8740 +#endif + +/*------------------------------------------------------------------------* + * ANGLE extension tokens + *------------------------------------------------------------------------*/ + +/* GL_ANGLE_depth_texture */ +#ifndef GL_ANGLE_depth_texture +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_UNSIGNED_INT 0x1405 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + +/* GL_ANGLE_framebuffer_blit */ +#ifndef GL_ANGLE_framebuffer_blit +#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA +#endif + +/* GL_ANGLE_framebuffer_multisample */ +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 +#define GL_MAX_SAMPLES_ANGLE 0x8D57 +#endif + +/* GL_ANGLE_instanced_arrays */ +#ifndef GL_ANGLE_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE +#endif + +/* GL_ANGLE_pack_reverse_row_order */ +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 +#endif + +/* GL_ANGLE_program_binary */ +#ifndef GL_ANGLE_program_binary +#define GL_PROGRAM_BINARY_ANGLE 0x93A6 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 +#endif + +/* GL_ANGLE_texture_usage */ +#ifndef GL_ANGLE_texture_usage +#define GL_TEXTURE_USAGE_ANGLE 0x93A2 +#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 +#endif + +/* GL_ANGLE_translated_shader_source */ +#ifndef GL_ANGLE_translated_shader_source +#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 +#endif + +/*------------------------------------------------------------------------* + * APPLE extension tokens + *------------------------------------------------------------------------*/ + +/* GL_APPLE_copy_texture_levels */ +/* No new tokens introduced by this extension. */ + +/* GL_APPLE_framebuffer_multisample */ +#ifndef GL_APPLE_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 +#define GL_MAX_SAMPLES_APPLE 0x8D57 +#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA +#endif + +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync + +#define GL_SYNC_OBJECT_APPLE 0x8A53 +#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 +#define GL_OBJECT_TYPE_APPLE 0x9112 +#define GL_SYNC_CONDITION_APPLE 0x9113 +#define GL_SYNC_STATUS_APPLE 0x9114 +#define GL_SYNC_FLAGS_APPLE 0x9115 +#define GL_SYNC_FENCE_APPLE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 +#define GL_UNSIGNALED_APPLE 0x9118 +#define GL_SIGNALED_APPLE 0x9119 +#define GL_ALREADY_SIGNALED_APPLE 0x911A +#define GL_TIMEOUT_EXPIRED_APPLE 0x911B +#define GL_CONDITION_SATISFIED_APPLE 0x911C +#define GL_WAIT_FAILED_APPLE 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 +#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull +#endif + +/* GL_APPLE_texture_format_BGRA8888 */ +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_BGRA_EXT 0x80E1 +#endif + +/* GL_APPLE_texture_max_level */ +#ifndef GL_APPLE_texture_max_level +#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D +#endif + +/*------------------------------------------------------------------------* + * ARM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_ARM_mali_program_binary */ +#ifndef GL_ARM_mali_program_binary +#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 +#endif + +/* GL_ARM_mali_shader_binary */ +#ifndef GL_ARM_mali_shader_binary +#define GL_MALI_SHADER_BINARY_ARM 0x8F60 +#endif + +/* GL_ARM_rgba8 */ +/* No new tokens introduced by this extension. */ + +/*------------------------------------------------------------------------* + * EXT extension tokens + *------------------------------------------------------------------------*/ + +/* GL_EXT_blend_minmax */ +#ifndef GL_EXT_blend_minmax +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#endif + +/* GL_EXT_color_buffer_half_float */ +#ifndef GL_EXT_color_buffer_half_float +#define GL_RGBA16F_EXT 0x881A +#define GL_RGB16F_EXT 0x881B +#define GL_RG16F_EXT 0x822F +#define GL_R16F_EXT 0x822D +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 +#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17 +#endif + +/* GL_EXT_debug_label */ +#ifndef GL_EXT_debug_label +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +#endif + +/* GL_EXT_debug_marker */ +/* No new tokens introduced by this extension. */ + +/* GL_EXT_discard_framebuffer */ +#ifndef GL_EXT_discard_framebuffer +#define GL_COLOR_EXT 0x1800 +#define GL_DEPTH_EXT 0x1801 +#define GL_STENCIL_EXT 0x1802 +#endif + +#ifndef GL_EXT_disjoint_timer_query +#define GL_QUERY_COUNTER_BITS_EXT 0x8864 +#define GL_CURRENT_QUERY_EXT 0x8865 +#define GL_QUERY_RESULT_EXT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 +#define GL_TIME_ELAPSED_EXT 0x88BF +#define GL_TIMESTAMP_EXT 0x8E28 +#define GL_GPU_DISJOINT_EXT 0x8FBB +#endif + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_MAX_DRAW_BUFFERS_EXT 0x8824 +#define GL_DRAW_BUFFER0_EXT 0x8825 +#define GL_DRAW_BUFFER1_EXT 0x8826 +#define GL_DRAW_BUFFER2_EXT 0x8827 +#define GL_DRAW_BUFFER3_EXT 0x8828 +#define GL_DRAW_BUFFER4_EXT 0x8829 +#define GL_DRAW_BUFFER5_EXT 0x882A +#define GL_DRAW_BUFFER6_EXT 0x882B +#define GL_DRAW_BUFFER7_EXT 0x882C +#define GL_DRAW_BUFFER8_EXT 0x882D +#define GL_DRAW_BUFFER9_EXT 0x882E +#define GL_DRAW_BUFFER10_EXT 0x882F +#define GL_DRAW_BUFFER11_EXT 0x8830 +#define GL_DRAW_BUFFER12_EXT 0x8831 +#define GL_DRAW_BUFFER13_EXT 0x8832 +#define GL_DRAW_BUFFER14_EXT 0x8833 +#define GL_DRAW_BUFFER15_EXT 0x8834 +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#endif + +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_MAP_READ_BIT_EXT 0x0001 +#define GL_MAP_WRITE_BIT_EXT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 +#endif + +/* GL_EXT_multisampled_render_to_texture */ +#ifndef GL_EXT_multisampled_render_to_texture +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C +/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +/* GL_EXT_multiview_draw_buffers */ +#ifndef GL_EXT_multiview_draw_buffers +#define GL_COLOR_ATTACHMENT_EXT 0x90F0 +#define GL_MULTIVIEW_EXT 0x90F1 +#define GL_DRAW_BUFFER_EXT 0x0C01 +#define GL_READ_BUFFER_EXT 0x0C02 +#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 +#endif + +/* GL_EXT_multi_draw_arrays */ +/* No new tokens introduced by this extension. */ + +/* GL_EXT_occlusion_query_boolean */ +#ifndef GL_EXT_occlusion_query_boolean +#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A +#define GL_CURRENT_QUERY_EXT 0x8865 +#define GL_QUERY_RESULT_EXT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 +#endif + +/* GL_EXT_read_format_bgra */ +#ifndef GL_EXT_read_format_bgra +#define GL_BGRA_EXT 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 +#endif + +/* GL_EXT_robustness */ +#ifndef GL_EXT_robustness +/* reuse GL_NO_ERROR */ +#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 +#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 +#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 +#define GL_NO_RESET_NOTIFICATION_EXT 0x8261 +#endif + +/* GL_EXT_separate_shader_objects */ +#ifndef GL_EXT_separate_shader_objects +#define GL_VERTEX_SHADER_BIT_EXT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 +#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE_EXT 0x8258 +#define GL_ACTIVE_PROGRAM_EXT 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A +#endif + +/* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif + +/* GL_EXT_shader_texture_lod */ +/* No new tokens introduced by this extension. */ + +/* GL_EXT_shadow_samplers */ +#ifndef GL_EXT_shadow_samplers +#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C +#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D +#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E +#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 +#endif + +/* GL_EXT_sRGB */ +#ifndef GL_EXT_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 +#endif + +/* GL_EXT_sRGB_write_control */ +#ifndef GL_EXT_sRGB_write_control +#define GL_EXT_sRGB_write_control 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#endif + +/* GL_EXT_texture_compression_dxt1 */ +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#endif + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_BGRA_EXT 0x80E1 +#endif + +/* GL_EXT_texture_rg */ +#ifndef GL_EXT_texture_rg +#define GL_RED_EXT 0x1903 +#define GL_RG_EXT 0x8227 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#endif + +/* GL_EXT_texture_sRGB_decode */ +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif + +/* GL_EXT_texture_storage */ +#ifndef GL_EXT_texture_storage +#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F +#define GL_ALPHA8_EXT 0x803C +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_RGBA32F_EXT 0x8814 +#define GL_RGB32F_EXT 0x8815 +#define GL_ALPHA32F_EXT 0x8816 +#define GL_LUMINANCE32F_EXT 0x8818 +#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 +/* reuse GL_RGBA16F_EXT */ +/* reuse GL_RGB16F_EXT */ +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGB10_EXT 0x8052 +#define GL_BGRA8_EXT 0x93A1 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +#define GL_R16F_EXT 0x822D +#define GL_RG16F_EXT 0x822F +#endif + +/* GL_EXT_texture_type_2_10_10_10_REV */ +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 +#endif + +/* GL_EXT_unpack_subimage */ +#ifndef GL_EXT_unpack_subimage +#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 +#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 +#endif + +/*------------------------------------------------------------------------* + * DMP extension tokens + *------------------------------------------------------------------------*/ + +/* GL_DMP_shader_binary */ +#ifndef GL_DMP_shader_binary +#define GL_SHADER_BINARY_DMP 0x9250 +#endif + +/*------------------------------------------------------------------------* + * FJ extension tokens + *------------------------------------------------------------------------*/ + +/* GL_FJ_shader_binary_GCCSO */ +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_GCCSO_SHADER_BINARY_FJ 0x9260 +#endif + +/*------------------------------------------------------------------------* + * IMG extension tokens + *------------------------------------------------------------------------*/ + +/* GL_IMG_program_binary */ +#ifndef GL_IMG_program_binary +#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 +#endif + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_BGRA_IMG 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 +#endif + +/* GL_IMG_shader_binary */ +#ifndef GL_IMG_shader_binary +#define GL_SGX_BINARY_IMG 0x8C0A +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif + +/* GL_IMG_texture_compression_pvrtc2 */ +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 +#endif + +/* GL_IMG_multisampled_render_to_texture */ +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 +#define GL_MAX_SAMPLES_IMG 0x9135 +#define GL_TEXTURE_SAMPLES_IMG 0x9136 +#endif + +/*------------------------------------------------------------------------* + * NV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_NV_coverage_sample */ +#ifndef GL_NV_coverage_sample +#define GL_COVERAGE_COMPONENT_NV 0x8ED0 +#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 +#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 +#define GL_COVERAGE_BUFFERS_NV 0x8ED3 +#define GL_COVERAGE_SAMPLES_NV 0x8ED4 +#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 +#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 +#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 +#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000 +#endif + +/* GL_NV_depth_nonlinear */ +#ifndef GL_NV_depth_nonlinear +#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C +#endif + +/* GL_NV_draw_buffers */ +#ifndef GL_NV_draw_buffers +#define GL_MAX_DRAW_BUFFERS_NV 0x8824 +#define GL_DRAW_BUFFER0_NV 0x8825 +#define GL_DRAW_BUFFER1_NV 0x8826 +#define GL_DRAW_BUFFER2_NV 0x8827 +#define GL_DRAW_BUFFER3_NV 0x8828 +#define GL_DRAW_BUFFER4_NV 0x8829 +#define GL_DRAW_BUFFER5_NV 0x882A +#define GL_DRAW_BUFFER6_NV 0x882B +#define GL_DRAW_BUFFER7_NV 0x882C +#define GL_DRAW_BUFFER8_NV 0x882D +#define GL_DRAW_BUFFER9_NV 0x882E +#define GL_DRAW_BUFFER10_NV 0x882F +#define GL_DRAW_BUFFER11_NV 0x8830 +#define GL_DRAW_BUFFER12_NV 0x8831 +#define GL_DRAW_BUFFER13_NV 0x8832 +#define GL_DRAW_BUFFER14_NV 0x8833 +#define GL_DRAW_BUFFER15_NV 0x8834 +#define GL_COLOR_ATTACHMENT0_NV 0x8CE0 +#define GL_COLOR_ATTACHMENT1_NV 0x8CE1 +#define GL_COLOR_ATTACHMENT2_NV 0x8CE2 +#define GL_COLOR_ATTACHMENT3_NV 0x8CE3 +#define GL_COLOR_ATTACHMENT4_NV 0x8CE4 +#define GL_COLOR_ATTACHMENT5_NV 0x8CE5 +#define GL_COLOR_ATTACHMENT6_NV 0x8CE6 +#define GL_COLOR_ATTACHMENT7_NV 0x8CE7 +#define GL_COLOR_ATTACHMENT8_NV 0x8CE8 +#define GL_COLOR_ATTACHMENT9_NV 0x8CE9 +#define GL_COLOR_ATTACHMENT10_NV 0x8CEA +#define GL_COLOR_ATTACHMENT11_NV 0x8CEB +#define GL_COLOR_ATTACHMENT12_NV 0x8CEC +#define GL_COLOR_ATTACHMENT13_NV 0x8CED +#define GL_COLOR_ATTACHMENT14_NV 0x8CEE +#define GL_COLOR_ATTACHMENT15_NV 0x8CEF +#endif + +/* GL_NV_draw_instanced */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_fbo_color_attachments */ +#ifndef GL_NV_fbo_color_attachments +#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF +/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */ +#endif + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +/* GL_NV_framebuffer_blit */ +#ifndef GL_NV_framebuffer_blit +#define GL_READ_FRAMEBUFFER_NV 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA +#endif + +/* GL_NV_framebuffer_multisample */ +#ifndef GL_NV_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 +#define GL_MAX_SAMPLES_NV 0x8D57 +#endif + +/* GL_NV_generate_mipmap_sRGB */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_instanced_arrays */ +#ifndef GL_NV_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE +#endif + +/* GL_NV_read_buffer */ +#ifndef GL_NV_read_buffer +#define GL_READ_BUFFER_NV 0x0C02 +#endif + +/* GL_NV_read_buffer_front */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_depth */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_depth_stencil */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_stencil */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_shadow_samplers_array */ +#ifndef GL_NV_shadow_samplers_array +#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 +#endif + +/* GL_NV_shadow_samplers_cube */ +#ifndef GL_NV_shadow_samplers_cube +#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 +#endif + +/* GL_NV_sRGB_formats */ +#ifndef GL_NV_sRGB_formats +#define GL_SLUMINANCE_NV 0x8C46 +#define GL_SLUMINANCE_ALPHA_NV 0x8C44 +#define GL_SRGB8_NV 0x8C41 +#define GL_SLUMINANCE8_NV 0x8C47 +#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F +#define GL_ETC1_SRGB8_NV 0x88EE +#endif + +/* GL_NV_texture_border_clamp */ +#ifndef GL_NV_texture_border_clamp +#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 +#define GL_CLAMP_TO_BORDER_NV 0x812D +#endif + +/* GL_NV_texture_compression_s3tc_update */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_texture_npot_2D_mipmap */ +/* No new tokens introduced by this extension. */ + +/*------------------------------------------------------------------------* + * QCOM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_QCOM_alpha_test */ +#ifndef GL_QCOM_alpha_test +#define GL_ALPHA_TEST_QCOM 0x0BC0 +#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 +#define GL_ALPHA_TEST_REF_QCOM 0x0BC2 +#endif + +/* GL_QCOM_binning_control */ +#ifndef GL_QCOM_binning_control +#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 +#define GL_CPU_OPTIMIZED_QCOM 0x8FB1 +#define GL_GPU_OPTIMIZED_QCOM 0x8FB2 +#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 +#endif + +/* GL_QCOM_driver_control */ +/* No new tokens introduced by this extension. */ + +/* GL_QCOM_extended_get */ +#ifndef GL_QCOM_extended_get +#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 +#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 +#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 +#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 +#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 +#define GL_TEXTURE_TYPE_QCOM 0x8BD7 +#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 +#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 +#define GL_TEXTURE_TARGET_QCOM 0x8BDA +#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB +#define GL_STATE_RESTORE 0x8BDC +#endif + +/* GL_QCOM_extended_get2 */ +/* No new tokens introduced by this extension. */ + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 +#endif + +/* GL_QCOM_writeonly_rendering */ +#ifndef GL_QCOM_writeonly_rendering +#define GL_WRITEONLY_RENDERING_QCOM 0x8823 +#endif + +/* GL_QCOM_tiled_rendering */ +#ifndef GL_QCOM_tiled_rendering +#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 +#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 +#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 +#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 +#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 +#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 +#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 +#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 +#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 +#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 +#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 +#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 +#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 +#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 +#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 +#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 +#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 +#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 +#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 +#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 +#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 +#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 +#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 +#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 +#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 +#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 +#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 +#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 +#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 +#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 +#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 +#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 +#endif + +/*------------------------------------------------------------------------* + * VIV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_VIV_shader_binary */ +#ifndef GL_VIV_shader_binary +#define GL_SHADER_BINARY_VIV 0x8FC4 +#endif + +/*------------------------------------------------------------------------* + * End of extension tokens, start of corresponding extension functions + *------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------* + * OES extension functions + *------------------------------------------------------------------------*/ + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_OES_compressed_ETC1_RGB8_texture 1 +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_OES_depth24 1 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_OES_depth32 1 +#endif + +/* GL_OES_depth_texture */ +#ifndef GL_OES_depth_texture +#define GL_OES_depth_texture 1 +#endif + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#endif + +/* GL_OES_EGL_image_external */ +#ifndef GL_OES_EGL_image_external +#define GL_OES_EGL_image_external 1 +/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */ +#endif + +/* GL_OES_element_index_uint */ +#ifndef GL_OES_element_index_uint +#define GL_OES_element_index_uint 1 +#endif + +/* GL_OES_fbo_render_mipmap */ +#ifndef GL_OES_fbo_render_mipmap +#define GL_OES_fbo_render_mipmap 1 +#endif + +/* GL_OES_fragment_precision_high */ +#ifndef GL_OES_fragment_precision_high +#define GL_OES_fragment_precision_high 1 +#endif + +/* GL_OES_get_program_binary */ +#ifndef GL_OES_get_program_binary +#define GL_OES_get_program_binary 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); +#endif +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_OES_mapbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); +GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid **params); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid **params); +#endif + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_OES_packed_depth_stencil 1 +#endif + +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_OES_required_internalformat 1 +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_OES_rgb8_rgba8 1 +#endif + +/* GL_OES_standard_derivatives */ +#ifndef GL_OES_standard_derivatives +#define GL_OES_standard_derivatives 1 +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_OES_stencil1 1 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_OES_stencil4 1 +#endif + +#ifndef GL_OES_surfaceless_context +#define GL_OES_surfaceless_context 1 +#endif + +/* GL_OES_texture_3D */ +#ifndef GL_OES_texture_3D +#define GL_OES_texture_3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#endif +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#endif + +/* GL_OES_texture_float */ +#ifndef GL_OES_texture_float +#define GL_OES_texture_float 1 +#endif + +/* GL_OES_texture_float_linear */ +#ifndef GL_OES_texture_float_linear +#define GL_OES_texture_float_linear 1 +#endif + +/* GL_OES_texture_half_float */ +#ifndef GL_OES_texture_half_float +#define GL_OES_texture_half_float 1 +#endif + +/* GL_OES_texture_half_float_linear */ +#ifndef GL_OES_texture_half_float_linear +#define GL_OES_texture_half_float_linear 1 +#endif + +/* GL_OES_texture_npot */ +#ifndef GL_OES_texture_npot +#define GL_OES_texture_npot 1 +#endif + +/* GL_OES_vertex_array_object */ +#ifndef GL_OES_vertex_array_object +#define GL_OES_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); +#endif +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); +#endif + +/* GL_OES_vertex_half_float */ +#ifndef GL_OES_vertex_half_float +#define GL_OES_vertex_half_float 1 +#endif + +/* GL_OES_vertex_type_10_10_10_2 */ +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_OES_vertex_type_10_10_10_2 1 +#endif + +/*------------------------------------------------------------------------* + * KHR extension functions + *------------------------------------------------------------------------*/ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam); +GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void); +GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, GLvoid **params); +#endif +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam); +typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void); +typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, GLvoid **params); +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif + + +/*------------------------------------------------------------------------* + * AMD extension functions + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_AMD_compressed_3DC_texture 1 +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_AMD_compressed_ATC_texture 1 +#endif + +/* AMD_performance_monitor */ +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); +GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); +typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif + +/* GL_AMD_program_binary_Z400 */ +#ifndef GL_AMD_program_binary_Z400 +#define GL_AMD_program_binary_Z400 1 +#endif + +/*------------------------------------------------------------------------* + * ANGLE extension functions + *------------------------------------------------------------------------*/ + +/* GL_ANGLE_depth_texture */ +#ifndef GL_ANGLE_depth_texture +#define GL_ANGLE_depth_texture 1 +#endif + +/* GL_ANGLE_framebuffer_blit */ +#ifndef GL_ANGLE_framebuffer_blit +#define GL_ANGLE_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +/* GL_ANGLE_framebuffer_multisample */ +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_ANGLE_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_ANGLE_instanced_arrays +#define GL_ANGLE_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); +#endif + +/* GL_ANGLE_pack_reverse_row_order */ +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_ANGLE_pack_reverse_row_order 1 +#endif + +/* GL_ANGLE_program_binary */ +#ifndef GL_ANGLE_program_binary +#define GL_ANGLE_program_binary 1 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_ANGLE_texture_compression_dxt3 1 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_ANGLE_texture_compression_dxt5 1 +#endif + +/* GL_ANGLE_texture_usage */ +#ifndef GL_ANGLE_texture_usage +#define GL_ANGLE_texture_usage 1 +#endif + +#ifndef GL_ANGLE_translated_shader_source +#define GL_ANGLE_translated_shader_source 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); +#endif +typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); +#endif + +/*------------------------------------------------------------------------* + * APPLE extension functions + *------------------------------------------------------------------------*/ + +/* GL_APPLE_copy_texture_levels */ +#ifndef GL_APPLE_copy_texture_levels +#define GL_APPLE_copy_texture_levels 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif +typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif + +/* GL_APPLE_framebuffer_multisample */ +#ifndef GL_APPLE_framebuffer_multisample +#define GL_APPLE_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); +#endif + +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync +#define GL_APPLE_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +/* GL_APPLE_texture_format_BGRA8888 */ +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_APPLE_texture_format_BGRA8888 1 +#endif + +/* GL_APPLE_texture_max_level */ +#ifndef GL_APPLE_texture_max_level +#define GL_APPLE_texture_max_level 1 +#endif + +/*------------------------------------------------------------------------* + * ARM extension functions + *------------------------------------------------------------------------*/ + +/* GL_ARM_mali_program_binary */ +#ifndef GL_ARM_mali_program_binary +#define GL_ARM_mali_program_binary 1 +#endif + +/* GL_ARM_mali_shader_binary */ +#ifndef GL_ARM_mali_shader_binary +#define GL_ARM_mali_shader_binary 1 +#endif + +/* GL_ARM_rgba8 */ +#ifndef GL_ARM_rgba8 +#define GL_ARM_rgba8 1 +#endif + +/*------------------------------------------------------------------------* + * EXT extension functions + *------------------------------------------------------------------------*/ + +/* GL_EXT_blend_minmax */ +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#endif + +/* GL_EXT_color_buffer_half_float */ +#ifndef GL_EXT_color_buffer_half_float +#define GL_EXT_color_buffer_half_float 1 +#endif + +/* GL_EXT_debug_label */ +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif + +/* GL_EXT_debug_marker */ +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void); +#endif +typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#endif + +/* GL_EXT_discard_framebuffer */ +#ifndef GL_EXT_discard_framebuffer +#define GL_EXT_discard_framebuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif +typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif + +#ifndef GL_EXT_disjoint_timer_query +#define GL_EXT_disjoint_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); +GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#endif /* GL_EXT_disjoint_timer_query */ + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs); +#endif /* GL_EXT_draw_buffers */ + +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_EXT_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + +/* GL_EXT_multisampled_render_to_texture */ +#ifndef GL_EXT_multisampled_render_to_texture +#define GL_EXT_multisampled_render_to_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif + +/* GL_EXT_multiview_draw_buffers */ +#ifndef GL_EXT_multiview_draw_buffers +#define GL_EXT_multiview_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); +GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); +GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); +#endif +typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +#endif + +/* GL_EXT_occlusion_query_boolean */ +#ifndef GL_EXT_occlusion_query_boolean +#define GL_EXT_occlusion_query_boolean 1 +/* All entry points also exist in GL_EXT_disjoint_timer_query */ +#endif + +/* GL_EXT_read_format_bgra */ +#ifndef GL_EXT_read_format_bgra +#define GL_EXT_read_format_bgra 1 +#endif + +/* GL_EXT_robustness */ +#ifndef GL_EXT_robustness +#define GL_EXT_robustness 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void); +GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#endif +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#endif + +/* GL_EXT_separate_shader_objects */ +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program); +GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings); +GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines); +GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint x); +GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint x, GLint y); +GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z); +GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat x); +GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings); +typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint x, GLint y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif + +/* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#endif + +/* GL_EXT_shader_texture_lod */ +#ifndef GL_EXT_shader_texture_lod +#define GL_EXT_shader_texture_lod 1 +#endif + +/* GL_EXT_shadow_samplers */ +#ifndef GL_EXT_shadow_samplers +#define GL_EXT_shadow_samplers 1 +#endif + +/* GL_EXT_sRGB */ +#ifndef GL_EXT_sRGB +#define GL_EXT_sRGB 1 +#endif + +/* GL_EXT_texture_compression_dxt1 */ +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_EXT_texture_compression_dxt1 1 +#endif + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_EXT_texture_format_BGRA8888 1 +#endif + +/* GL_EXT_texture_rg */ +#ifndef GL_EXT_texture_rg +#define GL_EXT_texture_rg 1 +#endif + +/* GL_EXT_texture_storage */ +#ifndef GL_EXT_texture_storage +#define GL_EXT_texture_storage 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif + +/* GL_EXT_texture_type_2_10_10_10_REV */ +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_EXT_texture_type_2_10_10_10_REV 1 +#endif + +/* GL_EXT_unpack_subimage */ +#ifndef GL_EXT_unpack_subimage +#define GL_EXT_unpack_subimage 1 +#endif + +/*------------------------------------------------------------------------* + * DMP extension functions + *------------------------------------------------------------------------*/ + +/* GL_DMP_shader_binary */ +#ifndef GL_DMP_shader_binary +#define GL_DMP_shader_binary 1 +#endif + +/*------------------------------------------------------------------------* + * FJ extension functions + *------------------------------------------------------------------------*/ + +/* GL_FJ_shader_binary_GCCSO */ +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_FJ_shader_binary_GCCSO 1 +#endif + +/*------------------------------------------------------------------------* + * IMG extension functions + *------------------------------------------------------------------------*/ + +/* GL_IMG_program_binary */ +#ifndef GL_IMG_program_binary +#define GL_IMG_program_binary 1 +#endif + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_IMG_read_format 1 +#endif + +/* GL_IMG_shader_binary */ +#ifndef GL_IMG_shader_binary +#define GL_IMG_shader_binary 1 +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_IMG_texture_compression_pvrtc 1 +#endif + +/* GL_IMG_texture_compression_pvrtc2 */ +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_IMG_texture_compression_pvrtc2 1 +#endif + +/* GL_IMG_multisampled_render_to_texture */ +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_IMG_multisampled_render_to_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif + +/*------------------------------------------------------------------------* + * NV extension functions + *------------------------------------------------------------------------*/ + +/* GL_NV_coverage_sample */ +#ifndef GL_NV_coverage_sample +#define GL_NV_coverage_sample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); +GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); +#endif +typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); +typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); +#endif + +/* GL_NV_depth_nonlinear */ +#ifndef GL_NV_depth_nonlinear +#define GL_NV_depth_nonlinear 1 +#endif + +/* GL_NV_draw_buffers */ +#ifndef GL_NV_draw_buffers +#define GL_NV_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); +#endif + +/* GL_NV_draw_instanced */ +#ifndef GL_NV_draw_instanced +#define GL_NV_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +/* GL_NV_fbo_color_attachments */ +#ifndef GL_NV_fbo_color_attachments +#define GL_NV_fbo_color_attachments 1 +#endif + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint fence); +GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint fence); +GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint fence); +GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +/* GL_NV_framebuffer_blit */ +#ifndef GL_NV_framebuffer_blit +#define GL_NV_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferNV (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +/* GL_NV_framebuffer_multisample */ +#ifndef GL_NV_framebuffer_multisample +#define GL_NV_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC) ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +/* GL_NV_generate_mipmap_sRGB */ +#ifndef GL_NV_generate_mipmap_sRGB +#define GL_NV_generate_mipmap_sRGB 1 +#endif + +/* GL_NV_instanced_arrays */ +#ifndef GL_NV_instanced_arrays +#define GL_NV_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor); +#endif +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor); +#endif + +/* GL_NV_read_buffer */ +#ifndef GL_NV_read_buffer +#define GL_NV_read_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode); +#endif +typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); +#endif + +/* GL_NV_read_buffer_front */ +#ifndef GL_NV_read_buffer_front +#define GL_NV_read_buffer_front 1 +#endif + +/* GL_NV_read_depth */ +#ifndef GL_NV_read_depth +#define GL_NV_read_depth 1 +#endif + +/* GL_NV_read_depth_stencil */ +#ifndef GL_NV_read_depth_stencil +#define GL_NV_read_depth_stencil 1 +#endif + +/* GL_NV_read_stencil */ +#ifndef GL_NV_read_stencil +#define GL_NV_read_stencil 1 +#endif + +/* GL_NV_shadow_samplers_array */ +#ifndef GL_NV_shadow_samplers_array +#define GL_NV_shadow_samplers_array 1 +#endif + +/* GL_NV_shadow_samplers_cube */ +#ifndef GL_NV_shadow_samplers_cube +#define GL_NV_shadow_samplers_cube 1 +#endif + +/* GL_NV_sRGB_formats */ +#ifndef GL_NV_sRGB_formats +#define GL_NV_sRGB_formats 1 +#endif + +/* GL_NV_texture_border_clamp */ +#ifndef GL_NV_texture_border_clamp +#define GL_NV_texture_border_clamp 1 +#endif + +/* GL_NV_texture_compression_s3tc_update */ +#ifndef GL_NV_texture_compression_s3tc_update +#define GL_NV_texture_compression_s3tc_update 1 +#endif + +/* GL_NV_texture_npot_2D_mipmap */ +#ifndef GL_NV_texture_npot_2D_mipmap +#define GL_NV_texture_npot_2D_mipmap 1 +#endif + +/*------------------------------------------------------------------------* + * QCOM extension functions + *------------------------------------------------------------------------*/ + +/* GL_QCOM_alpha_test */ +#ifndef GL_QCOM_alpha_test +#define GL_QCOM_alpha_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); +#endif +typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); +#endif + +/* GL_QCOM_binning_control */ +#ifndef GL_QCOM_binning_control +#define GL_QCOM_binning_control 1 +#endif + +/* GL_QCOM_driver_control */ +#ifndef GL_QCOM_driver_control +#define GL_QCOM_driver_control 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); +GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); +GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); +#endif +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +#endif + +/* GL_QCOM_extended_get */ +#ifndef GL_QCOM_extended_get +#define GL_QCOM_extended_get 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); +GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); +GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params); +#endif +typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params); +#endif + +/* GL_QCOM_extended_get2 */ +#ifndef GL_QCOM_extended_get2 +#define GL_QCOM_extended_get2 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); +GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); +GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif +typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_QCOM_perfmon_global_mode 1 +#endif + +/* GL_QCOM_writeonly_rendering */ +#ifndef GL_QCOM_writeonly_rendering +#define GL_QCOM_writeonly_rendering 1 +#endif + +/* GL_QCOM_tiled_rendering */ +#ifndef GL_QCOM_tiled_rendering +#define GL_QCOM_tiled_rendering 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); +#endif +typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); +#endif + +/*------------------------------------------------------------------------* + * VIV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_VIV_shader_binary */ +#ifndef GL_VIV_shader_binary +#define GL_VIV_shader_binary 1 +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __gl2ext_h_ */ diff --git a/#ThirdParty/libSDL/include/SDL_opengles2_gl2platform.h b/#ThirdParty/libSDL/include/SDL_opengles2_gl2platform.h new file mode 100644 index 0000000..c325686 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_opengles2_gl2platform.h @@ -0,0 +1,30 @@ +#ifndef __gl2platform_h_ +#define __gl2platform_h_ + +/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "OpenGL-ES" component "Registry". + */ + +/*#include */ + +#ifndef GL_APICALL +#define GL_APICALL KHRONOS_APICALL +#endif + +#ifndef GL_APIENTRY +#define GL_APIENTRY KHRONOS_APIENTRY +#endif + +#endif /* __gl2platform_h_ */ diff --git a/#ThirdParty/libSDL/include/SDL_opengles2_khrplatform.h b/#ThirdParty/libSDL/include/SDL_opengles2_khrplatform.h new file mode 100644 index 0000000..c9e6f17 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_opengles2_khrplatform.h @@ -0,0 +1,282 @@ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by sending them to the public Khronos Bugzilla + * (http://khronos.org/bugzilla) by filing a bug against product + * "Khronos (general)" component "Registry". + * + * A predefined template which fills in some of the bug fields can be + * reached using http://tinyurl.com/khrplatform-h-bugreport, but you + * must create a Bugzilla login first. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef _WIN64 +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ diff --git a/#ThirdParty/libSDL/include/SDL_pixels.h b/#ThirdParty/libSDL/include/SDL_pixels.h new file mode 100644 index 0000000..8499c32 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_pixels.h @@ -0,0 +1,454 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_pixels.h + * + * Header for the enumerated pixel format definitions. + */ + +#ifndef _SDL_pixels_h +#define _SDL_pixels_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Transparency definitions + * + * These define alpha as the opacity of a surface. + */ +/* @{ */ +#define SDL_ALPHA_OPAQUE 255 +#define SDL_ALPHA_TRANSPARENT 0 +/* @} */ + +/** Pixel type. */ +enum +{ + SDL_PIXELTYPE_UNKNOWN, + SDL_PIXELTYPE_INDEX1, + SDL_PIXELTYPE_INDEX4, + SDL_PIXELTYPE_INDEX8, + SDL_PIXELTYPE_PACKED8, + SDL_PIXELTYPE_PACKED16, + SDL_PIXELTYPE_PACKED32, + SDL_PIXELTYPE_ARRAYU8, + SDL_PIXELTYPE_ARRAYU16, + SDL_PIXELTYPE_ARRAYU32, + SDL_PIXELTYPE_ARRAYF16, + SDL_PIXELTYPE_ARRAYF32 +}; + +/** Bitmap pixel order, high bit -> low bit. */ +enum +{ + SDL_BITMAPORDER_NONE, + SDL_BITMAPORDER_4321, + SDL_BITMAPORDER_1234 +}; + +/** Packed component order, high bit -> low bit. */ +enum +{ + SDL_PACKEDORDER_NONE, + SDL_PACKEDORDER_XRGB, + SDL_PACKEDORDER_RGBX, + SDL_PACKEDORDER_ARGB, + SDL_PACKEDORDER_RGBA, + SDL_PACKEDORDER_XBGR, + SDL_PACKEDORDER_BGRX, + SDL_PACKEDORDER_ABGR, + SDL_PACKEDORDER_BGRA +}; + +/** Array component order, low byte -> high byte. */ +/* !!! FIXME: in 2.1, make these not overlap differently with + !!! FIXME: SDL_PACKEDORDER_*, so we can simplify SDL_ISPIXELFORMAT_ALPHA */ +enum +{ + SDL_ARRAYORDER_NONE, + SDL_ARRAYORDER_RGB, + SDL_ARRAYORDER_RGBA, + SDL_ARRAYORDER_ARGB, + SDL_ARRAYORDER_BGR, + SDL_ARRAYORDER_BGRA, + SDL_ARRAYORDER_ABGR +}; + +/** Packed component layout. */ +enum +{ + SDL_PACKEDLAYOUT_NONE, + SDL_PACKEDLAYOUT_332, + SDL_PACKEDLAYOUT_4444, + SDL_PACKEDLAYOUT_1555, + SDL_PACKEDLAYOUT_5551, + SDL_PACKEDLAYOUT_565, + SDL_PACKEDLAYOUT_8888, + SDL_PACKEDLAYOUT_2101010, + SDL_PACKEDLAYOUT_1010102 +}; + +#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D) + +#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \ + ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \ + ((bits) << 8) | ((bytes) << 0)) + +#define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F) +#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F) +#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F) +#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F) +#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF) +#define SDL_BYTESPERPIXEL(X) \ + (SDL_ISPIXELFORMAT_FOURCC(X) ? \ + ((((X) == SDL_PIXELFORMAT_YUY2) || \ + ((X) == SDL_PIXELFORMAT_UYVY) || \ + ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF)) + +#define SDL_ISPIXELFORMAT_INDEXED(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) + +#define SDL_ISPIXELFORMAT_PACKED(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32))) + +#define SDL_ISPIXELFORMAT_ARRAY(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32))) + +#define SDL_ISPIXELFORMAT_ALPHA(format) \ + ((SDL_ISPIXELFORMAT_PACKED(format) && \ + ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \ + (SDL_ISPIXELFORMAT_ARRAY(format) && \ + ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \ + (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \ + (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \ + (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA)))) + +/* The flag is set to 1 because 0x1? is not in the printable ASCII range */ +#define SDL_ISPIXELFORMAT_FOURCC(format) \ + ((format) && (SDL_PIXELFLAG(format) != 1)) + +/* Note: If you modify this list, update SDL_GetPixelFormatName() */ +enum +{ + SDL_PIXELFORMAT_UNKNOWN, + SDL_PIXELFORMAT_INDEX1LSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, + 1, 0), + SDL_PIXELFORMAT_INDEX1MSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, + 1, 0), + SDL_PIXELFORMAT_INDEX4LSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, + 4, 0), + SDL_PIXELFORMAT_INDEX4MSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, + 4, 0), + SDL_PIXELFORMAT_INDEX8 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), + SDL_PIXELFORMAT_RGB332 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_332, 8, 1), + SDL_PIXELFORMAT_RGB444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_4444, 12, 2), + SDL_PIXELFORMAT_RGB555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_1555, 15, 2), + SDL_PIXELFORMAT_BGR555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_1555, 15, 2), + SDL_PIXELFORMAT_ARGB4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_RGBA4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_ABGR4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_BGRA4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_ARGB1555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_1555, 16, 2), + SDL_PIXELFORMAT_RGBA5551 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_5551, 16, 2), + SDL_PIXELFORMAT_ABGR1555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_1555, 16, 2), + SDL_PIXELFORMAT_BGRA5551 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_5551, 16, 2), + SDL_PIXELFORMAT_RGB565 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_565, 16, 2), + SDL_PIXELFORMAT_BGR565 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_565, 16, 2), + SDL_PIXELFORMAT_RGB24 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, + 24, 3), + SDL_PIXELFORMAT_BGR24 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, + 24, 3), + SDL_PIXELFORMAT_RGB888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_RGBX8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_BGR888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_BGRX8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_ARGB8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_RGBA8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_ABGR8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_BGRA8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_ARGB2101010 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_2101010, 32, 4), + + SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */ + SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), + SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */ + SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), + SDL_PIXELFORMAT_YUY2 = /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), + SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), + SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'), + SDL_PIXELFORMAT_NV12 = /**< Planar mode: Y + U/V interleaved (2 planes) */ + SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'), + SDL_PIXELFORMAT_NV21 = /**< Planar mode: Y + V/U interleaved (2 planes) */ + SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1') +}; + +typedef struct SDL_Color +{ + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 a; +} SDL_Color; +#define SDL_Colour SDL_Color + +typedef struct SDL_Palette +{ + int ncolors; + SDL_Color *colors; + Uint32 version; + int refcount; +} SDL_Palette; + +/** + * \note Everything in the pixel format structure is read-only. + */ +typedef struct SDL_PixelFormat +{ + Uint32 format; + SDL_Palette *palette; + Uint8 BitsPerPixel; + Uint8 BytesPerPixel; + Uint8 padding[2]; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; + Uint8 Rloss; + Uint8 Gloss; + Uint8 Bloss; + Uint8 Aloss; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; + int refcount; + struct SDL_PixelFormat *next; +} SDL_PixelFormat; + +/** + * \brief Get the human readable name of a pixel format + */ +extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format); + +/** + * \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks. + * + * \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible. + * + * \sa SDL_MasksToPixelFormatEnum() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, + int *bpp, + Uint32 * Rmask, + Uint32 * Gmask, + Uint32 * Bmask, + Uint32 * Amask); + +/** + * \brief Convert a bpp and RGBA masks to an enumerated pixel format. + * + * \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion + * wasn't possible. + * + * \sa SDL_PixelFormatEnumToMasks() + */ +extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, + Uint32 Rmask, + Uint32 Gmask, + Uint32 Bmask, + Uint32 Amask); + +/** + * \brief Create an SDL_PixelFormat structure from a pixel format enum. + */ +extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); + +/** + * \brief Free an SDL_PixelFormat structure. + */ +extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); + +/** + * \brief Create a palette structure with the specified number of color + * entries. + * + * \return A new palette, or NULL if there wasn't enough memory. + * + * \note The palette entries are initialized to white. + * + * \sa SDL_FreePalette() + */ +extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); + +/** + * \brief Set the palette for a pixel format structure. + */ +extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, + SDL_Palette *palette); + +/** + * \brief Set a range of colors in a palette. + * + * \param palette The palette to modify. + * \param colors An array of colors to copy into the palette. + * \param firstcolor The index of the first palette entry to modify. + * \param ncolors The number of entries to modify. + * + * \return 0 on success, or -1 if not all of the colors could be set. + */ +extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, + const SDL_Color * colors, + int firstcolor, int ncolors); + +/** + * \brief Free a palette created with SDL_AllocPalette(). + * + * \sa SDL_AllocPalette() + */ +extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); + +/** + * \brief Maps an RGB triple to an opaque pixel value for a given pixel format. + * + * \sa SDL_MapRGBA + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format, + Uint8 r, Uint8 g, Uint8 b); + +/** + * \brief Maps an RGBA quadruple to a pixel value for a given pixel format. + * + * \sa SDL_MapRGB + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format, + Uint8 r, Uint8 g, Uint8 b, + Uint8 a); + +/** + * \brief Get the RGB components from a pixel of the specified format. + * + * \sa SDL_GetRGBA + */ +extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, + const SDL_PixelFormat * format, + Uint8 * r, Uint8 * g, Uint8 * b); + +/** + * \brief Get the RGBA components from a pixel of the specified format. + * + * \sa SDL_GetRGB + */ +extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, + const SDL_PixelFormat * format, + Uint8 * r, Uint8 * g, Uint8 * b, + Uint8 * a); + +/** + * \brief Calculate a 256 entry gamma ramp for a gamma value. + */ +extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_pixels_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_platform.h b/#ThirdParty/libSDL/include/SDL_platform.h new file mode 100644 index 0000000..c6c2139 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_platform.h @@ -0,0 +1,181 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_platform.h + * + * Try to get a standard set of platform defines. + */ + +#ifndef _SDL_platform_h +#define _SDL_platform_h + +#if defined(_AIX) +#undef __AIX__ +#define __AIX__ 1 +#endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif +#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) +#undef __BSDI__ +#define __BSDI__ 1 +#endif +#if defined(_arch_dreamcast) +#undef __DREAMCAST__ +#define __DREAMCAST__ 1 +#endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#undef __FREEBSD__ +#define __FREEBSD__ 1 +#endif +#if defined(hpux) || defined(__hpux) || defined(__hpux__) +#undef __HPUX__ +#define __HPUX__ 1 +#endif +#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) +#undef __IRIX__ +#define __IRIX__ 1 +#endif +#if (defined(linux) || defined(__linux) || defined(__linux__)) +#undef __LINUX__ +#define __LINUX__ 1 +#endif +#if defined(ANDROID) || defined(__ANDROID__) +#undef __ANDROID__ +#undef __LINUX__ /* do we need to do this? */ +#define __ANDROID__ 1 +#endif + +#if defined(__APPLE__) +/* lets us know what version of Mac OS X we're compiling on */ +#include "AvailabilityMacros.h" +#include "TargetConditionals.h" +#if TARGET_OS_IPHONE +/* if compiling for iPhone */ +#undef __IPHONEOS__ +#define __IPHONEOS__ 1 +#undef __MACOSX__ +#else +/* if not compiling for iPhone */ +#undef __MACOSX__ +#define __MACOSX__ 1 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +# error SDL for Mac OS X only supports deploying on 10.5 and above. +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */ +#endif /* TARGET_OS_IPHONE */ +#endif /* defined(__APPLE__) */ + +#if defined(__NetBSD__) +#undef __NETBSD__ +#define __NETBSD__ 1 +#endif +#if defined(__OpenBSD__) +#undef __OPENBSD__ +#define __OPENBSD__ 1 +#endif +#if defined(__OS2__) +#undef __OS2__ +#define __OS2__ 1 +#endif +#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) +#undef __OSF__ +#define __OSF__ 1 +#endif +#if defined(__QNXNTO__) +#undef __QNXNTO__ +#define __QNXNTO__ 1 +#endif +#if defined(riscos) || defined(__riscos) || defined(__riscos__) +#undef __RISCOS__ +#define __RISCOS__ 1 +#endif +#if defined(__sun) && defined(__SVR4) +#undef __SOLARIS__ +#define __SOLARIS__ 1 +#endif + +#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) +/* Try to find out if we're compiling for WinRT or non-WinRT */ +/* If _USING_V110_SDK71_ is defined it means we are using the v110_xp or v120_xp toolset. */ +#if (defined(_MSC_VER) && (_MSC_VER >= 1700) && !_USING_V110_SDK71_) /* _MSC_VER==1700 for MSVC 2012 */ +#include +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#undef __WINDOWS__ +#define __WINDOWS__ 1 +/* See if we're compiling for WinRT: */ +#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +#undef __WINRT__ +#define __WINRT__ 1 +#endif +#else +#undef __WINDOWS__ +#define __WINDOWS__ 1 +#endif /* _MSC_VER < 1700 */ +#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ + +#if defined(__WINDOWS__) +#undef __WIN32__ +#define __WIN32__ 1 +#endif +#if defined(__PSP__) +#undef __PSP__ +#define __PSP__ 1 +#endif + +/* The NACL compiler defines __native_client__ and __pnacl__ + * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi + */ +#if defined(__native_client__) +#undef __LINUX__ +#undef __NACL__ +#define __NACL__ 1 +#endif +#if defined(__pnacl__) +#undef __LINUX__ +#undef __PNACL__ +#define __PNACL__ 1 +/* PNACL with newlib supports static linking only */ +#define __SDL_NOGETPROCADDR__ +#endif + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Gets the name of the platform. + */ +extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_platform_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_power.h b/#ThirdParty/libSDL/include/SDL_power.h new file mode 100644 index 0000000..24c0501 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_power.h @@ -0,0 +1,75 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_power_h +#define _SDL_power_h + +/** + * \file SDL_power.h + * + * Header for the SDL power management routines. + */ + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The basic state for the system's power supply. + */ +typedef enum +{ + SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ + SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ + SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ + SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ + SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ +} SDL_PowerState; + + +/** + * \brief Get the current power supply details. + * + * \param secs Seconds of battery life left. You can pass a NULL here if + * you don't care. Will return -1 if we can't determine a + * value, or we're not running on a battery. + * + * \param pct Percentage of battery life left, between 0 and 100. You can + * pass a NULL here if you don't care. Will return -1 if we + * can't determine a value, or we're not running on a battery. + * + * \return The state of the battery (if any). + */ +extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_power_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_quit.h b/#ThirdParty/libSDL/include/SDL_quit.h new file mode 100644 index 0000000..cc06f28 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_quit.h @@ -0,0 +1,58 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_quit.h + * + * Include file for SDL quit event handling. + */ + +#ifndef _SDL_quit_h +#define _SDL_quit_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/** + * \file SDL_quit.h + * + * An ::SDL_QUIT event is generated when the user tries to close the application + * window. If it is ignored or filtered out, the window will remain open. + * If it is not ignored or filtered, it is queued normally and the window + * is allowed to close. When the window is closed, screen updates will + * complete, but have no effect. + * + * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) + * and SIGTERM (system termination request), if handlers do not already + * exist, that generate ::SDL_QUIT events as well. There is no way + * to determine the cause of an ::SDL_QUIT event, but setting a signal + * handler in your application will override the default generation of + * quit events for that signal. + * + * \sa SDL_Quit() + */ + +/* There are no functions directly affecting the quit event */ + +#define SDL_QuitRequested() \ + (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) + +#endif /* _SDL_quit_h */ diff --git a/#ThirdParty/libSDL/include/SDL_rect.h b/#ThirdParty/libSDL/include/SDL_rect.h new file mode 100644 index 0000000..bbcb9a3 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_rect.h @@ -0,0 +1,148 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_rect.h + * + * Header file for SDL_rect definition and management functions. + */ + +#ifndef _SDL_rect_h +#define _SDL_rect_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_pixels.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The structure that defines a point + * + * \sa SDL_EnclosePoints + * \sa SDL_PointInRect + */ +typedef struct SDL_Point +{ + int x; + int y; +} SDL_Point; + +/** + * \brief A rectangle, with the origin at the upper left. + * + * \sa SDL_RectEmpty + * \sa SDL_RectEquals + * \sa SDL_HasIntersection + * \sa SDL_IntersectRect + * \sa SDL_UnionRect + * \sa SDL_EnclosePoints + */ +typedef struct SDL_Rect +{ + int x, y; + int w, h; +} SDL_Rect; + +/** + * \brief Returns true if point resides inside a rectangle. + */ +SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) +{ + return ( (p->x >= r->x) && (p->x < (r->x + r->w)) && + (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE; +} + +/** + * \brief Returns true if the rectangle has no area. + */ +SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r) +{ + return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE; +} + +/** + * \brief Returns true if the two rectangles are equal. + */ +SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) +{ + return (a && b && (a->x == b->x) && (a->y == b->y) && + (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE; +} + +/** + * \brief Determine whether two rectangles intersect. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, + const SDL_Rect * B); + +/** + * \brief Calculate the intersection of two rectangles. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, + const SDL_Rect * B, + SDL_Rect * result); + +/** + * \brief Calculate the union of two rectangles. + */ +extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, + const SDL_Rect * B, + SDL_Rect * result); + +/** + * \brief Calculate a minimal rectangle enclosing a set of points + * + * \return SDL_TRUE if any points were within the clipping rect + */ +extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, + int count, + const SDL_Rect * clip, + SDL_Rect * result); + +/** + * \brief Calculate the intersection of a rectangle and line segment. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * + rect, int *X1, + int *Y1, int *X2, + int *Y2); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_rect_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_render.h b/#ThirdParty/libSDL/include/SDL_render.h new file mode 100644 index 0000000..e4ed2af --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_render.h @@ -0,0 +1,880 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_render.h + * + * Header file for SDL 2D rendering functions. + * + * This API supports the following features: + * * single pixel points + * * single pixel lines + * * filled rectangles + * * texture images + * + * The primitives may be drawn in opaque, blended, or additive modes. + * + * The texture images may be drawn in opaque, blended, or additive modes. + * They can have an additional color tint or alpha modulation applied to + * them, and may also be stretched with linear interpolation. + * + * This API is designed to accelerate simple 2D operations. You may + * want more functionality such as polygons and particle effects and + * in that case you should use SDL's OpenGL/Direct3D support or one + * of the many good 3D engines. + * + * These functions must be called from the main thread. + * See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995 + */ + +#ifndef _SDL_render_h +#define _SDL_render_h + +#include "SDL_stdinc.h" +#include "SDL_rect.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Flags used when creating a rendering context + */ +typedef enum +{ + SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ + SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware + acceleration */ + SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized + with the refresh rate */ + SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports + rendering to texture */ +} SDL_RendererFlags; + +/** + * \brief Information on the capabilities of a render driver or context. + */ +typedef struct SDL_RendererInfo +{ + const char *name; /**< The name of the renderer */ + Uint32 flags; /**< Supported ::SDL_RendererFlags */ + Uint32 num_texture_formats; /**< The number of available texture formats */ + Uint32 texture_formats[16]; /**< The available texture formats */ + int max_texture_width; /**< The maximum texture width */ + int max_texture_height; /**< The maximum texture height */ +} SDL_RendererInfo; + +/** + * \brief The access pattern allowed for a texture. + */ +typedef enum +{ + SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ + SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */ + SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ +} SDL_TextureAccess; + +/** + * \brief The texture channel modulation used in SDL_RenderCopy(). + */ +typedef enum +{ + SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */ + SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */ + SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */ +} SDL_TextureModulate; + +/** + * \brief Flip constants for SDL_RenderCopyEx + */ +typedef enum +{ + SDL_FLIP_NONE = 0x00000000, /**< Do not flip */ + SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */ + SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */ +} SDL_RendererFlip; + +/** + * \brief A structure representing rendering state + */ +struct SDL_Renderer; +typedef struct SDL_Renderer SDL_Renderer; + +/** + * \brief An efficient driver-specific representation of pixel data + */ +struct SDL_Texture; +typedef struct SDL_Texture SDL_Texture; + + +/* Function prototypes */ + +/** + * \brief Get the number of 2D rendering drivers available for the current + * display. + * + * A render driver is a set of code that handles rendering and texture + * management on a particular display. Normally there is only one, but + * some drivers may have several available with different capabilities. + * + * \sa SDL_GetRenderDriverInfo() + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); + +/** + * \brief Get information about a specific 2D rendering driver for the current + * display. + * + * \param index The index of the driver to query information about. + * \param info A pointer to an SDL_RendererInfo struct to be filled with + * information on the rendering driver. + * + * \return 0 on success, -1 if the index was out of range. + * + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, + SDL_RendererInfo * info); + +/** + * \brief Create a window and default renderer + * + * \param width The width of the window + * \param height The height of the window + * \param window_flags The flags used to create the window + * \param window A pointer filled with the window, or NULL on error + * \param renderer A pointer filled with the renderer, or NULL on error + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer( + int width, int height, Uint32 window_flags, + SDL_Window **window, SDL_Renderer **renderer); + + +/** + * \brief Create a 2D rendering context for a window. + * + * \param window The window where rendering is displayed. + * \param index The index of the rendering driver to initialize, or -1 to + * initialize the first one supporting the requested flags. + * \param flags ::SDL_RendererFlags. + * + * \return A valid rendering context or NULL if there was an error. + * + * \sa SDL_CreateSoftwareRenderer() + * \sa SDL_GetRendererInfo() + * \sa SDL_DestroyRenderer() + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window, + int index, Uint32 flags); + +/** + * \brief Create a 2D software rendering context for a surface. + * + * \param surface The surface where rendering is done. + * + * \return A valid rendering context or NULL if there was an error. + * + * \sa SDL_CreateRenderer() + * \sa SDL_DestroyRenderer() + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface); + +/** + * \brief Get the renderer associated with a window. + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window); + +/** + * \brief Get information about a rendering context. + */ +extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, + SDL_RendererInfo * info); + +/** + * \brief Get the output size in pixels of a rendering context. + */ +extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer, + int *w, int *h); + +/** + * \brief Create a texture for a rendering context. + * + * \param renderer The renderer. + * \param format The format of the texture. + * \param access One of the enumerated values in ::SDL_TextureAccess. + * \param w The width of the texture in pixels. + * \param h The height of the texture in pixels. + * + * \return The created texture is returned, or NULL if no rendering context was + * active, the format was unsupported, or the width or height were out + * of range. + * + * \sa SDL_QueryTexture() + * \sa SDL_UpdateTexture() + * \sa SDL_DestroyTexture() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, + Uint32 format, + int access, int w, + int h); + +/** + * \brief Create a texture from an existing surface. + * + * \param renderer The renderer. + * \param surface The surface containing pixel data used to fill the texture. + * + * \return The created texture is returned, or NULL on error. + * + * \note The surface is not modified or freed by this function. + * + * \sa SDL_QueryTexture() + * \sa SDL_DestroyTexture() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface); + +/** + * \brief Query the attributes of a texture + * + * \param texture A texture to be queried. + * \param format A pointer filled in with the raw format of the texture. The + * actual format may differ, but pixel transfers will use this + * format. + * \param access A pointer filled in with the actual access to the texture. + * \param w A pointer filled in with the width of the texture in pixels. + * \param h A pointer filled in with the height of the texture in pixels. + * + * \return 0 on success, or -1 if the texture is not valid. + */ +extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, + Uint32 * format, int *access, + int *w, int *h); + +/** + * \brief Set an additional color value used in render copy operations. + * + * \param texture The texture to update. + * \param r The red color value multiplied into copy operations. + * \param g The green color value multiplied into copy operations. + * \param b The blue color value multiplied into copy operations. + * + * \return 0 on success, or -1 if the texture is not valid or color modulation + * is not supported. + * + * \sa SDL_GetTextureColorMod() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, + Uint8 r, Uint8 g, Uint8 b); + + +/** + * \brief Get the additional color value used in render copy operations. + * + * \param texture The texture to query. + * \param r A pointer filled in with the current red color value. + * \param g A pointer filled in with the current green color value. + * \param b A pointer filled in with the current blue color value. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureColorMod() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, + Uint8 * r, Uint8 * g, + Uint8 * b); + +/** + * \brief Set an additional alpha value used in render copy operations. + * + * \param texture The texture to update. + * \param alpha The alpha value multiplied into copy operations. + * + * \return 0 on success, or -1 if the texture is not valid or alpha modulation + * is not supported. + * + * \sa SDL_GetTextureAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, + Uint8 alpha); + +/** + * \brief Get the additional alpha value used in render copy operations. + * + * \param texture The texture to query. + * \param alpha A pointer filled in with the current alpha value. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, + Uint8 * alpha); + +/** + * \brief Set the blend mode used for texture copy operations. + * + * \param texture The texture to update. + * \param blendMode ::SDL_BlendMode to use for texture blending. + * + * \return 0 on success, or -1 if the texture is not valid or the blend mode is + * not supported. + * + * \note If the blend mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetTextureBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for texture copy operations. + * + * \param texture The texture to query. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, + SDL_BlendMode *blendMode); + +/** + * \brief Update the given texture rectangle with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param pixels The raw pixel data. + * \param pitch The number of bytes in a row of pixel data, including padding between lines. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note This is a fairly slow function. + */ +extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const void *pixels, int pitch); + +/** + * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param Yplane The raw pixel data for the Y plane. + * \param Ypitch The number of bytes between rows of pixel data for the Y plane. + * \param Uplane The raw pixel data for the U plane. + * \param Upitch The number of bytes between rows of pixel data for the U plane. + * \param Vplane The raw pixel data for the V plane. + * \param Vpitch The number of bytes between rows of pixel data for the V plane. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note You can use SDL_UpdateTexture() as long as your pixel data is + * a contiguous block of Y and U/V planes in the proper order, but + * this function is available if your pixel data is not contiguous. + */ +extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); + +/** + * \brief Lock a portion of the texture for write-only pixel access. + * + * \param texture The texture to lock for access, which was created with + * ::SDL_TEXTUREACCESS_STREAMING. + * \param rect A pointer to the rectangle to lock for access. If the rect + * is NULL, the entire texture will be locked. + * \param pixels This is filled in with a pointer to the locked pixels, + * appropriately offset by the locked area. + * \param pitch This is filled in with the pitch of the locked pixels. + * + * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. + * + * \sa SDL_UnlockTexture() + */ +extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, + const SDL_Rect * rect, + void **pixels, int *pitch); + +/** + * \brief Unlock a texture, uploading the changes to video memory, if needed. + * + * \sa SDL_LockTexture() + */ +extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); + +/** + * \brief Determines whether a window supports the use of render targets + * + * \param renderer The renderer that will be checked + * + * \return SDL_TRUE if supported, SDL_FALSE if not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer); + +/** + * \brief Set a texture as the current rendering target. + * + * \param renderer The renderer. + * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target + * + * \return 0 on success, or -1 on error + * + * \sa SDL_GetRenderTarget() + */ +extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, + SDL_Texture *texture); + +/** + * \brief Get the current render target or NULL for the default render target. + * + * \return The current render target + * + * \sa SDL_SetRenderTarget() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); + +/** + * \brief Set device independent resolution for rendering + * + * \param renderer The renderer for which resolution should be set. + * \param w The width of the logical resolution + * \param h The height of the logical resolution + * + * This function uses the viewport and scaling functionality to allow a fixed logical + * resolution for rendering, regardless of the actual output resolution. If the actual + * output resolution doesn't have the same aspect ratio the output rendering will be + * centered within the output display. + * + * If the output display is a window, mouse events in the window will be filtered + * and scaled so they seem to arrive within the logical resolution. + * + * \note If this function results in scaling or subpixel drawing by the + * rendering backend, it will be handled using the appropriate + * quality hints. + * + * \sa SDL_RenderGetLogicalSize() + * \sa SDL_RenderSetScale() + * \sa SDL_RenderSetViewport() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h); + +/** + * \brief Get device independent resolution for rendering + * + * \param renderer The renderer from which resolution should be queried. + * \param w A pointer filled with the width of the logical resolution + * \param h A pointer filled with the height of the logical resolution + * + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h); + +/** + * \brief Set the drawing area for rendering on the current target. + * + * \param renderer The renderer for which the drawing area should be set. + * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target. + * + * The x,y of the viewport rect represents the origin for rendering. + * + * \return 0 on success, or -1 on error + * + * \note If the window associated with the renderer is resized, the viewport is automatically reset. + * + * \sa SDL_RenderGetViewport() + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Get the drawing area for the current target. + * + * \sa SDL_RenderSetViewport() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, + SDL_Rect * rect); + +/** + * \brief Set the clip rectangle for the current target. + * + * \param renderer The renderer for which clip rectangle should be set. + * \param rect A pointer to the rectangle to set as the clip rectangle, or + * NULL to disable clipping. + * + * \return 0 on success, or -1 on error + * + * \sa SDL_RenderGetClipRect() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Get the clip rectangle for the current target. + * + * \param renderer The renderer from which clip rectangle should be queried. + * \param rect A pointer filled in with the current clip rectangle, or + * an empty rectangle if clipping is disabled. + * + * \sa SDL_RenderSetClipRect() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer, + SDL_Rect * rect); + +/** + * \brief Get whether clipping is enabled on the given renderer. + * + * \param renderer The renderer from which clip state should be queried. + * + * \sa SDL_RenderGetClipRect() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer); + + +/** + * \brief Set the drawing scale for rendering on the current target. + * + * \param renderer The renderer for which the drawing scale should be set. + * \param scaleX The horizontal scaling factor + * \param scaleY The vertical scaling factor + * + * The drawing coordinates are scaled by the x/y scaling factors + * before they are used by the renderer. This allows resolution + * independent drawing with a single coordinate system. + * + * \note If this results in scaling or subpixel drawing by the + * rendering backend, it will be handled using the appropriate + * quality hints. For best results use integer scaling factors. + * + * \sa SDL_RenderGetScale() + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer, + float scaleX, float scaleY); + +/** + * \brief Get the drawing scale for the current target. + * + * \param renderer The renderer from which drawing scale should be queried. + * \param scaleX A pointer filled in with the horizontal scaling factor + * \param scaleY A pointer filled in with the vertical scaling factor + * + * \sa SDL_RenderSetScale() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer, + float *scaleX, float *scaleY); + +/** + * \brief Set the color used for drawing operations (Rect, Line and Clear). + * + * \param renderer The renderer for which drawing color should be set. + * \param r The red value used to draw on the rendering target. + * \param g The green value used to draw on the rendering target. + * \param b The blue value used to draw on the rendering target. + * \param a The alpha value used to draw on the rendering target, usually + * ::SDL_ALPHA_OPAQUE (255). + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer, + Uint8 r, Uint8 g, Uint8 b, + Uint8 a); + +/** + * \brief Get the color used for drawing operations (Rect, Line and Clear). + * + * \param renderer The renderer from which drawing color should be queried. + * \param r A pointer to the red value used to draw on the rendering target. + * \param g A pointer to the green value used to draw on the rendering target. + * \param b A pointer to the blue value used to draw on the rendering target. + * \param a A pointer to the alpha value used to draw on the rendering target, + * usually ::SDL_ALPHA_OPAQUE (255). + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer, + Uint8 * r, Uint8 * g, Uint8 * b, + Uint8 * a); + +/** + * \brief Set the blend mode used for drawing operations (Fill and Line). + * + * \param renderer The renderer for which blend mode should be set. + * \param blendMode ::SDL_BlendMode to use for blending. + * + * \return 0 on success, or -1 on error + * + * \note If the blend mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetRenderDrawBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for drawing operations. + * + * \param renderer The renderer from which blend mode should be queried. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 on error + * + * \sa SDL_SetRenderDrawBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, + SDL_BlendMode *blendMode); + +/** + * \brief Clear the current rendering target with the drawing color + * + * This function clears the entire rendering target, ignoring the viewport. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer); + +/** + * \brief Draw a point on the current rendering target. + * + * \param renderer The renderer which should draw a point. + * \param x The x coordinate of the point. + * \param y The y coordinate of the point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, + int x, int y); + +/** + * \brief Draw multiple points on the current rendering target. + * + * \param renderer The renderer which should draw multiple points. + * \param points The points to draw + * \param count The number of points to draw + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, + int count); + +/** + * \brief Draw a line on the current rendering target. + * + * \param renderer The renderer which should draw a line. + * \param x1 The x coordinate of the start point. + * \param y1 The y coordinate of the start point. + * \param x2 The x coordinate of the end point. + * \param y2 The y coordinate of the end point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, + int x1, int y1, int x2, int y2); + +/** + * \brief Draw a series of connected lines on the current rendering target. + * + * \param renderer The renderer which should draw multiple lines. + * \param points The points along the lines + * \param count The number of points, drawing count-1 lines + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, + int count); + +/** + * \brief Draw a rectangle on the current rendering target. + * + * \param renderer The renderer which should draw a rectangle. + * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Draw some number of rectangles on the current rendering target. + * + * \param renderer The renderer which should draw multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, + const SDL_Rect * rects, + int count); + +/** + * \brief Fill a rectangle on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill a rectangle. + * \param rect A pointer to the destination rectangle, or NULL for the entire + * rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect * rects, + int count); + +/** + * \brief Copy a portion of the texture to the current rendering target. + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect); + +/** + * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect + * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). + * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect, + const double angle, + const SDL_Point *center, + const SDL_RendererFlip flip); + +/** + * \brief Read pixels from the current rendering target. + * + * \param renderer The renderer from which pixels should be read. + * \param rect A pointer to the rectangle to read, or NULL for the entire + * render target. + * \param format The desired format of the pixel data, or 0 to use the format + * of the rendering target + * \param pixels A pointer to be filled in with the pixel data + * \param pitch The pitch of the pixels parameter. + * + * \return 0 on success, or -1 if pixel reading is not supported. + * + * \warning This is a very slow operation, and should not be used frequently. + */ +extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, + const SDL_Rect * rect, + Uint32 format, + void *pixels, int pitch); + +/** + * \brief Update the screen with rendering performed. + */ +extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer); + +/** + * \brief Destroy the specified texture. + * + * \sa SDL_CreateTexture() + * \sa SDL_CreateTextureFromSurface() + */ +extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); + +/** + * \brief Destroy the rendering context for a window and free associated + * textures. + * + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); + + +/** + * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with + * OpenGL instructions. + * + * \param texture The SDL texture to bind + * \param texw A pointer to a float that will be filled with the texture width + * \param texh A pointer to a float that will be filled with the texture height + * + * \return 0 on success, or -1 if the operation is not supported + */ +extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh); + +/** + * \brief Unbind a texture from the current OpenGL/ES/ES2 context. + * + * \param texture The SDL texture to unbind + * + * \return 0 on success, or -1 if the operation is not supported + */ +extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_render_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_revision.h b/#ThirdParty/libSDL/include/SDL_revision.h new file mode 100644 index 0000000..6d7163d --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_revision.h @@ -0,0 +1,2 @@ +#define SDL_REVISION "hg-10001:e12c38730512" +#define SDL_REVISION_NUMBER 10001 diff --git a/#ThirdParty/libSDL/include/SDL_rwops.h b/#ThirdParty/libSDL/include/SDL_rwops.h new file mode 100644 index 0000000..f460ae7 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_rwops.h @@ -0,0 +1,231 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_rwops.h + * + * This file provides a general interface for SDL to read and write + * data streams. It can easily be extended to files, memory, etc. + */ + +#ifndef _SDL_rwops_h +#define _SDL_rwops_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* RWops Types */ +#define SDL_RWOPS_UNKNOWN 0 /* Unknown stream type */ +#define SDL_RWOPS_WINFILE 1 /* Win32 file */ +#define SDL_RWOPS_STDFILE 2 /* Stdio file */ +#define SDL_RWOPS_JNIFILE 3 /* Android asset */ +#define SDL_RWOPS_MEMORY 4 /* Memory stream */ +#define SDL_RWOPS_MEMORY_RO 5 /* Read-Only memory stream */ + +/** + * This is the read/write operation structure -- very basic. + */ +typedef struct SDL_RWops +{ + /** + * Return the size of the file in this rwops, or -1 if unknown + */ + Sint64 (SDLCALL * size) (struct SDL_RWops * context); + + /** + * Seek to \c offset relative to \c whence, one of stdio's whence values: + * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END + * + * \return the final offset in the data stream, or -1 on error. + */ + Sint64 (SDLCALL * seek) (struct SDL_RWops * context, Sint64 offset, + int whence); + + /** + * Read up to \c maxnum objects each of size \c size from the data + * stream to the area pointed at by \c ptr. + * + * \return the number of objects read, or 0 at error or end of file. + */ + size_t (SDLCALL * read) (struct SDL_RWops * context, void *ptr, + size_t size, size_t maxnum); + + /** + * Write exactly \c num objects each of size \c size from the area + * pointed at by \c ptr to data stream. + * + * \return the number of objects written, or 0 at error or end of file. + */ + size_t (SDLCALL * write) (struct SDL_RWops * context, const void *ptr, + size_t size, size_t num); + + /** + * Close and free an allocated SDL_RWops structure. + * + * \return 0 if successful or -1 on write error when flushing data. + */ + int (SDLCALL * close) (struct SDL_RWops * context); + + Uint32 type; + union + { +#if defined(__ANDROID__) + struct + { + void *fileNameRef; + void *inputStreamRef; + void *readableByteChannelRef; + void *readMethod; + void *assetFileDescriptorRef; + long position; + long size; + long offset; + int fd; + } androidio; +#elif defined(__WIN32__) + struct + { + SDL_bool append; + void *h; + struct + { + void *data; + size_t size; + size_t left; + } buffer; + } windowsio; +#endif + +#ifdef HAVE_STDIO_H + struct + { + SDL_bool autoclose; + FILE *fp; + } stdio; +#endif + struct + { + Uint8 *base; + Uint8 *here; + Uint8 *stop; + } mem; + struct + { + void *data1; + void *data2; + } unknown; + } hidden; + +} SDL_RWops; + + +/** + * \name RWFrom functions + * + * Functions to create SDL_RWops structures from various data streams. + */ +/* @{ */ + +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, + const char *mode); + +#ifdef HAVE_STDIO_H +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, + SDL_bool autoclose); +#else +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp, + SDL_bool autoclose); +#endif + +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, + int size); + +/* @} *//* RWFrom functions */ + + +extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); +extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); + +#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ +#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ +#define RW_SEEK_END 2 /**< Seek relative to the end of data */ + +/** + * \name Read/write macros + * + * Macros to easily read and write from an SDL_RWops structure. + */ +/* @{ */ +#define SDL_RWsize(ctx) (ctx)->size(ctx) +#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) +#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) +#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) +#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) +#define SDL_RWclose(ctx) (ctx)->close(ctx) +/* @} *//* Read/write macros */ + + +/** + * \name Read endian functions + * + * Read an item of the specified endianness and return in native format. + */ +/* @{ */ +extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); +/* @} *//* Read endian functions */ + +/** + * \name Write endian functions + * + * Write an item of native format to the specified endianness. + */ +/* @{ */ +extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); +/* @} *//* Write endian functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_rwops_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_scancode.h b/#ThirdParty/libSDL/include/SDL_scancode.h new file mode 100644 index 0000000..0af1dd5 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_scancode.h @@ -0,0 +1,401 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_scancode.h + * + * Defines keyboard scancodes. + */ + +#ifndef _SDL_scancode_h +#define _SDL_scancode_h + +#include "SDL_stdinc.h" + +/** + * \brief The SDL keyboard scancode representation. + * + * Values of this type are used to represent keyboard keys, among other places + * in the \link SDL_Keysym::scancode key.keysym.scancode \endlink field of the + * SDL_Event structure. + * + * The values in this enumeration are based on the USB usage page standard: + * http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf + */ +typedef enum +{ + SDL_SCANCODE_UNKNOWN = 0, + + /** + * \name Usage page 0x07 + * + * These values are from usage page 0x07 (USB keyboard page). + */ + /* @{ */ + + SDL_SCANCODE_A = 4, + SDL_SCANCODE_B = 5, + SDL_SCANCODE_C = 6, + SDL_SCANCODE_D = 7, + SDL_SCANCODE_E = 8, + SDL_SCANCODE_F = 9, + SDL_SCANCODE_G = 10, + SDL_SCANCODE_H = 11, + SDL_SCANCODE_I = 12, + SDL_SCANCODE_J = 13, + SDL_SCANCODE_K = 14, + SDL_SCANCODE_L = 15, + SDL_SCANCODE_M = 16, + SDL_SCANCODE_N = 17, + SDL_SCANCODE_O = 18, + SDL_SCANCODE_P = 19, + SDL_SCANCODE_Q = 20, + SDL_SCANCODE_R = 21, + SDL_SCANCODE_S = 22, + SDL_SCANCODE_T = 23, + SDL_SCANCODE_U = 24, + SDL_SCANCODE_V = 25, + SDL_SCANCODE_W = 26, + SDL_SCANCODE_X = 27, + SDL_SCANCODE_Y = 28, + SDL_SCANCODE_Z = 29, + + SDL_SCANCODE_1 = 30, + SDL_SCANCODE_2 = 31, + SDL_SCANCODE_3 = 32, + SDL_SCANCODE_4 = 33, + SDL_SCANCODE_5 = 34, + SDL_SCANCODE_6 = 35, + SDL_SCANCODE_7 = 36, + SDL_SCANCODE_8 = 37, + SDL_SCANCODE_9 = 38, + SDL_SCANCODE_0 = 39, + + SDL_SCANCODE_RETURN = 40, + SDL_SCANCODE_ESCAPE = 41, + SDL_SCANCODE_BACKSPACE = 42, + SDL_SCANCODE_TAB = 43, + SDL_SCANCODE_SPACE = 44, + + SDL_SCANCODE_MINUS = 45, + SDL_SCANCODE_EQUALS = 46, + SDL_SCANCODE_LEFTBRACKET = 47, + SDL_SCANCODE_RIGHTBRACKET = 48, + SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return + * key on ISO keyboards and at the right end + * of the QWERTY row on ANSI keyboards. + * Produces REVERSE SOLIDUS (backslash) and + * VERTICAL LINE in a US layout, REVERSE + * SOLIDUS and VERTICAL LINE in a UK Mac + * layout, NUMBER SIGN and TILDE in a UK + * Windows layout, DOLLAR SIGN and POUND SIGN + * in a Swiss German layout, NUMBER SIGN and + * APOSTROPHE in a German layout, GRAVE + * ACCENT and POUND SIGN in a French Mac + * layout, and ASTERISK and MICRO SIGN in a + * French Windows layout. + */ + SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code + * instead of 49 for the same key, but all + * OSes I've seen treat the two codes + * identically. So, as an implementor, unless + * your keyboard generates both of those + * codes and your OS treats them differently, + * you should generate SDL_SCANCODE_BACKSLASH + * instead of this code. As a user, you + * should not rely on this code because SDL + * will never generate it with most (all?) + * keyboards. + */ + SDL_SCANCODE_SEMICOLON = 51, + SDL_SCANCODE_APOSTROPHE = 52, + SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI + * and ISO keyboards). Produces GRAVE ACCENT and + * TILDE in a US Windows layout and in US and UK + * Mac layouts on ANSI keyboards, GRAVE ACCENT + * and NOT SIGN in a UK Windows layout, SECTION + * SIGN and PLUS-MINUS SIGN in US and UK Mac + * layouts on ISO keyboards, SECTION SIGN and + * DEGREE SIGN in a Swiss German layout (Mac: + * only on ISO keyboards), CIRCUMFLEX ACCENT and + * DEGREE SIGN in a German layout (Mac: only on + * ISO keyboards), SUPERSCRIPT TWO and TILDE in a + * French Windows layout, COMMERCIAL AT and + * NUMBER SIGN in a French Mac layout on ISO + * keyboards, and LESS-THAN SIGN and GREATER-THAN + * SIGN in a Swiss German, German, or French Mac + * layout on ANSI keyboards. + */ + SDL_SCANCODE_COMMA = 54, + SDL_SCANCODE_PERIOD = 55, + SDL_SCANCODE_SLASH = 56, + + SDL_SCANCODE_CAPSLOCK = 57, + + SDL_SCANCODE_F1 = 58, + SDL_SCANCODE_F2 = 59, + SDL_SCANCODE_F3 = 60, + SDL_SCANCODE_F4 = 61, + SDL_SCANCODE_F5 = 62, + SDL_SCANCODE_F6 = 63, + SDL_SCANCODE_F7 = 64, + SDL_SCANCODE_F8 = 65, + SDL_SCANCODE_F9 = 66, + SDL_SCANCODE_F10 = 67, + SDL_SCANCODE_F11 = 68, + SDL_SCANCODE_F12 = 69, + + SDL_SCANCODE_PRINTSCREEN = 70, + SDL_SCANCODE_SCROLLLOCK = 71, + SDL_SCANCODE_PAUSE = 72, + SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but + does send code 73, not 117) */ + SDL_SCANCODE_HOME = 74, + SDL_SCANCODE_PAGEUP = 75, + SDL_SCANCODE_DELETE = 76, + SDL_SCANCODE_END = 77, + SDL_SCANCODE_PAGEDOWN = 78, + SDL_SCANCODE_RIGHT = 79, + SDL_SCANCODE_LEFT = 80, + SDL_SCANCODE_DOWN = 81, + SDL_SCANCODE_UP = 82, + + SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards + */ + SDL_SCANCODE_KP_DIVIDE = 84, + SDL_SCANCODE_KP_MULTIPLY = 85, + SDL_SCANCODE_KP_MINUS = 86, + SDL_SCANCODE_KP_PLUS = 87, + SDL_SCANCODE_KP_ENTER = 88, + SDL_SCANCODE_KP_1 = 89, + SDL_SCANCODE_KP_2 = 90, + SDL_SCANCODE_KP_3 = 91, + SDL_SCANCODE_KP_4 = 92, + SDL_SCANCODE_KP_5 = 93, + SDL_SCANCODE_KP_6 = 94, + SDL_SCANCODE_KP_7 = 95, + SDL_SCANCODE_KP_8 = 96, + SDL_SCANCODE_KP_9 = 97, + SDL_SCANCODE_KP_0 = 98, + SDL_SCANCODE_KP_PERIOD = 99, + + SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO + * keyboards have over ANSI ones, + * located between left shift and Y. + * Produces GRAVE ACCENT and TILDE in a + * US or UK Mac layout, REVERSE SOLIDUS + * (backslash) and VERTICAL LINE in a + * US or UK Windows layout, and + * LESS-THAN SIGN and GREATER-THAN SIGN + * in a Swiss German, German, or French + * layout. */ + SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */ + SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag, + * not a physical key - but some Mac keyboards + * do have a power key. */ + SDL_SCANCODE_KP_EQUALS = 103, + SDL_SCANCODE_F13 = 104, + SDL_SCANCODE_F14 = 105, + SDL_SCANCODE_F15 = 106, + SDL_SCANCODE_F16 = 107, + SDL_SCANCODE_F17 = 108, + SDL_SCANCODE_F18 = 109, + SDL_SCANCODE_F19 = 110, + SDL_SCANCODE_F20 = 111, + SDL_SCANCODE_F21 = 112, + SDL_SCANCODE_F22 = 113, + SDL_SCANCODE_F23 = 114, + SDL_SCANCODE_F24 = 115, + SDL_SCANCODE_EXECUTE = 116, + SDL_SCANCODE_HELP = 117, + SDL_SCANCODE_MENU = 118, + SDL_SCANCODE_SELECT = 119, + SDL_SCANCODE_STOP = 120, + SDL_SCANCODE_AGAIN = 121, /**< redo */ + SDL_SCANCODE_UNDO = 122, + SDL_SCANCODE_CUT = 123, + SDL_SCANCODE_COPY = 124, + SDL_SCANCODE_PASTE = 125, + SDL_SCANCODE_FIND = 126, + SDL_SCANCODE_MUTE = 127, + SDL_SCANCODE_VOLUMEUP = 128, + SDL_SCANCODE_VOLUMEDOWN = 129, +/* not sure whether there's a reason to enable these */ +/* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */ +/* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */ +/* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */ + SDL_SCANCODE_KP_COMMA = 133, + SDL_SCANCODE_KP_EQUALSAS400 = 134, + + SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see + footnotes in USB doc */ + SDL_SCANCODE_INTERNATIONAL2 = 136, + SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */ + SDL_SCANCODE_INTERNATIONAL4 = 138, + SDL_SCANCODE_INTERNATIONAL5 = 139, + SDL_SCANCODE_INTERNATIONAL6 = 140, + SDL_SCANCODE_INTERNATIONAL7 = 141, + SDL_SCANCODE_INTERNATIONAL8 = 142, + SDL_SCANCODE_INTERNATIONAL9 = 143, + SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */ + SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */ + SDL_SCANCODE_LANG3 = 146, /**< Katakana */ + SDL_SCANCODE_LANG4 = 147, /**< Hiragana */ + SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */ + SDL_SCANCODE_LANG6 = 149, /**< reserved */ + SDL_SCANCODE_LANG7 = 150, /**< reserved */ + SDL_SCANCODE_LANG8 = 151, /**< reserved */ + SDL_SCANCODE_LANG9 = 152, /**< reserved */ + + SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */ + SDL_SCANCODE_SYSREQ = 154, + SDL_SCANCODE_CANCEL = 155, + SDL_SCANCODE_CLEAR = 156, + SDL_SCANCODE_PRIOR = 157, + SDL_SCANCODE_RETURN2 = 158, + SDL_SCANCODE_SEPARATOR = 159, + SDL_SCANCODE_OUT = 160, + SDL_SCANCODE_OPER = 161, + SDL_SCANCODE_CLEARAGAIN = 162, + SDL_SCANCODE_CRSEL = 163, + SDL_SCANCODE_EXSEL = 164, + + SDL_SCANCODE_KP_00 = 176, + SDL_SCANCODE_KP_000 = 177, + SDL_SCANCODE_THOUSANDSSEPARATOR = 178, + SDL_SCANCODE_DECIMALSEPARATOR = 179, + SDL_SCANCODE_CURRENCYUNIT = 180, + SDL_SCANCODE_CURRENCYSUBUNIT = 181, + SDL_SCANCODE_KP_LEFTPAREN = 182, + SDL_SCANCODE_KP_RIGHTPAREN = 183, + SDL_SCANCODE_KP_LEFTBRACE = 184, + SDL_SCANCODE_KP_RIGHTBRACE = 185, + SDL_SCANCODE_KP_TAB = 186, + SDL_SCANCODE_KP_BACKSPACE = 187, + SDL_SCANCODE_KP_A = 188, + SDL_SCANCODE_KP_B = 189, + SDL_SCANCODE_KP_C = 190, + SDL_SCANCODE_KP_D = 191, + SDL_SCANCODE_KP_E = 192, + SDL_SCANCODE_KP_F = 193, + SDL_SCANCODE_KP_XOR = 194, + SDL_SCANCODE_KP_POWER = 195, + SDL_SCANCODE_KP_PERCENT = 196, + SDL_SCANCODE_KP_LESS = 197, + SDL_SCANCODE_KP_GREATER = 198, + SDL_SCANCODE_KP_AMPERSAND = 199, + SDL_SCANCODE_KP_DBLAMPERSAND = 200, + SDL_SCANCODE_KP_VERTICALBAR = 201, + SDL_SCANCODE_KP_DBLVERTICALBAR = 202, + SDL_SCANCODE_KP_COLON = 203, + SDL_SCANCODE_KP_HASH = 204, + SDL_SCANCODE_KP_SPACE = 205, + SDL_SCANCODE_KP_AT = 206, + SDL_SCANCODE_KP_EXCLAM = 207, + SDL_SCANCODE_KP_MEMSTORE = 208, + SDL_SCANCODE_KP_MEMRECALL = 209, + SDL_SCANCODE_KP_MEMCLEAR = 210, + SDL_SCANCODE_KP_MEMADD = 211, + SDL_SCANCODE_KP_MEMSUBTRACT = 212, + SDL_SCANCODE_KP_MEMMULTIPLY = 213, + SDL_SCANCODE_KP_MEMDIVIDE = 214, + SDL_SCANCODE_KP_PLUSMINUS = 215, + SDL_SCANCODE_KP_CLEAR = 216, + SDL_SCANCODE_KP_CLEARENTRY = 217, + SDL_SCANCODE_KP_BINARY = 218, + SDL_SCANCODE_KP_OCTAL = 219, + SDL_SCANCODE_KP_DECIMAL = 220, + SDL_SCANCODE_KP_HEXADECIMAL = 221, + + SDL_SCANCODE_LCTRL = 224, + SDL_SCANCODE_LSHIFT = 225, + SDL_SCANCODE_LALT = 226, /**< alt, option */ + SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */ + SDL_SCANCODE_RCTRL = 228, + SDL_SCANCODE_RSHIFT = 229, + SDL_SCANCODE_RALT = 230, /**< alt gr, option */ + SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */ + + SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered + * by any of the above, but since there's a + * special KMOD_MODE for it I'm adding it here + */ + + /* @} *//* Usage page 0x07 */ + + /** + * \name Usage page 0x0C + * + * These values are mapped from usage page 0x0C (USB consumer page). + */ + /* @{ */ + + SDL_SCANCODE_AUDIONEXT = 258, + SDL_SCANCODE_AUDIOPREV = 259, + SDL_SCANCODE_AUDIOSTOP = 260, + SDL_SCANCODE_AUDIOPLAY = 261, + SDL_SCANCODE_AUDIOMUTE = 262, + SDL_SCANCODE_MEDIASELECT = 263, + SDL_SCANCODE_WWW = 264, + SDL_SCANCODE_MAIL = 265, + SDL_SCANCODE_CALCULATOR = 266, + SDL_SCANCODE_COMPUTER = 267, + SDL_SCANCODE_AC_SEARCH = 268, + SDL_SCANCODE_AC_HOME = 269, + SDL_SCANCODE_AC_BACK = 270, + SDL_SCANCODE_AC_FORWARD = 271, + SDL_SCANCODE_AC_STOP = 272, + SDL_SCANCODE_AC_REFRESH = 273, + SDL_SCANCODE_AC_BOOKMARKS = 274, + + /* @} *//* Usage page 0x0C */ + + /** + * \name Walther keys + * + * These are values that Christian Walther added (for mac keyboard?). + */ + /* @{ */ + + SDL_SCANCODE_BRIGHTNESSDOWN = 275, + SDL_SCANCODE_BRIGHTNESSUP = 276, + SDL_SCANCODE_DISPLAYSWITCH = 277, /**< display mirroring/dual display + switch, video mode switch */ + SDL_SCANCODE_KBDILLUMTOGGLE = 278, + SDL_SCANCODE_KBDILLUMDOWN = 279, + SDL_SCANCODE_KBDILLUMUP = 280, + SDL_SCANCODE_EJECT = 281, + SDL_SCANCODE_SLEEP = 282, + + SDL_SCANCODE_APP1 = 283, + SDL_SCANCODE_APP2 = 284, + + /* @} *//* Walther keys */ + + /* Add any other keys here. */ + + SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes + for array bounds */ +} SDL_Scancode; + +#endif /* _SDL_scancode_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_shape.h b/#ThirdParty/libSDL/include/SDL_shape.h new file mode 100644 index 0000000..db10a8f --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_shape.h @@ -0,0 +1,143 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_shape_h +#define _SDL_shape_h + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_surface.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** \file SDL_shape.h + * + * Header file for the shaped window API. + */ + +#define SDL_NONSHAPEABLE_WINDOW -1 +#define SDL_INVALID_SHAPE_ARGUMENT -2 +#define SDL_WINDOW_LACKS_SHAPE -3 + +/** + * \brief Create a window that can be shaped with the specified position, dimensions, and flags. + * + * \param title The title of the window, in UTF-8 encoding. + * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param w The width of the window. + * \param h The height of the window. + * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: + * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, + * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_RESIZABLE, + * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, + * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. + * + * \return The window created, or NULL if window creation failed. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); + +/** + * \brief Return whether the given window is a shaped window. + * + * \param window The window to query for being shaped. + * + * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL. + * \sa SDL_CreateShapedWindow + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); + +/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ +typedef enum { + /** \brief The default mode, a binarized alpha cutoff of 1. */ + ShapeModeDefault, + /** \brief A binarized alpha cutoff with a given integer value. */ + ShapeModeBinarizeAlpha, + /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ + ShapeModeReverseBinarizeAlpha, + /** \brief A color key is applied. */ + ShapeModeColorKey +} WindowShapeMode; + +#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) + +/** \brief A union containing parameters for shaped windows. */ +typedef union { + /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ + Uint8 binarizationCutoff; + SDL_Color colorKey; +} SDL_WindowShapeParams; + +/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ +typedef struct SDL_WindowShapeMode { + /** \brief The mode of these window-shape parameters. */ + WindowShapeMode mode; + /** \brief Window-shape parameters. */ + SDL_WindowShapeParams parameters; +} SDL_WindowShapeMode; + +/** + * \brief Set the shape and parameters of a shaped window. + * + * \param window The shaped window whose parameters should be set. + * \param shape A surface encoding the desired shape for the window. + * \param shape_mode The parameters to set for the shaped window. + * + * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW + * if the SDL_Window* given does not reference a valid shaped window. + * + * \sa SDL_WindowShapeMode + * \sa SDL_GetShapedWindowMode. + */ +extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); + +/** + * \brief Get the shape parameters of a shaped window. + * + * \param window The shaped window whose parameters should be retrieved. + * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. + * + * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode + * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if + * the SDL_Window* given is a shapeable window currently lacking a shape. + * + * \sa SDL_WindowShapeMode + * \sa SDL_SetWindowShape + */ +extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_shape_h */ diff --git a/#ThirdParty/libSDL/include/SDL_stdinc.h b/#ThirdParty/libSDL/include/SDL_stdinc.h new file mode 100644 index 0000000..887bcd2 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_stdinc.h @@ -0,0 +1,527 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_stdinc.h + * + * This is a general header that includes C language support. + */ + +#ifndef _SDL_stdinc_h +#define _SDL_stdinc_h + +#include "SDL_config.h" + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#if defined(STDC_HEADERS) +# include +# include +# include +#else +# if defined(HAVE_STDLIB_H) +# include +# elif defined(HAVE_MALLOC_H) +# include +# endif +# if defined(HAVE_STDDEF_H) +# include +# endif +# if defined(HAVE_STDARG_H) +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#if defined(HAVE_INTTYPES_H) +# include +#elif defined(HAVE_STDINT_H) +# include +#endif +#ifdef HAVE_CTYPE_H +# include +#endif +#ifdef HAVE_MATH_H +# if defined(__WINRT__) +/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on + WinRT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx + for more information. +*/ +# define _USE_MATH_DEFINES +# endif +# include +#endif +#ifdef HAVE_FLOAT_H +# include +#endif +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +# include +#endif + +/** + * The number of elements in an array. + */ +#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) +#define SDL_TABLESIZE(table) SDL_arraysize(table) + +/** + * \name Cast operators + * + * Use proper C++ casts when compiled as C++ to be compatible with the option + * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). + */ +/* @{ */ +#ifdef __cplusplus +#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) +#define SDL_static_cast(type, expression) static_cast(expression) +#define SDL_const_cast(type, expression) const_cast(expression) +#else +#define SDL_reinterpret_cast(type, expression) ((type)(expression)) +#define SDL_static_cast(type, expression) ((type)(expression)) +#define SDL_const_cast(type, expression) ((type)(expression)) +#endif +/* @} *//* Cast operators */ + +/* Define a four character code as a Uint32 */ +#define SDL_FOURCC(A, B, C, D) \ + ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24)) + +/** + * \name Basic data types + */ +/* @{ */ + +typedef enum +{ + SDL_FALSE = 0, + SDL_TRUE = 1 +} SDL_bool; + +/** + * \brief A signed 8-bit integer type. + */ +typedef int8_t Sint8; +/** + * \brief An unsigned 8-bit integer type. + */ +typedef uint8_t Uint8; +/** + * \brief A signed 16-bit integer type. + */ +typedef int16_t Sint16; +/** + * \brief An unsigned 16-bit integer type. + */ +typedef uint16_t Uint16; +/** + * \brief A signed 32-bit integer type. + */ +typedef int32_t Sint32; +/** + * \brief An unsigned 32-bit integer type. + */ +typedef uint32_t Uint32; + +/** + * \brief A signed 64-bit integer type. + */ +typedef int64_t Sint64; +/** + * \brief An unsigned 64-bit integer type. + */ +typedef uint64_t Uint64; + +/* @} *//* Basic data types */ + +/* Make sure we have macros for printing 64 bit values. + * should define these but this is not true all platforms. + * (for example win32) */ +#ifndef SDL_PRIs64 +#ifdef PRIs64 +#define SDL_PRIs64 PRIs64 +#elif defined(__WIN32__) +#define SDL_PRIs64 "I64d" +#elif defined(__LINUX__) && defined(__LP64__) +#define SDL_PRIs64 "ld" +#else +#define SDL_PRIs64 "lld" +#endif +#endif +#ifndef SDL_PRIu64 +#ifdef PRIu64 +#define SDL_PRIu64 PRIu64 +#elif defined(__WIN32__) +#define SDL_PRIu64 "I64u" +#elif defined(__LINUX__) && defined(__LP64__) +#define SDL_PRIu64 "lu" +#else +#define SDL_PRIu64 "llu" +#endif +#endif +#ifndef SDL_PRIx64 +#ifdef PRIx64 +#define SDL_PRIx64 PRIx64 +#elif defined(__WIN32__) +#define SDL_PRIx64 "I64x" +#elif defined(__LINUX__) && defined(__LP64__) +#define SDL_PRIx64 "lx" +#else +#define SDL_PRIx64 "llx" +#endif +#endif +#ifndef SDL_PRIX64 +#ifdef PRIX64 +#define SDL_PRIX64 PRIX64 +#elif defined(__WIN32__) +#define SDL_PRIX64 "I64X" +#elif defined(__LINUX__) && defined(__LP64__) +#define SDL_PRIX64 "lX" +#else +#define SDL_PRIX64 "llX" +#endif +#endif + +/* Annotations to help code analysis tools */ +#ifdef SDL_DISABLE_ANALYZE_MACROS +#define SDL_IN_BYTECAP(x) +#define SDL_INOUT_Z_CAP(x) +#define SDL_OUT_Z_CAP(x) +#define SDL_OUT_CAP(x) +#define SDL_OUT_BYTECAP(x) +#define SDL_OUT_Z_BYTECAP(x) +#define SDL_PRINTF_FORMAT_STRING +#define SDL_SCANF_FORMAT_STRING +#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) +#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) +#else +#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */ +#include + +#define SDL_IN_BYTECAP(x) _In_bytecount_(x) +#define SDL_INOUT_Z_CAP(x) _Inout_z_cap_(x) +#define SDL_OUT_Z_CAP(x) _Out_z_cap_(x) +#define SDL_OUT_CAP(x) _Out_cap_(x) +#define SDL_OUT_BYTECAP(x) _Out_bytecap_(x) +#define SDL_OUT_Z_BYTECAP(x) _Out_z_bytecap_(x) + +#define SDL_PRINTF_FORMAT_STRING _Printf_format_string_ +#define SDL_SCANF_FORMAT_STRING _Scanf_format_string_impl_ +#else +#define SDL_IN_BYTECAP(x) +#define SDL_INOUT_Z_CAP(x) +#define SDL_OUT_Z_CAP(x) +#define SDL_OUT_CAP(x) +#define SDL_OUT_BYTECAP(x) +#define SDL_OUT_Z_BYTECAP(x) +#define SDL_PRINTF_FORMAT_STRING +#define SDL_SCANF_FORMAT_STRING +#endif +#if defined(__GNUC__) +#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 ))) +#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 ))) +#else +#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) +#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) +#endif +#endif /* SDL_DISABLE_ANALYZE_MACROS */ + +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_dummy_ ## name[(x) * 2 - 1] +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +/* Check to make sure enums are the size of ints, for structure packing. + For both Watcom C/C++ and Borland C/C++ the compiler option that makes + enums having the size of an int must be enabled. + This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). +*/ + +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +#if !defined(__ANDROID__) + /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ +typedef enum +{ + DUMMY_ENUM_VALUE +} SDL_DUMMY_ENUM; + +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); +#endif +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(HAVE_ALLOCA) && !defined(alloca) +# if defined(HAVE_ALLOCA_H) +# include +# elif defined(__GNUC__) +# define alloca __builtin_alloca +# elif defined(_MSC_VER) +# include +# define alloca _alloca +# elif defined(__WATCOMC__) +# include +# elif defined(__BORLANDC__) +# include +# elif defined(__DMC__) +# include +# elif defined(__AIX__) +#pragma alloca +# elif defined(__MRC__) +void *alloca(unsigned); +# else +char *alloca(); +# endif +#endif +#ifdef HAVE_ALLOCA +#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) +#define SDL_stack_free(data) +#else +#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) +#define SDL_stack_free(data) SDL_free(data) +#endif + +extern DECLSPEC void *SDLCALL SDL_malloc(size_t size); +extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size); +extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size); +extern DECLSPEC void SDLCALL SDL_free(void *mem); + +extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); +extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite); + +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)); + +extern DECLSPEC int SDLCALL SDL_abs(int x); + +/* !!! FIXME: these have side effects. You probably shouldn't use them. */ +/* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */ +#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) +#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) + +extern DECLSPEC int SDLCALL SDL_isdigit(int x); +extern DECLSPEC int SDLCALL SDL_isspace(int x); +extern DECLSPEC int SDLCALL SDL_toupper(int x); +extern DECLSPEC int SDLCALL SDL_tolower(int x); + +extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len); + +#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) +#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) + +/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */ +SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords) +{ +#if defined(__GNUC__) && defined(i386) + int u0, u1, u2; + __asm__ __volatile__ ( + "cld \n\t" + "rep ; stosl \n\t" + : "=&D" (u0), "=&a" (u1), "=&c" (u2) + : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords)) + : "memory" + ); +#else + size_t _n = (dwords + 3) / 4; + Uint32 *_p = SDL_static_cast(Uint32 *, dst); + Uint32 _val = (val); + if (dwords == 0) + return; + switch (dwords % 4) + { + case 0: do { *_p++ = _val; + case 3: *_p++ = _val; + case 2: *_p++ = _val; + case 1: *_p++ = _val; + } while ( --_n ); + } +#endif +} + + +extern DECLSPEC void *SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); + +extern DECLSPEC void *SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); + +extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr); +extern DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); +extern DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); + +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str); +extern DECLSPEC size_t SDLCALL SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); +extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes); +extern DECLSPEC size_t SDLCALL SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); +extern DECLSPEC char *SDLCALL SDL_strdup(const char *str); +extern DECLSPEC char *SDLCALL SDL_strrev(char *str); +extern DECLSPEC char *SDLCALL SDL_strupr(char *str); +extern DECLSPEC char *SDLCALL SDL_strlwr(char *str); +extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c); +extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c); +extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle); + +extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix); + +extern DECLSPEC int SDLCALL SDL_atoi(const char *str); +extern DECLSPEC double SDLCALL SDL_atof(const char *str); +extern DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base); +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base); +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base); +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base); +extern DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp); + +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len); + +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2); +extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap); +extern DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3); +extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap); + +#ifndef HAVE_M_PI +#ifndef M_PI +#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#endif +#endif + +extern DECLSPEC double SDLCALL SDL_acos(double x); +extern DECLSPEC double SDLCALL SDL_asin(double x); +extern DECLSPEC double SDLCALL SDL_atan(double x); +extern DECLSPEC double SDLCALL SDL_atan2(double x, double y); +extern DECLSPEC double SDLCALL SDL_ceil(double x); +extern DECLSPEC double SDLCALL SDL_copysign(double x, double y); +extern DECLSPEC double SDLCALL SDL_cos(double x); +extern DECLSPEC float SDLCALL SDL_cosf(float x); +extern DECLSPEC double SDLCALL SDL_fabs(double x); +extern DECLSPEC double SDLCALL SDL_floor(double x); +extern DECLSPEC double SDLCALL SDL_log(double x); +extern DECLSPEC double SDLCALL SDL_pow(double x, double y); +extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); +extern DECLSPEC double SDLCALL SDL_sin(double x); +extern DECLSPEC float SDLCALL SDL_sinf(float x); +extern DECLSPEC double SDLCALL SDL_sqrt(double x); +extern DECLSPEC float SDLCALL SDL_sqrtf(float x); +extern DECLSPEC double SDLCALL SDL_tan(double x); +extern DECLSPEC float SDLCALL SDL_tanf(float x); + +/* The SDL implementation of iconv() returns these error codes */ +#define SDL_ICONV_ERROR (size_t)-1 +#define SDL_ICONV_E2BIG (size_t)-2 +#define SDL_ICONV_EILSEQ (size_t)-3 +#define SDL_ICONV_EINVAL (size_t)-4 + +/* SDL_iconv_* are now always real symbols/types, not macros or inlined. */ +typedef struct _SDL_iconv_t *SDL_iconv_t; +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, + const char *fromcode); +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, + size_t * inbytesleft, char **outbuf, + size_t * outbytesleft); +/** + * This function converts a string between encodings in one pass, returning a + * string that must be freed with SDL_free() or NULL on error. + */ +extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, + const char *fromcode, + const char *inbuf, + size_t inbytesleft); +#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) + +/* force builds using Clang's static analysis tools to use literal C runtime + here, since there are possibly tests that are ineffective otherwise. */ +#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS) +#define SDL_malloc malloc +#define SDL_calloc calloc +#define SDL_realloc realloc +#define SDL_free free +#define SDL_memset memset +#define SDL_memcpy memcpy +#define SDL_memmove memmove +#define SDL_memcmp memcmp +#define SDL_strlen strlen +#define SDL_strlcpy strlcpy +#define SDL_strlcat strlcat +#define SDL_strdup strdup +#define SDL_strchr strchr +#define SDL_strrchr strrchr +#define SDL_strstr strstr +#define SDL_strcmp strcmp +#define SDL_strncmp strncmp +#define SDL_strcasecmp strcasecmp +#define SDL_strncasecmp strncasecmp +#define SDL_sscanf sscanf +#define SDL_vsscanf vsscanf +#define SDL_snprintf snprintf +#define SDL_vsnprintf vsnprintf +#endif + +SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_BYTECAP(dwords*4) const void *src, size_t dwords) +{ + return SDL_memcpy(dst, src, dwords * 4); +} + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_stdinc_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_surface.h b/#ThirdParty/libSDL/include/SDL_surface.h new file mode 100644 index 0000000..e63ca89 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_surface.h @@ -0,0 +1,503 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_surface.h + * + * Header file for ::SDL_Surface definition and management functions. + */ + +#ifndef _SDL_surface_h +#define _SDL_surface_h + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_blendmode.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Surface flags + * + * These are the currently supported flags for the ::SDL_Surface. + * + * \internal + * Used internally (read-only). + */ +/* @{ */ +#define SDL_SWSURFACE 0 /**< Just here for compatibility */ +#define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ +#define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ +#define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ +/* @} *//* Surface flags */ + +/** + * Evaluates to true if the surface needs to be locked before access. + */ +#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) + +/** + * \brief A collection of pixels used in software blitting. + * + * \note This structure should be treated as read-only, except for \c pixels, + * which, if not NULL, contains the raw pixel data for the surface. + */ +typedef struct SDL_Surface +{ + Uint32 flags; /**< Read-only */ + SDL_PixelFormat *format; /**< Read-only */ + int w, h; /**< Read-only */ + int pitch; /**< Read-only */ + void *pixels; /**< Read-write */ + + /** Application data associated with the surface */ + void *userdata; /**< Read-write */ + + /** information needed for surfaces requiring locks */ + int locked; /**< Read-only */ + void *lock_data; /**< Read-only */ + + /** clipping information */ + SDL_Rect clip_rect; /**< Read-only */ + + /** info for fast blit mapping to other surfaces */ + struct SDL_BlitMap *map; /**< Private */ + + /** Reference count -- used when freeing surface */ + int refcount; /**< Read-mostly */ +} SDL_Surface; + +/** + * \brief The type of function used for surface blitting functions. + */ +typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect, + struct SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * Allocate and free an RGB surface. + * + * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. + * If the depth is greater than 8 bits, the pixel format is set using the + * flags '[RGB]mask'. + * + * If the function runs out of memory, it will return NULL. + * + * \param flags The \c flags are obsolete and should be set to 0. + * \param width The width in pixels of the surface to create. + * \param height The height in pixels of the surface to create. + * \param depth The depth in bits of the surface to create. + * \param Rmask The red mask of the surface to create. + * \param Gmask The green mask of the surface to create. + * \param Bmask The blue mask of the surface to create. + * \param Amask The alpha mask of the surface to create. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, + int width, + int height, + int depth, + int pitch, + Uint32 Rmask, + Uint32 Gmask, + Uint32 Bmask, + Uint32 Amask); +extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface); + +/** + * \brief Set the palette used by a surface. + * + * \return 0, or -1 if the surface format doesn't use a palette. + * + * \note A single palette can be shared with many surfaces. + */ +extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface, + SDL_Palette * palette); + +/** + * \brief Sets up a surface for directly accessing the pixels. + * + * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write + * to and read from \c surface->pixels, using the pixel format stored in + * \c surface->format. Once you are done accessing the surface, you should + * use SDL_UnlockSurface() to release it. + * + * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates + * to 0, then you can read and write to the surface at any time, and the + * pixel format of the surface will not change. + * + * No operating system or library calls should be made between lock/unlock + * pairs, as critical system locks may be held during this time. + * + * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. + * + * \sa SDL_UnlockSurface() + */ +extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface); +/** \sa SDL_LockSurface() */ +extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface); + +/** + * Load a surface from a seekable SDL data stream (memory or file). + * + * If \c freesrc is non-zero, the stream will be closed after being read. + * + * The new surface should be freed with SDL_FreeSurface(). + * + * \return the new surface, or NULL if there was an error. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, + int freesrc); + +/** + * Load a surface from a file. + * + * Convenience macro. + */ +#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) + +/** + * Save a surface to a seekable SDL data stream (memory or file). + * + * If \c freedst is non-zero, the stream will be closed after being written. + * + * \return 0 if successful or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SaveBMP_RW + (SDL_Surface * surface, SDL_RWops * dst, int freedst); + +/** + * Save a surface to a file. + * + * Convenience macro. + */ +#define SDL_SaveBMP(surface, file) \ + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + +/** + * \brief Sets the RLE acceleration hint for a surface. + * + * \return 0 on success, or -1 if the surface is not valid + * + * \note If RLE is enabled, colorkey and alpha blending blits are much faster, + * but the surface must be locked before directly accessing the pixels. + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface, + int flag); + +/** + * \brief Sets the color key (transparent pixel) in a blittable surface. + * + * \param surface The surface to update + * \param flag Non-zero to enable colorkey and 0 to disable colorkey + * \param key The transparent pixel in the native surface format + * + * \return 0 on success, or -1 if the surface is not valid + * + * You can pass SDL_RLEACCEL to enable RLE accelerated blits. + */ +extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface, + int flag, Uint32 key); + +/** + * \brief Gets the color key (transparent pixel) in a blittable surface. + * + * \param surface The surface to update + * \param key A pointer filled in with the transparent pixel in the native + * surface format + * + * \return 0 on success, or -1 if the surface is not valid or colorkey is not + * enabled. + */ +extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, + Uint32 * key); + +/** + * \brief Set an additional color value used in blit operations. + * + * \param surface The surface to update. + * \param r The red color value multiplied into blit operations. + * \param g The green color value multiplied into blit operations. + * \param b The blue color value multiplied into blit operations. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_GetSurfaceColorMod() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface, + Uint8 r, Uint8 g, Uint8 b); + + +/** + * \brief Get the additional color value used in blit operations. + * + * \param surface The surface to query. + * \param r A pointer filled in with the current red color value. + * \param g A pointer filled in with the current green color value. + * \param b A pointer filled in with the current blue color value. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceColorMod() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface, + Uint8 * r, Uint8 * g, + Uint8 * b); + +/** + * \brief Set an additional alpha value used in blit operations. + * + * \param surface The surface to update. + * \param alpha The alpha value multiplied into blit operations. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_GetSurfaceAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface, + Uint8 alpha); + +/** + * \brief Get the additional alpha value used in blit operations. + * + * \param surface The surface to query. + * \param alpha A pointer filled in with the current alpha value. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface, + Uint8 * alpha); + +/** + * \brief Set the blend mode used for blit operations. + * + * \param surface The surface to update. + * \param blendMode ::SDL_BlendMode to use for blit blending. + * + * \return 0 on success, or -1 if the parameters are not valid. + * + * \sa SDL_GetSurfaceBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for blit operations. + * + * \param surface The surface to query. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, + SDL_BlendMode *blendMode); + +/** + * Sets the clipping rectangle for the destination surface in a blit. + * + * If the clip rectangle is NULL, clipping will be disabled. + * + * If the clip rectangle doesn't intersect the surface, the function will + * return SDL_FALSE and blits will be completely clipped. Otherwise the + * function returns SDL_TRUE and blits to the surface will be clipped to + * the intersection of the surface area and the clipping rectangle. + * + * Note that blits are automatically clipped to the edges of the source + * and destination surfaces. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface, + const SDL_Rect * rect); + +/** + * Gets the clipping rectangle for the destination surface in a blit. + * + * \c rect must be a pointer to a valid rectangle which will be filled + * with the correct values. + */ +extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, + SDL_Rect * rect); + +/** + * Creates a new surface of the specified format, and then copies and maps + * the given surface to it so the blit of the converted surface will be as + * fast as possible. If this function fails, it returns NULL. + * + * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those + * semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and + * SDL will try to RLE accelerate colorkey and alpha blits in the resulting + * surface. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface + (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); +extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat + (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); + +/** + * \brief Copy a block of pixels of one format to another format + * + * \return 0 on success, or -1 if there was an error + */ +extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, + Uint32 src_format, + const void * src, int src_pitch, + Uint32 dst_format, + void * dst, int dst_pitch); + +/** + * Performs a fast fill of the given rectangle with \c color. + * + * If \c rect is NULL, the whole surface will be filled with \c color. + * + * The color should be a pixel of the format used by the surface, and + * can be generated by the SDL_MapRGB() function. + * + * \return 0 on success, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_FillRect + (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); +extern DECLSPEC int SDLCALL SDL_FillRects + (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); + +/** + * Performs a fast blit from the source surface to the destination surface. + * + * This assumes that the source and destination rectangles are + * the same size. If either \c srcrect or \c dstrect are NULL, the entire + * surface (\c src or \c dst) is copied. The final blit rectangles are saved + * in \c srcrect and \c dstrect after all clipping is performed. + * + * \return If the blit is successful, it returns 0, otherwise it returns -1. + * + * The blit function should not be called on a locked surface. + * + * The blit semantics for surfaces with and without blending and colorkey + * are defined as follows: + * \verbatim + RGBA->RGB: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source alpha-channel and per-surface alpha) + SDL_SRCCOLORKEY ignored. + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB. + if SDL_SRCCOLORKEY set, only copy the pixels matching the + RGB values of the source color key, ignoring alpha in the + comparison. + + RGB->RGBA: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source per-surface alpha) + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB, set destination alpha to source per-surface alpha value. + both: + if SDL_SRCCOLORKEY set, only copy the pixels matching the + source color key. + + RGBA->RGBA: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source alpha-channel and per-surface alpha) + SDL_SRCCOLORKEY ignored. + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy all of RGBA to the destination. + if SDL_SRCCOLORKEY set, only copy the pixels matching the + RGB values of the source color key, ignoring alpha in the + comparison. + + RGB->RGB: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source per-surface alpha) + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB. + both: + if SDL_SRCCOLORKEY set, only copy the pixels matching the + source color key. + \endverbatim + * + * You should call SDL_BlitSurface() unless you know exactly how SDL + * blitting works internally and how to use the other blit functions. + */ +#define SDL_BlitSurface SDL_UpperBlit + +/** + * This is the public blit function, SDL_BlitSurface(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlit() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlit + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * This is a semi-private blit function and it performs low-level surface + * blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlit + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * \brief Perform a fast, low quality, stretch blit between two surfaces of the + * same pixel format. + * + * \note This function uses a static buffer, and is not thread-safe. + */ +extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, + const SDL_Rect * srcrect, + SDL_Surface * dst, + const SDL_Rect * dstrect); + +#define SDL_BlitScaled SDL_UpperBlitScaled + +/** + * This is the public scaled blit function, SDL_BlitScaled(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlitScaled() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlitScaled + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * This is a semi-private blit function and it performs low-level surface + * scaled blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlitScaled + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_surface_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_system.h b/#ThirdParty/libSDL/include/SDL_system.h new file mode 100644 index 0000000..5da9adb --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_system.h @@ -0,0 +1,216 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_system.h + * + * Include file for platform specific SDL API functions + */ + +#ifndef _SDL_system_h +#define _SDL_system_h + +#include "SDL_stdinc.h" +#include "SDL_keyboard.h" +#include "SDL_render.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* Platform specific functions for Windows */ +#ifdef __WIN32__ + +/** + \brief Set a function that is called for every windows message, before TranslateMessage() +*/ +typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam); +extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata); + +/** + \brief Returns the D3D9 adapter index that matches the specified display index. + + This adapter index can be passed to IDirect3D9::CreateDevice and controls + on which monitor a full screen application will appear. +*/ +extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); + +typedef struct IDirect3DDevice9 IDirect3DDevice9; +/** + \brief Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. + + Once you are done using the device, you should release it to avoid a resource leak. + */ +extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer); + +/** + \brief Returns the DXGI Adapter and Output indices for the specified display index. + + These can be passed to EnumAdapters and EnumOutputs respectively to get the objects + required to create a DX10 or DX11 device and swap chain. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex ); + +#endif /* __WIN32__ */ + + +/* Platform specific functions for iOS */ +#if defined(__IPHONEOS__) && __IPHONEOS__ + +#define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam) +extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam); + +#define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled) +extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); + +#endif /* __IPHONEOS__ */ + + +/* Platform specific functions for Android */ +#if defined(__ANDROID__) && __ANDROID__ + +/** + \brief Get the JNI environment for the current thread + + This returns JNIEnv*, but the prototype is void* so we don't need jni.h + */ +extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(); + +/** + \brief Get the SDL Activity object for the application + + This returns jobject, but the prototype is void* so we don't need jni.h + The jobject returned by SDL_AndroidGetActivity is a local reference. + It is the caller's responsibility to properly release it + (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef) + */ +extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(); + +/** + See the official Android developer guide for more information: + http://developer.android.com/guide/topics/data/data-storage.html +*/ +#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01 +#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 + +/** + \brief Get the path used for internal storage for this application. + + This path is unique to your application and cannot be written to + by other applications. + */ +extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath(); + +/** + \brief Get the current state of external storage, a bitmask of these values: + SDL_ANDROID_EXTERNAL_STORAGE_READ + SDL_ANDROID_EXTERNAL_STORAGE_WRITE + + If external storage is currently unavailable, this will return 0. +*/ +extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(); + +/** + \brief Get the path used for external storage for this application. + + This path is unique to your application, but is public and can be + written to by other applications. + */ +extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(); + +#endif /* __ANDROID__ */ + +/* Platform specific functions for WinRT */ +#if defined(__WINRT__) && __WINRT__ + +/** + * \brief WinRT / Windows Phone path types + */ +typedef enum +{ + /** \brief The installed app's root directory. + Files here are likely to be read-only. */ + SDL_WINRT_PATH_INSTALLED_LOCATION, + + /** \brief The app's local data store. Files may be written here */ + SDL_WINRT_PATH_LOCAL_FOLDER, + + /** \brief The app's roaming data store. Unsupported on Windows Phone. + Files written here may be copied to other machines via a network + connection. + */ + SDL_WINRT_PATH_ROAMING_FOLDER, + + /** \brief The app's temporary data store. Unsupported on Windows Phone. + Files written here may be deleted at any time. */ + SDL_WINRT_PATH_TEMP_FOLDER +} SDL_WinRT_Path; + + +/** + * \brief Retrieves a WinRT defined path on the local file system + * + * \note Documentation on most app-specific path types on WinRT + * can be found on MSDN, at the URL: + * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * + * \param pathType The type of path to retrieve. + * \return A UCS-2 string (16-bit, wide-char) containing the path, or NULL + * if the path is not available for any reason. Not all paths are + * available on all versions of Windows. This is especially true on + * Windows Phone. Check the documentation for the given + * SDL_WinRT_Path for more information on which path types are + * supported where. + */ +extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType); + +/** + * \brief Retrieves a WinRT defined path on the local file system + * + * \note Documentation on most app-specific path types on WinRT + * can be found on MSDN, at the URL: + * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * + * \param pathType The type of path to retrieve. + * \return A UTF-8 string (8-bit, multi-byte) containing the path, or NULL + * if the path is not available for any reason. Not all paths are + * available on all versions of Windows. This is especially true on + * Windows Phone. Check the documentation for the given + * SDL_WinRT_Path for more information on which path types are + * supported where. + */ +extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType); + +#endif /* __WINRT__ */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_system_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_syswm.h b/#ThirdParty/libSDL/include/SDL_syswm.h new file mode 100644 index 0000000..1056e52 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_syswm.h @@ -0,0 +1,301 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_syswm.h + * + * Include file for SDL custom system window manager hooks. + */ + +#ifndef _SDL_syswm_h +#define _SDL_syswm_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_syswm.h + * + * Your application has access to a special type of event ::SDL_SYSWMEVENT, + * which contains window-manager specific information and arrives whenever + * an unhandled window event occurs. This event is ignored by default, but + * you can enable it with SDL_EventState(). + */ +#ifdef SDL_PROTOTYPES_ONLY +struct SDL_SysWMinfo; +#else + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#endif + +#if defined(SDL_VIDEO_DRIVER_WINRT) +#include +#endif + +/* This is the structure for custom window manager events */ +#if defined(SDL_VIDEO_DRIVER_X11) +#if defined(__APPLE__) && defined(__MACH__) +/* conflicts with Quickdraw.h */ +#define Cursor X11Cursor +#endif + +#include +#include + +#if defined(__APPLE__) && defined(__MACH__) +/* matches the re-define above */ +#undef Cursor +#endif + +#endif /* defined(SDL_VIDEO_DRIVER_X11) */ + +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) +#include +#endif + +#if defined(SDL_VIDEO_DRIVER_COCOA) +#ifdef __OBJC__ +@class NSWindow; +#else +typedef struct _NSWindow NSWindow; +#endif +#endif + +#if defined(SDL_VIDEO_DRIVER_UIKIT) +#ifdef __OBJC__ +#include +#else +typedef struct _UIWindow UIWindow; +typedef struct _UIViewController UIViewController; +#endif +typedef Uint32 GLuint; +#endif + +#if defined(SDL_VIDEO_DRIVER_ANDROID) +typedef struct ANativeWindow ANativeWindow; +typedef void *EGLSurface; +#endif + +/** + * These are the various supported windowing subsystems + */ +typedef enum +{ + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, + SDL_SYSWM_WINRT, + SDL_SYSWM_ANDROID +} SDL_SYSWM_TYPE; + +/** + * The custom event structure. + */ +struct SDL_SysWMmsg +{ + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union + { +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + struct { + HWND hwnd; /**< The window for the message */ + UINT msg; /**< The type of message */ + WPARAM wParam; /**< WORD message parameter */ + LPARAM lParam; /**< LONG message parameter */ + } win; +#endif +#if defined(SDL_VIDEO_DRIVER_X11) + struct { + XEvent event; + } x11; +#endif +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) + struct { + DFBEvent event; + } dfb; +#endif +#if defined(SDL_VIDEO_DRIVER_COCOA) + struct + { + /* Latest version of Xcode clang complains about empty structs in C v. C++: + error: empty struct has size 0 in C, size 1 in C++ + */ + int dummy; + /* No Cocoa window events yet */ + } cocoa; +#endif +#if defined(SDL_VIDEO_DRIVER_UIKIT) + struct + { + int dummy; + /* No UIKit window events yet */ + } uikit; +#endif + /* Can't have an empty union */ + int dummy; + } msg; +}; + +/** + * The custom window manager information structure. + * + * When this structure is returned, it holds information about which + * low level system it is using, and will be one of SDL_SYSWM_TYPE. + */ +struct SDL_SysWMinfo +{ + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union + { +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + struct + { + HWND window; /**< The window handle */ + HDC hdc; /**< The window device context */ + } win; +#endif +#if defined(SDL_VIDEO_DRIVER_WINRT) + struct + { + IInspectable * window; /**< The WinRT CoreWindow */ + } winrt; +#endif +#if defined(SDL_VIDEO_DRIVER_X11) + struct + { + Display *display; /**< The X11 display */ + Window window; /**< The X11 window */ + } x11; +#endif +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) + struct + { + IDirectFB *dfb; /**< The directfb main interface */ + IDirectFBWindow *window; /**< The directfb window handle */ + IDirectFBSurface *surface; /**< The directfb client surface */ + } dfb; +#endif +#if defined(SDL_VIDEO_DRIVER_COCOA) + struct + { +#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) + NSWindow __unsafe_unretained *window; /* The Cocoa window */ +#else + NSWindow *window; /* The Cocoa window */ +#endif + } cocoa; +#endif +#if defined(SDL_VIDEO_DRIVER_UIKIT) + struct + { +#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) + UIWindow __unsafe_unretained *window; /* The UIKit window */ +#else + UIWindow *window; /* The UIKit window */ +#endif + GLuint framebuffer; /* The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */ + GLuint colorbuffer; /* The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */ + GLuint resolveFramebuffer; /* The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */ + } uikit; +#endif +#if defined(SDL_VIDEO_DRIVER_WAYLAND) + struct + { + struct wl_display *display; /**< Wayland display */ + struct wl_surface *surface; /**< Wayland surface */ + struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ + } wl; +#endif +#if defined(SDL_VIDEO_DRIVER_MIR) + struct + { + struct MirConnection *connection; /**< Mir display server connection */ + struct MirSurface *surface; /**< Mir surface */ + } mir; +#endif + +#if defined(SDL_VIDEO_DRIVER_ANDROID) + struct + { + ANativeWindow *window; + EGLSurface surface; + } android; +#endif + + /* Can't have an empty union */ + int dummy; + } info; +}; + +#endif /* SDL_PROTOTYPES_ONLY */ + +typedef struct SDL_SysWMinfo SDL_SysWMinfo; + +/* Function prototypes */ +/** + * \brief This function allows access to driver-dependent window information. + * + * \param window The window about which information is being requested + * \param info This structure must be initialized with the SDL version, and is + * then filled in with information about the given window. + * + * \return SDL_TRUE if the function is implemented and the version member of + * the \c info struct is valid, SDL_FALSE otherwise. + * + * You typically use this function like this: + * \code + * SDL_SysWMinfo info; + * SDL_VERSION(&info.version); + * if ( SDL_GetWindowWMInfo(window, &info) ) { ... } + * \endcode + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, + SDL_SysWMinfo * info); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_syswm_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test.h b/#ThirdParty/libSDL/include/SDL_test.h new file mode 100644 index 0000000..217847b --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test.h @@ -0,0 +1,68 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +#ifndef _SDL_test_h +#define _SDL_test_h + +#include "SDL.h" +#include "SDL_test_common.h" +#include "SDL_test_font.h" +#include "SDL_test_random.h" +#include "SDL_test_fuzzer.h" +#include "SDL_test_crc32.h" +#include "SDL_test_md5.h" +#include "SDL_test_log.h" +#include "SDL_test_assert.h" +#include "SDL_test_harness.h" +#include "SDL_test_images.h" +#include "SDL_test_compare.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Global definitions */ + +/* + * Note: Maximum size of SDLTest log message is less than SDL's limit + * to ensure we can fit additional information such as the timestamp. + */ +#define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_assert.h b/#ThirdParty/libSDL/include/SDL_test_assert.h new file mode 100644 index 0000000..29277e1 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_assert.h @@ -0,0 +1,105 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_assert.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + * + * Assert API for test code and test cases + * + */ + +#ifndef _SDL_test_assert_h +#define _SDL_test_assert_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Fails the assert. + */ +#define ASSERT_FAIL 0 + +/** + * \brief Passes the assert. + */ +#define ASSERT_PASS 1 + +/** + * \brief Assert that logs and break execution flow on failures. + * + * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). + * \param assertDescription Message to log with the assert describing it. + */ +void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. + * + * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). + * \param assertDescription Message to log with the assert describing it. + * + * \returns Returns the assertCondition so it can be used to externally to break execution flow if desired. + */ +int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Explicitly pass without checking an assertion condition. Updates assertion counter. + * + * \param assertDescription Message to log with the assert describing it. + */ +void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1); + +/** + * \brief Resets the assert summary counters to zero. + */ +void SDLTest_ResetAssertSummary(); + +/** + * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. + */ +void SDLTest_LogAssertSummary(); + + +/** + * \brief Converts the current assert summary state to a test result. + * + * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT + */ +int SDLTest_AssertSummaryToTestResult(); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_assert_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_common.h b/#ThirdParty/libSDL/include/SDL_test_common.h new file mode 100644 index 0000000..0ebf31c --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_common.h @@ -0,0 +1,188 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_common.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* Ported from original test\common.h file. */ + +#ifndef _SDL_test_common_h +#define _SDL_test_common_h + +#include "SDL.h" + +#if defined(__PSP__) +#define DEFAULT_WINDOW_WIDTH 480 +#define DEFAULT_WINDOW_HEIGHT 272 +#else +#define DEFAULT_WINDOW_WIDTH 640 +#define DEFAULT_WINDOW_HEIGHT 480 +#endif + +#define VERBOSE_VIDEO 0x00000001 +#define VERBOSE_MODES 0x00000002 +#define VERBOSE_RENDER 0x00000004 +#define VERBOSE_EVENT 0x00000008 +#define VERBOSE_AUDIO 0x00000010 + +typedef struct +{ + /* SDL init flags */ + char **argv; + Uint32 flags; + Uint32 verbose; + + /* Video info */ + const char *videodriver; + int display; + const char *window_title; + const char *window_icon; + Uint32 window_flags; + int window_x; + int window_y; + int window_w; + int window_h; + int window_minW; + int window_minH; + int window_maxW; + int window_maxH; + int logical_w; + int logical_h; + float scale; + int depth; + int refresh_rate; + int num_windows; + SDL_Window **windows; + + /* Renderer info */ + const char *renderdriver; + Uint32 render_flags; + SDL_bool skip_renderer; + SDL_Renderer **renderers; + SDL_Texture **targets; + + /* Audio info */ + const char *audiodriver; + SDL_AudioSpec audiospec; + + /* GL settings */ + int gl_red_size; + int gl_green_size; + int gl_blue_size; + int gl_alpha_size; + int gl_buffer_size; + int gl_depth_size; + int gl_stencil_size; + int gl_double_buffer; + int gl_accum_red_size; + int gl_accum_green_size; + int gl_accum_blue_size; + int gl_accum_alpha_size; + int gl_stereo; + int gl_multisamplebuffers; + int gl_multisamplesamples; + int gl_retained_backing; + int gl_accelerated; + int gl_major_version; + int gl_minor_version; + int gl_debug; + int gl_profile_mask; +} SDLTest_CommonState; + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * \brief Parse command line parameters and create common state. + * + * \param argv Array of command line parameters + * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO) + * + * \returns Returns a newly allocated common state object. + */ +SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); + +/** + * \brief Process one common argument. + * + * \param state The common state describing the test window to create. + * \param index The index of the argument to process in argv[]. + * + * \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error. + */ +int SDLTest_CommonArg(SDLTest_CommonState * state, int index); + +/** + * \brief Returns common usage information + * + * \param state The common state describing the test window to create. + * + * \returns String with usage information + */ +const char *SDLTest_CommonUsage(SDLTest_CommonState * state); + +/** + * \brief Open test window. + * + * \param state The common state describing the test window to create. + * + * \returns True if initialization succeeded, false otherwise + */ +SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); + +/** + * \brief Common event handler for test windows. + * + * \param state The common state used to create test window. + * \param event The event to handle. + * \param done Flag indicating we are done. + * + */ +void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done); + +/** + * \brief Close test window. + * + * \param state The common state used to create test window. + * + */ +void SDLTest_CommonQuit(SDLTest_CommonState * state); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_common_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_compare.h b/#ThirdParty/libSDL/include/SDL_test_compare.h new file mode 100644 index 0000000..772cf9f --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_compare.h @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_compare.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Defines comparison functions (i.e. for surfaces). + +*/ + +#ifndef _SDL_test_compare_h +#define _SDL_test_compare_h + +#include "SDL.h" + +#include "SDL_test_images.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Compares a surface and with reference image data for equality + * + * \param surface Surface used in comparison + * \param referenceSurface Test Surface used in comparison + * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. + * + * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. + */ +int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_compare_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_crc32.h b/#ThirdParty/libSDL/include/SDL_test_crc32.h new file mode 100644 index 0000000..572a3d9 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_crc32.h @@ -0,0 +1,124 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_crc32.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Implements CRC32 calculations (default output is Perl String::CRC32 compatible). + +*/ + +#ifndef _SDL_test_crc32_h +#define _SDL_test_crc32_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* ------------ Definitions --------- */ + +/* Definition shared by all CRC routines */ + +#ifndef CrcUint32 + #define CrcUint32 unsigned int +#endif +#ifndef CrcUint8 + #define CrcUint8 unsigned char +#endif + +#ifdef ORIGINAL_METHOD + #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ +#else + #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ +#endif + +/** + * Data structure for CRC32 (checksum) computation + */ + typedef struct { + CrcUint32 crc32_table[256]; /* CRC table */ + } SDLTest_Crc32Context; + +/* ---------- Function Prototypes ------------- */ + +/** + * \brief Initialize the CRC context + * + * Note: The function initializes the crc table required for all crc calculations. + * + * \param crcContext pointer to context variable + * + * \returns 0 for OK, -1 on error + * + */ + int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext); + + +/** + * \brief calculate a crc32 from a data block + * + * \param crcContext pointer to context variable + * \param inBuf input buffer to checksum + * \param inLen length of input buffer + * \param crc32 pointer to Uint32 to store the final CRC into + * + * \returns 0 for OK, -1 on error + * + */ +int SDLTest_crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); + +/* Same routine broken down into three steps */ +int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); +int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); +int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); + + +/** + * \brief clean up CRC context + * + * \param crcContext pointer to context variable + * + * \returns 0 for OK, -1 on error + * +*/ + +int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_crc32_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_font.h b/#ThirdParty/libSDL/include/SDL_test_font.h new file mode 100644 index 0000000..3378ea8 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_font.h @@ -0,0 +1,76 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_font.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +#ifndef _SDL_test_font_h +#define _SDL_test_font_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +#define FONT_CHARACTER_SIZE 8 + +/** + * \brief Draw a string in the currently set font. + * + * \param renderer The renderer to draw on. + * \param x The X coordinate of the upper left corner of the character. + * \param y The Y coordinate of the upper left corner of the character. + * \param c The character to draw. + * + * \returns Returns 0 on success, -1 on failure. + */ +int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c ); + +/** + * \brief Draw a string in the currently set font. + * + * \param renderer The renderer to draw on. + * \param x The X coordinate of the upper left corner of the string. + * \param y The Y coordinate of the upper left corner of the string. + * \param s The string to draw. + * + * \returns Returns 0 on success, -1 on failure. + */ +int SDLTest_DrawString( SDL_Renderer * renderer, int x, int y, const char *s ); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_font_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_fuzzer.h b/#ThirdParty/libSDL/include/SDL_test_fuzzer.h new file mode 100644 index 0000000..9603652 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_fuzzer.h @@ -0,0 +1,384 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_fuzzer.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Data generators for fuzzing test data in a reproducible way. + +*/ + +#ifndef _SDL_test_fuzzer_h +#define _SDL_test_fuzzer_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* + Based on GSOC code by Markus Kauppila +*/ + + +/** + * \file + * Note: The fuzzer implementation uses a static instance of random context + * internally which makes it thread-UNsafe. + */ + +/** + * Initializes the fuzzer for a test + * + * \param execKey Execution "Key" that initializes the random number generator uniquely for the test. + * + */ +void SDLTest_FuzzerInit(Uint64 execKey); + + +/** + * Returns a random Uint8 + * + * \returns Generated integer + */ +Uint8 SDLTest_RandomUint8(); + +/** + * Returns a random Sint8 + * + * \returns Generated signed integer + */ +Sint8 SDLTest_RandomSint8(); + + +/** + * Returns a random Uint16 + * + * \returns Generated integer + */ +Uint16 SDLTest_RandomUint16(); + +/** + * Returns a random Sint16 + * + * \returns Generated signed integer + */ +Sint16 SDLTest_RandomSint16(); + + +/** + * Returns a random integer + * + * \returns Generated integer + */ +Sint32 SDLTest_RandomSint32(); + + +/** + * Returns a random positive integer + * + * \returns Generated integer + */ +Uint32 SDLTest_RandomUint32(); + +/** + * Returns random Uint64. + * + * \returns Generated integer + */ +Uint64 SDLTest_RandomUint64(); + + +/** + * Returns random Sint64. + * + * \returns Generated signed integer + */ +Sint64 SDLTest_RandomSint64(); + +/** + * \returns random float in range [0.0 - 1.0[ + */ +float SDLTest_RandomUnitFloat(); + +/** + * \returns random double in range [0.0 - 1.0[ + */ +double SDLTest_RandomUnitDouble(); + +/** + * \returns random float. + * + */ +float SDLTest_RandomFloat(); + +/** + * \returns random double. + * + */ +double SDLTest_RandomDouble(); + +/** + * Returns a random boundary value for Uint8 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint8BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint8BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint8BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint8BoundaryValue(0, 255, SDL_FALSE) returns 0 (error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint16 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint16BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint16BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint16BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint16BoundaryValue(0, 0xFFFF, SDL_FALSE) returns 0 (error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint32 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint32BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint32BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint32BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint32BoundaryValue(0, 0xFFFFFFFF, SDL_FALSE) returns 0 (with error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint64 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint64BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint64BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint64BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, SDL_FALSE) returns 0 (with error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint8 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint8BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint8BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint8BoundaryValue(SINT8_MIN, 99, SDL_FALSE) returns 100 + * RandomSint8BoundaryValue(SINT8_MIN, SINT8_MAX, SDL_FALSE) returns SINT8_MIN (== error value) with error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT8_MIN with error set + */ +Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain); + + +/** + * Returns a random boundary value for Sint16 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint16BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint16BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint16BoundaryValue(SINT16_MIN, 99, SDL_FALSE) returns 100 + * RandomSint16BoundaryValue(SINT16_MIN, SINT16_MAX, SDL_FALSE) returns SINT16_MIN (== error value) with error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT16_MIN with error set + */ +Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint32 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint32BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint32BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint32BoundaryValue(SINT32_MIN, 99, SDL_FALSE) returns 100 + * RandomSint32BoundaryValue(SINT32_MIN, SINT32_MAX, SDL_FALSE) returns SINT32_MIN (== error value) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT32_MIN with error set + */ +Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint64 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint64BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint64BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint64BoundaryValue(SINT64_MIN, 99, SDL_FALSE) returns 100 + * RandomSint64BoundaryValue(SINT64_MIN, SINT64_MAX, SDL_FALSE) returns SINT64_MIN (== error value) and error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT64_MIN with error set + */ +Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain); + + +/** + * Returns integer in range [min, max] (inclusive). + * Min and max values can be negative values. + * If Max in smaller than min, then the values are swapped. + * Min and max are the same value, that value will be returned. + * + * \param min Minimum inclusive value of returned random number + * \param max Maximum inclusive value of returned random number + * + * \returns Generated random integer in range + */ +Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max); + + +/** + * Generates random null-terminated string. The minimum length for + * the string is 1 character, maximum length for the string is 255 + * characters and it can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \returns Newly allocated random string; or NULL if length was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiString(); + + +/** + * Generates random null-terminated string. The maximum length for + * the string is defined by the maxLength parameter. + * String can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \param maxLength The maximum length of the generated string. + * + * \returns Newly allocated random string; or NULL if maxLength was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength); + + +/** + * Generates random null-terminated string. The length for + * the string is defined by the size parameter. + * String can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \param size The length of the generated string + * + * \returns Newly allocated random string; or NULL if size was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiStringOfSize(int size); + +/** + * Returns the invocation count for the fuzzer since last ...FuzzerInit. + */ +int SDLTest_GetFuzzerInvocationCount(); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_fuzzer_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_harness.h b/#ThirdParty/libSDL/include/SDL_test_harness.h new file mode 100644 index 0000000..74c0950 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_harness.h @@ -0,0 +1,123 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_harness.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + Defines types for test case definitions and the test execution harness API. + + Based on original GSOC code by Markus Kauppila +*/ + +#ifndef _SDL_test_harness_h +#define _SDL_test_harness_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* ! Definitions for test case structures */ +#define TEST_ENABLED 1 +#define TEST_DISABLED 0 + +/* ! Definition of all the possible test return values of the test case method */ +#define TEST_ABORTED -1 +#define TEST_STARTED 0 +#define TEST_COMPLETED 1 +#define TEST_SKIPPED 2 + +/* ! Definition of all the possible test results for the harness */ +#define TEST_RESULT_PASSED 0 +#define TEST_RESULT_FAILED 1 +#define TEST_RESULT_NO_ASSERT 2 +#define TEST_RESULT_SKIPPED 3 +#define TEST_RESULT_SETUP_FAILURE 4 + +/* !< Function pointer to a test case setup function (run before every test) */ +typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); + +/* !< Function pointer to a test case function */ +typedef int (*SDLTest_TestCaseFp)(void *arg); + +/* !< Function pointer to a test case teardown function (run after every test) */ +typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); + +/** + * Holds information about a single test case. + */ +typedef struct SDLTest_TestCaseReference { + /* !< Func2Stress */ + SDLTest_TestCaseFp testCase; + /* !< Short name (or function name) "Func2Stress" */ + char *name; + /* !< Long name or full description "This test pushes func2() to the limit." */ + char *description; + /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ + int enabled; +} SDLTest_TestCaseReference; + +/** + * Holds information about a test suite (multiple test cases). + */ +typedef struct SDLTest_TestSuiteReference { + /* !< "PlatformSuite" */ + char *name; + /* !< The function that is run before each test. NULL skips. */ + SDLTest_TestCaseSetUpFp testSetUp; + /* !< The test cases that are run as part of the suite. Last item should be NULL. */ + const SDLTest_TestCaseReference **testCases; + /* !< The function that is run after each test. NULL skips. */ + SDLTest_TestCaseTearDownFp testTearDown; +} SDLTest_TestSuiteReference; + + +/** + * \brief Execute a test suite using the given run seed and execution key. + * + * \param testSuites Suites containing the test case. + * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. + * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. + * \param filter Filter specification. NULL disables. Case sensitive. + * \param testIterations Number of iterations to run each test case. + * + * \returns Test run result; 0 when all tests passed, 1 if any tests failed. + */ +int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_harness_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_images.h b/#ThirdParty/libSDL/include/SDL_test_images.h new file mode 100644 index 0000000..8c64b4f --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_images.h @@ -0,0 +1,78 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_images.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Defines some images for tests. + +*/ + +#ifndef _SDL_test_images_h +#define _SDL_test_images_h + +#include "SDL.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + *Type for test images. + */ +typedef struct SDLTest_SurfaceImage_s { + int width; + int height; + unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ + const char *pixel_data; +} SDLTest_SurfaceImage_t; + +/* Test images */ +SDL_Surface *SDLTest_ImageBlit(); +SDL_Surface *SDLTest_ImageBlitColor(); +SDL_Surface *SDLTest_ImageBlitAlpha(); +SDL_Surface *SDLTest_ImageBlitBlendAdd(); +SDL_Surface *SDLTest_ImageBlitBlend(); +SDL_Surface *SDLTest_ImageBlitBlendMod(); +SDL_Surface *SDLTest_ImageBlitBlendNone(); +SDL_Surface *SDLTest_ImageBlitBlendAll(); +SDL_Surface *SDLTest_ImageFace(); +SDL_Surface *SDLTest_ImagePrimitives(); +SDL_Surface *SDLTest_ImagePrimitivesBlend(); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_images_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_log.h b/#ThirdParty/libSDL/include/SDL_test_log.h new file mode 100644 index 0000000..73a5c01 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_log.h @@ -0,0 +1,67 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_log.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + * + * Wrapper to log in the TEST category + * + */ + +#ifndef _SDL_test_log_h +#define _SDL_test_log_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Prints given message with a timestamp in the TEST category and INFO priority. + * + * \param fmt Message to be logged + */ +void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); + +/** + * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. + * + * \param fmt Message to be logged + */ +void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_log_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_md5.h b/#ThirdParty/libSDL/include/SDL_test_md5.h new file mode 100644 index 0000000..f2d9a7d --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_md5.h @@ -0,0 +1,129 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_md5.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + *********************************************************************** + ** Header file for implementation of MD5 ** + ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** + ** Revised (for MD5): RLR 4/27/91 ** + ** -- G modified to have y&~z instead of y&z ** + ** -- FF, GG, HH modified to add in last register done ** + ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** + ** -- distinct additive constant for each step ** + ** -- round 4 added, working mod 7 ** + *********************************************************************** +*/ + +/* + *********************************************************************** + ** Message-digest routines: ** + ** To form the message digest for a message M ** + ** (1) Initialize a context buffer mdContext using MD5Init ** + ** (2) Call MD5Update on mdContext and M ** + ** (3) Call MD5Final on mdContext ** + ** The message digest is now in mdContext->digest[0...15] ** + *********************************************************************** +*/ + +#ifndef _SDL_test_md5_h +#define _SDL_test_md5_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------ Definitions --------- */ + +/* typedef a 32-bit type */ + typedef unsigned long int MD5UINT4; + +/* Data structure for MD5 (Message-Digest) computation */ + typedef struct { + MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ + MD5UINT4 buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after Md5Final call */ + } SDLTest_Md5Context; + +/* ---------- Function Prototypes ------------- */ + +/** + * \brief initialize the context + * + * \param mdContext pointer to context variable + * + * Note: The function initializes the message-digest context + * mdContext. Call before each new use of the context - + * all fields are set to zero. + */ + void SDLTest_Md5Init(SDLTest_Md5Context * mdContext); + + +/** + * \brief update digest from variable length data + * + * \param mdContext pointer to context variable + * \param inBuf pointer to data array/string + * \param inLen length of data array/string + * + * Note: The function updates the message-digest context to account + * for the presence of each of the characters inBuf[0..inLen-1] + * in the message whose digest is being computed. +*/ + + void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, + unsigned int inLen); + + +/** + * \brief complete digest computation + * + * \param mdContext pointer to context variable + * + * Note: The function terminates the message-digest computation and + * ends with the desired message digest in mdContext.digest[0..15]. + * Always call before using the digest[] variable. +*/ + + void SDLTest_Md5Final(SDLTest_Md5Context * mdContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_md5_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_test_random.h b/#ThirdParty/libSDL/include/SDL_test_random.h new file mode 100644 index 0000000..91c3652 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_test_random.h @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_random.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + A "32-bit Multiply with carry random number generator. Very fast. + Includes a list of recommended multipliers. + + multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. + period: (a*2^31)-1 + +*/ + +#ifndef _SDL_test_random_h +#define _SDL_test_random_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* --- Definitions */ + +/* + * Macros that return a random number in a specific format. + */ +#define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) + +/* + * Context structure for the random number generator state. + */ + typedef struct { + unsigned int a; + unsigned int x; + unsigned int c; + unsigned int ah; + unsigned int al; + } SDLTest_RandomContext; + + +/* --- Function prototypes */ + +/** + * \brief Initialize random number generator with two integers. + * + * Note: The random sequence of numbers returned by ...Random() is the + * same for the same two integers and has a period of 2^31. + * + * \param rndContext pointer to context structure + * \param xi integer that defines the random sequence + * \param ci integer that defines the random sequence + * + */ + void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, + unsigned int ci); + +/** + * \brief Initialize random number generator based on current system time. + * + * \param rndContext pointer to context structure + * + */ + void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext); + + +/** + * \brief Initialize random number generator based on current system time. + * + * Note: ...RandomInit() or ...RandomInitTime() must have been called + * before using this function. + * + * \param rndContext pointer to context structure + * + * \returns A random number (32bit unsigned integer) + * + */ + unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_random_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_thread.h b/#ThirdParty/libSDL/include/SDL_thread.h new file mode 100644 index 0000000..377e6c7 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_thread.h @@ -0,0 +1,287 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_thread_h +#define _SDL_thread_h + +/** + * \file SDL_thread.h + * + * Header for the SDL thread management routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/* Thread synchronization primitives */ +#include "SDL_atomic.h" +#include "SDL_mutex.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The SDL thread structure, defined in SDL_thread.c */ +struct SDL_Thread; +typedef struct SDL_Thread SDL_Thread; + +/* The SDL thread ID */ +typedef unsigned long SDL_threadID; + +/* Thread local storage ID, 0 is the invalid ID */ +typedef unsigned int SDL_TLSID; + +/** + * The SDL thread priority. + * + * \note On many systems you require special privileges to set high priority. + */ +typedef enum { + SDL_THREAD_PRIORITY_LOW, + SDL_THREAD_PRIORITY_NORMAL, + SDL_THREAD_PRIORITY_HIGH +} SDL_ThreadPriority; + +/** + * The function passed to SDL_CreateThread(). + * It is passed a void* user context parameter and returns an int. + */ +typedef int (SDLCALL * SDL_ThreadFunction) (void *data); + +#if defined(__WIN32__) && !defined(HAVE_LIBC) +/** + * \file SDL_thread.h + * + * We compile SDL into a DLL. This means, that it's the DLL which + * creates a new thread for the calling process with the SDL_CreateThread() + * API. There is a problem with this, that only the RTL of the SDL.DLL will + * be initialized for those threads, and not the RTL of the calling + * application! + * + * To solve this, we make a little hack here. + * + * We'll always use the caller's _beginthread() and _endthread() APIs to + * start a new thread. This way, if it's the SDL.DLL which uses this API, + * then the RTL of SDL.DLL will be used to create the new thread, and if it's + * the application, then the RTL of the application will be used. + * + * So, in short: + * Always use the _beginthread() and _endthread() of the calling runtime + * library! + */ +#define SDL_PASSED_BEGINTHREAD_ENDTHREAD +#include /* This has _beginthread() and _endthread() defined! */ + +typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall * + func) (void + *), + void *arg, unsigned, + unsigned *threadID); +typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); + +/** + * Create a thread. + */ +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread); + +/** + * Create a thread. + */ +#if defined(SDL_CreateThread) && SDL_DYNAMIC_API +#undef SDL_CreateThread +#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex) +#else +#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex) +#endif + +#else + +/** + * Create a thread. + * + * Thread naming is a little complicated: Most systems have very small + * limits for the string length (Haiku has 32 bytes, Linux currently has 16, + * Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll + * have to see what happens with your system's debugger. The name should be + * UTF-8 (but using the naming limits of C identifiers is a better bet). + * There are no requirements for thread naming conventions, so long as the + * string is null-terminated UTF-8, but these guidelines are helpful in + * choosing a name: + * + * http://stackoverflow.com/questions/149932/naming-conventions-for-threads + * + * If a system imposes requirements, SDL will try to munge the string for + * it (truncate, etc), but the original string contents will be available + * from SDL_GetThreadName(). + */ +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data); + +#endif + +/** + * Get the thread name, as it was specified in SDL_CreateThread(). + * This function returns a pointer to a UTF-8 string that names the + * specified thread, or NULL if it doesn't have a name. This is internal + * memory, not to be free()'d by the caller, and remains valid until the + * specified thread is cleaned up by SDL_WaitThread(). + */ +extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread); + +/** + * Get the thread identifier for the current thread. + */ +extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void); + +/** + * Get the thread identifier for the specified thread. + * + * Equivalent to SDL_ThreadID() if the specified thread is NULL. + */ +extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread); + +/** + * Set the priority for the current thread + */ +extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); + +/** + * Wait for a thread to finish. Threads that haven't been detached will + * remain (as a "zombie") until this function cleans them up. Not doing so + * is a resource leak. + * + * Once a thread has been cleaned up through this function, the SDL_Thread + * that references it becomes invalid and should not be referenced again. + * As such, only one thread may call SDL_WaitThread() on another. + * + * The return code for the thread function is placed in the area + * pointed to by \c status, if \c status is not NULL. + * + * You may not wait on a thread that has been used in a call to + * SDL_DetachThread(). Use either that function or this one, but not + * both, or behavior is undefined. + * + * It is safe to pass NULL to this function; it is a no-op. + */ +extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status); + +/** + * A thread may be "detached" to signify that it should not remain until + * another thread has called SDL_WaitThread() on it. Detaching a thread + * is useful for long-running threads that nothing needs to synchronize + * with or further manage. When a detached thread is done, it simply + * goes away. + * + * There is no way to recover the return code of a detached thread. If you + * need this, don't detach the thread and instead use SDL_WaitThread(). + * + * Once a thread is detached, you should usually assume the SDL_Thread isn't + * safe to reference again, as it will become invalid immediately upon + * the detached thread's exit, instead of remaining until someone has called + * SDL_WaitThread() to finally clean it up. As such, don't detach the same + * thread more than once. + * + * If a thread has already exited when passed to SDL_DetachThread(), it will + * stop waiting for a call to SDL_WaitThread() and clean up immediately. + * It is not safe to detach a thread that might be used with SDL_WaitThread(). + * + * You may not call SDL_WaitThread() on a thread that has been detached. + * Use either that function or this one, but not both, or behavior is + * undefined. + * + * It is safe to pass NULL to this function; it is a no-op. + */ +extern DECLSPEC void SDLCALL SDL_DetachThread(SDL_Thread * thread); + +/** + * \brief Create an identifier that is globally visible to all threads but refers to data that is thread-specific. + * + * \return The newly created thread local storage identifier, or 0 on error + * + * \code + * static SDL_SpinLock tls_lock; + * static SDL_TLSID thread_local_storage; + * + * void SetMyThreadData(void *value) + * { + * if (!thread_local_storage) { + * SDL_AtomicLock(&tls_lock); + * if (!thread_local_storage) { + * thread_local_storage = SDL_TLSCreate(); + * } + * SDL_AtomicUnlock(&tls_lock); + * } + * SDL_TLSSet(thread_local_storage, value, 0); + * } + * + * void *GetMyThreadData(void) + * { + * return SDL_TLSGet(thread_local_storage); + * } + * \endcode + * + * \sa SDL_TLSGet() + * \sa SDL_TLSSet() + */ +extern DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate(void); + +/** + * \brief Get the value associated with a thread local storage ID for the current thread. + * + * \param id The thread local storage ID + * + * \return The value associated with the ID for the current thread, or NULL if no value has been set. + * + * \sa SDL_TLSCreate() + * \sa SDL_TLSSet() + */ +extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id); + +/** + * \brief Set the value associated with a thread local storage ID for the current thread. + * + * \param id The thread local storage ID + * \param value The value to associate with the ID for the current thread + * \param destructor A function called when the thread exits, to free the value. + * + * \return 0 on success, -1 on error + * + * \sa SDL_TLSCreate() + * \sa SDL_TLSGet() + */ +extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (*destructor)(void*)); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_thread_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_timer.h b/#ThirdParty/libSDL/include/SDL_timer.h new file mode 100644 index 0000000..e0d3785 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_timer.h @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_timer_h +#define _SDL_timer_h + +/** + * \file SDL_timer.h + * + * Header for the SDL time management routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Get the number of milliseconds since the SDL library initialization. + * + * \note This value wraps if the program runs for more than ~49 days. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); + +/** + * \brief Compare SDL ticks values, and return true if A has passed B + * + * e.g. if you want to wait 100 ms, you could do this: + * Uint32 timeout = SDL_GetTicks() + 100; + * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { + * ... do work until timeout has elapsed + * } + */ +#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) + +/** + * \brief Get the current value of the high resolution counter + */ +extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); + +/** + * \brief Get the count per second of the high resolution counter + */ +extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); + +/** + * \brief Wait a specified number of milliseconds before returning. + */ +extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); + +/** + * Function prototype for the timer callback function. + * + * The callback function is passed the current timer interval and returns + * the next timer interval. If the returned value is the same as the one + * passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is cancelled. + */ +typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); + +/** + * Definition of the timer ID type. + */ +typedef int SDL_TimerID; + +/** + * \brief Add a new timer to the pool of timers already running. + * + * \return A timer ID, or 0 when an error occurs. + */ +extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, + SDL_TimerCallback callback, + void *param); + +/** + * \brief Remove a timer knowing its ID. + * + * \return A boolean value indicating success or failure. + * + * \warning It is not safe to remove a timer multiple times. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_timer_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_touch.h b/#ThirdParty/libSDL/include/SDL_touch.h new file mode 100644 index 0000000..2643e36 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_touch.h @@ -0,0 +1,86 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_touch.h + * + * Include file for SDL touch event handling. + */ + +#ifndef _SDL_touch_h +#define _SDL_touch_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef Sint64 SDL_TouchID; +typedef Sint64 SDL_FingerID; + +typedef struct SDL_Finger +{ + SDL_FingerID id; + float x; + float y; + float pressure; +} SDL_Finger; + +/* Used as the device ID for mouse events simulated with touch input */ +#define SDL_TOUCH_MOUSEID ((Uint32)-1) + + +/* Function prototypes */ + +/** + * \brief Get the number of registered touch devices. + */ +extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); + +/** + * \brief Get the touch ID with the given index, or 0 if the index is invalid. + */ +extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); + +/** + * \brief Get the number of active fingers for a given touch device. + */ +extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); + +/** + * \brief Get the finger object of the given touch, with the given index. + */ +extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_touch_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_types.h b/#ThirdParty/libSDL/include/SDL_types.h new file mode 100644 index 0000000..5118af2 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_types.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_types.h + * + * \deprecated + */ + +/* DEPRECATED */ +#include "SDL_stdinc.h" diff --git a/#ThirdParty/libSDL/include/SDL_version.h b/#ThirdParty/libSDL/include/SDL_version.h new file mode 100644 index 0000000..de1f160 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_version.h @@ -0,0 +1,162 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_version.h + * + * This header defines the current SDL version. + */ + +#ifndef _SDL_version_h +#define _SDL_version_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Information the version of SDL in use. + * + * Represents the library's version as three levels: major revision + * (increments with massive changes, additions, and enhancements), + * minor revision (increments with backwards-compatible changes to the + * major revision), and patchlevel (increments with fixes to the minor + * revision). + * + * \sa SDL_VERSION + * \sa SDL_GetVersion + */ +typedef struct SDL_version +{ + Uint8 major; /**< major version */ + Uint8 minor; /**< minor version */ + Uint8 patch; /**< update version */ +} SDL_version; + +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL +*/ +#define SDL_MAJOR_VERSION 2 +#define SDL_MINOR_VERSION 0 +#define SDL_PATCHLEVEL 4 + +/** + * \brief Macro to determine SDL version program was compiled against. + * + * This macro fills in a SDL_version structure with the version of the + * library you compiled against. This is determined by what header the + * compiler uses. Note that if you dynamically linked the library, you might + * have a slightly newer or older version at runtime. That version can be + * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), + * is not a macro. + * + * \param x A pointer to a SDL_version struct to initialize. + * + * \sa SDL_version + * \sa SDL_GetVersion + */ +#define SDL_VERSION(x) \ +{ \ + (x)->major = SDL_MAJOR_VERSION; \ + (x)->minor = SDL_MINOR_VERSION; \ + (x)->patch = SDL_PATCHLEVEL; \ +} + +/** + * This macro turns the version numbers into a numeric value: + * \verbatim + (1,2,3) -> (1203) + \endverbatim + * + * This assumes that there will never be more than 100 patchlevels. + */ +#define SDL_VERSIONNUM(X, Y, Z) \ + ((X)*1000 + (Y)*100 + (Z)) + +/** + * This is the version number macro for the current SDL version. + */ +#define SDL_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +/** + * This macro will evaluate to true if compiled with SDL at least X.Y.Z. + */ +#define SDL_VERSION_ATLEAST(X, Y, Z) \ + (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/** + * \brief Get the version of SDL that is linked against your program. + * + * If you are linking to SDL dynamically, then it is possible that the + * current version will be different than the version you compiled against. + * This function returns the current version, while SDL_VERSION() is a + * macro that tells you what version you compiled with. + * + * \code + * SDL_version compiled; + * SDL_version linked; + * + * SDL_VERSION(&compiled); + * SDL_GetVersion(&linked); + * printf("We compiled against SDL version %d.%d.%d ...\n", + * compiled.major, compiled.minor, compiled.patch); + * printf("But we linked against SDL version %d.%d.%d.\n", + * linked.major, linked.minor, linked.patch); + * \endcode + * + * This function may be called safely at any time, even before SDL_Init(). + * + * \sa SDL_VERSION + */ +extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); + +/** + * \brief Get the code revision of SDL that is linked against your program. + * + * Returns an arbitrary string (a hash value) uniquely identifying the + * exact revision of the SDL library in use, and is only useful in comparing + * against other revisions. It is NOT an incrementing number. + */ +extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); + +/** + * \brief Get the revision number of SDL that is linked against your program. + * + * Returns a number uniquely identifying the exact revision of the SDL + * library in use. It is an incrementing number based on commits to + * hg.libsdl.org. + */ +extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_version_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/SDL_video.h b/#ThirdParty/libSDL/include/SDL_video.h new file mode 100644 index 0000000..52dbbc7 --- /dev/null +++ b/#ThirdParty/libSDL/include/SDL_video.h @@ -0,0 +1,1103 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_video.h + * + * Header file for SDL video functions. + */ + +#ifndef _SDL_video_h +#define _SDL_video_h + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_surface.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The structure that defines a display mode + * + * \sa SDL_GetNumDisplayModes() + * \sa SDL_GetDisplayMode() + * \sa SDL_GetDesktopDisplayMode() + * \sa SDL_GetCurrentDisplayMode() + * \sa SDL_GetClosestDisplayMode() + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_GetWindowDisplayMode() + */ +typedef struct +{ + Uint32 format; /**< pixel format */ + int w; /**< width, in screen coordinates */ + int h; /**< height, in screen coordinates */ + int refresh_rate; /**< refresh rate (or zero for unspecified) */ + void *driverdata; /**< driver-specific data, initialize to 0 */ +} SDL_DisplayMode; + +/** + * \brief The type used to identify a window + * + * \sa SDL_CreateWindow() + * \sa SDL_CreateWindowFrom() + * \sa SDL_DestroyWindow() + * \sa SDL_GetWindowData() + * \sa SDL_GetWindowFlags() + * \sa SDL_GetWindowGrab() + * \sa SDL_GetWindowPosition() + * \sa SDL_GetWindowSize() + * \sa SDL_GetWindowTitle() + * \sa SDL_HideWindow() + * \sa SDL_MaximizeWindow() + * \sa SDL_MinimizeWindow() + * \sa SDL_RaiseWindow() + * \sa SDL_RestoreWindow() + * \sa SDL_SetWindowData() + * \sa SDL_SetWindowFullscreen() + * \sa SDL_SetWindowGrab() + * \sa SDL_SetWindowIcon() + * \sa SDL_SetWindowPosition() + * \sa SDL_SetWindowSize() + * \sa SDL_SetWindowBordered() + * \sa SDL_SetWindowTitle() + * \sa SDL_ShowWindow() + */ +typedef struct SDL_Window SDL_Window; + +/** + * \brief The flags on a window + * + * \sa SDL_GetWindowFlags() + */ +typedef enum +{ + SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */ + SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */ + SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */ + SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */ + SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */ + SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ + SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */ + SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */ + SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */ + SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ + SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ + SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), + SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */ + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported */ + SDL_WINDOW_MOUSE_CAPTURE = 0x00004000 /**< window has mouse captured (unrelated to INPUT_GRABBED) */ +} SDL_WindowFlags; + +/** + * \brief Used to indicate that you don't care what the window position is. + */ +#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000 +#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) +#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) +#define SDL_WINDOWPOS_ISUNDEFINED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) + +/** + * \brief Used to indicate that the window position should be centered. + */ +#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000 +#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) +#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) +#define SDL_WINDOWPOS_ISCENTERED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) + +/** + * \brief Event subtype for window events + */ +typedef enum +{ + SDL_WINDOWEVENT_NONE, /**< Never used */ + SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */ + SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */ + SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be + redrawn */ + SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2 + */ + SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */ + SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as + a result of an API call or through the + system or user changing the window size. */ + SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */ + SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */ + SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size + and position */ + SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */ + SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */ + SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */ + SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */ + SDL_WINDOWEVENT_CLOSE /**< The window manager requests that the + window be closed */ +} SDL_WindowEventID; + +/** + * \brief An opaque handle to an OpenGL context. + */ +typedef void *SDL_GLContext; + +/** + * \brief OpenGL configuration attributes + */ +typedef enum +{ + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION, + SDL_GL_CONTEXT_EGL, + SDL_GL_CONTEXT_FLAGS, + SDL_GL_CONTEXT_PROFILE_MASK, + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, + SDL_GL_CONTEXT_RELEASE_BEHAVIOR +} SDL_GLattr; + +typedef enum +{ + SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, + SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, + SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /* GLX_CONTEXT_ES2_PROFILE_BIT_EXT */ +} SDL_GLprofile; + +typedef enum +{ + SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, + SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, + SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004, + SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008 +} SDL_GLcontextFlag; + +typedef enum +{ + SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000, + SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001 +} SDL_GLcontextReleaseFlag; + + +/* Function prototypes */ + +/** + * \brief Get the number of video drivers compiled into SDL + * + * \sa SDL_GetVideoDriver() + */ +extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); + +/** + * \brief Get the name of a built in video driver. + * + * \note The video drivers are presented in the order in which they are + * normally checked during initialization. + * + * \sa SDL_GetNumVideoDrivers() + */ +extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); + +/** + * \brief Initialize the video subsystem, optionally specifying a video driver. + * + * \param driver_name Initialize a specific driver by name, or NULL for the + * default video driver. + * + * \return 0 on success, -1 on error + * + * This function initializes the video subsystem; setting up a connection + * to the window manager, etc, and determines the available display modes + * and pixel formats, but does not initialize a window or graphics mode. + * + * \sa SDL_VideoQuit() + */ +extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name); + +/** + * \brief Shuts down the video subsystem. + * + * This function closes all windows, and restores the original video mode. + * + * \sa SDL_VideoInit() + */ +extern DECLSPEC void SDLCALL SDL_VideoQuit(void); + +/** + * \brief Returns the name of the currently initialized video driver. + * + * \return The name of the current video driver or NULL if no driver + * has been initialized + * + * \sa SDL_GetNumVideoDrivers() + * \sa SDL_GetVideoDriver() + */ +extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); + +/** + * \brief Returns the number of available video displays. + * + * \sa SDL_GetDisplayBounds() + */ +extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); + +/** + * \brief Get the name of a display in UTF-8 encoding + * + * \return The name of a display, or NULL for an invalid display index. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex); + +/** + * \brief Get the desktop area represented by a display, with the primary + * display located at 0,0 + * + * \return 0 on success, or -1 if the index is out of range. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect); + +/** + * \brief Get the dots/pixels-per-inch for a display + * + * \note Diagonal, horizontal and vertical DPI can all be optionally + * returned if the parameter is non-NULL. + * + * \return 0 on success, or -1 if no DPI information is available or the index is out of range. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi); + +/** + * \brief Returns the number of available display modes. + * + * \sa SDL_GetDisplayMode() + */ +extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex); + +/** + * \brief Fill in information about a specific display mode. + * + * \note The display modes are sorted in this priority: + * \li bits per pixel -> more colors to fewer colors + * \li width -> largest to smallest + * \li height -> largest to smallest + * \li refresh rate -> highest to lowest + * + * \sa SDL_GetNumDisplayModes() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, + SDL_DisplayMode * mode); + +/** + * \brief Fill in information about the desktop display mode. + */ +extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode); + +/** + * \brief Fill in information about the current display mode. + */ +extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode); + + +/** + * \brief Get the closest match to the requested display mode. + * + * \param displayIndex The index of display from which mode should be queried. + * \param mode The desired display mode + * \param closest A pointer to a display mode to be filled in with the closest + * match of the available display modes. + * + * \return The passed in value \c closest, or NULL if no matching video mode + * was available. + * + * The available display modes are scanned, and \c closest is filled in with the + * closest mode matching the requested mode and returned. The mode format and + * refresh_rate default to the desktop mode if they are 0. The modes are + * scanned with size being first priority, format being second priority, and + * finally checking the refresh_rate. If all the available modes are too + * small, then NULL is returned. + * + * \sa SDL_GetNumDisplayModes() + * \sa SDL_GetDisplayMode() + */ +extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); + +/** + * \brief Get the display index associated with a window. + * + * \return the display index of the display containing the center of the + * window, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window); + +/** + * \brief Set the display mode used when a fullscreen window is visible. + * + * By default the window's dimensions and the desktop format and refresh rate + * are used. + * + * \param window The window for which the display mode should be set. + * \param mode The mode to use, or NULL for the default mode. + * + * \return 0 on success, or -1 if setting the display mode failed. + * + * \sa SDL_GetWindowDisplayMode() + * \sa SDL_SetWindowFullscreen() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, + const SDL_DisplayMode + * mode); + +/** + * \brief Fill in information about the display mode used when a fullscreen + * window is visible. + * + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_SetWindowFullscreen() + */ +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, + SDL_DisplayMode * mode); + +/** + * \brief Get the pixel format associated with the window. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); + +/** + * \brief Create a window with the specified position, dimensions, and flags. + * + * \param title The title of the window, in UTF-8 encoding. + * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param w The width of the window, in screen coordinates. + * \param h The height of the window, in screen coordinates. + * \param flags The flags for the window, a mask of any of the following: + * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, + * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS, + * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, + * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED, + * ::SDL_WINDOW_ALLOW_HIGHDPI. + * + * \return The id of the window created, or zero if window creation failed. + * + * If the window is created with the SDL_WINDOW_ALLOW_HIGHDPI flag, its size + * in pixels may differ from its size in screen coordinates on platforms with + * high-DPI support (e.g. iOS and Mac OS X). Use SDL_GetWindowSize() to query + * the client area's size in screen coordinates, and SDL_GL_GetDrawableSize() + * or SDL_GetRendererOutputSize() to query the drawable size in pixels. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, + int x, int y, int w, + int h, Uint32 flags); + +/** + * \brief Create an SDL window from an existing native window. + * + * \param data A pointer to driver-dependent window creation data + * + * \return The id of the window created, or zero if window creation failed. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data); + +/** + * \brief Get the numeric ID of a window, for logging purposes. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window); + +/** + * \brief Get a window from a stored ID, or NULL if it doesn't exist. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id); + +/** + * \brief Get the window flags. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window); + +/** + * \brief Set the title of a window, in UTF-8 format. + * + * \sa SDL_GetWindowTitle() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, + const char *title); + +/** + * \brief Get the title of a window, in UTF-8 format. + * + * \sa SDL_SetWindowTitle() + */ +extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window); + +/** + * \brief Set the icon for a window. + * + * \param window The window for which the icon should be set. + * \param icon The icon for the window. + */ +extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, + SDL_Surface * icon); + +/** + * \brief Associate an arbitrary named pointer with a window. + * + * \param window The window to associate with the pointer. + * \param name The name of the pointer. + * \param userdata The associated pointer. + * + * \return The previous value associated with 'name' + * + * \note The name is case-sensitive. + * + * \sa SDL_GetWindowData() + */ +extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, + const char *name, + void *userdata); + +/** + * \brief Retrieve the data pointer associated with a window. + * + * \param window The window to query. + * \param name The name of the pointer. + * + * \return The value associated with 'name' + * + * \sa SDL_SetWindowData() + */ +extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, + const char *name); + +/** + * \brief Set the position of a window. + * + * \param window The window to reposition. + * \param x The x coordinate of the window in screen coordinates, or + * ::SDL_WINDOWPOS_CENTERED or ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y coordinate of the window in screen coordinates, or + * ::SDL_WINDOWPOS_CENTERED or ::SDL_WINDOWPOS_UNDEFINED. + * + * \note The window coordinate origin is the upper left of the display. + * + * \sa SDL_GetWindowPosition() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, + int x, int y); + +/** + * \brief Get the position of a window. + * + * \param window The window to query. + * \param x Pointer to variable for storing the x position, in screen + * coordinates. May be NULL. + * \param y Pointer to variable for storing the y position, in screen + * coordinates. May be NULL. + * + * \sa SDL_SetWindowPosition() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, + int *x, int *y); + +/** + * \brief Set the size of a window's client area. + * + * \param window The window to resize. + * \param w The width of the window, in screen coordinates. Must be >0. + * \param h The height of the window, in screen coordinates. Must be >0. + * + * \note You can't change the size of a fullscreen window, it automatically + * matches the size of the display mode. + * + * The window size in screen coordinates may differ from the size in pixels, if + * the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with + * high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or + * SDL_GetRendererOutputSize() to get the real client area size in pixels. + * + * \sa SDL_GetWindowSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, + int h); + +/** + * \brief Get the size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the width, in screen + * coordinates. May be NULL. + * \param h Pointer to variable for storing the height, in screen + * coordinates. May be NULL. + * + * The window size in screen coordinates may differ from the size in pixels, if + * the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with + * high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or + * SDL_GetRendererOutputSize() to get the real client area size in pixels. + * + * \sa SDL_SetWindowSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, + int *h); + +/** + * \brief Set the minimum size of a window's client area. + * + * \param window The window to set a new minimum size. + * \param min_w The minimum width of the window, must be >0 + * \param min_h The minimum height of the window, must be >0 + * + * \note You can't change the minimum size of a fullscreen window, it + * automatically matches the size of the display mode. + * + * \sa SDL_GetWindowMinimumSize() + * \sa SDL_SetWindowMaximumSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window, + int min_w, int min_h); + +/** + * \brief Get the minimum size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the minimum width, may be NULL + * \param h Pointer to variable for storing the minimum height, may be NULL + * + * \sa SDL_GetWindowMaximumSize() + * \sa SDL_SetWindowMinimumSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window, + int *w, int *h); + +/** + * \brief Set the maximum size of a window's client area. + * + * \param window The window to set a new maximum size. + * \param max_w The maximum width of the window, must be >0 + * \param max_h The maximum height of the window, must be >0 + * + * \note You can't change the maximum size of a fullscreen window, it + * automatically matches the size of the display mode. + * + * \sa SDL_GetWindowMaximumSize() + * \sa SDL_SetWindowMinimumSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window, + int max_w, int max_h); + +/** + * \brief Get the maximum size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the maximum width, may be NULL + * \param h Pointer to variable for storing the maximum height, may be NULL + * + * \sa SDL_GetWindowMinimumSize() + * \sa SDL_SetWindowMaximumSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window, + int *w, int *h); + +/** + * \brief Set the border state of a window. + * + * This will add or remove the window's SDL_WINDOW_BORDERLESS flag and + * add or remove the border from the actual window. This is a no-op if the + * window's border already matches the requested state. + * + * \param window The window of which to change the border state. + * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border. + * + * \note You can't change the border state of a fullscreen window. + * + * \sa SDL_GetWindowFlags() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, + SDL_bool bordered); + +/** + * \brief Show a window. + * + * \sa SDL_HideWindow() + */ +extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window); + +/** + * \brief Hide a window. + * + * \sa SDL_ShowWindow() + */ +extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window); + +/** + * \brief Raise a window above other windows and set the input focus. + */ +extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window); + +/** + * \brief Make a window as large as possible. + * + * \sa SDL_RestoreWindow() + */ +extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window); + +/** + * \brief Minimize a window to an iconic representation. + * + * \sa SDL_RestoreWindow() + */ +extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window); + +/** + * \brief Restore the size and position of a minimized or maximized window. + * + * \sa SDL_MaximizeWindow() + * \sa SDL_MinimizeWindow() + */ +extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); + +/** + * \brief Set a window's fullscreen state. + * + * \return 0 on success, or -1 if setting the display mode failed. + * + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_GetWindowDisplayMode() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, + Uint32 flags); + +/** + * \brief Get the SDL surface associated with the window. + * + * \return The window's framebuffer surface, or NULL on error. + * + * A new surface will be created with the optimal format for the window, + * if necessary. This surface will be freed when the window is destroyed. + * + * \note You may not combine this with 3D or the rendering API on this window. + * + * \sa SDL_UpdateWindowSurface() + * \sa SDL_UpdateWindowSurfaceRects() + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window); + +/** + * \brief Copy the window surface to the screen. + * + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetWindowSurface() + * \sa SDL_UpdateWindowSurfaceRects() + */ +extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window); + +/** + * \brief Copy a number of rectangles on the window surface to the screen. + * + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetWindowSurface() + * \sa SDL_UpdateWindowSurfaceRect() + */ +extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, + const SDL_Rect * rects, + int numrects); + +/** + * \brief Set a window's input grab mode. + * + * \param window The window for which the input grab mode should be set. + * \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input. + * + * If the caller enables a grab while another window is currently grabbed, + * the other window loses its grab in favor of the caller's window. + * + * \sa SDL_GetWindowGrab() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, + SDL_bool grabbed); + +/** + * \brief Get a window's input grab mode. + * + * \return This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise. + * + * \sa SDL_SetWindowGrab() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window); + +/** + * \brief Get the window that currently has an input grab enabled. + * + * \return This returns the window if input is grabbed, and NULL otherwise. + * + * \sa SDL_SetWindowGrab() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void); + +/** + * \brief Set the brightness (gamma correction) for a window. + * + * \return 0 on success, or -1 if setting the brightness isn't supported. + * + * \sa SDL_GetWindowBrightness() + * \sa SDL_SetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness); + +/** + * \brief Get the brightness (gamma correction) for a window. + * + * \return The last brightness value passed to SDL_SetWindowBrightness() + * + * \sa SDL_SetWindowBrightness() + */ +extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window); + +/** + * \brief Set the gamma ramp for a window. + * + * \param window The window for which the gamma ramp should be set. + * \param red The translation table for the red channel, or NULL. + * \param green The translation table for the green channel, or NULL. + * \param blue The translation table for the blue channel, or NULL. + * + * \return 0 on success, or -1 if gamma ramps are unsupported. + * + * Set the gamma translation table for the red, green, and blue channels + * of the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. + * The input is the index into the array, and the output is the 16-bit + * gamma value at that index, scaled to the output color precision. + * + * \sa SDL_GetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, + const Uint16 * red, + const Uint16 * green, + const Uint16 * blue); + +/** + * \brief Get the gamma ramp for a window. + * + * \param window The window from which the gamma ramp should be queried. + * \param red A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the red channel, or NULL. + * \param green A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the green channel, or NULL. + * \param blue A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the blue channel, or NULL. + * + * \return 0 on success, or -1 if gamma ramps are unsupported. + * + * \sa SDL_SetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, + Uint16 * red, + Uint16 * green, + Uint16 * blue); + +/** + * \brief Possible return values from the SDL_HitTest callback. + * + * \sa SDL_HitTest + */ +typedef enum +{ + SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */ + SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */ + SDL_HITTEST_RESIZE_TOPLEFT, + SDL_HITTEST_RESIZE_TOP, + SDL_HITTEST_RESIZE_TOPRIGHT, + SDL_HITTEST_RESIZE_RIGHT, + SDL_HITTEST_RESIZE_BOTTOMRIGHT, + SDL_HITTEST_RESIZE_BOTTOM, + SDL_HITTEST_RESIZE_BOTTOMLEFT, + SDL_HITTEST_RESIZE_LEFT +} SDL_HitTestResult; + +/** + * \brief Callback used for hit-testing. + * + * \sa SDL_SetWindowHitTest + */ +typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win, + const SDL_Point *area, + void *data); + +/** + * \brief Provide a callback that decides if a window region has special properties. + * + * Normally windows are dragged and resized by decorations provided by the + * system window manager (a title bar, borders, etc), but for some apps, it + * makes sense to drag them from somewhere else inside the window itself; for + * example, one might have a borderless window that wants to be draggable + * from any part, or simulate its own title bar, etc. + * + * This function lets the app provide a callback that designates pieces of + * a given window as special. This callback is run during event processing + * if we need to tell the OS to treat a region of the window specially; the + * use of this callback is known as "hit testing." + * + * Mouse input may not be delivered to your application if it is within + * a special area; the OS will often apply that input to moving the window or + * resizing the window and not deliver it to the application. + * + * Specifying NULL for a callback disables hit-testing. Hit-testing is + * disabled by default. + * + * Platforms that don't support this functionality will return -1 + * unconditionally, even if you're attempting to disable hit-testing. + * + * Your callback may fire at any time, and its firing does not indicate any + * specific behavior (for example, on Windows, this certainly might fire + * when the OS is deciding whether to drag your window, but it fires for lots + * of other reasons, too, some unrelated to anything you probably care about + * _and when the mouse isn't actually at the location it is testing_). + * Since this can fire at any time, you should try to keep your callback + * efficient, devoid of allocations, etc. + * + * \param window The window to set hit-testing on. + * \param callback The callback to call when doing a hit-test. + * \param callback_data An app-defined void pointer passed to the callback. + * \return 0 on success, -1 on error (including unsupported). + */ +extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window * window, + SDL_HitTest callback, + void *callback_data); + +/** + * \brief Destroy a window. + */ +extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window); + + +/** + * \brief Returns whether the screensaver is currently enabled (default on). + * + * \sa SDL_EnableScreenSaver() + * \sa SDL_DisableScreenSaver() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void); + +/** + * \brief Allow the screen to be blanked by a screensaver + * + * \sa SDL_IsScreenSaverEnabled() + * \sa SDL_DisableScreenSaver() + */ +extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void); + +/** + * \brief Prevent the screen from being blanked by a screensaver + * + * \sa SDL_IsScreenSaverEnabled() + * \sa SDL_EnableScreenSaver() + */ +extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); + + +/** + * \name OpenGL support functions + */ +/* @{ */ + +/** + * \brief Dynamically load an OpenGL library. + * + * \param path The platform dependent OpenGL library name, or NULL to open the + * default OpenGL library. + * + * \return 0 on success, or -1 if the library couldn't be loaded. + * + * This should be done after initializing the video driver, but before + * creating any OpenGL windows. If no OpenGL library is loaded, the default + * library will be loaded upon creation of the first OpenGL window. + * + * \note If you do this, you need to retrieve all of the GL functions used in + * your program from the dynamic library using SDL_GL_GetProcAddress(). + * + * \sa SDL_GL_GetProcAddress() + * \sa SDL_GL_UnloadLibrary() + */ +extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); + +/** + * \brief Get the address of an OpenGL function. + */ +extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc); + +/** + * \brief Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). + * + * \sa SDL_GL_LoadLibrary() + */ +extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); + +/** + * \brief Return true if an OpenGL extension is supported for the current + * context. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char + *extension); + +/** + * \brief Reset all previously set OpenGL context attributes to their default values + */ +extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); + +/** + * \brief Set an OpenGL window attribute before window creation. + */ +extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); + +/** + * \brief Get the actual value for an attribute from the current context. + */ +extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value); + +/** + * \brief Create an OpenGL context for use with an OpenGL window, and make it + * current. + * + * \sa SDL_GL_DeleteContext() + */ +extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * + window); + +/** + * \brief Set up an OpenGL context for rendering into an OpenGL window. + * + * \note The context must have been created with a compatible window. + */ +extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, + SDL_GLContext context); + +/** + * \brief Get the currently active OpenGL window. + */ +extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void); + +/** + * \brief Get the currently active OpenGL context. + */ +extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); + +/** + * \brief Get the size of a window's underlying drawable in pixels (for use + * with glViewport). + * + * \param window Window from which the drawable size should be queried + * \param w Pointer to variable for storing the width in pixels, may be NULL + * \param h Pointer to variable for storing the height in pixels, may be NULL + * + * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI + * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a + * platform with high-DPI support (Apple calls this "Retina"), and not disabled + * by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. + * + * \sa SDL_GetWindowSize() + * \sa SDL_CreateWindow() + */ +extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, + int *h); + +/** + * \brief Set the swap interval for the current OpenGL context. + * + * \param interval 0 for immediate updates, 1 for updates synchronized with the + * vertical retrace. If the system supports it, you may + * specify -1 to allow late swaps to happen immediately + * instead of waiting for the next retrace. + * + * \return 0 on success, or -1 if setting the swap interval is not supported. + * + * \sa SDL_GL_GetSwapInterval() + */ +extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval); + +/** + * \brief Get the swap interval for the current OpenGL context. + * + * \return 0 if there is no vertical retrace synchronization, 1 if the buffer + * swap is synchronized with the vertical retrace, and -1 if late + * swaps happen immediately instead of waiting for the next retrace. + * If the system can't determine the swap interval, or there isn't a + * valid current context, this will return 0 as a safe default. + * + * \sa SDL_GL_SetSwapInterval() + */ +extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void); + +/** + * \brief Swap the OpenGL buffers for a window, if double-buffering is + * supported. + */ +extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); + +/** + * \brief Delete an OpenGL context. + * + * \sa SDL_GL_CreateContext() + */ +extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); + +/* @} *//* OpenGL support functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/#ThirdParty/libSDL/include/begin_code.h b/#ThirdParty/libSDL/include/begin_code.h new file mode 100644 index 0000000..04e78c6 --- /dev/null +++ b/#ThirdParty/libSDL/include/begin_code.h @@ -0,0 +1,146 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file begin_code.h + * + * This file sets things up for C dynamic library function definitions, + * static inlined functions, and structures aligned at 4-byte alignment. + * If you don't like ugly C preprocessor code, don't look at this file. :) + */ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +#ifndef SDL_DEPRECATED +# if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ +# define SDL_DEPRECATED __attribute__((deprecated)) +# else +# define SDL_DEPRECATED +# endif +#endif + +#ifndef SDL_UNUSED +# ifdef __GNUC__ +# define SDL_UNUSED __attribute__((unused)) +# else +# define SDL_UNUSED +# endif +#endif + +/* Some compilers use a special export keyword */ +#ifndef DECLSPEC +# if defined(__WIN32__) || defined(__WINRT__) +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && __GNUC__ >= 4 +# define DECLSPEC __attribute__ ((visibility("default"))) +# else +# define DECLSPEC +# endif +# endif +#endif + +/* By default SDL uses the C calling convention */ +#ifndef SDLCALL +#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) +#define SDLCALL __cdecl +#else +#define SDLCALL +#endif +#endif /* SDLCALL */ + +/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ +#ifdef __SYMBIAN32__ +#undef DECLSPEC +#define DECLSPEC +#endif /* __SYMBIAN32__ */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#ifdef _M_X64 +/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ +#pragma pack(push,8) +#else +#pragma pack(push,4) +#endif +#endif /* Compiler needs structure packing set */ + +#ifndef SDL_INLINE +#if defined(__GNUC__) +#define SDL_INLINE __inline__ +#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) +#define SDL_INLINE __inline +#ifndef __inline__ +#define __inline__ __inline +#endif +#else +#define SDL_INLINE inline +#ifndef __inline__ +#define __inline__ inline +#endif +#endif +#endif /* SDL_INLINE not defined */ + +#ifndef SDL_FORCE_INLINE +#if defined(_MSC_VER) +#define SDL_FORCE_INLINE __forceinline +#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ +#else +#define SDL_FORCE_INLINE static SDL_INLINE +#endif +#endif /* SDL_FORCE_INLINE not defined */ + +/* Apparently this is needed by several Windows compilers */ +#if !defined(__MACH__) +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ +#endif /* ! Mac OS X - breaks precompiled headers */ diff --git a/#ThirdParty/libSDL/include/close_code.h b/#ThirdParty/libSDL/include/close_code.h new file mode 100644 index 0000000..d908b00 --- /dev/null +++ b/#ThirdParty/libSDL/include/close_code.h @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2016 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file close_code.h + * + * This file reverses the effects of begin_code.h and should be included + * after you finish any function and structure declarations in your headers + */ + +#undef _begin_code_h + +/* Reset structure packing at previous byte alignment */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#pragma pack(pop) +#endif /* Compiler needs structure packing set */ diff --git a/#ThirdParty/libSDL/lib/x64/SDL2.dll b/#ThirdParty/libSDL/lib/x64/SDL2.dll new file mode 100644 index 0000000..0f653f5 Binary files /dev/null and b/#ThirdParty/libSDL/lib/x64/SDL2.dll differ diff --git a/#ThirdParty/libSDL/lib/x64/SDL2.lib b/#ThirdParty/libSDL/lib/x64/SDL2.lib new file mode 100644 index 0000000..fd67b32 Binary files /dev/null and b/#ThirdParty/libSDL/lib/x64/SDL2.lib differ diff --git a/#ThirdParty/libSDL/lib/x64/SDL2main.lib b/#ThirdParty/libSDL/lib/x64/SDL2main.lib new file mode 100644 index 0000000..a001767 Binary files /dev/null and b/#ThirdParty/libSDL/lib/x64/SDL2main.lib differ diff --git a/#ThirdParty/libSDL/lib/x64/SDL2test.lib b/#ThirdParty/libSDL/lib/x64/SDL2test.lib new file mode 100644 index 0000000..ef4eaad Binary files /dev/null and b/#ThirdParty/libSDL/lib/x64/SDL2test.lib differ diff --git a/#ThirdParty/libSDL/lib/x86/SDL2.dll b/#ThirdParty/libSDL/lib/x86/SDL2.dll new file mode 100644 index 0000000..15ad52e Binary files /dev/null and b/#ThirdParty/libSDL/lib/x86/SDL2.dll differ diff --git a/#ThirdParty/libSDL/lib/x86/SDL2.lib b/#ThirdParty/libSDL/lib/x86/SDL2.lib new file mode 100644 index 0000000..d24f272 Binary files /dev/null and b/#ThirdParty/libSDL/lib/x86/SDL2.lib differ diff --git a/#ThirdParty/libSDL/lib/x86/SDL2main.lib b/#ThirdParty/libSDL/lib/x86/SDL2main.lib new file mode 100644 index 0000000..5993374 Binary files /dev/null and b/#ThirdParty/libSDL/lib/x86/SDL2main.lib differ diff --git a/#ThirdParty/libSDL/lib/x86/SDL2test.lib b/#ThirdParty/libSDL/lib/x86/SDL2test.lib new file mode 100644 index 0000000..d9f3614 Binary files /dev/null and b/#ThirdParty/libSDL/lib/x86/SDL2test.lib differ diff --git a/.vs/BlitzNext/v14/.suo b/.vs/BlitzNext/v14/.suo index 93af6e7..555f44d 100644 Binary files a/.vs/BlitzNext/v14/.suo and b/.vs/BlitzNext/v14/.suo differ diff --git a/blitzide/IDE (logo, no code) 32.ico b/BlitzBasicIDE/IDE (logo, no code) 32.ico similarity index 100% rename from blitzide/IDE (logo, no code) 32.ico rename to BlitzBasicIDE/IDE (logo, no code) 32.ico diff --git a/blitzide/about.cpp b/BlitzBasicIDE/about.cpp similarity index 89% rename from blitzide/about.cpp rename to BlitzBasicIDE/about.cpp index b9fea3c..04be734 100644 --- a/blitzide/about.cpp +++ b/BlitzBasicIDE/about.cpp @@ -88,28 +88,7 @@ void aboutBlitz( bool delay ){ string t=""; -#ifdef PRO - t+="Blitz3D"; -#else - t+="Blitz2D"; -#endif - -#ifdef EDU - t+=" - Educational Version"; -#else -#ifdef DEMO - t+=" - Demo Version\n\n"; - /* - int n=shareProtCheck(); - if( n>1 ) t+=itoa(n)+" runs left"; - else if( n ) t+=itoa(n)+" run left"; - else t+="expired"; - t+=")\n\n"; - */ -#else - t+=" - Release Version\n\n"; -#endif -#endif + t+="BlitzNext"; about.GetDlgItem( IDC_PRODUCT )->SetWindowText( t.c_str() ); diff --git a/blitzide/about.h b/BlitzBasicIDE/about.h similarity index 100% rename from blitzide/about.h rename to BlitzBasicIDE/about.h diff --git a/blitzide/b3dlogo.bmp b/BlitzBasicIDE/b3dlogo.bmp similarity index 100% rename from blitzide/b3dlogo.bmp rename to BlitzBasicIDE/b3dlogo.bmp diff --git a/blitzide/blitzide.cpp b/BlitzBasicIDE/blitzide.cpp similarity index 100% rename from blitzide/blitzide.cpp rename to BlitzBasicIDE/blitzide.cpp diff --git a/blitzide/blitzide.dsp b/BlitzBasicIDE/blitzide.dsp similarity index 100% rename from blitzide/blitzide.dsp rename to BlitzBasicIDE/blitzide.dsp diff --git a/blitzide/blitzide.h b/BlitzBasicIDE/blitzide.h similarity index 100% rename from blitzide/blitzide.h rename to BlitzBasicIDE/blitzide.h diff --git a/blitzide/blitzide.rc b/BlitzBasicIDE/blitzide.rc similarity index 100% rename from blitzide/blitzide.rc rename to BlitzBasicIDE/blitzide.rc diff --git a/BlitzBasicIDE/blitzide.vcxproj b/BlitzBasicIDE/blitzide.vcxproj new file mode 100644 index 0000000..8fa610b --- /dev/null +++ b/BlitzBasicIDE/blitzide.vcxproj @@ -0,0 +1,204 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + MFCProj + {B61D8348-B715-42B8-A759-C7BBB0C8CD4D} + IDE + 8.1 + + + + Application + v140 + false + MultiByte + + + Application + v140 + false + MultiByte + + + + + + + + + + + + + + + ..\#Test\bin + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + ..\#Test\bin + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + + MultiThreadedDebug + Default + true + Disabled + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) + EnableFastChecks + true + true + true + false + false + true + Guard + Level3 + true + Speed + true + true + false + StdCall + + + true + _DEBUG;%(PreprocessorDefinitions) + .\Debug\blitzide.tlb + true + Win32 + + + 0x0409 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\blitzide.bsc + + + true + true + Windows + afxmem.obj;%(IgnoreSpecificDefaultLibraries) + ..\blitzbasic\bin\ide.exe + /FIXED:NO + ddraw.lib;dinput.lib;dsound.lib;dplayx.lib;dxguid.lib;winmm.lib;%(AdditionalDependencies) + + + + + MultiThreaded + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + true + Speed + false + false + false + StdCall + + + true + NDEBUG;%(PreprocessorDefinitions) + .\Release\blitzide.tlb + true + Win32 + + + 0x0409 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\blitzide.bsc + + + true + false + Windows + false + ..\blitzbasic\bin\ide.exe + winmm.lib;%(AdditionalDependencies) + + + + + + + + + + + + + Create + stdafx.h + Create + stdafx.h + + + + + + + + + + + + + + + + + + + + + + + + + + {3e355353-96d8-4aaf-bf95-8e6ca0d4b1ba} + false + + + + + + \ No newline at end of file diff --git a/blitzide/blitzide.vcxproj.filters b/BlitzBasicIDE/blitzide.vcxproj.filters similarity index 100% rename from blitzide/blitzide.vcxproj.filters rename to BlitzBasicIDE/blitzide.vcxproj.filters diff --git a/BlitzBasicIDE/editor.cpp b/BlitzBasicIDE/editor.cpp new file mode 100644 index 0000000..93bcc63 --- /dev/null +++ b/BlitzBasicIDE/editor.cpp @@ -0,0 +1,886 @@ + +#include "stdafx.h" +#include "blitzide.h" +#include "editor.h" + +static bool locked; + +#ifdef DEMO +static const int TEXTLIMIT = 16384; +#else +static const int TEXTLIMIT = 1024 * 1024 - 1; +#endif + +static const UINT wm_Find = RegisterWindowMessage(FINDMSGSTRING); + +IMPLEMENT_DYNAMIC(Editor, CWnd) +BEGIN_MESSAGE_MAP(Editor, CWnd) + ON_WM_CREATE() + ON_WM_SIZE() + ON_WM_SETFOCUS() + ON_WM_KILLFOCUS() + ON_WM_PAINT() + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONDOWN() + ON_WM_LBUTTONUP() + ON_CONTROL(EN_CHANGE, 1, en_change) + ON_CONTROL(EN_UPDATE, 1, en_update) + ON_NOTIFY(EN_SELCHANGE, 1, en_selchange) + ON_NOTIFY(EN_PROTECTED, 1, en_protected) + ON_NOTIFY(EN_MSGFILTER, 1, en_msgfilter) + ON_REGISTERED_MESSAGE(wm_Find, onFind) +END_MESSAGE_MAP() + +static int blink; +static set keyWordSet; +static map keyWordMap; + +static bool isid(int c) { + return isalnum(c) || c == '_'; +} + +static bool isfmt(int ch, int nxt) { + return ch == ';' || ch == '\"' || isalpha(ch) || isdigit(ch) || (ch == '$' && isxdigit(nxt)); +} + +static string rtfbgr(int bgr) { + return "\\red" + itoa(bgr & 0xff) + "\\green" + itoa((bgr >> 8) & 0xff) + "\\blue" + itoa((bgr >> 16) & 0xff) + ';'; +} + +DWORD Editor::streamIn(LPBYTE buff, LONG cnt, LONG *done) { + int n = 0; + while (n < cnt) { + if (is_curs == is_line.size()) { + if (is_stream->peek() == EOF) break; + is_curs = 0; is_line = ""; int c = 0; + for (;;) { + c = is_stream->get(); + if (c == '\r' || c == '\n' || c == EOF) break; + if (c == '\\' || c == '{' || c == '}') is_line += '\\'; + is_line += (char)c; + } + formatStreamLine(); ++is_linenum; + if (c == '\r' && is_stream->peek() == '\n') is_stream->get(); + if (is_stream->peek() == EOF) is_line += '}'; + } + int sz = is_line.size() - is_curs; + if (n + sz > cnt) sz = cnt - n; + memcpy(buff + n, is_line.data() + is_curs, sz); + is_curs += sz; n += sz; + } + *done = n; + return 0; +} + +DWORD CALLBACK Editor::streamIn(DWORD cookie, LPBYTE buff, LONG cnt, LONG *done) { + Editor *e = (Editor*)cookie; + return e->streamIn(buff, cnt, done); +} + +DWORD CALLBACK Editor::streamOut(DWORD cookie, LPBYTE buff, LONG cnt, LONG *done) { + ostream *out = (ostream*)cookie; + out->write((char*)buff, cnt); + *done = cnt; return 0; +} + +Editor::Editor(EditorListener *l) : + listener(l), sizing(false), tabber_width(170), + fmtBusy(false), findOnly(false), found(false), + finder(0), selStart(0), selEnd(0), + findFlags(0), lineToFmt(-1) { + findBuff[0] = replaceBuff[0] = 0; + if (!blink) blink = GetCaretBlinkTime(); + funcList.setListener(this); + typeList.setListener(this); + labsList.setListener(this); +} + +Editor::~Editor() { +} + +void Editor::resized() { + CRect r; + GetClientRect(&r); + int x = 0, y = 0, w = r.Width(), h = r.Height(); + if (w) { + if (tabber_width < 4) tabber_width = 4; + else if (w - 64 > 0 && tabber_width > w - 64) tabber_width = w - 64; + } + editCtrl.MoveWindow(x, y, w - tabber_width - 4, y + h); + tabber.MoveWindow(w - tabber_width + 4, y, tabber_width - 4, y + h); +} + +void Editor::OnPaint() { + CPaintDC dc(this); + + CRect r; + GetClientRect(&r); + int x = 0, y = 0, w = r.Width(), h = r.Height(); + + x = w - tabber_width - 4; + w = 8; + + CBrush br(GetSysColor(COLOR_3DFACE)); + CRect tr(x, y, x + w, y + h); + dc.FillRect(&tr, &br); + + // CRect ar( x,y,x+w,y+w ); + // dc.DrawFrameControl( &ar,DFC_SCROLL,DFCS_SCROLLRIGHT ); + // y+=w;h-=w; + + CRect dr(x + 2, y + 2, x + w - 2, y + h - 2); + dc.DrawEdge(&dr, EDGE_RAISED, BF_RECT); +} + +void Editor::OnMouseMove(UINT flags, CPoint p) { + CWnd::OnMouseMove(flags, p); + + CRect r; + GetClientRect(&r); + if (sizing) { + int dx = p.x - point.x, dy = p.y - point.y; + tabber_width -= dx; + resized(); Invalidate(); + point = p; + } else if (abs(p.x - (r.Width() - tabber_width)) < 4) { + SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE)); + } else { + SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); + } +} + +void Editor::OnSize(UINT type, int sw, int sh) { + CWnd::OnSize(type, sw, sh); + + resized(); +} + +void Editor::OnLButtonDown(UINT flags, CPoint p) { + + CRect r; + GetClientRect(&r); + + if (abs(p.x - (r.Width() - tabber_width)) < 4) { + point = p; + SetCapture(); + SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE)); + sizing = true; + } +} + +void Editor::OnLButtonUp(UINT flags, CPoint p) { + if (sizing) { + SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); + ReleaseCapture(); + sizing = false; + } + SetFocus(); +} + +int Editor::OnCreate(LPCREATESTRUCT cs) { + CWnd::OnCreate(cs); + + CHARFORMAT fmt; fmt.cbSize = sizeof(fmt); + fmt.dwMask = CFM_COLOR | CFM_PROTECTED; + fmt.dwEffects = CFE_PROTECTED; + fmt.crTextColor = prefs.rgb_default; + + PARAFORMAT pf; + memset(&pf, 0, sizeof(pf)); + pf.cbSize = sizeof(pf); + pf.dwMask = PFM_TABSTOPS; + pf.cTabCount = MAX_TAB_STOPS; + int tabTwips = 1440 * 8 / GetDeviceCaps(::GetDC(0), LOGPIXELSX) * prefs.edit_tabs; + for (int k = 0; k < MAX_TAB_STOPS; ++k) pf.rgxTabs[k] = k*tabTwips; + + CRect r(0, 0, 0, 0); + + editCtrl.Create( + WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER | + ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_NOHIDESEL, + r, this, 1); + editCtrl.SetFont(&prefs.editFont); + editCtrl.SetBackgroundColor(false, prefs.rgb_bkgrnd); + editCtrl.SetDefaultCharFormat(fmt); + editCtrl.SetEventMask(ENM_CHANGE | ENM_PROTECTED | ENM_KEYEVENTS | ENM_MOUSEEVENTS | ENM_SELCHANGE); + editCtrl.SetParaFormat(pf); + editCtrl.LimitText(TEXTLIMIT); + if (editCtrl.GetLimitText() != TEXTLIMIT) AfxMessageBox("Unable to set editor text Limit"); + editCtrl.SetModify(false); + + tabber.Create(WS_CHILD | WS_VISIBLE | TCS_BUTTONS | TCS_HOTTRACK, r, this, 2); + tabber.SetFont(&prefs.tabsFont); + tabber.SetPadding(CSize(3, 3)); + + tabber.setListener(this); + + int bk = prefs.rgb_bkgrnd; + int fg = prefs.rgb_ident; + + int ws = WS_CHILD | WS_BORDER; + + funcList.Create(ws | LVS_LIST | LVS_SHOWSELALWAYS, r, &tabber, 1); + funcList.SetFont(&prefs.debugFont); + funcList.SetBkColor(bk); + funcList.SetTextColor(fg); + funcList.SetTextBkColor(bk); + + typeList.Create(ws | LVS_LIST | LVS_SHOWSELALWAYS, r, &tabber, 2); + typeList.SetFont(&prefs.debugFont); + typeList.SetBkColor(bk); + typeList.SetTextColor(fg); + typeList.SetTextBkColor(bk); + + labsList.Create(ws | LVS_LIST | LVS_SHOWSELALWAYS, r, &tabber, 3); + labsList.SetFont(&prefs.debugFont); + labsList.SetBkColor(bk); + labsList.SetTextColor(fg); + labsList.SetTextBkColor(bk); + + tabber.insert(0, &funcList, "funcs"); + tabber.insert(1, &typeList, "types"); + tabber.insert(2, &labsList, "labels"); + + cursorMoved(); + + return 0; +} + +/************************************************* PUBLIC ***********************************************/ + +void Editor::setName(const string &n) { + name = n; +} + +bool Editor::setText(istream &in) { + // editCtrl.HideCaret(); + fmtBusy = true; + EDITSTREAM es; + es.dwCookie = (DWORD)this; + es.dwError = 0; + es.pfnCallback = streamIn; + is_line = "{{\\colortbl;" + rtfbgr(prefs.rgb_string) + rtfbgr(prefs.rgb_ident) + + rtfbgr(prefs.rgb_keyword) + rtfbgr(prefs.rgb_comment) + rtfbgr(prefs.rgb_digit) + + rtfbgr(prefs.rgb_default) + "}"; + int tabTwips = 1440 * 8 / GetDeviceCaps(::GetDC(0), LOGPIXELSX) * prefs.edit_tabs; + for (int k = 0; k < MAX_TAB_STOPS; ++k) is_line += "\\tx" + itoa(k*tabTwips) + ' '; + is_stream = ∈ + is_curs = is_linenum = 0; + funcList.clear(); + typeList.clear(); + labsList.clear(); + editCtrl.StreamIn(SF_RTF, es); + fmtBusy = false; + // editCtrl.HideCaret(); + caret(); + return es.dwError == 0; +} + +void Editor::setModified(bool n) { + editCtrl.SetModify(n); +} + +void Editor::setCursor(int n) { + int row = (n >> 16) & 0xffff, col = n & 0xffff; + int pos = editCtrl.LineIndex(row) + col; + editCtrl.SetSel(pos, pos); +} + +string Editor::getName()const { + return name; +} + +bool Editor::getText(ostream &out) { + fixFmt(true); + EDITSTREAM es; + es.dwCookie = (DWORD)&out; + es.dwError = 0; + es.pfnCallback = streamOut; + editCtrl.StreamOut(SF_TEXT, es); + return es.dwError == 0; +} + +void Editor::cut() { + editCtrl.Cut(); +} + +void Editor::copy() { + editCtrl.Copy(); +} + +void Editor::paste() { + editCtrl.PasteSpecial(CF_TEXT, 0); +} + +bool Editor::canCutCopy() { + getSel(); return selStart != selEnd; +} + +bool Editor::canPaste() { + return editCtrl.CanPaste() ? true : false; +} + +void Editor::print() { + + static const int MARG = 720; //1440=1 inch + + CPrintDialog dlg(false); + int e = dlg.DoModal(); if (e == IDCANCEL) return; + + HDC hdc = dlg.GetPrinterDC(); + if (!hdc) { + MessageBox("Error printing"); + return; + } + + int hr = GetDeviceCaps(hdc, HORZRES), vr = GetDeviceCaps(hdc, VERTRES); + int px = GetDeviceCaps(hdc, LOGPIXELSX), py = GetDeviceCaps(hdc, LOGPIXELSY); + + SetMapMode(hdc, MM_TEXT); + + FORMATRANGE fr = { 0 }; + fr.hdc = fr.hdcTarget = hdc; + fr.rcPage.left = fr.rcPage.top = 0; + fr.rcPage.right = (hr / px) * 1440; + fr.rcPage.bottom = (vr / py) * 1440; + + //margins + fr.rc.left = fr.rcPage.left + MARG; + fr.rc.top = fr.rcPage.top + MARG; + fr.rc.right = fr.rcPage.right - MARG; + fr.rc.bottom = fr.rcPage.bottom - MARG; + + char buff[MAX_PATH]; + strcpy(buff, name.c_str()); + + DOCINFO di = { sizeof(di) }; + di.lpszDocName = buff; + + getSel(); + int start = selStart, end = selEnd; + if (start == end) { start = 0; end = editCtrl.GetTextLength(); } + + StartDoc(hdc, &di); + while (start < end) { + StartPage(hdc); + fr.chrg.cpMin = start; + fr.chrg.cpMax = end; + start = editCtrl.FormatRange(&fr, true); + EndPage(hdc); + } + EndDoc(hdc); + + editCtrl.FormatRange(0, false); + DeleteDC(hdc); +} + +void Editor::find() { + if (finder) return; + finder = new CFindReplaceDialog(); + finder->m_fr.lpstrFindWhat = findBuff; + finder->m_fr.wFindWhatLen = 256; + finder->m_fr.lpstrReplaceWith = replaceBuff; + finder->m_fr.wReplaceWithLen = 256; + finder->Create(findOnly = true, 0, 0, FR_HIDEUPDOWN, this); + found = false; +} + +void Editor::replace() { + if (finder) return; + finder = new CFindReplaceDialog(); + finder->m_fr.lpstrFindWhat = findBuff; + finder->m_fr.wFindWhatLen = 256; + finder->m_fr.lpstrReplaceWith = replaceBuff; + finder->m_fr.wReplaceWithLen = 256; + finder->Create(findOnly = false, 0, 0, FR_HIDEUPDOWN, this); + found = false; +} + +bool Editor::canFind() { + return finder == 0; +} + +bool Editor::findNext(bool wrap) { + long start, end; + editCtrl.GetSel(start, end); + + FINDTEXTEX t; + memset(&t, 0, sizeof(t)); + t.chrg.cpMin = end; + t.chrg.cpMax = -1; + t.lpstrText = findBuff; + if (editCtrl.FindText(findFlags, &t) >= 0) { + editCtrl.SetSel(t.chrgText.cpMin, t.chrgText.cpMax); + return true; + } + if (!wrap) return false; + t.chrg.cpMin = 0; + t.chrg.cpMax = end; + if (editCtrl.FindText(findFlags, &t) >= 0) { + editCtrl.SetSel(t.chrgText.cpMin, t.chrgText.cpMax); + return true; + } + string s("Can't find \""); s += findBuff; s += '\"'; + MessageBox(s.c_str(), "Text not found"); + if (finder) finder->SetFocus(); + return false; +} + +void Editor::hilight(int pos) { + int row = (pos >> 16) & 0xffff, col = pos & 0xffff; + pos = editCtrl.LineIndex(row) + col; + + editCtrl.HideSelection(true, false); + getSel(); + bool quote = false; + int end = pos, len = editCtrl.GetTextLength(); + while (end < len) { + char temp[8]; + editCtrl.SetSel(end, end + 1); + auto txt = editCtrl.GetSelText(); + if (txt[0] == '\"') quote = !quote; + if (!quote && (txt[0] == ':' || !isprint(txt[0]))) break; + ++end; + } + editCtrl.HideSelection(false, false); + editCtrl.SetSel(pos, end); +} + +void Editor::selectAll() { + editCtrl.SetSel(0, -1); +} + +void Editor::lock() { + locked = true; +} + +void Editor::unlock() { + locked = false; +} + +string Editor::getKeyword() { + fixFmt(true); + getSel(); + int ln = editCtrl.LineFromChar(selStart); + int pos = selStart - editCtrl.LineIndex(ln); + string line = getLine(ln); if (pos > line.size()) return ""; + + //ok, scan back until we have an isapha char preceded by a nonalnum/non '_' char + for (;;) { + while (pos > 0 && (!isalpha(line[pos]) || isid(line[pos - 1]))) --pos; + if (!isalpha(line[pos])) return ""; + int end = pos; while (end < line.size() && isid(line[end])) ++end; + string t = line.substr(pos, end - pos); + if (keyWordSet.find(t) != keyWordSet.end()) return t; + if (!pos) return ""; + --pos; + } +} + +bool Editor::getModified() { + return editCtrl.GetModify() ? true : false; +} + +int Editor::getCursor() { + long start, end; + editCtrl.GetSel(start, end); + int row, col; + row = editCtrl.LineFromChar(start); + col = start - editCtrl.LineIndex(row); + return ((row) << 16) | (col); +} + +void Editor::getCursor(int *row, int *col) { + long start, end; + editCtrl.GetSel(start, end); + *row = editCtrl.LineFromChar(end); + *col = end - editCtrl.LineIndex(*row); +} + +void Editor::addKeyword(const string &s) { + keyWordSet.insert(s); + string t = s; + for (int k = 0; k < t.size(); ++k) t[k] = tolower(t[k]); + keyWordMap[t] = s; +} + +/************************************************* PRIVATE ***********************************************/ + +void Editor::endFind() { + if (!finder) return; + finder->DestroyWindow(); + finder = 0; +} + +LRESULT Editor::onFind(WPARAM w, LPARAM l) { + if (!finder) return 0; + + findFlags = 0; + if (finder->MatchCase()) findFlags |= FR_MATCHCASE; + if (finder->MatchWholeWord()) findFlags |= FR_WHOLEWORD; + strcpy(findBuff, finder->GetFindString()); + strcpy(replaceBuff, finder->GetReplaceString()); + + if (finder->FindNext()) { + found = findNext(true); + if (found && findOnly) endFind(); + } else if (finder->ReplaceCurrent()) { + if (found) editCtrl.ReplaceSel(replaceBuff, true); + found = findNext(true); + } else if (finder->ReplaceAll()) { + int cnt = 0; + editCtrl.HideSelection(true, false); + editCtrl.SetSel(0, 0); + while (findNext(false)) { + editCtrl.ReplaceSel(replaceBuff, true); + ++cnt; + } + endFind(); + char buff[32]; itoa(cnt, buff, 10); + string s(buff); s += " occurances replaced"; + MessageBox(s.c_str(), "Replace All Done"); + editCtrl.HideSelection(false, false); + } + + if (finder && finder->IsTerminating()) endFind(); + + return 0; +} + +void Editor::caret() { + if (!prefs.edit_blkcursor) return; + long start, end; + editCtrl.GetSel(start, end); + if (start == end) { + editCtrl.CreateSolidCaret(8, 13); + editCtrl.ShowCaret(); + } else editCtrl.HideCaret(); +} + +void Editor::OnSetFocus(CWnd *wnd) { + if (prefs.edit_blkcursor) SetCaretBlinkTime(200); + editCtrl.SetFocus(); + caret(); +} + +void Editor::OnKillFocus(CWnd *wnd) { + CWnd::OnKillFocus(wnd); + fixFmt(true); +} + +string Editor::getLine(int line) { + int idx1 = editCtrl.LineIndex(line); + int idx2 = editCtrl.LineIndex(line + 1); if (idx2 == -1) idx2 = editCtrl.GetTextLength(); + int len = idx2 - idx1; + char *buff = new char[len > 3 ? len + 1 : 4]; + *(int*)buff = len; + int out = editCtrl.GetLine(line, buff); + buff[len] = 0; + string t = string(buff); + delete[] buff; + return t; +} + +void Editor::funcSelected(int line) { + int pos = editCtrl.LineIndex(line); + editCtrl.SetSel(editCtrl.GetTextLength() - 1, editCtrl.GetTextLength() - 1); + editCtrl.SetSel(pos, pos); + SetFocus(); +} + +void Editor::currentSet(Tabber *tabber, int index) { + SetFocus(); +} + +void Editor::cursorMoved() { + listener->cursorMoved(this); +} + +void Editor::en_update() { + caret(); +} + +void Editor::en_msgfilter(NMHDR *nmhdr, LRESULT *result) { + if (locked || fmtBusy) { *result = 1; return; } + + *result = 0; + getSel(); + + MSGFILTER *msg = (MSGFILTER*)nmhdr; + + + if (msg->msg == WM_RBUTTONDOWN) { + + CPoint p(LOWORD(msg->lParam), HIWORD(msg->lParam)); + + ClientToScreen(&p); + + CMenu *menu = blitzIDE.mainFrame->GetMenu(); + + CMenu *edit = menu->GetSubMenu(1); + + edit->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, blitzIDE.mainFrame); + + } else if (msg->msg == WM_CHAR) { + if (msg->wParam == '\t') { + int lineStart = editCtrl.LineFromChar(selStart); + int lineEnd = editCtrl.LineFromChar(selEnd); + if (lineEnd <= lineStart) return; + editCtrl.HideSelection(true, false); + if (GetAsyncKeyState(VK_SHIFT) & 0x80000000) { + char buff[4]; + for (int line = lineStart; line < lineEnd; ++line) { + int n = editCtrl.LineIndex(line); + editCtrl.SetSel(n, n + 1); + auto txt = editCtrl.GetSelText(); + if (txt[0] == '\t') editCtrl.ReplaceSel("", true); + } + } else { + for (int line = lineStart; line < lineEnd; ++line) { + int n = editCtrl.LineIndex(line); + editCtrl.SetSel(n, n); editCtrl.ReplaceSel("\t", true); + } + } + selStart = editCtrl.LineIndex(lineStart); + selEnd = editCtrl.LineIndex(lineEnd); + setSel(); *result = 1; + editCtrl.HideSelection(false, false); + } else if (msg->wParam == 13) { + if (selStart != selEnd) return; + int k; + int ln = editCtrl.LineFromChar(selStart); + int pos = selStart - editCtrl.LineIndex(ln); + string line = getLine(ln); if (pos > line.size()) return; + for (k = 0; k < pos && line[k] == '\t'; ++k) {} + line = "\r\n" + line.substr(0, k) + '\0'; + editCtrl.ReplaceSel(line.data(), true); + *result = 1; + } + } + caret(); +} + +void Editor::en_selchange(NMHDR *nmhdr, LRESULT *result) { + if (!fmtBusy) fixFmt(false); + cursorMoved(); + caret(); +} + +void Editor::en_protected(NMHDR *nmhdr, LRESULT *result) { + *result = 0; if (fmtBusy) return; + fmtLineCount = editCtrl.GetLineCount(); + found = false; +} + +void Editor::en_change() { + if (fmtBusy) return; + + fmtBusy = true; + editCtrl.HideSelection(true, false); + getSel(); + + int begin = editCtrl.LineFromChar(selStart); + int end = begin + 1; + + int lineCount = editCtrl.GetLineCount(); + int delta = lineCount - fmtLineCount; + + if (delta > 0) { + begin -= delta; + funcList.relocate(begin, delta); + typeList.relocate(begin, delta); + labsList.relocate(begin, delta); + funcList.remove(begin, end); + typeList.remove(begin, end); + labsList.remove(begin, end); + } else if (delta < 0) { + int t = end - delta; + funcList.remove(begin, t); + typeList.remove(begin, t); + labsList.remove(begin, t); + funcList.relocate(t, delta); + typeList.relocate(t, delta); + labsList.relocate(t, delta); + } else { + funcList.remove(begin, end); + typeList.remove(begin, end); + labsList.remove(begin, end); + } + + for (int n = begin; n < end; ++n) formatLine(n); + + setSel(); editCtrl.HideSelection(false, false); + fmtBusy = false; + cursorMoved(); +} + +void Editor::setFormat(int from, int to, int color, const string &s) { + editCtrl.SetSel(from, to); + if (s.size()) { + char buff[256]; + CString txt = editCtrl.GetSelText(); + txt[to - from] = 0; + if (string(buff) != s) { + editCtrl.ReplaceSel(s.c_str()); + editCtrl.SetSel(from, to); + } + } + CHARFORMAT fmt; + fmt.cbSize = sizeof(fmt); + DWORD t = editCtrl.GetSelectionCharFormat(fmt); + if ((t&CFM_COLOR) && fmt.crTextColor == color) return; + fmt.dwMask = CFM_COLOR | CFM_PROTECTED; + fmt.dwEffects = CFE_PROTECTED; + fmt.crTextColor = color; + editCtrl.SetSelectionCharFormat(fmt); +} + +void Editor::formatStreamLine() { + string out; + char cf = '0'; + for (int k = 0; k < is_line.size(); ) { + int from = k; + char pf = cf; + int c = is_line[k], is_sz = is_line.size(); + if (!isgraph(c)) { + for (++k; k < is_sz && !isgraph(is_line[k]); ++k) {} + } else if (!isfmt(c, k + 1 < is_sz ? is_line[k + 1] : 0)) { + for (++k; k < is_sz && !isfmt(is_line[k], k + 1 < is_sz ? is_line[k + 1] : 0); ++k) {} + cf = '6'; + } else if (c == ';') { //comment? + k = is_sz; + cf = '4'; + } else if (c == '\"') { //string const? + for (++k; k < is_sz && is_line[k] != '\"'; ++k) {} + if (k < is_sz) ++k; + cf = '1'; + } else if (isalpha(c)) { //ident? + for (++k; k < is_sz && isid(is_line[k]); ++k) {} + if (keyWordSet.find(is_line.substr(from, k - from)) == keyWordSet.end()) cf = '2'; + else cf = '3'; + } else if (c == '$') { + for (++k; k < is_sz && isxdigit(is_line[k]); ++k) {} + cf = '5'; + } else if (isdigit(c)) { //numeric const? + for (++k; k < is_sz && isdigit(is_line[k]); ++k) {} + cf = '5'; + } + if (cf != pf) { + out += "\\cf"; out += cf; out += ' '; + } + out += is_line.substr(from, k - from); + } + if (is_line[0] == 'F' && is_line.find("Function") == 0) { + for (int k = 8; k < is_line.size(); ++k) { + if (isalpha(is_line[k])) { + int start = k; + for (++k; k < is_line.size() && isid(is_line[k]); ++k) {} + funcList.insert(is_linenum, is_line.substr(start, k - start)); + break; + } + } + } else if (is_line[0] == 'T' && is_line.find("Type") == 0) { + for (int k = 4; k < is_line.size(); ++k) { + if (isalpha(is_line[k])) { + int start = k; + for (++k; k < is_line.size() && isid(is_line[k]); ++k) {} + typeList.insert(is_linenum, is_line.substr(start, k - start)); + break; + } + } + } else if (is_line[0] == '.') { + for (int k = 1; k < is_line.size(); ++k) { + if (isalpha(is_line[k])) { + int start = k; + for (++k; k < is_line.size() && isid(is_line[k]); ++k) {} + labsList.insert(is_linenum, is_line.substr(start, k - start)); + break; + } + } + } + is_line = out + "\\line "; +} + +void Editor::fixFmt(bool fmt) { + if (lineToFmt < 0 || fmtBusy) return; + fmtBusy = true; + editCtrl.HideSelection(true, false); getSel(); + long start = selStart; if (fmt) selStart = -1; + formatLine(lineToFmt); + selStart = start; setSel(); editCtrl.HideSelection(false, false); + fmtBusy = false; +} + +void Editor::formatLine(int ln) { + if (ln < 0 || ln >= editCtrl.GetLineCount()) return; + + lineToFmt = -1; + int pos = editCtrl.LineIndex(ln); + string tline = getLine(ln); + string line = tolower(tline); + + int *cf = 0; + string rep; + for (int k = 0; k < line.size(); ) { + rep.resize(0); + int *pf = cf; + int from = k, c = line[k], sz = line.size(); + if (!isgraph(c)) { + for (++k; k < sz && !isgraph(line[k]); ++k) {} + } else if (!isfmt(c, k + 1 < sz ? line[k + 1] : 0)) { + for (++k; k < sz && !isfmt(line[k], k + 1 < sz ? line[k + 1] : 0); ++k) {} + cf = &prefs.rgb_default; + } else if (c == ';') { //comment? + k = sz; + cf = &prefs.rgb_comment; + } else if (c == '\"') { //string const? + for (++k; k < sz && line[k] != '\"'; ++k) {} + if (k < sz) ++k; + cf = &prefs.rgb_string; + } else if (isalpha(c)) { //ident? + for (++k; k < sz && isid(line[k]); ++k) {} + cf = &prefs.rgb_ident; pf = 0; + if (selStart <= pos + from || selStart > pos + k) { + map::iterator it = keyWordMap.find(line.substr(from, k - from)); + if (it != keyWordMap.end()) { + rep = it->second; cf = &prefs.rgb_keyword; + } + } else lineToFmt = ln; + } else if (c == '$' && k + 1 < sz && isxdigit(line[k + 1])) { + for (++k; k < sz && isxdigit(line[k]); ++k) {} + cf = &prefs.rgb_digit; + } else if (isdigit(c)) { //numeric const? + for (++k; k < sz && isdigit(line[k]); ++k) {} + cf = &prefs.rgb_digit; + } + if (cf != pf) setFormat(pos + from, pos + k, *cf, rep); + } + if (line[0] == 'f' && line.find("function") == 0) { + for (int k = 8; k < line.size(); ++k) { + if (isalpha(line[k])) { + int start = k; + for (++k; k < line.size() && isid(line[k]); ++k) {} + funcList.insert(ln, tline.substr(start, k - start)); + break; + } + } + } else if (line[0] == 't' && line.find("type") == 0) { + for (int k = 4; k < line.size(); ++k) { + if (isalpha(line[k])) { + int start = k; + for (++k; k < line.size() && isid(line[k]); ++k) {} + typeList.insert(ln, tline.substr(start, k - start)); + break; + } + } + } else if (line[0] == '.') { + for (int k = 1; k < line.size(); ++k) { + if (isalpha(line[k])) { + int start = k; + for (++k; k < line.size() && isid(line[k]); ++k) {} + labsList.insert(ln, tline.substr(start, k - start)); + break; + } + } + } +} diff --git a/blitzide/editor.h b/BlitzBasicIDE/editor.h similarity index 100% rename from blitzide/editor.h rename to BlitzBasicIDE/editor.h diff --git a/blitzide/funclist.cpp b/BlitzBasicIDE/funclist.cpp similarity index 100% rename from blitzide/funclist.cpp rename to BlitzBasicIDE/funclist.cpp diff --git a/blitzide/funclist.h b/BlitzBasicIDE/funclist.h similarity index 100% rename from blitzide/funclist.h rename to BlitzBasicIDE/funclist.h diff --git a/blitzide/htmlhelp.cpp b/BlitzBasicIDE/htmlhelp.cpp similarity index 89% rename from blitzide/htmlhelp.cpp rename to BlitzBasicIDE/htmlhelp.cpp index f0914e1..5f5a2cb 100644 --- a/blitzide/htmlhelp.cpp +++ b/BlitzBasicIDE/htmlhelp.cpp @@ -4,8 +4,8 @@ #include "mainframe.h" #include "libs.h" -IMPLEMENT_DYNAMIC( HtmlHelp,CHtmlView ) -BEGIN_MESSAGE_MAP( HtmlHelp,CHtmlView ) +IMPLEMENT_DYNAMIC( HtmlHelp, CHtmlView ) +BEGIN_MESSAGE_MAP( HtmlHelp, CHtmlView ) ON_WM_ERASEBKGND() END_MESSAGE_MAP() diff --git a/blitzide/htmlhelp.h b/BlitzBasicIDE/htmlhelp.h similarity index 100% rename from blitzide/htmlhelp.h rename to BlitzBasicIDE/htmlhelp.h diff --git a/blitzide/libs.cpp b/BlitzBasicIDE/libs.cpp similarity index 100% rename from blitzide/libs.cpp rename to BlitzBasicIDE/libs.cpp diff --git a/blitzide/libs.h b/BlitzBasicIDE/libs.h similarity index 100% rename from blitzide/libs.h rename to BlitzBasicIDE/libs.h diff --git a/blitzide/mainframe.cpp b/BlitzBasicIDE/mainframe.cpp similarity index 99% rename from blitzide/mainframe.cpp rename to BlitzBasicIDE/mainframe.cpp index 510495a..a786ccc 100644 --- a/blitzide/mainframe.cpp +++ b/BlitzBasicIDE/mainframe.cpp @@ -193,13 +193,8 @@ void MainFrame::OnDestroy(){ } void MainFrame::setTitle( const string &s ){ -#ifdef PRO SetWindowText( ("Blitz3D - "+s ).c_str() ); return; -#else - SetWindowText( ("Blitz2D - "+s ).c_str() ); - return; -#endif } void MainFrame::OnClose(){ @@ -233,11 +228,9 @@ static char *bbFilter= "Blitz Basic files (.bb)|*.bb|" -#ifdef PRO "Image files (.bmp,.jpg,.png,.tga,.iff,.pcx)|*.bmp;*.jpg;*.png;*.tga;*.iff;*.pcx|" "Audio files (.wav,.mid,.mod,.mp3,.s3m,.xm,.it,.rmi,.sgt)|*.wav;*.mid;*.mod;*.mp3;*.s3m;*.xm;*.it;*.rmi;*.sgt|" "3D Mesh files (.x,.3ds,.md2)|*.x;*.3ds;*.md2|" -#endif "All files|*.*||"; @@ -898,9 +891,7 @@ static string commandURL( const string &t ){ static char *dirs[]={ "help\\commands\\2d_commands\\", -#ifdef PRO "help\\commands\\3d_commands\\", -#endif 0 }; diff --git a/blitzide/mainframe.h b/BlitzBasicIDE/mainframe.h similarity index 100% rename from blitzide/mainframe.h rename to BlitzBasicIDE/mainframe.h diff --git a/blitzide/prefs.cpp b/BlitzBasicIDE/prefs.cpp similarity index 99% rename from blitzide/prefs.cpp rename to BlitzBasicIDE/prefs.cpp index 2c348cd..3508f33 100644 --- a/blitzide/prefs.cpp +++ b/BlitzBasicIDE/prefs.cpp @@ -134,8 +134,8 @@ void Prefs::setDefault(){ font_editor="courier"; font_editor_height=10; #else - font_editor="blitz"; - font_editor_height=12; + font_editor="Consolas"; + font_editor_height=10; #endif font_tabs="verdana"; font_tabs_height=8; diff --git a/blitzide/prefs.h b/BlitzBasicIDE/prefs.h similarity index 100% rename from blitzide/prefs.h rename to BlitzBasicIDE/prefs.h diff --git a/blitzide/resource.h b/BlitzBasicIDE/resource.h similarity index 100% rename from blitzide/resource.h rename to BlitzBasicIDE/resource.h diff --git a/blitzide/stdafx.cpp b/BlitzBasicIDE/stdafx.cpp similarity index 100% rename from blitzide/stdafx.cpp rename to BlitzBasicIDE/stdafx.cpp diff --git a/blitzide/stdafx.h b/BlitzBasicIDE/stdafx.h similarity index 100% rename from blitzide/stdafx.h rename to BlitzBasicIDE/stdafx.h diff --git a/blitzide/tabber.cpp b/BlitzBasicIDE/tabber.cpp similarity index 100% rename from blitzide/tabber.cpp rename to BlitzBasicIDE/tabber.cpp diff --git a/blitzide/tabber.h b/BlitzBasicIDE/tabber.h similarity index 100% rename from blitzide/tabber.h rename to BlitzBasicIDE/tabber.h diff --git a/bblaunch/bblaunch.cpp b/BlitzBasicLauncher/bblaunch.cpp similarity index 88% rename from bblaunch/bblaunch.cpp rename to BlitzBasicLauncher/bblaunch.cpp index a951191..c43e2b9 100644 --- a/bblaunch/bblaunch.cpp +++ b/BlitzBasicLauncher/bblaunch.cpp @@ -56,15 +56,15 @@ int _stdcall WinMain( HINSTANCE inst,HINSTANCE prev,char *cmd,int show ){ if( getIEVersion()<4 ) fail( ie_err ); //Ugly hack to get application dir... - string t=getAppDir(); - putenv( ("blitzpath="+t).c_str() ); - SetCurrentDirectory( t.c_str() ); - t=t+"\\bin\\ide.exe "+cmd; + string blitzIdePath=getAppDir(); + _putenv( ("blitzpath="+blitzIdePath).c_str() ); + SetCurrentDirectory( blitzIdePath.c_str() ); + blitzIdePath=blitzIdePath+"\\bin\\ide.exe "+cmd; STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si,sizeof(si));si.cb=sizeof(si); - if( !CreateProcess( 0,(char*)t.c_str(),0,0,0,0,0,0,&si,&pi ) ){ + if( !CreateProcess( 0,(char*)blitzIdePath.c_str(),0,0,0,0,0,0,&si,&pi ) ){ ::MessageBox( 0,bb_err,"Blitz Basic Error",MB_SETFOREGROUND|MB_TOPMOST|MB_ICONERROR ); ExitProcess(-1); } diff --git a/bblaunch/bblaunch.dsp b/BlitzBasicLauncher/bblaunch.dsp similarity index 100% rename from bblaunch/bblaunch.dsp rename to BlitzBasicLauncher/bblaunch.dsp diff --git a/bblaunch/bblaunch.ico b/BlitzBasicLauncher/bblaunch.ico similarity index 100% rename from bblaunch/bblaunch.ico rename to BlitzBasicLauncher/bblaunch.ico diff --git a/bblaunch/bblaunch.rc b/BlitzBasicLauncher/bblaunch.rc similarity index 100% rename from bblaunch/bblaunch.rc rename to BlitzBasicLauncher/bblaunch.rc diff --git a/BlitzBasicLauncher/bblaunch.vcxproj b/BlitzBasicLauncher/bblaunch.vcxproj new file mode 100644 index 0000000..54066cf --- /dev/null +++ b/BlitzBasicLauncher/bblaunch.vcxproj @@ -0,0 +1,200 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + {C74A383E-81B0-4679-AAC9-535C94C92EA5} + BlitzBasicLauncher + 8.1 + + + + Application + v140 + false + MultiByte + + + Application + v140 + false + MultiByte + + + + + + + + + + + + + + + ..\#Test + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + ..\#Test + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + + MultiThreadedDebug + Default + true + Disabled + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) + EnableFastChecks + true + true + true + false + false + true + Guard + Level3 + true + Speed + true + true + false + StdCall + + + true + _DEBUG;%(PreprocessorDefinitions) + .\Debug\bblaunch.tlb + true + Win32 + + + 0x0409 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\bblaunch.bsc + + + true + true + Windows + /FIXED:NO + dxguid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + MultiThreaded + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + true + Speed + false + false + false + StdCall + + + true + NDEBUG;%(PreprocessorDefinitions) + .\Release\bblaunch.tlb + true + Win32 + + + 0x0409 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\bblaunch.bsc + + + true + Windows + dxguid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + {be0ba538-6215-4836-9227-1d3627e40d61} + false + + + {c23af61e-9509-411f-933e-17db18884b21} + false + + + {d884a075-e3b8-44e1-838d-74f28b33391b} + false + + + {3e355353-96d8-4aaf-bf95-8e6ca0d4b1ba} + false + + + {4132c330-95d9-4f68-a51a-3b90381587c5} + false + + + {ff2d8bf7-1930-4cab-bc48-05cd33b7dc18} + false + + + {6bcfc5ca-ea71-4ae9-8b96-28b8701f939e} + false + + + + + + \ No newline at end of file diff --git a/bblaunch/blitzide.prefs b/BlitzBasicLauncher/blitzide.prefs similarity index 100% rename from bblaunch/blitzide.prefs rename to BlitzBasicLauncher/blitzide.prefs diff --git a/BlitzBasicLauncher/checkdx.cpp b/BlitzBasicLauncher/checkdx.cpp new file mode 100644 index 0000000..94b651e --- /dev/null +++ b/BlitzBasicLauncher/checkdx.cpp @@ -0,0 +1,343 @@ + +//----------------------------------------------------------------------------- +// File: GetDXVer.cpp +// +// Desc: Demonstrates how applications can detect what version of DirectX +// is installed. +// +// (C) Copyright 1995-1997 Microsoft Corp. All rights reserved. +//----------------------------------------------------------------------------- +#include +#include +#include +#define DIRECTINPUT_VERSION 0x0700 +#include +//#include + +typedef HRESULT(WINAPI * DIRECTDRAWCREATE)( GUID*, LPDIRECTDRAW*, IUnknown* ); +typedef HRESULT(WINAPI * DIRECTDRAWCREATEEX)( GUID*, VOID**, REFIID, IUnknown* ); +typedef HRESULT(WINAPI * DIRECTINPUTCREATE)( HINSTANCE, DWORD, LPDIRECTINPUT*, + IUnknown* ); + + + +//----------------------------------------------------------------------------- +// Name: GetDXVersion() +// Desc: This function returns two arguments: +// dwDXVersion: +// 0x0000 = No DirectX installed +// 0x0100 = DirectX version 1 installed +// 0x0200 = DirectX 2 installed +// 0x0300 = DirectX 3 installed +// 0x0500 = At least DirectX 5 installed. +// 0x0600 = At least DirectX 6 installed. +// 0x0601 = At least DirectX 6.1 installed. +// 0x0700 = At least DirectX 7 installed. +// dwDXPlatform: +// 0 = Unknown (This is a failure case) +// VER_PLATFORM_WIN32_WINDOWS = Windows 9X platform +// VER_PLATFORM_WIN32_NT = Windows NT platform +// +// Please note that this code is intended as a general guideline. Your +// app will probably be able to simply query for functionality (via +// QueryInterface) for one or two components. +// +// Please also note: +// "if (dxVer != 0x500) return FALSE;" is BAD. +// "if (dxVer < 0x500) return FALSE;" is MUCH BETTER. +// to ensure your app will run on future releases of DirectX. +//----------------------------------------------------------------------------- +VOID GetDXVersion( DWORD* pdwDXVersion, DWORD* pdwDXPlatform ) +{ + *pdwDXVersion = 0x0700; + *pdwDXPlatform = VER_PLATFORM_WIN32_NT; + // HRESULT hr; + // HINSTANCE DDHinst = 0; + // HINSTANCE DIHinst = 0; + // LPDIRECTDRAW pDDraw = 0; + // LPDIRECTDRAW2 pDDraw2 = 0; + // DIRECTDRAWCREATE DirectDrawCreate = 0; + // DIRECTDRAWCREATEEX DirectDrawCreateEx = 0; + // DIRECTINPUTCREATE DirectInputCreate = 0; + // OSVERSIONINFO osVer; + // LPDIRECTDRAWSURFACE pSurf = 0; + // LPDIRECTDRAWSURFACE3 pSurf3 = 0; + // LPDIRECTDRAWSURFACE4 pSurf4 = 0; + + // // First get the windows platform + // osVer.dwOSVersionInfoSize = sizeof(osVer); + // if( !GetVersionEx( &osVer ) ) + // { + // (*pdwDXPlatform) = 0; + // (*pdwDXVersion) = 0; + // return; + // } + + // if( osVer.dwPlatformId == VER_PLATFORM_WIN32_NT ) + // { + // (*pdwDXPlatform) = VER_PLATFORM_WIN32_NT; + + // // NT is easy... NT 4.0 is DX2, 4.0 SP3 is DX3, 5.0 is DX5 + // // and no DX on earlier versions. + // if( osVer.dwMajorVersion < 4 ) + // { + // (*pdwDXVersion) = 0; // No DX on NT3.51 or earlier + // return; + // } + + // if( osVer.dwMajorVersion == 4 ) + // { + // // NT4 up to SP2 is DX2, and SP3 onwards is DX3, so we are at least DX2 + // (*pdwDXVersion) = 0x200; + + // // We're not supposed to be able to tell which SP we're on, so check for dinput + // DIHinst = LoadLibrary( "DINPUT.DLL" ); + // if( DIHinst == 0 ) + // { + // // No DInput... must be DX2 on NT 4 pre-SP3 + // OutputDebugString( "Couldn't LoadLibrary DInput\r\n" ); + // return; + // } + + // DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst, + // "DirectInputCreateA" ); + // FreeLibrary( DIHinst ); + + // if( DirectInputCreate == 0 ) + // { + // // No DInput... must be pre-SP3 DX2 + // OutputDebugString( "Couldn't GetProcAddress DInputCreate\r\n" ); + // return; + // } + + // // It must be NT4, DX2 + // (*pdwDXVersion) = 0x300; // DX3 on NT4 SP3 or higher + // return; + // } + // // Else it's NT5 or higher, and it's DX5a or higher: Drop through to + // // Win9x tests for a test of DDraw (DX6 or higher) + // } + // else + // { + // // Not NT... must be Win9x + // (*pdwDXPlatform) = VER_PLATFORM_WIN32_WINDOWS; + // } + + // // Now we know we are in Windows 9x (or maybe 3.1), so anything's possible. + // // First see if DDRAW.DLL even exists. + // DDHinst = LoadLibrary( "DDRAW.DLL" ); + // if( DDHinst == 0 ) + // { + // (*pdwDXVersion) = 0; + // (*pdwDXPlatform) = 0; + // FreeLibrary( DDHinst ); + // return; + // } + + // // See if we can create the DirectDraw object. + // DirectDrawCreate = (DIRECTDRAWCREATE)GetProcAddress( DDHinst, "DirectDrawCreate" ); + // if( DirectDrawCreate == 0 ) + // { + // (*pdwDXVersion) = 0; + // (*pdwDXPlatform) = 0; + // FreeLibrary( DDHinst ); + // OutputDebugString( "Couldn't LoadLibrary DDraw\r\n" ); + // return; + // } + + // hr = DirectDrawCreate( NULL, &pDDraw, NULL ); + // if( FAILED(hr) ) + // { + // (*pdwDXVersion) = 0; + // (*pdwDXPlatform) = 0; + // FreeLibrary( DDHinst ); + // OutputDebugString( "Couldn't create DDraw\r\n" ); + // return; + // } + + // // So DirectDraw exists. We are at least DX1. + // (*pdwDXVersion) = 0x100; + + // // Let's see if IID_IDirectDraw2 exists. + // hr = pDDraw->QueryInterface( IID_IDirectDraw2, (VOID**)&pDDraw2 ); + // if( FAILED(hr) ) + // { + // // No IDirectDraw2 exists... must be DX1 + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // OutputDebugString( "Couldn't QI DDraw2\r\n" ); + // return; + // } + + // // IDirectDraw2 exists. We must be at least DX2 + // pDDraw2->Release(); + // (*pdwDXVersion) = 0x200; + + + // /////////////////////////////////////////////////////////////////////////// + // // DirectX 3.0 Checks + // /////////////////////////////////////////////////////////////////////////// + + // // DirectInput was added for DX3 + // DIHinst = LoadLibrary( "DINPUT.DLL" ); + // if( DIHinst == 0 ) + // { + // // No DInput... must not be DX3 + // OutputDebugString( "Couldn't LoadLibrary DInput\r\n" ); + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // return; + // } + + // DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst, + // "DirectInputCreateA" ); + // if( DirectInputCreate == 0 ) + // { + // // No DInput... must be DX2 + // FreeLibrary( DIHinst ); + // FreeLibrary( DDHinst ); + // pDDraw->Release(); + // OutputDebugString( "Couldn't GetProcAddress DInputCreate\r\n" ); + // return; + // } + + // // DirectInputCreate exists. We are at least DX3 + // (*pdwDXVersion) = 0x300; + // FreeLibrary( DIHinst ); + + // // Can do checks for 3a vs 3b here + + + // /////////////////////////////////////////////////////////////////////////// + // // DirectX 5.0 Checks + // /////////////////////////////////////////////////////////////////////////// + + // // We can tell if DX5 is present by checking for the existence of + // // IDirectDrawSurface3. First, we need a surface to QI off of. + // DDSURFACEDESC ddsd; + // ZeroMemory( &ddsd, sizeof(ddsd) ); + // ddsd.dwSize = sizeof(ddsd); + // ddsd.dwFlags = DDSD_CAPS; + // ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + // hr = pDDraw->SetCooperativeLevel( NULL, DDSCL_NORMAL ); + // if( FAILED(hr) ) + // { + // // Failure. This means DDraw isn't properly installed. + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // (*pdwDXVersion) = 0; + // OutputDebugString( "Couldn't Set coop level\r\n" ); + // return; + // } + + // hr = pDDraw->CreateSurface( &ddsd, &pSurf, NULL ); + // if( FAILED(hr) ) + // { + // // Failure. This means DDraw isn't properly installed. + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // *pdwDXVersion = 0; + // OutputDebugString( "Couldn't CreateSurface\r\n" ); + // return; + // } + + // // Query for the IDirectDrawSurface3 interface + // if( FAILED( pSurf->QueryInterface( IID_IDirectDrawSurface3, + // (VOID**)&pSurf3 ) ) ) + // { + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // return; + // } + + // // QI for IDirectDrawSurface3 succeeded. We must be at least DX5 + // (*pdwDXVersion) = 0x500; + + + // /////////////////////////////////////////////////////////////////////////// + // // DirectX 6.0 Checks + // /////////////////////////////////////////////////////////////////////////// + + // // The IDirectDrawSurface4 interface was introduced with DX 6.0 + // if( FAILED( pSurf->QueryInterface( IID_IDirectDrawSurface4, + // (VOID**)&pSurf4 ) ) ) + // { + // pDDraw->Release(); + // FreeLibrary( DDHinst ); + // return; + // } + + // // IDirectDrawSurface4 was create successfully. We must be at least DX6 + // (*pdwDXVersion) = 0x600; + // pSurf->Release(); + // pDDraw->Release(); + + + // /////////////////////////////////////////////////////////////////////////// + // // DirectX 6.1 Checks + // /////////////////////////////////////////////////////////////////////////// + + //// FIX: DirectMusic is deprecated. + // //// Check for DMusic, which was introduced with DX6.1 + // //LPDIRECTMUSIC pDMusic = NULL; + // //CoInitialize( NULL ); + // //hr = CoCreateInstance( CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, + // // IID_IDirectMusic, (VOID**)&pDMusic ); + // //if( FAILED(hr) ) + // //{ + // // OutputDebugString( "Couldn't create CLSID_DirectMusic\r\n" ); + // // FreeLibrary( DDHinst ); + // // return; + // //} + + // //// DirectMusic was created successfully. We must be at least DX6.1 + // //(*pdwDXVersion) = 0x601; + // //pDMusic->Release(); + // //CoUninitialize(); + // + + // /////////////////////////////////////////////////////////////////////////// + // // DirectX 7.0 Checks + // /////////////////////////////////////////////////////////////////////////// + + // // Check for DirectX 7 by creating a DDraw7 object + // LPDIRECTDRAW7 pDD7; + // DirectDrawCreateEx = (DIRECTDRAWCREATEEX)GetProcAddress( DDHinst, + // "DirectDrawCreateEx" ); + // if( NULL == DirectDrawCreateEx ) + // { + // FreeLibrary( DDHinst ); + // return; + // } + + // if( FAILED( DirectDrawCreateEx( NULL, (VOID**)&pDD7, IID_IDirectDraw7, + // NULL ) ) ) + // { + // FreeLibrary( DDHinst ); + // return; + // } + + // // DDraw7 was created successfully. We must be at least DX7.0 + // (*pdwDXVersion) = 0x700; + // pDD7->Release(); + + // + // /////////////////////////////////////////////////////////////////////////// + // // End of checks + // /////////////////////////////////////////////////////////////////////////// + + // // Close open libraries and return + // FreeLibrary( DDHinst ); + // + return; +} + +int getDXVersion(){ + DWORD version,platform; + + GetDXVersion( &version,&platform ); + + return (version>>8)&0xff; +} + diff --git a/bblaunch/checkdx.h b/BlitzBasicLauncher/checkdx.h similarity index 100% rename from bblaunch/checkdx.h rename to BlitzBasicLauncher/checkdx.h diff --git a/bblaunch/checkie.cpp b/BlitzBasicLauncher/checkie.cpp similarity index 100% rename from bblaunch/checkie.cpp rename to BlitzBasicLauncher/checkie.cpp diff --git a/bblaunch/checkie.h b/BlitzBasicLauncher/checkie.h similarity index 100% rename from bblaunch/checkie.h rename to BlitzBasicLauncher/checkie.h diff --git a/bblaunch/demo.html b/BlitzBasicLauncher/demo.html similarity index 100% rename from bblaunch/demo.html rename to BlitzBasicLauncher/demo.html diff --git a/bblaunch/resource.h b/BlitzBasicLauncher/resource.h similarity index 100% rename from bblaunch/resource.h rename to BlitzBasicLauncher/resource.h diff --git a/BlitzNext.sln b/BlitzNext.sln index 1868d5d..53f9de1 100644 --- a/BlitzNext.sln +++ b/BlitzNext.sln @@ -5,638 +5,133 @@ VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asm_makeinsts", "asm_makeinsts\asm_makeinsts.vcxproj", "{E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bblaunch", "bblaunch\bblaunch.vcxproj", "{C74A383E-81B0-4679-AAC9-535C94C92EA5}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bbruntime", "bbruntime\bbruntime.vcxproj", "{DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bbruntime_dll", "bbruntime_dll\bbruntime_dll.vcxproj", "{5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blitz", "blitz\blitz.vcxproj", "{C23AF61E-9509-411F-933E-17DB18884B21}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blitz3d", "blitz3d\blitz3d.vcxproj", "{BE0BA538-6215-4836-9227-1D3627E40D61}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blitzide", "blitzide\blitzide.vcxproj", "{B61D8348-B715-42B8-A759-C7BBB0C8CD4D}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Compiler", "Compiler\compiler.vcxproj", "{D884A075-E3B8-44E1-838D-74F28B33391B}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compiler", "compiler\compiler.vcxproj", "{D884A075-E3B8-44E1-838D-74F28B33391B}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Configuration", "config\config.vcxproj", "{3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "config", "config\config.vcxproj", "{3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Debugger", "Debugger\debugger.vcxproj", "{4132C330-95D9-4F68-A51A-3B90381587C5}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "debugger", "debugger\debugger.vcxproj", "{4132C330-95D9-4F68-A51A-3B90381587C5}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gxruntime", "gxruntime\gxruntime.vcxproj", "{FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "linker", "linker\linker.vcxproj", "{0B629BA3-D138-407A-801D-DBE7C8DC4324}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "linker_dll", "linker_dll\linker_dll.vcxproj", "{778BCC7F-40F9-4309-9A88-C0F60D9B364D}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GraphicsRuntime", "gxruntime\gxruntime.vcxproj", "{FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stdutil", "stdutil\stdutil.vcxproj", "{6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlitzBasicIDE", "BlitzBasicIDE\blitzide.vcxproj", "{B61D8348-B715-42B8-A759-C7BBB0C8CD4D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlitzBasicLauncher", "BlitzBasicLauncher\bblaunch.vcxproj", "{C74A383E-81B0-4679-AAC9-535C94C92EA5}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Runtime", "Runtime\bbruntime_dll.vcxproj", "{5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RuntimeLib", "RuntimeLib\bbruntime.vcxproj", "{DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Linker", "Linker\linker_dll.vcxproj", "{778BCC7F-40F9-4309-9A88-C0F60D9B364D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LinkerLib", "LinkerLib\linker.vcxproj", "{0B629BA3-D138-407A-801D-DBE7C8DC4324}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Engine", "Engine\Engine.vcxproj", "{CB5EDAC6-C090-40B5-84F2-BA6269261539}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - AppStore|Any CPU = AppStore|Any CPU - AppStore|ARM = AppStore|ARM - AppStore|iPhone = AppStore|iPhone - AppStore|iPhoneSimulator = AppStore|iPhoneSimulator - AppStore|x86 = AppStore|x86 - Blitz2DRelease|Any CPU = Blitz2DRelease|Any CPU - Blitz2DRelease|ARM = Blitz2DRelease|ARM - Blitz2DRelease|iPhone = Blitz2DRelease|iPhone - Blitz2DRelease|iPhoneSimulator = Blitz2DRelease|iPhoneSimulator - Blitz2DRelease|x86 = Blitz2DRelease|x86 - Blitz3DRelease|Any CPU = Blitz3DRelease|Any CPU - Blitz3DRelease|ARM = Blitz3DRelease|ARM - Blitz3DRelease|iPhone = Blitz3DRelease|iPhone - Blitz3DRelease|iPhoneSimulator = Blitz3DRelease|iPhoneSimulator - Blitz3DRelease|x86 = Blitz3DRelease|x86 - Debug|Any CPU = Debug|Any CPU - Debug|ARM = Debug|ARM - Debug|iPhone = Debug|iPhone - Debug|iPhoneSimulator = Debug|iPhoneSimulator + Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|ARM = Release|ARM - Release|iPhone = Release|iPhone - Release|iPhoneSimulator = Release|iPhoneSimulator + Release|x64 = Release|x64 Release|x86 = Release|x86 - Template|Any CPU = Template|Any CPU - Template|ARM = Template|ARM - Template|iPhone = Template|iPhone - Template|iPhoneSimulator = Template|iPhoneSimulator - Template|x86 = Template|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.AppStore|Any CPU.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.AppStore|Any CPU.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.AppStore|ARM.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.AppStore|ARM.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.AppStore|iPhone.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.AppStore|iPhone.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.AppStore|iPhoneSimulator.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.AppStore|x86.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.AppStore|x86.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz2DRelease|Any CPU.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz2DRelease|Any CPU.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz2DRelease|ARM.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz2DRelease|ARM.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz2DRelease|iPhone.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz2DRelease|iPhone.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz2DRelease|iPhoneSimulator.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz2DRelease|x86.ActiveCfg = Release|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz2DRelease|x86.Build.0 = Release|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz3DRelease|Any CPU.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz3DRelease|Any CPU.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz3DRelease|ARM.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz3DRelease|ARM.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz3DRelease|iPhone.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz3DRelease|iPhone.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz3DRelease|iPhoneSimulator.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz3DRelease|x86.ActiveCfg = Release|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Blitz3DRelease|x86.Build.0 = Release|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Debug|ARM.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Debug|iPhone.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 + {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Debug|x64.ActiveCfg = Debug|Win32 {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Debug|x86.ActiveCfg = Debug|Win32 {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Debug|x86.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Release|Any CPU.ActiveCfg = Release|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Release|ARM.ActiveCfg = Release|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Release|iPhone.ActiveCfg = Release|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 + {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Release|x64.ActiveCfg = Release|Win32 {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Release|x86.ActiveCfg = Release|Win32 {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Release|x86.Build.0 = Release|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Template|Any CPU.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Template|Any CPU.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Template|ARM.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Template|ARM.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Template|iPhone.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Template|iPhone.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Template|iPhoneSimulator.ActiveCfg = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Template|iPhoneSimulator.Build.0 = Debug|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Template|x86.ActiveCfg = Release|Win32 - {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E}.Template|x86.Build.0 = Release|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.AppStore|Any CPU.Build.0 = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.AppStore|ARM.ActiveCfg = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.AppStore|ARM.Build.0 = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.AppStore|iPhone.ActiveCfg = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.AppStore|iPhone.Build.0 = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.AppStore|x86.ActiveCfg = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.AppStore|x86.Build.0 = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Debug|ARM.ActiveCfg = Debug|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Debug|iPhone.ActiveCfg = Debug|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Debug|x86.ActiveCfg = Debug|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Debug|x86.Build.0 = Debug|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Release|Any CPU.ActiveCfg = Release|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Release|ARM.ActiveCfg = Release|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Release|iPhone.ActiveCfg = Release|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Release|x86.ActiveCfg = Release|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Release|x86.Build.0 = Release|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Template|Any CPU.ActiveCfg = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Template|ARM.ActiveCfg = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Template|iPhone.ActiveCfg = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Template|x86.ActiveCfg = Template|Win32 - {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Template|x86.Build.0 = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.AppStore|Any CPU.Build.0 = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.AppStore|ARM.ActiveCfg = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.AppStore|ARM.Build.0 = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.AppStore|iPhone.ActiveCfg = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.AppStore|iPhone.Build.0 = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.AppStore|x86.ActiveCfg = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.AppStore|x86.Build.0 = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Debug|ARM.ActiveCfg = Debug|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Debug|iPhone.ActiveCfg = Debug|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Debug|x86.ActiveCfg = Debug|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Debug|x86.Build.0 = Debug|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Release|Any CPU.ActiveCfg = Release|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Release|ARM.ActiveCfg = Release|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Release|iPhone.ActiveCfg = Release|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Release|x86.ActiveCfg = Release|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Release|x86.Build.0 = Release|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Template|Any CPU.ActiveCfg = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Template|ARM.ActiveCfg = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Template|iPhone.ActiveCfg = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Template|x86.ActiveCfg = Template|Win32 - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Template|x86.Build.0 = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.AppStore|Any CPU.Build.0 = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.AppStore|ARM.ActiveCfg = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.AppStore|ARM.Build.0 = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.AppStore|iPhone.ActiveCfg = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.AppStore|iPhone.Build.0 = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.AppStore|x86.ActiveCfg = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.AppStore|x86.Build.0 = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Debug|ARM.ActiveCfg = Debug|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Debug|iPhone.ActiveCfg = Debug|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Debug|x86.ActiveCfg = Debug|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Debug|x86.Build.0 = Debug|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Release|Any CPU.ActiveCfg = Release|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Release|ARM.ActiveCfg = Release|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Release|iPhone.ActiveCfg = Release|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Release|x86.ActiveCfg = Release|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Release|x86.Build.0 = Release|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Template|Any CPU.ActiveCfg = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Template|ARM.ActiveCfg = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Template|iPhone.ActiveCfg = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Template|x86.ActiveCfg = Template|Win32 - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Template|x86.Build.0 = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.AppStore|Any CPU.Build.0 = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.AppStore|ARM.ActiveCfg = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.AppStore|ARM.Build.0 = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.AppStore|iPhone.ActiveCfg = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.AppStore|iPhone.Build.0 = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.AppStore|x86.ActiveCfg = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.AppStore|x86.Build.0 = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Debug|ARM.ActiveCfg = Debug|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Debug|iPhone.ActiveCfg = Debug|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 + {C23AF61E-9509-411F-933E-17DB18884B21}.Debug|x64.ActiveCfg = Debug|Win32 {C23AF61E-9509-411F-933E-17DB18884B21}.Debug|x86.ActiveCfg = Debug|Win32 {C23AF61E-9509-411F-933E-17DB18884B21}.Debug|x86.Build.0 = Debug|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Release|Any CPU.ActiveCfg = Release|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Release|ARM.ActiveCfg = Release|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Release|iPhone.ActiveCfg = Release|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 + {C23AF61E-9509-411F-933E-17DB18884B21}.Release|x64.ActiveCfg = Release|Win32 {C23AF61E-9509-411F-933E-17DB18884B21}.Release|x86.ActiveCfg = Release|Win32 {C23AF61E-9509-411F-933E-17DB18884B21}.Release|x86.Build.0 = Release|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Template|Any CPU.ActiveCfg = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Template|ARM.ActiveCfg = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Template|iPhone.ActiveCfg = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Template|x86.ActiveCfg = Template|Win32 - {C23AF61E-9509-411F-933E-17DB18884B21}.Template|x86.Build.0 = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.AppStore|Any CPU.Build.0 = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.AppStore|ARM.ActiveCfg = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.AppStore|ARM.Build.0 = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.AppStore|iPhone.ActiveCfg = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.AppStore|iPhone.Build.0 = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.AppStore|x86.ActiveCfg = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.AppStore|x86.Build.0 = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Debug|ARM.ActiveCfg = Debug|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Debug|iPhone.ActiveCfg = Debug|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 + {BE0BA538-6215-4836-9227-1D3627E40D61}.Debug|x64.ActiveCfg = Debug|Win32 {BE0BA538-6215-4836-9227-1D3627E40D61}.Debug|x86.ActiveCfg = Debug|Win32 {BE0BA538-6215-4836-9227-1D3627E40D61}.Debug|x86.Build.0 = Debug|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Release|Any CPU.ActiveCfg = Release|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Release|ARM.ActiveCfg = Release|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Release|iPhone.ActiveCfg = Release|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 + {BE0BA538-6215-4836-9227-1D3627E40D61}.Release|x64.ActiveCfg = Release|Win32 {BE0BA538-6215-4836-9227-1D3627E40D61}.Release|x86.ActiveCfg = Release|Win32 {BE0BA538-6215-4836-9227-1D3627E40D61}.Release|x86.Build.0 = Release|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Template|Any CPU.ActiveCfg = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Template|ARM.ActiveCfg = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Template|iPhone.ActiveCfg = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Template|x86.ActiveCfg = Template|Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61}.Template|x86.Build.0 = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.AppStore|Any CPU.Build.0 = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.AppStore|ARM.ActiveCfg = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.AppStore|ARM.Build.0 = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.AppStore|iPhone.ActiveCfg = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.AppStore|iPhone.Build.0 = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.AppStore|x86.ActiveCfg = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.AppStore|x86.Build.0 = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Debug|ARM.ActiveCfg = Debug|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Debug|iPhone.ActiveCfg = Debug|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Debug|x86.ActiveCfg = Debug|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Debug|x86.Build.0 = Debug|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Release|Any CPU.ActiveCfg = Release|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Release|ARM.ActiveCfg = Release|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Release|iPhone.ActiveCfg = Release|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Release|x86.ActiveCfg = Release|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Release|x86.Build.0 = Release|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Template|Any CPU.ActiveCfg = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Template|ARM.ActiveCfg = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Template|iPhone.ActiveCfg = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Template|x86.ActiveCfg = Template|Win32 - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Template|x86.Build.0 = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.AppStore|Any CPU.Build.0 = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.AppStore|ARM.ActiveCfg = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.AppStore|ARM.Build.0 = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.AppStore|iPhone.ActiveCfg = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.AppStore|iPhone.Build.0 = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.AppStore|x86.ActiveCfg = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.AppStore|x86.Build.0 = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Debug|ARM.ActiveCfg = Debug|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Debug|iPhone.ActiveCfg = Debug|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 + {D884A075-E3B8-44E1-838D-74F28B33391B}.Debug|x64.ActiveCfg = Debug|Win32 {D884A075-E3B8-44E1-838D-74F28B33391B}.Debug|x86.ActiveCfg = Debug|Win32 {D884A075-E3B8-44E1-838D-74F28B33391B}.Debug|x86.Build.0 = Debug|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Release|Any CPU.ActiveCfg = Release|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Release|ARM.ActiveCfg = Release|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Release|iPhone.ActiveCfg = Release|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 + {D884A075-E3B8-44E1-838D-74F28B33391B}.Release|x64.ActiveCfg = Release|Win32 {D884A075-E3B8-44E1-838D-74F28B33391B}.Release|x86.ActiveCfg = Release|Win32 {D884A075-E3B8-44E1-838D-74F28B33391B}.Release|x86.Build.0 = Release|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Template|Any CPU.ActiveCfg = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Template|ARM.ActiveCfg = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Template|iPhone.ActiveCfg = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Template|x86.ActiveCfg = Template|Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B}.Template|x86.Build.0 = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.AppStore|Any CPU.Build.0 = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.AppStore|ARM.ActiveCfg = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.AppStore|ARM.Build.0 = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.AppStore|iPhone.ActiveCfg = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.AppStore|iPhone.Build.0 = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.AppStore|x86.ActiveCfg = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.AppStore|x86.Build.0 = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Debug|ARM.ActiveCfg = Debug|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Debug|iPhone.ActiveCfg = Debug|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 + {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Debug|x64.ActiveCfg = Debug|Win32 {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Debug|x86.ActiveCfg = Debug|Win32 {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Debug|x86.Build.0 = Debug|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Release|Any CPU.ActiveCfg = Release|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Release|ARM.ActiveCfg = Release|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Release|iPhone.ActiveCfg = Release|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 + {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Release|x64.ActiveCfg = Release|Win32 {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Release|x86.ActiveCfg = Release|Win32 {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Release|x86.Build.0 = Release|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Template|Any CPU.ActiveCfg = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Template|ARM.ActiveCfg = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Template|iPhone.ActiveCfg = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Template|x86.ActiveCfg = Template|Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA}.Template|x86.Build.0 = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.AppStore|Any CPU.Build.0 = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.AppStore|ARM.ActiveCfg = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.AppStore|ARM.Build.0 = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.AppStore|iPhone.ActiveCfg = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.AppStore|iPhone.Build.0 = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.AppStore|x86.ActiveCfg = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.AppStore|x86.Build.0 = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Debug|ARM.ActiveCfg = Debug|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Debug|iPhone.ActiveCfg = Debug|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 + {4132C330-95D9-4F68-A51A-3B90381587C5}.Debug|x64.ActiveCfg = Debug|Win32 {4132C330-95D9-4F68-A51A-3B90381587C5}.Debug|x86.ActiveCfg = Debug|Win32 {4132C330-95D9-4F68-A51A-3B90381587C5}.Debug|x86.Build.0 = Debug|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Release|Any CPU.ActiveCfg = Release|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Release|ARM.ActiveCfg = Release|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Release|iPhone.ActiveCfg = Release|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 + {4132C330-95D9-4F68-A51A-3B90381587C5}.Release|x64.ActiveCfg = Release|Win32 {4132C330-95D9-4F68-A51A-3B90381587C5}.Release|x86.ActiveCfg = Release|Win32 {4132C330-95D9-4F68-A51A-3B90381587C5}.Release|x86.Build.0 = Release|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Template|Any CPU.ActiveCfg = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Template|ARM.ActiveCfg = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Template|iPhone.ActiveCfg = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Template|x86.ActiveCfg = Template|Win32 - {4132C330-95D9-4F68-A51A-3B90381587C5}.Template|x86.Build.0 = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.AppStore|Any CPU.Build.0 = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.AppStore|ARM.ActiveCfg = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.AppStore|ARM.Build.0 = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.AppStore|iPhone.ActiveCfg = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.AppStore|iPhone.Build.0 = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.AppStore|x86.ActiveCfg = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.AppStore|x86.Build.0 = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Debug|ARM.ActiveCfg = Debug|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Debug|iPhone.ActiveCfg = Debug|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 + {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Debug|x64.ActiveCfg = Debug|Win32 {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Debug|x86.ActiveCfg = Debug|Win32 {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Debug|x86.Build.0 = Debug|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Release|Any CPU.ActiveCfg = Release|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Release|ARM.ActiveCfg = Release|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Release|iPhone.ActiveCfg = Release|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 + {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Release|x64.ActiveCfg = Release|Win32 {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Release|x86.ActiveCfg = Release|Win32 {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Release|x86.Build.0 = Release|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Template|Any CPU.ActiveCfg = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Template|ARM.ActiveCfg = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Template|iPhone.ActiveCfg = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Template|x86.ActiveCfg = Template|Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}.Template|x86.Build.0 = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.AppStore|Any CPU.Build.0 = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.AppStore|ARM.ActiveCfg = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.AppStore|ARM.Build.0 = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.AppStore|iPhone.ActiveCfg = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.AppStore|iPhone.Build.0 = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.AppStore|x86.ActiveCfg = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.AppStore|x86.Build.0 = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Debug|ARM.ActiveCfg = Debug|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Debug|iPhone.ActiveCfg = Debug|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Debug|x86.ActiveCfg = Debug|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Debug|x86.Build.0 = Debug|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Release|Any CPU.ActiveCfg = Release|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Release|ARM.ActiveCfg = Release|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Release|iPhone.ActiveCfg = Release|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Release|x86.ActiveCfg = Release|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Release|x86.Build.0 = Release|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Template|Any CPU.ActiveCfg = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Template|ARM.ActiveCfg = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Template|iPhone.ActiveCfg = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Template|x86.ActiveCfg = Template|Win32 - {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Template|x86.Build.0 = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.AppStore|Any CPU.Build.0 = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.AppStore|ARM.ActiveCfg = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.AppStore|ARM.Build.0 = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.AppStore|iPhone.ActiveCfg = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.AppStore|iPhone.Build.0 = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.AppStore|x86.ActiveCfg = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.AppStore|x86.Build.0 = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Debug|ARM.ActiveCfg = Debug|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Debug|iPhone.ActiveCfg = Debug|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Debug|x86.ActiveCfg = Debug|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Debug|x86.Build.0 = Debug|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Release|Any CPU.ActiveCfg = Release|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Release|ARM.ActiveCfg = Release|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Release|iPhone.ActiveCfg = Release|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Release|x86.ActiveCfg = Release|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Release|x86.Build.0 = Release|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Template|Any CPU.ActiveCfg = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Template|ARM.ActiveCfg = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Template|iPhone.ActiveCfg = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Template|x86.ActiveCfg = Template|Win32 - {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Template|x86.Build.0 = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.AppStore|Any CPU.ActiveCfg = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.AppStore|Any CPU.Build.0 = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.AppStore|ARM.ActiveCfg = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.AppStore|ARM.Build.0 = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.AppStore|iPhone.ActiveCfg = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.AppStore|iPhone.Build.0 = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.AppStore|iPhoneSimulator.ActiveCfg = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.AppStore|iPhoneSimulator.Build.0 = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.AppStore|x86.ActiveCfg = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.AppStore|x86.Build.0 = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz2DRelease|Any CPU.ActiveCfg = Blitz2DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz2DRelease|ARM.ActiveCfg = Blitz2DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz2DRelease|iPhone.ActiveCfg = Blitz2DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz2DRelease|iPhoneSimulator.ActiveCfg = Blitz2DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz2DRelease|x86.ActiveCfg = Blitz2DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz2DRelease|x86.Build.0 = Blitz2DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz3DRelease|Any CPU.ActiveCfg = Blitz3DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz3DRelease|ARM.ActiveCfg = Blitz3DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz3DRelease|iPhone.ActiveCfg = Blitz3DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz3DRelease|iPhoneSimulator.ActiveCfg = Blitz3DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz3DRelease|x86.ActiveCfg = Blitz3DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Blitz3DRelease|x86.Build.0 = Blitz3DRelease|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Debug|ARM.ActiveCfg = Debug|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Debug|iPhone.ActiveCfg = Debug|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Win32 + {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Debug|x64.ActiveCfg = Debug|Win32 {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Debug|x86.ActiveCfg = Debug|Win32 {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Debug|x86.Build.0 = Debug|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Release|Any CPU.ActiveCfg = Release|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Release|ARM.ActiveCfg = Release|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Release|iPhone.ActiveCfg = Release|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Release|iPhoneSimulator.ActiveCfg = Release|Win32 + {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Release|x64.ActiveCfg = Release|Win32 {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Release|x86.ActiveCfg = Release|Win32 {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Release|x86.Build.0 = Release|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Template|Any CPU.ActiveCfg = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Template|ARM.ActiveCfg = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Template|iPhone.ActiveCfg = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Template|iPhoneSimulator.ActiveCfg = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Template|x86.ActiveCfg = Template|Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E}.Template|x86.Build.0 = Template|Win32 + {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Debug|x64.ActiveCfg = Debug|Win32 + {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Debug|x86.ActiveCfg = Debug|Win32 + {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Release|x64.ActiveCfg = Release|Win32 + {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Release|x86.ActiveCfg = Release|Win32 + {B61D8348-B715-42B8-A759-C7BBB0C8CD4D}.Release|x86.Build.0 = Release|Win32 + {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Debug|x64.ActiveCfg = Debug|Win32 + {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Debug|x86.ActiveCfg = Debug|Win32 + {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Debug|x86.Build.0 = Debug|Win32 + {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Release|x64.ActiveCfg = Release|Win32 + {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Release|x86.ActiveCfg = Release|Win32 + {C74A383E-81B0-4679-AAC9-535C94C92EA5}.Release|x86.Build.0 = Release|Win32 + {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Debug|x64.ActiveCfg = Debug|Win32 + {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Debug|x86.ActiveCfg = Debug|Win32 + {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Debug|x86.Build.0 = Debug|Win32 + {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Release|x64.ActiveCfg = Release|Win32 + {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Release|x86.ActiveCfg = Release|Win32 + {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3}.Release|x86.Build.0 = Release|Win32 + {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Debug|x64.ActiveCfg = Debug|Win32 + {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Debug|x86.ActiveCfg = Debug|Win32 + {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Debug|x86.Build.0 = Debug|Win32 + {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Release|x64.ActiveCfg = Release|Win32 + {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Release|x86.ActiveCfg = Release|Win32 + {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354}.Release|x86.Build.0 = Release|Win32 + {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Debug|x64.ActiveCfg = Debug|Win32 + {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Debug|x86.ActiveCfg = Debug|Win32 + {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Debug|x86.Build.0 = Debug|Win32 + {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Release|x64.ActiveCfg = Release|Win32 + {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Release|x86.ActiveCfg = Release|Win32 + {778BCC7F-40F9-4309-9A88-C0F60D9B364D}.Release|x86.Build.0 = Release|Win32 + {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Debug|x64.ActiveCfg = Debug|Win32 + {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Debug|x86.ActiveCfg = Debug|Win32 + {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Debug|x86.Build.0 = Debug|Win32 + {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Release|x64.ActiveCfg = Release|Win32 + {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Release|x86.ActiveCfg = Release|Win32 + {0B629BA3-D138-407A-801D-DBE7C8DC4324}.Release|x86.Build.0 = Release|Win32 + {CB5EDAC6-C090-40B5-84F2-BA6269261539}.Debug|x64.ActiveCfg = Debug|x64 + {CB5EDAC6-C090-40B5-84F2-BA6269261539}.Debug|x64.Build.0 = Debug|x64 + {CB5EDAC6-C090-40B5-84F2-BA6269261539}.Debug|x86.ActiveCfg = Debug|Win32 + {CB5EDAC6-C090-40B5-84F2-BA6269261539}.Debug|x86.Build.0 = Debug|Win32 + {CB5EDAC6-C090-40B5-84F2-BA6269261539}.Release|x64.ActiveCfg = Release|x64 + {CB5EDAC6-C090-40B5-84F2-BA6269261539}.Release|x64.Build.0 = Release|x64 + {CB5EDAC6-C090-40B5-84F2-BA6269261539}.Release|x86.ActiveCfg = Release|Win32 + {CB5EDAC6-C090-40B5-84F2-BA6269261539}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Engine/Engine.cpp b/Engine/Engine.cpp new file mode 100644 index 0000000..5a7206d --- /dev/null +++ b/Engine/Engine.cpp @@ -0,0 +1,43 @@ +#include "Engine.h" + +Engine Engine::GetInstance() { + return Instance; +} + +Engine::Engine() { + +} + +Engine::~Engine() { + // Unload all GraphicsDrivers + for (auto iter = m_GraphicsDrivers.begin(); iter != m_GraphicsDrivers.end(); iter++) { + UnloadGraphicsDriver(*iter); + } +} + +typedef GraphicsDriver*(__stdcall *GraphicsDriverInstance_t)(); + +GraphicsDriver* Engine::LoadGraphicsDriver(std::string libraryPath) { + HINSTANCE lib = LoadLibrary(libraryPath.c_str()); + if (lib != NULL) { + FARPROC fnGraphicsDriverInstance = GetProcAddress(lib, "GraphicsDriverInstance"); + if (fnGraphicsDriverInstance != NULL) { + GraphicsDriver* graphicsDriver = ((GraphicsDriverInstance_t)fnGraphicsDriverInstance)(); + + // Insert into list. + m_GraphicsDrivers.emplace_back(graphicsDriver); + m_GraphicsDrivers_MapToLibrary[graphicsDriver] = lib; + + return graphicsDriver; + } + FreeLibrary(lib); + } + + // An error occured, handle it somehow here. + MessageBox(0, "Not Yet Implemented", "Not Yet Implemented", 0); + return nullptr; +} + +void Engine::UnloadGraphicsDriver(GraphicsDriver* graphicsDriver) { + +} diff --git a/Engine/Engine.h b/Engine/Engine.h new file mode 100644 index 0000000..8f05701 --- /dev/null +++ b/Engine/Engine.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include +#include +#include + +#include "GraphicsDriver.h" + +class Engine { +#pragma region Singleton +private: + const static Engine Instance; +public: + Engine GetInstance(); +#pragma endregion + +public: + Engine(); + ~Engine(); + + GraphicsDriver* LoadGraphicsDriver(std::string libraryPath); + void UnloadGraphicsDriver(GraphicsDriver*); + + + +private: + std::list m_GraphicsDrivers; + std::map m_GraphicsDrivers_MapToLibrary; +}; \ No newline at end of file diff --git a/Engine/Engine.vcxproj b/Engine/Engine.vcxproj new file mode 100644 index 0000000..22d80f1 --- /dev/null +++ b/Engine/Engine.vcxproj @@ -0,0 +1,174 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {CB5EDAC6-C090-40B5-84F2-BA6269261539} + Engine + 8.1 + + + + StaticLibrary + true + v140 + MultiByte + false + + + StaticLibrary + false + v140 + false + MultiByte + false + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + + + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + + + + Disabled + true + MultiThreadedDebug + true + EnableFastChecks + true + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) + ProgramDatabase + false + false + Guard + Level3 + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + true + true + false + StdCall + + + MachineX86 + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + false + MultiThreaded + true + true + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + false + false + Guard + $(IntDir)vc$(PlatformToolsetVersion).pdb + Speed + false + false + false + StdCall + OnlyExplicitInline + + + true + true + + + MachineX86 + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Engine/Engine.vcxproj.filters b/Engine/Engine.vcxproj.filters new file mode 100644 index 0000000..8ebc601 --- /dev/null +++ b/Engine/Engine.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Engine/GraphicsDriver.cpp b/Engine/GraphicsDriver.cpp new file mode 100644 index 0000000..93ec916 --- /dev/null +++ b/Engine/GraphicsDriver.cpp @@ -0,0 +1 @@ +#include "GraphicsDriver.h" \ No newline at end of file diff --git a/Engine/GraphicsDriver.h b/Engine/GraphicsDriver.h new file mode 100644 index 0000000..7e0a8de --- /dev/null +++ b/Engine/GraphicsDriver.h @@ -0,0 +1,7 @@ +#pragma once + +#include "Renderer.h" + +class GraphicsDriver { +public: +}; \ No newline at end of file diff --git a/Engine/Public.h b/Engine/Public.h new file mode 100644 index 0000000..32ff104 --- /dev/null +++ b/Engine/Public.h @@ -0,0 +1,5 @@ +#pragma once + +#include "Engine.h" +#include "GraphicsDriver.h" +#include "Renderer.h" diff --git a/Engine/Renderer.h b/Engine/Renderer.h new file mode 100644 index 0000000..8c7c814 --- /dev/null +++ b/Engine/Renderer.h @@ -0,0 +1,8 @@ +#pragma once + +class Renderer { +public: + +private: + +}; \ No newline at end of file diff --git a/linker_dll/linker_dll.cpp b/Linker/linker_dll.cpp similarity index 83% rename from linker_dll/linker_dll.cpp rename to Linker/linker_dll.cpp index 3b90081..35b99e9 100644 --- a/linker_dll/linker_dll.cpp +++ b/Linker/linker_dll.cpp @@ -1,6 +1,6 @@ -#include "../linker/std.h" -#include "../linker/linker.h" +#include "../LinkerLib/std.h" +#include "../LinkerLib/linker.h" #include diff --git a/linker_dll/linker_dll.dsp b/Linker/linker_dll.dsp similarity index 100% rename from linker_dll/linker_dll.dsp rename to Linker/linker_dll.dsp diff --git a/Linker/linker_dll.vcxproj b/Linker/linker_dll.vcxproj new file mode 100644 index 0000000..f651d30 --- /dev/null +++ b/Linker/linker_dll.vcxproj @@ -0,0 +1,175 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + {778BCC7F-40F9-4309-9A88-C0F60D9B364D} + Linker + 8.1 + + + + DynamicLibrary + v140 + false + MultiByte + + + DynamicLibrary + v140 + false + MultiByte + + + + + + + + + + + + + + + ..\#Test\bin\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + ..\#Test\bin\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + + MultiThreadedDebug + Default + true + Disabled + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) + EnableFastChecks + true + true + true + false + false + true + Guard + Level3 + true + Speed + true + true + false + StdCall + + + true + _DEBUG;%(PreprocessorDefinitions) + .\Debug\linker_dll.tlb + true + Win32 + + + 0x0409 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\linker_dll.bsc + + + true + true + true + Console + .\Debug\linker.lib + /FIXED:NO + odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + MultiThreaded + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + true + Speed + false + false + false + StdCall + + + true + NDEBUG;%(PreprocessorDefinitions) + .\Release\linker_dll.tlb + true + Win32 + + + 0x0409 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\linker_dll.bsc + + + true + true + Console + .\Release\linker.lib + odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + {3e355353-96d8-4aaf-bf95-8e6ca0d4b1ba} + false + + + {0b629ba3-d138-407a-801d-dbe7c8dc4324} + + + {6bcfc5ca-ea71-4ae9-8b96-28b8701f939e} + false + + + + + + \ No newline at end of file diff --git a/linker/dlltoexe.cpp b/LinkerLib/dlltoexe.cpp similarity index 100% rename from linker/dlltoexe.cpp rename to LinkerLib/dlltoexe.cpp diff --git a/linker/dlltoexe.h b/LinkerLib/dlltoexe.h similarity index 100% rename from linker/dlltoexe.h rename to LinkerLib/dlltoexe.h diff --git a/linker/image_util.cpp b/LinkerLib/image_util.cpp similarity index 100% rename from linker/image_util.cpp rename to LinkerLib/image_util.cpp diff --git a/linker/image_util.h b/LinkerLib/image_util.h similarity index 100% rename from linker/image_util.h rename to LinkerLib/image_util.h diff --git a/linker/linker.cpp b/LinkerLib/linker.cpp similarity index 100% rename from linker/linker.cpp rename to LinkerLib/linker.cpp diff --git a/linker/linker.dsp b/LinkerLib/linker.dsp similarity index 100% rename from linker/linker.dsp rename to LinkerLib/linker.dsp diff --git a/linker/linker.h b/LinkerLib/linker.h similarity index 100% rename from linker/linker.h rename to LinkerLib/linker.h diff --git a/LinkerLib/linker.vcxproj b/LinkerLib/linker.vcxproj new file mode 100644 index 0000000..6a84709 --- /dev/null +++ b/LinkerLib/linker.vcxproj @@ -0,0 +1,162 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + {0B629BA3-D138-407A-801D-DBE7C8DC4324} + LinkerLib + 8.1 + + + + StaticLibrary + v140 + false + MultiByte + + + StaticLibrary + v140 + false + MultiByte + + + + + + + + + + + + + + + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + true + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + + MultiThreadedDebug + Default + true + Disabled + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) + EnableFastChecks + true + true + true + false + false + true + Guard + Level3 + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + true + true + false + StdCall + + + 0x0409 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\linker.bsc + + + true + MachineX86 + + + + + MultiThreaded + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + false + false + false + StdCall + + + 0x0409 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\linker.bsc + + + true + MachineX86 + + + + + + + Create + std.h + + + + + + + + + + {3e355353-96d8-4aaf-bf95-8e6ca0d4b1ba} + false + + + {6bcfc5ca-ea71-4ae9-8b96-28b8701f939e} + false + + + + + + \ No newline at end of file diff --git a/linker/std.cpp b/LinkerLib/std.cpp similarity index 100% rename from linker/std.cpp rename to LinkerLib/std.cpp diff --git a/linker/std.h b/LinkerLib/std.h similarity index 100% rename from linker/std.h rename to LinkerLib/std.h diff --git a/bbruntime_dll/bbexe.ico b/Runtime/bbexe.ico similarity index 100% rename from bbruntime_dll/bbexe.ico rename to Runtime/bbexe.ico diff --git a/bbruntime_dll/bbruntime_dll.cpp b/Runtime/bbruntime_dll.cpp similarity index 96% rename from bbruntime_dll/bbruntime_dll.cpp rename to Runtime/bbruntime_dll.cpp index ca80372..f977aeb 100644 --- a/bbruntime_dll/bbruntime_dll.cpp +++ b/Runtime/bbruntime_dll.cpp @@ -4,9 +4,6 @@ #include "bbruntime_dll.h" #include "../debugger/debugger.h" -#ifdef PRODEMO -#include "../shareprot/shareprot.h" -#endif using namespace std; @@ -14,7 +11,7 @@ using namespace std; #include #include -#include "../bbruntime/bbruntime.h" +#include "../RuntimeLib/bbruntime.h" class DummyDebugger : public Debugger{ public: @@ -39,12 +36,6 @@ static void rtSym( const char *sym,void *pc ){ syms[sym]=pc; } -#ifdef PRODEMO -static void killer(){ - ExitProcess( -1 ); -} -#endif - static void _cdecl seTranslator( unsigned int u,EXCEPTION_POINTERS* pExp ){ switch( u ){ case EXCEPTION_INT_DIVIDE_BY_ZERO: @@ -108,10 +99,6 @@ void Runtime::execute( void (*pc)(),const char *args,Debugger *dbg ){ while( params.size() && params[params.size()-1]==' ' ) params=params.substr( 0,params.size()-1 ); if( gx_runtime=gxRuntime::openRuntime( hinst,params,dbg ) ){ - -#ifdef PRODEMO - shareProtCheck( killer ); -#endif bbruntime_run( gx_runtime,pc,debug ); gxRuntime *t=gx_runtime; diff --git a/bbruntime_dll/bbruntime_dll.dsp b/Runtime/bbruntime_dll.dsp similarity index 100% rename from bbruntime_dll/bbruntime_dll.dsp rename to Runtime/bbruntime_dll.dsp diff --git a/bbruntime_dll/bbruntime_dll.h b/Runtime/bbruntime_dll.h similarity index 100% rename from bbruntime_dll/bbruntime_dll.h rename to Runtime/bbruntime_dll.h diff --git a/bbruntime_dll/bbruntime_dll.rc b/Runtime/bbruntime_dll.rc similarity index 97% rename from bbruntime_dll/bbruntime_dll.rc rename to Runtime/bbruntime_dll.rc index 84ca5f1..d31b91b 100644 --- a/bbruntime_dll/bbruntime_dll.rc +++ b/Runtime/bbruntime_dll.rc @@ -77,7 +77,7 @@ IDI_ICON1 ICON DISCARDABLE "bbexe.ico" // // Generated from the TEXTINCLUDE 3 resource. // -#include "../bbruntime/multiplay_setup.rc" +//#include "../bbruntime/multiplay_setup.rc" ///////////////////////////////////////////////////////////////////////////// diff --git a/Runtime/bbruntime_dll.vcxproj b/Runtime/bbruntime_dll.vcxproj new file mode 100644 index 0000000..495da01 --- /dev/null +++ b/Runtime/bbruntime_dll.vcxproj @@ -0,0 +1,197 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3} + Runtime + 8.1 + + + + DynamicLibrary + v140 + false + MultiByte + + + DynamicLibrary + v140 + false + MultiByte + + + + + + + + + + + + + + + ..\#Test\bin\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + ..\#Test\bin\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + + MultiThreadedDebug + Default + true + Disabled + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) + EnableFastChecks + true + true + true + false + false + true + Guard + Level3 + true + Speed + true + true + false + StdCall + + + true + _DEBUG;%(PreprocessorDefinitions) + .\Debug\bbruntime_dll.tlb + true + Win32 + + + 0x0409 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\bbruntime_dll.bsc + + + true + true + true + Console + .\Debug\runtime.lib + /FIXED:NO + dxguid.lib;d3dx9.lib;d3d9.lib;dsound.lib;dinput8.lib;ddraw.lib;wsock32.lib;winmm.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)#ThirdParty\;$(DXSDK_DIR)Lib\x86\;%(AdditionalLibraryDirectories) + false + + + + + MultiThreaded + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + true + Speed + false + false + false + StdCall + + + true + NDEBUG;%(PreprocessorDefinitions) + .\Release\bbruntime_dll.tlb + true + Win32 + + + 0x0409 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\bbruntime_dll.bsc + + + true + true + Console + .\Release\runtime.lib + dxguid.lib;d3dx9.lib;d3d9.lib;dsound.lib;dinput8.lib;ddraw.lib;wsock32.lib;winmm.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)#ThirdParty\;$(DXSDK_DIR)Lib\x86\;%(AdditionalLibraryDirectories) + false + + + + + + + + + + + + + + + + + + {be0ba538-6215-4836-9227-1d3627e40d61} + + + {ff2d8bf7-1930-4cab-bc48-05cd33b7dc18} + + + {df8caa9d-7154-4d5f-bccc-0d7bb57c7354} + + + {6bcfc5ca-ea71-4ae9-8b96-28b8701f939e} + false + + + + + + + + + + + + \ No newline at end of file diff --git a/bbruntime_dll/bbruntime_dll.vcxproj.filters b/Runtime/bbruntime_dll.vcxproj.filters similarity index 82% rename from bbruntime_dll/bbruntime_dll.vcxproj.filters rename to Runtime/bbruntime_dll.vcxproj.filters index 6637178..63b4602 100644 --- a/bbruntime_dll/bbruntime_dll.vcxproj.filters +++ b/Runtime/bbruntime_dll.vcxproj.filters @@ -38,7 +38,9 @@ - - + + + +
\ No newline at end of file diff --git a/bbruntime_dll/resource.h b/Runtime/resource.h similarity index 100% rename from bbruntime_dll/resource.h rename to Runtime/resource.h diff --git a/bbruntime/basic.cpp b/RuntimeLib/basic.cpp similarity index 95% rename from bbruntime/basic.cpp rename to RuntimeLib/basic.cpp index e3658d4..9985722 100644 --- a/bbruntime/basic.cpp +++ b/RuntimeLib/basic.cpp @@ -186,7 +186,7 @@ void _bbVecFree( void *vec,BBVecType *type ){ } void _bbVecBoundsEx(){ - RTEX( "Blitz array index out of bounds" ); + ThrowRuntimeException( "Blitz array index out of bounds" ); } void _bbUndimArray( BBArray *array ){ @@ -221,7 +221,7 @@ void _bbDimArray( BBArray *array ){ } void _bbArrayBoundsEx(){ - RTEX( "Array index out of bounds" ); + ThrowRuntimeException( "Array index out of bounds" ); } static void unlinkObj( BBObj *obj ){ @@ -438,7 +438,7 @@ BBObj *_bbObjFromHandle( int handle,BBObjType *type ){ } void _bbNullObjEx(){ - RTEX( "Object does not exist" ); + ThrowRuntimeException( "Object does not exist" ); } void _bbRestore( BBData *data ){ @@ -447,31 +447,31 @@ void _bbRestore( BBData *data ){ int _bbReadInt(){ switch( dataPtr->fieldType ){ - case BBTYPE_END:RTEX( "Out of data" );return 0; + case BBTYPE_END:ThrowRuntimeException( "Out of data" );return 0; case BBTYPE_INT:return dataPtr++->field.INT; case BBTYPE_FLT:return dataPtr++->field.FLT; case BBTYPE_CSTR:return atoi( dataPtr++->field.CSTR ); - default:RTEX( "Bad data type" );return 0; + default:ThrowRuntimeException( "Bad data type" );return 0; } } float _bbReadFloat(){ switch( dataPtr->fieldType ){ - case BBTYPE_END:RTEX( "Out of data" );return 0; + case BBTYPE_END:ThrowRuntimeException( "Out of data" );return 0; case BBTYPE_INT:return dataPtr++->field.INT; case BBTYPE_FLT:return dataPtr++->field.FLT; case BBTYPE_CSTR:return atof( dataPtr++->field.CSTR ); - default:RTEX( "Bad data type" );return 0; + default:ThrowRuntimeException( "Bad data type" );return 0; } } BBStr *_bbReadStr(){ switch( dataPtr->fieldType ){ - case BBTYPE_END:RTEX( "Out of data" );return 0; + case BBTYPE_END:ThrowRuntimeException( "Out of data" );return 0; case BBTYPE_INT:return d_new BBStr( itoa( dataPtr++->field.INT ) ); case BBTYPE_FLT:return d_new BBStr( ftoa( dataPtr++->field.FLT ) ); case BBTYPE_CSTR:return d_new BBStr( dataPtr++->field.CSTR ); - default:RTEX( "Bad data type" );return 0; + default:ThrowRuntimeException( "Bad data type" );return 0; } } diff --git a/bbruntime/basic.h b/RuntimeLib/basic.h similarity index 100% rename from bbruntime/basic.h rename to RuntimeLib/basic.h diff --git a/bbruntime/bb_basic.h b/RuntimeLib/bb_basic.h similarity index 100% rename from bbruntime/bb_basic.h rename to RuntimeLib/bb_basic.h diff --git a/bbruntime/bbaudio.cpp b/RuntimeLib/bbaudio.cpp similarity index 96% rename from bbruntime/bbaudio.cpp rename to RuntimeLib/bbaudio.cpp index cf99dd1..82199e7 100644 --- a/bbruntime/bbaudio.cpp +++ b/RuntimeLib/bbaudio.cpp @@ -6,7 +6,7 @@ gxAudio *gx_audio; static inline void debugSound( gxSound *s ){ if( debug ){ - if( !gx_audio->verifySound( s ) ) RTEX( "Sound does not exist" ); + if( !gx_audio->verifySound( s ) ) ThrowRuntimeException( "Sound does not exist" ); } } @@ -102,11 +102,9 @@ int bbChannelPlaying( gxChannel *channel ){ return channel ? channel->isPlaying() : 0; } -#ifdef PRO gxSound *bbLoad3DSound( BBStr *f ){ return loadSound( f,true ); } -#endif bool audio_create(){ gx_audio=gx_runtime->openAudio( 0 ); @@ -136,7 +134,5 @@ void audio_link( void(*rtSym)(const char*,void*) ){ rtSym( "ChannelVolume%channel#volume",bbChannelVolume ); rtSym( "ChannelPan%channel#pan",bbChannelPan ); rtSym( "%ChannelPlaying%channel",bbChannelPlaying ); -#ifdef PRO rtSym( "%Load3DSound$filename",bbLoad3DSound ); -#endif } diff --git a/bbruntime/bbaudio.h b/RuntimeLib/bbaudio.h similarity index 100% rename from bbruntime/bbaudio.h rename to RuntimeLib/bbaudio.h diff --git a/bbruntime/bbbank.cpp b/RuntimeLib/bbbank.cpp similarity index 96% rename from bbruntime/bbbank.cpp rename to RuntimeLib/bbbank.cpp index 774da81..e8cd9ff 100644 --- a/bbruntime/bbbank.cpp +++ b/RuntimeLib/bbbank.cpp @@ -35,14 +35,14 @@ static set bank_set; static inline void debugBank( bbBank *b ){ if( debug ){ - if( !bank_set.count( b ) ) RTEX( "bbBank does not exist" ); + if( !bank_set.count( b ) ) ThrowRuntimeException( "bbBank does not exist" ); } } static inline void debugBank( bbBank *b,int offset ){ if( debug ){ debugBank( b ); - if( offset>=b->size ) RTEX( "Offset out of range" ); + if( offset>=b->size ) ThrowRuntimeException( "Offset out of range" ); } } diff --git a/bbruntime/bbbank.h b/RuntimeLib/bbbank.h similarity index 100% rename from bbruntime/bbbank.h rename to RuntimeLib/bbbank.h diff --git a/bbruntime/bbblitz3d.cpp b/RuntimeLib/bbblitz3d.cpp similarity index 94% rename from bbruntime/bbblitz3d.cpp rename to RuntimeLib/bbblitz3d.cpp index 8a458c9..733a285 100644 --- a/bbruntime/bbblitz3d.cpp +++ b/RuntimeLib/bbblitz3d.cpp @@ -56,91 +56,91 @@ static Loader_B3D loader_b3d; static map loader_mat_map; static inline void debug3d(){ - if( debug && !gx_scene ) RTEX( "3D Graphics mode not set" ); + if( debug && !gx_scene ) ThrowRuntimeException( "3D Graphics mode not set" ); } static inline void debugTexture( Texture *t ){ - if( debug && !texture_set.count( t ) ) RTEX( "Texture does not exist" ); + if( debug && !texture_set.count( t ) ) ThrowRuntimeException( "Texture does not exist" ); } static inline void debugBrush( Brush *b ){ - if( debug && !brush_set.count( b ) ) RTEX( "Brush does not exist" ); + if( debug && !brush_set.count( b ) ) ThrowRuntimeException( "Brush does not exist" ); } static inline void debugEntity( Entity *e ){ - if( debug && !entity_set.count(e) ) RTEX( "Entity does not exist" ); + if( debug && !entity_set.count(e) ) ThrowRuntimeException( "Entity does not exist" ); } static inline void debugParent( Entity *e ){ if( debug ){ debug3d(); - if( e && !entity_set.count(e) ) RTEX( "Parent entity does not exist" ); + if( e && !entity_set.count(e) ) ThrowRuntimeException( "Parent entity does not exist" ); } } static inline void debugMesh( MeshModel *m ){ if( debug ){ - debugEntity(m);if( !m->getMeshModel() ) RTEX( "Entity is not a mesh" ); + debugEntity(m);if( !m->getMeshModel() ) ThrowRuntimeException( "Entity is not a mesh" ); } } static inline void debugObject( Object *o ){ if( debug ){ - debugEntity(o);if( !o->getObject() ) RTEX( "Entity is not an object" ); + debugEntity(o);if( !o->getObject() ) ThrowRuntimeException( "Entity is not an object" ); } } static inline void debugColl( Object *o,int index ){ if( debug ){ debugObject(o); - if( index<1 || index>o->getCollisions().size() ) RTEX( "Collision index out of range" ); + if( index<1 || index>o->getCollisions().size() ) ThrowRuntimeException( "Collision index out of range" ); } } static inline void debugCamera( Camera *c ){ if( debug ){ - debugEntity(c);if( !c->getCamera() ) RTEX( "Entity is not a camera" ); + debugEntity(c);if( !c->getCamera() ) ThrowRuntimeException( "Entity is not a camera" ); } } static inline void debugLight( Light *l ){ if( debug ){ - debugEntity(l);if( !l->getLight() ) RTEX( "Entity is not a light" ); + debugEntity(l);if( !l->getLight() ) ThrowRuntimeException( "Entity is not a light" ); } } static inline void debugModel( Model *m ){ if( debug ){ - debugEntity(m);if( !m->getModel() ) RTEX( "Entity is not a model" ); + debugEntity(m);if( !m->getModel() ) ThrowRuntimeException( "Entity is not a model" ); } } static inline void debugSprite( Sprite *s ){ if( debug ){ - debugModel(s);if( !s->getSprite() ) RTEX( "Entity is not a sprite" ); + debugModel(s);if( !s->getSprite() ) ThrowRuntimeException( "Entity is not a sprite" ); } } static inline void debugMD2( MD2Model *m ){ if( debug ){ - debugModel(m);if( !m->getMD2Model() ) RTEX( "Entity is not an MD2 Model" ); + debugModel(m);if( !m->getMD2Model() ) ThrowRuntimeException( "Entity is not an MD2 Model" ); } } static inline void debugBSP( Q3BSPModel *m ){ if( debug ){ - debugModel(m);if( !m->getBSPModel() ) RTEX( "Entity is not a BSP Model" ); + debugModel(m);if( !m->getBSPModel() ) ThrowRuntimeException( "Entity is not a BSP Model" ); } } static inline void debugTerrain( Terrain *t ){ if( debug ){ - debugModel(t);if( !t->getTerrain() ) RTEX( "Entity is not a terrain" ); + debugModel(t);if( !t->getTerrain() ) ThrowRuntimeException( "Entity is not a terrain" ); } } static inline void debugSegs( int n ){ if( debug ){ debug3d(); - if( n<3 || n>50 ) RTEX( "Illegal number of segments" ); + if( n<3 || n>50 ) ThrowRuntimeException( "Illegal number of segments" ); } } static inline void debugVertex( Surface *s,int n ){ if( debug ){ debug3d(); - if( n<0 || n>=s->numVertices() ) RTEX( "Vertex index out of range" ); + if( n<0 || n>=s->numVertices() ) ThrowRuntimeException( "Vertex index out of range" ); } } static inline void debugVertex( Surface *s,int n,int t ){ if( debug ){ debug3d(); - if( n<0 || n>=s->numVertices() ) RTEX( "Vertex index out of range" ); - if( t<0 || t>1 ) RTEX( "Texture coordinate set out of range" ); + if( n<0 || n>=s->numVertices() ) ThrowRuntimeException( "Vertex index out of range" ); + if( t<0 || t>1 ) ThrowRuntimeException( "Texture coordinate set out of range" ); } } @@ -375,7 +375,7 @@ Texture * bbCreateTexture( int w,int h,int flags,int frames ){ if( debug ){ debug3d(); if( frames<=0 ){ - RTEX( "Illegal number of texture frames" ); + ThrowRuntimeException( "Illegal number of texture frames" ); } } Texture *t=d_new Texture( w,h,flags,frames ); @@ -576,19 +576,19 @@ Entity * bbCreateCube( Entity *p ){ } Entity * bbCreateSphere( int segs,Entity *p ){ - if( debug ){ debugParent(p);if( segs<2 || segs>100 ) RTEX( "Illegal number of segments" ); } + if( debug ){ debugParent(p);if( segs<2 || segs>100 ) ThrowRuntimeException( "Illegal number of segments" ); } Entity *e=MeshUtil::createSphere( Brush(),segs ); return insertEntity( e,p ); } Entity * bbCreateCylinder( int segs,int solid,Entity *p ){ - if( debug ){ debugParent(p);if( segs<3 || segs>100 ) RTEX( "Illegal number of segments" ); } + if( debug ){ debugParent(p);if( segs<3 || segs>100 ) ThrowRuntimeException( "Illegal number of segments" ); } Entity *e=MeshUtil::createCylinder( Brush(),segs,!!solid ); return insertEntity( e,p ); } Entity * bbCreateCone( int segs,int solid,Entity *p ){ - if( debug ){ debugParent(p);if( segs<3 || segs>100 ) RTEX( "Illegal number of segments" ); } + if( debug ){ debugParent(p);if( segs<3 || segs>100 ) ThrowRuntimeException( "Illegal number of segments" ); } Entity *e=MeshUtil::createCone( Brush(),segs,!!solid ); return insertEntity( e,p ); } @@ -655,7 +655,7 @@ void bbPaintMesh( MeshModel *m,Brush *b ){ void bbAddMesh( MeshModel *src,MeshModel *dest ){ if( debug ){ debugMesh(src);debugMesh(dest); - if( src==dest ) RTEX( "A mesh cannot be added to itself" ); + if( src==dest ) ThrowRuntimeException( "A mesh cannot be added to itself" ); } dest->add( *src ); @@ -700,7 +700,7 @@ Surface * bbGetSurface( MeshModel *m,int index ){ if( debug ){ debugMesh(m); if( index<1 || index>m->getSurfaces().size() ){ - RTEX( "Surface Index out of range" ); + ThrowRuntimeException( "Surface Index out of range" ); } } return m->getSurfaces()[index-1]; @@ -1160,7 +1160,7 @@ Entity * bbCreateMirror( Entity *p ){ Entity * bbCreatePlane( int segs,Entity *p ){ if( debug ){ debugParent(p); - if( segs<1 || segs>20 ) RTEX( "Illegal number of segments" ); + if( segs<1 || segs>20 ) ThrowRuntimeException( "Illegal number of segments" ); } PlaneModel *t=d_new PlaneModel( segs ); return insertEntity( t,p ); @@ -1245,7 +1245,7 @@ Entity * bbCreateTerrain( int n,Entity *p ){ debugParent(p); int shift=0; while( (1<loadCanvas( *file,gxCanvas::CANVAS_HIGHCOLOR ); - if( !c ) RTEX( "Unable to load heightmap image" ); + if( !c ) ThrowRuntimeException( "Unable to load heightmap image" ); int w=c->getWidth(),h=c->getHeight(); - if( w!=h ) RTEX( "Terrain must be square" ); + if( w!=h ) ThrowRuntimeException( "Terrain must be square" ); int shift=0; while( (1<lock(); for( int y=0;yemitSound( sound ); } @@ -1376,7 +1376,7 @@ void bbEntityParent( Entity *e,Entity *p,int global ){ Entity *t=p; while( t ){ if( t==e ){ - RTEX( "Entity cannot be parented to itself!" ); + ThrowRuntimeException( "Entity cannot be parented to itself!" ); } t=t->getParent(); } @@ -1441,7 +1441,7 @@ void bbSetAnimTime( Object *o,float time,int seq ){ if( Animator *anim=o->getAnimator() ){ anim->setAnimTime( time,seq ); }else{ - RTEX( "Entity has not animation" ); + ThrowRuntimeException( "Entity has not animation" ); } } @@ -1450,7 +1450,7 @@ void bbAnimate( Object *o,int mode,float speed,int seq,float trans ){ if( Animator *anim=o->getAnimator() ){ anim->animate( mode,speed,seq,trans ); }else{ - RTEX( "Entity has no animation" ); + ThrowRuntimeException( "Entity has no animation" ); } } @@ -1559,7 +1559,7 @@ void bbEntityOrder( Object *o,int n ){ if( debug ){ debugEntity(o); if( !o->getModel() && !o->getCamera() ){ - RTEX( "Entity is not a model or camera" ); + ThrowRuntimeException( "Entity is not a model or camera" ); } } o->setOrder( n ); @@ -1691,7 +1691,7 @@ static void entityType( Entity *e,int type ){ void bbEntityType( Object *o,int type,int recurs ){ if( debug ){ debugObject(o); - if( type<0 || type>999 ) RTEX( "EntityType ID must be in the range 0...999" ); + if( type<0 || type>999 ) ThrowRuntimeException( "EntityType ID must be in the range 0...999" ); } if( recurs ) entityType( o,type ); else{ @@ -1927,7 +1927,7 @@ int bbActiveTextures(){ void blitz3d_open(){ gx_scene=gx_graphics->createScene( 0 ); - if( !gx_scene ) RTEX( "Unable to create 3D Scene" ); + if( !gx_scene ) ThrowRuntimeException( "Unable to create 3D Scene" ); world=d_new World(); projected=Vector(); picked.collision=Collision(); diff --git a/bbruntime/bbblitz3d.h b/RuntimeLib/bbblitz3d.h similarity index 100% rename from bbruntime/bbblitz3d.h rename to RuntimeLib/bbblitz3d.h diff --git a/bbruntime/bbfilesystem.cpp b/RuntimeLib/bbfilesystem.cpp similarity index 95% rename from bbruntime/bbfilesystem.cpp rename to RuntimeLib/bbfilesystem.cpp index 56ff3b8..0a6348e 100644 --- a/bbruntime/bbfilesystem.cpp +++ b/RuntimeLib/bbfilesystem.cpp @@ -31,13 +31,13 @@ static set file_set; static inline void debugFile( bbFile *f ){ if( debug ){ - if( !file_set.count( f ) ) RTEX( "File does not exist" ); + if( !file_set.count( f ) ) ThrowRuntimeException( "File does not exist" ); } } static inline void debugDir( gxDir *d ){ if( debug ){ - if( !gx_filesys->verifyDir( d ) ) RTEX( "Directory does not exist" ); + if( !gx_filesys->verifyDir( d ) ) ThrowRuntimeException( "Directory does not exist" ); } } diff --git a/bbruntime/bbfilesystem.h b/RuntimeLib/bbfilesystem.h similarity index 100% rename from bbruntime/bbfilesystem.h rename to RuntimeLib/bbfilesystem.h diff --git a/RuntimeLib/bbgraphics.cpp b/RuntimeLib/bbgraphics.cpp new file mode 100644 index 0000000..7e64cd1 --- /dev/null +++ b/RuntimeLib/bbgraphics.cpp @@ -0,0 +1,1363 @@ + +#include "std.h" +#include "bbgraphics.h" +#include "bbinput.h" + +gxGraphics *gx_graphics; +gxCanvas *gx_canvas; + +struct GfxMode { + int w, h, d, caps; +}; + +class bbImage { +public: + bbImage(const vector &f) :frames(f) { + } + ~bbImage() { + for (int k = 0; k < frames.size(); ++k) { + gx_graphics->freeCanvas(frames[k]); + } + } + const vector &getFrames()const { + return frames; + } + void replaceFrame(int n, gxCanvas *c) { + gx_graphics->freeCanvas(frames[n]); + frames[n] = c; + } +private: + vector frames; +}; + +//degrees to radians +static const float dtor = 0.0174532925199432957692369076848861f; + +static int gx_driver; //current graphics driver + +static bool filter; +static bool auto_dirty; +static bool auto_midhandle; +static set image_set; +static int curs_x, curs_y; +static gxCanvas *p_canvas; + +static gxFont *curr_font; +static unsigned curr_color; +static unsigned curr_clsColor; + +static vector gfx_modes; + +static inline void debugImage(bbImage *i, int frame = 0) { + if (debug) { + if (!image_set.count(i)) ThrowRuntimeException("Image does not exist"); + if (frame >= i->getFrames().size()) ThrowRuntimeException("Image frame out of range"); + } +} + +static inline void debugFont(gxFont *f) { + if (debug) { + if (!gx_graphics->verifyFont(f)) ThrowRuntimeException("Font does not exist"); + } +} + +static inline void debugCanvas(gxCanvas *c) { + if (debug) { + if (!gx_graphics->verifyCanvas(c)) ThrowRuntimeException("Buffer does not exist"); + } +} + +static inline void debugDriver(int n) { + if (debug) { + if (n<1 || n>gx_runtime->enumerateGraphicsDrivers()) { + ThrowRuntimeException("Illegal graphics driver index"); + } + } +} + +static inline void debugMode(int n) { + if (debug) { + if (n<1 || n>gfx_modes.size()) { + ThrowRuntimeException("Illegal graphics mode index"); + } + } +} + +void bbFreeImage(bbImage *i); + +static void freeGraphics() { + extern void blitz3d_close(); + blitz3d_close(); + while (image_set.size()) bbFreeImage(*image_set.begin()); + if (p_canvas) { + gx_graphics->freeCanvas(p_canvas); + p_canvas = 0; + } +} + +#define RED(_X_) ( ((_X_)>>16) & 0xff ) +#define GRN(_X_) ( ((_X_)>>8) & 0xff ) +#define BLU(_X_) ( (_X_) & 0xff ) + +static int getPixel(gxCanvas *c, float x, float y) { + debugCanvas(c); + + x -= .5f; y -= .5f; + float fx = floor(x), fy = floor(y); + int ix = fx, iy = fy; fx = x - fx; fy = y - fy; + + int tl = c->getPixel(ix, iy); + int tr = c->getPixel(ix + 1, iy); + int br = c->getPixel(ix + 1, iy + 1); + int bl = c->getPixel(ix, iy + 1); + + float w1 = (1 - fx)*(1 - fy), w2 = fx*(1 - fy), w3 = (1 - fx)*fy, w4 = fx*fy; + + float r = RED(tl)*w1 + RED(tr)*w2 + RED(bl)*w3 + RED(br)*w4; + float g = GRN(tl)*w1 + GRN(tr)*w2 + GRN(bl)*w3 + GRN(br)*w4; + float b = BLU(tl)*w1 + BLU(tr)*w2 + BLU(bl)*w3 + BLU(br)*w4; + + return (int(r + .5f) << 16) | (int(g + .5f) << 8) | int(b + .5f); +} + +struct vec2 { float x, y; }; + +static vec2 vrot(float m[2][2], const vec2 &v) { + vec2 t; t.x = m[0][0] * v.x + m[0][1] * v.y; t.y = m[1][0] * v.x + m[1][1] * v.y; + return t; +} + +static float vmin(float a, float b, float c, float d) { + float t = a; if (b < t) t = b; if (c < t) t = c; if (d < t) t = d; return t; +} + +static float vmax(float a, float b, float c, float d) { + float t = a; if (b > t) t = b; if (c > t) t = c; if (d > t) t = d; return t; +} + +static gxCanvas *tformCanvas(gxCanvas *c, float m[2][2], int x_handle, int y_handle) { + + vec2 v, v0, v1, v2, v3; + float i[2][2]; + float dt = 1.0f / (m[0][0] * m[1][1] - m[1][0] * m[0][1]); + i[0][0] = dt*m[1][1]; i[1][0] = -dt*m[1][0]; + i[0][1] = -dt*m[0][1]; i[1][1] = dt*m[0][0]; + + float ox = x_handle, oy = y_handle; + v0.x = -ox; v0.y = -oy; //tl + v1.x = c->getWidth() - ox; v1.y = -oy; //tr + v2.x = c->getWidth() - ox; v2.y = c->getHeight() - oy; //br + v3.x = -ox; v3.y = c->getHeight() - oy; //bl + v0 = vrot(m, v0); v1 = vrot(m, v1); v2 = vrot(m, v2); v3 = vrot(m, v3); + float minx = floor(vmin(v0.x, v1.x, v2.x, v3.x)); + float miny = floor(vmin(v0.y, v1.y, v2.y, v3.y)); + float maxx = ceil(vmax(v0.x, v1.x, v2.x, v3.x)); + float maxy = ceil(vmax(v0.y, v1.y, v2.y, v3.y)); + int iw = maxx - minx, ih = maxy - miny; + + gxCanvas *t = gx_graphics->createCanvas(iw, ih, 0); + t->setHandle(-minx, -miny); + t->setMask(c->getMask()); + + c->lock(); + t->lock(); + + v.y = miny + .5f; + for (int y = 0; y < ih; ++v.y, ++y) { + v.x = minx + .5f; + for (int x = 0; x < iw; ++v.x, ++x) { + vec2 q = vrot(i, v); + unsigned rgb = filter ? getPixel(c, q.x + ox, q.y + oy) : c->getPixel(floor(q.x + ox), floor(q.y + oy)); + t->setPixel(x, y, rgb); + } + } + + t->unlock(); + c->unlock(); + + return t; +} + +static bool saveCanvas(gxCanvas *c, const string &f) { + + ofstream out(f.c_str(), ios::binary); + if (!out.good()) return false; + + int tempsize = (c->getWidth() * 3 + 3)&~3; + + BITMAPFILEHEADER bf; + memset(&bf, 0, sizeof(bf)); + bf.bfType = 'MB'; + bf.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + tempsize*c->getHeight(); + bf.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); + BITMAPINFOHEADER bi; memset(&bi, 0, sizeof(bi)); + bi.biSize = sizeof(bi); + bi.biWidth = c->getWidth(); + bi.biHeight = c->getHeight(); + bi.biPlanes = 1; + bi.biBitCount = 24; + out.write((char*)&bf, sizeof(bf)); + out.write((char*)&bi, sizeof(bi)); + + unsigned char *temp = d_new unsigned char[tempsize]; + memset(temp, 0, tempsize); + + c->lock(); + for (int y = c->getHeight() - 1; y >= 0; --y) { + unsigned char *dest = temp; + for (int x = 0; x < c->getWidth(); ++x) { + unsigned rgb = c->getPixelFast(x, y); + *dest++ = rgb & 0xff; + *dest++ = (rgb >> 8) & 0xff; + *dest++ = (rgb >> 16) & 0xff; + } + out.write((char*)temp, tempsize); + } + c->unlock(); + + delete[] temp; + + return out.good(); +} + +int bbCountGfxDrivers() { + return gx_runtime->enumerateGraphicsDrivers(); +} + +BBStr * bbGfxDriverName(int n) { + debugDriver(n); + string t; int caps; + gx_runtime->graphicsDriverInfo(n - 1, &t, &caps); + return d_new BBStr(t); +} + +void bbSetGfxDriver(int n) { + debugDriver(n); + gfx_modes.clear(); + gx_driver = n - 1; +} + +int bbCountGfxModes() { + gfx_modes.clear(); + int n = gx_runtime->countGraphicsModes(gx_driver); + for (int k = 0; k < n; ++k) { + GfxMode m; + gx_runtime->graphicsModeInfo(gx_driver, k, &m.w, &m.h, &m.d, &m.caps); + gfx_modes.push_back(m); + } + return gfx_modes.size(); +} + +int bbGfxModeWidth(int n) { + debugMode(n); + return gfx_modes[n - 1].w; +} + +int bbGfxModeHeight(int n) { + debugMode(n); + return gfx_modes[n - 1].h; +} + +int bbGfxModeDepth(int n) { + debugMode(n); + return gfx_modes[n - 1].d; +} + +static int modeExists(int w, int h, int d, bool bb3d) { + int cnt = gx_runtime->countGraphicsModes(gx_driver); + for (int k = 0; k < cnt; ++k) { + int tw, th, td, tc; + gx_runtime->graphicsModeInfo(gx_driver, k, &tw, &th, &td, &tc); + if (bb3d && !(tc&gxRuntime::GFXMODECAPS_3D)) continue; + if (w == tw && h == th && d == td) return 1; + } + return 0; +} + +int bbGfxModeExists(int w, int h, int d) { + return modeExists(w, h, d, false); +} + +int bbGfxDriver3D(int n) { + debugDriver(n); + string t; int caps; + gx_runtime->graphicsDriverInfo(n - 1, &t, &caps); + return (caps & gxRuntime::GFXMODECAPS_3D) ? 1 : 0; +} + +int bbCountGfxModes3D() { + gfx_modes.clear(); + int n = gx_runtime->countGraphicsModes(gx_driver); + for (int k = 0; k < n; ++k) { + GfxMode m; + gx_runtime->graphicsModeInfo(gx_driver, k, &m.w, &m.h, &m.d, &m.caps); + if (m.caps & gxRuntime::GFXMODECAPS_3D) gfx_modes.push_back(m); + } + return gfx_modes.size(); +} + +int bbGfxMode3DExists(int w, int h, int d) { + return modeExists(w, h, d, true); +} + +int bbGfxMode3D(int n) { + debugMode(n); + return gfx_modes[n - 1].caps & gxRuntime::GFXMODECAPS_3D ? 1 : 0; +} + +int bbWindowed3D() { + int tc; + gx_runtime->windowedModeInfo(&tc); + return (tc & gxRuntime::GFXMODECAPS_3D) ? 1 : 0; +} + +int bbTotalVidMem() { + return gx_graphics->getTotalVidmem(); +} + +int bbAvailVidMem() { + return gx_graphics->getAvailVidmem(); +} + +void bbSetBuffer(gxCanvas *buff) { + debugCanvas(buff); + gx_canvas = buff; + curs_x = curs_y = 0; + gx_canvas->setOrigin(0, 0); + gx_canvas->setViewport(0, 0, gx_canvas->getWidth(), gx_canvas->getHeight()); + gx_canvas->setColor(curr_color); + gx_canvas->setClsColor(curr_clsColor); + gx_canvas->setFont(curr_font); + + // Switch Render Target + //if (gx_graphics != nullptr) { + // if (gx_graphics->dir3dDev != nullptr) { + // LPDIRECTDRAWSURFACE7 pddsOldRenderTarget = NULL, pddsNewRenderTarget = gx_canvas->getSurface(); + // gx_graphics->dir3dDev->GetRenderTarget(&pddsOldRenderTarget); + + // if (pddsOldRenderTarget) { + // LPDIRECTDRAWSURFACE7 pddsZBuffer = NULL; + // DDSCAPS2 ddscaps = { DDSCAPS_ZBUFFER, 0, 0, 0 }; + // pddsOldRenderTarget->GetAttachedSurface(&ddscaps, &pddsZBuffer); + + // if (pddsZBuffer) { + // pddsOldRenderTarget->DeleteAttachedSurface(0, pddsZBuffer); + // pddsNewRenderTarget->AddAttachedSurface(pddsZBuffer); + // //pddsZBuffer->Release(); + // } + // //pddsOldRenderTarget->Release(); + // } + + // gx_graphics->dir3dDev->SetRenderTarget(pddsNewRenderTarget, 0); + // } + //} +} + +gxCanvas *bbGraphicsBuffer() { + return gx_canvas; +} + +int bbLoadBuffer(gxCanvas *c, BBStr *str) { + debugCanvas(c); + string s = *str; delete str; + gxCanvas *t = gx_graphics->loadCanvas(s, 0); + if (!t) return 0; + float m[2][2]; + m[0][0] = (float)c->getWidth() / (float)t->getWidth(); + m[1][1] = (float)c->getHeight() / (float)t->getHeight(); + m[1][0] = m[0][1] = 0; + gxCanvas *p = tformCanvas(t, m, 0, 0); + gx_graphics->freeCanvas(t); + int ox, oy; + c->getOrigin(&ox, &oy); c->setOrigin(0, 0); + c->blit(0, 0, p, 0, 0, p->getWidth(), p->getHeight(), true); + gx_graphics->freeCanvas(p); + return 1; +} + +int bbSaveBuffer(gxCanvas *c, BBStr *str) { + debugCanvas(c); + string t = *str; delete str; + return saveCanvas(c, t) ? 1 : 0; +} + +void bbBufferDirty(gxCanvas *c) { + debugCanvas(c); + c->backup(); +} + +static void graphics(int w, int h, int d, int flags) { + freeGraphics(); + gx_runtime->closeGraphics(gx_graphics); + gx_graphics = gx_runtime->openGraphics(w, h, d, gx_driver, flags); + if (!gx_runtime->idle()) ThrowRuntimeException(0); + if (!gx_graphics) { + ThrowRuntimeException("Unable to set graphics mode"); + } + curr_clsColor = 0; + curr_color = 0xffffffff; + curr_font = gx_graphics->getDefaultFont(); + gxCanvas *buff = (flags & gxGraphics::GRAPHICS_3D) ? + gx_graphics->getBackCanvas() : gx_graphics->getFrontCanvas(); + bbSetBuffer(buff); +} + +void bbGraphics(int w, int h, int d, int mode) { + int flags = 0; + switch (mode) { + case 0:flags |= debug ? gxGraphics::GRAPHICS_WINDOWED : 0; break; + case 1:break; + case 2:flags |= gxGraphics::GRAPHICS_WINDOWED; break; + case 3:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED; break; + case 6:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; + case 7:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; + default:ThrowRuntimeException("Illegal Graphics mode"); + } + graphics(w, h, d, flags); +} + +void bbGraphics3D(int w, int h, int d, int mode) { + int flags = gxGraphics::GRAPHICS_3D; + switch (mode) { + case 0:flags |= (debug && bbWindowed3D()) ? gxGraphics::GRAPHICS_WINDOWED : 0; break; + case 1:break; + case 2:flags |= gxGraphics::GRAPHICS_WINDOWED; break; + case 3:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED; break; + case 6:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; + case 7:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; + default:ThrowRuntimeException("Illegal Graphics3D mode"); + } + graphics(w, h, d, flags); + extern void blitz3d_open(); + blitz3d_open(); +} + +void bbEndGraphics() { + freeGraphics(); + gx_runtime->closeGraphics(gx_graphics); + gx_graphics = gx_runtime->openGraphics(400, 300, 0, 0, gxGraphics::GRAPHICS_WINDOWED); + if (!gx_runtime->idle()) ThrowRuntimeException(0); + if (gx_graphics) { + curr_clsColor = 0; + curr_color = 0xffffffff; + curr_font = gx_graphics->getDefaultFont(); + bbSetBuffer(gx_graphics->getFrontCanvas()); + return; + } + ThrowRuntimeException("Unable to set graphics mode"); +} + +int bbGraphicsLost() { + return gx_runtime->graphicsLost(); +} + +void bbSetGamma(int r, int g, int b, float dr, float dg, float db) { + if (dr < 0) dr = 0; + else if (dr > 255.0f) dr = 255.0f; + if (dg < 0) dg = 0; + else if (dg > 255.0f) dg = 255.0f; + if (db < 0) db = 0; + else if (db > 255.0f) db = 255.0f; + gx_graphics->setGamma(r, g, b, dr, dg, db); +} + +void bbUpdateGamma(int calibrate) { + gx_graphics->updateGamma(!!calibrate); +} + +float bbGammaRed(int n) { + float dr, dg, db; + gx_graphics->getGamma(n, n, n, &dr, &dg, &db); + return dr; +} + +float bbGammaGreen(int n) { + float dr, dg, db; + gx_graphics->getGamma(n, n, n, &dr, &dg, &db); + return dg; +} + +float bbGammaBlue(int n) { + float dr, dg, db; + gx_graphics->getGamma(n, n, n, &dr, &dg, &db); + return db; +} + +gxCanvas *bbFrontBuffer() { + return gx_graphics->getFrontCanvas(); +} + +gxCanvas *bbBackBuffer() { + return gx_graphics->getBackCanvas(); +} + +void bbLockBuffer(gxCanvas *buff) { + if (buff) debugCanvas(buff); + (buff ? buff : gx_canvas)->lock(); +} + +void bbUnlockBuffer(gxCanvas *buff) { + if (buff) debugCanvas(buff); + (buff ? buff : gx_canvas)->unlock(); +} + +int bbReadPixel(int x, int y, gxCanvas *buff) { + if (buff) debugCanvas(buff); + return (buff ? buff : gx_canvas)->getPixel(x, y); +} + +void bbWritePixel(int x, int y, int argb, gxCanvas *buff) { + if (buff) debugCanvas(buff); + (buff ? buff : gx_canvas)->setPixel(x, y, argb); +} + +int bbReadPixelFast(int x, int y, gxCanvas *buff) { + return (buff ? buff : gx_canvas)->getPixelFast(x, y); +} + +void bbWritePixelFast(int x, int y, int argb, gxCanvas *buff) { + (buff ? buff : gx_canvas)->setPixelFast(x, y, argb); +} + +void bbCopyPixel(int src_x, int src_y, gxCanvas *src, int dest_x, int dest_y, gxCanvas *buff) { + (buff ? buff : gx_canvas)->copyPixel(dest_x, dest_y, src ? src : gx_canvas, src_x, src_y); +} + +void bbCopyPixelFast(int src_x, int src_y, gxCanvas *src, int dest_x, int dest_y, gxCanvas *buff) { + (buff ? buff : gx_canvas)->copyPixelFast(dest_x, dest_y, src ? src : gx_canvas, src_x, src_y); +} + +int bbScanLine() { + return gx_graphics->getScanLine(); +} + +void bbVWait(int n) { + gx_graphics->vwait(); + if (!gx_runtime->idle()) ThrowRuntimeException(0); +} + +void bbFlip(int vwait) { + gx_graphics->flip(vwait ? true : false); + if (!gx_runtime->idle()) ThrowRuntimeException(0); +} + +int bbGraphicsWidth() { + return gx_graphics->getWidth(); +} + +int bbGraphicsHeight() { + return gx_graphics->getHeight(); +} + +int bbGraphicsDepth() { + return gx_graphics->getDepth(); +} + +void bbOrigin(int x, int y) { + gx_canvas->setOrigin(x, y); +} + +void bbViewport(int x, int y, int w, int h) { + gx_canvas->setViewport(x, y, w, h); +} + +void bbColor(int r, int g, int b) { + gx_canvas->setColor(curr_color = (r << 16) | (g << 8) | b); +} + +void bbGetColor(int x, int y) { + gx_canvas->setColor(curr_color = gx_canvas->getPixel(x, y)); +} + +int bbColorRed() { + return (gx_canvas->getColor() >> 16) & 0xff; +} + +int bbColorGreen() { + return (gx_canvas->getColor() >> 8) & 0xff; +} + +int bbColorBlue() { + return gx_canvas->getColor() & 0xff; +} + +void bbClsColor(int r, int g, int b) { + gx_canvas->setClsColor(curr_clsColor = (r << 16) | (g << 8) | b); +} + +void bbSetFont(gxFont *f) { + debugFont(f); + gx_canvas->setFont(curr_font = f); +} + +void bbCls() { + gx_canvas->cls(); +} + +void bbPlot(int x, int y) { + gx_canvas->plot(x, y); +} + +void bbLine(int x1, int y1, int x2, int y2) { + gx_canvas->line(x1, y1, x2, y2); +} + +void bbRect(int x, int y, int w, int h, int solid) { + gx_canvas->rect(x, y, w, h, solid ? true : false); +} + +void bbOval(int x, int y, int w, int h, int solid) { + gx_canvas->oval(x, y, w, h, solid ? true : false); +} + +void bbText(int x, int y, BBStr *str, int centre_x, int centre_y) { + if (centre_x) x -= curr_font->getWidth(*str) / 2; + if (centre_y) y -= curr_font->getHeight() / 2; + gx_canvas->text(x, y, *str); + delete str; +} + +void bbCopyRect(int sx, int sy, int w, int h, int dx, int dy, gxCanvas *src, gxCanvas *dest) { + if (src) debugCanvas(src); + else src = gx_canvas; + if (dest) debugCanvas(dest); + else dest = gx_canvas; + dest->blit(dx, dy, src, sx, sy, w, h, true); +} + +gxFont *bbLoadFont(BBStr *name, int height, int bold, int italic, int underline) { + int flags = + (bold ? gxFont::FONT_BOLD : 0) | + (italic ? gxFont::FONT_ITALIC : 0) | + (underline ? gxFont::FONT_UNDERLINE : 0); + gxFont *font = gx_graphics->loadFont(*name, height, flags); + delete name; + return font; +} + +void bbFreeFont(gxFont *f) { + debugFont(f); + if (f == curr_font) bbSetFont(gx_graphics->getDefaultFont()); + gx_graphics->freeFont(f); +} + +int bbFontWidth() { + return curr_font->getWidth(); +} + +int bbFontHeight() { + return curr_font->getHeight(); +} + +int bbStringWidth(BBStr *str) { + string t = *str; delete str; + return curr_font->getWidth(t); +} + +int bbStringHeight(BBStr *str) { + delete str; + return curr_font->getHeight(); +} + +gxMovie *bbOpenMovie(BBStr *s) { + gxMovie *movie = gx_graphics->openMovie(*s, 0); delete s; + return movie; +} + +int bbDrawMovie(gxMovie *movie, int x, int y, int w, int h) { + if (w < 0) w = movie->getWidth(); + if (h < 0) h = movie->getHeight(); + int playing = movie->draw(gx_canvas, x, y, w, h); + if (!gx_runtime->idle()) ThrowRuntimeException(0); + return playing; +} + +int bbMovieWidth(gxMovie *movie) { + return movie->getWidth(); +} + +int bbMovieHeight(gxMovie *movie) { + return movie->getHeight(); +} + +int bbMoviePlaying(gxMovie *movie) { + return movie->isPlaying(); +} + +void bbCloseMovie(gxMovie *movie) { + gx_graphics->closeMovie(movie); +} + +bbImage *bbLoadImage(BBStr *s) { + string t = *s; delete s; + gxCanvas *c = gx_graphics->loadCanvas(t, 0); + if (!c) return 0; + if (auto_dirty) c->backup(); + if (auto_midhandle) c->setHandle(c->getWidth() / 2, c->getHeight() / 2); + vector frames; + frames.push_back(c); + bbImage *i = d_new bbImage(frames); + image_set.insert(i); + return i; +} + +bbImage *bbLoadAnimImage(BBStr *s, int w, int h, int first, int cnt) { + + string t = *s; delete s; + + if (cnt < 1) ThrowRuntimeException("Illegal frame count"); + if (first < 0) ThrowRuntimeException("Illegal first frame"); + + gxCanvas *pic = gx_graphics->loadCanvas(t, gxCanvas::CANVAS_NONDISPLAY); + if (!pic) return 0; + + //frames per row, per picture + int fpr = pic->getWidth() / w; + int fpp = pic->getHeight() / h*fpr; + if (first + cnt > fpp) { + gx_graphics->freeCanvas(pic); + ThrowRuntimeException("Not enough frames in bitmap"); + } + + //x,y of first frame... + vector frames; + int src_x = first%fpr*w, src_y = first / fpr*h; + + for (int k = 0; k < cnt; ++k) { + gxCanvas *c = gx_graphics->createCanvas(w, h, 0); + if (!c) { + for (--k; k >= 0; --k) gx_graphics->freeCanvas(frames[k]); + gx_graphics->freeCanvas(pic); return 0; + } + c->blit(0, 0, pic, src_x, src_y, w, h, true); + if (auto_dirty) c->backup(); + if (auto_midhandle) c->setHandle(c->getWidth() / 2, c->getHeight() / 2); + frames.push_back(c); + src_x += w; if (src_x + w > pic->getWidth()) { src_x = 0; src_y += h; } + } + gx_graphics->freeCanvas(pic); + bbImage *i = d_new bbImage(frames); + image_set.insert(i); + return i; +} + +bbImage *bbCopyImage(bbImage *i) { + debugImage(i); + vector frames; + const vector &f = i->getFrames(); + for (int k = 0; k < f.size(); ++k) { + gxCanvas *t = f[k]; + gxCanvas *c = gx_graphics->createCanvas(t->getWidth(), t->getHeight(), 0); + if (!c) { + for (--k; k >= 0; --k) gx_graphics->freeCanvas(frames[k]); + return 0; + } + int x, y; + t->getHandle(&x, &y); + t->setHandle(0, 0); + c->blit(0, 0, t, 0, 0, t->getWidth(), t->getHeight(), true); + if (auto_dirty) c->backup(); + t->setHandle(x, y); + c->setHandle(x, y); + c->setMask(t->getMask()); + frames.push_back(c); + } + bbImage *t = d_new bbImage(frames); + image_set.insert(t); + return t; +} + +bbImage *bbCreateImage(int w, int h, int n) { + vector frames; + for (int k = 0; k < n; ++k) { + gxCanvas *c = gx_graphics->createCanvas(w, h, 0); + if (!c) { + for (--k; k >= 0; --k) gx_graphics->freeCanvas(frames[k]); + return 0; + } + if (auto_dirty) c->backup(); + if (auto_midhandle) c->setHandle(c->getWidth() / 2, c->getHeight() / 2); + frames.push_back(c); + } + bbImage *i = d_new bbImage(frames); + image_set.insert(i); + return i; +} + +void bbFreeImage(bbImage *i) { + if (!image_set.erase(i)) return; + const vector &f = i->getFrames(); + for (int k = 0; k < f.size(); ++k) { + if (f[k] == gx_canvas) { + bbSetBuffer(gx_graphics->getFrontCanvas()); + break; + } + } + delete i; +} + +int bbSaveImage(bbImage *i, BBStr *str, int n) { + debugImage(i, n); + string t = *str; delete str; + gxCanvas *c = i->getFrames()[n]; + return saveCanvas(c, t) ? 1 : 0; +} + +void bbGrabImage(bbImage *i, int x, int y, int n) { + debugImage(i, n); + gxCanvas *c = i->getFrames()[n]; + int src_ox, src_oy, dst_hx, dst_hy; + gx_canvas->getOrigin(&src_ox, &src_oy); + c->getHandle(&dst_hx, &dst_hy); + x += src_ox - dst_hx; y += src_oy - dst_hy; + c->setViewport(0, 0, c->getWidth(), c->getHeight()); + c->blit(0, 0, gx_canvas, x, y, c->getWidth(), c->getHeight(), true); + if (auto_dirty) c->backup(); +} + +gxCanvas *bbImageBuffer(bbImage *i, int n) { + debugImage(i, n); + return i->getFrames()[n]; +} + +void bbDrawImage(bbImage *i, int x, int y, int frame) { + debugImage(i, frame); + gxCanvas *c = i->getFrames()[frame]; + gx_canvas->blit(x, y, c, 0, 0, c->getWidth(), c->getHeight(), false); +} + +void bbDrawBlock(bbImage *i, int x, int y, int frame) { + debugImage(i, frame); + gxCanvas *c = i->getFrames()[frame]; + gx_canvas->blit(x, y, c, 0, 0, c->getWidth(), c->getHeight(), true); +} + +static void tile(bbImage *i, int x, int y, int frame, bool solid) { + gxCanvas *c = i->getFrames()[frame]; + + int hx, hy; + c->getHandle(&hx, &hy); + int w = c->getWidth(), h = c->getHeight(); + + int ox, oy, vp_x, vp_y, vp_w, vp_h; + gx_canvas->getOrigin(&ox, &oy); + gx_canvas->getViewport(&vp_x, &vp_y, &vp_w, &vp_h); + int dx = vp_x - ox + hx; + int dy = vp_y - oy + hy; + x -= dx; + y -= dy; + dx += (x >= 0 ? x%w : w - (-x%w)); + dy += (y >= 0 ? y%h : h - (-y%h)); + + for (y = -h; y < vp_h; y += h) { + for (x = -w; x < vp_w; x += w) { + gx_canvas->blit(x + dx, y + dy, c, 0, 0, w, h, solid); + } + } +} + +void bbTileImage(bbImage *i, int x, int y, int frame) { + debugImage(i, frame); + tile(i, x, y, frame, false); +} + +void bbTileBlock(bbImage *i, int x, int y, int frame) { + debugImage(i, frame); + tile(i, x, y, frame, true); +} + +void bbDrawImageRect(bbImage *i, int x, int y, int r_x, int r_y, int r_w, int r_h, int frame) { + debugImage(i, frame); + gxCanvas *c = i->getFrames()[frame]; + gx_canvas->blit(x, y, c, r_x, r_y, r_w, r_h, false); +} + +void bbDrawBlockRect(bbImage *i, int x, int y, int r_x, int r_y, int r_w, int r_h, int frame) { + debugImage(i, frame); + gxCanvas *c = i->getFrames()[frame]; + gx_canvas->blit(x, y, c, r_x, r_y, r_w, r_h, true); +} + +void bbMaskImage(bbImage *i, int r, int g, int b) { + debugImage(i); + unsigned argb = (r << 16) | (g << 8) | b; + const vector &f = i->getFrames(); + for (int k = 0; k < f.size(); ++k) f[k]->setMask(argb); +} + +void bbHandleImage(bbImage *i, int x, int y) { + debugImage(i); + const vector &f = i->getFrames(); + for (int k = 0; k < f.size(); ++k) f[k]->setHandle(x, y); +} + +void bbMidHandle(bbImage *i) { + debugImage(i); + const vector &f = i->getFrames(); + for (int k = 0; k < f.size(); ++k) f[k]->setHandle(f[k]->getWidth() / 2, f[k]->getHeight() / 2); +} + +void bbAutoMidHandle(int enable) { + auto_midhandle = enable ? true : false; +} + +int bbImageWidth(bbImage *i) { + debugImage(i); + return i->getFrames()[0]->getWidth(); +} + +int bbImageHeight(bbImage *i) { + debugImage(i); + return i->getFrames()[0]->getHeight(); +} + +int bbImageXHandle(bbImage *i) { + debugImage(i); + int x, y; + i->getFrames()[0]->getHandle(&x, &y); + return x; +} + +int bbImageYHandle(bbImage *i) { + debugImage(i); + int x, y; + i->getFrames()[0]->getHandle(&x, &y); + return y; +} + +int bbImagesOverlap(bbImage *i1, int x1, int y1, bbImage *i2, int x2, int y2) { + debugImage(i1); + debugImage(i2); + gxCanvas *c1 = i1->getFrames()[0]; + gxCanvas *c2 = i2->getFrames()[0]; + return c1->collide(x1, y1, c2, x2, y2, true); +} + +int bbImagesCollide(bbImage *i1, int x1, int y1, int f1, bbImage *i2, int x2, int y2, int f2) { + debugImage(i1, f1); + debugImage(i2, f2); + gxCanvas *c1 = i1->getFrames()[f1]; + gxCanvas *c2 = i2->getFrames()[f2]; + return c1->collide(x1, y1, c2, x2, y2, false); +} + +int bbRectsOverlap(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) { + if (x1 + w1 <= x2 || x1 >= x2 + w2 || y1 + h1 <= y2 || y1 >= y2 + h2) return 0; + return 1; +} + +int bbImageRectOverlap(bbImage *i, int x, int y, int x2, int y2, int w2, int h2) { + debugImage(i); + gxCanvas *c = i->getFrames()[0]; + return c->rect_collide(x, y, x2, y2, w2, h2, true); +} + +int bbImageRectCollide(bbImage *i, int x, int y, int f, int x2, int y2, int w2, int h2) { + debugImage(i, f); + gxCanvas *c = i->getFrames()[f]; + return c->rect_collide(x, y, x2, y2, w2, h2, false); +} + +void bbTFormImage(bbImage *i, float a, float b, float c, float d) { + debugImage(i); + const vector &f = i->getFrames(); + int k; + for (k = 0; k < f.size(); ++k) { + if (f[k] == gx_canvas) { + bbSetBuffer(gx_graphics->getFrontCanvas()); + break; + } + } + float m[2][2]; + m[0][0] = a; m[1][0] = b; m[0][1] = c; m[1][1] = d; + for (k = 0; k < f.size(); ++k) { + gxCanvas *c = f[k]; + int hx, hy; c->getHandle(&hx, &hy); + gxCanvas *t = tformCanvas(c, m, hx, hy); + i->replaceFrame(k, t); + t->backup(); + } +} + +void bbScaleImage(bbImage *i, float w, float h) { + debugImage(i); + bbTFormImage(i, w, 0, 0, h); +} + +void bbResizeImage(bbImage *i, float w, float h) { + debugImage(i); + gxCanvas *c = i->getFrames()[0]; + bbTFormImage(i, w / (float)c->getWidth(), 0, 0, h / (float)c->getHeight()); +} + +void bbRotateImage(bbImage *i, float d) { + debugImage(i); + d *= -dtor; + bbTFormImage(i, cos(d), -sin(d), sin(d), cos(d)); +} + +void bbTFormFilter(int enable) { + filter = enable ? true : false; +} + +static int p_ox, p_oy, p_hx, p_hy, p_vpx, p_vpy, p_vpw, p_vph; + +static gxCanvas *startPrinting() { + + gxCanvas *c = gx_graphics->getFrontCanvas(); + + c->lock(); + c->unlock(); + + c->getOrigin(&p_ox, &p_oy); + c->getHandle(&p_hx, &p_hy); + c->getViewport(&p_vpx, &p_vpy, &p_vpw, &p_vph); + + c->setOrigin(0, 0); + c->setHandle(0, 0); + c->setViewport(0, 0, c->getWidth(), c->getHeight()); + if (c != gx_canvas) { + c->setFont(curr_font); + c->setColor(curr_color); + } + + int dy = curs_y + curr_font->getHeight() - c->getHeight(); + if (dy > 0) { + curs_y = c->getHeight() - curr_font->getHeight(); + c->blit(0, 0, c, 0, dy, c->getWidth(), c->getHeight() - dy, true); + c->setColor(curr_clsColor); + c->rect(0, c->getHeight() - dy, c->getWidth(), dy, true); + c->setColor(curr_color); + } + return c; +} + +static void endPrinting(gxCanvas *c) { + c->setViewport(p_vpx, p_vpy, p_vpw, p_vph); + c->setHandle(p_hx, p_hy); + c->setOrigin(p_ox, p_oy); + if (c == gx_canvas) c->setColor(curr_color); + if (!gx_runtime->idle()) ThrowRuntimeException(0); +} + +void bbWrite(BBStr *str) { + gxCanvas *c = startPrinting(); + c->text(curs_x, curs_y, *str); + curs_x += curr_font->getWidth(*str); + endPrinting(c); + delete str; +} + +void bbPrint(BBStr *str) { + gxCanvas *c = startPrinting(); + c->text(curs_x, curs_y, *str); + curs_x = 0; + curs_y += curr_font->getHeight(); + endPrinting(c); + delete str; +} + +BBStr *bbInput(BBStr *prompt) { + gxCanvas *c = startPrinting(); + string t = *prompt; delete prompt; + + //get temp canvas + if (!p_canvas || p_canvas->getWidth() < c->getWidth() || p_canvas->getHeight() < curr_font->getHeight() * 2) { + if (p_canvas) gx_graphics->freeCanvas(p_canvas); + p_canvas = gx_graphics->createCanvas(c->getWidth(), curr_font->getHeight() * 2, 0); + if (!p_canvas) { + endPrinting(c); + return d_new BBStr(); + } + } + //draw prompt + c->text(curs_x, curs_y, t); + curs_x += curr_font->getWidth(t); + + p_canvas->setFont(curr_font); + p_canvas->setColor(curr_color); + p_canvas->blit(0, 0, c, 0, curs_y, c->getWidth(), curr_font->getHeight(), true); + + string str; + bool go = true; + int curs = 0, last_key = 0, last_time, rep_delay; + + while (go) { + + //render all text + //calc curs x and width + int cx = curs_x + curr_font->getWidth(str.substr(0, curs)); + int cw = curr_font->getWidth(curs < str.size() ? str.substr(curs, 1) : "X"); + + //wait for a key + int key = 0, st = gx_runtime->getMilliSecs(), tc = -1; + + while (gx_runtime->idle()) { + int t = gx_runtime->getMilliSecs(); + int n = (t - st) / 320; + if (n != tc) { + tc = n; + if (!(tc & 1)) { //cursor ON + c->setColor(curr_clsColor ^ 0xffffff); + c->rect(cx, curs_y, cw, curr_font->getHeight(), true); + c->setColor(curr_clsColor); + } else { //cursor OFF + c->blit(cx, curs_y, p_canvas, cx, 0, cw, curr_font->getHeight(), true); + c->setColor(curr_color); + } + c->text(cx, curs_y, str.substr(curs, 1)); + } + if (key = gx_keyboard->getKey()) { + if (int asc = gx_input->toAscii(key)) { + rep_delay = 280; + last_key = key; + last_time = t; + key = asc; + break; + } + } + if (last_key && gx_keyboard->keyDown(last_key)) { + if (t - last_time > rep_delay) { + if (key = gx_input->toAscii(last_key)) { + last_time += rep_delay; + rep_delay = 40; + break; + } + } + } else last_key = 0; + gx_runtime->delay(20); + } + + //check the key + switch (key) { + case 0: + go = false; + str = ""; + break; + case 8: + if (curs) { + str = str.substr(0, curs - 1) + str.substr(curs); + --curs; + } + break; + case 27: + curs = 0; str = ""; + break; + case gxInput::ASC_DELETE: + if (curs < str.size()) str = str.substr(0, curs) + str.substr(curs + 1); + break; + case gxInput::ASC_HOME: + curs = 0; + break; + case gxInput::ASC_END: + curs = str.size(); + break; + case gxInput::ASC_LEFT: + if (curs) --curs; + break; + case gxInput::ASC_RIGHT: + if (curs < str.size()) ++curs; + break; + case '\r': + go = false; + break; + default: + if (curr_font->isPrintable(key)) { + str = str.substr(0, curs) + char(key) + str.substr(curs); + ++curs; + } + } + + //render text + p_canvas->blit(0, curr_font->getHeight(), p_canvas, 0, 0, c->getWidth(), curr_font->getHeight(), true); + p_canvas->text(curs_x, curr_font->getHeight(), str); + c->blit(0, curs_y, p_canvas, 0, curr_font->getHeight(), c->getWidth(), curr_font->getHeight(), true); + } + + curs_x = 0; + curs_y += curr_font->getHeight(); + endPrinting(c); + return d_new BBStr(str); +} + +void bbLocate(int x, int y) { + gxCanvas *c = gx_graphics->getFrontCanvas(); + curs_x = x < 0 ? 0 : (x > c->getWidth() ? c->getWidth() : x); + curs_y = y < 0 ? 0 : (y > c->getHeight() ? c->getHeight() : y); +} + +void bbShowPointer() { + gx_runtime->setPointerVisible(true); +} + +void bbHidePointer() { + gx_runtime->setPointerVisible(false); +} + +bool graphics_create() { + p_canvas = 0; + filter = true; + gx_driver = 0; + freeGraphics(); + auto_dirty = true; + auto_midhandle = false; + gx_graphics = gx_runtime->openGraphics(400, 300, 0, 0, gxGraphics::GRAPHICS_WINDOWED); + if (gx_graphics) { + curr_clsColor = 0; + curr_color = 0xffffffff; + curr_font = gx_graphics->getDefaultFont(); + bbSetBuffer(bbFrontBuffer()); + return true; + } + return false; +} + +bool graphics_destroy() { + freeGraphics(); + gfx_modes.clear(); + if (gx_graphics) { + gx_runtime->closeGraphics(gx_graphics); + gx_graphics = 0; + } + return true; +} + +void graphics_link(void(*rtSym)(const char *sym, void *pc)) { + + //gfx driver info + rtSym("%CountGfxDrivers", bbCountGfxDrivers); + rtSym("$GfxDriverName%driver", bbGfxDriverName); + rtSym("SetGfxDriver%driver", bbSetGfxDriver); + + //gfx mode info + rtSym("%CountGfxModes", bbCountGfxModes); + rtSym("%GfxModeExists%width%height%depth", bbGfxModeExists); + + rtSym("%GfxModeWidth%mode", bbGfxModeWidth); + rtSym("%GfxModeHeight%mode", bbGfxModeHeight); + rtSym("%GfxModeDepth%mode", bbGfxModeDepth); + rtSym("%AvailVidMem", bbAvailVidMem); + rtSym("%TotalVidMem", bbTotalVidMem); + + rtSym("%GfxDriver3D%driver", bbGfxDriver3D); + rtSym("%CountGfxModes3D", bbCountGfxModes3D); + rtSym("%GfxMode3DExists%width%height%depth", bbGfxMode3DExists); + rtSym("%GfxMode3D%mode", bbGfxMode3D); + rtSym("%Windowed3D", bbWindowed3D); + + //display mode +// rtSym( "Graphics%width%height%depth=0%mode=0",bbGraphics ); + rtSym("Graphics3D%width%height%depth=0%mode=0", bbGraphics3D); + rtSym("EndGraphics", bbEndGraphics); + rtSym("%GraphicsLost", bbGraphicsLost); + + rtSym("SetGamma%src_red%src_green%src_blue#dest_red#dest_green#dest_blue", bbSetGamma); + rtSym("UpdateGamma%calibrate=0", bbUpdateGamma); + rtSym("#GammaRed%red", bbGammaRed); + rtSym("#GammaGreen%green", bbGammaGreen); + rtSym("#GammaBlue%blue", bbGammaBlue); + + rtSym("%FrontBuffer", bbFrontBuffer); + rtSym("%BackBuffer", bbBackBuffer); + rtSym("%ScanLine", bbScanLine); + rtSym("VWait%frames=1", bbVWait); + rtSym("Flip%vwait=1", bbFlip); + rtSym("%GraphicsWidth", bbGraphicsWidth); + rtSym("%GraphicsHeight", bbGraphicsHeight); + rtSym("%GraphicsDepth", bbGraphicsDepth); + + //buffer management + rtSym("SetBuffer%buffer", bbSetBuffer); + rtSym("%GraphicsBuffer", bbGraphicsBuffer); + rtSym("%LoadBuffer%buffer$bmpfile", bbLoadBuffer); + rtSym("%SaveBuffer%buffer$bmpfile", bbSaveBuffer); + rtSym("BufferDirty%buffer", bbBufferDirty); + + //fast pixel reads/write + rtSym("LockBuffer%buffer=0", bbLockBuffer); + rtSym("UnlockBuffer%buffer=0", bbUnlockBuffer); + rtSym("%ReadPixel%x%y%buffer=0", bbReadPixel); + rtSym("WritePixel%x%y%argb%buffer=0", bbWritePixel); + rtSym("%ReadPixelFast%x%y%buffer=0", bbReadPixelFast); + rtSym("WritePixelFast%x%y%argb%buffer=0", bbWritePixelFast); + rtSym("CopyPixel%src_x%src_y%src_buffer%dest_x%dest_y%dest_buffer=0", bbCopyPixel); + rtSym("CopyPixelFast%src_x%src_y%src_buffer%dest_x%dest_y%dest_buffer=0", bbCopyPixelFast); + + //rendering + rtSym("Origin%x%y", bbOrigin); + rtSym("Viewport%x%y%width%height", bbViewport); + rtSym("Color%red%green%blue", bbColor); + rtSym("GetColor%x%y", bbGetColor); + rtSym("%ColorRed", bbColorRed); + rtSym("%ColorGreen", bbColorGreen); + rtSym("%ColorBlue", bbColorBlue); + rtSym("ClsColor%red%green%blue", bbClsColor); + rtSym("SetFont%font", bbSetFont); + rtSym("Cls", bbCls); + rtSym("Plot%x%y", bbPlot); + rtSym("Rect%x%y%width%height%solid=1", bbRect); + rtSym("Oval%x%y%width%height%solid=1", bbOval); + rtSym("Line%x1%y1%x2%y2", bbLine); + rtSym("Text%x%y$text%centre_x=0%centre_y=0", bbText); + rtSym("CopyRect%source_x%source_y%width%height%dest_x%dest_y%src_buffer=0%dest_buffer=0", bbCopyRect); + + //fonts + rtSym("%LoadFont$fontname%height=12%bold=0%italic=0%underline=0", bbLoadFont); + rtSym("FreeFont%font", bbFreeFont); + rtSym("%FontWidth", bbFontWidth); + rtSym("%FontHeight", bbFontHeight); + rtSym("%StringWidth$string", bbStringWidth); + rtSym("%StringHeight$string", bbStringHeight); + + //movies + rtSym("%OpenMovie$file", bbOpenMovie); + rtSym("%DrawMovie%movie%x=0%y=0%w=-1%h=-1", bbDrawMovie); + rtSym("%MovieWidth%movie", bbMovieWidth); + rtSym("%MovieHeight%movie", bbMovieHeight); + rtSym("%MoviePlaying%movie", bbMoviePlaying); + rtSym("CloseMovie%movie", bbCloseMovie); + + rtSym("%LoadImage$bmpfile", bbLoadImage); + rtSym("%LoadAnimImage$bmpfile%cellwidth%cellheight%first%count", bbLoadAnimImage); + rtSym("%CopyImage%image", bbCopyImage); + rtSym("%CreateImage%width%height%frames=1", bbCreateImage); + rtSym("FreeImage%image", bbFreeImage); + rtSym("%SaveImage%image$bmpfile%frame=0", bbSaveImage); + + rtSym("GrabImage%image%x%y%frame=0", bbGrabImage); + rtSym("%ImageBuffer%image%frame=0", bbImageBuffer); + rtSym("DrawImage%image%x%y%frame=0", bbDrawImage); + rtSym("DrawBlock%image%x%y%frame=0", bbDrawBlock); + rtSym("TileImage%image%x=0%y=0%frame=0", bbTileImage); + rtSym("TileBlock%image%x=0%y=0%frame=0", bbTileBlock); + rtSym("DrawImageRect%image%x%y%rect_x%rect_y%rect_width%rect_height%frame=0", bbDrawImageRect); + rtSym("DrawBlockRect%image%x%y%rect_x%rect_y%rect_width%rect_height%frame=0", bbDrawBlockRect); + rtSym("MaskImage%image%red%green%blue", bbMaskImage); + rtSym("HandleImage%image%x%y", bbHandleImage); + rtSym("MidHandle%image", bbMidHandle); + rtSym("AutoMidHandle%enable", bbAutoMidHandle); + rtSym("%ImageWidth%image", bbImageWidth); + rtSym("%ImageHeight%image", bbImageHeight); + rtSym("%ImageXHandle%image", bbImageXHandle); + rtSym("%ImageYHandle%image", bbImageYHandle); + + rtSym("ScaleImage%image#xscale#yscale", bbScaleImage); + rtSym("ResizeImage%image#width#height", bbResizeImage); + rtSym("RotateImage%image#angle", bbRotateImage); + rtSym("TFormImage%image#a#b#c#d", bbTFormImage); + rtSym("TFormFilter%enable", bbTFormFilter); + + rtSym("%ImagesOverlap%image1%x1%y1%image2%x2%y2", bbImagesOverlap); + rtSym("%ImagesCollide%image1%x1%y1%frame1%image2%x2%y2%frame2", bbImagesCollide); + rtSym("%RectsOverlap%x1%y1%width1%height1%x2%y2%width2%height2", bbRectsOverlap); + rtSym("%ImageRectOverlap%image%x%y%rect_x%rect_y%rect_width%rect_height", bbImageRectOverlap); + rtSym("%ImageRectCollide%image%x%y%frame%rect_x%rect_y%rect_width%rect_height", bbImageRectCollide); + + rtSym("Write$string", bbWrite); + rtSym("Print$string=\"\"", bbPrint); + rtSym("$Input$prompt=\"\"", bbInput); + rtSym("Locate%x%y", bbLocate); + + rtSym("ShowPointer", bbShowPointer); + rtSym("HidePointer", bbHidePointer); +} diff --git a/bbruntime/bbgraphics.h b/RuntimeLib/bbgraphics.h similarity index 100% rename from bbruntime/bbgraphics.h rename to RuntimeLib/bbgraphics.h diff --git a/bbruntime/bbinput.cpp b/RuntimeLib/bbinput.cpp similarity index 97% rename from bbruntime/bbinput.cpp rename to RuntimeLib/bbinput.cpp index 2ea3d9e..b626fad 100644 --- a/bbruntime/bbinput.cpp +++ b/RuntimeLib/bbinput.cpp @@ -50,7 +50,7 @@ int bbGetKey(){ int bbWaitKey(){ for(;;){ - if( !gx_runtime->idle() ) RTEX( 0 ); + if( !gx_runtime->idle() ) ThrowRuntimeException( 0 ); if( int key=gx_keyboard->getKey( ) ){ if( key=gx_input->toAscii( key ) ) return key; } @@ -76,7 +76,7 @@ int bbGetMouse(){ int bbWaitMouse(){ for(;;){ - if( !gx_runtime->idle() ) RTEX( 0 ); + if( !gx_runtime->idle() ) ThrowRuntimeException( 0 ); if( int key=gx_mouse->getKey() ) return key; gx_runtime->delay( 20 ); } @@ -146,7 +146,7 @@ int bbGetJoy( int port ){ int bbWaitJoy( int port ){ if( port<0 || port>=gx_joysticks.size() ) return 0; for(;;){ - if( !gx_runtime->idle() ) RTEX( 0 ); + if( !gx_runtime->idle() ) ThrowRuntimeException( 0 ); if( int key=gx_joysticks[port]->getKey() ) return key; gx_runtime->delay( 20 ); } diff --git a/bbruntime/bbinput.h b/RuntimeLib/bbinput.h similarity index 100% rename from bbruntime/bbinput.h rename to RuntimeLib/bbinput.h diff --git a/bbruntime/bbmath.cpp b/RuntimeLib/bbmath.cpp similarity index 100% rename from bbruntime/bbmath.cpp rename to RuntimeLib/bbmath.cpp diff --git a/bbruntime/bbmath.h b/RuntimeLib/bbmath.h similarity index 100% rename from bbruntime/bbmath.h rename to RuntimeLib/bbmath.h diff --git a/RuntimeLib/bbruntime.cpp b/RuntimeLib/bbruntime.cpp new file mode 100644 index 0000000..f5b440d --- /dev/null +++ b/RuntimeLib/bbruntime.cpp @@ -0,0 +1,260 @@ + +#include "std.h" +#include "bbsys.h" +#include "bbruntime.h" + +void bbEnd() { + ThrowRuntimeException(0); +} +void bbStop() { + gx_runtime->debugStop(); + if (!gx_runtime->idle()) ThrowRuntimeException(0); +} + +void bbAppTitle(BBStr *ti, BBStr *cp) { + gx_runtime->setTitle(*ti, *cp); + delete ti; delete cp; +} + +void bbRuntimeError(BBStr *str) { + string t = *str; delete str; + if (t.size() > 255) t[255] = 0; + static char err[256]; + strcpy(err, t.c_str()); + ThrowRuntimeException(err); +} + +int bbExecFile(BBStr *f) { + string t = *f; delete f; + int n = gx_runtime->execute(t); + if (!gx_runtime->idle()) ThrowRuntimeException(0); + return n; +} + +void bbDelay(int ms) { + if (!gx_runtime->delay(ms)) ThrowRuntimeException(0); +} + +int bbMilliSecs() { + return gx_runtime->getMilliSecs(); +} + +BBStr * bbCommandLine() { + return d_new BBStr(gx_runtime->commandLine()); +} + +BBStr * bbSystemProperty(BBStr *p) { + string t = gx_runtime->systemProperty(*p); + delete p; return d_new BBStr(t); +} + +BBStr * bbGetEnv(BBStr *env_var) { + char *p = getenv(env_var->c_str()); + BBStr *val = d_new BBStr(p ? p : ""); + delete env_var; + return val; +} + +void bbSetEnv(BBStr *env_var, BBStr *val) { + string t = *env_var + "=" + *val; + _putenv(t.c_str()); + delete env_var; + delete val; +} + +gxTimer * bbCreateTimer(int hertz) { + gxTimer *t = gx_runtime->createTimer(hertz); + return t; +} + +int bbWaitTimer(gxTimer *t) { + int n = t->wait(); + if (!gx_runtime->idle()) ThrowRuntimeException(0); + return n; +} + +void bbFreeTimer(gxTimer *t) { + gx_runtime->freeTimer(t); +} + +void bbDebugLog(BBStr *t) { + gx_runtime->debugLog(t->c_str()); + delete t; +} + +void _bbDebugStmt(int pos, const char *file) { + gx_runtime->debugStmt(pos, file); + if (!gx_runtime->idle()) ThrowRuntimeException(0); +} + +void _bbDebugEnter(void *frame, void *env, const char *func) { + gx_runtime->debugEnter(frame, env, func); +} + +void _bbDebugLeave() { + gx_runtime->debugLeave(); +} + +bool basic_create(); +bool basic_destroy(); +void basic_link(void(*rtSym)(const char *sym, void *pc)); +bool math_create(); +bool math_destroy(); +void math_link(void(*rtSym)(const char *sym, void *pc)); +bool string_create(); +bool string_destroy(); +void string_link(void(*rtSym)(const char *sym, void *pc)); +bool stream_create(); +bool stream_destroy(); +void stream_link(void(*rtSym)(const char *sym, void *pc)); +bool sockets_create(); +bool sockets_destroy(); +void sockets_link(void(*rtSym)(const char *sym, void *pc)); +bool filesystem_create(); +bool filesystem_destroy(); +void filesystem_link(void(*rtSym)(const char *sym, void *pc)); +bool bank_create(); +bool bank_destroy(); +void bank_link(void(*rtSym)(const char *sym, void *pc)); +bool graphics_create(); +bool graphics_destroy(); +void graphics_link(void(*rtSym)(const char *sym, void *pc)); +bool input_create(); +bool input_destroy(); +void input_link(void(*rtSym)(const char *sym, void *pc)); +bool audio_create(); +bool audio_destroy(); +void audio_link(void(*rtSym)(const char *sym, void *pc)); +//bool multiplay_create(); +//bool multiplay_destroy(); +//void multiplay_link( void (*rtSym)( const char *sym,void *pc ) ); +bool userlibs_create(); +void userlibs_destroy(); +void userlibs_link(void(*rtSym)(const char *sym, void *pc)); +bool blitz3d_create(); +bool blitz3d_destroy(); +void blitz3d_link(void(*rtSym)(const char *sym, void *pc)); + +void bbruntime_link(void(*rtSym)(const char *sym, void *pc)) { + + rtSym("End", bbEnd); + rtSym("Stop", bbStop); + rtSym("AppTitle$title$close_prompt=\"\"", bbAppTitle); + rtSym("RuntimeError$message", bbRuntimeError); + rtSym("ExecFile$command", bbExecFile); + rtSym("Delay%millisecs", bbDelay); + rtSym("%MilliSecs", bbMilliSecs); + rtSym("$CommandLine", bbCommandLine); + rtSym("$SystemProperty$property", bbSystemProperty); + rtSym("$GetEnv$env_var", bbGetEnv); + rtSym("SetEnv$env_var$value", bbSetEnv); + + rtSym("%CreateTimer%hertz", bbCreateTimer); + rtSym("%WaitTimer%timer", bbWaitTimer); + rtSym("FreeTimer%timer", bbFreeTimer); + rtSym("DebugLog$text", bbDebugLog); + + rtSym("_bbDebugStmt", _bbDebugStmt); + rtSym("_bbDebugEnter", _bbDebugEnter); + rtSym("_bbDebugLeave", _bbDebugLeave); + + basic_link(rtSym); + math_link(rtSym); + string_link(rtSym); + stream_link(rtSym); + sockets_link(rtSym); + filesystem_link(rtSym); + bank_link(rtSym); + graphics_link(rtSym); + input_link(rtSym); + audio_link(rtSym); + //multiplay_link( rtSym ); + blitz3d_link(rtSym); + userlibs_link(rtSym); +} + +//start up error +static void sue(const char *t) { + string p = string("Startup Error: ") + t; + gx_runtime->debugInfo(p.c_str()); +} + +bool bbruntime_create() { + if (basic_create()) { + if (math_create()) { + if (string_create()) { + if (stream_create()) { + if (sockets_create()) { + if (filesystem_create()) { + if (bank_create()) { + if (graphics_create()) { + if (input_create()) { + if (audio_create()) { + //if( multiplay_create() ){ + if (blitz3d_create()) { + if (userlibs_create()) { + return true; + } + } else sue("blitz3d_create failed"); + // multiplay_destroy(); + //}else sue( "multiplay_create failed" ); + audio_destroy(); + } else sue("audio_create failed"); + input_destroy(); + } else sue("input_create failed"); + graphics_destroy(); + } else sue("graphics_create failed"); + bank_destroy(); + } else sue("bank_create failed"); + filesystem_destroy(); + } else sue("filesystem_create failed"); + sockets_destroy(); + } else sue("sockets_create failed"); + stream_destroy(); + } else sue("stream_create failed"); + string_destroy(); + } else sue("string_create failed"); + math_destroy(); + } else sue("math_create failed"); + basic_destroy(); + } else sue("basic_create failed"); + return false; +} + +bool bbruntime_destroy() { + userlibs_destroy(); + blitz3d_destroy(); + //multiplay_destroy(); + audio_destroy(); + input_destroy(); + graphics_destroy(); + bank_destroy(); + filesystem_destroy(); + sockets_destroy(); + stream_destroy(); + string_destroy(); + math_destroy(); + basic_destroy(); + return true; +} + +const char *bbruntime_run(gxRuntime *rt, void(*pc)(), bool dbg) { + debug = dbg; + gx_runtime = rt; + + if (!bbruntime_create()) return "Unable to start program"; + const char *t = 0; + try { + if (!gx_runtime->idle()) ThrowRuntimeException(0); + pc(); + gx_runtime->debugInfo("Program has ended"); + } catch (bbEx x) { + t = x.err; + } + bbruntime_destroy(); + return t; +} + +void bbruntime_panic(const char *err) { + ThrowRuntimeException(err); +} diff --git a/bbruntime/bbruntime.dsp b/RuntimeLib/bbruntime.dsp similarity index 100% rename from bbruntime/bbruntime.dsp rename to RuntimeLib/bbruntime.dsp diff --git a/bbruntime/bbruntime.h b/RuntimeLib/bbruntime.h similarity index 100% rename from bbruntime/bbruntime.h rename to RuntimeLib/bbruntime.h diff --git a/RuntimeLib/bbruntime.vcxproj b/RuntimeLib/bbruntime.vcxproj new file mode 100644 index 0000000..0713615 --- /dev/null +++ b/RuntimeLib/bbruntime.vcxproj @@ -0,0 +1,191 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354} + RuntimeLib + 8.1 + + + + StaticLibrary + v140 + false + MultiByte + + + StaticLibrary + v140 + false + MultiByte + + + + + + + + + + + + + + + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + true + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + + MultiThreadedDebug + Default + true + Disabled + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) + EnableFastChecks + true + true + true + false + false + true + + Guard + Level3 + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + true + true + false + StdCall + + + 0x0409 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\bbruntime.bsc + + + true + MachineX86 + + + + + MultiThreaded + OnlyExplicitInline + true + MaxSpeed + true + Level3 + true + Speed + true + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + + Guard + $(IntDir)vc$(PlatformToolsetVersion).pdb + false + false + false + StdCall + + + 0x0409 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\bbruntime.bsc + + + true + MachineX86 + + + + + + + + + + + + + Use + std.h + + + + + + + + + Create + std.h + Create + std.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bbruntime/bbruntime.vcxproj.filters b/RuntimeLib/bbruntime.vcxproj.filters similarity index 100% rename from bbruntime/bbruntime.vcxproj.filters rename to RuntimeLib/bbruntime.vcxproj.filters diff --git a/bbruntime/bbsockets.cpp b/RuntimeLib/bbsockets.cpp similarity index 97% rename from bbruntime/bbsockets.cpp rename to RuntimeLib/bbsockets.cpp index 15f2eaa..321ce76 100644 --- a/bbruntime/bbsockets.cpp +++ b/RuntimeLib/bbsockets.cpp @@ -273,19 +273,19 @@ void TCPServer::remove(TCPStream *s) { static inline void debugUDPStream(UDPStream *p) { if (debug && !udp_set.count(p)) { - RTEX("UDP Stream does not exist"); + ThrowRuntimeException("UDP Stream does not exist"); } } static inline void debugTCPStream(TCPStream *p) { if (debug && !tcp_set.count(p)) { - RTEX("TCP Stream does not exist"); + ThrowRuntimeException("TCP Stream does not exist"); } } static inline void debugTCPServer(TCPServer *p) { if (debug && !server_set.count(p)) { - RTEX("TCP Server does not exist"); + ThrowRuntimeException("TCP Server does not exist"); } } @@ -303,7 +303,7 @@ int bbCountHostIPs(BBStr *host) { int bbHostIP(int index) { if (debug) { if (index<1 || index>host_ips.size()) { - RTEX("Host index out of range"); + ThrowRuntimeException("Host index out of range"); } } return host_ips[index - 1]; @@ -440,7 +440,7 @@ void bbCloseTCPServer(TCPServer *p) { TCPStream * bbAcceptTCPStream(TCPServer *server) { debugTCPServer(server); - if (!gx_runtime->idle()) RTEX(0); + if (!gx_runtime->idle()) ThrowRuntimeException(0); if (TCPStream *tcp = server->accept()) { tcp_set.insert(tcp); return tcp; diff --git a/bbruntime/bbsockets.h b/RuntimeLib/bbsockets.h similarity index 100% rename from bbruntime/bbsockets.h rename to RuntimeLib/bbsockets.h diff --git a/bbruntime/bbstream.cpp b/RuntimeLib/bbstream.cpp similarity index 95% rename from bbruntime/bbstream.cpp rename to RuntimeLib/bbstream.cpp index 8873b5e..612b93b 100644 --- a/bbruntime/bbstream.cpp +++ b/RuntimeLib/bbstream.cpp @@ -6,7 +6,7 @@ static set stream_set; void debugStream( bbStream *s ){ if( stream_set.count(s) ) return; - RTEX( "Stream does not exist" ); + ThrowRuntimeException( "Stream does not exist" ); } bbStream::bbStream(){ @@ -119,7 +119,7 @@ void bbWriteLine( bbStream *s,BBStr *t ){ void bbCopyStream( bbStream *s,bbStream *d,int buff_size ){ if( debug ){ debugStream( s );debugStream( d ); - if( buff_size<1 || buff_size>1024*1024 ) RTEX( "Illegal buffer size" ); + if( buff_size<1 || buff_size>1024*1024 ) ThrowRuntimeException( "Illegal buffer size" ); } char *buff=d_new char[buff_size]; while( s->eof()==0 && d->eof()==0 ){ diff --git a/bbruntime/bbstream.h b/RuntimeLib/bbstream.h similarity index 100% rename from bbruntime/bbstream.h rename to RuntimeLib/bbstream.h diff --git a/bbruntime/bbstring.cpp b/RuntimeLib/bbstring.cpp similarity index 94% rename from bbruntime/bbstring.cpp rename to RuntimeLib/bbstring.cpp index 96592d7..1fd994c 100644 --- a/bbruntime/bbstring.cpp +++ b/RuntimeLib/bbstring.cpp @@ -3,8 +3,8 @@ #include "bbsys.h" #include -#define CHKPOS(x) if( (x)<0 ) RTEX( "parameter must be positive" ); -#define CHKOFF(x) if( (x)<=0 ) RTEX( "parameter must be greater than 0" ); +#define CHKPOS(x) if( (x)<0 ) ThrowRuntimeException( "parameter must be positive" ); +#define CHKOFF(x) if( (x)<=0 ) ThrowRuntimeException( "parameter must be greater than 0" ); BBStr *bbString( BBStr *s,int n ){ BBStr *t=d_new BBStr(); diff --git a/bbruntime/bbstring.h b/RuntimeLib/bbstring.h similarity index 100% rename from bbruntime/bbstring.h rename to RuntimeLib/bbstring.h diff --git a/bbruntime/bbsys.cpp b/RuntimeLib/bbsys.cpp similarity index 100% rename from bbruntime/bbsys.cpp rename to RuntimeLib/bbsys.cpp diff --git a/bbruntime/bbsys.h b/RuntimeLib/bbsys.h similarity index 81% rename from bbruntime/bbsys.h rename to RuntimeLib/bbsys.h index 6a5d0f6..c5bf0f5 100644 --- a/bbruntime/bbsys.h +++ b/RuntimeLib/bbsys.h @@ -15,6 +15,6 @@ struct bbEx{ } }; -#define RTEX( _X_ ) throw bbEx( _X_ ); +#define ThrowRuntimeException( _X_ ) throw bbEx( _X_ ); #endif \ No newline at end of file diff --git a/bbruntime/multiplay.cpp b/RuntimeLib/multiplay.cpp similarity index 100% rename from bbruntime/multiplay.cpp rename to RuntimeLib/multiplay.cpp diff --git a/bbruntime/multiplay.h b/RuntimeLib/multiplay.h similarity index 100% rename from bbruntime/multiplay.h rename to RuntimeLib/multiplay.h diff --git a/bbruntime/multiplay_setup.cpp b/RuntimeLib/multiplay_setup.cpp similarity index 100% rename from bbruntime/multiplay_setup.cpp rename to RuntimeLib/multiplay_setup.cpp diff --git a/bbruntime/multiplay_setup.h b/RuntimeLib/multiplay_setup.h similarity index 100% rename from bbruntime/multiplay_setup.h rename to RuntimeLib/multiplay_setup.h diff --git a/bbruntime/multiplay_setup.rc b/RuntimeLib/multiplay_setup.rc similarity index 100% rename from bbruntime/multiplay_setup.rc rename to RuntimeLib/multiplay_setup.rc diff --git a/bbruntime/resource.h b/RuntimeLib/resource.h similarity index 100% rename from bbruntime/resource.h rename to RuntimeLib/resource.h diff --git a/RuntimeLib/runtime.cpp b/RuntimeLib/runtime.cpp new file mode 100644 index 0000000..e69de29 diff --git a/bbruntime/std.cpp b/RuntimeLib/std.cpp similarity index 100% rename from bbruntime/std.cpp rename to RuntimeLib/std.cpp diff --git a/bbruntime/std.h b/RuntimeLib/std.h similarity index 100% rename from bbruntime/std.h rename to RuntimeLib/std.h diff --git a/bbruntime/userlib.cpp b/RuntimeLib/userlib.cpp similarity index 100% rename from bbruntime/userlib.cpp rename to RuntimeLib/userlib.cpp diff --git a/bbruntime/userlib.h b/RuntimeLib/userlib.h similarity index 100% rename from bbruntime/userlib.h rename to RuntimeLib/userlib.h diff --git a/bbruntime/userlibs.cpp b/RuntimeLib/userlibs.cpp similarity index 93% rename from bbruntime/userlibs.cpp rename to RuntimeLib/userlibs.cpp index 368f2d2..fdf1807 100644 --- a/bbruntime/userlibs.cpp +++ b/RuntimeLib/userlibs.cpp @@ -16,11 +16,11 @@ static Str _strs[256]; static int _nextStr; static void libNotFound(){ - RTEX( "User lib not found" ); + ThrowRuntimeException( "User lib not found" ); } static void procNotFound(){ - RTEX( "User lib function not found" ); + ThrowRuntimeException( "User lib function not found" ); } void _bbLoadLibs( char *p ){ diff --git a/bbruntime/userlibs.h b/RuntimeLib/userlibs.h similarity index 100% rename from bbruntime/userlibs.h rename to RuntimeLib/userlibs.h diff --git a/asm_makeinsts/asm_makeinsts.vcxproj b/asm_makeinsts/asm_makeinsts.vcxproj index 426d4b2..8b89527 100644 --- a/asm_makeinsts/asm_makeinsts.vcxproj +++ b/asm_makeinsts/asm_makeinsts.vcxproj @@ -14,7 +14,7 @@ {E85F5BD3-FEA3-4342-885E-2C00AFBFE12E} - 10.0.10586.0 + 8.1 @@ -42,31 +42,42 @@ - .\Release\ - .\Release\ + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 ..\#Build\$(ProjectName)\$(ConfigurationName)\ ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ true + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 MultiThreaded - AnySuitable + OnlyExplicitInline true MaxSpeed true Level3 true - Size + Speed true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - .\Release\ - .\Release\asm_makeinsts.pch - .\Release\ - .\Release\ + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + false + false + false + StdCall .\Release\asm_makeinsts.tlb @@ -82,25 +93,33 @@ true Console - .\Release\asm_makeinsts.exe odbc32.lib;odbccp32.lib;%(AdditionalDependencies) MultiThreadedDebug - Default - false + true Disabled true - Level3 true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\asm_makeinsts.pch - .\Debug\ - .\Debug\ + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) EnableFastChecks + true + true + true + false + false + true + Guard + Level3 + Default + true + Speed + true + true + false + StdCall .\Debug\asm_makeinsts.tlb @@ -117,7 +136,6 @@ true true Console - .\Debug\asm_makeinsts.exe odbc32.lib;odbccp32.lib;%(AdditionalDependencies) diff --git a/asm_makeinsts/main.cpp b/asm_makeinsts/main.cpp index 2316ef5..0575c83 100644 --- a/asm_makeinsts/main.cpp +++ b/asm_makeinsts/main.cpp @@ -126,7 +126,7 @@ void main(){ name='\"'+name+'\"'; } - char bf[4];itoa( bytes.size()/3,bf,16 ); + char bf[4]; _itoa( bytes.size()/3,bf,16 ); bytes="\\x"+string( bf )+bytes; out< - - - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - - - Debug - Win32 - - - Release - Win32 - - - Template - Win32 - - - - - - {C74A383E-81B0-4679-AAC9-535C94C92EA5} - 10.0.10586.0 - - - - Application - v140 - - - Application - v140 - false - MultiByte - - - Application - v140 - false - MultiByte - - - Application - v140 - false - MultiByte - - - Application - v140 - false - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - .\bblaunch___Win32_Blitz2DRelease\ - .\bblaunch___Win32_Blitz2DRelease\ - false - - - .\bblaunch___Win32_Blitz3DRelease\ - .\bblaunch___Win32_Blitz3DRelease\ - false - - - ..\#Build\$(ProjectName)\$(ConfigurationName)\ - ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ - false - - - .\Release\ - .\Release\ - false - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - .\bblaunch___Win32_Blitz2DRelease\ - .\bblaunch___Win32_Blitz2DRelease\bblaunch.pch - .\bblaunch___Win32_Blitz2DRelease\ - .\bblaunch___Win32_Blitz2DRelease\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\bblaunch___Win32_Blitz2DRelease\bblaunch.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\bblaunch___Win32_Blitz2DRelease\bblaunch.bsc - - - true - Windows - ..\..\release\blitz2drelease\BlitzBasic.exe - dxguid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - _WINDOWS;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\bblaunch___Win32_Blitz3DRelease\ - .\bblaunch___Win32_Blitz3DRelease\bblaunch.pch - .\bblaunch___Win32_Blitz3DRelease\ - .\bblaunch___Win32_Blitz3DRelease\ - StdCall - - - true - NDEBUG;%(PreprocessorDefinitions) - .\bblaunch___Win32_Blitz3DRelease\bblaunch.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\bblaunch___Win32_Blitz3DRelease\bblaunch.bsc - - - true - Windows - ../_release/Blitz3D.exe - dxguid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreadedDebug - Default - false - Disabled - true - Level3 - true - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\bblaunch.pch - .\Debug\ - .\Debug\ - EnableFastChecks - - - true - _DEBUG;%(PreprocessorDefinitions) - .\Debug\bblaunch.tlb - true - Win32 - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - true - .\Debug\bblaunch.bsc - - - true - true - Windows - ..\blitzbasic\blitzbasic.exe - /FIXED:NO - dxguid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreaded - AnySuitable - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - .\Release\ - .\Release\bblaunch.pch - .\Release\ - .\Release\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\Release\bblaunch.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\Release\bblaunch.bsc - - - true - Windows - ..\blitzbasic\blitzbasic.exe - dxguid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - {df8caa9d-7154-4d5f-bccc-0d7bb57c7354} - false - - - {5fa2fd4a-f9a4-41ba-9484-07c3a57a87e3} - false - - - {be0ba538-6215-4836-9227-1d3627e40d61} - false - - - {b61d8348-b715-42b8-a759-c7bbb0c8cd4d} - false - - - {c23af61e-9509-411f-933e-17db18884b21} - false - - - {d884a075-e3b8-44e1-838d-74f28b33391b} - false - - - {3e355353-96d8-4aaf-bf95-8e6ca0d4b1ba} - false - - - {4132c330-95d9-4f68-a51a-3b90381587c5} - false - - - {ff2d8bf7-1930-4cab-bc48-05cd33b7dc18} - false - - - {0b629ba3-d138-407a-801d-dbe7c8dc4324} - false - - - {778bcc7f-40f9-4309-9a88-c0f60d9b364d} - false - - - {6bcfc5ca-ea71-4ae9-8b96-28b8701f939e} - false - - - - - - \ No newline at end of file diff --git a/bblaunch/checkdx.cpp b/bblaunch/checkdx.cpp deleted file mode 100644 index fe1ca44..0000000 --- a/bblaunch/checkdx.cpp +++ /dev/null @@ -1,339 +0,0 @@ - -//----------------------------------------------------------------------------- -// File: GetDXVer.cpp -// -// Desc: Demonstrates how applications can detect what version of DirectX -// is installed. -// -// (C) Copyright 1995-1997 Microsoft Corp. All rights reserved. -//----------------------------------------------------------------------------- -#include -#include -#include -#include -#include - -typedef HRESULT(WINAPI * DIRECTDRAWCREATE)( GUID*, LPDIRECTDRAW*, IUnknown* ); -typedef HRESULT(WINAPI * DIRECTDRAWCREATEEX)( GUID*, VOID**, REFIID, IUnknown* ); -typedef HRESULT(WINAPI * DIRECTINPUTCREATE)( HINSTANCE, DWORD, LPDIRECTINPUT*, - IUnknown* ); - - - -//----------------------------------------------------------------------------- -// Name: GetDXVersion() -// Desc: This function returns two arguments: -// dwDXVersion: -// 0x0000 = No DirectX installed -// 0x0100 = DirectX version 1 installed -// 0x0200 = DirectX 2 installed -// 0x0300 = DirectX 3 installed -// 0x0500 = At least DirectX 5 installed. -// 0x0600 = At least DirectX 6 installed. -// 0x0601 = At least DirectX 6.1 installed. -// 0x0700 = At least DirectX 7 installed. -// dwDXPlatform: -// 0 = Unknown (This is a failure case) -// VER_PLATFORM_WIN32_WINDOWS = Windows 9X platform -// VER_PLATFORM_WIN32_NT = Windows NT platform -// -// Please note that this code is intended as a general guideline. Your -// app will probably be able to simply query for functionality (via -// QueryInterface) for one or two components. -// -// Please also note: -// "if (dxVer != 0x500) return FALSE;" is BAD. -// "if (dxVer < 0x500) return FALSE;" is MUCH BETTER. -// to ensure your app will run on future releases of DirectX. -//----------------------------------------------------------------------------- -VOID GetDXVersion( DWORD* pdwDXVersion, DWORD* pdwDXPlatform ) -{ - HRESULT hr; - HINSTANCE DDHinst = 0; - HINSTANCE DIHinst = 0; - LPDIRECTDRAW pDDraw = 0; - LPDIRECTDRAW2 pDDraw2 = 0; - DIRECTDRAWCREATE DirectDrawCreate = 0; - DIRECTDRAWCREATEEX DirectDrawCreateEx = 0; - DIRECTINPUTCREATE DirectInputCreate = 0; - OSVERSIONINFO osVer; - LPDIRECTDRAWSURFACE pSurf = 0; - LPDIRECTDRAWSURFACE3 pSurf3 = 0; - LPDIRECTDRAWSURFACE4 pSurf4 = 0; - - // First get the windows platform - osVer.dwOSVersionInfoSize = sizeof(osVer); - if( !GetVersionEx( &osVer ) ) - { - (*pdwDXPlatform) = 0; - (*pdwDXVersion) = 0; - return; - } - - if( osVer.dwPlatformId == VER_PLATFORM_WIN32_NT ) - { - (*pdwDXPlatform) = VER_PLATFORM_WIN32_NT; - - // NT is easy... NT 4.0 is DX2, 4.0 SP3 is DX3, 5.0 is DX5 - // and no DX on earlier versions. - if( osVer.dwMajorVersion < 4 ) - { - (*pdwDXVersion) = 0; // No DX on NT3.51 or earlier - return; - } - - if( osVer.dwMajorVersion == 4 ) - { - // NT4 up to SP2 is DX2, and SP3 onwards is DX3, so we are at least DX2 - (*pdwDXVersion) = 0x200; - - // We're not supposed to be able to tell which SP we're on, so check for dinput - DIHinst = LoadLibrary( "DINPUT.DLL" ); - if( DIHinst == 0 ) - { - // No DInput... must be DX2 on NT 4 pre-SP3 - OutputDebugString( "Couldn't LoadLibrary DInput\r\n" ); - return; - } - - DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst, - "DirectInputCreateA" ); - FreeLibrary( DIHinst ); - - if( DirectInputCreate == 0 ) - { - // No DInput... must be pre-SP3 DX2 - OutputDebugString( "Couldn't GetProcAddress DInputCreate\r\n" ); - return; - } - - // It must be NT4, DX2 - (*pdwDXVersion) = 0x300; // DX3 on NT4 SP3 or higher - return; - } - // Else it's NT5 or higher, and it's DX5a or higher: Drop through to - // Win9x tests for a test of DDraw (DX6 or higher) - } - else - { - // Not NT... must be Win9x - (*pdwDXPlatform) = VER_PLATFORM_WIN32_WINDOWS; - } - - // Now we know we are in Windows 9x (or maybe 3.1), so anything's possible. - // First see if DDRAW.DLL even exists. - DDHinst = LoadLibrary( "DDRAW.DLL" ); - if( DDHinst == 0 ) - { - (*pdwDXVersion) = 0; - (*pdwDXPlatform) = 0; - FreeLibrary( DDHinst ); - return; - } - - // See if we can create the DirectDraw object. - DirectDrawCreate = (DIRECTDRAWCREATE)GetProcAddress( DDHinst, "DirectDrawCreate" ); - if( DirectDrawCreate == 0 ) - { - (*pdwDXVersion) = 0; - (*pdwDXPlatform) = 0; - FreeLibrary( DDHinst ); - OutputDebugString( "Couldn't LoadLibrary DDraw\r\n" ); - return; - } - - hr = DirectDrawCreate( NULL, &pDDraw, NULL ); - if( FAILED(hr) ) - { - (*pdwDXVersion) = 0; - (*pdwDXPlatform) = 0; - FreeLibrary( DDHinst ); - OutputDebugString( "Couldn't create DDraw\r\n" ); - return; - } - - // So DirectDraw exists. We are at least DX1. - (*pdwDXVersion) = 0x100; - - // Let's see if IID_IDirectDraw2 exists. - hr = pDDraw->QueryInterface( IID_IDirectDraw2, (VOID**)&pDDraw2 ); - if( FAILED(hr) ) - { - // No IDirectDraw2 exists... must be DX1 - pDDraw->Release(); - FreeLibrary( DDHinst ); - OutputDebugString( "Couldn't QI DDraw2\r\n" ); - return; - } - - // IDirectDraw2 exists. We must be at least DX2 - pDDraw2->Release(); - (*pdwDXVersion) = 0x200; - - - /////////////////////////////////////////////////////////////////////////// - // DirectX 3.0 Checks - /////////////////////////////////////////////////////////////////////////// - - // DirectInput was added for DX3 - DIHinst = LoadLibrary( "DINPUT.DLL" ); - if( DIHinst == 0 ) - { - // No DInput... must not be DX3 - OutputDebugString( "Couldn't LoadLibrary DInput\r\n" ); - pDDraw->Release(); - FreeLibrary( DDHinst ); - return; - } - - DirectInputCreate = (DIRECTINPUTCREATE)GetProcAddress( DIHinst, - "DirectInputCreateA" ); - if( DirectInputCreate == 0 ) - { - // No DInput... must be DX2 - FreeLibrary( DIHinst ); - FreeLibrary( DDHinst ); - pDDraw->Release(); - OutputDebugString( "Couldn't GetProcAddress DInputCreate\r\n" ); - return; - } - - // DirectInputCreate exists. We are at least DX3 - (*pdwDXVersion) = 0x300; - FreeLibrary( DIHinst ); - - // Can do checks for 3a vs 3b here - - - /////////////////////////////////////////////////////////////////////////// - // DirectX 5.0 Checks - /////////////////////////////////////////////////////////////////////////// - - // We can tell if DX5 is present by checking for the existence of - // IDirectDrawSurface3. First, we need a surface to QI off of. - DDSURFACEDESC ddsd; - ZeroMemory( &ddsd, sizeof(ddsd) ); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - hr = pDDraw->SetCooperativeLevel( NULL, DDSCL_NORMAL ); - if( FAILED(hr) ) - { - // Failure. This means DDraw isn't properly installed. - pDDraw->Release(); - FreeLibrary( DDHinst ); - (*pdwDXVersion) = 0; - OutputDebugString( "Couldn't Set coop level\r\n" ); - return; - } - - hr = pDDraw->CreateSurface( &ddsd, &pSurf, NULL ); - if( FAILED(hr) ) - { - // Failure. This means DDraw isn't properly installed. - pDDraw->Release(); - FreeLibrary( DDHinst ); - *pdwDXVersion = 0; - OutputDebugString( "Couldn't CreateSurface\r\n" ); - return; - } - - // Query for the IDirectDrawSurface3 interface - if( FAILED( pSurf->QueryInterface( IID_IDirectDrawSurface3, - (VOID**)&pSurf3 ) ) ) - { - pDDraw->Release(); - FreeLibrary( DDHinst ); - return; - } - - // QI for IDirectDrawSurface3 succeeded. We must be at least DX5 - (*pdwDXVersion) = 0x500; - - - /////////////////////////////////////////////////////////////////////////// - // DirectX 6.0 Checks - /////////////////////////////////////////////////////////////////////////// - - // The IDirectDrawSurface4 interface was introduced with DX 6.0 - if( FAILED( pSurf->QueryInterface( IID_IDirectDrawSurface4, - (VOID**)&pSurf4 ) ) ) - { - pDDraw->Release(); - FreeLibrary( DDHinst ); - return; - } - - // IDirectDrawSurface4 was create successfully. We must be at least DX6 - (*pdwDXVersion) = 0x600; - pSurf->Release(); - pDDraw->Release(); - - - /////////////////////////////////////////////////////////////////////////// - // DirectX 6.1 Checks - /////////////////////////////////////////////////////////////////////////// - - // Check for DMusic, which was introduced with DX6.1 - LPDIRECTMUSIC pDMusic = NULL; - CoInitialize( NULL ); - hr = CoCreateInstance( CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, - IID_IDirectMusic, (VOID**)&pDMusic ); - if( FAILED(hr) ) - { - OutputDebugString( "Couldn't create CLSID_DirectMusic\r\n" ); - FreeLibrary( DDHinst ); - return; - } - - // DirectMusic was created successfully. We must be at least DX6.1 - (*pdwDXVersion) = 0x601; - pDMusic->Release(); - CoUninitialize(); - - - /////////////////////////////////////////////////////////////////////////// - // DirectX 7.0 Checks - /////////////////////////////////////////////////////////////////////////// - - // Check for DirectX 7 by creating a DDraw7 object - LPDIRECTDRAW7 pDD7; - DirectDrawCreateEx = (DIRECTDRAWCREATEEX)GetProcAddress( DDHinst, - "DirectDrawCreateEx" ); - if( NULL == DirectDrawCreateEx ) - { - FreeLibrary( DDHinst ); - return; - } - - if( FAILED( DirectDrawCreateEx( NULL, (VOID**)&pDD7, IID_IDirectDraw7, - NULL ) ) ) - { - FreeLibrary( DDHinst ); - return; - } - - // DDraw7 was created successfully. We must be at least DX7.0 - (*pdwDXVersion) = 0x700; - pDD7->Release(); - - - /////////////////////////////////////////////////////////////////////////// - // End of checks - /////////////////////////////////////////////////////////////////////////// - - // Close open libraries and return - FreeLibrary( DDHinst ); - - return; -} - -int getDXVersion(){ - DWORD version,platform; - - GetDXVersion( &version,&platform ); - - return (version>>8)&0xff; -} - diff --git a/bbruntime/bbgraphics.cpp b/bbruntime/bbgraphics.cpp deleted file mode 100644 index 469bb39..0000000 --- a/bbruntime/bbgraphics.cpp +++ /dev/null @@ -1,1350 +0,0 @@ - -#include "std.h" -#include "bbgraphics.h" -#include "bbinput.h" - -gxGraphics *gx_graphics; -gxCanvas *gx_canvas; - -struct GfxMode{ - int w,h,d,caps; -}; - -class bbImage{ -public: - bbImage( const vector &f ):frames(f){ - } - ~bbImage(){ - for( int k=0;kfreeCanvas( frames[k] ); - } - } - const vector &getFrames()const{ - return frames; - } - void replaceFrame( int n,gxCanvas *c ){ - gx_graphics->freeCanvas( frames[n] ); - frames[n]=c; - } -private: - vector frames; -}; - -//degrees to radians -static const float dtor=0.0174532925199432957692369076848861f; - -static int gx_driver; //current graphics driver - -static bool filter; -static bool auto_dirty; -static bool auto_midhandle; -static set image_set; -static int curs_x,curs_y; -static gxCanvas *p_canvas; - -static gxFont *curr_font; -static unsigned curr_color; -static unsigned curr_clsColor; - -static vector gfx_modes; - -static inline void debugImage( bbImage *i,int frame=0 ){ - if( debug ){ - if( !image_set.count(i) ) RTEX( "Image does not exist" ); - if( frame>=i->getFrames().size() ) RTEX( "Image frame out of range" ); - } -} - -static inline void debugFont( gxFont *f ){ - if( debug ){ - if( !gx_graphics->verifyFont( f ) ) RTEX( "Font does not exist" ); - } -} - -static inline void debugCanvas( gxCanvas *c ){ - if( debug ){ - if( !gx_graphics->verifyCanvas( c ) ) RTEX( "Buffer does not exist" ); - } -} - -static inline void debugDriver( int n ){ - if( debug ){ - if( n<1 || n>gx_runtime->numGraphicsDrivers() ){ - RTEX( "Illegal graphics driver index" ); - } - } -} - -static inline void debugMode( int n ){ - if( debug ){ - if( n<1 || n>gfx_modes.size() ){ - RTEX( "Illegal graphics mode index" ); - } - } -} - -void bbFreeImage( bbImage *i ); - -static void freeGraphics(){ -#ifdef PRO - extern void blitz3d_close(); - blitz3d_close(); -#endif - while( image_set.size() ) bbFreeImage( *image_set.begin() ); - if( p_canvas ){ - gx_graphics->freeCanvas( p_canvas ); - p_canvas=0; - } -} - -#define RED(_X_) ( ((_X_)>>16) & 0xff ) -#define GRN(_X_) ( ((_X_)>>8) & 0xff ) -#define BLU(_X_) ( (_X_) & 0xff ) - -static int getPixel( gxCanvas *c,float x,float y ){ - debugCanvas( c ); - - x-=.5f;y-=.5f; - float fx=floor(x),fy=floor(y); - int ix=fx,iy=fy;fx=x-fx;fy=y-fy; - - int tl=c->getPixel( ix,iy ); - int tr=c->getPixel( ix+1,iy ); - int br=c->getPixel( ix+1,iy+1 ); - int bl=c->getPixel( ix,iy+1 ); - - float w1=(1-fx)*(1-fy),w2=fx*(1-fy),w3=(1-fx)*fy,w4=fx*fy; - - float r=RED(tl)*w1+RED(tr)*w2+RED(bl)*w3+RED(br)*w4; - float g=GRN(tl)*w1+GRN(tr)*w2+GRN(bl)*w3+GRN(br)*w4; - float b=BLU(tl)*w1+BLU(tr)*w2+BLU(bl)*w3+BLU(br)*w4; - - return (int(r+.5f)<<16)|(int(g+.5f)<<8)|int(b+.5f); -} - -struct vec2{ float x,y; }; - -static vec2 vrot( float m[2][2],const vec2 &v ){ - vec2 t;t.x=m[0][0]*v.x+m[0][1]*v.y;t.y=m[1][0]*v.x+m[1][1]*v.y; - return t; -} - -static float vmin( float a,float b,float c,float d ){ - float t=a;if( bt ) t=b;if( c>t ) t=c;if( d>t ) t=d;return t; -} - -static gxCanvas *tformCanvas( gxCanvas *c,float m[2][2],int x_handle,int y_handle ){ - - vec2 v,v0,v1,v2,v3; - float i[2][2]; - float dt=1.0f/(m[0][0]*m[1][1]-m[1][0]*m[0][1]); - i[0][0]=dt*m[1][1];i[1][0]=-dt*m[1][0]; - i[0][1]=-dt*m[0][1];i[1][1]=dt*m[0][0]; - - float ox=x_handle,oy=y_handle; - v0.x=-ox;v0.y=-oy; //tl - v1.x=c->getWidth()-ox;v1.y=-oy; //tr - v2.x=c->getWidth()-ox;v2.y=c->getHeight()-oy; //br - v3.x=-ox;v3.y=c->getHeight()-oy; //bl - v0=vrot(m,v0);v1=vrot(m,v1);v2=vrot(m,v2);v3=vrot(m,v3); - float minx=floor( vmin( v0.x,v1.x,v2.x,v3.x ) ); - float miny=floor( vmin( v0.y,v1.y,v2.y,v3.y ) ); - float maxx=ceil( vmax( v0.x,v1.x,v2.x,v3.x ) ); - float maxy=ceil( vmax( v0.y,v1.y,v2.y,v3.y ) ); - int iw=maxx-minx,ih=maxy-miny; - - gxCanvas *t=gx_graphics->createCanvas( iw,ih,0 ); - t->setHandle( -minx,-miny ); - t->setMask( c->getMask() ); - - c->lock(); - t->lock(); - - v.y=miny+.5f; - for( int y=0;ygetPixel( floor(q.x+ox),floor(q.y+oy) ); - t->setPixel( x,y,rgb ); - } - } - - t->unlock(); - c->unlock(); - - return t; -} - -static bool saveCanvas( gxCanvas *c,const string &f ){ - - ofstream out( f.c_str(),ios::binary ); - if( !out.good() ) return false; - - int tempsize=(c->getWidth()*3+3)&~3; - - BITMAPFILEHEADER bf; - memset( &bf,0,sizeof(bf) ); - bf.bfType='MB'; - bf.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+tempsize*c->getHeight(); - bf.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); - BITMAPINFOHEADER bi;memset( &bi,0,sizeof(bi) ); - bi.biSize=sizeof(bi); - bi.biWidth=c->getWidth(); - bi.biHeight=c->getHeight(); - bi.biPlanes=1; - bi.biBitCount=24; - out.write( (char*)&bf,sizeof(bf) ); - out.write( (char*)&bi,sizeof(bi) ); - - unsigned char *temp=d_new unsigned char[ tempsize ]; - memset( temp,0,tempsize ); - - c->lock(); - for( int y=c->getHeight()-1;y>=0;--y ){ - unsigned char *dest=temp; - for( int x=0;xgetWidth();++x ){ - unsigned rgb=c->getPixelFast( x,y ); - *dest++=rgb&0xff; - *dest++=(rgb>>8)&0xff; - *dest++=(rgb>>16)&0xff; - } - out.write( (char*)temp,tempsize ); - } - c->unlock(); - - delete [] temp; - - return out.good(); -} - -int bbCountGfxDrivers(){ - return gx_runtime->numGraphicsDrivers(); -} - -BBStr * bbGfxDriverName( int n ){ - debugDriver( n ); - string t;int caps; - gx_runtime->graphicsDriverInfo( n-1,&t,&caps ); - return d_new BBStr( t ); -} - -void bbSetGfxDriver( int n ){ - debugDriver( n ); - gfx_modes.clear(); - gx_driver=n-1; -} - -int bbCountGfxModes(){ - gfx_modes.clear(); - int n=gx_runtime->numGraphicsModes( gx_driver ); - for( int k=0;kgraphicsModeInfo( gx_driver,k,&m.w,&m.h,&m.d,&m.caps ); - gfx_modes.push_back( m ); - } - return gfx_modes.size(); -} - -int bbGfxModeWidth( int n ){ - debugMode( n ); - return gfx_modes[n-1].w; -} - -int bbGfxModeHeight( int n ){ - debugMode( n ); - return gfx_modes[n-1].h; -} - -int bbGfxModeDepth( int n ){ - debugMode( n ); - return gfx_modes[n-1].d; -} - -static int modeExists( int w,int h,int d,bool bb3d ){ - int cnt=gx_runtime->numGraphicsModes( gx_driver ); - for( int k=0;kgraphicsModeInfo( gx_driver,k,&tw,&th,&td,&tc ); - if( bb3d && !(tc&gxRuntime::GFXMODECAPS_3D) ) continue; - if( w==tw && h==th && d==td ) return 1; - } - return 0; -} - -int bbGfxModeExists( int w,int h,int d ){ - return modeExists( w,h,d,false ); -} - -#ifdef PRO -int bbGfxDriver3D( int n ){ - debugDriver( n ); - string t;int caps; - gx_runtime->graphicsDriverInfo( n-1,&t,&caps ); - return (caps & gxRuntime::GFXMODECAPS_3D) ? 1 : 0; -} - -int bbCountGfxModes3D(){ - gfx_modes.clear(); - int n=gx_runtime->numGraphicsModes( gx_driver ); - for( int k=0;kgraphicsModeInfo( gx_driver,k,&m.w,&m.h,&m.d,&m.caps ); - if( m.caps & gxRuntime::GFXMODECAPS_3D) gfx_modes.push_back( m ); - } - return gfx_modes.size(); -} - -int bbGfxMode3DExists( int w,int h,int d ){ - return modeExists( w,h,d,true ); -} - -int bbGfxMode3D( int n ){ - debugMode( n ); - return gfx_modes[n-1].caps & gxRuntime::GFXMODECAPS_3D ? 1 :0; -} - -int bbWindowed3D(){ - int tc; - gx_runtime->windowedModeInfo( &tc ); - return (tc & gxRuntime::GFXMODECAPS_3D) ? 1 : 0; -} -#endif - -int bbTotalVidMem(){ - return gx_graphics->getTotalVidmem(); -} - -int bbAvailVidMem(){ - return gx_graphics->getAvailVidmem(); -} - -void bbSetBuffer( gxCanvas *buff ){ - debugCanvas( buff ); - gx_canvas=buff; - curs_x=curs_y=0; - gx_canvas->setOrigin( 0,0 ); - gx_canvas->setViewport( 0,0,gx_canvas->getWidth(),gx_canvas->getHeight() ); - gx_canvas->setColor( curr_color ); - gx_canvas->setClsColor( curr_clsColor ); - gx_canvas->setFont( curr_font ); -} - -gxCanvas *bbGraphicsBuffer(){ - return gx_canvas; -} - -int bbLoadBuffer( gxCanvas *c,BBStr *str ){ - debugCanvas( c ); - string s=*str;delete str; - gxCanvas *t=gx_graphics->loadCanvas( s,0 ); - if( !t ) return 0; - float m[2][2]; - m[0][0]=(float)c->getWidth()/(float)t->getWidth(); - m[1][1]=(float)c->getHeight()/(float)t->getHeight(); - m[1][0]=m[0][1]=0; - gxCanvas *p=tformCanvas( t,m,0,0 ); - gx_graphics->freeCanvas( t ); - int ox,oy; - c->getOrigin( &ox,&oy );c->setOrigin( 0,0 ); - c->blit( 0,0,p,0,0,p->getWidth(),p->getHeight(),true ); - gx_graphics->freeCanvas( p ); - return 1; -} - -int bbSaveBuffer( gxCanvas *c,BBStr *str ){ - debugCanvas( c ); - string t=*str;delete str; - return saveCanvas( c,t ) ? 1 : 0; -} - -void bbBufferDirty( gxCanvas *c ){ - debugCanvas( c ); - c->backup(); -} - -static void graphics( int w,int h,int d,int flags ){ - freeGraphics(); - gx_runtime->closeGraphics( gx_graphics ); - gx_graphics=gx_runtime->openGraphics( w,h,d,gx_driver,flags ); - if( !gx_runtime->idle() ) RTEX( 0 ); - if( !gx_graphics ){ - RTEX( "Unable to set graphics mode" ); - } - curr_clsColor=0; - curr_color=0xffffffff; - curr_font=gx_graphics->getDefaultFont(); - gxCanvas *buff=(flags & gxGraphics::GRAPHICS_3D) ? - gx_graphics->getBackCanvas() : gx_graphics->getFrontCanvas(); - bbSetBuffer( buff ); -} - -void bbGraphics( int w,int h,int d,int mode ){ - int flags=0; - switch( mode ){ - case 0:flags|=debug ? gxGraphics::GRAPHICS_WINDOWED : 0 ;break; - case 1:break; - case 2:flags|=gxGraphics::GRAPHICS_WINDOWED;break; - case 3:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_SCALED;break; - case 6:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_AUTOSUSPEND;break; - case 7:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_SCALED|gxGraphics::GRAPHICS_AUTOSUSPEND;break; - default:RTEX( "Illegal Graphics mode" ); - } - graphics( w,h,d,flags ); -} - -#ifdef PRO -void bbGraphics3D( int w,int h,int d,int mode ){ - int flags=gxGraphics::GRAPHICS_3D; - switch( mode ){ - case 0:flags|=(debug && bbWindowed3D()) ? gxGraphics::GRAPHICS_WINDOWED : 0 ;break; - case 1:break; - case 2:flags|=gxGraphics::GRAPHICS_WINDOWED;break; - case 3:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_SCALED;break; - case 6:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_AUTOSUSPEND;break; - case 7:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_SCALED|gxGraphics::GRAPHICS_AUTOSUSPEND;break; - default:RTEX( "Illegal Graphics3D mode" ); - } - graphics( w,h,d,flags ); - extern void blitz3d_open(); - blitz3d_open(); -} -#endif - -void bbEndGraphics(){ - freeGraphics(); - gx_runtime->closeGraphics( gx_graphics ); - gx_graphics=gx_runtime->openGraphics( 400,300,0,0,gxGraphics::GRAPHICS_WINDOWED ); - if( !gx_runtime->idle() ) RTEX( 0 ); - if( gx_graphics ){ - curr_clsColor=0; - curr_color=0xffffffff; - curr_font=gx_graphics->getDefaultFont(); - bbSetBuffer( gx_graphics->getFrontCanvas() ); - return; - } - RTEX( "Unable to set graphics mode" ); -} - -int bbGraphicsLost(){ - return gx_runtime->graphicsLost(); -} - -void bbSetGamma( int r,int g,int b,float dr,float dg,float db ){ - if( dr<0 ) dr=0; - else if( dr>255.0f ) dr=255.0f; - if( dg<0 ) dg=0; - else if( dg>255.0f ) dg=255.0f; - if( db<0 ) db=0; - else if( db>255.0f ) db=255.0f; - gx_graphics->setGamma( r,g,b,dr,dg,db ); -} - -void bbUpdateGamma( int calibrate ){ - gx_graphics->updateGamma( !!calibrate ); -} - -float bbGammaRed( int n ){ - float dr,dg,db; - gx_graphics->getGamma( n,n,n,&dr,&dg,&db ); - return dr; -} - -float bbGammaGreen( int n ){ - float dr,dg,db; - gx_graphics->getGamma( n,n,n,&dr,&dg,&db ); - return dg; -} - -float bbGammaBlue( int n ){ - float dr,dg,db; - gx_graphics->getGamma( n,n,n,&dr,&dg,&db ); - return db; -} - -gxCanvas *bbFrontBuffer(){ - return gx_graphics->getFrontCanvas(); -} - -gxCanvas *bbBackBuffer(){ - return gx_graphics->getBackCanvas(); -} - -void bbLockBuffer( gxCanvas *buff ){ - if( buff ) debugCanvas( buff ); - (buff ? buff : gx_canvas)->lock(); -} - -void bbUnlockBuffer( gxCanvas *buff ){ - if( buff ) debugCanvas( buff ); - (buff ? buff : gx_canvas)->unlock(); -} - -int bbReadPixel( int x,int y,gxCanvas *buff ){ - if( buff ) debugCanvas( buff ); - return (buff ? buff : gx_canvas)->getPixel( x,y ); -} - -void bbWritePixel( int x,int y,int argb,gxCanvas *buff ){ - if( buff ) debugCanvas( buff ); - (buff ? buff : gx_canvas)->setPixel( x,y,argb ); -} - -int bbReadPixelFast( int x,int y,gxCanvas *buff ){ - return (buff ? buff : gx_canvas)->getPixelFast( x,y ); -} - -void bbWritePixelFast( int x,int y,int argb,gxCanvas *buff ){ - (buff ? buff : gx_canvas)->setPixelFast( x,y,argb ); -} - -void bbCopyPixel( int src_x,int src_y,gxCanvas *src,int dest_x,int dest_y,gxCanvas *buff ){ - (buff ? buff : gx_canvas)->copyPixel( dest_x,dest_y,src ? src : gx_canvas,src_x,src_y ); -} - -void bbCopyPixelFast( int src_x,int src_y,gxCanvas *src,int dest_x,int dest_y,gxCanvas *buff ){ - (buff ? buff : gx_canvas)->copyPixelFast( dest_x,dest_y,src ? src : gx_canvas,src_x,src_y ); -} - -int bbScanLine(){ - return gx_graphics->getScanLine(); -} - -void bbVWait( int n ){ - gx_graphics->vwait(); - if( !gx_runtime->idle() ) RTEX( 0 ); -} - -void bbFlip( int vwait ){ - gx_graphics->flip( vwait ? true : false ); - if( !gx_runtime->idle() ) RTEX( 0 ); -} - -int bbGraphicsWidth(){ - return gx_graphics->getWidth(); -} - -int bbGraphicsHeight(){ - return gx_graphics->getHeight(); -} - -int bbGraphicsDepth(){ - return gx_graphics->getDepth(); -} - -void bbOrigin( int x,int y ){ - gx_canvas->setOrigin( x,y ); -} - -void bbViewport( int x,int y,int w,int h ){ - gx_canvas->setViewport( x,y,w,h ); -} - -void bbColor( int r,int g,int b ){ - gx_canvas->setColor( curr_color=(r<<16)|(g<<8)|b ); -} - -void bbGetColor( int x,int y ){ - gx_canvas->setColor( curr_color=gx_canvas->getPixel( x,y ) ); -} - -int bbColorRed(){ - return (gx_canvas->getColor()>>16)&0xff; -} - -int bbColorGreen(){ - return (gx_canvas->getColor()>>8)&0xff; -} - -int bbColorBlue(){ - return gx_canvas->getColor()&0xff; -} - -void bbClsColor( int r,int g,int b ){ - gx_canvas->setClsColor( curr_clsColor=(r<<16)|(g<<8)|b ); -} - -void bbSetFont( gxFont *f ){ - debugFont( f ); - gx_canvas->setFont( curr_font=f ); -} - -void bbCls(){ - gx_canvas->cls(); -} - -void bbPlot( int x,int y ){ - gx_canvas->plot( x,y ); -} - -void bbLine( int x1,int y1,int x2,int y2 ){ - gx_canvas->line( x1,y1,x2,y2 ); -} - -void bbRect( int x,int y,int w,int h,int solid ){ - gx_canvas->rect( x,y,w,h,solid ? true : false ); -} - -void bbOval( int x,int y,int w,int h,int solid ){ - gx_canvas->oval( x,y,w,h,solid ? true : false ); -} - -void bbText( int x,int y,BBStr *str,int centre_x,int centre_y ){ - if( centre_x ) x-=curr_font->getWidth( *str )/2; - if( centre_y ) y-=curr_font->getHeight()/2; - gx_canvas->text( x,y,*str ); - delete str; -} - -void bbCopyRect( int sx,int sy,int w,int h,int dx,int dy,gxCanvas *src,gxCanvas *dest ){ - if( src ) debugCanvas( src ); - else src=gx_canvas; - if( dest ) debugCanvas( dest ); - else dest=gx_canvas; - dest->blit( dx,dy,src,sx,sy,w,h,true ); -} - -gxFont *bbLoadFont( BBStr *name,int height,int bold,int italic,int underline ){ - int flags= - (bold ? gxFont::FONT_BOLD : 0 ) | - (italic ? gxFont::FONT_ITALIC : 0 ) | - (underline ? gxFont::FONT_UNDERLINE : 0 ); - gxFont *font=gx_graphics->loadFont( *name,height,flags ); - delete name; - return font; -} - -void bbFreeFont( gxFont *f ){ - debugFont( f ); - if( f==curr_font ) bbSetFont( gx_graphics->getDefaultFont() ); - gx_graphics->freeFont( f ); -} - -int bbFontWidth(){ - return curr_font->getWidth(); -} - -int bbFontHeight(){ - return curr_font->getHeight(); -} - -int bbStringWidth( BBStr *str ){ - string t=*str;delete str; - return curr_font->getWidth( t ); -} - -int bbStringHeight( BBStr *str ){ - delete str; - return curr_font->getHeight(); -} - -gxMovie *bbOpenMovie( BBStr *s ){ - gxMovie *movie=gx_graphics->openMovie( *s,0 );delete s; - return movie; -} - -int bbDrawMovie( gxMovie *movie,int x,int y,int w,int h ){ - if( w<0 ) w=movie->getWidth(); - if( h<0 ) h=movie->getHeight(); - int playing=movie->draw( gx_canvas,x,y,w,h ); - if( !gx_runtime->idle() ) RTEX( 0 ); - return playing; -} - -int bbMovieWidth( gxMovie *movie ){ - return movie->getWidth(); -} - -int bbMovieHeight( gxMovie *movie ){ - return movie->getHeight(); -} - -int bbMoviePlaying( gxMovie *movie ){ - return movie->isPlaying(); -} - -void bbCloseMovie( gxMovie *movie ){ - gx_graphics->closeMovie( movie ); -} - -bbImage *bbLoadImage( BBStr *s ){ - string t=*s;delete s; - gxCanvas *c=gx_graphics->loadCanvas( t,0 ); - if( !c ) return 0; - if( auto_dirty ) c->backup(); - if( auto_midhandle ) c->setHandle( c->getWidth()/2,c->getHeight()/2 ); - vector frames; - frames.push_back( c ); - bbImage *i=d_new bbImage( frames ); - image_set.insert( i ); - return i; -} - -bbImage *bbLoadAnimImage( BBStr *s,int w,int h,int first,int cnt ){ - - string t=*s;delete s; - - if( cnt<1 ) RTEX( "Illegal frame count" ); - if( first<0 ) RTEX( "Illegal first frame" ); - - gxCanvas *pic=gx_graphics->loadCanvas( t,gxCanvas::CANVAS_NONDISPLAY ); - if( !pic ) return 0; - - //frames per row, per picture - int fpr=pic->getWidth()/w; - int fpp=pic->getHeight()/h*fpr; - if( first+cnt>fpp ){ - gx_graphics->freeCanvas( pic ); - RTEX( "Not enough frames in bitmap" ); - } - - //x,y of first frame... - vector frames; - int src_x=first%fpr*w,src_y=first/fpr*h; - - for( int k=0;kcreateCanvas( w,h,0 ); - if( !c ){ - for( --k;k>=0;--k ) gx_graphics->freeCanvas( frames[k] ); - gx_graphics->freeCanvas( pic );return 0; - } - c->blit( 0,0,pic,src_x,src_y,w,h,true ); - if( auto_dirty ) c->backup(); - if( auto_midhandle ) c->setHandle( c->getWidth()/2,c->getHeight()/2 ); - frames.push_back( c ); - src_x+=w;if( src_x+w>pic->getWidth() ){ src_x=0;src_y+=h; } - } - gx_graphics->freeCanvas( pic ); - bbImage *i=d_new bbImage( frames ); - image_set.insert( i ); - return i; -} - -bbImage *bbCopyImage( bbImage *i ){ - debugImage( i ); - vector frames; - const vector &f=i->getFrames(); - for( int k=0;kcreateCanvas( t->getWidth(),t->getHeight(),0 ); - if( !c ){ - for( --k;k>=0;--k ) gx_graphics->freeCanvas( frames[k] ); - return 0; - } - int x,y; - t->getHandle( &x,&y ); - t->setHandle( 0,0 ); - c->blit( 0,0,t,0,0,t->getWidth(),t->getHeight(),true ); - if( auto_dirty ) c->backup(); - t->setHandle( x,y ); - c->setHandle( x,y ); - c->setMask( t->getMask() ); - frames.push_back( c ); - } - bbImage *t=d_new bbImage( frames ); - image_set.insert( t ); - return t; -} - -bbImage *bbCreateImage( int w,int h,int n ){ - vector frames; - for( int k=0;kcreateCanvas( w,h,0 ); - if( !c ){ - for( --k;k>=0;--k ) gx_graphics->freeCanvas( frames[k] ); - return 0; - } - if( auto_dirty ) c->backup(); - if( auto_midhandle ) c->setHandle( c->getWidth()/2,c->getHeight()/2 ); - frames.push_back( c ); - } - bbImage *i=d_new bbImage( frames ); - image_set.insert( i ); - return i; -} - -void bbFreeImage( bbImage *i ){ - if( !image_set.erase(i) ) return; - const vector &f=i->getFrames(); - for( int k=0;kgetFrontCanvas() ); - break; - } - } - delete i; -} - -int bbSaveImage( bbImage *i,BBStr *str,int n ){ - debugImage( i,n ); - string t=*str;delete str; - gxCanvas *c=i->getFrames()[n]; - return saveCanvas( c,t ) ? 1 : 0; -} - -void bbGrabImage( bbImage *i,int x,int y,int n ){ - debugImage( i,n ); - gxCanvas *c=i->getFrames()[n]; - int src_ox,src_oy,dst_hx,dst_hy; - gx_canvas->getOrigin( &src_ox,&src_oy ); - c->getHandle( &dst_hx,&dst_hy ); - x+=src_ox-dst_hx;y+=src_oy-dst_hy; - c->setViewport( 0,0,c->getWidth(),c->getHeight() ); - c->blit( 0,0,gx_canvas,x,y,c->getWidth(),c->getHeight(),true ); - if( auto_dirty ) c->backup(); -} - -gxCanvas *bbImageBuffer( bbImage *i,int n ){ - debugImage( i,n ); - return i->getFrames()[n]; -} - -void bbDrawImage( bbImage *i,int x,int y,int frame ){ - debugImage( i,frame ); - gxCanvas *c=i->getFrames()[frame]; - gx_canvas->blit( x,y,c,0,0,c->getWidth(),c->getHeight(),false ); -} - -void bbDrawBlock( bbImage *i,int x,int y,int frame ){ - debugImage( i,frame ); - gxCanvas *c=i->getFrames()[frame]; - gx_canvas->blit( x,y,c,0,0,c->getWidth(),c->getHeight(),true ); -} - -static void tile( bbImage *i,int x,int y,int frame,bool solid ){ - gxCanvas *c=i->getFrames()[frame]; - - int hx,hy; - c->getHandle( &hx,&hy ); - int w=c->getWidth(),h=c->getHeight(); - - int ox,oy,vp_x,vp_y,vp_w,vp_h; - gx_canvas->getOrigin( &ox,&oy ); - gx_canvas->getViewport( &vp_x,&vp_y,&vp_w,&vp_h ); - int dx=vp_x-ox+hx; - int dy=vp_y-oy+hy; - x-=dx; - y-=dy; - dx+=(x>=0?x%w:w-(-x%w)); - dy+=(y>=0?y%h:h-(-y%h)); - - for( y=-h;yblit( x+dx,y+dy,c,0,0,w,h,solid ); - } - } -} - -void bbTileImage( bbImage *i,int x,int y,int frame ){ - debugImage( i,frame ); - tile( i,x,y,frame,false ); -} - -void bbTileBlock( bbImage *i,int x,int y,int frame ){ - debugImage( i,frame ); - tile( i,x,y,frame,true ); -} - -void bbDrawImageRect( bbImage *i,int x,int y,int r_x,int r_y,int r_w,int r_h,int frame ){ - debugImage( i,frame ); - gxCanvas *c=i->getFrames()[frame]; - gx_canvas->blit( x,y,c,r_x,r_y,r_w,r_h,false ); -} - -void bbDrawBlockRect( bbImage *i,int x,int y,int r_x,int r_y,int r_w,int r_h,int frame ){ - debugImage( i,frame ); - gxCanvas *c=i->getFrames()[frame]; - gx_canvas->blit( x,y,c,r_x,r_y,r_w,r_h,true ); -} - -void bbMaskImage( bbImage *i,int r,int g,int b ){ - debugImage( i ); - unsigned argb=(r<<16)|(g<<8)|b; - const vector &f=i->getFrames(); - for( int k=0;ksetMask( argb ); -} - -void bbHandleImage( bbImage *i,int x,int y ){ - debugImage( i ); - const vector &f=i->getFrames(); - for( int k=0;ksetHandle( x,y ); -} - -void bbMidHandle( bbImage *i ){ - debugImage( i ); - const vector &f=i->getFrames(); - for( int k=0;ksetHandle( f[k]->getWidth()/2,f[k]->getHeight()/2 ); -} - -void bbAutoMidHandle( int enable ){ - auto_midhandle=enable ? true : false; -} - -int bbImageWidth( bbImage *i ){ - debugImage( i ); - return i->getFrames()[0]->getWidth(); -} - -int bbImageHeight( bbImage *i ){ - debugImage( i ); - return i->getFrames()[0]->getHeight(); -} - -int bbImageXHandle( bbImage *i ){ - debugImage( i ); - int x,y; - i->getFrames()[0]->getHandle( &x,&y ); - return x; -} - -int bbImageYHandle( bbImage *i ){ - debugImage( i ); - int x,y; - i->getFrames()[0]->getHandle( &x,&y ); - return y; -} - -int bbImagesOverlap( bbImage *i1,int x1,int y1,bbImage *i2,int x2,int y2 ){ - debugImage( i1 ); - debugImage( i2 ); - gxCanvas *c1=i1->getFrames()[0]; - gxCanvas *c2=i2->getFrames()[0]; - return c1->collide( x1,y1,c2,x2,y2,true ); -} - -int bbImagesCollide( bbImage *i1,int x1,int y1,int f1,bbImage *i2,int x2,int y2,int f2 ){ - debugImage( i1,f1 ); - debugImage( i2,f2 ); - gxCanvas *c1=i1->getFrames()[f1]; - gxCanvas *c2=i2->getFrames()[f2]; - return c1->collide( x1,y1,c2,x2,y2,false ); -} - -int bbRectsOverlap( int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2 ){ - if( x1+w1<=x2 || x1>=x2+w2 || y1+h1<=y2 || y1>=y2+h2 ) return 0; - return 1; -} - -int bbImageRectOverlap( bbImage *i,int x,int y,int x2,int y2,int w2,int h2 ){ - debugImage( i ); - gxCanvas *c=i->getFrames()[0]; - return c->rect_collide( x,y,x2,y2,w2,h2,true ); -} - -int bbImageRectCollide( bbImage *i,int x,int y,int f,int x2,int y2,int w2,int h2 ){ - debugImage( i,f ); - gxCanvas *c=i->getFrames()[f]; - return c->rect_collide( x,y,x2,y2,w2,h2,false ); -} - -void bbTFormImage( bbImage *i,float a,float b,float c,float d ){ - debugImage( i ); - const vector &f=i->getFrames(); - int k; - for( k=0;kgetFrontCanvas() ); - break; - } - } - float m[2][2]; - m[0][0]=a;m[1][0]=b;m[0][1]=c;m[1][1]=d; - for( k=0;kgetHandle( &hx,&hy ); - gxCanvas *t=tformCanvas( c,m,hx,hy ); - i->replaceFrame( k,t ); - t->backup(); - } -} - -void bbScaleImage( bbImage *i,float w,float h ){ - debugImage( i ); - bbTFormImage( i,w,0,0,h ); -} - -void bbResizeImage( bbImage *i,float w,float h ){ - debugImage( i ); - gxCanvas *c=i->getFrames()[0]; - bbTFormImage( i,w/(float)c->getWidth(),0,0,h/(float)c->getHeight() ); -} - -void bbRotateImage( bbImage *i,float d ){ - debugImage( i ); - d*=-dtor; - bbTFormImage( i,cos(d),-sin(d),sin(d),cos(d) ); -} - -void bbTFormFilter( int enable ){ - filter=enable ? true : false; -} - -static int p_ox,p_oy,p_hx,p_hy,p_vpx,p_vpy,p_vpw,p_vph; - -static gxCanvas *startPrinting(){ - - gxCanvas *c=gx_graphics->getFrontCanvas(); - - c->lock(); - c->unlock(); - - c->getOrigin( &p_ox,&p_oy ); - c->getHandle( &p_hx,&p_hy ); - c->getViewport( &p_vpx,&p_vpy,&p_vpw,&p_vph ); - - c->setOrigin( 0,0 ); - c->setHandle( 0,0 ); - c->setViewport( 0,0,c->getWidth(),c->getHeight() ); - if( c!=gx_canvas ){ - c->setFont( curr_font ); - c->setColor( curr_color ); - } - - int dy=curs_y+curr_font->getHeight()-c->getHeight(); - if( dy>0 ){ - curs_y=c->getHeight()-curr_font->getHeight(); - c->blit( 0,0,c,0,dy,c->getWidth(),c->getHeight()-dy,true ); - c->setColor( curr_clsColor ); - c->rect( 0,c->getHeight()-dy,c->getWidth(),dy,true ); - c->setColor( curr_color ); - } - return c; -} - -static void endPrinting( gxCanvas *c ){ - c->setViewport( p_vpx,p_vpy,p_vpw,p_vph ); - c->setHandle( p_hx,p_hy ); - c->setOrigin( p_ox,p_oy ); - if( c==gx_canvas ) c->setColor( curr_color ); - if( !gx_runtime->idle() ) RTEX( 0 ); -} - -void bbWrite( BBStr *str ){ - gxCanvas *c=startPrinting(); - c->text( curs_x,curs_y,*str ); - curs_x+=curr_font->getWidth( *str ); - endPrinting( c ); - delete str; -} - -void bbPrint( BBStr *str ){ - gxCanvas *c=startPrinting(); - c->text( curs_x,curs_y,*str ); - curs_x=0; - curs_y+=curr_font->getHeight(); - endPrinting( c ); - delete str; -} - -BBStr *bbInput( BBStr *prompt ){ - gxCanvas *c=startPrinting(); - string t=*prompt;delete prompt; - - //get temp canvas - if( !p_canvas || p_canvas->getWidth()getWidth() || p_canvas->getHeight()getHeight()*2 ){ - if( p_canvas ) gx_graphics->freeCanvas( p_canvas ); - p_canvas=gx_graphics->createCanvas( c->getWidth(),curr_font->getHeight()*2,0 ); - if( !p_canvas ){ - endPrinting(c); - return d_new BBStr(); - } - } - //draw prompt - c->text( curs_x,curs_y,t ); - curs_x+=curr_font->getWidth( t ); - - p_canvas->setFont( curr_font ); - p_canvas->setColor( curr_color ); - p_canvas->blit( 0,0,c,0,curs_y,c->getWidth(),curr_font->getHeight(),true ); - - string str; - bool go=true; - int curs=0,last_key=0,last_time,rep_delay; - - while( go ){ - - //render all text - //calc curs x and width - int cx=curs_x+curr_font->getWidth( str.substr( 0,curs ) ); - int cw=curr_font->getWidth( cursgetMilliSecs(),tc=-1; - - while( gx_runtime->idle() ){ - int t=gx_runtime->getMilliSecs(); - int n=(t-st)/320; - if( n!=tc ){ - tc=n; - if( !(tc&1) ){ //cursor ON - c->setColor( curr_clsColor^0xffffff ); - c->rect( cx,curs_y,cw,curr_font->getHeight(),true ); - c->setColor( curr_clsColor ); - }else{ //cursor OFF - c->blit( cx,curs_y,p_canvas,cx,0,cw,curr_font->getHeight(),true ); - c->setColor( curr_color ); - } - c->text( cx,curs_y,str.substr( curs,1 ) ); - } - if( key=gx_keyboard->getKey() ){ - if( int asc=gx_input->toAscii( key ) ){ - rep_delay=280; - last_key=key; - last_time=t; - key=asc; - break; - } - } - if( last_key && gx_keyboard->keyDown( last_key ) ){ - if( t-last_time>rep_delay ){ - if( key=gx_input->toAscii( last_key ) ){ - last_time+=rep_delay; - rep_delay=40; - break; - } - } - }else last_key=0; - gx_runtime->delay( 20 ); - } - - //check the key - switch( key ){ - case 0: - go=false; - str=""; - break; - case 8: - if( curs ){ - str=str.substr( 0,curs-1 )+str.substr( curs ); - --curs; - } - break; - case 27: - curs=0;str=""; - break; - case gxInput::ASC_DELETE: - if( cursisPrintable( key ) ){ - str=str.substr(0,curs)+char(key)+str.substr(curs); - ++curs; - } - } - - //render text - p_canvas->blit( 0,curr_font->getHeight(),p_canvas,0,0,c->getWidth(),curr_font->getHeight(),true ); - p_canvas->text( curs_x,curr_font->getHeight(),str ); - c->blit( 0,curs_y,p_canvas,0,curr_font->getHeight(),c->getWidth(),curr_font->getHeight(),true ); - } - - curs_x=0; - curs_y+=curr_font->getHeight(); - endPrinting( c ); - return d_new BBStr( str ); -} - -void bbLocate( int x,int y ){ - gxCanvas *c=gx_graphics->getFrontCanvas(); - curs_x=x<0 ? 0 : (x > c->getWidth() ? c->getWidth() : x); - curs_y=y<0 ? 0 : (y > c->getHeight() ? c->getHeight() : y); -} - -void bbShowPointer(){ - gx_runtime->setPointerVisible( true ); -} - -void bbHidePointer(){ - gx_runtime->setPointerVisible( false ); -} - -bool graphics_create(){ - p_canvas=0; - filter=true; - gx_driver=0; - freeGraphics(); - auto_dirty=true; - auto_midhandle=false; - gx_graphics=gx_runtime->openGraphics( 400,300,0,0,gxGraphics::GRAPHICS_WINDOWED ); - if( gx_graphics ){ - curr_clsColor=0; - curr_color=0xffffffff; - curr_font=gx_graphics->getDefaultFont(); - bbSetBuffer( bbFrontBuffer() ); - return true; - } - return false; -} - -bool graphics_destroy(){ - freeGraphics(); - gfx_modes.clear(); - if( gx_graphics ){ - gx_runtime->closeGraphics( gx_graphics ); - gx_graphics=0; - } - return true; -} - -void graphics_link( void (*rtSym)( const char *sym,void *pc ) ){ - - //gfx driver info - rtSym( "%CountGfxDrivers",bbCountGfxDrivers ); - rtSym( "$GfxDriverName%driver",bbGfxDriverName ); - rtSym( "SetGfxDriver%driver",bbSetGfxDriver ); - - //gfx mode info - rtSym( "%CountGfxModes",bbCountGfxModes ); - rtSym( "%GfxModeExists%width%height%depth",bbGfxModeExists ); - - rtSym( "%GfxModeWidth%mode",bbGfxModeWidth ); - rtSym( "%GfxModeHeight%mode",bbGfxModeHeight ); - rtSym( "%GfxModeDepth%mode",bbGfxModeDepth ); - rtSym( "%AvailVidMem",bbAvailVidMem ); - rtSym( "%TotalVidMem",bbTotalVidMem ); - -#ifdef PRO - rtSym( "%GfxDriver3D%driver",bbGfxDriver3D ); - rtSym( "%CountGfxModes3D",bbCountGfxModes3D ); - rtSym( "%GfxMode3DExists%width%height%depth",bbGfxMode3DExists ); - rtSym( "%GfxMode3D%mode",bbGfxMode3D ); - rtSym( "%Windowed3D",bbWindowed3D ); -#endif - - //display mode - rtSym( "Graphics%width%height%depth=0%mode=0",bbGraphics ); -#ifdef PRO - rtSym( "Graphics3D%width%height%depth=0%mode=0",bbGraphics3D ); -#endif - rtSym( "EndGraphics",bbEndGraphics ); - rtSym( "%GraphicsLost",bbGraphicsLost ); - - rtSym( "SetGamma%src_red%src_green%src_blue#dest_red#dest_green#dest_blue",bbSetGamma ); - rtSym( "UpdateGamma%calibrate=0",bbUpdateGamma ); - rtSym( "#GammaRed%red",bbGammaRed ); - rtSym( "#GammaGreen%green",bbGammaGreen ); - rtSym( "#GammaBlue%blue",bbGammaBlue ); - - rtSym( "%FrontBuffer",bbFrontBuffer ); - rtSym( "%BackBuffer",bbBackBuffer ); - rtSym( "%ScanLine",bbScanLine ); - rtSym( "VWait%frames=1",bbVWait ); - rtSym( "Flip%vwait=1",bbFlip ); - rtSym( "%GraphicsWidth",bbGraphicsWidth ); - rtSym( "%GraphicsHeight",bbGraphicsHeight ); - rtSym( "%GraphicsDepth",bbGraphicsDepth ); - - //buffer management - rtSym( "SetBuffer%buffer",bbSetBuffer ); - rtSym( "%GraphicsBuffer",bbGraphicsBuffer ); - rtSym( "%LoadBuffer%buffer$bmpfile",bbLoadBuffer ); - rtSym( "%SaveBuffer%buffer$bmpfile",bbSaveBuffer ); - rtSym( "BufferDirty%buffer",bbBufferDirty ); - - //fast pixel reads/write - rtSym( "LockBuffer%buffer=0",bbLockBuffer ); - rtSym( "UnlockBuffer%buffer=0",bbUnlockBuffer ); - rtSym( "%ReadPixel%x%y%buffer=0",bbReadPixel ); - rtSym( "WritePixel%x%y%argb%buffer=0",bbWritePixel ); - rtSym( "%ReadPixelFast%x%y%buffer=0",bbReadPixelFast ); - rtSym( "WritePixelFast%x%y%argb%buffer=0",bbWritePixelFast ); - rtSym( "CopyPixel%src_x%src_y%src_buffer%dest_x%dest_y%dest_buffer=0",bbCopyPixel ); - rtSym( "CopyPixelFast%src_x%src_y%src_buffer%dest_x%dest_y%dest_buffer=0",bbCopyPixelFast ); - - //rendering - rtSym( "Origin%x%y",bbOrigin ); - rtSym( "Viewport%x%y%width%height",bbViewport ); - rtSym( "Color%red%green%blue",bbColor ); - rtSym( "GetColor%x%y",bbGetColor ); - rtSym( "%ColorRed",bbColorRed ); - rtSym( "%ColorGreen",bbColorGreen ); - rtSym( "%ColorBlue",bbColorBlue ); - rtSym( "ClsColor%red%green%blue",bbClsColor ); - rtSym( "SetFont%font",bbSetFont ); - rtSym( "Cls",bbCls ); - rtSym( "Plot%x%y",bbPlot ); - rtSym( "Rect%x%y%width%height%solid=1",bbRect ); - rtSym( "Oval%x%y%width%height%solid=1",bbOval ); - rtSym( "Line%x1%y1%x2%y2",bbLine ); - rtSym( "Text%x%y$text%centre_x=0%centre_y=0",bbText ); - rtSym( "CopyRect%source_x%source_y%width%height%dest_x%dest_y%src_buffer=0%dest_buffer=0",bbCopyRect ); - - //fonts - rtSym( "%LoadFont$fontname%height=12%bold=0%italic=0%underline=0",bbLoadFont ); - rtSym( "FreeFont%font",bbFreeFont ); - rtSym( "%FontWidth",bbFontWidth ); - rtSym( "%FontHeight",bbFontHeight ); - rtSym( "%StringWidth$string",bbStringWidth ); - rtSym( "%StringHeight$string",bbStringHeight ); - - //movies - rtSym( "%OpenMovie$file",bbOpenMovie ); - rtSym( "%DrawMovie%movie%x=0%y=0%w=-1%h=-1",bbDrawMovie ); - rtSym( "%MovieWidth%movie",bbMovieWidth ); - rtSym( "%MovieHeight%movie",bbMovieHeight ); - rtSym( "%MoviePlaying%movie",bbMoviePlaying ); - rtSym( "CloseMovie%movie",bbCloseMovie ); - - rtSym( "%LoadImage$bmpfile",bbLoadImage ); - rtSym( "%LoadAnimImage$bmpfile%cellwidth%cellheight%first%count",bbLoadAnimImage ); - rtSym( "%CopyImage%image",bbCopyImage ); - rtSym( "%CreateImage%width%height%frames=1",bbCreateImage ); - rtSym( "FreeImage%image",bbFreeImage ); - rtSym( "%SaveImage%image$bmpfile%frame=0",bbSaveImage ); - - rtSym( "GrabImage%image%x%y%frame=0",bbGrabImage ); - rtSym( "%ImageBuffer%image%frame=0",bbImageBuffer ); - rtSym( "DrawImage%image%x%y%frame=0",bbDrawImage ); - rtSym( "DrawBlock%image%x%y%frame=0",bbDrawBlock ); - rtSym( "TileImage%image%x=0%y=0%frame=0",bbTileImage ); - rtSym( "TileBlock%image%x=0%y=0%frame=0",bbTileBlock ); - rtSym( "DrawImageRect%image%x%y%rect_x%rect_y%rect_width%rect_height%frame=0",bbDrawImageRect ); - rtSym( "DrawBlockRect%image%x%y%rect_x%rect_y%rect_width%rect_height%frame=0",bbDrawBlockRect ); - rtSym( "MaskImage%image%red%green%blue",bbMaskImage ); - rtSym( "HandleImage%image%x%y",bbHandleImage ); - rtSym( "MidHandle%image",bbMidHandle ); - rtSym( "AutoMidHandle%enable",bbAutoMidHandle ); - rtSym( "%ImageWidth%image",bbImageWidth ); - rtSym( "%ImageHeight%image",bbImageHeight ); - rtSym( "%ImageXHandle%image",bbImageXHandle ); - rtSym( "%ImageYHandle%image",bbImageYHandle ); - - rtSym( "ScaleImage%image#xscale#yscale",bbScaleImage ); - rtSym( "ResizeImage%image#width#height",bbResizeImage ); - rtSym( "RotateImage%image#angle",bbRotateImage ); - rtSym( "TFormImage%image#a#b#c#d",bbTFormImage ); - rtSym( "TFormFilter%enable",bbTFormFilter ); - - rtSym( "%ImagesOverlap%image1%x1%y1%image2%x2%y2",bbImagesOverlap ); - rtSym( "%ImagesCollide%image1%x1%y1%frame1%image2%x2%y2%frame2",bbImagesCollide ); - rtSym( "%RectsOverlap%x1%y1%width1%height1%x2%y2%width2%height2",bbRectsOverlap ); - rtSym( "%ImageRectOverlap%image%x%y%rect_x%rect_y%rect_width%rect_height",bbImageRectOverlap ); - rtSym( "%ImageRectCollide%image%x%y%frame%rect_x%rect_y%rect_width%rect_height",bbImageRectCollide ); - - rtSym( "Write$string",bbWrite ); - rtSym( "Print$string=\"\"",bbPrint ); - rtSym( "$Input$prompt=\"\"",bbInput ); - rtSym( "Locate%x%y",bbLocate ); - - rtSym( "ShowPointer",bbShowPointer ); - rtSym( "HidePointer",bbHidePointer ); -} diff --git a/bbruntime/bbruntime.cpp b/bbruntime/bbruntime.cpp deleted file mode 100644 index 0bc991a..0000000 --- a/bbruntime/bbruntime.cpp +++ /dev/null @@ -1,266 +0,0 @@ - -#include "std.h" -#include "bbsys.h" -#include "bbruntime.h" - -void bbEnd(){ - RTEX( 0 ); -} -void bbStop(){ - gx_runtime->debugStop(); - if( !gx_runtime->idle() ) RTEX( 0 ); -} - -void bbAppTitle( BBStr *ti,BBStr *cp ){ - gx_runtime->setTitle( *ti,*cp ); - delete ti;delete cp; -} - -void bbRuntimeError( BBStr *str ){ - string t=*str;delete str; - if( t.size()>255 ) t[255]=0; - static char err[256]; - strcpy( err,t.c_str() ); - RTEX( err ); -} - -int bbExecFile( BBStr *f ){ - string t=*f;delete f; - int n=gx_runtime->execute( t ); - if( !gx_runtime->idle() ) RTEX( 0 ); - return n; -} - -void bbDelay( int ms ){ - if( !gx_runtime->delay( ms ) ) RTEX( 0 ); -} - -int bbMilliSecs(){ - return gx_runtime->getMilliSecs(); -} - -BBStr * bbCommandLine(){ - return d_new BBStr( gx_runtime->commandLine() ); -} - -BBStr * bbSystemProperty( BBStr *p ){ - string t=gx_runtime->systemProperty( *p ); - delete p;return d_new BBStr( t ); -} - -BBStr * bbGetEnv( BBStr *env_var ){ - char *p=getenv( env_var->c_str() ); - BBStr *val=d_new BBStr( p ? p : "" ); - delete env_var; - return val; -} - -void bbSetEnv( BBStr *env_var,BBStr *val ){ - string t=*env_var+"="+*val; - putenv( t.c_str() ); - delete env_var; - delete val; -} - -gxTimer * bbCreateTimer( int hertz ){ - gxTimer *t=gx_runtime->createTimer( hertz ); - return t; -} - -int bbWaitTimer( gxTimer *t ){ - int n=t->wait(); - if( !gx_runtime->idle() ) RTEX( 0 ); - return n; -} - -void bbFreeTimer( gxTimer *t ){ - gx_runtime->freeTimer( t ); -} - -void bbDebugLog( BBStr *t ){ - gx_runtime->debugLog( t->c_str() ); - delete t; -} - -void _bbDebugStmt( int pos,const char *file ){ - gx_runtime->debugStmt( pos,file ); - if( !gx_runtime->idle() ) RTEX( 0 ); -} - -void _bbDebugEnter( void *frame,void *env,const char *func ){ - gx_runtime->debugEnter( frame,env,func ); -} - -void _bbDebugLeave(){ - gx_runtime->debugLeave(); -} - -bool basic_create(); -bool basic_destroy(); -void basic_link( void (*rtSym)( const char *sym,void *pc ) ); -bool math_create(); -bool math_destroy(); -void math_link( void (*rtSym)( const char *sym,void *pc ) ); -bool string_create(); -bool string_destroy(); -void string_link( void (*rtSym)( const char *sym,void *pc ) ); -bool stream_create(); -bool stream_destroy(); -void stream_link( void (*rtSym)( const char *sym,void *pc ) ); -bool sockets_create(); -bool sockets_destroy(); -void sockets_link( void (*rtSym)( const char *sym,void *pc ) ); -bool filesystem_create(); -bool filesystem_destroy(); -void filesystem_link( void (*rtSym)( const char *sym,void *pc ) ); -bool bank_create(); -bool bank_destroy(); -void bank_link( void (*rtSym)( const char *sym,void *pc ) ); -bool graphics_create(); -bool graphics_destroy(); -void graphics_link( void (*rtSym)( const char *sym,void *pc ) ); -bool input_create(); -bool input_destroy(); -void input_link( void (*rtSym)( const char *sym,void *pc ) ); -bool audio_create(); -bool audio_destroy(); -void audio_link( void (*rtSym)( const char *sym,void *pc ) ); -bool multiplay_create(); -bool multiplay_destroy(); -void multiplay_link( void (*rtSym)( const char *sym,void *pc ) ); -bool userlibs_create(); -void userlibs_destroy(); -void userlibs_link( void (*rtSym)( const char *sym,void *pc ) ); -#ifdef PRO -bool blitz3d_create(); -bool blitz3d_destroy(); -void blitz3d_link( void (*rtSym)( const char *sym,void *pc ) ); -#else -bool blitz3d_create(){ return true; } -bool blitz3d_destroy(){ return true; } -void blitz3d_link( void (*rtSym)( const char *sym,void *pc ) ){} -#endif - -void bbruntime_link( void (*rtSym)( const char *sym,void *pc ) ){ - - rtSym( "End",bbEnd ); - rtSym( "Stop",bbStop ); - rtSym( "AppTitle$title$close_prompt=\"\"",bbAppTitle ); - rtSym( "RuntimeError$message",bbRuntimeError ); - rtSym( "ExecFile$command",bbExecFile ); - rtSym( "Delay%millisecs",bbDelay ); - rtSym( "%MilliSecs",bbMilliSecs ); - rtSym( "$CommandLine",bbCommandLine ); - rtSym( "$SystemProperty$property",bbSystemProperty ); - rtSym( "$GetEnv$env_var",bbGetEnv ); - rtSym( "SetEnv$env_var$value",bbSetEnv ); - - rtSym( "%CreateTimer%hertz",bbCreateTimer ); - rtSym( "%WaitTimer%timer",bbWaitTimer ); - rtSym( "FreeTimer%timer",bbFreeTimer ); - rtSym( "DebugLog$text",bbDebugLog ); - - rtSym( "_bbDebugStmt",_bbDebugStmt ); - rtSym( "_bbDebugEnter",_bbDebugEnter ); - rtSym( "_bbDebugLeave",_bbDebugLeave ); - - basic_link( rtSym ); - math_link( rtSym ); - string_link( rtSym ); - stream_link( rtSym ); - sockets_link( rtSym ); - filesystem_link( rtSym ); - bank_link( rtSym ); - graphics_link( rtSym ); - input_link( rtSym ); - audio_link( rtSym ); - multiplay_link( rtSym ); - blitz3d_link( rtSym ); - userlibs_link( rtSym ); -} - -//start up error -static void sue( const char *t ){ - string p=string( "Startup Error: " )+t; - gx_runtime->debugInfo( p.c_str() ); -} - -bool bbruntime_create(){ - if( basic_create() ){ - if( math_create() ){ - if( string_create() ){ - if( stream_create() ){ - if( sockets_create() ){ - if( filesystem_create() ){ - if( bank_create() ){ - if( graphics_create() ){ - if( input_create() ){ - if( audio_create() ){ - if( multiplay_create() ){ - if( blitz3d_create() ){ - if( userlibs_create() ){ - return true; - } - }else sue( "blitz3d_create failed" ); - multiplay_destroy(); - }else sue( "multiplay_create failed" ); - audio_destroy(); - }else sue( "audio_create failed" ); - input_destroy(); - }else sue( "input_create failed" ); - graphics_destroy(); - }else sue( "graphics_create failed" ); - bank_destroy(); - }else sue( "bank_create failed" ); - filesystem_destroy(); - }else sue( "filesystem_create failed" ); - sockets_destroy(); - }else sue( "sockets_create failed" ); - stream_destroy(); - }else sue( "stream_create failed" ); - string_destroy(); - }else sue( "string_create failed" ); - math_destroy(); - }else sue( "math_create failed" ); - basic_destroy(); - }else sue( "basic_create failed" ); - return false; -} - -bool bbruntime_destroy(){ - userlibs_destroy(); - blitz3d_destroy(); - multiplay_destroy(); - audio_destroy(); - input_destroy(); - graphics_destroy(); - bank_destroy(); - filesystem_destroy(); - sockets_destroy(); - stream_destroy(); - string_destroy(); - math_destroy(); - basic_destroy(); - return true; -} - -const char *bbruntime_run( gxRuntime *rt,void (*pc)(),bool dbg ){ - debug=dbg; - gx_runtime=rt; - - if( !bbruntime_create() ) return "Unable to start program"; - const char *t=0; - try{ - if( !gx_runtime->idle() ) RTEX( 0 ); - pc(); - gx_runtime->debugInfo( "Program has ended" ); - }catch( bbEx x ){ - t=x.err; - } - bbruntime_destroy(); - return t; -} - -void bbruntime_panic( const char *err ){ - RTEX( err ); -} diff --git a/bbruntime/bbruntime.vcxproj b/bbruntime/bbruntime.vcxproj deleted file mode 100644 index 5136ee9..0000000 --- a/bbruntime/bbruntime.vcxproj +++ /dev/null @@ -1,285 +0,0 @@ - - - - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - - - Debug - Win32 - - - Release - Win32 - - - Template - Win32 - - - - - - {DF8CAA9D-7154-4D5F-BCCC-0D7BB57C7354} - 10.0.10586.0 - - - - Application - v140 - - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - ..\#Build\$(ProjectName)\$(ConfigurationName)\ - ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ - true - - - .\bbruntime___Win32_Blitz2DRelease\ - .\bbruntime___Win32_Blitz2DRelease\ - false - - - .\bbruntime___Win32_Blitz3DRelease\ - .\bbruntime___Win32_Blitz3DRelease\ - false - - - .\Release\ - .\Release\ - false - - - - MultiThreadedDebug - Default - false - Disabled - true - Level3 - true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\bbruntime.pch - Use - std.h - .\Debug\ - .\Debug\ - EnableFastChecks - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - true - .\Debug\bbruntime.bsc - - - true - .\Debug\bbruntime.lib - - - - - MultiThreaded - AnySuitable - true - true - MaxSpeed - true - Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\bbruntime___Win32_Blitz2DRelease\ - .\bbruntime___Win32_Blitz2DRelease\bbruntime.pch - Use - std.h - .\bbruntime___Win32_Blitz2DRelease\ - .\bbruntime___Win32_Blitz2DRelease\ - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\bbruntime___Win32_Blitz2DRelease\bbruntime.bsc - - - true - .\bbruntime___Win32_Blitz2DRelease\bbruntime.lib - - - - - MultiThreaded - AnySuitable - true - true - MaxSpeed - true - Level3 - _LIB;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\bbruntime___Win32_Blitz3DRelease\ - .\bbruntime___Win32_Blitz3DRelease\bbruntime.pch - - .\bbruntime___Win32_Blitz3DRelease\ - .\bbruntime___Win32_Blitz3DRelease\ - StdCall - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\bbruntime___Win32_Blitz3DRelease\bbruntime.bsc - - - true - .\bbruntime___Win32_Blitz3DRelease\bbruntime.lib - - - - - MultiThreaded - AnySuitable - true - MaxSpeed - true - Level3 - true - Size - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\Release\ - .\Release\bbruntime.pch - Use - std.h - .\Release\ - .\Release\ - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\Release\bbruntime.bsc - - - true - .\Release\bbruntime.lib - - - - - Use - - - - - - - - - - Use - std.h - - - - - - - - - Create - std.h - Create - std.h - Create - std.h - Create - std.h - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bbruntime_dll/bbruntime_dll.vcxproj b/bbruntime_dll/bbruntime_dll.vcxproj deleted file mode 100644 index b28ecf0..0000000 --- a/bbruntime_dll/bbruntime_dll.vcxproj +++ /dev/null @@ -1,304 +0,0 @@ - - - - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - - - Debug - Win32 - - - Release - Win32 - - - Template - Win32 - - - - - - {5FA2FD4A-F9A4-41BA-9484-07C3A57A87E3} - 10.0.10586.0 - - - - Application - v140 - - - DynamicLibrary - v140 - false - MultiByte - - - DynamicLibrary - v140 - false - MultiByte - - - DynamicLibrary - v140 - false - MultiByte - - - DynamicLibrary - v140 - false - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - ..\#Build\$(ProjectName)\$(ConfigurationName)\ - ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ - false - - - .\Release\ - .\Release\ - false - - - .\bbruntime_dll___Win32_Blitz2DRelease\ - .\bbruntime_dll___Win32_Blitz2DRelease\ - false - - - .\bbruntime_dll___Win32_Blitz3DRelease\ - .\bbruntime_dll___Win32_Blitz3DRelease\ - false - - - - MultiThreadedDebug - Default - false - Disabled - true - Level3 - true - WIN32;_DEBUG;_WINDOWS;_USRDLL;BBRUNTIME_DLL_EXPORTS;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\bbruntime_dll.pch - .\Debug\ - .\Debug\ - EnableFastChecks - - - true - _DEBUG;%(PreprocessorDefinitions) - .\Debug\bbruntime_dll.tlb - true - Win32 - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - true - .\Debug\bbruntime_dll.bsc - - - true - true - true - Console - ..\blitzbasic\bin\runtime.dll - .\Debug\runtime.lib - /FIXED:NO - wsock32.lib;winmm.lib;dxguid.lib;d3dxof.lib;dplayx.lib;ddraw.lib;dinput.lib;dsound.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_WINDOWS;_USRDLL;BBRUNTIME_DLL_EXPORTS;%(PreprocessorDefinitions) - AssemblyCode - .\Release\ - .\Release\bbruntime_dll.pch - .\Release\ - .\Release\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\Release\bbruntime_dll.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\Release\bbruntime_dll.bsc - - - true - true - Console - ..\blitzbasic\bin\runtime.dll - .\Release\runtime.lib - wsock32.lib;winmm.lib;dxguid.lib;d3dxof.lib;dplayx.lib;ddraw.lib;dinput.lib;dsound.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_WINDOWS;_USRDLL;BBRUNTIME_DLL_EXPORTS;%(PreprocessorDefinitions) - AssemblyCode - .\bbruntime_dll___Win32_Blitz2DRelease\ - .\bbruntime_dll___Win32_Blitz2DRelease\bbruntime_dll.pch - .\bbruntime_dll___Win32_Blitz2DRelease\ - .\bbruntime_dll___Win32_Blitz2DRelease\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\bbruntime_dll___Win32_Blitz2DRelease\bbruntime_dll.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\bbruntime_dll___Win32_Blitz2DRelease\bbruntime_dll.bsc - - - true - true - Console - ..\..\release\blitz2drelease\bin\runtime.dll - .\bbruntime_dll___Win32_Blitz2DRelease\runtime.lib - wsock32.lib;winmm.lib;dxguid.lib;d3dxof.lib;dplayx.lib;ddraw.lib;dinput.lib;dsound.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - _WINDOWS;_USRDLL;BBRUNTIME_DLL_EXPORTS;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - AssemblyCode - .\bbruntime_dll___Win32_Blitz3DRelease\ - .\bbruntime_dll___Win32_Blitz3DRelease\bbruntime_dll.pch - .\bbruntime_dll___Win32_Blitz3DRelease\ - .\bbruntime_dll___Win32_Blitz3DRelease\ - StdCall - - - true - NDEBUG;%(PreprocessorDefinitions) - .\bbruntime_dll___Win32_Blitz3DRelease\bbruntime_dll.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\bbruntime_dll___Win32_Blitz3DRelease\bbruntime_dll.bsc - - - true - true - Console - ../_release/bin/runtime.dll - .\bbruntime_dll___Win32_Blitz3DRelease\runtime.lib - wsock32.lib;amstrmid.lib;winmm.lib;dxguid.lib;d3dxof.lib;dplayx.lib;ddraw.lib;dinput.lib;dsound.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - {df8caa9d-7154-4d5f-bccc-0d7bb57c7354} - false - - - {be0ba538-6215-4836-9227-1d3627e40d61} - false - - - {ff2d8bf7-1930-4cab-bc48-05cd33b7dc18} - false - - - {6bcfc5ca-ea71-4ae9-8b96-28b8701f939e} - false - - - - - - \ No newline at end of file diff --git a/blitz/blitz.vcxproj b/blitz/blitz.vcxproj index d2ae9b2..bd306fe 100644 --- a/blitz/blitz.vcxproj +++ b/blitz/blitz.vcxproj @@ -1,14 +1,6 @@  - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - Debug Win32 @@ -17,40 +9,21 @@ Release Win32 - - Template - Win32 - {C23AF61E-9509-411F-933E-17DB18884B21} - 10.0.10586.0 + BlitzCc + 8.1 - - Application - v140 - Application v140 false MultiByte - - Application - v140 - false - MultiByte - - - Application - v140 - false - MultiByte - Application v140 @@ -60,61 +33,54 @@ - - - - - - - - - - - - ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Test\bin\ ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ true - - - .\blitz___Win32_Blitz2DRelease\ - .\blitz___Win32_Blitz2DRelease\ - false - - - .\blitz___Win32_Blitz3DRelease\ - .\blitz___Win32_Blitz3DRelease\ - false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 - .\Release\ - .\Release\ + ..\#Test\bin\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 MultiThreadedDebug Default - false + true Disabled true - Level3 true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\blitz.pch - .\Debug\ - .\Debug\ + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) EnableFastChecks + true + true + true + false + false + true + ProgramDatabase + Guard + Level3 + true + Speed + true + true + false + StdCall .\Debug\blitz.tlb @@ -131,91 +97,33 @@ true true Console - .\Debug\blitz.exe - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - .\blitz___Win32_Blitz2DRelease\ - .\blitz___Win32_Blitz2DRelease\blitz.pch - .\blitz___Win32_Blitz2DRelease\ - .\blitz___Win32_Blitz2DRelease\ - - - .\blitz___Win32_Blitz2DRelease\blitz.tlb - - - 0x1409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\blitz___Win32_Blitz2DRelease\blitz.bsc - - - true - Console - ..\..\release\blitz2drelease\bin\blitzcc.exe - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - _CONSOLE;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\blitz___Win32_Blitz3DRelease\ - .\blitz___Win32_Blitz3DRelease\blitz.pch - .\blitz___Win32_Blitz3DRelease\ - .\blitz___Win32_Blitz3DRelease\ - StdCall - - - .\blitz___Win32_Blitz3DRelease\blitz.tlb - - - 0x1409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\blitz___Win32_Blitz3DRelease\blitz.bsc - - - true - Console - ../_release/bin/blitzcc.exe odbc32.lib;odbccp32.lib;%(AdditionalDependencies) MultiThreaded - Default + OnlyExplicitInline true true - MinSpace + MaxSpeed true Level3 - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - .\Release\ - .\Release\blitz.pch - .\Release\ - .\Release\ + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + ProgramDatabase + Guard + true + Speed + false + false + false + StdCall .\Release\blitz.tlb @@ -231,7 +139,6 @@ true Console - ..\blitzbasic\bin\blitzcc.exe odbc32.lib;odbccp32.lib;%(AdditionalDependencies) diff --git a/blitz/libs.cpp b/blitz/libs.cpp index 3a58a5d..63becd3 100644 --- a/blitz/libs.cpp +++ b/blitz/libs.cpp @@ -17,13 +17,13 @@ Environ *runtimeEnviron; vector keyWords; vector userFuncs; -static HMODULE linkerHMOD,runtimeHMOD; +static HMODULE linkerHMOD, runtimeHMOD; -static Type *typeof( int c ){ - switch( c ){ - case '%':return Type::int_type; - case '#':return Type::float_type; - case '$':return Type::string_type; +static Type *typeof(int c) { + switch (c) { + case '%':return Type::int_type; + case '#':return Type::float_type; + case '$':return Type::string_type; } return Type::void_type; } @@ -31,255 +31,261 @@ static Type *typeof( int c ){ static int curr; static string text; -static int next( istream &in ){ +static int next(istream &in) { - text=""; + text = ""; - int t=0; + int t = 0; - for(;;){ - while( isspace( in.peek() ) ) in.get(); - if( in.eof() ) return curr=0; - t=in.get();if( t!=';' ) break; - while( !in.eof() && in.get()!='\n' ){} + for (;;) { + while (isspace(in.peek())) in.get(); + if (in.eof()) return curr = 0; + t = in.get(); if (t != ';') break; + while (!in.eof() && in.get() != '\n') {} } - if( isalpha(t) ){ - text+=(char)t; - while( isalnum( in.peek() ) || in.peek()=='_' ) text+=(char)in.get(); - return curr=-1; + if (isalpha(t)) { + text += (char)t; + while (isalnum(in.peek()) || in.peek() == '_') text += (char)in.get(); + return curr = -1; } - if( t=='\"' ){ - while( in.peek()!='\"' ) text=text+(char)in.get(); + if (t == '\"') { + while (in.peek() != '\"') text = text + (char)in.get(); in.get(); - return curr=-2; + return curr = -2; } - return curr=t; + return curr = t; } -static const char *linkRuntime(){ +static const char *linkRuntime() { - while( const char *sym=runtimeLib->nextSym() ){ + while (const char *sym = runtimeLib->nextSym()) { - string s( sym ); + string s(sym); - int pc=runtimeLib->symValue(sym); + int pc = runtimeLib->symValue(sym); //internal? - if( s[0]=='_' ){ - runtimeModule->addSymbol( ("_"+s).c_str(),pc ); + if (s[0] == '_') { + runtimeModule->addSymbol(("_" + s).c_str(), pc); continue; } - bool cfunc=false; + bool cfunc = false; - if( s[0]=='!' ){ - cfunc=true; - s=s.substr(1); + if (s[0] == '!') { + cfunc = true; + s = s.substr(1); } - keyWords.push_back( s ); + keyWords.push_back(s); //global! - int start=0,end; - Type *t=Type::void_type; - if( !isalpha( s[0] ) ){ start=1;t=typeof( s[0] ); } - for( int k=1;kinsertDecl( str,t,DECL_PARAM,defType ); + Decl *d = params->insertDecl(str, t, DECL_PARAM, defType); } - FuncType *f=d_new FuncType( t,params,false,cfunc ); - n=tolower(n); - runtimeEnviron->funcDecls->insertDecl( n,f,DECL_FUNC ); - runtimeModule->addSymbol( ("_f"+n).c_str(),pc ); + FuncType *f = d_new FuncType(t, params, false, cfunc); + n = tolower(n); + runtimeEnviron->funcDecls->insertDecl(n, f, DECL_FUNC); + runtimeModule->addSymbol(("_f" + n).c_str(), pc); } return 0; } static set _ulibkws; -static const char *loadUserLib( const string &userlib ){ +static const char *loadUserLib(const string &userlib) { - string t=home+"/userlibs/"+userlib; + string t = home + "/userlibs/" + userlib; - string lib=""; + string lib = ""; ifstream in(t.c_str()); next(in); - while( curr ){ + while (curr) { - if( curr=='.' ){ + if (curr == '.') { - if( next(in)!=-1 ) return "expecting identifier after '.'"; + if (next(in) != -1) return "expecting identifier after '.'"; - if( text=="lib" ){ - if( next(in)!=-2 ) return "expecting string after lib directive"; - lib=text; + if (text == "lib") { + if (next(in) != -2) return "expecting string after lib directive"; + lib = text; - }else{ + } else { return "unknown decl directive"; } - next( in ); - - }else if( curr==-1 ){ - - if( !lib.size() ) return "function decl without lib directive"; - - string id=text; - string lower_id=tolower(id); - - if( _ulibkws.count( lower_id ) ) return "duplicate identifier"; - _ulibkws.insert( lower_id ); - - Type *ty=0; - switch( next(in) ){ - case '%':ty=Type::int_type;break; - case '#':ty=Type::float_type;break; - case '$':ty=Type::string_type;break; - } - if( ty ) next(in); - else ty=Type::void_type; - - DeclSeq *params=d_new DeclSeq(); - - if( curr!='(' ) return "expecting '(' after function identifier"; next(in); - if( curr!=')' ){ - for(;;){ - if( curr!=-1 ) break; - string arg=text; - Type *ty=0; - switch( next(in) ){ - case '%':ty=Type::int_type;break; - case '#':ty=Type::float_type;break; - case '$':ty=Type::string_type;break; - case '*':ty=Type::null_type;break; + } else if (curr == -1) { + + if (!lib.size()) return "function decl without lib directive"; + + string id = text; + string lower_id = tolower(id); + + if (_ulibkws.count(lower_id)) return "duplicate identifier"; + _ulibkws.insert(lower_id); + + Type *ty = 0; + switch (next(in)) { + case '%':ty = Type::int_type; break; + case '#':ty = Type::float_type; break; + case '$':ty = Type::string_type; break; + } + if (ty) next(in); + else ty = Type::void_type; + + DeclSeq *params = d_new DeclSeq(); + + if (curr != '(') return "expecting '(' after function identifier"; + next(in); + if (curr != ')') { + for (;;) { + if (curr != -1) break; + string arg = text; + + Type *ty = 0; + switch (next(in)) { + case '%':ty = Type::int_type; break; + case '#':ty = Type::float_type; break; + case '$':ty = Type::string_type; break; + case '*':ty = Type::null_type; break; } - if( ty ) next(in); - else ty=Type::int_type; + if (ty) next(in); + else ty = Type::int_type; - ConstType *defType=0; + ConstType *defType = 0; - Decl *d=params->insertDecl( arg,ty,DECL_PARAM,defType ); + Decl *d = params->insertDecl(arg, ty, DECL_PARAM, defType); - if( curr!=',' ) break; + if (curr != ',') break; next(in); } } - if( curr!=')' ) return "expecting ')' after function decl"; + if (curr != ')') return "expecting ')' after function decl"; - keyWords.push_back( id ); + keyWords.push_back(id); - FuncType *fn=d_new FuncType( ty,params,true,true ); + FuncType *fn = d_new FuncType(ty, params, true, true); - runtimeEnviron->funcDecls->insertDecl( lower_id,fn,DECL_FUNC ); + runtimeEnviron->funcDecls->insertDecl(lower_id, fn, DECL_FUNC); - if( next(in)==':' ){ //real name? + if (next(in) == ':') { //real name? next(in); - if( curr!=-1 && curr!=-2 ) return "expecting identifier or string after alias"; - id=text; + if (curr != -1 && curr != -2) return "expecting identifier or string after alias"; + id = text; next(in); } - userFuncs.push_back( UserFunc( lower_id,id,lib ) ); + userFuncs.push_back(UserFunc(lower_id, id, lib)); } } return 0; } -static const char *linkUserLibs(){ +static const char *linkUserLibs() { _ulibkws.clear(); WIN32_FIND_DATA fd; - HANDLE h=FindFirstFile( (home+"/userlibs/*.decls").c_str(),&fd ); + HANDLE h = FindFirstFile((home + "/userlibs/*.decls").c_str(), &fd); - if( h==INVALID_HANDLE_VALUE ) return 0; + if (h == INVALID_HANDLE_VALUE) return 0; - const char *err=0; + const char *err = 0; - do{ - if( err=loadUserLib( fd.cFileName ) ){ + do { + if (err = loadUserLib(fd.cFileName)) { static char buf[64]; - sprintf( buf,"Error in userlib '%s' - %s",fd.cFileName,err ); - err=buf;break; + sprintf(buf, "Error in userlib '%s' - %s", fd.cFileName, err); + err = buf; break; } - }while( FindNextFile( h,&fd ) ); + } while (FindNextFile(h, &fd)); - FindClose( h ); + FindClose(h); _ulibkws.clear(); return err; } -const char *openLibs(){ - - char *p=getenv( "blitzpath" ); - if( !p ) return "Can't find blitzpath environment variable"; - home=string(p); +const char *openLibs() { - linkerHMOD=LoadLibrary( (home+"/bin/linker.dll").c_str() ); - if( !linkerHMOD ) return "Unable to open linker.dll"; + /*char *p = getenv("blitzpath"); + if (!p) return "Can't find blitzpath environment variable"; + */ + char* buf = new char[MAX_PATH]; + GetModuleFileName(NULL, buf, MAX_PATH); + home = string(buf); + delete buf; + + string::size_type pos = home.find_last_of("\\/"); + home = home.substr(0, pos); + + linkerHMOD = LoadLibrary((home + "\\linker.dll").c_str()); + if (!linkerHMOD) return "Unable to open linker.dll"; typedef Linker *(_cdecl*GetLinker)(); - GetLinker gl=(GetLinker)GetProcAddress( linkerHMOD,"linkerGetLinker" ); - if( !gl ) return "Error in linker.dll"; - linkerLib=gl(); + GetLinker gl = (GetLinker)GetProcAddress(linkerHMOD, "linkerGetLinker"); + if (!gl) return "Error in linker.dll"; + linkerLib = gl(); - runtimeHMOD=LoadLibrary( (home+"/bin/runtime.dll").c_str() ); - if( !runtimeHMOD ) return "Unable to open runtime.dll"; + runtimeHMOD = LoadLibrary((home + "\\runtime.dll").c_str()); + if (!runtimeHMOD) return "Unable to open runtime.dll"; typedef Runtime *(_cdecl*GetRuntime)(); - GetRuntime gr=(GetRuntime)GetProcAddress( runtimeHMOD,"runtimeGetRuntime" ); - if( !gr ) return "Error in runtime.dll"; - runtimeLib=gr(); + GetRuntime gr = (GetRuntime)GetProcAddress(runtimeHMOD, "runtimeGetRuntime"); + if (!gr) return "Error in runtime.dll"; + runtimeLib = gr(); - bcc_ver=VERSION; - lnk_ver=linkerLib->version(); - run_ver=runtimeLib->version(); + bcc_ver = VERSION; + lnk_ver = linkerLib->version(); + run_ver = runtimeLib->version(); - if( (lnk_ver>>16)!=(bcc_ver>>16) || - (run_ver>>16)!=(bcc_ver>>16) || - (lnk_ver>>16)!=(bcc_ver>>16) ) return "Library version error"; + if ((lnk_ver >> 16) != (bcc_ver >> 16) || + (run_ver >> 16) != (bcc_ver >> 16) || + (lnk_ver >> 16) != (bcc_ver >> 16)) return "Library version error"; - runtimeLib->startup( GetModuleHandle(0) ); + runtimeLib->startup(GetModuleHandle(0)); - runtimeModule=linkerLib->createModule(); - runtimeEnviron=d_new Environ( "",Type::int_type,0,0 ); + runtimeModule = linkerLib->createModule(); + runtimeEnviron = d_new Environ("", Type::int_type, 0, 0); keyWords.clear(); userFuncs.clear(); @@ -287,26 +293,26 @@ const char *openLibs(){ return 0; } -const char *linkLibs(){ +const char *linkLibs() { - if( const char *p=linkRuntime() ) return p; + if (const char *p = linkRuntime()) return p; - if( const char *p=linkUserLibs() ) return p; + if (const char *p = linkUserLibs()) return p; return 0; } -void closeLibs(){ +void closeLibs() { delete runtimeEnviron; - if( linkerLib ) linkerLib->deleteModule( runtimeModule ); - if( runtimeLib ) runtimeLib->shutdown(); - if( runtimeHMOD ) FreeLibrary( runtimeHMOD ); - if( linkerHMOD ) FreeLibrary( linkerHMOD ); + if (linkerLib) linkerLib->deleteModule(runtimeModule); + if (runtimeLib) runtimeLib->shutdown(); + if (runtimeHMOD) FreeLibrary(runtimeHMOD); + if (linkerHMOD) FreeLibrary(linkerHMOD); - runtimeEnviron=0; - linkerLib=0; - runtimeLib=0; - runtimeHMOD=0; - linkerHMOD=0; + runtimeEnviron = 0; + linkerLib = 0; + runtimeLib = 0; + runtimeHMOD = 0; + linkerHMOD = 0; } diff --git a/blitz/libs.h b/blitz/libs.h index 31ca905..81e8f34 100644 --- a/blitz/libs.h +++ b/blitz/libs.h @@ -9,10 +9,10 @@ using namespace std; -#include "../linker/linker.h" +#include "../LinkerLib/linker.h" #include "../compiler/environ.h" #include "../compiler/parser.h" -#include "../bbruntime_dll/bbruntime_dll.h" +#include "../Runtime/bbruntime_dll.h" extern int bcc_ver; extern int lnk_ver; diff --git a/blitz/main.cpp b/blitz/main.cpp index de4bb2f..36ab61d 100644 --- a/blitz/main.cpp +++ b/blitz/main.cpp @@ -19,278 +19,278 @@ using namespace std; -#include "../linker/linker.h" +#include "../LinkerLib/linker.h" #include "../compiler/environ.h" #include "../compiler/parser.h" #include "../compiler/assem_x86/assem_x86.h" #include "../compiler/codegen_x86/codegen_x86.h" -#include "../bbruntime_dll/bbruntime_dll.h" +#include "../Runtime/bbruntime_dll.h" -static void showInfo(){ - const int major=(VERSION&0xffff)/100,minor=(VERSION&0xffff)%100; - cout<<"BlitzCC V"<funcDecls->findDecl( tolower( kw ) ); - if( !d || d->type->funcType()==0 ) return "No quick help available for "+kw; - string t=kw; - FuncType *f=d->type->funcType(); - if( f->returnType==Type::float_type ) t+='#'; - else if( f->returnType==Type::string_type ) t+='$'; + Environ *e = runtimeEnviron; + Decl *d = e->funcDecls->findDecl(tolower(kw)); + if (!d || d->type->funcType() == 0) return "No quick help available for " + kw; + string t = kw; + FuncType *f = d->type->funcType(); + if (f->returnType == Type::float_type) t += '#'; + else if (f->returnType == Type::string_type) t += '$'; - t+=" "; + t += " "; - if( f->returnType!=Type::void_type ) t+="( "; + if (f->returnType != Type::void_type) t += "( "; - for( int k=0;kparams->size();++k ){ + for (int k = 0; k < f->params->size(); ++k) { string s; - if( k ) s+=','; - Decl *p=f->params->decls[k];s+=p->name; - if( p->type==Type::float_type ) s+='#'; - else if( p->type==Type::string_type ) s+='$'; - else if( p->type==Type::void_type ) s+='*'; - if( p->defType ) s='['+s+']'; - t+=s; + if (k) s += ','; + Decl *p = f->params->decls[k]; s += p->name; + if (p->type == Type::float_type) s += '#'; + else if (p->type == Type::string_type) s += '$'; + else if (p->type == Type::void_type) s += '*'; + if (p->defType) s = '[' + s + ']'; + t += s; } - if( f->returnType!=Type::void_type ){ - t+=f->params->size() ? " )" : ")"; + if (f->returnType != Type::void_type) { + t += f->params->size() ? " )" : ")"; } return t; } -static void dumpKeys( bool lang,bool mod,bool help ){ +static void dumpKeys(bool lang, bool mod, bool help) { - if( lang ){ - map::iterator it; - map &keywords=Toker::getKeywords(); - for( it=keywords.begin();it!=keywords.end();++it ){ - if( it->first.find(' ')!=string::npos ) continue; - cout<first<::iterator it; + map &keywords = Toker::getKeywords(); + for (it = keywords.begin(); it != keywords.end(); ++it) { + if (it->first.find(' ') != string::npos) continue; + cout << it->first << endl; } } - if( !mod ) return; + if (!mod) return; - for( int k=0;ksemant( runtimeEnviron ); + if (!veryquiet) cout << "Generating..." << endl; + v_environ = prog->semant(runtimeEnviron); //translate - if( !veryquiet ) cout<<"Translating..."<translate( &codegen,userFuncs ); + prog->translate(&codegen, userFuncs); - if( dumpasm ){ - cout<createModule(); - Assem_x86 assem( asmcode,module ); + if (!veryquiet) cout << "Assembling..." << endl; + module = linkerLib->createModule(); + Assem_x86 assem(asmcode, module); assem.assemble(); - }catch( Ex &x ){ + } catch (Ex &x) { - string file='\"'+x.file+'\"'; - int row=((x.pos>>16)&65535)+1,col=(x.pos&65535)+1; - cout<> 16) & 65535) + 1, col = (x.pos & 65535) + 1; + cout << file << ":" << row << ":" << col << ":" << row << ":" << col << ":" << x.ex << endl; exit(-1); } delete prog; - if( out_file.size() ){ - if( !veryquiet ) cout<<"Creating executable \""<createExe( out_file.c_str(),(home+"/bin/runtime.dll").c_str() ) ){ - err( "Error creating executable" ); + if (out_file.size()) { + if (!veryquiet) cout << "Creating executable \"" << out_file << "\"..." << endl; + if (!module->createExe(out_file.c_str(), (home + "/bin/runtime.dll").c_str())) { + err("Error creating executable"); } - }else if( !compileonly ){ - void *entry=module->link( runtimeModule ); - if( !entry ) return 0; + } else if (!compileonly) { + void *entry = module->link(runtimeModule); + if (!entry) return 0; - HMODULE dbgHandle=0; - Debugger *debugger=0; + HMODULE dbgHandle = 0; + Debugger *debugger = 0; - if( debug ){ - dbgHandle=LoadLibrary( (home+"/bin/debugger.dll").c_str() ); - if( dbgHandle ){ - typedef Debugger *(_cdecl*GetDebugger)( Module*,Environ* ); - GetDebugger gd=(GetDebugger)GetProcAddress( dbgHandle,"debuggerGetDebugger" ); - if( gd ) debugger=gd( module,environ ); + if (debug) { + dbgHandle = LoadLibrary((home + "/bin/debugger.dll").c_str()); + if (dbgHandle) { + typedef Debugger *(_cdecl*GetDebugger)(Module*, Environ*); + GetDebugger gd = (GetDebugger)GetProcAddress(dbgHandle, "debuggerGetDebugger"); + if (gd) debugger = gd(module, v_environ); } - if( !debugger ) err( "Error launching debugger" ); + if (!debugger) err("Error launching debugger"); } - if( !veryquiet ) cout<<"Executing..."<execute( (void(*)())entry,args.c_str(),debugger ); + runtimeLib->execute((void(*)())entry, args.c_str(), debugger); - if( dbgHandle ) FreeLibrary( dbgHandle ); + if (dbgHandle) FreeLibrary(dbgHandle); } delete module; - delete environ; + delete v_environ; closeLibs(); diff --git a/blitz3d/blitz3d.vcxproj b/blitz3d/blitz3d.vcxproj index 56058c7..711c4e5 100644 --- a/blitz3d/blitz3d.vcxproj +++ b/blitz3d/blitz3d.vcxproj @@ -1,14 +1,6 @@  - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - Debug Win32 @@ -17,40 +9,20 @@ Release Win32 - - Template - Win32 - {BE0BA538-6215-4836-9227-1D3627E40D61} - 10.0.10586.0 + 8.1 - - Application - v140 - StaticLibrary v140 false MultiByte - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte - StaticLibrary v140 @@ -60,62 +32,53 @@ - - - - - - - - - - - - .\Release\ - .\Release\ - false - - - .\blitz3d___Win32_Blitz2DRelease\ - .\blitz3d___Win32_Blitz2DRelease\ - false - - - .\blitz3d___Win32_Blitz3DRelease\ - .\blitz3d___Win32_Blitz3DRelease\ + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 ..\#Build\$(ProjectName)\$(ConfigurationName)\ ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ true + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 MultiThreaded - AnySuitable + OnlyExplicitInline true true MaxSpeed true Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\Release\ - .\Release\blitz3d.pch - Use - std.h - .\Release\ - .\Release\ + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + false + false + false + StdCall 0x0409 @@ -128,83 +91,35 @@ true .\Release\blitz3d.lib - - - - - MultiThreaded - AnySuitable - true - true - MaxSpeed - true - Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\blitz3d___Win32_Blitz2DRelease\ - .\blitz3d___Win32_Blitz2DRelease\blitz3d.pch - Use - std.h - .\blitz3d___Win32_Blitz2DRelease\ - .\blitz3d___Win32_Blitz2DRelease\ - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\blitz3d___Win32_Blitz2DRelease\blitz3d.bsc - - - true - .\blitz3d___Win32_Blitz2DRelease\blitz3d.lib - - - - - MultiThreaded - AnySuitable - true - true - MaxSpeed - true - Level3 - _LIB;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\blitz3d___Win32_Blitz3DRelease\ - .\blitz3d___Win32_Blitz3DRelease\blitz3d.pch - - .\blitz3d___Win32_Blitz3DRelease\ - .\blitz3d___Win32_Blitz3DRelease\ - StdCall - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\blitz3d___Win32_Blitz3DRelease\blitz3d.bsc - - - true - .\blitz3d___Win32_Blitz3DRelease\blitz3d.lib + MachineX86 MultiThreadedDebug Default - false + true Disabled true - Level3 true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\blitz3d.pch - .\Debug\ - .\Debug\ + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) EnableFastChecks + $(DXSDK_INCLUDE);$(DIRECTXSDK_INCLUDE); + true + true + true + false + false + true + Guard + Level3 + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + true + true + false + StdCall 0x0409 @@ -217,6 +132,7 @@ true .\Debug\blitz3d.lib + MachineX86 @@ -252,10 +168,6 @@ Create std.h - Create - std.h - Create - std.h diff --git a/blitz3d/entity.cpp b/blitz3d/entity.cpp index bf8ec81..a69a027 100644 --- a/blitz3d/entity.cpp +++ b/blitz3d/entity.cpp @@ -2,7 +2,7 @@ #include "std.h" #include "entity.h" -#include "stats.h" +//#include "stats.h" Entity *Entity::_orphans,*Entity::_last_orphan; diff --git a/blitz3d/geom.h b/blitz3d/geom.h index 4e6fbb8..24971be 100644 --- a/blitz3d/geom.h +++ b/blitz3d/geom.h @@ -77,15 +77,15 @@ public: x -= q.x; y -= q.y; z -= q.z; return *this; } bool operator<(const Vector &q)const { - if (fabs(x - q.x) > FLT_FLT_EPSILON) return x < q.x ? true : false; - if (fabs(y - q.y) > FLT_FLT_EPSILON) return y < q.y ? true : false; - return fabs(z - q.z) > FLT_FLT_EPSILON && z < q.z; + if (fabs(x - q.x) > FLT_EPSILON) return x < q.x ? true : false; + if (fabs(y - q.y) > FLT_EPSILON) return y < q.y ? true : false; + return fabs(z - q.z) > FLT_EPSILON && z < q.z; } bool operator==(const Vector &q)const { - return fabs(x - q.x) <= FLT_FLT_EPSILON && fabs(y - q.y) <= FLT_FLT_EPSILON && fabs(z - q.z) <= FLT_FLT_EPSILON; + return fabs(x - q.x) <= FLT_EPSILON && fabs(y - q.y) <= FLT_EPSILON && fabs(z - q.z) <= FLT_EPSILON; } bool operator!=(const Vector &q)const { - return fabs(x - q.x) > FLT_FLT_EPSILON || fabs(y - q.y) > FLT_FLT_EPSILON || fabs(z - q.z) > FLT_FLT_EPSILON; + return fabs(x - q.x) > FLT_EPSILON || fabs(y - q.y) > FLT_EPSILON || fabs(z - q.z) > FLT_EPSILON; } float dot(const Vector &q)const { return x*q.x + y*q.y + z*q.z; @@ -222,7 +222,7 @@ struct Quat { Quat t = q; float d = dot(q), b = 1 - a; if (d < 0) { t.w = -t.w; t.v = -t.v; d = -d; } - if (d < 1 - FLT_FLT_EPSILON) { + if (d < 1 - FLT_EPSILON) { float om = acosf(d); float si = sinf(om); a = sinf(a*om) / si; @@ -527,7 +527,7 @@ inline Quat matrixQuat(const Matrix &p) { Matrix m = p; m.orthogonalize(); float t = m.i.x + m.j.y + m.k.z, w, x, y, z; - if (t > FLT_FLT_EPSILON) { + if (t > FLT_EPSILON) { t = sqrtf(t + 1) * 2; x = (m.k.y - m.j.z) / t; y = (m.i.z - m.k.x) / t; diff --git a/blitz3d/loader_3ds.cpp b/blitz3d/loader_3ds.cpp index 6c0413f..b94acf6 100644 --- a/blitz3d/loader_3ds.cpp +++ b/blitz3d/loader_3ds.cpp @@ -12,6 +12,8 @@ extern gxRuntime *gx_runtime; #define _log( X ) #endif +class Box; + static filebuf in; static int chunk_end; static vector parent_end; @@ -369,7 +371,7 @@ static void parseMeshInfo( MeshModel *root,float curr_time ){ Vector pivot; Animation anim; unsigned short id=65535,parent=65535,flags1,flags2; - Box box( Vector(),Vector() ); + Box box = Box( Vector(),Vector() ); Vector box_centre; while( int chunk_id=nextChunk() ){ switch( chunk_id ){ diff --git a/blitz3d/q3bsprep.cpp b/blitz3d/q3bsprep.cpp index 59b1419..7a96f78 100644 --- a/blitz3d/q3bsprep.cpp +++ b/blitz3d/q3bsprep.cpp @@ -6,31 +6,31 @@ #pragma pack(push,1) -struct q3_plane{ +struct q3_plane { Vector normal; float distance; }; -struct q3_tex{ +struct q3_tex { char name[64]; - int flags,contents; + int flags, contents; }; -struct q3_vertex{ +struct q3_vertex { Vector coords; float tex_coords[4]; Vector normal; unsigned char color[4]; }; -struct q3_node{ +struct q3_node { int plane; int children[2]; int mins[3]; int maxs[3]; }; -struct q3_face{ +struct q3_face { int texture; int effect; int type; @@ -47,7 +47,7 @@ struct q3_face{ int patch_size[2]; }; -struct q3_leaf{ +struct q3_leaf { int cluster; int area; int mins[3]; @@ -58,26 +58,26 @@ struct q3_leaf{ int n_leafbrushes; }; -struct q3_brush{ +struct q3_brush { int brushside; int n_brushsides; int texture; }; -struct q3_brushside{ +struct q3_brushside { int plane; int texture; }; -struct q3_direntry{ - union{ +struct q3_direntry { + union { int offset; void *lump; }; int length; }; -struct q3_header{ +struct q3_header { unsigned magic; int version; q3_direntry dir[17]; @@ -86,59 +86,59 @@ struct q3_header{ #pragma pack(pop) /* Loading reps */ -struct Surf{ +struct Surf { Q3BSPSurf *surf; - int texture,lm_index; - vector verts,tris; + int texture, lm_index; + vector verts, tris; }; -struct FaceCmp{ - bool operator()( const q3_face *a,const q3_face *b )const{ - if( a->texturetexture ) return true; - if( b->texturetexture ) return false; - if( a->lm_indexlm_index ) return true; +struct FaceCmp { + bool operator()(const q3_face *a, const q3_face *b)const { + if (a->texture < b->texture) return true; + if (b->texture < a->texture) return false; + if (a->lm_index < b->lm_index) return true; return false; } }; -typedef map FaceMap; +typedef map FaceMap; /* render reps */ struct Q3BSPFace; -struct Q3BSPSurf{ +struct Q3BSPSurf { Brush brush; gxMesh *mesh; vector r_faces; - int texture,lm_index; + int texture, lm_index; }; -struct Q3BSPFace{ - union{ +struct Q3BSPFace { + union { Surf *t_surf; Q3BSPSurf *surf; }; - int vert,n_verts,tri,n_tris; + int vert, n_verts, tri, n_tris; }; -struct Q3BSPBrush{ +struct Q3BSPBrush { vector planes; }; -struct Q3BSPLeaf{ +struct Q3BSPLeaf { int cluster; Box box; vector faces; }; -struct Q3BSPNode{ +struct Q3BSPNode { Box box; Plane plane; Q3BSPNode *nodes[2]; Q3BSPLeaf *leafs[2]; - ~Q3BSPNode(){ delete nodes[0];delete nodes[1];delete leafs[0];delete leafs[1]; } + ~Q3BSPNode() { delete nodes[0]; delete nodes[1]; delete leafs[0]; delete leafs[1]; } }; static q3_header header; @@ -154,163 +154,163 @@ static Vector r_eye; static int r_cluster; static Frustum r_frustum; static Vector r_frustedges[12]; -static map q3face_map; +static map q3face_map; extern gxScene *gx_scene; extern gxRuntime *gx_runtime; extern gxGraphics *gx_graphics; //#define SWAPTRIS -Vector static tf( const Vector &v ){ - return Vector( -v.y,v.z,v.x ); +Vector static tf(const Vector &v) { + return Vector(-v.y, v.z, v.x); } #ifdef BETA -static int log( const string &t ){ - gx_runtime->debugLog( t.c_str() ); +static void debuglog(const string &t) { + gx_runtime->debugLog(t.c_str()); } #else -static int log( const string &t ){} +static void debuglog(const string &t) {} #endif -static Surf *findSurf( q3_face *f ){ - FaceMap::const_iterator it=face_map.find( f ); - if( it!=face_map.end() ) return it->second; - Surf *s=d_new Surf; - s->texture=f->texture; - s->lm_index=f->lm_index; - face_map.insert( make_pair( f,s ) ); - t_surfs.push_back( s ); +static Surf *findSurf(q3_face *f) { + FaceMap::const_iterator it = face_map.find(f); + if (it != face_map.end()) return it->second; + Surf *s = d_new Surf; + s->texture = f->texture; + s->lm_index = f->lm_index; + face_map.insert(make_pair(f, s)); + t_surfs.push_back(s); return s; } -void Q3BSPRep::createTextures(){ - int n_texs=header.dir[1].length/sizeof(q3_tex); - q3_tex *q3tex=(q3_tex*)header.dir[1].lump; - for( int k=0;kname); - char fl[32],co[32]; - itoa( q3tex->flags,fl,16 ); - itoa( q3tex->contents,co,16 ); - log( t+", flags=0x"+fl+", contents=0x"+co ); - Texture tex( t+".tga",1 ); - if( !tex.getCanvas(0) ){ - tex=Texture( t+".jpg",1 ); - if( !tex.getCanvas(0) ){ - tex=Texture( t+".png",1 ); - if( !tex.getCanvas(0) ){ - tex=Texture( t+".dds",1 ); - if( !tex.getCanvas(0) ) log( "Failed!" ); +void Q3BSPRep::createTextures() { + int n_texs = header.dir[1].length / sizeof(q3_tex); + q3_tex *q3tex = (q3_tex*)header.dir[1].lump; + for (int k = 0; k < n_texs; ++k) { + string t = string(q3tex->name); + char fl[32], co[32]; + _itoa(q3tex->flags, fl, 16); + _itoa(q3tex->contents, co, 16); + debuglog(t + ", flags=0x" + fl + ", contents=0x" + co); + Texture tex(t + ".tga", 1); + if (!tex.getCanvas(0)) { + tex = Texture(t + ".jpg", 1); + if (!tex.getCanvas(0)) { + tex = Texture(t + ".png", 1); + if (!tex.getCanvas(0)) { + tex = Texture(t + ".dds", 1); + if (!tex.getCanvas(0)) debuglog("Failed!"); } } } - tex.setFlags( 1 ); - textures.push_back( tex ); + tex.setFlags(1); + textures.push_back(tex); ++q3tex; } } -void Q3BSPRep::createLightMaps(){ - int n_lmaps=header.dir[14].length/(128*128*3); - unsigned char *rgb=(unsigned char*)header.dir[14].lump; +void Q3BSPRep::createLightMaps() { + int n_lmaps = header.dir[14].length / (128 * 128 * 3); + unsigned char *rgb = (unsigned char*)header.dir[14].lump; unsigned char adj[256]; int k; - for( k=0;k<256;++k ) adj[k]=pow( k/255.0f,gamma_adj )*255.0f; + for (k = 0; k < 256; ++k) adj[k] = pow(k / 255.0f, gamma_adj)*255.0f; - for( k=0;klock(); - for( int y=0;y<128;++y ){ - for( int x=0;x<128;++x ){ - unsigned argb=0xff000000|(adj[rgb[0]]<<16)|(adj[rgb[1]]<<8)|adj[rgb[2]]; - c->setPixelFast( x,y,argb ); - rgb+=3; + for (int y = 0; y < 128; ++y) { + for (int x = 0; x < 128; ++x) { + unsigned argb = 0xff000000 | (adj[rgb[0]] << 16) | (adj[rgb[1]] << 8) | adj[rgb[2]]; + c->setPixelFast(x, y, argb); + rgb += 3; } } c->unlock(); - light_maps.push_back( tex ); + light_maps.push_back(tex); } } -void Q3BSPRep::createVis(){ - int *vis=(int*)header.dir[16].lump; - int n_vecs=*vis++; - vis_sz=*vis++; - log( "vis: "+itoa(n_vecs)+","+itoa(vis_sz) ); - vis_data=new char[n_vecs*vis_sz]; - memcpy( vis_data,vis,n_vecs*vis_sz ); +void Q3BSPRep::createVis() { + int *vis = (int*)header.dir[16].lump; + int n_vecs = *vis++; + vis_sz = *vis++; + debuglog("vis: " + itoa(n_vecs) + "," + itoa(vis_sz)); + vis_data = new char[n_vecs*vis_sz]; + memcpy(vis_data, vis, n_vecs*vis_sz); } -void Q3BSPRep::createCollider(){ +void Q3BSPRep::createCollider() { vector coll_verts; - int n_verts=header.dir[10].length/sizeof(q3_vertex); - q3_vertex *t=(q3_vertex*)header.dir[10].lump; + int n_verts = header.dir[10].length / sizeof(q3_vertex); + q3_vertex *t = (q3_vertex*)header.dir[10].lump; MeshCollider::Vertex cv; int k; - for( k=0;kcoords ); - coll_verts.push_back( cv ); + for (k = 0; k < n_verts; ++k) { + cv.coords = tf(t->coords); + coll_verts.push_back(cv); ++t; } - for( k=0;kcreateMesh( s->verts.size(),s->tris.size()/3,0 ); + for (k = 0; k < t_surfs.size(); ++k) { + Surf *s = t_surfs[k]; + gxMesh *mesh = gx_graphics->createMesh(s->verts.size(), s->tris.size() / 3, 0); - mesh->lock( true ); + mesh->lock(true); int j; - for( j=0;jverts.size();++j ){ + for (j = 0; j < s->verts.size(); ++j) { q3_vertex *t; - int n=s->verts[j]; - if( n>=0 ){ - t=(q3_vertex*)header.dir[10].lump+n; - }else{ - t=&p_verts[-n-1]; + int n = s->verts[j]; + if (n >= 0) { + t = (q3_vertex*)header.dir[10].lump + n; + } else { + t = &p_verts[-n - 1]; } - float tex_coords[2][2]={ {t->tex_coords[2],t->tex_coords[3]},{t->tex_coords[0],t->tex_coords[1]}}; - unsigned argb=0xff000000|(t->color[0]<<16)|(t->color[1]<<8)|t->color[2]; - mesh->setVertex( j,tf(t->coords),tf(t->normal),argb,tex_coords ); + float tex_coords[2][2] = { {t->tex_coords[2],t->tex_coords[3]},{t->tex_coords[0],t->tex_coords[1]} }; + unsigned argb = 0xff000000 | (t->color[0] << 16) | (t->color[1] << 8) | t->color[2]; + mesh->setVertex(j, tf(t->coords), tf(t->normal), argb, tex_coords); } - for( j=0;jtris.size();j+=3 ){ + for (j = 0; j < s->tris.size(); j += 3) { #ifdef SWAPTRIS - mesh->setTriangle( j/3,s->tris[j],s->tris[j+2],s->tris[j+1] ); + mesh->setTriangle(j / 3, s->tris[j], s->tris[j + 2], s->tris[j + 1]); #else - mesh->setTriangle( j/3,s->tris[j],s->tris[j+1],s->tris[j+2] ); + mesh->setTriangle(j / 3, s->tris[j], s->tris[j + 1], s->tris[j + 2]); #endif } mesh->unlock(); - Q3BSPSurf *surf=d_new Q3BSPSurf; - surf->texture=s->texture; - surf->lm_index=s->lm_index; - surf->mesh=mesh; - surfs.push_back( surf ); - s->surf=surf; + Q3BSPSurf *surf = d_new Q3BSPSurf; + surf->texture = s->texture; + surf->lm_index = s->lm_index; + surf->mesh = mesh; + surfs.push_back(surf); + s->surf = surf; } - for( k=0;ksurf=f->t_surf->surf; - f->tri/=3;f->n_tris/=3; + for (k = 0; k < faces.size(); ++k) { + Q3BSPFace *f = faces[k]; + f->surf = f->t_surf->surf; + f->tri /= 3; f->n_tris /= 3; } - for( k=0;kcoords=(a.coords+b.coords)*.5f; - c->normal=(a.normal+b.normal)*.5f; - for( int k=0;k<4;++k ){ - c->color[k]=(a.color[k]+b.color[k]+1)/2; - c->tex_coords[k]=(a.tex_coords[k]+b.tex_coords[k])*.5f; +static void average(const q3_vertex &a, const q3_vertex &b, q3_vertex *c) { + c->coords = (a.coords + b.coords)*.5f; + c->normal = (a.normal + b.normal)*.5f; + for (int k = 0; k < 4; ++k) { + c->color[k] = (a.color[k] + b.color[k] + 1) / 2; + c->tex_coords[k] = (a.tex_coords[k] + b.tex_coords[k])*.5f; } } -static void subdivide( vector &verts,int level,int index,int step ){ - if( !level ){ - q3_vertex t1,t2; - average( verts[index],verts[index+step],&t1 ); - average( verts[index+step],verts[index+step*2],&t2 ); - average( t1,t2,&verts[index+step] ); +static void subdivide(vector &verts, int level, int index, int step) { + if (!level) { + q3_vertex t1, t2; + average(verts[index], verts[index + step], &t1); + average(verts[index + step], verts[index + step * 2], &t2); + average(t1, t2, &verts[index + step]); return; } - average( verts[index],verts[index+step],&verts[index+step/2] ); - average( verts[index+step],verts[index+step*2],&verts[index+step+step/2] ); - average( verts[index+step/2],verts[index+step+step/2],&verts[index+step] ); - subdivide( verts,level-1,index,step/2 ); - subdivide( verts,level-1,index+step,step/2 ); + average(verts[index], verts[index + step], &verts[index + step / 2]); + average(verts[index + step], verts[index + step * 2], &verts[index + step + step / 2]); + average(verts[index + step / 2], verts[index + step + step / 2], &verts[index + step]); + subdivide(verts, level - 1, index, step / 2); + subdivide(verts, level - 1, index + step, step / 2); } -static void patchFace( Q3BSPFace *face,q3_face *q3face,bool draw,bool solid,int level ){ +static void patchFace(Q3BSPFace *face, q3_face *q3face, bool draw, bool solid, int level) { - int k,x,y; + int k, x, y; vector verts; - if( draw ){ - int step=1<patch_size[0]-1)*step+1; - int size_y=(q3face->patch_size[1]-1)*step+1; - verts.resize( size_x*size_y ); + if (draw) { + int step = 1 << level; + int size_x = (q3face->patch_size[0] - 1)*step + 1; + int size_y = (q3face->patch_size[1] - 1)*step + 1; + verts.resize(size_x*size_y); //seed initial verts - q3_vertex *t=(q3_vertex*)header.dir[10].lump+q3face->vertex; - for( y=0;yvertex; + for (y = 0; y < size_y; y += step) { + for (x = 0; x < size_x; x += step) { + verts[y*size_x + x] = *t++; } } //subdivide! - for( y=0;yt_surf; - int vert=surf->verts.size()-face->vert; + Surf *surf = face->t_surf; + int vert = surf->verts.size() - face->vert; //generate patch verts - for( k=0;kverts.push_back( -p_verts.size() ); + for (k = 0; k < size_x*size_y; ++k) { + p_verts.push_back(verts[k]); + surf->verts.push_back(p_verts.size()); // Why was there a - here } - face->n_verts+=size_x*size_y; + face->n_verts += size_x*size_y; //generate tris... - for( y=0;ytris.push_back( n ); - surf->tris.push_back( n+size_x ); - surf->tris.push_back( n+1 ); - surf->tris.push_back( n+size_x+1 ); - surf->tris.push_back( n+1 ); - surf->tris.push_back( n+size_x ); + for (y = 0; y < size_y - 1; ++y) { + int n = y*size_x + vert; + for (x = 0; x < size_x - 1; ++n, ++x) { + surf->tris.push_back(n); + surf->tris.push_back(n + size_x); + surf->tris.push_back(n + 1); + surf->tris.push_back(n + size_x + 1); + surf->tris.push_back(n + 1); + surf->tris.push_back(n + size_x); } } - face->n_tris+=(size_x-1)*(size_y-1)*6; + face->n_tris += (size_x - 1)*(size_y - 1) * 6; } - if( solid ){ + if (solid) { vector verts; - int step=1; - int size_x=q3face->patch_size[0]; - int size_y=q3face->patch_size[1]; - verts.resize( size_x*size_y ); + int step = 1; + int size_x = q3face->patch_size[0]; + int size_y = q3face->patch_size[1]; + verts.resize(size_x*size_y); //seed initial verts - q3_vertex *t=(q3_vertex*)header.dir[10].lump+q3face->vertex; - for( k=0;kvertex; + for (k = 0; k < size_x*size_y; ++k) verts[k] = *t++; //subdivide! - for( y=0;y vert_map; +static void meshFace(Q3BSPFace *face, q3_face *q3face, bool draw, bool solid) { + static map vert_map; vert_map.clear(); - int *meshverts=(int*)header.dir[11].lump+q3face->meshvert; + int *meshverts = (int*)header.dir[11].lump + q3face->meshvert; MeshCollider::Triangle ct; - ct.surface=0;ct.index=0; - for( int j=0;jn_meshverts;j+=3 ){ - for( int q=0;q<3;++q ){ - int n=meshverts[j+q]+q3face->vertex; - if( draw ){ - if( !vert_map.count( n ) ){ - vert_map[n]=face->t_surf->verts.size()-face->vert; + ct.surface = 0; ct.index = 0; + for (int j = 0; j < q3face->n_meshverts; j += 3) { + for (int q = 0; q < 3; ++q) { + int n = meshverts[j + q] + q3face->vertex; + if (draw) { + if (!vert_map.count(n)) { + vert_map[n] = face->t_surf->verts.size() - face->vert; face->t_surf->verts.push_back(n); ++face->n_verts; } - face->t_surf->tris.push_back( vert_map[n] ); + face->t_surf->tris.push_back(vert_map[n]); ++face->n_tris; } - ct.verts[q]=n; + ct.verts[q] = n; } - if( solid ) coll_tris.push_back( ct ); + if (solid) coll_tris.push_back(ct); } } -static Q3BSPBrush *createBrush( int n ){ - Q3BSPBrush *brush=d_new Q3BSPBrush; - q3_brush *q3brush=(q3_brush*)header.dir[8].lump+n; - q3_brushside *q3brushside=(q3_brushside*)header.dir[9].lump+q3brush->brushside; +static Q3BSPBrush *createBrush(int n) { + Q3BSPBrush *brush = d_new Q3BSPBrush; + q3_brush *q3brush = (q3_brush*)header.dir[8].lump + n; + q3_brushside *q3brushside = (q3_brushside*)header.dir[9].lump + q3brush->brushside; Plane p; - for( int j=0;jn_brushsides;++j ){ - q3_plane *q3plane=(q3_plane*)header.dir[2].lump+q3brushside[j].plane; - p.n=tf( q3plane->normal ); - p.d=-q3plane->distance; - brush->planes.push_back( p ); + for (int j = 0; j < q3brush->n_brushsides; ++j) { + q3_plane *q3plane = (q3_plane*)header.dir[2].lump + q3brushside[j].plane; + p.n = tf(q3plane->normal); + p.d = -q3plane->distance; + brush->planes.push_back(p); } return brush; } -Q3BSPLeaf *Q3BSPRep::createLeaf( int n ){ - q3_leaf *q3leaf=(q3_leaf*)header.dir[4].lump+n; +Q3BSPLeaf *Q3BSPRep::createLeaf(int n) { + q3_leaf *q3leaf = (q3_leaf*)header.dir[4].lump + n; - Q3BSPLeaf *leaf=d_new Q3BSPLeaf; + Q3BSPLeaf *leaf = d_new Q3BSPLeaf; - leaf->cluster=q3leaf->cluster; + leaf->cluster = q3leaf->cluster; - Vector mins( q3leaf->mins[0],q3leaf->mins[1],q3leaf->mins[2] ); - Vector maxs( q3leaf->maxs[0],q3leaf->maxs[1],q3leaf->maxs[2] ); - leaf->box=Box( tf(mins) ); - leaf->box.update( tf(maxs) ); - int *leaffaces=(int*)header.dir[5].lump+q3leaf->leafface; + Vector mins(q3leaf->mins[0], q3leaf->mins[1], q3leaf->mins[2]); + Vector maxs(q3leaf->maxs[0], q3leaf->maxs[1], q3leaf->maxs[2]); + leaf->box = Box(tf(mins)); + leaf->box.update(tf(maxs)); + int *leaffaces = (int*)header.dir[5].lump + q3leaf->leafface; - for( int k=0;kn_leaffaces;++k ){ + for (int k = 0; k < q3leaf->n_leaffaces; ++k) { - int face_n=leaffaces[k]; + int face_n = leaffaces[k]; - map::const_iterator it=q3face_map.find(face_n); - if( it!=q3face_map.end() ){ - if( it->second ) leaf->faces.push_back( it->second ); + map::const_iterator it = q3face_map.find(face_n); + if (it != q3face_map.end()) { + if (it->second) leaf->faces.push_back(it->second); continue; } - q3_face *q3face=(q3_face*)header.dir[13].lump+leaffaces[k]; + q3_face *q3face = (q3_face*)header.dir[13].lump + leaffaces[k]; - if( q3face->type==1 || q3face->type==3 ){ - if( !q3face->n_meshverts || (q3face->n_meshverts%3) ) continue; - }else if( q3face->type!=2 ) continue; + if (q3face->type == 1 || q3face->type == 3) { + if (!q3face->n_meshverts || (q3face->n_meshverts % 3)) continue; + } else if (q3face->type != 2) continue; - bool draw=true,solid=true; + bool draw = true, solid = true; - if( q3face->texture>=0 ){ - q3_tex *q3tex=(q3_tex*)header.dir[1].lump+q3face->texture; - if( !(q3tex->contents & 1) ) continue; - if( q3tex->flags & 0x84 ) draw=false; + if (q3face->texture >= 0) { + q3_tex *q3tex = (q3_tex*)header.dir[1].lump + q3face->texture; + if (!(q3tex->contents & 1)) continue; + if (q3tex->flags & 0x84) draw = false; } - if( !draw && !solid ) continue; + if (!draw && !solid) continue; - Q3BSPFace *face=0; - if( draw ){ - Surf *surf=findSurf( q3face ); - face=d_new Q3BSPFace; - face->t_surf=surf; - face->vert=surf->verts.size(); - face->tri=surf->tris.size(); - face->n_verts=face->n_tris=0; - leaf->faces.push_back( face ); - faces.push_back( face ); - q3face_map.insert( make_pair( face_n,face ) ); + Q3BSPFace *face = 0; + if (draw) { + Surf *surf = findSurf(q3face); + face = d_new Q3BSPFace; + face->t_surf = surf; + face->vert = surf->verts.size(); + face->tri = surf->tris.size(); + face->n_verts = face->n_tris = 0; + leaf->faces.push_back(face); + faces.push_back(face); + q3face_map.insert(make_pair(face_n, face)); } - if( q3face->type==2 ){ - patchFace( face,q3face,draw,solid,1 ); - }else{ - meshFace( face,q3face,draw,solid ); + if (q3face->type == 2) { + patchFace(face, q3face, draw, solid, 1); + } else { + meshFace(face, q3face, draw, solid); } } return leaf; } -Q3BSPNode *Q3BSPRep::createNode( int n ){ - q3_node *q3node=(q3_node*)header.dir[3].lump+n; - q3_plane *q3plane=(q3_plane*)header.dir[2].lump+q3node->plane; +Q3BSPNode *Q3BSPRep::createNode(int n) { + q3_node *q3node = (q3_node*)header.dir[3].lump + n; + q3_plane *q3plane = (q3_plane*)header.dir[2].lump + q3node->plane; - Q3BSPNode *node=new Q3BSPNode; + Q3BSPNode *node = new Q3BSPNode; - Vector mins( q3node->mins[0],q3node->mins[1],q3node->mins[2] ); - Vector maxs( q3node->maxs[0],q3node->maxs[1],q3node->maxs[2] ); + Vector mins(q3node->mins[0], q3node->mins[1], q3node->mins[2]); + Vector maxs(q3node->maxs[0], q3node->maxs[1], q3node->maxs[2]); - node->box=Box( tf(mins) ); - node->box.update( tf(maxs) ); - node->plane.n=tf(q3plane->normal); - node->plane.d=-q3plane->distance; + node->box = Box(tf(mins)); + node->box.update(tf(maxs)); + node->plane.n = tf(q3plane->normal); + node->plane.d = -q3plane->distance; - for( int k=0;k<2;++k ){ - if( q3node->children[k]>=0 ){ - node->nodes[k]=createNode( q3node->children[k] ); - node->leafs[k]=0; - }else{ - node->leafs[k]=createLeaf( -q3node->children[k]-1 ); - node->nodes[k]=0; + for (int k = 0; k < 2; ++k) { + if (q3node->children[k] >= 0) { + node->nodes[k] = createNode(q3node->children[k]); + node->leafs[k] = 0; + } else { + node->leafs[k] = createLeaf(-q3node->children[k] - 1); + node->nodes[k] = 0; } } return node; } -Q3BSPRep::Q3BSPRep( const string &f,float gam ):root_node(0),vis_sz(0),vis_data(0),use_lmap(true){ +Q3BSPRep::Q3BSPRep(const string &f, float gam) :root_node(0), vis_sz(0), vis_data(0), use_lmap(true) { - gamma_adj=1-gam; + gamma_adj = 1 - gam; - FILE *buf=fopen( f.c_str(),"rb" );if( !buf ) return; + FILE *buf = fopen(f.c_str(), "rb"); if (!buf) return; - fread( &header,sizeof(header),1,buf ); - if( header.magic!='PSBI' || header.version!=0x2e ){ - fclose( buf );return; + fread(&header, sizeof(header), 1, buf); + if (header.magic != 'PSBI' || header.version != 0x2e) { + fclose(buf); return; } - log( "Header OK" ); + debuglog("Header OK"); int k; //load all lumps... - for( k=0;k<17;++k ){ - if( header.dir[k].offset && header.dir[k].length ){ - fseek( buf,header.dir[k].offset,SEEK_SET ); - header.dir[k].lump=d_new char[header.dir[k].length]; - fread( header.dir[k].lump,header.dir[k].length,1,buf ); - }else{ - header.dir[k].lump=0; + for (k = 0; k < 17; ++k) { + if (header.dir[k].offset && header.dir[k].length) { + fseek(buf, header.dir[k].offset, SEEK_SET); + header.dir[k].lump = d_new char[header.dir[k].length]; + fread(header.dir[k].lump, header.dir[k].length, 1, buf); + } else { + header.dir[k].lump = 0; } } //create root of BSP tree - root_node=createNode( 0 ); + root_node = createNode(0); createCollider(); @@ -609,154 +609,154 @@ Q3BSPRep::Q3BSPRep( const string &f,float gam ):root_node(0),vis_sz(0),vis_data( createVis(); //unload all lumps... - for( k=0;k<17;++k ){ + for (k = 0; k < 17; ++k) { delete[] header.dir[k].lump; } - fclose( buf ); + fclose(buf); - use_lmap=false; - setLighting( true ); + use_lmap = false; + setLighting(true); q3face_map.clear(); } -Q3BSPRep::~Q3BSPRep(){ +Q3BSPRep::~Q3BSPRep() { delete root_node; delete[] vis_data; int k; - for( k=0;kfreeMesh( surfs[k]->mesh ); + for (k = 0; k < surfs.size(); ++k) { + gx_graphics->freeMesh(surfs[k]->mesh); delete surfs[k]; } - for( k=0;kplane.distance( r_eye )<0; - if( n->nodes[i] ) vis( n->nodes[i] ); - else r_cluster=n->leafs[i]->cluster; +void Q3BSPRep::vis(Q3BSPNode *n) { + int i = n->plane.distance(r_eye) < 0; + if (n->nodes[i]) vis(n->nodes[i]); + else r_cluster = n->leafs[i]->cluster; } -static bool cull( const Box &b,int *clip ){ - for( int n=0;n<6;++n ){ - int mask=1<=0)+(p.distance(b.corner(1))>=0)+ - (p.distance(b.corner(2))>=0)+(p.distance(b.corner(3))>=0)+ - (p.distance(b.corner(4))>=0)+(p.distance(b.corner(5))>=0)+ - (p.distance(b.corner(6))>=0)+(p.distance(b.corner(7))>=0); - if( !q ) return false; - if( q==8 ) *clip&=~mask; +static bool cull(const Box &b, int *clip) { + for (int n = 0; n < 6; ++n) { + int mask = 1 << n; + if (!(*clip & mask)) continue; + const Plane &p = r_frustum.getPlane(n); + int q = + (p.distance(b.corner(0)) >= 0) + (p.distance(b.corner(1)) >= 0) + + (p.distance(b.corner(2)) >= 0) + (p.distance(b.corner(3)) >= 0) + + (p.distance(b.corner(4)) >= 0) + (p.distance(b.corner(5)) >= 0) + + (p.distance(b.corner(6)) >= 0) + (p.distance(b.corner(7)) >= 0); + if (!q) return false; + if (q == 8) *clip &= ~mask; } return true; } -void Q3BSPRep::render( Q3BSPLeaf *l,int clip ){ - int cluster=l->cluster; - if( cluster<0 ) return; +void Q3BSPRep::render(Q3BSPLeaf *l, int clip) { + int cluster = l->cluster; + if (cluster < 0) return; - if( r_cluster>=0 ){ - if( !( vis_data[cluster*vis_sz+r_cluster/8] & (1<<(r_cluster&7))) ) return; + if (r_cluster >= 0) { + if (!(vis_data[cluster*vis_sz + r_cluster / 8] & (1 << (r_cluster & 7)))) return; } - if( clip && !cull( l->box,&clip ) ) return; + if (clip && !cull(l->box, &clip)) return; - for( int k=0;kfaces.size();++k ){ - Q3BSPFace *f=l->faces[k]; - if( Q3BSPSurf *s=f->surf ){ - if( !s->r_faces.size() ) r_surfs.push_back( s ); - s->r_faces.push_back( f ); - f->surf=0; + for (int k = 0; k < l->faces.size(); ++k) { + Q3BSPFace *f = l->faces[k]; + if (Q3BSPSurf *s = f->surf) { + if (!s->r_faces.size()) r_surfs.push_back(s); + s->r_faces.push_back(f); + f->surf = 0; } } } -void Q3BSPRep::render( Q3BSPNode *n,int clip ){ - if( clip && !cull( n->box,&clip ) ) return; +void Q3BSPRep::render(Q3BSPNode *n, int clip) { + if (clip && !cull(n->box, &clip)) return; //draw front to back... - int i=n->plane.distance( r_eye )<0; - if( n->nodes[i] ) render( n->nodes[i],clip ); - else render( n->leafs[i],clip ); - i^=1; - if( n->nodes[i] ) render( n->nodes[i],clip ); - else render( n->leafs[i],clip ); + int i = n->plane.distance(r_eye) < 0; + if (n->nodes[i]) render(n->nodes[i], clip); + else render(n->leafs[i], clip); + i ^= 1; + if (n->nodes[i]) render(n->nodes[i], clip); + else render(n->leafs[i], clip); } -void Q3BSPRep::render( Model *model,const RenderContext &rc ){ - r_eye=-model->getRenderTform() * rc.getCameraTform().v; - new( &r_frustum ) Frustum( rc.getWorldFrustum(),-model->getRenderTform() ); +void Q3BSPRep::render(Model *model, const RenderContext &rc) { + r_eye = -model->getRenderTform() * rc.getCameraTform().v; + new(&r_frustum) Frustum(rc.getWorldFrustum(), -model->getRenderTform()); - vis( root_node ); - if( r_cluster==-1 ) log( "No cluster!" ); - render( root_node,0x3f ); + vis(root_node); + if (r_cluster == -1) debuglog("No cluster!"); + render(root_node, 0x3f); - if( !r_surfs.size() ) return; + if (!r_surfs.size()) return; - gx_scene->setAmbient2( &ambient.x ); - gx_scene->setWorldMatrix( (gxScene::Matrix*)&model->getRenderTform() ); + gx_scene->setAmbient2(&ambient.x); + gx_scene->setWorldMatrix((gxScene::Matrix*)&model->getRenderTform()); int k; - for( k=0;ksetRenderState( s->brush.getRenderState() ); + for (k = 0; k < r_surfs.size(); ++k) { + Q3BSPSurf *s = r_surfs[k]; + gx_scene->setRenderState(s->brush.getRenderState()); int j; - for( j=0;jr_faces.size();++j ){ - Q3BSPFace *f=s->r_faces[j]; - gx_scene->render( s->mesh,f->vert,f->n_verts,f->tri,f->n_tris ); - f->surf=s; + for (j = 0; j < s->r_faces.size(); ++j) { + Q3BSPFace *f = s->r_faces[j]; + gx_scene->render(s->mesh, f->vert, f->n_verts, f->tri, f->n_tris); + f->surf = s; } s->r_faces.clear(); } r_surfs.clear(); } -bool Q3BSPRep::collide( const Line &line,float radius,Collision *curr_coll,const Transform &t ){ - return collider->collide( line,radius,curr_coll,t ); +bool Q3BSPRep::collide(const Line &line, float radius, Collision *curr_coll, const Transform &t) { + return collider->collide(line, radius, curr_coll, t); } -void Q3BSPRep::setAmbient( const Vector &t ){ - ambient=t; +void Q3BSPRep::setAmbient(const Vector &t) { + ambient = t; } -void Q3BSPRep::setLighting( bool lmap ){ - if( lmap==use_lmap ) return; - int fx=gxScene::FX_CONDLIGHT; - if( use_lmap=lmap ){ +void Q3BSPRep::setLighting(bool lmap) { + if (lmap == use_lmap) return; + int fx = gxScene::FX_CONDLIGHT; + if (use_lmap = lmap) { int k; - for( k=0;klm_index>=0 ){ + for (k = 0; k < surfs.size(); ++k) { + Q3BSPSurf *s = surfs[k]; + if (s->lm_index >= 0) { //has a lightmap... - s->brush.setFX( fx ); - s->brush.setTexture( 0,light_maps[s->lm_index],0 ); - if( s->texture>=0 ){ - s->brush.setTexture( 1,textures[s->texture],0 ); + s->brush.setFX(fx); + s->brush.setTexture(0, light_maps[s->lm_index], 0); + if (s->texture >= 0) { + s->brush.setTexture(1, textures[s->texture], 0); } - }else{ - s->brush.setFX( fx|gxScene::FX_EMISSIVE ); - if( s->texture>=0 ){ - s->brush.setTexture( 0,textures[s->texture],0 ); + } else { + s->brush.setFX(fx | gxScene::FX_EMISSIVE); + if (s->texture >= 0) { + s->brush.setTexture(0, textures[s->texture], 0); } } } - }else{ + } else { int k; Texture tex; - for( k=0;kbrush.setFX( fx|gxScene::FX_EMISSIVE ); - if( s->texture>=0 ){ - s->brush.setTexture( 0,textures[s->texture],0 ); - }else{ - s->brush.setTexture( 0,tex,0 ); + for (k = 0; k < surfs.size(); ++k) { + Q3BSPSurf *s = surfs[k]; + s->brush.setFX(fx | gxScene::FX_EMISSIVE); + if (s->texture >= 0) { + s->brush.setTexture(0, textures[s->texture], 0); + } else { + s->brush.setTexture(0, tex, 0); } - s->brush.setTexture( 1,tex,0 ); + s->brush.setTexture(1, tex, 0); } } } diff --git a/blitz3d/surface.cpp b/blitz3d/surface.cpp index d74879d..292f127 100644 --- a/blitz3d/surface.cpp +++ b/blitz3d/surface.cpp @@ -69,7 +69,7 @@ void Surface::updateNormals(){ const Vector &v1=vertices[t.verts[1]].coords; const Vector &v2=vertices[t.verts[2]].coords; Vector n=(v1-v0).cross(v2-v0); - if( n.length()<= FLT_FLT_EPSILON ) continue; + if( n.length()<= FLT_EPSILON ) continue; n.normalize(); norm_map[v0]+=n; norm_map[v1]+=n; diff --git a/blitz3d/terrainrep.cpp b/blitz3d/terrainrep.cpp index 218a6f5..6a48ded 100644 --- a/blitz3d/terrainrep.cpp +++ b/blitz3d/terrainrep.cpp @@ -15,7 +15,7 @@ static const TerrainRep *curr; static Frustum frustum; static int out_cnt,proc_cnt,clip_cnt; -static float proj_epsilon= FLT_FLT_EPSILON; //.01f; +static float proj_epsilon= FLT_EPSILON; //.01f; struct TerrainRep::Cell{ unsigned char height; @@ -259,7 +259,7 @@ void TerrainRep::insert( Tri *t ){ Vector v=Vector( verts[t->v1].v+verts[t->v2].v )/2; // float d=eye_plane.distance( v ); float d=eye_vec.distance( v ); - if( dproj_err=errors[t->id].error/d; if( t->proj_err>proj_epsilon ){ tri_que.push( t ); @@ -344,7 +344,7 @@ TerrainRep::Error TerrainRep::calcErr( int id,const Vert &v0,const Vert &v1,cons Vert tv( (v1.x+v2.x)/2,(v1.z+v2.z)/2 ); float e=fabs(tv.v.y-(v1.v.y+v2.v.y)/2); - et.error= e>=1 ? 255 : ceil( (e- FLT_FLT_EPSILON)*255.0f ); + et.error= e>=1 ? 255 : ceil( (e- FLT_EPSILON)*255.0f ); Error el=calcErr( id*2,tv,v2,v0 ); Error er=calcErr( id*2+1,tv,v0,v1 ); @@ -382,7 +382,7 @@ TerrainRep::Error TerrainRep::calcErr( int id,int x,int z,const Vert &v0,const V Vert tv( (v1.x+v2.x)/2,(v1.z+v2.z)/2 ); float e=fabs(tv.v.y-(v1.v.y+v2.v.y)/2); - et.error= e>=1 ? 255 : ceil( (e- FLT_FLT_EPSILON)*255.0f ); + et.error= e>=1 ? 255 : ceil( (e- FLT_EPSILON)*255.0f ); Error el=calcErr( id*2,x,z,tv,v2,v0 ); Error er=calcErr( id*2+1,x,z,tv,v0,v1 ); diff --git a/blitz3d/texture.cpp b/blitz3d/texture.cpp index 87ddcc0..be3f904 100644 --- a/blitz3d/texture.cpp +++ b/blitz3d/texture.cpp @@ -9,187 +9,187 @@ extern gxScene *gx_scene; extern gxGraphics *gx_graphics; -struct Filter{ +struct Filter { string t; int flags; - Filter( const string &t,int flags ):t(t),flags(flags){ + Filter(const string &t, int flags) :t(t), flags(flags) { } }; static vector filters; -static int filterFile( const string &t,int flags ){ +static int filterFile(const string &t, int flags) { //check filters... - string l=tolower(t); - for( int k=0;k tex_frames; - int tex_blend,tex_flags; + int tex_blend, tex_flags; bool transparent; - float sx,sy,tx,ty,rot; - bool mat_used,mat_valid; + float sx, sy, tx, ty, rot; + bool mat_used, mat_valid; gxScene::Matrix matrix; - Rep( int w,int h,int flags,int cnt ): - ref_cnt(1),cached_tex( w,h,flags,cnt ), - tex_blend(gxScene::BLEND_MULTIPLY),tex_flags(0), - sx(1),sy(1),tx(0),ty(0),rot(0),mat_used(false){ - tex_frames=cached_tex.getFrames(); - transparent= + Rep(int w, int h, int flags, int cnt) : + ref_cnt(1), cached_tex(w, h, flags, cnt), + tex_blend(gxScene::BLEND_MULTIPLY), tex_flags(0), + sx(1), sy(1), tx(0), ty(0), rot(0), mat_used(false) { + tex_frames = cached_tex.getFrames(); + transparent = (flags & gxCanvas::CANVAS_TEX_ALPHA) && !(flags & gxCanvas::CANVAS_TEX_MASK); - memset( &matrix,0,sizeof( matrix ) ); + memset(&matrix, 0, sizeof(matrix)); } - Rep( const string &f,int flags,int w,int h,int first,int cnt ): - ref_cnt(1),cached_tex( f,flags,w,h,first,cnt ), - tex_blend(gxScene::BLEND_MULTIPLY),tex_flags(0), - sx(1),sy(1),tx(0),ty(0),rot(0),mat_used(false){ - tex_frames=cached_tex.getFrames(); - transparent= + Rep(const string &f, int flags, int w, int h, int first, int cnt) : + ref_cnt(1), cached_tex(f, flags, w, h, first, cnt), + tex_blend(gxScene::BLEND_MULTIPLY), tex_flags(0), + sx(1), sy(1), tx(0), ty(0), rot(0), mat_used(false) { + tex_frames = cached_tex.getFrames(); + transparent = (flags & gxCanvas::CANVAS_TEX_ALPHA) && !(flags & gxCanvas::CANVAS_TEX_MASK); - memset( &matrix,0,sizeof( matrix ) ); + memset(&matrix, 0, sizeof(matrix)); } - Rep( const Rep &t ): - ref_cnt(1),cached_tex(t.cached_tex),tex_frames(t.tex_frames), - tex_blend(t.tex_blend),tex_flags(t.tex_flags), - sx(t.sx),sy(t.sy),tx(t.tx),ty(t.ty),rot(t.rot), - mat_used(t.mat_used),mat_valid(t.mat_valid),matrix(t.matrix), - transparent(t.transparent){ + Rep(const Rep &t) : + ref_cnt(1), cached_tex(t.cached_tex), tex_frames(t.tex_frames), + tex_blend(t.tex_blend), tex_flags(t.tex_flags), + sx(t.sx), sy(t.sy), tx(t.tx), ty(t.ty), rot(t.rot), + mat_used(t.mat_used), mat_valid(t.mat_valid), matrix(t.matrix), + transparent(t.transparent) { } }; -Texture::Texture():rep(0){ +Texture::Texture() :rep(0) { } -Texture::Texture( const string &f,int flags ){ - flags=filterFile( f,flags )|gxCanvas::CANVAS_TEXTURE; - if( flags & gxCanvas::CANVAS_TEX_MASK ) flags|=gxCanvas::CANVAS_TEX_RGB|gxCanvas::CANVAS_TEX_ALPHA; - rep=d_new Rep( f,flags,0,0,0,1 ); +Texture::Texture(const string &f, int flags) { + flags = filterFile(f, flags) | gxCanvas::CANVAS_TEXTURE; + if (flags & gxCanvas::CANVAS_TEX_MASK) flags |= gxCanvas::CANVAS_TEX_RGB | gxCanvas::CANVAS_TEX_ALPHA; + rep = d_new Rep(f, flags, 0, 0, 0, 1); } -Texture::Texture( const string &f,int flags,int w,int h,int first,int cnt ){ - flags=filterFile( f,flags )|gxCanvas::CANVAS_TEXTURE; - if( flags & gxCanvas::CANVAS_TEX_MASK ) flags|=gxCanvas::CANVAS_TEX_RGB|gxCanvas::CANVAS_TEX_ALPHA; - rep=d_new Rep( f,flags,w,h,first,cnt ); +Texture::Texture(const string &f, int flags, int w, int h, int first, int cnt) { + flags = filterFile(f, flags) | gxCanvas::CANVAS_TEXTURE; + if (flags & gxCanvas::CANVAS_TEX_MASK) flags |= gxCanvas::CANVAS_TEX_RGB | gxCanvas::CANVAS_TEX_ALPHA; + rep = d_new Rep(f, flags, w, h, first, cnt); } -Texture::Texture( int w,int h,int flags,int cnt ){ - flags|=gxCanvas::CANVAS_TEXTURE; - if( flags & gxCanvas::CANVAS_TEX_MASK ) flags|=gxCanvas::CANVAS_TEX_RGB|gxCanvas::CANVAS_TEX_ALPHA; - rep=d_new Rep( w,h,flags,cnt ); +Texture::Texture(int w, int h, int flags, int cnt) { + flags |= gxCanvas::CANVAS_TEXTURE; + if (flags & gxCanvas::CANVAS_TEX_MASK) flags |= gxCanvas::CANVAS_TEX_RGB | gxCanvas::CANVAS_TEX_ALPHA; + rep = d_new Rep(w, h, flags, cnt); } -Texture::Texture( const Texture &t ): -rep(t.rep){ - if( rep ) ++rep->ref_cnt; +Texture::Texture(const Texture &t) : + rep(t.rep) { + if (rep) ++rep->ref_cnt; } -Texture::~Texture(){ - if( rep && !--rep->ref_cnt ) delete rep; +Texture::~Texture() { + if (rep && !--rep->ref_cnt) delete rep; } -Texture &Texture::operator=( const Texture &t ){ - if( t.rep ) ++t.rep->ref_cnt; - if( rep && !--rep->ref_cnt ) delete rep; - rep=t.rep; +Texture &Texture::operator=(const Texture &t) { + if (t.rep) ++t.rep->ref_cnt; + if (rep && !--rep->ref_cnt) delete rep; + rep = t.rep; return *this; } -void Texture::setScale( float u_scale,float v_scale ){ - if( !rep ) return; - rep->sx=u_scale;rep->sy=v_scale; - rep->mat_valid=false; - rep->mat_used=true; +void Texture::setScale(float u_scale, float v_scale) { + if (!rep) return; + rep->sx = u_scale; rep->sy = v_scale; + rep->mat_valid = false; + rep->mat_used = true; } -void Texture::setRotation( float angle ){ - if( !rep ) return; - rep->rot=angle; - rep->mat_valid=false; - rep->mat_used=true; +void Texture::setRotation(float angle) { + if (!rep) return; + rep->rot = angle; + rep->mat_valid = false; + rep->mat_used = true; } -void Texture::setPosition( float u_pos,float v_pos ){ - if( !rep ) return; - rep->tx=u_pos; - rep->ty=v_pos; - rep->mat_valid=false; - rep->mat_used=true; +void Texture::setPosition(float u_pos, float v_pos) { + if (!rep) return; + rep->tx = u_pos; + rep->ty = v_pos; + rep->mat_valid = false; + rep->mat_used = true; } -void Texture::setBlend( int blend ){ - if( !rep ) return; - rep->tex_blend=blend; +void Texture::setBlend(int blend) { + if (!rep) return; + rep->tex_blend = blend; } -void Texture::setFlags( int flags ){ - if( !rep ) return; - rep->tex_flags=flags; +void Texture::setFlags(int flags) { + if (!rep) return; + rep->tex_flags = flags; } -bool Texture::isTransparent()const{ +bool Texture::isTransparent()const { return rep ? rep->transparent : false; } -gxCanvas *Texture::getCanvas( int n )const{ - return rep && n>=0 && ntex_frames.size() ? rep->tex_frames[n] : 0; +gxCanvas *Texture::getCanvas(int n)const { + return rep && n >= 0 && n < rep->tex_frames.size() ? rep->tex_frames[n] : 0; } -int Texture::getCanvasFlags()const{ +int Texture::getCanvasFlags()const { return rep && rep->tex_frames.size() ? rep->tex_frames[0]->getFlags() : 0; } -CachedTexture *Texture::getCachedTexture()const{ +CachedTexture *Texture::getCachedTexture()const { return rep ? &rep->cached_tex : 0; } -int Texture::getBlend()const{ +int Texture::getBlend()const { return rep ? rep->tex_blend : 0; } -int Texture::getFlags()const{ +int Texture::getFlags()const { return rep ? rep->tex_flags : 0; } -const gxScene::Matrix *Texture::getMatrix()const{ - if( !rep || !rep->mat_used ) return 0; - if( !rep->mat_valid ){ - float c=cos(rep->rot),s=sin(rep->rot); - rep->matrix.elements[0][0]=c*rep->sx; - rep->matrix.elements[1][0]=s*rep->sx; - rep->matrix.elements[0][1]=-s*rep->sy; - rep->matrix.elements[1][1]=c*rep->sy; - rep->matrix.elements[2][0]=rep->tx; - rep->matrix.elements[2][1]=rep->ty; - rep->mat_valid=true; +const gxScene::Matrix *Texture::getMatrix()const { + if (!rep || !rep->mat_used) return 0; + if (!rep->mat_valid) { + float c = cos(rep->rot), s = sin(rep->rot); + rep->matrix.elements[0][0] = c*rep->sx; + rep->matrix.elements[1][0] = s*rep->sx; + rep->matrix.elements[0][1] = -s*rep->sy; + rep->matrix.elements[1][1] = c*rep->sy; + rep->matrix.elements[2][0] = rep->tx; + rep->matrix.elements[2][1] = rep->ty; + rep->mat_valid = true; } return &rep->matrix; } -bool Texture::operator<( const Texture &t )const{ - if( rep && t.rep ) return rep->cached_texcached_tex; - return repcached_tex < t.rep->cached_tex; + return rep < t.rep; } -void Texture::clearFilters(){ +void Texture::clearFilters() { filters.clear(); } -void Texture::addFilter( const string &t,int flags ){ - filters.push_back( Filter( tolower(t),flags ) ); +void Texture::addFilter(const string &t, int flags) { + filters.push_back(Filter(tolower(t), flags)); } diff --git a/blitz3d/world.cpp b/blitz3d/world.cpp index ac09812..fcae0dd 100644 --- a/blitz3d/world.cpp +++ b/blitz3d/world.cpp @@ -257,7 +257,7 @@ void World::collide( Object *src ){ }else if( n_hit==1 ){ if( planes[0].distance(nv)>=0 ){ dv=nv;n_hit=0; - }else if( fabs( planes[0].n.dot( coll_plane.n ) )<1-FLT_FLT_EPSILON ){ + }else if( fabs( planes[0].n.dot( coll_plane.n ) )<1-FLT_EPSILON ){ dv=coll_plane.intersect( planes[0] ).nearest( dv ); }else{ //SQUISHED! @@ -277,11 +277,11 @@ void World::collide( Object *src ){ if( coll_info->response==COLLISION_RESPONSE_SLIDE ){ float d=dd.length(); - if( d<= FLT_FLT_EPSILON ){ dv=sv;break; } + if( d<= FLT_EPSILON ){ dv=sv;break; } if( d>td ) dd*=td/d; }else if( coll_info->response==COLLISION_RESPONSE_SLIDEXZ ){ float d=Vector( dd.x,0,dd.z ).length(); - if( d<= FLT_FLT_EPSILON ){ dv=sv;break; } + if( d<= FLT_EPSILON ){ dv=sv;break; } if( d>td_xz ) dd*=td_xz/d; } diff --git a/blitzbasic/bin/debugger.dll b/blitzbasic/bin/debugger.dll index 2ae3e95..c37fdcc 100644 Binary files a/blitzbasic/bin/debugger.dll and b/blitzbasic/bin/debugger.dll differ diff --git a/blitzide/blitzide.vcxproj b/blitzide/blitzide.vcxproj deleted file mode 100644 index 6006d5a..0000000 --- a/blitzide/blitzide.vcxproj +++ /dev/null @@ -1,320 +0,0 @@ - - - - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - - - Debug - Win32 - - - Release - Win32 - - - Template - Win32 - - - - - - MFCProj - {B61D8348-B715-42B8-A759-C7BBB0C8CD4D} - 10.0.10586.0 - - - - Application - v140 - - - Application - v140 - Static - MultiByte - - - Application - v140 - Static - MultiByte - - - Application - v140 - Static - MultiByte - - - Application - v140 - Static - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - .\blitzide___Win32_Blitz2DRelease\ - .\blitzide___Win32_Blitz2DRelease\ - false - - - .\blitzide___Win32_Blitz3DRelease\ - .\blitzide___Win32_Blitz3DRelease\ - false - - - ..\#Build\$(ProjectName)\$(ConfigurationName)\ - ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ - false - - - .\Release\ - .\Release\ - false - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - .\blitzide___Win32_Blitz2DRelease\ - .\blitzide___Win32_Blitz2DRelease\blitzide.pch - Use - stdafx.h - .\blitzide___Win32_Blitz2DRelease\ - .\blitzide___Win32_Blitz2DRelease\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\blitzide___Win32_Blitz2DRelease\blitzide.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\blitzide___Win32_Blitz2DRelease\blitzide.bsc - - - true - false - Windows - false - ..\..\release\blitz2drelease\bin\ide.exe - winmm.lib;%(AdditionalDependencies) - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - _WINDOWS;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\blitzide___Win32_Blitz3DRelease\ - .\blitzide___Win32_Blitz3DRelease\blitzide.pch - - .\blitzide___Win32_Blitz3DRelease\ - .\blitzide___Win32_Blitz3DRelease\ - StdCall - - - true - NDEBUG;%(PreprocessorDefinitions) - .\blitzide___Win32_Blitz3DRelease\blitzide.tlb - true - Win32 - - - 0x0409 - NDEBUG;PRO;%(PreprocessorDefinitions) - - - true - .\blitzide___Win32_Blitz3DRelease\blitzide.bsc - - - true - false - Windows - false - ../_release/bin/ide.exe - winmm.lib;%(AdditionalDependencies) - - - - - MultiThreadedDebug - Default - false - Disabled - true - Level3 - true - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\blitzide.pch - Use - stdafx.h - .\Debug\ - .\Debug\ - EnableFastChecks - - - true - _DEBUG;%(PreprocessorDefinitions) - .\Debug\blitzide.tlb - true - Win32 - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - true - .\Debug\blitzide.bsc - - - true - true - Windows - afxmem.obj;%(IgnoreSpecificDefaultLibraries) - ..\blitzbasic\bin\ide.exe - /FIXED:NO - ddraw.lib;dinput.lib;dsound.lib;dplayx.lib;dxguid.lib;winmm.lib;%(AdditionalDependencies) - - - - - MultiThreaded - AnySuitable - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - .\Release\ - .\Release\blitzide.pch - Use - stdafx.h - .\Release\ - .\Release\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\Release\blitzide.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\Release\blitzide.bsc - - - true - false - Windows - false - ..\blitzbasic\bin\ide.exe - winmm.lib;%(AdditionalDependencies) - - - - - - - - - - - - - Create - stdafx.h - Create - stdafx.h - Create - stdafx.h - Create - stdafx.h - - - - - - - - - - - - - - - - - - - - - - - - - - {3e355353-96d8-4aaf-bf95-8e6ca0d4b1ba} - false - - - - - - \ No newline at end of file diff --git a/blitzide/editor.cpp b/blitzide/editor.cpp deleted file mode 100644 index faddcad..0000000 --- a/blitzide/editor.cpp +++ /dev/null @@ -1,884 +0,0 @@ - -#include "stdafx.h" -#include "blitzide.h" -#include "editor.h" - -static bool locked; - -#ifdef DEMO -static const int TEXTLIMIT=16384; -#else -static const int TEXTLIMIT=1024*1024-1; -#endif - -static const UINT wm_Find=RegisterWindowMessage( FINDMSGSTRING ); - -IMPLEMENT_DYNAMIC( Editor,CWnd ) -BEGIN_MESSAGE_MAP( Editor,CWnd ) - ON_WM_CREATE() - ON_WM_SIZE() - ON_WM_SETFOCUS() - ON_WM_KILLFOCUS() - ON_WM_PAINT() - ON_WM_MOUSEMOVE() - ON_WM_LBUTTONDOWN() - ON_WM_LBUTTONUP() - ON_CONTROL( EN_CHANGE,1,en_change ) - ON_CONTROL( EN_UPDATE,1,en_update ) - ON_NOTIFY( EN_SELCHANGE,1,en_selchange ) - ON_NOTIFY( EN_PROTECTED,1,en_protected ) - ON_NOTIFY( EN_MSGFILTER,1,en_msgfilter ) - ON_REGISTERED_MESSAGE( wm_Find,onFind ) -END_MESSAGE_MAP() - -static int blink; -static set keyWordSet; -static map keyWordMap; - -static bool isid( int c ){ - return isalnum(c)||c=='_'; -} - -static bool isfmt( int ch,int nxt ){ - return ch==';' || ch=='\"' || isalpha(ch) || isdigit(ch) || (ch=='$' && isxdigit(nxt)); -} - -static string rtfbgr( int bgr ){ - return "\\red"+itoa(bgr&0xff)+"\\green"+itoa((bgr>>8)&0xff)+"\\blue"+itoa((bgr>>16)&0xff)+';'; -} - -DWORD Editor::streamIn( LPBYTE buff,LONG cnt,LONG *done ){ - int n=0; - while( npeek()==EOF ) break; - is_curs=0;is_line="";int c=0; - for(;;){ - c=is_stream->get(); - if( c=='\r' || c=='\n' || c==EOF ) break; - if( c=='\\' || c=='{' || c=='}' ) is_line+='\\'; - is_line+=(char)c; - } - formatStreamLine();++is_linenum; - if( c=='\r' && is_stream->peek()=='\n' ) is_stream->get(); - if( is_stream->peek()==EOF ) is_line+='}'; - } - int sz=is_line.size()-is_curs; - if( n+sz>cnt ) sz=cnt-n; - memcpy( buff+n,is_line.data()+is_curs,sz ); - is_curs+=sz;n+=sz; - } - *done=n; - return 0; -} - -DWORD CALLBACK Editor::streamIn( DWORD cookie,LPBYTE buff,LONG cnt,LONG *done ){ - Editor *e=(Editor*)cookie; - return e->streamIn( buff,cnt,done ); -} - -DWORD CALLBACK Editor::streamOut( DWORD cookie,LPBYTE buff,LONG cnt,LONG *done ){ - ostream *out=(ostream*)cookie; - out->write( (char*)buff,cnt ); - *done=cnt;return 0; -} - -Editor::Editor( EditorListener *l ): -listener(l),sizing(false),tabber_width(170), -fmtBusy(false),findOnly(false),found(false), -finder(0),selStart(0),selEnd(0), -findFlags(0),lineToFmt(-1){ - findBuff[0]=replaceBuff[0]=0; - if( !blink ) blink=GetCaretBlinkTime(); - funcList.setListener( this ); - typeList.setListener( this ); - labsList.setListener( this ); -} - -Editor::~Editor(){ -} - -void Editor::resized(){ - CRect r; - GetClientRect( &r ); - int x=0,y=0,w=r.Width(),h=r.Height(); - if( w ){ - if( tabber_width<4 ) tabber_width=4; - else if( w-64>0 && tabber_width>w-64 ) tabber_width=w-64; - } - editCtrl.MoveWindow( x,y,w-tabber_width-4,y+h ); - tabber.MoveWindow( w-tabber_width+4,y,tabber_width-4,y+h ); -} - -void Editor::OnPaint(){ - CPaintDC dc( this ); - - CRect r; - GetClientRect( &r ); - int x=0,y=0,w=r.Width(),h=r.Height(); - - x=w-tabber_width-4; - w=8; - - CBrush br( GetSysColor( COLOR_3DFACE ) ); - CRect tr( x,y,x+w,y+h ); - dc.FillRect( &tr,&br ); - -// CRect ar( x,y,x+w,y+w ); -// dc.DrawFrameControl( &ar,DFC_SCROLL,DFCS_SCROLLRIGHT ); -// y+=w;h-=w; - - CRect dr( x+2,y+2,x+w-2,y+h-2 ); - dc.DrawEdge( &dr,EDGE_RAISED,BF_RECT ); -} - -void Editor::OnMouseMove( UINT flags,CPoint p ){ - CWnd::OnMouseMove( flags,p ); - - CRect r; - GetClientRect( &r ); - if( sizing ){ - int dx=p.x-point.x,dy=p.y-point.y; - tabber_width-=dx; - resized();Invalidate(); - point=p; - }else if( abs(p.x-(r.Width()-tabber_width))<4 ){ - SetCursor( AfxGetApp()->LoadStandardCursor( IDC_SIZEWE ) ); - }else{ - SetCursor( AfxGetApp()->LoadStandardCursor( IDC_ARROW ) ); - } -} - -void Editor::OnSize( UINT type,int sw,int sh ){ - CWnd::OnSize( type,sw,sh ); - - resized(); -} - -void Editor::OnLButtonDown( UINT flags,CPoint p ){ - - CRect r; - GetClientRect( &r ); - - if( abs(p.x-(r.Width()-tabber_width))<4 ){ - point=p; - SetCapture(); - SetCursor( AfxGetApp()->LoadStandardCursor( IDC_SIZEWE ) ); - sizing=true; - } -} - -void Editor::OnLButtonUp( UINT flags,CPoint p ){ - if( sizing ){ - SetCursor( AfxGetApp()->LoadStandardCursor( IDC_ARROW ) ); - ReleaseCapture(); - sizing=false; - } - SetFocus(); -} - -int Editor::OnCreate( LPCREATESTRUCT cs ){ - CWnd::OnCreate( cs ); - - CHARFORMAT fmt;fmt.cbSize=sizeof( fmt ); - fmt.dwMask=CFM_COLOR|CFM_PROTECTED; - fmt.dwEffects=CFE_PROTECTED; - fmt.crTextColor=prefs.rgb_default; - - PARAFORMAT pf; - memset( &pf,0,sizeof( pf ) ); - pf.cbSize=sizeof( pf ); - pf.dwMask=PFM_TABSTOPS; - pf.cTabCount=MAX_TAB_STOPS; - int tabTwips=1440*8/GetDeviceCaps( ::GetDC(0),LOGPIXELSX ) * prefs.edit_tabs; - for( int k=0;k>16)&0xffff,col=n&0xffff; - int pos=editCtrl.LineIndex( row )+col; - editCtrl.SetSel( pos,pos ); -} - -string Editor::getName()const{ - return name; -} - -bool Editor::getText( ostream &out ){ - fixFmt(true); - EDITSTREAM es; - es.dwCookie=(DWORD)&out; - es.dwError=0; - es.pfnCallback=streamOut; - editCtrl.StreamOut( SF_TEXT,es ); - return es.dwError==0; -} - -void Editor::cut(){ - editCtrl.Cut(); -} - -void Editor::copy(){ - editCtrl.Copy(); -} - -void Editor::paste(){ - editCtrl.PasteSpecial( CF_TEXT,0 ); -} - -bool Editor::canCutCopy(){ - getSel();return selStart!=selEnd; -} - -bool Editor::canPaste(){ - return editCtrl.CanPaste() ? true : false; -} - -void Editor::print(){ - - static const int MARG=720; //1440=1 inch - - CPrintDialog dlg(false); - int e=dlg.DoModal();if( e==IDCANCEL ) return; - - HDC hdc=dlg.GetPrinterDC(); - if( !hdc ){ - MessageBox( "Error printing" ); - return; - } - - int hr=GetDeviceCaps(hdc,HORZRES),vr=GetDeviceCaps(hdc,VERTRES); - int px=GetDeviceCaps(hdc,LOGPIXELSX),py=GetDeviceCaps(hdc,LOGPIXELSY); - - SetMapMode(hdc,MM_TEXT); - - FORMATRANGE fr={0}; - fr.hdc=fr.hdcTarget=hdc; - fr.rcPage.left=fr.rcPage.top=0; - fr.rcPage.right=(hr/px)*1440; - fr.rcPage.bottom=(vr/py)*1440; - - //margins - fr.rc.left=fr.rcPage.left+MARG; - fr.rc.top=fr.rcPage.top+MARG; - fr.rc.right=fr.rcPage.right-MARG; - fr.rc.bottom=fr.rcPage.bottom-MARG; - - char buff[MAX_PATH]; - strcpy( buff,name.c_str() ); - - DOCINFO di={sizeof(di)}; - di.lpszDocName=buff; - - getSel(); - int start=selStart,end=selEnd; - if( start==end ){ start=0;end=editCtrl.GetTextLength(); } - - StartDoc(hdc,&di); - while( startm_fr.lpstrFindWhat=findBuff; - finder->m_fr.wFindWhatLen=256; - finder->m_fr.lpstrReplaceWith=replaceBuff; - finder->m_fr.wReplaceWithLen=256; - finder->Create( findOnly=true,0,0,FR_HIDEUPDOWN,this ); - found=false; -} - -void Editor::replace(){ - if( finder ) return; - finder=new CFindReplaceDialog(); - finder->m_fr.lpstrFindWhat=findBuff; - finder->m_fr.wFindWhatLen=256; - finder->m_fr.lpstrReplaceWith=replaceBuff; - finder->m_fr.wReplaceWithLen=256; - finder->Create( findOnly=false,0,0,FR_HIDEUPDOWN,this ); - found=false; -} - -bool Editor::canFind(){ - return finder==0; -} - -bool Editor::findNext( bool wrap ){ - long start,end; - editCtrl.GetSel( start,end ); - - FINDTEXTEX t; - memset( &t,0,sizeof( t ) ); - t.chrg.cpMin=end; - t.chrg.cpMax=-1; - t.lpstrText=findBuff; - if( editCtrl.FindText( findFlags,&t )>=0 ){ - editCtrl.SetSel( t.chrgText.cpMin,t.chrgText.cpMax ); - return true; - } - if( !wrap ) return false; - t.chrg.cpMin=0; - t.chrg.cpMax=end; - if( editCtrl.FindText( findFlags,&t )>=0 ){ - editCtrl.SetSel( t.chrgText.cpMin,t.chrgText.cpMax ); - return true; - } - string s( "Can't find \"" );s+=findBuff;s+='\"'; - MessageBox( s.c_str(),"Text not found" ); - if( finder ) finder->SetFocus(); - return false; -} - -void Editor::hilight( int pos ){ - int row=(pos>>16)&0xffff,col=pos&0xffff; - pos=editCtrl.LineIndex( row )+col; - - editCtrl.HideSelection( true,false ); - getSel(); - bool quote=false; - int end=pos,len=editCtrl.GetTextLength(); - while( endline.size() ) return ""; - - //ok, scan back until we have an isapha char preceded by a nonalnum/non '_' char - for(;;){ - while( pos>0 && ( !isalpha(line[pos]) || isid(line[pos-1]) ) ) --pos; - if( !isalpha(line[pos]) ) return ""; - int end=pos;while( endDestroyWindow(); - finder=0; -} - -LRESULT Editor::onFind( WPARAM w,LPARAM l ){ - if( !finder ) return 0; - - findFlags=0; - if( finder->MatchCase() ) findFlags|=FR_MATCHCASE; - if( finder->MatchWholeWord() ) findFlags|=FR_WHOLEWORD; - strcpy( findBuff,finder->GetFindString() ); - strcpy( replaceBuff,finder->GetReplaceString() ); - - if( finder->FindNext() ){ - found=findNext( true ); - if( found && findOnly ) endFind(); - }else if( finder->ReplaceCurrent() ){ - if( found ) editCtrl.ReplaceSel( replaceBuff,true ); - found=findNext( true ); - }else if( finder->ReplaceAll() ){ - int cnt=0; - editCtrl.HideSelection( true,false ); - editCtrl.SetSel( 0,0 ); - while( findNext( false ) ){ - editCtrl.ReplaceSel( replaceBuff,true ); - ++cnt; - } - endFind(); - char buff[32];itoa( cnt,buff,10 ); - string s( buff );s+=" occurances replaced"; - MessageBox( s.c_str(),"Replace All Done" ); - editCtrl.HideSelection( false,false ); - } - - if( finder && finder->IsTerminating() ) endFind(); - - return 0; -} - -void Editor::caret(){ - if( !prefs.edit_blkcursor ) return; - long start,end; - editCtrl.GetSel( start,end ); - if( start==end ){ - editCtrl.CreateSolidCaret( 8,13 ); - editCtrl.ShowCaret(); - }else editCtrl.HideCaret(); -} - -void Editor::OnSetFocus( CWnd *wnd ){ - if( prefs.edit_blkcursor ) SetCaretBlinkTime( 200 ); - editCtrl.SetFocus(); - caret(); -} - -void Editor::OnKillFocus( CWnd *wnd ){ - CWnd::OnKillFocus( wnd ); - fixFmt(true); -} - -string Editor::getLine( int line ){ - int idx1=editCtrl.LineIndex( line ); - int idx2=editCtrl.LineIndex( line+1 );if( idx2==-1 ) idx2=editCtrl.GetTextLength(); - int len=idx2-idx1; - char *buff=new char[ len>3 ? len+1 : 4 ]; - *(int*)buff=len; - int out=editCtrl.GetLine( line,buff ); - buff[len]=0; - string t=string( buff ); - delete [] buff; - return t; -} - -void Editor::funcSelected( int line ){ - int pos=editCtrl.LineIndex( line ); - editCtrl.SetSel( editCtrl.GetTextLength()-1,editCtrl.GetTextLength()-1 ); - editCtrl.SetSel( pos,pos ); - SetFocus(); -} - -void Editor::currentSet( Tabber *tabber,int index ){ - SetFocus(); -} - -void Editor::cursorMoved(){ - listener->cursorMoved( this ); -} - -void Editor::en_update(){ - caret(); -} - -void Editor::en_msgfilter( NMHDR *nmhdr,LRESULT *result ){ - if( locked || fmtBusy ){ *result=1;return; } - - *result=0; - getSel(); - - MSGFILTER *msg=(MSGFILTER*)nmhdr; - - - if( msg->msg==WM_RBUTTONDOWN ){ - - CPoint p( LOWORD(msg->lParam),HIWORD(msg->lParam) ); - - ClientToScreen( &p ); - - CMenu *menu=blitzIDE.mainFrame->GetMenu(); - - CMenu *edit=menu->GetSubMenu(1); - - edit->TrackPopupMenu( TPM_LEFTALIGN,p.x,p.y,blitzIDE.mainFrame ); - - }else if( msg->msg==WM_CHAR ){ - if( msg->wParam=='\t' ){ - int lineStart=editCtrl.LineFromChar( selStart ); - int lineEnd=editCtrl.LineFromChar( selEnd ); - if( lineEnd<=lineStart ) return; - editCtrl.HideSelection( true,false ); - if( GetAsyncKeyState( VK_SHIFT )&0x80000000 ){ - char buff[4]; - for( int line=lineStart;linewParam==13 ){ - if( selStart!=selEnd ) return; - int k; - int ln=editCtrl.LineFromChar( selStart ); - int pos=selStart-editCtrl.LineIndex( ln ); - string line=getLine( ln );if( pos>line.size() ) return; - for( k=0;k0 ){ - begin-=delta; - funcList.relocate( begin,delta ); - typeList.relocate( begin,delta ); - labsList.relocate( begin,delta ); - funcList.remove( begin,end ); - typeList.remove( begin,end ); - labsList.remove( begin,end ); - }else if( delta<0 ){ - int t=end-delta; - funcList.remove( begin,t ); - typeList.remove( begin,t ); - labsList.remove( begin,t ); - funcList.relocate( t,delta ); - typeList.relocate( t,delta ); - labsList.relocate( t,delta ); - }else{ - funcList.remove( begin,end ); - typeList.remove( begin,end ); - labsList.remove( begin,end ); - } - - for( int n=begin;n=editCtrl.GetLineCount() ) return; - - lineToFmt=-1; - int pos=editCtrl.LineIndex( ln ); - string tline=getLine( ln ); - string line=tolower( tline ); - - int *cf=0; - string rep; - for( int k=0;kpos+k ){ - map::iterator it=keyWordMap.find( line.substr( from,k-from ) ); - if( it!=keyWordMap.end() ){ - rep=it->second;cf=&prefs.rgb_keyword; - } - }else lineToFmt=ln; - }else if( c=='$' && k+1 codeFrags,dataFrags; +static vector codeFrags, dataFrags; //name of function static string funcLabel; -static void resetRegs(){ - for( int n=1;n<=NUM_REGS;++n ) regUsed[n]=false; +static void resetRegs() { + for (int n = 1; n <= NUM_REGS; ++n) regUsed[n] = false; } -static int allocReg( int n ){ - if( !n || regUsed[n] ){ - for( n=NUM_REGS;n>=1 && regUsed[n];--n ){} - if( !n ) return 0; +static int allocReg(int n) { + if (!n || regUsed[n]) { + for (n = NUM_REGS; n >= 1 && regUsed[n]; --n) {} + if (!n) return 0; } - regUsed[n]=true; + regUsed[n] = true; return n; } -static void freeReg( int n ){ - regUsed[n]=false; +static void freeReg(int n) { + regUsed[n] = false; } -static void pushReg( int n ){ - frameSize+=4; - if( frameSize>maxFrameSize ) maxFrameSize=frameSize; - char buff[32];itoa( frameSize,buff,10 ); - string s="\tmov\t[ebp-";s+=buff;s+="],";s+=regs[n];s+='\n'; - codeFrags.push_back( s ); +static void pushReg(int n) { + frameSize += 4; + if (frameSize > maxFrameSize) maxFrameSize = frameSize; + char buff[32]; + _itoa(frameSize, buff, 10); + string s = "\tmov\t[ebp-"; s += buff; s += "],"; s += regs[n]; s += '\n'; + codeFrags.push_back(s); } -static void popReg( int n ){ - char buff[32];itoa( frameSize,buff,10 ); - string s="\tmov\t";s+=regs[n];s+=",[ebp-";s+=buff;s+="]\n"; - codeFrags.push_back( s ); - frameSize-=4; +static void popReg(int n) { + char buff[32]; _itoa(frameSize, buff, 10); + string s = "\tmov\t"; s += regs[n]; s += ",[ebp-"; s += buff; s += "]\n"; + codeFrags.push_back(s); + frameSize -= 4; } -static void moveReg( int d,int s ){ - string t="\tmov\t"+regs[d]+','+regs[s]+'\n'; - codeFrags.push_back( t ); +static void moveReg(int d, int s) { + string t = "\tmov\t" + regs[d] + ',' + regs[s] + '\n'; + codeFrags.push_back(t); } -static void swapRegs( int d,int s ){ - string t="\txchg\t"+regs[d]+','+regs[s]+'\n'; - codeFrags.push_back( t ); +static void swapRegs(int d, int s) { + string t = "\txchg\t" + regs[d] + ',' + regs[s] + '\n'; + codeFrags.push_back(t); } -Tile::Tile( const string &a,Tile *l,Tile *r ) -:assem(a),l(l),r(r),want_l(0),want_r(0),hits(0),need(0),argFrame(0){ +Tile::Tile(const string &a, Tile *l, Tile *r) + :assem(a), l(l), r(r), want_l(0), want_r(0), hits(0), need(0), argFrame(0) { } -Tile::Tile( const string &a,const string &a2,Tile *l,Tile *r ) -:assem(a),assem2(a2),l(l),r(r),want_l(0),want_r(0),hits(0),need(0),argFrame(0){ +Tile::Tile(const string &a, const string &a2, Tile *l, Tile *r) + : assem(a), assem2(a2), l(l), r(r), want_l(0), want_r(0), hits(0), need(0), argFrame(0) { } -Tile::~Tile(){ - delete l;delete r; +Tile::~Tile() { + delete l; delete r; } -void Tile::label(){ - if( !l ){ - need=1; - }else if( !r ){ +void Tile::label() { + if (!l) { + need = 1; + } else if (!r) { l->label(); - need=l->need; - }else{ - l->label();r->label(); - if( l->need==r->need ) need=l->need+1; - else if( l->need>r->need ) need=l->need; - else need=r->need; + need = l->need; + } else { + l->label(); r->label(); + if (l->need == r->need) need = l->need + 1; + else if (l->need > r->need) need = l->need; + else need = r->need; } } -int Tile::eval( int want ){ +int Tile::eval(int want) { //save any hit registers - int spill=hits; - if( want_l ) spill|=1<eval( want ); - }else{ - if( l->need>=NUM_REGS && r->need>=NUM_REGS ){ - got_r=r->eval( 0 ); - pushReg( got_r );freeReg( got_r ); - got_l=l->eval( want ); - got_r=allocReg( want_r );popReg( got_r ); - }else if( r->need>l->need ){ - got_r=r->eval( want_r ); - got_l=l->eval( want ); - }else{ - got_l=l->eval( want ); - got_r=r->eval( want_r ); - if( assem2.size() ) as=&assem2; + if (!l) { + got_l = allocReg(want); + } else if (!r) { + got_l = l->eval(want); + } else { + if (l->need >= NUM_REGS && r->need >= NUM_REGS) { + got_r = r->eval(0); + pushReg(got_r); freeReg(got_r); + got_l = l->eval(want); + got_r = allocReg(want_r); popReg(got_r); + } else if (r->need > l->need) { + got_r = r->eval(want_r); + got_l = l->eval(want); + } else { + got_l = l->eval(want); + got_r = r->eval(want_r); + if (assem2.size()) as = &assem2; } - if( want_l==got_r || want_r==got_l ){ - swapRegs( got_l,got_r ); - int t=got_l;got_l=got_r;got_r=t; + if (want_l == got_r || want_r == got_l) { + swapRegs(got_l, got_r); + int t = got_l; got_l = got_r; got_r = t; } } - if( !want_l ) want_l=got_l; - else if( want_l!=got_l ) moveReg( want_l,got_l ); + if (!want_l) want_l = got_l; + else if (want_l != got_l) moveReg(want_l, got_l); - if( !want_r ) want_r=got_r; - else if( want_r!=got_r ) moveReg( want_r,got_r ); + if (!want_r) want_r = got_r; + else if (want_r != got_r) moveReg(want_r, got_r); int i; - while( (i=as->find( "%l" ))!=string::npos ) as->replace( i,2,regs[want_l] ); - while( (i=as->find( "%r" ))!=string::npos ) as->replace( i,2,regs[want_r] ); + while ((i = as->find("%l")) != string::npos) as->replace(i, 2, regs[want_l]); + while ((i = as->find("%r")) != string::npos) as->replace(i, 2, regs[want_r]); - codeFrags.push_back( *as ); + codeFrags.push_back(*as); - freeReg( got_r ); - if( want_l!=got_l ) moveReg( got_l,want_l ); + freeReg(got_r); + if (want_l != got_l) moveReg(got_l, want_l); //cleanup argFrame - if( argFrame ){ + if (argFrame) { //***** Not needed for STDCALL ***** // codeFrags.push_back( "+"+itoa(argFrame) ); } //restore spilled regs - if( spill ){ - for( int n=NUM_REGS;n>=1;--n ){ - if( spill&(1<= 1; --n) { + if (spill&(1 << n)) popReg(n); } } return got_l; } -void Codegen_x86::flush(){ +void Codegen_x86::flush() { vector::iterator it; - for( it=dataFrags.begin();it!=dataFrags.end();++it ) out<<*it; + for (it = dataFrags.begin(); it != dataFrags.end(); ++it) out << *it; dataFrags.clear(); } -void Codegen_x86::enter( const string &l,int frameSize ){ +void Codegen_x86::enter(const string &l, int frameSize) { - inCode=true; - ::frameSize=maxFrameSize=frameSize; - codeFrags.clear();funcLabel=l; + inCode = true; + ::frameSize = maxFrameSize = frameSize; + codeFrags.clear(); funcLabel = l; } -void Codegen_x86::code( TNode *stmt ){ +void Codegen_x86::code(TNode *stmt) { resetRegs(); - Tile *q=munch( stmt ); + Tile *q = munch(stmt); q->label(); - q->eval( 0 ); + q->eval(0); delete q; delete stmt; } -static string fixEsp( int esp_off ){ - if( esp_off<0 ) return "\tsub\tesp,"+itoa(-esp_off)+"\n"; - return "\tadd\tesp,"+itoa(esp_off)+"\n"; +static string fixEsp(int esp_off) { + if (esp_off < 0) return "\tsub\tesp," + itoa(-esp_off) + "\n"; + return "\tadd\tesp," + itoa(esp_off) + "\n"; } -void Codegen_x86::leave( TNode *cleanup,int pop_sz ){ - if( cleanup ){ +void Codegen_x86::leave(TNode *cleanup, int pop_sz) { + if (cleanup) { resetRegs(); - allocReg( EAX ); - Tile *q=munch( cleanup ); + allocReg(EAX); + Tile *q = munch(cleanup); q->label(); - q->eval( 0 ); + q->eval(0); delete q; } - out<<"\t.align\t16\n"; + out << "\t.align\t16\n"; - if( funcLabel.size() ) out<::iterator it=codeFrags.begin(); - for( it=codeFrags.begin();it!=codeFrags.end();++it ){ - const string &t=*it; - if( t[0]=='+' ){ - esp_off+=atoi(t.substr(1)); - }else if( t[0]=='-' ){ + int esp_off = 0; + vector::iterator it = codeFrags.begin(); + for (it = codeFrags.begin(); it != codeFrags.end(); ++it) { + const string &t = *it; + if (t[0] == '+') { + esp_off += atoi(t.substr(1)); + } else if (t[0] == '-') { //***** Still needed for STDCALL ***** - esp_off-=atoi(t.substr(1)); - }else{ - if( esp_off ){ - out< - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - Debug Win32 @@ -17,22 +9,15 @@ Release Win32 - - Template - Win32 - {D884A075-E3B8-44E1-838D-74F28B33391B} - 10.0.10586.0 + Compiler + 8.1 - - Application - v140 - StaticLibrary v140 @@ -45,24 +30,9 @@ false MultiByte - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte - - - - @@ -71,112 +41,46 @@ - - - - - - - - - - .\compiler___Win32_Blitz2DRelease\ - .\compiler___Win32_Blitz2DRelease\ - false - - - .\compiler___Win32_Blitz3DRelease\ - .\compiler___Win32_Blitz3DRelease\ - false - ..\#Build\$(ProjectName)\$(ConfigurationName)\ ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ true + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 - .\Release\ - .\Release\ + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\compiler___Win32_Blitz2DRelease\ - .\compiler___Win32_Blitz2DRelease\compiler.pch - Use - std.h - .\compiler___Win32_Blitz2DRelease\ - .\compiler___Win32_Blitz2DRelease\ - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\compiler___Win32_Blitz2DRelease\compiler.bsc - - - true - .\compiler___Win32_Blitz2DRelease\compiler.lib - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - _LIB;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\compiler___Win32_Blitz3DRelease\ - .\compiler___Win32_Blitz3DRelease\compiler.pch - - .\compiler___Win32_Blitz3DRelease\ - .\compiler___Win32_Blitz3DRelease\ - StdCall - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\compiler___Win32_Blitz3DRelease\compiler.bsc - - - true - .\compiler___Win32_Blitz3DRelease\compiler.lib - - MultiThreadedDebug Default - false + true Disabled true - Level3 true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\compiler.pch - Use - std.h - .\Debug\ - .\Debug\ + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) EnableFastChecks + true + true + true + false + false + true + Guard + Level3 + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + true + true + false + StdCall 0x0409 @@ -188,25 +92,32 @@ true - .\Debug\compiler.lib MultiThreaded - AnySuitable + OnlyExplicitInline true true MaxSpeed true Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\Release\ - .\Release\compiler.pch - Use - std.h - .\Release\ - .\Release\ + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + false + false + false + StdCall 0x0409 @@ -218,55 +129,34 @@ true - .\Release\compiler.lib - Use - ../std.h - Use - ../std.h Use ../std.h Use ../std.h - Use - ../std.h - Use - ../std.h Use ../std.h Use ../std.h - Use - ../std.h - Use - ../std.h Use ../std.h Use ../std.h - Use - ../std.h - Use - ../std.h Use ../std.h Use ../std.h - Use - ../std.h - Use - ../std.h Use ../std.h Use @@ -280,10 +170,6 @@ - Create - std.h - Create - std.h Create std.h Create diff --git a/compiler/declnode.cpp b/compiler/declnode.cpp index fd11a18..80dfda6 100644 --- a/compiler/declnode.cpp +++ b/compiler/declnode.cpp @@ -5,46 +5,42 @@ ////////////////////////////// // Sequence of declarations // ////////////////////////////// -void DeclSeqNode::proto( DeclSeq *d,Environ *e ){ - for( int k=0;kproto( d,e ); } - catch( Ex &x ){ - if( x.pos<0 ) x.pos=decls[k]->pos; - if(!x.file.size() ) x.file=decls[k]->file; - throw; +void DeclSeqNode::proto(DeclSeq *d, Environ *e) { + for (int k = 0; k < decls.size(); ++k) { + try { decls[k]->proto(d, e); } catch (Ex &x) { + if (x.pos < 0) x.pos = decls[k]->pos; + if (!x.file.size()) x.file = decls[k]->file; + throw; } } } -void DeclSeqNode::semant( Environ *e ){ - for( int k=0;ksemant( e ); } - catch( Ex &x ){ - if( x.pos<0 ) x.pos=decls[k]->pos; - if(!x.file.size() ) x.file=decls[k]->file; - throw; +void DeclSeqNode::semant(Environ *e) { + for (int k = 0; k < decls.size(); ++k) { + try { decls[k]->semant(e); } catch (Ex &x) { + if (x.pos < 0) x.pos = decls[k]->pos; + if (!x.file.size()) x.file = decls[k]->file; + throw; } } } -void DeclSeqNode::translate( Codegen *g ){ - for( int k=0;ktranslate( g ); } - catch( Ex &x ){ - if( x.pos<0 ) x.pos=decls[k]->pos; - if(!x.file.size() ) x.file=decls[k]->file; - throw; +void DeclSeqNode::translate(Codegen *g) { + for (int k = 0; k < decls.size(); ++k) { + try { decls[k]->translate(g); } catch (Ex &x) { + if (x.pos < 0) x.pos = decls[k]->pos; + if (!x.file.size()) x.file = decls[k]->file; + throw; } } } -void DeclSeqNode::transdata( Codegen *g ){ - for( int k=0;ktransdata( g ); } - catch( Ex &x ){ - if( x.pos<0 ) x.pos=decls[k]->pos; - if(!x.file.size() ) x.file=decls[k]->file; - throw; +void DeclSeqNode::transdata(Codegen *g) { + for (int k = 0; k < decls.size(); ++k) { + try { decls[k]->transdata(g); } catch (Ex &x) { + if (x.pos < 0) x.pos = decls[k]->pos; + if (!x.file.size()) x.file = decls[k]->file; + throw; } } } @@ -52,154 +48,163 @@ void DeclSeqNode::transdata( Codegen *g ){ //////////////////////////// // Simple var declaration // //////////////////////////// -void VarDeclNode::proto( DeclSeq *d,Environ *e ){ +void VarDeclNode::proto(DeclSeq *d, Environ *e) { - Type *ty=tagType( tag,e ); - if( !ty ) ty=Type::int_type; - ConstType *defType=0; + Type *ty = tagType(tag, e); + if (!ty) ty = Type::int_type; + ConstType *defType = 0; - if( expr ){ - expr=expr->semant( e ); - expr=expr->castTo( ty,e ); - if( constant || (kind&DECL_PARAM) ){ - ConstNode *c=expr->constNode(); - if( !c ) ex( "Expression must be constant" ); - if( ty==Type::int_type ) ty=d_new ConstType( c->intValue() ); - else if( ty==Type::float_type ) ty=d_new ConstType( c->floatValue() ); - else ty=d_new ConstType( c->stringValue() ); - e->types.push_back( ty ); - delete expr;expr=0; + if (expr != nullptr) { + expr->semant(e); + if (expr == nullptr) { + ex("Internal Error: expr turned into nullptr (1)"); } - if( kind&DECL_PARAM ){ - defType=ty->constType();ty=defType->valueType; + expr = expr->castTo(ty, e); + if (expr == nullptr) { + ex("Internal Error: expr turned into nullptr (2)"); } - }else if( constant ) ex( "Constants must be initialized" ); - Decl *decl=d->insertDecl( ident,ty,kind,defType ); - if( !decl ) ex( "Duplicate variable name" ); - if( expr ) sem_var=d_new DeclVarNode( decl ); + if (constant || (kind&DECL_PARAM)) { + ConstNode *c = expr->constNode(); + + + if (!c) ex("Expression must be constant"); + if (ty == Type::int_type) ty = d_new ConstType(c->intValue()); + else if (ty == Type::float_type) ty = d_new ConstType(c->floatValue()); + else ty = d_new ConstType(c->stringValue()); + e->types.push_back(ty); + delete expr; expr = 0; + } + if (kind&DECL_PARAM) { + defType = ty->constType(); ty = defType->valueType; + } + } else if (constant) ex("Constants must be initialized"); + + Decl *decl = d->insertDecl(ident, ty, kind, defType); + if (!decl) ex("Duplicate variable name"); + if (expr) sem_var = d_new DeclVarNode(decl); } -void VarDeclNode::semant( Environ *e ){ +void VarDeclNode::semant(Environ *e) { } -void VarDeclNode::translate( Codegen *g ){ - if( kind & DECL_GLOBAL ){ - g->align_data( 4 ); - g->i_data( 0,"_v"+ident ); +void VarDeclNode::translate(Codegen *g) { + if (kind & DECL_GLOBAL) { + g->align_data(4); + g->i_data(0, "_v" + ident); } - if( expr ) g->code( sem_var->store( g,expr->translate( g ) ) ); + if (expr) g->code(sem_var->store(g, expr->translate(g))); } ////////////////////////// // Function Declaration // ////////////////////////// -void FuncDeclNode::proto( DeclSeq *d,Environ *e ){ - Type *t=tagType( tag,e );if( !t ) t=Type::int_type; - a_ptr decls( d_new DeclSeq() ); - params->proto( decls,e ); - sem_type=d_new FuncType( t,decls.release(),false,false ); - if( !d->insertDecl( ident,sem_type,DECL_FUNC ) ){ - delete sem_type;ex( "duplicate identifier" ); +void FuncDeclNode::proto(DeclSeq *d, Environ *e) { + Type *t = tagType(tag, e); if (!t) t = Type::int_type; + a_ptr decls(d_new DeclSeq()); + params->proto(decls, e); + sem_type = d_new FuncType(t, decls.release(), false, false); + if (!d->insertDecl(ident, sem_type, DECL_FUNC)) { + delete sem_type; ex("duplicate identifier"); } - e->types.push_back( sem_type ); + e->types.push_back(sem_type); } -void FuncDeclNode::semant( Environ *e ){ +void FuncDeclNode::semant(Environ *e) { - sem_env=d_new Environ( genLabel(),sem_type->returnType,1,e ); - DeclSeq *decls=sem_env->decls; + sem_env = d_new Environ(genLabel(), sem_type->returnType, 1, e); + DeclSeq *decls = sem_env->decls; int k; - for( k=0;kparams->size();++k ){ - Decl *d=sem_type->params->decls[k]; - if( !decls->insertDecl( d->name,d->type,d->kind ) ) ex( "duplicate identifier" ); + for (k = 0; k < sem_type->params->size(); ++k) { + Decl *d = sem_type->params->decls[k]; + if (!decls->insertDecl(d->name, d->type, d->kind)) ex("duplicate identifier"); } - stmts->semant( sem_env ); + stmts->semant(sem_env); } -void FuncDeclNode::translate( Codegen *g ){ +void FuncDeclNode::translate(Codegen *g) { //var offsets - int size=enumVars( sem_env ); + int size = enumVars(sem_env); //enter function - g->enter( "_f"+ident,size ); + g->enter("_f" + ident, size); //initialize locals - TNode *t=createVars( sem_env ); - if( t ) g->code( t ); - if( g->debug ){ - string t=genLabel(); - g->s_data( ident,t ); - g->code( call( "__bbDebugEnter",local(0),iconst((int)sem_env),global(t) ) ); + TNode *t = createVars(sem_env); + if (t) g->code(t); + if (g->debug) { + string t = genLabel(); + g->s_data(ident, t); + g->code(call("__bbDebugEnter", local(0), iconst((int)sem_env), global(t))); } //translate statements - stmts->translate( g ); + stmts->translate(g); - for( int k=0;klabels.size();++k ){ - if( sem_env->labels[k]->def<0 ) ex( "Undefined label",sem_env->labels[k]->ref ); + for (int k = 0; k < sem_env->labels.size(); ++k) { + if (sem_env->labels[k]->def < 0) ex("Undefined label", sem_env->labels[k]->ref); } //leave the function - g->label( sem_env->funcLabel+"_leave" ); - t=deleteVars( sem_env ); - if( g->debug ) t=d_new TNode( IR_SEQ,call( "__bbDebugLeave" ),t ); - g->leave( t,sem_type->params->size()*4 ); + g->label(sem_env->funcLabel + "_leave"); + t = deleteVars(sem_env); + if (g->debug) t = d_new TNode(IR_SEQ, call("__bbDebugLeave"), t); + g->leave(t, sem_type->params->size() * 4); } ////////////////////// // Type Declaration // ////////////////////// -void StructDeclNode::proto( DeclSeq *d,Environ *e ){ - sem_type=d_new StructType( ident,d_new DeclSeq() ); - if( !d->insertDecl( ident,sem_type,DECL_STRUCT ) ){ - delete sem_type;ex( "Duplicate identifier" ); +void StructDeclNode::proto(DeclSeq *d, Environ *e) { + sem_type = d_new StructType(ident, d_new DeclSeq()); + if (!d->insertDecl(ident, sem_type, DECL_STRUCT)) { + delete sem_type; ex("Duplicate identifier"); } - e->types.push_back( sem_type ); + e->types.push_back(sem_type); } -void StructDeclNode::semant( Environ *e ){ - fields->proto( sem_type->fields,e ); - for( int k=0;kfields->size();++k ) sem_type->fields->decls[k]->offset=k*4; +void StructDeclNode::semant(Environ *e) { + fields->proto(sem_type->fields, e); + for (int k = 0; k < sem_type->fields->size(); ++k) sem_type->fields->decls[k]->offset = k * 4; } -void StructDeclNode::translate( Codegen *g ){ +void StructDeclNode::translate(Codegen *g) { //translate fields - fields->translate( g ); + fields->translate(g); //type ID - g->align_data( 4 ); - g->i_data( 5,"_t"+ident ); + g->align_data(4); + g->i_data(5, "_t" + ident); //used and free lists for type int k; - for( k=0;k<2;++k ){ - string lab=genLabel(); - g->i_data( 0,lab ); //fields - g->p_data( lab ); //next - g->p_data( lab ); //prev - g->i_data( 0 ); //type - g->i_data( -1 ); //ref_cnt + for (k = 0; k < 2; ++k) { + string lab = genLabel(); + g->i_data(0, lab); //fields + g->p_data(lab); //next + g->p_data(lab); //prev + g->i_data(0); //type + g->i_data(-1); //ref_cnt } //number of fields - g->i_data( sem_type->fields->size() ); + g->i_data(sem_type->fields->size()); //type of each field - for( k=0;kfields->size();++k ){ - Decl *field=sem_type->fields->decls[k]; - Type *type=field->type; + for (k = 0; k < sem_type->fields->size(); ++k) { + Decl *field = sem_type->fields->decls[k]; + Type *type = field->type; string t; - if( type==Type::int_type ) t="__bbIntType"; - else if( type==Type::float_type ) t="__bbFltType"; - else if( type==Type::string_type ) t="__bbStrType"; - else if( StructType *s=type->structType() ) t="_t"+s->ident; - else if( VectorType *v=type->vectorType() ) t=v->label; - g->p_data( t ); + if (type == Type::int_type) t = "__bbIntType"; + else if (type == Type::float_type) t = "__bbFltType"; + else if (type == Type::string_type) t = "__bbStrType"; + else if (StructType *s = type->structType()) t = "_t" + s->ident; + else if (VectorType *v = type->vectorType()) t = v->label; + g->p_data(t); } } @@ -207,74 +212,74 @@ void StructDeclNode::translate( Codegen *g ){ ////////////////////// // Data declaration // ////////////////////// -void DataDeclNode::proto( DeclSeq *d,Environ *e ){ - expr=expr->semant( e ); - ConstNode *c=expr->constNode(); - if( !c ) ex( "Data expression must be constant" ); - if( expr->sem_type==Type::string_type ) str_label=genLabel(); +void DataDeclNode::proto(DeclSeq *d, Environ *e) { + expr = expr->semant(e); + ConstNode *c = expr->constNode(); + if (!c) ex("Data expression must be constant"); + if (expr->sem_type == Type::string_type) str_label = genLabel(); } -void DataDeclNode::semant( Environ *e ){ +void DataDeclNode::semant(Environ *e) { } -void DataDeclNode::translate( Codegen *g ){ - if( expr->sem_type!=Type::string_type ) return; - ConstNode *c=expr->constNode(); - g->s_data( c->stringValue(),str_label ); +void DataDeclNode::translate(Codegen *g) { + if (expr->sem_type != Type::string_type) return; + ConstNode *c = expr->constNode(); + g->s_data(c->stringValue(), str_label); } -void DataDeclNode::transdata( Codegen *g ){ - ConstNode *c=expr->constNode(); - if( expr->sem_type==Type::int_type ){ - g->i_data( 1 );g->i_data( c->intValue() ); - }else if( expr->sem_type==Type::float_type ){ - float n=c->floatValue(); - g->i_data( 2 );g->i_data( *(int*)&n ); - }else{ - g->i_data( 4 );g->p_data( str_label ); +void DataDeclNode::transdata(Codegen *g) { + ConstNode *c = expr->constNode(); + if (expr->sem_type == Type::int_type) { + g->i_data(1); g->i_data(c->intValue()); + } else if (expr->sem_type == Type::float_type) { + float n = c->floatValue(); + g->i_data(2); g->i_data(*(int*)&n); + } else { + g->i_data(4); g->p_data(str_label); } } //////////////////////// // Vector declaration // //////////////////////// -void VectorDeclNode::proto( DeclSeq *d,Environ *env ){ +void VectorDeclNode::proto(DeclSeq *d, Environ *env) { - Type *ty=tagType( tag,env );if( !ty ) ty=Type::int_type; + Type *ty = tagType(tag, env); if (!ty) ty = Type::int_type; vector sizes; - for( int k=0;ksize();++k ){ - ExprNode *e=exprs->exprs[k]=exprs->exprs[k]->semant( env ); - ConstNode *c=e->constNode(); - if( !c ) ex( "Blitz array sizes must be constant" ); - int n=c->intValue(); - if( n<0 ) ex( "Blitz array sizes must not be negative" ); - sizes.push_back( n+1 ); + for (int k = 0; k < exprs->size(); ++k) { + ExprNode *e = exprs->exprs[k] = exprs->exprs[k]->semant(env); + ConstNode *c = e->constNode(); + if (!c) ex("Blitz array sizes must be constant"); + int n = c->intValue(); + if (n < 0) ex("Blitz array sizes must not be negative"); + sizes.push_back(n + 1); } - string label=genLabel(); - sem_type=d_new VectorType( label,ty,sizes ); - if( !d->insertDecl( ident,sem_type,kind ) ){ - delete sem_type;ex( "Duplicate identifier" ); + string label = genLabel(); + sem_type = d_new VectorType(label, ty, sizes); + if (!d->insertDecl(ident, sem_type, kind)) { + delete sem_type; ex("Duplicate identifier"); } - env->types.push_back( sem_type ); + env->types.push_back(sem_type); } -void VectorDeclNode::translate( Codegen *g ){ +void VectorDeclNode::translate(Codegen *g) { //type tag! - g->align_data( 4 ); - VectorType *v=sem_type->vectorType(); - g->i_data( 6,v->label ); - int sz=1; - for( int k=0;ksizes.size();++k ) sz*=v->sizes[k]; - g->i_data( sz ); + g->align_data(4); + VectorType *v = sem_type->vectorType(); + g->i_data(6, v->label); + int sz = 1; + for (int k = 0; k < v->sizes.size(); ++k) sz *= v->sizes[k]; + g->i_data(sz); string t; - Type *type=v->elementType; - if( type==Type::int_type ) t="__bbIntType"; - else if( type==Type::float_type ) t="__bbFltType"; - else if( type==Type::string_type ) t="__bbStrType"; - else if( StructType *s=type->structType() ) t="_t"+s->ident; - else if( VectorType *v=type->vectorType() ) t=v->label; - g->p_data( t ); + Type *type = v->elementType; + if (type == Type::int_type) t = "__bbIntType"; + else if (type == Type::float_type) t = "__bbFltType"; + else if (type == Type::string_type) t = "__bbStrType"; + else if (StructType *s = type->structType()) t = "_t" + s->ident; + else if (VectorType *v = type->vectorType()) t = v->label; + g->p_data(t); - if( kind==DECL_GLOBAL ) g->i_data( 0,"_v"+ident ); + if (kind == DECL_GLOBAL) g->i_data(0, "_v" + ident); } diff --git a/compiler/exprnode.cpp b/compiler/exprnode.cpp index 4bc721e..51e0328 100644 --- a/compiler/exprnode.cpp +++ b/compiler/exprnode.cpp @@ -8,65 +8,66 @@ ////////////////////////////////// // Cast an expression to a type // ////////////////////////////////// -ExprNode *ExprNode::castTo( Type *ty,Environ *e ){ - if( !sem_type->canCastTo( ty ) ){ - ex( "Illegal type conversion" ); +ExprNode *ExprNode::castTo(Type *ty, Environ *e) { + if (!sem_type->canCastTo(ty)) { + ex("Illegal type conversion"); } - ExprNode *cast=d_new CastNode( this,ty ); - return cast->semant( e ); + ExprNode *cast = d_new CastNode(this, ty); + cast->semant(e); + return cast; } -ExprNode *CastNode::semant( Environ *e ){ - if( !expr->sem_type ){ - expr=expr->semant( e ); +ExprNode *CastNode::semant(Environ *e) { + if (!expr->sem_type) { + expr = expr->semant(e); } - if( ConstNode *c=expr->constNode() ){ + if (ConstNode *c = expr->constNode()) { ExprNode *e; - if( type==Type::int_type ) e=d_new IntConstNode( c->intValue() ); - else if( type==Type::float_type ) e=d_new FloatConstNode( c->floatValue() ); - else e=d_new StringConstNode( c->stringValue() ); + if (type == Type::int_type) e = d_new IntConstNode(c->intValue()); + else if (type == Type::float_type) e = d_new FloatConstNode(c->floatValue()); + else e = d_new StringConstNode(c->stringValue()); delete this; return e; } - sem_type=type; + sem_type = type; return this; } ////////////////////////////////// // Cast an expression to a type // ////////////////////////////////// -TNode *CastNode::translate( Codegen *g ){ - TNode *t=expr->translate( g ); - if( expr->sem_type==Type::float_type && sem_type==Type::int_type ){ +TNode *CastNode::translate(Codegen *g) { + TNode *t = expr->translate(g); + if (expr->sem_type == Type::float_type && sem_type == Type::int_type) { //float->int - return d_new TNode( IR_CAST,t,0 ); + return d_new TNode(IR_CAST, t, 0); } - if( expr->sem_type==Type::int_type && sem_type==Type::float_type ){ + if (expr->sem_type == Type::int_type && sem_type == Type::float_type) { //int->float - return d_new TNode( IR_FCAST,t,0 ); + return d_new TNode(IR_FCAST, t, 0); } - if( expr->sem_type==Type::string_type && sem_type==Type::int_type ){ + if (expr->sem_type == Type::string_type && sem_type == Type::int_type) { //str->int - return call( "__bbStrToInt",t ); + return call("__bbStrToInt", t); } - if( expr->sem_type==Type::int_type && sem_type==Type::string_type ){ + if (expr->sem_type == Type::int_type && sem_type == Type::string_type) { //int->str - return call( "__bbStrFromInt",t ); + return call("__bbStrFromInt", t); } - if( expr->sem_type==Type::string_type && sem_type==Type::float_type ){ + if (expr->sem_type == Type::string_type && sem_type == Type::float_type) { //str->float - return fcall( "__bbStrToFloat",t ); + return fcall("__bbStrToFloat", t); } - if( expr->sem_type==Type::float_type && sem_type==Type::string_type ){ + if (expr->sem_type == Type::float_type && sem_type == Type::string_type) { //float->str - return call( "__bbStrFromFloat",t ); + return call("__bbStrFromFloat", t); } - if( expr->sem_type->structType() && sem_type==Type::string_type ){ + if (expr->sem_type->structType() && sem_type == Type::string_type) { //obj->str - return call( "__bbObjToStr",t ); + return call("__bbObjToStr", t); } return t; } @@ -74,111 +75,111 @@ TNode *CastNode::translate( Codegen *g ){ ///////////////////////////// // Sequence of Expressions // ///////////////////////////// -void ExprSeqNode::semant( Environ *e ){ - for( int k=0;ksemant( e ); +void ExprSeqNode::semant(Environ *e) { + for (int k = 0; k < exprs.size(); ++k) { + if (exprs[k]) exprs[k] = exprs[k]->semant(e); } } -TNode *ExprSeqNode::translate( Codegen *g,bool cfunc ){ - TNode *t=0,*l=0; - for( int k=0;ktranslate(g); + TNode *q = exprs[k]->translate(g); - if( cfunc ){ - Type *ty=exprs[k]->sem_type; - if( ty->stringType() ){ - q=call( "__bbStrToCStr",q ); - }else if( ty->structType() ){ - q=d_new TNode( IR_MEM,q ); - }else if( ty==Type::void_type ){ - q=d_new TNode( IR_MEM,add(q,iconst(4)) ); + if (cfunc) { + Type *ty = exprs[k]->sem_type; + if (ty->stringType()) { + q = call("__bbStrToCStr", q); + } else if (ty->structType()) { + q = d_new TNode(IR_MEM, q); + } else if (ty == Type::void_type) { + q = d_new TNode(IR_MEM, add(q, iconst(4))); } } TNode *p; - p=d_new TNode( IR_ARG,0,0,k*4 ); - p=d_new TNode( IR_MEM,p,0 ); - p=d_new TNode( IR_MOVE,q,p ); - p=d_new TNode( IR_SEQ,p,0 ); - if( l ) l->r=p; - else t=p; - l=p; + p = d_new TNode(IR_ARG, 0, 0, k * 4); + p = d_new TNode(IR_MEM, p, 0); + p = d_new TNode(IR_MOVE, q, p); + p = d_new TNode(IR_SEQ, p, 0); + if (l) l->r = p; + else t = p; + l = p; } return t; } -void ExprSeqNode::castTo( DeclSeq *decls,Environ *e,bool cfunc ){ - if( exprs.size()>decls->size() ) ex( "Too many parameters" ); - for( int k=0;ksize();++k ){ - Decl *d=decls->decls[k]; - if( k decls->size()) ex("Too many parameters"); + for (int k = 0; k < decls->size(); ++k) { + Decl *d = decls->decls[k]; + if (k < exprs.size() && exprs[k]) { - if( cfunc && d->type->structType() ){ - if( exprs[k]->sem_type->structType() ){ - }else if( exprs[k]->sem_type->intType() ){ - exprs[k]->sem_type=Type::void_type; - }else{ - ex( "Illegal type conversion" ); + if (cfunc && d->type->structType()) { + if (exprs[k]->sem_type->structType()) { + } else if (exprs[k]->sem_type->intType()) { + exprs[k]->sem_type = Type::void_type; + } else { + ex("Illegal type conversion"); } continue; } - exprs[k]=exprs[k]->castTo( d->type,e ); + exprs[k] = exprs[k]->castTo(d->type, e); - }else{ - if( !d->defType ) ex( "Not enough parameters" ); - ExprNode *expr=constValue( d->defType ); - if( kdefType) ex("Not enough parameters"); + ExprNode *expr = constValue(d->defType); + if (k < exprs.size()) exprs[k] = expr; + else exprs.push_back(expr); } } } -void ExprSeqNode::castTo( Type *t,Environ *e ){ - for( int k=0;kcastTo( t,e ); +void ExprSeqNode::castTo(Type *t, Environ *e) { + for (int k = 0; k < exprs.size(); ++k) { + exprs[k] = exprs[k]->castTo(t, e); } } /////////////////// // Function call // /////////////////// -ExprNode *CallNode::semant( Environ *e ){ - Type *t=e->findType( tag ); - sem_decl=e->findFunc( ident ); - if( !sem_decl || !(sem_decl->kind & DECL_FUNC) ) ex( "Function '"+ident+"' not found" ); - FuncType *f=sem_decl->type->funcType(); - if( t && f->returnType!=t ) ex( "incorrect function return type" ); - exprs->semant( e ); - exprs->castTo( f->params,e,f->cfunc ); - sem_type=f->returnType; +ExprNode *CallNode::semant(Environ *e) { + Type *t = e->findType(tag); + sem_decl = e->findFunc(ident); + if (!sem_decl || !(sem_decl->kind & DECL_FUNC)) ex("Function '" + ident + "' not found"); + FuncType *f = sem_decl->type->funcType(); + if (t && f->returnType != t) ex("incorrect function return type"); + exprs->semant(e); + exprs->castTo(f->params, e, f->cfunc); + sem_type = f->returnType; return this; } -TNode *CallNode::translate( Codegen *g ){ +TNode *CallNode::translate(Codegen *g) { - FuncType *f=sem_decl->type->funcType(); + FuncType *f = sem_decl->type->funcType(); TNode *t; - TNode *l=global( "_f"+ident ); - TNode *r=exprs->translate( g,f->cfunc ); + TNode *l = global("_f" + ident); + TNode *r = exprs->translate(g, f->cfunc); - if( f->userlib ){ - l=d_new TNode( IR_MEM,l ); - usedfuncs.insert( ident ); + if (f->userlib) { + l = d_new TNode(IR_MEM, l); + usedfuncs.insert(ident); } - if( sem_type==Type::float_type ){ - t=d_new TNode( IR_FCALL,l,r,exprs->size()*4 ); - }else{ - t=d_new TNode( IR_CALL,l,r,exprs->size()*4 ); + if (sem_type == Type::float_type) { + t = d_new TNode(IR_FCALL, l, r, exprs->size() * 4); + } else { + t = d_new TNode(IR_CALL, l, r, exprs->size() * 4); } - if( f->returnType->stringType() ){ - if( f->cfunc ){ - t=call( "__bbCStrToStr",t ); + if (f->returnType->stringType()) { + if (f->cfunc) { + t = call("__bbCStrToStr", t); } } return t; @@ -187,232 +188,232 @@ TNode *CallNode::translate( Codegen *g ){ ///////////////////////// // Variable expression // ///////////////////////// -ExprNode *VarExprNode::semant( Environ *e ){ - var->semant( e ); - sem_type=var->sem_type; - ConstType *c=sem_type->constType(); - if( !c ) return this; - ExprNode *expr=constValue( c ); - delete this;return expr; +ExprNode *VarExprNode::semant(Environ *e) { + var->semant(e); + sem_type = var->sem_type; + ConstType *c = sem_type->constType(); + if (!c) return this; + ExprNode *expr = constValue(c); + delete this; return expr; } -TNode *VarExprNode::translate( Codegen *g ){ - return var->load( g ); +TNode *VarExprNode::translate(Codegen *g) { + return var->load(g); } ////////////////////// // Integer constant // ////////////////////// -IntConstNode::IntConstNode( int n ):value(n){ - sem_type=Type::int_type; +IntConstNode::IntConstNode(int n) :value(n) { + sem_type = Type::int_type; } -TNode *IntConstNode::translate( Codegen *g ){ - return d_new TNode( IR_CONST,0,0,value ); +TNode *IntConstNode::translate(Codegen *g) { + return d_new TNode(IR_CONST, 0, 0, value); } -int IntConstNode::intValue(){ +int IntConstNode::intValue() { return value; } -float IntConstNode::floatValue(){ +float IntConstNode::floatValue() { return value; } -string IntConstNode::stringValue(){ - return itoa( value ); +string IntConstNode::stringValue() { + return itoa(value); } //////////////////// // Float constant // //////////////////// -FloatConstNode::FloatConstNode( float f ):value(f){ - sem_type=Type::float_type; +FloatConstNode::FloatConstNode(float f) :value(f) { + sem_type = Type::float_type; } -TNode *FloatConstNode::translate( Codegen *g ){ - return d_new TNode( IR_CONST,0,0,*(int*)&value ); +TNode *FloatConstNode::translate(Codegen *g) { + return d_new TNode(IR_CONST, 0, 0, *(int*)&value); } -int FloatConstNode::intValue(){ - float flt=value; +int FloatConstNode::intValue() { + float flt = value; int temp; - _control87( _RC_NEAR|_PC_24|_EM_INVALID|_EM_ZERODIVIDE|_EM_OVERFLOW|_EM_UNDERFLOW|_EM_INEXACT|_EM_DENORMAL,0xfffff ); - _asm{ - fld [flt]; - fistp [temp]; + _control87(_RC_NEAR | _PC_24 | _EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW | _EM_UNDERFLOW | _EM_INEXACT | _EM_DENORMAL, 0xfffff); + _asm { + fld[flt]; + fistp[temp]; } - _control87( _CW_DEFAULT,0xfffff ); + _control87(_CW_DEFAULT, 0xfffff); return temp; } -float FloatConstNode::floatValue(){ +float FloatConstNode::floatValue() { return value; } -string FloatConstNode::stringValue(){ - return ftoa( value ); +string FloatConstNode::stringValue() { + return ftoa(value); } ///////////////////// // String constant // ///////////////////// -StringConstNode::StringConstNode( const string &s ):value(s){ - sem_type=Type::string_type; +StringConstNode::StringConstNode(const string &s) :value(s) { + sem_type = Type::string_type; } -TNode *StringConstNode::translate( Codegen *g ){ - string lab=genLabel(); - g->s_data( value,lab ); - return call( "__bbStrConst",global( lab ) ); +TNode *StringConstNode::translate(Codegen *g) { + string lab = genLabel(); + g->s_data(value, lab); + return call("__bbStrConst", global(lab)); } -int StringConstNode::intValue(){ - return atoi( value ); +int StringConstNode::intValue() { + return atoi(value); } -float StringConstNode::floatValue(){ - return (float)atof( value ); +float StringConstNode::floatValue() { + return (float)atof(value); } -string StringConstNode::stringValue(){ +string StringConstNode::stringValue() { return value; } //////////////////// // Unary operator // //////////////////// -ExprNode *UniExprNode::semant( Environ *e ){ - expr=expr->semant( e ); - sem_type=expr->sem_type; - if( sem_type!=Type::int_type && sem_type!=Type::float_type ) ex( "Illegal operator for type" ); - if( ConstNode *c=expr->constNode() ){ +ExprNode *UniExprNode::semant(Environ *e) { + expr = expr->semant(e); + sem_type = expr->sem_type; + if (sem_type != Type::int_type && sem_type != Type::float_type) ex("Illegal operator for type"); + if (ConstNode *c = expr->constNode()) { ExprNode *e; - if( sem_type==Type::int_type ){ - switch( op ){ - case '+':e=d_new IntConstNode( +c->intValue() );break; - case '-':e=d_new IntConstNode( -c->intValue() );break; - case ABS:e=d_new IntConstNode( c->intValue()>=0 ? c->intValue() : -c->intValue() );break; - case SGN:e=d_new IntConstNode( c->intValue()>0 ? 1 : (c->intValue()<0 ? -1 : 0) );break; + if (sem_type == Type::int_type) { + switch (op) { + case '+':e = d_new IntConstNode(+c->intValue()); break; + case '-':e = d_new IntConstNode(-c->intValue()); break; + case ABS:e = d_new IntConstNode(c->intValue() >= 0 ? c->intValue() : -c->intValue()); break; + case SGN:e = d_new IntConstNode(c->intValue() > 0 ? 1 : (c->intValue() < 0 ? -1 : 0)); break; } - }else{ - switch( op ){ - case '+':e=d_new FloatConstNode( +c->floatValue() );break; - case '-':e=d_new FloatConstNode( -c->floatValue() );break; - case ABS:e=d_new FloatConstNode( c->floatValue()>=0 ? c->floatValue() : -c->floatValue() );break; - case SGN:e=d_new FloatConstNode( c->floatValue()>0 ? 1 : (c->floatValue()<0 ? -1 : 0) );break; + } else { + switch (op) { + case '+':e = d_new FloatConstNode(+c->floatValue()); break; + case '-':e = d_new FloatConstNode(-c->floatValue()); break; + case ABS:e = d_new FloatConstNode(c->floatValue() >= 0 ? c->floatValue() : -c->floatValue()); break; + case SGN:e = d_new FloatConstNode(c->floatValue() > 0 ? 1 : (c->floatValue() < 0 ? -1 : 0)); break; } } delete this; - return e; + return e = nullptr; } return this; } -TNode *UniExprNode::translate( Codegen *g ){ - int n=0; - TNode *l=expr->translate( g ); - if( sem_type==Type::int_type ){ - switch( op ){ - case '+':return l; - case '-':n=IR_NEG;break; - case ABS:return call( "__bbAbs",l ); - case SGN:return call( "__bbSgn",l ); +TNode *UniExprNode::translate(Codegen *g) { + int n = 0; + TNode *l = expr->translate(g); + if (sem_type == Type::int_type) { + switch (op) { + case '+':return l; + case '-':n = IR_NEG; break; + case ABS:return call("__bbAbs", l); + case SGN:return call("__bbSgn", l); } - }else{ - switch( op ){ - case '+':return l; - case '-':n=IR_FNEG;break; - case ABS:return fcall( "__bbFAbs",l ); - case SGN:return fcall( "__bbFSgn",l ); + } else { + switch (op) { + case '+':return l; + case '-':n = IR_FNEG; break; + case ABS:return fcall("__bbFAbs", l); + case SGN:return fcall("__bbFSgn", l); } } - return d_new TNode( n,l,0 ); + return d_new TNode(n, l, 0); } ///////////////////////////////////////////////////// // boolean expression - accepts ints, returns ints // ///////////////////////////////////////////////////// -ExprNode *BinExprNode::semant( Environ *e ){ - lhs=lhs->semant(e);lhs=lhs->castTo( Type::int_type,e ); - rhs=rhs->semant(e);rhs=rhs->castTo( Type::int_type,e ); - ConstNode *lc=lhs->constNode(),*rc=rhs->constNode(); - if( lc && rc ){ - ExprNode *expr; - switch( op ){ - case AND:expr=d_new IntConstNode( lc->intValue() & rc->intValue() );break; - case OR: expr=d_new IntConstNode( lc->intValue() | rc->intValue() );break; - case XOR:expr=d_new IntConstNode( lc->intValue() ^ rc->intValue() );break; - case SHL:expr=d_new IntConstNode( lc->intValue()<< rc->intValue() );break; - case SHR:expr=d_new IntConstNode( (unsigned)lc->intValue()>>rc->intValue() );break; - case SAR:expr=d_new IntConstNode( lc->intValue()>> rc->intValue() );break; +ExprNode *BinExprNode::semant(Environ *e) { + lhs = lhs->semant(e); lhs = lhs->castTo(Type::int_type, e); + rhs = rhs->semant(e); rhs = rhs->castTo(Type::int_type, e); + ConstNode *lc = lhs->constNode(), *rc = rhs->constNode(); + if (lc && rc) { + ExprNode *expr = nullptr; + switch (op) { + case AND:expr = d_new IntConstNode(lc->intValue() & rc->intValue()); break; + case OR: expr = d_new IntConstNode(lc->intValue() | rc->intValue()); break; + case XOR:expr = d_new IntConstNode(lc->intValue() ^ rc->intValue()); break; + case SHL:expr = d_new IntConstNode(lc->intValue() << rc->intValue()); break; + case SHR:expr = d_new IntConstNode((unsigned)lc->intValue() >> rc->intValue()); break; + case SAR:expr = d_new IntConstNode(lc->intValue() >> rc->intValue()); break; } delete this; return expr; } - sem_type=Type::int_type; + sem_type = Type::int_type; return this; } -TNode *BinExprNode::translate( Codegen *g ){ - TNode *l=lhs->translate( g ); - TNode *r=rhs->translate( g ); - int n=0; - switch( op ){ - case AND:n=IR_AND;break;case OR:n=IR_OR;break;case XOR:n=IR_XOR;break; - case SHL:n=IR_SHL;break;case SHR:n=IR_SHR;break;case SAR:n=IR_SAR;break; +TNode *BinExprNode::translate(Codegen *g) { + TNode *l = lhs->translate(g); + TNode *r = rhs->translate(g); + int n = 0; + switch (op) { + case AND:n = IR_AND; break; case OR:n = IR_OR; break; case XOR:n = IR_XOR; break; + case SHL:n = IR_SHL; break; case SHR:n = IR_SHR; break; case SAR:n = IR_SAR; break; } - return d_new TNode( n,l,r ); + return d_new TNode(n, l, r); } /////////////////////////// // arithmetic expression // /////////////////////////// -ExprNode *ArithExprNode::semant( Environ *e ){ - lhs=lhs->semant(e); - rhs=rhs->semant(e); - if( lhs->sem_type->structType() || rhs->sem_type->structType() ){ - ex( "Arithmetic operator cannot be applied to custom type objects" ); +ExprNode *ArithExprNode::semant(Environ *e) { + lhs = lhs->semant(e); + rhs = rhs->semant(e); + if (lhs->sem_type->structType() || rhs->sem_type->structType()) { + ex("Arithmetic operator cannot be applied to custom type objects"); } - if( lhs->sem_type==Type::string_type || rhs->sem_type==Type::string_type ){ + if (lhs->sem_type == Type::string_type || rhs->sem_type == Type::string_type) { //one side is a string - only + operator... - if( op!='+' ) ex( "Operator cannot be applied to strings" ); - sem_type=Type::string_type; - }else if( op=='^' || lhs->sem_type==Type::float_type || rhs->sem_type==Type::float_type ){ + if (op != '+') ex("Operator cannot be applied to strings"); + sem_type = Type::string_type; + } else if (op == '^' || lhs->sem_type == Type::float_type || rhs->sem_type == Type::float_type) { //It's ^, or one side is a float - sem_type=Type::float_type; - }else{ + sem_type = Type::float_type; + } else { //must be 2 ints - sem_type=Type::int_type; + sem_type = Type::int_type; } - lhs=lhs->castTo( sem_type,e ); - rhs=rhs->castTo( sem_type,e ); - ConstNode *lc=lhs->constNode(),*rc=rhs->constNode(); - if( rc && (op=='/' || op==MOD) ){ - if( (sem_type==Type::int_type && !rc->intValue()) || (sem_type==Type::float_type && !rc->floatValue()) ){ - ex( "Division by zero" ); + lhs = lhs->castTo(sem_type, e); + rhs = rhs->castTo(sem_type, e); + ConstNode *lc = lhs->constNode(), *rc = rhs->constNode(); + if (rc && (op == '/' || op == MOD)) { + if ((sem_type == Type::int_type && !rc->intValue()) || (sem_type == Type::float_type && !rc->floatValue())) { + ex("Division by zero"); } } - if( lc && rc ){ - ExprNode *expr; - if( sem_type==Type::string_type ){ - expr=d_new StringConstNode( lc->stringValue()+rc->stringValue() ); - }else if( sem_type==Type::int_type ){ - switch( op ){ - case '+':expr=d_new IntConstNode( lc->intValue()+rc->intValue() );break; - case '-':expr=d_new IntConstNode( lc->intValue()-rc->intValue() );break; - case '*':expr=d_new IntConstNode( lc->intValue()*rc->intValue() );break; - case '/':expr=d_new IntConstNode( lc->intValue()/rc->intValue() );break; - case MOD:expr=d_new IntConstNode( lc->intValue()%rc->intValue() );break; + if (lc && rc) { + ExprNode *expr = nullptr; + if (sem_type == Type::string_type) { + expr = d_new StringConstNode(lc->stringValue() + rc->stringValue()); + } else if (sem_type == Type::int_type) { + switch (op) { + case '+':expr = d_new IntConstNode(lc->intValue() + rc->intValue()); break; + case '-':expr = d_new IntConstNode(lc->intValue() - rc->intValue()); break; + case '*':expr = d_new IntConstNode(lc->intValue()*rc->intValue()); break; + case '/':expr = d_new IntConstNode(lc->intValue() / rc->intValue()); break; + case MOD:expr = d_new IntConstNode(lc->intValue() % rc->intValue()); break; } - }else{ - switch( op ){ - case '+':expr=d_new FloatConstNode( lc->floatValue()+rc->floatValue() );break; - case '-':expr=d_new FloatConstNode( lc->floatValue()-rc->floatValue() );break; - case '*':expr=d_new FloatConstNode( lc->floatValue()*rc->floatValue() );break; - case '/':expr=d_new FloatConstNode( lc->floatValue()/rc->floatValue() );break; - case MOD:expr=d_new FloatConstNode( fmod( lc->floatValue(),rc->floatValue() ) );break; - case '^':expr=d_new FloatConstNode( pow( lc->floatValue(),rc->floatValue() ) );break; + } else { + switch (op) { + case '+':expr = d_new FloatConstNode(lc->floatValue() + rc->floatValue()); break; + case '-':expr = d_new FloatConstNode(lc->floatValue() - rc->floatValue()); break; + case '*':expr = d_new FloatConstNode(lc->floatValue()*rc->floatValue()); break; + case '/':expr = d_new FloatConstNode(lc->floatValue() / rc->floatValue()); break; + case MOD:expr = d_new FloatConstNode(fmod(lc->floatValue(), rc->floatValue())); break; + case '^':expr = d_new FloatConstNode(pow(lc->floatValue(), rc->floatValue())); break; } } delete this; @@ -421,78 +422,78 @@ ExprNode *ArithExprNode::semant( Environ *e ){ return this; } -TNode *ArithExprNode::translate( Codegen *g ){ - TNode *l=lhs->translate( g ); - TNode *r=rhs->translate( g ); - if( sem_type==Type::string_type ){ - return call( "__bbStrConcat",l,r ); +TNode *ArithExprNode::translate(Codegen *g) { + TNode *l = lhs->translate(g); + TNode *r = rhs->translate(g); + if (sem_type == Type::string_type) { + return call("__bbStrConcat", l, r); } - int n=0; - if( sem_type==Type::int_type ){ - switch( op ){ - case '+':n=IR_ADD;break;case '-':n=IR_SUB;break; - case '*':n=IR_MUL;break;case '/':n=IR_DIV;break; - case MOD:return call( "__bbMod",l,r ); + int n = 0; + if (sem_type == Type::int_type) { + switch (op) { + case '+':n = IR_ADD; break; case '-':n = IR_SUB; break; + case '*':n = IR_MUL; break; case '/':n = IR_DIV; break; + case MOD:return call("__bbMod", l, r); } - }else{ - switch( op ){ - case '+':n=IR_FADD;break;case '-':n=IR_FSUB;break; - case '*':n=IR_FMUL;break;case '/':n=IR_FDIV;break; - case MOD:return fcall( "__bbFMod",l,r ); - case '^':return fcall( "__bbFPow",l,r ); + } else { + switch (op) { + case '+':n = IR_FADD; break; case '-':n = IR_FSUB; break; + case '*':n = IR_FMUL; break; case '/':n = IR_FDIV; break; + case MOD:return fcall("__bbFMod", l, r); + case '^':return fcall("__bbFPow", l, r); } } - return d_new TNode( n,l,r ); + return d_new TNode(n, l, r); } ///////////////////////// // relation expression // ///////////////////////// -ExprNode *RelExprNode::semant( Environ *e ){ - lhs=lhs->semant(e); - rhs=rhs->semant(e); - if( lhs->sem_type->structType() || rhs->sem_type->structType() ){ - if( op!='=' && op!=NE ) ex( "Illegal operator for custom type objects" ); - opType=lhs->sem_type!=Type::null_type ? lhs->sem_type : rhs->sem_type; - }else if( lhs->sem_type==Type::string_type || rhs->sem_type==Type::string_type ){ - opType=Type::string_type; - }else if( lhs->sem_type==Type::float_type || rhs->sem_type==Type::float_type ){ - opType=Type::float_type; - }else{ - opType=Type::int_type; +ExprNode *RelExprNode::semant(Environ *e) { + lhs = lhs->semant(e); + rhs = rhs->semant(e); + if (lhs->sem_type->structType() || rhs->sem_type->structType()) { + if (op != '=' && op != NE) ex("Illegal operator for custom type objects"); + opType = lhs->sem_type != Type::null_type ? lhs->sem_type : rhs->sem_type; + } else if (lhs->sem_type == Type::string_type || rhs->sem_type == Type::string_type) { + opType = Type::string_type; + } else if (lhs->sem_type == Type::float_type || rhs->sem_type == Type::float_type) { + opType = Type::float_type; + } else { + opType = Type::int_type; } - sem_type=Type::int_type; - lhs=lhs->castTo( opType,e ); - rhs=rhs->castTo( opType,e ); - ConstNode *lc=lhs->constNode(),*rc=rhs->constNode(); - if( lc && rc ){ - ExprNode *expr; - if( opType==Type::string_type ){ - switch( op ){ - case '<':expr=d_new IntConstNode( lc->stringValue()< rc->stringValue() );break; - case '=':expr=d_new IntConstNode( lc->stringValue()==rc->stringValue() );break; - case '>':expr=d_new IntConstNode( lc->stringValue()> rc->stringValue() );break; - case LE: expr=d_new IntConstNode( lc->stringValue()<=rc->stringValue() );break; - case NE: expr=d_new IntConstNode( lc->stringValue()!=rc->stringValue() );break; - case GE: expr=d_new IntConstNode( lc->stringValue()>=rc->stringValue() );break; + sem_type = Type::int_type; + lhs = lhs->castTo(opType, e); + rhs = rhs->castTo(opType, e); + ConstNode *lc = lhs->constNode(), *rc = rhs->constNode(); + if (lc && rc) { + ExprNode *expr = nullptr; + if (opType == Type::string_type) { + switch (op) { + case '<':expr = d_new IntConstNode(lc->stringValue() < rc->stringValue()); break; + case '=':expr = d_new IntConstNode(lc->stringValue() == rc->stringValue()); break; + case '>':expr = d_new IntConstNode(lc->stringValue() > rc->stringValue()); break; + case LE: expr = d_new IntConstNode(lc->stringValue() <= rc->stringValue()); break; + case NE: expr = d_new IntConstNode(lc->stringValue() != rc->stringValue()); break; + case GE: expr = d_new IntConstNode(lc->stringValue() >= rc->stringValue()); break; } - }else if( opType==Type::float_type ){ - switch( op ){ - case '<':expr=d_new IntConstNode( lc->floatValue()< rc->floatValue() );break; - case '=':expr=d_new IntConstNode( lc->floatValue()==rc->floatValue() );break; - case '>':expr=d_new IntConstNode( lc->floatValue()> rc->floatValue() );break; - case LE: expr=d_new IntConstNode( lc->floatValue()<=rc->floatValue() );break; - case NE: expr=d_new IntConstNode( lc->floatValue()!=rc->floatValue() );break; - case GE: expr=d_new IntConstNode( lc->floatValue()>=rc->floatValue() );break; + } else if (opType == Type::float_type) { + switch (op) { + case '<':expr = d_new IntConstNode(lc->floatValue() < rc->floatValue()); break; + case '=':expr = d_new IntConstNode(lc->floatValue() == rc->floatValue()); break; + case '>':expr = d_new IntConstNode(lc->floatValue() > rc->floatValue()); break; + case LE: expr = d_new IntConstNode(lc->floatValue() <= rc->floatValue()); break; + case NE: expr = d_new IntConstNode(lc->floatValue() != rc->floatValue()); break; + case GE: expr = d_new IntConstNode(lc->floatValue() >= rc->floatValue()); break; } - }else{ - switch( op ){ - case '<':expr=d_new IntConstNode( lc->intValue()< rc->intValue() );break; - case '=':expr=d_new IntConstNode( lc->intValue()==rc->intValue() );break; - case '>':expr=d_new IntConstNode( lc->intValue()> rc->intValue() );break; - case LE: expr=d_new IntConstNode( lc->intValue()<=rc->intValue() );break; - case NE: expr=d_new IntConstNode( lc->intValue()!=rc->intValue() );break; - case GE: expr=d_new IntConstNode( lc->intValue()>=rc->intValue() );break; + } else { + switch (op) { + case '<':expr = d_new IntConstNode(lc->intValue() < rc->intValue()); break; + case '=':expr = d_new IntConstNode(lc->intValue() == rc->intValue()); break; + case '>':expr = d_new IntConstNode(lc->intValue() > rc->intValue()); break; + case LE: expr = d_new IntConstNode(lc->intValue() <= rc->intValue()); break; + case NE: expr = d_new IntConstNode(lc->intValue() != rc->intValue()); break; + case GE: expr = d_new IntConstNode(lc->intValue() >= rc->intValue()); break; } } delete this; @@ -501,127 +502,127 @@ ExprNode *RelExprNode::semant( Environ *e ){ return this; } -TNode *RelExprNode::translate( Codegen *g ){ - TNode *l=lhs->translate( g ); - TNode *r=rhs->translate( g ); - return compare( op,l,r,opType ); +TNode *RelExprNode::translate(Codegen *g) { + TNode *l = lhs->translate(g); + TNode *r = rhs->translate(g); + return compare(op, l, r, opType); } //////////////////// // New expression // //////////////////// -ExprNode *NewNode::semant( Environ *e ){ - sem_type=e->findType( ident ); - if( !sem_type ) ex( "custom type name not found" ); - if( sem_type->structType()==0 ) ex( "type is not a custom type" ); +ExprNode *NewNode::semant(Environ *e) { + sem_type = e->findType(ident); + if (!sem_type) ex("custom type name not found"); + if (sem_type->structType() == 0) ex("type is not a custom type"); return this; } -TNode *NewNode::translate( Codegen *g ){ - return call( "__bbObjNew",global( "_t"+ident ) ); +TNode *NewNode::translate(Codegen *g) { + return call("__bbObjNew", global("_t" + ident)); } //////////////////// // First of class // //////////////////// -ExprNode *FirstNode::semant( Environ *e ){ - sem_type=e->findType( ident ); - if( !sem_type ) ex( "custom type name name not found" ); +ExprNode *FirstNode::semant(Environ *e) { + sem_type = e->findType(ident); + if (!sem_type) ex("custom type name name not found"); return this; } -TNode *FirstNode::translate( Codegen *g ){ - return call( "__bbObjFirst",global( "_t"+ident ) ); +TNode *FirstNode::translate(Codegen *g) { + return call("__bbObjFirst", global("_t" + ident)); } /////////////////// // Last of class // /////////////////// -ExprNode *LastNode::semant( Environ *e ){ - sem_type=e->findType( ident ); - if( !sem_type ) ex( "custom type name not found" ); +ExprNode *LastNode::semant(Environ *e) { + sem_type = e->findType(ident); + if (!sem_type) ex("custom type name not found"); return this; } -TNode *LastNode::translate( Codegen *g ){ - return call( "__bbObjLast",global( "_t"+ident ) ); +TNode *LastNode::translate(Codegen *g) { + return call("__bbObjLast", global("_t" + ident)); } //////////////////// // Next of object // //////////////////// -ExprNode *AfterNode::semant( Environ *e ){ - expr=expr->semant( e ); - if( expr->sem_type==Type::null_type ) ex( "'After' cannot be used on 'Null'" ); - if( expr->sem_type->structType()==0 ) ex( "'After' must be used with a custom type object" ); - sem_type=expr->sem_type; +ExprNode *AfterNode::semant(Environ *e) { + expr = expr->semant(e); + if (expr->sem_type == Type::null_type) ex("'After' cannot be used on 'Null'"); + if (expr->sem_type->structType() == 0) ex("'After' must be used with a custom type object"); + sem_type = expr->sem_type; return this; } -TNode *AfterNode::translate( Codegen *g ){ - TNode *t=expr->translate( g ); - if( g->debug ) t=jumpf( t,"__bbNullObjEx" ); - return call( "__bbObjNext",t ); +TNode *AfterNode::translate(Codegen *g) { + TNode *t = expr->translate(g); + if (g->debug) t = jumpf(t, "__bbNullObjEx"); + return call("__bbObjNext", t); } //////////////////// // Prev of object // //////////////////// -ExprNode *BeforeNode::semant( Environ *e ){ - expr=expr->semant( e ); - if( expr->sem_type==Type::null_type ) ex( "'Before' cannot be used with 'Null'" ); - if( expr->sem_type->structType()==0 ) ex( "'Before' must be used with a custom type object" ); - sem_type=expr->sem_type; +ExprNode *BeforeNode::semant(Environ *e) { + expr = expr->semant(e); + if (expr->sem_type == Type::null_type) ex("'Before' cannot be used with 'Null'"); + if (expr->sem_type->structType() == 0) ex("'Before' must be used with a custom type object"); + sem_type = expr->sem_type; return this; } -TNode *BeforeNode::translate( Codegen *g ){ - TNode *t=expr->translate( g ); - if( g->debug ) t=jumpf( t,"__bbNullObjEx" ); - return call( "__bbObjPrev",t ); +TNode *BeforeNode::translate(Codegen *g) { + TNode *t = expr->translate(g); + if (g->debug) t = jumpf(t, "__bbNullObjEx"); + return call("__bbObjPrev", t); } ///////////////// // Null object // ///////////////// -ExprNode *NullNode::semant( Environ *e ){ - sem_type=Type::null_type; +ExprNode *NullNode::semant(Environ *e) { + sem_type = Type::null_type; return this; } -TNode *NullNode::translate( Codegen *g ){ - return d_new TNode( IR_CONST,0,0,0 ); +TNode *NullNode::translate(Codegen *g) { + return d_new TNode(IR_CONST, 0, 0, 0); } ///////////////// // Object cast // ///////////////// -ExprNode *ObjectCastNode::semant( Environ *e ){ - expr=expr->semant( e ); - expr=expr->castTo( Type::int_type,e ); - sem_type=e->findType( type_ident ); - if( !sem_type ) ex( "custom type name not found" ); - if( !sem_type->structType() ) ex( "type is not a custom type" ); +ExprNode *ObjectCastNode::semant(Environ *e) { + expr = expr->semant(e); + expr = expr->castTo(Type::int_type, e); + sem_type = e->findType(type_ident); + if (!sem_type) ex("custom type name not found"); + if (!sem_type->structType()) ex("type is not a custom type"); return this; } -TNode *ObjectCastNode::translate( Codegen *g ){ - TNode *t=expr->translate( g ); - t=call( "__bbObjFromHandle",t,global( "_t"+sem_type->structType()->ident ) ); +TNode *ObjectCastNode::translate(Codegen *g) { + TNode *t = expr->translate(g); + t = call("__bbObjFromHandle", t, global("_t" + sem_type->structType()->ident)); return t; } /////////////////// // Object Handle // /////////////////// -ExprNode *ObjectHandleNode::semant( Environ *e ){ - expr=expr->semant( e ); - if( !expr->sem_type->structType() ) ex( "'ObjectHandle' must be used with an object" ); - sem_type=Type::int_type; +ExprNode *ObjectHandleNode::semant(Environ *e) { + expr = expr->semant(e); + if (!expr->sem_type->structType()) ex("'ObjectHandle' must be used with an object"); + sem_type = Type::int_type; return this; } -TNode *ObjectHandleNode::translate( Codegen *g ){ - TNode *t=expr->translate( g ); - return call( "__bbObjToHandle",t ); +TNode *ObjectHandleNode::translate(Codegen *g) { + TNode *t = expr->translate(g); + return call("__bbObjToHandle", t); } diff --git a/compiler/exprnode.h b/compiler/exprnode.h index 43d5b9a..91b3b29 100644 --- a/compiler/exprnode.h +++ b/compiler/exprnode.h @@ -6,188 +6,188 @@ struct ConstNode; //is constant int,float or string -struct ExprNode : public Node{ +struct ExprNode : public Node { Type *sem_type; - ExprNode():sem_type(0){} - ExprNode( Type *t ):sem_type( t ){} + ExprNode() :sem_type(0) {} + ExprNode(Type *t) :sem_type(t) {} - ExprNode *castTo( Type *ty,Environ *e ); - ExprNode *semant( Environ *e,Type *ty ); + ExprNode *castTo(Type *ty, Environ *e); + ExprNode *semant(Environ *e, Type *ty); - virtual ExprNode *semant( Environ *e )=0; - virtual TNode *translate( Codegen *g )=0; - virtual ConstNode *constNode(){ return 0; } + virtual ExprNode *semant(Environ *e) = 0; + virtual TNode *translate(Codegen *g) = 0; + virtual ConstNode *constNode() { return 0; } }; -struct ExprSeqNode : public Node{ +struct ExprSeqNode : public Node { vector exprs; - ~ExprSeqNode(){ for( ;exprs.size();exprs.pop_back() ) delete exprs.back(); } - void push_back( ExprNode *e ){ exprs.push_back( e ); } - int size(){ return exprs.size(); } - void semant( Environ *e ); - TNode *translate( Codegen *g,bool userlib ); - void castTo( DeclSeq *ds,Environ *e,bool userlib ); - void castTo( Type *t,Environ *e ); + ~ExprSeqNode() { for (; exprs.size(); exprs.pop_back()) delete exprs.back(); } + void push_back(ExprNode *e) { exprs.push_back(e); } + int size() { return exprs.size(); } + void semant(Environ *e); + TNode *translate(Codegen *g, bool userlib); + void castTo(DeclSeq *ds, Environ *e, bool userlib); + void castTo(Type *t, Environ *e); }; #include "varnode.h" -struct CastNode : public ExprNode{ +struct CastNode : public ExprNode { ExprNode *expr; Type *type; - CastNode( ExprNode *ex,Type *ty ):expr( ex ),type( ty ){} - ~CastNode(){ delete expr; } - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + CastNode(ExprNode *ex, Type *ty) :expr(ex), type(ty) {} + ~CastNode() { delete expr; } + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct CallNode : public ExprNode{ - string ident,tag; +struct CallNode : public ExprNode { + string ident, tag; ExprSeqNode *exprs; Decl *sem_decl; - CallNode( const string &i,const string &t,ExprSeqNode *e ):ident(i),tag(t),exprs(e){} - ~CallNode(){ delete exprs; } - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + CallNode(const string &i, const string &t, ExprSeqNode *e) :ident(i), tag(t), exprs(e) {} + ~CallNode() { delete exprs; } + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct VarExprNode : public ExprNode{ +struct VarExprNode : public ExprNode { VarNode *var; - VarExprNode( VarNode *v ):var(v){} - ~VarExprNode(){ delete var; } - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + VarExprNode(VarNode *v) :var(v) {} + ~VarExprNode() { delete var; } + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct ConstNode : public ExprNode{ - ExprNode *semant( Environ *e ){ return this; } - ConstNode *constNode(){ return this; } - virtual int intValue()=0; - virtual float floatValue()=0; - virtual string stringValue()=0; +struct ConstNode : public ExprNode { + ExprNode *semant(Environ *e) { return this; } + ConstNode *constNode() { return this; } + virtual int intValue() = 0; + virtual float floatValue() = 0; + virtual string stringValue() = 0; }; -struct IntConstNode : public ConstNode{ +struct IntConstNode : public ConstNode { int value; - IntConstNode( int n ); - TNode *translate( Codegen *g ); + IntConstNode(int n); + TNode *translate(Codegen *g); int intValue(); float floatValue(); string stringValue(); }; -struct FloatConstNode : public ConstNode{ +struct FloatConstNode : public ConstNode { float value; - FloatConstNode( float f ); - TNode *translate( Codegen *g ); + FloatConstNode(float f); + TNode *translate(Codegen *g); int intValue(); float floatValue(); string stringValue(); }; -struct StringConstNode : public ConstNode{ +struct StringConstNode : public ConstNode { string value; - StringConstNode( const string &s ); - TNode *translate( Codegen *g ); + StringConstNode(const string &s); + TNode *translate(Codegen *g); int intValue(); float floatValue(); string stringValue(); }; -struct UniExprNode : public ExprNode{ - int op;ExprNode *expr; - UniExprNode( int op,ExprNode *expr ):op( op ),expr( expr ){} - ~UniExprNode(){ delete expr; } +struct UniExprNode : public ExprNode { + int op; ExprNode *expr; + UniExprNode(int op, ExprNode *expr) :op(op), expr(expr) {} + ~UniExprNode() { delete expr; } ExprNode *constize(); - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; // and, or, eor, lsl, lsr, asr -struct BinExprNode : public ExprNode{ - int op;ExprNode *lhs,*rhs; - BinExprNode( int op,ExprNode *lhs,ExprNode *rhs ):op( op ),lhs( lhs ),rhs( rhs ){} - ~BinExprNode(){ delete lhs;delete rhs; } - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); +struct BinExprNode : public ExprNode { + int op; ExprNode *lhs, *rhs; + BinExprNode(int op, ExprNode *lhs, ExprNode *rhs) :op(op), lhs(lhs), rhs(rhs) {} + ~BinExprNode() { delete lhs; delete rhs; } + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; // *,/,Mod,+,- -struct ArithExprNode : public ExprNode{ - int op;ExprNode *lhs,*rhs; - ArithExprNode( int op,ExprNode *lhs,ExprNode *rhs ):op( op ),lhs( lhs ),rhs( rhs ){} - ~ArithExprNode(){ delete lhs;delete rhs; } - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); +struct ArithExprNode : public ExprNode { + int op; ExprNode *lhs, *rhs; + ArithExprNode(int op, ExprNode *lhs, ExprNode *rhs) :op(op), lhs(lhs), rhs(rhs) {} + ~ArithExprNode() { delete lhs; delete rhs; } + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; //<,=,>,<=,<>,>= -struct RelExprNode : public ExprNode{ - int op;ExprNode *lhs,*rhs; +struct RelExprNode : public ExprNode { + int op; ExprNode *lhs, *rhs; Type *opType; - RelExprNode( int op,ExprNode *lhs,ExprNode *rhs ):op( op ),lhs( lhs ),rhs( rhs ){} - ~RelExprNode(){ delete lhs;delete rhs; } - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + RelExprNode(int op, ExprNode *lhs, ExprNode *rhs) :op(op), lhs(lhs), rhs(rhs) {} + ~RelExprNode() { delete lhs; delete rhs; } + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct NewNode : public ExprNode{ +struct NewNode : public ExprNode { string ident; - NewNode( const string &i ):ident(i){} - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + NewNode(const string &i) :ident(i) {} + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct FirstNode : public ExprNode{ +struct FirstNode : public ExprNode { string ident; - FirstNode( const string &i ):ident(i){} - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + FirstNode(const string &i) :ident(i) {} + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct LastNode : public ExprNode{ +struct LastNode : public ExprNode { string ident; - LastNode( const string &i ):ident(i){} - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + LastNode(const string &i) :ident(i) {} + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct AfterNode : public ExprNode{ +struct AfterNode : public ExprNode { ExprNode *expr; - AfterNode( ExprNode *e ):expr(e){} - ~AfterNode(){ delete expr; } - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + AfterNode(ExprNode *e) :expr(e) {} + ~AfterNode() { delete expr; } + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct BeforeNode : public ExprNode{ +struct BeforeNode : public ExprNode { ExprNode *expr; - BeforeNode( ExprNode *e ):expr(e){} - ~BeforeNode(){ delete expr; } - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + BeforeNode(ExprNode *e) :expr(e) {} + ~BeforeNode() { delete expr; } + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct NullNode : public ExprNode{ - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); +struct NullNode : public ExprNode { + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct ObjectCastNode : public ExprNode{ +struct ObjectCastNode : public ExprNode { ExprNode *expr; string type_ident; - ObjectCastNode( ExprNode *e,const string &t ):expr(e),type_ident(t){} - ~ObjectCastNode(){ delete expr; } - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + ObjectCastNode(ExprNode *e, const string &t) :expr(e), type_ident(t) {} + ~ObjectCastNode() { delete expr; } + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; -struct ObjectHandleNode : public ExprNode{ +struct ObjectHandleNode : public ExprNode { ExprNode *expr; - ObjectHandleNode( ExprNode *e ):expr(e){} - ~ObjectHandleNode(){ delete expr; } - ExprNode *semant( Environ *e ); - TNode *translate( Codegen *g ); + ObjectHandleNode(ExprNode *e) :expr(e) {} + ~ObjectHandleNode() { delete expr; } + ExprNode *semant(Environ *e); + TNode *translate(Codegen *g); }; #endif diff --git a/compiler/node.cpp b/compiler/node.cpp index 47490c3..bd90b8b 100644 --- a/compiler/node.cpp +++ b/compiler/node.cpp @@ -98,7 +98,7 @@ TNode *Node::createVars( Environ *e ){ // release local vars // //////////////////////// TNode *Node::deleteVars( Environ *e ){ - TNode *t=0,*l=0,*p,*p1,*p2; + TNode *t=0,*l=0,*p,*p1 = nullptr,*p2 = nullptr; for( int k=0;kdecls->size();++k ){ Decl *d=e->decls->decls[k]; Type *type=d->type; diff --git a/compiler/stmtnode.cpp b/compiler/stmtnode.cpp index 6043c8e..dd8d2f1 100644 --- a/compiler/stmtnode.cpp +++ b/compiler/stmtnode.cpp @@ -3,301 +3,299 @@ #include "nodes.h" static string fileLabel; -static map fileMap; +static map fileMap; -void StmtNode::debug( int pos,Codegen *g ){ - if( g->debug ){ - TNode *t=fileLabel.size() ? global( fileLabel ) : iconst(0); - g->code( call( "__bbDebugStmt",iconst( pos ),t ) ); +void StmtNode::debug(int pos, Codegen *g) { + if (g->debug) { + TNode *t = fileLabel.size() ? global(fileLabel) : iconst(0); + g->code(call("__bbDebugStmt", iconst(pos), t)); } } -void StmtSeqNode::reset( const string &file,const string &lab ){ - fileLabel=""; +void StmtSeqNode::reset(const string &file, const string &lab) { + fileLabel = ""; fileMap.clear(); - fileMap[file]=lab; + fileMap[file] = lab; } //////////////////////// // Statement Sequence // //////////////////////// -void StmtSeqNode::semant( Environ *e ){ - for( int k=0;ksemant( e ); } - catch( Ex &x ){ - if( x.pos<0 ) x.pos=stmts[k]->pos; - if( !x.file.size() ) x.file=file; - throw; +void StmtSeqNode::semant(Environ *e) { + for (int k = 0; k < stmts.size(); ++k) { + try { stmts[k]->semant(e); } catch (Ex &x) { + if (x.pos < 0) x.pos = stmts[k]->pos; + if (!x.file.size()) x.file = file; + throw; } } } -void StmtSeqNode::translate( Codegen *g ){ +void StmtSeqNode::translate(Codegen *g) { - string t=fileLabel; - fileLabel=file.size() ? fileMap[file] : ""; - for( int k=0;kdebug( stmts[k]->pos,g ); - try{ - stmt->translate( g ); - } - catch( Ex &x ){ - if( x.pos<0 ) x.pos=stmts[k]->pos; - if( !x.file.size() ) x.file=file; - throw; + string t = fileLabel; + fileLabel = file.size() ? fileMap[file] : ""; + for (int k = 0; k < stmts.size(); ++k) { + StmtNode *stmt = stmts[k]; + stmt->debug(stmts[k]->pos, g); + try { + stmt->translate(g); + } catch (Ex &x) { + if (x.pos < 0) x.pos = stmts[k]->pos; + if (!x.file.size()) x.file = file; + throw; } } - fileLabel=t; + fileLabel = t; } ///////////////// // An Include! // ///////////////// -void IncludeNode::semant( Environ *e ){ +void IncludeNode::semant(Environ *e) { - label=genLabel(); - fileMap[file]=label; - - stmts->semant( e ); + label = genLabel(); + fileMap[file] = label; + + stmts->semant(e); } -void IncludeNode::translate( Codegen *g ){ +void IncludeNode::translate(Codegen *g) { - if( g->debug ) g->s_data( file,label ); + if (g->debug) g->s_data(file, label); - stmts->translate( g ); + stmts->translate(g); } /////////////////// // a declaration // /////////////////// -void DeclStmtNode::semant( Environ *e ){ - decl->proto( e->decls,e ); - decl->semant( e ); +void DeclStmtNode::semant(Environ *e) { + decl->proto(e->decls, e); + decl->semant(e); } -void DeclStmtNode::translate( Codegen *g ){ - decl->translate( g ); +void DeclStmtNode::translate(Codegen *g) { + decl->translate(g); } ////////////////////////////// // Dim AND declare an Array // ////////////////////////////// -void DimNode::semant( Environ *e ){ - Type *t=tagType( tag,e ); - if( Decl *d=e->findDecl( ident ) ){ - ArrayType *a=d->type->arrayType(); - if( !a || a->dims!=exprs->size() || (t && a->elementType!=t) ){ - ex( "Duplicate identifier" ); +void DimNode::semant(Environ *e) { + Type *t = tagType(tag, e); + if (Decl *d = e->findDecl(ident)) { + ArrayType *a = d->type->arrayType(); + if (!a || a->dims != exprs->size() || (t && a->elementType != t)) { + ex("Duplicate identifier"); } - sem_type=a;sem_decl=0; - }else{ - if( e->level>0 ) ex( "Array not found in main program" ); - if( !t ) t=Type::int_type; - sem_type=d_new ArrayType( t,exprs->size() ); - sem_decl=e->decls->insertDecl( ident,sem_type,DECL_ARRAY ); - e->types.push_back( sem_type ); + sem_type = a; sem_decl = 0; + } else { + if (e->level > 0) ex("Array not found in main program"); + if (!t) t = Type::int_type; + sem_type = d_new ArrayType(t, exprs->size()); + sem_decl = e->decls->insertDecl(ident, sem_type, DECL_ARRAY); + e->types.push_back(sem_type); } - exprs->semant( e ); - exprs->castTo( Type::int_type,e ); + exprs->semant(e); + exprs->castTo(Type::int_type, e); } -void DimNode::translate( Codegen *g ){ +void DimNode::translate(Codegen *g) { TNode *t; - g->code( call( "__bbUndimArray",global( "_a"+ident ) ) ); - for( int k=0;ksize();++k ){ - t=add( global( "_a"+ident ),iconst( k*4+12 ) ); - t=move( exprs->exprs[k]->translate(g),mem( t ) ); - g->code( t ); + g->code(call("__bbUndimArray", global("_a" + ident))); + for (int k = 0; k < exprs->size(); ++k) { + t = add(global("_a" + ident), iconst(k * 4 + 12)); + t = move(exprs->exprs[k]->translate(g), mem(t)); + g->code(t); } - g->code( call( "__bbDimArray",global( "_a"+ident ) ) ); + g->code(call("__bbDimArray", global("_a" + ident))); - if( !sem_decl ) return; + if (!sem_decl) return; - int et; - Type *ty=sem_type->arrayType()->elementType; - if( ty==Type::int_type ) et=1; - else if( ty==Type::float_type ) et=2; - else if( ty==Type::string_type ) et=3; - else et=5; + int et, k; + Type *ty = sem_type->arrayType()->elementType; + if (ty == Type::int_type) et = 1; + else if (ty == Type::float_type) et = 2; + else if (ty == Type::string_type) et = 3; + else et = 5; - g->align_data( 4 ); - g->i_data( 0,"_a"+ident ); - g->i_data( et ); - g->i_data( exprs->size() ); - for( k=0;ksize();++k ) g->i_data( 0 ); + g->align_data(4); + g->i_data(0, "_a" + ident); + g->i_data(et); + g->i_data(exprs->size()); + for (k = 0; k < exprs->size(); ++k) g->i_data(0); } //////////////// // Assignment // //////////////// -void AssNode::semant( Environ *e ){ - var->semant( e ); - if( var->sem_type->constType() ) ex( "Constants can not be assigned to" ); - if( var->sem_type->vectorType() ) ex( "Blitz arrays can not be assigned to" ); - expr=expr->semant( e ); - expr=expr->castTo( var->sem_type,e ); +void AssNode::semant(Environ *e) { + var->semant(e); + if (var->sem_type->constType()) ex("Constants can not be assigned to"); + if (var->sem_type->vectorType()) ex("Blitz arrays can not be assigned to"); + expr = expr->semant(e); + expr = expr->castTo(var->sem_type, e); } -void AssNode::translate( Codegen *g ){ - g->code( var->store( g,expr->translate( g ) ) ); +void AssNode::translate(Codegen *g) { + g->code(var->store(g, expr->translate(g))); } ////////////////////////// // Expression statement // ////////////////////////// -void ExprStmtNode::semant( Environ *e ){ - expr=expr->semant( e ); +void ExprStmtNode::semant(Environ *e) { + expr = expr->semant(e); } -void ExprStmtNode::translate( Codegen *g ){ - TNode *t=expr->translate( g ); - if( expr->sem_type==Type::string_type ) t=call( "__bbStrRelease",t ); - g->code( t ); +void ExprStmtNode::translate(Codegen *g) { + TNode *t = expr->translate(g); + if (expr->sem_type == Type::string_type) t = call("__bbStrRelease", t); + g->code(t); } //////////////// // user label // //////////////// -void LabelNode::semant( Environ *e ){ - if( Label *l=e->findLabel( ident ) ){ - if( l->def>=0 ) ex( "duplicate label" ); - l->def=pos;l->data_sz=data_sz; - }else e->insertLabel( ident,pos,-1,data_sz ); - ident=e->funcLabel+ident; +void LabelNode::semant(Environ *e) { + if (Label *l = e->findLabel(ident)) { + if (l->def >= 0) ex("duplicate label"); + l->def = pos; l->data_sz = data_sz; + } else e->insertLabel(ident, pos, -1, data_sz); + ident = e->funcLabel + ident; } -void LabelNode::translate( Codegen *g ){ - g->label( "_l"+ident ); +void LabelNode::translate(Codegen *g) { + g->label("_l" + ident); } ////////////////// // Restore data // ////////////////// -void RestoreNode::semant( Environ *e ){ - if( e->level>0 ) e=e->globals; +void RestoreNode::semant(Environ *e) { + if (e->level > 0) e = e->globals; - if( ident.size()==0 ) sem_label=0; - else{ - sem_label=e->findLabel( ident ); - if( !sem_label ) sem_label=e->insertLabel( ident,-1,pos,-1 ); + if (ident.size() == 0) sem_label = 0; + else { + sem_label = e->findLabel(ident); + if (!sem_label) sem_label = e->insertLabel(ident, -1, pos, -1); } } -void RestoreNode::translate( Codegen *g ){ - TNode *t=global( "__DATA" ); - if( sem_label ) t=add( t,iconst( sem_label->data_sz*8 ) ); - g->code( call( "__bbRestore",t ) ); +void RestoreNode::translate(Codegen *g) { + TNode *t = global("__DATA"); + if (sem_label) t = add(t, iconst(sem_label->data_sz * 8)); + g->code(call("__bbRestore", t)); } //////////////////// // Goto statement // //////////////////// -void GotoNode::semant( Environ *e ){ - if( !e->findLabel( ident ) ){ - e->insertLabel( ident,-1,pos,-1 ); +void GotoNode::semant(Environ *e) { + if (!e->findLabel(ident)) { + e->insertLabel(ident, -1, pos, -1); } - ident=e->funcLabel+ident; + ident = e->funcLabel + ident; } -void GotoNode::translate( Codegen *g ){ - g->code( jump( "_l"+ident ) ); +void GotoNode::translate(Codegen *g) { + g->code(jump("_l" + ident)); } ///////////////////// // Gosub statement // ///////////////////// -void GosubNode::semant( Environ *e ){ - if( e->level>0 ) ex( "'Gosub' may not be used inside a function" ); - if( !e->findLabel( ident ) ) e->insertLabel( ident,-1,pos,-1 ); - ident=e->funcLabel+ident; +void GosubNode::semant(Environ *e) { + if (e->level > 0) ex("'Gosub' may not be used inside a function"); + if (!e->findLabel(ident)) e->insertLabel(ident, -1, pos, -1); + ident = e->funcLabel + ident; } -void GosubNode::translate( Codegen *g ){ - g->code( jsr( "_l"+ident ) ); +void GosubNode::translate(Codegen *g) { + g->code(jsr("_l" + ident)); } ////////////////// // If statement // ////////////////// -void IfNode::semant( Environ *e ){ - expr=expr->semant( e ); - expr=expr->castTo( Type::int_type,e ); - stmts->semant( e ); - if( elseOpt ) elseOpt->semant( e ); +void IfNode::semant(Environ *e) { + expr = expr->semant(e); + expr = expr->castTo(Type::int_type, e); + stmts->semant(e); + if (elseOpt) elseOpt->semant(e); } -void IfNode::translate( Codegen *g ){ - if( ConstNode *c=expr->constNode() ){ - if( c->intValue() ) stmts->translate( g ); - else if( elseOpt ) elseOpt->translate( g ); - }else{ - string _else=genLabel(); - g->code( jumpf( expr->translate( g ),_else ) ); - stmts->translate( g ); - if( elseOpt ){ - string _else2=genLabel(); - g->code( jump( _else2 ) ); - g->label( _else ); - elseOpt->translate( g ); - _else=_else2; +void IfNode::translate(Codegen *g) { + if (ConstNode *c = expr->constNode()) { + if (c->intValue()) stmts->translate(g); + else if (elseOpt) elseOpt->translate(g); + } else { + string _else = genLabel(); + g->code(jumpf(expr->translate(g), _else)); + stmts->translate(g); + if (elseOpt) { + string _else2 = genLabel(); + g->code(jump(_else2)); + g->label(_else); + elseOpt->translate(g); + _else = _else2; } - g->label( _else ); + g->label(_else); } } /////////// // Break // /////////// -void ExitNode::semant( Environ *e ){ - sem_brk=e->breakLabel; - if( !sem_brk.size() ) ex( "break must appear inside a loop" ); +void ExitNode::semant(Environ *e) { + sem_brk = e->breakLabel; + if (!sem_brk.size()) ex("break must appear inside a loop"); } -void ExitNode::translate( Codegen *g ){ - g->code( d_new TNode( IR_JUMP,0,0,sem_brk ) ); +void ExitNode::translate(Codegen *g) { + g->code(d_new TNode(IR_JUMP, 0, 0, sem_brk)); } ///////////////////// // While statement // ///////////////////// -void WhileNode::semant( Environ *e ){ - expr=expr->semant( e ); - expr=expr->castTo( Type::int_type,e ); - string brk=e->setBreak( sem_brk=genLabel() ); - stmts->semant( e ); - e->setBreak( brk ); +void WhileNode::semant(Environ *e) { + expr = expr->semant(e); + expr = expr->castTo(Type::int_type, e); + string brk = e->setBreak(sem_brk = genLabel()); + stmts->semant(e); + e->setBreak(brk); } -void WhileNode::translate( Codegen *g ){ - string loop=genLabel(); - if( ConstNode *c=expr->constNode() ){ - if( !c->intValue() ) return; - g->label( loop ); - stmts->translate( g ); - g->code( jump( loop ) ); - }else{ - string cond=genLabel(); - g->code( jump( cond ) ); - g->label( loop ); - stmts->translate( g ); - debug( wendPos,g ); - g->label( cond ); - g->code( jumpt( expr->translate( g ),loop ) ); +void WhileNode::translate(Codegen *g) { + string loop = genLabel(); + if (ConstNode *c = expr->constNode()) { + if (!c->intValue()) return; + g->label(loop); + stmts->translate(g); + g->code(jump(loop)); + } else { + string cond = genLabel(); + g->code(jump(cond)); + g->label(loop); + stmts->translate(g); + debug(wendPos, g); + g->label(cond); + g->code(jumpt(expr->translate(g), loop)); } - g->label( sem_brk ); + g->label(sem_brk); } /////////////////// // For/Next loop // /////////////////// -ForNode::ForNode( VarNode *var,ExprNode *from,ExprNode *to,ExprNode *step,StmtSeqNode *ss,int np ) -:var(var),fromExpr(from),toExpr(to),stepExpr(step),stmts(ss),nextPos(np){ +ForNode::ForNode(VarNode *var, ExprNode *from, ExprNode *to, ExprNode *step, StmtSeqNode *ss, int np) + :var(var), fromExpr(from), toExpr(to), stepExpr(step), stmts(ss), nextPos(np) { } -ForNode::~ForNode(){ +ForNode::~ForNode() { delete stmts; delete stepExpr; delete toExpr; @@ -305,282 +303,283 @@ ForNode::~ForNode(){ delete var; } -void ForNode::semant( Environ *e ){ - var->semant( e ); - Type *ty=var->sem_type; - if( ty->constType() ) ex( "Index variable can not be constant" ); - if( ty!=Type::int_type && ty!=Type::float_type ){ - ex( "index variable must be integer or real" ); +void ForNode::semant(Environ *e) { + var->semant(e); + Type *ty = var->sem_type; + if (ty->constType()) ex("Index variable can not be constant"); + if (ty != Type::int_type && ty != Type::float_type) { + ex("index variable must be integer or real"); } - fromExpr=fromExpr->semant( e ); - fromExpr=fromExpr->castTo( ty,e ); - toExpr=toExpr->semant( e ); - toExpr=toExpr->castTo( ty,e ); - stepExpr=stepExpr->semant( e ); - stepExpr=stepExpr->castTo( ty,e ); + fromExpr = fromExpr->semant(e); + fromExpr = fromExpr->castTo(ty, e); + toExpr = toExpr->semant(e); + toExpr = toExpr->castTo(ty, e); + stepExpr = stepExpr->semant(e); + stepExpr = stepExpr->castTo(ty, e); - if( !stepExpr->constNode() ) ex( "Step value must be constant" ); + if (!stepExpr->constNode()) ex("Step value must be constant"); - string brk=e->setBreak( sem_brk=genLabel() ); - stmts->semant( e ); - e->setBreak( brk ); + string brk = e->setBreak(sem_brk = genLabel()); + stmts->semant(e); + e->setBreak(brk); } -void ForNode::translate( Codegen *g ){ +void ForNode::translate(Codegen *g) { - TNode *t;Type *ty=var->sem_type; + TNode *t; Type *ty = var->sem_type; //initial assignment - g->code( var->store( g,fromExpr->translate( g ) ) ); + g->code(var->store(g, fromExpr->translate(g))); - string cond=genLabel(); - string loop=genLabel(); - g->code( jump( cond ) ); - g->label( loop ); - stmts->translate( g ); + string cond = genLabel(); + string loop = genLabel(); + g->code(jump(cond)); + g->label(loop); + stmts->translate(g); //execute the step part - debug( nextPos,g ); - int op=ty==Type::int_type ? IR_ADD : IR_FADD; - t=d_new TNode( op,var->load( g ),stepExpr->translate( g ) ); - g->code( var->store( g,t ) ); + debug(nextPos, g); + int op = ty == Type::int_type ? IR_ADD : IR_FADD; + t = d_new TNode(op, var->load(g), stepExpr->translate(g)); + g->code(var->store(g, t)); //test for loop cond - g->label( cond ); - op=stepExpr->constNode()->floatValue()>0 ? '>' : '<'; - t=compare( op,var->load( g ),toExpr->translate( g ),ty ); - g->code( jumpf( t,loop ) ); + g->label(cond); + op = stepExpr->constNode()->floatValue() > 0 ? '>' : '<'; + t = compare(op, var->load(g), toExpr->translate(g), ty); + g->code(jumpf(t, loop)); - g->label( sem_brk ); + g->label(sem_brk); } /////////////////////////////// // For each object of a type // /////////////////////////////// -void ForEachNode::semant( Environ *e ){ - var->semant( e ); - Type *ty=var->sem_type; +void ForEachNode::semant(Environ *e) { + var->semant(e); + Type *ty = var->sem_type; - if( ty->structType()==0 ) ex( "Index variable is not a NewType" ); - Type *t=e->findType( typeIdent ); - if( !t ) ex( "Type name not found" ); - if( t!=ty ) ex( "Type mismatch" ); + if (ty->structType() == 0) ex("Index variable is not a NewType"); + Type *t = e->findType(typeIdent); + if (!t) ex("Type name not found"); + if (t != ty) ex("Type mismatch"); - string brk=e->setBreak( sem_brk=genLabel() ); - stmts->semant( e ); - e->setBreak( brk ); + string brk = e->setBreak(sem_brk = genLabel()); + stmts->semant(e); + e->setBreak(brk); } -void ForEachNode::translate( Codegen *g ){ - TNode *t,*l,*r; - string _loop=genLabel(); +void ForEachNode::translate(Codegen *g) { + TNode *t, *l, *r; + string _loop = genLabel(); - string objFirst,objNext; + string objFirst, objNext; - if( var->isObjParam() ){ - objFirst="__bbObjEachFirst2"; - objNext="__bbObjEachNext2"; - }else{ - objFirst="__bbObjEachFirst"; - objNext="__bbObjEachNext"; + if (var->isObjParam()) { + objFirst = "__bbObjEachFirst2"; + objNext = "__bbObjEachNext2"; + } else { + objFirst = "__bbObjEachFirst"; + objNext = "__bbObjEachNext"; } - l=var->translate( g ); - r=global( "_t"+typeIdent ); - t=jumpf( call( objFirst,l,r ),sem_brk ); - g->code( t ); + l = var->translate(g); + r = global("_t" + typeIdent); + t = jumpf(call(objFirst, l, r), sem_brk); + g->code(t); - g->label( _loop ); - stmts->translate( g ); + g->label(_loop); + stmts->translate(g); - debug( nextPos,g ); - t=jumpt( call( objNext,var->translate( g ) ),_loop ); - g->code( t ); + debug(nextPos, g); + t = jumpt(call(objNext, var->translate(g)), _loop); + g->code(t); - g->label( sem_brk ); + g->label(sem_brk); } //////////////////////////// // Return from a function // //////////////////////////// -void ReturnNode::semant( Environ *e ){ - if( e->level<=0 && expr ){ - ex( "Main program cannot return a value" ); +void ReturnNode::semant(Environ *e) { + if (e->level <= 0 && expr) { + ex("Main program cannot return a value"); } - if( e->level>0 ){ - if( !expr ){ - if( e->returnType==Type::float_type ){ - expr=d_new FloatConstNode( 0 ); - }else if( e->returnType==Type::string_type ){ - expr=d_new StringConstNode( "" ); - }else if( e->returnType->structType() ){ - expr=d_new NullNode(); - }else{ - expr=d_new IntConstNode( 0 ); + if (e->level > 0) { + if (!expr) { + if (e->returnType == Type::float_type) { + expr = d_new FloatConstNode(0); + } else if (e->returnType == Type::string_type) { + expr = d_new StringConstNode(""); + } else if (e->returnType->structType()) { + expr = d_new NullNode(); + } else { + expr = d_new IntConstNode(0); } } - expr=expr->semant( e ); - expr=expr->castTo( e->returnType,e ); - returnLabel=e->funcLabel+"_leave"; + expr = expr->semant(e); + expr = expr->castTo(e->returnType, e); + returnLabel = e->funcLabel + "_leave"; } } -void ReturnNode::translate( Codegen *g ){ - if( !expr ){ - g->code( d_new TNode( IR_RET,0,0 ) ); +void ReturnNode::translate(Codegen *g) { + if (!expr) { + g->code(d_new TNode(IR_RET, 0, 0)); return; } - TNode *t=expr->translate( g ); + TNode *t = expr->translate(g); - if( expr->sem_type==Type::float_type ){ - g->code( d_new TNode( IR_FRETURN,t,0,returnLabel ) ); - }else{ - g->code( d_new TNode( IR_RETURN,t,0,returnLabel ) ); + if (expr->sem_type == Type::float_type) { + g->code(d_new TNode(IR_FRETURN, t, 0, returnLabel)); + } else { + g->code(d_new TNode(IR_RETURN, t, 0, returnLabel)); } } ////////////////////// // Delete statement // ////////////////////// -void DeleteNode::semant( Environ *e ){ - expr=expr->semant( e ); - if( expr->sem_type->structType()==0 ) ex( "Can't delete non-Newtype" ); +void DeleteNode::semant(Environ *e) { + expr = expr->semant(e); + if (expr->sem_type->structType() == 0) ex("Can't delete non-Newtype"); } -void DeleteNode::translate( Codegen *g ){ - TNode *t=expr->translate( g ); - g->code( call( "__bbObjDelete",t ) ); +void DeleteNode::translate(Codegen *g) { + TNode *t = expr->translate(g); + g->code(call("__bbObjDelete", t)); } /////////////////////////// // Delete each of a type // /////////////////////////// -void DeleteEachNode::semant( Environ *e ){ - Type *t=e->findType( typeIdent ); - if( !t || t->structType()==0 ) ex( "Specified name is not a NewType name" ); +void DeleteEachNode::semant(Environ *e) { + Type *t = e->findType(typeIdent); + if (!t || t->structType() == 0) ex("Specified name is not a NewType name"); } -void DeleteEachNode::translate( Codegen *g ){ - g->code( call( "__bbObjDeleteEach",global( "_t"+typeIdent ) ) ); +void DeleteEachNode::translate(Codegen *g) { + g->code(call("__bbObjDeleteEach", global("_t" + typeIdent))); } /////////////////////////// // Insert object in list // /////////////////////////// -void InsertNode::semant( Environ *e ){ - expr1=expr1->semant( e ); - expr2=expr2->semant( e ); - StructType *t1=expr1->sem_type->structType(); - StructType *t2=expr2->sem_type->structType(); - if( !t1 || !t2 ) ex( "Illegal expression type" ); - if( t1!=t2 ) ex( "Objects types are differnt" ); +void InsertNode::semant(Environ *e) { + expr1 = expr1->semant(e); + expr2 = expr2->semant(e); + StructType *t1 = expr1->sem_type->structType(); + StructType *t2 = expr2->sem_type->structType(); + if (!t1 || !t2) ex("Illegal expression type"); + if (t1 != t2) ex("Objects types are differnt"); } -void InsertNode::translate( Codegen *g ){ - TNode *t1=expr1->translate( g ); - if( g->debug ) t1=jumpf( t1,"__bbNullObjEx" ); - TNode *t2=expr2->translate( g ); - if( g->debug ) t2=jumpf( t2,"__bbNullObjEx" ); - string s=before ? "__bbObjInsBefore" : "__bbObjInsAfter"; - g->code( call( s,t1,t2 ) ); +void InsertNode::translate(Codegen *g) { + TNode *t1 = expr1->translate(g); + if (g->debug) t1 = jumpf(t1, "__bbNullObjEx"); + TNode *t2 = expr2->translate(g); + if (g->debug) t2 = jumpf(t2, "__bbNullObjEx"); + string s = before ? "__bbObjInsBefore" : "__bbObjInsAfter"; + g->code(call(s, t1, t2)); } //////////////////////// // A select statement // //////////////////////// -void SelectNode::semant( Environ *e ){ - expr=expr->semant( e ); - Type *ty=expr->sem_type; - if( ty->structType() ) ex( "Select cannot be used with objects" ); +void SelectNode::semant(Environ *e) { + expr = expr->semant(e); + Type *ty = expr->sem_type; + if (ty->structType()) ex("Select cannot be used with objects"); //we need a temp var - Decl *d=e->decls->insertDecl( genLabel(),expr->sem_type,DECL_LOCAL ); - sem_temp=d_new DeclVarNode( d ); + Decl *d = e->decls->insertDecl(genLabel(), expr->sem_type, DECL_LOCAL); + sem_temp = d_new DeclVarNode(d); - for( int k=0;kexprs->semant( e ); - c->exprs->castTo( ty,e ); - c->stmts->semant( e ); + for (int k = 0; k < cases.size(); ++k) { + CaseNode *c = cases[k]; + c->exprs->semant(e); + c->exprs->castTo(ty, e); + c->stmts->semant(e); } - if( defStmts ) defStmts->semant( e ); + if (defStmts) defStmts->semant(e); } -void SelectNode::translate( Codegen *g ){ +void SelectNode::translate(Codegen *g) { - Type *ty=expr->sem_type; + Type *ty = expr->sem_type; + int k; - g->code( sem_temp->store( g,expr->translate( g ) ) ); + g->code(sem_temp->store(g, expr->translate(g))); vector labs; - string brk=genLabel(); + string brk = genLabel(); - for( int k=0;kexprs->size();++j ){ - ExprNode *e=c->exprs->exprs[j]; - TNode *t=compare( '=',sem_temp->load( g ),e->translate( g ),ty ); - g->code( jumpt( t,labs.back() ) ); + for (k = 0; k < cases.size(); ++k) { + CaseNode *c = cases[k]; + labs.push_back(genLabel()); + for (int j = 0; j < c->exprs->size(); ++j) { + ExprNode *e = c->exprs->exprs[j]; + TNode *t = compare('=', sem_temp->load(g), e->translate(g), ty); + g->code(jumpt(t, labs.back())); } } - if( defStmts ) defStmts->translate( g ); - g->code( jump( brk ) ); - for( k=0;klabel( labs[k] ); - c->stmts->translate( g ); - g->code( jump( brk ) ); + if (defStmts) defStmts->translate(g); + g->code(jump(brk)); + for (k = 0; k < cases.size(); ++k) { + CaseNode *c = cases[k]; + g->label(labs[k]); + c->stmts->translate(g); + g->code(jump(brk)); } - g->label( brk ); + g->label(brk); } //////////////////////////// // Repeat...Until/Forever // //////////////////////////// -void RepeatNode::semant( Environ *e ){ - sem_brk=genLabel(); - string brk=e->setBreak( sem_brk ); - stmts->semant( e ); - e->setBreak( brk ); - if( expr ){ - expr=expr->semant( e ); - expr=expr->castTo( Type::int_type,e ); +void RepeatNode::semant(Environ *e) { + sem_brk = genLabel(); + string brk = e->setBreak(sem_brk); + stmts->semant(e); + e->setBreak(brk); + if (expr) { + expr = expr->semant(e); + expr = expr->castTo(Type::int_type, e); } } -void RepeatNode::translate( Codegen *g ){ +void RepeatNode::translate(Codegen *g) { - string loop=genLabel(); - g->label( loop ); - stmts->translate( g ); - debug( untilPos,g ); + string loop = genLabel(); + g->label(loop); + stmts->translate(g); + debug(untilPos, g); - if( ConstNode *c=expr ? expr->constNode() : 0 ){ - if( !c->intValue() ) g->code( jump( loop ) ); - }else{ - if( expr ) g->code( jumpf( expr->translate( g ),loop ) ); - else g->code( jump( loop ) ); + if (ConstNode *c = expr ? expr->constNode() : 0) { + if (!c->intValue()) g->code(jump(loop)); + } else { + if (expr) g->code(jumpf(expr->translate(g), loop)); + else g->code(jump(loop)); } - g->label( sem_brk ); + g->label(sem_brk); } /////////////// // Read data // /////////////// -void ReadNode::semant( Environ *e ){ - var->semant( e ); - if( var->sem_type->constType() ) ex( "Constants can not be modified" ); - if( var->sem_type->structType() ) ex( "Data can not be read into an object" ); +void ReadNode::semant(Environ *e) { + var->semant(e); + if (var->sem_type->constType()) ex("Constants can not be modified"); + if (var->sem_type->structType()) ex("Data can not be read into an object"); } -void ReadNode::translate( Codegen *g ){ +void ReadNode::translate(Codegen *g) { TNode *t; - if( var->sem_type==Type::int_type ) t=call( "__bbReadInt" ); - else if( var->sem_type==Type::float_type ) t=fcall( "__bbReadFloat" ); - else t=call( "__bbReadStr" ); - g->code( var->store( g,t ) ); + if (var->sem_type == Type::int_type) t = call("__bbReadInt"); + else if (var->sem_type == Type::float_type) t = fcall("__bbReadFloat"); + else t = call("__bbReadStr"); + g->code(var->store(g, t)); } diff --git a/config/Source.cpp b/config/Source.cpp new file mode 100644 index 0000000..217bdf4 --- /dev/null +++ b/config/Source.cpp @@ -0,0 +1,5 @@ +#include "config.h" + +void none() { + +} \ No newline at end of file diff --git a/config/config.vcxproj b/config/config.vcxproj index 558ab43..f571d8b 100644 --- a/config/config.vcxproj +++ b/config/config.vcxproj @@ -1,14 +1,6 @@  - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - Debug Win32 @@ -17,22 +9,15 @@ Release Win32 - - Template - Win32 - {3E355353-96D8-4AAF-BF95-8E6CA0D4B1BA} - 10.0.10586.0 + Configuration + 8.1 - - Application - v140 - StaticLibrary v140 @@ -45,24 +30,9 @@ false MultiByte - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte - - - - @@ -71,108 +41,45 @@ - - - - - - - - - - .\config___Win32_Blitz2DRelease\ - .\config___Win32_Blitz2DRelease\ - false - - - .\config___Win32_Blitz3DRelease\ - .\config___Win32_Blitz3DRelease\ - false - - .\Release\ - .\Release\ + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 ..\#Build\$(ProjectName)\$(ConfigurationName)\ ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ true + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\config___Win32_Blitz2DRelease\ - .\config___Win32_Blitz2DRelease\config.pch - .\config___Win32_Blitz2DRelease\ - .\config___Win32_Blitz2DRelease\ - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\config___Win32_Blitz2DRelease\config.bsc - - - true - .\config___Win32_Blitz2DRelease\config.lib - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - _LIB;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\config___Win32_Blitz3DRelease\ - .\config___Win32_Blitz3DRelease\config.pch - .\config___Win32_Blitz3DRelease\ - .\config___Win32_Blitz3DRelease\ - StdCall - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\config___Win32_Blitz3DRelease\config.bsc - - - true - .\config___Win32_Blitz3DRelease\config.lib - - MultiThreaded - AnySuitable + OnlyExplicitInline true MaxSpeed true Level3 true - Size + Speed true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\Release\ - .\Release\config.pch - .\Release\ - .\Release\ + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + $(IntDir)vc$(PlatformToolsetVersion).pdb + false + false + false + StdCall 0x0409 @@ -184,24 +91,34 @@ true - .\Release\config.lib + MachineX86 MultiThreadedDebug Default - false + true Disabled true - Level3 true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\config.pch - .\Debug\ - .\Debug\ + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) EnableFastChecks + true + true + true + false + false + true + Guard + Level3 + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + true + true + false + StdCall 0x0409 @@ -213,12 +130,15 @@ true - .\Debug\config.lib + MachineX86 + + + diff --git a/debugger/debugger.vcxproj b/debugger/debugger.vcxproj index 5069918..756708c 100644 --- a/debugger/debugger.vcxproj +++ b/debugger/debugger.vcxproj @@ -1,14 +1,6 @@  - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - Debug Win32 @@ -17,104 +9,77 @@ Release Win32 - - Template - Win32 - MFCProj {4132C330-95D9-4F68-A51A-3B90381587C5} - 10.0.10586.0 + Debugger + 8.1 - - Application - v140 - DynamicLibrary v140 - Static - MultiByte - - - DynamicLibrary - v140 - Static - MultiByte - - - DynamicLibrary - v140 - Static + false MultiByte DynamicLibrary v140 - Static + false MultiByte - - - - - - - - - - - - .\Release\ - .\Release\ - false - - - .\debugger___Win32_Blitz2DRelease\ - .\debugger___Win32_Blitz2DRelease\ - false - - - .\debugger___Win32_Blitz3DRelease\ - .\debugger___Win32_Blitz3DRelease\ - false - - - ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Test\bin\ ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + + + ..\#Test\bin\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ + false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 MultiThreaded - Default + OnlyExplicitInline true true - MinSpace + MaxSpeed true Level3 - WIN32;NDEBUG;_WINDOWS;_USRDLL;DEBUGGER_EXPORTS;%(PreprocessorDefinitions) - .\Release\ - .\Release\debugger.pch - .\Release\ - .\Release\ + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + true + Speed + false + false + false + StdCall true @@ -135,102 +100,33 @@ true true Windows - ..\blitzbasic\bin\debugger.dll .\Release\debugger.lib - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_WINDOWS;_USRDLL;DEBUGGER_EXPORTS;%(PreprocessorDefinitions) - .\debugger___Win32_Blitz2DRelease\ - .\debugger___Win32_Blitz2DRelease\debugger.pch - .\debugger___Win32_Blitz2DRelease\ - .\debugger___Win32_Blitz2DRelease\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\debugger___Win32_Blitz2DRelease\debugger.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\debugger___Win32_Blitz2DRelease\debugger.bsc - - - true - true - Windows - ..\..\release\blitz2drelease\bin\debugger.dll - .\debugger___Win32_Blitz2DRelease\debugger.lib - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - _WINDOWS;_USRDLL;DEBUGGER_EXPORTS;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\debugger___Win32_Blitz3DRelease\ - .\debugger___Win32_Blitz3DRelease\debugger.pch - .\debugger___Win32_Blitz3DRelease\ - .\debugger___Win32_Blitz3DRelease\ - StdCall - - - true - NDEBUG;%(PreprocessorDefinitions) - .\debugger___Win32_Blitz3DRelease\debugger.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\debugger___Win32_Blitz3DRelease\debugger.bsc - - - true - true - Windows - ../_release/bin/debugger.dll - .\debugger___Win32_Blitz3DRelease\debugger.lib - - MultiThreadedDebug Default - false + true Disabled true - Level3 true - WIN32;_DEBUG;_WINDOWS;_USRDLL;DEBUGGER_EXPORTS;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\debugger.pch - .\Debug\ - .\Debug\ + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) EnableFastChecks + true + true + true + false + false + true + Guard + Level3 + true + Speed + true + true + false + StdCall true @@ -252,7 +148,6 @@ true true Console - ..\blitzbasic\bin\debugger.dll .\Debug\debugger.lib /FIXED:NO @@ -269,10 +164,6 @@ Create stdafx.h - Create - stdafx.h - Create - stdafx.h diff --git a/debugger/debugtree.cpp b/debugger/debugtree.cpp index e4393b9..ad913ca 100644 --- a/debugger/debugtree.cpp +++ b/debugger/debugtree.cpp @@ -3,7 +3,7 @@ #include "debugtree.h" #include "prefs.h" -#include "../bbruntime/basic.h" +#include "../RuntimeLib/basic.h" IMPLEMENT_DYNAMIC( DebugTree,CTreeCtrl ) BEGIN_MESSAGE_MAP( DebugTree,CTreeCtrl ) diff --git a/debugger/debugtree.h b/debugger/debugtree.h index c1e3da4..cd06047 100644 --- a/debugger/debugtree.h +++ b/debugger/debugtree.h @@ -2,8 +2,8 @@ #ifndef DEBUGTREE_H #define DEBUGTREE_H -#include "../linker/linker.h" -#include "../compiler/environ.h" +#include "../LinkerLib/linker.h" +#include "../Compiler/environ.h" class DebugTree : public CTreeCtrl{ int st_nest; diff --git a/debugger/sourcefile.cpp b/debugger/sourcefile.cpp index 57c3325..89ee238 100644 --- a/debugger/sourcefile.cpp +++ b/debugger/sourcefile.cpp @@ -39,11 +39,11 @@ void SourceFile::highLight( int row,int col ){ bool quote=false; int end=pos,len=GetTextLength(); while( end -

Plugin functions - -

- -

From version 2.1.0 on FreeImage provides a new, simplified interface besides the old style API. - -

- -

The new API, known as the plugin API, treats bitmap formats and their accompanied loader and saver routines as plugin modules. A new series of functions provides access to these plugins. For example the new functions provide the means to retrieve a list of supported bitmap formats, as well as their descriptions and their possible file extensions. The new API has many advantages over the old one. - -

- -

For a start the plugin interface will enable FreeImage's hot swap technology: a feature that allows you to compile and link the library only once in your program making instantly profit from bug fixes, newly supported bitmap formats and more without ever recompiling again. Second it opens the way to use plugins. You won't have these advantages when you use the standard API. - -

-

Subsections

- - - -

FreeImage_GetFIFByIndex - -

- -

FREE_IMAGE_FORMAT FreeImage_GetFIFByIndex(int index); - -

- -

Returns the needed plugin id in the plugin list. The plugin list is sorted on the format string. - -

FreeImage_GetFIFCount - -

- -

int FreeImage_GetFIFCount(); - -

- -

Returns the number of supported bitmap formats. - -

FreeImage_GetFIFFromFormat - -

- -

FREE_IMAGE_FORMAT FreeImage_GetFIFFromFormat(const char *format); - -

- -

Returns the FreeImage format ID for the given format string. - -

FreeImage_GetFormatFromFIF - -

- -

const char *FreeImage_GetFormatFromFIF(FREE_IMAGE_FORMAT fif); - -

- -

Returns a format string for the given FreeImage Format ID. - -

FreeImage_GetFIFExtensionList - -

- -

const char *FreeImage_GetFIFExtensionList(FREE_IMAGE_FORMAT fif); - -

- -

Returns a list of possible file extension for the given FreeImage Format ID. The extension list is a string containing one or more comma separated file extensions. - -

-FreeImage_GetFIFDescription - -

- -

const char *FreeImage_GetFIFDescription(FREE_IMAGE_FORMAT fif); - -

- -

Returns a descriptive string for the given FreeImage Format ID. - -

FreeImage_GetFIFRegExpr - -

- -

const char *FreeImage_GetFIFRegExpr(FREE_IMAGE_FORMAT fif); - -

- -

Returns a regular expression for the given FreeImage Format ID, assisting external libraries to identify the bitmap format. Currently FreeImageQt uses this function. - -

-FreeImage_GetFIFFromFilename - -

- -

FREE_IMAGE_FORMAT FreeImage_GetFIFFromFilename(const char *filename); - -

- -

Tries to identify a bitmap type by looking at the filename or a file extension. FreeImage_GetFIFFromFilename returns a valid FreeImage Format ID on success and FIF_UNKNOWN on failure. - -

-FreeImage_FIFSupportsReading - -

- -

BOOL FreeImage_FIFSupportsReading(FREE_IMAGE_FORMAT fif); - -

- -

Returns true if the plugin belonging to this FreeImage Format ID supports reading, false otherwise. - -

FreeImage_FIFSupportsWriting - -

- -

BOOL FreeImage_FIFSupportsWriting(FREE_IMAGE_FORMAT fif); - -

- -

Returns true if the plugin belonging to this FreeImage Format ID supports writing, false otherwise. - -

FreeImage_LoadFromHandle - -

- -

FIBITMAP * FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); - -

- -

Loads a bitmap file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadFromHandle returns NULL. - -

- -

The fif parameter specifies the desired bitmap format to be loaded. The parameter accepts any valid FreeImage Format ID, such as FIF_BMP or FIF_JPEG, or an integer value obtained from any of the plugin interface functions. - -

-FreeImage_Load - -

- -

FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif, const char *filename, int flags FI_DEFAULT(0)); - -

- -

Loads the bitmap file into a FreeImage bitmap. If the bitmap is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the bitmap couldn't be loaded, FreeImage_Load returns NULL. - -

FreeImage_SaveToHandle - -

- -

BOOL FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); - -

- -

Saves the FreeImage DIB to a bitmap file of the given type. - -

FreeImage_Save - -

- -

BOOL FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(0)); - -

- -

Saves the FreeImage DIB to a bitmap file of the given type. - -

diff --git a/freeimage241/Docs/102.html b/freeimage241/Docs/102.html deleted file mode 100644 index ba47ea0..0000000 --- a/freeimage241/Docs/102.html +++ /dev/null @@ -1,25 +0,0 @@ - -

Extra functions - -

- -

FreeImage supports a number of additional functions you can use to manipulate FIBITMAPs. - -

-

Subsections

- - - -

FreeImage_Combine - -

- -

void FreeImage_Combine(FIBITMAP *target, FIBITMAP *source, int x, int y, int alpha FI_DEFAULT(255)); - -

- -

Combines the source and target bitmap and stores the result in the target bitmap. Optionally an alpha blend value can be specified to blend the two bitmaps together. - -

diff --git a/freeimage241/Docs/104.html b/freeimage241/Docs/104.html deleted file mode 100644 index bec247a..0000000 --- a/freeimage241/Docs/104.html +++ /dev/null @@ -1,30 +0,0 @@ - -

FreeImageQt functions - -

-

Subsections

- - - - diff --git a/freeimage241/Docs/105.html b/freeimage241/Docs/105.html deleted file mode 100644 index 5b555aa..0000000 --- a/freeimage241/Docs/105.html +++ /dev/null @@ -1,12 +0,0 @@ - -

Introduction - -

- -

FreeImageQt is the binding of the DLL to TrollTech's Qt library. Qt is a sophisticated c++ programming framework for Windows and Unix, used primarily for the creation of graphical user interface. The framework many powerful objects, better known as widgets, which make programming GUIs considerably easier. - -

- -

Qt provides several objects used to deal with graphics. The most interesting objects to FreeImage are Qimage and QimageIO, because these are the objects that FreeImage hooks. By hooking these two objects, FreeImage provides its enormous list of supported bitmap types to Qt, while keeping the generic interface for loading bitmaps in that library intact. As a Qt programmer you won't notice that you are using FreeImage. And that is the strength of it. - -

diff --git a/freeimage241/Docs/106.html b/freeimage241/Docs/106.html deleted file mode 100644 index be50fd6..0000000 --- a/freeimage241/Docs/106.html +++ /dev/null @@ -1,180 +0,0 @@ - -

-Functions - -

- -

FreeImageQt supports the following functions. Note that in average use you only need FIQT_Register to use this library. - -

-

Subsections

- - - -

FIQT_Register - -

- -

bool FIQT_Register(bool new_formats_only = false); - -

- -

Registers the FreeImage load functions in Qt and returns true if successful. If new_formats_only is true, only the bitmap formats not supported by Qt are registered. Else all bitmap formats supported by FreeImage are registered. You have to call this function to take advantage of FreeImage. - -

FIQT_Unregister - -

- -

void FIQT_Unregister(); - -

- -

Removes all binding between FreeImage and Qt. You shouldn't normally have to call this function. It is called automatically on program exit. - -

FIQT_IsLoaded - -

- -

Bool FIQT_IsLoaded(); - -

- -

Returns true if FreeImage was successfully registered into Qt's bitmap functionality handler, false otherwise. - -

FIQT_GetVersion - -

- -

const char *FIQT_GetVersion(); - -

- -

Returns the version string of the library. - -

FIQT_GetCopyrightMessage - -

- -

const char *FIQT_GetVersion(); - -

- -

Returns a short copyright message you can include in your program. - -

FIQT_GetFIFCount - -

- -

int FIQT_GetFIFCount(); - -

- -

Returns the number of supported bitmap formats. - -

FIQT_GetFIFFromFormat - -

- -

FREE_IMAGE_FORMAT FIQT_GetFIFFromFormat(const char *format); - -

- -

Returns the FreeImage format ID for the given format string. - -

FIQT_GetFormatFromFIF - -

- -

const char *FIQT_GetFormatFromFIF(FREE_IMAGE_FORMAT fif); - -

- -

Returns a format string for the given FreeImage Format ID. - -

FIQT_GetFIFExtensionList - -

- -

const char *FIQT_GetFIFExtensionList(FREE_IMAGE_FORMAT fif); - -

- -

Returns a list of possible file extension for the given FreeImage Format ID. The extension list is a string containing one or more comma separated file extensions. - -

FIQT_GetFIFDescription - -

- -

const char *FIQT_GetFIFDescription(FREE_IMAGE_FORMAT fif); - -

- -

Returns a descriptive string for the given FreeImage Format ID. - -

FIQT_GetFIFFromFilename - -

- -

FREE_IMAGE_FORMAT FIQT_GetFIFFromFilename(const char *filename); - -

- -

Tries to identify a bitmap type by looking at the filename or a file extension. FreeImage_GetFIFFromFilename returns a valid FreeImage Format ID on success and FIF_UNKNOWN on failure. - -

FIQT_FIFSupportsReading - -

- -

BOOL FIQT_FIFSupportsReading(FREE_IMAGE_FORMAT fif); - -

- -

Returns true if the plugin belonging to this FreeImage Format ID supports reading, false otherwise. - -

FIQT_FIFSupportsWriting - -

- -

BOOL FIQT_FIFSupportsWriting(FREE_IMAGE_FORMAT fif); - -

- -

Returns true if the plugin belonging to this FreeImage Format ID supports writing, false otherwise. - -

FIQT_GetFileTypeFromFormat - -

- -

const char *FIQT_GetFileTypeFromFormat(FREE_IMAGE_FORMAT fif); - -

- -

This function is deprecated. FIQT_GetFIFFromFormat has replaced its functionality. - -

FIQT_GetFormatFromExtension - -

- -

const char *FIQT_GetFormatFromExtension(const char *extension); - -

- -

Returns a FreeImage Format string for the given file extension. - -

diff --git a/freeimage241/Docs/122.html b/freeimage241/Docs/122.html deleted file mode 100644 index 8a8766e..0000000 --- a/freeimage241/Docs/122.html +++ /dev/null @@ -1,4 +0,0 @@ - -

Index

-[ A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z ]

- \ No newline at end of file diff --git a/freeimage241/Docs/2.html b/freeimage241/Docs/2.html deleted file mode 100644 index c14f4bc..0000000 --- a/freeimage241/Docs/2.html +++ /dev/null @@ -1,148 +0,0 @@ - -

-FreeImage functions - -

-

Subsections

- - - - diff --git a/freeimage241/Docs/25.html b/freeimage241/Docs/25.html deleted file mode 100644 index 13483e3..0000000 --- a/freeimage241/Docs/25.html +++ /dev/null @@ -1,271 +0,0 @@ - -

Simple load functions - -

-

Subsections

- - - -

FreeImage_LoadBMP - -

- -

FIBITMAP *FreeImage_LoadBMP(const char *filename, int flags = BMP_DEFAULT); - -

- -

Loads the given Windows Bitmap file or OS/2 Bitmap file into a FreeImage bitmap. If the bitmap is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the bitmap couldn't be loaded, FreeImage_LoadBMP returns NULL. - -

- -

FIBITMAP *dib = FreeImage_LoadBMP("test.bmp"); - -

FreeImage_LoadICO - -

- -

FIBITMAP *FreeImage_LoadICO(const char *filename, int flags = ICO_DEFAULT); - -

- -

Loads the given Windows ICON file into a FreeImage bitmap. If the icon is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the bitmap couldn't be loaded, FreeImage_LoadICO returns NULL. - -

- -

Flags defaults to ICO_DEFAULT. The following parameters can be passed to change the behaviour of the load routine: - -

- -

FIBITMAP *dib = FreeImage_LoadICO("test.ico");
FIBITMAP *dib = FreeImage_LoadICO("test.ico", ICO_SECOND); - -

- -

- -

- -

-

-
Value Meaning
ICO_FIRST Loads the first icon in the cabinet
ICO_SECOND Loads the second icon in the cabinet
ICO_THIRD Loads the third icon in the cabinet

- -

FreeImage_LoadJPEG - -

- -

FIBITMAP *FreeImage_LoadJPEG(const char *filename, int flags = JPEG_DEFAULT); - -

- -

Loads the given JPEG or JIF file into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadJPEG returns NULL. - -

- -

Flags defaults to JPEG_DEFAULT. The following parameters can be passed to the flags parameter to change the behaviour of the load routine: - -

- -

FIBITMAP *dib = FreeImage_LoadJPEG("test.jpg");
FIBITMAP *dib = FreeImage_LoadJPEG("test.jpg", JPEG_ACCURATE); - -

- -

- -

- -

-

Value Meaning
JPEG_FAST Loads the file as fast as possible, sacrificing some quality.
JPEG_ACCURATE Loads the file as accurate as possible, sacrificing some speed.

- -

FreeImage_LoadKOALA - -

- -

FIBITMAP *FreeImage_LoadKOALA(const char *filename, int flags = KOALA_DEFAULT); - -

- -

Loads the given KOALA file into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadKOALA returns NULL - -

- -

KOALA is a 4-bit bitmap format developed for and supported by ancient commodore 64 computers and emulators. The format is supported for nostalgic reasons of the author. - -

- -

FIBITMAP *dib = FreeImage_LoadKOALA("test.koa"); - -

FreeImage_LoadLBM - -

- -

FIBITMAP *FreeImage_LoadLBM(const char *filename, int flags = LBM_DEFAULT); - -

- -

Loads the given Deluxe Paint LBM file into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadLBM returns NULL - -

-FreeImage_LoadMNG - -

- -

FIBITMAP *FreeImage_LoadMNG(const char *filename, int flags = MNG_DEFAULT); - -

- -

Loads the given Multi Network Graphics (MNG) or JPEG Network Graphics (JNG) file into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadMNG returns NULL - -

FreeImage_LoadPCD - -

- -

FIBITMAP *FreeImage_LoadPCD(const char *filename, int flags = PCD_DEFAULT); - -

- -

Loads the given Kodak PhotoCD file into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadPCD returns NULL. - -

- -

PhotoCD images are so called cabinet files, where several versions of the same bitmap exist in one file. By default FreeImage loads the image marked in the flags as PCD_BASE. By using the flags parameter other image versions can be obtained: - -

- -

FIBITMAP *dib = FreeImage_LoadPCD("test.pcd");
FIBITMAP *dib = FreeImage_LoadPCX("test.pcd", PCD_BASEDIV16); - -

- -

- -

- -

-

-
Value Meaning
PCD_BASE 24-bit, 768 x 512 pixels
PCD_BASEDIV4 24-bit, 192 x 128 pixels
PCD_BASEDIV16 24-bit. 384 x 256 pixels

- -

FreeImage_LoadPCX - -

- -

FIBITMAP *FreeImage_LoadPCX(const char *filename, int flags = PCX_DEFAULT); - -

- -

Loads the given PCX file into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadPCX returns NULL. - -

- -

FIBITMAP *dib = FreeImage_LoadPCX("test.pcx"); - -

FreeImage_LoadPNM - -

- -

FIBITMAP *FreeImage_LoadPNM(const char *filename, PNMFlags flags = PNM_DEFAULT); - -

- -

Loads one of the PNM supported bitmap files into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadPNM returns NULL. - -

- -

PNM is a descriptive name for a collection of ASCII based bitmap types: PBM, PGM and PPM. PBM (Portable Bitmap format) is a 1-bit, black and white bitmap type, PGM (Portable Greymap format) is an 8-bit greyscale bitmap type and PPM (Portable Pixelmap format) is a 24-bit full colour bitmap. FreeImage automatically detects if you are dealing with a PBM, PGM or PPM bitmap and will load it in the default bit depth of that particular image. - -

- -

FIBITMAP *dib = FreeImage_LoadPNM("test.ppm");
FIBITMAP *dib = FreeImage_LoadPNM("test.pgm");
FIBITMAP *dib = FreeImage_LoadPNM("test.pbm"); - -

FreeImage_LoadPNG - -

- -

FIBITMAP *FreeImage_LoadPNG(const char *filename, int flags = PNG_DEFAULT); - -

- -

Loads the given PNG file into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadPNG returns NULL. - -

- -

FIBITMAP *dib = FreeImage_LoadPNG("test.png"); - -

FreeImage_LoadRAS - -

- -

FIBITMAP *FreeImage_LoadRAS(const char *filename, int flags = RAS_DEFAULT); - -

- -

Loads the given Sun rasterfile into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadRAS returns NULL. - -

- -

FIBITMAP *dib = FreeImage_LoadRAS("test.ras"); - -

FreeImage_LoadTARGA - -

- -

FIBITMAP *FreeImage_LoadTARGA(const char *filename, int flags = TARGA_DEFAULT); - -

- -

Loads the given TARGA file into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadTARGA returns NULL. - -

- -

Flags defaults to TARGA_DEFAULT. The flags parameter can be passed the following values to change the behaviour of the load plugin: - -

- -

FIBITMAP *dib = FreeImage_LoadTARGA("test.tga");
FIBITMAP *dib = FreeImage_LoadTARGA("test.tga", TARGA_LOAD_RGB888); - -

- -

- -

- -

-

Value Meaning
TARGA_LOAD_RGB888 If the TARGA file is 16 or 32-bit, it is automatically converted to 24-bit.

- -

FreeImage_LoadTIFF - -

- -

FIBITMAP *FreeImage_LoadTIFF(const char *filename, int flags = TIFF_DEFAULT); - -

- -

Loads the given TIFF file into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadTIFF returns NULL. - -

- -

FIBITMAP *dib = FreeImage_LoadTIFF("test.tiff"); - -

FreeImage_LoadWBMP - -

- -

FIBITMAP *FreeImage_LoadWBMP(const char *filename, int flags = WBMP_DEFAULT); - -

- -

Loads the given WBMP or WAP file into a FreeImage bitmap. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadWBMP returns NULL. - -

diff --git a/freeimage241/Docs/3.html b/freeimage241/Docs/3.html deleted file mode 100644 index 5edae25..0000000 --- a/freeimage241/Docs/3.html +++ /dev/null @@ -1,37 +0,0 @@ - -

Initialisation - -

- -

When the FreeImage is loaded, there has to be allocated data internally to address the various plugins. The initialisation functions are responsible for that task. Note that in the precompiled DLL version the initialisation functions are automatically called. You normally don't need to initialise FreeImage (but it doesn't hurt when you do) - -

-

Subsections

- - - -

-FreeImage_Initialise - -

- -

void FreeImage_Initialise(); - -

- -

Initialises the library. - -

FreeImage_DeInitialise - -

- -

void FreeImage_DeInitialise(); - -

- -

DeInitialises the library. - -

diff --git a/freeimage241/Docs/40.html b/freeimage241/Docs/40.html deleted file mode 100644 index ab824be..0000000 --- a/freeimage241/Docs/40.html +++ /dev/null @@ -1,297 +0,0 @@ - -

-Advanced load functions - -

- -

FreeImage_LoadFromHandle functions are slightly more advanced than the simple load functions, but still quite easy to use. The idea of these functions is that FreeImage doesn't care how it gets its data as long as it gets it. It shouldn't matter if the bitmap is loaded from file, memory or the Internet since data is data not matter where it comes from. - -

- -

To make this idea of data abstraction work a new, abstract file I/O system is used: FreeImageIO . FreeImageIO is a structure containing pointers to 4 functions: a read function, write function, seek function and tell function. All these functions have to be implemented so that data is delivered. The handle representing the data is made abstract as well and is named fi_handle . - -

- -

Loading a bitmap using the ...FromHandle functions involves four things. First the 4 file I/O functions are implemented and a FreeImageIO structure is filled with the pointers. Then the file is opened (that is, if we are in fact dealing with a file). After that one of the ...LoadFromHandle functions can be called. If the bitmap is successfully loaded the file has to be closed. - -

- -

unsigned - -

- -

_ReadProc(FIBITMAP *buffer, unsigned s, unsigned c, fi_handle handle) { - -

- -

return fread(buffer, s, c, (FILE *)handle); - -

- -

} - -

- -

unsigned - -

- -

_WriteProc(FIBITMAP *buffer, unsigned s, unsigned c, fi_handle handle){ - -

- -

return fwrite(buffer, s, c, (FILE *)handle); - -

- -

} - -

- -

int - -

- -

_SeekProc(fi_handle handle, long offset, int origin) { - -

- -

return fseek((FILE *)handle, offset, origin); - -

- -

} - -

- -

long - -

- -

_TellProc(fi_handle handle) { - -

- -

return ftell((FILE *)handle); - -

- -

} - -

- -

FreeImageIO io; - -

- -

io.read_proc = _ReadProc; - -

- -

io.write_proc = _WriteProc; - -

- -

io.seek_proc = _SeekProc; - -

- -

io.tell_proc = _TellProc; - -

- -

FILE *file = fopen("test.bmp", "rb"); - -

- -

if (file != NULL) { - -

- -

FIBITMAP *dib = FreeImage_LoadBMPFromHandle(&io, (fi_handle)file); - -

- -

FreeImage_Free(dib); - -

- -

fclose(file); - -

- -

} - -

-

Subsections

- - - -

FreeImage_LoadBMPFromHandle - -

- -

FIBITMAP *FreeImage_LoadBMPFromHandle(FreeImageIO *io, fi_handle handle, int flags = BMP_DEFAULT); - -

- -

Loads the given BMP file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadBMPFromHandle returns NULL. - -

-FreeImage_LoadICOFromHandle - -

- -

FIBITMAP *FreeImage_LoadICOFromHandle(FreeImageIO *io, fi_handle handle, int flags = ICO_DEFAULT); - -

- -

Loads the given ICO file into a FreeImage bitmap using the given FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadICOFromHandle returns NULL. - -

FreeImage_LoadJPEGFromHandle - -

- -

FIBITMAP *FreeImage_LoadJPEGFromHandle(FreeImageIO *io, fi_handle handle, int flags = JPEG_DEFAULT); - -

- -

Loads the given JPEG file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadJPEGFromHandle returns NULL. - -

-FreeImage_LoadKOALAFromHandle - -

- -

FIBITMAP *FreeImage_LoadKOALAFromHandle(FreeImageIO *io, fi_handle handle, int flags = KOALA_DEFAULT); - -

- -

Loads the given KOALA file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadKOALAFromHandle returns NULL. - -

-FreeImage_LoadLBMFromHandle - -

- -

FIBITMAP *FreeImage_LoadLBMFromHandle(FreeImageIO *io, fi_handle handle, int flags = LBM_DEFAULT); - -

- -

Loads the given Deluxe Paint LBM file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadLBMFromHandle returns NULL. - -

-FreeImage_LoadMNGFromHandle - -

- -

FIBITMAP *FreeImage_LoadMNGFromHandle(FreeImageIO *io, fi_handle handle, int flags = MNG_DEFAULT); - -

- -

Loads the Multi Network Graphics (MNG) or JPEG Network Graphics (JNG) file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadMNGFromHandle returns NULL. - -

-FreeImage_LoadPCDFromHandle - -

- -

FIBITMAP *FreeImage_LoadPCDFromHandle(FreeImageIO *io, fi_handle handle, int flags = PCD_DEFAULT); - -

- -

Loads the given Kodak PhotoCD file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadPCDFromHandle returns NULL. - -

-FreeImage_LoadPCXFromHandle - -

- -

FIBITMAP *FreeImage_LoadPCXFromHandle(FreeImageIO *io, fi_handle handle, int flags = PCX_DEFAULT); - -

- -

Loads the given PCX file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadPCXFromHandle returns NULL. - -

-FreeImage_LoadPNMFromHandle - -

- -

FIBITMAP *FreeImage_LoadPNMFromHandle(FreeImageIO *io, fi_handle handle, int flags = PNM_DEFAULT); - -

- -

Loads the given PBM, PGM or PPM file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadPNMFromHandle returns NULL. - -

-FreeImage_LoadPNGFromHandle - -

- -

FIBITMAP *FreeImage_LoadPNGFromHandle(FreeImageIO *io, fi_handle handle, int flags = PNG_DEFAULT); - -

- -

Loads the given PNG file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadPNGFromHandle returns NULL. - -

-FreeImage_LoadRASFromHandle - -

- -

FIBITMAP *FreeImage_LoadRASFromHandle(FreeImageIO *io, fi_handle handle, int flags = RAS_DEFAULT); - -

- -

Loads the given Sun Rasterfile into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadRASFromHandle returns NULL. - -

-FreeImage_LoadTARGAFromHandle - -

- -

FIBITMAP *FreeImage_LoadTARGAFromHandle(FreeImageIO *io, fi_handle handle, int flags = TARGA_DEFAULT); - -

- -

Loads the given TARGA file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadTARGAFromHandle returns NULL. - -

-FreeImage_LoadTIFFFromHandle - -

- -

FIBITMAP *FreeImage_LoadTIFFFromHandle(FreeImageIO *io, fi_handle handle, int flags = TIFF_DEFAULT); - -

- -

Loads the given TIFF file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadTIFFFromHandle returns NULL. - -

-FreeImage_LoadWBMPFromHandle - -

- -

FIBITMAP *FreeImage_LoadWBMPFromHandle(FreeImageIO *io, fi_handle handle, int flags = WBMP_DEFAULT); - -

- -

Loads the given WBMP file into a FreeImage bitmap using the specified FreeImageIO struct and fi_handle. If the file is loaded successfully, memory for it is allocated and a bitmap pointer is returned. If the file couldn't be loaded, FreeImage_LoadWBMPFromHandle returns NULL. - -

diff --git a/freeimage241/Docs/55.html b/freeimage241/Docs/55.html deleted file mode 100644 index d5acded..0000000 --- a/freeimage241/Docs/55.html +++ /dev/null @@ -1,105 +0,0 @@ - -

-Simple save functions - -

-

Subsections

- - - -

FreeImage_SaveBMP - -

- -

bool FreeImage_SaveBMP(FIBITMAP *dib, const char *filename, int flags = BMP_DEFAULT); - -

- -

Saves the FreeImage DIB to a Windows Bitmap file. The BMP file is always saved in the Windows format. No compression is used. - -

- -

FIBITMAP *dib = FreeImage_LoadBMP("test.bmp");
if (dib != NULL) {
FreeImage_SaveBMP("saved.bmp");
FreeImage_Free(dib);
} - -

FreeImage_SaveJPEG - -

- -

bool FreeImage_SaveJPEG(FIBITMAP *dib, const char *filename, int flags = JPEG_DEFAULT); - -

- -

Saves the FreeImage DIB to a JPEG file. . Only 24-bit bitmaps can be saved as JPEG. Bitmaps in bit depths will have to be converted. - -

- -

FIBITMAP *dib = FreeImage_LoadBMP("test.bmp");
if (dib != NULL) {
FreeImage_SaveJPEG("saved.jpg");
FreeImage_Free(dib);
} - -

FreeImage_SavePNG - -

- -

bool FreeImage_SavePNG(FIBITMAP *dib, const char *filename, int flags = PNG_DEFAULT); - -

- -

Saves the FreeImage DIB to a PNG file. - -

- -

FIBITMAP *dib = FreeImage_LoadBMP("test.bmp");
if (dib != NULL) {
FreeImage_SavePNG("saved.png");
FreeImage_Free(dib);
} - -

FreeImage_SavePNM - -

- -

bool FreeImage_SavePNM(FIBITMAP *dib, const char *filename, PNMFlags flags = PNM_DEFAULT); - -

- -

Saves the FreeImage DIB to a PNM file. PNM is a descriptive name for a collection of ASCII based bitmap types: PBM, PGM and PPM. If the bitmap has a bit depth of 1, the file is saved as a PBM file. If the bitmap has a bit depth of 8, the file is saved as a PGM file. If the bitmap has a bit depth of 24, the file is saved as a PPM file. Other bit depths are not supported. - -

- -

FIBITMAP *dib = FreeImage_LoadBMP("test.bmp"); - -

- -

if (dib != NULL) {
switch(FreeImage_GetBPP(dib)) {
case 1 :
FreeImage_SavePNM("saved.pbm");
break;
case 8 :
FreeImage_SavePNM("saved.pgm");
break;
case 24 :
FreeImage_SavePNM("saved.ppm");
break;
}
FreeImage_Free(dib);
} - -

FreeImage_SaveTIFF - -

- -

bool FreeImage_SaveTIFF(FIBITMAP *dib, const char *filename, int flags = TIFF_DEFAULT); - -

- -

Saves the FreeImage DIB to a TIFF file. - -

- -

FIBITMAP *dib = FreeImage_LoadBMP("test.bmp");
if (dib != NULL) {
FreeImage_SaveTIFF("saved.tiff");
FreeImage_Free(dib);
} - -

FreeImage_SaveWBMP - -

- -

bool FreeImage_SaveWBMP(FIBITMAP *dib, const char *filename, int flags = WBMP_DEFAULT); - -

- -

Saves the FreeImage DIB to a WBMP file. - -

- -

FIBITMAP *dib = FreeImage_LoadBMP("test.bmp");
if (dib != NULL) {
FreeImage_SaveWBMP("saved.wbmp");
FreeImage_Free(dib);
} - -

diff --git a/freeimage241/Docs/6.html b/freeimage241/Docs/6.html deleted file mode 100644 index b67be96..0000000 --- a/freeimage241/Docs/6.html +++ /dev/null @@ -1,43 +0,0 @@ - -

Bitmap Allocation functions - -

-

Subsections

- - - -

FreeImage_Allocate - -

- -

FIBITMAP *FreeImage_Allocate(int width, int height, int bpp, int red_mask = 0, int green_mask = 0, int blue_mask = 0); - -

- -

Allocates a new FreeImage bitmap using the given width, height and bits per pixel and optional red, green and blue mask. The mask is stored in BGR order. - -

FreeImage_Free - -

- -

void FreeImage_Free(FIBITMAP *dib); - -

- -

Disposes the given bitmap from memory. - -

FreeImage_Unload - -

- -

void FreeImage_Unload(FIBITMAP *dib); - -

- -

Alias for FreeImage_Free. - -

diff --git a/freeimage241/Docs/62.html b/freeimage241/Docs/62.html deleted file mode 100644 index 144530d..0000000 --- a/freeimage241/Docs/62.html +++ /dev/null @@ -1,196 +0,0 @@ - -

Advanced save functions - -

- -

Saving bitmaps using the ...SaveToHandle functions is almost identical to loading bitmap via the ...LoadFromHandle functions. Information about the FreeImageIO and fi_handle can therefore be obtained from the information belonging to these functions. - -

- -

unsigned - -

- -

_ReadProc(FIBITMAP *buffer, unsigned s, unsigned c, fi_handle handle) { - -

- -

return fread(buffer, s, c, (FILE *)handle); - -

- -

} - -

- -

unsigned - -

- -

_WriteProc(FIBITMAP *buffer, unsigned s, unsigned c, fi_handle handle){ - -

- -

return fwrite(buffer, s, c, (FILE *)handle); - -

- -

} - -

- -

int - -

- -

_SeekProc(fi_handle handle, long offset, int origin) { - -

- -

return fseek((FILE *)handle, offset, origin); - -

- -

} - -

- -

long - -

- -

_TellProc(fi_handle handle) { - -

- -

return ftell((FILE *)handle); - -

- -

} - -

- -

FreeImageIO io; - -

- -

io.read_proc = _ReadProc; - -

- -

io.write_proc = _WriteProc; - -

- -

io.seek_proc = _SeekProc; - -

- -

io.tell_proc = _TellProc; - -

- -


FILE *file = fopen("test.bmp", "rb"); - -

- -

FIBITMAP *dib = FreeImage_LoadBMPFromHandle(&io, (fi_handle)file); - -

- -

-
fclose(file);
- -

- -

if (dib != NULL) { - -

- -

file = fopen("saved.bmp", "wb"); -
- -

- -

FreeImage_SavePNGToHandle(dib, &io, (fi_handle)file); -
fclose(file);
}
- -

- -

FreeImage_Free(dib); - -

-

Subsections

- - - -

FreeImage_SaveBMPToHandle - -

- -

bool FreeImage_SaveBMPToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags = BMP_DEFAULT); - -

- -

Saves the FreeImage DIB to a Windows Bitmap file. The BMP file is always saved in the Windows format. No compression is used. - -

FreeImage_SaveJPEGToHandle - -

- -

bool FreeImage_SaveJPEGToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags = JPEG_DEFAULT); - -

- -

Saves the FreeImage DIB to a JPEG file. Only 24-bit bitmaps can be saved as JPEG. Bitmaps in bit depths will have to be converted. - -

FreeImage_SavePNGToHandle - -

- -

bool FreeImage_SavePNGToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags = PNG_DEFAULT); - -

- -

Saves the FreeImage DIB to a PNG file. - -

FreeImage_SavePNMToHandle - -

- -

bool FreeImage_SavePNMToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags = PNM_DEFAULT); - -

- -

Saves the FreeImage DIB to a PNM file. PNM is a descriptive name for a collection of ASCII based bitmap types: PBM, PGM and PPM. If the bitmap has a bitdepth of 1, the file is saved as a PBM file. If the bitmap has a bitdepth of 8, the file is saved as a PGM file. If the bitmap has a bitdepth of 24, the file is saved as a PPM file. Other bitdepths are not supported. - -

-FreeImage_SaveTIFFToHandle - -

- -

bool FreeImage_SaveTIFFToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags = TIFF_DEFAULT); - -

- -

Saves the FreeImage DIB to a TIFF file. - -

FreeImage_SaveWBMPToHandle - -

- -

bool FreeImage_SaveWBMPToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags = WBMP_DEFAULT); - -

- -

Saves the FreeImage DIB to a WBMP file. - -

diff --git a/freeimage241/Docs/69.html b/freeimage241/Docs/69.html deleted file mode 100644 index 1a25e21..0000000 --- a/freeimage241/Docs/69.html +++ /dev/null @@ -1,149 +0,0 @@ - -

Filetype functions - -

-

Subsections

- - - -

FreeImage_GetFileType - -

- -

FREE_IMAGE_FORMAT FreeImage_GetFileType(const char *filename, int size); - -

- -

Investigates the bitmap data from the given bitmap and returns the FreeImage Format ID for it. FreeImage_GetFileType will read the first size bytes of the file but not more than 16. FreeImage_GetFileType will return one of the following values: - -

- -

- -

- -

-

- - -
Type Bitmap
FIF_UNKNOWN Unidentified bitmap type
FIF_BMP Windows or OS/2 Bitmap
FIF_ICO Windows Icon
FIF_JPEG JPEG - JFIF Compliant
FIF_JNG JPEG Network Graphics
FIF_KOALA C64 Koala Graphics
FIF_LBM -Deluxe Paint LBM
FIF_MNG Multiple Network Graphics
FIF_PBM Portable Bitmap
FIF_PCD Kodak PhotoCD
FIF_PCX Zsoft Paintbrush
FIF_PGM Portable Greymap
FIF_PNG Portable Network Graphics -
FIF_PPM Portable Pixmap
FIF_RAS Sun Raster Image
FIF_TARGA Truevision Targa
FIF_TIFF Tagged Image File Format
FIF_WBMP Wireless Bitmap

- -

FreeImage_GetFileTypeFromHandle - -

- -

FREE_IMAGE_FORMAT FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size); - -

- -

Investigates the bitmap data from the given bitmap and returns the FreeImage Format ID for it. Code example: - -

- -

unsigned - -

- -

_ReadProc(FIBITMAP *buffer, unsigned s, unsigned c, fi_handle handle) { - -

- -

return fread(buffer, s, c, (FILE *)handle); - -

- -

} - -

- -

unsigned - -

- -

_WriteProc(FIBITMAP *buffer, unsigned s, unsigned c, fi_handle handle){ - -

- -

return fwrite(buffer, s, c, (FILE *)handle); - -

- -

} - -

- -

int - -

- -

_SeekProc(fi_handle handle, long offset, int origin) { - -

- -

return fseek((FILE *)handle, offset, origin); - -

- -

} - -

- -

long - -

- -

_TellProc(fi_handle handle) { - -

- -

return ftell((FILE *)handle); - -

- -

} - -

- -

FreeImageIO io; - -

- -

io.read_proc = _ReadProc; - -

- -

io.write_proc = _WriteProc; - -

- -

io.seek_proc = _SeekProc; - -

- -

io.tell_proc = _TellProc; - -

- -


FILE *file = fopen("test.bmp", "rb"); - -

- -

FREE_IMAGE_TYPE type;
type = FreeImage_GetFileTypeFromHandle(&io, (fi_handle)file, 16); - -

FreeImage_GetFileTypeFromExt - -

- -

FREE_IMAGE_FORMAT FreeImage_GetFileTypeFromExt(const char *ext); - -

- -

This function is deprecated. FreeImage_GetFIFFromFilename has replaced its functionality. - -

diff --git a/freeimage241/Docs/73.html b/freeimage241/Docs/73.html deleted file mode 100644 index 064c3e0..0000000 --- a/freeimage241/Docs/73.html +++ /dev/null @@ -1,77 +0,0 @@ - -

FreeImage bitmap information functions - -

-

Subsections

- - - -

FreeImage_GetRedMask - -

- -

unsigned FreeImage_GetRedMask(FIBITMAP *dib); - -

- -

Returns the red bitmask for the bitmap. If the bitmap is palletised 0 is returned. - -

FreeImage_GetGreenMask - -

- -

unsigned FreeImage_GetGreenMask(FIBITMAP *dib); - -

- -

Returns the green bitmask for the bitmap. If the bitmap is palletised 0 is returned. - -

FreeImage_GetBlueMask - -

- -

unsigned FreeImage_GetBlueMask(FIBITMAP *dib); - -

- -

Returns the blue bitmask for the bitmap. If the bitmap is palletised 0 is returned. - -

FreeImage_GetTransparencyCount - -

- -

BYTE FreeImage_GetTransparencyCount(FIBITMAP *dib); - -

- -

Returns the number of transparent colours stored into the transparency colour table of the given bitmap. Every palletised bitmap includes a transparency table containing up to 256 alpha values. - -

-FreeImage_GetTransparencyTable - -

- -

BYTE *FreeImage_GetTransparencyTable(FIBITMAP *dib); - -

- -

Returns the transparency table assigned to this bitmap. If the bitmap doesn't contain a transparency table NULL is returned. - -

FreeImage_SetTransparencyTable - -

- -

void FreeImage_SetTransparencyTable(FIBITMAP *dib, BYTE *table, BYTE count); - -

- -

Assigns a new transparency table to the bitmap. A transparency table consists of up to 256 bytes in an array, where a value of 0xFF in that table stands for completely opaque and 0x00 stands for completely invisible. The transparency table is used in TrollTech Qt to draw transparent bitmaps on a widget. - -

diff --git a/freeimage241/Docs/80.html b/freeimage241/Docs/80.html deleted file mode 100644 index 64935ce..0000000 --- a/freeimage241/Docs/80.html +++ /dev/null @@ -1,175 +0,0 @@ - -

-DIB information functions - -

-

Subsections

- - - -

FreeImage_GetColorsUsed - -

- -

unsigned FreeImage_GetColorsUsed(FIBITMAP *dib); - -

- -

Retrieves the number of colours used in the bitmap. If the bitmap is non-palletised, 0 is returned. - -

FreeImage_GetBits - -

- -

BYTE * FreeImage_GetBits(FIBITMAP *dib); - -

- -

Returns a pointer to the bitmap bits. - -

FreeImage_GetBitsRowCol - -

- -

BYTE * FreeImage_GetBitsRowCol(FIBITMAP *dib, int col, int row); - -

- -

Returns a pointer to the bitmap bits on the given column and row. - -

FreeImage_GetScanLine - -

- -

BYTE * FreeImage_GetScanLine(FIBITMAP *dib, int scanline); - -

- -

Returns a pointer to the beginning of the bits of the given scanline. - -

FreeImage_GetBPP - -

- -

unsigned FreeImage_GetBPP(FIBITMAP *dib); - -

- -

Returns the bitdepth of the bitmap. - -

FreeImage_GetWidth - -

- -

unsigned FreeImage_GetWidth(FIBITMAP *dib); - -

- -

Returns the width of the bitmap in pixels. - -

FreeImage_GetHeight - -

- -

unsigned FreeImage_GetHeight(FIBITMAP *dib); - -

- -

Returns the height of the bitmap in pixels. - -

FreeImage_GetLine - -

- -

unsigned FreeImage_GetLine(FIBITMAP *dib); - -

- -

Returns the width of the bitmap in bytes. - -

FreeImage_GetPitch - -

- -

unsigned FreeImage_GetPitch(FIBITMAP *dib); - -

- -

Returns the width of the bitmap in bytes rounded to the nearest DWORD. - -

FreeImage_GetDIBSize - -

- -

unsigned FreeImage_GetDIBSize(FIBITMAP *dib); - -

- -

Returns the size of the bitmap in bytes. The size of the bitmap is the BITMAPINFOHEADER + the size of the palette + the size of the bitmap data. - -

FreeImage_GetPalette - -

- -

RGBQUAD *FreeImage_GetPalette(FIBITMAP *dib); - -

- -

Returns a pointer to the bitmap's palette. If the bitmap doesn't have a palette, FreeImage_GetPalette returns NULL. - -

FreeImage_GetInfoHeader - -

- -

BITMAPINFOHEADER *FreeImage_GetInfoHeader(FIBITMAP *dib); - -

- -

Returns a pointer to the bitmap's BITMAPINFOHEADER. - -

FreeImage_GetInfo - -

- -

BITMAPINFO *FreeImage_GetInfo(FIBITMAP *dib); - -

- -

Returns a pointer to the bitmap's BITMAPINFO header. - -

FreeImage_GetColorType - -

- -

FREE_IMAGE_COLOR_TYPE FreeImage_GetColorType(FIBITMAP *dib); - -

- -

Investigates the colour type of the bitmap and returns one of the following values: - -

- -

- -

- -

-

-
Value Description
FIC_MINISWHITE 1-bit bitmap. The min value is white
FIC_MINISBLACK 1-bit bitmap. The min value is black 8-bit grayscale. The min value is black
FIC_RGB 24/32-bit RGB
FIC_PALETTE 1/4/8-bit palletised

- -

diff --git a/freeimage241/Docs/95.html b/freeimage241/Docs/95.html deleted file mode 100644 index ca560fa..0000000 --- a/freeimage241/Docs/95.html +++ /dev/null @@ -1,93 +0,0 @@ - -

Conversion functions - -

- -

Bitmaps in FreeImage are always loaded in their default bit depth. If you want the bitmap to be stored in another bit depth, the library provides several conversion functions. - -

-

Subsections

- - - -

FreeImage_ConvertTo8Bits - -

- -

FIBITMAP *FreeImage_ConvertTo8Bits(FIBITMAP *dib); - -

- -

Converts the given bitmap to 8 bits. If the bitmap is 24 or 32-bit RGB, the colour values are converted to greyscale. - -

FreeImage_ConvertTo16Bits 555 - -

- -

FIBITMAP *FreeImage_ConvertTo16Bits555(FIBITMAP *dib); - -

- -

Converts the given bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 5 bits green, 5 bits red and 1 unused bit. - -

FreeImage_ConvertTo16Bits565 - -

- -

FIBITMAP *FreeImage_ConvertTo16Bits565(FIBITMAP *dib); - -

- -

Converts the given bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 6 bits green and 5 bits red. - -

FreeImage_ConvertTo24Bits - -

- -

FIBITMAP *FreeImage_ConvertTo24Bits(FIBITMAP *dib); - -

- -

Converts the given bitmap to 24 bits. - -

FreeImage_ConvertTo32Bits - -

- -

FIBITMAP *FreeImage_ConvertTo32Bits(FIBITMAP *dib); - -

- -

Converts the given bitmap to 32 bits. - -

FreeImage_ColorQuantize - -

- -

FIBITMAP *FreeImage_ColorQuantize(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize); - -

- -

Quantizes a full colour 24-bit bitmap to a palletised 8-bit bitmap. The quantize parameter specifies which colour reduction algorithm should be used. - -

- -

- -

- -

-

- -

- -

Parameter Description
FIQ_WUQUANT Wu's color quantization algorithm
FIQ_NNQUANT NeuQuant quantization algorithm

- -

diff --git a/freeimage241/Docs/contents.xml b/freeimage241/Docs/contents.xml deleted file mode 100644 index 3f85eb6..0000000 --- a/freeimage241/Docs/contents.xml +++ /dev/null @@ -1,249 +0,0 @@ - - - - FreeImage functions - Initialisation - FreeImage_Initialise - - FreeImage_DeInitialise - - - Bitmap Allocation functions - FreeImage_Allocate - - FreeImage_Free - - FreeImage_Unload - - - Plugin functions - FreeImage_GetFIFByIndex - - FreeImage_GetFIFCount - - FreeImage_GetFIFFromFormat - - FreeImage_GetFormatFromFIF - - FreeImage_GetFIFExtensionList - - FreeImage_GetFIFDescription - - FreeImage_GetFIFRegExpr - - FreeImage_GetFIFFromFilename - - FreeImage_FIFSupportsReading - - FreeImage_FIFSupportsWriting - - FreeImage_LoadFromHandle - - FreeImage_Load - - FreeImage_SaveToHandle - - FreeImage_Save - - - Simple load functions - FreeImage_LoadBMP - - FreeImage_LoadICO - - FreeImage_LoadJPEG - - FreeImage_LoadKOALA - - FreeImage_LoadLBM - - FreeImage_LoadMNG - - FreeImage_LoadPCD - - FreeImage_LoadPCX - - FreeImage_LoadPNM - - FreeImage_LoadPNG - - FreeImage_LoadRAS - - FreeImage_LoadTARGA - - FreeImage_LoadTIFF - - FreeImage_LoadWBMP - - - Advanced load functions - FreeImage_LoadBMPFromHandle - - FreeImage_LoadICOFromHandle - - FreeImage_LoadJPEGFromHandle - - FreeImage_LoadKOALAFromHandle - - FreeImage_LoadLBMFromHandle - - FreeImage_LoadMNGFromHandle - - FreeImage_LoadPCDFromHandle - - FreeImage_LoadPCXFromHandle - - FreeImage_LoadPNMFromHandle - - FreeImage_LoadPNGFromHandle - - FreeImage_LoadRASFromHandle - - FreeImage_LoadTARGAFromHandle - - FreeImage_LoadTIFFFromHandle - - FreeImage_LoadWBMPFromHandle - - - Simple save functions - FreeImage_SaveBMP - - FreeImage_SaveJPEG - - FreeImage_SavePNG - - FreeImage_SavePNM - - FreeImage_SaveTIFF - - FreeImage_SaveWBMP - - - Advanced save functions - FreeImage_SaveBMPToHandle - - FreeImage_SaveJPEGToHandle - - FreeImage_SavePNGToHandle - - FreeImage_SavePNMToHandle - - FreeImage_SaveTIFFToHandle - - FreeImage_SaveWBMPToHandle - - - Filetype functions - FreeImage_GetFileType - - FreeImage_GetFileTypeFromHandle - - FreeImage_GetFileTypeFromExt - - - FreeImage bitmap information functions - FreeImage_GetRedMask - - FreeImage_GetGreenMask - - FreeImage_GetBlueMask - - FreeImage_GetTransparencyCount - - FreeImage_GetTransparencyTable - - FreeImage_SetTransparencyTable - - - DIB information functions - FreeImage_GetColorsUsed - - FreeImage_GetBits - - FreeImage_GetBitsRowCol - - FreeImage_GetScanLine - - FreeImage_GetBPP - - FreeImage_GetWidth - - FreeImage_GetHeight - - FreeImage_GetLine - - FreeImage_GetPitch - - FreeImage_GetDIBSize - - FreeImage_GetPalette - - FreeImage_GetInfoHeader - - FreeImage_GetInfo - - FreeImage_GetColorType - - - Conversion functions - FreeImage_ConvertTo8Bits - - FreeImage_ConvertTo16Bits 555 - - FreeImage_ConvertTo16Bits565 - - FreeImage_ConvertTo24Bits - - FreeImage_ConvertTo32Bits - - FreeImage_ColorQuantize - - - Extra functions - FreeImage_Combine - - - - FreeImageQt functions - Introduction - - Functions - FIQT_Register - - FIQT_Unregister - - FIQT_IsLoaded - - FIQT_GetVersion - - FIQT_GetCopyrightMessage - - FIQT_GetFIFCount - - FIQT_GetFIFFromFormat - - FIQT_GetFormatFromFIF - - FIQT_GetFIFExtensionList - - FIQT_GetFIFDescription - - FIQT_GetFIFFromFilename - - FIQT_FIFSupportsReading - - FIQT_FIFSupportsWriting - - FIQT_GetFileTypeFromFormat - - FIQT_GetFormatFromExtension - - - - Index - - - - - diff --git a/freeimage241/Docs/index.html b/freeimage241/Docs/index.html deleted file mode 100644 index 3587278..0000000 --- a/freeimage241/Docs/index.html +++ /dev/null @@ -1,190 +0,0 @@ - - - -FreeImage 2.3.0 - - - -

Thank you for downloading FreeImage, an Open Source image library for multimedia and game programmers. The goal of FreeImage is to create a sophisticated, easy to use library to serve all your bitmap manipulation needs. The library is already in use by many companies and individuals, and the user base is still rapidly growing. - -

- -

If you have any questions about this manual, or about FreeImage, please don't hesitate to send an e-mail to freeimage@6ixsoft.com . You can also browse the FreeImage forum or sign up on the FreeImage mailing list via the FreeImage website: http://www.6ixsoft.com - -

- -

Floris - -

-

Subsections

- - - - diff --git a/freeimage241/Examples/Generic/BatchLoad.cpp b/freeimage241/Examples/Generic/BatchLoad.cpp deleted file mode 100644 index 6c0dcd7..0000000 --- a/freeimage241/Examples/Generic/BatchLoad.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// ========================================================== -// Batch loader -// -// Design and implementation by Floris van den Berg -// -// This file is part of FreeImage -// -// Use at own risk! -// ========================================================== -// -// This example shows how to easily batch load a directory -// full of images. Because not all formats can be identified -// by their header (some images don't have a header or one -// at the end of the file) we make use of the -// FreeImage_GetFileTypeFromExt function. This function -// receives a file extension, for example BMP, and returns -// a FREE_IMAGE_TYPE enum which identifies that bitmap. -// -// ========================================================== - -#include -#include -#include -#include -#include - -#include "FreeImage.h" - -// ---------------------------------------------------------- - -int __cdecl -main(int argc, char *argv[]) { - FIBITMAP *dib = NULL; - int id = 1; - - printf(FreeImage_GetVersion()); - printf(FreeImage_GetCopyrightMessage()); - - // open the log file - - FILE *log_file = fopen("log_file.txt", "w"); - - // batch convert all supported bitmaps - - _finddata_t finddata; - - long handle; - - if ((handle = _findfirst("d:\\images\\*.*", &finddata)) != -1) { - do { - // grab the extension - - char *ext = new char[4]; - ext[3] = 0; - strncpy(ext, finddata.name + strlen(finddata.name) - 3, 3); - - // make a path to a directory - - char *directory = new char[128]; - strcpy(directory, "d:\\images\\"); - strcat(directory, finddata.name); - - // make a unique filename - - char *unique = new char[128]; - itoa(id, unique, 10); - strcat(unique, ".bmp"); - - // open the file - - switch(FreeImage_GetFileTypeFromExt(ext)) { - case FIF_BMP : - dib = FreeImage_LoadBMP(directory); - break; - - case FIF_ICO : - dib = FreeImage_LoadICO(directory); - break; - - case FIF_JPEG : - dib = FreeImage_LoadJPEG(directory); - break; - - case FIF_KOALA : - dib = FreeImage_LoadKOALA(directory); - break; - - case FIF_PCD : - dib = FreeImage_LoadPCD(directory); - break; - - case FIF_PCX : - dib = FreeImage_LoadPCX(directory); - break; - - case FIF_PNG : - dib = FreeImage_LoadPNG(directory); - break; - - case FIF_PBM : - dib = FreeImage_LoadPNM(directory); - break; - - case FIF_PGM : - dib = FreeImage_LoadPNM(directory); - break; - - case FIF_PPM : - dib = FreeImage_LoadPNM(directory); - break; - - case FIF_RAS : - dib = FreeImage_LoadRAS(directory); - break; - - case FIF_TARGA : - dib = FreeImage_LoadTARGA(directory); - break; - - case FIF_TIFF : - dib = FreeImage_LoadTIFF(directory); - break; - }; - - if (dib != NULL) { - FreeImage_SaveBMP(dib, unique); - - FreeImage_Free(dib); - - fwrite(unique, strlen(unique), 1, log_file); - fwrite(" >> ", 4, 1, log_file); - fwrite(directory, strlen(directory), 1, log_file); - fwrite("\n", 1, 1, log_file); - - id++; - } - - delete [] unique; - delete [] directory; - delete [] ext; - - } while (_findnext(handle, &finddata) == 0); - - _findclose(handle); - } - - fclose(log_file); - - return 0; -} \ No newline at end of file diff --git a/freeimage241/Examples/Generic/LoadFromHandle.cpp b/freeimage241/Examples/Generic/LoadFromHandle.cpp deleted file mode 100644 index 498b1f5..0000000 --- a/freeimage241/Examples/Generic/LoadFromHandle.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// ========================================================== -// Load From Handle Example -// -// Design and implementation by Floris van den Berg -// -// This file is part of FreeImage -// -// Use at own risk! -// ========================================================== -// -// This example shows how to load a bitmap from a -// user allocated FILE pointer. -// -// ========================================================== - -#include -#include -#include - -#include "FreeImage.h" - -// ---------------------------------------------------------- - -unsigned -_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { - return fread(buffer, size, count, (FILE *)handle); -} - -unsigned -_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { - return fwrite(buffer, size, count, (FILE *)handle); -} - -int -_SeekProc(fi_handle handle, long offset, int origin) { - return fseek((FILE *)handle, offset, origin); -} - -long -_TellProc(fi_handle handle) { - return ftell((FILE *)handle); -} - -// ---------------------------------------------------------- - -int __cdecl -main(int argc, char *argv[]) { - FreeImageIO io; - - io.read_proc = _ReadProc; - io.write_proc = _WriteProc; - io.seek_proc = _SeekProc; - io.tell_proc = _TellProc; - - FILE *file = fopen("d:\\images\\money-256.bmp", "rb"); - - if (file != NULL) { - FIBITMAP *dib = FreeImage_LoadBMPFromHandle(&io, (fi_handle)file); - - FreeImage_Free(dib); - - fclose(file); - } - - return 0; -} \ No newline at end of file diff --git a/freeimage241/Examples/Plugin/PluginCradle.cpp b/freeimage241/Examples/Plugin/PluginCradle.cpp deleted file mode 100644 index f082efd..0000000 --- a/freeimage241/Examples/Plugin/PluginCradle.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// ========================================================== -// Loader/Saver Plugin Cradle -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include -#include - -#include "FreeImage.h" -#include "Utilities.h" - -// ========================================================== - -BOOL APIENTRY -DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { - switch (ul_reason_for_call) { - case DLL_PROCESS_ATTACH : - case DLL_PROCESS_DETACH : - case DLL_THREAD_ATTACH : - case DLL_THREAD_DETACH : - break; - } - - return TRUE; -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "CRADLE"; -} - -static const char * DLL_CALLCONV -Description() { - return "Here comes the description for your image loader/saver"; -} - -// the extension list is always a chain of extensions -// seperated by commas. no spaces or whatsoever are allowed. - -static const char * DLL_CALLCONV -Extension() { - return "ext1,ext2"; -} - -// RegExpr is only needed for the Qt wrapper -// It allows the Qt mechanism for loading bitmaps to identify the bitmap - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -// FreeImage's internal way of seeing if a bitmap is of the desired type. -// When the type of a bitmap is to be retrieved, FreeImage runs Validate -// for each registered plugin until one returns true. If a plugin doesn't -// have a validate function, a return value of false is assumed. -// -// You can always force to use a particular plugin by directly specifying -// it on the command line, but this can result in a dead DLL if the plugin -// was not made for the bitmap. - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - return FALSE; -} - -// ---------------------------------------------------------- - -// NEVER EVER use direct function calls to FreeImage when writing -// a plugin. Always use the function pointers provides in the FreeImage -// structure. Using this indirect approach ensures that plugins run -// from the FreeImage DLL, an external DLL or within the application -// code with a simple recompile. Also NEVER EVER allocate memory in -// a plugin and return it. Memory allocated in one DLL can't be freed -// in another DLL unless they share the same c runtime library (which -// usually is not the case). Always use freeimage.allocate_proc to -// allocate memory for a bitmap. - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - return NULL; -} - -static BOOL DLL_CALLCONV -Save(FreeImage &freeimage, FreeImageIO &io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - return FALSE; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -Init(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; - plugin.save_proc = Save; - plugin.validate_proc = Validate; -} diff --git a/freeimage241/FreeImage.dsp b/freeimage241/FreeImage.dsp deleted file mode 100644 index 1f752c9..0000000 --- a/freeimage241/FreeImage.dsp +++ /dev/null @@ -1,274 +0,0 @@ -# Microsoft Developer Studio Project File - Name="FreeImage" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=FreeImage - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "FreeImage.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "FreeImage.mak" CFG="FreeImage - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "FreeImage - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "FreeImage - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "FreeImage - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# 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 /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREEIMAGE_EXPORTS" /YX /FD /c -# ADD CPP /nologo /G6 /Gd /MT /W3 /GX /O1 /I "Source" /I "Source\ZLib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREEIMAGE_EXPORTS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# 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 /nologo /dll /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 /nologo /dll /machine:I386 -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Cmds=copy Release\FreeImage.dll Dist copy Release\FreeImage.lib Dist copy Source\FreeImage.h Dist -# End Special Build Tool - -!ELSEIF "$(CFG)" == "FreeImage - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREEIMAGE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "Source" /I "Source\ZLib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FREEIMAGE_EXPORTS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# 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 /nologo /dll /debug /machine:I386 /pdbtype:sept -# 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 /nologo /dll /debug /machine:I386 /out:"Debug/FreeImaged.dll" /pdbtype:sept -# SUBTRACT LINK32 /incremental:no -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Cmds=copy Debug\FreeImaged.dll Dist copy Debug\FreeImaged.lib Dist copy Source\FreeImage.h Dist -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "FreeImage - Win32 Release" -# Name "FreeImage - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Group "Plugins" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\Source\FreeImage\Plugin.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginBMP.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginICO.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginIFF.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginJPEG.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginKOALA.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginMNG.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginPCD.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginPCX.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginPNG.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginPNM.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginPSD.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginRAS.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginTARGA.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginTIFF.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\PluginWBMP.cpp -# End Source File -# End Group -# Begin Group "Conversion" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\Source\FreeImage\Conversion.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\Conversion16_555.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\Conversion16_565.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\Conversion24.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\Conversion32.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\Conversion8.cpp -# End Source File -# End Group -# Begin Group "Quantizers" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\Source\FreeImage\NNQuantizer.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\WuQuantizer.cpp -# End Source File -# End Group -# Begin Source File - -SOURCE=.\Source\FreeImage\BitmapAccess.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\FreeImage.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\FreeImageIO.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\GetType.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImage\LoadFunctions.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\Source\FreeImage.h -# End Source File -# Begin Source File - -SOURCE=.\Source\FreeImageIO.h -# End Source File -# Begin Source File - -SOURCE=.\Source\Plugin.h -# End Source File -# Begin Source File - -SOURCE=.\Source\Quantizers.h -# End Source File -# Begin Source File - -SOURCE=.\Source\Utilities.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# Begin Source File - -SOURCE=.\KnownBugs.txt -# End Source File -# Begin Source File - -SOURCE=.\Todo.txt -# End Source File -# Begin Source File - -SOURCE=.\Whatsnew.txt -# End Source File -# End Target -# End Project diff --git a/freeimage241/FreeImage.dsw b/freeimage241/FreeImage.dsw deleted file mode 100644 index 0ddecc0..0000000 --- a/freeimage241/FreeImage.dsw +++ /dev/null @@ -1,158 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "FreeImage"=.\FreeImage.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name LibJPEG - End Project Dependency - Begin Project Dependency - Project_Dep_Name LibPNG - End Project Dependency - Begin Project Dependency - Project_Dep_Name LibTIFF - End Project Dependency - Begin Project Dependency - Project_Dep_Name ZLib - End Project Dependency - Begin Project Dependency - Project_Dep_Name LibMNG - End Project Dependency -}}} - -############################################################################### - -Project: "FreeImageLib"=.\SOURCE\FreeImageLib\FreeImageLib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name LibJPEG - End Project Dependency - Begin Project Dependency - Project_Dep_Name LibMNG - End Project Dependency - Begin Project Dependency - Project_Dep_Name LibPNG - End Project Dependency - Begin Project Dependency - Project_Dep_Name LibTIFF - End Project Dependency -}}} - -############################################################################### - -Project: "FreeImageQt"=.\Source\FreeImageQt\FreeImageQt.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "LibJPEG"=.\Source\LibJPEG\LibJPEG.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "LibMNG"=.\Source\LibMNG\LibMNG.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name ZLib - End Project Dependency -}}} - -############################################################################### - -Project: "LibPNG"=.\Source\LibPNG\LibPNG.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "LibTIFF"=.\Source\LibTIFF\LibTIFF.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "Test"=.\Source\Test\Test.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name FreeImage - End Project Dependency -}}} - -############################################################################### - -Project: "ZLib"=.\Source\ZLib\ZLib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/freeimage241/KnownBugs.txt b/freeimage241/KnownBugs.txt deleted file mode 100644 index fb8e85e..0000000 --- a/freeimage241/KnownBugs.txt +++ /dev/null @@ -1,27 +0,0 @@ -Known bugs for FreeImage - -- PHOTOSHOP AND ALPHA-CHANNELED TIFF ------------------------------------ - -LibTIFF doesn't load the alpha channel when that file is created -with Adobe Photoshop. This is a bug in Photoshop as it writes -the TIFF in a non-standard, non-documented way. According to -the LibTIFF mailing list: - -"Photoshop's PSD file format allows for a number of layers, alpha -channels, etc. In such a sceme, there is no such thing as a single alpha -channel, but only a number of channels, some of which represent colors -in layers, or in a global picture, others alpha's that can have just -about any local layers or global image meaning and must even considered -to be editable and enablable/disablable by users all the time. I guess -this makes adobe reluctant to define such a thing as a single alpha -channel, including when they write out other formats that allow for -something else/more than a single alpha." - -On the same libTIFF mailing a semi-solution is provided: - -"If I create a 32-bit (24-bit + 8 bit alpha) TGA image in another -program, and load it into Photoshop, Photoshop shows it as RGBA. -If I then save it to TIFF, Photoshop properly flags it as an Alpha -channel, and TIFFReadRGBAImage reads it fine. I'm not sure what -Photoshop does differently when you create an Alpha channel by hand -versus loading it with the image." diff --git a/freeimage241/Makefile b/freeimage241/Makefile deleted file mode 100644 index f9e2275..0000000 --- a/freeimage241/Makefile +++ /dev/null @@ -1,38 +0,0 @@ - -# configure your options in Makefile.cfg - -include Makefile.cfg - - - -all: default - -default: dist examples - -dist: FreeImage - cp Source/FreeImage/*.a Dist - cp Source/FreeImage/*.so Dist - -examples: FreeImage - make -C Examples/Linux all - -FreeImage: - @if [ ! -f .nodos2unix ]; then \ - $(DOS2UNIX) Source/*.[ch]* Source/FreeImage/*.[ch]* \ - Source/LibJPEG/*.[ch]* Source/LibMNG/*.[ch]* Source/LibPNG/*.[ch]* \ - Source/LibTIFF/*.[ch]* Source/ZLib/*.[ch]* \ - Examples/Linux/*.[ch]* ; \ - touch .nodos2unix; \ - fi - make -C Source/FreeImage all - -refix: - rm .nodos2unix - -install: - make -C Source/FreeImage install - -clean: - rm -f Dist/* u2dtmp* .nodos2unix - make -C Source/FreeImage clean - make -C Examples clean diff --git a/freeimage241/Makefile.cfg b/freeimage241/Makefile.cfg deleted file mode 100644 index 7d2ee8e..0000000 --- a/freeimage241/Makefile.cfg +++ /dev/null @@ -1,10 +0,0 @@ -CC = gcc -CPP = g++ - -INSTALLDIR = /usr/lib - -#converts cr/lf to just lf -DOS2UNIX = dos2unix - -COMPILERFLAGS = -O3 -LIBRARIES = -ljpeg -lpng -ltiff -lmng diff --git a/freeimage241/README.linux b/freeimage241/README.linux deleted file mode 100644 index de3b83a..0000000 --- a/freeimage241/README.linux +++ /dev/null @@ -1,23 +0,0 @@ -Check Makefile.cfg and set the variables in there if things dont work. -This compiles with no warnings at all with the default options on -Redhat 6.2 / Linux-2.2.16 with glibc6 and the pre-installed libjpeg, -libpng, libtiff, and libz libraries that were already installed in my -/usr/lib directory. -I tested the GTK example I wrote under X11R6 running 1024x768x24bit but -the machine I was using does not allow switching to other modes, so -I am unsure if the picture would be displayed properly in other video -modes. -You should be able to link progams with the -lfreeimage options after -it is compiled and installed, which will require that libjpeg, libpng, -libtiff, and libz are installed as well. If you statically link with -libfreeimage.a you must also link with libjpeg.a, libpng.a, libtiff.a, -and libz.a. -If you unzip a new snapshot over old code, it will need to be reran -thru dos2unix to strip the CR's from it. `make refix` or just -rm .nodos2unix yourself to allow make to rerun dos2unix next time -the library is build. -Please let me know how this works for you under Linux or any other *nix - -- Ryan "Ark" Rubley -- ark@lhq.com / rubleyr@csis.gvsu.edu - diff --git a/freeimage241/Source/FreeImage/BitmapAccess.cpp b/freeimage241/Source/FreeImage/BitmapAccess.cpp deleted file mode 100644 index 5c51426..0000000 --- a/freeimage241/Source/FreeImage/BitmapAccess.cpp +++ /dev/null @@ -1,323 +0,0 @@ -// ========================================================== -// FreeImage implementation -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@iut.univ-lehavre.fr) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#pragma warning (disable : 4786) - -#include - -#include "FreeImage.h" -#include "FreeImageIO.h" -#include "Utilities.h" - -// ---------------------------------------------------------- - -FI_STRUCT (FREEIMAGEHEADER) { - unsigned red_mask; - unsigned green_mask; - unsigned blue_mask; - BOOL transparent; - BYTE transparency_count; - BYTE transparent_table[256]; - BYTE filler[3]; -}; - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_Allocate(int width, int height, int bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask) { - FIBITMAP *bitmap = (FIBITMAP *)malloc(sizeof(FIBITMAP)); - - if (bitmap != NULL) { - height = abs(height); - - int dib_size = sizeof(FREEIMAGEHEADER) + sizeof(BITMAPINFOHEADER); - dib_size += sizeof(RGBQUAD) * CalculateUsedColors(bpp); - dib_size += CalculatePitch(CalculateLine(width, bpp)) * height; - - bitmap->data = (BYTE *)malloc(dib_size); - - if (bitmap->data != NULL) { - memset(bitmap->data, 0, dib_size); - - // write out the FREEIMAGEHEADER - - FREEIMAGEHEADER *fih = (FREEIMAGEHEADER *)bitmap->data; - fih->red_mask = red_mask; - fih->green_mask = green_mask; - fih->blue_mask = blue_mask; - fih->transparent = FALSE; - fih->transparency_count = 0; - - // write out the BITMAPINFOHEADER - - BITMAPINFOHEADER *bih = FreeImage_GetInfoHeader(bitmap); - bih->biSize = sizeof(BITMAPINFOHEADER); - bih->biWidth = width; - bih->biHeight = height; - bih->biPlanes = 1; - bih->biCompression = 0; - bih->biBitCount = bpp; - bih->biClrUsed = CalculateUsedColors(bpp); - bih->biClrImportant = bih->biClrUsed; - - return bitmap; - } else { - free(bitmap); - } - } - - return NULL; -} - -void DLL_CALLCONV -FreeImage_Free(FIBITMAP *dib) { - if (dib != NULL) { - if (dib->data != NULL) - free(dib->data); - - free(dib); - } -} - -void DLL_CALLCONV -FreeImage_Unload(FIBITMAP *dib) { - FreeImage_Free(dib); -} - -// ---------------------------------------------------------- - -FREE_IMAGE_COLOR_TYPE DLL_CALLCONV -FreeImage_GetColorType(FIBITMAP *dib) { - RGBQUAD *rgb; - - switch (FreeImage_GetBPP(dib)) { - case 1: - { - rgb = FreeImage_GetPalette(dib); - - if ((rgb->rgbRed == 0) && (rgb->rgbGreen == 0) && (rgb->rgbBlue == 0)) { - rgb++; - - if ((rgb->rgbRed == 255) && (rgb->rgbGreen == 255) && (rgb->rgbBlue == 255)) - return FIC_MINISBLACK; - } - - if ((rgb->rgbRed == 255) && (rgb->rgbGreen == 255) && (rgb->rgbBlue == 255)) { - rgb++; - - if ((rgb->rgbRed == 0) && (rgb->rgbGreen == 0) && (rgb->rgbBlue == 0)) - return FIC_MINISWHITE; - } - - return FIC_PALETTE; - } - - case 4: - case 8: // Check if the DIB has a color or a greyscale palette - { - rgb = FreeImage_GetPalette(dib); - - for (unsigned i = 0; i < FreeImage_GetColorsUsed(dib); i++) { - if ((rgb->rgbRed != rgb->rgbGreen) || (rgb->rgbRed != rgb->rgbBlue)) - return FIC_PALETTE; - - // The DIB has a color palette if the greyscale isn't a linear ramp - - if (rgb->rgbRed != i) - return FIC_PALETTE; - - rgb++; - } - - return FIC_MINISBLACK; - } - - case 16: - case 24: - return FIC_RGB; - - case 32: - { - for (unsigned y = 0; y < FreeImage_GetHeight(dib); ++y) { - rgb = (RGBQUAD *)FreeImage_GetScanLine(dib, y); - - for (unsigned x = 0; x < FreeImage_GetWidth(dib); ++x) - if (rgb[x].rgbReserved != 0) - return FIC_RGBALPHA; - } - - return FIC_RGB; - } - - default : - return FIC_MINISBLACK; - } -} - -// ---------------------------------------------------------- - -unsigned DLL_CALLCONV -FreeImage_GetRedMask(FIBITMAP *dib) { - return dib ? ((FREEIMAGEHEADER *)dib->data)->red_mask : 0; -} - -unsigned DLL_CALLCONV -FreeImage_GetGreenMask(FIBITMAP *dib) { - return dib ? ((FREEIMAGEHEADER *)dib->data)->green_mask : 0; -} - -unsigned DLL_CALLCONV -FreeImage_GetBlueMask(FIBITMAP *dib) { - return dib ? ((FREEIMAGEHEADER *)dib->data)->blue_mask : 0; -} - -BOOL DLL_CALLCONV -FreeImage_IsTransparent(FIBITMAP *dib) { - return (dib != NULL) ? ((FREEIMAGEHEADER *)dib->data)->transparent : FALSE; -} - -BYTE * DLL_CALLCONV -FreeImage_GetTransparencyTable(FIBITMAP *dib) { - return dib ? ((FREEIMAGEHEADER *)dib->data)->transparent_table : NULL; -} - -void DLL_CALLCONV -FreeImage_SetTransparent(FIBITMAP *dib, BOOL enabled) { - if (dib) { - if ((FreeImage_GetBPP(dib) == 8) || (FreeImage_GetBPP(dib) == 32)) { - ((FREEIMAGEHEADER *)dib->data)->transparent = enabled; - } else { - ((FREEIMAGEHEADER *)dib->data)->transparent = FALSE; - } - } -} - -unsigned DLL_CALLCONV -FreeImage_GetTransparencyCount(FIBITMAP *dib) { - return dib ? ((FREEIMAGEHEADER *)dib->data)->transparency_count : 0; -} - -void DLL_CALLCONV -FreeImage_SetTransparencyTable(FIBITMAP *dib, BYTE *table, BYTE count) { - if (dib) { - if (FreeImage_GetBPP(dib) == 8) { - ((FREEIMAGEHEADER *)dib->data)->transparent = TRUE; - ((FREEIMAGEHEADER *)dib->data)->transparency_count = count; - - if (table != NULL) { - memcpy(((FREEIMAGEHEADER *)dib->data)->transparent_table, table, count); - } else { - memset(((FREEIMAGEHEADER *)dib->data)->transparent_table, 0xff, count); - } - } else { - ((FREEIMAGEHEADER *)dib->data)->transparency_count = 0; - } - } -} - -// ---------------------------------------------------------- - -unsigned DLL_CALLCONV -FreeImage_GetWidth(FIBITMAP *dib) { - return dib ? FreeImage_GetInfoHeader(dib)->biWidth : 0; -} - -unsigned DLL_CALLCONV -FreeImage_GetHeight(FIBITMAP *dib) { - return (dib) ? FreeImage_GetInfoHeader(dib)->biHeight : 0; -} - -unsigned DLL_CALLCONV -FreeImage_GetBPP(FIBITMAP *dib) { - return dib ? FreeImage_GetInfoHeader(dib)->biBitCount : 0; -} - -unsigned DLL_CALLCONV -FreeImage_GetLine(FIBITMAP *dib) { - return dib ? ((FreeImage_GetWidth(dib) * FreeImage_GetBPP(dib)) + 7) / 8 : 0; -} - -unsigned DLL_CALLCONV -FreeImage_GetPitch(FIBITMAP *dib) { - return dib ? FreeImage_GetLine(dib) + 3 & ~3 : 0; -} - -unsigned DLL_CALLCONV -FreeImage_GetColorsUsed(FIBITMAP *dib) { - return dib ? FreeImage_GetInfoHeader(dib)->biClrUsed : 0; -} - -BYTE * DLL_CALLCONV -FreeImage_GetBits(FIBITMAP *dib) { - return dib ? ((BYTE *)FreeImage_GetInfoHeader(dib) + sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * FreeImage_GetInfoHeader(dib)->biClrUsed) : NULL; -} - -BYTE * DLL_CALLCONV -FreeImage_GetBitsRowCol(FIBITMAP *dib, int col, int row) { - if (dib) { - int width = FreeImage_GetWidth(dib); - - if (FreeImage_GetBPP(dib) == 4) - width /= 2; - else if (FreeImage_GetBPP(dib) == 1) - width /= 8; - - return FreeImage_GetBits(dib) + ((FreeImage_GetHeight(dib) - row - 1) * FreeImage_GetPitch(dib)) + (col * FreeImage_GetBPP(dib) / 8); - } else { - return NULL; - } -} - -BYTE * DLL_CALLCONV -FreeImage_GetScanLine(FIBITMAP *dib, int scanline) { - return (dib) ? CalculateScanLine(FreeImage_GetBits(dib), FreeImage_GetPitch(dib), scanline) : NULL; -} - -unsigned DLL_CALLCONV -FreeImage_GetDIBSize(FIBITMAP *dib) { - return (dib) ? sizeof(BITMAPINFOHEADER) + (FreeImage_GetColorsUsed(dib) * sizeof(RGBQUAD)) + (FreeImage_GetPitch(dib) * FreeImage_GetHeight(dib)) : 0; -} - -RGBQUAD * DLL_CALLCONV -FreeImage_GetPalette(FIBITMAP *dib) { - return (dib && FreeImage_GetBPP(dib) < 16) ? (RGBQUAD *)((BYTE *)dib->data + sizeof(FREEIMAGEHEADER) + sizeof(BITMAPINFOHEADER)) : NULL; -} - -unsigned DLL_CALLCONV -FreeImage_GetDotsPerMeterX(FIBITMAP *dib) { - return FreeImage_GetInfoHeader(dib)->biXPelsPerMeter; -} - -unsigned DLL_CALLCONV -FreeImage_GetDotsPerMeterY(FIBITMAP *dib) { - return (dib) ? FreeImage_GetInfoHeader(dib)->biYPelsPerMeter : 0; -} - -BITMAPINFOHEADER * DLL_CALLCONV -FreeImage_GetInfoHeader(FIBITMAP *dib) { - return (dib) ? (BITMAPINFOHEADER *)((BYTE *)dib->data + sizeof(FREEIMAGEHEADER)) : NULL; -} - -BITMAPINFO * DLL_CALLCONV -FreeImage_GetInfo(FIBITMAP *dib) { - return (dib) ? (BITMAPINFO *)((BYTE *)dib->data + sizeof(FREEIMAGEHEADER)) : NULL; -} diff --git a/freeimage241/Source/FreeImage/Conversion.cpp b/freeimage241/Source/FreeImage/Conversion.cpp deleted file mode 100644 index a6b148d..0000000 --- a/freeimage241/Source/FreeImage/Conversion.cpp +++ /dev/null @@ -1,185 +0,0 @@ -// ========================================================== -// Bitmap conversion routines -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@iut.univ-lehavre.fr) -// - Jani Kajala (janik@remedy.fi) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include - -#include "FreeImage.h" -#include "Quantizers.h" - -// ---------------------------------------------------------- - -#define CONVERT(from, to) case to : FreeImage_ConvertLine##from##To##to(bits, scanline, FreeImage_GetWidth(dib)); break; -#define CONVERTWITHPALETTE(from, to) case to : FreeImage_ConvertLine##from##To##to(bits, scanline, FreeImage_GetWidth(dib), FreeImage_GetPalette(dib)); break; - -#define CONVERTTO16(from) \ - case 16 : \ - if ((red_mask == 0x7C00) && (green_mask == 0x3E0) && (blue_mask == 0x1F)) { \ - FreeImage_ConvertLine##from##To16_555(bits, scanline, FreeImage_GetWidth(dib)); \ - } else { \ - FreeImage_ConvertLine##from##To16_565(bits, scanline, FreeImage_GetWidth(dib)); \ - } \ - break; - -#define CONVERTTO16WITHPALETTE(from) \ - case 16 : \ - if ((red_mask == 0x7C00) && (green_mask == 0x3E0) && (blue_mask == 0x1F)) { \ - FreeImage_ConvertLine##from##To16_555(bits, scanline, FreeImage_GetWidth(dib), FreeImage_GetPalette(dib)); \ - } else { \ - FreeImage_ConvertLine##from##To16_565(bits, scanline, FreeImage_GetWidth(dib), FreeImage_GetPalette(dib)); \ - } \ - break; - -// ========================================================== - -FIBITMAP * DLL_CALLCONV -FreeImage_ColorQuantize(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize) { - if (dib) { - if (FreeImage_GetBPP(dib) == 24) { - switch(quantize) { - case FIQ_WUQUANT : - try { - WuQuantizer Q (dib); - return (FIBITMAP *) Q.Quantize(); - } catch (char *) { - return NULL; - } - - case FIQ_NNQUANT : - return NNQuantizer(dib, 15); - } - } - } - - return NULL; -} - -// ========================================================== - -FIBITMAP * DLL_CALLCONV -FreeImage_ConvertFromRawBits(BYTE *bits, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown) { - FIBITMAP *dib = FreeImage_Allocate(width, height, bpp, red_mask, green_mask, blue_mask); - - if (dib != NULL) { - if (topdown) { - for (int i = 0; i < height; ++i) { - memcpy(FreeImage_GetScanLine(dib, i), bits, FreeImage_GetLine(dib)); - - bits += pitch; - } - } else { - for (int i = height - 1; i >= 0; --i) { - memcpy(FreeImage_GetScanLine(dib, i), bits, FreeImage_GetLine(dib)); - - bits += pitch; - } - } - } - - return dib; -} - -void DLL_CALLCONV -FreeImage_ConvertToRawBits(BYTE *bits, FIBITMAP *dib, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown) { - if ((dib != NULL) && (bits != NULL)) { - for (unsigned i = 0; i < FreeImage_GetHeight(dib); ++i) { - BYTE *scanline; - - if (topdown) { - scanline = FreeImage_GetScanLine(dib, i); - } else { - scanline = FreeImage_GetScanLine(dib, FreeImage_GetHeight(dib) - i - 1); - } - - if ((bpp == 16) && (FreeImage_GetBPP(dib) == 16)) { - // convert 555 to 565 or vice versa - - if ((red_mask == 0x7C00) && (green_mask == 0x3E0) && (blue_mask == 0x1F)) { - if ((FreeImage_GetRedMask(dib) == 0xF800) && (FreeImage_GetGreenMask(dib) == 0x7E0) && (FreeImage_GetBlueMask(dib) == 0x1F)) { - FreeImage_ConvertLine16_555_To16_565(bits, scanline, FreeImage_GetWidth(dib)); - } else { - memcpy(bits, scanline, FreeImage_GetLine(dib)); - } - } else { - if ((FreeImage_GetRedMask(dib) == 0x7C00) && (FreeImage_GetGreenMask(dib) == 0x3E0) && (FreeImage_GetBlueMask(dib) == 0x1F)) { - FreeImage_ConvertLine16_565_To16_555(bits, scanline, FreeImage_GetWidth(dib)); - } else { - memcpy(bits, scanline, FreeImage_GetLine(dib)); - } - } - } else if (FreeImage_GetBPP(dib) != bpp) { - switch(FreeImage_GetBPP(dib)) { - case 1 : - switch(bpp) { - CONVERT(1, 8) - CONVERTTO16WITHPALETTE(1) - CONVERTWITHPALETTE(1, 24) - CONVERTWITHPALETTE(1, 32) - }; - - break; - - case 4 : - switch(bpp) { - CONVERT(4, 8) - CONVERTTO16WITHPALETTE(4) - CONVERTWITHPALETTE(4, 24) - CONVERTWITHPALETTE(4, 32) - }; - - break; - - case 8 : - switch(bpp) { - CONVERTTO16WITHPALETTE(8) - CONVERTWITHPALETTE(8, 24) - CONVERTWITHPALETTE(8, 32) - }; - - break; - - case 24 : - switch(bpp) { - CONVERT(24, 8) - CONVERTTO16(24) - CONVERT(24, 32) - }; - - break; - - case 32 : - switch(bpp) { - CONVERT(32, 8) - CONVERTTO16(32) - CONVERT(32, 24) - }; - - break; - }; - } else { - memcpy(bits, scanline, FreeImage_GetLine(dib)); - } - - bits += pitch; - } - } -} diff --git a/freeimage241/Source/FreeImage/Conversion16_555.cpp b/freeimage241/Source/FreeImage/Conversion16_555.cpp deleted file mode 100644 index 9f5ded5..0000000 --- a/freeimage241/Source/FreeImage/Conversion16_555.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// ========================================================== -// Bitmap conversion routines -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@iut.univ-lehavre.fr) -// - Jani Kajala (janik@remedy.fi) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- - -#define RGB555(r, g, b) (((r) >> 3) | (((g) >> 3) << 5) | (((b) >> 3) << 10)) - -// ---------------------------------------------------------- -// internal conversions X to 16 bits (555) -// ---------------------------------------------------------- - -void DLL_CALLCONV -FreeImage_ConvertLine1To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - WORD *new_bits = (WORD *)target; - - for (int cols = 0; cols < width_in_pixels; cols++) { - int index = (source[cols >> 3] & (0x80 >> (cols & 0x07))) != 0 ? 1 : 0; - - new_bits[cols] = RGB555(palette[index].rgbBlue, palette[index].rgbGreen, palette[index].rgbRed); - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine4To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - WORD *new_bits = (WORD *)target; - BOOL lonibble = FALSE; - int x = 0; - - for (int cols = 0; cols < width_in_pixels; cols++) { - RGBQUAD *grab_palette; - - if (lonibble) { - grab_palette = palette + LOWNIBBLE(source[x++]); - } else { - grab_palette = palette + (HINIBBLE(source[x]) >> 4); - } - - new_bits[cols] = RGB555(grab_palette->rgbBlue, grab_palette->rgbGreen, grab_palette->rgbRed); - - lonibble = !lonibble; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine8To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - WORD *new_bits = (WORD *)target; - - for (int cols = 0; cols < width_in_pixels; cols++) { - RGBQUAD *grab_palette = palette + source[cols]; - - new_bits[cols] = RGB555(grab_palette->rgbBlue, grab_palette->rgbGreen, grab_palette->rgbRed); - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine16_565_To16_555(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *src_bits = (WORD *)source; - WORD *new_bits = (WORD *)target; - - for (int cols = 0; cols < width_in_pixels; cols++) { - new_bits[cols] = RGB555((((src_bits[cols] & 0x7C00) >> 10) * 0xFF) / 0x1F, - (((src_bits[cols] & 0x3E0) >> 5) * 0xFF) / 0x1F, - ((src_bits[cols] & 0x1F) * 0xFF) / 0x1F); - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine24To16_555(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *new_bits = (WORD *)target; - - for (int cols = 0; cols < width_in_pixels; cols++) { - new_bits[cols] = RGB555(source[0], source[1], source[2]); - - source += 3; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine32To16_555(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *new_bits = (WORD *)target; - - for (int cols = 0; cols < width_in_pixels; cols++) { - new_bits[cols] = RGB555(source[0], source[1], source[2]); - - source += 4; - } -} - -// ---------------------------------------------------------- -// smart convert X to 16 bits -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_ConvertTo16Bits555(FIBITMAP *dib) { - if (dib != NULL) { - int width = FreeImage_GetWidth(dib); - int height = FreeImage_GetHeight(dib); - - switch (FreeImage_GetBPP(dib)) { - case 1 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x3E0, 0x7C00); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine1To16_555(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - return new_dib; - } - - break; - } - - case 4 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x3E0, 0x7C00); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine4To16_555(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - return new_dib; - } - - break; - } - - case 8 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x3E0, 0x7C00); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine8To16_555(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - return new_dib; - } - - break; - } - - case 16 : - { - - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x3E0, 0x7C00); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine16_565_To16_555(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - - return new_dib; - } - - break; - } - - case 24 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x3E0, 0x7C00); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine24To16_555(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - - return new_dib; - } - - break; - } - - case 32 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x3E0, 0x7C00); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine32To16_555(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - - return new_dib; - } - - break; - } - } - } - - return NULL; -} diff --git a/freeimage241/Source/FreeImage/Conversion16_565.cpp b/freeimage241/Source/FreeImage/Conversion16_565.cpp deleted file mode 100644 index 6529c28..0000000 --- a/freeimage241/Source/FreeImage/Conversion16_565.cpp +++ /dev/null @@ -1,214 +0,0 @@ -// ========================================================== -// Bitmap conversion routines -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@iut.univ-lehavre.fr) -// - Jani Kajala (janik@remedy.fi) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- - -#define RGB565(r, g, b) (((r) >> 3) | (((g) >> 2) << 5) | (((b) >> 3) << 11)) - -// ---------------------------------------------------------- -// internal conversions X to 16 bits (565) -// ---------------------------------------------------------- - -void DLL_CALLCONV -FreeImage_ConvertLine1To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - WORD *new_bits = (WORD *)target; - - for (int cols = 0; cols < width_in_pixels; cols++) { - int index = (source[cols >> 3] & (0x80 >> (cols & 0x07))) != 0 ? 1 : 0; - - new_bits[cols] = RGB565(palette[index].rgbBlue, palette[index].rgbGreen, palette[index].rgbRed); - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine4To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - WORD *new_bits = (WORD *)target; - BOOL lonibble = FALSE; - int x = 0; - - for (int cols = 0; cols < width_in_pixels; cols++) { - RGBQUAD *grab_palette; - - if (lonibble) { - grab_palette = palette + LOWNIBBLE(source[x++]); - } else { - grab_palette = palette + (HINIBBLE(source[x]) >> 4); - } - - new_bits[cols] = RGB565(grab_palette->rgbBlue, grab_palette->rgbGreen, grab_palette->rgbRed); - - lonibble = !lonibble; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine8To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - WORD *new_bits = (WORD *)target; - - for (int cols = 0; cols < width_in_pixels; cols++) { - RGBQUAD *grab_palette = palette + source[cols]; - - new_bits[cols] = RGB565(grab_palette->rgbBlue, grab_palette->rgbGreen, grab_palette->rgbRed); - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine16_555_To16_565(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *new_bits = (WORD *)target; - - for (int cols = 0; cols < width_in_pixels; cols++) { - RGBQUAD quad; - - quad.rgbBlue = (((source[cols] & 0xF800) >> 11) * 0xFF) / 0x1F; - quad.rgbGreen = (((source[cols] & 0x7E0) >> 5) * 0xFF) / 0x3F; - quad.rgbRed = ((source[cols] & 0x1F) * 0xFF) / 0x1F; - - new_bits[cols] = RGB565(quad.rgbBlue, quad.rgbGreen, quad.rgbRed); - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine24To16_565(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *new_bits = (WORD *)target; - - for (int cols = 0; cols < width_in_pixels; cols++) { - new_bits[cols] = RGB565(source[0], source[1], source[2]); - - source += 3; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine32To16_565(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *new_bits = (WORD *)target; - - for (int cols = 0; cols < width_in_pixels; cols++) { - new_bits[cols] = RGB565(source[0], source[1], source[2]); - - source += 4; - } -} - -// ---------------------------------------------------------- -// smart convert X to 16 bits (565) -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_ConvertTo16Bits565(FIBITMAP *dib) { - if (dib != NULL) { - int width = FreeImage_GetWidth(dib); - int height = FreeImage_GetHeight(dib); - - switch (FreeImage_GetBPP(dib)) { - case 1 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x7E0, 0xF800); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine1To16_565(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - return new_dib; - } - - break; - } - - case 4 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x7E0, 0xF800); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine4To16_565(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - return new_dib; - } - - break; - } - - case 8 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x7E0, 0xF800); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine8To16_565(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - return new_dib; - } - - break; - } - - case 16 : - { - - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x7E0, 0xF800); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine16_555_To16_565(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - - return new_dib; - } - - break; - } - - case 24 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x7E0, 0xF800); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine24To16_565(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - - return new_dib; - } - - break; - } - - case 32 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 16, 0x1F, 0x7E0, 0xF800); - - if (new_dib) { - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine32To16_565(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - - return new_dib; - } - - break; - } - } - } - - return NULL; -} diff --git a/freeimage241/Source/FreeImage/Conversion24.cpp b/freeimage241/Source/FreeImage/Conversion24.cpp deleted file mode 100644 index fad494a..0000000 --- a/freeimage241/Source/FreeImage/Conversion24.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// ========================================================== -// Bitmap conversion routines -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Dale Larson (dlarson@norsesoft.com) -// - Hervé Drolon (drolon@iut.univ-lehavre.fr) -// - Jani Kajala (janik@remedy.fi) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- -// internal conversions X to 24 bits -// ---------------------------------------------------------- - -void DLL_CALLCONV -FreeImage_ConvertLine1To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - for (int cols = 0; cols < width_in_pixels; cols++) { - BYTE index = (source[cols >> 3] & (0x80 >> (cols & 0x07))) != 0 ? 1 : 0; - - target[0] = palette[index].rgbBlue; - target[1] = palette[index].rgbGreen; - target[2] = palette[index].rgbRed; - - target += 3; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine4To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - BOOL low_nibble = FALSE; - int x = 0; - - for (int cols = 0; cols < width_in_pixels; ++cols ) { - if (low_nibble) { - target[0] = palette[LOWNIBBLE(source[x])].rgbBlue; - target[1] = palette[LOWNIBBLE(source[x])].rgbGreen; - target[2] = palette[LOWNIBBLE(source[x])].rgbRed; - - x++; - } else { - target[0] = palette[HINIBBLE(source[x]) >> 4].rgbBlue; - target[1] = palette[HINIBBLE(source[x]) >> 4].rgbGreen; - target[2] = palette[HINIBBLE(source[x]) >> 4].rgbRed; - } - - low_nibble = !low_nibble; - - target += 3; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine8To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - for (int cols = 0; cols < width_in_pixels; cols++) { - target[0] = palette[source[cols]].rgbBlue; - target[1] = palette[source[cols]].rgbGreen; - target[2] = palette[source[cols]].rgbRed; - - target += 3; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine16To24_555(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *bits = (WORD *)source; - - for (int cols = 0; cols < width_in_pixels; cols++) { - target[2] = (((bits[cols] & 0x7C00) >> 10) * 0xFF) / 0x1F; - target[1] = (((bits[cols] & 0x3E0) >> 5) * 0xFF) / 0x1F; - target[0] = ((bits[cols] & 0x1F) * 0xFF) / 0x1F; - - target += 3; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine16To24_565(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *bits = (WORD *)source; - - for (int cols = 0; cols < width_in_pixels; cols++) { - target[2] = (((bits[cols] & 0xF800) >> 11) * 0xFF) / 0x1F; - target[1] = (((bits[cols] & 0x7E0) >> 5) * 0xFF) / 0x3F; - target[0] = ((bits[cols] & 0x1F) * 0xFF) / 0x1F; - - target += 3; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine32To24(BYTE *target, BYTE *source, int width_in_pixels) { - for (int cols = 0; cols < width_in_pixels; cols++) { - target[0] = source[0]; - target[1] = source[1]; - target[2] = source[2]; - - target += 3; - source += 4; - } -} - -// ---------------------------------------------------------- -// smart convert X to 24 bits -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_ConvertTo24Bits(FIBITMAP *dib) { - if (dib != NULL) { - int width = FreeImage_GetWidth(dib); - int height = FreeImage_GetHeight(dib); - - switch (FreeImage_GetBPP(dib)) { - case 1 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 24, 0xFF, 0xFF00, 0xFF0000); - - if (new_dib != NULL) - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine1To24(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - return new_dib; - } - - case 4 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 24, 0xFF, 0xFF00, 0xFF0000); - - if (new_dib != NULL) - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine4To24(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - return new_dib; - } - - case 8 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 24, 0xFF, 0xFF00, 0xFF0000); - - if (new_dib != NULL) - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine8To24(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - return new_dib; - } - - case 16 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 24, 0xFF, 0xFF00, 0xFF0000); - - if (new_dib != NULL) { - for (int rows = 0; rows < height; rows++) { - if ((FreeImage_GetRedMask(dib) == 0x1F) && (FreeImage_GetGreenMask(dib) == 0x3E0) && (FreeImage_GetBlueMask(dib) == 0x7C00)) { - FreeImage_ConvertLine16To24_555(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } else { - FreeImage_ConvertLine16To24_565(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } - } - } - - return new_dib; - } - - case 32 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 24, 0xFF, 0xFF00, 0xFF0000); - - if (new_dib != NULL) - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine32To24(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - - return new_dib; - } - } - } - - return NULL; -} diff --git a/freeimage241/Source/FreeImage/Conversion32.cpp b/freeimage241/Source/FreeImage/Conversion32.cpp deleted file mode 100644 index b7c45da..0000000 --- a/freeimage241/Source/FreeImage/Conversion32.cpp +++ /dev/null @@ -1,214 +0,0 @@ -// ========================================================== -// Bitmap conversion routines -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@iut.univ-lehavre.fr) -// - Jani Kajala (janik@remedy.fi) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- -// internal conversions X to 32 bits -// ---------------------------------------------------------- - -void DLL_CALLCONV -FreeImage_ConvertLine1To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - for (int cols = 0; cols < width_in_pixels; cols++) { - int index = (source[cols>>3] & (0x80 >> (cols & 0x07))) != 0 ? 1 : 0; - - target[0] = palette[index].rgbBlue; - target[1] = palette[index].rgbGreen; - target[2] = palette[index].rgbRed; - - target += 4; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine4To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - BOOL low_nibble = FALSE; - int x = 0; - - for (int cols = 0 ; cols < width_in_pixels ; ++cols) { - if (low_nibble) { - target[0] = palette[LOWNIBBLE(source[x])].rgbBlue; - target[1] = palette[LOWNIBBLE(source[x])].rgbGreen; - target[2] = palette[LOWNIBBLE(source[x])].rgbRed; - - x++; - } else { - target[0] = palette[HINIBBLE(source[x]) >> 4].rgbBlue; - target[1] = palette[HINIBBLE(source[x]) >> 4].rgbGreen; - target[2] = palette[HINIBBLE(source[x]) >> 4].rgbRed; - } - - low_nibble = !low_nibble; - - target += 4; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine8To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette) { - for (int cols = 0; cols < width_in_pixels; cols++) { - target[0] = palette[source[cols]].rgbBlue; - target[1] = palette[source[cols]].rgbGreen; - target[2] = palette[source[cols]].rgbRed; - - target += 4; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine16To32_555(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *bits = (WORD *)source; - - for (int cols = 0; cols < width_in_pixels; cols++) { - target[2] = (((bits[cols] & 0x7C00) >> 10) * 0xFF) / 0x1F; - target[1] = (((bits[cols] & 0x3E0) >> 5) * 0xFF) / 0x1F; - target[0] = ((bits[cols] & 0x1F) * 0xFF) / 0x1F; - - target += 4; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine16To32_565(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *bits = (WORD *)source; - - for (int cols = 0; cols < width_in_pixels; cols++) { - target[2] = ((bits[cols] & 0xF800) >> 11) << 3; - target[1] = ((bits[cols] & 0x7E0) >> 5) << 2; - target[0] = (bits[cols] & 0x1F) << 3; - - target += 4; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine24To32(BYTE *target, BYTE *source, int width_in_pixels) { - for (int cols = 0; cols < width_in_pixels; cols++) { -// *(DWORD *)target = *(DWORD *) source & 0x00FFFFFF; //this does an extra READ! - target[0]=source[0]; - target[1]=source[1]; - target[2]=source[2]; - target[3]=0; - target += 4; - source += 3; - } -} - -// ---------------------------------------------------------- - -static void DLL_CALLCONV -MapTransparentTableToAlpha(RGBQUAD *target, BYTE *source, BYTE *table, int transparent_pixels, int width_in_pixels) { - for (int cols = 0; cols < width_in_pixels; cols++) { - target[cols].rgbReserved = (source[cols] < transparent_pixels) ? table[source[cols]] : 255; - } -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_ConvertTo32Bits(FIBITMAP *dib) { - if (dib != NULL) { - int width = FreeImage_GetWidth(dib); - int height = FreeImage_GetHeight(dib); - - switch (FreeImage_GetBPP(dib)) { - case 1 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 32, 0xFF, 0xFF00, 0xFF0000); - - if (new_dib != NULL) - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine1To32(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - return new_dib; - } - - case 4 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 32, 0xFF, 0xFF00, 0xFF0000); - - if (new_dib != NULL) { - for (int rows = 0; rows < height; rows++) { - FreeImage_ConvertLine4To32(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - if (FreeImage_IsTransparent(dib)) { - MapTransparentTableToAlpha((RGBQUAD *)FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), FreeImage_GetTransparencyTable(dib), FreeImage_GetTransparencyCount(dib), width); - } - } - - return new_dib; - } - } - - case 8 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 32, 0xFF, 0xFF00, 0xFF0000); - - if (new_dib != NULL) { - for (int rows = 0; rows < height; rows++) { - FreeImage_ConvertLine8To32(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib)); - - if (FreeImage_IsTransparent(dib)) { - MapTransparentTableToAlpha((RGBQUAD *)FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), FreeImage_GetTransparencyTable(dib), FreeImage_GetTransparencyCount(dib), width); - } - } - - return new_dib; - } - } - - case 16 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 32, 0xFF, 0xFF00, 0xFF0000); - - if (new_dib != NULL) { - for (int rows = 0; rows < height; rows++) { - if ((FreeImage_GetRedMask(dib) == 0x1F) && (FreeImage_GetGreenMask(dib) == 0x3E0) && (FreeImage_GetBlueMask(dib) == 0x7C00)) { - FreeImage_ConvertLine16To32_555(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } else { - FreeImage_ConvertLine16To32_565(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } - } - } - - return new_dib; - } - - case 24 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 32, 0xFF, 0xFF00, 0xFF0000); - - if (new_dib != NULL){ - for (int rows = 0; rows < height; rows++){ - FreeImage_ConvertLine24To32(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } - } - - return new_dib; - } - } - } - - return NULL; -} diff --git a/freeimage241/Source/FreeImage/Conversion8.cpp b/freeimage241/Source/FreeImage/Conversion8.cpp deleted file mode 100644 index b3196ef..0000000 --- a/freeimage241/Source/FreeImage/Conversion8.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// ========================================================== -// Bitmap conversion routines -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@iut.univ-lehavre.fr) -// - Jani Kajala (janik@remedy.fi) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" - -// ---------------------------------------------------------- - -#define GREY1(r,g,b) (BYTE)(((WORD)r*77 + (WORD)g*150 + (WORD)b*29) >> 8) // .299R + .587G + .114B -#define GREY2(r,g,b) (BYTE)(((WORD)r*169 + (WORD)g*256 + (WORD)b*87) >> 9) // .33R + 0.5G + .17B - -// ---------------------------------------------------------- -// internal conversions X to 8 bits -// ---------------------------------------------------------- - -void DLL_CALLCONV -FreeImage_ConvertLine1To8(BYTE *target, BYTE *source, int width_in_pixels) { - for (int cols = 0; cols < width_in_pixels; cols++) - target[cols] = (source[cols >> 3] & (0x80 >> (cols & 0x07))) != 0; -} - -void DLL_CALLCONV -FreeImage_ConvertLine4To8(BYTE *target, BYTE *source, int width_in_pixels) { - int count_new = 0; - int count_org = 0; - BOOL hinibble = TRUE; - - while (count_new < width_in_pixels) { - if (hinibble) { - target[count_new] = (source[count_org] & 0xf0) >> 4; - } else { - target[count_new] = (source[count_org] & 0x0f); - - count_org++; - } - - hinibble = !hinibble; - - count_new++; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine16To8_555(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *bits = (WORD *)source; - - for (int cols = 0; cols < width_in_pixels; cols++) { - target[cols] = GREY1((((bits[cols] & 0x7C00) >> 10) * 0xFF) / 0x1F, - (((bits[cols] & 0x3E0) >> 5) * 0xFF) / 0x1F, - ((bits[cols] & 0x1F) * 0xFF) / 0x1F); - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine16To8_565(BYTE *target, BYTE *source, int width_in_pixels) { - WORD *bits = (WORD *)source; - - for (int cols = 0; cols < width_in_pixels; cols++) - target[cols] = GREY1((((bits[cols] & 0xF800) >> 11) * 0xFF) / 0x1F, - (((bits[cols] & 0x7E0) >> 5) * 0xFF) / 0x3F, - ((bits[cols] & 0x1F) * 0xFF) / 0x1F); -} - -void DLL_CALLCONV -FreeImage_ConvertLine24To8(BYTE *target, BYTE *source, int width_in_pixels) { - for (int cols = 0; cols < width_in_pixels; cols++) { - target[cols] = GREY1(source[2], source[1], source[0]); - - source += 3; - } -} - -void DLL_CALLCONV -FreeImage_ConvertLine32To8(BYTE *target, BYTE *source, int width_in_pixels) { - for (int cols = 0; cols < width_in_pixels; cols++) { - target[cols] = GREY1(source[2], source[1], source[0]); - - source += 4; - } -} - -// ---------------------------------------------------------- -// smart convert X to 8 bits -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_ConvertTo8Bits(FIBITMAP *dib) { - if(dib) { - int width = FreeImage_GetWidth(dib); - int height = FreeImage_GetHeight(dib); - - switch(FreeImage_GetBPP(dib)) { - case 1: - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); - - if (new_dib != NULL) { - // Copy the palette - - RGBQUAD *new_pal = FreeImage_GetPalette(new_dib); - RGBQUAD *old_pal = FreeImage_GetPalette(dib); - - for (int i = 0; i < 2; i++) { - new_pal[i].rgbRed = old_pal[i].rgbRed; - new_pal[i].rgbGreen = old_pal[i].rgbGreen; - new_pal[i].rgbBlue = old_pal[i].rgbBlue; - } - - // Expand and copy the bitmap data - - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine1To8(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - - } - - return new_dib; - } - - case 4 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); - - if (new_dib != NULL) { - // Copy the palette - - RGBQUAD *new_pal = FreeImage_GetPalette(new_dib); - RGBQUAD *old_pal = FreeImage_GetPalette(dib); - - for (int i = 0; i < 16; i++) { - new_pal[i].rgbRed = old_pal[i].rgbRed; - new_pal[i].rgbGreen = old_pal[i].rgbGreen; - new_pal[i].rgbBlue = old_pal[i].rgbBlue; - } - - // Expand and copy the bitmap data - - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine4To8(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } - - return new_dib; - } - - case 16 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); - - if (new_dib != NULL) { - // Build a greyscale palette - - RGBQUAD *new_pal = FreeImage_GetPalette(new_dib); - - for (int i = 0; i < 256; i++) { - new_pal[i].rgbRed = i; - new_pal[i].rgbGreen = i; - new_pal[i].rgbBlue = i; - } - - // Expand and copy the bitmap data - - for (int rows = 0; rows < height; rows++) { - if ((FreeImage_GetRedMask(dib) == 0x1F) && (FreeImage_GetGreenMask(dib) == 0x3E0) && (FreeImage_GetBlueMask(dib) == 0x7C00)) { - FreeImage_ConvertLine16To8_555(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } else { - FreeImage_ConvertLine16To8_565(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } - } - - return new_dib; - } - - return NULL; - } - - case 24 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); - - if (new_dib != NULL) { - // Build a greyscale palette - - RGBQUAD *new_pal = FreeImage_GetPalette(new_dib); - - for (int i = 0; i < 256; i++) { - new_pal[i].rgbRed = i; - new_pal[i].rgbGreen = i; - new_pal[i].rgbBlue = i; - } - - // Expand and copy the bitmap data - - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine24To8(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } - - return new_dib; - } - - case 32 : - { - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); - - if (new_dib != NULL) { - // Build a greyscale palette - - RGBQUAD *new_pal = FreeImage_GetPalette(new_dib); - - for (int i = 0; i < 256; i++) { - new_pal[i].rgbRed = i; - new_pal[i].rgbGreen = i; - new_pal[i].rgbBlue = i; - } - - // Expand and copy the bitmap data - - for (int rows = 0; rows < height; rows++) - FreeImage_ConvertLine32To8(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width); - } - - return new_dib; - } - } - } - - return NULL; -} diff --git a/freeimage241/Source/FreeImage/FreeImage.cpp b/freeimage241/Source/FreeImage/FreeImage.cpp deleted file mode 100644 index b56ca59..0000000 --- a/freeimage241/Source/FreeImage/FreeImage.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// ========================================================== -// FreeImage implementation -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifdef WIN32 -#include -#endif - -#include "FreeImage.h" - -//---------------------------------------------------------------------- - -static const char *s_version = "2.4.1"; -static const char *s_copyright = "This program uses FreeImage, an open source image library supporting all common bitmap formats. Get your free copy now from http://www.6ixsoft.com."; - -//---------------------------------------------------------------------- - -#ifdef WIN32 -#ifndef _LIB -BOOL APIENTRY -DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { - switch (ul_reason_for_call) { - case DLL_PROCESS_ATTACH : - FreeImage_Initialise(FALSE); - break; - - case DLL_PROCESS_DETACH : - FreeImage_DeInitialise(); - break; - - case DLL_THREAD_ATTACH : - case DLL_THREAD_DETACH : - break; - } - - return TRUE; -} -#endif -#endif - -//---------------------------------------------------------------------- - -const char * DLL_CALLCONV -FreeImage_GetVersion() { - return s_version; -} - -const char * DLL_CALLCONV -FreeImage_GetCopyrightMessage() { - return s_copyright; -} - -//---------------------------------------------------------------------- - -FreeImage_OutputMessageFunction FreeImage_OutputMessageProc = NULL; - -void DLL_CALLCONV -FreeImage_SetOutputMessage(FreeImage_OutputMessageFunction omf) { - FreeImage_OutputMessageProc = omf; -} - -void DLL_CALLCONV -FreeImage_OutputMessage(int fif, const char *message) { - if (FreeImage_OutputMessageProc != NULL) - FreeImage_OutputMessageProc((FREE_IMAGE_FORMAT)fif, message); -} diff --git a/freeimage241/Source/FreeImage/GetType.cpp b/freeimage241/Source/FreeImage/GetType.cpp deleted file mode 100644 index dbada96..0000000 --- a/freeimage241/Source/FreeImage/GetType.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// ========================================================== -// GetType -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include -#include - -#include "FreeImage.h" -#include "FreeImageIO.h" -#include "Plugin.h" - -// ---------------------------------------------------------- - -FREE_IMAGE_FORMAT DLL_CALLCONV -FreeImage_GetFileType(const char *filename, int size) { - FreeImageIO io; - SetDefaultIO(&io); - - FILE *handle = fopen(filename, "rb"); - - if (handle != NULL) { - FREE_IMAGE_FORMAT format = FreeImage_GetFileTypeFromHandle(&io, (fi_handle)handle, size); - - fclose(handle); - - return format; - } else { - return FIF_UNKNOWN; - } -} - -// ---------------------------------------------------------- - -FREE_IMAGE_FORMAT DLL_CALLCONV -FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size) { - if (handle != NULL) { - for (int i = FreeImage_GetFIFCount() - 1; i >= 0; --i) { - if (FreeImage_Validate((FREE_IMAGE_FORMAT)i, *io, handle)) { - return (FREE_IMAGE_FORMAT)i; - } - } - } - - return FIF_UNKNOWN; -} - -// ALIASES FOR BACKWARDS COMPATIBILITY ---------------------- - -const char * DLL_CALLCONV -FreeImage_GetFileTypeFromFormat(FREE_IMAGE_FORMAT fif) { - return FreeImage_GetFormatFromFIF(fif); -} - -FREE_IMAGE_FORMAT DLL_CALLCONV -FreeImage_GetFileTypeFromExt(const char *filename) { - return FreeImage_GetFIFFromFilename(filename); -} diff --git a/freeimage241/Source/FreeImage/LoadFunctions.cpp b/freeimage241/Source/FreeImage/LoadFunctions.cpp deleted file mode 100644 index 98dec3e..0000000 --- a/freeimage241/Source/FreeImage/LoadFunctions.cpp +++ /dev/null @@ -1,274 +0,0 @@ -// ========================================================== -// Simplified load functions -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadBMP(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("BMP"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadBMPFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("BMP"), io, handle, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SaveBMP(FIBITMAP *dib, const char *filename, int flags) { - return FreeImage_Save(FreeImage_GetFIFFromFormat("BMP"), dib, filename, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SaveBMPToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_SaveToHandle(FreeImage_GetFIFFromFormat("BMP"), dib, io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadICO(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("ICO"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadICOFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("ICO"), io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadIFF(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("IFF"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadIFFFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("IFF"), io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadJPEG(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("JPEG"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadJPEGFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("JPEG"), io, handle, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SaveJPEG(FIBITMAP *dib, const char *filename, int flags) { - return FreeImage_Save(FreeImage_GetFIFFromFormat("JPEG"), dib, filename, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SaveJPEGToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_SaveToHandle(FreeImage_GetFIFFromFormat("JPEG"), dib, io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadKOALA(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("KOALA"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadKOALAFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("KOALA"), io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadLBM(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("IFF"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadLBMFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("IFF"), io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadMNG(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("MNG"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadMNGFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("MNG"), io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadPCD(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("PCD"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadPCDFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("PCD"), io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadPCX(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("PCX"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadPCXFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("PCX"), io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadPNG(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("PNG"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadPNGFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("PNG"), io, handle, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SavePNG(FIBITMAP *dib, const char *filename, int flags) { - return FreeImage_Save(FreeImage_GetFIFFromFormat("PNG"), dib, filename, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SavePNGToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_SaveToHandle(FreeImage_GetFIFFromFormat("PNG"), dib, io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadPNM(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("PGM"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadPNMFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("PGM"), io, handle, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SavePNM(FIBITMAP *dib, const char *filename, int flags) { - return FreeImage_Save(FreeImage_GetFIFFromFormat("PGM"), dib, filename, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SavePNMToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_SaveToHandle(FreeImage_GetFIFFromFormat("PGM"), dib, io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadPSD(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("PSD"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadPSDFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("PSD"), io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadRAS(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("RAS"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadRASFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("RAS"), io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadTARGA(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("TARGA"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadTARGAFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("TARGA"), io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadTIFF(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("TIFF"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadTIFFFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("TIFF"), io, handle, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SaveTIFF(FIBITMAP *dib, const char *filename, int flags) { - return FreeImage_Save(FreeImage_GetFIFFromFormat("TIFF"), dib, filename, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SaveTIFFToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_SaveToHandle(FreeImage_GetFIFFromFormat("TIFF"), dib, io, handle, flags); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadWBMP(const char *filename, int flags) { - return FreeImage_Load(FreeImage_GetFIFFromFormat("WBMP"), filename, flags); -} - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadWBMPFromHandle(FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_LoadFromHandle(FreeImage_GetFIFFromFormat("WBMP"), io, handle, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SaveWBMP(FIBITMAP *dib, const char *filename, int flags) { - return FreeImage_Save(FreeImage_GetFIFFromFormat("WBMP"), dib, filename, flags); -} - -BOOL DLL_CALLCONV -FreeImage_SaveWBMPToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags) { - return FreeImage_SaveToHandle(FreeImage_GetFIFFromFormat("WBMP"), dib, io, handle, flags); -} diff --git a/freeimage241/Source/FreeImage/Makefile b/freeimage241/Source/FreeImage/Makefile deleted file mode 100644 index 461dd59..0000000 --- a/freeimage241/Source/FreeImage/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -include ../../Makefile.cfg - -INCLUDE = -I../ -CFLAGS = $(COMPILERFLAGS) $(INCLUDE) - -TARGET = freeimage -VER_MAJOR = 2 -VER_MINOR = 0.0 -MODULES = BitmapAccess.o Conversion.o Conversion16_555.o Conversion16_565.o \ - Conversion24.o Conversion32.o Conversion8.o FreeImage.o GetType.o Plugin.o \ - PluginBMP.o PluginICO.o PluginJPEG.o PluginKOALA.o PluginMNG.o PluginPCD.o \ - PluginPCX.o PluginPNG.o PluginPNM.o PluginRAS.o PluginTARGA.o PluginTIFF.o \ - PluginWBMP.o PluginLBM.o OldLoadFunctions.o NNQuantizer.o WuQuantizer.o Combine.o - -STATICLIB = lib$(TARGET).a -SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so -LIBNAME = lib$(TARGET).so.$(VER_MAJOR) - -all: default - -default: $(STATICLIB) $(SHAREDLIB) - -.c.o: - $(CC) $(CFLAGS) -c $< - -.cpp.o: - $(CPP) $(CFLAGS) -c $< - -$(STATICLIB): $(MODULES) - ar r $@ $? - -$(SHAREDLIB): $(MODULES) - $(CC) -s -shared -Wl,-soname,$(LIBNAME) -o $@ $? $(LIBRARIES) - ln -sf $(SHAREDLIB) $(LIBNAME) - -install: $(STATICLIB) $(SHAREDLIB) - install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR) - install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR) - ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(LIBNAME) - ldconfig - -clean: - rm -f *.o core d2utmp* $(STATICLIB) $(SHAREDLIB) $(LIBNAME) diff --git a/freeimage241/Source/FreeImage/NNQuantizer.cpp b/freeimage241/Source/FreeImage/NNQuantizer.cpp deleted file mode 100644 index 7dcf930..0000000 --- a/freeimage241/Source/FreeImage/NNQuantizer.cpp +++ /dev/null @@ -1,510 +0,0 @@ -// NeuQuant Neural-Net Quantization Algorithm -// ------------------------------------------ -// -// Copyright (c) 1994 Anthony Dekker -// -// NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. -// See "Kohonen neural networks for optimal colour quantization" -// in "Network: Computation in Neural Systems" Vol. 5 (1994) pp 351-367. -// for a discussion of the algorithm. -// -// Any party obtaining a copy of these files from the author, directly or -// indirectly, is granted, free of charge, a full and unrestricted irrevocable, -// world-wide, paid up, royalty-free, nonexclusive right and license to deal -// in this software and documentation files (the "Software"), including without -// limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons who receive -// copies from any such party to do so, with the only requirement being -// that this copyright notice remain intact. - -/////////////////////////////////////////////////////////////////////// -// History -// ------- -// January 2001: Adaptation of the Neural-Net Quantization Algorithm -// for the FreeImage 2 library -// Author: Hervé Drolon (drolon@infonie.fr) -/////////////////////////////////////////////////////////////////////// - -#include "FreeImage.h" - -const int netsize = 256; // number of colours used - - -// For 256 colours, fixed arrays need 8kb, plus space for the image -// ---------------------------------------------------------------- - - -// Four primes near 500 - assume no image has a length so large -// that it is divisible by all four primes -// ========================================================== - -#define prime1 499 -#define prime2 491 -#define prime3 487 -#define prime4 503 - -// Prototypes -// ========================================================== - -static void initnet(BYTE *thepic, DWORD len, int sample); -static void unbiasnet(); // can edit this function to do output of colour map -static void inxbuild(); -static int inxsearch(int b, int g, int r); -static int contest(int b, int g, int r); -static void altersingle(int alpha, int i, int b, int g, int r); -static void alterneigh(int rad, int i, int b, int g, int r); -static void learn(); - -// Network Definitions -// ========================================================== - -#define maxnetpos (netsize-1) -#define netbiasshift 4 // bias for colour values -#define ncycles 100 // no. of learning cycles - -// defs for freq and bias - -#define intbiasshift 16 // bias for fractions -#define intbias (((int) 1)<>betashift) // beta = 1 / 1024 -#define betagamma (intbias<<(gammashift-betashift)) - -// defs for decreasing radius factor - -#define initrad (netsize>>3) // for 256 cols, radius starts -#define radiusbiasshift 6 // at 32.0 biased by 6 bits -#define radiusbias (((int) 1)<>= netbiasshift; - } - network[i][3] = i; // record colour no - } -} - -////////////////////////////////////////////////////////////////////////////////// -// Insertion sort of network and building of netindex[0..255] (to do after unbias) -// ------------------------------------------------------------------------------- - -static void inxbuild() -{ - int i,j,smallpos,smallval; - int *p,*q; - int previouscol,startpos; - - previouscol = 0; - startpos = 0; - for (i = 0; i < netsize; i++) { - p = network[i]; - smallpos = i; - smallval = p[1]; // index on g - // find smallest in i..netsize-1 - for (j = i+1; j < netsize; j++) { - q = network[j]; - if (q[1] < smallval) { // index on g - smallpos = j; - smallval = q[1]; // index on g - } - } - q = network[smallpos]; - // swap p (i) and q (smallpos) entries - if (i != smallpos) { - j = q[0]; q[0] = p[0]; p[0] = j; - j = q[1]; q[1] = p[1]; p[1] = j; - j = q[2]; q[2] = p[2]; p[2] = j; - j = q[3]; q[3] = p[3]; p[3] = j; - } - // smallval entry is now in position i - if (smallval != previouscol) { - netindex[previouscol] = (startpos+i)>>1; - for (j = previouscol+1; j < smallval; j++) - netindex[j] = i; - previouscol = smallval; - startpos = i; - } - } - netindex[previouscol] = (startpos+maxnetpos)>>1; - for (j = previouscol+1; j < 256; j++) - netindex[j] = maxnetpos; // really 256 -} - -/////////////////////////////////////////////////////////////////////////////// -// Search for BGR values 0..255 (after net is unbiased) and return colour index -// ---------------------------------------------------------------------------- - -static int inxsearch(int b, int g, int r) -{ - int i, j, dist, a, bestd; - int *p; - int best; - - bestd = 1000; // biggest possible dist is 256*3 - best = -1; - i = netindex[g]; // index on g - j = i-1; // start at netindex[g] and work outwards - - while ((i < netsize) || (j >= 0)) { - if (i < netsize) { - p = network[i]; - dist = p[1] - g; // inx key - if (dist >= bestd) - i = netsize; // stop iter - else { - i++; - if (dist < 0) - dist = -dist; - a = p[0] - b; - if (a < 0) - a = -a; - dist += a; - if (dist < bestd) { - a = p[2] - r; - if (a<0) - a = -a; - dist += a; - if (dist < bestd) { - bestd = dist; - best = p[3]; - } - } - } - } - if (j >= 0) { - p = network[j]; - dist = g - p[1]; // inx key - reverse dif - if (dist >= bestd) - j = -1; // stop iter - else { - j--; - if (dist < 0) - dist = -dist; - a = p[0] - b; - if (a<0) - a = -a; - dist += a; - if (dist < bestd) { - a = p[2] - r; - if (a<0) - a = -a; - dist += a; - if (dist < bestd) { - bestd = dist; - best = p[3]; - } - } - } - } - } - return best; -} - -/////////////////////////////// -// Search for biased BGR values -// ---------------------------- - -static int contest(int b, int g, int r) -{ - // finds closest neuron (min dist) and updates freq - // finds best neuron (min dist-bias) and returns position - // for frequently chosen neurons, freq[i] is high and bias[i] is negative - // bias[i] = gamma*((1/netsize)-freq[i]) - - int i,dist,a,biasdist,betafreq; - int bestpos,bestbiaspos,bestd,bestbiasd; - int *p,*f, *n; - - bestd = ~(((int) 1)<<31); - bestbiasd = bestd; - bestpos = -1; - bestbiaspos = bestpos; - p = bias; - f = freq; - - for (i = 0; i < netsize; i++) { - n = network[i]; - dist = n[0] - b; - if (dist < 0) - dist = -dist; - a = n[1] - g; - if (a < 0) - a = -a; - dist += a; - a = n[2] - r; - if (a < 0) - a = -a; - dist += a; - if (dist < bestd) { - bestd = dist; - bestpos = i; - } - biasdist = dist - ((*p)>>(intbiasshift-netbiasshift)); - if (biasdist < bestbiasd) { - bestbiasd = biasdist; - bestbiaspos = i; - } - betafreq = (*f >> betashift); - *f++ -= betafreq; - *p++ += (betafreq << gammashift); - } - freq[bestpos] += beta; - bias[bestpos] -= betagamma; - return bestbiaspos; -} - -/////////////////////////////////////////////////////// -// Move neuron i towards biased (b,g,r) by factor alpha -// ---------------------------------------------------- - -static void altersingle(int alpha, int i, int b, int g, int r) -{ - int *n; - - n = network[i]; // alter hit neuron - *n -= (alpha * (*n - b)) / initalpha; - n++; - *n -= (alpha * (*n - g)) / initalpha; - n++; - *n -= (alpha * (*n - r)) / initalpha; -} - -//////////////////////////////////////////////////////////////////////////////////// -// Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2)) in radpower[|i-j|] -// --------------------------------------------------------------------------------- - -static void alterneigh(int rad, int i, int b, int g, int r) -{ - int j, k, lo, hi, a; - int *p, *q; - - lo = i - rad; if (lo < -1) lo = -1; - hi = i + rad; if (hi > netsize) hi = netsize; - - j = i+1; - k = i-1; - q = radpower; - while ((j < hi) || (k > lo)) { - a = (*(++q)); - if (j < hi) { - p = network[j]; - *p -= (a * (*p - b)) / alpharadbias; - p++; - *p -= (a * (*p - g)) / alpharadbias; - p++; - *p -= (a * (*p - r)) / alpharadbias; - j++; - } - if (k > lo) { - p = network[k]; - *p -= (a * (*p - b)) / alpharadbias; - p++; - *p -= (a * (*p - g)) / alpharadbias; - p++; - *p -= (a * (*p - r)) / alpharadbias; - k--; - } - } -} - -///////////////////// -// Main Learning Loop -// ------------------ - -static void learn() -{ - int i, j, b, g, r; - int radius, rad, alpha, step, delta, samplepixels; - int alphadec; // biased by 10 bits - BYTE *p; - BYTE *lim; - - alphadec = 30 + ((samplefac - 1) / 3); - p = thepicture; - lim = thepicture + lengthcount; - samplepixels = lengthcount / (3*samplefac); - delta = samplepixels / ncycles; - alpha = initalpha; - radius = initradius; - - rad = radius >> radiusbiasshift; - if (rad <= 1) rad = 0; - for (i = 0; i < rad; i++) - radpower[i] = alpha*(((rad*rad - i*i)*radbias)/(rad*rad)); - - if ((lengthcount % prime1) != 0) - step = 3*prime1; - else { - if ((lengthcount % prime2) != 0) - step = 3*prime2; - else { - if ((lengthcount % prime3) != 0) - step = 3*prime3; - else - step = 3*prime4; - } - } - - i = 0; - while (i < samplepixels) { - b = p[0] << netbiasshift; - g = p[1] << netbiasshift; - r = p[2] << netbiasshift; - j = contest(b,g,r); - - altersingle(alpha,j,b,g,r); - if (rad) alterneigh(rad,j,b,g,r); // alter neighbours - - p += step; - if (p >= lim) p -= lengthcount; - - i++; - if (i % delta == 0) { - alpha -= alpha / alphadec; - radius -= radius / radiusdec; - rad = radius >> radiusbiasshift; - if (rad <= 1) rad = 0; - for (j = 0; j < rad; j++) - radpower[j] = alpha * (((rad*rad - j*j) * radbias) / (rad*rad)); - } - } -} - -/////////////////////////// -// FreeImage implementation -// ------------------------ - -// Input parameters: -// - void* dib: DIB 24-bit to be quantized -// - int sampling: a sampling factor in range 1..30 -// 1 => slower, 30 => faster. Default value is 15 -// Return value: -// - NULL if the DIB is not valid or if it's not a 24-bit DIB -// - the quantized 8-bit (color palette) DIB otherwise - -FIBITMAP * -NNQuantizer(FIBITMAP *dib, int sampling) -{ - LONG width, height; - BYTE *dib_bits; // the input image itself - DWORD length; - - if ((!dib) || (FreeImage_GetBPP(dib) != 24)) { - return NULL; - } - - // 1) select a sampling factor in range 1..30 (input parameter 'sampling') - // 1 => slower, 30 => faster. Default value is 15 - - - // 2) Get DIB parameters - - width = FreeImage_GetWidth(dib); // DIB width - height = FreeImage_GetHeight(dib); // DIB height - dib_bits = FreeImage_GetBits(dib); // pointer to DIB pixels - length = 3L * width * height; // image size in bytes - - // 3) Initialize the network and apply the learning algorithm - - initnet(dib_bits, length, sampling); - learn(); - unbiasnet(); - - // 4) Allocate a new 8-bit DIB - - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); - - if (new_dib == NULL) - return NULL; - - // 5) Write the quantized palette - - RGBQUAD *new_pal = FreeImage_GetPalette(new_dib); - - for (int j = 0; j < netsize; j++) { - new_pal[j].rgbBlue = (BYTE)network[j][0]; - new_pal[j].rgbGreen = (BYTE)network[j][1]; - new_pal[j].rgbRed = (BYTE)network[j][2]; - } - - inxbuild(); - - // 6) Write output image using inxsearch(b,g,r) - - for (WORD rows = 0; rows < height; rows++) { - BYTE *new_bits = FreeImage_GetScanLine(new_dib, rows); - BYTE *bits = FreeImage_GetScanLine(dib, rows); - - for (WORD cols = 0; cols < FreeImage_GetWidth(dib); cols++) { - new_bits[cols] = (BYTE)inxsearch(bits[0], bits[1], bits[2]); - - bits += 3; - } - } - - return (FIBITMAP*) new_dib; -} diff --git a/freeimage241/Source/FreeImage/Plugin.cpp b/freeimage241/Source/FreeImage/Plugin.cpp deleted file mode 100644 index 02cb47c..0000000 --- a/freeimage241/Source/FreeImage/Plugin.cpp +++ /dev/null @@ -1,713 +0,0 @@ -// ===================================================================== -// FreeImage Plugin Interface -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Rui Lopes (ruiglopes@yahoo.com) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ================== =================================================== - -#ifdef WIN32 -#pragma warning (disable : 4786) -#include -#else -#include -#endif - -#include -#include -#include -#include -#include - -#include "FreeImage.h" -#include "FreeImageIO.h" -#include "Plugin.h" - -// ===================================================================== - -using namespace std; - -// ===================================================================== -// Plugin search list -// ===================================================================== - -const char * -s_search_list[] = { - "", - "plugins\\", -}; - -static int s_search_list_size = sizeof(s_search_list) / sizeof(char *); - -// ===================================================================== -// Reimplementation of stricmp (it is not supported on some systems) -// ===================================================================== - -int -FreeImage_stricmp(const char *s1, const char *s2) { - int c1, c2; - - do { - c1 = tolower(*s1++); - c2 = tolower(*s2++); - } while (c1 && c1 == c2); - - return c1 - c2; -} - -// ===================================================================== -// Declaration of the FreeImage function pointer structure -// ===================================================================== - -static FreeImage s_freeimage; - -// ===================================================================== -// Plugin Node -// ===================================================================== - -FI_STRUCT (PluginNode) { - int m_id; - void *m_instance; - Plugin *m_plugin; - PluginNode *m_next; - BOOL m_enabled; - - const char *m_format; - const char *m_description; - const char *m_extension; - const char *m_regexpr; -}; - -// ===================================================================== -// Internal Plugin List -// ===================================================================== - -class PluginList { -public : - PluginList(); - ~PluginList(); - - FREE_IMAGE_FORMAT AddNode(FI_InitProc proc, void *instance = NULL, const char *format = 0, const char *description = 0, const char *extension = 0, const char *regexpr = 0); - PluginNode *FindNodeFromFormat(const char *format); - PluginNode *FindNodeFromMime(const char *mime); - PluginNode *FindNodeFromFIF(int node_id); - - int Size() const; - BOOL IsEmpty() const; - -private : - map m_plugin_map; - int m_node_count; -}; - -// --------------------------------------------------------------------- - -PluginList::PluginList() : -m_plugin_map() { -} - -FREE_IMAGE_FORMAT -PluginList::AddNode(FI_InitProc init_proc, void *instance, const char *format, const char *description, const char *extension, const char *regexpr) { - if (init_proc != NULL) { - PluginNode *node = new PluginNode; - Plugin *plugin = new Plugin; - memset(plugin, 0, sizeof(Plugin)); - - // fill-in the plugin structure - - init_proc(*plugin, m_plugin_map.size()); - - // get the format string (two possible ways) - - const char *the_format = NULL; - - if (format != NULL) - the_format = format; - else if (plugin->format_proc != NULL) - the_format = plugin->format_proc(); - - // add the node if it wasn't there already - - if (the_format != NULL) { - if (FindNodeFromFormat(the_format) == NULL) { - node->m_id = m_plugin_map.size(); - node->m_instance = instance; - node->m_plugin = plugin; - node->m_format = format; - node->m_description = description; - node->m_extension = extension; - node->m_regexpr = regexpr; - node->m_next = NULL; - node->m_enabled = TRUE; - - m_plugin_map[m_plugin_map.size()] = node; - - return (FREE_IMAGE_FORMAT)node->m_id; - } - } - - // something went wrong while allocating the plugin... cleanup - - delete plugin; - delete node; - } - - return FIF_UNKNOWN; -} - -PluginNode * -PluginList::FindNodeFromFormat(const char *format) { - int count = 0; - - for (map::iterator i = m_plugin_map.begin(); i != m_plugin_map.end(); ++i) { - const char *the_format = ((*i).second->m_format != NULL) ? (*i).second->m_format : (*i).second->m_plugin->format_proc(); - - if (strcmp(the_format, format) == 0) - return (*i).second; - - count++; - } - - return NULL; -} - -PluginNode * -PluginList::FindNodeFromMime(const char *mime) { - int count = 0; - - for (map::iterator i = m_plugin_map.begin(); i != m_plugin_map.end(); ++i) { - const char *the_mime = ((*i).second->m_plugin->mime_proc != NULL) ? (*i).second->m_plugin->mime_proc() : ""; - - if (strcmp(the_mime, mime) == 0) - return (*i).second; - - count++; - } - - return NULL; -} - -PluginNode * -PluginList::FindNodeFromFIF(int node_id) { - map::iterator i = m_plugin_map.find(node_id); - - if (i != m_plugin_map.end()) - return (*i).second; - - return NULL; -} - -int -PluginList::Size() const { - return m_plugin_map.size(); -} - -BOOL -PluginList::IsEmpty() const { - return m_plugin_map.empty(); -} - -PluginList::~PluginList() { - for (map::iterator i = m_plugin_map.begin(); i != m_plugin_map.end(); ++i) { -#ifdef WIN32 - if ((*i).second->m_instance != NULL) - FreeLibrary((HINSTANCE)(*i).second->m_instance); -#endif - delete (*i).second->m_plugin; /*CORRECTED*/ - delete ((*i).second); - } -} - -// ===================================================================== -// Plugin System Initialization -// ===================================================================== - -static PluginList *s_plugins = NULL; -static int s_plugin_reference_count = 0; - -// --------------------------------------------------------------------- - -void DLL_CALLCONV -FreeImage_Initialise(BOOL load_local_plugins_only) { - if (s_plugin_reference_count++ == 0) { - // initialize the freeimage function pointer table - - s_freeimage.allocate_proc = FreeImage_Allocate; - s_freeimage.free_proc = FreeImage_Free; - s_freeimage.get_bits_proc = FreeImage_GetBits; - s_freeimage.get_bits_row_col_proc = FreeImage_GetBitsRowCol; - s_freeimage.get_blue_mask_proc = FreeImage_GetBlueMask; - s_freeimage.get_bpp_proc = FreeImage_GetBPP; - s_freeimage.get_color_type_proc = FreeImage_GetColorType; - s_freeimage.get_colors_used_proc = FreeImage_GetColorsUsed; - s_freeimage.get_dib_size_proc = FreeImage_GetDIBSize; - s_freeimage.get_dots_per_meter_x_proc = FreeImage_GetDotsPerMeterX; - s_freeimage.get_dots_per_meter_y_proc = FreeImage_GetDotsPerMeterY; - s_freeimage.get_green_mask_proc = FreeImage_GetGreenMask; - s_freeimage.get_height_proc = FreeImage_GetHeight; - s_freeimage.get_info_header_proc = FreeImage_GetInfoHeader; - s_freeimage.get_info_proc = FreeImage_GetInfo; - s_freeimage.get_line_proc = FreeImage_GetLine; - s_freeimage.get_palette_proc = FreeImage_GetPalette; - s_freeimage.get_pitch_proc = FreeImage_GetPitch; - s_freeimage.get_red_mask_proc = FreeImage_GetRedMask; - s_freeimage.get_scanline_proc = FreeImage_GetScanLine; - s_freeimage.get_transparency_count_proc = FreeImage_GetTransparencyCount; - s_freeimage.get_transparency_table_proc = FreeImage_GetTransparencyTable; - s_freeimage.get_width_proc = FreeImage_GetWidth; - s_freeimage.output_message_proc = FreeImage_OutputMessage; - s_freeimage.set_transparency_table_proc = FreeImage_SetTransparencyTable; - s_freeimage.is_transparent_proc = FreeImage_IsTransparent; - s_freeimage.set_transparent_proc = FreeImage_SetTransparent; - s_freeimage.unload_proc = FreeImage_Unload; - s_freeimage.convert_line1to8_proc = FreeImage_ConvertLine1To8; - s_freeimage.convert_line_4to8_proc = FreeImage_ConvertLine4To8; - s_freeimage.convert_line_16to8_555_proc = FreeImage_ConvertLine16To8_555; - s_freeimage.convert_line_16to8_565_proc = FreeImage_ConvertLine16To8_565; - s_freeimage.convert_line_24to8_proc = FreeImage_ConvertLine24To8; - s_freeimage.convert_line_32to8_proc = FreeImage_ConvertLine32To8; - s_freeimage.convert_line_1to16_555_proc = FreeImage_ConvertLine1To16_555; - s_freeimage.convert_line_4to16_555_proc = FreeImage_ConvertLine4To16_555; - s_freeimage.convert_line_8to16_555_proc = FreeImage_ConvertLine8To16_555; - s_freeimage.convert_line_16_565_to_16_555_proc = FreeImage_ConvertLine16_565_To16_555; - s_freeimage.convert_line_24to16_555_proc = FreeImage_ConvertLine24To16_555; - s_freeimage.convert_line_32to16_555_proc = FreeImage_ConvertLine32To16_555; - s_freeimage.convert_line_1to16_565_proc = FreeImage_ConvertLine1To16_565; - s_freeimage.convert_line_4to16_565_proc = FreeImage_ConvertLine4To16_565; - s_freeimage.convert_line_8to16_565_proc = FreeImage_ConvertLine8To16_565; - s_freeimage.convert_line_16_555_to_16_565_proc = FreeImage_ConvertLine16_555_To16_565; - s_freeimage.convert_line_24to16_565_proc = FreeImage_ConvertLine24To16_565; - s_freeimage.convert_line_32to16_565_proc = FreeImage_ConvertLine32To16_565; - s_freeimage.convert_line_1to24_proc = FreeImage_ConvertLine1To24; - s_freeimage.convert_line_4to24_proc = FreeImage_ConvertLine4To24; - s_freeimage.convert_line_8to24_proc = FreeImage_ConvertLine8To24; - s_freeimage.convert_line_16to24_555_proc = FreeImage_ConvertLine16To24_555; - s_freeimage.convert_line_16to24_565_proc = FreeImage_ConvertLine16To24_565; - s_freeimage.convert_line_32to24_proc = FreeImage_ConvertLine32To24; - s_freeimage.convert_line_1to32_proc = FreeImage_ConvertLine1To32; - s_freeimage.convert_line_4to32_proc = FreeImage_ConvertLine4To32; - s_freeimage.convert_line_8to32_proc = FreeImage_ConvertLine8To32; - s_freeimage.convert_line_16to32_555_proc = FreeImage_ConvertLine16To32_555; - s_freeimage.convert_line_16to32_565_proc = FreeImage_ConvertLine16To32_565; - s_freeimage.convert_line_24to32_proc = FreeImage_ConvertLine24To32; - - // internal plugin initialization - - s_plugins = new PluginList; - - s_plugins->AddNode(InitBMP); -// s_plugins->AddNode(InitICO); - s_plugins->AddNode(InitJPEG); -// s_plugins->AddNode(InitMNG, NULL, "JNG", "JPEG Network Graphics", "jng", ""); -// s_plugins->AddNode(InitKOALA); - s_plugins->AddNode(InitIFF); -// s_plugins->AddNode(InitMNG); -// s_plugins->AddNode(InitPNM, NULL, "PBM", "Portable Bitmap (ASCII)", "pbm", "^P1"); -// s_plugins->AddNode(InitPNM, NULL, "PBMRAW", "Portable Bitmap (RAW)", "pbm", "^P4"); -// s_plugins->AddNode(InitPCD); - s_plugins->AddNode(InitPCX); -// s_plugins->AddNode(InitPNM, NULL, "PGM", "Portable Greymap (ASCII)", "pgm", "^P2"); -// s_plugins->AddNode(InitPNM, NULL, "PGMRAW", "Portable Greymap (RAW)", "pgm", "^P5"); - s_plugins->AddNode(InitPNG); -// s_plugins->AddNode(InitPNM, NULL, "PPM", "Portable Pixelmap (ASCII)", "ppm", "^P3"); -// s_plugins->AddNode(InitPNM, NULL, "PPMRAW", "Portable Pixelmap (RAW)", "ppm", "^P6"); -// s_plugins->AddNode(InitRAS); - s_plugins->AddNode(InitTARGA); -// s_plugins->AddNode(InitTIFF); -// s_plugins->AddNode(InitWBMP); -// s_plugins->AddNode(InitPSD); - - // external plugin initialization - -#ifdef WIN32 - if (!load_local_plugins_only) { - int count = 0; - char buffer[MAX_PATH + 200]; - - while (count < s_search_list_size) { - _finddata_t find_data; - long find_handle; - - strcpy(buffer, s_search_list[count]); - strcat(buffer, "*.fip"); - - if ((find_handle= _findfirst(buffer, &find_data)) != -1L) { - do { - strcpy(buffer, s_search_list[count]); - strncat(buffer, find_data.name, MAX_PATH + 200); - - HINSTANCE instance = LoadLibrary(buffer); - - if (instance != NULL) { - FARPROC proc_address = GetProcAddress(instance, "_Init@8"); - - if (proc_address != NULL) - s_plugins->AddNode((FI_InitProc)proc_address, (void *)instance); - else - FreeLibrary(instance); - } - } while (_findnext(find_handle, &find_data) != -1L); - - _findclose(find_handle); - } - - count++; - } - } -#endif - } -} - -void DLL_CALLCONV -FreeImage_DeInitialise() { - --s_plugin_reference_count; - - if (s_plugin_reference_count == 0) - delete s_plugins; -} - -// ===================================================================== -// Plugin System Load/Save Functions -// ===================================================================== - -FIBITMAP * DLL_CALLCONV -FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags) { - if ((fif >= 0) && (fif < FreeImage_GetFIFCount())) { - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - if (node != NULL) { - if (node->m_enabled) { - FIBITMAP *bitmap = NULL; - - if (node->m_plugin->open_proc != NULL) { - void *data = node->m_plugin->open_proc(*io, handle, TRUE); - - bitmap = node->m_plugin->load_proc(s_freeimage, *io, handle, -1, flags, data); - - if (node->m_plugin->close_proc != NULL) - node->m_plugin->close_proc(*io, handle, data); - - return bitmap; - } else { - return node->m_plugin->load_proc(s_freeimage, *io, handle, -1, flags, NULL); - } - } - } - } - - return NULL; -} - -FIBITMAP * DLL_CALLCONV -FreeImage_Load(FREE_IMAGE_FORMAT fif, const char *filename, int flags) { - FreeImageIO io; - SetDefaultIO(&io); - - FILE *handle = fopen(filename, "rb"); - - if (handle) { - FIBITMAP *bitmap = FreeImage_LoadFromHandle(fif, &io, (fi_handle)handle, flags); - - fclose(handle); - - return bitmap; - } - - return NULL; -} - -BOOL DLL_CALLCONV -FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags) { - if ((fif >= 0) && (fif < FreeImage_GetFIFCount())) { - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - if (node != NULL) { - if (node->m_enabled) { - BOOL result = FALSE; - - if (node->m_plugin->open_proc != NULL) { - void *data = node->m_plugin->open_proc(*io, handle, FALSE); - - result = node->m_plugin->save_proc(s_freeimage, *io, dib, handle, -1, flags, data); - - if (node->m_plugin->close_proc != NULL) - node->m_plugin->close_proc(*io, handle, data); - } else { - result = node->m_plugin->save_proc(s_freeimage, *io, dib, handle, -1, flags, NULL); - } - - return result; - } - } - } - - return NULL; -} - - -BOOL DLL_CALLCONV -FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const char *filename, int flags) { - FreeImageIO io; - SetDefaultIO(&io); - - FILE *handle = fopen(filename, "wb"); - - if (handle) { - BOOL success = FreeImage_SaveToHandle(fif, dib, &io, (fi_handle)handle, flags); - - fclose(handle); - - return success; - } - - return FALSE; -} - -// ===================================================================== -// Plugin Creation / Enabling Functions -// ===================================================================== - -FREE_IMAGE_FORMAT DLL_CALLCONV -FreeImage_RegisterLocalPlugin(FI_InitProc proc_address, const char *format, const char *description, const char *extension, const char *regexpr) { - return s_plugins->AddNode(proc_address, NULL, format, description, extension, regexpr); -} - -FREE_IMAGE_FORMAT DLL_CALLCONV -FreeImage_RegisterExternalPlugin(const char *path, const char *format, const char *description, const char *extension, const char *regexpr) { - if (path != NULL) { - HINSTANCE instance = LoadLibrary(path); - - if (instance != NULL) { - FARPROC proc_address = GetProcAddress(instance, "_Init@8"); - - FREE_IMAGE_FORMAT result = s_plugins->AddNode((FI_InitProc)proc_address, (void *)instance, format, description, extension, regexpr); - - if (result == FIF_UNKNOWN) - FreeLibrary(instance); - - return result; - } - } - - return FIF_UNKNOWN; -} - -int DLL_CALLCONV -FreeImage_SetPluginEnabled(FREE_IMAGE_FORMAT fif, BOOL enable) { - if (s_plugins != NULL) { - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - if (node != NULL) { - BOOL previous_state = node->m_enabled; - - node->m_enabled = enable; - - return previous_state; - } - } - - return -1; -} - -int DLL_CALLCONV -FreeImage_IsPluginEnabled(FREE_IMAGE_FORMAT fif) { - if (s_plugins != NULL) { - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - return (node != NULL) ? node->m_enabled : FALSE; - } - - return -1; -} - -// ===================================================================== -// Plugin Access Functions -// ===================================================================== - -int DLL_CALLCONV -FreeImage_GetFIFCount() { - return (s_plugins != NULL) ? s_plugins->Size() : 0; -} - -FREE_IMAGE_FORMAT DLL_CALLCONV -FreeImage_GetFIFFromFormat(const char *format) { - if (s_plugins != NULL) { - PluginNode *node = s_plugins->FindNodeFromFormat(format); - - return (node != NULL) ? (node->m_enabled) ? (FREE_IMAGE_FORMAT)node->m_id : FIF_UNKNOWN : FIF_UNKNOWN; - } - - return FIF_UNKNOWN; -} - -FREE_IMAGE_FORMAT DLL_CALLCONV -FreeImage_GetFIFFromMime(const char *mime) { - if (s_plugins != NULL) { - PluginNode *node = s_plugins->FindNodeFromMime(mime); - - return (node != NULL) ? (node->m_enabled) ? (FREE_IMAGE_FORMAT)node->m_id : FIF_UNKNOWN : FIF_UNKNOWN; - } - - return FIF_UNKNOWN; -} - -const char * DLL_CALLCONV -FreeImage_GetFormatFromFIF(FREE_IMAGE_FORMAT fif) { - if (s_plugins != NULL) { - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - return (node != NULL) ? (node->m_format != NULL) ? node->m_format : node->m_plugin->format_proc() : NULL; - } - - return NULL; -} - -const char * DLL_CALLCONV -FreeImage_GetFIFExtensionList(FREE_IMAGE_FORMAT fif) { - if (s_plugins != NULL) { - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - return (node != NULL) ? (node->m_extension != NULL) ? node->m_extension : (node->m_plugin->extension_proc != NULL) ? node->m_plugin->extension_proc() : NULL : NULL; - } - - return NULL; -} - -const char * DLL_CALLCONV -FreeImage_GetFIFDescription(FREE_IMAGE_FORMAT fif) { - if (s_plugins != NULL) { - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - return (node != NULL) ? (node->m_description != NULL) ? node->m_description : (node->m_plugin->description_proc != NULL) ? node->m_plugin->description_proc() : NULL : NULL; - } - - return NULL; -} - -const char * DLL_CALLCONV -FreeImage_GetFIFRegExpr(FREE_IMAGE_FORMAT fif) { - if (s_plugins != NULL) { - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - return (node != NULL) ? (node->m_regexpr != NULL) ? node->m_regexpr : (node->m_plugin->regexpr_proc != NULL) ? node->m_plugin->regexpr_proc() : NULL : NULL; - } - - return NULL; -} - -BOOL DLL_CALLCONV -FreeImage_FIFSupportsReading(FREE_IMAGE_FORMAT fif) { - if (s_plugins != NULL) { - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - return (node != NULL) ? (node->m_enabled) ? node->m_plugin->load_proc != NULL : FALSE : FALSE; - } - - return FALSE; -} - -BOOL DLL_CALLCONV -FreeImage_FIFSupportsWriting(FREE_IMAGE_FORMAT fif) { - if (s_plugins != NULL) { - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - return (node != NULL) ? (node->m_enabled) ? node->m_plugin->save_proc != NULL : FALSE : FALSE; - } - - return FALSE; -} - -FREE_IMAGE_FORMAT DLL_CALLCONV -FreeImage_GetFIFFromFilename(const char *filename) { - if (filename != NULL) { - const char *extension; - - // get the proper extension if we received a filename - - char *place = strrchr((char *)filename, '.'); - - if (place != NULL) - extension = ++place; - else - extension = filename; - - // look for the extension in the plugin table - - for (int i = 0; i < FreeImage_GetFIFCount(); ++i) { - // compare the format id with the extension - - if (FreeImage_stricmp(FreeImage_GetFormatFromFIF((FREE_IMAGE_FORMAT)i), extension) == 0) { - if (s_plugins->FindNodeFromFIF(i)->m_enabled) { - return (FREE_IMAGE_FORMAT)i; - } else { - return FIF_UNKNOWN; - } - } else { - // make a copy of the extension list and split it - - char *copy = (char *)malloc(strlen(FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i)) + 1); - memset(copy, 0, strlen(FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i)) + 1); - memcpy(copy, FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i), strlen(FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i))); - - // get the first token - - char *token = strtok(copy, ","); - - while (token != NULL) { - if (FreeImage_stricmp(token, extension) == 0) { - free(copy); - - if (s_plugins->FindNodeFromFIF(i)->m_enabled) { - return (FREE_IMAGE_FORMAT)i; - } else { - return FIF_UNKNOWN; - } - } - - token = strtok(NULL, ","); - } - - // free the copy of the extension list - - free(copy); - } - } - } - - return FIF_UNKNOWN; -} - -BOOL DLL_CALLCONV -FreeImage_Validate(FREE_IMAGE_FORMAT fif, FreeImageIO &io, fi_handle handle) { - if (s_plugins != NULL) { - BOOL validated = FALSE; - - PluginNode *node = s_plugins->FindNodeFromFIF(fif); - - if (node) { - long tell = io.tell_proc(handle); - - validated = (node != NULL) ? (node->m_enabled) ? (node->m_plugin->validate_proc != NULL) ? node->m_plugin->validate_proc(io, handle) : FALSE : FALSE : FALSE; - - io.seek_proc(handle, tell, SEEK_SET); - } - - return validated; - } - - return FALSE; -} diff --git a/freeimage241/Source/FreeImage/PluginBMP.cpp b/freeimage241/Source/FreeImage/PluginBMP.cpp deleted file mode 100644 index 13979f2..0000000 --- a/freeimage241/Source/FreeImage/PluginBMP.cpp +++ /dev/null @@ -1,1031 +0,0 @@ - // ========================================================== -// BMP Loader and Writer -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Markus Loibl (markus.loibl@epost.de) -// - Martin Weber (martweb@gmx.net) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- -// Constants + headers -// ---------------------------------------------------------- - -const RLE_COMMAND = 0; -const RLE_ENDOFLINE = 0; -const RLE_ENDOFBITMAP = 1; -const RLE_DELTA = 2; - -#define BI_RGB 0L -#define BI_RLE8 1L -#define BI_RLE4 2L -#define BI_BITFIELDS 3L - -// ---------------------------------------------------------- - -#ifdef WIN32 -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif - -typedef struct tagBITMAPCOREHEADER { - DWORD bcSize; - WORD bcWidth; - WORD bcHeight; - WORD bcPlanes; - WORD bcBitCnt; -} BITMAPCOREHEADER, *PBITMAPCOREHEADER; - -typedef struct tagBITMAPINFOOS2_1X_HEADER { - DWORD biSize; - WORD biWidth; - WORD biHeight; - WORD biPlanes; - WORD biBitCount; -} BITMAPINFOOS2_1X_HEADER, *PBITMAPINFOOS2_1X_HEADER; - -typedef struct tagBITMAPFILEHEADER { - WORD bfType; - DWORD bfSize; - WORD bfReserved1; - WORD bfReserved2; - DWORD bfOffBits; -} BITMAPFILEHEADER, *PBITMAPFILEHEADER; - -typedef struct tagRGBTRIPLE { - BYTE rgbtBlue; - BYTE rgbtGreen; - BYTE rgbtRed; -} RGBTRIPLE; - -#ifdef WIN32 -#pragma pack(pop) -#else -#pragma pack(4) -#endif - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Internal functions -// ========================================================== - -static FIBITMAP * -LoadWindowsBMP(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int flags, unsigned bitmap_bits_offset) { - FIBITMAP *dib; - - try { - // load the info header - - BITMAPINFOHEADER bih; - - io.read_proc(&bih, sizeof(BITMAPINFOHEADER), 1, handle); - - // keep some general information about the bitmap - - int used_colors = bih.biClrUsed; - int width = bih.biWidth; - int height = bih.biHeight; - int bit_count = bih.biBitCount; - int compression = bih.biCompression; - int pitch = CalculatePitch(CalculateLine(width, bit_count)); - - switch (bit_count) { - case 1 : - case 4 : - case 8 : - { - if ((used_colors <= 0) || (used_colors > CalculateUsedColors(bit_count))) - used_colors = CalculateUsedColors(bit_count); - - // allocate enough memory to hold the bitmap (header, palette, pixels) and read the palette - - dib = freeimage.allocate_proc(width, height, bit_count); - - if (dib == NULL) - throw "DIB allocation failed"; - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - pInfoHeader->biXPelsPerMeter = bih.biXPelsPerMeter; - pInfoHeader->biYPelsPerMeter = bih.biYPelsPerMeter; - - // load the palette - - io.read_proc(freeimage.get_palette_proc(dib), used_colors * sizeof(RGBQUAD), 1, handle); - - // seek to the actual pixel data. - // this is needed because sometimes the palette is larger than the entries it contains predicts - - if (bitmap_bits_offset > (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + (used_colors * sizeof(RGBQUAD)))) - io.seek_proc(handle, bitmap_bits_offset, SEEK_SET); - - // read the pixel data - - switch (compression) { - case BI_RGB : - if (height > 0) { - io.read_proc((void *)freeimage.get_bits_proc(dib), height * pitch, 1, handle); - } else { - for (int c = 0; c < abs(height); ++c) { - io.read_proc((void *)freeimage.get_scanline_proc(dib, height - c - 1), pitch, 1, handle); - } - } - - return dib; - - case BI_RLE4 : - { - BYTE status_byte = 0; - BYTE second_byte = 0; - int scanline = 0; - int bits = 0; - BOOL low_nibble = FALSE; - - for (;;) { - io.read_proc(&status_byte, sizeof(BYTE), 1, handle); - - switch (status_byte) { - case RLE_COMMAND : - io.read_proc(&status_byte, sizeof(BYTE), 1, handle); - - switch (status_byte) { - case RLE_ENDOFLINE : - bits = 0; - scanline++; - low_nibble = FALSE; - break; - - case RLE_ENDOFBITMAP : - return (FIBITMAP *)dib; - - case RLE_DELTA : - { - // read the delta values - - BYTE delta_x; - BYTE delta_y; - - io.read_proc(&delta_x, sizeof(BYTE), 1, handle); - io.read_proc(&delta_y, sizeof(BYTE), 1, handle); - - // apply them - - bits += delta_x / 2; - scanline += delta_y; - break; - } - - default : - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - BYTE *sline = freeimage.get_scanline_proc(dib, scanline); - - for (int i = 0; i < status_byte; i++) { - if (low_nibble) { - *(sline + bits) |= LOWNIBBLE(second_byte); - - if (i != status_byte - 1) - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - bits++; - } else { - *(sline + bits) |= HINIBBLE(second_byte); - } - - low_nibble = !low_nibble; - } - - if (((status_byte / 2) & 1 )== 1) - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - break; - }; - - break; - - default : - { - BYTE *sline = freeimage.get_scanline_proc(dib, scanline); - - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - for (unsigned i = 0; i < status_byte; i++) { - if (low_nibble) { - *(sline + bits) |= LOWNIBBLE(second_byte); - - bits++; - } else { - *(sline + bits) |= HINIBBLE(second_byte); - } - - low_nibble = !low_nibble; - } - } - - break; - }; - } - - break; - } - - case BI_RLE8 : - { - BYTE status_byte = 0; - BYTE second_byte = 0; - int scanline = 0; - int bits = 0; - - for (;;) { - io.read_proc(&status_byte, sizeof(BYTE), 1, handle); - - switch (status_byte) { - case RLE_COMMAND : - io.read_proc(&status_byte, sizeof(BYTE), 1, handle); - - switch (status_byte) { - case RLE_ENDOFLINE : - bits = 0; - scanline++; - break; - - case RLE_ENDOFBITMAP : - return (FIBITMAP *)dib; - - case RLE_DELTA : - { - // read the delta values - - BYTE delta_x; - BYTE delta_y; - - io.read_proc(&delta_x, sizeof(BYTE), 1, handle); - io.read_proc(&delta_y, sizeof(BYTE), 1, handle); - - // apply them - - bits += delta_x; - scanline += delta_y; - break; - } - - default : - io.read_proc((void *)(freeimage.get_scanline_proc(dib, scanline) + bits), sizeof(BYTE) * status_byte, 1, handle); - - // align run length to even number of bytes - - if ((status_byte & 1) == 1) - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - bits += status_byte; - - break; - }; - - break; - - default : - BYTE *sline = freeimage.get_scanline_proc(dib, scanline); - - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - for (unsigned i = 0; i < status_byte; i++) { - *(sline + bits) = second_byte; - - bits++; - } - - break; - }; - } - - break; - } - - default : - throw "compression type not supported"; - } - - break; - } - - case 16 : - { - if (bih.biCompression == BI_BITFIELDS) { - DWORD bitfields[3]; - - io.read_proc(bitfields, 3 * sizeof(DWORD), 1, handle); - - dib = freeimage.allocate_proc(width, height, bit_count, bitfields[2], bitfields[1], bitfields[0]); - } else { - dib = freeimage.allocate_proc(width, height, bit_count, 0x1F, 0x3E0, 0x7C00); - } - - if (dib == NULL) - throw "DIB allocation failed"; - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - pInfoHeader->biXPelsPerMeter = bih.biXPelsPerMeter; - pInfoHeader->biYPelsPerMeter = bih.biYPelsPerMeter; - - io.read_proc(freeimage.get_bits_proc(dib), height * pitch, 1, handle); - - return dib; - } - - case 24 : - case 32 : - { - if (bih.biCompression == BI_BITFIELDS) { - throw "bitfields in 32-bit BMPs are currently unsupported"; - } else { - dib = freeimage.allocate_proc(width, height, bit_count, 0xFF, 0xFF00, 0xFF0000); - - if (dib == NULL) - throw "DIB allocation failed"; - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - pInfoHeader->biXPelsPerMeter = bih.biXPelsPerMeter; - pInfoHeader->biYPelsPerMeter = bih.biYPelsPerMeter; - - // Skip over the optional palette - // A 24 or 32 bit DIB may contain a palette for faster color reduction - - if (pInfoHeader->biClrUsed > 0) - io.seek_proc(handle, pInfoHeader->biClrUsed * sizeof(RGBQUAD), SEEK_CUR); - - // read in the bitmap bits - - io.read_proc(freeimage.get_bits_proc(dib), height * pitch, 1, handle); - - // check if the bitmap contains transparency, if so enable it in the header - - freeimage.set_transparent_proc(dib, (freeimage.get_color_type_proc(dib) == FIC_RGBALPHA)); - - return dib; - } - } - } - } catch(const char *message) { - freeimage.output_message_proc(s_format_id, message); - } - - return NULL; -} - -static FIBITMAP * -LoadOS22XBMP(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int flags, unsigned bitmap_bits_offset) { - FIBITMAP *dib = NULL; - - try { - // load the info header - - BITMAPINFOHEADER bih; - - io.read_proc(&bih, sizeof(BITMAPINFOHEADER), 1, handle); - - // keep some general information about the bitmap - - int used_colors = bih.biClrUsed; - int width = bih.biWidth; - int height = bih.biHeight; - int bit_count = bih.biBitCount; - int compression = bih.biCompression; - int pitch = CalculatePitch(CalculateLine(width, bit_count)); - - switch (bit_count) { - case 1 : - case 4 : - case 8 : - { - if ((used_colors <= 0) || (used_colors > CalculateUsedColors(bit_count))) - used_colors = CalculateUsedColors(bit_count); - - // allocate enough memory to hold the bitmap (header, palette, pixels) and read the palette - - dib = freeimage.allocate_proc(width, height, bit_count); - - if (dib == NULL) - throw "DIB allocation failed"; - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - pInfoHeader->biXPelsPerMeter = bih.biXPelsPerMeter; - pInfoHeader->biYPelsPerMeter = bih.biYPelsPerMeter; - - // load the palette - - io.seek_proc(handle, sizeof(BITMAPFILEHEADER) + bih.biSize, SEEK_SET); - - RGBQUAD *pal = freeimage.get_palette_proc(dib); - - for (int count = 0; count < used_colors; count++) { - RGBTRIPLE triple; - - io.read_proc(&triple, sizeof(RGBTRIPLE), 1, handle); - - pal[count].rgbRed = triple.rgbtRed; - pal[count].rgbGreen = triple.rgbtGreen; - pal[count].rgbBlue = triple.rgbtBlue; - } - - // seek to the actual pixel data. - // this is needed because sometimes the palette is larger than the entries it contains predicts - - if (bitmap_bits_offset > (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + (used_colors * 3))) - io.seek_proc(handle, bitmap_bits_offset, SEEK_SET); - - // read the pixel data - - switch (compression) { - case BI_RGB : - if (height > 0) { - io.read_proc((void *)freeimage.get_bits_proc(dib), height * pitch, 1, handle); - } else { - for (int c = 0; c < abs(height); ++c) { - io.read_proc((void *)freeimage.get_scanline_proc(dib, height - c - 1), pitch, 1, handle); - } - } - - return dib; - - case BI_RLE4 : - { - BYTE status_byte = 0; - BYTE second_byte = 0; - int scanline = 0; - int bits = 0; - BOOL low_nibble = FALSE; - - for (;;) { - io.read_proc(&status_byte, sizeof(BYTE), 1, handle); - - switch (status_byte) { - case RLE_COMMAND : - io.read_proc(&status_byte, sizeof(BYTE), 1, handle); - - switch (status_byte) { - case RLE_ENDOFLINE : - bits = 0; - scanline++; - low_nibble = FALSE; - break; - - case RLE_ENDOFBITMAP : - return (FIBITMAP *)dib; - - case RLE_DELTA : - { - // read the delta values - - BYTE delta_x; - BYTE delta_y; - - io.read_proc(&delta_x, sizeof(BYTE), 1, handle); - io.read_proc(&delta_y, sizeof(BYTE), 1, handle); - - // apply them - - bits += delta_x / 2; - scanline += delta_y; - break; - } - - default : - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - BYTE *sline = freeimage.get_scanline_proc(dib, scanline); - - for (int i = 0; i < status_byte; i++) { - if (low_nibble) { - *(sline + bits) |= LOWNIBBLE(second_byte); - - if (i != status_byte - 1) - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - bits++; - } else { - *(sline + bits) |= HINIBBLE(second_byte); - } - - low_nibble = !low_nibble; - } - - if (((status_byte / 2) & 1 ) == 1) - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - break; - }; - - break; - - default : - { - BYTE *sline = freeimage.get_scanline_proc(dib, scanline); - - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - for (unsigned i = 0; i < status_byte; i++) { - if (low_nibble) { - *(sline + bits) |= LOWNIBBLE(second_byte); - - bits++; - } else { - *(sline + bits) |= HINIBBLE(second_byte); - } - - low_nibble = !low_nibble; - } - } - - break; - }; - } - - break; - } - - case BI_RLE8 : - { - BYTE status_byte = 0; - BYTE second_byte = 0; - int scanline = 0; - int bits = 0; - - for (;;) { - io.read_proc(&status_byte, sizeof(BYTE), 1, handle); - - switch (status_byte) { - case RLE_COMMAND : - io.read_proc(&status_byte, sizeof(BYTE), 1, handle); - - switch (status_byte) { - case RLE_ENDOFLINE : - bits = 0; - scanline++; - break; - - case RLE_ENDOFBITMAP : - return (FIBITMAP *)dib; - - case RLE_DELTA : - { - // read the delta values - - BYTE delta_x; - BYTE delta_y; - - io.read_proc(&delta_x, sizeof(BYTE), 1, handle); - io.read_proc(&delta_y, sizeof(BYTE), 1, handle); - - // apply them - - bits += delta_x; - scanline += delta_y; - break; - } - - default : - io.read_proc((void *)(freeimage.get_scanline_proc(dib, scanline) + bits), sizeof(BYTE) * status_byte, 1, handle); - - // align run length to even number of bytes - - if (status_byte & 1 == 1) - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - bits += status_byte; - - break; - }; - - break; - - default : - BYTE *sline = freeimage.get_scanline_proc(dib, scanline); - - io.read_proc(&second_byte, sizeof(BYTE), 1, handle); - - for (unsigned i = 0; i < status_byte; i++) { - *(sline + bits) = second_byte; - - bits++; - } - - break; - }; - } - - break; - } - - default : - throw "compression type not supported"; - } - - break; - } - - case 16 : - { - if (bih.biCompression == 3) { - DWORD bitfields[3]; - - io.read_proc(bitfields, 3 * sizeof(DWORD), 1, handle); - - dib = freeimage.allocate_proc(width, height, bit_count, bitfields[2], bitfields[1], bitfields[0]); - } else { - dib = freeimage.allocate_proc(width, height, bit_count, 0x1F, 0x3E0, 0x7C00); - } - - if (dib == NULL) - throw "DIB allocation failed"; - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - pInfoHeader->biXPelsPerMeter = bih.biXPelsPerMeter; - pInfoHeader->biYPelsPerMeter = bih.biYPelsPerMeter; - - if (bitmap_bits_offset > (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + (used_colors * 3))) - io.seek_proc(handle, bitmap_bits_offset, SEEK_SET); - - io.read_proc(freeimage.get_bits_proc(dib), height * pitch, 1, handle); - - return dib; - } - - case 24 : - case 32 : - { - dib = freeimage.allocate_proc(width, height, bit_count, 0xFF, 0xFF00, 0xFF0000); - - if (dib == NULL) - throw "DIB allocation failed"; - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - pInfoHeader->biXPelsPerMeter = bih.biXPelsPerMeter; - pInfoHeader->biYPelsPerMeter = bih.biYPelsPerMeter; - - // Skip over the optional palette - // A 24 or 32 bit DIB may contain a palette for faster color reduction - - if (bitmap_bits_offset > (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + (used_colors * 3))) - io.seek_proc(handle, bitmap_bits_offset, SEEK_SET); - - // read in the bitmap bits - - io.read_proc(freeimage.get_bits_proc(dib), height * pitch, 1, handle); - - // check if the bitmap contains transparency, if so enable it in the header - - if (freeimage.get_color_type_proc(dib) == FIC_RGBALPHA) - freeimage.set_transparent_proc(dib, TRUE); - else - freeimage.set_transparent_proc(dib, FALSE); - - return dib; - } - } - } catch(const char *message) { - freeimage.output_message_proc(s_format_id, message); - } - - return NULL; -} - -static FIBITMAP * -LoadOS21XBMP(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int flags, unsigned bitmap_bits_offset) { - FIBITMAP *dib = NULL; - - try { - BITMAPINFOOS2_1X_HEADER bios2_1x; - - io.read_proc(&bios2_1x, sizeof(BITMAPINFOOS2_1X_HEADER), 1, handle); - - // keep some general information about the bitmap - - int used_colors = 0; - int width = bios2_1x.biWidth; - int height = bios2_1x.biHeight; - int bit_count = bios2_1x.biBitCount; - int compression = 0; - int pitch = CalculatePitch(CalculateLine(width, bit_count)); - - switch (bit_count) { - case 1 : - case 4 : - case 8 : - { - used_colors = CalculateUsedColors(bit_count); - - // allocate enough memory to hold the bitmap (header, palette, pixels) and read the palette - - dib = freeimage.allocate_proc(width, height, bit_count); - - if (dib == NULL) - throw "DIB allocation failed"; - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - pInfoHeader->biXPelsPerMeter = 0; - pInfoHeader->biYPelsPerMeter = 0; - - // load the palette - - RGBQUAD *pal = freeimage.get_palette_proc(dib); - - for (int count = 0; count < used_colors; count++) { - RGBTRIPLE triple; - - io.read_proc(&triple, sizeof(RGBTRIPLE), 1, handle); - - pal[count].rgbRed = triple.rgbtRed; - pal[count].rgbGreen = triple.rgbtGreen; - pal[count].rgbBlue = triple.rgbtBlue; - } - - // Skip over the optional palette - // A 24 or 32 bit DIB may contain a palette for faster color reduction - - io.seek_proc(handle, bitmap_bits_offset, SEEK_SET); - - // read the pixel data - - if (height > 0) { - io.read_proc((void *)freeimage.get_bits_proc(dib), height * pitch, 1, handle); - } else { - for (int c = 0; c < abs(height); ++c) { - io.read_proc((void *)freeimage.get_scanline_proc(dib, height - c - 1), pitch, 1, handle); - } - } - - return dib; - } - - case 16 : - { - dib = freeimage.allocate_proc(width, height, bit_count, 0x1F, 0x3E0, 0x7C00); - - if (dib == NULL) - throw "DIB allocation failed"; - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - pInfoHeader->biXPelsPerMeter = 0; - pInfoHeader->biYPelsPerMeter = 0; - - io.read_proc(freeimage.get_bits_proc(dib), height * pitch, 1, handle); - - return dib; - } - - case 24 : - case 32 : - { - dib = freeimage.allocate_proc(width, height, bit_count, 0xFF, 0xFF00, 0xFF0000); - - if (dib == NULL) - throw "DIB allocation failed"; - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - pInfoHeader->biXPelsPerMeter = 0; - pInfoHeader->biYPelsPerMeter = 0; - - // Skip over the optional palette - // A 24 or 32 bit DIB may contain a palette for faster color reduction - - io.read_proc(freeimage.get_bits_proc(dib), height * pitch, 1, handle); - - // check if the bitmap contains transparency, if so enable it in the header - - freeimage.set_transparent_proc(dib, (freeimage.get_color_type_proc(dib) == FIC_RGBALPHA)); - - return dib; - } - } - } catch(const char *message) { - freeimage.output_message_proc(s_format_id, message); - } - - return NULL; -} - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "BMP"; -} - -static const char * DLL_CALLCONV -Description() { - return "Windows or OS/2 Bitmap"; -} - -static const char * DLL_CALLCONV -Extension() { - return "bmp"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return "^BM"; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - BYTE bmp_signature1[] = { 0x42, 0x4D }; - BYTE bmp_signature2[] = { 0x42, 0x41 }; - BYTE signature[2]; - - int items_read = io.read_proc(signature, 1, sizeof(bmp_signature1), handle); - - if (memcmp(bmp_signature1, signature, sizeof(bmp_signature1)) == 0) - return TRUE; - - if (memcmp(bmp_signature2, signature, sizeof(bmp_signature2)) == 0) - return TRUE; - - return FALSE; -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - if (handle != NULL) { - BITMAPFILEHEADER bitmapfileheader; - DWORD type = 0; - WORD magic; - - // we use this offset value to make seemingly absolute seeks relative in the file - - long offset_in_file = io.tell_proc(handle); - - // read the magic - - io.read_proc(&magic, sizeof(WORD), 1, handle); - - // compare the magic with the number we know - - while (memcmp(&magic, "BA", 2) == 0) { - io.read_proc(&bitmapfileheader.bfSize, sizeof(DWORD), 1, handle); - io.read_proc(&bitmapfileheader.bfReserved1, sizeof(WORD), 1, handle); - io.read_proc(&bitmapfileheader.bfReserved2, sizeof(WORD), 1, handle); - io.read_proc(&bitmapfileheader.bfOffBits, sizeof(DWORD), 1, handle); - io.read_proc(&magic, sizeof(WORD), 1, handle); - } - - // read the fileheader - - io.seek_proc(handle, 0 - sizeof(WORD), SEEK_CUR); - io.read_proc(&bitmapfileheader, sizeof(BITMAPFILEHEADER), 1, handle); - - // read the first byte of the infoheader - - io.read_proc(&type, sizeof(DWORD), 1, handle); - io.seek_proc(handle, 0 - sizeof(DWORD), SEEK_CUR); - - // call the appropriate load function for the found bitmap type - - if (type == 40) - return LoadWindowsBMP(freeimage, io, handle, flags, offset_in_file + bitmapfileheader.bfOffBits); - - if (type == 12) - return LoadOS21XBMP(freeimage, io, handle, flags, offset_in_file + bitmapfileheader.bfOffBits); - - if (type <= 64) - return LoadOS22XBMP(freeimage, io, handle, flags, offset_in_file + bitmapfileheader.bfOffBits); - } - - return NULL; -} - -// ---------------------------------------------------------- - -static BOOL DLL_CALLCONV -Save(FreeImage &freeimage, FreeImageIO &io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - if ((dib != NULL) && (handle != NULL)) { - bool bit_fields = (freeimage.get_bpp_proc(dib) == 16); - - // write the file header - - BITMAPFILEHEADER bitmapfileheader; - bitmapfileheader.bfType = 0x4D42; - bitmapfileheader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + freeimage.get_height_proc(dib) * freeimage.get_pitch_proc(dib); - bitmapfileheader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + freeimage.get_colors_used_proc(dib) * sizeof(RGBQUAD); - bitmapfileheader.bfReserved1 = 0; - bitmapfileheader.bfReserved2 = 0; - - if (bit_fields) { - bitmapfileheader.bfSize += 3 * sizeof(DWORD); - bitmapfileheader.bfOffBits += 3 * sizeof(DWORD); - } - - if (io.write_proc(&bitmapfileheader, sizeof(BITMAPFILEHEADER), 1, handle) != 1) - return FALSE; - - // write the info header - - BITMAPINFOHEADER bih = *freeimage.get_info_header_proc(dib); - - bih.biCompression = (bit_fields) ? 3 : 0; - bih.biBitCount = ((freeimage.get_bpp_proc(dib) == 32) && (!freeimage.is_transparent_proc(dib))) ? 24 : bih.biBitCount; - - if (io.write_proc(&bih, sizeof(BITMAPINFOHEADER), 1, handle) != 1) { - return FALSE; - } - - // write the bit fields when we are dealing with a 16 bit BMP - - if (bit_fields) { - DWORD d; - - d = freeimage.get_blue_mask_proc(dib); - - if (io.write_proc(&d, sizeof(DWORD), 1, handle) != 1) - return FALSE; - - d = freeimage.get_green_mask_proc(dib); - - if (io.write_proc(&d, sizeof(DWORD), 1, handle) != 1) - return FALSE; - - d = freeimage.get_red_mask_proc(dib); - - if (io.write_proc(&d, sizeof(DWORD), 1, handle) != 1) - return FALSE; - } - - // write the palette - - if (freeimage.get_palette_proc(dib) != NULL) - if (io.write_proc(freeimage.get_palette_proc(dib), sizeof(RGBQUAD) * freeimage.get_colors_used_proc(dib), 1, handle) != 1) - return FALSE; - - // write the bitmap data - - if ((freeimage.get_bpp_proc(dib) == 32) && (!freeimage.is_transparent_proc(dib))) { - int pitch = CalculatePitch(CalculateLine(freeimage.get_width_proc(dib), 24)); - - BYTE *buffer = (BYTE *)malloc(pitch); - - for (unsigned i = 0; i < freeimage.get_height_proc(dib); ++i) { - freeimage.convert_line_32to24_proc(buffer, freeimage.get_scanline_proc(dib, i), freeimage.get_width_proc(dib)); - - if (io.write_proc(buffer, pitch, 1, handle) != 1) { - free(buffer); - return FALSE; - } - } - - free(buffer); - } else { - if (io.write_proc(freeimage.get_bits_proc(dib), freeimage.get_height_proc(dib) * freeimage.get_pitch_proc(dib), 1, handle) != 1) { - return FALSE; - } - } - - return TRUE; - } else { - return FALSE; - } -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitBMP(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; - plugin.save_proc = 0; //Save; - plugin.validate_proc = Validate; -} diff --git a/freeimage241/Source/FreeImage/PluginICO.cpp b/freeimage241/Source/FreeImage/PluginICO.cpp deleted file mode 100644 index 2084a1e..0000000 --- a/freeimage241/Source/FreeImage/PluginICO.cpp +++ /dev/null @@ -1,217 +0,0 @@ -// ========================================================== -// ICO Loader -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- -// Constants + headers -// ---------------------------------------------------------- - -#ifdef WIN32 -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif - -typedef struct tagIconDirectoryEntry { - BYTE bWidth; - BYTE bHeight; - BYTE bColorCount; - BYTE bReserved; - WORD wPlanes; - WORD wBitCount; - DWORD dwBytesInRes; - DWORD dwImageOffset; -} ICONDIRENTRY; - -typedef struct tagIconDir { - WORD idReserved; - WORD idType; - WORD idCount; -} ICONHEADER; - -#ifdef WIN32 -#pragma pack(pop) -#else -#pragma pack(4) -#endif - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "ICO"; -} - -static const char * DLL_CALLCONV -Description() { - return "Windows Icon"; -} - -static const char * DLL_CALLCONV -Extension() { - return "ico"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - ICONHEADER icon_header; - - long read = io.read_proc(&icon_header, 1, sizeof(ICONHEADER), handle); - - return ((icon_header.idReserved == 0) && (icon_header.idType == 1)); -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - if (page == -1) - page = 0; - - if (handle != NULL) { - FIBITMAP *dib; - - // we use this offset value to make seemingly absolute seeks relative in the file - - long start_of_file = io.tell_proc(handle); - - // read the icon header - - ICONHEADER icon_header; - - io.read_proc(&icon_header, sizeof(ICONHEADER), 1, handle); - - if ((icon_header.idReserved == 0) && (icon_header.idType == 1)) { - // load the icon descriptions - - ICONDIRENTRY *icon_list = (ICONDIRENTRY *)malloc(icon_header.idCount * sizeof(ICONDIRENTRY)); - - io.read_proc(icon_list, icon_header.idCount * sizeof(ICONDIRENTRY), 1, handle); - - // load the specified icon - - if (page < icon_header.idCount) { - // seek to the start of the bitmap data for the icon - - io.seek_proc(handle, start_of_file, SEEK_SET); - io.seek_proc(handle, icon_list[(int)flags].dwImageOffset, SEEK_CUR); - - // load the BITMAPINFOHEADER - - BITMAPINFOHEADER header; - io.read_proc(&header, sizeof(BITMAPINFOHEADER), 1, handle); - - // allocate the bitmap - - int width = header.biWidth; - int height = header.biHeight / 2; // height == xor + and mask - int bit_count = header.biBitCount; - int line = CalculateLine(width, bit_count); - int pitch = CalculatePitch(line); - - // allocate memory for one icon - - dib = freeimage.allocate_proc(width, height, bit_count); - - if (dib == NULL) { - free(icon_list); - - return NULL; - } - - // black and white cursors look much better on white - - if (icon_header.idType == 2) - if (bit_count == 1) - memset(FreeImage_GetBits(dib), 255, pitch * height); - - // read the palette data - - io.read_proc(freeimage.get_palette_proc(dib), CalculateUsedColors(bit_count) * sizeof(RGBQUAD), 1, handle); - - // apply the AND and XOR masks - - BYTE *xor_mask = (BYTE *)malloc(pitch * height); - BYTE *and_mask = (BYTE *)malloc(pitch * height); - BYTE *copy_xor_mask = xor_mask; - BYTE *copy_and_mask = and_mask; - - io.read_proc(xor_mask, pitch * height, 1, handle); - io.read_proc(and_mask, pitch * height, 1, handle); - - for (int row = 0; row < height; row++) { - for (int column = 0; column < line; column++) { - *(freeimage.get_scanline_proc(dib, row) + column) &= copy_and_mask[column]; - *(freeimage.get_scanline_proc(dib, row) + column) ^= copy_xor_mask[column]; - } - - copy_xor_mask += pitch; - copy_and_mask += pitch; - } - - free(icon_list); - free(and_mask); - free(xor_mask); - - // bitmap has been loaded successfully! - - return (FIBITMAP *)dib; - } - } else { - freeimage.output_message_proc(s_format_id, "file is not an ICO file"); - } - } - - return NULL; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitICO(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; - plugin.validate_proc = Validate; -} diff --git a/freeimage241/Source/FreeImage/PluginIFF.cpp b/freeimage241/Source/FreeImage/PluginIFF.cpp deleted file mode 100644 index 1adf06b..0000000 --- a/freeimage241/Source/FreeImage/PluginIFF.cpp +++ /dev/null @@ -1,318 +0,0 @@ -// ========================================================== -// Deluxe Paint Loader -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Mark Sibly (marksibly@blitzbasic.com) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- -// Internal typedefs and structures -// ---------------------------------------------------------- - -#ifdef WIN32 -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif - -typedef struct { - WORD w, h; /* raster width & height in pixels */ - WORD x, y; /* position for this image */ - BYTE nPlanes; /* # source bitplanes */ - BYTE masking; /* masking technique */ - BYTE compression; /* compression algorithm */ - BYTE pad1; /* UNUSED. For consistency, put 0 here.*/ - WORD transparentColor; /* transparent "color number" */ - BYTE xAspect, yAspect; /* aspect ratio, a rational number x/y */ - WORD pageWidth, pageHeight; /* source "page" size in pixels */ -} BMHD; - -#ifdef WIN32 -#pragma pack(pop) -#else -#pragma pack(4) -#endif - -// ---------------------------------------------------------- - -static BOOL big_endian = TRUE; - -// ---------------------------------------------------------- - -static WORD swapWORD( WORD n ){ - return big_endian ? (n >> 8) | (n << 8) : n; -} - -static DWORD swapDWORD( DWORD n ){ - return big_endian ? (n >> 24) | (n << 24) | ((n >> 8) & 0xff00) | ((n << 8) & 0xff0000) : n; -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "IFF"; -} - -static const char * DLL_CALLCONV -Description() { - return "IFF Interleaved Bitmap"; -} - -static const char * DLL_CALLCONV -Extension() { - return "iff,lbm"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - unsigned type = 0; - - io.read_proc(&type, 4, 1, handle); - - return (swapDWORD(type) == 'FORM'); -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - if (handle != NULL) { - FIBITMAP *dib = 0; - - unsigned type, size; - - io.read_proc(&type, 4, 1, handle); - - if (swapDWORD(type) != 'FORM') - return NULL; - - io.read_proc( &size,4,1,handle ); - - size = swapDWORD(size); - - io.read_proc(&type, 4, 1, handle); - - if ((swapDWORD(type) != 'ILBM') && (swapDWORD(type) != 'PBM ')) - return NULL; - - size -= 4; - - unsigned width, height, planes, depth, comp; - - while (size) { - unsigned ch_type,ch_size; - - io.read_proc(&ch_type, 4, 1, handle); - ch_type = swapDWORD(ch_type); - - io.read_proc(&ch_size,4,1,handle ); - ch_size = swapDWORD(ch_size); - - unsigned ch_end = io.tell_proc(handle) + ch_size; - - if (ch_type == 'BMHD') { - if (dib) - FreeImage_Unload(dib); - - BMHD bmhd; - - io.read_proc(&bmhd, sizeof(bmhd), 1, handle); - - width = swapWORD(bmhd.w); - height = swapWORD(bmhd.h); - planes = bmhd.nPlanes; - comp = bmhd.compression; - - if (planes > 8 && planes != 24) - return NULL; - - depth = planes > 8 ? 24 : 8; - - unsigned mask = planes > 8 ? 0xff : 0; - - dib = freeimage.allocate_proc(width, height, depth, mask << 16, mask << 8, mask); - } else if (ch_type == 'CMAP') { - if (!dib) - return NULL; - - RGBQUAD *pal = freeimage.get_palette_proc(dib); - - for (unsigned k = 0; k < ch_size / 3;++k ){ - io.read_proc(&pal[k].rgbRed, 1, 1, handle ); - io.read_proc(&pal[k].rgbGreen, 1, 1, handle ); - io.read_proc(&pal[k].rgbBlue, 1, 1, handle ); - } - - } else if (ch_type == 'BODY') { - if (!dib) - return NULL; - - if (swapDWORD(type) == 'PBM ') { - // NON INTERLACED (LBM) - - unsigned line = freeimage.get_line_proc(dib) + 1 & ~1; - - for (unsigned i = 0; i < freeimage.get_height_proc(dib); ++i) { - BYTE *bits = freeimage.get_scanline_proc(dib, freeimage.get_height_proc(dib) - i - 1); - - if (comp == 1) { - // use RLE compression - - DWORD number_of_bytes_written = 0; - BYTE rle_count; - BYTE byte; - - while (number_of_bytes_written < line) { - io.read_proc(&rle_count, 1, 1, handle); - - if (rle_count < 128) { - for (int k = 0; k < rle_count + 1; k++) { - io.read_proc(&byte, 1, 1, handle); - - bits[number_of_bytes_written++] += byte; - } - } else if (rle_count > 128) { - io.read_proc(&byte, 1, 1, handle); - - for (int k = 0; k < 257 - rle_count; k++) { - bits[number_of_bytes_written++] += byte; - } - } - } - } else { - // don't use compression - - io.read_proc(bits, line, 1, handle); - } - } - - return dib; - } else { - // INTERLACED (ILBM) - - unsigned pixel_size = depth/8; - unsigned n_width=(width+15)&~15; - unsigned plane_size = n_width/8; - unsigned src_size = plane_size * planes; - unsigned char *src = (unsigned char*)malloc(src_size); - unsigned char *dest = freeimage.get_bits_proc(dib); - - dest += freeimage.get_pitch_proc(dib) * height; - - for (unsigned y = 0; y < height; ++y) { - dest -= freeimage.get_pitch_proc(dib); - - // read all planes in one hit, - // 'coz PSP compresses across planes... - - if (comp) { - for(unsigned x = 0; x < src_size;){ - signed char t; - - io.read_proc(&t, 1, 1, handle); - - if (t >= 0) { - ++t; - - io.read_proc(src + x, t, 1, handle); - - x += t; - } else if( t!=-128 ){ - signed char b; - - io.read_proc( &b,1,1,handle ); - - t =- t +1; - - memset(src + x, b, t); - - x += t; - } - } - } else { - io.read_proc(src, src_size, 1, handle); - } - - // lazy planar->chunky... - - for (unsigned x = 0; x < width; ++x) { - for (unsigned n = 0; n < planes; ++n) { - char bit = src[n * plane_size + (x / 8)] >> ((x^7) & 7); - dest[x * pixel_size + (n / 8)] |= (bit & 1) << (n & 7); - } - } - - if (depth == 24){ - for(unsigned x = 0; x < width; ++x){ - char t = dest[x * 3]; - dest[x * 3] = dest[x * 3 + 2]; - dest[x * 3 + 2] = t; - } - } - } - - free(src); - - return dib; - } - } - - io.seek_proc(handle, ch_end - io.tell_proc(handle), SEEK_CUR); - - size -= ch_size+8; - } - - if (dib) - freeimage.unload_proc(dib); - } - - return 0; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitIFF(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; - plugin.validate_proc = Validate; -} diff --git a/freeimage241/Source/FreeImage/PluginJPEG.cpp b/freeimage241/Source/FreeImage/PluginJPEG.cpp deleted file mode 100644 index 4e39c2b..0000000 --- a/freeimage241/Source/FreeImage/PluginJPEG.cpp +++ /dev/null @@ -1,625 +0,0 @@ -// ========================================================== -// JPEG Loader -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Jan L. Nauta (jln@magentammt.com) -// - Markus Loibl (markus.loibl@epost.de) -// -// Based on code developed by The Independent JPEG Group -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -extern "C" { -#define XMD_H -#undef FAR -#include -#include "../LibJPEG/jpeglib.h" -} - -// ---------------------------------------------------------- - -#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ -#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ - -typedef struct my_error_mgr * my_error_ptr; - -// ---------------------------------------------------------- -// Constants + headers -// ---------------------------------------------------------- - -METHODDEF(void) -jpeg_error_exit (j_common_ptr cinfo) { - (*cinfo->err->output_message)(cinfo); - - jpeg_destroy(cinfo); - - throw FIF_JPEG; -} - -METHODDEF(void) -jpeg_output_message (j_common_ptr cinfo) { - char buffer[JMSG_LENGTH_MAX]; - - (*cinfo->err->format_message)(cinfo, buffer); - - //FreeImage_OutputMessage(FreeImage_GetFIFFromFormat("JPEG"), buffer); -} - -//=========================================================== -/* - * jdatasrc.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains decompression data source routines for the case of - * reading JPEG data from a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * source manager. - * IMPORTANT: we assume that fread() will correctly transcribe an array of - * JOCTETs from 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -#include "../libjpeg/jinclude.h" -#include "../libjpeg/jpeglib.h" -#include "../libjpeg/jerror.h" - -// Expanded data source object for stdio input -------------- - -struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ - - jmp_buf setjmp_buffer; /* for return to caller */ -}; - -// ---------------------------------------------------------- - -typedef struct { - struct jpeg_source_mgr pub; /* public fields */ - - fi_handle infile; /* source stream */ - FreeImageIO *m_io; - - JOCTET * buffer; /* start of buffer */ - boolean start_of_file; /* have we gotten any data yet? */ -} my_source_mgr; - -typedef struct { - struct jpeg_destination_mgr pub; /* public fields */ - - fi_handle outfile; /* destination stream */ - FreeImageIO *m_io; - - JOCTET * buffer; /* start of buffer */ -} my_destination_mgr; - -// ---------------------------------------------------------- - -typedef my_source_mgr * freeimage_src_ptr; -typedef my_destination_mgr * freeimage_dst_ptr; - -// ---------------------------------------------------------- - -METHODDEF(void) -init_source (j_decompress_ptr cinfo) { - freeimage_src_ptr src = (freeimage_src_ptr) cinfo->src; - - /* We reset the empty-input-file flag for each image, - * but we don't clear the input buffer. - * This is correct behavior for reading a series of images from one source. - */ - - src->start_of_file = TRUE; -} - -METHODDEF(void) -init_destination (j_compress_ptr cinfo) { - freeimage_dst_ptr dest = (freeimage_dst_ptr) cinfo->dest; - - dest->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; -} - -// ---------------------------------------------------------- - -/* - * Fill the input buffer --- called whenever buffer is emptied. - * - * In typical applications, this should read fresh data into the buffer - * (ignoring the current state of next_input_byte & bytes_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been reloaded. It is not necessary to - * fill the buffer entirely, only to obtain at least one more byte. - * - * There is no such thing as an EOF return. If the end of the file has been - * reached, the routine has a choice of ERREXIT() or inserting fake data into - * the buffer. In most cases, generating a warning message and inserting a - * fake EOI marker is the best course of action --- this will allow the - * decompressor to output however much of the image is there. However, - * the resulting error message is misleading if the real problem is an empty - * input file, so we handle that case specially. - * - * In applications that need to be able to suspend compression due to input - * not being available yet, a FALSE return indicates that no more data can be - * obtained right now, but more may be forthcoming later. In this situation, - * the decompressor will return to its caller (with an indication of the - * number of scanlines it has read, if any). The application should resume - * decompression after it has loaded more data into the input buffer. Note - * that there are substantial restrictions on the use of suspension --- see - * the documentation. - * - * When suspending, the decompressor will back up to a convenient restart point - * (typically the start of the current MCU). next_input_byte & bytes_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point must be rescanned after resumption, so move it to - * the front of the buffer rather than discarding it. - */ - -METHODDEF(boolean) -fill_input_buffer (j_decompress_ptr cinfo) { - freeimage_src_ptr src = (freeimage_src_ptr) cinfo->src; - - size_t nbytes = src->m_io->read_proc(src->buffer, 1, INPUT_BUF_SIZE, src->infile); - - if (nbytes <= 0) { - if (src->start_of_file) /* Treat empty input file as fatal error */ - ERREXIT(cinfo, JERR_INPUT_EMPTY); - - WARNMS(cinfo, JWRN_JPEG_EOF); - - /* Insert a fake EOI marker */ - - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; - - nbytes = 2; - } - - src->pub.next_input_byte = src->buffer; - src->pub.bytes_in_buffer = nbytes; - src->start_of_file = FALSE; - - return TRUE; -} - -METHODDEF(boolean) -empty_output_buffer (j_compress_ptr cinfo) { - freeimage_dst_ptr dest = (freeimage_dst_ptr) cinfo->dest; - - if (dest->m_io->write_proc(dest->buffer, 1, OUTPUT_BUF_SIZE, dest->outfile) != OUTPUT_BUF_SIZE) - ERREXIT(cinfo, JERR_FILE_WRITE); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; - - return TRUE; -} - -/* - * Skip data --- used to skip over a potentially large amount of - * uninteresting data (such as an APPn marker). - * - * Writers of suspendable-input applications must note that skip_input_data - * is not granted the right to give a suspension return. If the skip extends - * beyond the data currently in the buffer, the buffer can be marked empty so - * that the next read will cause a fill_input_buffer call that can suspend. - * Arranging for additional bytes to be discarded before reloading the input - * buffer is the application writer's problem. - */ - -METHODDEF(void) -skip_input_data (j_decompress_ptr cinfo, long num_bytes) { - freeimage_src_ptr src = (freeimage_src_ptr) cinfo->src; - - /* Just a dumb implementation for now. Could use fseek() except - * it doesn't work on pipes. Not clear that being smart is worth - * any trouble anyway --- large skips are infrequent. - */ - - if (num_bytes > 0) { - while (num_bytes > (long) src->pub.bytes_in_buffer) { - num_bytes -= (long) src->pub.bytes_in_buffer; - - (void) fill_input_buffer(cinfo); - - /* note we assume that fill_input_buffer will never return FALSE, - * so suspension need not be handled. - */ - } - - src->pub.next_input_byte += (size_t) num_bytes; - src->pub.bytes_in_buffer -= (size_t) num_bytes; - } -} - -/* - * Terminate source --- called by jpeg_finish_decompress - * after all data has been read. Often a no-op. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_source (j_decompress_ptr cinfo) { - /* no work necessary here */ -} - -METHODDEF(void) -term_destination (j_compress_ptr cinfo) { - freeimage_dst_ptr dest = (freeimage_dst_ptr) cinfo->dest; - - size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; - - /* Write any data remaining in the buffer */ - - if (datacount > 0) { - if (dest->m_io->write_proc(dest->buffer, 1, datacount, dest->outfile) != datacount) - ERREXIT(cinfo, JERR_FILE_WRITE); - } -} - -/* - * Prepare for input from a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing decompression. - */ - -GLOBAL(void) -jpeg_freeimage_src (j_decompress_ptr cinfo, fi_handle infile, FreeImageIO &io) { - freeimage_src_ptr src; - - // allocate memory for the buffer. is released automatically in the end - - if (cinfo->src == NULL) { - cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_source_mgr)); - - src = (freeimage_src_ptr) cinfo->src; - - src->buffer = (JOCTET *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_PERMANENT, INPUT_BUF_SIZE * SIZEOF(JOCTET)); - } - - // initialize the jpeg pointer struct with pointers to functions - - src = (freeimage_src_ptr) cinfo->src; - src->pub.init_source = init_source; - src->pub.fill_input_buffer = fill_input_buffer; - src->pub.skip_input_data = skip_input_data; - src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ - src->pub.term_source = term_source; - src->infile = infile; - src->m_io = &io; - src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->pub.next_input_byte = NULL; /* until buffer loaded */ -} - -GLOBAL(void) -jpeg_freeimage_dst (j_compress_ptr cinfo, fi_handle outfile, FreeImageIO &io) { - freeimage_dst_ptr dest; - - if (cinfo->dest == NULL) { - cinfo->dest = (struct jpeg_destination_mgr *)(*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_destination_mgr)); - } - - dest = (freeimage_dst_ptr) cinfo->dest; - dest->pub.init_destination = init_destination; - dest->pub.empty_output_buffer = empty_output_buffer; - dest->pub.term_destination = term_destination; - dest->outfile = outfile; - dest->m_io = &io; -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "JPEG"; -} - -static const char * DLL_CALLCONV -Description() { - return "JPEG - JFIF Compliant"; -} - -static const char * DLL_CALLCONV -Extension() { - return "jpg,jif,jpeg"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return "^\377\330\377"; -} - -static const char * DLL_CALLCONV -MimeType() { - return "image/jpeg"; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - BYTE jpeg_signature[] = { 0xFF, 0xD8 }; - BYTE signature[2] = { 0, 0 }; - - io.read_proc(signature, 1, sizeof(jpeg_signature), handle); - - return (memcmp(jpeg_signature, signature, sizeof(jpeg_signature)) == 0); -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - if (handle) { - FIBITMAP *dib = NULL; - - try { - struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; - - // Step 1: allocate and initialize JPEG decompression object - - cinfo.err = jpeg_std_error(&jerr); - - jerr.error_exit = jpeg_error_exit; - jerr.output_message = jpeg_output_message; - - jpeg_create_decompress(&cinfo); - - // Step 2: specify data source (eg, a handle) - - jpeg_freeimage_src(&cinfo, handle, io); - - // Step 3: read handle parameters with jpeg_read_header() - - jpeg_read_header(&cinfo, TRUE); - - // Step 4a: set parameters for decompression - - if ((flags != JPEG_ACCURATE)) { - cinfo.dct_method = JDCT_IFAST; - cinfo.do_fancy_upsampling = FALSE; - } - - // Step 4b: allocate dib and init header - - dib = freeimage.allocate_proc(cinfo.image_width, cinfo.image_height, 8 * cinfo.num_components, 0xFF00, 0xFF, 0xFF0000); - - if (cinfo.num_components == 1) { - RGBQUAD *colors = freeimage.get_palette_proc(dib); - - for (int i = 0; i < 256; i++) { - colors[i].rgbRed = i; - colors[i].rgbGreen = i; - colors[i].rgbBlue = i; - } - } - - // Step 4c: handle metrices - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - - if (cinfo.density_unit == 1) { - // dots/inch - - pInfoHeader->biXPelsPerMeter = (int) (((float)cinfo.X_density) / 0.0254000 + 0.5); - pInfoHeader->biYPelsPerMeter = (int) (((float)cinfo.Y_density) / 0.0254000 + 0.5); - } else if (cinfo.density_unit == 2) { - // dots/cm - - pInfoHeader->biXPelsPerMeter = cinfo.X_density * 100; - pInfoHeader->biYPelsPerMeter = cinfo.Y_density * 100; - } - - // Step 5: start decompressor - - jpeg_start_decompress(&cinfo); - - // Step 6: while (scan lines remain to be read) jpeg_read_scanlines(...); - - while (cinfo.output_scanline < cinfo.output_height) { - JSAMPROW b = freeimage.get_scanline_proc(dib, cinfo.output_height - cinfo.output_scanline - 1); - - jpeg_read_scanlines(&cinfo, &b, 1); - } - - // Step 7: finish decompression - - jpeg_finish_decompress(&cinfo); - - // Step 8: release JPEG decompression object - - jpeg_destroy_decompress(&cinfo); - - return (FIBITMAP *)dib; - } catch (...) { - freeimage.unload_proc(dib); - } - } - - return NULL; -} - -static BOOL DLL_CALLCONV -Save(FreeImage &freeimage, FreeImageIO &io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - if ((dib) && (handle)) { - try { - // Check dib format - - WORD bpp = freeimage.get_bpp_proc(dib); - - if ((bpp == 32) && (freeimage.is_transparent_proc(dib))) - throw "JPEG does not support alpha channels"; - else if (((bpp != 24) && (bpp != 32)) && (!((bpp == 8) && (FreeImage_GetColorType(dib) == FIC_MINISBLACK)))) - throw "only 24-bit highcolor or 8-bit greyscale bitmaps can be saved as JPEG"; - - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - - // Step 1: allocate and initialize JPEG compression object - - cinfo.err = jpeg_std_error(&jerr); - - jerr.error_exit = jpeg_error_exit; - jerr.output_message = jpeg_output_message; - - /* Now we can initialize the JPEG compression object. */ - - jpeg_create_compress(&cinfo); - - /* Step 2: specify data destination (eg, a file) */ - - jpeg_freeimage_dst(&cinfo, handle, io); - - /* Step 3: set parameters for compression */ - - cinfo.image_width = freeimage.get_width_proc(dib); - cinfo.image_height = freeimage.get_height_proc(dib); - - switch(FreeImage_GetColorType(dib)) { - case FIC_MINISBLACK : - cinfo.in_color_space = JCS_GRAYSCALE; - cinfo.input_components = 1; - break; - - default : - cinfo.in_color_space = JCS_RGB; - cinfo.input_components = 3; - break; - } - - jpeg_set_defaults(&cinfo); - - // Set JFIF density parameters from the DIB data - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - cinfo.X_density = (WORD)(pInfoHeader->biXPelsPerMeter / 100.0F + 0.5); - cinfo.Y_density = (WORD)(pInfoHeader->biYPelsPerMeter / 100.0F + 0.5); - cinfo.density_unit = 2; // dots / cm - - // Step 4: set quality - // the first 7 bits are reserved for low level quality settings - // the other bits are high level (i.e. enum-ish) - - int quality; - - if ((flags & JPEG_QUALITYBAD) == JPEG_QUALITYBAD) { - quality = 10; - } else if ((flags & JPEG_QUALITYAVERAGE) == JPEG_QUALITYAVERAGE) { - quality = 25; - } else if ((flags & JPEG_QUALITYNORMAL) == JPEG_QUALITYNORMAL) { - quality = 50; - } else if ((flags & JPEG_QUALITYGOOD) == JPEG_QUALITYGOOD) { - quality = 75; - } else if ((flags & JPEG_QUALITYSUPERB) == JPEG_QUALITYSUPERB) { - quality = 100; - } else { - if ((flags & 0x7F) == 0) { - quality = 75; - } else { - quality = flags & 0x7F; - } - } - - jpeg_set_quality(&cinfo, quality, TRUE); /* limit to baseline-JPEG values */ - - /* Step 5: Start compressor */ - - jpeg_start_compress(&cinfo, TRUE); - - /* Step 6: while (scan lines remain to be written) */ - - if (freeimage.get_bpp_proc(dib) == 32) { - int pitch = CalculatePitch(CalculateLine(freeimage.get_width_proc(dib), 24)); - - JSAMPROW b = (BYTE *)malloc(pitch); - - for (unsigned i = 0; i < freeimage.get_height_proc(dib); ++i) { - freeimage.convert_line_32to24_proc(b, freeimage.get_scanline_proc(dib, freeimage.get_height_proc(dib) - cinfo.next_scanline - 1), freeimage.get_width_proc(dib)); - - jpeg_write_scanlines(&cinfo, &b, 1); - } - - free(b); - } else { - while (cinfo.next_scanline < cinfo.image_height) { - JSAMPROW b = freeimage.get_scanline_proc(dib, freeimage.get_height_proc(dib) - cinfo.next_scanline - 1); - - jpeg_write_scanlines(&cinfo, &b, 1); - } - } - - /* Step 7: Finish compression */ - - jpeg_finish_compress(&cinfo); - - /* Step 8: release JPEG compression object */ - - jpeg_destroy_compress(&cinfo); - - return TRUE; - - } catch (char *text) { - freeimage.output_message_proc(s_format_id, text); - - return FALSE; - } catch (FREE_IMAGE_FORMAT) { - return FALSE; - } - } - - return FALSE; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitJPEG(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; - plugin.save_proc = 0; //Save; - plugin.validate_proc = Validate; - plugin.mime_proc = MimeType; -} diff --git a/freeimage241/Source/FreeImage/PluginKOALA.cpp b/freeimage241/Source/FreeImage/PluginKOALA.cpp deleted file mode 100644 index d369169..0000000 --- a/freeimage241/Source/FreeImage/PluginKOALA.cpp +++ /dev/null @@ -1,218 +0,0 @@ -// ========================================================== -// KOALA Loader -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- -// Constants + headers -// ---------------------------------------------------------- - -#ifdef WIN32 -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif - -typedef struct tagKOALA { - BYTE image[8000]; // pixmap image - BYTE colour1[1000]; // first colourmap (colour 1 and 2) - BYTE colour2[1000]; // second colourmap (colour 3) - BYTE background; // background colour -} koala_t; - -struct colour_t { - int r; - int g; - int b; -}; - -#ifdef WIN32 -#pragma pack(pop) -#else -#pragma pack(4) -#endif - -// ---------------------------------------------------------- - -#define CBM_WIDTH 320 -#define CBM_HEIGHT 200 - -// ---------------------------------------------------------- - -const colour_t c64colours[16] = { - { 0, 0, 0 }, // Black - { 255, 255, 255 }, // White - { 170, 17, 17 }, // Red - { 12, 204, 204 }, // Cyan - { 221, 51, 221 }, // Purple - { 0, 187, 0 }, // Green - { 0, 0, 204 }, // Blue - { 255, 255, 140 }, // Yellow - { 204, 119, 34 }, // Orange - { 136, 68, 0 }, // Brown - { 255, 153, 136 }, // Light red - { 92, 92, 92 }, // Gray 1 - { 170, 170, 170 }, // Gray 2 - { 140, 255, 178 }, // Light green - { 39, 148, 255 }, // Light blue - { 196, 196, 196 } // Gray 3 -}; - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -const char * DLL_CALLCONV -Format() { - return "KOALA"; -} - -const char * DLL_CALLCONV -Description() { - return "C64 Koala Graphics"; -} - -const char * DLL_CALLCONV -Extension() { - return "koa"; -} - -const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - BYTE koala_signature[] = { 0x00, 0x60 }; - BYTE signature[2] = { 0, 0 }; - - int items_read = io.read_proc(signature, 1, sizeof(koala_signature), handle); - - return (memcmp(koala_signature, signature, sizeof(koala_signature)) == 0); -} - -// ---------------------------------------------------------- - -FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - if (handle) { - koala_t image; - - // read the load address - - unsigned char load_address[2]; // highbit, lowbit - io.read_proc(&load_address, 1, 2, handle); - - // if the load address is correct, skip it. otherwise ignore the load address - - if ((load_address[0] != 0x00) || (load_address[1] != 0x60)) { - ((BYTE *)&image)[0] = load_address[0]; - ((BYTE *)&image)[1] = load_address[1]; - - io.read_proc((BYTE *)&image + 2, 1, 10001 - 2, handle); - } else { - io.read_proc(&image, 1, 10001, handle); - } - - // build DIB in memory - - FIBITMAP *dib = freeimage.allocate_proc(CBM_WIDTH, CBM_HEIGHT, 4); - - if (dib) { - // write out the commodore 64 color palette - - RGBQUAD *palette = freeimage.get_palette_proc(dib); - - for (int i = 0; i < 16; i++) { - palette[i].rgbBlue = c64colours[i].b; - palette[i].rgbGreen = c64colours[i].g; - palette[i].rgbRed = c64colours[i].r; - } - - // write out bitmap data - - BYTE pixel_mask[4] = { 0xc0, 0x30, 0x0c, 0x03 }; - BYTE pixel_displacement[4] = { 6, 4, 2, 0 }; - int pixel, index, colourindex; - unsigned char found_color = 0; - - for (int y = 0; y < 200; y++) { - for (int x = 0; x < 160; x++) { - // Get value of pixel at (x,y) - - index = (x / 4) * 8 + (y % 8) + (y / 8) * CBM_WIDTH; - colourindex = (x / 4) + (y / 8) * 40; - pixel = (image.image[index] & pixel_mask[x % 4]) >> pixel_displacement[x % 4]; - - // Retrieve RGB values - - switch (pixel) { - case 0: // Background - found_color = image.background; - break; - - case 1: // Colour 1 - found_color = image.colour1[colourindex] >> 4; - break; - - case 2: // Colour 2 - found_color = image.colour1[colourindex] & 0xf; - break; - - case 3: // Colour 3 - found_color = image.colour2[colourindex] & 0xf; - break; - }; - - *(freeimage.get_scanline_proc(dib, CBM_HEIGHT - y - 1) + x) = (found_color << 4) | found_color; - } - } - - return dib; - } - } - - return NULL; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitKOALA(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; - plugin.validate_proc = Validate; -} diff --git a/freeimage241/Source/FreeImage/PluginMNG.cpp b/freeimage241/Source/FreeImage/PluginMNG.cpp deleted file mode 100644 index 3f8b8d9..0000000 --- a/freeimage241/Source/FreeImage/PluginMNG.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// ========================================================== -// MNG Loader -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -#include -#include - -#include "../LibMNG/libmng.h" - -// ---------------------------------------------------------- -// Constants + headers -// ---------------------------------------------------------- - -typedef struct { - FIBITMAP *bitmap; // pointer to the bitmap data - FreeImage &freeimage; // pointer to the freeimage access functions - FreeImageIO &io; // pointer to the io functions - fi_handle file; // pointer to the file we're decoding -} mngstuff; - -// ---------------------------------------------------------- -// Callbacks for the mng decoder -// ---------------------------------------------------------- - -mng_ptr -mymngalloc(mng_uint32 size) { - return (mng_ptr)calloc(1, size); -} - -void -mymngfree(mng_ptr p, mng_uint32 size) { - free(p); -} - -mng_bool -mymngopenstream(mng_handle mng) { - // since the user is responsible for opening and closing the file, - // we leave the default implementation open - - return MNG_TRUE; -} - -mng_bool -mymngclosestream(mng_handle mng) { - // since the user is responsible for opening and closing the file, - // we leave the default implementation open - - return MNG_TRUE; -} - -mng_bool -mymngreadstream(mng_handle mng, mng_ptr buffer, mng_uint32 size, mng_uint32 *bytesread) { - mngstuff *mymng = (mngstuff *)mng_get_userdata(mng); - - *bytesread = mymng->io.read_proc(buffer, 1, size, mymng->file); - - return MNG_TRUE; -} - -mng_bool -mymngprocessheader(mng_handle mng, mng_uint32 width, mng_uint32 height) { - // allocate a bitmap with the given dimensions - - FreeImage &freeimage = ((mngstuff *)mng_get_userdata(mng))->freeimage; - - ((mngstuff *)mng_get_userdata(mng))->bitmap = freeimage.allocate_proc(width, height, 24, 0xFF, 0xFF00, 0xFF0000); - - // tell the mng decoder about our bit-depth choice - - mng_set_canvasstyle(mng, MNG_CANVAS_BGR8); - - return MNG_TRUE; -} - -mng_ptr -mymnggetcanvasline(mng_handle mng, mng_uint32 line) { - FreeImage &freeimage = ((mngstuff *)mng_get_userdata(mng))->freeimage; - - FIBITMAP *bitmap = ((mngstuff *)mng_get_userdata(mng))->bitmap; - - return freeimage.get_scanline_proc(bitmap, freeimage.get_height_proc(bitmap) - line - 1); -} - -mng_bool -mymngrefresh(mng_handle mng, mng_uint32 x, mng_uint32 y, mng_uint32 w, mng_uint32 h) { - return MNG_TRUE; -} - -mng_uint32 -mymnggetticks(mng_handle mng) { - return 0; -} - -mng_bool -mymngsettimer(mng_handle mng, mng_uint32 msecs) { - return MNG_TRUE; -} - -mng_bool -mymngerror(mng_handle mng, mng_int32 code, mng_int8 severity, mng_chunkid chunktype, mng_uint32 chunkseq, mng_int32 extra1, mng_int32 extra2, mng_pchar text) { - throw (const char *)text; -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "MNG"; -} - -static const char * DLL_CALLCONV -Description() { - return "Multiple Network Graphics"; -} - -static const char * DLL_CALLCONV -Extension() { - return "mng"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -// ---------------------------------------------------------- - -static void * DLL_CALLCONV -Open(FreeImageIO &io, fi_handle handle, BOOL read) { - mngstuff *mymng = (mngstuff *)calloc(1, sizeof(*mymng)); - mymng->io = io; - mymng->file = handle; - - return mymng; -} - -static void DLL_CALLCONV -Close(FreeImageIO &io, fi_handle handle, void *data) { - free((mngstuff *)data); -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - if (handle != NULL) { - try { - // allocate our stream data structure - - mngstuff *mymng = (mngstuff *)data; - - // set up the mng decoder for our stream - - mng_handle mng = mng_initialize(mymng, mymngalloc, mymngfree, MNG_NULL); - - if (mng == MNG_NULL) - throw "could not initialize libmng"; - - // set the callbacks - - mng_setcb_errorproc(mng, mymngerror); - mng_setcb_openstream(mng, mymngopenstream); - mng_setcb_closestream(mng, mymngclosestream); - mng_setcb_readdata(mng, mymngreadstream); - mng_setcb_processheader(mng, mymngprocessheader); - mng_setcb_getcanvasline(mng, mymnggetcanvasline); - mng_setcb_refresh(mng, mymngrefresh); - mng_setcb_gettickcount(mng, mymnggetticks); - mng_setcb_settimer(mng, mymngsettimer); - - // read in the bitmap - - mng_readdisplay(mng); - - // temp store the newly created bitmap - - FIBITMAP *bitmap = mymng->bitmap; - - // cleanup and return the temp stored bitmap - - mng_cleanup(&mng); - - return bitmap; - } catch (const char *message) { - freeimage.output_message_proc(s_format_id, message); - } - } - - return NULL; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitMNG(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.open_proc = Open; - plugin.close_proc = Close; - plugin.load_proc = Load; -} diff --git a/freeimage241/Source/FreeImage/PluginPCD.cpp b/freeimage241/Source/FreeImage/PluginPCD.cpp deleted file mode 100644 index 71042ba..0000000 --- a/freeimage241/Source/FreeImage/PluginPCD.cpp +++ /dev/null @@ -1,207 +0,0 @@ -// ========================================================== -// Kodak PhotoCD Loader -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// Based on pascal code developed by Alex Kwak -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#pragma warning (disable : 4244) - -#include -#include - -#include "FreeImage.h" -#include "Utilities.h" - -// ========================================================== -// Internal functions -// ========================================================== - -inline float -fix(float a) { - return (a < 0) ? 0 : (a > 255) ? 255 : a; -} - -static void -YUV2RGB(int y, int cb, int cr, int &r, int &g, int &b) { - const float c = 256; - - float c11 = 0.0054980 * c; - float c12 = 0.0000001 * c; - float c13 = 0.0051681 * c; - float c21 = 0.0054980 * c; - float c22 = -0.0015446 * c; - float c23 = -0.0026325 * c; - float c31 = 0.0054980 * c; - float c32 = 0.0079533 * c; - float c33 = 0.0000001 * c; - - r = fix(round(c11 * y + c12 * (cb - 156) + c13 * (cr - 137))); - g = fix(round(c21 * y + c22 * (cb - 156) + c23 * (cr - 137))); - b = fix(round(c31 * y + c32 * (cb - 156) + c33 * (cr - 137))); -} - -static BOOL -VerticalOrientation(FreeImageIO &io, fi_handle handle) { - char buffer[128]; - - io.read_proc(buffer, 128, 1, handle); - - return (buffer[72] & 63) == 8; -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "PCD"; -} - -static const char * DLL_CALLCONV -Description() { - return "Kodak PhotoCD"; -} - -static const char * DLL_CALLCONV -Extension() { - return "pcd"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - int width; - int height; - int line; - int pitch; - int bpp = 24; - int scan_line_add = 1; - int start_scan_line = 0; - - // to make absolute seeks possible we store the current position in the file - - long offset_in_file = io.tell_proc(handle); - long seek; - - switch (flags) { - case PCD_BASEDIV4 : - seek = 0x2000; - width = 192; - height = 128; - line = CalculateLine(width, bpp); - pitch = CalculatePitch(line); - break; - - case PCD_BASEDIV16 : - seek = 0xB800; - width = 384; - height = 256; - line = CalculateLine(width, bpp); - pitch = CalculatePitch(line); - break; - - default : - seek = 0x30000; - width = 768; - height = 512; - line = CalculateLine(width, bpp); - pitch = CalculatePitch(line); - break; - } - - // allocate the dib and write out the header - - FIBITMAP *dib = freeimage.allocate_proc(width, height, bpp, 0xFF, 0xFF00, 0xFF0000); - - // check if the PCD is bottom-up - - if (VerticalOrientation(io, handle)) { - scan_line_add = -1; - start_scan_line = height - 1; - } - - // temporary stuff to load PCD - - BYTE *y1 = (BYTE *)malloc(width); - BYTE *y2 = (BYTE *)malloc(width); - BYTE *cbcr = (BYTE *)malloc(width); - BYTE *yl[] = { y1, y2 }; - - // seek to the part where the bitmap data begins - - io.seek_proc(handle, offset_in_file, SEEK_SET); - io.seek_proc(handle, seek, SEEK_CUR); - - // read the data - - for (int y = 0; y < height / 2; ++y) { - io.read_proc(y1, width, 1, handle); - io.read_proc(y2, width, 1, handle); - io.read_proc(cbcr, width, 1, handle); - - for (int i = 0; i < 2; ++i) { - for (int x = 0; x < width; ++x) { - int r, g, b; - - YUV2RGB(yl[i][x], cbcr[x / 2], cbcr[(width / 2) + (x / 2)], r, g, b); - - *(freeimage.get_scanline_proc(dib, start_scan_line) + (x * 3) + 0) = b; - *(freeimage.get_scanline_proc(dib, start_scan_line) + (x * 3) + 1) = g; - *(freeimage.get_scanline_proc(dib, start_scan_line) + (x * 3) + 2) = r; - } - - start_scan_line += scan_line_add; - } - } - - free(cbcr); - free(y2); - free(y1); - - return dib; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitPCD(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; -} diff --git a/freeimage241/Source/FreeImage/PluginPCX.cpp b/freeimage241/Source/FreeImage/PluginPCX.cpp deleted file mode 100644 index 1d65b73..0000000 --- a/freeimage241/Source/FreeImage/PluginPCX.cpp +++ /dev/null @@ -1,398 +0,0 @@ -// ========================================================== -// PCX Loader -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Jani Kajala (janik@remedy.fi) -// - Markus Loibl (markus.loibl@epost.de) -// - Hervé Drolon (drolon@infonie.fr) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- -// Constants + headers -// ---------------------------------------------------------- - -#ifdef WIN32 -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif - -typedef struct tagPCXHEADER { - BYTE manufacturer; // Magic number (0x0A = ZSoft Z) - BYTE version; // Version 0 == 2.5 - // 2 == 2.8 with palette info - // 3 == 2.8 without palette info - // 5 == 3.0 with palette info - BYTE encoding; // Encoding: 0 = uncompressed, 1 = PCX rle compressed - BYTE bpp; // Bits per pixel per plane (only 1 or 8) - WORD window[4]; // left, upper, right,lower pixel coord. - WORD hdpi; // Horizontal resolution - WORD vdpi; // Vertical resolution - BYTE color_map[48]; // Colormap for 16-color images - BYTE reserved; - BYTE planes; // Number of planes (1, 3 or 4) - WORD bytes_per_line; // Bytes per row (always even) - WORD palette_info; // Palette information (1 = color or b&w; 2 = gray scale) - WORD h_screen_size; - WORD v_screen_size; - BYTE filler[54]; // Reserved filler -} PCXHEADER; - -#ifdef WIN32 -#pragma pack(pop) -#else -#pragma pack(4) -#endif - -// ========================================================== -// Internal functions -// ========================================================== - -static WORD -readline(FreeImageIO &io, fi_handle handle, BYTE *buffer, WORD length, BOOL rle) { - // -----------------------------------------------------------// - // Read either run-length encoded or normal image data // - // // - // THIS IS HOW RUNTIME LENGTH ENCODING WORKS IN PCX: // - // // - // 1) If the upper 2 bits of a byte are set, // - // the lower 6 bits specify the count for the next byte // - // // - // 2) If the upper 2 bits of the byte are clear, // - // the byte is actual data with a count of 1 // - // // - // Note that a scanline always has an even number of bytes // - // ------------------------------------------------------------- - - BYTE count = 0, value = 0; - WORD written = 0; - - if (rle) { - // run-length encoded read - - while (length--) { - if (count == 0) { - io.read_proc(&value, 1, 1, handle); - - if ((value & 0xC0) == 0xC0) { - count = value & 0x3F; - io.read_proc(&value, 1, 1, handle); - } else { - count = 1; - } - } - - count--; - - *(buffer + written++) = value; - } - } else { - // normal read - - written = io.read_proc(buffer, length, 1, handle); - } - - return written; -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "PCX"; -} - -static const char * DLL_CALLCONV -Description() { - return "Zsoft Paintbrush"; -} - -static const char * DLL_CALLCONV -Extension() { - return "pcx"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - BYTE pcx_signature = 0x0A; - BYTE signature = 0; - - io.read_proc(&signature, 1, 1, handle); - - return (pcx_signature == signature); -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - FIBITMAP *dib = NULL; - BYTE *bits; // Pointer to dib data - RGBQUAD *pal; // Pointer to dib palette - BYTE *line = NULL; // PCX raster line - WORD linelength; // Length of raster line in bytes - WORD pitch; // Length of DIB line in bytes - BOOL rle; // True if the file is run-length encoded - - if (handle) { - try { - // process the header - - PCXHEADER header; - - io.read_proc(&header, sizeof(PCXHEADER), 1, handle); - - // check PCX identifier - - if ((header.manufacturer != 0x0A) || (header.version > 5)) - throw "Invalid PCX file"; - - // allocate a new DIB - - WORD width = header.window[2] - header.window[0] + 1; - WORD height = header.window[3] - header.window[1] + 1; - WORD bitcount = header.bpp * header.planes; - - if (bitcount == 24) - dib = freeimage.allocate_proc(width, height, bitcount, 0xFF, 0xFF00, 0xFF0000); - else - dib = freeimage.allocate_proc(width, height, bitcount); - - // if the dib couldn't be allocated, throw an error - - if (!dib) - throw "DIB allocation failed"; - - // metrics handling code - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - pInfoHeader->biXPelsPerMeter = (int) (((float)header.hdpi) / 0.0254000 + 0.5); - pInfoHeader->biYPelsPerMeter = (int) (((float)header.vdpi) / 0.0254000 + 0.5); - - // Set up the palette if needed - // ---------------------------- - - switch(bitcount) { - case 1: - { - pal = freeimage.get_palette_proc(dib); - pal[0].rgbRed = pal[0].rgbGreen = pal[0].rgbBlue = 0; - pal[1].rgbRed = pal[1].rgbGreen = pal[1].rgbBlue = 255; - break; - } - - case 4: - { - pal = freeimage.get_palette_proc(dib); - - BYTE *pColormap = &header.color_map[0]; - - for(int i = 0; i < 16; i++) { - pal[i].rgbRed = pColormap[0]; - pal[i].rgbGreen = pColormap[1]; - pal[i].rgbBlue = pColormap[2]; - pColormap += 3; - } - - break; - } - - case 8: - { - BYTE palette_id; - - io.seek_proc(handle, -769L, SEEK_END); - io.read_proc(&palette_id, 1, 1, handle); - - if (palette_id == 0x0C) { - BYTE *cmap = (BYTE*)malloc(768 * sizeof(BYTE)); - io.read_proc(cmap, 768, 1, handle); - - pal = freeimage.get_palette_proc(dib); - BYTE *pColormap = &cmap[0]; - - for(int i = 0; i < 256; i++) { - pal[i].rgbRed = pColormap[0]; - pal[i].rgbGreen = pColormap[1]; - pal[i].rgbBlue = pColormap[2]; - pColormap += 3; - } - - free(cmap); - } - - // wrong palette ID, perhaps a gray scale is needed ? - - else if (header.palette_info == 2) { - pal = freeimage.get_palette_proc(dib); - - for(int i = 0; i < 256; i++) { - pal[i].rgbRed = i; - pal[i].rgbGreen = i; - pal[i].rgbBlue = i; - } - } - - io.seek_proc(handle, (long)sizeof(PCXHEADER), SEEK_SET); - } - break; - } - - // calculate the line length for the PCX and the DIB - - linelength = header.bytes_per_line * header.planes; - pitch = freeimage.get_pitch_proc(dib); - - // run-length encoding ? - - rle = (header.encoding == 1) ? TRUE : FALSE; - - // load image data - // --------------- - - line = (BYTE*) malloc(linelength * sizeof(BYTE)); - bits = freeimage.get_scanline_proc(dib, height - 1); - - if ((header.planes == 1) && ((header.bpp == 1) || (header.bpp == 8))) { - BYTE skip; - WORD written; - - for (WORD y = 0; y < height; y++) { - written = readline(io, handle, line, linelength, rle); - memcpy(bits, line, linelength); - - // skip trailing garbage at the end of the scanline - - for (int count = written; count < linelength; count++) - io.read_proc(&skip, sizeof(BYTE), 1, handle); - - bits -= pitch; - } - } - else if ((header.planes == 4) && (header.bpp == 1)) { - BYTE bit, index, mask, skip; - BYTE *buffer; - WORD x, y, written; - buffer = (BYTE*)malloc(width * sizeof(BYTE)); - - for (y = 0; y < height; y++) { - written = readline(io, handle, line, linelength, rle); - - // build a nibble using the 4 planes - - memset(buffer, 0, width * sizeof(BYTE)); - - for(int plane = 0; plane < 4; plane++) { - bit = 1 << plane; - - for(x = 0; x < width; x++) { - index = (x / 8) + plane * header.bytes_per_line; - mask = 0x80 >> (x & 0x07); - buffer[x] |= (line[index] & mask) ? bit : 0; - } - } - - // then write the DIB row - - for (x = 0; x < width / 2; x++) - bits[x] = (buffer[2*x] << 4) | buffer[2*x+1]; - - // skip trailing garbage at the end of the scanline - - for (int count = written; count < linelength; count++) - io.read_proc(&skip, sizeof(BYTE), 1, handle); - - bits -= pitch; - } - - free(buffer); - } else if((header.planes == 3) && (header.bpp == 8)) { - BYTE *pline; - - for (WORD y = 0; y < height; y++) { - readline(io, handle, line, linelength, rle); - - // convert the plane stream to BGR (RRRRGGGGBBBB -> BGRBGRBGRBGR) - - pline = line; - - for (int plane = 2; plane >= 0; plane--) { - for (WORD x = 0; x < width; x++) - bits[x * 3 + plane] = pline[x]; - - pline += header.bytes_per_line; - } - - bits -= pitch; - } - } else { - throw "Unable to read this file"; - } - - free(line); - return dib; - - } catch (char *text) { - // free allocated memory - - if (dib != NULL) - freeimage.free_proc(dib); - - if (line != NULL) - free(line); - - freeimage.output_message_proc(s_format_id, text); - - return NULL; - } - } - - return NULL; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitPCX(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.validate_proc = Validate; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; -} diff --git a/freeimage241/Source/FreeImage/PluginPNG.cpp b/freeimage241/Source/FreeImage/PluginPNG.cpp deleted file mode 100644 index d42fbc8..0000000 --- a/freeimage241/Source/FreeImage/PluginPNG.cpp +++ /dev/null @@ -1,610 +0,0 @@ -// ========================================================== -// PNG Loader and Writer -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Herve Drolon (drolon@infonie.fr) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -#include -#include - -// ---------------------------------------------------------- - -#define PNG_ASSEMBLER_CODE_SUPPORTED -#define PNG_BYTES_TO_CHECK 8 - -// ---------------------------------------------------------- - -#include "../LibPNG/png.h" - -// ---------------------------------------------------------- - -static FreeImageIO *s_io; -static fi_handle s_handle; - -///////////////////////////////////////////////////////////////////////////// -// libpng interface -// - -static void -_ReadProc(struct png_struct_def *, unsigned char *data, unsigned int size) { - s_io->read_proc(data, size, 1, s_handle); -} - -static void -_WriteProc(struct png_struct_def *, unsigned char *data, unsigned int size) { - s_io->write_proc(data, size, 1, s_handle); -} - -static void -_FlushProc(png_structp png_ptr) { - // empty flush implementation -} - -static void -error_handler(struct png_struct_def *, const char *error) { - throw error; -} - -// in FreeImage warnings disabled - -static void -warning_handler(struct png_struct_def *, const char *warning) { -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "PNG"; -} - -static const char * DLL_CALLCONV -Description() { - return "Portable Network Graphics"; -} - -static const char * DLL_CALLCONV -Extension() { - return "png"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return "^.PNG\r"; -} - -static const char * DLL_CALLCONV -MimeType() { - return "image/png"; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - BYTE png_signature[8] = { 137, 80, 78, 71, 13, 10, 26, 10 }; - BYTE signature[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - - io.read_proc(&signature, 1, 8, handle); - - return (memcmp(png_signature, signature, 8) == 0); -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - png_structp png_ptr; - png_infop info_ptr; - png_uint_32 width, height; - png_colorp png_palette; - int bpp, color_type, palette_entries; - - FIBITMAP *dib = NULL; - RGBQUAD *palette; // pointer to dib palette - png_bytepp row_pointers = NULL; - int i; - - s_io = &io; - s_handle = handle; - - if (handle) { - try { - // check to see if the file is in fact a PNG file - - unsigned char png_check[PNG_BYTES_TO_CHECK]; - - io.read_proc(png_check, 1, PNG_BYTES_TO_CHECK, handle); - - if (png_sig_cmp(png_check, (png_size_t)0, PNG_BYTES_TO_CHECK) != 0) - return NULL; // Bad signature - - // create the chunk manage structure - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)error_handler, error_handler, warning_handler); - - if (!png_ptr) - return NULL; - - // create the info structure - - info_ptr = png_create_info_struct(png_ptr); - - if (!info_ptr) { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); - return NULL; - } - - // init the IO - - png_set_read_fn(png_ptr, info_ptr, _ReadProc); - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return NULL; - } - - // Because we have already read the signature... - - png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); - - // read the IHDR chunk - - png_read_info(png_ptr, info_ptr); - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bpp, &color_type, NULL, NULL, NULL); - - // DIB's don't support >8 bits per sample - // => tell libpng to strip 16 bit/color files down to 8 bits/color - - if (bpp == 16) { - png_set_strip_16(png_ptr); - bpp = 8; - } - - // Set some additional flags - - switch(color_type) { - case PNG_COLOR_TYPE_RGB: - case PNG_COLOR_TYPE_RGB_ALPHA: - // Flip the RGB pixels to BGR (or RGBA to BGRA) - - png_set_bgr(png_ptr); - break; - - case PNG_COLOR_TYPE_PALETTE: - // Expand palette images to the full 8 bits from 2 or 4 bits/pixel - - if ((bpp == 2) || (bpp == 4)) { - png_set_packing(png_ptr); - bpp = 8; - } - - break; - - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_GRAY_ALPHA: - // Expand grayscale images to the full 8 bits from 2 or 4 bits/pixel - - if ((bpp == 2) || (bpp == 4)) { - png_set_expand(png_ptr); - bpp = 8; - } - - break; - - default: - throw "PNG format not supported"; - } - - // Set the background color to draw transparent and alpha images over. - // It is possible to set the red, green, and blue components directly - // for paletted images instead of supplying a palette index. Note that - // even if the PNG file supplies a background, you are not required to - // use it - you should use the (solid) application background if it has one. - - if (color_type != PNG_COLOR_TYPE_RGB_ALPHA) { - png_color_16 my_background= { 0, 255, 255, 255, 0 }; - png_color_16 *image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - } - - // if this image has transparency, store the trns values - - png_bytep trans = NULL; - int num_trans = 0; - png_color_16p trans_values = NULL; - png_uint_32 transparent_value = png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &trans_values); - - // unlike the example in the libpng documentation, we have *no* idea where - // this file may have come from--so if it doesn't have a file gamma, don't - // do any correction ("do no harm") - - double gamma = 0; - double screen_gamma = 2.2; - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - - // All transformations have been registered; now update info_ptr data - - png_read_update_info(png_ptr, info_ptr); - - // Create a DIB and write the bitmap header - // set up the DIB palette, if needed - - switch (color_type) { - case PNG_COLOR_TYPE_RGB: - png_set_invert_alpha(png_ptr); - - dib = freeimage.allocate_proc(width, height, 24, 0xFF, 0xFF00, 0xFF0000); - break; - - case PNG_COLOR_TYPE_RGB_ALPHA : - dib = freeimage.allocate_proc(width, height, 32, 0xFF, 0xFF00, 0xFF0000); - break; - - case PNG_COLOR_TYPE_PALETTE : - dib = freeimage.allocate_proc(width, height, bpp); - - png_get_PLTE(png_ptr,info_ptr, &png_palette,&palette_entries); - - palette = freeimage.get_palette_proc(dib); - - // store the palette - - for (i = 0; i < palette_entries; i++) { - palette[i].rgbRed = png_palette[i].red; - palette[i].rgbGreen = png_palette[i].green; - palette[i].rgbBlue = png_palette[i].blue; - } - - // store the transparency table - - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - freeimage.set_transparency_table_proc(dib, (BYTE *)trans, num_trans); - - break; - - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_GRAY_ALPHA: - dib = freeimage.allocate_proc(width, height, bpp); - - palette = freeimage.get_palette_proc(dib); - palette_entries = 1 << bpp; - - for (i = 0; i < palette_entries; i++) { - palette[i].rgbRed = - palette[i].rgbGreen = - palette[i].rgbBlue = (i * 255) / (palette_entries - 1); - } - - // store the transparency table - - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - freeimage.set_transparency_table_proc(dib, (BYTE *)trans, num_trans); - - break; - } - - // DIBs *do* support physical resolution - - if (png_get_valid(png_ptr,info_ptr,PNG_INFO_pHYs)) { - png_uint_32 res_x, res_y; - - // We'll overload this var and use 0 to mean no phys data, - // since if it's not in meters we can't use it anyway - - int res_unit_type = 0; - - png_get_pHYs(png_ptr,info_ptr,&res_x,&res_y,&res_unit_type); - - if (res_unit_type == 1) { - BITMAPINFOHEADER *bih = freeimage.get_info_header_proc(dib); - - bih->biXPelsPerMeter = res_x; - bih->biYPelsPerMeter = res_y; - } - } - - // set the individual row_pointers to point at the correct offsets - - row_pointers = (png_bytepp)malloc(height * sizeof(png_bytep)); - - if (!row_pointers) { - if (palette) - png_free(png_ptr, palette); - - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - - freeimage.free_proc(dib); - free(row_pointers); - return NULL; - } - - // read in the bitmap bits via the pointer table - - for (png_uint_32 k = 0; k < height; k++) - row_pointers[height - 1 - k] = freeimage.get_scanline_proc(dib, k); - - png_read_image(png_ptr, row_pointers); - - // check if the bitmap contains transparency, if so enable it in the header - - if (freeimage.get_bpp_proc(dib) == 32) - if (freeimage.get_color_type_proc(dib) == FIC_RGBALPHA) - freeimage.set_transparent_proc(dib, TRUE); - else - freeimage.set_transparent_proc(dib, FALSE); - - // cleanup - - if (row_pointers) - free(row_pointers); - - png_read_end(png_ptr, info_ptr); - - if (png_ptr) - png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); - - return dib; - } catch (const char *text) { - if (png_ptr) - png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); - - if (row_pointers) - free(row_pointers); - - if (dib) - freeimage.free_proc(dib); - - freeimage.output_message_proc(s_format_id, text); - - return NULL; - } - } - - return NULL; -} - -static BOOL DLL_CALLCONV -Save(FreeImage &freeimage, FreeImageIO &io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - png_structp png_ptr; - png_infop info_ptr; - png_colorp palette = NULL; - png_uint_32 width, height, bpp; - BOOL has_alpha_channel = FALSE; - - RGBQUAD *pal; // pointer to dib palette - int bit_depth; - int palette_entries; - int interlace_type; - - s_io = &io; - s_handle = handle; - - if ((dib) && (handle)) { - try { - // create the chunk manage structure - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)error_handler, error_handler, warning_handler); - - if (!png_ptr) { - return FALSE; - } - - // Allocate/initialize the image information data. - - info_ptr = png_create_info_struct(png_ptr); - - if (!info_ptr) { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - return FALSE; - } - - // Set error handling. REQUIRED if you aren't supplying your own - // error handling functions in the png_create_write_struct() call. - - if (setjmp(png_jmpbuf(png_ptr))) { - // If we get here, we had a problem reading the file - - png_destroy_write_struct(&png_ptr, &info_ptr); - - return FALSE; - } - - // init the IO - - png_set_write_fn(png_ptr, info_ptr, _WriteProc, _FlushProc); - - // DIBs *do* support physical resolution - - BITMAPINFOHEADER *bih = freeimage.get_info_header_proc(dib); - png_uint_32 res_x = bih->biXPelsPerMeter; - png_uint_32 res_y = bih->biYPelsPerMeter; - - if ((res_x > 0) && (res_y > 0)) { - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, 1); - } - - // Set the image information here. Width and height are up to 2^31, - // bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on - // the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, - // PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, - // or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or - // PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST - // currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED - - width = freeimage.get_width_proc(dib); - height = freeimage.get_height_proc(dib); - bpp = bit_depth = freeimage.get_bpp_proc(dib); - - if (bit_depth == 16) { - png_destroy_write_struct(&png_ptr, &info_ptr); - - throw "Format not supported"; // Note: this could be enhanced here... - } - - bit_depth = (bit_depth > 8) ? 8 : bit_depth; - - interlace_type = PNG_INTERLACE_NONE; // Default value - - switch (freeimage.get_color_type_proc(dib)) { - case FIC_MINISWHITE: - // Invert monochrome files to have 0 as black and 1 as white - // (no break here) - png_set_invert_mono(png_ptr); - - case FIC_MINISBLACK: - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - PNG_COLOR_TYPE_GRAY, interlace_type, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - break; - - case FIC_PALETTE: - { - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - PNG_COLOR_TYPE_PALETTE, interlace_type, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - // set the palette - - palette_entries = 1 << bit_depth; - palette = (png_colorp)png_malloc(png_ptr, palette_entries * sizeof (png_color)); - pal = freeimage.get_palette_proc(dib); - - for (int i = 0; i < palette_entries; i++) { - palette[i].red = pal[i].rgbRed; - palette[i].green = pal[i].rgbGreen; - palette[i].blue = pal[i].rgbBlue; - } - - png_set_PLTE(png_ptr, info_ptr, palette, palette_entries); - - // You must not free palette here, because png_set_PLTE only makes a link to - // the palette that you malloced. Wait until you are about to destroy - // the png structure. - - break; - } - - case FIC_RGBALPHA : - if (freeimage.is_transparent_proc(dib)) { - has_alpha_channel = TRUE; - - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - PNG_COLOR_TYPE_RGBA, interlace_type, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - png_set_bgr(png_ptr); // flip BGR pixels to RGB - break; - } - - // intentionally no break here... - - case FIC_RGB: - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - PNG_COLOR_TYPE_RGB, interlace_type, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - png_set_bgr(png_ptr); // flip BGR pixels to RGB - break; - } - - // Optional gamma chunk is strongly suggested if you have any guess - // as to the correct gamma of the image. - // png_set_gAMA(png_ptr, info_ptr, gamma); - - if ((freeimage.get_bpp_proc(dib) == 8) && (freeimage.is_transparent_proc(dib)) && (freeimage.get_transparency_count_proc(dib) > 0)) - png_set_tRNS(png_ptr, info_ptr, freeimage.get_transparency_table_proc(dib), freeimage.get_transparency_count_proc(dib), NULL); - - // Write the file header information. - - png_write_info(png_ptr, info_ptr); - - // write out the image data - - if ((bpp == 32) && (!has_alpha_channel)) { - BYTE *buffer = (BYTE *)malloc(width * 3); - - for (png_uint_32 k = 0; k < height; k++) { - freeimage.convert_line_32to24_proc(buffer, freeimage.get_scanline_proc(dib, height - k - 1), width); - - png_write_row(png_ptr, buffer); - } - - free(buffer); - } else { - for (png_uint_32 k = 0; k < height; k++) { - png_write_row(png_ptr, freeimage.get_scanline_proc(dib, height - k - 1)); - } - } - - // It is REQUIRED to call this to finish writing the rest of the file - // Bug with png_flush - - png_write_end(png_ptr, info_ptr); - - // clean up after the write, and free any memory allocated - - png_destroy_write_struct(&png_ptr, &info_ptr); - - if (palette) - png_free(png_ptr, palette); - - return TRUE; - } catch (const char *text) { - freeimage.output_message_proc(s_format_id, text); - } - } - - return FALSE; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitPNG(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.pagecount_proc = NULL; - plugin.pagecapability_proc = NULL; - plugin.load_proc = Load; - plugin.save_proc = 0; //Save; - plugin.validate_proc = Validate; - plugin.mime_proc = MimeType; -} diff --git a/freeimage241/Source/FreeImage/PluginPNM.cpp b/freeimage241/Source/FreeImage/PluginPNM.cpp deleted file mode 100644 index 87e02af..0000000 --- a/freeimage241/Source/FreeImage/PluginPNM.cpp +++ /dev/null @@ -1,599 +0,0 @@ -// ========================================================== -// PNM (PPM, PGM, PBM) Loader and Writer -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@infonie.fr) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include // for sprintf() -#include - -#include "FreeImage.h" -#include "Utilities.h" - -// ========================================================== -// Internal functions -// ========================================================== - -static int -GetInt(FreeImageIO &io, fi_handle handle) { - // get an integer value from the actual position pointed by handle - - char c = 0; - BOOL firstchar; - - // skip forward to start of next number - - io.read_proc(&c, 1, 1, handle); - - while (1) { - // eat comments - - if (c == '#') { - // if we're at a comment, read to end of line - - firstchar = TRUE; - - while (1) { - io.read_proc(&c, 1, 1, handle); - - if (firstchar && c == ' ') { - // loop off 1 sp after # - - firstchar = FALSE; - } else if(c == '\n') { - break; - } - } - } - - if (c >= '0' && c <='9') { - // we've found what we were looking for - - break; - } - - io.read_proc(&c, 1, 1, handle); - } - - // we're at the start of a number, continue until we hit a non-number - - int i = 0; - - while (1) { - i = (i*10) + (c - '0'); - - io.read_proc(&c, 1, 1, handle); - - if (c < '0' || c > '9') - break; - } - - return i; -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "PNM"; -} - -static const char * DLL_CALLCONV -Description() { - return "Portable Network Media"; -} - -static const char * DLL_CALLCONV -Extension() { - return "pbm,pgm,ppm"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - BYTE pbm_id1[] = { 0x50, 0x31 }; - BYTE pbm_id2[] = { 0x50, 0x34 }; - BYTE pgm_id1[] = { 0x50, 0x32 }; - BYTE pgm_id2[] = { 0x50, 0x35 }; - BYTE ppm_id1[] = { 0x50, 0x33 }; - BYTE ppm_id2[] = { 0x50, 0x36 }; - BYTE signature[2] = { 0, 0 }; - - io.read_proc(signature, 1, sizeof(pbm_id1), handle); - - if (memcmp(pbm_id1, signature, sizeof(pbm_id1)) == 0) - return TRUE; - - if (memcmp(pbm_id1, signature, sizeof(pbm_id2)) == 0) - return TRUE; - - if (memcmp(pbm_id1, signature, sizeof(pgm_id1)) == 0) - return TRUE; - - if (memcmp(pbm_id1, signature, sizeof(pgm_id2)) == 0) - return TRUE; - - if (memcmp(pbm_id1, signature, sizeof(ppm_id1)) == 0) - return TRUE; - - if (memcmp(pbm_id1, signature, sizeof(ppm_id2)) == 0) - return TRUE; - - return FALSE; -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - char id_one, id_two; - WORD x, y; - FIBITMAP *dib; - BYTE *bits; // pointer to dib data - RGBQUAD *pal; // pointer to dib palette - int i, max, level; - - if (!handle) - return NULL; - - try { - // Read the first two bytes of the file to determine the file format - // "P1" = ascii bitmap, "P2" = ascii greymap, "P3" = ascii pixmap, - // "P4" = raw bitmap, "P5" = raw greymap, "P6" = raw pixmap - - io.read_proc(&id_one, 1, 1, handle); - io.read_proc(&id_two, 1, 1, handle); - - if (id_one != 'P' || id_two < '1' || id_two > '6') { - throw "Invalid magic number"; - } - - // Read the header information - - int width = GetInt(io, handle); - int height = GetInt(io, handle); - - // Create a new DIB - - switch (id_two) { - case '1': - case '4': - dib = freeimage.allocate_proc(width, height, 1); - break; - - case '2': - case '5': - dib = freeimage.allocate_proc(width, height, 8); - break; - - case '3': - case '6': - dib = freeimage.allocate_proc(width, height, 24, 0xFF, 0xFF00, 0xFF0000); - break; - } - - if (dib == NULL) - throw "DIB allocation failed"; - - // Read the image... - - int pitch = freeimage.get_pitch_proc(dib); - - switch(id_two) { - case '1': - case '4': - // write the palette data - - pal = freeimage.get_palette_proc(dib); - pal[0].rgbRed = pal[0].rgbGreen = pal[0].rgbBlue = 0; - pal[1].rgbRed = pal[1].rgbGreen = pal[1].rgbBlue = 255; - - // write the bitmap data - - if (id_two == '1') { // ASCII bitmap - for (y = 0; y < height; y++) { - bits = freeimage.get_bits_proc(dib) + (height - 1 - y) * pitch; - - for (x = 0; x < width; x++) { - if (GetInt(io, handle) == 0) - bits[x >> 3] |= (0x80 >> (x & 0x7)); - else - bits[x >> 3] &= (0xFF7F >> (x & 0x7)); - } - } - } else { // Raw bitmap - int line = CalculateLine(width, 1); - - for (y = 0; y < height; y++) { - bits = freeimage.get_bits_proc(dib) + (height - 1 - y) * pitch; - - for (x = 0; x < line; x++) { - io.read_proc(&bits[x], 1, 1, handle); - - bits[x] = ~bits[x]; - } - } - } - - return dib; - - case '2': - case '5': - // Build a greyscale palette - - pal = freeimage.get_palette_proc(dib); - - for (i = 0; i < 256; i++) { - pal[i].rgbRed = - pal[i].rgbGreen = - pal[i].rgbBlue = i; - } - - max = GetInt(io, handle); // read the 'max' value - - // write the bitmap data - - if(id_two == '2') { // ASCII greymap - for (y = 0; y < height; y++) { - bits = freeimage.get_bits_proc(dib) + (height - 1 - y) * pitch; - for (x = 0; x < width; x++) { - level = GetInt(io, handle); - bits[x] = (BYTE)((255 * level) / max); - } - } - } else { // Raw greymap - level = 0; - - for (y = 0; y < height; y++) { - bits = freeimage.get_bits_proc(dib) + (height - 1 - y) * pitch; - - for (x = 0; x < width; x++) { - io.read_proc(&level, 1, 1, handle); - bits[x] = (BYTE)((255 * level) / max); - } - } - } - - return dib; - - case '3': - case '6': - max = GetInt(io, handle); // read the 'max' value - - // write the bitmap data - - if (id_two == '3') { // ASCII pixmap - for (y = 0; y < height; y++) { - bits = freeimage.get_bits_proc(dib) + (height - 1 - y) * pitch; - - for (x = 0; x < width; x++) { - bits[2] = (BYTE)((255 * GetInt(io, handle)) / max); // R - bits[1] = (BYTE)((255 * GetInt(io, handle)) / max); // G - bits[0] = (BYTE)((255 * GetInt(io, handle)) / max); // B - - bits += 3; - } - } - } else { // Raw pixmap - level = 0; - - for (y = 0; y < height; y++) { - bits = freeimage.get_bits_proc(dib) + (height - 1 - y) * pitch; - - for (x = 0; x < width; x++) { - io.read_proc(&level, 1, 1, handle); - bits[2] = (BYTE)((255 * level) / max); // R - - io.read_proc(&level, 1, 1, handle); - bits[1] = (BYTE)((255 * level) / max); // G - - io.read_proc(&level, 1, 1, handle); - bits[0] = (BYTE)((255 * level) / max); // B - - bits += 3; - } - } - } - - return dib; - } - - } catch(char *text) { - switch(id_two) { - case '1': - case '4': - freeimage.output_message_proc(s_format_id, text); - break; - case '2': - case '5': - freeimage.output_message_proc(s_format_id, text); - break; - case '3': - case '6': - freeimage.output_message_proc(s_format_id, text); - break; - } - - return NULL; - } - - return NULL; -} - -static BOOL DLL_CALLCONV -Save(FreeImage &freeimage, FreeImageIO &io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - // ---------------------------------------------------------- - // PNM Saving - // ---------------------------------------------------------- - // - // Output format : - // - // Bit depth flags file format - // ------------- -------------- ----------- - // 1-bit / pixel PNM_SAVE_ASCII PBM (P1) - // 1-bit / pixel PNM_SAVE_RAW PBM (P4) - // 8-bit / pixel PNM_SAVE_ASCII PGM (P2) - // 8-bit / pixel PNM_SAVE_RAW PGM (P5) - // 24-bit / pixel PNM_SAVE_ASCII PPM (P3) - // 24-bit / pixel PNM_SAVE_RAW PPM (P6) - // ---------------------------------------------------------- - - int magic, bpp; - WORD x, y, width, height; - BYTE *bits; // pointer to dib data - - if ((dib) && (handle)) { - bpp = freeimage.get_bpp_proc(dib); - width = freeimage.get_width_proc(dib); - height = freeimage.get_height_proc(dib); - - // Find the appropriate magic number for this file type - - magic = 0; - - switch (bpp) { - case 1 : - magic = 1; // PBM file (B & W) - break; - case 8 : - magic = 2; // PGM file (Greyscale) - break; - - case 24 : - magic = 3; // PPM file (RGB) - break; - - case 32 : - if (!freeimage.is_transparent_proc(dib)) - magic = 3; - else - throw "PNM does not support alpha channels"; - - break; - - default: - return FALSE; // Invalid bit depth - } - - if (flags == PNM_SAVE_RAW) - magic += 3; - - // Write the header info - - char buffer[20]; - sprintf(buffer, "P%d\n%d %d\n", magic, width, height); - io.write_proc(&buffer, strlen(buffer), 1, handle); - - if (bpp != 1) { - sprintf(buffer, "255\n"); - io.write_proc(&buffer, strlen(buffer), 1, handle); - } - - // Write the image data - /////////////////////// - - int pitch = (bpp == 32) ? CalculatePitch(CalculateLine(width, 24)) : freeimage.get_pitch_proc(dib); - - switch(bpp) { - case 32 : - case 24 : // 24-bit RGB, 3 bytes per pixel - { - if (flags == PNM_SAVE_RAW) { - BYTE *buffer = (BYTE *)malloc(pitch); - - for (y = 0; y < height; y++) { - // get a pointer to the (converted) scanline - - if (bpp == 32) - freeimage.convert_line_32to24_proc(buffer, freeimage.get_scanline_proc(dib, height - y - 1), width); - else - memcpy(buffer, freeimage.get_scanline_proc(dib, height - 1 - y), pitch); - - // write the scanline to disc - - BYTE *bits = buffer; - - for (x = 0; x < width; x++) { - io.write_proc(&bits[2], 1, 1, handle); // R - io.write_proc(&bits[1], 1, 1, handle); // G - io.write_proc(&bits[0], 1, 1, handle); // B - - bits += 3; - } - } - - free(buffer); - } else { - int length = 0; - - BYTE *buffer = (BYTE *)malloc(pitch); - - for (y = 0; y < height; y++) { - // get a pointer to the (converted) scanline - - if (bpp == 32) - freeimage.convert_line_32to24_proc(buffer, freeimage.get_scanline_proc(dib, height - 1 - y), width); - else - memcpy(buffer, freeimage.get_scanline_proc(dib, height - 1 - y), pitch); - - // write the scanline to disc - - BYTE *bits = buffer; - - for (x = 0; x < width; x++) { - char buffer[20]; - - sprintf(buffer, "%3d %3d %3d ", bits[2], bits[1], bits[0]); - - io.write_proc(&buffer, strlen(buffer), 1, handle); - - length += 12; - - if(length > 58) { - sprintf(buffer, "\n"); - - io.write_proc(&buffer, strlen(buffer), 1, handle); - - length = 0; - } - - bits += 3; - } - } - - free(buffer); - } - - break; - } - - case 8: // 8-bit greyscale - { - if (flags == PNM_SAVE_RAW) { - for (y = 0; y < height; y++) { - bits = freeimage.get_bits_proc(dib) + (height - 1 - y) * pitch; - - for (x = 0; x < width; x++) { - io.write_proc(&bits[x], 1, 1, handle); - } - } - } else { - int length = 0; - - for (y = 0; y < height; y++) { - bits = freeimage.get_bits_proc(dib) + (height - 1 - y) * pitch; - - for (x = 0; x < width; x++) { - sprintf(buffer, "%3d ", bits[x]); - - io.write_proc(&buffer, strlen(buffer), 1, handle); - - length += 4; - - if (length > 66) { - sprintf(buffer, "\n"); - - io.write_proc(&buffer, strlen(buffer), 1, handle); - - length = 0; - } - } - } - } - - break; - } - - case 1: // 1-bit B & W - { - RGBQUAD *pal = freeimage.get_palette_proc(dib); - int color; - - if (flags == PNM_SAVE_RAW) { - for(y = 0; y < height; y++) { - bits = freeimage.get_bits_proc(dib) + (height - 1 - y) * pitch; - - for(x = 0; x < freeimage.get_line_proc(dib); x++) - io.write_proc(&bits[x], 1, 1, handle); - } - } else { - int length = 0; - - for (y = 0; y < height; y++) { - bits = freeimage.get_bits_proc(dib) + (height - 1 - y) * pitch; - - for (x = 0; x < freeimage.get_line_proc(dib) * 8; x++) { - color = (bits[x>>3] & (0x80 >> (x & 0x07))) != 0; - - sprintf(buffer, "%c ", color ? '1':'0'); - - io.write_proc(&buffer, strlen(buffer), 1, handle); - - length += 2; - - if (length > 68) { - sprintf(buffer, "\n"); - - io.write_proc(&buffer, strlen(buffer), 1, handle); - - length = 0; - } - } - } - } - } - - break; - } - - return TRUE; - } - - return FALSE; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitPNM(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; - plugin.save_proc = Save; - plugin.validate_proc = Validate; -} - diff --git a/freeimage241/Source/FreeImage/PluginPSD.cpp b/freeimage241/Source/FreeImage/PluginPSD.cpp deleted file mode 100644 index eaa55cb..0000000 --- a/freeimage241/Source/FreeImage/PluginPSD.cpp +++ /dev/null @@ -1,389 +0,0 @@ -// ========================================================== -// Photoshop Loader -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// Based on public domain code created and -// published by Thatcher Ulrich (ulrich@world.std.com) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" - -// ========================================================== -// Bitmap pointer access macros -// ========================================================== - -#define BP_START(DIB, WIDTH, HEIGHT) \ - int scanline = 0; \ - unsigned *bits = (unsigned *)freeimage.get_scanline_proc(DIB, HEIGHT - 1 - scanline); \ - unsigned *p = bits; - -#define BP_NEXT(DIB, WIDTH, HEIGHT) \ - p++; \ - if (p - bits == width) { \ - scanline++; \ - bits = (unsigned *)freeimage.get_scanline_proc(DIB, HEIGHT - 1 - scanline); \ - p = bits; \ - } - -#define BP_SETVALUE(VALUE) \ - *p |= VALUE; - -// ========================================================== -// Internal functions -// ========================================================== - -static unsigned -Read8(FreeImageIO &io, fi_handle handle) { - unsigned i = 0; - io.read_proc(&i, 1, 1, handle); - return i; -} - -static unsigned -Read16(FreeImageIO &io, fi_handle handle) { - // reads a two-byte big-endian integer from the given file and returns its value. - // assumes unsigned. - - unsigned hi = Read8(io, handle); - unsigned lo = Read8(io, handle); - return lo + (hi << 8); -} - -static unsigned -Read32(FreeImageIO &io, fi_handle handle) { - // reads a four-byte big-endian integer from the given file and returns its value. - // assumes unsigned. - - unsigned b3 = Read8(io, handle); - unsigned b2 = Read8(io, handle); - unsigned b1 = Read8(io, handle); - unsigned b0 = Read8(io, handle); - return (b3 << 24) + (b2 << 16) + (b1 << 8) + b0; -} - -// ---------------------------------------------------------- - -static void -ScanForResolution(float* hres, float* vres, FreeImageIO &io, fi_handle handle, int width, int height, int channel_count, int byte_count) { - // scans through the next byte_count bytes of the file, looking for an - // image resource block encoding the image's resolution. Returns the resolution(s), - // if found, in the pointed-to floats. Units are in pixels/meter. - - while (byte_count) { - // read the image resource block header. - - if (Read32(io, handle) != 0x3842494D /* "8BIM" */) - throw "image resource block has unknown signature"; - - int id = Read16(io, handle); - - // skip the name. - - int name_length = Read8(io, handle) | 1; // name_length must be odd, so that total including size byte is even. - - io.seek_proc(handle, name_length, SEEK_CUR); - - // get the size of the data block. - - int data_size = Read32(io, handle); - - if (data_size & 1 == 1) - data_size += 1; // block size must be even. - - // account for header size. - - byte_count -= 11 + name_length; - - // if this block is a resolution info structure, then get the resolution. - - if (id == 0x03ED) { - int junk; - - int hres_fixed = Read32(io, handle); - junk = Read16(io, handle); // display units of hres. - junk = Read16(io, handle); // display units of width. - - int vres_fixed = Read32(io, handle); - junk = Read16(io, handle); // display units of vres. - junk = Read16(io, handle); // display units of height. - - byte_count -= data_size; - data_size -= 16; - - // skip any extra bytes at the end of this block... - - if (data_size > 0) - io.seek_proc(handle, data_size, SEEK_CUR); - - // need to convert resolution figures from fixed point, pixels/inch - // to floating point, pixels/meter. - - *hres = hres_fixed * ((float)39.4 / (float)65536.0); - *vres = vres_fixed * ((float)39.4 / (float)65536.0); - } else { - // skip the rest of this block. - - io.seek_proc(handle, data_size, SEEK_CUR); - - byte_count -= data_size; - } - } -} - -// ---------------------------------------------------------- - -static FIBITMAP * -LoadPSDRGB(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int width, int height, int channel_count) { - // skip the mode data. (it's the palette for indexed color; other info for other modes.) - - int mode_data_count = Read32(io, handle); - - if (mode_data_count) - io.seek_proc(handle, mode_data_count, SEEK_CUR); - - // skip the image resources. (resolution, pen tool paths, alpha channel names, etc) - - int resource_data_count = Read32(io, handle); - - if (resource_data_count) - io.seek_proc(handle, resource_data_count, SEEK_CUR); - - // skip the reserved data - - int reserved_data_count = Read32(io, handle); - - if (reserved_data_count) - io.seek_proc(handle, reserved_data_count, SEEK_CUR); - - // find out if the data is compressed - // 0: no compressiod - // 1: RLE compressed - - unsigned compression = Read16(io, handle); - - if ((compression > 1) || (compression < 0)) - return NULL; - - // some formatting information about the channels - - const struct ChannelInfo { - int shift, mask, deflt; - } Channel[4] = { - { 16, 0x00FF0000, 0 }, // red - { 8, 0x0000FF00, 0 }, // green - { 0, 0x000000FF, 0 }, // blue - { 24, 0xFF000000, 255 } // alpha - }; - - // Create the destination bitmap - - FIBITMAP *dib = freeimage.allocate_proc(width, height, 32, 0xFF, 0xFF00, 0xFF0000); - - // finally, read the image data. - - if (compression) { - // the RLE-compressed data is preceeded by a 2-byte data count for each row in the data - - io.seek_proc(handle, height * channel_count * 2, SEEK_CUR); - - // read the RLE data by channel - - for (int channel = 0; channel < (channel_count > 4 ? 4 : channel_count); channel++) { - const ChannelInfo &c = Channel[channel]; - - BP_START(dib, width, height) - - if (channel >= channel_count) { - // fill this channel with default data. - - unsigned def = (c.deflt << c.shift) & c.mask; - - for (int i = 0; i < width * height; i++) { - BP_SETVALUE(def); - BP_NEXT(dib, width, height) - } - } else { - // read the RLE data. - - int count = 0; - - while (count < width * height) { - int len = Read8(io, handle); - - if (len == 128) { - // nop - } else if (len < 128) { - // copy next len + 1 bytes literally. - - len++; - count += len; - - while (len) { - BP_SETVALUE(((Read8(io, handle) << c.shift) & c.mask)); - BP_NEXT(dib, width, height) - - len--; - } - } else if (len > 128) { - // next -len + 1 bytes in the dest are replicated from next source byte. - // (interpret len as a negative 8-bit int.) - - len ^= 0x0FF; - len += 2; - count += len; - - unsigned val = (Read8(io, handle) << c.shift) & c.mask; - - while (len) { - BP_SETVALUE(val); - BP_NEXT(dib, width, height) - - len--; - } - } - } - } - } - } else { - // we're at the raw image data. it's each channel in order (Red, Green, Blue, Alpha, ...) - // where each channel consists of an 8-bit value for each pixel in the image. - - for (int channel = 0; channel < 4; channel++) { - const ChannelInfo &c = Channel[channel]; - - BP_START(dib, width, height) - - if (channel > channel_count) { - // fill this channel with default data. - - unsigned def = (c.deflt << c.shift) & c.mask; - - for (int i = 0; i < width * height; i++) { - BP_SETVALUE(def); - BP_NEXT(dib, width, height) - } - } else { - // read the data - - for (int i = 0; i < width * height; i++) { - BP_SETVALUE((Read8(io, handle) << c.shift) & c.mask); - BP_NEXT(dib, width, height) - } - } - } - } - - return dib; -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "PSD"; -} - -static const char * DLL_CALLCONV -Description() { - return "Adobe Photoshop"; -} - -static const char * DLL_CALLCONV -Extension() { - return "psd"; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - return (Read32(io, handle) == 0x38425053); -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - try { - if (Read32(io, handle) == 0x38425053) { - if (Read16(io, handle) == 1) { - // 6 reserved bytes. - - Read32(io, handle); - Read16(io, handle); - - // Read the number of channels (R, G, B, A, etc). - - unsigned channel_count = Read16(io, handle); - - if (channel_count >= 0 && channel_count <= 16) { - unsigned height = Read32(io, handle); - unsigned width = Read32(io, handle); - - if (Read16(io, handle) == 8) { - unsigned mode = Read16(io, handle); - - // Valid options are: - // 0: Bitmap (not implemented) - // 1: Grayscale (not implemented) - // 2: Indexed color (not implemented) - // 3: RGB color - // 4: CMYK color (not implemented) - // 7: Multichannel (not implemented) - // 8: Duotone (not implemented) - // 9: Lab color (not implemented) - - switch (mode) { - case 3 : - return LoadPSDRGB(freeimage, io, handle, width, height, channel_count); - - default : - throw "color mode not supported"; - } - } - } - } - } - } catch(const char *message) { - freeimage.output_message_proc(s_format_id, message); - } - - return NULL; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitPSD(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.validate_proc = Validate; - plugin.load_proc = Load; -} diff --git a/freeimage241/Source/FreeImage/PluginRAS.cpp b/freeimage241/Source/FreeImage/PluginRAS.cpp deleted file mode 100644 index a8bd01b..0000000 --- a/freeimage241/Source/FreeImage/PluginRAS.cpp +++ /dev/null @@ -1,470 +0,0 @@ -// ========================================================== -// Sun rasterfile Loader -// -// Design and implementation by -// - Hervé Drolon (drolon@infonie.fr) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include -#include - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- -// Constants + headers -// ---------------------------------------------------------- - -#ifdef WIN32 -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif - -typedef struct { - DWORD magic; // Magic number - DWORD width; // Image width in pixels - DWORD height; // Image height in pixels - DWORD depth; // Depth (1, 8, 24 or 32 bits) of each pixel - DWORD length; // Image length (in bytes) - DWORD type; // Format of file (see RT_* below) - DWORD maptype; // Type of colormap (see RMT_* below) - DWORD maplength; // Length of colormap (in bytes) -} Sun_Header; - -#ifdef WIN32 -#pragma pack(pop) -#else -#pragma pack(4) -#endif - -// ---------------------------------------------------------- - -// Following the header is the colormap, for maplength bytes (unless maplength is zero), -// then the image. Each row of the image is rounded to 2 bytes. - -#define RAS_MAGIC 0x59A66A95 // Magic number for Sun rasterfiles - -// Sun supported type's - -#define RT_OLD 0 // Old format (raw image in 68000 byte order) -#define RT_STANDARD 1 // Raw image in 68000 byte order -#define RT_BYTE_ENCODED 2 // Run-length encoding of bytes -#define RT_FORMAT_RGB 3 // XRGB or RGB instead of XBGR or BGR -#define RT_FORMAT_TIFF 4 // TIFF <-> standard rasterfile -#define RT_FORMAT_IFF 5 // IFF (TAAC format) <-> standard rasterfile - -#define RT_EXPERIMENTAL 0xffff // Reserved for testing - -// These are the possible colormap types. -// if it's in RGB format, the map is made up of three byte arrays -// (red, green, then blue) that are each 1/3 of the colormap length. - -#define RMT_NONE 0 // maplength is expected to be 0 -#define RMT_EQUAL_RGB 1 // red[maplength/3], green[maplength/3], blue[maplength/3] -#define RMT_RAW 2 // Raw colormap -#define RESC 128 // Run-length encoding escape character - -// ----- NOTES ----- -// Each line of the image is rounded out to a multiple of 16 bits. -// This corresponds to the rounding convention used by the memory pixrect -// package (/usr/include/pixrect/memvar.h) of the SunWindows system. -// The ras_encoding field (always set to 0 by Sun's supported software) -// was renamed to ras_length in release 2.0. As a result, rasterfiles -// of type 0 generated by the old software claim to have 0 length; for -// compatibility, code reading rasterfiles must be prepared to compute the -// TRUE length from the width, height, and depth fields. - -// ========================================================== -// Internal functions -// ========================================================== - -static void -SwapLong(DWORD *lp) { - // Byte Swapping Support - - register BYTE *cp = (BYTE*) lp; - - BYTE t; - - t = cp[3]; cp[3] = cp[0]; cp[0] = t; - t = cp[2]; cp[2] = cp[1]; cp[1] = t; -} - -static void -ReadData(FreeImageIO &io, fi_handle handle, BYTE *buf, DWORD length, BOOL rle) { - // Read either Run-Length Encoded or normal image data - - static BYTE repchar, remaining= 0; - - if (rle) { - // Run-length encoded read - - while(length--) { - if (remaining) { - remaining--; - *(buf++)= repchar; - } else { - io.read_proc(&repchar, 1, 1, handle); - - if (repchar == RESC) { - io.read_proc(&remaining, 1, 1, handle); - - if (remaining == 0) { - *(buf++)= RESC; - } else { - io.read_proc(&repchar, 1, 1, handle); - - *(buf++)= repchar; - } - } else { - *(buf++)= repchar; - } - } - } - } else { - // Normal read - - io.read_proc(buf, length, 1, handle); - } -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "RAS"; -} - -static const char * DLL_CALLCONV -Description() { - return "Sun Raster Image"; -} - -static const char * DLL_CALLCONV -Extension() { - return "ras"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - BYTE ras_signature[] = { 0x59, 0xA6, 0x6A, 0x95 }; - BYTE signature[4] = { 0, 0, 0, 0 }; - - io.read_proc(signature, 1, sizeof(ras_signature), handle); - - return (memcmp(ras_signature, signature, sizeof(ras_signature)) == 0); -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - Sun_Header header; // Sun file header - WORD linelength; // Length of raster line in bytes - WORD fill; // Number of fill bytes per raster line - BOOL rle; // TRUE if RLE file - BOOL isRGB; // TRUE if file type is RT_FORMAT_RGB - BYTE fillchar; - - FIBITMAP *dib = NULL; - BYTE *bits; // Pointer to dib data - WORD x, y; - - if (handle) { - try { - // Read SUN raster header - - io.read_proc(&header, sizeof(Sun_Header), 1, handle); - - // SUN rasterfiles are big endian only - - SwapLong(&header.magic); - SwapLong(&header.width); - SwapLong(&header.height); - SwapLong(&header.depth); - SwapLong(&header.length); - SwapLong(&header.type); - SwapLong(&header.maptype); - SwapLong(&header.maplength); - - // Verify SUN identifier - - if (header.magic != RAS_MAGIC) - throw "Invalid magic number"; - - // Allocate a new DIB - - switch(header.depth) { - case 1: - case 8: - dib = freeimage.allocate_proc(header.width, header.height, header.depth); - break; - - case 24: - case 32: - dib = freeimage.allocate_proc(header.width, header.height, header.depth, 0xFF, 0xFF00, 0xFF0000); - break; - } - - if (dib == NULL) - throw "DIB allocation failed"; - - // Check the file format - - rle = FALSE; - isRGB = FALSE; - - switch(header.type) { - case RT_OLD: - case RT_STANDARD: - break; - - case RT_BYTE_ENCODED: - rle = TRUE; - break; - - case RT_FORMAT_RGB: - isRGB = TRUE; - break; - - case RT_FORMAT_TIFF: // I don't even know what these format are... - case RT_FORMAT_IFF: - - default: - throw "Unsupported Sun rasterfile"; - } - - // set up the colormap if needed - - switch(header.maptype) { - case RMT_NONE : - { - if (header.depth < 24) { - // Create linear color ramp - - RGBQUAD *pal = freeimage.get_palette_proc(dib); - - int numcolors = 1 << header.depth; - - for (int i = 0; i < numcolors; i++) { - pal[i].rgbRed = (255 * i) / (numcolors - 1); - pal[i].rgbGreen = (255 * i) / (numcolors - 1); - pal[i].rgbBlue = (255 * i) / (numcolors - 1); - } - } - - break; - } - - case RMT_EQUAL_RGB: - { - BYTE *r, *g, *b; - - // Read SUN raster colormap - - int numcolors = 1 << header.depth; - - r = (BYTE*)malloc(3 * numcolors * sizeof(BYTE)); - g = r + numcolors; - b = g + numcolors; - - RGBQUAD *pal = freeimage.get_palette_proc(dib); - - io.read_proc(r, 3 * numcolors, 1, handle); - - for (int i = 0; i < numcolors; i++) { - pal[i].rgbRed = r[i]; - pal[i].rgbGreen = g[i]; - pal[i].rgbBlue = b[i]; - } - - free(r); - break; - } - - case RMT_RAW: - { - BYTE *colormap; - - // Read (skip) SUN raster colormap. - - colormap = (BYTE *)malloc(header.maplength * sizeof(BYTE)); - - io.read_proc(colormap, header.maplength, 1, handle); - - free(colormap); - break; - } - } - - // Calculate the line + pitch - // Each row is multiple of 16 bits (2 bytes). - - if (header.depth == 1) - linelength = (WORD)((header.width / 8) + (header.width % 8 ? 1 : 0)); - else - linelength = (WORD)header.width; - - fill = (linelength % 2) ? 1 : 0; - - int pitch = freeimage.get_pitch_proc(dib); - - // Read the image data - - switch(header.depth) { - case 1: - case 8: - { - bits = freeimage.get_bits_proc(dib) + (header.height - 1) * pitch; - - for (y = 0; y < header.height; y++) { - ReadData(io, handle, bits, linelength, rle); - - bits -= pitch; - - if (fill) - ReadData(io, handle, &fillchar, fill, rle); - } - - break; - } - - case 24: - { - BYTE *buf, *bp; - - buf = (BYTE*)malloc(header.width * 3); - - for (y = 0; y < header.height; y++) { - bits = freeimage.get_bits_proc(dib) + (header.height - 1 - y) * pitch; - - ReadData(io, handle, buf, header.width * 3, rle); - - bp = buf; - - if (isRGB) { - for (x = 0; x < header.width; x++) { - bits[2] = *(bp++); // red - bits[1] = *(bp++); // green - bits[0] = *(bp++); // blue - - bits += 3; - } - } else { - for (x = 0; x < header.width; x++) { - bits[2] = *(bp + 2); // red - bits[1] = *(bp + 1); // green - bits[0] = *bp; // blue - - bits += 3; bp += 3; - } - } - - if (fill) - ReadData(io, handle, &fillchar, fill, rle); - } - - free(buf); - break; - } - - case 32: - { - BYTE *buf, *bp; - - buf = (BYTE*)malloc(header.width * 4); - - for (y = 0; y < header.height; y++) { - bits = freeimage.get_bits_proc(dib) + (header.height - 1 - y) * pitch; - - ReadData(io, handle, buf, header.width * 4, rle); - - bp = buf; - - if (isRGB) { - for (x = 0; x < header.width; x++) { - bp++; // skip byte - - bits[2] = *(bp++); // red - bits[1] = *(bp++); // green - bits[0] = *(bp++); // blue - - bits += 4; - } - } - else { - for (x = 0; x < header.width; x++) { - bits[2] = *(bp + 3); // red - bits[1] = *(bp + 2); // green - bits[0] = *(bp + 1); // blue - - bits += 4; - bp += 4; - } - } - - if (fill) - ReadData(io, handle, &fillchar, fill, rle); - } - - free(buf); - break; - } - } - - return dib; - - } catch (char *text) { - freeimage.output_message_proc(s_format_id, text); - - return NULL; - } - - } - - return NULL; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitRAS(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; - plugin.validate_proc = Validate; -} diff --git a/freeimage241/Source/FreeImage/PluginTARGA.cpp b/freeimage241/Source/FreeImage/PluginTARGA.cpp deleted file mode 100644 index 7f6fd9b..0000000 --- a/freeimage241/Source/FreeImage/PluginTARGA.cpp +++ /dev/null @@ -1,839 +0,0 @@ -// ========================================================== -// TARGA Loader -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Jani Kajala (janik@remedy.fi) -// - Martin Weber (martweb@gmx.net) -// - Machiel ten Brinke (brinkem@uni-one.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- -// Constants + headers -// ---------------------------------------------------------- - -#ifdef WIN32 -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif - -typedef struct tagRGBTRIPLE { - BYTE rgbtBlue; - BYTE rgbtGreen; - BYTE rgbtRed; -} RGBTRIPLE; - -typedef struct tagBGRAQUAD { - BYTE bgraBlue; - BYTE bgraGreen; - BYTE bgraRed; - BYTE bgraAlpha; -} BGRAQUAD; - -struct tagTGAHEADER { - BYTE id_length; - BYTE color_map_type; - BYTE image_type; - - WORD cm_first_entry; - WORD cm_length; - BYTE cm_size; - - WORD is_xorigin; - WORD is_yorigin; - WORD is_width; - WORD is_height; - BYTE is_pixel_depth; - BYTE is_image_descriptor; -}; - -#ifdef WIN32 -#pragma pack(pop) -#else -#pragma pack(4) -#endif - -// ========================================================== -// Internal functions -// ========================================================== - -static BYTE * -Internal_GetScanLine(FreeImage &freeimage, FIBITMAP *dib, int scanline, int flipvert) { - //assert ((scanline >= 0) && (scanline < (int)freeimage.get_height_proc(dib))); - - if (flipvert) { - return freeimage.get_scanline_proc(dib, scanline); - } else { - return freeimage.get_scanline_proc(dib, freeimage.get_height_proc(dib) - scanline - 1); - } -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "TARGA"; -} - -static const char * DLL_CALLCONV -Description() { - return "Truevision Targa"; -} - -static const char * DLL_CALLCONV -Extension() { - return "tga,targa"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - if (handle) { - try { - // remember the start offset - - long start_offset = io.tell_proc(handle); - - // read and process the bitmap's header - - FIBITMAP *dib = NULL; - tagTGAHEADER header; - - io.read_proc(&header, sizeof(tagTGAHEADER), 1, handle); - - int line = CalculateLine(header.is_width, header.is_pixel_depth); - int pitch = CalculatePitch(line); - int alphabits = header.is_image_descriptor & 0x0f; - int fliphoriz = (header.is_image_descriptor & 0x10) ? 0 : 1; - int flipvert = (header.is_image_descriptor & 0x20) ? 1 : 0; - - io.seek_proc(handle, header.id_length, SEEK_CUR); - switch (header.is_pixel_depth) { - case 8 : - { - dib = freeimage.allocate_proc(header.is_width, header.is_height, 8); - - if (dib == NULL) { - throw "DIB allocation failed"; - } - - // read the palette - - RGBQUAD *palette = freeimage.get_palette_proc(dib); - - if (header.color_map_type == 0) - for (unsigned i = 0; i < 256; i++) { - palette[i].rgbRed = i; - palette[i].rgbGreen = i; - palette[i].rgbBlue = i; - } - else if (alphabits) { - for (unsigned count = header.cm_first_entry; count < header.cm_length; count++) { - BGRAQUAD quad; - - io.read_proc(&quad, sizeof(RGBTRIPLE), 1, handle); - - palette[count].rgbBlue = quad.bgraBlue; - palette[count].rgbRed = quad.bgraRed; - palette[count].rgbGreen = quad.bgraGreen; - palette[count].rgbReserved = quad.bgraAlpha; - } - } - else { - for (unsigned count = header.cm_first_entry; count < header.cm_length; count++) { - RGBTRIPLE triple; - - io.read_proc(&triple, sizeof(RGBTRIPLE), 1, handle); - - palette[count].rgbRed = triple.rgbtRed; - palette[count].rgbGreen = triple.rgbtGreen; - palette[count].rgbBlue = triple.rgbtBlue; - } - } - - // read in the bitmap bits - switch (header.image_type) { - case 1 : - case 3 : - { - if (fliphoriz) { - for (unsigned count = header.is_height; count > 0; count--) - io.read_proc(Internal_GetScanLine(freeimage, dib, count - 1, flipvert), line, 1, handle); - - } - else { - for (unsigned count = 0; count < header.is_height; count++) - io.read_proc(Internal_GetScanLine(freeimage, dib, count, flipvert), line, 1, handle); - - } - - break; - } - - case 9 : - case 11: - { - int x = 0; - int y = 0; - BYTE *bits; - - if (fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height - y - 1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - - BYTE rle; - - while(1) { - io.read_proc(&rle,1, 1, handle); - - if (rle>127) { - rle -= 127; - - BYTE triple; - - io.read_proc(&triple, 1, 1, handle); - - for (int ix = 0; ix < rle; ix++) { - bits[x++] = triple; - - if (x >= line) { - x = 0; - - y++; - - if (y >= header.is_height) - goto done89; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - } - } - } else { - rle++; - - for (int ix = 0; ix < rle; ix++) { - BYTE triple; - - io.read_proc(&triple, 1, 1, handle); - - bits[x++] = triple; - - if (x >= line) { - x = 0; - - y++; - - if (y >= header.is_height) - goto done89; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - } - } - } - } - done89 : - break; - } - - default : - freeimage.free_proc(dib); - return NULL; - } - - break; - } - - case 15 : - case 16 : - { - int pixel_bits; - - // allocate the dib - - if (TARGA_LOAD_RGB888 & flags) { - pixel_bits = 24; - - dib = freeimage.allocate_proc(header.is_width, header.is_height, pixel_bits, 0xFF, 0xFF00, 0xFF0000); - } else { - pixel_bits = 16; - - dib = freeimage.allocate_proc(header.is_width, header.is_height, pixel_bits, 0x1F, 0x3E0, 0x7C00); - } - - if (dib == NULL) - throw "DIB allocation failed"; - - int line = CalculateLine(header.is_width, pixel_bits); - int pitch = CalculatePitch(line); - - const unsigned pixel_size = unsigned(pixel_bits) / 8; - - // note header.cm_size is a misleading name, it should be seen as header.cm_bits - // ignore current position in file and set filepointer explicitly from the beginning of the file - - int garblen = 0; - - if (header.color_map_type != 0) - garblen = (int)((header.cm_size + 7) / 8) * header.cm_length; /* should byte align */ - else - garblen = 0; - - io.seek_proc(handle, start_offset, SEEK_SET); - io.seek_proc(handle, sizeof(tagTGAHEADER) + header.id_length + garblen, SEEK_SET); - - // read in the bitmap bits - - WORD pixel; - - switch (header.image_type) { - case 2 : - { - for (int y = 0; y < header.is_height; y++) { - BYTE *bits; - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - - for (int x = 0; x < line; ) { - io.read_proc(&pixel, sizeof(WORD), 1, handle); - - if (TARGA_LOAD_RGB888 & flags) { - bits[x + 0] = ((pixel & 0x1F) * 0xFF) / 0x1F; - bits[x + 1] = (((pixel & 0x3E0) >> 5) * 0xFF) / 0x1F; - bits[x + 2] = (((pixel & 0x7C00) >> 10) * 0xFF) / 0x1F; - } else { - *reinterpret_cast(bits + x) = 0x7FFF & pixel; - } - - x += pixel_size; - } - } - - break; - } - - case 10 : - { - int x = 0; - int y = 0; - BYTE rle; - WORD pixel; - - while(1) { - BYTE *bits; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - - io.read_proc(&rle,1, 1, handle); - - // compressed block - - if (rle > 127) { - rle -= 127; - - io.read_proc(&pixel, sizeof(WORD), 1, handle); - - for (int ix = 0; ix < rle; ix++) { - if (TARGA_LOAD_RGB888 & flags) { - bits[x + 0] = ((pixel & 0x1F) * 0xFF) / 0x1F; - bits[x + 1] = (((pixel & 0x3E0) >> 5) * 0xFF) / 0x1F; - bits[x + 2] = (((pixel & 0x7C00) >> 10) * 0xFF) / 0x1F; - } else { - *reinterpret_cast(bits + x) = 0x7FFF & pixel; - } - - x += pixel_size; - - if (x >= line) { - x = 0; - y++; - - if (y >= header.is_height) - goto done2; - } - } - } else { - rle++; - - for (int ix = 0; ix < rle; ix++) { - io.read_proc(&pixel, sizeof(WORD), 1, handle); - - if (TARGA_LOAD_RGB888 & flags) { - bits[x + 0] = ((pixel & 0x1F) * 0xFF) / 0x1F; - bits[x + 1] = (((pixel & 0x3E0) >> 5) * 0xFF) / 0x1F; - bits[x + 2] = (((pixel & 0x7C00) >> 10) * 0xFF) / 0x1F; - } else { - *reinterpret_cast(bits + x) = 0x7FFF & pixel; - } - - x += pixel_size; - - if (x >= line) { - x = 0; - y++; - - if (y >= header.is_height) - goto done2; - } - } - } - } - - done2 : - break; - } - - default : - freeimage.free_proc(dib); - return NULL; - } - - break; - } - - case 24 : - { - dib = freeimage.allocate_proc(header.is_width, header.is_height, 24, 0xFF, 0xFF00, 0xFF0000); - - if (dib == 0) - throw "DIB allocation failed"; - - // read in the bitmap bits - - switch (header.image_type) { - case 2 : - { - if (fliphoriz) - for (unsigned count = header.is_height; count > 0; count--) { - BYTE *bits = bits = Internal_GetScanLine(freeimage, dib, count-1, flipvert); - - io.read_proc(bits, line, 1, handle); - - bits += pitch; - } - else - for (unsigned count = 0; count < header.is_height; count++) { - BYTE *bits = bits = Internal_GetScanLine(freeimage, dib, count, flipvert); - - io.read_proc(bits, line, 1, handle); - - bits += pitch; - } - - break; - } - - case 10 : - { - int x = 0; - int y = 0; - BYTE rle; - BYTE *bits; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - - if (alphabits) { - while(1) { - io.read_proc(&rle,1, 1, handle); - - if (rle>127) { - rle -= 127; - - BGRAQUAD quad; - - io.read_proc(&quad, sizeof(BGRAQUAD), 1, handle); - - for (int ix = 0; ix < rle; ix++) { - bits[x++] = quad.bgraBlue; - bits[x++] = quad.bgraGreen; - bits[x++] = quad.bgraRed; - bits[x++] = quad.bgraAlpha; - - if (x >= line) { - x = 0; - y++; - - if (y >= header.is_height) - goto done243; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - } - } - } else { - rle++; - - for (int ix = 0; ix < rle; ix++) { - BGRAQUAD quad; - - io.read_proc(&quad, sizeof(BGRAQUAD), 1, handle); - - bits[x++] = quad.bgraBlue; - bits[x++] = quad.bgraGreen; - bits[x++] = quad.bgraRed; - bits[x++] = quad.bgraAlpha; - - if (x >= line) { - x = 0; - y++; - - if (y >= header.is_height) - goto done243; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - } - } - } - } - } else { - while (1) { - io.read_proc(&rle,1, 1, handle); - - if (rle>127) { - rle -= 127; - - RGBTRIPLE triple; - - io.read_proc(&triple, sizeof(RGBTRIPLE), 1, handle); - - for (int ix = 0; ix < rle; ix++) { - bits[x++] = triple.rgbtBlue; - bits[x++] = triple.rgbtGreen; - bits[x++] = triple.rgbtRed; - - if (x >= line) { - x = 0; - y++; - - if (y >= header.is_height) - goto done243; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - } - } - } else { - rle++; - - for (int ix = 0; ix < rle; ix++) { - RGBTRIPLE triple; - - io.read_proc(&triple, sizeof(RGBTRIPLE), 1, handle); - - bits[x++] = triple.rgbtBlue; - bits[x++] = triple.rgbtGreen; - bits[x++] = triple.rgbtRed; - - if (x >= line) { - x = 0; - y++; - - if (y >= header.is_height) - goto done243; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - } - } - } - } - } - done243 : - break; - } - - default : - freeimage.free_proc(dib); - return NULL; - } - - break; - } - - case 32 : - { - int pixel_bits; - - if (TARGA_LOAD_RGB888 & flags) { - pixel_bits = 24; - - line = CalculateLine(header.is_width, pixel_bits); - pitch = CalculatePitch(line); - } else { - pixel_bits = 32; - } - - const unsigned pixel_size = unsigned (pixel_bits) / 8; - - // Allocate the DIB - - dib = freeimage.allocate_proc(header.is_width, header.is_height, pixel_bits, 0xFF, 0xFF00, 0xFF0000); - - if (dib == 0) - throw "DIB allocation failed"; - - // read in the bitmap bits - - switch (header.image_type) { - case 2 : - { - // uncompressed - - if (alphabits) { - if (fliphoriz) - for (unsigned count = header.is_height; count > 0; count--) { - BYTE *bits = bits = Internal_GetScanLine(freeimage, dib, count-1, flipvert); - - for (unsigned cols = 0; cols < header.is_width; cols++) { - RGBQUAD rgb; - - io.read_proc(&rgb, sizeof(RGBQUAD), 1, handle); - - bits[0] = rgb.rgbBlue; - bits[1] = rgb.rgbGreen; - bits[2] = rgb.rgbRed; - - if ((TARGA_LOAD_RGB888 & flags) != TARGA_LOAD_RGB888) - bits[3] = rgb.rgbReserved; - - bits += pixel_size; - } - } - else - for (unsigned count = 0; count < header.is_height; count++) { - BYTE *bits = Internal_GetScanLine(freeimage, dib, count, flipvert); - - for (unsigned cols = 0; cols < header.is_width; cols++) { - RGBQUAD rgb; - - io.read_proc(&rgb, sizeof(RGBQUAD), 1, handle); - - bits[0] = rgb.rgbBlue; - bits[1] = rgb.rgbGreen; - bits[2] = rgb.rgbRed; - - if ((TARGA_LOAD_RGB888 & flags) != TARGA_LOAD_RGB888) - bits[3] = rgb.rgbReserved; - - bits += pixel_size; - } - } - - } else { - if (fliphoriz) - for (unsigned count = header.is_height; count > 0; count--) { - BYTE *bits; - - if (fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-count, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, count-1, flipvert); - - for (unsigned cols = 0; cols < header.is_width; cols++) { - RGBQUAD rgb; - - io.read_proc(&rgb, sizeof(RGBQUAD), 1, handle); - - bits[0] = rgb.rgbBlue; - bits[1] = rgb.rgbGreen; - bits[2] = rgb.rgbRed; - - if ((TARGA_LOAD_RGB888 & flags) != TARGA_LOAD_RGB888) - bits[3] = rgb.rgbReserved; - - bits += pixel_size; - } - } - else - for (unsigned count = 0; count < header.is_height; count++) { - BYTE *bits; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-count-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, count, flipvert); - - for (unsigned cols = 0; cols < header.is_width; cols++) { - RGBQUAD rgb; - - io.read_proc(&rgb, sizeof(RGBQUAD), 1, handle); - - bits[0] = rgb.rgbBlue; - bits[1] = rgb.rgbGreen; - bits[2] = rgb.rgbRed; - - if ((TARGA_LOAD_RGB888 & flags) != TARGA_LOAD_RGB888) - bits[3] = rgb.rgbReserved; - - bits += pixel_size; - } - } - } - - break; - } - case 10: - { - int x = 0; - int y = 0; - BYTE rle; - BYTE *bits; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - - while(1) { - io.read_proc(&rle,1, 1, handle); - - if (rle>127) { - rle -= 127; - - BGRAQUAD quad; - - io.read_proc(&quad, sizeof(BGRAQUAD), 1, handle); - - for (int ix = 0; ix < rle; ix++) { - bits[x++] = quad.bgraBlue; - bits[x++] = quad.bgraGreen; - bits[x++] = quad.bgraRed; - bits[x++] = quad.bgraAlpha; - - if (x >= line) { - x = 0; - y++; - - if (y >= header.is_height) - goto done3210; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - } - } - } else { - rle++; - - for (int ix = 0; ix < rle; ix++) { - BGRAQUAD quad; - - io.read_proc(&quad, sizeof(BGRAQUAD), 1, handle); - - bits[x++] = quad.bgraBlue; - bits[x++] = quad.bgraGreen; - bits[x++] = quad.bgraRed; - bits[x++] = quad.bgraAlpha; - - if (x >= line) { - x = 0; - y++; - - if (y >= header.is_height) - goto done3210; - - if(fliphoriz) - bits = Internal_GetScanLine(freeimage, dib, header.is_height-y-1, flipvert); - else - bits = Internal_GetScanLine(freeimage, dib, y, flipvert); - } - } - } - } - - done3210 : - break; - } - - default : - freeimage.free_proc(dib); - return NULL; - } - - break; - } - } - - return (FIBITMAP *)dib; - - } catch(char *message) { - freeimage.output_message_proc(s_format_id, message); - - return NULL; - } - } - - return NULL; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitTARGA(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; -} diff --git a/freeimage241/Source/FreeImage/PluginTIFF.cpp b/freeimage241/Source/FreeImage/PluginTIFF.cpp deleted file mode 100644 index f6d8736..0000000 --- a/freeimage241/Source/FreeImage/PluginTIFF.cpp +++ /dev/null @@ -1,789 +0,0 @@ -// ========================================================== -// TIFF Loader and Writer -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@iut.univ-lehavre.fr) -// - Markus Loibl (markus.loibl@epost.de) -// - Luca Piergentili (l.pierge@terra.es) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifdef unix -#undef unix -#endif -#ifdef __unix -#undef __unix -#endif - -#include "../LibTIFF/tiffiop.h" - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- - -static FreeImageIO *g_io = NULL; - -// ---------------------------------------------------------- -// libtiff interface -// ---------------------------------------------------------- - -static tsize_t -_tiffReadProc(thandle_t file, tdata_t buf, tsize_t size) { - return g_io->read_proc(buf, size, 1, (fi_handle)file) * size; -} - -static tsize_t -_tiffWriteProc(thandle_t file, tdata_t buf, tsize_t size) { - return g_io->write_proc(buf, size, 1, (fi_handle)file) * size; -} - -static toff_t -_tiffSeekProc(thandle_t file, toff_t off, int whence) { - g_io->seek_proc((fi_handle)file, off, whence); - return g_io->tell_proc((fi_handle)file); -} - -static int -_tiffCloseProc(thandle_t fd) { - return 0; -} - -#include - -static toff_t -_tiffSizeProc(thandle_t file) { - struct stat sb; - return (fstat((int) file, &sb) < 0 ? 0 : sb.st_size); -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) { - return 0; -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) { -} - -// ---------------------------------------------------------- -// Open a TIFF file descriptor for read/writing. -// ---------------------------------------------------------- - -TIFF * -TIFFFdOpen(thandle_t handle, const char *name, const char *mode) { - TIFF *tif; - - tif = TIFFClientOpen(name, mode, handle, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - - if (tif) - tif->tif_fd = (int)handle; - - return tif; -} - -// ---------------------------------------------------------- -// Open a TIFF file for read/writing. -// ---------------------------------------------------------- - -TIFF* -TIFFOpen(const char* name, const char* mode) { - return 0; -} - -tdata_t -_TIFFmalloc(tsize_t s) { - return malloc(s); -} - -void -_TIFFfree(tdata_t p) { - free(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) { - return realloc(p, s); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) { - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) { - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) { - return (memcmp(p1, p2, (size_t) c)); -} - -// ---------------------------------------------------------- -// in FreeImage warnings and errors are disabled -// ---------------------------------------------------------- - -static void -msdosWarningHandler(const char* module, const char* fmt, va_list ap) { -} - -TIFFErrorHandler _TIFFwarningHandler = msdosWarningHandler; - -static void -msdosErrorHandler(const char* module, const char* fmt, va_list ap) { -} - -TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler; - -// ---------------------------------------------------------- - -#define CVT(x) (((x) * 255L) / ((1L<<16)-1)) -#define SCALE(x) (((x)*((1L<<16)-1))/255) - -// ========================================================== -// Internal functions -// ========================================================== - -static uint16 -CheckColormap(int n, uint16* r, uint16* g, uint16* b) { - while (n-- > 0) { - if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) { - return 16; - } - } - - return 8; -} - -static uint16 -CheckPhotometric(FreeImage &freeimage, FIBITMAP *dib, uint16 bitspersample) { - RGBQUAD *rgb; - uint16 i; - - switch(bitspersample) { - case 1: - { - rgb = freeimage.get_palette_proc(dib); - - if ((rgb->rgbRed == 0) && (rgb->rgbGreen == 0) && (rgb->rgbBlue == 0)) { - rgb++; - - if ((rgb->rgbRed == 255) && (rgb->rgbGreen == 255) && (rgb->rgbBlue == 255)) - return PHOTOMETRIC_MINISBLACK; - } - - if ((rgb->rgbRed == 255) && (rgb->rgbGreen == 255) && (rgb->rgbBlue == 255)) { - rgb++; - - if ((rgb->rgbRed == 0) && (rgb->rgbGreen == 0) && (rgb->rgbBlue == 0)) - return PHOTOMETRIC_MINISWHITE; - } - - return PHOTOMETRIC_PALETTE; - } - - case 4: // Check if the DIB has a color or a greyscale palette - case 8: - rgb = freeimage.get_palette_proc(dib); - - for (i = 0; i < freeimage.get_colors_used_proc(dib); i++) { - if ((rgb->rgbRed != rgb->rgbGreen) || (rgb->rgbRed != rgb->rgbBlue)) - return PHOTOMETRIC_PALETTE; - - // The DIB has a color palette if the greyscale isn't a linear ramp - - if (rgb->rgbRed != i) - return PHOTOMETRIC_PALETTE; - - rgb++; - } - - return PHOTOMETRIC_MINISBLACK; - - case 24: - return PHOTOMETRIC_RGB; - } - - return PHOTOMETRIC_MINISBLACK; -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "TIFF"; -} - -static const char * DLL_CALLCONV -Description() { - return "Tagged Image File Format"; -} - -static const char * DLL_CALLCONV -Extension() { - return "tif,tiff"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return "^[MI][MI][\\x01*][\\x01*]"; -} - -static const char * DLL_CALLCONV -MimeType() { - return "image/tiff"; -} - -static BOOL DLL_CALLCONV -Validate(FreeImageIO &io, fi_handle handle) { - BYTE tiff_id1[] = { 0x49, 0x49 }; - BYTE tiff_id2[] = { 0x4D, 0x4D }; - BYTE signature[2] = { 0, 0 }; - - io.read_proc(signature, 1, sizeof(tiff_id1), handle); - - if (memcmp(tiff_id1, signature, sizeof(tiff_id1)) == 0) - return TRUE; - - if (memcmp(tiff_id2, signature, sizeof(tiff_id1)) == 0) - return TRUE; - - return FALSE; -} - -// ---------------------------------------------------------- - -static void * DLL_CALLCONV -Open(FreeImageIO &io, fi_handle handle, BOOL read) { - g_io = &io; - - if (read) - return TIFFFdOpen((thandle_t)handle, "", "r"); - else - return TIFFFdOpen((thandle_t)handle, "", "w"); -} - -static void DLL_CALLCONV -Close(FreeImageIO &io, fi_handle handle, void *data) { - TIFFClose((TIFF *)data); - - g_io = NULL; -} - -// ---------------------------------------------------------- - -static int DLL_CALLCONV -PageCount(FreeImageIO &io, fi_handle handle, void *data) { - int nr_ifd = 0; - - TIFF *tif = (TIFF *)data; - - do { - nr_ifd++; - } while (TIFFReadDirectory(tif)); - - return nr_ifd; -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data) { - if ((handle != NULL) && (data != NULL)) { - TIFF *tif; - uint32 height; - uint32 width; - uint16 bitspersample; - uint16 samplesperpixel; - uint32 rowsperstrip; - uint16 photometric; - uint16 compression; - uint32 x, y; - BOOL isRGB; - - int32 nrow; - BYTE *buf; - FIBITMAP *dib; - BYTE *bits; // pointer to dib data - RGBQUAD *pal; // pointer to dib palette - - if (handle) { - try { - tif = (TIFF *)data; - - if (page != -1) - if (!tif || !TIFFSetDirectory(tif, page)) - throw "Error encountered while opening TIFF file"; - - TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression); - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); - TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); - TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample); - TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric); - - if (compression == COMPRESSION_LZW) - throw "LZW compression is no longer supported due to Unisys patent enforcement"; - - // Convert to 24 or 32 bits RGB if the image is full color - - isRGB = (bitspersample >= 8) && - (photometric == PHOTOMETRIC_RGB) || - (photometric == PHOTOMETRIC_YCBCR) || - (photometric == PHOTOMETRIC_SEPARATED) || - (photometric == PHOTOMETRIC_LOGLUV); - - if (isRGB) { - // Read the whole image into one big RGBA buffer and then - // convert it to a DIB. This is using the traditional - // TIFFReadRGBAImage() API that we trust. - - uint32* raster; // retrieve RGBA image - uint32 *row; - - raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32)); - - if (raster == NULL) { - throw "No space for raster buffer"; - } - - // Read the image in one chunk into an RGBA array - - if(!TIFFReadRGBAImage(tif, width, height, raster, 0)) { - _TIFFfree(raster); - return NULL; - } - - // create a new DIB - - if (samplesperpixel == 4) - dib = freeimage.allocate_proc(width, height, 32, 0xFF, 0xFF00, 0xFF0000); - else - dib = freeimage.allocate_proc(width, height, 24, 0xFF, 0xFF00, 0xFF0000); - - if (dib == NULL) { - _TIFFfree(raster); - - throw "DIB allocation failed"; - } - - // fill in the metrics (english or universal) - - float fResX, fResY; - uint16 resUnit; - TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &resUnit); - TIFFGetField(tif, TIFFTAG_XRESOLUTION, &fResX); - TIFFGetField(tif, TIFFTAG_YRESOLUTION, &fResY); - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - - if (resUnit == RESUNIT_INCH) { - pInfoHeader->biXPelsPerMeter = (int) (fResX/0.0254000 + 0.5); - pInfoHeader->biYPelsPerMeter = (int) (fResY/0.0254000 + 0.5); - } else if(resUnit == RESUNIT_CENTIMETER) { - pInfoHeader->biXPelsPerMeter = (int) (fResX*100.0 + 0.5); - pInfoHeader->biYPelsPerMeter = (int) (fResY*100.0 + 0.5); - } - - // read the raster lines and save them in the DIB - // with RGB mode, we have to change the order of the 3 samples RGB - // We use macros for extracting components from the packed ABGR - // form returned by TIFFReadRGBAImage. - - BOOL has_alpha = FALSE; - row = &raster[0]; - - for (y = 0; y < height; y++) { - bits = freeimage.get_scanline_proc(dib, y); - - for (x = 0; x < width; x++) { - bits[0] = (BYTE)TIFFGetB(row[x]); - bits[1] = (BYTE)TIFFGetG(row[x]); - bits[2] = (BYTE)TIFFGetR(row[x]); - - if (samplesperpixel == 4) { - bits[3] = (BYTE)TIFFGetA(row[x]); - - if (bits[3] != 0) { - has_alpha = TRUE; - } - - bits += 4; - } else { - bits += 3; - } - } - - row += width; - } - - freeimage.set_transparent_proc(dib, has_alpha); - - _TIFFfree(raster); - - return (FIBITMAP *)dib; - } else { - // calculate the line + pitch - - int line = CalculateLine(width, bitspersample * samplesperpixel); - int pitch = CalculatePitch(line); - - // create a new DIB - - dib = freeimage.allocate_proc(width, height, bitspersample * samplesperpixel); - - if (dib == NULL) { - throw "No space for DIB image"; - } - - float fResX, fResY; - uint16 resUnit; - TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &resUnit); - TIFFGetField(tif, TIFFTAG_XRESOLUTION, &fResX); - TIFFGetField(tif, TIFFTAG_YRESOLUTION, &fResY); - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - - if (resUnit == RESUNIT_INCH) { - /* english */ - - pInfoHeader->biXPelsPerMeter = (int) (fResX/0.0254000 + 0.5); - pInfoHeader->biYPelsPerMeter = (int) (fResY/0.0254000 + 0.5); - } else if (resUnit== RESUNIT_CENTIMETER) { - /* metric */ - - pInfoHeader->biXPelsPerMeter = (int) (fResX*100.0 + 0.5); - pInfoHeader->biYPelsPerMeter = (int) (fResY*100.0 + 0.5); - } - - // In the tiff file the lines are save from up to down - // In a DIB the lines must be save from down to up - - bits = freeimage.get_bits_proc(dib) + height * pitch; - - // now lpBits pointe on the bottom line - - // set up the colormap based on photometric - - pal = freeimage.get_palette_proc(dib); - - switch(photometric) { - case PHOTOMETRIC_MINISBLACK: // bitmap and greyscale image types - case PHOTOMETRIC_MINISWHITE: - // Monochrome image - - if (bitspersample == 1) { - if (photometric == PHOTOMETRIC_MINISBLACK) { - pal[0].rgbRed = 0; - pal[0].rgbGreen = 0; - pal[0].rgbBlue = 0; - pal[1].rgbRed = 255; - pal[1].rgbGreen = 255; - pal[1].rgbBlue = 255; - } else { - pal[0].rgbRed = 255; - pal[0].rgbGreen = 255; - pal[0].rgbBlue = 255; - pal[1].rgbRed = 0; - pal[1].rgbGreen = 0; - pal[1].rgbBlue = 0; - } - } else { - // need to build the scale for greyscale images - - if (photometric == PHOTOMETRIC_MINISBLACK) { - for (int i = 0; i < 256; i++) { - pal[i].rgbRed = - pal[i].rgbGreen = - pal[i].rgbBlue = i; - } - } else { - for (int i = 0; i < 256; i++) { - pal[i].rgbRed = - pal[i].rgbGreen = - pal[i].rgbBlue = 255 - i; - } - } - } - - break; - - case PHOTOMETRIC_PALETTE: // color map indexed - uint16 *red; - uint16 *green; - uint16 *blue; - BOOL Palette16Bits; - - TIFFGetField(tif, TIFFTAG_COLORMAP, &red, &green, &blue); - - // Is the palette 16 or 8 bits ? - - if (CheckColormap(1<= 0; i--) { - if (Palette16Bits) { - pal[i].rgbRed =(BYTE) CVT(red[i]); - pal[i].rgbGreen = (BYTE) CVT(green[i]); - pal[i].rgbBlue = (BYTE) CVT(blue[i]); - } else { - pal[i].rgbRed = (BYTE) red[i]; - pal[i].rgbGreen = (BYTE) green[i]; - pal[i].rgbBlue = (BYTE) blue[i]; - } - } - - break; - - } - - // read the tiff lines and save them in the DIB - - buf = new BYTE[TIFFStripSize(tif)]; - - for (y = 0; y < height; y += rowsperstrip) { - nrow = (y + rowsperstrip > height ? height - y : rowsperstrip); - - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, y, 0), buf, nrow * line) == -1) { - delete [] buf; - - return NULL; - } else { - for (int l = 0; l < nrow; l++) { - bits -= pitch; - - memcpy(bits, buf + l * line, line); - } - } - } - - delete [] buf; - - return (FIBITMAP *)dib; - - } - } catch (char *message) { - freeimage.output_message_proc(s_format_id, message); - - return NULL; - } - } - } - - return NULL; -} - -static BOOL DLL_CALLCONV -Save(FreeImage &freeimage, FreeImageIO &io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - if (dib != NULL) { - TIFF *out = (TIFF *)data; - - uint32 height; - uint32 width; - uint32 rowsperstrip = (uint32) -1; - uint16 bitspersample; - uint16 samplesperpixel; - uint16 photometric; - uint16 compression; - uint16 pitch; - - uint32 x, y; - - width = freeimage.get_width_proc(dib); - height = freeimage.get_height_proc(dib); - bitspersample = freeimage.get_bpp_proc(dib); - samplesperpixel = ((bitspersample == 24) || (bitspersample == 32)) ? 3 : 1; - photometric = CheckPhotometric(freeimage, dib, (bitspersample == 32) ? 24 : bitspersample); - - // don't accept ALPHA at this moment - - if ((bitspersample == 32) && (freeimage.is_transparent_proc(dib))) - throw "alpha channels are currently unsupported"; - - // handle standard width/height/bpp stuff - - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, height); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, ((bitspersample == 32) ? 24 : bitspersample) / samplesperpixel); - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); // single image plane - TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, rowsperstrip)); - - // handle metrics - - BITMAPINFOHEADER *pInfoHeader = freeimage.get_info_header_proc(dib); - TIFFSetField(out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); - TIFFSetField(out, TIFFTAG_XRESOLUTION, 0.0254*((float)pInfoHeader->biXPelsPerMeter)); - TIFFSetField(out, TIFFTAG_YRESOLUTION, 0.0254*((float)pInfoHeader->biYPelsPerMeter)); - - // multi-paging - - if (page >= 0) { - char page_number[20]; - sprintf(page_number, "Page %d", page); - - TIFFSetField(out, TIFFTAG_SUBFILETYPE, FILETYPE_PAGE); - TIFFSetField(out, TIFFTAG_PAGENUMBER, page); - TIFFSetField(out, TIFFTAG_PAGENAME, page_number); - } else { - TIFFSetField(out, TIFFTAG_SUBFILETYPE, 0); - } - - // palettes (image colormaps are automatically scaled to 16-bits) - - if (photometric == PHOTOMETRIC_PALETTE) { - uint16 *r, *g, *b; - uint16 nColors = freeimage.get_colors_used_proc(dib); - RGBQUAD *pal = freeimage.get_palette_proc(dib); - - r = (uint16 *) _TIFFmalloc(sizeof(uint16) * 3 * nColors); - g = r + nColors; - b = g + nColors; - - for (int i = nColors - 1; i >= 0; i--) { - r[i] = SCALE((uint16)pal[i].rgbRed); - g[i] = SCALE((uint16)pal[i].rgbGreen); - b[i] = SCALE((uint16)pal[i].rgbBlue); - } - - TIFFSetField(out, TIFFTAG_COLORMAP, r, g, b); - - _TIFFfree(r); - } - - // compression - - switch(bitspersample) { - case 1 : - compression = COMPRESSION_CCITTFAX4; - break; - - case 8 : - case 24 : - case 32 : - compression = COMPRESSION_PACKBITS; - break; - - default : - compression = COMPRESSION_NONE; - break; - } - - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - - // read the DIB lines from bottom to top - // and save them in the TIF - // ------------------------------------- - - pitch = freeimage.get_pitch_proc(dib); - - switch(bitspersample) { - case 1 : - case 4 : - case 8 : - { - for (y = 0; y < height; y++) { - BYTE *bits = freeimage.get_bits_row_col_proc(dib, 0, y); - - TIFFWriteScanline(out,bits, y, 0); - } - - break; - } - - case 24: - case 32 : - { - BYTE *buffer = (BYTE *)malloc(CalculatePitch(CalculateLine(width, 24))); - - for (y = 0; y < height; y++) { - // get a pointer to the (converted) scanline - - if (bitspersample == 32) - freeimage.convert_line_32to24_proc(buffer, freeimage.get_scanline_proc(dib, height - y - 1), width); - else - memcpy(buffer, freeimage.get_scanline_proc(dib, height - y - 1), pitch); - - // TIFFs store color data RGB instead of BGR - - BYTE *pBuf = buffer; - - for (x = 0; x < width; x++) { - BYTE tmp = pBuf[0]; - pBuf[0] = pBuf[2]; - pBuf[2] = tmp; - - pBuf += 3; - } - - // write the scanline to disc - - TIFFWriteScanline(out, buffer, y, 0); - } - - free(buffer); - - break; - } - } - - return TRUE; - } - - return FALSE; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitTIFF(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.open_proc = Open; - plugin.close_proc = Close; - plugin.pagecount_proc = PageCount; - plugin.load_proc = Load; - plugin.save_proc = Save; - plugin.validate_proc = Validate; - plugin.mime_proc = MimeType; -} diff --git a/freeimage241/Source/FreeImage/PluginWBMP.cpp b/freeimage241/Source/FreeImage/PluginWBMP.cpp deleted file mode 100644 index b46bc1d..0000000 --- a/freeimage241/Source/FreeImage/PluginWBMP.cpp +++ /dev/null @@ -1,356 +0,0 @@ -// ========================================================== -// Wireless Bitmap Format Loader and Writer -// -// Design and implementation by -// - Hervé Drolon -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#include "FreeImage.h" -#include "Utilities.h" - -// ---------------------------------------------------------- -// Wireless Bitmap Format -// ---------------------- -// The WBMP format enables graphical information to be sent to a variety of handsets. -// The WBMP format is terminal independent and describes only graphical information. - -// IMPLEMENTATION NOTES: -// ------------------------ -// The WBMP format is configured according to a type field value (TypeField below), -// which maps to all relevant image encoding information, such as: -// · Pixel organisation and encoding -// · Palette organisation and encoding -// · Compression characteristics -// · Animation encoding -// For each TypeField value, all relevant image characteristics are -// fully specified as part of the WAP documentation. -// Currently, a simple compact, monochrome image format is defined -// within the WBMP type space : -// -// Image Type Identifier, multi-byte integer 0 -// Image Format description 0 B/W, no compression -// ------------------------------------------------------------------------------- - -// WBMP Header - -#ifdef WIN32 -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif - -typedef struct { - WORD TypeField; // Image type identifier of multi-byte length - BYTE FixHeaderField; // Octet of general header information - BYTE ExtHeaderFields; // Zero or more extension header fields - WORD Width; // Multi-byte width field - WORD Height; // Multi-byte height field -} WBMPHEADER; - -#ifdef WIN32 -#pragma pack(pop) -#else -#pragma pack(4) -#endif - -// The extension headers may be of type binary 00 through binary 11, defined as follows. - -// - Type 00 indicates a multi-byte bitfield used to specify additional header information. -// The first bit is set if a type 00, extension header is set if more data follows. -// The other bits are reserved for future use. -// - Type 01 - reserved for future use. -// - Type 10 - reserved for future use. -// - Type 11 indicates a sequence of parameter/value pairs. These can be used for -// optimisations and special purpose extensions, eg, animation image formats. -// The parameter size tells the length (1-8 bytes) of the following parameter name. -// The value size gives the length (1-16 bytes) of the following parameter value. -// The concatenation flag indicates whether another parameter/value pair will follow -// after reading the specified bytes of data. - -// ========================================================== -// Internal functions -// ========================================================== - -static DWORD -multiByteRead(FreeImageIO &io, fi_handle handle) { - // Multi-byte encoding / decoding - // ------------------------------- - // A multi-byte integer consists of a series of octets, where the most significant bit - // is the continuation flag, and the remaining seven bits are a scalar value. - // The continuation flag is used to indicate that an octet is not the end of the multi-byte - // sequence. - - DWORD Out = 0; - BYTE In = 0; - - while (io.read_proc(&In, 1, 1, handle)) { - Out += (In & 0x7F); - - if ((In & 0x80) == 0x00) { - // Last byte to read - - break; - } - - Out <<= 7; - } - - return Out; -} - -static void -multiByteWrite(FreeImageIO &io, fi_handle handle, DWORD In) { - BYTE Out, k = 1; - - while(In & (0x7F << 7*k)) - k++; - - while(k > 1) { - k--; - Out = (BYTE)(0x80 | (In >> 7*k) & 0xFF); - io.write_proc(&Out, 1, 1, handle); - } - - // Last byte to write - - Out = (BYTE)(In & 0x7F); - - io.write_proc(&Out, 1, 1, handle); -} - -static void -readExtHeader(FreeImageIO &io, fi_handle handle, BYTE b) { - // Extension header fields - // ------------------------ - // Read the extension header fields - // (since we don't use them for the moment, we skip them). - - switch(b & 0x60) { - // Type 00: read multi-byte bitfield - - case 0x00: - { - DWORD info = multiByteRead(io, handle); - } - break; - - // Type 11: read a sequence of parameter/value pairs. - - case 0x60: - { - BYTE sizeParamIdent = (b & 0x70) >> 4; // Size of Parameter Identifier (in bytes) - BYTE sizeParamValue = (b & 0x0F); // Size of Parameter Value (in bytes) - - BYTE *Ident = (BYTE*)malloc(sizeParamIdent * sizeof(BYTE)); - BYTE *Value = (BYTE*)malloc(sizeParamValue * sizeof(BYTE)); - - io.read_proc(Ident, sizeParamIdent, 1, handle); - io.read_proc(Value, sizeParamValue, 1, handle); - - free(Ident); - free(Value); - } - - break; - - // reserved for future use - case 0x20: // Type 01 - case 0x40: // Type 10 - break; - } -} - -// ========================================================== -// Plugin Interface -// ========================================================== - -static int s_format_id; - -// ========================================================== -// Plugin Implementation -// ========================================================== - -static const char * DLL_CALLCONV -Format() { - return "WBMP"; -} - -static const char * DLL_CALLCONV -Description() { - return "Wireless Bitmap"; -} - -static const char * DLL_CALLCONV -Extension() { - return "wbmp,wap"; -} - -static const char * DLL_CALLCONV -RegExpr() { - return NULL; -} - -static const char * DLL_CALLCONV -MimeType() { - return "image/vnd.wap.wbmp"; -} - -// ---------------------------------------------------------- - -static FIBITMAP * DLL_CALLCONV -Load(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *dataa) { - WORD x, y, width, height; - FIBITMAP *dib; - BYTE *bits; // pointer to dib data - RGBQUAD *pal; // pointer to dib palette - - WBMPHEADER header; - - if(handle) { - try { - // Read header information - // ----------------------- - - // Type - - header.TypeField = (WORD)multiByteRead(io, handle); - - if (header.TypeField != 0) - throw "Unsupported WBMP type"; - - // FixHeaderField - - io.read_proc(&header.FixHeaderField, 1, 1, handle); - - // ExtHeaderFields - // 1 = More will follow, 0 = Last octet - - if (header.FixHeaderField & 0x80) { - header.ExtHeaderFields = 0x80; - - while(header.ExtHeaderFields & 0x80) { - io.read_proc(&header.ExtHeaderFields, 1, 1, handle); - - readExtHeader(io, handle, header.ExtHeaderFields); - } - } - - // Width & Height - - width = (WORD)multiByteRead(io, handle); - height = (WORD)multiByteRead(io, handle); - - // Allocate a new dib - - dib = freeimage.allocate_proc(width, height, 1); - - if (!dib) { - throw "DIB allocation failed"; - } - - // write the palette data - - pal = freeimage.get_palette_proc(dib); - pal[0].rgbRed = pal[0].rgbGreen = pal[0].rgbBlue = 0; - pal[1].rgbRed = pal[1].rgbGreen = pal[1].rgbBlue = 255; - - // read the bitmap data - - int pitch = freeimage.get_pitch_proc(dib); - int line = freeimage.get_line_proc(dib); - - for (y = 0; y < height; y++) { - bits = freeimage.get_scanline_proc(dib, height - 1 - y); - - for (x = 0; x < line; x++) { - io.read_proc(&bits[x], 1, 1, handle); - } - } - - return dib; - - } catch(char *text) { - freeimage.output_message_proc(s_format_id, text); - - return NULL; - } - - } - - return NULL; -} - -static BOOL DLL_CALLCONV -Save(FreeImage &freeimage, FreeImageIO &io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) { - BYTE *bits; // pointer to dib data - - if ((dib) && (handle)) { - try { - if (freeimage.get_bpp_proc(dib) != 1) - throw "Only 1-bit depth bitmaps can be saved as WBMP"; - - // Write the header - - WBMPHEADER header; - header.TypeField = 0; // Type 0: B/W, no compression - header.FixHeaderField = 0; // No ExtHeaderField - header.Width = freeimage.get_width_proc(dib); // Image width - header.Height = freeimage.get_height_proc(dib); // Image height - - multiByteWrite(io, handle, header.TypeField); - - io.write_proc(&header.FixHeaderField, 1, 1, handle); - - multiByteWrite(io, handle, header.Width); - multiByteWrite(io, handle, header.Height); - - // write the bitmap data - - WORD linelength = freeimage.get_line_proc(dib); - - for (WORD y = 0; y < header.Height; y++) { - bits = freeimage.get_scanline_proc(dib, header.Height - 1 - y); - - io.write_proc(&bits[0], linelength, 1, handle); - } - - return TRUE; - - } catch (char* text) { - freeimage.output_message_proc(s_format_id, text); - } - } - - return FALSE; -} - -// ========================================================== -// Init -// ========================================================== - -void DLL_CALLCONV -InitWBMP(Plugin &plugin, int format_id) { - s_format_id = format_id; - - plugin.format_proc = Format; - plugin.description_proc = Description; - plugin.extension_proc = Extension; - plugin.regexpr_proc = RegExpr; - plugin.load_proc = Load; - plugin.save_proc = Save; - plugin.mime_proc = MimeType; -} diff --git a/freeimage241/Source/FreeImage/WuQuantizer.cpp b/freeimage241/Source/FreeImage/WuQuantizer.cpp deleted file mode 100644 index 74cf1d0..0000000 --- a/freeimage241/Source/FreeImage/WuQuantizer.cpp +++ /dev/null @@ -1,530 +0,0 @@ -/////////////////////////////////////////////////////////////////////// -// C Implementation of Wu's Color Quantizer (v. 2) -// (see Graphics Gems vol. II, pp. 126-133) -// -// Author: Xiaolin Wu -// Dept. of Computer Science -// Univ. of Western Ontario -// London, Ontario N6A 5B7 -// wu@csd.uwo.ca -// -// Algorithm: Greedy orthogonal bipartition of RGB space for variance -// minimization aided by inclusion-exclusion tricks. -// For speed no nearest neighbor search is done. Slightly -// better performance can be expected by more sophisticated -// but more expensive versions. -// -// The author thanks Tom Lane at Tom_Lane@G.GP.CS.CMU.EDU for much of -// additional documentation and a cure to a previous bug. -// -// Free to distribute, comments and suggestions are appreciated. -/////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////// -// History -// ------- -// July 2000: C++ Implementation of Wu's Color Quantizer -// and adaptation for the FreeImage 2 Library -// Author: Hervé Drolon (drolon@iut.univ-lehavre.fr) -/////////////////////////////////////////////////////////////////////// - -#include -#include - -#include "Quantizers.h" -#include "FreeImage.h" - -/////////////////////////////////////////////////////////////////////// - -// 3D array indexation - -#define INDEX(r, g, b) ((r << 10) + (r << 6) + r + (g << 5) + g + b) - -#define MAXCOLOR 256 -#define RED 2 -#define GREEN 1 -#define BLUE 0 - - -// Constructor / Destructor - -WuQuantizer::WuQuantizer(FIBITMAP *dib) -{ - width = FreeImage_GetWidth(dib); - height = FreeImage_GetHeight(dib); - pitch = FreeImage_GetPitch(dib); - m_dib = dib; - - gm2 = NULL; - wt = mr = mg = mb = NULL; - Qadd = NULL; - - // Allocate 3D arrays - gm2 = (float*)malloc(33 * 33 * 33 * sizeof(float)); - wt = (int32*)malloc(33 * 33 * 33 * sizeof(int32)); - mr = (int32*)malloc(33 * 33 * 33 * sizeof(int32)); - mg = (int32*)malloc(33 * 33 * 33 * sizeof(int32)); - mb = (int32*)malloc(33 * 33 * 33 * sizeof(int32)); - - // Allocate Qadd - Qadd = (uint16 *)malloc(sizeof(uint16) * width * height); - - if(!gm2 || !wt || !mr || !mg || !mb || !Qadd) - { - if(gm2) free(gm2); - if(wt) free(wt); - if(mr) free(mr); - if(mg) free(mg); - if(mb) free(mb); - if(Qadd) free(Qadd); - throw "Not enough memory"; - } - memset(gm2, 0, 35937 * sizeof(float)); - memset(wt, 0, 35937 * sizeof(int32)); - memset(mr, 0, 35937 * sizeof(int32)); - memset(mg, 0, 35937 * sizeof(int32)); - memset(mb, 0, 35937 * sizeof(int32)); - memset(Qadd, 0, sizeof(uint16) * width * height); -} - -WuQuantizer::~WuQuantizer() -{ - if(gm2) free(gm2); - if(wt) free(wt); - if(mr) free(mr); - if(mg) free(mg); - if(mb) free(mb); - if(Qadd) free(Qadd); -} - - -// Histogram is in elements 1..HISTSIZE along each axis, -// element 0 is for base or marginal value -// NB: these must start out 0! - -// Build 3-D color histogram of counts, r/g/b, c^2 -void WuQuantizer::Hist3D(int32 *vwt, int32 *vmr, int32 *vmg, int32 *vmb, float *m2) -{ - int ind; - int inr, ing, inb, table[256]; - int i; - uint16 y, x; - - for(i = 0; i < 256; i++) - table[i] = i * i; - - for(y = 0; y < height; y++) - { - uint8 *bits = FreeImage_GetBits(m_dib) + (y * pitch); - for(x = 0; x < width; x++) - { - inr = (bits[2] >> 3) + 1; - ing = (bits[1] >> 3) + 1; - inb = (bits[0] >> 3) + 1; - Qadd[y*width + x] = ind = INDEX(inr, ing, inb); - // [inr][ing][inb] - vwt[ind]++; - vmr[ind] += bits[2]; - vmg[ind] += bits[1]; - vmb[ind] += bits[0]; - m2[ind] += (float)(table[bits[2]] + table[bits[1]] + table[bits[0]]); - bits += 3; - } - } -} - - -// At conclusion of the histogram step, we can interpret -// wt[r][g][b] = sum over voxel of P(c) -// mr[r][g][b] = sum over voxel of r*P(c) , similarly for mg, mb -// m2[r][g][b] = sum over voxel of c^2*P(c) -// Actually each of these should be divided by 'ImageSize' to give the usual -// interpretation of P() as ranging from 0 to 1, but we needn't do that here. - - -// We now convert histogram into moments so that we can rapidly calculate -// the sums of the above quantities over any desired box. - -// Compute cumulative moments -void WuQuantizer::M3D(int32 *vwt, int32 *vmr, int32 *vmg, int32 *vmb, float *m2) -{ - uint16 ind1, ind2; - uint8 i, r, g, b; - int32 line, line_r, line_g, line_b; - int32 area[33], area_r[33], area_g[33], area_b[33]; - float line2, area2[33]; - - for(r = 1; r <= 32; r++) - { - for(i = 0; i <= 32; i++) - { - area2[i] = 0; - area[i] = area_r[i] = area_g[i] = area_b[i] = 0; - } - for(g = 1; g <= 32; g++) - { - line2 = 0; - line = line_r = line_g = line_b = 0; - for(b = 1; b <= 32; b++) - { - ind1 = INDEX(r, g, b); // [r][g][b] - line += vwt[ind1]; - line_r += vmr[ind1]; - line_g += vmg[ind1]; - line_b += vmb[ind1]; - line2 += m2[ind1]; - area[b] += line; - area_r[b] += line_r; - area_g[b] += line_g; - area_b[b] += line_b; - area2[b] += line2; - ind2 = ind1 - 1089; // [r-1][g][b] - vwt[ind1] = vwt[ind2] + area[b]; - vmr[ind1] = vmr[ind2] + area_r[b]; - vmg[ind1] = vmg[ind2] + area_g[b]; - vmb[ind1] = vmb[ind2] + area_b[b]; - m2[ind1] = m2[ind2] + area2[b]; - } - } - } -} - -// Compute sum over a box of any given statistic -int32 WuQuantizer::Vol( Box *cube, int32 *mmt ) -{ - return( mmt[INDEX(cube->r1, cube->g1, cube->b1)] - - mmt[INDEX(cube->r1, cube->g1, cube->b0)] - - mmt[INDEX(cube->r1, cube->g0, cube->b1)] - + mmt[INDEX(cube->r1, cube->g0, cube->b0)] - - mmt[INDEX(cube->r0, cube->g1, cube->b1)] - + mmt[INDEX(cube->r0, cube->g1, cube->b0)] - + mmt[INDEX(cube->r0, cube->g0, cube->b1)] - - mmt[INDEX(cube->r0, cube->g0, cube->b0)] ); -} - -// The next two routines allow a slightly more efficient calculation -// of Vol() for a proposed subbox of a given box. The sum of Top() -// and Bottom() is the Vol() of a subbox split in the given direction -// and with the specified new upper bound. - - -// Compute part of Vol(cube, mmt) that doesn't depend on r1, g1, or b1 -// (depending on dir) - -int32 WuQuantizer::Bottom(Box *cube, uint8 dir, int32 *mmt) -{ - switch(dir) - { - case RED: - return( - mmt[INDEX(cube->r0, cube->g1, cube->b1)] - + mmt[INDEX(cube->r0, cube->g1, cube->b0)] - + mmt[INDEX(cube->r0, cube->g0, cube->b1)] - - mmt[INDEX(cube->r0, cube->g0, cube->b0)] ); - break; - case GREEN: - return( - mmt[INDEX(cube->r1, cube->g0, cube->b1)] - + mmt[INDEX(cube->r1, cube->g0, cube->b0)] - + mmt[INDEX(cube->r0, cube->g0, cube->b1)] - - mmt[INDEX(cube->r0, cube->g0, cube->b0)] ); - break; - case BLUE: - return( - mmt[INDEX(cube->r1, cube->g1, cube->b0)] - + mmt[INDEX(cube->r1, cube->g0, cube->b0)] - + mmt[INDEX(cube->r0, cube->g1, cube->b0)] - - mmt[INDEX(cube->r0, cube->g0, cube->b0)] ); - break; - } - - return 0; -} - - -// Compute remainder of Vol(cube, mmt), substituting pos for -// r1, g1, or b1 (depending on dir) - -int32 WuQuantizer::Top(Box *cube, uint8 dir, int pos, int32 *mmt) -{ - switch(dir) - { - case RED: - return( mmt[INDEX(pos, cube->g1, cube->b1)] - -mmt[INDEX(pos, cube->g1, cube->b0)] - -mmt[INDEX(pos, cube->g0, cube->b1)] - +mmt[INDEX(pos, cube->g0, cube->b0)] ); - break; - case GREEN: - return( mmt[INDEX(cube->r1, pos, cube->b1)] - -mmt[INDEX(cube->r1, pos, cube->b0)] - -mmt[INDEX(cube->r0, pos, cube->b1)] - +mmt[INDEX(cube->r0, pos, cube->b0)] ); - break; - case BLUE: - return( mmt[INDEX(cube->r1, cube->g1, pos)] - -mmt[INDEX(cube->r1, cube->g0, pos)] - -mmt[INDEX(cube->r0, cube->g1, pos)] - +mmt[INDEX(cube->r0, cube->g0, pos)] ); - break; - } - - return 0; -} - -// Compute the weighted variance of a box -// NB: as with the raw statistics, this is really the variance * ImageSize - -float -WuQuantizer::Var(Box *cube) { - float dr = (float) Vol(cube, mr); - float dg = (float) Vol(cube, mg); - float db = (float) Vol(cube, mb); - float xx = gm2[INDEX(cube->r1, cube->g1, cube->b1)] - -gm2[INDEX(cube->r1, cube->g1, cube->b0)] - -gm2[INDEX(cube->r1, cube->g0, cube->b1)] - +gm2[INDEX(cube->r1, cube->g0, cube->b0)] - -gm2[INDEX(cube->r0, cube->g1, cube->b1)] - +gm2[INDEX(cube->r0, cube->g1, cube->b0)] - +gm2[INDEX(cube->r0, cube->g0, cube->b1)] - -gm2[INDEX(cube->r0, cube->g0, cube->b0)]; - - return (xx - (dr*dr+dg*dg+db*db)/(float)Vol(cube,wt)); -} - -// We want to minimize the sum of the variances of two subboxes. -// The sum(c^2) terms can be ignored since their sum over both subboxes -// is the same (the sum for the whole box) no matter where we split. -// The remaining terms have a minus sign in the variance formula, -// so we drop the minus sign and MAXIMIZE the sum of the two terms. - -float -WuQuantizer::Maximize(Box *cube, uint8 dir, int first, int last , int *cut, int32 whole_r, int32 whole_g, int32 whole_b, int32 whole_w) { - int32 half_r, half_g, half_b, half_w; - int i; - float temp; - - int32 base_r = Bottom(cube, dir, mr); - int32 base_g = Bottom(cube, dir, mg); - int32 base_b = Bottom(cube, dir, mb); - int32 base_w = Bottom(cube, dir, wt); - - float max = 0.0; - - *cut = -1; - - for (i = first; i < last; i++) { - half_r = base_r + Top(cube, dir, i, mr); - half_g = base_g + Top(cube, dir, i, mg); - half_b = base_b + Top(cube, dir, i, mb); - half_w = base_w + Top(cube, dir, i, wt); - - // now half_x is sum over lower half of box, if split at i - - if (half_w == 0) { // subbox could be empty of pixels! - continue; // never split into an empty box - } else { - temp = ((float)half_r*half_r + (float)half_g*half_g + (float)half_b*half_b)/half_w; - } - - half_r = whole_r - half_r; - half_g = whole_g - half_g; - half_b = whole_b - half_b; - half_w = whole_w - half_w; - - if (half_w == 0) { // subbox could be empty of pixels! - continue; // never split into an empty box - } else { - temp += ((float)half_r*half_r + (float)half_g*half_g + (float)half_b*half_b)/half_w; - } - - if (temp > max) { - max=temp; - *cut=i; - } - } - - return max; -} - -bool -WuQuantizer::Cut(Box *set1, Box *set2) { - uint8 dir; - int cutr, cutg, cutb; - - int32 whole_r = Vol(set1, mr); - int32 whole_g = Vol(set1, mg); - int32 whole_b = Vol(set1, mb); - int32 whole_w = Vol(set1, wt); - - float maxr = Maximize(set1, RED, set1->r0+1, set1->r1, &cutr, whole_r, whole_g, whole_b, whole_w); - float maxg = Maximize(set1, GREEN, set1->g0+1, set1->g1, &cutg, whole_r, whole_g, whole_b, whole_w); - float maxb = Maximize(set1, BLUE, set1->b0+1, set1->b1, &cutb, whole_r, whole_g, whole_b, whole_w); - - if ((maxr >= maxg) && (maxr >= maxb)) { - dir = RED; - - if (cutr < 0) { - return false; // can't split the box - } - } else if ((maxg >= maxr) && (maxg>=maxb)) { - dir = GREEN; - } else { - dir = BLUE; - } - - set2->r1 = set1->r1; - set2->g1 = set1->g1; - set2->b1 = set1->b1; - - switch (dir) { - case RED: - set2->r0 = set1->r1 = cutr; - set2->g0 = set1->g0; - set2->b0 = set1->b0; - break; - - case GREEN: - set2->g0 = set1->g1 = cutg; - set2->r0 = set1->r0; - set2->b0 = set1->b0; - break; - - case BLUE: - set2->b0 = set1->b1 = cutb; - set2->r0 = set1->r0; - set2->g0 = set1->g0; - break; - } - - set1->vol = (set1->r1-set1->r0)*(set1->g1-set1->g0)*(set1->b1-set1->b0); - set2->vol = (set2->r1-set2->r0)*(set2->g1-set2->g0)*(set2->b1-set2->b0); - - return true; -} - - -void -WuQuantizer::Mark(Box *cube, int label, uint8 *tag) { - for (int r = cube->r0 + 1; r <= cube->r1; r++) { - for (int g = cube->g0 + 1; g <= cube->g1; g++) { - for (int b = cube->b0 + 1; b <= cube->b1; b++) { - tag[INDEX(r, g, b)] = label; - } - } - } -} - -// Wu Quantization algorithm - -FIBITMAP * -WuQuantizer::Quantize() { - uint8 *tag = NULL; - - try { - int PalSize = 256; // Color look-up table size - Box cube[MAXCOLOR]; - int next; - int32 i, weight; - int k; - float vv[MAXCOLOR], temp; - - // Compute 3D histogram - - Hist3D(wt, mr, mg, mb, gm2); - - // Compute moments - - M3D(wt, mr, mg, mb, gm2); - - cube[0].r0 = cube[0].g0 = cube[0].b0 = 0; - cube[0].r1 = cube[0].g1 = cube[0].b1 = 32; - next = 0; - - for (i = 1; i < PalSize; i++) { - if(Cut(&cube[next], &cube[i])) { - // volume test ensures we won't try to cut one-cell box - vv[next] = (cube[next].vol > 1) ? Var(&cube[next]) : 0; - vv[i] = (cube[i].vol > 1) ? Var(&cube[i]) : 0; - } else { - vv[next] = 0.0; // don't try to split this box again - i--; // didn't create box i - } - - next = 0; temp = vv[0]; - - for (k = 1; k <= i; k++) { - if (vv[k] > temp) { - temp = vv[k]; next = k; - } - } - - if (temp <= 0.0) { - PalSize = i + 1; - - // Error: "Only got 'PalSize' boxes" - - break; - } - } - - // Partition done - - // the space for array gm2 can be freed now - - free(gm2); - - gm2 = NULL; - - // Allocate a new dib - - FIBITMAP *new_dib = FreeImage_Allocate(width, height, 8); - - if (new_dib == NULL) { - throw "Not enough memory"; - } - - // create an optimized palette - - RGBQUAD *new_pal = FreeImage_GetPalette(new_dib); - - tag = (uint8*) malloc(33 * 33 * 33 * sizeof(uint8)); - - if (tag == NULL) { - throw "Not enough memory"; - } - - for (k = 0; k < PalSize; k++) { - Mark(&cube[k], k, tag); - weight = Vol(&cube[k], wt); - - if (weight) { - new_pal[k].rgbRed = (uint8)(Vol(&cube[k], mr) / weight); - new_pal[k].rgbGreen = (uint8)(Vol(&cube[k], mg) / weight); - new_pal[k].rgbBlue = (uint8)(Vol(&cube[k], mb) / weight); - } else { - // Error: bogus box 'k' - - new_pal[k].rgbRed = new_pal[k].rgbGreen = new_pal[k].rgbBlue = 0; - } - } - - int npitch = FreeImage_GetPitch(new_dib); - - for (uint16 y = 0; y < height; y++) { - uint8 *new_bits = FreeImage_GetBits(new_dib) + (y * npitch); - - for (uint16 x = 0; x < width; x++) { - new_bits[x] = tag[Qadd[y*width + x]]; - } - } - - // output 'new_pal' as color look-up table contents, - // 'new_bits' as the quantized image (array of table addresses). - - free(tag); - - return (FIBITMAP*) new_dib; - } catch(...) { - free(tag); - } - - return NULL; -} diff --git a/freeimage241/Source/FreeImageLib/FreeImageLib.dsp b/freeimage241/Source/FreeImageLib/FreeImageLib.dsp deleted file mode 100644 index 28fccb8..0000000 --- a/freeimage241/Source/FreeImageLib/FreeImageLib.dsp +++ /dev/null @@ -1,240 +0,0 @@ -# Microsoft Developer Studio Project File - Name="FreeImageLib" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=FreeImageLib - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "FreeImageLib.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "FreeImageLib.mak" CFG="FreeImageLib - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "FreeImageLib - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "FreeImageLib - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "FreeImageLib - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G6 /Gd /MT /W3 /GX /O1 /I "..\\" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x413 /d "NDEBUG" -# ADD RSC /l 0x413 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Release\FreeImage.lib" - -!ELSEIF "$(CFG)" == "FreeImageLib - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\\" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD BASE RSC /l 0x413 /d "_DEBUG" -# ADD RSC /l 0x413 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Debug\FreeImaged.lib" - -!ENDIF - -# Begin Target - -# Name "FreeImageLib - Win32 Release" -# Name "FreeImageLib - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Group "Quantizers" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\FreeImage\NNQuantizer.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\WuQuantizer.cpp -# End Source File -# End Group -# Begin Group "Conversion" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\FreeImage\Conversion.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\Conversion16_555.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\Conversion16_565.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\Conversion24.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\Conversion32.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\Conversion8.cpp -# End Source File -# End Group -# Begin Group "Plugins" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\FreeImage\Plugin.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginBMP.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginICO.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginIFF.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginJPEG.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginKOALA.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginMNG.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginPCD.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginPCX.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginPNG.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginPNM.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginPSD.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginRAS.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginTARGA.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginTIFF.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\PluginWBMP.cpp -# End Source File -# End Group -# Begin Source File - -SOURCE=..\FreeImage\BitmapAccess.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\FreeImage.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\FreeImageIO.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\GetType.cpp -# End Source File -# Begin Source File - -SOURCE=..\FreeImage\LoadFunctions.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\FreeImage.h -# End Source File -# Begin Source File - -SOURCE=..\FreeImageIO.h -# End Source File -# Begin Source File - -SOURCE=..\Plugin.h -# End Source File -# Begin Source File - -SOURCE=..\Quantizers.h -# End Source File -# Begin Source File - -SOURCE=..\Utilities.h -# End Source File -# End Group -# End Target -# End Project diff --git a/freeimage241/Source/FreeImageQt/FreeImageQt.cpp b/freeimage241/Source/FreeImageQt/FreeImageQt.cpp deleted file mode 100644 index 2e66206..0000000 --- a/freeimage241/Source/FreeImageQt/FreeImageQt.cpp +++ /dev/null @@ -1,714 +0,0 @@ -// ========================================================== -// FreeImage Qt -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// Based on tiffIO code written by Markus L. Noga -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#pragma warning(disable : 4541) - -#include - -#include -#include -#include -#include -#include - -#include "FreeImageQt.h" - -// ========================================================== - -#define DLL_CALLCONV __stdcall - -// For C compatility ---------------------------------------- - -#ifdef __cplusplus -#define FI_DEFAULT(x) = x -#define FI_ENUM(x) enum x -#define FI_STRUCT(x) struct x -#else -#define FI_DEFAULT(x) -#define FI_ENUM(x) typedef int x; enum x -#define FI_STRUCT(x) typedef struct x x; struct x -#endif - -// File IO routines ----------------------------------------- - -#ifndef FREEIMAGE_IO -#define FREEIMAGE_IO - -#define fi_handle void* - -typedef unsigned (*FI_ReadProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); -typedef unsigned (*FI_WriteProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); -typedef int (*FI_SeekProc) (fi_handle handle, long offset, int origin); -typedef long (*FI_TellProc) (fi_handle handle); - -#ifdef WIN32 -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif - -struct FreeImageIO { - FI_ReadProc read_proc; //! pointer to the function used to read data - FI_WriteProc write_proc; //! pointer to the function used to write data - FI_SeekProc seek_proc; //! pointer to the function used to seek - FI_TellProc tell_proc; //! pointer to the function used to aquire the current position -}; - -#ifdef WIN32 -#pragma pack(pop) -#else -#pragma pack(4) -#endif - -#endif //!FREEIMAGE_IO - -// ---------------------------------------------------------- -// WINDOWS STUFF FOR DLL HANDLING -// ---------------------------------------------------------- - -static HMODULE s_library_handle; -static bool s_library_loaded = false; - -// ---------------------------------------------------------- -// DLL FUNCTION DECLARATIONS -// ---------------------------------------------------------- - -typedef void (DLL_CALLCONV *FreeImage_SetOutputMessageProc)(FreeImage_OutputMessageFunction omf); -typedef FIBITMAP *(DLL_CALLCONV *FreeImage_AllocateProc)(int width, int height, int bpp, int red_mask = 0, int green_mask = 0, int blue_mask = 0); -typedef void (DLL_CALLCONV *FreeImage_UnloadProc)(FIBITMAP *dib); -typedef int (DLL_CALLCONV *FreeImage_GetFIFCountProc)(); -typedef FREE_IMAGE_FORMAT (DLL_CALLCONV *FreeImage_GetFIFFromFormatProc)(const char *format); -typedef const char * (DLL_CALLCONV *FreeImage_GetFormatFromFIFProc)(int id); -typedef const char * (DLL_CALLCONV *FreeImage_GetFIFDescriptionProc)(int id); -typedef const char * (DLL_CALLCONV *FreeImage_GetFIFRegExprProc)(int id); -typedef const char * (DLL_CALLCONV *FreeImage_GetFIFExtensionListProc)(int id); -typedef FREE_IMAGE_FORMAT (DLL_CALLCONV *FreeImage_GetFIFFromFilenameProc)(const char *filename); -typedef BOOL (DLL_CALLCONV *FreeImage_FIFSupportsReadingProc)(FREE_IMAGE_FORMAT id); -typedef BOOL (DLL_CALLCONV *FreeImage_FIFSupportsWritingProc)(FREE_IMAGE_FORMAT id); -typedef FIBITMAP * (DLL_CALLCONV *FreeImage_LoadFromHandleProc)(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags = 0); -typedef BOOL (DLL_CALLCONV *FreeImage_SaveToHandleProc)(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags = 0); -typedef unsigned (DLL_CALLCONV *FreeImage_GetHeightProc) (FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FreeImage_GetWidthProc) (FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FreeImage_GetBPPProc) (FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FreeImage_GetDotsPerMeterXProc) (FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FreeImage_GetDotsPerMeterYProc) (FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FreeImage_GetTransparencyCountProc) (FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FreeImage_GetColorsUsedProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FreeImage_GetPitchProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FreeImage_GetRedMaskProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FreeImage_GetGreenMaskProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FreeImage_GetBlueMaskProc)(FIBITMAP *dib); -typedef const char *(DLL_CALLCONV *FreeImage_GetVersionProc)(); -typedef const char *(DLL_CALLCONV *FreeImage_GetCopyrightMessageProc)(); -typedef FREE_IMAGE_FORMAT (DLL_CALLCONV *FreeImage_GetFileTypeFromHandleProc)(FreeImageIO *io, fi_handle handle, int size); -typedef void (DLL_CALLCONV *FreeImage_SetTransparentProc) (FIBITMAP *dib, BOOL enable); -typedef BOOL (DLL_CALLCONV *FreeImage_IsTransparentProc) (FIBITMAP *dib); -typedef BYTE *(DLL_CALLCONV *FreeImage_GetScanLineProc) (FIBITMAP *dib, int scanline); -typedef BYTE *(DLL_CALLCONV *FreeImage_GetTransparencyTableProc) (FIBITMAP *dib); -typedef RGBQUAD *(DLL_CALLCONV *FreeImage_GetPaletteProc)(FIBITMAP *dib); -typedef BITMAPINFOHEADER *(DLL_CALLCONV *FreeImage_GetInfoHeaderProc) (FIBITMAP *dib); -typedef void (DLL_CALLCONV *FreeImage_ConvertLine16To32_555Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FreeImage_ConvertLine16To32_565Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FreeImage_ConvertLine4To8Proc) (BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FreeImage_ConvertLine24To32Proc) (BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FreeImage_ConvertLine32To24Proc) (BYTE *target, BYTE *source, int width_in_pixels); - -// ---------------------------------------------------------- -// DLL FUNCTION ÍNSTANTIATONS -// ---------------------------------------------------------- - -FreeImage_SetOutputMessageProc FI_SetOutputMessageProc; -FreeImage_AllocateProc FI_AllocateProc; -FreeImage_UnloadProc FI_UnloadProc; -FreeImage_GetFIFCountProc FI_GetFIFCountProc; -FreeImage_GetFIFFromFormatProc FI_GetFIFFromFormatProc; -FreeImage_GetFormatFromFIFProc FI_GetFormatFromFIFProc; -FreeImage_GetFIFDescriptionProc FI_GetFIFDescriptionProc; -FreeImage_GetFIFRegExprProc FI_GetFIFRegExprProc; -FreeImage_GetFIFExtensionListProc FI_GetFIFExtensionListProc; -FreeImage_GetFIFFromFilenameProc FI_GetFIFFromFilenameProc; -FreeImage_FIFSupportsReadingProc FI_FIFSupportsReadingProc; -FreeImage_FIFSupportsWritingProc FI_FIFSupportsWritingProc; -FreeImage_LoadFromHandleProc FI_LoadFromHandleProc; -FreeImage_SaveToHandleProc FI_SaveToHandleProc; -FreeImage_GetHeightProc FI_GetHeightProc; -FreeImage_GetWidthProc FI_GetWidthProc; -FreeImage_GetBPPProc FI_GetBPPProc; -FreeImage_GetDotsPerMeterXProc FI_GetDotsPerMeterXProc; -FreeImage_GetDotsPerMeterYProc FI_GetDotsPerMeterYProc; -FreeImage_SetTransparentProc FI_SetTransparentProc; -FreeImage_IsTransparentProc FI_IsTransparentProc; -FreeImage_GetTransparencyCountProc FI_GetTransparencyCountProc; -FreeImage_GetColorsUsedProc FI_GetColorsUsedProc; -FreeImage_GetPitchProc FI_GetPitchProc; -FreeImage_GetRedMaskProc FI_GetRedMaskProc; -FreeImage_GetGreenMaskProc FI_GetGreenMaskProc; -FreeImage_GetBlueMaskProc FI_GetBlueMaskProc; -FreeImage_GetVersionProc FI_GetVersionProc; -FreeImage_GetCopyrightMessageProc FI_GetCopyrightMessageProc; -FreeImage_GetFileTypeFromHandleProc FI_GetFileTypeFromHandleProc; -FreeImage_GetScanLineProc FI_GetScanLineProc; -FreeImage_GetTransparencyTableProc FI_GetTransparencyTableProc; -FreeImage_GetPaletteProc FI_GetPaletteProc; -FreeImage_GetInfoHeaderProc FI_GetInfoHeaderProc; -FreeImage_ConvertLine4To8Proc FI_ConvertLine4To8Proc; -FreeImage_ConvertLine16To32_555Proc FI_ConvertLine16To32_555Proc; -FreeImage_ConvertLine16To32_565Proc FI_ConvertLine16To32_565Proc; -FreeImage_ConvertLine24To32Proc FI_ConvertLine24To32Proc; -FreeImage_ConvertLine32To24Proc FI_ConvertLine32To24Proc; - -// ---------------------------------------------------------- -// INTERNAL QT BITMAP HANDLING FUNCTIONS -// ---------------------------------------------------------- - -BOOL -FormatSupportedByQt(QStrList &list, const char *format) { - for (const char *qtformat = list.first(); qtformat != 0; qtformat = list.next()) { - if (stricmp(format, qtformat) == 0) - return TRUE; - } - - return FALSE; -} - -unsigned -GetDotsPerMeterX(FIBITMAP *dib) { - return (FI_GetDotsPerMeterXProc != NULL) ? FI_GetDotsPerMeterXProc(dib) : 0; -} - -unsigned -GetDotsPerMeterY(FIBITMAP *dib) { - return (FI_GetDotsPerMeterYProc != NULL) ? FI_GetDotsPerMeterYProc(dib) : 0; -} - -// ---------------------------------------------------------- -// FREEIMAGEIO FUNCTIONS SUITABLE FOR USE WITH QIODEVICE -// ---------------------------------------------------------- - -inline unsigned -_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { - char *b = static_cast(buffer); - - for (unsigned c = 0; c < count; c++) { - QIODevice *iod = static_cast(handle); - - iod->readBlock(b, size); - - b += size; - } - - return count; -} - -inline unsigned -_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) { - char *b = static_cast(buffer); - - for (unsigned c = 0; c < count; c++) { - QIODevice *iod = static_cast(handle); - - iod->writeBlock(b, size); - - b += size; - } - - return count; -} - -inline int -_SeekProc(fi_handle handle, long offset, int origin) { - QIODevice *iod = static_cast(handle); - - switch(origin) { - case SEEK_SET : - iod->at(offset); - break; - - case SEEK_CUR : - iod->at(iod->at() + offset); - break; - - default : - return 1; - } - - return 0; -} - -inline long -_TellProc(fi_handle handle) { - QIODevice *iod = static_cast(handle); - - return iod->at(); -} - -// ---------------------------------------------------------- -// PLUGIN INTERFACE -// ---------------------------------------------------------- - -int -FIQT_GetFIFCount() { - return (FI_GetFIFCountProc != NULL) ? FI_GetFIFCountProc() : 0; -} - -FREE_IMAGE_FORMAT -FIQT_GetFIFFromFormat(const char *format) { - return (FI_GetFIFFromFormatProc != NULL) ? FI_GetFIFFromFormatProc(format) : FIF_UNKNOWN; -} - -const char * -FIQT_GetFormatFromFIF(FREE_IMAGE_FORMAT id) { - return (FI_GetFormatFromFIFProc != NULL) ? FI_GetFormatFromFIFProc(id) : NULL; -} - -const char * -FIQT_GetFIFDescription(FREE_IMAGE_FORMAT id) { - return (FI_GetFIFDescriptionProc != NULL) ? FI_GetFIFDescriptionProc(id) : NULL; -} - -const char * -FIQT_GetFIFExtensionList(FREE_IMAGE_FORMAT id) { - return (FI_GetFIFExtensionListProc != NULL) ? FI_GetFIFExtensionListProc(id) : NULL; -} - -bool -FIQT_FIFSupportsReading(FREE_IMAGE_FORMAT id) { - return (FI_FIFSupportsReadingProc != NULL) ? FI_FIFSupportsReadingProc(id) : false; -} - -bool -FIQT_FIFSupportsWriting(FREE_IMAGE_FORMAT id) { - return (FI_FIFSupportsWritingProc != NULL) ? FI_FIFSupportsWritingProc(id) : false; -} - -FREE_IMAGE_FORMAT -FIQT_GetFIFFromFilename(const char *filename) { - return (FI_GetFIFFromFilenameProc != NULL) ? FI_GetFIFFromFilenameProc(filename) : FIF_UNKNOWN; -} - -const char * -FIQT_GetFileTypeFromFormat(FREE_IMAGE_FORMAT fif) { - return FIQT_GetFormatFromFIF(fif); -} - -const char * -FIQT_GetFileTypeFromExtension(const char *format) { - FREE_IMAGE_FORMAT fif = FIQT_GetFIFFromFilename(format); - - return (fif != FIF_UNKNOWN) ? FIQT_GetFormatFromFIF(fif) : NULL; -} - -FREE_IMAGE_FORMAT -FIQT_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size) { - return (FI_GetFileTypeFromHandleProc != NULL) ? FI_GetFileTypeFromHandleProc(io, handle, size) : FIF_UNKNOWN; -} - -// ---------------------------------------------------------- -// LOAD/SAVE FUNCTIONS -// ---------------------------------------------------------- - -static void -FIQT_Load(QImageIO *iio) { - FreeImageIO io; - - io.read_proc = _ReadProc; - io.seek_proc = _SeekProc; - io.tell_proc = _TellProc; - io.write_proc = _WriteProc; - - // because we don't always receive the format string here, we need to do some of our own investigation... - // first try to identify the image by looking at the filename/extension - - FREE_IMAGE_FORMAT fif = FIQT_GetFIFFromFilename(iio->format()); - - if (fif == FIF_UNKNOWN) { - // format id based image lookup failed... try to identify the bitmap by looking at the header - - fif = FIQT_GetFileTypeFromHandle(&io, (fi_handle)iio->ioDevice(), 16); - - if (fif == FIF_UNKNOWN) { - // failed again... look at the complete filename as a last resort - - if (!iio->fileName().isEmpty()) { - fif = FIQT_GetFIFFromFilename(iio->fileName()); - - if (fif == FIF_UNKNOWN) { - iio->setStatus(-1); - return; - } - } else { - iio->setStatus(-1); - return; - } - } - } - - assert(fif != FIF_UNKNOWN); - - // if we come here, we have a valid FIF id - - if (FI_FIFSupportsReadingProc(fif)) { - FIBITMAP *bitmap = FI_LoadFromHandleProc(fif, &io, (fi_handle)iio->ioDevice(), 0); - - if (bitmap != NULL) { - QImage image; - - switch(FI_GetBPPProc(bitmap)) { - case 1 : - image.create(FI_GetWidthProc(bitmap), FI_GetHeightProc(bitmap), 1, FI_GetColorsUsedProc(bitmap), QImage::BigEndian); - break; - - case 4 : - image.create(FI_GetWidthProc(bitmap), FI_GetHeightProc(bitmap), 8, 256); - break; - - case 16 : - case 24 : - image.create(FI_GetWidthProc(bitmap), FI_GetHeightProc(bitmap), 32, 0); - break; - - default : - image.create(FI_GetWidthProc(bitmap), FI_GetHeightProc(bitmap), FI_GetBPPProc(bitmap), FI_GetColorsUsedProc(bitmap)); - break; - } - - // set metrics data - - image.setDotsPerMeterX(GetDotsPerMeterX(bitmap)); - image.setDotsPerMeterY(GetDotsPerMeterY(bitmap)); - - // if there is a palette, copy it - - if (FI_IsTransparentProc(bitmap)) { - image.setAlphaBuffer(TRUE); - - if (FI_GetBPPProc(bitmap) < 16) { - RGBQUAD *palette = FI_GetPaletteProc(bitmap); - BYTE *trans_table = FI_GetTransparencyTableProc(bitmap); - - unsigned i; - - for (i = 0; i < FI_GetTransparencyCountProc(bitmap); ++i) { - image.setColor(i, qRgba(palette[i].rgbRed, palette[i].rgbGreen, palette[i].rgbBlue, trans_table[i])); - } - - for (; i < FI_GetColorsUsedProc(bitmap); ++i) { - image.setColor(i, qRgba(palette[i].rgbRed, palette[i].rgbGreen, palette[i].rgbBlue, 0xff)); - } - } - } else { - image.setAlphaBuffer(FALSE); - - if (FI_GetBPPProc(bitmap) < 16) { - RGBQUAD *palette = FI_GetPaletteProc(bitmap); - - for (unsigned i = 0; i < FI_GetColorsUsedProc(bitmap); ++i) { - image.setColor(i, qRgb(palette[i].rgbRed, palette[i].rgbGreen, palette[i].rgbBlue)); - } - } - } - - // copy the bitmap data and convert if neccesary - - for (unsigned y = 0; y < FI_GetHeightProc(bitmap); y++) { - if (FI_GetBPPProc(bitmap) == 4) { - FI_ConvertLine4To8Proc(image.scanLine(FI_GetHeightProc(bitmap) - 1 - y), FI_GetScanLineProc(bitmap, y), FI_GetWidthProc(bitmap)); - } else if (FI_GetBPPProc(bitmap) == 16) { - if ((FI_GetRedMaskProc(bitmap) == 0x1F) && (FI_GetGreenMaskProc(bitmap) == 0x3E0) && (FI_GetBlueMaskProc(bitmap) == 0x7C00)) { - FI_ConvertLine16To32_555Proc(image.scanLine(FI_GetHeightProc(bitmap) - 1 - y), FI_GetScanLineProc(bitmap, y), FI_GetWidthProc(bitmap)); - } else { - FI_ConvertLine16To32_565Proc(image.scanLine(FI_GetHeightProc(bitmap) - 1 - y), FI_GetScanLineProc(bitmap, y), FI_GetWidthProc(bitmap)); - } - } else if (FI_GetBPPProc(bitmap) == 24) { - FI_ConvertLine24To32Proc(image.scanLine(FI_GetHeightProc(bitmap) - 1 - y), FI_GetScanLineProc(bitmap, y), FI_GetWidthProc(bitmap)); - } else { - memcpy(image.scanLine(FI_GetHeightProc(bitmap) - y - 1), FI_GetScanLineProc(bitmap, y), FI_GetPitchProc(bitmap)); - } - } - - iio->setImage(image); - iio->setStatus(0); - - FI_UnloadProc(bitmap); - - return; - } - } - - iio->setStatus(-1); -} - -static void -FIQT_Save(QImageIO *iio) { - FreeImageIO io; - - io.read_proc = _ReadProc; - io.seek_proc = _SeekProc; - io.tell_proc = _TellProc; - io.write_proc = _WriteProc; - - // get the save pointer for the needed bitmap format - - FREE_IMAGE_FORMAT fif = FIQT_GetFIFFromFilename(iio->format()); - - if (fif != FIF_UNKNOWN) { - if (FIQT_FIFSupportsWriting(fif)) { - FIBITMAP *bitmap; - - switch(fif) { - case FIF_BMP : - if ((!iio->image().hasAlphaBuffer()) && (iio->image().depth() == 32)) { - bitmap = FI_AllocateProc(iio->image().width(), iio->image().height(), 24); - } else { - bitmap = FI_AllocateProc(iio->image().width(), iio->image().height(), iio->image().depth()); - } - - break; - - case FIF_JPEG : - if (iio->image().depth() == 32) { - bitmap = FI_AllocateProc(iio->image().width(), iio->image().height(), 24); - } else { - bitmap = FI_AllocateProc(iio->image().width(), iio->image().height(), iio->image().depth()); - } - - break; - - default : - bitmap = FI_AllocateProc(iio->image().width(), iio->image().height(), iio->image().depth()); - break; - }; - - // enable alpha channels in the DIB when we must - - if (iio->image().hasAlphaBuffer()) { - FI_SetTransparentProc(bitmap, TRUE); - } else { - FI_SetTransparentProc(bitmap, FALSE); - } - - // copy the palette - - RGBQUAD *palette = FI_GetPaletteProc(bitmap); - QRgb *colorTable = iio->image().colorTable(); - - for (int i = 0; i < iio->image().numColors(); ++i) { - palette[i].rgbBlue = qBlue(colorTable[i]); - palette[i].rgbGreen = qGreen(colorTable[i]); - palette[i].rgbRed = qRed(colorTable[i]); - } - - // copy the metrics data - - BITMAPINFOHEADER *header = FI_GetInfoHeaderProc(bitmap); - header->biXPelsPerMeter = iio->image().dotsPerMeterX(); - header->biYPelsPerMeter = iio->image().dotsPerMeterY(); - - // copy the bits - - for (unsigned y = 0; y < FI_GetHeightProc(bitmap); y++) { - switch(fif) { - case FIF_BMP : - if ((!iio->image().hasAlphaBuffer()) && (iio->image().depth() == 32)) { - FI_ConvertLine32To24Proc(FI_GetScanLineProc(bitmap, y), iio->image().scanLine(FI_GetHeightProc(bitmap) - 1 - y), iio->image().width()); - } else { - memcpy(FI_GetScanLineProc(bitmap, y), iio->image().scanLine(FI_GetHeightProc(bitmap) - 1 - y), FI_GetPitchProc(bitmap)); - } - - break; - - case FIF_JPEG : - if (iio->image().depth() == 32) { - FI_ConvertLine32To24Proc(FI_GetScanLineProc(bitmap, y), iio->image().scanLine(FI_GetHeightProc(bitmap) - 1 - y), iio->image().width()); - } else { - memcpy(FI_GetScanLineProc(bitmap, y), iio->image().scanLine(FI_GetHeightProc(bitmap) - 1 - y), FI_GetPitchProc(bitmap)); - } - - break; - - default : - memcpy(FI_GetScanLineProc(bitmap, y), iio->image().scanLine(FI_GetHeightProc(bitmap) - 1 - y), FI_GetPitchProc(bitmap)); - break; - }; - } - - // save the bitmap - - if (FI_SaveToHandleProc(fif, bitmap, &io, (fi_handle)iio->ioDevice())) { - iio->setStatus(0); // status 0 == SUCCESS - } else { - iio->setStatus(-1); // status -1 == FAILURE - } - - FI_UnloadProc(bitmap); - - return; - } - } - - iio->setStatus(-1); -} - -// ---------------------------------------------------------- -// OUTPUT MESSAGE FUNCTIONS -// ---------------------------------------------------------- - -void -FIQT_SetOutputMessage(FreeImage_OutputMessageFunction omf) { - if (FI_SetOutputMessageProc != NULL) { - FI_SetOutputMessageProc(omf); - } -} - -// ---------------------------------------------------------- -// VERSION HANDLING / COPYRIGHT -// ---------------------------------------------------------- - -const char * -FIQT_GetVersion() { - return (FI_GetVersionProc != NULL) ? FI_GetVersionProc() : NULL; -} - -const char * -FIQT_GetCopyrightMessage() { - return (FI_GetCopyrightMessageProc != NULL) ? FI_GetCopyrightMessageProc() : NULL; -} - -// ---------------------------------------------------------- -// REGISTRATION OF FREEIMAGE IN THE QT MECHANISM -// ---------------------------------------------------------- - -bool -FIQT_Register(bool new_formats_only) { - if (!s_library_loaded) { -#ifdef _DEBUG - if ((s_library_handle = LoadLibrary("freeimaged.dll")) != NULL) { -#else - if ((s_library_handle = LoadLibrary("freeimage.dll")) != NULL) { -#endif - // extract the functions from the FreeImage library - - FI_SetOutputMessageProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_SetOutputMessage@4")); - FI_AllocateProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_Allocate@24")); - FI_UnloadProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_Unload@4")); - FI_GetFIFCountProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetFIFCount@0")); - FI_GetFIFFromFormatProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetFIFFromFormat@4")); - FI_GetFormatFromFIFProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetFormatFromFIF@4")); - FI_GetFIFDescriptionProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetFIFDescription@4")); - FI_GetFIFRegExprProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetFIFRegExpr@4")); - FI_GetFIFExtensionListProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetFIFExtensionList@4")); - FI_GetFIFFromFilenameProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetFIFFromFilename@4")); - FI_FIFSupportsReadingProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_FIFSupportsReading@4")); - FI_FIFSupportsWritingProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_FIFSupportsWriting@4")); - FI_LoadFromHandleProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_LoadFromHandle@16")); - FI_SaveToHandleProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_SaveToHandle@20")); - FI_GetHeightProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetHeight@4")); - FI_GetWidthProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetWidth@4")); - FI_GetBPPProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetBPP@4")); - FI_GetDotsPerMeterXProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetDotsPerMeterX@4")); - FI_GetDotsPerMeterYProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetDotsPerMeterY@4")); - FI_SetTransparentProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_SetTransparent@8")); - FI_IsTransparentProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_IsTransparent@4")); - FI_GetTransparencyCountProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetTransparencyCount@4")); - FI_GetTransparencyTableProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetTransparencyTable@4")); - FI_GetColorsUsedProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetColorsUsed@4")); - FI_GetPaletteProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetPalette@4")); - FI_GetPitchProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetPitch@4")); - FI_GetVersionProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetVersion@0")); - FI_GetRedMaskProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetRedMask@4")); - FI_GetGreenMaskProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetGreenMask@4")); - FI_GetBlueMaskProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetBlueMask@4")); - FI_GetCopyrightMessageProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetCopyrightMessage@4")); - FI_GetFileTypeFromHandleProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetFileTypeFromHandle@12")); - FI_GetScanLineProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetScanLine@8")); - FI_GetInfoHeaderProc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_GetInfoHeader@4")); - FI_ConvertLine4To8Proc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_ConvertLine4To8@12")); - FI_ConvertLine16To32_555Proc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_ConvertLine16To32_555@12")); - FI_ConvertLine16To32_565Proc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_ConvertLine16To32_565@12")); - FI_ConvertLine24To32Proc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_ConvertLine24To32@12")); - FI_ConvertLine32To24Proc = reinterpret_cast(GetProcAddress(s_library_handle, "_FreeImage_ConvertLine32To24@12")); - - if ((FI_GetVersionProc != 0) && - (FI_AllocateProc != 0) && - (FI_UnloadProc != 0) && - (FI_LoadFromHandleProc != 0) && - (FI_SaveToHandleProc != 0) && - (FI_GetHeightProc != 0) && - (FI_GetWidthProc != 0) && - (FI_GetBPPProc != 0) && - (FI_GetScanLineProc != 0) && - (FI_GetTransparencyCountProc != 0) && - (FI_GetTransparencyTableProc != 0) && - (FI_IsTransparentProc != 0) && - (FI_GetColorsUsedProc != 0) && - (FI_GetPaletteProc != 0) && - (FI_GetPitchProc != 0) && - (FI_GetRedMaskProc != 0) && - (FI_GetGreenMaskProc != 0) && - (FI_GetBlueMaskProc != 0) && - (FI_GetInfoHeaderProc != 0) && - (FI_ConvertLine4To8Proc != 0) && - (FI_ConvertLine16To32_555Proc != 0) && - (FI_ConvertLine16To32_565Proc != 0) && - (FI_ConvertLine24To32Proc != 0), - (FI_ConvertLine32To24Proc != 0), - (FI_GetFIFRegExprProc != 0)) { - - QStrList format_list; - format_list = QImageIO::inputFormats(); - - for (int i = 0; i < FIQT_GetFIFCount(); ++i) { - if (!FormatSupportedByQt(format_list, FIQT_GetFormatFromFIF((FREE_IMAGE_FORMAT)i)) || !new_formats_only) { - QImageIO::defineIOHandler(FIQT_GetFormatFromFIF((FREE_IMAGE_FORMAT)i), FI_GetFIFRegExprProc(i), 0, FIQT_FIFSupportsReading((FREE_IMAGE_FORMAT)i) ? FIQT_Load : NULL, FIQT_FIFSupportsWriting((FREE_IMAGE_FORMAT)i) ? FIQT_Save : NULL); - } - } - - s_library_loaded = true; - - atexit(FIQT_Unregister); // when the application stops, automatically unregister - - return s_library_loaded; - } - } - - s_library_loaded = false; - - return s_library_loaded; - } - - return s_library_loaded; -} - -bool -FIQT_IsLoaded() { - return s_library_loaded; -} - -void -FIQT_Unregister() { - if (s_library_loaded) { - FreeLibrary(s_library_handle); - - s_library_loaded = FALSE; - } -} diff --git a/freeimage241/Source/FreeImageQt/FreeImageQt.dsp b/freeimage241/Source/FreeImageQt/FreeImageQt.dsp deleted file mode 100644 index e7d6a61..0000000 --- a/freeimage241/Source/FreeImageQt/FreeImageQt.dsp +++ /dev/null @@ -1,108 +0,0 @@ -# Microsoft Developer Studio Project File - Name="FreeImageQt" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=FreeImageQt - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "FreeImageQt.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "FreeImageQt.mak" CFG="FreeImageQt - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "FreeImageQt - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "FreeImageQt - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "FreeImageQt - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G6 /Gd /MT /W3 /GX /O1 /I "../../Dist" /I "..\zlib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Cmds=copy Release\FreeImageQt.lib ..\..\Dist copy FreeImageQt.h ..\..\Dist -# End Special Build Tool - -!ELSEIF "$(CFG)" == "FreeImageQt - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../Dist" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Debug\FreeImageQtd.lib" -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Cmds=copy Debug\FreeImageQtd.lib ..\..\Dist copy FreeImageQt.h ..\..\Dist -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "FreeImageQt - Win32 Release" -# Name "FreeImageQt - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\FreeImageQt.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\FreeImageQt.h -# End Source File -# End Group -# End Target -# End Project diff --git a/freeimage241/Source/FreeImageQt/FreeImageQt.h b/freeimage241/Source/FreeImageQt/FreeImageQt.h deleted file mode 100644 index 7779a2e..0000000 --- a/freeimage241/Source/FreeImageQt/FreeImageQt.h +++ /dev/null @@ -1,88 +0,0 @@ -// ========================================================== -// FreeImage Qt -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// Based on tiffIO code written by Markus L. Noga -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifndef FREEIMAGEQT_H -#define FREEIMAGEQT_H - -// ---------------------------------------------------------- - -class QString; - -// Bitmap types ------------------------------------------------------------- - -struct FIBITMAP { void *data; }; - -// FreeImage type FI_ENUM (------------------------------------------------------ - -enum FREE_IMAGE_FORMAT { - FIF_UNKNOWN = -1, - FIF_BMP = 0, - FIF_ICO, - FIF_JPEG, - FIF_JNG, - FIF_KOALA, - FIF_LBM, - FIF_MNG, - FIF_PBM, - FIF_PBMRAW, - FIF_PCD, - FIF_PCX, - FIF_PGM, - FIF_PGMRAW, - FIF_PNG, - FIF_PPM, - FIF_PPMRAW, - FIF_RAS, - FIF_TARGA, - FIF_TIFF, - FIF_WBMP, -}; - -// ---------------------------------------------------------- - -typedef void (*FreeImage_OutputMessageFunction)(FREE_IMAGE_FORMAT fif, const char *msg); -void FIQT_SetOutputMessage(FreeImage_OutputMessageFunction omf); - -// ---------------------------------------------------------- - -bool FIQT_Register(bool new_formats_only = false); -bool FIQT_IsLoaded(); -void FIQT_Unregister(); -const char *FIQT_GetVersion(); -const char *FIQT_GetCopyrightMessage(); - -// ---------------------------------------------------------- - -int FIQT_GetFIFCount(); -FREE_IMAGE_FORMAT FIQT_GetFIFFromFormat(const char *format); -const char *FIQT_GetFormatFromFIF(FREE_IMAGE_FORMAT fif); -const char *FIQT_GetFIFDescription(FREE_IMAGE_FORMAT fif); -const char *FIQT_GetFIFExtensionList(FREE_IMAGE_FORMAT fif); -bool FIQT_FIFSupportsReading(FREE_IMAGE_FORMAT fif); -bool FIQT_FIFSupportsWriting(FREE_IMAGE_FORMAT fif); -FREE_IMAGE_FORMAT FIQT_GetFIFFromFilename(const char *filename); -const char *FIQT_GetFileTypeFromExtension(const char *format); -const char *FIQT_GetFileTypeFromFormat(FREE_IMAGE_FORMAT fif); // this function is deprecated - - -#endif //!FREEIMAGEQT_H diff --git a/freeimage241/Source/LibJPEG/LibJPEG.dsp b/freeimage241/Source/LibJPEG/LibJPEG.dsp deleted file mode 100644 index 2c220de..0000000 --- a/freeimage241/Source/LibJPEG/LibJPEG.dsp +++ /dev/null @@ -1,320 +0,0 @@ -# Microsoft Developer Studio Project File - Name="LibJPEG" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=LibJPEG - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "LibJPEG.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "LibJPEG.mak" CFG="LibJPEG - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "LibJPEG - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "LibJPEG - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName ""$/FreeImage/LibJPEG", IHAAAAAA" -# PROP Scc_LocalPath "." -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "LibJPEG - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G6 /Gd /MT /W3 /GX /O1 /I "..\zlib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "LibJPEG - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "LibJPEG - Win32 Release" -# Name "LibJPEG - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\jcapimin.c -# End Source File -# Begin Source File - -SOURCE=.\jcapistd.c -# End Source File -# Begin Source File - -SOURCE=.\jccoefct.c -# End Source File -# Begin Source File - -SOURCE=.\jccolor.c -# End Source File -# Begin Source File - -SOURCE=.\jcdctmgr.c -# End Source File -# Begin Source File - -SOURCE=.\jchuff.c -# End Source File -# Begin Source File - -SOURCE=.\jcinit.c -# End Source File -# Begin Source File - -SOURCE=.\jcmainct.c -# End Source File -# Begin Source File - -SOURCE=.\jcmarker.c -# End Source File -# Begin Source File - -SOURCE=.\jcmaster.c -# End Source File -# Begin Source File - -SOURCE=.\jcomapi.c -# End Source File -# Begin Source File - -SOURCE=.\jcparam.c -# End Source File -# Begin Source File - -SOURCE=.\jcphuff.c -# End Source File -# Begin Source File - -SOURCE=.\jcprepct.c -# End Source File -# Begin Source File - -SOURCE=.\jcsample.c -# End Source File -# Begin Source File - -SOURCE=.\jctrans.c -# End Source File -# Begin Source File - -SOURCE=.\jdapimin.c -# End Source File -# Begin Source File - -SOURCE=.\jdapistd.c -# End Source File -# Begin Source File - -SOURCE=.\jdatadst.c -# End Source File -# Begin Source File - -SOURCE=.\jdatasrc.c -# End Source File -# Begin Source File - -SOURCE=.\jdcoefct.c -# End Source File -# Begin Source File - -SOURCE=.\jdcolor.c -# End Source File -# Begin Source File - -SOURCE=.\jddctmgr.c -# End Source File -# Begin Source File - -SOURCE=.\jdhuff.c -# End Source File -# Begin Source File - -SOURCE=.\jdinput.c -# End Source File -# Begin Source File - -SOURCE=.\jdmainct.c -# End Source File -# Begin Source File - -SOURCE=.\jdmarker.c -# End Source File -# Begin Source File - -SOURCE=.\jdmaster.c -# End Source File -# Begin Source File - -SOURCE=.\jdmerge.c -# End Source File -# Begin Source File - -SOURCE=.\jdphuff.c -# End Source File -# Begin Source File - -SOURCE=.\jdpostct.c -# End Source File -# Begin Source File - -SOURCE=.\jdsample.c -# End Source File -# Begin Source File - -SOURCE=.\jdtrans.c -# End Source File -# Begin Source File - -SOURCE=.\jerror.c -# End Source File -# Begin Source File - -SOURCE=.\jfdctflt.c -# End Source File -# Begin Source File - -SOURCE=.\jfdctfst.c -# End Source File -# Begin Source File - -SOURCE=.\jfdctint.c -# End Source File -# Begin Source File - -SOURCE=.\jidctflt.c -# End Source File -# Begin Source File - -SOURCE=.\jidctfst.c -# End Source File -# Begin Source File - -SOURCE=.\jidctint.c -# End Source File -# Begin Source File - -SOURCE=.\jidctred.c -# End Source File -# Begin Source File - -SOURCE=.\jmemmgr.c -# End Source File -# Begin Source File - -SOURCE=.\jmemnobs.c -# End Source File -# Begin Source File - -SOURCE=.\jquant1.c -# End Source File -# Begin Source File - -SOURCE=.\jquant2.c -# End Source File -# Begin Source File - -SOURCE=.\jutils.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\jchuff.h -# End Source File -# Begin Source File - -SOURCE=.\jconfig.h -# End Source File -# Begin Source File - -SOURCE=.\jdct.h -# End Source File -# Begin Source File - -SOURCE=.\jdhuff.h -# End Source File -# Begin Source File - -SOURCE=.\jerror.h -# End Source File -# Begin Source File - -SOURCE=.\jinclude.h -# End Source File -# Begin Source File - -SOURCE=.\jmemsys.h -# End Source File -# Begin Source File - -SOURCE=.\jmorecfg.h -# End Source File -# Begin Source File - -SOURCE=.\jpegint.h -# End Source File -# Begin Source File - -SOURCE=.\jpeglib.h -# End Source File -# Begin Source File - -SOURCE=.\jversion.h -# End Source File -# End Group -# End Target -# End Project diff --git a/freeimage241/Source/LibJPEG/ansi2knr.c b/freeimage241/Source/LibJPEG/ansi2knr.c deleted file mode 100644 index 4e05fc2..0000000 --- a/freeimage241/Source/LibJPEG/ansi2knr.c +++ /dev/null @@ -1,693 +0,0 @@ -/* ansi2knr.c */ -/* Convert ANSI C function definitions to K&R ("traditional C") syntax */ - -/* -ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY. No author or distributor accepts responsibility to anyone for the -consequences of using it or for whether it serves any particular purpose or -works at all, unless he says so in writing. Refer to the GNU General Public -License (the "GPL") for full details. - -Everyone is granted permission to copy, modify and redistribute ansi2knr, -but only under the conditions described in the GPL. A copy of this license -is supposed to have been given to you along with ansi2knr so you can know -your rights and responsibilities. It should be in a file named COPYLEFT. -[In the IJG distribution, the GPL appears below, not in a separate file.] -Among other things, the copyright notice and this notice must be preserved -on all copies. - -We explicitly state here what we believe is already implied by the GPL: if -the ansi2knr program is distributed as a separate set of sources and a -separate executable file which are aggregated on a storage medium together -with another program, this in itself does not bring the other program under -the GPL, nor does the mere fact that such a program or the procedures for -constructing it invoke the ansi2knr executable bring any other part of the -program under the GPL. -*/ - -/* ----------- Here is the GNU GPL file COPYLEFT, referred to above ---------- ------ These terms do NOT apply to the JPEG software itself; see README ------ - - GHOSTSCRIPT GENERAL PUBLIC LICENSE - (Clarified 11 Feb 1988) - - Copyright (C) 1988 Richard M. Stallman - Everyone is permitted to copy and distribute verbatim copies of this - license, but changing it is not allowed. You can also use this wording - to make the terms for other programs. - - The license agreements of most software companies keep you at the -mercy of those companies. By contrast, our general public license is -intended to give everyone the right to share Ghostscript. To make sure -that you get the rights we want you to have, we need to make -restrictions that forbid anyone to deny you these rights or to ask you -to surrender the rights. Hence this license agreement. - - Specifically, we want to make sure that you have the right to give -away copies of Ghostscript, that you receive source code or else can get -it if you want it, that you can change Ghostscript or use pieces of it -in new free programs, and that you know you can do these things. - - To make sure that everyone has such rights, we have to forbid you to -deprive anyone else of these rights. For example, if you distribute -copies of Ghostscript, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must tell them their rights. - - Also, for our own protection, we must make certain that everyone finds -out that there is no warranty for Ghostscript. If Ghostscript is -modified by someone else and passed on, we want its recipients to know -that what they have is not what we distributed, so that any problems -introduced by others will not reflect on our reputation. - - Therefore we (Richard M. Stallman and the Free Software Foundation, -Inc.) make the following terms which say what you must do to be allowed -to distribute or change Ghostscript. - - - COPYING POLICIES - - 1. You may copy and distribute verbatim copies of Ghostscript source -code as you receive it, in any medium, provided that you conspicuously -and appropriately publish on each copy a valid copyright and license -notice "Copyright (C) 1989 Aladdin Enterprises. All rights reserved. -Distributed by Free Software Foundation, Inc." (or with whatever year is -appropriate); keep intact the notices on all files that refer to this -License Agreement and to the absence of any warranty; and give any other -recipients of the Ghostscript program a copy of this License Agreement -along with the program. You may charge a distribution fee for the -physical act of transferring a copy. - - 2. You may modify your copy or copies of Ghostscript or any portion of -it, and copy and distribute such modifications under the terms of -Paragraph 1 above, provided that you also do the following: - - a) cause the modified files to carry prominent notices stating - that you changed the files and the date of any change; and - - b) cause the whole of any work that you distribute or publish, - that in whole or in part contains or is a derivative of Ghostscript - or any part thereof, to be licensed at no charge to all third - parties on terms identical to those contained in this License - Agreement (except that you may choose to grant more extensive - warranty protection to some or all third parties, at your option). - - c) You may charge a distribution fee for the physical act of - transferring a copy, and you may at your option offer warranty - protection in exchange for a fee. - -Mere aggregation of another unrelated program with this program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other program under the scope of these terms. - - 3. You may copy and distribute Ghostscript (or a portion or derivative -of it, under Paragraph 2) in object code or executable form under the -terms of Paragraphs 1 and 2 above provided that you also do one of the -following: - - a) accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of - Paragraphs 1 and 2 above; or, - - b) accompany it with a written offer, valid for at least three - years, to give any third party free (except for a nominal - shipping charge) a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of - Paragraphs 1 and 2 above; or, - - c) accompany it with the information you received as to where the - corresponding source code may be obtained. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form alone.) - -For an executable file, complete source code means all the source code for -all modules it contains; but, as a special exception, it need not include -source code for modules which are standard libraries that accompany the -operating system on which the executable file runs. - - 4. You may not copy, sublicense, distribute or transfer Ghostscript -except as expressly provided under this License Agreement. Any attempt -otherwise to copy, sublicense, distribute or transfer Ghostscript is -void and your rights to use the program under this License agreement -shall be automatically terminated. However, parties who have received -computer software programs from you with this License Agreement will not -have their licenses terminated so long as such parties remain in full -compliance. - - 5. If you wish to incorporate parts of Ghostscript into other free -programs whose distribution conditions are different, write to the Free -Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not -yet worked out a simple rule that can be stated here, but we will often -permit this. We will be guided by the two goals of preserving the free -status of all derivatives of our free software and of promoting the -sharing and reuse of software. - -Your comments and suggestions about our licensing policies and our -software are welcome! Please contact the Free Software Foundation, -Inc., 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296. - - NO WARRANTY - - BECAUSE GHOSTSCRIPT IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY -NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT -WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD -M. STALLMAN, ALADDIN ENTERPRISES, L. PETER DEUTSCH, AND/OR OTHER PARTIES -PROVIDE GHOSTSCRIPT "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER -EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE -ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF GHOSTSCRIPT IS WITH -YOU. SHOULD GHOSTSCRIPT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL -NECESSARY SERVICING, REPAIR OR CORRECTION. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. -STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., L. PETER DEUTSCH, ALADDIN -ENTERPRISES, AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE -GHOSTSCRIPT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING -ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE -(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED -INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE -PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GHOSTSCRIPT, EVEN IF YOU -HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM -BY ANY OTHER PARTY. - --------------------- End of file COPYLEFT ------------------------------ -*/ - -/* - * Usage: - ansi2knr input_file [output_file] - * If no output_file is supplied, output goes to stdout. - * There are no error messages. - * - * ansi2knr recognizes function definitions by seeing a non-keyword - * identifier at the left margin, followed by a left parenthesis, - * with a right parenthesis as the last character on the line, - * and with a left brace as the first token on the following line - * (ignoring possible intervening comments). - * It will recognize a multi-line header provided that no intervening - * line ends with a left or right brace or a semicolon. - * These algorithms ignore whitespace and comments, except that - * the function name must be the first thing on the line. - * The following constructs will confuse it: - * - Any other construct that starts at the left margin and - * follows the above syntax (such as a macro or function call). - * - Some macros that tinker with the syntax of the function header. - */ - -/* - * The original and principal author of ansi2knr is L. Peter Deutsch - * . Other authors are noted in the change history - * that follows (in reverse chronological order): - lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with - compilers that don't understand void, as suggested by - Tom Lane - lpd 96-01-15 changed to require that the first non-comment token - on the line following a function header be a left brace, - to reduce sensitivity to macros, as suggested by Tom Lane - - lpd 95-06-22 removed #ifndefs whose sole purpose was to define - undefined preprocessor symbols as 0; changed all #ifdefs - for configuration symbols to #ifs - lpd 95-04-05 changed copyright notice to make it clear that - including ansi2knr in a program does not bring the entire - program under the GPL - lpd 94-12-18 added conditionals for systems where ctype macros - don't handle 8-bit characters properly, suggested by - Francois Pinard ; - removed --varargs switch (this is now the default) - lpd 94-10-10 removed CONFIG_BROKETS conditional - lpd 94-07-16 added some conditionals to help GNU `configure', - suggested by Francois Pinard ; - properly erase prototype args in function parameters, - contributed by Jim Avera ; - correct error in writeblanks (it shouldn't erase EOLs) - lpd 89-xx-xx original version - */ - -/* Most of the conditionals here are to make ansi2knr work with */ -/* or without the GNU configure machinery. */ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include - -#if HAVE_CONFIG_H - -/* - For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). - This will define HAVE_CONFIG_H and so, activate the following lines. - */ - -# if STDC_HEADERS || HAVE_STRING_H -# include -# else -# include -# endif - -#else /* not HAVE_CONFIG_H */ - -/* Otherwise do it the hard way */ - -# ifdef BSD -# include -# else -# ifdef VMS - extern int strlen(), strncmp(); -# else -# include -# endif -# endif - -#endif /* not HAVE_CONFIG_H */ - -#if STDC_HEADERS -# include -#else -/* - malloc and free should be declared in stdlib.h, - but if you've got a K&R compiler, they probably aren't. - */ -# ifdef MSDOS -# include -# else -# ifdef VMS - extern char *malloc(); - extern void free(); -# else - extern char *malloc(); - extern int free(); -# endif -# endif - -#endif - -/* - * The ctype macros don't always handle 8-bit characters correctly. - * Compensate for this here. - */ -#ifdef isascii -# undef HAVE_ISASCII /* just in case */ -# define HAVE_ISASCII 1 -#else -#endif -#if STDC_HEADERS || !HAVE_ISASCII -# define is_ascii(c) 1 -#else -# define is_ascii(c) isascii(c) -#endif - -#define is_space(c) (is_ascii(c) && isspace(c)) -#define is_alpha(c) (is_ascii(c) && isalpha(c)) -#define is_alnum(c) (is_ascii(c) && isalnum(c)) - -/* Scanning macros */ -#define isidchar(ch) (is_alnum(ch) || (ch) == '_') -#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') - -/* Forward references */ -char *skipspace(); -int writeblanks(); -int test1(); -int convert1(); - -/* The main program */ -int -main(argc, argv) - int argc; - char *argv[]; -{ FILE *in, *out; -#define bufsize 5000 /* arbitrary size */ - char *buf; - char *line; - char *more; - /* - * In previous versions, ansi2knr recognized a --varargs switch. - * If this switch was supplied, ansi2knr would attempt to convert - * a ... argument to va_alist and va_dcl; if this switch was not - * supplied, ansi2knr would simply drop any such arguments. - * Now, ansi2knr always does this conversion, and we only - * check for this switch for backward compatibility. - */ - int convert_varargs = 1; - - if ( argc > 1 && argv[1][0] == '-' ) - { if ( !strcmp(argv[1], "--varargs") ) - { convert_varargs = 1; - argc--; - argv++; - } - else - { fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); - exit(1); - } - } - switch ( argc ) - { - default: - printf("Usage: ansi2knr input_file [output_file]\n"); - exit(0); - case 2: - out = stdout; - break; - case 3: - out = fopen(argv[2], "w"); - if ( out == NULL ) - { fprintf(stderr, "Cannot open output file %s\n", argv[2]); - exit(1); - } - } - in = fopen(argv[1], "r"); - if ( in == NULL ) - { fprintf(stderr, "Cannot open input file %s\n", argv[1]); - exit(1); - } - fprintf(out, "#line 1 \"%s\"\n", argv[1]); - buf = malloc(bufsize); - line = buf; - while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) - { -test: line += strlen(line); - switch ( test1(buf) ) - { - case 2: /* a function header */ - convert1(buf, out, 1, convert_varargs); - break; - case 1: /* a function */ - /* Check for a { at the start of the next line. */ - more = ++line; -f: if ( line >= buf + (bufsize - 1) ) /* overflow check */ - goto wl; - if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL ) - goto wl; - switch ( *skipspace(more, 1) ) - { - case '{': - /* Definitely a function header. */ - convert1(buf, out, 0, convert_varargs); - fputs(more, out); - break; - case 0: - /* The next line was blank or a comment: */ - /* keep scanning for a non-comment. */ - line += strlen(line); - goto f; - default: - /* buf isn't a function header, but */ - /* more might be. */ - fputs(buf, out); - strcpy(buf, more); - line = buf; - goto test; - } - break; - case -1: /* maybe the start of a function */ - if ( line != buf + (bufsize - 1) ) /* overflow check */ - continue; - /* falls through */ - default: /* not a function */ -wl: fputs(buf, out); - break; - } - line = buf; - } - if ( line != buf ) - fputs(buf, out); - free(buf); - fclose(out); - fclose(in); - return 0; -} - -/* Skip over space and comments, in either direction. */ -char * -skipspace(p, dir) - register char *p; - register int dir; /* 1 for forward, -1 for backward */ -{ for ( ; ; ) - { while ( is_space(*p) ) - p += dir; - if ( !(*p == '/' && p[dir] == '*') ) - break; - p += dir; p += dir; - while ( !(*p == '*' && p[dir] == '/') ) - { if ( *p == 0 ) - return p; /* multi-line comment?? */ - p += dir; - } - p += dir; p += dir; - } - return p; -} - -/* - * Write blanks over part of a string. - * Don't overwrite end-of-line characters. - */ -int -writeblanks(start, end) - char *start; - char *end; -{ char *p; - for ( p = start; p < end; p++ ) - if ( *p != '\r' && *p != '\n' ) - *p = ' '; - return 0; -} - -/* - * Test whether the string in buf is a function definition. - * The string may contain and/or end with a newline. - * Return as follows: - * 0 - definitely not a function definition; - * 1 - definitely a function definition; - * 2 - definitely a function prototype (NOT USED); - * -1 - may be the beginning of a function definition, - * append another line and look again. - * The reason we don't attempt to convert function prototypes is that - * Ghostscript's declaration-generating macros look too much like - * prototypes, and confuse the algorithms. - */ -int -test1(buf) - char *buf; -{ register char *p = buf; - char *bend; - char *endfn; - int contin; - - if ( !isidfirstchar(*p) ) - return 0; /* no name at left margin */ - bend = skipspace(buf + strlen(buf) - 1, -1); - switch ( *bend ) - { - case ';': contin = 0 /*2*/; break; - case ')': contin = 1; break; - case '{': return 0; /* not a function */ - case '}': return 0; /* not a function */ - default: contin = -1; - } - while ( isidchar(*p) ) - p++; - endfn = p; - p = skipspace(p, 1); - if ( *p++ != '(' ) - return 0; /* not a function */ - p = skipspace(p, 1); - if ( *p == ')' ) - return 0; /* no parameters */ - /* Check that the apparent function name isn't a keyword. */ - /* We only need to check for keywords that could be followed */ - /* by a left parenthesis (which, unfortunately, is most of them). */ - { static char *words[] = - { "asm", "auto", "case", "char", "const", "double", - "extern", "float", "for", "if", "int", "long", - "register", "return", "short", "signed", "sizeof", - "static", "switch", "typedef", "unsigned", - "void", "volatile", "while", 0 - }; - char **key = words; - char *kp; - int len = endfn - buf; - - while ( (kp = *key) != 0 ) - { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) - return 0; /* name is a keyword */ - key++; - } - } - return contin; -} - -/* Convert a recognized function definition or header to K&R syntax. */ -int -convert1(buf, out, header, convert_varargs) - char *buf; - FILE *out; - int header; /* Boolean */ - int convert_varargs; /* Boolean */ -{ char *endfn; - register char *p; - char **breaks; - unsigned num_breaks = 2; /* for testing */ - char **btop; - char **bp; - char **ap; - char *vararg = 0; - - /* Pre-ANSI implementations don't agree on whether strchr */ - /* is called strchr or index, so we open-code it here. */ - for ( endfn = buf; *(endfn++) != '('; ) - ; -top: p = endfn; - breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); - if ( breaks == 0 ) - { /* Couldn't allocate break table, give up */ - fprintf(stderr, "Unable to allocate break table!\n"); - fputs(buf, out); - return -1; - } - btop = breaks + num_breaks * 2 - 2; - bp = breaks; - /* Parse the argument list */ - do - { int level = 0; - char *lp = NULL; - char *rp; - char *end = NULL; - - if ( bp >= btop ) - { /* Filled up break table. */ - /* Allocate a bigger one and start over. */ - free((char *)breaks); - num_breaks <<= 1; - goto top; - } - *bp++ = p; - /* Find the end of the argument */ - for ( ; end == NULL; p++ ) - { switch(*p) - { - case ',': - if ( !level ) end = p; - break; - case '(': - if ( !level ) lp = p; - level++; - break; - case ')': - if ( --level < 0 ) end = p; - else rp = p; - break; - case '/': - p = skipspace(p, 1) - 1; - break; - default: - ; - } - } - /* Erase any embedded prototype parameters. */ - if ( lp ) - writeblanks(lp + 1, rp); - p--; /* back up over terminator */ - /* Find the name being declared. */ - /* This is complicated because of procedure and */ - /* array modifiers. */ - for ( ; ; ) - { p = skipspace(p - 1, -1); - switch ( *p ) - { - case ']': /* skip array dimension(s) */ - case ')': /* skip procedure args OR name */ - { int level = 1; - while ( level ) - switch ( *--p ) - { - case ']': case ')': level++; break; - case '[': case '(': level--; break; - case '/': p = skipspace(p, -1) + 1; break; - default: ; - } - } - if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) - { /* We found the name being declared */ - while ( !isidfirstchar(*p) ) - p = skipspace(p, 1) + 1; - goto found; - } - break; - default: - goto found; - } - } -found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) - { if ( convert_varargs ) - { *bp++ = "va_alist"; - vararg = p-2; - } - else - { p++; - if ( bp == breaks + 1 ) /* sole argument */ - writeblanks(breaks[0], p); - else - writeblanks(bp[-1] - 1, p); - bp--; - } - } - else - { while ( isidchar(*p) ) p--; - *bp++ = p+1; - } - p = end; - } - while ( *p++ == ',' ); - *bp = p; - /* Make a special check for 'void' arglist */ - if ( bp == breaks+2 ) - { p = skipspace(breaks[0], 1); - if ( !strncmp(p, "void", 4) ) - { p = skipspace(p+4, 1); - if ( p == breaks[2] - 1 ) - { bp = breaks; /* yup, pretend arglist is empty */ - writeblanks(breaks[0], p + 1); - } - } - } - /* Put out the function name and left parenthesis. */ - p = buf; - while ( p != endfn ) putc(*p, out), p++; - /* Put out the declaration. */ - if ( header ) - { fputs(");", out); - for ( p = breaks[0]; *p; p++ ) - if ( *p == '\r' || *p == '\n' ) - putc(*p, out); - } - else - { for ( ap = breaks+1; ap < bp; ap += 2 ) - { p = *ap; - while ( isidchar(*p) ) - putc(*p, out), p++; - if ( ap < bp - 1 ) - fputs(", ", out); - } - fputs(") ", out); - /* Put out the argument declarations */ - for ( ap = breaks+2; ap <= bp; ap += 2 ) - (*ap)[-1] = ';'; - if ( vararg != 0 ) - { *vararg = 0; - fputs(breaks[0], out); /* any prior args */ - fputs("va_dcl", out); /* the final arg */ - fputs(bp[0], out); - } - else - fputs(breaks[0], out); - } - free((char *)breaks); - return 0; -} diff --git a/freeimage241/Source/LibJPEG/cderror.h b/freeimage241/Source/LibJPEG/cderror.h deleted file mode 100644 index 70435e1..0000000 --- a/freeimage241/Source/LibJPEG/cderror.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * cderror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the cjpeg/djpeg - * applications. These strings are not needed as part of the JPEG library - * proper. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef CDERROR_H -#define CDERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* CDERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */ - -#ifdef BMP_SUPPORTED -JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format") -JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported") -JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length") -JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1") -JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") -JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") -JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM") -JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image") -JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") -JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image") -JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image") -#endif /* BMP_SUPPORTED */ - -#ifdef GIF_SUPPORTED -JMESSAGE(JERR_GIF_BUG, "GIF output got confused") -JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d") -JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB") -JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file") -JMESSAGE(JERR_GIF_NOT, "Not a GIF file") -JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image") -JMESSAGE(JTRC_GIF_BADVERSION, - "Warning: unexpected GIF version number '%c%c%c'") -JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x") -JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input") -JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file") -JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring") -JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image") -JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits") -#endif /* GIF_SUPPORTED */ - -#ifdef PPM_SUPPORTED -JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB") -JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file") -JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file") -JMESSAGE(JTRC_PGM, "%ux%u PGM image") -JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image") -JMESSAGE(JTRC_PPM, "%ux%u PPM image") -JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image") -#endif /* PPM_SUPPORTED */ - -#ifdef RLE_SUPPORTED -JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library") -JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB") -JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE") -JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file") -JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header") -JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header") -JMESSAGE(JERR_RLE_NOT, "Not an RLE file") -JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE") -JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup") -JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file") -JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d") -JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file") -JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d") -JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d") -#endif /* RLE_SUPPORTED */ - -#ifdef TARGA_SUPPORTED -JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format") -JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file") -JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB") -JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image") -JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image") -JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image") -#else -JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled") -#endif /* TARGA_SUPPORTED */ - -JMESSAGE(JERR_BAD_CMAP_FILE, - "Color map file is invalid or of unsupported format") -JMESSAGE(JERR_TOO_MANY_COLORS, - "Output file format cannot handle %d colormap entries") -JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed") -#ifdef TARGA_SUPPORTED -JMESSAGE(JERR_UNKNOWN_FORMAT, - "Unrecognized input file format --- perhaps you need -targa") -#else -JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format") -#endif -JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTADDONCODE -} ADDON_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE diff --git a/freeimage241/Source/LibJPEG/cdjpeg.c b/freeimage241/Source/LibJPEG/cdjpeg.c deleted file mode 100644 index b6250ff..0000000 --- a/freeimage241/Source/LibJPEG/cdjpeg.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * cdjpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains common support routines used by the IJG application - * programs (cjpeg, djpeg, jpegtran). - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include /* to declare isupper(), tolower() */ -#ifdef NEED_SIGNAL_CATCHER -#include /* to declare signal() */ -#endif -#ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ -#endif - - -/* - * Signal catcher to ensure that temporary files are removed before aborting. - * NB: for Amiga Manx C this is actually a global routine named _abort(); - * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... - */ - -#ifdef NEED_SIGNAL_CATCHER - -static j_common_ptr sig_cinfo; - -void /* must be global for Manx C */ -signal_catcher (int signum) -{ - if (sig_cinfo != NULL) { - if (sig_cinfo->err != NULL) /* turn off trace output */ - sig_cinfo->err->trace_level = 0; - jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ - } - exit(EXIT_FAILURE); -} - - -GLOBAL(void) -enable_signal_catcher (j_common_ptr cinfo) -{ - sig_cinfo = cinfo; -#ifdef SIGINT /* not all systems have SIGINT */ - signal(SIGINT, signal_catcher); -#endif -#ifdef SIGTERM /* not all systems have SIGTERM */ - signal(SIGTERM, signal_catcher); -#endif -} - -#endif - - -/* - * Optional progress monitor: display a percent-done figure on stderr. - */ - -#ifdef PROGRESS_REPORT - -METHODDEF(void) -progress_monitor (j_common_ptr cinfo) -{ - cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; - int total_passes = prog->pub.total_passes + prog->total_extra_passes; - int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); - - if (percent_done != prog->percent_done) { - prog->percent_done = percent_done; - if (total_passes > 1) { - fprintf(stderr, "\rPass %d/%d: %3d%% ", - prog->pub.completed_passes + prog->completed_extra_passes + 1, - total_passes, percent_done); - } else { - fprintf(stderr, "\r %3d%% ", percent_done); - } - fflush(stderr); - } -} - - -GLOBAL(void) -start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress) -{ - /* Enable progress display, unless trace output is on */ - if (cinfo->err->trace_level == 0) { - progress->pub.progress_monitor = progress_monitor; - progress->completed_extra_passes = 0; - progress->total_extra_passes = 0; - progress->percent_done = -1; - cinfo->progress = &progress->pub; - } -} - - -GLOBAL(void) -end_progress_monitor (j_common_ptr cinfo) -{ - /* Clear away progress display */ - if (cinfo->err->trace_level == 0) { - fprintf(stderr, "\r \r"); - fflush(stderr); - } -} - -#endif - - -/* - * Case-insensitive matching of possibly-abbreviated keyword switches. - * keyword is the constant keyword (must be lower case already), - * minchars is length of minimum legal abbreviation. - */ - -GLOBAL(boolean) -keymatch (char * arg, const char * keyword, int minchars) -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return FALSE; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return FALSE; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return FALSE; - return TRUE; /* A-OK */ -} - - -/* - * Routines to establish binary I/O mode for stdin and stdout. - * Non-Unix systems often require some hacking to get out of text mode. - */ - -GLOBAL(FILE *) -read_stdin (void) -{ - FILE * input_file = stdin; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdin\n"); - exit(EXIT_FAILURE); - } -#endif - return input_file; -} - - -GLOBAL(FILE *) -write_stdout (void) -{ - FILE * output_file = stdout; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdout), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdout\n"); - exit(EXIT_FAILURE); - } -#endif - return output_file; -} diff --git a/freeimage241/Source/LibJPEG/cdjpeg.h b/freeimage241/Source/LibJPEG/cdjpeg.h deleted file mode 100644 index 2b387b6..0000000 --- a/freeimage241/Source/LibJPEG/cdjpeg.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * cdjpeg.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains common declarations for the sample applications - * cjpeg and djpeg. It is NOT used by the core JPEG library. - */ - -#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ -#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" /* get library error codes too */ -#include "cderror.h" /* get application-specific error codes */ - - -/* - * Object interface for cjpeg's source file decoding modules - */ - -typedef struct cjpeg_source_struct * cjpeg_source_ptr; - -struct cjpeg_source_struct { - JMETHOD(void, start_input, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - JMETHOD(void, finish_input, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); - - FILE *input_file; - - JSAMPARRAY buffer; - JDIMENSION buffer_height; -}; - - -/* - * Object interface for djpeg's output file encoding modules - */ - -typedef struct djpeg_dest_struct * djpeg_dest_ptr; - -struct djpeg_dest_struct { - /* start_output is called after jpeg_start_decompress finishes. - * The color map will be ready at this time, if one is needed. - */ - JMETHOD(void, start_output, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo)); - /* Emit the specified number of pixel rows from the buffer. */ - JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied)); - /* Finish up at the end of the image. */ - JMETHOD(void, finish_output, (j_decompress_ptr cinfo, - djpeg_dest_ptr dinfo)); - - /* Target file spec; filled in by djpeg.c after object is created. */ - FILE * output_file; - - /* Output pixel-row buffer. Created by module init or start_output. - * Width is cinfo->output_width * cinfo->output_components; - * height is buffer_height. - */ - JSAMPARRAY buffer; - JDIMENSION buffer_height; -}; - - -/* - * cjpeg/djpeg may need to perform extra passes to convert to or from - * the source/destination file format. The JPEG library does not know - * about these passes, but we'd like them to be counted by the progress - * monitor. We use an expanded progress monitor object to hold the - * additional pass count. - */ - -struct cdjpeg_progress_mgr { - struct jpeg_progress_mgr pub; /* fields known to JPEG library */ - int completed_extra_passes; /* extra passes completed */ - int total_extra_passes; /* total extra */ - /* last printed percentage stored here to avoid multiple printouts */ - int percent_done; -}; - -typedef struct cdjpeg_progress_mgr * cd_progress_ptr; - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jinit_read_bmp jIRdBMP -#define jinit_write_bmp jIWrBMP -#define jinit_read_gif jIRdGIF -#define jinit_write_gif jIWrGIF -#define jinit_read_ppm jIRdPPM -#define jinit_write_ppm jIWrPPM -#define jinit_read_rle jIRdRLE -#define jinit_write_rle jIWrRLE -#define jinit_read_targa jIRdTarga -#define jinit_write_targa jIWrTarga -#define read_quant_tables RdQTables -#define read_scan_script RdScnScript -#define set_quant_slots SetQSlots -#define set_sample_factors SetSFacts -#define read_color_map RdCMap -#define enable_signal_catcher EnSigCatcher -#define start_progress_monitor StProgMon -#define end_progress_monitor EnProgMon -#define read_stdin RdStdin -#define write_stdout WrStdout -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Module selection routines for I/O modules. */ - -EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo, - boolean is_os2)); -EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo)); -EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo)); -EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo)); - -/* cjpeg support routines (in rdswitch.c) */ - -EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename, - int scale_factor, boolean force_baseline)); -EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename)); -EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg)); -EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); - -/* djpeg support routines (in rdcolmap.c) */ - -EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* common support routines (in cdjpeg.c) */ - -EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo)); -EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo, - cd_progress_ptr progress)); -EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo)); -EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars)); -EXTERN(FILE *) read_stdin JPP((void)); -EXTERN(FILE *) write_stdout JPP((void)); - -/* miscellaneous useful macros */ - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define WRITE_BINARY "w" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define WRITE_BINARY "wb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define WRITE_BINARY "wb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif -#ifndef EXIT_WARNING -#ifdef VMS -#define EXIT_WARNING 1 /* VMS is very nonstandard */ -#else -#define EXIT_WARNING 2 -#endif -#endif diff --git a/freeimage241/Source/LibJPEG/change.log b/freeimage241/Source/LibJPEG/change.log deleted file mode 100644 index 74102c0..0000000 --- a/freeimage241/Source/LibJPEG/change.log +++ /dev/null @@ -1,217 +0,0 @@ -CHANGE LOG for Independent JPEG Group's JPEG software - - -Version 6b 27-Mar-1998 ------------------------ - -jpegtran has new features for lossless image transformations (rotation -and flipping) as well as "lossless" reduction to grayscale. - -jpegtran now copies comments by default; it has a -copy switch to enable -copying all APPn blocks as well, or to suppress comments. (Formerly it -always suppressed comments and APPn blocks.) jpegtran now also preserves -JFIF version and resolution information. - -New decompressor library feature: COM and APPn markers found in the input -file can be saved in memory for later use by the application. (Before, -you had to code this up yourself with a custom marker processor.) - -There is an unused field "void * client_data" now in compress and decompress -parameter structs; this may be useful in some applications. - -JFIF version number information is now saved by the decoder and accepted by -the encoder. jpegtran uses this to copy the source file's version number, -to ensure "jpegtran -copy all" won't create bogus files that contain JFXX -extensions but claim to be version 1.01. Applications that generate their -own JFXX extension markers also (finally) have a supported way to cause the -encoder to emit JFIF version number 1.02. - -djpeg's trace mode reports JFIF 1.02 thumbnail images as such, rather -than as unknown APP0 markers. - -In -verbose mode, djpeg and rdjpgcom will try to print the contents of -APP12 markers as text. Some digital cameras store useful text information -in APP12 markers. - -Handling of truncated data streams is more robust: blocks beyond the one in -which the error occurs will be output as uniform gray, or left unchanged -if decoding a progressive JPEG. The appearance no longer depends on the -Huffman tables being used. - -Huffman tables are checked for validity much more carefully than before. - -To avoid the Unisys LZW patent, djpeg's GIF output capability has been -changed to produce "uncompressed GIFs", and cjpeg's GIF input capability -has been removed altogether. We're not happy about it either, but there -seems to be no good alternative. - -The configure script now supports building libjpeg as a shared library -on many flavors of Unix (all the ones that GNU libtool knows how to -build shared libraries for). Use "./configure --enable-shared" to -try this out. - -New jconfig file and makefiles for Microsoft Visual C++ and Developer Studio. -Also, a jconfig file and a build script for Metrowerks CodeWarrior -on Apple Macintosh. makefile.dj has been updated for DJGPP v2, and there -are miscellaneous other minor improvements in the makefiles. - -jmemmac.c now knows how to create temporary files following Mac System 7 -conventions. - -djpeg's -map switch is now able to read raw-format PPM files reliably. - -cjpeg -progressive -restart no longer generates any unnecessary DRI markers. - -Multiple calls to jpeg_simple_progression for a single JPEG object -no longer leak memory. - - -Version 6a 7-Feb-96 --------------------- - -Library initialization sequence modified to detect version mismatches -and struct field packing mismatches between library and calling application. -This change requires applications to be recompiled, but does not require -any application source code change. - -All routine declarations changed to the style "GLOBAL(type) name ...", -that is, GLOBAL, LOCAL, METHODDEF, EXTERN are now macros taking the -routine's return type as an argument. This makes it possible to add -Microsoft-style linkage keywords to all the routines by changing just -these macros. Note that any application code that was using these macros -will have to be changed. - -DCT coefficient quantization tables are now stored in normal array order -rather than zigzag order. Application code that calls jpeg_add_quant_table, -or otherwise manipulates quantization tables directly, will need to be -changed. If you need to make such code work with either older or newer -versions of the library, a test like "#if JPEG_LIB_VERSION >= 61" is -recommended. - -djpeg's trace capability now dumps DQT tables in natural order, not zigzag -order. This allows the trace output to be made into a "-qtables" file -more easily. - -New system-dependent memory manager module for use on Apple Macintosh. - -Fix bug in cjpeg's -smooth option: last one or two scanlines would be -duplicates of the prior line unless the image height mod 16 was 1 or 2. - -Repair minor problems in VMS, BCC, MC6 makefiles. - -New configure script based on latest GNU Autoconf. - -Correct the list of include files needed by MetroWerks C for ccommand(). - -Numerous small documentation updates. - - -Version 6 2-Aug-95 -------------------- - -Progressive JPEG support: library can read and write full progressive JPEG -files. A "buffered image" mode supports incremental decoding for on-the-fly -display of progressive images. Simply recompiling an existing IJG-v5-based -decoder with v6 should allow it to read progressive files, though of course -without any special progressive display. - -New "jpegtran" application performs lossless transcoding between different -JPEG formats; primarily, it can be used to convert baseline to progressive -JPEG and vice versa. In support of jpegtran, the library now allows lossless -reading and writing of JPEG files as DCT coefficient arrays. This ability -may be of use in other applications. - -Notes for programmers: -* We changed jpeg_start_decompress() to be able to suspend; this makes all -decoding modes available to suspending-input applications. However, -existing applications that use suspending input will need to be changed -to check the return value from jpeg_start_decompress(). You don't need to -do anything if you don't use a suspending data source. -* We changed the interface to the virtual array routines: access_virt_array -routines now take a count of the number of rows to access this time. The -last parameter to request_virt_array routines is now interpreted as the -maximum number of rows that may be accessed at once, but not necessarily -the height of every access. - - -Version 5b 15-Mar-95 ---------------------- - -Correct bugs with grayscale images having v_samp_factor > 1. - -jpeg_write_raw_data() now supports output suspension. - -Correct bugs in "configure" script for case of compiling in -a directory other than the one containing the source files. - -Repair bug in jquant1.c: sometimes didn't use as many colors as it could. - -Borland C makefile and jconfig file work under either MS-DOS or OS/2. - -Miscellaneous improvements to documentation. - - -Version 5a 7-Dec-94 --------------------- - -Changed color conversion roundoff behavior so that grayscale values are -represented exactly. (This causes test image files to change.) - -Make ordered dither use 16x16 instead of 4x4 pattern for a small quality -improvement. - -New configure script based on latest GNU Autoconf. -Fix configure script to handle CFLAGS correctly. -Rename *.auto files to *.cfg, so that configure script still works if -file names have been truncated for DOS. - -Fix bug in rdbmp.c: didn't allow for extra data between header and image. - -Modify rdppm.c/wrppm.c to handle 2-byte raw PPM/PGM formats for 12-bit data. - -Fix several bugs in rdrle.c. - -NEED_SHORT_EXTERNAL_NAMES option was broken. - -Revise jerror.h/jerror.c for more flexibility in message table. - -Repair oversight in jmemname.c NO_MKTEMP case: file could be there -but unreadable. - - -Version 5 24-Sep-94 --------------------- - -Version 5 represents a nearly complete redesign and rewrite of the IJG -software. Major user-visible changes include: - * Automatic configuration simplifies installation for most Unix systems. - * A range of speed vs. image quality tradeoffs are supported. - This includes resizing of an image during decompression: scaling down - by a factor of 1/2, 1/4, or 1/8 is handled very efficiently. - * New programs rdjpgcom and wrjpgcom allow insertion and extraction - of text comments in a JPEG file. - -The application programmer's interface to the library has changed completely. -Notable improvements include: - * We have eliminated the use of callback routines for handling the - uncompressed image data. The application now sees the library as a - set of routines that it calls to read or write image data on a - scanline-by-scanline basis. - * The application image data is represented in a conventional interleaved- - pixel format, rather than as a separate array for each color channel. - This can save a copying step in many programs. - * The handling of compressed data has been cleaned up: the application can - supply routines to source or sink the compressed data. It is possible to - suspend processing on source/sink buffer overrun, although this is not - supported in all operating modes. - * All static state has been eliminated from the library, so that multiple - instances of compression or decompression can be active concurrently. - * JPEG abbreviated datastream formats are supported, ie, quantization and - Huffman tables can be stored separately from the image data. - * And not only that, but the documentation of the library has improved - considerably! - - -The last widely used release before the version 5 rewrite was version 4A of -18-Feb-93. Change logs before that point have been discarded, since they -are not of much interest after the rewrite. diff --git a/freeimage241/Source/LibJPEG/cjpeg.c b/freeimage241/Source/LibJPEG/cjpeg.c deleted file mode 100644 index f2a929f..0000000 --- a/freeimage241/Source/LibJPEG/cjpeg.c +++ /dev/null @@ -1,606 +0,0 @@ -/* - * cjpeg.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for the JPEG compressor. - * It should work on any system with Unix- or MS-DOS-style command lines. - * - * Two different command line styles are permitted, depending on the - * compile-time switch TWO_FILE_COMMANDLINE: - * cjpeg [options] inputfile outputfile - * cjpeg [options] [inputfile] - * In the second style, output is always to standard output, which you'd - * normally redirect to a file or pipe to some other program. Input is - * either from a named file or from standard input (typically redirected). - * The second style is convenient on Unix but is unhelpful on systems that - * don't support pipes. Also, you MUST use the first style if your system - * doesn't do binary I/O to stdin/stdout. - * To simplify script writing, the "-outfile" switch is provided. The syntax - * cjpeg [options] -outfile outputfile inputfile - * works regardless of which command line style is used. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "jversion.h" /* for version message */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - - -/* Create the add-on message string table. */ - -#define JMESSAGE(code,string) string , - -static const char * const cdjpeg_message_table[] = { -#include "cderror.h" - NULL -}; - - -/* - * This routine determines what format the input file is, - * and selects the appropriate input-reading module. - * - * To determine which family of input formats the file belongs to, - * we may look only at the first byte of the file, since C does not - * guarantee that more than one character can be pushed back with ungetc. - * Looking at additional bytes would require one of these approaches: - * 1) assume we can fseek() the input file (fails for piped input); - * 2) assume we can push back more than one character (works in - * some C implementations, but unportable); - * 3) provide our own buffering (breaks input readers that want to use - * stdio directly, such as the RLE library); - * or 4) don't put back the data, and modify the input_init methods to assume - * they start reading after the start of file (also breaks RLE library). - * #1 is attractive for MS-DOS but is untenable on Unix. - * - * The most portable solution for file types that can't be identified by their - * first byte is to make the user tell us what they are. This is also the - * only approach for "raw" file types that contain only arbitrary values. - * We presently apply this method for Targa files. Most of the time Targa - * files start with 0x00, so we recognize that case. Potentially, however, - * a Targa file could start with any byte value (byte 0 is the length of the - * seldom-used ID field), so we provide a switch to force Targa input mode. - */ - -static boolean is_targa; /* records user -targa switch */ - - -LOCAL(cjpeg_source_ptr) -select_file_type (j_compress_ptr cinfo, FILE * infile) -{ - int c; - - if (is_targa) { -#ifdef TARGA_SUPPORTED - return jinit_read_targa(cinfo); -#else - ERREXIT(cinfo, JERR_TGA_NOTCOMP); -#endif - } - - if ((c = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_INPUT_EMPTY); - if (ungetc(c, infile) == EOF) - ERREXIT(cinfo, JERR_UNGETC_FAILED); - - switch (c) { -#ifdef BMP_SUPPORTED - case 'B': - return jinit_read_bmp(cinfo); -#endif -#ifdef GIF_SUPPORTED - case 'G': - return jinit_read_gif(cinfo); -#endif -#ifdef PPM_SUPPORTED - case 'P': - return jinit_read_ppm(cinfo); -#endif -#ifdef RLE_SUPPORTED - case 'R': - return jinit_read_rle(cinfo); -#endif -#ifdef TARGA_SUPPORTED - case 0x00: - return jinit_read_targa(cinfo); -#endif - default: - ERREXIT(cinfo, JERR_UNKNOWN_FORMAT); - break; - } - - return NULL; /* suppress compiler warnings */ -} - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -quality N Compression quality (0..100; 5-95 is useful range)\n"); - fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); -#ifdef ENTROPY_OPT_SUPPORTED - fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); -#endif -#ifdef C_PROGRESSIVE_SUPPORTED - fprintf(stderr, " -progressive Create progressive JPEG file\n"); -#endif -#ifdef TARGA_SUPPORTED - fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n"); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef DCT_ISLOW_SUPPORTED - fprintf(stderr, " -dct int Use integer DCT method%s\n", - (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); -#endif -#ifdef DCT_IFAST_SUPPORTED - fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", - (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); -#endif -#ifdef DCT_FLOAT_SUPPORTED - fprintf(stderr, " -dct float Use floating-point DCT method%s\n", - (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); -#endif - fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); -#ifdef INPUT_SMOOTHING_SUPPORTED - fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n"); -#endif - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - fprintf(stderr, "Switches for wizards:\n"); -#ifdef C_ARITH_CODING_SUPPORTED - fprintf(stderr, " -arithmetic Use arithmetic coding\n"); -#endif - fprintf(stderr, " -baseline Force baseline quantization tables\n"); - fprintf(stderr, " -qtables file Use quantization tables given in file\n"); - fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); - fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n"); -#ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); -#endif - exit(EXIT_FAILURE); -} - - -LOCAL(int) -parse_switches (j_compress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - int quality; /* -quality parameter */ - int q_scale_factor; /* scaling percentage for -qtables */ - boolean force_baseline; - boolean simple_progressive; - char * qtablefile = NULL; /* saves -qtables filename if any */ - char * qslotsarg = NULL; /* saves -qslots parm if any */ - char * samplearg = NULL; /* saves -sample parm if any */ - char * scansarg = NULL; /* saves -scans parm if any */ - - /* Set up default JPEG parameters. */ - /* Note that default -quality level need not, and does not, - * match the default scaling for an explicit -qtables argument. - */ - quality = 75; /* default -quality value */ - q_scale_factor = 100; /* default to no scaling for -qtables */ - force_baseline = FALSE; /* by default, allow 16-bit quantizers */ - simple_progressive = FALSE; - is_targa = FALSE; - outfilename = NULL; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "arithmetic", 1)) { - /* Use arithmetic coding. */ -#ifdef C_ARITH_CODING_SUPPORTED - cinfo->arith_code = TRUE; -#else - fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "baseline", 1)) { - /* Force baseline-compatible output (8-bit quantizer values). */ - force_baseline = TRUE; - - } else if (keymatch(arg, "dct", 2)) { - /* Select DCT algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "int", 1)) { - cinfo->dct_method = JDCT_ISLOW; - } else if (keymatch(argv[argn], "fast", 2)) { - cinfo->dct_method = JDCT_IFAST; - } else if (keymatch(argv[argn], "float", 2)) { - cinfo->dct_method = JDCT_FLOAT; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { - /* Force a monochrome JPEG file to be generated. */ - jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { - /* Enable entropy parm optimization. */ -#ifdef ENTROPY_OPT_SUPPORTED - cinfo->optimize_coding = TRUE; -#else - fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "progressive", 1)) { - /* Select simple progressive mode. */ -#ifdef C_PROGRESSIVE_SUPPORTED - simple_progressive = TRUE; - /* We must postpone execution until num_components is known. */ -#else - fprintf(stderr, "%s: sorry, progressive output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "quality", 1)) { - /* Quality factor (quantization table scaling factor). */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &quality) != 1) - usage(); - /* Change scale factor in case -qtables is present. */ - q_scale_factor = jpeg_quality_scaling(quality); - - } else if (keymatch(arg, "qslots", 2)) { - /* Quantization table slot numbers. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qslotsarg = argv[argn]; - /* Must delay setting qslots until after we have processed any - * colorspace-determining switches, since jpeg_set_colorspace sets - * default quant table numbers. - */ - - } else if (keymatch(arg, "qtables", 2)) { - /* Quantization tables fetched from file. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qtablefile = argv[argn]; - /* We postpone actually reading the file in case -quality comes later. */ - - } else if (keymatch(arg, "restart", 1)) { - /* Restart interval in MCU rows (or in MCUs with 'b'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (lval < 0 || lval > 65535L) - usage(); - if (ch == 'b' || ch == 'B') { - cinfo->restart_interval = (unsigned int) lval; - cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ - } else { - cinfo->restart_in_rows = (int) lval; - /* restart_interval will be computed during startup */ - } - - } else if (keymatch(arg, "sample", 2)) { - /* Set sampling factors. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - samplearg = argv[argn]; - /* Must delay setting sample factors until after we have processed any - * colorspace-determining switches, since jpeg_set_colorspace sets - * default sampling factors. - */ - - } else if (keymatch(arg, "scans", 2)) { - /* Set scan script. */ -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - scansarg = argv[argn]; - /* We must postpone reading the file in case -progressive appears. */ -#else - fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "smooth", 2)) { - /* Set input smoothing factor. */ - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - if (val < 0 || val > 100) - usage(); - cinfo->smoothing_factor = val; - - } else if (keymatch(arg, "targa", 1)) { - /* Input file is Targa format. */ - is_targa = TRUE; - - } else { - usage(); /* bogus switch */ - } - } - - /* Post-switch-scanning cleanup */ - - if (for_real) { - - /* Set quantization tables for selected quality. */ - /* Some or all may be overridden if -qtables is present. */ - jpeg_set_quality(cinfo, quality, force_baseline); - - if (qtablefile != NULL) /* process -qtables if it was present */ - if (! read_quant_tables(cinfo, qtablefile, - q_scale_factor, force_baseline)) - usage(); - - if (qslotsarg != NULL) /* process -qslots if it was present */ - if (! set_quant_slots(cinfo, qslotsarg)) - usage(); - - if (samplearg != NULL) /* process -sample if it was present */ - if (! set_sample_factors(cinfo, samplearg)) - usage(); - -#ifdef C_PROGRESSIVE_SUPPORTED - if (simple_progressive) /* process -progressive; -scans can override */ - jpeg_simple_progression(cinfo); -#endif - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (scansarg != NULL) /* process -scans if it was present */ - if (! read_scan_script(cinfo, scansarg)) - usage(); -#endif - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - int file_index; - cjpeg_source_ptr src_mgr; - FILE * input_file; - FILE * output_file; - JDIMENSION num_scanlines; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "cjpeg"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG compression object with default error handling. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - /* Add some application-specific error messages (from cderror.h) */ - jerr.addon_message_table = cdjpeg_message_table; - jerr.first_addon_message = JMSG_FIRSTADDONCODE; - jerr.last_addon_message = JMSG_LASTADDONCODE; - - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - - /* Initialize JPEG parameters. - * Much of this may be overridden later. - * In particular, we don't yet know the input file's color space, - * but we need to provide some value for jpeg_set_defaults() to work. - */ - - cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ - jpeg_set_defaults(&cinfo); - - /* Scan command line to find file names. - * It is convenient to use just one switch-parsing routine, but the switch - * values read here are ignored; we will rescan the switches after opening - * the input file. - */ - - file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &cinfo, &progress); -#endif - - /* Figure out the input file format, and set up to read it. */ - src_mgr = select_file_type(&cinfo, input_file); - src_mgr->input_file = input_file; - - /* Read the input file header to obtain file size & colorspace. */ - (*src_mgr->start_input) (&cinfo, src_mgr); - - /* Now that we know input colorspace, fix colorspace-dependent defaults */ - jpeg_default_colorspace(&cinfo); - - /* Adjust default compression parameters by re-parsing the options */ - file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); - - /* Specify data destination for compression */ - jpeg_stdio_dest(&cinfo, output_file); - - /* Start compressor */ - jpeg_start_compress(&cinfo, TRUE); - - /* Process data */ - while (cinfo.next_scanline < cinfo.image_height) { - num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr); - (void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines); - } - - /* Finish compression and release memory */ - (*src_mgr->finish_input) (&cinfo, src_mgr); - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &cinfo); -#endif - - /* All done. */ - exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/freeimage241/Source/LibJPEG/ckconfig.c b/freeimage241/Source/LibJPEG/ckconfig.c deleted file mode 100644 index 34baf79..0000000 --- a/freeimage241/Source/LibJPEG/ckconfig.c +++ /dev/null @@ -1,402 +0,0 @@ -/* - * ckconfig.c - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - */ - -/* - * This program is intended to help you determine how to configure the JPEG - * software for installation on a particular system. The idea is to try to - * compile and execute this program. If your compiler fails to compile the - * program, make changes as indicated in the comments below. Once you can - * compile the program, run it, and it will produce a "jconfig.h" file for - * your system. - * - * As a general rule, each time you try to compile this program, - * pay attention only to the *first* error message you get from the compiler. - * Many C compilers will issue lots of spurious error messages once they - * have gotten confused. Go to the line indicated in the first error message, - * and read the comments preceding that line to see what to change. - * - * Almost all of the edits you may need to make to this program consist of - * changing a line that reads "#define SOME_SYMBOL" to "#undef SOME_SYMBOL", - * or vice versa. This is called defining or undefining that symbol. - */ - - -/* First we must see if your system has the include files we need. - * We start out with the assumption that your system has all the ANSI-standard - * include files. If you get any error trying to include one of these files, - * undefine the corresponding HAVE_xxx symbol. - */ - -#define HAVE_STDDEF_H /* replace 'define' by 'undef' if error here */ -#ifdef HAVE_STDDEF_H /* next line will be skipped if you undef... */ -#include -#endif - -#define HAVE_STDLIB_H /* same thing for stdlib.h */ -#ifdef HAVE_STDLIB_H -#include -#endif - -#include /* If you ain't got this, you ain't got C. */ - -/* We have to see if your string functions are defined by - * strings.h (old BSD convention) or string.h (everybody else). - * We try the non-BSD convention first; define NEED_BSD_STRINGS - * if the compiler says it can't find string.h. - */ - -#undef NEED_BSD_STRINGS - -#ifdef NEED_BSD_STRINGS -#include -#else -#include -#endif - -/* On some systems (especially older Unix machines), type size_t is - * defined only in the include file . If you get a failure - * on the size_t test below, try defining NEED_SYS_TYPES_H. - */ - -#undef NEED_SYS_TYPES_H /* start by assuming we don't need it */ -#ifdef NEED_SYS_TYPES_H -#include -#endif - - -/* Usually type size_t is defined in one of the include files we've included - * above. If not, you'll get an error on the "typedef size_t my_size_t;" line. - * In that case, first try defining NEED_SYS_TYPES_H just above. - * If that doesn't work, you'll have to search through your system library - * to figure out which include file defines "size_t". Look for a line that - * says "typedef something-or-other size_t;". Then, change the line below - * that says "#include " to instead include the file - * you found size_t in, and define NEED_SPECIAL_INCLUDE. If you can't find - * type size_t anywhere, try replacing "#include " with - * "typedef unsigned int size_t;". - */ - -#undef NEED_SPECIAL_INCLUDE /* assume we DON'T need it, for starters */ - -#ifdef NEED_SPECIAL_INCLUDE -#include -#endif - -typedef size_t my_size_t; /* The payoff: do we have size_t now? */ - - -/* The next question is whether your compiler supports ANSI-style function - * prototypes. You need to know this in order to choose between using - * makefile.ansi and using makefile.unix. - * The #define line below is set to assume you have ANSI function prototypes. - * If you get an error in this group of lines, undefine HAVE_PROTOTYPES. - */ - -#define HAVE_PROTOTYPES - -#ifdef HAVE_PROTOTYPES -int testfunction (int arg1, int * arg2); /* check prototypes */ - -struct methods_struct { /* check method-pointer declarations */ - int (*error_exit) (char *msgtext); - int (*trace_message) (char *msgtext); - int (*another_method) (void); -}; - -int testfunction (int arg1, int * arg2) /* check definitions */ -{ - return arg2[arg1]; -} - -int test2function (void) /* check void arg list */ -{ - return 0; -} -#endif - - -/* Now we want to find out if your compiler knows what "unsigned char" means. - * If you get an error on the "unsigned char un_char;" line, - * then undefine HAVE_UNSIGNED_CHAR. - */ - -#define HAVE_UNSIGNED_CHAR - -#ifdef HAVE_UNSIGNED_CHAR -unsigned char un_char; -#endif - - -/* Now we want to find out if your compiler knows what "unsigned short" means. - * If you get an error on the "unsigned short un_short;" line, - * then undefine HAVE_UNSIGNED_SHORT. - */ - -#define HAVE_UNSIGNED_SHORT - -#ifdef HAVE_UNSIGNED_SHORT -unsigned short un_short; -#endif - - -/* Now we want to find out if your compiler understands type "void". - * If you get an error anywhere in here, undefine HAVE_VOID. - */ - -#define HAVE_VOID - -#ifdef HAVE_VOID -/* Caution: a C++ compiler will insist on complete prototypes */ -typedef void * void_ptr; /* check void * */ -#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ -typedef void (*void_func) (int a, int b); -#else -typedef void (*void_func) (); -#endif - -#ifdef HAVE_PROTOTYPES /* check void function result */ -void test3function (void_ptr arg1, void_func arg2) -#else -void test3function (arg1, arg2) - void_ptr arg1; - void_func arg2; -#endif -{ - char * locptr = (char *) arg1; /* check casting to and from void * */ - arg1 = (void *) locptr; - (*arg2) (1, 2); /* check call of fcn returning void */ -} -#endif - - -/* Now we want to find out if your compiler knows what "const" means. - * If you get an error here, undefine HAVE_CONST. - */ - -#define HAVE_CONST - -#ifdef HAVE_CONST -static const int carray[3] = {1, 2, 3}; - -#ifdef HAVE_PROTOTYPES -int test4function (const int arg1) -#else -int test4function (arg1) - const int arg1; -#endif -{ - return carray[arg1]; -} -#endif - - -/* If you get an error or warning about this structure definition, - * define INCOMPLETE_TYPES_BROKEN. - */ - -#undef INCOMPLETE_TYPES_BROKEN - -#ifndef INCOMPLETE_TYPES_BROKEN -typedef struct undefined_structure * undef_struct_ptr; -#endif - - -/* If you get an error about duplicate names, - * define NEED_SHORT_EXTERNAL_NAMES. - */ - -#undef NEED_SHORT_EXTERNAL_NAMES - -#ifndef NEED_SHORT_EXTERNAL_NAMES - -int possibly_duplicate_function () -{ - return 0; -} - -int possibly_dupli_function () -{ - return 1; -} - -#endif - - - -/************************************************************************ - * OK, that's it. You should not have to change anything beyond this - * point in order to compile and execute this program. (You might get - * some warnings, but you can ignore them.) - * When you run the program, it will make a couple more tests that it - * can do automatically, and then it will create jconfig.h and print out - * any additional suggestions it has. - ************************************************************************ - */ - - -#ifdef HAVE_PROTOTYPES -int is_char_signed (int arg) -#else -int is_char_signed (arg) - int arg; -#endif -{ - if (arg == 189) { /* expected result for unsigned char */ - return 0; /* type char is unsigned */ - } - else if (arg != -67) { /* expected result for signed char */ - printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - } - return 1; /* assume char is signed otherwise */ -} - - -#ifdef HAVE_PROTOTYPES -int is_shifting_signed (long arg) -#else -int is_shifting_signed (arg) - long arg; -#endif -/* See whether right-shift on a long is signed or not. */ -{ - long res = arg >> 4; - - if (res == -0x7F7E80CL) { /* expected result for signed shift */ - return 1; /* right shift is signed */ - } - /* see if unsigned-shift hack will fix it. */ - /* we can't just test exact value since it depends on width of long... */ - res |= (~0L) << (32-4); - if (res == -0x7F7E80CL) { /* expected result now? */ - return 0; /* right shift is unsigned */ - } - printf("Right shift isn't acting as I expect it to.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - return 0; /* try it with unsigned anyway */ -} - - -#ifdef HAVE_PROTOTYPES -int main (int argc, char ** argv) -#else -int main (argc, argv) - int argc; - char ** argv; -#endif -{ - char signed_char_check = (char) (-67); - FILE *outfile; - - /* Attempt to write jconfig.h */ - if ((outfile = fopen("jconfig.h", "w")) == NULL) { - printf("Failed to write jconfig.h\n"); - return 1; - } - - /* Write out all the info */ - fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n"); - fprintf(outfile, "/* see jconfig.doc for explanations */\n\n"); -#ifdef HAVE_PROTOTYPES - fprintf(outfile, "#define HAVE_PROTOTYPES\n"); -#else - fprintf(outfile, "#undef HAVE_PROTOTYPES\n"); -#endif -#ifdef HAVE_UNSIGNED_CHAR - fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n"); -#else - fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n"); -#endif -#ifdef HAVE_UNSIGNED_SHORT - fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n"); -#else - fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n"); -#endif -#ifdef HAVE_VOID - fprintf(outfile, "/* #define void char */\n"); -#else - fprintf(outfile, "#define void char\n"); -#endif -#ifdef HAVE_CONST - fprintf(outfile, "/* #define const */\n"); -#else - fprintf(outfile, "#define const\n"); -#endif - if (is_char_signed((int) signed_char_check)) - fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n"); - else - fprintf(outfile, "#define CHAR_IS_UNSIGNED\n"); -#ifdef HAVE_STDDEF_H - fprintf(outfile, "#define HAVE_STDDEF_H\n"); -#else - fprintf(outfile, "#undef HAVE_STDDEF_H\n"); -#endif -#ifdef HAVE_STDLIB_H - fprintf(outfile, "#define HAVE_STDLIB_H\n"); -#else - fprintf(outfile, "#undef HAVE_STDLIB_H\n"); -#endif -#ifdef NEED_BSD_STRINGS - fprintf(outfile, "#define NEED_BSD_STRINGS\n"); -#else - fprintf(outfile, "#undef NEED_BSD_STRINGS\n"); -#endif -#ifdef NEED_SYS_TYPES_H - fprintf(outfile, "#define NEED_SYS_TYPES_H\n"); -#else - fprintf(outfile, "#undef NEED_SYS_TYPES_H\n"); -#endif - fprintf(outfile, "#undef NEED_FAR_POINTERS\n"); -#ifdef NEED_SHORT_EXTERNAL_NAMES - fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n"); -#else - fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n"); -#endif -#ifdef INCOMPLETE_TYPES_BROKEN - fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n"); -#else - fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n"); -#endif - fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n"); - if (is_shifting_signed(-0x7F7E80B1L)) - fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n"); - else - fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n"); - fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n"); - fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n"); - fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n"); - fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n"); - fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n"); - fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n"); - fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n"); - fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n"); - fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n"); - fprintf(outfile, "#undef DONT_USE_B_MODE\n"); - fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n"); - fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n"); - - /* Close the jconfig.h file */ - fclose(outfile); - - /* User report */ - printf("Configuration check for Independent JPEG Group's software done.\n"); - printf("\nI have written the jconfig.h file for you.\n\n"); -#ifdef HAVE_PROTOTYPES - printf("You should use makefile.ansi as the starting point for your Makefile.\n"); -#else - printf("You should use makefile.unix as the starting point for your Makefile.\n"); -#endif - -#ifdef NEED_SPECIAL_INCLUDE - printf("\nYou'll need to change jconfig.h to include the system include file\n"); - printf("that you found type size_t in, or add a direct definition of type\n"); - printf("size_t if that's what you used. Just add it to the end.\n"); -#endif - - return 0; -} diff --git a/freeimage241/Source/LibJPEG/djpeg.c b/freeimage241/Source/LibJPEG/djpeg.c deleted file mode 100644 index e099e90..0000000 --- a/freeimage241/Source/LibJPEG/djpeg.c +++ /dev/null @@ -1,616 +0,0 @@ -/* - * djpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for the JPEG decompressor. - * It should work on any system with Unix- or MS-DOS-style command lines. - * - * Two different command line styles are permitted, depending on the - * compile-time switch TWO_FILE_COMMANDLINE: - * djpeg [options] inputfile outputfile - * djpeg [options] [inputfile] - * In the second style, output is always to standard output, which you'd - * normally redirect to a file or pipe to some other program. Input is - * either from a named file or from standard input (typically redirected). - * The second style is convenient on Unix but is unhelpful on systems that - * don't support pipes. Also, you MUST use the first style if your system - * doesn't do binary I/O to stdin/stdout. - * To simplify script writing, the "-outfile" switch is provided. The syntax - * djpeg [options] -outfile outputfile inputfile - * works regardless of which command line style is used. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "jversion.h" /* for version message */ - -#include /* to declare isprint() */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - - -/* Create the add-on message string table. */ - -#define JMESSAGE(code,string) string , - -static const char * const cdjpeg_message_table[] = { -#include "cderror.h" - NULL -}; - - -/* - * This list defines the known output image formats - * (not all of which need be supported by a given version). - * You can change the default output format by defining DEFAULT_FMT; - * indeed, you had better do so if you undefine PPM_SUPPORTED. - */ - -typedef enum { - FMT_BMP, /* BMP format (Windows flavor) */ - FMT_GIF, /* GIF format */ - FMT_OS2, /* BMP format (OS/2 flavor) */ - FMT_PPM, /* PPM/PGM (PBMPLUS formats) */ - FMT_RLE, /* RLE format */ - FMT_TARGA, /* Targa format */ - FMT_TIFF /* TIFF format */ -} IMAGE_FORMATS; - -#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */ -#define DEFAULT_FMT FMT_PPM -#endif - -static IMAGE_FORMATS requested_fmt; - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -colors N Reduce image to no more than N colors\n"); - fprintf(stderr, " -fast Fast, low-quality processing\n"); - fprintf(stderr, " -grayscale Force grayscale output\n"); -#ifdef IDCT_SCALING_SUPPORTED - fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); -#endif -#ifdef BMP_SUPPORTED - fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n", - (DEFAULT_FMT == FMT_BMP ? " (default)" : "")); -#endif -#ifdef GIF_SUPPORTED - fprintf(stderr, " -gif Select GIF output format%s\n", - (DEFAULT_FMT == FMT_GIF ? " (default)" : "")); -#endif -#ifdef BMP_SUPPORTED - fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n", - (DEFAULT_FMT == FMT_OS2 ? " (default)" : "")); -#endif -#ifdef PPM_SUPPORTED - fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n", - (DEFAULT_FMT == FMT_PPM ? " (default)" : "")); -#endif -#ifdef RLE_SUPPORTED - fprintf(stderr, " -rle Select Utah RLE output format%s\n", - (DEFAULT_FMT == FMT_RLE ? " (default)" : "")); -#endif -#ifdef TARGA_SUPPORTED - fprintf(stderr, " -targa Select Targa output format%s\n", - (DEFAULT_FMT == FMT_TARGA ? " (default)" : "")); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef DCT_ISLOW_SUPPORTED - fprintf(stderr, " -dct int Use integer DCT method%s\n", - (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); -#endif -#ifdef DCT_IFAST_SUPPORTED - fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", - (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); -#endif -#ifdef DCT_FLOAT_SUPPORTED - fprintf(stderr, " -dct float Use floating-point DCT method%s\n", - (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); -#endif - fprintf(stderr, " -dither fs Use F-S dithering (default)\n"); - fprintf(stderr, " -dither none Don't use dithering in quantization\n"); - fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n"); -#ifdef QUANT_2PASS_SUPPORTED - fprintf(stderr, " -map FILE Map to colors used in named image file\n"); -#endif - fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n"); -#ifdef QUANT_1PASS_SUPPORTED - fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n"); -#endif - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - exit(EXIT_FAILURE); -} - - -LOCAL(int) -parse_switches (j_decompress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - - /* Set up default JPEG parameters. */ - requested_fmt = DEFAULT_FMT; /* set default output file format */ - outfilename = NULL; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "bmp", 1)) { - /* BMP output format. */ - requested_fmt = FMT_BMP; - - } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) || - keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) { - /* Do color quantization. */ - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - cinfo->desired_number_of_colors = val; - cinfo->quantize_colors = TRUE; - - } else if (keymatch(arg, "dct", 2)) { - /* Select IDCT algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "int", 1)) { - cinfo->dct_method = JDCT_ISLOW; - } else if (keymatch(argv[argn], "fast", 2)) { - cinfo->dct_method = JDCT_IFAST; - } else if (keymatch(argv[argn], "float", 2)) { - cinfo->dct_method = JDCT_FLOAT; - } else - usage(); - - } else if (keymatch(arg, "dither", 2)) { - /* Select dithering algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "fs", 2)) { - cinfo->dither_mode = JDITHER_FS; - } else if (keymatch(argv[argn], "none", 2)) { - cinfo->dither_mode = JDITHER_NONE; - } else if (keymatch(argv[argn], "ordered", 2)) { - cinfo->dither_mode = JDITHER_ORDERED; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "fast", 1)) { - /* Select recommended processing options for quick-and-dirty output. */ - cinfo->two_pass_quantize = FALSE; - cinfo->dither_mode = JDITHER_ORDERED; - if (! cinfo->quantize_colors) /* don't override an earlier -colors */ - cinfo->desired_number_of_colors = 216; - cinfo->dct_method = JDCT_FASTEST; - cinfo->do_fancy_upsampling = FALSE; - - } else if (keymatch(arg, "gif", 1)) { - /* GIF output format. */ - requested_fmt = FMT_GIF; - - } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { - /* Force monochrome output. */ - cinfo->out_color_space = JCS_GRAYSCALE; - - } else if (keymatch(arg, "map", 3)) { - /* Quantize to a color map taken from an input file. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (for_real) { /* too expensive to do twice! */ -#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ - FILE * mapfile; - - if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - read_color_map(cinfo, mapfile); - fclose(mapfile); - cinfo->quantize_colors = TRUE; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "nosmooth", 3)) { - /* Suppress fancy upsampling */ - cinfo->do_fancy_upsampling = FALSE; - - } else if (keymatch(arg, "onepass", 3)) { - /* Use fast one-pass quantization. */ - cinfo->two_pass_quantize = FALSE; - - } else if (keymatch(arg, "os2", 3)) { - /* BMP output format (OS/2 flavor). */ - requested_fmt = FMT_OS2; - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) { - /* PPM/PGM output format. */ - requested_fmt = FMT_PPM; - - } else if (keymatch(arg, "rle", 1)) { - /* RLE output format. */ - requested_fmt = FMT_RLE; - - } else if (keymatch(arg, "scale", 1)) { - /* Scale the output image by a fraction M/N. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d/%d", - &cinfo->scale_num, &cinfo->scale_denom) != 2) - usage(); - - } else if (keymatch(arg, "targa", 1)) { - /* Targa output format. */ - requested_fmt = FMT_TARGA; - - } else { - usage(); /* bogus switch */ - } - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * Marker processor for COM and interesting APPn markers. - * This replaces the library's built-in processor, which just skips the marker. - * We want to print out the marker as text, to the extent possible. - * Note this code relies on a non-suspending data source. - */ - -LOCAL(unsigned int) -jpeg_getc (j_decompress_ptr cinfo) -/* Read next byte */ -{ - struct jpeg_source_mgr * datasrc = cinfo->src; - - if (datasrc->bytes_in_buffer == 0) { - if (! (*datasrc->fill_input_buffer) (cinfo)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - datasrc->bytes_in_buffer--; - return GETJOCTET(*datasrc->next_input_byte++); -} - - -METHODDEF(boolean) -print_text_marker (j_decompress_ptr cinfo) -{ - boolean traceit = (cinfo->err->trace_level >= 1); - INT32 length; - unsigned int ch; - unsigned int lastch = 0; - - length = jpeg_getc(cinfo) << 8; - length += jpeg_getc(cinfo); - length -= 2; /* discount the length word itself */ - - if (traceit) { - if (cinfo->unread_marker == JPEG_COM) - fprintf(stderr, "Comment, length %ld:\n", (long) length); - else /* assume it is an APPn otherwise */ - fprintf(stderr, "APP%d, length %ld:\n", - cinfo->unread_marker - JPEG_APP0, (long) length); - } - - while (--length >= 0) { - ch = jpeg_getc(cinfo); - if (traceit) { - /* Emit the character in a readable form. - * Nonprintables are converted to \nnn form, - * while \ is converted to \\. - * Newlines in CR, CR/LF, or LF form will be printed as one newline. - */ - if (ch == '\r') { - fprintf(stderr, "\n"); - } else if (ch == '\n') { - if (lastch != '\r') - fprintf(stderr, "\n"); - } else if (ch == '\\') { - fprintf(stderr, "\\\\"); - } else if (isprint(ch)) { - putc(ch, stderr); - } else { - fprintf(stderr, "\\%03o", ch); - } - lastch = ch; - } - } - - if (traceit) - fprintf(stderr, "\n"); - - return TRUE; -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - int file_index; - djpeg_dest_ptr dest_mgr = NULL; - FILE * input_file; - FILE * output_file; - JDIMENSION num_scanlines; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "djpeg"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG decompression object with default error handling. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - /* Add some application-specific error messages (from cderror.h) */ - jerr.addon_message_table = cdjpeg_message_table; - jerr.first_addon_message = JMSG_FIRSTADDONCODE; - jerr.last_addon_message = JMSG_LASTADDONCODE; - - /* Insert custom marker processor for COM and APP12. - * APP12 is used by some digital camera makers for textual info, - * so we provide the ability to display it as text. - * If you like, additional APPn marker types can be selected for display, - * but don't try to override APP0 or APP14 this way (see libjpeg.doc). - */ - jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker); - jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker); - - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - - /* Scan command line to find file names. */ - /* It is convenient to use just one switch-parsing routine, but the switch - * values read here are ignored; we will rescan the switches after opening - * the input file. - * (Exception: tracing level set here controls verbosity for COM markers - * found during jpeg_read_header...) - */ - - file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &cinfo, &progress); -#endif - - /* Specify data source for decompression */ - jpeg_stdio_src(&cinfo, input_file); - - /* Read file header, set default decompression parameters */ - (void) jpeg_read_header(&cinfo, TRUE); - - /* Adjust default decompression parameters by re-parsing the options */ - file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); - - /* Initialize the output module now to let it override any crucial - * option settings (for instance, GIF wants to force color quantization). - */ - switch (requested_fmt) { -#ifdef BMP_SUPPORTED - case FMT_BMP: - dest_mgr = jinit_write_bmp(&cinfo, FALSE); - break; - case FMT_OS2: - dest_mgr = jinit_write_bmp(&cinfo, TRUE); - break; -#endif -#ifdef GIF_SUPPORTED - case FMT_GIF: - dest_mgr = jinit_write_gif(&cinfo); - break; -#endif -#ifdef PPM_SUPPORTED - case FMT_PPM: - dest_mgr = jinit_write_ppm(&cinfo); - break; -#endif -#ifdef RLE_SUPPORTED - case FMT_RLE: - dest_mgr = jinit_write_rle(&cinfo); - break; -#endif -#ifdef TARGA_SUPPORTED - case FMT_TARGA: - dest_mgr = jinit_write_targa(&cinfo); - break; -#endif - default: - ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT); - break; - } - dest_mgr->output_file = output_file; - - /* Start decompressor */ - (void) jpeg_start_decompress(&cinfo); - - /* Write output file header */ - (*dest_mgr->start_output) (&cinfo, dest_mgr); - - /* Process data */ - while (cinfo.output_scanline < cinfo.output_height) { - num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, - dest_mgr->buffer_height); - (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); - } - -#ifdef PROGRESS_REPORT - /* Hack: count final pass as done in case finish_output does an extra pass. - * The library won't have updated completed_passes. - */ - progress.pub.completed_passes = progress.pub.total_passes; -#endif - - /* Finish decompression and release memory. - * I must do it in this order because output module has allocated memory - * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. - */ - (*dest_mgr->finish_output) (&cinfo, dest_mgr); - (void) jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &cinfo); -#endif - - /* All done. */ - exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/freeimage241/Source/LibJPEG/example.c b/freeimage241/Source/LibJPEG/example.c deleted file mode 100644 index 7fc354f..0000000 --- a/freeimage241/Source/LibJPEG/example.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * example.c - * - * This file illustrates how to use the IJG code as a subroutine library - * to read or write JPEG image files. You should look at this code in - * conjunction with the documentation file libjpeg.doc. - * - * This code will not do anything useful as-is, but it may be helpful as a - * skeleton for constructing routines that call the JPEG library. - * - * We present these routines in the same coding style used in the JPEG code - * (ANSI function definitions, etc); but you are of course free to code your - * routines in a different style if you prefer. - */ - -#include - -/* - * Include file for users of JPEG library. - * You will need to have included system headers that define at least - * the typedefs FILE and size_t before you can include jpeglib.h. - * (stdio.h is sufficient on ANSI-conforming systems.) - * You may also wish to include "jerror.h". - */ - -#include "jpeglib.h" - -/* - * is used for the optional error recovery mechanism shown in - * the second part of the example. - */ - -#include - - - -/******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ - -/* This half of the example shows how to feed data into the JPEG compressor. - * We present a minimal version that does not worry about refinements such - * as error recovery (the JPEG code will just exit() if it gets an error). - */ - - -/* - * IMAGE DATA FORMATS: - * - * The standard input image format is a rectangular array of pixels, with - * each pixel having the same number of "component" values (color channels). - * Each pixel row is an array of JSAMPLEs (which typically are unsigned chars). - * If you are working with color data, then the color values for each pixel - * must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit - * RGB color. - * - * For this example, we'll assume that this data structure matches the way - * our application has stored the image in memory, so we can just pass a - * pointer to our image buffer. In particular, let's say that the image is - * RGB color and is described by: - */ - -extern JSAMPLE * image_buffer; /* Points to large array of R,G,B-order data */ -extern int image_height; /* Number of rows in image */ -extern int image_width; /* Number of columns in image */ - - -/* - * Sample routine for JPEG compression. We assume that the target file name - * and a compression quality factor are passed in. - */ - -GLOBAL(void) -write_JPEG_file (char * filename, int quality) -{ - /* This struct contains the JPEG compression parameters and pointers to - * working space (which is allocated as needed by the JPEG library). - * It is possible to have several such structures, representing multiple - * compression/decompression processes, in existence at once. We refer - * to any one struct (and its associated working data) as a "JPEG object". - */ - struct jpeg_compress_struct cinfo; - /* This struct represents a JPEG error handler. It is declared separately - * because applications often want to supply a specialized error handler - * (see the second half of this file for an example). But here we just - * take the easy way out and use the standard error handler, which will - * print a message on stderr and call exit() if compression fails. - * Note that this struct must live as long as the main JPEG parameter - * struct, to avoid dangling-pointer problems. - */ - struct jpeg_error_mgr jerr; - /* More stuff */ - FILE * outfile; /* target file */ - JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ - int row_stride; /* physical row width in image buffer */ - - /* Step 1: allocate and initialize JPEG compression object */ - - /* We have to set up the error handler first, in case the initialization - * step fails. (Unlikely, but it could happen if you are out of memory.) - * This routine fills in the contents of struct jerr, and returns jerr's - * address which we place into the link field in cinfo. - */ - cinfo.err = jpeg_std_error(&jerr); - /* Now we can initialize the JPEG compression object. */ - jpeg_create_compress(&cinfo); - - /* Step 2: specify data destination (eg, a file) */ - /* Note: steps 2 and 3 can be done in either order. */ - - /* Here we use the library-supplied code to send compressed data to a - * stdio stream. You can also write your own code to do something else. - * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that - * requires it in order to write binary files. - */ - if ((outfile = fopen(filename, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_dest(&cinfo, outfile); - - /* Step 3: set parameters for compression */ - - /* First we supply a description of the input image. - * Four fields of the cinfo struct must be filled in: - */ - cinfo.image_width = image_width; /* image width and height, in pixels */ - cinfo.image_height = image_height; - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ - /* Now use the library's routine to set default compression parameters. - * (You must set at least cinfo.in_color_space before calling this, - * since the defaults depend on the source color space.) - */ - jpeg_set_defaults(&cinfo); - /* Now you can set any non-default parameters you wish to. - * Here we just illustrate the use of quality (quantization table) scaling: - */ - jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); - - /* Step 4: Start compressor */ - - /* TRUE ensures that we will write a complete interchange-JPEG file. - * Pass TRUE unless you are very sure of what you're doing. - */ - jpeg_start_compress(&cinfo, TRUE); - - /* Step 5: while (scan lines remain to be written) */ - /* jpeg_write_scanlines(...); */ - - /* Here we use the library's state variable cinfo.next_scanline as the - * loop counter, so that we don't have to keep track ourselves. - * To keep things simple, we pass one scanline per call; you can pass - * more if you wish, though. - */ - row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ - - while (cinfo.next_scanline < cinfo.image_height) { - /* jpeg_write_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could pass - * more than one scanline at a time if that's more convenient. - */ - row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; - (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - - /* Step 6: Finish compression */ - - jpeg_finish_compress(&cinfo); - /* After finish_compress, we can close the output file. */ - fclose(outfile); - - /* Step 7: release JPEG compression object */ - - /* This is an important step since it will release a good deal of memory. */ - jpeg_destroy_compress(&cinfo); - - /* And we're done! */ -} - - -/* - * SOME FINE POINTS: - * - * In the above loop, we ignored the return value of jpeg_write_scanlines, - * which is the number of scanlines actually written. We could get away - * with this because we were only relying on the value of cinfo.next_scanline, - * which will be incremented correctly. If you maintain additional loop - * variables then you should be careful to increment them properly. - * Actually, for output to a stdio stream you needn't worry, because - * then jpeg_write_scanlines will write all the lines passed (or else exit - * with a fatal error). Partial writes can only occur if you use a data - * destination module that can demand suspension of the compressor. - * (If you don't know what that's for, you don't need it.) - * - * If the compressor requires full-image buffers (for entropy-coding - * optimization or a multi-scan JPEG file), it will create temporary - * files for anything that doesn't fit within the maximum-memory setting. - * (Note that temp files are NOT needed if you use the default parameters.) - * On some systems you may need to set up a signal handler to ensure that - * temporary files are deleted if the program is interrupted. See libjpeg.doc. - * - * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG - * files to be compatible with everyone else's. If you cannot readily read - * your data in that order, you'll need an intermediate array to hold the - * image. See rdtarga.c or rdbmp.c for examples of handling bottom-to-top - * source data using the JPEG code's internal virtual-array mechanisms. - */ - - - -/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/ - -/* This half of the example shows how to read data from the JPEG decompressor. - * It's a bit more refined than the above, in that we show: - * (a) how to modify the JPEG library's standard error-reporting behavior; - * (b) how to allocate workspace using the library's memory manager. - * - * Just to make this example a little different from the first one, we'll - * assume that we do not intend to put the whole image into an in-memory - * buffer, but to send it line-by-line someplace else. We need a one- - * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG - * memory manager allocate it for us. This approach is actually quite useful - * because we don't need to remember to deallocate the buffer separately: it - * will go away automatically when the JPEG object is cleaned up. - */ - - -/* - * ERROR HANDLING: - * - * The JPEG library's standard error handler (jerror.c) is divided into - * several "methods" which you can override individually. This lets you - * adjust the behavior without duplicating a lot of code, which you might - * have to update with each future release. - * - * Our example here shows how to override the "error_exit" method so that - * control is returned to the library's caller when a fatal error occurs, - * rather than calling exit() as the standard error_exit method does. - * - * We use C's setjmp/longjmp facility to return control. This means that the - * routine which calls the JPEG library must first execute a setjmp() call to - * establish the return point. We want the replacement error_exit to do a - * longjmp(). But we need to make the setjmp buffer accessible to the - * error_exit routine. To do this, we make a private extension of the - * standard JPEG error handler object. (If we were using C++, we'd say we - * were making a subclass of the regular error handler.) - * - * Here's the extended error handler struct: - */ - -struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ - - jmp_buf setjmp_buffer; /* for return to caller */ -}; - -typedef struct my_error_mgr * my_error_ptr; - -/* - * Here's the routine that will replace the standard error_exit method: - */ - -METHODDEF(void) -my_error_exit (j_common_ptr cinfo) -{ - /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ - my_error_ptr myerr = (my_error_ptr) cinfo->err; - - /* Always display the message. */ - /* We could postpone this until after returning, if we chose. */ - (*cinfo->err->output_message) (cinfo); - - /* Return control to the setjmp point */ - longjmp(myerr->setjmp_buffer, 1); -} - - -/* - * Sample routine for JPEG decompression. We assume that the source file name - * is passed in. We want to return 1 on success, 0 on error. - */ - - -GLOBAL(int) -read_JPEG_file (char * filename) -{ - /* This struct contains the JPEG decompression parameters and pointers to - * working space (which is allocated as needed by the JPEG library). - */ - struct jpeg_decompress_struct cinfo; - /* We use our private extension JPEG error handler. - * Note that this struct must live as long as the main JPEG parameter - * struct, to avoid dangling-pointer problems. - */ - struct my_error_mgr jerr; - /* More stuff */ - FILE * infile; /* source file */ - JSAMPARRAY buffer; /* Output row buffer */ - int row_stride; /* physical row width in output buffer */ - - /* In this example we want to open the input file before doing anything else, - * so that the setjmp() error recovery below can assume the file is open. - * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that - * requires it in order to read binary files. - */ - - if ((infile = fopen(filename, "rb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - return 0; - } - - /* Step 1: allocate and initialize JPEG decompression object */ - - /* We set up the normal JPEG error routines, then override error_exit. */ - cinfo.err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = my_error_exit; - /* Establish the setjmp return context for my_error_exit to use. */ - if (setjmp(jerr.setjmp_buffer)) { - /* If we get here, the JPEG code has signaled an error. - * We need to clean up the JPEG object, close the input file, and return. - */ - jpeg_destroy_decompress(&cinfo); - fclose(infile); - return 0; - } - /* Now we can initialize the JPEG decompression object. */ - jpeg_create_decompress(&cinfo); - - /* Step 2: specify data source (eg, a file) */ - - jpeg_stdio_src(&cinfo, infile); - - /* Step 3: read file parameters with jpeg_read_header() */ - - (void) jpeg_read_header(&cinfo, TRUE); - /* We can ignore the return value from jpeg_read_header since - * (a) suspension is not possible with the stdio data source, and - * (b) we passed TRUE to reject a tables-only JPEG file as an error. - * See libjpeg.doc for more info. - */ - - /* Step 4: set parameters for decompression */ - - /* In this example, we don't need to change any of the defaults set by - * jpeg_read_header(), so we do nothing here. - */ - - /* Step 5: Start decompressor */ - - (void) jpeg_start_decompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - */ - - /* We may need to do some setup of our own at this point before reading - * the data. After jpeg_start_decompress() we have the correct scaled - * output image dimensions available, as well as the output colormap - * if we asked for color quantization. - * In this example, we need to make an output work buffer of the right size. - */ - /* JSAMPLEs per row in output buffer */ - row_stride = cinfo.output_width * cinfo.output_components; - /* Make a one-row-high sample array that will go away when done with image */ - buffer = (*cinfo.mem->alloc_sarray) - ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); - - /* Step 6: while (scan lines remain to be read) */ - /* jpeg_read_scanlines(...); */ - - /* Here we use the library's state variable cinfo.output_scanline as the - * loop counter, so that we don't have to keep track ourselves. - */ - while (cinfo.output_scanline < cinfo.output_height) { - /* jpeg_read_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could ask for - * more than one scanline at a time if that's more convenient. - */ - (void) jpeg_read_scanlines(&cinfo, buffer, 1); - /* Assume put_scanline_someplace wants a pointer and sample count. */ - put_scanline_someplace(buffer[0], row_stride); - } - - /* Step 7: Finish decompression */ - - (void) jpeg_finish_decompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - */ - - /* Step 8: Release JPEG decompression object */ - - /* This is an important step since it will release a good deal of memory. */ - jpeg_destroy_decompress(&cinfo); - - /* After finish_decompress, we can close the input file. - * Here we postpone it until after no more JPEG errors are possible, - * so as to simplify the setjmp error logic above. (Actually, I don't - * think that jpeg_destroy can do an error exit, but why assume anything...) - */ - fclose(infile); - - /* At this point you may want to check to see whether any corrupt-data - * warnings occurred (test whether jerr.pub.num_warnings is nonzero). - */ - - /* And we're done! */ - return 1; -} - - -/* - * SOME FINE POINTS: - * - * In the above code, we ignored the return value of jpeg_read_scanlines, - * which is the number of scanlines actually read. We could get away with - * this because we asked for only one line at a time and we weren't using - * a suspending data source. See libjpeg.doc for more info. - * - * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress(); - * we should have done it beforehand to ensure that the space would be - * counted against the JPEG max_memory setting. In some systems the above - * code would risk an out-of-memory error. However, in general we don't - * know the output image dimensions before jpeg_start_decompress(), unless we - * call jpeg_calc_output_dimensions(). See libjpeg.doc for more about this. - * - * Scanlines are returned in the same order as they appear in the JPEG file, - * which is standardly top-to-bottom. If you must emit data bottom-to-top, - * you can use one of the virtual arrays provided by the JPEG memory manager - * to invert the data. See wrbmp.c for an example. - * - * As with compression, some operating modes may require temporary files. - * On some systems you may need to set up a signal handler to ensure that - * temporary files are deleted if the program is interrupted. See libjpeg.doc. - */ diff --git a/freeimage241/Source/LibJPEG/jcapimin.c b/freeimage241/Source/LibJPEG/jcapimin.c deleted file mode 100644 index 54fb8c5..0000000 --- a/freeimage241/Source/LibJPEG/jcapimin.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * jcapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-compression case or the transcoding-only - * case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jcapistd.c. But also see jcparam.c for - * parameter-setup helper routines, jcomapi.c for routines shared by - * compression and decompression, and jctrans.c for the transcoding case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Initialization of a JPEG compression object. - * The error manager must already be set up (in case memory manager fails). - */ - -GLOBAL(void) -jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) -{ - int i; - - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_compress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = FALSE; - - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); - - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->dest = NULL; - - cinfo->comp_info = NULL; - - for (i = 0; i < NUM_QUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } - - cinfo->script_space = NULL; - - cinfo->input_gamma = 1.0; /* in case application forgets */ - - /* OK, I'm ready */ - cinfo->global_state = CSTATE_START; -} - - -/* - * Destruction of a JPEG compression object - */ - -GLOBAL(void) -jpeg_destroy_compress (j_compress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Abort processing of a JPEG compression operation, - * but don't destroy the object itself. - */ - -GLOBAL(void) -jpeg_abort_compress (j_compress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Forcibly suppress or un-suppress all quantization and Huffman tables. - * Marks all currently defined tables as already written (if suppress) - * or not written (if !suppress). This will control whether they get emitted - * by a subsequent jpeg_start_compress call. - * - * This routine is exported for use by applications that want to produce - * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but - * since it is called by jpeg_start_compress, we put it here --- otherwise - * jcparam.o would be linked whether the application used it or not. - */ - -GLOBAL(void) -jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) -{ - int i; - JQUANT_TBL * qtbl; - JHUFF_TBL * htbl; - - for (i = 0; i < NUM_QUANT_TBLS; i++) { - if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) - qtbl->sent_table = suppress; - } - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - } -} - - -/* - * Finish JPEG compression. - * - * If a multipass operating mode was selected, this may do a great deal of - * work including most of the actual output. - */ - -GLOBAL(void) -jpeg_finish_compress (j_compress_ptr cinfo) -{ - JDIMENSION iMCU_row; - - if (cinfo->global_state == CSTATE_SCANNING || - cinfo->global_state == CSTATE_RAW_OK) { - /* Terminate first pass */ - if (cinfo->next_scanline < cinfo->image_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_pass) (cinfo); - } else if (cinfo->global_state != CSTATE_WRCOEFS) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any remaining passes */ - while (! cinfo->master->is_last_pass) { - (*cinfo->master->prepare_for_pass) (cinfo); - for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) iMCU_row; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* We bypass the main controller and invoke coef controller directly; - * all work is being done from the coefficient buffer. - */ - if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - (*cinfo->master->finish_pass) (cinfo); - } - /* Write EOI, do final cleanup */ - (*cinfo->marker->write_file_trailer) (cinfo); - (*cinfo->dest->term_destination) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); -} - - -/* - * Write a special marker. - * This is only recommended for writing COM or APPn markers. - * Must be called after jpeg_start_compress() and before - * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). - */ - -GLOBAL(void) -jpeg_write_marker (j_compress_ptr cinfo, int marker, - const JOCTET *dataptr, unsigned int datalen) -{ - JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val)); - - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); - write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ - while (datalen--) { - (*write_marker_byte) (cinfo, *dataptr); - dataptr++; - } -} - -/* Same, but piecemeal. */ - -GLOBAL(void) -jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -{ - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); -} - -GLOBAL(void) -jpeg_write_m_byte (j_compress_ptr cinfo, int val) -{ - (*cinfo->marker->write_marker_byte) (cinfo, val); -} - - -/* - * Alternate compression function: just write an abbreviated table file. - * Before calling this, all parameters and a data destination must be set up. - * - * To produce a pair of files containing abbreviated tables and abbreviated - * image data, one would proceed as follows: - * - * initialize JPEG object - * set JPEG parameters - * set destination to table file - * jpeg_write_tables(cinfo); - * set destination to image file - * jpeg_start_compress(cinfo, FALSE); - * write data... - * jpeg_finish_compress(cinfo); - * - * jpeg_write_tables has the side effect of marking all tables written - * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress - * will not re-emit the tables unless it is passed write_all_tables=TRUE. - */ - -GLOBAL(void) -jpeg_write_tables (j_compress_ptr cinfo) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Initialize the marker writer ... bit of a crock to do it here. */ - jinit_marker_writer(cinfo); - /* Write them tables! */ - (*cinfo->marker->write_tables_only) (cinfo); - /* And clean up. */ - (*cinfo->dest->term_destination) (cinfo); - /* - * In library releases up through v6a, we called jpeg_abort() here to free - * any working memory allocated by the destination manager and marker - * writer. Some applications had a problem with that: they allocated space - * of their own from the library memory manager, and didn't want it to go - * away during write_tables. So now we do nothing. This will cause a - * memory leak if an app calls write_tables repeatedly without doing a full - * compression cycle or otherwise resetting the JPEG object. However, that - * seems less bad than unexpectedly freeing memory in the normal case. - * An app that prefers the old behavior can call jpeg_abort for itself after - * each call to jpeg_write_tables(). - */ -} diff --git a/freeimage241/Source/LibJPEG/jcapistd.c b/freeimage241/Source/LibJPEG/jcapistd.c deleted file mode 100644 index c0320b1..0000000 --- a/freeimage241/Source/LibJPEG/jcapistd.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * jcapistd.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "standard" API routines that are - * used in the normal full-compression case. They are not used by a - * transcoding-only application. Note that if an application links in - * jpeg_start_compress, it will end up linking in the entire compressor. - * We thus must separate this file from jcapimin.c to avoid linking the - * whole compression library into a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Compression initialization. - * Before calling this, all parameters and a data destination must be set up. - * - * We require a write_all_tables parameter as a failsafe check when writing - * multiple datastreams from the same compression object. Since prior runs - * will have left all the tables marked sent_table=TRUE, a subsequent run - * would emit an abbreviated stream (no tables) by default. This may be what - * is wanted, but for safety's sake it should not be the default behavior: - * programmers should have to make a deliberate choice to emit abbreviated - * images. Therefore the documentation and examples should encourage people - * to pass write_all_tables=TRUE; then it will take active thought to do the - * wrong thing. - */ - -GLOBAL(void) -jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (write_all_tables) - jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ - - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Perform master selection of active modules */ - jinit_compress_master(cinfo); - /* Set up for the first pass */ - (*cinfo->master->prepare_for_pass) (cinfo); - /* Ready for application to drive first pass through jpeg_write_scanlines - * or jpeg_write_raw_data. - */ - cinfo->next_scanline = 0; - cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); -} - - -/* - * Write some scanlines of data to the JPEG compressor. - * - * The return value will be the number of lines actually written. - * This should be less than the supplied num_lines only in case that - * the data destination module has requested suspension of the compressor, - * or if more than image_height scanlines are passed in. - * - * Note: we warn about excess calls to jpeg_write_scanlines() since - * this likely signals an application programmer error. However, - * excess scanlines passed in the last valid call are *silently* ignored, - * so that the application need not adjust num_lines for end-of-image - * when using a multiple-scanline buffer. - */ - -GLOBAL(JDIMENSION) -jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, - JDIMENSION num_lines) -{ - JDIMENSION row_ctr, rows_left; - - if (cinfo->global_state != CSTATE_SCANNING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->next_scanline >= cinfo->image_height) - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->next_scanline; - cinfo->progress->pass_limit = (long) cinfo->image_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Give master control module another chance if this is first call to - * jpeg_write_scanlines. This lets output of the frame/scan headers be - * delayed so that application can write COM, etc, markers between - * jpeg_start_compress and jpeg_write_scanlines. - */ - if (cinfo->master->call_pass_startup) - (*cinfo->master->pass_startup) (cinfo); - - /* Ignore any extra scanlines at bottom of image. */ - rows_left = cinfo->image_height - cinfo->next_scanline; - if (num_lines > rows_left) - num_lines = rows_left; - - row_ctr = 0; - (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); - cinfo->next_scanline += row_ctr; - return row_ctr; -} - - -/* - * Alternate entry point to write raw data. - * Processes exactly one iMCU row per call, unless suspended. - */ - -GLOBAL(JDIMENSION) -jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, - JDIMENSION num_lines) -{ - JDIMENSION lines_per_iMCU_row; - - if (cinfo->global_state != CSTATE_RAW_OK) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->next_scanline >= cinfo->image_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->next_scanline; - cinfo->progress->pass_limit = (long) cinfo->image_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Give master control module another chance if this is first call to - * jpeg_write_raw_data. This lets output of the frame/scan headers be - * delayed so that application can write COM, etc, markers between - * jpeg_start_compress and jpeg_write_raw_data. - */ - if (cinfo->master->call_pass_startup) - (*cinfo->master->pass_startup) (cinfo); - - /* Verify that at least one iMCU row has been passed. */ - lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE; - if (num_lines < lines_per_iMCU_row) - ERREXIT(cinfo, JERR_BUFFER_SIZE); - - /* Directly compress the row. */ - if (! (*cinfo->coef->compress_data) (cinfo, data)) { - /* If compressor did not consume the whole row, suspend processing. */ - return 0; - } - - /* OK, we processed one iMCU row. */ - cinfo->next_scanline += lines_per_iMCU_row; - return lines_per_iMCU_row; -} diff --git a/freeimage241/Source/LibJPEG/jccoefct.c b/freeimage241/Source/LibJPEG/jccoefct.c deleted file mode 100644 index 1963ddb..0000000 --- a/freeimage241/Source/LibJPEG/jccoefct.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * jccoefct.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the coefficient buffer controller for compression. - * This controller is the top level of the JPEG compressor proper. - * The coefficient buffer lies between forward-DCT and entropy encoding steps. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* We use a full-image coefficient buffer when doing Huffman optimization, - * and also for writing multiple-scan JPEG files. In all cases, the DCT - * step is run during the first pass, and subsequent passes need only read - * the buffered coefficients. - */ -#ifdef ENTROPY_OPT_SUPPORTED -#define FULL_COEF_BUFFER_SUPPORTED -#else -#ifdef C_MULTISCAN_FILES_SUPPORTED -#define FULL_COEF_BUFFER_SUPPORTED -#endif -#endif - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_coef_controller pub; /* public fields */ - - JDIMENSION iMCU_row_num; /* iMCU row # within image */ - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* For single-pass compression, it's sufficient to buffer just one MCU - * (although this may prove a bit slow in practice). We allocate a - * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each - * MCU constructed and sent. (On 80x86, the workspace is FAR even though - * it's not really very big; this is to keep the module interfaces unchanged - * when a large coefficient buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays. - */ - JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; - - /* In multi-pass modes, we need a virtual block array for each component. */ - jvirt_barray_ptr whole_image[MAX_COMPONENTS]; -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - - -/* Forward declarations */ -METHODDEF(boolean) compress_data - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -#ifdef FULL_COEF_BUFFER_SUPPORTED -METHODDEF(boolean) compress_first_pass - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -METHODDEF(boolean) compress_output - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -#endif - - -LOCAL(void) -start_iMCU_row (j_compress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->mcu_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - coef->iMCU_row_num = 0; - start_iMCU_row(cinfo); - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (coef->whole_image[0] != NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_data; - break; -#ifdef FULL_COEF_BUFFER_SUPPORTED - case JBUF_SAVE_AND_PASS: - if (coef->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_first_pass; - break; - case JBUF_CRANK_DEST: - if (coef->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_output; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data in the single-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the image. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf contains a plane for each component in image, - * which we index according to the component's SOF position. - */ - -METHODDEF(boolean) -compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, bi, ci, yindex, yoffset, blockcnt; - JDIMENSION ypos, xpos; - jpeg_component_info *compptr; - - /* Loop to write as much as one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col; - MCU_col_num++) { - /* Determine where data comes from in input_buf and do the DCT thing. - * Each call on forward_DCT processes a horizontal row of DCT blocks - * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks - * sequentially. Dummy blocks at the right or bottom edge are filled in - * specially. The data in them does not matter for image reconstruction, - * so we fill them with values that will encode to the smallest amount of - * data, viz: all zeroes in the AC entries, DC entries equal to previous - * block's DC value. (Thanks to Thomas Kinsman for this idea.) - */ - blkn = 0; - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - xpos = MCU_col_num * compptr->MCU_sample_width; - ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */ - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (coef->iMCU_row_num < last_iMCU_row || - yoffset+yindex < compptr->last_row_height) { - (*cinfo->fdct->forward_DCT) (cinfo, compptr, - input_buf[compptr->component_index], - coef->MCU_buffer[blkn], - ypos, xpos, (JDIMENSION) blockcnt); - if (blockcnt < compptr->MCU_width) { - /* Create some dummy blocks at the right edge of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], - (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); - for (bi = blockcnt; bi < compptr->MCU_width; bi++) { - coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; - } - } - } else { - /* Create a row of dummy blocks at the bottom of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn], - compptr->MCU_width * SIZEOF(JBLOCK)); - for (bi = 0; bi < compptr->MCU_width; bi++) { - coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; - } - } - blkn += compptr->MCU_width; - ypos += DCTSIZE; - } - } - /* Try to write the MCU. In event of a suspension failure, we will - * re-DCT the MCU on restart (a bit inefficient, could be fixed...) - */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - - -#ifdef FULL_COEF_BUFFER_SUPPORTED - -/* - * Process some data in the first pass of a multi-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the image. - * This amount of data is read from the source buffer, DCT'd and quantized, - * and saved into the virtual arrays. We also generate suitable dummy blocks - * as needed at the right and lower edges. (The dummy blocks are constructed - * in the virtual arrays, which have been padded appropriately.) This makes - * it possible for subsequent passes not to worry about real vs. dummy blocks. - * - * We must also emit the data to the entropy encoder. This is conveniently - * done by calling compress_output() after we've loaded the current strip - * of the virtual arrays. - * - * NB: input_buf contains a plane for each component in image. All - * components are DCT'd and loaded into the virtual arrays in this pass. - * However, it may be that only a subset of the components are emitted to - * the entropy encoder during this first pass; be careful about looking - * at the scan-dependent variables (MCU dimensions, etc). - */ - -METHODDEF(boolean) -compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION blocks_across, MCUs_across, MCUindex; - int bi, ci, h_samp_factor, block_row, block_rows, ndummy; - JCOEF lastDC; - jpeg_component_info *compptr; - JBLOCKARRAY buffer; - JBLOCKROW thisblockrow, lastblockrow; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Align the virtual buffer for this component. */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, TRUE); - /* Count non-dummy DCT block rows in this iMCU row. */ - if (coef->iMCU_row_num < last_iMCU_row) - block_rows = compptr->v_samp_factor; - else { - /* NB: can't use last_row_height here, since may not be set! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - } - blocks_across = compptr->width_in_blocks; - h_samp_factor = compptr->h_samp_factor; - /* Count number of dummy blocks to be added at the right margin. */ - ndummy = (int) (blocks_across % h_samp_factor); - if (ndummy > 0) - ndummy = h_samp_factor - ndummy; - /* Perform DCT for all non-dummy blocks in this iMCU row. Each call - * on forward_DCT processes a complete horizontal row of DCT blocks. - */ - for (block_row = 0; block_row < block_rows; block_row++) { - thisblockrow = buffer[block_row]; - (*cinfo->fdct->forward_DCT) (cinfo, compptr, - input_buf[ci], thisblockrow, - (JDIMENSION) (block_row * DCTSIZE), - (JDIMENSION) 0, blocks_across); - if (ndummy > 0) { - /* Create dummy blocks at the right edge of the image. */ - thisblockrow += blocks_across; /* => first dummy block */ - jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); - lastDC = thisblockrow[-1][0]; - for (bi = 0; bi < ndummy; bi++) { - thisblockrow[bi][0] = lastDC; - } - } - } - /* If at end of image, create dummy block rows as needed. - * The tricky part here is that within each MCU, we want the DC values - * of the dummy blocks to match the last real block's DC value. - * This squeezes a few more bytes out of the resulting file... - */ - if (coef->iMCU_row_num == last_iMCU_row) { - blocks_across += ndummy; /* include lower right corner */ - MCUs_across = blocks_across / h_samp_factor; - for (block_row = block_rows; block_row < compptr->v_samp_factor; - block_row++) { - thisblockrow = buffer[block_row]; - lastblockrow = buffer[block_row-1]; - jzero_far((void FAR *) thisblockrow, - (size_t) (blocks_across * SIZEOF(JBLOCK))); - for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { - lastDC = lastblockrow[h_samp_factor-1][0]; - for (bi = 0; bi < h_samp_factor; bi++) { - thisblockrow[bi][0] = lastDC; - } - thisblockrow += h_samp_factor; /* advance to next MCU in row */ - lastblockrow += h_samp_factor; - } - } - } - } - /* NB: compress_output will increment iMCU_row_num if successful. - * A suspension return will result in redoing all the work above next time. - */ - - /* Emit data to the entropy encoder, sharing code with subsequent passes */ - return compress_output(cinfo, input_buf); -} - - -/* - * Process some data in subsequent passes of a multi-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the scan. - * The data is obtained from the virtual arrays and fed to the entropy coder. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf is ignored; it is likely to be a NULL pointer. - */ - -METHODDEF(boolean) -compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - int blkn, ci, xindex, yindex, yoffset; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. - * NB: during first pass, this is safe only because the buffers will - * already be aligned properly, so jmemmgr.c won't need to do any I/O. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < compptr->MCU_width; xindex++) { - coef->MCU_buffer[blkn++] = buffer_ptr++; - } - } - } - /* Try to write the MCU. */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - -#endif /* FULL_COEF_BUFFER_SUPPORTED */ - - -/* - * Initialize coefficient buffer controller. - */ - -GLOBAL(void) -jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_coef_ptr coef; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_c_coef_controller *) coef; - coef->pub.start_pass = start_pass_coef; - - /* Create the coefficient buffer. */ - if (need_full_buffer) { -#ifdef FULL_COEF_BUFFER_SUPPORTED - /* Allocate a full-image virtual array for each component, */ - /* padded to a multiple of samp_factor DCT blocks in each direction. */ - int ci; - jpeg_component_info *compptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) compptr->v_samp_factor); - } -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - } else { - /* We only need a single-MCU buffer. */ - JBLOCKROW buffer; - int i; - - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { - coef->MCU_buffer[i] = buffer + i; - } - coef->whole_image[0] = NULL; /* flag for no virtual arrays */ - } -} diff --git a/freeimage241/Source/LibJPEG/jccolor.c b/freeimage241/Source/LibJPEG/jccolor.c deleted file mode 100644 index 0a8a4b5..0000000 --- a/freeimage241/Source/LibJPEG/jccolor.c +++ /dev/null @@ -1,459 +0,0 @@ -/* - * jccolor.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains input colorspace conversion routines. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_converter pub; /* public fields */ - - /* Private state for RGB->YCC conversion */ - INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */ -} my_color_converter; - -typedef my_color_converter * my_cconvert_ptr; - - -/**************** RGB -> YCbCr conversion: most common case **************/ - -/* - * YCbCr is defined per CCIR 601-1, except that Cb and Cr are - * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. - * The conversion equations to be implemented are therefore - * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B - * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE - * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE - * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) - * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, - * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and - * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0) - * were not represented exactly. Now we sacrifice exact representation of - * maximum red and maximum blue in order to get exact grayscales. - * - * To avoid floating-point arithmetic, we represent the fractional constants - * as integers scaled up by 2^16 (about 4 digits precision); we have to divide - * the products by 2^16, with appropriate rounding, to get the correct answer. - * - * For even more speed, we avoid doing any multiplications in the inner loop - * by precalculating the constants times R,G,B for all possible values. - * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); - * for 12-bit samples it is still acceptable. It's not very reasonable for - * 16-bit samples, but if you want lossless storage you shouldn't be changing - * colorspace anyway. - * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included - * in the tables to save adding them separately in the inner loop. - */ - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define CBCR_OFFSET ((INT32) CENTERJSAMPLE << SCALEBITS) -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L< Y section */ -#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */ -#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */ -#define R_CB_OFF (3*(MAXJSAMPLE+1)) -#define G_CB_OFF (4*(MAXJSAMPLE+1)) -#define B_CB_OFF (5*(MAXJSAMPLE+1)) -#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */ -#define G_CR_OFF (6*(MAXJSAMPLE+1)) -#define B_CR_OFF (7*(MAXJSAMPLE+1)) -#define TABLE_SIZE (8*(MAXJSAMPLE+1)) - - -/* - * Initialize for RGB->YCC colorspace conversion. - */ - -METHODDEF(void) -rgb_ycc_start (j_compress_ptr cinfo) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - INT32 * rgb_ycc_tab; - INT32 i; - - /* Allocate and fill in the conversion tables. */ - cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (TABLE_SIZE * SIZEOF(INT32))); - - for (i = 0; i <= MAXJSAMPLE; i++) { - rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; - rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i; - rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF; - rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i; - rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i; - /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. - * This ensures that the maximum output will round to MAXJSAMPLE - * not MAXJSAMPLE+1, and thus that we don't have to range-limit. - */ - rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; -/* B=>Cb and R=>Cr tables are the same - rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; -*/ - rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i; - rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i; - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * - * Note that we change from the application's interleaved-pixel format - * to our internal noninterleaved, one-plane-per-component format. - * The input buffer is therefore three times as wide as the output buffer. - * - * A starting row offset is provided only for the output buffer. The caller - * can easily adjust the passed input_buf value to accommodate any row - * offset required on that side. - */ - -METHODDEF(void) -rgb_ycc_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr0, outptr1, outptr2; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr0 = output_buf[0][output_row]; - outptr1 = output_buf[1][output_row]; - outptr2 = output_buf[2][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = GETJSAMPLE(inptr[RGB_RED]); - g = GETJSAMPLE(inptr[RGB_GREEN]); - b = GETJSAMPLE(inptr[RGB_BLUE]); - inptr += RGB_PIXELSIZE; - /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations - * must be too; we do not need an explicit range-limiting operation. - * Hence the value being shifted is never negative, and we don't - * need the general RIGHT_SHIFT macro. - */ - /* Y */ - outptr0[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - /* Cb */ - outptr1[col] = (JSAMPLE) - ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) - >> SCALEBITS); - /* Cr */ - outptr2[col] = (JSAMPLE) - ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) - >> SCALEBITS); - } - } -} - - -/**************** Cases other than RGB -> YCbCr **************/ - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles RGB->grayscale conversion, which is the same - * as the RGB->Y portion of RGB->YCbCr. - * We assume rgb_ycc_start has been called (we only use the Y tables). - */ - -METHODDEF(void) -rgb_gray_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr = output_buf[0][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = GETJSAMPLE(inptr[RGB_RED]); - g = GETJSAMPLE(inptr[RGB_GREEN]); - b = GETJSAMPLE(inptr[RGB_BLUE]); - inptr += RGB_PIXELSIZE; - /* Y */ - outptr[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles Adobe-style CMYK->YCCK conversion, - * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same - * conversion as above, while passing K (black) unchanged. - * We assume rgb_ycc_start has been called. - */ - -METHODDEF(void) -cmyk_ycck_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr0, outptr1, outptr2, outptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr0 = output_buf[0][output_row]; - outptr1 = output_buf[1][output_row]; - outptr2 = output_buf[2][output_row]; - outptr3 = output_buf[3][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = MAXJSAMPLE - GETJSAMPLE(inptr[0]); - g = MAXJSAMPLE - GETJSAMPLE(inptr[1]); - b = MAXJSAMPLE - GETJSAMPLE(inptr[2]); - /* K passes through as-is */ - outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */ - inptr += 4; - /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations - * must be too; we do not need an explicit range-limiting operation. - * Hence the value being shifted is never negative, and we don't - * need the general RIGHT_SHIFT macro. - */ - /* Y */ - outptr0[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - /* Cb */ - outptr1[col] = (JSAMPLE) - ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) - >> SCALEBITS); - /* Cr */ - outptr2[col] = (JSAMPLE) - ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) - >> SCALEBITS); - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles grayscale output with no conversion. - * The source can be either plain grayscale or YCbCr (since Y == gray). - */ - -METHODDEF(void) -grayscale_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - int instride = cinfo->input_components; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr = output_buf[0][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */ - inptr += instride; - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles multi-component colorspaces without conversion. - * We assume input_components == num_components. - */ - -METHODDEF(void) -null_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - register int ci; - int nc = cinfo->num_components; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - /* It seems fastest to make a separate pass for each component. */ - for (ci = 0; ci < nc; ci++) { - inptr = *input_buf; - outptr = output_buf[ci][output_row]; - for (col = 0; col < num_cols; col++) { - outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */ - inptr += nc; - } - } - input_buf++; - output_row++; - } -} - - -/* - * Empty method for start_pass. - */ - -METHODDEF(void) -null_method (j_compress_ptr cinfo) -{ - /* no work needed */ -} - - -/* - * Module initialization routine for input colorspace conversion. - */ - -GLOBAL(void) -jinit_color_converter (j_compress_ptr cinfo) -{ - my_cconvert_ptr cconvert; - - cconvert = (my_cconvert_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_color_converter)); - cinfo->cconvert = (struct jpeg_color_converter *) cconvert; - /* set start_pass to null method until we find out differently */ - cconvert->pub.start_pass = null_method; - - /* Make sure input_components agrees with in_color_space */ - switch (cinfo->in_color_space) { - case JCS_GRAYSCALE: - if (cinfo->input_components != 1) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - case JCS_RGB: -#if RGB_PIXELSIZE != 3 - if (cinfo->input_components != RGB_PIXELSIZE) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; -#endif /* else share code with YCbCr */ - - case JCS_YCbCr: - if (cinfo->input_components != 3) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - case JCS_CMYK: - case JCS_YCCK: - if (cinfo->input_components != 4) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - default: /* JCS_UNKNOWN can be anything */ - if (cinfo->input_components < 1) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - } - - /* Check num_components, set conversion method based on requested space */ - switch (cinfo->jpeg_color_space) { - case JCS_GRAYSCALE: - if (cinfo->num_components != 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_GRAYSCALE) - cconvert->pub.color_convert = grayscale_convert; - else if (cinfo->in_color_space == JCS_RGB) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = rgb_gray_convert; - } else if (cinfo->in_color_space == JCS_YCbCr) - cconvert->pub.color_convert = grayscale_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_RGB: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_YCbCr: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_RGB) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = rgb_ycc_convert; - } else if (cinfo->in_color_space == JCS_YCbCr) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_CMYK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_CMYK) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_YCCK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_CMYK) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = cmyk_ycck_convert; - } else if (cinfo->in_color_space == JCS_YCCK) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - default: /* allow null conversion of JCS_UNKNOWN */ - if (cinfo->jpeg_color_space != cinfo->in_color_space || - cinfo->num_components != cinfo->input_components) - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - cconvert->pub.color_convert = null_convert; - break; - } -} diff --git a/freeimage241/Source/LibJPEG/jcdctmgr.c b/freeimage241/Source/LibJPEG/jcdctmgr.c deleted file mode 100644 index 61fa79b..0000000 --- a/freeimage241/Source/LibJPEG/jcdctmgr.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * jcdctmgr.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the forward-DCT management logic. - * This code selects a particular DCT implementation to be used, - * and it performs related housekeeping chores including coefficient - * quantization. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - - -/* Private subobject for this module */ - -typedef struct { - struct jpeg_forward_dct pub; /* public fields */ - - /* Pointer to the DCT routine actually in use */ - forward_DCT_method_ptr do_dct; - - /* The actual post-DCT divisors --- not identical to the quant table - * entries, because of scaling (especially for an unnormalized DCT). - * Each table is given in normal array order. - */ - DCTELEM * divisors[NUM_QUANT_TBLS]; - -#ifdef DCT_FLOAT_SUPPORTED - /* Same as above for the floating-point case. */ - float_DCT_method_ptr do_float_dct; - FAST_FLOAT * float_divisors[NUM_QUANT_TBLS]; -#endif -} my_fdct_controller; - -typedef my_fdct_controller * my_fdct_ptr; - - -/* - * Initialize for a processing pass. - * Verify that all referenced Q-tables are present, and set up - * the divisor table for each one. - * In the current implementation, DCT of all components is done during - * the first pass, even if only some components will be output in the - * first scan. Hence all components should be examined here. - */ - -METHODDEF(void) -start_pass_fdctmgr (j_compress_ptr cinfo) -{ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - int ci, qtblno, i; - jpeg_component_info *compptr; - JQUANT_TBL * qtbl; - DCTELEM * dtbl; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - qtblno = compptr->quant_tbl_no; - /* Make sure specified quantization table is present */ - if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || - cinfo->quant_tbl_ptrs[qtblno] == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); - qtbl = cinfo->quant_tbl_ptrs[qtblno]; - /* Compute divisors for this quant table */ - /* We may do this more than once for same table, but it's not a big deal */ - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - /* For LL&M IDCT method, divisors are equal to raw quantization - * coefficients multiplied by 8 (to counteract scaling). - */ - if (fdct->divisors[qtblno] == NULL) { - fdct->divisors[qtblno] = (DCTELEM *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(DCTELEM)); - } - dtbl = fdct->divisors[qtblno]; - for (i = 0; i < DCTSIZE2; i++) { - dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3; - } - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - { - /* For AA&N IDCT method, divisors are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * We apply a further scale factor of 8. - */ -#define CONST_BITS 14 - static const INT16 aanscales[DCTSIZE2] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 - }; - SHIFT_TEMPS - - if (fdct->divisors[qtblno] == NULL) { - fdct->divisors[qtblno] = (DCTELEM *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(DCTELEM)); - } - dtbl = fdct->divisors[qtblno]; - for (i = 0; i < DCTSIZE2; i++) { - dtbl[i] = (DCTELEM) - DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], - (INT32) aanscales[i]), - CONST_BITS-3); - } - } - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - { - /* For float AA&N IDCT method, divisors are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * We apply a further scale factor of 8. - * What's actually stored is 1/divisor so that the inner loop can - * use a multiplication rather than a division. - */ - FAST_FLOAT * fdtbl; - int row, col; - static const double aanscalefactor[DCTSIZE] = { - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - }; - - if (fdct->float_divisors[qtblno] == NULL) { - fdct->float_divisors[qtblno] = (FAST_FLOAT *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(FAST_FLOAT)); - } - fdtbl = fdct->float_divisors[qtblno]; - i = 0; - for (row = 0; row < DCTSIZE; row++) { - for (col = 0; col < DCTSIZE; col++) { - fdtbl[i] = (FAST_FLOAT) - (1.0 / (((double) qtbl->quantval[i] * - aanscalefactor[row] * aanscalefactor[col] * 8.0))); - i++; - } - } - } - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - } -} - - -/* - * Perform forward DCT on one or more blocks of a component. - * - * The input samples are taken from the sample_data[] array starting at - * position start_row/start_col, and moving to the right for any additional - * blocks. The quantized coefficients are returned in coef_blocks[]. - */ - -METHODDEF(void) -forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks) -/* This version is used for integer DCT implementations. */ -{ - /* This routine is heavily used, so it's worth coding it tightly. */ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - forward_DCT_method_ptr do_dct = fdct->do_dct; - DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no]; - DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ - JDIMENSION bi; - - sample_data += start_row; /* fold in the vertical offset once */ - - for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { - /* Load data into workspace, applying unsigned->signed conversion */ - { register DCTELEM *workspaceptr; - register JSAMPROW elemptr; - register int elemr; - - workspaceptr = workspace; - for (elemr = 0; elemr < DCTSIZE; elemr++) { - elemptr = sample_data[elemr] + start_col; -#if DCTSIZE == 8 /* unroll the inner loop */ - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; -#else - { register int elemc; - for (elemc = DCTSIZE; elemc > 0; elemc--) { - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - } - } -#endif - } - } - - /* Perform the DCT */ - (*do_dct) (workspace); - - /* Quantize/descale the coefficients, and store into coef_blocks[] */ - { register DCTELEM temp, qval; - register int i; - register JCOEFPTR output_ptr = coef_blocks[bi]; - - for (i = 0; i < DCTSIZE2; i++) { - qval = divisors[i]; - temp = workspace[i]; - /* Divide the coefficient value by qval, ensuring proper rounding. - * Since C does not specify the direction of rounding for negative - * quotients, we have to force the dividend positive for portability. - * - * In most files, at least half of the output values will be zero - * (at default quantization settings, more like three-quarters...) - * so we should ensure that this case is fast. On many machines, - * a comparison is enough cheaper than a divide to make a special test - * a win. Since both inputs will be nonnegative, we need only test - * for a < b to discover whether a/b is 0. - * If your machine's division is fast enough, define FAST_DIVIDE. - */ -#ifdef FAST_DIVIDE -#define DIVIDE_BY(a,b) a /= b -#else -#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 -#endif - if (temp < 0) { - temp = -temp; - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - temp = -temp; - } else { - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - } - output_ptr[i] = (JCOEF) temp; - } - } - } -} - - -#ifdef DCT_FLOAT_SUPPORTED - -METHODDEF(void) -forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks) -/* This version is used for floating-point DCT implementations. */ -{ - /* This routine is heavily used, so it's worth coding it tightly. */ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - float_DCT_method_ptr do_dct = fdct->do_float_dct; - FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no]; - FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ - JDIMENSION bi; - - sample_data += start_row; /* fold in the vertical offset once */ - - for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { - /* Load data into workspace, applying unsigned->signed conversion */ - { register FAST_FLOAT *workspaceptr; - register JSAMPROW elemptr; - register int elemr; - - workspaceptr = workspace; - for (elemr = 0; elemr < DCTSIZE; elemr++) { - elemptr = sample_data[elemr] + start_col; -#if DCTSIZE == 8 /* unroll the inner loop */ - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); -#else - { register int elemc; - for (elemc = DCTSIZE; elemc > 0; elemc--) { - *workspaceptr++ = (FAST_FLOAT) - (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - } - } -#endif - } - } - - /* Perform the DCT */ - (*do_dct) (workspace); - - /* Quantize/descale the coefficients, and store into coef_blocks[] */ - { register FAST_FLOAT temp; - register int i; - register JCOEFPTR output_ptr = coef_blocks[bi]; - - for (i = 0; i < DCTSIZE2; i++) { - /* Apply the quantization and scaling factor */ - temp = workspace[i] * divisors[i]; - /* Round to nearest integer. - * Since C does not specify the direction of rounding for negative - * quotients, we have to force the dividend positive for portability. - * The maximum coefficient size is +-16K (for 12-bit data), so this - * code should work for either 16-bit or 32-bit ints. - */ - output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); - } - } - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ - - -/* - * Initialize FDCT manager. - */ - -GLOBAL(void) -jinit_forward_dct (j_compress_ptr cinfo) -{ - my_fdct_ptr fdct; - int i; - - fdct = (my_fdct_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_fdct_controller)); - cinfo->fdct = (struct jpeg_forward_dct *) fdct; - fdct->pub.start_pass = start_pass_fdctmgr; - - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - fdct->pub.forward_DCT = forward_DCT; - fdct->do_dct = jpeg_fdct_islow; - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - fdct->pub.forward_DCT = forward_DCT; - fdct->do_dct = jpeg_fdct_ifast; - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - fdct->pub.forward_DCT = forward_DCT_float; - fdct->do_float_dct = jpeg_fdct_float; - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - - /* Mark divisor tables unallocated */ - for (i = 0; i < NUM_QUANT_TBLS; i++) { - fdct->divisors[i] = NULL; -#ifdef DCT_FLOAT_SUPPORTED - fdct->float_divisors[i] = NULL; -#endif - } -} diff --git a/freeimage241/Source/LibJPEG/jchuff.c b/freeimage241/Source/LibJPEG/jchuff.c deleted file mode 100644 index f235250..0000000 --- a/freeimage241/Source/LibJPEG/jchuff.c +++ /dev/null @@ -1,909 +0,0 @@ -/* - * jchuff.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy encoding routines. - * - * Much of the complexity here has to do with supporting output suspension. - * If the data destination module demands suspension, we want to be able to - * back up to the start of the current MCU. To do this, we copy state - * variables into local working storage, and update them back to the - * permanent JPEG objects only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jchuff.h" /* Declarations shared with jcphuff.c */ - - -/* Expanded entropy encoder object for Huffman encoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - INT32 put_buffer; /* current bit-accumulation buffer */ - int put_bits; /* # of bits now in it */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).put_buffer = (src).put_buffer, \ - (dest).put_bits = (src).put_bits, \ - (dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_encoder pub; /* public fields */ - - savable_state saved; /* Bit buffer & DC state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - int next_restart_num; /* next restart number to write (0-7) */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; - c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; - -#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */ - long * dc_count_ptrs[NUM_HUFF_TBLS]; - long * ac_count_ptrs[NUM_HUFF_TBLS]; -#endif -} huff_entropy_encoder; - -typedef huff_entropy_encoder * huff_entropy_ptr; - -/* Working state while writing an MCU. - * This struct contains all the fields that are needed by subroutines. - */ - -typedef struct { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - savable_state cur; /* Current bit buffer & DC state */ - j_compress_ptr cinfo; /* dump_buffer needs access to this */ -} working_state; - - -/* Forward declarations */ -METHODDEF(boolean) encode_mcu_huff JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_huff JPP((j_compress_ptr cinfo)); -#ifdef ENTROPY_OPT_SUPPORTED -METHODDEF(boolean) encode_mcu_gather JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_gather JPP((j_compress_ptr cinfo)); -#endif - - -/* - * Initialize for a Huffman-compressed scan. - * If gather_statistics is TRUE, we do not output anything during the scan, - * just count the Huffman symbols used and generate Huffman code tables. - */ - -METHODDEF(void) -start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, dctbl, actbl; - jpeg_component_info * compptr; - - if (gather_statistics) { -#ifdef ENTROPY_OPT_SUPPORTED - entropy->pub.encode_mcu = encode_mcu_gather; - entropy->pub.finish_pass = finish_pass_gather; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - entropy->pub.encode_mcu = encode_mcu_huff; - entropy->pub.finish_pass = finish_pass_huff; - } - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - if (gather_statistics) { -#ifdef ENTROPY_OPT_SUPPORTED - /* Check for invalid table indexes */ - /* (make_c_derived_tbl does this in the other path) */ - if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl); - if (actbl < 0 || actbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl); - /* Allocate and zero the statistics tables */ - /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ - if (entropy->dc_count_ptrs[dctbl] == NULL) - entropy->dc_count_ptrs[dctbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long)); - if (entropy->ac_count_ptrs[actbl] == NULL) - entropy->ac_count_ptrs[actbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long)); -#endif - } else { - /* Compute derived values for Huffman tables */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl, - & entropy->dc_derived_tbls[dctbl]); - jpeg_make_c_derived_tbl(cinfo, FALSE, actbl, - & entropy->ac_derived_tbls[actbl]); - } - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Initialize bit buffer to empty */ - entropy->saved.put_buffer = 0; - entropy->saved.put_bits = 0; - - /* Initialize restart stuff */ - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num = 0; -} - - -/* - * Compute the derived values for a Huffman table. - * This routine also performs some validation checks on the table. - * - * Note this is also used by jcphuff.c. - */ - -GLOBAL(void) -jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno, - c_derived_tbl ** pdtbl) -{ - JHUFF_TBL *htbl; - c_derived_tbl *dtbl; - int p, i, l, lastp, si, maxsymbol; - char huffsize[257]; - unsigned int huffcode[257]; - unsigned int code; - - /* Note that huffsize[] and huffcode[] are filled in code-length order, - * paralleling the order of the symbols themselves in htbl->huffval[]. - */ - - /* Find the input Huffman table */ - if (tblno < 0 || tblno >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - htbl = - isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - - /* Allocate a workspace if we haven't already done so. */ - if (*pdtbl == NULL) - *pdtbl = (c_derived_tbl *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(c_derived_tbl)); - dtbl = *pdtbl; - - /* Figure C.1: make table of Huffman code length for each symbol */ - - p = 0; - for (l = 1; l <= 16; l++) { - i = (int) htbl->bits[l]; - if (i < 0 || p + i > 256) /* protect against table overrun */ - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - while (i--) - huffsize[p++] = (char) l; - } - huffsize[p] = 0; - lastp = p; - - /* Figure C.2: generate the codes themselves */ - /* We also validate that the counts represent a legal Huffman code tree. */ - - code = 0; - si = huffsize[0]; - p = 0; - while (huffsize[p]) { - while (((int) huffsize[p]) == si) { - huffcode[p++] = code; - code++; - } - /* code is now 1 more than the last code used for codelength si; but - * it must still fit in si bits, since no code is allowed to be all ones. - */ - if (((INT32) code) >= (((INT32) 1) << si)) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - code <<= 1; - si++; - } - - /* Figure C.3: generate encoding tables */ - /* These are code and size indexed by symbol value */ - - /* Set all codeless symbols to have code length 0; - * this lets us detect duplicate VAL entries here, and later - * allows emit_bits to detect any attempt to emit such symbols. - */ - MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi)); - - /* This is also a convenient place to check for out-of-range - * and duplicated VAL entries. We allow 0..255 for AC symbols - * but only 0..15 for DC. (We could constrain them further - * based on data depth and mode, but this seems enough.) - */ - maxsymbol = isDC ? 15 : 255; - - for (p = 0; p < lastp; p++) { - i = htbl->huffval[p]; - if (i < 0 || i > maxsymbol || dtbl->ehufsi[i]) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - dtbl->ehufco[i] = huffcode[p]; - dtbl->ehufsi[i] = huffsize[p]; - } -} - - -/* Outputting bytes to the file */ - -/* Emit a byte, taking 'action' if must suspend. */ -#define emit_byte(state,val,action) \ - { *(state)->next_output_byte++ = (JOCTET) (val); \ - if (--(state)->free_in_buffer == 0) \ - if (! dump_buffer(state)) \ - { action; } } - - -LOCAL(boolean) -dump_buffer (working_state * state) -/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */ -{ - struct jpeg_destination_mgr * dest = state->cinfo->dest; - - if (! (*dest->empty_output_buffer) (state->cinfo)) - return FALSE; - /* After a successful buffer dump, must reset buffer pointers */ - state->next_output_byte = dest->next_output_byte; - state->free_in_buffer = dest->free_in_buffer; - return TRUE; -} - - -/* Outputting bits to the file */ - -/* Only the right 24 bits of put_buffer are used; the valid bits are - * left-justified in this part. At most 16 bits can be passed to emit_bits - * in one call, and we never retain more than 7 bits in put_buffer - * between calls, so 24 bits are sufficient. - */ - -INLINE -LOCAL(boolean) -emit_bits (working_state * state, unsigned int code, int size) -/* Emit some bits; return TRUE if successful, FALSE if must suspend */ -{ - /* This routine is heavily used, so it's worth coding tightly. */ - register INT32 put_buffer = (INT32) code; - register int put_bits = state->cur.put_bits; - - /* if size is 0, caller used an invalid Huffman table entry */ - if (size == 0) - ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE); - - put_buffer &= (((INT32) 1)<cur.put_buffer; /* and merge with old buffer contents */ - - while (put_bits >= 8) { - int c = (int) ((put_buffer >> 16) & 0xFF); - - emit_byte(state, c, return FALSE); - if (c == 0xFF) { /* need to stuff a zero byte? */ - emit_byte(state, 0, return FALSE); - } - put_buffer <<= 8; - put_bits -= 8; - } - - state->cur.put_buffer = put_buffer; /* update state variables */ - state->cur.put_bits = put_bits; - - return TRUE; -} - - -LOCAL(boolean) -flush_bits (working_state * state) -{ - if (! emit_bits(state, 0x7F, 7)) /* fill any partial byte with ones */ - return FALSE; - state->cur.put_buffer = 0; /* and reset bit-buffer to empty */ - state->cur.put_bits = 0; - return TRUE; -} - - -/* Encode a single block's worth of coefficients */ - -LOCAL(boolean) -encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, - c_derived_tbl *dctbl, c_derived_tbl *actbl) -{ - register int temp, temp2; - register int nbits; - register int k, r, i; - - /* Encode the DC coefficient difference per section F.1.2.1 */ - - temp = temp2 = block[0] - last_dc_val; - - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* For a negative input, want temp2 = bitwise complement of abs(input) */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); - - /* Emit the Huffman-coded symbol for the number of bits */ - if (! emit_bits(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits])) - return FALSE; - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (nbits) /* emit_bits rejects calls with size 0 */ - if (! emit_bits(state, (unsigned int) temp2, nbits)) - return FALSE; - - /* Encode the AC coefficients per section F.1.2.2 */ - - r = 0; /* r = run length of zeros */ - - for (k = 1; k < DCTSIZE2; k++) { - if ((temp = block[jpeg_natural_order[k]]) == 0) { - r++; - } else { - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - if (! emit_bits(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0])) - return FALSE; - r -= 16; - } - - temp2 = temp; - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); - - /* Emit Huffman symbol for run length / number of bits */ - i = (r << 4) + nbits; - if (! emit_bits(state, actbl->ehufco[i], actbl->ehufsi[i])) - return FALSE; - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (! emit_bits(state, (unsigned int) temp2, nbits)) - return FALSE; - - r = 0; - } - } - - /* If the last coef(s) were zero, emit an end-of-block code */ - if (r > 0) - if (! emit_bits(state, actbl->ehufco[0], actbl->ehufsi[0])) - return FALSE; - - return TRUE; -} - - -/* - * Emit a restart marker & resynchronize predictions. - */ - -LOCAL(boolean) -emit_restart (working_state * state, int restart_num) -{ - int ci; - - if (! flush_bits(state)) - return FALSE; - - emit_byte(state, 0xFF, return FALSE); - emit_byte(state, JPEG_RST0 + restart_num, return FALSE); - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < state->cinfo->comps_in_scan; ci++) - state->cur.last_dc_val[ci] = 0; - - /* The restart counter is not updated until we successfully write the MCU. */ - - return TRUE; -} - - -/* - * Encode and output one MCU's worth of Huffman-compressed coefficients. - */ - -METHODDEF(boolean) -encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - working_state state; - int blkn, ci; - jpeg_component_info * compptr; - - /* Load up working state */ - state.next_output_byte = cinfo->dest->next_output_byte; - state.free_in_buffer = cinfo->dest->free_in_buffer; - ASSIGN_STATE(state.cur, entropy->saved); - state.cinfo = cinfo; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! emit_restart(&state, entropy->next_restart_num)) - return FALSE; - } - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - if (! encode_one_block(&state, - MCU_data[blkn][0], state.cur.last_dc_val[ci], - entropy->dc_derived_tbls[compptr->dc_tbl_no], - entropy->ac_derived_tbls[compptr->ac_tbl_no])) - return FALSE; - /* Update last_dc_val */ - state.cur.last_dc_val[ci] = MCU_data[blkn][0][0]; - } - - /* Completed MCU, so update state */ - cinfo->dest->next_output_byte = state.next_output_byte; - cinfo->dest->free_in_buffer = state.free_in_buffer; - ASSIGN_STATE(entropy->saved, state.cur); - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * Finish up at the end of a Huffman-compressed scan. - */ - -METHODDEF(void) -finish_pass_huff (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - working_state state; - - /* Load up working state ... flush_bits needs it */ - state.next_output_byte = cinfo->dest->next_output_byte; - state.free_in_buffer = cinfo->dest->free_in_buffer; - ASSIGN_STATE(state.cur, entropy->saved); - state.cinfo = cinfo; - - /* Flush out the last data */ - if (! flush_bits(&state)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - - /* Update state */ - cinfo->dest->next_output_byte = state.next_output_byte; - cinfo->dest->free_in_buffer = state.free_in_buffer; - ASSIGN_STATE(entropy->saved, state.cur); -} - - -/* - * Huffman coding optimization. - * - * We first scan the supplied data and count the number of uses of each symbol - * that is to be Huffman-coded. (This process MUST agree with the code above.) - * Then we build a Huffman coding tree for the observed counts. - * Symbols which are not needed at all for the particular image are not - * assigned any code, which saves space in the DHT marker as well as in - * the compressed data. - */ - -#ifdef ENTROPY_OPT_SUPPORTED - - -/* Process a single block's worth of coefficients */ - -LOCAL(void) -htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val, - long dc_counts[], long ac_counts[]) -{ - register int temp; - register int nbits; - register int k, r; - - /* Encode the DC coefficient difference per section F.1.2.1 */ - - temp = block[0] - last_dc_val; - if (temp < 0) - temp = -temp; - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count the Huffman symbol for the number of bits */ - dc_counts[nbits]++; - - /* Encode the AC coefficients per section F.1.2.2 */ - - r = 0; /* r = run length of zeros */ - - for (k = 1; k < DCTSIZE2; k++) { - if ((temp = block[jpeg_natural_order[k]]) == 0) { - r++; - } else { - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - ac_counts[0xF0]++; - r -= 16; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - if (temp < 0) - temp = -temp; - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count Huffman symbol for run length / number of bits */ - ac_counts[(r << 4) + nbits]++; - - r = 0; - } - } - - /* If the last coef(s) were zero, emit an end-of-block code */ - if (r > 0) - ac_counts[0]++; -} - - -/* - * Trial-encode one MCU's worth of Huffman-compressed coefficients. - * No data is actually output, so no suspension return is possible. - */ - -METHODDEF(boolean) -encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int blkn, ci; - jpeg_component_info * compptr; - - /* Take care of restart intervals if needed */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - /* Update restart state */ - entropy->restarts_to_go = cinfo->restart_interval; - } - entropy->restarts_to_go--; - } - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci], - entropy->dc_count_ptrs[compptr->dc_tbl_no], - entropy->ac_count_ptrs[compptr->ac_tbl_no]); - entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0]; - } - - return TRUE; -} - - -/* - * Generate the best Huffman code table for the given counts, fill htbl. - * Note this is also used by jcphuff.c. - * - * The JPEG standard requires that no symbol be assigned a codeword of all - * one bits (so that padding bits added at the end of a compressed segment - * can't look like a valid code). Because of the canonical ordering of - * codewords, this just means that there must be an unused slot in the - * longest codeword length category. Section K.2 of the JPEG spec suggests - * reserving such a slot by pretending that symbol 256 is a valid symbol - * with count 1. In theory that's not optimal; giving it count zero but - * including it in the symbol set anyway should give a better Huffman code. - * But the theoretically better code actually seems to come out worse in - * practice, because it produces more all-ones bytes (which incur stuffed - * zero bytes in the final file). In any case the difference is tiny. - * - * The JPEG standard requires Huffman codes to be no more than 16 bits long. - * If some symbols have a very small but nonzero probability, the Huffman tree - * must be adjusted to meet the code length restriction. We currently use - * the adjustment method suggested in JPEG section K.2. This method is *not* - * optimal; it may not choose the best possible limited-length code. But - * typically only very-low-frequency symbols will be given less-than-optimal - * lengths, so the code is almost optimal. Experimental comparisons against - * an optimal limited-length-code algorithm indicate that the difference is - * microscopic --- usually less than a hundredth of a percent of total size. - * So the extra complexity of an optimal algorithm doesn't seem worthwhile. - */ - -GLOBAL(void) -jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]) -{ -#define MAX_CLEN 32 /* assumed maximum initial code length */ - UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */ - int codesize[257]; /* codesize[k] = code length of symbol k */ - int others[257]; /* next symbol in current branch of tree */ - int c1, c2; - int p, i, j; - long v; - - /* This algorithm is explained in section K.2 of the JPEG standard */ - - MEMZERO(bits, SIZEOF(bits)); - MEMZERO(codesize, SIZEOF(codesize)); - for (i = 0; i < 257; i++) - others[i] = -1; /* init links to empty */ - - freq[256] = 1; /* make sure 256 has a nonzero count */ - /* Including the pseudo-symbol 256 in the Huffman procedure guarantees - * that no real symbol is given code-value of all ones, because 256 - * will be placed last in the largest codeword category. - */ - - /* Huffman's basic algorithm to assign optimal code lengths to symbols */ - - for (;;) { - /* Find the smallest nonzero frequency, set c1 = its symbol */ - /* In case of ties, take the larger symbol number */ - c1 = -1; - v = 1000000000L; - for (i = 0; i <= 256; i++) { - if (freq[i] && freq[i] <= v) { - v = freq[i]; - c1 = i; - } - } - - /* Find the next smallest nonzero frequency, set c2 = its symbol */ - /* In case of ties, take the larger symbol number */ - c2 = -1; - v = 1000000000L; - for (i = 0; i <= 256; i++) { - if (freq[i] && freq[i] <= v && i != c1) { - v = freq[i]; - c2 = i; - } - } - - /* Done if we've merged everything into one frequency */ - if (c2 < 0) - break; - - /* Else merge the two counts/trees */ - freq[c1] += freq[c2]; - freq[c2] = 0; - - /* Increment the codesize of everything in c1's tree branch */ - codesize[c1]++; - while (others[c1] >= 0) { - c1 = others[c1]; - codesize[c1]++; - } - - others[c1] = c2; /* chain c2 onto c1's tree branch */ - - /* Increment the codesize of everything in c2's tree branch */ - codesize[c2]++; - while (others[c2] >= 0) { - c2 = others[c2]; - codesize[c2]++; - } - } - - /* Now count the number of symbols of each code length */ - for (i = 0; i <= 256; i++) { - if (codesize[i]) { - /* The JPEG standard seems to think that this can't happen, */ - /* but I'm paranoid... */ - if (codesize[i] > MAX_CLEN) - ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW); - - bits[codesize[i]]++; - } - } - - /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure - * Huffman procedure assigned any such lengths, we must adjust the coding. - * Here is what the JPEG spec says about how this next bit works: - * Since symbols are paired for the longest Huffman code, the symbols are - * removed from this length category two at a time. The prefix for the pair - * (which is one bit shorter) is allocated to one of the pair; then, - * skipping the BITS entry for that prefix length, a code word from the next - * shortest nonzero BITS entry is converted into a prefix for two code words - * one bit longer. - */ - - for (i = MAX_CLEN; i > 16; i--) { - while (bits[i] > 0) { - j = i - 2; /* find length of new prefix to be used */ - while (bits[j] == 0) - j--; - - bits[i] -= 2; /* remove two symbols */ - bits[i-1]++; /* one goes in this length */ - bits[j+1] += 2; /* two new symbols in this length */ - bits[j]--; /* symbol of this length is now a prefix */ - } - } - - /* Remove the count for the pseudo-symbol 256 from the largest codelength */ - while (bits[i] == 0) /* find largest codelength still in use */ - i--; - bits[i]--; - - /* Return final symbol counts (only for lengths 0..16) */ - MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); - - /* Return a list of the symbols sorted by code length */ - /* It's not real clear to me why we don't need to consider the codelength - * changes made above, but the JPEG spec seems to think this works. - */ - p = 0; - for (i = 1; i <= MAX_CLEN; i++) { - for (j = 0; j <= 255; j++) { - if (codesize[j] == i) { - htbl->huffval[p] = (UINT8) j; - p++; - } - } - } - - /* Set sent_table FALSE so updated table will be written to JPEG file. */ - htbl->sent_table = FALSE; -} - - -/* - * Finish up a statistics-gathering pass and create the new Huffman tables. - */ - -METHODDEF(void) -finish_pass_gather (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, dctbl, actbl; - jpeg_component_info * compptr; - JHUFF_TBL **htblptr; - boolean did_dc[NUM_HUFF_TBLS]; - boolean did_ac[NUM_HUFF_TBLS]; - - /* It's important not to apply jpeg_gen_optimal_table more than once - * per table, because it clobbers the input frequency counts! - */ - MEMZERO(did_dc, SIZEOF(did_dc)); - MEMZERO(did_ac, SIZEOF(did_ac)); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - if (! did_dc[dctbl]) { - htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]); - did_dc[dctbl] = TRUE; - } - if (! did_ac[actbl]) { - htblptr = & cinfo->ac_huff_tbl_ptrs[actbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]); - did_ac[actbl] = TRUE; - } - } -} - - -#endif /* ENTROPY_OPT_SUPPORTED */ - - -/* - * Module initialization routine for Huffman entropy encoding. - */ - -GLOBAL(void) -jinit_huff_encoder (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy; - int i; - - entropy = (huff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(huff_entropy_encoder)); - cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; - entropy->pub.start_pass = start_pass_huff; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; -#ifdef ENTROPY_OPT_SUPPORTED - entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL; -#endif - } -} diff --git a/freeimage241/Source/LibJPEG/jchuff.h b/freeimage241/Source/LibJPEG/jchuff.h deleted file mode 100644 index a9599fc..0000000 --- a/freeimage241/Source/LibJPEG/jchuff.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * jchuff.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy encoding routines - * that are shared between the sequential encoder (jchuff.c) and the - * progressive encoder (jcphuff.c). No other modules need to see these. - */ - -/* The legal range of a DCT coefficient is - * -1024 .. +1023 for 8-bit data; - * -16384 .. +16383 for 12-bit data. - * Hence the magnitude should always fit in 10 or 14 bits respectively. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MAX_COEF_BITS 10 -#else -#define MAX_COEF_BITS 14 -#endif - -/* Derived data constructed for each Huffman table */ - -typedef struct { - unsigned int ehufco[256]; /* code for each symbol */ - char ehufsi[256]; /* length of code for each symbol */ - /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ -} c_derived_tbl; - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_c_derived_tbl jMkCDerived -#define jpeg_gen_optimal_table jGenOptTbl -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Expand a Huffman table definition into the derived format */ -EXTERN(void) jpeg_make_c_derived_tbl - JPP((j_compress_ptr cinfo, boolean isDC, int tblno, - c_derived_tbl ** pdtbl)); - -/* Generate an optimal table definition given the specified counts */ -EXTERN(void) jpeg_gen_optimal_table - JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); diff --git a/freeimage241/Source/LibJPEG/jcinit.c b/freeimage241/Source/LibJPEG/jcinit.c deleted file mode 100644 index 5efffe3..0000000 --- a/freeimage241/Source/LibJPEG/jcinit.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * jcinit.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains initialization logic for the JPEG compressor. - * This routine is in charge of selecting the modules to be executed and - * making an initialization call to each one. - * - * Logically, this code belongs in jcmaster.c. It's split out because - * linking this routine implies linking the entire compression library. - * For a transcoding-only application, we want to be able to use jcmaster.c - * without linking in the whole library. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Master selection of compression modules. - * This is done once at the start of processing an image. We determine - * which modules will be used and give them appropriate initialization calls. - */ - -GLOBAL(void) -jinit_compress_master (j_compress_ptr cinfo) -{ - /* Initialize master control (includes parameter checking/processing) */ - jinit_c_master_control(cinfo, FALSE /* full compression */); - - /* Preprocessing */ - if (! cinfo->raw_data_in) { - jinit_color_converter(cinfo); - jinit_downsampler(cinfo); - jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); - } - /* Forward DCT */ - jinit_forward_dct(cinfo); - /* Entropy encoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - jinit_phuff_encoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_encoder(cinfo); - } - - /* Need a full-image coefficient buffer in any multi-pass mode. */ - jinit_c_coef_controller(cinfo, - (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); - jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); - - jinit_marker_writer(cinfo); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Write the datastream header (SOI) immediately. - * Frame and scan headers are postponed till later. - * This lets application insert special markers after the SOI. - */ - (*cinfo->marker->write_file_header) (cinfo); -} diff --git a/freeimage241/Source/LibJPEG/jcmainct.c b/freeimage241/Source/LibJPEG/jcmainct.c deleted file mode 100644 index e0279a7..0000000 --- a/freeimage241/Source/LibJPEG/jcmainct.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * jcmainct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the main buffer controller for compression. - * The main buffer lies between the pre-processor and the JPEG - * compressor proper; it holds downsampled data in the JPEG colorspace. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Note: currently, there is no operating mode in which a full-image buffer - * is needed at this step. If there were, that mode could not be used with - * "raw data" input, since this module is bypassed in that case. However, - * we've left the code here for possible use in special applications. - */ -#undef FULL_MAIN_BUFFER_SUPPORTED - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_main_controller pub; /* public fields */ - - JDIMENSION cur_iMCU_row; /* number of current iMCU row */ - JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */ - boolean suspended; /* remember if we suspended output */ - J_BUF_MODE pass_mode; /* current operating mode */ - - /* If using just a strip buffer, this points to the entire set of buffers - * (we allocate one for each component). In the full-image case, this - * points to the currently accessible strips of the virtual arrays. - */ - JSAMPARRAY buffer[MAX_COMPONENTS]; - -#ifdef FULL_MAIN_BUFFER_SUPPORTED - /* If using full-image storage, this array holds pointers to virtual-array - * control blocks for each component. Unused if not full-image storage. - */ - jvirt_sarray_ptr whole_image[MAX_COMPONENTS]; -#endif -} my_main_controller; - -typedef my_main_controller * my_main_ptr; - - -/* Forward declarations */ -METHODDEF(void) process_data_simple_main - JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); -#ifdef FULL_MAIN_BUFFER_SUPPORTED -METHODDEF(void) process_data_buffer_main - JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); -#endif - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - /* Do nothing in raw-data mode. */ - if (cinfo->raw_data_in) - return; - - main->cur_iMCU_row = 0; /* initialize counters */ - main->rowgroup_ctr = 0; - main->suspended = FALSE; - main->pass_mode = pass_mode; /* save mode for use by process_data */ - - switch (pass_mode) { - case JBUF_PASS_THRU: -#ifdef FULL_MAIN_BUFFER_SUPPORTED - if (main->whole_image[0] != NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - main->pub.process_data = process_data_simple_main; - break; -#ifdef FULL_MAIN_BUFFER_SUPPORTED - case JBUF_SAVE_SOURCE: - case JBUF_CRANK_DEST: - case JBUF_SAVE_AND_PASS: - if (main->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - main->pub.process_data = process_data_buffer_main; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data. - * This routine handles the simple pass-through mode, - * where we have only a strip buffer. - */ - -METHODDEF(void) -process_data_simple_main (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { - /* Read input data if we haven't filled the main buffer yet */ - if (main->rowgroup_ctr < DCTSIZE) - (*cinfo->prep->pre_process_data) (cinfo, - input_buf, in_row_ctr, in_rows_avail, - main->buffer, &main->rowgroup_ctr, - (JDIMENSION) DCTSIZE); - - /* If we don't have a full iMCU row buffered, return to application for - * more data. Note that preprocessor will always pad to fill the iMCU row - * at the bottom of the image. - */ - if (main->rowgroup_ctr != DCTSIZE) - return; - - /* Send the completed row to the compressor */ - if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { - /* If compressor did not consume the whole row, then we must need to - * suspend processing and return to the application. In this situation - * we pretend we didn't yet consume the last input row; otherwise, if - * it happened to be the last row of the image, the application would - * think we were done. - */ - if (! main->suspended) { - (*in_row_ctr)--; - main->suspended = TRUE; - } - return; - } - /* We did finish the row. Undo our little suspension hack if a previous - * call suspended; then mark the main buffer empty. - */ - if (main->suspended) { - (*in_row_ctr)++; - main->suspended = FALSE; - } - main->rowgroup_ctr = 0; - main->cur_iMCU_row++; - } -} - - -#ifdef FULL_MAIN_BUFFER_SUPPORTED - -/* - * Process some data. - * This routine handles all of the modes that use a full-size buffer. - */ - -METHODDEF(void) -process_data_buffer_main (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci; - jpeg_component_info *compptr; - boolean writing = (main->pass_mode != JBUF_CRANK_DEST); - - while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { - /* Realign the virtual buffers if at the start of an iMCU row. */ - if (main->rowgroup_ctr == 0) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->buffer[ci] = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, main->whole_image[ci], - main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing); - } - /* In a read pass, pretend we just read some source data. */ - if (! writing) { - *in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE; - main->rowgroup_ctr = DCTSIZE; - } - } - - /* If a write pass, read input data until the current iMCU row is full. */ - /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ - if (writing) { - (*cinfo->prep->pre_process_data) (cinfo, - input_buf, in_row_ctr, in_rows_avail, - main->buffer, &main->rowgroup_ctr, - (JDIMENSION) DCTSIZE); - /* Return to application if we need more data to fill the iMCU row. */ - if (main->rowgroup_ctr < DCTSIZE) - return; - } - - /* Emit data, unless this is a sink-only pass. */ - if (main->pass_mode != JBUF_SAVE_SOURCE) { - if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { - /* If compressor did not consume the whole row, then we must need to - * suspend processing and return to the application. In this situation - * we pretend we didn't yet consume the last input row; otherwise, if - * it happened to be the last row of the image, the application would - * think we were done. - */ - if (! main->suspended) { - (*in_row_ctr)--; - main->suspended = TRUE; - } - return; - } - /* We did finish the row. Undo our little suspension hack if a previous - * call suspended; then mark the main buffer empty. - */ - if (main->suspended) { - (*in_row_ctr)++; - main->suspended = FALSE; - } - } - - /* If get here, we are done with this iMCU row. Mark buffer empty. */ - main->rowgroup_ctr = 0; - main->cur_iMCU_row++; - } -} - -#endif /* FULL_MAIN_BUFFER_SUPPORTED */ - - -/* - * Initialize main buffer controller. - */ - -GLOBAL(void) -jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_main_ptr main; - int ci; - jpeg_component_info *compptr; - - main = (my_main_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_main_controller)); - cinfo->main = (struct jpeg_c_main_controller *) main; - main->pub.start_pass = start_pass_main; - - /* We don't need to create a buffer in raw-data mode. */ - if (cinfo->raw_data_in) - return; - - /* Create the buffer. It holds downsampled data, so each component - * may be of a different size. - */ - if (need_full_buffer) { -#ifdef FULL_MAIN_BUFFER_SUPPORTED - /* Allocate a full-image virtual array for each component */ - /* Note we pad the bottom to a multiple of the iMCU height */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor) * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); - } -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - } else { -#ifdef FULL_MAIN_BUFFER_SUPPORTED - main->whole_image[0] = NULL; /* flag for no virtual arrays */ -#endif - /* Allocate a strip buffer for each component */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->buffer[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); - } - } -} diff --git a/freeimage241/Source/LibJPEG/jcmarker.c b/freeimage241/Source/LibJPEG/jcmarker.c deleted file mode 100644 index 3d1e6c6..0000000 --- a/freeimage241/Source/LibJPEG/jcmarker.c +++ /dev/null @@ -1,664 +0,0 @@ -/* - * jcmarker.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write JPEG datastream markers. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, - M_SOF1 = 0xc1, - M_SOF2 = 0xc2, - M_SOF3 = 0xc3, - - M_SOF5 = 0xc5, - M_SOF6 = 0xc6, - M_SOF7 = 0xc7, - - M_JPG = 0xc8, - M_SOF9 = 0xc9, - M_SOF10 = 0xca, - M_SOF11 = 0xcb, - - M_SOF13 = 0xcd, - M_SOF14 = 0xce, - M_SOF15 = 0xcf, - - M_DHT = 0xc4, - - M_DAC = 0xcc, - - M_RST0 = 0xd0, - M_RST1 = 0xd1, - M_RST2 = 0xd2, - M_RST3 = 0xd3, - M_RST4 = 0xd4, - M_RST5 = 0xd5, - M_RST6 = 0xd6, - M_RST7 = 0xd7, - - M_SOI = 0xd8, - M_EOI = 0xd9, - M_SOS = 0xda, - M_DQT = 0xdb, - M_DNL = 0xdc, - M_DRI = 0xdd, - M_DHP = 0xde, - M_EXP = 0xdf, - - M_APP0 = 0xe0, - M_APP1 = 0xe1, - M_APP2 = 0xe2, - M_APP3 = 0xe3, - M_APP4 = 0xe4, - M_APP5 = 0xe5, - M_APP6 = 0xe6, - M_APP7 = 0xe7, - M_APP8 = 0xe8, - M_APP9 = 0xe9, - M_APP10 = 0xea, - M_APP11 = 0xeb, - M_APP12 = 0xec, - M_APP13 = 0xed, - M_APP14 = 0xee, - M_APP15 = 0xef, - - M_JPG0 = 0xf0, - M_JPG13 = 0xfd, - M_COM = 0xfe, - - M_TEM = 0x01, - - M_ERROR = 0x100 -} JPEG_MARKER; - - -/* Private state */ - -typedef struct { - struct jpeg_marker_writer pub; /* public fields */ - - unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */ -} my_marker_writer; - -typedef my_marker_writer * my_marker_ptr; - - -/* - * Basic output routines. - * - * Note that we do not support suspension while writing a marker. - * Therefore, an application using suspension must ensure that there is - * enough buffer space for the initial markers (typ. 600-700 bytes) before - * calling jpeg_start_compress, and enough space to write the trailing EOI - * (a few bytes) before calling jpeg_finish_compress. Multipass compression - * modes are not supported at all with suspension, so those two are the only - * points where markers will be written. - */ - -LOCAL(void) -emit_byte (j_compress_ptr cinfo, int val) -/* Emit a byte */ -{ - struct jpeg_destination_mgr * dest = cinfo->dest; - - *(dest->next_output_byte)++ = (JOCTET) val; - if (--dest->free_in_buffer == 0) { - if (! (*dest->empty_output_buffer) (cinfo)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } -} - - -LOCAL(void) -emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) -/* Emit a marker code */ -{ - emit_byte(cinfo, 0xFF); - emit_byte(cinfo, (int) mark); -} - - -LOCAL(void) -emit_2bytes (j_compress_ptr cinfo, int value) -/* Emit a 2-byte integer; these are always MSB first in JPEG files */ -{ - emit_byte(cinfo, (value >> 8) & 0xFF); - emit_byte(cinfo, value & 0xFF); -} - - -/* - * Routines to write specific marker types. - */ - -LOCAL(int) -emit_dqt (j_compress_ptr cinfo, int index) -/* Emit a DQT marker */ -/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ -{ - JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; - int prec; - int i; - - if (qtbl == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); - - prec = 0; - for (i = 0; i < DCTSIZE2; i++) { - if (qtbl->quantval[i] > 255) - prec = 1; - } - - if (! qtbl->sent_table) { - emit_marker(cinfo, M_DQT); - - emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); - - emit_byte(cinfo, index + (prec<<4)); - - for (i = 0; i < DCTSIZE2; i++) { - /* The table entries must be emitted in zigzag order. */ - unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; - if (prec) - emit_byte(cinfo, (int) (qval >> 8)); - emit_byte(cinfo, (int) (qval & 0xFF)); - } - - qtbl->sent_table = TRUE; - } - - return prec; -} - - -LOCAL(void) -emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) -/* Emit a DHT marker */ -{ - JHUFF_TBL * htbl; - int length, i; - - if (is_ac) { - htbl = cinfo->ac_huff_tbl_ptrs[index]; - index += 0x10; /* output index has AC bit set */ - } else { - htbl = cinfo->dc_huff_tbl_ptrs[index]; - } - - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); - - if (! htbl->sent_table) { - emit_marker(cinfo, M_DHT); - - length = 0; - for (i = 1; i <= 16; i++) - length += htbl->bits[i]; - - emit_2bytes(cinfo, length + 2 + 1 + 16); - emit_byte(cinfo, index); - - for (i = 1; i <= 16; i++) - emit_byte(cinfo, htbl->bits[i]); - - for (i = 0; i < length; i++) - emit_byte(cinfo, htbl->huffval[i]); - - htbl->sent_table = TRUE; - } -} - - -LOCAL(void) -emit_dac (j_compress_ptr cinfo) -/* Emit a DAC marker */ -/* Since the useful info is so small, we want to emit all the tables in */ -/* one DAC marker. Therefore this routine does its own scan of the table. */ -{ -#ifdef C_ARITH_CODING_SUPPORTED - char dc_in_use[NUM_ARITH_TBLS]; - char ac_in_use[NUM_ARITH_TBLS]; - int length, i; - jpeg_component_info *compptr; - - for (i = 0; i < NUM_ARITH_TBLS; i++) - dc_in_use[i] = ac_in_use[i] = 0; - - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - dc_in_use[compptr->dc_tbl_no] = 1; - ac_in_use[compptr->ac_tbl_no] = 1; - } - - length = 0; - for (i = 0; i < NUM_ARITH_TBLS; i++) - length += dc_in_use[i] + ac_in_use[i]; - - emit_marker(cinfo, M_DAC); - - emit_2bytes(cinfo, length*2 + 2); - - for (i = 0; i < NUM_ARITH_TBLS; i++) { - if (dc_in_use[i]) { - emit_byte(cinfo, i); - emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); - } - if (ac_in_use[i]) { - emit_byte(cinfo, i + 0x10); - emit_byte(cinfo, cinfo->arith_ac_K[i]); - } - } -#endif /* C_ARITH_CODING_SUPPORTED */ -} - - -LOCAL(void) -emit_dri (j_compress_ptr cinfo) -/* Emit a DRI marker */ -{ - emit_marker(cinfo, M_DRI); - - emit_2bytes(cinfo, 4); /* fixed length */ - - emit_2bytes(cinfo, (int) cinfo->restart_interval); -} - - -LOCAL(void) -emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) -/* Emit a SOF marker */ -{ - int ci; - jpeg_component_info *compptr; - - emit_marker(cinfo, code); - - emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ - - /* Make sure image isn't bigger than SOF field can handle */ - if ((long) cinfo->image_height > 65535L || - (long) cinfo->image_width > 65535L) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); - - emit_byte(cinfo, cinfo->data_precision); - emit_2bytes(cinfo, (int) cinfo->image_height); - emit_2bytes(cinfo, (int) cinfo->image_width); - - emit_byte(cinfo, cinfo->num_components); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - emit_byte(cinfo, compptr->component_id); - emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); - emit_byte(cinfo, compptr->quant_tbl_no); - } -} - - -LOCAL(void) -emit_sos (j_compress_ptr cinfo) -/* Emit a SOS marker */ -{ - int i, td, ta; - jpeg_component_info *compptr; - - emit_marker(cinfo, M_SOS); - - emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ - - emit_byte(cinfo, cinfo->comps_in_scan); - - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - emit_byte(cinfo, compptr->component_id); - td = compptr->dc_tbl_no; - ta = compptr->ac_tbl_no; - if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan; - * furthermore, Huffman coding of DC refinement uses no table at all. - * We emit 0 for unused field(s); this is recommended by the P&M text - * but does not seem to be specified in the standard. - */ - if (cinfo->Ss == 0) { - ta = 0; /* DC scan */ - if (cinfo->Ah != 0 && !cinfo->arith_code) - td = 0; /* no DC table either */ - } else { - td = 0; /* AC scan */ - } - } - emit_byte(cinfo, (td << 4) + ta); - } - - emit_byte(cinfo, cinfo->Ss); - emit_byte(cinfo, cinfo->Se); - emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); -} - - -LOCAL(void) -emit_jfif_app0 (j_compress_ptr cinfo) -/* Emit a JFIF-compliant APP0 marker */ -{ - /* - * Length of APP0 block (2 bytes) - * Block ID (4 bytes - ASCII "JFIF") - * Zero byte (1 byte to terminate the ID string) - * Version Major, Minor (2 bytes - major first) - * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) - * Xdpu (2 bytes - dots per unit horizontal) - * Ydpu (2 bytes - dots per unit vertical) - * Thumbnail X size (1 byte) - * Thumbnail Y size (1 byte) - */ - - emit_marker(cinfo, M_APP0); - - emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ - - emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ - emit_byte(cinfo, 0x46); - emit_byte(cinfo, 0x49); - emit_byte(cinfo, 0x46); - emit_byte(cinfo, 0); - emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ - emit_byte(cinfo, cinfo->JFIF_minor_version); - emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ - emit_2bytes(cinfo, (int) cinfo->X_density); - emit_2bytes(cinfo, (int) cinfo->Y_density); - emit_byte(cinfo, 0); /* No thumbnail image */ - emit_byte(cinfo, 0); -} - - -LOCAL(void) -emit_adobe_app14 (j_compress_ptr cinfo) -/* Emit an Adobe APP14 marker */ -{ - /* - * Length of APP14 block (2 bytes) - * Block ID (5 bytes - ASCII "Adobe") - * Version Number (2 bytes - currently 100) - * Flags0 (2 bytes - currently 0) - * Flags1 (2 bytes - currently 0) - * Color transform (1 byte) - * - * Although Adobe TN 5116 mentions Version = 101, all the Adobe files - * now in circulation seem to use Version = 100, so that's what we write. - * - * We write the color transform byte as 1 if the JPEG color space is - * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with - * whether the encoder performed a transformation, which is pretty useless. - */ - - emit_marker(cinfo, M_APP14); - - emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ - - emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ - emit_byte(cinfo, 0x64); - emit_byte(cinfo, 0x6F); - emit_byte(cinfo, 0x62); - emit_byte(cinfo, 0x65); - emit_2bytes(cinfo, 100); /* Version */ - emit_2bytes(cinfo, 0); /* Flags0 */ - emit_2bytes(cinfo, 0); /* Flags1 */ - switch (cinfo->jpeg_color_space) { - case JCS_YCbCr: - emit_byte(cinfo, 1); /* Color transform = 1 */ - break; - case JCS_YCCK: - emit_byte(cinfo, 2); /* Color transform = 2 */ - break; - default: - emit_byte(cinfo, 0); /* Color transform = 0 */ - break; - } -} - - -/* - * These routines allow writing an arbitrary marker with parameters. - * The only intended use is to emit COM or APPn markers after calling - * write_file_header and before calling write_frame_header. - * Other uses are not guaranteed to produce desirable results. - * Counting the parameter bytes properly is the caller's responsibility. - */ - -METHODDEF(void) -write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -/* Emit an arbitrary marker header */ -{ - if (datalen > (unsigned int) 65533) /* safety check */ - ERREXIT(cinfo, JERR_BAD_LENGTH); - - emit_marker(cinfo, (JPEG_MARKER) marker); - - emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ -} - -METHODDEF(void) -write_marker_byte (j_compress_ptr cinfo, int val) -/* Emit one byte of marker parameters following write_marker_header */ -{ - emit_byte(cinfo, val); -} - - -/* - * Write datastream header. - * This consists of an SOI and optional APPn markers. - * We recommend use of the JFIF marker, but not the Adobe marker, - * when using YCbCr or grayscale data. The JFIF marker should NOT - * be used for any other JPEG colorspace. The Adobe marker is helpful - * to distinguish RGB, CMYK, and YCCK colorspaces. - * Note that an application can write additional header markers after - * jpeg_start_compress returns. - */ - -METHODDEF(void) -write_file_header (j_compress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - emit_marker(cinfo, M_SOI); /* first the SOI */ - - /* SOI is defined to reset restart interval to 0 */ - marker->last_restart_interval = 0; - - if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ - emit_jfif_app0(cinfo); - if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ - emit_adobe_app14(cinfo); -} - - -/* - * Write frame header. - * This consists of DQT and SOFn markers. - * Note that we do not emit the SOF until we have emitted the DQT(s). - * This avoids compatibility problems with incorrect implementations that - * try to error-check the quant table numbers as soon as they see the SOF. - */ - -METHODDEF(void) -write_frame_header (j_compress_ptr cinfo) -{ - int ci, prec; - boolean is_baseline; - jpeg_component_info *compptr; - - /* Emit DQT for each quantization table. - * Note that emit_dqt() suppresses any duplicate tables. - */ - prec = 0; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - prec += emit_dqt(cinfo, compptr->quant_tbl_no); - } - /* now prec is nonzero iff there are any 16-bit quant tables. */ - - /* Check for a non-baseline specification. - * Note we assume that Huffman table numbers won't be changed later. - */ - if (cinfo->arith_code || cinfo->progressive_mode || - cinfo->data_precision != 8) { - is_baseline = FALSE; - } else { - is_baseline = TRUE; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) - is_baseline = FALSE; - } - if (prec && is_baseline) { - is_baseline = FALSE; - /* If it's baseline except for quantizer size, warn the user */ - TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); - } - } - - /* Emit the proper SOF marker */ - if (cinfo->arith_code) { - emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ - } else { - if (cinfo->progressive_mode) - emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ - else if (is_baseline) - emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ - else - emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ - } -} - - -/* - * Write scan header. - * This consists of DHT or DAC markers, optional DRI, and SOS. - * Compressed data will be written following the SOS. - */ - -METHODDEF(void) -write_scan_header (j_compress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - int i; - jpeg_component_info *compptr; - - if (cinfo->arith_code) { - /* Emit arith conditioning info. We may have some duplication - * if the file has multiple scans, but it's so small it's hardly - * worth worrying about. - */ - emit_dac(cinfo); - } else { - /* Emit Huffman tables. - * Note that emit_dht() suppresses any duplicate tables. - */ - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan */ - if (cinfo->Ss == 0) { - if (cinfo->Ah == 0) /* DC needs no table for refinement scan */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - } else { - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } - } else { - /* Sequential mode: need both DC and AC tables */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } - } - } - - /* Emit DRI if required --- note that DRI value could change for each scan. - * We avoid wasting space with unnecessary DRIs, however. - */ - if (cinfo->restart_interval != marker->last_restart_interval) { - emit_dri(cinfo); - marker->last_restart_interval = cinfo->restart_interval; - } - - emit_sos(cinfo); -} - - -/* - * Write datastream trailer. - */ - -METHODDEF(void) -write_file_trailer (j_compress_ptr cinfo) -{ - emit_marker(cinfo, M_EOI); -} - - -/* - * Write an abbreviated table-specification datastream. - * This consists of SOI, DQT and DHT tables, and EOI. - * Any table that is defined and not marked sent_table = TRUE will be - * emitted. Note that all tables will be marked sent_table = TRUE at exit. - */ - -METHODDEF(void) -write_tables_only (j_compress_ptr cinfo) -{ - int i; - - emit_marker(cinfo, M_SOI); - - for (i = 0; i < NUM_QUANT_TBLS; i++) { - if (cinfo->quant_tbl_ptrs[i] != NULL) - (void) emit_dqt(cinfo, i); - } - - if (! cinfo->arith_code) { - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if (cinfo->dc_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, FALSE); - if (cinfo->ac_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, TRUE); - } - } - - emit_marker(cinfo, M_EOI); -} - - -/* - * Initialize the marker writer module. - */ - -GLOBAL(void) -jinit_marker_writer (j_compress_ptr cinfo) -{ - my_marker_ptr marker; - - /* Create the subobject */ - marker = (my_marker_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_marker_writer)); - cinfo->marker = (struct jpeg_marker_writer *) marker; - /* Initialize method pointers */ - marker->pub.write_file_header = write_file_header; - marker->pub.write_frame_header = write_frame_header; - marker->pub.write_scan_header = write_scan_header; - marker->pub.write_file_trailer = write_file_trailer; - marker->pub.write_tables_only = write_tables_only; - marker->pub.write_marker_header = write_marker_header; - marker->pub.write_marker_byte = write_marker_byte; - /* Initialize private state */ - marker->last_restart_interval = 0; -} diff --git a/freeimage241/Source/LibJPEG/jcmaster.c b/freeimage241/Source/LibJPEG/jcmaster.c deleted file mode 100644 index aab4020..0000000 --- a/freeimage241/Source/LibJPEG/jcmaster.c +++ /dev/null @@ -1,590 +0,0 @@ -/* - * jcmaster.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains master control logic for the JPEG compressor. - * These routines are concerned with parameter validation, initial setup, - * and inter-pass control (determining the number of passes and the work - * to be done in each pass). - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef enum { - main_pass, /* input data, also do first output step */ - huff_opt_pass, /* Huffman code optimization pass */ - output_pass /* data output pass */ -} c_pass_type; - -typedef struct { - struct jpeg_comp_master pub; /* public fields */ - - c_pass_type pass_type; /* the type of the current pass */ - - int pass_number; /* # of passes completed */ - int total_passes; /* total # of passes needed */ - - int scan_number; /* current index in scan_info[] */ -} my_comp_master; - -typedef my_comp_master * my_master_ptr; - - -/* - * Support routines that do various essential calculations. - */ - -LOCAL(void) -initial_setup (j_compress_ptr cinfo) -/* Do computations that are needed before master selection phase */ -{ - int ci; - jpeg_component_info *compptr; - long samplesperrow; - JDIMENSION jd_samplesperrow; - - /* Sanity check on image dimensions */ - if (cinfo->image_height <= 0 || cinfo->image_width <= 0 - || cinfo->num_components <= 0 || cinfo->input_components <= 0) - ERREXIT(cinfo, JERR_EMPTY_IMAGE); - - /* Make sure image isn't bigger than I can handle */ - if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || - (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); - - /* Width of an input scanline must be representable as JDIMENSION. */ - samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; - jd_samplesperrow = (JDIMENSION) samplesperrow; - if ((long) jd_samplesperrow != samplesperrow) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - - /* For now, precision must match compiled-in value... */ - if (cinfo->data_precision != BITS_IN_JSAMPLE) - ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); - - /* Check that number of components won't exceed internal array sizes */ - if (cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - - /* Compute maximum sampling factors; check factor validity */ - cinfo->max_h_samp_factor = 1; - cinfo->max_v_samp_factor = 1; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || - compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) - ERREXIT(cinfo, JERR_BAD_SAMPLING); - cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, - compptr->h_samp_factor); - cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, - compptr->v_samp_factor); - } - - /* Compute dimensions of components */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Fill in the correct component_index value; don't rely on application */ - compptr->component_index = ci; - /* For compression, we never do DCT scaling. */ - compptr->DCT_scaled_size = DCTSIZE; - /* Size in DCT blocks */ - compptr->width_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->height_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - /* Size in samples */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) cinfo->max_h_samp_factor); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) cinfo->max_v_samp_factor); - /* Mark component needed (this flag isn't actually used for compression) */ - compptr->component_needed = TRUE; - } - - /* Compute number of fully interleaved MCU rows (number of times that - * main controller will call coefficient controller). - */ - cinfo->total_iMCU_rows = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); -} - - -#ifdef C_MULTISCAN_FILES_SUPPORTED - -LOCAL(void) -validate_script (j_compress_ptr cinfo) -/* Verify that the scan script in cinfo->scan_info[] is valid; also - * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. - */ -{ - const jpeg_scan_info * scanptr; - int scanno, ncomps, ci, coefi, thisi; - int Ss, Se, Ah, Al; - boolean component_sent[MAX_COMPONENTS]; -#ifdef C_PROGRESSIVE_SUPPORTED - int * last_bitpos_ptr; - int last_bitpos[MAX_COMPONENTS][DCTSIZE2]; - /* -1 until that coefficient has been seen; then last Al for it */ -#endif - - if (cinfo->num_scans <= 0) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0); - - /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1; - * for progressive JPEG, no scan can have this. - */ - scanptr = cinfo->scan_info; - if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) { -#ifdef C_PROGRESSIVE_SUPPORTED - cinfo->progressive_mode = TRUE; - last_bitpos_ptr = & last_bitpos[0][0]; - for (ci = 0; ci < cinfo->num_components; ci++) - for (coefi = 0; coefi < DCTSIZE2; coefi++) - *last_bitpos_ptr++ = -1; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - cinfo->progressive_mode = FALSE; - for (ci = 0; ci < cinfo->num_components; ci++) - component_sent[ci] = FALSE; - } - - for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) { - /* Validate component indexes */ - ncomps = scanptr->comps_in_scan; - if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN); - for (ci = 0; ci < ncomps; ci++) { - thisi = scanptr->component_index[ci]; - if (thisi < 0 || thisi >= cinfo->num_components) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - /* Components must appear in SOF order within each scan */ - if (ci > 0 && thisi <= scanptr->component_index[ci-1]) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - } - /* Validate progression parameters */ - Ss = scanptr->Ss; - Se = scanptr->Se; - Ah = scanptr->Ah; - Al = scanptr->Al; - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - /* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that - * seems wrong: the upper bound ought to depend on data precision. - * Perhaps they really meant 0..N+1 for N-bit precision. - * Here we allow 0..10 for 8-bit data; Al larger than 10 results in - * out-of-range reconstructed DC values during the first DC scan, - * which might cause problems for some decoders. - */ -#if BITS_IN_JSAMPLE == 8 -#define MAX_AH_AL 10 -#else -#define MAX_AH_AL 13 -#endif - if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 || - Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - if (Ss == 0) { - if (Se != 0) /* DC and AC together not OK */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } else { - if (ncomps != 1) /* AC scans must be for only one component */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } - for (ci = 0; ci < ncomps; ci++) { - last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0]; - if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - for (coefi = Ss; coefi <= Se; coefi++) { - if (last_bitpos_ptr[coefi] < 0) { - /* first scan of this coefficient */ - if (Ah != 0) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } else { - /* not first scan */ - if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } - last_bitpos_ptr[coefi] = Al; - } - } -#endif - } else { - /* For sequential JPEG, all progression parameters must be these: */ - if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - /* Make sure components are not sent twice */ - for (ci = 0; ci < ncomps; ci++) { - thisi = scanptr->component_index[ci]; - if (component_sent[thisi]) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - component_sent[thisi] = TRUE; - } - } - } - - /* Now verify that everything got sent. */ - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - /* For progressive mode, we only check that at least some DC data - * got sent for each component; the spec does not require that all bits - * of all coefficients be transmitted. Would it be wiser to enforce - * transmission of all coefficient bits?? - */ - for (ci = 0; ci < cinfo->num_components; ci++) { - if (last_bitpos[ci][0] < 0) - ERREXIT(cinfo, JERR_MISSING_DATA); - } -#endif - } else { - for (ci = 0; ci < cinfo->num_components; ci++) { - if (! component_sent[ci]) - ERREXIT(cinfo, JERR_MISSING_DATA); - } - } -} - -#endif /* C_MULTISCAN_FILES_SUPPORTED */ - - -LOCAL(void) -select_scan_parameters (j_compress_ptr cinfo) -/* Set up the scan parameters for the current scan */ -{ - int ci; - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (cinfo->scan_info != NULL) { - /* Prepare for current scan --- the script is already validated */ - my_master_ptr master = (my_master_ptr) cinfo->master; - const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number; - - cinfo->comps_in_scan = scanptr->comps_in_scan; - for (ci = 0; ci < scanptr->comps_in_scan; ci++) { - cinfo->cur_comp_info[ci] = - &cinfo->comp_info[scanptr->component_index[ci]]; - } - cinfo->Ss = scanptr->Ss; - cinfo->Se = scanptr->Se; - cinfo->Ah = scanptr->Ah; - cinfo->Al = scanptr->Al; - } - else -#endif - { - /* Prepare for single sequential-JPEG scan containing all components */ - if (cinfo->num_components > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPS_IN_SCAN); - cinfo->comps_in_scan = cinfo->num_components; - for (ci = 0; ci < cinfo->num_components; ci++) { - cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci]; - } - cinfo->Ss = 0; - cinfo->Se = DCTSIZE2-1; - cinfo->Ah = 0; - cinfo->Al = 0; - } -} - - -LOCAL(void) -per_scan_setup (j_compress_ptr cinfo) -/* Do computations that are needed before processing a JPEG scan */ -/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */ -{ - int ci, mcublks, tmp; - jpeg_component_info *compptr; - - if (cinfo->comps_in_scan == 1) { - - /* Noninterleaved (single-component) scan */ - compptr = cinfo->cur_comp_info[0]; - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = compptr->width_in_blocks; - cinfo->MCU_rows_in_scan = compptr->height_in_blocks; - - /* For noninterleaved scan, always one block per MCU */ - compptr->MCU_width = 1; - compptr->MCU_height = 1; - compptr->MCU_blocks = 1; - compptr->MCU_sample_width = DCTSIZE; - compptr->last_col_width = 1; - /* For noninterleaved scans, it is convenient to define last_row_height - * as the number of block rows present in the last iMCU row. - */ - tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (tmp == 0) tmp = compptr->v_samp_factor; - compptr->last_row_height = tmp; - - /* Prepare array describing MCU composition */ - cinfo->blocks_in_MCU = 1; - cinfo->MCU_membership[0] = 0; - - } else { - - /* Interleaved (multi-component) scan */ - if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, - MAX_COMPS_IN_SCAN); - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, - (long) (cinfo->max_h_samp_factor*DCTSIZE)); - cinfo->MCU_rows_in_scan = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - cinfo->blocks_in_MCU = 0; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Sampling factors give # of blocks of component in each MCU */ - compptr->MCU_width = compptr->h_samp_factor; - compptr->MCU_height = compptr->v_samp_factor; - compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; - compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE; - /* Figure number of non-dummy blocks in last MCU column & row */ - tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); - if (tmp == 0) tmp = compptr->MCU_width; - compptr->last_col_width = tmp; - tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); - if (tmp == 0) tmp = compptr->MCU_height; - compptr->last_row_height = tmp; - /* Prepare array describing MCU composition */ - mcublks = compptr->MCU_blocks; - if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU) - ERREXIT(cinfo, JERR_BAD_MCU_SIZE); - while (mcublks-- > 0) { - cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; - } - } - - } - - /* Convert restart specified in rows to actual MCU count. */ - /* Note that count must fit in 16 bits, so we provide limiting. */ - if (cinfo->restart_in_rows > 0) { - long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; - cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); - } -} - - -/* - * Per-pass setup. - * This is called at the beginning of each pass. We determine which modules - * will be active during this pass and give them appropriate start_pass calls. - * We also set is_last_pass to indicate whether any more passes will be - * required. - */ - -METHODDEF(void) -prepare_for_pass (j_compress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - switch (master->pass_type) { - case main_pass: - /* Initial pass: will collect input data, and do either Huffman - * optimization or data output for the first scan. - */ - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - if (! cinfo->raw_data_in) { - (*cinfo->cconvert->start_pass) (cinfo); - (*cinfo->downsample->start_pass) (cinfo); - (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU); - } - (*cinfo->fdct->start_pass) (cinfo); - (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding); - (*cinfo->coef->start_pass) (cinfo, - (master->total_passes > 1 ? - JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); - (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); - if (cinfo->optimize_coding) { - /* No immediate data output; postpone writing frame/scan headers */ - master->pub.call_pass_startup = FALSE; - } else { - /* Will write frame/scan headers at first jpeg_write_scanlines call */ - master->pub.call_pass_startup = TRUE; - } - break; -#ifdef ENTROPY_OPT_SUPPORTED - case huff_opt_pass: - /* Do Huffman optimization for a scan after the first one. */ - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) { - (*cinfo->entropy->start_pass) (cinfo, TRUE); - (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); - master->pub.call_pass_startup = FALSE; - break; - } - /* Special case: Huffman DC refinement scans need no Huffman table - * and therefore we can skip the optimization pass for them. - */ - master->pass_type = output_pass; - master->pass_number++; - /*FALLTHROUGH*/ -#endif - case output_pass: - /* Do a data-output pass. */ - /* We need not repeat per-scan setup if prior optimization pass did it. */ - if (! cinfo->optimize_coding) { - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - } - (*cinfo->entropy->start_pass) (cinfo, FALSE); - (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); - /* We emit frame/scan headers now */ - if (master->scan_number == 0) - (*cinfo->marker->write_frame_header) (cinfo); - (*cinfo->marker->write_scan_header) (cinfo); - master->pub.call_pass_startup = FALSE; - break; - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - } - - master->pub.is_last_pass = (master->pass_number == master->total_passes-1); - - /* Set up progress monitor's pass info if present */ - if (cinfo->progress != NULL) { - cinfo->progress->completed_passes = master->pass_number; - cinfo->progress->total_passes = master->total_passes; - } -} - - -/* - * Special start-of-pass hook. - * This is called by jpeg_write_scanlines if call_pass_startup is TRUE. - * In single-pass processing, we need this hook because we don't want to - * write frame/scan headers during jpeg_start_compress; we want to let the - * application write COM markers etc. between jpeg_start_compress and the - * jpeg_write_scanlines loop. - * In multi-pass processing, this routine is not used. - */ - -METHODDEF(void) -pass_startup (j_compress_ptr cinfo) -{ - cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */ - - (*cinfo->marker->write_frame_header) (cinfo); - (*cinfo->marker->write_scan_header) (cinfo); -} - - -/* - * Finish up at end of pass. - */ - -METHODDEF(void) -finish_pass_master (j_compress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - /* The entropy coder always needs an end-of-pass call, - * either to analyze statistics or to flush its output buffer. - */ - (*cinfo->entropy->finish_pass) (cinfo); - - /* Update state for next pass */ - switch (master->pass_type) { - case main_pass: - /* next pass is either output of scan 0 (after optimization) - * or output of scan 1 (if no optimization). - */ - master->pass_type = output_pass; - if (! cinfo->optimize_coding) - master->scan_number++; - break; - case huff_opt_pass: - /* next pass is always output of current scan */ - master->pass_type = output_pass; - break; - case output_pass: - /* next pass is either optimization or output of next scan */ - if (cinfo->optimize_coding) - master->pass_type = huff_opt_pass; - master->scan_number++; - break; - } - - master->pass_number++; -} - - -/* - * Initialize master compression control. - */ - -GLOBAL(void) -jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only) -{ - my_master_ptr master; - - master = (my_master_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_comp_master)); - cinfo->master = (struct jpeg_comp_master *) master; - master->pub.prepare_for_pass = prepare_for_pass; - master->pub.pass_startup = pass_startup; - master->pub.finish_pass = finish_pass_master; - master->pub.is_last_pass = FALSE; - - /* Validate parameters, determine derived values */ - initial_setup(cinfo); - - if (cinfo->scan_info != NULL) { -#ifdef C_MULTISCAN_FILES_SUPPORTED - validate_script(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - cinfo->progressive_mode = FALSE; - cinfo->num_scans = 1; - } - - if (cinfo->progressive_mode) /* TEMPORARY HACK ??? */ - cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */ - - /* Initialize my private state */ - if (transcode_only) { - /* no main pass in transcoding */ - if (cinfo->optimize_coding) - master->pass_type = huff_opt_pass; - else - master->pass_type = output_pass; - } else { - /* for normal compression, first pass is always this type: */ - master->pass_type = main_pass; - } - master->scan_number = 0; - master->pass_number = 0; - if (cinfo->optimize_coding) - master->total_passes = cinfo->num_scans * 2; - else - master->total_passes = cinfo->num_scans; -} diff --git a/freeimage241/Source/LibJPEG/jcomapi.c b/freeimage241/Source/LibJPEG/jcomapi.c deleted file mode 100644 index 9b1fa75..0000000 --- a/freeimage241/Source/LibJPEG/jcomapi.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * jcomapi.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface routines that are used for both - * compression and decompression. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Abort processing of a JPEG compression or decompression operation, - * but don't destroy the object itself. - * - * For this, we merely clean up all the nonpermanent memory pools. - * Note that temp files (virtual arrays) are not allowed to belong to - * the permanent pool, so we will be able to close all temp files here. - * Closing a data source or destination, if necessary, is the application's - * responsibility. - */ - -GLOBAL(void) -jpeg_abort (j_common_ptr cinfo) -{ - int pool; - - /* Do nothing if called on a not-initialized or destroyed JPEG object. */ - if (cinfo->mem == NULL) - return; - - /* Releasing pools in reverse order might help avoid fragmentation - * with some (brain-damaged) malloc libraries. - */ - for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { - (*cinfo->mem->free_pool) (cinfo, pool); - } - - /* Reset overall state for possible reuse of object */ - if (cinfo->is_decompressor) { - cinfo->global_state = DSTATE_START; - /* Try to keep application from accessing now-deleted marker list. - * A bit kludgy to do it here, but this is the most central place. - */ - ((j_decompress_ptr) cinfo)->marker_list = NULL; - } else { - cinfo->global_state = CSTATE_START; - } -} - - -/* - * Destruction of a JPEG object. - * - * Everything gets deallocated except the master jpeg_compress_struct itself - * and the error manager struct. Both of these are supplied by the application - * and must be freed, if necessary, by the application. (Often they are on - * the stack and so don't need to be freed anyway.) - * Closing a data source or destination, if necessary, is the application's - * responsibility. - */ - -GLOBAL(void) -jpeg_destroy (j_common_ptr cinfo) -{ - /* We need only tell the memory manager to release everything. */ - /* NB: mem pointer is NULL if memory mgr failed to initialize. */ - if (cinfo->mem != NULL) - (*cinfo->mem->self_destruct) (cinfo); - cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ - cinfo->global_state = 0; /* mark it destroyed */ -} - - -/* - * Convenience routines for allocating quantization and Huffman tables. - * (Would jutils.c be a more reasonable place to put these?) - */ - -GLOBAL(JQUANT_TBL *) -jpeg_alloc_quant_table (j_common_ptr cinfo) -{ - JQUANT_TBL *tbl; - - tbl = (JQUANT_TBL *) - (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); - tbl->sent_table = FALSE; /* make sure this is false in any new table */ - return tbl; -} - - -GLOBAL(JHUFF_TBL *) -jpeg_alloc_huff_table (j_common_ptr cinfo) -{ - JHUFF_TBL *tbl; - - tbl = (JHUFF_TBL *) - (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); - tbl->sent_table = FALSE; /* make sure this is false in any new table */ - return tbl; -} diff --git a/freeimage241/Source/LibJPEG/jconfig.h b/freeimage241/Source/LibJPEG/jconfig.h deleted file mode 100644 index 7e291c7..0000000 --- a/freeimage241/Source/LibJPEG/jconfig.h +++ /dev/null @@ -1,45 +0,0 @@ -/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT -/* #define void char */ -/* #define const */ -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ -#undef NEED_SHORT_EXTERNAL_NAMES -#undef INCOMPLETE_TYPES_BROKEN - -/* Define "boolean" as unsigned char, not int, per Windows custom */ -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ - - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#undef RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#define TWO_FILE_COMMANDLINE /* optional */ -#define USE_SETMODE /* Microsoft has setmode() */ -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE -#undef PROGRESS_REPORT /* optional */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/freeimage241/Source/LibJPEG/jcparam.c b/freeimage241/Source/LibJPEG/jcparam.c deleted file mode 100644 index 6fc48f5..0000000 --- a/freeimage241/Source/LibJPEG/jcparam.c +++ /dev/null @@ -1,610 +0,0 @@ -/* - * jcparam.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains optional default-setting code for the JPEG compressor. - * Applications do not have to use this file, but those that don't use it - * must know a lot more about the innards of the JPEG code. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Quantization table setup routines - */ - -GLOBAL(void) -jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, boolean force_baseline) -/* Define a quantization table equal to the basic_table times - * a scale factor (given as a percentage). - * If force_baseline is TRUE, the computed quantization table entries - * are limited to 1..255 for JPEG baseline compatibility. - */ -{ - JQUANT_TBL ** qtblptr; - int i; - long temp; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS) - ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl); - - qtblptr = & cinfo->quant_tbl_ptrs[which_tbl]; - - if (*qtblptr == NULL) - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo); - - for (i = 0; i < DCTSIZE2; i++) { - temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; - /* limit the values to the valid range */ - if (temp <= 0L) temp = 1L; - if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */ - if (force_baseline && temp > 255L) - temp = 255L; /* limit to baseline range if requested */ - (*qtblptr)->quantval[i] = (UINT16) temp; - } - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*qtblptr)->sent_table = FALSE; -} - - -GLOBAL(void) -jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, - boolean force_baseline) -/* Set or change the 'quality' (quantization) setting, using default tables - * and a straight percentage-scaling quality scale. In most cases it's better - * to use jpeg_set_quality (below); this entry point is provided for - * applications that insist on a linear percentage scaling. - */ -{ - /* These are the sample quantization tables given in JPEG spec section K.1. - * The spec says that the values given produce "good" quality, and - * when divided by 2, "very good" quality. - */ - static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = { - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 56, 68, 109, 103, 77, - 24, 35, 55, 64, 81, 104, 113, 92, - 49, 64, 78, 87, 103, 121, 120, 101, - 72, 92, 95, 98, 112, 100, 103, 99 - }; - static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = { - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 - }; - - /* Set up two quantization tables using the specified scaling */ - jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, - scale_factor, force_baseline); - jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, - scale_factor, force_baseline); -} - - -GLOBAL(int) -jpeg_quality_scaling (int quality) -/* Convert a user-specified quality rating to a percentage scaling factor - * for an underlying quantization table, using our recommended scaling curve. - * The input 'quality' factor should be 0 (terrible) to 100 (very good). - */ -{ - /* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */ - if (quality <= 0) quality = 1; - if (quality > 100) quality = 100; - - /* The basic table is used as-is (scaling 100) for a quality of 50. - * Qualities 50..100 are converted to scaling percentage 200 - 2*Q; - * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table - * to make all the table entries 1 (hence, minimum quantization loss). - * Qualities 1..50 are converted to scaling percentage 5000/Q. - */ - if (quality < 50) - quality = 5000 / quality; - else - quality = 200 - quality*2; - - return quality; -} - - -GLOBAL(void) -jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) -/* Set or change the 'quality' (quantization) setting, using default tables. - * This is the standard quality-adjusting entry point for typical user - * interfaces; only those who want detailed control over quantization tables - * would use the preceding three routines directly. - */ -{ - /* Convert user 0-100 rating to percentage scaling */ - quality = jpeg_quality_scaling(quality); - - /* Set up standard quality tables */ - jpeg_set_linear_quality(cinfo, quality, force_baseline); -} - - -/* - * Huffman table setup routines - */ - -LOCAL(void) -add_huff_table (j_compress_ptr cinfo, - JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) -/* Define a Huffman table */ -{ - int nsymbols, len; - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - /* Copy the number-of-symbols-of-each-code-length counts */ - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - - /* Validate the counts. We do this here mainly so we can copy the right - * number of symbols from the val[] array, without risking marching off - * the end of memory. jchuff.c will do a more thorough test later. - */ - nsymbols = 0; - for (len = 1; len <= 16; len++) - nsymbols += bits[len]; - if (nsymbols < 1 || nsymbols > 256) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8)); - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*htblptr)->sent_table = FALSE; -} - - -LOCAL(void) -std_huff_tables (j_compress_ptr cinfo) -/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ -/* IMPORTANT: these are only valid for 8-bit data precision! */ -{ - static const UINT8 bits_dc_luminance[17] = - { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_luminance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_dc_chrominance[17] = - { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_chrominance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_ac_luminance[17] = - { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; - static const UINT8 val_ac_luminance[] = - { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, - 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, - 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, - 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, - 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, - 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, - 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, - 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, - 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, - 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, - 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - static const UINT8 bits_ac_chrominance[17] = - { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; - static const UINT8 val_ac_chrominance[] = - { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, - 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, - 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, - 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, - 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, - 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, - 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, - 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, - 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, - 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, - 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, - 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, - 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0], - bits_dc_luminance, val_dc_luminance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0], - bits_ac_luminance, val_ac_luminance); - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1], - bits_dc_chrominance, val_dc_chrominance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1], - bits_ac_chrominance, val_ac_chrominance); -} - - -/* - * Default parameter setup for compression. - * - * Applications that don't choose to use this routine must do their - * own setup of all these parameters. Alternately, you can call this - * to establish defaults and then alter parameters selectively. This - * is the recommended approach since, if we add any new parameters, - * your code will still work (they'll be set to reasonable defaults). - */ - -GLOBAL(void) -jpeg_set_defaults (j_compress_ptr cinfo) -{ - int i; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* Allocate comp_info array large enough for maximum component count. - * Array is made permanent in case application wants to compress - * multiple images at same param settings. - */ - if (cinfo->comp_info == NULL) - cinfo->comp_info = (jpeg_component_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - MAX_COMPONENTS * SIZEOF(jpeg_component_info)); - - /* Initialize everything not dependent on the color space */ - - cinfo->data_precision = BITS_IN_JSAMPLE; - /* Set up two quantization tables using default quality of 75 */ - jpeg_set_quality(cinfo, 75, TRUE); - /* Set up two Huffman tables */ - std_huff_tables(cinfo); - - /* Initialize default arithmetic coding conditioning */ - for (i = 0; i < NUM_ARITH_TBLS; i++) { - cinfo->arith_dc_L[i] = 0; - cinfo->arith_dc_U[i] = 1; - cinfo->arith_ac_K[i] = 5; - } - - /* Default is no multiple-scan output */ - cinfo->scan_info = NULL; - cinfo->num_scans = 0; - - /* Expect normal source image, not raw downsampled data */ - cinfo->raw_data_in = FALSE; - - /* Use Huffman coding, not arithmetic coding, by default */ - cinfo->arith_code = FALSE; - - /* By default, don't do extra passes to optimize entropy coding */ - cinfo->optimize_coding = FALSE; - /* The standard Huffman tables are only valid for 8-bit data precision. - * If the precision is higher, force optimization on so that usable - * tables will be computed. This test can be removed if default tables - * are supplied that are valid for the desired precision. - */ - if (cinfo->data_precision > 8) - cinfo->optimize_coding = TRUE; - - /* By default, use the simpler non-cosited sampling alignment */ - cinfo->CCIR601_sampling = FALSE; - - /* No input smoothing */ - cinfo->smoothing_factor = 0; - - /* DCT algorithm preference */ - cinfo->dct_method = JDCT_DEFAULT; - - /* No restart markers */ - cinfo->restart_interval = 0; - cinfo->restart_in_rows = 0; - - /* Fill in default JFIF marker parameters. Note that whether the marker - * will actually be written is determined by jpeg_set_colorspace. - * - * By default, the library emits JFIF version code 1.01. - * An application that wants to emit JFIF 1.02 extension markers should set - * JFIF_minor_version to 2. We could probably get away with just defaulting - * to 1.02, but there may still be some decoders in use that will complain - * about that; saying 1.01 should minimize compatibility problems. - */ - cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */ - cinfo->JFIF_minor_version = 1; - cinfo->density_unit = 0; /* Pixel size is unknown by default */ - cinfo->X_density = 1; /* Pixel aspect ratio is square by default */ - cinfo->Y_density = 1; - - /* Choose JPEG colorspace based on input space, set defaults accordingly */ - - jpeg_default_colorspace(cinfo); -} - - -/* - * Select an appropriate JPEG colorspace for in_color_space. - */ - -GLOBAL(void) -jpeg_default_colorspace (j_compress_ptr cinfo) -{ - switch (cinfo->in_color_space) { - case JCS_GRAYSCALE: - jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); - break; - case JCS_RGB: - jpeg_set_colorspace(cinfo, JCS_YCbCr); - break; - case JCS_YCbCr: - jpeg_set_colorspace(cinfo, JCS_YCbCr); - break; - case JCS_CMYK: - jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */ - break; - case JCS_YCCK: - jpeg_set_colorspace(cinfo, JCS_YCCK); - break; - case JCS_UNKNOWN: - jpeg_set_colorspace(cinfo, JCS_UNKNOWN); - break; - default: - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - } -} - - -/* - * Set the JPEG colorspace, and choose colorspace-dependent default values. - */ - -GLOBAL(void) -jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) -{ - jpeg_component_info * compptr; - int ci; - -#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \ - (compptr = &cinfo->comp_info[index], \ - compptr->component_id = (id), \ - compptr->h_samp_factor = (hsamp), \ - compptr->v_samp_factor = (vsamp), \ - compptr->quant_tbl_no = (quant), \ - compptr->dc_tbl_no = (dctbl), \ - compptr->ac_tbl_no = (actbl) ) - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* For all colorspaces, we use Q and Huff tables 0 for luminance components, - * tables 1 for chrominance components. - */ - - cinfo->jpeg_color_space = colorspace; - - cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */ - cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */ - - switch (colorspace) { - case JCS_GRAYSCALE: - cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ - cinfo->num_components = 1; - /* JFIF specifies component ID 1 */ - SET_COMP(0, 1, 1,1, 0, 0,0); - break; - case JCS_RGB: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */ - cinfo->num_components = 3; - SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0); - SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0); - SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0); - break; - case JCS_YCbCr: - cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ - cinfo->num_components = 3; - /* JFIF specifies component IDs 1,2,3 */ - /* We default to 2x2 subsamples of chrominance */ - SET_COMP(0, 1, 2,2, 0, 0,0); - SET_COMP(1, 2, 1,1, 1, 1,1); - SET_COMP(2, 3, 1,1, 1, 1,1); - break; - case JCS_CMYK: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */ - cinfo->num_components = 4; - SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0); - SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0); - SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0); - SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0); - break; - case JCS_YCCK: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */ - cinfo->num_components = 4; - SET_COMP(0, 1, 2,2, 0, 0,0); - SET_COMP(1, 2, 1,1, 1, 1,1); - SET_COMP(2, 3, 1,1, 1, 1,1); - SET_COMP(3, 4, 2,2, 0, 0,0); - break; - case JCS_UNKNOWN: - cinfo->num_components = cinfo->input_components; - if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - for (ci = 0; ci < cinfo->num_components; ci++) { - SET_COMP(ci, ci, 1,1, 0, 0,0); - } - break; - default: - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - } -} - - -#ifdef C_PROGRESSIVE_SUPPORTED - -LOCAL(jpeg_scan_info *) -fill_a_scan (jpeg_scan_info * scanptr, int ci, - int Ss, int Se, int Ah, int Al) -/* Support routine: generate one scan for specified component */ -{ - scanptr->comps_in_scan = 1; - scanptr->component_index[0] = ci; - scanptr->Ss = Ss; - scanptr->Se = Se; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - return scanptr; -} - -LOCAL(jpeg_scan_info *) -fill_scans (jpeg_scan_info * scanptr, int ncomps, - int Ss, int Se, int Ah, int Al) -/* Support routine: generate one scan for each component */ -{ - int ci; - - for (ci = 0; ci < ncomps; ci++) { - scanptr->comps_in_scan = 1; - scanptr->component_index[0] = ci; - scanptr->Ss = Ss; - scanptr->Se = Se; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - } - return scanptr; -} - -LOCAL(jpeg_scan_info *) -fill_dc_scans (jpeg_scan_info * scanptr, int ncomps, int Ah, int Al) -/* Support routine: generate interleaved DC scan if possible, else N scans */ -{ - int ci; - - if (ncomps <= MAX_COMPS_IN_SCAN) { - /* Single interleaved DC scan */ - scanptr->comps_in_scan = ncomps; - for (ci = 0; ci < ncomps; ci++) - scanptr->component_index[ci] = ci; - scanptr->Ss = scanptr->Se = 0; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - } else { - /* Noninterleaved DC scan for each component */ - scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al); - } - return scanptr; -} - - -/* - * Create a recommended progressive-JPEG script. - * cinfo->num_components and cinfo->jpeg_color_space must be correct. - */ - -GLOBAL(void) -jpeg_simple_progression (j_compress_ptr cinfo) -{ - int ncomps = cinfo->num_components; - int nscans; - jpeg_scan_info * scanptr; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* Figure space needed for script. Calculation must match code below! */ - if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { - /* Custom script for YCbCr color images. */ - nscans = 10; - } else { - /* All-purpose script for other color spaces. */ - if (ncomps > MAX_COMPS_IN_SCAN) - nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */ - else - nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */ - } - - /* Allocate space for script. - * We need to put it in the permanent pool in case the application performs - * multiple compressions without changing the settings. To avoid a memory - * leak if jpeg_simple_progression is called repeatedly for the same JPEG - * object, we try to re-use previously allocated space, and we allocate - * enough space to handle YCbCr even if initially asked for grayscale. - */ - if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) { - cinfo->script_space_size = MAX(nscans, 10); - cinfo->script_space = (jpeg_scan_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - cinfo->script_space_size * SIZEOF(jpeg_scan_info)); - } - scanptr = cinfo->script_space; - cinfo->scan_info = scanptr; - cinfo->num_scans = nscans; - - if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { - /* Custom script for YCbCr color images. */ - /* Initial DC scan */ - scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); - /* Initial AC scan: get some luma data out in a hurry */ - scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2); - /* Chroma data is too small to be worth expending many scans on */ - scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1); - scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1); - /* Complete spectral selection for luma AC */ - scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2); - /* Refine next bit of luma AC */ - scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1); - /* Finish DC successive approximation */ - scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); - /* Finish AC successive approximation */ - scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0); - scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0); - /* Luma bottom bit comes last since it's usually largest scan */ - scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0); - } else { - /* All-purpose script for other color spaces. */ - /* Successive approximation first pass */ - scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); - scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2); - scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2); - /* Successive approximation second pass */ - scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1); - /* Successive approximation final pass */ - scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); - scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0); - } -} - -#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jcphuff.c b/freeimage241/Source/LibJPEG/jcphuff.c deleted file mode 100644 index 07f9178..0000000 --- a/freeimage241/Source/LibJPEG/jcphuff.c +++ /dev/null @@ -1,833 +0,0 @@ -/* - * jcphuff.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy encoding routines for progressive JPEG. - * - * We do not support output suspension in this module, since the library - * currently does not allow multiple-scan files to be written with output - * suspension. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jchuff.h" /* Declarations shared with jchuff.c */ - -#ifdef C_PROGRESSIVE_SUPPORTED - -/* Expanded entropy encoder object for progressive Huffman encoding. */ - -typedef struct { - struct jpeg_entropy_encoder pub; /* public fields */ - - /* Mode flag: TRUE for optimization, FALSE for actual data output */ - boolean gather_statistics; - - /* Bit-level coding status. - * next_output_byte/free_in_buffer are local copies of cinfo->dest fields. - */ - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - INT32 put_buffer; /* current bit-accumulation buffer */ - int put_bits; /* # of bits now in it */ - j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */ - - /* Coding status for DC components */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ - - /* Coding status for AC components */ - int ac_tbl_no; /* the table number of the single component */ - unsigned int EOBRUN; /* run length of EOBs */ - unsigned int BE; /* # of buffered correction bits before MCU */ - char * bit_buffer; /* buffer for correction bits (1 per char) */ - /* packing correction bits tightly would save some space but cost time... */ - - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - int next_restart_num; /* next restart number to write (0-7) */ - - /* Pointers to derived tables (these workspaces have image lifespan). - * Since any one scan codes only DC or only AC, we only need one set - * of tables, not one for DC and one for AC. - */ - c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; - - /* Statistics tables for optimization; again, one set is enough */ - long * count_ptrs[NUM_HUFF_TBLS]; -} phuff_entropy_encoder; - -typedef phuff_entropy_encoder * phuff_entropy_ptr; - -/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit - * buffer can hold. Larger sizes may slightly improve compression, but - * 1000 is already well into the realm of overkill. - * The minimum safe size is 64 bits. - */ - -#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */ - -/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32. - * We assume that int right shift is unsigned if INT32 right shift is, - * which should be safe. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define ISHIFT_TEMPS int ishift_temp; -#define IRIGHT_SHIFT(x,shft) \ - ((ishift_temp = (x)) < 0 ? \ - (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ - (ishift_temp >> (shft))) -#else -#define ISHIFT_TEMPS -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - -/* Forward declarations */ -METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo)); -METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo)); - - -/* - * Initialize for a Huffman-compressed scan using progressive JPEG. - */ - -METHODDEF(void) -start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band; - int ci, tbl; - jpeg_component_info * compptr; - - entropy->cinfo = cinfo; - entropy->gather_statistics = gather_statistics; - - is_DC_band = (cinfo->Ss == 0); - - /* We assume jcmaster.c already validated the scan parameters. */ - - /* Select execution routines */ - if (cinfo->Ah == 0) { - if (is_DC_band) - entropy->pub.encode_mcu = encode_mcu_DC_first; - else - entropy->pub.encode_mcu = encode_mcu_AC_first; - } else { - if (is_DC_band) - entropy->pub.encode_mcu = encode_mcu_DC_refine; - else { - entropy->pub.encode_mcu = encode_mcu_AC_refine; - /* AC refinement needs a correction bit buffer */ - if (entropy->bit_buffer == NULL) - entropy->bit_buffer = (char *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - MAX_CORR_BITS * SIZEOF(char)); - } - } - if (gather_statistics) - entropy->pub.finish_pass = finish_pass_gather_phuff; - else - entropy->pub.finish_pass = finish_pass_phuff; - - /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1 - * for AC coefficients. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Initialize DC predictions to 0 */ - entropy->last_dc_val[ci] = 0; - /* Get table index */ - if (is_DC_band) { - if (cinfo->Ah != 0) /* DC refinement needs no table */ - continue; - tbl = compptr->dc_tbl_no; - } else { - entropy->ac_tbl_no = tbl = compptr->ac_tbl_no; - } - if (gather_statistics) { - /* Check for invalid table index */ - /* (make_c_derived_tbl does this in the other path) */ - if (tbl < 0 || tbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); - /* Allocate and zero the statistics tables */ - /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ - if (entropy->count_ptrs[tbl] == NULL) - entropy->count_ptrs[tbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long)); - } else { - /* Compute derived values for Huffman table */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl, - & entropy->derived_tbls[tbl]); - } - } - - /* Initialize AC stuff */ - entropy->EOBRUN = 0; - entropy->BE = 0; - - /* Initialize bit buffer to empty */ - entropy->put_buffer = 0; - entropy->put_bits = 0; - - /* Initialize restart stuff */ - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num = 0; -} - - -/* Outputting bytes to the file. - * NB: these must be called only when actually outputting, - * that is, entropy->gather_statistics == FALSE. - */ - -/* Emit a byte */ -#define emit_byte(entropy,val) \ - { *(entropy)->next_output_byte++ = (JOCTET) (val); \ - if (--(entropy)->free_in_buffer == 0) \ - dump_buffer(entropy); } - - -LOCAL(void) -dump_buffer (phuff_entropy_ptr entropy) -/* Empty the output buffer; we do not support suspension in this module. */ -{ - struct jpeg_destination_mgr * dest = entropy->cinfo->dest; - - if (! (*dest->empty_output_buffer) (entropy->cinfo)) - ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); - /* After a successful buffer dump, must reset buffer pointers */ - entropy->next_output_byte = dest->next_output_byte; - entropy->free_in_buffer = dest->free_in_buffer; -} - - -/* Outputting bits to the file */ - -/* Only the right 24 bits of put_buffer are used; the valid bits are - * left-justified in this part. At most 16 bits can be passed to emit_bits - * in one call, and we never retain more than 7 bits in put_buffer - * between calls, so 24 bits are sufficient. - */ - -INLINE -LOCAL(void) -emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size) -/* Emit some bits, unless we are in gather mode */ -{ - /* This routine is heavily used, so it's worth coding tightly. */ - register INT32 put_buffer = (INT32) code; - register int put_bits = entropy->put_bits; - - /* if size is 0, caller used an invalid Huffman table entry */ - if (size == 0) - ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); - - if (entropy->gather_statistics) - return; /* do nothing if we're only getting stats */ - - put_buffer &= (((INT32) 1)<put_buffer; /* and merge with old buffer contents */ - - while (put_bits >= 8) { - int c = (int) ((put_buffer >> 16) & 0xFF); - - emit_byte(entropy, c); - if (c == 0xFF) { /* need to stuff a zero byte? */ - emit_byte(entropy, 0); - } - put_buffer <<= 8; - put_bits -= 8; - } - - entropy->put_buffer = put_buffer; /* update variables */ - entropy->put_bits = put_bits; -} - - -LOCAL(void) -flush_bits (phuff_entropy_ptr entropy) -{ - emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */ - entropy->put_buffer = 0; /* and reset bit-buffer to empty */ - entropy->put_bits = 0; -} - - -/* - * Emit (or just count) a Huffman symbol. - */ - -INLINE -LOCAL(void) -emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol) -{ - if (entropy->gather_statistics) - entropy->count_ptrs[tbl_no][symbol]++; - else { - c_derived_tbl * tbl = entropy->derived_tbls[tbl_no]; - emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); - } -} - - -/* - * Emit bits from a correction bit buffer. - */ - -LOCAL(void) -emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart, - unsigned int nbits) -{ - if (entropy->gather_statistics) - return; /* no real work */ - - while (nbits > 0) { - emit_bits(entropy, (unsigned int) (*bufstart), 1); - bufstart++; - nbits--; - } -} - - -/* - * Emit any pending EOBRUN symbol. - */ - -LOCAL(void) -emit_eobrun (phuff_entropy_ptr entropy) -{ - register int temp, nbits; - - if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ - temp = entropy->EOBRUN; - nbits = 0; - while ((temp >>= 1)) - nbits++; - /* safety check: shouldn't happen given limited correction-bit buffer */ - if (nbits > 14) - ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); - - emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4); - if (nbits) - emit_bits(entropy, entropy->EOBRUN, nbits); - - entropy->EOBRUN = 0; - - /* Emit any buffered correction bits */ - emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); - entropy->BE = 0; - } -} - - -/* - * Emit a restart marker & resynchronize predictions. - */ - -LOCAL(void) -emit_restart (phuff_entropy_ptr entropy, int restart_num) -{ - int ci; - - emit_eobrun(entropy); - - if (! entropy->gather_statistics) { - flush_bits(entropy); - emit_byte(entropy, 0xFF); - emit_byte(entropy, JPEG_RST0 + restart_num); - } - - if (entropy->cinfo->Ss == 0) { - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) - entropy->last_dc_val[ci] = 0; - } else { - /* Re-initialize all AC-related fields to 0 */ - entropy->EOBRUN = 0; - entropy->BE = 0; - } -} - - -/* - * MCU encoding for DC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp, temp2; - register int nbits; - int blkn, ci; - int Al = cinfo->Al; - JBLOCKROW block; - jpeg_component_info * compptr; - ISHIFT_TEMPS - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - - /* Compute the DC value after the required point transform by Al. - * This is simply an arithmetic right shift. - */ - temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al); - - /* DC differences are figured on the point-transformed values. */ - temp = temp2 - entropy->last_dc_val[ci]; - entropy->last_dc_val[ci] = temp2; - - /* Encode the DC coefficient difference per section G.1.2.1 */ - temp2 = temp; - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* For a negative input, want temp2 = bitwise complement of abs(input) */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count/emit the Huffman-coded symbol for the number of bits */ - emit_symbol(entropy, compptr->dc_tbl_no, nbits); - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (nbits) /* emit_bits rejects calls with size 0 */ - emit_bits(entropy, (unsigned int) temp2, nbits); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for AC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp, temp2; - register int nbits; - register int r, k; - int Se = cinfo->Se; - int Al = cinfo->Al; - JBLOCKROW block; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data block */ - block = MCU_data[0]; - - /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */ - - r = 0; /* r = run length of zeros */ - - for (k = cinfo->Ss; k <= Se; k++) { - if ((temp = (*block)[jpeg_natural_order[k]]) == 0) { - r++; - continue; - } - /* We must apply the point transform by Al. For AC coefficients this - * is an integer division with rounding towards 0. To do this portably - * in C, we shift after obtaining the absolute value; so the code is - * interwoven with finding the abs value (temp) and output bits (temp2). - */ - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - temp >>= Al; /* apply the point transform */ - /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ - temp2 = ~temp; - } else { - temp >>= Al; /* apply the point transform */ - temp2 = temp; - } - /* Watch out for case that nonzero coef is zero after point transform */ - if (temp == 0) { - r++; - continue; - } - - /* Emit any pending EOBRUN */ - if (entropy->EOBRUN > 0) - emit_eobrun(entropy); - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); - r -= 16; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count/emit Huffman symbol for run length / number of bits */ - emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - emit_bits(entropy, (unsigned int) temp2, nbits); - - r = 0; /* reset zero run length */ - } - - if (r > 0) { /* If there are trailing zeroes, */ - entropy->EOBRUN++; /* count an EOB */ - if (entropy->EOBRUN == 0x7FFF) - emit_eobrun(entropy); /* force it out to avoid overflow */ - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for DC successive approximation refinement scan. - * Note: we assume such scans can be multi-component, although the spec - * is not very clear on the point. - */ - -METHODDEF(boolean) -encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp; - int blkn; - int Al = cinfo->Al; - JBLOCKROW block; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - - /* We simply emit the Al'th bit of the DC coefficient value. */ - temp = (*block)[0]; - emit_bits(entropy, (unsigned int) (temp >> Al), 1); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for AC successive approximation refinement scan. - */ - -METHODDEF(boolean) -encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp; - register int r, k; - int EOB; - char *BR_buffer; - unsigned int BR; - int Se = cinfo->Se; - int Al = cinfo->Al; - JBLOCKROW block; - int absvalues[DCTSIZE2]; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data block */ - block = MCU_data[0]; - - /* It is convenient to make a pre-pass to determine the transformed - * coefficients' absolute values and the EOB position. - */ - EOB = 0; - for (k = cinfo->Ss; k <= Se; k++) { - temp = (*block)[jpeg_natural_order[k]]; - /* We must apply the point transform by Al. For AC coefficients this - * is an integer division with rounding towards 0. To do this portably - * in C, we shift after obtaining the absolute value. - */ - if (temp < 0) - temp = -temp; /* temp is abs value of input */ - temp >>= Al; /* apply the point transform */ - absvalues[k] = temp; /* save abs value for main pass */ - if (temp == 1) - EOB = k; /* EOB = index of last newly-nonzero coef */ - } - - /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */ - - r = 0; /* r = run length of zeros */ - BR = 0; /* BR = count of buffered bits added now */ - BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ - - for (k = cinfo->Ss; k <= Se; k++) { - if ((temp = absvalues[k]) == 0) { - r++; - continue; - } - - /* Emit any required ZRLs, but not if they can be folded into EOB */ - while (r > 15 && k <= EOB) { - /* emit any pending EOBRUN and the BE correction bits */ - emit_eobrun(entropy); - /* Emit ZRL */ - emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); - r -= 16; - /* Emit buffered correction bits that must be associated with ZRL */ - emit_buffered_bits(entropy, BR_buffer, BR); - BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ - BR = 0; - } - - /* If the coef was previously nonzero, it only needs a correction bit. - * NOTE: a straight translation of the spec's figure G.7 would suggest - * that we also need to test r > 15. But if r > 15, we can only get here - * if k > EOB, which implies that this coefficient is not 1. - */ - if (temp > 1) { - /* The correction bit is the next bit of the absolute value. */ - BR_buffer[BR++] = (char) (temp & 1); - continue; - } - - /* Emit any pending EOBRUN and the BE correction bits */ - emit_eobrun(entropy); - - /* Count/emit Huffman symbol for run length / number of bits */ - emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); - - /* Emit output bit for newly-nonzero coef */ - temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1; - emit_bits(entropy, (unsigned int) temp, 1); - - /* Emit buffered correction bits that must be associated with this code */ - emit_buffered_bits(entropy, BR_buffer, BR); - BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ - BR = 0; - r = 0; /* reset zero run length */ - } - - if (r > 0 || BR > 0) { /* If there are trailing zeroes, */ - entropy->EOBRUN++; /* count an EOB */ - entropy->BE += BR; /* concat my correction bits to older ones */ - /* We force out the EOB if we risk either: - * 1. overflow of the EOB counter; - * 2. overflow of the correction bit buffer during the next MCU. - */ - if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) - emit_eobrun(entropy); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * Finish up at the end of a Huffman-compressed progressive scan. - */ - -METHODDEF(void) -finish_pass_phuff (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Flush out any buffered data */ - emit_eobrun(entropy); - flush_bits(entropy); - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; -} - - -/* - * Finish up a statistics-gathering pass and create the new Huffman tables. - */ - -METHODDEF(void) -finish_pass_gather_phuff (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band; - int ci, tbl; - jpeg_component_info * compptr; - JHUFF_TBL **htblptr; - boolean did[NUM_HUFF_TBLS]; - - /* Flush out buffered data (all we care about is counting the EOB symbol) */ - emit_eobrun(entropy); - - is_DC_band = (cinfo->Ss == 0); - - /* It's important not to apply jpeg_gen_optimal_table more than once - * per table, because it clobbers the input frequency counts! - */ - MEMZERO(did, SIZEOF(did)); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - if (is_DC_band) { - if (cinfo->Ah != 0) /* DC refinement needs no table */ - continue; - tbl = compptr->dc_tbl_no; - } else { - tbl = compptr->ac_tbl_no; - } - if (! did[tbl]) { - if (is_DC_band) - htblptr = & cinfo->dc_huff_tbl_ptrs[tbl]; - else - htblptr = & cinfo->ac_huff_tbl_ptrs[tbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]); - did[tbl] = TRUE; - } - } -} - - -/* - * Module initialization routine for progressive Huffman entropy encoding. - */ - -GLOBAL(void) -jinit_phuff_encoder (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy; - int i; - - entropy = (phuff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(phuff_entropy_encoder)); - cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; - entropy->pub.start_pass = start_pass_phuff; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->derived_tbls[i] = NULL; - entropy->count_ptrs[i] = NULL; - } - entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ -} - -#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jcprepct.c b/freeimage241/Source/LibJPEG/jcprepct.c deleted file mode 100644 index fa93333..0000000 --- a/freeimage241/Source/LibJPEG/jcprepct.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * jcprepct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the compression preprocessing controller. - * This controller manages the color conversion, downsampling, - * and edge expansion steps. - * - * Most of the complexity here is associated with buffering input rows - * as required by the downsampler. See the comments at the head of - * jcsample.c for the downsampler's needs. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* At present, jcsample.c can request context rows only for smoothing. - * In the future, we might also need context rows for CCIR601 sampling - * or other more-complex downsampling procedures. The code to support - * context rows should be compiled only if needed. - */ -#ifdef INPUT_SMOOTHING_SUPPORTED -#define CONTEXT_ROWS_SUPPORTED -#endif - - -/* - * For the simple (no-context-row) case, we just need to buffer one - * row group's worth of pixels for the downsampling step. At the bottom of - * the image, we pad to a full row group by replicating the last pixel row. - * The downsampler's last output row is then replicated if needed to pad - * out to a full iMCU row. - * - * When providing context rows, we must buffer three row groups' worth of - * pixels. Three row groups are physically allocated, but the row pointer - * arrays are made five row groups high, with the extra pointers above and - * below "wrapping around" to point to the last and first real row groups. - * This allows the downsampler to access the proper context rows. - * At the top and bottom of the image, we create dummy context rows by - * copying the first or last real pixel row. This copying could be avoided - * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the - * trouble on the compression side. - */ - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_prep_controller pub; /* public fields */ - - /* Downsampling input buffer. This buffer holds color-converted data - * until we have enough to do a downsample step. - */ - JSAMPARRAY color_buf[MAX_COMPONENTS]; - - JDIMENSION rows_to_go; /* counts rows remaining in source image */ - int next_buf_row; /* index of next row to store in color_buf */ - -#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */ - int this_row_group; /* starting row index of group to process */ - int next_buf_stop; /* downsample when we reach this index */ -#endif -} my_prep_controller; - -typedef my_prep_controller * my_prep_ptr; - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - - if (pass_mode != JBUF_PASS_THRU) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - /* Initialize total-height counter for detecting bottom of image */ - prep->rows_to_go = cinfo->image_height; - /* Mark the conversion buffer empty */ - prep->next_buf_row = 0; -#ifdef CONTEXT_ROWS_SUPPORTED - /* Preset additional state variables for context mode. - * These aren't used in non-context mode, so we needn't test which mode. - */ - prep->this_row_group = 0; - /* Set next_buf_stop to stop after two row groups have been read in. */ - prep->next_buf_stop = 2 * cinfo->max_v_samp_factor; -#endif -} - - -/* - * Expand an image vertically from height input_rows to height output_rows, - * by duplicating the bottom row. - */ - -LOCAL(void) -expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, - int input_rows, int output_rows) -{ - register int row; - - for (row = input_rows; row < output_rows; row++) { - jcopy_sample_rows(image_data, input_rows-1, image_data, row, - 1, num_cols); - } -} - - -/* - * Process some data in the simple no-context case. - * - * Preprocessor output data is counted in "row groups". A row group - * is defined to be v_samp_factor sample rows of each component. - * Downsampling will produce this much data from each max_v_samp_factor - * input rows. - */ - -METHODDEF(void) -pre_process_data (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int numrows, ci; - JDIMENSION inrows; - jpeg_component_info * compptr; - - while (*in_row_ctr < in_rows_avail && - *out_row_group_ctr < out_row_groups_avail) { - /* Do color conversion to fill the conversion buffer. */ - inrows = in_rows_avail - *in_row_ctr; - numrows = cinfo->max_v_samp_factor - prep->next_buf_row; - numrows = (int) MIN((JDIMENSION) numrows, inrows); - (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, - prep->color_buf, - (JDIMENSION) prep->next_buf_row, - numrows); - *in_row_ctr += numrows; - prep->next_buf_row += numrows; - prep->rows_to_go -= numrows; - /* If at bottom of image, pad to fill the conversion buffer. */ - if (prep->rows_to_go == 0 && - prep->next_buf_row < cinfo->max_v_samp_factor) { - for (ci = 0; ci < cinfo->num_components; ci++) { - expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, - prep->next_buf_row, cinfo->max_v_samp_factor); - } - prep->next_buf_row = cinfo->max_v_samp_factor; - } - /* If we've filled the conversion buffer, empty it. */ - if (prep->next_buf_row == cinfo->max_v_samp_factor) { - (*cinfo->downsample->downsample) (cinfo, - prep->color_buf, (JDIMENSION) 0, - output_buf, *out_row_group_ctr); - prep->next_buf_row = 0; - (*out_row_group_ctr)++; - } - /* If at bottom of image, pad the output to a full iMCU height. - * Note we assume the caller is providing a one-iMCU-height output buffer! - */ - if (prep->rows_to_go == 0 && - *out_row_group_ctr < out_row_groups_avail) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - expand_bottom_edge(output_buf[ci], - compptr->width_in_blocks * DCTSIZE, - (int) (*out_row_group_ctr * compptr->v_samp_factor), - (int) (out_row_groups_avail * compptr->v_samp_factor)); - } - *out_row_group_ctr = out_row_groups_avail; - break; /* can exit outer loop without test */ - } - } -} - - -#ifdef CONTEXT_ROWS_SUPPORTED - -/* - * Process some data in the context case. - */ - -METHODDEF(void) -pre_process_context (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int numrows, ci; - int buf_height = cinfo->max_v_samp_factor * 3; - JDIMENSION inrows; - - while (*out_row_group_ctr < out_row_groups_avail) { - if (*in_row_ctr < in_rows_avail) { - /* Do color conversion to fill the conversion buffer. */ - inrows = in_rows_avail - *in_row_ctr; - numrows = prep->next_buf_stop - prep->next_buf_row; - numrows = (int) MIN((JDIMENSION) numrows, inrows); - (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, - prep->color_buf, - (JDIMENSION) prep->next_buf_row, - numrows); - /* Pad at top of image, if first time through */ - if (prep->rows_to_go == cinfo->image_height) { - for (ci = 0; ci < cinfo->num_components; ci++) { - int row; - for (row = 1; row <= cinfo->max_v_samp_factor; row++) { - jcopy_sample_rows(prep->color_buf[ci], 0, - prep->color_buf[ci], -row, - 1, cinfo->image_width); - } - } - } - *in_row_ctr += numrows; - prep->next_buf_row += numrows; - prep->rows_to_go -= numrows; - } else { - /* Return for more data, unless we are at the bottom of the image. */ - if (prep->rows_to_go != 0) - break; - /* When at bottom of image, pad to fill the conversion buffer. */ - if (prep->next_buf_row < prep->next_buf_stop) { - for (ci = 0; ci < cinfo->num_components; ci++) { - expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, - prep->next_buf_row, prep->next_buf_stop); - } - prep->next_buf_row = prep->next_buf_stop; - } - } - /* If we've gotten enough data, downsample a row group. */ - if (prep->next_buf_row == prep->next_buf_stop) { - (*cinfo->downsample->downsample) (cinfo, - prep->color_buf, - (JDIMENSION) prep->this_row_group, - output_buf, *out_row_group_ctr); - (*out_row_group_ctr)++; - /* Advance pointers with wraparound as necessary. */ - prep->this_row_group += cinfo->max_v_samp_factor; - if (prep->this_row_group >= buf_height) - prep->this_row_group = 0; - if (prep->next_buf_row >= buf_height) - prep->next_buf_row = 0; - prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor; - } - } -} - - -/* - * Create the wrapped-around downsampling input buffer needed for context mode. - */ - -LOCAL(void) -create_context_buffer (j_compress_ptr cinfo) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int rgroup_height = cinfo->max_v_samp_factor; - int ci, i; - jpeg_component_info * compptr; - JSAMPARRAY true_buffer, fake_buffer; - - /* Grab enough space for fake row pointers for all the components; - * we need five row groups' worth of pointers for each component. - */ - fake_buffer = (JSAMPARRAY) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (cinfo->num_components * 5 * rgroup_height) * - SIZEOF(JSAMPROW)); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Allocate the actual buffer space (3 row groups) for this component. - * We make the buffer wide enough to allow the downsampler to edge-expand - * horizontally within the buffer, if it so chooses. - */ - true_buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * - cinfo->max_h_samp_factor) / compptr->h_samp_factor), - (JDIMENSION) (3 * rgroup_height)); - /* Copy true buffer row pointers into the middle of the fake row array */ - MEMCOPY(fake_buffer + rgroup_height, true_buffer, - 3 * rgroup_height * SIZEOF(JSAMPROW)); - /* Fill in the above and below wraparound pointers */ - for (i = 0; i < rgroup_height; i++) { - fake_buffer[i] = true_buffer[2 * rgroup_height + i]; - fake_buffer[4 * rgroup_height + i] = true_buffer[i]; - } - prep->color_buf[ci] = fake_buffer + rgroup_height; - fake_buffer += 5 * rgroup_height; /* point to space for next component */ - } -} - -#endif /* CONTEXT_ROWS_SUPPORTED */ - - -/* - * Initialize preprocessing controller. - */ - -GLOBAL(void) -jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_prep_ptr prep; - int ci; - jpeg_component_info * compptr; - - if (need_full_buffer) /* safety check */ - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - prep = (my_prep_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_prep_controller)); - cinfo->prep = (struct jpeg_c_prep_controller *) prep; - prep->pub.start_pass = start_pass_prep; - - /* Allocate the color conversion buffer. - * We make the buffer wide enough to allow the downsampler to edge-expand - * horizontally within the buffer, if it so chooses. - */ - if (cinfo->downsample->need_context_rows) { - /* Set up to provide context rows */ -#ifdef CONTEXT_ROWS_SUPPORTED - prep->pub.pre_process_data = pre_process_context; - create_context_buffer(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - /* No context, just make it tall enough for one row group */ - prep->pub.pre_process_data = pre_process_data; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - prep->color_buf[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * - cinfo->max_h_samp_factor) / compptr->h_samp_factor), - (JDIMENSION) cinfo->max_v_samp_factor); - } - } -} diff --git a/freeimage241/Source/LibJPEG/jcsample.c b/freeimage241/Source/LibJPEG/jcsample.c deleted file mode 100644 index 212ec87..0000000 --- a/freeimage241/Source/LibJPEG/jcsample.c +++ /dev/null @@ -1,519 +0,0 @@ -/* - * jcsample.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains downsampling routines. - * - * Downsampling input data is counted in "row groups". A row group - * is defined to be max_v_samp_factor pixel rows of each component, - * from which the downsampler produces v_samp_factor sample rows. - * A single row group is processed in each call to the downsampler module. - * - * The downsampler is responsible for edge-expansion of its output data - * to fill an integral number of DCT blocks horizontally. The source buffer - * may be modified if it is helpful for this purpose (the source buffer is - * allocated wide enough to correspond to the desired output width). - * The caller (the prep controller) is responsible for vertical padding. - * - * The downsampler may request "context rows" by setting need_context_rows - * during startup. In this case, the input arrays will contain at least - * one row group's worth of pixels above and below the passed-in data; - * the caller will create dummy rows at image top and bottom by replicating - * the first or last real pixel row. - * - * An excellent reference for image resampling is - * Digital Image Warping, George Wolberg, 1990. - * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. - * - * The downsampling algorithm used here is a simple average of the source - * pixels covered by the output pixel. The hi-falutin sampling literature - * refers to this as a "box filter". In general the characteristics of a box - * filter are not very good, but for the specific cases we normally use (1:1 - * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not - * nearly so bad. If you intend to use other sampling ratios, you'd be well - * advised to improve this code. - * - * A simple input-smoothing capability is provided. This is mainly intended - * for cleaning up color-dithered GIF input files (if you find it inadequate, - * we suggest using an external filtering program such as pnmconvol). When - * enabled, each input pixel P is replaced by a weighted sum of itself and its - * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, - * where SF = (smoothing_factor / 1024). - * Currently, smoothing is only supported for 2h2v sampling factors. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Pointer to routine to downsample a single component */ -typedef JMETHOD(void, downsample1_ptr, - (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data)); - -/* Private subobject */ - -typedef struct { - struct jpeg_downsampler pub; /* public fields */ - - /* Downsampling method pointers, one per component */ - downsample1_ptr methods[MAX_COMPONENTS]; -} my_downsampler; - -typedef my_downsampler * my_downsample_ptr; - - -/* - * Initialize for a downsampling pass. - */ - -METHODDEF(void) -start_pass_downsample (j_compress_ptr cinfo) -{ - /* no work for now */ -} - - -/* - * Expand a component horizontally from width input_cols to width output_cols, - * by duplicating the rightmost samples. - */ - -LOCAL(void) -expand_right_edge (JSAMPARRAY image_data, int num_rows, - JDIMENSION input_cols, JDIMENSION output_cols) -{ - register JSAMPROW ptr; - register JSAMPLE pixval; - register int count; - int row; - int numcols = (int) (output_cols - input_cols); - - if (numcols > 0) { - for (row = 0; row < num_rows; row++) { - ptr = image_data[row] + input_cols; - pixval = ptr[-1]; /* don't need GETJSAMPLE() here */ - for (count = numcols; count > 0; count--) - *ptr++ = pixval; - } - } -} - - -/* - * Do downsampling for a whole row group (all components). - * - * In this version we simply downsample each component independently. - */ - -METHODDEF(void) -sep_downsample (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, JDIMENSION out_row_group_index) -{ - my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample; - int ci; - jpeg_component_info * compptr; - JSAMPARRAY in_ptr, out_ptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - in_ptr = input_buf[ci] + in_row_index; - out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor); - (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr); - } -} - - -/* - * Downsample pixel values of a single component. - * One row group is processed per call. - * This version handles arbitrary integral sampling ratios, without smoothing. - * Note that this version is not actually used for customary sampling ratios. - */ - -METHODDEF(void) -int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v; - JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */ - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - JSAMPROW inptr, outptr; - INT32 outvalue; - - h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor; - v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor; - numpix = h_expand * v_expand; - numpix2 = numpix/2; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * h_expand); - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - for (outcol = 0, outcol_h = 0; outcol < output_cols; - outcol++, outcol_h += h_expand) { - outvalue = 0; - for (v = 0; v < v_expand; v++) { - inptr = input_data[inrow+v] + outcol_h; - for (h = 0; h < h_expand; h++) { - outvalue += (INT32) GETJSAMPLE(*inptr++); - } - } - *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); - } - inrow += v_expand; - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the special case of a full-size component, - * without smoothing. - */ - -METHODDEF(void) -fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - /* Copy the data */ - jcopy_sample_rows(input_data, 0, output_data, 0, - cinfo->max_v_samp_factor, cinfo->image_width); - /* Edge-expand */ - expand_right_edge(output_data, cinfo->max_v_samp_factor, - cinfo->image_width, compptr->width_in_blocks * DCTSIZE); -} - - -/* - * Downsample pixel values of a single component. - * This version handles the common case of 2:1 horizontal and 1:1 vertical, - * without smoothing. - * - * A note about the "bias" calculations: when rounding fractional values to - * integer, we do not want to always round 0.5 up to the next integer. - * If we did that, we'd introduce a noticeable bias towards larger values. - * Instead, this code is arranged so that 0.5 will be rounded up or down at - * alternate pixel locations (a simple ordered dither pattern). - */ - -METHODDEF(void) -h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int outrow; - JDIMENSION outcol; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr, outptr; - register int bias; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * 2); - - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr = input_data[outrow]; - bias = 0; /* bias = 0,1,0,1,... for successive samples */ - for (outcol = 0; outcol < output_cols; outcol++) { - *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) - + bias) >> 1); - bias ^= 1; /* 0=>1, 1=>0 */ - inptr += 2; - } - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the standard case of 2:1 horizontal and 2:1 vertical, - * without smoothing. - */ - -METHODDEF(void) -h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow; - JDIMENSION outcol; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr0, inptr1, outptr; - register int bias; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * 2); - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr0 = input_data[inrow]; - inptr1 = input_data[inrow+1]; - bias = 1; /* bias = 1,2,1,2,... for successive samples */ - for (outcol = 0; outcol < output_cols; outcol++) { - *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) - + bias) >> 2); - bias ^= 3; /* 1=>2, 2=>1 */ - inptr0 += 2; inptr1 += 2; - } - inrow += 2; - } -} - - -#ifdef INPUT_SMOOTHING_SUPPORTED - -/* - * Downsample pixel values of a single component. - * This version handles the standard case of 2:1 horizontal and 2:1 vertical, - * with smoothing. One row of context is required. - */ - -METHODDEF(void) -h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow; - JDIMENSION colctr; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr; - INT32 membersum, neighsum, memberscale, neighscale; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, - cinfo->image_width, output_cols * 2); - - /* We don't bother to form the individual "smoothed" input pixel values; - * we can directly compute the output which is the average of the four - * smoothed values. Each of the four member pixels contributes a fraction - * (1-8*SF) to its own smoothed image and a fraction SF to each of the three - * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final - * output. The four corner-adjacent neighbor pixels contribute a fraction - * SF to just one smoothed pixel, or SF/4 to the final output; while the - * eight edge-adjacent neighbors contribute SF to each of two smoothed - * pixels, or SF/2 overall. In order to use integer arithmetic, these - * factors are scaled by 2^16 = 65536. - * Also recall that SF = smoothing_factor / 1024. - */ - - memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */ - neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */ - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr0 = input_data[inrow]; - inptr1 = input_data[inrow+1]; - above_ptr = input_data[inrow-1]; - below_ptr = input_data[inrow+2]; - - /* Special case for first column: pretend column -1 is same as column 0 */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]); - neighsum += neighsum; - neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]); - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; - - for (colctr = output_cols - 2; colctr > 0; colctr--) { - /* sum of pixels directly mapped to this output element */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - /* sum of edge-neighbor pixels */ - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) + - GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]); - /* The edge-neighbors count twice as much as corner-neighbors */ - neighsum += neighsum; - /* Add in the corner-neighbors */ - neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) + - GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]); - /* form final output scaled up by 2^16 */ - membersum = membersum * memberscale + neighsum * neighscale; - /* round, descale and output it */ - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; - } - - /* Special case for last column */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]); - neighsum += neighsum; - neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]); - membersum = membersum * memberscale + neighsum * neighscale; - *outptr = (JSAMPLE) ((membersum + 32768) >> 16); - - inrow += 2; - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the special case of a full-size component, - * with smoothing. One row of context is required. - */ - -METHODDEF(void) -fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int outrow; - JDIMENSION colctr; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr, above_ptr, below_ptr, outptr; - INT32 membersum, neighsum, memberscale, neighscale; - int colsum, lastcolsum, nextcolsum; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, - cinfo->image_width, output_cols); - - /* Each of the eight neighbor pixels contributes a fraction SF to the - * smoothed pixel, while the main pixel contributes (1-8*SF). In order - * to use integer arithmetic, these factors are multiplied by 2^16 = 65536. - * Also recall that SF = smoothing_factor / 1024. - */ - - memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */ - neighscale = cinfo->smoothing_factor * 64; /* scaled SF */ - - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr = input_data[outrow]; - above_ptr = input_data[outrow-1]; - below_ptr = input_data[outrow+1]; - - /* Special case for first column */ - colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) + - GETJSAMPLE(*inptr); - membersum = GETJSAMPLE(*inptr++); - nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + - GETJSAMPLE(*inptr); - neighsum = colsum + (colsum - membersum) + nextcolsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - lastcolsum = colsum; colsum = nextcolsum; - - for (colctr = output_cols - 2; colctr > 0; colctr--) { - membersum = GETJSAMPLE(*inptr++); - above_ptr++; below_ptr++; - nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + - GETJSAMPLE(*inptr); - neighsum = lastcolsum + (colsum - membersum) + nextcolsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - lastcolsum = colsum; colsum = nextcolsum; - } - - /* Special case for last column */ - membersum = GETJSAMPLE(*inptr); - neighsum = lastcolsum + (colsum - membersum) + colsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr = (JSAMPLE) ((membersum + 32768) >> 16); - - } -} - -#endif /* INPUT_SMOOTHING_SUPPORTED */ - - -/* - * Module initialization routine for downsampling. - * Note that we must select a routine for each component. - */ - -GLOBAL(void) -jinit_downsampler (j_compress_ptr cinfo) -{ - my_downsample_ptr downsample; - int ci; - jpeg_component_info * compptr; - boolean smoothok = TRUE; - - downsample = (my_downsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_downsampler)); - cinfo->downsample = (struct jpeg_downsampler *) downsample; - downsample->pub.start_pass = start_pass_downsample; - downsample->pub.downsample = sep_downsample; - downsample->pub.need_context_rows = FALSE; - - if (cinfo->CCIR601_sampling) - ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); - - /* Verify we can handle the sampling factors, and set up method pointers */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor == cinfo->max_h_samp_factor && - compptr->v_samp_factor == cinfo->max_v_samp_factor) { -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor) { - downsample->methods[ci] = fullsize_smooth_downsample; - downsample->pub.need_context_rows = TRUE; - } else -#endif - downsample->methods[ci] = fullsize_downsample; - } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && - compptr->v_samp_factor == cinfo->max_v_samp_factor) { - smoothok = FALSE; - downsample->methods[ci] = h2v1_downsample; - } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && - compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) { -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor) { - downsample->methods[ci] = h2v2_smooth_downsample; - downsample->pub.need_context_rows = TRUE; - } else -#endif - downsample->methods[ci] = h2v2_downsample; - } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && - (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { - smoothok = FALSE; - downsample->methods[ci] = int_downsample; - } else - ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); - } - -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor && !smoothok) - TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL); -#endif -} diff --git a/freeimage241/Source/LibJPEG/jctrans.c b/freeimage241/Source/LibJPEG/jctrans.c deleted file mode 100644 index 0e6d707..0000000 --- a/freeimage241/Source/LibJPEG/jctrans.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * jctrans.c - * - * Copyright (C) 1995-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains library routines for transcoding compression, - * that is, writing raw DCT coefficient arrays to an output JPEG file. - * The routines in jcapimin.c will also be needed by a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(void) transencode_master_selection - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); -LOCAL(void) transencode_coef_controller - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); - - -/* - * Compression initialization for writing raw-coefficient data. - * Before calling this, all parameters and a data destination must be set up. - * Call jpeg_finish_compress() to actually write the data. - * - * The number of passed virtual arrays must match cinfo->num_components. - * Note that the virtual arrays need not be filled or even realized at - * the time write_coefficients is called; indeed, if the virtual arrays - * were requested from this compression object's memory manager, they - * typically will be realized during this routine and filled afterwards. - */ - -GLOBAL(void) -jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Mark all tables to be written */ - jpeg_suppress_tables(cinfo, FALSE); - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Perform master selection of active modules */ - transencode_master_selection(cinfo, coef_arrays); - /* Wait for jpeg_finish_compress() call */ - cinfo->next_scanline = 0; /* so jpeg_write_marker works */ - cinfo->global_state = CSTATE_WRCOEFS; -} - - -/* - * Initialize the compression object with default parameters, - * then copy from the source object all parameters needed for lossless - * transcoding. Parameters that can be varied without loss (such as - * scan script and Huffman optimization) are left in their default states. - */ - -GLOBAL(void) -jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo) -{ - JQUANT_TBL ** qtblptr; - jpeg_component_info *incomp, *outcomp; - JQUANT_TBL *c_quant, *slot_quant; - int tblno, ci, coefi; - - /* Safety check to ensure start_compress not called yet. */ - if (dstinfo->global_state != CSTATE_START) - ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); - /* Copy fundamental image dimensions */ - dstinfo->image_width = srcinfo->image_width; - dstinfo->image_height = srcinfo->image_height; - dstinfo->input_components = srcinfo->num_components; - dstinfo->in_color_space = srcinfo->jpeg_color_space; - /* Initialize all parameters to default values */ - jpeg_set_defaults(dstinfo); - /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. - * Fix it to get the right header markers for the image colorspace. - */ - jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); - dstinfo->data_precision = srcinfo->data_precision; - dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; - /* Copy the source's quantization tables. */ - for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { - if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { - qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; - if (*qtblptr == NULL) - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); - MEMCOPY((*qtblptr)->quantval, - srcinfo->quant_tbl_ptrs[tblno]->quantval, - SIZEOF((*qtblptr)->quantval)); - (*qtblptr)->sent_table = FALSE; - } - } - /* Copy the source's per-component info. - * Note we assume jpeg_set_defaults has allocated the dest comp_info array. - */ - dstinfo->num_components = srcinfo->num_components; - if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) - ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, - MAX_COMPONENTS); - for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; - ci < dstinfo->num_components; ci++, incomp++, outcomp++) { - outcomp->component_id = incomp->component_id; - outcomp->h_samp_factor = incomp->h_samp_factor; - outcomp->v_samp_factor = incomp->v_samp_factor; - outcomp->quant_tbl_no = incomp->quant_tbl_no; - /* Make sure saved quantization table for component matches the qtable - * slot. If not, the input file re-used this qtable slot. - * IJG encoder currently cannot duplicate this. - */ - tblno = outcomp->quant_tbl_no; - if (tblno < 0 || tblno >= NUM_QUANT_TBLS || - srcinfo->quant_tbl_ptrs[tblno] == NULL) - ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno); - slot_quant = srcinfo->quant_tbl_ptrs[tblno]; - c_quant = incomp->quant_table; - if (c_quant != NULL) { - for (coefi = 0; coefi < DCTSIZE2; coefi++) { - if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) - ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); - } - } - /* Note: we do not copy the source's Huffman table assignments; - * instead we rely on jpeg_set_colorspace to have made a suitable choice. - */ - } - /* Also copy JFIF version and resolution information, if available. - * Strictly speaking this isn't "critical" info, but it's nearly - * always appropriate to copy it if available. In particular, - * if the application chooses to copy JFIF 1.02 extension markers from - * the source file, we need to copy the version to make sure we don't - * emit a file that has 1.02 extensions but a claimed version of 1.01. - * We will *not*, however, copy version info from mislabeled "2.01" files. - */ - if (srcinfo->saw_JFIF_marker) { - if (srcinfo->JFIF_major_version == 1) { - dstinfo->JFIF_major_version = srcinfo->JFIF_major_version; - dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version; - } - dstinfo->density_unit = srcinfo->density_unit; - dstinfo->X_density = srcinfo->X_density; - dstinfo->Y_density = srcinfo->Y_density; - } -} - - -/* - * Master selection of compression modules for transcoding. - * This substitutes for jcinit.c's initialization of the full compressor. - */ - -LOCAL(void) -transencode_master_selection (j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays) -{ - /* Although we don't actually use input_components for transcoding, - * jcmaster.c's initial_setup will complain if input_components is 0. - */ - cinfo->input_components = 1; - /* Initialize master control (includes parameter checking/processing) */ - jinit_c_master_control(cinfo, TRUE /* transcode only */); - - /* Entropy encoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - jinit_phuff_encoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_encoder(cinfo); - } - - /* We need a special coefficient buffer controller. */ - transencode_coef_controller(cinfo, coef_arrays); - - jinit_marker_writer(cinfo); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Write the datastream header (SOI, JFIF) immediately. - * Frame and scan headers are postponed till later. - * This lets application insert special markers after the SOI. - */ - (*cinfo->marker->write_file_header) (cinfo); -} - - -/* - * The rest of this file is a special implementation of the coefficient - * buffer controller. This is similar to jccoefct.c, but it handles only - * output from presupplied virtual arrays. Furthermore, we generate any - * dummy padding blocks on-the-fly rather than expecting them to be present - * in the arrays. - */ - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_coef_controller pub; /* public fields */ - - JDIMENSION iMCU_row_num; /* iMCU row # within image */ - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* Virtual block array for each component. */ - jvirt_barray_ptr * whole_image; - - /* Workspace for constructing dummy blocks at right/bottom edges. */ - JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - - -LOCAL(void) -start_iMCU_row (j_compress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->mcu_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - if (pass_mode != JBUF_CRANK_DEST) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - coef->iMCU_row_num = 0; - start_iMCU_row(cinfo); -} - - -/* - * Process some data. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the scan. - * The data is obtained from the virtual arrays and fed to the entropy coder. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf is ignored; it is likely to be a NULL pointer. - */ - -METHODDEF(boolean) -compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, ci, xindex, yindex, yoffset, blockcnt; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (coef->iMCU_row_num < last_iMCU_row || - yindex+yoffset < compptr->last_row_height) { - /* Fill in pointers to real blocks in this row */ - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < blockcnt; xindex++) - MCU_buffer[blkn++] = buffer_ptr++; - } else { - /* At bottom of image, need a whole row of dummy blocks */ - xindex = 0; - } - /* Fill in any dummy blocks needed in this row. - * Dummy blocks are filled in the same way as in jccoefct.c: - * all zeroes in the AC entries, DC entries equal to previous - * block's DC value. The init routine has already zeroed the - * AC entries, so we need only set the DC entries correctly. - */ - for (; xindex < compptr->MCU_width; xindex++) { - MCU_buffer[blkn] = coef->dummy_buffer[blkn]; - MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; - blkn++; - } - } - } - /* Try to write the MCU. */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - - -/* - * Initialize coefficient buffer controller. - * - * Each passed coefficient array must be the right size for that - * coefficient: width_in_blocks wide and height_in_blocks high, - * with unitheight at least v_samp_factor. - */ - -LOCAL(void) -transencode_coef_controller (j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays) -{ - my_coef_ptr coef; - JBLOCKROW buffer; - int i; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_c_coef_controller *) coef; - coef->pub.start_pass = start_pass_coef; - coef->pub.compress_data = compress_output; - - /* Save pointer to virtual arrays */ - coef->whole_image = coef_arrays; - - /* Allocate and pre-zero space for dummy DCT blocks. */ - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { - coef->dummy_buffer[i] = buffer + i; - } -} diff --git a/freeimage241/Source/LibJPEG/jdapimin.c b/freeimage241/Source/LibJPEG/jdapimin.c deleted file mode 100644 index cadb59f..0000000 --- a/freeimage241/Source/LibJPEG/jdapimin.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - * jdapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the decompression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-decompression case or the - * transcoding-only case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jdapistd.c. But also see jcomapi.c for routines - * shared by compression and decompression, and jdtrans.c for the transcoding - * case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Initialization of a JPEG decompression object. - * The error manager must already be set up (in case memory manager fails). - */ - -GLOBAL(void) -jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize) -{ - int i; - - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_decompress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = TRUE; - - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); - - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->src = NULL; - - for (i = 0; i < NUM_QUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } - - /* Initialize marker processor so application can override methods - * for COM, APPn markers before calling jpeg_read_header. - */ - cinfo->marker_list = NULL; - jinit_marker_reader(cinfo); - - /* And initialize the overall input controller. */ - jinit_input_controller(cinfo); - - /* OK, I'm ready */ - cinfo->global_state = DSTATE_START; -} - - -/* - * Destruction of a JPEG decompression object - */ - -GLOBAL(void) -jpeg_destroy_decompress (j_decompress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Abort processing of a JPEG decompression operation, - * but don't destroy the object itself. - */ - -GLOBAL(void) -jpeg_abort_decompress (j_decompress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Set default decompression parameters. - */ - -LOCAL(void) -default_decompress_parms (j_decompress_ptr cinfo) -{ - /* Guess the input colorspace, and set output colorspace accordingly. */ - /* (Wish JPEG committee had provided a real way to specify this...) */ - /* Note application may override our guesses. */ - switch (cinfo->num_components) { - case 1: - cinfo->jpeg_color_space = JCS_GRAYSCALE; - cinfo->out_color_space = JCS_GRAYSCALE; - break; - - case 3: - if (cinfo->saw_JFIF_marker) { - cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */ - } else if (cinfo->saw_Adobe_marker) { - switch (cinfo->Adobe_transform) { - case 0: - cinfo->jpeg_color_space = JCS_RGB; - break; - case 1: - cinfo->jpeg_color_space = JCS_YCbCr; - break; - default: - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ - break; - } - } else { - /* Saw no special markers, try to guess from the component IDs */ - int cid0 = cinfo->comp_info[0].component_id; - int cid1 = cinfo->comp_info[1].component_id; - int cid2 = cinfo->comp_info[2].component_id; - - if (cid0 == 1 && cid1 == 2 && cid2 == 3) - cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */ - else if (cid0 == 82 && cid1 == 71 && cid2 == 66) - cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */ - else { - TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2); - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ - } - } - /* Always guess RGB is proper output colorspace. */ - cinfo->out_color_space = JCS_RGB; - break; - - case 4: - if (cinfo->saw_Adobe_marker) { - switch (cinfo->Adobe_transform) { - case 0: - cinfo->jpeg_color_space = JCS_CMYK; - break; - case 2: - cinfo->jpeg_color_space = JCS_YCCK; - break; - default: - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); - cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */ - break; - } - } else { - /* No special markers, assume straight CMYK. */ - cinfo->jpeg_color_space = JCS_CMYK; - } - cinfo->out_color_space = JCS_CMYK; - break; - - default: - cinfo->jpeg_color_space = JCS_UNKNOWN; - cinfo->out_color_space = JCS_UNKNOWN; - break; - } - - /* Set defaults for other decompression parameters. */ - cinfo->scale_num = 1; /* 1:1 scaling */ - cinfo->scale_denom = 1; - cinfo->output_gamma = 1.0; - cinfo->buffered_image = FALSE; - cinfo->raw_data_out = FALSE; - cinfo->dct_method = JDCT_DEFAULT; - cinfo->do_fancy_upsampling = TRUE; - cinfo->do_block_smoothing = TRUE; - cinfo->quantize_colors = FALSE; - /* We set these in case application only sets quantize_colors. */ - cinfo->dither_mode = JDITHER_FS; -#ifdef QUANT_2PASS_SUPPORTED - cinfo->two_pass_quantize = TRUE; -#else - cinfo->two_pass_quantize = FALSE; -#endif - cinfo->desired_number_of_colors = 256; - cinfo->colormap = NULL; - /* Initialize for no mode change in buffered-image mode. */ - cinfo->enable_1pass_quant = FALSE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; -} - - -/* - * Decompression startup: read start of JPEG datastream to see what's there. - * Need only initialize JPEG object and supply a data source before calling. - * - * This routine will read as far as the first SOS marker (ie, actual start of - * compressed data), and will save all tables and parameters in the JPEG - * object. It will also initialize the decompression parameters to default - * values, and finally return JPEG_HEADER_OK. On return, the application may - * adjust the decompression parameters and then call jpeg_start_decompress. - * (Or, if the application only wanted to determine the image parameters, - * the data need not be decompressed. In that case, call jpeg_abort or - * jpeg_destroy to release any temporary space.) - * If an abbreviated (tables only) datastream is presented, the routine will - * return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then - * re-use the JPEG object to read the abbreviated image datastream(s). - * It is unnecessary (but OK) to call jpeg_abort in this case. - * The JPEG_SUSPENDED return code only occurs if the data source module - * requests suspension of the decompressor. In this case the application - * should load more source data and then re-call jpeg_read_header to resume - * processing. - * If a non-suspending data source is used and require_image is TRUE, then the - * return code need not be inspected since only JPEG_HEADER_OK is possible. - * - * This routine is now just a front end to jpeg_consume_input, with some - * extra error checking. - */ - -GLOBAL(int) -jpeg_read_header (j_decompress_ptr cinfo, boolean require_image) -{ - int retcode; - - if (cinfo->global_state != DSTATE_START && - cinfo->global_state != DSTATE_INHEADER) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - retcode = jpeg_consume_input(cinfo); - - switch (retcode) { - case JPEG_REACHED_SOS: - retcode = JPEG_HEADER_OK; - break; - case JPEG_REACHED_EOI: - if (require_image) /* Complain if application wanted an image */ - ERREXIT(cinfo, JERR_NO_IMAGE); - /* Reset to start state; it would be safer to require the application to - * call jpeg_abort, but we can't change it now for compatibility reasons. - * A side effect is to free any temporary memory (there shouldn't be any). - */ - jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */ - retcode = JPEG_HEADER_TABLES_ONLY; - break; - case JPEG_SUSPENDED: - /* no work */ - break; - } - - return retcode; -} - - -/* - * Consume data in advance of what the decompressor requires. - * This can be called at any time once the decompressor object has - * been created and a data source has been set up. - * - * This routine is essentially a state machine that handles a couple - * of critical state-transition actions, namely initial setup and - * transition from header scanning to ready-for-start_decompress. - * All the actual input is done via the input controller's consume_input - * method. - */ - -GLOBAL(int) -jpeg_consume_input (j_decompress_ptr cinfo) -{ - int retcode = JPEG_SUSPENDED; - - /* NB: every possible DSTATE value should be listed in this switch */ - switch (cinfo->global_state) { - case DSTATE_START: - /* Start-of-datastream actions: reset appropriate modules */ - (*cinfo->inputctl->reset_input_controller) (cinfo); - /* Initialize application's data source module */ - (*cinfo->src->init_source) (cinfo); - cinfo->global_state = DSTATE_INHEADER; - /*FALLTHROUGH*/ - case DSTATE_INHEADER: - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */ - /* Set up default parameters based on header data */ - default_decompress_parms(cinfo); - /* Set global state: ready for start_decompress */ - cinfo->global_state = DSTATE_READY; - } - break; - case DSTATE_READY: - /* Can't advance past first SOS until start_decompress is called */ - retcode = JPEG_REACHED_SOS; - break; - case DSTATE_PRELOAD: - case DSTATE_PRESCAN: - case DSTATE_SCANNING: - case DSTATE_RAW_OK: - case DSTATE_BUFIMAGE: - case DSTATE_BUFPOST: - case DSTATE_STOPPING: - retcode = (*cinfo->inputctl->consume_input) (cinfo); - break; - default: - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - return retcode; -} - - -/* - * Have we finished reading the input file? - */ - -GLOBAL(boolean) -jpeg_input_complete (j_decompress_ptr cinfo) -{ - /* Check for valid jpeg object */ - if (cinfo->global_state < DSTATE_START || - cinfo->global_state > DSTATE_STOPPING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return cinfo->inputctl->eoi_reached; -} - - -/* - * Is there more than one scan? - */ - -GLOBAL(boolean) -jpeg_has_multiple_scans (j_decompress_ptr cinfo) -{ - /* Only valid after jpeg_read_header completes */ - if (cinfo->global_state < DSTATE_READY || - cinfo->global_state > DSTATE_STOPPING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return cinfo->inputctl->has_multiple_scans; -} - - -/* - * Finish JPEG decompression. - * - * This will normally just verify the file trailer and release temp storage. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_finish_decompress (j_decompress_ptr cinfo) -{ - if ((cinfo->global_state == DSTATE_SCANNING || - cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) { - /* Terminate final pass of non-buffered mode */ - if (cinfo->output_scanline < cinfo->output_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_output_pass) (cinfo); - cinfo->global_state = DSTATE_STOPPING; - } else if (cinfo->global_state == DSTATE_BUFIMAGE) { - /* Finishing after a buffered-image operation */ - cinfo->global_state = DSTATE_STOPPING; - } else if (cinfo->global_state != DSTATE_STOPPING) { - /* STOPPING = repeat call after a suspension, anything else is error */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - /* Read until EOI */ - while (! cinfo->inputctl->eoi_reached) { - if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) - return FALSE; /* Suspend, come back later */ - } - /* Do final cleanup */ - (*cinfo->src->term_source) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); - return TRUE; -} diff --git a/freeimage241/Source/LibJPEG/jdapistd.c b/freeimage241/Source/LibJPEG/jdapistd.c deleted file mode 100644 index c8e3fa0..0000000 --- a/freeimage241/Source/LibJPEG/jdapistd.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * jdapistd.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the decompression half - * of the JPEG library. These are the "standard" API routines that are - * used in the normal full-decompression case. They are not used by a - * transcoding-only application. Note that if an application links in - * jpeg_start_decompress, it will end up linking in the entire decompressor. - * We thus must separate this file from jdapimin.c to avoid linking the - * whole decompression library into a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); - - -/* - * Decompression initialization. - * jpeg_read_header must be completed before calling this. - * - * If a multipass operating mode was selected, this will do all but the - * last pass, and thus may take a great deal of time. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_start_decompress (j_decompress_ptr cinfo) -{ - if (cinfo->global_state == DSTATE_READY) { - /* First call: initialize master control, select active modules */ - jinit_master_decompress(cinfo); - if (cinfo->buffered_image) { - /* No more work here; expecting jpeg_start_output next */ - cinfo->global_state = DSTATE_BUFIMAGE; - return TRUE; - } - cinfo->global_state = DSTATE_PRELOAD; - } - if (cinfo->global_state == DSTATE_PRELOAD) { - /* If file has multiple scans, absorb them all into the coef buffer */ - if (cinfo->inputctl->has_multiple_scans) { -#ifdef D_MULTISCAN_FILES_SUPPORTED - for (;;) { - int retcode; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - /* Absorb some more input */ - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_SUSPENDED) - return FALSE; - if (retcode == JPEG_REACHED_EOI) - break; - /* Advance progress counter if appropriate */ - if (cinfo->progress != NULL && - (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { - if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { - /* jdmaster underestimated number of scans; ratchet up one scan */ - cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; - } - } - } -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - } - cinfo->output_scan_number = cinfo->input_scan_number; - } else if (cinfo->global_state != DSTATE_PRESCAN) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any dummy output passes, and set up for the final pass */ - return output_pass_setup(cinfo); -} - - -/* - * Set up for an output pass, and perform any dummy pass(es) needed. - * Common subroutine for jpeg_start_decompress and jpeg_start_output. - * Entry: global_state = DSTATE_PRESCAN only if previously suspended. - * Exit: If done, returns TRUE and sets global_state for proper output mode. - * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. - */ - -LOCAL(boolean) -output_pass_setup (j_decompress_ptr cinfo) -{ - if (cinfo->global_state != DSTATE_PRESCAN) { - /* First call: do pass setup */ - (*cinfo->master->prepare_for_output_pass) (cinfo); - cinfo->output_scanline = 0; - cinfo->global_state = DSTATE_PRESCAN; - } - /* Loop over any required dummy passes */ - while (cinfo->master->is_dummy_pass) { -#ifdef QUANT_2PASS_SUPPORTED - /* Crank through the dummy pass */ - while (cinfo->output_scanline < cinfo->output_height) { - JDIMENSION last_scanline; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* Process some data */ - last_scanline = cinfo->output_scanline; - (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, - &cinfo->output_scanline, (JDIMENSION) 0); - if (cinfo->output_scanline == last_scanline) - return FALSE; /* No progress made, must suspend */ - } - /* Finish up dummy pass, and set up for another one */ - (*cinfo->master->finish_output_pass) (cinfo); - (*cinfo->master->prepare_for_output_pass) (cinfo); - cinfo->output_scanline = 0; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* QUANT_2PASS_SUPPORTED */ - } - /* Ready for application to drive output pass through - * jpeg_read_scanlines or jpeg_read_raw_data. - */ - cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; - return TRUE; -} - - -/* - * Read some scanlines of data from the JPEG decompressor. - * - * The return value will be the number of lines actually read. - * This may be less than the number requested in several cases, - * including bottom of image, data source suspension, and operating - * modes that emit multiple scanlines at a time. - * - * Note: we warn about excess calls to jpeg_read_scanlines() since - * this likely signals an application programmer error. However, - * an oversize buffer (max_lines > scanlines remaining) is not an error. - */ - -GLOBAL(JDIMENSION) -jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, - JDIMENSION max_lines) -{ - JDIMENSION row_ctr; - - if (cinfo->global_state != DSTATE_SCANNING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->output_scanline >= cinfo->output_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Process some data */ - row_ctr = 0; - (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); - cinfo->output_scanline += row_ctr; - return row_ctr; -} - - -/* - * Alternate entry point to read raw data. - * Processes exactly one iMCU row per call, unless suspended. - */ - -GLOBAL(JDIMENSION) -jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, - JDIMENSION max_lines) -{ - JDIMENSION lines_per_iMCU_row; - - if (cinfo->global_state != DSTATE_RAW_OK) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->output_scanline >= cinfo->output_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Verify that at least one iMCU row can be returned. */ - lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size; - if (max_lines < lines_per_iMCU_row) - ERREXIT(cinfo, JERR_BUFFER_SIZE); - - /* Decompress directly into user's buffer. */ - if (! (*cinfo->coef->decompress_data) (cinfo, data)) - return 0; /* suspension forced, can do nothing more */ - - /* OK, we processed one iMCU row. */ - cinfo->output_scanline += lines_per_iMCU_row; - return lines_per_iMCU_row; -} - - -/* Additional entry points for buffered-image mode. */ - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Initialize for an output pass in buffered-image mode. - */ - -GLOBAL(boolean) -jpeg_start_output (j_decompress_ptr cinfo, int scan_number) -{ - if (cinfo->global_state != DSTATE_BUFIMAGE && - cinfo->global_state != DSTATE_PRESCAN) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Limit scan number to valid range */ - if (scan_number <= 0) - scan_number = 1; - if (cinfo->inputctl->eoi_reached && - scan_number > cinfo->input_scan_number) - scan_number = cinfo->input_scan_number; - cinfo->output_scan_number = scan_number; - /* Perform any dummy output passes, and set up for the real pass */ - return output_pass_setup(cinfo); -} - - -/* - * Finish up after an output pass in buffered-image mode. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_finish_output (j_decompress_ptr cinfo) -{ - if ((cinfo->global_state == DSTATE_SCANNING || - cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { - /* Terminate this pass. */ - /* We do not require the whole pass to have been completed. */ - (*cinfo->master->finish_output_pass) (cinfo); - cinfo->global_state = DSTATE_BUFPOST; - } else if (cinfo->global_state != DSTATE_BUFPOST) { - /* BUFPOST = repeat call after a suspension, anything else is error */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - /* Read markers looking for SOS or EOI */ - while (cinfo->input_scan_number <= cinfo->output_scan_number && - ! cinfo->inputctl->eoi_reached) { - if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) - return FALSE; /* Suspend, come back later */ - } - cinfo->global_state = DSTATE_BUFIMAGE; - return TRUE; -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jdatadst.c b/freeimage241/Source/LibJPEG/jdatadst.c deleted file mode 100644 index a8f6fb0..0000000 --- a/freeimage241/Source/LibJPEG/jdatadst.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * jdatadst.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains compression data destination routines for the case of - * emitting JPEG data to a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * destination manager. - * IMPORTANT: we assume that fwrite() will correctly transcribe an array of - * JOCTETs into 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" - - -/* Expanded data destination object for stdio output */ - -typedef struct { - struct jpeg_destination_mgr pub; /* public fields */ - - FILE * outfile; /* target stream */ - JOCTET * buffer; /* start of buffer */ -} my_destination_mgr; - -typedef my_destination_mgr * my_dest_ptr; - -#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ - - -/* - * Initialize destination --- called by jpeg_start_compress - * before any data is actually written. - */ - -METHODDEF(void) -init_destination (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - /* Allocate the output buffer --- it will be released when done with image */ - dest->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; -} - - -/* - * Empty the output buffer --- called whenever buffer fills up. - * - * In typical applications, this should write the entire output buffer - * (ignoring the current state of next_output_byte & free_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been dumped. - * - * In applications that need to be able to suspend compression due to output - * overrun, a FALSE return indicates that the buffer cannot be emptied now. - * In this situation, the compressor will return to its caller (possibly with - * an indication that it has not accepted all the supplied scanlines). The - * application should resume compression after it has made more room in the - * output buffer. Note that there are substantial restrictions on the use of - * suspension --- see the documentation. - * - * When suspending, the compressor will back up to a convenient restart point - * (typically the start of the current MCU). next_output_byte & free_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point will be regenerated after resumption, so do not - * write it out when emptying the buffer externally. - */ - -METHODDEF(boolean) -empty_output_buffer (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) != - (size_t) OUTPUT_BUF_SIZE) - ERREXIT(cinfo, JERR_FILE_WRITE); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; - - return TRUE; -} - - -/* - * Terminate destination --- called by jpeg_finish_compress - * after all data has been written. Usually needs to flush buffer. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_destination (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; - - /* Write any data remaining in the buffer */ - if (datacount > 0) { - if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount) - ERREXIT(cinfo, JERR_FILE_WRITE); - } - fflush(dest->outfile); - /* Make sure we wrote the output file OK */ - if (ferror(dest->outfile)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * Prepare for output to a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing compression. - */ - -GLOBAL(void) -jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile) -{ - my_dest_ptr dest; - - /* The destination object is made permanent so that multiple JPEG images - * can be written to the same file without re-executing jpeg_stdio_dest. - * This makes it dangerous to use this manager and a different destination - * manager serially with the same JPEG object, because their private object - * sizes may be different. Caveat programmer. - */ - if (cinfo->dest == NULL) { /* first time for this JPEG object? */ - cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_destination_mgr)); - } - - dest = (my_dest_ptr) cinfo->dest; - dest->pub.init_destination = init_destination; - dest->pub.empty_output_buffer = empty_output_buffer; - dest->pub.term_destination = term_destination; - dest->outfile = outfile; -} diff --git a/freeimage241/Source/LibJPEG/jdatasrc.c b/freeimage241/Source/LibJPEG/jdatasrc.c deleted file mode 100644 index 9a41b90..0000000 --- a/freeimage241/Source/LibJPEG/jdatasrc.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * jdatasrc.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains decompression data source routines for the case of - * reading JPEG data from a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * source manager. - * IMPORTANT: we assume that fread() will correctly transcribe an array of - * JOCTETs from 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ - -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" - - -/* Expanded data source object for stdio input */ - -typedef struct { - struct jpeg_source_mgr pub; /* public fields */ - - FILE *infile; /* source stream */ - JOCTET * buffer; /* start of buffer */ - boolean start_of_file; /* have we gotten any data yet? */ -} my_source_mgr; - -typedef my_source_mgr * my_src_ptr; - -#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ - - -/* - * Initialize source --- called by jpeg_read_header - * before any data is actually read. - */ - -METHODDEF(void) -init_source (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - /* We reset the empty-input-file flag for each image, - * but we don't clear the input buffer. - * This is correct behavior for reading a series of images from one source. - */ - src->start_of_file = TRUE; -} - - -/* - * Fill the input buffer --- called whenever buffer is emptied. - * - * In typical applications, this should read fresh data into the buffer - * (ignoring the current state of next_input_byte & bytes_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been reloaded. It is not necessary to - * fill the buffer entirely, only to obtain at least one more byte. - * - * There is no such thing as an EOF return. If the end of the file has been - * reached, the routine has a choice of ERREXIT() or inserting fake data into - * the buffer. In most cases, generating a warning message and inserting a - * fake EOI marker is the best course of action --- this will allow the - * decompressor to output however much of the image is there. However, - * the resulting error message is misleading if the real problem is an empty - * input file, so we handle that case specially. - * - * In applications that need to be able to suspend compression due to input - * not being available yet, a FALSE return indicates that no more data can be - * obtained right now, but more may be forthcoming later. In this situation, - * the decompressor will return to its caller (with an indication of the - * number of scanlines it has read, if any). The application should resume - * decompression after it has loaded more data into the input buffer. Note - * that there are substantial restrictions on the use of suspension --- see - * the documentation. - * - * When suspending, the decompressor will back up to a convenient restart point - * (typically the start of the current MCU). next_input_byte & bytes_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point must be rescanned after resumption, so move it to - * the front of the buffer rather than discarding it. - */ - -METHODDEF(boolean) -fill_input_buffer (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - size_t nbytes; - - nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE); - - if (nbytes <= 0) { - if (src->start_of_file) /* Treat empty input file as fatal error */ - ERREXIT(cinfo, JERR_INPUT_EMPTY); - WARNMS(cinfo, JWRN_JPEG_EOF); - /* Insert a fake EOI marker */ - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; - nbytes = 2; - } - - src->pub.next_input_byte = src->buffer; - src->pub.bytes_in_buffer = nbytes; - src->start_of_file = FALSE; - - return TRUE; -} - - -/* - * Skip data --- used to skip over a potentially large amount of - * uninteresting data (such as an APPn marker). - * - * Writers of suspendable-input applications must note that skip_input_data - * is not granted the right to give a suspension return. If the skip extends - * beyond the data currently in the buffer, the buffer can be marked empty so - * that the next read will cause a fill_input_buffer call that can suspend. - * Arranging for additional bytes to be discarded before reloading the input - * buffer is the application writer's problem. - */ - -METHODDEF(void) -skip_input_data (j_decompress_ptr cinfo, long num_bytes) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - /* Just a dumb implementation for now. Could use fseek() except - * it doesn't work on pipes. Not clear that being smart is worth - * any trouble anyway --- large skips are infrequent. - */ - if (num_bytes > 0) { - while (num_bytes > (long) src->pub.bytes_in_buffer) { - num_bytes -= (long) src->pub.bytes_in_buffer; - (void) fill_input_buffer(cinfo); - /* note we assume that fill_input_buffer will never return FALSE, - * so suspension need not be handled. - */ - } - src->pub.next_input_byte += (size_t) num_bytes; - src->pub.bytes_in_buffer -= (size_t) num_bytes; - } -} - - -/* - * An additional method that can be provided by data source modules is the - * resync_to_restart method for error recovery in the presence of RST markers. - * For the moment, this source module just uses the default resync method - * provided by the JPEG library. That method assumes that no backtracking - * is possible. - */ - - -/* - * Terminate source --- called by jpeg_finish_decompress - * after all data has been read. Often a no-op. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_source (j_decompress_ptr cinfo) -{ - /* no work necessary here */ -} - - -/* - * Prepare for input from a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing decompression. - */ - -GLOBAL(void) -jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) -{ - my_src_ptr src; - - /* The source object and input buffer are made permanent so that a series - * of JPEG images can be read from the same file by calling jpeg_stdio_src - * only before the first one. (If we discarded the buffer at the end of - * one image, we'd likely lose the start of the next one.) - * This makes it unsafe to use this manager and a different source - * manager serially with the same JPEG object. Caveat programmer. - */ - if (cinfo->src == NULL) { /* first time for this JPEG object? */ - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_source_mgr)); - src = (my_src_ptr) cinfo->src; - src->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - INPUT_BUF_SIZE * SIZEOF(JOCTET)); - } - - src = (my_src_ptr) cinfo->src; - src->pub.init_source = init_source; - src->pub.fill_input_buffer = fill_input_buffer; - src->pub.skip_input_data = skip_input_data; - src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ - src->pub.term_source = term_source; - src->infile = infile; - src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->pub.next_input_byte = NULL; /* until buffer loaded */ -} diff --git a/freeimage241/Source/LibJPEG/jdcoefct.c b/freeimage241/Source/LibJPEG/jdcoefct.c deleted file mode 100644 index 4938d20..0000000 --- a/freeimage241/Source/LibJPEG/jdcoefct.c +++ /dev/null @@ -1,736 +0,0 @@ -/* - * jdcoefct.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the coefficient buffer controller for decompression. - * This controller is the top level of the JPEG decompressor proper. - * The coefficient buffer lies between entropy decoding and inverse-DCT steps. - * - * In buffered-image mode, this controller is the interface between - * input-oriented processing and output-oriented processing. - * Also, the input side (only) is used when reading a file for transcoding. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -/* Block smoothing is only applicable for progressive JPEG, so: */ -#ifndef D_PROGRESSIVE_SUPPORTED -#undef BLOCK_SMOOTHING_SUPPORTED -#endif - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_coef_controller pub; /* public fields */ - - /* These variables keep track of the current location of the input side. */ - /* cinfo->input_iMCU_row is also used for this. */ - JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* The output side's location is represented by cinfo->output_iMCU_row. */ - - /* In single-pass modes, it's sufficient to buffer just one MCU. - * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, - * and let the entropy decoder write into that workspace each time. - * (On 80x86, the workspace is FAR even though it's not really very big; - * this is to keep the module interfaces unchanged when a large coefficient - * buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays; it is used only by the input side. - */ - JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; - -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* In multi-pass modes, we need a virtual block array for each component. */ - jvirt_barray_ptr whole_image[MAX_COMPONENTS]; -#endif - -#ifdef BLOCK_SMOOTHING_SUPPORTED - /* When doing block smoothing, we latch coefficient Al values here */ - int * coef_bits_latch; -#define SAVED_COEFS 6 /* we save coef_bits[0..5] */ -#endif -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - -/* Forward declarations */ -METHODDEF(int) decompress_onepass - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#ifdef D_MULTISCAN_FILES_SUPPORTED -METHODDEF(int) decompress_data - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#endif -#ifdef BLOCK_SMOOTHING_SUPPORTED -LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); -METHODDEF(int) decompress_smooth_data - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#endif - - -LOCAL(void) -start_iMCU_row (j_decompress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row (input side) */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->MCU_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for an input processing pass. - */ - -METHODDEF(void) -start_input_pass (j_decompress_ptr cinfo) -{ - cinfo->input_iMCU_row = 0; - start_iMCU_row(cinfo); -} - - -/* - * Initialize for an output processing pass. - */ - -METHODDEF(void) -start_output_pass (j_decompress_ptr cinfo) -{ -#ifdef BLOCK_SMOOTHING_SUPPORTED - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* If multipass, check to see whether to use block smoothing on this pass */ - if (coef->pub.coef_arrays != NULL) { - if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) - coef->pub.decompress_data = decompress_smooth_data; - else - coef->pub.decompress_data = decompress_data; - } -#endif - cinfo->output_iMCU_row = 0; -} - - -/* - * Decompress and return some data in the single-pass case. - * Always attempts to emit one fully interleaved MCU row ("iMCU" row). - * Input and output must run in lockstep since we have only a one-MCU buffer. - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - * - * NB: output_buf contains a plane for each component in image, - * which we index according to the component's SOF position. - */ - -METHODDEF(int) -decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, ci, xindex, yindex, yoffset, useful_width; - JSAMPARRAY output_ptr; - JDIMENSION start_col, output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - - /* Loop to process as much as one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; - MCU_col_num++) { - /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ - jzero_far((void FAR *) coef->MCU_buffer[0], - (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); - if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->MCU_ctr = MCU_col_num; - return JPEG_SUSPENDED; - } - /* Determine where data should go in output_buf and do the IDCT thing. - * We skip dummy blocks at the right and bottom edges (but blkn gets - * incremented past them!). Note the inner loop relies on having - * allocated the MCU_buffer[] blocks sequentially. - */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) { - blkn += compptr->MCU_blocks; - continue; - } - inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; - useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - output_ptr = output_buf[compptr->component_index] + - yoffset * compptr->DCT_scaled_size; - start_col = MCU_col_num * compptr->MCU_sample_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (cinfo->input_iMCU_row < last_iMCU_row || - yoffset+yindex < compptr->last_row_height) { - output_col = start_col; - for (xindex = 0; xindex < useful_width; xindex++) { - (*inverse_DCT) (cinfo, compptr, - (JCOEFPTR) coef->MCU_buffer[blkn+xindex], - output_ptr, output_col); - output_col += compptr->DCT_scaled_size; - } - } - blkn += compptr->MCU_width; - output_ptr += compptr->DCT_scaled_size; - } - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->MCU_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - cinfo->output_iMCU_row++; - if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { - start_iMCU_row(cinfo); - return JPEG_ROW_COMPLETED; - } - /* Completed the scan */ - (*cinfo->inputctl->finish_input_pass) (cinfo); - return JPEG_SCAN_COMPLETED; -} - - -/* - * Dummy consume-input routine for single-pass operation. - */ - -METHODDEF(int) -dummy_consume_data (j_decompress_ptr cinfo) -{ - return JPEG_SUSPENDED; /* Always indicate nothing was done */ -} - - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Consume input data and store it in the full-image coefficient buffer. - * We read as much as one fully interleaved MCU row ("iMCU" row) per call, - * ie, v_samp_factor block rows for each component in the scan. - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - */ - -METHODDEF(int) -consume_data (j_decompress_ptr cinfo) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - int blkn, ci, xindex, yindex, yoffset; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - cinfo->input_iMCU_row * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, TRUE); - /* Note: entropy decoder expects buffer to be zeroed, - * but this is handled automatically by the memory manager - * because we requested a pre-zeroed array. - */ - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < compptr->MCU_width; xindex++) { - coef->MCU_buffer[blkn++] = buffer_ptr++; - } - } - } - /* Try to fetch the MCU. */ - if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->MCU_ctr = MCU_col_num; - return JPEG_SUSPENDED; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->MCU_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { - start_iMCU_row(cinfo); - return JPEG_ROW_COMPLETED; - } - /* Completed the scan */ - (*cinfo->inputctl->finish_input_pass) (cinfo); - return JPEG_SCAN_COMPLETED; -} - - -/* - * Decompress and return some data in the multi-pass case. - * Always attempts to emit one fully interleaved MCU row ("iMCU" row). - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - * - * NB: output_buf contains a plane for each component in image. - */ - -METHODDEF(int) -decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION block_num; - int ci, block_row, block_rows; - JBLOCKARRAY buffer; - JBLOCKROW buffer_ptr; - JSAMPARRAY output_ptr; - JDIMENSION output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - - /* Force some input to be done if we are getting ahead of the input. */ - while (cinfo->input_scan_number < cinfo->output_scan_number || - (cinfo->input_scan_number == cinfo->output_scan_number && - cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { - if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) - return JPEG_SUSPENDED; - } - - /* OK, output from the virtual arrays. */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) - continue; - /* Align the virtual buffer for this component. */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - cinfo->output_iMCU_row * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - /* Count non-dummy DCT block rows in this iMCU row. */ - if (cinfo->output_iMCU_row < last_iMCU_row) - block_rows = compptr->v_samp_factor; - else { - /* NB: can't use last_row_height here; it is input-side-dependent! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - } - inverse_DCT = cinfo->idct->inverse_DCT[ci]; - output_ptr = output_buf[ci]; - /* Loop over all DCT blocks to be processed. */ - for (block_row = 0; block_row < block_rows; block_row++) { - buffer_ptr = buffer[block_row]; - output_col = 0; - for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) { - (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, - output_ptr, output_col); - buffer_ptr++; - output_col += compptr->DCT_scaled_size; - } - output_ptr += compptr->DCT_scaled_size; - } - } - - if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) - return JPEG_ROW_COMPLETED; - return JPEG_SCAN_COMPLETED; -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - - -#ifdef BLOCK_SMOOTHING_SUPPORTED - -/* - * This code applies interblock smoothing as described by section K.8 - * of the JPEG standard: the first 5 AC coefficients are estimated from - * the DC values of a DCT block and its 8 neighboring blocks. - * We apply smoothing only for progressive JPEG decoding, and only if - * the coefficients it can estimate are not yet known to full precision. - */ - -/* Natural-order array positions of the first 5 zigzag-order coefficients */ -#define Q01_POS 1 -#define Q10_POS 8 -#define Q20_POS 16 -#define Q11_POS 9 -#define Q02_POS 2 - -/* - * Determine whether block smoothing is applicable and safe. - * We also latch the current states of the coef_bits[] entries for the - * AC coefficients; otherwise, if the input side of the decompressor - * advances into a new scan, we might think the coefficients are known - * more accurately than they really are. - */ - -LOCAL(boolean) -smoothing_ok (j_decompress_ptr cinfo) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - boolean smoothing_useful = FALSE; - int ci, coefi; - jpeg_component_info *compptr; - JQUANT_TBL * qtable; - int * coef_bits; - int * coef_bits_latch; - - if (! cinfo->progressive_mode || cinfo->coef_bits == NULL) - return FALSE; - - /* Allocate latch area if not already done */ - if (coef->coef_bits_latch == NULL) - coef->coef_bits_latch = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * - (SAVED_COEFS * SIZEOF(int))); - coef_bits_latch = coef->coef_bits_latch; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* All components' quantization values must already be latched. */ - if ((qtable = compptr->quant_table) == NULL) - return FALSE; - /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */ - if (qtable->quantval[0] == 0 || - qtable->quantval[Q01_POS] == 0 || - qtable->quantval[Q10_POS] == 0 || - qtable->quantval[Q20_POS] == 0 || - qtable->quantval[Q11_POS] == 0 || - qtable->quantval[Q02_POS] == 0) - return FALSE; - /* DC values must be at least partly known for all components. */ - coef_bits = cinfo->coef_bits[ci]; - if (coef_bits[0] < 0) - return FALSE; - /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ - for (coefi = 1; coefi <= 5; coefi++) { - coef_bits_latch[coefi] = coef_bits[coefi]; - if (coef_bits[coefi] != 0) - smoothing_useful = TRUE; - } - coef_bits_latch += SAVED_COEFS; - } - - return smoothing_useful; -} - - -/* - * Variant of decompress_data for use when doing block smoothing. - */ - -METHODDEF(int) -decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION block_num, last_block_column; - int ci, block_row, block_rows, access_rows; - JBLOCKARRAY buffer; - JBLOCKROW buffer_ptr, prev_block_row, next_block_row; - JSAMPARRAY output_ptr; - JDIMENSION output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - boolean first_row, last_row; - JBLOCK workspace; - int *coef_bits; - JQUANT_TBL *quanttbl; - INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; - int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; - int Al, pred; - - /* Force some input to be done if we are getting ahead of the input. */ - while (cinfo->input_scan_number <= cinfo->output_scan_number && - ! cinfo->inputctl->eoi_reached) { - if (cinfo->input_scan_number == cinfo->output_scan_number) { - /* If input is working on current scan, we ordinarily want it to - * have completed the current row. But if input scan is DC, - * we want it to keep one row ahead so that next block row's DC - * values are up to date. - */ - JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0; - if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta) - break; - } - if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) - return JPEG_SUSPENDED; - } - - /* OK, output from the virtual arrays. */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) - continue; - /* Count non-dummy DCT block rows in this iMCU row. */ - if (cinfo->output_iMCU_row < last_iMCU_row) { - block_rows = compptr->v_samp_factor; - access_rows = block_rows * 2; /* this and next iMCU row */ - last_row = FALSE; - } else { - /* NB: can't use last_row_height here; it is input-side-dependent! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - access_rows = block_rows; /* this iMCU row only */ - last_row = TRUE; - } - /* Align the virtual buffer for this component. */ - if (cinfo->output_iMCU_row > 0) { - access_rows += compptr->v_samp_factor; /* prior iMCU row too */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, - (JDIMENSION) access_rows, FALSE); - buffer += compptr->v_samp_factor; /* point to current iMCU row */ - first_row = FALSE; - } else { - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE); - first_row = TRUE; - } - /* Fetch component-dependent info */ - coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); - quanttbl = compptr->quant_table; - Q00 = quanttbl->quantval[0]; - Q01 = quanttbl->quantval[Q01_POS]; - Q10 = quanttbl->quantval[Q10_POS]; - Q20 = quanttbl->quantval[Q20_POS]; - Q11 = quanttbl->quantval[Q11_POS]; - Q02 = quanttbl->quantval[Q02_POS]; - inverse_DCT = cinfo->idct->inverse_DCT[ci]; - output_ptr = output_buf[ci]; - /* Loop over all DCT blocks to be processed. */ - for (block_row = 0; block_row < block_rows; block_row++) { - buffer_ptr = buffer[block_row]; - if (first_row && block_row == 0) - prev_block_row = buffer_ptr; - else - prev_block_row = buffer[block_row-1]; - if (last_row && block_row == block_rows-1) - next_block_row = buffer_ptr; - else - next_block_row = buffer[block_row+1]; - /* We fetch the surrounding DC values using a sliding-register approach. - * Initialize all nine here so as to do the right thing on narrow pics. - */ - DC1 = DC2 = DC3 = (int) prev_block_row[0][0]; - DC4 = DC5 = DC6 = (int) buffer_ptr[0][0]; - DC7 = DC8 = DC9 = (int) next_block_row[0][0]; - output_col = 0; - last_block_column = compptr->width_in_blocks - 1; - for (block_num = 0; block_num <= last_block_column; block_num++) { - /* Fetch current DCT block into workspace so we can modify it. */ - jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1); - /* Update DC values */ - if (block_num < last_block_column) { - DC3 = (int) prev_block_row[1][0]; - DC6 = (int) buffer_ptr[1][0]; - DC9 = (int) next_block_row[1][0]; - } - /* Compute coefficient estimates per K.8. - * An estimate is applied only if coefficient is still zero, - * and is not known to be fully accurate. - */ - /* AC01 */ - if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { - num = 36 * Q00 * (DC4 - DC6); - if (num >= 0) { - pred = (int) (((Q01<<7) + num) / (Q01<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q10<<7) + num) / (Q10<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q20<<7) + num) / (Q20<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q11<<7) + num) / (Q11<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q02<<7) + num) / (Q02<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<DCT_scaled_size; - } - output_ptr += compptr->DCT_scaled_size; - } - } - - if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) - return JPEG_ROW_COMPLETED; - return JPEG_SCAN_COMPLETED; -} - -#endif /* BLOCK_SMOOTHING_SUPPORTED */ - - -/* - * Initialize coefficient buffer controller. - */ - -GLOBAL(void) -jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_coef_ptr coef; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_d_coef_controller *) coef; - coef->pub.start_input_pass = start_input_pass; - coef->pub.start_output_pass = start_output_pass; -#ifdef BLOCK_SMOOTHING_SUPPORTED - coef->coef_bits_latch = NULL; -#endif - - /* Create the coefficient buffer. */ - if (need_full_buffer) { -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* Allocate a full-image virtual array for each component, */ - /* padded to a multiple of samp_factor DCT blocks in each direction. */ - /* Note we ask for a pre-zeroed array. */ - int ci, access_rows; - jpeg_component_info *compptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - access_rows = compptr->v_samp_factor; -#ifdef BLOCK_SMOOTHING_SUPPORTED - /* If block smoothing could be used, need a bigger window */ - if (cinfo->progressive_mode) - access_rows *= 3; -#endif - coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) access_rows); - } - coef->pub.consume_data = consume_data; - coef->pub.decompress_data = decompress_data; - coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - /* We only need a single-MCU buffer. */ - JBLOCKROW buffer; - int i; - - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { - coef->MCU_buffer[i] = buffer + i; - } - coef->pub.consume_data = dummy_consume_data; - coef->pub.decompress_data = decompress_onepass; - coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ - } -} diff --git a/freeimage241/Source/LibJPEG/jdcolor.c b/freeimage241/Source/LibJPEG/jdcolor.c deleted file mode 100644 index 6c04dfe..0000000 --- a/freeimage241/Source/LibJPEG/jdcolor.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * jdcolor.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains output colorspace conversion routines. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_deconverter pub; /* public fields */ - - /* Private state for YCC->RGB conversion */ - int * Cr_r_tab; /* => table for Cr to R conversion */ - int * Cb_b_tab; /* => table for Cb to B conversion */ - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ -} my_color_deconverter; - -typedef my_color_deconverter * my_cconvert_ptr; - - -/**************** YCbCr -> RGB conversion: most common case **************/ - -/* - * YCbCr is defined per CCIR 601-1, except that Cb and Cr are - * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. - * The conversion equations to be implemented are therefore - * R = Y + 1.40200 * Cr - * G = Y - 0.34414 * Cb - 0.71414 * Cr - * B = Y + 1.77200 * Cb - * where Cb and Cr represent the incoming values less CENTERJSAMPLE. - * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) - * - * To avoid floating-point arithmetic, we represent the fractional constants - * as integers scaled up by 2^16 (about 4 digits precision); we have to divide - * the products by 2^16, with appropriate rounding, to get the correct answer. - * Notice that Y, being an integral input, does not contribute any fraction - * so it need not participate in the rounding. - * - * For even more speed, we avoid doing any multiplications in the inner loop - * by precalculating the constants times Cb and Cr for all possible values. - * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); - * for 12-bit samples it is still acceptable. It's not very reasonable for - * 16-bit samples, but if you want lossless storage you shouldn't be changing - * colorspace anyway. - * The Cr=>R and Cb=>B values can be rounded to integers in advance; the - * values for the G calculation are left scaled up, since we must add them - * together before rounding. - */ - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. - */ - -LOCAL(void) -build_ycc_rgb_table (j_decompress_ptr cinfo) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - int i; - INT32 x; - SHIFT_TEMPS - - cconvert->Cr_r_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - cconvert->Cb_b_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - cconvert->Cr_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - cconvert->Cb_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - - for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { - /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ - /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ - /* Cr=>R value is nearest int to 1.40200 * x */ - cconvert->Cr_r_tab[i] = (int) - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); - /* Cb=>B value is nearest int to 1.77200 * x */ - cconvert->Cb_b_tab[i] = (int) - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); - /* Cr=>G value is scaled-up -0.71414 * x */ - cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; - /* Cb=>G value is scaled-up -0.34414 * x */ - /* We also add in ONE_HALF so that need not do it in inner loop */ - cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; - } -} - - -/* - * Convert some rows of samples to the output colorspace. - * - * Note that we change from noninterleaved, one-plane-per-component format - * to interleaved-pixel format. The output buffer is therefore three times - * as wide as the input buffer. - * A starting row offset is provided only for the input buffer. The caller - * can easily adjust the passed output_buf value to accommodate any row - * offset required on that side. - */ - -METHODDEF(void) -ycc_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - /* Range-limiting is essential due to noise introduced by DCT losses. */ - outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; - outptr[RGB_GREEN] = range_limit[y + - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS))]; - outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; - outptr += RGB_PIXELSIZE; - } - } -} - - -/**************** Cases other than YCbCr -> RGB **************/ - - -/* - * Color conversion for no colorspace change: just copy the data, - * converting from separate-planes to interleaved representation. - */ - -METHODDEF(void) -null_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - register JSAMPROW inptr, outptr; - register JDIMENSION count; - register int num_components = cinfo->num_components; - JDIMENSION num_cols = cinfo->output_width; - int ci; - - while (--num_rows >= 0) { - for (ci = 0; ci < num_components; ci++) { - inptr = input_buf[ci][input_row]; - outptr = output_buf[0] + ci; - for (count = num_cols; count > 0; count--) { - *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ - outptr += num_components; - } - } - input_row++; - output_buf++; - } -} - - -/* - * Color conversion for grayscale: just copy the data. - * This also works for YCbCr -> grayscale conversion, in which - * we just copy the Y (luminance) component and ignore chrominance. - */ - -METHODDEF(void) -grayscale_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, - num_rows, cinfo->output_width); -} - - -/* - * Convert grayscale to RGB: just duplicate the graylevel three times. - * This is provided to support applications that don't want to cope - * with grayscale as a separate case. - */ - -METHODDEF(void) -gray_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - register JSAMPROW inptr, outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - - while (--num_rows >= 0) { - inptr = input_buf[0][input_row++]; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - /* We can dispense with GETJSAMPLE() here */ - outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; - outptr += RGB_PIXELSIZE; - } - } -} - - -/* - * Adobe-style YCCK->CMYK conversion. - * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same - * conversion as above, while passing K (black) unchanged. - * We assume build_ycc_rgb_table has been called. - */ - -METHODDEF(void) -ycck_cmyk_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2, inptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - inptr3 = input_buf[3][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - /* Range-limiting is essential due to noise introduced by DCT losses. */ - outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ - outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS)))]; - outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ - /* K passes through unchanged */ - outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ - outptr += 4; - } - } -} - - -/* - * Empty method for start_pass. - */ - -METHODDEF(void) -start_pass_dcolor (j_decompress_ptr cinfo) -{ - /* no work needed */ -} - - -/* - * Module initialization routine for output colorspace conversion. - */ - -GLOBAL(void) -jinit_color_deconverter (j_decompress_ptr cinfo) -{ - my_cconvert_ptr cconvert; - int ci; - - cconvert = (my_cconvert_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_color_deconverter)); - cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; - cconvert->pub.start_pass = start_pass_dcolor; - - /* Make sure num_components agrees with jpeg_color_space */ - switch (cinfo->jpeg_color_space) { - case JCS_GRAYSCALE: - if (cinfo->num_components != 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - case JCS_RGB: - case JCS_YCbCr: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - case JCS_CMYK: - case JCS_YCCK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - default: /* JCS_UNKNOWN can be anything */ - if (cinfo->num_components < 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - } - - /* Set out_color_components and conversion method based on requested space. - * Also clear the component_needed flags for any unused components, - * so that earlier pipeline stages can avoid useless computation. - */ - - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - cinfo->out_color_components = 1; - if (cinfo->jpeg_color_space == JCS_GRAYSCALE || - cinfo->jpeg_color_space == JCS_YCbCr) { - cconvert->pub.color_convert = grayscale_convert; - /* For color->grayscale conversion, only the Y (0) component is needed */ - for (ci = 1; ci < cinfo->num_components; ci++) - cinfo->comp_info[ci].component_needed = FALSE; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_RGB: - cinfo->out_color_components = RGB_PIXELSIZE; - if (cinfo->jpeg_color_space == JCS_YCbCr) { - cconvert->pub.color_convert = ycc_rgb_convert; - build_ycc_rgb_table(cinfo); - } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { - cconvert->pub.color_convert = gray_rgb_convert; - } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { - cconvert->pub.color_convert = null_convert; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_CMYK: - cinfo->out_color_components = 4; - if (cinfo->jpeg_color_space == JCS_YCCK) { - cconvert->pub.color_convert = ycck_cmyk_convert; - build_ycc_rgb_table(cinfo); - } else if (cinfo->jpeg_color_space == JCS_CMYK) { - cconvert->pub.color_convert = null_convert; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - default: - /* Permit null conversion to same output space */ - if (cinfo->out_color_space == cinfo->jpeg_color_space) { - cinfo->out_color_components = cinfo->num_components; - cconvert->pub.color_convert = null_convert; - } else /* unsupported non-null conversion */ - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - } - - if (cinfo->quantize_colors) - cinfo->output_components = 1; /* single colormapped output component */ - else - cinfo->output_components = cinfo->out_color_components; -} diff --git a/freeimage241/Source/LibJPEG/jdct.h b/freeimage241/Source/LibJPEG/jdct.h deleted file mode 100644 index 04192a2..0000000 --- a/freeimage241/Source/LibJPEG/jdct.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * jdct.h - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file contains common declarations for the forward and - * inverse DCT modules. These declarations are private to the DCT managers - * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. - * The individual DCT algorithms are kept in separate files to ease - * machine-dependent tuning (e.g., assembly coding). - */ - - -/* - * A forward DCT routine is given a pointer to a work area of type DCTELEM[]; - * the DCT is to be performed in-place in that buffer. Type DCTELEM is int - * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT - * implementations use an array of type FAST_FLOAT, instead.) - * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). - * The DCT outputs are returned scaled up by a factor of 8; they therefore - * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This - * convention improves accuracy in integer implementations and saves some - * work in floating-point ones. - * Quantization of the output coefficients is done by jcdctmgr.c. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef int DCTELEM; /* 16 or 32 bits is fine */ -#else -typedef INT32 DCTELEM; /* must have 32 bits */ -#endif - -typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); -typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); - - -/* - * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer - * to an output sample array. The routine must dequantize the input data as - * well as perform the IDCT; for dequantization, it uses the multiplier table - * pointed to by compptr->dct_table. The output data is to be placed into the - * sample array starting at a specified column. (Any row offset needed will - * be applied to the array pointer before it is passed to the IDCT code.) - * Note that the number of samples emitted by the IDCT routine is - * DCT_scaled_size * DCT_scaled_size. - */ - -/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ - -/* - * Each IDCT routine has its own ideas about the best dct_table element type. - */ - -typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */ -#if BITS_IN_JSAMPLE == 8 -typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */ -#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */ -#else -typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */ -#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */ -#endif -typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ - - -/* - * Each IDCT routine is responsible for range-limiting its results and - * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could - * be quite far out of range if the input data is corrupt, so a bulletproof - * range-limiting step is required. We use a mask-and-table-lookup method - * to do the combined operations quickly. See the comments with - * prepare_range_limit_table (in jdmaster.c) for more info. - */ - -#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE) - -#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_fdct_islow jFDislow -#define jpeg_fdct_ifast jFDifast -#define jpeg_fdct_float jFDfloat -#define jpeg_idct_islow jRDislow -#define jpeg_idct_ifast jRDifast -#define jpeg_idct_float jRDfloat -#define jpeg_idct_4x4 jRD4x4 -#define jpeg_idct_2x2 jRD2x2 -#define jpeg_idct_1x1 jRD1x1 -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Extern declarations for the forward and inverse DCT routines. */ - -EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data)); - -EXTERN(void) jpeg_idct_islow - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_ifast - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_float - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_4x4 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_2x2 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_1x1 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); - - -/* - * Macros for handling fixed-point arithmetic; these are used by many - * but not all of the DCT/IDCT modules. - * - * All values are expected to be of type INT32. - * Fractional constants are scaled left by CONST_BITS bits. - * CONST_BITS is defined within each module using these macros, - * and may differ from one module to the next. - */ - -#define ONE ((INT32) 1) -#define CONST_SCALE (ONE << CONST_BITS) - -/* Convert a positive real constant to an integer scaled by CONST_SCALE. - * Caution: some C compilers fail to reduce "FIX(constant)" at compile time, - * thus causing a lot of useless floating-point operations at run time. - */ - -#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) - -/* Descale and correctly round an INT32 value that's scaled by N bits. - * We assume RIGHT_SHIFT rounds towards minus infinity, so adding - * the fudge factor is correct for either sign of X. - */ - -#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * This macro is used only when the two inputs will actually be no more than - * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a - * full 32x32 multiply. This provides a useful speedup on many machines. - * Unfortunately there is no way to specify a 16x16->32 multiply portably - * in C, but some C compilers will do the right thing if you provide the - * correct combination of casts. - */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const))) -#endif -#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const))) -#endif - -#ifndef MULTIPLY16C16 /* default definition */ -#define MULTIPLY16C16(var,const) ((var) * (const)) -#endif - -/* Same except both inputs are variables. */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2))) -#endif - -#ifndef MULTIPLY16V16 /* default definition */ -#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) -#endif diff --git a/freeimage241/Source/LibJPEG/jddctmgr.c b/freeimage241/Source/LibJPEG/jddctmgr.c deleted file mode 100644 index bbf8d0e..0000000 --- a/freeimage241/Source/LibJPEG/jddctmgr.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * jddctmgr.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the inverse-DCT management logic. - * This code selects a particular IDCT implementation to be used, - * and it performs related housekeeping chores. No code in this file - * is executed per IDCT step, only during output pass setup. - * - * Note that the IDCT routines are responsible for performing coefficient - * dequantization as well as the IDCT proper. This module sets up the - * dequantization multiplier table needed by the IDCT routine. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - - -/* - * The decompressor input side (jdinput.c) saves away the appropriate - * quantization table for each component at the start of the first scan - * involving that component. (This is necessary in order to correctly - * decode files that reuse Q-table slots.) - * When we are ready to make an output pass, the saved Q-table is converted - * to a multiplier table that will actually be used by the IDCT routine. - * The multiplier table contents are IDCT-method-dependent. To support - * application changes in IDCT method between scans, we can remake the - * multiplier tables if necessary. - * In buffered-image mode, the first output pass may occur before any data - * has been seen for some components, and thus before their Q-tables have - * been saved away. To handle this case, multiplier tables are preset - * to zeroes; the result of the IDCT will be a neutral gray level. - */ - - -/* Private subobject for this module */ - -typedef struct { - struct jpeg_inverse_dct pub; /* public fields */ - - /* This array contains the IDCT method code that each multiplier table - * is currently set up for, or -1 if it's not yet set up. - * The actual multiplier tables are pointed to by dct_table in the - * per-component comp_info structures. - */ - int cur_method[MAX_COMPONENTS]; -} my_idct_controller; - -typedef my_idct_controller * my_idct_ptr; - - -/* Allocated multiplier tables: big enough for any supported variant */ - -typedef union { - ISLOW_MULT_TYPE islow_array[DCTSIZE2]; -#ifdef DCT_IFAST_SUPPORTED - IFAST_MULT_TYPE ifast_array[DCTSIZE2]; -#endif -#ifdef DCT_FLOAT_SUPPORTED - FLOAT_MULT_TYPE float_array[DCTSIZE2]; -#endif -} multiplier_table; - - -/* The current scaled-IDCT routines require ISLOW-style multiplier tables, - * so be sure to compile that code if either ISLOW or SCALING is requested. - */ -#ifdef DCT_ISLOW_SUPPORTED -#define PROVIDE_ISLOW_TABLES -#else -#ifdef IDCT_SCALING_SUPPORTED -#define PROVIDE_ISLOW_TABLES -#endif -#endif - - -/* - * Prepare for an output pass. - * Here we select the proper IDCT routine for each component and build - * a matching multiplier table. - */ - -METHODDEF(void) -start_pass (j_decompress_ptr cinfo) -{ - my_idct_ptr idct = (my_idct_ptr) cinfo->idct; - int ci, i; - jpeg_component_info *compptr; - int method = 0; - inverse_DCT_method_ptr method_ptr = NULL; - JQUANT_TBL * qtbl; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Select the proper IDCT routine for this component's scaling */ - switch (compptr->DCT_scaled_size) { -#ifdef IDCT_SCALING_SUPPORTED - case 1: - method_ptr = jpeg_idct_1x1; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; - case 2: - method_ptr = jpeg_idct_2x2; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; - case 4: - method_ptr = jpeg_idct_4x4; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; -#endif - case DCTSIZE: - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - method_ptr = jpeg_idct_islow; - method = JDCT_ISLOW; - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - method_ptr = jpeg_idct_ifast; - method = JDCT_IFAST; - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - method_ptr = jpeg_idct_float; - method = JDCT_FLOAT; - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - break; - default: - ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); - break; - } - idct->pub.inverse_DCT[ci] = method_ptr; - /* Create multiplier table from quant table. - * However, we can skip this if the component is uninteresting - * or if we already built the table. Also, if no quant table - * has yet been saved for the component, we leave the - * multiplier table all-zero; we'll be reading zeroes from the - * coefficient controller's buffer anyway. - */ - if (! compptr->component_needed || idct->cur_method[ci] == method) - continue; - qtbl = compptr->quant_table; - if (qtbl == NULL) /* happens if no data yet for component */ - continue; - idct->cur_method[ci] = method; - switch (method) { -#ifdef PROVIDE_ISLOW_TABLES - case JDCT_ISLOW: - { - /* For LL&M IDCT method, multipliers are equal to raw quantization - * coefficients, but are stored as ints to ensure access efficiency. - */ - ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; - for (i = 0; i < DCTSIZE2; i++) { - ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; - } - } - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - { - /* For AA&N IDCT method, multipliers are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * For integer operation, the multiplier table is to be scaled by - * IFAST_SCALE_BITS. - */ - IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; -#define CONST_BITS 14 - static const INT16 aanscales[DCTSIZE2] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 - }; - SHIFT_TEMPS - - for (i = 0; i < DCTSIZE2; i++) { - ifmtbl[i] = (IFAST_MULT_TYPE) - DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], - (INT32) aanscales[i]), - CONST_BITS-IFAST_SCALE_BITS); - } - } - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - { - /* For float AA&N IDCT method, multipliers are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - */ - FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; - int row, col; - static const double aanscalefactor[DCTSIZE] = { - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - }; - - i = 0; - for (row = 0; row < DCTSIZE; row++) { - for (col = 0; col < DCTSIZE; col++) { - fmtbl[i] = (FLOAT_MULT_TYPE) - ((double) qtbl->quantval[i] * - aanscalefactor[row] * aanscalefactor[col]); - i++; - } - } - } - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - } -} - - -/* - * Initialize IDCT manager. - */ - -GLOBAL(void) -jinit_inverse_dct (j_decompress_ptr cinfo) -{ - my_idct_ptr idct; - int ci; - jpeg_component_info *compptr; - - idct = (my_idct_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_idct_controller)); - cinfo->idct = (struct jpeg_inverse_dct *) idct; - idct->pub.start_pass = start_pass; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Allocate and pre-zero a multiplier table for each component */ - compptr->dct_table = - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(multiplier_table)); - MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); - /* Mark multiplier table not yet set up for any method */ - idct->cur_method[ci] = -1; - } -} diff --git a/freeimage241/Source/LibJPEG/jdhuff.c b/freeimage241/Source/LibJPEG/jdhuff.c deleted file mode 100644 index b5ba39f..0000000 --- a/freeimage241/Source/LibJPEG/jdhuff.c +++ /dev/null @@ -1,651 +0,0 @@ -/* - * jdhuff.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy decoding routines. - * - * Much of the complexity here has to do with supporting input suspension. - * If the data source module demands suspension, we want to be able to back - * up to the start of the current MCU. To do this, we copy state variables - * into local working storage, and update them back to the permanent - * storage only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdhuff.h" /* Declarations shared with jdphuff.c */ - - -/* - * Expanded entropy decoder object for Huffman decoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_decoder pub; /* public fields */ - - /* These fields are loaded into local variables at start of each MCU. - * In case of suspension, we exit WITHOUT updating them. - */ - bitread_perm_state bitstate; /* Bit buffer at start of MCU */ - savable_state saved; /* Other state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; - d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; - - /* Precalculated info set up by start_pass for use in decode_mcu: */ - - /* Pointers to derived tables to be used for each block within an MCU */ - d_derived_tbl * dc_cur_tbls[D_MAX_BLOCKS_IN_MCU]; - d_derived_tbl * ac_cur_tbls[D_MAX_BLOCKS_IN_MCU]; - /* Whether we care about the DC and AC coefficient values for each block */ - boolean dc_needed[D_MAX_BLOCKS_IN_MCU]; - boolean ac_needed[D_MAX_BLOCKS_IN_MCU]; -} huff_entropy_decoder; - -typedef huff_entropy_decoder * huff_entropy_ptr; - - -/* - * Initialize for a Huffman-compressed scan. - */ - -METHODDEF(void) -start_pass_huff_decoder (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, blkn, dctbl, actbl; - jpeg_component_info * compptr; - - /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. - * This ought to be an error condition, but we make it a warning because - * there are some baseline files out there with all zeroes in these bytes. - */ - if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 || - cinfo->Ah != 0 || cinfo->Al != 0) - WARNMS(cinfo, JWRN_NOT_SEQUENTIAL); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - /* Compute derived values for Huffman tables */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, - & entropy->dc_derived_tbls[dctbl]); - jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, - & entropy->ac_derived_tbls[actbl]); - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Precalculate decoding info for each block in an MCU of this scan */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - /* Precalculate which table to use for each block */ - entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no]; - entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no]; - /* Decide whether we really care about the coefficient values */ - if (compptr->component_needed) { - entropy->dc_needed[blkn] = TRUE; - /* we don't need the ACs if producing a 1/8th-size image */ - entropy->ac_needed[blkn] = (compptr->DCT_scaled_size > 1); - } else { - entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE; - } - } - - /* Initialize bitread state variables */ - entropy->bitstate.bits_left = 0; - entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ - entropy->pub.insufficient_data = FALSE; - - /* Initialize restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; -} - - -/* - * Compute the derived values for a Huffman table. - * This routine also performs some validation checks on the table. - * - * Note this is also used by jdphuff.c. - */ - -GLOBAL(void) -jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno, - d_derived_tbl ** pdtbl) -{ - JHUFF_TBL *htbl; - d_derived_tbl *dtbl; - int p, i, l, si, numsymbols; - int lookbits, ctr; - char huffsize[257]; - unsigned int huffcode[257]; - unsigned int code; - - /* Note that huffsize[] and huffcode[] are filled in code-length order, - * paralleling the order of the symbols themselves in htbl->huffval[]. - */ - - /* Find the input Huffman table */ - if (tblno < 0 || tblno >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - htbl = - isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - - /* Allocate a workspace if we haven't already done so. */ - if (*pdtbl == NULL) - *pdtbl = (d_derived_tbl *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(d_derived_tbl)); - dtbl = *pdtbl; - dtbl->pub = htbl; /* fill in back link */ - - /* Figure C.1: make table of Huffman code length for each symbol */ - - p = 0; - for (l = 1; l <= 16; l++) { - i = (int) htbl->bits[l]; - if (i < 0 || p + i > 256) /* protect against table overrun */ - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - while (i--) - huffsize[p++] = (char) l; - } - huffsize[p] = 0; - numsymbols = p; - - /* Figure C.2: generate the codes themselves */ - /* We also validate that the counts represent a legal Huffman code tree. */ - - code = 0; - si = huffsize[0]; - p = 0; - while (huffsize[p]) { - while (((int) huffsize[p]) == si) { - huffcode[p++] = code; - code++; - } - /* code is now 1 more than the last code used for codelength si; but - * it must still fit in si bits, since no code is allowed to be all ones. - */ - if (((INT32) code) >= (((INT32) 1) << si)) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - code <<= 1; - si++; - } - - /* Figure F.15: generate decoding tables for bit-sequential decoding */ - - p = 0; - for (l = 1; l <= 16; l++) { - if (htbl->bits[l]) { - /* valoffset[l] = huffval[] index of 1st symbol of code length l, - * minus the minimum code of length l - */ - dtbl->valoffset[l] = (INT32) p - (INT32) huffcode[p]; - p += htbl->bits[l]; - dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */ - } else { - dtbl->maxcode[l] = -1; /* -1 if no codes of this length */ - } - } - dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */ - - /* Compute lookahead tables to speed up decoding. - * First we set all the table entries to 0, indicating "too long"; - * then we iterate through the Huffman codes that are short enough and - * fill in all the entries that correspond to bit sequences starting - * with that code. - */ - - MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits)); - - p = 0; - for (l = 1; l <= HUFF_LOOKAHEAD; l++) { - for (i = 1; i <= (int) htbl->bits[l]; i++, p++) { - /* l = current code's length, p = its index in huffcode[] & huffval[]. */ - /* Generate left-justified code followed by all possible bit sequences */ - lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l); - for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) { - dtbl->look_nbits[lookbits] = l; - dtbl->look_sym[lookbits] = htbl->huffval[p]; - lookbits++; - } - } - } - - /* Validate symbols as being reasonable. - * For AC tables, we make no check, but accept all byte values 0..255. - * For DC tables, we require the symbols to be in range 0..15. - * (Tighter bounds could be applied depending on the data depth and mode, - * but this is sufficient to ensure safe decoding.) - */ - if (isDC) { - for (i = 0; i < numsymbols; i++) { - int sym = htbl->huffval[i]; - if (sym < 0 || sym > 15) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - } - } -} - - -/* - * Out-of-line code for bit fetching (shared with jdphuff.c). - * See jdhuff.h for info about usage. - * Note: current values of get_buffer and bits_left are passed as parameters, - * but are returned in the corresponding fields of the state struct. - * - * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width - * of get_buffer to be used. (On machines with wider words, an even larger - * buffer could be used.) However, on some machines 32-bit shifts are - * quite slow and take time proportional to the number of places shifted. - * (This is true with most PC compilers, for instance.) In this case it may - * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the - * average shift distance at the cost of more calls to jpeg_fill_bit_buffer. - */ - -#ifdef SLOW_SHIFT_32 -#define MIN_GET_BITS 15 /* minimum allowable value */ -#else -#define MIN_GET_BITS (BIT_BUF_SIZE-7) -#endif - - -GLOBAL(boolean) -jpeg_fill_bit_buffer (bitread_working_state * state, - register bit_buf_type get_buffer, register int bits_left, - int nbits) -/* Load up the bit buffer to a depth of at least nbits */ -{ - /* Copy heavily used state fields into locals (hopefully registers) */ - register const JOCTET * next_input_byte = state->next_input_byte; - register size_t bytes_in_buffer = state->bytes_in_buffer; - j_decompress_ptr cinfo = state->cinfo; - - /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */ - /* (It is assumed that no request will be for more than that many bits.) */ - /* We fail to do so only if we hit a marker or are forced to suspend. */ - - if (cinfo->unread_marker == 0) { /* cannot advance past a marker */ - while (bits_left < MIN_GET_BITS) { - register int c; - - /* Attempt to read a byte */ - if (bytes_in_buffer == 0) { - if (! (*cinfo->src->fill_input_buffer) (cinfo)) - return FALSE; - next_input_byte = cinfo->src->next_input_byte; - bytes_in_buffer = cinfo->src->bytes_in_buffer; - } - bytes_in_buffer--; - c = GETJOCTET(*next_input_byte++); - - /* If it's 0xFF, check and discard stuffed zero byte */ - if (c == 0xFF) { - /* Loop here to discard any padding FF's on terminating marker, - * so that we can save a valid unread_marker value. NOTE: we will - * accept multiple FF's followed by a 0 as meaning a single FF data - * byte. This data pattern is not valid according to the standard. - */ - do { - if (bytes_in_buffer == 0) { - if (! (*cinfo->src->fill_input_buffer) (cinfo)) - return FALSE; - next_input_byte = cinfo->src->next_input_byte; - bytes_in_buffer = cinfo->src->bytes_in_buffer; - } - bytes_in_buffer--; - c = GETJOCTET(*next_input_byte++); - } while (c == 0xFF); - - if (c == 0) { - /* Found FF/00, which represents an FF data byte */ - c = 0xFF; - } else { - /* Oops, it's actually a marker indicating end of compressed data. - * Save the marker code for later use. - * Fine point: it might appear that we should save the marker into - * bitread working state, not straight into permanent state. But - * once we have hit a marker, we cannot need to suspend within the - * current MCU, because we will read no more bytes from the data - * source. So it is OK to update permanent state right away. - */ - cinfo->unread_marker = c; - /* See if we need to insert some fake zero bits. */ - goto no_more_bytes; - } - } - - /* OK, load c into get_buffer */ - get_buffer = (get_buffer << 8) | c; - bits_left += 8; - } /* end while */ - } else { - no_more_bytes: - /* We get here if we've read the marker that terminates the compressed - * data segment. There should be enough bits in the buffer register - * to satisfy the request; if so, no problem. - */ - if (nbits > bits_left) { - /* Uh-oh. Report corrupted data to user and stuff zeroes into - * the data stream, so that we can produce some kind of image. - * We use a nonvolatile flag to ensure that only one warning message - * appears per data segment. - */ - if (! cinfo->entropy->insufficient_data) { - WARNMS(cinfo, JWRN_HIT_MARKER); - cinfo->entropy->insufficient_data = TRUE; - } - /* Fill the buffer with zero bits */ - get_buffer <<= MIN_GET_BITS - bits_left; - bits_left = MIN_GET_BITS; - } - } - - /* Unload the local registers */ - state->next_input_byte = next_input_byte; - state->bytes_in_buffer = bytes_in_buffer; - state->get_buffer = get_buffer; - state->bits_left = bits_left; - - return TRUE; -} - - -/* - * Out-of-line code for Huffman code decoding. - * See jdhuff.h for info about usage. - */ - -GLOBAL(int) -jpeg_huff_decode (bitread_working_state * state, - register bit_buf_type get_buffer, register int bits_left, - d_derived_tbl * htbl, int min_bits) -{ - register int l = min_bits; - register INT32 code; - - /* HUFF_DECODE has determined that the code is at least min_bits */ - /* bits long, so fetch that many bits in one swoop. */ - - CHECK_BIT_BUFFER(*state, l, return -1); - code = GET_BITS(l); - - /* Collect the rest of the Huffman code one bit at a time. */ - /* This is per Figure F.16 in the JPEG spec. */ - - while (code > htbl->maxcode[l]) { - code <<= 1; - CHECK_BIT_BUFFER(*state, 1, return -1); - code |= GET_BITS(1); - l++; - } - - /* Unload the local registers */ - state->get_buffer = get_buffer; - state->bits_left = bits_left; - - /* With garbage input we may reach the sentinel value l = 17. */ - - if (l > 16) { - WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE); - return 0; /* fake a zero as the safest result */ - } - - return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ]; -} - - -/* - * Figure F.12: extend sign bit. - * On some machines, a shift and add will be faster than a table lookup. - */ - -#ifdef AVOID_TABLES - -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) - -#else - -#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) - -static const int extend_test[16] = /* entry n is 2**(n-1) */ - { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, - 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; - -static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ - { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, - ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, - ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, - ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; - -#endif /* AVOID_TABLES */ - - -/* - * Check for a restart marker & resynchronize decoder. - * Returns FALSE if must suspend. - */ - -LOCAL(boolean) -process_restart (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci; - - /* Throw away any unused bits remaining in bit buffer; */ - /* include any full bytes in next_marker's count of discarded bytes */ - cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; - entropy->bitstate.bits_left = 0; - - /* Advance past the RSTn marker */ - if (! (*cinfo->marker->read_restart_marker) (cinfo)) - return FALSE; - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - - /* Reset restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; - - /* Reset out-of-data flag, unless read_restart_marker left us smack up - * against a marker. In that case we will end up treating the next data - * segment as empty, and we can avoid producing bogus output pixels by - * leaving the flag set. - */ - if (cinfo->unread_marker == 0) - entropy->pub.insufficient_data = FALSE; - - return TRUE; -} - - -/* - * Decode and return one MCU's worth of Huffman-compressed coefficients. - * The coefficients are reordered from zigzag order into natural array order, - * but are not dequantized. - * - * The i'th block of the MCU is stored into the block pointed to by - * MCU_data[i]. WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER. - * (Wholesale zeroing is usually a little faster than retail...) - * - * Returns FALSE if data source requested suspension. In that case no - * changes have been made to permanent state. (Exception: some output - * coefficients may already have been assigned. This is harmless for - * this module, since we'll just re-assign them on the next call.) - */ - -METHODDEF(boolean) -decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int blkn; - BITREAD_STATE_VARS; - savable_state state; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(state, entropy->saved); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - JBLOCKROW block = MCU_data[blkn]; - d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn]; - d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn]; - register int s, k, r; - - /* Decode a single block's worth of coefficients */ - - /* Section F.2.2.1: decode the DC coefficient difference */ - HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); - if (s) { - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - } - - if (entropy->dc_needed[blkn]) { - /* Convert DC difference to actual value, update last_dc_val */ - int ci = cinfo->MCU_membership[blkn]; - s += state.last_dc_val[ci]; - state.last_dc_val[ci] = s; - /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ - (*block)[0] = (JCOEF) s; - } - - if (entropy->ac_needed[blkn]) { - - /* Section F.2.2.2: decode the AC coefficients */ - /* Since zeroes are skipped, output area must be cleared beforehand */ - for (k = 1; k < DCTSIZE2; k++) { - HUFF_DECODE(s, br_state, actbl, return FALSE, label2); - - r = s >> 4; - s &= 15; - - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - /* Output coefficient in natural (dezigzagged) order. - * Note: the extra entries in jpeg_natural_order[] will save us - * if k >= DCTSIZE2, which could happen if the data is corrupted. - */ - (*block)[jpeg_natural_order[k]] = (JCOEF) s; - } else { - if (r != 15) - break; - k += 15; - } - } - - } else { - - /* Section F.2.2.2: decode the AC coefficients */ - /* In this path we just discard the values */ - for (k = 1; k < DCTSIZE2; k++) { - HUFF_DECODE(s, br_state, actbl, return FALSE, label3); - - r = s >> 4; - s &= 15; - - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - DROP_BITS(s); - } else { - if (r != 15) - break; - k += 15; - } - } - - } - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(entropy->saved, state); - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * Module initialization routine for Huffman entropy decoding. - */ - -GLOBAL(void) -jinit_huff_decoder (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy; - int i; - - entropy = (huff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(huff_entropy_decoder)); - cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; - entropy->pub.start_pass = start_pass_huff_decoder; - entropy->pub.decode_mcu = decode_mcu; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; - } -} diff --git a/freeimage241/Source/LibJPEG/jdhuff.h b/freeimage241/Source/LibJPEG/jdhuff.h deleted file mode 100644 index ae19b6c..0000000 --- a/freeimage241/Source/LibJPEG/jdhuff.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * jdhuff.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy decoding routines - * that are shared between the sequential decoder (jdhuff.c) and the - * progressive decoder (jdphuff.c). No other modules need to see these. - */ - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_d_derived_tbl jMkDDerived -#define jpeg_fill_bit_buffer jFilBitBuf -#define jpeg_huff_decode jHufDecode -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Derived data constructed for each Huffman table */ - -#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ - -typedef struct { - /* Basic tables: (element [0] of each array is unused) */ - INT32 maxcode[18]; /* largest code of length k (-1 if none) */ - /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */ - INT32 valoffset[17]; /* huffval[] offset for codes of length k */ - /* valoffset[k] = huffval[] index of 1st symbol of code length k, less - * the smallest code of length k; so given a code of length k, the - * corresponding symbol is huffval[code + valoffset[k]] - */ - - /* Link to public Huffman table (needed only in jpeg_huff_decode) */ - JHUFF_TBL *pub; - - /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of - * the input data stream. If the next Huffman code is no more - * than HUFF_LOOKAHEAD bits long, we can obtain its length and - * the corresponding symbol directly from these tables. - */ - int look_nbits[1< 32 bits on your machine, and shifting/masking longs is - * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE - * appropriately should be a win. Unfortunately we can't define the size - * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) - * because not all machines measure sizeof in 8-bit bytes. - */ - -typedef struct { /* Bitreading state saved across MCUs */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ -} bitread_perm_state; - -typedef struct { /* Bitreading working state within an MCU */ - /* Current data source location */ - /* We need a copy, rather than munging the original, in case of suspension */ - const JOCTET * next_input_byte; /* => next byte to read from source */ - size_t bytes_in_buffer; /* # of bytes remaining in source buffer */ - /* Bit input buffer --- note these values are kept in register variables, - * not in this struct, inside the inner loops. - */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ - /* Pointer needed by jpeg_fill_bit_buffer. */ - j_decompress_ptr cinfo; /* back link to decompress master record */ -} bitread_working_state; - -/* Macros to declare and load/save bitread local variables. */ -#define BITREAD_STATE_VARS \ - register bit_buf_type get_buffer; \ - register int bits_left; \ - bitread_working_state br_state - -#define BITREAD_LOAD_STATE(cinfop,permstate) \ - br_state.cinfo = cinfop; \ - br_state.next_input_byte = cinfop->src->next_input_byte; \ - br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \ - get_buffer = permstate.get_buffer; \ - bits_left = permstate.bits_left; - -#define BITREAD_SAVE_STATE(cinfop,permstate) \ - cinfop->src->next_input_byte = br_state.next_input_byte; \ - cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \ - permstate.get_buffer = get_buffer; \ - permstate.bits_left = bits_left - -/* - * These macros provide the in-line portion of bit fetching. - * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer - * before using GET_BITS, PEEK_BITS, or DROP_BITS. - * The variables get_buffer and bits_left are assumed to be locals, - * but the state struct might not be (jpeg_huff_decode needs this). - * CHECK_BIT_BUFFER(state,n,action); - * Ensure there are N bits in get_buffer; if suspend, take action. - * val = GET_BITS(n); - * Fetch next N bits. - * val = PEEK_BITS(n); - * Fetch next N bits without removing them from the buffer. - * DROP_BITS(n); - * Discard next N bits. - * The value N should be a simple variable, not an expression, because it - * is evaluated multiple times. - */ - -#define CHECK_BIT_BUFFER(state,nbits,action) \ - { if (bits_left < (nbits)) { \ - if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \ - { action; } \ - get_buffer = (state).get_buffer; bits_left = (state).bits_left; } } - -#define GET_BITS(nbits) \ - (((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1)) - -#define PEEK_BITS(nbits) \ - (((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1)) - -#define DROP_BITS(nbits) \ - (bits_left -= (nbits)) - -/* Load up the bit buffer to a depth of at least nbits */ -EXTERN(boolean) jpeg_fill_bit_buffer - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, int nbits)); - - -/* - * Code for extracting next Huffman-coded symbol from input bit stream. - * Again, this is time-critical and we make the main paths be macros. - * - * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits - * without looping. Usually, more than 95% of the Huffman codes will be 8 - * or fewer bits long. The few overlength codes are handled with a loop, - * which need not be inline code. - * - * Notes about the HUFF_DECODE macro: - * 1. Near the end of the data segment, we may fail to get enough bits - * for a lookahead. In that case, we do it the hard way. - * 2. If the lookahead table contains no entry, the next code must be - * more than HUFF_LOOKAHEAD bits long. - * 3. jpeg_huff_decode returns -1 if forced to suspend. - */ - -#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \ -{ register int nb, look; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - nb = 1; goto slowlabel; \ - } \ - } \ - look = PEEK_BITS(HUFF_LOOKAHEAD); \ - if ((nb = htbl->look_nbits[look]) != 0) { \ - DROP_BITS(nb); \ - result = htbl->look_sym[look]; \ - } else { \ - nb = HUFF_LOOKAHEAD+1; \ -slowlabel: \ - if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ - { failaction; } \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - } \ -} - -/* Out-of-line case for Huffman code fetching */ -EXTERN(int) jpeg_huff_decode - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, d_derived_tbl * htbl, int min_bits)); diff --git a/freeimage241/Source/LibJPEG/jdinput.c b/freeimage241/Source/LibJPEG/jdinput.c deleted file mode 100644 index 0c2ac8f..0000000 --- a/freeimage241/Source/LibJPEG/jdinput.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * jdinput.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains input control logic for the JPEG decompressor. - * These routines are concerned with controlling the decompressor's input - * processing (marker reading and coefficient decoding). The actual input - * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef struct { - struct jpeg_input_controller pub; /* public fields */ - - boolean inheaders; /* TRUE until first SOS is reached */ -} my_input_controller; - -typedef my_input_controller * my_inputctl_ptr; - - -/* Forward declarations */ -METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); - - -/* - * Routines to calculate various quantities related to the size of the image. - */ - -LOCAL(void) -initial_setup (j_decompress_ptr cinfo) -/* Called once, when first SOS marker is reached */ -{ - int ci; - jpeg_component_info *compptr; - - /* Make sure image isn't bigger than I can handle */ - if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || - (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); - - /* For now, precision must match compiled-in value... */ - if (cinfo->data_precision != BITS_IN_JSAMPLE) - ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); - - /* Check that number of components won't exceed internal array sizes */ - if (cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - - /* Compute maximum sampling factors; check factor validity */ - cinfo->max_h_samp_factor = 1; - cinfo->max_v_samp_factor = 1; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || - compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) - ERREXIT(cinfo, JERR_BAD_SAMPLING); - cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, - compptr->h_samp_factor); - cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, - compptr->v_samp_factor); - } - - /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. - * In the full decompressor, this will be overridden by jdmaster.c; - * but in the transcoder, jdmaster.c is not used, so we must do it here. - */ - cinfo->min_DCT_scaled_size = DCTSIZE; - - /* Compute dimensions of components */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - compptr->DCT_scaled_size = DCTSIZE; - /* Size in DCT blocks */ - compptr->width_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->height_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - /* downsampled_width and downsampled_height will also be overridden by - * jdmaster.c if we are doing full decompression. The transcoder library - * doesn't use these values, but the calling application might. - */ - /* Size in samples */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) cinfo->max_h_samp_factor); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) cinfo->max_v_samp_factor); - /* Mark component needed, until color conversion says otherwise */ - compptr->component_needed = TRUE; - /* Mark no quantization table yet saved for component */ - compptr->quant_table = NULL; - } - - /* Compute number of fully interleaved MCU rows. */ - cinfo->total_iMCU_rows = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - /* Decide whether file contains multiple scans */ - if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode) - cinfo->inputctl->has_multiple_scans = TRUE; - else - cinfo->inputctl->has_multiple_scans = FALSE; -} - - -LOCAL(void) -per_scan_setup (j_decompress_ptr cinfo) -/* Do computations that are needed before processing a JPEG scan */ -/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ -{ - int ci, mcublks, tmp; - jpeg_component_info *compptr; - - if (cinfo->comps_in_scan == 1) { - - /* Noninterleaved (single-component) scan */ - compptr = cinfo->cur_comp_info[0]; - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = compptr->width_in_blocks; - cinfo->MCU_rows_in_scan = compptr->height_in_blocks; - - /* For noninterleaved scan, always one block per MCU */ - compptr->MCU_width = 1; - compptr->MCU_height = 1; - compptr->MCU_blocks = 1; - compptr->MCU_sample_width = compptr->DCT_scaled_size; - compptr->last_col_width = 1; - /* For noninterleaved scans, it is convenient to define last_row_height - * as the number of block rows present in the last iMCU row. - */ - tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (tmp == 0) tmp = compptr->v_samp_factor; - compptr->last_row_height = tmp; - - /* Prepare array describing MCU composition */ - cinfo->blocks_in_MCU = 1; - cinfo->MCU_membership[0] = 0; - - } else { - - /* Interleaved (multi-component) scan */ - if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, - MAX_COMPS_IN_SCAN); - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, - (long) (cinfo->max_h_samp_factor*DCTSIZE)); - cinfo->MCU_rows_in_scan = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - cinfo->blocks_in_MCU = 0; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Sampling factors give # of blocks of component in each MCU */ - compptr->MCU_width = compptr->h_samp_factor; - compptr->MCU_height = compptr->v_samp_factor; - compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; - compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size; - /* Figure number of non-dummy blocks in last MCU column & row */ - tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); - if (tmp == 0) tmp = compptr->MCU_width; - compptr->last_col_width = tmp; - tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); - if (tmp == 0) tmp = compptr->MCU_height; - compptr->last_row_height = tmp; - /* Prepare array describing MCU composition */ - mcublks = compptr->MCU_blocks; - if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU) - ERREXIT(cinfo, JERR_BAD_MCU_SIZE); - while (mcublks-- > 0) { - cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; - } - } - - } -} - - -/* - * Save away a copy of the Q-table referenced by each component present - * in the current scan, unless already saved during a prior scan. - * - * In a multiple-scan JPEG file, the encoder could assign different components - * the same Q-table slot number, but change table definitions between scans - * so that each component uses a different Q-table. (The IJG encoder is not - * currently capable of doing this, but other encoders might.) Since we want - * to be able to dequantize all the components at the end of the file, this - * means that we have to save away the table actually used for each component. - * We do this by copying the table at the start of the first scan containing - * the component. - * The JPEG spec prohibits the encoder from changing the contents of a Q-table - * slot between scans of a component using that slot. If the encoder does so - * anyway, this decoder will simply use the Q-table values that were current - * at the start of the first scan for the component. - * - * The decompressor output side looks only at the saved quant tables, - * not at the current Q-table slots. - */ - -LOCAL(void) -latch_quant_tables (j_decompress_ptr cinfo) -{ - int ci, qtblno; - jpeg_component_info *compptr; - JQUANT_TBL * qtbl; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* No work if we already saved Q-table for this component */ - if (compptr->quant_table != NULL) - continue; - /* Make sure specified quantization table is present */ - qtblno = compptr->quant_tbl_no; - if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || - cinfo->quant_tbl_ptrs[qtblno] == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); - /* OK, save away the quantization table */ - qtbl = (JQUANT_TBL *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(JQUANT_TBL)); - MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL)); - compptr->quant_table = qtbl; - } -} - - -/* - * Initialize the input modules to read a scan of compressed data. - * The first call to this is done by jdmaster.c after initializing - * the entire decompressor (during jpeg_start_decompress). - * Subsequent calls come from consume_markers, below. - */ - -METHODDEF(void) -start_input_pass (j_decompress_ptr cinfo) -{ - per_scan_setup(cinfo); - latch_quant_tables(cinfo); - (*cinfo->entropy->start_pass) (cinfo); - (*cinfo->coef->start_input_pass) (cinfo); - cinfo->inputctl->consume_input = cinfo->coef->consume_data; -} - - -/* - * Finish up after inputting a compressed-data scan. - * This is called by the coefficient controller after it's read all - * the expected data of the scan. - */ - -METHODDEF(void) -finish_input_pass (j_decompress_ptr cinfo) -{ - cinfo->inputctl->consume_input = consume_markers; -} - - -/* - * Read JPEG markers before, between, or after compressed-data scans. - * Change state as necessary when a new scan is reached. - * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - * - * The consume_input method pointer points either here or to the - * coefficient controller's consume_data routine, depending on whether - * we are reading a compressed data segment or inter-segment markers. - */ - -METHODDEF(int) -consume_markers (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; - int val; - - if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */ - return JPEG_REACHED_EOI; - - val = (*cinfo->marker->read_markers) (cinfo); - - switch (val) { - case JPEG_REACHED_SOS: /* Found SOS */ - if (inputctl->inheaders) { /* 1st SOS */ - initial_setup(cinfo); - inputctl->inheaders = FALSE; - /* Note: start_input_pass must be called by jdmaster.c - * before any more input can be consumed. jdapimin.c is - * responsible for enforcing this sequencing. - */ - } else { /* 2nd or later SOS marker */ - if (! inputctl->pub.has_multiple_scans) - ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ - start_input_pass(cinfo); - } - break; - case JPEG_REACHED_EOI: /* Found EOI */ - inputctl->pub.eoi_reached = TRUE; - if (inputctl->inheaders) { /* Tables-only datastream, apparently */ - if (cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOF_NO_SOS); - } else { - /* Prevent infinite loop in coef ctlr's decompress_data routine - * if user set output_scan_number larger than number of scans. - */ - if (cinfo->output_scan_number > cinfo->input_scan_number) - cinfo->output_scan_number = cinfo->input_scan_number; - } - break; - case JPEG_SUSPENDED: - break; - } - - return val; -} - - -/* - * Reset state to begin a fresh datastream. - */ - -METHODDEF(void) -reset_input_controller (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; - - inputctl->pub.consume_input = consume_markers; - inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ - inputctl->pub.eoi_reached = FALSE; - inputctl->inheaders = TRUE; - /* Reset other modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->marker->reset_marker_reader) (cinfo); - /* Reset progression state -- would be cleaner if entropy decoder did this */ - cinfo->coef_bits = NULL; -} - - -/* - * Initialize the input controller module. - * This is called only once, when the decompression object is created. - */ - -GLOBAL(void) -jinit_input_controller (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl; - - /* Create subobject in permanent pool */ - inputctl = (my_inputctl_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_input_controller)); - cinfo->inputctl = (struct jpeg_input_controller *) inputctl; - /* Initialize method pointers */ - inputctl->pub.consume_input = consume_markers; - inputctl->pub.reset_input_controller = reset_input_controller; - inputctl->pub.start_input_pass = start_input_pass; - inputctl->pub.finish_input_pass = finish_input_pass; - /* Initialize state: can't use reset_input_controller since we don't - * want to try to reset other modules yet. - */ - inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ - inputctl->pub.eoi_reached = FALSE; - inputctl->inheaders = TRUE; -} diff --git a/freeimage241/Source/LibJPEG/jdmainct.c b/freeimage241/Source/LibJPEG/jdmainct.c deleted file mode 100644 index 13c956f..0000000 --- a/freeimage241/Source/LibJPEG/jdmainct.c +++ /dev/null @@ -1,512 +0,0 @@ -/* - * jdmainct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the main buffer controller for decompression. - * The main buffer lies between the JPEG decompressor proper and the - * post-processor; it holds downsampled data in the JPEG colorspace. - * - * Note that this code is bypassed in raw-data mode, since the application - * supplies the equivalent of the main buffer in that case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * In the current system design, the main buffer need never be a full-image - * buffer; any full-height buffers will be found inside the coefficient or - * postprocessing controllers. Nonetheless, the main controller is not - * trivial. Its responsibility is to provide context rows for upsampling/ - * rescaling, and doing this in an efficient fashion is a bit tricky. - * - * Postprocessor input data is counted in "row groups". A row group - * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) - * sample rows of each component. (We require DCT_scaled_size values to be - * chosen such that these numbers are integers. In practice DCT_scaled_size - * values will likely be powers of two, so we actually have the stronger - * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.) - * Upsampling will typically produce max_v_samp_factor pixel rows from each - * row group (times any additional scale factor that the upsampler is - * applying). - * - * The coefficient controller will deliver data to us one iMCU row at a time; - * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or - * exactly min_DCT_scaled_size row groups. (This amount of data corresponds - * to one row of MCUs when the image is fully interleaved.) Note that the - * number of sample rows varies across components, but the number of row - * groups does not. Some garbage sample rows may be included in the last iMCU - * row at the bottom of the image. - * - * Depending on the vertical scaling algorithm used, the upsampler may need - * access to the sample row(s) above and below its current input row group. - * The upsampler is required to set need_context_rows TRUE at global selection - * time if so. When need_context_rows is FALSE, this controller can simply - * obtain one iMCU row at a time from the coefficient controller and dole it - * out as row groups to the postprocessor. - * - * When need_context_rows is TRUE, this controller guarantees that the buffer - * passed to postprocessing contains at least one row group's worth of samples - * above and below the row group(s) being processed. Note that the context - * rows "above" the first passed row group appear at negative row offsets in - * the passed buffer. At the top and bottom of the image, the required - * context rows are manufactured by duplicating the first or last real sample - * row; this avoids having special cases in the upsampling inner loops. - * - * The amount of context is fixed at one row group just because that's a - * convenient number for this controller to work with. The existing - * upsamplers really only need one sample row of context. An upsampler - * supporting arbitrary output rescaling might wish for more than one row - * group of context when shrinking the image; tough, we don't handle that. - * (This is justified by the assumption that downsizing will be handled mostly - * by adjusting the DCT_scaled_size values, so that the actual scale factor at - * the upsample step needn't be much less than one.) - * - * To provide the desired context, we have to retain the last two row groups - * of one iMCU row while reading in the next iMCU row. (The last row group - * can't be processed until we have another row group for its below-context, - * and so we have to save the next-to-last group too for its above-context.) - * We could do this most simply by copying data around in our buffer, but - * that'd be very slow. We can avoid copying any data by creating a rather - * strange pointer structure. Here's how it works. We allocate a workspace - * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number - * of row groups per iMCU row). We create two sets of redundant pointers to - * the workspace. Labeling the physical row groups 0 to M+1, the synthesized - * pointer lists look like this: - * M+1 M-1 - * master pointer --> 0 master pointer --> 0 - * 1 1 - * ... ... - * M-3 M-3 - * M-2 M - * M-1 M+1 - * M M-2 - * M+1 M-1 - * 0 0 - * We read alternate iMCU rows using each master pointer; thus the last two - * row groups of the previous iMCU row remain un-overwritten in the workspace. - * The pointer lists are set up so that the required context rows appear to - * be adjacent to the proper places when we pass the pointer lists to the - * upsampler. - * - * The above pictures describe the normal state of the pointer lists. - * At top and bottom of the image, we diddle the pointer lists to duplicate - * the first or last sample row as necessary (this is cheaper than copying - * sample rows around). - * - * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that - * situation each iMCU row provides only one row group so the buffering logic - * must be different (eg, we must read two iMCU rows before we can emit the - * first row group). For now, we simply do not support providing context - * rows when min_DCT_scaled_size is 1. That combination seems unlikely to - * be worth providing --- if someone wants a 1/8th-size preview, they probably - * want it quick and dirty, so a context-free upsampler is sufficient. - */ - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_main_controller pub; /* public fields */ - - /* Pointer to allocated workspace (M or M+2 row groups). */ - JSAMPARRAY buffer[MAX_COMPONENTS]; - - boolean buffer_full; /* Have we gotten an iMCU row from decoder? */ - JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ - - /* Remaining fields are only used in the context case. */ - - /* These are the master pointers to the funny-order pointer lists. */ - JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ - - int whichptr; /* indicates which pointer set is now in use */ - int context_state; /* process_data state machine status */ - JDIMENSION rowgroups_avail; /* row groups available to postprocessor */ - JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ -} my_main_controller; - -typedef my_main_controller * my_main_ptr; - -/* context_state values: */ -#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ -#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */ -#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */ - - -/* Forward declarations */ -METHODDEF(void) process_data_simple_main - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -METHODDEF(void) process_data_context_main - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -#ifdef QUANT_2PASS_SUPPORTED -METHODDEF(void) process_data_crank_post - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -#endif - - -LOCAL(void) -alloc_funny_pointers (j_decompress_ptr cinfo) -/* Allocate space for the funny pointer lists. - * This is done only once, not once per pass. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY xbuf; - - /* Get top-level space for component array pointers. - * We alloc both arrays with one call to save a few cycles. - */ - main->xbuffer[0] = (JSAMPIMAGE) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); - main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - /* Get space for pointer lists --- M+4 row groups in each list. - * We alloc both pointer lists with one call to save a few cycles. - */ - xbuf = (JSAMPARRAY) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); - xbuf += rgroup; /* want one row group at negative offsets */ - main->xbuffer[0][ci] = xbuf; - xbuf += rgroup * (M + 4); - main->xbuffer[1][ci] = xbuf; - } -} - - -LOCAL(void) -make_funny_pointers (j_decompress_ptr cinfo) -/* Create the funny pointer lists discussed in the comments above. - * The actual workspace is already allocated (in main->buffer), - * and the space for the pointer lists is allocated too. - * This routine just fills in the curiously ordered lists. - * This will be repeated at the beginning of each pass. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY buf, xbuf0, xbuf1; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - xbuf0 = main->xbuffer[0][ci]; - xbuf1 = main->xbuffer[1][ci]; - /* First copy the workspace pointers as-is */ - buf = main->buffer[ci]; - for (i = 0; i < rgroup * (M + 2); i++) { - xbuf0[i] = xbuf1[i] = buf[i]; - } - /* In the second list, put the last four row groups in swapped order */ - for (i = 0; i < rgroup * 2; i++) { - xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i]; - xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i]; - } - /* The wraparound pointers at top and bottom will be filled later - * (see set_wraparound_pointers, below). Initially we want the "above" - * pointers to duplicate the first actual data line. This only needs - * to happen in xbuffer[0]. - */ - for (i = 0; i < rgroup; i++) { - xbuf0[i - rgroup] = xbuf0[0]; - } - } -} - - -LOCAL(void) -set_wraparound_pointers (j_decompress_ptr cinfo) -/* Set up the "wraparound" pointers at top and bottom of the pointer lists. - * This changes the pointer list state from top-of-image to the normal state. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY xbuf0, xbuf1; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - xbuf0 = main->xbuffer[0][ci]; - xbuf1 = main->xbuffer[1][ci]; - for (i = 0; i < rgroup; i++) { - xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; - xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; - xbuf0[rgroup*(M+2) + i] = xbuf0[i]; - xbuf1[rgroup*(M+2) + i] = xbuf1[i]; - } - } -} - - -LOCAL(void) -set_bottom_pointers (j_decompress_ptr cinfo) -/* Change the pointer lists to duplicate the last sample row at the bottom - * of the image. whichptr indicates which xbuffer holds the final iMCU row. - * Also sets rowgroups_avail to indicate number of nondummy row groups in row. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup, iMCUheight, rows_left; - jpeg_component_info *compptr; - JSAMPARRAY xbuf; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Count sample rows in one iMCU row and in one row group */ - iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; - rgroup = iMCUheight / cinfo->min_DCT_scaled_size; - /* Count nondummy sample rows remaining for this component */ - rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); - if (rows_left == 0) rows_left = iMCUheight; - /* Count nondummy row groups. Should get same answer for each component, - * so we need only do it once. - */ - if (ci == 0) { - main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); - } - /* Duplicate the last real sample row rgroup*2 times; this pads out the - * last partial rowgroup and ensures at least one full rowgroup of context. - */ - xbuf = main->xbuffer[main->whichptr][ci]; - for (i = 0; i < rgroup * 2; i++) { - xbuf[rows_left + i] = xbuf[rows_left-1]; - } - } -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (cinfo->upsample->need_context_rows) { - main->pub.process_data = process_data_context_main; - make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ - main->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ - main->context_state = CTX_PREPARE_FOR_IMCU; - main->iMCU_row_ctr = 0; - } else { - /* Simple case with no context needed */ - main->pub.process_data = process_data_simple_main; - } - main->buffer_full = FALSE; /* Mark buffer empty */ - main->rowgroup_ctr = 0; - break; -#ifdef QUANT_2PASS_SUPPORTED - case JBUF_CRANK_DEST: - /* For last pass of 2-pass quantization, just crank the postprocessor */ - main->pub.process_data = process_data_crank_post; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data. - * This handles the simple case where no context is required. - */ - -METHODDEF(void) -process_data_simple_main (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - JDIMENSION rowgroups_avail; - - /* Read input data if we haven't filled the main buffer yet */ - if (! main->buffer_full) { - if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer)) - return; /* suspension forced, can do nothing more */ - main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ - } - - /* There are always min_DCT_scaled_size row groups in an iMCU row. */ - rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; - /* Note: at the bottom of the image, we may pass extra garbage row groups - * to the postprocessor. The postprocessor has to check for bottom - * of image anyway (at row resolution), so no point in us doing it too. - */ - - /* Feed the postprocessor */ - (*cinfo->post->post_process_data) (cinfo, main->buffer, - &main->rowgroup_ctr, rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - - /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ - if (main->rowgroup_ctr >= rowgroups_avail) { - main->buffer_full = FALSE; - main->rowgroup_ctr = 0; - } -} - - -/* - * Process some data. - * This handles the case where context rows must be provided. - */ - -METHODDEF(void) -process_data_context_main (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - /* Read input data if we haven't filled the main buffer yet */ - if (! main->buffer_full) { - if (! (*cinfo->coef->decompress_data) (cinfo, - main->xbuffer[main->whichptr])) - return; /* suspension forced, can do nothing more */ - main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ - main->iMCU_row_ctr++; /* count rows received */ - } - - /* Postprocessor typically will not swallow all the input data it is handed - * in one call (due to filling the output buffer first). Must be prepared - * to exit and restart. This switch lets us keep track of how far we got. - * Note that each case falls through to the next on successful completion. - */ - switch (main->context_state) { - case CTX_POSTPONED_ROW: - /* Call postprocessor using previously set pointers for postponed row */ - (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], - &main->rowgroup_ctr, main->rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - if (main->rowgroup_ctr < main->rowgroups_avail) - return; /* Need to suspend */ - main->context_state = CTX_PREPARE_FOR_IMCU; - if (*out_row_ctr >= out_rows_avail) - return; /* Postprocessor exactly filled output buf */ - /*FALLTHROUGH*/ - case CTX_PREPARE_FOR_IMCU: - /* Prepare to process first M-1 row groups of this iMCU row */ - main->rowgroup_ctr = 0; - main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); - /* Check for bottom of image: if so, tweak pointers to "duplicate" - * the last sample row, and adjust rowgroups_avail to ignore padding rows. - */ - if (main->iMCU_row_ctr == cinfo->total_iMCU_rows) - set_bottom_pointers(cinfo); - main->context_state = CTX_PROCESS_IMCU; - /*FALLTHROUGH*/ - case CTX_PROCESS_IMCU: - /* Call postprocessor using previously set pointers */ - (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], - &main->rowgroup_ctr, main->rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - if (main->rowgroup_ctr < main->rowgroups_avail) - return; /* Need to suspend */ - /* After the first iMCU, change wraparound pointers to normal state */ - if (main->iMCU_row_ctr == 1) - set_wraparound_pointers(cinfo); - /* Prepare to load new iMCU row using other xbuffer list */ - main->whichptr ^= 1; /* 0=>1 or 1=>0 */ - main->buffer_full = FALSE; - /* Still need to process last row group of this iMCU row, */ - /* which is saved at index M+1 of the other xbuffer */ - main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); - main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); - main->context_state = CTX_POSTPONED_ROW; - } -} - - -/* - * Process some data. - * Final pass of two-pass quantization: just call the postprocessor. - * Source data will be the postprocessor controller's internal buffer. - */ - -#ifdef QUANT_2PASS_SUPPORTED - -METHODDEF(void) -process_data_crank_post (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, - (JDIMENSION *) NULL, (JDIMENSION) 0, - output_buf, out_row_ctr, out_rows_avail); -} - -#endif /* QUANT_2PASS_SUPPORTED */ - - -/* - * Initialize main buffer controller. - */ - -GLOBAL(void) -jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_main_ptr main; - int ci, rgroup, ngroups; - jpeg_component_info *compptr; - - main = (my_main_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_main_controller)); - cinfo->main = (struct jpeg_d_main_controller *) main; - main->pub.start_pass = start_pass_main; - - if (need_full_buffer) /* shouldn't happen */ - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - /* Allocate the workspace. - * ngroups is the number of row groups we need. - */ - if (cinfo->upsample->need_context_rows) { - if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ - ERREXIT(cinfo, JERR_NOTIMPL); - alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ - ngroups = cinfo->min_DCT_scaled_size + 2; - } else { - ngroups = cinfo->min_DCT_scaled_size; - } - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - main->buffer[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - compptr->width_in_blocks * compptr->DCT_scaled_size, - (JDIMENSION) (rgroup * ngroups)); - } -} diff --git a/freeimage241/Source/LibJPEG/jdmarker.c b/freeimage241/Source/LibJPEG/jdmarker.c deleted file mode 100644 index f4cca8c..0000000 --- a/freeimage241/Source/LibJPEG/jdmarker.c +++ /dev/null @@ -1,1360 +0,0 @@ -/* - * jdmarker.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to decode JPEG datastream markers. - * Most of the complexity arises from our desire to support input - * suspension: if not all of the data for a marker is available, - * we must exit back to the application. On resumption, we reprocess - * the marker. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, - M_SOF1 = 0xc1, - M_SOF2 = 0xc2, - M_SOF3 = 0xc3, - - M_SOF5 = 0xc5, - M_SOF6 = 0xc6, - M_SOF7 = 0xc7, - - M_JPG = 0xc8, - M_SOF9 = 0xc9, - M_SOF10 = 0xca, - M_SOF11 = 0xcb, - - M_SOF13 = 0xcd, - M_SOF14 = 0xce, - M_SOF15 = 0xcf, - - M_DHT = 0xc4, - - M_DAC = 0xcc, - - M_RST0 = 0xd0, - M_RST1 = 0xd1, - M_RST2 = 0xd2, - M_RST3 = 0xd3, - M_RST4 = 0xd4, - M_RST5 = 0xd5, - M_RST6 = 0xd6, - M_RST7 = 0xd7, - - M_SOI = 0xd8, - M_EOI = 0xd9, - M_SOS = 0xda, - M_DQT = 0xdb, - M_DNL = 0xdc, - M_DRI = 0xdd, - M_DHP = 0xde, - M_EXP = 0xdf, - - M_APP0 = 0xe0, - M_APP1 = 0xe1, - M_APP2 = 0xe2, - M_APP3 = 0xe3, - M_APP4 = 0xe4, - M_APP5 = 0xe5, - M_APP6 = 0xe6, - M_APP7 = 0xe7, - M_APP8 = 0xe8, - M_APP9 = 0xe9, - M_APP10 = 0xea, - M_APP11 = 0xeb, - M_APP12 = 0xec, - M_APP13 = 0xed, - M_APP14 = 0xee, - M_APP15 = 0xef, - - M_JPG0 = 0xf0, - M_JPG13 = 0xfd, - M_COM = 0xfe, - - M_TEM = 0x01, - - M_ERROR = 0x100 -} JPEG_MARKER; - - -/* Private state */ - -typedef struct { - struct jpeg_marker_reader pub; /* public fields */ - - /* Application-overridable marker processing methods */ - jpeg_marker_parser_method process_COM; - jpeg_marker_parser_method process_APPn[16]; - - /* Limit on marker data length to save for each marker type */ - unsigned int length_limit_COM; - unsigned int length_limit_APPn[16]; - - /* Status of COM/APPn marker saving */ - jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */ - unsigned int bytes_read; /* data bytes read so far in marker */ - /* Note: cur_marker is not linked into marker_list until it's all read. */ -} my_marker_reader; - -typedef my_marker_reader * my_marker_ptr; - - -/* - * Macros for fetching data from the data source module. - * - * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect - * the current restart point; we update them only when we have reached a - * suitable place to restart if a suspension occurs. - */ - -/* Declare and initialize local copies of input pointer/count */ -#define INPUT_VARS(cinfo) \ - struct jpeg_source_mgr * datasrc = (cinfo)->src; \ - const JOCTET * next_input_byte = datasrc->next_input_byte; \ - size_t bytes_in_buffer = datasrc->bytes_in_buffer - -/* Unload the local copies --- do this only at a restart boundary */ -#define INPUT_SYNC(cinfo) \ - ( datasrc->next_input_byte = next_input_byte, \ - datasrc->bytes_in_buffer = bytes_in_buffer ) - -/* Reload the local copies --- used only in MAKE_BYTE_AVAIL */ -#define INPUT_RELOAD(cinfo) \ - ( next_input_byte = datasrc->next_input_byte, \ - bytes_in_buffer = datasrc->bytes_in_buffer ) - -/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available. - * Note we do *not* do INPUT_SYNC before calling fill_input_buffer, - * but we must reload the local copies after a successful fill. - */ -#define MAKE_BYTE_AVAIL(cinfo,action) \ - if (bytes_in_buffer == 0) { \ - if (! (*datasrc->fill_input_buffer) (cinfo)) \ - { action; } \ - INPUT_RELOAD(cinfo); \ - } - -/* Read a byte into variable V. - * If must suspend, take the specified action (typically "return FALSE"). - */ -#define INPUT_BYTE(cinfo,V,action) \ - MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V = GETJOCTET(*next_input_byte++); ) - -/* As above, but read two bytes interpreted as an unsigned 16-bit integer. - * V should be declared unsigned int or perhaps INT32. - */ -#define INPUT_2BYTES(cinfo,V,action) \ - MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ - MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V += GETJOCTET(*next_input_byte++); ) - - -/* - * Routines to process JPEG markers. - * - * Entry condition: JPEG marker itself has been read and its code saved - * in cinfo->unread_marker; input restart point is just after the marker. - * - * Exit: if return TRUE, have read and processed any parameters, and have - * updated the restart point to point after the parameters. - * If return FALSE, was forced to suspend before reaching end of - * marker parameters; restart point has not been moved. Same routine - * will be called again after application supplies more input data. - * - * This approach to suspension assumes that all of a marker's parameters - * can fit into a single input bufferload. This should hold for "normal" - * markers. Some COM/APPn markers might have large parameter segments - * that might not fit. If we are simply dropping such a marker, we use - * skip_input_data to get past it, and thereby put the problem on the - * source manager's shoulders. If we are saving the marker's contents - * into memory, we use a slightly different convention: when forced to - * suspend, the marker processor updates the restart point to the end of - * what it's consumed (ie, the end of the buffer) before returning FALSE. - * On resumption, cinfo->unread_marker still contains the marker code, - * but the data source will point to the next chunk of marker data. - * The marker processor must retain internal state to deal with this. - * - * Note that we don't bother to avoid duplicate trace messages if a - * suspension occurs within marker parameters. Other side effects - * require more care. - */ - - -LOCAL(boolean) -get_soi (j_decompress_ptr cinfo) -/* Process an SOI marker */ -{ - int i; - - TRACEMS(cinfo, 1, JTRC_SOI); - - if (cinfo->marker->saw_SOI) - ERREXIT(cinfo, JERR_SOI_DUPLICATE); - - /* Reset all parameters that are defined to be reset by SOI */ - - for (i = 0; i < NUM_ARITH_TBLS; i++) { - cinfo->arith_dc_L[i] = 0; - cinfo->arith_dc_U[i] = 1; - cinfo->arith_ac_K[i] = 5; - } - cinfo->restart_interval = 0; - - /* Set initial assumptions for colorspace etc */ - - cinfo->jpeg_color_space = JCS_UNKNOWN; - cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */ - - cinfo->saw_JFIF_marker = FALSE; - cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */ - cinfo->JFIF_minor_version = 1; - cinfo->density_unit = 0; - cinfo->X_density = 1; - cinfo->Y_density = 1; - cinfo->saw_Adobe_marker = FALSE; - cinfo->Adobe_transform = 0; - - cinfo->marker->saw_SOI = TRUE; - - return TRUE; -} - - -LOCAL(boolean) -get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith) -/* Process a SOFn marker */ -{ - INT32 length; - int c, ci; - jpeg_component_info * compptr; - INPUT_VARS(cinfo); - - cinfo->progressive_mode = is_prog; - cinfo->arith_code = is_arith; - - INPUT_2BYTES(cinfo, length, return FALSE); - - INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE); - INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE); - INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE); - INPUT_BYTE(cinfo, cinfo->num_components, return FALSE); - - length -= 8; - - TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker, - (int) cinfo->image_width, (int) cinfo->image_height, - cinfo->num_components); - - if (cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOF_DUPLICATE); - - /* We don't support files in which the image height is initially specified */ - /* as 0 and is later redefined by DNL. As long as we have to check that, */ - /* might as well have a general sanity check. */ - if (cinfo->image_height <= 0 || cinfo->image_width <= 0 - || cinfo->num_components <= 0) - ERREXIT(cinfo, JERR_EMPTY_IMAGE); - - if (length != (cinfo->num_components * 3)) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - if (cinfo->comp_info == NULL) /* do only once, even if suspend */ - cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * SIZEOF(jpeg_component_info)); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - compptr->component_index = ci; - INPUT_BYTE(cinfo, compptr->component_id, return FALSE); - INPUT_BYTE(cinfo, c, return FALSE); - compptr->h_samp_factor = (c >> 4) & 15; - compptr->v_samp_factor = (c ) & 15; - INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE); - - TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT, - compptr->component_id, compptr->h_samp_factor, - compptr->v_samp_factor, compptr->quant_tbl_no); - } - - cinfo->marker->saw_SOF = TRUE; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_sos (j_decompress_ptr cinfo) -/* Process a SOS marker */ -{ - INT32 length; - int i, ci, n, c, cc; - jpeg_component_info * compptr; - INPUT_VARS(cinfo); - - if (! cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOS_NO_SOF); - - INPUT_2BYTES(cinfo, length, return FALSE); - - INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */ - - TRACEMS1(cinfo, 1, JTRC_SOS, n); - - if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - cinfo->comps_in_scan = n; - - /* Collect the component-spec parameters */ - - for (i = 0; i < n; i++) { - INPUT_BYTE(cinfo, cc, return FALSE); - INPUT_BYTE(cinfo, c, return FALSE); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (cc == compptr->component_id) - goto id_found; - } - - ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); - - id_found: - - cinfo->cur_comp_info[i] = compptr; - compptr->dc_tbl_no = (c >> 4) & 15; - compptr->ac_tbl_no = (c ) & 15; - - TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, - compptr->dc_tbl_no, compptr->ac_tbl_no); - } - - /* Collect the additional scan parameters Ss, Se, Ah/Al. */ - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Ss = c; - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Se = c; - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Ah = (c >> 4) & 15; - cinfo->Al = (c ) & 15; - - TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se, - cinfo->Ah, cinfo->Al); - - /* Prepare to scan data & restart markers */ - cinfo->marker->next_restart_num = 0; - - /* Count another SOS marker */ - cinfo->input_scan_number++; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -#ifdef D_ARITH_CODING_SUPPORTED - -LOCAL(boolean) -get_dac (j_decompress_ptr cinfo) -/* Process a DAC marker */ -{ - INT32 length; - int index, val; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 0) { - INPUT_BYTE(cinfo, index, return FALSE); - INPUT_BYTE(cinfo, val, return FALSE); - - length -= 2; - - TRACEMS2(cinfo, 1, JTRC_DAC, index, val); - - if (index < 0 || index >= (2*NUM_ARITH_TBLS)) - ERREXIT1(cinfo, JERR_DAC_INDEX, index); - - if (index >= NUM_ARITH_TBLS) { /* define AC table */ - cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val; - } else { /* define DC table */ - cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F); - cinfo->arith_dc_U[index] = (UINT8) (val >> 4); - if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index]) - ERREXIT1(cinfo, JERR_DAC_VALUE, val); - } - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - -#else /* ! D_ARITH_CODING_SUPPORTED */ - -#define get_dac(cinfo) skip_variable(cinfo) - -#endif /* D_ARITH_CODING_SUPPORTED */ - - -LOCAL(boolean) -get_dht (j_decompress_ptr cinfo) -/* Process a DHT marker */ -{ - INT32 length; - UINT8 bits[17]; - UINT8 huffval[256]; - int i, index, count; - JHUFF_TBL **htblptr; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 16) { - INPUT_BYTE(cinfo, index, return FALSE); - - TRACEMS1(cinfo, 1, JTRC_DHT, index); - - bits[0] = 0; - count = 0; - for (i = 1; i <= 16; i++) { - INPUT_BYTE(cinfo, bits[i], return FALSE); - count += bits[i]; - } - - length -= 1 + 16; - - TRACEMS8(cinfo, 2, JTRC_HUFFBITS, - bits[1], bits[2], bits[3], bits[4], - bits[5], bits[6], bits[7], bits[8]); - TRACEMS8(cinfo, 2, JTRC_HUFFBITS, - bits[9], bits[10], bits[11], bits[12], - bits[13], bits[14], bits[15], bits[16]); - - /* Here we just do minimal validation of the counts to avoid walking - * off the end of our table space. jdhuff.c will check more carefully. - */ - if (count > 256 || ((INT32) count) > length) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - for (i = 0; i < count; i++) - INPUT_BYTE(cinfo, huffval[i], return FALSE); - - length -= count; - - if (index & 0x10) { /* AC table definition */ - index -= 0x10; - htblptr = &cinfo->ac_huff_tbl_ptrs[index]; - } else { /* DC table definition */ - htblptr = &cinfo->dc_huff_tbl_ptrs[index]; - } - - if (index < 0 || index >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_DHT_INDEX, index); - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_dqt (j_decompress_ptr cinfo) -/* Process a DQT marker */ -{ - INT32 length; - int n, i, prec; - unsigned int tmp; - JQUANT_TBL *quant_ptr; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 0) { - INPUT_BYTE(cinfo, n, return FALSE); - prec = n >> 4; - n &= 0x0F; - - TRACEMS2(cinfo, 1, JTRC_DQT, n, prec); - - if (n >= NUM_QUANT_TBLS) - ERREXIT1(cinfo, JERR_DQT_INDEX, n); - - if (cinfo->quant_tbl_ptrs[n] == NULL) - cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); - quant_ptr = cinfo->quant_tbl_ptrs[n]; - - for (i = 0; i < DCTSIZE2; i++) { - if (prec) - INPUT_2BYTES(cinfo, tmp, return FALSE); - else - INPUT_BYTE(cinfo, tmp, return FALSE); - /* We convert the zigzag-order table to natural array order. */ - quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp; - } - - if (cinfo->err->trace_level >= 2) { - for (i = 0; i < DCTSIZE2; i += 8) { - TRACEMS8(cinfo, 2, JTRC_QUANTVALS, - quant_ptr->quantval[i], quant_ptr->quantval[i+1], - quant_ptr->quantval[i+2], quant_ptr->quantval[i+3], - quant_ptr->quantval[i+4], quant_ptr->quantval[i+5], - quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]); - } - } - - length -= DCTSIZE2+1; - if (prec) length -= DCTSIZE2; - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_dri (j_decompress_ptr cinfo) -/* Process a DRI marker */ -{ - INT32 length; - unsigned int tmp; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - - if (length != 4) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_2BYTES(cinfo, tmp, return FALSE); - - TRACEMS1(cinfo, 1, JTRC_DRI, tmp); - - cinfo->restart_interval = tmp; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -/* - * Routines for processing APPn and COM markers. - * These are either saved in memory or discarded, per application request. - * APP0 and APP14 are specially checked to see if they are - * JFIF and Adobe markers, respectively. - */ - -#define APP0_DATA_LEN 14 /* Length of interesting data in APP0 */ -#define APP14_DATA_LEN 12 /* Length of interesting data in APP14 */ -#define APPN_DATA_LEN 14 /* Must be the largest of the above!! */ - - -LOCAL(void) -examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data, - unsigned int datalen, INT32 remaining) -/* Examine first few bytes from an APP0. - * Take appropriate action if it is a JFIF marker. - * datalen is # of bytes at data[], remaining is length of rest of marker data. - */ -{ - INT32 totallen = (INT32) datalen + remaining; - - if (datalen >= APP0_DATA_LEN && - GETJOCTET(data[0]) == 0x4A && - GETJOCTET(data[1]) == 0x46 && - GETJOCTET(data[2]) == 0x49 && - GETJOCTET(data[3]) == 0x46 && - GETJOCTET(data[4]) == 0) { - /* Found JFIF APP0 marker: save info */ - cinfo->saw_JFIF_marker = TRUE; - cinfo->JFIF_major_version = GETJOCTET(data[5]); - cinfo->JFIF_minor_version = GETJOCTET(data[6]); - cinfo->density_unit = GETJOCTET(data[7]); - cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]); - cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]); - /* Check version. - * Major version must be 1, anything else signals an incompatible change. - * (We used to treat this as an error, but now it's a nonfatal warning, - * because some bozo at Hijaak couldn't read the spec.) - * Minor version should be 0..2, but process anyway if newer. - */ - if (cinfo->JFIF_major_version != 1) - WARNMS2(cinfo, JWRN_JFIF_MAJOR, - cinfo->JFIF_major_version, cinfo->JFIF_minor_version); - /* Generate trace messages */ - TRACEMS5(cinfo, 1, JTRC_JFIF, - cinfo->JFIF_major_version, cinfo->JFIF_minor_version, - cinfo->X_density, cinfo->Y_density, cinfo->density_unit); - /* Validate thumbnail dimensions and issue appropriate messages */ - if (GETJOCTET(data[12]) | GETJOCTET(data[13])) - TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, - GETJOCTET(data[12]), GETJOCTET(data[13])); - totallen -= APP0_DATA_LEN; - if (totallen != - ((INT32)GETJOCTET(data[12]) * (INT32)GETJOCTET(data[13]) * (INT32) 3)) - TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen); - } else if (datalen >= 6 && - GETJOCTET(data[0]) == 0x4A && - GETJOCTET(data[1]) == 0x46 && - GETJOCTET(data[2]) == 0x58 && - GETJOCTET(data[3]) == 0x58 && - GETJOCTET(data[4]) == 0) { - /* Found JFIF "JFXX" extension APP0 marker */ - /* The library doesn't actually do anything with these, - * but we try to produce a helpful trace message. - */ - switch (GETJOCTET(data[5])) { - case 0x10: - TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen); - break; - case 0x11: - TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen); - break; - case 0x13: - TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen); - break; - default: - TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, - GETJOCTET(data[5]), (int) totallen); - break; - } - } else { - /* Start of APP0 does not match "JFIF" or "JFXX", or too short */ - TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen); - } -} - - -LOCAL(void) -examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data, - unsigned int datalen, INT32 remaining) -/* Examine first few bytes from an APP14. - * Take appropriate action if it is an Adobe marker. - * datalen is # of bytes at data[], remaining is length of rest of marker data. - */ -{ - unsigned int version, flags0, flags1, transform; - - if (datalen >= APP14_DATA_LEN && - GETJOCTET(data[0]) == 0x41 && - GETJOCTET(data[1]) == 0x64 && - GETJOCTET(data[2]) == 0x6F && - GETJOCTET(data[3]) == 0x62 && - GETJOCTET(data[4]) == 0x65) { - /* Found Adobe APP14 marker */ - version = (GETJOCTET(data[5]) << 8) + GETJOCTET(data[6]); - flags0 = (GETJOCTET(data[7]) << 8) + GETJOCTET(data[8]); - flags1 = (GETJOCTET(data[9]) << 8) + GETJOCTET(data[10]); - transform = GETJOCTET(data[11]); - TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform); - cinfo->saw_Adobe_marker = TRUE; - cinfo->Adobe_transform = (UINT8) transform; - } else { - /* Start of APP14 does not match "Adobe", or too short */ - TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining)); - } -} - - -METHODDEF(boolean) -get_interesting_appn (j_decompress_ptr cinfo) -/* Process an APP0 or APP14 marker without saving it */ -{ - INT32 length; - JOCTET b[APPN_DATA_LEN]; - unsigned int i, numtoread; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - /* get the interesting part of the marker data */ - if (length >= APPN_DATA_LEN) - numtoread = APPN_DATA_LEN; - else if (length > 0) - numtoread = (unsigned int) length; - else - numtoread = 0; - for (i = 0; i < numtoread; i++) - INPUT_BYTE(cinfo, b[i], return FALSE); - length -= numtoread; - - /* process it */ - switch (cinfo->unread_marker) { - case M_APP0: - examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length); - break; - case M_APP14: - examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length); - break; - default: - /* can't get here unless jpeg_save_markers chooses wrong processor */ - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); - break; - } - - /* skip any remaining data -- could be lots */ - INPUT_SYNC(cinfo); - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - - -#ifdef SAVE_MARKERS_SUPPORTED - -METHODDEF(boolean) -save_marker (j_decompress_ptr cinfo) -/* Save an APPn or COM marker into the marker list */ -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - jpeg_saved_marker_ptr cur_marker = marker->cur_marker; - unsigned int bytes_read, data_length; - JOCTET FAR * data; - INT32 length = 0; - INPUT_VARS(cinfo); - - if (cur_marker == NULL) { - /* begin reading a marker */ - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - if (length >= 0) { /* watch out for bogus length word */ - /* figure out how much we want to save */ - unsigned int limit; - if (cinfo->unread_marker == (int) M_COM) - limit = marker->length_limit_COM; - else - limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0]; - if ((unsigned int) length < limit) - limit = (unsigned int) length; - /* allocate and initialize the marker item */ - cur_marker = (jpeg_saved_marker_ptr) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(struct jpeg_marker_struct) + limit); - cur_marker->next = NULL; - cur_marker->marker = (UINT8) cinfo->unread_marker; - cur_marker->original_length = (unsigned int) length; - cur_marker->data_length = limit; - /* data area is just beyond the jpeg_marker_struct */ - data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1); - marker->cur_marker = cur_marker; - marker->bytes_read = 0; - bytes_read = 0; - data_length = limit; - } else { - /* deal with bogus length word */ - bytes_read = data_length = 0; - data = NULL; - } - } else { - /* resume reading a marker */ - bytes_read = marker->bytes_read; - data_length = cur_marker->data_length; - data = cur_marker->data + bytes_read; - } - - while (bytes_read < data_length) { - INPUT_SYNC(cinfo); /* move the restart point to here */ - marker->bytes_read = bytes_read; - /* If there's not at least one byte in buffer, suspend */ - MAKE_BYTE_AVAIL(cinfo, return FALSE); - /* Copy bytes with reasonable rapidity */ - while (bytes_read < data_length && bytes_in_buffer > 0) { - *data++ = *next_input_byte++; - bytes_in_buffer--; - bytes_read++; - } - } - - /* Done reading what we want to read */ - if (cur_marker != NULL) { /* will be NULL if bogus length word */ - /* Add new marker to end of list */ - if (cinfo->marker_list == NULL) { - cinfo->marker_list = cur_marker; - } else { - jpeg_saved_marker_ptr prev = cinfo->marker_list; - while (prev->next != NULL) - prev = prev->next; - prev->next = cur_marker; - } - /* Reset pointer & calc remaining data length */ - data = cur_marker->data; - length = cur_marker->original_length - data_length; - } - /* Reset to initial state for next marker */ - marker->cur_marker = NULL; - - /* Process the marker if interesting; else just make a generic trace msg */ - switch (cinfo->unread_marker) { - case M_APP0: - examine_app0(cinfo, data, data_length, length); - break; - case M_APP14: - examine_app14(cinfo, data, data_length, length); - break; - default: - TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, - (int) (data_length + length)); - break; - } - - /* skip any remaining data -- could be lots */ - INPUT_SYNC(cinfo); /* do before skip_input_data */ - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - -#endif /* SAVE_MARKERS_SUPPORTED */ - - -METHODDEF(boolean) -skip_variable (j_decompress_ptr cinfo) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - INT32 length; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); - - INPUT_SYNC(cinfo); /* do before skip_input_data */ - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - - -/* - * Find the next JPEG marker, save it in cinfo->unread_marker. - * Returns FALSE if had to suspend before reaching a marker; - * in that case cinfo->unread_marker is unchanged. - * - * Note that the result might not be a valid marker code, - * but it will never be 0 or FF. - */ - -LOCAL(boolean) -next_marker (j_decompress_ptr cinfo) -{ - int c; - INPUT_VARS(cinfo); - - for (;;) { - INPUT_BYTE(cinfo, c, return FALSE); - /* Skip any non-FF bytes. - * This may look a bit inefficient, but it will not occur in a valid file. - * We sync after each discarded byte so that a suspending data source - * can discard the byte from its buffer. - */ - while (c != 0xFF) { - cinfo->marker->discarded_bytes++; - INPUT_SYNC(cinfo); - INPUT_BYTE(cinfo, c, return FALSE); - } - /* This loop swallows any duplicate FF bytes. Extra FFs are legal as - * pad bytes, so don't count them in discarded_bytes. We assume there - * will not be so many consecutive FF bytes as to overflow a suspending - * data source's input buffer. - */ - do { - INPUT_BYTE(cinfo, c, return FALSE); - } while (c == 0xFF); - if (c != 0) - break; /* found a valid marker, exit loop */ - /* Reach here if we found a stuffed-zero data sequence (FF/00). - * Discard it and loop back to try again. - */ - cinfo->marker->discarded_bytes += 2; - INPUT_SYNC(cinfo); - } - - if (cinfo->marker->discarded_bytes != 0) { - WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c); - cinfo->marker->discarded_bytes = 0; - } - - cinfo->unread_marker = c; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -first_marker (j_decompress_ptr cinfo) -/* Like next_marker, but used to obtain the initial SOI marker. */ -/* For this marker, we do not allow preceding garbage or fill; otherwise, - * we might well scan an entire input file before realizing it ain't JPEG. - * If an application wants to process non-JFIF files, it must seek to the - * SOI before calling the JPEG library. - */ -{ - int c, c2; - INPUT_VARS(cinfo); - - INPUT_BYTE(cinfo, c, return FALSE); - INPUT_BYTE(cinfo, c2, return FALSE); - if (c != 0xFF || c2 != (int) M_SOI) - ERREXIT2(cinfo, JERR_NO_SOI, c, c2); - - cinfo->unread_marker = c2; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -/* - * Read markers until SOS or EOI. - * - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - -METHODDEF(int) -read_markers (j_decompress_ptr cinfo) -{ - /* Outer loop repeats once for each marker. */ - for (;;) { - /* Collect the marker proper, unless we already did. */ - /* NB: first_marker() enforces the requirement that SOI appear first. */ - if (cinfo->unread_marker == 0) { - if (! cinfo->marker->saw_SOI) { - if (! first_marker(cinfo)) - return JPEG_SUSPENDED; - } else { - if (! next_marker(cinfo)) - return JPEG_SUSPENDED; - } - } - /* At this point cinfo->unread_marker contains the marker code and the - * input point is just past the marker proper, but before any parameters. - * A suspension will cause us to return with this state still true. - */ - switch (cinfo->unread_marker) { - case M_SOI: - if (! get_soi(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - if (! get_sof(cinfo, FALSE, FALSE)) - return JPEG_SUSPENDED; - break; - - case M_SOF2: /* Progressive, Huffman */ - if (! get_sof(cinfo, TRUE, FALSE)) - return JPEG_SUSPENDED; - break; - - case M_SOF9: /* Extended sequential, arithmetic */ - if (! get_sof(cinfo, FALSE, TRUE)) - return JPEG_SUSPENDED; - break; - - case M_SOF10: /* Progressive, arithmetic */ - if (! get_sof(cinfo, TRUE, TRUE)) - return JPEG_SUSPENDED; - break; - - /* Currently unsupported SOFn types */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_JPG: /* Reserved for JPEG extensions */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker); - break; - - case M_SOS: - if (! get_sos(cinfo)) - return JPEG_SUSPENDED; - cinfo->unread_marker = 0; /* processed the marker */ - return JPEG_REACHED_SOS; - - case M_EOI: - TRACEMS(cinfo, 1, JTRC_EOI); - cinfo->unread_marker = 0; /* processed the marker */ - return JPEG_REACHED_EOI; - - case M_DAC: - if (! get_dac(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DHT: - if (! get_dht(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DQT: - if (! get_dqt(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DRI: - if (! get_dri(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_APP0: - case M_APP1: - case M_APP2: - case M_APP3: - case M_APP4: - case M_APP5: - case M_APP6: - case M_APP7: - case M_APP8: - case M_APP9: - case M_APP10: - case M_APP11: - case M_APP12: - case M_APP13: - case M_APP14: - case M_APP15: - if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[ - cinfo->unread_marker - (int) M_APP0]) (cinfo)) - return JPEG_SUSPENDED; - break; - - case M_COM: - if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo)) - return JPEG_SUSPENDED; - break; - - case M_RST0: /* these are all parameterless */ - case M_RST1: - case M_RST2: - case M_RST3: - case M_RST4: - case M_RST5: - case M_RST6: - case M_RST7: - case M_TEM: - TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker); - break; - - case M_DNL: /* Ignore DNL ... perhaps the wrong thing */ - if (! skip_variable(cinfo)) - return JPEG_SUSPENDED; - break; - - default: /* must be DHP, EXP, JPGn, or RESn */ - /* For now, we treat the reserved markers as fatal errors since they are - * likely to be used to signal incompatible JPEG Part 3 extensions. - * Once the JPEG 3 version-number marker is well defined, this code - * ought to change! - */ - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); - break; - } - /* Successfully processed marker, so reset state variable */ - cinfo->unread_marker = 0; - } /* end loop */ -} - - -/* - * Read a restart marker, which is expected to appear next in the datastream; - * if the marker is not there, take appropriate recovery action. - * Returns FALSE if suspension is required. - * - * This is called by the entropy decoder after it has read an appropriate - * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder - * has already read a marker from the data source. Under normal conditions - * cinfo->unread_marker will be reset to 0 before returning; if not reset, - * it holds a marker which the decoder will be unable to read past. - */ - -METHODDEF(boolean) -read_restart_marker (j_decompress_ptr cinfo) -{ - /* Obtain a marker unless we already did. */ - /* Note that next_marker will complain if it skips any data. */ - if (cinfo->unread_marker == 0) { - if (! next_marker(cinfo)) - return FALSE; - } - - if (cinfo->unread_marker == - ((int) M_RST0 + cinfo->marker->next_restart_num)) { - /* Normal case --- swallow the marker and let entropy decoder continue */ - TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num); - cinfo->unread_marker = 0; - } else { - /* Uh-oh, the restart markers have been messed up. */ - /* Let the data source manager determine how to resync. */ - if (! (*cinfo->src->resync_to_restart) (cinfo, - cinfo->marker->next_restart_num)) - return FALSE; - } - - /* Update next-restart state */ - cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7; - - return TRUE; -} - - -/* - * This is the default resync_to_restart method for data source managers - * to use if they don't have any better approach. Some data source managers - * may be able to back up, or may have additional knowledge about the data - * which permits a more intelligent recovery strategy; such managers would - * presumably supply their own resync method. - * - * read_restart_marker calls resync_to_restart if it finds a marker other than - * the restart marker it was expecting. (This code is *not* used unless - * a nonzero restart interval has been declared.) cinfo->unread_marker is - * the marker code actually found (might be anything, except 0 or FF). - * The desired restart marker number (0..7) is passed as a parameter. - * This routine is supposed to apply whatever error recovery strategy seems - * appropriate in order to position the input stream to the next data segment. - * Note that cinfo->unread_marker is treated as a marker appearing before - * the current data-source input point; usually it should be reset to zero - * before returning. - * Returns FALSE if suspension is required. - * - * This implementation is substantially constrained by wanting to treat the - * input as a data stream; this means we can't back up. Therefore, we have - * only the following actions to work with: - * 1. Simply discard the marker and let the entropy decoder resume at next - * byte of file. - * 2. Read forward until we find another marker, discarding intervening - * data. (In theory we could look ahead within the current bufferload, - * without having to discard data if we don't find the desired marker. - * This idea is not implemented here, in part because it makes behavior - * dependent on buffer size and chance buffer-boundary positions.) - * 3. Leave the marker unread (by failing to zero cinfo->unread_marker). - * This will cause the entropy decoder to process an empty data segment, - * inserting dummy zeroes, and then we will reprocess the marker. - * - * #2 is appropriate if we think the desired marker lies ahead, while #3 is - * appropriate if the found marker is a future restart marker (indicating - * that we have missed the desired restart marker, probably because it got - * corrupted). - * We apply #2 or #3 if the found marker is a restart marker no more than - * two counts behind or ahead of the expected one. We also apply #2 if the - * found marker is not a legal JPEG marker code (it's certainly bogus data). - * If the found marker is a restart marker more than 2 counts away, we do #1 - * (too much risk that the marker is erroneous; with luck we will be able to - * resync at some future point). - * For any valid non-restart JPEG marker, we apply #3. This keeps us from - * overrunning the end of a scan. An implementation limited to single-scan - * files might find it better to apply #2 for markers other than EOI, since - * any other marker would have to be bogus data in that case. - */ - -GLOBAL(boolean) -jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired) -{ - int marker = cinfo->unread_marker; - int action = 1; - - /* Always put up a warning. */ - WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); - - /* Outer loop handles repeated decision after scanning forward. */ - for (;;) { - if (marker < (int) M_SOF0) - action = 2; /* invalid marker */ - else if (marker < (int) M_RST0 || marker > (int) M_RST7) - action = 3; /* valid non-restart marker */ - else { - if (marker == ((int) M_RST0 + ((desired+1) & 7)) || - marker == ((int) M_RST0 + ((desired+2) & 7))) - action = 3; /* one of the next two expected restarts */ - else if (marker == ((int) M_RST0 + ((desired-1) & 7)) || - marker == ((int) M_RST0 + ((desired-2) & 7))) - action = 2; /* a prior restart, so advance */ - else - action = 1; /* desired restart or too far away */ - } - TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action); - switch (action) { - case 1: - /* Discard marker and let entropy decoder resume processing. */ - cinfo->unread_marker = 0; - return TRUE; - case 2: - /* Scan to the next marker, and repeat the decision loop. */ - if (! next_marker(cinfo)) - return FALSE; - marker = cinfo->unread_marker; - break; - case 3: - /* Return without advancing past this marker. */ - /* Entropy decoder will be forced to process an empty segment. */ - return TRUE; - } - } /* end loop */ -} - - -/* - * Reset marker processing state to begin a fresh datastream. - */ - -METHODDEF(void) -reset_marker_reader (j_decompress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - cinfo->comp_info = NULL; /* until allocated by get_sof */ - cinfo->input_scan_number = 0; /* no SOS seen yet */ - cinfo->unread_marker = 0; /* no pending marker */ - marker->pub.saw_SOI = FALSE; /* set internal state too */ - marker->pub.saw_SOF = FALSE; - marker->pub.discarded_bytes = 0; - marker->cur_marker = NULL; -} - - -/* - * Initialize the marker reader module. - * This is called only once, when the decompression object is created. - */ - -GLOBAL(void) -jinit_marker_reader (j_decompress_ptr cinfo) -{ - my_marker_ptr marker; - int i; - - /* Create subobject in permanent pool */ - marker = (my_marker_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_marker_reader)); - cinfo->marker = (struct jpeg_marker_reader *) marker; - /* Initialize public method pointers */ - marker->pub.reset_marker_reader = reset_marker_reader; - marker->pub.read_markers = read_markers; - marker->pub.read_restart_marker = read_restart_marker; - /* Initialize COM/APPn processing. - * By default, we examine and then discard APP0 and APP14, - * but simply discard COM and all other APPn. - */ - marker->process_COM = skip_variable; - marker->length_limit_COM = 0; - for (i = 0; i < 16; i++) { - marker->process_APPn[i] = skip_variable; - marker->length_limit_APPn[i] = 0; - } - marker->process_APPn[0] = get_interesting_appn; - marker->process_APPn[14] = get_interesting_appn; - /* Reset marker processing state */ - reset_marker_reader(cinfo); -} - - -/* - * Control saving of COM and APPn markers into marker_list. - */ - -#ifdef SAVE_MARKERS_SUPPORTED - -GLOBAL(void) -jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - long maxlength; - jpeg_marker_parser_method processor; - - /* Length limit mustn't be larger than what we can allocate - * (should only be a concern in a 16-bit environment). - */ - maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct); - if (((long) length_limit) > maxlength) - length_limit = (unsigned int) maxlength; - - /* Choose processor routine to use. - * APP0/APP14 have special requirements. - */ - if (length_limit) { - processor = save_marker; - /* If saving APP0/APP14, save at least enough for our internal use. */ - if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN) - length_limit = APP0_DATA_LEN; - else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN) - length_limit = APP14_DATA_LEN; - } else { - processor = skip_variable; - /* If discarding APP0/APP14, use our regular on-the-fly processor. */ - if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14) - processor = get_interesting_appn; - } - - if (marker_code == (int) M_COM) { - marker->process_COM = processor; - marker->length_limit_COM = length_limit; - } else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) { - marker->process_APPn[marker_code - (int) M_APP0] = processor; - marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit; - } else - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); -} - -#endif /* SAVE_MARKERS_SUPPORTED */ - - -/* - * Install a special processing method for COM or APPn markers. - */ - -GLOBAL(void) -jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - if (marker_code == (int) M_COM) - marker->process_COM = routine; - else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) - marker->process_APPn[marker_code - (int) M_APP0] = routine; - else - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); -} diff --git a/freeimage241/Source/LibJPEG/jdmaster.c b/freeimage241/Source/LibJPEG/jdmaster.c deleted file mode 100644 index 2802c5b..0000000 --- a/freeimage241/Source/LibJPEG/jdmaster.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * jdmaster.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains master control logic for the JPEG decompressor. - * These routines are concerned with selecting the modules to be executed - * and with determining the number of passes and the work to be done in each - * pass. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef struct { - struct jpeg_decomp_master pub; /* public fields */ - - int pass_number; /* # of passes completed */ - - boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */ - - /* Saved references to initialized quantizer modules, - * in case we need to switch modes. - */ - struct jpeg_color_quantizer * quantizer_1pass; - struct jpeg_color_quantizer * quantizer_2pass; -} my_decomp_master; - -typedef my_decomp_master * my_master_ptr; - - -/* - * Determine whether merged upsample/color conversion should be used. - * CRUCIAL: this must match the actual capabilities of jdmerge.c! - */ - -LOCAL(boolean) -use_merged_upsample (j_decompress_ptr cinfo) -{ -#ifdef UPSAMPLE_MERGING_SUPPORTED - /* Merging is the equivalent of plain box-filter upsampling */ - if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) - return FALSE; - /* jdmerge.c only supports YCC=>RGB color conversion */ - if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || - cinfo->out_color_space != JCS_RGB || - cinfo->out_color_components != RGB_PIXELSIZE) - return FALSE; - /* and it only handles 2h1v or 2h2v sampling ratios */ - if (cinfo->comp_info[0].h_samp_factor != 2 || - cinfo->comp_info[1].h_samp_factor != 1 || - cinfo->comp_info[2].h_samp_factor != 1 || - cinfo->comp_info[0].v_samp_factor > 2 || - cinfo->comp_info[1].v_samp_factor != 1 || - cinfo->comp_info[2].v_samp_factor != 1) - return FALSE; - /* furthermore, it doesn't work if we've scaled the IDCTs differently */ - if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || - cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || - cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) - return FALSE; - /* ??? also need to test for upsample-time rescaling, when & if supported */ - return TRUE; /* by golly, it'll work... */ -#else - return FALSE; -#endif -} - - -/* - * Compute output image dimensions and related values. - * NOTE: this is exported for possible use by application. - * Hence it mustn't do anything that can't be done twice. - * Also note that it may be called before the master module is initialized! - */ - -GLOBAL(void) -jpeg_calc_output_dimensions (j_decompress_ptr cinfo) -/* Do computations that are needed before master selection phase */ -{ -#ifdef IDCT_SCALING_SUPPORTED - int ci; - jpeg_component_info *compptr; -#endif - - /* Prevent application from calling me at wrong times */ - if (cinfo->global_state != DSTATE_READY) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - -#ifdef IDCT_SCALING_SUPPORTED - - /* Compute actual output image dimensions and DCT scaling choices. */ - if (cinfo->scale_num * 8 <= cinfo->scale_denom) { - /* Provide 1/8 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 8L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 8L); - cinfo->min_DCT_scaled_size = 1; - } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) { - /* Provide 1/4 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 4L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 4L); - cinfo->min_DCT_scaled_size = 2; - } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) { - /* Provide 1/2 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 2L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 2L); - cinfo->min_DCT_scaled_size = 4; - } else { - /* Provide 1/1 scaling */ - cinfo->output_width = cinfo->image_width; - cinfo->output_height = cinfo->image_height; - cinfo->min_DCT_scaled_size = DCTSIZE; - } - /* In selecting the actual DCT scaling for each component, we try to - * scale up the chroma components via IDCT scaling rather than upsampling. - * This saves time if the upsampler gets to use 1:1 scaling. - * Note this code assumes that the supported DCT scalings are powers of 2. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - int ssize = cinfo->min_DCT_scaled_size; - while (ssize < DCTSIZE && - (compptr->h_samp_factor * ssize * 2 <= - cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && - (compptr->v_samp_factor * ssize * 2 <= - cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { - ssize = ssize * 2; - } - compptr->DCT_scaled_size = ssize; - } - - /* Recompute downsampled dimensions of components; - * application needs to know these if using raw downsampled data. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Size in samples, after IDCT scaling */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * - (long) (compptr->h_samp_factor * compptr->DCT_scaled_size), - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * - (long) (compptr->v_samp_factor * compptr->DCT_scaled_size), - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - } - -#else /* !IDCT_SCALING_SUPPORTED */ - - /* Hardwire it to "no scaling" */ - cinfo->output_width = cinfo->image_width; - cinfo->output_height = cinfo->image_height; - /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, - * and has computed unscaled downsampled_width and downsampled_height. - */ - -#endif /* IDCT_SCALING_SUPPORTED */ - - /* Report number of components in selected colorspace. */ - /* Probably this should be in the color conversion module... */ - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - cinfo->out_color_components = 1; - break; - case JCS_RGB: -#if RGB_PIXELSIZE != 3 - cinfo->out_color_components = RGB_PIXELSIZE; - break; -#endif /* else share code with YCbCr */ - case JCS_YCbCr: - cinfo->out_color_components = 3; - break; - case JCS_CMYK: - case JCS_YCCK: - cinfo->out_color_components = 4; - break; - default: /* else must be same colorspace as in file */ - cinfo->out_color_components = cinfo->num_components; - break; - } - cinfo->output_components = (cinfo->quantize_colors ? 1 : - cinfo->out_color_components); - - /* See if upsampler will want to emit more than one row at a time */ - if (use_merged_upsample(cinfo)) - cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; - else - cinfo->rec_outbuf_height = 1; -} - - -/* - * Several decompression processes need to range-limit values to the range - * 0..MAXJSAMPLE; the input value may fall somewhat outside this range - * due to noise introduced by quantization, roundoff error, etc. These - * processes are inner loops and need to be as fast as possible. On most - * machines, particularly CPUs with pipelines or instruction prefetch, - * a (subscript-check-less) C table lookup - * x = sample_range_limit[x]; - * is faster than explicit tests - * if (x < 0) x = 0; - * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; - * These processes all use a common table prepared by the routine below. - * - * For most steps we can mathematically guarantee that the initial value - * of x is within MAXJSAMPLE+1 of the legal range, so a table running from - * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial - * limiting step (just after the IDCT), a wildly out-of-range value is - * possible if the input data is corrupt. To avoid any chance of indexing - * off the end of memory and getting a bad-pointer trap, we perform the - * post-IDCT limiting thus: - * x = range_limit[x & MASK]; - * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit - * samples. Under normal circumstances this is more than enough range and - * a correct output will be generated; with bogus input data the mask will - * cause wraparound, and we will safely generate a bogus-but-in-range output. - * For the post-IDCT step, we want to convert the data from signed to unsigned - * representation by adding CENTERJSAMPLE at the same time that we limit it. - * So the post-IDCT limiting table ends up looking like this: - * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE, - * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), - * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), - * 0,1,...,CENTERJSAMPLE-1 - * Negative inputs select values from the upper half of the table after - * masking. - * - * We can save some space by overlapping the start of the post-IDCT table - * with the simpler range limiting table. The post-IDCT table begins at - * sample_range_limit + CENTERJSAMPLE. - * - * Note that the table is allocated in near data space on PCs; it's small - * enough and used often enough to justify this. - */ - -LOCAL(void) -prepare_range_limit_table (j_decompress_ptr cinfo) -/* Allocate and fill in the sample_range_limit table */ -{ - JSAMPLE * table; - int i; - - table = (JSAMPLE *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); - table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ - cinfo->sample_range_limit = table; - /* First segment of "simple" table: limit[x] = 0 for x < 0 */ - MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); - /* Main part of "simple" table: limit[x] = x */ - for (i = 0; i <= MAXJSAMPLE; i++) - table[i] = (JSAMPLE) i; - table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */ - /* End of simple table, rest of first half of post-IDCT table */ - for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) - table[i] = MAXJSAMPLE; - /* Second half of post-IDCT table */ - MEMZERO(table + (2 * (MAXJSAMPLE+1)), - (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); - MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), - cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); -} - - -/* - * Master selection of decompression modules. - * This is done once at jpeg_start_decompress time. We determine - * which modules will be used and give them appropriate initialization calls. - * We also initialize the decompressor input side to begin consuming data. - * - * Since jpeg_read_header has finished, we know what is in the SOF - * and (first) SOS markers. We also have all the application parameter - * settings. - */ - -LOCAL(void) -master_selection (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - boolean use_c_buffer; - long samplesperrow; - JDIMENSION jd_samplesperrow; - - /* Initialize dimensions and other stuff */ - jpeg_calc_output_dimensions(cinfo); - prepare_range_limit_table(cinfo); - - /* Width of an output scanline must be representable as JDIMENSION. */ - samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; - jd_samplesperrow = (JDIMENSION) samplesperrow; - if ((long) jd_samplesperrow != samplesperrow) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - - /* Initialize my private state */ - master->pass_number = 0; - master->using_merged_upsample = use_merged_upsample(cinfo); - - /* Color quantizer selection */ - master->quantizer_1pass = NULL; - master->quantizer_2pass = NULL; - /* No mode changes if not using buffered-image mode. */ - if (! cinfo->quantize_colors || ! cinfo->buffered_image) { - cinfo->enable_1pass_quant = FALSE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; - } - if (cinfo->quantize_colors) { - if (cinfo->raw_data_out) - ERREXIT(cinfo, JERR_NOTIMPL); - /* 2-pass quantizer only works in 3-component color space. */ - if (cinfo->out_color_components != 3) { - cinfo->enable_1pass_quant = TRUE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; - cinfo->colormap = NULL; - } else if (cinfo->colormap != NULL) { - cinfo->enable_external_quant = TRUE; - } else if (cinfo->two_pass_quantize) { - cinfo->enable_2pass_quant = TRUE; - } else { - cinfo->enable_1pass_quant = TRUE; - } - - if (cinfo->enable_1pass_quant) { -#ifdef QUANT_1PASS_SUPPORTED - jinit_1pass_quantizer(cinfo); - master->quantizer_1pass = cinfo->cquantize; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - - /* We use the 2-pass code to map to external colormaps. */ - if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) { -#ifdef QUANT_2PASS_SUPPORTED - jinit_2pass_quantizer(cinfo); - master->quantizer_2pass = cinfo->cquantize; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - /* If both quantizers are initialized, the 2-pass one is left active; - * this is necessary for starting with quantization to an external map. - */ - } - - /* Post-processing: in particular, color conversion first */ - if (! cinfo->raw_data_out) { - if (master->using_merged_upsample) { -#ifdef UPSAMPLE_MERGING_SUPPORTED - jinit_merged_upsampler(cinfo); /* does color conversion too */ -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - jinit_color_deconverter(cinfo); - jinit_upsampler(cinfo); - } - jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant); - } - /* Inverse DCT */ - jinit_inverse_dct(cinfo); - /* Entropy decoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef D_PROGRESSIVE_SUPPORTED - jinit_phuff_decoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_decoder(cinfo); - } - - /* Initialize principal buffer controllers. */ - use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; - jinit_d_coef_controller(cinfo, use_c_buffer); - - if (! cinfo->raw_data_out) - jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Initialize input side of decompressor to consume first scan. */ - (*cinfo->inputctl->start_input_pass) (cinfo); - -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* If jpeg_start_decompress will read the whole file, initialize - * progress monitoring appropriately. The input step is counted - * as one pass. - */ - if (cinfo->progress != NULL && ! cinfo->buffered_image && - cinfo->inputctl->has_multiple_scans) { - int nscans; - /* Estimate number of scans to set pass_limit. */ - if (cinfo->progressive_mode) { - /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ - nscans = 2 + 3 * cinfo->num_components; - } else { - /* For a nonprogressive multiscan file, estimate 1 scan per component. */ - nscans = cinfo->num_components; - } - cinfo->progress->pass_counter = 0L; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; - cinfo->progress->completed_passes = 0; - cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2); - /* Count the input pass as done */ - master->pass_number++; - } -#endif /* D_MULTISCAN_FILES_SUPPORTED */ -} - - -/* - * Per-pass setup. - * This is called at the beginning of each output pass. We determine which - * modules will be active during this pass and give them appropriate - * start_pass calls. We also set is_dummy_pass to indicate whether this - * is a "real" output pass or a dummy pass for color quantization. - * (In the latter case, jdapistd.c will crank the pass to completion.) - */ - -METHODDEF(void) -prepare_for_output_pass (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - if (master->pub.is_dummy_pass) { -#ifdef QUANT_2PASS_SUPPORTED - /* Final pass of 2-pass quantization */ - master->pub.is_dummy_pass = FALSE; - (*cinfo->cquantize->start_pass) (cinfo, FALSE); - (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); - (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* QUANT_2PASS_SUPPORTED */ - } else { - if (cinfo->quantize_colors && cinfo->colormap == NULL) { - /* Select new quantization method */ - if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { - cinfo->cquantize = master->quantizer_2pass; - master->pub.is_dummy_pass = TRUE; - } else if (cinfo->enable_1pass_quant) { - cinfo->cquantize = master->quantizer_1pass; - } else { - ERREXIT(cinfo, JERR_MODE_CHANGE); - } - } - (*cinfo->idct->start_pass) (cinfo); - (*cinfo->coef->start_output_pass) (cinfo); - if (! cinfo->raw_data_out) { - if (! master->using_merged_upsample) - (*cinfo->cconvert->start_pass) (cinfo); - (*cinfo->upsample->start_pass) (cinfo); - if (cinfo->quantize_colors) - (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); - (*cinfo->post->start_pass) (cinfo, - (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); - (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); - } - } - - /* Set up progress monitor's pass info if present */ - if (cinfo->progress != NULL) { - cinfo->progress->completed_passes = master->pass_number; - cinfo->progress->total_passes = master->pass_number + - (master->pub.is_dummy_pass ? 2 : 1); - /* In buffered-image mode, we assume one more output pass if EOI not - * yet reached, but no more passes if EOI has been reached. - */ - if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { - cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); - } - } -} - - -/* - * Finish up at end of an output pass. - */ - -METHODDEF(void) -finish_output_pass (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - if (cinfo->quantize_colors) - (*cinfo->cquantize->finish_pass) (cinfo); - master->pass_number++; -} - - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Switch to a new external colormap between output passes. - */ - -GLOBAL(void) -jpeg_new_colormap (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - /* Prevent application from calling me at wrong times */ - if (cinfo->global_state != DSTATE_BUFIMAGE) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (cinfo->quantize_colors && cinfo->enable_external_quant && - cinfo->colormap != NULL) { - /* Select 2-pass quantizer for external colormap use */ - cinfo->cquantize = master->quantizer_2pass; - /* Notify quantizer of colormap change */ - (*cinfo->cquantize->new_color_map) (cinfo); - master->pub.is_dummy_pass = FALSE; /* just in case */ - } else - ERREXIT(cinfo, JERR_MODE_CHANGE); -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - - -/* - * Initialize master decompression control and select active modules. - * This is performed at the start of jpeg_start_decompress. - */ - -GLOBAL(void) -jinit_master_decompress (j_decompress_ptr cinfo) -{ - my_master_ptr master; - - master = (my_master_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_decomp_master)); - cinfo->master = (struct jpeg_decomp_master *) master; - master->pub.prepare_for_output_pass = prepare_for_output_pass; - master->pub.finish_output_pass = finish_output_pass; - - master->pub.is_dummy_pass = FALSE; - - master_selection(cinfo); -} diff --git a/freeimage241/Source/LibJPEG/jdmerge.c b/freeimage241/Source/LibJPEG/jdmerge.c deleted file mode 100644 index 3744446..0000000 --- a/freeimage241/Source/LibJPEG/jdmerge.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * jdmerge.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains code for merged upsampling/color conversion. - * - * This file combines functions from jdsample.c and jdcolor.c; - * read those files first to understand what's going on. - * - * When the chroma components are to be upsampled by simple replication - * (ie, box filtering), we can save some work in color conversion by - * calculating all the output pixels corresponding to a pair of chroma - * samples at one time. In the conversion equations - * R = Y + K1 * Cr - * G = Y + K2 * Cb + K3 * Cr - * B = Y + K4 * Cb - * only the Y term varies among the group of pixels corresponding to a pair - * of chroma samples, so the rest of the terms can be calculated just once. - * At typical sampling ratios, this eliminates half or three-quarters of the - * multiplications needed for color conversion. - * - * This file currently provides implementations for the following cases: - * YCbCr => RGB color conversion only. - * Sampling ratios of 2h1v or 2h2v. - * No scaling needed at upsample time. - * Corner-aligned (non-CCIR601) sampling alignment. - * Other special cases could be added, but in most applications these are - * the only common cases. (For uncommon cases we fall back on the more - * general code in jdsample.c and jdcolor.c.) - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef UPSAMPLE_MERGING_SUPPORTED - - -/* Private subobject */ - -typedef struct { - struct jpeg_upsampler pub; /* public fields */ - - /* Pointer to routine to do actual upsampling/conversion of one row group */ - JMETHOD(void, upmethod, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf)); - - /* Private state for YCC->RGB conversion */ - int * Cr_r_tab; /* => table for Cr to R conversion */ - int * Cb_b_tab; /* => table for Cb to B conversion */ - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ - - /* For 2:1 vertical sampling, we produce two output rows at a time. - * We need a "spare" row buffer to hold the second output row if the - * application provides just a one-row buffer; we also use the spare - * to discard the dummy last row if the image height is odd. - */ - JSAMPROW spare_row; - boolean spare_full; /* T if spare buffer is occupied */ - - JDIMENSION out_row_width; /* samples per output row */ - JDIMENSION rows_to_go; /* counts rows remaining in image */ -} my_upsampler; - -typedef my_upsampler * my_upsample_ptr; - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. - * This is taken directly from jdcolor.c; see that file for more info. - */ - -LOCAL(void) -build_ycc_rgb_table (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - int i; - INT32 x; - SHIFT_TEMPS - - upsample->Cr_r_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - upsample->Cb_b_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - upsample->Cr_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - upsample->Cb_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - - for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { - /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ - /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ - /* Cr=>R value is nearest int to 1.40200 * x */ - upsample->Cr_r_tab[i] = (int) - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); - /* Cb=>B value is nearest int to 1.77200 * x */ - upsample->Cb_b_tab[i] = (int) - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); - /* Cr=>G value is scaled-up -0.71414 * x */ - upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x; - /* Cb=>G value is scaled-up -0.34414 * x */ - /* We also add in ONE_HALF so that need not do it in inner loop */ - upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; - } -} - - -/* - * Initialize for an upsampling pass. - */ - -METHODDEF(void) -start_pass_merged_upsample (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Mark the spare buffer empty */ - upsample->spare_full = FALSE; - /* Initialize total-height counter for detecting bottom of image */ - upsample->rows_to_go = cinfo->output_height; -} - - -/* - * Control routine to do upsampling (and color conversion). - * - * The control routine just handles the row buffering considerations. - */ - -METHODDEF(void) -merged_2v_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -/* 2:1 vertical sampling case: may need a spare row. */ -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - JSAMPROW work_ptrs[2]; - JDIMENSION num_rows; /* number of rows returned to caller */ - - if (upsample->spare_full) { - /* If we have a spare row saved from a previous cycle, just return it. */ - jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, - 1, upsample->out_row_width); - num_rows = 1; - upsample->spare_full = FALSE; - } else { - /* Figure number of rows to return to caller. */ - num_rows = 2; - /* Not more than the distance to the end of the image. */ - if (num_rows > upsample->rows_to_go) - num_rows = upsample->rows_to_go; - /* And not more than what the client can accept: */ - out_rows_avail -= *out_row_ctr; - if (num_rows > out_rows_avail) - num_rows = out_rows_avail; - /* Create output pointer array for upsampler. */ - work_ptrs[0] = output_buf[*out_row_ctr]; - if (num_rows > 1) { - work_ptrs[1] = output_buf[*out_row_ctr + 1]; - } else { - work_ptrs[1] = upsample->spare_row; - upsample->spare_full = TRUE; - } - /* Now do the upsampling. */ - (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); - } - - /* Adjust counts */ - *out_row_ctr += num_rows; - upsample->rows_to_go -= num_rows; - /* When the buffer is emptied, declare this input row group consumed */ - if (! upsample->spare_full) - (*in_row_group_ctr)++; -} - - -METHODDEF(void) -merged_1v_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -/* 1:1 vertical sampling case: much easier, never need a spare row. */ -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Just do the upsampling. */ - (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, - output_buf + *out_row_ctr); - /* Adjust counts */ - (*out_row_ctr)++; - (*in_row_group_ctr)++; -} - - -/* - * These are the routines invoked by the control routines to do - * the actual upsampling/conversion. One row group is processed per call. - * - * Note: since we may be writing directly into application-supplied buffers, - * we have to be honest about the output width; we can't assume the buffer - * has been rounded up to an even width. - */ - - -/* - * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. - */ - -METHODDEF(void) -h2v1_merged_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - register int y, cred, cgreen, cblue; - int cb, cr; - register JSAMPROW outptr; - JSAMPROW inptr0, inptr1, inptr2; - JDIMENSION col; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - int * Crrtab = upsample->Cr_r_tab; - int * Cbbtab = upsample->Cb_b_tab; - INT32 * Crgtab = upsample->Cr_g_tab; - INT32 * Cbgtab = upsample->Cb_g_tab; - SHIFT_TEMPS - - inptr0 = input_buf[0][in_row_group_ctr]; - inptr1 = input_buf[1][in_row_group_ctr]; - inptr2 = input_buf[2][in_row_group_ctr]; - outptr = output_buf[0]; - /* Loop for each pair of output pixels */ - for (col = cinfo->output_width >> 1; col > 0; col--) { - /* Do the chroma part of the calculation */ - cb = GETJSAMPLE(*inptr1++); - cr = GETJSAMPLE(*inptr2++); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - /* Fetch 2 Y values and emit 2 pixels */ - y = GETJSAMPLE(*inptr0++); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - outptr += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr0++); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - outptr += RGB_PIXELSIZE; - } - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - cb = GETJSAMPLE(*inptr1); - cr = GETJSAMPLE(*inptr2); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - y = GETJSAMPLE(*inptr0); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - } -} - - -/* - * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. - */ - -METHODDEF(void) -h2v2_merged_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - register int y, cred, cgreen, cblue; - int cb, cr; - register JSAMPROW outptr0, outptr1; - JSAMPROW inptr00, inptr01, inptr1, inptr2; - JDIMENSION col; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - int * Crrtab = upsample->Cr_r_tab; - int * Cbbtab = upsample->Cb_b_tab; - INT32 * Crgtab = upsample->Cr_g_tab; - INT32 * Cbgtab = upsample->Cb_g_tab; - SHIFT_TEMPS - - inptr00 = input_buf[0][in_row_group_ctr*2]; - inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; - inptr1 = input_buf[1][in_row_group_ctr]; - inptr2 = input_buf[2][in_row_group_ctr]; - outptr0 = output_buf[0]; - outptr1 = output_buf[1]; - /* Loop for each group of output pixels */ - for (col = cinfo->output_width >> 1; col > 0; col--) { - /* Do the chroma part of the calculation */ - cb = GETJSAMPLE(*inptr1++); - cr = GETJSAMPLE(*inptr2++); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - /* Fetch 4 Y values and emit 4 pixels */ - y = GETJSAMPLE(*inptr00++); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - outptr0 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr00++); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - outptr0 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr01++); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - outptr1 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr01++); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - outptr1 += RGB_PIXELSIZE; - } - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - cb = GETJSAMPLE(*inptr1); - cr = GETJSAMPLE(*inptr2); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - y = GETJSAMPLE(*inptr00); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - y = GETJSAMPLE(*inptr01); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - } -} - - -/* - * Module initialization routine for merged upsampling/color conversion. - * - * NB: this is called under the conditions determined by use_merged_upsample() - * in jdmaster.c. That routine MUST correspond to the actual capabilities - * of this module; no safety checks are made here. - */ - -GLOBAL(void) -jinit_merged_upsampler (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample; - - upsample = (my_upsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_upsampler)); - cinfo->upsample = (struct jpeg_upsampler *) upsample; - upsample->pub.start_pass = start_pass_merged_upsample; - upsample->pub.need_context_rows = FALSE; - - upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; - - if (cinfo->max_v_samp_factor == 2) { - upsample->pub.upsample = merged_2v_upsample; - upsample->upmethod = h2v2_merged_upsample; - /* Allocate a spare row buffer */ - upsample->spare_row = (JSAMPROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); - } else { - upsample->pub.upsample = merged_1v_upsample; - upsample->upmethod = h2v1_merged_upsample; - /* No spare row needed */ - upsample->spare_row = NULL; - } - - build_ycc_rgb_table(cinfo); -} - -#endif /* UPSAMPLE_MERGING_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jdphuff.c b/freeimage241/Source/LibJPEG/jdphuff.c deleted file mode 100644 index 2267809..0000000 --- a/freeimage241/Source/LibJPEG/jdphuff.c +++ /dev/null @@ -1,668 +0,0 @@ -/* - * jdphuff.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy decoding routines for progressive JPEG. - * - * Much of the complexity here has to do with supporting input suspension. - * If the data source module demands suspension, we want to be able to back - * up to the start of the current MCU. To do this, we copy state variables - * into local working storage, and update them back to the permanent - * storage only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdhuff.h" /* Declarations shared with jdhuff.c */ - - -#ifdef D_PROGRESSIVE_SUPPORTED - -/* - * Expanded entropy decoder object for progressive Huffman decoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - unsigned int EOBRUN; /* remaining EOBs in EOBRUN */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).EOBRUN = (src).EOBRUN, \ - (dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_decoder pub; /* public fields */ - - /* These fields are loaded into local variables at start of each MCU. - * In case of suspension, we exit WITHOUT updating them. - */ - bitread_perm_state bitstate; /* Bit buffer at start of MCU */ - savable_state saved; /* Other state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - d_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; - - d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */ -} phuff_entropy_decoder; - -typedef phuff_entropy_decoder * phuff_entropy_ptr; - -/* Forward declarations */ -METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); - - -/* - * Initialize for a Huffman-compressed scan. - */ - -METHODDEF(void) -start_pass_phuff_decoder (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band, bad; - int ci, coefi, tbl; - int *coef_bit_ptr; - jpeg_component_info * compptr; - - is_DC_band = (cinfo->Ss == 0); - - /* Validate scan parameters */ - bad = FALSE; - if (is_DC_band) { - if (cinfo->Se != 0) - bad = TRUE; - } else { - /* need not check Ss/Se < 0 since they came from unsigned bytes */ - if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2) - bad = TRUE; - /* AC scans may have only one component */ - if (cinfo->comps_in_scan != 1) - bad = TRUE; - } - if (cinfo->Ah != 0) { - /* Successive approximation refinement scan: must have Al = Ah-1. */ - if (cinfo->Al != cinfo->Ah-1) - bad = TRUE; - } - if (cinfo->Al > 13) /* need not check for < 0 */ - bad = TRUE; - /* Arguably the maximum Al value should be less than 13 for 8-bit precision, - * but the spec doesn't say so, and we try to be liberal about what we - * accept. Note: large Al values could result in out-of-range DC - * coefficients during early scans, leading to bizarre displays due to - * overflows in the IDCT math. But we won't crash. - */ - if (bad) - ERREXIT4(cinfo, JERR_BAD_PROGRESSION, - cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); - /* Update progression status, and verify that scan order is legal. - * Note that inter-scan inconsistencies are treated as warnings - * not fatal errors ... not clear if this is right way to behave. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - int cindex = cinfo->cur_comp_info[ci]->component_index; - coef_bit_ptr = & cinfo->coef_bits[cindex][0]; - if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ - WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); - for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { - int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; - if (cinfo->Ah != expected) - WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); - coef_bit_ptr[coefi] = cinfo->Al; - } - } - - /* Select MCU decoding routine */ - if (cinfo->Ah == 0) { - if (is_DC_band) - entropy->pub.decode_mcu = decode_mcu_DC_first; - else - entropy->pub.decode_mcu = decode_mcu_AC_first; - } else { - if (is_DC_band) - entropy->pub.decode_mcu = decode_mcu_DC_refine; - else - entropy->pub.decode_mcu = decode_mcu_AC_refine; - } - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Make sure requested tables are present, and compute derived tables. - * We may build same derived table more than once, but it's not expensive. - */ - if (is_DC_band) { - if (cinfo->Ah == 0) { /* DC refinement needs no table */ - tbl = compptr->dc_tbl_no; - jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, - & entropy->derived_tbls[tbl]); - } - } else { - tbl = compptr->ac_tbl_no; - jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, - & entropy->derived_tbls[tbl]); - /* remember the single active table */ - entropy->ac_derived_tbl = entropy->derived_tbls[tbl]; - } - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Initialize bitread state variables */ - entropy->bitstate.bits_left = 0; - entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ - entropy->pub.insufficient_data = FALSE; - - /* Initialize private state variables */ - entropy->saved.EOBRUN = 0; - - /* Initialize restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; -} - - -/* - * Figure F.12: extend sign bit. - * On some machines, a shift and add will be faster than a table lookup. - */ - -#ifdef AVOID_TABLES - -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) - -#else - -#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) - -static const int extend_test[16] = /* entry n is 2**(n-1) */ - { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, - 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; - -static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ - { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, - ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, - ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, - ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; - -#endif /* AVOID_TABLES */ - - -/* - * Check for a restart marker & resynchronize decoder. - * Returns FALSE if must suspend. - */ - -LOCAL(boolean) -process_restart (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int ci; - - /* Throw away any unused bits remaining in bit buffer; */ - /* include any full bytes in next_marker's count of discarded bytes */ - cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; - entropy->bitstate.bits_left = 0; - - /* Advance past the RSTn marker */ - if (! (*cinfo->marker->read_restart_marker) (cinfo)) - return FALSE; - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - /* Re-init EOB run count, too */ - entropy->saved.EOBRUN = 0; - - /* Reset restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; - - /* Reset out-of-data flag, unless read_restart_marker left us smack up - * against a marker. In that case we will end up treating the next data - * segment as empty, and we can avoid producing bogus output pixels by - * leaving the flag set. - */ - if (cinfo->unread_marker == 0) - entropy->pub.insufficient_data = FALSE; - - return TRUE; -} - - -/* - * Huffman MCU decoding. - * Each of these routines decodes and returns one MCU's worth of - * Huffman-compressed coefficients. - * The coefficients are reordered from zigzag order into natural array order, - * but are not dequantized. - * - * The i'th block of the MCU is stored into the block pointed to by - * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. - * - * We return FALSE if data source requested suspension. In that case no - * changes have been made to permanent state. (Exception: some output - * coefficients may already have been assigned. This is harmless for - * spectral selection, since we'll just re-assign them on the next call. - * Successive approximation AC refinement has to be more careful, however.) - */ - -/* - * MCU decoding for DC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Al = cinfo->Al; - register int s, r; - int blkn, ci; - JBLOCKROW block; - BITREAD_STATE_VARS; - savable_state state; - d_derived_tbl * tbl; - jpeg_component_info * compptr; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(state, entropy->saved); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - tbl = entropy->derived_tbls[compptr->dc_tbl_no]; - - /* Decode a single block's worth of coefficients */ - - /* Section F.2.2.1: decode the DC coefficient difference */ - HUFF_DECODE(s, br_state, tbl, return FALSE, label1); - if (s) { - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - } - - /* Convert DC difference to actual value, update last_dc_val */ - s += state.last_dc_val[ci]; - state.last_dc_val[ci] = s; - /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */ - (*block)[0] = (JCOEF) (s << Al); - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(entropy->saved, state); - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for AC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Se = cinfo->Se; - int Al = cinfo->Al; - register int s, k, r; - unsigned int EOBRUN; - JBLOCKROW block; - BITREAD_STATE_VARS; - d_derived_tbl * tbl; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state. - * We can avoid loading/saving bitread state if in an EOB run. - */ - EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ - - /* There is always only one block per MCU */ - - if (EOBRUN > 0) /* if it's a band of zeroes... */ - EOBRUN--; /* ...process it now (we do nothing) */ - else { - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - block = MCU_data[0]; - tbl = entropy->ac_derived_tbl; - - for (k = cinfo->Ss; k <= Se; k++) { - HUFF_DECODE(s, br_state, tbl, return FALSE, label2); - r = s >> 4; - s &= 15; - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - /* Scale and output coefficient in natural (dezigzagged) order */ - (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); - } else { - if (r == 15) { /* ZRL */ - k += 15; /* skip 15 zeroes in band */ - } else { /* EOBr, run length is 2^r + appended bits */ - EOBRUN = 1 << r; - if (r) { /* EOBr, r > 0 */ - CHECK_BIT_BUFFER(br_state, r, return FALSE); - r = GET_BITS(r); - EOBRUN += r; - } - EOBRUN--; /* this band is processed at this moment */ - break; /* force end-of-band */ - } - } - } - - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - } - - /* Completed MCU, so update state */ - entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for DC successive approximation refinement scan. - * Note: we assume such scans can be multi-component, although the spec - * is not very clear on the point. - */ - -METHODDEF(boolean) -decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int blkn; - JBLOCKROW block; - BITREAD_STATE_VARS; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* Not worth the cycles to check insufficient_data here, - * since we will not change the data anyway if we read zeroes. - */ - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - - /* Encoded data is simply the next bit of the two's-complement DC value */ - CHECK_BIT_BUFFER(br_state, 1, return FALSE); - if (GET_BITS(1)) - (*block)[0] |= p1; - /* Note: since we use |=, repeating the assignment later is safe */ - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for AC successive approximation refinement scan. - */ - -METHODDEF(boolean) -decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Se = cinfo->Se; - int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ - register int s, k, r; - unsigned int EOBRUN; - JBLOCKROW block; - JCOEFPTR thiscoef; - BITREAD_STATE_VARS; - d_derived_tbl * tbl; - int num_newnz; - int newnz_pos[DCTSIZE2]; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, don't modify the MCU. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ - - /* There is always only one block per MCU */ - block = MCU_data[0]; - tbl = entropy->ac_derived_tbl; - - /* If we are forced to suspend, we must undo the assignments to any newly - * nonzero coefficients in the block, because otherwise we'd get confused - * next time about which coefficients were already nonzero. - * But we need not undo addition of bits to already-nonzero coefficients; - * instead, we can test the current bit to see if we already did it. - */ - num_newnz = 0; - - /* initialize coefficient loop counter to start of band */ - k = cinfo->Ss; - - if (EOBRUN == 0) { - for (; k <= Se; k++) { - HUFF_DECODE(s, br_state, tbl, goto undoit, label3); - r = s >> 4; - s &= 15; - if (s) { - if (s != 1) /* size of new coef should always be 1 */ - WARNMS(cinfo, JWRN_HUFF_BAD_CODE); - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) - s = p1; /* newly nonzero coef is positive */ - else - s = m1; /* newly nonzero coef is negative */ - } else { - if (r != 15) { - EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */ - if (r) { - CHECK_BIT_BUFFER(br_state, r, goto undoit); - r = GET_BITS(r); - EOBRUN += r; - } - break; /* rest of block is handled by EOB logic */ - } - /* note s = 0 for processing ZRL */ - } - /* Advance over already-nonzero coefs and r still-zero coefs, - * appending correction bits to the nonzeroes. A correction bit is 1 - * if the absolute value of the coefficient must be increased. - */ - do { - thiscoef = *block + jpeg_natural_order[k]; - if (*thiscoef != 0) { - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) { - if ((*thiscoef & p1) == 0) { /* do nothing if already set it */ - if (*thiscoef >= 0) - *thiscoef += p1; - else - *thiscoef += m1; - } - } - } else { - if (--r < 0) - break; /* reached target zero coefficient */ - } - k++; - } while (k <= Se); - if (s) { - int pos = jpeg_natural_order[k]; - /* Output newly nonzero coefficient */ - (*block)[pos] = (JCOEF) s; - /* Remember its position in case we have to suspend */ - newnz_pos[num_newnz++] = pos; - } - } - } - - if (EOBRUN > 0) { - /* Scan any remaining coefficient positions after the end-of-band - * (the last newly nonzero coefficient, if any). Append a correction - * bit to each already-nonzero coefficient. A correction bit is 1 - * if the absolute value of the coefficient must be increased. - */ - for (; k <= Se; k++) { - thiscoef = *block + jpeg_natural_order[k]; - if (*thiscoef != 0) { - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) { - if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */ - if (*thiscoef >= 0) - *thiscoef += p1; - else - *thiscoef += m1; - } - } - } - } - /* Count one block completed in EOB run */ - EOBRUN--; - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; - -undoit: - /* Re-zero any output coefficients that we made newly nonzero */ - while (num_newnz > 0) - (*block)[newnz_pos[--num_newnz]] = 0; - - return FALSE; -} - - -/* - * Module initialization routine for progressive Huffman entropy decoding. - */ - -GLOBAL(void) -jinit_phuff_decoder (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy; - int *coef_bit_ptr; - int ci, i; - - entropy = (phuff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(phuff_entropy_decoder)); - cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; - entropy->pub.start_pass = start_pass_phuff_decoder; - - /* Mark derived tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->derived_tbls[i] = NULL; - } - - /* Create progression status table */ - cinfo->coef_bits = (int (*)[DCTSIZE2]) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components*DCTSIZE2*SIZEOF(int)); - coef_bit_ptr = & cinfo->coef_bits[0][0]; - for (ci = 0; ci < cinfo->num_components; ci++) - for (i = 0; i < DCTSIZE2; i++) - *coef_bit_ptr++ = -1; -} - -#endif /* D_PROGRESSIVE_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jdpostct.c b/freeimage241/Source/LibJPEG/jdpostct.c deleted file mode 100644 index 571563d..0000000 --- a/freeimage241/Source/LibJPEG/jdpostct.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * jdpostct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the decompression postprocessing controller. - * This controller manages the upsampling, color conversion, and color - * quantization/reduction steps; specifically, it controls the buffering - * between upsample/color conversion and color quantization/reduction. - * - * If no color quantization/reduction is required, then this module has no - * work to do, and it just hands off to the upsample/color conversion code. - * An integrated upsample/convert/quantize process would replace this module - * entirely. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_post_controller pub; /* public fields */ - - /* Color quantization source buffer: this holds output data from - * the upsample/color conversion step to be passed to the quantizer. - * For two-pass color quantization, we need a full-image buffer; - * for one-pass operation, a strip buffer is sufficient. - */ - jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */ - JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */ - JDIMENSION strip_height; /* buffer size in rows */ - /* for two-pass mode only: */ - JDIMENSION starting_row; /* row # of first row in current strip */ - JDIMENSION next_row; /* index of next row to fill/empty in strip */ -} my_post_controller; - -typedef my_post_controller * my_post_ptr; - - -/* Forward declarations */ -METHODDEF(void) post_process_1pass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -#ifdef QUANT_2PASS_SUPPORTED -METHODDEF(void) post_process_prepass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -METHODDEF(void) post_process_2pass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -#endif - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (cinfo->quantize_colors) { - /* Single-pass processing with color quantization. */ - post->pub.post_process_data = post_process_1pass; - /* We could be doing buffered-image output before starting a 2-pass - * color quantization; in that case, jinit_d_post_controller did not - * allocate a strip buffer. Use the virtual-array buffer as workspace. - */ - if (post->buffer == NULL) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - (JDIMENSION) 0, post->strip_height, TRUE); - } - } else { - /* For single-pass processing without color quantization, - * I have no work to do; just call the upsampler directly. - */ - post->pub.post_process_data = cinfo->upsample->upsample; - } - break; -#ifdef QUANT_2PASS_SUPPORTED - case JBUF_SAVE_AND_PASS: - /* First pass of 2-pass quantization */ - if (post->whole_image == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - post->pub.post_process_data = post_process_prepass; - break; - case JBUF_CRANK_DEST: - /* Second pass of 2-pass quantization */ - if (post->whole_image == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - post->pub.post_process_data = post_process_2pass; - break; -#endif /* QUANT_2PASS_SUPPORTED */ - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } - post->starting_row = post->next_row = 0; -} - - -/* - * Process some data in the one-pass (strip buffer) case. - * This is used for color precision reduction as well as one-pass quantization. - */ - -METHODDEF(void) -post_process_1pass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION num_rows, max_rows; - - /* Fill the buffer, but not more than what we can dump out in one go. */ - /* Note we rely on the upsampler to detect bottom of image. */ - max_rows = out_rows_avail - *out_row_ctr; - if (max_rows > post->strip_height) - max_rows = post->strip_height; - num_rows = 0; - (*cinfo->upsample->upsample) (cinfo, - input_buf, in_row_group_ctr, in_row_groups_avail, - post->buffer, &num_rows, max_rows); - /* Quantize and emit data. */ - (*cinfo->cquantize->color_quantize) (cinfo, - post->buffer, output_buf + *out_row_ctr, (int) num_rows); - *out_row_ctr += num_rows; -} - - -#ifdef QUANT_2PASS_SUPPORTED - -/* - * Process some data in the first pass of 2-pass quantization. - */ - -METHODDEF(void) -post_process_prepass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION old_next_row, num_rows; - - /* Reposition virtual buffer if at start of strip. */ - if (post->next_row == 0) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - post->starting_row, post->strip_height, TRUE); - } - - /* Upsample some data (up to a strip height's worth). */ - old_next_row = post->next_row; - (*cinfo->upsample->upsample) (cinfo, - input_buf, in_row_group_ctr, in_row_groups_avail, - post->buffer, &post->next_row, post->strip_height); - - /* Allow quantizer to scan new data. No data is emitted, */ - /* but we advance out_row_ctr so outer loop can tell when we're done. */ - if (post->next_row > old_next_row) { - num_rows = post->next_row - old_next_row; - (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row, - (JSAMPARRAY) NULL, (int) num_rows); - *out_row_ctr += num_rows; - } - - /* Advance if we filled the strip. */ - if (post->next_row >= post->strip_height) { - post->starting_row += post->strip_height; - post->next_row = 0; - } -} - - -/* - * Process some data in the second pass of 2-pass quantization. - */ - -METHODDEF(void) -post_process_2pass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION num_rows, max_rows; - - /* Reposition virtual buffer if at start of strip. */ - if (post->next_row == 0) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - post->starting_row, post->strip_height, FALSE); - } - - /* Determine number of rows to emit. */ - num_rows = post->strip_height - post->next_row; /* available in strip */ - max_rows = out_rows_avail - *out_row_ctr; /* available in output area */ - if (num_rows > max_rows) - num_rows = max_rows; - /* We have to check bottom of image here, can't depend on upsampler. */ - max_rows = cinfo->output_height - post->starting_row; - if (num_rows > max_rows) - num_rows = max_rows; - - /* Quantize and emit data. */ - (*cinfo->cquantize->color_quantize) (cinfo, - post->buffer + post->next_row, output_buf + *out_row_ctr, - (int) num_rows); - *out_row_ctr += num_rows; - - /* Advance if we filled the strip. */ - post->next_row += num_rows; - if (post->next_row >= post->strip_height) { - post->starting_row += post->strip_height; - post->next_row = 0; - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ - - -/* - * Initialize postprocessing controller. - */ - -GLOBAL(void) -jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_post_ptr post; - - post = (my_post_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_post_controller)); - cinfo->post = (struct jpeg_d_post_controller *) post; - post->pub.start_pass = start_pass_dpost; - post->whole_image = NULL; /* flag for no virtual arrays */ - post->buffer = NULL; /* flag for no strip buffer */ - - /* Create the quantization buffer, if needed */ - if (cinfo->quantize_colors) { - /* The buffer strip height is max_v_samp_factor, which is typically - * an efficient number of rows for upsampling to return. - * (In the presence of output rescaling, we might want to be smarter?) - */ - post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor; - if (need_full_buffer) { - /* Two-pass color quantization: need full-image storage. */ - /* We round up the number of rows to a multiple of the strip height. */ -#ifdef QUANT_2PASS_SUPPORTED - post->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - cinfo->output_width * cinfo->out_color_components, - (JDIMENSION) jround_up((long) cinfo->output_height, - (long) post->strip_height), - post->strip_height); -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif /* QUANT_2PASS_SUPPORTED */ - } else { - /* One-pass color quantization: just make a strip buffer. */ - post->buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width * cinfo->out_color_components, - post->strip_height); - } - } -} diff --git a/freeimage241/Source/LibJPEG/jdsample.c b/freeimage241/Source/LibJPEG/jdsample.c deleted file mode 100644 index 80ffefb..0000000 --- a/freeimage241/Source/LibJPEG/jdsample.c +++ /dev/null @@ -1,478 +0,0 @@ -/* - * jdsample.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains upsampling routines. - * - * Upsampling input data is counted in "row groups". A row group - * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) - * sample rows of each component. Upsampling will normally produce - * max_v_samp_factor pixel rows from each row group (but this could vary - * if the upsampler is applying a scale factor of its own). - * - * An excellent reference for image resampling is - * Digital Image Warping, George Wolberg, 1990. - * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Pointer to routine to upsample a single component */ -typedef JMETHOD(void, upsample1_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); - -/* Private subobject */ - -typedef struct { - struct jpeg_upsampler pub; /* public fields */ - - /* Color conversion buffer. When using separate upsampling and color - * conversion steps, this buffer holds one upsampled row group until it - * has been color converted and output. - * Note: we do not allocate any storage for component(s) which are full-size, - * ie do not need rescaling. The corresponding entry of color_buf[] is - * simply set to point to the input data array, thereby avoiding copying. - */ - JSAMPARRAY color_buf[MAX_COMPONENTS]; - - /* Per-component upsampling method pointers */ - upsample1_ptr methods[MAX_COMPONENTS]; - - int next_row_out; /* counts rows emitted from color_buf */ - JDIMENSION rows_to_go; /* counts rows remaining in image */ - - /* Height of an input row group for each component. */ - int rowgroup_height[MAX_COMPONENTS]; - - /* These arrays save pixel expansion factors so that int_expand need not - * recompute them each time. They are unused for other upsampling methods. - */ - UINT8 h_expand[MAX_COMPONENTS]; - UINT8 v_expand[MAX_COMPONENTS]; -} my_upsampler; - -typedef my_upsampler * my_upsample_ptr; - - -/* - * Initialize for an upsampling pass. - */ - -METHODDEF(void) -start_pass_upsample (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Mark the conversion buffer empty */ - upsample->next_row_out = cinfo->max_v_samp_factor; - /* Initialize total-height counter for detecting bottom of image */ - upsample->rows_to_go = cinfo->output_height; -} - - -/* - * Control routine to do upsampling (and color conversion). - * - * In this version we upsample each component independently. - * We upsample one row group into the conversion buffer, then apply - * color conversion a row at a time. - */ - -METHODDEF(void) -sep_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - int ci; - jpeg_component_info * compptr; - JDIMENSION num_rows; - - /* Fill the conversion buffer, if it's empty */ - if (upsample->next_row_out >= cinfo->max_v_samp_factor) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Invoke per-component upsample method. Notice we pass a POINTER - * to color_buf[ci], so that fullsize_upsample can change it. - */ - (*upsample->methods[ci]) (cinfo, compptr, - input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), - upsample->color_buf + ci); - } - upsample->next_row_out = 0; - } - - /* Color-convert and emit rows */ - - /* How many we have in the buffer: */ - num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out); - /* Not more than the distance to the end of the image. Need this test - * in case the image height is not a multiple of max_v_samp_factor: - */ - if (num_rows > upsample->rows_to_go) - num_rows = upsample->rows_to_go; - /* And not more than what the client can accept: */ - out_rows_avail -= *out_row_ctr; - if (num_rows > out_rows_avail) - num_rows = out_rows_avail; - - (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf, - (JDIMENSION) upsample->next_row_out, - output_buf + *out_row_ctr, - (int) num_rows); - - /* Adjust counts */ - *out_row_ctr += num_rows; - upsample->rows_to_go -= num_rows; - upsample->next_row_out += num_rows; - /* When the buffer is emptied, declare this input row group consumed */ - if (upsample->next_row_out >= cinfo->max_v_samp_factor) - (*in_row_group_ctr)++; -} - - -/* - * These are the routines invoked by sep_upsample to upsample pixel values - * of a single component. One row group is processed per call. - */ - - -/* - * For full-size components, we just make color_buf[ci] point at the - * input buffer, and thus avoid copying any data. Note that this is - * safe only because sep_upsample doesn't declare the input row group - * "consumed" until we are done color converting and emitting it. - */ - -METHODDEF(void) -fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - *output_data_ptr = input_data; -} - - -/* - * This is a no-op version used for "uninteresting" components. - * These components will not be referenced by color conversion. - */ - -METHODDEF(void) -noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - *output_data_ptr = NULL; /* safety check */ -} - - -/* - * This version handles any integral sampling ratios. - * This is not used for typical JPEG files, so it need not be fast. - * Nor, for that matter, is it particularly accurate: the algorithm is - * simple replication of the input pixel onto the corresponding output - * pixels. The hi-falutin sampling literature refers to this as a - * "box filter". A box filter tends to introduce visible artifacts, - * so if you are actually going to use 3:1 or 4:1 sampling ratios - * you would be well advised to improve this code. - */ - -METHODDEF(void) -int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - register int h; - JSAMPROW outend; - int h_expand, v_expand; - int inrow, outrow; - - h_expand = upsample->h_expand[compptr->component_index]; - v_expand = upsample->v_expand[compptr->component_index]; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - /* Generate one output row with proper horizontal expansion */ - inptr = input_data[inrow]; - outptr = output_data[outrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - for (h = h_expand; h > 0; h--) { - *outptr++ = invalue; - } - } - /* Generate any additional output rows by duplicating the first one */ - if (v_expand > 1) { - jcopy_sample_rows(output_data, outrow, output_data, outrow+1, - v_expand-1, cinfo->output_width); - } - inrow++; - outrow += v_expand; - } -} - - -/* - * Fast processing for the common case of 2:1 horizontal and 1:1 vertical. - * It's still a box filter. - */ - -METHODDEF(void) -h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - JSAMPROW outend; - int inrow; - - for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { - inptr = input_data[inrow]; - outptr = output_data[inrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - *outptr++ = invalue; - *outptr++ = invalue; - } - } -} - - -/* - * Fast processing for the common case of 2:1 horizontal and 2:1 vertical. - * It's still a box filter. - */ - -METHODDEF(void) -h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - JSAMPROW outend; - int inrow, outrow; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - inptr = input_data[inrow]; - outptr = output_data[outrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - *outptr++ = invalue; - *outptr++ = invalue; - } - jcopy_sample_rows(output_data, outrow, output_data, outrow+1, - 1, cinfo->output_width); - inrow++; - outrow += 2; - } -} - - -/* - * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. - * - * The upsampling algorithm is linear interpolation between pixel centers, - * also known as a "triangle filter". This is a good compromise between - * speed and visual quality. The centers of the output pixels are 1/4 and 3/4 - * of the way between input pixel centers. - * - * A note about the "bias" calculations: when rounding fractional values to - * integer, we do not want to always round 0.5 up to the next integer. - * If we did that, we'd introduce a noticeable bias towards larger values. - * Instead, this code is arranged so that 0.5 will be rounded up or down at - * alternate pixel locations (a simple ordered dither pattern). - */ - -METHODDEF(void) -h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register int invalue; - register JDIMENSION colctr; - int inrow; - - for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { - inptr = input_data[inrow]; - outptr = output_data[inrow]; - /* Special case for first column */ - invalue = GETJSAMPLE(*inptr++); - *outptr++ = (JSAMPLE) invalue; - *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2); - - for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { - /* General case: 3/4 * nearer pixel + 1/4 * further pixel */ - invalue = GETJSAMPLE(*inptr++) * 3; - *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2); - *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2); - } - - /* Special case for last column */ - invalue = GETJSAMPLE(*inptr); - *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2); - *outptr++ = (JSAMPLE) invalue; - } -} - - -/* - * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. - * Again a triangle filter; see comments for h2v1 case, above. - * - * It is OK for us to reference the adjacent input rows because we demanded - * context from the main buffer controller (see initialization code). - */ - -METHODDEF(void) -h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr0, inptr1, outptr; -#if BITS_IN_JSAMPLE == 8 - register int thiscolsum, lastcolsum, nextcolsum; -#else - register INT32 thiscolsum, lastcolsum, nextcolsum; -#endif - register JDIMENSION colctr; - int inrow, outrow, v; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - for (v = 0; v < 2; v++) { - /* inptr0 points to nearest input row, inptr1 points to next nearest */ - inptr0 = input_data[inrow]; - if (v == 0) /* next nearest is row above */ - inptr1 = input_data[inrow-1]; - else /* next nearest is row below */ - inptr1 = input_data[inrow+1]; - outptr = output_data[outrow++]; - - /* Special case for first column */ - thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); - lastcolsum = thiscolsum; thiscolsum = nextcolsum; - - for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { - /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */ - /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */ - nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); - lastcolsum = thiscolsum; thiscolsum = nextcolsum; - } - - /* Special case for last column */ - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4); - } - inrow++; - } -} - - -/* - * Module initialization routine for upsampling. - */ - -GLOBAL(void) -jinit_upsampler (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample; - int ci; - jpeg_component_info * compptr; - boolean need_buffer, do_fancy; - int h_in_group, v_in_group, h_out_group, v_out_group; - - upsample = (my_upsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_upsampler)); - cinfo->upsample = (struct jpeg_upsampler *) upsample; - upsample->pub.start_pass = start_pass_upsample; - upsample->pub.upsample = sep_upsample; - upsample->pub.need_context_rows = FALSE; /* until we find out differently */ - - if (cinfo->CCIR601_sampling) /* this isn't supported */ - ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); - - /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, - * so don't ask for it. - */ - do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1; - - /* Verify we can handle the sampling factors, select per-component methods, - * and create storage as needed. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Compute size of an "input group" after IDCT scaling. This many samples - * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. - */ - h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; - v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; - h_out_group = cinfo->max_h_samp_factor; - v_out_group = cinfo->max_v_samp_factor; - upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ - need_buffer = TRUE; - if (! compptr->component_needed) { - /* Don't bother to upsample an uninteresting component. */ - upsample->methods[ci] = noop_upsample; - need_buffer = FALSE; - } else if (h_in_group == h_out_group && v_in_group == v_out_group) { - /* Fullsize components can be processed without any work. */ - upsample->methods[ci] = fullsize_upsample; - need_buffer = FALSE; - } else if (h_in_group * 2 == h_out_group && - v_in_group == v_out_group) { - /* Special cases for 2h1v upsampling */ - if (do_fancy && compptr->downsampled_width > 2) - upsample->methods[ci] = h2v1_fancy_upsample; - else - upsample->methods[ci] = h2v1_upsample; - } else if (h_in_group * 2 == h_out_group && - v_in_group * 2 == v_out_group) { - /* Special cases for 2h2v upsampling */ - if (do_fancy && compptr->downsampled_width > 2) { - upsample->methods[ci] = h2v2_fancy_upsample; - upsample->pub.need_context_rows = TRUE; - } else - upsample->methods[ci] = h2v2_upsample; - } else if ((h_out_group % h_in_group) == 0 && - (v_out_group % v_in_group) == 0) { - /* Generic integral-factors upsampling method */ - upsample->methods[ci] = int_upsample; - upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group); - upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); - } else - ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); - if (need_buffer) { - upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) jround_up((long) cinfo->output_width, - (long) cinfo->max_h_samp_factor), - (JDIMENSION) cinfo->max_v_samp_factor); - } - } -} diff --git a/freeimage241/Source/LibJPEG/jdtrans.c b/freeimage241/Source/LibJPEG/jdtrans.c deleted file mode 100644 index 6c0ab71..0000000 --- a/freeimage241/Source/LibJPEG/jdtrans.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * jdtrans.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains library routines for transcoding decompression, - * that is, reading raw DCT coefficient arrays from an input JPEG file. - * The routines in jdapimin.c will also be needed by a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); - - -/* - * Read the coefficient arrays from a JPEG file. - * jpeg_read_header must be completed before calling this. - * - * The entire image is read into a set of virtual coefficient-block arrays, - * one per component. The return value is a pointer to the array of - * virtual-array descriptors. These can be manipulated directly via the - * JPEG memory manager, or handed off to jpeg_write_coefficients(). - * To release the memory occupied by the virtual arrays, call - * jpeg_finish_decompress() when done with the data. - * - * An alternative usage is to simply obtain access to the coefficient arrays - * during a buffered-image-mode decompression operation. This is allowed - * after any jpeg_finish_output() call. The arrays can be accessed until - * jpeg_finish_decompress() is called. (Note that any call to the library - * may reposition the arrays, so don't rely on access_virt_barray() results - * to stay valid across library calls.) - * - * Returns NULL if suspended. This case need be checked only if - * a suspending data source is used. - */ - -GLOBAL(jvirt_barray_ptr *) -jpeg_read_coefficients (j_decompress_ptr cinfo) -{ - if (cinfo->global_state == DSTATE_READY) { - /* First call: initialize active modules */ - transdecode_master_selection(cinfo); - cinfo->global_state = DSTATE_RDCOEFS; - } - if (cinfo->global_state == DSTATE_RDCOEFS) { - /* Absorb whole file into the coef buffer */ - for (;;) { - int retcode; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - /* Absorb some more input */ - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_SUSPENDED) - return NULL; - if (retcode == JPEG_REACHED_EOI) - break; - /* Advance progress counter if appropriate */ - if (cinfo->progress != NULL && - (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { - if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { - /* startup underestimated number of scans; ratchet up one scan */ - cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; - } - } - } - /* Set state so that jpeg_finish_decompress does the right thing */ - cinfo->global_state = DSTATE_STOPPING; - } - /* At this point we should be in state DSTATE_STOPPING if being used - * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access - * to the coefficients during a full buffered-image-mode decompression. - */ - if ((cinfo->global_state == DSTATE_STOPPING || - cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { - return cinfo->coef->coef_arrays; - } - /* Oops, improper usage */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return NULL; /* keep compiler happy */ -} - - -/* - * Master selection of decompression modules for transcoding. - * This substitutes for jdmaster.c's initialization of the full decompressor. - */ - -LOCAL(void) -transdecode_master_selection (j_decompress_ptr cinfo) -{ - /* This is effectively a buffered-image operation. */ - cinfo->buffered_image = TRUE; - - /* Entropy decoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef D_PROGRESSIVE_SUPPORTED - jinit_phuff_decoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_decoder(cinfo); - } - - /* Always get a full-image coefficient buffer. */ - jinit_d_coef_controller(cinfo, TRUE); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Initialize input side of decompressor to consume first scan. */ - (*cinfo->inputctl->start_input_pass) (cinfo); - - /* Initialize progress monitoring. */ - if (cinfo->progress != NULL) { - int nscans; - /* Estimate number of scans to set pass_limit. */ - if (cinfo->progressive_mode) { - /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ - nscans = 2 + 3 * cinfo->num_components; - } else if (cinfo->inputctl->has_multiple_scans) { - /* For a nonprogressive multiscan file, estimate 1 scan per component. */ - nscans = cinfo->num_components; - } else { - nscans = 1; - } - cinfo->progress->pass_counter = 0L; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; - cinfo->progress->completed_passes = 0; - cinfo->progress->total_passes = 1; - } -} diff --git a/freeimage241/Source/LibJPEG/jerror.c b/freeimage241/Source/LibJPEG/jerror.c deleted file mode 100644 index 5802b99..0000000 --- a/freeimage241/Source/LibJPEG/jerror.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * jerror.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains simple error-reporting and trace-message routines. - * These are suitable for Unix-like systems and others where writing to - * stderr is the right thing to do. Many applications will want to replace - * some or all of these routines. - * - * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile, - * you get a Windows-specific hack to display error messages in a dialog box. - * It ain't much, but it beats dropping error messages into the bit bucket, - * which is what happens to output to stderr under most Windows C compilers. - * - * These routines are used by both the compression and decompression code. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jversion.h" -#include "jerror.h" - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif - - -/* - * Create the message string table. - * We do this from the master message list in jerror.h by re-reading - * jerror.h with a suitable definition for macro JMESSAGE. - * The message table is made an external symbol just in case any applications - * want to refer to it directly. - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_message_table jMsgTable -#endif - -#define JMESSAGE(code,string) string , - -const char * const jpeg_std_message_table[] = { -#include "jerror.h" - NULL -}; - - -/* - * Error exit handler: must not return to caller. - * - * Applications may override this if they want to get control back after - * an error. Typically one would longjmp somewhere instead of exiting. - * The setjmp buffer can be made a private field within an expanded error - * handler object. Note that the info needed to generate an error message - * is stored in the error object, so you can generate the message now or - * later, at your convenience. - * You should make sure that the JPEG object is cleaned up (with jpeg_abort - * or jpeg_destroy) at some point. - */ - -METHODDEF(void) -error_exit (j_common_ptr cinfo) -{ - /* Always display the message */ - (*cinfo->err->output_message) (cinfo); - - /* Let the memory manager delete any temp files before we die */ - jpeg_destroy(cinfo); - - exit(EXIT_FAILURE); -} - - -/* - * Actual output of an error or trace message. - * Applications may override this method to send JPEG messages somewhere - * other than stderr. - * - * On Windows, printing to stderr is generally completely useless, - * so we provide optional code to produce an error-dialog popup. - * Most Windows applications will still prefer to override this routine, - * but if they don't, it'll do something at least marginally useful. - * - * NOTE: to use the library in an environment that doesn't support the - * C stdio library, you may have to delete the call to fprintf() entirely, - * not just not use this routine. - */ - -METHODDEF(void) -output_message (j_common_ptr cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - - /* Create the message */ - (*cinfo->err->format_message) (cinfo, buffer); - -#ifdef USE_WINDOWS_MESSAGEBOX - /* Display it in a message dialog box */ - MessageBox(GetActiveWindow(), buffer, "JPEG Library Error", - MB_OK | MB_ICONERROR); -#else - /* Send it to stderr, adding a newline */ - fprintf(stderr, "%s\n", buffer); -#endif -} - - -/* - * Decide whether to emit a trace or warning message. - * msg_level is one of: - * -1: recoverable corrupt-data warning, may want to abort. - * 0: important advisory messages (always display to user). - * 1: first level of tracing detail. - * 2,3,...: successively more detailed tracing messages. - * An application might override this method if it wanted to abort on warnings - * or change the policy about which messages to display. - */ - -METHODDEF(void) -emit_message (j_common_ptr cinfo, int msg_level) -{ - struct jpeg_error_mgr * err = cinfo->err; - - if (msg_level < 0) { - /* It's a warning message. Since corrupt files may generate many warnings, - * the policy implemented here is to show only the first warning, - * unless trace_level >= 3. - */ - if (err->num_warnings == 0 || err->trace_level >= 3) - (*err->output_message) (cinfo); - /* Always count warnings in num_warnings. */ - err->num_warnings++; - } else { - /* It's a trace message. Show it if trace_level >= msg_level. */ - if (err->trace_level >= msg_level) - (*err->output_message) (cinfo); - } -} - - -/* - * Format a message string for the most recent JPEG error or message. - * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX - * characters. Note that no '\n' character is added to the string. - * Few applications should need to override this method. - */ - -METHODDEF(void) -format_message (j_common_ptr cinfo, char * buffer) -{ - struct jpeg_error_mgr * err = cinfo->err; - int msg_code = err->msg_code; - const char * msgtext = NULL; - const char * msgptr; - char ch; - boolean isstring; - - /* Look up message string in proper table */ - if (msg_code > 0 && msg_code <= err->last_jpeg_message) { - msgtext = err->jpeg_message_table[msg_code]; - } else if (err->addon_message_table != NULL && - msg_code >= err->first_addon_message && - msg_code <= err->last_addon_message) { - msgtext = err->addon_message_table[msg_code - err->first_addon_message]; - } - - /* Defend against bogus message number */ - if (msgtext == NULL) { - err->msg_parm.i[0] = msg_code; - msgtext = err->jpeg_message_table[0]; - } - - /* Check for string parameter, as indicated by %s in the message text */ - isstring = FALSE; - msgptr = msgtext; - while ((ch = *msgptr++) != '\0') { - if (ch == '%') { - if (*msgptr == 's') isstring = TRUE; - break; - } - } - - /* Format the message into the passed buffer */ - if (isstring) - sprintf(buffer, msgtext, err->msg_parm.s); - else - sprintf(buffer, msgtext, - err->msg_parm.i[0], err->msg_parm.i[1], - err->msg_parm.i[2], err->msg_parm.i[3], - err->msg_parm.i[4], err->msg_parm.i[5], - err->msg_parm.i[6], err->msg_parm.i[7]); -} - - -/* - * Reset error state variables at start of a new image. - * This is called during compression startup to reset trace/error - * processing to default state, without losing any application-specific - * method pointers. An application might possibly want to override - * this method if it has additional error processing state. - */ - -METHODDEF(void) -reset_error_mgr (j_common_ptr cinfo) -{ - cinfo->err->num_warnings = 0; - /* trace_level is not reset since it is an application-supplied parameter */ - cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */ -} - - -/* - * Fill in the standard error-handling methods in a jpeg_error_mgr object. - * Typical call is: - * struct jpeg_compress_struct cinfo; - * struct jpeg_error_mgr err; - * - * cinfo.err = jpeg_std_error(&err); - * after which the application may override some of the methods. - */ - -GLOBAL(struct jpeg_error_mgr *) -jpeg_std_error (struct jpeg_error_mgr * err) -{ - err->error_exit = error_exit; - err->emit_message = emit_message; - err->output_message = output_message; - err->format_message = format_message; - err->reset_error_mgr = reset_error_mgr; - - err->trace_level = 0; /* default = no tracing */ - err->num_warnings = 0; /* no warnings emitted yet */ - err->msg_code = 0; /* may be useful as a flag for "no error" */ - - /* Initialize message table pointers */ - err->jpeg_message_table = jpeg_std_message_table; - err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1; - - err->addon_message_table = NULL; - err->first_addon_message = 0; /* for safety */ - err->last_addon_message = 0; - - return err; -} diff --git a/freeimage241/Source/LibJPEG/jerror.h b/freeimage241/Source/LibJPEG/jerror.h deleted file mode 100644 index fc2fffe..0000000 --- a/freeimage241/Source/LibJPEG/jerror.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - * jerror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the JPEG library. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - * A set of error-reporting macros are defined too. Some applications using - * the JPEG library may wish to include this file to get the error codes - * and/or the macros. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef JERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* JERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ - -/* For maintenance convenience, list is alphabetical by message code name */ -JMESSAGE(JERR_ARITH_NOTIMPL, - "Sorry, there are legal restrictions on arithmetic coding") -JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") -JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") -JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") -JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") -JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") -JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") -JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") -JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") -JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") -JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") -JMESSAGE(JERR_BAD_LIB_VERSION, - "Wrong JPEG library version: library is %d, caller expects %d") -JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") -JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") -JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") -JMESSAGE(JERR_BAD_PROGRESSION, - "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") -JMESSAGE(JERR_BAD_PROG_SCRIPT, - "Invalid progressive parameters at scan script entry %d") -JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") -JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") -JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") -JMESSAGE(JERR_BAD_STRUCT_SIZE, - "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") -JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") -JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") -JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") -JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") -JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") -JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") -JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") -JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") -JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") -JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") -JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") -JMESSAGE(JERR_EMS_READ, "Read from EMS failed") -JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") -JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") -JMESSAGE(JERR_FILE_READ, "Input file read error") -JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") -JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") -JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") -JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") -JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") -JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") -JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") -JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, - "Cannot transcode due to multiple use of quantization table %d") -JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") -JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") -JMESSAGE(JERR_NOTIMPL, "Not implemented yet") -JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") -JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") -JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") -JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") -JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") -JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") -JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") -JMESSAGE(JERR_QUANT_COMPONENTS, - "Cannot quantize more than %d color components") -JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") -JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") -JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") -JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") -JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") -JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") -JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") -JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") -JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") -JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") -JMESSAGE(JERR_TFILE_WRITE, - "Write failed on temporary file --- out of disk space?") -JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") -JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") -JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") -JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") -JMESSAGE(JERR_XMS_READ, "Read from XMS failed") -JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") -JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) -JMESSAGE(JMSG_VERSION, JVERSION) -JMESSAGE(JTRC_16BIT_TABLES, - "Caution: quantization tables are too coarse for baseline JPEG") -JMESSAGE(JTRC_ADOBE, - "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") -JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") -JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") -JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") -JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") -JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") -JMESSAGE(JTRC_DRI, "Define Restart Interval %u") -JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") -JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") -JMESSAGE(JTRC_EOI, "End Of Image") -JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") -JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") -JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, - "Warning: thumbnail image size does not match data length %u") -JMESSAGE(JTRC_JFIF_EXTENSION, - "JFIF extension marker: type 0x%02x, length %u") -JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") -JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") -JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") -JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") -JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") -JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") -JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") -JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") -JMESSAGE(JTRC_RST, "RST%d") -JMESSAGE(JTRC_SMOOTH_NOTIMPL, - "Smoothing not supported with nonstandard sampling ratios") -JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") -JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") -JMESSAGE(JTRC_SOI, "Start of Image") -JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") -JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") -JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") -JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") -JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") -JMESSAGE(JTRC_THUMB_JPEG, - "JFIF extension marker: JPEG-compressed thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_PALETTE, - "JFIF extension marker: palette thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_RGB, - "JFIF extension marker: RGB thumbnail image, length %u") -JMESSAGE(JTRC_UNKNOWN_IDS, - "Unrecognized component IDs %d %d %d, assuming YCbCr") -JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") -JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") -JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") -JMESSAGE(JWRN_BOGUS_PROGRESSION, - "Inconsistent progression sequence for component %d coefficient %d") -JMESSAGE(JWRN_EXTRANEOUS_DATA, - "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") -JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") -JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") -JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") -JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") -JMESSAGE(JWRN_MUST_RESYNC, - "Corrupt JPEG data: found marker 0x%02x instead of RST%d") -JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") -JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTMSGCODE -} J_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE - - -#ifndef JERROR_H -#define JERROR_H - -/* Macros to simplify using the error and trace message stuff */ -/* The first parameter is either type of cinfo pointer */ - -/* Fatal errors (print message and exit) */ -#define ERREXIT(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT3(cinfo,code,p1,p2,p3) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (cinfo)->err->msg_parm.i[3] = (p4), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXITS(cinfo,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) - -#define MAKESTMT(stuff) do { stuff } while (0) - -/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ -#define WARNMS(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) - -/* Informational/debugging messages */ -#define TRACEMS(cinfo,lvl,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS1(cinfo,lvl,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS2(cinfo,lvl,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMSS(cinfo,lvl,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) - -#endif /* JERROR_H */ diff --git a/freeimage241/Source/LibJPEG/jfdctflt.c b/freeimage241/Source/LibJPEG/jfdctflt.c deleted file mode 100644 index 79d7a00..0000000 --- a/freeimage241/Source/LibJPEG/jfdctflt.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * jfdctflt.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a floating-point implementation of the - * forward DCT (Discrete Cosine Transform). - * - * This implementation should be more accurate than either of the integer - * DCT implementations. However, it may not give the same results on all - * machines because of differences in roundoff behavior. Speed will depend - * on the hardware's floating point capacity. - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with a fixed-point - * implementation, accuracy is lost due to imprecise representation of the - * scaled quantization values. However, that problem does not arise if - * we use floating point arithmetic. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_FLOAT_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_float (FAST_FLOAT * data) -{ - FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - FAST_FLOAT tmp10, tmp11, tmp12, tmp13; - FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; - FAST_FLOAT *dataptr; - int ctr; - - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ - z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ - z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ - z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ - dataptr[DCTSIZE*4] = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ - dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ - dataptr[DCTSIZE*6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ - z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ - z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ - z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ - dataptr[DCTSIZE*3] = z13 - z2; - dataptr[DCTSIZE*1] = z11 + z4; - dataptr[DCTSIZE*7] = z11 - z4; - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jfdctfst.c b/freeimage241/Source/LibJPEG/jfdctfst.c deleted file mode 100644 index ccb378a..0000000 --- a/freeimage241/Source/LibJPEG/jfdctfst.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * jfdctfst.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a fast, not so accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with fixed-point math, - * accuracy is lost due to imprecise representation of the scaled - * quantization values. The smaller the quantization table entry, the less - * precise the scaled value, so this implementation does worse with high- - * quality-setting files than with low-quality ones. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_IFAST_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling decisions are generally the same as in the LL&M algorithm; - * see jfdctint.c for more details. However, we choose to descale - * (right shift) multiplication products as soon as they are formed, - * rather than carrying additional fractional bits into subsequent additions. - * This compromises accuracy slightly, but it lets us save a few shifts. - * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) - * everywhere except in the multiplications proper; this saves a good deal - * of work on 16-bit-int machines. - * - * Again to save a few shifts, the intermediate results between pass 1 and - * pass 2 are not upscaled, but are represented only to integral precision. - * - * A final compromise is to represent the multiplicative constants to only - * 8 fractional bits, rather than 13. This saves some shifting work on some - * machines, and may also reduce the cost of multiplication (since there - * are fewer one-bits in the constants). - */ - -#define CONST_BITS 8 - - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 8 -#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */ -#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */ -#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */ -#define FIX_1_306562965 ((INT32) 334) /* FIX(1.306562965) */ -#else -#define FIX_0_382683433 FIX(0.382683433) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_707106781 FIX(0.707106781) -#define FIX_1_306562965 FIX(1.306562965) -#endif - - -/* We can gain a little more speed, with a further compromise in accuracy, - * by omitting the addition in a descaling shift. This yields an incorrectly - * rounded result half the time... - */ - -#ifndef USE_ACCURATE_ROUNDING -#undef DESCALE -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* Multiply a DCTELEM variable by an INT32 constant, and immediately - * descale to yield a DCTELEM result. - */ - -#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_ifast (DCTELEM * data) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z1, z2, z3, z4, z5, z11, z13; - DCTELEM *dataptr; - int ctr; - SHIFT_TEMPS - - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ - dataptr[DCTSIZE*4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ - dataptr[DCTSIZE*6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ - dataptr[DCTSIZE*3] = z13 - z2; - dataptr[DCTSIZE*1] = z11 + z4; - dataptr[DCTSIZE*7] = z11 - z4; - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_IFAST_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jfdctint.c b/freeimage241/Source/LibJPEG/jfdctint.c deleted file mode 100644 index 0a78b64..0000000 --- a/freeimage241/Source/LibJPEG/jfdctint.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * jfdctint.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a slow-but-accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_ISLOW_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: - * - * Each 1-D DCT step produces outputs which are a factor of sqrt(N) - * larger than the true DCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D DCT, - * because the y0 and y4 outputs need not be divided by sqrt(N). - * In the IJG code, this factor of 8 is removed by the quantization step - * (in jcdctmgr.c), NOT in this module. - * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. - * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (For 12-bit sample data, the intermediate - * array is INT32 anyway.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_islow (DCTELEM * data) -{ - INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - INT32 tmp10, tmp11, tmp12, tmp13; - INT32 z1, z2, z3, z4, z5; - DCTELEM *dataptr; - int ctr; - SHIFT_TEMPS - - /* Pass 1: process rows. */ - /* Note results are scaled up by sqrt(8) compared to a true DCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); - dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS-PASS1_BITS); - dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS-PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); - dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); - dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); - dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. - * We remove the PASS1_BITS scaling, but leave the results scaled up - * by an overall factor of 8. - */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); - dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS+PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, - CONST_BITS+PASS1_BITS); - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jidctflt.c b/freeimage241/Source/LibJPEG/jidctflt.c deleted file mode 100644 index 0188ce3..0000000 --- a/freeimage241/Source/LibJPEG/jidctflt.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * jidctflt.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a floating-point implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * This implementation should be more accurate than either of the integer - * IDCT implementations. However, it may not give the same results on all - * machines because of differences in roundoff behavior. Speed will depend - * on the hardware's floating point capacity. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with a fixed-point - * implementation, accuracy is lost due to imprecise representation of the - * scaled quantization values. However, that problem does not arise if - * we use floating point arithmetic. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_FLOAT_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce a float result. - */ - -#define DEQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - FAST_FLOAT tmp10, tmp11, tmp12, tmp13; - FAST_FLOAT z5, z10, z11, z12, z13; - JCOEFPTR inptr; - FLOAT_MULT_TYPE * quantptr; - FAST_FLOAT * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp10 = tmp0 + tmp2; /* phase 3 */ - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; /* phases 5-3 */ - tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */ - - tmp0 = tmp10 + tmp13; /* phase 2 */ - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - - z13 = tmp6 + tmp5; /* phase 6 */ - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ - - z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ - tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ - tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[DCTSIZE*0] = tmp0 + tmp7; - wsptr[DCTSIZE*7] = tmp0 - tmp7; - wsptr[DCTSIZE*1] = tmp1 + tmp6; - wsptr[DCTSIZE*6] = tmp1 - tmp6; - wsptr[DCTSIZE*2] = tmp2 + tmp5; - wsptr[DCTSIZE*5] = tmp2 - tmp5; - wsptr[DCTSIZE*4] = tmp3 + tmp4; - wsptr[DCTSIZE*3] = tmp3 - tmp4; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * And testing floats for zero is relatively expensive, so we don't bother. - */ - - /* Even part */ - - tmp10 = wsptr[0] + wsptr[4]; - tmp11 = wsptr[0] - wsptr[4]; - - tmp13 = wsptr[2] + wsptr[6]; - tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - z13 = wsptr[5] + wsptr[3]; - z10 = wsptr[5] - wsptr[3]; - z11 = wsptr[1] + wsptr[7]; - z12 = wsptr[1] - wsptr[7]; - - tmp7 = z11 + z13; - tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); - - z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ - tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ - tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - /* Final output stage: scale down by a factor of 8 and range-limit */ - - outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3) - & RANGE_MASK]; - outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3) - & RANGE_MASK]; - outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3) - & RANGE_MASK]; - outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3) - & RANGE_MASK]; - outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jidctfst.c b/freeimage241/Source/LibJPEG/jidctfst.c deleted file mode 100644 index dba4216..0000000 --- a/freeimage241/Source/LibJPEG/jidctfst.c +++ /dev/null @@ -1,368 +0,0 @@ -/* - * jidctfst.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a fast, not so accurate integer implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with fixed-point math, - * accuracy is lost due to imprecise representation of the scaled - * quantization values. The smaller the quantization table entry, the less - * precise the scaled value, so this implementation does worse with high- - * quality-setting files than with low-quality ones. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_IFAST_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling decisions are generally the same as in the LL&M algorithm; - * see jidctint.c for more details. However, we choose to descale - * (right shift) multiplication products as soon as they are formed, - * rather than carrying additional fractional bits into subsequent additions. - * This compromises accuracy slightly, but it lets us save a few shifts. - * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) - * everywhere except in the multiplications proper; this saves a good deal - * of work on 16-bit-int machines. - * - * The dequantized coefficients are not integers because the AA&N scaling - * factors have been incorporated. We represent them scaled up by PASS1_BITS, - * so that the first and second IDCT rounds have the same input scaling. - * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to - * avoid a descaling shift; this compromises accuracy rather drastically - * for small quantization table entries, but it saves a lot of shifts. - * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway, - * so we use a much larger scaling factor to preserve accuracy. - * - * A final compromise is to represent the multiplicative constants to only - * 8 fractional bits, rather than 13. This saves some shifting work on some - * machines, and may also reduce the cost of multiplication (since there - * are fewer one-bits in the constants). - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 8 -#define PASS1_BITS 2 -#else -#define CONST_BITS 8 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 8 -#define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */ -#define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */ -#define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */ -#define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */ -#else -#define FIX_1_082392200 FIX(1.082392200) -#define FIX_1_414213562 FIX(1.414213562) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_2_613125930 FIX(2.613125930) -#endif - - -/* We can gain a little more speed, with a further compromise in accuracy, - * by omitting the addition in a descaling shift. This yields an incorrectly - * rounded result half the time... - */ - -#ifndef USE_ACCURATE_ROUNDING -#undef DESCALE -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* Multiply a DCTELEM variable by an INT32 constant, and immediately - * descale to yield a DCTELEM result. - */ - -#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce a DCTELEM result. For 8-bit data a 16x16->16 - * multiplication will do. For 12-bit data, the multiplier table is - * declared INT32, so a 32-bit multiply will be used. - */ - -#if BITS_IN_JSAMPLE == 8 -#define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval)) -#else -#define DEQUANTIZE(coef,quantval) \ - DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS) -#endif - - -/* Like DESCALE, but applies to a DCTELEM and produces an int. - * We assume that int right shift is unsigned if INT32 right shift is. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define ISHIFT_TEMPS DCTELEM ishift_temp; -#if BITS_IN_JSAMPLE == 8 -#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */ -#else -#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */ -#endif -#define IRIGHT_SHIFT(x,shft) \ - ((ishift_temp = (x)) < 0 ? \ - (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \ - (ishift_temp >> (shft))) -#else -#define ISHIFT_TEMPS -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - -#ifdef USE_ACCURATE_ROUNDING -#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n)) -#else -#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n)) -#endif - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z5, z10, z11, z12, z13; - JCOEFPTR inptr; - IFAST_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS /* for DESCALE */ - ISHIFT_TEMPS /* for IDESCALE */ - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp10 = tmp0 + tmp2; /* phase 3 */ - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; /* phases 5-3 */ - tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ - - tmp0 = tmp10 + tmp13; /* phase 2 */ - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - - z13 = tmp6 + tmp5; /* phase 6 */ - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); - wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); - wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); - wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); - wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); - wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); - wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); - wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3, */ - /* and also undo the PASS1_BITS scaling. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * On machines with very fast multiplication, it's possible that the - * test takes more time than it's worth. In that case this section - * may be commented out. - */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - outptr[4] = dcval; - outptr[5] = dcval; - outptr[6] = dcval; - outptr[7] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); - tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); - - tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); - tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) - - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; - z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; - z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; - z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - /* Final output stage: scale down by a factor of 8 and range-limit */ - - outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) - & RANGE_MASK]; - outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) - & RANGE_MASK]; - outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) - & RANGE_MASK]; - outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) - & RANGE_MASK]; - outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) - & RANGE_MASK]; - outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) - & RANGE_MASK]; - outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) - & RANGE_MASK]; - outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_IFAST_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jidctint.c b/freeimage241/Source/LibJPEG/jidctint.c deleted file mode 100644 index a72b320..0000000 --- a/freeimage241/Source/LibJPEG/jidctint.c +++ /dev/null @@ -1,389 +0,0 @@ -/* - * jidctint.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a slow-but-accurate integer implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_ISLOW_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: - * - * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) - * larger than the true IDCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D IDCT, - * because the y0 and y4 inputs need not be divided by sqrt(N). - * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. - * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (To scale up 12-bit sample data further, an - * intermediate INT32 array would be needed.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce an int result. In this module, both inputs and result - * are 16 bits or less, so either int or short multiply will work. - */ - -#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp1, tmp2, tmp3; - INT32 tmp10, tmp11, tmp12, tmp13; - INT32 z1, z2, z3, z4, z5; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part: reverse the even part of the forward DCT. */ - /* The rotator is sqrt(2)*c(-6). */ - - z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - z1 = MULTIPLY(z2 + z3, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); - tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); - - z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - - tmp0 = (z2 + z3) << CONST_BITS; - tmp1 = (z2 - z3) << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - /* Odd part per figure 8; the matrix is unitary and hence its - * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. - */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - - z1 = tmp0 + tmp3; - z2 = tmp1 + tmp2; - z3 = tmp0 + tmp2; - z4 = tmp1 + tmp3; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - tmp0 += z1 + z3; - tmp1 += z2 + z4; - tmp2 += z2 + z3; - tmp3 += z1 + z4; - - /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*7] = (int) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*6] = (int) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*5] = (int) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*3] = (int) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*4] = (int) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3, */ - /* and also undo the PASS1_BITS scaling. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * On machines with very fast multiplication, it's possible that the - * test takes more time than it's worth. In that case this section - * may be commented out. - */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - outptr[4] = dcval; - outptr[5] = dcval; - outptr[6] = dcval; - outptr[7] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part: reverse the even part of the forward DCT. */ - /* The rotator is sqrt(2)*c(-6). */ - - z2 = (INT32) wsptr[2]; - z3 = (INT32) wsptr[6]; - - z1 = MULTIPLY(z2 + z3, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); - tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); - - tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS; - tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - /* Odd part per figure 8; the matrix is unitary and hence its - * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. - */ - - tmp0 = (INT32) wsptr[7]; - tmp1 = (INT32) wsptr[5]; - tmp2 = (INT32) wsptr[3]; - tmp3 = (INT32) wsptr[1]; - - z1 = tmp0 + tmp3; - z2 = tmp1 + tmp2; - z3 = tmp0 + tmp2; - z4 = tmp1 + tmp3; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - tmp0 += z1 + z3; - tmp1 += z2 + z4; - tmp2 += z2 + z3; - tmp3 += z1 + z4; - - /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp3, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[7] = range_limit[(int) DESCALE(tmp10 - tmp3, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp11 + tmp2, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[6] = range_limit[(int) DESCALE(tmp11 - tmp2, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE(tmp12 + tmp1, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[5] = range_limit[(int) DESCALE(tmp12 - tmp1, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE(tmp13 + tmp0, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jidctred.c b/freeimage241/Source/LibJPEG/jidctred.c deleted file mode 100644 index 421f3c7..0000000 --- a/freeimage241/Source/LibJPEG/jidctred.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - * jidctred.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains inverse-DCT routines that produce reduced-size output: - * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. - * - * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) - * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step - * with an 8-to-4 step that produces the four averages of two adjacent outputs - * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). - * These steps were derived by computing the corresponding values at the end - * of the normal LL&M code, then simplifying as much as possible. - * - * 1x1 is trivial: just take the DC coefficient divided by 8. - * - * See jidctint.c for additional comments. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef IDCT_SCALING_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling is the same as in jidctint.c. */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_211164243 ((INT32) 1730) /* FIX(0.211164243) */ -#define FIX_0_509795579 ((INT32) 4176) /* FIX(0.509795579) */ -#define FIX_0_601344887 ((INT32) 4926) /* FIX(0.601344887) */ -#define FIX_0_720959822 ((INT32) 5906) /* FIX(0.720959822) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_850430095 ((INT32) 6967) /* FIX(0.850430095) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_061594337 ((INT32) 8697) /* FIX(1.061594337) */ -#define FIX_1_272758580 ((INT32) 10426) /* FIX(1.272758580) */ -#define FIX_1_451774981 ((INT32) 11893) /* FIX(1.451774981) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_2_172734803 ((INT32) 17799) /* FIX(2.172734803) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_624509785 ((INT32) 29692) /* FIX(3.624509785) */ -#else -#define FIX_0_211164243 FIX(0.211164243) -#define FIX_0_509795579 FIX(0.509795579) -#define FIX_0_601344887 FIX(0.601344887) -#define FIX_0_720959822 FIX(0.720959822) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_850430095 FIX(0.850430095) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_061594337 FIX(1.061594337) -#define FIX_1_272758580 FIX(1.272758580) -#define FIX_1_451774981 FIX(1.451774981) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_2_172734803 FIX(2.172734803) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_624509785 FIX(3.624509785) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce an int result. In this module, both inputs and result - * are 16 bits or less, so either int or short multiply will work. - */ - -#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 4x4 output block. - */ - -GLOBAL(void) -jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp2, tmp10, tmp12; - INT32 z1, z2, z3, z4; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE*4]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { - /* Don't bother to process column 4, because second pass won't use it */ - if (ctr == DCTSIZE-4) - continue; - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 && - inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) { - /* AC terms all zero; we need not examine term 4 for 4x4 output */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp0 <<= (CONST_BITS+1); - - z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865); - - tmp10 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - - /* Odd part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - - tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ - + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ - + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ - + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ - - tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ - + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ - + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ - + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ - - /* Final output stage */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1); - } - - /* Pass 2: process 4 rows from work array, store into output array. */ - - wsptr = workspace; - for (ctr = 0; ctr < 4; ctr++) { - outptr = output_buf[ctr] + output_col; - /* It's not clear whether a zero row test is worthwhile here ... */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1); - - tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065) - + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865); - - tmp10 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - - /* Odd part */ - - z1 = (INT32) wsptr[7]; - z2 = (INT32) wsptr[5]; - z3 = (INT32) wsptr[3]; - z4 = (INT32) wsptr[1]; - - tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ - + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ - + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ - + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ - - tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ - + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ - + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ - + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ - - /* Final output stage */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 2x2 output block. - */ - -GLOBAL(void) -jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp10, z1; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE*2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { - /* Don't bother to process columns 2,4,6 */ - if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6) - continue; - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) { - /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - - continue; - } - - /* Even part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp10 = z1 << (CONST_BITS+2); - - /* Odd part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ - - /* Final output stage */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2); - } - - /* Pass 2: process 2 rows from work array, store into output array. */ - - wsptr = workspace; - for (ctr = 0; ctr < 2; ctr++) { - outptr = output_buf[ctr] + output_col; - /* It's not clear whether a zero row test is worthwhile here ... */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2); - - /* Odd part */ - - tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */ - + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */ - + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */ - + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ - - /* Final output stage */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0, - CONST_BITS+PASS1_BITS+3+2) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0, - CONST_BITS+PASS1_BITS+3+2) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 1x1 output block. - */ - -GLOBAL(void) -jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - int dcval; - ISLOW_MULT_TYPE * quantptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - SHIFT_TEMPS - - /* We hardly need an inverse DCT routine for this: just take the - * average pixel value, which is one-eighth of the DC coefficient. - */ - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - dcval = DEQUANTIZE(coef_block[0], quantptr[0]); - dcval = (int) DESCALE((INT32) dcval, 3); - - output_buf[0][output_col] = range_limit[dcval & RANGE_MASK]; -} - -#endif /* IDCT_SCALING_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jinclude.h b/freeimage241/Source/LibJPEG/jinclude.h deleted file mode 100644 index 0a4f151..0000000 --- a/freeimage241/Source/LibJPEG/jinclude.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * jinclude.h - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file exists to provide a single place to fix any problems with - * including the wrong system include files. (Common problems are taken - * care of by the standard jconfig symbols, but on really weird systems - * you may have to edit this file.) - * - * NOTE: this file is NOT intended to be included by applications using the - * JPEG library. Most applications need only include jpeglib.h. - */ - - -/* Include auto-config file to find out which system include files we need. */ - -#include "jconfig.h" /* auto configuration options */ -#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ - -/* - * We need the NULL macro and size_t typedef. - * On an ANSI-conforming system it is sufficient to include . - * Otherwise, we get them from or ; we may have to - * pull in as well. - * Note that the core JPEG library does not require ; - * only the default error handler and data source/destination modules do. - * But we must pull it in because of the references to FILE in jpeglib.h. - * You can remove those references if you want to compile without . - */ - -#ifdef HAVE_STDDEF_H -#include -#endif - -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef NEED_SYS_TYPES_H -#include -#endif - -#include - -/* - * We need memory copying and zeroing functions, plus strncpy(). - * ANSI and System V implementations declare these in . - * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). - * Some systems may declare memset and memcpy in . - * - * NOTE: we assume the size parameters to these functions are of type size_t. - * Change the casts in these macros if not! - */ - -#ifdef NEED_BSD_STRINGS - -#include -#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) -#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) - -#else /* not BSD, assume ANSI/SysV string lib */ - -#include -#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) -#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) - -#endif - -/* - * In ANSI C, and indeed any rational implementation, size_t is also the - * type returned by sizeof(). However, it seems there are some irrational - * implementations out there, in which sizeof() returns an int even though - * size_t is defined as long or unsigned long. To ensure consistent results - * we always use this SIZEOF() macro in place of using sizeof() directly. - */ - -#define SIZEOF(object) ((size_t) sizeof(object)) - -/* - * The modules that use fread() and fwrite() always invoke them through - * these macros. On some systems you may need to twiddle the argument casts. - * CAUTION: argument order is different from underlying functions! - */ - -#define JFREAD(file,buf,sizeofbuf) \ - ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) -#define JFWRITE(file,buf,sizeofbuf) \ - ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) diff --git a/freeimage241/Source/LibJPEG/jmemansi.c b/freeimage241/Source/LibJPEG/jmemansi.c deleted file mode 100644 index 2d93e49..0000000 --- a/freeimage241/Source/LibJPEG/jmemansi.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * jmemansi.c - * - * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a simple generic implementation of the system- - * dependent portion of the JPEG memory manager. This implementation - * assumes that you have the ANSI-standard library routine tmpfile(). - * Also, the problem of determining the amount of memory available - * is shoved onto the user. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - -#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ -#define SEEK_SET 0 /* if not, assume 0 is correct */ -#endif - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFREAD(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFWRITE(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - fclose(info->temp_file); - /* Since this implementation uses tmpfile() to create the file, - * no explicit file deletion is needed. - */ -} - - -/* - * Initial opening of a backing-store object. - * - * This version uses tmpfile(), which constructs a suitable file name - * behind the scenes. We don't have to use info->temp_name[] at all; - * indeed, we can't even find out the actual name of the temp file. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - if ((info->temp_file = tmpfile()) == NULL) - ERREXITS(cinfo, JERR_TFILE_CREATE, ""); - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/freeimage241/Source/LibJPEG/jmemdos.c b/freeimage241/Source/LibJPEG/jmemdos.c deleted file mode 100644 index 60b45c6..0000000 --- a/freeimage241/Source/LibJPEG/jmemdos.c +++ /dev/null @@ -1,638 +0,0 @@ -/* - * jmemdos.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides an MS-DOS-compatible implementation of the system- - * dependent portion of the JPEG memory manager. Temporary data can be - * stored in extended or expanded memory as well as in regular DOS files. - * - * If you use this file, you must be sure that NEED_FAR_POINTERS is defined - * if you compile in a small-data memory model; it should NOT be defined if - * you use a large-data memory model. This file is not recommended if you - * are using a flat-memory-space 386 environment such as DJGCC or Watcom C. - * Also, this code will NOT work if struct fields are aligned on greater than - * 2-byte boundaries. - * - * Based on code contributed by Ge' Weijers. - */ - -/* - * If you have both extended and expanded memory, you may want to change the - * order in which they are tried in jopen_backing_store. On a 286 machine - * expanded memory is usually faster, since extended memory access involves - * an expensive protected-mode-and-back switch. On 386 and better, extended - * memory is usually faster. As distributed, the code tries extended memory - * first (what? not everyone has a 386? :-). - * - * You can disable use of extended/expanded memory entirely by altering these - * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0). - */ - -#ifndef XMS_SUPPORTED -#define XMS_SUPPORTED 1 -#endif -#ifndef EMS_SUPPORTED -#define EMS_SUPPORTED 1 -#endif - - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare these */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -extern char * getenv JPP((const char * name)); -#endif - -#ifdef NEED_FAR_POINTERS - -#ifdef __TURBOC__ -/* These definitions work for Borland C (Turbo C) */ -#include /* need farmalloc(), farfree() */ -#define far_malloc(x) farmalloc(x) -#define far_free(x) farfree(x) -#else -/* These definitions work for Microsoft C and compatible compilers */ -#include /* need _fmalloc(), _ffree() */ -#define far_malloc(x) _fmalloc(x) -#define far_free(x) _ffree(x) -#endif - -#else /* not NEED_FAR_POINTERS */ - -#define far_malloc(x) malloc(x) -#define far_free(x) free(x) - -#endif /* NEED_FAR_POINTERS */ - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#else -#define READ_BINARY "rb" -#endif - -#ifndef USE_MSDOS_MEMMGR /* make sure user got configuration right */ - You forgot to define USE_MSDOS_MEMMGR in jconfig.h. /* deliberate syntax error */ -#endif - -#if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */ - MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */ -#endif - - -/* - * Declarations for assembly-language support routines (see jmemdosa.asm). - * - * The functions are declared "far" as are all their pointer arguments; - * this ensures the assembly source code will work regardless of the - * compiler memory model. We assume "short" is 16 bits, "long" is 32. - */ - -typedef void far * XMSDRIVER; /* actually a pointer to code */ -typedef struct { /* registers for calling XMS driver */ - unsigned short ax, dx, bx; - void far * ds_si; - } XMScontext; -typedef struct { /* registers for calling EMS driver */ - unsigned short ax, dx, bx; - void far * ds_si; - } EMScontext; - -extern short far jdos_open JPP((short far * handle, char far * filename)); -extern short far jdos_close JPP((short handle)); -extern short far jdos_seek JPP((short handle, long offset)); -extern short far jdos_read JPP((short handle, void far * buffer, - unsigned short count)); -extern short far jdos_write JPP((short handle, void far * buffer, - unsigned short count)); -extern void far jxms_getdriver JPP((XMSDRIVER far *)); -extern void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *)); -extern short far jems_available JPP((void)); -extern void far jems_calldriver JPP((EMScontext far *)); - - -/* - * Selection of a file name for a temporary file. - * This is highly system-dependent, and you may want to customize it. - */ - -static int next_file_num; /* to distinguish among several temp files */ - -LOCAL(void) -select_file_name (char * fname) -{ - const char * env; - char * ptr; - FILE * tfile; - - /* Keep generating file names till we find one that's not in use */ - for (;;) { - /* Get temp directory name from environment TMP or TEMP variable; - * if none, use "." - */ - if ((env = (const char *) getenv("TMP")) == NULL) - if ((env = (const char *) getenv("TEMP")) == NULL) - env = "."; - if (*env == '\0') /* null string means "." */ - env = "."; - ptr = fname; /* copy name to fname */ - while (*env != '\0') - *ptr++ = *env++; - if (ptr[-1] != '\\' && ptr[-1] != '/') - *ptr++ = '\\'; /* append backslash if not in env variable */ - /* Append a suitable file name */ - next_file_num++; /* advance counter */ - sprintf(ptr, "JPG%03d.TMP", next_file_num); - /* Probe to see if file name is already in use */ - if ((tfile = fopen(fname, READ_BINARY)) == NULL) - break; - fclose(tfile); /* oops, it's there; close tfile & try again */ - } -} - - -/* - * Near-memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are allocated in far memory, if possible - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) far_malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - far_free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 300000L /* for total usage about 450K */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - -/* - * For MS-DOS we support three types of backing storage: - * 1. Conventional DOS files. We access these by direct DOS calls rather - * than via the stdio package. This provides a bit better performance, - * but the real reason is that the buffers to be read or written are FAR. - * The stdio library for small-data memory models can't cope with that. - * 2. Extended memory, accessed per the XMS V2.0 specification. - * 3. Expanded memory, accessed per the LIM/EMS 4.0 specification. - * You'll need copies of those specs to make sense of the related code. - * The specs are available by Internet FTP from the SIMTEL archives - * (oak.oakland.edu and its various mirror sites). See files - * pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip. - */ - - -/* - * Access methods for a DOS file. - */ - - -METHODDEF(void) -read_file_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (jdos_seek(info->handle.file_handle, file_offset)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ - if (byte_count > 65535L) /* safety check */ - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - if (jdos_read(info->handle.file_handle, buffer_address, - (unsigned short) byte_count)) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_file_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (jdos_seek(info->handle.file_handle, file_offset)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ - if (byte_count > 65535L) /* safety check */ - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - if (jdos_write(info->handle.file_handle, buffer_address, - (unsigned short) byte_count)) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_file_store (j_common_ptr cinfo, backing_store_ptr info) -{ - jdos_close(info->handle.file_handle); /* close the file */ - remove(info->temp_name); /* delete the file */ -/* If your system doesn't have remove(), try unlink() instead. - * remove() is the ANSI-standard name for this function, but - * unlink() was more common in pre-ANSI systems. - */ - TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); -} - - -LOCAL(boolean) -open_file_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - short handle; - - select_file_name(info->temp_name); - if (jdos_open((short far *) & handle, (char far *) info->temp_name)) { - /* might as well exit since jpeg_open_backing_store will fail anyway */ - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - return FALSE; - } - info->handle.file_handle = handle; - info->read_backing_store = read_file_store; - info->write_backing_store = write_file_store; - info->close_backing_store = close_file_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); - return TRUE; /* succeeded */ -} - - -/* - * Access methods for extended memory. - */ - -#if XMS_SUPPORTED - -static XMSDRIVER xms_driver; /* saved address of XMS driver */ - -typedef union { /* either long offset or real-mode pointer */ - long offset; - void far * ptr; - } XMSPTR; - -typedef struct { /* XMS move specification structure */ - long length; - XMSH src_handle; - XMSPTR src; - XMSH dst_handle; - XMSPTR dst; - } XMSspec; - -#define ODD(X) (((X) & 1L) != 0) - - -METHODDEF(void) -read_xms_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - XMScontext ctx; - XMSspec spec; - char endbuffer[2]; - - /* The XMS driver can't cope with an odd length, so handle the last byte - * specially if byte_count is odd. We don't expect this to be common. - */ - - spec.length = byte_count & (~ 1L); - spec.src_handle = info->handle.xms_handle; - spec.src.offset = file_offset; - spec.dst_handle = 0; - spec.dst.ptr = buffer_address; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x0b00; /* EMB move */ - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - ERREXIT(cinfo, JERR_XMS_READ); - - if (ODD(byte_count)) { - read_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0]; - } -} - - -METHODDEF(void) -write_xms_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - XMScontext ctx; - XMSspec spec; - char endbuffer[2]; - - /* The XMS driver can't cope with an odd length, so handle the last byte - * specially if byte_count is odd. We don't expect this to be common. - */ - - spec.length = byte_count & (~ 1L); - spec.src_handle = 0; - spec.src.ptr = buffer_address; - spec.dst_handle = info->handle.xms_handle; - spec.dst.offset = file_offset; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x0b00; /* EMB move */ - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - ERREXIT(cinfo, JERR_XMS_WRITE); - - if (ODD(byte_count)) { - read_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L]; - write_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - } -} - - -METHODDEF(void) -close_xms_store (j_common_ptr cinfo, backing_store_ptr info) -{ - XMScontext ctx; - - ctx.dx = info->handle.xms_handle; - ctx.ax = 0x0a00; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle); - /* we ignore any error return from the driver */ -} - - -LOCAL(boolean) -open_xms_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - XMScontext ctx; - - /* Get address of XMS driver */ - jxms_getdriver((XMSDRIVER far *) & xms_driver); - if (xms_driver == NULL) - return FALSE; /* no driver to be had */ - - /* Get version number, must be >= 2.00 */ - ctx.ax = 0x0000; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax < (unsigned short) 0x0200) - return FALSE; - - /* Try to get space (expressed in kilobytes) */ - ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10); - ctx.ax = 0x0900; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - return FALSE; - - /* Succeeded, save the handle and away we go */ - info->handle.xms_handle = ctx.dx; - info->read_backing_store = read_xms_store; - info->write_backing_store = write_xms_store; - info->close_backing_store = close_xms_store; - TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx); - return TRUE; /* succeeded */ -} - -#endif /* XMS_SUPPORTED */ - - -/* - * Access methods for expanded memory. - */ - -#if EMS_SUPPORTED - -/* The EMS move specification structure requires word and long fields aligned - * at odd byte boundaries. Some compilers will align struct fields at even - * byte boundaries. While it's usually possible to force byte alignment, - * that causes an overall performance penalty and may pose problems in merging - * JPEG into a larger application. Instead we accept some rather dirty code - * here. Note this code would fail if the hardware did not allow odd-byte - * word & long accesses, but all 80x86 CPUs do. - */ - -typedef void far * EMSPTR; - -typedef union { /* EMS move specification structure */ - long length; /* It's easy to access first 4 bytes */ - char bytes[18]; /* Misaligned fields in here! */ - } EMSspec; - -/* Macros for accessing misaligned fields */ -#define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset]))) -#define SRC_TYPE(spec) FIELD_AT(spec,4,char) -#define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH) -#define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short) -#define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short) -#define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR) -#define DST_TYPE(spec) FIELD_AT(spec,11,char) -#define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH) -#define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short) -#define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short) -#define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR) - -#define EMSPAGESIZE 16384L /* gospel, see the EMS specs */ - -#define HIBYTE(W) (((W) >> 8) & 0xFF) -#define LOBYTE(W) ((W) & 0xFF) - - -METHODDEF(void) -read_ems_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - EMScontext ctx; - EMSspec spec; - - spec.length = byte_count; - SRC_TYPE(spec) = 1; - SRC_HANDLE(spec) = info->handle.ems_handle; - SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); - SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); - DST_TYPE(spec) = 0; - DST_HANDLE(spec) = 0; - DST_PTR(spec) = buffer_address; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x5700; /* move memory region */ - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - ERREXIT(cinfo, JERR_EMS_READ); -} - - -METHODDEF(void) -write_ems_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - EMScontext ctx; - EMSspec spec; - - spec.length = byte_count; - SRC_TYPE(spec) = 0; - SRC_HANDLE(spec) = 0; - SRC_PTR(spec) = buffer_address; - DST_TYPE(spec) = 1; - DST_HANDLE(spec) = info->handle.ems_handle; - DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); - DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x5700; /* move memory region */ - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - ERREXIT(cinfo, JERR_EMS_WRITE); -} - - -METHODDEF(void) -close_ems_store (j_common_ptr cinfo, backing_store_ptr info) -{ - EMScontext ctx; - - ctx.ax = 0x4500; - ctx.dx = info->handle.ems_handle; - jems_calldriver((EMScontext far *) & ctx); - TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle); - /* we ignore any error return from the driver */ -} - - -LOCAL(boolean) -open_ems_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - EMScontext ctx; - - /* Is EMS driver there? */ - if (! jems_available()) - return FALSE; - - /* Get status, make sure EMS is OK */ - ctx.ax = 0x4000; - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - return FALSE; - - /* Get version, must be >= 4.0 */ - ctx.ax = 0x4600; - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40) - return FALSE; - - /* Try to allocate requested space */ - ctx.ax = 0x4300; - ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE); - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - return FALSE; - - /* Succeeded, save the handle and away we go */ - info->handle.ems_handle = ctx.dx; - info->read_backing_store = read_ems_store; - info->write_backing_store = write_ems_store; - info->close_backing_store = close_ems_store; - TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx); - return TRUE; /* succeeded */ -} - -#endif /* EMS_SUPPORTED */ - - -/* - * Initial opening of a backing-store object. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - /* Try extended memory, then expanded memory, then regular file. */ -#if XMS_SUPPORTED - if (open_xms_store(cinfo, info, total_bytes_needed)) - return; -#endif -#if EMS_SUPPORTED - if (open_ems_store(cinfo, info, total_bytes_needed)) - return; -#endif - if (open_file_store(cinfo, info, total_bytes_needed)) - return; - ERREXITS(cinfo, JERR_TFILE_CREATE, ""); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; /* initialize temp file name generator */ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* Microsoft C, at least in v6.00A, will not successfully reclaim freed - * blocks of size > 32Kbytes unless we give it a kick in the rear, like so: - */ -#ifdef NEED_FHEAPMIN - _fheapmin(); -#endif -} diff --git a/freeimage241/Source/LibJPEG/jmemdosa.asm b/freeimage241/Source/LibJPEG/jmemdosa.asm deleted file mode 100644 index ecd4372..0000000 --- a/freeimage241/Source/LibJPEG/jmemdosa.asm +++ /dev/null @@ -1,379 +0,0 @@ -; -; jmemdosa.asm -; -; Copyright (C) 1992, Thomas G. Lane. -; This file is part of the Independent JPEG Group's software. -; For conditions of distribution and use, see the accompanying README file. -; -; This file contains low-level interface routines to support the MS-DOS -; backing store manager (jmemdos.c). Routines are provided to access disk -; files through direct DOS calls, and to access XMS and EMS drivers. -; -; This file should assemble with Microsoft's MASM or any compatible -; assembler (including Borland's Turbo Assembler). If you haven't got -; a compatible assembler, better fall back to jmemansi.c or jmemname.c. -; -; To minimize dependence on the C compiler's register usage conventions, -; we save and restore all 8086 registers, even though most compilers only -; require SI,DI,DS to be preserved. Also, we use only 16-bit-wide return -; values, which everybody returns in AX. -; -; Based on code contributed by Ge' Weijers. -; - -JMEMDOSA_TXT segment byte public 'CODE' - - assume cs:JMEMDOSA_TXT - - public _jdos_open - public _jdos_close - public _jdos_seek - public _jdos_read - public _jdos_write - public _jxms_getdriver - public _jxms_calldriver - public _jems_available - public _jems_calldriver - -; -; short far jdos_open (short far * handle, char far * filename) -; -; Create and open a temporary file -; -_jdos_open proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov cx,0 ; normal file attributes - lds dx,dword ptr [bp+10] ; get filename pointer - mov ah,3ch ; create file - int 21h - jc open_err ; if failed, return error code - lds bx,dword ptr [bp+6] ; get handle pointer - mov word ptr [bx],ax ; save the handle - xor ax,ax ; return zero for OK -open_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_open endp - - -; -; short far jdos_close (short handle) -; -; Close the file handle -; -_jdos_close proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - mov ah,3eh ; close file - int 21h - jc close_err ; if failed, return error code - xor ax,ax ; return zero for OK -close_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_close endp - - -; -; short far jdos_seek (short handle, long offset) -; -; Set file position -; -_jdos_seek proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - mov dx,word ptr [bp+8] ; LS offset - mov cx,word ptr [bp+10] ; MS offset - mov ax,4200h ; absolute seek - int 21h - jc seek_err ; if failed, return error code - xor ax,ax ; return zero for OK -seek_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_seek endp - - -; -; short far jdos_read (short handle, void far * buffer, unsigned short count) -; -; Read from file -; -_jdos_read proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - lds dx,dword ptr [bp+8] ; buffer address - mov cx,word ptr [bp+12] ; number of bytes - mov ah,3fh ; read file - int 21h - jc read_err ; if failed, return error code - cmp ax,word ptr [bp+12] ; make sure all bytes were read - je read_ok - mov ax,1 ; else return 1 for not OK - jmp short read_err -read_ok: xor ax,ax ; return zero for OK -read_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_read endp - - -; -; short far jdos_write (short handle, void far * buffer, unsigned short count) -; -; Write to file -; -_jdos_write proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov bx,word ptr [bp+6] ; file handle - lds dx,dword ptr [bp+8] ; buffer address - mov cx,word ptr [bp+12] ; number of bytes - mov ah,40h ; write file - int 21h - jc write_err ; if failed, return error code - cmp ax,word ptr [bp+12] ; make sure all bytes written - je write_ok - mov ax,1 ; else return 1 for not OK - jmp short write_err -write_ok: xor ax,ax ; return zero for OK -write_err: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jdos_write endp - - -; -; void far jxms_getdriver (XMSDRIVER far *) -; -; Get the address of the XMS driver, or NULL if not available -; -_jxms_getdriver proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov ax,4300h ; call multiplex interrupt with - int 2fh ; a magic cookie, hex 4300 - cmp al,80h ; AL should contain hex 80 - je xmsavail - xor dx,dx ; no XMS driver available - xor ax,ax ; return a nil pointer - jmp short xmsavail_done -xmsavail: mov ax,4310h ; fetch driver address with - int 2fh ; another magic cookie - mov dx,es ; copy address to dx:ax - mov ax,bx -xmsavail_done: les bx,dword ptr [bp+6] ; get pointer to return value - mov word ptr es:[bx],ax - mov word ptr es:[bx+2],dx - pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jxms_getdriver endp - - -; -; void far jxms_calldriver (XMSDRIVER, XMScontext far *) -; -; The XMScontext structure contains values for the AX,DX,BX,SI,DS registers. -; These are loaded, the XMS call is performed, and the new values of the -; AX,DX,BX registers are written back to the context structure. -; -_jxms_calldriver proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - les bx,dword ptr [bp+10] ; get XMScontext pointer - mov ax,word ptr es:[bx] ; load registers - mov dx,word ptr es:[bx+2] - mov si,word ptr es:[bx+6] - mov ds,word ptr es:[bx+8] - mov bx,word ptr es:[bx+4] - call dword ptr [bp+6] ; call the driver - mov cx,bx ; save returned BX for a sec - les bx,dword ptr [bp+10] ; get XMScontext pointer - mov word ptr es:[bx],ax ; put back ax,dx,bx - mov word ptr es:[bx+2],dx - mov word ptr es:[bx+4],cx - pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jxms_calldriver endp - - -; -; short far jems_available (void) -; -; Have we got an EMS driver? (this comes straight from the EMS 4.0 specs) -; -_jems_available proc far - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - mov ax,3567h ; get interrupt vector 67h - int 21h - push cs - pop ds - mov di,000ah ; check offs 10 in returned seg - lea si,ASCII_device_name ; against literal string - mov cx,8 - cld - repe cmpsb - jne no_ems - mov ax,1 ; match, it's there - jmp short avail_done -no_ems: xor ax,ax ; it's not there -avail_done: pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - ret - -ASCII_device_name db "EMMXXXX0" - -_jems_available endp - - -; -; void far jems_calldriver (EMScontext far *) -; -; The EMScontext structure contains values for the AX,DX,BX,SI,DS registers. -; These are loaded, the EMS trap is performed, and the new values of the -; AX,DX,BX registers are written back to the context structure. -; -_jems_calldriver proc far - push bp ; linkage - mov bp,sp - push si ; save all registers for safety - push di - push bx - push cx - push dx - push es - push ds - les bx,dword ptr [bp+6] ; get EMScontext pointer - mov ax,word ptr es:[bx] ; load registers - mov dx,word ptr es:[bx+2] - mov si,word ptr es:[bx+6] - mov ds,word ptr es:[bx+8] - mov bx,word ptr es:[bx+4] - int 67h ; call the EMS driver - mov cx,bx ; save returned BX for a sec - les bx,dword ptr [bp+6] ; get EMScontext pointer - mov word ptr es:[bx],ax ; put back ax,dx,bx - mov word ptr es:[bx+2],dx - mov word ptr es:[bx+4],cx - pop ds ; restore registers and exit - pop es - pop dx - pop cx - pop bx - pop di - pop si - pop bp - ret -_jems_calldriver endp - -JMEMDOSA_TXT ends - - end diff --git a/freeimage241/Source/LibJPEG/jmemmac.c b/freeimage241/Source/LibJPEG/jmemmac.c deleted file mode 100644 index 106f9be..0000000 --- a/freeimage241/Source/LibJPEG/jmemmac.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * jmemmac.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * jmemmac.c provides an Apple Macintosh implementation of the system- - * dependent portion of the JPEG memory manager. - * - * If you use jmemmac.c, then you must define USE_MAC_MEMMGR in the - * JPEG_INTERNALS part of jconfig.h. - * - * jmemmac.c uses the Macintosh toolbox routines NewPtr and DisposePtr - * instead of malloc and free. It accurately determines the amount of - * memory available by using CompactMem. Notice that if left to its - * own devices, this code can chew up all available space in the - * application's zone, with the exception of the rather small "slop" - * factor computed in jpeg_mem_available(). The application can ensure - * that more space is left over by reducing max_memory_to_use. - * - * Large images are swapped to disk using temporary files and System 7.0+'s - * temporary folder functionality. - * - * Note that jmemmac.c depends on two features of MacOS that were first - * introduced in System 7: FindFolder and the FSSpec-based calls. - * If your application uses jmemmac.c and is run under System 6 or earlier, - * and the jpeg library decides it needs a temporary file, it will abort, - * printing error messages about requiring System 7. (If no temporary files - * are created, it will run fine.) - * - * If you want to use jmemmac.c in an application that might be used with - * System 6 or earlier, then you should remove dependencies on FindFolder - * and the FSSpec calls. You will need to replace FindFolder with some - * other mechanism for finding a place to put temporary files, and you - * should replace the FSSpec calls with their HFS equivalents: - * - * FSpDelete -> HDelete - * FSpGetFInfo -> HGetFInfo - * FSpCreate -> HCreate - * FSpOpenDF -> HOpen *** Note: not HOpenDF *** - * FSMakeFSSpec -> (fill in spec by hand.) - * - * (Use HOpen instead of HOpenDF. HOpen is just a glue-interface to PBHOpen, - * which is on all HFS macs. HOpenDF is a System 7 addition which avoids the - * ages-old problem of names starting with a period.) - * - * Contributed by Sam Bushell (jsam@iagu.on.net) and - * Dan Gildor (gyld@in-touch.com). - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef USE_MAC_MEMMGR /* make sure user got configuration right */ - You forgot to define USE_MAC_MEMMGR in jconfig.h. /* deliberate syntax error */ -#endif - -#include /* we use the MacOS memory manager */ -#include /* we use the MacOS File stuff */ -#include /* we use the MacOS HFS stuff */ -#include /* for smSystemScript */ -#include /* we use Gestalt to test for specific functionality */ - -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "JPG%03d.TMP" -#endif - -static int next_file_num; /* to distinguish among several temp files */ - - -/* - * Memory allocation and freeing are controlled by the MacOS library - * routines NewPtr() and DisposePtr(), which allocate fixed-address - * storage. Unfortunately, the IJG library isn't smart enough to cope - * with relocatable storage. - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) NewPtr(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - DisposePtr((Ptr) object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: we include FAR keywords in the routine declarations simply for - * consistency with the rest of the IJG code; FAR should expand to empty - * on rational architectures like the Mac. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) NewPtr(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - DisposePtr((Ptr) object); -} - - -/* - * This routine computes the total memory space available for allocation. - */ - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - long limit = cinfo->mem->max_memory_to_use - already_allocated; - long slop, mem; - - /* Don't ask for more than what application has told us we may use */ - if (max_bytes_needed > limit && limit > 0) - max_bytes_needed = limit; - /* Find whether there's a big enough free block in the heap. - * CompactMem tries to create a contiguous block of the requested size, - * and then returns the size of the largest free block (which could be - * much more or much less than we asked for). - * We add some slop to ensure we don't use up all available memory. - */ - slop = max_bytes_needed / 16 + 32768L; - mem = CompactMem(max_bytes_needed + slop) - slop; - if (mem < 0) - mem = 0; /* sigh, couldn't even get the slop */ - /* Don't take more than the application says we can have */ - if (mem > limit && limit > 0) - mem = limit; - return mem; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - long bytes = byte_count; - long retVal; - - if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) - ERREXIT(cinfo, JERR_TFILE_SEEK); - - retVal = FSRead ( info->temp_file, &bytes, - (unsigned char *) buffer_address ); - if ( retVal != noErr || bytes != byte_count ) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - long bytes = byte_count; - long retVal; - - if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) - ERREXIT(cinfo, JERR_TFILE_SEEK); - - retVal = FSWrite ( info->temp_file, &bytes, - (unsigned char *) buffer_address ); - if ( retVal != noErr || bytes != byte_count ) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - FSClose ( info->temp_file ); - FSpDelete ( &(info->tempSpec) ); -} - - -/* - * Initial opening of a backing-store object. - * - * This version uses FindFolder to find the Temporary Items folder, - * and puts the temporary file in there. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - short tmpRef, vRefNum; - long dirID; - FInfo finderInfo; - FSSpec theSpec; - Str255 fName; - OSErr osErr; - long gestaltResponse = 0; - - /* Check that FSSpec calls are available. */ - osErr = Gestalt( gestaltFSAttr, &gestaltResponse ); - if ( ( osErr != noErr ) - || !( gestaltResponse & (1<temp_name, TEMP_FILE_NAME, next_file_num); - strcpy ( (Ptr)fName+1, info->temp_name ); - *fName = strlen (info->temp_name); - osErr = FSMakeFSSpec ( vRefNum, dirID, fName, &theSpec ); - - if ( (osErr = FSpGetFInfo ( &theSpec, &finderInfo ) ) != noErr ) - break; - } - - osErr = FSpCreate ( &theSpec, '????', '????', smSystemScript ); - if ( osErr != noErr ) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - - osErr = FSpOpenDF ( &theSpec, fsRdWrPerm, &(info->temp_file) ); - if ( osErr != noErr ) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - - info->tempSpec = theSpec; - - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; - - /* max_memory_to_use will be initialized to FreeMem()'s result; - * the calling application might later reduce it, for example - * to leave room to invoke multiple JPEG objects. - * Note that FreeMem returns the total number of free bytes; - * it may not be possible to allocate a single block of this size. - */ - return FreeMem(); -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/freeimage241/Source/LibJPEG/jmemmgr.c b/freeimage241/Source/LibJPEG/jmemmgr.c deleted file mode 100644 index d801b32..0000000 --- a/freeimage241/Source/LibJPEG/jmemmgr.c +++ /dev/null @@ -1,1118 +0,0 @@ -/* - * jmemmgr.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the JPEG system-independent memory management - * routines. This code is usable across a wide variety of machines; most - * of the system dependencies have been isolated in a separate file. - * The major functions provided here are: - * * pool-based allocation and freeing of memory; - * * policy decisions about how to divide available memory among the - * virtual arrays; - * * control logic for swapping virtual arrays between main memory and - * backing storage. - * The separate system-dependent file provides the actual backing-storage - * access code, and it contains the policy decision about how much total - * main memory to use. - * This file is system-dependent in the sense that some of its functions - * are unnecessary in some systems. For example, if there is enough virtual - * memory so that backing storage will never be used, much of the virtual - * array control logic could be removed. (Of course, if you have that much - * memory then you shouldn't care about a little bit of unused code...) - */ - -#define JPEG_INTERNALS -#define AM_MEMORY_MANAGER /* we define jvirt_Xarray_control structs */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef NO_GETENV -#ifndef HAVE_STDLIB_H /* should declare getenv() */ -extern char * getenv JPP((const char * name)); -#endif -#endif - - -/* - * Some important notes: - * The allocation routines provided here must never return NULL. - * They should exit to error_exit if unsuccessful. - * - * It's not a good idea to try to merge the sarray and barray routines, - * even though they are textually almost the same, because samples are - * usually stored as bytes while coefficients are shorts or ints. Thus, - * in machines where byte pointers have a different representation from - * word pointers, the resulting machine code could not be the same. - */ - - -/* - * Many machines require storage alignment: longs must start on 4-byte - * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc() - * always returns pointers that are multiples of the worst-case alignment - * requirement, and we had better do so too. - * There isn't any really portable way to determine the worst-case alignment - * requirement. This module assumes that the alignment requirement is - * multiples of sizeof(ALIGN_TYPE). - * By default, we define ALIGN_TYPE as double. This is necessary on some - * workstations (where doubles really do need 8-byte alignment) and will work - * fine on nearly everything. If your machine has lesser alignment needs, - * you can save a few bytes by making ALIGN_TYPE smaller. - * The only place I know of where this will NOT work is certain Macintosh - * 680x0 compilers that define double as a 10-byte IEEE extended float. - * Doing 10-byte alignment is counterproductive because longwords won't be - * aligned well. Put "#define ALIGN_TYPE long" in jconfig.h if you have - * such a compiler. - */ - -#ifndef ALIGN_TYPE /* so can override from jconfig.h */ -#define ALIGN_TYPE double -#endif - - -/* - * We allocate objects from "pools", where each pool is gotten with a single - * request to jpeg_get_small() or jpeg_get_large(). There is no per-object - * overhead within a pool, except for alignment padding. Each pool has a - * header with a link to the next pool of the same class. - * Small and large pool headers are identical except that the latter's - * link pointer must be FAR on 80x86 machines. - * Notice that the "real" header fields are union'ed with a dummy ALIGN_TYPE - * field. This forces the compiler to make SIZEOF(small_pool_hdr) a multiple - * of the alignment requirement of ALIGN_TYPE. - */ - -typedef union small_pool_struct * small_pool_ptr; - -typedef union small_pool_struct { - struct { - small_pool_ptr next; /* next in list of pools */ - size_t bytes_used; /* how many bytes already used within pool */ - size_t bytes_left; /* bytes still available in this pool */ - } hdr; - ALIGN_TYPE dummy; /* included in union to ensure alignment */ -} small_pool_hdr; - -typedef union large_pool_struct FAR * large_pool_ptr; - -typedef union large_pool_struct { - struct { - large_pool_ptr next; /* next in list of pools */ - size_t bytes_used; /* how many bytes already used within pool */ - size_t bytes_left; /* bytes still available in this pool */ - } hdr; - ALIGN_TYPE dummy; /* included in union to ensure alignment */ -} large_pool_hdr; - - -/* - * Here is the full definition of a memory manager object. - */ - -typedef struct { - struct jpeg_memory_mgr pub; /* public fields */ - - /* Each pool identifier (lifetime class) names a linked list of pools. */ - small_pool_ptr small_list[JPOOL_NUMPOOLS]; - large_pool_ptr large_list[JPOOL_NUMPOOLS]; - - /* Since we only have one lifetime class of virtual arrays, only one - * linked list is necessary (for each datatype). Note that the virtual - * array control blocks being linked together are actually stored somewhere - * in the small-pool list. - */ - jvirt_sarray_ptr virt_sarray_list; - jvirt_barray_ptr virt_barray_list; - - /* This counts total space obtained from jpeg_get_small/large */ - long total_space_allocated; - - /* alloc_sarray and alloc_barray set this value for use by virtual - * array routines. - */ - JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */ -} my_memory_mgr; - -typedef my_memory_mgr * my_mem_ptr; - - -/* - * The control blocks for virtual arrays. - * Note that these blocks are allocated in the "small" pool area. - * System-dependent info for the associated backing store (if any) is hidden - * inside the backing_store_info struct. - */ - -struct jvirt_sarray_control { - JSAMPARRAY mem_buffer; /* => the in-memory buffer */ - JDIMENSION rows_in_array; /* total virtual array height */ - JDIMENSION samplesperrow; /* width of array (and of memory buffer) */ - JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */ - JDIMENSION rows_in_mem; /* height of memory buffer */ - JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ - JDIMENSION cur_start_row; /* first logical row # in the buffer */ - JDIMENSION first_undef_row; /* row # of first uninitialized row */ - boolean pre_zero; /* pre-zero mode requested? */ - boolean dirty; /* do current buffer contents need written? */ - boolean b_s_open; /* is backing-store data valid? */ - jvirt_sarray_ptr next; /* link to next virtual sarray control block */ - backing_store_info b_s_info; /* System-dependent control info */ -}; - -struct jvirt_barray_control { - JBLOCKARRAY mem_buffer; /* => the in-memory buffer */ - JDIMENSION rows_in_array; /* total virtual array height */ - JDIMENSION blocksperrow; /* width of array (and of memory buffer) */ - JDIMENSION maxaccess; /* max rows accessed by access_virt_barray */ - JDIMENSION rows_in_mem; /* height of memory buffer */ - JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ - JDIMENSION cur_start_row; /* first logical row # in the buffer */ - JDIMENSION first_undef_row; /* row # of first uninitialized row */ - boolean pre_zero; /* pre-zero mode requested? */ - boolean dirty; /* do current buffer contents need written? */ - boolean b_s_open; /* is backing-store data valid? */ - jvirt_barray_ptr next; /* link to next virtual barray control block */ - backing_store_info b_s_info; /* System-dependent control info */ -}; - - -#ifdef MEM_STATS /* optional extra stuff for statistics */ - -LOCAL(void) -print_mem_stats (j_common_ptr cinfo, int pool_id) -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr shdr_ptr; - large_pool_ptr lhdr_ptr; - - /* Since this is only a debugging stub, we can cheat a little by using - * fprintf directly rather than going through the trace message code. - * This is helpful because message parm array can't handle longs. - */ - fprintf(stderr, "Freeing pool %d, total space = %ld\n", - pool_id, mem->total_space_allocated); - - for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; - lhdr_ptr = lhdr_ptr->hdr.next) { - fprintf(stderr, " Large chunk used %ld\n", - (long) lhdr_ptr->hdr.bytes_used); - } - - for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; - shdr_ptr = shdr_ptr->hdr.next) { - fprintf(stderr, " Small chunk used %ld free %ld\n", - (long) shdr_ptr->hdr.bytes_used, - (long) shdr_ptr->hdr.bytes_left); - } -} - -#endif /* MEM_STATS */ - - -LOCAL(void) -out_of_memory (j_common_ptr cinfo, int which) -/* Report an out-of-memory error and stop execution */ -/* If we compiled MEM_STATS support, report alloc requests before dying */ -{ -#ifdef MEM_STATS - cinfo->err->trace_level = 2; /* force self_destruct to report stats */ -#endif - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which); -} - - -/* - * Allocation of "small" objects. - * - * For these, we use pooled storage. When a new pool must be created, - * we try to get enough space for the current request plus a "slop" factor, - * where the slop will be the amount of leftover space in the new pool. - * The speed vs. space tradeoff is largely determined by the slop values. - * A different slop value is provided for each pool class (lifetime), - * and we also distinguish the first pool of a class from later ones. - * NOTE: the values given work fairly well on both 16- and 32-bit-int - * machines, but may be too small if longs are 64 bits or more. - */ - -static const size_t first_pool_slop[JPOOL_NUMPOOLS] = -{ - 1600, /* first PERMANENT pool */ - 16000 /* first IMAGE pool */ -}; - -static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = -{ - 0, /* additional PERMANENT pools */ - 5000 /* additional IMAGE pools */ -}; - -#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */ - - -METHODDEF(void *) -alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) -/* Allocate a "small" object */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr hdr_ptr, prev_hdr_ptr; - char * data_ptr; - size_t odd_bytes, min_request, slop; - - /* Check for unsatisfiable request (do now to ensure no overflow below) */ - if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr))) - out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ - - /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ - odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); - if (odd_bytes > 0) - sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; - - /* See if space is available in any existing pool */ - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - prev_hdr_ptr = NULL; - hdr_ptr = mem->small_list[pool_id]; - while (hdr_ptr != NULL) { - if (hdr_ptr->hdr.bytes_left >= sizeofobject) - break; /* found pool with enough space */ - prev_hdr_ptr = hdr_ptr; - hdr_ptr = hdr_ptr->hdr.next; - } - - /* Time to make a new pool? */ - if (hdr_ptr == NULL) { - /* min_request is what we need now, slop is what will be leftover */ - min_request = sizeofobject + SIZEOF(small_pool_hdr); - if (prev_hdr_ptr == NULL) /* first pool in class? */ - slop = first_pool_slop[pool_id]; - else - slop = extra_pool_slop[pool_id]; - /* Don't ask for more than MAX_ALLOC_CHUNK */ - if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request)) - slop = (size_t) (MAX_ALLOC_CHUNK-min_request); - /* Try to get space, if fail reduce slop and try again */ - for (;;) { - hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop); - if (hdr_ptr != NULL) - break; - slop /= 2; - if (slop < MIN_SLOP) /* give up when it gets real small */ - out_of_memory(cinfo, 2); /* jpeg_get_small failed */ - } - mem->total_space_allocated += min_request + slop; - /* Success, initialize the new pool header and add to end of list */ - hdr_ptr->hdr.next = NULL; - hdr_ptr->hdr.bytes_used = 0; - hdr_ptr->hdr.bytes_left = sizeofobject + slop; - if (prev_hdr_ptr == NULL) /* first pool in class? */ - mem->small_list[pool_id] = hdr_ptr; - else - prev_hdr_ptr->hdr.next = hdr_ptr; - } - - /* OK, allocate the object from the current pool */ - data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */ - data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */ - hdr_ptr->hdr.bytes_used += sizeofobject; - hdr_ptr->hdr.bytes_left -= sizeofobject; - - return (void *) data_ptr; -} - - -/* - * Allocation of "large" objects. - * - * The external semantics of these are the same as "small" objects, - * except that FAR pointers are used on 80x86. However the pool - * management heuristics are quite different. We assume that each - * request is large enough that it may as well be passed directly to - * jpeg_get_large; the pool management just links everything together - * so that we can free it all on demand. - * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY - * structures. The routines that create these structures (see below) - * deliberately bunch rows together to ensure a large request size. - */ - -METHODDEF(void FAR *) -alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) -/* Allocate a "large" object */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - large_pool_ptr hdr_ptr; - size_t odd_bytes; - - /* Check for unsatisfiable request (do now to ensure no overflow below) */ - if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr))) - out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ - - /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ - odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); - if (odd_bytes > 0) - sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; - - /* Always make a new pool */ - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + - SIZEOF(large_pool_hdr)); - if (hdr_ptr == NULL) - out_of_memory(cinfo, 4); /* jpeg_get_large failed */ - mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); - - /* Success, initialize the new pool header and add to list */ - hdr_ptr->hdr.next = mem->large_list[pool_id]; - /* We maintain space counts in each pool header for statistical purposes, - * even though they are not needed for allocation. - */ - hdr_ptr->hdr.bytes_used = sizeofobject; - hdr_ptr->hdr.bytes_left = 0; - mem->large_list[pool_id] = hdr_ptr; - - return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */ -} - - -/* - * Creation of 2-D sample arrays. - * The pointers are in near heap, the samples themselves in FAR heap. - * - * To minimize allocation overhead and to allow I/O of large contiguous - * blocks, we allocate the sample rows in groups of as many rows as possible - * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request. - * NB: the virtual array control routines, later in this file, know about - * this chunking of rows. The rowsperchunk value is left in the mem manager - * object so that it can be saved away if this sarray is the workspace for - * a virtual array. - */ - -METHODDEF(JSAMPARRAY) -alloc_sarray (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, JDIMENSION numrows) -/* Allocate a 2-D sample array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - JSAMPARRAY result; - JSAMPROW workspace; - JDIMENSION rowsperchunk, currow, i; - long ltemp; - - /* Calculate max # of rows allowed in one allocation chunk */ - ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / - ((long) samplesperrow * SIZEOF(JSAMPLE)); - if (ltemp <= 0) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - if (ltemp < (long) numrows) - rowsperchunk = (JDIMENSION) ltemp; - else - rowsperchunk = numrows; - mem->last_rowsperchunk = rowsperchunk; - - /* Get space for row pointers (small object) */ - result = (JSAMPARRAY) alloc_small(cinfo, pool_id, - (size_t) (numrows * SIZEOF(JSAMPROW))); - - /* Get the rows themselves (large objects) */ - currow = 0; - while (currow < numrows) { - rowsperchunk = MIN(rowsperchunk, numrows - currow); - workspace = (JSAMPROW) alloc_large(cinfo, pool_id, - (size_t) ((size_t) rowsperchunk * (size_t) samplesperrow - * SIZEOF(JSAMPLE))); - for (i = rowsperchunk; i > 0; i--) { - result[currow++] = workspace; - workspace += samplesperrow; - } - } - - return result; -} - - -/* - * Creation of 2-D coefficient-block arrays. - * This is essentially the same as the code for sample arrays, above. - */ - -METHODDEF(JBLOCKARRAY) -alloc_barray (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, JDIMENSION numrows) -/* Allocate a 2-D coefficient-block array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - JBLOCKARRAY result; - JBLOCKROW workspace; - JDIMENSION rowsperchunk, currow, i; - long ltemp; - - /* Calculate max # of rows allowed in one allocation chunk */ - ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / - ((long) blocksperrow * SIZEOF(JBLOCK)); - if (ltemp <= 0) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - if (ltemp < (long) numrows) - rowsperchunk = (JDIMENSION) ltemp; - else - rowsperchunk = numrows; - mem->last_rowsperchunk = rowsperchunk; - - /* Get space for row pointers (small object) */ - result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, - (size_t) (numrows * SIZEOF(JBLOCKROW))); - - /* Get the rows themselves (large objects) */ - currow = 0; - while (currow < numrows) { - rowsperchunk = MIN(rowsperchunk, numrows - currow); - workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, - (size_t) ((size_t) rowsperchunk * (size_t) blocksperrow - * SIZEOF(JBLOCK))); - for (i = rowsperchunk; i > 0; i--) { - result[currow++] = workspace; - workspace += blocksperrow; - } - } - - return result; -} - - -/* - * About virtual array management: - * - * The above "normal" array routines are only used to allocate strip buffers - * (as wide as the image, but just a few rows high). Full-image-sized buffers - * are handled as "virtual" arrays. The array is still accessed a strip at a - * time, but the memory manager must save the whole array for repeated - * accesses. The intended implementation is that there is a strip buffer in - * memory (as high as is possible given the desired memory limit), plus a - * backing file that holds the rest of the array. - * - * The request_virt_array routines are told the total size of the image and - * the maximum number of rows that will be accessed at once. The in-memory - * buffer must be at least as large as the maxaccess value. - * - * The request routines create control blocks but not the in-memory buffers. - * That is postponed until realize_virt_arrays is called. At that time the - * total amount of space needed is known (approximately, anyway), so free - * memory can be divided up fairly. - * - * The access_virt_array routines are responsible for making a specific strip - * area accessible (after reading or writing the backing file, if necessary). - * Note that the access routines are told whether the caller intends to modify - * the accessed strip; during a read-only pass this saves having to rewrite - * data to disk. The access routines are also responsible for pre-zeroing - * any newly accessed rows, if pre-zeroing was requested. - * - * In current usage, the access requests are usually for nonoverlapping - * strips; that is, successive access start_row numbers differ by exactly - * num_rows = maxaccess. This means we can get good performance with simple - * buffer dump/reload logic, by making the in-memory buffer be a multiple - * of the access height; then there will never be accesses across bufferload - * boundaries. The code will still work with overlapping access requests, - * but it doesn't handle bufferload overlaps very efficiently. - */ - - -METHODDEF(jvirt_sarray_ptr) -request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION samplesperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -/* Request a virtual 2-D sample array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - jvirt_sarray_ptr result; - - /* Only IMAGE-lifetime virtual arrays are currently supported */ - if (pool_id != JPOOL_IMAGE) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - /* get control block */ - result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id, - SIZEOF(struct jvirt_sarray_control)); - - result->mem_buffer = NULL; /* marks array not yet realized */ - result->rows_in_array = numrows; - result->samplesperrow = samplesperrow; - result->maxaccess = maxaccess; - result->pre_zero = pre_zero; - result->b_s_open = FALSE; /* no associated backing-store object */ - result->next = mem->virt_sarray_list; /* add to list of virtual arrays */ - mem->virt_sarray_list = result; - - return result; -} - - -METHODDEF(jvirt_barray_ptr) -request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION blocksperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -/* Request a virtual 2-D coefficient-block array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - jvirt_barray_ptr result; - - /* Only IMAGE-lifetime virtual arrays are currently supported */ - if (pool_id != JPOOL_IMAGE) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - /* get control block */ - result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id, - SIZEOF(struct jvirt_barray_control)); - - result->mem_buffer = NULL; /* marks array not yet realized */ - result->rows_in_array = numrows; - result->blocksperrow = blocksperrow; - result->maxaccess = maxaccess; - result->pre_zero = pre_zero; - result->b_s_open = FALSE; /* no associated backing-store object */ - result->next = mem->virt_barray_list; /* add to list of virtual arrays */ - mem->virt_barray_list = result; - - return result; -} - - -METHODDEF(void) -realize_virt_arrays (j_common_ptr cinfo) -/* Allocate the in-memory buffers for any unrealized virtual arrays */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - long space_per_minheight, maximum_space, avail_mem; - long minheights, max_minheights; - jvirt_sarray_ptr sptr; - jvirt_barray_ptr bptr; - - /* Compute the minimum space needed (maxaccess rows in each buffer) - * and the maximum space needed (full image height in each buffer). - * These may be of use to the system-dependent jpeg_mem_available routine. - */ - space_per_minheight = 0; - maximum_space = 0; - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->mem_buffer == NULL) { /* if not realized yet */ - space_per_minheight += (long) sptr->maxaccess * - (long) sptr->samplesperrow * SIZEOF(JSAMPLE); - maximum_space += (long) sptr->rows_in_array * - (long) sptr->samplesperrow * SIZEOF(JSAMPLE); - } - } - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->mem_buffer == NULL) { /* if not realized yet */ - space_per_minheight += (long) bptr->maxaccess * - (long) bptr->blocksperrow * SIZEOF(JBLOCK); - maximum_space += (long) bptr->rows_in_array * - (long) bptr->blocksperrow * SIZEOF(JBLOCK); - } - } - - if (space_per_minheight <= 0) - return; /* no unrealized arrays, no work */ - - /* Determine amount of memory to actually use; this is system-dependent. */ - avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space, - mem->total_space_allocated); - - /* If the maximum space needed is available, make all the buffers full - * height; otherwise parcel it out with the same number of minheights - * in each buffer. - */ - if (avail_mem >= maximum_space) - max_minheights = 1000000000L; - else { - max_minheights = avail_mem / space_per_minheight; - /* If there doesn't seem to be enough space, try to get the minimum - * anyway. This allows a "stub" implementation of jpeg_mem_available(). - */ - if (max_minheights <= 0) - max_minheights = 1; - } - - /* Allocate the in-memory buffers and initialize backing store as needed. */ - - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->mem_buffer == NULL) { /* if not realized yet */ - minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L; - if (minheights <= max_minheights) { - /* This buffer fits in memory */ - sptr->rows_in_mem = sptr->rows_in_array; - } else { - /* It doesn't fit in memory, create backing store. */ - sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess); - jpeg_open_backing_store(cinfo, & sptr->b_s_info, - (long) sptr->rows_in_array * - (long) sptr->samplesperrow * - (long) SIZEOF(JSAMPLE)); - sptr->b_s_open = TRUE; - } - sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE, - sptr->samplesperrow, sptr->rows_in_mem); - sptr->rowsperchunk = mem->last_rowsperchunk; - sptr->cur_start_row = 0; - sptr->first_undef_row = 0; - sptr->dirty = FALSE; - } - } - - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->mem_buffer == NULL) { /* if not realized yet */ - minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L; - if (minheights <= max_minheights) { - /* This buffer fits in memory */ - bptr->rows_in_mem = bptr->rows_in_array; - } else { - /* It doesn't fit in memory, create backing store. */ - bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess); - jpeg_open_backing_store(cinfo, & bptr->b_s_info, - (long) bptr->rows_in_array * - (long) bptr->blocksperrow * - (long) SIZEOF(JBLOCK)); - bptr->b_s_open = TRUE; - } - bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE, - bptr->blocksperrow, bptr->rows_in_mem); - bptr->rowsperchunk = mem->last_rowsperchunk; - bptr->cur_start_row = 0; - bptr->first_undef_row = 0; - bptr->dirty = FALSE; - } - } -} - - -LOCAL(void) -do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing) -/* Do backing store read or write of a virtual sample array */ -{ - long bytesperrow, file_offset, byte_count, rows, thisrow, i; - - bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); - file_offset = ptr->cur_start_row * bytesperrow; - /* Loop to read or write each allocation chunk in mem_buffer */ - for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { - /* One chunk, but check for short chunk at end of buffer */ - rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); - /* Transfer no more than is currently defined */ - thisrow = (long) ptr->cur_start_row + i; - rows = MIN(rows, (long) ptr->first_undef_row - thisrow); - /* Transfer no more than fits in file */ - rows = MIN(rows, (long) ptr->rows_in_array - thisrow); - if (rows <= 0) /* this chunk might be past end of file! */ - break; - byte_count = rows * bytesperrow; - if (writing) - (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - else - (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - file_offset += byte_count; - } -} - - -LOCAL(void) -do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing) -/* Do backing store read or write of a virtual coefficient-block array */ -{ - long bytesperrow, file_offset, byte_count, rows, thisrow, i; - - bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); - file_offset = ptr->cur_start_row * bytesperrow; - /* Loop to read or write each allocation chunk in mem_buffer */ - for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { - /* One chunk, but check for short chunk at end of buffer */ - rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); - /* Transfer no more than is currently defined */ - thisrow = (long) ptr->cur_start_row + i; - rows = MIN(rows, (long) ptr->first_undef_row - thisrow); - /* Transfer no more than fits in file */ - rows = MIN(rows, (long) ptr->rows_in_array - thisrow); - if (rows <= 0) /* this chunk might be past end of file! */ - break; - byte_count = rows * bytesperrow; - if (writing) - (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - else - (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - file_offset += byte_count; - } -} - - -METHODDEF(JSAMPARRAY) -access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr, - JDIMENSION start_row, JDIMENSION num_rows, - boolean writable) -/* Access the part of a virtual sample array starting at start_row */ -/* and extending for num_rows rows. writable is true if */ -/* caller intends to modify the accessed area. */ -{ - JDIMENSION end_row = start_row + num_rows; - JDIMENSION undef_row; - - /* debugging check */ - if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || - ptr->mem_buffer == NULL) - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - - /* Make the desired part of the virtual array accessible */ - if (start_row < ptr->cur_start_row || - end_row > ptr->cur_start_row+ptr->rows_in_mem) { - if (! ptr->b_s_open) - ERREXIT(cinfo, JERR_VIRTUAL_BUG); - /* Flush old buffer contents if necessary */ - if (ptr->dirty) { - do_sarray_io(cinfo, ptr, TRUE); - ptr->dirty = FALSE; - } - /* Decide what part of virtual array to access. - * Algorithm: if target address > current window, assume forward scan, - * load starting at target address. If target address < current window, - * assume backward scan, load so that target area is top of window. - * Note that when switching from forward write to forward read, will have - * start_row = 0, so the limiting case applies and we load from 0 anyway. - */ - if (start_row > ptr->cur_start_row) { - ptr->cur_start_row = start_row; - } else { - /* use long arithmetic here to avoid overflow & unsigned problems */ - long ltemp; - - ltemp = (long) end_row - (long) ptr->rows_in_mem; - if (ltemp < 0) - ltemp = 0; /* don't fall off front end of file */ - ptr->cur_start_row = (JDIMENSION) ltemp; - } - /* Read in the selected part of the array. - * During the initial write pass, we will do no actual read - * because the selected part is all undefined. - */ - do_sarray_io(cinfo, ptr, FALSE); - } - /* Ensure the accessed part of the array is defined; prezero if needed. - * To improve locality of access, we only prezero the part of the array - * that the caller is about to access, not the entire in-memory array. - */ - if (ptr->first_undef_row < end_row) { - if (ptr->first_undef_row < start_row) { - if (writable) /* writer skipped over a section of array */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - undef_row = start_row; /* but reader is allowed to read ahead */ - } else { - undef_row = ptr->first_undef_row; - } - if (writable) - ptr->first_undef_row = end_row; - if (ptr->pre_zero) { - size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE); - undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ - end_row -= ptr->cur_start_row; - while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); - undef_row++; - } - } else { - if (! writable) /* reader looking at undefined data */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - } - } - /* Flag the buffer dirty if caller will write in it */ - if (writable) - ptr->dirty = TRUE; - /* Return address of proper part of the buffer */ - return ptr->mem_buffer + (start_row - ptr->cur_start_row); -} - - -METHODDEF(JBLOCKARRAY) -access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr, - JDIMENSION start_row, JDIMENSION num_rows, - boolean writable) -/* Access the part of a virtual block array starting at start_row */ -/* and extending for num_rows rows. writable is true if */ -/* caller intends to modify the accessed area. */ -{ - JDIMENSION end_row = start_row + num_rows; - JDIMENSION undef_row; - - /* debugging check */ - if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || - ptr->mem_buffer == NULL) - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - - /* Make the desired part of the virtual array accessible */ - if (start_row < ptr->cur_start_row || - end_row > ptr->cur_start_row+ptr->rows_in_mem) { - if (! ptr->b_s_open) - ERREXIT(cinfo, JERR_VIRTUAL_BUG); - /* Flush old buffer contents if necessary */ - if (ptr->dirty) { - do_barray_io(cinfo, ptr, TRUE); - ptr->dirty = FALSE; - } - /* Decide what part of virtual array to access. - * Algorithm: if target address > current window, assume forward scan, - * load starting at target address. If target address < current window, - * assume backward scan, load so that target area is top of window. - * Note that when switching from forward write to forward read, will have - * start_row = 0, so the limiting case applies and we load from 0 anyway. - */ - if (start_row > ptr->cur_start_row) { - ptr->cur_start_row = start_row; - } else { - /* use long arithmetic here to avoid overflow & unsigned problems */ - long ltemp; - - ltemp = (long) end_row - (long) ptr->rows_in_mem; - if (ltemp < 0) - ltemp = 0; /* don't fall off front end of file */ - ptr->cur_start_row = (JDIMENSION) ltemp; - } - /* Read in the selected part of the array. - * During the initial write pass, we will do no actual read - * because the selected part is all undefined. - */ - do_barray_io(cinfo, ptr, FALSE); - } - /* Ensure the accessed part of the array is defined; prezero if needed. - * To improve locality of access, we only prezero the part of the array - * that the caller is about to access, not the entire in-memory array. - */ - if (ptr->first_undef_row < end_row) { - if (ptr->first_undef_row < start_row) { - if (writable) /* writer skipped over a section of array */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - undef_row = start_row; /* but reader is allowed to read ahead */ - } else { - undef_row = ptr->first_undef_row; - } - if (writable) - ptr->first_undef_row = end_row; - if (ptr->pre_zero) { - size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK); - undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ - end_row -= ptr->cur_start_row; - while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); - undef_row++; - } - } else { - if (! writable) /* reader looking at undefined data */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - } - } - /* Flag the buffer dirty if caller will write in it */ - if (writable) - ptr->dirty = TRUE; - /* Return address of proper part of the buffer */ - return ptr->mem_buffer + (start_row - ptr->cur_start_row); -} - - -/* - * Release all objects belonging to a specified pool. - */ - -METHODDEF(void) -free_pool (j_common_ptr cinfo, int pool_id) -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr shdr_ptr; - large_pool_ptr lhdr_ptr; - size_t space_freed; - - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - -#ifdef MEM_STATS - if (cinfo->err->trace_level > 1) - print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */ -#endif - - /* If freeing IMAGE pool, close any virtual arrays first */ - if (pool_id == JPOOL_IMAGE) { - jvirt_sarray_ptr sptr; - jvirt_barray_ptr bptr; - - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->b_s_open) { /* there may be no backing store */ - sptr->b_s_open = FALSE; /* prevent recursive close if error */ - (*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info); - } - } - mem->virt_sarray_list = NULL; - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->b_s_open) { /* there may be no backing store */ - bptr->b_s_open = FALSE; /* prevent recursive close if error */ - (*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info); - } - } - mem->virt_barray_list = NULL; - } - - /* Release large objects */ - lhdr_ptr = mem->large_list[pool_id]; - mem->large_list[pool_id] = NULL; - - while (lhdr_ptr != NULL) { - large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next; - space_freed = lhdr_ptr->hdr.bytes_used + - lhdr_ptr->hdr.bytes_left + - SIZEOF(large_pool_hdr); - jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; - lhdr_ptr = next_lhdr_ptr; - } - - /* Release small objects */ - shdr_ptr = mem->small_list[pool_id]; - mem->small_list[pool_id] = NULL; - - while (shdr_ptr != NULL) { - small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next; - space_freed = shdr_ptr->hdr.bytes_used + - shdr_ptr->hdr.bytes_left + - SIZEOF(small_pool_hdr); - jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; - shdr_ptr = next_shdr_ptr; - } -} - - -/* - * Close up shop entirely. - * Note that this cannot be called unless cinfo->mem is non-NULL. - */ - -METHODDEF(void) -self_destruct (j_common_ptr cinfo) -{ - int pool; - - /* Close all backing store, release all memory. - * Releasing pools in reverse order might help avoid fragmentation - * with some (brain-damaged) malloc libraries. - */ - for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { - free_pool(cinfo, pool); - } - - /* Release the memory manager control block too. */ - jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr)); - cinfo->mem = NULL; /* ensures I will be called only once */ - - jpeg_mem_term(cinfo); /* system-dependent cleanup */ -} - - -/* - * Memory manager initialization. - * When this is called, only the error manager pointer is valid in cinfo! - */ - -GLOBAL(void) -jinit_memory_mgr (j_common_ptr cinfo) -{ - my_mem_ptr mem; - long max_to_use; - int pool; - size_t test_mac; - - cinfo->mem = NULL; /* for safety if init fails */ - - /* Check for configuration errors. - * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably - * doesn't reflect any real hardware alignment requirement. - * The test is a little tricky: for X>0, X and X-1 have no one-bits - * in common if and only if X is a power of 2, ie has only one one-bit. - * Some compilers may give an "unreachable code" warning here; ignore it. - */ - if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0) - ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE); - /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be - * a multiple of SIZEOF(ALIGN_TYPE). - * Again, an "unreachable code" warning may be ignored here. - * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. - */ - test_mac = (size_t) MAX_ALLOC_CHUNK; - if ((long) test_mac != MAX_ALLOC_CHUNK || - (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - - max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ - - /* Attempt to allocate memory manager's control block */ - mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); - - if (mem == NULL) { - jpeg_mem_term(cinfo); /* system-dependent cleanup */ - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0); - } - - /* OK, fill in the method pointers */ - mem->pub.alloc_small = alloc_small; - mem->pub.alloc_large = alloc_large; - mem->pub.alloc_sarray = alloc_sarray; - mem->pub.alloc_barray = alloc_barray; - mem->pub.request_virt_sarray = request_virt_sarray; - mem->pub.request_virt_barray = request_virt_barray; - mem->pub.realize_virt_arrays = realize_virt_arrays; - mem->pub.access_virt_sarray = access_virt_sarray; - mem->pub.access_virt_barray = access_virt_barray; - mem->pub.free_pool = free_pool; - mem->pub.self_destruct = self_destruct; - - /* Make MAX_ALLOC_CHUNK accessible to other modules */ - mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK; - - /* Initialize working state */ - mem->pub.max_memory_to_use = max_to_use; - - for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { - mem->small_list[pool] = NULL; - mem->large_list[pool] = NULL; - } - mem->virt_sarray_list = NULL; - mem->virt_barray_list = NULL; - - mem->total_space_allocated = SIZEOF(my_memory_mgr); - - /* Declare ourselves open for business */ - cinfo->mem = & mem->pub; - - /* Check for an environment variable JPEGMEM; if found, override the - * default max_memory setting from jpeg_mem_init. Note that the - * surrounding application may again override this value. - * If your system doesn't support getenv(), define NO_GETENV to disable - * this feature. - */ -#ifndef NO_GETENV - { char * memenv; - - if ((memenv = getenv("JPEGMEM")) != NULL) { - char ch = 'x'; - - if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) { - if (ch == 'm' || ch == 'M') - max_to_use *= 1000L; - mem->pub.max_memory_to_use = max_to_use * 1000L; - } - } - } -#endif - -} diff --git a/freeimage241/Source/LibJPEG/jmemname.c b/freeimage241/Source/LibJPEG/jmemname.c deleted file mode 100644 index ed96dee..0000000 --- a/freeimage241/Source/LibJPEG/jmemname.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * jmemname.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a generic implementation of the system-dependent - * portion of the JPEG memory manager. This implementation assumes that - * you must explicitly construct a name for each temp file. - * Also, the problem of determining the amount of memory available - * is shoved onto the user. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - -#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ -#define SEEK_SET 0 /* if not, assume 0 is correct */ -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define RW_BINARY "w+" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define RW_BINARY "w+b", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define RW_BINARY "w+b" -#endif -#endif - - -/* - * Selection of a file name for a temporary file. - * This is system-dependent! - * - * The code as given is suitable for most Unix systems, and it is easily - * modified for most non-Unix systems. Some notes: - * 1. The temp file is created in the directory named by TEMP_DIRECTORY. - * The default value is /usr/tmp, which is the conventional place for - * creating large temp files on Unix. On other systems you'll probably - * want to change the file location. You can do this by editing the - * #define, or (preferred) by defining TEMP_DIRECTORY in jconfig.h. - * - * 2. If you need to change the file name as well as its location, - * you can override the TEMP_FILE_NAME macro. (Note that this is - * actually a printf format string; it must contain %s and %d.) - * Few people should need to do this. - * - * 3. mktemp() is used to ensure that multiple processes running - * simultaneously won't select the same file names. If your system - * doesn't have mktemp(), define NO_MKTEMP to do it the hard way. - * (If you don't have , also define NO_ERRNO_H.) - * - * 4. You probably want to define NEED_SIGNAL_CATCHER so that cjpeg.c/djpeg.c - * will cause the temp files to be removed if you stop the program early. - */ - -#ifndef TEMP_DIRECTORY /* can override from jconfig.h or Makefile */ -#define TEMP_DIRECTORY "/usr/tmp/" /* recommended setting for Unix */ -#endif - -static int next_file_num; /* to distinguish among several temp files */ - -#ifdef NO_MKTEMP - -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "%sJPG%03d.TMP" -#endif - -#ifndef NO_ERRNO_H -#include /* to define ENOENT */ -#endif - -/* ANSI C specifies that errno is a macro, but on older systems it's more - * likely to be a plain int variable. And not all versions of errno.h - * bother to declare it, so we have to in order to be most portable. Thus: - */ -#ifndef errno -extern int errno; -#endif - - -LOCAL(void) -select_file_name (char * fname) -{ - FILE * tfile; - - /* Keep generating file names till we find one that's not in use */ - for (;;) { - next_file_num++; /* advance counter */ - sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); - if ((tfile = fopen(fname, READ_BINARY)) == NULL) { - /* fopen could have failed for a reason other than the file not - * being there; for example, file there but unreadable. - * If isn't available, then we cannot test the cause. - */ -#ifdef ENOENT - if (errno != ENOENT) - continue; -#endif - break; - } - fclose(tfile); /* oops, it's there; close tfile & try again */ - } -} - -#else /* ! NO_MKTEMP */ - -/* Note that mktemp() requires the initial filename to end in six X's */ -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "%sJPG%dXXXXXX" -#endif - -LOCAL(void) -select_file_name (char * fname) -{ - next_file_num++; /* advance counter */ - sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); - mktemp(fname); /* make sure file name is unique */ - /* mktemp replaces the trailing XXXXXX with a unique string of characters */ -} - -#endif /* NO_MKTEMP */ - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFREAD(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFWRITE(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - fclose(info->temp_file); /* close the file */ - unlink(info->temp_name); /* delete the file */ -/* If your system doesn't have unlink(), use remove() instead. - * remove() is the ANSI-standard name for this function, but if - * your system was ANSI you'd be using jmemansi.c, right? - */ - TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); -} - - -/* - * Initial opening of a backing-store object. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - select_file_name(info->temp_name); - if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; /* initialize temp file name generator */ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/freeimage241/Source/LibJPEG/jmemnobs.c b/freeimage241/Source/LibJPEG/jmemnobs.c deleted file mode 100644 index eb8c337..0000000 --- a/freeimage241/Source/LibJPEG/jmemnobs.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * jmemnobs.c - * - * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a really simple implementation of the system- - * dependent portion of the JPEG memory manager. This implementation - * assumes that no backing-store files are needed: all required space - * can be obtained from malloc(). - * This is very portable in the sense that it'll compile on almost anything, - * but you'd better have lots of main memory (or virtual memory) if you want - * to process big images. - * Note that the max_memory_to_use option is ignored by this implementation. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * Here we always say, "we got all you want bud!" - */ - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return max_bytes_needed; -} - - -/* - * Backing store (temporary file) management. - * Since jpeg_mem_available always promised the moon, - * this should never be called and we can just error out. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - ERREXIT(cinfo, JERR_NO_BACKING_STORE); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. Here, there isn't any. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - return 0; /* just set max_memory_to_use to 0 */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/freeimage241/Source/LibJPEG/jmemsys.h b/freeimage241/Source/LibJPEG/jmemsys.h deleted file mode 100644 index 6c3c6d3..0000000 --- a/freeimage241/Source/LibJPEG/jmemsys.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * jmemsys.h - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file defines the interface between the system-independent - * and system-dependent portions of the JPEG memory manager. No other - * modules need include it. (The system-independent portion is jmemmgr.c; - * there are several different versions of the system-dependent portion.) - * - * This file works as-is for the system-dependent memory managers supplied - * in the IJG distribution. You may need to modify it if you write a - * custom memory manager. If system-dependent changes are needed in - * this file, the best method is to #ifdef them based on a configuration - * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR - * and USE_MAC_MEMMGR. - */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_get_small jGetSmall -#define jpeg_free_small jFreeSmall -#define jpeg_get_large jGetLarge -#define jpeg_free_large jFreeLarge -#define jpeg_mem_available jMemAvail -#define jpeg_open_backing_store jOpenBackStore -#define jpeg_mem_init jMemInit -#define jpeg_mem_term jMemTerm -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* - * These two functions are used to allocate and release small chunks of - * memory. (Typically the total amount requested through jpeg_get_small is - * no more than 20K or so; this will be requested in chunks of a few K each.) - * Behavior should be the same as for the standard library functions malloc - * and free; in particular, jpeg_get_small must return NULL on failure. - * On most systems, these ARE malloc and free. jpeg_free_small is passed the - * size of the object being freed, just in case it's needed. - * On an 80x86 machine using small-data memory model, these manage near heap. - */ - -EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject)); -EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, - size_t sizeofobject)); - -/* - * These two functions are used to allocate and release large chunks of - * memory (up to the total free space designated by jpeg_mem_available). - * The interface is the same as above, except that on an 80x86 machine, - * far pointers are used. On most other machines these are identical to - * the jpeg_get/free_small routines; but we keep them separate anyway, - * in case a different allocation strategy is desirable for large chunks. - */ - -EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo, - size_t sizeofobject)); -EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, - size_t sizeofobject)); - -/* - * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may - * be requested in a single call to jpeg_get_large (and jpeg_get_small for that - * matter, but that case should never come into play). This macro is needed - * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. - * On those machines, we expect that jconfig.h will provide a proper value. - * On machines with 32-bit flat address spaces, any large constant may be used. - * - * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type - * size_t and will be a multiple of sizeof(align_type). - */ - -#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */ -#define MAX_ALLOC_CHUNK 1000000000L -#endif - -/* - * This routine computes the total space still available for allocation by - * jpeg_get_large. If more space than this is needed, backing store will be - * used. NOTE: any memory already allocated must not be counted. - * - * There is a minimum space requirement, corresponding to the minimum - * feasible buffer sizes; jmemmgr.c will request that much space even if - * jpeg_mem_available returns zero. The maximum space needed, enough to hold - * all working storage in memory, is also passed in case it is useful. - * Finally, the total space already allocated is passed. If no better - * method is available, cinfo->mem->max_memory_to_use - already_allocated - * is often a suitable calculation. - * - * It is OK for jpeg_mem_available to underestimate the space available - * (that'll just lead to more backing-store access than is really necessary). - * However, an overestimate will lead to failure. Hence it's wise to subtract - * a slop factor from the true available space. 5% should be enough. - * - * On machines with lots of virtual memory, any large constant may be returned. - * Conversely, zero may be returned to always use the minimum amount of memory. - */ - -EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, - long min_bytes_needed, - long max_bytes_needed, - long already_allocated)); - - -/* - * This structure holds whatever state is needed to access a single - * backing-store object. The read/write/close method pointers are called - * by jmemmgr.c to manipulate the backing-store object; all other fields - * are private to the system-dependent backing store routines. - */ - -#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */ - - -#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */ - -typedef unsigned short XMSH; /* type of extended-memory handles */ -typedef unsigned short EMSH; /* type of expanded-memory handles */ - -typedef union { - short file_handle; /* DOS file handle if it's a temp file */ - XMSH xms_handle; /* handle if it's a chunk of XMS */ - EMSH ems_handle; /* handle if it's a chunk of EMS */ -} handle_union; - -#endif /* USE_MSDOS_MEMMGR */ - -#ifdef USE_MAC_MEMMGR /* Mac-specific junk */ -#include -#endif /* USE_MAC_MEMMGR */ - - -typedef struct backing_store_struct * backing_store_ptr; - -typedef struct backing_store_struct { - /* Methods for reading/writing/closing this backing-store object */ - JMETHOD(void, read_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JMETHOD(void, write_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JMETHOD(void, close_backing_store, (j_common_ptr cinfo, - backing_store_ptr info)); - - /* Private fields for system-dependent backing-store management */ -#ifdef USE_MSDOS_MEMMGR - /* For the MS-DOS manager (jmemdos.c), we need: */ - handle_union handle; /* reference to backing-store storage object */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else -#ifdef USE_MAC_MEMMGR - /* For the Mac manager (jmemmac.c), we need: */ - short temp_file; /* file reference number to temp file */ - FSSpec tempSpec; /* the FSSpec for the temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else - /* For a typical implementation with temp files, we need: */ - FILE * temp_file; /* stdio reference to temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ -#endif -#endif -} backing_store_info; - - -/* - * Initial opening of a backing-store object. This must fill in the - * read/write/close pointers in the object. The read/write routines - * may take an error exit if the specified maximum file size is exceeded. - * (If jpeg_mem_available always returns a large value, this routine can - * just take an error exit.) - */ - -EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, - backing_store_ptr info, - long total_bytes_needed)); - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. jpeg_mem_init will be called before anything is - * allocated (and, therefore, nothing in cinfo is of use except the error - * manager pointer). It should return a suitable default value for - * max_memory_to_use; this may subsequently be overridden by the surrounding - * application. (Note that max_memory_to_use is only important if - * jpeg_mem_available chooses to consult it ... no one else will.) - * jpeg_mem_term may assume that all requested memory has been freed and that - * all opened backing-store objects have been closed. - */ - -EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); diff --git a/freeimage241/Source/LibJPEG/jmorecfg.h b/freeimage241/Source/LibJPEG/jmorecfg.h deleted file mode 100644 index 771decf..0000000 --- a/freeimage241/Source/LibJPEG/jmorecfg.h +++ /dev/null @@ -1,363 +0,0 @@ -/* - * jmorecfg.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains additional configuration options that customize the - * JPEG software for special applications or support machine-dependent - * optimizations. Most users will not need to touch this file. - */ - - -/* - * Define BITS_IN_JSAMPLE as either - * 8 for 8-bit sample values (the usual setting) - * 12 for 12-bit sample values - * Only 8 and 12 are legal data precisions for lossy JPEG according to the - * JPEG standard, and the IJG code does not support anything else! - * We do not support run-time selection of data precision, sorry. - */ - -#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ - - -/* - * Maximum number of components (color channels) allowed in JPEG image. - * To meet the letter of the JPEG spec, set this to 255. However, darn - * few applications need more than 4 channels (maybe 5 for CMYK + alpha - * mask). We recommend 10 as a reasonable compromise; use 4 if you are - * really short on memory. (Each allowed component costs a hundred or so - * bytes of storage, whether actually used in an image or not.) - */ - -#define MAX_COMPONENTS 10 /* maximum number of image components */ - - -/* - * Basic data types. - * You may need to change these if you have a machine with unusual data - * type sizes; for example, "char" not 8 bits, "short" not 16 bits, - * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, - * but it had better be at least 16. - */ - -/* Representation of a single sample (pixel element value). - * We frequently allocate large arrays of these, so it's important to keep - * them small. But if you have memory to burn and access to char or short - * arrays is very slow on your hardware, you might want to change these. - */ - -#if BITS_IN_JSAMPLE == 8 -/* JSAMPLE should be the smallest type that will hold the values 0..255. - * You can use a signed char by having GETJSAMPLE mask it with 0xFF. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JSAMPLE; -#ifdef CHAR_IS_UNSIGNED -#define GETJSAMPLE(value) ((int) (value)) -#else -#define GETJSAMPLE(value) ((int) (value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - -#define MAXJSAMPLE 255 -#define CENTERJSAMPLE 128 - -#endif /* BITS_IN_JSAMPLE == 8 */ - - -#if BITS_IN_JSAMPLE == 12 -/* JSAMPLE should be the smallest type that will hold the values 0..4095. - * On nearly all machines "short" will do nicely. - */ - -typedef short JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#define MAXJSAMPLE 4095 -#define CENTERJSAMPLE 2048 - -#endif /* BITS_IN_JSAMPLE == 12 */ - - -/* Representation of a DCT frequency coefficient. - * This should be a signed value of at least 16 bits; "short" is usually OK. - * Again, we allocate large arrays of these, but you can change to int - * if you have memory to burn and "short" is really slow. - */ - -typedef short JCOEF; - - -/* Compressed datastreams are represented as arrays of JOCTET. - * These must be EXACTLY 8 bits wide, at least once they are written to - * external storage. Note that when using the stdio data source/destination - * managers, this is also the data type passed to fread/fwrite. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JOCTET; -#define GETJOCTET(value) (value) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JOCTET; -#ifdef CHAR_IS_UNSIGNED -#define GETJOCTET(value) (value) -#else -#define GETJOCTET(value) ((value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - - -/* These typedefs are used for various table entries and so forth. - * They must be at least as wide as specified; but making them too big - * won't cost a huge amount of memory, so we don't provide special - * extraction code like we did for JSAMPLE. (In other words, these - * typedefs live at a different point on the speed/space tradeoff curve.) - */ - -/* UINT8 must hold at least the values 0..255. */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char UINT8; -#else /* not HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char UINT8; -#else /* not CHAR_IS_UNSIGNED */ -typedef short UINT8; -#endif /* CHAR_IS_UNSIGNED */ -#endif /* HAVE_UNSIGNED_CHAR */ - -/* UINT16 must hold at least the values 0..65535. */ - -#ifdef HAVE_UNSIGNED_SHORT -typedef unsigned short UINT16; -#else /* not HAVE_UNSIGNED_SHORT */ -typedef unsigned int UINT16; -#endif /* HAVE_UNSIGNED_SHORT */ - -/* INT16 must hold at least the values -32768..32767. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ -typedef short INT16; -#endif - -/* INT32 must hold at least signed 32-bit values. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ -typedef long INT32; -#endif - -/* Datatype used for image dimensions. The JPEG standard only supports - * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore - * "unsigned int" is sufficient on all machines. However, if you need to - * handle larger images and you don't mind deviating from the spec, you - * can change this datatype. - */ - -typedef unsigned int JDIMENSION; - -#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ - - -/* These macros are used in all function definitions and extern declarations. - * You could modify them if you need to change function linkage conventions; - * in particular, you'll need to do that to make the library a Windows DLL. - * Another application is to make all functions global for use with debuggers - * or code profilers that require it. - */ - -/* a function called through method pointers: */ -#define METHODDEF(type) static type -/* a function used only in its module: */ -#define LOCAL(type) static type -/* a function referenced thru EXTERNs: */ -#define GLOBAL(type) type -/* a reference to a GLOBAL function: */ -#define EXTERN(type) extern type - - -/* This macro is used to declare a "method", that is, a function pointer. - * We want to supply prototype parameters if the compiler can cope. - * Note that the arglist parameter must be parenthesized! - * Again, you can customize this if you need special linkage keywords. - */ - -#ifdef HAVE_PROTOTYPES -#define JMETHOD(type,methodname,arglist) type (*methodname) arglist -#else -#define JMETHOD(type,methodname,arglist) type (*methodname) () -#endif - - -/* Here is the pseudo-keyword for declaring pointers that must be "far" - * on 80x86 machines. Most of the specialized coding for 80x86 is handled - * by just saying "FAR *" where such a pointer is needed. In a few places - * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. - */ - -#ifdef NEED_FAR_POINTERS -#define FAR far -#else -#define FAR -#endif - - -/* - * On a few systems, type boolean and/or its values FALSE, TRUE may appear - * in standard header files. Or you may have conflicts with application- - * specific header files that you want to include together with these files. - * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. - */ - -#ifndef HAVE_BOOLEAN -typedef int boolean; -#endif -#ifndef FALSE /* in case these macros already exist */ -#define FALSE 0 /* values of boolean */ -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - -/* - * The remaining options affect code selection within the JPEG library, - * but they don't need to be visible to most applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. - */ - -#ifdef JPEG_INTERNALS -#define JPEG_INTERNAL_OPTIONS -#endif - -#ifdef JPEG_INTERNAL_OPTIONS - - -/* - * These defines indicate whether to include various optional functions. - * Undefining some of these symbols will produce a smaller but less capable - * library. Note that you can leave certain source files out of the - * compilation/linking process if you've #undef'd the corresponding symbols. - * (You may HAVE to do that if your compiler doesn't like null source files.) - */ - -/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ - -/* Capability options common to encoder and decoder: */ - -#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ -#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ -#undef DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ - -/* Encoder capability options: */ - -#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ -/* Note: if you selected 12-bit data precision, it is dangerous to turn off - * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit - * precision, so jchuff.c normally uses entropy optimization to compute - * usable tables for higher precision. If you don't want to do optimization, - * you'll have to supply different default Huffman tables. - * The exact same statements apply for progressive JPEG: the default tables - * don't work for progressive mode. (This may get fixed, however.) - */ -#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ - -/* Decoder capability options: */ - -#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ -#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ -#undef IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ -#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ -#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ -#undef QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ -#undef QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ - -/* more capability options later, no doubt */ - - -/* - * Ordering of RGB data in scanlines passed to or from the application. - * If your application wants to deal with data in the order B,G,R, just - * change these macros. You can also deal with formats such as R,G,B,X - * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing - * the offsets will also change the order in which colormap data is organized. - * RESTRICTIONS: - * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. - * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not - * useful if you are using JPEG color spaces other than YCbCr or grayscale. - * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE - * is not 3 (they don't understand about dummy color components!). So you - * can't use color quantization if you change that value. - */ - -#define RGB_RED 2 /* Offset of Red in an RGB scanline element */ -#define RGB_GREEN 1 /* Offset of Green */ -#define RGB_BLUE 0 /* Offset of Blue */ -#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ - - -/* Definitions for speed-related optimizations. */ - - -/* If your compiler supports inline functions, define INLINE - * as the inline keyword; otherwise define it as empty. - */ - -#ifndef INLINE -#ifdef __GNUC__ /* for instance, GNU C knows about inline */ -#define INLINE __inline__ -#endif -#ifndef INLINE -#define INLINE /* default is to define it as empty */ -#endif -#endif - - -/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying - * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER - * as short on such a machine. MULTIPLIER must be at least 16 bits wide. - */ - -#ifndef MULTIPLIER -#define MULTIPLIER int /* type for fastest integer multiply */ -#endif - - -/* FAST_FLOAT should be either float or double, whichever is done faster - * by your compiler. (Note that this type is only used in the floating point - * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) - * Typically, float is faster in ANSI C compilers, while double is faster in - * pre-ANSI compilers (because they insist on converting to double anyway). - * The code below therefore chooses float if we have ANSI-style prototypes. - */ - -#ifndef FAST_FLOAT -#ifdef HAVE_PROTOTYPES -#define FAST_FLOAT float -#else -#define FAST_FLOAT double -#endif -#endif - -#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/freeimage241/Source/LibJPEG/jpegint.h b/freeimage241/Source/LibJPEG/jpegint.h deleted file mode 100644 index 95b00d4..0000000 --- a/freeimage241/Source/LibJPEG/jpegint.h +++ /dev/null @@ -1,392 +0,0 @@ -/* - * jpegint.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides common declarations for the various JPEG modules. - * These declarations are considered internal to the JPEG library; most - * applications using the library shouldn't need to include this file. - */ - - -/* Declarations for both compression & decompression */ - -typedef enum { /* Operating modes for buffer controllers */ - JBUF_PASS_THRU, /* Plain stripwise operation */ - /* Remaining modes require a full-image buffer to have been created */ - JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ - JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ - JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ -} J_BUF_MODE; - -/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ -#define CSTATE_START 100 /* after create_compress */ -#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ -#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ -#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ -#define DSTATE_START 200 /* after create_decompress */ -#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ -#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ -#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ -#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ -#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ -#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ -#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ -#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ -#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ -#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ - - -/* Declarations for compression modules */ - -/* Master control module */ -struct jpeg_comp_master { - JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); - JMETHOD(void, pass_startup, (j_compress_ptr cinfo)); - JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean call_pass_startup; /* True if pass_startup must be called */ - boolean is_last_pass; /* True during last pass */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_c_main_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail)); -}; - -/* Compression preprocessing (downsampling input buffer control) */ -struct jpeg_c_prep_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, pre_process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, - JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_c_coef_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(boolean, compress_data, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf)); -}; - -/* Colorspace conversion */ -struct jpeg_color_converter { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - JMETHOD(void, color_convert, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows)); -}; - -/* Downsampling */ -struct jpeg_downsampler { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - JMETHOD(void, downsample, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, - JDIMENSION out_row_group_index)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Forward DCT (also controls coefficient quantization) */ -struct jpeg_forward_dct { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - /* perhaps this should be an array??? */ - JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, - jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks)); -}; - -/* Entropy encoding */ -struct jpeg_entropy_encoder { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); - JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); - JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); -}; - -/* Marker writing */ -struct jpeg_marker_writer { - JMETHOD(void, write_file_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_frame_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_scan_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo)); - JMETHOD(void, write_tables_only, (j_compress_ptr cinfo)); - /* These routines are exported to allow insertion of extra markers */ - /* Probably only COM and APPn markers should be written this way */ - JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker, - unsigned int datalen)); - JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val)); -}; - - -/* Declarations for decompression modules */ - -/* Master control module */ -struct jpeg_decomp_master { - JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ -}; - -/* Input control module */ -struct jpeg_input_controller { - JMETHOD(int, consume_input, (j_decompress_ptr cinfo)); - JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); - JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean has_multiple_scans; /* True if file has multiple scans */ - boolean eoi_reached; /* True when EOI has been consumed */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_d_main_controller { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, process_data, (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_d_coef_controller { - JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JMETHOD(int, consume_data, (j_decompress_ptr cinfo)); - JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo)); - JMETHOD(int, decompress_data, (j_decompress_ptr cinfo, - JSAMPIMAGE output_buf)); - /* Pointer to array of coefficient virtual arrays, or NULL if none */ - jvirt_barray_ptr *coef_arrays; -}; - -/* Decompression postprocessing (color quantization buffer control) */ -struct jpeg_d_post_controller { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, post_process_data, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Marker reading & parsing */ -struct jpeg_marker_reader { - JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); - /* Read markers until SOS or EOI. - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - JMETHOD(int, read_markers, (j_decompress_ptr cinfo)); - /* Read a restart marker --- exported for use by entropy decoder only */ - jpeg_marker_parser_method read_restart_marker; - - /* State of marker reader --- nominally internal, but applications - * supplying COM or APPn handlers might like to know the state. - */ - boolean saw_SOI; /* found SOI? */ - boolean saw_SOF; /* found SOF? */ - int next_restart_num; /* next restart number expected (0-7) */ - unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ -}; - -/* Entropy decoding */ -struct jpeg_entropy_decoder { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); - - /* This is here to share code between baseline and progressive decoders; */ - /* other modules probably should not use it */ - boolean insufficient_data; /* set TRUE after emitting warning */ -}; - -/* Inverse DCT (also performs dequantization) */ -typedef JMETHOD(void, inverse_DCT_method_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col)); - -struct jpeg_inverse_dct { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - /* It is useful to allow each component to have a separate IDCT method. */ - inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; -}; - -/* Upsampling (note that upsampler must also call color converter) */ -struct jpeg_upsampler { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, upsample, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Colorspace conversion */ -struct jpeg_color_deconverter { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, color_convert, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows)); -}; - -/* Color quantization or color precision reduction */ -struct jpeg_color_quantizer { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); - JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, - int num_rows)); - JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); -}; - - -/* Miscellaneous useful macros */ - -#undef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#undef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - - -/* We assume that right shift corresponds to signed division by 2 with - * rounding towards minus infinity. This is correct for typical "arithmetic - * shift" instructions that shift in copies of the sign bit. But some - * C compilers implement >> with an unsigned shift. For these machines you - * must define RIGHT_SHIFT_IS_UNSIGNED. - * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. - * It is only applied with constant shift counts. SHIFT_TEMPS must be - * included in the variables of any routine using RIGHT_SHIFT. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define SHIFT_TEMPS INT32 shift_temp; -#define RIGHT_SHIFT(x,shft) \ - ((shift_temp = (x)) < 0 ? \ - (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ - (shift_temp >> (shft))) -#else -#define SHIFT_TEMPS -#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jinit_compress_master jICompress -#define jinit_c_master_control jICMaster -#define jinit_c_main_controller jICMainC -#define jinit_c_prep_controller jICPrepC -#define jinit_c_coef_controller jICCoefC -#define jinit_color_converter jICColor -#define jinit_downsampler jIDownsampler -#define jinit_forward_dct jIFDCT -#define jinit_huff_encoder jIHEncoder -#define jinit_phuff_encoder jIPHEncoder -#define jinit_marker_writer jIMWriter -#define jinit_master_decompress jIDMaster -#define jinit_d_main_controller jIDMainC -#define jinit_d_coef_controller jIDCoefC -#define jinit_d_post_controller jIDPostC -#define jinit_input_controller jIInCtlr -#define jinit_marker_reader jIMReader -#define jinit_huff_decoder jIHDecoder -#define jinit_phuff_decoder jIPHDecoder -#define jinit_inverse_dct jIIDCT -#define jinit_upsampler jIUpsampler -#define jinit_color_deconverter jIDColor -#define jinit_1pass_quantizer jI1Quant -#define jinit_2pass_quantizer jI2Quant -#define jinit_merged_upsampler jIMUpsampler -#define jinit_memory_mgr jIMemMgr -#define jdiv_round_up jDivRound -#define jround_up jRound -#define jcopy_sample_rows jCopySamples -#define jcopy_block_row jCopyBlocks -#define jzero_far jZeroFar -#define jpeg_zigzag_order jZIGTable -#define jpeg_natural_order jZAGTable -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Compression module initialization routines */ -EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, - boolean transcode_only)); -EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); -/* Decompression module initialization routines */ -EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); -/* Memory manager initialization */ -EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); - -/* Utility routines in jutils.c */ -EXTERN(long) jdiv_round_up JPP((long a, long b)); -EXTERN(long) jround_up JPP((long a, long b)); -EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols)); -EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks)); -EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); -/* Constant tables in jutils.c */ -#if 0 /* This table is not actually needed in v6a */ -extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ -#endif -extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ - -/* Suppress undefined-structure complaints if necessary. */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -#endif -#endif /* INCOMPLETE_TYPES_BROKEN */ diff --git a/freeimage241/Source/LibJPEG/jpeglib.h b/freeimage241/Source/LibJPEG/jpeglib.h deleted file mode 100644 index 24f6d9b..0000000 --- a/freeimage241/Source/LibJPEG/jpeglib.h +++ /dev/null @@ -1,1098 +0,0 @@ -/* - * jpeglib.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the application interface for the JPEG library. - * Most applications using the library need only include this file, - * and perhaps jerror.h if they want to know the exact error codes. - */ - -#ifndef JPEGLIB_H -#define JPEGLIB_H - -#include - - /* - * First we include the configuration files that record how this - * installation of the JPEG library is set up. jconfig.h can be - * generated automatically for many systems. jmorecfg.h contains - * manual configuration options that most people need not worry about. - */ - -#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ -#include "jconfig.h" /* widely used configuration options */ -#endif -#include "jmorecfg.h" /* seldom changed options */ - - -/* Version ID for the JPEG library. - * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". - */ - -#define JPEG_LIB_VERSION 62 /* Version 6b */ - - -/* Various constants determining the sizes of things. - * All of these are specified by the JPEG standard, so don't change them - * if you want to be compatible. - */ - -#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ -#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ -#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ -#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ -#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ -#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ -#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ -/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; - * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. - * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU - * to handle it. We even let you do this from the jconfig.h file. However, - * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe - * sometimes emits noncompliant files doesn't mean you should too. - */ -#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ -#ifndef D_MAX_BLOCKS_IN_MCU -#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ -#endif - - -/* Data structures for images (arrays of samples and of DCT coefficients). - * On 80x86 machines, the image arrays are too big for near pointers, - * but the pointer arrays can fit in near memory. - */ - -typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ -typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ -typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ - -typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ -typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ -typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ -typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ - -typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ - - -/* Types for JPEG compression parameters and working tables. */ - - -/* DCT coefficient quantization tables. */ - -typedef struct { - /* This array gives the coefficient quantizers in natural array order - * (not the zigzag order in which they are stored in a JPEG DQT marker). - * CAUTION: IJG versions prior to v6a kept this array in zigzag order. - */ - UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JQUANT_TBL; - - -/* Huffman coding tables. */ - -typedef struct { - /* These two fields directly represent the contents of a JPEG DHT marker */ - UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ - /* length k bits; bits[0] is unused */ - UINT8 huffval[256]; /* The symbols, in order of incr code length */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JHUFF_TBL; - - -/* Basic info about one component (color channel). */ - -typedef struct { - /* These values are fixed over the whole image. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOF marker. */ - int component_id; /* identifier for this component (0..255) */ - int component_index; /* its index in SOF or cinfo->comp_info[] */ - int h_samp_factor; /* horizontal sampling factor (1..4) */ - int v_samp_factor; /* vertical sampling factor (1..4) */ - int quant_tbl_no; /* quantization table selector (0..3) */ - /* These values may vary between scans. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOS marker. */ - /* The decompressor output side may not use these variables. */ - int dc_tbl_no; /* DC entropy table selector (0..3) */ - int ac_tbl_no; /* AC entropy table selector (0..3) */ - - /* Remaining fields should be treated as private by applications. */ - - /* These values are computed during compression or decompression startup: */ - /* Component's size in DCT blocks. - * Any dummy blocks added to complete an MCU are not counted; therefore - * these values do not depend on whether a scan is interleaved or not. - */ - JDIMENSION width_in_blocks; - JDIMENSION height_in_blocks; - /* Size of a DCT block in samples. Always DCTSIZE for compression. - * For decompression this is the size of the output from one DCT block, - * reflecting any scaling we choose to apply during the IDCT step. - * Values of 1,2,4,8 are likely to be supported. Note that different - * components may receive different IDCT scalings. - */ - int DCT_scaled_size; - /* The downsampled dimensions are the component's actual, unpadded number - * of samples at the main buffer (preprocessing/compression interface), thus - * downsampled_width = ceil(image_width * Hi/Hmax) - * and similarly for height. For decompression, IDCT scaling is included, so - * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) - */ - JDIMENSION downsampled_width; /* actual width in samples */ - JDIMENSION downsampled_height; /* actual height in samples */ - /* This flag is used only for decompression. In cases where some of the - * components will be ignored (eg grayscale output from YCbCr image), - * we can skip most computations for the unused components. - */ - boolean component_needed; /* do we need the value of this component? */ - - /* These values are computed before starting a scan of the component. */ - /* The decompressor output side may not use these variables. */ - int MCU_width; /* number of blocks per MCU, horizontally */ - int MCU_height; /* number of blocks per MCU, vertically */ - int MCU_blocks; /* MCU_width * MCU_height */ - int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ - int last_col_width; /* # of non-dummy blocks across in last MCU */ - int last_row_height; /* # of non-dummy blocks down in last MCU */ - - /* Saved quantization table for component; NULL if none yet saved. - * See jdinput.c comments about the need for this information. - * This field is currently used only for decompression. - */ - JQUANT_TBL * quant_table; - - /* Private per-component storage for DCT or IDCT subsystem. */ - void * dct_table; -} jpeg_component_info; - - -/* The script for encoding a multiple-scan file is an array of these: */ - -typedef struct { - int comps_in_scan; /* number of components encoded in this scan */ - int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ - int Ss, Se; /* progressive JPEG spectral selection parms */ - int Ah, Al; /* progressive JPEG successive approx. parms */ -} jpeg_scan_info; - -/* The decompressor can save APPn and COM markers in a list of these: */ - -typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; - -struct jpeg_marker_struct { - jpeg_saved_marker_ptr next; /* next in list, or NULL */ - UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ - unsigned int original_length; /* # bytes of data in the file */ - unsigned int data_length; /* # bytes of data saved at data[] */ - JOCTET FAR * data; /* the data contained in the marker */ - /* the marker length word is not counted in data_length or original_length */ -}; - -/* Known color spaces. */ - -typedef enum { - JCS_UNKNOWN, /* error/unspecified */ - JCS_GRAYSCALE, /* monochrome */ - JCS_RGB, /* red/green/blue */ - JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ - JCS_CMYK, /* C/M/Y/K */ - JCS_YCCK /* Y/Cb/Cr/K */ -} J_COLOR_SPACE; - -/* DCT/IDCT algorithm options. */ - -typedef enum { - JDCT_ISLOW, /* slow but accurate integer algorithm */ - JDCT_IFAST, /* faster, less accurate integer method */ - JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ -} J_DCT_METHOD; - -#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ -#define JDCT_DEFAULT JDCT_ISLOW -#endif -#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ -#define JDCT_FASTEST JDCT_IFAST -#endif - -/* Dithering options for decompression. */ - -typedef enum { - JDITHER_NONE, /* no dithering */ - JDITHER_ORDERED, /* simple ordered dither */ - JDITHER_FS /* Floyd-Steinberg error diffusion dither */ -} J_DITHER_MODE; - - -/* Common fields between JPEG compression and decompression master structs. */ - -#define jpeg_common_fields \ - struct jpeg_error_mgr * err; /* Error handler module */\ - struct jpeg_memory_mgr * mem; /* Memory manager module */\ - struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ - void * client_data; /* Available for use by application */\ - boolean is_decompressor; /* So common code can tell which is which */\ - int global_state /* For checking call sequence validity */ - -/* Routines that are to be used by both halves of the library are declared - * to receive a pointer to this structure. There are no actual instances of - * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. - */ -struct jpeg_common_struct { - jpeg_common_fields; /* Fields common to both master struct types */ - /* Additional fields follow in an actual jpeg_compress_struct or - * jpeg_decompress_struct. All three structs must agree on these - * initial fields! (This would be a lot cleaner in C++.) - */ -}; - -typedef struct jpeg_common_struct * j_common_ptr; -typedef struct jpeg_compress_struct * j_compress_ptr; -typedef struct jpeg_decompress_struct * j_decompress_ptr; - - -/* Master record for a compression instance */ - -struct jpeg_compress_struct { - jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ - - /* Destination for compressed data */ - struct jpeg_destination_mgr * dest; - - /* Description of source image --- these fields must be filled in by - * outer application before starting compression. in_color_space must - * be correct before you can even call jpeg_set_defaults(). - */ - - JDIMENSION image_width; /* input image width */ - JDIMENSION image_height; /* input image height */ - int input_components; /* # of color components in input image */ - J_COLOR_SPACE in_color_space; /* colorspace of input image */ - - double input_gamma; /* image gamma of input image */ - - /* Compression parameters --- these fields must be set before calling - * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to - * initialize everything to reasonable defaults, then changing anything - * the application specifically wants to change. That way you won't get - * burnt when new parameters are added. Also note that there are several - * helper routines to simplify changing parameters. - */ - - int data_precision; /* bits of precision in image data */ - - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - int num_scans; /* # of entries in scan_info array */ - const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ - /* The default value of scan_info is NULL, which causes a single-scan - * sequential JPEG file to be emitted. To create a multi-scan file, - * set num_scans and scan_info to point to an array of scan definitions. - */ - - boolean raw_data_in; /* TRUE=caller supplies downsampled data */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - int smoothing_factor; /* 1..100, or 0 for no input smoothing */ - J_DCT_METHOD dct_method; /* DCT algorithm selector */ - - /* The restart interval can be specified in absolute MCUs by setting - * restart_interval, or in MCU rows by setting restart_in_rows - * (in which case the correct restart_interval will be figured - * for each scan). - */ - unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ - int restart_in_rows; /* if > 0, MCU rows per restart interval */ - - /* Parameters controlling emission of special markers. */ - - boolean write_JFIF_header; /* should a JFIF marker be written? */ - UINT8 JFIF_major_version; /* What to write for the JFIF version number */ - UINT8 JFIF_minor_version; - /* These three values are not used by the JPEG code, merely copied */ - /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ - /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ - /* ratio is defined by X_density/Y_density even when density_unit=0. */ - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean write_Adobe_marker; /* should an Adobe marker be written? */ - - /* State variable: index of next scanline to be written to - * jpeg_write_scanlines(). Application may use this to control its - * processing loop, e.g., "while (next_scanline < image_height)". - */ - - JDIMENSION next_scanline; /* 0 .. image_height-1 */ - - /* Remaining fields are known throughout compressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during compression startup - */ - boolean progressive_mode; /* TRUE if scan script uses progressive mode */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ - /* The coefficient controller receives data in units of MCU rows as defined - * for fully interleaved scans (whether the JPEG file is interleaved or not). - * There are v_samp_factor * DCTSIZE sample rows of each component in an - * "iMCU" (interleaved MCU) row. - */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[C_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* - * Links to compression subobjects (methods and private variables of modules) - */ - struct jpeg_comp_master * master; - struct jpeg_c_main_controller * main; - struct jpeg_c_prep_controller * prep; - struct jpeg_c_coef_controller * coef; - struct jpeg_marker_writer * marker; - struct jpeg_color_converter * cconvert; - struct jpeg_downsampler * downsample; - struct jpeg_forward_dct * fdct; - struct jpeg_entropy_encoder * entropy; - jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ - int script_space_size; -}; - - -/* Master record for a decompression instance */ - -struct jpeg_decompress_struct { - jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ - - /* Source of compressed data */ - struct jpeg_source_mgr * src; - - /* Basic description of image --- filled in by jpeg_read_header(). */ - /* Application may inspect these values to decide how to process image. */ - - JDIMENSION image_width; /* nominal image width (from SOF marker) */ - JDIMENSION image_height; /* nominal image height */ - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - /* Decompression processing parameters --- these fields must be set before - * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes - * them to default values. - */ - - J_COLOR_SPACE out_color_space; /* colorspace for output */ - - unsigned int scale_num, scale_denom; /* fraction by which to scale image */ - - double output_gamma; /* image gamma wanted in output */ - - boolean buffered_image; /* TRUE=multiple output passes */ - boolean raw_data_out; /* TRUE=downsampled data wanted */ - - J_DCT_METHOD dct_method; /* IDCT algorithm selector */ - boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ - boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ - - boolean quantize_colors; /* TRUE=colormapped output wanted */ - /* the following are ignored if not quantize_colors: */ - J_DITHER_MODE dither_mode; /* type of color dithering to use */ - boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ - int desired_number_of_colors; /* max # colors to use in created colormap */ - /* these are significant only in buffered-image mode: */ - boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ - boolean enable_external_quant;/* enable future use of external colormap */ - boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ - - /* Description of actual output image that will be returned to application. - * These fields are computed by jpeg_start_decompress(). - * You can also use jpeg_calc_output_dimensions() to determine these values - * in advance of calling jpeg_start_decompress(). - */ - - JDIMENSION output_width; /* scaled image width */ - JDIMENSION output_height; /* scaled image height */ - int out_color_components; /* # of color components in out_color_space */ - int output_components; /* # of color components returned */ - /* output_components is 1 (a colormap index) when quantizing colors; - * otherwise it equals out_color_components. - */ - int rec_outbuf_height; /* min recommended height of scanline buffer */ - /* If the buffer passed to jpeg_read_scanlines() is less than this many rows - * high, space and time will be wasted due to unnecessary data copying. - * Usually rec_outbuf_height will be 1 or 2, at most 4. - */ - - /* When quantizing colors, the output colormap is described by these fields. - * The application can supply a colormap by setting colormap non-NULL before - * calling jpeg_start_decompress; otherwise a colormap is created during - * jpeg_start_decompress or jpeg_start_output. - * The map has out_color_components rows and actual_number_of_colors columns. - */ - int actual_number_of_colors; /* number of entries in use */ - JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ - - /* State variables: these variables indicate the progress of decompression. - * The application may examine these but must not modify them. - */ - - /* Row index of next scanline to be read from jpeg_read_scanlines(). - * Application may use this to control its processing loop, e.g., - * "while (output_scanline < output_height)". - */ - JDIMENSION output_scanline; /* 0 .. output_height-1 */ - - /* Current input scan number and number of iMCU rows completed in scan. - * These indicate the progress of the decompressor input side. - */ - int input_scan_number; /* Number of SOS markers seen so far */ - JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ - - /* The "output scan number" is the notional scan being displayed by the - * output side. The decompressor will not allow output scan/row number - * to get ahead of input scan/row, but it can fall arbitrarily far behind. - */ - int output_scan_number; /* Nominal scan number being displayed */ - JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ - - /* Current progression status. coef_bits[c][i] indicates the precision - * with which component c's DCT coefficient i (in zigzag order) is known. - * It is -1 when no data has yet been received, otherwise it is the point - * transform (shift) value for the most recent scan of the coefficient - * (thus, 0 at completion of the progression). - * This pointer is NULL when reading a non-progressive file. - */ - int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ - - /* Internal JPEG parameters --- the application usually need not look at - * these fields. Note that the decompressor output side may not use - * any parameters that can change between scans. - */ - - /* Quantization and Huffman tables are carried forward across input - * datastreams when processing abbreviated JPEG datastreams. - */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - /* These parameters are never carried across datastreams, since they - * are given in SOF/SOS markers or defined to be reset by SOI. - */ - - int data_precision; /* bits of precision in image data */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ - - /* These fields record data obtained from optional markers recognized by - * the JPEG library. - */ - boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ - /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ - UINT8 JFIF_major_version; /* JFIF version number */ - UINT8 JFIF_minor_version; - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ - UINT8 Adobe_transform; /* Color transform code from Adobe marker */ - - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - - /* Aside from the specific data retained from APPn markers known to the - * library, the uninterpreted contents of any or all APPn and COM markers - * can be saved in a list for examination by the application. - */ - jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ - - /* Remaining fields are known throughout decompressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during decompression startup - */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ - /* The coefficient controller's input and output progress is measured in - * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows - * in fully interleaved JPEG scans, but are used whether the scan is - * interleaved or not. We define an iMCU row as v_samp_factor DCT block - * rows of each component. Therefore, the IDCT output contains - * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. - */ - - JSAMPLE * sample_range_limit; /* table for fast range-limiting */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - * Note that the decompressor output side must not use these fields. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[D_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* This field is shared between entropy decoder and marker parser. - * It is either zero or the code of a JPEG marker that has been - * read from the data source, but has not yet been processed. - */ - int unread_marker; - - /* - * Links to decompression subobjects (methods, private variables of modules) - */ - struct jpeg_decomp_master * master; - struct jpeg_d_main_controller * main; - struct jpeg_d_coef_controller * coef; - struct jpeg_d_post_controller * post; - struct jpeg_input_controller * inputctl; - struct jpeg_marker_reader * marker; - struct jpeg_entropy_decoder * entropy; - struct jpeg_inverse_dct * idct; - struct jpeg_upsampler * upsample; - struct jpeg_color_deconverter * cconvert; - struct jpeg_color_quantizer * cquantize; -}; - - -/* "Object" declarations for JPEG modules that may be supplied or called - * directly by the surrounding application. - * As with all objects in the JPEG library, these structs only define the - * publicly visible methods and state variables of a module. Additional - * private fields may exist after the public ones. - */ - - -/* Error handler object */ - -struct jpeg_error_mgr { - /* Error exit handler: does not return to caller */ - JMETHOD(void, error_exit, (j_common_ptr cinfo)); - /* Conditionally emit a trace or warning message */ - JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); - /* Routine that actually outputs a trace or error message */ - JMETHOD(void, output_message, (j_common_ptr cinfo)); - /* Format a message string for the most recent JPEG error or message */ - JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); -#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ - /* Reset error state variables at start of a new image */ - JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); - - /* The message ID code and any parameters are saved here. - * A message can have one string parameter or up to 8 int parameters. - */ - int msg_code; -#define JMSG_STR_PARM_MAX 80 - union { - int i[8]; - char s[JMSG_STR_PARM_MAX]; - } msg_parm; - - /* Standard state variables for error facility */ - - int trace_level; /* max msg_level that will be displayed */ - - /* For recoverable corrupt-data errors, we emit a warning message, - * but keep going unless emit_message chooses to abort. emit_message - * should count warnings in num_warnings. The surrounding application - * can check for bad data by seeing if num_warnings is nonzero at the - * end of processing. - */ - long num_warnings; /* number of corrupt-data warnings */ - - /* These fields point to the table(s) of error message strings. - * An application can change the table pointer to switch to a different - * message list (typically, to change the language in which errors are - * reported). Some applications may wish to add additional error codes - * that will be handled by the JPEG library error mechanism; the second - * table pointer is used for this purpose. - * - * First table includes all errors generated by JPEG library itself. - * Error code 0 is reserved for a "no such error string" message. - */ - const char * const * jpeg_message_table; /* Library errors */ - int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ - /* Second table can be added by application (see cjpeg/djpeg for example). - * It contains strings numbered first_addon_message..last_addon_message. - */ - const char * const * addon_message_table; /* Non-library errors */ - int first_addon_message; /* code for first string in addon table */ - int last_addon_message; /* code for last string in addon table */ -}; - - -/* Progress monitor object */ - -struct jpeg_progress_mgr { - JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); - - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -}; - - -/* Data destination object for compression */ - -struct jpeg_destination_mgr { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - - JMETHOD(void, init_destination, (j_compress_ptr cinfo)); - JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); - JMETHOD(void, term_destination, (j_compress_ptr cinfo)); -}; - - -/* Data source object for decompression */ - -struct jpeg_source_mgr { - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - - JMETHOD(void, init_source, (j_decompress_ptr cinfo)); - JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); - JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); - JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); - JMETHOD(void, term_source, (j_decompress_ptr cinfo)); -}; - - -/* Memory manager object. - * Allocates "small" objects (a few K total), "large" objects (tens of K), - * and "really big" objects (virtual arrays with backing store if needed). - * The memory manager does not allow individual objects to be freed; rather, - * each created object is assigned to a pool, and whole pools can be freed - * at once. This is faster and more convenient than remembering exactly what - * to free, especially where malloc()/free() are not too speedy. - * NB: alloc routines never return NULL. They exit to error_exit if not - * successful. - */ - -#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ -#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ -#define JPOOL_NUMPOOLS 2 - -typedef struct jvirt_sarray_control * jvirt_sarray_ptr; -typedef struct jvirt_barray_control * jvirt_barray_ptr; - - -struct jpeg_memory_mgr { - /* Method pointers */ - JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, - JDIMENSION numrows)); - JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, - JDIMENSION numrows)); - JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION samplesperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION blocksperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); - JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, - jvirt_sarray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, - jvirt_barray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); - JMETHOD(void, self_destruct, (j_common_ptr cinfo)); - - /* Limit on memory allocation for this JPEG object. (Note that this is - * merely advisory, not a guaranteed maximum; it only affects the space - * used for virtual-array buffers.) May be changed by outer application - * after creating the JPEG object. - */ - long max_memory_to_use; - - /* Maximum allocation request accepted by alloc_large. */ - long max_alloc_chunk; -}; - - -/* Routine signature for application-supplied marker processing methods. - * Need not pass marker code since it is stored in cinfo->unread_marker. - */ -typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); - - -/* Declarations for routines called by application. - * The JPP macro hides prototype parameters from compilers that can't cope. - * Note JPP requires double parentheses. - */ - -#ifdef HAVE_PROTOTYPES -#define JPP(arglist) arglist -#else -#define JPP(arglist) () -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. - * We shorten external names to be unique in the first six letters, which - * is good enough for all known systems. - * (If your compiler itself needs names to be unique in less than 15 - * characters, you are out of luck. Get a better compiler.) - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_error jStdError -#define jpeg_CreateCompress jCreaCompress -#define jpeg_CreateDecompress jCreaDecompress -#define jpeg_destroy_compress jDestCompress -#define jpeg_destroy_decompress jDestDecompress -#define jpeg_stdio_dest jStdDest -#define jpeg_stdio_src jStdSrc -#define jpeg_set_defaults jSetDefaults -#define jpeg_set_colorspace jSetColorspace -#define jpeg_default_colorspace jDefColorspace -#define jpeg_set_quality jSetQuality -#define jpeg_set_linear_quality jSetLQuality -#define jpeg_add_quant_table jAddQuantTable -#define jpeg_quality_scaling jQualityScaling -#define jpeg_simple_progression jSimProgress -#define jpeg_suppress_tables jSuppressTables -#define jpeg_alloc_quant_table jAlcQTable -#define jpeg_alloc_huff_table jAlcHTable -#define jpeg_start_compress jStrtCompress -#define jpeg_write_scanlines jWrtScanlines -#define jpeg_finish_compress jFinCompress -#define jpeg_write_raw_data jWrtRawData -#define jpeg_write_marker jWrtMarker -#define jpeg_write_m_header jWrtMHeader -#define jpeg_write_m_byte jWrtMByte -#define jpeg_write_tables jWrtTables -#define jpeg_read_header jReadHeader -#define jpeg_start_decompress jStrtDecompress -#define jpeg_read_scanlines jReadScanlines -#define jpeg_finish_decompress jFinDecompress -#define jpeg_read_raw_data jReadRawData -#define jpeg_has_multiple_scans jHasMultScn -#define jpeg_start_output jStrtOutput -#define jpeg_finish_output jFinOutput -#define jpeg_input_complete jInComplete -#define jpeg_new_colormap jNewCMap -#define jpeg_consume_input jConsumeInput -#define jpeg_calc_output_dimensions jCalcDimensions -#define jpeg_save_markers jSaveMarkers -#define jpeg_set_marker_processor jSetMarker -#define jpeg_read_coefficients jReadCoefs -#define jpeg_write_coefficients jWrtCoefs -#define jpeg_copy_critical_parameters jCopyCrit -#define jpeg_abort_compress jAbrtCompress -#define jpeg_abort_decompress jAbrtDecompress -#define jpeg_abort jAbort -#define jpeg_destroy jDestroy -#define jpeg_resync_to_restart jResyncRestart -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Default error-management setup */ -EXTERN(struct jpeg_error_mgr *) jpeg_std_error - JPP((struct jpeg_error_mgr * err)); - -/* Initialization of JPEG compression objects. - * jpeg_create_compress() and jpeg_create_decompress() are the exported - * names that applications should call. These expand to calls on - * jpeg_CreateCompress and jpeg_CreateDecompress with additional information - * passed for version mismatch checking. - * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. - */ -#define jpeg_create_compress(cinfo) \ - jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_compress_struct)) -#define jpeg_create_decompress(cinfo) \ - jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_decompress_struct)) -EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, - int version, size_t structsize)); -EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, - int version, size_t structsize)); -/* Destruction of JPEG compression objects */ -EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); - -/* Standard data source and destination managers: stdio streams. */ -/* Caller is responsible for opening the file before and closing after. */ -EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); -EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* Default parameter setup for compression */ -EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); -/* Compression parameter setup aids */ -EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, - J_COLOR_SPACE colorspace)); -EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, - boolean force_baseline)); -EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, - int scale_factor, - boolean force_baseline)); -EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, - boolean force_baseline)); -EXTERN(int) jpeg_quality_scaling JPP((int quality)); -EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, - boolean suppress)); -EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); -EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); - -/* Main entry points for compression */ -EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, - boolean write_all_tables)); -EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION num_lines)); -EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); - -/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION num_lines)); - -/* Write a special marker. See libjpeg.doc concerning safe usage. */ -EXTERN(void) jpeg_write_marker - JPP((j_compress_ptr cinfo, int marker, - const JOCTET * dataptr, unsigned int datalen)); -/* Same, but piecemeal. */ -EXTERN(void) jpeg_write_m_header - JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); -EXTERN(void) jpeg_write_m_byte - JPP((j_compress_ptr cinfo, int val)); - -/* Alternate compression function: just write an abbreviated table file */ -EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); - -/* Decompression startup: read start of JPEG datastream to see what's there */ -EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, - boolean require_image)); -/* Return value is one of: */ -#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ -#define JPEG_HEADER_OK 1 /* Found valid image datastream */ -#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ -/* If you pass require_image = TRUE (normal case), you need not check for - * a TABLES_ONLY return code; an abbreviated file will cause an error exit. - * JPEG_SUSPENDED is only possible if you use a data source module that can - * give a suspension return (the stdio source module doesn't). - */ - -/* Main entry points for decompression */ -EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION max_lines)); -EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); - -/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION max_lines)); - -/* Additional entry points for buffered-image mode. */ -EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, - int scan_number)); -EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); -EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); -/* Return value is one of: */ -/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ -#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ -#define JPEG_REACHED_EOI 2 /* Reached end of image */ -#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ -#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ - -/* Precalculate output dimensions for current decompression parameters. */ -EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); - -/* Control saving of COM and APPn markers into marker_list. */ -EXTERN(void) jpeg_save_markers - JPP((j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit)); - -/* Install a special processing method for COM or APPn markers. */ -EXTERN(void) jpeg_set_marker_processor - JPP((j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine)); - -/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ -EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays)); -EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, - j_compress_ptr dstinfo)); - -/* If you choose to abort compression or decompression before completing - * jpeg_finish_(de)compress, then you need to clean up to release memory, - * temporary files, etc. You can just call jpeg_destroy_(de)compress - * if you're done with the JPEG object, but if you want to clean it up and - * reuse it, call this: - */ -EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); - -/* Generic versions of jpeg_abort and jpeg_destroy that work on either - * flavor of JPEG object. These may be more convenient in some places. - */ -EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); - -/* Default restart-marker-resync procedure for use by data source modules */ -EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, - int desired)); - - -/* These marker codes are exported since applications and data source modules - * are likely to want to use them. - */ - -#define JPEG_RST0 0xD0 /* RST0 marker code */ -#define JPEG_EOI 0xD9 /* EOI marker code */ -#define JPEG_APP0 0xE0 /* APP0 marker code */ -#define JPEG_COM 0xFE /* COM marker code */ - - -/* If we have a brain-damaged compiler that emits warnings (or worse, errors) - * for structure definitions that are never filled in, keep it quiet by - * supplying dummy definitions for the various substructures. - */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -struct jpeg_comp_master { long dummy; }; -struct jpeg_c_main_controller { long dummy; }; -struct jpeg_c_prep_controller { long dummy; }; -struct jpeg_c_coef_controller { long dummy; }; -struct jpeg_marker_writer { long dummy; }; -struct jpeg_color_converter { long dummy; }; -struct jpeg_downsampler { long dummy; }; -struct jpeg_forward_dct { long dummy; }; -struct jpeg_entropy_encoder { long dummy; }; -struct jpeg_decomp_master { long dummy; }; -struct jpeg_d_main_controller { long dummy; }; -struct jpeg_d_coef_controller { long dummy; }; -struct jpeg_d_post_controller { long dummy; }; -struct jpeg_input_controller { long dummy; }; -struct jpeg_marker_reader { long dummy; }; -struct jpeg_entropy_decoder { long dummy; }; -struct jpeg_inverse_dct { long dummy; }; -struct jpeg_upsampler { long dummy; }; -struct jpeg_color_deconverter { long dummy; }; -struct jpeg_color_quantizer { long dummy; }; -#endif /* JPEG_INTERNALS */ -#endif /* INCOMPLETE_TYPES_BROKEN */ - - -/* - * The JPEG library modules define JPEG_INTERNALS before including this file. - * The internal structure declarations are read only when that is true. - * Applications using the library should not include jpegint.h, but may wish - * to include jerror.h. - */ - -#ifdef JPEG_INTERNALS -#include "jpegint.h" /* fetch private declarations */ -#include "jerror.h" /* fetch error codes too */ -#endif - -#endif /* JPEGLIB_H */ diff --git a/freeimage241/Source/LibJPEG/jpegtran.c b/freeimage241/Source/LibJPEG/jpegtran.c deleted file mode 100644 index 20ef111..0000000 --- a/freeimage241/Source/LibJPEG/jpegtran.c +++ /dev/null @@ -1,504 +0,0 @@ -/* - * jpegtran.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for JPEG transcoding. - * It is very similar to cjpeg.c, but provides lossless transcoding between - * different JPEG file formats. It also provides some lossless and sort-of- - * lossless transformations of JPEG data. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "transupp.h" /* Support routines for jpegtran */ -#include "jversion.h" /* for version message */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ -static JCOPY_OPTION copyoption; /* -copy switch */ -static jpeg_transform_info transformoption; /* image transformation options */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -copy none Copy no extra markers from source file\n"); - fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); - fprintf(stderr, " -copy all Copy all extra markers\n"); -#ifdef ENTROPY_OPT_SUPPORTED - fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); -#endif -#ifdef C_PROGRESSIVE_SUPPORTED - fprintf(stderr, " -progressive Create progressive JPEG file\n"); -#endif -#if TRANSFORMS_SUPPORTED - fprintf(stderr, "Switches for modifying the image:\n"); - fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); - fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); - fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); - fprintf(stderr, " -transpose Transpose image\n"); - fprintf(stderr, " -transverse Transverse transpose image\n"); - fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); -#endif /* TRANSFORMS_SUPPORTED */ - fprintf(stderr, "Switches for advanced users:\n"); - fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - fprintf(stderr, "Switches for wizards:\n"); -#ifdef C_ARITH_CODING_SUPPORTED - fprintf(stderr, " -arithmetic Use arithmetic coding\n"); -#endif -#ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); -#endif - exit(EXIT_FAILURE); -} - - -LOCAL(void) -select_transform (JXFORM_CODE transform) -/* Silly little routine to detect multiple transform options, - * which we can't handle. - */ -{ -#if TRANSFORMS_SUPPORTED - if (transformoption.transform == JXFORM_NONE || - transformoption.transform == transform) { - transformoption.transform = transform; - } else { - fprintf(stderr, "%s: can only do one image transformation at a time\n", - progname); - usage(); - } -#else - fprintf(stderr, "%s: sorry, image transformation was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif -} - - -LOCAL(int) -parse_switches (j_compress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - boolean simple_progressive; - char * scansarg = NULL; /* saves -scans parm if any */ - - /* Set up default JPEG parameters. */ - simple_progressive = FALSE; - outfilename = NULL; - copyoption = JCOPYOPT_DEFAULT; - transformoption.transform = JXFORM_NONE; - transformoption.trim = FALSE; - transformoption.force_grayscale = FALSE; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "arithmetic", 1)) { - /* Use arithmetic coding. */ -#ifdef C_ARITH_CODING_SUPPORTED - cinfo->arith_code = TRUE; -#else - fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "copy", 1)) { - /* Select which extra markers to copy. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "none", 1)) { - copyoption = JCOPYOPT_NONE; - } else if (keymatch(argv[argn], "comments", 1)) { - copyoption = JCOPYOPT_COMMENTS; - } else if (keymatch(argv[argn], "all", 1)) { - copyoption = JCOPYOPT_ALL; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "flip", 1)) { - /* Mirror left-right or top-bottom. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "horizontal", 1)) - select_transform(JXFORM_FLIP_H); - else if (keymatch(argv[argn], "vertical", 1)) - select_transform(JXFORM_FLIP_V); - else - usage(); - - } else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) { - /* Force to grayscale. */ -#if TRANSFORMS_SUPPORTED - transformoption.force_grayscale = TRUE; -#else - select_transform(JXFORM_NONE); /* force an error */ -#endif - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { - /* Enable entropy parm optimization. */ -#ifdef ENTROPY_OPT_SUPPORTED - cinfo->optimize_coding = TRUE; -#else - fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "progressive", 1)) { - /* Select simple progressive mode. */ -#ifdef C_PROGRESSIVE_SUPPORTED - simple_progressive = TRUE; - /* We must postpone execution until num_components is known. */ -#else - fprintf(stderr, "%s: sorry, progressive output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "restart", 1)) { - /* Restart interval in MCU rows (or in MCUs with 'b'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (lval < 0 || lval > 65535L) - usage(); - if (ch == 'b' || ch == 'B') { - cinfo->restart_interval = (unsigned int) lval; - cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ - } else { - cinfo->restart_in_rows = (int) lval; - /* restart_interval will be computed during startup */ - } - - } else if (keymatch(arg, "rotate", 2)) { - /* Rotate 90, 180, or 270 degrees (measured clockwise). */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "90", 2)) - select_transform(JXFORM_ROT_90); - else if (keymatch(argv[argn], "180", 3)) - select_transform(JXFORM_ROT_180); - else if (keymatch(argv[argn], "270", 3)) - select_transform(JXFORM_ROT_270); - else - usage(); - - } else if (keymatch(arg, "scans", 1)) { - /* Set scan script. */ -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - scansarg = argv[argn]; - /* We must postpone reading the file in case -progressive appears. */ -#else - fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "transpose", 1)) { - /* Transpose (across UL-to-LR axis). */ - select_transform(JXFORM_TRANSPOSE); - - } else if (keymatch(arg, "transverse", 6)) { - /* Transverse transpose (across UR-to-LL axis). */ - select_transform(JXFORM_TRANSVERSE); - - } else if (keymatch(arg, "trim", 3)) { - /* Trim off any partial edge MCUs that the transform can't handle. */ - transformoption.trim = TRUE; - - } else { - usage(); /* bogus switch */ - } - } - - /* Post-switch-scanning cleanup */ - - if (for_real) { - -#ifdef C_PROGRESSIVE_SUPPORTED - if (simple_progressive) /* process -progressive; -scans can override */ - jpeg_simple_progression(cinfo); -#endif - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (scansarg != NULL) /* process -scans if it was present */ - if (! read_scan_script(cinfo, scansarg)) - usage(); -#endif - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_decompress_struct srcinfo; - struct jpeg_compress_struct dstinfo; - struct jpeg_error_mgr jsrcerr, jdsterr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - jvirt_barray_ptr * src_coef_arrays; - jvirt_barray_ptr * dst_coef_arrays; - int file_index; - FILE * input_file; - FILE * output_file; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "jpegtran"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG decompression object with default error handling. */ - srcinfo.err = jpeg_std_error(&jsrcerr); - jpeg_create_decompress(&srcinfo); - /* Initialize the JPEG compression object with default error handling. */ - dstinfo.err = jpeg_std_error(&jdsterr); - jpeg_create_compress(&dstinfo); - - /* Now safe to enable signal catcher. - * Note: we assume only the decompression object will have virtual arrays. - */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &srcinfo); -#endif - - /* Scan command line to find file names. - * It is convenient to use just one switch-parsing routine, but the switch - * values read here are mostly ignored; we will rescan the switches after - * opening the input file. Also note that most of the switches affect the - * destination JPEG object, so we parse into that and then copy over what - * needs to affects the source too. - */ - - file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE); - jsrcerr.trace_level = jdsterr.trace_level; - srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &dstinfo, &progress); -#endif - - /* Specify data source for decompression */ - jpeg_stdio_src(&srcinfo, input_file); - - /* Enable saving of extra markers that we want to copy */ - jcopy_markers_setup(&srcinfo, copyoption); - - /* Read file header */ - (void) jpeg_read_header(&srcinfo, TRUE); - - /* Any space needed by a transform option must be requested before - * jpeg_read_coefficients so that memory allocation will be done right. - */ -#if TRANSFORMS_SUPPORTED - jtransform_request_workspace(&srcinfo, &transformoption); -#endif - - /* Read source file as DCT coefficients */ - src_coef_arrays = jpeg_read_coefficients(&srcinfo); - - /* Initialize destination compression parameters from source values */ - jpeg_copy_critical_parameters(&srcinfo, &dstinfo); - - /* Adjust destination parameters if required by transform options; - * also find out which set of coefficient arrays will hold the output. - */ -#if TRANSFORMS_SUPPORTED - dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, - src_coef_arrays, - &transformoption); -#else - dst_coef_arrays = src_coef_arrays; -#endif - - /* Adjust default compression parameters by re-parsing the options */ - file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); - - /* Specify data destination for compression */ - jpeg_stdio_dest(&dstinfo, output_file); - - /* Start compressor (note no image data is actually written here) */ - jpeg_write_coefficients(&dstinfo, dst_coef_arrays); - - /* Copy to the output file any extra markers that we want to preserve */ - jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); - - /* Execute image transformation, if any */ -#if TRANSFORMS_SUPPORTED - jtransform_execute_transformation(&srcinfo, &dstinfo, - src_coef_arrays, - &transformoption); -#endif - - /* Finish compression and release memory */ - jpeg_finish_compress(&dstinfo); - jpeg_destroy_compress(&dstinfo); - (void) jpeg_finish_decompress(&srcinfo); - jpeg_destroy_decompress(&srcinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &dstinfo); -#endif - - /* All done. */ - exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/freeimage241/Source/LibJPEG/jquant1.c b/freeimage241/Source/LibJPEG/jquant1.c deleted file mode 100644 index b2f96aa..0000000 --- a/freeimage241/Source/LibJPEG/jquant1.c +++ /dev/null @@ -1,856 +0,0 @@ -/* - * jquant1.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains 1-pass color quantization (color mapping) routines. - * These routines provide mapping to a fixed color map using equally spaced - * color values. Optional Floyd-Steinberg or ordered dithering is available. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef QUANT_1PASS_SUPPORTED - - -/* - * The main purpose of 1-pass quantization is to provide a fast, if not very - * high quality, colormapped output capability. A 2-pass quantizer usually - * gives better visual quality; however, for quantized grayscale output this - * quantizer is perfectly adequate. Dithering is highly recommended with this - * quantizer, though you can turn it off if you really want to. - * - * In 1-pass quantization the colormap must be chosen in advance of seeing the - * image. We use a map consisting of all combinations of Ncolors[i] color - * values for the i'th component. The Ncolors[] values are chosen so that - * their product, the total number of colors, is no more than that requested. - * (In most cases, the product will be somewhat less.) - * - * Since the colormap is orthogonal, the representative value for each color - * component can be determined without considering the other components; - * then these indexes can be combined into a colormap index by a standard - * N-dimensional-array-subscript calculation. Most of the arithmetic involved - * can be precalculated and stored in the lookup table colorindex[]. - * colorindex[i][j] maps pixel value j in component i to the nearest - * representative value (grid plane) for that component; this index is - * multiplied by the array stride for component i, so that the - * index of the colormap entry closest to a given pixel value is just - * sum( colorindex[component-number][pixel-component-value] ) - * Aside from being fast, this scheme allows for variable spacing between - * representative values with no additional lookup cost. - * - * If gamma correction has been applied in color conversion, it might be wise - * to adjust the color grid spacing so that the representative colors are - * equidistant in linear space. At this writing, gamma correction is not - * implemented by jdcolor, so nothing is done here. - */ - - -/* Declarations for ordered dithering. - * - * We use a standard 16x16 ordered dither array. The basic concept of ordered - * dithering is described in many references, for instance Dale Schumacher's - * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991). - * In place of Schumacher's comparisons against a "threshold" value, we add a - * "dither" value to the input pixel and then round the result to the nearest - * output value. The dither value is equivalent to (0.5 - threshold) times - * the distance between output values. For ordered dithering, we assume that - * the output colors are equally spaced; if not, results will probably be - * worse, since the dither may be too much or too little at a given point. - * - * The normal calculation would be to form pixel value + dither, range-limit - * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual. - * We can skip the separate range-limiting step by extending the colorindex - * table in both directions. - */ - -#define ODITHER_SIZE 16 /* dimension of dither matrix */ -/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */ -#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */ -#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */ - -typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE]; -typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE]; - -static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = { - /* Bayer's order-4 dither array. Generated by the code given in - * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I. - * The values in this array must range from 0 to ODITHER_CELLS-1. - */ - { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }, - { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 }, - { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 }, - { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 }, - { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 }, - { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 }, - { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 }, - { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 }, - { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 }, - { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 }, - { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 }, - { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 }, - { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 }, - { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 }, - { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 }, - { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 } -}; - - -/* Declarations for Floyd-Steinberg dithering. - * - * Errors are accumulated into the array fserrors[], at a resolution of - * 1/16th of a pixel count. The error at a given pixel is propagated - * to its not-yet-processed neighbors using the standard F-S fractions, - * ... (here) 7/16 - * 3/16 5/16 1/16 - * We work left-to-right on even rows, right-to-left on odd rows. - * - * We can get away with a single array (holding one row's worth of errors) - * by using it to store the current row's errors at pixel columns not yet - * processed, but the next row's errors at columns already processed. We - * need only a few extra variables to hold the errors immediately around the - * current column. (If we are lucky, those variables are in registers, but - * even if not, they're probably cheaper to access than array elements are.) - * - * The fserrors[] array is indexed [component#][position]. - * We provide (#columns + 2) entries per component; the extra entry at each - * end saves us from special-casing the first and last pixels. - * - * Note: on a wide image, we might not have enough room in a PC's near data - * segment to hold the error array; so it is allocated with alloc_large. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef INT16 FSERROR; /* 16 bits should be enough */ -typedef int LOCFSERROR; /* use 'int' for calculation temps */ -#else -typedef INT32 FSERROR; /* may need more than 16 bits */ -typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ -#endif - -typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ - - -/* Private subobject */ - -#define MAX_Q_COMPS 4 /* max components I can handle */ - -typedef struct { - struct jpeg_color_quantizer pub; /* public fields */ - - /* Initially allocated colormap is saved here */ - JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */ - int sv_actual; /* number of entries in use */ - - JSAMPARRAY colorindex; /* Precomputed mapping for speed */ - /* colorindex[i][j] = index of color closest to pixel value j in component i, - * premultiplied as described above. Since colormap indexes must fit into - * JSAMPLEs, the entries of this array will too. - */ - boolean is_padded; /* is the colorindex padded for odither? */ - - int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */ - - /* Variables for ordered dithering */ - int row_index; /* cur row's vertical index in dither matrix */ - ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */ - - /* Variables for Floyd-Steinberg dithering */ - FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */ - boolean on_odd_row; /* flag to remember which row we are on */ -} my_cquantizer; - -typedef my_cquantizer * my_cquantize_ptr; - - -/* - * Policy-making subroutines for create_colormap and create_colorindex. - * These routines determine the colormap to be used. The rest of the module - * only assumes that the colormap is orthogonal. - * - * * select_ncolors decides how to divvy up the available colors - * among the components. - * * output_value defines the set of representative values for a component. - * * largest_input_value defines the mapping from input values to - * representative values for a component. - * Note that the latter two routines may impose different policies for - * different components, though this is not currently done. - */ - - -LOCAL(int) -select_ncolors (j_decompress_ptr cinfo, int Ncolors[]) -/* Determine allocation of desired colors to components, */ -/* and fill in Ncolors[] array to indicate choice. */ -/* Return value is total number of colors (product of Ncolors[] values). */ -{ - int nc = cinfo->out_color_components; /* number of color components */ - int max_colors = cinfo->desired_number_of_colors; - int total_colors, iroot, i, j; - boolean changed; - long temp; - static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; - - /* We can allocate at least the nc'th root of max_colors per component. */ - /* Compute floor(nc'th root of max_colors). */ - iroot = 1; - do { - iroot++; - temp = iroot; /* set temp = iroot ** nc */ - for (i = 1; i < nc; i++) - temp *= iroot; - } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */ - iroot--; /* now iroot = floor(root) */ - - /* Must have at least 2 color values per component */ - if (iroot < 2) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp); - - /* Initialize to iroot color values for each component */ - total_colors = 1; - for (i = 0; i < nc; i++) { - Ncolors[i] = iroot; - total_colors *= iroot; - } - /* We may be able to increment the count for one or more components without - * exceeding max_colors, though we know not all can be incremented. - * Sometimes, the first component can be incremented more than once! - * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.) - * In RGB colorspace, try to increment G first, then R, then B. - */ - do { - changed = FALSE; - for (i = 0; i < nc; i++) { - j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i); - /* calculate new total_colors if Ncolors[j] is incremented */ - temp = total_colors / Ncolors[j]; - temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */ - if (temp > (long) max_colors) - break; /* won't fit, done with this pass */ - Ncolors[j]++; /* OK, apply the increment */ - total_colors = (int) temp; - changed = TRUE; - } - } while (changed); - - return total_colors; -} - - -LOCAL(int) -output_value (j_decompress_ptr cinfo, int ci, int j, int maxj) -/* Return j'th output value, where j will range from 0 to maxj */ -/* The output values must fall in 0..MAXJSAMPLE in increasing order */ -{ - /* We always provide values 0 and MAXJSAMPLE for each component; - * any additional values are equally spaced between these limits. - * (Forcing the upper and lower values to the limits ensures that - * dithering can't produce a color outside the selected gamut.) - */ - return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj); -} - - -LOCAL(int) -largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj) -/* Return largest input value that should map to j'th output value */ -/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */ -{ - /* Breakpoints are halfway between values returned by output_value */ - return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj)); -} - - -/* - * Create the colormap. - */ - -LOCAL(void) -create_colormap (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPARRAY colormap; /* Created colormap */ - int total_colors; /* Number of distinct output colors */ - int i,j,k, nci, blksize, blkdist, ptr, val; - - /* Select number of colors for each component */ - total_colors = select_ncolors(cinfo, cquantize->Ncolors); - - /* Report selected color counts */ - if (cinfo->out_color_components == 3) - TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, - total_colors, cquantize->Ncolors[0], - cquantize->Ncolors[1], cquantize->Ncolors[2]); - else - TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors); - - /* Allocate and fill in the colormap. */ - /* The colors are ordered in the map in standard row-major order, */ - /* i.e. rightmost (highest-indexed) color changes most rapidly. */ - - colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components); - - /* blksize is number of adjacent repeated entries for a component */ - /* blkdist is distance between groups of identical entries for a component */ - blkdist = total_colors; - - for (i = 0; i < cinfo->out_color_components; i++) { - /* fill in colormap entries for i'th color component */ - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - blksize = blkdist / nci; - for (j = 0; j < nci; j++) { - /* Compute j'th output value (out of nci) for component */ - val = output_value(cinfo, i, j, nci-1); - /* Fill in all colormap entries that have this value of this component */ - for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) { - /* fill in blksize entries beginning at ptr */ - for (k = 0; k < blksize; k++) - colormap[i][ptr+k] = (JSAMPLE) val; - } - } - blkdist = blksize; /* blksize of this color is blkdist of next */ - } - - /* Save the colormap in private storage, - * where it will survive color quantization mode changes. - */ - cquantize->sv_colormap = colormap; - cquantize->sv_actual = total_colors; -} - - -/* - * Create the color index table. - */ - -LOCAL(void) -create_colorindex (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPROW indexptr; - int i,j,k, nci, blksize, val, pad; - - /* For ordered dither, we pad the color index tables by MAXJSAMPLE in - * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE). - * This is not necessary in the other dithering modes. However, we - * flag whether it was done in case user changes dithering mode. - */ - if (cinfo->dither_mode == JDITHER_ORDERED) { - pad = MAXJSAMPLE*2; - cquantize->is_padded = TRUE; - } else { - pad = 0; - cquantize->is_padded = FALSE; - } - - cquantize->colorindex = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (MAXJSAMPLE+1 + pad), - (JDIMENSION) cinfo->out_color_components); - - /* blksize is number of adjacent repeated entries for a component */ - blksize = cquantize->sv_actual; - - for (i = 0; i < cinfo->out_color_components; i++) { - /* fill in colorindex entries for i'th color component */ - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - blksize = blksize / nci; - - /* adjust colorindex pointers to provide padding at negative indexes. */ - if (pad) - cquantize->colorindex[i] += MAXJSAMPLE; - - /* in loop, val = index of current output value, */ - /* and k = largest j that maps to current val */ - indexptr = cquantize->colorindex[i]; - val = 0; - k = largest_input_value(cinfo, i, 0, nci-1); - for (j = 0; j <= MAXJSAMPLE; j++) { - while (j > k) /* advance val if past boundary */ - k = largest_input_value(cinfo, i, ++val, nci-1); - /* premultiply so that no multiplication needed in main processing */ - indexptr[j] = (JSAMPLE) (val * blksize); - } - /* Pad at both ends if necessary */ - if (pad) - for (j = 1; j <= MAXJSAMPLE; j++) { - indexptr[-j] = indexptr[0]; - indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE]; - } - } -} - - -/* - * Create an ordered-dither array for a component having ncolors - * distinct output values. - */ - -LOCAL(ODITHER_MATRIX_PTR) -make_odither_array (j_decompress_ptr cinfo, int ncolors) -{ - ODITHER_MATRIX_PTR odither; - int j,k; - INT32 num,den; - - odither = (ODITHER_MATRIX_PTR) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ODITHER_MATRIX)); - /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). - * Hence the dither value for the matrix cell with fill order f - * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). - * On 16-bit-int machine, be careful to avoid overflow. - */ - den = 2 * ODITHER_CELLS * ((INT32) (ncolors - 1)); - for (j = 0; j < ODITHER_SIZE; j++) { - for (k = 0; k < ODITHER_SIZE; k++) { - num = ((INT32) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k]))) - * MAXJSAMPLE; - /* Ensure round towards zero despite C's lack of consistency - * about rounding negative values in integer division... - */ - odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den); - } - } - return odither; -} - - -/* - * Create the ordered-dither tables. - * Components having the same number of representative colors may - * share a dither table. - */ - -LOCAL(void) -create_odither_tables (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - ODITHER_MATRIX_PTR odither; - int i, j, nci; - - for (i = 0; i < cinfo->out_color_components; i++) { - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - odither = NULL; /* search for matching prior component */ - for (j = 0; j < i; j++) { - if (nci == cquantize->Ncolors[j]) { - odither = cquantize->odither[j]; - break; - } - } - if (odither == NULL) /* need a new table? */ - odither = make_odither_array(cinfo, nci); - cquantize->odither[i] = odither; - } -} - - -/* - * Map some rows of pixels to the output colormapped representation. - */ - -METHODDEF(void) -color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPARRAY colorindex = cquantize->colorindex; - register int pixcode, ci; - register JSAMPROW ptrin, ptrout; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - register int nc = cinfo->out_color_components; - - for (row = 0; row < num_rows; row++) { - ptrin = input_buf[row]; - ptrout = output_buf[row]; - for (col = width; col > 0; col--) { - pixcode = 0; - for (ci = 0; ci < nc; ci++) { - pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]); - } - *ptrout++ = (JSAMPLE) pixcode; - } - } -} - - -METHODDEF(void) -color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* Fast path for out_color_components==3, no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register int pixcode; - register JSAMPROW ptrin, ptrout; - JSAMPROW colorindex0 = cquantize->colorindex[0]; - JSAMPROW colorindex1 = cquantize->colorindex[1]; - JSAMPROW colorindex2 = cquantize->colorindex[2]; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - ptrin = input_buf[row]; - ptrout = output_buf[row]; - for (col = width; col > 0; col--) { - pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]); - pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]); - pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]); - *ptrout++ = (JSAMPLE) pixcode; - } - } -} - - -METHODDEF(void) -quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, with ordered dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex_ci; - int * dither; /* points to active row of dither matrix */ - int row_index, col_index; /* current indexes into dither matrix */ - int nc = cinfo->out_color_components; - int ci; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); - row_index = cquantize->row_index; - for (ci = 0; ci < nc; ci++) { - input_ptr = input_buf[row] + ci; - output_ptr = output_buf[row]; - colorindex_ci = cquantize->colorindex[ci]; - dither = cquantize->odither[ci][row_index]; - col_index = 0; - - for (col = width; col > 0; col--) { - /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE, - * select output value, accumulate into output code for this pixel. - * Range-limiting need not be done explicitly, as we have extended - * the colorindex table to produce the right answers for out-of-range - * inputs. The maximum dither is +- MAXJSAMPLE; this sets the - * required amount of padding. - */ - *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]]; - input_ptr += nc; - output_ptr++; - col_index = (col_index + 1) & ODITHER_MASK; - } - } - /* Advance row index for next row */ - row_index = (row_index + 1) & ODITHER_MASK; - cquantize->row_index = row_index; - } -} - - -METHODDEF(void) -quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* Fast path for out_color_components==3, with ordered dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register int pixcode; - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex0 = cquantize->colorindex[0]; - JSAMPROW colorindex1 = cquantize->colorindex[1]; - JSAMPROW colorindex2 = cquantize->colorindex[2]; - int * dither0; /* points to active row of dither matrix */ - int * dither1; - int * dither2; - int row_index, col_index; /* current indexes into dither matrix */ - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - row_index = cquantize->row_index; - input_ptr = input_buf[row]; - output_ptr = output_buf[row]; - dither0 = cquantize->odither[0][row_index]; - dither1 = cquantize->odither[1][row_index]; - dither2 = cquantize->odither[2][row_index]; - col_index = 0; - - for (col = width; col > 0; col--) { - pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + - dither0[col_index]]); - pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + - dither1[col_index]]); - pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + - dither2[col_index]]); - *output_ptr++ = (JSAMPLE) pixcode; - col_index = (col_index + 1) & ODITHER_MASK; - } - row_index = (row_index + 1) & ODITHER_MASK; - cquantize->row_index = row_index; - } -} - - -METHODDEF(void) -quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, with Floyd-Steinberg dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register LOCFSERROR cur; /* current error or pixel value */ - LOCFSERROR belowerr; /* error for pixel below cur */ - LOCFSERROR bpreverr; /* error for below/prev col */ - LOCFSERROR bnexterr; /* error for below/next col */ - LOCFSERROR delta; - register FSERRPTR errorptr; /* => fserrors[] at column before current */ - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex_ci; - JSAMPROW colormap_ci; - int pixcode; - int nc = cinfo->out_color_components; - int dir; /* 1 for left-to-right, -1 for right-to-left */ - int dirnc; /* dir * nc */ - int ci; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - JSAMPLE *range_limit = cinfo->sample_range_limit; - SHIFT_TEMPS - - for (row = 0; row < num_rows; row++) { - /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); - for (ci = 0; ci < nc; ci++) { - input_ptr = input_buf[row] + ci; - output_ptr = output_buf[row]; - if (cquantize->on_odd_row) { - /* work right to left in this row */ - input_ptr += (width-1) * nc; /* so point to rightmost pixel */ - output_ptr += width-1; - dir = -1; - dirnc = -nc; - errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */ - } else { - /* work left to right in this row */ - dir = 1; - dirnc = nc; - errorptr = cquantize->fserrors[ci]; /* => entry before first column */ - } - colorindex_ci = cquantize->colorindex[ci]; - colormap_ci = cquantize->sv_colormap[ci]; - /* Preset error values: no error propagated to first pixel from left */ - cur = 0; - /* and no error propagated to row below yet */ - belowerr = bpreverr = 0; - - for (col = width; col > 0; col--) { - /* cur holds the error propagated from the previous pixel on the - * current line. Add the error propagated from the previous line - * to form the complete error correction term for this pixel, and - * round the error term (which is expressed * 16) to an integer. - * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct - * for either sign of the error value. - * Note: errorptr points to *previous* column's array entry. - */ - cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4); - /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. - * The maximum error is +- MAXJSAMPLE; this sets the required size - * of the range_limit array. - */ - cur += GETJSAMPLE(*input_ptr); - cur = GETJSAMPLE(range_limit[cur]); - /* Select output value, accumulate into output code for this pixel */ - pixcode = GETJSAMPLE(colorindex_ci[cur]); - *output_ptr += (JSAMPLE) pixcode; - /* Compute actual representation error at this pixel */ - /* Note: we can do this even though we don't have the final */ - /* pixel code, because the colormap is orthogonal. */ - cur -= GETJSAMPLE(colormap_ci[pixcode]); - /* Compute error fractions to be propagated to adjacent pixels. - * Add these into the running sums, and simultaneously shift the - * next-line error sums left by 1 column. - */ - bnexterr = cur; - delta = cur * 2; - cur += delta; /* form error * 3 */ - errorptr[0] = (FSERROR) (bpreverr + cur); - cur += delta; /* form error * 5 */ - bpreverr = belowerr + cur; - belowerr = bnexterr; - cur += delta; /* form error * 7 */ - /* At this point cur contains the 7/16 error value to be propagated - * to the next pixel on the current line, and all the errors for the - * next line have been shifted over. We are therefore ready to move on. - */ - input_ptr += dirnc; /* advance input ptr to next column */ - output_ptr += dir; /* advance output ptr to next column */ - errorptr += dir; /* advance errorptr to current column */ - } - /* Post-loop cleanup: we must unload the final error value into the - * final fserrors[] entry. Note we need not unload belowerr because - * it is for the dummy column before or after the actual array. - */ - errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */ - } - cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE); - } -} - - -/* - * Allocate workspace for Floyd-Steinberg errors. - */ - -LOCAL(void) -alloc_fs_workspace (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - size_t arraysize; - int i; - - arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); - for (i = 0; i < cinfo->out_color_components; i++) { - cquantize->fserrors[i] = (FSERRPTR) - (*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); - } -} - - -/* - * Initialize for one-pass color quantization. - */ - -METHODDEF(void) -start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - size_t arraysize; - int i; - - /* Install my colormap. */ - cinfo->colormap = cquantize->sv_colormap; - cinfo->actual_number_of_colors = cquantize->sv_actual; - - /* Initialize for desired dithering mode. */ - switch (cinfo->dither_mode) { - case JDITHER_NONE: - if (cinfo->out_color_components == 3) - cquantize->pub.color_quantize = color_quantize3; - else - cquantize->pub.color_quantize = color_quantize; - break; - case JDITHER_ORDERED: - if (cinfo->out_color_components == 3) - cquantize->pub.color_quantize = quantize3_ord_dither; - else - cquantize->pub.color_quantize = quantize_ord_dither; - cquantize->row_index = 0; /* initialize state for ordered dither */ - /* If user changed to ordered dither from another mode, - * we must recreate the color index table with padding. - * This will cost extra space, but probably isn't very likely. - */ - if (! cquantize->is_padded) - create_colorindex(cinfo); - /* Create ordered-dither tables if we didn't already. */ - if (cquantize->odither[0] == NULL) - create_odither_tables(cinfo); - break; - case JDITHER_FS: - cquantize->pub.color_quantize = quantize_fs_dither; - cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */ - /* Allocate Floyd-Steinberg workspace if didn't already. */ - if (cquantize->fserrors[0] == NULL) - alloc_fs_workspace(cinfo); - /* Initialize the propagated errors to zero. */ - arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); - for (i = 0; i < cinfo->out_color_components; i++) - jzero_far((void FAR *) cquantize->fserrors[i], arraysize); - break; - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } -} - - -/* - * Finish up at the end of the pass. - */ - -METHODDEF(void) -finish_pass_1_quant (j_decompress_ptr cinfo) -{ - /* no work in 1-pass case */ -} - - -/* - * Switch to a new external colormap between output passes. - * Shouldn't get to this module! - */ - -METHODDEF(void) -new_color_map_1_quant (j_decompress_ptr cinfo) -{ - ERREXIT(cinfo, JERR_MODE_CHANGE); -} - - -/* - * Module initialization routine for 1-pass color quantization. - */ - -GLOBAL(void) -jinit_1pass_quantizer (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize; - - cquantize = (my_cquantize_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_cquantizer)); - cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; - cquantize->pub.start_pass = start_pass_1_quant; - cquantize->pub.finish_pass = finish_pass_1_quant; - cquantize->pub.new_color_map = new_color_map_1_quant; - cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */ - cquantize->odither[0] = NULL; /* Also flag odither arrays not allocated */ - - /* Make sure my internal arrays won't overflow */ - if (cinfo->out_color_components > MAX_Q_COMPS) - ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS); - /* Make sure colormap indexes can be represented by JSAMPLEs */ - if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1)) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1); - - /* Create the colormap and color index table. */ - create_colormap(cinfo); - create_colorindex(cinfo); - - /* Allocate Floyd-Steinberg workspace now if requested. - * We do this now since it is FAR storage and may affect the memory - * manager's space calculations. If the user changes to FS dither - * mode in a later pass, we will allocate the space then, and will - * possibly overrun the max_memory_to_use setting. - */ - if (cinfo->dither_mode == JDITHER_FS) - alloc_fs_workspace(cinfo); -} - -#endif /* QUANT_1PASS_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jquant2.c b/freeimage241/Source/LibJPEG/jquant2.c deleted file mode 100644 index af601e3..0000000 --- a/freeimage241/Source/LibJPEG/jquant2.c +++ /dev/null @@ -1,1310 +0,0 @@ -/* - * jquant2.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains 2-pass color quantization (color mapping) routines. - * These routines provide selection of a custom color map for an image, - * followed by mapping of the image to that color map, with optional - * Floyd-Steinberg dithering. - * It is also possible to use just the second pass to map to an arbitrary - * externally-given color map. - * - * Note: ordered dithering is not supported, since there isn't any fast - * way to compute intercolor distances; it's unclear that ordered dither's - * fundamental assumptions even hold with an irregularly spaced color map. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef QUANT_2PASS_SUPPORTED - - -/* - * This module implements the well-known Heckbert paradigm for color - * quantization. Most of the ideas used here can be traced back to - * Heckbert's seminal paper - * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display", - * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304. - * - * In the first pass over the image, we accumulate a histogram showing the - * usage count of each possible color. To keep the histogram to a reasonable - * size, we reduce the precision of the input; typical practice is to retain - * 5 or 6 bits per color, so that 8 or 4 different input values are counted - * in the same histogram cell. - * - * Next, the color-selection step begins with a box representing the whole - * color space, and repeatedly splits the "largest" remaining box until we - * have as many boxes as desired colors. Then the mean color in each - * remaining box becomes one of the possible output colors. - * - * The second pass over the image maps each input pixel to the closest output - * color (optionally after applying a Floyd-Steinberg dithering correction). - * This mapping is logically trivial, but making it go fast enough requires - * considerable care. - * - * Heckbert-style quantizers vary a good deal in their policies for choosing - * the "largest" box and deciding where to cut it. The particular policies - * used here have proved out well in experimental comparisons, but better ones - * may yet be found. - * - * In earlier versions of the IJG code, this module quantized in YCbCr color - * space, processing the raw upsampled data without a color conversion step. - * This allowed the color conversion math to be done only once per colormap - * entry, not once per pixel. However, that optimization precluded other - * useful optimizations (such as merging color conversion with upsampling) - * and it also interfered with desired capabilities such as quantizing to an - * externally-supplied colormap. We have therefore abandoned that approach. - * The present code works in the post-conversion color space, typically RGB. - * - * To improve the visual quality of the results, we actually work in scaled - * RGB space, giving G distances more weight than R, and R in turn more than - * B. To do everything in integer math, we must use integer scale factors. - * The 2/3/1 scale factors used here correspond loosely to the relative - * weights of the colors in the NTSC grayscale equation. - * If you want to use this code to quantize a non-RGB color space, you'll - * probably need to change these scale factors. - */ - -#define R_SCALE 2 /* scale R distances by this much */ -#define G_SCALE 3 /* scale G distances by this much */ -#define B_SCALE 1 /* and B by this much */ - -/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined - * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B - * and B,G,R orders. If you define some other weird order in jmorecfg.h, - * you'll get compile errors until you extend this logic. In that case - * you'll probably want to tweak the histogram sizes too. - */ - -#if RGB_RED == 0 -#define C0_SCALE R_SCALE -#endif -#if RGB_BLUE == 0 -#define C0_SCALE B_SCALE -#endif -#if RGB_GREEN == 1 -#define C1_SCALE G_SCALE -#endif -#if RGB_RED == 2 -#define C2_SCALE R_SCALE -#endif -#if RGB_BLUE == 2 -#define C2_SCALE B_SCALE -#endif - - -/* - * First we have the histogram data structure and routines for creating it. - * - * The number of bits of precision can be adjusted by changing these symbols. - * We recommend keeping 6 bits for G and 5 each for R and B. - * If you have plenty of memory and cycles, 6 bits all around gives marginally - * better results; if you are short of memory, 5 bits all around will save - * some space but degrade the results. - * To maintain a fully accurate histogram, we'd need to allocate a "long" - * (preferably unsigned long) for each cell. In practice this is overkill; - * we can get by with 16 bits per cell. Few of the cell counts will overflow, - * and clamping those that do overflow to the maximum value will give close- - * enough results. This reduces the recommended histogram size from 256Kb - * to 128Kb, which is a useful savings on PC-class machines. - * (In the second pass the histogram space is re-used for pixel mapping data; - * in that capacity, each cell must be able to store zero to the number of - * desired colors. 16 bits/cell is plenty for that too.) - * Since the JPEG code is intended to run in small memory model on 80x86 - * machines, we can't just allocate the histogram in one chunk. Instead - * of a true 3-D array, we use a row of pointers to 2-D arrays. Each - * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and - * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that - * on 80x86 machines, the pointer row is in near memory but the actual - * arrays are in far memory (same arrangement as we use for image arrays). - */ - -#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ - -/* These will do the right thing for either R,G,B or B,G,R color order, - * but you may not like the results for other color orders. - */ -#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */ -#define HIST_C1_BITS 6 /* bits of precision in G histogram */ -#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */ - -/* Number of elements along histogram axes. */ -#define HIST_C0_ELEMS (1<cquantize; - register JSAMPROW ptr; - register histptr histp; - register hist3d histogram = cquantize->histogram; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - ptr = input_buf[row]; - for (col = width; col > 0; col--) { - /* get pixel value and index into the histogram */ - histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT] - [GETJSAMPLE(ptr[1]) >> C1_SHIFT] - [GETJSAMPLE(ptr[2]) >> C2_SHIFT]; - /* increment, check for overflow and undo increment if so. */ - if (++(*histp) <= 0) - (*histp)--; - ptr += 3; - } - } -} - - -/* - * Next we have the really interesting routines: selection of a colormap - * given the completed histogram. - * These routines work with a list of "boxes", each representing a rectangular - * subset of the input color space (to histogram precision). - */ - -typedef struct { - /* The bounds of the box (inclusive); expressed as histogram indexes */ - int c0min, c0max; - int c1min, c1max; - int c2min, c2max; - /* The volume (actually 2-norm) of the box */ - INT32 volume; - /* The number of nonzero histogram cells within this box */ - long colorcount; -} box; - -typedef box * boxptr; - - -LOCAL(boxptr) -find_biggest_color_pop (boxptr boxlist, int numboxes) -/* Find the splittable box with the largest color population */ -/* Returns NULL if no splittable boxes remain */ -{ - register boxptr boxp; - register int i; - register long maxc = 0; - boxptr which = NULL; - - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { - if (boxp->colorcount > maxc && boxp->volume > 0) { - which = boxp; - maxc = boxp->colorcount; - } - } - return which; -} - - -LOCAL(boxptr) -find_biggest_volume (boxptr boxlist, int numboxes) -/* Find the splittable box with the largest (scaled) volume */ -/* Returns NULL if no splittable boxes remain */ -{ - register boxptr boxp; - register int i; - register INT32 maxv = 0; - boxptr which = NULL; - - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { - if (boxp->volume > maxv) { - which = boxp; - maxv = boxp->volume; - } - } - return which; -} - - -LOCAL(void) -update_box (j_decompress_ptr cinfo, boxptr boxp) -/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ -/* and recompute its volume and population */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - histptr histp; - int c0,c1,c2; - int c0min,c0max,c1min,c1max,c2min,c2max; - INT32 dist0,dist1,dist2; - long ccount; - - c0min = boxp->c0min; c0max = boxp->c0max; - c1min = boxp->c1min; c1max = boxp->c1max; - c2min = boxp->c2min; c2max = boxp->c2max; - - if (c0max > c0min) - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c0min = c0min = c0; - goto have_c0min; - } - } - have_c0min: - if (c0max > c0min) - for (c0 = c0max; c0 >= c0min; c0--) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c0max = c0max = c0; - goto have_c0max; - } - } - have_c0max: - if (c1max > c1min) - for (c1 = c1min; c1 <= c1max; c1++) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c1min = c1min = c1; - goto have_c1min; - } - } - have_c1min: - if (c1max > c1min) - for (c1 = c1max; c1 >= c1min; c1--) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c1max = c1max = c1; - goto have_c1max; - } - } - have_c1max: - if (c2max > c2min) - for (c2 = c2min; c2 <= c2max; c2++) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1min][c2]; - for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) - if (*histp != 0) { - boxp->c2min = c2min = c2; - goto have_c2min; - } - } - have_c2min: - if (c2max > c2min) - for (c2 = c2max; c2 >= c2min; c2--) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1min][c2]; - for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) - if (*histp != 0) { - boxp->c2max = c2max = c2; - goto have_c2max; - } - } - have_c2max: - - /* Update box volume. - * We use 2-norm rather than real volume here; this biases the method - * against making long narrow boxes, and it has the side benefit that - * a box is splittable iff norm > 0. - * Since the differences are expressed in histogram-cell units, - * we have to shift back to JSAMPLE units to get consistent distances; - * after which, we scale according to the selected distance scale factors. - */ - dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE; - dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; - dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; - boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; - - /* Now scan remaining volume of box and compute population */ - ccount = 0; - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++, histp++) - if (*histp != 0) { - ccount++; - } - } - boxp->colorcount = ccount; -} - - -LOCAL(int) -median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes, - int desired_colors) -/* Repeatedly select and split the largest box until we have enough boxes */ -{ - int n,lb; - int c0,c1,c2,cmax; - register boxptr b1,b2; - - while (numboxes < desired_colors) { - /* Select box to split. - * Current algorithm: by population for first half, then by volume. - */ - if (numboxes*2 <= desired_colors) { - b1 = find_biggest_color_pop(boxlist, numboxes); - } else { - b1 = find_biggest_volume(boxlist, numboxes); - } - if (b1 == NULL) /* no splittable boxes left! */ - break; - b2 = &boxlist[numboxes]; /* where new box will go */ - /* Copy the color bounds to the new box. */ - b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max; - b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min; - /* Choose which axis to split the box on. - * Current algorithm: longest scaled axis. - * See notes in update_box about scaling distances. - */ - c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; - c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; - c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; - /* We want to break any ties in favor of green, then red, blue last. - * This code does the right thing for R,G,B or B,G,R color orders only. - */ -#if RGB_RED == 0 - cmax = c1; n = 1; - if (c0 > cmax) { cmax = c0; n = 0; } - if (c2 > cmax) { n = 2; } -#else - cmax = c1; n = 1; - if (c2 > cmax) { cmax = c2; n = 2; } - if (c0 > cmax) { n = 0; } -#endif - /* Choose split point along selected axis, and update box bounds. - * Current algorithm: split at halfway point. - * (Since the box has been shrunk to minimum volume, - * any split will produce two nonempty subboxes.) - * Note that lb value is max for lower box, so must be < old max. - */ - switch (n) { - case 0: - lb = (b1->c0max + b1->c0min) / 2; - b1->c0max = lb; - b2->c0min = lb+1; - break; - case 1: - lb = (b1->c1max + b1->c1min) / 2; - b1->c1max = lb; - b2->c1min = lb+1; - break; - case 2: - lb = (b1->c2max + b1->c2min) / 2; - b1->c2max = lb; - b2->c2min = lb+1; - break; - } - /* Update stats for boxes */ - update_box(cinfo, b1); - update_box(cinfo, b2); - numboxes++; - } - return numboxes; -} - - -LOCAL(void) -compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) -/* Compute representative color for a box, put it in colormap[icolor] */ -{ - /* Current algorithm: mean weighted by pixels (not colors) */ - /* Note it is important to get the rounding correct! */ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - histptr histp; - int c0,c1,c2; - int c0min,c0max,c1min,c1max,c2min,c2max; - long count; - long total = 0; - long c0total = 0; - long c1total = 0; - long c2total = 0; - - c0min = boxp->c0min; c0max = boxp->c0max; - c1min = boxp->c1min; c1max = boxp->c1max; - c2min = boxp->c2min; c2max = boxp->c2max; - - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) { - if ((count = *histp++) != 0) { - total += count; - c0total += ((c0 << C0_SHIFT) + ((1<>1)) * count; - c1total += ((c1 << C1_SHIFT) + ((1<>1)) * count; - c2total += ((c2 << C2_SHIFT) + ((1<>1)) * count; - } - } - } - - cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); - cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); - cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); -} - - -LOCAL(void) -select_colors (j_decompress_ptr cinfo, int desired_colors) -/* Master routine for color selection */ -{ - boxptr boxlist; - int numboxes; - int i; - - /* Allocate workspace for box list */ - boxlist = (boxptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box)); - /* Initialize one box containing whole space */ - numboxes = 1; - boxlist[0].c0min = 0; - boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT; - boxlist[0].c1min = 0; - boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT; - boxlist[0].c2min = 0; - boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT; - /* Shrink it to actually-used volume and set its statistics */ - update_box(cinfo, & boxlist[0]); - /* Perform median-cut to produce final box list */ - numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors); - /* Compute the representative color for each box, fill colormap */ - for (i = 0; i < numboxes; i++) - compute_color(cinfo, & boxlist[i], i); - cinfo->actual_number_of_colors = numboxes; - TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes); -} - - -/* - * These routines are concerned with the time-critical task of mapping input - * colors to the nearest color in the selected colormap. - * - * We re-use the histogram space as an "inverse color map", essentially a - * cache for the results of nearest-color searches. All colors within a - * histogram cell will be mapped to the same colormap entry, namely the one - * closest to the cell's center. This may not be quite the closest entry to - * the actual input color, but it's almost as good. A zero in the cache - * indicates we haven't found the nearest color for that cell yet; the array - * is cleared to zeroes before starting the mapping pass. When we find the - * nearest color for a cell, its colormap index plus one is recorded in the - * cache for future use. The pass2 scanning routines call fill_inverse_cmap - * when they need to use an unfilled entry in the cache. - * - * Our method of efficiently finding nearest colors is based on the "locally - * sorted search" idea described by Heckbert and on the incremental distance - * calculation described by Spencer W. Thomas in chapter III.1 of Graphics - * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that - * the distances from a given colormap entry to each cell of the histogram can - * be computed quickly using an incremental method: the differences between - * distances to adjacent cells themselves differ by a constant. This allows a - * fairly fast implementation of the "brute force" approach of computing the - * distance from every colormap entry to every histogram cell. Unfortunately, - * it needs a work array to hold the best-distance-so-far for each histogram - * cell (because the inner loop has to be over cells, not colormap entries). - * The work array elements have to be INT32s, so the work array would need - * 256Kb at our recommended precision. This is not feasible in DOS machines. - * - * To get around these problems, we apply Thomas' method to compute the - * nearest colors for only the cells within a small subbox of the histogram. - * The work array need be only as big as the subbox, so the memory usage - * problem is solved. Furthermore, we need not fill subboxes that are never - * referenced in pass2; many images use only part of the color gamut, so a - * fair amount of work is saved. An additional advantage of this - * approach is that we can apply Heckbert's locality criterion to quickly - * eliminate colormap entries that are far away from the subbox; typically - * three-fourths of the colormap entries are rejected by Heckbert's criterion, - * and we need not compute their distances to individual cells in the subbox. - * The speed of this approach is heavily influenced by the subbox size: too - * small means too much overhead, too big loses because Heckbert's criterion - * can't eliminate as many colormap entries. Empirically the best subbox - * size seems to be about 1/512th of the histogram (1/8th in each direction). - * - * Thomas' article also describes a refined method which is asymptotically - * faster than the brute-force method, but it is also far more complex and - * cannot efficiently be applied to small subboxes. It is therefore not - * useful for programs intended to be portable to DOS machines. On machines - * with plenty of memory, filling the whole histogram in one shot with Thomas' - * refined method might be faster than the present code --- but then again, - * it might not be any faster, and it's certainly more complicated. - */ - - -/* log2(histogram cells in update box) for each axis; this can be adjusted */ -#define BOX_C0_LOG (HIST_C0_BITS-3) -#define BOX_C1_LOG (HIST_C1_BITS-3) -#define BOX_C2_LOG (HIST_C2_BITS-3) - -#define BOX_C0_ELEMS (1<actual_number_of_colors; - int maxc0, maxc1, maxc2; - int centerc0, centerc1, centerc2; - int i, x, ncolors; - INT32 minmaxdist, min_dist, max_dist, tdist; - INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */ - - /* Compute true coordinates of update box's upper corner and center. - * Actually we compute the coordinates of the center of the upper-corner - * histogram cell, which are the upper bounds of the volume we care about. - * Note that since ">>" rounds down, the "center" values may be closer to - * min than to max; hence comparisons to them must be "<=", not "<". - */ - maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT)); - centerc0 = (minc0 + maxc0) >> 1; - maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT)); - centerc1 = (minc1 + maxc1) >> 1; - maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT)); - centerc2 = (minc2 + maxc2) >> 1; - - /* For each color in colormap, find: - * 1. its minimum squared-distance to any point in the update box - * (zero if color is within update box); - * 2. its maximum squared-distance to any point in the update box. - * Both of these can be found by considering only the corners of the box. - * We save the minimum distance for each color in mindist[]; - * only the smallest maximum distance is of interest. - */ - minmaxdist = 0x7FFFFFFFL; - - for (i = 0; i < numcolors; i++) { - /* We compute the squared-c0-distance term, then add in the other two. */ - x = GETJSAMPLE(cinfo->colormap[0][i]); - if (x < minc0) { - tdist = (x - minc0) * C0_SCALE; - min_dist = tdist*tdist; - tdist = (x - maxc0) * C0_SCALE; - max_dist = tdist*tdist; - } else if (x > maxc0) { - tdist = (x - maxc0) * C0_SCALE; - min_dist = tdist*tdist; - tdist = (x - minc0) * C0_SCALE; - max_dist = tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - min_dist = 0; - if (x <= centerc0) { - tdist = (x - maxc0) * C0_SCALE; - max_dist = tdist*tdist; - } else { - tdist = (x - minc0) * C0_SCALE; - max_dist = tdist*tdist; - } - } - - x = GETJSAMPLE(cinfo->colormap[1][i]); - if (x < minc1) { - tdist = (x - minc1) * C1_SCALE; - min_dist += tdist*tdist; - tdist = (x - maxc1) * C1_SCALE; - max_dist += tdist*tdist; - } else if (x > maxc1) { - tdist = (x - maxc1) * C1_SCALE; - min_dist += tdist*tdist; - tdist = (x - minc1) * C1_SCALE; - max_dist += tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - if (x <= centerc1) { - tdist = (x - maxc1) * C1_SCALE; - max_dist += tdist*tdist; - } else { - tdist = (x - minc1) * C1_SCALE; - max_dist += tdist*tdist; - } - } - - x = GETJSAMPLE(cinfo->colormap[2][i]); - if (x < minc2) { - tdist = (x - minc2) * C2_SCALE; - min_dist += tdist*tdist; - tdist = (x - maxc2) * C2_SCALE; - max_dist += tdist*tdist; - } else if (x > maxc2) { - tdist = (x - maxc2) * C2_SCALE; - min_dist += tdist*tdist; - tdist = (x - minc2) * C2_SCALE; - max_dist += tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - if (x <= centerc2) { - tdist = (x - maxc2) * C2_SCALE; - max_dist += tdist*tdist; - } else { - tdist = (x - minc2) * C2_SCALE; - max_dist += tdist*tdist; - } - } - - mindist[i] = min_dist; /* save away the results */ - if (max_dist < minmaxdist) - minmaxdist = max_dist; - } - - /* Now we know that no cell in the update box is more than minmaxdist - * away from some colormap entry. Therefore, only colors that are - * within minmaxdist of some part of the box need be considered. - */ - ncolors = 0; - for (i = 0; i < numcolors; i++) { - if (mindist[i] <= minmaxdist) - colorlist[ncolors++] = (JSAMPLE) i; - } - return ncolors; -} - - -LOCAL(void) -find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, - int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[]) -/* Find the closest colormap entry for each cell in the update box, - * given the list of candidate colors prepared by find_nearby_colors. - * Return the indexes of the closest entries in the bestcolor[] array. - * This routine uses Thomas' incremental distance calculation method to - * find the distance from a colormap entry to successive cells in the box. - */ -{ - int ic0, ic1, ic2; - int i, icolor; - register INT32 * bptr; /* pointer into bestdist[] array */ - JSAMPLE * cptr; /* pointer into bestcolor[] array */ - INT32 dist0, dist1; /* initial distance values */ - register INT32 dist2; /* current distance in inner loop */ - INT32 xx0, xx1; /* distance increments */ - register INT32 xx2; - INT32 inc0, inc1, inc2; /* initial values for increments */ - /* This array holds the distance to the nearest-so-far color for each cell */ - INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; - - /* Initialize best-distance for each cell of the update box */ - bptr = bestdist; - for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) - *bptr++ = 0x7FFFFFFFL; - - /* For each color selected by find_nearby_colors, - * compute its distance to the center of each cell in the box. - * If that's less than best-so-far, update best distance and color number. - */ - - /* Nominal steps between cell centers ("x" in Thomas article) */ -#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) -#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) -#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) - - for (i = 0; i < numcolors; i++) { - icolor = GETJSAMPLE(colorlist[i]); - /* Compute (square of) distance from minc0/c1/c2 to this color */ - inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE; - dist0 = inc0*inc0; - inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE; - dist0 += inc1*inc1; - inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE; - dist0 += inc2*inc2; - /* Form the initial difference increments */ - inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0; - inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1; - inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2; - /* Now loop over all cells in box, updating distance per Thomas method */ - bptr = bestdist; - cptr = bestcolor; - xx0 = inc0; - for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) { - dist1 = dist0; - xx1 = inc1; - for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) { - dist2 = dist1; - xx2 = inc2; - for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) { - if (dist2 < *bptr) { - *bptr = dist2; - *cptr = (JSAMPLE) icolor; - } - dist2 += xx2; - xx2 += 2 * STEP_C2 * STEP_C2; - bptr++; - cptr++; - } - dist1 += xx1; - xx1 += 2 * STEP_C1 * STEP_C1; - } - dist0 += xx0; - xx0 += 2 * STEP_C0 * STEP_C0; - } - } -} - - -LOCAL(void) -fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2) -/* Fill the inverse-colormap entries in the update box that contains */ -/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ -/* we can fill as many others as we wish.) */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - int minc0, minc1, minc2; /* lower left corner of update box */ - int ic0, ic1, ic2; - register JSAMPLE * cptr; /* pointer into bestcolor[] array */ - register histptr cachep; /* pointer into main cache array */ - /* This array lists the candidate colormap indexes. */ - JSAMPLE colorlist[MAXNUMCOLORS]; - int numcolors; /* number of candidate colors */ - /* This array holds the actually closest colormap index for each cell. */ - JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; - - /* Convert cell coordinates to update box ID */ - c0 >>= BOX_C0_LOG; - c1 >>= BOX_C1_LOG; - c2 >>= BOX_C2_LOG; - - /* Compute true coordinates of update box's origin corner. - * Actually we compute the coordinates of the center of the corner - * histogram cell, which are the lower bounds of the volume we care about. - */ - minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); - minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); - minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); - - /* Determine which colormap entries are close enough to be candidates - * for the nearest entry to some cell in the update box. - */ - numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist); - - /* Determine the actually nearest colors. */ - find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist, - bestcolor); - - /* Save the best color numbers (plus 1) in the main cache array */ - c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ - c1 <<= BOX_C1_LOG; - c2 <<= BOX_C2_LOG; - cptr = bestcolor; - for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) { - for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) { - cachep = & histogram[c0+ic0][c1+ic1][c2]; - for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) { - *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1); - } - } - } -} - - -/* - * Map some rows of pixels to the output colormapped representation. - */ - -METHODDEF(void) -pass2_no_dither (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) -/* This version performs no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - register JSAMPROW inptr, outptr; - register histptr cachep; - register int c0, c1, c2; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - inptr = input_buf[row]; - outptr = output_buf[row]; - for (col = width; col > 0; col--) { - /* get pixel value and index into the cache */ - c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT; - c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT; - c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT; - cachep = & histogram[c0][c1][c2]; - /* If we have not seen this color before, find nearest colormap entry */ - /* and update the cache */ - if (*cachep == 0) - fill_inverse_cmap(cinfo, c0,c1,c2); - /* Now emit the colormap index for this cell */ - *outptr++ = (JSAMPLE) (*cachep - 1); - } - } -} - - -METHODDEF(void) -pass2_fs_dither (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) -/* This version performs Floyd-Steinberg dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ - LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ - LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ - register FSERRPTR errorptr; /* => fserrors[] at column before current */ - JSAMPROW inptr; /* => current input pixel */ - JSAMPROW outptr; /* => current output pixel */ - histptr cachep; - int dir; /* +1 or -1 depending on direction */ - int dir3; /* 3*dir, for advancing inptr & errorptr */ - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - JSAMPLE *range_limit = cinfo->sample_range_limit; - int *error_limit = cquantize->error_limiter; - JSAMPROW colormap0 = cinfo->colormap[0]; - JSAMPROW colormap1 = cinfo->colormap[1]; - JSAMPROW colormap2 = cinfo->colormap[2]; - SHIFT_TEMPS - - for (row = 0; row < num_rows; row++) { - inptr = input_buf[row]; - outptr = output_buf[row]; - if (cquantize->on_odd_row) { - /* work right to left in this row */ - inptr += (width-1) * 3; /* so point to rightmost pixel */ - outptr += width-1; - dir = -1; - dir3 = -3; - errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */ - cquantize->on_odd_row = FALSE; /* flip for next time */ - } else { - /* work left to right in this row */ - dir = 1; - dir3 = 3; - errorptr = cquantize->fserrors; /* => entry before first real column */ - cquantize->on_odd_row = TRUE; /* flip for next time */ - } - /* Preset error values: no error propagated to first pixel from left */ - cur0 = cur1 = cur2 = 0; - /* and no error propagated to row below yet */ - belowerr0 = belowerr1 = belowerr2 = 0; - bpreverr0 = bpreverr1 = bpreverr2 = 0; - - for (col = width; col > 0; col--) { - /* curN holds the error propagated from the previous pixel on the - * current line. Add the error propagated from the previous line - * to form the complete error correction term for this pixel, and - * round the error term (which is expressed * 16) to an integer. - * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct - * for either sign of the error value. - * Note: errorptr points to *previous* column's array entry. - */ - cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4); - cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4); - cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4); - /* Limit the error using transfer function set by init_error_limit. - * See comments with init_error_limit for rationale. - */ - cur0 = error_limit[cur0]; - cur1 = error_limit[cur1]; - cur2 = error_limit[cur2]; - /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. - * The maximum error is +- MAXJSAMPLE (or less with error limiting); - * this sets the required size of the range_limit array. - */ - cur0 += GETJSAMPLE(inptr[0]); - cur1 += GETJSAMPLE(inptr[1]); - cur2 += GETJSAMPLE(inptr[2]); - cur0 = GETJSAMPLE(range_limit[cur0]); - cur1 = GETJSAMPLE(range_limit[cur1]); - cur2 = GETJSAMPLE(range_limit[cur2]); - /* Index into the cache with adjusted pixel value */ - cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT]; - /* If we have not seen this color before, find nearest colormap */ - /* entry and update the cache */ - if (*cachep == 0) - fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); - /* Now emit the colormap index for this cell */ - { register int pixcode = *cachep - 1; - *outptr = (JSAMPLE) pixcode; - /* Compute representation error for this pixel */ - cur0 -= GETJSAMPLE(colormap0[pixcode]); - cur1 -= GETJSAMPLE(colormap1[pixcode]); - cur2 -= GETJSAMPLE(colormap2[pixcode]); - } - /* Compute error fractions to be propagated to adjacent pixels. - * Add these into the running sums, and simultaneously shift the - * next-line error sums left by 1 column. - */ - { register LOCFSERROR bnexterr, delta; - - bnexterr = cur0; /* Process component 0 */ - delta = cur0 * 2; - cur0 += delta; /* form error * 3 */ - errorptr[0] = (FSERROR) (bpreverr0 + cur0); - cur0 += delta; /* form error * 5 */ - bpreverr0 = belowerr0 + cur0; - belowerr0 = bnexterr; - cur0 += delta; /* form error * 7 */ - bnexterr = cur1; /* Process component 1 */ - delta = cur1 * 2; - cur1 += delta; /* form error * 3 */ - errorptr[1] = (FSERROR) (bpreverr1 + cur1); - cur1 += delta; /* form error * 5 */ - bpreverr1 = belowerr1 + cur1; - belowerr1 = bnexterr; - cur1 += delta; /* form error * 7 */ - bnexterr = cur2; /* Process component 2 */ - delta = cur2 * 2; - cur2 += delta; /* form error * 3 */ - errorptr[2] = (FSERROR) (bpreverr2 + cur2); - cur2 += delta; /* form error * 5 */ - bpreverr2 = belowerr2 + cur2; - belowerr2 = bnexterr; - cur2 += delta; /* form error * 7 */ - } - /* At this point curN contains the 7/16 error value to be propagated - * to the next pixel on the current line, and all the errors for the - * next line have been shifted over. We are therefore ready to move on. - */ - inptr += dir3; /* Advance pixel pointers to next column */ - outptr += dir; - errorptr += dir3; /* advance errorptr to current column */ - } - /* Post-loop cleanup: we must unload the final error values into the - * final fserrors[] entry. Note we need not unload belowerrN because - * it is for the dummy column before or after the actual array. - */ - errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */ - errorptr[1] = (FSERROR) bpreverr1; - errorptr[2] = (FSERROR) bpreverr2; - } -} - - -/* - * Initialize the error-limiting transfer function (lookup table). - * The raw F-S error computation can potentially compute error values of up to - * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be - * much less, otherwise obviously wrong pixels will be created. (Typical - * effects include weird fringes at color-area boundaries, isolated bright - * pixels in a dark area, etc.) The standard advice for avoiding this problem - * is to ensure that the "corners" of the color cube are allocated as output - * colors; then repeated errors in the same direction cannot cause cascading - * error buildup. However, that only prevents the error from getting - * completely out of hand; Aaron Giles reports that error limiting improves - * the results even with corner colors allocated. - * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty - * well, but the smoother transfer function used below is even better. Thanks - * to Aaron Giles for this idea. - */ - -LOCAL(void) -init_error_limit (j_decompress_ptr cinfo) -/* Allocate and fill in the error_limiter table */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - int * table; - int in, out; - - table = (int *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int)); - table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ - cquantize->error_limiter = table; - -#define STEPSIZE ((MAXJSAMPLE+1)/16) - /* Map errors 1:1 up to +- MAXJSAMPLE/16 */ - out = 0; - for (in = 0; in < STEPSIZE; in++, out++) { - table[in] = out; table[-in] = -out; - } - /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */ - for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) { - table[in] = out; table[-in] = -out; - } - /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */ - for (; in <= MAXJSAMPLE; in++) { - table[in] = out; table[-in] = -out; - } -#undef STEPSIZE -} - - -/* - * Finish up at the end of each pass. - */ - -METHODDEF(void) -finish_pass1 (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - - /* Select the representative colors and fill in cinfo->colormap */ - cinfo->colormap = cquantize->sv_colormap; - select_colors(cinfo, cquantize->desired); - /* Force next pass to zero the color index table */ - cquantize->needs_zeroed = TRUE; -} - - -METHODDEF(void) -finish_pass2 (j_decompress_ptr cinfo) -{ - /* no work */ -} - - -/* - * Initialize for each processing pass. - */ - -METHODDEF(void) -start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - int i; - - /* Only F-S dithering or no dithering is supported. */ - /* If user asks for ordered dither, give him F-S. */ - if (cinfo->dither_mode != JDITHER_NONE) - cinfo->dither_mode = JDITHER_FS; - - if (is_pre_scan) { - /* Set up method pointers */ - cquantize->pub.color_quantize = prescan_quantize; - cquantize->pub.finish_pass = finish_pass1; - cquantize->needs_zeroed = TRUE; /* Always zero histogram */ - } else { - /* Set up method pointers */ - if (cinfo->dither_mode == JDITHER_FS) - cquantize->pub.color_quantize = pass2_fs_dither; - else - cquantize->pub.color_quantize = pass2_no_dither; - cquantize->pub.finish_pass = finish_pass2; - - /* Make sure color count is acceptable */ - i = cinfo->actual_number_of_colors; - if (i < 1) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 1); - if (i > MAXNUMCOLORS) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); - - if (cinfo->dither_mode == JDITHER_FS) { - size_t arraysize = (size_t) ((cinfo->output_width + 2) * - (3 * SIZEOF(FSERROR))); - /* Allocate Floyd-Steinberg workspace if we didn't already. */ - if (cquantize->fserrors == NULL) - cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); - /* Initialize the propagated errors to zero. */ - jzero_far((void FAR *) cquantize->fserrors, arraysize); - /* Make the error-limit table if we didn't already. */ - if (cquantize->error_limiter == NULL) - init_error_limit(cinfo); - cquantize->on_odd_row = FALSE; - } - - } - /* Zero the histogram or inverse color map, if necessary */ - if (cquantize->needs_zeroed) { - for (i = 0; i < HIST_C0_ELEMS; i++) { - jzero_far((void FAR *) histogram[i], - HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); - } - cquantize->needs_zeroed = FALSE; - } -} - - -/* - * Switch to a new external colormap between output passes. - */ - -METHODDEF(void) -new_color_map_2_quant (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - - /* Reset the inverse color map */ - cquantize->needs_zeroed = TRUE; -} - - -/* - * Module initialization routine for 2-pass color quantization. - */ - -GLOBAL(void) -jinit_2pass_quantizer (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize; - int i; - - cquantize = (my_cquantize_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_cquantizer)); - cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; - cquantize->pub.start_pass = start_pass_2_quant; - cquantize->pub.new_color_map = new_color_map_2_quant; - cquantize->fserrors = NULL; /* flag optional arrays not allocated */ - cquantize->error_limiter = NULL; - - /* Make sure jdmaster didn't give me a case I can't handle */ - if (cinfo->out_color_components != 3) - ERREXIT(cinfo, JERR_NOTIMPL); - - /* Allocate the histogram/inverse colormap storage */ - cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d)); - for (i = 0; i < HIST_C0_ELEMS; i++) { - cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); - } - cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ - - /* Allocate storage for the completed colormap, if required. - * We do this now since it is FAR storage and may affect - * the memory manager's space calculations. - */ - if (cinfo->enable_2pass_quant) { - /* Make sure color count is acceptable */ - int desired = cinfo->desired_number_of_colors; - /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */ - if (desired < 8) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8); - /* Make sure colormap indexes can be represented by JSAMPLEs */ - if (desired > MAXNUMCOLORS) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); - cquantize->sv_colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3); - cquantize->desired = desired; - } else - cquantize->sv_colormap = NULL; - - /* Only F-S dithering or no dithering is supported. */ - /* If user asks for ordered dither, give him F-S. */ - if (cinfo->dither_mode != JDITHER_NONE) - cinfo->dither_mode = JDITHER_FS; - - /* Allocate Floyd-Steinberg workspace if necessary. - * This isn't really needed until pass 2, but again it is FAR storage. - * Although we will cope with a later change in dither_mode, - * we do not promise to honor max_memory_to_use if dither_mode changes. - */ - if (cinfo->dither_mode == JDITHER_FS) { - cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR)))); - /* Might as well create the error-limiting table too. */ - init_error_limit(cinfo); - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/jutils.c b/freeimage241/Source/LibJPEG/jutils.c deleted file mode 100644 index d18a955..0000000 --- a/freeimage241/Source/LibJPEG/jutils.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * jutils.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains tables and miscellaneous utility routines needed - * for both compression and decompression. - * Note we prefix all global names with "j" to minimize conflicts with - * a surrounding application. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element - * of a DCT block read in natural order (left to right, top to bottom). - */ - -#if 0 /* This table is not actually needed in v6a */ - -const int jpeg_zigzag_order[DCTSIZE2] = { - 0, 1, 5, 6, 14, 15, 27, 28, - 2, 4, 7, 13, 16, 26, 29, 42, - 3, 8, 12, 17, 25, 30, 41, 43, - 9, 11, 18, 24, 31, 40, 44, 53, - 10, 19, 23, 32, 39, 45, 52, 54, - 20, 22, 33, 38, 46, 51, 55, 60, - 21, 34, 37, 47, 50, 56, 59, 61, - 35, 36, 48, 49, 57, 58, 62, 63 -}; - -#endif - -/* - * jpeg_natural_order[i] is the natural-order position of the i'th element - * of zigzag order. - * - * When reading corrupted data, the Huffman decoders could attempt - * to reference an entry beyond the end of this array (if the decoded - * zero run length reaches past the end of the block). To prevent - * wild stores without adding an inner-loop test, we put some extra - * "63"s after the real entries. This will cause the extra coefficient - * to be stored in location 63 of the block, not somewhere random. - * The worst case would be a run-length of 15, which means we need 16 - * fake entries. - */ - -const int jpeg_natural_order[DCTSIZE2+16] = { - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ - 63, 63, 63, 63, 63, 63, 63, 63 -}; - - -/* - * Arithmetic utilities - */ - -GLOBAL(long) -jdiv_round_up (long a, long b) -/* Compute a/b rounded up to next integer, ie, ceil(a/b) */ -/* Assumes a >= 0, b > 0 */ -{ - return (a + b - 1L) / b; -} - - -GLOBAL(long) -jround_up (long a, long b) -/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ -/* Assumes a >= 0, b > 0 */ -{ - a += b - 1L; - return a - (a % b); -} - - -/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays - * and coefficient-block arrays. This won't work on 80x86 because the arrays - * are FAR and we're assuming a small-pointer memory model. However, some - * DOS compilers provide far-pointer versions of memcpy() and memset() even - * in the small-model libraries. These will be used if USE_FMEM is defined. - * Otherwise, the routines below do it the hard way. (The performance cost - * is not all that great, because these routines aren't very heavily used.) - */ - -#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */ -#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) -#define FMEMZERO(target,size) MEMZERO(target,size) -#else /* 80x86 case, define if we can */ -#ifdef USE_FMEM -#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) -#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) -#endif -#endif - - -GLOBAL(void) -jcopy_sample_rows (JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols) -/* Copy some rows of samples from one place to another. - * num_rows rows are copied from input_array[source_row++] - * to output_array[dest_row++]; these areas may overlap for duplication. - * The source and destination arrays must be at least as wide as num_cols. - */ -{ - register JSAMPROW inptr, outptr; -#ifdef FMEMCOPY - register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); -#else - register JDIMENSION count; -#endif - register int row; - - input_array += source_row; - output_array += dest_row; - - for (row = num_rows; row > 0; row--) { - inptr = *input_array++; - outptr = *output_array++; -#ifdef FMEMCOPY - FMEMCOPY(outptr, inptr, count); -#else - for (count = num_cols; count > 0; count--) - *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ -#endif - } -} - - -GLOBAL(void) -jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks) -/* Copy a row of coefficient blocks from one place to another. */ -{ -#ifdef FMEMCOPY - FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); -#else - register JCOEFPTR inptr, outptr; - register long count; - - inptr = (JCOEFPTR) input_row; - outptr = (JCOEFPTR) output_row; - for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { - *outptr++ = *inptr++; - } -#endif -} - - -GLOBAL(void) -jzero_far (void FAR * target, size_t bytestozero) -/* Zero out a chunk of FAR memory. */ -/* This might be sample-array data, block-array data, or alloc_large data. */ -{ -#ifdef FMEMZERO - FMEMZERO(target, bytestozero); -#else - register char FAR * ptr = (char FAR *) target; - register size_t count; - - for (count = bytestozero; count > 0; count--) { - *ptr++ = 0; - } -#endif -} diff --git a/freeimage241/Source/LibJPEG/jversion.h b/freeimage241/Source/LibJPEG/jversion.h deleted file mode 100644 index 6472c58..0000000 --- a/freeimage241/Source/LibJPEG/jversion.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * jversion.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains software version identification. - */ - - -#define JVERSION "6b 27-Mar-1998" - -#define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" diff --git a/freeimage241/Source/LibJPEG/mssccprj.scc b/freeimage241/Source/LibJPEG/mssccprj.scc deleted file mode 100644 index 81e63d9..0000000 --- a/freeimage241/Source/LibJPEG/mssccprj.scc +++ /dev/null @@ -1,5 +0,0 @@ -SCC = This is a Source Code Control file - -[LibJPEG.dsp] -SCC_Aux_Path = "\\ASIMOV\Magenta\SourceSafe" -SCC_Project_Name = "$/FreeImage/LibJPEG", IHAAAAAA diff --git a/freeimage241/Source/LibJPEG/rdbmp.c b/freeimage241/Source/LibJPEG/rdbmp.c deleted file mode 100644 index b05fe2a..0000000 --- a/freeimage241/Source/LibJPEG/rdbmp.c +++ /dev/null @@ -1,439 +0,0 @@ -/* - * rdbmp.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Microsoft "BMP" - * format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors). - * Currently, only 8-bit and 24-bit images are supported, not 1-bit or - * 4-bit (feeding such low-depth images into JPEG would be silly anyway). - * Also, we don't support RLE-compressed files. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed BMP format). - * - * This code contributed by James Arthur Boucher. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef BMP_SUPPORTED - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char U_CHAR; -#define UCH(x) ((int) (x)) -#else -typedef char U_CHAR; -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* Private version of data source object */ - -typedef struct _bmp_source_struct * bmp_source_ptr; - -typedef struct _bmp_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - j_compress_ptr cinfo; /* back link saves passing separate parm */ - - JSAMPARRAY colormap; /* BMP colormap (converted to my format) */ - - jvirt_sarray_ptr whole_image; /* Needed to reverse row order */ - JDIMENSION source_row; /* Current source row number */ - JDIMENSION row_width; /* Physical width of scanlines in file */ - - int bits_per_pixel; /* remembers 8- or 24-bit format */ -} bmp_source_struct; - - -LOCAL(int) -read_byte (bmp_source_ptr sinfo) -/* Read next byte from BMP file */ -{ - register FILE *infile = sinfo->pub.input_file; - register int c; - - if ((c = getc(infile)) == EOF) - ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); - return c; -} - - -LOCAL(void) -read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize) -/* Read the colormap from a BMP file */ -{ - int i; - - switch (mapentrysize) { - case 3: - /* BGR format (occurs in OS/2 files) */ - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - } - break; - case 4: - /* BGR0 format (occurs in MS Windows files) */ - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - (void) read_byte(sinfo); - } - break; - default: - ERREXIT(sinfo->cinfo, JERR_BMP_BADCMAP); - break; - } -} - - -/* - * Read one row of pixels. - * The image has been read into the whole_image array, but is otherwise - * unprocessed. We must read it out in top-to-bottom row order, and if - * it is an 8-bit image, we must expand colormapped pixels to 24bit format. - */ - -METHODDEF(JDIMENSION) -get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit colormap indexes */ -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - register JSAMPARRAY colormap = source->colormap; - JSAMPARRAY image_ptr; - register int t; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - - /* Fetch next row from virtual array */ - source->source_row--; - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - source->source_row, (JDIMENSION) 1, FALSE); - - /* Expand the colormap indexes to real data */ - inptr = image_ptr[0]; - outptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - t = GETJSAMPLE(*inptr++); - *outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */ - *outptr++ = colormap[1][t]; - *outptr++ = colormap[2][t]; - } - - return 1; -} - - -METHODDEF(JDIMENSION) -get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 24-bit pixels */ -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - JSAMPARRAY image_ptr; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - - /* Fetch next row from virtual array */ - source->source_row--; - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - source->source_row, (JDIMENSION) 1, FALSE); - - /* Transfer data. Note source values are in BGR order - * (even though Microsoft's own documents say the opposite). - */ - inptr = image_ptr[0]; - outptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ - outptr[1] = *inptr++; - outptr[0] = *inptr++; - outptr += 3; - } - - return 1; -} - - -/* - * This method loads the image into whole_image during the first call on - * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call - * get_8bit_row or get_24bit_row on subsequent calls. - */ - -METHODDEF(JDIMENSION) -preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - register FILE *infile = source->pub.input_file; - register int c; - register JSAMPROW out_ptr; - JSAMPARRAY image_ptr; - JDIMENSION row, col; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Read the data into a virtual array in input-file row order. */ - for (row = 0; row < cinfo->image_height; row++) { - if (progress != NULL) { - progress->pub.pass_counter = (long) row; - progress->pub.pass_limit = (long) cinfo->image_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - row, (JDIMENSION) 1, TRUE); - out_ptr = image_ptr[0]; - for (col = source->row_width; col > 0; col--) { - /* inline copy of read_byte() for speed */ - if ((c = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_INPUT_EOF); - *out_ptr++ = (JSAMPLE) c; - } - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Set up to read from the virtual array in top-to-bottom order */ - switch (source->bits_per_pixel) { - case 8: - source->pub.get_pixel_rows = get_8bit_row; - break; - case 24: - source->pub.get_pixel_rows = get_24bit_row; - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - } - source->source_row = cinfo->image_height; - - /* And read the first row */ - return (*source->pub.get_pixel_rows) (cinfo, sinfo); -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - U_CHAR bmpfileheader[14]; - U_CHAR bmpinfoheader[64]; -#define GET_2B(array,offset) ((unsigned int) UCH(array[offset]) + \ - (((unsigned int) UCH(array[offset+1])) << 8)) -#define GET_4B(array,offset) ((INT32) UCH(array[offset]) + \ - (((INT32) UCH(array[offset+1])) << 8) + \ - (((INT32) UCH(array[offset+2])) << 16) + \ - (((INT32) UCH(array[offset+3])) << 24)) - INT32 bfOffBits; - INT32 headerSize; - INT32 biWidth = 0; /* initialize to avoid compiler warning */ - INT32 biHeight = 0; - unsigned int biPlanes; - INT32 biCompression; - INT32 biXPelsPerMeter,biYPelsPerMeter; - INT32 biClrUsed = 0; - int mapentrysize = 0; /* 0 indicates no colormap */ - INT32 bPad; - JDIMENSION row_width; - - /* Read and verify the bitmap file header */ - if (! ReadOK(source->pub.input_file, bmpfileheader, 14)) - ERREXIT(cinfo, JERR_INPUT_EOF); - if (GET_2B(bmpfileheader,0) != 0x4D42) /* 'BM' */ - ERREXIT(cinfo, JERR_BMP_NOT); - bfOffBits = (INT32) GET_4B(bmpfileheader,10); - /* We ignore the remaining fileheader fields */ - - /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows), - * or 64 bytes (OS/2 2.x). Check the first 4 bytes to find out which. - */ - if (! ReadOK(source->pub.input_file, bmpinfoheader, 4)) - ERREXIT(cinfo, JERR_INPUT_EOF); - headerSize = (INT32) GET_4B(bmpinfoheader,0); - if (headerSize < 12 || headerSize > 64) - ERREXIT(cinfo, JERR_BMP_BADHEADER); - if (! ReadOK(source->pub.input_file, bmpinfoheader+4, headerSize-4)) - ERREXIT(cinfo, JERR_INPUT_EOF); - - switch ((int) headerSize) { - case 12: - /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */ - biWidth = (INT32) GET_2B(bmpinfoheader,4); - biHeight = (INT32) GET_2B(bmpinfoheader,6); - biPlanes = GET_2B(bmpinfoheader,8); - source->bits_per_pixel = (int) GET_2B(bmpinfoheader,10); - - switch (source->bits_per_pixel) { - case 8: /* colormapped image */ - mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */ - TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight); - break; - case 24: /* RGB image */ - TRACEMS2(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight); - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - break; - } - if (biPlanes != 1) - ERREXIT(cinfo, JERR_BMP_BADPLANES); - break; - case 40: - case 64: - /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */ - /* or OS/2 2.x header, which has additional fields that we ignore */ - biWidth = GET_4B(bmpinfoheader,4); - biHeight = GET_4B(bmpinfoheader,8); - biPlanes = GET_2B(bmpinfoheader,12); - source->bits_per_pixel = (int) GET_2B(bmpinfoheader,14); - biCompression = GET_4B(bmpinfoheader,16); - biXPelsPerMeter = GET_4B(bmpinfoheader,24); - biYPelsPerMeter = GET_4B(bmpinfoheader,28); - biClrUsed = GET_4B(bmpinfoheader,32); - /* biSizeImage, biClrImportant fields are ignored */ - - switch (source->bits_per_pixel) { - case 8: /* colormapped image */ - mapentrysize = 4; /* Windows uses RGBQUAD colormap */ - TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (int) biWidth, (int) biHeight); - break; - case 24: /* RGB image */ - TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight); - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - break; - } - if (biPlanes != 1) - ERREXIT(cinfo, JERR_BMP_BADPLANES); - if (biCompression != 0) - ERREXIT(cinfo, JERR_BMP_COMPRESSED); - - if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) { - /* Set JFIF density parameters from the BMP data */ - cinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */ - cinfo->Y_density = (UINT16) (biYPelsPerMeter/100); - cinfo->density_unit = 2; /* dots/cm */ - } - break; - default: - ERREXIT(cinfo, JERR_BMP_BADHEADER); - break; - } - - /* Compute distance to bitmap data --- will adjust for colormap below */ - bPad = bfOffBits - (headerSize + 14); - - /* Read the colormap, if any */ - if (mapentrysize > 0) { - if (biClrUsed <= 0) - biClrUsed = 256; /* assume it's 256 */ - else if (biClrUsed > 256) - ERREXIT(cinfo, JERR_BMP_BADCMAP); - /* Allocate space to store the colormap */ - source->colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) biClrUsed, (JDIMENSION) 3); - /* and read it from the file */ - read_colormap(source, (int) biClrUsed, mapentrysize); - /* account for size of colormap */ - bPad -= biClrUsed * mapentrysize; - } - - /* Skip any remaining pad bytes */ - if (bPad < 0) /* incorrect bfOffBits value? */ - ERREXIT(cinfo, JERR_BMP_BADHEADER); - while (--bPad >= 0) { - (void) read_byte(source); - } - - /* Compute row width in file, including padding to 4-byte boundary */ - if (source->bits_per_pixel == 24) - row_width = (JDIMENSION) (biWidth * 3); - else - row_width = (JDIMENSION) biWidth; - while ((row_width & 3) != 0) row_width++; - source->row_width = row_width; - - /* Allocate space for inversion array, prepare for preload pass */ - source->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - row_width, (JDIMENSION) biHeight, (JDIMENSION) 1); - source->pub.get_pixel_rows = preload_image; - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - - /* Allocate one-row buffer for returned data */ - source->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (biWidth * 3), (JDIMENSION) 1); - source->pub.buffer_height = 1; - - cinfo->in_color_space = JCS_RGB; - cinfo->input_components = 3; - cinfo->data_precision = 8; - cinfo->image_width = (JDIMENSION) biWidth; - cinfo->image_height = (JDIMENSION) biHeight; -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for BMP format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_bmp (j_compress_ptr cinfo) -{ - bmp_source_ptr source; - - /* Create module interface object */ - source = (bmp_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(bmp_source_struct)); - source->cinfo = cinfo; /* make back link for subroutines */ - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_bmp; - source->pub.finish_input = finish_input_bmp; - - return (cjpeg_source_ptr) source; -} - -#endif /* BMP_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/rdcolmap.c b/freeimage241/Source/LibJPEG/rdcolmap.c deleted file mode 100644 index 42b3437..0000000 --- a/freeimage241/Source/LibJPEG/rdcolmap.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * rdcolmap.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file implements djpeg's "-map file" switch. It reads a source image - * and constructs a colormap to be supplied to the JPEG decompressor. - * - * Currently, these file formats are supported for the map file: - * GIF: the contents of the GIF's global colormap are used. - * PPM (either text or raw flavor): the entire file is read and - * each unique pixel value is entered in the map. - * Note that reading a large PPM file will be horrendously slow. - * Typically, a PPM-format map file should contain just one pixel - * of each desired color. Such a file can be extracted from an - * ordinary image PPM file with ppmtomap(1). - * - * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not - * currently implemented. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ - -/* Portions of this code are based on the PBMPLUS library, which is: -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose and without fee is hereby granted, provided -** that the above copyright notice appear in all copies and that both that -** copyright notice and this permission notice appear in supporting -** documentation. This software is provided "as is" without express or -** implied warranty. -*/ - - -/* - * Add a (potentially) new color to the color map. - */ - -LOCAL(void) -add_map_entry (j_decompress_ptr cinfo, int R, int G, int B) -{ - JSAMPROW colormap0 = cinfo->colormap[0]; - JSAMPROW colormap1 = cinfo->colormap[1]; - JSAMPROW colormap2 = cinfo->colormap[2]; - int ncolors = cinfo->actual_number_of_colors; - int index; - - /* Check for duplicate color. */ - for (index = 0; index < ncolors; index++) { - if (GETJSAMPLE(colormap0[index]) == R && - GETJSAMPLE(colormap1[index]) == G && - GETJSAMPLE(colormap2[index]) == B) - return; /* color is already in map */ - } - - /* Check for map overflow. */ - if (ncolors >= (MAXJSAMPLE+1)) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE+1)); - - /* OK, add color to map. */ - colormap0[ncolors] = (JSAMPLE) R; - colormap1[ncolors] = (JSAMPLE) G; - colormap2[ncolors] = (JSAMPLE) B; - cinfo->actual_number_of_colors++; -} - - -/* - * Extract color map from a GIF file. - */ - -LOCAL(void) -read_gif_map (j_decompress_ptr cinfo, FILE * infile) -{ - int header[13]; - int i, colormaplen; - int R, G, B; - - /* Initial 'G' has already been read by read_color_map */ - /* Read the rest of the GIF header and logical screen descriptor */ - for (i = 1; i < 13; i++) { - if ((header[i] = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - } - - /* Verify GIF Header */ - if (header[1] != 'I' || header[2] != 'F') - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* There must be a global color map. */ - if ((header[10] & 0x80) == 0) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* OK, fetch it. */ - colormaplen = 2 << (header[10] & 0x07); - - for (i = 0; i < colormaplen; i++) { - R = getc(infile); - G = getc(infile); - B = getc(infile); - if (R == EOF || G == EOF || B == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - add_map_entry(cinfo, - R << (BITS_IN_JSAMPLE-8), - G << (BITS_IN_JSAMPLE-8), - B << (BITS_IN_JSAMPLE-8)); - } -} - - -/* Support routines for reading PPM */ - - -LOCAL(int) -pbm_getc (FILE * infile) -/* Read next char, skipping over any comments */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(infile); - if (ch == '#') { - do { - ch = getc(infile); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(unsigned int) -read_pbm_integer (j_decompress_ptr cinfo, FILE * infile) -/* Read an unsigned decimal integer from the PPM file */ -/* Swallows one trailing character after the integer */ -/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ -/* This should not be a problem in practice. */ -{ - register int ch; - register unsigned int val; - - /* Skip any leading whitespace */ - do { - ch = pbm_getc(infile); - if (ch == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); - - if (ch < '0' || ch > '9') - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - val = ch - '0'; - while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { - val *= 10; - val += ch - '0'; - } - return val; -} - - -/* - * Extract color map from a PPM file. - */ - -LOCAL(void) -read_ppm_map (j_decompress_ptr cinfo, FILE * infile) -{ - int c; - unsigned int w, h, maxval, row, col; - int R, G, B; - - /* Initial 'P' has already been read by read_color_map */ - c = getc(infile); /* save format discriminator for a sec */ - - /* while we fetch the remaining header info */ - w = read_pbm_integer(cinfo, infile); - h = read_pbm_integer(cinfo, infile); - maxval = read_pbm_integer(cinfo, infile); - - if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* For now, we don't support rescaling from an unusual maxval. */ - if (maxval != (unsigned int) MAXJSAMPLE) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - switch (c) { - case '3': /* it's a text-format PPM file */ - for (row = 0; row < h; row++) { - for (col = 0; col < w; col++) { - R = read_pbm_integer(cinfo, infile); - G = read_pbm_integer(cinfo, infile); - B = read_pbm_integer(cinfo, infile); - add_map_entry(cinfo, R, G, B); - } - } - break; - - case '6': /* it's a raw-format PPM file */ - for (row = 0; row < h; row++) { - for (col = 0; col < w; col++) { - R = getc(infile); - G = getc(infile); - B = getc(infile); - if (R == EOF || G == EOF || B == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - add_map_entry(cinfo, R, G, B); - } - } - break; - - default: - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - break; - } -} - - -/* - * Main entry point from djpeg.c. - * Input: opened input file (from file name argument on command line). - * Output: colormap and actual_number_of_colors fields are set in cinfo. - */ - -GLOBAL(void) -read_color_map (j_decompress_ptr cinfo, FILE * infile) -{ - /* Allocate space for a color map of maximum supported size. */ - cinfo->colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (MAXJSAMPLE+1), (JDIMENSION) 3); - cinfo->actual_number_of_colors = 0; /* initialize map to empty */ - - /* Read first byte to determine file format */ - switch (getc(infile)) { - case 'G': - read_gif_map(cinfo, infile); - break; - case 'P': - read_ppm_map(cinfo, infile); - break; - default: - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - break; - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/rdgif.c b/freeimage241/Source/LibJPEG/rdgif.c deleted file mode 100644 index b27c167..0000000 --- a/freeimage241/Source/LibJPEG/rdgif.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * rdgif.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in GIF format. - * - ***************************************************************************** - * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * - * the ability to read GIF files has been removed from the IJG distribution. * - * Sorry about that. * - ***************************************************************************** - * - * We are required to state that - * "The Graphics Interchange Format(c) is the Copyright property of - * CompuServe Incorporated. GIF(sm) is a Service Mark property of - * CompuServe Incorporated." - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef GIF_SUPPORTED - -/* - * The module selection routine for GIF format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_gif (j_compress_ptr cinfo) -{ - fprintf(stderr, "GIF input is unsupported for legal reasons. Sorry.\n"); - exit(EXIT_FAILURE); - return NULL; /* keep compiler happy */ -} - -#endif /* GIF_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/rdjpgcom.c b/freeimage241/Source/LibJPEG/rdjpgcom.c deleted file mode 100644 index ffe6fc6..0000000 --- a/freeimage241/Source/LibJPEG/rdjpgcom.c +++ /dev/null @@ -1,496 +0,0 @@ -/* - * rdjpgcom.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a very simple stand-alone application that displays - * the text in COM (comment) markers in a JFIF file. - * This may be useful as an example of the minimum logic needed to parse - * JPEG markers. - */ - -#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ -#include "jinclude.h" /* get auto-config symbols, */ - -#include /* to declare isupper(), tolower() */ -#ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ -#endif - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif - - -/* - * These macros are used to read the input file. - * To reuse this code in another application, you might need to change these. - */ - -static FILE * infile; /* input JPEG file */ - -/* Return next input byte, or EOF if no more */ -#define NEXTBYTE() getc(infile) - - -/* Error exit handler */ -#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) - - -/* Read one byte, testing for EOF */ -static int -read_1_byte (void) -{ - int c; - - c = NEXTBYTE(); - if (c == EOF) - ERREXIT("Premature EOF in JPEG file"); - return c; -} - -/* Read 2 bytes, convert to unsigned int */ -/* All 2-byte quantities in JPEG markers are MSB first */ -static unsigned int -read_2_bytes (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - if (c1 == EOF) - ERREXIT("Premature EOF in JPEG file"); - c2 = NEXTBYTE(); - if (c2 == EOF) - ERREXIT("Premature EOF in JPEG file"); - return (((unsigned int) c1) << 8) + ((unsigned int) c2); -} - - -/* - * JPEG markers consist of one or more 0xFF bytes, followed by a marker - * code byte (which is not an FF). Here are the marker codes of interest - * in this program. (See jdmarker.c for a more complete list.) - */ - -#define M_SOF0 0xC0 /* Start Of Frame N */ -#define M_SOF1 0xC1 /* N indicates which compression process */ -#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ -#define M_SOF3 0xC3 -#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ -#define M_SOF6 0xC6 -#define M_SOF7 0xC7 -#define M_SOF9 0xC9 -#define M_SOF10 0xCA -#define M_SOF11 0xCB -#define M_SOF13 0xCD -#define M_SOF14 0xCE -#define M_SOF15 0xCF -#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ -#define M_EOI 0xD9 /* End Of Image (end of datastream) */ -#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ -#define M_APP0 0xE0 /* Application-specific marker, type N */ -#define M_APP12 0xEC /* (we don't bother to list all 16 APPn's) */ -#define M_COM 0xFE /* COMment */ - - -/* - * Find the next JPEG marker and return its marker code. - * We expect at least one FF byte, possibly more if the compressor used FFs - * to pad the file. - * There could also be non-FF garbage between markers. The treatment of such - * garbage is unspecified; we choose to skip over it but emit a warning msg. - * NB: this routine must not be used after seeing SOS marker, since it will - * not deal correctly with FF/00 sequences in the compressed image data... - */ - -static int -next_marker (void) -{ - int c; - int discarded_bytes = 0; - - /* Find 0xFF byte; count and skip any non-FFs. */ - c = read_1_byte(); - while (c != 0xFF) { - discarded_bytes++; - c = read_1_byte(); - } - /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs - * are legal as pad bytes, so don't count them in discarded_bytes. - */ - do { - c = read_1_byte(); - } while (c == 0xFF); - - if (discarded_bytes != 0) { - fprintf(stderr, "Warning: garbage data found in JPEG file\n"); - } - - return c; -} - - -/* - * Read the initial marker, which should be SOI. - * For a JFIF file, the first two bytes of the file should be literally - * 0xFF M_SOI. To be more general, we could use next_marker, but if the - * input file weren't actually JPEG at all, next_marker might read the whole - * file and then return a misleading error message... - */ - -static int -first_marker (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - c2 = NEXTBYTE(); - if (c1 != 0xFF || c2 != M_SOI) - ERREXIT("Not a JPEG file"); - return c2; -} - - -/* - * Most types of marker are followed by a variable-length parameter segment. - * This routine skips over the parameters for any marker we don't otherwise - * want to process. - * Note that we MUST skip the parameter segment explicitly in order not to - * be fooled by 0xFF bytes that might appear within the parameter segment; - * such bytes do NOT introduce new markers. - */ - -static void -skip_variable (void) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - (void) read_1_byte(); - length--; - } -} - - -/* - * Process a COM marker. - * We want to print out the marker contents as legible text; - * we must guard against non-text junk and varying newline representations. - */ - -static void -process_COM (void) -{ - unsigned int length; - int ch; - int lastch = 0; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - - while (length > 0) { - ch = read_1_byte(); - /* Emit the character in a readable form. - * Nonprintables are converted to \nnn form, - * while \ is converted to \\. - * Newlines in CR, CR/LF, or LF form will be printed as one newline. - */ - if (ch == '\r') { - printf("\n"); - } else if (ch == '\n') { - if (lastch != '\r') - printf("\n"); - } else if (ch == '\\') { - printf("\\\\"); - } else if (isprint(ch)) { - putc(ch, stdout); - } else { - printf("\\%03o", ch); - } - lastch = ch; - length--; - } - printf("\n"); -} - - -/* - * Process a SOFn marker. - * This code is only needed if you want to know the image dimensions... - */ - -static void -process_SOFn (int marker) -{ - unsigned int length; - unsigned int image_height, image_width; - int data_precision, num_components; - const char * process; - int ci; - - length = read_2_bytes(); /* usual parameter length count */ - - data_precision = read_1_byte(); - image_height = read_2_bytes(); - image_width = read_2_bytes(); - num_components = read_1_byte(); - - switch (marker) { - case M_SOF0: process = "Baseline"; break; - case M_SOF1: process = "Extended sequential"; break; - case M_SOF2: process = "Progressive"; break; - case M_SOF3: process = "Lossless"; break; - case M_SOF5: process = "Differential sequential"; break; - case M_SOF6: process = "Differential progressive"; break; - case M_SOF7: process = "Differential lossless"; break; - case M_SOF9: process = "Extended sequential, arithmetic coding"; break; - case M_SOF10: process = "Progressive, arithmetic coding"; break; - case M_SOF11: process = "Lossless, arithmetic coding"; break; - case M_SOF13: process = "Differential sequential, arithmetic coding"; break; - case M_SOF14: process = "Differential progressive, arithmetic coding"; break; - case M_SOF15: process = "Differential lossless, arithmetic coding"; break; - default: process = "Unknown"; break; - } - - printf("JPEG image is %uw * %uh, %d color components, %d bits per sample\n", - image_width, image_height, num_components, data_precision); - printf("JPEG process: %s\n", process); - - if (length != (unsigned int) (8 + num_components * 3)) - ERREXIT("Bogus SOF marker length"); - - for (ci = 0; ci < num_components; ci++) { - (void) read_1_byte(); /* Component ID code */ - (void) read_1_byte(); /* H, V sampling factors */ - (void) read_1_byte(); /* Quantization table number */ - } -} - - -/* - * Parse the marker stream until SOS or EOI is seen; - * display any COM markers. - * While the companion program wrjpgcom will always insert COM markers before - * SOFn, other implementations might not, so we scan to SOS before stopping. - * If we were only interested in the image dimensions, we would stop at SOFn. - * (Conversely, if we only cared about COM markers, there would be no need - * for special code to handle SOFn; we could treat it like other markers.) - */ - -static int -scan_JPEG_header (int verbose) -{ - int marker; - - /* Expect SOI at start of file */ - if (first_marker() != M_SOI) - ERREXIT("Expected SOI marker first"); - - /* Scan miscellaneous markers until we reach SOS. */ - for (;;) { - marker = next_marker(); - switch (marker) { - /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, - * treated as SOFn. C4 in particular is actually DHT. - */ - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - case M_SOF2: /* Progressive, Huffman */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_SOF9: /* Extended sequential, arithmetic */ - case M_SOF10: /* Progressive, arithmetic */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - if (verbose) - process_SOFn(marker); - else - skip_variable(); - break; - - case M_SOS: /* stop before hitting compressed data */ - return marker; - - case M_EOI: /* in case it's a tables-only JPEG stream */ - return marker; - - case M_COM: - process_COM(); - break; - - case M_APP12: - /* Some digital camera makers put useful textual information into - * APP12 markers, so we print those out too when in -verbose mode. - */ - if (verbose) { - printf("APP12 contains:\n"); - process_COM(); - } else - skip_variable(); - break; - - default: /* Anything else just gets skipped */ - skip_variable(); /* we assume it has a parameter count... */ - break; - } - } /* end loop */ -} - - -/* Command line parsing code */ - -static const char * progname; /* program name for error messages */ - - -static void -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "rdjpgcom displays any textual comments in a JPEG file.\n"); - - fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname); - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -verbose Also display dimensions of JPEG image\n"); - - exit(EXIT_FAILURE); -} - - -static int -keymatch (char * arg, const char * keyword, int minchars) -/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ -/* keyword is the constant keyword (must be lower case already), */ -/* minchars is length of minimum legal abbreviation. */ -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return 0; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return 0; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return 0; - return 1; /* A-OK */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - int argn; - char * arg; - int verbose = 0; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "rdjpgcom"; /* in case C library doesn't provide it */ - - /* Parse switches, if any */ - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (arg[0] != '-') - break; /* not switch, must be file name */ - arg++; /* advance over '-' */ - if (keymatch(arg, "verbose", 1)) { - verbose++; - } else - usage(); - } - - /* Open the input file. */ - /* Unix style: expect zero or one file name */ - if (argn < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } - if (argn < argc) { - if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdin\n", progname); - exit(EXIT_FAILURE); - } -#else - infile = stdin; -#endif - } - - /* Scan the JPEG headers. */ - (void) scan_JPEG_header(verbose); - - /* All done. */ - exit(EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/freeimage241/Source/LibJPEG/rdppm.c b/freeimage241/Source/LibJPEG/rdppm.c deleted file mode 100644 index 1df35c1..0000000 --- a/freeimage241/Source/LibJPEG/rdppm.c +++ /dev/null @@ -1,458 +0,0 @@ -/* - * rdppm.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in PPM/PGM format. - * The extended 2-byte-per-sample raw PPM/PGM formats are supported. - * The PBMPLUS library is NOT required to compile this software - * (but it is highly useful as a set of PPM image manipulation programs). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed PPM format). - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef PPM_SUPPORTED - - -/* Portions of this code are based on the PBMPLUS library, which is: -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose and without fee is hereby granted, provided -** that the above copyright notice appear in all copies and that both that -** copyright notice and this permission notice appear in supporting -** documentation. This software is provided "as is" without express or -** implied warranty. -*/ - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char U_CHAR; -#define UCH(x) ((int) (x)) -#else -typedef char U_CHAR; -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* - * On most systems, reading individual bytes with getc() is drastically less - * efficient than buffering a row at a time with fread(). On PCs, we must - * allocate the buffer in near data space, because we are assuming small-data - * memory model, wherein fread() can't reach far memory. If you need to - * process very wide images on a PC, you might have to compile in large-memory - * model, or else replace fread() with a getc() loop --- which will be much - * slower. - */ - - -/* Private version of data source object */ - -typedef struct { - struct cjpeg_source_struct pub; /* public fields */ - - U_CHAR *iobuffer; /* non-FAR pointer to I/O buffer */ - JSAMPROW pixrow; /* FAR pointer to same */ - size_t buffer_width; /* width of I/O buffer */ - JSAMPLE *rescale; /* => maxval-remapping array, or NULL */ -} ppm_source_struct; - -typedef ppm_source_struct * ppm_source_ptr; - - -LOCAL(int) -pbm_getc (FILE * infile) -/* Read next char, skipping over any comments */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(infile); - if (ch == '#') { - do { - ch = getc(infile); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(unsigned int) -read_pbm_integer (j_compress_ptr cinfo, FILE * infile) -/* Read an unsigned decimal integer from the PPM file */ -/* Swallows one trailing character after the integer */ -/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ -/* This should not be a problem in practice. */ -{ - register int ch; - register unsigned int val; - - /* Skip any leading whitespace */ - do { - ch = pbm_getc(infile); - if (ch == EOF) - ERREXIT(cinfo, JERR_INPUT_EOF); - } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); - - if (ch < '0' || ch > '9') - ERREXIT(cinfo, JERR_PPM_NONNUMERIC); - - val = ch - '0'; - while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { - val *= 10; - val += ch - '0'; - } - return val; -} - - -/* - * Read one row of pixels. - * - * We provide several different versions depending on input file format. - * In all cases, input is scaled to the size of JSAMPLE. - * - * A really fast path is provided for reading byte/sample raw files with - * maxval = MAXJSAMPLE, which is the normal case for 8-bit data. - */ - - -METHODDEF(JDIMENSION) -get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading text-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - FILE * infile = source->pub.input_file; - register JSAMPROW ptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading text-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - FILE * infile = source->pub.input_file; - register JSAMPROW ptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - *ptr++ = rescale[read_pbm_integer(cinfo, infile)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_scaled_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[UCH(*bufferptr++)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_scaled_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - *ptr++ = rescale[UCH(*bufferptr++)]; - *ptr++ = rescale[UCH(*bufferptr++)]; - *ptr++ = rescale[UCH(*bufferptr++)]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_raw_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE. - * In this case we just read right into the JSAMPLE buffer! - * Note that same code works for PPM and PGM files. - */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - return 1; -} - - -METHODDEF(JDIMENSION) -get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-word-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - register int temp; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-word-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pub.buffer[0]; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - register int temp; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - temp = UCH(*bufferptr++); - temp |= UCH(*bufferptr++) << 8; - *ptr++ = rescale[temp]; - } - return 1; -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - int c; - unsigned int w, h, maxval; - boolean need_iobuffer, use_raw_buffer, need_rescale; - - if (getc(source->pub.input_file) != 'P') - ERREXIT(cinfo, JERR_PPM_NOT); - - c = getc(source->pub.input_file); /* subformat discriminator character */ - - /* detect unsupported variants (ie, PBM) before trying to read header */ - switch (c) { - case '2': /* it's a text-format PGM file */ - case '3': /* it's a text-format PPM file */ - case '5': /* it's a raw-format PGM file */ - case '6': /* it's a raw-format PPM file */ - break; - default: - ERREXIT(cinfo, JERR_PPM_NOT); - break; - } - - /* fetch the remaining header info */ - w = read_pbm_integer(cinfo, source->pub.input_file); - h = read_pbm_integer(cinfo, source->pub.input_file); - maxval = read_pbm_integer(cinfo, source->pub.input_file); - - if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ - ERREXIT(cinfo, JERR_PPM_NOT); - - cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ - cinfo->image_width = (JDIMENSION) w; - cinfo->image_height = (JDIMENSION) h; - - /* initialize flags to most common settings */ - need_iobuffer = TRUE; /* do we need an I/O buffer? */ - use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */ - need_rescale = TRUE; /* do we need a rescale array? */ - - switch (c) { - case '2': /* it's a text-format PGM file */ - cinfo->input_components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h); - source->pub.get_pixel_rows = get_text_gray_row; - need_iobuffer = FALSE; - break; - - case '3': /* it's a text-format PPM file */ - cinfo->input_components = 3; - cinfo->in_color_space = JCS_RGB; - TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h); - source->pub.get_pixel_rows = get_text_rgb_row; - need_iobuffer = FALSE; - break; - - case '5': /* it's a raw-format PGM file */ - cinfo->input_components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_PGM, w, h); - if (maxval > 255) { - source->pub.get_pixel_rows = get_word_gray_row; - } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { - source->pub.get_pixel_rows = get_raw_row; - use_raw_buffer = TRUE; - need_rescale = FALSE; - } else { - source->pub.get_pixel_rows = get_scaled_gray_row; - } - break; - - case '6': /* it's a raw-format PPM file */ - cinfo->input_components = 3; - cinfo->in_color_space = JCS_RGB; - TRACEMS2(cinfo, 1, JTRC_PPM, w, h); - if (maxval > 255) { - source->pub.get_pixel_rows = get_word_rgb_row; - } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { - source->pub.get_pixel_rows = get_raw_row; - use_raw_buffer = TRUE; - need_rescale = FALSE; - } else { - source->pub.get_pixel_rows = get_scaled_rgb_row; - } - break; - } - - /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */ - if (need_iobuffer) { - source->buffer_width = (size_t) w * cinfo->input_components * - ((maxval<=255) ? SIZEOF(U_CHAR) : (2*SIZEOF(U_CHAR))); - source->iobuffer = (U_CHAR *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - source->buffer_width); - } - - /* Create compressor input buffer. */ - if (use_raw_buffer) { - /* For unscaled raw-input case, we can just map it onto the I/O buffer. */ - /* Synthesize a JSAMPARRAY pointer structure */ - /* Cast here implies near->far pointer conversion on PCs */ - source->pixrow = (JSAMPROW) source->iobuffer; - source->pub.buffer = & source->pixrow; - source->pub.buffer_height = 1; - } else { - /* Need to translate anyway, so make a separate sample buffer. */ - source->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) w * cinfo->input_components, (JDIMENSION) 1); - source->pub.buffer_height = 1; - } - - /* Compute the rescaling array if required. */ - if (need_rescale) { - INT32 val, half_maxval; - - /* On 16-bit-int machines we have to be careful of maxval = 65535 */ - source->rescale = (JSAMPLE *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (((long) maxval + 1L) * SIZEOF(JSAMPLE))); - half_maxval = maxval / 2; - for (val = 0; val <= (INT32) maxval; val++) { - /* The multiplication here must be done in 32 bits to avoid overflow */ - source->rescale[val] = (JSAMPLE) ((val*MAXJSAMPLE + half_maxval)/maxval); - } - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for PPM format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_ppm (j_compress_ptr cinfo) -{ - ppm_source_ptr source; - - /* Create module interface object */ - source = (ppm_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ppm_source_struct)); - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_ppm; - source->pub.finish_input = finish_input_ppm; - - return (cjpeg_source_ptr) source; -} - -#endif /* PPM_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/rdrle.c b/freeimage241/Source/LibJPEG/rdrle.c deleted file mode 100644 index 542bc37..0000000 --- a/freeimage241/Source/LibJPEG/rdrle.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * rdrle.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Utah RLE format. - * The Utah Raster Toolkit library is required (version 3.1 or later). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed RLE format). - * - * Based on code contributed by Mike Lijewski, - * with updates from Robert Hutchinson. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef RLE_SUPPORTED - -/* rle.h is provided by the Utah Raster Toolkit. */ - -#include - -/* - * We assume that JSAMPLE has the same representation as rle_pixel, - * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * We support the following types of RLE files: - * - * GRAYSCALE - 8 bits, no colormap - * MAPPEDGRAY - 8 bits, 1 channel colomap - * PSEUDOCOLOR - 8 bits, 3 channel colormap - * TRUECOLOR - 24 bits, 3 channel colormap - * DIRECTCOLOR - 24 bits, no colormap - * - * For now, we ignore any alpha channel in the image. - */ - -typedef enum - { GRAYSCALE, MAPPEDGRAY, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind; - - -/* - * Since RLE stores scanlines bottom-to-top, we have to invert the image - * to conform to JPEG's top-to-bottom order. To do this, we read the - * incoming image into a virtual array on the first get_pixel_rows call, - * then fetch the required row from the virtual array on subsequent calls. - */ - -typedef struct _rle_source_struct * rle_source_ptr; - -typedef struct _rle_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - rle_kind visual; /* actual type of input file */ - jvirt_sarray_ptr image; /* virtual array to hold the image */ - JDIMENSION row; /* current row # in the virtual array */ - rle_hdr header; /* Input file information */ - rle_pixel** rle_row; /* holds a row returned by rle_getrow() */ - -} rle_source_struct; - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JDIMENSION width, height; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* Use RLE library routine to get the header info */ - source->header = *rle_hdr_init(NULL); - source->header.rle_file = source->pub.input_file; - switch (rle_get_setup(&(source->header))) { - case RLE_SUCCESS: - /* A-OK */ - break; - case RLE_NOT_RLE: - ERREXIT(cinfo, JERR_RLE_NOT); - break; - case RLE_NO_SPACE: - ERREXIT(cinfo, JERR_RLE_MEM); - break; - case RLE_EMPTY: - ERREXIT(cinfo, JERR_RLE_EMPTY); - break; - case RLE_EOF: - ERREXIT(cinfo, JERR_RLE_EOF); - break; - default: - ERREXIT(cinfo, JERR_RLE_BADERROR); - break; - } - - /* Figure out what we have, set private vars and return values accordingly */ - - width = source->header.xmax - source->header.xmin + 1; - height = source->header.ymax - source->header.ymin + 1; - source->header.xmin = 0; /* realign horizontally */ - source->header.xmax = width-1; - - cinfo->image_width = width; - cinfo->image_height = height; - cinfo->data_precision = 8; /* we can only handle 8 bit data */ - - if (source->header.ncolors == 1 && source->header.ncmap == 0) { - source->visual = GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_RLE_GRAY, width, height); - } else if (source->header.ncolors == 1 && source->header.ncmap == 1) { - source->visual = MAPPEDGRAY; - TRACEMS3(cinfo, 1, JTRC_RLE_MAPGRAY, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 1 && source->header.ncmap == 3) { - source->visual = PSEUDOCOLOR; - TRACEMS3(cinfo, 1, JTRC_RLE_MAPPED, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 3 && source->header.ncmap == 3) { - source->visual = TRUECOLOR; - TRACEMS3(cinfo, 1, JTRC_RLE_FULLMAP, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 3 && source->header.ncmap == 0) { - source->visual = DIRECTCOLOR; - TRACEMS2(cinfo, 1, JTRC_RLE, width, height); - } else - ERREXIT(cinfo, JERR_RLE_UNSUPPORTED); - - if (source->visual == GRAYSCALE || source->visual == MAPPEDGRAY) { - cinfo->in_color_space = JCS_GRAYSCALE; - cinfo->input_components = 1; - } else { - cinfo->in_color_space = JCS_RGB; - cinfo->input_components = 3; - } - - /* - * A place to hold each scanline while it's converted. - * (GRAYSCALE scanlines don't need converting) - */ - if (source->visual != GRAYSCALE) { - source->rle_row = (rle_pixel**) (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) width, (JDIMENSION) cinfo->input_components); - } - - /* request a virtual array to hold the image */ - source->image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) (width * source->header.ncolors), - (JDIMENSION) height, (JDIMENSION) 1); - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - /* count file input as separate pass */ - progress->total_extra_passes++; - } -#endif - - source->pub.buffer_height = 1; -} - - -/* - * Read one row of pixels. - * Called only after load_image has read the image into the virtual array. - * Used for GRAYSCALE, MAPPEDGRAY, TRUECOLOR, and DIRECTCOLOR images. - */ - -METHODDEF(JDIMENSION) -get_rle_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - - source->row--; - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); - - return 1; -} - -/* - * Read one row of pixels. - * Called only after load_image has read the image into the virtual array. - * Used for PSEUDOCOLOR images. - */ - -METHODDEF(JDIMENSION) -get_pseudocolor_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JSAMPROW src_row, dest_row; - JDIMENSION col; - rle_map *colormap; - int val; - - colormap = source->header.cmap; - dest_row = source->pub.buffer[0]; - source->row--; - src_row = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); - - for (col = cinfo->image_width; col > 0; col--) { - val = GETJSAMPLE(*src_row++); - *dest_row++ = (JSAMPLE) (colormap[val ] >> 8); - *dest_row++ = (JSAMPLE) (colormap[val + 256] >> 8); - *dest_row++ = (JSAMPLE) (colormap[val + 512] >> 8); - } - - return 1; -} - - -/* - * Load the image into a virtual array. We have to do this because RLE - * files start at the lower left while the JPEG standard has them starting - * in the upper left. This is called the first time we want to get a row - * of input. What we do is load the RLE data into the array and then call - * the appropriate routine to read one row from the array. Before returning, - * we set source->pub.get_pixel_rows so that subsequent calls go straight to - * the appropriate row-reading routine. - */ - -METHODDEF(JDIMENSION) -load_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JDIMENSION row, col; - JSAMPROW scanline, red_ptr, green_ptr, blue_ptr; - rle_pixel **rle_row; - rle_map *colormap; - char channel; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - colormap = source->header.cmap; - rle_row = source->rle_row; - - /* Read the RLE data into our virtual array. - * We assume here that (a) rle_pixel is represented the same as JSAMPLE, - * and (b) we are not on a machine where FAR pointers differ from regular. - */ - RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */ - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_limit = cinfo->image_height; - progress->pub.pass_counter = 0; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - - switch (source->visual) { - - case GRAYSCALE: - case PSEUDOCOLOR: - for (row = 0; row < cinfo->image_height; row++) { - rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - rle_getrow(&source->header, rle_row); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - break; - - case MAPPEDGRAY: - case TRUECOLOR: - for (row = 0; row < cinfo->image_height; row++) { - scanline = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - rle_row = source->rle_row; - rle_getrow(&source->header, rle_row); - - for (col = 0; col < cinfo->image_width; col++) { - for (channel = 0; channel < source->header.ncolors; channel++) { - *scanline++ = (JSAMPLE) - (colormap[GETJSAMPLE(rle_row[channel][col]) + 256 * channel] >> 8); - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - break; - - case DIRECTCOLOR: - for (row = 0; row < cinfo->image_height; row++) { - scanline = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - rle_getrow(&source->header, rle_row); - - red_ptr = rle_row[0]; - green_ptr = rle_row[1]; - blue_ptr = rle_row[2]; - - for (col = cinfo->image_width; col > 0; col--) { - *scanline++ = *red_ptr++; - *scanline++ = *green_ptr++; - *scanline++ = *blue_ptr++; - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) - progress->completed_extra_passes++; -#endif - - /* Set up to call proper row-extraction routine in future */ - if (source->visual == PSEUDOCOLOR) { - source->pub.buffer = source->rle_row; - source->pub.get_pixel_rows = get_pseudocolor_row; - } else { - source->pub.get_pixel_rows = get_rle_row; - } - source->row = cinfo->image_height; - - /* And fetch the topmost (bottommost) row */ - return (*source->pub.get_pixel_rows) (cinfo, sinfo); -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for RLE format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_rle (j_compress_ptr cinfo) -{ - rle_source_ptr source; - - /* Create module interface object */ - source = (rle_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(rle_source_struct)); - /* Fill in method ptrs */ - source->pub.start_input = start_input_rle; - source->pub.finish_input = finish_input_rle; - source->pub.get_pixel_rows = load_image; - - return (cjpeg_source_ptr) source; -} - -#endif /* RLE_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/rdswitch.c b/freeimage241/Source/LibJPEG/rdswitch.c deleted file mode 100644 index 4f4bb4f..0000000 --- a/freeimage241/Source/LibJPEG/rdswitch.c +++ /dev/null @@ -1,332 +0,0 @@ -/* - * rdswitch.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to process some of cjpeg's more complicated - * command-line switches. Switches processed here are: - * -qtables file Read quantization tables from text file - * -scans file Read scan script from text file - * -qslots N[,N,...] Set component quantization table selectors - * -sample HxV[,HxV,...] Set component sampling factors - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include /* to declare isdigit(), isspace() */ - - -LOCAL(int) -text_getc (FILE * file) -/* Read next char, skipping over any comments (# to end of line) */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(file); - if (ch == '#') { - do { - ch = getc(file); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(boolean) -read_text_integer (FILE * file, long * result, int * termchar) -/* Read an unsigned decimal integer from a file, store it in result */ -/* Reads one trailing character after the integer; returns it in termchar */ -{ - register int ch; - register long val; - - /* Skip any leading whitespace, detect EOF */ - do { - ch = text_getc(file); - if (ch == EOF) { - *termchar = ch; - return FALSE; - } - } while (isspace(ch)); - - if (! isdigit(ch)) { - *termchar = ch; - return FALSE; - } - - val = ch - '0'; - while ((ch = text_getc(file)) != EOF) { - if (! isdigit(ch)) - break; - val *= 10; - val += ch - '0'; - } - *result = val; - *termchar = ch; - return TRUE; -} - - -GLOBAL(boolean) -read_quant_tables (j_compress_ptr cinfo, char * filename, - int scale_factor, boolean force_baseline) -/* Read a set of quantization tables from the specified file. - * The file is plain ASCII text: decimal numbers with whitespace between. - * Comments preceded by '#' may be included in the file. - * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values. - * The tables are implicitly numbered 0,1,etc. - * NOTE: does not affect the qslots mapping, which will default to selecting - * table 0 for luminance (or primary) components, 1 for chrominance components. - * You must use -qslots if you want a different component->table mapping. - */ -{ - FILE * fp; - int tblno, i, termchar; - long val; - unsigned int table[DCTSIZE2]; - - if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, "Can't open table file %s\n", filename); - return FALSE; - } - tblno = 0; - - while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */ - if (tblno >= NUM_QUANT_TBLS) { - fprintf(stderr, "Too many tables in file %s\n", filename); - fclose(fp); - return FALSE; - } - table[0] = (unsigned int) val; - for (i = 1; i < DCTSIZE2; i++) { - if (! read_text_integer(fp, &val, &termchar)) { - fprintf(stderr, "Invalid table data in file %s\n", filename); - fclose(fp); - return FALSE; - } - table[i] = (unsigned int) val; - } - jpeg_add_quant_table(cinfo, tblno, table, scale_factor, force_baseline); - tblno++; - } - - if (termchar != EOF) { - fprintf(stderr, "Non-numeric data in file %s\n", filename); - fclose(fp); - return FALSE; - } - - fclose(fp); - return TRUE; -} - - -#ifdef C_MULTISCAN_FILES_SUPPORTED - -LOCAL(boolean) -read_scan_integer (FILE * file, long * result, int * termchar) -/* Variant of read_text_integer that always looks for a non-space termchar; - * this simplifies parsing of punctuation in scan scripts. - */ -{ - register int ch; - - if (! read_text_integer(file, result, termchar)) - return FALSE; - ch = *termchar; - while (ch != EOF && isspace(ch)) - ch = text_getc(file); - if (isdigit(ch)) { /* oops, put it back */ - if (ungetc(ch, file) == EOF) - return FALSE; - ch = ' '; - } else { - /* Any separators other than ';' and ':' are ignored; - * this allows user to insert commas, etc, if desired. - */ - if (ch != EOF && ch != ';' && ch != ':') - ch = ' '; - } - *termchar = ch; - return TRUE; -} - - -GLOBAL(boolean) -read_scan_script (j_compress_ptr cinfo, char * filename) -/* Read a scan script from the specified text file. - * Each entry in the file defines one scan to be emitted. - * Entries are separated by semicolons ';'. - * An entry contains one to four component indexes, - * optionally followed by a colon ':' and four progressive-JPEG parameters. - * The component indexes denote which component(s) are to be transmitted - * in the current scan. The first component has index 0. - * Sequential JPEG is used if the progressive-JPEG parameters are omitted. - * The file is free format text: any whitespace may appear between numbers - * and the ':' and ';' punctuation marks. Also, other punctuation (such - * as commas or dashes) can be placed between numbers if desired. - * Comments preceded by '#' may be included in the file. - * Note: we do very little validity checking here; - * jcmaster.c will validate the script parameters. - */ -{ - FILE * fp; - int scanno, ncomps, termchar; - long val; - jpeg_scan_info * scanptr; -#define MAX_SCANS 100 /* quite arbitrary limit */ - jpeg_scan_info scans[MAX_SCANS]; - - if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, "Can't open scan definition file %s\n", filename); - return FALSE; - } - scanptr = scans; - scanno = 0; - - while (read_scan_integer(fp, &val, &termchar)) { - if (scanno >= MAX_SCANS) { - fprintf(stderr, "Too many scans defined in file %s\n", filename); - fclose(fp); - return FALSE; - } - scanptr->component_index[0] = (int) val; - ncomps = 1; - while (termchar == ' ') { - if (ncomps >= MAX_COMPS_IN_SCAN) { - fprintf(stderr, "Too many components in one scan in file %s\n", - filename); - fclose(fp); - return FALSE; - } - if (! read_scan_integer(fp, &val, &termchar)) - goto bogus; - scanptr->component_index[ncomps] = (int) val; - ncomps++; - } - scanptr->comps_in_scan = ncomps; - if (termchar == ':') { - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Ss = (int) val; - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Se = (int) val; - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Ah = (int) val; - if (! read_scan_integer(fp, &val, &termchar)) - goto bogus; - scanptr->Al = (int) val; - } else { - /* set non-progressive parameters */ - scanptr->Ss = 0; - scanptr->Se = DCTSIZE2-1; - scanptr->Ah = 0; - scanptr->Al = 0; - } - if (termchar != ';' && termchar != EOF) { -bogus: - fprintf(stderr, "Invalid scan entry format in file %s\n", filename); - fclose(fp); - return FALSE; - } - scanptr++, scanno++; - } - - if (termchar != EOF) { - fprintf(stderr, "Non-numeric data in file %s\n", filename); - fclose(fp); - return FALSE; - } - - if (scanno > 0) { - /* Stash completed scan list in cinfo structure. - * NOTE: for cjpeg's use, JPOOL_IMAGE is the right lifetime for this data, - * but if you want to compress multiple images you'd want JPOOL_PERMANENT. - */ - scanptr = (jpeg_scan_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - scanno * SIZEOF(jpeg_scan_info)); - MEMCOPY(scanptr, scans, scanno * SIZEOF(jpeg_scan_info)); - cinfo->scan_info = scanptr; - cinfo->num_scans = scanno; - } - - fclose(fp); - return TRUE; -} - -#endif /* C_MULTISCAN_FILES_SUPPORTED */ - - -GLOBAL(boolean) -set_quant_slots (j_compress_ptr cinfo, char *arg) -/* Process a quantization-table-selectors parameter string, of the form - * N[,N,...] - * If there are more components than parameters, the last value is replicated. - */ -{ - int val = 0; /* default table # */ - int ci; - char ch; - - for (ci = 0; ci < MAX_COMPONENTS; ci++) { - if (*arg) { - ch = ','; /* if not set by sscanf, will be ',' */ - if (sscanf(arg, "%d%c", &val, &ch) < 1) - return FALSE; - if (ch != ',') /* syntax check */ - return FALSE; - if (val < 0 || val >= NUM_QUANT_TBLS) { - fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n", - NUM_QUANT_TBLS-1); - return FALSE; - } - cinfo->comp_info[ci].quant_tbl_no = val; - while (*arg && *arg++ != ',') /* advance to next segment of arg string */ - ; - } else { - /* reached end of parameter, set remaining components to last table */ - cinfo->comp_info[ci].quant_tbl_no = val; - } - } - return TRUE; -} - - -GLOBAL(boolean) -set_sample_factors (j_compress_ptr cinfo, char *arg) -/* Process a sample-factors parameter string, of the form - * HxV[,HxV,...] - * If there are more components than parameters, "1x1" is assumed for the rest. - */ -{ - int ci, val1, val2; - char ch1, ch2; - - for (ci = 0; ci < MAX_COMPONENTS; ci++) { - if (*arg) { - ch2 = ','; /* if not set by sscanf, will be ',' */ - if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3) - return FALSE; - if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */ - return FALSE; - if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) { - fprintf(stderr, "JPEG sampling factors must be 1..4\n"); - return FALSE; - } - cinfo->comp_info[ci].h_samp_factor = val1; - cinfo->comp_info[ci].v_samp_factor = val2; - while (*arg && *arg++ != ',') /* advance to next segment of arg string */ - ; - } else { - /* reached end of parameter, set remaining components to 1x1 sampling */ - cinfo->comp_info[ci].h_samp_factor = 1; - cinfo->comp_info[ci].v_samp_factor = 1; - } - } - return TRUE; -} diff --git a/freeimage241/Source/LibJPEG/rdtarga.c b/freeimage241/Source/LibJPEG/rdtarga.c deleted file mode 100644 index 4c2cd26..0000000 --- a/freeimage241/Source/LibJPEG/rdtarga.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * rdtarga.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Targa format. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed Targa format). - * - * Based on code contributed by Lee Daniel Crocker. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef TARGA_SUPPORTED - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char U_CHAR; -#define UCH(x) ((int) (x)) -#else -typedef char U_CHAR; -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* Private version of data source object */ - -typedef struct _tga_source_struct * tga_source_ptr; - -typedef struct _tga_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - j_compress_ptr cinfo; /* back link saves passing separate parm */ - - JSAMPARRAY colormap; /* Targa colormap (converted to my format) */ - - jvirt_sarray_ptr whole_image; /* Needed if funny input row order */ - JDIMENSION current_row; /* Current logical row number to read */ - - /* Pointer to routine to extract next Targa pixel from input file */ - JMETHOD(void, read_pixel, (tga_source_ptr sinfo)); - - /* Result of read_pixel is delivered here: */ - U_CHAR tga_pixel[4]; - - int pixel_size; /* Bytes per Targa pixel (1 to 4) */ - - /* State info for reading RLE-coded pixels; both counts must be init to 0 */ - int block_count; /* # of pixels remaining in RLE block */ - int dup_pixel_count; /* # of times to duplicate previous pixel */ - - /* This saves the correct pixel-row-expansion method for preload_image */ - JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); -} tga_source_struct; - - -/* For expanding 5-bit pixel values to 8-bit with best rounding */ - -static const UINT8 c5to8bits[32] = { - 0, 8, 16, 25, 33, 41, 49, 58, - 66, 74, 82, 90, 99, 107, 115, 123, - 132, 140, 148, 156, 165, 173, 181, 189, - 197, 206, 214, 222, 230, 239, 247, 255 -}; - - - -LOCAL(int) -read_byte (tga_source_ptr sinfo) -/* Read next byte from Targa file */ -{ - register FILE *infile = sinfo->pub.input_file; - register int c; - - if ((c = getc(infile)) == EOF) - ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); - return c; -} - - -LOCAL(void) -read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize) -/* Read the colormap from a Targa file */ -{ - int i; - - /* Presently only handles 24-bit BGR format */ - if (mapentrysize != 24) - ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP); - - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - } -} - - -/* - * read_pixel methods: get a single pixel from Targa file into tga_pixel[] - */ - -METHODDEF(void) -read_non_rle_pixel (tga_source_ptr sinfo) -/* Read one Targa pixel from the input file; no RLE expansion */ -{ - register FILE *infile = sinfo->pub.input_file; - register int i; - - for (i = 0; i < sinfo->pixel_size; i++) { - sinfo->tga_pixel[i] = (U_CHAR) getc(infile); - } -} - - -METHODDEF(void) -read_rle_pixel (tga_source_ptr sinfo) -/* Read one Targa pixel from the input file, expanding RLE data as needed */ -{ - register FILE *infile = sinfo->pub.input_file; - register int i; - - /* Duplicate previously read pixel? */ - if (sinfo->dup_pixel_count > 0) { - sinfo->dup_pixel_count--; - return; - } - - /* Time to read RLE block header? */ - if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */ - i = read_byte(sinfo); - if (i & 0x80) { /* Start of duplicate-pixel block? */ - sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */ - sinfo->block_count = 0; /* then read new block header */ - } else { - sinfo->block_count = i & 0x7F; /* number of pixels after this one */ - } - } - - /* Read next pixel */ - for (i = 0; i < sinfo->pixel_size; i++) { - sinfo->tga_pixel[i] = (U_CHAR) getc(infile); - } -} - - -/* - * Read one row of pixels. - * - * We provide several different versions depending on input file format. - */ - - -METHODDEF(JDIMENSION) -get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit grayscale pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); - } - return 1; -} - -METHODDEF(JDIMENSION) -get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit colormap indexes */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register int t; - register JSAMPROW ptr; - register JDIMENSION col; - register JSAMPARRAY colormap = source->colormap; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - t = UCH(source->tga_pixel[0]); - *ptr++ = colormap[0][t]; - *ptr++ = colormap[1][t]; - *ptr++ = colormap[2][t]; - } - return 1; -} - -METHODDEF(JDIMENSION) -get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 16-bit pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register int t; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - t = UCH(source->tga_pixel[0]); - t += UCH(source->tga_pixel[1]) << 8; - /* We expand 5 bit data to 8 bit sample width. - * The format of the 16-bit (LSB first) input word is - * xRRRRRGGGGGBBBBB - */ - ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F]; - t >>= 5; - ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F]; - t >>= 5; - ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F]; - ptr += 3; - } - return 1; -} - -METHODDEF(JDIMENSION) -get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 24-bit pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]); - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); - } - return 1; -} - -/* - * Targa also defines a 32-bit pixel format with order B,G,R,A. - * We presently ignore the attribute byte, so the code for reading - * these pixels is identical to the 24-bit routine above. - * This works because the actual pixel length is only known to read_pixel. - */ - -#define get_32bit_row get_24bit_row - - -/* - * This method is for re-reading the input data in standard top-down - * row order. The entire image has already been read into whole_image - * with proper conversion of pixel format, but it's in a funny row order. - */ - -METHODDEF(JDIMENSION) -get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - JDIMENSION source_row; - - /* Compute row of source that maps to current_row of normal order */ - /* For now, assume image is bottom-up and not interlaced. */ - /* NEEDS WORK to support interlaced images! */ - source_row = cinfo->image_height - source->current_row - 1; - - /* Fetch that row from virtual array */ - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, - source_row, (JDIMENSION) 1, FALSE); - - source->current_row++; - return 1; -} - - -/* - * This method loads the image into whole_image during the first call on - * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call - * get_memory_row on subsequent calls. - */ - -METHODDEF(JDIMENSION) -preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - JDIMENSION row; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Read the data into a virtual array in input-file row order. */ - for (row = 0; row < cinfo->image_height; row++) { - if (progress != NULL) { - progress->pub.pass_counter = (long) row; - progress->pub.pass_limit = (long) cinfo->image_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE); - (*source->get_pixel_rows) (cinfo, sinfo); - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Set up to read from the virtual array in unscrambled order */ - source->pub.get_pixel_rows = get_memory_row; - source->current_row = 0; - /* And read the first row */ - return get_memory_row(cinfo, sinfo); -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - U_CHAR targaheader[18]; - int idlen, cmaptype, subtype, flags, interlace_type, components; - unsigned int width, height, maplen; - boolean is_bottom_up; - -#define GET_2B(offset) ((unsigned int) UCH(targaheader[offset]) + \ - (((unsigned int) UCH(targaheader[offset+1])) << 8)) - - if (! ReadOK(source->pub.input_file, targaheader, 18)) - ERREXIT(cinfo, JERR_INPUT_EOF); - - /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */ - if (targaheader[16] == 15) - targaheader[16] = 16; - - idlen = UCH(targaheader[0]); - cmaptype = UCH(targaheader[1]); - subtype = UCH(targaheader[2]); - maplen = GET_2B(5); - width = GET_2B(12); - height = GET_2B(14); - source->pixel_size = UCH(targaheader[16]) >> 3; - flags = UCH(targaheader[17]); /* Image Descriptor byte */ - - is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */ - interlace_type = flags >> 6; /* bits 6/7 are interlace code */ - - if (cmaptype > 1 || /* cmaptype must be 0 or 1 */ - source->pixel_size < 1 || source->pixel_size > 4 || - (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */ - interlace_type != 0) /* currently don't allow interlaced image */ - ERREXIT(cinfo, JERR_TGA_BADPARMS); - - if (subtype > 8) { - /* It's an RLE-coded file */ - source->read_pixel = read_rle_pixel; - source->block_count = source->dup_pixel_count = 0; - subtype -= 8; - } else { - /* Non-RLE file */ - source->read_pixel = read_non_rle_pixel; - } - - /* Now should have subtype 1, 2, or 3 */ - components = 3; /* until proven different */ - cinfo->in_color_space = JCS_RGB; - - switch (subtype) { - case 1: /* Colormapped image */ - if (source->pixel_size == 1 && cmaptype == 1) - source->get_pixel_rows = get_8bit_row; - else - ERREXIT(cinfo, JERR_TGA_BADPARMS); - TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height); - break; - case 2: /* RGB image */ - switch (source->pixel_size) { - case 2: - source->get_pixel_rows = get_16bit_row; - break; - case 3: - source->get_pixel_rows = get_24bit_row; - break; - case 4: - source->get_pixel_rows = get_32bit_row; - break; - default: - ERREXIT(cinfo, JERR_TGA_BADPARMS); - break; - } - TRACEMS2(cinfo, 1, JTRC_TGA, width, height); - break; - case 3: /* Grayscale image */ - components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - if (source->pixel_size == 1) - source->get_pixel_rows = get_8bit_gray_row; - else - ERREXIT(cinfo, JERR_TGA_BADPARMS); - TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height); - break; - default: - ERREXIT(cinfo, JERR_TGA_BADPARMS); - break; - } - - if (is_bottom_up) { - /* Create a virtual array to buffer the upside-down image. */ - source->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1); - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - /* source->pub.buffer will point to the virtual array. */ - source->pub.buffer_height = 1; /* in case anyone looks at it */ - source->pub.get_pixel_rows = preload_image; - } else { - /* Don't need a virtual array, but do need a one-row input buffer. */ - source->whole_image = NULL; - source->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) width * components, (JDIMENSION) 1); - source->pub.buffer_height = 1; - source->pub.get_pixel_rows = source->get_pixel_rows; - } - - while (idlen--) /* Throw away ID field */ - (void) read_byte(source); - - if (maplen > 0) { - if (maplen > 256 || GET_2B(3) != 0) - ERREXIT(cinfo, JERR_TGA_BADCMAP); - /* Allocate space to store the colormap */ - source->colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3); - /* and read it from the file */ - read_colormap(source, (int) maplen, UCH(targaheader[7])); - } else { - if (cmaptype) /* but you promised a cmap! */ - ERREXIT(cinfo, JERR_TGA_BADPARMS); - source->colormap = NULL; - } - - cinfo->input_components = components; - cinfo->data_precision = 8; - cinfo->image_width = width; - cinfo->image_height = height; -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for Targa format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_targa (j_compress_ptr cinfo) -{ - tga_source_ptr source; - - /* Create module interface object */ - source = (tga_source_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(tga_source_struct)); - source->cinfo = cinfo; /* make back link for subroutines */ - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_tga; - source->pub.finish_input = finish_input_tga; - - return (cjpeg_source_ptr) source; -} - -#endif /* TARGA_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/tca.map b/freeimage241/Source/LibJPEG/tca.map deleted file mode 100644 index c891ee2..0000000 Binary files a/freeimage241/Source/LibJPEG/tca.map and /dev/null differ diff --git a/freeimage241/Source/LibJPEG/transupp.c b/freeimage241/Source/LibJPEG/transupp.c deleted file mode 100644 index e5ec564..0000000 --- a/freeimage241/Source/LibJPEG/transupp.c +++ /dev/null @@ -1,928 +0,0 @@ -/* - * transupp.c - * - * Copyright (C) 1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains image transformation routines and other utility code - * used by the jpegtran sample application. These are NOT part of the core - * JPEG library. But we keep these routines separate from jpegtran.c to - * ease the task of maintaining jpegtran-like programs that have other user - * interfaces. - */ - -/* Although this file really shouldn't have access to the library internals, - * it's helpful to let it call jround_up() and jcopy_block_row(). - */ -#define JPEG_INTERNALS - -#include "jinclude.h" -#include "jpeglib.h" -#include "transupp.h" /* My own external interface */ - - -#if TRANSFORMS_SUPPORTED - -/* - * Lossless image transformation routines. These routines work on DCT - * coefficient arrays and thus do not require any lossy decompression - * or recompression of the image. - * Thanks to Guido Vollbeding for the initial design and code of this feature. - * - * Horizontal flipping is done in-place, using a single top-to-bottom - * pass through the virtual source array. It will thus be much the - * fastest option for images larger than main memory. - * - * The other routines require a set of destination virtual arrays, so they - * need twice as much memory as jpegtran normally does. The destination - * arrays are always written in normal scan order (top to bottom) because - * the virtual array manager expects this. The source arrays will be scanned - * in the corresponding order, which means multiple passes through the source - * arrays for most of the transforms. That could result in much thrashing - * if the image is larger than main memory. - * - * Some notes about the operating environment of the individual transform - * routines: - * 1. Both the source and destination virtual arrays are allocated from the - * source JPEG object, and therefore should be manipulated by calling the - * source's memory manager. - * 2. The destination's component count should be used. It may be smaller - * than the source's when forcing to grayscale. - * 3. Likewise the destination's sampling factors should be used. When - * forcing to grayscale the destination's sampling factors will be all 1, - * and we may as well take that as the effective iMCU size. - * 4. When "trim" is in effect, the destination's dimensions will be the - * trimmed values but the source's will be untrimmed. - * 5. All the routines assume that the source and destination buffers are - * padded out to a full iMCU boundary. This is true, although for the - * source buffer it is an undocumented property of jdcoefct.c. - * Notes 2,3,4 boil down to this: generally we should use the destination's - * dimensions and ignore the source's. - */ - - -LOCAL(void) -do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays) -/* Horizontal flip; done in-place, so no separate dest array is required */ -{ - JDIMENSION MCU_cols, comp_width, blk_x, blk_y; - int ci, k, offset_y; - JBLOCKARRAY buffer; - JCOEFPTR ptr1, ptr2; - JCOEF temp1, temp2; - jpeg_component_info *compptr; - - /* Horizontal mirroring of DCT blocks is accomplished by swapping - * pairs of blocks in-place. Within a DCT block, we perform horizontal - * mirroring by changing the signs of odd-numbered columns. - * Partial iMCUs at the right edge are left untouched. - */ - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - for (blk_y = 0; blk_y < compptr->height_in_blocks; - blk_y += compptr->v_samp_factor) { - buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) { - ptr1 = buffer[offset_y][blk_x]; - ptr2 = buffer[offset_y][comp_width - blk_x - 1]; - /* this unrolled loop doesn't need to know which row it's on... */ - for (k = 0; k < DCTSIZE2; k += 2) { - temp1 = *ptr1; /* swap even column */ - temp2 = *ptr2; - *ptr1++ = temp2; - *ptr2++ = temp1; - temp1 = *ptr1; /* swap odd column with sign change */ - temp2 = *ptr2; - *ptr1++ = -temp2; - *ptr2++ = -temp1; - } - } - } - } - } -} - - -LOCAL(void) -do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Vertical flip */ -{ - JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* We output into a separate array because we can't touch different - * rows of the source virtual array simultaneously. Otherwise, this - * is a pretty straightforward analog of horizontal flip. - * Within a DCT block, vertical mirroring is done by changing the signs - * of odd-numbered rows. - * Partial iMCUs at the bottom edge are copied verbatim. - */ - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - /* Bottom-edge blocks will be copied verbatim. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - if (dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[dst_blk_x]; - for (i = 0; i < DCTSIZE; i += 2) { - /* copy even row */ - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = *src_ptr++; - /* copy odd row with sign change */ - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = - *src_ptr++; - } - } - } else { - /* Just copy row verbatim. */ - jcopy_block_row(src_buffer[offset_y], dst_buffer[offset_y], - compptr->width_in_blocks); - } - } - } - } -} - - -LOCAL(void) -do_transpose (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Transpose source into destination */ -{ - JDIMENSION dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Transposing pixels within a block just requires transposing the - * DCT coefficients. - * Partial iMCUs at the edges require no special treatment; we simply - * process all the available DCT blocks for every component. - */ - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } -} - - -LOCAL(void) -do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 90 degree rotation is equivalent to - * 1. Transposing the image; - * 2. Horizontal mirroring. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Because of the horizontal mirror step, we can't process partial iMCUs - * at the (output) right edge properly. They just get transposed and - * not mirrored. - */ - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - if (dst_blk_x < comp_width) { - /* Block is within the mirrorable area. */ - dst_ptr = dst_buffer[offset_y] - [comp_width - dst_blk_x - offset_x - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - i++; - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } else { - /* Edge blocks are transposed but not mirrored. */ - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } -} - - -LOCAL(void) -do_rot_270 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 270 degree rotation is equivalent to - * 1. Horizontal mirroring; - * 2. Transposing the image. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Because of the horizontal mirror step, we can't process partial iMCUs - * at the (output) bottom edge properly. They just get transposed and - * not mirrored. - */ - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - if (dst_blk_y < comp_height) { - /* Block is within the mirrorable area. */ - src_ptr = src_buffer[offset_x] - [comp_height - dst_blk_y - offset_y - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } - } else { - /* Edge blocks are transposed but not mirrored. */ - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } -} - - -LOCAL(void) -do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 180 degree rotation is equivalent to - * 1. Vertical mirroring; - * 2. Horizontal mirroring. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (dst_blk_y < comp_height) { - /* Row is within the vertically mirrorable area. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - /* Bottom-edge rows are only mirrored horizontally. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - if (dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; - /* Process the blocks that can be mirrored both ways. */ - for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; - for (i = 0; i < DCTSIZE; i += 2) { - /* For even row, negate every odd column. */ - for (j = 0; j < DCTSIZE; j += 2) { - *dst_ptr++ = *src_ptr++; - *dst_ptr++ = - *src_ptr++; - } - /* For odd row, negate every even column. */ - for (j = 0; j < DCTSIZE; j += 2) { - *dst_ptr++ = - *src_ptr++; - *dst_ptr++ = *src_ptr++; - } - } - } - /* Any remaining right-edge blocks are only mirrored vertically. */ - for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[dst_blk_x]; - for (i = 0; i < DCTSIZE; i += 2) { - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = *src_ptr++; - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = - *src_ptr++; - } - } - } else { - /* Remaining rows are just mirrored horizontally. */ - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[offset_y]; - /* Process the blocks that can be mirrored. */ - for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; - for (i = 0; i < DCTSIZE2; i += 2) { - *dst_ptr++ = *src_ptr++; - *dst_ptr++ = - *src_ptr++; - } - } - /* Any remaining right-edge blocks are only copied. */ - for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[dst_blk_x]; - for (i = 0; i < DCTSIZE2; i++) - *dst_ptr++ = *src_ptr++; - } - } - } - } - } -} - - -LOCAL(void) -do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Transverse transpose is equivalent to - * 1. 180 degree rotation; - * 2. Transposition; - * or - * 1. Horizontal mirroring; - * 2. Transposition; - * 3. Horizontal mirroring. - * These steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - if (dst_blk_y < comp_height) { - src_ptr = src_buffer[offset_x] - [comp_height - dst_blk_y - offset_y - 1]; - if (dst_blk_x < comp_width) { - /* Block is within the mirrorable area. */ - dst_ptr = dst_buffer[offset_y] - [comp_width - dst_blk_x - offset_x - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - i++; - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } else { - /* Right-edge blocks are mirrored in y only */ - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } - } - } else { - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; - if (dst_blk_x < comp_width) { - /* Bottom-edge blocks are mirrored in x only */ - dst_ptr = dst_buffer[offset_y] - [comp_width - dst_blk_x - offset_x - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - i++; - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } else { - /* At lower right corner, just transpose, no mirroring */ - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } - } -} - - -/* Request any required workspace. - * - * We allocate the workspace virtual arrays from the source decompression - * object, so that all the arrays (both the original data and the workspace) - * will be taken into account while making memory management decisions. - * Hence, this routine must be called after jpeg_read_header (which reads - * the image dimensions) and before jpeg_read_coefficients (which realizes - * the source's virtual arrays). - */ - -GLOBAL(void) -jtransform_request_workspace (j_decompress_ptr srcinfo, - jpeg_transform_info *info) -{ - jvirt_barray_ptr *coef_arrays = NULL; - jpeg_component_info *compptr; - int ci; - - if (info->force_grayscale && - srcinfo->jpeg_color_space == JCS_YCbCr && - srcinfo->num_components == 3) { - /* We'll only process the first component */ - info->num_components = 1; - } else { - /* Process all the components */ - info->num_components = srcinfo->num_components; - } - - switch (info->transform) { - case JXFORM_NONE: - case JXFORM_FLIP_H: - /* Don't need a workspace array */ - break; - case JXFORM_FLIP_V: - case JXFORM_ROT_180: - /* Need workspace arrays having same dimensions as source image. - * Note that we allocate arrays padded out to the next iMCU boundary, - * so that transform routines need not worry about missing edge blocks. - */ - coef_arrays = (jvirt_barray_ptr *) - (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, - SIZEOF(jvirt_barray_ptr) * info->num_components); - for (ci = 0; ci < info->num_components; ci++) { - compptr = srcinfo->comp_info + ci; - coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) - ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) compptr->v_samp_factor); - } - break; - case JXFORM_TRANSPOSE: - case JXFORM_TRANSVERSE: - case JXFORM_ROT_90: - case JXFORM_ROT_270: - /* Need workspace arrays having transposed dimensions. - * Note that we allocate arrays padded out to the next iMCU boundary, - * so that transform routines need not worry about missing edge blocks. - */ - coef_arrays = (jvirt_barray_ptr *) - (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, - SIZEOF(jvirt_barray_ptr) * info->num_components); - for (ci = 0; ci < info->num_components; ci++) { - compptr = srcinfo->comp_info + ci; - coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) - ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) compptr->h_samp_factor); - } - break; - } - info->workspace_coef_arrays = coef_arrays; -} - - -/* Transpose destination image parameters */ - -LOCAL(void) -transpose_critical_parameters (j_compress_ptr dstinfo) -{ - int tblno, i, j, ci, itemp; - jpeg_component_info *compptr; - JQUANT_TBL *qtblptr; - JDIMENSION dtemp; - UINT16 qtemp; - - /* Transpose basic image dimensions */ - dtemp = dstinfo->image_width; - dstinfo->image_width = dstinfo->image_height; - dstinfo->image_height = dtemp; - - /* Transpose sampling factors */ - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - itemp = compptr->h_samp_factor; - compptr->h_samp_factor = compptr->v_samp_factor; - compptr->v_samp_factor = itemp; - } - - /* Transpose quantization tables */ - for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { - qtblptr = dstinfo->quant_tbl_ptrs[tblno]; - if (qtblptr != NULL) { - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < i; j++) { - qtemp = qtblptr->quantval[i*DCTSIZE+j]; - qtblptr->quantval[i*DCTSIZE+j] = qtblptr->quantval[j*DCTSIZE+i]; - qtblptr->quantval[j*DCTSIZE+i] = qtemp; - } - } - } - } -} - - -/* Trim off any partial iMCUs on the indicated destination edge */ - -LOCAL(void) -trim_right_edge (j_compress_ptr dstinfo) -{ - int ci, max_h_samp_factor; - JDIMENSION MCU_cols; - - /* We have to compute max_h_samp_factor ourselves, - * because it hasn't been set yet in the destination - * (and we don't want to use the source's value). - */ - max_h_samp_factor = 1; - for (ci = 0; ci < dstinfo->num_components; ci++) { - int h_samp_factor = dstinfo->comp_info[ci].h_samp_factor; - max_h_samp_factor = MAX(max_h_samp_factor, h_samp_factor); - } - MCU_cols = dstinfo->image_width / (max_h_samp_factor * DCTSIZE); - if (MCU_cols > 0) /* can't trim to 0 pixels */ - dstinfo->image_width = MCU_cols * (max_h_samp_factor * DCTSIZE); -} - -LOCAL(void) -trim_bottom_edge (j_compress_ptr dstinfo) -{ - int ci, max_v_samp_factor; - JDIMENSION MCU_rows; - - /* We have to compute max_v_samp_factor ourselves, - * because it hasn't been set yet in the destination - * (and we don't want to use the source's value). - */ - max_v_samp_factor = 1; - for (ci = 0; ci < dstinfo->num_components; ci++) { - int v_samp_factor = dstinfo->comp_info[ci].v_samp_factor; - max_v_samp_factor = MAX(max_v_samp_factor, v_samp_factor); - } - MCU_rows = dstinfo->image_height / (max_v_samp_factor * DCTSIZE); - if (MCU_rows > 0) /* can't trim to 0 pixels */ - dstinfo->image_height = MCU_rows * (max_v_samp_factor * DCTSIZE); -} - - -/* Adjust output image parameters as needed. - * - * This must be called after jpeg_copy_critical_parameters() - * and before jpeg_write_coefficients(). - * - * The return value is the set of virtual coefficient arrays to be written - * (either the ones allocated by jtransform_request_workspace, or the - * original source data arrays). The caller will need to pass this value - * to jpeg_write_coefficients(). - */ - -GLOBAL(jvirt_barray_ptr *) -jtransform_adjust_parameters (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info) -{ - /* If force-to-grayscale is requested, adjust destination parameters */ - if (info->force_grayscale) { - /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed - * properly. Among other things, the target h_samp_factor & v_samp_factor - * will get set to 1, which typically won't match the source. - * In fact we do this even if the source is already grayscale; that - * provides an easy way of coercing a grayscale JPEG with funny sampling - * factors to the customary 1,1. (Some decoders fail on other factors.) - */ - if ((dstinfo->jpeg_color_space == JCS_YCbCr && - dstinfo->num_components == 3) || - (dstinfo->jpeg_color_space == JCS_GRAYSCALE && - dstinfo->num_components == 1)) { - /* We have to preserve the source's quantization table number. */ - int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no; - jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE); - dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no; - } else { - /* Sorry, can't do it */ - ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL); - } - } - - /* Correct the destination's image dimensions etc if necessary */ - switch (info->transform) { - case JXFORM_NONE: - /* Nothing to do */ - break; - case JXFORM_FLIP_H: - if (info->trim) - trim_right_edge(dstinfo); - break; - case JXFORM_FLIP_V: - if (info->trim) - trim_bottom_edge(dstinfo); - break; - case JXFORM_TRANSPOSE: - transpose_critical_parameters(dstinfo); - /* transpose does NOT have to trim anything */ - break; - case JXFORM_TRANSVERSE: - transpose_critical_parameters(dstinfo); - if (info->trim) { - trim_right_edge(dstinfo); - trim_bottom_edge(dstinfo); - } - break; - case JXFORM_ROT_90: - transpose_critical_parameters(dstinfo); - if (info->trim) - trim_right_edge(dstinfo); - break; - case JXFORM_ROT_180: - if (info->trim) { - trim_right_edge(dstinfo); - trim_bottom_edge(dstinfo); - } - break; - case JXFORM_ROT_270: - transpose_critical_parameters(dstinfo); - if (info->trim) - trim_bottom_edge(dstinfo); - break; - } - - /* Return the appropriate output data set */ - if (info->workspace_coef_arrays != NULL) - return info->workspace_coef_arrays; - return src_coef_arrays; -} - - -/* Execute the actual transformation, if any. - * - * This must be called *after* jpeg_write_coefficients, because it depends - * on jpeg_write_coefficients to have computed subsidiary values such as - * the per-component width and height fields in the destination object. - * - * Note that some transformations will modify the source data arrays! - */ - -GLOBAL(void) -jtransform_execute_transformation (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info) -{ - jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays; - - switch (info->transform) { - case JXFORM_NONE: - break; - case JXFORM_FLIP_H: - do_flip_h(srcinfo, dstinfo, src_coef_arrays); - break; - case JXFORM_FLIP_V: - do_flip_v(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_TRANSPOSE: - do_transpose(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_TRANSVERSE: - do_transverse(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_90: - do_rot_90(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_180: - do_rot_180(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_270: - do_rot_270(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); - break; - } -} - -#endif /* TRANSFORMS_SUPPORTED */ - - -/* Setup decompression object to save desired markers in memory. - * This must be called before jpeg_read_header() to have the desired effect. - */ - -GLOBAL(void) -jcopy_markers_setup (j_decompress_ptr srcinfo, JCOPY_OPTION option) -{ -#ifdef SAVE_MARKERS_SUPPORTED - int m; - - /* Save comments except under NONE option */ - if (option != JCOPYOPT_NONE) { - jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF); - } - /* Save all types of APPn markers iff ALL option */ - if (option == JCOPYOPT_ALL) { - for (m = 0; m < 16; m++) - jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF); - } -#endif /* SAVE_MARKERS_SUPPORTED */ -} - -/* Copy markers saved in the given source object to the destination object. - * This should be called just after jpeg_start_compress() or - * jpeg_write_coefficients(). - * Note that those routines will have written the SOI, and also the - * JFIF APP0 or Adobe APP14 markers if selected. - */ - -GLOBAL(void) -jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JCOPY_OPTION option) -{ - jpeg_saved_marker_ptr marker; - - /* In the current implementation, we don't actually need to examine the - * option flag here; we just copy everything that got saved. - * But to avoid confusion, we do not output JFIF and Adobe APP14 markers - * if the encoder library already wrote one. - */ - for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) { - if (dstinfo->write_JFIF_header && - marker->marker == JPEG_APP0 && - marker->data_length >= 5 && - GETJOCTET(marker->data[0]) == 0x4A && - GETJOCTET(marker->data[1]) == 0x46 && - GETJOCTET(marker->data[2]) == 0x49 && - GETJOCTET(marker->data[3]) == 0x46 && - GETJOCTET(marker->data[4]) == 0) - continue; /* reject duplicate JFIF */ - if (dstinfo->write_Adobe_marker && - marker->marker == JPEG_APP0+14 && - marker->data_length >= 5 && - GETJOCTET(marker->data[0]) == 0x41 && - GETJOCTET(marker->data[1]) == 0x64 && - GETJOCTET(marker->data[2]) == 0x6F && - GETJOCTET(marker->data[3]) == 0x62 && - GETJOCTET(marker->data[4]) == 0x65) - continue; /* reject duplicate Adobe */ -#ifdef NEED_FAR_POINTERS - /* We could use jpeg_write_marker if the data weren't FAR... */ - { - unsigned int i; - jpeg_write_m_header(dstinfo, marker->marker, marker->data_length); - for (i = 0; i < marker->data_length; i++) - jpeg_write_m_byte(dstinfo, marker->data[i]); - } -#else - jpeg_write_marker(dstinfo, marker->marker, - marker->data, marker->data_length); -#endif - } -} diff --git a/freeimage241/Source/LibJPEG/transupp.h b/freeimage241/Source/LibJPEG/transupp.h deleted file mode 100644 index 5c2d32a..0000000 --- a/freeimage241/Source/LibJPEG/transupp.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * transupp.h - * - * Copyright (C) 1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for image transformation routines and - * other utility code used by the jpegtran sample application. These are - * NOT part of the core JPEG library. But we keep these routines separate - * from jpegtran.c to ease the task of maintaining jpegtran-like programs - * that have other user interfaces. - * - * NOTE: all the routines declared here have very specific requirements - * about when they are to be executed during the reading and writing of the - * source and destination files. See the comments in transupp.c, or see - * jpegtran.c for an example of correct usage. - */ - -/* If you happen not to want the image transform support, disable it here */ -#ifndef TRANSFORMS_SUPPORTED -#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ -#endif - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jtransform_request_workspace jTrRequest -#define jtransform_adjust_parameters jTrAdjust -#define jtransform_execute_transformation jTrExec -#define jcopy_markers_setup jCMrkSetup -#define jcopy_markers_execute jCMrkExec -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* - * Codes for supported types of image transformations. - */ - -typedef enum { - JXFORM_NONE, /* no transformation */ - JXFORM_FLIP_H, /* horizontal flip */ - JXFORM_FLIP_V, /* vertical flip */ - JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ - JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ - JXFORM_ROT_90, /* 90-degree clockwise rotation */ - JXFORM_ROT_180, /* 180-degree rotation */ - JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ -} JXFORM_CODE; - -/* - * Although rotating and flipping data expressed as DCT coefficients is not - * hard, there is an asymmetry in the JPEG format specification for images - * whose dimensions aren't multiples of the iMCU size. The right and bottom - * image edges are padded out to the next iMCU boundary with junk data; but - * no padding is possible at the top and left edges. If we were to flip - * the whole image including the pad data, then pad garbage would become - * visible at the top and/or left, and real pixels would disappear into the - * pad margins --- perhaps permanently, since encoders & decoders may not - * bother to preserve DCT blocks that appear to be completely outside the - * nominal image area. So, we have to exclude any partial iMCUs from the - * basic transformation. - * - * Transpose is the only transformation that can handle partial iMCUs at the - * right and bottom edges completely cleanly. flip_h can flip partial iMCUs - * at the bottom, but leaves any partial iMCUs at the right edge untouched. - * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched. - * The other transforms are defined as combinations of these basic transforms - * and process edge blocks in a way that preserves the equivalence. - * - * The "trim" option causes untransformable partial iMCUs to be dropped; - * this is not strictly lossless, but it usually gives the best-looking - * result for odd-size images. Note that when this option is active, - * the expected mathematical equivalences between the transforms may not hold. - * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim - * followed by -rot 180 -trim trims both edges.) - * - * We also offer a "force to grayscale" option, which simply discards the - * chrominance channels of a YCbCr image. This is lossless in the sense that - * the luminance channel is preserved exactly. It's not the same kind of - * thing as the rotate/flip transformations, but it's convenient to handle it - * as part of this package, mainly because the transformation routines have to - * be aware of the option to know how many components to work on. - */ - -typedef struct { - /* Options: set by caller */ - JXFORM_CODE transform; /* image transform operator */ - boolean trim; /* if TRUE, trim partial MCUs as needed */ - boolean force_grayscale; /* if TRUE, convert color image to grayscale */ - - /* Internal workspace: caller should not touch these */ - int num_components; /* # of components in workspace */ - jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ -} jpeg_transform_info; - - -#if TRANSFORMS_SUPPORTED - -/* Request any required workspace */ -EXTERN(void) jtransform_request_workspace - JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); -/* Adjust output image parameters */ -EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters - JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info)); -/* Execute the actual transformation, if any */ -EXTERN(void) jtransform_execute_transformation - JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info)); - -#endif /* TRANSFORMS_SUPPORTED */ - - -/* - * Support for copying optional markers from source to destination file. - */ - -typedef enum { - JCOPYOPT_NONE, /* copy no optional markers */ - JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */ - JCOPYOPT_ALL /* copy all optional markers */ -} JCOPY_OPTION; - -#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */ - -/* Setup decompression object to save desired markers in memory */ -EXTERN(void) jcopy_markers_setup - JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option)); -/* Copy markers saved in the given source object to the destination object */ -EXTERN(void) jcopy_markers_execute - JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JCOPY_OPTION option)); diff --git a/freeimage241/Source/LibJPEG/vssver.scc b/freeimage241/Source/LibJPEG/vssver.scc deleted file mode 100644 index 4710178..0000000 Binary files a/freeimage241/Source/LibJPEG/vssver.scc and /dev/null differ diff --git a/freeimage241/Source/LibJPEG/wrbmp.c b/freeimage241/Source/LibJPEG/wrbmp.c deleted file mode 100644 index 3283b0f..0000000 --- a/freeimage241/Source/LibJPEG/wrbmp.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * wrbmp.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in Microsoft "BMP" - * format (MS Windows 3.x and OS/2 1.x flavors). - * Either 8-bit colormapped or 24-bit full-color format can be written. - * No compression is supported. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * This code contributed by James Arthur Boucher. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef BMP_SUPPORTED - - -/* - * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. - * This is not yet implemented. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * Since BMP stores scanlines bottom-to-top, we have to invert the image - * from JPEG's top-to-bottom order. To do this, we save the outgoing data - * in a virtual array during put_pixel_row calls, then actually emit the - * BMP file during finish_output. The virtual array contains one JSAMPLE per - * pixel if the output is grayscale or colormapped, three if it is full color. - */ - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - boolean is_os2; /* saves the OS2 format request flag */ - - jvirt_sarray_ptr whole_image; /* needed to reverse row order */ - JDIMENSION data_width; /* JSAMPLEs per row */ - JDIMENSION row_width; /* physical width of one row in the BMP file */ - int pad_bytes; /* number of padding bytes needed per row */ - JDIMENSION cur_output_row; /* next row# to write to virtual array */ -} bmp_dest_struct; - -typedef bmp_dest_struct * bmp_dest_ptr; - - -/* Forward declarations */ -LOCAL(void) write_colormap - JPP((j_decompress_ptr cinfo, bmp_dest_ptr dest, - int map_colors, int map_entry_size)); - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* This version is for writing 24-bit pixels */ -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - JSAMPARRAY image_ptr; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - int pad; - - /* Access next row in virtual array */ - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->whole_image, - dest->cur_output_row, (JDIMENSION) 1, TRUE); - dest->cur_output_row++; - - /* Transfer data. Note destination values must be in BGR order - * (even though Microsoft's own documents say the opposite). - */ - inptr = dest->pub.buffer[0]; - outptr = image_ptr[0]; - for (col = cinfo->output_width; col > 0; col--) { - outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ - outptr[1] = *inptr++; - outptr[0] = *inptr++; - outptr += 3; - } - - /* Zero out the pad bytes. */ - pad = dest->pad_bytes; - while (--pad >= 0) - *outptr++ = 0; -} - -METHODDEF(void) -put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* This version is for grayscale OR quantized color output */ -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - JSAMPARRAY image_ptr; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - int pad; - - /* Access next row in virtual array */ - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->whole_image, - dest->cur_output_row, (JDIMENSION) 1, TRUE); - dest->cur_output_row++; - - /* Transfer data. */ - inptr = dest->pub.buffer[0]; - outptr = image_ptr[0]; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = *inptr++; /* can omit GETJSAMPLE() safely */ - } - - /* Zero out the pad bytes. */ - pad = dest->pad_bytes; - while (--pad >= 0) - *outptr++ = 0; -} - - -/* - * Startup: normally writes the file header. - * In this module we may as well postpone everything until finish_output. - */ - -METHODDEF(void) -start_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* no work here */ -} - - -/* - * Finish up at the end of the file. - * - * Here is where we really output the BMP file. - * - * First, routines to write the Windows and OS/2 variants of the file header. - */ - -LOCAL(void) -write_bmp_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) -/* Write a Windows-style BMP file header, including colormap if needed */ -{ - char bmpfileheader[14]; - char bmpinfoheader[40]; -#define PUT_2B(array,offset,value) \ - (array[offset] = (char) ((value) & 0xFF), \ - array[offset+1] = (char) (((value) >> 8) & 0xFF)) -#define PUT_4B(array,offset,value) \ - (array[offset] = (char) ((value) & 0xFF), \ - array[offset+1] = (char) (((value) >> 8) & 0xFF), \ - array[offset+2] = (char) (((value) >> 16) & 0xFF), \ - array[offset+3] = (char) (((value) >> 24) & 0xFF)) - INT32 headersize, bfSize; - int bits_per_pixel, cmap_entries; - - /* Compute colormap size and total file size */ - if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* Colormapped RGB */ - bits_per_pixel = 8; - cmap_entries = 256; - } else { - /* Unquantized, full color RGB */ - bits_per_pixel = 24; - cmap_entries = 0; - } - } else { - /* Grayscale output. We need to fake a 256-entry colormap. */ - bits_per_pixel = 8; - cmap_entries = 256; - } - /* File size */ - headersize = 14 + 40 + cmap_entries * 4; /* Header and colormap */ - bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; - - /* Set unused fields of header to 0 */ - MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); - MEMZERO(bmpinfoheader, SIZEOF(bmpinfoheader)); - - /* Fill the file header */ - bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ - bmpfileheader[1] = 0x4D; - PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ - /* we leave bfReserved1 & bfReserved2 = 0 */ - PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ - - /* Fill the info header (Microsoft calls this a BITMAPINFOHEADER) */ - PUT_2B(bmpinfoheader, 0, 40); /* biSize */ - PUT_4B(bmpinfoheader, 4, cinfo->output_width); /* biWidth */ - PUT_4B(bmpinfoheader, 8, cinfo->output_height); /* biHeight */ - PUT_2B(bmpinfoheader, 12, 1); /* biPlanes - must be 1 */ - PUT_2B(bmpinfoheader, 14, bits_per_pixel); /* biBitCount */ - /* we leave biCompression = 0, for none */ - /* we leave biSizeImage = 0; this is correct for uncompressed data */ - if (cinfo->density_unit == 2) { /* if have density in dots/cm, then */ - PUT_4B(bmpinfoheader, 24, (INT32) (cinfo->X_density*100)); /* XPels/M */ - PUT_4B(bmpinfoheader, 28, (INT32) (cinfo->Y_density*100)); /* XPels/M */ - } - PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */ - /* we leave biClrImportant = 0 */ - - if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) - ERREXIT(cinfo, JERR_FILE_WRITE); - if (JFWRITE(dest->pub.output_file, bmpinfoheader, 40) != (size_t) 40) - ERREXIT(cinfo, JERR_FILE_WRITE); - - if (cmap_entries > 0) - write_colormap(cinfo, dest, cmap_entries, 4); -} - - -LOCAL(void) -write_os2_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) -/* Write an OS2-style BMP file header, including colormap if needed */ -{ - char bmpfileheader[14]; - char bmpcoreheader[12]; - INT32 headersize, bfSize; - int bits_per_pixel, cmap_entries; - - /* Compute colormap size and total file size */ - if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* Colormapped RGB */ - bits_per_pixel = 8; - cmap_entries = 256; - } else { - /* Unquantized, full color RGB */ - bits_per_pixel = 24; - cmap_entries = 0; - } - } else { - /* Grayscale output. We need to fake a 256-entry colormap. */ - bits_per_pixel = 8; - cmap_entries = 256; - } - /* File size */ - headersize = 14 + 12 + cmap_entries * 3; /* Header and colormap */ - bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; - - /* Set unused fields of header to 0 */ - MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); - MEMZERO(bmpcoreheader, SIZEOF(bmpcoreheader)); - - /* Fill the file header */ - bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ - bmpfileheader[1] = 0x4D; - PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ - /* we leave bfReserved1 & bfReserved2 = 0 */ - PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ - - /* Fill the info header (Microsoft calls this a BITMAPCOREHEADER) */ - PUT_2B(bmpcoreheader, 0, 12); /* bcSize */ - PUT_2B(bmpcoreheader, 4, cinfo->output_width); /* bcWidth */ - PUT_2B(bmpcoreheader, 6, cinfo->output_height); /* bcHeight */ - PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */ - PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */ - - if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) - ERREXIT(cinfo, JERR_FILE_WRITE); - if (JFWRITE(dest->pub.output_file, bmpcoreheader, 12) != (size_t) 12) - ERREXIT(cinfo, JERR_FILE_WRITE); - - if (cmap_entries > 0) - write_colormap(cinfo, dest, cmap_entries, 3); -} - - -/* - * Write the colormap. - * Windows uses BGR0 map entries; OS/2 uses BGR entries. - */ - -LOCAL(void) -write_colormap (j_decompress_ptr cinfo, bmp_dest_ptr dest, - int map_colors, int map_entry_size) -{ - JSAMPARRAY colormap = cinfo->colormap; - int num_colors = cinfo->actual_number_of_colors; - FILE * outfile = dest->pub.output_file; - int i; - - if (colormap != NULL) { - if (cinfo->out_color_components == 3) { - /* Normal case with RGB colormap */ - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(colormap[2][i]), outfile); - putc(GETJSAMPLE(colormap[1][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } else { - /* Grayscale colormap (only happens with grayscale quantization) */ - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(colormap[0][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } - } else { - /* If no colormap, must be grayscale data. Generate a linear "map". */ - for (i = 0; i < 256; i++) { - putc(i, outfile); - putc(i, outfile); - putc(i, outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } - /* Pad colormap with zeros to ensure specified number of colormap entries */ - if (i > map_colors) - ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, i); - for (; i < map_colors; i++) { - putc(0, outfile); - putc(0, outfile); - putc(0, outfile); - if (map_entry_size == 4) - putc(0, outfile); - } -} - - -METHODDEF(void) -finish_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - register FILE * outfile = dest->pub.output_file; - JSAMPARRAY image_ptr; - register JSAMPROW data_ptr; - JDIMENSION row; - register JDIMENSION col; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Write the header and colormap */ - if (dest->is_os2) - write_os2_header(cinfo, dest); - else - write_bmp_header(cinfo, dest); - - /* Write the file body from our virtual array */ - for (row = cinfo->output_height; row > 0; row--) { - if (progress != NULL) { - progress->pub.pass_counter = (long) (cinfo->output_height - row); - progress->pub.pass_limit = (long) cinfo->output_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - image_ptr = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->whole_image, row-1, (JDIMENSION) 1, FALSE); - data_ptr = image_ptr[0]; - for (col = dest->row_width; col > 0; col--) { - putc(GETJSAMPLE(*data_ptr), outfile); - data_ptr++; - } - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Make sure we wrote the output file OK */ - fflush(outfile); - if (ferror(outfile)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for BMP format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2) -{ - bmp_dest_ptr dest; - JDIMENSION row_width; - - /* Create module interface object, fill in method pointers */ - dest = (bmp_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(bmp_dest_struct)); - dest->pub.start_output = start_output_bmp; - dest->pub.finish_output = finish_output_bmp; - dest->is_os2 = is_os2; - - if (cinfo->out_color_space == JCS_GRAYSCALE) { - dest->pub.put_pixel_rows = put_gray_rows; - } else if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) - dest->pub.put_pixel_rows = put_gray_rows; - else - dest->pub.put_pixel_rows = put_pixel_rows; - } else { - ERREXIT(cinfo, JERR_BMP_COLORSPACE); - } - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Determine width of rows in the BMP file (padded to 4-byte boundary). */ - row_width = cinfo->output_width * cinfo->output_components; - dest->data_width = row_width; - while ((row_width & 3) != 0) row_width++; - dest->row_width = row_width; - dest->pad_bytes = (int) (row_width - dest->data_width); - - /* Allocate space for inversion array, prepare for write pass */ - dest->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - row_width, cinfo->output_height, (JDIMENSION) 1); - dest->cur_output_row = 0; - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, row_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return (djpeg_dest_ptr) dest; -} - -#endif /* BMP_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/wrgif.c b/freeimage241/Source/LibJPEG/wrgif.c deleted file mode 100644 index 5fe8328..0000000 --- a/freeimage241/Source/LibJPEG/wrgif.c +++ /dev/null @@ -1,399 +0,0 @@ -/* - * wrgif.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in GIF format. - * - ************************************************************************** - * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * - * this code has been modified to output "uncompressed GIF" files. * - * There is no trace of the LZW algorithm in this file. * - ************************************************************************** - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - */ - -/* - * This code is loosely based on ppmtogif from the PBMPLUS distribution - * of Feb. 1991. That file contains the following copyright notice: - * Based on GIFENCODE by David Rowley . - * Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al. - * Copyright (C) 1989 by Jef Poskanzer. - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation. This software is provided "as is" without express or - * implied warranty. - * - * We are also required to state that - * "The Graphics Interchange Format(c) is the Copyright property of - * CompuServe Incorporated. GIF(sm) is a Service Mark property of - * CompuServe Incorporated." - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef GIF_SUPPORTED - - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - j_decompress_ptr cinfo; /* back link saves passing separate parm */ - - /* State for packing variable-width codes into a bitstream */ - int n_bits; /* current number of bits/code */ - int maxcode; /* maximum code, given n_bits */ - INT32 cur_accum; /* holds bits not yet output */ - int cur_bits; /* # of bits in cur_accum */ - - /* State for GIF code assignment */ - int ClearCode; /* clear code (doesn't change) */ - int EOFCode; /* EOF code (ditto) */ - int code_counter; /* counts output symbols */ - - /* GIF data packet construction buffer */ - int bytesinpkt; /* # of bytes in current packet */ - char packetbuf[256]; /* workspace for accumulating packet */ - -} gif_dest_struct; - -typedef gif_dest_struct * gif_dest_ptr; - -/* Largest value that will fit in N bits */ -#define MAXCODE(n_bits) ((1 << (n_bits)) - 1) - - -/* - * Routines to package finished data bytes into GIF data blocks. - * A data block consists of a count byte (1..255) and that many data bytes. - */ - -LOCAL(void) -flush_packet (gif_dest_ptr dinfo) -/* flush any accumulated data */ -{ - if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */ - dinfo->packetbuf[0] = (char) dinfo->bytesinpkt++; - if (JFWRITE(dinfo->pub.output_file, dinfo->packetbuf, dinfo->bytesinpkt) - != (size_t) dinfo->bytesinpkt) - ERREXIT(dinfo->cinfo, JERR_FILE_WRITE); - dinfo->bytesinpkt = 0; - } -} - - -/* Add a character to current packet; flush to disk if necessary */ -#define CHAR_OUT(dinfo,c) \ - { (dinfo)->packetbuf[++(dinfo)->bytesinpkt] = (char) (c); \ - if ((dinfo)->bytesinpkt >= 255) \ - flush_packet(dinfo); \ - } - - -/* Routine to convert variable-width codes into a byte stream */ - -LOCAL(void) -output (gif_dest_ptr dinfo, int code) -/* Emit a code of n_bits bits */ -/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */ -{ - dinfo->cur_accum |= ((INT32) code) << dinfo->cur_bits; - dinfo->cur_bits += dinfo->n_bits; - - while (dinfo->cur_bits >= 8) { - CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); - dinfo->cur_accum >>= 8; - dinfo->cur_bits -= 8; - } -} - - -/* The pseudo-compression algorithm. - * - * In this module we simply output each pixel value as a separate symbol; - * thus, no compression occurs. In fact, there is expansion of one bit per - * pixel, because we use a symbol width one bit wider than the pixel width. - * - * GIF ordinarily uses variable-width symbols, and the decoder will expect - * to ratchet up the symbol width after a fixed number of symbols. - * To simplify the logic and keep the expansion penalty down, we emit a - * GIF Clear code to reset the decoder just before the width would ratchet up. - * Thus, all the symbols in the output file will have the same bit width. - * Note that emitting the Clear codes at the right times is a mere matter of - * counting output symbols and is in no way dependent on the LZW patent. - * - * With a small basic pixel width (low color count), Clear codes will be - * needed very frequently, causing the file to expand even more. So this - * simplistic approach wouldn't work too well on bilevel images, for example. - * But for output of JPEG conversions the pixel width will usually be 8 bits - * (129 to 256 colors), so the overhead added by Clear symbols is only about - * one symbol in every 256. - */ - -LOCAL(void) -compress_init (gif_dest_ptr dinfo, int i_bits) -/* Initialize pseudo-compressor */ -{ - /* init all the state variables */ - dinfo->n_bits = i_bits; - dinfo->maxcode = MAXCODE(dinfo->n_bits); - dinfo->ClearCode = (1 << (i_bits - 1)); - dinfo->EOFCode = dinfo->ClearCode + 1; - dinfo->code_counter = dinfo->ClearCode + 2; - /* init output buffering vars */ - dinfo->bytesinpkt = 0; - dinfo->cur_accum = 0; - dinfo->cur_bits = 0; - /* GIF specifies an initial Clear code */ - output(dinfo, dinfo->ClearCode); -} - - -LOCAL(void) -compress_pixel (gif_dest_ptr dinfo, int c) -/* Accept and "compress" one pixel value. - * The given value must be less than n_bits wide. - */ -{ - /* Output the given pixel value as a symbol. */ - output(dinfo, c); - /* Issue Clear codes often enough to keep the reader from ratcheting up - * its symbol size. - */ - if (dinfo->code_counter < dinfo->maxcode) { - dinfo->code_counter++; - } else { - output(dinfo, dinfo->ClearCode); - dinfo->code_counter = dinfo->ClearCode + 2; /* reset the counter */ - } -} - - -LOCAL(void) -compress_term (gif_dest_ptr dinfo) -/* Clean up at end */ -{ - /* Send an EOF code */ - output(dinfo, dinfo->EOFCode); - /* Flush the bit-packing buffer */ - if (dinfo->cur_bits > 0) { - CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); - } - /* Flush the packet buffer */ - flush_packet(dinfo); -} - - -/* GIF header construction */ - - -LOCAL(void) -put_word (gif_dest_ptr dinfo, unsigned int w) -/* Emit a 16-bit word, LSB first */ -{ - putc(w & 0xFF, dinfo->pub.output_file); - putc((w >> 8) & 0xFF, dinfo->pub.output_file); -} - - -LOCAL(void) -put_3bytes (gif_dest_ptr dinfo, int val) -/* Emit 3 copies of same byte value --- handy subr for colormap construction */ -{ - putc(val, dinfo->pub.output_file); - putc(val, dinfo->pub.output_file); - putc(val, dinfo->pub.output_file); -} - - -LOCAL(void) -emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap) -/* Output the GIF file header, including color map */ -/* If colormap==NULL, synthesize a gray-scale colormap */ -{ - int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte; - int cshift = dinfo->cinfo->data_precision - 8; - int i; - - if (num_colors > 256) - ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors); - /* Compute bits/pixel and related values */ - BitsPerPixel = 1; - while (num_colors > (1 << BitsPerPixel)) - BitsPerPixel++; - ColorMapSize = 1 << BitsPerPixel; - if (BitsPerPixel <= 1) - InitCodeSize = 2; - else - InitCodeSize = BitsPerPixel; - /* - * Write the GIF header. - * Note that we generate a plain GIF87 header for maximum compatibility. - */ - putc('G', dinfo->pub.output_file); - putc('I', dinfo->pub.output_file); - putc('F', dinfo->pub.output_file); - putc('8', dinfo->pub.output_file); - putc('7', dinfo->pub.output_file); - putc('a', dinfo->pub.output_file); - /* Write the Logical Screen Descriptor */ - put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); - put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); - FlagByte = 0x80; /* Yes, there is a global color table */ - FlagByte |= (BitsPerPixel-1) << 4; /* color resolution */ - FlagByte |= (BitsPerPixel-1); /* size of global color table */ - putc(FlagByte, dinfo->pub.output_file); - putc(0, dinfo->pub.output_file); /* Background color index */ - putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */ - /* Write the Global Color Map */ - /* If the color map is more than 8 bits precision, */ - /* we reduce it to 8 bits by shifting */ - for (i=0; i < ColorMapSize; i++) { - if (i < num_colors) { - if (colormap != NULL) { - if (dinfo->cinfo->out_color_space == JCS_RGB) { - /* Normal case: RGB color map */ - putc(GETJSAMPLE(colormap[0][i]) >> cshift, dinfo->pub.output_file); - putc(GETJSAMPLE(colormap[1][i]) >> cshift, dinfo->pub.output_file); - putc(GETJSAMPLE(colormap[2][i]) >> cshift, dinfo->pub.output_file); - } else { - /* Grayscale "color map": possible if quantizing grayscale image */ - put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift); - } - } else { - /* Create a gray-scale map of num_colors values, range 0..255 */ - put_3bytes(dinfo, (i * 255 + (num_colors-1)/2) / (num_colors-1)); - } - } else { - /* fill out the map to a power of 2 */ - put_3bytes(dinfo, 0); - } - } - /* Write image separator and Image Descriptor */ - putc(',', dinfo->pub.output_file); /* separator */ - put_word(dinfo, 0); /* left/top offset */ - put_word(dinfo, 0); - put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); /* image size */ - put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); - /* flag byte: not interlaced, no local color map */ - putc(0x00, dinfo->pub.output_file); - /* Write Initial Code Size byte */ - putc(InitCodeSize, dinfo->pub.output_file); - - /* Initialize for "compression" of image data */ - compress_init(dinfo, InitCodeSize+1); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - - if (cinfo->quantize_colors) - emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap); - else - emit_header(dest, 256, (JSAMPARRAY) NULL); -} - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - for (col = cinfo->output_width; col > 0; col--) { - compress_pixel(dest, GETJSAMPLE(*ptr++)); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - - /* Flush "compression" mechanism */ - compress_term(dest); - /* Write a zero-length data block to end the series */ - putc(0, dest->pub.output_file); - /* Write the GIF terminator mark */ - putc(';', dest->pub.output_file); - /* Make sure we wrote the output file OK */ - fflush(dest->pub.output_file); - if (ferror(dest->pub.output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for GIF format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_gif (j_decompress_ptr cinfo) -{ - gif_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (gif_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(gif_dest_struct)); - dest->cinfo = cinfo; /* make back link for subroutines */ - dest->pub.start_output = start_output_gif; - dest->pub.put_pixel_rows = put_pixel_rows; - dest->pub.finish_output = finish_output_gif; - - if (cinfo->out_color_space != JCS_GRAYSCALE && - cinfo->out_color_space != JCS_RGB) - ERREXIT(cinfo, JERR_GIF_COLORSPACE); - - /* Force quantization if color or if > 8 bits input */ - if (cinfo->out_color_space != JCS_GRAYSCALE || cinfo->data_precision > 8) { - /* Force quantization to at most 256 colors */ - cinfo->quantize_colors = TRUE; - if (cinfo->desired_number_of_colors > 256) - cinfo->desired_number_of_colors = 256; - } - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - if (cinfo->output_components != 1) /* safety check: just one component? */ - ERREXIT(cinfo, JERR_GIF_BUG); - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return (djpeg_dest_ptr) dest; -} - -#endif /* GIF_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/wrjpgcom.c b/freeimage241/Source/LibJPEG/wrjpgcom.c deleted file mode 100644 index 8c04b05..0000000 --- a/freeimage241/Source/LibJPEG/wrjpgcom.c +++ /dev/null @@ -1,583 +0,0 @@ -/* - * wrjpgcom.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a very simple stand-alone application that inserts - * user-supplied text as a COM (comment) marker in a JFIF file. - * This may be useful as an example of the minimum logic needed to parse - * JPEG markers. - */ - -#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ -#include "jinclude.h" /* get auto-config symbols, */ - -#ifndef HAVE_STDLIB_H /* should declare malloc() */ -extern void * malloc (); -#endif -#include /* to declare isupper(), tolower() */ -#ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ -#endif - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define WRITE_BINARY "w" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define WRITE_BINARY "wb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define WRITE_BINARY "wb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif - -/* Reduce this value if your malloc() can't allocate blocks up to 64K. - * On DOS, compiling in large model is usually a better solution. - */ - -#ifndef MAX_COM_LENGTH -#define MAX_COM_LENGTH 65000L /* must be <= 65533 in any case */ -#endif - - -/* - * These macros are used to read the input file and write the output file. - * To reuse this code in another application, you might need to change these. - */ - -static FILE * infile; /* input JPEG file */ - -/* Return next input byte, or EOF if no more */ -#define NEXTBYTE() getc(infile) - -static FILE * outfile; /* output JPEG file */ - -/* Emit an output byte */ -#define PUTBYTE(x) putc((x), outfile) - - -/* Error exit handler */ -#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) - - -/* Read one byte, testing for EOF */ -static int -read_1_byte (void) -{ - int c; - - c = NEXTBYTE(); - if (c == EOF) - ERREXIT("Premature EOF in JPEG file"); - return c; -} - -/* Read 2 bytes, convert to unsigned int */ -/* All 2-byte quantities in JPEG markers are MSB first */ -static unsigned int -read_2_bytes (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - if (c1 == EOF) - ERREXIT("Premature EOF in JPEG file"); - c2 = NEXTBYTE(); - if (c2 == EOF) - ERREXIT("Premature EOF in JPEG file"); - return (((unsigned int) c1) << 8) + ((unsigned int) c2); -} - - -/* Routines to write data to output file */ - -static void -write_1_byte (int c) -{ - PUTBYTE(c); -} - -static void -write_2_bytes (unsigned int val) -{ - PUTBYTE((val >> 8) & 0xFF); - PUTBYTE(val & 0xFF); -} - -static void -write_marker (int marker) -{ - PUTBYTE(0xFF); - PUTBYTE(marker); -} - -static void -copy_rest_of_file (void) -{ - int c; - - while ((c = NEXTBYTE()) != EOF) - PUTBYTE(c); -} - - -/* - * JPEG markers consist of one or more 0xFF bytes, followed by a marker - * code byte (which is not an FF). Here are the marker codes of interest - * in this program. (See jdmarker.c for a more complete list.) - */ - -#define M_SOF0 0xC0 /* Start Of Frame N */ -#define M_SOF1 0xC1 /* N indicates which compression process */ -#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ -#define M_SOF3 0xC3 -#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ -#define M_SOF6 0xC6 -#define M_SOF7 0xC7 -#define M_SOF9 0xC9 -#define M_SOF10 0xCA -#define M_SOF11 0xCB -#define M_SOF13 0xCD -#define M_SOF14 0xCE -#define M_SOF15 0xCF -#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ -#define M_EOI 0xD9 /* End Of Image (end of datastream) */ -#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ -#define M_COM 0xFE /* COMment */ - - -/* - * Find the next JPEG marker and return its marker code. - * We expect at least one FF byte, possibly more if the compressor used FFs - * to pad the file. (Padding FFs will NOT be replicated in the output file.) - * There could also be non-FF garbage between markers. The treatment of such - * garbage is unspecified; we choose to skip over it but emit a warning msg. - * NB: this routine must not be used after seeing SOS marker, since it will - * not deal correctly with FF/00 sequences in the compressed image data... - */ - -static int -next_marker (void) -{ - int c; - int discarded_bytes = 0; - - /* Find 0xFF byte; count and skip any non-FFs. */ - c = read_1_byte(); - while (c != 0xFF) { - discarded_bytes++; - c = read_1_byte(); - } - /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs - * are legal as pad bytes, so don't count them in discarded_bytes. - */ - do { - c = read_1_byte(); - } while (c == 0xFF); - - if (discarded_bytes != 0) { - fprintf(stderr, "Warning: garbage data found in JPEG file\n"); - } - - return c; -} - - -/* - * Read the initial marker, which should be SOI. - * For a JFIF file, the first two bytes of the file should be literally - * 0xFF M_SOI. To be more general, we could use next_marker, but if the - * input file weren't actually JPEG at all, next_marker might read the whole - * file and then return a misleading error message... - */ - -static int -first_marker (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - c2 = NEXTBYTE(); - if (c1 != 0xFF || c2 != M_SOI) - ERREXIT("Not a JPEG file"); - return c2; -} - - -/* - * Most types of marker are followed by a variable-length parameter segment. - * This routine skips over the parameters for any marker we don't otherwise - * want to process. - * Note that we MUST skip the parameter segment explicitly in order not to - * be fooled by 0xFF bytes that might appear within the parameter segment; - * such bytes do NOT introduce new markers. - */ - -static void -copy_variable (void) -/* Copy an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - write_2_bytes(length); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - write_1_byte(read_1_byte()); - length--; - } -} - -static void -skip_variable (void) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - (void) read_1_byte(); - length--; - } -} - - -/* - * Parse the marker stream until SOFn or EOI is seen; - * copy data to output, but discard COM markers unless keep_COM is true. - */ - -static int -scan_JPEG_header (int keep_COM) -{ - int marker; - - /* Expect SOI at start of file */ - if (first_marker() != M_SOI) - ERREXIT("Expected SOI marker first"); - write_marker(M_SOI); - - /* Scan miscellaneous markers until we reach SOFn. */ - for (;;) { - marker = next_marker(); - switch (marker) { - /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, - * treated as SOFn. C4 in particular is actually DHT. - */ - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - case M_SOF2: /* Progressive, Huffman */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_SOF9: /* Extended sequential, arithmetic */ - case M_SOF10: /* Progressive, arithmetic */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - return marker; - - case M_SOS: /* should not see compressed data before SOF */ - ERREXIT("SOS without prior SOFn"); - break; - - case M_EOI: /* in case it's a tables-only JPEG stream */ - return marker; - - case M_COM: /* Existing COM: conditionally discard */ - if (keep_COM) { - write_marker(marker); - copy_variable(); - } else { - skip_variable(); - } - break; - - default: /* Anything else just gets copied */ - write_marker(marker); - copy_variable(); /* we assume it has a parameter count... */ - break; - } - } /* end loop */ -} - - -/* Command line parsing code */ - -static const char * progname; /* program name for error messages */ - - -static void -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "wrjpgcom inserts a textual comment in a JPEG file.\n"); - fprintf(stderr, "You can add to or replace any existing comment(s).\n"); - - fprintf(stderr, "Usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -replace Delete any existing comments\n"); - fprintf(stderr, " -comment \"text\" Insert comment with given text\n"); - fprintf(stderr, " -cfile name Read comment from named file\n"); - fprintf(stderr, "Notice that you must put quotes around the comment text\n"); - fprintf(stderr, "when you use -comment.\n"); - fprintf(stderr, "If you do not give either -comment or -cfile on the command line,\n"); - fprintf(stderr, "then the comment text is read from standard input.\n"); - fprintf(stderr, "It can be multiple lines, up to %u characters total.\n", - (unsigned int) MAX_COM_LENGTH); -#ifndef TWO_FILE_COMMANDLINE - fprintf(stderr, "You must specify an input JPEG file name when supplying\n"); - fprintf(stderr, "comment text from standard input.\n"); -#endif - - exit(EXIT_FAILURE); -} - - -static int -keymatch (char * arg, const char * keyword, int minchars) -/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ -/* keyword is the constant keyword (must be lower case already), */ -/* minchars is length of minimum legal abbreviation. */ -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return 0; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return 0; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return 0; - return 1; /* A-OK */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - int argn; - char * arg; - int keep_COM = 1; - char * comment_arg = NULL; - FILE * comment_file = NULL; - unsigned int comment_length = 0; - int marker; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "wrjpgcom"; /* in case C library doesn't provide it */ - - /* Parse switches, if any */ - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (arg[0] != '-') - break; /* not switch, must be file name */ - arg++; /* advance over '-' */ - if (keymatch(arg, "replace", 1)) { - keep_COM = 0; - } else if (keymatch(arg, "cfile", 2)) { - if (++argn >= argc) usage(); - if ((comment_file = fopen(argv[argn], "r")) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else if (keymatch(arg, "comment", 1)) { - if (++argn >= argc) usage(); - comment_arg = argv[argn]; - /* If the comment text starts with '"', then we are probably running - * under MS-DOG and must parse out the quoted string ourselves. Sigh. - */ - if (comment_arg[0] == '"') { - comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); - if (comment_arg == NULL) - ERREXIT("Insufficient memory"); - strcpy(comment_arg, argv[argn]+1); - for (;;) { - comment_length = (unsigned int) strlen(comment_arg); - if (comment_length > 0 && comment_arg[comment_length-1] == '"') { - comment_arg[comment_length-1] = '\0'; /* zap terminating quote */ - break; - } - if (++argn >= argc) - ERREXIT("Missing ending quote mark"); - strcat(comment_arg, " "); - strcat(comment_arg, argv[argn]); - } - } - comment_length = (unsigned int) strlen(comment_arg); - } else - usage(); - } - - /* Cannot use both -comment and -cfile. */ - if (comment_arg != NULL && comment_file != NULL) - usage(); - /* If there is neither -comment nor -cfile, we will read the comment text - * from stdin; in this case there MUST be an input JPEG file name. - */ - if (comment_arg == NULL && comment_file == NULL && argn >= argc) - usage(); - - /* Open the input file. */ - if (argn < argc) { - if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdin\n", progname); - exit(EXIT_FAILURE); - } -#else - infile = stdin; -#endif - } - - /* Open the output file. */ -#ifdef TWO_FILE_COMMANDLINE - /* Must have explicit output file name */ - if (argn != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - if ((outfile = fopen(argv[argn+1], WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn+1]); - exit(EXIT_FAILURE); - } -#else - /* Unix style: expect zero or one file name */ - if (argn < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } - /* default output file is stdout */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdout), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdout\n", progname); - exit(EXIT_FAILURE); - } -#else - outfile = stdout; -#endif -#endif /* TWO_FILE_COMMANDLINE */ - - /* Collect comment text from comment_file or stdin, if necessary */ - if (comment_arg == NULL) { - FILE * src_file; - int c; - - comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); - if (comment_arg == NULL) - ERREXIT("Insufficient memory"); - comment_length = 0; - src_file = (comment_file != NULL ? comment_file : stdin); - while ((c = getc(src_file)) != EOF) { - if (comment_length >= (unsigned int) MAX_COM_LENGTH) { - fprintf(stderr, "Comment text may not exceed %u bytes\n", - (unsigned int) MAX_COM_LENGTH); - exit(EXIT_FAILURE); - } - comment_arg[comment_length++] = (char) c; - } - if (comment_file != NULL) - fclose(comment_file); - } - - /* Copy JPEG headers until SOFn marker; - * we will insert the new comment marker just before SOFn. - * This (a) causes the new comment to appear after, rather than before, - * existing comments; and (b) ensures that comments come after any JFIF - * or JFXX markers, as required by the JFIF specification. - */ - marker = scan_JPEG_header(keep_COM); - /* Insert the new COM marker, but only if nonempty text has been supplied */ - if (comment_length > 0) { - write_marker(M_COM); - write_2_bytes(comment_length + 2); - while (comment_length > 0) { - write_1_byte(*comment_arg++); - comment_length--; - } - } - /* Duplicate the remainder of the source file. - * Note that any COM markers occuring after SOF will not be touched. - */ - write_marker(marker); - copy_rest_of_file(); - - /* All done. */ - exit(EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/freeimage241/Source/LibJPEG/wrppm.c b/freeimage241/Source/LibJPEG/wrppm.c deleted file mode 100644 index 6c6d908..0000000 --- a/freeimage241/Source/LibJPEG/wrppm.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * wrppm.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in PPM/PGM format. - * The extended 2-byte-per-sample raw PPM/PGM formats are supported. - * The PBMPLUS library is NOT required to compile this software - * (but it is highly useful as a set of PPM image manipulation programs). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef PPM_SUPPORTED - - -/* - * For 12-bit JPEG data, we either downscale the values to 8 bits - * (to write standard byte-per-sample PPM/PGM files), or output - * nonstandard word-per-sample PPM/PGM files. Downscaling is done - * if PPM_NORAWWORD is defined (this can be done in the Makefile - * or in jconfig.h). - * (When the core library supports data precision reduction, a cleaner - * implementation will be to ask for that instead.) - */ - -#if BITS_IN_JSAMPLE == 8 -#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v) -#define BYTESPERSAMPLE 1 -#define PPM_MAXVAL 255 -#else -#ifdef PPM_NORAWWORD -#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8)) -#define BYTESPERSAMPLE 1 -#define PPM_MAXVAL 255 -#else -/* The word-per-sample format always puts the LSB first. */ -#define PUTPPMSAMPLE(ptr,v) \ - { register int val_ = v; \ - *ptr++ = (char) (val_ & 0xFF); \ - *ptr++ = (char) ((val_ >> 8) & 0xFF); \ - } -#define BYTESPERSAMPLE 2 -#define PPM_MAXVAL ((1<pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * This code is used when we have to copy the data and apply a pixel - * format translation. Typically this only happens in 12-bit mode. - */ - -METHODDEF(void) -copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - bufferptr = dest->iobuffer; - for (col = dest->samples_per_row; col > 0; col--) { - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(*ptr++)); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Write some pixel data when color quantization is in effect. - * We have to demap the color index values to straight data. - */ - -METHODDEF(void) -put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register int pixval; - register JSAMPROW ptr; - register JSAMPROW color_map0 = cinfo->colormap[0]; - register JSAMPROW color_map1 = cinfo->colormap[1]; - register JSAMPROW color_map2 = cinfo->colormap[2]; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - bufferptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - pixval = GETJSAMPLE(*ptr++); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[pixval])); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map1[pixval])); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map2[pixval])); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -METHODDEF(void) -put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register JSAMPROW ptr; - register JSAMPROW color_map = cinfo->colormap[0]; - register JDIMENSION col; - - ptr = dest->pub.buffer[0]; - bufferptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map[GETJSAMPLE(*ptr++)])); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - - /* Emit file header */ - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - /* emit header for raw PGM format */ - fprintf(dest->pub.output_file, "P5\n%ld %ld\n%d\n", - (long) cinfo->output_width, (long) cinfo->output_height, - PPM_MAXVAL); - break; - case JCS_RGB: - /* emit header for raw PPM format */ - fprintf(dest->pub.output_file, "P6\n%ld %ld\n%d\n", - (long) cinfo->output_width, (long) cinfo->output_height, - PPM_MAXVAL); - break; - default: - ERREXIT(cinfo, JERR_PPM_COLORSPACE); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* Make sure we wrote the output file OK */ - fflush(dinfo->output_file); - if (ferror(dinfo->output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for PPM format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_ppm (j_decompress_ptr cinfo) -{ - ppm_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (ppm_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ppm_dest_struct)); - dest->pub.start_output = start_output_ppm; - dest->pub.finish_output = finish_output_ppm; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Create physical I/O buffer. Note we make this near on a PC. */ - dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; - dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char)); - dest->iobuffer = (char *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width); - - if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 || - SIZEOF(JSAMPLE) != SIZEOF(char)) { - /* When quantizing, we need an output buffer for colormap indexes - * that's separate from the physical I/O buffer. We also need a - * separate buffer if pixel format translation must take place. - */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width * cinfo->output_components, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - if (! cinfo->quantize_colors) - dest->pub.put_pixel_rows = copy_pixel_rows; - else if (cinfo->out_color_space == JCS_GRAYSCALE) - dest->pub.put_pixel_rows = put_demapped_gray; - else - dest->pub.put_pixel_rows = put_demapped_rgb; - } else { - /* We will fwrite() directly from decompressor output buffer. */ - /* Synthesize a JSAMPARRAY pointer structure */ - /* Cast here implies near->far pointer conversion on PCs */ - dest->pixrow = (JSAMPROW) dest->iobuffer; - dest->pub.buffer = & dest->pixrow; - dest->pub.buffer_height = 1; - dest->pub.put_pixel_rows = put_pixel_rows; - } - - return (djpeg_dest_ptr) dest; -} - -#endif /* PPM_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/wrrle.c b/freeimage241/Source/LibJPEG/wrrle.c deleted file mode 100644 index a4e7337..0000000 --- a/freeimage241/Source/LibJPEG/wrrle.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - * wrrle.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in RLE format. - * The Utah Raster Toolkit library is required (version 3.1 or later). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * Based on code contributed by Mike Lijewski, - * with updates from Robert Hutchinson. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef RLE_SUPPORTED - -/* rle.h is provided by the Utah Raster Toolkit. */ - -#include - -/* - * We assume that JSAMPLE has the same representation as rle_pixel, - * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - - -/* - * Since RLE stores scanlines bottom-to-top, we have to invert the image - * from JPEG's top-to-bottom order. To do this, we save the outgoing data - * in a virtual array during put_pixel_row calls, then actually emit the - * RLE file during finish_output. - */ - - -/* - * For now, if we emit an RLE color map then it is always 256 entries long, - * though not all of the entries need be used. - */ - -#define CMAPBITS 8 -#define CMAPLENGTH (1<<(CMAPBITS)) - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - jvirt_sarray_ptr image; /* virtual array to store the output image */ - rle_map *colormap; /* RLE-style color map, or NULL if none */ - rle_pixel **rle_row; /* To pass rows to rle_putrow() */ - -} rle_dest_struct; - -typedef rle_dest_struct * rle_dest_ptr; - -/* Forward declarations */ -METHODDEF(void) rle_put_pixel_rows - JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied)); - - -/* - * Write the file header. - * - * In this module it's easier to wait till finish_output to write anything. - */ - -METHODDEF(void) -start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - size_t cmapsize; - int i, ci; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* - * Make sure the image can be stored in RLE format. - * - * - RLE stores image dimensions as *signed* 16 bit integers. JPEG - * uses unsigned, so we have to check the width. - * - * - Colorspace is expected to be grayscale or RGB. - * - * - The number of channels (components) is expected to be 1 (grayscale/ - * pseudocolor) or 3 (truecolor/directcolor). - * (could be 2 or 4 if using an alpha channel, but we aren't) - */ - - if (cinfo->output_width > 32767 || cinfo->output_height > 32767) - ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width, - cinfo->output_height); - - if (cinfo->out_color_space != JCS_GRAYSCALE && - cinfo->out_color_space != JCS_RGB) - ERREXIT(cinfo, JERR_RLE_COLORSPACE); - - if (cinfo->output_components != 1 && cinfo->output_components != 3) - ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components); - - /* Convert colormap, if any, to RLE format. */ - - dest->colormap = NULL; - - if (cinfo->quantize_colors) { - /* Allocate storage for RLE-style cmap, zero any extra entries */ - cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); - dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); - MEMZERO(dest->colormap, cmapsize); - - /* Save away data in RLE format --- note 8-bit left shift! */ - /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */ - for (ci = 0; ci < cinfo->out_color_components; ci++) { - for (i = 0; i < cinfo->actual_number_of_colors; i++) { - dest->colormap[ci * CMAPLENGTH + i] = - GETJSAMPLE(cinfo->colormap[ci][i]) << 8; - } - } - } - - /* Set the output buffer to the first row */ - dest->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE); - dest->pub.buffer_height = 1; - - dest->pub.put_pixel_rows = rle_put_pixel_rows; - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->total_extra_passes++; /* count file writing as separate pass */ - } -#endif -} - - -/* - * Write some pixel data. - * - * This routine just saves the data away in a virtual array. - */ - -METHODDEF(void) -rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - - if (cinfo->output_scanline < cinfo->output_height) { - dest->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - cinfo->output_scanline, (JDIMENSION) 1, TRUE); - } -} - -/* - * Finish up at the end of the file. - * - * Here is where we really output the RLE file. - */ - -METHODDEF(void) -finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - rle_hdr header; /* Output file information */ - rle_pixel **rle_row, *red, *green, *blue; - JSAMPROW output_row; - char cmapcomment[80]; - int row, col; - int ci; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* Initialize the header info */ - header = *rle_hdr_init(NULL); - header.rle_file = dest->pub.output_file; - header.xmin = 0; - header.xmax = cinfo->output_width - 1; - header.ymin = 0; - header.ymax = cinfo->output_height - 1; - header.alpha = 0; - header.ncolors = cinfo->output_components; - for (ci = 0; ci < cinfo->output_components; ci++) { - RLE_SET_BIT(header, ci); - } - if (cinfo->quantize_colors) { - header.ncmap = cinfo->out_color_components; - header.cmaplen = CMAPBITS; - header.cmap = dest->colormap; - /* Add a comment to the output image with the true colormap length. */ - sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors); - rle_putcom(cmapcomment, &header); - } - - /* Emit the RLE header and color map (if any) */ - rle_put_setup(&header); - - /* Now output the RLE data from our virtual array. - * We assume here that (a) rle_pixel is represented the same as JSAMPLE, - * and (b) we are not on a machine where FAR pointers differ from regular. - */ - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_limit = cinfo->output_height; - progress->pub.pass_counter = 0; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - - if (cinfo->output_components == 1) { - for (row = cinfo->output_height-1; row >= 0; row--) { - rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - (JDIMENSION) row, (JDIMENSION) 1, FALSE); - rle_putrow(rle_row, (int) cinfo->output_width, &header); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } else { - for (row = cinfo->output_height-1; row >= 0; row--) { - rle_row = (rle_pixel **) dest->rle_row; - output_row = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - (JDIMENSION) row, (JDIMENSION) 1, FALSE); - red = rle_row[0]; - green = rle_row[1]; - blue = rle_row[2]; - for (col = cinfo->output_width; col > 0; col--) { - *red++ = GETJSAMPLE(*output_row++); - *green++ = GETJSAMPLE(*output_row++); - *blue++ = GETJSAMPLE(*output_row++); - } - rle_putrow(rle_row, (int) cinfo->output_width, &header); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) - progress->completed_extra_passes++; -#endif - - /* Emit file trailer */ - rle_puteof(&header); - fflush(dest->pub.output_file); - if (ferror(dest->pub.output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for RLE format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_rle (j_decompress_ptr cinfo) -{ - rle_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (rle_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(rle_dest_struct)); - dest->pub.start_output = start_output_rle; - dest->pub.finish_output = finish_output_rle; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Allocate a work array for output to the RLE library. */ - dest->rle_row = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width, (JDIMENSION) cinfo->output_components); - - /* Allocate a virtual array to hold the image. */ - dest->image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) (cinfo->output_width * cinfo->output_components), - cinfo->output_height, (JDIMENSION) 1); - - return (djpeg_dest_ptr) dest; -} - -#endif /* RLE_SUPPORTED */ diff --git a/freeimage241/Source/LibJPEG/wrtarga.c b/freeimage241/Source/LibJPEG/wrtarga.c deleted file mode 100644 index cf104d2..0000000 --- a/freeimage241/Source/LibJPEG/wrtarga.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * wrtarga.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in Targa format. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * Based on code contributed by Lee Daniel Crocker. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef TARGA_SUPPORTED - - -/* - * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. - * This is not yet implemented. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * The output buffer needs to be writable by fwrite(). On PCs, we must - * allocate the buffer in near data space, because we are assuming small-data - * memory model, wherein fwrite() can't reach far memory. If you need to - * process very wide images on a PC, you might have to compile in large-memory - * model, or else replace fwrite() with a putc() loop --- which will be much - * slower. - */ - - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - char *iobuffer; /* physical I/O buffer */ - JDIMENSION buffer_width; /* width of one row */ -} tga_dest_struct; - -typedef tga_dest_struct * tga_dest_ptr; - - -LOCAL(void) -write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors) -/* Create and write a Targa header */ -{ - char targaheader[18]; - - /* Set unused fields of header to 0 */ - MEMZERO(targaheader, SIZEOF(targaheader)); - - if (num_colors > 0) { - targaheader[1] = 1; /* color map type 1 */ - targaheader[5] = (char) (num_colors & 0xFF); - targaheader[6] = (char) (num_colors >> 8); - targaheader[7] = 24; /* 24 bits per cmap entry */ - } - - targaheader[12] = (char) (cinfo->output_width & 0xFF); - targaheader[13] = (char) (cinfo->output_width >> 8); - targaheader[14] = (char) (cinfo->output_height & 0xFF); - targaheader[15] = (char) (cinfo->output_height >> 8); - targaheader[17] = 0x20; /* Top-down, non-interlaced */ - - if (cinfo->out_color_space == JCS_GRAYSCALE) { - targaheader[2] = 3; /* image type = uncompressed gray-scale */ - targaheader[16] = 8; /* bits per pixel */ - } else { /* must be RGB */ - if (num_colors > 0) { - targaheader[2] = 1; /* image type = colormapped RGB */ - targaheader[16] = 8; - } else { - targaheader[2] = 2; /* image type = uncompressed RGB */ - targaheader[16] = 24; - } - } - - if (JFWRITE(dinfo->output_file, targaheader, 18) != (size_t) 18) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* used for unquantized full-color output */ -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - outptr[0] = (char) GETJSAMPLE(inptr[2]); /* RGB to BGR order */ - outptr[1] = (char) GETJSAMPLE(inptr[1]); - outptr[2] = (char) GETJSAMPLE(inptr[0]); - inptr += 3, outptr += 3; - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - -METHODDEF(void) -put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* used for grayscale OR quantized color output */ -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = (char) GETJSAMPLE(*inptr++); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Write some demapped pixel data when color quantization is in effect. - * For Targa, this is only applied to grayscale data. - */ - -METHODDEF(void) -put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JSAMPROW color_map0 = cinfo->colormap[0]; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = (char) GETJSAMPLE(color_map0[GETJSAMPLE(*inptr++)]); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - int num_colors, i; - FILE *outfile; - - if (cinfo->out_color_space == JCS_GRAYSCALE) { - /* Targa doesn't have a mapped grayscale format, so we will */ - /* demap quantized gray output. Never emit a colormap. */ - write_header(cinfo, dinfo, 0); - if (cinfo->quantize_colors) - dest->pub.put_pixel_rows = put_demapped_gray; - else - dest->pub.put_pixel_rows = put_gray_rows; - } else if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* We only support 8-bit colormap indexes, so only 256 colors */ - num_colors = cinfo->actual_number_of_colors; - if (num_colors > 256) - ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors); - write_header(cinfo, dinfo, num_colors); - /* Write the colormap. Note Targa uses BGR byte order */ - outfile = dest->pub.output_file; - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile); - putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile); - putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile); - } - dest->pub.put_pixel_rows = put_gray_rows; - } else { - write_header(cinfo, dinfo, 0); - dest->pub.put_pixel_rows = put_pixel_rows; - } - } else { - ERREXIT(cinfo, JERR_TGA_COLORSPACE); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* Make sure we wrote the output file OK */ - fflush(dinfo->output_file); - if (ferror(dinfo->output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for Targa format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_targa (j_decompress_ptr cinfo) -{ - tga_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (tga_dest_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(tga_dest_struct)); - dest->pub.start_output = start_output_tga; - dest->pub.finish_output = finish_output_tga; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Create I/O buffer. Note we make this near on a PC. */ - dest->buffer_width = cinfo->output_width * cinfo->output_components; - dest->iobuffer = (char *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (dest->buffer_width * SIZEOF(char))); - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return (djpeg_dest_ptr) dest; -} - -#endif /* TARGA_SUPPORTED */ diff --git a/freeimage241/Source/LibMNG/Changes b/freeimage241/Source/LibMNG/Changes deleted file mode 100644 index 6a9f8ef..0000000 --- a/freeimage241/Source/LibMNG/Changes +++ /dev/null @@ -1,792 +0,0 @@ ------------------------------------------------------------ - -1.0.2 (Jul 7th 2001) --------------------- - -in short: - -Another maintenance release with a few added extra's. - -------------------- - -bugfixes: -- B421427 - writes wrong format in bKGD and tRNS -- B434583 - compiler-warning if MNG_STORE_CHUNKS undefined - -core: -- added optimization option for MNG-video playback -- added processterm callback -- added late binding errorcode (not used internally) -- fixed memory-leak with delta-images (Thanks Michael!) -- added option to turn off progressive refresh for large images - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.1 (May 2nd 2001) --------------------- - -in short: - -Maintenance release. -Fixed several memory-leaks with the help of Gregg Kelly, added/fixed some CMS -handling, exported JPEG functions from standard DLL, and some other minor fixes. - -The CMS fix now makes libmng automagically work in MNG_FULL_CMS mode as a -sRGB compliant system. YOU WILL NEED TO CHANGE THIS IF YOU ARE NOT ON AN sRGB -COMPLIANT SYSTEM AND WANT TO USE CMS!!!! -(look in libmng.h for the proper function-calls) - -------------------- - -bugfixes: - -core: -- added MEND processing callback -- fixed first FRAM_MODE=4 timing problem -- added handle status-copy function (use with care) -- exported JPEG functions from standard DLL -- added BGRA8 canvas with premultiplied alpha (contrib by Gregg Kelly) -- fixed problem with display_reset/display_resume (Thanks Gregg!) -- fixed several memory-leaks (Thanks Gregg!) -- fixed reset_rundata to drop all objects (Thanks again, Gregg!) -- fixed problem with cms profile being created multiple times when both - iCCP & cHRM/gAMA are present (And again... Gregg) -- moved mng_clear_cms to libmng_cms -- added "default" sRGB generation (Thanks Marti!) - -samples: - -contrib: - -doc: - -makefiles: - -autoconf: - ------------------------------------------------------------ - -1.0.0 (Feb 6th 2001) --------------------- - -in short: - -First public release. Finally(!) - -This is the 0.9.5 CVS version, which will never be released, because I feel it -is now ready for a public release. So apart from the version-numbers here and -there, all other changes are listed under 0.9.5. - -This library will work with every MNG/JNG known and available to me. Note that -there are still parts that need to be coded, and that MNG support is around -90-95% (JNG at 100%). It is however compliant with the latest and greatest -MNG 1.0 specification. - -I hope to dedicate a bit more time this year to finish up full support and fill -in the remaining blanks. But this is coming out of my spare time. And extra -help is always appreciated. - -Please enjoy! - -Gerard - ------------------------------------------------------------ - -0.9.5 (no release) ------------------- - -in short: - -intermediate CVS - -------------------- - -bugfixes: -B129681 - fixed compiler warnings SGI/Irix (thanks Dimitri) - -core: -- fixed compiler-warnings Mozilla (thanks Tim) -- fixed timing-problem with switching framing_modes -- fixed some small compiler warnings (thanks Nikki) - -samples: - -contrib: -- fixed library-paths for MSVC DLL project (thanks Chad) - -doc: - -makefiles: -- added makefile for DJGPP (thanks Silvio) - -autoconf: - ------------------------------------------------------------ - -0.9.4 (Jan 19th 2001) ----------------------- - -in short: - -Now that the MNG spec is at 1.0, this should be the last beta. There's a few -small changes to make it inline with the spec, and a couple of bug-fixes. -This is a serious release-candidate for libmng-1.0!! -Please... test test test test!! - -------------------- - -bugfixes: -B123314 - fixed number of TERM related problems -B123322 - fixed unwanted repetition in mng_readdisplay() -B123443 - fixed by Ralph -B124910 - fixed definition for WIN32_LEAN_AND_MEAN (thanks Chad) -B125750 - fixed by Ralph -B125756 - fixed mixup of data- & function-pointers (thanks Dimitri) -B127517 - changed inclusion of the lcms header file for non-windows platforms - -core: -- version numbers -- fixed possible loop in display_resume() (Thanks Vova!) -- fixed unwanted repetition in mng_readdisplay() -- changed inclusion of the lcms header file for non-windows platforms -- changed IHDR filter_method check for PNGs -- moved restore of object 0 to libmng_display -- added restore of object 0 to TERM processing (B123314) -- fixed TERM delay processing (B123314) -- fixed TERM end processing when count = 0 (B123314) -- changed callback convention for MSVC (Thanks Chad) -- fixed mixup of data- & function-pointers (thanks Dimitri) -- added support for "nEED MNG-1.0" -- added errorcode for MAGN methods -- added errorchecking for MAGN methods -- removed "old" MAGN methods 3 & 4 -- added "new" MAGN methods 3, 4 & 5 -- removed test filter-methods 1 & 65 -- set default level-set for filtertype=64 to all zeroes - -samples: - -contrib: -- added GTK mng-view example by Vova Babin -- added MSVC MNGview sample by Nikolaus Brennig -- updated Jason Summer's mngplg to version 0.9.2 - (that's mngplg-0.9.2 based on libmng-0.9.3 !!!) -- rearranged contrib directory slightly -- added MSVC project to build libmng.dll by Chad Austin - -doc: -- added README.dll -- added README.config - -makefiles: -- added a makefile for MS Visual C++ (Thanks to Atsushi Matsuda) - -autoconf: -- fixed configure.in for lcms (FreeBSD port by Mikhail Teterin) -- by default configure includes CMS support if lcms is present - ------------------------------------------------------------ - -0.9.3 (October 29th 2000) -------------------------- - -in short: - -Another beta release. The number of changes in the MNG specification have -resulted in a lot of new code and some changed code. At the same time I saw -no need to withhold some new functionality as it was pretty clear there was -going to be another beta-round. If things go well, I'm going to try to release -libmng 1.0.0 very shortly after this one. - -Many thanks to a lot of people for helping out, sending contributions, making -suggestions and testing this little baby. This would get nowhere without YOU!!! - -- fixed bug 111300/117103 -- added workaround for faulty PhotoShop iCCP chunk -- added MAGN/JDAA chunks -- added support for new filter_types -- added PNG/MNG spec version indicators -- added BCB mngview contribution by Andy Protano -- added BCB mngdump; a GUI-based MNG dumping utility (Andy Protano) -- implemented support for nEED "draft nn" -- implemented app-defined support for bKGD for PNG images -- removed trace-options from default SO/DLL builds (!!!) -- raised initial maximum canvas size to 10000x10000 (!!!) - (an App that wants to protect from overly large images should call - mng_set_maxcanvassize() with appropriate values) -- fixed other assorted stuff - -------------------- - -bugfixes: -B111300 - fixup for improved portability -B117103 - fixed compilation errors on *nix with lcms (thanks Ralph!) - -core: -- fixed compiler-warnings from Mozilla -- added check for simplicity-bits in MHDR -- added workaround for faulty PhotoShop iCCP chunk -- fixed app-supplied background restore -- fixed TERM processing delay of 0 msecs -- fixed write-code for zTXt & iTXt -- fixed read-code for iTXt -- added MAGN chunk -- fixed sRGB precedence for gamma_only corection -- added support for new filter_types -- fixed problem with no refresh after TERM -- fixed DEFI behavior -- fixed inclusion parameters to make the external libs work together -- added export of zlib functions from windows dll -- fixed timing & refresh behavior for single PNG/JNG -- removed trace-options from default SO/DLL builds (!!!) -- fixed MAGN rounding errors (thanks Matthias!) -- fixed small timing problem when FRAM delay = 0 -- fixed simplicity-check in compliance with draft 81/0.98a -- fixed alpha-blending for all alpha-canvasstyles -- added support for alpha-depth prediction -- fixed processing of unknown critical chunks -- removed test-MaGN -- added PNG/MNG spec version indicators -- implemented support for nEED -- added support for JDAA -- added functions to retrieve PNG/JNG specific header-info -- added optional support for bKGD for PNG images -- raised initial maximum canvas size to 10000x10000 -- added support for delta-JNG -- added callback to process non-critical unknown chunks -- fixed support for delta-images during read() / display() -- added closestream() processing for mng_cleanup() -- fixed delta-processing behavior -- added storage for pixel-/alpha-sampledepth for delta's -- implemented delayed delta-processing -- fixed putchunk_plte() to set bEmpty parameter (thanks Ben!) -- added errorcode for delayed delta-processing -- added get/set for bKGD preference setting -- added get function for interlace/progressive display -- fixed bug in empty PLTE handling -- fixed seperate read() & display() processing -- fixed tRNS processing for gray-image < 8-bits - -samples: -- added BCB mngview contribution by Andy Protano - -contrib: -- added BCB mngdump; a GUI-based MNG dumping utility (Andy Protano) - -doc: -- updated RPM spec-file by MATSUURA Takanori -- updated README.contrib - -makefiles: -- fixed some stuff in automake/autoconf/libtool -- fixed auto* for bug B117103 - ------------------------------------------------------------ - -0.9.2 (August 7th 2000) ------------------------ - -in short: - -Third beta release! Last one??? - -!!IMPORTANT!! All file-names are now prefixed with "libmng_" !!IMPORTANT!! - -Many thanks to Albert Chin-A-Young for his contribution of the -autoconf/automake/libtool stuff and to Ralph Giles for helping me -put it in the right places. - -There's a special README.autoconf so please read it! - -- fixed bug 110320/110546/110547/111096 -- added several status retrieval functions -- fixed other small bugs in display processing -- fixed number of small problems and documentation typos -- added autoconf/automake/libtool -- added latest MNG plugin (0.9.0) by Jason Summers - -------------------- - -bugfixes: -B110320 - fixed GCC warning about mix-sized pointer math -B110546 - fixed for improperly returning UNEXPECTEDEOF -B110547 - fixed bug in interlace code -B111096 - fixed large-buffer read-suspension - -core: -- version numbers -- fixed small bugs in display processing -- removed Nextbackxxx fields (no longer used) -- fixed problem with trace-functions improperly wrapped -- put specific code in add_chunk() inside MNG_SUPPORT_WRITE wrapper -- fixed documentation typos -- fixed wrapping of suspension parameters -- added status_xxxx functions -- added trace-codes/-strings for status_xxxxx functions -- changed file-prefixes -- added function to set simplicity field -- added trace-code/-string for updatemngsimplicity -- fixed putchunk_unknown() function - -samples: - -contrib: -- added latest MNG plugin (0.9.0) by Jason Summers - -doc: -- version numbers -- added autoconf readme -- version numbers in RPM stuff - -makefiles: -- fixed for new file-prefix -- added autoconf/automake/libtool - ------------------------------------------------------------ - -0.9.1 (July 26th 2000) ----------------------- - -in short: - -Second beta release. - -Given the enormous amount of bug-reports (not ;-), this will most likely -be one of the last betas. If things remain upright, the first public release -(1.0.0) is fairly eminent in the weeks to come... - -- added SDL mng player by Ralph Giles to contributions -- fixed timing and added internal buffering for I/O-suspension scenarios -- added get routines for internal display-state variables (frame/layer/playtime) -- changed read-processing for improved I/O-suspension (internal buffering) -- fixed several problems with create- & write-support -- added a load of documentation -- lots of small stuff - -------------------- - -bugfixes: - -core: -- fixed mandatory BACK color to be opaque -- changed mng_display_resume to allow to be called after a suspension - return with MNG_NEEDMOREDATA -- changed comments to indicate modified behavior for timer & suspension breaks -- added variables for go_xxxx processing -- implemented support for freeze/reset/resume & go_xxxx -- added trace-codes/-strings for special display processing -- added variables for improved timing support -- added support for improved timing -- added get routines for internal display variables -- added get/set routines for suspensionmode variable -- added trace-code/-string for get/set suspensionmode -- added trace-codes/-strings for get/set display variables -- added support for improved I/O-suspension -- changed read-processing for improved I/O-suspension -- added trace-code/-string for read_databuffer (I/O-suspension) -- added suspendbuffer constants -- changed EOF processing behavior -- fixed TERM delay processing -- changed pre-draft48 frame_mode=3 to frame_mode=1 -- added callbacks for SAVE/SEEK processing -- added trace-codes/-strings for SAVE/SEEK callbacks -- added variable for NEEDSECTIONWAIT breaks -- added trace-codes/-strings for get/set sectionbreaks -- added NEEDSECTIONWAIT error-code/-string -- added macro + routine to set returncode without calling error callback -- added trace-code/-string for special error routine -- changed default readbuffer size from 1024 to 4200 -- added variable for freeze & reset processing -- fixed storage of images during mng_read() -- fixed support for mng_display() after mng_read() -- added error cleanup processing -- fixed support for mng_display_reset() -- fixed suspension-buffering for 32K+ chunks -- added function to set frame-/layer-count & playtime -- added trace-code/-string for updatemngheader -- added error-code/-string for updatemngheader if not a MNG -- fixed creation-code -- fixed writing of signature -- fixed several chunk-writing routines - -samples: -- fixed the libmng.pas module in line with libmng.h - -contrib: -- added the SDL based mngplay viewer by Ralph Giles - -doc: -- extended the RPM contribution by MATSUURA Takanori -- added libmng.txt, a full description of the library and its usage -- added man-pages for mng(5), jng(5) and libmng(3) - -makefiles: - ------------------------------------------------------------ - -0.9.0 (June 30th 2000) ----------------------- - -in short: - -This is the first beta!!! Yippee!!! - -Thanks to all the people who helped to guide me in the right direction. -You know who you are! - -A special thanks to the guys with early implementations, who stood by and -put up with my whims :-) - -changes over 0.5.3: - -- updated mngplg to 0.4.1 (the latest & greatest) -- changed refresh parameters to 'x,y,width,height' - ------------------------------------------------------------ - -0.5.3 (never released) ----------------------- - -in short: - -This is a working version only; the next release will be 0.9.0 (first Beta!) - -There are a few incompatible changes with previous versions. The userdata -variable has been changed from mng_uint32 to mng_ptr to accomodate 64-bit -systems. For the same reason memory allocation size parameters have been -changed to a mng_size_t type which is a typedef of size_t. - -Thanks to Aleks Jakulin for helping to iron out some 64-bit platform issues! - -- implemented the update-region parameters of the refresh callback -- added support for most common delta-image options -- added an animation-speed modifier -- added an image-level parameter for the processtext callback -- updated mngplg to 0.4.0 (supports JNG, full CMS, and other enhancements!) -- fixed a lot of small things -- added support for PPLT chunk -- fixed to support 64-bit platforms - -------------------- - -bugfixes: - -core: -- added processing of color-info on delta-image -- fixed handling of empty SAVE chunk -- fixed display of stored JNG images -- fixed problem with BASI-IEND as object 0 -- changed the version parameters (obviously) -- added update-region parms for refresh calback -- added Needrefresh parameter -- added initialization of update-region for refresh -- added initialization of Needrefresh parameter -- changed progressive-display processing -- added tracecodes for tracing JPEG progression -- added tracing of JPEG calls -- added Deltaimmediate parm for faster delta-processing -- added extra checks for delta-images -- many changes to support delta-images -- optimized some store_xxx routines -- fixed some small things (as precaution) -- fixed possible trouble if IEND display-processing got broken up -- fixed nasty bug with embedded PNG after delta-image -- added processing of PLTE & tRNS for delta-images -- added processing of PLTE/tRNS & color-info for delta-images in the - ani_objects chain -- fixed problem with color-correction for stored images -- added get/set for speedtype to facilitate testing -- added trace-codes & -strings for get/set speedtype -- added speed-modifier to timing routine -- added get-routine of imagelevel for processtext callback -- added trace-code & -string for get imagelevel -- added administration of imagelevel parameter -- added support for PPLT chunk -- added trace-codes & -strings for PPLT chunk processing -- fixed problem with incorrect gamma-correction -- fixed inclusion of IJG read/write code -- fixed problem with 16-bit GA format -- fixed problem with cheap transparency for 4-bit gray -- fixed display_xxxx routines for interlaced images -- added precaution against faulty iCCP chunks from PS -- changed userdata variable to mng_ptr -- added typedef for mng_size_t -- changed size parameter for memory allocation to mng_size_t -- fixed compiler-warning for non-initialized iB variable -- changed definition for 32-bit ints (64-bit platforms) -- changed definition for mng_handle (64-bit platforms) -- swapped refresh parameters -- fixed initialization routine for new mng_handle type -- added inclusion of stdlib.h for abs() -- fixed some 64-bit warnings -- fixed incompatible return-types - -samples: - -contrib: -- updated mngplg to 0.3.0 (supports JNG & full color-correction!) -- updated mngplg to 0.4.0 (Jason is picking up the pace ;-) - -doc: -- added rpm directory with rpm spec-file (contributed by MATSUURA Takanori) - -makefiles: -- changed makefile.linux to reflect versionnr for shared-lib -- changed makefile.linux to depend on mng_conf.h & mng_types.h - ------------------------------------------------------------ - -0.5.2 (June 10th 2000) ----------------------- - -in short: - -This is the third release for developers -Another milestone since JNG is now fully supported -The next release will most likely be numbered 0.9.0 as the first Beta!! - -Fixed bug 106017 & 106019 -Added many constants regarding chunk-property values -Implemented full JNG support -Added all the error- & trace-strings -Added get/set routines for default ZLIB/IJG parameters -Added a generic makefile for Unix platforms (contributed by Tim Rowley) -Added canvasstyle for separate RGB + A canvas (eg. mozilla-style) -Separated configuration-options into a separate file: "mng_conf.h" -Fixed stuff for generic Unix compilation (contributed by Tim Rowley) -Upgraded to lcms1.0.6 (now supports 16-bit endian-peculiarities) -Added a makefile for Linux ELF & fixed some code-issues to go along with gcc -Added support for suspended input-buffer processing -Implemented the display-routines for RGBA/ARGB/BGRA/ABGR canvasstyles -Implemented the application background-restore functionality -Fixed & tested the mngtree Unix-sample (runs on Linux-RH6.2 with libmng.so) -Upgraded mngplg to v0.2.2 (based on the latest code including JNG) -Fixed a lot of other assorted stuff - -------------------- - -bugfixes: -B003(106017) - fixed problem with being proprietary to BCB -B004(106019) - fixed problem when MNG_SUPPORT_WRITE not defined - -core: -- bumped version-numbers up to 0.5.2 (yeah, really) -- fixed support for IJGSRC6B -- cleaned up some code regarding mixed support-options -- complemented constants for chunk-property values -- fixed MNG_UINT_pHYg value -- implemented JNG support -- fixed problem with DEFI clipping -- added error telltale strings & support -- added trace telltale strings & support -- added support for global color-chunks inside TERM/LOOP -- added support for global PLTE,tRNS,bKGD inside TERM/LOOP -- added default IJG compression parameters and such -- moved init of default zlib parms to "mng_hlapi.c" -- added init of default IJG parms -- added support for get/set of zlib/IJG default parms -- added tracestrings for global animation color-chunks -- added tracestrings for get/set of default ZLIB/IJG parms -- added tracestrings for global PLTE,tRNS,bKGD -- added framenr/layernr/playtime to object header -- added initialization of framenr/layernr/playtime -- changed ani_create calls not returning object pointer -- create ani objects always (not just inside TERM/LOOP) -- fixed inconsistancy with freeing global iCCP profile -- fixed minor bugs 16-bit pixel-handling -- added object promotion routine (PROM handling) -- added trace-codes & -strings for image-object promotion -- added trace-codes & -strings for delta-image processing -- added error-codes & -strings for delta-image processing -- added support for delta-image processing -- added ani-object routines for delta-image processing -- added delta-image fields -- added compression/filter/interlace fields to object-buffer for - delta-image processing -- added delta-image row-processing routines -- fixed up punctuation in several files (contributed by Tim Rowley) -- removed useless definition in "mng_chunks.h" (contributed by Tim Rowley) -- fixed pointer confusion in "mng_display.c" (contributed by Tim Rowley) -- fixed inclusion for memcpy (contributed by Tim Rowley) -- added mng_int32p (contributed by Tim Rowley) -- added internal delta-image processing callbacks -- separated configuration-options into "mng_conf.h" -- changed to most likely configuration -- added RGB8_A8 canvasstyle -- added getalphaline callback for RGB8_A8 canvasstyle -- fixed some makeup for Linux gcc compile -- implemented app bkgd restore routines -- implemented RGBA8, ARGB8, BGRA8 & ABGR8 display routines -- added support for RGB8_A8 canvasstyle -- added support for suspended input-buffer processing -- added mng_read_resume HLAPI function to support read-suspension -- fixed timer-handling to run with Mozilla (Tim Rowley) -- fixed alpha-handling for alpha canvasstyles -- fixed some compilation-warnings (contrib Jason Morris) - -samples: -- fixed mngview(delphi) to work with the new core -- synchronized libmng.pas(delphi) with the new libmng.h header -- removed the error- & trace-strings from libmng.pas(delphi) -- fixed mngtree(Unix) to compile on Linux (runs with libmng.so) -- added makefile.linux for mngtree(Unix) (tested on RedHat6.2) - -contrib: -- updated mngplg to 0.2.2 (based on latest code; supports JNG!) - -doc: -- this file obviously -- added Tim Rowley as contributing author -- changed the examples.readme doc -- updated the design-schematics in line with the current code - -makefiles: -- changed the directory to "makefiles" to avoid name-conflicts -- added generic Unix makefile (thanks to Tim Rowley) -- added Linux ELF makefile (tested on RedHat6.2) - ------------------------------------------------------------ - -0.5.1 May 16th 2000 -------------------- - -in short: - -This is the second release for developers -It's a bit of a milestone since all the chunk functionality is in place and -functioning (read, examine, create & write) -This version is incompatible with 0.5.0 since some of the callback prototypes -have changed (should be the last time that happens!) -There are a few more samples and even a real contribution! - -Fixed bug 105795 & 105797 -Fixed a mis-alignment in animation-timing -Added chunk-access functions -Finished all chunk-storage routine-bits -Finished all chunk-write routines -Changed the callback prototypes to allow error-reporting back to the library -Fixed some routines to allow for callback error-reporting -Added version-control functions & constants -Added two functions to set display- & sRGB-profile from memory -Moved CRC table to dynamic structure (for improved thread-safety) -Added SAVE & SEEK save&restore functionality -Finished the application-based CMS-callbacks -Fixed a few BCB specifics -Changed the Win32 DLL and samples to use __stdcall -Did some more assorted little changes -Added 2 BCB samples -Added 1 Unix sample -Added the MNG plugin by Jason Summers in the contrib section -Changed some documents to reflect these changes - -------------------- - -bugfixes: -B001(105795) - fixed wrong lcms call & memory-leak for gammatables -B002(105797) - fixed problem with missing sRGB profile - -core: -- changed chunk iteration function -- added chunk access functions -- added version control constants & functions -- changed strict-ANSI stuff -- added set_outputprofile2 & set_srgbprofile2 -- added empty-chunk put-routines -- added version_dll & VERSION_DLL (for consistency) -- added version control explanatory text & samples -- added iteratechunk callback definition -- improved definitions for DLL support -- added 8-bit palette definition -- added general array definitions -- added MNG_NULL definition -- changed most callback prototypes to allow the app - to report errors during callback processing -- added CRC table to main structure (for thread-safety) -- added iPLTEentries for checking hIST-length -- changed palette definition to exported palette-type -- removed frozen indicator -- added create/write indicators -- added eMNGma hack (will be removed in 1.0.0 !!!) -- added TERM animation object pointer (easier reference) -- added saved-data structure for SAVE/SEEK processing -- added some errorcodes -- added application errorcodes (used with callbacks) -- moved chunk-access errorcodes to severity 5 -- added chunk-access function trace-codes -- changed trace to macro for callback error-reporting -- added save_state & restore_state trace-codes -- put in some extra comments -- fixed layout for sBIT, PPLT -- changed write callback definition -- fixed layout for PPLT again (missed deltatype ?!?) -- cleaned up left-over teststuff in the BACK chunk routine -- changed CRC initialization to use dynamic structure - (wasn't thread-safe the old way !) -- filled in many missing sequence&length checks -- filled in many missing chunk-store snippets -- added checks for running animations -- filled remaining write routines -- fixed read_pplt with regard to deltatype -- added callback error-reporting support -- added pre-draft48 support (short MHDR, frame_mode, LOOP) -- fixed chunk-storage bit in several routines -- supplemented the SAVE & SEEK display processing -- added init of iPLTEcount -- changed calling-convention definition -- changed status-handling of display-routines -- added versioning-control routines -- filled the write routine -- fixed frame_delay misalignment -- added sanity check for frozen status -- changed display_mend to reset state to initial or SAVE -- added save_state and restore_state for SAVE/SEEK/TERM - processing -- added process_save & process_seek routines -- changed and filled iterate-chunk function -- added getchunk functions -- added putchunk functions -- added empty-chunk put-routines -- filled application-based color-management routines -- added creatememprofile -- filled the deflatedata routine -- added cleanup of saved-data (SAVE/SEEK processing) -- moved the actual write_graphic functionality from mng_hlapi.c - to it's appropriate function in the mng_write.c module -- moved standard header includes into mng_types.h - (stdlib/mem for mem-mngmt & math for fp gamma-calc) -- added getimgdata & putimgdata functions - -samples: -- fixed mngview(delphi) to work with the new core -- synchronized libmng.pas(delphi) with the new libmng.h header -- added mngtree(bcb) sample -- added bogus(bcb) sample -- added mngtree(unix) sample - -contrib: -- added mngplg 0.1.0 / a MNG plugin for Win32 by Jason Summers - -doc: -- added this changes.readme file -- changed the samples.readme doc accordingly -- changed the contrib.readme doc accordingly - ------------------------------------------------------------ - -0.5.0 May 1st 2000 ------------------- - -in short: - -This is the first developers release. -It's roughly about 60% done. diff --git a/freeimage241/Source/LibMNG/LICENSE b/freeimage241/Source/LibMNG/LICENSE deleted file mode 100644 index bae3a82..0000000 --- a/freeimage241/Source/LibMNG/LICENSE +++ /dev/null @@ -1,56 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * COPYRIGHT NOTICE: * */ -/* * * */ -/* * Copyright (c) 2000 Gerard Juyn (gerard@libmng.com) * */ -/* * [You may insert additional notices after this sentence if you modify * */ -/* * this source] * */ -/* * * */ -/* * For the purposes of this copyright and license, "Contributing Authors" * */ -/* * is defined as the following set of individuals: * */ -/* * * */ -/* * Gerard Juyn * */ -/* * * */ -/* * The MNG Library is supplied "AS IS". The Contributing Authors * */ -/* * disclaim all warranties, expressed or implied, including, without * */ -/* * limitation, the warranties of merchantability and of fitness for any * */ -/* * purpose. The Contributing Authors assume no liability for direct, * */ -/* * indirect, incidental, special, exemplary, or consequential damages, * */ -/* * which may result from the use of the MNG Library, even if advised of * */ -/* * the possibility of such damage. * */ -/* * * */ -/* * Permission is hereby granted to use, copy, modify, and distribute this * */ -/* * source code, or portions hereof, for any purpose, without fee, subject * */ -/* * to the following restrictions: * */ -/* * * */ -/* * 1. The origin of this source code must not be misrepresented; * */ -/* * you must not claim that you wrote the original software. * */ -/* * * */ -/* * 2. Altered versions must be plainly marked as such and must not be * */ -/* * misrepresented as being the original source. * */ -/* * * */ -/* * 3. This Copyright notice may not be removed or altered from any source * */ -/* * or altered source distribution. * */ -/* * * */ -/* * The Contributing Authors specifically permit, without fee, and * */ -/* * encourage the use of this source code as a component to supporting * */ -/* * the MNG and JNG file format in commercial products. If you use this * */ -/* * source code in a product, acknowledgment would be highly appreciated. * */ -/* * * */ -/* ************************************************************************** */ -/* * * */ -/* * Parts of this software have been adapted from the libpng package. * */ -/* * Although this library supports all features from the PNG specification * */ -/* * (as MNG descends from it) it does not require the libpng package. * */ -/* * It does require the zlib library and optionally the IJG jpeg library, * */ -/* * and/or the "little-cms" library by Marti Maria (depending on the * */ -/* * inclusion of support for JNG and Full-Color-Management respectively. * */ -/* * * */ -/* * This library's function is primarily to read and display MNG * */ -/* * animations. It is not meant as a full-featured image-editing * */ -/* * component! It does however offer creation and editing functionality * */ -/* * at the chunk level. * */ -/* * (future modifications may include some more support for creation * */ -/* * and or editing) * */ -/* * * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/LibMNG.dsp b/freeimage241/Source/LibMNG/LibMNG.dsp deleted file mode 100644 index a672f53..0000000 --- a/freeimage241/Source/LibMNG/LibMNG.dsp +++ /dev/null @@ -1,248 +0,0 @@ -# Microsoft Developer Studio Project File - Name="LibMNG" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=LibMNG - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "LibMNG.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "LibMNG.mak" CFG="LibMNG - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "LibMNG - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "LibMNG - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "LibMNG - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G6 /Gd /MT /W3 /GX /O1 /I "..\Zlib" /I "..\libjpeg" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x413 /d "NDEBUG" -# ADD RSC /l 0x413 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "LibMNG - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\Zlib" /I "..\libjpeg" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD BASE RSC /l 0x413 /d "_DEBUG" -# ADD RSC /l 0x413 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "LibMNG - Win32 Release" -# Name "LibMNG - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\libmng_callback_xs.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_chunk_io.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_chunk_prc.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_chunk_xs.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_cms.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_display.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_dither.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_error.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_filter.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_hlapi.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_jpeg.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_object_prc.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_pixels.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_prop_xs.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_read.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_trace.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_write.c -# End Source File -# Begin Source File - -SOURCE=.\libmng_zlib.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\libmng.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_chunk_io.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_chunk_prc.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_chunks.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_cms.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_conf.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_data.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_display.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_dither.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_error.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_filter.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_jpeg.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_memory.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_object_prc.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_objects.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_pixels.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_read.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_trace.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_types.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_write.h -# End Source File -# Begin Source File - -SOURCE=.\libmng_zlib.h -# End Source File -# End Group -# End Target -# End Project diff --git a/freeimage241/Source/LibMNG/README b/freeimage241/Source/LibMNG/README deleted file mode 100644 index 99c460f..0000000 --- a/freeimage241/Source/LibMNG/README +++ /dev/null @@ -1,38 +0,0 @@ -libmng 1.0.1 ------------- - -First maintenance release! - -There's been some changes in the CMS profile handling, that should make it -easier for sRGB-compliant systems. Non-sRGB compliant systems will still need -some extra work if they want to use MNG_FULL_CMS with lcms. But this has always -been so, so it's not an extra step anyway. -(Many thanks to Marti, Ivan & Warwick for their help & comments!) - -Gregg Kelly has been helpful in locating a couple of memory-leaks, and make -the library even better. - -The default Windows DLL that's part of the Windows zip-files now also exports -the JPEG library function calls (ijgsrc6b). Note that there's a new Delphi -component (TNGImage) that makes it a snap to work with PNG/JNG & MNG images -within Delphi. - -Please enjoy! - -Gerard - - -For more information please visit: - -The official libmng web-site: - http://www.libmng.com - -Libmng's community on SourceForge: - https://sourceforge.net/project/?group_id=5635 - -The official MNG homepage: - http://www.libpng.org/pub/mng - -The official PNG homepage: - http://www.libpng.org/pub/png - diff --git a/freeimage241/Source/LibMNG/README.config b/freeimage241/Source/LibMNG/README.config deleted file mode 100644 index d5cd454..0000000 --- a/freeimage241/Source/LibMNG/README.config +++ /dev/null @@ -1,104 +0,0 @@ -Configuration options in libmng -=============================== - -The library is fairly configurable through the use of a number of defines. -Please note however that certain defines are for internal use only. -The following list gives a summary of options that can be used externally to -define the functionality of the library: - -======================================== - -#define MNG_BUILD_DLL - -This is used to indicate that a "standard" DLL should result from compiling -the library. Please note the remarks in README.dll if you intend to work -with the library as a DLL. The purpose of this option is to ensure that -DLL builds have the same set of functions. - -#define MNG_BUILD_SO - -This is used to indicate that a "standard" shared library (SO) should result -from a compilation. The purpose of this option is to ensure that all -shared libraries generated this way will have the same set of functions. - -#define MNG_USE_DLL / #define MNG_USE_SO - -These should be used when including the library header in the compilation -of an application to indicate that the compiler/linker must take the -necessary steps to make the binary executable to use the standard DLL -or shared library (SO). - -#define MNG_SKIP_ZLIB / #define MNG_SKIP_LCMS / #define MNG_SKIP_IJG6B - -Use these in conjunction with MNG_USE_DLL / MNG_USE_SO. This is useful if -you only need the external definitions of the MNG library and not the others, -which will speed up the compilation process. - -#define MNG_SUPPORT_FULL / #define MNG_SUPPORT_LC / #define MNG_SUPPORT_VLC - -These can be used to indicate the level of MNG spec compliance required. -Currently only full MNG compliance is supported. - -#define MNG_SUPPORT_IJG6B - -This can be used to indicate if JNG support is required. This option will -include the IJG JPEG-library. Note that MNG_SUPPORT_FULL will automatically -set this option. Use this only if you need JNG support with MNG-(V)LC. - -#define MNG_FULL_CMS / #define MNG_GAMMA_ONLY / #define MNG_NO_CMS / -#define MNG_APP_CMS - -These indicate the color-correction support level of the library. -If you are on a platform that supports lcms (Little CMS by Marti Maria Saguar) -then it is highly recommended to define MNG_FULL_CMS. -If your platform has it's own CMS then select MNG_APP_CMS and be sure to -include the appropriate callbacks in your app. -In all other cases it is recommended to define MNG_GAMMA_ONLY. - -#define MNG_SUPPORT_READ / #define MNG_SUPPORT_WRITE / -#define MNG_SUPPORT_DISPLAY - -These indicate the high-level support for reading, writing and/or -displaying files. Note that in order to display a file, you'll need to read -it first. (yes, really!) - -#define MNG_STORE_CHUNKS - -This indicates that the library should store chunk-information when reading -a file. This information can then be processed through the -MNG_ITERATE_CHUNKS() function. Note that you must specify this option if -you want to create and write a new file. - -#define MNG_ACCESS_CHUNKS - -This is used to indicate that the app may need access to internally stored -chunk information. MNG_STORE_CHUNKS must be defined as well for this option -to function properly. - -#define MNG_INTERNAL_MEMMNGMT - -You can use this to have the library handle it's own memory allocation and -deallocation through the "standard" memory functions. This option is turned -off by default, which means your app must define the memory callbacks. - -#define MNG_ERROR_TELLTALE - -Set this on to allow human-readable error-messages to be included in the -library and the error function and callback. - -#define MNG_BIGENDIAN_SUPPORTED - -This option should be used to indicate the hardware is based on big endian -integers. - -#define MNG_SUPPORT_TRACE / #define MNG_TRACE_TELLTALE - -These two can be used when debugging an app. You'll need to have the trace -callback setup also. This allows for a rather thorough investigation of the -libraries function paths. - -======================================== - -Any other optional defines you may encounter are for internal use only. -please do not specify them externally. In case of doubt, consult the -support email lists. More info can be found on http://www.libmng.com diff --git a/freeimage241/Source/LibMNG/README.contrib b/freeimage241/Source/LibMNG/README.contrib deleted file mode 100644 index 386b6d5..0000000 --- a/freeimage241/Source/LibMNG/README.contrib +++ /dev/null @@ -1,66 +0,0 @@ -The contrib directory contains contributions made by fellow enthousiasts. -(Check the web-sites for the latest versions) - ----------------------------------------------------------------------- - -mngplg - A Netscape plugin for MNG - by Jason Summers - -http://pobox.com/~jason1/imaging/mngplg/ - -The very first contribution, and what a start! -GIF look out, MNG is on the prowl and ready to swat you like a fly! - ----------------------------------------------------------------------- - -mngplay - An SDL based MNG viewer - by Ralph Giles - -http://snow.ashlu.bc.ca/~giles/mng/ - -Another nice contribution. View MNG files on practically any platform -with this standalone viewer. -Source-code only; Requires SDL library and libmng.so - ----------------------------------------------------------------------- - -mngview - A BCB port of the Delphi sample - by Andy Protano - -I have added this nice little port to the BCB samples directory. -It adds a nifty progressbar while reading a file. Excellent work! -Requires libmng.dll -(note: this is in the BCB samples directory) - ----------------------------------------------------------------------- - -mngdump - A BCB GUI-based dump utility - by Andy Protano - -Andy has sent me this fully functional MNG dump utility, that gives -detailed information of the contents of any MNG file. -Requires libmng.dll - ----------------------------------------------------------------------- - -mng-view - A GTK-based MNG viewer - by Vova Babin - -Vova has been hacking away with the libmng code and has come up with -this nice little sample how to write a MNG viewer using GTK. -Thanks mate! -Source-code only -Requires GTK+ (1.2 or higher) and libmng (0.9.2 or higher) - ----------------------------------------------------------------------- - -mngview - Another MNG viewer; this one for MSVC - by Nicholaus Brennig - -A welcome contribution from Nicholaus. Author of SlowView. A very nice -image-handling utility for Windows. A welcome contribution since there -have been numerous questions about linking libmng with MSVC. -Well, look no further. Here it is! - ----------------------------------------------------------------------- - -MSVC libmng project - A MSVC project to build libmng.dll - by Chad Austin - -Chad has contributed some project-files that you could use to build -libmng.dll with MSVC. Please be sure to read the README file included. - ----------------------------------------------------------------------- diff --git a/freeimage241/Source/LibMNG/README.examples b/freeimage241/Source/LibMNG/README.examples deleted file mode 100644 index 66dc5cb..0000000 --- a/freeimage241/Source/LibMNG/README.examples +++ /dev/null @@ -1,43 +0,0 @@ -The samples are in platform-specific directories. - -!!! contributions are very welcome !!! - - -bcb - Borland C++ Builder (3.0) -------------------------------- - -win32dll - sample project to create a Windows dll. Requires zlib1.1.3, - IJG jpgsrc6b and lcms1.0.6. The directories containing these - libraries must be at the same level as the libmng directory. - So if you're in the directory with this file and the libmng - sources, they should be in ..\zlib , ..\jpgsrc6b and ..\lcms - respectively. - -!!! To run the other Win32 samples you need to copy the libmng.dll - file from here into the sample's directory !!! - -mngtree - sample project to create a little command-line tool that dumps - the chunk-structure of a given file onto stdout. - -bogus - a completely bogus example on how to create a perfectly valid - (though slightly biased) MNG. - -mngview - port of the Delphi mngview sample. contributed by Andy Protano. - see also README.contrib - - -delphi - Borland Delphi (3.0+) ------------------------------- - -mngview - sample project for a simple mng-viewer. The general unit in - the delphi directory was translated from libmng.h It can be - used in other projects to access libmng.dll created with the - win32dll example above. - - -unix - Unix ------------ - -mngtree - basically a copy of the BCB sample. It includes a makefile for - Linux and it's been tested on RedHat6.2 - diff --git a/freeimage241/Source/LibMNG/README.packaging b/freeimage241/Source/LibMNG/README.packaging deleted file mode 100644 index da0db3e..0000000 --- a/freeimage241/Source/LibMNG/README.packaging +++ /dev/null @@ -1,24 +0,0 @@ -Packaging Libmng for distribution ---------------------------------- - -These are some notes for those building binaries for distribution. - -We're interested to hear about anywhere libmng is helpful, so let us -know if you're including it with your application or OS. Also, if your -build is publicly accessible, we'd be happy to link to it from -the libmng site. - -However, We respectfully request that you *not* distribute binaries as a -shared library (DLL) with any of the major features disabled. While -there is support for this in terms of #ifdef directives (in -libmng_conf.h) and autoconf switches they are intended for embedded -application and testing. The default compilation options support the -full MNG specification, and we wish to avoid the confusion among -general users that partial support would engender. - - -Platform specific notes: - -We have a basic .spec file for generating rpms. Send us a note if you'd -like to clean it up. - diff --git a/freeimage241/Source/LibMNG/autogen.sh b/freeimage241/Source/LibMNG/autogen.sh deleted file mode 100644 index 0ed4a8b..0000000 --- a/freeimage241/Source/LibMNG/autogen.sh +++ /dev/null @@ -1,34 +0,0 @@ -# autogen.sh -# -# invoke the auto* tools to create the configureation system - -# move out configure.in -if ! test -f configure.in; then - echo "copying out configure.in" - ln -s makefiles/configure.in -fi - -# move out the macros and run aclocal -if ! test -f acinclude.m4; then - echo "copying configure macros" - ln -s makefiles/acinclude.m4 . -fi -aclocal - -# build the configure script -autoconf - -# set up libtool -libtoolize --force - -# copy up our Makefile template and invoke automake -if ! test -f Makefile.am; then - echo "copying automake template" - ln -s makefiles/Makefile.am . -fi -automake --foreign --add-missing - -# and finally invoke our new configure -./configure $* - -# end diff --git a/freeimage241/Source/LibMNG/libmng.h b/freeimage241/Source/LibMNG/libmng.h deleted file mode 100644 index 18b98e0..0000000 --- a/freeimage241/Source/LibMNG/libmng.h +++ /dev/null @@ -1,2501 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * COPYRIGHT NOTICE: * */ -/* * * */ -/* * Copyright (c) 2000,2001 Gerard Juyn (gerard@libmng.com) * */ -/* * [You may insert additional notices after this sentence if you modify * */ -/* * this source] * */ -/* * * */ -/* * For the purposes of this copyright and license, "Contributing Authors" * */ -/* * is defined as the following set of individuals: * */ -/* * * */ -/* * Gerard Juyn (gerard@libmng.com) * */ -/* * * */ -/* * The MNG Library is supplied "AS IS". The Contributing Authors * */ -/* * disclaim all warranties, expressed or implied, including, without * */ -/* * limitation, the warranties of merchantability and of fitness for any * */ -/* * purpose. The Contributing Authors assume no liability for direct, * */ -/* * indirect, incidental, special, exemplary, or consequential damages, * */ -/* * which may result from the use of the MNG Library, even if advised of * */ -/* * the possibility of such damage. * */ -/* * * */ -/* * Permission is hereby granted to use, copy, modify, and distribute this * */ -/* * source code, or portions hereof, for any purpose, without fee, subject * */ -/* * to the following restrictions: * */ -/* * * */ -/* * 1. The origin of this source code must not be misrepresented; * */ -/* * you must not claim that you wrote the original software. * */ -/* * * */ -/* * 2. Altered versions must be plainly marked as such and must not be * */ -/* * misrepresented as being the original source. * */ -/* * * */ -/* * 3. This Copyright notice may not be removed or altered from any source * */ -/* * or altered source distribution. * */ -/* * * */ -/* * The Contributing Authors specifically permit, without fee, and * */ -/* * encourage the use of this source code as a component to supporting * */ -/* * the MNG and JNG file format in commercial products. If you use this * */ -/* * source code in a product, acknowledgment would be highly appreciated. * */ -/* * * */ -/* ************************************************************************** */ -/* * * */ -/* * Parts of this software have been adapted from the libpng package. * */ -/* * Although this library supports all features from the PNG specification * */ -/* * (as MNG descends from it) it does not require the libpng package. * */ -/* * It does require the zlib library and optionally the IJG jpeg library, * */ -/* * and/or the "little-cms" library by Marti Maria (depending on the * */ -/* * inclusion of support for JNG and Full-Color-Management respectively. * */ -/* * * */ -/* * This library's function is primarily to read and display MNG * */ -/* * animations. It is not meant as a full-featured image-editing * */ -/* * component! It does however offer creation and editing functionality * */ -/* * at the chunk level. * */ -/* * (future modifications may include some more support for creation * */ -/* * and or editing) * */ -/* * * */ -/* ************************************************************************** */ - -/* ************************************************************************** */ -/* * * */ -/* * Version numbering * */ -/* * * */ -/* * X.Y.Z : X = release (0 = initial build) * */ -/* * Y = major version (uneven = test; even = production) * */ -/* * Z = minor version (bugfixes; 2 is older than 10) * */ -/* * * */ -/* * production versions only appear when a test-version is extensively * */ -/* * tested and found stable or for intermediate bug-fixes (recognized by * */ -/* * a change in the Z number) * */ -/* * * */ -/* * x.1.x = test version * */ -/* * x.2.x = production version * */ -/* * x.3.x = test version * */ -/* * x.4.x = production version * */ -/* * etc. * */ -/* * * */ -/* ************************************************************************** */ -/* * * */ -/* * Identifier naming conventions throughout this library * */ -/* * * */ -/* * iXxxx = an integer * */ -/* * dXxxx = a float * */ -/* * pXxxx = a pointer * */ -/* * bXxxx = a boolean * */ -/* * eXxxx = an enumeration * */ -/* * hXxxx = a handle * */ -/* * zXxxx = a zero-terminated string (pchar) * */ -/* * fXxxx = a pointer to a function (callback) * */ -/* * aXxxx = an array * */ -/* * sXxxx = a structure * */ -/* * * */ -/* * Macros & defines are in all uppercase. * */ -/* * Functions & typedefs in all lowercase. * */ -/* * Exported stuff is prefixed with MNG_ or mng_ respectively. * */ -/* * * */ -/* * (I may have missed a couple; don't hesitate to let me know!) * */ -/* * * */ -/* ************************************************************************** */ - -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : main application interface * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : The main application interface. An application should not * */ -/* * need access to any of the other modules! * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - changed chunk iteration function * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added chunk access functions * */ -/* * - added version control constants & functions * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added set_outputprofile2 & set_srgbprofile2 * */ -/* * - added empty-chunk put-routines * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - added version_dll & VERSION_DLL (for consistency) * */ -/* * - added version control explanatory text & samples * */ -/* * 0.5.1 - 05/15/2000 - G.Juyn * */ -/* * - added getimgdata & putimgdata functions * */ -/* * * */ -/* * 0.5.2 - 05/16/2000 - G.Juyn * */ -/* * - changed the version parameters (obviously) * */ -/* * 0.5.2 - 05/18/2000 - G.Juyn * */ -/* * - complimented constants for chunk-property values * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - fixed MNG_UINT_pHYg value * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for get/set default zlib/IJG parms * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added MNG_BIGENDIAN_SUPPORT (contributed by Tim Rowley) * */ -/* * - separated configuration-options into "mng_conf.h" * */ -/* * - added RGB8_A8 canvasstyle * */ -/* * - added getalphaline callback for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - moved errorcodes from "mng_error.h" * */ -/* * - added mng_read_resume function to support * */ -/* * read-suspension * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed the version parameters (obviously) * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added get/set for speedtype to facilitate testing * */ -/* * - added get for imagelevel during processtext callback * */ -/* * 0.5.3 - 06/24/2000 - G.Juyn * */ -/* * - fixed inclusion of IJG read/write code * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * * */ -/* * 0.9.0 - 06/30/2000 - G.Juyn * */ -/* * - changed refresh parameters to 'x,y,width,height' * */ -/* * * */ -/* * 0.9.1 - 07/06/2000 - G.Juyn * */ -/* * - added MNG_NEEDTIMERWAIT errorcode * */ -/* * - changed comments to indicate modified behavior for * */ -/* * timer & suspension breaks * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added get routines for internal display variables * */ -/* * - added get/set routines for suspensionmode variable * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * - added get/set routines for sectionbreak variable * */ -/* * - added NEEDSECTIONWAIT errorcode * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added function to set frame-/layer-count & playtime * */ -/* * - added errorcode for updatemngheader if not a MNG * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - fixed problem with trace-functions improperly wrapped * */ -/* * - added status_xxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added function to set simplicity field * */ -/* * * */ -/* * 0.9.3 - 08/09/2000 - G.Juyn * */ -/* * - added check for simplicity-bits in MHDR * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - fixed processing of unknown critical chunks * */ -/* * - removed test-MaGN * */ -/* * - added PNG/MNG spec version indicators * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * - added JDAA chunk * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added errocode for delayed delta-processing * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 0.9.4 - 01/18/2001 - G.Juyn * */ -/* * - added errorcode for MAGN methods * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * * */ -/* * 1.0.0 - 02/05/2001 - G.Juyn * */ -/* * - version numbers (obviously) * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added late binding errorcode (not used internally) * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_h_ -#define _libmng_h_ - -/* ************************************************************************** */ - -#include "libmng_conf.h" /* user-specific configuration options */ - -/* ************************************************************************** */ - -#define MNG_CHECK_BAD_ICCP /* let's catch that sucker !!! */ - -#ifdef MNG_SUPPORT_READ /* dependencies based on user-configuration */ -#define MNG_INCLUDE_READ_PROCS -#endif - -#ifdef MNG_SUPPORT_WRITE -#define MNG_INCLUDE_WRITE_PROCS -#endif - -#ifdef MNG_SUPPORT_DISPLAY -#define MNG_INCLUDE_FILTERS -#define MNG_INCLUDE_INTERLACE -#define MNG_INCLUDE_OBJECTS -#define MNG_INCLUDE_DISPLAY_PROCS -#define MNG_INCLUDE_TIMING_PROCS -#define MNG_INCLUDE_ZLIB -#endif - -#ifdef MNG_STORE_CHUNKS -#define MNG_INCLUDE_ZLIB -#endif - -#ifdef MNG_SUPPORT_IJG6B -#define MNG_INCLUDE_JNG -#define MNG_INCLUDE_IJG6B -#define MNG_USE_SETJMP -#endif - -#ifdef MNG_INCLUDE_JNG -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_ACCESS_CHUNKS) -#define MNG_INCLUDE_JNG_READ -#endif -#if defined(MNG_SUPPORT_WRITE) || defined(MNG_ACCESS_CHUNKS) -#define MNG_INCLUDE_JNG_WRITE -#endif -#endif - -#ifdef MNG_FULL_CMS -#define MNG_INCLUDE_LCMS -#endif - -#ifdef MNG_AUTO_DITHER -#define MNG_INCLUDE_DITHERING -#endif - -#ifdef MNG_SUPPORT_TRACE -#define MNG_INCLUDE_TRACE_PROCS -#ifdef MNG_TRACE_TELLTALE -#define MNG_INCLUDE_TRACE_STRINGS -#endif -#endif - -#ifdef MNG_ERROR_TELLTALE -#define MNG_INCLUDE_ERROR_STRINGS -#endif - -/* ************************************************************************** */ - -#include "libmng_types.h" /* platform-specific definitions - and other assorted stuff */ - -/* ************************************************************************** */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Versioning control * */ -/* * * */ -/* * version_so and version_dll will NOT reflect version_major; * */ -/* * these will only change for binary incompatible changes (which will * */ -/* * hopefully never occur) * */ -/* * note: they will be set to 1 on the first public release !!! * */ -/* * * */ -/* * first public release: * */ -/* * #define MNG_VERSION_TEXT "1.0.0" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 1 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * bug fix & cosmetics : * */ -/* * #define MNG_VERSION_TEXT "1.0.1" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 1 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 1 * */ -/* * * */ -/* * feature change : * */ -/* * #define MNG_VERSION_TEXT "1.2.0" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 1 * */ -/* * #define MNG_VERSION_MINOR 2 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * major rewrite (still binary compatible) : * */ -/* * #define MNG_VERSION_TEXT "2.0.0" * */ -/* * #define MNG_VERSION_SO 1 eg. libmng.so.1 * */ -/* * #define MNG_VERSION_DLL 1 eg. libmng.dll * */ -/* * #define MNG_VERSION_MAJOR 2 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * binary incompatible change: * */ -/* * #define MNG_VERSION_TEXT "13.0.0" * */ -/* * #define MNG_VERSION_SO 2 eg. libmng.so.2 * */ -/* * #define MNG_VERSION_DLL 2 eg. libmng2.dll * */ -/* * #define MNG_VERSION_MAJOR 13 * */ -/* * #define MNG_VERSION_MINOR 0 * */ -/* * #define MNG_VERSION_RELEASE 0 * */ -/* * * */ -/* * note that version_so & version_dll will always remain equal so it * */ -/* * doesn't matter which one is called to do version-checking; they are * */ -/* * just provided for their target platform * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_VERSION_TEXT "1.0.2" -#define MNG_VERSION_SO 1 /* eg. libmng.so.1 */ -#define MNG_VERSION_DLL 1 /* but: libmng.dll (!) */ -#define MNG_VERSION_MAJOR 1 -#define MNG_VERSION_MINOR 0 -#define MNG_VERSION_RELEASE 2 - -MNG_EXT mng_pchar MNG_DECL mng_version_text (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_so (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_dll (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_major (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_minor (void); -MNG_EXT mng_uint8 MNG_DECL mng_version_release (void); - -/* ************************************************************************** */ -/* * * */ -/* * MNG/PNG specification level conformance * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_PNG_VERSION "1.2" -#define MNG_PNG_VERSION_MAJ 1 -#define MNG_PNG_VERSION_MIN 2 - -#define MNG_MNG_VERSION "1.0" -#define MNG_MNG_VERSION_MAJ 1 -#define MNG_MNG_VERSION_MIN 0 -#define MNG_MNG_DRAFT 99 /* deprecated */ - -/* ************************************************************************** */ -/* * * */ -/* * High-level application functions * */ -/* * * */ -/* ************************************************************************** */ - -/* library initialization function */ -/* must be the first called before anything can be done at all */ -/* initializes internal datastructure(s) */ -MNG_EXT mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata, - mng_memalloc fMemalloc, - mng_memfree fMemfree, - mng_traceproc fTraceproc); - -/* library reset function */ -/* can be used to re-initialize the library, so another image can be - processed. there's absolutely no harm in calling it, even when it's not - really necessary */ -MNG_EXT mng_retcode MNG_DECL mng_reset (mng_handle hHandle); - -/* library cleanup function */ -/* must be the last called to clean up internal datastructure(s) */ -MNG_EXT mng_retcode MNG_DECL mng_cleanup (mng_handle* hHandle); - -/* high-level read functions */ -/* use mng_read if you simply want to read a Network Graphic */ -/* mng_read_resume is used in I/O-read-suspension scenarios, where the - "readdata" callback may return FALSE & length=0 indicating it's buffer is - depleted or too short to supply the required bytes, and the buffer needs - to be refilled; libmng will return the errorcode MNG_NEEDMOREDATA telling - the app to refill it's read-buffer after which it must call mng_read_resume - (or mng_display_resume if it also displaying the image simultaneously) */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_read (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_read_resume (mng_handle hHandle); -#endif - -/* high-level write & create functions */ -/* use this if you want to write a previously read Network Graphic or - if you want to create a new graphic and write it */ -/* to write a previously read graphic you must have defined MNG_STORE_CHUNKS */ -/* to create a new graphic you'll also need access to the chunks - (eg. #define MNG_ACCESS_CHUNKS !) */ -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_retcode MNG_DECL mng_write (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_create (mng_handle hHandle); -#endif - -/* high-level display functions */ -/* use these to display a previously read or created graphic or - to read & display a graphic simultaneously */ -/* mng_display_resume should be called after a timer-interval - expires that was set through the settimer-callback, after a - read suspension-break, or, to resume an animation after a call - to mng_display_freeze/mng_display_reset */ -/* mng_display_freeze thru mng_display_gotime can be used to influence - the display of an image, BUT ONLY if it has been completely read! */ -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_readdisplay (mng_handle hHandle); -#endif -MNG_EXT mng_retcode MNG_DECL mng_display (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_resume (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_freeze (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_reset (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_display_goframe (mng_handle hHandle, - mng_uint32 iFramenr); -MNG_EXT mng_retcode MNG_DECL mng_display_golayer (mng_handle hHandle, - mng_uint32 iLayernr); -MNG_EXT mng_retcode MNG_DECL mng_display_gotime (mng_handle hHandle, - mng_uint32 iPlaytime); -#endif /* MNG_SUPPORT_DISPLAY */ - -/* error reporting function */ -/* use this if you need more detailed info on the last error */ -/* iExtra1 & iExtra2 may contain errorcodes from zlib, jpeg, etc... */ -/* zErrortext will only be filled if you #define MNG_ERROR_TELLTALE */ -MNG_EXT mng_retcode MNG_DECL mng_getlasterror (mng_handle hHandle, - mng_int8* iSeverity, - mng_chunkid* iChunkname, - mng_uint32* iChunkseq, - mng_int32* iExtra1, - mng_int32* iExtra2, - mng_pchar* zErrortext); - -/* ************************************************************************** */ -/* * * */ -/* * Callback set functions * */ -/* * * */ -/* ************************************************************************** */ - -/* memory callbacks */ -/* called to allocate and release internal datastructures */ -#ifndef MNG_INTERNAL_MEMMNGMT -MNG_EXT mng_retcode MNG_DECL mng_setcb_memalloc (mng_handle hHandle, - mng_memalloc fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_memfree (mng_handle hHandle, - mng_memfree fProc); -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* open- & close-stream callbacks */ -/* called to open & close streams for input or output */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -MNG_EXT mng_retcode MNG_DECL mng_setcb_openstream (mng_handle hHandle, - mng_openstream fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_closestream (mng_handle hHandle, - mng_closestream fProc); -#endif - -/* read callback */ -/* called to get data from the inputstream */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_setcb_readdata (mng_handle hHandle, - mng_readdata fProc); -#endif - -/* write callback */ -/* called to put data into the outputstream */ -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_retcode MNG_DECL mng_setcb_writedata (mng_handle hHandle, - mng_writedata fProc); -#endif - -/* error callback */ -/* called when an error occurs */ -/* the application can determine if the error is recoverable, - and may inform the library by setting specific returncodes */ -MNG_EXT mng_retcode MNG_DECL mng_setcb_errorproc (mng_handle hHandle, - mng_errorproc fProc); - -/* trace callback */ -/* called to show the currently executing function */ -#ifdef MNG_SUPPORT_TRACE -MNG_EXT mng_retcode MNG_DECL mng_setcb_traceproc (mng_handle hHandle, - mng_traceproc fProc); -#endif - -/* callbacks for read processing */ -/* processheader is called when all header information has been gathered - from the inputstream */ -/* processtext is called for every tEXt, zTXt and iTXt chunk in the - inputstream (iType=0 for tEXt, 1 for zTXt and 2 for iTXt); - you can call get_imagelevel to check at what nesting-level the chunk is - encountered (eg. tEXt inside an embedded image inside a MNG -> level == 2; - in most other case -> level == 1) */ -/* processsave & processseek are called for SAVE/SEEK chunks */ -/* processneed is called for the nEED chunk; you should specify a callback - for this as the default behavior will be to abort processing */ -/* processunknown is called after reading each non-critical unknown chunk */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_retcode MNG_DECL mng_setcb_processheader (mng_handle hHandle, - mng_processheader fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processtext (mng_handle hHandle, - mng_processtext fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processsave (mng_handle hHandle, - mng_processsave fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processseek (mng_handle hHandle, - mng_processseek fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processneed (mng_handle hHandle, - mng_processneed fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processmend (mng_handle hHandle, - mng_processmend fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processunknown(mng_handle hHandle, - mng_processunknown fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processterm (mng_handle hHandle, - mng_processterm fProc); -#endif - -/* callbacks for display processing */ -/* getcanvasline is called to get an access-pointer to a line on the - drawing-canvas */ -/* getbkgdline is called to get an access-pointer to a line from the - background-canvas */ -/* refresh is called to inform the GUI to redraw the current canvas onto - it's output device (eg. in Win32 this would mean sending an - invalidate message for the specified region */ -/* NOTE that the update-region is specified as x,y,width,height; eg. the - invalidate message for Windows requires left,top,right,bottom parameters - where the bottom-right is exclusive of the region!! - to get these correctly is as simple as: - left = x; - top = y; - right = x + width; - bottom = y + height; - if your implementation requires inclusive points, simply subtract 1 from - both the right & bottom values calculated above. - */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_retcode MNG_DECL mng_setcb_getcanvasline (mng_handle hHandle, - mng_getcanvasline fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_getbkgdline (mng_handle hHandle, - mng_getbkgdline fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_getalphaline (mng_handle hHandle, - mng_getalphaline fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_refresh (mng_handle hHandle, - mng_refresh fProc); - -/* timing callbacks */ -/* gettickcount is called to get the system tickcount (milliseconds); - this is used to determine the remaining interval between frames */ -/* settimer is called to inform the application that it should set a timer; - when the timer is triggered the app must call mng_display_resume */ -MNG_EXT mng_retcode MNG_DECL mng_setcb_gettickcount (mng_handle hHandle, - mng_gettickcount fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_settimer (mng_handle hHandle, - mng_settimer fProc); - -/* color management callbacks */ -/* called to transmit color management information to the application */ -/* these are only used when you #define MNG_APP_CMS */ -#ifdef MNG_APP_CMS -MNG_EXT mng_retcode MNG_DECL mng_setcb_processgamma (mng_handle hHandle, - mng_processgamma fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processchroma (mng_handle hHandle, - mng_processchroma fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processsrgb (mng_handle hHandle, - mng_processsrgb fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processiccp (mng_handle hHandle, - mng_processiccp fProc); -MNG_EXT mng_retcode MNG_DECL mng_setcb_processarow (mng_handle hHandle, - mng_processarow fProc); -#endif /* MNG_APP_CMS */ -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ -/* * * */ -/* * Callback get functions * */ -/* * * */ -/* ************************************************************************** */ - -/* see _setcb_ */ -#ifndef MNG_INTERNAL_MEMMNGMT -MNG_EXT mng_memalloc MNG_DECL mng_getcb_memalloc (mng_handle hHandle); -MNG_EXT mng_memfree MNG_DECL mng_getcb_memfree (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_WRITE_SUPPORT) -MNG_EXT mng_openstream MNG_DECL mng_getcb_openstream (mng_handle hHandle); -MNG_EXT mng_closestream MNG_DECL mng_getcb_closestream (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_readdata MNG_DECL mng_getcb_readdata (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_writedata MNG_DECL mng_getcb_writedata (mng_handle hHandle); -#endif - -/* see _setcb_ */ -MNG_EXT mng_errorproc MNG_DECL mng_getcb_errorproc (mng_handle hHandle); - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_TRACE -MNG_EXT mng_traceproc MNG_DECL mng_getcb_traceproc (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_processheader MNG_DECL mng_getcb_processheader (mng_handle hHandle); -MNG_EXT mng_processtext MNG_DECL mng_getcb_processtext (mng_handle hHandle); -MNG_EXT mng_processsave MNG_DECL mng_getcb_processsave (mng_handle hHandle); -MNG_EXT mng_processseek MNG_DECL mng_getcb_processseek (mng_handle hHandle); -MNG_EXT mng_processneed MNG_DECL mng_getcb_processneed (mng_handle hHandle); -MNG_EXT mng_processunknown MNG_DECL mng_getcb_processunknown (mng_handle hHandle); -MNG_EXT mng_processterm MNG_DECL mng_getcb_processterm (mng_handle hHandle); -#endif - -/* see _setcb_ */ -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_getcanvasline MNG_DECL mng_getcb_getcanvasline (mng_handle hHandle); -MNG_EXT mng_getbkgdline MNG_DECL mng_getcb_getbkgdline (mng_handle hHandle); -MNG_EXT mng_getalphaline MNG_DECL mng_getcb_getalphaline (mng_handle hHandle); -MNG_EXT mng_refresh MNG_DECL mng_getcb_refresh (mng_handle hHandle); - -/* see _setcb_ */ -MNG_EXT mng_gettickcount MNG_DECL mng_getcb_gettickcount (mng_handle hHandle); -MNG_EXT mng_settimer MNG_DECL mng_getcb_settimer (mng_handle hHandle); - -/* see _setcb_ */ -#ifdef MNG_APP_CMS -MNG_EXT mng_processgamma MNG_DECL mng_getcb_processgamma (mng_handle hHandle); -MNG_EXT mng_processchroma MNG_DECL mng_getcb_processchroma (mng_handle hHandle); -MNG_EXT mng_processsrgb MNG_DECL mng_getcb_processsrgb (mng_handle hHandle); -MNG_EXT mng_processiccp MNG_DECL mng_getcb_processiccp (mng_handle hHandle); -MNG_EXT mng_processarow MNG_DECL mng_getcb_processarow (mng_handle hHandle); -#endif /* MNG_APP_CMS */ -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ -/* * * */ -/* * Property set functions * */ -/* * * */ -/* ************************************************************************** */ - -/* Application data pointer */ -/* provided for application use; not used by the library */ -MNG_EXT mng_retcode MNG_DECL mng_set_userdata (mng_handle hHandle, - mng_ptr pUserdata); - -/* The style of the drawing- & background-canvas */ -/* only used for displaying images */ -/* both are initially set to 24-bit RGB (eg. 8-bit per channel) */ -MNG_EXT mng_retcode MNG_DECL mng_set_canvasstyle (mng_handle hHandle, - mng_uint32 iStyle); -MNG_EXT mng_retcode MNG_DECL mng_set_bkgdstyle (mng_handle hHandle, - mng_uint32 iStyle); - -/* The default background color */ -/* only used if the getbkgdline callback is not defined */ -/* for initially painting the canvas and restoring (part of) the background */ -MNG_EXT mng_retcode MNG_DECL mng_set_bgcolor (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue); - -/* Indicates preferred use of the bKGD chunk for PNG images */ -MNG_EXT mng_retcode MNG_DECL mng_set_usebkgd (mng_handle hHandle, - mng_bool bUseBKGD); - -/* Indicates storage of read chunks */ -/* only useful if you #define mng_store_chunks */ -/* can be used to dynamically change storage management */ -MNG_EXT mng_retcode MNG_DECL mng_set_storechunks (mng_handle hHandle, - mng_bool bStorechunks); - -/* Indicates breaks requested when processing SAVE/SEEK */ -/* set this to let the app handle section breaks; the library will return - MNG_NEEDSECTIONWAIT return-codes for each SEEK chunk */ -MNG_EXT mng_retcode MNG_DECL mng_set_sectionbreaks (mng_handle hHandle, - mng_bool bSectionbreaks); - -/* Indicates storage of playback info (ON by default!) */ -/* can be used to turn off caching of playback info; this is useful to - specifically optimize MNG-video playback; note that if caching is turned off - LOOP chunks will be flagged as errors! TERM chunks will be ignored and only - passed to the processterm() callback if it is defined by the app; also, this - feature can only be used with mng_readdisplay(); mng_read(), - mng_display_reset() and mng_display_goxxxx() will return an error; - once this option is turned off it can't be turned on for the same stream!!! */ -MNG_EXT mng_retcode MNG_DECL mng_set_cacheplayback (mng_handle hHandle, - mng_bool bCacheplayback); - -/* Indicates automatic progressive refreshes for large images (ON by default!) */ -/* turn this off if you do not want intermittent painting while a large image - is being read. useful if the input-stream comes from a fast medium, such - as a local harddisk */ -MNG_EXT mng_retcode MNG_DECL mng_set_doprogressive (mng_handle hHandle, - mng_bool bDoProgressive); - -/* Color-management necessaries */ -/* - ************************************************************************* - !!!!!!!! THIS BIT IS IMPORTANT !!!!!!!!! - ************************************************************************* - - If you have defined MNG_FULL_CMS (and are using lcms), you will have to - think hard about the following routines. - - lcms requires 2 profiles to work off the differences in the input-image - and the output-device. The ICC profile for the input-image will be - embedded within it to reflect its color-characteristics, but the output - profile depends on the output-device, which is something only *YOU* know - about. sRGB (standard RGB) is common for x86 compatible environments - (eg. Windows, Linux and some others) - - If you are compiling for a sRGB compliant system you probably won't have - to do anything special. (unless you want to ofcourse) - - If you are compiling for a non-sRGB compliant system - (eg. SGI, Mac, Next, others...) - you *MUST* define a proper ICC profile for the generic output-device - associated with that platform. - - In either event, you may also want to offer an option to your users to - set the profile manually, or, if you know how, set it from a - system-defined default. - - TO RECAP: for sRGB systems (Windows, Linux) no action required! - for non-sRGB systems (SGI, Mac, Next) ACTION REQUIRED! - - Please visit http://www.srgb.com, http://www.color.org and - http://www.littlecms.com for more info. - - ************************************************************************* - !!!!!!!! THIS BIT IS IMPORTANT !!!!!!!!! - ************************************************************************* -*/ -/* mng_set_srgb tells libmng if it's running on a sRGB compliant system or not - the default is already set to MNG_TRUE */ -/* mng_set_outputprofile, mng_set_outputprofile2, mng_set_outputsrgb - are used to set the default profile describing the output-device - by default it is already initialized with an sRGB profile */ -/* mng_set_srgbprofile, mng_set_srgbprofile2, mng_set_srgbimplicit - are used to set the default profile describing a standard sRGB device - this is used when the input-image is tagged only as being sRGB, but the - output-device is defined as not being sRGB compliant - by default it is already initialized with a standard sRGB profile */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_retcode MNG_DECL mng_set_srgb (mng_handle hHandle, - mng_bool bIssRGB); -MNG_EXT mng_retcode MNG_DECL mng_set_outputprofile (mng_handle hHandle, - mng_pchar zFilename); -MNG_EXT mng_retcode MNG_DECL mng_set_outputprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile); -MNG_EXT mng_retcode MNG_DECL mng_set_outputsrgb (mng_handle hHandle); -MNG_EXT mng_retcode MNG_DECL mng_set_srgbprofile (mng_handle hHandle, - mng_pchar zFilename); -MNG_EXT mng_retcode MNG_DECL mng_set_srgbprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile); -MNG_EXT mng_retcode MNG_DECL mng_set_srgbimplicit (mng_handle hHandle); -#endif - -/* Gamma settings */ -/* only used if you #define MNG_FULL_CMS or #define MNG_GAMMA_ONLY */ -/* ... blabla (explain gamma processing a little; eg. formula & stuff) ... */ -MNG_EXT mng_retcode MNG_DECL mng_set_viewgamma (mng_handle hHandle, - mng_float dGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_displaygamma (mng_handle hHandle, - mng_float dGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_dfltimggamma (mng_handle hHandle, - mng_float dGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_viewgammaint (mng_handle hHandle, - mng_uint32 iGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_displaygammaint (mng_handle hHandle, - mng_uint32 iGamma); -MNG_EXT mng_retcode MNG_DECL mng_set_dfltimggammaint (mng_handle hHandle, - mng_uint32 iGamma); - -/* Ultimate clipping size */ -/* used to limit extreme graphics from overloading the system */ -/* if a graphic exceeds these limits a warning is issued, which can - be ignored by the app (using the errorproc callback). in that case - the library will use these settings to clip the input graphic, and - the app's canvas must account for this */ -MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvaswidth (mng_handle hHandle, - mng_uint32 iMaxwidth); -MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvasheight (mng_handle hHandle, - mng_uint32 iMaxheight); -MNG_EXT mng_retcode MNG_DECL mng_set_maxcanvassize (mng_handle hHandle, - mng_uint32 iMaxwidth, - mng_uint32 iMaxheight); - -/* ZLIB default compression parameters */ -/* these are used when writing out chunks */ -/* they are also used when compressing PNG image-data or JNG alpha-data; - in this case you can set them just before calling mng_putimgdata_ihdr */ -/* set to your liking; usually the defaults will suffice though! */ -/* check the documentation for ZLIB for details on these parameters */ -#ifdef MNG_INCLUDE_ZLIB -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_level (mng_handle hHandle, - mng_int32 iZlevel); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_method (mng_handle hHandle, - mng_int32 iZmethod); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_windowbits (mng_handle hHandle, - mng_int32 iZwindowbits); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_memlevel (mng_handle hHandle, - mng_int32 iZmemlevel); -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_strategy (mng_handle hHandle, - mng_int32 iZstrategy); - -MNG_EXT mng_retcode MNG_DECL mng_set_zlib_maxidat (mng_handle hHandle, - mng_uint32 iMaxIDAT); -#endif /* MNG_INCLUDE_ZLIB */ - -/* JNG default compression parameters (based on IJG code) */ -/* these are used when compressing JNG image-data; so you can set them - just before calling mng_putimgdata_jhdr */ -/* set to your liking; usually the defaults will suffice though! */ -/* check the documentation for IJGSRC6B for details on these parameters */ -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_INCLUDE_IJG6B -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_dctmethod (mng_handle hHandle, - mngjpeg_dctmethod eJPEGdctmethod); -#endif -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_quality (mng_handle hHandle, - mng_int32 iJPEGquality); -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_smoothing (mng_handle hHandle, - mng_int32 iJPEGsmoothing); -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_progressive(mng_handle hHandle, - mng_bool bJPEGprogressive); -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_optimized (mng_handle hHandle, - mng_bool bJPEGoptimized); - -MNG_EXT mng_retcode MNG_DECL mng_set_jpeg_maxjdat (mng_handle hHandle, - mng_uint32 iMaxJDAT); -#endif /* MNG_INCLUDE_JNG */ - -/* Suspension-mode setting */ -/* use this to activate the internal suspension-buffer to improve - read-suspension processing */ -/* TODO: write-suspension ??? */ -#if defined(MNG_SUPPORT_READ) -MNG_EXT mng_retcode MNG_DECL mng_set_suspensionmode (mng_handle hHandle, - mng_bool bSuspensionmode); -#endif - -/* Speed setting */ -/* use this to influence the display-speed of animations */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_retcode MNG_DECL mng_set_speed (mng_handle hHandle, - mng_speedtype iSpeed); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Property get functions * */ -/* * * */ -/* ************************************************************************** */ - -/* see _set_ */ -MNG_EXT mng_ptr MNG_DECL mng_get_userdata (mng_handle hHandle); - -/* Network Graphic header details */ -/* these get filled once the graphics header is processed, - so they are available in the processheader callback; before that - they are zeroed out and imagetype is set to it_unknown */ -/* this might be a good point for the app to initialize the drawing-canvas! */ -/* note that some fields are only set for the first(!) header-chunk: - MNG/MHDR (imagetype = mng_it_mng) - ticks thru simplicity - PNG/IHDR (imagetype = mng_it_png) - bitdepth thru interlace - JNG/JHDR (imagetype = mng_it_jng) - bitdepth thru compression & - interlace thru alphainterlace */ -MNG_EXT mng_imgtype MNG_DECL mng_get_sigtype (mng_handle hHandle); -MNG_EXT mng_imgtype MNG_DECL mng_get_imagetype (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_imagewidth (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_imageheight (mng_handle hHandle); - -MNG_EXT mng_uint32 MNG_DECL mng_get_ticks (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_framecount (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_layercount (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_playtime (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_simplicity (mng_handle hHandle); - -MNG_EXT mng_uint8 MNG_DECL mng_get_bitdepth (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_colortype (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_compression (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_filter (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_interlace (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphabitdepth (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphacompression(mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphafilter (mng_handle hHandle); -MNG_EXT mng_uint8 MNG_DECL mng_get_alphainterlace (mng_handle hHandle); - -/* indicates the predicted alpha-depth required to properly display the image */ -/* gets set once the graphics header is processed and is available in the - processheader callback for any type of input-image (PNG, JNG or MNG) */ -/* possible values are 0,1,2,4,8,16 - 0 = no transparency required - 1 = on/off transparency required (alpha-values are 0 or 2^bit_depth-1) - 2+ = semi-transparency required (values will be scaled to the bitdepth of the - canvasstyle supplied by the application) */ -MNG_EXT mng_uint8 MNG_DECL mng_get_alphadepth (mng_handle hHandle); - -/* defines whether a refresh() callback is called for an interlace pass (PNG) - or progressive scan (JNG) */ -/* returns the interlace pass number for PNG or a fabricated pass number for JNG; - returns 0 in all other cases */ -/* only useful if the image_type = mng_it_png or mng_it_jng and if the image - is actually interlaced (PNG) or progressive (JNG) */ -MNG_EXT mng_uint8 MNG_DECL mng_get_refreshpass (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_uint32 MNG_DECL mng_get_canvasstyle (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_bkgdstyle (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_retcode MNG_DECL mng_get_bgcolor (mng_handle hHandle, - mng_uint16* iRed, - mng_uint16* iGreen, - mng_uint16* iBlue); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_usebkgd (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_storechunks (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_sectionbreaks (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_cacheplayback (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_bool MNG_DECL mng_get_doprogressive (mng_handle hHandle); - -/* see _set_ */ -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS) -MNG_EXT mng_bool MNG_DECL mng_get_srgb (mng_handle hHandle); -#endif - -/* see _set_ */ -MNG_EXT mng_float MNG_DECL mng_get_viewgamma (mng_handle hHandle); -MNG_EXT mng_float MNG_DECL mng_get_displaygamma (mng_handle hHandle); -MNG_EXT mng_float MNG_DECL mng_get_dfltimggamma (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_viewgammaint (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_displaygammaint (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_dfltimggammaint (mng_handle hHandle); - -/* see _set_ */ -MNG_EXT mng_uint32 MNG_DECL mng_get_maxcanvaswidth (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_maxcanvasheight (mng_handle hHandle); - -/* see _set_ */ -#ifdef MNG_INCLUDE_ZLIB -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_level (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_method (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_windowbits (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_memlevel (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_zlib_strategy (mng_handle hHandle); - -MNG_EXT mng_uint32 MNG_DECL mng_get_zlib_maxidat (mng_handle hHandle); -#endif /* MNG_INCLUDE_ZLIB */ - -/* see _set_ */ -#ifdef MNG_INCLUDE_JNG -#ifdef MNG_INCLUDE_IJG6B -MNG_EXT mngjpeg_dctmethod - MNG_DECL mng_get_jpeg_dctmethod (mng_handle hHandle); -#endif -MNG_EXT mng_int32 MNG_DECL mng_get_jpeg_quality (mng_handle hHandle); -MNG_EXT mng_int32 MNG_DECL mng_get_jpeg_smoothing (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_get_jpeg_progressive(mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_get_jpeg_optimized (mng_handle hHandle); - -MNG_EXT mng_uint32 MNG_DECL mng_get_jpeg_maxjdat (mng_handle hHandle); -#endif /* MNG_INCLUDE_JNG */ - -/* see _set_ */ -#if defined(MNG_SUPPORT_READ) -MNG_EXT mng_bool MNG_DECL mng_get_suspensionmode (mng_handle hHandle); -#endif - -/* see _set_ */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_speedtype - MNG_DECL mng_get_speed (mng_handle hHandle); -#endif - -/* Image-level */ -/* this can be used inside the processtext callback to determine the level of - text of the image being processed; the value 1 is returned for top-level - texts, and the value 2 for a text inside an embedded image inside a MNG */ -MNG_EXT mng_uint32 MNG_DECL mng_get_imagelevel (mng_handle hHandle); - -/* Display status variables */ -/* these get filled & updated during display processing */ -/* starttime is the tickcount at the start of displaying the animation */ -/* runtime is the actual number of millisecs since the start of the animation */ -/* currentframe, currentlayer & currentplaytime indicate the current - frame/layer/playtime(msecs) in the animation (these keep increasing; - even after the animation loops back to the TERM chunk) */ -#if defined(MNG_SUPPORT_DISPLAY) -MNG_EXT mng_uint32 MNG_DECL mng_get_starttime (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_runtime (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_currentframe (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_currentlayer (mng_handle hHandle); -MNG_EXT mng_uint32 MNG_DECL mng_get_currentplaytime (mng_handle hHandle); -#endif - -/* Status variables */ -/* these indicate the internal state of the library */ -/* most indicate exactly what you would expect: - status_error returns MNG_TRUE if the last function call returned an errorcode - status_reading returns MNG_TRUE if the library is (still) reading an image - status_suspendbreak returns MNG_TRUE if the library has suspended for "I/O" - status_creating returns MNG_TRUE if the library is in the middle of creating an image - status_writing returns MNG_TRUE if the library is in the middle of writing an image - status_displaying returns MNG_TRUE if the library is displaying an image - status_running returns MNG_TRUE if display processing is active (eg. not frozen or reset) - status_timerbreak returns MNG_TRUE if the library has suspended for a "timer-break" */ -/* eg. mng_readdisplay() will turn the reading, displaying and running status on; - when EOF is reached the reading status will be turned off */ -MNG_EXT mng_bool MNG_DECL mng_status_error (mng_handle hHandle); -#ifdef MNG_SUPPORT_READ -MNG_EXT mng_bool MNG_DECL mng_status_reading (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_suspendbreak (mng_handle hHandle); -#endif -#ifdef MNG_SUPPORT_WRITE -MNG_EXT mng_bool MNG_DECL mng_status_creating (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_writing (mng_handle hHandle); -#endif -#ifdef MNG_SUPPORT_DISPLAY -MNG_EXT mng_bool MNG_DECL mng_status_displaying (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_running (mng_handle hHandle); -MNG_EXT mng_bool MNG_DECL mng_status_timerbreak (mng_handle hHandle); -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Chunk access functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_ACCESS_CHUNKS - -/* ************************************************************************** */ - -/* use this to iterate the stored chunks */ -/* requires MNG_ACCESS_CHUNKS & MNG_STORE_CHUNKS */ -/* starts from the supplied chunk-index-nr; the first chunk has index 0!! */ -MNG_EXT mng_retcode MNG_DECL mng_iterate_chunks (mng_handle hHandle, - mng_uint32 iChunkseq, - mng_iteratechunk fProc); - -/* ************************************************************************** */ - -/* use these to get chunk data from within the callback in iterate_chunks */ -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ihdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_plte (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_palette8 *aPalette); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_idat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_trns (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_bool *bGlobal, - mng_uint8 *iType, - mng_uint32 *iCount, - mng_uint8arr *aAlphas, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint32 *iRawlen, - mng_uint8arr *aRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_gama (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iGamma); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_chrm (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iWhitepointx, - mng_uint32 *iWhitepointy, - mng_uint32 *iRedx, - mng_uint32 *iRedy, - mng_uint32 *iGreenx, - mng_uint32 *iGreeny, - mng_uint32 *iBluex, - mng_uint32 *iBluey); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_srgb (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iRenderingintent); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_iccp (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iCompression, - mng_uint32 *iProfilesize, - mng_ptr *pProfile); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_text (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint32 *iTextsize, - mng_pchar *zText); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ztxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompression, - mng_uint32 *iTextsize, - mng_pchar *zText); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_itxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompressionflag, - mng_uint8 *iCompressionmethod, - mng_uint32 *iLanguagesize, - mng_pchar *zLanguage, - mng_uint32 *iTranslationsize, - mng_pchar *zTranslation, - mng_uint32 *iTextsize, - mng_pchar *zText); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_bkgd (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8 *iIndex, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_phys (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_sbit (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8arr4 *aBits); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_splt (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iSampledepth, - mng_uint32 *iEntrycount, - mng_ptr *pEntries); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_hist (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iEntrycount, - mng_uint16arr *aEntries); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_time (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iYear, - mng_uint8 *iMonth, - mng_uint8 *iDay, - mng_uint8 *iHour, - mng_uint8 *iMinute, - mng_uint8 *iSecond); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_mhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint32 *iTicks, - mng_uint32 *iLayercount, - mng_uint32 *iFramecount, - mng_uint32 *iPlaytime, - mng_uint32 *iSimplicity); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_loop (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel, - mng_uint32 *iRepeat, - mng_uint8 *iTermination, - mng_uint32 *iItermin, - mng_uint32 *iItermax, - mng_uint32 *iCount, - mng_uint32p *pSignals); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_endl (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_defi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_int32 *iXlocation, - mng_int32 *iYlocation, - mng_bool *bHasclip, - mng_int32 *iLeftcb, - mng_int32 *iRightcb, - mng_int32 *iTopcb, - mng_int32 *iBottomcb); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_basi (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_uint8 *iViewable); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_clon (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSourceid, - mng_uint16 *iCloneid, - mng_uint8 *iClonetype, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_uint8 *iLocationtype, - mng_int32 *iLocationx, - mng_int32 *iLocationy); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_past (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iDestid, - mng_uint8 *iTargettype, - mng_int32 *iTargetx, - mng_int32 *iTargety, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_past_src (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iSourceid, - mng_uint8 *iComposition, - mng_uint8 *iOrientation, - mng_uint8 *iOffsettype, - mng_int32 *iOffsetx, - mng_int32 *iOffsety, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_disc (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_uint16p *pObjectids); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_back (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint8 *iMandatory, - mng_uint16 *iImageid, - mng_uint8 *iTile); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_fram (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iMode, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iChangedelay, - mng_uint8 *iChangetimeout, - mng_uint8 *iChangeclipping, - mng_uint8 *iChangesyncid, - mng_uint32 *iDelay, - mng_uint32 *iTimeout, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb, - mng_uint32 *iCount, - mng_uint32p *pSyncids); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_move (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMovetype, - mng_int32 *iMovex, - mng_int32 *iMovey); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_clip (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iCliptype, - mng_int32 *iClipl, - mng_int32 *iClipr, - mng_int32 *iClipt, - mng_int32 *iClipb); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_show (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMode); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_term (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iTermaction, - mng_uint8 *iIteraction, - mng_uint32 *iDelay, - mng_uint32 *iItermax); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_save (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iOffsettype, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_save_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint8 *iEntrytype, - mng_uint32arr2 *iOffset, - mng_uint32arr2 *iStarttime, - mng_uint32 *iLayernr, - mng_uint32 *iFramenr, - mng_uint32 *iNamesize, - mng_pchar *zName); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_seek (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iNamesize, - mng_pchar *zName); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_expi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSnapshotid, - mng_uint32 *iNamesize, - mng_pchar *zName); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_fpri (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iDeltatype, - mng_uint8 *iPriority); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_need (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_phyg (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_jhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iColortype, - mng_uint8 *iImagesampledepth, - mng_uint8 *iImagecompression, - mng_uint8 *iImageinterlace, - mng_uint8 *iAlphasampledepth, - mng_uint8 *iAlphacompression, - mng_uint8 *iAlphafilter, - mng_uint8 *iAlphainterlace); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_jdat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_jdaa (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_dhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iImagetype, - mng_uint8 *iDeltatype, - mng_uint32 *iBlockwidth, - mng_uint32 *iBlockheight, - mng_uint32 *iBlockx, - mng_uint32 *iBlocky); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_prom (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iColortype, - mng_uint8 *iSampledepth, - mng_uint8 *iFilltype); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_pplt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_pplt_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_bool *bUsed); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_drop (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_chunkidp *pChunknames); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_dbyk (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint8 *iPolarity, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ordr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_ordr_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_chunkid *iChunkname, - mng_uint8 *iOrdertype); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_magn (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint16 *iMethodX, - mng_uint16 *iMX, - mng_uint16 *iMY, - mng_uint16 *iML, - mng_uint16 *iMR, - mng_uint16 *iMT, - mng_uint16 *iMB, - mng_uint16 *iMethodY); - -MNG_EXT mng_retcode MNG_DECL mng_getchunk_unknown (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint32 *iRawlen, - mng_ptr *pRawdata); - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* use these to create new chunks at the end of the chunk-list */ -/* requires at least MNG_ACCESS_CHUNKS (MNG_SUPPORT_WRITE may be nice too) */ -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_plte (mng_handle hHandle, - mng_uint32 iCount, - mng_palette8 aPalette); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_idat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_iend (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_trns (mng_handle hHandle, - mng_bool bEmpty, - mng_bool bGlobal, - mng_uint8 iType, - mng_uint32 iCount, - mng_uint8arr aAlphas, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint32 iRawlen, - mng_uint8arr aRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_gama (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iGamma); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_chrm (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_srgb (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iRenderingintent); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_iccp (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iCompression, - mng_uint32 iProfilesize, - mng_ptr pProfile); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_text (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint32 iTextsize, - mng_pchar zText); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ztxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompression, - mng_uint32 iTextsize, - mng_pchar zText); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_itxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompressionflag, - mng_uint8 iCompressionmethod, - mng_uint32 iLanguagesize, - mng_pchar zLanguage, - mng_uint32 iTranslationsize, - mng_pchar zTranslation, - mng_uint32 iTextsize, - mng_pchar zText); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_bkgd (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8 iIndex, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_phys (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_sbit (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8arr4 aBits); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_splt (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iSampledepth, - mng_uint32 iEntrycount, - mng_ptr pEntries); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_hist (mng_handle hHandle, - mng_uint32 iEntrycount, - mng_uint16arr aEntries); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_time (mng_handle hHandle, - mng_uint16 iYear, - mng_uint8 iMonth, - mng_uint8 iDay, - mng_uint8 iHour, - mng_uint8 iMinute, - mng_uint8 iSecond); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_mhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint32 iTicks, - mng_uint32 iLayercount, - mng_uint32 iFramecount, - mng_uint32 iPlaytime, - mng_uint32 iSimplicity); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_mend (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_loop (mng_handle hHandle, - mng_uint8 iLevel, - mng_uint32 iRepeat, - mng_uint8 iTermination, - mng_uint32 iItermin, - mng_uint32 iItermax, - mng_uint32 iCount, - mng_uint32p pSignals); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_endl (mng_handle hHandle, - mng_uint8 iLevel); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_defi (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_int32 iXlocation, - mng_int32 iYlocation, - mng_bool bHasclip, - mng_int32 iLeftcb, - mng_int32 iRightcb, - mng_int32 iTopcb, - mng_int32 iBottomcb); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_basi (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha, - mng_uint8 iViewable); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_clon (mng_handle hHandle, - mng_uint16 iSourceid, - mng_uint16 iCloneid, - mng_uint8 iClonetype, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_past (mng_handle hHandle, - mng_uint16 iDestid, - mng_uint8 iTargettype, - mng_int32 iTargetx, - mng_int32 iTargety, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_past_src (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iSourceid, - mng_uint8 iComposition, - mng_uint8 iOrientation, - mng_uint8 iOffsettype, - mng_int32 iOffsetx, - mng_int32 iOffsety, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_disc (mng_handle hHandle, - mng_uint32 iCount, - mng_uint16p pObjectids); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_back (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_fram (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iMode, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iChangedelay, - mng_uint8 iChangetimeout, - mng_uint8 iChangeclipping, - mng_uint8 iChangesyncid, - mng_uint32 iDelay, - mng_uint32 iTimeout, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb, - mng_uint32 iCount, - mng_uint32p pSyncids); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_move (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_clip (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_show (mng_handle hHandle, - mng_bool bEmpty, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_term (mng_handle hHandle, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_save (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iOffsettype, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_save_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint8 iEntrytype, - mng_uint32arr2 iOffset, - mng_uint32arr2 iStarttime, - mng_uint32 iLayernr, - mng_uint32 iFramenr, - mng_uint32 iNamesize, - mng_pchar zName); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_seek (mng_handle hHandle, - mng_uint32 iNamesize, - mng_pchar zName); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_expi (mng_handle hHandle, - mng_uint16 iSnapshotid, - mng_uint32 iNamesize, - mng_pchar zName); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_fpri (mng_handle hHandle, - mng_uint8 iDeltatype, - mng_uint8 iPriority); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_need (mng_handle hHandle, - mng_uint32 iKeywordssize, - mng_pchar zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_phyg (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iImagesampledepth, - mng_uint8 iImagecompression, - mng_uint8 iImageinterlace, - mng_uint8 iAlphasampledepth, - mng_uint8 iAlphacompression, - mng_uint8 iAlphafilter, - mng_uint8 iAlphainterlace); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jdat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jdaa (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jsep (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_dhdr (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_prom (mng_handle hHandle, - mng_uint8 iColortype, - mng_uint8 iSampledepth, - mng_uint8 iFilltype); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ipng (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_pplt (mng_handle hHandle, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_pplt_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha, - mng_bool bUsed); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_jpng (mng_handle hHandle); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_drop (mng_handle hHandle, - mng_uint32 iCount, - mng_chunkidp pChunknames); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_dbyk (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint8 iPolarity, - mng_uint32 iKeywordssize, - mng_pchar zKeywords); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ordr (mng_handle hHandle, - mng_uint32 iCount); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_ordr_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_chunkid iChunkname, - mng_uint8 iOrdertype); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_magn (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY); - -MNG_EXT mng_retcode MNG_DECL mng_putchunk_unknown (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint32 iRawlen, - mng_ptr pRawdata); - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ - -/* use these functions to access the actual image-data in stored chunks, - as opposed to the IDAT/JDAT data */ -/* to get accurate pixel-data the canvasstyle should seriously reflect the - bitdepth/colortype combination of the preceding IHDR/JHDR/BASI/DHDR; - all input can be converted to rgb(a)8 (rgb(a)16 for 16-bit images), but - there are only limited conversions back (see below for putimgdata) */ - -/* call this function if you want to extract the nth image from the list; - the first image is designated seqnr 0! */ -/* this function finds the IHDR/JHDR/BASI/DHDR with the appropriate seqnr, - starting from the beginning of the chunk-list; this may tend to get a little - slow for animations with a large number of chunks for images near the end */ -/* supplying a seqnr past the last image in the animation will return with - an errorcode */ -MNG_EXT mng_retcode MNG_DECL mng_getimgdata_seq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* both the following functions will search forward to find the first IDAT/JDAT, - and then traverse back to find the start of the image (IHDR,JHDR,DHDR,BASI); - note that this is very fast compared to decoding the IDAT/JDAT, so there's - not really a need for optimization; either can be called from the - iterate_chunks callback when a IHDR/JHDR is encountered; for BASI/DHDR there - may not be real image-data so it's wisest to keep iterating till the IEND, - and then call either of these functions if necessary (remember the correct seqnr!) */ - -/* call this function if you want to extract the image starting at or after the nth - position in the chunk-list; this number is returned in the iterate_chunks callback */ -MNG_EXT mng_retcode MNG_DECL mng_getimgdata_chunkseq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* call this function if you want to extract the image starting at or after the - indicated chunk; the handle of a chunk is returned in the iterate_chunks callback */ -MNG_EXT mng_retcode MNG_DECL mng_getimgdata_chunk (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* use the following functions to add image-data to the list of stored chunks */ -/* note that this only adds the IDAT or JDAT chunks and no others; you must call - one of these functions after you 'put' the initial chunks of the image and - before you 'put' the closing chunks */ -/* the canvasstyle should seriously reflect the bitdepth/colortype combination; - eg. bitdepth=16 would expect a 16-bit canvasstyle, - colortype=g or ga would expect a gray or gray+alpha style respectively - and so on, and so forth ... - (nb. the number of conversions will be extremely limited for the moment!) */ - -MNG_EXT mng_retcode MNG_DECL mng_putimgdata_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -MNG_EXT mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iInterlace, - mng_uint8 iAlphaBitdepth, - mng_uint8 iAlphaCompression, - mng_uint8 iAlphaFilter, - mng_uint8 iAlphaInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline); - -/* ************************************************************************** */ - -/* use the following functions to set the framecount/layercount/playtime or - simplicity of an animation you are creating; this may be useful if these - variables are calculated during the creation-process */ - -MNG_EXT mng_retcode MNG_DECL mng_updatemngheader (mng_handle hHandle, - mng_uint32 iFramecount, - mng_uint32 iLayercount, - mng_uint32 iPlaytime); - -MNG_EXT mng_retcode MNG_DECL mng_updatemngsimplicity (mng_handle hHandle, - mng_uint32 iSimplicity); - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -#endif /* MNG_ACCESS_CHUNKS */ - -/* ************************************************************************** */ -/* * * */ -/* * Error-code structure * */ -/* * * */ -/* * 0b0000 00xx xxxx xxxx - basic errors; severity 9 (environment) * */ -/* * 0b0000 01xx xxxx xxxx - chunk errors; severity 9 (image induced) * */ -/* * 0b0000 10xx xxxx xxxx - severity 5 errors (application induced) * */ -/* * 0b0001 00xx xxxx xxxx - severity 2 warnings (recoverable) * */ -/* * 0b0010 00xx xxxx xxxx - severity 1 warnings (recoverable) * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_NOERROR (mng_retcode)0 /* er.. indicates all's well */ - -#define MNG_OUTOFMEMORY (mng_retcode)1 /* oops, buy some megabytes! */ -#define MNG_INVALIDHANDLE (mng_retcode)2 /* call mng_initialize first */ -#define MNG_NOCALLBACK (mng_retcode)3 /* set the callbacks please */ -#define MNG_UNEXPECTEDEOF (mng_retcode)4 /* what'd ya do with the data? */ -#define MNG_ZLIBERROR (mng_retcode)5 /* zlib burped */ -#define MNG_JPEGERROR (mng_retcode)6 /* jpglib complained */ -#define MNG_LCMSERROR (mng_retcode)7 /* little cms stressed out */ -#define MNG_NOOUTPUTPROFILE (mng_retcode)8 /* no output-profile defined */ -#define MNG_NOSRGBPROFILE (mng_retcode)9 /* no sRGB-profile defined */ -#define MNG_BUFOVERFLOW (mng_retcode)10 /* zlib output-buffer overflow */ -#define MNG_FUNCTIONINVALID (mng_retcode)11 /* ay, totally inappropriate */ -#define MNG_OUTPUTERROR (mng_retcode)12 /* disk full ? */ -#define MNG_JPEGBUFTOOSMALL (mng_retcode)13 /* can't handle buffer overflow*/ -#define MNG_NEEDMOREDATA (mng_retcode)14 /* I'm hungry, give me more */ -#define MNG_NEEDTIMERWAIT (mng_retcode)15 /* Sleep a while then wake me */ -#define MNG_NEEDSECTIONWAIT (mng_retcode)16 /* just processed a SEEK */ -#define MNG_LOOPWITHCACHEOFF (mng_retcode)17 /* LOOP when playback info off */ - -#define MNG_DLLNOTLOADED (mng_retcode)99 /* late binding failed */ - -#define MNG_APPIOERROR (mng_retcode)901 /* application I/O error */ -#define MNG_APPTIMERERROR (mng_retcode)902 /* application timing error */ -#define MNG_APPCMSERROR (mng_retcode)903 /* application CMS error */ -#define MNG_APPMISCERROR (mng_retcode)904 /* application other error */ -#define MNG_APPTRACEABORT (mng_retcode)905 /* application aborts on trace */ - -#define MNG_INTERNALERROR (mng_retcode)999 /* internal inconsistancy */ - -#define MNG_INVALIDSIG (mng_retcode)1025 /* invalid graphics file */ -#define MNG_INVALIDCRC (mng_retcode)1027 /* crc check failed */ -#define MNG_INVALIDLENGTH (mng_retcode)1028 /* chunklength mystifies me */ -#define MNG_SEQUENCEERROR (mng_retcode)1029 /* invalid chunk sequence */ -#define MNG_CHUNKNOTALLOWED (mng_retcode)1030 /* completely out-of-place */ -#define MNG_MULTIPLEERROR (mng_retcode)1031 /* only one occurence allowed */ -#define MNG_PLTEMISSING (mng_retcode)1032 /* indexed-color requires PLTE */ -#define MNG_IDATMISSING (mng_retcode)1033 /* IHDR-block requires IDAT */ -#define MNG_CANNOTBEEMPTY (mng_retcode)1034 /* must contain some data */ -#define MNG_GLOBALLENGTHERR (mng_retcode)1035 /* global data incorrect */ -#define MNG_INVALIDBITDEPTH (mng_retcode)1036 /* bitdepth out-of-range */ -#define MNG_INVALIDCOLORTYPE (mng_retcode)1037 /* colortype out-of-range */ -#define MNG_INVALIDCOMPRESS (mng_retcode)1038 /* compression method invalid */ -#define MNG_INVALIDFILTER (mng_retcode)1039 /* filter method invalid */ -#define MNG_INVALIDINTERLACE (mng_retcode)1040 /* interlace method invalid */ -#define MNG_NOTENOUGHIDAT (mng_retcode)1041 /* ran out of compressed data */ -#define MNG_PLTEINDEXERROR (mng_retcode)1042 /* palette-index out-of-range */ -#define MNG_NULLNOTFOUND (mng_retcode)1043 /* couldn't find null-separator*/ -#define MNG_KEYWORDNULL (mng_retcode)1044 /* keyword cannot be empty */ -#define MNG_OBJECTUNKNOWN (mng_retcode)1045 /* the object can't be found */ -#define MNG_OBJECTEXISTS (mng_retcode)1046 /* the object already exists */ -#define MNG_TOOMUCHIDAT (mng_retcode)1047 /* got too much compressed data*/ -#define MNG_INVSAMPLEDEPTH (mng_retcode)1048 /* sampledepth out-of-range */ -#define MNG_INVOFFSETSIZE (mng_retcode)1049 /* invalid offset-size */ -#define MNG_INVENTRYTYPE (mng_retcode)1050 /* invalid entry-type */ -#define MNG_ENDWITHNULL (mng_retcode)1051 /* may not end with NULL */ -#define MNG_INVIMAGETYPE (mng_retcode)1052 /* invalid image_type */ -#define MNG_INVDELTATYPE (mng_retcode)1053 /* invalid delta_type */ -#define MNG_INVALIDINDEX (mng_retcode)1054 /* index-value invalid */ -#define MNG_TOOMUCHJDAT (mng_retcode)1055 /* got too much compressed data*/ -#define MNG_JPEGPARMSERR (mng_retcode)1056 /* JHDR/JPEG parms do not match*/ -#define MNG_INVFILLMETHOD (mng_retcode)1057 /* invalid fill_method */ -#define MNG_OBJNOTCONCRETE (mng_retcode)1058 /* object must be concrete */ -#define MNG_TARGETNOALPHA (mng_retcode)1059 /* object has no alpha-channel */ -#define MNG_MNGTOOCOMPLEX (mng_retcode)1060 /* can't handle complexity */ -#define MNG_UNKNOWNCRITICAL (mng_retcode)1061 /* unknown critical chunk found*/ -#define MNG_UNSUPPORTEDNEED (mng_retcode)1062 /* nEED requirement unsupported*/ -#define MNG_INVALIDDELTA (mng_retcode)1063 /* Delta operation illegal */ -#define MNG_INVALIDMETHOD (mng_retcode)1064 /* invalid MAGN method */ - -#define MNG_INVALIDCNVSTYLE (mng_retcode)2049 /* can't make anything of this */ -#define MNG_WRONGCHUNK (mng_retcode)2050 /* accessing the wrong chunk */ -#define MNG_INVALIDENTRYIX (mng_retcode)2051 /* accessing the wrong entry */ -#define MNG_NOHEADER (mng_retcode)2052 /* must have had header first */ -#define MNG_NOCORRCHUNK (mng_retcode)2053 /* can't find parent chunk */ -#define MNG_NOMHDR (mng_retcode)2054 /* no MNG header available */ - -#define MNG_IMAGETOOLARGE (mng_retcode)4097 /* input-image way too big */ -#define MNG_NOTANANIMATION (mng_retcode)4098 /* file not a MNG */ -#define MNG_FRAMENRTOOHIGH (mng_retcode)4099 /* frame-nr out-of-range */ -#define MNG_LAYERNRTOOHIGH (mng_retcode)4100 /* layer-nr out-of-range */ -#define MNG_PLAYTIMETOOHIGH (mng_retcode)4101 /* playtime out-of-range */ -#define MNG_FNNOTIMPLEMENTED (mng_retcode)4102 /* function not yet available */ - -#define MNG_IMAGEFROZEN (mng_retcode)8193 /* stopped displaying */ - -#define MNG_LCMS_NOHANDLE 1 /* LCMS returned NULL handle */ -#define MNG_LCMS_NOMEM 2 /* LCMS returned NULL gammatab */ -#define MNG_LCMS_NOTRANS 3 /* LCMS returned NULL transform*/ - -/* ************************************************************************** */ -/* * * */ -/* * Canvas styles * */ -/* * * */ -/* * Note that the intentions are pretty darn good, but that the focus * */ -/* * is currently on 8-bit color support * */ -/* * * */ -/* * The RGB8_A8 style is defined for apps that require a separate * */ -/* * canvas for the color-planes and the alpha-plane (eg. mozilla) * */ -/* * This requires for the app to supply the "getalphaline" callback!!! * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_CANVAS_RGB8 0x00000000L -#define MNG_CANVAS_RGBA8 0x00001000L -#define MNG_CANVAS_ARGB8 0x00003000L -#define MNG_CANVAS_RGB8_A8 0x00005000L -#define MNG_CANVAS_BGR8 0x00000001L -#define MNG_CANVAS_BGRA8 0x00001001L -#define MNG_CANVAS_BGRA8PM 0x00009001L -#define MNG_CANVAS_ABGR8 0x00003001L -#define MNG_CANVAS_RGB16 0x00000100L /* not supported yet */ -#define MNG_CANVAS_RGBA16 0x00001100L /* not supported yet */ -#define MNG_CANVAS_ARGB16 0x00003100L /* not supported yet */ -#define MNG_CANVAS_BGR16 0x00000101L /* not supported yet */ -#define MNG_CANVAS_BGRA16 0x00001101L /* not supported yet */ -#define MNG_CANVAS_ABGR16 0x00003101L /* not supported yet */ -#define MNG_CANVAS_GRAY8 0x00000002L /* not supported yet */ -#define MNG_CANVAS_GRAY16 0x00000102L /* not supported yet */ -#define MNG_CANVAS_GRAYA8 0x00001002L /* not supported yet */ -#define MNG_CANVAS_GRAYA16 0x00001102L /* not supported yet */ -#define MNG_CANVAS_AGRAY8 0x00003002L /* not supported yet */ -#define MNG_CANVAS_AGRAY16 0x00003102L /* not supported yet */ -#define MNG_CANVAS_DX15 0x00000003L /* not supported yet */ -#define MNG_CANVAS_DX16 0x00000004L /* not supported yet */ - -#define MNG_CANVAS_PIXELTYPE(C) (C & 0x000000FFL) -#define MNG_CANVAS_BITDEPTH(C) (C & 0x00000100L) -#define MNG_CANVAS_HASALPHA(C) (C & 0x00001000L) -#define MNG_CANVAS_ALPHAFIRST(C) (C & 0x00002000L) -#define MNG_CANVAS_ALPHASEPD(C) (C & 0x00004000L) -#define MNG_CANVAS_ALPHAPM(C) (C & 0x00008000L) - -#define MNG_CANVAS_RGB(C) (MNG_CANVAS_PIXELTYPE (C) == 0) -#define MNG_CANVAS_BGR(C) (MNG_CANVAS_PIXELTYPE (C) == 1) -#define MNG_CANVAS_GRAY(C) (MNG_CANVAS_PIXELTYPE (C) == 2) -#define MNG_CANVAS_DIRECTX15(C) (MNG_CANVAS_PIXELTYPE (C) == 3) -#define MNG_CANVAS_DIRECTX16(C) (MNG_CANVAS_PIXELTYPE (C) == 4) -#define MNG_CANVAS_8BIT(C) (!MNG_CANVAS_BITDEPTH (C)) -#define MNG_CANVAS_16BIT(C) (MNG_CANVAS_BITDEPTH (C)) -#define MNG_CANVAS_PIXELFIRST(C) (!MNG_CANVAS_ALPHAFIRST (C)) - -/* ************************************************************************** */ -/* * * */ -/* * Chunk names (idea adapted from libpng 1.1.0 - png.h) * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_UINT_HUH 0x40404040L - -#define MNG_UINT_BACK 0x4241434bL -#define MNG_UINT_BASI 0x42415349L -#define MNG_UINT_CLIP 0x434c4950L -#define MNG_UINT_CLON 0x434c4f4eL -#define MNG_UINT_DBYK 0x4442594bL -#define MNG_UINT_DEFI 0x44454649L -#define MNG_UINT_DHDR 0x44484452L -#define MNG_UINT_DISC 0x44495343L -#define MNG_UINT_DROP 0x44524f50L -#define MNG_UINT_ENDL 0x454e444cL -#define MNG_UINT_FRAM 0x4652414dL -#define MNG_UINT_IDAT 0x49444154L -#define MNG_UINT_IEND 0x49454e44L -#define MNG_UINT_IHDR 0x49484452L -#define MNG_UINT_IJNG 0x494a4e47L -#define MNG_UINT_IPNG 0x49504e47L -#define MNG_UINT_JDAA 0x4a444141L -#define MNG_UINT_JDAT 0x4a444154L -#define MNG_UINT_JHDR 0x4a484452L -#define MNG_UINT_JSEP 0x4a534550L -#define MNG_UINT_JdAA 0x4a644141L -#define MNG_UINT_LOOP 0x4c4f4f50L -#define MNG_UINT_MAGN 0x4d41474eL -#define MNG_UINT_MEND 0x4d454e44L -#define MNG_UINT_MHDR 0x4d484452L -#define MNG_UINT_MOVE 0x4d4f5645L -#define MNG_UINT_ORDR 0x4f524452L -#define MNG_UINT_PAST 0x50415354L -#define MNG_UINT_PLTE 0x504c5445L -#define MNG_UINT_PPLT 0x50504c54L -#define MNG_UINT_PROM 0x50524f4dL -#define MNG_UINT_SAVE 0x53415645L -#define MNG_UINT_SEEK 0x5345454bL -#define MNG_UINT_SHOW 0x53484f57L -#define MNG_UINT_TERM 0x5445524dL -#define MNG_UINT_bKGD 0x624b4744L -#define MNG_UINT_cHRM 0x6348524dL -#define MNG_UINT_eXPI 0x65585049L -#define MNG_UINT_fPRI 0x66505249L -#define MNG_UINT_gAMA 0x67414d41L -#define MNG_UINT_hIST 0x68495354L -#define MNG_UINT_iCCP 0x69434350L -#define MNG_UINT_iTXt 0x69545874L -#define MNG_UINT_nEED 0x6e454544L -#define MNG_UINT_oFFs 0x6f464673L -#define MNG_UINT_pCAL 0x7043414cL -#define MNG_UINT_pHYg 0x70444167L -#define MNG_UINT_pHYs 0x70485973L -#define MNG_UINT_sBIT 0x73424954L -#define MNG_UINT_sCAL 0x7343414cL -#define MNG_UINT_sPLT 0x73504c54L -#define MNG_UINT_sRGB 0x73524742L -#define MNG_UINT_tEXt 0x74455874L -#define MNG_UINT_tIME 0x74494d45L -#define MNG_UINT_tRNS 0x74524e53L -#define MNG_UINT_zTXt 0x7a545874L - -/* ************************************************************************** */ -/* * * */ -/* * Chunk property values * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_BITDEPTH_1 1 /* IHDR, BASI, JHDR, PROM */ -#define MNG_BITDEPTH_2 2 -#define MNG_BITDEPTH_4 4 -#define MNG_BITDEPTH_8 8 /* sPLT */ -#define MNG_BITDEPTH_16 16 - -#define MNG_COLORTYPE_GRAY 0 /* IHDR, BASI, PROM */ -#define MNG_COLORTYPE_RGB 2 -#define MNG_COLORTYPE_INDEXED 3 -#define MNG_COLORTYPE_GRAYA 4 -#define MNG_COLORTYPE_RGBA 6 - -#define MNG_COMPRESSION_DEFLATE 0 /* IHDR, zTXt, iTXt, iCCP, - BASI, JHDR */ - -#define MNG_FILTER_ADAPTIVE 0 /* IHDR, BASI, JHDR */ -/* #define MNG_FILTER_NO_ADAPTIVE 1 */ -#define MNG_FILTER_NO_DIFFERING 0 -#define MNG_FILTER_DIFFERING 0x40 -/* #define MNG_FILTER_MASK (MNG_FILTER_NO_ADAPTIVE | MNG_FILTER_DIFFERING) */ - -#define MNG_INTERLACE_NONE 0 /* IHDR, BASI, JHDR */ -#define MNG_INTERLACE_ADAM7 1 - -#define MNG_FILTER_NONE 0 /* IDAT */ -#define MNG_FILTER_SUB 1 -#define MNG_FILTER_UP 2 -#define MNG_FILTER_AVERAGE 3 -#define MNG_FILTER_PAETH 4 - -#define MNG_INTENT_PERCEPTUAL 0 /* sRGB */ -#define MNG_INTENT_RELATIVECOLORIMETRIC 1 -#define MNG_INTENT_SATURATION 2 -#define MNG_INTENT_ABSOLUTECOLORIMETRIC 3 - /* tEXt, zTXt, iTXt */ -#define MNG_TEXT_TITLE "Title" -#define MNG_TEXT_AUTHOR "Author" -#define MNG_TEXT_DESCRIPTION "Description" -#define MNG_TEXT_COPYRIGHT "Copyright" -#define MNG_TEXT_CREATIONTIME "Creation Time" -#define MNG_TEXT_SOFTWARE "Software" -#define MNG_TEXT_DISCLAIMER "Disclaimer" -#define MNG_TEXT_WARNING "Warning" -#define MNG_TEXT_SOURCE "Source" -#define MNG_TEXT_COMMENT "Comment" - -#define MNG_FLAG_UNCOMPRESSED 0 /* iTXt */ -#define MNG_FLAG_COMPRESSED 1 - -#define MNG_UNIT_UNKNOWN 0 /* pHYs, pHYg */ -#define MNG_UNIT_METER 1 - /* MHDR */ -#define MNG_SIMPLICITY_VALID 0x00000001 -#define MNG_SIMPLICITY_SIMPLEFEATURES 0x00000002 -#define MNG_SIMPLICITY_COMPLEXFEATURES 0x00000004 -#define MNG_SIMPLICITY_TRANSPARENCY 0x00000008 -#define MNG_SIMPLICITY_JNG 0x00000010 -#define MNG_SIMPLICITY_DELTAPNG 0x00000020 - -#define MNG_TERMINATION_DECODER_NC 0 /* LOOP */ -#define MNG_TERMINATION_USER_NC 1 -#define MNG_TERMINATION_EXTERNAL_NC 2 -#define MNG_TERMINATION_DETERMINISTIC_NC 3 -#define MNG_TERMINATION_DECODER_C 4 -#define MNG_TERMINATION_USER_C 5 -#define MNG_TERMINATION_EXTERNAL_C 6 -#define MNG_TERMINATION_DETERMINISTIC_C 7 - -#define MNG_DONOTSHOW_VISIBLE 0 /* DEFI */ -#define MNG_DONOTSHOW_NOTVISIBLE 1 - -#define MNG_ABSTRACT 0 /* DEFI */ -#define MNG_CONCRETE 1 - -#define MNG_NOTVIEWABLE 0 /* BASI */ -#define MNG_VIEWABLE 1 - -#define MNG_FULL_CLONE 0 /* CLON */ -#define MNG_PARTIAL_CLONE 1 -#define MNG_RENUMBER 2 - -#define MNG_CONCRETE_ASPARENT 0 /* CLON */ -#define MNG_CONCRETE_MAKEABSTRACT 1 - -#define MNG_LOCATION_ABSOLUTE 0 /* CLON, MOVE */ -#define MNG_LOCATION_RELATIVE 1 - -#define MNG_TARGET_ABSOLUTE 0 /* PAST */ -#define MNG_TARGET_RELATIVE_SAMEPAST 1 -#define MNG_TARGET_RELATIVE_PREVPAST 2 - -#define MNG_COMPOSITE_OVER 0 /* PAST */ -#define MNG_COMPOSITE_REPLACE 1 -#define MNG_COMPOSITE_UNDER 2 - -#define MNG_ORIENTATION_SAME 0 /* PAST */ -#define MNG_ORIENTATION_180DEG 2 -#define MNG_ORIENTATION_FLIPHORZ 4 -#define MNG_ORIENTATION_FLIPVERT 6 -#define MNG_ORIENTATION_TILED 8 - -#define MNG_OFFSET_ABSOLUTE 0 /* PAST */ -#define MNG_OFFSET_RELATIVE 1 - -#define MNG_BOUNDARY_ABSOLUTE 0 /* PAST, FRAM */ -#define MNG_BOUNDARY_RELATIVE 1 - -#define MNG_BACKGROUNDCOLOR_MANDATORY 0x01 /* BACK */ -#define MNG_BACKGROUNDIMAGE_MANDATORY 0x02 /* BACK */ - -#define MNG_BACKGROUNDIMAGE_NOTILE 0 /* BACK */ -#define MNG_BACKGROUNDIMAGE_TILE 1 - -#define MNG_FRAMINGMODE_NOCHANGE 0 /* FRAM */ -#define MNG_FRAMINGMODE_1 1 -#define MNG_FRAMINGMODE_2 2 -#define MNG_FRAMINGMODE_3 3 -#define MNG_FRAMINGMODE_4 4 - -#define MNG_CHANGEDELAY_NO 0 /* FRAM */ -#define MNG_CHANGEDELAY_NEXTSUBFRAME 1 -#define MNG_CHANGEDELAY_DEFAULT 2 - -#define MNG_CHANGETIMOUT_NO 0 /* FRAM */ -#define MNG_CHANGETIMOUT_DETERMINISTIC_1 1 -#define MNG_CHANGETIMOUT_DETERMINISTIC_2 2 -#define MNG_CHANGETIMOUT_DECODER_1 3 -#define MNG_CHANGETIMOUT_DECODER_2 4 -#define MNG_CHANGETIMOUT_USER_1 5 -#define MNG_CHANGETIMOUT_USER_2 6 -#define MNG_CHANGETIMOUT_EXTERNAL_1 7 -#define MNG_CHANGETIMOUT_EXTERNAL_2 8 - -#define MNG_CHANGECLIPPING_NO 0 /* FRAM */ -#define MNG_CHANGECLIPPING_NEXTSUBFRAME 1 -#define MNG_CHANGECLIPPING_DEFAULT 2 - -#define MNG_CHANGESYNCID_NO 0 /* FRAM */ -#define MNG_CHANGESYNCID_NEXTSUBFRAME 1 -#define MNG_CHANGESYNCID_DEFAULT 2 - -#define MNG_CLIPPING_ABSOLUTE 0 /* CLIP */ -#define MNG_CLIPPING_RELATIVE 1 - -#define MNG_SHOWMODE_0 0 /* SHOW */ -#define MNG_SHOWMODE_1 1 -#define MNG_SHOWMODE_2 2 -#define MNG_SHOWMODE_3 3 -#define MNG_SHOWMODE_4 4 -#define MNG_SHOWMODE_5 5 -#define MNG_SHOWMODE_6 6 -#define MNG_SHOWMODE_7 7 - -#define MNG_TERMACTION_LASTFRAME 0 /* TERM */ -#define MNG_TERMACTION_CLEAR 1 -#define MNG_TERMACTION_FIRSTFRAME 2 -#define MNG_TERMACTION_REPEAT 3 - -#define MNG_ITERACTION_LASTFRAME 0 /* TERM */ -#define MNG_ITERACTION_CLEAR 1 -#define MNG_ITERACTION_FIRSTFRAME 2 - -#define MNG_SAVEOFFSET_4BYTE 4 /* SAVE */ -#define MNG_SAVEOFFSET_8BYTE 8 - -#define MNG_SAVEENTRY_SEGMENTFULL 0 /* SAVE */ -#define MNG_SAVEENTRY_SEGMENT 1 -#define MNG_SAVEENTRY_SUBFRAME 2 -#define MNG_SAVEENTRY_EXPORTEDIMAGE 3 - -#define MNG_PRIORITY_ABSOLUTE 0 /* fPRI */ -#define MNG_PRIORITY_RELATIVE 1 - -#ifdef MNG_INCLUDE_JNG -#define MNG_COLORTYPE_JPEGGRAY 8 /* JHDR */ -#define MNG_COLORTYPE_JPEGCOLOR 10 -#define MNG_COLORTYPE_JPEGGRAYA 12 -#define MNG_COLORTYPE_JPEGCOLORA 14 - -#define MNG_BITDEPTH_JPEG8 8 /* JHDR */ -#define MNG_BITDEPTH_JPEG12 12 -#define MNG_BITDEPTH_JPEG8AND12 20 - -#define MNG_COMPRESSION_BASELINEJPEG 8 /* JHDR */ - -#define MNG_INTERLACE_SEQUENTIAL 0 /* JHDR */ -#define MNG_INTERLACE_PROGRESSIVE 8 -#endif /* MNG_INCLUDE_JNG */ - -#define MNG_IMAGETYPE_UNKNOWN 0 /* DHDR */ -#define MNG_IMAGETYPE_PNG 1 -#define MNG_IMAGETYPE_JNG 2 - -#define MNG_DELTATYPE_REPLACE 0 /* DHDR */ -#define MNG_DELTATYPE_BLOCKPIXELADD 1 -#define MNG_DELTATYPE_BLOCKALPHAADD 2 -#define MNG_DELTATYPE_BLOCKCOLORADD 3 -#define MNG_DELTATYPE_BLOCKPIXELREPLACE 4 -#define MNG_DELTATYPE_BLOCKALPHAREPLACE 5 -#define MNG_DELTATYPE_BLOCKCOLORREPLACE 6 -#define MNG_DELTATYPE_NOCHANGE 7 - -#define MNG_FILLMETHOD_LEFTBITREPLICATE 0 /* PROM */ -#define MNG_FILLMETHOD_ZEROFILL 1 - -#define MNG_DELTATYPE_REPLACERGB 0 /* PPLT */ -#define MNG_DELTATYPE_DELTARGB 1 -#define MNG_DELTATYPE_REPLACEALPHA 2 -#define MNG_DELTATYPE_DELTAALPHA 3 -#define MNG_DELTATYPE_REPLACERGBA 4 -#define MNG_DELTATYPE_DELTARGBA 5 - -#define MNG_POLARITY_ONLY 0 /* DBYK */ -#define MNG_POLARITY_ALLBUT 1 - -/* ************************************************************************** */ -/* * * */ -/* * Processtext callback types * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_TYPE_TEXT 0 -#define MNG_TYPE_ZTXT 1 -#define MNG_TYPE_ITXT 2 - -/* ************************************************************************** */ - -#ifdef __cplusplus -} -#endif - -#endif /* _libmng_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_callback_xs.c b/freeimage241/Source/LibMNG/libmng_callback_xs.c deleted file mode 100644 index 690b3a8..0000000 --- a/freeimage241/Source/LibMNG/libmng_callback_xs.c +++ /dev/null @@ -1,1147 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_callback_xs.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : callback get/set interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the callback get/set functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - fixed calling convention * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contribution by Tim Rowley) * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added getalphaline callback for RGB8_A8 canvasstyle * */ -/* * * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added processterm callback * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Callback set functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_retcode MNG_DECL mng_setcb_memalloc (mng_handle hHandle, - mng_memalloc fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMALLOC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fMemalloc = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMALLOC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_retcode MNG_DECL mng_setcb_memfree (mng_handle hHandle, - mng_memfree fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMFREE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fMemfree = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_MEMFREE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_retcode MNG_DECL mng_setcb_openstream (mng_handle hHandle, - mng_openstream fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_OPENSTREAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fOpenstream = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_OPENSTREAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_retcode MNG_DECL mng_setcb_closestream (mng_handle hHandle, - mng_closestream fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_CLOSESTREAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fClosestream = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_CLOSESTREAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_readdata (mng_handle hHandle, - mng_readdata fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_READDATA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fReaddata = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_READDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_setcb_writedata (mng_handle hHandle, - mng_writedata fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_WRITEDATA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fWritedata = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_WRITEDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_setcb_errorproc (mng_handle hHandle, - mng_errorproc fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_ERRORPROC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fErrorproc = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_ERRORPROC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_TRACE -mng_retcode MNG_DECL mng_setcb_traceproc (mng_handle hHandle, - mng_traceproc fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_TRACEPROC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fTraceproc = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_TRACEPROC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_TRACE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processheader (mng_handle hHandle, - mng_processheader fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSHEADER, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessheader = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSHEADER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processtext (mng_handle hHandle, - mng_processtext fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTEXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesstext = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processsave (mng_handle hHandle, - mng_processsave fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSAVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesssave = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processseek (mng_handle hHandle, - mng_processseek fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSEEK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessseek = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processneed (mng_handle hHandle, - mng_processneed fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSNEED, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessneed = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSNEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processmend (mng_handle hHandle, - mng_processmend fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSMEND, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessmend = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSMEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processunknown (mng_handle hHandle, - mng_processunknown fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSUNKNOWN, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessunknown = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSUNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_setcb_processterm (mng_handle hHandle, - mng_processterm fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTERM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessterm = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSTERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_getcanvasline (mng_handle hHandle, - mng_getcanvasline fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETCANVASLINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGetcanvasline = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETCANVASLINE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_getbkgdline (mng_handle hHandle, - mng_getbkgdline fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETBKGDLINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGetbkgdline = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETBKGDLINE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_getalphaline (mng_handle hHandle, - mng_getalphaline fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETALPHALINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGetalphaline = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETALPHALINE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_refresh (mng_handle hHandle, - mng_refresh fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_REFRESH, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fRefresh = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_REFRESH, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_gettickcount (mng_handle hHandle, - mng_gettickcount fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETTICKCOUNT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fGettickcount = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_GETTICKCOUNT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_setcb_settimer (mng_handle hHandle, - mng_settimer fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_SETTIMER, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fSettimer = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_SETTIMER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processgamma (mng_handle hHandle, - mng_processgamma fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSGAMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessgamma = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSGAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processchroma (mng_handle hHandle, - mng_processchroma fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSCHROMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesschroma = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSCHROMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processsrgb (mng_handle hHandle, - mng_processsrgb fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcesssrgb = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSSRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processiccp (mng_handle hHandle, - mng_processiccp fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSICCP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessiccp = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_retcode MNG_DECL mng_setcb_processarow (mng_handle hHandle, - mng_processarow fProc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSAROW, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->fProcessarow = fProc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SETCB_PROCESSAROW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ -/* * * */ -/* * Callback get functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_memalloc MNG_DECL mng_getcb_memalloc (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMALLOC, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMALLOC, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fMemalloc; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#ifndef MNG_INTERNAL_MEMMNGMT -mng_memfree MNG_DECL mng_getcb_memfree (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMFREE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_MEMFREE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fMemfree; -} -#endif /* MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_readdata MNG_DECL mng_getcb_readdata (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_READDATA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_READDATA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fReaddata; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_openstream MNG_DECL mng_getcb_openstream (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_OPENSTREAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_OPENSTREAM, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fOpenstream; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_closestream MNG_DECL mng_getcb_closestream (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_CLOSESTREAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_CLOSESTREAM, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fClosestream; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_writedata MNG_DECL mng_getcb_writedata (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_WRITEDATA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_WRITEDATA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fWritedata; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -mng_errorproc MNG_DECL mng_getcb_errorproc (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_ERRORPROC, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_ERRORPROC, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fErrorproc; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_TRACE -mng_traceproc MNG_DECL mng_getcb_traceproc (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_TRACEPROC, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_TRACEPROC, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fTraceproc; -} -#endif /* MNG_SUPPORT_TRACE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processheader MNG_DECL mng_getcb_processheader (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSHEADER, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSHEADER, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessheader; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processtext MNG_DECL mng_getcb_processtext (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTEXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTEXT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcesstext; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processsave MNG_DECL mng_getcb_processsave (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSAVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSAVE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcesssave; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processseek MNG_DECL mng_getcb_processseek (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSEEK, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSEEK, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessseek; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processneed MNG_DECL mng_getcb_processneed (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSNEED, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSNEED, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessneed; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processmend MNG_DECL mng_getcb_processmend (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSMEND, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSMEND, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessmend; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processunknown MNG_DECL mng_getcb_processunknown (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSUNKNOWN, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSUNKNOWN, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessunknown; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_processterm MNG_DECL mng_getcb_processterm (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTERM, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSTERM, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessterm; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_getcanvasline MNG_DECL mng_getcb_getcanvasline (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETCANVASLINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETCANVASLINE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fGetcanvasline; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_getbkgdline MNG_DECL mng_getcb_getbkgdline (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETBKGDLINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETBKGDLINE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fGetbkgdline; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_getalphaline MNG_DECL mng_getcb_getalphaline (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETALPHALINE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETALPHALINE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fGetalphaline; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_refresh MNG_DECL mng_getcb_refresh (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_REFRESH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_REFRESH, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fRefresh; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_gettickcount MNG_DECL mng_getcb_gettickcount (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETTICKCOUNT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_GETTICKCOUNT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fGettickcount; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_settimer MNG_DECL mng_getcb_settimer (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_SETTIMER, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_SETTIMER, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fSettimer; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processgamma MNG_DECL mng_getcb_processgamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSGAMMA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessgamma; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processchroma MNG_DECL mng_getcb_processchroma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSCHROMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSCHROMA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcesschroma; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processsrgb MNG_DECL mng_getcb_processsrgb (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSSRGB, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcesssrgb; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processiccp MNG_DECL mng_getcb_processiccp (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSICCP, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSICCP, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessiccp; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_APP_CMS) -mng_processarow MNG_DECL mng_getcb_processarow (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSAROW, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GETCB_PROCESSAROW, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->fProcessarow; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_APP_CMS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_chunk_io.c b/freeimage241/Source/LibMNG/libmng_chunk_io.c deleted file mode 100644 index 0f61a70..0000000 --- a/freeimage241/Source/LibMNG/libmng_chunk_io.c +++ /dev/null @@ -1,8817 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_io.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Chunk I/O routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of chunk input/output routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/01/2000 - G.Juyn * */ -/* * - cleaned up left-over teststuff in the BACK chunk routine * */ -/* * 0.5.1 - 05/04/2000 - G.Juyn * */ -/* * - changed CRC initialization to use dynamic structure * */ -/* * (wasn't thread-safe the old way !) * */ -/* * 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - filled in many missing sequence&length checks * */ -/* * - filled in many missing chunk-store snippets * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added checks for running animations * */ -/* * - filled some write routines * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/10/2000 - G.Juyn * */ -/* * - filled some more write routines * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - filled remaining write routines * */ -/* * - fixed read_pplt with regard to deltatype * */ -/* * - added callback error-reporting support * */ -/* * - added pre-draft48 support (short MHDR, frame_mode, LOOP) * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * - fixed chunk-storage bit in several routines * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * - supplemented the SAVE & SEEK display processing * */ -/* * * */ -/* * 0.5.2 - 05/18/2000 - G.Juyn * */ -/* * - B004 - fixed problem with MNG_SUPPORT_WRITE not defined * */ -/* * also for MNG_SUPPORT_WRITE without MNG_INCLUDE_JNG * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - cleaned up some code regarding mixed support * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - implemented JNG support * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for global color-chunks in animation * */ -/* * - added support for global PLTE,tRNS,bKGD in animation * */ -/* * - added support for SAVE & SEEK in animation * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - changed ani_create calls not returning object pointer * */ -/* * - create ani objects always (not just inside TERM/LOOP) * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added support for delta-image processing * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - changed SWAP_ENDIAN to BIGENDIAN_SUPPORTED * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * * */ -/* * 0.5.3 - 06/12/2000 - G.Juyn * */ -/* * - added processing of color-info on delta-image * */ -/* * 0.5.3 - 06/13/2000 - G.Juyn * */ -/* * - fixed handling of empty SAVE chunk * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed to support delta-images * */ -/* * - added extra checks for delta-images * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed possible trouble if IEND display-process got * */ -/* * broken up * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added processing of PLTE & tRNS for delta-images * */ -/* * - added administration of imagelevel parameter * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - implemented support for PPLT chunk * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - added precaution against faulty iCCP chunks from PS * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed some 64-bit warnings * */ -/* * * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed pre-draft48 frame_mode=3 to frame_mode=1 * */ -/* * 0.9.1 - 07/16/2000 - G.Juyn * */ -/* * - fixed storage of images during mng_read() * */ -/* * - fixed support for mng_display() after mng_read() * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed several chunk-writing routines * */ -/* * 0.9.1 - 07/24/2000 - G.Juyn * */ -/* * - fixed reading of still-images * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/08/2000 - G.Juyn * */ -/* * - fixed compiler-warnings from Mozilla * */ -/* * 0.9.3 - 08/09/2000 - G.Juyn * */ -/* * - added check for simplicity-bits in MHDR * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - fixed check for simplicity-bits in MHDR (JNG) * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 08/22/2000 - G.Juyn * */ -/* * - fixed write-code for zTXt & iTXt * */ -/* * - fixed read-code for iTXt * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/02/2000 - G.Juyn * */ -/* * - fixed simplicity-check in compliance with draft 81/0.98a * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - fixed support for MAGN * */ -/* * - implemented nEED "xxxx" (where "xxxx" is a chunkid) * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/23/2000 - G.Juyn * */ -/* * - fixed bug in empty PLTE handling * */ -/* * * */ -/* * 0.9.4 - 11/20/2000 - G.Juyn * */ -/* * - changed IHDR filter_method check for PNGs * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added errorchecking for MAGN methods * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * * */ -/* * 0.9.5 - 1/25/2001 - G.Juyn * */ -/* * - fixed some small compiler warnings (thanks Nikki) * */ -/* * * */ -/* * 1.0.2 - 05/05/2000 - G.Juyn * */ -/* * - B421427 - writes wrong format in bKGD and tRNS * */ -/* * 1.0.2 - 06/20/2000 - G.Juyn * */ -/* * - B434583 - compiler-warning if MNG_STORE_CHUNKS undefined * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_chunks.h" -#ifdef MNG_CHECK_BAD_ICCP -#include "libmng_chunk_prc.h" -#endif -#include "libmng_memory.h" -#include "libmng_display.h" -#include "libmng_zlib.h" -#include "libmng_pixels.h" -#include "libmng_chunk_io.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * CRC - Cyclic Redundancy Check * */ -/* * * */ -/* * The code below is taken directly from the sample provided with the * */ -/* * PNG specification. * */ -/* * (it is only adapted to the library's internal data-definitions) * */ -/* * * */ -/* ************************************************************************** */ - -/* Make the table for a fast CRC. */ -void make_crc_table (mng_datap pData) -{ - mng_uint32 iC; - mng_int32 iN, iK; - - for (iN = 0; iN < 256; iN++) - { - iC = (mng_uint32) iN; - - for (iK = 0; iK < 8; iK++) - { - if (iC & 1) - iC = 0xedb88320U ^ (iC >> 1); - else - iC = iC >> 1; - } - - pData->aCRCtable [iN] = iC; - } - - pData->bCRCcomputed = MNG_TRUE; -} - -/* Update a running CRC with the bytes buf[0..len-1]--the CRC - should be initialized to all 1's, and the transmitted value - is the 1's complement of the final running CRC (see the - crc() routine below). */ - -mng_uint32 update_crc (mng_datap pData, - mng_uint32 iCrc, - mng_uint8p pBuf, - mng_int32 iLen) -{ - mng_uint32 iC = iCrc; - mng_int32 iN; - - if (!pData->bCRCcomputed) - make_crc_table (pData); - - for (iN = 0; iN < iLen; iN++) - iC = pData->aCRCtable [(iC ^ pBuf [iN]) & 0xff] ^ (iC >> 8); - - return iC; -} - -/* Return the CRC of the bytes buf[0..len-1]. */ -mng_uint32 crc (mng_datap pData, - mng_uint8p pBuf, - mng_int32 iLen) -{ - return update_crc (pData, 0xffffffffU, pBuf, iLen) ^ 0xffffffffU; -} - -/* ************************************************************************** */ -/* * * */ -/* * Routines for swapping byte-order from and to graphic files * */ -/* * (This code is adapted from the libpng package) * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_BIGENDIAN_SUPPORTED - -/* ************************************************************************** */ - -mng_uint32 mng_get_uint32 (mng_uint8p pBuf) -{ - mng_uint32 i = ((mng_uint32)(*pBuf) << 24) + - ((mng_uint32)(*(pBuf + 1)) << 16) + - ((mng_uint32)(*(pBuf + 2)) << 8) + - (mng_uint32)(*(pBuf + 3)); - return (i); -} - -/* ************************************************************************** */ - -mng_int32 mng_get_int32 (mng_uint8p pBuf) -{ - mng_int32 i = ((mng_int32)(*pBuf) << 24) + - ((mng_int32)(*(pBuf + 1)) << 16) + - ((mng_int32)(*(pBuf + 2)) << 8) + - (mng_int32)(*(pBuf + 3)); - return (i); -} - -/* ************************************************************************** */ - -mng_uint16 mng_get_uint16 (mng_uint8p pBuf) -{ - mng_uint16 i = (mng_uint16)(((mng_uint16)(*pBuf) << 8) + - (mng_uint16)(*(pBuf + 1))); - return (i); -} - -/* ************************************************************************** */ - -void mng_put_uint32 (mng_uint8p pBuf, - mng_uint32 i) -{ - *pBuf = (mng_uint8)((i >> 24) & 0xff); - *(pBuf+1) = (mng_uint8)((i >> 16) & 0xff); - *(pBuf+2) = (mng_uint8)((i >> 8) & 0xff); - *(pBuf+3) = (mng_uint8)(i & 0xff); -} - -/* ************************************************************************** */ - -void mng_put_int32 (mng_uint8p pBuf, - mng_int32 i) -{ - *pBuf = (mng_uint8)((i >> 24) & 0xff); - *(pBuf+1) = (mng_uint8)((i >> 16) & 0xff); - *(pBuf+2) = (mng_uint8)((i >> 8) & 0xff); - *(pBuf+3) = (mng_uint8)(i & 0xff); -} - -/* ************************************************************************** */ - -void mng_put_uint16 (mng_uint8p pBuf, - mng_uint16 i) -{ - *pBuf = (mng_uint8)((i >> 8) & 0xff); - *(pBuf+1) = (mng_uint8)(i & 0xff); -} - -/* ************************************************************************** */ - -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - -/* ************************************************************************** */ -/* * * */ -/* * Helper routines to simplify chunk-data extraction * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -/* ************************************************************************** */ - -mng_uint8p find_null (mng_uint8p pIn) -{ - mng_uint8p pOut = pIn; - - while (*pOut) /* the read_graphic routine has made sure there's */ - pOut++; /* always at least 1 zero-byte in the buffer */ - - return pOut; -} - -/* ************************************************************************** */ - -mng_retcode inflate_buffer (mng_datap pData, - mng_uint8p pInbuf, - mng_uint32 iInsize, - mng_uint8p *pOutbuf, - mng_uint32 *iOutsize, - mng_uint32 *iRealsize) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INFLATE_BUFFER, MNG_LC_START) -#endif - - if (iInsize) /* anything to do ? */ - { - *iOutsize = iInsize * 3; /* estimate uncompressed size */ - /* and allocate a temporary buffer */ - MNG_ALLOC (pData, *pOutbuf, *iOutsize) - - do - { - mngzlib_inflateinit (pData); /* initialize zlib */ - /* let zlib know where to store the output */ - pData->sZlib.next_out = *pOutbuf; - /* "size - 1" so we've got space for the - zero-termination of a possible string */ - pData->sZlib.avail_out = *iOutsize - 1; - /* ok; let's inflate... */ - iRetcode = mngzlib_inflatedata (pData, iInsize, pInbuf); - /* determine actual output size */ - *iRealsize = (mng_uint32)pData->sZlib.total_out; - - mngzlib_inflatefree (pData); /* zlib's done */ - - if (iRetcode == MNG_BUFOVERFLOW) /* not enough space ? */ - { /* then get some more */ - MNG_FREEX (pData, *pOutbuf, *iOutsize) - *iOutsize = *iOutsize + iInsize; - MNG_ALLOC (pData, *pOutbuf, *iOutsize) - } - } /* repeat if we didn't have enough space */ - while ((iRetcode == MNG_BUFOVERFLOW) && - (*iOutsize < 20 * iInsize)); - - if (!iRetcode) /* if oke ? */ - *((*pOutbuf) + *iRealsize) = 0; /* then put terminator zero */ - - } - else - { - *pOutbuf = 0; /* nothing to do; then there's no output */ - *iOutsize = 0; - *iRealsize = 0; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INFLATE_BUFFER, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_READ_PROCS */ - -/* ************************************************************************** */ -/* * * */ -/* * Helper routines to simplify chunk writing * */ -/* * * */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_WRITE_PROCS -/* B004 */ -/* ************************************************************************** */ - -mng_retcode deflate_buffer (mng_datap pData, - mng_uint8p pInbuf, - mng_uint32 iInsize, - mng_uint8p *pOutbuf, - mng_uint32 *iOutsize, - mng_uint32 *iRealsize) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DEFLATE_BUFFER, MNG_LC_START) -#endif - - if (iInsize) /* anything to do ? */ - { - *iOutsize = (iInsize * 5) >> 2; /* estimate compressed size */ - /* and allocate a temporary buffer */ - MNG_ALLOC (pData, *pOutbuf, *iOutsize) - - do - { - mngzlib_deflateinit (pData); /* initialize zlib */ - /* let zlib know where to store the output */ - pData->sZlib.next_out = *pOutbuf; - pData->sZlib.avail_out = *iOutsize; - /* ok; let's deflate... */ - iRetcode = mngzlib_deflatedata (pData, iInsize, pInbuf); - /* determine actual output size */ - *iRealsize = pData->sZlib.total_out; - - mngzlib_deflatefree (pData); /* zlib's done */ - - if (iRetcode == MNG_BUFOVERFLOW) /* not enough space ? */ - { /* then get some more */ - MNG_FREEX (pData, *pOutbuf, *iOutsize) - *iOutsize = *iOutsize + (iInsize >> 1); - MNG_ALLOC (pData, *pOutbuf, *iOutsize) - } - } /* repeat if we didn't have enough space */ - while (iRetcode == MNG_BUFOVERFLOW); - } - else - { - *pOutbuf = 0; /* nothing to do; then there's no output */ - *iOutsize = 0; - *iRealsize = 0; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DEFLATE_BUFFER, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode write_raw_chunk (mng_datap pData, - mng_chunkid iChunkname, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_uint32 iCrc; - mng_uint32 iWritten; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_RAW_CHUNK, MNG_LC_START) -#endif - /* temporary buffer ? */ - if ((pRawdata != 0) && (pRawdata != pData->pWritebuf+8)) - { /* store length & chunktype in default buffer */ - mng_put_uint32 (pData->pWritebuf, iRawlen); - mng_put_uint32 (pData->pWritebuf+4, (mng_uint32)iChunkname); - /* calculate the crc */ - iCrc = update_crc (pData, 0xffffffffL, pData->pWritebuf+4, 4); - iCrc = update_crc (pData, iCrc, pRawdata, iRawlen) ^ 0xffffffffL; - /* store crc in default buffer */ - mng_put_uint32 (pData->pWritebuf+8, iCrc); - /* write the length & chunktype */ - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, 8, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR) - - if (iWritten != 8) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR) - /* write the temporary buffer */ - if (!pData->fWritedata ((mng_handle)pData, pRawdata, iRawlen, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR) - - if (iWritten != iRawlen) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR) - - /* write the crc */ - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf+8, 4, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR) - - if (iWritten != 4) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR) - - } - else - { /* prefix with length & chunktype */ - mng_put_uint32 (pData->pWritebuf, iRawlen); - mng_put_uint32 (pData->pWritebuf+4, (mng_uint32)iChunkname); - /* calculate the crc */ - iCrc = crc (pData, pData->pWritebuf+4, iRawlen + 4); - /* add it to the buffer */ - mng_put_uint32 (pData->pWritebuf + iRawlen + 8, iCrc); - /* write it in a single pass */ - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, iRawlen + 12, &iWritten)) - MNG_ERROR (pData, MNG_APPIOERROR) - - if (iWritten != iRawlen + 12) /* disk full ? */ - MNG_ERROR (pData, MNG_OUTPUTERROR) - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_RAW_CHUNK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#endif /* MNG_INCLUDE_WRITE_PROCS */ -/* B004 */ -/* ************************************************************************** */ -/* * * */ -/* * chunk read functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -/* ************************************************************************** */ - -READ_CHUNK (read_ihdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IHDR, MNG_LC_START) -#endif - - if (iRawlen != 13) /* length oke ? */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - /* only allowed inside PNG or MNG */ - if ((pData->eSigtype != mng_it_png) && (pData->eSigtype != mng_it_mng)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - /* sequence checks */ - if ((pData->eSigtype == mng_it_png) && (pData->iChunkseq > 1)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasIDAT) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasIDAT)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - pData->bHasIHDR = MNG_TRUE; /* indicate IHDR is present */ - /* and store interesting fields */ - if ((!pData->bHasDHDR) || (pData->iDeltatype == MNG_DELTATYPE_NOCHANGE)) - { - pData->iDatawidth = mng_get_uint32 (pRawdata); - pData->iDataheight = mng_get_uint32 (pRawdata+4); - } - - pData->iBitdepth = *(pRawdata+8); - pData->iColortype = *(pRawdata+9); - pData->iCompression = *(pRawdata+10); - pData->iFilter = *(pRawdata+11); - pData->iInterlace = *(pRawdata+12); - - if ((pData->iBitdepth != 1) && /* parameter validity checks */ - (pData->iBitdepth != 2) && - (pData->iBitdepth != 4) && - (pData->iBitdepth != 8) && - (pData->iBitdepth != 16) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if ((pData->iColortype != MNG_COLORTYPE_GRAY ) && - (pData->iColortype != MNG_COLORTYPE_RGB ) && - (pData->iColortype != MNG_COLORTYPE_INDEXED) && - (pData->iColortype != MNG_COLORTYPE_GRAYA ) && - (pData->iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8)) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (((pData->iColortype == MNG_COLORTYPE_RGB ) || - (pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) && - (pData->iBitdepth < 8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (pData->iCompression != MNG_COMPRESSION_DEFLATE) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if ((pData->eSigtype == mng_it_png) && (pData->iFilter)) - MNG_ERROR (pData, MNG_INVALIDFILTER) - else - if (pData->iFilter & (~MNG_FILTER_DIFFERING)) - MNG_ERROR (pData, MNG_INVALIDFILTER) - - if ((pData->iInterlace != MNG_INTERLACE_NONE ) && - (pData->iInterlace != MNG_INTERLACE_ADAM7) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE) - - if (pData->bHasDHDR) /* check the colortype for delta-images ! */ - { - mng_imagedatap pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - - if (pData->iColortype != pBuf->iColortype) - { - if ( ( (pData->iColortype != MNG_COLORTYPE_INDEXED) || - (pBuf->iColortype == MNG_COLORTYPE_GRAY ) ) && - ( (pData->iColortype != MNG_COLORTYPE_GRAY ) || - (pBuf->iColortype == MNG_COLORTYPE_INDEXED) ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - } - } - - if (!pData->bHasheader) /* first chunk ? */ - { - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_png; /* then this must be a PNG */ - pData->iWidth = pData->iDatawidth; - pData->iHeight = pData->iDataheight; - /* predict alpha-depth ! */ - if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) - pData->iAlphadepth = pData->iBitdepth; - else - if (pData->iColortype == MNG_COLORTYPE_INDEXED) - pData->iAlphadepth = 8; /* worst case scenario */ - else - pData->iAlphadepth = 0; - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE) - - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR) - } - - if (!pData->bHasDHDR) - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = process_display_ihdr (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the fields */ - ((mng_ihdrp)*ppChunk)->iWidth = mng_get_uint32 (pRawdata); - ((mng_ihdrp)*ppChunk)->iHeight = mng_get_uint32 (pRawdata+4); - ((mng_ihdrp)*ppChunk)->iBitdepth = pData->iBitdepth; - ((mng_ihdrp)*ppChunk)->iColortype = pData->iColortype; - ((mng_ihdrp)*ppChunk)->iCompression = pData->iCompression; - ((mng_ihdrp)*ppChunk)->iFilter = pData->iFilter; - ((mng_ihdrp)*ppChunk)->iInterlace = pData->iInterlace; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_plte) -{ -#if defined(MNG_SUPPORT_DISPLAY) || defined(MNG_STORE_CHUNKS) - mng_uint32 iX; - mng_uint8p pRawdata2; -#endif -#ifdef MNG_SUPPORT_DISPLAY - mng_uint32 iRawlen2; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PLTE, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJHDR)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* multiple PLTE only inside BASI */ - if ((pData->bHasPLTE) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_MULTIPLEERROR) - /* length must be multiple of 3 */ - if (((iRawlen % 3) != 0) || (iRawlen > 768)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* only allowed for indexed-color or - rgb(a)-color! */ - if ((pData->iColortype != 2) && (pData->iColortype != 3) && (pData->iColortype != 6)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - /* empty only allowed if global present */ - if ((iRawlen == 0) && (!pData->bHasglobalPLTE)) - MNG_ERROR (pData, MNG_CANNOTBEEMPTY) - } - else - { - if (iRawlen == 0) /* cannot be empty as global! */ - MNG_ERROR (pData, MNG_CANNOTBEEMPTY) - } - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - pData->bHasPLTE = MNG_TRUE; /* got it! */ - else - pData->bHasglobalPLTE = MNG_TRUE; - - pData->iPLTEcount = iRawlen / 3; - -#ifdef MNG_SUPPORT_DISPLAY - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - mng_imagep pImage; - mng_imagedatap pBuf; - - if (pData->bHasDHDR) /* processing delta-image ? */ - { /* store in object 0 !!! */ - pImage = (mng_imagep)pData->pObjzero; - pBuf = pImage->pImgbuf; - pBuf->bHasPLTE = MNG_TRUE; /* it's definitely got a PLTE now */ - pBuf->iPLTEcount = iRawlen / 3; /* this is the exact length */ - pRawdata2 = pRawdata; /* copy the entries */ - - for (iX = 0; iX < iRawlen / 3; iX++) - { - pBuf->aPLTEentries[iX].iRed = *pRawdata2; - pBuf->aPLTEentries[iX].iGreen = *(pRawdata2+1); - pBuf->aPLTEentries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - } - else - { /* get the current object */ - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address the object buffer */ - pBuf->bHasPLTE = MNG_TRUE; /* and tell it it's got a PLTE now */ - - if (!iRawlen) /* if empty, inherit from global */ - { - pBuf->iPLTEcount = pData->iGlobalPLTEcount; - MNG_COPY (pBuf->aPLTEentries, pData->aGlobalPLTEentries, - sizeof (pBuf->aPLTEentries)) - - if (pData->bHasglobalTRNS) /* also copy global tRNS ? */ - { /* indicate tRNS available */ - pBuf->bHasTRNS = MNG_TRUE; - - iRawlen2 = pData->iGlobalTRNSrawlen; - pRawdata2 = (mng_uint8p)(pData->aGlobalTRNSrawdata); - /* global length oke ? */ - if ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR) - /* copy it */ - pBuf->iTRNScount = iRawlen2; - MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2) - } - } - else - { /* store fields for future reference */ - pBuf->iPLTEcount = iRawlen / 3; - pRawdata2 = pRawdata; - - for (iX = 0; iX < pBuf->iPLTEcount; iX++) - { - pBuf->aPLTEentries[iX].iRed = *pRawdata2; - pBuf->aPLTEentries[iX].iGreen = *(pRawdata2+1); - pBuf->aPLTEentries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - } - } - } - else /* store as global */ - { - pData->iGlobalPLTEcount = iRawlen / 3; - pRawdata2 = pRawdata; - - for (iX = 0; iX < pData->iGlobalPLTEcount; iX++) - { - pData->aGlobalPLTEentries[iX].iRed = *pRawdata2; - pData->aGlobalPLTEentries[iX].iGreen = *(pRawdata2+1); - pData->aGlobalPLTEentries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_plte (pData, pData->iGlobalPLTEcount, - pData->aGlobalPLTEentries); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_pltep)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_pltep)*ppChunk)->iEntrycount = iRawlen / 3; - pRawdata2 = pRawdata; - - for (iX = 0; iX < ((mng_pltep)*ppChunk)->iEntrycount; iX++) - { - ((mng_pltep)*ppChunk)->aEntries[iX].iRed = *pRawdata2; - ((mng_pltep)*ppChunk)->aEntries[iX].iGreen = *(pRawdata2+1); - ((mng_pltep)*ppChunk)->aEntries[iX].iBlue = *(pRawdata2+2); - - pRawdata2 += 3; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_idat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IDAT, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_JNG /* sequence checks */ - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasJHDR) && - (pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (pData->bHasJSEP) - MNG_ERROR (pData, MNG_SEQUENCEERROR) -#endif - /* not allowed for for deltatype NO_CHANGE */ - if ((pData->bHasDHDR) && ((pData->iDeltatype == MNG_DELTATYPE_NOCHANGE))) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - /* can only be empty in BASI-block! */ - if ((iRawlen == 0) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - /* indexed-color requires PLTE */ - if ((pData->bHasIHDR) && (pData->iColortype == 3) && (!pData->bHasPLTE)) - MNG_ERROR (pData, MNG_PLTEMISSING) - - pData->bHasIDAT = MNG_TRUE; /* got some IDAT now, don't we */ - -#ifdef MNG_SUPPORT_DISPLAY - if (iRawlen) - { /* display processing */ - mng_retcode iRetcode = process_display_idat (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_idatp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_idatp)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen != 0) /* is there any data ? */ - { - MNG_ALLOC (pData, ((mng_idatp)*ppChunk)->pData, iRawlen) - MNG_COPY (((mng_idatp)*ppChunk)->pData, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_iend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IEND, MNG_LC_START) -#endif - - if (iRawlen > 0) /* must not contain data! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH); - -#ifdef MNG_INCLUDE_JNG /* sequence checks */ - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* IHDR-block requires IDAT */ - if ((pData->bHasIHDR) && (!pData->bHasIDAT)) - MNG_ERROR (pData, MNG_IDATMISSING) - - pData->iImagelevel--; /* one level up */ - -#ifdef MNG_SUPPORT_DISPLAY - { /* create an animation object */ - mng_retcode iRetcode = create_ani_image (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* display processing */ - iRetcode = process_display_iend (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_SUPPORT_DISPLAY - if (!pData->bTimerset) /* reset only if not broken !!! */ - { -#endif - /* IEND signals the end for most ... */ - pData->bHasIHDR = MNG_FALSE; - pData->bHasBASI = MNG_FALSE; - pData->bHasDHDR = MNG_FALSE; -#ifdef MNG_INCLUDE_JNG - pData->bHasJHDR = MNG_FALSE; - pData->bHasJSEP = MNG_FALSE; - pData->bHasJDAA = MNG_FALSE; - pData->bHasJDAT = MNG_FALSE; -#endif - pData->bHasPLTE = MNG_FALSE; - pData->bHasTRNS = MNG_FALSE; - pData->bHasGAMA = MNG_FALSE; - pData->bHasCHRM = MNG_FALSE; - pData->bHasSRGB = MNG_FALSE; - pData->bHasICCP = MNG_FALSE; - pData->bHasBKGD = MNG_FALSE; - pData->bHasIDAT = MNG_FALSE; -#ifdef MNG_SUPPORT_DISPLAY - } -#endif - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IEND, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_trns) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TRNS, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJHDR)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* multiple tRNS only inside BASI */ - if ((pData->bHasTRNS) && (!pData->bHasBASI)) - MNG_ERROR (pData, MNG_MULTIPLEERROR) - - if (iRawlen > 256) /* it just can't be bigger than that! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* not allowed with full alpha-channel */ - if ((pData->iColortype == 4) || (pData->iColortype == 6)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - - if (iRawlen != 0) /* filled ? */ - { /* length checks */ - if ((pData->iColortype == 0) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 2) && (iRawlen != 6)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - if (pData->iColortype == 3) - { - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; - - if (!pImage) /* no object then check obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - - if ((iRawlen == 0) || (iRawlen > pBuf->iPLTEcount)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } -#endif - } - else /* if empty there must be global stuff! */ - { - if (!pData->bHasglobalTRNS) - MNG_ERROR (pData, MNG_CANNOTBEEMPTY) - } - } - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - pData->bHasTRNS = MNG_TRUE; /* indicate tRNS available */ - else - pData->bHasglobalTRNS = MNG_TRUE; - -#ifdef MNG_SUPPORT_DISPLAY - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - mng_imagep pImage; - mng_imagedatap pBuf; - mng_uint8p pRawdata2; - mng_uint32 iRawlen2; - - if (pData->bHasDHDR) /* processing delta-image ? */ - { /* store in object 0 !!! */ - pImage = (mng_imagep)pData->pObjzero; - pBuf = pImage->pImgbuf; /* address object buffer */ - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0: { /* gray */ - pBuf->iTRNSgray = mng_get_uint16 (pRawdata); - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = 0; - break; - } - case 2: { /* rgb */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = mng_get_uint16 (pRawdata); - pBuf->iTRNSgreen = mng_get_uint16 (pRawdata+2); - pBuf->iTRNSblue = mng_get_uint16 (pRawdata+4); - pBuf->iTRNScount = 0; - break; - } - case 3: { /* indexed */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = iRawlen; - MNG_COPY (pBuf->aTRNSentries, pRawdata, iRawlen) - break; - } - } - - pBuf->bHasTRNS = MNG_TRUE; /* tell it it's got a tRNS now */ - } - else - { /* address current object */ - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasTRNS = MNG_TRUE; /* and tell it it's got a tRNS now */ - - if (iRawlen == 0) /* if empty, inherit from global */ - { - iRawlen2 = pData->iGlobalTRNSrawlen; - pRawdata2 = (mng_ptr)(pData->aGlobalTRNSrawdata); - /* global length oke ? */ - if ((pData->iColortype == 0) && (iRawlen2 != 2)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR) - - if ((pData->iColortype == 2) && (iRawlen2 != 6)) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR) - - if ((pData->iColortype == 3) && ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount))) - MNG_ERROR (pData, MNG_GLOBALLENGTHERR) - } - else - { - iRawlen2 = iRawlen; - pRawdata2 = pRawdata; - } - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0: { /* gray */ - pBuf->iTRNSgray = mng_get_uint16 (pRawdata2); - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = 0; - break; - } - case 2: { /* rgb */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = mng_get_uint16 (pRawdata2); - pBuf->iTRNSgreen = mng_get_uint16 (pRawdata2+2); - pBuf->iTRNSblue = mng_get_uint16 (pRawdata2+4); - pBuf->iTRNScount = 0; - break; - } - case 3: { /* indexed */ - pBuf->iTRNSgray = 0; - pBuf->iTRNSred = 0; - pBuf->iTRNSgreen = 0; - pBuf->iTRNSblue = 0; - pBuf->iTRNScount = iRawlen2; - MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2) - break; - } - } - } - } - else /* store as global */ - { - pData->iGlobalTRNSrawlen = iRawlen; - MNG_COPY (pData->aGlobalTRNSrawdata, pRawdata, iRawlen) - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_trns (pData, pData->iGlobalTRNSrawlen, - pData->aGlobalTRNSrawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { /* not global! */ - ((mng_trnsp)*ppChunk)->bGlobal = MNG_FALSE; - ((mng_trnsp)*ppChunk)->iType = pData->iColortype; - - if (iRawlen == 0) /* if empty, indicate so */ - ((mng_trnsp)*ppChunk)->bEmpty = MNG_TRUE; - else - { - ((mng_trnsp)*ppChunk)->bEmpty = MNG_FALSE; - - switch (pData->iColortype) /* store fields */ - { - case 0: { /* gray */ - ((mng_trnsp)*ppChunk)->iGray = mng_get_uint16 (pRawdata); - break; - } - case 2: { /* rgb */ - ((mng_trnsp)*ppChunk)->iRed = mng_get_uint16 (pRawdata); - ((mng_trnsp)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+2); - ((mng_trnsp)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+4); - break; - } - case 3: { /* indexed */ - ((mng_trnsp)*ppChunk)->iCount = iRawlen; - MNG_COPY (((mng_trnsp)*ppChunk)->aEntries, pRawdata, iRawlen) - break; - } - } - } - } - else /* it's global! */ - { - ((mng_trnsp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_trnsp)*ppChunk)->bGlobal = MNG_TRUE; - ((mng_trnsp)*ppChunk)->iType = 0; - ((mng_trnsp)*ppChunk)->iRawlen = iRawlen; - - MNG_COPY (((mng_trnsp)*ppChunk)->aRawdata, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_gama) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_GAMA, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be exactly 4 */ - if (iRawlen != 4) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { /* length must be empty or exactly 4 */ - if ((iRawlen != 0) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasGAMA = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalGAMA = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - - if (pData->bHasDHDR) /* update delta image ? */ - { /* store in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iGamma = mng_get_uint32 (pRawdata); - pImage->pImgbuf->bHasGAMA = MNG_TRUE; - } - else - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iGamma = mng_get_uint32 (pRawdata); - pImage->pImgbuf->bHasGAMA = MNG_TRUE; - } - } - else - { /* store as global */ - if (iRawlen != 0) - pData->iGlobalGamma = mng_get_uint32 (pRawdata); - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_gama (pData, (mng_bool)(iRawlen == 0), - pData->iGlobalGamma); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_gamap)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - ((mng_gamap)*ppChunk)->iGamma = mng_get_uint32 (pRawdata); - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_chrm) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHRM, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be exactly 32 */ - if (iRawlen != 32) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { /* length must be empty or exactly 32 */ - if ((iRawlen != 0) && (iRawlen != 32)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasCHRM = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalCHRM = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint32 iWhitepointx, iWhitepointy; - mng_uint32 iPrimaryredx, iPrimaryredy; - mng_uint32 iPrimarygreenx, iPrimarygreeny; - mng_uint32 iPrimarybluex, iPrimarybluey; - - iWhitepointx = mng_get_uint32 (pRawdata); - iWhitepointy = mng_get_uint32 (pRawdata+4); - iPrimaryredx = mng_get_uint32 (pRawdata+8); - iPrimaryredy = mng_get_uint32 (pRawdata+12); - iPrimarygreenx = mng_get_uint32 (pRawdata+16); - iPrimarygreeny = mng_get_uint32 (pRawdata+20); - iPrimarybluex = mng_get_uint32 (pRawdata+24); - iPrimarybluey = mng_get_uint32 (pRawdata+28); - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - mng_imagedatap pBuf; - - if (pData->bHasDHDR) /* update delta image ? */ - { /* store it in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasCHRM = MNG_TRUE; /* and tell it it's got a CHRM now */ - /* store for color-processing routines */ - pBuf->iWhitepointx = iWhitepointx; - pBuf->iWhitepointy = iWhitepointy; - pBuf->iPrimaryredx = iPrimaryredx; - pBuf->iPrimaryredy = iPrimaryredy; - pBuf->iPrimarygreenx = iPrimarygreenx; - pBuf->iPrimarygreeny = iPrimarygreeny; - pBuf->iPrimarybluex = iPrimarybluex; - pBuf->iPrimarybluey = iPrimarybluey; - } - else - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - pBuf->bHasCHRM = MNG_TRUE; /* and tell it it's got a CHRM now */ - /* store for color-processing routines */ - pBuf->iWhitepointx = iWhitepointx; - pBuf->iWhitepointy = iWhitepointy; - pBuf->iPrimaryredx = iPrimaryredx; - pBuf->iPrimaryredy = iPrimaryredy; - pBuf->iPrimarygreenx = iPrimarygreenx; - pBuf->iPrimarygreeny = iPrimarygreeny; - pBuf->iPrimarybluex = iPrimarybluex; - pBuf->iPrimarybluey = iPrimarybluey; - } - } - else - { /* store as global */ - if (iRawlen != 0) - { - pData->iGlobalWhitepointx = iWhitepointx; - pData->iGlobalWhitepointy = iWhitepointy; - pData->iGlobalPrimaryredx = iPrimaryredx; - pData->iGlobalPrimaryredy = iPrimaryredy; - pData->iGlobalPrimarygreenx = iPrimarygreenx; - pData->iGlobalPrimarygreeny = iPrimarygreeny; - pData->iGlobalPrimarybluex = iPrimarybluex; - pData->iGlobalPrimarybluey = iPrimarybluey; - } - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_chrm (pData, (mng_bool)(iRawlen == 0), - iWhitepointx, iWhitepointy, - iPrimaryredx, iPrimaryredy, - iPrimarygreenx, iPrimarygreeny, - iPrimarybluex, iPrimarybluey); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_chrmp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_chrmp)*ppChunk)->iWhitepointx = mng_get_uint32 (pRawdata); - ((mng_chrmp)*ppChunk)->iWhitepointy = mng_get_uint32 (pRawdata+4); - ((mng_chrmp)*ppChunk)->iRedx = mng_get_uint32 (pRawdata+8); - ((mng_chrmp)*ppChunk)->iRedy = mng_get_uint32 (pRawdata+12); - ((mng_chrmp)*ppChunk)->iGreenx = mng_get_uint32 (pRawdata+16); - ((mng_chrmp)*ppChunk)->iGreeny = mng_get_uint32 (pRawdata+20); - ((mng_chrmp)*ppChunk)->iBluex = mng_get_uint32 (pRawdata+24); - ((mng_chrmp)*ppChunk)->iBluey = mng_get_uint32 (pRawdata+28); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_srgb) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SRGB, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be exactly 1 */ - if (iRawlen != 1) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { /* length must be empty or exactly 1 */ - if ((iRawlen != 0) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasSRGB = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalSRGB = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - - if (pData->bHasDHDR) /* update delta image ? */ - { /* store in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iRenderingintent = *pRawdata; - pImage->pImgbuf->bHasSRGB = MNG_TRUE; - } - else - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - /* store for color-processing routines */ - pImage->pImgbuf->iRenderingintent = *pRawdata; - pImage->pImgbuf->bHasSRGB = MNG_TRUE; - } - } - else - { /* store as global */ - if (iRawlen != 0) - pData->iGlobalRendintent = *pRawdata; - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_srgb (pData, (mng_bool)(iRawlen == 0), - pData->iGlobalRendintent); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_srgbp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - ((mng_srgbp)*ppChunk)->iRenderingintent = *pRawdata; - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_iccp) -{ - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iCompressedsize; - mng_uint32 iProfilesize; - mng_uint32 iBufsize = 0; - mng_uint8p pBuf = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ICCP, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasPLTE) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasIDAT) || (pData->bHasPLTE)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { /* length must be at least 2 */ - if (iRawlen < 2) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { /* length must be empty or at least 2 */ - if ((iRawlen != 0) && (iRawlen < 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - - pTemp = find_null (pRawdata); /* find null-separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - /* determine size of compressed profile */ - iCompressedsize = (mng_uint32)(iRawlen - (pTemp - pRawdata) - 2); - /* decompress the profile */ - iRetcode = inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iProfilesize); - -#ifdef MNG_CHECK_BAD_ICCP /* Check for bad iCCP chunk */ - if ((iRetcode) && (!strncmp ((char *)pRawdata, "Photoshop ICC profile", 21))) - { - if (iRawlen == 2615) /* is it the sRGB profile ? */ - { - mng_chunk_header chunk_srgb = {MNG_UINT_sRGB, init_srgb, free_srgb, - read_srgb, write_srgb, 0, 0}; - /* pretend it's an sRGB chunk then ! */ - iRetcode = read_srgb (pData, &chunk_srgb, 1, (mng_ptr)"0", ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - } - } - else - { -#endif /* MNG_CHECK_BAD_ICCP */ - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasICCP = MNG_TRUE; /* indicate we've got it */ - else - pData->bHasglobalICCP = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - { - mng_imagep pImage; - - if (pData->bHasDHDR) /* update delta image ? */ - { /* store in object 0 ! */ - pImage = (mng_imagep)pData->pObjzero; - - if (pImage->pImgbuf->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize) - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pImage->pImgbuf->pProfile, iProfilesize) - MNG_COPY (pImage->pImgbuf->pProfile, pBuf, iProfilesize) - /* store it's length as well */ - pImage->pImgbuf->iProfilesize = iProfilesize; - pImage->pImgbuf->bHasICCP = MNG_TRUE; - } - else - { - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* no object then dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - if (pImage->pImgbuf->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize) - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pImage->pImgbuf->pProfile, iProfilesize) - MNG_COPY (pImage->pImgbuf->pProfile, pBuf, iProfilesize) - /* store it's length as well */ - pImage->pImgbuf->iProfilesize = iProfilesize; - pImage->pImgbuf->bHasICCP = MNG_TRUE; - } - } - else - { /* store as global */ - if (iRawlen == 0) /* empty chunk ? */ - { - if (pData->pGlobalProfile) /* did we have a global profile ? */ - MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) - - pData->iGlobalProfilesize = 0; /* reset to null */ - pData->pGlobalProfile = MNG_NULL; - } - else - { /* allocate a global buffer & copy it */ - MNG_ALLOC (pData, pData->pGlobalProfile, iProfilesize) - MNG_COPY (pData->pGlobalProfile, pBuf, iProfilesize) - /* store it's length as well */ - pData->iGlobalProfilesize = iProfilesize; - } - - /* create an animation object */ - iRetcode = create_ani_iccp (pData, (mng_bool)(iRawlen == 0), - pData->iGlobalProfilesize, - pData->pGlobalProfile); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - /* store the fields */ - ((mng_iccpp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) /* not empty ? */ - { - if (!pBuf) /* hasn't been unpuzzled it yet ? */ - { /* find null-separator */ - pTemp = find_null (pRawdata); - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - /* determine size of compressed profile */ - iCompressedsize = iRawlen - (pTemp - pRawdata) - 2; - /* decompress the profile */ - iRetcode = inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iProfilesize); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - } - - ((mng_iccpp)*ppChunk)->iNamesize = (mng_uint32)(pTemp - pRawdata); - - if (((mng_iccpp)*ppChunk)->iNamesize) - { - MNG_ALLOC (pData, ((mng_iccpp)*ppChunk)->zName, - ((mng_iccpp)*ppChunk)->iNamesize + 1) - MNG_COPY (((mng_iccpp)*ppChunk)->zName, pRawdata, - ((mng_iccpp)*ppChunk)->iNamesize) - } - - ((mng_iccpp)*ppChunk)->iCompression = *(pTemp+1); - ((mng_iccpp)*ppChunk)->iProfilesize = iProfilesize; - - MNG_ALLOC (pData, ((mng_iccpp)*ppChunk)->pProfile, iProfilesize) - MNG_COPY (((mng_iccpp)*ppChunk)->pProfile, pBuf, iProfilesize) - } - } -#endif /* MNG_STORE_CHUNKS */ - - if (pBuf) /* free the temporary buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - -#ifdef MNG_CHECK_BAD_ICCP - } -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_text) -{ - mng_uint32 iKeywordlen, iTextlen; - mng_pchar zKeyword, zText; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TEXT, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen < 2) /* length must be at least 2 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pTemp = find_null (pRawdata); /* find the null separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - - if (pTemp == pRawdata) /* there must be at least 1 char for keyword */ - MNG_ERROR (pData, MNG_KEYWORDNULL) - - iKeywordlen = (mng_uint32)(pTemp - pRawdata); - iTextlen = iRawlen - iKeywordlen - 1; - - if (pData->fProcesstext) /* inform the application ? */ - { - mng_bool bOke; - - MNG_ALLOC (pData, zKeyword, iKeywordlen + 1) - MNG_COPY (zKeyword, pRawdata, iKeywordlen) - - MNG_ALLOCX (pData, zText, iTextlen + 1) - - if (!zText) /* on error bail out */ - { - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - - if (iTextlen) - MNG_COPY (zText, pTemp+1, iTextlen) - - bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_TEXT, zKeyword, zText, 0, 0); - - MNG_FREEX (pData, zText, iTextlen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR) - - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_textp)*ppChunk)->iKeywordsize = iKeywordlen; - ((mng_textp)*ppChunk)->iTextsize = iTextlen; - - if (iKeywordlen) - { - MNG_ALLOC (pData, ((mng_textp)*ppChunk)->zKeyword, iKeywordlen+1) - MNG_COPY (((mng_textp)*ppChunk)->zKeyword, pRawdata, iKeywordlen) - } - - if (iTextlen) - { - MNG_ALLOC (pData, ((mng_textp)*ppChunk)->zText, iTextlen+1) - MNG_COPY (((mng_textp)*ppChunk)->zText, pTemp+1, iTextlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_ztxt) -{ - mng_retcode iRetcode; - mng_uint32 iKeywordlen, iTextlen; - mng_pchar zKeyword; - mng_uint8p pTemp; - mng_uint32 iCompressedsize; - mng_uint32 iBufsize; - mng_uint8p pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ZTXT, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen < 3) /* length must be at least 3 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pTemp = find_null (pRawdata); /* find the null separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - - if (pTemp == pRawdata) /* there must be at least 1 char for keyword */ - MNG_ERROR (pData, MNG_KEYWORDNULL) - - if (*(pTemp+1) != 0) /* only deflate compression-method allowed */ - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - iKeywordlen = (mng_uint32)(pTemp - pRawdata); - iCompressedsize = (mng_uint32)(iRawlen - iKeywordlen - 2); - - zKeyword = 0; /* there's no keyword buffer yet */ - pBuf = 0; /* or a temporary buffer ! */ - - if (pData->fProcesstext) /* inform the application ? */ - { /* decompress the text */ - iRetcode = inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - - MNG_ALLOCX (pData, zKeyword, iKeywordlen+1) - - if (!zKeyword) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (zKeyword, pRawdata, iKeywordlen) - - if (!pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ZTXT, zKeyword, (mng_pchar)pBuf, 0, 0)) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - MNG_ERROR (pData, MNG_APPMISCERROR) - } - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - return iRetcode; - } - /* store the fields */ - ((mng_ztxtp)*ppChunk)->iKeywordsize = iKeywordlen; - ((mng_ztxtp)*ppChunk)->iCompression = *(pTemp+1); - - if ((!pBuf) && (iCompressedsize)) /* did we not get a text-buffer yet ? */ - { /* decompress the text */ - iRetcode = inflate_buffer (pData, pTemp+2, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - return iRetcode; - } - } - - MNG_ALLOCX (pData, ((mng_ztxtp)*ppChunk)->zKeyword, iKeywordlen + 1) - /* on error bail out */ - if (!((mng_ztxtp)*ppChunk)->zKeyword) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (((mng_ztxtp)*ppChunk)->zKeyword, pRawdata, iKeywordlen) - - ((mng_ztxtp)*ppChunk)->iTextsize = iTextlen; - - if (iCompressedsize) - { - MNG_ALLOCX (pData, ((mng_ztxtp)*ppChunk)->zText, iTextlen + 1) - /* on error bail out */ - if (!((mng_ztxtp)*ppChunk)->zText) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, pBuf, iBufsize) - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - MNG_ERROR (pData, MNG_OUTOFMEMORY); - } - - MNG_COPY (((mng_ztxtp)*ppChunk)->zText, pBuf, iTextlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - - MNG_FREEX (pData, pBuf, iBufsize) /* free the temporary buffers */ - MNG_FREEX (pData, zKeyword, iKeywordlen+1) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ZTXT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_itxt) -{ - mng_retcode iRetcode; - mng_uint32 iKeywordlen, iTextlen, iLanguagelen, iTranslationlen; - mng_pchar zKeyword, zLanguage, zTranslation; - mng_uint8p pNull1, pNull2, pNull3; - mng_uint32 iCompressedsize; - mng_uint8 iCompressionflag; - mng_uint32 iBufsize; - mng_uint8p pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ITXT, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen < 6) /* length must be at least 6 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pNull1 = find_null (pRawdata); /* find the null separators */ - pNull2 = find_null (pNull1+3); - pNull3 = find_null (pNull2+1); - /* not found inside input-data ? */ - if (((pNull1 - pRawdata) > (mng_int32)iRawlen) || - ((pNull2 - pRawdata) > (mng_int32)iRawlen) || - ((pNull3 - pRawdata) > (mng_int32)iRawlen) ) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - - if (pNull1 == pRawdata) /* there must be at least 1 char for keyword */ - MNG_ERROR (pData, MNG_KEYWORDNULL) - /* compression or not ? */ - if ((*(pNull1+1) != 0) && (*(pNull1+1) != 1)) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if (*(pNull1+2) != 0) /* only deflate compression-method allowed */ - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - iKeywordlen = (mng_uint32)(pNull1 - pRawdata); - iLanguagelen = (mng_uint32)(pNull2 - pNull1 - 3); - iTranslationlen = (mng_uint32)(pNull3 - pNull2 - 1); - iCompressedsize = (mng_uint32)(iRawlen - iKeywordlen - iLanguagelen - iTranslationlen - 5); - iCompressionflag = *(pNull1+1); - - zKeyword = 0; /* no buffers acquired yet */ - zLanguage = 0; - zTranslation = 0; - pBuf = 0; - iTextlen = 0; - - if (pData->fProcesstext) /* inform the application ? */ - { - if (iCompressionflag) /* decompress the text ? */ - { - iRetcode = inflate_buffer (pData, pNull3+1, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffer */ - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - } - else - { - iTextlen = iCompressedsize; - iBufsize = iTextlen+1; /* plus 1 for terminator byte!!! */ - - MNG_ALLOCX (pData, pBuf, iBufsize); - MNG_COPY (pBuf, pNull3+1, iTextlen); - } - - MNG_ALLOCX (pData, zKeyword, iKeywordlen + 1) - MNG_ALLOCX (pData, zLanguage, iLanguagelen + 1) - MNG_ALLOCX (pData, zTranslation, iTranslationlen + 1) - /* on error bail out */ - if ((!zKeyword) || (!zLanguage) || (!zTranslation)) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - - MNG_COPY (zKeyword, pRawdata, iKeywordlen) - MNG_COPY (zLanguage, pNull1+3, iLanguagelen) - MNG_COPY (zTranslation, pNull2+1, iTranslationlen) - - if (!pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ITXT, zKeyword, (mng_pchar)pBuf, - zLanguage, zTranslation)) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - - MNG_ERROR (pData, MNG_APPMISCERROR) - } - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - /* store the fields */ - ((mng_itxtp)*ppChunk)->iKeywordsize = iKeywordlen; - ((mng_itxtp)*ppChunk)->iLanguagesize = iLanguagelen; - ((mng_itxtp)*ppChunk)->iTranslationsize = iTranslationlen; - ((mng_itxtp)*ppChunk)->iCompressionflag = *(pNull1+1); - ((mng_itxtp)*ppChunk)->iCompressionmethod = *(pNull1+2); - - if ((!pBuf) && (iCompressedsize)) /* did we not get a text-buffer yet ? */ - { - if (iCompressionflag) /* decompress the text ? */ - { - iRetcode = inflate_buffer (pData, pNull3+1, iCompressedsize, - &pBuf, &iBufsize, &iTextlen); - - if (iRetcode) /* on error bail out */ - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - return iRetcode; - } - } - else - { - iTextlen = iCompressedsize; - iBufsize = iTextlen+1; /* plus 1 for terminator byte!!! */ - - MNG_ALLOCX (pData, pBuf, iBufsize); - MNG_COPY (pBuf, pNull3+1, iTextlen); - } - } - - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zKeyword, iKeywordlen + 1) - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zLanguage, iLanguagelen + 1) - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zTranslation, iTranslationlen + 1) - /* on error bail out */ - if ((!((mng_itxtp)*ppChunk)->zKeyword ) || - (!((mng_itxtp)*ppChunk)->zLanguage ) || - (!((mng_itxtp)*ppChunk)->zTranslation) ) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - - MNG_COPY (((mng_itxtp)*ppChunk)->zKeyword, pRawdata, iKeywordlen) - MNG_COPY (((mng_itxtp)*ppChunk)->zLanguage, pNull1+3, iLanguagelen) - MNG_COPY (((mng_itxtp)*ppChunk)->zTranslation, pNull2+1, iTranslationlen) - - ((mng_itxtp)*ppChunk)->iTextsize = iTextlen; - - if (iTextlen) - { - MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zText, iTextlen + 1) - - if (!((mng_itxtp)*ppChunk)->zText) - { /* don't forget to drop the temp buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - - MNG_COPY (((mng_itxtp)*ppChunk)->zText, pBuf, iTextlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - /* free the temporary buffers */ - MNG_FREEX (pData, zTranslation, iTranslationlen + 1) - MNG_FREEX (pData, zLanguage, iLanguagelen + 1) - MNG_FREEX (pData, zKeyword, iKeywordlen + 1) - MNG_FREEX (pData, pBuf, iBufsize) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_bkgd) -{ -#ifdef MNG_SUPPORT_DISPLAY - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BKGD, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen > 6) /* it just can't be bigger than that! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_INCLUDE_JNG /* length checks */ - if (pData->bHasJHDR) - { - if (((pData->iJHDRcolortype == 8) || (pData->iJHDRcolortype == 12)) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if (((pData->iJHDRcolortype == 10) || (pData->iJHDRcolortype == 14)) && (iRawlen != 6)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - if (((pData->iColortype == 0) || (pData->iColortype == 4)) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if (((pData->iColortype == 2) || (pData->iColortype == 6)) && (iRawlen != 6)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 3) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { - if (iRawlen != 6) /* global is always 16-bit RGB ! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - pData->bHasBKGD = MNG_TRUE; /* indicate bKGD available */ - else - pData->bHasglobalBKGD = (mng_bool)(iRawlen != 0); - -#ifdef MNG_SUPPORT_DISPLAY - if (!pImage) /* if no object dump it in obj 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address object buffer */ - -#ifdef MNG_INCLUDE_JNG - if (pData->bHasJHDR) - { - pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */ - - switch (pData->iJHDRcolortype) /* store fields for future reference */ - { - case 8 : ; /* gray */ - case 12 : { /* graya */ - pBuf->iBKGDgray = mng_get_uint16 (pRawdata); - break; - } - case 10 : ; /* rgb */ - case 14 : { /* rgba */ - pBuf->iBKGDred = mng_get_uint16 (pRawdata); - pBuf->iBKGDgreen = mng_get_uint16 (pRawdata+2); - pBuf->iBKGDblue = mng_get_uint16 (pRawdata+4); - break; - } - } - } - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */ - - switch (pData->iColortype) /* store fields for future reference */ - { - case 0 : ; /* gray */ - case 4 : { /* graya */ - pBuf->iBKGDgray = mng_get_uint16 (pRawdata); - break; - } - case 2 : ; /* rgb */ - case 6 : { /* rgba */ - pBuf->iBKGDred = mng_get_uint16 (pRawdata); - pBuf->iBKGDgreen = mng_get_uint16 (pRawdata+2); - pBuf->iBKGDblue = mng_get_uint16 (pRawdata+4); - break; - } - case 3 : { /* indexed */ - pBuf->iBKGDindex = *pRawdata; - break; - } - } - } - else /* store as global */ - { - if (iRawlen) - { - pData->iGlobalBKGDred = mng_get_uint16 (pRawdata); - pData->iGlobalBKGDgreen = mng_get_uint16 (pRawdata+2); - pData->iGlobalBKGDblue = mng_get_uint16 (pRawdata+4); - } - - { /* create an animation object */ - mng_retcode iRetcode = create_ani_bkgd (pData, pData->iGlobalBKGDred, - pData->iGlobalBKGDgreen, - pData->iGlobalBKGDblue); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_bkgdp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_bkgdp)*ppChunk)->iType = pData->iColortype; - - if (iRawlen) - { - switch (iRawlen) /* guess from length */ - { - case 1 : { /* indexed */ - ((mng_bkgdp)*ppChunk)->iType = 3; - ((mng_bkgdp)*ppChunk)->iIndex = *pRawdata; - break; - } - case 2 : { /* gray */ - ((mng_bkgdp)*ppChunk)->iType = 0; - ((mng_bkgdp)*ppChunk)->iGray = mng_get_uint16 (pRawdata); - break; - } - case 6 : { /* rgb */ - ((mng_bkgdp)*ppChunk)->iType = 2; - ((mng_bkgdp)*ppChunk)->iRed = mng_get_uint16 (pRawdata); - ((mng_bkgdp)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+2); - ((mng_bkgdp)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+4); - break; - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_phys) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYS, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIDAT) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if (pData->bHasIDAT) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* it's 9 bytes or empty; no more, no less! */ - if ((iRawlen != 9) && (iRawlen != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_physp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_physp)*ppChunk)->iSizex = mng_get_uint32 (pRawdata); - ((mng_physp)*ppChunk)->iSizey = mng_get_uint32 (pRawdata+4); - ((mng_physp)*ppChunk)->iUnit = *(pRawdata+8); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYS, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_sbit) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SBIT, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasPLTE) || (pData->bHasIDAT) || (pData->bHasJDAT) || (pData->bHasJDAA)) -#else - if ((pData->bHasPLTE) || (pData->bHasIDAT)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen > 4) /* it just can't be bigger than that! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_INCLUDE_JNG /* length checks */ - if (pData->bHasJHDR) - { - if ((pData->iJHDRcolortype == 8) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iJHDRcolortype == 10) && (iRawlen != 3)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iJHDRcolortype == 12) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iJHDRcolortype == 14) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else -#endif /* MNG_INCLUDE_JNG */ - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) - { - if ((pData->iColortype == 0) && (iRawlen != 1)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 2) && (iRawlen != 3)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 3) && (iRawlen != 3)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 4) && (iRawlen != 2)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((pData->iColortype == 6) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { /* global = empty or RGBA */ - if ((iRawlen != 0) && (iRawlen != 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_sbitp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { -#ifdef MNG_INCLUDE_JNG - if (pData->bHasJHDR) - ((mng_sbitp)*ppChunk)->iType = pData->iJHDRcolortype; - else -#endif - if (pData->bHasIHDR) - ((mng_sbitp)*ppChunk)->iType = pData->iColortype; - else /* global ! */ - ((mng_sbitp)*ppChunk)->iType = 6; - - if (iRawlen > 0) - ((mng_sbitp)*ppChunk)->aBits [0] = *pRawdata; - if (iRawlen > 1) - ((mng_sbitp)*ppChunk)->aBits [1] = *(pRawdata+1); - if (iRawlen > 2) - ((mng_sbitp)*ppChunk)->aBits [2] = *(pRawdata+2); - if (iRawlen > 3) - ((mng_sbitp)*ppChunk)->aBits [3] = *(pRawdata+3); - - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SBIT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_splt) -{ - mng_uint8p pTemp; - mng_uint32 iNamelen; - mng_uint8 iSampledepth; - mng_uint32 iRemain; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SPLT, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (pData->bHasIDAT) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen) - { - pTemp = find_null (pRawdata); /* find null-separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - - iNamelen = (mng_uint32)(pTemp - pRawdata); - iSampledepth = *(pTemp+1); - iRemain = (iRawlen - 2 - iNamelen); - - if ((iSampledepth != 1) && (iSampledepth != 2)) - MNG_ERROR (pData, MNG_INVSAMPLEDEPTH) - /* check remaining length */ - if ( ((iSampledepth == 1) && (iRemain % 6 != 0)) || - ((iSampledepth == 2) && (iRemain % 10 != 0)) ) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - } - else - { - pTemp = MNG_NULL; - iNamelen = 0; - iSampledepth = 0; - iRemain = 0; - } - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_spltp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_spltp)*ppChunk)->iNamesize = iNamelen; - ((mng_spltp)*ppChunk)->iSampledepth = iSampledepth; - - if (iSampledepth == 1) - ((mng_spltp)*ppChunk)->iEntrycount = iRemain / 6; - else - ((mng_spltp)*ppChunk)->iEntrycount = iRemain / 10; - - if (iNamelen) - { - MNG_ALLOC (pData, ((mng_spltp)*ppChunk)->zName, iNamelen+1) - MNG_COPY (((mng_spltp)*ppChunk)->zName, pRawdata, iNamelen) - } - - if (iRemain) - { - MNG_ALLOC (pData, ((mng_spltp)*ppChunk)->pEntries, iRemain) - MNG_COPY (((mng_spltp)*ppChunk)->pEntries, pTemp+2, iRemain) - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_hist) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_HIST, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasIHDR) && (!pData->bHasBASI) && (!pData->bHasDHDR) ) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if ((!pData->bHasPLTE) || (pData->bHasIDAT)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* length oke ? */ - if ( ((iRawlen & 0x01) != 0) || ((iRawlen >> 1) != pData->iPLTEcount) ) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { - mng_uint32 iX; - /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_histp)*ppChunk)->iEntrycount = iRawlen >> 1; - - for (iX = 0; iX < (iRawlen >> 1); iX++) - { - ((mng_histp)*ppChunk)->aEntries [iX] = mng_get_uint16 (pRawdata); - pRawdata += 2; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_HIST, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_time) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TIME, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen != 7) /* length must be exactly 7 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -/* if (pData->fProcesstime) */ /* inform the application ? */ -/* { - - pData->fProcesstime ((mng_handle)pData, ); - } */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_timep)*ppChunk)->iYear = mng_get_uint16 (pRawdata); - ((mng_timep)*ppChunk)->iMonth = *(pRawdata+2); - ((mng_timep)*ppChunk)->iDay = *(pRawdata+3); - ((mng_timep)*ppChunk)->iHour = *(pRawdata+4); - ((mng_timep)*ppChunk)->iMinute = *(pRawdata+5); - ((mng_timep)*ppChunk)->iSecond = *(pRawdata+6); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TIME, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_mhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MHDR, MNG_LC_START) -#endif - - if (pData->eSigtype != mng_it_mng) /* sequence checks */ - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - - if (pData->bHasheader) /* can only be the first chunk! */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* correct length ? */ - if ((iRawlen != 28) && (iRawlen != 12)) - MNG_ERROR (pData, MNG_INVALIDLENGTH); - - pData->bHasMHDR = MNG_TRUE; /* oh boy, a real MNG */ - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_mng; /* fill header fields */ - pData->iWidth = mng_get_uint32 (pRawdata); - pData->iHeight = mng_get_uint32 (pRawdata+4); - pData->iTicks = mng_get_uint32 (pRawdata+8); - - if (iRawlen == 28) /* proper MHDR ? */ - { - pData->iLayercount = mng_get_uint32 (pRawdata+12); - pData->iFramecount = mng_get_uint32 (pRawdata+16); - pData->iPlaytime = mng_get_uint32 (pRawdata+20); - pData->iSimplicity = mng_get_uint32 (pRawdata+24); - - pData->bPreDraft48 = MNG_FALSE; - } - else /* probably pre-draft48 then */ - { - pData->iLayercount = 0; - pData->iFramecount = 0; - pData->iPlaytime = 0; - pData->iSimplicity = 0; - - pData->bPreDraft48 = MNG_TRUE; - } - /* predict alpha-depth */ - if ((pData->iSimplicity & 0x00000001) == 0) - pData->iAlphadepth = 16; /* no indicators = assume the worst */ - else - if ((pData->iSimplicity & 0x00000008) == 0) - pData->iAlphadepth = 0; /* no transparency at all */ - else - if ((pData->iSimplicity & 0x00000140) == 0x00000040) - pData->iAlphadepth = 1; /* no semi-transparency guaranteed */ - else - pData->iAlphadepth = 16; /* anything else = assume the worst */ - -#ifdef MNG_INCLUDE_JNG /* can we handle the complexity ? */ - if (pData->iSimplicity & 0x0000FC00) -#else - if (pData->iSimplicity & 0x0000FC10) -#endif - MNG_ERROR (pData, MNG_MNGTOOCOMPLEX) - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE) - - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR) - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_mhdrp)*ppChunk)->iWidth = pData->iWidth; - ((mng_mhdrp)*ppChunk)->iHeight = pData->iHeight; - ((mng_mhdrp)*ppChunk)->iTicks = pData->iTicks; - ((mng_mhdrp)*ppChunk)->iLayercount = pData->iLayercount; - ((mng_mhdrp)*ppChunk)->iFramecount = pData->iFramecount; - ((mng_mhdrp)*ppChunk)->iPlaytime = pData->iPlaytime; - ((mng_mhdrp)*ppChunk)->iSimplicity = pData->iSimplicity; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_mend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MEND, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen > 0) /* must not contain data! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { /* do something */ - mng_retcode iRetcode = process_display_mend (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - - pData->bHasMHDR = MNG_FALSE; /* end of the line, bro! */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MEND, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_loop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_LOOP, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_LOOPWITHCACHEOFF) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen >= 5) /* length checks */ - { - if (iRawlen >= 6) - { - if ((iRawlen - 6) % 4 != 0) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - } - else - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint8 iLevel; - mng_uint32 iRepeat; - mng_uint8 iTermination = 0; - mng_uint32 iItermin = 1; - mng_uint32 iItermax = 0x7fffffffL; - mng_retcode iRetcode; - - pData->bHasLOOP = MNG_TRUE; /* indicate we're inside a loop */ - - iLevel = *pRawdata; /* determine the fields for processing */ - - if (pData->bPreDraft48) - { - iTermination = *(pRawdata+1); - - iRepeat = mng_get_uint32 (pRawdata+2); - } - else - iRepeat = mng_get_uint32 (pRawdata+1); - - if (iRawlen >= 6) - { - if (!pData->bPreDraft48) - iTermination = *(pRawdata+5); - - if (iRawlen >= 10) - { - iItermin = mng_get_uint32 (pRawdata+6); - - if (iRawlen >= 14) - { - iItermax = mng_get_uint32 (pRawdata+10); - - /* TODO: process signals */ - - } - } - } - - /* create the LOOP ani-object */ - iRetcode = create_ani_loop (pData, iLevel, iRepeat, iTermination, - iItermin, iItermax, 0, 0); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (iRawlen >= 5) /* store the fields */ - { - ((mng_loopp)*ppChunk)->iLevel = *pRawdata; - - if (pData->bPreDraft48) - { - ((mng_loopp)*ppChunk)->iTermination = *(pRawdata+1); - ((mng_loopp)*ppChunk)->iRepeat = mng_get_uint32 (pRawdata+2); - } - else - { - ((mng_loopp)*ppChunk)->iRepeat = mng_get_uint32 (pRawdata+1); - } - - if (iRawlen >= 6) - { - if (!pData->bPreDraft48) - ((mng_loopp)*ppChunk)->iTermination = *(pRawdata+5); - - if (iRawlen >= 10) - { - ((mng_loopp)*ppChunk)->iItermin = mng_get_uint32 (pRawdata+6); - - if (iRawlen >= 14) - { - ((mng_loopp)*ppChunk)->iItermax = mng_get_uint32 (pRawdata+10); - ((mng_loopp)*ppChunk)->iCount = (iRawlen - 14) / 4; - - if (((mng_loopp)*ppChunk)->iCount) - { - MNG_ALLOC (pData, ((mng_loopp)*ppChunk)->pSignals, - ((mng_loopp)*ppChunk)->iCount << 2) - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint8p pIn = pRawdata + 14; - mng_uint32p pOut = (mng_uint32p)((mng_loopp)*ppChunk)->pSignals; - - for (iX = 0; iX < ((mng_loopp)*ppChunk)->iCount; iX++) - { - *pOut++ = mng_get_uint32 (pIn); - pIn += 4; - } - } -#else - MNG_COPY (((mng_loopp)*ppChunk)->pSignals, pRawdata + 14, - ((mng_loopp)*ppChunk)->iCount << 2) -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } - } - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_endl) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ENDL, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen != 1) /* length must be exactly 1 */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - if (pData->bHasLOOP) /* are we really processing a loop ? */ - { - mng_uint8 iLevel = *pRawdata; /* get the nest level */ - /* create an ENDL animation object */ - mng_retcode iRetcode = create_ani_endl (pData, iLevel); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - { /* process it */ - mng_ani_endlp pENDL = (mng_ani_endlp)pData->pLastaniobj; - - iRetcode = pENDL->sHeader.fProcess (pData, pENDL); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - else - { - - /* TODO: error abort ??? */ - - } - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_endlp)*ppChunk)->iLevel = *pRawdata; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_defi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DEFI, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* check the length */ - if ((iRawlen != 2) && (iRawlen != 3) && (iRawlen != 4) && - (iRawlen != 12) && (iRawlen != 28)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - pData->iDEFIobjectid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - { - pData->bDEFIhasdonotshow = MNG_TRUE; - pData->iDEFIdonotshow = *(pRawdata+2); - } - else - { - pData->bDEFIhasdonotshow = MNG_FALSE; - pData->iDEFIdonotshow = 0; - } - - if (iRawlen > 3) - { - pData->bDEFIhasconcrete = MNG_TRUE; - pData->iDEFIconcrete = *(pRawdata+3); - } - else - { - pData->bDEFIhasconcrete = MNG_FALSE; - pData->iDEFIconcrete = 0; - } - - if (iRawlen > 4) - { - pData->bDEFIhasloca = MNG_TRUE; - pData->iDEFIlocax = mng_get_int32 (pRawdata+4); - pData->iDEFIlocay = mng_get_int32 (pRawdata+8); - } - else - { - pData->bDEFIhasloca = MNG_FALSE; - pData->iDEFIlocax = 0; - pData->iDEFIlocay = 0; - } - - if (iRawlen > 12) - { - pData->bDEFIhasclip = MNG_TRUE; - pData->iDEFIclipl = mng_get_int32 (pRawdata+12); - pData->iDEFIclipr = mng_get_int32 (pRawdata+16); - pData->iDEFIclipt = mng_get_int32 (pRawdata+20); - pData->iDEFIclipb = mng_get_int32 (pRawdata+24); - } - else - { - pData->bDEFIhasclip = MNG_FALSE; - pData->iDEFIclipl = 0; - pData->iDEFIclipr = 0; - pData->iDEFIclipt = 0; - pData->iDEFIclipb = 0; - } - /* create an animation object */ - iRetcode = create_ani_defi (pData); - - if (!iRetcode) /* do display processing */ - iRetcode = process_display_defi (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_defip)*ppChunk)->iObjectid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - { - ((mng_defip)*ppChunk)->bHasdonotshow = MNG_TRUE; - ((mng_defip)*ppChunk)->iDonotshow = *(pRawdata+2); - } - else - ((mng_defip)*ppChunk)->bHasdonotshow = MNG_FALSE; - - if (iRawlen > 3) - { - ((mng_defip)*ppChunk)->bHasconcrete = MNG_TRUE; - ((mng_defip)*ppChunk)->iConcrete = *(pRawdata+3); - } - else - ((mng_defip)*ppChunk)->bHasconcrete = MNG_FALSE; - - if (iRawlen > 4) - { - ((mng_defip)*ppChunk)->bHasloca = MNG_TRUE; - ((mng_defip)*ppChunk)->iXlocation = mng_get_int32 (pRawdata+4); - ((mng_defip)*ppChunk)->iYlocation = mng_get_int32 (pRawdata+8); - } - else - ((mng_defip)*ppChunk)->bHasloca = MNG_FALSE; - - if (iRawlen > 12) - { - ((mng_defip)*ppChunk)->bHasclip = MNG_TRUE; - ((mng_defip)*ppChunk)->iLeftcb = mng_get_int32 (pRawdata+12); - ((mng_defip)*ppChunk)->iRightcb = mng_get_int32 (pRawdata+16); - ((mng_defip)*ppChunk)->iTopcb = mng_get_int32 (pRawdata+20); - ((mng_defip)*ppChunk)->iBottomcb = mng_get_int32 (pRawdata+24); - } - else - ((mng_defip)*ppChunk)->bHasclip = MNG_FALSE; - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_basi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BASI, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* check the length */ - if ((iRawlen != 13) && (iRawlen != 19) && (iRawlen != 21) && (iRawlen != 22)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasBASI = MNG_TRUE; /* inside a BASI-IEND block now */ - /* store interesting fields */ - pData->iDatawidth = mng_get_uint32 (pRawdata); - pData->iDataheight = mng_get_uint32 (pRawdata+4); - pData->iBitdepth = *(pRawdata+8); - pData->iColortype = *(pRawdata+9); - pData->iCompression = *(pRawdata+10); - pData->iFilter = *(pRawdata+11); - pData->iInterlace = *(pRawdata+12); - - if ((pData->iBitdepth != 1) && /* parameter validity checks */ - (pData->iBitdepth != 2) && - (pData->iBitdepth != 4) && - (pData->iBitdepth != 8) && - (pData->iBitdepth != 16) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if ((pData->iColortype != MNG_COLORTYPE_GRAY ) && - (pData->iColortype != MNG_COLORTYPE_RGB ) && - (pData->iColortype != MNG_COLORTYPE_INDEXED) && - (pData->iColortype != MNG_COLORTYPE_GRAYA ) && - (pData->iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8)) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (((pData->iColortype == MNG_COLORTYPE_RGB ) || - (pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iColortype == MNG_COLORTYPE_RGBA ) ) && - (pData->iBitdepth < 8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (pData->iCompression != MNG_COMPRESSION_DEFLATE) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if (pData->iFilter & (~MNG_FILTER_DIFFERING)) - MNG_ERROR (pData, MNG_INVALIDFILTER) - - if ((pData->iInterlace != MNG_INTERLACE_NONE ) && - (pData->iInterlace != MNG_INTERLACE_ADAM7) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE) - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint16 iRed = 0; - mng_uint16 iGreen = 0; - mng_uint16 iBlue = 0; - mng_bool bHasalpha = MNG_FALSE; - mng_uint16 iAlpha = 0xFFFF; - mng_uint8 iViewable = 0; - mng_retcode iRetcode; - - if (iRawlen > 13) /* get remaining fields, if any */ - { - iRed = mng_get_uint16 (pRawdata+13); - iGreen = mng_get_uint16 (pRawdata+15); - iBlue = mng_get_uint16 (pRawdata+17); - } - - if (iRawlen > 19) - { - bHasalpha = MNG_TRUE; - iAlpha = mng_get_uint16 (pRawdata+19); - } - - if (iRawlen > 21) - iViewable = *(pRawdata+21); - /* create an animation object */ - iRetcode = create_ani_basi (pData, iRed, iGreen, iBlue, - bHasalpha, iAlpha, iViewable); - - if (!iRetcode) /* display-processing... */ - iRetcode = process_display_basi (pData, iRed, iGreen, iBlue, - bHasalpha, iAlpha, iViewable); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_basip)*ppChunk)->iWidth = mng_get_uint32 (pRawdata); - ((mng_basip)*ppChunk)->iHeight = mng_get_uint32 (pRawdata+4); - ((mng_basip)*ppChunk)->iBitdepth = *(pRawdata+8); - ((mng_basip)*ppChunk)->iColortype = *(pRawdata+9); - ((mng_basip)*ppChunk)->iCompression = *(pRawdata+10); - ((mng_basip)*ppChunk)->iFilter = *(pRawdata+11); - ((mng_basip)*ppChunk)->iInterlace = *(pRawdata+12); - - if (iRawlen > 13) - { - ((mng_basip)*ppChunk)->iRed = mng_get_uint16 (pRawdata+13); - ((mng_basip)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+15); - ((mng_basip)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+17); - } - - if (iRawlen > 19) - ((mng_basip)*ppChunk)->iAlpha = mng_get_uint16 (pRawdata+19); - - if (iRawlen > 21) - ((mng_basip)*ppChunk)->iViewable = *(pRawdata+21); - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_clon) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLON, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* check the length */ - if ((iRawlen != 4) && (iRawlen != 5) && (iRawlen != 6) && - (iRawlen != 7) && (iRawlen != 16)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint16 iSourceid, iCloneid; - mng_uint8 iClonetype = 0; - mng_bool bHasdonotshow = MNG_FALSE; - mng_uint8 iDonotshow = 0; - mng_uint8 iConcrete = 0; - mng_bool bHasloca = MNG_FALSE; - mng_uint8 iLocationtype = 0; - mng_int32 iLocationx = 0; - mng_int32 iLocationy = 0; - mng_retcode iRetcode; - - iSourceid = mng_get_uint16 (pRawdata); - iCloneid = mng_get_uint16 (pRawdata+2); - - if (iRawlen > 4) - iClonetype = *(pRawdata+4); - - if (iRawlen > 5) - { - bHasdonotshow = MNG_TRUE; - iDonotshow = *(pRawdata+5); - } - - if (iRawlen > 6) - iConcrete = *(pRawdata+6); - - if (iRawlen > 7) - { - bHasloca = MNG_TRUE; - iLocationtype = *(pRawdata+7); - iLocationx = mng_get_int32 (pRawdata+8); - iLocationy = mng_get_int32 (pRawdata+12); - } - - iRetcode = create_ani_clon (pData, iSourceid, iCloneid, iClonetype, - bHasdonotshow, iDonotshow, iConcrete, - bHasloca, iLocationtype, iLocationx, iLocationy); - - if (!iRetcode) /* do display processing */ - iRetcode = process_display_clon (pData, iSourceid, iCloneid, iClonetype, - bHasdonotshow, iDonotshow, iConcrete, - bHasloca, iLocationtype, iLocationx, iLocationy); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_clonp)*ppChunk)->iSourceid = mng_get_uint16 (pRawdata); - ((mng_clonp)*ppChunk)->iCloneid = mng_get_uint16 (pRawdata+2); - - if (iRawlen > 4) - ((mng_clonp)*ppChunk)->iClonetype = *(pRawdata+4); - - if (iRawlen > 5) - ((mng_clonp)*ppChunk)->iDonotshow = *(pRawdata+5); - - if (iRawlen > 6) - ((mng_clonp)*ppChunk)->iConcrete = *(pRawdata+6); - - if (iRawlen > 7) - { - ((mng_clonp)*ppChunk)->bHasloca = MNG_TRUE; - ((mng_clonp)*ppChunk)->iLocationtype = *(pRawdata+7); - ((mng_clonp)*ppChunk)->iLocationx = mng_get_int32 (pRawdata+8); - ((mng_clonp)*ppChunk)->iLocationy = mng_get_int32 (pRawdata+12); - } - else - { - ((mng_clonp)*ppChunk)->bHasloca = MNG_FALSE; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_past) -{ -#ifdef MNG_STORE_CHUNKS - mng_uint32 iCount; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PAST, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - /* check the length */ - if ((iRawlen < 41) || (((iRawlen - 11) % 30) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_STORE_CHUNKS - iCount = ((iRawlen - 11) / 30); /* how many entries again */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { - mng_uint32 iX; - mng_past_sourcep pSource; - /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_pastp)*ppChunk)->iDestid = mng_get_uint16 (pRawdata); - ((mng_pastp)*ppChunk)->iTargettype = *(pRawdata+2); - ((mng_pastp)*ppChunk)->iTargetx = mng_get_int32 (pRawdata+3); - ((mng_pastp)*ppChunk)->iTargety = mng_get_int32 (pRawdata+7); - ((mng_pastp)*ppChunk)->iCount = iCount; - - pRawdata += 11; - /* get a buffer for all the source blocks */ - MNG_ALLOC (pData, ((mng_pastp)*ppChunk)->pSources, (iCount * sizeof (mng_past_source))) - - pSource = ((mng_pastp)*ppChunk)->pSources; - - for (iX = 0; iX < iCount; iX++) /* now copy the source blocks */ - { - pSource->iSourceid = mng_get_uint16 (pRawdata); - pSource->iComposition = *(pRawdata+2); - pSource->iOrientation = *(pRawdata+3); - pSource->iOffsettype = *(pRawdata+4); - pSource->iOffsetx = mng_get_int32 (pRawdata+5); - pSource->iOffsety = mng_get_int32 (pRawdata+9); - pSource->iBoundarytype = *(pRawdata+13); - pSource->iBoundaryl = mng_get_int32 (pRawdata+14); - pSource->iBoundaryr = mng_get_int32 (pRawdata+18); - pSource->iBoundaryt = mng_get_int32 (pRawdata+22); - pSource->iBoundaryb = mng_get_int32 (pRawdata+26); - - pSource += sizeof (mng_past_source); - pRawdata += 30; - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PAST, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_disc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DISC, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if ((iRawlen % 2) != 0) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { /* process it */ - mng_retcode iRetcode = process_display_disc (pData, (iRawlen / 2), - (mng_uint16p)pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_discp)*ppChunk)->iCount = iRawlen / 2; - - MNG_ALLOC (pData, ((mng_discp)*ppChunk)->pObjectids, iRawlen) - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint8p pIn = pRawdata; - mng_uint16p pOut = ((mng_discp)*ppChunk)->pObjectids; - - for (iX = 0; iX < ((mng_discp)*ppChunk)->iCount; iX++) - { - *pOut++ = mng_get_uint16 (pIn); - pIn += 2; - } - } -#else - MNG_COPY (((mng_discp)*ppChunk)->pObjectids, pRawdata, iRawlen) -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_back) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BACK, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* check the length */ - if ((iRawlen != 6) && (iRawlen != 7) && (iRawlen != 9) && (iRawlen != 10)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - /* retrieve the fields */ - pData->bHasBACK = MNG_TRUE; - pData->iBACKred = mng_get_uint16 (pRawdata); - pData->iBACKgreen = mng_get_uint16 (pRawdata+2); - pData->iBACKblue = mng_get_uint16 (pRawdata+4); - - if (iRawlen > 6) - pData->iBACKmandatory = *(pRawdata+6); - else - pData->iBACKmandatory = 0; - - if (iRawlen > 7) - pData->iBACKimageid = mng_get_uint16 (pRawdata+7); - else - pData->iBACKimageid = 0; - - if (iRawlen > 9) - pData->iBACKtile = *(pRawdata+9); - else - pData->iBACKtile = 0; - - iRetcode = create_ani_back (pData, pData->iBACKred, pData->iBACKgreen, - pData->iBACKblue, pData->iBACKmandatory, - pData->iBACKimageid, pData->iBACKtile); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_backp)*ppChunk)->iRed = mng_get_uint16 (pRawdata); - ((mng_backp)*ppChunk)->iGreen = mng_get_uint16 (pRawdata+2); - ((mng_backp)*ppChunk)->iBlue = mng_get_uint16 (pRawdata+4); - - if (iRawlen > 6) - ((mng_backp)*ppChunk)->iMandatory = *(pRawdata+6); - - if (iRawlen > 7) - ((mng_backp)*ppChunk)->iImageid = mng_get_uint16 (pRawdata+7); - - if (iRawlen > 9) - ((mng_backp)*ppChunk)->iTile = *(pRawdata+9); - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_fram) -{ - mng_uint8p pTemp; -#ifdef MNG_STORE_CHUNKS - mng_uint32 iNamelen; -#endif - mng_uint32 iRemain; - mng_uint32 iRequired = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FRAM, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen <= 1) /* only framing-mode ? */ - { -#ifdef MNG_STORE_CHUNKS - iNamelen = 0; /* indicate so */ -#endif - iRemain = 0; - pTemp = MNG_NULL; - } - else - { - pTemp = find_null (pRawdata+1); /* find null-separator */ - /* not found inside input-data ? */ - if ((pTemp - pRawdata) > (mng_int32)iRawlen) - MNG_ERROR (pData, MNG_NULLNOTFOUND) - -#ifdef MNG_STORE_CHUNKS - iNamelen = (mng_uint32)((pTemp - pRawdata) - 1); -#endif - iRemain = (mng_uint32)(iRawlen - (pTemp - pRawdata) - 1); - /* remains must be empty or at least 4 bytes */ - if ((iRemain != 0) && (iRemain < 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if (iRemain) - { - iRequired = 4; /* calculate and check required remaining length */ - - if (*(pTemp+1)) { iRequired += 4; } - if (*(pTemp+2)) { iRequired += 4; } - if (*(pTemp+3)) { iRequired += 17; } - - if (*(pTemp+4)) - { - if ((iRemain - iRequired) % 4 != 0) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - else - { - if (iRemain != iRequired) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - } - } - } - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint8p pWork = pTemp; - mng_uint8 iFramemode = 0; - mng_uint8 iChangedelay = 0; - mng_uint32 iDelay = 0; - mng_uint8 iChangetimeout = 0; - mng_uint32 iTimeout = 0; - mng_uint8 iChangeclipping = 0; - mng_uint8 iCliptype = 0; - mng_int32 iClipl = 0; - mng_int32 iClipr = 0; - mng_int32 iClipt = 0; - mng_int32 iClipb = 0; - mng_retcode iRetcode; - - if (iRawlen) /* any data specified ? */ - { - if (*(pRawdata)) /* save the new framing mode ? */ - { - iFramemode = *(pRawdata); - - if (pData->bPreDraft48) /* old style input-stream ? */ - { - switch (iFramemode) - { - case 0: { break; } - case 1: { iFramemode = 3; break; } - case 2: { iFramemode = 4; break; } - case 3: { iFramemode = 1; break; } - case 4: { iFramemode = 1; break; } - case 5: { iFramemode = 2; break; } - default: { iFramemode = 1; break; } - } - } - } - - if (iRemain) - { - iChangedelay = *(pWork+1); - iChangetimeout = *(pWork+2); - iChangeclipping = *(pWork+3); - pWork += 5; - - if (iChangedelay) /* delay changed ? */ - { - iDelay = mng_get_uint32 (pWork); - pWork += 4; - } - - if (iChangetimeout) /* timeout changed ? */ - { - iTimeout = mng_get_uint32 (pWork); - pWork += 4; - } - - if (iChangeclipping) /* clipping changed ? */ - { - iCliptype = *pWork; - iClipl = mng_get_int32 (pWork+1); - iClipr = mng_get_int32 (pWork+5); - iClipt = mng_get_int32 (pWork+9); - iClipb = mng_get_int32 (pWork+13); - } - } - } - - iRetcode = create_ani_fram (pData, iFramemode, iChangedelay, iDelay, - iChangetimeout, iTimeout, - iChangeclipping, iCliptype, - iClipl, iClipr, iClipt, iClipb); - - if (!iRetcode) /* now go and do something */ - iRetcode = process_display_fram (pData, iFramemode, iChangedelay, iDelay, - iChangetimeout, iTimeout, - iChangeclipping, iCliptype, - iClipl, iClipr, iClipt, iClipb); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_framp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - mng_uint8 iFramemode = *(pRawdata); - - if (pData->bPreDraft48) /* old style input-stream ? */ - { - switch (iFramemode) - { - case 1: { iFramemode = 3; break; } - case 2: { iFramemode = 4; break; } - case 3: { iFramemode = 5; break; } /* TODO: provision for mode=5 ??? */ - case 4: { iFramemode = 1; break; } - case 5: { iFramemode = 2; break; } - default: { iFramemode = 1; break; } - } - } - - ((mng_framp)*ppChunk)->iMode = iFramemode; - ((mng_framp)*ppChunk)->iNamesize = iNamelen; - - if (iNamelen) - { - MNG_ALLOC (pData, ((mng_framp)*ppChunk)->zName, iNamelen+1) - MNG_COPY (((mng_framp)*ppChunk)->zName, pRawdata+1, iNamelen) - } - - if (iRemain) - { - ((mng_framp)*ppChunk)->iChangedelay = *(pTemp+1); - ((mng_framp)*ppChunk)->iChangetimeout = *(pTemp+2); - ((mng_framp)*ppChunk)->iChangeclipping = *(pTemp+3); - ((mng_framp)*ppChunk)->iChangesyncid = *(pTemp+4); - - pTemp += 5; - - if (((mng_framp)*ppChunk)->iChangedelay) - { - ((mng_framp)*ppChunk)->iDelay = mng_get_uint32 (pTemp); - pTemp += 4; - } - - if (((mng_framp)*ppChunk)->iChangetimeout) - { - ((mng_framp)*ppChunk)->iTimeout = mng_get_uint32 (pTemp); - pTemp += 4; - } - - if (((mng_framp)*ppChunk)->iChangeclipping) - { - ((mng_framp)*ppChunk)->iBoundarytype = *pTemp; - ((mng_framp)*ppChunk)->iBoundaryl = mng_get_int32 (pTemp+1); - ((mng_framp)*ppChunk)->iBoundaryr = mng_get_int32 (pTemp+5); - ((mng_framp)*ppChunk)->iBoundaryt = mng_get_int32 (pTemp+9); - ((mng_framp)*ppChunk)->iBoundaryb = mng_get_int32 (pTemp+13); - pTemp += 17; - } - - if (((mng_framp)*ppChunk)->iChangesyncid) - { - ((mng_framp)*ppChunk)->iCount = (iRemain - iRequired) / 4; - - if (((mng_framp)*ppChunk)->iCount) - { - MNG_ALLOC (pData, ((mng_framp)*ppChunk)->pSyncids, - ((mng_framp)*ppChunk)->iCount * 4); - -#ifndef MNG_BIGENDIAN_SUPPORTED - { - mng_uint32 iX; - mng_uint32p pOut = ((mng_framp)*ppChunk)->pSyncids; - - for (iX = 0; iX < ((mng_framp)*ppChunk)->iCount; iX++) - { - *pOut++ = mng_get_uint32 (pTemp); - pTemp += 4; - } - } -#else - MNG_COPY (((mng_framp)*ppChunk)->pSyncids, pTemp, - ((mng_framp)*ppChunk)->iCount * 4) -#endif /* !MNG_BIGENDIAN_SUPPORTED */ - } - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_move) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MOVE, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen != 13) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - /* create a MOVE animation object */ - iRetcode = create_ani_move (pData, mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9)); - - if (!iRetcode) /* process the move */ - iRetcode = process_display_move (pData, - mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9)); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_movep)*ppChunk)->iFirstid = mng_get_uint16 (pRawdata); - ((mng_movep)*ppChunk)->iLastid = mng_get_uint16 (pRawdata+2); - ((mng_movep)*ppChunk)->iMovetype = *(pRawdata+4); - ((mng_movep)*ppChunk)->iMovex = mng_get_int32 (pRawdata+5); - ((mng_movep)*ppChunk)->iMovey = mng_get_int32 (pRawdata+9); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_clip) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLIP, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen != 21) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - /* create a CLIP animation object */ - iRetcode = create_ani_clip (pData, mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9), - mng_get_int32 (pRawdata+13), - mng_get_int32 (pRawdata+17)); - - if (!iRetcode) /* process the clipping */ - iRetcode = process_display_clip (pData, - mng_get_uint16 (pRawdata), - mng_get_uint16 (pRawdata+2), - *(pRawdata+4), - mng_get_int32 (pRawdata+5), - mng_get_int32 (pRawdata+9), - mng_get_int32 (pRawdata+13), - mng_get_int32 (pRawdata+17)); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_clipp)*ppChunk)->iFirstid = mng_get_uint16 (pRawdata); - ((mng_clipp)*ppChunk)->iLastid = mng_get_uint16 (pRawdata+2); - ((mng_clipp)*ppChunk)->iCliptype = *(pRawdata+4); - ((mng_clipp)*ppChunk)->iClipl = mng_get_int32 (pRawdata+5); - ((mng_clipp)*ppChunk)->iClipr = mng_get_int32 (pRawdata+9); - ((mng_clipp)*ppChunk)->iClipt = mng_get_int32 (pRawdata+13); - ((mng_clipp)*ppChunk)->iClipb = mng_get_int32 (pRawdata+17); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_show) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SHOW, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* check the length */ - if ((iRawlen != 0) && (iRawlen != 2) && (iRawlen != 4) && (iRawlen != 5)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - if (iRawlen) /* determine parameters if any */ - { - pData->iSHOWfromid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - pData->iSHOWtoid = mng_get_uint16 (pRawdata+2); - else - pData->iSHOWtoid = pData->iSHOWfromid; - - if (iRawlen > 4) - pData->iSHOWmode = *(pRawdata+4); - else - pData->iSHOWmode = 0; - } - else /* use defaults then */ - { - pData->iSHOWmode = 2; - pData->iSHOWfromid = 1; - pData->iSHOWtoid = 65535; - } - /* create a SHOW animation object */ - iRetcode = create_ani_show (pData, pData->iSHOWfromid, pData->iSHOWtoid, - pData->iSHOWmode); - - if (!iRetcode) /* go and do it! */ - iRetcode = process_display_show (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_showp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_showp)*ppChunk)->iFirstid = mng_get_uint16 (pRawdata); - - if (iRawlen > 2) - ((mng_showp)*ppChunk)->iLastid = mng_get_uint16 (pRawdata+2); - - if (iRawlen > 4) - ((mng_showp)*ppChunk)->iMode = *(pRawdata+4); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_term) -{ - mng_uint8 iTermaction; - mng_uint8 iIteraction = 0; - mng_uint32 iDelay = 0; - mng_uint32 iItermax = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TERM, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (pData->bHasLOOP) /* no way, jose! */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (pData->bHasTERM) /* only 1 allowed! */ - MNG_ERROR (pData, MNG_MULTIPLEERROR) - /* check the length */ - if ((iRawlen != 1) && (iRawlen != 10)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasTERM = MNG_TRUE; - /* TODO: remove in 1.0.0 !!! */ - if ((!pData->bHasSAVE) && (pData->iChunkseq > 2)) - pData->bEMNGMAhack = MNG_TRUE; - - iTermaction = *pRawdata; /* get the fields */ - - if (iRawlen > 1) - { - iIteraction = *(pRawdata+1); - iDelay = mng_get_uint32 (pRawdata+2); - iItermax = mng_get_uint32 (pRawdata+6); - } - - if (pData->fProcessterm) /* inform the app ? */ - if (!pData->fProcessterm (((mng_handle)pData), iTermaction, iIteraction, - iDelay, iItermax)) - MNG_ERROR (pData, MNG_APPMISCERROR) - -#ifdef MNG_SUPPORT_DISPLAY - { /* create the TERM ani-object */ - mng_retcode iRetcode = create_ani_term (pData, iTermaction, iIteraction, - iDelay, iItermax); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* save for future reference */ - pData->pTermaniobj = pData->pLastaniobj; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_termp)*ppChunk)->iTermaction = iTermaction; - ((mng_termp)*ppChunk)->iIteraction = iIteraction; - ((mng_termp)*ppChunk)->iDelay = iDelay; - ((mng_termp)*ppChunk)->iItermax = iItermax; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_save) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SAVE, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (pData->bHasSAVE)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - pData->bHasSAVE = MNG_TRUE; - - if (pData->fProcesssave) /* inform the application ? */ - { - mng_bool bOke = pData->fProcesssave ((mng_handle)pData); - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR) - } - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - - /* TODO: something with the parameters */ - - - /* create a SAVE animation object */ - iRetcode = create_ani_save (pData); - - if (!iRetcode) /* process it */ - iRetcode = process_display_save (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_savep)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) /* not empty ? */ - { - mng_uint8 iOtype = *pRawdata; - mng_uint8 iEtype; - mng_uint32 iCount = 0; - mng_uint8p pTemp; - mng_uint8p pNull; - mng_uint32 iLen; - mng_uint32 iOffset[2]; - mng_uint32 iStarttime[2]; - mng_uint32 iFramenr; - mng_uint32 iLayernr; - mng_uint32 iX; - mng_save_entryp pEntry = MNG_NULL; - mng_uint32 iNamesize; - - if ((iOtype != 4) && (iOtype != 8)) - MNG_ERROR (pData, MNG_INVOFFSETSIZE); - - ((mng_savep)*ppChunk)->iOffsettype = iOtype; - - for (iX = 0; iX < 2; iX++) /* do this twice to get the count first ! */ - { - pTemp = pRawdata + 1; - iLen = iRawlen - 1; - - if (iX) /* second run ? */ - { - MNG_ALLOC (pData, pEntry, (iCount * sizeof (mng_save_entry))) - - ((mng_savep)*ppChunk)->iCount = iCount; - ((mng_savep)*ppChunk)->pEntries = pEntry; - } - - while (iLen) /* anything left ? */ - { - iEtype = *pTemp; /* entrytype */ - - if ((iEtype != 0) && (iEtype != 1) && (iEtype != 2) && (iEtype != 3)) - MNG_ERROR (pData, MNG_INVENTRYTYPE); - - pTemp++; - - if (iEtype > 1) - { - iOffset [0] = 0; - iOffset [1] = 0; - iStarttime [0] = 0; - iStarttime [1] = 0; - iLayernr = 0; - iFramenr = 0; - } - else - { - if (iOtype == 4) - { - iOffset [0] = 0; - iOffset [1] = mng_get_uint32 (pTemp); - - pTemp += 4; - } - else - { - iOffset [0] = mng_get_uint32 (pTemp); - iOffset [1] = mng_get_uint32 (pTemp+4); - - pTemp += 8; - } - - if (iEtype > 0) - { - iStarttime [0] = 0; - iStarttime [1] = 0; - iLayernr = 0; - iFramenr = 0; - } - else - { - if (iOtype == 4) - { - iStarttime [0] = 0; - iStarttime [1] = mng_get_uint32 (pTemp+0); - iLayernr = mng_get_uint32 (pTemp+4); - iFramenr = mng_get_uint32 (pTemp+8); - - pTemp += 12; - } - else - { - iStarttime [0] = mng_get_uint32 (pTemp+0); - iStarttime [1] = mng_get_uint32 (pTemp+4); - iLayernr = mng_get_uint32 (pTemp+8); - iFramenr = mng_get_uint32 (pTemp+12); - - pTemp += 16; - } - } - } - - pNull = find_null (pTemp); /* get the name length */ - - if ((pNull - pRawdata) > (mng_int32)iRawlen) - { - iNamesize = iLen; /* no null found; so end of SAVE */ - iLen = 0; - } - else - { - iNamesize = pNull - pTemp; /* should be another entry */ - iLen -= iNamesize; - - if (!iLen) /* must not end with a null ! */ - MNG_ERROR (pData, MNG_ENDWITHNULL) - } - - if (!pEntry) - { - iCount++; - } - else - { - pEntry->iEntrytype = iEtype; - pEntry->iOffset [0] = iOffset [0]; - pEntry->iOffset [1] = iOffset [1]; - pEntry->iStarttime [0] = iStarttime [0]; - pEntry->iStarttime [1] = iStarttime [1]; - pEntry->iLayernr = iLayernr; - pEntry->iFramenr = iFramenr; - pEntry->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, pEntry->zName, iNamesize+1) - MNG_COPY (pEntry->zName, pTemp, iNamesize) - } - - pEntry++; - } - - pTemp += iNamesize; - } - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_seek) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SEEK, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasSAVE)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (pData->fProcessseek) /* inform the app ? */ - { - mng_bool bOke; - mng_pchar zName; - - MNG_ALLOC (pData, zName, iRawlen + 1) - - if (iRawlen) - MNG_COPY (zName, pRawdata, iRawlen) - - bOke = pData->fProcessseek ((mng_handle)pData, zName); - - MNG_FREEX (pData, zName, iRawlen + 1) - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR) - } - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - - /* TODO: something with the name ??? */ - - - - /* create a SEEK animation object */ - iRetcode = create_ani_seek (pData); - - if (!iRetcode) /* process it */ - iRetcode = process_display_seek (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_seekp)*ppChunk)->iNamesize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_seekp)*ppChunk)->zName, iRawlen+1) - MNG_COPY (((mng_seekp)*ppChunk)->zName, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_expi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_EXPI, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen < 3) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_expip)*ppChunk)->iSnapshotid = mng_get_uint16 (pRawdata); - ((mng_expip)*ppChunk)->iNamesize = iRawlen - 2; - - if (((mng_expip)*ppChunk)->iNamesize) - { - MNG_ALLOC (pData, ((mng_expip)*ppChunk)->zName, - ((mng_expip)*ppChunk)->iNamesize + 1) - MNG_COPY (((mng_expip)*ppChunk)->zName, pRawdata+2, - ((mng_expip)*ppChunk)->iNamesize) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_EXPI, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_fpri) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FPRI, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen != 2) /* must be two bytes long */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_fprip)*ppChunk)->iDeltatype = *pRawdata; - ((mng_fprip)*ppChunk)->iPriority = *(pRawdata+1); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_FPRI, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -mng_bool CheckKeyword (mng_datap pData, - mng_uint8p pKeyword) -{ - mng_chunkid handled_chunks [] = - { - MNG_UINT_BACK, - MNG_UINT_BASI, - MNG_UINT_CLIP, - MNG_UINT_CLON, -/* TODO: MNG_UINT_DBYK, */ - MNG_UINT_DEFI, - MNG_UINT_DHDR, - MNG_UINT_DISC, -/* TODO: MNG_UINT_DROP, */ - MNG_UINT_ENDL, - MNG_UINT_FRAM, - MNG_UINT_IDAT, - MNG_UINT_IEND, - MNG_UINT_IHDR, - MNG_UINT_IJNG, - MNG_UINT_IPNG, -#ifdef MNG_INCLUDE_JNG - MNG_UINT_JDAA, - MNG_UINT_JDAT, - MNG_UINT_JHDR, -/* TODO: MNG_UINT_JSEP, */ - MNG_UINT_JdAA, -#endif - MNG_UINT_LOOP, - MNG_UINT_MAGN, - MNG_UINT_MEND, - MNG_UINT_MHDR, - MNG_UINT_MOVE, -/* TODO: MNG_UINT_ORDR, */ -/* TODO: MNG_UINT_PAST, */ - MNG_UINT_PLTE, - MNG_UINT_PPLT, - MNG_UINT_PROM, - MNG_UINT_SAVE, - MNG_UINT_SEEK, - MNG_UINT_SHOW, - MNG_UINT_TERM, - MNG_UINT_bKGD, - MNG_UINT_cHRM, -/* TODO: MNG_UINT_eXPI, */ -/* TODO: MNG_UINT_fPRI, */ - MNG_UINT_gAMA, -/* TODO: MNG_UINT_hIST, */ - MNG_UINT_iCCP, - MNG_UINT_iTXt, - MNG_UINT_nEED, -/* TODO: MNG_UINT_oFFs, */ -/* TODO: MNG_UINT_pCAL, */ -/* TODO: MNG_UINT_pHYg, */ -/* TODO: MNG_UINT_pHYs, */ -/* TODO: MNG_UINT_sBIT, */ -/* TODO: MNG_UINT_sCAL, */ -/* TODO: MNG_UINT_sPLT, */ - MNG_UINT_sRGB, - MNG_UINT_tEXt, - MNG_UINT_tIME, - MNG_UINT_tRNS, - MNG_UINT_zTXt, - }; - - mng_bool bOke = MNG_FALSE; - - if (pData->fProcessneed) /* does the app handle it ? */ - bOke = pData->fProcessneed ((mng_handle)pData, (mng_pchar)pKeyword); - - if (!bOke) - { /* find the keyword length */ - mng_uint8p pNull = find_null (pKeyword); - - if (pNull - pKeyword == 4) /* test a chunk ? */ - { /* get the chunk-id */ - mng_chunkid iChunkid = (*pKeyword << 24) + (*(pKeyword+1) << 16) + - (*(pKeyword+2) << 8) + (*(pKeyword+3) ); - /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - /* determine max index of table */ - iTop = (sizeof (handled_chunks) / sizeof (handled_chunks [0])) - 1; - - /* binary search; with 52 chunks, worst-case is 7 comparisons */ - iLower = 0; - iMiddle = iTop >> 1; - iUpper = iTop; - - do /* the binary search itself */ - { - if (handled_chunks [iMiddle] < iChunkid) - iLower = iMiddle + 1; - else if (handled_chunks [iMiddle] > iChunkid) - iUpper = iMiddle - 1; - else - { - bOke = MNG_TRUE; - break; - } - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - } - /* test draft ? */ - if ((!bOke) && (pNull - pKeyword == 8) && - (*pKeyword == 'd') && (*(pKeyword+1) == 'r') && - (*(pKeyword+2) == 'a') && (*(pKeyword+3) == 'f') && - (*(pKeyword+4) == 't') && (*(pKeyword+5) == ' ')) - { - mng_uint32 iDraft; - - iDraft = (*(pKeyword+6) - '0') * 10 + (*(pKeyword+7) - '0'); - bOke = (mng_bool)(iDraft <= MNG_MNG_DRAFT); - } - /* test MNG 1.0 ? */ - if ((!bOke) && (pNull - pKeyword == 7) && - (*pKeyword == 'M') && (*(pKeyword+1) == 'N') && - (*(pKeyword+2) == 'G') && (*(pKeyword+3) == '-') && - (*(pKeyword+4) == '1') && (*(pKeyword+5) == '.') && - (*(pKeyword+6) == '0')) - bOke = MNG_TRUE; - - } - - return bOke; -} - -/* ************************************************************************** */ - -READ_CHUNK (read_need) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_NEED, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen < 1) /* check the length */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - { /* let's check it */ - mng_bool bOke = MNG_TRUE; - mng_pchar zKeywords; - mng_uint8p pNull, pTemp; - - MNG_ALLOC (pData, zKeywords, iRawlen + 1) - - if (iRawlen) - MNG_COPY (zKeywords, pRawdata, iRawlen) - - pTemp = (mng_uint8p)zKeywords; - pNull = find_null (pTemp); - - while ((bOke) && (pNull < (mng_uint8p)zKeywords + iRawlen)) - { - bOke = CheckKeyword (pData, pTemp); - pTemp = pNull + 1; - pNull = find_null (pTemp); - } - - if (bOke) - bOke = CheckKeyword (pData, pTemp); - - MNG_FREEX (pData, zKeywords, iRawlen + 1) - - if (!bOke) - MNG_ERROR (pData, MNG_UNSUPPORTEDNEED) - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_needp)*ppChunk)->iKeywordssize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_needp)*ppChunk)->zKeywords, iRawlen+1) - MNG_COPY (((mng_needp)*ppChunk)->zKeywords, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_NEED, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_phyg) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYG, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* it's 9 bytes or empty; no more, no less! */ - if ((iRawlen != 9) && (iRawlen != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_phygp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - - if (iRawlen) - { - ((mng_phygp)*ppChunk)->iSizex = mng_get_uint32 (pRawdata); - ((mng_phygp)*ppChunk)->iSizey = mng_get_uint32 (pRawdata+4); - ((mng_phygp)*ppChunk)->iUnit = *(pRawdata+8); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PHYG, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (read_jhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JHDR, MNG_LC_START) -#endif - /* sequence checks */ - if ((pData->eSigtype != mng_it_jng) && (pData->eSigtype != mng_it_mng)) - MNG_ERROR (pData, MNG_CHUNKNOTALLOWED) - - if ((pData->eSigtype == mng_it_jng) && (pData->iChunkseq > 1)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen != 16) /* length oke ? */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - /* inside a JHDR-IEND block now */ - pData->bHasJHDR = MNG_TRUE; - /* and store interesting fields */ - pData->iDatawidth = mng_get_uint32 (pRawdata); - pData->iDataheight = mng_get_uint32 (pRawdata+4); - pData->iJHDRcolortype = *(pRawdata+8); - pData->iJHDRimgbitdepth = *(pRawdata+9); - pData->iJHDRimgcompression = *(pRawdata+10); - pData->iJHDRimginterlace = *(pRawdata+11); - pData->iJHDRalphabitdepth = *(pRawdata+12); - pData->iJHDRalphacompression = *(pRawdata+13); - pData->iJHDRalphafilter = *(pRawdata+14); - pData->iJHDRalphainterlace = *(pRawdata+15); - /* parameter validity checks */ - if ((pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAY ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLOR ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAYA ) && - (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLORA) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - if ((pData->iJHDRimgbitdepth != 8) && - (pData->iJHDRimgbitdepth != 12) && - (pData->iJHDRimgbitdepth != 20) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (pData->iJHDRimgcompression != MNG_COMPRESSION_BASELINEJPEG) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if ((pData->iJHDRimginterlace != MNG_INTERLACE_SEQUENTIAL ) && - (pData->iJHDRimginterlace != MNG_INTERLACE_PROGRESSIVE) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE) - - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { - if ((pData->iJHDRalphabitdepth != 1) && - (pData->iJHDRalphabitdepth != 2) && - (pData->iJHDRalphabitdepth != 4) && - (pData->iJHDRalphabitdepth != 8) && - (pData->iJHDRalphabitdepth != 16) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if ((pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE ) && - (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG) ) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if ((pData->iJHDRalphacompression == MNG_COMPRESSION_BASELINEJPEG) && - (pData->iJHDRalphabitdepth != 8 ) ) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (pData->iJHDRalphafilter & (~MNG_FILTER_DIFFERING)) - MNG_ERROR (pData, MNG_INVALIDFILTER) - - if ((pData->iJHDRalphainterlace != MNG_INTERLACE_NONE ) && - (pData->iJHDRalphainterlace != MNG_INTERLACE_ADAM7) ) - MNG_ERROR (pData, MNG_INVALIDINTERLACE) - - } - else - { - if (pData->iJHDRalphabitdepth != 0) - MNG_ERROR (pData, MNG_INVALIDBITDEPTH) - - if (pData->iJHDRalphacompression != 0) - MNG_ERROR (pData, MNG_INVALIDCOMPRESS) - - if (pData->iJHDRalphafilter != 0) - MNG_ERROR (pData, MNG_INVALIDFILTER) - - if (pData->iJHDRalphainterlace != 0) - MNG_ERROR (pData, MNG_INVALIDINTERLACE) - - } - - if (!pData->bHasheader) /* first chunk ? */ - { - pData->bHasheader = MNG_TRUE; /* we've got a header */ - pData->eImagetype = mng_it_jng; /* then this must be a JNG */ - pData->iWidth = mng_get_uint32 (pRawdata); - pData->iHeight = mng_get_uint32 (pRawdata+4); - /* predict alpha-depth ! */ - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - pData->iAlphadepth = pData->iJHDRalphabitdepth; - else - pData->iAlphadepth = 0; - /* fits on maximum canvas ? */ - if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight)) - MNG_WARNING (pData, MNG_IMAGETOOLARGE) - - if (pData->fProcessheader) /* inform the app ? */ - if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight)) - MNG_ERROR (pData, MNG_APPMISCERROR) - - } - - pData->iColortype = 0; /* fake grayscale for other routines */ - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = process_display_jhdr (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_jhdrp)*ppChunk)->iWidth = mng_get_uint32 (pRawdata); - ((mng_jhdrp)*ppChunk)->iHeight = mng_get_uint32 (pRawdata+4); - ((mng_jhdrp)*ppChunk)->iColortype = *(pRawdata+8); - ((mng_jhdrp)*ppChunk)->iImagesampledepth = *(pRawdata+9); - ((mng_jhdrp)*ppChunk)->iImagecompression = *(pRawdata+10); - ((mng_jhdrp)*ppChunk)->iImageinterlace = *(pRawdata+11); - ((mng_jhdrp)*ppChunk)->iAlphasampledepth = *(pRawdata+12); - ((mng_jhdrp)*ppChunk)->iAlphacompression = *(pRawdata+13); - ((mng_jhdrp)*ppChunk)->iAlphafilter = *(pRawdata+14); - ((mng_jhdrp)*ppChunk)->iAlphainterlace = *(pRawdata+15); - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jhdr 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (read_jdaa) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAA, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasJHDR) && (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (pData->bHasJSEP) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen == 0) /* can never be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasJDAA = MNG_TRUE; /* got some JDAA now, don't we */ - -#ifdef MNG_SUPPORT_DISPLAY - if (iRawlen) - { /* display processing for non-empty chunks */ - mng_retcode iRetcode = process_display_jdaa (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_jdaap)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_jdaap)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen != 0) /* is there any data ? */ - { - MNG_ALLOC (pData, ((mng_jdaap)*ppChunk)->pData, iRawlen) - MNG_COPY (((mng_jdaap)*ppChunk)->pData, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAA, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jdaa 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (read_jdat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAT, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasJHDR) && (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen == 0) /* can never be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasJDAT = MNG_TRUE; /* got some JDAT now, don't we */ - -#ifdef MNG_SUPPORT_DISPLAY - if (iRawlen) - { /* display processing for non-empty chunks */ - mng_retcode iRetcode = process_display_jdat (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_jdatp)*ppChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_jdatp)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen != 0) /* is there any data ? */ - { - MNG_ALLOC (pData, ((mng_jdatp)*ppChunk)->pData, iRawlen) - MNG_COPY (((mng_jdatp)*ppChunk)->pData, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jdat 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -READ_CHUNK (read_jsep) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JSEP, MNG_LC_START) -#endif - - if (!pData->bHasJHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen != 0) /* must be empty ! */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasJSEP = MNG_TRUE; /* indicate we've had the 8-/12-bit separator */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_JSEP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} -#else -#define read_jsep 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -READ_CHUNK (read_dhdr) -{ - mng_uint8 iImagetype, iDeltatype; -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DHDR, MNG_LC_START) -#endif - - if (!pData->bHasMHDR) /* sequence checks */ - MNG_ERROR (pData, MNG_SEQUENCEERROR) - -#ifdef MNG_INCLUDE_JNG - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* check for valid length */ - if ((iRawlen != 4) && (iRawlen != 12) && (iRawlen != 20)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - iImagetype = *(pRawdata+2); /* check fields for validity */ - iDeltatype = *(pRawdata+3); - - if (iImagetype > MNG_IMAGETYPE_JNG) - MNG_ERROR (pData, MNG_INVIMAGETYPE) - - if (iDeltatype > MNG_DELTATYPE_NOCHANGE) - MNG_ERROR (pData, MNG_INVDELTATYPE) - - if ((iDeltatype == MNG_DELTATYPE_REPLACE) && (iRawlen > 12)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((iDeltatype == MNG_DELTATYPE_NOCHANGE) && (iRawlen > 4)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - pData->bHasDHDR = MNG_TRUE; /* inside a DHDR-IEND block now */ - - pData->iImagelevel++; /* one level deeper */ - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_uint16 iObjectid = mng_get_uint16 (pRawdata); - mng_uint32 iBlockwidth = 0; - mng_uint32 iBlockheight = 0; - mng_uint32 iBlockx = 0; - mng_uint32 iBlocky = 0; - mng_retcode iRetcode; - - if (iRawlen > 4) - { - iBlockwidth = mng_get_uint32 (pRawdata+4); - iBlockheight = mng_get_uint32 (pRawdata+8); - } - - if (iRawlen > 12) - { - iBlockx = mng_get_uint32 (pRawdata+12); - iBlocky = mng_get_uint32 (pRawdata+16); - } - - iRetcode = create_ani_dhdr (pData, iObjectid, iImagetype, iDeltatype, - iBlockwidth, iBlockheight, iBlockx, iBlocky); - - if (!iRetcode) /* display processing ? */ - iRetcode = process_display_dhdr (pData, iObjectid, iImagetype, iDeltatype, - iBlockwidth, iBlockheight, iBlockx, iBlocky); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_dhdrp)*ppChunk)->iObjectid = mng_get_uint16 (pRawdata); - ((mng_dhdrp)*ppChunk)->iImagetype = iImagetype; - ((mng_dhdrp)*ppChunk)->iDeltatype = iDeltatype; - - if (iRawlen > 4) - { - ((mng_dhdrp)*ppChunk)->iBlockwidth = mng_get_uint32 (pRawdata+4); - ((mng_dhdrp)*ppChunk)->iBlockheight = mng_get_uint32 (pRawdata+8); - } - - if (iRawlen > 12) - { - ((mng_dhdrp)*ppChunk)->iBlockx = mng_get_uint32 (pRawdata+12); - ((mng_dhdrp)*ppChunk)->iBlocky = mng_get_uint32 (pRawdata+16); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_prom) -{ - mng_uint8 iColortype; - mng_uint8 iSampledepth; - mng_uint8 iFilltype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PROM, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen != 3) /* gotta be exactly 3 bytes */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - iColortype = *pRawdata; /* check fields for validity */ - iSampledepth = *(pRawdata+1); - iFilltype = *(pRawdata+2); - - if ((iColortype != MNG_COLORTYPE_GRAY ) && - (iColortype != MNG_COLORTYPE_RGB ) && - (iColortype != MNG_COLORTYPE_INDEXED) && - (iColortype != MNG_COLORTYPE_GRAYA ) && - (iColortype != MNG_COLORTYPE_RGBA ) ) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - if ((iSampledepth != MNG_BITDEPTH_1 ) && - (iSampledepth != MNG_BITDEPTH_2 ) && - (iSampledepth != MNG_BITDEPTH_4 ) && - (iSampledepth != MNG_BITDEPTH_8 ) && - (iSampledepth != MNG_BITDEPTH_16) ) - MNG_ERROR (pData, MNG_INVSAMPLEDEPTH) - - if ((iFilltype != MNG_FILLMETHOD_LEFTBITREPLICATE) && - (iFilltype != MNG_FILLMETHOD_ZEROFILL ) ) - MNG_ERROR (pData, MNG_INVFILLMETHOD) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = create_ani_prom (pData, iSampledepth, iColortype, iFilltype); - - if (!iRetcode) /* display processing ? */ - iRetcode = process_display_prom (pData, iSampledepth, - iColortype, iFilltype); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_promp)*ppChunk)->iColortype = iColortype; - ((mng_promp)*ppChunk)->iSampledepth = iSampledepth; - ((mng_promp)*ppChunk)->iFilltype = iFilltype; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_ipng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IPNG, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen != 0) /* gotta be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = create_ani_ipng (pData); - - if (!iRetcode) /* process it */ - iRetcode = process_display_ipng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_pplt) -{ - mng_uint8 iDeltatype; - mng_uint8p pTemp; - mng_uint32 iLen; - mng_uint8 iX, iM; - mng_uint32 iY; - mng_uint32 iMax; - mng_rgbpaltab aIndexentries; - mng_uint8arr aAlphaentries; - mng_uint8arr aUsedentries; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PPLT, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) && (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen < 1) /* must have at least 1 byte */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - iDeltatype = *pRawdata; - /* valid ? */ - if (iDeltatype > MNG_DELTATYPE_DELTARGBA) - MNG_ERROR (pData, MNG_INVDELTATYPE) - /* must be indexed color ! */ - if (pData->iColortype != MNG_COLORTYPE_INDEXED) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - pTemp = pRawdata + 1; - iLen = iRawlen - 1; - iMax = 0; - - for (iY = 0; iY < 256; iY++) /* reset arrays */ - { - aIndexentries [iY].iRed = 0; - aIndexentries [iY].iGreen = 0; - aIndexentries [iY].iBlue = 0; - aAlphaentries [iY] = 255; - aUsedentries [iY] = 0; - } - - while (iLen) /* as long as there are entries left ... */ - { - mng_uint32 iDiff; - - if (iLen < 2) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - iX = *pTemp; /* get start and end index */ - iM = *(pTemp+1); - - if (iM < iX) - MNG_ERROR (pData, MNG_INVALIDINDEX) - - if ((mng_uint32)iM >= iMax) /* determine highest used index */ - iMax = (mng_uint32)iM + 1; - - pTemp += 2; - iLen -= 2; - - if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) || - (iDeltatype == MNG_DELTATYPE_DELTARGB ) ) - iDiff = (iM - iX + 1) * 3; - else - if ((iDeltatype == MNG_DELTATYPE_REPLACEALPHA) || - (iDeltatype == MNG_DELTATYPE_DELTAALPHA ) ) - iDiff = (iM - iX + 1); - else - iDiff = (iM - iX + 1) * 4; - - if (iLen < iDiff) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) || - (iDeltatype == MNG_DELTATYPE_DELTARGB ) ) - { - for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++) - { - aIndexentries [iY].iRed = *pTemp; - aIndexentries [iY].iGreen = *(pTemp+1); - aIndexentries [iY].iBlue = *(pTemp+2); - aUsedentries [iY] = 1; - - pTemp += 3; - iLen -= 3; - } - } - else - if ((iDeltatype == MNG_DELTATYPE_REPLACEALPHA) || - (iDeltatype == MNG_DELTATYPE_DELTAALPHA ) ) - { - for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++) - { - aAlphaentries [iY] = *pTemp; - aUsedentries [iY] = 1; - - pTemp++; - iLen--; - } - } - else - { - for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++) - { - aIndexentries [iY].iRed = *pTemp; - aIndexentries [iY].iGreen = *(pTemp+1); - aIndexentries [iY].iBlue = *(pTemp+2); - aAlphaentries [iY] = *(pTemp+3); - aUsedentries [iY] = 1; - - pTemp += 4; - iLen -= 4; - } - } - } - - switch (pData->iBitdepth) /* check maximum allowed entries for bitdepth */ - { - case MNG_BITDEPTH_1 : { - if (iMax > 2) - MNG_ERROR (pData, MNG_INVALIDINDEX) - break; - } - case MNG_BITDEPTH_2 : { - if (iMax > 4) - MNG_ERROR (pData, MNG_INVALIDINDEX) - break; - } - case MNG_BITDEPTH_4 : { - if (iMax > 16) - MNG_ERROR (pData, MNG_INVALIDINDEX) - break; - } - } - -#ifdef MNG_SUPPORT_DISPLAY - { /* create animation object */ - mng_retcode iRetcode = create_ani_pplt (pData, iDeltatype, iMax, - aIndexentries, aAlphaentries, - aUsedentries); - - if (!iRetcode) /* execute it now ? */ - iRetcode = process_display_pplt (pData, iDeltatype, iMax, aIndexentries, - aAlphaentries, aUsedentries); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_ppltp)*ppChunk)->iDeltatype = iDeltatype; - ((mng_ppltp)*ppChunk)->iCount = iMax; - - for (iY = 0; iY < 256; iY++) - { - ((mng_ppltp)*ppChunk)->aEntries [iY].iRed = aIndexentries [iY].iRed; - ((mng_ppltp)*ppChunk)->aEntries [iY].iGreen = aIndexentries [iY].iGreen; - ((mng_ppltp)*ppChunk)->aEntries [iY].iBlue = aIndexentries [iY].iBlue; - ((mng_ppltp)*ppChunk)->aEntries [iY].iAlpha = aAlphaentries [iY]; - ((mng_ppltp)*ppChunk)->aEntries [iY].bUsed = (mng_bool)(aUsedentries [iY]); - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_ijng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IJNG, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen != 0) /* gotta be empty */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode = create_ani_ijng (pData); - - if (!iRetcode) /* process it */ - iRetcode = process_display_ijng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_drop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DROP, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* check length */ - if ((iRawlen < 4) || ((iRawlen % 4) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_dropp)*ppChunk)->iCount = iRawlen / 4; - - if (iRawlen) - { - mng_uint32 iX; - mng_uint8p pTemp = pRawdata; - mng_uint32p pEntry; - - MNG_ALLOC (pData, pEntry, iRawlen) - - ((mng_dropp)*ppChunk)->pChunknames = (mng_ptr)pEntry; - - for (iX = 0; iX < iRawlen / 4; iX++) - { - *pEntry = mng_get_uint32 (pTemp); - - pTemp += 4; - pEntry++; - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DROP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_dbyk) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DBYK, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - - if (iRawlen < 6) /* must be at least 6 long */ - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_dbykp)*ppChunk)->iChunkname = mng_get_uint32 (pRawdata); - ((mng_dbykp)*ppChunk)->iPolarity = *(pRawdata+4); - ((mng_dbykp)*ppChunk)->iKeywordssize = iRawlen - 5; - - if (iRawlen > 5) - { - MNG_ALLOC (pData, ((mng_dbykp)*ppChunk)->zKeywords, iRawlen-4) - MNG_COPY (((mng_dbykp)*ppChunk)->zKeywords, pRawdata+5, iRawlen-5) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DBYK, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_ordr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ORDR, MNG_LC_START) -#endif - /* sequence checks */ - if ((!pData->bHasMHDR) || (!pData->bHasDHDR)) - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* check length */ - if ((iRawlen < 5) || ((iRawlen % 5) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - -#ifdef MNG_SUPPORT_DISPLAY - { - - - /* TODO: something !!! */ - - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_ordrp)*ppChunk)->iCount = iRawlen / 5; - - if (iRawlen) - { - mng_uint32 iX; - mng_ordr_entryp pEntry; - mng_uint8p pTemp = pRawdata; - - MNG_ALLOC (pData, pEntry, iRawlen) - - ((mng_ordrp)*ppChunk)->pEntries = pEntry; - - for (iX = 0; iX < iRawlen / 5; iX++) - { - pEntry->iChunkname = mng_get_uint32 (pTemp); - pEntry->iOrdertype = *(pTemp+4); - - pTemp += 5; - pEntry++; - } - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_ORDR, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_magn) -{ - mng_uint16 iFirstid, iLastid; - mng_uint16 iMethodX, iMethodY; - mng_uint16 iMX, iMY, iML, iMR, iMT, iMB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MAGN, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_SUPPORT_JNG - if ((!pData->bHasMHDR) || (pData->bHasIHDR) || (pData->bHasDHDR) || (pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) || (pData->bHasIHDR) || (pData->bHasDHDR)) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* check length */ - if ((iRawlen > 20) || ((iRawlen & 0x01) != 0)) - MNG_ERROR (pData, MNG_INVALIDLENGTH) - - if (iRawlen > 0) /* get the fields */ - iFirstid = mng_get_uint16 (pRawdata); - else - iFirstid = 0; - - if (iRawlen > 2) - iLastid = mng_get_uint16 (pRawdata+2); - else - iLastid = iFirstid; - - if (iRawlen > 4) - iMethodX = mng_get_uint16 (pRawdata+4); - else - iMethodX = 0; - - if (iRawlen > 6) - iMX = mng_get_uint16 (pRawdata+6); - else - iMX = 1; - - if (iRawlen > 8) - iMY = mng_get_uint16 (pRawdata+8); - else - iMY = iMX; - - if (iRawlen > 10) - iML = mng_get_uint16 (pRawdata+10); - else - iML = iMX; - - if (iRawlen > 12) - iMR = mng_get_uint16 (pRawdata+12); - else - iMR = iMX; - - if (iRawlen > 14) - iMT = mng_get_uint16 (pRawdata+14); - else - iMT = iMY; - - if (iRawlen > 16) - iMB = mng_get_uint16 (pRawdata+16); - else - iMB = iMY; - - if (iRawlen > 18) - iMethodY = mng_get_uint16 (pRawdata+18); - else - iMethodY = iMethodX; - /* check field validity */ - if ((iMethodX > 5) || (iMethodY > 5)) - MNG_ERROR (pData, MNG_INVALIDMETHOD) - -#ifdef MNG_SUPPORT_DISPLAY - { - mng_retcode iRetcode; - - iRetcode = create_ani_magn (pData, iFirstid, iLastid, iMethodX, - iMX, iMY, iML, iMR, iMT, iMB, iMethodY); - - if (!iRetcode) /* display processing ? */ - iRetcode = process_display_magn (pData, iFirstid, iLastid, iMethodX, - iMX, iMY, iML, iMR, iMT, iMB, iMethodY); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the fields */ - ((mng_magnp)*ppChunk)->iFirstid = iFirstid; - ((mng_magnp)*ppChunk)->iLastid = iLastid; - ((mng_magnp)*ppChunk)->iMethodX = iMethodX; - ((mng_magnp)*ppChunk)->iMX = iMX; - ((mng_magnp)*ppChunk)->iMY = iMY; - ((mng_magnp)*ppChunk)->iML = iML; - ((mng_magnp)*ppChunk)->iMR = iMR; - ((mng_magnp)*ppChunk)->iMT = iMT; - ((mng_magnp)*ppChunk)->iMB = iMB; - ((mng_magnp)*ppChunk)->iMethodY = iMethodY; - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -READ_CHUNK (read_unknown) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_UNKNOWN, MNG_LC_START) -#endif - /* sequence checks */ -#ifdef MNG_INCLUDE_JNG - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && - (!pData->bHasBASI) && (!pData->bHasDHDR) ) -#endif - MNG_ERROR (pData, MNG_SEQUENCEERROR) - /* critical chunk ? */ - if (((mng_uint32)pData->iChunkname & 0x20000000) == 0) - MNG_ERROR (pData, MNG_UNKNOWNCRITICAL) - - if (pData->fProcessunknown) /* let the app handle it ? */ - { - mng_bool bOke = pData->fProcessunknown ((mng_handle)pData, pData->iChunkname, - iRawlen, (mng_ptr)pRawdata); - - if (!bOke) - MNG_ERROR (pData, MNG_APPMISCERROR) - } - -#ifdef MNG_STORE_CHUNKS - if (pData->bStorechunks) - { /* initialize storage */ - mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* store the length */ - ((mng_chunk_headerp)*ppChunk)->iChunkname = pData->iChunkname; - ((mng_unknown_chunkp)*ppChunk)->iDatasize = iRawlen; - - if (iRawlen == 0) /* any data at all ? */ - ((mng_unknown_chunkp)*ppChunk)->pData = 0; - else - { /* then store it */ - MNG_ALLOC (pData, ((mng_unknown_chunkp)*ppChunk)->pData, iRawlen) - MNG_COPY (((mng_unknown_chunkp)*ppChunk)->pData, pRawdata, iRawlen) - } - } -#endif /* MNG_STORE_CHUNKS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_UNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_READ_PROCS */ - -/* ************************************************************************** */ -/* * * */ -/* * chunk write functions * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* ************************************************************************** */ - -WRITE_CHUNK (write_ihdr) -{ - mng_ihdrp pIHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IHDR, MNG_LC_START) -#endif - - pIHDR = (mng_ihdrp)pChunk; /* address the proper chunk */ - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 13; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pIHDR->iWidth); - mng_put_uint32 (pRawdata+4, pIHDR->iHeight); - - *(pRawdata+8) = pIHDR->iBitdepth; - *(pRawdata+9) = pIHDR->iColortype; - *(pRawdata+10) = pIHDR->iCompression; - *(pRawdata+11) = pIHDR->iFilter; - *(pRawdata+12) = pIHDR->iInterlace; - /* and write it */ - iRetcode = write_raw_chunk (pData, pIHDR->sHeader.iChunkname, iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IHDR, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_plte) -{ - mng_pltep pPLTE; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PLTE, MNG_LC_START) -#endif - - pPLTE = (mng_pltep)pChunk; /* address the proper chunk */ - - if (pPLTE->bEmpty) /* write empty chunk ? */ - iRetcode = write_raw_chunk (pData, pPLTE->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pPLTE->iEntrycount * 3; - /* fill the output buffer */ - pTemp = pRawdata; - - for (iX = 0; iX < pPLTE->iEntrycount; iX++) - { - *pTemp = pPLTE->aEntries [iX].iRed; - *(pTemp+1) = pPLTE->aEntries [iX].iGreen; - *(pTemp+2) = pPLTE->aEntries [iX].iBlue; - - pTemp += 3; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pPLTE->sHeader.iChunkname, iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PLTE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_idat) -{ - mng_idatp pIDAT; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IDAT, MNG_LC_START) -#endif - - pIDAT = (mng_idatp)pChunk; /* address the proper chunk */ - - if (pIDAT->bEmpty) /* and write it */ - iRetcode = write_raw_chunk (pData, pIDAT->sHeader.iChunkname, 0, 0); - else - iRetcode = write_raw_chunk (pData, pIDAT->sHeader.iChunkname, - pIDAT->iDatasize, pIDAT->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IDAT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_iend) -{ - mng_iendp pIEND; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IEND, MNG_LC_START) -#endif - - pIEND = (mng_iendp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pIEND->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IEND, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_trns) -{ - mng_trnsp pTRNS; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TRNS, MNG_LC_START) -#endif - - pTRNS = (mng_trnsp)pChunk; /* address the proper chunk */ - - if (pTRNS->bEmpty) /* write empty chunk ? */ - iRetcode = write_raw_chunk (pData, pTRNS->sHeader.iChunkname, 0, 0); - else - if (pTRNS->bGlobal) /* write global chunk ? */ - iRetcode = write_raw_chunk (pData, pTRNS->sHeader.iChunkname, - pTRNS->iRawlen, (mng_uint8p)pTRNS->aRawdata); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer */ - iRawlen = 0; /* and default size */ - - switch (pTRNS->iType) - { - case 0: { - iRawlen = 2; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pTRNS->iGray); - - break; - } - case 2: { - iRawlen = 6; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pTRNS->iRed); - mng_put_uint16 (pRawdata+2, pTRNS->iGreen); - mng_put_uint16 (pRawdata+4, pTRNS->iBlue); - - break; - } - case 3: { /* init output buffer size */ - iRawlen = pTRNS->iCount; - - pTemp = pRawdata; /* fill the output buffer */ - - for (iX = 0; iX < pTRNS->iCount; iX++) - { - *pTemp = pTRNS->aEntries[iX]; - pTemp++; - } - - break; - } - } - /* write the chunk */ - iRetcode = write_raw_chunk (pData, pTRNS->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TRNS, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_gama) -{ - mng_gamap pGAMA; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_GAMA, MNG_LC_START) -#endif - - pGAMA = (mng_gamap)pChunk; /* address the proper chunk */ - - if (pGAMA->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pGAMA->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 4; - /* fill the buffer */ - mng_put_uint32 (pRawdata, pGAMA->iGamma); - /* and write it */ - iRetcode = write_raw_chunk (pData, pGAMA->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_GAMA, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_chrm) -{ - mng_chrmp pCHRM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CHRM, MNG_LC_START) -#endif - - pCHRM = (mng_chrmp)pChunk; /* address the proper chunk */ - - if (pCHRM->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pCHRM->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 32; - /* fill the buffer */ - mng_put_uint32 (pRawdata, pCHRM->iWhitepointx); - mng_put_uint32 (pRawdata+4, pCHRM->iWhitepointy); - mng_put_uint32 (pRawdata+8, pCHRM->iRedx); - mng_put_uint32 (pRawdata+12, pCHRM->iRedy); - mng_put_uint32 (pRawdata+16, pCHRM->iGreenx); - mng_put_uint32 (pRawdata+20, pCHRM->iGreeny); - mng_put_uint32 (pRawdata+24, pCHRM->iBluex); - mng_put_uint32 (pRawdata+28, pCHRM->iBluey); - /* and write it */ - iRetcode = write_raw_chunk (pData, pCHRM->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CHRM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_srgb) -{ - mng_srgbp pSRGB; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SRGB, MNG_LC_START) -#endif - - pSRGB = (mng_srgbp)pChunk; /* address the proper chunk */ - - if (pSRGB->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pSRGB->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - /* fill the buffer */ - *pRawdata = pSRGB->iRenderingintent; - /* and write it */ - iRetcode = write_raw_chunk (pData, pSRGB->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SRGB, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_iccp) -{ - mng_iccpp pICCP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint8p pBuf = 0; - mng_uint32 iBuflen; - mng_uint32 iReallen; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ICCP, MNG_LC_START) -#endif - - pICCP = (mng_iccpp)pChunk; /* address the proper chunk */ - - if (pICCP->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pICCP->sHeader.iChunkname, 0, 0); - else - { /* compress the profile */ - iRetcode = deflate_buffer (pData, pICCP->pProfile, pICCP->iProfilesize, - &pBuf, &iBuflen, &iReallen); - - if (!iRetcode) /* still oke ? */ - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pICCP->iNamesize + 2 + iReallen; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - - pTemp = pRawdata; /* fill the buffer */ - - if (pICCP->iNamesize) - { - MNG_COPY (pTemp, pICCP->zName, pICCP->iNamesize) - pTemp += pICCP->iNamesize; - } - - *pTemp = 0; - *(pTemp+1) = pICCP->iCompression; - pTemp += 2; - - if (iReallen) - MNG_COPY (pTemp, pBuf, iReallen) - /* and write it */ - iRetcode = write_raw_chunk (pData, pICCP->sHeader.iChunkname, - iRawlen, pRawdata); - /* drop the temp buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen) - - } - - MNG_FREEX (pData, pBuf, iBuflen) /* always drop the extra buffer */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ICCP, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_text) -{ - mng_textp pTEXT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TEXT, MNG_LC_START) -#endif - - pTEXT = (mng_textp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pTEXT->iKeywordsize + 1 + pTEXT->iTextsize; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - - pTemp = pRawdata; /* fill the buffer */ - - if (pTEXT->iKeywordsize) - { - MNG_COPY (pTemp, pTEXT->zKeyword, pTEXT->iKeywordsize) - pTemp += pTEXT->iKeywordsize; - } - - *pTemp = 0; - pTemp += 1; - - if (pTEXT->iTextsize) - MNG_COPY (pTemp, pTEXT->zText, pTEXT->iTextsize) - /* and write it */ - iRetcode = write_raw_chunk (pData, pTEXT->sHeader.iChunkname, - iRawlen, pRawdata); - - if (iRawlen > pData->iWritebufsize) /* drop the temp buffer ? */ - MNG_FREEX (pData, pRawdata, iRawlen) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TEXT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_ztxt) -{ - mng_ztxtp pZTXT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint8p pBuf = 0; - mng_uint32 iBuflen; - mng_uint32 iReallen; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ZTXT, MNG_LC_START) -#endif - - pZTXT = (mng_ztxtp)pChunk; /* address the proper chunk */ - /* compress the text */ - iRetcode = deflate_buffer (pData, (mng_uint8p)pZTXT->zText, pZTXT->iTextsize, - &pBuf, &iBuflen, &iReallen); - - if (!iRetcode) /* all ok ? */ - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pZTXT->iKeywordsize + 2 + iReallen; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - - pTemp = pRawdata; /* fill the buffer */ - - if (pZTXT->iKeywordsize) - { - MNG_COPY (pTemp, pZTXT->zKeyword, pZTXT->iKeywordsize) - pTemp += pZTXT->iKeywordsize; - } - - *pTemp = 0; /* terminator zero */ - pTemp++; - *pTemp = 0; /* compression type */ - pTemp++; - - if (iReallen) - MNG_COPY (pTemp, pBuf, iReallen) - /* and write it */ - iRetcode = write_raw_chunk (pData, pZTXT->sHeader.iChunkname, - iRawlen, pRawdata); - /* drop the temp buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen) - - } - - MNG_FREEX (pData, pBuf, iBuflen); /* always drop the compression buffer */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ZTXT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_itxt) -{ - mng_itxtp pITXT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint8p pBuf = 0; - mng_uint32 iBuflen; - mng_uint32 iReallen; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ITXT, MNG_LC_START) -#endif - - pITXT = (mng_itxtp)pChunk; /* address the proper chunk */ - - if (pITXT->iCompressionflag) /* compress the text */ - iRetcode = deflate_buffer (pData, (mng_uint8p)pITXT->zText, pITXT->iTextsize, - &pBuf, &iBuflen, &iReallen); - else - iRetcode = MNG_NOERROR; - - if (!iRetcode) /* all ok ? */ - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pITXT->iKeywordsize + pITXT->iLanguagesize + - pITXT->iTranslationsize + 5; - - if (pITXT->iCompressionflag) - iRawlen = iRawlen + iReallen; - else - iRawlen = iRawlen + pITXT->iTextsize; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - - pTemp = pRawdata; /* fill the buffer */ - - if (pITXT->iKeywordsize) - { - MNG_COPY (pTemp, pITXT->zKeyword, pITXT->iKeywordsize) - pTemp += pITXT->iKeywordsize; - } - - *pTemp = 0; - pTemp++; - *pTemp = pITXT->iCompressionflag; - pTemp++; - *pTemp = pITXT->iCompressionmethod; - pTemp++; - - if (pITXT->iLanguagesize) - { - MNG_COPY (pTemp, pITXT->zLanguage, pITXT->iLanguagesize) - pTemp += pITXT->iLanguagesize; - } - - *pTemp = 0; - pTemp++; - - if (pITXT->iTranslationsize) - { - MNG_COPY (pTemp, pITXT->zTranslation, pITXT->iTranslationsize) - pTemp += pITXT->iTranslationsize; - } - - *pTemp = 0; - pTemp++; - - if (pITXT->iCompressionflag) - { - if (iReallen) - MNG_COPY (pTemp, pBuf, iReallen) - } - else - { - if (pITXT->iTextsize) - MNG_COPY (pTemp, pITXT->zText, pITXT->iTextsize) - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pITXT->sHeader.iChunkname, - iRawlen, pRawdata); - /* drop the temp buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen) - - } - - MNG_FREEX (pData, pBuf, iBuflen); /* always drop the compression buffer */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_bkgd) -{ - mng_bkgdp pBKGD; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BKGD, MNG_LC_START) -#endif - - pBKGD = (mng_bkgdp)pChunk; /* address the proper chunk */ - - if (pBKGD->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pBKGD->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 0; /* and default size */ - - switch (pBKGD->iType) - { - case 0: { /* gray */ - iRawlen = 2; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pBKGD->iGray); - - break; - } - case 2: { /* rgb */ - iRawlen = 6; /* fill the size & output buffer */ - mng_put_uint16 (pRawdata, pBKGD->iRed); - mng_put_uint16 (pRawdata+2, pBKGD->iGreen); - mng_put_uint16 (pRawdata+4, pBKGD->iBlue); - - break; - } - case 3: { /* indexed */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pBKGD->iIndex; - - break; - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pBKGD->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BKGD, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_phys) -{ - mng_physp pPHYS; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYS, MNG_LC_START) -#endif - - pPHYS = (mng_physp)pChunk; /* address the proper chunk */ - - if (pPHYS->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pPHYS->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 9; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pPHYS->iSizex); - mng_put_uint32 (pRawdata+4, pPHYS->iSizey); - - *(pRawdata+8) = pPHYS->iUnit; - /* and write it */ - iRetcode = write_raw_chunk (pData, pPHYS->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYS, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_sbit) -{ - mng_sbitp pSBIT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SBIT, MNG_LC_START) -#endif - - pSBIT = (mng_sbitp)pChunk; /* address the proper chunk */ - - if (pSBIT->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pSBIT->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 0; /* and default size */ - - switch (pSBIT->iType) - { - case 0: { /* gray */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - - break; - } - case 2: { /* rgb */ - iRawlen = 3; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - - break; - } - case 3: { /* indexed */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - - break; - } - case 4: { /* gray + alpha */ - iRawlen = 2; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - - break; - } - case 6: { /* rgb + alpha */ - iRawlen = 4; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - *(pRawdata+3) = pSBIT->aBits[3]; - - break; - } - case 10: { /* jpeg gray */ - iRawlen = 1; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - - break; - } - case 12: { /* jpeg rgb */ - iRawlen = 3; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - - break; - } - case 14: { /* jpeg gray + alpha */ - iRawlen = 2; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - - break; - } - case 16: { /* jpeg rgb + alpha */ - iRawlen = 4; /* fill the size & output buffer */ - *pRawdata = pSBIT->aBits[0]; - *(pRawdata+1) = pSBIT->aBits[1]; - *(pRawdata+2) = pSBIT->aBits[2]; - *(pRawdata+3) = pSBIT->aBits[3]; - - break; - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pSBIT->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SBIT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_splt) -{ - mng_spltp pSPLT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint32 iEntrieslen; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SPLT, MNG_LC_START) -#endif - - pSPLT = (mng_spltp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iEntrieslen = ((pSPLT->iSampledepth >> 3) * 4 + 2) * pSPLT->iEntrycount; - iRawlen = pSPLT->iNamesize + 2 + iEntrieslen; - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - - pTemp = pRawdata; /* fill the buffer */ - - if (pSPLT->iNamesize) - { - MNG_COPY (pTemp, pSPLT->zName, pSPLT->iNamesize) - pTemp += pSPLT->iNamesize; - } - - *pTemp = 0; - *(pTemp+1) = pSPLT->iSampledepth; - pTemp += 2; - - if (pSPLT->iEntrycount) - MNG_COPY (pTemp, pSPLT->pEntries, iEntrieslen) - /* and write it */ - iRetcode = write_raw_chunk (pData, pSPLT->sHeader.iChunkname, - iRawlen, pRawdata); - - if (iRawlen > pData->iWritebufsize) /* drop the temp buffer ? */ - MNG_FREEX (pData, pRawdata, iRawlen) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SPLT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_hist) -{ - mng_histp pHIST; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_HIST, MNG_LC_START) -#endif - - pHIST = (mng_histp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pHIST->iEntrycount << 1; - - pTemp = pRawdata; /* fill the output buffer */ - - for (iX = 0; iX < pHIST->iEntrycount; iX++) - { - mng_put_uint16 (pTemp, pHIST->aEntries [iX]); - pTemp += 2; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pHIST->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_HIST, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_time) -{ - mng_timep pTIME; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TIME, MNG_LC_START) -#endif - - pTIME = (mng_timep)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 7; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pTIME->iYear); - - *(pRawdata+2) = pTIME->iMonth; - *(pRawdata+3) = pTIME->iDay; - *(pRawdata+4) = pTIME->iHour; - *(pRawdata+5) = pTIME->iMinute; - *(pRawdata+6) = pTIME->iSecond; - /* and write it */ - iRetcode = write_raw_chunk (pData, pTIME->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TIME, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_mhdr) -{ - mng_mhdrp pMHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MHDR, MNG_LC_START) -#endif - - pMHDR = (mng_mhdrp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 28; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pMHDR->iWidth); - mng_put_uint32 (pRawdata+4, pMHDR->iHeight); - mng_put_uint32 (pRawdata+8, pMHDR->iTicks); - mng_put_uint32 (pRawdata+12, pMHDR->iLayercount); - mng_put_uint32 (pRawdata+16, pMHDR->iFramecount); - mng_put_uint32 (pRawdata+20, pMHDR->iPlaytime); - mng_put_uint32 (pRawdata+24, pMHDR->iSimplicity); - - /* and write it */ - iRetcode = write_raw_chunk (pData, pMHDR->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MHDR, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_mend) -{ - mng_mendp pMEND; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MEND, MNG_LC_START) -#endif - - pMEND = (mng_mendp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pMEND->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MEND, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_loop) -{ - mng_loopp pLOOP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp1; - mng_uint32p pTemp2; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_LOOP, MNG_LC_START) -#endif - - pLOOP = (mng_loopp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 5; - /* fill the output buffer */ - *pRawdata = pLOOP->iLevel; - mng_put_uint32 (pRawdata+1, pLOOP->iRepeat); - - if (pLOOP->iTermination) - { - iRawlen++; - *(pRawdata+5) = pLOOP->iTermination; - - if ((pLOOP->iCount) || - (pLOOP->iItermin != 1) || (pLOOP->iItermax != 0x7FFFFFFFL)) - { - iRawlen += 8; - - mng_put_uint32 (pRawdata+6, pLOOP->iItermin); - mng_put_uint32 (pRawdata+10, pLOOP->iItermax); - - if (pLOOP->iCount) - { - iRawlen += pLOOP->iCount * 4; - - pTemp1 = pRawdata+14; - pTemp2 = pLOOP->pSignals; - - for (iX = 0; iX < pLOOP->iCount; iX++) - { - mng_put_uint32 (pTemp1, *pTemp2); - - pTemp1 += 4; - pTemp2++; - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pLOOP->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_LOOP, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_endl) -{ - mng_endlp pENDL; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ENDL, MNG_LC_START) -#endif - - pENDL = (mng_endlp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pENDL->iLevel; /* fill the output buffer */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pENDL->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ENDL, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_defi) -{ - mng_defip pDEFI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DEFI, MNG_LC_START) -#endif - - pDEFI = (mng_defip)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pDEFI->iObjectid); - - if ((pDEFI->iDonotshow) || (pDEFI->iConcrete) || (pDEFI->bHasloca) || (pDEFI->bHasclip)) - { - iRawlen++; - *(pRawdata+2) = pDEFI->iDonotshow; - - if ((pDEFI->iConcrete) || (pDEFI->bHasloca) || (pDEFI->bHasclip)) - { - iRawlen++; - *(pRawdata+3) = pDEFI->iConcrete; - - if ((pDEFI->bHasloca) || (pDEFI->bHasclip)) - { - iRawlen += 8; - - mng_put_uint32 (pRawdata+4, pDEFI->iXlocation); - mng_put_uint32 (pRawdata+8, pDEFI->iYlocation); - - if (pDEFI->bHasclip) - { - iRawlen += 16; - - mng_put_uint32 (pRawdata+12, pDEFI->iLeftcb); - mng_put_uint32 (pRawdata+16, pDEFI->iRightcb); - mng_put_uint32 (pRawdata+20, pDEFI->iTopcb); - mng_put_uint32 (pRawdata+24, pDEFI->iBottomcb); - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDEFI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DEFI, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_basi) -{ - mng_basip pBASI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_bool bOpaque; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BASI, MNG_LC_START) -#endif - - pBASI = (mng_basip)pChunk; /* address the proper chunk */ - - if (pBASI->iBitdepth <= 8) /* determine opacity alpha-field */ - bOpaque = (mng_bool)(pBASI->iAlpha == 0xFF); - else - bOpaque = (mng_bool)(pBASI->iAlpha == 0xFFFF); - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 13; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pBASI->iWidth); - mng_put_uint32 (pRawdata+4, pBASI->iHeight); - - *(pRawdata+8) = pBASI->iBitdepth; - *(pRawdata+9) = pBASI->iColortype; - *(pRawdata+10) = pBASI->iCompression; - *(pRawdata+11) = pBASI->iFilter; - *(pRawdata+12) = pBASI->iInterlace; - - if ((pBASI->iRed) || (pBASI->iGreen) || (pBASI->iBlue) || - (!bOpaque) || (pBASI->iViewable)) - { - iRawlen += 6; - mng_put_uint16 (pRawdata+13, pBASI->iRed); - mng_put_uint16 (pRawdata+15, pBASI->iGreen); - mng_put_uint16 (pRawdata+17, pBASI->iBlue); - - if ((!bOpaque) || (pBASI->iViewable)) - { - iRawlen += 2; - mng_put_uint16 (pRawdata+19, pBASI->iAlpha); - - if (pBASI->iViewable) - { - iRawlen++; - *(pRawdata+21) = pBASI->iViewable; - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pBASI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BASI, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_clon) -{ - mng_clonp pCLON; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLON, MNG_LC_START) -#endif - - pCLON = (mng_clonp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 4; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pCLON->iSourceid); - mng_put_uint16 (pRawdata+2, pCLON->iCloneid); - - if ((pCLON->iClonetype) || (pCLON->iDonotshow) || (pCLON->iConcrete) || (pCLON->bHasloca)) - { - iRawlen++; - *(pRawdata+4) = pCLON->iClonetype; - - if ((pCLON->iDonotshow) || (pCLON->iConcrete) || (pCLON->bHasloca)) - { - iRawlen++; - *(pRawdata+5) = pCLON->iDonotshow; - - if ((pCLON->iConcrete) || (pCLON->bHasloca)) - { - iRawlen++; - *(pRawdata+6) = pCLON->iConcrete; - - if (pCLON->bHasloca) - { - iRawlen += 9; - *(pRawdata+7) = pCLON->iLocationtype; - mng_put_int32 (pRawdata+8, pCLON->iLocationx); - mng_put_int32 (pRawdata+12, pCLON->iLocationy); - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pCLON->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLON, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_past) -{ - mng_pastp pPAST; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_past_sourcep pSource; - mng_uint32 iX; - mng_uint8p pTemp; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PAST, MNG_LC_START) -#endif - - pPAST = (mng_pastp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 11 + (30 * pPAST->iCount); - /* requires large buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_ALLOC (pData, pRawdata, iRawlen) - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pPAST->iDestid); - - *(pRawdata+2) = pPAST->iTargettype; - - mng_put_int32 (pRawdata+3, pPAST->iTargetx); - mng_put_int32 (pRawdata+7, pPAST->iTargety); - - pTemp = pRawdata+11; - pSource = pPAST->pSources; - - for (iX = 0; iX < pPAST->iCount; iX++) - { - mng_put_uint16 (pTemp, pSource->iSourceid); - - *(pTemp+2) = pSource->iComposition; - *(pTemp+3) = pSource->iOrientation; - *(pTemp+4) = pSource->iOffsettype; - - mng_put_int32 (pTemp+5, pSource->iOffsetx); - mng_put_int32 (pTemp+9, pSource->iOffsety); - - *(pTemp+13) = pSource->iBoundarytype; - - mng_put_int32 (pTemp+14, pSource->iBoundaryl); - mng_put_int32 (pTemp+18, pSource->iBoundaryr); - mng_put_int32 (pTemp+22, pSource->iBoundaryt); - mng_put_int32 (pTemp+26, pSource->iBoundaryb); - - pSource++; - pTemp += 30; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pPAST->sHeader.iChunkname, - iRawlen, pRawdata); - /* free temporary buffer ? */ - if (iRawlen > pData->iWritebufsize) - MNG_FREEX (pData, pRawdata, iRawlen) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PAST, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_disc) -{ - mng_discp pDISC; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint32 iX; - mng_uint8p pTemp1; - mng_uint16p pTemp2; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DISC, MNG_LC_START) -#endif - - pDISC = (mng_discp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pDISC->iCount << 1; - - pTemp1 = pRawdata; /* fill the output buffer */ - pTemp2 = pDISC->pObjectids; - - for (iX = 0; iX < pDISC->iCount; iX++) - { - mng_put_uint16 (pTemp1, *pTemp2); - - pTemp2++; - pTemp1 += 2; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDISC->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DISC, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_back) -{ - mng_backp pBACK; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BACK, MNG_LC_START) -#endif - - pBACK = (mng_backp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 6; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pBACK->iRed); - mng_put_uint16 (pRawdata+2, pBACK->iGreen); - mng_put_uint16 (pRawdata+4, pBACK->iBlue); - - if ((pBACK->iMandatory) || (pBACK->iImageid) || (pBACK->iTile)) - { - iRawlen++; - *(pRawdata+6) = pBACK->iMandatory; - - if ((pBACK->iImageid) || (pBACK->iTile)) - { - iRawlen += 2; - mng_put_uint16 (pRawdata+7, pBACK->iImageid); - - if (pBACK->iTile) - { - iRawlen++; - *(pRawdata+9) = pBACK->iTile; - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pBACK->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_BACK, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_fram) -{ - mng_framp pFRAM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_uint32p pTemp2; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FRAM, MNG_LC_START) -#endif - - pFRAM = (mng_framp)pChunk; /* address the proper chunk */ - - if (pFRAM->bEmpty) /* empty ? */ - iRetcode = write_raw_chunk (pData, pFRAM->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - /* fill the output buffer */ - *pRawdata = pFRAM->iMode; - - if ((pFRAM->iNamesize ) || - (pFRAM->iChangedelay ) || (pFRAM->iChangetimeout) || - (pFRAM->iChangeclipping) || (pFRAM->iChangesyncid ) ) - { - if (pFRAM->iNamesize) - MNG_COPY (pRawdata+1, pFRAM->zName, pFRAM->iNamesize) - - iRawlen += pFRAM->iNamesize; - pTemp = pRawdata + pFRAM->iNamesize + 1; - - if ((pFRAM->iChangedelay ) || (pFRAM->iChangetimeout) || - (pFRAM->iChangeclipping) || (pFRAM->iChangesyncid ) ) - { - *pTemp = 0; - *(pTemp+1) = pFRAM->iChangedelay; - *(pTemp+2) = pFRAM->iChangetimeout; - *(pTemp+3) = pFRAM->iChangeclipping; - *(pTemp+4) = pFRAM->iChangesyncid; - - iRawlen += 5; - pTemp += 5; - - if (pFRAM->iChangedelay) - { - mng_put_uint32 (pTemp, pFRAM->iDelay); - iRawlen += 4; - pTemp += 4; - } - - if (pFRAM->iChangetimeout) - { - mng_put_uint32 (pTemp, pFRAM->iTimeout); - iRawlen += 4; - pTemp += 4; - } - - if (pFRAM->iChangeclipping) - { - *pTemp = pFRAM->iBoundarytype; - - mng_put_uint32 (pTemp+1, pFRAM->iBoundaryl); - mng_put_uint32 (pTemp+5, pFRAM->iBoundaryr); - mng_put_uint32 (pTemp+9, pFRAM->iBoundaryt); - mng_put_uint32 (pTemp+13, pFRAM->iBoundaryb); - - iRawlen += 17; - pTemp += 17; - } - - if (pFRAM->iChangesyncid) - { - iRawlen += pFRAM->iCount * 4; - pTemp2 = pFRAM->pSyncids; - - for (iX = 0; iX < pFRAM->iCount; iX++) - { - mng_put_uint32 (pTemp, *pTemp2); - - pTemp2++; - pTemp += 4; - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pFRAM->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FRAM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_move) -{ - mng_movep pMOVE; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MOVE, MNG_LC_START) -#endif - - pMOVE = (mng_movep)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 13; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pMOVE->iFirstid); - mng_put_uint16 (pRawdata+2, pMOVE->iLastid); - - *(pRawdata+4) = pMOVE->iMovetype; - - mng_put_int32 (pRawdata+5, pMOVE->iMovex); - mng_put_int32 (pRawdata+9, pMOVE->iMovey); - /* and write it */ - iRetcode = write_raw_chunk (pData, pMOVE->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MOVE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_clip) -{ - mng_clipp pCLIP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLIP, MNG_LC_START) -#endif - - pCLIP = (mng_clipp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 21; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pCLIP->iFirstid); - mng_put_uint16 (pRawdata+2, pCLIP->iLastid); - - *(pRawdata+4) = pCLIP->iCliptype; - - mng_put_int32 (pRawdata+5, pCLIP->iClipl); - mng_put_int32 (pRawdata+9, pCLIP->iClipr); - mng_put_int32 (pRawdata+13, pCLIP->iClipt); - mng_put_int32 (pRawdata+17, pCLIP->iClipb); - /* and write it */ - iRetcode = write_raw_chunk (pData, pCLIP->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_CLIP, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_show) -{ - mng_showp pSHOW; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SHOW, MNG_LC_START) -#endif - - pSHOW = (mng_showp)pChunk; /* address the proper chunk */ - - if (pSHOW->bEmpty) /* empty ? */ - iRetcode = write_raw_chunk (pData, pSHOW->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pSHOW->iFirstid); - - if ((pSHOW->iLastid != pSHOW->iFirstid) || (pSHOW->iMode)) - { - iRawlen += 2; - mng_put_uint16 (pRawdata+2, pSHOW->iLastid); - - if (pSHOW->iMode) - { - iRawlen++; - *(pRawdata+4) = pSHOW->iMode; - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pSHOW->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SHOW, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_term) -{ - mng_termp pTERM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TERM, MNG_LC_START) -#endif - - pTERM = (mng_termp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pTERM->iTermaction; /* fill the output buffer */ - - if (pTERM->iTermaction == 3) - { - iRawlen = 10; - *(pRawdata+1) = pTERM->iIteraction; - - mng_put_uint32 (pRawdata+2, pTERM->iDelay); - mng_put_uint32 (pRawdata+6, pTERM->iItermax); - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pTERM->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_TERM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_save) -{ - mng_savep pSAVE; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_save_entryp pEntry; - mng_uint32 iEntrysize; - mng_uint8p pTemp; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SAVE, MNG_LC_START) -#endif - - pSAVE = (mng_savep)pChunk; /* address the proper chunk */ - - if (pSAVE->bEmpty) /* empty ? */ - iRetcode = write_raw_chunk (pData, pSAVE->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pSAVE->iOffsettype; /* fill the output buffer */ - - if (pSAVE->iOffsettype == 16) - iEntrysize = 25; - else - iEntrysize = 17; - - pTemp = pRawdata+1; - pEntry = pSAVE->pEntries; - - for (iX = 0; iX < pSAVE->iCount; iX++) - { - if (iX) /* put separator null-byte, except the first */ - { - *pTemp = 0; - pTemp++; - iRawlen++; - } - - iRawlen += iEntrysize + pEntry->iNamesize; - *pTemp = pEntry->iEntrytype; - - if (pSAVE->iOffsettype == 16) - { - mng_put_uint32 (pTemp+1, pEntry->iOffset[0]); - mng_put_uint32 (pTemp+5, pEntry->iOffset[1]); - mng_put_uint32 (pTemp+9, pEntry->iStarttime[0]); - mng_put_uint32 (pTemp+13, pEntry->iStarttime[1]); - mng_put_uint32 (pTemp+17, pEntry->iLayernr); - mng_put_uint32 (pTemp+21, pEntry->iFramenr); - - pTemp += 25; - } - else - { - mng_put_uint32 (pTemp+1, pEntry->iOffset[1]); - mng_put_uint32 (pTemp+5, pEntry->iStarttime[1]); - mng_put_uint32 (pTemp+9, pEntry->iLayernr); - mng_put_uint32 (pTemp+13, pEntry->iFramenr); - - pTemp += 17; - } - - if (pEntry->iNamesize) - { - MNG_COPY (pTemp, pEntry->zName, pEntry->iNamesize); - pTemp += pEntry->iNamesize; - } - - pEntry++; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pSAVE->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SAVE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_seek) -{ - mng_seekp pSEEK; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SEEK, MNG_LC_START) -#endif - - pSEEK = (mng_seekp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pSEEK->iNamesize; - - if (iRawlen) /* fill the output buffer */ - MNG_COPY (pRawdata, pSEEK->zName, iRawlen) - /* and write it */ - iRetcode = write_raw_chunk (pData, pSEEK->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_SEEK, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_expi) -{ - mng_expip pEXPI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_EXPI, MNG_LC_START) -#endif - - pEXPI = (mng_expip)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2 + pEXPI->iNamesize; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pEXPI->iSnapshotid); - - if (pEXPI->iNamesize) - MNG_COPY (pRawdata+2, pEXPI->zName, pEXPI->iNamesize) - /* and write it */ - iRetcode = write_raw_chunk (pData, pEXPI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_EXPI, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_fpri) -{ - mng_fprip pFPRI; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FPRI, MNG_LC_START) -#endif - - pFPRI = (mng_fprip)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 2; - - *pRawdata = pFPRI->iDeltatype; /* fill the output buffer */ - *(pRawdata+1) = pFPRI->iPriority; - /* and write it */ - iRetcode = write_raw_chunk (pData, pFPRI->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_FPRI, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_need) -{ - mng_needp pNEED; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_NEED, MNG_LC_START) -#endif - - pNEED = (mng_needp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pNEED->iKeywordssize; - /* fill the output buffer */ - if (pNEED->iKeywordssize) - MNG_COPY (pRawdata, pNEED->zKeywords, pNEED->iKeywordssize) - /* and write it */ - iRetcode = write_raw_chunk (pData, pNEED->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_NEED, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_phyg) -{ - mng_phygp pPHYG; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYG, MNG_LC_START) -#endif - - pPHYG = (mng_phygp)pChunk; /* address the proper chunk */ - - if (pPHYG->bEmpty) /* write empty ? */ - iRetcode = write_raw_chunk (pData, pPHYG->sHeader.iChunkname, 0, 0); - else - { - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 9; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pPHYG->iSizex); - mng_put_uint32 (pRawdata+4, pPHYG->iSizey); - - *(pRawdata+8) = pPHYG->iUnit; - /* and write it */ - iRetcode = write_raw_chunk (pData, pPHYG->sHeader.iChunkname, - iRawlen, pRawdata); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PHYG, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -WRITE_CHUNK (write_jhdr) -{ - mng_jhdrp pJHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JHDR, MNG_LC_START) -#endif - - pJHDR = (mng_jhdrp)pChunk; /* address the proper chunk */ - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 16; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pJHDR->iWidth); - mng_put_uint32 (pRawdata+4, pJHDR->iHeight); - - *(pRawdata+8) = pJHDR->iColortype; - *(pRawdata+9) = pJHDR->iImagesampledepth; - *(pRawdata+10) = pJHDR->iImagecompression; - *(pRawdata+11) = pJHDR->iImageinterlace; - *(pRawdata+12) = pJHDR->iAlphasampledepth; - *(pRawdata+13) = pJHDR->iAlphacompression; - *(pRawdata+14) = pJHDR->iAlphafilter; - *(pRawdata+15) = pJHDR->iAlphainterlace; - /* and write it */ - iRetcode = write_raw_chunk (pData, pJHDR->sHeader.iChunkname, iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JHDR, MNG_LC_END) -#endif - - return iRetcode; -} -#else -#define write_jhdr 0 -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -WRITE_CHUNK (write_jdaa) -{ - mng_jdatp pJDAA; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAA, MNG_LC_START) -#endif - - pJDAA = (mng_jdaap)pChunk; /* address the proper chunk */ - - if (pJDAA->bEmpty) /* and write it */ - iRetcode = write_raw_chunk (pData, pJDAA->sHeader.iChunkname, 0, 0); - else - iRetcode = write_raw_chunk (pData, pJDAA->sHeader.iChunkname, - pJDAA->iDatasize, pJDAA->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAA, MNG_LC_END) -#endif - - return iRetcode; -} -#else -#define write_jdaa 0 -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -WRITE_CHUNK (write_jdat) -{ - mng_jdatp pJDAT; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAT, MNG_LC_START) -#endif - - pJDAT = (mng_jdatp)pChunk; /* address the proper chunk */ - - if (pJDAT->bEmpty) /* and write it */ - iRetcode = write_raw_chunk (pData, pJDAT->sHeader.iChunkname, 0, 0); - else - iRetcode = write_raw_chunk (pData, pJDAT->sHeader.iChunkname, - pJDAT->iDatasize, pJDAT->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JDAT, MNG_LC_END) -#endif - - return iRetcode; -} -#else -#define write_jdat 0 -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ - -/* ************************************************************************** */ - -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -WRITE_CHUNK (write_jsep) -{ - mng_jsepp pJSEP; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JSEP, MNG_LC_START) -#endif - - pJSEP = (mng_jsepp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pJSEP->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_JSEP, MNG_LC_END) -#endif - - return iRetcode; -} -#else -#define write_jsep 0 -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ - -/* ************************************************************************** */ - -WRITE_CHUNK (write_dhdr) -{ - mng_dhdrp pDHDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DHDR, MNG_LC_START) -#endif - - pDHDR = (mng_dhdrp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 4; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pDHDR->iObjectid); - - *(pRawdata+2) = pDHDR->iImagetype; - *(pRawdata+3) = pDHDR->iDeltatype; - - if (pDHDR->iDeltatype != 7) - { - iRawlen += 8; - mng_put_uint32 (pRawdata+4, pDHDR->iBlockwidth); - mng_put_uint32 (pRawdata+8, pDHDR->iBlockheight); - - if (pDHDR->iDeltatype != 0) - { - iRawlen += 8; - mng_put_uint32 (pRawdata+12, pDHDR->iBlockx); - mng_put_uint32 (pRawdata+16, pDHDR->iBlocky); - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDHDR->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DHDR, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_prom) -{ - mng_promp pPROM; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PROM, MNG_LC_START) -#endif - - pPROM = (mng_promp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 3; - - *pRawdata = pPROM->iColortype; /* fill the output buffer */ - *(pRawdata+1) = pPROM->iSampledepth; - *(pRawdata+2) = pPROM->iFilltype; - /* and write it */ - iRetcode = write_raw_chunk (pData, pPROM->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PROM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_ipng) -{ - mng_ipngp pIPNG; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IPNG, MNG_LC_START) -#endif - - pIPNG = (mng_ipngp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pIPNG->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IPNG, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_pplt) -{ - mng_ppltp pPPLT; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_pplt_entryp pEntry; - mng_uint8p pTemp; - mng_uint32 iX; - mng_bool bHasgroup; - mng_uint8p pLastid = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PPLT, MNG_LC_START) -#endif - - pPPLT = (mng_ppltp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 1; - - *pRawdata = pPPLT->iDeltatype; /* fill the output buffer */ - - pTemp = pRawdata+1; - bHasgroup = MNG_FALSE; - - for (iX = 0; iX < pPPLT->iCount; iX++) - { - pEntry = &pPPLT->aEntries[iX]; - - if (pEntry->bUsed) /* valid entry ? */ - { - if (!bHasgroup) /* start a new group ? */ - { - bHasgroup = MNG_TRUE; - pLastid = pTemp+1; - - *pTemp = (mng_uint8)iX; - *(pTemp+1) = 0; - - pTemp += 2; - } - - switch (pPPLT->iDeltatype) /* add group-entry depending on type */ - { - case 0: ; - case 1: { - *pTemp = pEntry->iRed; - *(pTemp+1) = pEntry->iGreen; - *(pTemp+2) = pEntry->iBlue; - - pTemp += 3; - - break; - } - - case 2: ; - case 3: { - *pTemp = pEntry->iAlpha; - - pTemp++; - - break; - } - - case 4: ; - case 5: { - *pTemp = pEntry->iRed; - *(pTemp+1) = pEntry->iGreen; - *(pTemp+2) = pEntry->iBlue; - *(pTemp+3) = pEntry->iAlpha; - - pTemp += 4; - - break; - } - - } - } - else - { - if (bHasgroup) /* finish off a group ? */ - *pLastid = (mng_uint8)(iX-1); - - bHasgroup = MNG_FALSE; - } - } - - if (bHasgroup) /* last group unfinished ? */ - *pLastid = (mng_uint8)(pPPLT->iCount-1); - /* write the output buffer */ - iRetcode = write_raw_chunk (pData, pPPLT->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_PPLT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_ijng) -{ - mng_ijngp pIJNG; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IJNG, MNG_LC_START) -#endif - - pIJNG = (mng_ijngp)pChunk; /* address the proper chunk */ - /* and write it */ - iRetcode = write_raw_chunk (pData, pIJNG->sHeader.iChunkname, 0, 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_IJNG, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_drop) -{ - mng_dropp pDROP; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint32 iX; - mng_uint8p pTemp1; - mng_chunkidp pTemp2; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DROP, MNG_LC_START) -#endif - - pDROP = (mng_dropp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pDROP->iCount << 2; - - pTemp1 = pRawdata; /* fill the output buffer */ - pTemp2 = pDROP->pChunknames; - - for (iX = 0; iX < pDROP->iCount; iX++) - { - mng_put_uint32 (pTemp1, (mng_uint32)*pTemp2); - - pTemp2++; - pTemp1 += 4; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pDROP->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DROP, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_dbyk) -{ - mng_dbykp pDBYK; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DBYK, MNG_LC_START) -#endif - - pDBYK = (mng_dbykp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 5 + pDBYK->iKeywordssize; - /* fill the output buffer */ - mng_put_uint32 (pRawdata, pDBYK->iChunkname); - *(pRawdata+4) = pDBYK->iPolarity; - - if (pDBYK->iKeywordssize) - MNG_COPY (pRawdata+5, pDBYK->zKeywords, pDBYK->iKeywordssize) - /* and write it */ - iRetcode = write_raw_chunk (pData, pDBYK->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_DBYK, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_ordr) -{ - mng_ordrp pORDR; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - mng_uint8p pTemp; - mng_ordr_entryp pEntry; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ORDR, MNG_LC_START) -#endif - - pORDR = (mng_ordrp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = pORDR->iCount * 5; - - pTemp = pRawdata; /* fill the output buffer */ - pEntry = pORDR->pEntries; - - for (iX = 0; iX < pORDR->iCount; iX++) - { - mng_put_uint32 (pTemp, pEntry->iChunkname); - *(pTemp+4) = pEntry->iOrdertype; - pTemp += 5; - pEntry++; - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pORDR->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_ORDR, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_magn) -{ - mng_magnp pMAGN; - mng_uint8p pRawdata; - mng_uint32 iRawlen; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MAGN, MNG_LC_START) -#endif - - pMAGN = (mng_magnp)pChunk; /* address the proper chunk */ - - pRawdata = pData->pWritebuf+8; /* init output buffer & size */ - iRawlen = 20; - /* fill the output buffer */ - mng_put_uint16 (pRawdata, pMAGN->iFirstid); - mng_put_uint16 (pRawdata+2, pMAGN->iLastid); - mng_put_uint16 (pRawdata+4, pMAGN->iMethodX); - mng_put_uint16 (pRawdata+6, pMAGN->iMX); - mng_put_uint16 (pRawdata+8, pMAGN->iMY); - mng_put_uint16 (pRawdata+10, pMAGN->iML); - mng_put_uint16 (pRawdata+12, pMAGN->iMR); - mng_put_uint16 (pRawdata+14, pMAGN->iMT); - mng_put_uint16 (pRawdata+16, pMAGN->iMB); - mng_put_uint16 (pRawdata+18, pMAGN->iMethodY); - /* optimize length */ - if (pMAGN->iMethodY == pMAGN->iMethodX) - { - iRawlen -= 2; - - if (pMAGN->iMB == pMAGN->iMY) - { - iRawlen -= 2; - - if (pMAGN->iMT == pMAGN->iMY) - { - iRawlen -= 2; - - if (pMAGN->iMR == pMAGN->iMX) - { - iRawlen -= 2; - - if (pMAGN->iML == pMAGN->iMX) - { - iRawlen -= 2; - - if (pMAGN->iMY == pMAGN->iMX) - { - iRawlen -= 2; - - if (pMAGN->iMX == 1) - { - iRawlen -= 2; - - if (pMAGN->iMethodX == 0) - { - iRawlen -= 2; - - if (pMAGN->iLastid == pMAGN->iFirstid) - { - iRawlen -= 2; - - if (pMAGN->iFirstid == 0) - iRawlen = 0; - - } - } - } - } - } - } - } - } - } - /* and write it */ - iRetcode = write_raw_chunk (pData, pMAGN->sHeader.iChunkname, - iRawlen, pRawdata); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_MAGN, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -WRITE_CHUNK (write_unknown) -{ - mng_unknown_chunkp pUnknown; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_UNKNOWN, MNG_LC_START) -#endif - /* address the proper chunk */ - pUnknown = (mng_unknown_chunkp)pChunk; - /* and write it */ - iRetcode = write_raw_chunk (pData, pUnknown->sHeader.iChunkname, - pUnknown->iDatasize, pUnknown->pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_UNKNOWN, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - - - - diff --git a/freeimage241/Source/LibMNG/libmng_chunk_io.h b/freeimage241/Source/LibMNG/libmng_chunk_io.h deleted file mode 100644 index d905601..0000000 --- a/freeimage241/Source/LibMNG/libmng_chunk_io.h +++ /dev/null @@ -1,295 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_io.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Chunk I/O routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the chunk input/output routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */ -/* * - changed CRC initializtion to use dynamic structure * */ -/* * (wasn't thread-safe the old way !) * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed write routines definition * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_chunk_io_h_ -#define _libmng_chunk_io_h_ - -/* ************************************************************************** */ - -mng_uint32 crc (mng_datap pData, - mng_uint8p buf, - mng_int32 len); - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -#define READ_CHUNK(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pHeader, \ - mng_uint32 iRawlen, \ - mng_uint8p pRawdata, \ - mng_chunkp* ppChunk) - -READ_CHUNK (read_ihdr) ; -READ_CHUNK (read_plte) ; -READ_CHUNK (read_idat) ; -READ_CHUNK (read_iend) ; -READ_CHUNK (read_trns) ; -READ_CHUNK (read_gama) ; -READ_CHUNK (read_chrm) ; -READ_CHUNK (read_srgb) ; -READ_CHUNK (read_iccp) ; -READ_CHUNK (read_text) ; -READ_CHUNK (read_ztxt) ; -READ_CHUNK (read_itxt) ; -READ_CHUNK (read_bkgd) ; -READ_CHUNK (read_phys) ; -READ_CHUNK (read_sbit) ; -READ_CHUNK (read_splt) ; -READ_CHUNK (read_hist) ; -READ_CHUNK (read_time) ; -READ_CHUNK (read_mhdr) ; -READ_CHUNK (read_mend) ; -READ_CHUNK (read_loop) ; -READ_CHUNK (read_endl) ; -READ_CHUNK (read_defi) ; -READ_CHUNK (read_basi) ; -READ_CHUNK (read_clon) ; -READ_CHUNK (read_past) ; -READ_CHUNK (read_disc) ; -READ_CHUNK (read_back) ; -READ_CHUNK (read_fram) ; -READ_CHUNK (read_move) ; -READ_CHUNK (read_clip) ; -READ_CHUNK (read_show) ; -READ_CHUNK (read_term) ; -READ_CHUNK (read_save) ; -READ_CHUNK (read_seek) ; -READ_CHUNK (read_expi) ; -READ_CHUNK (read_fpri) ; -READ_CHUNK (read_phyg) ; -READ_CHUNK (read_jhdr) ; -READ_CHUNK (read_jdaa) ; -READ_CHUNK (read_jdat) ; -READ_CHUNK (read_jsep) ; -READ_CHUNK (read_dhdr) ; -READ_CHUNK (read_prom) ; -READ_CHUNK (read_ipng) ; -READ_CHUNK (read_pplt) ; -READ_CHUNK (read_ijng) ; -READ_CHUNK (read_drop) ; -READ_CHUNK (read_dbyk) ; -READ_CHUNK (read_ordr) ; -READ_CHUNK (read_magn) ; -READ_CHUNK (read_need) ; -READ_CHUNK (read_unknown) ; - -/* ************************************************************************** */ - -#else /* MNG_INCLUDE_READ_PROCS */ -#define read_ihdr 0 -#define read_plte 0 -#define read_idat 0 -#define read_iend 0 -#define read_trns 0 -#define read_gama 0 -#define read_chrm 0 -#define read_srgb 0 -#define read_iccp 0 -#define read_text 0 -#define read_ztxt 0 -#define read_itxt 0 -#define read_bkgd 0 -#define read_phys 0 -#define read_sbit 0 -#define read_splt 0 -#define read_hist 0 -#define read_time 0 -#define read_mhdr 0 -#define read_mend 0 -#define read_loop 0 -#define read_endl 0 -#define read_defi 0 -#define read_basi 0 -#define read_clon 0 -#define read_past 0 -#define read_disc 0 -#define read_back 0 -#define read_fram 0 -#define read_move 0 -#define read_clip 0 -#define read_show 0 -#define read_term 0 -#define read_save 0 -#define read_seek 0 -#define read_expi 0 -#define read_fpri 0 -#define read_phyg 0 -#define read_jhdr 0 -#define read_jdaa 0 -#define read_jdat 0 -#define read_jsep 0 -#define read_dhdr 0 -#define read_prom 0 -#define read_ipng 0 -#define read_pplt 0 -#define read_ijng 0 -#define read_drop 0 -#define read_dbyk 0 -#define read_ordr 0 -#define read_magn 0 -#define read_need 0 -#define read_unknown 0 -#endif /* MNG_INCLUDE_READ_PROCS */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -#define WRITE_CHUNK(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pChunk) - -WRITE_CHUNK (write_ihdr) ; -WRITE_CHUNK (write_plte) ; -WRITE_CHUNK (write_idat) ; -WRITE_CHUNK (write_iend) ; -WRITE_CHUNK (write_trns) ; -WRITE_CHUNK (write_gama) ; -WRITE_CHUNK (write_chrm) ; -WRITE_CHUNK (write_srgb) ; -WRITE_CHUNK (write_iccp) ; -WRITE_CHUNK (write_text) ; -WRITE_CHUNK (write_ztxt) ; -WRITE_CHUNK (write_itxt) ; -WRITE_CHUNK (write_bkgd) ; -WRITE_CHUNK (write_phys) ; -WRITE_CHUNK (write_sbit) ; -WRITE_CHUNK (write_splt) ; -WRITE_CHUNK (write_hist) ; -WRITE_CHUNK (write_time) ; -WRITE_CHUNK (write_mhdr) ; -WRITE_CHUNK (write_mend) ; -WRITE_CHUNK (write_loop) ; -WRITE_CHUNK (write_endl) ; -WRITE_CHUNK (write_defi) ; -WRITE_CHUNK (write_basi) ; -WRITE_CHUNK (write_clon) ; -WRITE_CHUNK (write_past) ; -WRITE_CHUNK (write_disc) ; -WRITE_CHUNK (write_back) ; -WRITE_CHUNK (write_fram) ; -WRITE_CHUNK (write_move) ; -WRITE_CHUNK (write_clip) ; -WRITE_CHUNK (write_show) ; -WRITE_CHUNK (write_term) ; -WRITE_CHUNK (write_save) ; -WRITE_CHUNK (write_seek) ; -WRITE_CHUNK (write_expi) ; -WRITE_CHUNK (write_fpri) ; -WRITE_CHUNK (write_phyg) ; -WRITE_CHUNK (write_jhdr) ; -WRITE_CHUNK (write_jdaa) ; -WRITE_CHUNK (write_jdat) ; -WRITE_CHUNK (write_jsep) ; -WRITE_CHUNK (write_dhdr) ; -WRITE_CHUNK (write_prom) ; -WRITE_CHUNK (write_ipng) ; -WRITE_CHUNK (write_pplt) ; -WRITE_CHUNK (write_ijng) ; -WRITE_CHUNK (write_drop) ; -WRITE_CHUNK (write_dbyk) ; -WRITE_CHUNK (write_ordr) ; -WRITE_CHUNK (write_magn) ; -WRITE_CHUNK (write_need) ; -WRITE_CHUNK (write_unknown) ; - -/* ************************************************************************** */ - -#else /* MNG_INCLUDE_WRITE_PROCS */ -#define write_ihdr 0 -#define write_plte 0 -#define write_idat 0 -#define write_iend 0 -#define write_trns 0 -#define write_gama 0 -#define write_chrm 0 -#define write_srgb 0 -#define write_iccp 0 -#define write_text 0 -#define write_ztxt 0 -#define write_itxt 0 -#define write_bkgd 0 -#define write_phys 0 -#define write_sbit 0 -#define write_splt 0 -#define write_hist 0 -#define write_time 0 -#define write_mhdr 0 -#define write_mend 0 -#define write_loop 0 -#define write_endl 0 -#define write_defi 0 -#define write_basi 0 -#define write_clon 0 -#define write_past 0 -#define write_disc 0 -#define write_back 0 -#define write_fram 0 -#define write_move 0 -#define write_clip 0 -#define write_show 0 -#define write_term 0 -#define write_save 0 -#define write_seek 0 -#define write_expi 0 -#define write_fpri 0 -#define write_phyg 0 -#define write_jhdr 0 -#define write_jdaa 0 -#define write_jdat 0 -#define write_jsep 0 -#define write_dhdr 0 -#define write_prom 0 -#define write_ipng 0 -#define write_pplt 0 -#define write_ijng 0 -#define write_drop 0 -#define write_dbyk 0 -#define write_ordr 0 -#define write_magn 0 -#define write_need 0 -#define write_unknown 0 -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_chunk_io_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_chunk_prc.c b/freeimage241/Source/LibMNG/libmng_chunk_prc.c deleted file mode 100644 index f3c27f4..0000000 --- a/freeimage241/Source/LibMNG/libmng_chunk_prc.c +++ /dev/null @@ -1,2102 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_prc.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Chunk initialization & cleanup (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the chunk initialization & cleanup * */ -/* * routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed creation-code * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - put add_chunk() inside MNG_INCLUDE_WRITE_PROCS wrapper * */ -/* * 0.9.2 - 08/01/2000 - G.Juyn * */ -/* * - wrapper for add_chunk() changed * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_chunks.h" -#include "libmng_chunk_prc.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * General chunk routines * */ -/* * * */ -/* ************************************************************************** */ - -void add_chunk (mng_datap pData, - mng_chunkp pChunk) -{ - if (!pData->pFirstchunk) /* list is still empty ? */ - { - pData->pFirstchunk = pChunk; /* then this becomes the first */ - -#ifdef MNG_SUPPORT_WRITE - pData->iFirstchunkadded = ((mng_chunk_headerp)pChunk)->iChunkname; -#endif - - if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_IHDR) - pData->eImagetype = mng_it_png; - else -#ifdef MNG_INCLUDE_JNG - if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_JHDR) - pData->eImagetype = mng_it_jng; - else -#endif - pData->eImagetype = mng_it_mng; - - pData->eSigtype = pData->eImagetype; - } - else - { /* else we make appropriate links */ - ((mng_chunk_headerp)pChunk)->pPrev = pData->pLastchunk; - ((mng_chunk_headerp)pData->pLastchunk)->pNext = pChunk; - } - - pData->pLastchunk = pChunk; /* and it's always the last */ - - return; -} - -/* ************************************************************************** */ -/* * * */ -/* * Chunk specific initialization routines * */ -/* * * */ -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_ihdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IHDR, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ihdr)) - ((mng_ihdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_plte) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PLTE, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_plte)) - ((mng_pltep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_idat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDAT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_idat)) - ((mng_idatp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_iend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IEND, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_iend)) - ((mng_iendp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_trns) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TRNS, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_trns)) - ((mng_trnsp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_gama) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMA, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_gama)) - ((mng_gamap)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_chrm) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CHRM, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_chrm)) - ((mng_chrmp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_srgb) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SRGB, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_srgb)) - ((mng_srgbp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_iccp) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ICCP, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_iccp)) - ((mng_iccpp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_text) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TEXT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_text)) - ((mng_textp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_ztxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ZTXT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ztxt)) - ((mng_ztxtp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ZTXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_itxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ITXT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_itxt)) - ((mng_itxtp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_bkgd) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BKGD, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_bkgd)) - ((mng_bkgdp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_phys) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYS, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_phys)) - ((mng_physp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_sbit) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SBIT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_sbit)) - ((mng_sbitp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SBIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_splt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SPLT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_splt)) - ((mng_spltp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_hist) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_HIST, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_hist)) - ((mng_histp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_HIST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_time) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TIME, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_time)) - ((mng_timep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TIME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_mhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MHDR, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_mhdr)) - ((mng_mhdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_mend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MEND, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_mend)) - ((mng_mendp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_loop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_LOOP, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_loop)) - ((mng_loopp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_endl) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ENDL, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_endl)) - ((mng_endlp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_defi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DEFI, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_defi)) - ((mng_defip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_basi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BASI, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_basi)) - ((mng_basip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_clon) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLON, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_clon)) - ((mng_clonp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_past) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PAST, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_past)) - ((mng_pastp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PAST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_disc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DISC, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_disc)) - ((mng_discp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_back) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BACK, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_back)) - ((mng_backp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_fram) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FRAM, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_fram)) - ((mng_framp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_move) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MOVE, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_move)) - ((mng_movep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_clip) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLIP, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_clip)) - ((mng_clipp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_show) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SHOW, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_show)) - ((mng_showp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_term) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TERM, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_term)) - ((mng_termp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_save) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SAVE, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_save)) - ((mng_savep)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_seek) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SEEK, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_seek)) - ((mng_seekp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_expi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_EXPI, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_expi)) - ((mng_expip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_EXPI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_fpri) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FPRI, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_fpri)) - ((mng_fprip)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FPRI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_need) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_NEED, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_need)) - ((mng_needp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_NEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_phyg) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYG, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_phyg)) - ((mng_phygp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PHYG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (init_jhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JHDR, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jhdr)) - ((mng_jhdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (init_jdaa) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAA, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jdaa)) - ((mng_jdaap)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (init_jdat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jdat)) - ((mng_jdatp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -INIT_CHUNK_HDR (init_jsep) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JSEP, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_jsep)) - ((mng_jsepp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JSEP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_dhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DHDR, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_dhdr)) - ((mng_dhdrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_prom) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PROM, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_prom)) - ((mng_promp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_ipng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IPNG, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ipng)) - ((mng_ipngp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_pplt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PPLT, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_pplt)) - ((mng_ppltp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_ijng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IJNG, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ijng)) - ((mng_ijngp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_drop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DROP, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_drop)) - ((mng_dropp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DROP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_dbyk) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DBYK, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_dbyk)) - ((mng_dbykp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_DBYK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_ordr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ORDR, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_ordr)) - ((mng_ordrp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ORDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_magn) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MAGN, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_magn)) - ((mng_magnp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -INIT_CHUNK_HDR (init_unknown) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_UNKNOWN, MNG_LC_START) -#endif - - MNG_ALLOC (pData, *ppChunk, sizeof (mng_unknown_chunk)) - ((mng_unknown_chunkp)*ppChunk)->sHeader = *((mng_chunk_headerp)pHeader); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_UNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Chunk specific cleanup routines * */ -/* * * */ -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_ihdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IHDR, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_ihdr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_plte) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PLTE, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_plte)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_idat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IDAT, MNG_LC_START) -#endif - - if (((mng_idatp)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_idatp)pHeader)->pData, - ((mng_idatp)pHeader)->iDatasize) - - MNG_FREEX (pData, pHeader, sizeof (mng_idat)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_iend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IEND, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_iend)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_trns) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TRNS, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_trns)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_gama) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_GAMA, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_gama)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_chrm) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CHRM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_chrm)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_srgb) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SRGB, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_srgb)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_iccp) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ICCP, MNG_LC_START) -#endif - - if (((mng_iccpp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_iccpp)pHeader)->zName, - ((mng_iccpp)pHeader)->iNamesize + 1) - - if (((mng_iccpp)pHeader)->iProfilesize) - MNG_FREEX (pData, ((mng_iccpp)pHeader)->pProfile, - ((mng_iccpp)pHeader)->iProfilesize) - - MNG_FREEX (pData, pHeader, sizeof (mng_iccp)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_text) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TEXT, MNG_LC_START) -#endif - - if (((mng_textp)pHeader)->iKeywordsize) - MNG_FREEX (pData, ((mng_textp)pHeader)->zKeyword, - ((mng_textp)pHeader)->iKeywordsize + 1) - - if (((mng_textp)pHeader)->iTextsize) - MNG_FREEX (pData, ((mng_textp)pHeader)->zText, - ((mng_textp)pHeader)->iTextsize + 1) - - MNG_FREEX (pData, pHeader, sizeof (mng_text)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_ztxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ZTXT, MNG_LC_START) -#endif - - if (((mng_ztxtp)pHeader)->iKeywordsize) - MNG_FREEX (pData, ((mng_ztxtp)pHeader)->zKeyword, - ((mng_ztxtp)pHeader)->iKeywordsize + 1) - - if (((mng_ztxtp)pHeader)->iTextsize) - MNG_FREEX (pData, ((mng_ztxtp)pHeader)->zText, - ((mng_ztxtp)pHeader)->iTextsize) - - MNG_FREEX (pData, pHeader, sizeof (mng_ztxt)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ZTXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_itxt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ITXT, MNG_LC_START) -#endif - - if (((mng_itxtp)pHeader)->iKeywordsize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zKeyword, - ((mng_itxtp)pHeader)->iKeywordsize + 1) - - if (((mng_itxtp)pHeader)->iLanguagesize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zLanguage, - ((mng_itxtp)pHeader)->iLanguagesize + 1) - - if (((mng_itxtp)pHeader)->iTranslationsize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zTranslation, - ((mng_itxtp)pHeader)->iTranslationsize + 1) - - if (((mng_itxtp)pHeader)->iTextsize) - MNG_FREEX (pData, ((mng_itxtp)pHeader)->zText, - ((mng_itxtp)pHeader)->iTextsize) - - MNG_FREEX (pData, pHeader, sizeof (mng_itxt)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_bkgd) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BKGD, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_bkgd)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_phys) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYS, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_phys)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_sbit) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SBIT, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_sbit)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SBIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_splt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SPLT, MNG_LC_START) -#endif - - if (((mng_spltp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_spltp)pHeader)->zName, - ((mng_spltp)pHeader)->iNamesize + 1) - - if (((mng_spltp)pHeader)->iEntrycount) - MNG_FREEX (pData, ((mng_spltp)pHeader)->pEntries, - ((mng_spltp)pHeader)->iEntrycount * - (((mng_spltp)pHeader)->iSampledepth * 3 + sizeof (mng_uint16)) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_splt)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_hist) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_HIST, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_hist)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_HIST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_time) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TIME, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_time)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TIME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_mhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MHDR, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_mhdr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_mend) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MEND, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_mend)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_loop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_LOOP, MNG_LC_START) -#endif - - if (((mng_loopp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_loopp)pHeader)->pSignals, - ((mng_loopp)pHeader)->iCount * sizeof (mng_uint32) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_loop)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_endl) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ENDL, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_endl)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_defi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DEFI, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_defi)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_basi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BASI, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_basi)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_clon) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLON, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_clon)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_past) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PAST, MNG_LC_START) -#endif - - if (((mng_pastp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_pastp)pHeader)->pSources, - ((mng_pastp)pHeader)->iCount * sizeof (mng_past_source) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_past)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PAST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_disc) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DISC, MNG_LC_START) -#endif - - if (((mng_discp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_discp)pHeader)->pObjectids, - ((mng_discp)pHeader)->iCount * sizeof (mng_uint16) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_disc)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_back) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BACK, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_back)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_fram) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FRAM, MNG_LC_START) -#endif - - if (((mng_framp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_framp)pHeader)->zName, - ((mng_framp)pHeader)->iNamesize + 1) - - if (((mng_framp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_framp)pHeader)->pSyncids, - ((mng_framp)pHeader)->iCount * sizeof (mng_uint32) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_fram)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_move) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MOVE, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_move)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_clip) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLIP, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_clip)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_show) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SHOW, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_show)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_term) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TERM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_term)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_save) -{ - mng_save_entryp pEntry = ((mng_savep)pHeader)->pEntries; - mng_uint32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SAVE, MNG_LC_START) -#endif - - for (iX = 0; iX < ((mng_savep)pHeader)->iCount; iX++) - { - if (pEntry->iNamesize) - MNG_FREEX (pData, pEntry->zName, pEntry->iNamesize) - - pEntry = pEntry + sizeof (mng_save_entry); - } - - if (((mng_savep)pHeader)->iCount) - MNG_FREEX (pData, ((mng_savep)pHeader)->pEntries, - ((mng_savep)pHeader)->iCount * sizeof (mng_save_entry) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_save)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_seek) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SEEK, MNG_LC_START) -#endif - - if (((mng_seekp)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_seekp)pHeader)->zName, - ((mng_seekp)pHeader)->iNamesize + 1) - - MNG_FREEX (pData, pHeader, sizeof (mng_seek)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_expi) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_EXPI, MNG_LC_START) -#endif - - if (((mng_expip)pHeader)->iNamesize) - MNG_FREEX (pData, ((mng_expip)pHeader)->zName, - ((mng_expip)pHeader)->iNamesize + 1) - - MNG_FREEX (pData, pHeader, sizeof (mng_expi)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_EXPI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_fpri) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FPRI, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_fpri)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_FPRI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_need) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_NEED, MNG_LC_START) -#endif - - if (((mng_needp)pHeader)->iKeywordssize) - MNG_FREEX (pData, ((mng_needp)pHeader)->zKeywords, - ((mng_needp)pHeader)->iKeywordssize + 1) - - MNG_FREEX (pData, pHeader, sizeof (mng_need)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_NEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_phyg) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYG, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_phyg)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PHYG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (free_jhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JHDR, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_jhdr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (free_jdaa) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAA, MNG_LC_START) -#endif - - if (((mng_jdaap)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_jdaap)pHeader)->pData, - ((mng_jdaap)pHeader)->iDatasize) - - MNG_FREEX (pData, pHeader, sizeof (mng_jdaa)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (free_jdat) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAT, MNG_LC_START) -#endif - - if (((mng_jdatp)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_jdatp)pHeader)->pData, - ((mng_jdatp)pHeader)->iDatasize) - - MNG_FREEX (pData, pHeader, sizeof (mng_jdat)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -FREE_CHUNK_HDR (free_jsep) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JSEP, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_jsep)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_JSEP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_dhdr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DHDR, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_dhdr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_prom) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PROM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_prom)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_ipng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IPNG, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_ipng)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_pplt) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PPLT, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_pplt)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_ijng) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IJNG, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_ijng)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_drop) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DROP, MNG_LC_START) -#endif - - if (((mng_dropp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_dropp)pHeader)->pChunknames, - ((mng_dropp)pHeader)->iCount * sizeof (mng_chunkid) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_drop)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DROP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_dbyk) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DBYK, MNG_LC_START) -#endif - - if (((mng_dbykp)pHeader)->iKeywordssize) - MNG_FREEX (pData, ((mng_dbykp)pHeader)->zKeywords, - ((mng_dbykp)pHeader)->iKeywordssize) - - MNG_FREEX (pData, pHeader, sizeof (mng_dbyk)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_DBYK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_ordr) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ORDR, MNG_LC_START) -#endif - - if (((mng_ordrp)pHeader)->iCount) - MNG_FREEX (pData, ((mng_ordrp)pHeader)->pEntries, - ((mng_ordrp)pHeader)->iCount * sizeof (mng_ordr_entry) ) - - MNG_FREEX (pData, pHeader, sizeof (mng_ordr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ORDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_magn) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MAGN, MNG_LC_START) -#endif - - MNG_FREEX (pData, pHeader, sizeof (mng_magn)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -FREE_CHUNK_HDR (free_unknown) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_UNKNOWN, MNG_LC_START) -#endif - - if (((mng_unknown_chunkp)pHeader)->iDatasize) - MNG_FREEX (pData, ((mng_unknown_chunkp)pHeader)->pData, - ((mng_unknown_chunkp)pHeader)->iDatasize) - - MNG_FREEX (pData, pHeader, sizeof (mng_unknown_chunk)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_UNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_chunk_prc.h b/freeimage241/Source/LibMNG/libmng_chunk_prc.h deleted file mode 100644 index a1054d4..0000000 --- a/freeimage241/Source/LibMNG/libmng_chunk_prc.h +++ /dev/null @@ -1,168 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_prc.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Chunk initialization & cleanup (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : definition of the chunk initialization & cleanup routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_chunk_prc_h_ -#define _libmng_chunk_prc_h_ - -/* ************************************************************************** */ - -void add_chunk (mng_datap pData, - mng_chunkp pChunk); - -/* ************************************************************************** */ - -#define INIT_CHUNK_HDR(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pHeader, \ - mng_chunkp* ppChunk) - -INIT_CHUNK_HDR (init_ihdr) ; -INIT_CHUNK_HDR (init_plte) ; -INIT_CHUNK_HDR (init_idat) ; -INIT_CHUNK_HDR (init_iend) ; -INIT_CHUNK_HDR (init_trns) ; -INIT_CHUNK_HDR (init_gama) ; -INIT_CHUNK_HDR (init_chrm) ; -INIT_CHUNK_HDR (init_srgb) ; -INIT_CHUNK_HDR (init_iccp) ; -INIT_CHUNK_HDR (init_text) ; -INIT_CHUNK_HDR (init_ztxt) ; -INIT_CHUNK_HDR (init_itxt) ; -INIT_CHUNK_HDR (init_bkgd) ; -INIT_CHUNK_HDR (init_phys) ; -INIT_CHUNK_HDR (init_sbit) ; -INIT_CHUNK_HDR (init_splt) ; -INIT_CHUNK_HDR (init_hist) ; -INIT_CHUNK_HDR (init_time) ; -INIT_CHUNK_HDR (init_mhdr) ; -INIT_CHUNK_HDR (init_mend) ; -INIT_CHUNK_HDR (init_loop) ; -INIT_CHUNK_HDR (init_endl) ; -INIT_CHUNK_HDR (init_defi) ; -INIT_CHUNK_HDR (init_basi) ; -INIT_CHUNK_HDR (init_clon) ; -INIT_CHUNK_HDR (init_past) ; -INIT_CHUNK_HDR (init_disc) ; -INIT_CHUNK_HDR (init_back) ; -INIT_CHUNK_HDR (init_fram) ; -INIT_CHUNK_HDR (init_move) ; -INIT_CHUNK_HDR (init_clip) ; -INIT_CHUNK_HDR (init_show) ; -INIT_CHUNK_HDR (init_term) ; -INIT_CHUNK_HDR (init_save) ; -INIT_CHUNK_HDR (init_seek) ; -INIT_CHUNK_HDR (init_expi) ; -INIT_CHUNK_HDR (init_fpri) ; -INIT_CHUNK_HDR (init_need) ; -INIT_CHUNK_HDR (init_phyg) ; -INIT_CHUNK_HDR (init_jhdr) ; -INIT_CHUNK_HDR (init_jdaa) ; -INIT_CHUNK_HDR (init_jdat) ; -INIT_CHUNK_HDR (init_jsep) ; -INIT_CHUNK_HDR (init_dhdr) ; -INIT_CHUNK_HDR (init_prom) ; -INIT_CHUNK_HDR (init_ipng) ; -INIT_CHUNK_HDR (init_pplt) ; -INIT_CHUNK_HDR (init_ijng) ; -INIT_CHUNK_HDR (init_drop) ; -INIT_CHUNK_HDR (init_dbyk) ; -INIT_CHUNK_HDR (init_ordr) ; -INIT_CHUNK_HDR (init_magn) ; -INIT_CHUNK_HDR (init_unknown) ; - -/* ************************************************************************** */ - -#define FREE_CHUNK_HDR(n) mng_retcode n (mng_datap pData, \ - mng_chunkp pHeader) - -FREE_CHUNK_HDR (free_ihdr) ; -FREE_CHUNK_HDR (free_plte) ; -FREE_CHUNK_HDR (free_idat) ; -FREE_CHUNK_HDR (free_iend) ; -FREE_CHUNK_HDR (free_trns) ; -FREE_CHUNK_HDR (free_gama) ; -FREE_CHUNK_HDR (free_chrm) ; -FREE_CHUNK_HDR (free_srgb) ; -FREE_CHUNK_HDR (free_iccp) ; -FREE_CHUNK_HDR (free_text) ; -FREE_CHUNK_HDR (free_ztxt) ; -FREE_CHUNK_HDR (free_itxt) ; -FREE_CHUNK_HDR (free_bkgd) ; -FREE_CHUNK_HDR (free_phys) ; -FREE_CHUNK_HDR (free_sbit) ; -FREE_CHUNK_HDR (free_splt) ; -FREE_CHUNK_HDR (free_hist) ; -FREE_CHUNK_HDR (free_time) ; -FREE_CHUNK_HDR (free_mhdr) ; -FREE_CHUNK_HDR (free_mend) ; -FREE_CHUNK_HDR (free_loop) ; -FREE_CHUNK_HDR (free_endl) ; -FREE_CHUNK_HDR (free_defi) ; -FREE_CHUNK_HDR (free_basi) ; -FREE_CHUNK_HDR (free_clon) ; -FREE_CHUNK_HDR (free_past) ; -FREE_CHUNK_HDR (free_disc) ; -FREE_CHUNK_HDR (free_back) ; -FREE_CHUNK_HDR (free_fram) ; -FREE_CHUNK_HDR (free_move) ; -FREE_CHUNK_HDR (free_clip) ; -FREE_CHUNK_HDR (free_show) ; -FREE_CHUNK_HDR (free_term) ; -FREE_CHUNK_HDR (free_save) ; -FREE_CHUNK_HDR (free_seek) ; -FREE_CHUNK_HDR (free_expi) ; -FREE_CHUNK_HDR (free_fpri) ; -FREE_CHUNK_HDR (free_need) ; -FREE_CHUNK_HDR (free_phyg) ; -FREE_CHUNK_HDR (free_jhdr) ; -FREE_CHUNK_HDR (free_jdaa) ; -FREE_CHUNK_HDR (free_jdat) ; -FREE_CHUNK_HDR (free_jsep) ; -FREE_CHUNK_HDR (free_dhdr) ; -FREE_CHUNK_HDR (free_prom) ; -FREE_CHUNK_HDR (free_ipng) ; -FREE_CHUNK_HDR (free_pplt) ; -FREE_CHUNK_HDR (free_ijng) ; -FREE_CHUNK_HDR (free_drop) ; -FREE_CHUNK_HDR (free_dbyk) ; -FREE_CHUNK_HDR (free_ordr) ; -FREE_CHUNK_HDR (free_magn) ; -FREE_CHUNK_HDR (free_unknown) ; - -/* ************************************************************************** */ - -#endif /* _libmng_chunk_prc_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_chunk_xs.c b/freeimage241/Source/LibMNG/libmng_chunk_xs.c deleted file mode 100644 index 8ca3f47..0000000 --- a/freeimage241/Source/LibMNG/libmng_chunk_xs.c +++ /dev/null @@ -1,5119 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunk_xs.c copyright (c) 2000 G. Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : chunk access functions (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the chunk access functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - changed and filled iterate-chunk function * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - fixed calling convention * */ -/* * - added getchunk functions * */ -/* * - added putchunk functions * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added empty-chunk put-routines * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/15/2000 - G.Juyn * */ -/* * - added getimgdata & putimgdata functions * */ -/* * * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - B004 - fixed problem with MNG_SUPPORT_WRITE not defined * */ -/* * also for MNG_SUPPORT_WRITE without MNG_INCLUDE_JNG * */ -/* * - Cleaned up some code regarding mixed support * */ -/* * * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed creation-code * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added function to set simplicity field * */ -/* * - fixed putchunk_unknown() function * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - fixed putchunk_plte() to set bEmpty parameter * */ -/* * * */ -/* * 0.9.5 - 1/25/2001 - G.Juyn * */ -/* * - fixed some small compiler warnings (thanks Nikki) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_chunks.h" -#include "libmng_chunk_prc.h" -#include "libmng_chunk_io.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_ACCESS_CHUNKS - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_iterate_chunks (mng_handle hHandle, - mng_uint32 iChunkseq, - mng_iteratechunk fProc) -{ - mng_uint32 iSeq; - mng_chunkid iChunkname; - mng_datap pData; - mng_chunkp pChunk; - mng_bool bCont; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_ITERATE_CHUNKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - iSeq = 0; - bCont = MNG_TRUE; - pChunk = pData->pFirstchunk; /* get the first chunk */ - /* as long as there are some more */ - while ((pChunk) && (bCont)) /* and the app didn't signal a stop */ - { - if (iSeq >= iChunkseq) /* reached the first target ? */ - { /* then call this and next ones back in... */ - iChunkname = ((mng_chunk_headerp)pChunk)->iChunkname; - bCont = fProc (hHandle, (mng_handle)pChunk, iChunkname, iSeq); - } - - iSeq++; /* next one */ - pChunk = ((mng_chunk_headerp)pChunk)->pNext; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_ITERATE_CHUNKS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_ihdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace) -{ - mng_datap pData; - mng_ihdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ihdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_IHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iBitdepth = pChunk->iBitdepth; - *iColortype = pChunk->iColortype; - *iCompression = pChunk->iCompression; - *iFilter = pChunk->iFilter; - *iInterlace = pChunk->iInterlace; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_plte (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_palette8 *aPalette) -{ - mng_datap pData; - mng_pltep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PLTE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_pltep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PLTE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iEntrycount; /* fill the fields */ - - MNG_COPY (*aPalette, pChunk->aEntries, sizeof (mng_palette8)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_idat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata) -{ - mng_datap pData; - mng_idatp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_idatp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_IDAT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iRawlen = pChunk->iDatasize; /* fill the fields */ - *pRawdata = pChunk->pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_trns (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_bool *bGlobal, - mng_uint8 *iType, - mng_uint32 *iCount, - mng_uint8arr *aAlphas, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint32 *iRawlen, - mng_uint8arr *aRawdata) -{ - mng_datap pData; - mng_trnsp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TRNS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_trnsp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_tRNS) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *bGlobal = pChunk->bGlobal; - *iType = pChunk->iType; - *iCount = pChunk->iCount; - *iGray = pChunk->iGray; - *iRed = pChunk->iRed; - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - *iRawlen = pChunk->iRawlen; - - MNG_COPY (*aAlphas, pChunk->aEntries, sizeof (mng_uint8arr)) - MNG_COPY (*aRawdata, pChunk->aRawdata, sizeof (mng_uint8arr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_gama (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iGamma) -{ - mng_datap pData; - mng_gamap pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_GAMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_gamap)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_gAMA) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iGamma = pChunk->iGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_chrm (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iWhitepointx, - mng_uint32 *iWhitepointy, - mng_uint32 *iRedx, - mng_uint32 *iRedy, - mng_uint32 *iGreenx, - mng_uint32 *iGreeny, - mng_uint32 *iBluex, - mng_uint32 *iBluey) -{ - mng_datap pData; - mng_chrmp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CHRM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_chrmp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_cHRM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iWhitepointx = pChunk->iWhitepointx; - *iWhitepointy = pChunk->iWhitepointy; - *iRedx = pChunk->iRedx; - *iRedy = pChunk->iRedy; - *iGreenx = pChunk->iGreenx; - *iGreeny = pChunk->iGreeny; - *iBluex = pChunk->iBluex; - *iBluey = pChunk->iBluey; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_srgb (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iRenderingintent) -{ - mng_datap pData; - mng_srgbp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_srgbp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_sRGB) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iRenderingintent = pChunk->iRenderingintent; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_iccp (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iCompression, - mng_uint32 *iProfilesize, - mng_ptr *pProfile) -{ - mng_datap pData; - mng_iccpp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ICCP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_iccpp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_iCCP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - *iCompression = pChunk->iCompression; - *iProfilesize = pChunk->iProfilesize; - *pProfile = pChunk->pProfile; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_text (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint32 *iTextsize, - mng_pchar *zText) -{ - mng_datap pData; - mng_textp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TEXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_textp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_tEXt) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordsize = pChunk->iKeywordsize; - *zKeyword = pChunk->zKeyword; - *iTextsize = pChunk->iTextsize; - *zText = pChunk->zText; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_ztxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompression, - mng_uint32 *iTextsize, - mng_pchar *zText) -{ - mng_datap pData; - mng_ztxtp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ZTXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ztxtp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_zTXt) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordsize = pChunk->iKeywordsize; - *zKeyword = pChunk->zKeyword; - *iCompression = pChunk->iCompression; - *iTextsize = pChunk->iTextsize; - *zText = pChunk->zText; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ZTXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_itxt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordsize, - mng_pchar *zKeyword, - mng_uint8 *iCompressionflag, - mng_uint8 *iCompressionmethod, - mng_uint32 *iLanguagesize, - mng_pchar *zLanguage, - mng_uint32 *iTranslationsize, - mng_pchar *zTranslation, - mng_uint32 *iTextsize, - mng_pchar *zText) -{ - mng_datap pData; - mng_itxtp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ITXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_itxtp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_iTXt) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordsize = pChunk->iKeywordsize; - *zKeyword = pChunk->zKeyword; - *iCompressionflag = pChunk->iCompressionflag; - *iCompressionmethod = pChunk->iCompressionmethod; - *iLanguagesize = pChunk->iLanguagesize; - *zLanguage = pChunk->zLanguage; - *iTranslationsize = pChunk->iTranslationsize; - *zTranslation = pChunk->zTranslation; - *iTextsize = pChunk->iTextsize; - *zText = pChunk->zText; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_bkgd (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8 *iIndex, - mng_uint16 *iGray, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue) -{ - mng_datap pData; - mng_bkgdp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BKGD, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_bkgdp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_bKGD) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iType = pChunk->iType; - *iIndex = pChunk->iIndex; - *iGray = pChunk->iGray; - *iRed = pChunk->iRed; - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_phys (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit) -{ - mng_datap pData; - mng_physp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_physp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_pHYs) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iSizex = pChunk->iSizex; - *iSizey = pChunk->iSizey; - *iUnit = pChunk->iUnit; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_sbit (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iType, - mng_uint8arr4 *aBits) -{ - mng_datap pData; - mng_sbitp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SBIT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_sbitp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_sBIT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; - *iType = pChunk->iType; - (*aBits)[0] = pChunk->aBits[0]; - (*aBits)[1] = pChunk->aBits[1]; - (*aBits)[2] = pChunk->aBits[2]; - (*aBits)[3] = pChunk->aBits[3]; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SBIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_splt (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iSampledepth, - mng_uint32 *iEntrycount, - mng_ptr *pEntries) -{ - mng_datap pData; - mng_spltp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SPLT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_spltp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_sPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - *iSampledepth = pChunk->iSampledepth; - *iEntrycount = pChunk->iEntrycount; - *pEntries = pChunk->pEntries; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_hist (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iEntrycount, - mng_uint16arr *aEntries) -{ - mng_datap pData; - mng_histp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_HIST, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_histp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_hIST) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iEntrycount = pChunk->iEntrycount; /* fill the fields */ - - MNG_COPY (*aEntries, pChunk->aEntries, sizeof (mng_uint16arr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_HIST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_time (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iYear, - mng_uint8 *iMonth, - mng_uint8 *iDay, - mng_uint8 *iHour, - mng_uint8 *iMinute, - mng_uint8 *iSecond) -{ - mng_datap pData; - mng_timep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TIME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_timep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_tIME) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iYear = pChunk->iYear; /* fill the fields */ - *iMonth = pChunk->iMonth; - *iDay = pChunk->iDay; - *iHour = pChunk->iHour; - *iMinute = pChunk->iMinute; - *iSecond = pChunk->iSecond; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TIME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_mhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint32 *iTicks, - mng_uint32 *iLayercount, - mng_uint32 *iFramecount, - mng_uint32 *iPlaytime, - mng_uint32 *iSimplicity) -{ - mng_datap pData; - mng_mhdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_mhdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iTicks = pChunk->iTicks; - *iLayercount = pChunk->iLayercount; - *iFramecount = pChunk->iFramecount; - *iPlaytime = pChunk->iPlaytime; - *iSimplicity = pChunk->iSimplicity; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_loop (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel, - mng_uint32 *iRepeat, - mng_uint8 *iTermination, - mng_uint32 *iItermin, - mng_uint32 *iItermax, - mng_uint32 *iCount, - mng_uint32p *pSignals) -{ - mng_datap pData; - mng_loopp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_LOOP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_loopp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_LOOP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iLevel = pChunk->iLevel; /* fill teh fields */ - *iRepeat = pChunk->iRepeat; - *iTermination = pChunk->iTermination; - *iItermin = pChunk->iItermin; - *iItermax = pChunk->iItermax; - *iCount = pChunk->iCount; - *pSignals = pChunk->pSignals; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_endl (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iLevel) -{ - mng_datap pData; - mng_endlp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ENDL, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_endlp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_ENDL) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iLevel = pChunk->iLevel; /* fill the field */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_defi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_int32 *iXlocation, - mng_int32 *iYlocation, - mng_bool *bHasclip, - mng_int32 *iLeftcb, - mng_int32 *iRightcb, - mng_int32 *iTopcb, - mng_int32 *iBottomcb) -{ - mng_datap pData; - mng_defip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DEFI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_defip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DEFI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iObjectid = pChunk->iObjectid; /* fill the fields */ - *iDonotshow = pChunk->iDonotshow; - *iConcrete = pChunk->iConcrete; - *bHasloca = pChunk->bHasloca; - *iXlocation = pChunk->iXlocation; - *iYlocation = pChunk->iYlocation; - *bHasclip = pChunk->bHasclip; - *iLeftcb = pChunk->iLeftcb; - *iRightcb = pChunk->iRightcb; - *iTopcb = pChunk->iTopcb; - *iBottomcb = pChunk->iBottomcb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_basi (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iBitdepth, - mng_uint8 *iColortype, - mng_uint8 *iCompression, - mng_uint8 *iFilter, - mng_uint8 *iInterlace, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_uint8 *iViewable) -{ - mng_datap pData; - mng_basip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BASI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_basip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_BASI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iBitdepth = pChunk->iBitdepth; - *iColortype = pChunk->iColortype; - *iCompression = pChunk->iCompression; - *iFilter = pChunk->iFilter; - *iInterlace = pChunk->iInterlace; - *iRed = pChunk->iRed; - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - *iAlpha = pChunk->iAlpha; - *iViewable = pChunk->iViewable; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_clon (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSourceid, - mng_uint16 *iCloneid, - mng_uint8 *iClonetype, - mng_uint8 *iDonotshow, - mng_uint8 *iConcrete, - mng_bool *bHasloca, - mng_uint8 *iLocationtype, - mng_int32 *iLocationx, - mng_int32 *iLocationy) -{ - mng_datap pData; - mng_clonp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLON, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_clonp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_CLON) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iSourceid = pChunk->iSourceid; /* fill the fields */ - *iCloneid = pChunk->iCloneid; - *iClonetype = pChunk->iClonetype; - *iDonotshow = pChunk->iDonotshow; - *iConcrete = pChunk->iConcrete; - *bHasloca = pChunk->bHasloca; - *iLocationtype = pChunk->iLocationtype; - *iLocationx = pChunk->iLocationx; - *iLocationy = pChunk->iLocationy; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_past (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iDestid, - mng_uint8 *iTargettype, - mng_int32 *iTargetx, - mng_int32 *iTargety, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_pastp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_pastp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PAST) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iDestid = pChunk->iDestid; /* fill the fields */ - *iTargettype = pChunk->iTargettype; - *iTargetx = pChunk->iTargetx; - *iTargety = pChunk->iTargety; - *iCount = pChunk->iCount; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_past_src (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iSourceid, - mng_uint8 *iComposition, - mng_uint8 *iOrientation, - mng_uint8 *iOffsettype, - mng_int32 *iOffsetx, - mng_int32 *iOffsety, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb) -{ - mng_datap pData; - mng_pastp pChunk; - mng_past_sourcep pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST_SRC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_pastp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PAST) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address the entry */ - pEntry = pChunk->pSources + iEntry; - - *iSourceid = pEntry->iSourceid; /* fill the fields */ - *iComposition = pEntry->iComposition; - *iOrientation = pEntry->iOrientation; - *iOffsettype = pEntry->iOffsettype; - *iOffsetx = pEntry->iOffsetx; - *iOffsety = pEntry->iOffsety; - *iBoundarytype = pEntry->iBoundarytype; - *iBoundaryl = pEntry->iBoundaryl; - *iBoundaryr = pEntry->iBoundaryr; - *iBoundaryt = pEntry->iBoundaryt; - *iBoundaryb = pEntry->iBoundaryb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PAST_SRC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_disc (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_uint16p *pObjectids) -{ - mng_datap pData; - mng_discp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DISC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_discp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DISC) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the fields */ - *pObjectids = pChunk->pObjectids; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_back (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint8 *iMandatory, - mng_uint16 *iImageid, - mng_uint8 *iTile) -{ - mng_datap pData; - mng_backp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BACK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_backp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_BACK) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iRed = pChunk->iRed; /* fill the fields */ - *iGreen = pChunk->iGreen; - *iBlue = pChunk->iBlue; - *iMandatory = pChunk->iMandatory; - *iImageid = pChunk->iImageid; - *iTile = pChunk->iTile; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_fram (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iMode, - mng_uint32 *iNamesize, - mng_pchar *zName, - mng_uint8 *iChangedelay, - mng_uint8 *iChangetimeout, - mng_uint8 *iChangeclipping, - mng_uint8 *iChangesyncid, - mng_uint32 *iDelay, - mng_uint32 *iTimeout, - mng_uint8 *iBoundarytype, - mng_int32 *iBoundaryl, - mng_int32 *iBoundaryr, - mng_int32 *iBoundaryt, - mng_int32 *iBoundaryb, - mng_uint32 *iCount, - mng_uint32p *pSyncids) -{ - mng_datap pData; - mng_framp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FRAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_framp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_FRAM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iMode = pChunk->iMode; - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - *iChangedelay = pChunk->iChangedelay; - *iChangetimeout = pChunk->iChangetimeout; - *iChangeclipping = pChunk->iChangeclipping; - *iChangesyncid = pChunk->iChangesyncid; - *iDelay = pChunk->iDelay; - *iTimeout = pChunk->iTimeout; - *iBoundarytype = pChunk->iBoundarytype; - *iBoundaryl = pChunk->iBoundaryl; - *iBoundaryr = pChunk->iBoundaryr; - *iBoundaryt = pChunk->iBoundaryt; - *iBoundaryb = pChunk->iBoundaryb; - *iCount = pChunk->iCount; - *pSyncids = pChunk->pSyncids; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_move (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMovetype, - mng_int32 *iMovex, - mng_int32 *iMovey) -{ - mng_datap pData; - mng_movep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MOVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_movep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_MOVE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iFirstid = pChunk->iFirstid; /* fill the fields */ - *iLastid = pChunk->iLastid; - *iMovetype = pChunk->iMovetype; - *iMovex = pChunk->iMovex; - *iMovey = pChunk->iMovey; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_clip (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iCliptype, - mng_int32 *iClipl, - mng_int32 *iClipr, - mng_int32 *iClipt, - mng_int32 *iClipb) -{ - mng_datap pData; - mng_clipp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLIP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_clipp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_CLIP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iFirstid = pChunk->iFirstid; /* fill the fields */ - *iLastid = pChunk->iLastid; - *iCliptype = pChunk->iCliptype; - *iClipl = pChunk->iClipl; - *iClipr = pChunk->iClipr; - *iClipt = pChunk->iClipt; - *iClipb = pChunk->iClipb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_show (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint8 *iMode) -{ - mng_datap pData; - mng_showp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SHOW, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_showp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SHOW) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iFirstid = pChunk->iFirstid; - *iLastid = pChunk->iLastid; - *iMode = pChunk->iMode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_term (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iTermaction, - mng_uint8 *iIteraction, - mng_uint32 *iDelay, - mng_uint32 *iItermax) -{ - mng_datap pData; - mng_termp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TERM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_termp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_TERM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iTermaction = pChunk->iTermaction; /* fill the fields */ - *iIteraction = pChunk->iIteraction; - *iDelay = pChunk->iDelay; - *iItermax = pChunk->iItermax; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_save (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint8 *iOffsettype, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_savep pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_savep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SAVE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iOffsettype = pChunk->iOffsettype; - *iCount = pChunk->iCount; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_save_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint8 *iEntrytype, - mng_uint32arr2 *iOffset, - mng_uint32arr2 *iStarttime, - mng_uint32 *iLayernr, - mng_uint32 *iFramenr, - mng_uint32 *iNamesize, - mng_pchar *zName) -{ - mng_datap pData; - mng_savep pChunk; - mng_save_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_savep)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SAVE) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pEntry = pChunk->pEntries + iEntry; /* address the entry */ - /* fill the fields */ - *iEntrytype = pEntry->iEntrytype; - (*iOffset)[0] = pEntry->iOffset[0]; - (*iOffset)[1] = pEntry->iOffset[1]; - (*iStarttime)[0] = pEntry->iStarttime[0]; - (*iStarttime)[1] = pEntry->iStarttime[1]; - *iLayernr = pEntry->iLayernr; - *iFramenr = pEntry->iFramenr; - *iNamesize = pEntry->iNamesize; - *zName = pEntry->zName; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SAVE_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_seek (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iNamesize, - mng_pchar *zName) -{ - mng_datap pData; - mng_seekp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SEEK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_seekp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_SEEK) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iNamesize = pChunk->iNamesize; /* fill the fields */ - *zName = pChunk->zName; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_expi (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iSnapshotid, - mng_uint32 *iNamesize, - mng_pchar *zName) -{ - mng_datap pData; - mng_expip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EXPI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_expip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_eXPI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iSnapshotid = pChunk->iSnapshotid; /* fill the fields */ - *iNamesize = pChunk->iNamesize; - *zName = pChunk->zName; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_EXPI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_fpri (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iDeltatype, - mng_uint8 *iPriority) -{ - mng_datap pData; - mng_fprip pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FPRI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_fprip)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_fPRI) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iDeltatype = pChunk->iDeltatype; /* fill the fields */ - *iPriority = pChunk->iPriority; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_FPRI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_need (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords) -{ - mng_datap pData; - mng_needp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_NEED, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_needp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_nEED) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iKeywordssize = pChunk->iKeywordssize; - *zKeywords = pChunk->zKeywords; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_NEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_phyg (mng_handle hHandle, - mng_handle hChunk, - mng_bool *bEmpty, - mng_uint32 *iSizex, - mng_uint32 *iSizey, - mng_uint8 *iUnit) -{ - mng_datap pData; - mng_phygp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYG, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_phygp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_pHYg) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *bEmpty = pChunk->bEmpty; /* fill the fields */ - *iSizex = pChunk->iSizex; - *iSizey = pChunk->iSizey; - *iUnit = pChunk->iUnit; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PHYG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -mng_retcode MNG_DECL mng_getchunk_jhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iWidth, - mng_uint32 *iHeight, - mng_uint8 *iColortype, - mng_uint8 *iImagesampledepth, - mng_uint8 *iImagecompression, - mng_uint8 *iImageinterlace, - mng_uint8 *iAlphasampledepth, - mng_uint8 *iAlphacompression, - mng_uint8 *iAlphafilter, - mng_uint8 *iAlphainterlace) -{ - mng_datap pData; - mng_jhdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_jhdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_JHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iWidth = pChunk->iWidth; /* fill the fields */ - *iHeight = pChunk->iHeight; - *iColortype = pChunk->iColortype; - *iImagesampledepth = pChunk->iImagesampledepth; - *iImagecompression = pChunk->iImagecompression; - *iImageinterlace = pChunk->iImageinterlace; - *iAlphasampledepth = pChunk->iAlphasampledepth; - *iAlphacompression = pChunk->iAlphacompression; - *iAlphafilter = pChunk->iAlphafilter; - *iAlphainterlace = pChunk->iAlphainterlace; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -mng_retcode MNG_DECL mng_getchunk_jdat (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iRawlen, - mng_ptr *pRawdata) -{ - mng_datap pData; - mng_jdatp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_jdatp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_JDAT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iRawlen = pChunk->iDatasize; /* fill the fields */ - *pRawdata = pChunk->pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_dhdr (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iObjectid, - mng_uint8 *iImagetype, - mng_uint8 *iDeltatype, - mng_uint32 *iBlockwidth, - mng_uint32 *iBlockheight, - mng_uint32 *iBlockx, - mng_uint32 *iBlocky) -{ - mng_datap pData; - mng_dhdrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_dhdrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DHDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iObjectid = pChunk->iObjectid; /* fill the fields */ - *iImagetype = pChunk->iImagetype; - *iDeltatype = pChunk->iDeltatype; - *iBlockwidth = pChunk->iBlockwidth; - *iBlockheight = pChunk->iBlockheight; - *iBlockx = pChunk->iBlockx; - *iBlocky = pChunk->iBlocky; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_prom (mng_handle hHandle, - mng_handle hChunk, - mng_uint8 *iColortype, - mng_uint8 *iSampledepth, - mng_uint8 *iFilltype) -{ - mng_datap pData; - mng_promp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PROM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_promp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PROM) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iColortype = pChunk->iColortype; /* fill the fields */ - *iSampledepth = pChunk->iSampledepth; - *iFilltype = pChunk->iFilltype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_pplt (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_ppltp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ppltp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the field */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_pplt_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_uint16 *iRed, - mng_uint16 *iGreen, - mng_uint16 *iBlue, - mng_uint16 *iAlpha, - mng_bool *bUsed) -{ - mng_datap pData; - mng_ppltp pChunk; - mng_pplt_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ppltp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_PPLT) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pEntry = &pChunk->aEntries[iEntry]; /* address the entry */ - - *iRed = pEntry->iRed; /* fill the fields */ - *iGreen = pEntry->iGreen; - *iBlue = pEntry->iBlue; - *iAlpha = pEntry->iAlpha; - *bUsed = pEntry->bUsed; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_PPLT_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_drop (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount, - mng_chunkidp *pChunknames) -{ - mng_datap pData; - mng_dropp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DROP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_dropp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DROP) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the fields */ - *pChunknames = pChunk->pChunknames; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DROP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_dbyk (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint8 *iPolarity, - mng_uint32 *iKeywordssize, - mng_pchar *zKeywords) -{ - mng_datap pData; - mng_dbykp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DBYK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_dbykp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_DBYK) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iChunkname = pChunk->iChunkname; /* fill the fields */ - *iPolarity = pChunk->iPolarity; - *iKeywordssize = pChunk->iKeywordssize; - *zKeywords = pChunk->zKeywords; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_DBYK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_ordr (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 *iCount) -{ - mng_datap pData; - mng_ordrp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ordrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_ORDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iCount = pChunk->iCount; /* fill the field */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_ordr_entry (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iEntry, - mng_chunkid *iChunkname, - mng_uint8 *iOrdertype) -{ - mng_datap pData; - mng_ordrp pChunk; - mng_ordr_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_ordrp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_ORDR) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - if (iEntry >= pChunk->iCount) /* valid index ? */ - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - - pEntry = pChunk->pEntries + iEntry; /* address the proper entry */ - - *iChunkname = pEntry->iChunkname; /* fill the fields */ - *iOrdertype = pEntry->iOrdertype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_ORDR_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_magn (mng_handle hHandle, - mng_handle hChunk, - mng_uint16 *iFirstid, - mng_uint16 *iLastid, - mng_uint16 *iMethodX, - mng_uint16 *iMX, - mng_uint16 *iMY, - mng_uint16 *iML, - mng_uint16 *iMR, - mng_uint16 *iMT, - mng_uint16 *iMB, - mng_uint16 *iMethodY) -{ - mng_datap pData; - mng_magnp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MAGN, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_magnp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.iChunkname != MNG_UINT_MAGN) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - - *iFirstid = pChunk->iFirstid; /* fill the fields */ - *iLastid = pChunk->iLastid; - *iMethodX = pChunk->iMethodX; - *iMX = pChunk->iMX; - *iMY = pChunk->iMY; - *iML = pChunk->iML; - *iMR = pChunk->iMR; - *iMT = pChunk->iMT; - *iMB = pChunk->iMB; - *iMethodY = pChunk->iMethodY; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getchunk_unknown (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid *iChunkname, - mng_uint32 *iRawlen, - mng_ptr *pRawdata) -{ - mng_datap pData; - mng_unknown_chunkp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_UNKNOWN, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - pChunk = (mng_unknown_chunkp)hChunk; /* address the chunk */ - - if (pChunk->sHeader.fCreate != init_unknown) - MNG_ERROR (pData, MNG_WRONGCHUNK) /* ouch */ - /* fill the fields */ - *iChunkname = pChunk->sHeader.iChunkname; - *iRawlen = pChunk->iDatasize; - *pRawdata = pChunk->pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETCHUNK_UNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_WRITE_PROCS -/* B004 */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_IHDR, init_ihdr, free_ihdr, read_ihdr, write_ihdr, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* create the chunk */ - iRetcode = init_ihdr (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ihdrp)pChunk)->iWidth = iWidth; - ((mng_ihdrp)pChunk)->iHeight = iHeight; - ((mng_ihdrp)pChunk)->iBitdepth = iBitdepth; - ((mng_ihdrp)pChunk)->iColortype = iColortype; - ((mng_ihdrp)pChunk)->iCompression = iCompression; - ((mng_ihdrp)pChunk)->iFilter = iFilter; - ((mng_ihdrp)pChunk)->iInterlace = iInterlace; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_plte (mng_handle hHandle, - mng_uint32 iCount, - mng_palette8 aPalette) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_PLTE, init_plte, free_plte, read_plte, write_plte, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PLTE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_plte (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_pltep)pChunk)->iEntrycount = iCount; - ((mng_pltep)pChunk)->bEmpty = (mng_bool)(iCount == 0); - - MNG_COPY (((mng_pltep)pChunk)->aEntries, aPalette, sizeof (mng_palette8)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_idat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_IDAT, init_idat, free_idat, read_idat, write_idat, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_idat (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_idatp)pChunk)->bEmpty = (mng_bool)(iRawlen == 0); - ((mng_idatp)pChunk)->iDatasize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_idatp)pChunk)->pData, iRawlen) - MNG_COPY (((mng_idatp)pChunk)->pData, pRawdata, iRawlen) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_iend (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_IEND, init_iend, free_iend, read_iend, write_iend, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IEND, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_iend (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_INCLUDE_JNG - if ((pData->iFirstchunkadded == MNG_UINT_IHDR) || - (pData->iFirstchunkadded == MNG_UINT_JHDR) ) -#else - if (pData->iFirstchunkadded == MNG_UINT_IHDR) -#endif - pData->bCreating = MNG_FALSE; /* should be last chunk !!! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_trns (mng_handle hHandle, - mng_bool bEmpty, - mng_bool bGlobal, - mng_uint8 iType, - mng_uint32 iCount, - mng_uint8arr aAlphas, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint32 iRawlen, - mng_uint8arr aRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_tRNS, init_trns, free_trns, read_trns, write_trns, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TRNS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_trns (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_trnsp)pChunk)->bEmpty = bEmpty; - ((mng_trnsp)pChunk)->bGlobal = bGlobal; - ((mng_trnsp)pChunk)->iType = iType; - ((mng_trnsp)pChunk)->iCount = iCount; - ((mng_trnsp)pChunk)->iGray = iGray; - ((mng_trnsp)pChunk)->iRed = iRed; - ((mng_trnsp)pChunk)->iGreen = iGreen; - ((mng_trnsp)pChunk)->iBlue = iBlue; - ((mng_trnsp)pChunk)->iRawlen = iRawlen; - - MNG_COPY (((mng_trnsp)pChunk)->aEntries, aAlphas, sizeof (mng_uint8arr)) - MNG_COPY (((mng_trnsp)pChunk)->aRawdata, aRawdata, sizeof (mng_uint8arr)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_gama (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iGamma) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_gAMA, init_gama, free_gama, read_gama, write_gama, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_GAMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_gama (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_gamap)pChunk)->bEmpty = bEmpty; - ((mng_gamap)pChunk)->iGamma = iGamma; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_chrm (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_cHRM, init_chrm, free_chrm, read_chrm, write_chrm, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CHRM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_chrm (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_chrmp)pChunk)->bEmpty = bEmpty; - ((mng_chrmp)pChunk)->iWhitepointx = iWhitepointx; - ((mng_chrmp)pChunk)->iWhitepointy = iWhitepointy; - ((mng_chrmp)pChunk)->iRedx = iRedx; - ((mng_chrmp)pChunk)->iRedy = iRedy; - ((mng_chrmp)pChunk)->iGreenx = iGreenx; - ((mng_chrmp)pChunk)->iGreeny = iGreeny; - ((mng_chrmp)pChunk)->iBluex = iBluex; - ((mng_chrmp)pChunk)->iBluey = iBluey; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_srgb (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iRenderingintent) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_sRGB, init_srgb, free_srgb, read_srgb, write_srgb, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_srgb (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_srgbp)pChunk)->bEmpty = bEmpty; - ((mng_srgbp)pChunk)->iRenderingintent = iRenderingintent; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_iccp (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iCompression, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_iCCP, init_iccp, free_iccp, read_iccp, write_iccp, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ICCP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_iccp (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_iccpp)pChunk)->bEmpty = bEmpty; - ((mng_iccpp)pChunk)->iNamesize = iNamesize; - ((mng_iccpp)pChunk)->iCompression = iCompression; - ((mng_iccpp)pChunk)->iProfilesize = iProfilesize; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_iccpp)pChunk)->zName, iNamesize + 1) - MNG_COPY (((mng_iccpp)pChunk)->zName, zName, iNamesize) - } - - if (iProfilesize) - { - MNG_ALLOC (pData, ((mng_iccpp)pChunk)->pProfile, iProfilesize) - MNG_COPY (((mng_iccpp)pChunk)->pProfile, pProfile, iProfilesize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_text (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint32 iTextsize, - mng_pchar zText) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_tEXt, init_text, free_text, read_text, write_text, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TEXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_text (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_textp)pChunk)->iKeywordsize = iKeywordsize; - ((mng_textp)pChunk)->iTextsize = iTextsize; - - if (iKeywordsize) - { - MNG_ALLOC (pData, ((mng_textp)pChunk)->zKeyword, iKeywordsize + 1) - MNG_COPY (((mng_textp)pChunk)->zKeyword, zKeyword, iKeywordsize) - } - - if (iTextsize) - { - MNG_ALLOC (pData, ((mng_textp)pChunk)->zText, iTextsize + 1) - MNG_COPY (((mng_textp)pChunk)->zText, zText, iTextsize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TEXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ztxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompression, - mng_uint32 iTextsize, - mng_pchar zText) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_zTXt, init_ztxt, free_ztxt, read_ztxt, write_ztxt, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ZTXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_ztxt (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ztxtp)pChunk)->iKeywordsize = iKeywordsize; - ((mng_ztxtp)pChunk)->iCompression = iCompression; - ((mng_ztxtp)pChunk)->iTextsize = iTextsize; - - if (iKeywordsize) - { - MNG_ALLOC (pData, ((mng_ztxtp)pChunk)->zKeyword, iKeywordsize + 1) - MNG_COPY (((mng_ztxtp)pChunk)->zKeyword, zKeyword, iKeywordsize) - } - - if (iTextsize) - { - MNG_ALLOC (pData, ((mng_ztxtp)pChunk)->zText, iTextsize + 1) - MNG_COPY (((mng_ztxtp)pChunk)->zText, zText, iTextsize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ZTXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_itxt (mng_handle hHandle, - mng_uint32 iKeywordsize, - mng_pchar zKeyword, - mng_uint8 iCompressionflag, - mng_uint8 iCompressionmethod, - mng_uint32 iLanguagesize, - mng_pchar zLanguage, - mng_uint32 iTranslationsize, - mng_pchar zTranslation, - mng_uint32 iTextsize, - mng_pchar zText) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_iTXt, init_itxt, free_itxt, read_itxt, write_itxt, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ITXT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_itxt (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_itxtp)pChunk)->iKeywordsize = iKeywordsize; - ((mng_itxtp)pChunk)->iCompressionflag = iCompressionflag; - ((mng_itxtp)pChunk)->iCompressionmethod = iCompressionmethod; - ((mng_itxtp)pChunk)->iLanguagesize = iLanguagesize; - ((mng_itxtp)pChunk)->iTranslationsize = iTranslationsize; - ((mng_itxtp)pChunk)->iTextsize = iTextsize; - - if (iKeywordsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zKeyword, iKeywordsize + 1) - MNG_COPY (((mng_itxtp)pChunk)->zKeyword, zKeyword, iKeywordsize) - } - - if (iLanguagesize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zLanguage, iLanguagesize + 1) - MNG_COPY (((mng_itxtp)pChunk)->zLanguage, zLanguage, iLanguagesize) - } - - if (iTranslationsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zTranslation, iTranslationsize + 1) - MNG_COPY (((mng_itxtp)pChunk)->zTranslation, zTranslation, iTranslationsize) - } - - if (iTextsize) - { - MNG_ALLOC (pData, ((mng_itxtp)pChunk)->zText, iTextsize + 1) - MNG_COPY (((mng_itxtp)pChunk)->zText, zText, iTextsize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ITXT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_bkgd (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8 iIndex, - mng_uint16 iGray, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_bKGD, init_bkgd, free_bkgd, read_bkgd, write_bkgd, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BKGD, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_bkgd (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_bkgdp)pChunk)->bEmpty = bEmpty; - ((mng_bkgdp)pChunk)->iType = iType; - ((mng_bkgdp)pChunk)->iIndex = iIndex; - ((mng_bkgdp)pChunk)->iGray = iGray; - ((mng_bkgdp)pChunk)->iRed = iRed; - ((mng_bkgdp)pChunk)->iGreen = iGreen; - ((mng_bkgdp)pChunk)->iBlue = iBlue; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_phys (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_pHYs, init_phys, free_phys, read_phys, write_phys, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_phys (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_physp)pChunk)->bEmpty = bEmpty; - ((mng_physp)pChunk)->iSizex = iSizex; - ((mng_physp)pChunk)->iSizey = iSizey; - ((mng_physp)pChunk)->iUnit = iUnit; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_sbit (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iType, - mng_uint8arr4 aBits) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_sBIT, init_sbit, free_sbit, read_sbit, write_sbit, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SBIT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_sbit (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_sbitp)pChunk)->bEmpty = bEmpty; - ((mng_sbitp)pChunk)->iType = iType; - ((mng_sbitp)pChunk)->aBits[0] = aBits[0]; - ((mng_sbitp)pChunk)->aBits[1] = aBits[1]; - ((mng_sbitp)pChunk)->aBits[2] = aBits[2]; - ((mng_sbitp)pChunk)->aBits[3] = aBits[3]; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SBIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_splt (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iSampledepth, - mng_uint32 iEntrycount, - mng_ptr pEntries) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_sPLT, init_splt, free_splt, read_splt, write_splt, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SPLT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_splt (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_spltp)pChunk)->bEmpty = bEmpty; - ((mng_spltp)pChunk)->iNamesize = iNamesize; - ((mng_spltp)pChunk)->iSampledepth = iSampledepth; - ((mng_spltp)pChunk)->iEntrycount = iEntrycount; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_spltp)pChunk)->zName, iNamesize + 1) - MNG_COPY (((mng_spltp)pChunk)->zName, zName, iNamesize) - } - - if (iEntrycount) - { - mng_uint32 iSize = iEntrycount * ((iSampledepth >> 1) + 2); - - MNG_ALLOC (pData, ((mng_spltp)pChunk)->pEntries, iSize) - MNG_COPY (((mng_spltp)pChunk)->pEntries, pEntries, iSize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_hist (mng_handle hHandle, - mng_uint32 iEntrycount, - mng_uint16arr aEntries) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_hIST, init_hist, free_hist, read_hist, write_hist, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_HIST, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_hist (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_histp)pChunk)->iEntrycount = iEntrycount; - - MNG_COPY (((mng_histp)pChunk)->aEntries, aEntries, sizeof (mng_uint16arr)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_HIST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_time (mng_handle hHandle, - mng_uint16 iYear, - mng_uint8 iMonth, - mng_uint8 iDay, - mng_uint8 iHour, - mng_uint8 iMinute, - mng_uint8 iSecond) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_tIME, init_time, free_time, read_time, write_time, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TIME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_time (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_timep)pChunk)->iYear = iYear; - ((mng_timep)pChunk)->iMonth = iMonth; - ((mng_timep)pChunk)->iDay = iDay; - ((mng_timep)pChunk)->iHour = iHour; - ((mng_timep)pChunk)->iMinute = iMinute; - ((mng_timep)pChunk)->iSecond = iSecond; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TIME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_mhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint32 iTicks, - mng_uint32 iLayercount, - mng_uint32 iFramecount, - mng_uint32 iPlaytime, - mng_uint32 iSimplicity) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_MHDR, init_mhdr, free_mhdr, read_mhdr, write_mhdr, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* create the chunk */ - iRetcode = init_mhdr (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_mhdrp)pChunk)->iWidth = iWidth; - ((mng_mhdrp)pChunk)->iHeight = iHeight; - ((mng_mhdrp)pChunk)->iTicks = iTicks; - ((mng_mhdrp)pChunk)->iLayercount = iLayercount; - ((mng_mhdrp)pChunk)->iFramecount = iFramecount; - ((mng_mhdrp)pChunk)->iPlaytime = iPlaytime; - ((mng_mhdrp)pChunk)->iSimplicity = iSimplicity; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_mend (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_MEND, init_mend, free_mend, read_mend, write_mend, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MEND, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_mend (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - add_chunk (pData, pChunk); /* add it to the list */ - - pData->bCreating = MNG_FALSE; /* should be last chunk !!! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_loop (mng_handle hHandle, - mng_uint8 iLevel, - mng_uint32 iRepeat, - mng_uint8 iTermination, - mng_uint32 iItermin, - mng_uint32 iItermax, - mng_uint32 iCount, - mng_uint32p pSignals) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_LOOP, init_loop, free_loop, read_loop, write_loop, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_LOOP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_loop (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_loopp)pChunk)->iLevel = iLevel; - ((mng_loopp)pChunk)->iRepeat = iRepeat; - ((mng_loopp)pChunk)->iTermination = iTermination; - ((mng_loopp)pChunk)->iItermin = iItermin; - ((mng_loopp)pChunk)->iItermax = iItermax; - ((mng_loopp)pChunk)->iCount = iCount; - ((mng_loopp)pChunk)->pSignals = pSignals; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_endl (mng_handle hHandle, - mng_uint8 iLevel) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_ENDL, init_endl, free_endl, read_endl, write_endl, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ENDL, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_endl (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_endlp)pChunk)->iLevel = iLevel; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_defi (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_int32 iXlocation, - mng_int32 iYlocation, - mng_bool bHasclip, - mng_int32 iLeftcb, - mng_int32 iRightcb, - mng_int32 iTopcb, - mng_int32 iBottomcb) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_DEFI, init_defi, free_defi, read_defi, write_defi, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DEFI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_defi (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_defip)pChunk)->iObjectid = iObjectid; - ((mng_defip)pChunk)->iDonotshow = iDonotshow; - ((mng_defip)pChunk)->iConcrete = iConcrete; - ((mng_defip)pChunk)->bHasloca = bHasloca; - ((mng_defip)pChunk)->iXlocation = iXlocation; - ((mng_defip)pChunk)->iYlocation = iYlocation; - ((mng_defip)pChunk)->bHasclip = bHasclip; - ((mng_defip)pChunk)->iLeftcb = iLeftcb; - ((mng_defip)pChunk)->iRightcb = iRightcb; - ((mng_defip)pChunk)->iTopcb = iTopcb; - ((mng_defip)pChunk)->iBottomcb = iBottomcb; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_basi (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha, - mng_uint8 iViewable) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_BASI, init_basi, free_basi, read_basi, write_basi, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BASI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_basi (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_basip)pChunk)->iWidth = iWidth; - ((mng_basip)pChunk)->iHeight = iHeight; - ((mng_basip)pChunk)->iBitdepth = iBitdepth; - ((mng_basip)pChunk)->iColortype = iColortype; - ((mng_basip)pChunk)->iCompression = iCompression; - ((mng_basip)pChunk)->iFilter = iFilter; - ((mng_basip)pChunk)->iInterlace = iInterlace; - ((mng_basip)pChunk)->iRed = iRed; - ((mng_basip)pChunk)->iGreen = iGreen; - ((mng_basip)pChunk)->iBlue = iBlue; - ((mng_basip)pChunk)->iAlpha = iAlpha; - ((mng_basip)pChunk)->iViewable = iViewable; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_clon (mng_handle hHandle, - mng_uint16 iSourceid, - mng_uint16 iCloneid, - mng_uint8 iClonetype, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_CLON, init_clon, free_clon, read_clon, write_clon, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLON, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_clon (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_clonp)pChunk)->iSourceid = iSourceid; - ((mng_clonp)pChunk)->iCloneid = iCloneid; - ((mng_clonp)pChunk)->iClonetype = iClonetype; - ((mng_clonp)pChunk)->iDonotshow = iDonotshow; - ((mng_clonp)pChunk)->iConcrete = iConcrete; - ((mng_clonp)pChunk)->bHasloca = bHasloca; - ((mng_clonp)pChunk)->iLocationtype = iLocationtype; - ((mng_clonp)pChunk)->iLocationx = iLocationx; - ((mng_clonp)pChunk)->iLocationy = iLocationy; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_past (mng_handle hHandle, - mng_uint16 iDestid, - mng_uint8 iTargettype, - mng_int32 iTargetx, - mng_int32 iTargety, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_PAST, init_past, free_past, read_past, write_past, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_past (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_pastp)pChunk)->iDestid = iDestid; - ((mng_pastp)pChunk)->iTargettype = iTargettype; - ((mng_pastp)pChunk)->iTargetx = iTargetx; - ((mng_pastp)pChunk)->iTargety = iTargety; - ((mng_pastp)pChunk)->iCount = iCount; - - if (iCount) - MNG_ALLOC (pData, ((mng_pastp)pChunk)->pSources, iCount * sizeof (mng_past_source)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_past_src (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iSourceid, - mng_uint8 iComposition, - mng_uint8 iOrientation, - mng_uint8 iOffsettype, - mng_int32 iOffsetx, - mng_int32 iOffsety, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_past_sourcep pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST_SRC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been PAST ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_PAST) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= ((mng_pastp)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = ((mng_pastp)pChunk)->pSources + iEntry; - - pEntry->iSourceid = iSourceid; /* fill entry */ - pEntry->iComposition = iComposition; - pEntry->iOrientation = iOrientation; - pEntry->iOffsettype = iOffsettype; - pEntry->iOffsetx = iOffsetx; - pEntry->iOffsety = iOffsety; - pEntry->iBoundarytype = iBoundarytype; - pEntry->iBoundaryl = iBoundaryl; - pEntry->iBoundaryr = iBoundaryr; - pEntry->iBoundaryt = iBoundaryt; - pEntry->iBoundaryb = iBoundaryb; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PAST_SRC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_disc (mng_handle hHandle, - mng_uint32 iCount, - mng_uint16p pObjectids) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_DISC, init_disc, free_disc, read_disc, write_disc, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DISC, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_disc (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_discp)pChunk)->iCount = iCount; - - if (iCount) - { - mng_uint32 iSize = iCount * sizeof (mng_uint32); - - MNG_ALLOC (pData, ((mng_discp)pChunk)->pObjectids, iSize); - MNG_COPY (((mng_discp)pChunk)->pObjectids, pObjectids, iSize); - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_back (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_BACK, init_back, free_back, read_back, write_back, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BACK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_back (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_backp)pChunk)->iRed = iRed; - ((mng_backp)pChunk)->iGreen = iGreen; - ((mng_backp)pChunk)->iBlue = iBlue; - ((mng_backp)pChunk)->iMandatory = iMandatory; - ((mng_backp)pChunk)->iImageid = iImageid; - ((mng_backp)pChunk)->iTile = iTile; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_fram (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iMode, - mng_uint32 iNamesize, - mng_pchar zName, - mng_uint8 iChangedelay, - mng_uint8 iChangetimeout, - mng_uint8 iChangeclipping, - mng_uint8 iChangesyncid, - mng_uint32 iDelay, - mng_uint32 iTimeout, - mng_uint8 iBoundarytype, - mng_int32 iBoundaryl, - mng_int32 iBoundaryr, - mng_int32 iBoundaryt, - mng_int32 iBoundaryb, - mng_uint32 iCount, - mng_uint32p pSyncids) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_FRAM, init_fram, free_fram, read_fram, write_fram, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FRAM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_fram (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_framp)pChunk)->bEmpty = bEmpty; - ((mng_framp)pChunk)->iMode = iMode; - ((mng_framp)pChunk)->iNamesize = iNamesize; - ((mng_framp)pChunk)->iChangedelay = iChangedelay; - ((mng_framp)pChunk)->iChangetimeout = iChangetimeout; - ((mng_framp)pChunk)->iChangeclipping = iChangeclipping; - ((mng_framp)pChunk)->iChangesyncid = iChangesyncid; - ((mng_framp)pChunk)->iDelay = iDelay; - ((mng_framp)pChunk)->iTimeout = iTimeout; - ((mng_framp)pChunk)->iBoundarytype = iBoundarytype; - ((mng_framp)pChunk)->iBoundaryl = iBoundaryl; - ((mng_framp)pChunk)->iBoundaryr = iBoundaryr; - ((mng_framp)pChunk)->iBoundaryt = iBoundaryt; - ((mng_framp)pChunk)->iBoundaryb = iBoundaryb; - ((mng_framp)pChunk)->iCount = iCount; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_framp)pChunk)->zName, iNamesize + 1) - MNG_COPY (((mng_framp)pChunk)->zName, zName, iNamesize) - } - - if (iCount) - { - mng_uint32 iSize = iCount * sizeof (mng_uint32); - - MNG_ALLOC (pData, ((mng_framp)pChunk)->pSyncids, iSize) - MNG_COPY (((mng_framp)pChunk)->pSyncids, pSyncids, iSize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_move (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_MOVE, init_move, free_move, read_move, write_move, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MOVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_move (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_movep)pChunk)->iFirstid = iFirstid; - ((mng_movep)pChunk)->iLastid = iLastid; - ((mng_movep)pChunk)->iMovetype = iMovetype; - ((mng_movep)pChunk)->iMovex = iMovex; - ((mng_movep)pChunk)->iMovey = iMovey; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_clip (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_CLIP, init_clip, free_clip, read_clip, write_clip, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLIP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_clip (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_clipp)pChunk)->iFirstid = iFirstid; - ((mng_clipp)pChunk)->iLastid = iLastid; - ((mng_clipp)pChunk)->iCliptype = iCliptype; - ((mng_clipp)pChunk)->iClipl = iClipl; - ((mng_clipp)pChunk)->iClipr = iClipr; - ((mng_clipp)pChunk)->iClipt = iClipt; - ((mng_clipp)pChunk)->iClipb = iClipb; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_show (mng_handle hHandle, - mng_bool bEmpty, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_SHOW, init_show, free_show, read_show, write_show, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SHOW, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_show (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_showp)pChunk)->bEmpty = bEmpty; - ((mng_showp)pChunk)->iFirstid = iFirstid; - ((mng_showp)pChunk)->iLastid = iLastid; - ((mng_showp)pChunk)->iMode = iMode; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_term (mng_handle hHandle, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_TERM, init_term, free_term, read_term, write_term, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TERM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_term (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_termp)pChunk)->iTermaction = iTermaction; - ((mng_termp)pChunk)->iIteraction = iIteraction; - ((mng_termp)pChunk)->iDelay = iDelay; - ((mng_termp)pChunk)->iItermax = iItermax; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_save (mng_handle hHandle, - mng_bool bEmpty, - mng_uint8 iOffsettype, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_SAVE, init_save, free_save, read_save, write_save, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_save (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_savep)pChunk)->bEmpty = bEmpty; - ((mng_savep)pChunk)->iOffsettype = iOffsettype; - ((mng_savep)pChunk)->iCount = iCount; - - if (iCount) - MNG_ALLOC (pData, ((mng_savep)pChunk)->pEntries, iCount * sizeof (mng_save_entry)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_save_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint8 iEntrytype, - mng_uint32arr2 iOffset, - mng_uint32arr2 iStarttime, - mng_uint32 iLayernr, - mng_uint32 iFramenr, - mng_uint32 iNamesize, - mng_pchar zName) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_save_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been SAVE ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_SAVE) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= ((mng_savep)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = ((mng_savep)pChunk)->pEntries + iEntry; - - pEntry->iEntrytype = iEntrytype; /* fill entry */ - pEntry->iOffset[0] = iOffset[0]; - pEntry->iOffset[1] = iOffset[1]; - pEntry->iStarttime[0] = iStarttime[0]; - pEntry->iStarttime[1] = iStarttime[1]; - pEntry->iLayernr = iLayernr; - pEntry->iFramenr = iFramenr; - pEntry->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, pEntry->zName, iNamesize + 1) - MNG_COPY (pEntry->zName, zName, iNamesize) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SAVE_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_seek (mng_handle hHandle, - mng_uint32 iNamesize, - mng_pchar zName) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_SEEK, init_seek, free_seek, read_seek, write_seek, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SEEK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_seek (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_seekp)pChunk)->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_seekp)pChunk)->zName, iNamesize + 1) - MNG_COPY (((mng_seekp)pChunk)->zName, zName, iNamesize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_expi (mng_handle hHandle, - mng_uint16 iSnapshotid, - mng_uint32 iNamesize, - mng_pchar zName) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_eXPI, init_expi, free_expi, read_expi, write_expi, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EXPI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_expi (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_expip)pChunk)->iSnapshotid = iSnapshotid; - ((mng_expip)pChunk)->iNamesize = iNamesize; - - if (iNamesize) - { - MNG_ALLOC (pData, ((mng_expip)pChunk)->zName, iNamesize + 1) - MNG_COPY (((mng_expip)pChunk)->zName, zName, iNamesize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_EXPI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_fpri (mng_handle hHandle, - mng_uint8 iDeltatype, - mng_uint8 iPriority) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_fPRI, init_fpri, free_fpri, read_fpri, write_fpri, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FPRI, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_fpri (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_fprip)pChunk)->iDeltatype = iDeltatype; - ((mng_fprip)pChunk)->iPriority = iPriority; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_FPRI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_need (mng_handle hHandle, - mng_uint32 iKeywordssize, - mng_pchar zKeywords) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_nEED, init_need, free_need, read_need, write_need, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_NEED, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_need (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_needp)pChunk)->iKeywordssize = iKeywordssize; - - if (iKeywordssize) - { - MNG_ALLOC (pData, ((mng_needp)pChunk)->zKeywords, iKeywordssize + 1) - MNG_COPY (((mng_needp)pChunk)->zKeywords, zKeywords, iKeywordssize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_NEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_phyg (mng_handle hHandle, - mng_bool bEmpty, - mng_uint32 iSizex, - mng_uint32 iSizey, - mng_uint8 iUnit) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_pHYg, init_phyg, free_phyg, read_phyg, write_phyg, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYG, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_phyg (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_phygp)pChunk)->bEmpty = bEmpty; - ((mng_phygp)pChunk)->iSizex = iSizex; - ((mng_phygp)pChunk)->iSizey = iSizey; - ((mng_phygp)pChunk)->iUnit = iUnit; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PHYG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -mng_retcode MNG_DECL mng_putchunk_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iImagesampledepth, - mng_uint8 iImagecompression, - mng_uint8 iImageinterlace, - mng_uint8 iAlphasampledepth, - mng_uint8 iAlphacompression, - mng_uint8 iAlphafilter, - mng_uint8 iAlphainterlace) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_JHDR, init_jhdr, free_jhdr, read_jhdr, write_jhdr, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* create the chunk */ - iRetcode = init_jhdr (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_jhdrp)pChunk)->iWidth = iWidth; - ((mng_jhdrp)pChunk)->iHeight = iHeight; - ((mng_jhdrp)pChunk)->iColortype = iColortype; - ((mng_jhdrp)pChunk)->iImagesampledepth = iImagesampledepth; - ((mng_jhdrp)pChunk)->iImagecompression = iImagecompression; - ((mng_jhdrp)pChunk)->iImageinterlace = iImageinterlace; - ((mng_jhdrp)pChunk)->iAlphasampledepth = iAlphasampledepth; - ((mng_jhdrp)pChunk)->iAlphacompression = iAlphacompression; - ((mng_jhdrp)pChunk)->iAlphafilter = iAlphafilter; - ((mng_jhdrp)pChunk)->iAlphainterlace = iAlphainterlace; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -mng_retcode MNG_DECL mng_putchunk_jdat (mng_handle hHandle, - mng_uint32 iRawlen, - mng_ptr pRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_JDAT, init_jdat, free_jdat, read_jdat, write_jdat, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR or JHDR first! */ - if ((pData->iFirstchunkadded != MNG_UINT_MHDR) && - (pData->iFirstchunkadded != MNG_UINT_JHDR) ) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_jdat (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_jdatp)pChunk)->iDatasize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_jdatp)pChunk)->pData, iRawlen) - MNG_COPY (((mng_jdatp)pChunk)->pData, pRawdata, iRawlen) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_JNG -/* B004 */ -mng_retcode MNG_DECL mng_putchunk_jsep (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_JSEP, init_jsep, free_jsep, read_jsep, write_jsep, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JSEP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR or JHDR first! */ - if ((pData->iFirstchunkadded != MNG_UINT_MHDR) && - (pData->iFirstchunkadded != MNG_UINT_JHDR) ) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_jsep (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_JSEP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -/* B004 */ -#endif /* MNG_INCLUDE_JNG */ -/* B004 */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_dhdr (mng_handle hHandle, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_DHDR, init_dhdr, free_dhdr, read_dhdr, write_dhdr, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DHDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_dhdr (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_dhdrp)pChunk)->iObjectid = iObjectid; - ((mng_dhdrp)pChunk)->iImagetype = iImagetype; - ((mng_dhdrp)pChunk)->iDeltatype = iDeltatype; - ((mng_dhdrp)pChunk)->iBlockwidth = iBlockwidth; - ((mng_dhdrp)pChunk)->iBlockheight = iBlockheight; - ((mng_dhdrp)pChunk)->iBlockx = iBlockx; - ((mng_dhdrp)pChunk)->iBlocky = iBlocky; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_prom (mng_handle hHandle, - mng_uint8 iColortype, - mng_uint8 iSampledepth, - mng_uint8 iFilltype) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_PROM, init_prom, free_prom, read_prom, write_prom, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PROM, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_prom (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_promp)pChunk)->iColortype = iColortype; - ((mng_promp)pChunk)->iSampledepth = iSampledepth; - ((mng_promp)pChunk)->iFilltype = iFilltype; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ipng (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_IPNG, init_ipng, free_ipng, read_ipng, write_ipng, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IPNG, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_ipng (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_pplt (mng_handle hHandle, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_PPLT, init_pplt, free_pplt, read_pplt, write_pplt, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_pplt (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ppltp)pChunk)->iCount = iCount; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_pplt_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint16 iAlpha, - mng_bool bUsed) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_pplt_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been PPLT ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_PPLT) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - - /* index out of bounds ? */ - if (iEntry >= ((mng_ppltp)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = (mng_pplt_entryp)(((mng_ppltp)pChunk)->aEntries) + iEntry; - - pEntry->iRed = (mng_uint8)iRed; /* fill the entry */ - pEntry->iGreen = (mng_uint8)iGreen; - pEntry->iBlue = (mng_uint8)iBlue; - pEntry->iAlpha = (mng_uint8)iAlpha; - pEntry->bUsed = bUsed; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_PPLT_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ijng (mng_handle hHandle) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_IJNG, init_ijng, free_ijng, read_ijng, write_ijng, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IJNG, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_ijng (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_drop (mng_handle hHandle, - mng_uint32 iCount, - mng_chunkidp pChunknames) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_DROP, init_drop, free_drop, read_drop, write_drop, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DROP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_drop (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_dropp)pChunk)->iCount = iCount; - - if (iCount) - { - mng_uint32 iSize = iCount * sizeof (mng_chunkid); - - MNG_ALLOC (pData, ((mng_dropp)pChunk)->pChunknames, iSize) - MNG_COPY (((mng_dropp)pChunk)->pChunknames, pChunknames, iSize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DROP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_dbyk (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint8 iPolarity, - mng_uint32 iKeywordssize, - mng_pchar zKeywords) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_DBYK, init_dbyk, free_dbyk, read_dbyk, write_dbyk, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DBYK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_dbyk (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_dbykp)pChunk)->iChunkname = iChunkname; - ((mng_dbykp)pChunk)->iPolarity = iPolarity; - ((mng_dbykp)pChunk)->iKeywordssize = iKeywordssize; - - if (iKeywordssize) - { - MNG_ALLOC (pData, ((mng_dbykp)pChunk)->zKeywords, iKeywordssize + 1) - MNG_COPY (((mng_dbykp)pChunk)->zKeywords, zKeywords, iKeywordssize) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_DBYK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ordr (mng_handle hHandle, - mng_uint32 iCount) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_ORDR, init_ordr, free_ordr, read_ordr, write_ordr, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_ordr (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_ordrp)pChunk)->iCount = iCount; - - if (iCount) - MNG_ALLOC (pData, ((mng_ordrp)pChunk)->pEntries, iCount * sizeof (mng_ordr_entry)) - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_ordr_entry (mng_handle hHandle, - mng_uint32 iEntry, - mng_chunkid iChunkname, - mng_uint8 iOrdertype) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_ordr_entryp pEntry; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR_ENTRY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - - pChunk = pData->pLastchunk; /* last one must have been ORDR ! */ - - if (((mng_chunk_headerp)pChunk)->iChunkname != MNG_UINT_ORDR) - MNG_ERROR (pData, MNG_NOCORRCHUNK) - /* index out of bounds ? */ - if (iEntry >= ((mng_ordrp)pChunk)->iCount) - MNG_ERROR (pData, MNG_INVALIDENTRYIX) - /* address proper entry */ - pEntry = ((mng_ordrp)pChunk)->pEntries + iEntry; - - pEntry->iChunkname = iChunkname; /* fill the entry */ - pEntry->iOrdertype = iOrdertype; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_ORDR_ENTRY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_magn (mng_handle hHandle, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_MAGN, init_magn, free_magn, read_magn, write_magn, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MAGN, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a MHDR first! */ - if (pData->iFirstchunkadded != MNG_UINT_MHDR) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_magn (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_magnp)pChunk)->iFirstid = iFirstid; - ((mng_magnp)pChunk)->iLastid = iLastid; - ((mng_magnp)pChunk)->iMethodX = iMethodX; - ((mng_magnp)pChunk)->iMX = iMX; - ((mng_magnp)pChunk)->iMY = iMY; - ((mng_magnp)pChunk)->iML = iML; - ((mng_magnp)pChunk)->iMR = iMR; - ((mng_magnp)pChunk)->iMT = iMT; - ((mng_magnp)pChunk)->iMB = iMB; - ((mng_magnp)pChunk)->iMethodY = iMethodY; - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putchunk_unknown (mng_handle hHandle, - mng_chunkid iChunkname, - mng_uint32 iRawlen, - mng_ptr pRawdata) -{ - mng_datap pData; - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_chunk_header sChunkheader = - {MNG_UINT_HUH, init_unknown, free_unknown, read_unknown, write_unknown, 0, 0}; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_UNKNOWN, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must have had a header first! */ - if (pData->iFirstchunkadded == 0) - MNG_ERROR (pData, MNG_NOHEADER) - /* create the chunk */ - iRetcode = init_unknown (pData, &sChunkheader, &pChunk); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fill the chunk */ - ((mng_unknown_chunkp)pChunk)->sHeader.iChunkname = iChunkname; - ((mng_unknown_chunkp)pChunk)->iDatasize = iRawlen; - - if (iRawlen) - { - MNG_ALLOC (pData, ((mng_unknown_chunkp)pChunk)->pData, iRawlen) - MNG_COPY (((mng_unknown_chunkp)pChunk)->pData, pRawdata, iRawlen) - } - - add_chunk (pData, pChunk); /* add it to the list */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTCHUNK_UNKNOWN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#endif /* MNG_INCLUDE_WRITE_PROCS */ -/* B004 */ -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getimgdata_seq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_SEQ, MNG_LC_START) -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_SEQ, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getimgdata_chunkseq (mng_handle hHandle, - mng_uint32 iSeqnr, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNKSEQ, MNG_LC_START) -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNKSEQ, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getimgdata_chunk (mng_handle hHandle, - mng_handle hChunk, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNK, MNG_LC_START) -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETIMGDATA_CHUNK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ -/* B004 */ -#ifdef MNG_INCLUDE_WRITE_PROCS -/* B004 */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putimgdata_ihdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_IHDR, MNG_LC_START) -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_putimgdata_jhdr (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iColortype, - mng_uint8 iBitdepth, - mng_uint8 iCompression, - mng_uint8 iInterlace, - mng_uint8 iAlphaBitdepth, - mng_uint8 iAlphaCompression, - mng_uint8 iAlphaFilter, - mng_uint8 iAlphaInterlace, - mng_uint32 iCanvasstyle, - mng_getcanvasline fGetcanvasline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_JHDR, MNG_LC_START) -#endif - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_PUTIMGDATA_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_updatemngheader (mng_handle hHandle, - mng_uint32 iFramecount, - mng_uint32 iLayercount, - mng_uint32 iPlaytime) -{ - mng_datap pData; - mng_chunkp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGHEADER, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must be a MNG animation! */ - if ((pData->eImagetype != mng_it_mng) || (pData->iFirstchunkadded != MNG_UINT_MHDR)) - MNG_ERROR (pData, MNG_NOMHDR) - - pChunk = pData->pFirstchunk; /* get the first chunk */ - /* and update the variables */ - ((mng_mhdrp)pChunk)->iFramecount = iFramecount; - ((mng_mhdrp)pChunk)->iLayercount = iLayercount; - ((mng_mhdrp)pChunk)->iPlaytime = iPlaytime; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGHEADER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_updatemngsimplicity (mng_handle hHandle, - mng_uint32 iSimplicity) -{ - mng_datap pData; - mng_chunkp pChunk; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGSIMPLICITY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = (mng_datap)hHandle; /* and make it addressable */ - - if (!pData->bCreating) /* aren't we creating a new file ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - /* must be a MNG animation! */ - if ((pData->eImagetype != mng_it_mng) || (pData->iFirstchunkadded != MNG_UINT_MHDR)) - MNG_ERROR (pData, MNG_NOMHDR) - - pChunk = pData->pFirstchunk; /* get the first chunk */ - /* and update the variable */ - ((mng_mhdrp)pChunk)->iSimplicity = iSimplicity; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_UPDATEMNGSIMPLICITY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* B004 */ -#endif /* MNG_INCLUDE_WRITE_PROCS */ -/* B004 */ -/* ************************************************************************** */ - -#endif /* MNG_ACCESS_CHUNKS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_chunks.h b/freeimage241/Source/LibMNG/libmng_chunks.h deleted file mode 100644 index 0fe7871..0000000 --- a/freeimage241/Source/LibMNG/libmng_chunks.h +++ /dev/null @@ -1,759 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_chunks.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Chunk structures (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of known chunk structures * */ -/* * * */ -/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */ -/* * - put in some extra comments * */ -/* * 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - fixed layout for sBIT, PPLT * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed write callback definition * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - fixed layout for PPLT again (missed deltatype ?!?) * */ -/* * * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - removed useless definition (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_chunks_h_ -#define _libmng_chunks_h_ - -/* ************************************************************************** */ - -#ifdef MNG_SWAP_ENDIAN -#define PNG_SIG 0x474e5089L -#define JNG_SIG 0x474e4a8bL -#define MNG_SIG 0x474e4d8aL -#define POST_SIG 0x0a1a0a0dL -#else -#define PNG_SIG 0x89504e47L -#define JNG_SIG 0x8b4a4e47L -#define MNG_SIG 0x8a4d4e47L -#define POST_SIG 0x0d0a1a0aL -#endif - -/* ************************************************************************** */ - -typedef mng_retcode (*mng_createchunk) (mng_datap pData, - mng_chunkp pHeader, - mng_chunkp* ppChunk); - -typedef mng_retcode (*mng_cleanupchunk) (mng_datap pData, - mng_chunkp pHeader); - -typedef mng_retcode (*mng_readchunk) (mng_datap pData, - mng_chunkp pHeader, - mng_uint32 iRawlen, - mng_uint8p pRawdata, - mng_chunkp* pChunk); - -typedef mng_retcode (*mng_writechunk) (mng_datap pData, - mng_chunkp pChunk); - -/* ************************************************************************** */ - -typedef struct { /* generic header */ - mng_chunkid iChunkname; - mng_createchunk fCreate; - mng_cleanupchunk fCleanup; - mng_readchunk fRead; - mng_writechunk fWrite; - mng_chunkp pNext; /* for double-linked list */ - mng_chunkp pPrev; - } mng_chunk_header; -typedef mng_chunk_header * mng_chunk_headerp; - -/* ************************************************************************** */ - -typedef struct { /* IHDR */ - mng_chunk_header sHeader; - mng_uint32 iWidth; - mng_uint32 iHeight; - mng_uint8 iBitdepth; - mng_uint8 iColortype; - mng_uint8 iCompression; - mng_uint8 iFilter; - mng_uint8 iInterlace; - } mng_ihdr; -typedef mng_ihdr * mng_ihdrp; - -/* ************************************************************************** */ - -typedef struct { /* PLTE */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iEntrycount; - mng_rgbpaltab aEntries; - } mng_plte; -typedef mng_plte * mng_pltep; - -/* ************************************************************************** */ - -typedef struct { /* IDAT */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iDatasize; - mng_ptr pData; - } mng_idat; -typedef mng_idat * mng_idatp; - -/* ************************************************************************** */ - -typedef struct { /* IEND */ - mng_chunk_header sHeader; - } mng_iend; -typedef mng_iend * mng_iendp; - -/* ************************************************************************** */ - -typedef struct { /* tRNS */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_bool bGlobal; - mng_uint8 iType; /* colortype (0,2,3) */ - mng_uint32 iCount; - mng_uint8arr aEntries; - mng_uint16 iGray; - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - mng_uint32 iRawlen; - mng_uint8arr aRawdata; - } mng_trns; -typedef mng_trns * mng_trnsp; - -/* ************************************************************************** */ - -typedef struct { /* gAMA */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iGamma; - } mng_gama; -typedef mng_gama * mng_gamap; - -/* ************************************************************************** */ - -typedef struct { /* cHRM */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iWhitepointx; - mng_uint32 iWhitepointy; - mng_uint32 iRedx; - mng_uint32 iRedy; - mng_uint32 iGreenx; - mng_uint32 iGreeny; - mng_uint32 iBluex; - mng_uint32 iBluey; - } mng_chrm; -typedef mng_chrm * mng_chrmp; - -/* ************************************************************************** */ - -typedef struct { /* sRGB */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iRenderingintent; - } mng_srgb; -typedef mng_srgb * mng_srgbp; - -/* ************************************************************************** */ - -typedef struct { /* iCCP */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iNamesize; - mng_pchar zName; - mng_uint8 iCompression; - mng_uint32 iProfilesize; - mng_ptr pProfile; - } mng_iccp; -typedef mng_iccp * mng_iccpp; - -/* ************************************************************************** */ - -typedef struct { /* tEXt */ - mng_chunk_header sHeader; - mng_uint32 iKeywordsize; - mng_pchar zKeyword; - mng_uint32 iTextsize; - mng_pchar zText; - } mng_text; -typedef mng_text * mng_textp; - -/* ************************************************************************** */ - -typedef struct { /* zTXt */ - mng_chunk_header sHeader; - mng_uint32 iKeywordsize; - mng_pchar zKeyword; - mng_uint8 iCompression; - mng_uint32 iTextsize; - mng_pchar zText; - } mng_ztxt; -typedef mng_ztxt * mng_ztxtp; - -/* ************************************************************************** */ - -typedef struct { /* iTXt */ - mng_chunk_header sHeader; - mng_uint32 iKeywordsize; - mng_pchar zKeyword; - mng_uint8 iCompressionflag; - mng_uint8 iCompressionmethod; - mng_uint32 iLanguagesize; - mng_pchar zLanguage; - mng_uint32 iTranslationsize; - mng_pchar zTranslation; - mng_uint32 iTextsize; - mng_pchar zText; - } mng_itxt; -typedef mng_itxt * mng_itxtp; - -/* ************************************************************************** */ - -typedef struct { /* bKGD */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iType; /* 3=indexed, 0=gray, 2=rgb */ - mng_uint8 iIndex; - mng_uint16 iGray; - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - } mng_bkgd; -typedef mng_bkgd * mng_bkgdp; - -/* ************************************************************************** */ - -typedef struct { /* pHYs */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iSizex; - mng_uint32 iSizey; - mng_uint8 iUnit; - } mng_phys; -typedef mng_phys * mng_physp; - -/* ************************************************************************** */ - -typedef struct { /* sBIT */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iType; /* colortype (0,2,3,4,6,10,12,14,16) */ - mng_uint8arr4 aBits; - } mng_sbit; -typedef mng_sbit * mng_sbitp; - -/* ************************************************************************** */ - -typedef struct { /* sPLT */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint32 iNamesize; - mng_pchar zName; - mng_uint8 iSampledepth; - mng_uint32 iEntrycount; - mng_ptr pEntries; - } mng_splt; -typedef mng_splt * mng_spltp; - -/* ************************************************************************** */ - -typedef struct { /* hIST */ - mng_chunk_header sHeader; - mng_uint32 iEntrycount; - mng_uint16arr aEntries; - } mng_hist; -typedef mng_hist * mng_histp; - -/* ************************************************************************** */ - -typedef struct { /* tIME */ - mng_chunk_header sHeader; - mng_uint16 iYear; - mng_uint8 iMonth; - mng_uint8 iDay; - mng_uint8 iHour; - mng_uint8 iMinute; - mng_uint8 iSecond; - } mng_time; -typedef mng_time * mng_timep; - -/* ************************************************************************** */ - -typedef struct { /* MHDR */ - mng_chunk_header sHeader; - mng_uint32 iWidth; - mng_uint32 iHeight; - mng_uint32 iTicks; - mng_uint32 iLayercount; - mng_uint32 iFramecount; - mng_uint32 iPlaytime; - mng_uint32 iSimplicity; - } mng_mhdr; -typedef mng_mhdr * mng_mhdrp; - -/* ************************************************************************** */ - -typedef struct { /* MEND */ - mng_chunk_header sHeader; - } mng_mend; -typedef mng_mend * mng_mendp; - -/* ************************************************************************** */ - -typedef struct { /* LOOP */ - mng_chunk_header sHeader; - mng_uint8 iLevel; - mng_uint32 iRepeat; - mng_uint8 iTermination; - mng_uint32 iItermin; - mng_uint32 iItermax; - mng_uint32 iCount; - mng_uint32p pSignals; - } mng_loop; -typedef mng_loop * mng_loopp; - -/* ************************************************************************** */ - -typedef struct { /* ENDL */ - mng_chunk_header sHeader; - mng_uint8 iLevel; - } mng_endl; -typedef mng_endl * mng_endlp; - -/* ************************************************************************** */ - -typedef struct { /* DEFI */ - mng_chunk_header sHeader; - mng_uint16 iObjectid; - mng_bool bHasdonotshow; - mng_uint8 iDonotshow; - mng_bool bHasconcrete; - mng_uint8 iConcrete; - mng_bool bHasloca; - mng_int32 iXlocation; - mng_int32 iYlocation; - mng_bool bHasclip; - mng_int32 iLeftcb; - mng_int32 iRightcb; - mng_int32 iTopcb; - mng_int32 iBottomcb; - } mng_defi; -typedef mng_defi * mng_defip; - -/* ************************************************************************** */ - -typedef struct { /* BASI */ - mng_chunk_header sHeader; - mng_uint32 iWidth; - mng_uint32 iHeight; - mng_uint8 iBitdepth; - mng_uint8 iColortype; - mng_uint8 iCompression; - mng_uint8 iFilter; - mng_uint8 iInterlace; - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - mng_uint16 iAlpha; - mng_uint8 iViewable; - } mng_basi; -typedef mng_basi * mng_basip; - -/* ************************************************************************** */ - -typedef struct { /* CLON */ - mng_chunk_header sHeader; - mng_uint16 iSourceid; - mng_uint16 iCloneid; - mng_uint8 iClonetype; - mng_uint8 iDonotshow; - mng_uint8 iConcrete; - mng_bool bHasloca; - mng_uint8 iLocationtype; - mng_int32 iLocationx; - mng_int32 iLocationy; - } mng_clon; -typedef mng_clon * mng_clonp; - -/* ************************************************************************** */ - -typedef struct { /* PAST source */ - mng_uint16 iSourceid; - mng_uint8 iComposition; - mng_uint8 iOrientation; - mng_uint8 iOffsettype; - mng_int32 iOffsetx; - mng_int32 iOffsety; - mng_uint8 iBoundarytype; - mng_int32 iBoundaryl; - mng_int32 iBoundaryr; - mng_int32 iBoundaryt; - mng_int32 iBoundaryb; - } mng_past_source; -typedef mng_past_source * mng_past_sourcep; - -typedef struct { /* PAST */ - mng_chunk_header sHeader; - mng_uint16 iDestid; - mng_uint8 iTargettype; - mng_int32 iTargetx; - mng_int32 iTargety; - mng_uint32 iCount; - mng_past_sourcep pSources; - } mng_past; -typedef mng_past * mng_pastp; - -/* ************************************************************************** */ - -typedef struct { /* DISC */ - mng_chunk_header sHeader; - mng_uint32 iCount; - mng_uint16p pObjectids; - } mng_disc; -typedef mng_disc * mng_discp; - -/* ************************************************************************** */ - -typedef struct { /* BACK */ - mng_chunk_header sHeader; - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - mng_uint8 iMandatory; - mng_uint16 iImageid; - mng_uint8 iTile; - } mng_back; -typedef mng_back * mng_backp; - -/* ************************************************************************** */ - -typedef struct { /* FRAM */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iMode; - mng_uint32 iNamesize; - mng_pchar zName; - mng_uint8 iChangedelay; - mng_uint8 iChangetimeout; - mng_uint8 iChangeclipping; - mng_uint8 iChangesyncid; - mng_uint32 iDelay; - mng_uint32 iTimeout; - mng_uint8 iBoundarytype; - mng_int32 iBoundaryl; - mng_int32 iBoundaryr; - mng_int32 iBoundaryt; - mng_int32 iBoundaryb; - mng_uint32 iCount; - mng_uint32p pSyncids; - } mng_fram; -typedef mng_fram * mng_framp; - -/* ************************************************************************** */ - -typedef struct { /* MOVE */ - mng_chunk_header sHeader; - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iMovetype; - mng_int32 iMovex; - mng_int32 iMovey; - } mng_move; -typedef mng_move * mng_movep; - -/* ************************************************************************** */ - -typedef struct { /* CLIP */ - mng_chunk_header sHeader; - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iCliptype; - mng_int32 iClipl; - mng_int32 iClipr; - mng_int32 iClipt; - mng_int32 iClipb; - } mng_clip; -typedef mng_clip * mng_clipp; - -/* ************************************************************************** */ - -typedef struct { /* SHOW */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iMode; - } mng_show; -typedef mng_show * mng_showp; - -/* ************************************************************************** */ - -typedef struct { /* TERM */ - mng_chunk_header sHeader; - mng_uint8 iTermaction; - mng_uint8 iIteraction; - mng_uint32 iDelay; - mng_uint32 iItermax; - } mng_term; -typedef mng_term * mng_termp; - -/* ************************************************************************** */ - -typedef struct { /* SAVE entry */ - mng_uint8 iEntrytype; - mng_uint32arr2 iOffset; /* 0=MSI, 1=LSI */ - mng_uint32arr2 iStarttime; /* 0=MSI, 1=LSI */ - mng_uint32 iLayernr; - mng_uint32 iFramenr; - mng_uint32 iNamesize; - mng_pchar zName; - } mng_save_entry; -typedef mng_save_entry * mng_save_entryp; - -typedef struct { /* SAVE */ - mng_chunk_header sHeader; - mng_bool bEmpty; - mng_uint8 iOffsettype; - mng_uint32 iCount; - mng_save_entryp pEntries; - } mng_save; -typedef mng_save * mng_savep; - -/* ************************************************************************** */ - -typedef struct { /* SEEK */ - mng_chunk_header sHeader; - mng_uint32 iNamesize; - mng_pchar zName; - } mng_seek; -typedef mng_seek * mng_seekp; - -/* ************************************************************************** */ - -typedef struct { /* eXPI */ - mng_chunk_header sHeader; - mng_uint16 iSnapshotid; - mng_uint32 iNamesize; - mng_pchar zName; - } mng_expi; -typedef mng_expi * mng_expip; - -/* ************************************************************************** */ - -typedef struct { /* fPRI */ - mng_chunk_header sHeader; - mng_uint8 iDeltatype; - mng_uint8 iPriority; - } mng_fpri; -typedef mng_fpri * mng_fprip; - -/* ************************************************************************** */ - -typedef struct { /* nEED */ - mng_chunk_header sHeader; - mng_uint32 iKeywordssize; - mng_pchar zKeywords; - } mng_need; -typedef mng_need * mng_needp; - -/* ************************************************************************** */ - -typedef mng_phys mng_phyg; /* pHYg */ -typedef mng_phyg * mng_phygp; - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -typedef struct { /* JHDR */ - mng_chunk_header sHeader; - mng_uint32 iWidth; - mng_uint32 iHeight; - mng_uint8 iColortype; - mng_uint8 iImagesampledepth; - mng_uint8 iImagecompression; - mng_uint8 iImageinterlace; - mng_uint8 iAlphasampledepth; - mng_uint8 iAlphacompression; - mng_uint8 iAlphafilter; - mng_uint8 iAlphainterlace; - } mng_jhdr; -typedef mng_jhdr * mng_jhdrp; - -/* ************************************************************************** */ - -typedef mng_idat mng_jdaa; /* JDAA */ -typedef mng_jdaa * mng_jdaap; - -/* ************************************************************************** */ - -typedef mng_idat mng_jdat; /* JDAT */ -typedef mng_jdat * mng_jdatp; - -/* ************************************************************************** */ - -typedef struct { /* JSEP */ - mng_chunk_header sHeader; - } mng_jsep; -typedef mng_jsep * mng_jsepp; - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -typedef struct { /* DHDR */ - mng_chunk_header sHeader; - mng_uint16 iObjectid; - mng_uint8 iImagetype; - mng_uint8 iDeltatype; - mng_uint32 iBlockwidth; - mng_uint32 iBlockheight; - mng_uint32 iBlockx; - mng_uint32 iBlocky; - } mng_dhdr; -typedef mng_dhdr * mng_dhdrp; - -/* ************************************************************************** */ - -typedef struct { /* PROM */ - mng_chunk_header sHeader; - mng_uint8 iColortype; - mng_uint8 iSampledepth; - mng_uint8 iFilltype; - } mng_prom; -typedef mng_prom * mng_promp; - -/* ************************************************************************** */ - -typedef struct { /* IPNG */ - mng_chunk_header sHeader; - } mng_ipng; -typedef mng_ipng *mng_ipngp; - -/* ************************************************************************** */ - -typedef struct { /* PPLT entry */ - mng_uint8 iRed; - mng_uint8 iGreen; - mng_uint8 iBlue; - mng_uint8 iAlpha; - mng_bool bUsed; - } mng_pplt_entry; -typedef mng_pplt_entry * mng_pplt_entryp; - -typedef struct { /* PPLT */ - mng_chunk_header sHeader; - mng_uint8 iDeltatype; - mng_uint32 iCount; - mng_pplt_entry aEntries [256]; - } mng_pplt; -typedef mng_pplt * mng_ppltp; - -/* ************************************************************************** */ - -typedef struct { /* IJNG */ - mng_chunk_header sHeader; - } mng_ijng; -typedef mng_ijng *mng_ijngp; - -/* ************************************************************************** */ - -typedef struct { /* DROP */ - mng_chunk_header sHeader; - mng_uint32 iCount; - mng_chunkidp pChunknames; - } mng_drop; -typedef mng_drop * mng_dropp; - -/* ************************************************************************** */ - -typedef struct { /* DBYK */ - mng_chunk_header sHeader; - mng_chunkid iChunkname; - mng_uint8 iPolarity; - mng_uint32 iKeywordssize; - mng_pchar zKeywords; - } mng_dbyk; -typedef mng_dbyk * mng_dbykp; - -/* ************************************************************************** */ - -typedef struct { /* ORDR entry */ - mng_chunkid iChunkname; - mng_uint8 iOrdertype; - } mng_ordr_entry; -typedef mng_ordr_entry * mng_ordr_entryp; - -typedef struct mng_ordr_struct { /* ORDR */ - mng_chunk_header sHeader; - mng_uint32 iCount; - mng_ordr_entryp pEntries; - } mng_ordr; -typedef mng_ordr * mng_ordrp; - -/* ************************************************************************** */ - -typedef struct { /* MAGN */ - mng_chunk_header sHeader; - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint16 iMethodX; - mng_uint16 iMX; - mng_uint16 iMY; - mng_uint16 iML; - mng_uint16 iMR; - mng_uint16 iMT; - mng_uint16 iMB; - mng_uint16 iMethodY; - } mng_magn; -typedef mng_magn * mng_magnp; - -/* ************************************************************************** */ - -typedef struct { /* unknown chunk */ - mng_chunk_header sHeader; - mng_uint32 iDatasize; - mng_ptr pData; - } mng_unknown_chunk; -typedef mng_unknown_chunk * mng_unknown_chunkp; - -/* ************************************************************************** */ - -#endif /* _libmng_chunks_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_cms.c b/freeimage241/Source/LibMNG/libmng_cms.c deleted file mode 100644 index d072e37..0000000 --- a/freeimage241/Source/LibMNG/libmng_cms.c +++ /dev/null @@ -1,928 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_cms.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.1 * */ -/* * * */ -/* * purpose : color management routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the color management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/01/2000 - G.Juyn * */ -/* * - B001(105795) - fixed a typo and misconception about * */ -/* * freeing allocated gamma-table. (reported by Marti Maria) * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/09/2000 - G.Juyn * */ -/* * - filled application-based color-management routines * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added creatememprofile * */ -/* * - added callback error-reporting support * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 06/10/2000 - G.Juyn * */ -/* * - fixed some compilation-warnings (contrib Jason Morris) * */ -/* * * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - fixed problem with color-correction for stored images * */ -/* * 0.5.3 - 06/23/2000 - G.Juyn * */ -/* * - fixed problem with incorrect gamma-correction * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/31/2000 - G.Juyn * */ -/* * - fixed sRGB precedence for gamma_only corection * */ -/* * * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * * */ -/* * 1.0.1 - 03/31/2001 - G.Juyn * */ -/* * - ignore gamma=0 (see png-list for more info) * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn (reported by Gregg Kelly) * */ -/* * - fixed problem with cms profile being created multiple * */ -/* * times when both iCCP & cHRM/gAMA are present * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_cms.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ -/* * * */ -/* * Little CMS helper routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS - -#define MNG_CMS_FLAGS 0 - -/* ************************************************************************** */ - -void mnglcms_initlibrary () -{ - cmsErrorAction (LCMS_ERROR_IGNORE); /* LCMS should ignore errors! */ -} - -/* ************************************************************************** */ - -mng_cmsprof mnglcms_createfileprofile (mng_pchar zFilename) -{ - return cmsOpenProfileFromFile (zFilename, "r"); -} - -/* ************************************************************************** */ - -mng_cmsprof mnglcms_creatememprofile (mng_uint32 iProfilesize, - mng_ptr pProfile) -{ - return cmsOpenProfileFromMem (pProfile, iProfilesize); -} - -/* ************************************************************************** */ - -mng_cmsprof mnglcms_createsrgbprofile (void) -{ - cmsCIExyY D65; - cmsCIExyYTRIPLE Rec709Primaries = { - {0.6400, 0.3300, 1.0}, - {0.3000, 0.6000, 1.0}, - {0.1500, 0.0600, 1.0} - }; - LPGAMMATABLE Gamma24[3]; - mng_cmsprof hsRGB; - - cmsWhitePointFromTemp(6504, &D65); - Gamma24[0] = Gamma24[1] = Gamma24[2] = cmsBuildGamma(256, 2.4); - hsRGB = cmsCreateRGBProfile(&D65, &Rec709Primaries, Gamma24); - cmsFreeGamma(Gamma24[0]); - - return hsRGB; -} - -/* ************************************************************************** */ - -void mnglcms_freeprofile (mng_cmsprof hProf) -{ - cmsCloseProfile (hProf); - return; -} - -/* ************************************************************************** */ - -void mnglcms_freetransform (mng_cmstrans hTrans) -{ -/* B001 start */ - cmsDeleteTransform (hTrans); -/* B001 end */ - return; -} - -/* ************************************************************************** */ - -mng_retcode mng_clear_cms (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CMS, MNG_LC_START) -#endif - - if (pData->hTrans) /* transformation still active ? */ - mnglcms_freetransform (pData->hTrans); - - pData->hTrans = 0; - - if (pData->hProf1) /* file profile still active ? */ - mnglcms_freeprofile (pData->hProf1); - - pData->hProf1 = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CMS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ -/* * * */ -/* * Color-management initialization & correction routines * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS - -mng_retcode init_full_cms (mng_datap pData) -{ - mng_cmsprof hProf; - mng_cmstrans hTrans; - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS, MNG_LC_START) -#endif - - if (!pImage) /* no current object? then use object 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address the buffer */ - - if ((pBuf->bHasICCP) || (pData->bHasglobalICCP)) - { - if (!pData->hProf2) /* output profile not defined ? */ - { /* then assume sRGB !! */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - - if (pBuf->bHasICCP) /* generate a profile handle */ - hProf = cmsOpenProfileFromMem (pBuf->pProfile, pBuf->iProfilesize); - else - hProf = cmsOpenProfileFromMem (pData->pGlobalProfile, pData->iGlobalProfilesize); - - pData->hProf1 = hProf; /* save for future use */ - - if (!hProf) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - else - if ((pBuf->bHasSRGB) || (pData->bHasglobalSRGB)) - { - mng_uint8 iIntent; - - if (pData->bIssRGB) /* sRGB system ? */ - return MNG_NOERROR; /* no conversion required */ - - if (!pData->hProf3) /* sRGB profile not defined ? */ - { /* then create it implicitly !! */ - pData->hProf3 = mnglcms_createsrgbprofile (); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - - hProf = pData->hProf3; /* convert from sRGB profile */ - - if (pBuf->bHasSRGB) /* determine rendering intent */ - iIntent = pBuf->iRenderingintent; - else - iIntent = pData->iGlobalRendintent; - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - iIntent, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - iIntent, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - else - if ( ((pBuf->bHasCHRM) || (pData->bHasglobalCHRM)) && - ( ((pBuf->bHasGAMA) && (pBuf->iGamma > 0)) || - ((pData->bHasglobalGAMA) && (pData->iGlobalGamma > 0)) )) - { - mng_CIExyY sWhitepoint; - mng_CIExyYTRIPLE sPrimaries; - mng_gammatabp pGammatable[3]; - mng_float dGamma; - - if (!pData->hProf2) /* output profile not defined ? */ - { /* then assume sRGB !! */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - - if (pBuf->bHasCHRM) /* local cHRM ? */ - { - sWhitepoint.x = (mng_float)pBuf->iWhitepointx / 100000; - sWhitepoint.y = (mng_float)pBuf->iWhitepointy / 100000; - sPrimaries.Red.x = (mng_float)pBuf->iPrimaryredx / 100000; - sPrimaries.Red.y = (mng_float)pBuf->iPrimaryredy / 100000; - sPrimaries.Green.x = (mng_float)pBuf->iPrimarygreenx / 100000; - sPrimaries.Green.y = (mng_float)pBuf->iPrimarygreeny / 100000; - sPrimaries.Blue.x = (mng_float)pBuf->iPrimarybluex / 100000; - sPrimaries.Blue.y = (mng_float)pBuf->iPrimarybluey / 100000; - } - else - { - sWhitepoint.x = (mng_float)pData->iGlobalWhitepointx / 100000; - sWhitepoint.y = (mng_float)pData->iGlobalWhitepointy / 100000; - sPrimaries.Red.x = (mng_float)pData->iGlobalPrimaryredx / 100000; - sPrimaries.Red.y = (mng_float)pData->iGlobalPrimaryredy / 100000; - sPrimaries.Green.x = (mng_float)pData->iGlobalPrimarygreenx / 100000; - sPrimaries.Green.y = (mng_float)pData->iGlobalPrimarygreeny / 100000; - sPrimaries.Blue.x = (mng_float)pData->iGlobalPrimarybluex / 100000; - sPrimaries.Blue.y = (mng_float)pData->iGlobalPrimarybluey / 100000; - } - - sWhitepoint.Y = /* Y component is always 1.0 */ - sPrimaries.Red.Y = - sPrimaries.Green.Y = - sPrimaries.Blue.Y = 1.0; - - if (pBuf->bHasGAMA) /* get the gamma value */ - dGamma = (mng_float)pBuf->iGamma / 100000; - else - dGamma = (mng_float)pData->iGlobalGamma / 100000; - -/* dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma); ??? */ - dGamma = pData->dViewgamma / dGamma; - - pGammatable [0] = /* and build the lookup tables */ - pGammatable [1] = - pGammatable [2] = cmsBuildGamma (256, dGamma); - -/* B001 start */ - if (!pGammatable [0]) /* enough memory ? */ -/* B001 end */ - MNG_ERRORL (pData, MNG_LCMS_NOMEM) - /* create the profile */ - hProf = cmsCreateRGBProfile (&sWhitepoint, &sPrimaries, pGammatable); - -/* B001 start */ - cmsFreeGamma (pGammatable [0]); /* free the temporary gamma tables ? */ - /* yes! but just the one! */ -/* B001 end */ - - pData->hProf1 = hProf; /* save for future use */ - - if (!hProf) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS, MNG_LC_END) -#endif - - return init_gamma_only (pData); /* if we get here, we'll only do gamma */ -} -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS - -mng_retcode init_full_cms_object (mng_datap pData) -{ - mng_cmsprof hProf; - mng_cmstrans hTrans; - mng_imagedatap pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS_OBJ, MNG_LC_START) -#endif - /* address the object-buffer */ - pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - - if (pBuf->bHasICCP) - { - if (!pData->hProf2) /* output profile not defined ? */ - { /* then assume sRGB !! */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - /* generate a profile handle */ - hProf = cmsOpenProfileFromMem (pBuf->pProfile, pBuf->iProfilesize); - - pData->hProf1 = hProf; /* save for future use */ - - if (!hProf) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - else - if (pBuf->bHasSRGB) - { - if (pData->bIssRGB) /* sRGB system ? */ - return MNG_NOERROR; /* no conversion required */ - - if (!pData->hProf3) /* sRGB profile not defined ? */ - { /* then create it implicitly !! */ - pData->hProf3 = mnglcms_createsrgbprofile (); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - - hProf = pData->hProf3; /* convert from sRGB profile */ - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - pBuf->iRenderingintent, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - pBuf->iRenderingintent, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - else - if ((pBuf->bHasCHRM) && (pBuf->bHasGAMA) && (pBuf->iGamma > 0)) - { - mng_CIExyY sWhitepoint; - mng_CIExyYTRIPLE sPrimaries; - mng_gammatabp pGammatable[3]; - mng_float dGamma; - - if (!pData->hProf2) /* output profile not defined ? */ - { /* then assume sRGB !! */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - } - - sWhitepoint.x = (mng_float)pBuf->iWhitepointx / 100000; - sWhitepoint.y = (mng_float)pBuf->iWhitepointy / 100000; - sPrimaries.Red.x = (mng_float)pBuf->iPrimaryredx / 100000; - sPrimaries.Red.y = (mng_float)pBuf->iPrimaryredy / 100000; - sPrimaries.Green.x = (mng_float)pBuf->iPrimarygreenx / 100000; - sPrimaries.Green.y = (mng_float)pBuf->iPrimarygreeny / 100000; - sPrimaries.Blue.x = (mng_float)pBuf->iPrimarybluex / 100000; - sPrimaries.Blue.y = (mng_float)pBuf->iPrimarybluey / 100000; - - sWhitepoint.Y = /* Y component is always 1.0 */ - sPrimaries.Red.Y = - sPrimaries.Green.Y = - sPrimaries.Blue.Y = 1.0; - - dGamma = (mng_float)pBuf->iGamma / 100000; - -/* dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma); ??? */ - dGamma = pData->dViewgamma / dGamma; - - pGammatable [0] = /* and build the lookup tables */ - pGammatable [1] = - pGammatable [2] = cmsBuildGamma (256, dGamma); - -/* B001 start */ - if (!pGammatable [0]) /* enough memory ? */ -/* B001 end */ - MNG_ERRORL (pData, MNG_LCMS_NOMEM) - - /* create the profile */ - hProf = cmsCreateRGBProfile (&sWhitepoint, &sPrimaries, pGammatable); - -/* B001 start */ - cmsFreeGamma (pGammatable [0]); /* free the temporary gamma tables ? */ - /* yes! but just the one! */ -/* B001 end */ - - pData->hProf1 = hProf; /* save for future use */ - - if (!hProf) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) - - if (pData->bIsRGBA16) /* 16-bit intermediates ? */ - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_16_SE, - pData->hProf2, TYPE_RGBA_16_SE, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - else - hTrans = cmsCreateTransform (hProf, TYPE_RGBA_8, - pData->hProf2, TYPE_RGBA_8, - INTENT_PERCEPTUAL, MNG_CMS_FLAGS); - - pData->hTrans = hTrans; /* save for future use */ - - if (!hTrans) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOTRANS) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_full_cms; - - return MNG_NOERROR; /* and done */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_FULL_CMS_OBJ, MNG_LC_END) -#endif - /* if we get here, we'll only do gamma */ - return init_gamma_only_object (pData); -} -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS -mng_retcode correct_full_cms (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_FULL_CMS, MNG_LC_START) -#endif - - cmsDoTransform (pData->hTrans, pData->pRGBArow, pData->pRGBArow, pData->iRowsamples); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_FULL_CMS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ - -#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) -mng_retcode init_gamma_only (mng_datap pData) -{ - mng_float dGamma; - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY, MNG_LC_START) -#endif - - if (!pImage) /* no current object? then use object 0 */ - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; /* address the buffer */ - - if (pBuf->bHasSRGB) /* get the gamma value */ - dGamma = 0.45455; - else - if (pBuf->bHasGAMA) - dGamma = (mng_float)pBuf->iGamma / 100000; - else - if (pData->bHasglobalSRGB) - dGamma = 0.45455; - else - if (pData->bHasglobalGAMA) - dGamma = (mng_float)pData->iGlobalGamma / 100000; - else - dGamma = pData->dDfltimggamma; - - if (dGamma > 0) /* ignore gamma=0 */ - { - dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma); - - if (dGamma != pData->dLastgamma) /* lookup table needs to be computed ? */ - { - mng_int32 iX; - - pData->aGammatab [0] = 0; - - for (iX = 1; iX <= 255; iX++) - pData->aGammatab [iX] = (mng_uint8)(pow (iX / 255.0, dGamma) * 255 + 0.5); - - pData->dLastgamma = dGamma; /* keep for next time */ - } - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_gamma_only; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_GAMMA_ONLY || MNG_FULL_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) -mng_retcode init_gamma_only_object (mng_datap pData) -{ - mng_float dGamma; - mng_imagedatap pBuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY_OBJ, MNG_LC_START) -#endif - /* address the object-buffer */ - pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - - if (pBuf->bHasSRGB) /* get the gamma value */ - dGamma = 0.45455; - else - if (pBuf->bHasGAMA) - dGamma = (mng_float)pBuf->iGamma / 100000; - else - dGamma = pData->dDfltimggamma; - - if (dGamma) /* lets not divide by zero, shall we... */ - dGamma = pData->dViewgamma / (dGamma * pData->dDisplaygamma); - - if (dGamma != pData->dLastgamma) /* lookup table needs to be computed ? */ - { - mng_int32 iX; - - pData->aGammatab [0] = 0; - - for (iX = 1; iX <= 255; iX++) - pData->aGammatab [iX] = (mng_uint8)(pow (iX / 255.0, dGamma) * 255 + 0.5); - - pData->dLastgamma = dGamma; /* keep for next time */ - } - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_gamma_only; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GAMMA_ONLY_OBJ, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_GAMMA_ONLY || MNG_FULL_CMS */ - -/* ************************************************************************** */ - -#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) -mng_retcode correct_gamma_only (mng_datap pData) -{ - mng_uint8p pWork; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_GAMMA_ONLY, MNG_LC_START) -#endif - - pWork = pData->pRGBArow; /* address intermediate row */ - - if (pData->bIsRGBA16) /* 16-bit intermediate row ? */ - { - - - /* TODO: 16-bit precision gamma processing */ - /* we'll just do the high-order byte for now */ - - - /* convert all samples in the row */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* using the precalculated gamma lookup table */ - *pWork = pData->aGammatab [*pWork]; - *(pWork+2) = pData->aGammatab [*(pWork+2)]; - *(pWork+4) = pData->aGammatab [*(pWork+4)]; - - pWork += 8; - } - } - else - { /* convert all samples in the row */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* using the precalculated gamma lookup table */ - *pWork = pData->aGammatab [*pWork]; - *(pWork+1) = pData->aGammatab [*(pWork+1)]; - *(pWork+2) = pData->aGammatab [*(pWork+2)]; - - pWork += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_GAMMA_ONLY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_GAMMA_ONLY || MNG_FULL_CMS */ - -/* ************************************************************************** */ - -#ifdef MNG_APP_CMS -mng_retcode init_app_cms (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_APP_CMS, MNG_LC_START) -#endif - - if ( (pData->fProcessiccp) && - ((pBuf->bHasICCP) || (pData->bHasglobalICCP)) ) - { - mng_uint32 iProfilesize; - mng_ptr pProfile; - - if (pBuf->bHasICCP) /* get the right profile */ - { - iProfilesize = pBuf->iProfilesize; - pProfile = pBuf->pProfile; - } - else - { - iProfilesize = pData->iGlobalProfilesize; - pProfile = pData->pGlobalProfile; - } - /* inform the app */ - if (!pData->fProcessiccp ((mng_handle)pData, iProfilesize, pProfile)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ( (pData->fProcesssrgb) && - ((pBuf->bHasSRGB) || (pData->bHasglobalSRGB)) ) - { - mng_uint8 iIntent; - - if (pBuf->bHasSRGB) /* determine rendering intent */ - iIntent = pBuf->iRenderingintent; - else - iIntent = pData->iGlobalRendintent; - /* inform the app */ - if (!pData->fProcesssrgb ((mng_handle)pData, iIntent)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ( (pData->fProcesschroma) && - ( ((pBuf->bHasCHRM) || (pData->bHasglobalCHRM)) ) ) - { - mng_uint32 iWhitepointx, iWhitepointy; - mng_uint32 iPrimaryredx, iPrimaryredy; - mng_uint32 iPrimarygreenx, iPrimarygreeny; - mng_uint32 iPrimarybluex, iPrimarybluey; - - if (pBuf->bHasCHRM) /* local cHRM ? */ - { - iWhitepointx = pBuf->iWhitepointx; - iWhitepointy = pBuf->iWhitepointy; - iPrimaryredx = pBuf->iPrimaryredx; - iPrimaryredy = pBuf->iPrimaryredy; - iPrimarygreenx = pBuf->iPrimarygreenx; - iPrimarygreeny = pBuf->iPrimarygreeny; - iPrimarybluex = pBuf->iPrimarybluex; - iPrimarybluey = pBuf->iPrimarybluey; - } - else - { - iWhitepointx = pData->iGlobalWhitepointx; - iWhitepointy = pData->iGlobalWhitepointy; - iPrimaryredx = pData->iGlobalPrimaryredx; - iPrimaryredy = pData->iGlobalPrimaryredy; - iPrimarygreenx = pData->iGlobalPrimarygreenx; - iPrimarygreeny = pData->iGlobalPrimarygreeny; - iPrimarybluex = pData->iGlobalPrimarybluex; - iPrimarybluey = pData->iGlobalPrimarybluey; - } - /* inform the app */ - if (!pData->fProcesschroma ((mng_handle)pData, iWhitepointx, iWhitepointy, - iPrimaryredx, iPrimaryredy, - iPrimarygreenx, iPrimarygreeny, - iPrimarybluex, iPrimarybluey)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ( (pData->fProcessgamma) && - ((pBuf->bHasGAMA) || (pData->bHasglobalGAMA)) ) - { - mng_uint32 iGamma; - - if (pBuf->bHasGAMA) /* get the gamma value */ - iGamma = pBuf->iGamma; - else - iGamma = pData->iGlobalGamma; - /* inform the app */ - if (!pData->fProcessgamma ((mng_handle)pData, iGamma)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_APP_CMS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_APP_CMS */ - -/* ************************************************************************** */ - -#ifdef MNG_APP_CMS -mng_retcode init_app_cms_object (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pCurrentobj)->pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_APP_CMS_OBJ, MNG_LC_START) -#endif - - if ((pData->fProcessiccp) && (pBuf->bHasICCP)) - { /* inform the app */ - if (!pData->fProcessiccp ((mng_handle)pData, pBuf->iProfilesize, pBuf->pProfile)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ((pData->fProcesssrgb) && (pBuf->bHasSRGB)) - { /* inform the app */ - if (!pData->fProcesssrgb ((mng_handle)pData, pBuf->iRenderingintent)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ((pData->fProcesschroma) && (pBuf->bHasCHRM)) - { /* inform the app */ - if (!pData->fProcesschroma ((mng_handle)pData, pBuf->iWhitepointx, pBuf->iWhitepointy, - pBuf->iPrimaryredx, pBuf->iPrimaryredy, - pBuf->iPrimarygreenx, pBuf->iPrimarygreeny, - pBuf->iPrimarybluex, pBuf->iPrimarybluey)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - - if ((pData->fProcessgamma) && (pBuf->bHasGAMA)) - { /* inform the app */ - if (!pData->fProcessgamma ((mng_handle)pData, pBuf->iGamma)) - MNG_ERROR (pData, MNG_APPCMSERROR) - /* load color-correction routine */ - pData->fCorrectrow = (mng_fptr)correct_app_cms; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_APP_CMS_OBJ, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_APP_CMS */ - -/* ************************************************************************** */ - -#ifdef MNG_APP_CMS -mng_retcode correct_app_cms (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_APP_CMS, MNG_LC_START) -#endif - - if (pData->fProcessarow) /* let the app do something with our row */ - if (!pData->fProcessarow ((mng_handle)pData, pData->iRowsamples, - pData->bIsRGBA16, pData->pRGBArow)) - MNG_ERROR (pData, MNG_APPCMSERROR) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CORRECT_APP_CMS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_APP_CMS */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - - diff --git a/freeimage241/Source/LibMNG/libmng_cms.h b/freeimage241/Source/LibMNG/libmng_cms.h deleted file mode 100644 index 02d6c33..0000000 --- a/freeimage241/Source/LibMNG/libmng_cms.h +++ /dev/null @@ -1,80 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_cms.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.1 * */ -/* * * */ -/* * purpose : color management routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of color management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added creatememprofile * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_cms_h_ -#define _libmng_cms_h_ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS -void mnglcms_initlibrary (void); -mng_cmsprof mnglcms_createfileprofile (mng_pchar zFilename); -mng_cmsprof mnglcms_creatememprofile (mng_uint32 iProfilesize, - mng_ptr pProfile ); -mng_cmsprof mnglcms_createsrgbprofile (void); -void mnglcms_freeprofile (mng_cmsprof hProf ); -void mnglcms_freetransform (mng_cmstrans hTrans ); - -mng_retcode mng_clear_cms (mng_datap pData ); -#endif - -/* ************************************************************************** */ - -#ifdef MNG_FULL_CMS -mng_retcode init_full_cms (mng_datap pData); -mng_retcode init_full_cms_object (mng_datap pData); -mng_retcode correct_full_cms (mng_datap pData); -#endif - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) -mng_retcode init_gamma_only (mng_datap pData); -mng_retcode init_gamma_only_object (mng_datap pData); -mng_retcode correct_gamma_only (mng_datap pData); -#endif - -#ifdef MNG_APP_CMS -mng_retcode init_app_cms (mng_datap pData); -mng_retcode init_app_cms_object (mng_datap pData); -mng_retcode correct_app_cms (mng_datap pData); -#endif - -/* ************************************************************************** */ - -#endif /* _libmng_cms_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_conf.h b/freeimage241/Source/LibMNG/libmng_conf.h deleted file mode 100644 index c844dfa..0000000 --- a/freeimage241/Source/LibMNG/libmng_conf.h +++ /dev/null @@ -1,209 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_conf.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : main configuration file * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : The configuration file. Change this to include/exclude * */ -/* * the options you want or do not want in libmng. * */ -/* * * */ -/* * changes : 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - separated configuration-options into this file * */ -/* * - changed to most likely configuration (?) * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - changed options to create a standard so-library * */ -/* * with everything enabled * */ -/* * 0.5.2 - 06/04/2000 - G.Juyn * */ -/* * - changed options to create a standard win32-dll * */ -/* * with everything enabled * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 09/16/2000 - G.Juyn * */ -/* * - removed trace-options from default SO/DLL builds * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_conf_h_ -#define _libmng_conf_h_ - -/* ************************************************************************** */ -/* * * */ -/* * User-selectable compile-time options * */ -/* * * */ -/* ************************************************************************** */ - -/* enable exactly one(1) of the MNG-(sub)set selectors */ -/* use this to select which (sub)set of the MNG specification you wish - to support */ -/* generally you'll want full support as the library provides it automatically - for you! if you're really strung on memory-requirements you can opt - to enable less support (but it's just NOT a good idea!) */ -/* NOTE that this isn't actually implemented yet */ - -#if !defined(MNG_SUPPORT_FULL) && !defined(MNG_SUPPORT_LC) && !defined(MNG_SUPPORT_VLC) -#define MNG_SUPPORT_FULL -/* #define MNG_SUPPORT_LC */ -/* #define MNG_SUPPORT_VLC */ -#endif - -/* ************************************************************************** */ - -/* enable JPEG support if required */ -/* use this to enable the JNG support routines */ -/* this requires an external jpeg package; - currently only IJG's jpgsrc6b is supported! */ -/* NOTE that the IJG code can be either 8- or 12-bit (eg. not both); - so choose the one you've defined in jconfig.h; if you don't know what - the heck I'm talking about, just leave it at 8-bit support (thank you!) */ - -#ifdef MNG_SUPPORT_FULL /* full support includes JNG */ -#define MNG_SUPPORT_IJG6B -#endif - -#ifndef MNG_SUPPORT_IJG6B -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_SUPPORT_IJG6B -#endif -#endif - -#if defined(MNG_SUPPORT_IJG6B) && !defined(MNG_SUPPORT_JPEG8) && !defined(MNG_SUPPORT_JPEG12) -#define MNG_SUPPORT_JPEG8 -/* #define MNG_SUPPORT_JPEG12 */ -#endif - -/* ************************************************************************** */ - -/* enable required high-level functions */ -/* use this to select the high-level functions you require */ -/* if you only need to display a MNG, disable write support! */ -/* if you only need to examine a MNG, disable write & display support! */ -/* if you only need to copy a MNG, disable display support! */ -/* if you only need to create a MNG, disable read & display support! */ -/* NOTE that turning all options off will be very unuseful! */ - -#if !defined(MNG_SUPPORT_READ) && !defined(MNG_SUPPORT_WRITE) && !defined(MNG_SUPPORT_DISPLAY) -#define MNG_SUPPORT_READ -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_SUPPORT_WRITE -#endif -#define MNG_SUPPORT_DISPLAY -#endif - -/* ************************************************************************** */ - -/* enable chunk access functions */ -/* use this to select whether you need access to the individual chunks */ -/* useful if you want to examine a read MNG (you'll also need MNG_STORE_CHUNKS !)*/ -/* required if you need to create & write a new MNG! */ - -#ifndef MNG_ACCESS_CHUNKS -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_ACCESS_CHUNKS -#endif -#endif - -/* ************************************************************************** */ - -/* enable exactly one of the color-management-functionality selectors */ -/* use this to select the level of automatic color support */ -/* MNG_FULL_CMS requires the lcms (little cms) external package ! */ -/* if you want your own app (or the OS) to handle color-management - select MNG_APP_CMS */ - -#if !defined(MNG_FULL_CMS) && !defined(MNG_GAMMA_ONLY) && !defined(MNG_NO_CMS) && !defined(MNG_APP_CMS) -#if defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_FULL_CMS -#else -#define MNG_GAMMA_ONLY -#endif -/* #define MNG_NO_CMS */ -/* #define MNG_APP_CMS */ -#endif - -/* ************************************************************************** */ - -/* enable automatic dithering */ -/* use this if you need dithering support to convert high-resolution - images to a low-resolution output-device */ -/* NOTE that this is not supported yet */ - -/* #define MNG_AUTO_DITHER */ - -/* ************************************************************************** */ - -/* enable whether chunks should be stored for reference later */ -/* use this if you need to examine the chunks of a MNG you have read, - or (re-)write a MNG you have read */ -/* turn this off if you want to reduce memory-consumption */ - -#ifndef MNG_STORE_CHUNKS -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_STORE_CHUNKS -#endif -#endif - -/* ************************************************************************** */ - -/* enable internal memory management (if your compiler supports it) */ -/* use this if your compiler supports the 'standard' memory functions - (calloc & free), and you want the library to use these functions and not - bother your app with memory-callbacks */ - -/* #define MNG_INTERNAL_MEMMNGMT */ - -/* ************************************************************************** */ - -/* enable internal tracing-functionality (manual debugging purposes) */ -/* use this if you have trouble location bugs or problems */ -/* NOTE that you'll need to specify the trace callback function! */ - -/* #define MNG_SUPPORT_TRACE */ - -/* ************************************************************************** */ - -/* enable extended error- and trace-telltaling */ -/* use this if you need explanatory messages with errors and/or tracing */ - -#if !defined(MNG_ERROR_TELLTALE) && !defined(MNG_TRACE_TELLTALE) -#if defined(MNG_BUILD_SO) || defined(MNG_USE_SO) || defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_ERROR_TELLTALE -#define MNG_TRACE_TELLTALE -#endif -#endif - -/* ************************************************************************** */ - -/* enable big-endian support */ -/* enable this if you're on an architecture that supports big-endian reads - and writes that aren't word-aligned */ -/* according to reliable sources this only works for PowerPC (bigendian mode) - and 680x0 */ - -/* #define MNG_BIGENDIAN_SUPPORTED */ - -/* ************************************************************************** */ -/* * * */ -/* * End of user-selectable compile-time options * */ -/* * * */ -/* ************************************************************************** */ - -#endif /* _libmng_conf_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_data.h b/freeimage241/Source/LibMNG/libmng_data.h deleted file mode 100644 index e881ce1..0000000 --- a/freeimage241/Source/LibMNG/libmng_data.h +++ /dev/null @@ -1,768 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_data.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : main data structure definition * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the library main data structure * */ -/* * * */ -/* * changes : 0.5.1 - 05/04/2000 - G.Juyn * */ -/* * - added CRC table to main structure (for thread-safety) * */ -/* * 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - added iPLTEentries for checking hIST-length * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed palette definition to exported palette-type * */ -/* * - removed frozen indicator * */ -/* * - added create/write indicators * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * - added saved-data structure for SAVE/SEEK processing * */ -/* * * */ -/* * 0.5.2 - 05/18/2000 - G.Juyn * */ -/* * - added fields for JNG support (IJG-based) * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - changed global tRNS definition * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added delta-image fields * */ -/* * 0.5.2 - 06/01/2000 - G.Juyn * */ -/* * - added internal delta-image processing callbacks * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - changed SWAP_ENDIAN to BIGENDIAN_SUPPORTED * */ -/* * (contributed by Tim Rowley) * */ -/* * - added getalphaline callback for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added parameter for delayed buffer-processing * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - added update-region parms for refresh calback * */ -/* * - added Needrefresh parameter * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - added Deltaimmediate parm for faster delta-processing * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added Speed parameter to facilitate testing * */ -/* * - added Imagelevel parameter for processtext callback * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added variables for go_xxxx processing * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added variables for improved timing support * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * - added variable for NEEDSECTIONWAIT breaks * */ -/* * - added variable for freeze & reset processing * */ -/* * 0.9.1 - 07/17/2000 - G.Juyn * */ -/* * - fixed suspension-buffering for 32K+ chunks * */ -/* * * */ -/* * 0.9.2 - 07/29/2000 - G.Juyn * */ -/* * - removed Nextbackxxx fields (no longer used) * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - fixed wrapping of suspension parameters * */ -/* * 0.9.2 - 08/04/2000 - G.Juyn * */ -/* * - B111096 - fixed large-buffer read-suspension * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 02/13/2001 - G.Juyn * */ -/* * - fixed first FRAM_MODE=4 timing problem * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_data_h_ -#define _libmng_data_h_ - -/* ************************************************************************** */ - -#define MNG_MAGIC 0x52530a0aL - -/* ************************************************************************** */ -/* * * */ -/* * Internal structures * */ -/* * * */ -/* ************************************************************************** */ - -typedef mng_palette8 mng_rgbpaltab; - -/* ************************************************************************** */ -/* * * */ -/* * The saved_data structure * */ -/* * * */ -/* * This contains the saved data after a SAVE chunk has been processed. * */ -/* * The data is saved from the main data structure during SAVE processing, * */ -/* * and restored to the main data structure during SEEK processing. * */ -/* * * */ -/* ************************************************************************** */ - -typedef struct mng_savedata_struct { - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - mng_bool bHasglobalPLTE; /* global PLTE chunk processed */ - mng_bool bHasglobalTRNS; /* global tRNS chunk processed */ - mng_bool bHasglobalGAMA; /* global gAMA chunk processed */ - mng_bool bHasglobalCHRM; /* global cHRM chunk processed */ - mng_bool bHasglobalSRGB; /* global sRGB chunk processed */ - mng_bool bHasglobalICCP; /* global iCCP chunk processed */ - mng_bool bHasglobalBKGD; /* global bKGD chunk processed */ -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -#ifdef MNG_SUPPORT_DISPLAY - mng_uint16 iBACKred; /* BACK fields */ - mng_uint16 iBACKgreen; - mng_uint16 iBACKblue; - mng_uint8 iBACKmandatory; - mng_uint16 iBACKimageid; - mng_uint8 iBACKtile; - - mng_uint8 iFRAMmode; /* FRAM fields (global) */ - mng_uint32 iFRAMdelay; - mng_uint32 iFRAMtimeout; - mng_bool bFRAMclipping; - mng_int32 iFRAMclipl; - mng_int32 iFRAMclipr; - mng_int32 iFRAMclipt; - mng_int32 iFRAMclipb; - - mng_uint32 iGlobalPLTEcount; /* global PLTE fields */ - mng_rgbpaltab aGlobalPLTEentries; - - mng_uint32 iGlobalTRNSrawlen; /* global tRNS fields */ - mng_uint8arr aGlobalTRNSrawdata; - - mng_uint32 iGlobalGamma; /* global gAMA fields */ - - mng_uint32 iGlobalWhitepointx; /* global cHRM fields */ - mng_uint32 iGlobalWhitepointy; - mng_uint32 iGlobalPrimaryredx; - mng_uint32 iGlobalPrimaryredy; - mng_uint32 iGlobalPrimarygreenx; - mng_uint32 iGlobalPrimarygreeny; - mng_uint32 iGlobalPrimarybluex; - mng_uint32 iGlobalPrimarybluey; - - mng_uint8 iGlobalRendintent; /* global sRGB fields */ - - mng_uint32 iGlobalProfilesize; /* global iCCP fields */ - mng_ptr pGlobalProfile; - - mng_uint16 iGlobalBKGDred; /* global bKGD fields */ - mng_uint16 iGlobalBKGDgreen; - mng_uint16 iGlobalBKGDblue; -#endif /* MNG_SUPPORT_DISPLAY */ - - } mng_savedata; - -typedef mng_savedata * mng_savedatap; - -/* ************************************************************************** */ -/* * * */ -/* * The main libmng data structure * */ -/* * * */ -/* * The handle used in all functions points to this structure which * */ -/* * contains all volatile data necessary to process the network graphic. * */ -/* * * */ -/* ************************************************************************** */ - -typedef struct mng_data_struct { - - mng_uint32 iMagic; /* magic number to validate - a given handle */ - mng_ptr pUserdata; /* application workdata */ - - mng_imgtype eSigtype; /* image information */ - mng_imgtype eImagetype; /* initially zeroed */ - mng_uint32 iWidth; /* filled after header is processed */ - mng_uint32 iHeight; - mng_uint32 iTicks; /* these only after MHDR */ - mng_uint32 iLayercount; - mng_uint32 iFramecount; - mng_uint32 iPlaytime; - mng_uint32 iSimplicity; - mng_uint8 iAlphadepth; /* indicates expected alpha-depth */ - - mng_uint32 iImagelevel; /* level an image inside a stream */ - - mng_uint32 iCanvasstyle; /* layout of the drawing-canvas */ - mng_uint32 iBkgdstyle; /* layout of the background-canvas */ - - mng_int8 iMagnify; /* magnification factor (not used yet) */ - mng_uint32 iOffsetx; /* x-offset for extremely large image */ - mng_uint32 iOffsety; /* y-offset for extremely large image */ - mng_uint32 iCanvaswidth; /* real canvas size */ - mng_uint32 iCanvasheight; /* must be set by processheader callback */ - - mng_uint16 iBGred; /* default background color */ - mng_uint16 iBGgreen; /* initially "black" */ - mng_uint16 iBGblue; - mng_bool bUseBKGD; /* preferred use of bKGD for PNG */ - - mng_bool bIssRGB; /* indicates sRGB system */ - -#ifdef MNG_FULL_CMS /* little CMS variables */ - mng_cmsprof hProf1; /* image input profile */ - mng_cmsprof hProf2; /* default output profile */ - mng_cmsprof hProf3; /* default sRGB profile */ - mng_cmstrans hTrans; /* current transformation handle */ -#endif - - mng_float dViewgamma; /* gamma calculation variables */ - mng_float dDisplaygamma; /* initially set for sRGB conditions */ - mng_float dDfltimggamma; - - mng_bool bStorechunks; /* switch for storing chunkdata */ - mng_bool bSectionbreaks; /* indicate NEEDSECTIONWAIT breaks */ - mng_bool bCacheplayback; /* switch to cache playback info */ - mng_bool bDoProgressive; /* progressive refresh for large images */ - - mng_speedtype iSpeed; /* speed-modifier for animations */ - - mng_uint32 iMaxwidth; /* maximum canvas size */ - mng_uint32 iMaxheight; /* initially set to 1024 x 1024 */ - - mng_int32 iErrorcode; /* error reporting fields */ - mng_int8 iSeverity; - mng_int32 iErrorx1; - mng_int32 iErrorx2; - mng_pchar zErrortext; - - mng_memalloc fMemalloc; /* callback pointers */ - mng_memfree fMemfree; /* initially nulled */ - mng_openstream fOpenstream; - mng_closestream fClosestream; - mng_readdata fReaddata; - mng_writedata fWritedata; - mng_errorproc fErrorproc; - mng_traceproc fTraceproc; - mng_processheader fProcessheader; - mng_processtext fProcesstext; - mng_processsave fProcesssave; - mng_processseek fProcessseek; - mng_processneed fProcessneed; - mng_processmend fProcessmend; - mng_processunknown fProcessunknown; - mng_processterm fProcessterm; - mng_getcanvasline fGetcanvasline; - mng_getbkgdline fGetbkgdline; - mng_getalphaline fGetalphaline; - mng_refresh fRefresh; - mng_gettickcount fGettickcount; - mng_settimer fSettimer; - mng_processgamma fProcessgamma; - mng_processchroma fProcesschroma; - mng_processsrgb fProcesssrgb; - mng_processiccp fProcessiccp; - mng_processarow fProcessarow; - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - mng_bool bPreDraft48; /* flags ancient style draft */ - - mng_chunkid iChunkname; /* read/write-state variables */ - mng_uint32 iChunkseq; - mng_chunkp pFirstchunk; /* double-linked list of */ - mng_chunkp pLastchunk; /* stored chunk-structures */ - - mng_bool bHasheader; /* first header chunk processed */ - mng_bool bHasMHDR; /* inside a MHDR-MEND sequence */ - mng_bool bHasIHDR; /* inside a IHDR-IEND sequence */ - mng_bool bHasBASI; /* inside a BASI-IEND sequence */ - mng_bool bHasDHDR; /* inside a DHDR-IEND sequence */ -#ifdef MNG_INCLUDE_JNG - mng_bool bHasJHDR; /* inside a JHDR-IEND sequence */ - mng_bool bHasJSEP; /* passed the JSEP separator */ - mng_bool bHasJDAA; /* at least 1 JDAA processed */ - mng_bool bHasJDAT; /* at least 1 JDAT processed */ -#endif - mng_bool bHasPLTE; /* PLTE chunk processed */ - mng_bool bHasTRNS; /* tRNS chunk processed */ - mng_bool bHasGAMA; /* gAMA chunk processed */ - mng_bool bHasCHRM; /* cHRM chunk processed */ - mng_bool bHasSRGB; /* sRGB chunk processed */ - mng_bool bHasICCP; /* iCCP chunk processed */ - mng_bool bHasBKGD; /* bKGD chunk processed */ - mng_bool bHasIDAT; /* at least 1 IDAT processed */ - - mng_bool bHasSAVE; /* SAVE chunk processed */ - mng_bool bHasBACK; /* BACK chunk processed */ - mng_bool bHasFRAM; /* FRAM chunk processed */ - mng_bool bHasTERM; /* TERM chunk processed */ - mng_bool bHasLOOP; /* at least 1 LOOP open */ - - mng_bool bHasglobalPLTE; /* global PLTE chunk processed */ - mng_bool bHasglobalTRNS; /* global tRNS chunk processed */ - mng_bool bHasglobalGAMA; /* global gAMA chunk processed */ - mng_bool bHasglobalCHRM; /* global cHRM chunk processed */ - mng_bool bHasglobalSRGB; /* global sRGB chunk processed */ - mng_bool bHasglobalICCP; /* global iCCP chunk processed */ - mng_bool bHasglobalBKGD; /* global bKGD chunk processed */ - - mng_uint32 iDatawidth; /* IHDR/BASI/DHDR fields */ - mng_uint32 iDataheight; /* valid if inside IHDR-IEND, */ - mng_uint8 iBitdepth; /* BASI-IEND or DHDR-IEND */ - mng_uint8 iColortype; - mng_uint8 iCompression; - mng_uint8 iFilter; - mng_uint8 iInterlace; - - mng_uint32 iPLTEcount; /* PLTE fields */ - - mng_bool bEMNGMAhack; /* TODO: to be removed in 1.0.0 !!! */ - -#ifdef MNG_INCLUDE_JNG - mng_uint8 iJHDRcolortype; /* JHDR fields */ - mng_uint8 iJHDRimgbitdepth; /* valid if inside JHDR-IEND */ - mng_uint8 iJHDRimgcompression; - mng_uint8 iJHDRimginterlace; - mng_uint8 iJHDRalphabitdepth; - mng_uint8 iJHDRalphacompression; - mng_uint8 iJHDRalphafilter; - mng_uint8 iJHDRalphainterlace; -#endif - -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -#ifdef MNG_SUPPORT_READ - mng_bool bReading; /* read processing variables */ - mng_bool bHavesig; - mng_bool bEOF; - mng_uint32 iReadbufsize; - mng_uint8p pReadbuf; - - mng_uint32 iLargebufsize; /* temp for very large chunks */ - mng_uint8p pLargebuf; - - mng_uint32 iSuspendtime; /* tickcount at last suspension */ - mng_bool bSuspended; /* input-reading has been suspended; - we're expecting a call to - mng_read_resume! */ - mng_uint8 iSuspendpoint; /* indicates at which point the flow - was broken to suspend input-reading */ - - mng_bool bSuspensionmode; /* I/O-suspension variables */ - mng_uint32 iSuspendbufsize; - mng_uint8p pSuspendbuf; - mng_uint8p pSuspendbufnext; - mng_uint32 iSuspendbufleft; - mng_uint32 iChunklen; /* chunk length */ - mng_uint8p pReadbufnext; /* 32K+ suspension-processing */ -#endif /* MNG_SUPPORT_READ */ - -#ifdef MNG_SUPPORT_WRITE - mng_bool bCreating; /* create/write processing variables */ - mng_bool bWriting; - mng_chunkid iFirstchunkadded; - mng_uint32 iWritebufsize; - mng_uint8p pWritebuf; -#endif - -#ifdef MNG_SUPPORT_DISPLAY - mng_bool bDisplaying; /* display-state variables */ - mng_bool bFramedone; - mng_uint32 iFrameseq; - mng_uint32 iLayerseq; - mng_uint32 iFrametime; /* millisecs */ - - mng_uint32 iRequestframe; /* go_xxxx variables */ - mng_uint32 iRequestlayer; - mng_uint32 iRequesttime; - mng_bool bSearching; - - mng_bool bRestorebkgd; /* flags restore required before IDAT/JDAT */ - - mng_uint32 iRuntime; /* millisecs since start */ - mng_uint32 iSynctime; /* tickcount at last framesync */ - mng_uint32 iStarttime; /* tickcount at start */ - mng_uint32 iEndtime; /* tickcount at end */ - mng_bool bRunning; /* animation is active */ - mng_bool bTimerset; /* the timer has been set; - we're expecting a call to - mng_display_resume! */ - mng_uint8 iBreakpoint; /* indicates at which point the - flow was broken to run the timer */ - mng_bool bSectionwait; /* indicates a section break */ - mng_bool bFreezing; /* indicates app requested a freeze */ - mng_bool bResetting; /* indicates app requested a reset */ - mng_bool bNeedrefresh; /* indicates screen-refresh is needed */ - mng_objectp pCurrentobj; /* current "object" */ - mng_objectp pCurraniobj; /* current animation object - "to be"/"being" processed */ - mng_objectp pTermaniobj; /* TERM animation object */ - mng_uint32 iIterations; /* TERM/MEND iteration count */ - mng_objectp pObjzero; /* "on-the-fly" image (object = 0) */ - mng_objectp pLastclone; /* last clone */ - mng_objectp pStoreobj; /* current store object for row routines */ - mng_objectp pStorebuf; /* current store object-buffer for row routines */ - mng_objectp pRetrieveobj; /* current retrieve object for row routines */ - mng_savedatap pSavedata; /* pointer to saved data (after SAVE) */ - - mng_uint32 iUpdateleft; /* update region for refresh */ - mng_uint32 iUpdateright; - mng_uint32 iUpdatetop; - mng_uint32 iUpdatebottom; - - mng_int8 iPass; /* current interlacing pass; - negative value means no interlace */ - mng_int32 iRow; /* current row counter */ - mng_int32 iRowinc; /* row increment for this pass */ - mng_int32 iCol; /* current starting column */ - mng_int32 iColinc; /* column increment for this pass */ - mng_int32 iRowsamples; /* nr. of samples in current workrow */ - mng_int32 iSamplemul; /* needed to calculate rowsize */ - mng_int32 iSampleofs; /* from rowsamples */ - mng_int32 iSamplediv; - mng_int32 iRowsize; /* size of actual data in work row */ - mng_int32 iRowmax; /* maximum size of data in work row */ - mng_int32 iFilterofs; /* offset to filter-byte in work row */ - mng_int32 iPixelofs; /* offset to pixel-bytes in work row */ - mng_uint32 iLevel0; /* leveling variables */ - mng_uint32 iLevel1; - mng_uint32 iLevel2; - mng_uint32 iLevel3; - mng_uint8p pWorkrow; /* working row of pixel-data */ - mng_uint8p pPrevrow; /* previous row of pixel-data */ - mng_uint8p pRGBArow; /* intermediate row of RGBA8 or RGBA16 data */ - mng_bool bIsRGBA16; /* indicates intermediate row is RGBA16 */ - mng_bool bIsOpaque; /* indicates intermediate row is fully opaque */ - mng_int32 iFilterbpp; /* bpp index for filtering routines */ - - mng_int32 iSourcel; /* variables for showing objects */ - mng_int32 iSourcer; - mng_int32 iSourcet; - mng_int32 iSourceb; - mng_int32 iDestl; - mng_int32 iDestr; - mng_int32 iDestt; - mng_int32 iDestb; - - mng_objectp pFirstimgobj; /* double-linked list of */ - mng_objectp pLastimgobj; /* image-object structures */ - mng_objectp pFirstaniobj; /* double-linked list of */ - mng_objectp pLastaniobj; /* animation-object structures */ - -#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) - mng_uint8 aGammatab[256]; /* precomputed gamma lookup table */ - mng_float dLastgamma; /* last gamma used to compute table */ -#endif - - mng_fptr fDisplayrow; /* internal callback to display an - uncompressed/unfiltered/ - color-corrected row */ - mng_fptr fRestbkgdrow; /* internal callback for restore- - background processing of a row */ - mng_fptr fCorrectrow; /* internal callback to color-correct an - uncompressed/unfiltered row */ - mng_fptr fRetrieverow; /* internal callback to retrieve an - uncompressed/unfiltered row of data */ - mng_fptr fStorerow; /* internal callback to store an - uncompressed/unfiltered row of data */ - mng_fptr fProcessrow; /* internal callback to process an - uncompressed row of data */ - mng_fptr fDifferrow; /* internal callback to perform - added filter leveling and - differing on an unfiltered row */ - mng_fptr fScalerow; /* internal callback to scale a - delta-row to the bitdepth of its target */ - mng_fptr fDeltarow; /* internal callback to execute a - delta-row onto a target */ - mng_fptr fInitrowproc; /* internal callback to initialize - the row processing */ - - mng_uint16 iDEFIobjectid; /* DEFI fields */ - mng_bool bDEFIhasdonotshow; - mng_uint8 iDEFIdonotshow; - mng_bool bDEFIhasconcrete; - mng_uint8 iDEFIconcrete; - mng_bool bDEFIhasloca; - mng_int32 iDEFIlocax; - mng_int32 iDEFIlocay; - mng_bool bDEFIhasclip; - mng_int32 iDEFIclipl; - mng_int32 iDEFIclipr; - mng_int32 iDEFIclipt; - mng_int32 iDEFIclipb; - - mng_uint16 iBACKred; /* BACK fields */ - mng_uint16 iBACKgreen; - mng_uint16 iBACKblue; - mng_uint8 iBACKmandatory; - mng_uint16 iBACKimageid; - mng_uint8 iBACKtile; - - mng_uint8 iFRAMmode; /* FRAM fields (global) */ - mng_uint32 iFRAMdelay; - mng_uint32 iFRAMtimeout; - mng_bool bFRAMclipping; - mng_int32 iFRAMclipl; - mng_int32 iFRAMclipr; - mng_int32 iFRAMclipt; - mng_int32 iFRAMclipb; - - mng_uint8 iFramemode; /* current subframe variables */ - mng_uint32 iFramedelay; - mng_uint32 iFrametimeout; - mng_bool bFrameclipping; - mng_int32 iFrameclipl; - mng_int32 iFrameclipr; - mng_int32 iFrameclipt; - mng_int32 iFrameclipb; - - mng_uint32 iNextdelay; /* delay for *after* next image */ - - mng_uint8 iSHOWmode; /* SAVE fields */ - mng_uint16 iSHOWfromid; - mng_uint16 iSHOWtoid; - mng_uint16 iSHOWnextid; - mng_int16 iSHOWskip; - - mng_uint32 iGlobalPLTEcount; /* global PLTE fields */ - mng_rgbpaltab aGlobalPLTEentries; - - mng_uint32 iGlobalTRNSrawlen; /* global tRNS fields */ - mng_uint8arr aGlobalTRNSrawdata; - - mng_uint32 iGlobalGamma; /* global gAMA fields */ - - mng_uint32 iGlobalWhitepointx; /* global cHRM fields */ - mng_uint32 iGlobalWhitepointy; - mng_uint32 iGlobalPrimaryredx; - mng_uint32 iGlobalPrimaryredy; - mng_uint32 iGlobalPrimarygreenx; - mng_uint32 iGlobalPrimarygreeny; - mng_uint32 iGlobalPrimarybluex; - mng_uint32 iGlobalPrimarybluey; - - mng_uint8 iGlobalRendintent; /* global sRGB fields */ - - mng_uint32 iGlobalProfilesize; /* global iCCP fields */ - mng_ptr pGlobalProfile; - - mng_uint16 iGlobalBKGDred; /* global bKGD fields */ - mng_uint16 iGlobalBKGDgreen; - mng_uint16 iGlobalBKGDblue; - - mng_ptr pDeltaImage; /* delta-image fields */ - mng_uint8 iDeltaImagetype; - mng_uint8 iDeltatype; - mng_uint32 iDeltaBlockwidth; - mng_uint32 iDeltaBlockheight; - mng_uint32 iDeltaBlockx; - mng_uint32 iDeltaBlocky; - mng_bool bDeltaimmediate; - - mng_fptr fDeltagetrow; /* internal delta-proc callbacks */ - mng_fptr fDeltaaddrow; - mng_fptr fDeltareplacerow; - mng_fptr fDeltaputrow; - - mng_uint16 iMAGNfromid; - mng_uint16 iMAGNtoid; -#endif /* MNG_SUPPORT_DISPLAY */ - -#ifdef MNG_INCLUDE_ZLIB - z_stream sZlib; /* zlib (de)compression variables */ - - mng_int32 iZlevel; /* zlib compression parameters */ - mng_int32 iZmethod; - mng_int32 iZwindowbits; - mng_int32 iZmemlevel; - mng_int32 iZstrategy; - - mng_uint32 iMaxIDAT; /* maximum size of IDAT data */ - - mng_bool bInflating; /* indicates "inflate" in progress */ - mng_bool bDeflating; /* indicates "deflate" in progress */ -#endif /* MNG_INCLUDE_ZLIB */ - -#ifdef MNG_INCLUDE_JNG - mngjpeg_dctmethod eJPEGdctmethod; /* IJG compression variables */ - mng_int32 iJPEGquality; - mng_int32 iJPEGsmoothing; - mng_bool bJPEGcompressprogr; - mng_bool bJPEGcompressopt; - - mng_uint32 iMaxJDAT; /* maximum size of JDAT/JDAA data */ - - mngjpeg_compp pJPEGcinfo; /* compression structure */ - mngjpeg_errorp pJPEGcerr; /* error-manager compress */ - - mngjpeg_decompp pJPEGdinfo; /* decompression structure (JDAT) */ - mngjpeg_errorp pJPEGderr; /* error-manager decompress (JDAT) */ - mngjpeg_sourcep pJPEGdsrc; /* source-manager decompress (JDAT) */ - - mngjpeg_decompp pJPEGdinfo2; /* decompression structure (JDAA) */ - mngjpeg_errorp pJPEGderr2; /* error-manager decompress (JDAA) */ - mngjpeg_sourcep pJPEGdsrc2; /* source-manager decompress (JDAA) */ - - mng_uint8p pJPEGbuf; /* buffer for JPEG (de)compression (JDAT) */ - mng_uint32 iJPEGbufmax; /* allocated space for buffer (JDAT) */ - mng_uint8p pJPEGcurrent; /* current pointer into buffer (JDAT) */ - mng_uint32 iJPEGbufremain; /* remaining bytes in buffer (JDAT) */ - mng_uint32 iJPEGtoskip; /* bytes to skip on next input-block (JDAT) */ - - mng_uint8p pJPEGbuf2; /* buffer for JPEG (de)compression (JDAA) */ - mng_uint32 iJPEGbufmax2; /* allocated space for buffer (JDAA) */ - mng_uint8p pJPEGcurrent2; /* current pointer into buffer (JDAA) */ - mng_uint32 iJPEGbufremain2; /* remaining bytes in buffer (JDAA) */ - mng_uint32 iJPEGtoskip2; /* bytes to skip on next input-block (JDAA) */ - - mng_uint8p pJPEGrow; /* buffer for a JPEG row of samples (JDAT) */ - mng_uint32 iJPEGrowlen; - - mng_uint8p pJPEGrow2; /* buffer for a JPEG row of samples (JDAA) */ - mng_uint32 iJPEGrowlen2; - - mng_bool bJPEGcompress; /* indicates "compress" initialized */ - - mng_bool bJPEGdecompress; /* indicates "decompress" initialized (JDAT) */ - mng_bool bJPEGhasheader; /* indicates "readheader" succeeded (JDAT) */ - mng_bool bJPEGdecostarted; /* indicates "decompress" started (JDAT) */ - mng_bool bJPEGscanstarted; /* indicates "first scan" started (JDAT) */ - mng_bool bJPEGprogressive; /* indicates a progressive image (JDAT) */ - - mng_bool bJPEGdecompress2; /* indicates "decompress" initialized (JDAA) */ - mng_bool bJPEGhasheader2; /* indicates "readheader" succeeded (JDAA) */ - mng_bool bJPEGdecostarted2; /* indicates "decompress" started (JDAA) */ - mng_bool bJPEGscanstarted2; /* indicates "first scan" started (JDAA) */ - mng_bool bJPEGprogressive2; /* indicates a progressive image (JDAA) */ - - mng_fptr fStorerow2; /* internal callback to store an - uncompressed/unfiltered row of JPEG-data (JDAT) */ - - mng_fptr fStorerow3; /* internal callback to store an - uncompressed/unfiltered row of JPEG-data (JDAA) */ - - mng_uint32 iJPEGrow; /* row-number for current JPEG row */ - mng_uint32 iJPEGalpharow; /* nr. of rows filled with alpha */ - mng_uint32 iJPEGrgbrow; /* nr. of rows filled with 'color'-info */ - mng_uint32 iJPEGdisprow; /* nr. of rows already displayed "on-the-fly" */ - -#if defined(MNG_USE_SETJMP) && defined (MNG_INCLUDE_IJG6B) - jmp_buf sErrorbuf; /* setjmp/longjmp buffer (error-recovery) */ -#endif - -#endif /* MNG_INCLUDE_JNG */ - - mng_uint32 aCRCtable [256]; /* CRC prefab table */ - mng_bool bCRCcomputed; /* "has been build" indicator */ - - } mng_data; - -typedef mng_data * mng_datap; - -/* ************************************************************************** */ -/* * * */ -/* * Internal Callback-Function prototypes * */ -/* * * */ -/* ************************************************************************** */ - -typedef mng_retcode(*mng_displayrow) (mng_datap pData); -typedef mng_retcode(*mng_restbkgdrow) (mng_datap pData); -typedef mng_retcode(*mng_correctrow) (mng_datap pData); -typedef mng_retcode(*mng_retrieverow) (mng_datap pData); -typedef mng_retcode(*mng_storerow) (mng_datap pData); -typedef mng_retcode(*mng_processrow) (mng_datap pData); -typedef mng_retcode(*mng_initrowproc) (mng_datap pData); -typedef mng_retcode(*mng_differrow) (mng_datap pData); -typedef mng_retcode(*mng_scalerow) (mng_datap pData); -typedef mng_retcode(*mng_deltarow) (mng_datap pData); - -typedef mng_retcode(*mng_magnify_x) (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p iSrcline, - mng_uint8p iDstline); -typedef mng_retcode(*mng_magnify_y) (mng_datap pData, - mng_int32 iM, - mng_int32 iS, - mng_uint32 iWidth, - mng_uint8p iSrcline1, - mng_uint8p iSrcline2, - mng_uint8p iDstline); - -/* ************************************************************************** */ -/* * * */ -/* * Routines for swapping byte-order from and to graphic files * */ -/* * (This code is adapted from the libpng package) * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef MNG_BIGENDIAN_SUPPORTED -mng_uint32 mng_get_uint32 (mng_uint8p pBuf); -mng_int32 mng_get_int32 (mng_uint8p pBuf); -mng_uint16 mng_get_uint16 (mng_uint8p pBuf); -void mng_put_uint32 (mng_uint8p pBuf, - mng_uint32 i); -void mng_put_int32 (mng_uint8p pBuf, - mng_int32 i); -void mng_put_uint16 (mng_uint8p pBuf, - mng_uint16 i); -#else /* MNG_BIGENDIAN_SUPPORTED */ -#define mng_get_uint32(P) *(mng_uint32p)(P) -#define mng_get_int32(P) *(mng_int32p)(P) -#define mng_get_uint16(P) *(mng_uint16p)(P) -#define mng_put_uint32(P,I) *(mng_uint32p)(P) = (I) -#define mng_put_int32(P,I) *(mng_int32p)(P) = (I) -#define mng_put_uint16(P,I) *(mng_uint16p)(P) = (I) -#endif /* MNG_BIGENDIAN_SUPPORTED */ - -/* ************************************************************************** */ -/* * * */ -/* * Some handy(?) macro definitions * */ -/* * * */ -/* ************************************************************************** */ - -#define MAX_COORD(a, b) (((a) > (b)) ? (a) : (b)) -#define MIN_COORD(a, b) (((a) < (b)) ? (a) : (b)) - -/* ************************************************************************** */ - -#endif /* _libmng_data_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_display.c b/freeimage241/Source/LibMNG/libmng_display.c deleted file mode 100644 index d2e460c..0000000 --- a/freeimage241/Source/LibMNG/libmng_display.c +++ /dev/null @@ -1,4699 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_display.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Display management (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the display management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * - fixed frame_delay misalignment * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - added sanity check for frozen status * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - changed display_mend to reset state to initial or SAVE * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * - added process_save & process_seek routines * */ -/* * 0.5.1 - 05/14/2000 - G.Juyn * */ -/* * - added save_state and restore_state for SAVE/SEEK/TERM * */ -/* * processing * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added JNG support (JHDR/JDAT) * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - fixed problem with DEFI clipping * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added delta-image support (DHDR,PROM,IPNG,IJNG) * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed pointer confusion (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/09/2000 - G.Juyn * */ -/* * - fixed timer-handling to run with Mozilla (Tim Rowley) * */ -/* * 0.5.2 - 06/10/2000 - G.Juyn * */ -/* * - fixed some compilation-warnings (contrib Jason Morris) * */ -/* * * */ -/* * 0.5.3 - 06/12/2000 - G.Juyn * */ -/* * - fixed display of stored JNG images * */ -/* * 0.5.3 - 06/13/2000 - G.Juyn * */ -/* * - fixed problem with BASI-IEND as object 0 * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed delta-image processing * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed some minor stuff * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added speed-modifier to timing routine * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added support for PPLT chunk processing * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - swapped refresh parameters * */ -/* * * */ -/* * 0.9.0 - 06/30/2000 - G.Juyn * */ -/* * - changed refresh parameters to 'x,y,width,height' * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - implemented support for freeze/reset/resume & go_xxxx * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added support for improved timing * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed EOF processing behavior * */ -/* * - fixed TERM delay processing * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - fixed freeze & reset processing * */ -/* * 0.9.1 - 07/16/2000 - G.Juyn * */ -/* * - fixed storage of images during mng_read() * */ -/* * - fixed support for mng_display() after mng_read() * */ -/* * 0.9.1 - 07/24/2000 - G.Juyn * */ -/* * - fixed reading of still-images * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/21/2000 - G.Juyn * */ -/* * - fixed TERM processing delay of 0 msecs * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed problem with no refresh after TERM * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 09/16/2000 - G.Juyn * */ -/* * - fixed timing & refresh behavior for single PNG/JNG * */ -/* * 0.9.3 - 09/19/2000 - G.Juyn * */ -/* * - refixed timing & refresh behavior for single PNG/JNG * */ -/* * 0.9.3 - 10/02/2000 - G.Juyn * */ -/* * - fixed timing again (this is getting boring...) * */ -/* * - refixed problem with no refresh after TERM * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - fixed delta-processing behavior * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - added storage for pixel-/alpha-sampledepth for delta's * */ -/* * 0.9.3 - 10/27/2000 - G.Juyn * */ -/* * - fixed seperate read() & display() processing * */ -/* * * */ -/* * 0.9.4 - 10/31/2000 - G.Juyn * */ -/* * - fixed possible loop in display_resume() (Thanks Vova!) * */ -/* * 0.9.4 - 11/20/2000 - G.Juyn * */ -/* * - fixed unwanted repetition in mng_readdisplay() * */ -/* * 0.9.4 - 11/24/2000 - G.Juyn * */ -/* * - moved restore of object 0 to libmng_display * */ -/* * - added restore of object 0 to TERM processing !!! * */ -/* * - fixed TERM delay processing * */ -/* * - fixed TERM end processing (count = 0) * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * - set default level-set for filtertype=64 to all zeroes * */ -/* * * */ -/* * 0.9.5 - 1/20/2001 - G.Juyn * */ -/* * - fixed compiler-warnings Mozilla (thanks Tim) * */ -/* * 0.9.5 - 1/23/2001 - G.Juyn * */ -/* * - fixed timing-problem with switching framing_modes * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 02/13/2001 - G.Juyn * */ -/* * - fixed first FRAM_MODE=4 timing problem * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn * */ -/* * - fixed memory-leak for JNGs with alpha (Thanks Gregg!) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - fixed memory-leak with delta-images (Thanks Michael!) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_memory.h" -#include "libmng_zlib.h" -#include "libmng_jpeg.h" -#include "libmng_cms.h" -#include "libmng_pixels.h" -#include "libmng_display.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ - -mng_retcode set_delay (mng_datap pData, - mng_uint32 iInterval) -{ - if (!iInterval) /* at least 1 msec please! */ - iInterval = 1; - - if (!pData->fSettimer ((mng_handle)pData, iInterval)) - MNG_ERROR (pData, MNG_APPTIMERERROR) - - pData->bTimerset = MNG_TRUE; /* and indicate so */ - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Progressive display refresh - does the call to the refresh callback * */ -/* * and sets the timer to allow the app to perform the actual refresh to * */ -/* * the screen (eg. process its main message-loop) * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode display_progressive_refresh (mng_datap pData, - mng_uint32 iInterval) -{ - if (!pData->bSearching) /* we mustn't be searching !!! */ - { - if ((pData->bRunning) && /* let the app refresh first ? */ - (pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright)) - { - if (!pData->fRefresh (((mng_handle)pData), - pData->iUpdateleft, pData->iUpdatetop, - pData->iUpdateright - pData->iUpdateleft, - pData->iUpdatebottom - pData->iUpdatetop)) - MNG_ERROR (pData, MNG_APPMISCERROR) - - pData->iUpdateleft = 0; /* reset update-region */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; /* reset refreshneeded indicator */ - pData->bNeedrefresh = MNG_FALSE; - /* interval requested ? */ - if ((!pData->bFreezing) && (iInterval)) - { /* setup the timer */ - mng_retcode iRetcode = set_delay (pData, iInterval); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Generic display routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode interframe_delay (mng_datap pData) -{ - mng_uint32 iWaitfor = 0; - mng_uint32 iInterval; - mng_uint32 iRuninterval; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INTERFRAME_DELAY, MNG_LC_START) -#endif - - if (!pData->bSearching) /* we mustn't be searching !!! */ - { - if (pData->iFramedelay > 0) /* real delay ? */ - { - if ((pData->bRunning) && /* let the app refresh first ? */ - (pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright)) - if (!pData->fRefresh (((mng_handle)pData), - pData->iUpdateleft, pData->iUpdatetop, - pData->iUpdateright - pData->iUpdateleft, - pData->iUpdatebottom - pData->iUpdatetop)) - MNG_ERROR (pData, MNG_APPMISCERROR) - - pData->iUpdateleft = 0; /* reset update-region */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; /* reset refreshneeded indicator */ - pData->bNeedrefresh = MNG_FALSE; - /* get current tickcount */ - pData->iRuntime = pData->fGettickcount ((mng_handle)pData); - /* calculate interval since last sync-point */ - if (pData->iRuntime < pData->iSynctime) - iRuninterval = pData->iRuntime + ~pData->iSynctime + 1; - else - iRuninterval = pData->iRuntime - pData->iSynctime; - /* calculate actual run-time */ - if (pData->iRuntime < pData->iStarttime) - pData->iRuntime = pData->iRuntime + ~pData->iStarttime + 1; - else - pData->iRuntime = pData->iRuntime - pData->iStarttime; - - if (pData->iTicks) /* what are we aiming for */ - { - switch (pData->iSpeed) /* honor speed modifier */ - { - case mng_st_fast : - { - iWaitfor = (mng_uint32)(( 500 * pData->iFramedelay) / pData->iTicks); - break; - } - case mng_st_slow : - { - iWaitfor = (mng_uint32)((3000 * pData->iFramedelay) / pData->iTicks); - break; - } - case mng_st_slowest : - { - iWaitfor = (mng_uint32)((8000 * pData->iFramedelay) / pData->iTicks); - break; - } - default : - { - iWaitfor = (mng_uint32)((1000 * pData->iFramedelay) / pData->iTicks); - } - } - } - else - { - if (pData->eImagetype == mng_it_mng) - iWaitfor = 1000; - else - iWaitfor = 1; - } - - if (iWaitfor > iRuninterval) /* delay necessary ? */ - iInterval = iWaitfor - iRuninterval; - else - iInterval = 1; /* force app to process messageloop */ - - if (pData->bRunning) /* set the timer ? */ - { - iRetcode = set_delay (pData, iInterval); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - - if (pData->bRunning) /* increase frametime in advance */ - pData->iFrametime = pData->iFrametime + iWaitfor; - /* setup for next delay */ - pData->iFramedelay = pData->iNextdelay; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INTERFRAME_DELAY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -void set_display_routine (mng_datap pData) -{ /* actively running ? */ - if ((pData->bRunning) && (!pData->bFreezing)) - { - switch (pData->iCanvasstyle) /* determine display routine */ - { - case MNG_CANVAS_RGB8 : { pData->fDisplayrow = (mng_fptr)display_rgb8; break; } - case MNG_CANVAS_RGBA8 : { pData->fDisplayrow = (mng_fptr)display_rgba8; break; } - case MNG_CANVAS_ARGB8 : { pData->fDisplayrow = (mng_fptr)display_argb8; break; } - case MNG_CANVAS_RGB8_A8 : { pData->fDisplayrow = (mng_fptr)display_rgb8_a8; break; } - case MNG_CANVAS_BGR8 : { pData->fDisplayrow = (mng_fptr)display_bgr8; break; } - case MNG_CANVAS_BGRA8 : { pData->fDisplayrow = (mng_fptr)display_bgra8; break; } - case MNG_CANVAS_BGRA8PM : { pData->fDisplayrow = (mng_fptr)display_bgra8_pm; break; } - case MNG_CANVAS_ABGR8 : { pData->fDisplayrow = (mng_fptr)display_abgr8; break; } -/* case MNG_CANVAS_RGB16 : { pData->fDisplayrow = (mng_fptr)display_rgb16; break; } */ -/* case MNG_CANVAS_RGBA16 : { pData->fDisplayrow = (mng_fptr)display_rgba16; break; } */ -/* case MNG_CANVAS_ARGB16 : { pData->fDisplayrow = (mng_fptr)display_argb16; break; } */ -/* case MNG_CANVAS_BGR16 : { pData->fDisplayrow = (mng_fptr)display_bgr16; break; } */ -/* case MNG_CANVAS_BGRA16 : { pData->fDisplayrow = (mng_fptr)display_bgra16; break; } */ -/* case MNG_CANVAS_ABGR16 : { pData->fDisplayrow = (mng_fptr)display_abgr16; break; } */ -/* case MNG_CANVAS_INDEX8 : { pData->fDisplayrow = (mng_fptr)display_index8; break; } */ -/* case MNG_CANVAS_INDEXA8 : { pData->fDisplayrow = (mng_fptr)display_indexa8; break; } */ -/* case MNG_CANVAS_AINDEX8 : { pData->fDisplayrow = (mng_fptr)display_aindex8; break; } */ -/* case MNG_CANVAS_GRAY8 : { pData->fDisplayrow = (mng_fptr)display_gray8; break; } */ -/* case MNG_CANVAS_GRAY16 : { pData->fDisplayrow = (mng_fptr)display_gray16; break; } */ -/* case MNG_CANVAS_GRAYA8 : { pData->fDisplayrow = (mng_fptr)display_graya8; break; } */ -/* case MNG_CANVAS_GRAYA16 : { pData->fDisplayrow = (mng_fptr)display_graya16; break; } */ -/* case MNG_CANVAS_AGRAY8 : { pData->fDisplayrow = (mng_fptr)display_agray8; break; } */ -/* case MNG_CANVAS_AGRAY16 : { pData->fDisplayrow = (mng_fptr)display_agray16; break; } */ -/* case MNG_CANVAS_DX15 : { pData->fDisplayrow = (mng_fptr)display_dx15; break; } */ -/* case MNG_CANVAS_DX16 : { pData->fDisplayrow = (mng_fptr)display_dx16; break; } */ - } - } - - return; -} - -/* ************************************************************************** */ - -mng_retcode load_bkgdlayer (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_LOAD_BKGDLAYER, MNG_LC_START) -#endif - /* actively running ? */ - if ((pData->bRunning) && (!pData->bFreezing)) - { - mng_int32 iY; - mng_retcode iRetcode; /* save values */ - mng_int32 iDestl = pData->iDestl; - mng_int32 iDestr = pData->iDestr; - mng_int32 iDestt = pData->iDestt; - mng_int32 iDestb = pData->iDestb; - mng_int32 iSourcel = pData->iSourcel; - mng_int32 iSourcer = pData->iSourcer; - mng_int32 iSourcet = pData->iSourcet; - mng_int32 iSourceb = pData->iSourceb; - mng_int8 iPass = pData->iPass; - mng_int32 iRow = pData->iRow; - mng_int32 iRowinc = pData->iRowinc; - mng_int32 iCol = pData->iCol; - mng_int32 iColinc = pData->iColinc; - mng_int32 iRowsamples = pData->iRowsamples; - mng_int32 iRowsize = pData->iRowsize; - mng_bool bIsRGBA16 = pData->bIsRGBA16; - mng_bool bIsOpaque = pData->bIsOpaque; - mng_fptr fCorrectrow = pData->fCorrectrow; - - pData->iDestl = 0; /* determine clipping region */ - pData->iDestt = 0; - pData->iDestr = pData->iWidth; - pData->iDestb = pData->iHeight; - - if (pData->bFrameclipping) /* frame clipping specified ? */ - { - pData->iDestl = MAX_COORD (pData->iDestl, pData->iFrameclipl); - pData->iDestt = MAX_COORD (pData->iDestt, pData->iFrameclipt); - pData->iDestr = MIN_COORD (pData->iDestr, pData->iFrameclipr); - pData->iDestb = MIN_COORD (pData->iDestb, pData->iFrameclipb); - } - /* anything to clear ? */ - if ((pData->iDestr >= pData->iDestl) && (pData->iDestb >= pData->iDestt)) - { - pData->iPass = -1; /* these are the object's dimensions now */ - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iWidth; - pData->iRowsize = pData->iRowsamples << 2; - pData->bIsRGBA16 = MNG_FALSE; /* let's keep it simple ! */ - pData->bIsOpaque = MNG_TRUE; - - pData->iSourcel = 0; /* source relative to destination */ - pData->iSourcer = pData->iDestr - pData->iDestl; - pData->iSourcet = 0; - pData->iSourceb = pData->iDestb - pData->iDestt; - - set_display_routine (pData); /* determine display routine */ - /* default restore using preset BG color */ - pData->fRestbkgdrow = (mng_fptr)restore_bkgd_bgcolor; - - if (((pData->eImagetype == mng_it_png) || (pData->eImagetype == mng_it_jng)) && - (pData->bUseBKGD)) - { /* prefer bKGD in PNG/JNG */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) - pImage = (mng_imagep)pData->pObjzero; - - if (pImage->pImgbuf->bHasBKGD) - pData->fRestbkgdrow = (mng_fptr)restore_bkgd_bkgd; - } - - if (pData->fGetbkgdline) /* background-canvas-access callback set ? */ - { - switch (pData->iBkgdstyle) - { - case MNG_CANVAS_RGB8 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_rgb8; break; } - case MNG_CANVAS_BGR8 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_bgr8; break; } - /* case MNG_CANVAS_RGB16 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_rgb16; break; } */ - /* case MNG_CANVAS_BGR16 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_bgr16; break; } */ - /* case MNG_CANVAS_INDEX8 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_index8; break; } */ - /* case MNG_CANVAS_GRAY8 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_gray8; break; } */ - /* case MNG_CANVAS_GRAY16 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_gray16; break; } */ - /* case MNG_CANVAS_DX15 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_dx15; break; } */ - /* case MNG_CANVAS_DX16 : { pData->fRestbkgdrow = (mng_fptr)restore_bkgd_dx16; break; } */ - } - } - - if (pData->bHasBACK) - { /* background image ? */ - if ((pData->iBACKmandatory & 0x02) && (pData->iBACKimageid)) - pData->fRestbkgdrow = (mng_fptr)restore_bkgd_backimage; - else /* background color ? */ - if (pData->iBACKmandatory & 0x01) - pData->fRestbkgdrow = (mng_fptr)restore_bkgd_backcolor; - - } - - pData->fCorrectrow = MNG_NULL; /* default no color-correction */ - - - /* TODO: determine color correction; this is tricky; - the BACK color is treated differently as the image; - it probably requires a rewrite of the logic here... */ - - - /* get a temporary row-buffer */ - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize) - - iY = pData->iDestt; /* this is where we start */ - iRetcode = MNG_NOERROR; /* so far, so good */ - - while ((!iRetcode) && (iY < pData->iDestb)) - { /* restore a background row */ - iRetcode = ((mng_restbkgdrow)pData->fRestbkgdrow) (pData); - /* color correction ? */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* so... display it */ - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) - iRetcode = next_row (pData); /* adjust variables for next row */ - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pData->iRowsize) - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - - pData->iDestl = iDestl; /* restore values */ - pData->iDestr = iDestr; - pData->iDestt = iDestt; - pData->iDestb = iDestb; - pData->iSourcel = iSourcel; - pData->iSourcer = iSourcer; - pData->iSourcet = iSourcet; - pData->iSourceb = iSourceb; - pData->iPass = iPass; - pData->iRow = iRow; - pData->iRowinc = iRowinc; - pData->iCol = iCol; - pData->iColinc = iColinc; - pData->iRowsamples = iRowsamples; - pData->iRowsize = iRowsize; - pData->bIsRGBA16 = bIsRGBA16; - pData->bIsOpaque = bIsOpaque; - pData->fCorrectrow = fCorrectrow; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_LOAD_BKGDLAYER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode clear_canvas (mng_datap pData) -{ - mng_int32 iY; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CANVAS, MNG_LC_START) -#endif - - pData->iDestl = 0; /* clipping region is full canvas! */ - pData->iDestt = 0; - pData->iDestr = pData->iWidth; - pData->iDestb = pData->iHeight; - - pData->iSourcel = 0; /* source is same as destination */ - pData->iSourcer = pData->iWidth; - pData->iSourcet = 0; - pData->iSourceb = pData->iHeight; - - pData->iPass = -1; /* these are the object's dimensions now */ - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iWidth; - pData->iRowsize = pData->iRowsamples << 2; - pData->bIsRGBA16 = MNG_FALSE; /* let's keep it simple ! */ - pData->bIsOpaque = MNG_TRUE; - - set_display_routine (pData); /* determine display routine */ - /* get a temporary row-buffer */ - /* it's transparent black by default!! */ - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize) - - iY = pData->iDestt; /* this is where we start */ - iRetcode = MNG_NOERROR; /* so far, so good */ - - while ((!iRetcode) && (iY < pData->iDestb)) - { /* clear a row then */ - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) - iRetcode = next_row (pData); /* adjust variables for next row */ - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pData->iRowsize) - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEAR_CANVAS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode next_frame (mng_datap pData, - mng_uint8 iFramemode, - mng_uint8 iChangedelay, - mng_uint32 iDelay, - mng_uint8 iChangetimeout, - mng_uint32 iTimeout, - mng_uint8 iChangeclipping, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_FRAME, MNG_LC_START) -#endif - - if (!pData->iBreakpoint) /* no previous break here ? */ - { - mng_uint8 iOldmode = pData->iFramemode; - /* interframe delay required ? */ - if ((iOldmode == 2) || (iOldmode == 4)) - { -/* changed here because FRAM 1/3 will delay themselves before each image */ - if ((pData->iFrameseq) && (iFramemode != 1) && (iFramemode != 3)) - iRetcode = interframe_delay (pData); - else - pData->iFramedelay = pData->iNextdelay; - } - else - { /* delay before inserting background layer? */ - if ((pData->bFramedone) && (iFramemode == 4)) - iRetcode = interframe_delay (pData); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* now we'll assume we're in the next frame! */ - if (iFramemode) /* save the new framing mode ? */ - { - pData->iFRAMmode = iFramemode; - pData->iFramemode = iFramemode; - } - else /* reload default */ - pData->iFramemode = pData->iFRAMmode; - - if (iChangedelay) /* delay changed ? */ - { - pData->iNextdelay = iDelay; /* for *after* next subframe */ - - if ((iOldmode == 2) || (iOldmode == 4)) -/* pData->iFramedelay = iDelay; */ - pData->iFramedelay = pData->iFRAMdelay; - - if (iChangedelay == 2) /* also overall ? */ - pData->iFRAMdelay = iDelay; - } - else - { /* reload default */ - pData->iNextdelay = pData->iFRAMdelay; - -/* if ((iOldmode == 2) || (iOldmode == 4)) - pData->iFramedelay = pData->iNextdelay; */ - } - - if (iChangetimeout) /* timeout changed ? */ - { /* for next subframe */ - pData->iFrametimeout = iTimeout; - - if ((iChangetimeout == 2) || /* also overall ? */ - (iChangetimeout == 4) || - (iChangetimeout == 6) || - (iChangetimeout == 8)) - pData->iFRAMtimeout = iTimeout; - } - else /* reload default */ - pData->iFrametimeout = pData->iFRAMtimeout; - - if (iChangeclipping) /* clipping changed ? */ - { - pData->bFrameclipping = MNG_TRUE; - - if (!iCliptype) /* absolute ? */ - { - pData->iFrameclipl = iClipl; - pData->iFrameclipr = iClipr; - pData->iFrameclipt = iClipt; - pData->iFrameclipb = iClipb; - } - else /* relative */ - { - pData->iFrameclipl = pData->iFrameclipl + iClipl; - pData->iFrameclipr = pData->iFrameclipr + iClipr; - pData->iFrameclipt = pData->iFrameclipt + iClipt; - pData->iFrameclipb = pData->iFrameclipb + iClipb; - } - - if (iChangeclipping == 2) /* also overall ? */ - { - pData->bFRAMclipping = MNG_TRUE; - - if (!iCliptype) /* absolute ? */ - { - pData->iFRAMclipl = iClipl; - pData->iFRAMclipr = iClipr; - pData->iFRAMclipt = iClipt; - pData->iFRAMclipb = iClipb; - } - else /* relative */ - { - pData->iFRAMclipl = pData->iFRAMclipl + iClipl; - pData->iFRAMclipr = pData->iFRAMclipr + iClipr; - pData->iFRAMclipt = pData->iFRAMclipt + iClipt; - pData->iFRAMclipb = pData->iFRAMclipb + iClipb; - } - } - } - else - { /* reload defaults */ - pData->bFrameclipping = pData->bFRAMclipping; - pData->iFrameclipl = pData->iFRAMclipl; - pData->iFrameclipr = pData->iFRAMclipr; - pData->iFrameclipt = pData->iFRAMclipt; - pData->iFrameclipb = pData->iFRAMclipb; - } - } - - if (!pData->bTimerset) /* timer still off ? */ - { - if ((pData->iFramemode == 4) || /* insert background layer after a new frame */ - (!pData->iLayerseq)) /* and certainly before the very first layer */ - iRetcode = load_bkgdlayer (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if ((pData->bDisplaying) && (pData->bRunning)) - { - pData->iFrameseq++; /* count the frame ! */ - pData->bFramedone = MNG_TRUE; /* and indicate we've done one */ - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_FRAME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode next_layer (mng_datap pData) -{ - mng_imagep pImage; - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_LAYER, MNG_LC_START) -#endif - - if (!pData->iBreakpoint) /* no previous break here ? */ - { /* interframe delay required ? */ - if ((pData->eImagetype == mng_it_mng) && (pData->iLayerseq) && - ((pData->iFramemode == 1) || (pData->iFramemode == 3))) - iRetcode = interframe_delay (pData); - else - pData->iFramedelay = pData->iNextdelay; - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (!pData->bTimerset) /* timer still off ? */ - { - if (!pData->iLayerseq) /* restore background for the very first layer ? */ - { /* wait till IDAT/JDAT for PNGs & JNGs !!! */ - if ((pData->eImagetype == mng_it_png) || (pData->eImagetype == mng_it_jng)) - pData->bRestorebkgd = MNG_TRUE; - else - { /* for MNG we do it right away */ - iRetcode = load_bkgdlayer (pData); - - if (pData->bRunning) - pData->iLayerseq++; /* and it counts as a layer then ! */ - } - } - else - if (pData->iFramemode == 3) /* restore background for each layer ? */ - iRetcode = load_bkgdlayer (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bHasDHDR) /* processing a delta-image ? */ - pImage = (mng_imagep)pData->pDeltaImage; - else - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* not an active object ? */ - pImage = (mng_imagep)pData->pObjzero; - /* determine display rectangle */ - pData->iDestl = MAX_COORD ((mng_int32)0, pImage->iPosx); - pData->iDestt = MAX_COORD ((mng_int32)0, pImage->iPosy); - /* is it a valid buffer ? */ - if ((pImage->pImgbuf->iWidth) && (pImage->pImgbuf->iHeight)) - { - pData->iDestr = MIN_COORD ((mng_int32)pData->iWidth, - pImage->iPosx + (mng_int32)pImage->pImgbuf->iWidth ); - pData->iDestb = MIN_COORD ((mng_int32)pData->iHeight, - pImage->iPosy + (mng_int32)pImage->pImgbuf->iHeight); - } - else /* it's a single image ! */ - { - pData->iDestr = MIN_COORD ((mng_int32)pData->iWidth, - (mng_int32)pData->iDatawidth ); - pData->iDestb = MIN_COORD ((mng_int32)pData->iHeight, - (mng_int32)pData->iDataheight); - } - - if (pData->bFrameclipping) /* frame clipping specified ? */ - { - pData->iDestl = MAX_COORD (pData->iDestl, pData->iFrameclipl); - pData->iDestt = MAX_COORD (pData->iDestt, pData->iFrameclipt); - pData->iDestr = MIN_COORD (pData->iDestr, pData->iFrameclipr); - pData->iDestb = MIN_COORD (pData->iDestb, pData->iFrameclipb); - } - - if (pImage->bClipped) /* is the image clipped itself ? */ - { - pData->iDestl = MAX_COORD (pData->iDestl, pImage->iClipl); - pData->iDestt = MAX_COORD (pData->iDestt, pImage->iClipt); - pData->iDestr = MIN_COORD (pData->iDestr, pImage->iClipr); - pData->iDestb = MIN_COORD (pData->iDestb, pImage->iClipb); - } - /* determine source starting point */ - pData->iSourcel = MAX_COORD ((mng_int32)0, pData->iDestl - pImage->iPosx); - pData->iSourcet = MAX_COORD ((mng_int32)0, pData->iDestt - pImage->iPosy); - - if ((pImage->pImgbuf->iWidth) && (pImage->pImgbuf->iHeight)) - { /* and maximum size */ - pData->iSourcer = MIN_COORD ((mng_int32)pImage->pImgbuf->iWidth, - pData->iSourcel + pData->iDestr - pData->iDestl); - pData->iSourceb = MIN_COORD ((mng_int32)pImage->pImgbuf->iHeight, - pData->iSourcet + pData->iDestb - pData->iDestt); - } - else /* it's a single image ! */ - { - pData->iSourcer = pData->iSourcel + pData->iDestr - pData->iDestl; - pData->iSourceb = pData->iSourcet + pData->iDestb - pData->iDestt; - } - - if (pData->bRunning) - pData->iLayerseq++; /* count the layer ! */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_LAYER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_image (mng_datap pData, - mng_imagep pImage, - mng_bool bLayeradvanced) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_IMAGE, MNG_LC_START) -#endif - /* actively running ? */ - if ((pData->bRunning) && (!pData->bFreezing)) - { - if ( (!pData->iBreakpoint) && /* needs magnification ? */ - ( (pImage->iMAGN_MethodX) || (pImage->iMAGN_MethodY) ) ) - { - iRetcode = magnify_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - - pData->pRetrieveobj = pImage; /* so retrieve-row and color-correction can find it */ - - if (!bLayeradvanced) /* need to advance the layer ? */ - { - mng_imagep pSave = pData->pCurrentobj; - pData->pCurrentobj = pImage; - next_layer (pData); /* advance to next layer */ - pData->pCurrentobj = pSave; - } - /* need to restore the background ? */ - if ((!pData->bTimerset) && (pData->bRestorebkgd)) - { - mng_imagep pSave = pData->pCurrentobj; - pData->pCurrentobj = pImage; - pData->bRestorebkgd = MNG_FALSE; - iRetcode = load_bkgdlayer (pData); - pData->pCurrentobj = pSave; - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bRunning) - pData->iLayerseq++; /* and it counts as a layer then ! */ - } - /* actively running ? */ - if ((pData->bRunning) && (!pData->bFreezing)) - { - if (!pData->bTimerset) /* all systems still go ? */ - { - pData->iBreakpoint = 0; /* let's make absolutely sure... */ - /* anything to display ? */ - if ((pData->iDestr >= pData->iDestl) && (pData->iDestb >= pData->iDestt)) - { - mng_int32 iY; - - set_display_routine (pData); /* determine display routine */ - /* and image-buffer retrieval routine */ - switch (pImage->pImgbuf->iColortype) - { - case 0 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_g16; - else - pData->fRetrieverow = (mng_fptr)retrieve_g8; - - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - case 2 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_rgb16; - else - pData->fRetrieverow = (mng_fptr)retrieve_rgb8; - - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - - case 3 : { pData->fRetrieverow = (mng_fptr)retrieve_idx8; - pData->bIsOpaque = (mng_bool)(!pImage->pImgbuf->bHasTRNS); - break; - } - - - case 4 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_ga16; - else - pData->fRetrieverow = (mng_fptr)retrieve_ga8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - - case 6 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_rgba16; - else - pData->fRetrieverow = (mng_fptr)retrieve_rgba8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - case 8 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_g16; - else - pData->fRetrieverow = (mng_fptr)retrieve_g8; - - pData->bIsOpaque = MNG_TRUE; - break; - } - - case 10 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_rgb16; - else - pData->fRetrieverow = (mng_fptr)retrieve_rgb8; - - pData->bIsOpaque = MNG_TRUE; - break; - } - - - case 12 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_ga16; - else - pData->fRetrieverow = (mng_fptr)retrieve_ga8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - - case 14 : { if (pImage->pImgbuf->iBitdepth > 8) - pData->fRetrieverow = (mng_fptr)retrieve_rgba16; - else - pData->fRetrieverow = (mng_fptr)retrieve_rgba8; - - pData->bIsOpaque = MNG_FALSE; - break; - } - - } - - pData->iPass = -1; /* these are the object's dimensions now */ - pData->iRow = pData->iSourcet; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pImage->pImgbuf->iWidth; - pData->iRowsize = pData->iRowsamples << 2; - pData->bIsRGBA16 = MNG_FALSE; - /* adjust for 16-bit object ? */ - if (pImage->pImgbuf->iBitdepth > 8) - { - pData->bIsRGBA16 = MNG_TRUE; - pData->iRowsize = pData->iRowsamples << 3; - } - - pData->fCorrectrow = MNG_NULL; /* default no color-correction */ - -#ifdef MNG_NO_CMS - iRetcode = MNG_NOERROR; -#else -#if defined(MNG_FULL_CMS) /* determine color-management routine */ - iRetcode = init_full_cms_object (pData); -#elif defined(MNG_GAMMA_ONLY) - iRetcode = init_gamma_only_object (pData); -#elif defined(MNG_APP_CMS) - iRetcode = init_app_cms_object (pData); -#endif - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_NO_CMS */ - /* get a temporary row-buffer */ - MNG_ALLOC (pData, pData->pRGBArow, pData->iRowsize) - - iY = pData->iSourcet; /* this is where we start */ - - while ((!iRetcode) && (iY < pData->iSourceb)) - { /* get a row */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - /* color correction ? */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* so... display it */ - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) /* adjust variables for next row */ - iRetcode = next_row (pData); - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pData->iRowsize) - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#if defined(MNG_INCLUDE_LCMS) /* cleanup cms stuff */ - iRetcode = mng_clear_cms (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_IMAGE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* whehehe, this is good ! */ -} - -/* ************************************************************************** */ - -mng_retcode execute_delta_image (mng_datap pData, - mng_imagep pTarget, - mng_imagep pDelta) -{ - mng_imagedatap pBuftarget = pTarget->pImgbuf; - mng_imagedatap pBufdelta = pDelta->pImgbuf; - mng_uint32 iY; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_EXECUTE_DELTA_IMAGE, MNG_LC_START) -#endif - /* actively running ? */ - if ((pData->bRunning) && (!pData->bFreezing)) - { - if (pBufdelta->bHasPLTE) /* palette in delta ? */ - { - mng_uint32 iX; - /* new palette larger than old one ? */ - if ((!pBuftarget->bHasPLTE) || (pBuftarget->iPLTEcount < pBufdelta->iPLTEcount)) - pBuftarget->iPLTEcount = pBufdelta->iPLTEcount; - /* it's definitely got a PLTE now */ - pBuftarget->bHasPLTE = MNG_TRUE; - - for (iX = 0; iX < pBufdelta->iPLTEcount; iX++) - { - pBuftarget->aPLTEentries[iX].iRed = pBufdelta->aPLTEentries[iX].iRed; - pBuftarget->aPLTEentries[iX].iGreen = pBufdelta->aPLTEentries[iX].iGreen; - pBuftarget->aPLTEentries[iX].iBlue = pBufdelta->aPLTEentries[iX].iBlue; - } - } - - if (pBufdelta->bHasTRNS) /* cheap transparency in delta ? */ - { - switch (pData->iColortype) /* drop it into the target */ - { - case 0: { /* gray */ - pBuftarget->iTRNSgray = pBufdelta->iTRNSgray; - pBuftarget->iTRNSred = 0; - pBuftarget->iTRNSgreen = 0; - pBuftarget->iTRNSblue = 0; - pBuftarget->iTRNScount = 0; - break; - } - case 2: { /* rgb */ - pBuftarget->iTRNSgray = 0; - pBuftarget->iTRNSred = pBufdelta->iTRNSred; - pBuftarget->iTRNSgreen = pBufdelta->iTRNSgreen; - pBuftarget->iTRNSblue = pBufdelta->iTRNSblue; - pBuftarget->iTRNScount = 0; - break; - } - case 3: { /* indexed */ - pBuftarget->iTRNSgray = 0; - pBuftarget->iTRNSred = 0; - pBuftarget->iTRNSgreen = 0; - pBuftarget->iTRNSblue = 0; - /* existing range smaller than new one ? */ - if ((!pBuftarget->bHasTRNS) || (pBuftarget->iTRNScount < pBufdelta->iTRNScount)) - pBuftarget->iTRNScount = pBufdelta->iTRNScount; - - MNG_COPY (pBuftarget->aTRNSentries, pBufdelta->aTRNSentries, pBufdelta->iTRNScount) - break; - } - } - - pBuftarget->bHasTRNS = MNG_TRUE; /* tell it it's got a tRNS now */ - } - - if (pBufdelta->bHasBKGD) /* bkgd in source ? */ - { /* drop it onto the target */ - pBuftarget->bHasBKGD = MNG_TRUE; - pBuftarget->iBKGDindex = pBufdelta->iBKGDindex; - pBuftarget->iBKGDgray = pBufdelta->iBKGDgray; - pBuftarget->iBKGDred = pBufdelta->iBKGDred; - pBuftarget->iBKGDgreen = pBufdelta->iBKGDgreen; - pBuftarget->iBKGDblue = pBufdelta->iBKGDblue; - } - - if (pBufdelta->bHasGAMA) /* gamma in source ? */ - { - pBuftarget->bHasGAMA = MNG_TRUE; /* drop it onto the target */ - pBuftarget->iGamma = pBufdelta->iGamma; - } - - if (pBufdelta->bHasCHRM) /* chroma in delta ? */ - { /* drop it onto the target */ - pBuftarget->bHasCHRM = MNG_TRUE; - pBuftarget->iWhitepointx = pBufdelta->iWhitepointx; - pBuftarget->iWhitepointy = pBufdelta->iWhitepointy; - pBuftarget->iPrimaryredx = pBufdelta->iPrimaryredx; - pBuftarget->iPrimaryredy = pBufdelta->iPrimaryredy; - pBuftarget->iPrimarygreenx = pBufdelta->iPrimarygreenx; - pBuftarget->iPrimarygreeny = pBufdelta->iPrimarygreeny; - pBuftarget->iPrimarybluex = pBufdelta->iPrimarybluex; - pBuftarget->iPrimarybluey = pBufdelta->iPrimarybluey; - } - - if (pBufdelta->bHasSRGB) /* sRGB in delta ? */ - { /* drop it onto the target */ - pBuftarget->bHasSRGB = MNG_TRUE; - pBuftarget->iRenderingintent = pBufdelta->iRenderingintent; - } - - if (pBufdelta->bHasICCP) /* ICC profile in delta ? */ - { - pBuftarget->bHasICCP = MNG_TRUE; /* drop it onto the target */ - - if (pBuftarget->pProfile) /* profile existed ? */ - MNG_FREEX (pData, pBuftarget->pProfile, pBuftarget->iProfilesize) - /* allocate a buffer & copy it */ - MNG_ALLOC (pData, pBuftarget->pProfile, pBufdelta->iProfilesize) - MNG_COPY (pBuftarget->pProfile, pBufdelta->pProfile, pBufdelta->iProfilesize) - /* store it's length as well */ - pBuftarget->iProfilesize = pBufdelta->iProfilesize; - } - /* need to execute delta pixels ? */ - if ((!pData->bDeltaimmediate) && (pData->iDeltatype != MNG_DELTATYPE_NOCHANGE)) - { - pData->fScalerow = MNG_NULL; /* not needed by default */ - - switch (pBuftarget->iBitdepth) /* determine scaling routine */ - { - - - } - - pData->fDeltarow = MNG_NULL; /* let's assume there's nothing to do */ - - switch (pBuftarget->iColortype) /* determine delta processing routine */ - { - case 0 : ; - case 8 : { /* gray */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3) || - (pBufdelta->iColortype == 8)) - { - switch (pBuftarget->iBitdepth) - { - case 1 : { pData->fDeltarow = (mng_fptr)delta_g1_g1; break; } - case 2 : { pData->fDeltarow = (mng_fptr)delta_g2_g2; break; } - case 4 : { pData->fDeltarow = (mng_fptr)delta_g4_g4; break; } - case 8 : { pData->fDeltarow = (mng_fptr)delta_g8_g8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_g16_g16; break; } - } - } - } - - break; - } - - case 2 : ; - case 10 : { /* rgb */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 2) || (pBufdelta->iColortype == 10)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_rgb8_rgb8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_rgb16_rgb16; break; } - } - } - } - - break; - } - - case 3 : { /* indexed; abuse gray routines */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3)) - { - switch (pBuftarget->iBitdepth) - { - case 1 : { pData->fDeltarow = (mng_fptr)delta_g1_g1; break; } - case 2 : { pData->fDeltarow = (mng_fptr)delta_g2_g2; break; } - case 4 : { pData->fDeltarow = (mng_fptr)delta_g4_g4; break; } - case 8 : { pData->fDeltarow = (mng_fptr)delta_g8_g8; break; } - } - } - } - - break; - } - - case 4 : ; - case 12 : { /* gray + alpha */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 4) || (pBufdelta->iColortype == 12)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_ga8_ga8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_ga16_ga16; break; } - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3) || - (pBufdelta->iColortype == 8)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_ga8_g8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_ga16_g16; break; } - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_ga8_a8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_ga16_a16; break; } - } - } - } - - break; - } - - case 6 : ; - case 14 : { /* rgb + alpha */ - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - if ((pBufdelta->iColortype == 6) || (pBufdelta->iColortype == 14)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_rgba8_rgba8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_rgba16_rgba16; break; } - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - { - if ((pBufdelta->iColortype == 2) || (pBufdelta->iColortype == 10)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_rgba8_rgb8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_rgba16_rgb16; break; } - } - } - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - { - if ((pBufdelta->iColortype == 0) || (pBufdelta->iColortype == 3)) - { - switch (pBuftarget->iBitdepth) - { - case 8 : { pData->fDeltarow = (mng_fptr)delta_rgba8_a8; break; } - case 16 : { pData->fDeltarow = (mng_fptr)delta_rgba16_a16; break; } - } - } - } - - break; - } - - } - - if (pData->fDeltarow) /* do we need to take action ? */ - { - pData->iPass = -1; /* setup row dimensions and stuff */ - pData->iRow = pData->iDeltaBlocky; - pData->iRowinc = 1; - pData->iCol = pData->iDeltaBlockx; - pData->iColinc = 1; - pData->iRowsamples = pBufdelta->iWidth; - pData->iRowsize = pBuftarget->iRowsize; - /* indicate where to retrieve & where to store */ - pData->pRetrieveobj = (mng_objectp)pDelta; - pData->pStoreobj = (mng_objectp)pTarget; - - if (pData->pRGBArow) /* prevent duplicate allocation! */ - MNG_FREE (pData, pData->pRGBArow, (pData->iDatawidth << 3)) - /* get a temporary row-buffer */ - MNG_ALLOC (pData, pData->pRGBArow, pBufdelta->iRowsize) - - iY = 0; /* this is where we start */ - iRetcode = MNG_NOERROR; /* still oke for now */ - - while ((!iRetcode) && (iY < pBufdelta->iHeight)) - { /* get a row */ - mng_uint8p pWork = pBufdelta->pImgdata + (iY * pBufdelta->iRowsize); - - MNG_COPY (pData->pRGBArow, pWork, pBufdelta->iRowsize); - - if (pData->fScalerow) /* scale it (if necessary) */ - iRetcode = ((mng_scalerow)pData->fScalerow) (pData); - - if (!iRetcode) /* and... execute it */ - iRetcode = ((mng_deltarow)pData->fDeltarow) (pData); - - if (!iRetcode) /* adjust variables for next row */ - iRetcode = next_row (pData); - - iY++; /* and next line */ - } - /* drop the temporary row-buffer */ - MNG_FREE (pData, pData->pRGBArow, pBufdelta->iRowsize) - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - else - MNG_ERROR (pData, MNG_INVALIDDELTA) - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_EXECUTE_DELTA_IMAGE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode save_state (mng_datap pData) -{ - mng_savedatap pSave; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SAVE_STATE, MNG_LC_START) -#endif - - if (pData->pSavedata) /* sanity check */ - MNG_ERROR (pData, MNG_INTERNALERROR) - /* get a buffer for saving */ - MNG_ALLOC (pData, pData->pSavedata, sizeof (mng_savedata)) - - pSave = pData->pSavedata; /* address it more directly */ - /* and copy global data from the main struct */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - pSave->bHasglobalPLTE = pData->bHasglobalPLTE; - pSave->bHasglobalTRNS = pData->bHasglobalTRNS; - pSave->bHasglobalGAMA = pData->bHasglobalGAMA; - pSave->bHasglobalCHRM = pData->bHasglobalCHRM; - pSave->bHasglobalSRGB = pData->bHasglobalSRGB; - pSave->bHasglobalICCP = pData->bHasglobalICCP; - pSave->bHasglobalBKGD = pData->bHasglobalBKGD; -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - - pSave->iBACKred = pData->iBACKred; - pSave->iBACKgreen = pData->iBACKgreen; - pSave->iBACKblue = pData->iBACKblue; - pSave->iBACKmandatory = pData->iBACKmandatory; - pSave->iBACKimageid = pData->iBACKimageid; - pSave->iBACKtile = pData->iBACKtile; - - pSave->iFRAMmode = pData->iFRAMmode; - pSave->iFRAMdelay = pData->iFRAMdelay; - pSave->iFRAMtimeout = pData->iFRAMtimeout; - pSave->bFRAMclipping = pData->bFRAMclipping; - pSave->iFRAMclipl = pData->iFRAMclipl; - pSave->iFRAMclipr = pData->iFRAMclipr; - pSave->iFRAMclipt = pData->iFRAMclipt; - pSave->iFRAMclipb = pData->iFRAMclipb; - - pSave->iGlobalPLTEcount = pData->iGlobalPLTEcount; - - MNG_COPY (pSave->aGlobalPLTEentries, pData->aGlobalPLTEentries, sizeof (mng_rgbpaltab)) - - pSave->iGlobalTRNSrawlen = pData->iGlobalTRNSrawlen; - MNG_COPY (pSave->aGlobalTRNSrawdata, pData->aGlobalTRNSrawdata, 256) - - pSave->iGlobalGamma = pData->iGlobalGamma; - - pSave->iGlobalWhitepointx = pData->iGlobalWhitepointx; - pSave->iGlobalWhitepointy = pData->iGlobalWhitepointy; - pSave->iGlobalPrimaryredx = pData->iGlobalPrimaryredx; - pSave->iGlobalPrimaryredy = pData->iGlobalPrimaryredy; - pSave->iGlobalPrimarygreenx = pData->iGlobalPrimarygreenx; - pSave->iGlobalPrimarygreeny = pData->iGlobalPrimarygreeny; - pSave->iGlobalPrimarybluex = pData->iGlobalPrimarybluex; - pSave->iGlobalPrimarybluey = pData->iGlobalPrimarybluey; - - pSave->iGlobalRendintent = pData->iGlobalRendintent; - - pSave->iGlobalProfilesize = pData->iGlobalProfilesize; - - if (pSave->iGlobalProfilesize) /* has a profile ? */ - { /* then copy that ! */ - MNG_ALLOC (pData, pSave->pGlobalProfile, pSave->iGlobalProfilesize) - MNG_COPY (pSave->pGlobalProfile, pData->pGlobalProfile, pSave->iGlobalProfilesize) - } - - pSave->iGlobalBKGDred = pData->iGlobalBKGDred; - pSave->iGlobalBKGDgreen = pData->iGlobalBKGDgreen; - pSave->iGlobalBKGDblue = pData->iGlobalBKGDblue; - - /* freeze current image objects */ - pImage = (mng_imagep)pData->pFirstimgobj; - - while (pImage) - { /* freeze the object AND it's buffer */ - pImage->bFrozen = MNG_TRUE; - pImage->pImgbuf->bFrozen = MNG_TRUE; - /* neeeext */ - pImage = (mng_imagep)pImage->sHeader.pNext; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_SAVE_STATE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mng_reset_objzero (mng_datap pData) -{ - mng_imagep pImage = (mng_imagep)pData->pObjzero; - mng_retcode iRetcode = reset_object_details (pData, pImage, 0, 0, 0, - 0, 0, 0, 0, MNG_TRUE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pImage->bVisible = MNG_TRUE; - pImage->bViewable = MNG_TRUE; - pImage->iPosx = 0; - pImage->iPosy = 0; - pImage->bClipped = MNG_FALSE; - pImage->iClipl = 0; - pImage->iClipr = 0; - pImage->iClipt = 0; - pImage->iClipb = 0; - pImage->iMAGN_MethodX = 0; - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_state (mng_datap pData) -{ - mng_savedatap pSave; - mng_imagep pImage; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_STATE, MNG_LC_START) -#endif - /* restore object 0 status !!! */ - iRetcode = mng_reset_objzero (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* fresh cycle; fake no frames done yet */ - pData->bFramedone = MNG_FALSE; - - if (pData->pSavedata) /* do we have a saved state ? */ - { - pSave = pData->pSavedata; /* address it more directly */ - /* and copy it back to the main struct */ -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - pData->bHasglobalPLTE = pSave->bHasglobalPLTE; - pData->bHasglobalTRNS = pSave->bHasglobalTRNS; - pData->bHasglobalGAMA = pSave->bHasglobalGAMA; - pData->bHasglobalCHRM = pSave->bHasglobalCHRM; - pData->bHasglobalSRGB = pSave->bHasglobalSRGB; - pData->bHasglobalICCP = pSave->bHasglobalICCP; - pData->bHasglobalBKGD = pSave->bHasglobalBKGD; -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - - pData->iBACKred = pSave->iBACKred; - pData->iBACKgreen = pSave->iBACKgreen; - pData->iBACKblue = pSave->iBACKblue; - pData->iBACKmandatory = pSave->iBACKmandatory; - pData->iBACKimageid = pSave->iBACKimageid; - pData->iBACKtile = pSave->iBACKtile; - - pData->iFRAMmode = pSave->iFRAMmode; - pData->iFRAMdelay = pSave->iFRAMdelay; - pData->iFRAMtimeout = pSave->iFRAMtimeout; - pData->bFRAMclipping = pSave->bFRAMclipping; - pData->iFRAMclipl = pSave->iFRAMclipl; - pData->iFRAMclipr = pSave->iFRAMclipr; - pData->iFRAMclipt = pSave->iFRAMclipt; - pData->iFRAMclipb = pSave->iFRAMclipb; - /* also the next subframe parms */ - pData->iFramemode = pSave->iFRAMmode; - pData->iFramedelay = pSave->iFRAMdelay; - pData->iFrametimeout = pSave->iFRAMtimeout; - pData->bFrameclipping = pSave->bFRAMclipping; - pData->iFrameclipl = pSave->iFRAMclipl; - pData->iFrameclipr = pSave->iFRAMclipr; - pData->iFrameclipt = pSave->iFRAMclipt; - pData->iFrameclipb = pSave->iFRAMclipb; - - pData->iNextdelay = pSave->iFRAMdelay; - - pData->iGlobalPLTEcount = pSave->iGlobalPLTEcount; - MNG_COPY (pData->aGlobalPLTEentries, pSave->aGlobalPLTEentries, sizeof (mng_rgbpaltab)) - - pData->iGlobalTRNSrawlen = pSave->iGlobalTRNSrawlen; - MNG_COPY (pData->aGlobalTRNSrawdata, pSave->aGlobalTRNSrawdata, 256) - - pData->iGlobalGamma = pSave->iGlobalGamma; - - pData->iGlobalWhitepointx = pSave->iGlobalWhitepointx; - pData->iGlobalWhitepointy = pSave->iGlobalWhitepointy; - pData->iGlobalPrimaryredx = pSave->iGlobalPrimaryredx; - pData->iGlobalPrimaryredy = pSave->iGlobalPrimaryredy; - pData->iGlobalPrimarygreenx = pSave->iGlobalPrimarygreenx; - pData->iGlobalPrimarygreeny = pSave->iGlobalPrimarygreeny; - pData->iGlobalPrimarybluex = pSave->iGlobalPrimarybluex; - pData->iGlobalPrimarybluey = pSave->iGlobalPrimarybluey; - - pData->iGlobalRendintent = pSave->iGlobalRendintent; - - pData->iGlobalProfilesize = pSave->iGlobalProfilesize; - - if (pData->iGlobalProfilesize) /* has a profile ? */ - { /* then copy that ! */ - MNG_ALLOC (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) - MNG_COPY (pData->pGlobalProfile, pSave->pGlobalProfile, pData->iGlobalProfilesize) - } - - pData->iGlobalBKGDred = pSave->iGlobalBKGDred; - pData->iGlobalBKGDgreen = pSave->iGlobalBKGDgreen; - pData->iGlobalBKGDblue = pSave->iGlobalBKGDblue; - } - else /* no saved-data; so reset the lot */ - { -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - pData->bHasglobalPLTE = MNG_FALSE; - pData->bHasglobalTRNS = MNG_FALSE; - pData->bHasglobalGAMA = MNG_FALSE; - pData->bHasglobalCHRM = MNG_FALSE; - pData->bHasglobalSRGB = MNG_FALSE; - pData->bHasglobalICCP = MNG_FALSE; - pData->bHasglobalBKGD = MNG_FALSE; -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - - if (!pData->bEMNGMAhack) /* TODO: remove line in 1.0.0 !!! */ - { /* TODO: remove line in 1.0.0 !!! */ - pData->iBACKred = 0; - pData->iBACKgreen = 0; - pData->iBACKblue = 0; - pData->iBACKmandatory = 0; - pData->iBACKimageid = 0; - pData->iBACKtile = 0; - } /* TODO: remove line in 1.0.0 !!! */ - - pData->iFRAMmode = 1; - pData->iFRAMdelay = 1; - pData->iFRAMtimeout = 0x7fffffffl; - pData->bFRAMclipping = MNG_FALSE; - pData->iFRAMclipl = 0; - pData->iFRAMclipr = 0; - pData->iFRAMclipt = 0; - pData->iFRAMclipb = 0; - /* also the next subframe parms */ - pData->iFramemode = 1; - pData->iFramedelay = 1; - pData->iFrametimeout = 0x7fffffffl; - pData->bFrameclipping = MNG_FALSE; - pData->iFrameclipl = 0; - pData->iFrameclipr = 0; - pData->iFrameclipt = 0; - pData->iFrameclipb = 0; - - pData->iNextdelay = 1; - - pData->iGlobalPLTEcount = 0; - - pData->iGlobalTRNSrawlen = 0; - - pData->iGlobalGamma = 0; - - pData->iGlobalWhitepointx = 0; - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; - - pData->iGlobalRendintent = 0; - - if (pData->iGlobalProfilesize) /* free a previous profile ? */ - MNG_FREE (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) - - pData->iGlobalProfilesize = 0; - - pData->iGlobalBKGDred = 0; - pData->iGlobalBKGDgreen = 0; - pData->iGlobalBKGDblue = 0; - } - - if (!pData->bEMNGMAhack) /* TODO: remove line in 1.0.0 !!! */ - { /* TODO: remove line in 1.0.0 !!! */ - /* drop un-frozen image objects */ - pImage = (mng_imagep)pData->pFirstimgobj; - - while (pImage) - { /* is it un-frozen ? */ - if (!pImage->bFrozen) - { - mng_imagep pPrev = (mng_imagep)pImage->sHeader.pPrev; - mng_imagep pNext = (mng_imagep)pImage->sHeader.pNext; - - if (pPrev) /* unlink it */ - pPrev->sHeader.pNext = pNext; - else - pData->pFirstimgobj = pNext; - - if (pNext) - pNext->sHeader.pPrev = pPrev; - else - pData->pLastimgobj = pPrev; - - if (pImage->pImgbuf->bFrozen) /* buffer frozen ? */ - { - if (pImage->pImgbuf->iRefcount <= 2) - MNG_ERROR (pData, MNG_INTERNALERROR) - /* decrease ref counter */ - pImage->pImgbuf->iRefcount--; - /* just cleanup the object then */ - MNG_FREEX (pData, pImage, sizeof (mng_image)) - } - else - { /* free the image buffer */ - iRetcode = free_imagedataobject (pData, pImage->pImgbuf); - /* and cleanup the object */ - MNG_FREEX (pData, pImage, sizeof (mng_image)) - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - pImage = pNext; /* this is the next */ - } - else /* neeeext */ - pImage = (mng_imagep)pImage->sHeader.pNext; - - } - } /* TODO: remove line in 1.0.0 !!! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_STATE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * General display processing routine * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode process_display (mng_datap pData) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY, MNG_LC_START) -#endif - - if (!pData->iBreakpoint) /* not broken previously ? */ - { - if ((pData->iRequestframe) || (pData->iRequestlayer) || (pData->iRequesttime)) - { - pData->bSearching = MNG_TRUE; /* indicate we're searching */ - - iRetcode = clear_canvas (pData); /* make the canvas virgin black ?!? */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* let's start from the top, shall we */ - pData->pCurraniobj = pData->pFirstaniobj; - } - } - - do /* process the objects */ - { - if (pData->bSearching) /* are we looking sor something ? */ - { - if ((pData->iRequestframe) && - (pData->iRequestframe < ((mng_object_headerp)pData->pCurraniobj)->iFramenr)) - { - pData->iRequestframe = 0; /* found the frame ! */ - pData->bSearching = MNG_FALSE; - } - else - if ((pData->iRequestlayer) && - (pData->iRequestlayer < ((mng_object_headerp)pData->pCurraniobj)->iLayernr)) - { - pData->iRequestlayer = 0; /* found the layer ! */ - pData->bSearching = MNG_FALSE; - } - else - if ((pData->iRequesttime) && - (pData->iRequesttime < ((mng_object_headerp)pData->pCurraniobj)->iPlaytime)) - { - pData->iRequesttime = 0; /* found the playtime ! */ - pData->bSearching = MNG_FALSE; - } - } - /* do we need to finish something first ? */ - if ((pData->iBreakpoint) && (pData->iBreakpoint < 99)) - { - switch (pData->iBreakpoint) /* return to broken display routine */ - { - case 1 : { iRetcode = process_display_fram2 (pData); break; } - case 3 : ; /* same as 4 !!! */ - case 4 : { iRetcode = process_display_show (pData); break; } - case 5 : { iRetcode = process_display_clon2 (pData); break; } - case 9 : { iRetcode = process_display_magn2 (pData); break; } - default : MNG_ERROR (pData, MNG_INTERNALERROR) - } - } - else - { - if (pData->pCurraniobj) - iRetcode = ((mng_object_headerp)pData->pCurraniobj)->fProcess (pData, pData->pCurraniobj); - } - - if (!pData->bTimerset) /* reset breakpoint flag ? */ - pData->iBreakpoint = 0; - /* can we advance to next object ? */ - if ((!iRetcode) && (pData->pCurraniobj) && - (!pData->bTimerset) && (!pData->bSectionwait)) - { - pData->pCurraniobj = ((mng_object_headerp)pData->pCurraniobj)->pNext; - /* MEND processing to be done ? */ - if ((pData->eImagetype == mng_it_mng) && (!pData->pCurraniobj)) - iRetcode = process_display_mend (pData); - - if (!pData->pCurraniobj) /* refresh after last image ? */ - pData->bNeedrefresh = MNG_TRUE; - } - } /* until error or a break or no more objects */ - while ((!iRetcode) && (pData->pCurraniobj) && - (!pData->bTimerset) && (!pData->bSectionwait) && (!pData->bFreezing)); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* refresh needed ? */ - if ((!pData->bTimerset) && (pData->bNeedrefresh)) - { - iRetcode = display_progressive_refresh (pData, 1); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* timer break ? */ - if ((pData->bTimerset) && (!pData->iBreakpoint)) - pData->iBreakpoint = 99; - else - if (!pData->bTimerset) - pData->iBreakpoint = 0; /* reset if no timer break */ - - if ((!pData->bTimerset) && (!pData->pCurraniobj)) - pData->bRunning = MNG_FALSE; /* all done now ! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Chunk display processing routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode process_display_ihdr (mng_datap pData) -{ /* address the current "object" if any */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IHDR, MNG_LC_START) -#endif - - if (!pData->bHasDHDR) - { - pData->fInitrowproc = MNG_NULL; /* do nothing by default */ - pData->fDisplayrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->fDifferrow = MNG_NULL; - pData->pStoreobj = MNG_NULL; - } - - if (!pData->iBreakpoint) /* not previously broken ? */ - { - mng_retcode iRetcode = MNG_NOERROR; - - if (pData->bHasDHDR) /* is a delta-image ? */ - { - if (pData->iDeltatype == MNG_DELTATYPE_REPLACE) - iRetcode = reset_object_details (pData, (mng_imagep)pData->pDeltaImage, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iBitdepth; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iBitdepth; - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iBitdepth; - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iBitdepth; - - /* process immediatly if bitdepth & colortype are equal */ - pData->bDeltaimmediate = - (mng_bool)((pData->iBitdepth == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iBitdepth ) && - (pData->iColortype == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iColortype) ); - } - else - { - if (pImage) /* update object buffer ? */ - iRetcode = reset_object_details (pData, pImage, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - else - iRetcode = reset_object_details (pData, (mng_imagep)pData->pObjzero, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (!pData->bHasDHDR) - { - if (pImage) /* real object ? */ - pData->pStoreobj = pImage; /* tell the row routines */ - else /* otherwise use object 0 */ - pData->pStoreobj = pData->pObjzero; - /* display "on-the-fly" ? */ - if ( (((mng_imagep)pData->pStoreobj)->iMAGN_MethodX == 0) && - (((mng_imagep)pData->pStoreobj)->iMAGN_MethodY == 0) && - ( (pData->eImagetype == mng_it_png ) || - (((mng_imagep)pData->pStoreobj)->bVisible) ) ) - { - next_layer (pData); /* that's a new layer then ! */ - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 2; - else - { - pData->iBreakpoint = 0; - /* anything to display ? */ - if ((pData->iDestr > pData->iDestl) && (pData->iDestb > pData->iDestt)) - set_display_routine (pData); /* then determine display routine */ - } - } - } - - if (!pData->bTimerset) /* no timer break ? */ - { - switch (pData->iColortype) /* determine row initialization routine */ - { - case 0 : { /* gray */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g1_ni; - else - pData->fInitrowproc = (mng_fptr)init_g1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g2_ni; - else - pData->fInitrowproc = (mng_fptr)init_g2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g4_ni; - else - pData->fInitrowproc = (mng_fptr)init_g4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g8_ni; - else - pData->fInitrowproc = (mng_fptr)init_g8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g16_ni; - else - pData->fInitrowproc = (mng_fptr)init_g16_i; - - break; - } - } - - break; - } - case 2 : { /* rgb */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb16_i; - - break; - } - } - - break; - } - case 3 : { /* indexed */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx1_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx2_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx4_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx8_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx8_i; - - break; - } - } - - break; - } - case 4 : { /* gray+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga8_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga16_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga16_i; - - break; - } - } - - break; - } - case 6 : { /* rgb+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba16_i; - - break; - } - } - - break; - } - } - - pData->iFilterofs = 0; /* determine filter characteristics */ - pData->iLevel0 = 0; /* default levels */ - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - /* leveling & differing ? */ -/* if (pData->iFilter & 0x40) - { - switch (pData->iColortype) - { - case 0 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 1; - else - pData->iFilterofs = 2; - - break; - } - case 2 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 3; - else - pData->iFilterofs = 6; - - break; - } - case 3 : { - pData->iFilterofs = 1; - break; - } - case 4 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 2; - else - pData->iFilterofs = 4; - - break; - } - case 6 : { - if (pData->iBitdepth <= 8) - pData->iPixelofs = 5; - else - pData->iFilterofs = 8; - - break; - } - } - } */ - /* no adaptive filtering ? */ -/* if (pData->iFilter & 0x01) - pData->iPixelofs = pData->iFilterofs; - else */ - pData->iPixelofs = pData->iFilterofs + 1; - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_idat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IDAT, MNG_LC_START) -#endif - - if (pData->bRestorebkgd) /* need to restore the background ? */ - { - pData->bRestorebkgd = MNG_FALSE; - iRetcode = load_bkgdlayer (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if ((pData->bDisplaying) && (pData->bRunning)) - pData->iLayerseq++; /* and it counts as a layer then ! */ - } - - if (pData->fInitrowproc) /* need to initialize row processing? */ - { - iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData); - pData->fInitrowproc = MNG_NULL; /* only call this once !!! */ - } - - if ((!iRetcode) && (!pData->bInflating)) - /* initialize inflate */ - iRetcode = mngzlib_inflateinit (pData); - - if (!iRetcode) /* all ok? then inflate, my man */ - iRetcode = mngzlib_inflaterows (pData, iRawlen, pRawdata); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_iend (mng_datap pData) -{ - mng_retcode iRetcode, iRetcode2; - mng_bool bDodisplay = MNG_FALSE; - mng_bool bMagnify = MNG_FALSE; - mng_bool bCleanup = (mng_bool)(pData->iBreakpoint != 0); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IEND, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_JNG /* progressive+alpha JNG can be displayed now */ - if ( (pData->bHasJHDR ) && - ( (pData->bJPEGprogressive) || (pData->bJPEGprogressive2)) && - ( (pData->eImagetype == mng_it_jng ) || - (((mng_imagep)pData->pStoreobj)->bVisible) ) && - ( (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) ) - bDodisplay = MNG_TRUE; -#endif - - if ( (pData->pStoreobj) && /* on-the-fly magnification ? */ - ( (((mng_imagep)pData->pStoreobj)->iMAGN_MethodX) || - (((mng_imagep)pData->pStoreobj)->iMAGN_MethodY) ) ) - bMagnify = MNG_TRUE; - - if ((pData->bHasBASI) || /* was it a BASI stream */ - (bDodisplay) || /* or should we display the JNG */ - (bMagnify) || /* or should we magnify it */ - /* or did we get broken here last time ? */ - ((pData->iBreakpoint) && (pData->iBreakpoint != 8))) - { - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) /* or was it object 0 ? */ - pImage = (mng_imagep)pData->pObjzero; - /* display it now then ? */ - if ((pImage->bVisible) && (pImage->bViewable)) - { /* ok, so do it */ - iRetcode = display_image (pData, pImage, bDodisplay); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 6; - } - } - else - if ((pData->bHasDHDR) || /* was it a DHDR stream */ - (pData->iBreakpoint == 8)) /* or did we get broken here last time ? */ - { - mng_imagep pImage = (mng_imagep)pData->pDeltaImage; - - if (!pData->iBreakpoint) - { /* perform the delta operations needed */ - iRetcode = execute_delta_image (pData, pImage, (mng_imagep)pData->pObjzero); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* display it now then ? */ - if ((pImage->bVisible) && (pImage->bViewable)) - { /* ok, so do it */ - iRetcode = display_image (pData, pImage, MNG_FALSE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 8; - } - } - - if (!pData->bTimerset) /* can we continue ? */ - { - pData->iBreakpoint = 0; /* clear this flag now ! */ - /* cleanup object 0 */ - reset_object_details (pData, (mng_imagep)pData->pObjzero, - 0, 0, 0, 0, 0, 0, 0, MNG_TRUE); - - if (pData->bInflating) /* if we've been inflating */ - { /* cleanup row-processing, */ - iRetcode = cleanup_rowproc (pData); - /* also cleanup inflate! */ - iRetcode2 = mngzlib_inflatefree (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - if (iRetcode2) - return iRetcode2; - } - -#ifdef MNG_INCLUDE_JNG - if (pData->bJPEGdecompress) /* if we've been decompressing JDAT */ - { /* cleanup row-processing, */ - iRetcode = cleanup_rowproc (pData); - /* also cleanup decompress! */ - iRetcode2 = mngjpeg_decompressfree (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - if (iRetcode2) - return iRetcode2; - } - - if (pData->bJPEGdecompress2) /* if we've been decompressing JDAA */ - { /* cleanup row-processing, */ - iRetcode = cleanup_rowproc (pData); - /* also cleanup decompress! */ - iRetcode2 = mngjpeg_decompressfree2 (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - if (iRetcode2) - return iRetcode2; - } -#endif - - if (bCleanup) /* if we got broken last time we need to cleanup */ - { - pData->bHasIHDR = MNG_FALSE; /* IEND signals the end for most ... */ - pData->bHasBASI = MNG_FALSE; - pData->bHasDHDR = MNG_FALSE; -#ifdef MNG_INCLUDE_JNG - pData->bHasJHDR = MNG_FALSE; - pData->bHasJSEP = MNG_FALSE; - pData->bHasJDAA = MNG_FALSE; - pData->bHasJDAT = MNG_FALSE; -#endif - pData->bHasPLTE = MNG_FALSE; - pData->bHasTRNS = MNG_FALSE; - pData->bHasGAMA = MNG_FALSE; - pData->bHasCHRM = MNG_FALSE; - pData->bHasSRGB = MNG_FALSE; - pData->bHasICCP = MNG_FALSE; - pData->bHasBKGD = MNG_FALSE; - pData->bHasIDAT = MNG_FALSE; - } - /* if the image was displayed on the fly, */ - /* we'll have to make the app refresh */ - if ((pData->eImagetype != mng_it_mng) && (pData->fDisplayrow)) - pData->bNeedrefresh = MNG_TRUE; - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_mend (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MEND, MNG_LC_START) -#endif - /* TERM processed ? */ - if ((pData->bDisplaying) && (pData->bRunning) && - (pData->bHasTERM) && (pData->pTermaniobj)) - { - mng_retcode iRetcode; - mng_ani_termp pTERM; - /* get the right animation object ! */ - pTERM = (mng_ani_termp)pData->pTermaniobj; - - pData->iIterations++; /* increase iteration count */ - - switch (pTERM->iTermaction) /* determine what to do! */ - { - case 0 : { /* show last frame indefinitly */ - break; /* piece of cake, that is... */ - } - - case 1 : { /* cease displaying anything */ - pData->bFrameclipping = MNG_FALSE; - load_bkgdlayer (pData); - break; - } - - case 2 : { /* show first image after TERM */ - - /* TODO: something */ - - break; - } - - case 3 : { /* repeat */ - if ((pTERM->iItermax) && (pTERM->iItermax < 0x7FFFFFFF)) - pTERM->iItermax--; - - if (pTERM->iItermax) /* go back to TERM ? */ - { /* restore to initial or SAVE state */ - iRetcode = restore_state (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* notify the app ? */ - if (pData->fProcessmend) - { - mng_bool bOke = pData->fProcessmend ((mng_handle)pData, - pData->iIterations, - pTERM->iItermax); - if (!bOke) /* stop here and now ? */ - break; - } - /* restart from TERM chunk */ - pData->pCurraniobj = pTERM; - - if (pTERM->iDelay) /* set the delay (?) */ - { - mng_uint32 iWaitfor = 1000; - /* what are we aiming for */ - if (pData->iTicks) - { /* honor speed modifier */ - switch (pData->iSpeed) - { - case mng_st_fast : - { - iWaitfor = (mng_uint32)(( 500 * pTERM->iDelay) / pData->iTicks); - break; - } - case mng_st_slow : - { - iWaitfor = (mng_uint32)((3000 * pTERM->iDelay) / pData->iTicks); - break; - } - case mng_st_slowest : - { - iWaitfor = (mng_uint32)((8000 * pTERM->iDelay) / pData->iTicks); - break; - } - default : - { - iWaitfor = (mng_uint32)((1000 * pTERM->iDelay) / pData->iTicks); - } - } - } - - iRetcode = display_progressive_refresh (pData, iWaitfor); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - else - { - switch (pTERM->iIteraction) - { - case 0 : { /* show last frame indefinitly */ - break; /* piece of cake, that is... */ - } - - case 1 : { /* cease displaying anything */ - pData->bFrameclipping = MNG_FALSE; - load_bkgdlayer (pData); - break; - } - - case 2 : { /* show first image after TERM */ - - /* TODO: something */ - - break; - } - - } - } - - break; - } - - } - } - - if (!pData->pCurraniobj) /* always let the app refresh at the end ! */ - pData->bNeedrefresh = MNG_TRUE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MEND, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_defi (mng_datap pData) -{ - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DEFI, MNG_LC_START) -#endif - - if (!pData->iDEFIobjectid) /* object id=0 ? */ - { - pImage = (mng_imagep)pData->pObjzero; - - if (pData->bDEFIhasdonotshow) - pImage->bVisible = (mng_bool)(pData->iDEFIdonotshow == 0); - - if (pData->bDEFIhasloca) - { - pImage->iPosx = pData->iDEFIlocax; - pImage->iPosy = pData->iDEFIlocay; - } - - if (pData->bDEFIhasclip) - { - pImage->bClipped = pData->bDEFIhasclip; - pImage->iClipl = pData->iDEFIclipl; - pImage->iClipr = pData->iDEFIclipr; - pImage->iClipt = pData->iDEFIclipt; - pImage->iClipb = pData->iDEFIclipb; - } - - pData->pCurrentobj = 0; /* not a real object ! */ - } - else - { /* already exists ? */ - pImage = (mng_imagep)find_imageobject (pData, pData->iDEFIobjectid); - - if (!pImage) /* if not; create new */ - { - mng_retcode iRetcode = create_imageobject (pData, pData->iDEFIobjectid, - (mng_bool)(pData->iDEFIconcrete == 1), - (mng_bool)(pData->iDEFIdonotshow == 0), - MNG_FALSE, 0, 0, 0, 0, 0, 0, 0, - pData->iDEFIlocax, pData->iDEFIlocay, - pData->bDEFIhasclip, - pData->iDEFIclipl, pData->iDEFIclipr, - pData->iDEFIclipt, pData->iDEFIclipb, - &pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* exists; then set new info */ - if (pData->bDEFIhasdonotshow) - pImage->bVisible = (mng_bool)(pData->iDEFIdonotshow == 0); - - pImage->bViewable = MNG_FALSE; - - if (pData->bDEFIhasloca) - { - pImage->iPosx = pData->iDEFIlocax; - pImage->iPosy = pData->iDEFIlocay; - } - - if (pData->bDEFIhasclip) - { - pImage->bClipped = pData->bDEFIhasclip; - pImage->iClipl = pData->iDEFIclipl; - pImage->iClipr = pData->iDEFIclipr; - pImage->iClipt = pData->iDEFIclipt; - pImage->iClipb = pData->iDEFIclipb; - } - - if (pData->bDEFIhasconcrete) - pImage->pImgbuf->bConcrete = (mng_bool)(pData->iDEFIconcrete == 1); - } - - pData->pCurrentobj = pImage; /* others may want to know this */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable) -{ /* address the current "object" if any */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_uint8p pWork; - mng_uint32 iX; - mng_imagedatap pBuf; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_BASI, MNG_LC_START) -#endif - - if (!pImage) /* or is it an "on-the-fly" image ? */ - pImage = (mng_imagep)pData->pObjzero; - /* address the object-buffer */ - pBuf = pImage->pImgbuf; - - pData->fDisplayrow = MNG_NULL; /* do nothing by default */ - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - /* set parms now that they're known */ - iRetcode = reset_object_details (pData, pImage, pData->iDatawidth, - pData->iDataheight, pData->iBitdepth, - pData->iColortype, pData->iCompression, - pData->iFilter, pData->iInterlace, MNG_FALSE); - if (iRetcode) /* on error bail out */ - return iRetcode; - /* save the viewable flag */ - pImage->bViewable = (mng_bool)(iViewable == 1); - pBuf->bViewable = pImage->bViewable; - pData->pStoreobj = pImage; /* let row-routines know which object */ - - pWork = pBuf->pImgdata; /* fill the object-buffer with the specified - "color" sample */ - switch (pData->iColortype) /* depending on color_type & bit_depth */ - { - case 0 : { /* gray */ - if (pData->iBitdepth == 16) - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - mng_put_uint16 (pWork, iRed); - pWork += 2; - } - } - else - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - *pWork = (mng_uint8)iRed; - pWork++; - } - } - /* force tRNS ? */ - if ((bHasalpha) && (!iAlpha)) - { - pBuf->bHasTRNS = MNG_TRUE; - pBuf->iTRNSgray = iRed; - } - - break; - } - - case 2 : { /* rgb */ - if (pData->iBitdepth == 16) - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - mng_put_uint16 (pWork, iRed ); - mng_put_uint16 (pWork+2, iGreen); - mng_put_uint16 (pWork+4, iBlue ); - pWork += 6; - } - } - else - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - *pWork = (mng_uint8)iRed; - *(pWork+1) = (mng_uint8)iGreen; - *(pWork+2) = (mng_uint8)iBlue; - pWork += 3; - } - } - /* force tRNS ? */ - if ((bHasalpha) && (!iAlpha)) - { - pBuf->bHasTRNS = MNG_TRUE; - pBuf->iTRNSred = iRed; - pBuf->iTRNSgreen = iGreen; - pBuf->iTRNSblue = iBlue; - } - - break; - } - - case 3 : { /* indexed */ - pBuf->bHasPLTE = MNG_TRUE; - - switch (pData->iBitdepth) - { - case 1 : { pBuf->iPLTEcount = 2; break; } - case 2 : { pBuf->iPLTEcount = 4; break; } - case 4 : { pBuf->iPLTEcount = 16; break; } - case 8 : { pBuf->iPLTEcount = 256; break; } - default : { pBuf->iPLTEcount = 1; break; } - } - - pBuf->aPLTEentries [0].iRed = (mng_uint8)iRed; - pBuf->aPLTEentries [0].iGreen = (mng_uint8)iGreen; - pBuf->aPLTEentries [0].iBlue = (mng_uint8)iBlue; - - for (iX = 1; iX < pBuf->iPLTEcount; iX++) - { - pBuf->aPLTEentries [iX].iRed = 0; - pBuf->aPLTEentries [iX].iGreen = 0; - pBuf->aPLTEentries [iX].iBlue = 0; - } - /* force tRNS ? */ - if ((bHasalpha) && (iAlpha < 255)) - { - pBuf->bHasTRNS = MNG_TRUE; - pBuf->iTRNScount = 1; - pBuf->aTRNSentries [0] = (mng_uint8)iAlpha; - } - - break; - } - - case 4 : { /* gray+alpha */ - if (pData->iBitdepth == 16) - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - mng_put_uint16 (pWork, iRed); - mng_put_uint16 (pWork+2, iAlpha); - pWork += 4; - } - } - else - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - *pWork = (mng_uint8)iRed; - *(pWork+1) = (mng_uint8)iAlpha; - pWork += 2; - } - } - - break; - } - - case 6 : { /* rgb+alpha */ - if (pData->iBitdepth == 16) - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - mng_put_uint16 (pWork, iRed); - mng_put_uint16 (pWork+2, iGreen); - mng_put_uint16 (pWork+4, iBlue); - mng_put_uint16 (pWork+6, iAlpha); - pWork += 8; - } - } - else - { - for (iX = 0; iX < pData->iDatawidth * pData->iDataheight; iX++) - { - *pWork = (mng_uint8)iRed; - *(pWork+1) = (mng_uint8)iGreen; - *(pWork+2) = (mng_uint8)iBlue; - *(pWork+3) = (mng_uint8)iAlpha; - pWork += 4; - } - } - - break; - } - - } - - switch (pData->iColortype) /* determine row initialization routine */ - { /* just to accomodate IDAT if it arrives */ - case 0 : { /* gray */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g1_ni; - else - pData->fInitrowproc = (mng_fptr)init_g1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g2_ni; - else - pData->fInitrowproc = (mng_fptr)init_g2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g4_ni; - else - pData->fInitrowproc = (mng_fptr)init_g4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g8_ni; - else - pData->fInitrowproc = (mng_fptr)init_g8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g16_ni; - else - pData->fInitrowproc = (mng_fptr)init_g16_i; - - break; - } - } - - break; - } - case 2 : { /* rgb */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb16_i; - - break; - } - } - - break; - } - case 3 : { /* indexed */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx1_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx2_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx4_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx8_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx8_i; - - break; - } - } - - break; - } - case 4 : { /* gray+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga8_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga16_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga16_i; - - break; - } - } - - break; - } - case 6 : { /* rgb+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba16_i; - - break; - } - } - - break; - } - } - - pData->iFilterofs = 0; /* determine filter characteristics */ - pData->iLevel0 = 0; /* default levels */ - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - /* leveling & differing ? */ -/* if (pData->iFilter & 0x40) - { - switch (pData->iColortype) - { - case 0 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 1; - else - pData->iFilterofs = 2; - - break; - } - case 2 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 3; - else - pData->iFilterofs = 6; - - break; - } - case 3 : { - pData->iFilterofs = 1; - break; - } - case 4 : { - if (pData->iBitdepth <= 8) - pData->iFilterofs = 2; - else - pData->iFilterofs = 4; - - break; - } - case 6 : { - if (pData->iBitdepth <= 8) - pData->iPixelofs = 5; - else - pData->iFilterofs = 8; - - break; - } - } - } */ - /* no adaptive filtering ? */ -/* if (pData->iFilter & 0x01) - pData->iPixelofs = pData->iFilterofs; - else */ - pData->iPixelofs = pData->iFilterofs + 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_clon (mng_datap pData, - mng_uint16 iSourceid, - mng_uint16 iCloneid, - mng_uint8 iClonetype, - mng_bool bHasdonotshow, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy) -{ - mng_imagep pSource, pClone; - mng_bool bVisible, bAbstract; - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_START) -#endif - /* locate the source object first */ - pSource = find_imageobject (pData, iSourceid); - /* check if the clone exists */ - pClone = find_imageobject (pData, iCloneid); - - if (!pSource) /* source must exist ! */ - MNG_ERROR (pData, MNG_OBJECTUNKNOWN); - - if (pClone) /* clone must not exist ! */ - MNG_ERROR (pData, MNG_OBJECTEXISTS); - - if (bHasdonotshow) /* DoNotShow flag filled ? */ - bVisible = (mng_bool)(iDonotshow == 0); - else - bVisible = pSource->bVisible; - - bAbstract = (mng_bool)(iConcrete == 1); - - switch (iClonetype) /* determine action to take */ - { - case 0 : { /* full clone */ - iRetcode = clone_imageobject (pData, iCloneid, MNG_FALSE, - bVisible, bAbstract, bHasloca, - iLocationtype, iLocationx, iLocationy, - pSource, &pClone); - break; - } - - case 1 : { /* partial clone */ - iRetcode = clone_imageobject (pData, iCloneid, MNG_TRUE, - bVisible, bAbstract, bHasloca, - iLocationtype, iLocationx, iLocationy, - pSource, &pClone); - break; - } - - case 2 : { /* renumber object */ - iRetcode = renum_imageobject (pData, pSource, iCloneid, - bVisible, bAbstract, bHasloca, - iLocationtype, iLocationx, iLocationy); - pClone = pSource; - break; - } - - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - /* display on the fly ? */ - if ((pClone->bViewable) && (pClone->bVisible)) - { - pData->pLastclone = pClone; /* remember in case of timer break ! */ - /* display it */ - display_image (pData, pClone, MNG_FALSE); - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 5; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_clon2 (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_START) -#endif - /* only called after timer break ! */ - display_image (pData, (mng_imagep)pData->pLastclone, MNG_FALSE); - pData->iBreakpoint = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_disc (mng_datap pData, - mng_uint32 iCount, - mng_uint16p pIds) -{ - mng_uint32 iX; - mng_imagep pImage; - mng_uint32 iRetcode; -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DISC, MNG_LC_START) -#endif - - if (iCount) /* specific list ? */ - { - mng_uint16p pWork = pIds; - - for (iX = 0; iX < iCount; iX++) /* iterate the list */ - { - pImage = find_imageobject (pData, *pWork++); - - if (pImage) /* found the object ? */ - { /* then drop it */ - iRetcode = free_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } - else /* empty: drop all un-frozen objects */ - { - mng_imagep pNext = (mng_imagep)pData->pFirstimgobj; - - while (pNext) /* any left ? */ - { - pImage = pNext; - pNext = pImage->sHeader.pNext; - - if (!pImage->bFrozen) /* not frozen ? */ - { /* then drop it */ - iRetcode = free_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DISC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_fram (mng_datap pData, - mng_uint8 iFramemode, - mng_uint8 iChangedelay, - mng_uint32 iDelay, - mng_uint8 iChangetimeout, - mng_uint32 iTimeout, - mng_uint8 iChangeclipping, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_START) -#endif - /* advance a frame then */ - iRetcode = next_frame (pData, iFramemode, iChangedelay, iDelay, - iChangetimeout, iTimeout, iChangeclipping, - iCliptype, iClipl, iClipr, iClipt, iClipb); - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode process_display_fram2 (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_START) -#endif - /* again; after the break */ - iRetcode = next_frame (pData, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - pData->iBreakpoint = 0; /* not again! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_FRAM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode process_display_move (mng_datap pData, - mng_uint16 iFromid, - mng_uint16 iToid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey) -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MOVE, MNG_LC_START) -#endif - /* iterate the list */ - for (iX = iFromid; iX <= iToid; iX++) - { - if (!iX) /* object id=0 ? */ - pImage = (mng_imagep)pData->pObjzero; - else - pImage = find_imageobject (pData, iX); - - if (pImage) /* object exists ? */ - { - switch (iMovetype) - { - case 0 : { /* absolute */ - pImage->iPosx = iMovex; - pImage->iPosy = iMovey; - break; - } - case 1 : { /* relative */ - pImage->iPosx = pImage->iPosx + iMovex; - pImage->iPosy = pImage->iPosy + iMovey; - break; - } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_clip (mng_datap pData, - mng_uint16 iFromid, - mng_uint16 iToid, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLIP, MNG_LC_START) -#endif - /* iterate the list */ - for (iX = iFromid; iX <= iToid; iX++) - { - if (!iX) /* object id=0 ? */ - pImage = (mng_imagep)pData->pObjzero; - else - pImage = find_imageobject (pData, iX); - - if (pImage) /* object exists ? */ - { - switch (iCliptype) - { - case 0 : { /* absolute */ - pImage->bClipped = MNG_TRUE; - pImage->iClipl = iClipl; - pImage->iClipr = iClipr; - pImage->iClipt = iClipt; - pImage->iClipb = iClipb; - break; - } - case 1 : { /* relative */ - pImage->bClipped = MNG_TRUE; - pImage->iClipl = pImage->iClipl + iClipl; - pImage->iClipr = pImage->iClipr + iClipr; - pImage->iClipt = pImage->iClipt + iClipt; - pImage->iClipb = pImage->iClipb + iClipb; - break; - } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_show (mng_datap pData) -{ - mng_int16 iX, iS, iFrom, iTo; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SHOW, MNG_LC_START) -#endif - - /* TODO: optimization for the cases where "abs (iTo - iFrom)" is rather high; - especially where ((iFrom==1) && (iTo==65535)); eg. an empty SHOW !!! */ - - if (pData->iBreakpoint == 3) /* previously broken during cycle-mode ? */ - { - pImage = find_imageobject (pData, pData->iSHOWnextid); - - if (pImage) /* still there ? */ - display_image (pData, pImage, MNG_FALSE); - - pData->iBreakpoint = 0; /* let's not go through this again! */ - } - else - { - if (pData->iBreakpoint) /* previously broken at other point ? */ - { /* restore last parms */ - iFrom = (mng_int16)pData->iSHOWfromid; - iTo = (mng_int16)pData->iSHOWtoid; - iX = (mng_int16)pData->iSHOWnextid; - iS = (mng_int16)pData->iSHOWskip; - } - else - { /* regular sequence ? */ - if (pData->iSHOWtoid >= pData->iSHOWfromid) - iS = 1; - else /* reverse sequence ! */ - iS = -1; - - iFrom = (mng_int16)pData->iSHOWfromid; - iTo = (mng_int16)pData->iSHOWtoid; - iX = iFrom; - - pData->iSHOWfromid = (mng_uint16)iFrom; - pData->iSHOWtoid = (mng_uint16)iTo; - pData->iSHOWskip = iS; - } - /* cycle mode ? */ - if ((pData->iSHOWmode == 6) || (pData->iSHOWmode == 7)) - { - mng_uint16 iTrigger = 0; - mng_uint16 iFound = 0; - mng_uint16 iPass = 0; - mng_imagep pFound = 0; - - do - { - iPass++; /* lets prevent endless loops when there - are no potential candidates in the list! */ - - if (iS > 0) /* forward ? */ - { - for (iX = iFrom; iX <= iTo; iX += iS) - { - pImage = find_imageobject (pData, (mng_uint16)iX); - - if (pImage) /* object exists ? */ - { - if (iFound) /* already found a candidate ? */ - pImage->bVisible = MNG_FALSE; - else - if (iTrigger) /* found the trigger ? */ - { - pImage->bVisible = MNG_TRUE; - iFound = iX; - pFound = pImage; - } - else - if (pImage->bVisible) /* ok, this is the trigger */ - { - pImage->bVisible = MNG_FALSE; - iTrigger = iX; - } - } - } - } - else - { - for (iX = iFrom; iX >= iTo; iX += iS) - { - pImage = find_imageobject (pData, (mng_uint16)iX); - - if (pImage) /* object exists ? */ - { - if (iFound) /* already found a candidate ? */ - pImage->bVisible = MNG_FALSE; - else - if (iTrigger) /* found the trigger ? */ - { - pImage->bVisible = MNG_TRUE; - iFound = iX; - pFound = pImage; - } - else - if (pImage->bVisible) /* ok, this is the trigger */ - { - pImage->bVisible = MNG_FALSE; - iTrigger = iX; - } - } - } - } - - if (!iTrigger) /* did not find a trigger ? */ - iTrigger = 1; /* then fake it so the first image - gets nominated */ - } /* cycle back to beginning ? */ - while ((iPass < 2) && (iTrigger) && (!iFound)); - - pData->iBreakpoint = 0; /* just a sanity precaution */ - /* display it ? */ - if ((pData->iSHOWmode == 6) && (pFound)) - { - display_image (pData, pFound, MNG_FALSE); - - if (pData->bTimerset) /* timer set ? */ - { - pData->iBreakpoint = 3; - pData->iSHOWnextid = iFound; /* save it for after the break */ - } - } - } - else - { - do - { - pImage = find_imageobject (pData, iX); - - if (pImage) /* object exists ? */ - { - if (pData->iBreakpoint) /* did we get broken last time ? */ - { /* could only happen in the display routine */ - display_image (pData, pImage, MNG_FALSE); - pData->iBreakpoint = 0; /* only once inside this loop please ! */ - } - else - { - switch (pData->iSHOWmode) /* do what ? */ - { - case 0 : { - pImage->bVisible = MNG_TRUE; - display_image (pData, pImage, MNG_FALSE); - break; - } - case 1 : { - pImage->bVisible = MNG_FALSE; - break; - } - case 2 : { - if (pImage->bVisible) - display_image (pData, pImage, MNG_FALSE); - break; - } - case 3 : { - pImage->bVisible = MNG_TRUE; - break; - } - case 4 : { - pImage->bVisible = (mng_bool)(!pImage->bVisible); - if (pImage->bVisible) - display_image (pData, pImage, MNG_FALSE); - break; - } - case 5 : { - pImage->bVisible = (mng_bool)(!pImage->bVisible); - } - } - } - } - - if (!pData->bTimerset) /* next ? */ - iX += iS; - - } /* continue ? */ - while ((!pData->bTimerset) && (((iS > 0) && (iX <= iTo)) || - ((iS < 0) && (iX >= iTo)) )); - - if (pData->bTimerset) /* timer set ? */ - { - pData->iBreakpoint = 4; - pData->iSHOWnextid = iX; /* save for next time */ - } - else - pData->iBreakpoint = 0; - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_save (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SAVE, MNG_LC_START) -#endif - - iRetcode = save_state (pData); /* save the current state */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_seek (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SEEK, MNG_LC_START) -#endif - - iRetcode = restore_state (pData); /* restore the initial or SAVE state */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode process_display_jhdr (mng_datap pData) -{ /* address the current "object" if any */ - mng_imagep pImage = (mng_imagep)pData->pCurrentobj; - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JHDR, MNG_LC_START) -#endif - - if (!pData->bHasDHDR) - { - pData->fInitrowproc = MNG_NULL; /* do nothing by default */ - pData->fDisplayrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->fDifferrow = MNG_NULL; - pData->fStorerow2 = MNG_NULL; - pData->fStorerow3 = MNG_NULL; - - pData->pStoreobj = MNG_NULL; /* initialize important work-parms */ - - pData->iJPEGrow = 0; - pData->iJPEGalpharow = 0; - pData->iJPEGrgbrow = 0; - pData->iRowmax = 0; /* so init_rowproc does the right thing ! */ - } - - if (!pData->iBreakpoint) /* not previously broken ? */ - { - if (pData->bHasDHDR) /* delta-image ? */ - { - if (pData->iDeltatype == MNG_DELTATYPE_REPLACE) - { - iRetcode = reset_object_details (pData, (mng_imagep)pData->pDeltaImage, - pData->iDatawidth, pData->iDataheight, - pData->iJHDRimgbitdepth, pData->iJHDRcolortype, - pData->iJHDRalphacompression, pData->iJHDRalphafilter, - pData->iJHDRalphainterlace, MNG_TRUE); - - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphabitdepth = pData->iJHDRalphabitdepth; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iJHDRcompression = pData->iJHDRimgcompression; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iJHDRinterlace = pData->iJHDRimginterlace; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iJHDRimgbitdepth; - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - else - if ((pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORADD ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKCOLORREPLACE) ) - ((mng_imagep)pData->pDeltaImage)->pImgbuf->iPixelsampledepth = pData->iJHDRimgbitdepth; - - } - else - { - if (pImage) /* update object buffer ? */ - { - iRetcode = reset_object_details (pData, pImage, - pData->iDatawidth, pData->iDataheight, - pData->iJHDRimgbitdepth, pData->iJHDRcolortype, - pData->iJHDRalphacompression, pData->iJHDRalphafilter, - pData->iJHDRalphainterlace, MNG_TRUE); - - pImage->pImgbuf->iAlphabitdepth = pData->iJHDRalphabitdepth; - pImage->pImgbuf->iJHDRcompression = pData->iJHDRimgcompression; - pImage->pImgbuf->iJHDRinterlace = pData->iJHDRimginterlace; - pImage->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - else /* update object 0 */ - { - iRetcode = reset_object_details (pData, (mng_imagep)pData->pObjzero, - pData->iDatawidth, pData->iDataheight, - pData->iJHDRimgbitdepth, pData->iJHDRcolortype, - pData->iJHDRalphacompression, pData->iJHDRalphafilter, - pData->iJHDRalphainterlace, MNG_TRUE); - - ((mng_imagep)pData->pObjzero)->pImgbuf->iAlphabitdepth = pData->iJHDRalphabitdepth; - ((mng_imagep)pData->pObjzero)->pImgbuf->iJHDRcompression = pData->iJHDRimgcompression; - ((mng_imagep)pData->pObjzero)->pImgbuf->iJHDRinterlace = pData->iJHDRimginterlace; - ((mng_imagep)pData->pObjzero)->pImgbuf->iAlphasampledepth = pData->iJHDRalphabitdepth; - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (!pData->bHasDHDR) - { /* we're always storing a JPEG */ - if (pImage) /* real object ? */ - pData->pStoreobj = pImage; /* tell the row routines */ - else /* otherwise use object 0 */ - pData->pStoreobj = pData->pObjzero; - /* display "on-the-fly" ? */ - if ( (((mng_imagep)pData->pStoreobj)->iMAGN_MethodX == 0) && - (((mng_imagep)pData->pStoreobj)->iMAGN_MethodY == 0) && - ( (pData->eImagetype == mng_it_jng ) || - (((mng_imagep)pData->pStoreobj)->bVisible) ) ) - { - next_layer (pData); /* that's a new layer then ! */ - - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 7; - else - { - pData->iBreakpoint = 0; - /* anything to display ? */ - if ((pData->iDestr > pData->iDestl) && (pData->iDestb > pData->iDestt)) - { - set_display_routine (pData); /* then determine display routine */ - /* display from the object we store in */ - pData->pRetrieveobj = pData->pStoreobj; - } - } - } - } - - if (!pData->bTimerset) /* no timer break ? */ - { /* default row initialization ! */ - pData->fInitrowproc = (mng_fptr)init_rowproc; - - if ((!pData->bHasDHDR) || (pData->iDeltatype == MNG_DELTATYPE_REPLACE)) - { /* 8-bit JPEG ? */ - if (pData->iJHDRimgbitdepth == 8) - { /* intermediate row is 8-bit deep */ - pData->bIsRGBA16 = MNG_FALSE; - pData->iRowsamples = pData->iDatawidth; - - switch (pData->iJHDRcolortype) /* determine pixel processing routines */ - { - case MNG_COLORTYPE_JPEGGRAY : - { - pData->fStorerow2 = (mng_fptr)store_jpeg_g8; - pData->fRetrieverow = (mng_fptr)retrieve_g8; - pData->bIsOpaque = MNG_TRUE; - break; - } - case MNG_COLORTYPE_JPEGCOLOR : - { - pData->fStorerow2 = (mng_fptr)store_jpeg_rgb8; - pData->fRetrieverow = (mng_fptr)retrieve_rgb8; - pData->bIsOpaque = MNG_TRUE; - break; - } - case MNG_COLORTYPE_JPEGGRAYA : - { - pData->fStorerow2 = (mng_fptr)store_jpeg_ga8; - pData->fRetrieverow = (mng_fptr)retrieve_ga8; - pData->bIsOpaque = MNG_FALSE; - break; - } - case MNG_COLORTYPE_JPEGCOLORA : - { - pData->fStorerow2 = (mng_fptr)store_jpeg_rgba8; - pData->fRetrieverow = (mng_fptr)retrieve_rgba8; - pData->bIsOpaque = MNG_FALSE; - break; - } - } - } - else - { - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - - /* TODO: 12-bit JPEG */ - /* TODO: 8- + 12-bit JPEG (eg. type=20) */ - - } - /* possible IDAT alpha-channel ? */ - if (pData->iJHDRalphacompression == MNG_COMPRESSION_DEFLATE) - { - /* determine alpha processing routine */ - switch (pData->iJHDRalphabitdepth) - { - case 1 : { pData->fInitrowproc = (mng_fptr)init_jpeg_a1_ni; break; } - case 2 : { pData->fInitrowproc = (mng_fptr)init_jpeg_a2_ni; break; } - case 4 : { pData->fInitrowproc = (mng_fptr)init_jpeg_a4_ni; break; } - case 8 : { pData->fInitrowproc = (mng_fptr)init_jpeg_a8_ni; break; } - case 16 : { pData->fInitrowproc = (mng_fptr)init_jpeg_a16_ni; break; } - } - } - else /* possible JDAA alpha-channel ? */ - if (pData->iJHDRalphacompression == MNG_COMPRESSION_BASELINEJPEG) - { /* 8-bit JPEG ? */ - if (pData->iJHDRimgbitdepth == 8) - { - if (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) - pData->fStorerow3 = (mng_fptr)store_jpeg_g8_alpha; - else - if (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) - pData->fStorerow3 = (mng_fptr)store_jpeg_rgb8_alpha; - } - else - { - /* TODO: 12-bit JPEG with 8-bit JDAA */ - } - } - /* initialize JPEG library */ - iRetcode = mngjpeg_initialize (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* must be alpha add/replace !! */ - if ((pData->iDeltatype != MNG_DELTATYPE_BLOCKALPHAADD ) && - (pData->iDeltatype != MNG_DELTATYPE_BLOCKALPHAREPLACE) ) - MNG_ERROR (pData, MNG_INVDELTATYPE) - /* determine alpha processing routine */ - switch (pData->iJHDRalphabitdepth) - { - case 1 : { pData->fInitrowproc = (mng_fptr)init_g1_ni; break; } - case 2 : { pData->fInitrowproc = (mng_fptr)init_g2_ni; break; } - case 4 : { pData->fInitrowproc = (mng_fptr)init_g4_ni; break; } - case 8 : { pData->fInitrowproc = (mng_fptr)init_g8_ni; break; } - case 16 : { pData->fInitrowproc = (mng_fptr)init_g16_ni; break; } - } - } - - pData->iFilterofs = 0; /* determine filter characteristics */ - pData->iLevel0 = 0; /* default levels */ - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - /* leveling & differing ? */ -/* if (pData->iJHDRalphafilter & 0x40) - { - if (pData->iJHDRalphabitdepth <= 8) - pData->iFilterofs = 1; - else - pData->iFilterofs = 2; - - } */ - /* no adaptive filtering ? */ -/* if (pData->iJHDRalphafilter & 0x01) - pData->iPixelofs = pData->iFilterofs; - else */ - pData->iPixelofs = pData->iFilterofs + 1; - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode process_display_jdaa (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAA, MNG_LC_START) -#endif - - if (!pData->bJPEGdecompress2) /* if we're not decompressing already */ - { - if (pData->fInitrowproc) /* initialize row-processing? */ - { - iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData); - pData->fInitrowproc = MNG_NULL; /* only call this once !!! */ - } - - if (!iRetcode) /* initialize decompress */ - iRetcode = mngjpeg_decompressinit2 (pData); - } - - if (!iRetcode) /* all ok? then decompress, my man */ - iRetcode = mngjpeg_decompressdata2 (pData, iRawlen, pRawdata); - - if (iRetcode) - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode process_display_jdat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAT, MNG_LC_START) -#endif - - if (pData->bRestorebkgd) /* need to restore the background ? */ - { - pData->bRestorebkgd = MNG_FALSE; - iRetcode = load_bkgdlayer (pData); - - if ((pData->bDisplaying) && (pData->bRunning)) - pData->iLayerseq++; /* and it counts as a layer then ! */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (!pData->bJPEGdecompress) /* if we're not decompressing already */ - { - if (pData->fInitrowproc) /* initialize row-processing? */ - { - iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData); - pData->fInitrowproc = MNG_NULL; /* only call this once !!! */ - } - - if (!iRetcode) /* initialize decompress */ - iRetcode = mngjpeg_decompressinit (pData); - } - - if (!iRetcode) /* all ok? then decompress, my man */ - iRetcode = mngjpeg_decompressdata (pData, iRawlen, pRawdata); - - if (iRetcode) - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_JDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -mng_retcode process_display_dhdr (mng_datap pData, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky) -{ - mng_imagep pImage; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DHDR, MNG_LC_START) -#endif - - pData->fInitrowproc = MNG_NULL; /* do nothing by default */ - pData->fDisplayrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->pStoreobj = MNG_NULL; - - pData->fDeltagetrow = MNG_NULL; - pData->fDeltaaddrow = MNG_NULL; - pData->fDeltareplacerow = MNG_NULL; - pData->fDeltaputrow = MNG_NULL; - - pImage = find_imageobject (pData, iObjectid); - - if (pImage) /* object exists ? */ - { - if (pImage->pImgbuf->bConcrete) /* is it concrete ? */ - { /* previous magnification to be done ? */ - if ((pImage->iMAGN_MethodX) || (pImage->iMAGN_MethodY)) - { - iRetcode = magnify_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* save delta fields */ - pData->pDeltaImage = (mng_ptr)pImage; - pData->iDeltaImagetype = iImagetype; - pData->iDeltatype = iDeltatype; - pData->iDeltaBlockwidth = iBlockwidth; - pData->iDeltaBlockheight = iBlockheight; - pData->iDeltaBlockx = iBlockx; - pData->iDeltaBlocky = iBlocky; - /* restore target-object fields */ - pData->iDatawidth = pImage->pImgbuf->iWidth; - pData->iDataheight = pImage->pImgbuf->iHeight; - pData->iBitdepth = pImage->pImgbuf->iBitdepth; - pData->iColortype = pImage->pImgbuf->iColortype; - pData->iCompression = pImage->pImgbuf->iCompression; - pData->iFilter = pImage->pImgbuf->iFilter; - pData->iInterlace = pImage->pImgbuf->iInterlace; - -#ifdef MNG_INCLUDE_JNG - pData->iJHDRimgbitdepth = pImage->pImgbuf->iBitdepth; - pData->iJHDRcolortype = pImage->pImgbuf->iColortype; - pData->iJHDRimgcompression = pImage->pImgbuf->iJHDRcompression; - pData->iJHDRimginterlace = pImage->pImgbuf->iJHDRinterlace; - pData->iJHDRalphacompression = pImage->pImgbuf->iCompression; - pData->iJHDRalphafilter = pImage->pImgbuf->iFilter; - pData->iJHDRalphainterlace = pImage->pImgbuf->iInterlace; - pData->iJHDRalphabitdepth = pImage->pImgbuf->iAlphabitdepth; -#endif - /* block size specified ? */ - if (iDeltatype != MNG_DELTATYPE_NOCHANGE) - { - pData->iDatawidth = iBlockwidth; - pData->iDataheight = iBlockheight; - } - - switch (iDeltatype) /* determine nr of delta-channels */ - { - case MNG_DELTATYPE_BLOCKALPHAADD : ; - case MNG_DELTATYPE_BLOCKALPHAREPLACE : - { -#ifdef MNG_INCLUDE_JNG - if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) ) - { - pData->iColortype = MNG_COLORTYPE_GRAY; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGGRAY; - } - else - if ((pData->iColortype == MNG_COLORTYPE_RGBA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { - pData->iColortype = MNG_COLORTYPE_GRAY; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGGRAY; - } -#else - if (pData->iColortype == MNG_COLORTYPE_GRAYA) - pData->iColortype = MNG_COLORTYPE_GRAY; - else - if (pData->iColortype == MNG_COLORTYPE_RGBA) - pData->iColortype = MNG_COLORTYPE_GRAY; -#endif - else /* target has no alpha; that sucks! */ - MNG_ERROR (pData, MNG_TARGETNOALPHA) - - break; - } - - case MNG_DELTATYPE_BLOCKCOLORADD : ; - case MNG_DELTATYPE_BLOCKCOLORREPLACE : - { -#ifdef MNG_INCLUDE_JNG - if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) ) - { - pData->iColortype = MNG_COLORTYPE_GRAY; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGGRAY; - } - else - if ((pData->iColortype == MNG_COLORTYPE_RGBA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { - pData->iColortype = MNG_COLORTYPE_RGB; - pData->iJHDRcolortype = MNG_COLORTYPE_JPEGCOLOR; - } -#else - if (pData->iColortype == MNG_COLORTYPE_GRAYA) - pData->iColortype = MNG_COLORTYPE_GRAY; - else - if (pData->iColortype == MNG_COLORTYPE_RGBA) - pData->iColortype = MNG_COLORTYPE_RGB; -#endif - else /* target has no alpha; that sucks! */ - MNG_ERROR (pData, MNG_TARGETNOALPHA) - - break; - } - - } - /* full image replace ? */ - if (iDeltatype == MNG_DELTATYPE_REPLACE) - { - iRetcode = reset_object_details (pData, pImage, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_FALSE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->pStoreobj = pImage; /* and store straight into this object */ - } - else - { - mng_imagedatap pBufzero, pBuf; - /* we store in object 0 and process it later */ - pData->pStoreobj = pData->pObjzero; - /* make sure to initialize object 0 then */ - iRetcode = reset_object_details (pData, (mng_imagep)pData->pObjzero, - pData->iDatawidth, pData->iDataheight, - pData->iBitdepth, pData->iColortype, - pData->iCompression, pData->iFilter, - pData->iInterlace, MNG_TRUE); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pBuf = pImage->pImgbuf; /* copy possible palette & cheap transparency */ - pBufzero = ((mng_imagep)pData->pObjzero)->pImgbuf; - - pBufzero->bHasPLTE = pBuf->bHasPLTE; - pBufzero->bHasTRNS = pBuf->bHasTRNS; - - if (pBufzero->bHasPLTE) /* copy palette ? */ - { - mng_uint32 iX; - - pBufzero->iPLTEcount = pBuf->iPLTEcount; - - for (iX = 0; iX < pBuf->iPLTEcount; iX++) - { - pBufzero->aPLTEentries [iX].iRed = pBuf->aPLTEentries [iX].iRed; - pBufzero->aPLTEentries [iX].iGreen = pBuf->aPLTEentries [iX].iGreen; - pBufzero->aPLTEentries [iX].iBlue = pBuf->aPLTEentries [iX].iBlue; - } - } - - if (pBufzero->bHasTRNS) /* copy cheap transparency ? */ - { - pBufzero->iTRNSgray = pBuf->iTRNSgray; - pBufzero->iTRNSred = pBuf->iTRNSred; - pBufzero->iTRNSgreen = pBuf->iTRNSgreen; - pBufzero->iTRNSblue = pBuf->iTRNSblue; - pBufzero->iTRNScount = pBuf->iTRNScount; - - MNG_COPY (pBufzero->aTRNSentries, pBuf->aTRNSentries, - sizeof (pBufzero->aTRNSentries)) - } - /* process immediatly if bitdepth & colortype are equal */ - pData->bDeltaimmediate = - (mng_bool)((pData->bDisplaying) && (pData->bRunning) && - (pData->iBitdepth == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iBitdepth ) && - (pData->iColortype == ((mng_imagep)pData->pDeltaImage)->pImgbuf->iColortype) ); - } - - switch (pData->iColortype) /* determine row initialization routine */ - { - case 0 : { /* gray */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g1_ni; - else - pData->fInitrowproc = (mng_fptr)init_g1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g2_ni; - else - pData->fInitrowproc = (mng_fptr)init_g2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g4_ni; - else - pData->fInitrowproc = (mng_fptr)init_g4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g8_ni; - else - pData->fInitrowproc = (mng_fptr)init_g8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_g16_ni; - else - pData->fInitrowproc = (mng_fptr)init_g16_i; - - break; - } - } - - break; - } - case 2 : { /* rgb */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgb16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgb16_i; - - break; - } - } - - break; - } - case 3 : { /* indexed */ - switch (pData->iBitdepth) - { - case 1 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx1_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx1_i; - - break; - } - case 2 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx2_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx2_i; - - break; - } - case 4 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx4_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx4_i; - - break; - } - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_idx8_ni; - else - pData->fInitrowproc = (mng_fptr)init_idx8_i; - - break; - } - } - - break; - } - case 4 : { /* gray+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga8_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_ga16_ni; - else - pData->fInitrowproc = (mng_fptr)init_ga16_i; - - break; - } - } - - break; - } - case 6 : { /* rgb+alpha */ - switch (pData->iBitdepth) - { - case 8 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba8_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba8_i; - - break; - } - case 16 : { - if (!pData->iInterlace) - pData->fInitrowproc = (mng_fptr)init_rgba16_ni; - else - pData->fInitrowproc = (mng_fptr)init_rgba16_i; - - break; - } - } - - break; - } - } - } - else - MNG_ERROR (pData, MNG_OBJNOTCONCRETE) - - } - else - MNG_ERROR (pData, MNG_OBJECTUNKNOWN) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PROM, MNG_LC_START) -#endif - - - /* TODO: everything */ - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_ipng (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IPNG, MNG_LC_START) -#endif - /* indicate it for what it is now */ - pData->iDeltaImagetype = MNG_IMAGETYPE_PNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_ijng (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IJNG, MNG_LC_START) -#endif - /* indicate it for what it is now */ - pData->iDeltaImagetype = MNG_IMAGETYPE_JNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries) -{ - mng_uint32 iX; - mng_imagep pImage = (mng_imagep)pData->pObjzero; - mng_imagedatap pBuf = pImage->pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PPLT, MNG_LC_START) -#endif - - switch (iType) - { - case MNG_DELTATYPE_REPLACERGB : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = paIndexentries [iX].iRed; - pBuf->aPLTEentries [iX].iGreen = paIndexentries [iX].iGreen; - pBuf->aPLTEentries [iX].iBlue = paIndexentries [iX].iBlue; - } - } - - break; - } - case MNG_DELTATYPE_DELTARGB : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = - (mng_uint8)(pBuf->aPLTEentries [iX].iRed + - paIndexentries [iX].iRed ); - pBuf->aPLTEentries [iX].iGreen = - (mng_uint8)(pBuf->aPLTEentries [iX].iGreen + - paIndexentries [iX].iGreen); - pBuf->aPLTEentries [iX].iBlue = - (mng_uint8)(pBuf->aPLTEentries [iX].iBlue + - paIndexentries [iX].iBlue ); - } - } - - break; - } - case MNG_DELTATYPE_REPLACEALPHA : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - pBuf->aTRNSentries [iX] = paAlphaentries [iX]; - } - - break; - } - case MNG_DELTATYPE_DELTAALPHA : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - pBuf->aTRNSentries [iX] = - (mng_uint8)(pBuf->aTRNSentries [iX] + - paAlphaentries [iX]); - } - - break; - } - case MNG_DELTATYPE_REPLACERGBA : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = paIndexentries [iX].iRed; - pBuf->aPLTEentries [iX].iGreen = paIndexentries [iX].iGreen; - pBuf->aPLTEentries [iX].iBlue = paIndexentries [iX].iBlue; - pBuf->aTRNSentries [iX] = paAlphaentries [iX]; - } - } - - break; - } - case MNG_DELTATYPE_DELTARGBA : - { - for (iX = 0; iX < iCount; iX++) - { - if (paUsedentries [iX]) - { - pBuf->aPLTEentries [iX].iRed = - (mng_uint8)(pBuf->aPLTEentries [iX].iRed + - paIndexentries [iX].iRed ); - pBuf->aPLTEentries [iX].iGreen = - (mng_uint8)(pBuf->aPLTEentries [iX].iGreen + - paIndexentries [iX].iGreen); - pBuf->aPLTEentries [iX].iBlue = - (mng_uint8)(pBuf->aPLTEentries [iX].iBlue + - paIndexentries [iX].iBlue ); - pBuf->aTRNSentries [iX] = - (mng_uint8)(pBuf->aTRNSentries [iX] + - paAlphaentries [iX]); - } - } - - break; - } - } - - if ((iType != MNG_DELTATYPE_REPLACERGB) && (iType != MNG_DELTATYPE_DELTARGB)) - { - if (pBuf->bHasTRNS) - { - if (iCount > pBuf->iTRNScount) - pBuf->iTRNScount = iCount; - } - else - { - pBuf->iTRNScount = iCount; - pBuf->bHasTRNS = MNG_TRUE; - } - } - - if ((iType != MNG_DELTATYPE_REPLACEALPHA) && (iType != MNG_DELTATYPE_DELTAALPHA)) - { - if (iCount > pBuf->iPLTEcount) - pBuf->iPLTEcount = iCount; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY) -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_START) -#endif - /* iterate the object-ids */ - for (iX = iFirstid; iX <= iLastid; iX++) - { - if (iX == 0) /* process object 0 ? */ - { - pImage = (mng_imagep)pData->pObjzero; - - pImage->iMAGN_MethodX = iMethodX; - pImage->iMAGN_MethodY = iMethodY; - pImage->iMAGN_MX = iMX; - pImage->iMAGN_MY = iMY; - pImage->iMAGN_ML = iML; - pImage->iMAGN_MR = iMR; - pImage->iMAGN_MT = iMT; - pImage->iMAGN_MB = iMB; - } - else - { - pImage = find_imageobject (pData, iX); - /* object exists & is not frozen ? */ - if ((pImage) && (!pImage->bFrozen)) - { /* previous magnification to be done ? */ - if ((pImage->iMAGN_MethodX) || (pImage->iMAGN_MethodY)) - { - mng_retcode iRetcode = magnify_imageobject (pData, pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - pImage->iMAGN_MethodX = iMethodX; - pImage->iMAGN_MethodY = iMethodY; - pImage->iMAGN_MX = iMX; - pImage->iMAGN_MY = iMY; - pImage->iMAGN_ML = iML; - pImage->iMAGN_MR = iMR; - pImage->iMAGN_MT = iMT; - pImage->iMAGN_MB = iMB; - } - } - } - - iX = iFirstid; - /* iterate again for showing */ - while ((iX <= iLastid) && (!pData->bTimerset)) - { - if (iX) /* only real objects ! */ - { - pImage = find_imageobject (pData, iX); - /* object exists & is not frozen & - is visible & is viewable ? */ - if ((pImage) && (!pImage->bFrozen) && - (pImage->bVisible) && (pImage->bViewable)) - display_image (pData, pImage, MNG_FALSE); - } - - iX++; - } - - if (pData->bTimerset) /* broken ? */ - { - pData->iMAGNfromid = iFirstid; - pData->iMAGNtoid = iLastid; - pData->iBreakpoint = 9; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_display_magn2 (mng_datap pData) -{ - mng_uint16 iX; - mng_imagep pImage; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_START) -#endif - - iX = pData->iMAGNfromid; - /* iterate again for showing */ - while ((iX <= pData->iMAGNtoid) && (!pData->bTimerset)) - { - if (iX) /* only real objects ! */ - { - pImage = find_imageobject (pData, iX); - /* object exists & is not frozen & - is visible & is viewable ? */ - if ((pImage) && (!pImage->bFrozen) && - (pImage->bVisible) && (pImage->bViewable)) - display_image (pData, pImage, MNG_FALSE); - } - - iX++; - } - - if (pData->bTimerset) /* broken ? */ - pData->iBreakpoint = 9; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_DISPLAY_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_display.h b/freeimage241/Source/LibMNG/libmng_display.h deleted file mode 100644 index 32d3b5c..0000000 --- a/freeimage241/Source/LibMNG/libmng_display.h +++ /dev/null @@ -1,195 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_display.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Display management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the display managament routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added JNG support stuff * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added support for delta-image processing * */ -/* * - added support for PPLT chunk processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * * */ -/* * 0.9.4 - 11/24/2000 - G.Juyn * */ -/* * - moved restore of object 0 to libmng_display * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_display_h_ -#define _libmng_display_h_ - -/* ************************************************************************** */ - -mng_retcode display_progressive_refresh (mng_datap pData, - mng_uint32 iInterval); - -/* ************************************************************************** */ - -mng_retcode mng_reset_objzero (mng_datap pData); - -mng_retcode display_image (mng_datap pData, - mng_imagep pImage, - mng_bool bLayeradvanced); - -mng_retcode execute_delta_image (mng_datap pData, - mng_imagep pTarget, - mng_imagep pDelta); - -/* ************************************************************************** */ - -mng_retcode process_display (mng_datap pData); - -/* ************************************************************************** */ - -mng_retcode process_display_ihdr (mng_datap pData); - -mng_retcode process_display_idat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode process_display_iend (mng_datap pData); -mng_retcode process_display_mend (mng_datap pData); -mng_retcode process_display_defi (mng_datap pData); - -mng_retcode process_display_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable); - -mng_retcode process_display_clon (mng_datap pData, - mng_uint16 iSourceid, - mng_uint16 iCloneid, - mng_uint8 iClonetype, - mng_bool bHasdonotshow, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy); -mng_retcode process_display_clon2 (mng_datap pData); - -mng_retcode process_display_disc (mng_datap pData, - mng_uint32 iCount, - mng_uint16p pIds); - -mng_retcode process_display_fram (mng_datap pData, - mng_uint8 iFramemode, - mng_uint8 iChangedelay, - mng_uint32 iDelay, - mng_uint8 iChangetimeout, - mng_uint32 iTimeout, - mng_uint8 iChangeclipping, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); -mng_retcode process_display_fram2 (mng_datap pData); - -mng_retcode process_display_move (mng_datap pData, - mng_uint16 iFromid, - mng_uint16 iToid, - mng_uint8 iMovetype, - mng_int32 iMovex, - mng_int32 iMovey); - -mng_retcode process_display_clip (mng_datap pData, - mng_uint16 iFromid, - mng_uint16 iToid, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); - -mng_retcode process_display_show (mng_datap pData); -mng_retcode process_display_save (mng_datap pData); -mng_retcode process_display_seek (mng_datap pData); -mng_retcode process_display_jhdr (mng_datap pData); - -mng_retcode process_display_jdaa (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode process_display_jdat (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode process_display_dhdr (mng_datap pData, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky); - -mng_retcode process_display_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype); - -mng_retcode process_display_ipng (mng_datap pData); -mng_retcode process_display_ijng (mng_datap pData); - -mng_retcode process_display_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries); - -mng_retcode process_display_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY); -mng_retcode process_display_magn2 (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_display_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_dither.c b/freeimage241/Source/LibMNG/libmng_dither.c deleted file mode 100644 index 4f308e5..0000000 --- a/freeimage241/Source/LibMNG/libmng_dither.c +++ /dev/null @@ -1,54 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_dither.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Dithering routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the dithering routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_dither.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -mng_retcode dither_a_row (mng_datap pData, - mng_uint8p pRow) -{ - - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - - diff --git a/freeimage241/Source/LibMNG/libmng_dither.h b/freeimage241/Source/LibMNG/libmng_dither.h deleted file mode 100644 index 7c8ab8a..0000000 --- a/freeimage241/Source/LibMNG/libmng_dither.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_dither.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Dithering routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the dithering routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_dither_h_ -#define _libmng_dither_h_ - -/* ************************************************************************** */ - -mng_retcode dither_a_row (mng_datap pData, - mng_uint8p pRow); - -/* ************************************************************************** */ - -#endif /* _libmng_dither_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_error.c b/freeimage241/Source/LibMNG/libmng_error.c deleted file mode 100644 index 237f467..0000000 --- a/freeimage241/Source/LibMNG/libmng_error.c +++ /dev/null @@ -1,271 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_error.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Error routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the general error handling routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - added error telltaling * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added errorstrings for delta-image processing * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added errorstring for delayed buffer-processing * */ -/* * * */ -/* * 0.9.1 - 07/06/2000 - G.Juyn * */ -/* * - added MNG_NEEDTIMERWAIT errorstring * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added NEEDSECTIONWAIT errorstring * */ -/* * - added macro + routine to set returncode without * */ -/* * calling error callback * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added errorstring for updatemngheader if not a MNG * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/09/2000 - G.Juyn * */ -/* * - added check for simplicity-bits in MHDR * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - fixed processing of unknown critical chunks * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added errorcode for delayed delta-processing * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added errorcode for MAGN methods * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ERROR_STRINGS - mng_error_entry error_table [] = - { - {MNG_NOERROR, "No error"}, - {MNG_OUTOFMEMORY, "Out of memory"}, - {MNG_INVALIDHANDLE, "The handle is invalid"}, - {MNG_NOCALLBACK, "A required callback is not defined"}, - {MNG_UNEXPECTEDEOF, "Encountered unexpected end-of-file"}, - {MNG_ZLIBERROR, "zlib encountered an error"}, - {MNG_JPEGERROR, "ijgsrc6b encountered an error"}, - {MNG_LCMSERROR, "lcms encountered an error"}, - {MNG_NOOUTPUTPROFILE, "No output-profile defined for CMS"}, - {MNG_NOSRGBPROFILE, "No sRGB-profile defined for CMS"}, - {MNG_BUFOVERFLOW, "Internal buffer-overflow"}, - {MNG_FUNCTIONINVALID, "Function is invalid at this point"}, - {MNG_OUTPUTERROR, "Writing was unsuccessful; disk full?"}, - {MNG_JPEGBUFTOOSMALL, "Internal buffer for JPEG processing too small"}, - {MNG_NEEDMOREDATA, "Reading suspended; waiting for I/O to catch up"}, - {MNG_NEEDTIMERWAIT, "Timer suspension; normal animation delay"}, - {MNG_NEEDSECTIONWAIT, "SEEK suspension; application decides"}, - {MNG_LOOPWITHCACHEOFF, "LOOP encountered when playback cache is turned off"}, - - {MNG_APPIOERROR, "Application signalled I/O error"}, - {MNG_APPTIMERERROR, "Application signalled timing error"}, - {MNG_APPCMSERROR, "Application signalled CMS error"}, - {MNG_APPMISCERROR, "Application signalled an error"}, - {MNG_APPTRACEABORT, "Application signalled error during trace-callback"}, - - {MNG_INTERNALERROR, "Internal error in libmng"}, - - {MNG_INVALIDSIG, "The signature is invalid"}, - {MNG_INVALIDCRC, "The CRC for this chunk is invalid"}, - {MNG_INVALIDLENGTH, "Chunk-length is invalid"}, - {MNG_SEQUENCEERROR, "Chunk out of sequence"}, - {MNG_CHUNKNOTALLOWED, "Chunk not allowed at this point"}, - {MNG_MULTIPLEERROR, "Chunk cannot occur multiple times"}, - {MNG_PLTEMISSING, "Missing PLTE chunk"}, - {MNG_IDATMISSING, "Missing IDAT chunk(s)"}, - {MNG_CANNOTBEEMPTY, "Chunk cannot be empty"}, - {MNG_GLOBALLENGTHERR, "Global data length invalid"}, - {MNG_INVALIDBITDEPTH, "The bit_depth is invalid"}, - {MNG_INVALIDCOLORTYPE, "The color_type is invalid"}, - {MNG_INVALIDCOMPRESS, "The compression_method is invalid"}, - {MNG_INVALIDFILTER, "The filter_method or filter_type is invalid"}, - {MNG_INVALIDINTERLACE, "The interlace_method is invalid"}, - {MNG_NOTENOUGHIDAT, "There is not enough data in the IDAT chunk(s)"}, - {MNG_PLTEINDEXERROR, "Palette-index out of bounds"}, - {MNG_NULLNOTFOUND, "NULL separator not found"}, - {MNG_KEYWORDNULL, "Keyword cannot be zero-length"}, - {MNG_OBJECTUNKNOWN, "Object does not exist"}, - {MNG_OBJECTEXISTS, "Object already exists"}, - {MNG_TOOMUCHIDAT, "Too much data in IDAT chunk(s)"}, - {MNG_INVSAMPLEDEPTH, "The sample_depth is invalid"}, - {MNG_INVOFFSETSIZE, "The offset_type is invalid"}, - {MNG_INVENTRYTYPE, "The entry_type is invalid"}, - {MNG_ENDWITHNULL, "Chunk must not end with NULL byte"}, - {MNG_INVIMAGETYPE, "The image_type is invalid"}, - {MNG_INVDELTATYPE, "The delta_type is invalid"}, - {MNG_INVALIDINDEX, "Index-value out of bounds"}, - {MNG_TOOMUCHJDAT, "Too much data in JDAT chunk(s)"}, - {MNG_JPEGPARMSERR, "JHDR parameters & JFIF-data do not match"}, - {MNG_INVFILLMETHOD, "The fill_method is invalid"}, - {MNG_OBJNOTCONCRETE, "Target object for DHDR must be concrete"}, - {MNG_TARGETNOALPHA, "Target object must have alpha-channel"}, - {MNG_MNGTOOCOMPLEX, "MHDR simplicity indicates unsupported feature(s)"}, - {MNG_UNKNOWNCRITICAL, "Unknown critical chunk encountered"}, - {MNG_UNSUPPORTEDNEED, "Requested nEED resources are not supported"}, - {MNG_INVALIDDELTA, "The delta operation is invalid (mismatched color_types?)"}, - {MNG_INVALIDMETHOD, "Method is invalid"}, - - {MNG_INVALIDCNVSTYLE, "Canvas_style is invalid"}, - {MNG_WRONGCHUNK, "Attempt to access the wrong chunk"}, - {MNG_INVALIDENTRYIX, "Attempt to access an non-existing entry"}, - {MNG_NOHEADER, "No valid header-chunk"}, - {MNG_NOCORRCHUNK, "Parent chunk not found"}, - {MNG_NOMHDR, "No MNG header (MHDR) found"}, - - {MNG_IMAGETOOLARGE, "Image is larger than defined maximum"}, - {MNG_NOTANANIMATION, "Image is not an animation"}, - {MNG_FRAMENRTOOHIGH, "Framenr out of bounds"}, - {MNG_LAYERNRTOOHIGH, "Layernr out of bounds"}, - {MNG_PLAYTIMETOOHIGH, "Playtime out of bounds"}, - {MNG_FNNOTIMPLEMENTED, "Function not yet implemented"}, - {MNG_IMAGEFROZEN, "Image is frozen"}, - - {MNG_LCMS_NOHANDLE, "Handle could not be initialized"}, - {MNG_LCMS_NOMEM, "No memory for gamma-table(s)"}, - {MNG_LCMS_NOTRANS, "Transformation could not be initialized"}, - }; -#endif /* MNG_INCLUDE_ERROR_STRINGS */ - -/* ************************************************************************** */ - -mng_bool mng_store_error (mng_datap pData, - mng_retcode iError, - mng_retcode iExtra1, - mng_retcode iExtra2) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (pData, MNG_FN_STORE_ERROR, MNG_LC_START) -#endif - - if (pData != 0) - { - pData->iErrorcode = iError; /* save also for getlasterror */ - pData->iErrorx1 = iExtra1; - pData->iErrorx2 = iExtra2; - -#ifdef MNG_INCLUDE_ERROR_STRINGS - { /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - mng_error_entryp pEntry; /* pointer to found entry */ - /* determine max index of table */ - iTop = (sizeof (error_table) / sizeof (error_table [0])) - 1; - - iLower = 0; /* initialize binary search */ - iMiddle = iTop >> 1; /* start in the middle */ - iUpper = iTop; - pEntry = 0; /* no goods yet! */ - - do /* the binary search itself */ - { - if (error_table [iMiddle].iError < iError) - iLower = iMiddle + 1; - else if (error_table [iMiddle].iError > iError) - iUpper = iMiddle - 1; - else - { - pEntry = &error_table [iMiddle]; - break; - } - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - - if (pEntry) /* found it ? */ - pData->zErrortext = pEntry->zErrortext; - else - pData->zErrortext = "Unknown error"; - } -#else - pData->zErrortext = 0; -#endif /* mng_error_telltale */ - - if (iError == 0) /* no error is not severe ! */ - { - pData->iSeverity = 0; - } - else - { - switch (iError&0x3C00) /* determine the severity */ - { - case 0x0800 : { pData->iSeverity = 5; break; } - case 0x1000 : { pData->iSeverity = 2; break; } - case 0x2000 : { pData->iSeverity = 1; break; } - default : { pData->iSeverity = 9; } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (pData, MNG_FN_STORE_ERROR, MNG_LC_END) -#endif - - return MNG_TRUE; -} - -/* ************************************************************************** */ - -mng_bool mng_process_error (mng_datap pData, - mng_retcode iError, - mng_retcode iExtra1, - mng_retcode iExtra2) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (pData, MNG_FN_PROCESS_ERROR, MNG_LC_START) -#endif - - mng_store_error (pData, iError, iExtra1, iExtra2); - - if (pData != 0) - { - if (pData->fErrorproc) /* callback defined ? */ - return pData->fErrorproc (((mng_handle)pData), iError, pData->iSeverity, - pData->iChunkname, pData->iChunkseq, - pData->iErrorx1, pData->iErrorx2, pData->zErrortext); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (pData, MNG_FN_PROCESS_ERROR, MNG_LC_END) -#endif - - return MNG_FALSE; /* automatic failure */ -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_error.h b/freeimage241/Source/LibMNG/libmng_error.h deleted file mode 100644 index 9ea9316..0000000 --- a/freeimage241/Source/LibMNG/libmng_error.h +++ /dev/null @@ -1,109 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_error.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Error functions (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the generic error-codes and functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - added some errorcodes * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added some errorcodes * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added application errorcodes (used with callbacks) * */ -/* * - moved chunk-access errorcodes to severity 5 * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added JNG errorcodes * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - added error tell-tale definition * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added errorcodes for delta-image processing * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added errorcode for delayed buffer-processing * */ -/* * - moved errorcodes to "libmng.h" * */ -/* * * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added macro + routine to set returncode without * */ -/* * calling error callback * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_error_h_ -#define _libmng_error_h_ - -/* ************************************************************************** */ -/* * * */ -/* * Default error routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_bool mng_store_error (mng_datap pData, - mng_retcode iError, - mng_retcode iExtra1, - mng_retcode iExtra2); - -mng_bool mng_process_error (mng_datap pData, - mng_retcode iError, - mng_retcode iExtra1, - mng_retcode iExtra2); - -/* ************************************************************************** */ -/* * * */ -/* * Error handling macros * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_ERROR(D,C) { mng_process_error (D, C, 0, 0); return C; } -#define MNG_ERRORZ(D,Z) { mng_process_error (D, MNG_ZLIBERROR, Z, 0); return MNG_ZLIBERROR; } -#define MNG_ERRORJ(D,J) { mng_process_error (D, MNG_JPEGERROR, J, 0); return MNG_JPEGERROR; } -#define MNG_ERRORL(D,L) { mng_process_error (D, MNG_LCMSERROR, L, 0); return MNG_LCMSERROR; } - -#define MNG_RETURN(D,C) { mng_store_error (D, C, 0, 0); return C; } - -#define MNG_WARNING(D,C) { if (!mng_process_error (D, C, 0, 0)) return C; } - -#define MNG_VALIDHANDLE(H) { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \ - return MNG_INVALIDHANDLE; } -#define MNG_VALIDHANDLEX(H) { if ((H == 0) || (((mng_datap)H)->iMagic != MNG_MAGIC)) \ - return 0; } -#define MNG_VALIDCB(D,C) { if (!((mng_datap)D)->C) \ - MNG_ERROR (((mng_datap)D), MNG_NOCALLBACK) } - -/* ************************************************************************** */ -/* * * */ -/* * Error string-table entry * */ -/* * * */ -/* ************************************************************************** */ - -typedef struct { - mng_retcode iError; - mng_pchar zErrortext; - } mng_error_entry; -typedef mng_error_entry * mng_error_entryp; - -/* ************************************************************************** */ - -#endif /* _libmng_error_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_filter.c b/freeimage241/Source/LibMNG/libmng_filter.c deleted file mode 100644 index a055f5c..0000000 --- a/freeimage241/Source/LibMNG/libmng_filter.c +++ /dev/null @@ -1,890 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_filter.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Filtering routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the filtering routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_filter.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_FILTERS - -/* ************************************************************************** */ - -mng_retcode filter_a_row (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_A_ROW, MNG_LC_START) -#endif - - switch (*(pData->pWorkrow + pData->iFilterofs)) - { - case 1 : { - iRetcode = filter_sub (pData); - break; - } - case 2 : { - iRetcode = filter_up (pData); - break; - } - case 3 : { - iRetcode = filter_average (pData); - break; - } - case 4 : { - iRetcode = filter_paeth (pData); - break; - } - - default : iRetcode = MNG_INVALIDFILTER; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_A_ROW, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode filter_sub (mng_datap pData) -{ - mng_uint32 iBpp; - mng_uint8p pRawx; - mng_uint8p pRawx_prev; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_SUB, MNG_LC_START) -#endif - - iBpp = pData->iFilterbpp; - pRawx = pData->pWorkrow + pData->iPixelofs + iBpp; - pRawx_prev = pData->pWorkrow + pData->iPixelofs; - - for (iX = iBpp; iX < pData->iRowsize; iX++) - { - *pRawx = (mng_uint8)(*pRawx + *pRawx_prev); - pRawx++; - pRawx_prev++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_SUB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode filter_up (mng_datap pData) -{ - mng_uint8p pRawx; - mng_uint8p pPriorx; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_UP, MNG_LC_START) -#endif - - pRawx = pData->pWorkrow + pData->iPixelofs; - pPriorx = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsize; iX++) - { - *pRawx = (mng_uint8)(*pRawx + *pPriorx); - pRawx++; - pPriorx++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_UP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode filter_average (mng_datap pData) -{ - mng_int32 iBpp; - mng_uint8p pRawx; - mng_uint8p pRawx_prev; - mng_uint8p pPriorx; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_AVERAGE, MNG_LC_START) -#endif - - iBpp = pData->iFilterbpp; - pRawx = pData->pWorkrow + pData->iPixelofs; - pPriorx = pData->pPrevrow + pData->iPixelofs; - pRawx_prev = pData->pWorkrow + pData->iPixelofs; - - for (iX = 0; iX < iBpp; iX++) - { - *pRawx = (mng_uint8)(*pRawx + ((*pPriorx) >> 1)); - pRawx++; - pPriorx++; - } - - for (iX = iBpp; iX < pData->iRowsize; iX++) - { - *pRawx = (mng_uint8)(*pRawx + ((*pRawx_prev + *pPriorx) >> 1)); - pRawx++; - pPriorx++; - pRawx_prev++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_AVERAGE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode filter_paeth (mng_datap pData) -{ - mng_int32 iBpp; - mng_uint8p pRawx; - mng_uint8p pRawx_prev; - mng_uint8p pPriorx; - mng_uint8p pPriorx_prev; - mng_int32 iX; - mng_uint32 iA, iB, iC; - mng_uint32 iP; - mng_uint32 iPa, iPb, iPc; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_PAETH, MNG_LC_START) -#endif - - iBpp = pData->iFilterbpp; - pRawx = pData->pWorkrow + pData->iPixelofs; - pPriorx = pData->pPrevrow + pData->iPixelofs; - pRawx_prev = pData->pWorkrow + pData->iPixelofs; - pPriorx_prev = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < iBpp; iX++) - { - *pRawx = (mng_uint8)(*pRawx + *pPriorx); - - pRawx++; - pPriorx++; - } - - for (iX = iBpp; iX < pData->iRowsize; iX++) - { - iA = (mng_uint32)*pRawx_prev; - iB = (mng_uint32)*pPriorx; - iC = (mng_uint32)*pPriorx_prev; - iP = iA + iB - iC; - iPa = abs (iP - iA); - iPb = abs (iP - iB); - iPc = abs (iP - iC); - - if ((iPa <= iPb) && (iPa <= iPc)) - *pRawx = (mng_uint8)(*pRawx + iA); - else - if (iPb <= iPc) - *pRawx = (mng_uint8)(*pRawx + iB); - else - *pRawx = (mng_uint8)(*pRawx + iC); - - pRawx++; - pPriorx++; - pRawx_prev++; - pPriorx_prev++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FILTER_PAETH, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode init_rowdiffering (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWDIFFERING, MNG_LC_START) -#endif - - if (pData->iFilter & 0x40) /* has leveling parameters ? */ - { - switch (pData->iColortype) /* salvage leveling parameters */ - { - case 0 : { /* gray */ - if (pData->iBitdepth <= 8) - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - else - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - - break; - } - case 2 : { /* rgb */ - if (pData->iBitdepth <= 8) - { - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - pData->iLevel1 = (mng_uint16)*(pData->pWorkrow+1); - pData->iLevel2 = (mng_uint16)*(pData->pWorkrow+2); - } - else - { - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - pData->iLevel1 = mng_get_uint16 (pData->pWorkrow+2); - pData->iLevel2 = mng_get_uint16 (pData->pWorkrow+4); - } - - break; - } - case 3 : { /* indexed */ - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - break; - } - case 4 : { /* gray+alpha */ - if (pData->iBitdepth <= 8) - { - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - pData->iLevel1 = (mng_uint16)*(pData->pWorkrow+1); - } - else - { - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - pData->iLevel1 = mng_get_uint16 (pData->pWorkrow+2); - } - - break; - } - case 6 : { /* rgb+alpha */ - if (pData->iBitdepth <= 8) - { - pData->iLevel0 = (mng_uint16)*pData->pWorkrow; - pData->iLevel1 = (mng_uint16)*(pData->pWorkrow+1); - pData->iLevel2 = (mng_uint16)*(pData->pWorkrow+2); - pData->iLevel3 = (mng_uint16)*(pData->pWorkrow+3); - } - else - { - pData->iLevel0 = mng_get_uint16 (pData->pWorkrow); - pData->iLevel1 = mng_get_uint16 (pData->pWorkrow+2); - pData->iLevel2 = mng_get_uint16 (pData->pWorkrow+4); - pData->iLevel3 = mng_get_uint16 (pData->pWorkrow+6); - } - - break; - } - } - } - /* shift the entire row back in place */ - pRawi = pData->pWorkrow + pData->iFilterofs; - pRawo = pData->pWorkrow; - - for (iX = 0; iX < pData->iRowsize + pData->iPixelofs - pData->iFilterofs; iX++) - *pRawo++ = *pRawi++; - - pData->iFilterofs = 0; /* indicate so ! */ - - if (pData->iFilter & 0x01) /* no adaptive filtering ? */ - pData->iPixelofs = pData->iFilterofs; - else - pData->iPixelofs = pData->iFilterofs + 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWDIFFERING, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_g1 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G1, MNG_LC_START) -#endif - - if (pData->iLevel0 & 0x01) /* is it uneven level ? */ - { - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - /* just invert every bit */ - for (iX = 0; iX < pData->iRowsize; iX++) - *pRawo++ = (mng_uint8)(~(*pRawi++)); - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_g2 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G2, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iC) - { - iC = 4; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 2; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x03); - iN = (mng_uint8)((iN << 2) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_g4 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G4, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iC) - { - iC = 2; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 4; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x0F); - iN = (mng_uint8)((iN << 4) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_g8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G8, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRawo++ = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0) & 0xFF); - - pRawi++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_g16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G16, MNG_LC_START) -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRawo++ = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0) & 0xFFFF); - - pRawi++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_rgb8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB8, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *(pRawo+1) = (mng_uint8)(((mng_uint16)*(pRawi+1) + pData->iLevel1) & 0xFF); - *pRawo = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0 + - (mng_uint16)*(pRawo+1)) & 0xFF); - *(pRawo+2) = (mng_uint8)(((mng_uint16)*(pRawi+2) + pData->iLevel2 + - (mng_uint16)*(pRawo+1)) & 0xFF); - - pRawi += 3; - pRawo += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_rgb16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB16, MNG_LC_START) -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *(pRawo+1) = (mng_uint16)(((mng_uint32)*(pRawi+1) + (mng_uint32)pData->iLevel1) & 0xFFFF); - *pRawo = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - *(pRawo+2) = (mng_uint16)(((mng_uint32)*(pRawi+2) + (mng_uint32)pData->iLevel2 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - - pRawi += 3; - pRawo += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_idx1 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX1, MNG_LC_START) -#endif - - if (pData->iLevel0 & 0x01) /* is it uneven level ? */ - { - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - /* just invert every bit */ - for (iX = 0; iX < pData->iRowsize; iX++) - *pRawo++ = (mng_uint8)(~(*pRawi++)); - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_idx2 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX2, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iC) - { - iC = 4; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 2; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x03); - iN = (mng_uint8)((iN << 2) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_idx4 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - mng_int32 iC, iS; - mng_uint8 iB, iN, iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX4, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - iC = 0; - iB = 0; - iN = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iC) - { - iC = 2; - iB = *pRawi++; - iN = 0; - iS = 8; - } - - iS -= 4; - iQ = (mng_uint8)(((iB >> iS) + pData->iLevel0) & 0x0F); - iN = (mng_uint8)((iN << 4) + iQ); - iC--; - - if (!iC) - *pRawo++ = iN; - - } - - if (iC) - *pRawo = (mng_uint8)(iN << iS); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_idx8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX8, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRawo++ = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0) & 0xFF); - - pRawi++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_IDX8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_ga8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA8, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRawo = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0) & 0xFF); - *(pRawo+1) = (mng_uint8)(((mng_uint16)*(pRawi+1) + pData->iLevel1) & 0xFF); - - pRawi += 2; - pRawo += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_ga16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA16, MNG_LC_START) -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRawo = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0) & 0xFFFF); - *(pRawo+1) = (mng_uint16)(((mng_uint32)*(pRawi+1) + (mng_uint32)pData->iLevel1) & 0xFFFF); - - pRawi += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_GA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_rgba8 (mng_datap pData) -{ - mng_uint8p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA8, MNG_LC_START) -#endif - - pRawi = pData->pWorkrow + pData->iPixelofs; - pRawo = pData->pPrevrow + pData->iPixelofs; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *(pRawo+1) = (mng_uint8)(((mng_uint16)*(pRawi+1) + pData->iLevel1) & 0xFF); - *pRawo = (mng_uint8)(((mng_uint16)*pRawi + pData->iLevel0 + - (mng_uint16)*(pRawo+1)) & 0xFF); - *(pRawo+2) = (mng_uint8)(((mng_uint16)*(pRawi+2) + pData->iLevel2 + - (mng_uint16)*(pRawo+1)) & 0xFF); - *(pRawo+3) = (mng_uint8)(((mng_uint16)*(pRawi+3) + pData->iLevel3) & 0xFF); - - pRawi += 4; - pRawo += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode differ_rgba16 (mng_datap pData) -{ - mng_uint16p pRawi, pRawo; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA16, MNG_LC_START) -#endif - - pRawi = (mng_uint16p)(pData->pWorkrow + pData->iPixelofs); - pRawo = (mng_uint16p)(pData->pPrevrow + pData->iPixelofs); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *(pRawo+1) = (mng_uint16)(((mng_uint32)*(pRawi+1) + (mng_uint32)pData->iLevel1) & 0xFFFF); - *pRawo = (mng_uint16)(((mng_uint32)*pRawi + (mng_uint32)pData->iLevel0 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - *(pRawo+2) = (mng_uint16)(((mng_uint32)*(pRawi+2) + (mng_uint32)pData->iLevel2 + - (mng_uint32)*(pRawo+1)) & 0xFFFF); - *(pRawo+3) = (mng_uint16)(((mng_uint32)*(pRawi+3) + (mng_uint32)pData->iLevel3) & 0xFFFF); - - pRawi += 4; - pRawo += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DIFFER_RGBA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_FILTERS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_filter.h b/freeimage241/Source/LibMNG/libmng_filter.h deleted file mode 100644 index 2c8c61d..0000000 --- a/freeimage241/Source/LibMNG/libmng_filter.h +++ /dev/null @@ -1,71 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_filter.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Filtering routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the filtering routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_filter_h_ -#define _libmng_filter_h_ - -/* ************************************************************************** */ - -mng_retcode filter_a_row (mng_datap pData); - -mng_retcode filter_sub (mng_datap pData); -mng_retcode filter_up (mng_datap pData); -mng_retcode filter_average (mng_datap pData); -mng_retcode filter_paeth (mng_datap pData); - -/* ************************************************************************** */ - -mng_retcode init_rowdiffering (mng_datap pData); - -mng_retcode differ_g1 (mng_datap pData); -mng_retcode differ_g2 (mng_datap pData); -mng_retcode differ_g4 (mng_datap pData); -mng_retcode differ_g8 (mng_datap pData); -mng_retcode differ_g16 (mng_datap pData); -mng_retcode differ_rgb8 (mng_datap pData); -mng_retcode differ_rgb16 (mng_datap pData); -mng_retcode differ_idx1 (mng_datap pData); -mng_retcode differ_idx2 (mng_datap pData); -mng_retcode differ_idx4 (mng_datap pData); -mng_retcode differ_idx8 (mng_datap pData); -mng_retcode differ_ga8 (mng_datap pData); -mng_retcode differ_ga16 (mng_datap pData); -mng_retcode differ_rgba8 (mng_datap pData); -mng_retcode differ_rgba16 (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_filter_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_hlapi.c b/freeimage241/Source/LibMNG/libmng_hlapi.c deleted file mode 100644 index 9a897ff..0000000 --- a/freeimage241/Source/LibMNG/libmng_hlapi.c +++ /dev/null @@ -1,1814 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_hlapi.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : high-level application API (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the high-level function interface * */ -/* * for applications. * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - added init of iPLTEcount * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed calling-convention definition * */ -/* * - changed status-handling of display-routines * */ -/* * - added versioning-control routines * */ -/* * - filled the write routine * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */ -/* * - added TERM animation object pointer (easier reference) * */ -/* * 0.5.1 - 05/14/2000 - G.Juyn * */ -/* * - added cleanup of saved-data (SAVE/SEEK processing) * */ -/* * 0.5.1 - 05/16/2000 - G.Juyn * */ -/* * - moved the actual write_graphic functionality from here * */ -/* * to it's appropriate function in the mng_write module * */ -/* * * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - cleaned up some code regarding mixed support * */ -/* * - added JNG support * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - moved init of default zlib parms here from "mng_zlib.c" * */ -/* * - added init of default IJG parms * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - fixed inconsistancy with freeing global iCCP profile * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added delta-image field initialization * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added initialization of the buffer-suspend parameter * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - added initialization of update-region for refresh * */ -/* * - added initialization of Needrefresh parameter * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - added initialization of Deltaimmediate * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added initialization of Speed * */ -/* * - added initialization of Imagelevel * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed initialization routine for new mng_handle type * */ -/* * * */ -/* * 0.9.1 - 07/06/2000 - G.Juyn * */ -/* * - changed mng_display_resume to allow to be called after * */ -/* * a suspension return with MNG_NEEDMOREDATA * */ -/* * - added returncode MNG_NEEDTIMERWAIT for timer breaks * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - implemented support for freeze/reset/resume & go_xxxx * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added support for improved timing * */ -/* * - added support for improved I/O-suspension * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed EOF processing behavior * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * - added variable for NEEDSECTIONWAIT breaks * */ -/* * - added variable for freeze & reset processing * */ -/* * 0.9.1 - 07/17/2000 - G.Juyn * */ -/* * - added error cleanup processing * */ -/* * - fixed support for mng_display_reset() * */ -/* * - fixed suspension-buffering for 32K+ chunks * */ -/* * * */ -/* * 0.9.2 - 07/29/2000 - G.Juyn * */ -/* * - fixed small bugs in display processing * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - fixed wrapping of suspension parameters * */ -/* * 0.9.2 - 08/04/2000 - G.Juyn * */ -/* * - B111096 - fixed large-buffer read-suspension * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - raised initial maximum canvas size * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - fixed support for delta-images during read() / display() * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - added closestream() processing for mng_cleanup() * */ -/* * 0.9.3 - 10/27/2000 - G.Juyn * */ -/* * - fixed seperate read() & display() processing * */ -/* * * */ -/* * 0.9.4 - 11/20/2000 - G.Juyn * */ -/* * - fixed unwanted repetition in mng_readdisplay() * */ -/* * 0.9.4 - 11/24/2000 - G.Juyn * */ -/* * - moved restore of object 0 to libmng_display * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 02/13/2001 - G.Juyn * */ -/* * - fixed first FRAM_MODE=4 timing problem * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn * */ -/* * - fixed bug with display_reset/display_resume (Thanks G!) * */ -/* * 1.0.1 - 04/22/2001 - G.Juyn * */ -/* * - fixed memory-leak (Thanks Gregg!) * */ -/* * 1.0.1 - 04/23/2001 - G.Juyn * */ -/* * - fixed reset_rundata to drop all objects * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_chunks.h" -#include "libmng_memory.h" -#include "libmng_read.h" -#include "libmng_write.h" -#include "libmng_display.h" -#include "libmng_zlib.h" -#include "libmng_jpeg.h" -#include "libmng_cms.h" -#include "libmng_pixels.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * local routines * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) -mng_retcode mng_drop_chunks (mng_datap pData) -{ - mng_chunkp pChunk; - mng_chunkp pNext; - mng_cleanupchunk fCleanup; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_CHUNKS, MNG_LC_START) -#endif - - pChunk = pData->pFirstchunk; /* and get first stored chunk (if any) */ - - while (pChunk) /* more chunks to discard ? */ - { - pNext = ((mng_chunk_headerp)pChunk)->pNext; - /* call appropriate cleanup */ - fCleanup = ((mng_chunk_headerp)pChunk)->fCleanup; - fCleanup (pData, pChunk); - - pChunk = pNext; /* neeeext */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_CHUNKS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode mng_drop_objects (mng_datap pData, - mng_bool bDropaniobj) -{ - mng_objectp pObject; - mng_objectp pNext; - mng_cleanupobject fCleanup; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_OBJECTS, MNG_LC_START) -#endif - - pObject = pData->pFirstimgobj; /* get first stored image-object (if any) */ - - while (pObject) /* more objects to discard ? */ - { - pNext = ((mng_object_headerp)pObject)->pNext; - /* call appropriate cleanup */ - fCleanup = ((mng_object_headerp)pObject)->fCleanup; - fCleanup (pData, pObject); - - pObject = pNext; /* neeeext */ - } - - pData->pFirstimgobj = MNG_NULL; /* clean this up!!! */ - - if (bDropaniobj) /* drop animation objects ? */ - { - pObject = pData->pFirstaniobj; /* get first stored animation-object (if any) */ - - while (pObject) /* more objects to discard ? */ - { - pNext = ((mng_object_headerp)pObject)->pNext; - /* call appropriate cleanup */ - fCleanup = ((mng_object_headerp)pObject)->fCleanup; - fCleanup (pData, pObject); - - pObject = pNext; /* neeeext */ - } - - pData->pFirstaniobj = MNG_NULL; /* clean this up!!! */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_OBJECTS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode mng_drop_savedata (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_SAVEDATA, MNG_LC_START) -#endif - - if (pData->pSavedata) /* sanity check */ - { /* address it more directly */ - mng_savedatap pSave = pData->pSavedata; - - if (pSave->iGlobalProfilesize) /* cleanup the profile ? */ - MNG_FREEX (pData, pSave->pGlobalProfile, pSave->iGlobalProfilesize) - /* cleanup the save structure */ - MNG_FREE (pData, pData->pSavedata, sizeof (mng_savedata)) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_SAVEDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode mng_reset_rundata (mng_datap pData) -{ - drop_invalid_objects (pData); /* drop invalidly stored objects */ - mng_drop_savedata (pData); /* drop stored savedata */ - mng_reset_objzero (pData); /* reset object 0 */ - /* drop stored objects (if any) */ - mng_drop_objects (pData, MNG_FALSE); - - pData->bFramedone = MNG_FALSE; - pData->iFrameseq = 0; /* reset counters & stuff */ - pData->iLayerseq = 0; - pData->iFrametime = 0; - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - - pData->iRuntime = 0; - pData->iSynctime = 0; - pData->iStarttime = 0; - pData->iEndtime = 0; - pData->bRunning = MNG_FALSE; - pData->bTimerset = MNG_FALSE; - pData->iBreakpoint = 0; - pData->bSectionwait = MNG_FALSE; - pData->bFreezing = MNG_FALSE; - pData->bResetting = MNG_FALSE; - pData->bNeedrefresh = MNG_FALSE; - - pData->iIterations = 0; - /* start of animation objects! */ - pData->pCurraniobj = MNG_NULL; - - pData->iUpdateleft = 0; /* reset region */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; - pData->iPLTEcount = 0; /* reset PLTE data */ - - pData->iDEFIobjectid = 0; /* reset DEFI data */ - pData->bDEFIhasdonotshow = MNG_FALSE; - pData->iDEFIdonotshow = 0; - pData->bDEFIhasconcrete = MNG_FALSE; - pData->iDEFIconcrete = 0; - pData->bDEFIhasloca = MNG_FALSE; - pData->iDEFIlocax = 0; - pData->iDEFIlocay = 0; - pData->bDEFIhasclip = MNG_FALSE; - pData->iDEFIclipl = 0; - pData->iDEFIclipr = 0; - pData->iDEFIclipt = 0; - pData->iDEFIclipb = 0; - - pData->iBACKred = 0; /* reset BACK data */ - pData->iBACKgreen = 0; - pData->iBACKblue = 0; - pData->iBACKmandatory = 0; - pData->iBACKimageid = 0; - pData->iBACKtile = 0; - - pData->iFRAMmode = 1; /* default global FRAM variables */ - pData->iFRAMdelay = 1; - pData->iFRAMtimeout = 0x7fffffffl; - pData->bFRAMclipping = MNG_FALSE; - pData->iFRAMclipl = 0; - pData->iFRAMclipr = 0; - pData->iFRAMclipt = 0; - pData->iFRAMclipb = 0; - - pData->iFramemode = 1; /* again for the current frame */ - pData->iFramedelay = 1; - pData->iFrametimeout = 0x7fffffffl; - pData->bFrameclipping = MNG_FALSE; - pData->iFrameclipl = 0; - pData->iFrameclipr = 0; - pData->iFrameclipt = 0; - pData->iFrameclipb = 0; - - pData->iNextdelay = 1; - - pData->iSHOWmode = 0; /* reset SHOW data */ - pData->iSHOWfromid = 0; - pData->iSHOWtoid = 0; - pData->iSHOWnextid = 0; - pData->iSHOWskip = 0; - - pData->iGlobalPLTEcount = 0; /* reset global PLTE data */ - - pData->iGlobalTRNSrawlen = 0; /* reset global tRNS data */ - - pData->iGlobalGamma = 0; /* reset global gAMA data */ - - pData->iGlobalWhitepointx = 0; /* reset global cHRM data */ - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; - - pData->iGlobalRendintent = 0; /* reset global sRGB data */ - - if (pData->iGlobalProfilesize) /* drop global profile (if any) */ - MNG_FREE (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) - - pData->iGlobalProfilesize = 0; - - pData->iGlobalBKGDred = 0; /* reset global bKGD data */ - pData->iGlobalBKGDgreen = 0; - pData->iGlobalBKGDblue = 0; - /* reset delta-image */ - pData->pDeltaImage = MNG_NULL; - pData->iDeltaImagetype = 0; - pData->iDeltatype = 0; - pData->iDeltaBlockwidth = 0; - pData->iDeltaBlockheight = 0; - pData->iDeltaBlockx = 0; - pData->iDeltaBlocky = 0; - pData->bDeltaimmediate = MNG_FALSE; - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -void cleanup_errors (mng_datap pData) -{ - pData->iErrorcode = MNG_NOERROR; - pData->iSeverity = 0; - pData->iErrorx1 = 0; - pData->iErrorx2 = 0; - pData->zErrortext = MNG_NULL; - - return; -} - -/* ************************************************************************** */ -/* * * */ -/* * Versioning control * */ -/* * * */ -/* ************************************************************************** */ - -mng_pchar MNG_DECL mng_version_text (void) -{ - return MNG_VERSION_TEXT; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_so (void) -{ - return MNG_VERSION_SO; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_dll (void) -{ - return MNG_VERSION_DLL; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_major (void) -{ - return MNG_VERSION_MAJOR; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_minor (void) -{ - return MNG_VERSION_MINOR; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_version_release (void) -{ - return MNG_VERSION_RELEASE; -} - -/* ************************************************************************** */ -/* * * */ -/* * HLAPI routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata, - mng_memalloc fMemalloc, - mng_memfree fMemfree, - mng_traceproc fTraceproc) -{ - mng_datap pData; -#ifdef MNG_SUPPORT_DISPLAY - mng_retcode iRetcode; - mng_imagep pImage; -#endif - -#ifdef MNG_INTERNAL_MEMMNGMT /* allocate the main datastruc */ - pData = (mng_datap)calloc (1, sizeof (mng_data)); -#else - pData = (mng_datap)fMemalloc (sizeof (mng_data)); -#endif - - if (!pData) - return MNG_NULL; /* error: out of memory?? */ - /* validate the structure */ - pData->iMagic = MNG_MAGIC; - /* save userdata field */ - pData->pUserdata = pUserdata; - /* remember trace callback */ - pData->fTraceproc = fTraceproc; - -#ifdef MNG_SUPPORT_TRACE - if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_INITIALIZE)) - { - MNG_FREEX (pData, pData, sizeof (mng_data)) - return MNG_NULL; - } -#endif - /* default canvas styles are 8-bit RGB */ - pData->iCanvasstyle = MNG_CANVAS_RGB8; - pData->iBkgdstyle = MNG_CANVAS_RGB8; - - pData->iBGred = 0; /* black */ - pData->iBGgreen = 0; - pData->iBGblue = 0; - - pData->bUseBKGD = MNG_TRUE; - -#ifdef MNG_FULL_CMS - pData->bIssRGB = MNG_TRUE; - pData->hProf1 = 0; /* no profiles yet */ - pData->hProf2 = 0; - pData->hProf3 = 0; - pData->hTrans = 0; -#endif - - pData->dViewgamma = 1.0; - pData->dDisplaygamma = 2.2; - pData->dDfltimggamma = 0.45455; - /* initially remember chunks */ - pData->bStorechunks = MNG_TRUE; - /* no breaks at section-borders */ - pData->bSectionbreaks = MNG_FALSE; - /* initially cache playback info */ - pData->bCacheplayback = MNG_TRUE; - /* progressive refresh for large images */ - pData->bDoProgressive = MNG_TRUE; - /* normal animation-speed ! */ - pData->iSpeed = mng_st_normal; - /* initial image limits */ - pData->iMaxwidth = 10000; - pData->iMaxheight = 10000; - -#ifdef MNG_INTERNAL_MEMMNGMT /* internal management */ - pData->fMemalloc = MNG_NULL; - pData->fMemfree = MNG_NULL; -#else /* keep callbacks */ - pData->fMemalloc = fMemalloc; - pData->fMemfree = fMemfree; -#endif - /* no value (yet) */ - pData->fOpenstream = MNG_NULL; - pData->fClosestream = MNG_NULL; - pData->fReaddata = MNG_NULL; - pData->fWritedata = MNG_NULL; - pData->fErrorproc = MNG_NULL; - pData->fProcessheader = MNG_NULL; - pData->fProcesstext = MNG_NULL; - pData->fProcesssave = MNG_NULL; - pData->fProcessseek = MNG_NULL; - pData->fProcessneed = MNG_NULL; - pData->fProcessmend = MNG_NULL; - pData->fProcessunknown = MNG_NULL; - pData->fProcessterm = MNG_NULL; - pData->fGetcanvasline = MNG_NULL; - pData->fGetbkgdline = MNG_NULL; - pData->fGetalphaline = MNG_NULL; - pData->fRefresh = MNG_NULL; - pData->fGettickcount = MNG_NULL; - pData->fSettimer = MNG_NULL; - pData->fProcessgamma = MNG_NULL; - pData->fProcesschroma = MNG_NULL; - pData->fProcesssrgb = MNG_NULL; - pData->fProcessiccp = MNG_NULL; - pData->fProcessarow = MNG_NULL; - -#if defined(MNG_SUPPORT_DISPLAY) && (defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS)) - pData->dLastgamma = 0; /* lookup table needs first-time calc */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY /* create object 0 */ - iRetcode = create_imageobject (pData, 0, MNG_TRUE, MNG_TRUE, MNG_TRUE, - 0, 0, 0, 0, 0, 0, 0, 0, 0, MNG_FALSE, - 0, 0, 0, 0, &pImage); - - if (iRetcode) /* on error drop out */ - { - MNG_FREEX (pData, pData, sizeof (mng_data)) - return MNG_NULL; - } - - pData->pObjzero = pImage; -#endif - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_LCMS) - mnglcms_initlibrary (); /* init lcms particulairs */ -#endif - -#ifdef MNG_SUPPORT_READ - pData->bSuspensionmode = MNG_FALSE; - pData->iSuspendbufsize = 0; - pData->pSuspendbuf = MNG_NULL; - pData->pSuspendbufnext = MNG_NULL; - pData->iSuspendbufleft = 0; - pData->iChunklen = 0; - pData->pReadbufnext = MNG_NULL; -#endif - -#ifdef MNG_INCLUDE_ZLIB - mngzlib_initialize (pData); /* initialize zlib structures and such */ - /* default zlib compression parameters */ - pData->iZlevel = MNG_ZLIB_LEVEL; - pData->iZmethod = MNG_ZLIB_METHOD; - pData->iZwindowbits = MNG_ZLIB_WINDOWBITS; - pData->iZmemlevel = MNG_ZLIB_MEMLEVEL; - pData->iZstrategy = MNG_ZLIB_STRATEGY; - /* default maximum IDAT data size */ - pData->iMaxIDAT = MNG_MAX_IDAT_SIZE; -#endif - -#ifdef MNG_INCLUDE_JNG /* default IJG compression parameters */ - pData->eJPEGdctmethod = MNG_JPEG_DCT; - pData->iJPEGquality = MNG_JPEG_QUALITY; - pData->iJPEGsmoothing = MNG_JPEG_SMOOTHING; - pData->bJPEGcompressprogr = MNG_JPEG_PROGRESSIVE; - pData->bJPEGcompressopt = MNG_JPEG_OPTIMIZED; - /* default maximum JDAT data size */ - pData->iMaxJDAT = MNG_MAX_JDAT_SIZE; -#endif - - mng_reset ((mng_handle)pData); - -#ifdef MNG_SUPPORT_TRACE - if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_END)) - { - MNG_FREEX (pData, pData, sizeof (mng_data)) - return MNG_NULL; - } -#endif - - return (mng_handle)pData; /* if we get here, we're in business */ -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_reset (mng_handle hHandle) -{ - mng_datap pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_RESET, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)(hHandle)); /* address main structure */ - -#ifdef MNG_SUPPORT_DISPLAY - mng_drop_savedata (pData); /* cleanup saved-data from SAVE/SEEK */ -#endif - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS) - mng_clear_cms (pData); /* cleanup left-over cms stuff if any */ -#endif - -#ifdef MNG_INCLUDE_JNG - mngjpeg_cleanup (pData); /* cleanup jpeg stuff */ -#endif - -#ifdef MNG_INCLUDE_ZLIB - if (pData->bInflating) /* if we've been inflating */ - { -#ifdef MNG_INCLUDE_DISPLAY_PROCS - cleanup_rowproc (pData); /* cleanup row-processing, */ -#endif - mngzlib_inflatefree (pData); /* cleanup inflate! */ - } -#endif /* MNG_INCLUDE_ZLIB */ - -#ifdef MNG_SUPPORT_READ - if ((pData->bReading) && (!pData->bEOF)) - process_eof (pData); /* cleanup app streaming */ - /* cleanup default read buffers */ - MNG_FREE (pData, pData->pReadbuf, pData->iReadbufsize) - MNG_FREE (pData, pData->pLargebuf, pData->iLargebufsize) - MNG_FREE (pData, pData->pSuspendbuf, pData->iSuspendbufsize) -#endif - -#ifdef MNG_SUPPORT_WRITE /* cleanup default write buffer */ - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize) -#endif - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - mng_drop_chunks (pData); /* drop stored chunks (if any) */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY - mng_drop_objects (pData, MNG_TRUE); /* drop stored objects (if any) */ - - if (pData->iGlobalProfilesize) /* drop global profile (if any) */ - MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) -#endif - - pData->eSigtype = mng_it_unknown; - pData->eImagetype = mng_it_unknown; - pData->iWidth = 0; /* these are unknown yet */ - pData->iHeight = 0; - pData->iTicks = 0; - pData->iLayercount = 0; - pData->iFramecount = 0; - pData->iPlaytime = 0; - pData->iSimplicity = 0; - pData->iAlphadepth = 16; /* assume the worst! */ - - pData->iImagelevel = 0; /* no image encountered */ - - pData->iMagnify = 0; /* 1-to-1 display */ - pData->iOffsetx = 0; /* no offsets */ - pData->iOffsety = 0; - pData->iCanvaswidth = 0; /* let the app decide during processheader */ - pData->iCanvasheight = 0; - /* so far, so good */ - pData->iErrorcode = MNG_NOERROR; - pData->iSeverity = 0; - pData->iErrorx1 = 0; - pData->iErrorx2 = 0; - pData->zErrortext = MNG_NULL; - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - /* let's assume the best scenario */ - pData->bPreDraft48 = MNG_FALSE; - /* the unknown chunk */ - pData->iChunkname = MNG_UINT_HUH; - pData->iChunkseq = 0; - pData->pFirstchunk = MNG_NULL; - pData->pLastchunk = MNG_NULL; - /* nothing processed yet */ - pData->bHasheader = MNG_FALSE; - pData->bHasMHDR = MNG_FALSE; - pData->bHasIHDR = MNG_FALSE; - pData->bHasBASI = MNG_FALSE; - pData->bHasDHDR = MNG_FALSE; -#ifdef MNG_INCLUDE_JNG - pData->bHasJHDR = MNG_FALSE; - pData->bHasJSEP = MNG_FALSE; - pData->bHasJDAA = MNG_FALSE; - pData->bHasJDAT = MNG_FALSE; -#endif - pData->bHasPLTE = MNG_FALSE; - pData->bHasTRNS = MNG_FALSE; - pData->bHasGAMA = MNG_FALSE; - pData->bHasCHRM = MNG_FALSE; - pData->bHasSRGB = MNG_FALSE; - pData->bHasICCP = MNG_FALSE; - pData->bHasBKGD = MNG_FALSE; - pData->bHasIDAT = MNG_FALSE; - - pData->bHasSAVE = MNG_FALSE; - pData->bHasBACK = MNG_FALSE; - pData->bHasFRAM = MNG_FALSE; - pData->bHasTERM = MNG_FALSE; - pData->bHasLOOP = MNG_FALSE; - /* there's no global stuff yet either */ - pData->bHasglobalPLTE = MNG_FALSE; - pData->bHasglobalTRNS = MNG_FALSE; - pData->bHasglobalGAMA = MNG_FALSE; - pData->bHasglobalCHRM = MNG_FALSE; - pData->bHasglobalSRGB = MNG_FALSE; - pData->bHasglobalICCP = MNG_FALSE; - - pData->iDatawidth = 0; /* no IHDR/BASI/DHDR done yet */ - pData->iDataheight = 0; - pData->iBitdepth = 0; - pData->iColortype = 0; - pData->iCompression = 0; - pData->iFilter = 0; - pData->iInterlace = 0; - -#ifdef MNG_INCLUDE_JNG - pData->iJHDRcolortype = 0; /* no JHDR data */ - pData->iJHDRimgbitdepth = 0; - pData->iJHDRimgcompression = 0; - pData->iJHDRimginterlace = 0; - pData->iJHDRalphabitdepth = 0; - pData->iJHDRalphacompression = 0; - pData->iJHDRalphafilter = 0; - pData->iJHDRalphainterlace = 0; -#endif - -#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */ - -#ifdef MNG_SUPPORT_READ /* no reading done */ - pData->bReading = MNG_FALSE; - pData->bHavesig = MNG_FALSE; - pData->bEOF = MNG_FALSE; - pData->iReadbufsize = 0; - pData->pReadbuf = MNG_NULL; - - pData->iLargebufsize = 0; - pData->pLargebuf = MNG_NULL; - - pData->iSuspendtime = 0; - pData->bSuspended = MNG_FALSE; - pData->iSuspendpoint = 0; - - pData->pSuspendbufnext = pData->pSuspendbuf; - pData->iSuspendbufleft = 0; -#endif /* MNG_SUPPORT_READ */ - -#ifdef MNG_SUPPORT_WRITE /* no creating/writing done */ - pData->bCreating = MNG_FALSE; - pData->bWriting = MNG_FALSE; - pData->iFirstchunkadded = 0; - pData->iWritebufsize = 0; - pData->pWritebuf = MNG_NULL; -#endif /* MNG_SUPPORT_WRITE */ - -#ifdef MNG_SUPPORT_DISPLAY /* done nuttin' yet */ - pData->bDisplaying = MNG_FALSE; - pData->iFrameseq = 0; - pData->iLayerseq = 0; - pData->iFrametime = 0; - - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - - pData->bRestorebkgd = MNG_FALSE; - - pData->iRuntime = 0; - pData->iSynctime = 0; - pData->iStarttime = 0; - pData->iEndtime = 0; - pData->bRunning = MNG_FALSE; - pData->bTimerset = MNG_FALSE; - pData->iBreakpoint = 0; - pData->bSectionwait = MNG_FALSE; - pData->bFreezing = MNG_FALSE; - pData->bResetting = MNG_FALSE; - pData->bNeedrefresh = MNG_FALSE; - /* these don't exist yet */ - pData->pCurrentobj = MNG_NULL; - pData->pCurraniobj = MNG_NULL; - pData->pTermaniobj = MNG_NULL; - pData->pLastclone = MNG_NULL; - pData->pStoreobj = MNG_NULL; - pData->pStorebuf = MNG_NULL; - pData->pRetrieveobj = MNG_NULL; - /* no saved data ! */ - pData->pSavedata = MNG_NULL; - /* TODO: remove in 1.0.0 !!! */ - pData->bEMNGMAhack = MNG_FALSE; - - pData->iUpdateleft = 0; /* no region updated yet */ - pData->iUpdateright = 0; - pData->iUpdatetop = 0; - pData->iUpdatebottom = 0; - - pData->iPass = -1; /* interlacing stuff and temp buffers */ - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = 0; - pData->iSamplemul = 0; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = 0; - pData->iRowmax = 0; - pData->iFilterofs = 0; - pData->iPixelofs = 1; - pData->iLevel0 = 0; - pData->iLevel1 = 0; - pData->iLevel2 = 0; - pData->iLevel3 = 0; - pData->pWorkrow = MNG_NULL; - pData->pPrevrow = MNG_NULL; - pData->pRGBArow = 0; - pData->bIsRGBA16 = MNG_TRUE; - pData->bIsOpaque = MNG_TRUE; - pData->iFilterbpp = 1; - - pData->iSourcel = 0; /* always initialized just before */ - pData->iSourcer = 0; /* compositing the next layer */ - pData->iSourcet = 0; - pData->iSourceb = 0; - pData->iDestl = 0; - pData->iDestr = 0; - pData->iDestt = 0; - pData->iDestb = 0; - /* lists are empty */ - pData->pFirstimgobj = MNG_NULL; - pData->pLastimgobj = MNG_NULL; - pData->pFirstaniobj = MNG_NULL; - pData->pLastaniobj = MNG_NULL; - /* no processing callbacks */ - pData->fDisplayrow = MNG_NULL; - pData->fRestbkgdrow = MNG_NULL; - pData->fCorrectrow = MNG_NULL; - pData->fRetrieverow = MNG_NULL; - pData->fStorerow = MNG_NULL; - pData->fProcessrow = MNG_NULL; - pData->fDifferrow = MNG_NULL; - pData->fInitrowproc = MNG_NULL; - - pData->iPLTEcount = 0; /* no PLTE data */ - - pData->iDEFIobjectid = 0; /* no DEFI data */ - pData->bDEFIhasdonotshow = MNG_FALSE; - pData->iDEFIdonotshow = 0; - pData->bDEFIhasconcrete = MNG_FALSE; - pData->iDEFIconcrete = 0; - pData->bDEFIhasloca = MNG_FALSE; - pData->iDEFIlocax = 0; - pData->iDEFIlocay = 0; - pData->bDEFIhasclip = MNG_FALSE; - pData->iDEFIclipl = 0; - pData->iDEFIclipr = 0; - pData->iDEFIclipt = 0; - pData->iDEFIclipb = 0; - - pData->iBACKred = 0; /* no BACK data */ - pData->iBACKgreen = 0; - pData->iBACKblue = 0; - pData->iBACKmandatory = 0; - pData->iBACKimageid = 0; - pData->iBACKtile = 0; - - pData->iFRAMmode = 1; /* default global FRAM variables */ - pData->iFRAMdelay = 1; - pData->iFRAMtimeout = 0x7fffffffl; - pData->bFRAMclipping = MNG_FALSE; - pData->iFRAMclipl = 0; - pData->iFRAMclipr = 0; - pData->iFRAMclipt = 0; - pData->iFRAMclipb = 0; - - pData->iFramemode = 1; /* again for the current frame */ - pData->iFramedelay = 1; - pData->iFrametimeout = 0x7fffffffl; - pData->bFrameclipping = MNG_FALSE; - pData->iFrameclipl = 0; - pData->iFrameclipr = 0; - pData->iFrameclipt = 0; - pData->iFrameclipb = 0; - - pData->iNextdelay = 1; - - pData->iSHOWmode = 0; /* no SHOW data */ - pData->iSHOWfromid = 0; - pData->iSHOWtoid = 0; - pData->iSHOWnextid = 0; - pData->iSHOWskip = 0; - - pData->iGlobalPLTEcount = 0; /* no global PLTE data */ - - pData->iGlobalTRNSrawlen = 0; /* no global tRNS data */ - - pData->iGlobalGamma = 0; /* no global gAMA data */ - - pData->iGlobalWhitepointx = 0; /* no global cHRM data */ - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; - - pData->iGlobalRendintent = 0; /* no global sRGB data */ - - pData->iGlobalProfilesize = 0; /* no global iCCP data */ - pData->pGlobalProfile = MNG_NULL; - - pData->iGlobalBKGDred = 0; /* no global bKGD data */ - pData->iGlobalBKGDgreen = 0; - pData->iGlobalBKGDblue = 0; - /* no delta-image */ - pData->pDeltaImage = MNG_NULL; - pData->iDeltaImagetype = 0; - pData->iDeltatype = 0; - pData->iDeltaBlockwidth = 0; - pData->iDeltaBlockheight = 0; - pData->iDeltaBlockx = 0; - pData->iDeltaBlocky = 0; - pData->bDeltaimmediate = MNG_FALSE; -#endif - -#ifdef MNG_INCLUDE_ZLIB - pData->bInflating = 0; /* no inflating or deflating */ - pData->bDeflating = 0; /* going on at the moment */ -#endif - -#ifdef MNG_SUPPORT_DISPLAY /* reset object 0 */ - mng_reset_objzero (pData); -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_RESET, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_cleanup (mng_handle* hHandle) -{ - mng_datap pData; /* local vars */ -#ifndef MNG_INTERNAL_MEMMNGMT - mng_memfree fFree; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)*hHandle), MNG_FN_CLEANUP, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (*hHandle) /* check validity handle */ - pData = ((mng_datap)(*hHandle)); /* and address main structure */ - - mng_reset (*hHandle); /* do an implicit reset to cleanup most stuff */ - -#ifdef MNG_SUPPORT_DISPLAY /* drop object 0 */ - free_imageobject (pData, (mng_imagep)pData->pObjzero); -#endif - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_LCMS) - if (pData->hProf2) /* output profile defined ? */ - mnglcms_freeprofile (pData->hProf2); - - if (pData->hProf3) /* sRGB profile defined ? */ - mnglcms_freeprofile (pData->hProf3); -#endif /* MNG_SUPPORT_DISPLAY && MNG_INCLUDE_LCMS */ - -#ifdef MNG_INCLUDE_ZLIB - mngzlib_cleanup (pData); /* cleanup zlib stuff */ -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)*hHandle), MNG_FN_CLEANUP, MNG_LC_CLEANUP) -#endif - - pData->iMagic = 0; /* invalidate the actual memory */ - -#ifdef MNG_INTERNAL_MEMMNGMT - free ((void *)*hHandle); /* cleanup the data-structure */ -#else - fFree = ((mng_datap)*hHandle)->fMemfree; - fFree ((mng_ptr)*hHandle, sizeof (mng_data)); -#endif - - *hHandle = 0; /* wipe pointer to inhibit future use */ - - return MNG_NOERROR; /* and we're done */ -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_read (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - - MNG_VALIDCB (hHandle, fOpenstream) - MNG_VALIDCB (hHandle, fClosestream) - MNG_VALIDCB (hHandle, fReaddata) - -#ifdef MNG_SUPPORT_DISPLAY /* valid at this point ? */ - if ((pData->bReading) || (pData->bDisplaying)) -#else - if (pData->bReading) -#endif - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - -#ifdef MNG_SUPPORT_WRITE - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bReading = MNG_TRUE; /* read only! */ - - if (!pData->fOpenstream (hHandle)) /* open it and start reading */ - iRetcode = MNG_APPIOERROR; - else - iRetcode = read_graphic (pData); - - if (pData->bEOF) /* already at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - -#ifdef MNG_SUPPORT_DISPLAY - mng_reset_rundata (pData); /* reset rundata */ -#endif - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ, MNG_LC_END) -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_read_resume (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_RESUME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - /* can we expect this call ? */ - if ((!pData->bReading) || (!pData->bSuspended)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bSuspended = MNG_FALSE; /* reset the flag */ - -#ifdef MNG_SUPPORT_DISPLAY /* re-synchronize ? */ - if ((pData->bDisplaying) && (pData->bRunning)) - pData->iSynctime = pData->iSynctime - pData->iSuspendtime + - pData->fGettickcount (hHandle); -#endif - - iRetcode = read_graphic (pData); /* continue reading now */ - - if (pData->bEOF) /* at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - -#ifdef MNG_SUPPORT_DISPLAY - mng_reset_rundata (pData); /* reset rundata */ -#endif - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_RESUME, MNG_LC_END) -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_write (mng_handle hHandle) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_WRITE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - - MNG_VALIDCB (hHandle, fOpenstream) - MNG_VALIDCB (hHandle, fClosestream) - MNG_VALIDCB (hHandle, fWritedata) - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) /* valid at this point ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - - if (pData->bCreating) /* can't write while it's still being made! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - iRetcode = write_graphic (pData); /* do the write */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_WRITE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_retcode MNG_DECL mng_create (mng_handle hHandle) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_CREATE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) /* valid at this point ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - iRetcode = mng_reset (hHandle); /* clear any previous stuff */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pData->bCreating = MNG_TRUE; /* indicate we're creating a new file */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_CREATE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_WRITE */ - -/* ************************************************************************** */ - -#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_READ) -mng_retcode MNG_DECL mng_readdisplay (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READDISPLAY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - - MNG_VALIDCB (hHandle, fReaddata) - MNG_VALIDCB (hHandle, fGetcanvasline) - MNG_VALIDCB (hHandle, fRefresh) - MNG_VALIDCB (hHandle, fGettickcount) - MNG_VALIDCB (hHandle, fSettimer) - /* valid at this point ? */ - if ((pData->bReading) || (pData->bDisplaying)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - -#ifdef MNG_SUPPORT_WRITE - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bReading = MNG_TRUE; /* read & display! */ - pData->bDisplaying = MNG_TRUE; - pData->bRunning = MNG_TRUE; - pData->iFrameseq = 0; - pData->iLayerseq = 0; - pData->iFrametime = 0; - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - pData->iRuntime = 0; - pData->iSynctime = pData->fGettickcount (hHandle); - pData->iSuspendtime = 0; - pData->iStarttime = pData->iSynctime; - pData->iEndtime = 0; - - if (!pData->fOpenstream (hHandle)) /* open it and start reading */ - iRetcode = MNG_APPIOERROR; - else - iRetcode = read_graphic (pData); - - if (pData->bEOF) /* already at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - drop_invalid_objects (pData); /* drop invalidly stored objects */ - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - else - if (pData->bTimerset) /* indicate timer break ? */ - iRetcode = MNG_NEEDTIMERWAIT; - else - if (pData->bSectionwait) /* indicate section break ? */ - iRetcode = MNG_NEEDSECTIONWAIT; - else - pData->bRunning = MNG_FALSE; /* no breaks = end of run */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_READDISPLAY, MNG_LC_END) -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_DISPLAY && MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - -#ifndef MNG_INTERNAL_MEMMNGMT - MNG_VALIDCB (hHandle, fMemalloc) - MNG_VALIDCB (hHandle, fMemfree) -#endif - - MNG_VALIDCB (hHandle, fGetcanvasline) - MNG_VALIDCB (hHandle, fRefresh) - MNG_VALIDCB (hHandle, fGettickcount) - MNG_VALIDCB (hHandle, fSettimer) - - if (pData->bDisplaying) /* valid at this point ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - -#ifdef MNG_SUPPORT_WRITE - if ((pData->bWriting) || (pData->bCreating)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) -#endif - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->bDisplaying = MNG_TRUE; /* display! */ - pData->bRunning = MNG_TRUE; - pData->iFrameseq = 0; - pData->iLayerseq = 0; - pData->iFrametime = 0; - pData->iRequestframe = 0; - pData->iRequestlayer = 0; - pData->iRequesttime = 0; - pData->bSearching = MNG_FALSE; - pData->iRuntime = 0; - pData->iSynctime = pData->fGettickcount (hHandle); -#ifdef MNG_SUPPORT_READ - pData->iSuspendtime = 0; -#endif - pData->iStarttime = pData->iSynctime; - pData->iEndtime = 0; - pData->pCurraniobj = pData->pFirstaniobj; - - iRetcode = process_display (pData); /* go do it */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bTimerset) /* indicate timer break ? */ - iRetcode = MNG_NEEDTIMERWAIT; - else - pData->bRunning = MNG_FALSE; /* no breaks = end of run */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY, MNG_LC_END) -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_resume (mng_handle hHandle) -{ - mng_datap pData; /* local vars */ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESUME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (!pData->bDisplaying) /* can we expect this call ? */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->bRunning) /* was it running ? */ - { /* are we expecting this call ? */ - if ((pData->bTimerset) || (pData->bSuspended) || (pData->bSectionwait)) - { - pData->bTimerset = MNG_FALSE; /* reset the flags */ - pData->bSectionwait = MNG_FALSE; - -#ifdef MNG_SUPPORT_READ - if (pData->bReading) /* set during read&display ? */ - { - if (pData->bSuspended) /* calculate proper synchronization */ - pData->iSynctime = pData->iSynctime - pData->iSuspendtime + - pData->fGettickcount (hHandle); - else - pData->iSynctime = pData->fGettickcount (hHandle); - - pData->bSuspended = MNG_FALSE; /* now reset this flag */ - /* and continue reading */ - iRetcode = read_graphic (pData); - - if (pData->bEOF) /* already at EOF ? */ - { - pData->bReading = MNG_FALSE; /* then we're no longer reading */ - /* drop invalidly stored objects */ - drop_invalid_objects (pData); - } - } - else -#endif /* MNG_SUPPORT_READ */ - { /* synchronize timing */ - pData->iSynctime = pData->fGettickcount (hHandle); - /* resume display processing */ - iRetcode = process_display (pData); - } - } - else - { - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - } - } - else - { /* synchronize timing */ - pData->iSynctime = pData->fGettickcount (hHandle); - pData->bRunning = MNG_TRUE; /* it's restarted again ! */ - /* resume display processing */ - iRetcode = process_display (pData); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->bSuspended) /* read suspension ? */ - { - iRetcode = MNG_NEEDMOREDATA; - pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); - } - else - if (pData->bTimerset) /* indicate timer break ? */ - iRetcode = MNG_NEEDTIMERWAIT; - else - if (pData->bSectionwait) /* indicate section break ? */ - iRetcode = MNG_NEEDSECTIONWAIT; - else - { /* no breaks = end of run */ - pData->bRunning = MNG_FALSE; - - if (pData->bFreezing) /* trying to freeze ? */ - { /* then we're there ! */ - pData->bFreezing = MNG_FALSE; - } - - if (pData->bResetting) /* trying to reset as well ? */ - { /* full stop!!! */ - pData->bDisplaying = MNG_FALSE; - - iRetcode = mng_reset_rundata (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESUME, MNG_LC_END) -#endif - - return iRetcode; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_freeze (mng_handle hHandle) -{ - mng_datap pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_FREEZE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bReading)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->bRunning) /* is it running ? */ - { - mng_retcode iRetcode; - - pData->bFreezing = MNG_TRUE; /* indicate we need to freeze */ - /* continue "normal" processing */ - iRetcode = mng_display_resume (hHandle); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_FREEZE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_reset (mng_handle hHandle) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESET, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bReading)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - cleanup_errors (pData); /* cleanup previous errors */ - - if (pData->bRunning) /* is it running ? */ - { - pData->bFreezing = MNG_TRUE; /* indicate we need to freeze */ - pData->bResetting = MNG_TRUE; /* indicate we're about to reset too */ - /* continue normal processing ? */ - iRetcode = mng_display_resume (hHandle); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - else - { /* full stop!!! */ - pData->bDisplaying = MNG_FALSE; - - iRetcode = mng_reset_rundata (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESET, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_goframe (mng_handle hHandle, - mng_uint32 iFramenr) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOFRAME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->eImagetype != mng_it_mng) /* is it an animation ? */ - MNG_ERROR (pData, MNG_NOTANANIMATION); - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bRunning)) - MNG_ERROR ((mng_datap)hHandle, MNG_FUNCTIONINVALID) - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (iFramenr > pData->iFramecount) /* is the parameter within bounds ? */ - MNG_ERROR (pData, MNG_FRAMENRTOOHIGH); - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->iRequestframe = iFramenr; /* go find the requested frame then */ - iRetcode = process_display (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOFRAME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_golayer (mng_handle hHandle, - mng_uint32 iLayernr) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOLAYER, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->eImagetype != mng_it_mng) /* is it an animation ? */ - MNG_ERROR (pData, MNG_NOTANANIMATION) - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bRunning)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (iLayernr > pData->iLayercount) /* is the parameter within bounds ? */ - MNG_ERROR (pData, MNG_LAYERNRTOOHIGH) - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->iRequestlayer = iLayernr; /* go find the requested layer then */ - iRetcode = process_display (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOLAYER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_display_gotime (mng_handle hHandle, - mng_uint32 iPlaytime) -{ - mng_datap pData; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOTIME, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - if (pData->eImagetype != mng_it_mng) /* is it an animation ? */ - MNG_ERROR (pData, MNG_NOTANANIMATION) - /* can we expect this call ? */ - if ((!pData->bDisplaying) || (pData->bRunning)) - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (!pData->bCacheplayback) /* must store playback info to work!! */ - MNG_ERROR (pData, MNG_FUNCTIONINVALID) - - if (iPlaytime > pData->iPlaytime) /* is the parameter within bounds ? */ - MNG_ERROR (pData, MNG_PLAYTIMETOOHIGH) - - cleanup_errors (pData); /* cleanup previous errors */ - - pData->iRequesttime = iPlaytime; /* go find the requested playtime then */ - iRetcode = process_display (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOTIME, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_getlasterror (mng_handle hHandle, - mng_int8* iSeverity, - mng_chunkid* iChunkname, - mng_uint32* iChunkseq, - mng_int32* iExtra1, - mng_int32* iExtra2, - mng_pchar* zErrortext) -{ - mng_datap pData; /* local vars */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETLASTERROR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) /* check validity handle */ - pData = ((mng_datap)hHandle); /* and make it addressable */ - - *iSeverity = pData->iSeverity; /* return the appropriate fields */ - -#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE) - *iChunkname = pData->iChunkname; - *iChunkseq = pData->iChunkseq; -#else - *iChunkname = MNG_UINT_HUH; - *iChunkseq = 0; -#endif - - *iExtra1 = pData->iErrorx1; - *iExtra2 = pData->iErrorx2; - *zErrortext = pData->zErrortext; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETLASTERROR, MNG_LC_END) -#endif - - return pData->iErrorcode; /* and the errorcode */ -} - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_jpeg.c b/freeimage241/Source/LibMNG/libmng_jpeg.c deleted file mode 100644 index d128adc..0000000 --- a/freeimage241/Source/LibMNG/libmng_jpeg.c +++ /dev/null @@ -1,1034 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_jpeg.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : JPEG library interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the JPEG library interface * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/22/2000 - G.Juyn * */ -/* * - implemented all the JNG routines * */ -/* * * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - added tracing of JPEG calls * */ -/* * 0.5.3 - 06/24/2000 - G.Juyn * */ -/* * - fixed inclusion of IJG read/write code * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed some 64-bit warnings * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* * 1.0.1 - 04/19/2001 - G.Juyn * */ -/* * - added export of JPEG functions for DLL * */ -/* * 1.0.1 - 04/22/2001 - G.Juyn * */ -/* * - fixed memory-leaks (Thanks Gregg!) * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_pixels.h" -#include "libmng_jpeg.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ -/* * * */ -/* * Local IJG callback routines (source-manager, error-manager and such) * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_IJG6B - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -void MNG_DECL mng_init_source (j_decompress_ptr cinfo) -{ - return; /* nothing needed */ -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -boolean MNG_DECL mng_fill_input_buffer (j_decompress_ptr cinfo) -{ - return FALSE; /* force IJG routine to return to caller */ -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -void MNG_DECL mng_skip_input_data (j_decompress_ptr cinfo, long num_bytes) -{ - if (num_bytes > 0) /* ignore fony calls */ - { /* address my generic structure */ - mng_datap pData = (mng_datap)cinfo->client_data; - /* address source manager */ - mngjpeg_sourcep pSrc = pData->pJPEGdinfo->src; - /* problem scenario ? */ - if (pSrc->bytes_in_buffer < (size_t)num_bytes) - { /* tell the boss we need to skip some data! */ - pData->iJPEGtoskip = (mng_uint32)((size_t)num_bytes - pSrc->bytes_in_buffer); - - pSrc->bytes_in_buffer = 0; /* let the JPEG lib suspend */ - pSrc->next_input_byte = MNG_NULL; - } - else - { /* simply advance in the buffer */ - pSrc->bytes_in_buffer -= num_bytes; - pSrc->next_input_byte += num_bytes; - } - } - - return; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -void MNG_DECL mng_skip_input_data2 (j_decompress_ptr cinfo, long num_bytes) -{ - if (num_bytes > 0) /* ignore fony calls */ - { /* address my generic structure */ - mng_datap pData = (mng_datap)cinfo->client_data; - /* address source manager */ - mngjpeg_sourcep pSrc = pData->pJPEGdinfo2->src; - /* problem scenario ? */ - if (pSrc->bytes_in_buffer < (size_t)num_bytes) - { /* tell the boss we need to skip some data! */ - pData->iJPEGtoskip2 = (mng_uint32)((size_t)num_bytes - pSrc->bytes_in_buffer); - - pSrc->bytes_in_buffer = 0; /* let the JPEG lib suspend */ - pSrc->next_input_byte = MNG_NULL; - } - else - { /* simply advance in the buffer */ - pSrc->bytes_in_buffer -= num_bytes; - pSrc->next_input_byte += num_bytes; - } - } - - return; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -void MNG_DECL mng_term_source (j_decompress_ptr cinfo) -{ - return; /* nothing needed */ -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_USE_SETJMP -void MNG_DECL mng_error_exit (j_common_ptr cinfo) -{ /* address my generic structure */ - mng_datap pData = (mng_datap)cinfo->client_data; - -#ifdef MNG_ERROR_TELLTALE /* fill the message text ??? */ - (*cinfo->err->output_message) (cinfo); -#endif - /* return to the point of no return... */ - longjmp (pData->sErrorbuf, cinfo->err->msg_code); -} -#endif /* MNG_USE_SETJMP */ - -/* ************************************************************************** */ - -#ifdef MNG_USE_SETJMP -void MNG_DECL mng_output_message (j_common_ptr cinfo) -{ - return; /* just do nothing ! */ -} -#endif /* MNG_USE_SETJMP */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_IJG6B */ - -/* ************************************************************************** */ -/* * * */ -/* * Global JPEG routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode mngjpeg_initialize (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_INITIALIZE, MNG_LC_START) -#endif - /* allocate space for JPEG structures if necessary */ -#ifdef MNG_INCLUDE_JNG_READ - if (pData->pJPEGderr == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGderr, sizeof (mngjpeg_error )) - if (pData->pJPEGdsrc == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGdsrc, sizeof (mngjpeg_source)) - if (pData->pJPEGdinfo == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGdinfo, sizeof (mngjpeg_decomp)) - /* enable reverse addressing */ - pData->pJPEGdinfo->client_data = pData; - - if (pData->pJPEGderr2 == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGderr2, sizeof (mngjpeg_error )) - if (pData->pJPEGdsrc2 == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGdsrc2, sizeof (mngjpeg_source)) - if (pData->pJPEGdinfo2 == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGdinfo2, sizeof (mngjpeg_decomp)) - /* enable reverse addressing */ - pData->pJPEGdinfo2->client_data = pData; -#endif - -#ifdef MNG_INCLUDE_JNG_WRITE - if (pData->pJPEGcerr == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGcerr, sizeof (mngjpeg_error )) - if (pData->pJPEGcinfo == MNG_NULL) - MNG_ALLOC (pData, pData->pJPEGcinfo, sizeof (mngjpeg_comp )) - /* enable reverse addressing */ - pData->pJPEGcinfo->client_data = pData; -#endif - - if (pData->pJPEGbuf == MNG_NULL) /* initialize temporary buffers */ - { - pData->iJPEGbufmax = MNG_JPEG_MAXBUF; - MNG_ALLOC (pData, pData->pJPEGbuf, pData->iJPEGbufmax) - } - - if (pData->pJPEGbuf2 == MNG_NULL) - { - pData->iJPEGbufmax2 = MNG_JPEG_MAXBUF; - MNG_ALLOC (pData, pData->pJPEGbuf2, pData->iJPEGbufmax2) - } - - pData->pJPEGcurrent = pData->pJPEGbuf; - pData->iJPEGbufremain = 0; - pData->pJPEGrow = MNG_NULL; - pData->iJPEGrowlen = 0; - pData->iJPEGtoskip = 0; - - pData->pJPEGcurrent2 = pData->pJPEGbuf2; - pData->iJPEGbufremain2 = 0; - pData->pJPEGrow2 = MNG_NULL; - pData->iJPEGrowlen2 = 0; - pData->iJPEGtoskip2 = 0; - /* not doing anything yet ! */ - pData->bJPEGcompress = MNG_FALSE; - - pData->bJPEGdecompress = MNG_FALSE; - pData->bJPEGhasheader = MNG_FALSE; - pData->bJPEGdecostarted = MNG_FALSE; - pData->bJPEGscanstarted = MNG_FALSE; - - pData->bJPEGdecompress2 = MNG_FALSE; - pData->bJPEGhasheader2 = MNG_FALSE; - pData->bJPEGdecostarted2 = MNG_FALSE; - pData->bJPEGscanstarted2 = MNG_FALSE; - - pData->iJPEGrow = 0; /* zero input/output lines */ - pData->iJPEGalpharow = 0; - pData->iJPEGrgbrow = 0; - pData->iJPEGdisprow = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_INITIALIZE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mngjpeg_cleanup (mng_datap pData) -{ -#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_CLEANUP, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_IJG6B -#ifdef MNG_USE_SETJMP - iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif - -#ifdef MNG_INCLUDE_JNG_READ /* still decompressing something ? */ - if (pData->bJPEGdecompress) - jpeg_destroy_decompress (pData->pJPEGdinfo); - if (pData->bJPEGdecompress2) - jpeg_destroy_decompress (pData->pJPEGdinfo2); -#endif - -#ifdef MNG_INCLUDE_JNG_WRITE - if (pData->bJPEGcompress) /* still compressing something ? */ - jpeg_destroy_compress (pData->pJPEGcinfo); -#endif - -#endif /* MNG_INCLUDE_IJG6B */ - /* cleanup temporary buffers */ - MNG_FREE (pData, pData->pJPEGbuf2, pData->iJPEGbufmax2) - MNG_FREE (pData, pData->pJPEGbuf, pData->iJPEGbufmax) - /* cleanup space for JPEG structures */ -#ifdef MNG_INCLUDE_JNG_WRITE - MNG_FREE (pData, pData->pJPEGcinfo, sizeof (mngjpeg_comp )) - MNG_FREE (pData, pData->pJPEGcerr, sizeof (mngjpeg_error )) -#endif - -#ifdef MNG_INCLUDE_JNG_READ - MNG_FREE (pData, pData->pJPEGdinfo, sizeof (mngjpeg_decomp)) - MNG_FREE (pData, pData->pJPEGdsrc, sizeof (mngjpeg_source)) - MNG_FREE (pData, pData->pJPEGderr, sizeof (mngjpeg_error )) - MNG_FREE (pData, pData->pJPEGdinfo2, sizeof (mngjpeg_decomp)) - MNG_FREE (pData, pData->pJPEGdsrc2, sizeof (mngjpeg_source)) - MNG_FREE (pData, pData->pJPEGderr2, sizeof (mngjpeg_error )) -#endif - - MNG_FREE (pData, pData->pJPEGrow2, pData->iJPEGrowlen2) - MNG_FREE (pData, pData->pJPEGrow, pData->iJPEGrowlen) - /* whatever we were doing ... */ - /* we don't anymore ... */ - pData->bJPEGcompress = MNG_FALSE; - - pData->bJPEGdecompress = MNG_FALSE; - pData->bJPEGhasheader = MNG_FALSE; - pData->bJPEGdecostarted = MNG_FALSE; - pData->bJPEGscanstarted = MNG_FALSE; - - pData->bJPEGdecompress2 = MNG_FALSE; - pData->bJPEGhasheader2 = MNG_FALSE; - pData->bJPEGdecostarted2 = MNG_FALSE; - pData->bJPEGscanstarted2 = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_CLEANUP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * JPEG decompression routines (JDAT) * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressinit (mng_datap pData) -{ -#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_IJG6B - /* allocate and initialize a JPEG decompression object */ - pData->pJPEGdinfo->err = jpeg_std_error (pData->pJPEGderr); - -#ifdef MNG_USE_SETJMP /* setup local JPEG error-routines */ - pData->pJPEGderr->error_exit = mng_error_exit; - pData->pJPEGderr->output_message = mng_output_message; - - iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif /* MNG_USE_SETJMP */ - - /* allocate and initialize a JPEG decompression object (continued) */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_JPEG_CREATE_DECOMPRESS) -#endif - jpeg_create_decompress (pData->pJPEGdinfo); - - pData->bJPEGdecompress = MNG_TRUE; /* indicate it's initialized */ - - /* specify the source of the compressed data (eg, a file) */ - /* no, not a file; we have buffered input */ - pData->pJPEGdinfo->src = pData->pJPEGdsrc; - /* use the default handler */ - pData->pJPEGdinfo->src->resync_to_restart = jpeg_resync_to_restart; - /* setup local source routine & parms */ - pData->pJPEGdinfo->src->init_source = mng_init_source; - pData->pJPEGdinfo->src->fill_input_buffer = mng_fill_input_buffer; - pData->pJPEGdinfo->src->skip_input_data = mng_skip_input_data; - pData->pJPEGdinfo->src->term_source = mng_term_source; - pData->pJPEGdinfo->src->next_input_byte = pData->pJPEGcurrent; - pData->pJPEGdinfo->src->bytes_in_buffer = pData->iJPEGbufremain; - -#endif /* MNG_INCLUDE_IJG6B */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressdata (mng_datap pData, - mng_uint32 iRawsize, - mng_uint8p pRawdata) -{ - mng_retcode iRetcode; - mng_uint32 iRemain; - mng_uint8p pWork; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_START) -#endif - -#if defined (MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - iRetcode = setjmp (pData->sErrorbuf);/* initialize local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif - - pWork = pRawdata; - iRemain = iRawsize; - - if (pData->iJPEGtoskip) /* JPEG-lib told us to skip some more data ? */ - { - if (iRemain > pData->iJPEGtoskip) /* enough data in this buffer ? */ - { - iRemain -= pData->iJPEGtoskip; /* skip enough to access the next byte */ - pWork += pData->iJPEGtoskip; - - pData->iJPEGtoskip = 0; /* no more to skip then */ - } - else - { - pData->iJPEGtoskip -= iRemain; /* skip all data in the buffer */ - iRemain = 0; /* and indicate this accordingly */ - } - /* the skip set current-pointer to NULL ! */ - pData->pJPEGcurrent = pData->pJPEGbuf; - } - - while (iRemain) /* repeat until no more input-bytes */ - { /* need to shift anything ? */ - if ((pData->pJPEGcurrent > pData->pJPEGbuf) && - (pData->pJPEGcurrent - pData->pJPEGbuf + pData->iJPEGbufremain + iRemain > pData->iJPEGbufmax)) - { - if (pData->iJPEGbufremain > 0) /* then do so */ - MNG_COPY (pData->pJPEGbuf, pData->pJPEGcurrent, pData->iJPEGbufremain) - - pData->pJPEGcurrent = pData->pJPEGbuf; - } - /* does the remaining input fit into the buffer ? */ - if (pData->iJPEGbufremain + iRemain <= pData->iJPEGbufmax) - { /* move the lot */ - MNG_COPY ((pData->pJPEGcurrent + pData->iJPEGbufremain), pWork, iRemain) - - pData->iJPEGbufremain += iRemain;/* adjust remaining_bytes counter */ - iRemain = 0; /* and indicate there's no input left */ - } - else - { /* calculate what does fit */ - mng_uint32 iFits = pData->iJPEGbufmax - pData->iJPEGbufremain; - - if (iFits <= 0) /* no space is just bugger 'm all */ - MNG_ERROR (pData, MNG_JPEGBUFTOOSMALL) - /* move that */ - MNG_COPY ((pData->pJPEGcurrent + pData->iJPEGbufremain), pWork, iFits) - - pData->iJPEGbufremain += iFits; /* adjust remain_bytes counter */ - iRemain -= iFits; /* and the input-parms */ - pWork += iFits; - } - -#ifdef MNG_INCLUDE_IJG6B - pData->pJPEGdinfo->src->next_input_byte = pData->pJPEGcurrent; - pData->pJPEGdinfo->src->bytes_in_buffer = pData->iJPEGbufremain; - - if (!pData->bJPEGhasheader) /* haven't got the header yet ? */ - { - /* call jpeg_read_header() to obtain image info */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_READ_HEADER) -#endif - if (jpeg_read_header (pData->pJPEGdinfo, TRUE) != JPEG_SUSPENDED) - { /* indicate the header's oke */ - pData->bJPEGhasheader = MNG_TRUE; - /* let's do some sanity checks ! */ - if ((pData->pJPEGdinfo->image_width != pData->iDatawidth ) || - (pData->pJPEGdinfo->image_height != pData->iDataheight) ) - MNG_ERROR (pData, MNG_JPEGPARMSERR) - - if ( ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAY ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA) ) && - (pData->pJPEGdinfo->jpeg_color_space != JCS_GRAYSCALE ) ) - MNG_ERROR (pData, MNG_JPEGPARMSERR) - - if ( ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLOR ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) && - (pData->pJPEGdinfo->jpeg_color_space != JCS_YCbCr ) ) - MNG_ERROR (pData, MNG_JPEGPARMSERR) - /* indicate whether or not it's progressive */ - pData->bJPEGprogressive = (mng_bool)jpeg_has_multiple_scans (pData->pJPEGdinfo); - /* progressive+alpha can't display "on-the-fly"!! */ - if ((pData->bJPEGprogressive) && - ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) )) - pData->fDisplayrow = MNG_NULL; - /* allocate a row of JPEG-samples */ - if (pData->pJPEGdinfo->jpeg_color_space == JCS_YCbCr) - pData->iJPEGrowlen = pData->pJPEGdinfo->image_width * 3; - else - pData->iJPEGrowlen = pData->pJPEGdinfo->image_width; - - MNG_ALLOC (pData, pData->pJPEGrow, pData->iJPEGrowlen) - - pData->iJPEGrgbrow = 0; /* quite empty up to now */ - } - - pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte; - pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer; - } - /* decompress not started ? */ - if ((pData->bJPEGhasheader) && (!pData->bJPEGdecostarted)) - { - /* set parameters for decompression */ - - if (pData->bJPEGprogressive) /* progressive display ? */ - pData->pJPEGdinfo->buffered_image = TRUE; - - /* jpeg_start_decompress(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_START_DECOMPRESS) -#endif - if (jpeg_start_decompress (pData->pJPEGdinfo) == TRUE) - /* indicate it started */ - pData->bJPEGdecostarted = MNG_TRUE; - - pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte; - pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer; - } - /* process some scanlines ? */ - if ((pData->bJPEGhasheader) && (pData->bJPEGdecostarted) && - ((!jpeg_input_complete (pData->pJPEGdinfo)) || - (pData->pJPEGdinfo->output_scanline < pData->pJPEGdinfo->output_height))) - { - mng_int32 iLines; - - /* for (each output pass) */ - do - { /* address the row output buffer */ - JSAMPROW pRow = (JSAMPROW)pData->pJPEGrow; - - /* init new pass ? */ - if ((pData->bJPEGprogressive) && - ((!pData->bJPEGscanstarted) || - (pData->pJPEGdinfo->output_scanline >= pData->pJPEGdinfo->output_height))) - { - pData->bJPEGscanstarted = MNG_TRUE; - - /* adjust output decompression parameters if required */ - /* nop */ - - /* start a new output pass */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_START_OUTPUT) -#endif - jpeg_start_output (pData->pJPEGdinfo, pData->pJPEGdinfo->input_scan_number); - - pData->iJPEGrow = 0; /* start at row 0 in the image again */ - } - - /* while (scan lines remain to be read) */ - do - { - /* jpeg_read_scanlines(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_READ_SCANLINES) -#endif - iLines = jpeg_read_scanlines (pData->pJPEGdinfo, (JSAMPARRAY)&pRow, 1); - - pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte; - pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer; - - if (iLines > 0) /* got something ? */ - { - if (pData->fStorerow2) /* store in object ? */ - { - iRetcode = ((mng_storerow)pData->fStorerow2) (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - } - } - while ((pData->pJPEGdinfo->output_scanline < pData->pJPEGdinfo->output_height) && - (iLines > 0)); /* until end-of-image or not enough input-data */ - - /* terminate output pass */ - if ((pData->bJPEGprogressive) && - (pData->pJPEGdinfo->output_scanline >= pData->pJPEGdinfo->output_height)) - { -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_OUTPUT) -#endif - jpeg_finish_output (pData->pJPEGdinfo); - /* this scan has ended */ - pData->bJPEGscanstarted = MNG_FALSE; - } - } - while ((!jpeg_input_complete (pData->pJPEGdinfo)) && (iLines > 0)); - } - /* end of image ? */ - if ((pData->bJPEGhasheader) && (pData->bJPEGdecostarted) && - (jpeg_input_complete (pData->pJPEGdinfo)) && - (pData->pJPEGdinfo->input_scan_number == pData->pJPEGdinfo->output_scan_number)) - { - /* jpeg_finish_decompress(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_DECOMPRESS) -#endif - if (jpeg_finish_decompress (pData->pJPEGdinfo) == TRUE) - { /* indicate it's done */ - pData->bJPEGhasheader = MNG_FALSE; - pData->bJPEGdecostarted = MNG_FALSE; - pData->pJPEGcurrent = (mng_uint8p)pData->pJPEGdinfo->src->next_input_byte; - pData->iJPEGbufremain = (mng_uint32)pData->pJPEGdinfo->src->bytes_in_buffer; - /* remaining fluff is an error ! */ - if ((pData->iJPEGbufremain > 0) || (iRemain > 0)) - MNG_ERROR (pData, MNG_TOOMUCHJDAT) - } - } -#endif /* MNG_INCLUDE_IJG6B */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressfree (mng_datap pData) -{ -#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_IJG6B -#ifdef MNG_USE_SETJMP - iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif - /* free the row of JPEG-samples*/ - MNG_FREE (pData, pData->pJPEGrow, pData->iJPEGrowlen) - - /* release the JPEG decompression object */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_JPEG_DESTROY_DECOMPRESS) -#endif - jpeg_destroy_decompress (pData->pJPEGdinfo); - - pData->bJPEGdecompress = MNG_FALSE; /* indicate it's done */ - -#endif /* MNG_INCLUDE_IJG6B */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ -/* * * */ -/* * JPEG decompression routines (JDAA) * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressinit2 (mng_datap pData) -{ -#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_IJG6B - /* allocate and initialize a JPEG decompression object */ - pData->pJPEGdinfo2->err = jpeg_std_error (pData->pJPEGderr2); - -#ifdef MNG_USE_SETJMP /* setup local JPEG error-routines */ - pData->pJPEGderr2->error_exit = mng_error_exit; - pData->pJPEGderr2->output_message = mng_output_message; - - iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif /* MNG_USE_SETJMP */ - - /* allocate and initialize a JPEG decompression object (continued) */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_JPEG_CREATE_DECOMPRESS) -#endif - jpeg_create_decompress (pData->pJPEGdinfo2); - - pData->bJPEGdecompress2 = MNG_TRUE; /* indicate it's initialized */ - - /* specify the source of the compressed data (eg, a file) */ - /* no, not a file; we have buffered input */ - pData->pJPEGdinfo2->src = pData->pJPEGdsrc2; - /* use the default handler */ - pData->pJPEGdinfo2->src->resync_to_restart = jpeg_resync_to_restart; - /* setup local source routine & parms */ - pData->pJPEGdinfo2->src->init_source = mng_init_source; - pData->pJPEGdinfo2->src->fill_input_buffer = mng_fill_input_buffer; - pData->pJPEGdinfo2->src->skip_input_data = mng_skip_input_data2; - pData->pJPEGdinfo2->src->term_source = mng_term_source; - pData->pJPEGdinfo2->src->next_input_byte = pData->pJPEGcurrent2; - pData->pJPEGdinfo2->src->bytes_in_buffer = pData->iJPEGbufremain2; - -#endif /* MNG_INCLUDE_IJG6B */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSINIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressdata2 (mng_datap pData, - mng_uint32 iRawsize, - mng_uint8p pRawdata) -{ - mng_retcode iRetcode; - mng_uint32 iRemain; - mng_uint8p pWork; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_START) -#endif - -#if defined (MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - iRetcode = setjmp (pData->sErrorbuf);/* initialize local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif - - pWork = pRawdata; - iRemain = iRawsize; - - if (pData->iJPEGtoskip2) /* JPEG-lib told us to skip some more data ? */ - { - if (iRemain > pData->iJPEGtoskip2) /* enough data in this buffer ? */ - { - iRemain -= pData->iJPEGtoskip2; /* skip enough to access the next byte */ - pWork += pData->iJPEGtoskip2; - - pData->iJPEGtoskip2 = 0; /* no more to skip then */ - } - else - { - pData->iJPEGtoskip2 -= iRemain; /* skip all data in the buffer */ - iRemain = 0; /* and indicate this accordingly */ - } - /* the skip set current-pointer to NULL ! */ - pData->pJPEGcurrent2 = pData->pJPEGbuf2; - } - - while (iRemain) /* repeat until no more input-bytes */ - { /* need to shift anything ? */ - if ((pData->pJPEGcurrent2 > pData->pJPEGbuf2) && - (pData->pJPEGcurrent2 - pData->pJPEGbuf2 + pData->iJPEGbufremain2 + iRemain > pData->iJPEGbufmax2)) - { - if (pData->iJPEGbufremain2 > 0) /* then do so */ - MNG_COPY (pData->pJPEGbuf2, pData->pJPEGcurrent2, pData->iJPEGbufremain2) - - pData->pJPEGcurrent2 = pData->pJPEGbuf2; - } - /* does the remaining input fit into the buffer ? */ - if (pData->iJPEGbufremain2 + iRemain <= pData->iJPEGbufmax2) - { /* move the lot */ - MNG_COPY ((pData->pJPEGcurrent2 + pData->iJPEGbufremain2), pWork, iRemain) - /* adjust remaining_bytes counter */ - pData->iJPEGbufremain2 += iRemain; - iRemain = 0; /* and indicate there's no input left */ - } - else - { /* calculate what does fit */ - mng_uint32 iFits = pData->iJPEGbufmax2 - pData->iJPEGbufremain2; - - if (iFits <= 0) /* no space is just bugger 'm all */ - MNG_ERROR (pData, MNG_JPEGBUFTOOSMALL) - /* move that */ - MNG_COPY ((pData->pJPEGcurrent2 + pData->iJPEGbufremain2), pWork, iFits) - - pData->iJPEGbufremain2 += iFits; /* adjust remain_bytes counter */ - iRemain -= iFits; /* and the input-parms */ - pWork += iFits; - } - -#ifdef MNG_INCLUDE_IJG6B - pData->pJPEGdinfo2->src->next_input_byte = pData->pJPEGcurrent2; - pData->pJPEGdinfo2->src->bytes_in_buffer = pData->iJPEGbufremain2; - - if (!pData->bJPEGhasheader2) /* haven't got the header yet ? */ - { - /* call jpeg_read_header() to obtain image info */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_READ_HEADER) -#endif - if (jpeg_read_header (pData->pJPEGdinfo2, TRUE) != JPEG_SUSPENDED) - { /* indicate the header's oke */ - pData->bJPEGhasheader2 = MNG_TRUE; - /* let's do some sanity checks ! */ - if ((pData->pJPEGdinfo2->image_width != pData->iDatawidth ) || - (pData->pJPEGdinfo2->image_height != pData->iDataheight) ) - MNG_ERROR (pData, MNG_JPEGPARMSERR) - - if (pData->pJPEGdinfo2->jpeg_color_space != JCS_GRAYSCALE) - MNG_ERROR (pData, MNG_JPEGPARMSERR) - /* indicate whether or not it's progressive */ - pData->bJPEGprogressive2 = (mng_bool)jpeg_has_multiple_scans (pData->pJPEGdinfo2); - - if (pData->bJPEGprogressive2) /* progressive alphachannel not allowed !!! */ - MNG_ERROR (pData, MNG_JPEGPARMSERR) - /* allocate a row of JPEG-samples */ - if (pData->pJPEGdinfo2->jpeg_color_space == JCS_YCbCr) - pData->iJPEGrowlen2 = pData->pJPEGdinfo2->image_width * 3; - else - pData->iJPEGrowlen2 = pData->pJPEGdinfo2->image_width; - - MNG_ALLOC (pData, pData->pJPEGrow2, pData->iJPEGrowlen2) - - pData->iJPEGalpharow = 0; /* quite empty up to now */ - } - - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - } - /* decompress not started ? */ - if ((pData->bJPEGhasheader2) && (!pData->bJPEGdecostarted2)) - { - /* set parameters for decompression */ - - if (pData->bJPEGprogressive2) /* progressive display ? */ - pData->pJPEGdinfo2->buffered_image = TRUE; - - /* jpeg_start_decompress(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_START_DECOMPRESS) -#endif - if (jpeg_start_decompress (pData->pJPEGdinfo2) == TRUE) - /* indicate it started */ - pData->bJPEGdecostarted2 = MNG_TRUE; - - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - } - /* process some scanlines ? */ - if ((pData->bJPEGhasheader2) && (pData->bJPEGdecostarted2) && - ((!jpeg_input_complete (pData->pJPEGdinfo2)) || - (pData->pJPEGdinfo2->output_scanline < pData->pJPEGdinfo2->output_height))) - { - mng_int32 iLines; - - /* for (each output pass) */ - do - { /* address the row output buffer */ - JSAMPROW pRow = (JSAMPROW)pData->pJPEGrow2; - - /* init new pass ? */ - if ((pData->bJPEGprogressive2) && - ((!pData->bJPEGscanstarted2) || - (pData->pJPEGdinfo2->output_scanline >= pData->pJPEGdinfo2->output_height))) - { - pData->bJPEGscanstarted2 = MNG_TRUE; - - /* adjust output decompression parameters if required */ - /* nop */ - - /* start a new output pass */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_START_OUTPUT) -#endif - jpeg_start_output (pData->pJPEGdinfo2, pData->pJPEGdinfo2->input_scan_number); - - pData->iJPEGrow = 0; /* start at row 0 in the image again */ - } - - /* while (scan lines remain to be read) */ - do - { - /* jpeg_read_scanlines(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_READ_SCANLINES) -#endif - iLines = jpeg_read_scanlines (pData->pJPEGdinfo2, (JSAMPARRAY)&pRow, 1); - - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - - if (iLines > 0) /* got something ? */ - { - if (pData->fStorerow3) /* store in object ? */ - { - iRetcode = ((mng_storerow)pData->fStorerow3) (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - } - } - while ((pData->pJPEGdinfo2->output_scanline < pData->pJPEGdinfo2->output_height) && - (iLines > 0)); /* until end-of-image or not enough input-data */ - - /* terminate output pass */ - if ((pData->bJPEGprogressive2) && - (pData->pJPEGdinfo2->output_scanline >= pData->pJPEGdinfo2->output_height)) - { -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_OUTPUT) -#endif - jpeg_finish_output (pData->pJPEGdinfo2); - /* this scan has ended */ - pData->bJPEGscanstarted2 = MNG_FALSE; - } - } - while ((!jpeg_input_complete (pData->pJPEGdinfo2)) && (iLines > 0)); - } - /* end of image ? */ - if ((pData->bJPEGhasheader2) && (pData->bJPEGdecostarted2) && - (jpeg_input_complete (pData->pJPEGdinfo2)) && - (pData->pJPEGdinfo2->input_scan_number == pData->pJPEGdinfo2->output_scan_number)) - { - /* jpeg_finish_decompress(...); */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_JPEG_FINISH_DECOMPRESS) -#endif - if (jpeg_finish_decompress (pData->pJPEGdinfo2) == TRUE) - { /* indicate it's done */ - pData->bJPEGhasheader2 = MNG_FALSE; - pData->bJPEGdecostarted2 = MNG_FALSE; - pData->pJPEGcurrent2 = (mng_uint8p)pData->pJPEGdinfo2->src->next_input_byte; - pData->iJPEGbufremain2 = (mng_uint32)pData->pJPEGdinfo2->src->bytes_in_buffer; - /* remaining fluff is an error ! */ - if ((pData->iJPEGbufremain2 > 0) || (iRemain > 0)) - MNG_ERROR (pData, MNG_TOOMUCHJDAT) - } - } -#endif /* MNG_INCLUDE_IJG6B */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG_READ -mng_retcode mngjpeg_decompressfree2 (mng_datap pData) -{ -#if defined(MNG_INCLUDE_IJG6B) && defined(MNG_USE_SETJMP) - mng_retcode iRetcode; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_IJG6B -#ifdef MNG_USE_SETJMP - iRetcode = setjmp (pData->sErrorbuf);/* setup local JPEG error-recovery */ - if (iRetcode != 0) /* got here from longjmp ? */ - MNG_ERRORJ (pData, iRetcode) /* then IJG-lib issued an error */ -#endif - /* free the row of JPEG-samples*/ - MNG_FREE (pData, pData->pJPEGrow2, pData->iJPEGrowlen2) - - /* release the JPEG decompression object */ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_JPEG_DESTROY_DECOMPRESS) -#endif - jpeg_destroy_decompress (pData->pJPEGdinfo2); - - pData->bJPEGdecompress2 = MNG_FALSE; /* indicate it's done */ - -#endif /* MNG_INCLUDE_IJG6B */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_JPEG_DECOMPRESSFREE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG_READ */ - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_jpeg.h b/freeimage241/Source/LibMNG/libmng_jpeg.h deleted file mode 100644 index 0f1aa6f..0000000 --- a/freeimage241/Source/LibMNG/libmng_jpeg.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_jpeg.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : JPEG library interface (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the JPEG library interface * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_jpeg_h_ -#define _libmng_jpeg_h_ - -/* ************************************************************************** */ - -mng_retcode mngjpeg_initialize (mng_datap pData); -mng_retcode mngjpeg_cleanup (mng_datap pData); - -mng_retcode mngjpeg_decompressinit (mng_datap pData); -mng_retcode mngjpeg_decompressdata (mng_datap pData, - mng_uint32 iRawsize, - mng_uint8p pRawdata); -mng_retcode mngjpeg_decompressfree (mng_datap pData); - -mng_retcode mngjpeg_decompressinit2 (mng_datap pData); -mng_retcode mngjpeg_decompressdata2 (mng_datap pData, - mng_uint32 iRawsize, - mng_uint8p pRawdata); -mng_retcode mngjpeg_decompressfree2 (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_jpeg_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_memory.h b/freeimage241/Source/LibMNG/libmng_memory.h deleted file mode 100644 index 568d324..0000000 --- a/freeimage241/Source/LibMNG/libmng_memory.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_memory.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Memory management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of memory management functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.3 - 06/12/2000 - G.Juyn * */ -/* * - swapped MNG_COPY parameter-names * */ -/* * 0.5.3 - 06/27/2000 - G.Juyn * */ -/* * - changed size parameter to mng_size_t * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_memory_h_ -#define _libmng_memory_h_ - -/* ************************************************************************** */ -/* * * */ -/* * Generic memory manager macros * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INTERNAL_MEMMNGMT -#define MNG_ALLOC(H,P,L) { P = calloc (1, (mng_size_t)(L)); \ - if (P == 0) { MNG_ERROR (H, MNG_OUTOFMEMORY) } } -#define MNG_ALLOCX(H,P,L) { P = calloc (1, (mng_size_t)(L)); } -#define MNG_FREE(H,P,L) { if (P) { free (P); P = 0; } } -#define MNG_FREEX(H,P,L) { if (P) free (P); } -#else -#define MNG_ALLOC(H,P,L) { P = H->fMemalloc ((mng_size_t)(L)); \ - if (P == 0) { MNG_ERROR (H, MNG_OUTOFMEMORY) } } -#define MNG_ALLOCX(H,P,L) { P = H->fMemalloc ((mng_size_t)(L)); } -#define MNG_FREE(H,P,L) { if (P) { H->fMemfree (P, (mng_size_t)(L)); P = 0; } } -#define MNG_FREEX(H,P,L) { if (P) { H->fMemfree (P, (mng_size_t)(L)); } } -#endif /* mng_internal_memmngmt */ - -#define MNG_COPY(D,S,L) { memcpy (D, S, (mng_size_t)(L)); } - -/* ************************************************************************** */ - -#endif /* _libmng_memory_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_object_prc.c b/freeimage241/Source/LibMNG/libmng_object_prc.c deleted file mode 100644 index 6915db8..0000000 --- a/freeimage241/Source/LibMNG/libmng_object_prc.c +++ /dev/null @@ -1,3828 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_object_prc.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Object processing routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the internal object processing routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - fixed to support JNG objects * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for global color-chunks in animation * */ -/* * - added support for global PLTE,tRNS,bKGD in animation * */ -/* * - added SAVE & SEEK animation objects * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - added initialization of framenr/layernr/playtime * */ -/* * - changed ani_object create routines not to return the * */ -/* * created object (wasn't necessary) * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added object promotion routine (PROM handling) * */ -/* * - added ani-object routines for delta-image processing * */ -/* * - added compression/filter/interlace fields to * */ -/* * object-buffer for delta-image processing * */ -/* * * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed support for delta-image processing * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed some small things (as precaution) * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added processing of PLTE/tRNS & color-info for * */ -/* * delta-images in the ani_objects chain * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added support for PPLT chunk * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added support for freeze/restart/resume & go_xxxx * */ -/* * 0.9.1 - 07/16/2000 - G.Juyn * */ -/* * - fixed support for mng_display() after mng_read() * */ -/* * * */ -/* * 0.9.2 - 07/29/2000 - G.Juyn * */ -/* * - fixed small bugs in display processing * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added valid-flag to stored objects for read() / display()* */ -/* * - added routine to discard "invalid" objects * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - fixed delta-processing behavior * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - added storage for pixel-/alpha-sampledepth for delta's * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - removed "old" MAGN methods 3 & 4 * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 0.9.5 - 1/22/2001 - G.Juyn * */ -/* * - B129681 - fixed compiler warnings SGI/Irix * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_objects.h" -#include "libmng_display.h" -#include "libmng_pixels.h" -#include "libmng_object_prc.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ -/* * * */ -/* * Generic object routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode drop_invalid_objects (mng_datap pData) -{ - mng_objectp pObject; - mng_objectp pNext; - mng_cleanupobject fCleanup; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_INVALID_OBJECTS, MNG_LC_START) -#endif - - pObject = pData->pFirstimgobj; /* get first stored image-object (if any) */ - - while (pObject) /* more objects to check ? */ - { - pNext = ((mng_object_headerp)pObject)->pNext; - /* invalid ? */ - if (!((mng_imagep)pObject)->bValid) - { /* call appropriate cleanup */ - fCleanup = ((mng_object_headerp)pObject)->fCleanup; - fCleanup (pData, pObject); - } - - pObject = pNext; /* neeeext */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DROP_INVALID_OBJECTS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Image-data-object routines * */ -/* * * */ -/* * these handle the "object buffer" as defined by the MNG specification * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode create_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_bool bViewable, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_imagedatap *ppObject) -{ - mng_imagedatap pImagedata; - mng_uint32 iSamplesize = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGDATAOBJECT, MNG_LC_START) -#endif - /* get a buffer */ - MNG_ALLOC (pData, pImagedata, sizeof (mng_imagedata)) - /* fill the appropriate fields */ - pImagedata->sHeader.fCleanup = (mng_cleanupobject)free_imagedataobject; - pImagedata->sHeader.fProcess = 0; - pImagedata->iRefcount = 1; - pImagedata->bFrozen = MNG_FALSE; - pImagedata->bConcrete = bConcrete; - pImagedata->bViewable = bViewable; - pImagedata->iWidth = iWidth; - pImagedata->iHeight = iHeight; - pImagedata->iBitdepth = iBitdepth; - pImagedata->iColortype = iColortype; - pImagedata->iCompression = iCompression; - pImagedata->iFilter = iFilter; - pImagedata->iInterlace = iInterlace; - pImagedata->iAlphabitdepth = 0; - pImagedata->iJHDRcompression = 0; - pImagedata->iJHDRinterlace = 0; - pImagedata->iPixelsampledepth = iBitdepth; - pImagedata->iAlphasampledepth = iBitdepth; - /* determine samplesize from color_type/bit_depth */ - switch (iColortype) /* for < 8-bit samples we just reserve 8 bits */ - { - case 0 : ; /* gray */ - case 8 : { /* JPEG gray */ - if (iBitdepth > 8) - iSamplesize = 2; - else - iSamplesize = 1; - - break; - } - case 2 : ; /* rgb */ - case 10 : { /* JPEG rgb */ - if (iBitdepth > 8) - iSamplesize = 6; - else - iSamplesize = 3; - - break; - } - case 3 : { /* indexed */ - iSamplesize = 1; - break; - } - case 4 : ; /* gray+alpha */ - case 12 : { /* JPEG gray+alpha */ - if (iBitdepth > 8) - iSamplesize = 4; - else - iSamplesize = 2; - - break; - } - case 6 : ; /* rgb+alpha */ - case 14 : { /* JPEG rgb+alpha */ - if (iBitdepth > 8) - iSamplesize = 8; - else - iSamplesize = 4; - - break; - } - } - /* make sure we remember all this */ - pImagedata->iSamplesize = iSamplesize; - pImagedata->iRowsize = iSamplesize * iWidth; - pImagedata->iImgdatasize = pImagedata->iRowsize * iHeight; - - if (pImagedata->iImgdatasize) /* need a buffer ? */ - { /* so allocate it */ - MNG_ALLOCX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize) - - if (!pImagedata->pImgdata) /* enough memory ? */ - { - MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata)) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - } - /* check global stuff */ - pImagedata->bHasGAMA = pData->bHasglobalGAMA; - pImagedata->bHasCHRM = pData->bHasglobalCHRM; - pImagedata->bHasSRGB = pData->bHasglobalSRGB; - pImagedata->bHasICCP = pData->bHasglobalICCP; - pImagedata->bHasBKGD = pData->bHasglobalBKGD; - - if (pData->bHasglobalGAMA) /* global gAMA present ? */ - pImagedata->iGamma = pData->iGlobalGamma; - - if (pData->bHasglobalCHRM) /* global cHRM present ? */ - { - pImagedata->iWhitepointx = pData->iGlobalWhitepointx; - pImagedata->iWhitepointy = pData->iGlobalWhitepointy; - pImagedata->iPrimaryredx = pData->iGlobalPrimaryredx; - pImagedata->iPrimaryredy = pData->iGlobalPrimaryredy; - pImagedata->iPrimarygreenx = pData->iGlobalPrimarygreenx; - pImagedata->iPrimarygreeny = pData->iGlobalPrimarygreeny; - pImagedata->iPrimarybluex = pData->iGlobalPrimarybluex; - pImagedata->iPrimarybluey = pData->iGlobalPrimarybluey; - } - - if (pData->bHasglobalSRGB) /* glbal sRGB present ? */ - pImagedata->iRenderingintent = pData->iGlobalRendintent; - - if (pData->bHasglobalICCP) /* glbal iCCP present ? */ - { - pImagedata->iProfilesize = pData->iGlobalProfilesize; - - if (pImagedata->iProfilesize) - { - MNG_ALLOCX (pData, pImagedata->pProfile, pImagedata->iProfilesize) - - if (!pImagedata->pProfile) /* enough memory ? */ - { - MNG_FREEX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize) - MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata)) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - - MNG_COPY (pImagedata->pProfile, pData->pGlobalProfile, pImagedata->iProfilesize) - } - } - - if (pData->bHasglobalBKGD) /* global bKGD present ? */ - { - pImagedata->iBKGDred = pData->iGlobalBKGDred; - pImagedata->iBKGDgreen = pData->iGlobalBKGDgreen; - pImagedata->iBKGDblue = pData->iGlobalBKGDblue; - } - - *ppObject = pImagedata; /* return it */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGDATAOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_imagedataobject (mng_datap pData, - mng_imagedatap pImagedata) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGDATAOBJECT, MNG_LC_START) -#endif - - if (pImagedata->iRefcount) /* decrease reference count */ - pImagedata->iRefcount--; - - if (!pImagedata->iRefcount) /* reached zero ? */ - { - if (pImagedata->iProfilesize) /* stored an iCCP profile ? */ - MNG_FREEX (pData, pImagedata->pProfile, pImagedata->iProfilesize) - - if (pImagedata->iImgdatasize) /* sample-buffer present ? */ - MNG_FREEX (pData, pImagedata->pImgdata, pImagedata->iImgdatasize) - /* drop the buffer */ - MNG_FREEX (pData, pImagedata, sizeof (mng_imagedata)) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGDATAOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode clone_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_imagedatap pSource, - mng_imagedatap *ppClone) -{ - mng_imagedatap pNewdata; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGDATAOBJECT, MNG_LC_START) -#endif - /* get a buffer */ - MNG_ALLOC (pData, pNewdata, sizeof (mng_imagedata)) - /* blatently copy the original buffer */ - MNG_COPY (pNewdata, pSource, sizeof (mng_imagedata)) - - pNewdata->iRefcount = 1; /* only the reference count */ - pNewdata->bConcrete = bConcrete; /* and concrete-flag are different */ - - if (pNewdata->iImgdatasize) /* sample buffer present ? */ - { - MNG_ALLOCX (pData, pNewdata->pImgdata, pNewdata->iImgdatasize) - - if (!pNewdata->pImgdata) /* not enough memory ? */ - { - MNG_FREEX (pData, pNewdata, sizeof (mng_imagedata)) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - /* make a copy */ - MNG_COPY (pNewdata->pImgdata, pSource->pImgdata, pNewdata->iImgdatasize) - } - - if (pNewdata->iProfilesize) /* iCCP profile present ? */ - { - MNG_ALLOCX (pData, pNewdata->pProfile, pNewdata->iProfilesize) - - if (!pNewdata->pProfile) /* enough memory ? */ - { - MNG_FREEX (pData, pNewdata, sizeof (mng_imagedata)) - MNG_ERROR (pData, MNG_OUTOFMEMORY) - } - /* make a copy */ - MNG_COPY (pNewdata->pProfile, pSource->pProfile, pNewdata->iProfilesize) - } - - *ppClone = pNewdata; /* return the clone */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGDATAOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Image-object routines * */ -/* * * */ -/* * these handle the "object" as defined by the MNG specification * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode create_imageobject (mng_datap pData, - mng_uint16 iId, - mng_bool bConcrete, - mng_bool bVisible, - mng_bool bViewable, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_int32 iPosx, - mng_int32 iPosy, - mng_bool bClipped, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb, - mng_imagep *ppObject) -{ - mng_imagep pImage; - mng_imagep pPrev, pNext; - mng_retcode iRetcode; - mng_imagedatap pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGOBJECT, MNG_LC_START) -#endif - /* get a buffer */ - MNG_ALLOC (pData, pImage, sizeof (mng_image)) - /* now get a new "object buffer" */ - iRetcode = create_imagedataobject (pData, bConcrete, bViewable, - iWidth, iHeight, iBitdepth, iColortype, - iCompression, iFilter, iInterlace, - &pImgbuf); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pImage, sizeof (mng_image)) - return iRetcode; - } - /* fill the appropriate fields */ - pImage->sHeader.fCleanup = (mng_cleanupobject)free_imageobject; - pImage->sHeader.fProcess = 0; - pImage->iId = iId; - pImage->bFrozen = MNG_FALSE; - pImage->bVisible = bVisible; - pImage->bViewable = bViewable; - pImage->bValid = (mng_bool)((pData->bDisplaying) && - (pData->bRunning ) && - (!pData->bFreezing ) ); - pImage->iPosx = iPosx; - pImage->iPosy = iPosy; - pImage->bClipped = bClipped; - pImage->iClipl = iClipl; - pImage->iClipr = iClipr; - pImage->iClipt = iClipt; - pImage->iClipb = iClipb; - pImage->iMAGN_MethodX = 0; - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; - pImage->pImgbuf = pImgbuf; - - if (iId) /* only if not object 0 ! */ - { /* find previous lower object-id */ - pPrev = (mng_imagep)pData->pLastimgobj; - - while ((pPrev) && (pPrev->iId > iId)) - pPrev = (mng_imagep)pPrev->sHeader.pPrev; - - if (pPrev) /* found it ? */ - { - pImage->sHeader.pPrev = pPrev; /* than link it in place */ - pImage->sHeader.pNext = pPrev->sHeader.pNext; - pPrev->sHeader.pNext = pImage; - } - else /* if not found, it becomes the first ! */ - { - pImage->sHeader.pNext = pData->pFirstimgobj; - pData->pFirstimgobj = pImage; - } - - pNext = (mng_imagep)pImage->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pImage; - else - pData->pLastimgobj = pImage; - - } - - *ppObject = pImage; /* and return the new buffer */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_IMGOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* okido */ -} - -/* ************************************************************************** */ - -mng_retcode free_imageobject (mng_datap pData, - mng_imagep pImage) -{ - mng_retcode iRetcode; - mng_imagep pPrev = pImage->sHeader.pPrev; - mng_imagep pNext = pImage->sHeader.pNext; - mng_imagedatap pImgbuf = pImage->pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGOBJECT, MNG_LC_START) -#endif - - if (pImage->iId) /* not for object 0 */ - { - if (pPrev) /* unlink from the list first ! */ - pPrev->sHeader.pNext = pImage->sHeader.pNext; - else - pData->pFirstimgobj = pImage->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pImage->sHeader.pPrev; - else - pData->pLastimgobj = pImage->sHeader.pPrev; - - } - /* unlink the image-data buffer */ - iRetcode = free_imagedataobject (pData, pImgbuf); - /* drop it's own buffer */ - MNG_FREEX (pData, pImage, sizeof (mng_image)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_IMGOBJECT, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_imagep find_imageobject (mng_datap pData, - mng_uint16 iId) -{ - mng_imagep pImage = (mng_imagep)pData->pFirstimgobj; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (pData, MNG_FN_FIND_IMGOBJECT, MNG_LC_START) -#endif - /* look up the right id */ - while ((pImage) && (pImage->iId != iId)) - pImage = (mng_imagep)pImage->sHeader.pNext; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (pData, MNG_FN_FIND_IMGOBJECT, MNG_LC_END) -#endif - - return pImage; -} - -/* ************************************************************************** */ - -mng_retcode clone_imageobject (mng_datap pData, - mng_uint16 iId, - mng_bool bPartial, - mng_bool bVisible, - mng_bool bAbstract, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy, - mng_imagep pSource, - mng_imagep *ppClone) -{ - mng_imagep pNew; - mng_imagep pPrev, pNext; - mng_retcode iRetcode; - mng_imagedatap pImgbuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGOBJECT, MNG_LC_START) -#endif - - if ((pSource->iId) && /* needs magnification ? */ - ((pSource->iMAGN_MethodX) || (pSource->iMAGN_MethodY))) - { - iRetcode = magnify_imageobject (pData, pSource); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* get a buffer */ - MNG_ALLOC (pData, pNew, sizeof (mng_image)) - /* fill or copy the appropriate fields */ - pNew->sHeader.fCleanup = (mng_cleanupobject)free_imageobject; - pNew->sHeader.fProcess = 0; - pNew->iId = iId; - pNew->bFrozen = MNG_FALSE; - pNew->bVisible = bVisible; - pNew->bViewable = pSource->bViewable; - - if (bHasloca) /* location info available ? */ - { - if (iLocationtype == 0) /* absolute position ? */ - { - pNew->iPosx = iLocationx; - pNew->iPosy = iLocationy; - } - else /* relative */ - { - pNew->iPosx = pSource->iPosx + iLocationx; - pNew->iPosy = pSource->iPosy + iLocationy; - } - } - else /* copy from source */ - { - pNew->iPosx = pSource->iPosx; - pNew->iPosy = pSource->iPosy; - } - /* copy clipping info */ - pNew->bClipped = pSource->bClipped; - pNew->iClipl = pSource->iClipl; - pNew->iClipr = pSource->iClipr; - pNew->iClipt = pSource->iClipt; - pNew->iClipb = pSource->iClipb; - /* copy magnification info */ - pNew->iMAGN_MethodX = pSource->iMAGN_MethodX; - pNew->iMAGN_MethodY = pSource->iMAGN_MethodY; - pNew->iMAGN_MX = pSource->iMAGN_MX; - pNew->iMAGN_MY = pSource->iMAGN_MY; - pNew->iMAGN_ML = pSource->iMAGN_ML; - pNew->iMAGN_MR = pSource->iMAGN_MR; - pNew->iMAGN_MT = pSource->iMAGN_MT; - pNew->iMAGN_MB = pSource->iMAGN_MB; - - if (iId) /* not for object 0 */ - { /* find previous lower object-id */ - pPrev = (mng_imagep)pData->pLastimgobj; - while ((pPrev) && (pPrev->iId > iId)) - pPrev = (mng_imagep)pPrev->sHeader.pPrev; - - if (pPrev) /* found it ? */ - { - pNew->sHeader.pPrev = pPrev; /* than link it in place */ - pNew->sHeader.pNext = pPrev->sHeader.pNext; - pPrev->sHeader.pNext = pNew; - } - else /* if not found, it becomes the first ! */ - { - pNew->sHeader.pNext = pData->pFirstimgobj; - pData->pFirstimgobj = pNew; - } - - pNext = (mng_imagep)pNew->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pNew; - else - pData->pLastimgobj = pNew; - - } - - if (bPartial) /* partial clone ? */ - { - pNew->pImgbuf = pSource->pImgbuf; /* use the same object buffer */ - pNew->pImgbuf->iRefcount++; /* and increase the reference count */ - } - else /* create a full clone ! */ - { - mng_bool bConcrete = MNG_FALSE; /* it's abstract by default (?) */ - - if (!bAbstract) /* determine concreteness from source ? */ - bConcrete = pSource->pImgbuf->bConcrete; - /* create a full clone ! */ - iRetcode = clone_imagedataobject (pData, bConcrete, pSource->pImgbuf, &pImgbuf); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pNew, sizeof (mng_image)) - return iRetcode; - } - - pNew->pImgbuf = pImgbuf; /* and remember it */ - } - - *ppClone = pNew; /* return it */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLONE_IMGOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode renum_imageobject (mng_datap pData, - mng_imagep pSource, - mng_uint16 iId, - mng_bool bVisible, - mng_bool bAbstract, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy) -{ - mng_imagep pPrev, pNext; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RENUM_IMGOBJECT, MNG_LC_START) -#endif - - pSource->bVisible = bVisible; /* store the new visibility */ - - if (bHasloca) /* location info available ? */ - { - if (iLocationtype == 0) /* absolute position ? */ - { - pSource->iPosx = iLocationx; - pSource->iPosy = iLocationy; - } - else /* relative */ - { - pSource->iPosx = pSource->iPosx + iLocationx; - pSource->iPosy = pSource->iPosy + iLocationy; - } - } - - if (iId) /* not for object 0 */ - { /* find previous lower object-id */ - pPrev = (mng_imagep)pData->pLastimgobj; - while ((pPrev) && (pPrev->iId > iId)) - pPrev = (mng_imagep)pPrev->sHeader.pPrev; - /* different from current ? */ - if (pPrev != (mng_imagep)pSource->sHeader.pPrev) - { - if (pSource->sHeader.pPrev) /* unlink from current position !! */ - ((mng_imagep)pSource->sHeader.pPrev)->sHeader.pNext = pSource->sHeader.pNext; - else - pData->pFirstimgobj = pSource->sHeader.pNext; - - if (pSource->sHeader.pNext) - ((mng_imagep)pSource->sHeader.pNext)->sHeader.pPrev = pSource->sHeader.pPrev; - else - pData->pLastimgobj = pSource->sHeader.pPrev; - - if (pPrev) /* found the previous ? */ - { /* than link it in place */ - pSource->sHeader.pPrev = pPrev; - pSource->sHeader.pNext = pPrev->sHeader.pNext; - pPrev->sHeader.pNext = pSource; - } - else /* if not found, it becomes the first ! */ - { - pSource->sHeader.pNext = pData->pFirstimgobj; - pData->pFirstimgobj = pSource; - } - - pNext = (mng_imagep)pSource->sHeader.pNext; - - if (pNext) - pNext->sHeader.pPrev = pSource; - else - pData->pLastimgobj = pSource; - - } - } - - pSource->iId = iId; /* now set the new id! */ - - if (bAbstract) /* force it to abstract ? */ - pSource->pImgbuf->bConcrete = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RENUM_IMGOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode reset_object_details (mng_datap pData, - mng_imagep pImage, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_bool bResetall) -{ - mng_imagedatap pBuf = pImage->pImgbuf; - mng_uint32 iSamplesize = 0; - mng_uint32 iRowsize; - mng_uint32 iImgdatasize; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESET_OBJECTDETAILS, MNG_LC_START) -#endif - - pBuf->iWidth = iWidth; /* set buffer characteristics */ - pBuf->iHeight = iHeight; - pBuf->iBitdepth = iBitdepth; - pBuf->iColortype = iColortype; - pBuf->iCompression = iCompression; - pBuf->iFilter = iFilter; - pBuf->iInterlace = iInterlace; - pBuf->iAlphabitdepth = 0; - /* determine samplesize from color_type/bit_depth */ - switch (iColortype) /* for < 8-bit samples we just reserve 8 bits */ - { - case 0 : ; /* gray */ - case 8 : { /* JPEG gray */ - if (iBitdepth > 8) - iSamplesize = 2; - else - iSamplesize = 1; - - break; - } - case 2 : ; /* rgb */ - case 10 : { /* JPEG rgb */ - if (iBitdepth > 8) - iSamplesize = 6; - else - iSamplesize = 3; - - break; - } - case 3 : { /* indexed */ - iSamplesize = 1; - break; - } - case 4 : ; /* gray+alpha */ - case 12 : { /* JPEG gray+alpha */ - if (iBitdepth > 8) - iSamplesize = 4; - else - iSamplesize = 2; - - break; - } - case 6 : ; /* rgb+alpha */ - case 14 : { /* JPEG rgb+alpha */ - if (iBitdepth > 8) - iSamplesize = 8; - else - iSamplesize = 4; - - break; - } - } - - iRowsize = iSamplesize * iWidth; - iImgdatasize = iRowsize * iHeight; - /* buffer size changed ? */ - if (iImgdatasize != pBuf->iImgdatasize) - { /* drop the old one */ - MNG_FREE (pData, pBuf->pImgdata, pBuf->iImgdatasize) - - if (iImgdatasize) /* allocate new sample-buffer ? */ - MNG_ALLOC (pData, pBuf->pImgdata, iImgdatasize) - } - - pBuf->iSamplesize = iSamplesize; /* remember new sizes */ - pBuf->iRowsize = iRowsize; - pBuf->iImgdatasize = iImgdatasize; - /* dimension set and clipping not ? */ - if ((iWidth) && (iHeight) && (!pImage->bClipped)) - { - pImage->iClipl = 0; /* set clipping to dimension by default */ - pImage->iClipr = iWidth; - pImage->iClipt = 0; - pImage->iClipb = iHeight; - } - - if (pImage->iId) /* reset magnification info ? */ - { - pImage->iMAGN_MethodX = 0; - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; - } - - if (bResetall) /* reset the other characteristics ? */ - { - pBuf->bHasPLTE = MNG_FALSE; - pBuf->bHasTRNS = MNG_FALSE; - pBuf->bHasGAMA = pData->bHasglobalGAMA; - pBuf->bHasCHRM = pData->bHasglobalCHRM; - pBuf->bHasSRGB = pData->bHasglobalSRGB; - pBuf->bHasICCP = pData->bHasglobalICCP; - pBuf->bHasBKGD = pData->bHasglobalBKGD; - - if (pBuf->iProfilesize) /* drop possibly old ICC profile */ - { - MNG_FREE (pData, pBuf->pProfile, pBuf->iProfilesize) - pBuf->iProfilesize = 0; - } - - if (pData->bHasglobalGAMA) /* global gAMA present ? */ - pBuf->iGamma = pData->iGlobalGamma; - - if (pData->bHasglobalCHRM) /* global cHRM present ? */ - { - pBuf->iWhitepointx = pData->iGlobalWhitepointx; - pBuf->iWhitepointy = pData->iGlobalWhitepointy; - pBuf->iPrimaryredx = pData->iGlobalPrimaryredx; - pBuf->iPrimaryredy = pData->iGlobalPrimaryredy; - pBuf->iPrimarygreenx = pData->iGlobalPrimarygreenx; - pBuf->iPrimarygreeny = pData->iGlobalPrimarygreeny; - pBuf->iPrimarybluex = pData->iGlobalPrimarybluex; - pBuf->iPrimarybluey = pData->iGlobalPrimarybluey; - } - - if (pData->bHasglobalSRGB) /* global sRGB present ? */ - pBuf->iRenderingintent = pData->iGlobalRendintent; - - if (pData->bHasglobalICCP) /* global iCCP present ? */ - { - if (pData->iGlobalProfilesize) - { - MNG_ALLOC (pData, pBuf->pProfile, pData->iGlobalProfilesize) - MNG_COPY (pBuf->pProfile, pData->pGlobalProfile, pData->iGlobalProfilesize) - } - - pBuf->iProfilesize = pData->iGlobalProfilesize; - } - - if (pData->bHasglobalBKGD) /* global bKGD present ? */ - { - pBuf->iBKGDred = pData->iGlobalBKGDred; - pBuf->iBKGDgreen = pData->iGlobalBKGDgreen; - pBuf->iBKGDblue = pData->iGlobalBKGDblue; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESET_OBJECTDETAILS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode promote_imageobject (mng_datap pData, - mng_imagep pImage, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype) -{ - mng_uint8p pNewbuf; - mng_uint32 iNewbufsize; - mng_uint32 iNewrowsize; - mng_uint32 iNewsamplesize; - mng_uint32 iX, iY; - mng_uint8p pSrcline, pDstline; - mng_uint8 iB; - mng_imagedatap pBuf = pImage->pImgbuf; - mng_uint32 iW = pBuf->iWidth; - mng_uint32 iH = pBuf->iHeight; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IMGOBJECT, MNG_LC_START) -#endif - - if ((pBuf->iColortype == 3) && (iColortype == 2)) - { /* indexed -> rgb */ - iNewsamplesize = 3; - iNewrowsize = iW * iNewsamplesize; - iNewbufsize = iH * iNewrowsize; - - MNG_ALLOC (pData, pNewbuf, iNewbufsize) - - pSrcline = pBuf->pImgdata; - pDstline = pNewbuf; - - for (iY = 0; iY < iH; iY++) - { - for (iX = 0; iX < iW; iX++) - { - iB = *pSrcline; - - if ((mng_uint32)iB < pBuf->iPLTEcount) - { - *pDstline = pBuf->aPLTEentries [iB].iRed; - *(pDstline+1) = pBuf->aPLTEentries [iB].iGreen; - *(pDstline+2) = pBuf->aPLTEentries [iB].iBlue; - } - - pSrcline++; - pDstline += 3; - } - } - - MNG_FREEX (pData, pBuf->pImgdata, pBuf->iImgdatasize) - - pBuf->iBitdepth = iBitdepth; - pBuf->iColortype = iColortype; - pBuf->iSamplesize = iNewsamplesize; - pBuf->iRowsize = iNewrowsize; - pBuf->iImgdatasize = iNewbufsize; - pBuf->pImgdata = pNewbuf; - pBuf->bHasPLTE = MNG_FALSE; - pBuf->bHasTRNS = MNG_FALSE; - } - else - if ((pBuf->iColortype == 3) && (iColortype == 6)) - { /* indexed -> rgba */ - iNewsamplesize = 4; - iNewrowsize = iW * iNewsamplesize; - iNewbufsize = iH * iNewrowsize; - - MNG_ALLOC (pData, pNewbuf, iNewbufsize) - - pSrcline = pBuf->pImgdata; - pDstline = pNewbuf; - - for (iY = 0; iY < iH; iY++) - { - for (iX = 0; iX < iW; iX++) - { - iB = *pSrcline; - - if ((mng_uint32)iB < pBuf->iPLTEcount) - { - *pDstline = pBuf->aPLTEentries [iB].iRed; - *(pDstline+1) = pBuf->aPLTEentries [iB].iGreen; - *(pDstline+2) = pBuf->aPLTEentries [iB].iBlue; - - if ((mng_uint32)iB < pBuf->iTRNScount) - *(pDstline+3) = pBuf->aTRNSentries [iB]; - else - *(pDstline+3) = 255; - } - - pSrcline++; - pDstline += 4; - } - } - - MNG_FREEX (pData, pBuf->pImgdata, pBuf->iImgdatasize) - - pBuf->iBitdepth = iBitdepth; - pBuf->iColortype = iColortype; - pBuf->iSamplesize = iNewsamplesize; - pBuf->iRowsize = iNewrowsize; - pBuf->iImgdatasize = iNewbufsize; - pBuf->pImgdata = pNewbuf; - pBuf->bHasPLTE = MNG_FALSE; - pBuf->bHasTRNS = MNG_FALSE; - } - else - { - - /* TODO: other promotion */ - - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROMOTE_IMGOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_imageobject (mng_datap pData, - mng_imagep pImage) -{ - mng_uint8p pNewdata; - mng_uint8p pSrcline1; - mng_uint8p pSrcline2; - mng_uint8p pTempline; - mng_uint8p pDstline; - mng_uint32 iNewrowsize; - mng_uint32 iNewsize; - mng_uint32 iY; - mng_int32 iS, iM; - mng_retcode iRetcode; - - mng_imagedatap pBuf = pImage->pImgbuf; - mng_uint32 iNewW = pBuf->iWidth; - mng_uint32 iNewH = pBuf->iHeight; - mng_magnify_x fMagnifyX = MNG_NULL; - mng_magnify_y fMagnifyY = MNG_NULL; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_IMGOBJECT, MNG_LC_START) -#endif - - if (pBuf->iColortype == 3) /* indexed color ? */ - { /* concrete buffer ? */ - if ((pBuf->bConcrete) && (pImage->iId)) - MNG_ERROR (pData, MNG_INVALIDCOLORTYPE) - - if (pBuf->iTRNScount) /* with transparency ? */ - iRetcode = promote_imageobject (pData, pImage, 8, 6, 0); - else - iRetcode = promote_imageobject (pData, pImage, 8, 2, 0); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - if (pImage->iMAGN_MethodX) /* determine new width */ - { - if (pImage->iMAGN_MethodX == 1) - { - iNewW = pImage->iMAGN_ML; - if (pBuf->iWidth > 1) - iNewW = iNewW + pImage->iMAGN_MR; - if (pBuf->iWidth > 2) - iNewW = iNewW + (pBuf->iWidth - 2) * (pImage->iMAGN_MX); - } - else - { - iNewW = pBuf->iWidth + pImage->iMAGN_ML - 1; - if (pBuf->iWidth > 2) - iNewW = iNewW + pImage->iMAGN_MR - 1; - if (pBuf->iWidth > 3) - iNewW = iNewW + (pBuf->iWidth - 3) * (pImage->iMAGN_MX - 1); - } - } - - if (pImage->iMAGN_MethodY) /* determine new height */ - { - if (pImage->iMAGN_MethodY == 1) - { - iNewH = pImage->iMAGN_MT; - if (pBuf->iHeight > 1) - iNewH = iNewH + pImage->iMAGN_ML; - if (pBuf->iHeight > 2) - iNewH = iNewH + (pBuf->iHeight - 2) * (pImage->iMAGN_MY); - } - else - { - iNewH = pBuf->iHeight + pImage->iMAGN_MT - 1; - if (pBuf->iHeight > 2) - iNewH = iNewH + pImage->iMAGN_MB - 1; - if (pBuf->iHeight > 3) - iNewH = iNewH + (pBuf->iHeight - 3) * (pImage->iMAGN_MY - 1); - } - } - /* get new buffer */ - iNewrowsize = iNewW * pBuf->iSamplesize; - iNewsize = iNewH * iNewrowsize; - - MNG_ALLOC (pData, pNewdata, iNewsize); - - switch (pBuf->iColortype) /* determine magnification routines */ - { - case 0 : ; - case 8 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = magnify_g8_x1; break; } - case 2 : { fMagnifyX = magnify_g8_x2; break; } - case 3 : { fMagnifyX = magnify_g8_x3; break; } - case 4 : { fMagnifyX = magnify_g8_x2; break; } - case 5 : { fMagnifyX = magnify_g8_x3; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = magnify_g8_y1; break; } - case 2 : { fMagnifyY = magnify_g8_y2; break; } - case 3 : { fMagnifyY = magnify_g8_y3; break; } - case 4 : { fMagnifyY = magnify_g8_y2; break; } - case 5 : { fMagnifyY = magnify_g8_y3; break; } - } - } - else - { - - /* TODO: magnify 16-bit */ - - } - - break; - } - - case 2 : ; - case 10 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = magnify_rgb8_x1; break; } - case 2 : { fMagnifyX = magnify_rgb8_x2; break; } - case 3 : { fMagnifyX = magnify_rgb8_x3; break; } - case 4 : { fMagnifyX = magnify_rgb8_x2; break; } - case 5 : { fMagnifyX = magnify_rgb8_x3; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = magnify_rgb8_y1; break; } - case 2 : { fMagnifyY = magnify_rgb8_y2; break; } - case 3 : { fMagnifyY = magnify_rgb8_y3; break; } - case 4 : { fMagnifyY = magnify_rgb8_y2; break; } - case 5 : { fMagnifyY = magnify_rgb8_y3; break; } - } - } - else - { - - /* TODO: magnify 16-bit */ - - } - - break; - } - - case 4 : ; - case 12 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = magnify_ga8_x1; break; } - case 2 : { fMagnifyX = magnify_ga8_x2; break; } - case 3 : { fMagnifyX = magnify_ga8_x3; break; } - case 4 : { fMagnifyX = magnify_ga8_x4; break; } - case 5 : { fMagnifyX = magnify_ga8_x5; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = magnify_ga8_y1; break; } - case 2 : { fMagnifyY = magnify_ga8_y2; break; } - case 3 : { fMagnifyY = magnify_ga8_y3; break; } - case 4 : { fMagnifyY = magnify_ga8_y4; break; } - case 5 : { fMagnifyY = magnify_ga8_y5; break; } - } - } - else - { - - /* TODO: magnify 16-bit */ - - } - - break; - } - - case 6 : ; - case 14 : { - if (pBuf->iBitdepth <= 8) - { - switch (pImage->iMAGN_MethodX) - { - case 1 : { fMagnifyX = magnify_rgba8_x1; break; } - case 2 : { fMagnifyX = magnify_rgba8_x2; break; } - case 3 : { fMagnifyX = magnify_rgba8_x3; break; } - case 4 : { fMagnifyX = magnify_rgba8_x4; break; } - case 5 : { fMagnifyX = magnify_rgba8_x5; break; } - } - - switch (pImage->iMAGN_MethodY) - { - case 1 : { fMagnifyY = magnify_rgba8_y1; break; } - case 2 : { fMagnifyY = magnify_rgba8_y2; break; } - case 3 : { fMagnifyY = magnify_rgba8_y3; break; } - case 4 : { fMagnifyY = magnify_rgba8_y4; break; } - case 5 : { fMagnifyY = magnify_rgba8_y5; break; } - } - } - else - { - - /* TODO: magnify 16-bit */ - - } - - break; - } - } - - pSrcline1 = pBuf->pImgdata; /* initialize row-loop variables */ - pDstline = pNewdata; - /* allocate temporary row */ - MNG_ALLOC (pData, pTempline, iNewrowsize) - - for (iY = 0; iY < pBuf->iHeight; iY++) - { - pSrcline2 = pSrcline1 + pBuf->iRowsize; - - if (fMagnifyX) /* magnifying in X-direction ? */ - { - iRetcode = fMagnifyX (pData, pImage->iMAGN_MX, - pImage->iMAGN_ML, pImage->iMAGN_MR, - pBuf->iWidth, pSrcline1, pDstline); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pTempline, iNewrowsize) - MNG_FREEX (pData, pNewdata, iNewsize) - return iRetcode; - } - } - else - { - MNG_COPY (pDstline, pSrcline1, iNewrowsize) - } - - pDstline += iNewrowsize; - /* magnifying in Y-direction ? */ - if ((fMagnifyY) && - ((iY < pBuf->iHeight - 1) || (pBuf->iHeight == 1) || (pImage->iMAGN_MethodY == 1))) - { - if (iY == 0) /* first interval ? */ - { - if (pBuf->iHeight == 1) /* single row ? */ - pSrcline2 = MNG_NULL; - - iM = (mng_int32)pImage->iMAGN_MT; - } - else /* last interval ? */ - if (((pImage->iMAGN_MethodY == 1) && (iY == (pBuf->iHeight - 1))) || - ((pImage->iMAGN_MethodY != 1) && (iY == (pBuf->iHeight - 2))) ) - iM = (mng_int32)pImage->iMAGN_MB; - else /* middle interval */ - iM = (mng_int32)pImage->iMAGN_MY; - - for (iS = 1; iS < iM; iS++) - { - iRetcode = fMagnifyY (pData, iS, iM, pBuf->iWidth, - pSrcline1, pSrcline2, pTempline); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pTempline, iNewrowsize) - MNG_FREEX (pData, pNewdata, iNewsize) - return iRetcode; - } - - if (fMagnifyX) /* magnifying in X-direction ? */ - { - iRetcode = fMagnifyX (pData, pImage->iMAGN_MX, - pImage->iMAGN_ML, pImage->iMAGN_MR, - pBuf->iWidth, pTempline, pDstline); - - if (iRetcode) /* on error bail out */ - { - MNG_FREEX (pData, pTempline, iNewrowsize) - MNG_FREEX (pData, pNewdata, iNewsize) - return iRetcode; - } - } - else - { - MNG_COPY (pDstline, pTempline, iNewrowsize) - } - - pDstline += iNewrowsize; - } - } - - pSrcline1 += pBuf->iRowsize; - } - /* drop temporary row */ - MNG_FREEX (pData, pTempline, iNewrowsize) - /* drop old pixel-data */ - MNG_FREEX (pData, pBuf->pImgdata, pBuf->iImgdatasize) - - pBuf->pImgdata = pNewdata; /* save new buffer dimensions */ - pBuf->iRowsize = iNewrowsize; - pBuf->iImgdatasize = iNewsize; - pBuf->iWidth = iNewW; - pBuf->iHeight = iNewH; - - if (pImage->iId) /* real object ? */ - { - pImage->iMAGN_MethodX = 0; /* it's done; don't do it again !!! */ - pImage->iMAGN_MethodY = 0; - pImage->iMAGN_MX = 0; - pImage->iMAGN_MY = 0; - pImage->iMAGN_ML = 0; - pImage->iMAGN_MR = 0; - pImage->iMAGN_MT = 0; - pImage->iMAGN_MB = 0; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_IMGOBJECT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Animation-object routines * */ -/* * * */ -/* * these handle the animation objects used to re-run parts of a MNG. * */ -/* * eg. during LOOP or TERM processing * */ -/* * * */ -/* ************************************************************************** */ - -void add_ani_object (mng_datap pData, - mng_object_headerp pObject) -{ - mng_object_headerp pLast = (mng_object_headerp)pData->pLastaniobj; - - if (pLast) /* link it as last in the chain */ - { - pObject->pPrev = pLast; - pLast->pNext = pObject; - } - else - { - pObject->pPrev = MNG_NULL; /* be on the safe side */ - pData->pFirstaniobj = pObject; - } - - pObject->pNext = MNG_NULL; /* be on the safe side */ - pData->pLastaniobj = pObject; - /* keep track for jumping */ - pObject->iFramenr = pData->iFrameseq; - pObject->iLayernr = pData->iLayerseq; - pObject->iPlaytime = pData->iFrametime; - /* save restart object ? */ - if ((pData->bDisplaying) && (!pData->bRunning) && (!pData->pCurraniobj)) - pData->pCurraniobj = pObject; - - return; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_image (mng_datap pData) -{ - mng_ani_imagep pImage; - mng_imagep pCurrent; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IMAGE, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - if (pData->bHasDHDR) /* processing delta-image ? */ - pCurrent = (mng_imagep)pData->pObjzero; - else /* get the current object */ - pCurrent = (mng_imagep)pData->pCurrentobj; - - if (!pCurrent) /* otherwise object 0 */ - pCurrent = (mng_imagep)pData->pObjzero; - /* now just clone the object !!! */ - iRetcode = clone_imageobject (pData, 0, MNG_FALSE, pCurrent->bVisible, - MNG_FALSE, MNG_FALSE, 0, 0, 0, pCurrent, &pImage); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - pImage->sHeader.fCleanup = free_ani_image; - pImage->sHeader.fProcess = process_ani_image; - - add_ani_object (pData, (mng_object_headerp)pImage); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IMAGE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* okido */ -} - -/* ************************************************************************** */ - -mng_retcode free_ani_image (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_imagep pImage = (mng_ani_imagep)pObject; - mng_imagedatap pImgbuf = pImage->pImgbuf; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IMAGE, MNG_LC_START) -#endif - /* unlink the image-data buffer */ - iRetcode = free_imagedataobject (pData, pImgbuf); - /* drop it's own buffer */ - MNG_FREEX (pData, pImage, sizeof (mng_ani_image)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IMAGE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_image (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode = MNG_NOERROR; - mng_ani_imagep pImage = (mng_imagep)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IMAGE, MNG_LC_START) -#endif - - if (pData->bHasDHDR) /* processing delta-image ? */ - { - mng_imagep pDelta = (mng_imagep)pData->pDeltaImage; - - if (!pData->iBreakpoint) /* only execute if not broken before */ - { /* make sure to process pixels as well */ - pData->bDeltaimmediate = MNG_FALSE; - /* execute the delta process */ - iRetcode = execute_delta_image (pData, pDelta, (mng_imagep)pObject); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - /* now go and shoot it off (if required) */ - if ((pDelta->bVisible) && (pDelta->bViewable)) - iRetcode = display_image (pData, pDelta, MNG_FALSE); - - if (!pData->bTimerset) - pData->bHasDHDR = MNG_FALSE; /* this image signifies IEND !! */ - - } - else - if (pData->pCurrentobj) /* active object ? */ - { - mng_imagep pCurrent = (mng_imagep)pData->pCurrentobj; - mng_imagedatap pBuf = pCurrent->pImgbuf; - - if (!pData->iBreakpoint) /* don't copy it again ! */ - { - if (pBuf->iImgdatasize) /* buffer present in active object ? */ - /* then drop it */ - MNG_FREE (pData, pBuf->pImgdata, pBuf->iImgdatasize) - - if (pBuf->iProfilesize) /* iCCP profile present ? */ - /* then drop it */ - MNG_FREE (pData, pBuf->pProfile, pBuf->iProfilesize) - /* now blatently copy the animation buffer */ - MNG_COPY (pBuf, pImage->pImgbuf, sizeof (mng_imagedata)) - /* copy viewability */ - pCurrent->bViewable = pImage->bViewable; - - if (pBuf->iImgdatasize) /* sample buffer present ? */ - { /* then make a copy */ - MNG_ALLOC (pData, pBuf->pImgdata, pBuf->iImgdatasize) - MNG_COPY (pBuf->pImgdata, pImage->pImgbuf->pImgdata, pBuf->iImgdatasize) - } - - if (pBuf->iProfilesize) /* iCCP profile present ? */ - { /* then make a copy */ - MNG_ALLOC (pData, pBuf->pProfile, pBuf->iProfilesize) - MNG_COPY (pBuf->pProfile, pImage->pImgbuf->pProfile, pBuf->iProfilesize) - } - } - /* now go and shoot it off (if required) */ - if ((pCurrent->bVisible) && (pCurrent->bViewable)) - iRetcode = display_image (pData, pCurrent, MNG_FALSE); - } - else - { - mng_imagep pObjzero = (mng_imagep)pData->pObjzero; - /* overlay with object 0 status */ - pImage->bVisible = pObjzero->bVisible; - pImage->bViewable = pObjzero->bViewable; - pImage->iPosx = pObjzero->iPosx; - pImage->iPosy = pObjzero->iPosy; - pImage->bClipped = pObjzero->bClipped; - pImage->iClipl = pObjzero->iClipl; - pImage->iClipr = pObjzero->iClipr; - pImage->iClipt = pObjzero->iClipt; - pImage->iClipb = pObjzero->iClipb; - /* now this should do the trick */ - if ((pImage->bVisible) && (pImage->bViewable)) - iRetcode = display_image (pData, pImage, MNG_FALSE); - } - - if (!iRetcode) /* all's well ? */ - { - if (pData->bTimerset) /* timer break ? */ - pData->iBreakpoint = 99; /* fictive number; no more processing needed! */ - else - pData->iBreakpoint = 0; /* else clear it */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IMAGE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_plte (mng_datap pData, - mng_uint32 iEntrycount, - mng_palette8ep paEntries) -{ - mng_ani_pltep pPLTE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PLTE, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pPLTE, sizeof (mng_ani_plte)) - - pPLTE->sHeader.fCleanup = free_ani_plte; - pPLTE->sHeader.fProcess = process_ani_plte; - - add_ani_object (pData, (mng_object_headerp)pPLTE); - - pPLTE->iEntrycount = iEntrycount; - - MNG_COPY (pPLTE->aEntries, paEntries, sizeof (pPLTE->aEntries)) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_plte (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PLTE, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_plte)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_plte (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_pltep pPLTE = (mng_ani_pltep)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PLTE, MNG_LC_START) -#endif - - pData->bHasglobalPLTE = MNG_TRUE; - pData->iGlobalPLTEcount = pPLTE->iEntrycount; - - MNG_COPY (pData->aGlobalPLTEentries, pPLTE->aEntries, sizeof (pPLTE->aEntries)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PLTE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_trns (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata) -{ - mng_ani_trnsp pTRNS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TRNS, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pTRNS, sizeof (mng_ani_trns)) - - pTRNS->sHeader.fCleanup = free_ani_trns; - pTRNS->sHeader.fProcess = process_ani_trns; - - add_ani_object (pData, (mng_object_headerp)pTRNS); - - pTRNS->iRawlen = iRawlen; - - MNG_COPY (pTRNS->aRawdata, pRawdata, sizeof (pTRNS->aRawdata)) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_trns (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TRNS, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_trns)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_trns (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_trnsp pTRNS = (mng_ani_trnsp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TRNS, MNG_LC_START) -#endif - - pData->bHasglobalTRNS = MNG_TRUE; - pData->iGlobalTRNSrawlen = pTRNS->iRawlen; - - MNG_COPY (pData->aGlobalTRNSrawdata, pTRNS->aRawdata, sizeof (pTRNS->aRawdata)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TRNS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_gama (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iGamma) -{ - mng_ani_gamap pGAMA; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_GAMA, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pGAMA, sizeof (mng_ani_gama)) - - pGAMA->sHeader.fCleanup = free_ani_gama; - pGAMA->sHeader.fProcess = process_ani_gama; - - add_ani_object (pData, (mng_object_headerp)pGAMA); - - pGAMA->bEmpty = bEmpty; - pGAMA->iGamma = iGamma; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_gama (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_GAMA, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_gama)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_gama (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_gamap pGAMA = (mng_ani_gamap)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_GAMA, MNG_LC_START) -#endif - - if (pGAMA->bEmpty) /* empty chunk ? */ - { /* clear global gAMA */ - pData->bHasglobalGAMA = MNG_FALSE; - pData->iGlobalGamma = 0; - } - else - { /* set global gAMA */ - pData->bHasglobalGAMA = MNG_TRUE; - pData->iGlobalGamma = pGAMA->iGamma; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_GAMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_chrm (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey) -{ - mng_ani_chrmp pCHRM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CHRM, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pCHRM, sizeof (mng_ani_chrm)) - - pCHRM->sHeader.fCleanup = free_ani_chrm; - pCHRM->sHeader.fProcess = process_ani_chrm; - - add_ani_object (pData, (mng_object_headerp)pCHRM); - - pCHRM->bEmpty = bEmpty; - pCHRM->iWhitepointx = iWhitepointx; - pCHRM->iWhitepointy = iWhitepointy; - pCHRM->iRedx = iRedx; - pCHRM->iRedy = iRedy; - pCHRM->iGreenx = iGreenx; - pCHRM->iGreeny = iGreeny; - pCHRM->iBluex = iBluex; - pCHRM->iBluey = iBluey; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_chrm (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CHRM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_chrm)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_chrm (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_chrmp pCHRM = (mng_ani_chrmp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CHRM, MNG_LC_START) -#endif - - if (pCHRM->bEmpty) /* empty chunk ? */ - { /* clear global cHRM */ - pData->bHasglobalCHRM = MNG_FALSE; - pData->iGlobalWhitepointx = 0; - pData->iGlobalWhitepointy = 0; - pData->iGlobalPrimaryredx = 0; - pData->iGlobalPrimaryredy = 0; - pData->iGlobalPrimarygreenx = 0; - pData->iGlobalPrimarygreeny = 0; - pData->iGlobalPrimarybluex = 0; - pData->iGlobalPrimarybluey = 0; - } - else - { /* set global cHRM */ - pData->bHasglobalCHRM = MNG_TRUE; - pData->iGlobalWhitepointx = pCHRM->iWhitepointx; - pData->iGlobalWhitepointy = pCHRM->iWhitepointy; - pData->iGlobalPrimaryredx = pCHRM->iRedx; - pData->iGlobalPrimaryredy = pCHRM->iRedy; - pData->iGlobalPrimarygreenx = pCHRM->iGreenx; - pData->iGlobalPrimarygreeny = pCHRM->iGreeny; - pData->iGlobalPrimarybluex = pCHRM->iBluex; - pData->iGlobalPrimarybluey = pCHRM->iBluey; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CHRM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_srgb (mng_datap pData, - mng_bool bEmpty, - mng_uint8 iRenderingintent) -{ - mng_ani_srgbp pSRGB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SRGB, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pSRGB, sizeof (mng_ani_srgb)) - - pSRGB->sHeader.fCleanup = free_ani_srgb; - pSRGB->sHeader.fProcess = process_ani_srgb; - - add_ani_object (pData, (mng_object_headerp)pSRGB); - - pSRGB->bEmpty = bEmpty; - pSRGB->iRenderingintent = iRenderingintent; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_srgb (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SRGB, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_srgb)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_srgb (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_srgbp pSRGB = (mng_ani_srgbp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SRGB, MNG_LC_START) -#endif - - if (pSRGB->bEmpty) /* empty chunk ? */ - { /* clear global sRGB */ - pData->bHasglobalSRGB = MNG_FALSE; - pData->iGlobalRendintent = 0; - } - else - { /* set global sRGB */ - pData->bHasglobalSRGB = MNG_TRUE; - pData->iGlobalRendintent = pSRGB->iRenderingintent; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_iccp (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ - mng_ani_iccpp pICCP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ICCP, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pICCP, sizeof (mng_ani_iccp)) - - pICCP->sHeader.fCleanup = free_ani_iccp; - pICCP->sHeader.fProcess = process_ani_iccp; - - add_ani_object (pData, (mng_object_headerp)pICCP); - - pICCP->bEmpty = bEmpty; - pICCP->iProfilesize = iProfilesize; - - if (iProfilesize) - { - MNG_ALLOC (pData, pICCP->pProfile, iProfilesize) - MNG_COPY (pICCP->pProfile, pProfile, iProfilesize) - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_iccp (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_iccpp pICCP = (mng_ani_iccpp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ICCP, MNG_LC_START) -#endif - - if (pICCP->iProfilesize) - MNG_FREEX (pData, pICCP->pProfile, pICCP->iProfilesize) - - MNG_FREEX (pData, pObject, sizeof (mng_ani_iccp)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_iccp (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_iccpp pICCP = (mng_ani_iccpp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ICCP, MNG_LC_START) -#endif - - if (pICCP->bEmpty) /* empty chunk ? */ - { /* clear global iCCP */ - pData->bHasglobalICCP = MNG_FALSE; - - if (pData->iGlobalProfilesize) - MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize) - - pData->iGlobalProfilesize = 0; - pData->pGlobalProfile = MNG_NULL; - } - else - { /* set global iCCP */ - pData->bHasglobalICCP = MNG_TRUE; - pData->iGlobalProfilesize = pICCP->iProfilesize; - - if (pICCP->iProfilesize) - { - MNG_ALLOC (pData, pData->pGlobalProfile, pICCP->iProfilesize) - MNG_COPY (pData->pGlobalProfile, pICCP->pProfile, pICCP->iProfilesize) - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ICCP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_bkgd (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue) -{ - mng_ani_bkgdp pBKGD; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BKGD, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pBKGD, sizeof (mng_ani_bkgd)) - - pBKGD->sHeader.fCleanup = free_ani_bkgd; - pBKGD->sHeader.fProcess = process_ani_bkgd; - - add_ani_object (pData, (mng_object_headerp)pBKGD); - - pBKGD->iRed = iRed; - pBKGD->iGreen = iGreen; - pBKGD->iBlue = iBlue; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_bkgd (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BKGD, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_bkgd)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_bkgd (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_bkgdp pBKGD = (mng_ani_bkgdp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BKGD, MNG_LC_START) -#endif - - pData->bHasglobalBKGD = MNG_TRUE; - pData->iGlobalBKGDred = pBKGD->iRed; - pData->iGlobalBKGDgreen = pBKGD->iGreen; - pData->iGlobalBKGDblue = pBKGD->iBlue; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_loop (mng_datap pData, - mng_uint8 iLevel, - mng_uint32 iRepeatcount, - mng_uint8 iTermcond, - mng_uint32 iItermin, - mng_uint32 iItermax, - mng_uint32 iCount, - mng_uint32p pSignals) -{ - mng_ani_loopp pLOOP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_LOOP, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pLOOP, sizeof (mng_ani_loop)) - - pLOOP->sHeader.fCleanup = free_ani_loop; - pLOOP->sHeader.fProcess = process_ani_loop; - - add_ani_object (pData, (mng_object_headerp)pLOOP); - - pLOOP->iLevel = iLevel; - pLOOP->iRepeatcount = iRepeatcount; - pLOOP->iTermcond = iTermcond; - pLOOP->iItermin = iItermin; - pLOOP->iItermax = iItermax; - pLOOP->iCount = iCount; - /* running counter starts with repeat_count */ - pLOOP->iRunningcount = iRepeatcount; - - if (iCount) - { - MNG_ALLOC (pData, pLOOP->pSignals, (iCount << 1)) - MNG_COPY (pLOOP->pSignals, pSignals, (iCount << 1)) - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_loop (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_loopp pLOOP = (mng_ani_loopp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_LOOP, MNG_LC_START) -#endif - - if (pLOOP->iCount) /* drop signal buffer ? */ - MNG_FREEX (pData, pLOOP->pSignals, (pLOOP->iCount << 1)) - - MNG_FREEX (pData, pObject, sizeof (mng_ani_loop)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_loop (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_loopp pLOOP = (mng_ani_loopp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_LOOP, MNG_LC_START) -#endif - /* just reset the running counter */ - pLOOP->iRunningcount = pLOOP->iRepeatcount; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_LOOP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_endl (mng_datap pData, - mng_uint8 iLevel) -{ - mng_ani_endlp pENDL; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ENDL, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pENDL, sizeof (mng_ani_endl)) - - pENDL->sHeader.fCleanup = free_ani_endl; - pENDL->sHeader.fProcess = process_ani_endl; - - add_ani_object (pData, (mng_object_headerp)pENDL); - - pENDL->iLevel = iLevel; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_endl (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ENDL, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_endl)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_endl (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_endlp pENDL = (mng_ani_endlp)pObject; - mng_ani_loopp pLOOP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ENDL, MNG_LC_START) -#endif - - if ((pData->bDisplaying) && (pData->bRunning)) - { - pLOOP = pENDL->pLOOP; /* determine matching LOOP */ - - if (!pLOOP) /* haven't got it yet ? */ - { /* go and look back in the list */ - pLOOP = (mng_ani_loopp)pENDL->sHeader.pPrev; - - while ((pLOOP) && - ((pLOOP->sHeader.fCleanup != free_ani_loop) || - (pLOOP->iLevel != pENDL->iLevel) )) - pLOOP = pLOOP->sHeader.pPrev; - } - /* got it now ? */ - if ((pLOOP) && (pLOOP->iLevel == pENDL->iLevel)) - { - pENDL->pLOOP = pLOOP; /* save for next time ! */ - /* decrease running counter ? */ - if ((pLOOP->iRunningcount) && (pLOOP->iRunningcount < 0x7fffffffL)) - pLOOP->iRunningcount--; - - /* TODO: we're cheating out on the termination_condition, - iteration_min, iteration_max and possible signals; - the code is just not ready for that can of worms.... */ - - if (!pLOOP->iRunningcount) /* reached zero ? */ - { /* was this the outer LOOP ? */ - if (pData->pFirstaniobj == (mng_objectp)pLOOP) - pData->bHasLOOP = MNG_FALSE; - } - else - { - if (pData->pCurraniobj) /* was we processing objects ? */ - pData->pCurraniobj = pLOOP; /* then restart with LOOP */ - else /* else restart behind LOOP !!! */ - pData->pCurraniobj = pLOOP->sHeader.pNext; - } - } - else - { - MNG_ERROR (pData, 1234); - /* TODO: error abort ??? */ - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_ENDL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_defi (mng_datap pData) -{ - mng_ani_defip pDEFI; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DEFI, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pDEFI, sizeof (mng_ani_defi)) - - pDEFI->sHeader.fCleanup = free_ani_defi; - pDEFI->sHeader.fProcess = process_ani_defi; - - add_ani_object (pData, (mng_object_headerp)pDEFI); - - pDEFI->iId = pData->iDEFIobjectid; - pDEFI->bHasdonotshow = pData->bDEFIhasdonotshow; - pDEFI->iDonotshow = pData->iDEFIdonotshow; - pDEFI->bHasconcrete = pData->bDEFIhasconcrete; - pDEFI->iConcrete = pData->iDEFIconcrete; - pDEFI->bHasloca = pData->bDEFIhasloca; - pDEFI->iLocax = pData->iDEFIlocax; - pDEFI->iLocay = pData->iDEFIlocay; - pDEFI->bHasclip = pData->bDEFIhasclip; - pDEFI->iClipl = pData->iDEFIclipl; - pDEFI->iClipr = pData->iDEFIclipr; - pDEFI->iClipt = pData->iDEFIclipt; - pDEFI->iClipb = pData->iDEFIclipb; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_defi (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DEFI, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_defi)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_defi (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_defip pDEFI = (mng_ani_defip)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DEFI, MNG_LC_START) -#endif - - pData->iDEFIobjectid = pDEFI->iId; - pData->bDEFIhasdonotshow = pDEFI->bHasdonotshow; - pData->iDEFIdonotshow = pDEFI->iDonotshow; - pData->bDEFIhasconcrete = pDEFI->bHasconcrete; - pData->iDEFIconcrete = pDEFI->iConcrete; - pData->bDEFIhasloca = pDEFI->bHasloca; - pData->iDEFIlocax = pDEFI->iLocax; - pData->iDEFIlocay = pDEFI->iLocay; - pData->bDEFIhasclip = pDEFI->bHasclip; - pData->iDEFIclipl = pDEFI->iClipl; - pData->iDEFIclipr = pDEFI->iClipr; - pData->iDEFIclipt = pDEFI->iClipt; - pData->iDEFIclipb = pDEFI->iClipb; - - iRetcode = process_display_defi (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DEFI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable) -{ - mng_ani_basip pBASI; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BASI, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pBASI, sizeof (mng_ani_basi)) - - pBASI->sHeader.fCleanup = free_ani_basi; - pBASI->sHeader.fProcess = process_ani_basi; - - add_ani_object (pData, (mng_object_headerp)pBASI); - - pBASI->iRed = iRed; - pBASI->iGreen = iGreen; - pBASI->iBlue = iBlue; - pBASI->bHasalpha = bHasalpha; - pBASI->iAlpha = iAlpha; - pBASI->iViewable = iViewable; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_basi (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BASI, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_basi)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BASI, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_basi (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_basip pBASI = (mng_ani_basip)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BASI, MNG_LC_START) -#endif - - iRetcode = process_display_basi (pData, pBASI->iRed, pBASI->iGreen, pBASI->iBlue, - pBASI->bHasalpha, pBASI->iAlpha, pBASI->iViewable); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BASI, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_clon (mng_datap pData, - mng_uint16 iCloneid, - mng_uint16 iSourceid, - mng_uint8 iClonetype, - mng_bool bHasdonotshow, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocatype, - mng_int32 iLocax, - mng_int32 iLocay) -{ - mng_ani_clonp pCLON; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLON, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pCLON, sizeof (mng_ani_clon)) - - pCLON->sHeader.fCleanup = free_ani_clon; - pCLON->sHeader.fProcess = process_ani_clon; - - add_ani_object (pData, (mng_object_headerp)pCLON); - - pCLON->iCloneid = iCloneid; - pCLON->iSourceid = iSourceid; - pCLON->iClonetype = iClonetype; - pCLON->bHasdonotshow = bHasdonotshow; - pCLON->iDonotshow = iDonotshow; - pCLON->iConcrete = iConcrete; - pCLON->bHasloca = bHasloca; - pCLON->iLocatype = iLocatype; - pCLON->iLocax = iLocax; - pCLON->iLocay = iLocay; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_clon (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLON, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_clon)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLON, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_clon (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_clonp pCLON = (mng_ani_clonp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLON, MNG_LC_START) -#endif - - iRetcode = process_display_clon (pData, pCLON->iCloneid, pCLON->iSourceid, - pCLON->iClonetype, pCLON->bHasdonotshow, - pCLON->iDonotshow, pCLON->iConcrete, - pCLON->bHasloca, pCLON->iLocatype, - pCLON->iLocax, pCLON->iLocay); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLON, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_back (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile) -{ - mng_ani_backp pBACK; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BACK, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pBACK, sizeof (mng_ani_back)) - - pBACK->sHeader.fCleanup = free_ani_back; - pBACK->sHeader.fProcess = process_ani_back; - - add_ani_object (pData, (mng_object_headerp)pBACK); - - pBACK->iRed = iRed; - pBACK->iGreen = iGreen; - pBACK->iBlue = iBlue; - pBACK->iMandatory = iMandatory; - pBACK->iImageid = iImageid; - pBACK->iTile = iTile; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_back (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BACK, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_back)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_back (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_backp pBACK = (mng_ani_backp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BACK, MNG_LC_START) -#endif - - pData->iBACKred = pBACK->iRed; - pData->iBACKgreen = pBACK->iGreen; - pData->iBACKblue = pBACK->iBlue; - pData->iBACKmandatory = pBACK->iMandatory; - pData->iBACKimageid = pBACK->iImageid; - pData->iBACKtile = pBACK->iTile; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_BACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_fram (mng_datap pData, - mng_uint8 iFramemode, - mng_uint8 iChangedelay, - mng_uint32 iDelay, - mng_uint8 iChangetimeout, - mng_uint32 iTimeout, - mng_uint8 iChangeclipping, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_ani_framp pFRAM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_FRAM, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pFRAM, sizeof (mng_ani_fram)) - - pFRAM->sHeader.fCleanup = free_ani_fram; - pFRAM->sHeader.fProcess = process_ani_fram; - - add_ani_object (pData, (mng_object_headerp)pFRAM); - - pFRAM->iFramemode = iFramemode; - pFRAM->iChangedelay = iChangedelay; - pFRAM->iDelay = iDelay; - pFRAM->iChangetimeout = iChangetimeout; - pFRAM->iTimeout = iTimeout; - pFRAM->iChangeclipping = iChangeclipping; - pFRAM->iCliptype = iCliptype; - pFRAM->iClipl = iClipl; - pFRAM->iClipr = iClipr; - pFRAM->iClipt = iClipt; - pFRAM->iClipb = iClipb; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_fram (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_FRAM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_fram)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_FRAM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_fram (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_framp pFRAM = (mng_ani_framp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_FRAM, MNG_LC_START) -#endif - - if (pData->iBreakpoint) /* previously broken ? */ - { - iRetcode = process_display_fram2 (pData); - pData->iBreakpoint = 0; /* not again */ - } - else - iRetcode = process_display_fram (pData, pFRAM->iFramemode, - pFRAM->iChangedelay, pFRAM->iDelay, - pFRAM->iChangetimeout, pFRAM->iTimeout, - pFRAM->iChangeclipping, pFRAM->iCliptype, - pFRAM->iClipl, pFRAM->iClipr, - pFRAM->iClipt, pFRAM->iClipb); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_FRAM, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_move (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iType, - mng_int32 iLocax, - mng_int32 iLocay) -{ - mng_ani_movep pMOVE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MOVE, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pMOVE, sizeof (mng_ani_move)) - - pMOVE->sHeader.fCleanup = free_ani_move; - pMOVE->sHeader.fProcess = process_ani_move; - - add_ani_object (pData, (mng_object_headerp)pMOVE); - - pMOVE->iFirstid = iFirstid; - pMOVE->iLastid = iLastid; - pMOVE->iType = iType; - pMOVE->iLocax = iLocax; - pMOVE->iLocay = iLocay; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_move (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MOVE, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_move)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MOVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_move (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - mng_ani_movep pMOVE = (mng_ani_movep)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MOVE, MNG_LC_START) -#endif - /* re-process the MOVE chunk */ - iRetcode = process_display_move (pData, pMOVE->iFirstid, pMOVE->iLastid, - pMOVE->iType, - pMOVE->iLocax, pMOVE->iLocay); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MOVE, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_clip (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iType, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb) -{ - mng_ani_clipp pCLIP; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLIP, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pCLIP, sizeof (mng_ani_clip)) - - pCLIP->sHeader.fCleanup = free_ani_clip; - pCLIP->sHeader.fProcess = process_ani_clip; - - add_ani_object (pData, (mng_object_headerp)pCLIP); - - pCLIP->iFirstid = iFirstid; - pCLIP->iLastid = iLastid; - pCLIP->iType = iType; - pCLIP->iClipl = iClipl; - pCLIP->iClipr = iClipr; - pCLIP->iClipt = iClipt; - pCLIP->iClipb = iClipb; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_clip (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLIP, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_clip)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_CLIP, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_clip (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - mng_ani_clipp pCLIP = (mng_ani_clipp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLIP, MNG_LC_START) -#endif - /* re-process the CLIP chunk */ - iRetcode = process_display_clip (pData, pCLIP->iFirstid, pCLIP->iLastid, - pCLIP->iType, - pCLIP->iClipl, pCLIP->iClipr, - pCLIP->iClipt, pCLIP->iClipb); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_CLIP, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_show (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode) -{ - mng_ani_showp pSHOW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SHOW, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pSHOW, sizeof (mng_ani_show)) - - pSHOW->sHeader.fCleanup = free_ani_show; - pSHOW->sHeader.fProcess = process_ani_show; - - add_ani_object (pData, (mng_object_headerp)pSHOW); - - pSHOW->iFirstid = iFirstid; - pSHOW->iLastid = iLastid; - pSHOW->iMode = iMode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_show (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SHOW, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_show)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SHOW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_show (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - mng_ani_showp pSHOW = (mng_ani_showp)pObject; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SHOW, MNG_LC_START) -#endif - - if (pData->iBreakpoint) /* returning from breakpoint ? */ - { - iRetcode = process_display_show (pData); - } - else - { /* "re-run" SHOW chunk */ - pData->iSHOWmode = pSHOW->iMode; - pData->iSHOWfromid = pSHOW->iFirstid; - pData->iSHOWtoid = pSHOW->iLastid; - - iRetcode = process_display_show (pData); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SHOW, MNG_LC_END) -#endif - - return iRetcode; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_term (mng_datap pData, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax) -{ - mng_ani_termp pTERM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TERM, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pTERM, sizeof (mng_ani_term)) - - pTERM->sHeader.fCleanup = free_ani_term; - pTERM->sHeader.fProcess = process_ani_term; - - add_ani_object (pData, (mng_object_headerp)pTERM); - - pTERM->iTermaction = iTermaction; - pTERM->iIteraction = iIteraction; - pTERM->iDelay = iDelay; - pTERM->iItermax = iItermax; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_term (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TERM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_term)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_term (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TERM, MNG_LC_START) -#endif - - /* dummy: no action required! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_TERM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_save (mng_datap pData) -{ - mng_ani_savep pSAVE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SAVE, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pSAVE, sizeof (mng_ani_save)) - - pSAVE->sHeader.fCleanup = free_ani_save; - pSAVE->sHeader.fProcess = process_ani_save; - - add_ani_object (pData, (mng_object_headerp)pSAVE); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_save (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SAVE, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_save)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_save (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SAVE, MNG_LC_START) -#endif - - iRetcode = process_display_save (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SAVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_seek (mng_datap pData) -{ - mng_ani_seekp pSEEK; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SEEK, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pSEEK, sizeof (mng_ani_seek)) - - pSEEK->sHeader.fCleanup = free_ani_seek; - pSEEK->sHeader.fProcess = process_ani_seek; - - add_ani_object (pData, (mng_object_headerp)pSEEK); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_seek (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SEEK, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_seek)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_seek (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SEEK, MNG_LC_START) -#endif - - iRetcode = process_display_seek (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_SEEK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_dhdr (mng_datap pData, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky) -{ - mng_ani_dhdrp pDHDR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DHDR, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pDHDR, sizeof (mng_ani_dhdr)) - - pDHDR->sHeader.fCleanup = free_ani_dhdr; - pDHDR->sHeader.fProcess = process_ani_dhdr; - - pDHDR->iObjectid = iObjectid; - pDHDR->iImagetype = iImagetype; - pDHDR->iDeltatype = iDeltatype; - pDHDR->iBlockwidth = iBlockwidth; - pDHDR->iBlockheight = iBlockheight; - pDHDR->iBlockx = iBlockx; - pDHDR->iBlocky = iBlocky; - - add_ani_object (pData, (mng_object_headerp)pDHDR); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_dhdr (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DHDR, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_dhdr)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_dhdr (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_dhdrp pDHDR = (mng_ani_dhdrp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DHDR, MNG_LC_START) -#endif - - pData->bHasDHDR = MNG_TRUE; /* let everyone know we're inside a DHDR */ - - iRetcode = process_display_dhdr (pData, pDHDR->iObjectid, - pDHDR->iImagetype, pDHDR->iDeltatype, - pDHDR->iBlockwidth, pDHDR->iBlockheight, - pDHDR->iBlockx, pDHDR->iBlocky); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_DHDR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype) -{ - mng_ani_promp pPROM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PROM, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pPROM, sizeof (mng_ani_prom)) - - pPROM->sHeader.fCleanup = free_ani_prom; - pPROM->sHeader.fProcess = process_ani_prom; - - pPROM->iBitdepth = iBitdepth; - pPROM->iColortype = iColortype; - pPROM->iFilltype = iFilltype; - - add_ani_object (pData, (mng_object_headerp)pPROM); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_prom (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PROM, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_prom)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_prom (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_promp pPROM = (mng_ani_promp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PROM, MNG_LC_START) -#endif - - iRetcode = process_display_prom (pData, pPROM->iBitdepth, - pPROM->iColortype, pPROM->iFilltype); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PROM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_ipng (mng_datap pData) -{ - mng_ani_ipngp pIPNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IPNG, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pIPNG, sizeof (mng_ani_ipng)) - - pIPNG->sHeader.fCleanup = free_ani_ipng; - pIPNG->sHeader.fProcess = process_ani_ipng; - - add_ani_object (pData, (mng_object_headerp)pIPNG); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_ipng (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IPNG, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_ipng)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_ipng (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IPNG, MNG_LC_START) -#endif - - iRetcode = process_display_ipng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IPNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_ijng (mng_datap pData) -{ - mng_ani_ijngp pIJNG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IJNG, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pIJNG, sizeof (mng_ani_ijng)) - - pIJNG->sHeader.fCleanup = free_ani_ijng; - pIJNG->sHeader.fProcess = process_ani_ijng; - - add_ani_object (pData, (mng_object_headerp)pIJNG); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_ijng (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IJNG, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_ijng)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_ijng (mng_datap pData, - mng_objectp pObject) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IJNG, MNG_LC_START) -#endif - - iRetcode = process_display_ijng (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_IJNG, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries) -{ - mng_ani_ppltp pPPLT; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PPLT, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pPPLT, sizeof (mng_ani_pplt)) - - pPPLT->sHeader.fCleanup = free_ani_pplt; - pPPLT->sHeader.fProcess = process_ani_pplt; - - pPPLT->iType = iType; - pPPLT->iCount = iCount; - - MNG_COPY (pPPLT->aIndexentries, paIndexentries, sizeof (pPPLT->aIndexentries)) - MNG_COPY (pPPLT->aAlphaentries, paAlphaentries, sizeof (pPPLT->aAlphaentries)) - MNG_COPY (pPPLT->aUsedentries, paUsedentries, sizeof (pPPLT->aUsedentries )) - - add_ani_object (pData, (mng_object_headerp)pPPLT); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_pplt (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PPLT, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_pplt)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_pplt (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_ppltp pPPLT = (mng_ani_ppltp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PPLT, MNG_LC_START) -#endif - - iRetcode = process_display_pplt (pData, pPPLT->iType, pPPLT->iCount, - pPPLT->aIndexentries, pPPLT->aAlphaentries, - pPPLT->aUsedentries); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_PPLT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* ************************************************************************** */ - -mng_retcode create_ani_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY) -{ - mng_ani_magnp pMAGN; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MAGN, MNG_LC_START) -#endif - - if (pData->bCacheplayback) /* caching playback info ? */ - { - MNG_ALLOC (pData, pMAGN, sizeof (mng_ani_magn)) - - pMAGN->sHeader.fCleanup = free_ani_magn; - pMAGN->sHeader.fProcess = process_ani_magn; - - pMAGN->iFirstid = iFirstid; - pMAGN->iLastid = iLastid; - pMAGN->iMethodX = iMethodX; - pMAGN->iMX = iMX; - pMAGN->iMY = iMY; - pMAGN->iML = iML; - pMAGN->iMR = iMR; - pMAGN->iMT = iMT; - pMAGN->iMB = iMB; - pMAGN->iMethodY = iMethodY; - - add_ani_object (pData, (mng_object_headerp)pMAGN); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CREATE_ANI_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode free_ani_magn (mng_datap pData, - mng_objectp pObject) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MAGN, MNG_LC_START) -#endif - - MNG_FREEX (pData, pObject, sizeof (mng_ani_magn)) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_FREE_ANI_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ani_magn (mng_datap pData, - mng_objectp pObject) -{ - mng_ani_magnp pMAGN = (mng_ani_magnp)pObject; - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MAGN, MNG_LC_START) -#endif - - iRetcode = process_display_magn (pData, pMAGN->iFirstid, pMAGN->iLastid, - pMAGN->iMethodX, pMAGN->iMX, pMAGN->iMY, - pMAGN->iML, pMAGN->iMR, pMAGN->iMT, pMAGN->iMB, - pMAGN->iMethodY); - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_ANI_MAGN, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_object_prc.h b/freeimage241/Source/LibMNG/libmng_object_prc.h deleted file mode 100644 index 7a1c786..0000000 --- a/freeimage241/Source/LibMNG/libmng_object_prc.h +++ /dev/null @@ -1,432 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_object_prc.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Object processing routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the internal object processing routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for global color-chunks in animation * */ -/* * - added support for global PLTE,tRNS,bKGD in animation * */ -/* * - added SAVE & SEEK animation objects * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - changed ani_object create routines not to return the * */ -/* * created object (wasn't necessary) * */ -/* * - added compression/filter/interlace fields to * */ -/* * object-buffer for delta-image processing * */ -/* * * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added support for PPLT chunk * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added routine to discard "invalid" objects * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_object_prc_h_ -#define _libmng_object_prc_h_ - -/* ************************************************************************** */ - -mng_retcode drop_invalid_objects (mng_datap pData); - -/* ************************************************************************** */ - -mng_retcode create_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_bool bViewable, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_imagedatap *ppObject); - -mng_retcode free_imagedataobject (mng_datap pData, - mng_imagedatap pImagedata); - -mng_retcode clone_imagedataobject (mng_datap pData, - mng_bool bConcrete, - mng_imagedatap pSource, - mng_imagedatap *ppClone); - -/* ************************************************************************** */ - -mng_retcode create_imageobject (mng_datap pData, - mng_uint16 iId, - mng_bool bConcrete, - mng_bool bVisible, - mng_bool bViewable, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_int32 iPosx, - mng_int32 iPosy, - mng_bool bClipped, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb, - mng_imagep *ppObject); - -mng_retcode free_imageobject (mng_datap pData, - mng_imagep pImage); - -mng_imagep find_imageobject (mng_datap pData, - mng_uint16 iId); - -mng_retcode clone_imageobject (mng_datap pData, - mng_uint16 iId, - mng_bool bPartial, - mng_bool bVisible, - mng_bool bAbstract, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy, - mng_imagep pSource, - mng_imagep *ppClone); - -mng_retcode renum_imageobject (mng_datap pData, - mng_imagep pSource, - mng_uint16 iId, - mng_bool bVisible, - mng_bool bAbstract, - mng_bool bHasloca, - mng_uint8 iLocationtype, - mng_int32 iLocationx, - mng_int32 iLocationy); - -mng_retcode reset_object_details (mng_datap pData, - mng_imagep pImage, - mng_uint32 iWidth, - mng_uint32 iHeight, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iCompression, - mng_uint8 iFilter, - mng_uint8 iInterlace, - mng_bool bResetall); - -mng_retcode promote_imageobject (mng_datap pData, - mng_imagep pImage, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype); - -mng_retcode magnify_imageobject (mng_datap pData, - mng_imagep pImage); - -/* ************************************************************************** */ - -mng_retcode create_ani_image (mng_datap pData); - -mng_retcode create_ani_plte (mng_datap pData, - mng_uint32 iEntrycount, - mng_palette8ep paEntries); - -mng_retcode create_ani_trns (mng_datap pData, - mng_uint32 iRawlen, - mng_uint8p pRawdata); - -mng_retcode create_ani_gama (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iGamma); - -mng_retcode create_ani_chrm (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey); - -mng_retcode create_ani_srgb (mng_datap pData, - mng_bool bEmpty, - mng_uint8 iRenderinginent); - -mng_retcode create_ani_iccp (mng_datap pData, - mng_bool bEmpty, - mng_uint32 iProfilesize, - mng_ptr pProfile); - -mng_retcode create_ani_bkgd (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue); - -mng_retcode create_ani_loop (mng_datap pData, - mng_uint8 iLevel, - mng_uint32 iRepeatcount, - mng_uint8 iTermcond, - mng_uint32 iItermin, - mng_uint32 iItermax, - mng_uint32 iCount, - mng_uint32p pSignals); - -mng_retcode create_ani_endl (mng_datap pData, - mng_uint8 iLevel); - -mng_retcode create_ani_defi (mng_datap pData); - -mng_retcode create_ani_basi (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_bool bHasalpha, - mng_uint16 iAlpha, - mng_uint8 iViewable); - -mng_retcode create_ani_clon (mng_datap pData, - mng_uint16 iCloneid, - mng_uint16 iSourceid, - mng_uint8 iClonetype, - mng_bool bHasdonotshow, - mng_uint8 iDonotshow, - mng_uint8 iConcrete, - mng_bool bHasloca, - mng_uint8 iLocatype, - mng_int32 iLocax, - mng_int32 iLocay); - -mng_retcode create_ani_back (mng_datap pData, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue, - mng_uint8 iMandatory, - mng_uint16 iImageid, - mng_uint8 iTile); - -mng_retcode create_ani_fram (mng_datap pData, - mng_uint8 iFramemode, - mng_uint8 iChangedelay, - mng_uint32 iDelay, - mng_uint8 iChangetimeout, - mng_uint32 iTimeout, - mng_uint8 iChangeclipping, - mng_uint8 iCliptype, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); - -mng_retcode create_ani_move (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iType, - mng_int32 iLocax, - mng_int32 iLocay); - -mng_retcode create_ani_clip (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iType, - mng_int32 iClipl, - mng_int32 iClipr, - mng_int32 iClipt, - mng_int32 iClipb); - -mng_retcode create_ani_show (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint8 iMode); - -mng_retcode create_ani_term (mng_datap pData, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax); - -mng_retcode create_ani_save (mng_datap pData); -mng_retcode create_ani_seek (mng_datap pData); - -mng_retcode create_ani_dhdr (mng_datap pData, - mng_uint16 iObjectid, - mng_uint8 iImagetype, - mng_uint8 iDeltatype, - mng_uint32 iBlockwidth, - mng_uint32 iBlockheight, - mng_uint32 iBlockx, - mng_uint32 iBlocky); - -mng_retcode create_ani_prom (mng_datap pData, - mng_uint8 iBitdepth, - mng_uint8 iColortype, - mng_uint8 iFilltype); - -mng_retcode create_ani_ipng (mng_datap pData); -mng_retcode create_ani_ijng (mng_datap pData); - -mng_retcode create_ani_pplt (mng_datap pData, - mng_uint8 iType, - mng_uint32 iCount, - mng_palette8ep paIndexentries, - mng_uint8p paAlphaentries, - mng_uint8p paUsedentries); - -mng_retcode create_ani_magn (mng_datap pData, - mng_uint16 iFirstid, - mng_uint16 iLastid, - mng_uint16 iMethodX, - mng_uint16 iMX, - mng_uint16 iMY, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint16 iMT, - mng_uint16 iMB, - mng_uint16 iMethodY); - -/* ************************************************************************** */ - -mng_retcode free_ani_image (mng_datap pData, - mng_objectp pObject); - -mng_retcode free_ani_plte (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_trns (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_gama (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_chrm (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_srgb (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_iccp (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_bkgd (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_loop (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_endl (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_defi (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_basi (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_clon (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_back (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_fram (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_move (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_clip (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_show (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_term (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_save (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_seek (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_dhdr (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_prom (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_ipng (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_ijng (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_pplt (mng_datap pData, - mng_objectp pObject); -mng_retcode free_ani_magn (mng_datap pData, - mng_objectp pObject); - -/* ************************************************************************** */ - -mng_retcode process_ani_image (mng_datap pData, - mng_objectp pObject); - -mng_retcode process_ani_plte (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_trns (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_gama (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_chrm (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_srgb (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_iccp (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_bkgd (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_loop (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_endl (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_defi (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_basi (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_clon (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_back (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_fram (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_move (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_clip (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_show (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_term (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_save (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_seek (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_dhdr (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_prom (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_ipng (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_ijng (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_pplt (mng_datap pData, - mng_objectp pObject); -mng_retcode process_ani_magn (mng_datap pData, - mng_objectp pObject); - -/* ************************************************************************** */ - -#endif /* _libmng_object_prc_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_objects.h b/freeimage241/Source/LibMNG/libmng_objects.h deleted file mode 100644 index 67647f3..0000000 --- a/freeimage241/Source/LibMNG/libmng_objects.h +++ /dev/null @@ -1,509 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_objects.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Internal object structures (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the internal object structures * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - changed inclusion to DISPLAY_PROCS * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added global color-chunks for animations * */ -/* * - added global PLTE,tRNS,bKGD chunks for animation * */ -/* * - added SAVE & SEEK animation objects * */ -/* * 0.5.2 - 05/29/2000 - G.Juyn * */ -/* * - added framenr/layernr/playtime to object header * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added ani-objects for delta-image processing * */ -/* * - added compression/filter/interlace fields to * */ -/* * object-buffer for delta-image processing * */ -/* * * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed definition of aTRNSentries * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added definition for PPLT animation-processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/10/2000 - G.Juyn * */ -/* * - fixed DEFI behavior * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for delta-JNG * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added valid-flag to stored objects for read() / display()* */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - added storage for pixel-/alpha-sampledepth for delta's * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_objects_h_ -#define _libmng_objects_h_ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* ************************************************************************** */ - -typedef mng_retcode (*mng_cleanupobject) (mng_datap pData, - mng_objectp pHeader); - -typedef mng_retcode (*mng_processobject) (mng_datap pData, - mng_objectp pHeader); - -/* ************************************************************************** */ - -typedef struct { - mng_cleanupobject fCleanup; - mng_processobject fProcess; - mng_objectp pNext; /* for double-linked list */ - mng_objectp pPrev; - mng_uint32 iFramenr; - mng_uint32 iLayernr; - mng_uint32 iPlaytime; - } mng_object_header; -typedef mng_object_header * mng_object_headerp; - -/* ************************************************************************** */ - -typedef struct { /* MNG specification "object-buffer" */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint32 iRefcount; /* reference counter */ - mng_bool bFrozen; /* frozen flag */ - mng_bool bConcrete; /* concrete flag */ - mng_bool bViewable; /* viewable flag */ - mng_uint32 iWidth; /* image specifics */ - mng_uint32 iHeight; - mng_uint8 iBitdepth; - mng_uint8 iColortype; - mng_uint8 iCompression; - mng_uint8 iFilter; - mng_uint8 iInterlace; - - mng_uint8 iAlphabitdepth; /* used only for JNG images */ - mng_uint8 iJHDRcompression; - mng_uint8 iJHDRinterlace; - - mng_uint8 iPixelsampledepth; /* used with delta-images */ - mng_uint8 iAlphasampledepth; - - mng_bool bHasPLTE; /* PLTE chunk present */ - mng_bool bHasTRNS; /* tRNS chunk present */ - mng_bool bHasGAMA; /* gAMA chunk present */ - mng_bool bHasCHRM; /* cHRM chunk present */ - mng_bool bHasSRGB; /* sRGB chunk present */ - mng_bool bHasICCP; /* iCCP chunk present */ - mng_bool bHasBKGD; /* bKGD chunk present */ - - mng_uint32 iPLTEcount; /* PLTE fields */ - mng_rgbpaltab aPLTEentries; - - mng_uint16 iTRNSgray; /* tRNS fields */ - mng_uint16 iTRNSred; - mng_uint16 iTRNSgreen; - mng_uint16 iTRNSblue; - mng_uint32 iTRNScount; - mng_uint8arr aTRNSentries; - - mng_uint32 iGamma; /* gAMA fields */ - - mng_uint32 iWhitepointx; /* cHRM fields */ - mng_uint32 iWhitepointy; - mng_uint32 iPrimaryredx; - mng_uint32 iPrimaryredy; - mng_uint32 iPrimarygreenx; - mng_uint32 iPrimarygreeny; - mng_uint32 iPrimarybluex; - mng_uint32 iPrimarybluey; - - mng_uint8 iRenderingintent; /* sRGB fields */ - - mng_uint32 iProfilesize; /* iCCP fields */ - mng_ptr pProfile; - - mng_uint8 iBKGDindex; /* bKGD fields */ - mng_uint16 iBKGDgray; - mng_uint16 iBKGDred; - mng_uint16 iBKGDgreen; - mng_uint16 iBKGDblue; - - mng_uint32 iSamplesize; /* size of a sample */ - mng_uint32 iRowsize; /* size of a row of samples */ - mng_uint32 iImgdatasize; /* size of the sample data buffer */ - mng_uint8p pImgdata; /* actual sample data buffer */ - - } mng_imagedata; -typedef mng_imagedata * mng_imagedatap; - -/* ************************************************************************** */ - -typedef struct { /* MNG specification "object" */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iId; /* object-id */ - mng_bool bFrozen; /* frozen flag */ - mng_bool bVisible; /* potential visibility flag */ - mng_bool bViewable; /* viewable flag */ - mng_bool bValid; /* marks invalid when only reading */ - mng_int32 iPosx; /* location fields */ - mng_int32 iPosy; - mng_bool bClipped; /* clipping fields */ - mng_int32 iClipl; - mng_int32 iClipr; - mng_int32 iClipt; - mng_int32 iClipb; - mng_uint16 iMAGN_MethodX; /* magnification (MAGN) */ - mng_uint16 iMAGN_MethodY; - mng_uint16 iMAGN_MX; - mng_uint16 iMAGN_MY; - mng_uint16 iMAGN_ML; - mng_uint16 iMAGN_MR; - mng_uint16 iMAGN_MT; - mng_uint16 iMAGN_MB; - mng_imagedatap pImgbuf; /* the image-data buffer */ - } mng_image; -typedef mng_image * mng_imagep; - -/* ************************************************************************** */ - - /* "on-the-fly" image (= object 0) */ -typedef mng_image mng_ani_image; /* let's (ab)use the general "object" */ -typedef mng_ani_image * mng_ani_imagep; /* that's actualy crucial, so don't change it! */ - -/* ************************************************************************** */ - -typedef struct { /* global PLTE object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint32 iEntrycount; - mng_rgbpaltab aEntries; - } mng_ani_plte; -typedef mng_ani_plte * mng_ani_pltep; - -/* ************************************************************************** */ - -typedef struct { /* global tRNS object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint32 iRawlen; - mng_uint8arr aRawdata; - } mng_ani_trns; -typedef mng_ani_trns * mng_ani_trnsp; - -/* ************************************************************************** */ - -typedef struct { /* global gAMA object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_bool bEmpty; - mng_uint32 iGamma; - } mng_ani_gama; -typedef mng_ani_gama * mng_ani_gamap; - -/* ************************************************************************** */ - -typedef struct { /* global gCRM object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_bool bEmpty; - mng_uint32 iWhitepointx; - mng_uint32 iWhitepointy; - mng_uint32 iRedx; - mng_uint32 iRedy; - mng_uint32 iGreenx; - mng_uint32 iGreeny; - mng_uint32 iBluex; - mng_uint32 iBluey; - } mng_ani_chrm; -typedef mng_ani_chrm * mng_ani_chrmp; - -/* ************************************************************************** */ - -typedef struct { /* global sRGB object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_bool bEmpty; - mng_uint8 iRenderingintent; - } mng_ani_srgb; -typedef mng_ani_srgb * mng_ani_srgbp; - -/* ************************************************************************** */ - -typedef struct { /* global iCCP object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_bool bEmpty; - mng_uint32 iProfilesize; - mng_ptr pProfile; - } mng_ani_iccp; -typedef mng_ani_iccp * mng_ani_iccpp; - -/* ************************************************************************** */ - -typedef struct { /* global bKGD object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - } mng_ani_bkgd; -typedef mng_ani_bkgd * mng_ani_bkgdp; - -/* ************************************************************************** */ - -typedef struct { /* LOOP object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iLevel; - mng_uint32 iRepeatcount; - mng_uint8 iTermcond; - mng_uint32 iItermin; - mng_uint32 iItermax; - mng_uint32 iCount; - mng_uint32p pSignals; - - mng_uint32 iRunningcount; /* running counter */ - } mng_ani_loop; -typedef mng_ani_loop * mng_ani_loopp; - -/* ************************************************************************** */ - -typedef struct { /* ENDL object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iLevel; - - mng_ani_loopp pLOOP; /* matching LOOP */ - } mng_ani_endl; -typedef mng_ani_endl * mng_ani_endlp; - -/* ************************************************************************** */ - -typedef struct { /* DEFI object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iId; - mng_bool bHasdonotshow; - mng_uint8 iDonotshow; - mng_bool bHasconcrete; - mng_uint8 iConcrete; - mng_bool bHasloca; - mng_int32 iLocax; - mng_int32 iLocay; - mng_bool bHasclip; - mng_int32 iClipl; - mng_int32 iClipr; - mng_int32 iClipt; - mng_int32 iClipb; - } mng_ani_defi; -typedef mng_ani_defi * mng_ani_defip; - -/* ************************************************************************** */ - -typedef struct { /* BASI object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - mng_bool bHasalpha; - mng_uint16 iAlpha; - mng_uint8 iViewable; - } mng_ani_basi; -typedef mng_ani_basi * mng_ani_basip; - -/* ************************************************************************** */ - -typedef struct { /* CLON object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iCloneid; - mng_uint16 iSourceid; - mng_uint8 iClonetype; - mng_bool bHasdonotshow; - mng_uint8 iDonotshow; - mng_uint8 iConcrete; - mng_bool bHasloca; - mng_uint8 iLocatype; - mng_int32 iLocax; - mng_int32 iLocay; - } mng_ani_clon; -typedef mng_ani_clon * mng_ani_clonp; - -/* ************************************************************************** */ - -typedef struct { /* BACK object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iRed; - mng_uint16 iGreen; - mng_uint16 iBlue; - mng_uint8 iMandatory; - mng_uint16 iImageid; - mng_uint8 iTile; - } mng_ani_back; -typedef mng_ani_back * mng_ani_backp; - -/* ************************************************************************** */ - -typedef struct { /* FRAM object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iFramemode; - mng_uint8 iChangedelay; - mng_uint32 iDelay; - mng_uint8 iChangetimeout; - mng_uint32 iTimeout; - mng_uint8 iChangeclipping; - mng_uint8 iCliptype; - mng_int32 iClipl; - mng_int32 iClipr; - mng_int32 iClipt; - mng_int32 iClipb; - } mng_ani_fram; -typedef mng_ani_fram * mng_ani_framp; - -/* ************************************************************************** */ - -typedef struct { /* MOVE object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iType; - mng_int32 iLocax; - mng_int32 iLocay; - } mng_ani_move; -typedef mng_ani_move * mng_ani_movep; - -/* ************************************************************************** */ - -typedef struct { /* CLIP object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iType; - mng_int32 iClipl; - mng_int32 iClipr; - mng_int32 iClipt; - mng_int32 iClipb; - } mng_ani_clip; -typedef mng_ani_clip * mng_ani_clipp; - -/* ************************************************************************** */ - -typedef struct { /* SHOW object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint8 iMode; - } mng_ani_show; -typedef mng_ani_show * mng_ani_showp; - -/* ************************************************************************** */ - -typedef struct { /* TERM object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iTermaction; - mng_uint8 iIteraction; - mng_uint32 iDelay; - mng_uint32 iItermax; - } mng_ani_term; -typedef mng_ani_term * mng_ani_termp; - -/* ************************************************************************** */ - -typedef struct { /* SAVE object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - } mng_ani_save; -typedef mng_ani_save * mng_ani_savep; - -/* ************************************************************************** */ - -typedef struct { /* SEEK object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - } mng_ani_seek; -typedef mng_ani_seek * mng_ani_seekp; - -/* ************************************************************************** */ - -typedef struct { /* DHDR object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iObjectid; - mng_uint8 iImagetype; - mng_uint8 iDeltatype; - mng_uint32 iBlockwidth; - mng_uint32 iBlockheight; - mng_uint32 iBlockx; - mng_uint32 iBlocky; - } mng_ani_dhdr; -typedef mng_ani_dhdr * mng_ani_dhdrp; - -/* ************************************************************************** */ - -typedef struct { /* PROM object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iBitdepth; - mng_uint8 iColortype; - mng_uint8 iFilltype; - } mng_ani_prom; -typedef mng_ani_prom * mng_ani_promp; - -/* ************************************************************************** */ - -typedef struct { /* IPNG object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - } mng_ani_ipng; -typedef mng_ani_ipng * mng_ani_ipngp; - -/* ************************************************************************** */ - -typedef struct { /* IJNG object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - } mng_ani_ijng; -typedef mng_ani_ijng * mng_ani_ijngp; - -/* ************************************************************************** */ - -typedef struct { /* PPLT object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint8 iType; - mng_uint32 iCount; - mng_rgbpaltab aIndexentries; - mng_uint8arr aAlphaentries; - mng_uint8arr aUsedentries; - } mng_ani_pplt; -typedef mng_ani_pplt * mng_ani_ppltp; - -/* ************************************************************************** */ - -typedef struct { /* MAGN object */ - mng_object_header sHeader; /* default header (DO NOT REMOVE) */ - mng_uint16 iFirstid; - mng_uint16 iLastid; - mng_uint16 iMethodX; - mng_uint16 iMX; - mng_uint16 iMY; - mng_uint16 iML; - mng_uint16 iMR; - mng_uint16 iMT; - mng_uint16 iMB; - mng_uint16 iMethodY; - } mng_ani_magn; -typedef mng_ani_magn * mng_ani_magnp; - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_objects_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_pixels.c b/freeimage241/Source/LibMNG/libmng_pixels.c deleted file mode 100644 index cddffb7..0000000 --- a/freeimage241/Source/LibMNG/libmng_pixels.c +++ /dev/null @@ -1,10837 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_pixels.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Pixel-row management routines (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the pixel-row management routines * */ -/* * * */ -/* * the dual alpha-composing for RGBA/BGRA/etc output-canvas' * */ -/* * is based on the Note on Compositing chapter of the * */ -/* * DOH-3 draft, noted to me by Adam M. Costello * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/22/2000 - G.Juyn * */ -/* * - added JNG support * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - fixed minor bugs 16-bit pixel-handling * */ -/* * - added delta-image row-processing routines * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - fixed endian support (hopefully) * */ -/* * 0.5.2 - 06/03/2000 - G.Juyn * */ -/* * - fixed makeup for Linux gcc compile * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - implemented app bkgd restore routines * */ -/* * - implemented RGBA8, ARGB8, BGRA8 & ABGR8 display routines * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/09/2000 - G.Juyn * */ -/* * - fixed alpha-handling for alpha canvasstyles * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * 0.5.3 - 06/17/2000 - G.Juyn * */ -/* * - changed to support delta-images * */ -/* * - optimized some store_xxx routines * */ -/* * 0.5.3 - 06/20/2000 - G.Juyn * */ -/* * - fixed nasty bug with embedded PNG after delta-image * */ -/* * 0.5.3 - 06/24/2000 - G.Juyn * */ -/* * - fixed problem with 16-bit GA format * */ -/* * 0.5.3 - 06/25/2000 - G.Juyn * */ -/* * - fixed problem with cheap transparency for 4-bit gray * */ -/* * - fixed display_xxxx routines for interlaced images * */ -/* * 0.5.3 - 06/28/2000 - G.Juyn * */ -/* * - fixed compiler-warning for non-initialized iB variable * */ -/* * * */ -/* * 0.9.1 - 07/05/2000 - G.Juyn * */ -/* * - fixed mandatory BACK color to be opaque * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - B110547 - fixed bug in interlace code * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/20/2000 - G.Juyn * */ -/* * - fixed app-supplied background restore * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 09/30/2000 - G.Juyn * */ -/* * - fixed MAGN rounding errors (thanks Matthias!) * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - fixed alpha-blending for RGBA canvasstyle * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - fixed alpha-blending for other alpha-canvasstyles * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - fixed support for bKGD * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.3 - 10/28/2000 - G.Juyn * */ -/* * - fixed tRNS processing for gray-image < 8-bits * */ -/* * * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - removed "old" MAGN methods 3 & 4 * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * - removed test filter-methods 1 & 65 * */ -/* * * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 04/25/2001 - G.Juyn * */ -/* * - moved mng_clear_cms to libmng_cms * */ -/* * * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_objects.h" -#include "libmng_memory.h" -#include "libmng_cms.h" -#include "libmng_filter.h" -#include "libmng_pixels.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_DISPLAY_PROCS - -/* TODO: magnification & canvas-positioning/-clipping */ - -/* TODO: major optimization of pixel-loops by using assembler (?) */ - -/* ************************************************************************** */ -/* * * */ -/* * Interlace tables * */ -/* * * */ -/* ************************************************************************** */ - -mng_uint32 const interlace_row [7] = { 0, 0, 4, 0, 2, 0, 1 }; -mng_uint32 const interlace_rowskip [7] = { 8, 8, 8, 4, 4, 2, 2 }; -mng_uint32 const interlace_col [7] = { 0, 4, 0, 2, 0, 1, 0 }; -mng_uint32 const interlace_colskip [7] = { 8, 8, 4, 4, 2, 2, 1 }; -mng_uint32 const interlace_roundoff [7] = { 7, 7, 3, 3, 1, 1, 0 }; -mng_uint32 const interlace_divider [7] = { 3, 3, 2, 2, 1, 1, 0 }; - -/* ************************************************************************** */ -/* * * */ -/* * Alpha composing macros * */ -/* * the code below is slightly modified from the libpng package * */ -/* * the original was last optimized by Greg Roelofs & Mark Adler * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_COMPOSE8(RET,FG,ALPHA,BG) { \ - mng_uint16 iH = (mng_uint16)((mng_uint16)(FG) * (mng_uint16)(ALPHA) \ - + (mng_uint16)(BG)*(mng_uint16)(255 - \ - (mng_uint16)(ALPHA)) + (mng_uint16)128); \ - (RET) = (mng_uint8)((iH + (iH >> 8)) >> 8); } - -#define MNG_COMPOSE16(RET,FG,ALPHA,BG) { \ - mng_uint32 iH = (mng_uint32)((mng_uint32)(FG) * (mng_uint32)(ALPHA) \ - + (mng_uint32)(BG)*(mng_uint32)(65535L - \ - (mng_uint32)(ALPHA)) + (mng_uint32)32768L); \ - (RET) = (mng_uint16)((iH + (iH >> 16)) >> 16); } - -/* ************************************************************************** */ -/* * * */ -/* * Alpha blending macros * */ -/* * this code is based on Adam Costello's "Note on Compositing" from the * */ -/* * mng-list which gives the following formula: * */ -/* * * */ -/* * top pixel = (Rt, Gt, Bt, At) * */ -/* * bottom pixel = (Rb, Gb, Bb, Ab) * */ -/* * composite pixel = (Rc, Gc, Bc, Ac) * */ -/* * * */ -/* * all values in the range 0..1 * */ -/* * * */ -/* * Ac = 1 - (1 - At)(1 - Ab) * */ -/* * s = At / Ac * */ -/* * t = (1 - At) Ab / Ac * */ -/* * Rc = s Rt + t Rb * */ -/* * Gc = s Gt + t Gb * */ -/* * Bc = s Bt + t Bb * */ -/* * * */ -/* * (I just hope I coded it correctly in integer arithmetic...) * */ -/* * * */ -/* ************************************************************************** */ - -#define MNG_BLEND8(RT, GT, BT, AT, RB, GB, BB, AB, RC, GC, BC, AC) { \ - mng_uint32 S, T; \ - (AC) = (mng_uint8)((mng_uint32)255 - \ - ((((mng_uint32)255 - (mng_uint32)(AT)) * \ - ((mng_uint32)255 - (mng_uint32)(AB)) ) >> 8)); \ - S = (mng_uint32)(((mng_uint32)(AT) << 8) / \ - (mng_uint32)(AC)); \ - T = (mng_uint32)(((mng_uint32)255 - (mng_uint32)(AT)) * \ - (mng_uint32)(AB) / (mng_uint32)(AC)); \ - (RC) = (mng_uint8)((S * (mng_uint32)(RT) + \ - T * (mng_uint32)(RB) + (mng_uint32)127) >> 8); \ - (GC) = (mng_uint8)((S * (mng_uint32)(GT) + \ - T * (mng_uint32)(GB) + (mng_uint32)127) >> 8); \ - (BC) = (mng_uint8)((S * (mng_uint32)(BT) + \ - T * (mng_uint32)(BB) + (mng_uint32)127) >> 8); } - -#define MNG_BLEND16(RT, GT, BT, AT, RB, GB, BB, AB, RC, GC, BC, AC) { \ - mng_uint32 S, T; \ - (AC) = (mng_uint16)((mng_uint32)65525 - \ - ((((mng_uint32)65535 - (mng_uint32)(AT)) * \ - ((mng_uint32)65535 - (mng_uint32)(AB)) ) >> 16)); \ - S = (mng_uint32)(((mng_uint32)(AT) << 16) / \ - (mng_uint32)(AC)); \ - T = (mng_uint32)(((mng_uint32)65535 - (mng_uint32)(AT)) * \ - (mng_uint32)(AB) / (mng_uint32)(AC)); \ - (RC) = (mng_uint16)((S * (mng_uint32)(RT) + \ - T * (mng_uint32)(RB) + (mng_uint32)32767) >> 16); \ - (GC) = (mng_uint16)((S * (mng_uint32)(GT) + \ - T * (mng_uint32)(GB) + (mng_uint32)32767) >> 16); \ - (BC) = (mng_uint16)((S * (mng_uint32)(BT) + \ - T * (mng_uint32)(BB) + (mng_uint32)32767) >> 16); } - -/* ************************************************************************** */ - -/* note a good optimizing compiler will optimize this */ -#define DIV255B8(x) (mng_uint8)(((x) + 127) / 255) -#define DIV255B16(x) (mng_uint16)(((x) + 32767) / 65535) - -/* ************************************************************************** */ -/* * * */ -/* * Progressive display check - checks to see if progressive display is * */ -/* * in order & indicates so * */ -/* * * */ -/* * The routine is called after a call to one of the display_xxx routines * */ -/* * if appropriate * */ -/* * * */ -/* * The refresh is warrented in the read_chunk routine (mng_read.c) * */ -/* * and only during read&display processing, since there's not much point * */ -/* * doing it from memory! * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode display_progressive_check (mng_datap pData) -{ - if ((pData->bDoProgressive) && /* need progressive display? */ - ((pData->eImagetype != mng_it_mng) || (pData->iDataheight > 300)) && - (pData->iDestb - pData->iDestt > 50) && (!pData->pCurraniobj)) - { - mng_int32 iC = pData->iRow + pData->iDestt - pData->iSourcet; - - if (iC % 20 == 0) /* every 20th line */ - pData->bNeedrefresh = MNG_TRUE; - - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Display routines - convert rowdata (which is already color-corrected) * */ -/* * to the output canvas, respecting the opacity information * */ -/* * * */ -/* ************************************************************************** */ - -void check_update_region (mng_datap pData) -{ /* determine actual canvas row */ - mng_int32 iRow = pData->iRow + pData->iDestt - pData->iSourcet; - /* check for change in update-region */ - if ((pData->iDestl < (mng_int32)pData->iUpdateleft) || (pData->iUpdateright == 0)) - pData->iUpdateleft = pData->iDestl; - - if (pData->iDestr > (mng_int32)pData->iUpdateright) - pData->iUpdateright = pData->iDestr; - - if ((iRow < (mng_int32)pData->iUpdatetop) || (pData->iUpdatebottom == 0)) - pData->iUpdatetop = iRow; - - if (iRow+1 > (mng_int32)pData->iUpdatebottom) - pData->iUpdatebottom = iRow+1; - - return; -} - -/* ************************************************************************** */ - -mng_retcode display_rgb8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGr16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGb16 >> 8); - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - } - else - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *pDataline, iA8, *pScanline ) - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iA8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iA8, *(pScanline+2)) - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_rgba8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *(pScanline+3) = *(pDataline+6); - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+3); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+3)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *(pScanline+3) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGr16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGb16 >> 8); - /* alpha remains fully opaque !!! */ - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iCr16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCb16 >> 8); - *(pScanline+3) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *pDataline, iFGa8, *pScanline ) - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iFGa8, *(pScanline+2)) - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8) - /* and return the composed values */ - *pScanline = iCr8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCb8; - *(pScanline+3) = iCa8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_argb8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8, MNG_LC_START) -#endif - - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+4); - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *(pDataline+2); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pScanline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *(pDataline+4); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+1)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+3)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16) - /* and return the composed values */ - /* alpha remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8)(iFGr16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+3) = (mng_uint8)(iFGb16 >> 8); - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+1)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+3)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iCa16 >> 8); - *(pScanline+1) = (mng_uint8)(iCr16 >> 8); - *(pScanline+2) = (mng_uint8)(iCg16 >> 8); - *(pScanline+3) = (mng_uint8)(iCb16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pScanline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *pDataline; - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *(pDataline+2); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do simple alpha composing */ - /* alpha itself remains fully opaque !!! */ - MNG_COMPOSE8 (*(pScanline+1), *pDataline, iFGa8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+1), iFGa8, *(pScanline+2)) - MNG_COMPOSE8 (*(pScanline+3), *(pDataline+2), iFGa8, *(pScanline+3)) - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+1), *(pScanline+2), *(pScanline+3), iBGa8, - iCr8, iCg8, iCb8, iCa8) - /* and return the composed values */ - *pScanline = iCa8; - *(pScanline+1) = iCr8; - *(pScanline+2) = iCg8; - *(pScanline+3) = iCb8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ARGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_rgb8_a8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pAlphaline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8_A8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination rows */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - pAlphaline = (mng_uint8p)pData->fGetalphaline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination rows starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pAlphaline = pAlphaline + pData->iCol + pData->iDestl; - - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *pAlphaline = *(pDataline+6); - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *pAlphaline = *(pDataline+3); - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pAlphaline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+4); - *pAlphaline = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGr16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGb16 >> 8); - /* alpha remains fully opaque !!! */ - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*pScanline ); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*(pScanline+2)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iCr16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCb16 >> 8); - *pAlphaline = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *pDataline; - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *(pDataline+2); - *pAlphaline = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *pDataline, iFGa8, *pScanline ) - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+2), iFGa8, *(pScanline+2)) - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *pScanline, *(pScanline+1), *(pScanline+2), iBGa8, - iCr8, iCg8, iCb8, iCa8) - /* and return the composed values */ - *pScanline = iCr8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCb8; - *pAlphaline = iCa8; - } - } - } - - pScanline += (pData->iColinc * 3); - pAlphaline += pData->iColinc; - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_RGB8_A8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_bgr8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iA16; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint8 iA8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol * 3) + (pData->iDestl * 3); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + (pData->iSourcel / pData->iColinc) * 8; - else - pDataline = pDataline + (pData->iSourcel / pData->iColinc) * 4; - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha value */ - iA16 = mng_get_uint16 (pDataline+6); - - if (iA16) /* any opacity at all ? */ - { - if (iA16 == 0xFFFF) /* fully opaque ? */ - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - } - else - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iA16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iA16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iA16, iBGb16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGb16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGr16 >> 8); - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iA8 = *(pDataline+3); /* get alpha value */ - - if (iA8) /* any opacity at all ? */ - { - if (iA8 == 0xFF) /* fully opaque ? */ - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - } - else - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *(pDataline+2), iA8, *pScanline ) - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iA8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *pDataline, iA8, *(pScanline+2)) - } - } - - pScanline += (pData->iColinc * 3); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGR8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_bgra8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+6); - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+3); - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*(pScanline+3)); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+4); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+6); - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iFGb16 >> 8); - *(pScanline+1) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGr16 >> 8); - /* alpha remains fully opaque !!! */ - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+2)); - iBGg16 = (mng_uint16)(*(pScanline+1)); - iBGb16 = (mng_uint16)(*pScanline ); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iCb16 >> 8); - *(pScanline+1) = (mng_uint8)(iCg16 >> 8); - *(pScanline+2) = (mng_uint8)(iCr16 >> 8); - *(pScanline+3) = (mng_uint8)(iCa16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *(pScanline+3); - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+2); - *(pScanline+1) = *(pDataline+1); - *(pScanline+2) = *pDataline; - *(pScanline+3) = *(pDataline+3); - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do alpha composing */ - MNG_COMPOSE8 (*pScanline, *(pDataline+2), iFGa8, *pScanline ) - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+1), iFGa8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *pDataline, iFGa8, *(pScanline+2)) - /* alpha remains fully opaque !!! */ - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+2), *(pScanline+1), *pScanline, iBGa8, - iCr8, iCg8, iCb8, iCa8) - /* and return the composed values */ - *pScanline = iCb8; - *(pScanline+1) = iCg8; - *(pScanline+2) = iCr8; - *(pScanline+3) = iCa8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_bgra8_pm (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint32 s, t; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8PM, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - if ((s = pDataline[6]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[4]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { - pScanline[0] = DIV255B8(s * pDataline[4]); - pScanline[1] = DIV255B8(s * pDataline[2]); - pScanline[2] = DIV255B8(s * pDataline[0]); - pScanline[3] = (mng_uint8)s; - } - } - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values and premultiply */ - if ((s = pDataline[3]) == 0) - *(mng_uint32*) pScanline = 0; /* set all components = 0 */ - else - { - if (s == 255) - { - pScanline[0] = pDataline[2]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { - pScanline[0] = DIV255B8(s * pDataline[2]); - pScanline[1] = DIV255B8(s * pDataline[1]); - pScanline[2] = DIV255B8(s * pDataline[0]); - pScanline[3] = (mng_uint8)s; - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - if ((s = pDataline[6]) != 0) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if (s == 255) - { /* plain copy it */ - pScanline[0] = pDataline[4]; - pScanline[1] = pDataline[2]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = DIV255B8(s * pDataline[4] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[2] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[0] + t * pScanline[2]); - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - if ((s = pDataline[3]) != 0) /* any opacity at all ? */ - { /* fully opaque ? */ - if (s == 255) - { /* then simply copy the values */ - pScanline[0] = pDataline[2]; - pScanline[1] = pDataline[1]; - pScanline[2] = pDataline[0]; - pScanline[3] = 255; - } - else - { /* now blend (premultiplied) */ - t = 255 - s; - pScanline[0] = DIV255B8(s * pDataline[2] + t * pScanline[0]); - pScanline[1] = DIV255B8(s * pDataline[1] + t * pScanline[1]); - pScanline[2] = DIV255B8(s * pDataline[0] + t * pScanline[2]); - pScanline[3] = (mng_uint8)(255 - DIV255B8(t * (255 - pScanline[3]))); - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_BGRA8PM, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode display_abgr8 (mng_datap pData) -{ - mng_uint8p pScanline; - mng_uint8p pDataline; - mng_int32 iX; - mng_uint16 iFGa16, iBGa16, iCa16; - mng_uint8 iFGa8, iBGa8, iCa8; - mng_uint16 iFGr16, iFGg16, iFGb16; - mng_uint16 iBGr16, iBGg16, iBGb16; - mng_uint16 iCr16, iCg16, iCb16; - mng_uint8 iCr8, iCg8, iCb8; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8, MNG_LC_START) -#endif - /* viewable row ? */ - if ((pData->iRow >= pData->iSourcet) && (pData->iRow < pData->iSourceb)) - { /* address destination row */ - pScanline = (mng_uint8p)pData->fGetcanvasline (((mng_handle)pData), - pData->iRow + pData->iDestt - - pData->iSourcet); - /* adjust destination row starting-point */ - pScanline = pScanline + (pData->iCol << 2) + (pData->iDestl << 2); - pDataline = pData->pRGBArow; /* address source row */ - - if (pData->bIsRGBA16) /* adjust source row starting-point */ - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 3); - else - pDataline = pDataline + ((pData->iSourcel / pData->iColinc) << 2); - - if (pData->bIsOpaque) /* forget about transparency ? */ - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* scale down by dropping the LSB */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *(pDataline+4); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *pDataline; - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *pDataline; - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - else - { - if (pData->bIsRGBA16) /* 16-bit input row ? */ - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { /* get alpha values */ - iFGa16 = mng_get_uint16 (pDataline+6); - iBGa16 = (mng_uint16)(*pScanline); - iBGa16 = (mng_uint16)(iBGa16 << 8) | iBGa16; - - if (iFGa16) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa16 == 0xFFFF) || (iBGa16 == 0)) - { /* plain copy it */ - *pScanline = *(pDataline+6); - *(pScanline+1) = *(pDataline+4); - *(pScanline+2) = *(pDataline+2); - *(pScanline+3) = *pDataline; - } - else - { - if (iBGa16 == 0xFFFF) /* background fully opaque ? */ - { /* get the proper values */ - iFGr16 = mng_get_uint16 (pDataline ); - iFGg16 = mng_get_uint16 (pDataline+2); - iFGb16 = mng_get_uint16 (pDataline+4); - /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+3)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+1)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* now compose */ - MNG_COMPOSE16(iFGr16, iFGr16, iFGa16, iBGr16) - MNG_COMPOSE16(iFGg16, iFGg16, iFGa16, iBGg16) - MNG_COMPOSE16(iFGb16, iFGb16, iFGa16, iBGb16) - /* and return the composed values */ - /* alpha itself remains fully opaque !!! */ - *(pScanline+1) = (mng_uint8)(iFGb16 >> 8); - *(pScanline+2) = (mng_uint8)(iFGg16 >> 8); - *(pScanline+3) = (mng_uint8)(iFGr16 >> 8); - } - else - { /* scale background up */ - iBGr16 = (mng_uint16)(*(pScanline+3)); - iBGg16 = (mng_uint16)(*(pScanline+2)); - iBGb16 = (mng_uint16)(*(pScanline+1)); - iBGr16 = (mng_uint16)((mng_uint32)iBGr16 << 8) | iBGr16; - iBGg16 = (mng_uint16)((mng_uint32)iBGg16 << 8) | iBGg16; - iBGb16 = (mng_uint16)((mng_uint32)iBGb16 << 8) | iBGb16; - /* let's blend */ - MNG_BLEND16 (mng_get_uint16 (pDataline ), - mng_get_uint16 (pDataline+2), - mng_get_uint16 (pDataline+4), iFGa16, - iBGr16, iBGg16, iBGb16, iBGa16, - iCr16, iCg16, iCb16, iCa16) - /* and return the composed values */ - *pScanline = (mng_uint8)(iCa16 >> 8); - *(pScanline+1) = (mng_uint8)(iCb16 >> 8); - *(pScanline+2) = (mng_uint8)(iCg16 >> 8); - *(pScanline+3) = (mng_uint8)(iCr16 >> 8); - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 8; - } - } - else - { - for (iX = pData->iSourcel + pData->iCol; iX < pData->iSourcer; iX += pData->iColinc) - { - iFGa8 = *(pDataline+3); /* get alpha values */ - iBGa8 = *pScanline; - - if (iFGa8) /* any opacity at all ? */ - { /* fully opaque or background fully transparent ? */ - if ((iFGa8 == 0xFF) || (iBGa8 == 0)) - { /* then simply copy the values */ - *pScanline = *(pDataline+3); - *(pScanline+1) = *(pDataline+2); - *(pScanline+2) = *(pDataline+1); - *(pScanline+3) = *pDataline; - } - else - { - if (iBGa8 == 0xFF) /* background fully opaque ? */ - { /* do simple alpha composing */ - /* alpha itself remains fully opaque !!! */ - MNG_COMPOSE8 (*(pScanline+1), *(pDataline+2), iFGa8, *(pScanline+1)) - MNG_COMPOSE8 (*(pScanline+2), *(pDataline+1), iFGa8, *(pScanline+2)) - MNG_COMPOSE8 (*(pScanline+3), *pDataline, iFGa8, *(pScanline+3)) - } - else - { /* now blend */ - MNG_BLEND8 (*pDataline, *(pDataline+1), *(pDataline+2), iFGa8, - *(pScanline+3), *(pScanline+2), *(pScanline+1), iBGa8, - iCr8, iCg8, iCb8, iCa8) - /* and return the composed values */ - *pScanline = iCa8; - *(pScanline+1) = iCb8; - *(pScanline+2) = iCg8; - *(pScanline+3) = iCr8; - } - } - } - - pScanline += (pData->iColinc << 2); - pDataline += 4; - } - } - } - } - - check_update_region (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_ABGR8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Background restore routines - restore the background with info from * */ -/* * the BACK and/or bKGD chunk or the app's background canvas * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode restore_bkgd_backimage (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKIMAGE, MNG_LC_START) -#endif - /* make it easy on yourself */ - iRetcode = restore_bkgd_backcolor (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - - /* TODO: loading the background-image */ - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKIMAGE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_bkgd_backcolor (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKCOLOR, MNG_LC_START) -#endif - - for (iX = pData->iSourcel; iX < pData->iSourcer; iX++) - { /* ok; drop the background-color in there */ - *pWork = (mng_uint8)(pData->iBACKred >> 8); - *(pWork+1) = (mng_uint8)(pData->iBACKgreen >> 8); - *(pWork+2) = (mng_uint8)(pData->iBACKblue >> 8); - *(pWork+3) = 0xFF; /* opaque! it's mandatory */ - - pWork += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BACKCOLOR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_bkgd_bkgd (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pWork = pData->pRGBArow; - mng_imagep pImage; - mng_imagedatap pBuf; - mng_uint8 iRed = 0; - mng_uint8 iGreen = 0; - mng_uint8 iBlue = 0; - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BKGD, MNG_LC_START) -#endif - /* determine the correct image buffer */ - pImage = (mng_imagep)pData->pCurrentobj; - - if (!pImage) - pImage = (mng_imagep)pData->pObjzero; - - pBuf = pImage->pImgbuf; - - switch (pBuf->iColortype) - { - case 0 : ; /* gray types */ - case 4 : { - mng_uint8 iGray; - - if (pBuf->iBitdepth > 8) - iGray = (mng_uint8)(pBuf->iBKGDgray >> 8); - else - { - iGray = (mng_uint8)pBuf->iBKGDgray; - /* please note how tricky the next code is !! */ - switch (pBuf->iBitdepth) - { - case 1 : iGray = (mng_uint8)((iGray << 1) + iGray); - case 2 : iGray = (mng_uint8)((iGray << 2) + iGray); - case 4 : iGray = (mng_uint8)((iGray << 4) + iGray); - } - } - - iRed = iGray; - iGreen = iGray; - iBlue = iGray; - - break; - } - - case 3 : { /* indexed type */ - iRed = pBuf->aPLTEentries [pBuf->iBKGDindex].iRed; - iGreen = pBuf->aPLTEentries [pBuf->iBKGDindex].iGreen; - iBlue = pBuf->aPLTEentries [pBuf->iBKGDindex].iBlue; - - break; - } - - case 2 : ; /* rgb types */ - case 6 : { - if (pBuf->iBitdepth > 8) - { - iRed = (mng_uint8)(pBuf->iBKGDred >> 8); - iGreen = (mng_uint8)(pBuf->iBKGDgreen >> 8); - iBlue = (mng_uint8)(pBuf->iBKGDblue >> 8); - } - else - { - iRed = (mng_uint8)(pBuf->iBKGDred ); - iGreen = (mng_uint8)(pBuf->iBKGDgreen); - iBlue = (mng_uint8)(pBuf->iBKGDblue ); - } - - break; - } - } - - for (iX = pData->iSourcel; iX < pData->iSourcer; iX++) - { - *pWork = iRed; - *(pWork+1) = iGreen; - *(pWork+2) = iBlue; - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_bkgd_bgcolor (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGCOLOR, MNG_LC_START) -#endif - - for (iX = pData->iSourcel; iX < pData->iSourcer; iX++) - { /* ok; drop the background-color in there */ - *pWork = (mng_uint8)(pData->iBGred >> 8); - *(pWork+1) = (mng_uint8)(pData->iBGgreen >> 8); - *(pWork+2) = (mng_uint8)(pData->iBGblue >> 8); - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGCOLOR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_bkgd_rgb8 (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pBkgd; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_RGB8, MNG_LC_START) -#endif - - if (pData->fGetbkgdline) /* can we access the background ? */ - { /* point to the right pixel then */ - pBkgd = (mng_uint8p)pData->fGetbkgdline ((mng_handle)pData, - pData->iRow + pData->iDestt) + - (3 * pData->iDestl); - - for (iX = pData->iSourcel; iX < pData->iSourcer; iX++) - { - *pWork = *pBkgd; /* ok; copy the pixel */ - *(pWork+1) = *(pBkgd+1); - *(pWork+2) = *(pBkgd+2); - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - pBkgd += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode restore_bkgd_bgr8 (mng_datap pData) -{ - mng_int32 iX; - mng_uint8p pBkgd; - mng_uint8p pWork = pData->pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGR8, MNG_LC_START) -#endif - - if (pData->fGetbkgdline) /* can we access the background ? */ - { /* point to the right pixel then */ - pBkgd = (mng_uint8p)pData->fGetbkgdline ((mng_handle)pData, - pData->iRow + pData->iDestt) + - (3 * pData->iDestl); - - for (iX = pData->iSourcel; iX < pData->iSourcer; iX++) - { - *pWork = *(pBkgd+2); /* ok; copy the pixel */ - *(pWork+1) = *(pBkgd+1); - *(pWork+2) = *pBkgd; - *(pWork+3) = 0x00; /* transparant for alpha-canvasses */ - - pWork += 4; - pBkgd += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RESTORE_BGR8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Row retrieval routines - retrieve processed & uncompressed row-data * */ -/* * from the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -/* TODO: a serious optimization is to retrieve only those pixels that will - actually be displayed; this would require changes in - the "display_image" routine (in mng_display.c) & - all the "retrieve_xxx" routines below & - the "display_xxx" routines above !!!!! - NOTE that "correct_xxx" routines would not require modification */ - -mng_retcode retrieve_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G8, MNG_LC_START) -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = *pWorkrow; /* get the gray-value */ - /* is it transparent ? */ - if ((mng_uint16)iG == pBuf->iTRNSgray) - { - *pRGBArow = 0x00; /* nuttin to display */ - *(pRGBArow+1) = 0x00; - *(pRGBArow+2) = 0x00; - *(pRGBArow+3) = 0x00; - } - else - { - switch (pBuf->iBitdepth) /* LBR to 8-bits ! */ - { - case 1 : iG = (mng_uint8)((iG << 1) + iG); - case 2 : iG = (mng_uint8)((iG << 2) + iG); - case 4 : iG = (mng_uint8)((iG << 4) + iG); - } - - *pRGBArow = iG; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iG; - *(pRGBArow+3) = 0xFF; - } - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = *pWorkrow; /* get the gray-value */ - - switch (pBuf->iBitdepth) /* LBR to 8-bits ! */ - { - case 1 : iG = (mng_uint8)((iG << 1) + iG); - case 2 : iG = (mng_uint8)((iG << 2) + iG); - case 4 : iG = (mng_uint8)((iG << 4) + iG); - } - - *pRGBArow = iG; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iG; - *(pRGBArow+3) = 0xFF; - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G16, MNG_LC_START) -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = mng_get_uint16 (pWorkrow); /* get the gray-value */ - /* is it transparent ? */ - if (iG == pBuf->iTRNSgray) - { /* nuttin to display */ - mng_put_uint16 (pRGBArow, 0x0000); - mng_put_uint16 (pRGBArow+2, 0x0000); - mng_put_uint16 (pRGBArow+4, 0x0000); - mng_put_uint16 (pRGBArow+6, 0x0000); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iG); - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iG); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pWorkrow += 2; /* next pixel */ - pRGBArow += 8; - } - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = mng_get_uint16 (pWorkrow); /* get the gray-value */ - - mng_put_uint16 (pRGBArow, iG); /* and put in intermediate row */ - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iG); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pWorkrow += 2; /* next pixel */ - pRGBArow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iR, iG, iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB8, MNG_LC_START) -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iR = *pWorkrow; /* get the rgb-values */ - iG = *(pWorkrow+1); - iB = *(pWorkrow+2); - /* is it transparent ? */ - if (((mng_uint16)iR == pBuf->iTRNSred ) && - ((mng_uint16)iG == pBuf->iTRNSgreen) && - ((mng_uint16)iB == pBuf->iTRNSblue ) ) - { - *pRGBArow = 0x00; /* nothing to display */ - *(pRGBArow+1) = 0x00; - *(pRGBArow+2) = 0x00; - *(pRGBArow+3) = 0x00; - } - else - { - *pRGBArow = iR; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; - } - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRGBArow = *pWorkrow; /* just copy the pixel */ - *(pRGBArow+1) = *(pWorkrow+1); - *(pRGBArow+2) = *(pWorkrow+2); - *(pRGBArow+3) = 0xFF; - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iR, iG, iB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB16, MNG_LC_START) -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iR = mng_get_uint16 (pWorkrow); /* get the rgb-values */ - iG = mng_get_uint16 (pWorkrow+2); - iB = mng_get_uint16 (pWorkrow+4); - /* is it transparent ? */ - if ((iR == pBuf->iTRNSred ) && - (iG == pBuf->iTRNSgreen) && - (iB == pBuf->iTRNSblue ) ) - { /* nothing to display */ - mng_put_uint16 (pRGBArow, 0x0000); - mng_put_uint16 (pRGBArow+2, 0x0000); - mng_put_uint16 (pRGBArow+4, 0x0000); - mng_put_uint16 (pRGBArow+6, 0x0000); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iR); - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iB); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* just copy the pixel */ - mng_put_uint16 (pRGBArow, mng_get_uint16 (pWorkrow )); - mng_put_uint16 (pRGBArow+2, mng_get_uint16 (pWorkrow+2)); - mng_put_uint16 (pRGBArow+4, mng_get_uint16 (pWorkrow+4)); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_idx8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_IDX8, MNG_LC_START) -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - if (pBuf->bHasTRNS) /* tRNS in buffer ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iQ = *pWorkrow; /* get the index */ - /* is it valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - *(pRGBArow+3) = pBuf->aTRNSentries [iQ]; - else - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iQ = *pWorkrow; /* get the index */ - /* is it valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pWorkrow++; /* next pixel */ - pRGBArow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_IDX8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA8, MNG_LC_START) -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = *pWorkrow; /* get the gray-value */ - *pRGBArow = iG; /* put in intermediate row */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iG; - *(pRGBArow+3) = *(pWorkrow+1); - - pWorkrow += 2; /* next pixel */ - pRGBArow += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iG; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iG = mng_get_uint16 (pWorkrow); /* get the gray-value */ - - mng_put_uint16 (pRGBArow, iG); /* and put in intermediate row */ - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iG); - mng_put_uint16 (pRGBArow+6, mng_get_uint16 (pWorkrow+2)); - - pWorkrow += 4; /* next pixel */ - pRGBArow += 8; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_GA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA8, MNG_LC_START) -#endif - - pRGBArow = pData->pRGBArow; /* temporary work pointers */ - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - /* can't be easier than this ! */ - MNG_COPY (pRGBArow, pWorkrow, pBuf->iRowsize) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode retrieve_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pRetrieveobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pRGBArow = pData->pRGBArow; - pWorkrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize); - /* can't be easier than this ! */ - MNG_COPY (pRGBArow, pWorkrow, pBuf->iRowsize) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_RETRIEVE_RGBA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode store_g1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - *pOutrow = 0x01; /* white */ - else - *pOutrow = 0x00; /* black */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_g2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - iQ = (mng_uint8)((iB & iM) >> iS); /* get the gray level */ - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_g4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - - iQ = (mng_uint8)((iB & iM) >> iS); /* get the gray level */ - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* copy into object buffer */ - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow)); - - pOutrow += (pData->iColinc << 1); /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* copy the RGB bytes */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - - pWorkrow += 3; /* next pixel */ - pOutrow += (pData->iColinc * 3); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - MNG_COPY (pOutrow, pWorkrow, 6) /* copy the RGB bytes */ - - pWorkrow += 6; /* next pixel */ - pOutrow += (pData->iColinc * 6); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_idx1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* store the index */ - *pOutrow = 0x01; - else - *pOutrow = 0x00; - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_idx2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* store the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_idx4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* store the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_idx8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_IDX8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* copy the GA bytes */ - *(pOutrow+1) = *(pWorkrow+1); - - pWorkrow += 2; /* next pixel */ - pOutrow += (pData->iColinc << 1); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - MNG_COPY (pOutrow, pWorkrow, 4) /* copy the GA bytes */ - - pWorkrow += 4; /* next pixel */ - pOutrow += (pData->iColinc << 2); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_GA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* copy the RGBA bytes */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - - pWorkrow += 4; /* next pixel */ - pOutrow += (pData->iColinc << 2); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode store_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - MNG_COPY (pOutrow, pWorkrow, 8) /* copy the RGBA bytes */ - - pWorkrow += 8; /* next pixel */ - pOutrow += (pData->iColinc << 3); - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_RGBA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines (JPEG) - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8, MNG_LC_START) -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - /* easy as pie ... */ - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8, MNG_LC_END) -#endif - - return next_jpeg_row (pData); /* we've got one more row of gray-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8, MNG_LC_START) -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - /* easy as pie ... */ - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples * 3) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8, MNG_LC_END) -#endif - - return next_jpeg_row (pData); /* we've got one more row of rgb-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_GA8, MNG_LC_START) -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* copy into object buffer */ - - pOutrow += 2; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_GA8, MNG_LC_END) -#endif - - return next_jpeg_row (pData); /* we've got one more row of gray-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGBA8, MNG_LC_START) -#endif - - pWorkrow = pData->pJPEGrow; /* temporary work pointers */ - pOutrow = pBuf->pImgdata + (pData->iJPEGrow * pBuf->iRowsize); - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* copy pixel into object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - - pOutrow += 4; /* next pixel */ - pWorkrow += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGBA8, MNG_LC_END) -#endif - - return next_jpeg_row (pData); /* we've got one more row of rgb-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_alpha (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_ALPHA, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pJPEGrow2; - pOutrow = pBuf->pImgdata + (pData->iJPEGalpharow * pBuf->iRowsize) + 1; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += 2; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_ALPHA, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_alpha (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_ALPHA, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pJPEGrow2; - pOutrow = pBuf->pImgdata + (pData->iJPEGalpharow * pBuf->iRowsize) + 3; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += 4; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_ALPHA, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_a1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - iM = 0; /* start at pixel 0 */ - iB = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it opaque ? */ - *pOutrow = 0xFF; /* opaque */ - else - *pOutrow = 0x00; /* transparent */ - - pOutrow += 2; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A1, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_a2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - switch ((iB & iM) >> iS) /* determine the alpha level */ - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } - - pOutrow += 2; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A2, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_a4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the alpha level */ - iQ = (mng_uint8)((iB & iM) >> iS); - iQ = (mng_uint8)(iQ + (iQ << 4)); /* expand to 8-bit by replication */ - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += 2; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A4, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += 2; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A8, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* only high-order byte! */ - - pOutrow += 2; /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G8_A16, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_a1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - iM = 0; /* start at pixel 0 */ - iB = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it opaque ? */ - *pOutrow = 0xFF; /* opaque */ - else - *pOutrow = 0x00; /* transparent */ - - pOutrow += 4; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A1, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_a2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - switch ((iB & iM) >> iS) /* determine the alpha level */ - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } - - pOutrow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A2, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_a4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the alpha level */ - iQ = (mng_uint8)((iB & iM) >> iS); - iQ = (mng_uint8)(iQ + (iQ << 4)); /* expand to 8-bit by replication */ - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A4, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in buffer */ - - pOutrow += 4; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A8, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_rgb8_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* only high-order byte */ - - pOutrow += 4; /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_RGB8_A16, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g12_a1 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - iM = 0; /* start at pixel 0 */ - iB = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* opaque ? */ - mng_put_uint16 (pOutrow, 0xFFFF);/* opaque */ - else - mng_put_uint16 (pOutrow, 0x0000);/* transparent */ - - pOutrow += 4; /* next pixel */ - iM >>= 1; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A1, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g12_a2 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - switch ((iB & iM) >> iS) /* determine the gray level */ - { - case 0x03 : { mng_put_uint16 (pOutrow, 0xFFFF); break; } - case 0x02 : { mng_put_uint16 (pOutrow, 0xAAAA); break; } - case 0x01 : { mng_put_uint16 (pOutrow, 0x5555); break; } - default : { mng_put_uint16 (pOutrow, 0x0000); } - } - - pOutrow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A2, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g12_a4 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint16 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint16)((iB & iM) >> iS); - iQ = (mng_uint16)(iQ + (iQ << 4)); /* expand to 16-bit by replication */ - iQ = (mng_uint16)(iQ + (iQ << 8)); - /* put in object buffer */ - mng_put_uint16 (pOutrow, iQ); - - pOutrow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A4, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g12_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iW = (mng_uint16)(*pWorkrow); /* get input byte */ - iW = (mng_uint16)(iW + (iW << 8)); /* expand to 16-bit by replication */ - - mng_put_uint16 (pOutrow, iW); /* put in object buffer */ - - pOutrow += 4; /* next pixel */ - pWorkrow++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A8, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -mng_retcode store_jpeg_g12_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 2; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* copy it */ - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow)); - - pOutrow += 4; /* next pixel */ - pWorkrow += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_STORE_JPEG_G12_A16, MNG_LC_END) -#endif - - return next_jpeg_alpharow (pData); /* we've got one more row of alpha-samples */ -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the processed & uncompressed row-data * */ -/* * onto the target "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode delta_g1 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - *pOutrow = 0xFF; /* white */ - else - *pOutrow = 0x00; /* black */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* invert if it is white ? */ - *pOutrow = (mng_uint8)(*pOutrow ^ 0xFF); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1, MNG_LC_END) -#endif - - return store_g1 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_g2 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - switch ((iB & iM) >> iS) /* determine the gray level */ - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* determine the gray level */ - switch (((*pOutrow >> 6) + ((iB & iM) >> iS)) & 0x03) - { - case 0x03 : { *pOutrow = 0xFF; break; } - case 0x02 : { *pOutrow = 0xAA; break; } - case 0x01 : { *pOutrow = 0x55; break; } - default : { *pOutrow = 0x00; } - } - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2, MNG_LC_END) -#endif - - return store_g2 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_g4 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* expand to 8-bit by replication */ - iQ = (mng_uint8)(iQ + (iQ << 4)); - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)(((*pOutrow >> 4) + ((iB & iM) >> iS)) & 0x0F); - /* expand to 8-bit by replication */ - iQ = (mng_uint8)(iQ + (iQ << 4)); - - *pOutrow = iQ; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4, MNG_LC_END) -#endif - - return store_g4 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow); - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8, MNG_LC_END) -#endif - - return store_g8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow) )); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16, MNG_LC_END) -#endif - - return store_g16 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - /* next pixel */ - pOutrow += (pData->iColinc * 3); - pWorkrow += 3; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow ); - *(pOutrow+1) = (mng_uint8)(*(pOutrow+1) + *(pWorkrow+1)); - *(pOutrow+2) = (mng_uint8)(*(pOutrow+2) + *(pWorkrow+2)); - /* next pixel */ - pOutrow += (pData->iColinc * 3); - pWorkrow += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8, MNG_LC_END) -#endif - - return store_rgb8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - *(pOutrow+4) = *(pWorkrow+4); - *(pOutrow+5) = *(pWorkrow+5); - /* next pixel */ - pOutrow += (pData->iColinc * 6); - pWorkrow += 6; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow ) )); - mng_put_uint16 (pOutrow+2, (mng_uint16)(mng_get_uint16 (pOutrow+2 ) + - mng_get_uint16 (pWorkrow+2) )); - mng_put_uint16 (pOutrow+4, (mng_uint16)(mng_get_uint16 (pOutrow+4 ) + - mng_get_uint16 (pWorkrow+4) )); - /* next pixel */ - pOutrow += (pData->iColinc * 6); - pWorkrow += 6; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16, MNG_LC_END) -#endif - - return store_rgb16 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_idx1 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX1, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* put the right index value */ - *pOutrow = 1; - else - *pOutrow = 0; - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* invert if it is non-zero index */ - *pOutrow = (mng_uint8)(*pOutrow ^ 0x01); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 1; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX1, MNG_LC_END) -#endif - - return store_idx1 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_idx2 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX2, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* put the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* calculate the index */ - *pOutrow = (mng_uint8)((*pOutrow + ((iB & iM) >> iS)) & 0x03); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 2; - iS -= 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX2, MNG_LC_END) -#endif - - return store_idx2 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_idx4 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX4, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* put the index */ - *pOutrow = (mng_uint8)((iB & iM) >> iS); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* calculate the index */ - *pOutrow = (mng_uint8)((*pOutrow + ((iB & iM) >> iS)) & 0x0F); - - pOutrow += pData->iColinc; /* next pixel */ - iM >>= 4; - iS -= 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX4, MNG_LC_END) -#endif - - return store_idx4 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_idx8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow); - - pOutrow += pData->iColinc; /* next pixel */ - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_IDX8, MNG_LC_END) -#endif - - return store_idx8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow ); - *(pOutrow+1) = (mng_uint8)(*(pOutrow+1) + *(pWorkrow+1)); - /* next pixel */ - pOutrow += (pData->iColinc << 1); - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8, MNG_LC_END) -#endif - - return store_ga8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow ) )); - mng_put_uint16 (pOutrow+2, (mng_uint16)(mng_get_uint16 (pOutrow+2 ) + - mng_get_uint16 (pWorkrow+2) )); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16, MNG_LC_END) -#endif - - return store_ga16 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; /* put in object buffer */ - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - *(pOutrow+3) = *(pWorkrow+3); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - *pOutrow = (mng_uint8)(*pOutrow + *pWorkrow ); - *(pOutrow+1) = (mng_uint8)(*(pOutrow+1) + *(pWorkrow+1)); - *(pOutrow+2) = (mng_uint8)(*(pOutrow+2) + *(pWorkrow+2)); - *(pOutrow+3) = (mng_uint8)(*(pOutrow+3) + *(pWorkrow+3)); - /* next pixel */ - pOutrow += (pData->iColinc << 2); - pWorkrow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8, MNG_LC_END) -#endif - - return store_rgba8 (pData); -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pDeltaImage)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iDeltaBlocky * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + - (pData->iDeltaBlockx * pBuf->iSamplesize); - /* pixel replace ? */ - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - MNG_COPY (pOutrow, pWorkrow, 8) /* put in object buffer */ - /* next pixel */ - pOutrow += (pData->iColinc << 3); - pWorkrow += 8; - } - } - else - { /* pixel add ! */ - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* add to object buffer */ - mng_put_uint16 (pOutrow, (mng_uint16)(mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow ) )); - mng_put_uint16 (pOutrow+2, (mng_uint16)(mng_get_uint16 (pOutrow+2 ) + - mng_get_uint16 (pWorkrow+2) )); - mng_put_uint16 (pOutrow+4, (mng_uint16)(mng_get_uint16 (pOutrow+4 ) + - mng_get_uint16 (pWorkrow+4) )); - mng_put_uint16 (pOutrow+6, (mng_uint16)(mng_get_uint16 (pOutrow+6 ) + - mng_get_uint16 (pWorkrow+6) )); - /* next pixel */ - pOutrow += (pData->iColinc << 3); - pWorkrow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16, MNG_LC_END) -#endif - - return store_rgba16 (pData); -} - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the source row onto the target * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode delta_g1_g1 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1_G1, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0x01); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G1_G1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_g2_g2 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2_G2, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0x03); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G2_G2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_g4_g4 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4_G4, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0x0F); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G4_G4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_g8_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8_G8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G8_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_g16_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16_G16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples << 1)) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 2; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_G16_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgb8_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8_RGB8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples * 3) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < (pData->iRowsamples * 3); iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB8_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgb16_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16_RGB16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples * 6)) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - mng_put_uint16 (pOutrow+4, (mng_uint16)((mng_get_uint16 (pOutrow+4) + - mng_get_uint16 (pWorkrow+4)) & 0xFFFF)); - - pOutrow += 6; - pWorkrow += 6; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGB16_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga8_ga8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_GA8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples << 1) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < (pData->iRowsamples << 1); iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_GA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga8_g8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_G8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; - - pOutrow += 2; - pWorkrow++; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow += 2; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_A8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 1; - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; - - pOutrow += 2; - pWorkrow++; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow += 2; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA8_A8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga16_ga16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_GA16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples << 2)) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - - pOutrow += 4; - pWorkrow += 4; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_GA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga16_g16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_A16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow)); - - pOutrow += 4; - pWorkrow += 2; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 4; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_A16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_ga16_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_G16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow+2, mng_get_uint16 (pWorkrow)); - - pOutrow += 4; - pWorkrow += 2; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 4; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_GA16_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba8_rgba8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGBA8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, pData->iRowsamples << 2) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < (pData->iRowsamples << 2); iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow++; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba8_rgb8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGB8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; - *(pOutrow+1) = *(pWorkrow+1); - *(pOutrow+2) = *(pWorkrow+2); - - pOutrow += 4; - pWorkrow += 3; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow ) & 0xFF); - *(pOutrow+1) = (mng_uint8)(((mng_uint16)*(pOutrow+1) + - (mng_uint16)*(pWorkrow+1)) & 0xFF); - *(pOutrow+2) = (mng_uint8)(((mng_uint16)*(pOutrow+2) + - (mng_uint16)*(pWorkrow+2)) & 0xFF); - - pOutrow += 4; - pWorkrow += 3; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba8_a8 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_A8, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize) + 3; - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = *pWorkrow; - - pOutrow += 4; - pWorkrow++; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pOutrow = (mng_uint8)(((mng_uint16)*pOutrow + - (mng_uint16)*pWorkrow) & 0xFF); - - pOutrow += 4; - pWorkrow++; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA8_A8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba16_rgba16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGBA16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - MNG_COPY (pOutrow, pWorkrow, (pData->iRowsamples << 3)) - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - mng_put_uint16 (pOutrow+4, (mng_uint16)((mng_get_uint16 (pOutrow+4) + - mng_get_uint16 (pWorkrow+4)) & 0xFFFF)); - mng_put_uint16 (pOutrow+6, (mng_uint16)((mng_get_uint16 (pOutrow+6) + - mng_get_uint16 (pWorkrow+6)) & 0xFFFF)); - - pOutrow += 8; - pWorkrow += 8; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGBA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba16_rgb16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGB16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, mng_get_uint16 (pWorkrow )); - mng_put_uint16 (pOutrow+2, mng_get_uint16 (pWorkrow+2)); - mng_put_uint16 (pOutrow+4, mng_get_uint16 (pWorkrow+4)); - - pOutrow += 8; - pWorkrow += 6; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow, (mng_uint16)((mng_get_uint16 (pOutrow ) + - mng_get_uint16 (pWorkrow )) & 0xFFFF)); - mng_put_uint16 (pOutrow+2, (mng_uint16)((mng_get_uint16 (pOutrow+2) + - mng_get_uint16 (pWorkrow+2)) & 0xFFFF)); - mng_put_uint16 (pOutrow+4, (mng_uint16)((mng_get_uint16 (pOutrow+4) + - mng_get_uint16 (pWorkrow+4)) & 0xFFFF)); - - pOutrow += 8; - pWorkrow += 6; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode delta_rgba16_a16 (mng_datap pData) -{ - mng_imagedatap pBuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - mng_uint8p pWorkrow; - mng_uint8p pOutrow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_A16, MNG_LC_START) -#endif - - pWorkrow = pData->pRGBArow; - pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + - (pData->iCol * pBuf->iSamplesize); - - if ((pData->iDeltatype == MNG_DELTATYPE_REPLACE ) || - (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) ) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow+6, mng_get_uint16 (pWorkrow)); - - pOutrow += 8; - pWorkrow += 2; - } - } - else - if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELADD) - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - mng_put_uint16 (pOutrow+6, (mng_uint16)((mng_get_uint16 (pOutrow+6) + - mng_get_uint16 (pWorkrow)) & 0xFFFF)); - - pOutrow += 8; - pWorkrow += 2; - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DELTA_RGBA16_A16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - scale the source to bitdepth of target * */ -/* * * */ -/* ************************************************************************** */ - - - -/* ************************************************************************** */ -/* * * */ -/* * Row processing routines - convert uncompressed data from zlib to * */ -/* * managable row-data which serves as input to the color-management * */ -/* * routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode process_g1 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G1, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - if (pBuf->iTRNSgray) /* white transparent ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - /* transparent ! */ - mng_put_uint32 (pRGBArow, 0x00000000); - else /* opaque black */ - mng_put_uint32 (pRGBArow, 0x000000FF); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - } - } - else /* black transparent */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - /* opaque white */ - mng_put_uint32 (pRGBArow, 0xFFFFFFFF); - else /* transparent */ - mng_put_uint32 (pRGBArow, 0x00000000); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - } - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else /* no transparency */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - } - - if (iB & iM) /* is it white ? */ - /* opaque white */ - mng_put_uint32 (pRGBArow, 0xFFFFFFFF); - else /* opaque black */ - mng_put_uint32 (pRGBArow, 0x000000FF); - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_g2 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G2, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* determine gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - - if (iQ == pBuf->iTRNSgray) /* transparent ? */ - mng_put_uint32 (pRGBArow, 0x00000000); - else - { - switch (iQ) /* determine the gray level */ - { - case 0x03 : { mng_put_uint32 (pRGBArow, 0xFFFFFFFF); break; } - case 0x02 : { mng_put_uint32 (pRGBArow, 0xAAAAAAFF); break; } - case 0x01 : { mng_put_uint32 (pRGBArow, 0x555555FF); break; } - default : { mng_put_uint32 (pRGBArow, 0x000000FF); } - } - } - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - - switch ((iB & iM) >> iS) /* determine the gray level */ - { - case 0x03 : { mng_put_uint32 (pRGBArow, 0xFFFFFFFF); break; } - case 0x02 : { mng_put_uint32 (pRGBArow, 0xAAAAAAFF); break; } - case 0x01 : { mng_put_uint32 (pRGBArow, 0x555555FF); break; } - default : { mng_put_uint32 (pRGBArow, 0x000000FF); } - } - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_g4 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G4, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - - if (iQ == pBuf->iTRNSgray) /* transparent ? */ - { - *pRGBArow = 0; /* put in intermediate row */ - *(pRGBArow+1) = 0; - *(pRGBArow+2) = 0; - *(pRGBArow+3) = 0; - } - else - { /* expand to 8-bit by replication */ - iQ = (mng_uint8)(iQ + (iQ << 4)); - - *pRGBArow = iQ; /* put in intermediate row */ - *(pRGBArow+1) = iQ; - *(pRGBArow+2) = iQ; - *(pRGBArow+3) = 0xFF; - } - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the gray level */ - iQ = (mng_uint8)((iB & iM) >> iS); - iQ = (mng_uint8)(iQ + (iQ << 4));/* expand to 8-bit by replication */ - - *pRGBArow = iQ; /* put in intermediate row */ - *(pRGBArow+1) = iQ; - *(pRGBArow+2) = iQ; - *(pRGBArow+3) = 0xFF; - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_g8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G8, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iB = *pWorkrow; /* get next input-byte */ - - if (iB == pBuf->iTRNSgray) /* transparent ? */ - { - *pRGBArow = 0; /* put in intermediate row */ - *(pRGBArow+1) = 0; - *(pRGBArow+2) = 0; - *(pRGBArow+3) = 0; - } - else - { - *pRGBArow = iB; /* put in intermediate row */ - *(pRGBArow+1) = iB; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; - } - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iB = *pWorkrow; /* get next input-byte */ - - *pRGBArow = iB; /* put in intermediate row */ - *(pRGBArow+1) = iB; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_g16 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iW; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G16, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iW = mng_get_uint16 (pWorkrow); /* get input */ - - if (iW == pBuf->iTRNSgray) /* transparent ? */ - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, 0); - mng_put_uint16 (pRGBArow+2, 0); - mng_put_uint16 (pRGBArow+4, 0); - mng_put_uint16 (pRGBArow+6, 0); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iW); - mng_put_uint16 (pRGBArow+2, iW); - mng_put_uint16 (pRGBArow+4, iW); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pRGBArow += 8; /* next pixel */ - pWorkrow += 2; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iW = mng_get_uint16 (pWorkrow); /* get input */ - - mng_put_uint16 (pRGBArow, iW); /* and put in intermediate row */ - mng_put_uint16 (pRGBArow+2, iW); - mng_put_uint16 (pRGBArow+4, iW); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pRGBArow += 8; /* next pixel */ - pWorkrow += 2; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_G16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_rgb8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iR, iG, iB; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB8, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iR = *pWorkrow; /* get the RGB values */ - iG = *(pWorkrow+1); - iB = *(pWorkrow+2); - /* transparent ? */ - if ((iR == pBuf->iTRNSred) && (iG == pBuf->iTRNSgreen) && - (iB == pBuf->iTRNSblue)) - { - *pRGBArow = 0; /* this pixel is transparent ! */ - *(pRGBArow+1) = 0; - *(pRGBArow+2) = 0; - *(pRGBArow+3) = 0; - } - else - { - *pRGBArow = iR; /* copy the RGB values */ - *(pRGBArow+1) = iG; - *(pRGBArow+2) = iB; - *(pRGBArow+3) = 0xFF; /* this one isn't transparent */ - } - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRGBArow = *pWorkrow; /* copy the RGB bytes */ - *(pRGBArow+1) = *(pWorkrow+1); - *(pRGBArow+2) = *(pWorkrow+2); - *(pRGBArow+3) = 0xFF; /* no alpha; so always fully opaque */ - - pWorkrow += 3; /* next pixel */ - pRGBArow += 4; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_rgb16 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iR, iG, iB; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB16, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iR = mng_get_uint16 (pWorkrow); /* get the RGB values */ - iG = mng_get_uint16 (pWorkrow+2); - iB = mng_get_uint16 (pWorkrow+4); - /* transparent ? */ - if ((iR == pBuf->iTRNSred) && (iG == pBuf->iTRNSgreen) && - (iB == pBuf->iTRNSblue)) - { /* transparent then */ - mng_put_uint16 (pRGBArow, 0); - mng_put_uint16 (pRGBArow+2, 0); - mng_put_uint16 (pRGBArow+4, 0); - mng_put_uint16 (pRGBArow+6, 0); - } - else - { /* put in intermediate row */ - mng_put_uint16 (pRGBArow, iR); - mng_put_uint16 (pRGBArow+2, iG); - mng_put_uint16 (pRGBArow+4, iB); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - } - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { /* copy the RGB values */ - mng_put_uint16 (pRGBArow, mng_get_uint16 (pWorkrow )); - mng_put_uint16 (pRGBArow+2, mng_get_uint16 (pWorkrow+2)); - mng_put_uint16 (pRGBArow+4, mng_get_uint16 (pWorkrow+4)); - mng_put_uint16 (pRGBArow+6, 0xFFFF); - - pWorkrow += 6; /* next pixel */ - pRGBArow += 8; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGB16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_idx1 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX1, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - iS = 7; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - *(pRGBArow+3) = pBuf->aTRNSentries [iQ]; - else - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - iS -= 1; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0x80; - iS = 7; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 1; - iS -= 1; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_idx2 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX2, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - *(pRGBArow+3) = pBuf->aTRNSentries [iQ]; - else - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = *pWorkrow; /* get next input-byte */ - pWorkrow++; - iM = 0xC0; - iS = 6; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - *pRGBArow = pBuf->aPLTEentries [iQ].iRed; - *(pRGBArow+1) = pBuf->aPLTEentries [iQ].iGreen; - *(pRGBArow+2) = pBuf->aPLTEentries [iQ].iBlue; - *(pRGBArow+3) = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 2; - iS -= 2; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_idx4 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iB; - mng_uint8 iM; - mng_uint32 iS; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX4, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - iM = 0; /* start at pixel 0 */ - iB = 0; - iS = 0; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = pWorkrow [0]; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - pRGBArow [3] = pBuf->aTRNSentries [iQ]; - else - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - if (!iM) /* mask underflow ? */ - { - iB = pWorkrow [0]; /* get next input-byte */ - pWorkrow++; - iM = 0xF0; - iS = 4; - } - /* get the index */ - iQ = (mng_uint8)((iB & iM) >> iS); - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - iM >>= 4; - iS -= 4; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_idx8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint8 iQ; - mng_imagedatap pBuf = (mng_imagedatap)pData->pStorebuf; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX8, MNG_LC_START) -#endif - - if (!pBuf) /* no object? then use obj 0 */ - pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf; - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - if (pBuf->bHasTRNS) /* tRNS encountered ? */ - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iQ = *pWorkrow; /* get input byte */ - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - /* transparency for this index ? */ - if ((mng_uint32)iQ < pBuf->iTRNScount) - pRGBArow [3] = pBuf->aTRNSentries [iQ]; - else - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_FALSE; /* it's not fully opaque */ - } - else - { - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iQ = *pWorkrow; /* get input byte */ - /* index valid ? */ - if ((mng_uint32)iQ < pBuf->iPLTEcount) - { /* put in intermediate row */ - pRGBArow [0] = pBuf->aPLTEentries [iQ].iRed; - pRGBArow [1] = pBuf->aPLTEentries [iQ].iGreen; - pRGBArow [2] = pBuf->aPLTEentries [iQ].iBlue; - pRGBArow [3] = 0xFF; - } - else - MNG_ERROR (pData, MNG_PLTEINDEXERROR) - - pRGBArow += 4; /* next pixel */ - pWorkrow++; - } - - pData->bIsOpaque = MNG_TRUE; /* it's fully opaque */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_IDX8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ga8 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA8, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - *pRGBArow = *pWorkrow; /* copy the gray value */ - *(pRGBArow+1) = *pWorkrow; - *(pRGBArow+2) = *pWorkrow; - *(pRGBArow+3) = *(pWorkrow+1); /* copy the alpha value */ - - pWorkrow += 2; /* next pixel */ - pRGBArow += 4; - } - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_ga16 (mng_datap pData) -{ - mng_uint8p pWorkrow; - mng_uint8p pRGBArow; - mng_int32 iX; - mng_uint16 iW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA16, MNG_LC_START) -#endif - /* temporary work pointers */ - pWorkrow = pData->pWorkrow + pData->iPixelofs; - pRGBArow = pData->pRGBArow; - - for (iX = 0; iX < pData->iRowsamples; iX++) - { - iW = mng_get_uint16 (pWorkrow); /* copy the gray value */ - mng_put_uint16 (pRGBArow, iW); - mng_put_uint16 (pRGBArow+2, iW); - mng_put_uint16 (pRGBArow+4, iW); - /* copy the alpha value */ - mng_put_uint16 (pRGBArow+6, mng_get_uint16 (pWorkrow+2)); - - pWorkrow += 4; /* next pixel */ - pRGBArow += 8; - } - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_GA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_rgba8 (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA8, MNG_LC_START) -#endif - /* this is the easiest transform */ - MNG_COPY (pData->pRGBArow, pData->pWorkrow + pData->iPixelofs, pData->iRowsize) - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA8, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_rgba16 (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA16, MNG_LC_START) -#endif - /* this is the easiest transform */ - MNG_COPY (pData->pRGBArow, pData->pWorkrow + pData->iPixelofs, pData->iRowsize) - - pData->bIsOpaque = MNG_FALSE; /* it's definitely not fully opaque */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RGBA16, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines - set up the variables needed * */ -/* * to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode init_g1_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g1; - else - pData->fStorerow = (mng_fptr)store_g1; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g1; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g1_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g1; - else - pData->fStorerow = (mng_fptr)store_g1; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g1; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = ((pData->iRowsamples + 7) >> 3); - pData->iRowmax = ((pData->iDatawidth + 7) >> 3) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G1_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g2_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g2; - else - pData->fStorerow = (mng_fptr)store_g2; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g2; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g2_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g2; - else - pData->fStorerow = (mng_fptr)store_g2; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g2; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = ((pData->iRowsamples + 3) >> 2); - pData->iRowmax = ((pData->iDatawidth + 3) >> 2) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G2_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g4_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g4; - else - pData->fStorerow = (mng_fptr)store_g4; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g4; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g4_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g4; - else - pData->fStorerow = (mng_fptr)store_g4; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g4; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = ((pData->iRowsamples + 1) >> 1); - pData->iRowmax = ((pData->iDatawidth + 1) >> 1) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G4_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g8; - else - pData->fStorerow = (mng_fptr)store_g8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g8; - else - pData->fStorerow = (mng_fptr)store_g8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g8; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iDatawidth + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G8_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g16; - else - pData->fStorerow = (mng_fptr)store_g16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g16; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_g16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_g16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_g16; - else - pData->fStorerow = (mng_fptr)store_g16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g16; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = (pData->iDatawidth << 1) + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_G16_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgb8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgb8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgb8; - else - pData->fStorerow = (mng_fptr)store_rgb8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgb8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 3; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 3; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgb8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgb8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgb8; - else - pData->fStorerow = (mng_fptr)store_rgb8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgb8; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 3; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 3; - pData->iRowmax = (pData->iDatawidth * 3) + pData->iPixelofs; - pData->iFilterbpp = 3; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB8_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgb16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgb16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgb16; - else - pData->fStorerow = (mng_fptr)store_rgb16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgb16; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 6; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 6; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 6; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgb16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgb16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgb16; - else - pData->fStorerow = (mng_fptr)store_rgb16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgb16; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 6; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples * 6; - pData->iRowmax = (pData->iDatawidth * 6) + pData->iPixelofs; - pData->iFilterbpp = 6; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGB16_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx1_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx1; - else - pData->fStorerow = (mng_fptr)store_idx1; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx1; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx1_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx1; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx1; - else - pData->fStorerow = (mng_fptr)store_idx1; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx1; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = ((pData->iDatawidth + 7) >> 3) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX1_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx2_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx2; - else - pData->fStorerow = (mng_fptr)store_idx2; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx2; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx2_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx2; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx2; - else - pData->fStorerow = (mng_fptr)store_idx2; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx2; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = ((pData->iDatawidth + 3) >> 2) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX2_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx4_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx4; - else - pData->fStorerow = (mng_fptr)store_idx4; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx4; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx4_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx4; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx4; - else - pData->fStorerow = (mng_fptr)store_idx4; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx4; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = ((pData->iDatawidth + 1) >> 1) + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX4_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx8; - else - pData->fStorerow = (mng_fptr)store_idx8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_idx8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_idx8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_idx8; - else - pData->fStorerow = (mng_fptr)store_idx8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_idx8; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iDatawidth + pData->iPixelofs; - pData->iFilterbpp = 1; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_IDX8_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_ga8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_ga8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_ga8; - else - pData->fStorerow = (mng_fptr)store_ga8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_ga8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_ga8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_ga8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_ga8; - else - pData->fStorerow = (mng_fptr)store_ga8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_ga8; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = (pData->iDatawidth << 1) + pData->iPixelofs; - pData->iFilterbpp = 2; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA8_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_ga16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_ga16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_ga16; - else - pData->fStorerow = (mng_fptr)store_ga16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_ga16; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_ga16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_ga16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_ga16; - else - pData->fStorerow = (mng_fptr)store_ga16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_ga16; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = (pData->iDatawidth << 2) + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_GA16_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgba8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgba8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgba8; - else - pData->fStorerow = (mng_fptr)store_rgba8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgba8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgba8_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgba8; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgba8; - else - pData->fStorerow = (mng_fptr)store_rgba8; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgba8; - - pData->iPass = 0; /* from 0..6; is 1..7 in specifications */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 4; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 2; - pData->iRowmax = (pData->iDatawidth << 2) + pData->iPixelofs; - pData->iFilterbpp = 4; - pData->bIsRGBA16 = MNG_FALSE; /* intermediate row is 8-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA8_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgba16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_NI, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgba16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgba16; - else - pData->fStorerow = (mng_fptr)store_rgba16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgba16; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 8; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 8; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_rgba16_i (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_I, MNG_LC_START) -#endif - - if (pData->fDisplayrow) - pData->fProcessrow = (mng_fptr)process_rgba16; - - if (pData->pStoreobj) /* store in object too ? */ - { /* immediate delta ? */ - if ((pData->bHasDHDR) && (pData->bDeltaimmediate)) - pData->fStorerow = (mng_fptr)delta_rgba16; - else - pData->fStorerow = (mng_fptr)store_rgba16; - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_rgba16; - - pData->iPass = 0; /* from 0..6; (1..7 in specification) */ - pData->iRow = interlace_row [0]; - pData->iRowinc = interlace_rowskip [0]; - pData->iCol = interlace_col [0]; - pData->iColinc = interlace_colskip [0]; - pData->iRowsamples = (pData->iDatawidth + interlace_roundoff [0]) >> interlace_divider [0]; - pData->iSamplemul = 8; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 3; - pData->iRowmax = (pData->iDatawidth << 3) + pData->iPixelofs; - pData->iFilterbpp = 8; - pData->bIsRGBA16 = MNG_TRUE; /* intermediate row is 16-bit deep */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_RGBA16_I, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines (JPEG) - set up the variables * */ -/* * needed to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ - -mng_retcode init_jpeg_a1_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A1_NI, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)store_jpeg_g8_a1; break; } - case 14 : { pData->fStorerow = (mng_fptr)store_jpeg_rgb8_a1; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g1; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 7; - pData->iSamplediv = 3; - pData->iRowsize = (pData->iRowsamples + 7) >> 3; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A1_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_jpeg_a2_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A2_NI, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)store_jpeg_g8_a2; break; } - case 14 : { pData->fStorerow = (mng_fptr)store_jpeg_rgb8_a2; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g2; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 3; - pData->iSamplediv = 2; - pData->iRowsize = (pData->iRowsamples + 3) >> 2; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A2_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_jpeg_a4_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A4_NI, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)store_jpeg_g8_a4; break; } - case 14 : { pData->fStorerow = (mng_fptr)store_jpeg_rgb8_a4; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g4; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 1; - pData->iSamplediv = 1; - pData->iRowsize = (pData->iRowsamples + 1) >> 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A4_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_jpeg_a8_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A8_NI, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)store_jpeg_g8_a8; break; } - case 14 : { pData->fStorerow = (mng_fptr)store_jpeg_rgb8_a8; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g8; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 1; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 1; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A8_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -mng_retcode init_jpeg_a16_ni (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A16_NI, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* store in object too ? */ - { - if (pData->iJHDRimgbitdepth == 8) - { - switch (pData->iJHDRcolortype) - { - case 12 : { pData->fStorerow = (mng_fptr)store_jpeg_g8_a16; break; } - case 14 : { pData->fStorerow = (mng_fptr)store_jpeg_rgb8_a16; break; } - } - } - - /* TODO: bitdepth 12 & 20 */ - - } - - if (pData->iFilter & 0x40) /* leveling & differing ? */ - pData->fDifferrow = (mng_fptr)differ_g16; - - pData->iPass = -1; - pData->iRow = 0; - pData->iRowinc = 1; - pData->iCol = 0; - pData->iColinc = 1; - pData->iRowsamples = pData->iDatawidth; - pData->iSamplemul = 2; - pData->iSampleofs = 0; - pData->iSamplediv = 0; - pData->iRowsize = pData->iRowsamples << 1; - pData->iRowmax = pData->iRowsize + pData->iPixelofs; - pData->iFilterbpp = 2; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_JPEG_A16_NI, MNG_LC_END) -#endif - - return init_rowproc (pData); -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ -/* * * */ -/* * Generic row processing initialization & cleanup routines * */ -/* * - initialize the buffers used by the row processing routines * */ -/* * - cleanup the buffers used by the row processing routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode init_rowproc (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWPROC, MNG_LC_START) -#endif - - if (pData->pStoreobj) /* storage object selected ? */ - { - pData->pStorebuf = ((mng_imagep)pData->pStoreobj)->pImgbuf; - /* and so it becomes viewable ! */ - ((mng_imagep)pData->pStoreobj)->bViewable = MNG_TRUE; - ((mng_imagedatap)pData->pStorebuf)->bViewable = MNG_TRUE; - } - - /* allocate the buffers; the individual init routines have already - calculated the required maximum size; except in the case of a JNG - without alpha!!! */ - if (pData->iRowmax) - { - MNG_ALLOC (pData, pData->pWorkrow, pData->iRowmax) - MNG_ALLOC (pData, pData->pPrevrow, pData->iRowmax) - } - - /* allocate an RGBA16 row for intermediate processing */ - MNG_ALLOC (pData, pData->pRGBArow, (pData->iDatawidth << 3)); - -#ifndef MNG_NO_CMS - if (pData->fDisplayrow) /* display "on-the-fly" ? */ - { -#if defined(MNG_FULL_CMS) /* determine color-management initialization */ - mng_retcode iRetcode = init_full_cms (pData); -#elif defined(MNG_GAMMA_ONLY) - mng_retcode iRetcode = init_gamma_only (pData); -#elif defined(MNG_APP_CMS) - mng_retcode iRetcode = init_app_cms (pData); -#endif - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif /* !MNG_NO_CMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INIT_ROWPROC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode next_row (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_ROW, MNG_LC_START) -#endif - - pData->iRow += pData->iRowinc; /* increase the row counter */ - - if (pData->iPass >= 0) /* interlaced ? */ - { - while ((pData->iPass < 7) && /* went 'outside' the image ? */ - ((pData->iRow >= (mng_int32)pData->iDataheight) || - (pData->iCol >= (mng_int32)pData->iDatawidth ) )) - { - pData->iPass++; /* next pass ! */ - - if (pData->iPass < 7) /* there's only 7 passes ! */ - { - pData->iRow = interlace_row [pData->iPass]; - pData->iRowinc = interlace_rowskip [pData->iPass]; - pData->iCol = interlace_col [pData->iPass]; - pData->iColinc = interlace_colskip [pData->iPass]; - pData->iRowsamples = (pData->iDatawidth - pData->iCol + interlace_roundoff [pData->iPass]) - >> interlace_divider [pData->iPass]; - - if (pData->iSamplemul > 1) /* recalculate row dimension */ - pData->iRowsize = pData->iRowsamples * pData->iSamplemul; - else - if (pData->iSamplediv > 0) - pData->iRowsize = (pData->iRowsamples + pData->iSampleofs) >> pData->iSamplediv; - else - pData->iRowsize = pData->iRowsamples; - - } - - if ((pData->iPass < 7) && /* reset previous row to zeroes ? */ - (pData->iRow < (mng_int32)pData->iDataheight) && - (pData->iCol < (mng_int32)pData->iDatawidth ) ) - { /* making sure the filters will work properly! */ - mng_int32 iX; - mng_uint8p pTemp = pData->pPrevrow; - - for (iX = 0; iX < pData->iRowsize; iX++) - { - *pTemp = 0; - pTemp++; - } - } - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_ROW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode cleanup_rowproc (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEANUP_ROWPROC, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS /* cleanup cms profile/transform */ - mng_retcode iRetcode = mng_clear_cms (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; -#endif /* MNG_INCLUDE_LCMS */ - - if (pData->pWorkrow) /* cleanup buffer for working row */ - MNG_FREE (pData, pData->pWorkrow, pData->iRowmax) - - if (pData->pPrevrow) /* cleanup buffer for previous row */ - MNG_FREE (pData, pData->pPrevrow, pData->iRowmax) - - if (pData->pRGBArow) /* cleanup buffer for intermediate row */ - MNG_FREE (pData, pData->pRGBArow, (pData->iDatawidth << 3)) - - pData->pWorkrow = 0; /* propogate uninitialized buffers */ - pData->pPrevrow = 0; - pData->pRGBArow = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_CLEANUP_ROWPROC, MNG_LC_END) -#endif - - return MNG_NOERROR; /* woohiii */ -} - -/* ************************************************************************** */ -/* * * */ -/* * Generic row processing routines for JNG * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -/* ************************************************************************** */ - -mng_retcode display_jpeg_rows (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_JPEG_ROWS, MNG_LC_START) -#endif - /* any completed rows ? */ - if ((pData->iJPEGrow > pData->iJPEGdisprow) && - (pData->iJPEGalpharow > pData->iJPEGdisprow) ) - { - mng_uint32 iX, iMax; - mng_uint32 iSaverow = pData->iRow; /* save alpha decompression row-count */ - /* determine the highest complete(!) row */ - if (pData->iJPEGrow > pData->iJPEGalpharow) - iMax = pData->iJPEGalpharow; - else - iMax = pData->iJPEGrow; - /* display the rows */ - for (iX = pData->iJPEGdisprow; iX < iMax; iX++) - { - pData->iRow = iX; /* make sure we all know which row to handle */ - /* makeup an intermediate row from the buffer */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - /* color-correct it if necessary */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* and display it */ - { - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) /* check progressive display refresh */ - iRetcode = display_progressive_check (pData); - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - pData->iJPEGdisprow = iMax; /* keep track of the last displayed row */ - pData->iRow = iSaverow; /* restore alpha decompression row-count */ - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_DISPLAY_JPEG_ROWS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode next_jpeg_alpharow (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ALPHAROW, MNG_LC_START) -#endif - - pData->iJPEGalpharow++; /* count the row */ - - if (pData->fDisplayrow) /* display "on-the-fly" ? */ - { /* try to display what you can */ - iRetcode = display_jpeg_rows (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ALPHAROW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode next_jpeg_row (mng_datap pData) -{ - mng_retcode iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ROW, MNG_LC_START) -#endif - - pData->iJPEGrow++; /* increase the row-counter */ - - if (pData->fDisplayrow) /* display "on-the-fly" ? */ - { /* has alpha channel ? */ - if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) || - (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) ) - { /* try to display what you can */ - iRetcode = display_jpeg_rows (pData); - } - else - { /* make sure we all know which row to handle */ - pData->iRow = pData->iJPEGrow - 1; - /* makeup an intermediate row from the buffer */ - iRetcode = ((mng_retrieverow)pData->fRetrieverow) (pData); - /* color-correct it if necessary */ - if ((!iRetcode) && (pData->fCorrectrow)) - iRetcode = ((mng_correctrow)pData->fCorrectrow) (pData); - - if (!iRetcode) /* and display it */ - { - iRetcode = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRetcode) /* check progressive display refresh */ - iRetcode = display_progressive_check (pData); - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - } - - /* surpassed last filled row ? */ - if (pData->iJPEGrow > pData->iJPEGrgbrow) - pData->iJPEGrgbrow = pData->iJPEGrow; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_NEXT_JPEG_ROW, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -mng_retcode magnify_g8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X1, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_g8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 1; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { /* is it same as first ? */ - if (*pTempsrc1 == *pTempsrc2) - { - for (iS = 1; iS < iM; iS++) /* then just repeat the first */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) /* calculate the distances */ - { - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - pTempdst++; - } - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - } - } - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_g8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X3, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 1; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { /* is it same as first ? */ - if (*pTempsrc1 == *pTempsrc2) - { - for (iS = 1; iS < iM; iS++) /* then just repeat the first */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - } - else - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - pTempdst++; - } - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - } - } - } - - pTempsrc1++; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_X3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X1, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 3; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - } - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X3, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 3; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - - pTempdst += 3; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - - pTempdst += 3; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - } - } - } - - pTempsrc1 += 3; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_X3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X1, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X3, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - - pTempdst += 2; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - - pTempdst += 2; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X4, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - *pTempdst = *(pTempsrc1+1); /* replicate alpha from left */ - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - *pTempdst = *(pTempsrc2+1); /* replicate alpha from right */ - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X5, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 2; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - *pTempdst = *pTempsrc1; /* replicate gray from left */ - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1);/* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - *pTempdst = *pTempsrc2; /* replicate gray from right */ - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1);/* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - } - } - } - - pTempsrc1 += 2; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_X5, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX, iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X1, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - iM = iML; - else - if (iX == (iWidth - 1)) /* last interval ? */ - iM = iMR; - else - iM = iMX; - - for (iS = 1; iS < iM; iS++) /* fill interval */ - { - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - for (iS = 1; iS < iM; iS++) - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *pTempdst = *(pTempsrc1+3); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+3)) - - (mng_int32)(*(pTempsrc1+3)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+3)) ); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X3, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* replicate first half */ - { - *pTempdst = *pTempsrc1; - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - *(pTempdst+3) = *(pTempsrc1+3); - - pTempdst += 4; - } - - for (iS = iH; iS < iM; iS++) /* replicate second half */ - { - *pTempdst = *pTempsrc2; - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - *(pTempdst+3) = *(pTempsrc2+3); - - pTempdst += 4; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X4, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - /* replicate alpha from left */ - *pTempdst = *(pTempsrc1+3); - - pTempdst++; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; /* just repeat the first */ - else /* calculate the distance */ - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2)) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - - if (*(pTempsrc1+1) == *(pTempsrc2+1)) - *pTempdst = *(pTempsrc1+1); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+1)) - - (mng_int32)(*(pTempsrc1+1)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+1)) ); - - pTempdst++; - - if (*(pTempsrc1+2) == *(pTempsrc2+2)) - *pTempdst = *(pTempsrc1+2); - else - *pTempdst = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+2)) - - (mng_int32)(*(pTempsrc1+2)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+2)) ); - - pTempdst++; - /* replicate alpha from right */ - *pTempdst = *(pTempsrc2+3); - - pTempdst++; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_int32 iS, iM, iH; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X5, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline; /* initialize pixel-loop */ - pTempdst = pDstline; - - for (iX = 0; iX < iWidth; iX++) - { - pTempsrc2 = pTempsrc1 + 4; - - *pTempdst = *pTempsrc1; /* copy original source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - - if (iX == 0) /* first interval ? */ - { - if (iWidth == 1) /* single pixel ? */ - pTempsrc2 = MNG_NULL; - - iM = (mng_int32)iML; - } - else - if (iX == (iWidth - 2)) /* last interval ? */ - iM = (mng_int32)iMR; - else - iM = (mng_int32)iMX; - /* fill interval ? */ - if ((iX < iWidth - 1) || (iWidth == 1)) - { - if (pTempsrc2) /* do we have the second pixel ? */ - { - iH = (iM+1) / 2; /* calculate halfway point */ - - for (iS = 1; iS < iH; iS++) /* first half */ - { - *pTempdst = *pTempsrc1; /* replicate color from left */ - *(pTempdst+1) = *(pTempsrc1+1); - *(pTempdst+2) = *(pTempsrc1+2); - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *(pTempdst+3) = *(pTempsrc1+3); - else - *(pTempdst+3) = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+3)) - - (mng_int32)(*(pTempsrc1+3)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+3)) ); - - pTempdst += 4; - } - - for (iS = iH; iS < iM; iS++) /* second half */ - { - *pTempdst = *pTempsrc2; /* replicate color from right */ - *(pTempdst+1) = *(pTempsrc2+1); - *(pTempdst+2) = *(pTempsrc2+2); - - if (*(pTempsrc1+3) == *(pTempsrc2+3)) - *(pTempdst+3) = *(pTempsrc1+3); - else - *(pTempdst+3) = (mng_uint8)(((2 * iS * ( (mng_int32)(*(pTempsrc2+3)) - - (mng_int32)(*(pTempsrc1+3)) ) + iM) / - (iM * 2)) + (mng_int32)(*(pTempsrc1+3)) ); - - pTempdst += 4; - } - } - else - { - for (iS = 1; iS < iM; iS++) - { - *pTempdst = *pTempsrc1; /* repeat first source pixel */ - pTempdst++; - *pTempdst = *(pTempsrc1+1); - pTempdst++; - *pTempdst = *(pTempsrc1+2); - pTempdst++; - *pTempdst = *(pTempsrc1+3); - pTempdst++; - } - } - } - - pTempsrc1 += 4; - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_X4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_g8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y1, MNG_LC_START) -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_g8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_g8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y3, MNG_LC_START) -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth) - else - MNG_COPY (pDstline, pSrcline2, iWidth) - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_G8_Y3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y1, MNG_LC_START) -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth * 3) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth * 3) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgb8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y3, MNG_LC_START) -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth * 3) - else - MNG_COPY (pDstline, pSrcline2, iWidth * 3) - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth * 3) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGB8_Y3, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y1, MNG_LC_START) -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth << 1) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 1) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y3, MNG_LC_START) -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth << 1) - else - MNG_COPY (pDstline, pSrcline2, iWidth << 1) - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth << 1) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y4, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2 += 2; - - *pTempdst++ = *pTempsrc1++; /* replicate alpha from top */ - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1 += 2; - pTempsrc2++; - - *pTempdst++ = *pTempsrc2++; /* replicate alpha from bottom */ - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 1) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_ga8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y5, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc1; /* replicate gray from top */ - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst = *pTempsrc2; /* replicate gray from bottom */ - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 1) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_GA8_Y5, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y1, MNG_LC_START) -#endif - - MNG_COPY (pDstline, pSrcline1, iWidth << 2) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y1, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y2, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 2) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y3, MNG_LC_START) -#endif - - if (pSrcline2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - MNG_COPY (pDstline, pSrcline1, iWidth << 2) - else - MNG_COPY (pDstline, pSrcline2, iWidth << 2) - } - else - { /* just repeat the entire line */ - MNG_COPY (pDstline, pSrcline1, iWidth << 2) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y4, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2 += 2; - - *pTempdst++ = *pTempsrc1++; /* replicate alpha from top */ - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { /* calculate the distances */ - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - - if (*pTempsrc1 == *pTempsrc2) - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1 += 2; - pTempsrc2++; - - *pTempdst++ = *pTempsrc2++; /* replicate alpha from bottom */ - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 2) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y4, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode magnify_rgba8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline) -{ - mng_uint32 iX; - mng_uint8p pTempsrc1; - mng_uint8p pTempsrc2; - mng_uint8p pTempdst; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y5, MNG_LC_START) -#endif - - pTempsrc1 = pSrcline1; /* initialize pixel-loop */ - pTempsrc2 = pSrcline2; - pTempdst = pDstline; - - if (pTempsrc2) /* do we have a second line ? */ - { - if (iS < (iM+1) / 2) /* top half ? */ - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst++ = *pTempsrc1++; /* replicate color from top */ - *pTempdst++ = *pTempsrc1++; - *pTempdst++ = *pTempsrc1++; - - pTempsrc2 += 3; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - else - { - for (iX = 0; iX < iWidth; iX++) - { - *pTempdst++ = *pTempsrc2++; /* replicate color from bottom */ - *pTempdst++ = *pTempsrc2++; - *pTempdst++ = *pTempsrc2++; - - pTempsrc1 += 3; - - if (*pTempsrc1 == *pTempsrc2) /* calculate the distances */ - *pTempdst = *pTempsrc1; - else - *pTempdst = (mng_uint8)( ( (2 * iS * ( (mng_int32)(*pTempsrc2) - - (mng_int32)(*pTempsrc1) ) + iM) / - (iM * 2) ) + (mng_int32)(*pTempsrc1) ); - - pTempdst++; - pTempsrc1++; - pTempsrc2++; - } - } - } - else - { /* just repeat the entire line */ - MNG_COPY (pTempdst, pTempsrc1, iWidth << 2) - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_MAGNIFY_RGBA8_Y5, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_DISPLAY_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_pixels.h b/freeimage241/Source/LibMNG/libmng_pixels.h deleted file mode 100644 index aa97c70..0000000 --- a/freeimage241/Source/LibMNG/libmng_pixels.h +++ /dev/null @@ -1,570 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_pixels.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.1 * */ -/* * * */ -/* * purpose : Pixel-row management routines (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the pixel-row management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.5.2 - 05/22/2000 - G.Juyn * */ -/* * - added some JNG definitions * */ -/* * - added delta-image row-processing routines * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN support * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added optional support for bKGD for PNG images * */ -/* * - added support for JDAA * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_pixels_h_ -#define _libmng_pixels_h_ - -/* ************************************************************************** */ -/* * * */ -/* * Progressive display check - checks to see if progressive display is * */ -/* * in order & indicates so * */ -/* * * */ -/* * The routine is called after a call to one of the display_xxx routines * */ -/* * if appropriate * */ -/* * * */ -/* * The refresh is warrented in the read_chunk routine (mng_read.c) * */ -/* * and only during read&display processing, since there's not much point * */ -/* * doing it from memory! * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode display_progressive_check (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Display routines - convert rowdata (which is already color-corrected) * */ -/* * to the output canvas, respecting any transparency information * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode display_rgb8 (mng_datap pData); -mng_retcode display_rgba8 (mng_datap pData); -mng_retcode display_argb8 (mng_datap pData); -mng_retcode display_rgb8_a8 (mng_datap pData); -mng_retcode display_bgr8 (mng_datap pData); -mng_retcode display_bgra8 (mng_datap pData); -mng_retcode display_bgra8_pm (mng_datap pData); -mng_retcode display_abgr8 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Background restore routines - restore the background with info from * */ -/* * the BACK and/or bKGD chunk and/or the app's background canvas * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode restore_bkgd_backimage (mng_datap pData); -mng_retcode restore_bkgd_backcolor (mng_datap pData); -mng_retcode restore_bkgd_bkgd (mng_datap pData); -mng_retcode restore_bkgd_bgcolor (mng_datap pData); -mng_retcode restore_bkgd_rgb8 (mng_datap pData); -mng_retcode restore_bkgd_bgr8 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Row retrieval routines - retrieve processed & uncompressed row-data * */ -/* * from the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode retrieve_g8 (mng_datap pData); -mng_retcode retrieve_g16 (mng_datap pData); -mng_retcode retrieve_rgb8 (mng_datap pData); -mng_retcode retrieve_rgb16 (mng_datap pData); -mng_retcode retrieve_idx8 (mng_datap pData); -mng_retcode retrieve_ga8 (mng_datap pData); -mng_retcode retrieve_ga16 (mng_datap pData); -mng_retcode retrieve_rgba8 (mng_datap pData); -mng_retcode retrieve_rgba16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode store_g1 (mng_datap pData); -mng_retcode store_g2 (mng_datap pData); -mng_retcode store_g4 (mng_datap pData); -mng_retcode store_g8 (mng_datap pData); -mng_retcode store_g16 (mng_datap pData); -mng_retcode store_rgb8 (mng_datap pData); -mng_retcode store_rgb16 (mng_datap pData); -mng_retcode store_idx1 (mng_datap pData); -mng_retcode store_idx2 (mng_datap pData); -mng_retcode store_idx4 (mng_datap pData); -mng_retcode store_idx8 (mng_datap pData); -mng_retcode store_ga8 (mng_datap pData); -mng_retcode store_ga16 (mng_datap pData); -mng_retcode store_rgba8 (mng_datap pData); -mng_retcode store_rgba16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Row storage routines (JPEG) - store processed & uncompressed row-data * */ -/* * into the current "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode store_jpeg_g8 (mng_datap pData); -mng_retcode store_jpeg_rgb8 (mng_datap pData); -mng_retcode store_jpeg_ga8 (mng_datap pData); -mng_retcode store_jpeg_rgba8 (mng_datap pData); - -mng_retcode store_jpeg_g12 (mng_datap pData); -mng_retcode store_jpeg_rgb12 (mng_datap pData); -mng_retcode store_jpeg_ga12 (mng_datap pData); -mng_retcode store_jpeg_rgba12 (mng_datap pData); - -mng_retcode store_jpeg_g8_alpha (mng_datap pData); -mng_retcode store_jpeg_rgb8_alpha (mng_datap pData); - -mng_retcode store_jpeg_g8_a1 (mng_datap pData); -mng_retcode store_jpeg_g8_a2 (mng_datap pData); -mng_retcode store_jpeg_g8_a4 (mng_datap pData); -mng_retcode store_jpeg_g8_a8 (mng_datap pData); -mng_retcode store_jpeg_g8_a16 (mng_datap pData); - -mng_retcode store_jpeg_rgb8_a1 (mng_datap pData); -mng_retcode store_jpeg_rgb8_a2 (mng_datap pData); -mng_retcode store_jpeg_rgb8_a4 (mng_datap pData); -mng_retcode store_jpeg_rgb8_a8 (mng_datap pData); -mng_retcode store_jpeg_rgb8_a16 (mng_datap pData); - -mng_retcode store_jpeg_g12_a1 (mng_datap pData); -mng_retcode store_jpeg_g12_a2 (mng_datap pData); -mng_retcode store_jpeg_g12_a4 (mng_datap pData); -mng_retcode store_jpeg_g12_a8 (mng_datap pData); -mng_retcode store_jpeg_g12_a16 (mng_datap pData); - -mng_retcode store_jpeg_rgb12_a1 (mng_datap pData); -mng_retcode store_jpeg_rgb12_a2 (mng_datap pData); -mng_retcode store_jpeg_rgb12_a4 (mng_datap pData); -mng_retcode store_jpeg_rgb12_a8 (mng_datap pData); -mng_retcode store_jpeg_rgb12_a16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the processed & uncompressed row-data * */ -/* * onto the target "object" * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode delta_g1 (mng_datap pData); -mng_retcode delta_g2 (mng_datap pData); -mng_retcode delta_g4 (mng_datap pData); -mng_retcode delta_g8 (mng_datap pData); -mng_retcode delta_g16 (mng_datap pData); -mng_retcode delta_rgb8 (mng_datap pData); -mng_retcode delta_rgb16 (mng_datap pData); -mng_retcode delta_idx1 (mng_datap pData); -mng_retcode delta_idx2 (mng_datap pData); -mng_retcode delta_idx4 (mng_datap pData); -mng_retcode delta_idx8 (mng_datap pData); -mng_retcode delta_ga8 (mng_datap pData); -mng_retcode delta_ga16 (mng_datap pData); -mng_retcode delta_rgba8 (mng_datap pData); -mng_retcode delta_rgba16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - apply the source row onto the target * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode delta_g1_g1 (mng_datap pData); -mng_retcode delta_g2_g2 (mng_datap pData); -mng_retcode delta_g4_g4 (mng_datap pData); -mng_retcode delta_g8_g8 (mng_datap pData); -mng_retcode delta_g16_g16 (mng_datap pData); -mng_retcode delta_rgb8_rgb8 (mng_datap pData); -mng_retcode delta_rgb16_rgb16 (mng_datap pData); -mng_retcode delta_ga8_ga8 (mng_datap pData); -mng_retcode delta_ga8_g8 (mng_datap pData); -mng_retcode delta_ga8_a8 (mng_datap pData); -mng_retcode delta_ga16_ga16 (mng_datap pData); -mng_retcode delta_ga16_g16 (mng_datap pData); -mng_retcode delta_ga16_a16 (mng_datap pData); -mng_retcode delta_rgba8_rgba8 (mng_datap pData); -mng_retcode delta_rgba8_rgb8 (mng_datap pData); -mng_retcode delta_rgba8_a8 (mng_datap pData); -mng_retcode delta_rgba16_rgba16 (mng_datap pData); -mng_retcode delta_rgba16_rgb16 (mng_datap pData); -mng_retcode delta_rgba16_a16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Delta-image row routines - scale the source to bitdepth of target * */ -/* * * */ -/* ************************************************************************** */ - - - -/* ************************************************************************** */ -/* * * */ -/* * Row processing routines - convert uncompressed data from zlib to * */ -/* * managable row-data which serves as input to the color-management * */ -/* * routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode process_g1 (mng_datap pData); -mng_retcode process_g2 (mng_datap pData); -mng_retcode process_g4 (mng_datap pData); -mng_retcode process_g8 (mng_datap pData); -mng_retcode process_g16 (mng_datap pData); -mng_retcode process_rgb8 (mng_datap pData); -mng_retcode process_rgb16 (mng_datap pData); -mng_retcode process_idx1 (mng_datap pData); -mng_retcode process_idx2 (mng_datap pData); -mng_retcode process_idx4 (mng_datap pData); -mng_retcode process_idx8 (mng_datap pData); -mng_retcode process_ga8 (mng_datap pData); -mng_retcode process_ga16 (mng_datap pData); -mng_retcode process_rgba8 (mng_datap pData); -mng_retcode process_rgba16 (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines - set up the variables needed * */ -/* * to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode init_g1_ni (mng_datap pData); -mng_retcode init_g1_i (mng_datap pData); -mng_retcode init_g2_ni (mng_datap pData); -mng_retcode init_g2_i (mng_datap pData); -mng_retcode init_g4_ni (mng_datap pData); -mng_retcode init_g4_i (mng_datap pData); -mng_retcode init_g8_ni (mng_datap pData); -mng_retcode init_g8_i (mng_datap pData); -mng_retcode init_g16_ni (mng_datap pData); -mng_retcode init_g16_i (mng_datap pData); -mng_retcode init_rgb8_ni (mng_datap pData); -mng_retcode init_rgb8_i (mng_datap pData); -mng_retcode init_rgb16_ni (mng_datap pData); -mng_retcode init_rgb16_i (mng_datap pData); -mng_retcode init_idx1_ni (mng_datap pData); -mng_retcode init_idx1_i (mng_datap pData); -mng_retcode init_idx2_ni (mng_datap pData); -mng_retcode init_idx2_i (mng_datap pData); -mng_retcode init_idx4_ni (mng_datap pData); -mng_retcode init_idx4_i (mng_datap pData); -mng_retcode init_idx8_ni (mng_datap pData); -mng_retcode init_idx8_i (mng_datap pData); -mng_retcode init_ga8_ni (mng_datap pData); -mng_retcode init_ga8_i (mng_datap pData); -mng_retcode init_ga16_ni (mng_datap pData); -mng_retcode init_ga16_i (mng_datap pData); -mng_retcode init_rgba8_ni (mng_datap pData); -mng_retcode init_rgba8_i (mng_datap pData); -mng_retcode init_rgba16_ni (mng_datap pData); -mng_retcode init_rgba16_i (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Row processing initialization routines (JPEG) - set up the variables * */ -/* * needed to process uncompressed row-data * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode init_jpeg_a1_ni (mng_datap pData); -mng_retcode init_jpeg_a2_ni (mng_datap pData); -mng_retcode init_jpeg_a4_ni (mng_datap pData); -mng_retcode init_jpeg_a8_ni (mng_datap pData); -mng_retcode init_jpeg_a16_ni (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * General row processing routines * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode init_rowproc (mng_datap pData); -mng_retcode next_row (mng_datap pData); -mng_retcode next_jpeg_alpharow (mng_datap pData); -mng_retcode next_jpeg_row (mng_datap pData); -mng_retcode cleanup_rowproc (mng_datap pData); - -/* ************************************************************************** */ -/* * * */ -/* * Magnification row routines - apply magnification transforms * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode magnify_g8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_g8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_g8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_ga8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_ga8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_ga8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_ga8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_ga8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_x1 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_x2 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_x3 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_x4 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_x5 (mng_datap pData, - mng_uint16 iMX, - mng_uint16 iML, - mng_uint16 iMR, - mng_uint32 iWidth, - mng_uint8p pSrcline, - mng_uint8p pDstline); - -mng_retcode magnify_g8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_g8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_g8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgb8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_ga8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_ga8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_ga8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_ga8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_ga8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_y1 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_y2 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_y3 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_y4 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); -mng_retcode magnify_rgba8_y5 (mng_datap pData, - mng_int32 iS, - mng_int32 iM, - mng_uint32 iWidth, - mng_uint8p pSrcline1, - mng_uint8p pSrcline2, - mng_uint8p pDstline); - -/* ************************************************************************** */ - -#endif /* _libmng_pixels_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_prop_xs.c b/freeimage241/Source/LibMNG/libmng_prop_xs.c deleted file mode 100644 index 8ff252e..0000000 --- a/freeimage241/Source/LibMNG/libmng_prop_xs.c +++ /dev/null @@ -1,2322 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_prop_xs.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : property get/set interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the property get/set functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - fixed calling convention * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added set_outputprofile2 & set_srgbprofile2 * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - changed inclusion of cms-routines * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added support for get/set default zlib/IJG parms * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contribution by Tim Rowley) * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added support for RGB8_A8 canvasstyle * */ -/* * * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added get/set for speedtype to facilitate testing * */ -/* * - added get for imagelevel during processtext callback * */ -/* * 0.5.3 - 06/26/2000 - G.Juyn * */ -/* * - changed userdata variable to mng_ptr * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - fixed incompatible return-types * */ -/* * * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added get routines for internal display variables * */ -/* * - added get/set routines for suspensionmode variable * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added get/set routines for sectionbreak variable * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - added status_xxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_cms.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Property set functions * */ -/* * * */ -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_userdata (mng_handle hHandle, - mng_ptr pUserdata) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USERDATA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->pUserdata = pUserdata; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USERDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_canvasstyle (mng_handle hHandle, - mng_uint32 iStyle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CANVASSTYLE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - - switch (iStyle) - { - case MNG_CANVAS_RGB8 : break; - case MNG_CANVAS_RGBA8 : break; - case MNG_CANVAS_ARGB8 : break; - case MNG_CANVAS_RGB8_A8 : break; - case MNG_CANVAS_BGR8 : break; - case MNG_CANVAS_BGRA8 : break; - case MNG_CANVAS_BGRA8PM : break; - case MNG_CANVAS_ABGR8 : break; -/* case MNG_CANVAS_RGB16 : break; */ -/* case MNG_CANVAS_RGBA16 : break; */ -/* case MNG_CANVAS_ARGB16 : break; */ -/* case MNG_CANVAS_BGR16 : break; */ -/* case MNG_CANVAS_BGRA16 : break; */ -/* case MNG_CANVAS_ABGR16 : break; */ -/* case MNG_CANVAS_INDEX8 : break; */ -/* case MNG_CANVAS_INDEXA8 : break; */ -/* case MNG_CANVAS_AINDEX8 : break; */ -/* case MNG_CANVAS_GRAY8 : break; */ -/* case MNG_CANVAS_GRAY16 : break; */ -/* case MNG_CANVAS_GRAYA8 : break; */ -/* case MNG_CANVAS_GRAYA16 : break; */ -/* case MNG_CANVAS_AGRAY8 : break; */ -/* case MNG_CANVAS_AGRAY16 : break; */ -/* case MNG_CANVAS_DX15 : break; */ -/* case MNG_CANVAS_DX16 : break; */ - default : { MNG_ERROR (((mng_datap)hHandle), MNG_INVALIDCNVSTYLE) } - } - - ((mng_datap)hHandle)->iCanvasstyle = iStyle; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CANVASSTYLE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_bkgdstyle (mng_handle hHandle, - mng_uint32 iStyle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BKGDSTYLE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - - switch (iStyle) /* alpha-modes not supported */ - { - case MNG_CANVAS_RGB8 : break; - case MNG_CANVAS_BGR8 : break; -/* case MNG_CANVAS_RGB16 : break; */ -/* case MNG_CANVAS_BGR16 : break; */ -/* case MNG_CANVAS_INDEX8 : break; */ -/* case MNG_CANVAS_GRAY8 : break; */ -/* case MNG_CANVAS_GRAY16 : break; */ -/* case MNG_CANVAS_DX15 : break; */ -/* case MNG_CANVAS_DX16 : break; */ - default : MNG_ERROR (((mng_datap)hHandle), MNG_INVALIDCNVSTYLE) - } - - ((mng_datap)hHandle)->iBkgdstyle = iStyle; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BKGDSTYLE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_bgcolor (mng_handle hHandle, - mng_uint16 iRed, - mng_uint16 iGreen, - mng_uint16 iBlue) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BGCOLOR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iBGred = iRed; - ((mng_datap)hHandle)->iBGgreen = iGreen; - ((mng_datap)hHandle)->iBGblue = iBlue; - ((mng_datap)hHandle)->bUseBKGD = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BGCOLOR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_usebkgd (mng_handle hHandle, - mng_bool bUseBKGD) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USEBKGD, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bUseBKGD = bUseBKGD; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USEBKGD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_storechunks (mng_handle hHandle, - mng_bool bStorechunks) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_STORECHUNKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bStorechunks = bStorechunks; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_STORECHUNKS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_sectionbreaks (mng_handle hHandle, - mng_bool bSectionbreaks) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SECTIONBREAKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bSectionbreaks = bSectionbreaks; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SECTIONBREAKS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_cacheplayback (mng_handle hHandle, - mng_bool bCacheplayback) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CACHEPLAYBACK, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - - if (((mng_datap)hHandle)->bHasheader) - MNG_ERROR (((mng_datap)hHandle), MNG_FUNCTIONINVALID) - - ((mng_datap)hHandle)->bCacheplayback = bCacheplayback; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CACHEPLAYBACK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_doprogressive (mng_handle hHandle, - mng_bool bDoProgressive) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DOPROGRESSIVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - - ((mng_datap)hHandle)->bDoProgressive = bDoProgressive; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DOPROGRESSIVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_srgb (mng_handle hHandle, - mng_bool bIssRGB) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bIssRGB = bIssRGB; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_outputprofile (mng_handle hHandle, - mng_pchar zFilename) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf2) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf2); - /* allocate new CMS profile handle */ - pData->hProf2 = mnglcms_createfileprofile (zFilename); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_outputprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE2, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf2) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf2); - /* allocate new CMS profile handle */ - pData->hProf2 = mnglcms_creatememprofile (iProfilesize, pProfile); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_outputsrgb (mng_handle hHandle) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTSRGB, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf2) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf2); - /* allocate new CMS profile handle */ - pData->hProf2 = mnglcms_createsrgbprofile (); - - if (!pData->hProf2) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTSRGB, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_srgbprofile (mng_handle hHandle, - mng_pchar zFilename) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE2, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf3) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf3); - /* allocate new CMS profile handle */ - pData->hProf3 = mnglcms_createfileprofile (zFilename); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE2, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_srgbprofile2 (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf3) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf3); - /* allocate new CMS profile handle */ - pData->hProf3 = mnglcms_creatememprofile (iProfilesize, pProfile); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_srgbimplicit (mng_handle hHandle) -{ -#ifdef MNG_INCLUDE_LCMS - mng_datap pData; -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBIMPLICIT, MNG_LC_START) -#endif - -#ifdef MNG_INCLUDE_LCMS - MNG_VALIDHANDLE (hHandle) - - pData = (mng_datap)hHandle; /* address the structure */ - - if (pData->hProf3) /* previously defined ? */ - mnglcms_freeprofile (pData->hProf3); - /* allocate new CMS profile handle */ - pData->hProf3 = mnglcms_createsrgbprofile (); - - if (!pData->hProf3) /* handle error ? */ - MNG_ERRORL (pData, MNG_LCMS_NOHANDLE) -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBIMPLICIT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_viewgamma (mng_handle hHandle, - mng_float dGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dViewgamma = dGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_displaygamma (mng_handle hHandle, - mng_float dGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDisplaygamma = dGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_dfltimggamma (mng_handle hHandle, - mng_float dGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDfltimggamma = dGamma; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_viewgammaint (mng_handle hHandle, - mng_uint32 iGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dViewgamma = (mng_float)iGamma / 100000; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_displaygammaint (mng_handle hHandle, - mng_uint32 iGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDisplaygamma = (mng_float)iGamma / 100000; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_dfltimggammaint (mng_handle hHandle, - mng_uint32 iGamma) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->dDfltimggamma = (mng_float)iGamma / 100000; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_maxcanvaswidth (mng_handle hHandle, - mng_uint32 iMaxwidth) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASWIDTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxwidth = iMaxwidth; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASWIDTH, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_maxcanvasheight (mng_handle hHandle, - mng_uint32 iMaxheight) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASHEIGHT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxheight = iMaxheight; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASHEIGHT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_set_maxcanvassize (mng_handle hHandle, - mng_uint32 iMaxwidth, - mng_uint32 iMaxheight) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASSIZE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxwidth = iMaxwidth; - ((mng_datap)hHandle)->iMaxheight = iMaxheight; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASSIZE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_level (mng_handle hHandle, - mng_int32 iZlevel) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_LEVEL, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZlevel = iZlevel; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_LEVEL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_method (mng_handle hHandle, - mng_int32 iZmethod) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_METHOD, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZmethod = iZmethod; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_METHOD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_windowbits (mng_handle hHandle, - mng_int32 iZwindowbits) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_WINDOWBITS, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZwindowbits = iZwindowbits; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_WINDOWBITS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_memlevel (mng_handle hHandle, - mng_int32 iZmemlevel) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MEMLEVEL, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZmemlevel = iZmemlevel; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MEMLEVEL, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_strategy (mng_handle hHandle, - mng_int32 iZstrategy) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_STRATEGY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iZstrategy = iZstrategy; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_STRATEGY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_retcode MNG_DECL mng_set_zlib_maxidat (mng_handle hHandle, - mng_uint32 iMaxIDAT) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MAXIDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxIDAT = iMaxIDAT; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MAXIDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_dctmethod (mng_handle hHandle, - mngjpeg_dctmethod eJPEGdctmethod) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_DCTMETHOD, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->eJPEGdctmethod = eJPEGdctmethod; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_DCTMETHOD, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_quality (mng_handle hHandle, - mng_int32 iJPEGquality) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_QUALITY, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iJPEGquality = iJPEGquality; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_QUALITY, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_smoothing (mng_handle hHandle, - mng_int32 iJPEGsmoothing) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_SMOOTHING, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iJPEGsmoothing = iJPEGsmoothing; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_SMOOTHING, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_progressive (mng_handle hHandle, - mng_bool bJPEGprogressive) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_PROGRESSIVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bJPEGcompressprogr = bJPEGprogressive; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_PROGRESSIVE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_optimized (mng_handle hHandle, - mng_bool bJPEGoptimized) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_OPTIMIZED, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->bJPEGcompressopt = bJPEGoptimized; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_OPTIMIZED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_retcode MNG_DECL mng_set_jpeg_maxjdat (mng_handle hHandle, - mng_uint32 iMaxJDAT) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_MAXJDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iMaxJDAT = iMaxJDAT; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_MAXJDAT, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_retcode MNG_DECL mng_set_suspensionmode (mng_handle hHandle, - mng_bool bSuspensionmode) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SUSPENSIONMODE, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - - if (((mng_datap)hHandle)->bReading) /* we must NOT be reading !!! */ - MNG_ERROR ((mng_datap)hHandle, MNG_FUNCTIONINVALID) - - ((mng_datap)hHandle)->bSuspensionmode = bSuspensionmode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SUSPENSIONMODE, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode MNG_DECL mng_set_speed (mng_handle hHandle, - mng_speedtype iSpeed) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SPEED, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - ((mng_datap)hHandle)->iSpeed = iSpeed; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SPEED, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ -/* * * */ -/* * Property get functions * */ -/* * * */ -/* ************************************************************************** */ - -mng_ptr MNG_DECL mng_get_userdata (mng_handle hHandle) -{ /* no tracing in here to prevent recursive calls */ - MNG_VALIDHANDLEX (hHandle) - return ((mng_datap)hHandle)->pUserdata; -} - -/* ************************************************************************** */ - -mng_imgtype MNG_DECL mng_get_sigtype (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIGTYPE, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_it_unknown; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIGTYPE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->eSigtype; -} - -/* ************************************************************************** */ - -mng_imgtype MNG_DECL mng_get_imagetype (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGETYPE, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_it_unknown; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGETYPE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->eImagetype; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_imagewidth (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iWidth; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_imageheight (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEHEIGHT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iHeight; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_ticks (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TICKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TICKS, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iTicks; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_framecount (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FRAMECOUNT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FRAMECOUNT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iFramecount; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_layercount (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LAYERCOUNT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LAYERCOUNT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iLayercount; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_playtime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_PLAYTIME, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_PLAYTIME, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iPlaytime; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_simplicity (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIMPLICITY, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIMPLICITY, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iSimplicity; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_bitdepth (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BITDEPTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iBitdepth; - else - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRimgbitdepth; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BITDEPTH, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_colortype (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COLORTYPE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iColortype; - else - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRcolortype; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COLORTYPE, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_compression (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COMPRESSION, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iCompression; - else - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRimgcompression; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COMPRESSION, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_filter (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FILTER, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iFilter; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FILTER, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_interlace (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_INTERLACE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_png) - iRslt = ((mng_datap)hHandle)->iInterlace; - else - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRimginterlace; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_INTERLACE, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphabitdepth (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHABITDEPTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphabitdepth; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHABITDEPTH, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_refreshpass (mng_handle hHandle) -{ - mng_uint8 iRslt; - mng_datap pData; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_REFRESHPASS, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - pData = (mng_datap)hHandle; - /* for PNG we know the exact pass */ - if ((pData->eImagetype == mng_it_png) && (pData->iPass >= 0)) - iRslt = pData->iPass; -#ifdef MNG_INCLUDE_JNG - else /* for JNG we'll fake it... */ - if ((pData->eImagetype == mng_it_jng) && - (pData->bJPEGhasheader) && (pData->bJPEGdecostarted) && - (pData->bJPEGprogressive)) - { - if (pData->pJPEGdinfo->input_scan_number <= 1) - iRslt = 0; /* first pass (I think...) */ - else - if (jpeg_input_complete (pData->pJPEGdinfo)) - iRslt = 7; /* input complete; aka final pass */ - else - iRslt = 3; /* anything between 0 and 7 will do */ - - } -#endif - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_REFRESHPASS, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphacompression (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHACOMPRESSION, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphacompression; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHACOMPRESSION, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphafilter (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAFILTER, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphafilter; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAFILTER, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphainterlace (mng_handle hHandle) -{ - mng_uint8 iRslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAINTERLACE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - - if (((mng_datap)hHandle)->eImagetype == mng_it_jng) - iRslt = ((mng_datap)hHandle)->iJHDRalphainterlace; - else - iRslt = 0; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHAINTERLACE, MNG_LC_END) -#endif - - return iRslt; -} - -/* ************************************************************************** */ - -mng_uint8 MNG_DECL mng_get_alphadepth (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHADEPTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHADEPTH, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iAlphadepth; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_canvasstyle (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CANVASSTYLE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CANVASSTYLE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iCanvasstyle; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_bkgdstyle (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BKGDSTYLE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BKGDSTYLE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iBkgdstyle; -} - -/* ************************************************************************** */ - -mng_retcode MNG_DECL mng_get_bgcolor (mng_handle hHandle, - mng_uint16* iRed, - mng_uint16* iGreen, - mng_uint16* iBlue) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GET_BGCOLOR, MNG_LC_START) -#endif - - MNG_VALIDHANDLE (hHandle) - *iRed = ((mng_datap)hHandle)->iBGred; - *iGreen = ((mng_datap)hHandle)->iBGgreen; - *iBlue = ((mng_datap)hHandle)->iBGblue; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (((mng_datap)hHandle), MNG_FN_GET_BGCOLOR, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_usebkgd (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_USEBKGD, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_USEBKGD, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bUseBKGD; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_storechunks (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_STORECHUNKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_STORECHUNKS, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bStorechunks; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_sectionbreaks (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SECTIONBREAKS, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SECTIONBREAKS, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bSectionbreaks; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_cacheplayback (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_CACHEPLAYBACK, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_CACHEPLAYBACK, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bCacheplayback; -} - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_get_doprogressive (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_DOPROGRESSIVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_DOPROGRESSIVE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bDoProgressive; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_get_srgb (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SRGB, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEB (((mng_datap)hHandle), MNG_FN_GET_SRGB, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bIssRGB; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_float MNG_DECL mng_get_viewgamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->dViewgamma; -} - -/* ************************************************************************** */ - -mng_float MNG_DECL mng_get_displaygamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->dDisplaygamma; -} - -/* ************************************************************************** */ - -mng_float MNG_DECL mng_get_dfltimggamma (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->dDfltimggamma; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_viewgammaint (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_VIEWGAMMA, MNG_LC_END) -#endif - - return (mng_uint32)(((mng_datap)hHandle)->dViewgamma * 100000); -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_displaygammaint (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DISPLAYGAMMA, MNG_LC_END) -#endif - - return (mng_uint32)(((mng_datap)hHandle)->dDisplaygamma * 100000); -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_dfltimggammaint (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_DFLTIMGGAMMA, MNG_LC_END) -#endif - - return (mng_uint32)(((mng_datap)hHandle)->dDfltimggamma * 100000); -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_maxcanvaswidth (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASWIDTH, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASWIDTH, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iMaxwidth; -} - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_maxcanvasheight (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASHEIGHT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_MAXCANVASHEIGHT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iMaxheight; -} - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_int32 MNG_DECL mng_get_zlib_level (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_LEVEL, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_LEVEL, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iZlevel; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_int32 MNG_DECL mng_get_zlib_method (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_METHOD, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_METHOD, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iZmethod; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_int32 MNG_DECL mng_get_zlib_windowbits (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_WINDOWBITS, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_WINDOWBITS, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iZwindowbits; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_int32 MNG_DECL mng_get_zlib_memlevel (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MEMLEVEL, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MEMLEVEL, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iZmemlevel; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_int32 MNG_DECL mng_get_zlib_strategy (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_STRATEGY, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_STRATEGY, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iZstrategy; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB -mng_uint32 MNG_DECL mng_get_zlib_maxidat (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MAXIDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ZLIB_MAXIDAT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iMaxIDAT; -} -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mngjpeg_dctmethod MNG_DECL mng_get_jpeg_dctmethod (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_DCTMETHOD, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return JDCT_ISLOW; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_DCTMETHOD, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->eJPEGdctmethod; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_int32 MNG_DECL mng_get_jpeg_quality (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_QUALITY, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_QUALITY, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iJPEGquality; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_int32 MNG_DECL mng_get_jpeg_smoothing (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_SMOOTHING, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_SMOOTHING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iJPEGsmoothing; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_bool MNG_DECL mng_get_jpeg_progressive (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_PROGRESSIVE, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_PROGRESSIVE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bJPEGcompressprogr; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_bool MNG_DECL mng_get_jpeg_optimized (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_OPTIMIZED, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_OPTIMIZED, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bJPEGcompressopt; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG -mng_uint32 MNG_DECL mng_get_jpeg_maxjdat (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_MAXJDAT, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_JPEG_MAXJDAT, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iMaxJDAT; -} -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_bool MNG_DECL mng_get_suspensionmode (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SUSPENSIONMODE, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SUSPENSIONMODE, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bSuspensionmode; -} -#endif /* MNG_SUPPORT_READ */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_speedtype MNG_DECL mng_get_speed (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SPEED, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SPEED, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iSpeed; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_uint32 MNG_DECL mng_get_imagelevel (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGELEVEL, MNG_LC_START) -#endif - - MNG_VALIDHANDLEX (hHandle) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGELEVEL, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iImagelevel; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_starttime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_STARTTIME, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_STARTTIME, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iStarttime; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_runtime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_RUNTIME, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_RUNTIME, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iRuntime; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_currentframe (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTFRAME, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTFRAME, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iFrameseq; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_currentlayer (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTLAYER, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTLAYER, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iLayerseq; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_uint32 MNG_DECL mng_get_currentplaytime (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTPLAYTIME, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return mng_st_normal; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_CURRENTPLAYTIME, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->iFrametime; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_bool MNG_DECL mng_status_error (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_ERROR, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_ERROR, MNG_LC_END) -#endif - - return (mng_bool)((mng_datap)hHandle)->iErrorcode; -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_bool MNG_DECL mng_status_reading (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_READING, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_READING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bReading; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_READ -mng_bool MNG_DECL mng_status_suspendbreak (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_SUSPENDBREAK, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_SUSPENDBREAK, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bSuspended; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_bool MNG_DECL mng_status_creating (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_CREATING, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_CREATING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bCreating; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_WRITE -mng_bool MNG_DECL mng_status_writing (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_WRITING, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_WRITING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bWriting; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_status_displaying (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_DISPLAYING, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_DISPLAYING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bDisplaying; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_status_running (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_RUNNING, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_RUNNING, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bRunning; -} -#endif - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_bool MNG_DECL mng_status_timerbreak (mng_handle hHandle) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_TIMERBREAK, MNG_LC_START) -#endif - - if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC)) - return MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACEX (((mng_datap)hHandle), MNG_FN_STATUS_TIMERBREAK, MNG_LC_END) -#endif - - return ((mng_datap)hHandle)->bTimerset; -} -#endif - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_read.c b/freeimage241/Source/LibMNG/libmng_read.c deleted file mode 100644 index 61c0e9c..0000000 --- a/freeimage241/Source/LibMNG/libmng_read.c +++ /dev/null @@ -1,693 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_read.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Read logic (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the high-level read logic * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/19/2000 - G.Juyn * */ -/* * - cleaned up some code regarding mixed support * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added support for JNG * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed up punctuation (contribution by Tim Rowley) * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - changed read-processing for improved I/O-suspension * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed EOF processing behavior * */ -/* * 0.9.1 - 07/14/2000 - G.Juyn * */ -/* * - changed default readbuffer size from 1024 to 4200 * */ -/* * * */ -/* * 0.9.2 - 07/27/2000 - G.Juyn * */ -/* * - B110320 - fixed GCC warning about mix-sized pointer math * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - B110546 - fixed for improperly returning UNEXPECTEDEOF * */ -/* * 0.9.2 - 08/04/2000 - G.Juyn * */ -/* * - B111096 - fixed large-buffer read-suspension * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - removed test-MaGN * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added support for JDAA * */ -/* * * */ -/* * 0.9.5 - 1/23/2001 - G.Juyn * */ -/* * - fixed timing-problem with switching framing_modes * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_objects.h" -#include "libmng_object_prc.h" -#include "libmng_chunks.h" -#include "libmng_chunk_prc.h" -#include "libmng_chunk_io.h" -#include "libmng_display.h" -#include "libmng_read.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_READ_PROCS - -/* ************************************************************************** */ - -mng_retcode process_eof (mng_datap pData) -{ - if (!pData->bEOF) /* haven't closed the stream yet ? */ - { - pData->bEOF = MNG_TRUE; /* now we do! */ - - if (!pData->fClosestream ((mng_handle)pData)) - MNG_ERROR (pData, MNG_APPIOERROR) - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode read_databuffer (mng_datap pData, - mng_uint8p pBuf, - mng_uint32 iSize, - mng_uint32 * iRead) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DATABUFFER, MNG_LC_START) -#endif - - if (pData->bSuspensionmode) - { - mng_uint8p pTemp; - mng_uint32 iTemp; - - *iRead = 0; /* let's be negative about the outcome */ - - if (!pData->pSuspendbuf) /* need to create a suspension buffer ? */ - { - pData->iSuspendbufsize = MNG_SUSPENDBUFFERSIZE; - /* so, create it */ - MNG_ALLOC (pData, pData->pSuspendbuf, pData->iSuspendbufsize) - - pData->iSuspendbufleft = 0; /* make sure to fill it first time */ - pData->pSuspendbufnext = pData->pSuspendbuf; - } - /* more than our buffer can hold ? */ - if (iSize > pData->iSuspendbufsize) - { - mng_uint32 iRemain; - - if (!pData->pReadbufnext) /* first time ? */ - { - if (pData->iSuspendbufleft) /* do we have some data left ? */ - { /* then copy it */ - MNG_COPY (pBuf, pData->pSuspendbufnext, pData->iSuspendbufleft) - /* fixup variables */ - pData->pReadbufnext = pBuf + pData->iSuspendbufleft; - pData->pSuspendbufnext = pData->pSuspendbuf; - pData->iSuspendbufleft = 0; - } - else - { - pData->pReadbufnext = pBuf; - } - } - /* calculate how much to get */ - iRemain = iSize - (mng_uint32)(pData->pReadbufnext - pBuf); - /* let's go get it */ - if (!pData->fReaddata (((mng_handle)pData), pData->pReadbufnext, iRemain, &iTemp)) - MNG_ERROR (pData, MNG_APPIOERROR); - /* first read after suspension return 0 means EOF */ - if ((pData->iSuspendpoint) && (iTemp == 0)) - { /* that makes it final */ - mng_retcode iRetcode = process_eof (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - /* indicate the source is depleted */ - *iRead = iSize - iRemain + iTemp; - } - else - { - if (iTemp < iRemain) /* suspension required ? */ - { - pData->pReadbufnext = pData->pReadbufnext + iTemp; - pData->bSuspended = MNG_TRUE; - } - else - { - *iRead = iSize; /* got it all now ! */ - } - } - } - else - { /* need to read some more ? */ - while ((!pData->bSuspended) && (!pData->bEOF) && (iSize > pData->iSuspendbufleft)) - { /* not enough space left in buffer ? */ - if (pData->iSuspendbufsize - pData->iSuspendbufleft - - (mng_uint32)(pData->pSuspendbufnext - pData->pSuspendbuf) < - MNG_SUSPENDREQUESTSIZE) - { - if (pData->iSuspendbufleft) /* then lets shift (if there's anything left) */ - MNG_COPY (pData->pSuspendbuf, pData->pSuspendbufnext, pData->iSuspendbufleft) - /* adjust running pointer */ - pData->pSuspendbufnext = pData->pSuspendbuf; - } - /* still not enough room ? */ - if (pData->iSuspendbufsize - pData->iSuspendbufleft < MNG_SUSPENDREQUESTSIZE) - MNG_ERROR (pData, MNG_INTERNALERROR) - /* now read some more data */ - pTemp = pData->pSuspendbufnext + pData->iSuspendbufleft; - - if (!pData->fReaddata (((mng_handle)pData), pTemp, MNG_SUSPENDREQUESTSIZE, &iTemp)) - MNG_ERROR (pData, MNG_APPIOERROR); - /* adjust fill-counter */ - pData->iSuspendbufleft += iTemp; - /* first read after suspension returning 0 means EOF */ - if ((pData->iSuspendpoint) && (iTemp == 0)) - { /* that makes it final */ - mng_retcode iRetcode = process_eof (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if (pData->iSuspendbufleft) /* return the leftover scraps */ - MNG_COPY (pBuf, pData->pSuspendbufnext, pData->iSuspendbufleft) - /* and indicate so */ - *iRead = pData->iSuspendbufleft; - pData->pSuspendbufnext = pData->pSuspendbuf; - pData->iSuspendbufleft = 0; - } - else - { /* suspension required ? */ - if ((iSize > pData->iSuspendbufleft) && (iTemp < MNG_SUSPENDREQUESTSIZE)) - pData->bSuspended = MNG_TRUE; - - } - - pData->iSuspendpoint = 0; /* reset it here in case we loop back */ - } - - if ((!pData->bSuspended) && (!pData->bEOF)) - { /* return the data ! */ - MNG_COPY (pBuf, pData->pSuspendbufnext, iSize) - - *iRead = iSize; /* returned it all */ - /* adjust suspension-buffer variables */ - pData->pSuspendbufnext += iSize; - pData->iSuspendbufleft -= iSize; - } - } - } - else - { - if (!pData->fReaddata (((mng_handle)pData), (mng_ptr)pBuf, iSize, iRead)) - { - if (iRead == 0) /* suspension required ? */ - pData->bSuspended = MNG_TRUE; - else - MNG_ERROR (pData, MNG_APPIOERROR); - } - } - - pData->iSuspendpoint = 0; /* safely reset it here ! */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_DATABUFFER, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode process_raw_chunk (mng_datap pData, - mng_uint8p pBuf, - mng_uint32 iBuflen) -{ - /* the table-idea & binary search code was adapted from - libpng 1.1.0 (pngread.c) */ - /* NOTE1: the table must remain sorted by chunkname, otherwise the binary - search will break !!! */ - /* NOTE2: the layout must remain equal to the header part of all the - chunk-structures (yes, that means even the pNext and pPrev fields; - it's wasting a bit of space, but hey, the code is a lot easier) */ - - mng_chunk_header chunk_unknown = {MNG_UINT_HUH, init_unknown, free_unknown, - read_unknown, write_unknown, 0, 0}; - - mng_chunk_header chunk_table [] = - { - {MNG_UINT_BACK, init_back, free_back, read_back, write_back, 0, 0}, - {MNG_UINT_BASI, init_basi, free_basi, read_basi, write_basi, 0, 0}, - {MNG_UINT_CLIP, init_clip, free_clip, read_clip, write_clip, 0, 0}, - {MNG_UINT_CLON, init_clon, free_clon, read_clon, write_clon, 0, 0}, - {MNG_UINT_DBYK, init_dbyk, free_dbyk, read_dbyk, write_dbyk, 0, 0}, - {MNG_UINT_DEFI, init_defi, free_defi, read_defi, write_defi, 0, 0}, - {MNG_UINT_DHDR, init_dhdr, free_dhdr, read_dhdr, write_dhdr, 0, 0}, - {MNG_UINT_DISC, init_disc, free_disc, read_disc, write_disc, 0, 0}, - {MNG_UINT_DROP, init_drop, free_drop, read_drop, write_drop, 0, 0}, - {MNG_UINT_ENDL, init_endl, free_endl, read_endl, write_endl, 0, 0}, - {MNG_UINT_FRAM, init_fram, free_fram, read_fram, write_fram, 0, 0}, - {MNG_UINT_IDAT, init_idat, free_idat, read_idat, write_idat, 0, 0}, /* 12-th element! */ - {MNG_UINT_IEND, init_iend, free_iend, read_iend, write_iend, 0, 0}, - {MNG_UINT_IHDR, init_ihdr, free_ihdr, read_ihdr, write_ihdr, 0, 0}, - {MNG_UINT_IJNG, init_ijng, free_ijng, read_ijng, write_ijng, 0, 0}, - {MNG_UINT_IPNG, init_ipng, free_ipng, read_ipng, write_ipng, 0, 0}, -#ifdef MNG_INCLUDE_JNG - {MNG_UINT_JDAA, init_jdaa, free_jdaa, read_jdaa, write_jdaa, 0, 0}, - {MNG_UINT_JDAT, init_jdat, free_jdat, read_jdat, write_jdat, 0, 0}, - {MNG_UINT_JHDR, init_jhdr, free_jhdr, read_jhdr, write_jhdr, 0, 0}, - {MNG_UINT_JSEP, init_jsep, free_jsep, read_jsep, write_jsep, 0, 0}, - {MNG_UINT_JdAA, init_jdaa, free_jdaa, read_jdaa, write_jdaa, 0, 0}, -#endif - {MNG_UINT_LOOP, init_loop, free_loop, read_loop, write_loop, 0, 0}, - {MNG_UINT_MAGN, init_magn, free_magn, read_magn, write_magn, 0, 0}, - {MNG_UINT_MEND, init_mend, free_mend, read_mend, write_mend, 0, 0}, - {MNG_UINT_MHDR, init_mhdr, free_mhdr, read_mhdr, write_mhdr, 0, 0}, - {MNG_UINT_MOVE, init_move, free_move, read_move, write_move, 0, 0}, - {MNG_UINT_ORDR, init_ordr, free_ordr, read_ordr, write_ordr, 0, 0}, - {MNG_UINT_PAST, init_past, free_past, read_past, write_past, 0, 0}, - {MNG_UINT_PLTE, init_plte, free_plte, read_plte, write_plte, 0, 0}, - {MNG_UINT_PPLT, init_pplt, free_pplt, read_pplt, write_pplt, 0, 0}, - {MNG_UINT_PROM, init_prom, free_prom, read_prom, write_prom, 0, 0}, - {MNG_UINT_SAVE, init_save, free_save, read_save, write_save, 0, 0}, - {MNG_UINT_SEEK, init_seek, free_seek, read_seek, write_seek, 0, 0}, - {MNG_UINT_SHOW, init_show, free_show, read_show, write_show, 0, 0}, - {MNG_UINT_TERM, init_term, free_term, read_term, write_term, 0, 0}, - {MNG_UINT_bKGD, init_bkgd, free_bkgd, read_bkgd, write_bkgd, 0, 0}, - {MNG_UINT_cHRM, init_chrm, free_chrm, read_chrm, write_chrm, 0, 0}, - {MNG_UINT_eXPI, init_expi, free_expi, read_expi, write_expi, 0, 0}, - {MNG_UINT_fPRI, init_fpri, free_fpri, read_fpri, write_fpri, 0, 0}, - {MNG_UINT_gAMA, init_gama, free_gama, read_gama, write_gama, 0, 0}, - {MNG_UINT_hIST, init_hist, free_hist, read_hist, write_hist, 0, 0}, - {MNG_UINT_iCCP, init_iccp, free_iccp, read_iccp, write_iccp, 0, 0}, - {MNG_UINT_iTXt, init_itxt, free_itxt, read_itxt, write_itxt, 0, 0}, - {MNG_UINT_nEED, init_need, free_need, read_need, write_need, 0, 0}, -/* TODO: {MNG_UINT_oFFs, 0, 0, 0, 0, 0, 0}, */ -/* TODO: {MNG_UINT_pCAL, 0, 0, 0, 0, 0, 0}, */ - {MNG_UINT_pHYg, init_phyg, free_phyg, read_phyg, write_phyg, 0, 0}, - {MNG_UINT_pHYs, init_phys, free_phys, read_phys, write_phys, 0, 0}, - {MNG_UINT_sBIT, init_sbit, free_sbit, read_sbit, write_sbit, 0, 0}, -/* TODO: {MNG_UINT_sCAL, 0, 0, 0, 0, 0, 0}, */ - {MNG_UINT_sPLT, init_splt, free_splt, read_splt, write_splt, 0, 0}, - {MNG_UINT_sRGB, init_srgb, free_srgb, read_srgb, write_srgb, 0, 0}, - {MNG_UINT_tEXt, init_text, free_text, read_text, write_text, 0, 0}, - {MNG_UINT_tIME, init_time, free_time, read_time, write_time, 0, 0}, - {MNG_UINT_tRNS, init_trns, free_trns, read_trns, write_trns, 0, 0}, - {MNG_UINT_zTXt, init_ztxt, free_ztxt, read_ztxt, write_ztxt, 0, 0}, - }; - /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - mng_chunk_headerp pEntry; /* pointer to found entry */ - mng_chunkid iChunkname; /* the chunk's tag */ - mng_chunkp pChunk; /* chunk structure (if #define MNG_STORE_CHUNKS) */ - mng_retcode iRetcode; /* temporary error-code */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RAW_CHUNK, MNG_LC_START) -#endif - /* get the chunkname */ - iChunkname = (mng_chunkid)(mng_get_uint32 (pBuf)); - - pBuf += sizeof (mng_chunkid); /* adjust the buffer */ - iBuflen -= sizeof (mng_chunkid); - /* determine max index of table */ - iTop = (sizeof (chunk_table) / sizeof (chunk_table [0])) - 1; - - /* binary search; with 52 chunks, worst-case is 7 comparisons */ - iLower = 0; - iMiddle = 11; /* start with the IDAT entry */ - iUpper = iTop; - pEntry = 0; /* no goods yet! */ - pChunk = 0; - - do /* the binary search itself */ - { - if (chunk_table [iMiddle].iChunkname < iChunkname) - iLower = iMiddle + 1; - else if (chunk_table [iMiddle].iChunkname > iChunkname) - iUpper = iMiddle - 1; - else - { - pEntry = &chunk_table [iMiddle]; - break; - } - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - - if (!pEntry) /* unknown chunk ? */ - pEntry = &chunk_unknown; /* make it so! */ - - pData->iChunkname = iChunkname; /* keep track of where we are */ - pData->iChunkseq++; - - if (pEntry->fRead) /* read-callback available ? */ - { - iRetcode = pEntry->fRead (pData, pEntry, iBuflen, (mng_ptr)pBuf, &pChunk); - - if (!iRetcode) /* everything oke ? */ - { /* remember unknown chunk's id */ - if ((pChunk) && (pEntry == &chunk_unknown)) - ((mng_chunk_headerp)pChunk)->iChunkname = iChunkname; - } - } - else - iRetcode = MNG_NOERROR; - - if (pChunk) /* store this chunk ? */ - add_chunk (pData, pChunk); /* do it */ - -#ifdef MNG_INCLUDE_JNG /* implicit EOF ? */ - if ((!pData->bHasMHDR) && (!pData->bHasIHDR) && (!pData->bHasJHDR)) -#else - if ((!pData->bHasMHDR) && (!pData->bHasIHDR)) -#endif - iRetcode = process_eof (pData); /* then do some EOF processing */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_PROCESS_RAW_CHUNK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode read_chunk (mng_datap pData) -{ - mng_uint32 iBufmax = pData->iReadbufsize; - mng_uint8p pBuf = pData->pReadbuf; - mng_uint32 iBuflen = 0; /* number of bytes requested */ - mng_uint32 iRead = 0; /* number of bytes read */ - mng_uint32 iCrc; /* calculated CRC */ - mng_retcode iRetcode = MNG_NOERROR; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHUNK, MNG_LC_START) -#endif - -#ifdef MNG_SUPPORT_DISPLAY - if (pData->pCurraniobj) /* processing an animation object ? */ - { - do /* process it then */ - { - iRetcode = ((mng_object_headerp)pData->pCurraniobj)->fProcess (pData, pData->pCurraniobj); - /* refresh needed ? */ -/* if ((!iRetcode) && (!pData->bTimerset) && (pData->bNeedrefresh)) - iRetcode = display_progressive_refresh (pData, 1); */ - /* can we advance to next object ? */ - if ((!iRetcode) && (pData->pCurraniobj) && - (!pData->bTimerset) && (!pData->bSectionwait)) - { - pData->pCurraniobj = ((mng_object_headerp)pData->pCurraniobj)->pNext; - /* TERM processing to be done ? */ - if ((!pData->pCurraniobj) && (pData->bHasTERM) && (!pData->bHasMHDR)) - iRetcode = process_display_mend (pData); - } - } /* until error or a break or no more objects */ - while ((!iRetcode) && (pData->pCurraniobj) && - (!pData->bTimerset) && (!pData->bSectionwait) && (!pData->bFreezing)); - } - else - { - if (pData->iBreakpoint) /* do we need to finish something first ? */ - { - switch (pData->iBreakpoint) /* return to broken display routine */ - { - case 1 : { iRetcode = process_display_fram2 (pData); break; } - case 2 : { iRetcode = process_display_ihdr (pData); break; } - case 3 : ; /* same as 4 !!! */ - case 4 : { iRetcode = process_display_show (pData); break; } - case 5 : { iRetcode = process_display_clon2 (pData); break; } -#ifdef MNG_INCLUDE_JNG - case 7 : { iRetcode = process_display_jhdr (pData); break; } -#endif - case 6 : ; /* same as 8 !!! */ - case 8 : { iRetcode = process_display_iend (pData); break; } - case 9 : { iRetcode = process_display_magn2 (pData); break; } - } - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - -#endif /* MNG_SUPPORT_DISPLAY */ - /* can we continue processing now, or do we */ - /* need to wait for the timer to finish (again) ? */ -#ifdef MNG_SUPPORT_DISPLAY - if ((!pData->bTimerset) && (!pData->bSectionwait) && (!pData->bEOF)) -#else - if (!pData->bEOF) -#endif - { /* freezing in progress ? */ - if ((pData->bFreezing) && (pData->iSuspendpoint == 0)) - pData->bRunning = MNG_FALSE; /* then this is the right moment to do it */ - - if (pData->iSuspendpoint <= 2) - { - iBuflen = sizeof (mng_uint32); /* read length */ - iRetcode = read_databuffer (pData, pBuf, iBuflen, &iRead); - - if (iRetcode) /* bail on errors */ - return iRetcode; - - if (pData->bSuspended) /* suspended ? */ - pData->iSuspendpoint = 2; - else /* save the length */ - pData->iChunklen = mng_get_uint32 (pBuf); - - } - - if (!pData->bSuspended) /* still going ? */ - { /* previously suspended or not eof ? */ - if ((pData->iSuspendpoint > 2) || (iRead == iBuflen)) - { /* determine length chunkname + data + crc */ - iBuflen = pData->iChunklen + (mng_uint32)(sizeof (mng_chunkid) + sizeof (iCrc)); - - if (iBuflen < iBufmax) /* does it fit in default buffer ? */ - { /* note that we don't use the full size - so there's always a zero-byte at the - very end !!! */ - iRetcode = read_databuffer (pData, pBuf, iBuflen, &iRead); - - if (iRetcode) /* bail on errors */ - return iRetcode; - - if (pData->bSuspended) /* suspended ? */ - pData->iSuspendpoint = 3; - else - { - if (iRead != iBuflen) /* did we get all the data ? */ - iRetcode = MNG_UNEXPECTEDEOF; - else - { - mng_uint32 iL = iBuflen - (mng_uint32)(sizeof (iCrc)); - /* calculate the crc */ - iCrc = crc (pData, pBuf, iL); - /* and check it */ - if (!(iCrc == mng_get_uint32 (pBuf + iL))) - iRetcode = MNG_INVALIDCRC; - else - iRetcode = process_raw_chunk (pData, pBuf, iL); - } - } - } - else - { - if (!pData->iSuspendpoint) /* create additional large buffer ? */ - { /* again reserve space for the last zero-byte */ - pData->iLargebufsize = iBuflen + 1; - MNG_ALLOC (pData, pData->pLargebuf, pData->iLargebufsize) - } - - iRetcode = read_databuffer (pData, pData->pLargebuf, iBuflen, &iRead); - - if (iRetcode) - return iRetcode; - - if (pData->bSuspended) /* suspended ? */ - pData->iSuspendpoint = 4; - else - { - if (iRead != iBuflen) /* did we get all the data ? */ - iRetcode = MNG_UNEXPECTEDEOF; - else - { - mng_uint32 iL = iBuflen - (mng_uint32)(sizeof (iCrc)); - /* calculate the crc */ - iCrc = crc (pData, pData->pLargebuf, iL); - /* and check it */ - if (!(iCrc == mng_get_uint32 (pData->pLargebuf + iL))) - iRetcode = MNG_INVALIDCRC; - else - iRetcode = process_raw_chunk (pData, pData->pLargebuf, iL); - } - /* cleanup additional large buffer */ - MNG_FREE (pData, pData->pLargebuf, pData->iLargebufsize) - } - } - - if (iRetcode) /* on error bail out */ - return iRetcode; - - } - else - { /* that's final */ - iRetcode = process_eof (pData); - - if (iRetcode) /* on error bail out */ - return iRetcode; - - if ((iRead != 0) || /* did we get an unexpected eof ? */ -#ifdef MNG_INCLUDE_JNG - (pData->bHasIHDR || pData->bHasMHDR || pData->bHasJHDR)) -#else - (pData->bHasIHDR || pData->bHasMHDR)) -#endif - MNG_ERROR (pData, MNG_UNEXPECTEDEOF); - } - } - } - -#ifdef MNG_SUPPORT_DISPLAY /* refresh needed ? */ - if ((!pData->bTimerset) && (!pData->bSuspended) && (pData->bNeedrefresh)) - { - iRetcode = display_progressive_refresh (pData, 1); - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#endif - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_CHUNK, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode read_graphic (mng_datap pData) -{ - mng_uint32 iBuflen; /* number of bytes requested */ - mng_uint32 iRead; /* number of bytes read */ - mng_retcode iRetcode; /* temporary error-code */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_GRAPHIC, MNG_LC_START) -#endif - - if (!pData->pReadbuf) /* buffer allocated ? */ - { - pData->iReadbufsize = 4200; /* allocate a default read buffer */ - MNG_ALLOC (pData, pData->pReadbuf, pData->iReadbufsize) - } - /* haven't processed the signature ? */ - if ((!pData->bHavesig) || (pData->iSuspendpoint == 1)) - { - iBuflen = 2 * sizeof (mng_uint32); /* read signature */ - - iRetcode = read_databuffer (pData, pData->pReadbuf, iBuflen, &iRead); - - if (iRetcode) - return iRetcode; - - if (pData->bSuspended) /* input suspension ? */ - pData->iSuspendpoint = 1; - else - { - if (iRead != iBuflen) /* full signature received ? */ - MNG_ERROR (pData, MNG_UNEXPECTEDEOF); - /* is it a valid signature ? */ - if (mng_get_uint32 (pData->pReadbuf) == PNG_SIG) - pData->eSigtype = mng_it_png; - else - if (mng_get_uint32 (pData->pReadbuf) == JNG_SIG) - pData->eSigtype = mng_it_jng; - else - if (mng_get_uint32 (pData->pReadbuf) == MNG_SIG) - pData->eSigtype = mng_it_mng; - else - MNG_ERROR (pData, MNG_INVALIDSIG); - /* all of it ? */ - if (mng_get_uint32 (pData->pReadbuf+4) != POST_SIG) - MNG_ERROR (pData, MNG_INVALIDSIG); - - pData->bHavesig = MNG_TRUE; - } - } - - if (!pData->bSuspended) /* still going ? */ - { - do - { - iRetcode = read_chunk (pData); /* process a chunk */ - - if (iRetcode) /* on error bail out */ - return iRetcode; - } -#ifdef MNG_SUPPORT_DISPLAY /* until EOF or a break-request */ - while (((!pData->bEOF) || (pData->pCurraniobj)) && (!pData->bSuspended) && - (!pData->bTimerset) && (!pData->bSectionwait)); -#else - while ((!pData->bEOF) && (!pData->bSuspended)); -#endif - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_READ_GRAPHIC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_READ_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_read.h b/freeimage241/Source/LibMNG/libmng_read.h deleted file mode 100644 index 280043d..0000000 --- a/freeimage241/Source/LibMNG/libmng_read.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_read.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Read management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the read management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 10/18/2000 - G.Juyn * */ -/* * - added closestream() processing for mng_cleanup() * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_read_h_ -#define _libmng_read_h_ - -/* ************************************************************************** */ - -mng_retcode process_eof (mng_datap pData); - -mng_retcode read_graphic (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_read_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_trace.c b/freeimage241/Source/LibMNG/libmng_trace.c deleted file mode 100644 index acf44a4..0000000 --- a/freeimage241/Source/LibMNG/libmng_trace.c +++ /dev/null @@ -1,1170 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_trace.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Trace functions (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the trace functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - added callback error-reporting support * */ -/* * * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - added trace telltale reporting * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added tracestrings for global animation color-chunks * */ -/* * - added tracestrings for get/set of default ZLIB/IJG parms * */ -/* * - added tracestrings for global PLTE,tRNS,bKGD * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added tracestrings for image-object promotion * */ -/* * - added tracestrings for delta-image processing * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added tracestrings for getalphaline callback * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added tracestring for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added tracestring for mng_read_resume HLAPI function * */ -/* * * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added tracestrings for get/set speedtype * */ -/* * - added tracestring for get imagelevel * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added tracestring for delta-image processing * */ -/* * - added tracestrings for PPLT chunk processing * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added tracecodes for special display processing * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added tracestring for get/set suspensionmode * */ -/* * - added tracestrings for get/set display variables * */ -/* * - added tracecode for read_databuffer (I/O-suspension) * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added tracestrings for SAVE/SEEK callbacks * */ -/* * - added tracestrings for get/set sectionbreaks * */ -/* * - added tracestring for special error routine * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added tracestring for updatemngheader * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - added tracestrings for status_xxxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added tracestring for updatemngsimplicity * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * - added optional support for bKGD for PNG images * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - added routine to discard "invalid" objects * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_TRACE_PROCS - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_TRACE_STRINGS - mng_trace_entry trace_table [] = - { - {MNG_FN_INITIALIZE, "initialize"}, - {MNG_FN_RESET, "reset"}, - {MNG_FN_CLEANUP, "cleanup"}, - {MNG_FN_READ, "read"}, - {MNG_FN_WRITE, "write"}, - {MNG_FN_CREATE, "create"}, - {MNG_FN_READDISPLAY, "readdisplay"}, - {MNG_FN_DISPLAY, "display"}, - {MNG_FN_DISPLAY_RESUME, "display_resume"}, - {MNG_FN_DISPLAY_FREEZE, "display_freeze"}, - {MNG_FN_DISPLAY_RESET, "display_reset"}, - {MNG_FN_DISPLAY_GOFRAME, "display_goframe"}, - {MNG_FN_DISPLAY_GOLAYER, "display_golayer"}, - {MNG_FN_DISPLAY_GOTIME, "display_gotime"}, - {MNG_FN_GETLASTERROR, "getlasterror"}, - {MNG_FN_READ_RESUME, "read_resume"}, - - {MNG_FN_SETCB_MEMALLOC, "setcb_memalloc"}, - {MNG_FN_SETCB_MEMFREE, "setcb_memfree"}, - {MNG_FN_SETCB_READDATA, "setcb_readdata"}, - {MNG_FN_SETCB_WRITEDATA, "setcb_writedata"}, - {MNG_FN_SETCB_ERRORPROC, "setcb_errorproc"}, - {MNG_FN_SETCB_TRACEPROC, "setcb_traceproc"}, - {MNG_FN_SETCB_PROCESSHEADER, "setcb_processheader"}, - {MNG_FN_SETCB_PROCESSTEXT, "setcb_processtext"}, - {MNG_FN_SETCB_GETCANVASLINE, "setcb_getcanvasline"}, - {MNG_FN_SETCB_GETBKGDLINE, "setcb_getbkgdline"}, - {MNG_FN_SETCB_REFRESH, "setcb_refresh"}, - {MNG_FN_SETCB_GETTICKCOUNT, "setcb_gettickcount"}, - {MNG_FN_SETCB_SETTIMER, "setcb_settimer"}, - {MNG_FN_SETCB_PROCESSGAMMA, "setcb_processgamma"}, - {MNG_FN_SETCB_PROCESSCHROMA, "setcb_processchroma"}, - {MNG_FN_SETCB_PROCESSSRGB, "setcb_processsrgb"}, - {MNG_FN_SETCB_PROCESSICCP, "setcb_processiccp"}, - {MNG_FN_SETCB_PROCESSAROW, "setcb_processarow"}, - {MNG_FN_SETCB_OPENSTREAM, "setcb_openstream"}, - {MNG_FN_SETCB_CLOSESTREAM, "setcb_closestream"}, - {MNG_FN_SETCB_GETALPHALINE, "setcb_getalphaline"}, - {MNG_FN_SETCB_PROCESSSAVE, "setcb_processsave"}, - {MNG_FN_SETCB_PROCESSSEEK, "setcb_processseek"}, - {MNG_FN_SETCB_PROCESSNEED, "setcb_processneed"}, - {MNG_FN_SETCB_PROCESSUNKNOWN, "setcb_processunknown"}, - {MNG_FN_SETCB_PROCESSMEND, "setcb_processmend"}, - {MNG_FN_SETCB_PROCESSTERM, "setcb_processterm"}, - - {MNG_FN_GETCB_MEMALLOC, "getcb_memalloc"}, - {MNG_FN_GETCB_MEMFREE, "getcb_memfree"}, - {MNG_FN_GETCB_READDATA, "getcb_readdata,"}, - {MNG_FN_GETCB_WRITEDATA, "getcb_writedata"}, - {MNG_FN_GETCB_ERRORPROC, "getcb_errorproc"}, - {MNG_FN_GETCB_TRACEPROC, "getcb_traceproc"}, - {MNG_FN_GETCB_PROCESSHEADER, "getcb_processheader"}, - {MNG_FN_GETCB_PROCESSTEXT, "getcb_processtext"}, - {MNG_FN_GETCB_GETCANVASLINE, "getcb_getcanvasline"}, - {MNG_FN_GETCB_GETBKGDLINE, "getcb_getbkgdline"}, - {MNG_FN_GETCB_REFRESH, "getcb_refresh"}, - {MNG_FN_GETCB_GETTICKCOUNT, "getcb_gettickcount"}, - {MNG_FN_GETCB_SETTIMER, "getcb_settimer"}, - {MNG_FN_GETCB_PROCESSGAMMA, "getcb_processgamma"}, - {MNG_FN_GETCB_PROCESSCHROMA, "getcb_processchroma"}, - {MNG_FN_GETCB_PROCESSSRGB, "getcb_processsrgb"}, - {MNG_FN_GETCB_PROCESSICCP, "getcb_processiccp"}, - {MNG_FN_GETCB_PROCESSAROW, "getcb_processarow"}, - {MNG_FN_GETCB_OPENSTREAM, "getcb_openstream"}, - {MNG_FN_GETCB_CLOSESTREAM, "getcb_closestream"}, - {MNG_FN_GETCB_GETALPHALINE, "getcb_getalphaline"}, - {MNG_FN_GETCB_PROCESSSAVE, "getcb_processsave"}, - {MNG_FN_GETCB_PROCESSSEEK, "getcb_processseek"}, - {MNG_FN_GETCB_PROCESSNEED, "getcb_processneed"}, - {MNG_FN_GETCB_PROCESSUNKNOWN, "getcb_processunknown"}, - {MNG_FN_GETCB_PROCESSMEND, "getcb_processmend"}, - {MNG_FN_GETCB_PROCESSTERM, "getcb_processterm"}, - - {MNG_FN_SET_USERDATA, "set_userdata"}, - {MNG_FN_SET_CANVASSTYLE, "set_canvasstyle"}, - {MNG_FN_SET_BKGDSTYLE, "set_bkgdstyle"}, - {MNG_FN_SET_BGCOLOR, "set_bgcolor"}, - {MNG_FN_SET_STORECHUNKS, "set_storechunks"}, - {MNG_FN_SET_VIEWGAMMA, "set_viewgamma"}, - {MNG_FN_SET_DISPLAYGAMMA, "set_displaygamma"}, - {MNG_FN_SET_DFLTIMGGAMMA, "set_dfltimggamma"}, - {MNG_FN_SET_SRGB, "set_srgb"}, - {MNG_FN_SET_OUTPUTPROFILE, "set_outputprofile"}, - {MNG_FN_SET_SRGBPROFILE, "set_srgbprofile"}, - {MNG_FN_SET_MAXCANVASWIDTH, "set_maxcanvaswidth"}, - {MNG_FN_SET_MAXCANVASHEIGHT, "set_maxcanvasheight"}, - {MNG_FN_SET_MAXCANVASSIZE, "set_maxcanvassize"}, - {MNG_FN_SET_ZLIB_LEVEL, "set_zlib_level"}, - {MNG_FN_SET_ZLIB_METHOD, "set_zlib_method"}, - {MNG_FN_SET_ZLIB_WINDOWBITS, "set_zlib_windowbits"}, - {MNG_FN_SET_ZLIB_MEMLEVEL, "set_zlib_memlevel"}, - {MNG_FN_SET_ZLIB_STRATEGY, "set_zlib_strategy"}, - {MNG_FN_SET_ZLIB_MAXIDAT, "set_zlib_maxidat"}, - {MNG_FN_SET_JPEG_DCTMETHOD, "set_jpeg_dctmethod"}, - {MNG_FN_SET_JPEG_QUALITY, "set_jpeg_quality"}, - {MNG_FN_SET_JPEG_SMOOTHING, "set_jpeg_smoothing"}, - {MNG_FN_SET_JPEG_PROGRESSIVE, "set_jpeg_progressive"}, - {MNG_FN_SET_JPEG_OPTIMIZED, "set_jpeg_optimized"}, - {MNG_FN_SET_JPEG_MAXJDAT, "set_jpeg_maxjdat"}, - {MNG_FN_SET_SPEED, "set_speed"}, - {MNG_FN_SET_SUSPENSIONMODE, "set_suspensionmode"}, - {MNG_FN_SET_SECTIONBREAKS, "set_sectionbreaks"}, - {MNG_FN_SET_USEBKGD, "set_usebkgd"}, - {MNG_FN_SET_OUTPUTPROFILE2, "set_outputprofile2"}, - {MNG_FN_SET_SRGBPROFILE2, "set_srgbprofile2"}, - {MNG_FN_SET_OUTPUTSRGB, "set_outputsrgb"}, - {MNG_FN_SET_SRGBIMPLICIT, "set_srgbimplicit"}, - {MNG_FN_SET_CACHEPLAYBACK, "set_cacheplayback"}, - {MNG_FN_SET_DOPROGRESSIVE, "set_doprogressive"}, - - {MNG_FN_GET_USERDATA, "get_userdata"}, - {MNG_FN_GET_SIGTYPE, "get_sigtype"}, - {MNG_FN_GET_IMAGETYPE, "get_imagetype"}, - {MNG_FN_GET_IMAGEWIDTH, "get_imagewidth"}, - {MNG_FN_GET_IMAGEHEIGHT, "get_imageheight"}, - {MNG_FN_GET_TICKS, "get_ticks"}, - {MNG_FN_GET_FRAMECOUNT, "get_framecount"}, - {MNG_FN_GET_LAYERCOUNT, "get_layercount"}, - {MNG_FN_GET_PLAYTIME, "get_playtime"}, - {MNG_FN_GET_SIMPLICITY, "get_simplicity"}, - {MNG_FN_GET_CANVASSTYLE, "get_canvasstyle"}, - {MNG_FN_GET_BKGDSTYLE, "get_bkgdstyle"}, - {MNG_FN_GET_BGCOLOR, "get_bgcolor"}, - {MNG_FN_GET_STORECHUNKS, "get_storechunks"}, - {MNG_FN_GET_VIEWGAMMA, "get_viewgamma"}, - {MNG_FN_GET_DISPLAYGAMMA, "get_displaygamma"}, - {MNG_FN_GET_DFLTIMGGAMMA, "get_dfltimggamma"}, - {MNG_FN_GET_SRGB, "get_srgb"}, - {MNG_FN_GET_MAXCANVASWIDTH, "get_maxcanvaswidth"}, - {MNG_FN_GET_MAXCANVASHEIGHT, "get_maxcanvasheight"}, - {MNG_FN_GET_ZLIB_LEVEL, "get_zlib_level"}, - {MNG_FN_GET_ZLIB_METHOD, "get_zlib_method"}, - {MNG_FN_GET_ZLIB_WINDOWBITS, "get_zlib_windowbits"}, - {MNG_FN_GET_ZLIB_MEMLEVEL, "get_zlib_memlevel"}, - {MNG_FN_GET_ZLIB_STRATEGY, "get_zlib_strategy"}, - {MNG_FN_GET_ZLIB_MAXIDAT, "get_zlib_maxidat"}, - {MNG_FN_GET_JPEG_DCTMETHOD, "get_jpeg_dctmethod"}, - {MNG_FN_GET_JPEG_QUALITY, "get_jpeg_quality"}, - {MNG_FN_GET_JPEG_SMOOTHING, "get_jpeg_smoothing"}, - {MNG_FN_GET_JPEG_PROGRESSIVE, "get_jpeg_progressive"}, - {MNG_FN_GET_JPEG_OPTIMIZED, "get_jpeg_optimized"}, - {MNG_FN_GET_JPEG_MAXJDAT, "get_jpeg_maxjdat"}, - {MNG_FN_GET_SPEED, "get_speed"}, - {MNG_FN_GET_IMAGELEVEL, "get_imagelevel"}, - {MNG_FN_GET_SUSPENSIONMODE, "get_speed"}, - {MNG_FN_GET_STARTTIME, "get_starttime"}, - {MNG_FN_GET_RUNTIME, "get_runtime"}, - {MNG_FN_GET_CURRENTFRAME, "get_currentframe"}, - {MNG_FN_GET_CURRENTLAYER, "get_currentlayer"}, - {MNG_FN_GET_CURRENTPLAYTIME, "get_currentplaytime"}, - {MNG_FN_GET_SECTIONBREAKS, "get_sectionbreaks"}, - {MNG_FN_GET_ALPHADEPTH, "get_alphadepth"}, - {MNG_FN_GET_BITDEPTH, "get_bitdepth"}, - {MNG_FN_GET_COLORTYPE, "get_colortype"}, - {MNG_FN_GET_COMPRESSION, "get_compression"}, - {MNG_FN_GET_FILTER, "get_filter"}, - {MNG_FN_GET_INTERLACE, "get_interlace"}, - {MNG_FN_GET_ALPHABITDEPTH, "get_alphabitdepth"}, - {MNG_FN_GET_ALPHACOMPRESSION, "get_alphacompression"}, - {MNG_FN_GET_ALPHAFILTER, "get_alphafilter"}, - {MNG_FN_GET_ALPHAINTERLACE, "get_alphainterlace"}, - {MNG_FN_GET_USEBKGD, "get_usebkgd"}, - {MNG_FN_GET_REFRESHPASS, "get_refreshpass"}, - {MNG_FN_GET_CACHEPLAYBACK, "get_cacheplayback"}, - {MNG_FN_GET_DOPROGRESSIVE, "get_doprogressive"}, - - {MNG_FN_STATUS_ERROR, "status_error"}, - {MNG_FN_STATUS_READING, "status_reading"}, - {MNG_FN_STATUS_SUSPENDBREAK, "status_suspendbreak"}, - {MNG_FN_STATUS_CREATING, "status_creating"}, - {MNG_FN_STATUS_WRITING, "status_writing"}, - {MNG_FN_STATUS_DISPLAYING, "status_displaying"}, - {MNG_FN_STATUS_RUNNING, "status_running"}, - {MNG_FN_STATUS_TIMERBREAK, "status_timerbreak"}, - - {MNG_FN_ITERATE_CHUNKS, "iterate_chunks"}, - - {MNG_FN_GETCHUNK_IHDR, "getchunk_ihdr"}, - {MNG_FN_GETCHUNK_PLTE, "getchunk_plte"}, - {MNG_FN_GETCHUNK_IDAT, "getchunk_idat"}, - {MNG_FN_GETCHUNK_IEND, "getchunk_iend"}, - {MNG_FN_GETCHUNK_TRNS, "getchunk_trns"}, - {MNG_FN_GETCHUNK_GAMA, "getchunk_gama"}, - {MNG_FN_GETCHUNK_CHRM, "getchunk_chrm"}, - {MNG_FN_GETCHUNK_SRGB, "getchunk_srgb"}, - {MNG_FN_GETCHUNK_ICCP, "getchunk_iccp"}, - {MNG_FN_GETCHUNK_TEXT, "getchunk_text"}, - {MNG_FN_GETCHUNK_ZTXT, "getchunk_ztxt"}, - {MNG_FN_GETCHUNK_ITXT, "getchunk_itxt"}, - {MNG_FN_GETCHUNK_BKGD, "getchunk_bkgd"}, - {MNG_FN_GETCHUNK_PHYS, "getchunk_phys"}, - {MNG_FN_GETCHUNK_SBIT, "getchunk_sbit"}, - {MNG_FN_GETCHUNK_SPLT, "getchunk_splt"}, - {MNG_FN_GETCHUNK_HIST, "getchunk_hist"}, - {MNG_FN_GETCHUNK_TIME, "getchunk_time"}, - {MNG_FN_GETCHUNK_MHDR, "getchunk_mhdr"}, - {MNG_FN_GETCHUNK_MEND, "getchunk_mend"}, - {MNG_FN_GETCHUNK_LOOP, "getchunk_loop"}, - {MNG_FN_GETCHUNK_ENDL, "getchunk_endl"}, - {MNG_FN_GETCHUNK_DEFI, "getchunk_defi"}, - {MNG_FN_GETCHUNK_BASI, "getchunk_basi"}, - {MNG_FN_GETCHUNK_CLON, "getchunk_clon"}, - {MNG_FN_GETCHUNK_PAST, "getchunk_past"}, - {MNG_FN_GETCHUNK_DISC, "getchunk_disc"}, - {MNG_FN_GETCHUNK_BACK, "getchunk_back"}, - {MNG_FN_GETCHUNK_FRAM, "getchunk_fram"}, - {MNG_FN_GETCHUNK_MOVE, "getchunk_move"}, - {MNG_FN_GETCHUNK_CLIP, "getchunk_clip"}, - {MNG_FN_GETCHUNK_SHOW, "getchunk_show"}, - {MNG_FN_GETCHUNK_TERM, "getchunk_term"}, - {MNG_FN_GETCHUNK_SAVE, "getchunk_save"}, - {MNG_FN_GETCHUNK_SEEK, "getchunk_seek"}, - {MNG_FN_GETCHUNK_EXPI, "getchunk_expi"}, - {MNG_FN_GETCHUNK_FPRI, "getchunk_fpri"}, - {MNG_FN_GETCHUNK_NEED, "getchunk_need"}, - {MNG_FN_GETCHUNK_PHYG, "getchunk_phyg"}, - {MNG_FN_GETCHUNK_JHDR, "getchunk_jhdr"}, - {MNG_FN_GETCHUNK_JDAT, "getchunk_jdat"}, - {MNG_FN_GETCHUNK_JSEP, "getchunk_jsep"}, - {MNG_FN_GETCHUNK_DHDR, "getchunk_dhdr"}, - {MNG_FN_GETCHUNK_PROM, "getchunk_prom"}, - {MNG_FN_GETCHUNK_IPNG, "getchunk_ipng"}, - {MNG_FN_GETCHUNK_PPLT, "getchunk_pplt"}, - {MNG_FN_GETCHUNK_IJNG, "getchunk_ijng"}, - {MNG_FN_GETCHUNK_DROP, "getchunk_drop"}, - {MNG_FN_GETCHUNK_DBYK, "getchunk_dbyk"}, - {MNG_FN_GETCHUNK_ORDR, "getchunk_ordr"}, - {MNG_FN_GETCHUNK_UNKNOWN, "getchunk_unknown"}, - {MNG_FN_GETCHUNK_MAGN, "getchunk_magn"}, - {MNG_FN_GETCHUNK_JDAA, "getchunk_jdaa"}, - - {MNG_FN_GETCHUNK_PAST_SRC, "getchunk_past_src"}, - {MNG_FN_GETCHUNK_SAVE_ENTRY, "getchunk_save_entry"}, - {MNG_FN_GETCHUNK_PPLT_ENTRY, "getchunk_pplt_entry"}, - {MNG_FN_GETCHUNK_ORDR_ENTRY, "getchunk_ordr_entry"}, - - {MNG_FN_PUTCHUNK_IHDR, "putchunk_ihdr"}, - {MNG_FN_PUTCHUNK_PLTE, "putchunk_plte"}, - {MNG_FN_PUTCHUNK_IDAT, "putchunk_idat"}, - {MNG_FN_PUTCHUNK_IEND, "putchunk_iend"}, - {MNG_FN_PUTCHUNK_TRNS, "putchunk_trns"}, - {MNG_FN_PUTCHUNK_GAMA, "putchunk_gama"}, - {MNG_FN_PUTCHUNK_CHRM, "putchunk_chrm"}, - {MNG_FN_PUTCHUNK_SRGB, "putchunk_srgb"}, - {MNG_FN_PUTCHUNK_ICCP, "putchunk_iccp"}, - {MNG_FN_PUTCHUNK_TEXT, "putchunk_text"}, - {MNG_FN_PUTCHUNK_ZTXT, "putchunk_ztxt"}, - {MNG_FN_PUTCHUNK_ITXT, "putchunk_itxt"}, - {MNG_FN_PUTCHUNK_BKGD, "putchunk_bkgd"}, - {MNG_FN_PUTCHUNK_PHYS, "putchunk_phys"}, - {MNG_FN_PUTCHUNK_SBIT, "putchunk_sbit"}, - {MNG_FN_PUTCHUNK_SPLT, "putchunk_splt"}, - {MNG_FN_PUTCHUNK_HIST, "putchunk_hist"}, - {MNG_FN_PUTCHUNK_TIME, "putchunk_time"}, - {MNG_FN_PUTCHUNK_MHDR, "putchunk_mhdr"}, - {MNG_FN_PUTCHUNK_MEND, "putchunk_mend"}, - {MNG_FN_PUTCHUNK_LOOP, "putchunk_loop"}, - {MNG_FN_PUTCHUNK_ENDL, "putchunk_endl"}, - {MNG_FN_PUTCHUNK_DEFI, "putchunk_defi"}, - {MNG_FN_PUTCHUNK_BASI, "putchunk_basi"}, - {MNG_FN_PUTCHUNK_CLON, "putchunk_clon"}, - {MNG_FN_PUTCHUNK_PAST, "putchunk_past"}, - {MNG_FN_PUTCHUNK_DISC, "putchunk_disc"}, - {MNG_FN_PUTCHUNK_BACK, "putchunk_back"}, - {MNG_FN_PUTCHUNK_FRAM, "putchunk_fram"}, - {MNG_FN_PUTCHUNK_MOVE, "putchunk_move"}, - {MNG_FN_PUTCHUNK_CLIP, "putchunk_clip"}, - {MNG_FN_PUTCHUNK_SHOW, "putchunk_show"}, - {MNG_FN_PUTCHUNK_TERM, "putchunk_term"}, - {MNG_FN_PUTCHUNK_SAVE, "putchunk_save"}, - {MNG_FN_PUTCHUNK_SEEK, "putchunk_seek"}, - {MNG_FN_PUTCHUNK_EXPI, "putchunk_expi"}, - {MNG_FN_PUTCHUNK_FPRI, "putchunk_fpri"}, - {MNG_FN_PUTCHUNK_NEED, "putchunk_need"}, - {MNG_FN_PUTCHUNK_PHYG, "putchunk_phyg"}, - {MNG_FN_PUTCHUNK_JHDR, "putchunk_jhdr"}, - {MNG_FN_PUTCHUNK_JDAT, "putchunk_jdat"}, - {MNG_FN_PUTCHUNK_JSEP, "putchunk_jsep"}, - {MNG_FN_PUTCHUNK_DHDR, "putchunk_dhdr"}, - {MNG_FN_PUTCHUNK_PROM, "putchunk_prom"}, - {MNG_FN_PUTCHUNK_IPNG, "putchunk_ipng"}, - {MNG_FN_PUTCHUNK_PPLT, "putchunk_pplt"}, - {MNG_FN_PUTCHUNK_IJNG, "putchunk_ijng"}, - {MNG_FN_PUTCHUNK_DROP, "putchunk_drop"}, - {MNG_FN_PUTCHUNK_DBYK, "putchunk_dbyk"}, - {MNG_FN_PUTCHUNK_ORDR, "putchunk_ordr"}, - {MNG_FN_PUTCHUNK_UNKNOWN, "putchunk_unknown"}, - {MNG_FN_PUTCHUNK_MAGN, "putchunk_magn"}, - {MNG_FN_PUTCHUNK_JDAA, "putchunk_jdaa"}, - - {MNG_FN_PUTCHUNK_PAST_SRC, "putchunk_past_src"}, - {MNG_FN_PUTCHUNK_SAVE_ENTRY, "putchunk_save_entry"}, - {MNG_FN_PUTCHUNK_PPLT_ENTRY, "putchunk_pplt_entry"}, - {MNG_FN_PUTCHUNK_ORDR_ENTRY, "putchunk_ordr_entry"}, - - {MNG_FN_GETIMGDATA_SEQ, "getimgdata_seq"}, - {MNG_FN_GETIMGDATA_CHUNKSEQ, "getimgdata_chunkseq"}, - {MNG_FN_GETIMGDATA_CHUNK, "getimgdata_chunk"}, - - {MNG_FN_PUTIMGDATA_IHDR, "putimgdata_ihdr"}, - {MNG_FN_PUTIMGDATA_JHDR, "putimgdata_jhdr"}, - {MNG_FN_PUTIMGDATA_BASI, "putimgdata_basi"}, - {MNG_FN_PUTIMGDATA_DHDR, "putimgdata_dhdr"}, - - {MNG_FN_UPDATEMNGHEADER, "updatemngheader"}, - {MNG_FN_UPDATEMNGSIMPLICITY, "updatemngsimplicity"}, - - {MNG_FN_PROCESS_RAW_CHUNK, "process_raw_chunk"}, - {MNG_FN_READ_GRAPHIC, "read_graphic"}, - {MNG_FN_DROP_CHUNKS, "drop_chunks"}, - {MNG_FN_PROCESS_ERROR, "process_error"}, - {MNG_FN_CLEAR_CMS, "clear_cms"}, - {MNG_FN_DROP_OBJECTS, "drop_objects"}, - {MNG_FN_READ_CHUNK, "read_chunk"}, - {MNG_FN_LOAD_BKGDLAYER, "load_bkgdlayer"}, - {MNG_FN_NEXT_FRAME, "next_frame"}, - {MNG_FN_NEXT_LAYER, "next_layer"}, - {MNG_FN_INTERFRAME_DELAY, "interframe_delay"}, - {MNG_FN_DISPLAY_IMAGE, "display_image"}, - {MNG_FN_DROP_IMGOBJECTS, "drop_imgobjects"}, - {MNG_FN_DROP_ANIOBJECTS, "drop_aniobjects"}, - {MNG_FN_INFLATE_BUFFER, "inflate_buffer"}, - {MNG_FN_DEFLATE_BUFFER, "deflate_buffer"}, - {MNG_FN_WRITE_RAW_CHUNK, "write_raw_chunk"}, - {MNG_FN_WRITE_GRAPHIC, "write_graphic"}, - {MNG_FN_SAVE_STATE, "save_state"}, - {MNG_FN_RESTORE_STATE, "restore_state"}, - {MNG_FN_DROP_SAVEDATA, "drop_savedata"}, - {MNG_FN_EXECUTE_DELTA_IMAGE, "execute_delta_image"}, - {MNG_FN_PROCESS_DISPLAY, "process_display"}, - {MNG_FN_CLEAR_CANVAS, "clear_canvas"}, - {MNG_FN_READ_DATABUFFER, "read_databuffer"}, - {MNG_FN_STORE_ERROR, "store_error"}, - {MNG_FN_DROP_INVALID_OBJECTS, "drop_invalid_objects"}, - - {MNG_FN_DISPLAY_RGB8, "display_rgb8"}, - {MNG_FN_DISPLAY_RGBA8, "display_rgba8"}, - {MNG_FN_DISPLAY_ARGB8, "display_argb8"}, - {MNG_FN_DISPLAY_BGR8, "display_bgr8"}, - {MNG_FN_DISPLAY_BGRA8, "display_bgra8"}, - {MNG_FN_DISPLAY_ABGR8, "display_abgr8"}, - {MNG_FN_DISPLAY_RGB16, "display_rgb16"}, - {MNG_FN_DISPLAY_RGBA16, "display_rgba16"}, - {MNG_FN_DISPLAY_ARGB16, "display_argb16"}, - {MNG_FN_DISPLAY_BGR16, "display_bgr16"}, - {MNG_FN_DISPLAY_BGRA16, "display_bgra16"}, - {MNG_FN_DISPLAY_ABGR16, "display_abgr16"}, - {MNG_FN_DISPLAY_INDEX8, "display_index8"}, - {MNG_FN_DISPLAY_INDEXA8, "display_indexa8"}, - {MNG_FN_DISPLAY_AINDEX8, "display_aindex8"}, - {MNG_FN_DISPLAY_GRAY8, "display_gray8"}, - {MNG_FN_DISPLAY_GRAY16, "display_gray16"}, - {MNG_FN_DISPLAY_GRAYA8, "display_graya8"}, - {MNG_FN_DISPLAY_GRAYA16, "display_graya16"}, - {MNG_FN_DISPLAY_AGRAY8, "display_agray8"}, - {MNG_FN_DISPLAY_AGRAY16, "display_agray16"}, - {MNG_FN_DISPLAY_DX15, "display_dx15"}, - {MNG_FN_DISPLAY_DX16, "display_dx16"}, - {MNG_FN_DISPLAY_RGB8_A8, "display_rgb8_a8"}, - {MNG_FN_DISPLAY_BGRA8PM, "display_bgra8_pm"}, - - {MNG_FN_INIT_FULL_CMS, "init_full_cms"}, - {MNG_FN_CORRECT_FULL_CMS, "correct_full_cms"}, - {MNG_FN_INIT_GAMMA_ONLY, "init_gamma_only"}, - {MNG_FN_CORRECT_GAMMA_ONLY, "correct_gamma_only"}, - {MNG_FN_CORRECT_APP_CMS, "correct_app_cms"}, - {MNG_FN_INIT_FULL_CMS_OBJ, "init_full_cms_obj"}, - {MNG_FN_INIT_GAMMA_ONLY_OBJ, "init_gamma_only_obj"}, - {MNG_FN_INIT_APP_CMS, "init_app_cms"}, - {MNG_FN_INIT_APP_CMS_OBJ, "init_app_cms_obj"}, - - {MNG_FN_PROCESS_G1, "process_g1"}, - {MNG_FN_PROCESS_G2, "process_g2"}, - {MNG_FN_PROCESS_G4, "process_g4"}, - {MNG_FN_PROCESS_G8, "process_g8"}, - {MNG_FN_PROCESS_G16, "process_g16"}, - {MNG_FN_PROCESS_RGB8, "process_rgb8"}, - {MNG_FN_PROCESS_RGB16, "process_rgb16"}, - {MNG_FN_PROCESS_IDX1, "process_idx1"}, - {MNG_FN_PROCESS_IDX2, "process_idx2"}, - {MNG_FN_PROCESS_IDX4, "process_idx4"}, - {MNG_FN_PROCESS_IDX8, "process_idx8"}, - {MNG_FN_PROCESS_GA8, "process_ga8"}, - {MNG_FN_PROCESS_GA16, "process_ga16"}, - {MNG_FN_PROCESS_RGBA8, "process_rgba8"}, - {MNG_FN_PROCESS_RGBA16, "process_rgba16"}, - - {MNG_FN_INIT_G1_NI, "init_g1_ni"}, - {MNG_FN_INIT_G1_I, "init_g1_i"}, - {MNG_FN_INIT_G2_NI, "init_g2_ni"}, - {MNG_FN_INIT_G2_I, "init_g2_i"}, - {MNG_FN_INIT_G4_NI, "init_g4_ni"}, - {MNG_FN_INIT_G4_I, "init_g4_i"}, - {MNG_FN_INIT_G8_NI, "init_g8_ni"}, - {MNG_FN_INIT_G8_I, "init_g8_i"}, - {MNG_FN_INIT_G16_NI, "init_g16_ni"}, - {MNG_FN_INIT_G16_I, "init_g16_i"}, - {MNG_FN_INIT_RGB8_NI, "init_rgb8_ni"}, - {MNG_FN_INIT_RGB8_I, "init_rgb8_i"}, - {MNG_FN_INIT_RGB16_NI, "init_rgb16_ni"}, - {MNG_FN_INIT_RGB16_I, "init_rgb16_i"}, - {MNG_FN_INIT_IDX1_NI, "init_idx1_ni"}, - {MNG_FN_INIT_IDX1_I, "init_idx1_i"}, - {MNG_FN_INIT_IDX2_NI, "init_idx2_ni"}, - {MNG_FN_INIT_IDX2_I, "init_idx2_i"}, - {MNG_FN_INIT_IDX4_NI, "init_idx4_ni"}, - {MNG_FN_INIT_IDX4_I, "init_idx4_i"}, - {MNG_FN_INIT_IDX8_NI, "init_idx8_ni"}, - {MNG_FN_INIT_IDX8_I, "init_idx8_i"}, - {MNG_FN_INIT_GA8_NI, "init_ga8_ni"}, - {MNG_FN_INIT_GA8_I, "init_ga8_i"}, - {MNG_FN_INIT_GA16_NI, "init_ga16_ni"}, - {MNG_FN_INIT_GA16_I, "init_ga16_i"}, - {MNG_FN_INIT_RGBA8_NI, "init_rgba8_ni"}, - {MNG_FN_INIT_RGBA8_I, "init_rgba8_i"}, - {MNG_FN_INIT_RGBA16_NI, "init_rgba16_ni"}, - {MNG_FN_INIT_RGBA16_I, "init_rgba16_i"}, - - {MNG_FN_INIT_ROWPROC, "init_rowproc"}, - {MNG_FN_NEXT_ROW, "next_row"}, - {MNG_FN_CLEANUP_ROWPROC, "cleanup_rowproc"}, - - {MNG_FN_FILTER_A_ROW, "filter_a_row"}, - {MNG_FN_FILTER_SUB, "filter_sub"}, - {MNG_FN_FILTER_UP, "filter_up"}, - {MNG_FN_FILTER_AVERAGE, "filter_average"}, - {MNG_FN_FILTER_PAETH, "filter_paeth"}, - - {MNG_FN_INIT_ROWDIFFERING, "init_rowdiffering"}, - {MNG_FN_DIFFER_G1, "differ_g1"}, - {MNG_FN_DIFFER_G2, "differ_g2"}, - {MNG_FN_DIFFER_G4, "differ_g4"}, - {MNG_FN_DIFFER_G8, "differ_g8"}, - {MNG_FN_DIFFER_G16, "differ_g16"}, - {MNG_FN_DIFFER_RGB8, "differ_rgb8"}, - {MNG_FN_DIFFER_RGB16, "differ_rgb16"}, - {MNG_FN_DIFFER_IDX1, "differ_idx1"}, - {MNG_FN_DIFFER_IDX2, "differ_idx2"}, - {MNG_FN_DIFFER_IDX4, "differ_idx4"}, - {MNG_FN_DIFFER_IDX8, "differ_idx8"}, - {MNG_FN_DIFFER_GA8, "differ_ga8"}, - {MNG_FN_DIFFER_GA16, "differ_ga16"}, - {MNG_FN_DIFFER_RGBA8, "differ_rgba8"}, - {MNG_FN_DIFFER_RGBA16, "differ_rgba16"}, - - {MNG_FN_CREATE_IMGDATAOBJECT, "create_imgdataobject"}, - {MNG_FN_FREE_IMGDATAOBJECT, "free_imgdataobject"}, - {MNG_FN_CLONE_IMGDATAOBJECT, "clone_imgdataobject"}, - {MNG_FN_CREATE_IMGOBJECT, "create_imgobject"}, - {MNG_FN_FREE_IMGOBJECT, "free_imgobject"}, - {MNG_FN_FIND_IMGOBJECT, "find_imgobject"}, - {MNG_FN_CLONE_IMGOBJECT, "clone_imgobject"}, - {MNG_FN_RESET_OBJECTDETAILS, "reset_objectdetails"}, - {MNG_FN_RENUM_IMGOBJECT, "renum_imgobject"}, - {MNG_FN_PROMOTE_IMGOBJECT, "promote_imgobject"}, - {MNG_FN_MAGNIFY_IMGOBJECT, "magnify_imgobject"}, - - {MNG_FN_STORE_G1, "store_g1"}, - {MNG_FN_STORE_G2, "store_g2"}, - {MNG_FN_STORE_G4, "store_g4"}, - {MNG_FN_STORE_G8, "store_g8"}, - {MNG_FN_STORE_G16, "store_g16"}, - {MNG_FN_STORE_RGB8, "store_rgb8"}, - {MNG_FN_STORE_RGB16, "store_rgb16"}, - {MNG_FN_STORE_IDX1, "store_idx1"}, - {MNG_FN_STORE_IDX2, "store_idx2"}, - {MNG_FN_STORE_IDX4, "store_idx4"}, - {MNG_FN_STORE_IDX8, "store_idx8"}, - {MNG_FN_STORE_GA8, "store_ga8"}, - {MNG_FN_STORE_GA16, "store_ga16"}, - {MNG_FN_STORE_RGBA8, "store_rgba8"}, - {MNG_FN_STORE_RGBA16, "store_rgba16"}, - - {MNG_FN_RETRIEVE_G8, "retrieve_g8"}, - {MNG_FN_RETRIEVE_G16, "retrieve_g16"}, - {MNG_FN_RETRIEVE_RGB8, "retrieve_rgb8"}, - {MNG_FN_RETRIEVE_RGB16, "retrieve_rgb16"}, - {MNG_FN_RETRIEVE_IDX8, "retrieve_idx8"}, - {MNG_FN_RETRIEVE_GA8, "retrieve_ga8"}, - {MNG_FN_RETRIEVE_GA16, "retrieve_ga16"}, - {MNG_FN_RETRIEVE_RGBA8, "retrieve_rgba8"}, - {MNG_FN_RETRIEVE_RGBA16, "retrieve_rgba16"}, - - {MNG_FN_DELTA_G1, "delta_g1"}, - {MNG_FN_DELTA_G2, "delta_g2"}, - {MNG_FN_DELTA_G4, "delta_g4"}, - {MNG_FN_DELTA_G8, "delta_g8"}, - {MNG_FN_DELTA_G16, "delta_g16"}, - {MNG_FN_DELTA_RGB8, "delta_rgb8"}, - {MNG_FN_DELTA_RGB16, "delta_rgb16"}, - {MNG_FN_DELTA_IDX1, "delta_idx1"}, - {MNG_FN_DELTA_IDX2, "delta_idx2"}, - {MNG_FN_DELTA_IDX4, "delta_idx4"}, - {MNG_FN_DELTA_IDX8, "delta_idx8"}, - {MNG_FN_DELTA_GA8, "delta_ga8"}, - {MNG_FN_DELTA_GA16, "delta_ga16"}, - {MNG_FN_DELTA_RGBA8, "delta_rgba8"}, - {MNG_FN_DELTA_RGBA16, "delta_rgba16"}, - - {MNG_FN_CREATE_ANI_LOOP, "create_ani_loop"}, - {MNG_FN_CREATE_ANI_ENDL, "create_ani_endl"}, - {MNG_FN_CREATE_ANI_DEFI, "create_ani_defi"}, - {MNG_FN_CREATE_ANI_BASI, "create_ani_basi"}, - {MNG_FN_CREATE_ANI_CLON, "create_ani_clon"}, - {MNG_FN_CREATE_ANI_PAST, "create_ani_past"}, - {MNG_FN_CREATE_ANI_DISC, "create_ani_disc"}, - {MNG_FN_CREATE_ANI_BACK, "create_ani_back"}, - {MNG_FN_CREATE_ANI_FRAM, "create_ani_fram"}, - {MNG_FN_CREATE_ANI_MOVE, "create_ani_move"}, - {MNG_FN_CREATE_ANI_CLIP, "create_ani_clip"}, - {MNG_FN_CREATE_ANI_SHOW, "create_ani_show"}, - {MNG_FN_CREATE_ANI_TERM, "create_ani_term"}, - {MNG_FN_CREATE_ANI_SAVE, "create_ani_save"}, - {MNG_FN_CREATE_ANI_SEEK, "create_ani_seek"}, - {MNG_FN_CREATE_ANI_GAMA, "create_ani_gama"}, - {MNG_FN_CREATE_ANI_CHRM, "create_ani_chrm"}, - {MNG_FN_CREATE_ANI_SRGB, "create_ani_srgb"}, - {MNG_FN_CREATE_ANI_ICCP, "create_ani_iccp"}, - {MNG_FN_CREATE_ANI_PLTE, "create_ani_plte"}, - {MNG_FN_CREATE_ANI_TRNS, "create_ani_trns"}, - {MNG_FN_CREATE_ANI_BKGD, "create_ani_bkgd"}, - {MNG_FN_CREATE_ANI_DHDR, "create_ani_dhdr"}, - {MNG_FN_CREATE_ANI_PROM, "create_ani_prom"}, - {MNG_FN_CREATE_ANI_IPNG, "create_ani_ipng"}, - {MNG_FN_CREATE_ANI_IJNG, "create_ani_ijng"}, - {MNG_FN_CREATE_ANI_PPLT, "create_ani_pplt"}, - {MNG_FN_CREATE_ANI_MAGN, "create_ani_magn"}, - - {MNG_FN_CREATE_ANI_IMAGE, "create_ani_image"}, - - {MNG_FN_FREE_ANI_LOOP, "free_ani_loop"}, - {MNG_FN_FREE_ANI_ENDL, "free_ani_endl"}, - {MNG_FN_FREE_ANI_DEFI, "free_ani_defi"}, - {MNG_FN_FREE_ANI_BASI, "free_ani_basi"}, - {MNG_FN_FREE_ANI_CLON, "free_ani_clon"}, - {MNG_FN_FREE_ANI_PAST, "free_ani_past"}, - {MNG_FN_FREE_ANI_DISC, "free_ani_disc"}, - {MNG_FN_FREE_ANI_BACK, "free_ani_back"}, - {MNG_FN_FREE_ANI_FRAM, "free_ani_fram"}, - {MNG_FN_FREE_ANI_MOVE, "free_ani_move"}, - {MNG_FN_FREE_ANI_CLIP, "free_ani_clip"}, - {MNG_FN_FREE_ANI_SHOW, "free_ani_show"}, - {MNG_FN_FREE_ANI_TERM, "free_ani_term"}, - {MNG_FN_FREE_ANI_SAVE, "free_ani_save"}, - {MNG_FN_FREE_ANI_SEEK, "free_ani_seek"}, - {MNG_FN_FREE_ANI_GAMA, "free_ani_gama"}, - {MNG_FN_FREE_ANI_CHRM, "free_ani_chrm"}, - {MNG_FN_FREE_ANI_SRGB, "free_ani_srgb"}, - {MNG_FN_FREE_ANI_ICCP, "free_ani_iccp"}, - {MNG_FN_FREE_ANI_PLTE, "free_ani_plte"}, - {MNG_FN_FREE_ANI_TRNS, "free_ani_trns"}, - {MNG_FN_FREE_ANI_BKGD, "free_ani_bkgd"}, - {MNG_FN_FREE_ANI_DHDR, "free_ani_dhdr"}, - {MNG_FN_FREE_ANI_PROM, "free_ani_prom"}, - {MNG_FN_FREE_ANI_IPNG, "free_ani_ipng"}, - {MNG_FN_FREE_ANI_IJNG, "free_ani_ijng"}, - {MNG_FN_FREE_ANI_PPLT, "free_ani_pplt"}, - {MNG_FN_FREE_ANI_MAGN, "free_ani_magn"}, - - {MNG_FN_FREE_ANI_IMAGE, "free_ani_image"}, - - {MNG_FN_PROCESS_ANI_LOOP, "process_ani_loop"}, - {MNG_FN_PROCESS_ANI_ENDL, "process_ani_endl"}, - {MNG_FN_PROCESS_ANI_DEFI, "process_ani_defi"}, - {MNG_FN_PROCESS_ANI_BASI, "process_ani_basi"}, - {MNG_FN_PROCESS_ANI_CLON, "process_ani_clon"}, - {MNG_FN_PROCESS_ANI_PAST, "process_ani_past"}, - {MNG_FN_PROCESS_ANI_DISC, "process_ani_disc"}, - {MNG_FN_PROCESS_ANI_BACK, "process_ani_back"}, - {MNG_FN_PROCESS_ANI_FRAM, "process_ani_fram"}, - {MNG_FN_PROCESS_ANI_MOVE, "process_ani_move"}, - {MNG_FN_PROCESS_ANI_CLIP, "process_ani_clip"}, - {MNG_FN_PROCESS_ANI_SHOW, "process_ani_show"}, - {MNG_FN_PROCESS_ANI_TERM, "process_ani_term"}, - {MNG_FN_PROCESS_ANI_SAVE, "process_ani_save"}, - {MNG_FN_PROCESS_ANI_SEEK, "process_ani_seek"}, - {MNG_FN_PROCESS_ANI_GAMA, "process_ani_gama"}, - {MNG_FN_PROCESS_ANI_CHRM, "process_ani_chrm"}, - {MNG_FN_PROCESS_ANI_SRGB, "process_ani_srgb"}, - {MNG_FN_PROCESS_ANI_ICCP, "process_ani_iccp"}, - {MNG_FN_PROCESS_ANI_PLTE, "process_ani_plte"}, - {MNG_FN_PROCESS_ANI_TRNS, "process_ani_trns"}, - {MNG_FN_PROCESS_ANI_BKGD, "process_ani_bkgd"}, - {MNG_FN_PROCESS_ANI_DHDR, "process_ani_dhdr"}, - {MNG_FN_PROCESS_ANI_PROM, "process_ani_prom"}, - {MNG_FN_PROCESS_ANI_IPNG, "process_ani_ipng"}, - {MNG_FN_PROCESS_ANI_IJNG, "process_ani_ijng"}, - {MNG_FN_PROCESS_ANI_PPLT, "process_ani_pplt"}, - {MNG_FN_PROCESS_ANI_MAGN, "process_ani_magn"}, - - {MNG_FN_PROCESS_ANI_IMAGE, "process_ani_image"}, - - {MNG_FN_RESTORE_BACKIMAGE, "restore_backimage"}, - {MNG_FN_RESTORE_BACKCOLOR, "restore_backcolor"}, - {MNG_FN_RESTORE_BGCOLOR, "restore_bgcolor"}, - {MNG_FN_RESTORE_RGB8, "restore_rgb8"}, - {MNG_FN_RESTORE_BGR8, "restore_bgr8"}, - {MNG_FN_RESTORE_BKGD, "restore_bkgd"}, - - {MNG_FN_INIT_IHDR, "init_ihdr"}, - {MNG_FN_INIT_PLTE, "init_plte"}, - {MNG_FN_INIT_IDAT, "init_idat"}, - {MNG_FN_INIT_IEND, "init_iend"}, - {MNG_FN_INIT_TRNS, "init_trns"}, - {MNG_FN_INIT_GAMA, "init_gama"}, - {MNG_FN_INIT_CHRM, "init_chrm"}, - {MNG_FN_INIT_SRGB, "init_srgb"}, - {MNG_FN_INIT_ICCP, "init_iccp"}, - {MNG_FN_INIT_TEXT, "init_text"}, - {MNG_FN_INIT_ZTXT, "init_ztxt"}, - {MNG_FN_INIT_ITXT, "init_itxt"}, - {MNG_FN_INIT_BKGD, "init_bkgd"}, - {MNG_FN_INIT_PHYS, "init_phys"}, - {MNG_FN_INIT_SBIT, "init_sbit"}, - {MNG_FN_INIT_SPLT, "init_splt"}, - {MNG_FN_INIT_HIST, "init_hist"}, - {MNG_FN_INIT_TIME, "init_time"}, - {MNG_FN_INIT_MHDR, "init_mhdr"}, - {MNG_FN_INIT_MEND, "init_mend"}, - {MNG_FN_INIT_LOOP, "init_loop"}, - {MNG_FN_INIT_ENDL, "init_endl"}, - {MNG_FN_INIT_DEFI, "init_defi"}, - {MNG_FN_INIT_BASI, "init_basi"}, - {MNG_FN_INIT_CLON, "init_clon"}, - {MNG_FN_INIT_PAST, "init_past"}, - {MNG_FN_INIT_DISC, "init_disc"}, - {MNG_FN_INIT_BACK, "init_back"}, - {MNG_FN_INIT_FRAM, "init_fram"}, - {MNG_FN_INIT_MOVE, "init_move"}, - {MNG_FN_INIT_CLIP, "init_clip"}, - {MNG_FN_INIT_SHOW, "init_show"}, - {MNG_FN_INIT_TERM, "init_term"}, - {MNG_FN_INIT_SAVE, "init_save"}, - {MNG_FN_INIT_SEEK, "init_seek"}, - {MNG_FN_INIT_EXPI, "init_expi"}, - {MNG_FN_INIT_FPRI, "init_fpri"}, - {MNG_FN_INIT_NEED, "init_need"}, - {MNG_FN_INIT_PHYG, "init_phyg"}, - {MNG_FN_INIT_JHDR, "init_jhdr"}, - {MNG_FN_INIT_JDAT, "init_jdat"}, - {MNG_FN_INIT_JSEP, "init_jsep"}, - {MNG_FN_INIT_DHDR, "init_dhdr"}, - {MNG_FN_INIT_PROM, "init_prom"}, - {MNG_FN_INIT_IPNG, "init_ipng"}, - {MNG_FN_INIT_PPLT, "init_pplt"}, - {MNG_FN_INIT_IJNG, "init_ijng"}, - {MNG_FN_INIT_DROP, "init_drop"}, - {MNG_FN_INIT_DBYK, "init_dbyk"}, - {MNG_FN_INIT_ORDR, "init_ordr"}, - {MNG_FN_INIT_UNKNOWN, "init_unknown"}, - {MNG_FN_INIT_MAGN, "init_magn"}, - {MNG_FN_INIT_JDAA, "init_jdaa"}, - - {MNG_FN_FREE_IHDR, "free_ihdr"}, - {MNG_FN_FREE_PLTE, "free_plte"}, - {MNG_FN_FREE_IDAT, "free_idat"}, - {MNG_FN_FREE_IEND, "free_iend"}, - {MNG_FN_FREE_TRNS, "free_trns"}, - {MNG_FN_FREE_GAMA, "free_gama"}, - {MNG_FN_FREE_CHRM, "free_chrm"}, - {MNG_FN_FREE_SRGB, "free_srgb"}, - {MNG_FN_FREE_ICCP, "free_iccp"}, - {MNG_FN_FREE_TEXT, "free_text"}, - {MNG_FN_FREE_ZTXT, "free_ztxt"}, - {MNG_FN_FREE_ITXT, "free_itxt"}, - {MNG_FN_FREE_BKGD, "free_bkgd"}, - {MNG_FN_FREE_PHYS, "free_phys"}, - {MNG_FN_FREE_SBIT, "free_sbit"}, - {MNG_FN_FREE_SPLT, "free_splt"}, - {MNG_FN_FREE_HIST, "free_hist"}, - {MNG_FN_FREE_TIME, "free_time"}, - {MNG_FN_FREE_MHDR, "free_mhdr"}, - {MNG_FN_FREE_MEND, "free_mend"}, - {MNG_FN_FREE_LOOP, "free_loop"}, - {MNG_FN_FREE_ENDL, "free_endl"}, - {MNG_FN_FREE_DEFI, "free_defi"}, - {MNG_FN_FREE_BASI, "free_basi"}, - {MNG_FN_FREE_CLON, "free_clon"}, - {MNG_FN_FREE_PAST, "free_past"}, - {MNG_FN_FREE_DISC, "free_disc"}, - {MNG_FN_FREE_BACK, "free_back"}, - {MNG_FN_FREE_FRAM, "free_fram"}, - {MNG_FN_FREE_MOVE, "free_move"}, - {MNG_FN_FREE_CLIP, "free_clip"}, - {MNG_FN_FREE_SHOW, "free_show"}, - {MNG_FN_FREE_TERM, "free_term"}, - {MNG_FN_FREE_SAVE, "free_save"}, - {MNG_FN_FREE_SEEK, "free_seek"}, - {MNG_FN_FREE_EXPI, "free_expi"}, - {MNG_FN_FREE_FPRI, "free_fpri"}, - {MNG_FN_FREE_NEED, "free_need"}, - {MNG_FN_FREE_PHYG, "free_phyg"}, - {MNG_FN_FREE_JHDR, "free_jhdr"}, - {MNG_FN_FREE_JDAT, "free_jdat"}, - {MNG_FN_FREE_JSEP, "free_jsep"}, - {MNG_FN_FREE_DHDR, "free_dhdr"}, - {MNG_FN_FREE_PROM, "free_prom"}, - {MNG_FN_FREE_IPNG, "free_ipng"}, - {MNG_FN_FREE_PPLT, "free_pplt"}, - {MNG_FN_FREE_IJNG, "free_ijng"}, - {MNG_FN_FREE_DROP, "free_drop"}, - {MNG_FN_FREE_DBYK, "free_dbyk"}, - {MNG_FN_FREE_ORDR, "free_ordr"}, - {MNG_FN_FREE_UNKNOWN, "free_unknown"}, - {MNG_FN_FREE_MAGN, "free_magn"}, - {MNG_FN_FREE_JDAA, "free_jdaa"}, - - {MNG_FN_READ_IHDR, "read_ihdr"}, - {MNG_FN_READ_PLTE, "read_plte"}, - {MNG_FN_READ_IDAT, "read_idat"}, - {MNG_FN_READ_IEND, "read_iend"}, - {MNG_FN_READ_TRNS, "read_trns"}, - {MNG_FN_READ_GAMA, "read_gama"}, - {MNG_FN_READ_CHRM, "read_chrm"}, - {MNG_FN_READ_SRGB, "read_srgb"}, - {MNG_FN_READ_ICCP, "read_iccp"}, - {MNG_FN_READ_TEXT, "read_text"}, - {MNG_FN_READ_ZTXT, "read_ztxt"}, - {MNG_FN_READ_ITXT, "read_itxt"}, - {MNG_FN_READ_BKGD, "read_bkgd"}, - {MNG_FN_READ_PHYS, "read_phys"}, - {MNG_FN_READ_SBIT, "read_sbit"}, - {MNG_FN_READ_SPLT, "read_splt"}, - {MNG_FN_READ_HIST, "read_hist"}, - {MNG_FN_READ_TIME, "read_time"}, - {MNG_FN_READ_MHDR, "read_mhdr"}, - {MNG_FN_READ_MEND, "read_mend"}, - {MNG_FN_READ_LOOP, "read_loop"}, - {MNG_FN_READ_ENDL, "read_endl"}, - {MNG_FN_READ_DEFI, "read_defi"}, - {MNG_FN_READ_BASI, "read_basi"}, - {MNG_FN_READ_CLON, "read_clon"}, - {MNG_FN_READ_PAST, "read_past"}, - {MNG_FN_READ_DISC, "read_disc"}, - {MNG_FN_READ_BACK, "read_back"}, - {MNG_FN_READ_FRAM, "read_fram"}, - {MNG_FN_READ_MOVE, "read_move"}, - {MNG_FN_READ_CLIP, "read_clip"}, - {MNG_FN_READ_SHOW, "read_show"}, - {MNG_FN_READ_TERM, "read_term"}, - {MNG_FN_READ_SAVE, "read_save"}, - {MNG_FN_READ_SEEK, "read_seek"}, - {MNG_FN_READ_EXPI, "read_expi"}, - {MNG_FN_READ_FPRI, "read_fpri"}, - {MNG_FN_READ_NEED, "read_need"}, - {MNG_FN_READ_PHYG, "read_phyg"}, - {MNG_FN_READ_JHDR, "read_jhdr"}, - {MNG_FN_READ_JDAT, "read_jdat"}, - {MNG_FN_READ_JSEP, "read_jsep"}, - {MNG_FN_READ_DHDR, "read_dhdr"}, - {MNG_FN_READ_PROM, "read_prom"}, - {MNG_FN_READ_IPNG, "read_ipng"}, - {MNG_FN_READ_PPLT, "read_pplt"}, - {MNG_FN_READ_IJNG, "read_ijng"}, - {MNG_FN_READ_DROP, "read_drop"}, - {MNG_FN_READ_DBYK, "read_dbyk"}, - {MNG_FN_READ_ORDR, "read_ordr"}, - {MNG_FN_READ_UNKNOWN, "read_unknown"}, - {MNG_FN_READ_MAGN, "read_magn"}, - {MNG_FN_READ_JDAA, "read_jdaa"}, - - {MNG_FN_WRITE_IHDR, "write_ihdr"}, - {MNG_FN_WRITE_PLTE, "write_plte"}, - {MNG_FN_WRITE_IDAT, "write_idat"}, - {MNG_FN_WRITE_IEND, "write_iend"}, - {MNG_FN_WRITE_TRNS, "write_trns"}, - {MNG_FN_WRITE_GAMA, "write_gama"}, - {MNG_FN_WRITE_CHRM, "write_chrm"}, - {MNG_FN_WRITE_SRGB, "write_srgb"}, - {MNG_FN_WRITE_ICCP, "write_iccp"}, - {MNG_FN_WRITE_TEXT, "write_text"}, - {MNG_FN_WRITE_ZTXT, "write_ztxt"}, - {MNG_FN_WRITE_ITXT, "write_itxt"}, - {MNG_FN_WRITE_BKGD, "write_bkgd"}, - {MNG_FN_WRITE_PHYS, "write_phys"}, - {MNG_FN_WRITE_SBIT, "write_sbit"}, - {MNG_FN_WRITE_SPLT, "write_splt"}, - {MNG_FN_WRITE_HIST, "write_hist"}, - {MNG_FN_WRITE_TIME, "write_time"}, - {MNG_FN_WRITE_MHDR, "write_mhdr"}, - {MNG_FN_WRITE_MEND, "write_mend"}, - {MNG_FN_WRITE_LOOP, "write_loop"}, - {MNG_FN_WRITE_ENDL, "write_endl"}, - {MNG_FN_WRITE_DEFI, "write_defi"}, - {MNG_FN_WRITE_BASI, "write_basi"}, - {MNG_FN_WRITE_CLON, "write_clon"}, - {MNG_FN_WRITE_PAST, "write_past"}, - {MNG_FN_WRITE_DISC, "write_disc"}, - {MNG_FN_WRITE_BACK, "write_back"}, - {MNG_FN_WRITE_FRAM, "write_fram"}, - {MNG_FN_WRITE_MOVE, "write_move"}, - {MNG_FN_WRITE_CLIP, "write_clip"}, - {MNG_FN_WRITE_SHOW, "write_show"}, - {MNG_FN_WRITE_TERM, "write_term"}, - {MNG_FN_WRITE_SAVE, "write_save"}, - {MNG_FN_WRITE_SEEK, "write_seek"}, - {MNG_FN_WRITE_EXPI, "write_expi"}, - {MNG_FN_WRITE_FPRI, "write_fpri"}, - {MNG_FN_WRITE_NEED, "write_need"}, - {MNG_FN_WRITE_PHYG, "write_phyg"}, - {MNG_FN_WRITE_JHDR, "write_jhdr"}, - {MNG_FN_WRITE_JDAT, "write_jdat"}, - {MNG_FN_WRITE_JSEP, "write_jsep"}, - {MNG_FN_WRITE_DHDR, "write_dhdr"}, - {MNG_FN_WRITE_PROM, "write_prom"}, - {MNG_FN_WRITE_IPNG, "write_ipng"}, - {MNG_FN_WRITE_PPLT, "write_pplt"}, - {MNG_FN_WRITE_IJNG, "write_ijng"}, - {MNG_FN_WRITE_DROP, "write_drop"}, - {MNG_FN_WRITE_DBYK, "write_dbyk"}, - {MNG_FN_WRITE_ORDR, "write_ordr"}, - {MNG_FN_WRITE_UNKNOWN, "write_unknown"}, - {MNG_FN_WRITE_MAGN, "write_magn"}, - {MNG_FN_WRITE_JDAA, "write_jdaa"}, - - {MNG_FN_ZLIB_INITIALIZE, "zlib_initialize"}, - {MNG_FN_ZLIB_CLEANUP, "zlib_cleanup"}, - {MNG_FN_ZLIB_INFLATEINIT, "zlib_inflateinit"}, - {MNG_FN_ZLIB_INFLATEROWS, "zlib_inflaterows"}, - {MNG_FN_ZLIB_INFLATEDATA, "zlib_inflatedata"}, - {MNG_FN_ZLIB_INFLATEFREE, "zlib_inflatefree"}, - {MNG_FN_ZLIB_DEFLATEINIT, "zlib_deflateinit"}, - {MNG_FN_ZLIB_DEFLATEROWS, "zlib_deflaterows"}, - {MNG_FN_ZLIB_DEFLATEDATA, "zlib_deflatedata"}, - {MNG_FN_ZLIB_DEFLATEFREE, "zlib_deflatefree"}, - - {MNG_FN_PROCESS_DISPLAY_IHDR, "process_display_ihdr"}, - {MNG_FN_PROCESS_DISPLAY_PLTE, "process_display_plte"}, - {MNG_FN_PROCESS_DISPLAY_IDAT, "process_display_idat"}, - {MNG_FN_PROCESS_DISPLAY_IEND, "process_display_iend"}, - {MNG_FN_PROCESS_DISPLAY_TRNS, "process_display_trns"}, - {MNG_FN_PROCESS_DISPLAY_GAMA, "process_display_gama"}, - {MNG_FN_PROCESS_DISPLAY_CHRM, "process_display_chrm"}, - {MNG_FN_PROCESS_DISPLAY_SRGB, "process_display_srgb"}, - {MNG_FN_PROCESS_DISPLAY_ICCP, "process_display_iccp"}, - {MNG_FN_PROCESS_DISPLAY_BKGD, "process_display_bkgd"}, - {MNG_FN_PROCESS_DISPLAY_PHYS, "process_display_phys"}, - {MNG_FN_PROCESS_DISPLAY_SBIT, "process_display_sbit"}, - {MNG_FN_PROCESS_DISPLAY_SPLT, "process_display_splt"}, - {MNG_FN_PROCESS_DISPLAY_HIST, "process_display_hist"}, - {MNG_FN_PROCESS_DISPLAY_MHDR, "process_display_mhdr"}, - {MNG_FN_PROCESS_DISPLAY_MEND, "process_display_mend"}, - {MNG_FN_PROCESS_DISPLAY_LOOP, "process_display_loop"}, - {MNG_FN_PROCESS_DISPLAY_ENDL, "process_display_endl"}, - {MNG_FN_PROCESS_DISPLAY_DEFI, "process_display_defi"}, - {MNG_FN_PROCESS_DISPLAY_BASI, "process_display_basi"}, - {MNG_FN_PROCESS_DISPLAY_CLON, "process_display_clon"}, - {MNG_FN_PROCESS_DISPLAY_PAST, "process_display_past"}, - {MNG_FN_PROCESS_DISPLAY_DISC, "process_display_disc"}, - {MNG_FN_PROCESS_DISPLAY_BACK, "process_display_back"}, - {MNG_FN_PROCESS_DISPLAY_FRAM, "process_display_fram"}, - {MNG_FN_PROCESS_DISPLAY_MOVE, "process_display_move"}, - {MNG_FN_PROCESS_DISPLAY_CLIP, "process_display_clip"}, - {MNG_FN_PROCESS_DISPLAY_SHOW, "process_display_show"}, - {MNG_FN_PROCESS_DISPLAY_TERM, "process_display_term"}, - {MNG_FN_PROCESS_DISPLAY_SAVE, "process_display_save"}, - {MNG_FN_PROCESS_DISPLAY_SEEK, "process_display_seek"}, - {MNG_FN_PROCESS_DISPLAY_EXPI, "process_display_expi"}, - {MNG_FN_PROCESS_DISPLAY_FPRI, "process_display_fpri"}, - {MNG_FN_PROCESS_DISPLAY_NEED, "process_display_need"}, - {MNG_FN_PROCESS_DISPLAY_PHYG, "process_display_phyg"}, - {MNG_FN_PROCESS_DISPLAY_JHDR, "process_display_jhdr"}, - {MNG_FN_PROCESS_DISPLAY_JDAT, "process_display_jdat"}, - {MNG_FN_PROCESS_DISPLAY_JSEP, "process_display_jsep"}, - {MNG_FN_PROCESS_DISPLAY_DHDR, "process_display_dhdr"}, - {MNG_FN_PROCESS_DISPLAY_PROM, "process_display_prom"}, - {MNG_FN_PROCESS_DISPLAY_IPNG, "process_display_ipng"}, - {MNG_FN_PROCESS_DISPLAY_PPLT, "process_display_pplt"}, - {MNG_FN_PROCESS_DISPLAY_IJNG, "process_display_ijng"}, - {MNG_FN_PROCESS_DISPLAY_DROP, "process_display_drop"}, - {MNG_FN_PROCESS_DISPLAY_DBYK, "process_display_dbyk"}, - {MNG_FN_PROCESS_DISPLAY_ORDR, "process_display_ordr"}, - {MNG_FN_PROCESS_DISPLAY_MAGN, "process_display_magn"}, - {MNG_FN_PROCESS_DISPLAY_JDAA, "process_display_jdaa"}, - - {MNG_FN_JPEG_INITIALIZE, "jpeg_initialize"}, - {MNG_FN_JPEG_CLEANUP, "jpeg_cleanup"}, - {MNG_FN_JPEG_DECOMPRESSINIT, "jpeg_decompressinit"}, - {MNG_FN_JPEG_DECOMPRESSDATA, "jpeg_decompressdata"}, - {MNG_FN_JPEG_DECOMPRESSFREE, "jpeg_decompressfree"}, - - {MNG_FN_STORE_JPEG_G8, "store_jpeg_g8"}, - {MNG_FN_STORE_JPEG_RGB8, "store_jpeg_rgb8"}, - {MNG_FN_STORE_JPEG_G12, "store_jpeg_g12"}, - {MNG_FN_STORE_JPEG_RGB12, "store_jpeg_rgb12"}, - {MNG_FN_STORE_JPEG_GA8, "store_jpeg_ga8"}, - {MNG_FN_STORE_JPEG_RGBA8, "store_jpeg_rgba8"}, - {MNG_FN_STORE_JPEG_GA12, "store_jpeg_ga12"}, - {MNG_FN_STORE_JPEG_RGBA12, "store_jpeg_rgba12"}, - {MNG_FN_STORE_JPEG_G8_ALPHA, "store_jpeg_g8_alpha"}, - {MNG_FN_STORE_JPEG_RGB8_ALPHA, "store_jpeg_rgb8_alpha"}, - - {MNG_FN_INIT_JPEG_A1_NI, "init_jpeg_a1_ni"}, - {MNG_FN_INIT_JPEG_A2_NI, "init_jpeg_a2_ni"}, - {MNG_FN_INIT_JPEG_A4_NI, "init_jpeg_a4_ni"}, - {MNG_FN_INIT_JPEG_A8_NI, "init_jpeg_a8_ni"}, - {MNG_FN_INIT_JPEG_A16_NI, "init_jpeg_a16_ni"}, - - {MNG_FN_STORE_JPEG_G8_A1, "store_jpeg_g8_a1"}, - {MNG_FN_STORE_JPEG_G8_A2, "store_jpeg_g8_a2"}, - {MNG_FN_STORE_JPEG_G8_A4, "store_jpeg_g8_a4"}, - {MNG_FN_STORE_JPEG_G8_A8, "store_jpeg_g8_a8"}, - {MNG_FN_STORE_JPEG_G8_A16, "store_jpeg_g8_a16"}, - - {MNG_FN_STORE_JPEG_RGB8_A1, "store_jpeg_rgb8_a1"}, - {MNG_FN_STORE_JPEG_RGB8_A2, "store_jpeg_rgb8_a2"}, - {MNG_FN_STORE_JPEG_RGB8_A4, "store_jpeg_rgb8_a4"}, - {MNG_FN_STORE_JPEG_RGB8_A8, "store_jpeg_rgb8_a8"}, - {MNG_FN_STORE_JPEG_RGB8_A16, "store_jpeg_rgb8_a16"}, - - {MNG_FN_STORE_JPEG_G12_A1, "store_jpeg_g12_a1"}, - {MNG_FN_STORE_JPEG_G12_A2, "store_jpeg_g12_a2"}, - {MNG_FN_STORE_JPEG_G12_A4, "store_jpeg_g12_a4"}, - {MNG_FN_STORE_JPEG_G12_A8, "store_jpeg_g12_a8"}, - {MNG_FN_STORE_JPEG_G12_A16, "store_jpeg_g12_a16"}, - - {MNG_FN_STORE_JPEG_RGB12_A1, "store_jpeg_rgb12_a1"}, - {MNG_FN_STORE_JPEG_RGB12_A2, "store_jpeg_rgb12_a2"}, - {MNG_FN_STORE_JPEG_RGB12_A4, "store_jpeg_rgb12_a4"}, - {MNG_FN_STORE_JPEG_RGB12_A8, "store_jpeg_rgb12_a8"}, - {MNG_FN_STORE_JPEG_RGB12_A16, "store_jpeg_rgb12_a16"}, - - {MNG_FN_NEXT_JPEG_ALPHAROW, "next_jpeg_alpharow"}, - {MNG_FN_NEXT_JPEG_ROW, "next_jpeg_row"}, - {MNG_FN_DISPLAY_JPEG_ROWS, "display_jpeg_rows"}, - - {MNG_FN_MAGNIFY_G8_X1, "magnify_g8_x1"}, - {MNG_FN_MAGNIFY_G8_X2, "magnify_g8_x2"}, - {MNG_FN_MAGNIFY_RGB8_X1, "magnify_rgb8_x1"}, - {MNG_FN_MAGNIFY_RGB8_X2, "magnify_rgb8_x2"}, - {MNG_FN_MAGNIFY_GA8_X1, "magnify_ga8_x1"}, - {MNG_FN_MAGNIFY_GA8_X2, "magnify_ga8_x2"}, - {MNG_FN_MAGNIFY_GA8_X3, "magnify_ga8_x3"}, - {MNG_FN_MAGNIFY_GA8_X4, "magnify_ga8_x4"}, - {MNG_FN_MAGNIFY_RGBA8_X1, "magnify_rgba8_x1"}, - {MNG_FN_MAGNIFY_RGBA8_X2, "magnify_rgba8_x2"}, - {MNG_FN_MAGNIFY_RGBA8_X3, "magnify_rgba8_x3"}, - {MNG_FN_MAGNIFY_RGBA8_X4, "magnify_rgba8_x4"}, - {MNG_FN_MAGNIFY_G8_X3, "magnify_g8_x3"}, - {MNG_FN_MAGNIFY_RGB8_X3, "magnify_rgb8_x3"}, - {MNG_FN_MAGNIFY_GA8_X5, "magnify_ga8_x5"}, - {MNG_FN_MAGNIFY_RGBA8_X5, "magnify_rgba8_x5"}, - - {MNG_FN_MAGNIFY_G8_Y1, "magnify_g8_y1"}, - {MNG_FN_MAGNIFY_G8_Y2, "magnify_g8_y2"}, - {MNG_FN_MAGNIFY_RGB8_Y1, "magnify_rgb8_y1"}, - {MNG_FN_MAGNIFY_RGB8_Y2, "magnify_rgb8_y2"}, - {MNG_FN_MAGNIFY_GA8_Y1, "magnify_ga8_y1"}, - {MNG_FN_MAGNIFY_GA8_Y2, "magnify_ga8_y2"}, - {MNG_FN_MAGNIFY_GA8_Y3, "magnify_ga8_y3"}, - {MNG_FN_MAGNIFY_GA8_Y4, "magnify_ga8_y4"}, - {MNG_FN_MAGNIFY_RGBA8_Y1, "magnify_rgba8_y1"}, - {MNG_FN_MAGNIFY_RGBA8_Y2, "magnify_rgba8_y2"}, - {MNG_FN_MAGNIFY_RGBA8_Y3, "magnify_rgba8_y3"}, - {MNG_FN_MAGNIFY_RGBA8_Y4, "magnify_rgba8_y4"}, - {MNG_FN_MAGNIFY_G8_Y3, "magnify_g8_y3"}, - {MNG_FN_MAGNIFY_RGB8_Y3, "magnify_rgb8_y3"}, - {MNG_FN_MAGNIFY_GA8_Y5, "magnify_ga8_y5"}, - {MNG_FN_MAGNIFY_RGBA8_Y5, "magnify_rgba8_y5"}, - - {MNG_FN_DELTA_G1_G1, "delta_g1_g1"}, - {MNG_FN_DELTA_G2_G2, "delta_g2_g2"}, - {MNG_FN_DELTA_G4_G4, "delta_g4_g4"}, - {MNG_FN_DELTA_G8_G8, "delta_g8_g8"}, - {MNG_FN_DELTA_G16_G16, "delta_g16_g16"}, - {MNG_FN_DELTA_RGB8_RGB8, "delta_rgb8_rgb8"}, - {MNG_FN_DELTA_RGB16_RGB16, "delta_rgb16_rgb16"}, - {MNG_FN_DELTA_GA8_GA8, "delta_ga8_ga8"}, - {MNG_FN_DELTA_GA8_G8, "delta_ga8_g8"}, - {MNG_FN_DELTA_GA8_A8, "delta_ga8_a8"}, - {MNG_FN_DELTA_GA16_GA16, "delta_ga16_ga16"}, - {MNG_FN_DELTA_GA16_G16, "delta_ga16_g16"}, - {MNG_FN_DELTA_GA16_A16, "delta_ga16_a16"}, - {MNG_FN_DELTA_RGBA8_RGBA8, "delta_rgba8_rgba8"}, - {MNG_FN_DELTA_RGBA8_RGB8, "delta_rgba8_rgb8"}, - {MNG_FN_DELTA_RGBA8_A8, "delta_rgba8_a8"}, - {MNG_FN_DELTA_RGBA16_RGBA16, "delta_rgba16_rgba16"}, - {MNG_FN_DELTA_RGBA16_RGB16, "delta_rgba16_rgb16"}, - {MNG_FN_DELTA_RGBA16_A16, "delta_rgba16_a16"}, - }; -#endif /* MNG_INCLUDE_TRACE_STINGS */ - -/* ************************************************************************** */ - -mng_retcode mng_trace (mng_datap pData, - mng_uint32 iFunction, - mng_uint32 iLocation) -{ - mng_pchar zName = 0; /* bufferptr for tracestring */ - - if ((pData == 0) || (pData->iMagic != MNG_MAGIC)) - return MNG_INVALIDHANDLE; /* no good if the handle is corrupt */ - - if (pData->fTraceproc) /* report back to user ? */ - { -#ifdef MNG_INCLUDE_TRACE_STRINGS - { /* binary search variables */ - mng_int32 iTop, iLower, iUpper, iMiddle; - mng_trace_entryp pEntry; /* pointer to found entry */ - /* determine max index of table */ - iTop = (sizeof (trace_table) / sizeof (trace_table [0])) - 1; - - iLower = 0; /* initialize binary search */ - iMiddle = iTop >> 1; /* start in the middle */ - iUpper = iTop; - pEntry = 0; /* no goods yet! */ - - do /* the binary search itself */ - { - if (trace_table [iMiddle].iFunction < iFunction) - iLower = iMiddle + 1; - else if (trace_table [iMiddle].iFunction > iFunction) - iUpper = iMiddle - 1; - else - { - pEntry = &trace_table [iMiddle]; - break; - }; - - iMiddle = (iLower + iUpper) >> 1; - } - while (iLower <= iUpper); - - if (pEntry) /* found it ? */ - zName = pEntry->zTracetext; - - } -#endif - /* oke, now tell */ - if (!pData->fTraceproc (((mng_handle)pData), iFunction, iLocation, zName)) - return MNG_APPTRACEABORT; - - } - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_TRACE_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_trace.h b/freeimage241/Source/LibMNG/libmng_trace.h deleted file mode 100644 index e1f4b39..0000000 --- a/freeimage241/Source/LibMNG/libmng_trace.h +++ /dev/null @@ -1,1211 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_trace.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : Trace functions (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the trace functions * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - added chunk-access function trace-codes * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/13/2000 - G.Juyn * */ -/* * - added save_state & restore_state trace-codes * */ -/* * 0.5.1 - 05/15/2000 - G.Juyn * */ -/* * - added getimgdata & putimgdata trace-codes * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - added JNG tracecodes * */ -/* * 0.5.2 - 05/23/2000 - G.Juyn * */ -/* * - added trace-table entry definition * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added tracecodes for global animation color-chunks * */ -/* * - added tracecodes for get/set of default ZLIB/IJG parms * */ -/* * - added tracecodes for global PLTE,tRNS,bKGD * */ -/* * 0.5.2 - 05/30/2000 - G.Juyn * */ -/* * - added tracecodes for image-object promotion * */ -/* * - added tracecodes for delta-image processing * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - added tracecodes for getalphaline callback * */ -/* * 0.5.2 - 06/05/2000 - G.Juyn * */ -/* * - added tracecode for RGB8_A8 canvasstyle * */ -/* * 0.5.2 - 06/06/2000 - G.Juyn * */ -/* * - added tracecode for mng_read_resume HLAPI function * */ -/* * * */ -/* * 0.5.3 - 06/06/2000 - G.Juyn * */ -/* * - added tracecodes for tracing JPEG progression * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added tracecodes for get/set speedtype * */ -/* * - added tracecodes for get imagelevel * */ -/* * 0.5.3 - 06/22/2000 - G.Juyn * */ -/* * - added tracecode for delta-image processing * */ -/* * - added tracecodes for PPLT chunk processing * */ -/* * * */ -/* * 0.9.1 - 07/07/2000 - G.Juyn * */ -/* * - added tracecodes for special display processing * */ -/* * 0.9.1 - 07/08/2000 - G.Juyn * */ -/* * - added tracecode for get/set suspensionmode * */ -/* * - added tracecodes for get/set display variables * */ -/* * - added tracecode for read_databuffer (I/O-suspension) * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added tracecodes for SAVE/SEEK callbacks * */ -/* * - added tracecodes for get/set sectionbreaks * */ -/* * - added tracecode for special error routine * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - added tracecode for updatemngheader * */ -/* * * */ -/* * 0.9.2 - 07/31/2000 - G.Juyn * */ -/* * - added tracecodes for status_xxxxx functions * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * - added tracecode for updatemngsimplicity * */ -/* * * */ -/* * 0.9.3 - 08/26/2000 - G.Juyn * */ -/* * - added MAGN chunk * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * 0.9.3 - 10/10/2000 - G.Juyn * */ -/* * - added support for alpha-depth prediction * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added JDAA chunk * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/16/2000 - G.Juyn * */ -/* * - added functions to retrieve PNG/JNG specific header-info * */ -/* * - added optional support for bKGD for PNG images * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * - added routine to discard "invalid" objects * */ -/* * 0.9.3 - 10/19/2000 - G.Juyn * */ -/* * - implemented delayed delta-processing * */ -/* * 0.9.3 - 10/20/2000 - G.Juyn * */ -/* * - added get/set for bKGD preference setting * */ -/* * 0.9.3 - 10/21/2000 - G.Juyn * */ -/* * - added get function for interlace/progressive display * */ -/* * * */ -/* * 0.9.4 - 1/18/2001 - G.Juyn * */ -/* * - added "new" MAGN methods 3, 4 & 5 * */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * 1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly) * */ -/* * - added BGRA8 canvas with premultiplied alpha * */ -/* * 1.0.1 - 05/02/2001 - G.Juyn * */ -/* * - added "default" sRGB generation (Thanks Marti!) * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added optimization option for MNG-video playback * */ -/* * - added processterm callback * */ -/* * 1.0.2 - 06/25/2001 - G.Juyn * */ -/* * - added option to turn off progressive refresh * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_trace_h_ -#define _libmng_trace_h_ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_TRACE_PROCS - -/* ************************************************************************** */ - -/* TODO: add a trace-mask so certain functions can be excluded */ - -mng_retcode mng_trace (mng_datap pData, - mng_uint32 iFunction, - mng_uint32 iLocation); - -/* ************************************************************************** */ - -#define MNG_TRACE(D,F,L) { mng_retcode iR = mng_trace (D,F,L); \ - if (iR) return iR; } - -#define MNG_TRACEB(D,F,L) { if (mng_trace (D,F,L)) return MNG_FALSE; } - -#define MNG_TRACEX(D,F,L) { if (mng_trace (D,F,L)) return 0; } - -/* ************************************************************************** */ - -#define MNG_LC_START 1 -#define MNG_LC_END 2 -#define MNG_LC_INITIALIZE 3 -#define MNG_LC_CLEANUP 4 - -/* ************************************************************************** */ - -#define MNG_LC_JPEG_CREATE_DECOMPRESS 101 -#define MNG_LC_JPEG_READ_HEADER 102 -#define MNG_LC_JPEG_START_DECOMPRESS 103 -#define MNG_LC_JPEG_START_OUTPUT 104 -#define MNG_LC_JPEG_READ_SCANLINES 105 -#define MNG_LC_JPEG_FINISH_OUTPUT 106 -#define MNG_LC_JPEG_FINISH_DECOMPRESS 107 -#define MNG_LC_JPEG_DESTROY_DECOMPRESS 108 - -/* ************************************************************************** */ - -#define MNG_FN_INITIALIZE 1 -#define MNG_FN_RESET 2 -#define MNG_FN_CLEANUP 3 -#define MNG_FN_READ 4 -#define MNG_FN_WRITE 5 -#define MNG_FN_CREATE 6 -#define MNG_FN_READDISPLAY 7 -#define MNG_FN_DISPLAY 8 -#define MNG_FN_DISPLAY_RESUME 9 -#define MNG_FN_DISPLAY_FREEZE 10 -#define MNG_FN_DISPLAY_RESET 11 -#define MNG_FN_DISPLAY_GOFRAME 12 -#define MNG_FN_DISPLAY_GOLAYER 13 -#define MNG_FN_DISPLAY_GOTIME 14 -#define MNG_FN_GETLASTERROR 15 -#define MNG_FN_READ_RESUME 16 - -#define MNG_FN_SETCB_MEMALLOC 101 -#define MNG_FN_SETCB_MEMFREE 102 -#define MNG_FN_SETCB_READDATA 103 -#define MNG_FN_SETCB_WRITEDATA 104 -#define MNG_FN_SETCB_ERRORPROC 105 -#define MNG_FN_SETCB_TRACEPROC 106 -#define MNG_FN_SETCB_PROCESSHEADER 107 -#define MNG_FN_SETCB_PROCESSTEXT 108 -#define MNG_FN_SETCB_GETCANVASLINE 109 -#define MNG_FN_SETCB_GETBKGDLINE 110 -#define MNG_FN_SETCB_REFRESH 111 -#define MNG_FN_SETCB_GETTICKCOUNT 112 -#define MNG_FN_SETCB_SETTIMER 113 -#define MNG_FN_SETCB_PROCESSGAMMA 114 -#define MNG_FN_SETCB_PROCESSCHROMA 115 -#define MNG_FN_SETCB_PROCESSSRGB 116 -#define MNG_FN_SETCB_PROCESSICCP 117 -#define MNG_FN_SETCB_PROCESSAROW 118 -#define MNG_FN_SETCB_OPENSTREAM 119 -#define MNG_FN_SETCB_CLOSESTREAM 120 -#define MNG_FN_SETCB_GETALPHALINE 121 -#define MNG_FN_SETCB_PROCESSSAVE 122 -#define MNG_FN_SETCB_PROCESSSEEK 123 -#define MNG_FN_SETCB_PROCESSNEED 124 -#define MNG_FN_SETCB_PROCESSUNKNOWN 125 -#define MNG_FN_SETCB_PROCESSMEND 126 -#define MNG_FN_SETCB_PROCESSTERM 127 - -#define MNG_FN_GETCB_MEMALLOC 201 -#define MNG_FN_GETCB_MEMFREE 202 -#define MNG_FN_GETCB_READDATA 203 -#define MNG_FN_GETCB_WRITEDATA 204 -#define MNG_FN_GETCB_ERRORPROC 205 -#define MNG_FN_GETCB_TRACEPROC 206 -#define MNG_FN_GETCB_PROCESSHEADER 207 -#define MNG_FN_GETCB_PROCESSTEXT 208 -#define MNG_FN_GETCB_GETCANVASLINE 209 -#define MNG_FN_GETCB_GETBKGDLINE 210 -#define MNG_FN_GETCB_REFRESH 211 -#define MNG_FN_GETCB_GETTICKCOUNT 212 -#define MNG_FN_GETCB_SETTIMER 213 -#define MNG_FN_GETCB_PROCESSGAMMA 214 -#define MNG_FN_GETCB_PROCESSCHROMA 215 -#define MNG_FN_GETCB_PROCESSSRGB 216 -#define MNG_FN_GETCB_PROCESSICCP 217 -#define MNG_FN_GETCB_PROCESSAROW 218 -#define MNG_FN_GETCB_OPENSTREAM 219 -#define MNG_FN_GETCB_CLOSESTREAM 220 -#define MNG_FN_GETCB_GETALPHALINE 221 -#define MNG_FN_GETCB_PROCESSSAVE 222 -#define MNG_FN_GETCB_PROCESSSEEK 223 -#define MNG_FN_GETCB_PROCESSNEED 224 -#define MNG_FN_GETCB_PROCESSUNKNOWN 225 -#define MNG_FN_GETCB_PROCESSMEND 226 -#define MNG_FN_GETCB_PROCESSTERM 227 - -#define MNG_FN_SET_USERDATA 301 -#define MNG_FN_SET_CANVASSTYLE 302 -#define MNG_FN_SET_BKGDSTYLE 303 -#define MNG_FN_SET_BGCOLOR 304 -#define MNG_FN_SET_STORECHUNKS 305 -#define MNG_FN_SET_VIEWGAMMA 306 -#define MNG_FN_SET_DISPLAYGAMMA 307 -#define MNG_FN_SET_DFLTIMGGAMMA 308 -#define MNG_FN_SET_SRGB 309 -#define MNG_FN_SET_OUTPUTPROFILE 310 -#define MNG_FN_SET_SRGBPROFILE 311 -#define MNG_FN_SET_MAXCANVASWIDTH 312 -#define MNG_FN_SET_MAXCANVASHEIGHT 313 -#define MNG_FN_SET_MAXCANVASSIZE 314 -#define MNG_FN_SET_ZLIB_LEVEL 315 -#define MNG_FN_SET_ZLIB_METHOD 316 -#define MNG_FN_SET_ZLIB_WINDOWBITS 317 -#define MNG_FN_SET_ZLIB_MEMLEVEL 318 -#define MNG_FN_SET_ZLIB_STRATEGY 319 -#define MNG_FN_SET_ZLIB_MAXIDAT 320 -#define MNG_FN_SET_JPEG_DCTMETHOD 321 -#define MNG_FN_SET_JPEG_QUALITY 322 -#define MNG_FN_SET_JPEG_SMOOTHING 323 -#define MNG_FN_SET_JPEG_PROGRESSIVE 324 -#define MNG_FN_SET_JPEG_OPTIMIZED 325 -#define MNG_FN_SET_JPEG_MAXJDAT 326 -#define MNG_FN_SET_SPEED 327 -#define MNG_FN_SET_SUSPENSIONMODE 328 -#define MNG_FN_SET_SECTIONBREAKS 329 -#define MNG_FN_SET_USEBKGD 330 -#define MNG_FN_SET_OUTPUTPROFILE2 331 -#define MNG_FN_SET_SRGBPROFILE2 332 -#define MNG_FN_SET_OUTPUTSRGB 333 -#define MNG_FN_SET_SRGBIMPLICIT 334 -#define MNG_FN_SET_CACHEPLAYBACK 335 -#define MNG_FN_SET_DOPROGRESSIVE 336 - -#define MNG_FN_GET_USERDATA 401 -#define MNG_FN_GET_SIGTYPE 402 -#define MNG_FN_GET_IMAGETYPE 403 -#define MNG_FN_GET_IMAGEWIDTH 404 -#define MNG_FN_GET_IMAGEHEIGHT 405 -#define MNG_FN_GET_TICKS 406 -#define MNG_FN_GET_FRAMECOUNT 407 -#define MNG_FN_GET_LAYERCOUNT 408 -#define MNG_FN_GET_PLAYTIME 409 -#define MNG_FN_GET_SIMPLICITY 410 -#define MNG_FN_GET_CANVASSTYLE 411 -#define MNG_FN_GET_BKGDSTYLE 412 -#define MNG_FN_GET_BGCOLOR 413 -#define MNG_FN_GET_STORECHUNKS 414 -#define MNG_FN_GET_VIEWGAMMA 415 -#define MNG_FN_GET_DISPLAYGAMMA 416 -#define MNG_FN_GET_DFLTIMGGAMMA 417 -#define MNG_FN_GET_SRGB 418 -#define MNG_FN_GET_MAXCANVASWIDTH 419 -#define MNG_FN_GET_MAXCANVASHEIGHT 420 -#define MNG_FN_GET_ZLIB_LEVEL 421 -#define MNG_FN_GET_ZLIB_METHOD 422 -#define MNG_FN_GET_ZLIB_WINDOWBITS 423 -#define MNG_FN_GET_ZLIB_MEMLEVEL 424 -#define MNG_FN_GET_ZLIB_STRATEGY 425 -#define MNG_FN_GET_ZLIB_MAXIDAT 426 -#define MNG_FN_GET_JPEG_DCTMETHOD 427 -#define MNG_FN_GET_JPEG_QUALITY 428 -#define MNG_FN_GET_JPEG_SMOOTHING 429 -#define MNG_FN_GET_JPEG_PROGRESSIVE 430 -#define MNG_FN_GET_JPEG_OPTIMIZED 431 -#define MNG_FN_GET_JPEG_MAXJDAT 432 -#define MNG_FN_GET_SPEED 433 -#define MNG_FN_GET_IMAGELEVEL 434 -#define MNG_FN_GET_SUSPENSIONMODE 435 -#define MNG_FN_GET_STARTTIME 436 -#define MNG_FN_GET_RUNTIME 437 -#define MNG_FN_GET_CURRENTFRAME 438 -#define MNG_FN_GET_CURRENTLAYER 439 -#define MNG_FN_GET_CURRENTPLAYTIME 440 -#define MNG_FN_GET_SECTIONBREAKS 441 -#define MNG_FN_GET_ALPHADEPTH 442 -#define MNG_FN_GET_BITDEPTH 443 -#define MNG_FN_GET_COLORTYPE 444 -#define MNG_FN_GET_COMPRESSION 445 -#define MNG_FN_GET_FILTER 446 -#define MNG_FN_GET_INTERLACE 447 -#define MNG_FN_GET_ALPHABITDEPTH 448 -#define MNG_FN_GET_ALPHACOMPRESSION 449 -#define MNG_FN_GET_ALPHAFILTER 450 -#define MNG_FN_GET_ALPHAINTERLACE 451 -#define MNG_FN_GET_USEBKGD 452 -#define MNG_FN_GET_REFRESHPASS 453 -#define MNG_FN_GET_CACHEPLAYBACK 454 -#define MNG_FN_GET_DOPROGRESSIVE 455 - -#define MNG_FN_STATUS_ERROR 481 -#define MNG_FN_STATUS_READING 482 -#define MNG_FN_STATUS_SUSPENDBREAK 483 -#define MNG_FN_STATUS_CREATING 484 -#define MNG_FN_STATUS_WRITING 485 -#define MNG_FN_STATUS_DISPLAYING 486 -#define MNG_FN_STATUS_RUNNING 487 -#define MNG_FN_STATUS_TIMERBREAK 488 - -/* ************************************************************************** */ - -#define MNG_FN_ITERATE_CHUNKS 601 - -#define MNG_FN_GETCHUNK_IHDR 701 -#define MNG_FN_GETCHUNK_PLTE 702 -#define MNG_FN_GETCHUNK_IDAT 703 -#define MNG_FN_GETCHUNK_IEND 704 -#define MNG_FN_GETCHUNK_TRNS 705 -#define MNG_FN_GETCHUNK_GAMA 706 -#define MNG_FN_GETCHUNK_CHRM 707 -#define MNG_FN_GETCHUNK_SRGB 708 -#define MNG_FN_GETCHUNK_ICCP 709 -#define MNG_FN_GETCHUNK_TEXT 710 -#define MNG_FN_GETCHUNK_ZTXT 711 -#define MNG_FN_GETCHUNK_ITXT 712 -#define MNG_FN_GETCHUNK_BKGD 713 -#define MNG_FN_GETCHUNK_PHYS 714 -#define MNG_FN_GETCHUNK_SBIT 715 -#define MNG_FN_GETCHUNK_SPLT 716 -#define MNG_FN_GETCHUNK_HIST 717 -#define MNG_FN_GETCHUNK_TIME 718 -#define MNG_FN_GETCHUNK_MHDR 719 -#define MNG_FN_GETCHUNK_MEND 720 -#define MNG_FN_GETCHUNK_LOOP 721 -#define MNG_FN_GETCHUNK_ENDL 722 -#define MNG_FN_GETCHUNK_DEFI 723 -#define MNG_FN_GETCHUNK_BASI 724 -#define MNG_FN_GETCHUNK_CLON 725 -#define MNG_FN_GETCHUNK_PAST 726 -#define MNG_FN_GETCHUNK_DISC 727 -#define MNG_FN_GETCHUNK_BACK 728 -#define MNG_FN_GETCHUNK_FRAM 729 -#define MNG_FN_GETCHUNK_MOVE 730 -#define MNG_FN_GETCHUNK_CLIP 731 -#define MNG_FN_GETCHUNK_SHOW 732 -#define MNG_FN_GETCHUNK_TERM 733 -#define MNG_FN_GETCHUNK_SAVE 734 -#define MNG_FN_GETCHUNK_SEEK 735 -#define MNG_FN_GETCHUNK_EXPI 736 -#define MNG_FN_GETCHUNK_FPRI 737 -#define MNG_FN_GETCHUNK_NEED 738 -#define MNG_FN_GETCHUNK_PHYG 739 -#define MNG_FN_GETCHUNK_JHDR 740 -#define MNG_FN_GETCHUNK_JDAT 741 -#define MNG_FN_GETCHUNK_JSEP 742 -#define MNG_FN_GETCHUNK_DHDR 743 -#define MNG_FN_GETCHUNK_PROM 744 -#define MNG_FN_GETCHUNK_IPNG 745 -#define MNG_FN_GETCHUNK_PPLT 746 -#define MNG_FN_GETCHUNK_IJNG 747 -#define MNG_FN_GETCHUNK_DROP 748 -#define MNG_FN_GETCHUNK_DBYK 749 -#define MNG_FN_GETCHUNK_ORDR 750 -#define MNG_FN_GETCHUNK_UNKNOWN 751 -#define MNG_FN_GETCHUNK_MAGN 752 -#define MNG_FN_GETCHUNK_JDAA 753 - -#define MNG_FN_GETCHUNK_PAST_SRC 781 -#define MNG_FN_GETCHUNK_SAVE_ENTRY 782 -#define MNG_FN_GETCHUNK_PPLT_ENTRY 783 -#define MNG_FN_GETCHUNK_ORDR_ENTRY 784 - -#define MNG_FN_PUTCHUNK_IHDR 801 -#define MNG_FN_PUTCHUNK_PLTE 802 -#define MNG_FN_PUTCHUNK_IDAT 803 -#define MNG_FN_PUTCHUNK_IEND 804 -#define MNG_FN_PUTCHUNK_TRNS 805 -#define MNG_FN_PUTCHUNK_GAMA 806 -#define MNG_FN_PUTCHUNK_CHRM 807 -#define MNG_FN_PUTCHUNK_SRGB 808 -#define MNG_FN_PUTCHUNK_ICCP 809 -#define MNG_FN_PUTCHUNK_TEXT 810 -#define MNG_FN_PUTCHUNK_ZTXT 811 -#define MNG_FN_PUTCHUNK_ITXT 812 -#define MNG_FN_PUTCHUNK_BKGD 813 -#define MNG_FN_PUTCHUNK_PHYS 814 -#define MNG_FN_PUTCHUNK_SBIT 815 -#define MNG_FN_PUTCHUNK_SPLT 816 -#define MNG_FN_PUTCHUNK_HIST 817 -#define MNG_FN_PUTCHUNK_TIME 818 -#define MNG_FN_PUTCHUNK_MHDR 819 -#define MNG_FN_PUTCHUNK_MEND 820 -#define MNG_FN_PUTCHUNK_LOOP 821 -#define MNG_FN_PUTCHUNK_ENDL 822 -#define MNG_FN_PUTCHUNK_DEFI 823 -#define MNG_FN_PUTCHUNK_BASI 824 -#define MNG_FN_PUTCHUNK_CLON 825 -#define MNG_FN_PUTCHUNK_PAST 826 -#define MNG_FN_PUTCHUNK_DISC 827 -#define MNG_FN_PUTCHUNK_BACK 828 -#define MNG_FN_PUTCHUNK_FRAM 829 -#define MNG_FN_PUTCHUNK_MOVE 830 -#define MNG_FN_PUTCHUNK_CLIP 831 -#define MNG_FN_PUTCHUNK_SHOW 832 -#define MNG_FN_PUTCHUNK_TERM 833 -#define MNG_FN_PUTCHUNK_SAVE 834 -#define MNG_FN_PUTCHUNK_SEEK 835 -#define MNG_FN_PUTCHUNK_EXPI 836 -#define MNG_FN_PUTCHUNK_FPRI 837 -#define MNG_FN_PUTCHUNK_NEED 838 -#define MNG_FN_PUTCHUNK_PHYG 839 -#define MNG_FN_PUTCHUNK_JHDR 840 -#define MNG_FN_PUTCHUNK_JDAT 841 -#define MNG_FN_PUTCHUNK_JSEP 842 -#define MNG_FN_PUTCHUNK_DHDR 843 -#define MNG_FN_PUTCHUNK_PROM 844 -#define MNG_FN_PUTCHUNK_IPNG 845 -#define MNG_FN_PUTCHUNK_PPLT 846 -#define MNG_FN_PUTCHUNK_IJNG 847 -#define MNG_FN_PUTCHUNK_DROP 848 -#define MNG_FN_PUTCHUNK_DBYK 849 -#define MNG_FN_PUTCHUNK_ORDR 850 -#define MNG_FN_PUTCHUNK_UNKNOWN 851 -#define MNG_FN_PUTCHUNK_MAGN 852 -#define MNG_FN_PUTCHUNK_JDAA 853 - -#define MNG_FN_PUTCHUNK_PAST_SRC 881 -#define MNG_FN_PUTCHUNK_SAVE_ENTRY 882 -#define MNG_FN_PUTCHUNK_PPLT_ENTRY 883 -#define MNG_FN_PUTCHUNK_ORDR_ENTRY 884 - -/* ************************************************************************** */ - -#define MNG_FN_GETIMGDATA_SEQ 901 -#define MNG_FN_GETIMGDATA_CHUNKSEQ 902 -#define MNG_FN_GETIMGDATA_CHUNK 903 - -#define MNG_FN_PUTIMGDATA_IHDR 951 -#define MNG_FN_PUTIMGDATA_JHDR 952 -#define MNG_FN_PUTIMGDATA_BASI 953 -#define MNG_FN_PUTIMGDATA_DHDR 954 - -#define MNG_FN_UPDATEMNGHEADER 981 -#define MNG_FN_UPDATEMNGSIMPLICITY 982 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_RAW_CHUNK 1001 -#define MNG_FN_READ_GRAPHIC 1002 -#define MNG_FN_DROP_CHUNKS 1003 -#define MNG_FN_PROCESS_ERROR 1004 -#define MNG_FN_CLEAR_CMS 1005 -#define MNG_FN_DROP_OBJECTS 1006 -#define MNG_FN_READ_CHUNK 1007 -#define MNG_FN_LOAD_BKGDLAYER 1008 -#define MNG_FN_NEXT_FRAME 1009 -#define MNG_FN_NEXT_LAYER 1010 -#define MNG_FN_INTERFRAME_DELAY 1011 -#define MNG_FN_DISPLAY_IMAGE 1012 -#define MNG_FN_DROP_IMGOBJECTS 1013 -#define MNG_FN_DROP_ANIOBJECTS 1014 -#define MNG_FN_INFLATE_BUFFER 1015 -#define MNG_FN_DEFLATE_BUFFER 1016 -#define MNG_FN_WRITE_RAW_CHUNK 1017 -#define MNG_FN_WRITE_GRAPHIC 1018 -#define MNG_FN_SAVE_STATE 1019 -#define MNG_FN_RESTORE_STATE 1020 -#define MNG_FN_DROP_SAVEDATA 1021 -#define MNG_FN_EXECUTE_DELTA_IMAGE 1022 -#define MNG_FN_PROCESS_DISPLAY 1023 -#define MNG_FN_CLEAR_CANVAS 1024 -#define MNG_FN_READ_DATABUFFER 1025 -#define MNG_FN_STORE_ERROR 1026 -#define MNG_FN_DROP_INVALID_OBJECTS 1027 - -/* ************************************************************************** */ - -#define MNG_FN_DISPLAY_RGB8 1101 -#define MNG_FN_DISPLAY_RGBA8 1102 -#define MNG_FN_DISPLAY_ARGB8 1103 -#define MNG_FN_DISPLAY_BGR8 1104 -#define MNG_FN_DISPLAY_BGRA8 1105 -#define MNG_FN_DISPLAY_ABGR8 1106 -#define MNG_FN_DISPLAY_RGB16 1107 -#define MNG_FN_DISPLAY_RGBA16 1108 -#define MNG_FN_DISPLAY_ARGB16 1109 -#define MNG_FN_DISPLAY_BGR16 1110 -#define MNG_FN_DISPLAY_BGRA16 1111 -#define MNG_FN_DISPLAY_ABGR16 1112 -#define MNG_FN_DISPLAY_INDEX8 1113 -#define MNG_FN_DISPLAY_INDEXA8 1114 -#define MNG_FN_DISPLAY_AINDEX8 1115 -#define MNG_FN_DISPLAY_GRAY8 1116 -#define MNG_FN_DISPLAY_GRAY16 1117 -#define MNG_FN_DISPLAY_GRAYA8 1118 -#define MNG_FN_DISPLAY_GRAYA16 1119 -#define MNG_FN_DISPLAY_AGRAY8 1120 -#define MNG_FN_DISPLAY_AGRAY16 1121 -#define MNG_FN_DISPLAY_DX15 1122 -#define MNG_FN_DISPLAY_DX16 1123 -#define MNG_FN_DISPLAY_RGB8_A8 1124 -#define MNG_FN_DISPLAY_BGRA8PM 1125 - -/* ************************************************************************** */ - -#define MNG_FN_INIT_FULL_CMS 1201 -#define MNG_FN_CORRECT_FULL_CMS 1202 -#define MNG_FN_INIT_GAMMA_ONLY 1204 -#define MNG_FN_CORRECT_GAMMA_ONLY 1205 -#define MNG_FN_CORRECT_APP_CMS 1206 -#define MNG_FN_INIT_FULL_CMS_OBJ 1207 -#define MNG_FN_INIT_GAMMA_ONLY_OBJ 1208 -#define MNG_FN_INIT_APP_CMS 1209 -#define MNG_FN_INIT_APP_CMS_OBJ 1210 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_G1 1301 -#define MNG_FN_PROCESS_G2 1302 -#define MNG_FN_PROCESS_G4 1303 -#define MNG_FN_PROCESS_G8 1304 -#define MNG_FN_PROCESS_G16 1305 -#define MNG_FN_PROCESS_RGB8 1306 -#define MNG_FN_PROCESS_RGB16 1307 -#define MNG_FN_PROCESS_IDX1 1308 -#define MNG_FN_PROCESS_IDX2 1309 -#define MNG_FN_PROCESS_IDX4 1310 -#define MNG_FN_PROCESS_IDX8 1311 -#define MNG_FN_PROCESS_GA8 1312 -#define MNG_FN_PROCESS_GA16 1313 -#define MNG_FN_PROCESS_RGBA8 1314 -#define MNG_FN_PROCESS_RGBA16 1315 - -/* ************************************************************************** */ - -#define MNG_FN_INIT_G1_NI 1401 -#define MNG_FN_INIT_G1_I 1402 -#define MNG_FN_INIT_G2_NI 1403 -#define MNG_FN_INIT_G2_I 1404 -#define MNG_FN_INIT_G4_NI 1405 -#define MNG_FN_INIT_G4_I 1406 -#define MNG_FN_INIT_G8_NI 1407 -#define MNG_FN_INIT_G8_I 1408 -#define MNG_FN_INIT_G16_NI 1409 -#define MNG_FN_INIT_G16_I 1410 -#define MNG_FN_INIT_RGB8_NI 1411 -#define MNG_FN_INIT_RGB8_I 1412 -#define MNG_FN_INIT_RGB16_NI 1413 -#define MNG_FN_INIT_RGB16_I 1414 -#define MNG_FN_INIT_IDX1_NI 1415 -#define MNG_FN_INIT_IDX1_I 1416 -#define MNG_FN_INIT_IDX2_NI 1417 -#define MNG_FN_INIT_IDX2_I 1418 -#define MNG_FN_INIT_IDX4_NI 1419 -#define MNG_FN_INIT_IDX4_I 1420 -#define MNG_FN_INIT_IDX8_NI 1421 -#define MNG_FN_INIT_IDX8_I 1422 -#define MNG_FN_INIT_GA8_NI 1423 -#define MNG_FN_INIT_GA8_I 1424 -#define MNG_FN_INIT_GA16_NI 1425 -#define MNG_FN_INIT_GA16_I 1426 -#define MNG_FN_INIT_RGBA8_NI 1427 -#define MNG_FN_INIT_RGBA8_I 1428 -#define MNG_FN_INIT_RGBA16_NI 1429 -#define MNG_FN_INIT_RGBA16_I 1430 - -#define MNG_FN_INIT_ROWPROC 1497 -#define MNG_FN_NEXT_ROW 1498 -#define MNG_FN_CLEANUP_ROWPROC 1499 - -/* ************************************************************************** */ - -#define MNG_FN_FILTER_A_ROW 1501 -#define MNG_FN_FILTER_SUB 1502 -#define MNG_FN_FILTER_UP 1503 -#define MNG_FN_FILTER_AVERAGE 1504 -#define MNG_FN_FILTER_PAETH 1505 - -#define MNG_FN_INIT_ROWDIFFERING 1551 -#define MNG_FN_DIFFER_G1 1552 -#define MNG_FN_DIFFER_G2 1553 -#define MNG_FN_DIFFER_G4 1554 -#define MNG_FN_DIFFER_G8 1555 -#define MNG_FN_DIFFER_G16 1556 -#define MNG_FN_DIFFER_RGB8 1557 -#define MNG_FN_DIFFER_RGB16 1558 -#define MNG_FN_DIFFER_IDX1 1559 -#define MNG_FN_DIFFER_IDX2 1560 -#define MNG_FN_DIFFER_IDX4 1561 -#define MNG_FN_DIFFER_IDX8 1562 -#define MNG_FN_DIFFER_GA8 1563 -#define MNG_FN_DIFFER_GA16 1564 -#define MNG_FN_DIFFER_RGBA8 1565 -#define MNG_FN_DIFFER_RGBA16 1566 - -/* ************************************************************************** */ - -#define MNG_FN_CREATE_IMGDATAOBJECT 1601 -#define MNG_FN_FREE_IMGDATAOBJECT 1602 -#define MNG_FN_CLONE_IMGDATAOBJECT 1603 -#define MNG_FN_CREATE_IMGOBJECT 1604 -#define MNG_FN_FREE_IMGOBJECT 1605 -#define MNG_FN_FIND_IMGOBJECT 1606 -#define MNG_FN_CLONE_IMGOBJECT 1607 -#define MNG_FN_RESET_OBJECTDETAILS 1608 -#define MNG_FN_RENUM_IMGOBJECT 1609 -#define MNG_FN_PROMOTE_IMGOBJECT 1610 -#define MNG_FN_MAGNIFY_IMGOBJECT 1611 - -/* ************************************************************************** */ - -#define MNG_FN_STORE_G1 1701 -#define MNG_FN_STORE_G2 1702 -#define MNG_FN_STORE_G4 1703 -#define MNG_FN_STORE_G8 1704 -#define MNG_FN_STORE_G16 1705 -#define MNG_FN_STORE_RGB8 1706 -#define MNG_FN_STORE_RGB16 1707 -#define MNG_FN_STORE_IDX1 1708 -#define MNG_FN_STORE_IDX2 1709 -#define MNG_FN_STORE_IDX4 1710 -#define MNG_FN_STORE_IDX8 1711 -#define MNG_FN_STORE_GA8 1712 -#define MNG_FN_STORE_GA16 1713 -#define MNG_FN_STORE_RGBA8 1714 -#define MNG_FN_STORE_RGBA16 1715 - -#define MNG_FN_RETRIEVE_G8 1751 -#define MNG_FN_RETRIEVE_G16 1752 -#define MNG_FN_RETRIEVE_RGB8 1753 -#define MNG_FN_RETRIEVE_RGB16 1754 -#define MNG_FN_RETRIEVE_IDX8 1755 -#define MNG_FN_RETRIEVE_GA8 1756 -#define MNG_FN_RETRIEVE_GA16 1757 -#define MNG_FN_RETRIEVE_RGBA8 1758 -#define MNG_FN_RETRIEVE_RGBA16 1759 - -#define MNG_FN_DELTA_G1 1771 -#define MNG_FN_DELTA_G2 1772 -#define MNG_FN_DELTA_G4 1773 -#define MNG_FN_DELTA_G8 1774 -#define MNG_FN_DELTA_G16 1775 -#define MNG_FN_DELTA_RGB8 1776 -#define MNG_FN_DELTA_RGB16 1777 -#define MNG_FN_DELTA_IDX1 1778 -#define MNG_FN_DELTA_IDX2 1779 -#define MNG_FN_DELTA_IDX4 1780 -#define MNG_FN_DELTA_IDX8 1781 -#define MNG_FN_DELTA_GA8 1782 -#define MNG_FN_DELTA_GA16 1783 -#define MNG_FN_DELTA_RGBA8 1784 -#define MNG_FN_DELTA_RGBA16 1785 - -/* ************************************************************************** */ - -#define MNG_FN_CREATE_ANI_LOOP 1801 -#define MNG_FN_CREATE_ANI_ENDL 1802 -#define MNG_FN_CREATE_ANI_DEFI 1803 -#define MNG_FN_CREATE_ANI_BASI 1804 -#define MNG_FN_CREATE_ANI_CLON 1805 -#define MNG_FN_CREATE_ANI_PAST 1806 -#define MNG_FN_CREATE_ANI_DISC 1807 -#define MNG_FN_CREATE_ANI_BACK 1808 -#define MNG_FN_CREATE_ANI_FRAM 1809 -#define MNG_FN_CREATE_ANI_MOVE 1810 -#define MNG_FN_CREATE_ANI_CLIP 1811 -#define MNG_FN_CREATE_ANI_SHOW 1812 -#define MNG_FN_CREATE_ANI_TERM 1813 -#define MNG_FN_CREATE_ANI_SAVE 1814 -#define MNG_FN_CREATE_ANI_SEEK 1815 -#define MNG_FN_CREATE_ANI_GAMA 1816 -#define MNG_FN_CREATE_ANI_CHRM 1817 -#define MNG_FN_CREATE_ANI_SRGB 1818 -#define MNG_FN_CREATE_ANI_ICCP 1819 -#define MNG_FN_CREATE_ANI_PLTE 1820 -#define MNG_FN_CREATE_ANI_TRNS 1821 -#define MNG_FN_CREATE_ANI_BKGD 1822 -#define MNG_FN_CREATE_ANI_DHDR 1823 -#define MNG_FN_CREATE_ANI_PROM 1824 -#define MNG_FN_CREATE_ANI_IPNG 1825 -#define MNG_FN_CREATE_ANI_IJNG 1826 -#define MNG_FN_CREATE_ANI_PPLT 1827 -#define MNG_FN_CREATE_ANI_MAGN 1828 - -#define MNG_FN_CREATE_ANI_IMAGE 1891 - -/* ************************************************************************** */ - -#define MNG_FN_FREE_ANI_LOOP 1901 -#define MNG_FN_FREE_ANI_ENDL 1902 -#define MNG_FN_FREE_ANI_DEFI 1903 -#define MNG_FN_FREE_ANI_BASI 1904 -#define MNG_FN_FREE_ANI_CLON 1905 -#define MNG_FN_FREE_ANI_PAST 1906 -#define MNG_FN_FREE_ANI_DISC 1907 -#define MNG_FN_FREE_ANI_BACK 1908 -#define MNG_FN_FREE_ANI_FRAM 1909 -#define MNG_FN_FREE_ANI_MOVE 1910 -#define MNG_FN_FREE_ANI_CLIP 1911 -#define MNG_FN_FREE_ANI_SHOW 1912 -#define MNG_FN_FREE_ANI_TERM 1913 -#define MNG_FN_FREE_ANI_SAVE 1914 -#define MNG_FN_FREE_ANI_SEEK 1915 -#define MNG_FN_FREE_ANI_GAMA 1916 -#define MNG_FN_FREE_ANI_CHRM 1917 -#define MNG_FN_FREE_ANI_SRGB 1918 -#define MNG_FN_FREE_ANI_ICCP 1919 -#define MNG_FN_FREE_ANI_PLTE 1920 -#define MNG_FN_FREE_ANI_TRNS 1921 -#define MNG_FN_FREE_ANI_BKGD 1922 -#define MNG_FN_FREE_ANI_DHDR 1923 -#define MNG_FN_FREE_ANI_PROM 1924 -#define MNG_FN_FREE_ANI_IPNG 1925 -#define MNG_FN_FREE_ANI_IJNG 1926 -#define MNG_FN_FREE_ANI_PPLT 1927 -#define MNG_FN_FREE_ANI_MAGN 1928 - -#define MNG_FN_FREE_ANI_IMAGE 1991 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_ANI_LOOP 2001 -#define MNG_FN_PROCESS_ANI_ENDL 2002 -#define MNG_FN_PROCESS_ANI_DEFI 2003 -#define MNG_FN_PROCESS_ANI_BASI 2004 -#define MNG_FN_PROCESS_ANI_CLON 2005 -#define MNG_FN_PROCESS_ANI_PAST 2006 -#define MNG_FN_PROCESS_ANI_DISC 2007 -#define MNG_FN_PROCESS_ANI_BACK 2008 -#define MNG_FN_PROCESS_ANI_FRAM 2009 -#define MNG_FN_PROCESS_ANI_MOVE 2010 -#define MNG_FN_PROCESS_ANI_CLIP 2011 -#define MNG_FN_PROCESS_ANI_SHOW 2012 -#define MNG_FN_PROCESS_ANI_TERM 2013 -#define MNG_FN_PROCESS_ANI_SAVE 2014 -#define MNG_FN_PROCESS_ANI_SEEK 2015 -#define MNG_FN_PROCESS_ANI_GAMA 2016 -#define MNG_FN_PROCESS_ANI_CHRM 2017 -#define MNG_FN_PROCESS_ANI_SRGB 2018 -#define MNG_FN_PROCESS_ANI_ICCP 2019 -#define MNG_FN_PROCESS_ANI_PLTE 2020 -#define MNG_FN_PROCESS_ANI_TRNS 2021 -#define MNG_FN_PROCESS_ANI_BKGD 2022 -#define MNG_FN_PROCESS_ANI_DHDR 2023 -#define MNG_FN_PROCESS_ANI_PROM 2024 -#define MNG_FN_PROCESS_ANI_IPNG 2025 -#define MNG_FN_PROCESS_ANI_IJNG 2026 -#define MNG_FN_PROCESS_ANI_PPLT 2027 -#define MNG_FN_PROCESS_ANI_MAGN 2028 - -#define MNG_FN_PROCESS_ANI_IMAGE 2091 - -/* ************************************************************************** */ - -#define MNG_FN_RESTORE_BACKIMAGE 2101 -#define MNG_FN_RESTORE_BACKCOLOR 2102 -#define MNG_FN_RESTORE_BGCOLOR 2103 -#define MNG_FN_RESTORE_RGB8 2104 -#define MNG_FN_RESTORE_BGR8 2105 -#define MNG_FN_RESTORE_BKGD 2106 - -/* ************************************************************************** */ - -#define MNG_FN_INIT_IHDR 2201 -#define MNG_FN_INIT_PLTE 2202 -#define MNG_FN_INIT_IDAT 2203 -#define MNG_FN_INIT_IEND 2204 -#define MNG_FN_INIT_TRNS 2205 -#define MNG_FN_INIT_GAMA 2206 -#define MNG_FN_INIT_CHRM 2207 -#define MNG_FN_INIT_SRGB 2208 -#define MNG_FN_INIT_ICCP 2209 -#define MNG_FN_INIT_TEXT 2210 -#define MNG_FN_INIT_ZTXT 2211 -#define MNG_FN_INIT_ITXT 2212 -#define MNG_FN_INIT_BKGD 2213 -#define MNG_FN_INIT_PHYS 2214 -#define MNG_FN_INIT_SBIT 2215 -#define MNG_FN_INIT_SPLT 2216 -#define MNG_FN_INIT_HIST 2217 -#define MNG_FN_INIT_TIME 2218 -#define MNG_FN_INIT_MHDR 2219 -#define MNG_FN_INIT_MEND 2220 -#define MNG_FN_INIT_LOOP 2221 -#define MNG_FN_INIT_ENDL 2222 -#define MNG_FN_INIT_DEFI 2223 -#define MNG_FN_INIT_BASI 2224 -#define MNG_FN_INIT_CLON 2225 -#define MNG_FN_INIT_PAST 2226 -#define MNG_FN_INIT_DISC 2227 -#define MNG_FN_INIT_BACK 2228 -#define MNG_FN_INIT_FRAM 2229 -#define MNG_FN_INIT_MOVE 2230 -#define MNG_FN_INIT_CLIP 2231 -#define MNG_FN_INIT_SHOW 2232 -#define MNG_FN_INIT_TERM 2233 -#define MNG_FN_INIT_SAVE 2234 -#define MNG_FN_INIT_SEEK 2235 -#define MNG_FN_INIT_EXPI 2236 -#define MNG_FN_INIT_FPRI 2237 -#define MNG_FN_INIT_NEED 2238 -#define MNG_FN_INIT_PHYG 2239 -#define MNG_FN_INIT_JHDR 2240 -#define MNG_FN_INIT_JDAT 2241 -#define MNG_FN_INIT_JSEP 2242 -#define MNG_FN_INIT_DHDR 2243 -#define MNG_FN_INIT_PROM 2244 -#define MNG_FN_INIT_IPNG 2245 -#define MNG_FN_INIT_PPLT 2246 -#define MNG_FN_INIT_IJNG 2247 -#define MNG_FN_INIT_DROP 2248 -#define MNG_FN_INIT_DBYK 2249 -#define MNG_FN_INIT_ORDR 2250 -#define MNG_FN_INIT_UNKNOWN 2251 -#define MNG_FN_INIT_MAGN 2252 -#define MNG_FN_INIT_JDAA 2253 - -/* ************************************************************************** */ - -#define MNG_FN_FREE_IHDR 2401 -#define MNG_FN_FREE_PLTE 2402 -#define MNG_FN_FREE_IDAT 2403 -#define MNG_FN_FREE_IEND 2404 -#define MNG_FN_FREE_TRNS 2405 -#define MNG_FN_FREE_GAMA 2406 -#define MNG_FN_FREE_CHRM 2407 -#define MNG_FN_FREE_SRGB 2408 -#define MNG_FN_FREE_ICCP 2409 -#define MNG_FN_FREE_TEXT 2410 -#define MNG_FN_FREE_ZTXT 2411 -#define MNG_FN_FREE_ITXT 2412 -#define MNG_FN_FREE_BKGD 2413 -#define MNG_FN_FREE_PHYS 2414 -#define MNG_FN_FREE_SBIT 2415 -#define MNG_FN_FREE_SPLT 2416 -#define MNG_FN_FREE_HIST 2417 -#define MNG_FN_FREE_TIME 2418 -#define MNG_FN_FREE_MHDR 2419 -#define MNG_FN_FREE_MEND 2420 -#define MNG_FN_FREE_LOOP 2421 -#define MNG_FN_FREE_ENDL 2422 -#define MNG_FN_FREE_DEFI 2423 -#define MNG_FN_FREE_BASI 2424 -#define MNG_FN_FREE_CLON 2425 -#define MNG_FN_FREE_PAST 2426 -#define MNG_FN_FREE_DISC 2427 -#define MNG_FN_FREE_BACK 2428 -#define MNG_FN_FREE_FRAM 2429 -#define MNG_FN_FREE_MOVE 2430 -#define MNG_FN_FREE_CLIP 2431 -#define MNG_FN_FREE_SHOW 2432 -#define MNG_FN_FREE_TERM 2433 -#define MNG_FN_FREE_SAVE 2434 -#define MNG_FN_FREE_SEEK 2435 -#define MNG_FN_FREE_EXPI 2436 -#define MNG_FN_FREE_FPRI 2437 -#define MNG_FN_FREE_NEED 2438 -#define MNG_FN_FREE_PHYG 2439 -#define MNG_FN_FREE_JHDR 2440 -#define MNG_FN_FREE_JDAT 2441 -#define MNG_FN_FREE_JSEP 2442 -#define MNG_FN_FREE_DHDR 2443 -#define MNG_FN_FREE_PROM 2444 -#define MNG_FN_FREE_IPNG 2445 -#define MNG_FN_FREE_PPLT 2446 -#define MNG_FN_FREE_IJNG 2447 -#define MNG_FN_FREE_DROP 2448 -#define MNG_FN_FREE_DBYK 2449 -#define MNG_FN_FREE_ORDR 2450 -#define MNG_FN_FREE_UNKNOWN 2451 -#define MNG_FN_FREE_MAGN 2452 -#define MNG_FN_FREE_JDAA 2453 - -/* ************************************************************************** */ - -#define MNG_FN_READ_IHDR 2601 -#define MNG_FN_READ_PLTE 2602 -#define MNG_FN_READ_IDAT 2603 -#define MNG_FN_READ_IEND 2604 -#define MNG_FN_READ_TRNS 2605 -#define MNG_FN_READ_GAMA 2606 -#define MNG_FN_READ_CHRM 2607 -#define MNG_FN_READ_SRGB 2608 -#define MNG_FN_READ_ICCP 2609 -#define MNG_FN_READ_TEXT 2610 -#define MNG_FN_READ_ZTXT 2611 -#define MNG_FN_READ_ITXT 2612 -#define MNG_FN_READ_BKGD 2613 -#define MNG_FN_READ_PHYS 2614 -#define MNG_FN_READ_SBIT 2615 -#define MNG_FN_READ_SPLT 2616 -#define MNG_FN_READ_HIST 2617 -#define MNG_FN_READ_TIME 2618 -#define MNG_FN_READ_MHDR 2619 -#define MNG_FN_READ_MEND 2620 -#define MNG_FN_READ_LOOP 2621 -#define MNG_FN_READ_ENDL 2622 -#define MNG_FN_READ_DEFI 2623 -#define MNG_FN_READ_BASI 2624 -#define MNG_FN_READ_CLON 2625 -#define MNG_FN_READ_PAST 2626 -#define MNG_FN_READ_DISC 2627 -#define MNG_FN_READ_BACK 2628 -#define MNG_FN_READ_FRAM 2629 -#define MNG_FN_READ_MOVE 2630 -#define MNG_FN_READ_CLIP 2631 -#define MNG_FN_READ_SHOW 2632 -#define MNG_FN_READ_TERM 2633 -#define MNG_FN_READ_SAVE 2634 -#define MNG_FN_READ_SEEK 2635 -#define MNG_FN_READ_EXPI 2636 -#define MNG_FN_READ_FPRI 2637 -#define MNG_FN_READ_NEED 2638 -#define MNG_FN_READ_PHYG 2639 -#define MNG_FN_READ_JHDR 2640 -#define MNG_FN_READ_JDAT 2641 -#define MNG_FN_READ_JSEP 2642 -#define MNG_FN_READ_DHDR 2643 -#define MNG_FN_READ_PROM 2644 -#define MNG_FN_READ_IPNG 2645 -#define MNG_FN_READ_PPLT 2646 -#define MNG_FN_READ_IJNG 2647 -#define MNG_FN_READ_DROP 2648 -#define MNG_FN_READ_DBYK 2649 -#define MNG_FN_READ_ORDR 2650 -#define MNG_FN_READ_UNKNOWN 2651 -#define MNG_FN_READ_MAGN 2652 -#define MNG_FN_READ_JDAA 2653 - -/* ************************************************************************** */ - -#define MNG_FN_WRITE_IHDR 2801 -#define MNG_FN_WRITE_PLTE 2802 -#define MNG_FN_WRITE_IDAT 2803 -#define MNG_FN_WRITE_IEND 2804 -#define MNG_FN_WRITE_TRNS 2805 -#define MNG_FN_WRITE_GAMA 2806 -#define MNG_FN_WRITE_CHRM 2807 -#define MNG_FN_WRITE_SRGB 2808 -#define MNG_FN_WRITE_ICCP 2809 -#define MNG_FN_WRITE_TEXT 2810 -#define MNG_FN_WRITE_ZTXT 2811 -#define MNG_FN_WRITE_ITXT 2812 -#define MNG_FN_WRITE_BKGD 2813 -#define MNG_FN_WRITE_PHYS 2814 -#define MNG_FN_WRITE_SBIT 2815 -#define MNG_FN_WRITE_SPLT 2816 -#define MNG_FN_WRITE_HIST 2817 -#define MNG_FN_WRITE_TIME 2818 -#define MNG_FN_WRITE_MHDR 2819 -#define MNG_FN_WRITE_MEND 2820 -#define MNG_FN_WRITE_LOOP 2821 -#define MNG_FN_WRITE_ENDL 2822 -#define MNG_FN_WRITE_DEFI 2823 -#define MNG_FN_WRITE_BASI 2824 -#define MNG_FN_WRITE_CLON 2825 -#define MNG_FN_WRITE_PAST 2826 -#define MNG_FN_WRITE_DISC 2827 -#define MNG_FN_WRITE_BACK 2828 -#define MNG_FN_WRITE_FRAM 2829 -#define MNG_FN_WRITE_MOVE 2830 -#define MNG_FN_WRITE_CLIP 2831 -#define MNG_FN_WRITE_SHOW 2832 -#define MNG_FN_WRITE_TERM 2833 -#define MNG_FN_WRITE_SAVE 2834 -#define MNG_FN_WRITE_SEEK 2835 -#define MNG_FN_WRITE_EXPI 2836 -#define MNG_FN_WRITE_FPRI 2837 -#define MNG_FN_WRITE_NEED 2838 -#define MNG_FN_WRITE_PHYG 2839 -#define MNG_FN_WRITE_JHDR 2840 -#define MNG_FN_WRITE_JDAT 2841 -#define MNG_FN_WRITE_JSEP 2842 -#define MNG_FN_WRITE_DHDR 2843 -#define MNG_FN_WRITE_PROM 2844 -#define MNG_FN_WRITE_IPNG 2845 -#define MNG_FN_WRITE_PPLT 2846 -#define MNG_FN_WRITE_IJNG 2847 -#define MNG_FN_WRITE_DROP 2848 -#define MNG_FN_WRITE_DBYK 2849 -#define MNG_FN_WRITE_ORDR 2850 -#define MNG_FN_WRITE_UNKNOWN 2851 -#define MNG_FN_WRITE_MAGN 2852 -#define MNG_FN_WRITE_JDAA 2853 - -/* ************************************************************************** */ - -#define MNG_FN_ZLIB_INITIALIZE 3001 -#define MNG_FN_ZLIB_CLEANUP 3002 -#define MNG_FN_ZLIB_INFLATEINIT 3003 -#define MNG_FN_ZLIB_INFLATEROWS 3004 -#define MNG_FN_ZLIB_INFLATEDATA 3005 -#define MNG_FN_ZLIB_INFLATEFREE 3006 -#define MNG_FN_ZLIB_DEFLATEINIT 3007 -#define MNG_FN_ZLIB_DEFLATEROWS 3008 -#define MNG_FN_ZLIB_DEFLATEDATA 3009 -#define MNG_FN_ZLIB_DEFLATEFREE 3010 - -/* ************************************************************************** */ - -#define MNG_FN_PROCESS_DISPLAY_IHDR 3201 -#define MNG_FN_PROCESS_DISPLAY_PLTE 3202 -#define MNG_FN_PROCESS_DISPLAY_IDAT 3203 -#define MNG_FN_PROCESS_DISPLAY_IEND 3204 -#define MNG_FN_PROCESS_DISPLAY_TRNS 3205 -#define MNG_FN_PROCESS_DISPLAY_GAMA 3206 -#define MNG_FN_PROCESS_DISPLAY_CHRM 3207 -#define MNG_FN_PROCESS_DISPLAY_SRGB 3208 -#define MNG_FN_PROCESS_DISPLAY_ICCP 3209 -#define MNG_FN_PROCESS_DISPLAY_BKGD 3210 -#define MNG_FN_PROCESS_DISPLAY_PHYS 3211 -#define MNG_FN_PROCESS_DISPLAY_SBIT 3212 -#define MNG_FN_PROCESS_DISPLAY_SPLT 3213 -#define MNG_FN_PROCESS_DISPLAY_HIST 3214 -#define MNG_FN_PROCESS_DISPLAY_MHDR 3215 -#define MNG_FN_PROCESS_DISPLAY_MEND 3216 -#define MNG_FN_PROCESS_DISPLAY_LOOP 3217 -#define MNG_FN_PROCESS_DISPLAY_ENDL 3218 -#define MNG_FN_PROCESS_DISPLAY_DEFI 3219 -#define MNG_FN_PROCESS_DISPLAY_BASI 3220 -#define MNG_FN_PROCESS_DISPLAY_CLON 3221 -#define MNG_FN_PROCESS_DISPLAY_PAST 3222 -#define MNG_FN_PROCESS_DISPLAY_DISC 3223 -#define MNG_FN_PROCESS_DISPLAY_BACK 3224 -#define MNG_FN_PROCESS_DISPLAY_FRAM 3225 -#define MNG_FN_PROCESS_DISPLAY_MOVE 3226 -#define MNG_FN_PROCESS_DISPLAY_CLIP 3227 -#define MNG_FN_PROCESS_DISPLAY_SHOW 3228 -#define MNG_FN_PROCESS_DISPLAY_TERM 3229 -#define MNG_FN_PROCESS_DISPLAY_SAVE 3230 -#define MNG_FN_PROCESS_DISPLAY_SEEK 3231 -#define MNG_FN_PROCESS_DISPLAY_EXPI 3232 -#define MNG_FN_PROCESS_DISPLAY_FPRI 3233 -#define MNG_FN_PROCESS_DISPLAY_NEED 3234 -#define MNG_FN_PROCESS_DISPLAY_PHYG 3235 -#define MNG_FN_PROCESS_DISPLAY_JHDR 3236 -#define MNG_FN_PROCESS_DISPLAY_JDAT 3237 -#define MNG_FN_PROCESS_DISPLAY_JSEP 3238 -#define MNG_FN_PROCESS_DISPLAY_DHDR 3239 -#define MNG_FN_PROCESS_DISPLAY_PROM 3240 -#define MNG_FN_PROCESS_DISPLAY_IPNG 3241 -#define MNG_FN_PROCESS_DISPLAY_PPLT 3242 -#define MNG_FN_PROCESS_DISPLAY_IJNG 3243 -#define MNG_FN_PROCESS_DISPLAY_DROP 3244 -#define MNG_FN_PROCESS_DISPLAY_DBYK 3245 -#define MNG_FN_PROCESS_DISPLAY_ORDR 3246 -#define MNG_FN_PROCESS_DISPLAY_MAGN 3247 -#define MNG_FN_PROCESS_DISPLAY_JDAA 3248 - -/* ************************************************************************** */ - -#define MNG_FN_JPEG_INITIALIZE 3401 -#define MNG_FN_JPEG_CLEANUP 3402 -#define MNG_FN_JPEG_DECOMPRESSINIT 3403 -#define MNG_FN_JPEG_DECOMPRESSDATA 3404 -#define MNG_FN_JPEG_DECOMPRESSFREE 3405 - -#define MNG_FN_STORE_JPEG_G8 3501 -#define MNG_FN_STORE_JPEG_RGB8 3502 -#define MNG_FN_STORE_JPEG_G12 3503 -#define MNG_FN_STORE_JPEG_RGB12 3504 -#define MNG_FN_STORE_JPEG_GA8 3505 -#define MNG_FN_STORE_JPEG_RGBA8 3506 -#define MNG_FN_STORE_JPEG_GA12 3507 -#define MNG_FN_STORE_JPEG_RGBA12 3508 -#define MNG_FN_STORE_JPEG_G8_ALPHA 3509 -#define MNG_FN_STORE_JPEG_RGB8_ALPHA 3510 - -#define MNG_FN_INIT_JPEG_A1_NI 3511 -#define MNG_FN_INIT_JPEG_A2_NI 3512 -#define MNG_FN_INIT_JPEG_A4_NI 3513 -#define MNG_FN_INIT_JPEG_A8_NI 3514 -#define MNG_FN_INIT_JPEG_A16_NI 3515 - -#define MNG_FN_STORE_JPEG_G8_A1 3521 -#define MNG_FN_STORE_JPEG_G8_A2 3522 -#define MNG_FN_STORE_JPEG_G8_A4 3523 -#define MNG_FN_STORE_JPEG_G8_A8 3524 -#define MNG_FN_STORE_JPEG_G8_A16 3525 - -#define MNG_FN_STORE_JPEG_RGB8_A1 3531 -#define MNG_FN_STORE_JPEG_RGB8_A2 3532 -#define MNG_FN_STORE_JPEG_RGB8_A4 3533 -#define MNG_FN_STORE_JPEG_RGB8_A8 3534 -#define MNG_FN_STORE_JPEG_RGB8_A16 3535 - -#define MNG_FN_STORE_JPEG_G12_A1 3541 -#define MNG_FN_STORE_JPEG_G12_A2 3542 -#define MNG_FN_STORE_JPEG_G12_A4 3543 -#define MNG_FN_STORE_JPEG_G12_A8 3544 -#define MNG_FN_STORE_JPEG_G12_A16 3545 - -#define MNG_FN_STORE_JPEG_RGB12_A1 3551 -#define MNG_FN_STORE_JPEG_RGB12_A2 3552 -#define MNG_FN_STORE_JPEG_RGB12_A4 3553 -#define MNG_FN_STORE_JPEG_RGB12_A8 3554 -#define MNG_FN_STORE_JPEG_RGB12_A16 3555 - -#define MNG_FN_NEXT_JPEG_ALPHAROW 3591 -#define MNG_FN_NEXT_JPEG_ROW 3592 -#define MNG_FN_DISPLAY_JPEG_ROWS 3593 - -/* ************************************************************************** */ - -#define MNG_FN_MAGNIFY_G8_X1 3701 -#define MNG_FN_MAGNIFY_G8_X2 3702 -#define MNG_FN_MAGNIFY_RGB8_X1 3703 -#define MNG_FN_MAGNIFY_RGB8_X2 3704 -#define MNG_FN_MAGNIFY_GA8_X1 3705 -#define MNG_FN_MAGNIFY_GA8_X2 3706 -#define MNG_FN_MAGNIFY_GA8_X3 3707 -#define MNG_FN_MAGNIFY_GA8_X4 3708 -#define MNG_FN_MAGNIFY_RGBA8_X1 3709 -#define MNG_FN_MAGNIFY_RGBA8_X2 3710 -#define MNG_FN_MAGNIFY_RGBA8_X3 3711 -#define MNG_FN_MAGNIFY_RGBA8_X4 3712 -#define MNG_FN_MAGNIFY_G8_X3 3713 -#define MNG_FN_MAGNIFY_RGB8_X3 3714 -#define MNG_FN_MAGNIFY_GA8_X5 3715 -#define MNG_FN_MAGNIFY_RGBA8_X5 3716 - -#define MNG_FN_MAGNIFY_G8_Y1 3751 -#define MNG_FN_MAGNIFY_G8_Y2 3752 -#define MNG_FN_MAGNIFY_RGB8_Y1 3753 -#define MNG_FN_MAGNIFY_RGB8_Y2 3754 -#define MNG_FN_MAGNIFY_GA8_Y1 3755 -#define MNG_FN_MAGNIFY_GA8_Y2 3756 -#define MNG_FN_MAGNIFY_GA8_Y3 3757 -#define MNG_FN_MAGNIFY_GA8_Y4 3758 -#define MNG_FN_MAGNIFY_RGBA8_Y1 3759 -#define MNG_FN_MAGNIFY_RGBA8_Y2 3760 -#define MNG_FN_MAGNIFY_RGBA8_Y3 3761 -#define MNG_FN_MAGNIFY_RGBA8_Y4 3762 -#define MNG_FN_MAGNIFY_G8_Y3 3763 -#define MNG_FN_MAGNIFY_RGB8_Y3 3764 -#define MNG_FN_MAGNIFY_GA8_Y5 3765 -#define MNG_FN_MAGNIFY_RGBA8_Y5 3766 - -/* ************************************************************************** */ - -#define MNG_FN_DELTA_G1_G1 3801 -#define MNG_FN_DELTA_G2_G2 3802 -#define MNG_FN_DELTA_G4_G4 3803 -#define MNG_FN_DELTA_G8_G8 3804 -#define MNG_FN_DELTA_G16_G16 3805 -#define MNG_FN_DELTA_RGB8_RGB8 3806 -#define MNG_FN_DELTA_RGB16_RGB16 3807 -#define MNG_FN_DELTA_GA8_GA8 3808 -#define MNG_FN_DELTA_GA8_G8 3809 -#define MNG_FN_DELTA_GA8_A8 3810 -#define MNG_FN_DELTA_GA16_GA16 3811 -#define MNG_FN_DELTA_GA16_G16 3812 -#define MNG_FN_DELTA_GA16_A16 3813 -#define MNG_FN_DELTA_RGBA8_RGBA8 3814 -#define MNG_FN_DELTA_RGBA8_RGB8 3815 -#define MNG_FN_DELTA_RGBA8_A8 3816 -#define MNG_FN_DELTA_RGBA16_RGBA16 3817 -#define MNG_FN_DELTA_RGBA16_RGB16 3818 -#define MNG_FN_DELTA_RGBA16_A16 3819 - -/* ************************************************************************** */ -/* * * */ -/* * Trace string-table entry * */ -/* * * */ -/* ************************************************************************** */ - -typedef struct { - mng_uint32 iFunction; - mng_pchar zTracetext; - } mng_trace_entry; -typedef mng_trace_entry * mng_trace_entryp; - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_TRACE_PROCS */ - -/* ************************************************************************** */ - -#endif /* _libmng_trace_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_types.h b/freeimage241/Source/LibMNG/libmng_types.h deleted file mode 100644 index eeffb0e..0000000 --- a/freeimage241/Source/LibMNG/libmng_types.h +++ /dev/null @@ -1,494 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_types.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.2 * */ -/* * * */ -/* * purpose : type specifications * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Specification of the types used by the library * */ -/* * Creates platform-independant structure * */ -/* * * */ -/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */ -/* * - added iteratechunk callback definition * */ -/* * 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - improved definitions for DLL support * */ -/* * - added 8-bit palette definition * */ -/* * - added general array definitions * */ -/* * - added MNG_NULL definition * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - changed most callback prototypes to allow the app * */ -/* * to report errors during callback processing * */ -/* * 0.5.1 - 05/16/2000 - G.Juyn * */ -/* * - moved standard header includes into this file * */ -/* * (stdlib/mem for mem-mngmt & math for fp gamma-calc) * */ -/* * * */ -/* * 0.5.2 - 05/18/2000 - G.Juyn * */ -/* * - B003 - fixed problem with being proprietary * */ -/* * to Borland platform * */ -/* * - added helper definitions for JNG (IJG-based) * */ -/* * - fixed support for IJGSRC6B * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - added default IJG compression parameters and such * */ -/* * 0.5.2 - 05/31/2000 - G.Juyn * */ -/* * - fixed inclusion for memcpy (contributed by Tim Rowley) * */ -/* * - added mng_int32p (contributed by Tim Rowley) * */ -/* * 0.5.2 - 06/02/2000 - G.Juyn * */ -/* * - removed SWAP_ENDIAN reference (contributed by Tim Rowley)* */ -/* * - added getalphaline callback for RGB8_A8 canvasstyle * */ -/* * * */ -/* * 0.5.3 - 06/21/2000 - G.Juyn * */ -/* * - added speedtype to facilitate testing * */ -/* * 0.5.3 - 06/27/2000 - G.Juyn * */ -/* * - added typedef for mng_size_t * */ -/* * - changed size parameter for memory callbacks to * */ -/* * mng_size_t * */ -/* * 0.5.3 - 06/28/2000 - G.Juyn * */ -/* * - changed definition of 32-bit ints (64-bit platforms) * */ -/* * - changed definition of mng_handle (64-bit platforms) * */ -/* * 0.5.3 - 06/29/2000 - G.Juyn * */ -/* * - changed definition of mng_handle (again) * */ -/* * - swapped refresh parameters * */ -/* * - added inclusion of stdlib.h for abs() * */ -/* * * */ -/* * 0.9.0 - 06/30/2000 - G.Juyn * */ -/* * - changed refresh parameters to 'x,y,width,height' * */ -/* * 0.9.1 - 07/10/2000 - G.Juyn * */ -/* * - added suspendbuffer constants * */ -/* * 0.9.1 - 07/15/2000 - G.Juyn * */ -/* * - added callbacks for SAVE/SEEK processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/07/2000 - G.Juyn * */ -/* * - B111300 - fixup for improved portability * */ -/* * 0.9.3 - 08/12/2000 - G.Juyn * */ -/* * - added workaround for faulty PhotoShop iCCP chunk * */ -/* * 0.9.3 - 09/11/2000 - G.Juyn * */ -/* * - added export of zlib functions from windows dll * */ -/* * - fixed inclusion parameters once again to make those * */ -/* * external libs work together * */ -/* * - re-fixed fixed inclusion parameters * */ -/* * (these freeking libraries make me mad) * */ -/* * 0.9.3 - 10/11/2000 - G.Juyn * */ -/* * - added support for nEED * */ -/* * 0.9.3 - 10/17/2000 - G.Juyn * */ -/* * - added callback to process non-critical unknown chunks * */ -/* * * */ -/* * 0.9.4 - 11/20/2000 - R.Giles * */ -/* * - fixed inclusion of lcms header for non-windows platforms * */ -/* * 0.9.4 - 12/12/2000 - G.Juyn * */ -/* * - changed callback convention for MSVC (Thanks Chad) * */ -/* * 0.9.4 - 12/16/2000 - G.Juyn * */ -/* * - fixed mixup of data- & function-pointers (thanks Dimitri)* */ -/* * * */ -/* * 1.0.1 - 02/08/2001 - G.Juyn * */ -/* * - added MEND processing callback * */ -/* * * */ -/* * 1.0.2 - 06/23/2001 - G.Juyn * */ -/* * - added processterm callback * */ -/* * * */ -/* ************************************************************************** */ - -#ifndef _libmng_types_h_ -#define _libmng_types_h_ - -/* ************************************************************************** */ - -#ifdef __BORLANDC__ -#pragma option -AT /* turn off strict ANSI-C for the moment */ -#endif - -#ifndef WIN32 -#if defined(_WIN32) || defined(__WIN32__) || defined(_Windows) || defined(_WINDOWS) -#define WIN32 /* gather them into a single define */ -#endif -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Here's where the external & standard libs are embedded * */ -/* * * */ -/* * (it can be a bit of a pain in the lower-back to get them to work * */ -/* * together) * */ -/* * * */ -/* ************************************************************************** */ - -#ifdef WIN32 /* only include needed stuff */ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#endif - -#ifdef MNG_USE_DLL -#ifdef MNG_SKIP_ZLIB -#undef MNG_INCLUDE_ZLIB -#endif -#ifdef MNG_SKIP_LCMS -#undef MNG_INCLUDE_LCMS -#endif -#ifdef MNG_SKIP_IJG6B -#undef MNG_INCLUDE_IJG6B -#endif -#endif - -#ifdef MNG_INCLUDE_ZLIB /* zlib by Mark Adler & Jean-loup Gailly */ -#include "../zlib/zlib.h" -#endif - -#ifdef MNG_INCLUDE_LCMS /* little cms by Marti Maria Saguer */ -#ifndef ZLIB_DLL -#undef FAR -#endif -#ifdef WIN32 /* different header locations */ -#include "lcms.h" -#else -#include "lcms/lcms.h" -#endif -#endif /* MNG_INCLUDE_LCMS */ - -#ifdef MNG_INCLUDE_IJG6B /* IJG's jpgsrc6b */ -#include -#ifdef MNG_USE_SETJMP -#include /* needed for error-recovery (blergh) */ -#else -#ifdef WIN32 -#define USE_WINDOWS_MESSAGEBOX /* display a messagebox under Windoze */ -#endif -#endif /* MNG_USE_SETJMP */ -#ifdef FAR -#undef FAR /* possibly defined by zlib or lcms */ -#endif -#include "../libjpeg/jpeglib.h" /* all that for JPEG support :-) */ -#endif /* MNG_INCLUDE_IJG6B */ - -#if defined(MNG_INTERNAL_MEMMNGMT) || defined(MNG_INCLUDE_FILTERS) -#include /* "calloc" & "free" & "abs" */ -#endif - -#include /* get proper integer widths */ - -#ifdef WIN32 -/* B003 */ -#if defined __BORLANDC__ -#include /* defines "memcpy" for BCB */ -#else -#include /* defines "memcpy" for other win32 platforms */ -#endif -/* B003 */ -#ifdef MNG_CHECK_BAD_ICCP -#include /* strncmp() */ -#endif -#else -#ifdef BSD -#include /* defines "memcpy" for BSD (?) */ -#else -#include /* defines "memcpy" for all others (???) */ -#endif -#endif - -#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) -#include /* fp gamma-calculation */ -#endif - -/* ************************************************************************** */ -/* * * */ -/* * Platform-dependant stuff * */ -/* * * */ -/* ************************************************************************** */ - -/* TODO: this may require some elaboration for other platforms; - only works with BCB for now */ - -#ifndef MNG_DLL -#if defined(MNG_BUILD_DLL) || defined(MNG_USE_DLL) -#define MNG_DLL -#endif -#endif - -#if defined(MNG_DLL) && defined(WIN32) /* setup DLL calling conventions */ -#define MNG_DECL __stdcall -#if defined(MNG_BUILD_DLL) -#define MNG_EXT __declspec(dllexport) -#elif defined(MNG_USE_DLL) -#define MNG_EXT __declspec(dllimport) -#else -#define MNG_EXT -#endif -#ifdef MNG_STRICT_ANSI -#undef MNG_STRICT_ANSI /* can't do strict-ANSI with this DLL-stuff */ -#endif -#else -#define MNG_DECL /* dummies for non-DLL */ -#define MNG_EXT -#endif /* MNG_DLL && WIN32 */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* now force ANSI-C from here on */ -#endif - -/* ************************************************************************** */ - -#if USHRT_MAX == 0xffffffffU /* get the proper 32-bit width !!! */ -typedef unsigned short mng_uint32; -typedef signed short mng_int32; -#elif UINT_MAX == 0xffffffffU -typedef unsigned int mng_uint32; -typedef signed int mng_int32; -#elif ULONG_MAX == 0xffffffffU -typedef unsigned long mng_uint32; -typedef signed long mng_int32; -#else -#error "Sorry, I can't find any 32-bit integers on this platform." -#endif - -typedef signed short mng_int16; /* other basic integers */ -typedef unsigned short mng_uint16; -typedef signed char mng_int8; -typedef unsigned char mng_uint8; - -typedef double mng_float; /* basic float */ - -typedef size_t mng_size_t; /* size field for memory allocation */ - -typedef char * mng_pchar; /* string */ -typedef void * mng_ptr; /* generic pointer */ -typedef void (*mng_fptr) (void); /* generic function pointer */ - -/* ************************************************************************** */ -/* * * */ -/* * Platform-independant from here * */ -/* * * */ -/* ************************************************************************** */ - -typedef mng_uint32 * mng_uint32p; /* pointer to unsigned longs */ -typedef mng_int32 * mng_int32p; /* pointer to longs */ -typedef mng_uint16 * mng_uint16p; /* pointer to unsigned words */ -typedef mng_uint8 * mng_uint8p; /* pointer to unsigned bytes */ - -typedef mng_int8 mng_bool; /* booleans */ - -struct mng_data_struct; -typedef struct mng_data_struct * mng_handle; /* generic handle */ - -typedef mng_int32 mng_retcode; /* generic return code */ -typedef mng_int32 mng_chunkid; /* 4-byte chunkname identifier */ -typedef mng_ptr mng_chunkp; /* pointer to a chunk-structure */ -typedef mng_ptr mng_objectp; /* pointer to an object-structure */ - -typedef mng_chunkid * mng_chunkidp; /* pointer to chunkid */ - -typedef struct { /* 8-bit palette element */ - mng_uint8 iRed; - mng_uint8 iGreen; - mng_uint8 iBlue; - } mng_palette8e; -typedef mng_palette8e mng_palette8[256]; /* 8-bit palette */ -typedef mng_palette8e * mng_palette8ep; - -typedef mng_uint8 mng_uint8arr[256]; /* generic arrays */ -typedef mng_uint8 mng_uint8arr4[4]; -typedef mng_uint16 mng_uint16arr[256]; -typedef mng_uint32 mng_uint32arr2[2]; - -/* ************************************************************************** */ - -#define MNG_FALSE 0 -#define MNG_TRUE 1 -#define MNG_NULL 0 - -#define MNG_SUSPENDBUFFERSIZE 32768 -#define MNG_SUSPENDREQUESTSIZE 1024 - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB - -/* size of temporary zlib buffer for deflate processing */ -#define MNG_ZLIB_MAXBUF 8192 - -/* default zlib compression parameters for deflateinit2 */ -#define MNG_ZLIB_LEVEL 9 /* level */ -#define MNG_ZLIB_METHOD Z_DEFLATED /* method */ -#define MNG_ZLIB_WINDOWBITS 15 /* window size */ -#define MNG_ZLIB_MEMLEVEL 9 /* memory level */ -#define MNG_ZLIB_STRATEGY Z_DEFAULT_STRATEGY /* strategy */ - -#define MNG_MAX_IDAT_SIZE 4096 /* maximum size of IDAT data */ - -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_JNG - -#ifdef MNG_INCLUDE_IJG6B /* IJG helper defs */ -typedef struct jpeg_compress_struct mngjpeg_comp; -typedef struct jpeg_decompress_struct mngjpeg_decomp; -typedef struct jpeg_error_mgr mngjpeg_error; -typedef struct jpeg_source_mgr mngjpeg_source; - -typedef mngjpeg_comp * mngjpeg_compp; -typedef mngjpeg_decomp * mngjpeg_decompp; -typedef mngjpeg_error * mngjpeg_errorp; -typedef mngjpeg_source * mngjpeg_sourcep; - -typedef J_DCT_METHOD mngjpeg_dctmethod; - -/* default IJG parameters for compression */ -#define MNG_JPEG_DCT JDCT_DEFAULT /* DCT algorithm (JDCT_ISLOW) */ -#define MNG_JPEG_QUALITY 100 /* quality 0..100; 100=best */ -#define MNG_JPEG_SMOOTHING 0 /* default no smoothing */ -#define MNG_JPEG_PROGRESSIVE MNG_FALSE /* default is just baseline */ -#define MNG_JPEG_OPTIMIZED MNG_FALSE /* default is not optimized */ -#endif /* MNG_INCLUDE_IJG6B */ - -#define MNG_JPEG_MAXBUF 65500 /* max size of temp JPEG buffer */ -#define MNG_MAX_JDAT_SIZE 4096 /* maximum size of JDAT data */ - -#endif /* MNG_INCLUDE_JNG */ - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_LCMS -typedef cmsHPROFILE mng_cmsprof; /* little CMS helper defs */ -typedef cmsHTRANSFORM mng_cmstrans; -typedef cmsCIExyY mng_CIExyY; -typedef cmsCIExyYTRIPLE mng_CIExyYTRIPLE; -typedef LPGAMMATABLE mng_gammatabp; -#endif /* MNG_INCLUDE_LCMS */ - -/* ************************************************************************** */ - - /* enumeration of known graphics types */ -enum mng_imgtypes {mng_it_unknown, mng_it_png, mng_it_mng, mng_it_jng}; -typedef enum mng_imgtypes mng_imgtype; - - /* enumeration of animation speed-types */ -enum mng_speedtypes {mng_st_normal, mng_st_fast, mng_st_slow, mng_st_slowest}; -typedef enum mng_speedtypes mng_speedtype; - -/* ************************************************************************** */ - - /* memory management callbacks */ -typedef mng_ptr (MNG_DECL *mng_memalloc) (mng_size_t iLen); -typedef void (MNG_DECL *mng_memfree) (mng_ptr iPtr, - mng_size_t iLen); - - /* I/O management callbacks */ -typedef mng_bool (MNG_DECL *mng_openstream) (mng_handle hHandle); -typedef mng_bool (MNG_DECL *mng_closestream) (mng_handle hHandle); -typedef mng_bool (MNG_DECL *mng_readdata) (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pRead); -typedef mng_bool (MNG_DECL *mng_writedata) (mng_handle hHandle, - mng_ptr pBuf, - mng_uint32 iBuflen, - mng_uint32p pWritten); - - /* error & trace processing callbacks */ -typedef mng_bool (MNG_DECL *mng_errorproc) (mng_handle hHandle, - mng_int32 iErrorcode, - mng_int8 iSeverity, - mng_chunkid iChunkname, - mng_uint32 iChunkseq, - mng_int32 iExtra1, - mng_int32 iExtra2, - mng_pchar zErrortext); -typedef mng_bool (MNG_DECL *mng_traceproc) (mng_handle hHandle, - mng_int32 iFuncnr, - mng_int32 iFuncseq, - mng_pchar zFuncname); - - /* read processing callbacks */ -typedef mng_bool (MNG_DECL *mng_processheader) (mng_handle hHandle, - mng_uint32 iWidth, - mng_uint32 iHeight); -typedef mng_bool (MNG_DECL *mng_processtext) (mng_handle hHandle, - mng_uint8 iType, - mng_pchar zKeyword, - mng_pchar zText, - mng_pchar zLanguage, - mng_pchar zTranslation); -typedef mng_bool (MNG_DECL *mng_processsave) (mng_handle hHandle); -typedef mng_bool (MNG_DECL *mng_processseek) (mng_handle hHandle, - mng_pchar zName); -typedef mng_bool (MNG_DECL *mng_processneed) (mng_handle hHandle, - mng_pchar zKeyword); -typedef mng_bool (MNG_DECL *mng_processmend) (mng_handle hHandle, - mng_uint32 iIterationsdone, - mng_uint32 iIterationsleft); -typedef mng_bool (MNG_DECL *mng_processunknown) (mng_handle hHandle, - mng_chunkid iChunkid, - mng_uint32 iRawlen, - mng_ptr pRawdata); -typedef mng_bool (MNG_DECL *mng_processterm) (mng_handle hHandle, - mng_uint8 iTermaction, - mng_uint8 iIteraction, - mng_uint32 iDelay, - mng_uint32 iItermax); - - /* display processing callbacks */ -typedef mng_ptr (MNG_DECL *mng_getcanvasline) (mng_handle hHandle, - mng_uint32 iLinenr); -typedef mng_ptr (MNG_DECL *mng_getbkgdline) (mng_handle hHandle, - mng_uint32 iLinenr); -typedef mng_ptr (MNG_DECL *mng_getalphaline) (mng_handle hHandle, - mng_uint32 iLinenr); -typedef mng_bool (MNG_DECL *mng_refresh) (mng_handle hHandle, - mng_uint32 iX, - mng_uint32 iY, - mng_uint32 iWidth, - mng_uint32 iHeight); - - /* timer management callbacks */ -typedef mng_uint32 (MNG_DECL *mng_gettickcount) (mng_handle hHandle); -typedef mng_bool (MNG_DECL *mng_settimer) (mng_handle hHandle, - mng_uint32 iMsecs); - - /* color management callbacks */ -typedef mng_bool (MNG_DECL *mng_processgamma) (mng_handle hHandle, - mng_uint32 iGamma); -typedef mng_bool (MNG_DECL *mng_processchroma) (mng_handle hHandle, - mng_uint32 iWhitepointx, - mng_uint32 iWhitepointy, - mng_uint32 iRedx, - mng_uint32 iRedy, - mng_uint32 iGreenx, - mng_uint32 iGreeny, - mng_uint32 iBluex, - mng_uint32 iBluey); -typedef mng_bool (MNG_DECL *mng_processsrgb) (mng_handle hHandle, - mng_uint8 iRenderingintent); -typedef mng_bool (MNG_DECL *mng_processiccp) (mng_handle hHandle, - mng_uint32 iProfilesize, - mng_ptr pProfile); -typedef mng_bool (MNG_DECL *mng_processarow) (mng_handle hHandle, - mng_uint32 iRowsamples, - mng_bool bIsRGBA16, - mng_ptr pRow); - - /* chunk access callback(s) */ -typedef mng_bool (MNG_DECL *mng_iteratechunk) (mng_handle hHandle, - mng_handle hChunk, - mng_chunkid iChunkid, - mng_uint32 iChunkseq); - -/* ************************************************************************** */ - -#endif /* _libmng_types_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_write.c b/freeimage241/Source/LibMNG/libmng_write.c deleted file mode 100644 index 07a530f..0000000 --- a/freeimage241/Source/LibMNG/libmng_write.c +++ /dev/null @@ -1,139 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_write.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Write management (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the write management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * 0.5.1 - 05/16/2000 - G.Juyn * */ -/* * - moved the actual write_graphic functionality from * */ -/* * mng_hlapi to it's appropriate function here * */ -/* * * */ -/* * 0.9.1 - 07/19/2000 - G.Juyn * */ -/* * - fixed writing of signature * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_chunks.h" -#include "libmng_chunk_io.h" -#include "libmng_write.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_WRITE_PROCS - -/* ************************************************************************** */ - -mng_retcode write_graphic (mng_datap pData) -{ - mng_chunkp pChunk; - mng_retcode iRetcode; - mng_uint32 iWritten; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_GRAPHIC, MNG_LC_START) -#endif - - pChunk = pData->pFirstchunk; /* we'll start with the first, thank you */ - - if (pChunk) /* is there anything to write ? */ - { /* open the file */ - if (!pData->fOpenstream ((mng_handle)pData)) - MNG_ERROR (pData, MNG_APPIOERROR) - else - { - pData->bWriting = MNG_TRUE; /* indicate writing */ - pData->iWritebufsize = 32768; /* get a temporary write buffer */ - /* reserve 12 bytes for length, chunkname & crc */ - MNG_ALLOC (pData, pData->pWritebuf, pData->iWritebufsize+12) - /* write the signature */ - if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_IHDR) - mng_put_uint32 (pData->pWritebuf, PNG_SIG); - else - if (((mng_chunk_headerp)pChunk)->iChunkname == MNG_UINT_JHDR) - mng_put_uint32 (pData->pWritebuf, JNG_SIG); - else - mng_put_uint32 (pData->pWritebuf, MNG_SIG); - - mng_put_uint32 (pData->pWritebuf+4, POST_SIG); - - if (!pData->fWritedata ((mng_handle)pData, pData->pWritebuf, 8, &iWritten)) - { - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12) - MNG_ERROR (pData, MNG_APPIOERROR) - } - - if (iWritten != 8) /* disk full ? */ - { - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12) - MNG_ERROR (pData, MNG_OUTPUTERROR) - } - - while (pChunk) /* so long as there's something to write */ - { /* let's call it's output routine */ - iRetcode = ((mng_chunk_headerp)pChunk)->fWrite (pData, pChunk); - - if (iRetcode) /* on error bail out */ - { - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12) - return iRetcode; - } - /* neeeext */ - pChunk = ((mng_chunk_headerp)pChunk)->pNext; - } - /* free the temporary buffer */ - MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize+12) - - pData->bWriting = MNG_FALSE; /* done writing */ - /* close the stream now */ - if (!pData->fClosestream ((mng_handle)pData)) - MNG_ERROR (pData, MNG_APPIOERROR) - - } - } - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_WRITE_GRAPHIC, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_WRITE_PROCS */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - - diff --git a/freeimage241/Source/LibMNG/libmng_write.h b/freeimage241/Source/LibMNG/libmng_write.h deleted file mode 100644 index df72396..0000000 --- a/freeimage241/Source/LibMNG/libmng_write.h +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_write.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : Write management (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the write management routines * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_write_h_ -#define _libmng_write_h_ - -/* ************************************************************************** */ - -mng_retcode write_graphic (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_write_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibMNG/libmng_zlib.c b/freeimage241/Source/LibMNG/libmng_zlib.c deleted file mode 100644 index 0730b2f..0000000 --- a/freeimage241/Source/LibMNG/libmng_zlib.c +++ /dev/null @@ -1,451 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_zlib.c copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : ZLIB library interface (implementation) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : implementation of the ZLIB library interface * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * 0.5.1 - 05/11/2000 - G.Juyn * */ -/* * - filled the deflatedata routine * */ -/* * 0.5.1 - 05/12/2000 - G.Juyn * */ -/* * - changed trace to macro for callback error-reporting * */ -/* * * */ -/* * 0.5.2 - 05/20/2000 - G.Juyn * */ -/* * - fixed for JNG alpha handling * */ -/* * 0.5.2 - 05/24/2000 - G.Juyn * */ -/* * - moved init of default zlib parms from here to * */ -/* * "mng_hlapi.c" * */ -/* * * */ -/* * 0.5.3 - 06/16/2000 - G.Juyn * */ -/* * - changed progressive-display processing * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* * 0.9.3 - 08/08/2000 - G.Juyn * */ -/* * - fixed compiler-warnings from Mozilla * */ -/* * 0.9.3 - 09/07/2000 - G.Juyn * */ -/* * - added support for new filter_types * */ -/* * * */ -/* ************************************************************************** */ - -#include "libmng.h" -#include "libmng_data.h" -#include "libmng_error.h" -#include "libmng_trace.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif -#include "libmng_memory.h" -#include "libmng_pixels.h" -#include "libmng_filter.h" -#include "libmng_zlib.h" - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -/* ************************************************************************** */ - -#ifdef MNG_INCLUDE_ZLIB - -/* ************************************************************************** */ - -voidpf mngzlib_alloc (voidpf pData, - uInt iCount, - uInt iSize) -{ - voidpf pPtr; /* temporary space */ - -#ifdef MNG_INTERNAL_MEMMNGMT - pPtr = calloc (iCount, iSize); /* local allocation */ -#else - if (((mng_datap)pData)->fMemalloc) /* callback function set ? */ - pPtr = ((mng_datap)pData)->fMemalloc (iCount * iSize); - else - pPtr = Z_NULL; /* can't allocate! */ -#endif - - return pPtr; /* return the result */ -} - -/* ************************************************************************** */ - -void mngzlib_free (voidpf pData, - voidpf pAddress) -{ -#ifdef MNG_INTERNAL_MEMMNGMT - free (pAddress); /* free locally */ -#else - if (((mng_datap)pData)->fMemfree) /* callback set? */ - ((mng_datap)pData)->fMemfree (pAddress, 1); -#endif -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_initialize (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INITIALIZE, MNG_LC_START) -#endif - -#ifdef MNG_INTERNAL_MEMMNGMT - pData->sZlib.zalloc = Z_NULL; /* let zlib figure out memory management */ - pData->sZlib.zfree = Z_NULL; - pData->sZlib.opaque = Z_NULL; -#else /* use user-provided callbacks */ - pData->sZlib.zalloc = mngzlib_alloc; - pData->sZlib.zfree = mngzlib_free; - pData->sZlib.opaque = (voidpf)pData; -#endif - - pData->bInflating = MNG_FALSE; /* not performing any action yet */ - pData->bDeflating = MNG_FALSE; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INITIALIZE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_cleanup (mng_datap pData) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_CLEANUP, MNG_LC_START) -#endif - - if (pData->bInflating) /* force zlib cleanup */ - mngzlib_inflatefree (pData); - if (pData->bDeflating) - mngzlib_deflatefree (pData); - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_CLEANUP, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_inflateinit (mng_datap pData) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEINIT, MNG_LC_START) -#endif - /* initialize zlib structures and such */ - iZrslt = inflateInit (&pData->sZlib); - - if (iZrslt != Z_OK) /* on error bail out */ - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - - pData->bInflating = MNG_TRUE; /* really inflating something now */ - pData->sZlib.next_out = 0; /* force JIT initialization */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEINIT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#ifdef MNG_SUPPORT_DISPLAY -mng_retcode mngzlib_inflaterows (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata) -{ - int iZrslt; - mng_retcode iRslt; - mng_ptr pSwap; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEROWS, MNG_LC_START) -#endif - - pData->sZlib.next_in = pIndata; /* let zlib know where to get stuff */ - pData->sZlib.avail_in = (uInt)iInlen; - - if (pData->sZlib.next_out == 0) /* initialize output variables ? */ - { /* let zlib know where to store stuff */ - pData->sZlib.next_out = pData->pWorkrow; - pData->sZlib.avail_out = (uInt)(pData->iRowsize + pData->iPixelofs); - } - - do - { /* now inflate a row */ - iZrslt = inflate (&pData->sZlib, Z_SYNC_FLUSH); - /* produced a full row ? */ - if (((iZrslt == Z_OK) || (iZrslt == Z_STREAM_END)) && - (pData->sZlib.avail_out == 0)) - { /* shouldn't we be at the end ? */ - if (pData->iRow >= (mng_int32)pData->iDataheight) -/* MNG_ERROR (pData, MNG_TOOMUCHIDAT) */ ; /* TODO: check this!!! */ - else - { /* has leveling info ? */ -/* if (pData->iFilterofs) - iRslt = init_rowdiffering (pData); - else - iRslt = MNG_NOERROR; */ - /* filter the row if necessary */ -/* if ((!iRslt) && (pData->iFilterofs < pData->iPixelofs ) && - (*(pData->pWorkrow + pData->iFilterofs)) ) */ - if (*(pData->pWorkrow + pData->iFilterofs)) - iRslt = filter_a_row (pData); - else - iRslt = MNG_NOERROR; - /* additonal leveling/differing ? */ - if ((!iRslt) && (pData->fDifferrow)) - { - iRslt = ((mng_differrow)pData->fDifferrow) (pData); - - pSwap = pData->pWorkrow; - pData->pWorkrow = pData->pPrevrow; - pData->pPrevrow = pSwap; /* make sure we're processing the right data */ - } - - if (!iRslt) - { -#ifdef MNG_INCLUDE_JNG - if (pData->bHasJHDR) /* is JNG alpha-channel ? */ - { /* just store in object ? */ - if ((!iRslt) && (pData->fStorerow)) - iRslt = ((mng_storerow)pData->fStorerow) (pData); - } - else -#endif /* MNG_INCLUDE_JNG */ - { /* process this row */ - if ((!iRslt) && (pData->fProcessrow)) - iRslt = ((mng_processrow)pData->fProcessrow) (pData); - /* store in object ? */ - if ((!iRslt) && (pData->fStorerow)) - iRslt = ((mng_storerow)pData->fStorerow) (pData); - /* color correction ? */ - if ((!iRslt) && (pData->fCorrectrow)) - iRslt = ((mng_correctrow)pData->fCorrectrow) (pData); - /* slap onto canvas ? */ - if ((!iRslt) && (pData->fDisplayrow)) - { - iRslt = ((mng_displayrow)pData->fDisplayrow) (pData); - - if (!iRslt) /* check progressive display refresh */ - iRslt = display_progressive_check (pData); - - } - } - } - - if (iRslt) /* on error bail out */ - MNG_ERROR (pData, iRslt); - - if (!pData->fDifferrow) /* swap row-pointers */ - { - pSwap = pData->pWorkrow; - pData->pWorkrow = pData->pPrevrow; - pData->pPrevrow = pSwap; /* so prev points to the processed row! */ - } - - iRslt = next_row (pData); /* adjust variables for next row */ - - if (iRslt) /* on error bail out */ - MNG_ERROR (pData, iRslt); - } - /* let zlib know where to store next output */ - pData->sZlib.next_out = pData->pWorkrow; - pData->sZlib.avail_out = (uInt)(pData->iRowsize + pData->iPixelofs); - } - } /* until some error or EOI */ - while ((iZrslt == Z_OK) && (pData->sZlib.avail_in > 0)); - /* on error bail out */ - if ((iZrslt != Z_OK) && (iZrslt != Z_STREAM_END)) - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEROWS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} -#endif /* MNG_SUPPORT_DISPLAY */ - -/* ************************************************************************** */ - -mng_retcode mngzlib_inflatedata (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEDATA, MNG_LC_START) -#endif - /* let zlib know where to get stuff */ - pData->sZlib.next_in = pIndata; - pData->sZlib.avail_in = (uInt)iInlen; - /* now inflate the data in one go! */ - iZrslt = inflate (&pData->sZlib, Z_FINISH); - /* not enough room in output-buffer ? */ - if ((iZrslt == Z_BUF_ERROR) || (pData->sZlib.avail_in > 0)) - return MNG_BUFOVERFLOW; - /* on error bail out */ - if ((iZrslt != Z_OK) && (iZrslt != Z_STREAM_END)) - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_inflatefree (mng_datap pData) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEFREE, MNG_LC_START) -#endif - - pData->bInflating = MNG_FALSE; /* stopped it */ - - iZrslt = inflateEnd (&pData->sZlib); /* let zlib cleanup it's own stuff */ - - if (iZrslt != Z_OK) /* on error bail out */ - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEFREE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_deflateinit (mng_datap pData) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEINIT, MNG_LC_START) -#endif - /* initialize zlib structures and such */ - iZrslt = deflateInit2 (&pData->sZlib, pData->iZlevel, pData->iZmethod, - pData->iZwindowbits, pData->iZmemlevel, - pData->iZstrategy); - - if (iZrslt != Z_OK) /* on error bail out */ - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - - pData->bDeflating = MNG_TRUE; /* really deflating something now */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEINIT, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_deflaterows (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata) -{ -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEROWS, MNG_LC_START) -#endif - - - - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEROWS, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_deflatedata (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEDATA, MNG_LC_START) -#endif - - pData->sZlib.next_in = pIndata; /* let zlib know where to get stuff */ - pData->sZlib.avail_in = (uInt)iInlen; - /* now deflate the data in one go! */ - iZrslt = deflate (&pData->sZlib, Z_FINISH); - /* not enough room in output-buffer ? */ - if ((iZrslt == Z_BUF_ERROR) || (pData->sZlib.avail_in > 0)) - return MNG_BUFOVERFLOW; - /* on error bail out */ - if ((iZrslt != Z_OK) && (iZrslt != Z_STREAM_END)) - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEDATA, MNG_LC_END) -#endif - - return MNG_NOERROR; -} - -/* ************************************************************************** */ - -mng_retcode mngzlib_deflatefree (mng_datap pData) -{ - int iZrslt; - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEFREE, MNG_LC_START) -#endif - - iZrslt = deflateEnd (&pData->sZlib); /* let zlib cleanup it's own stuff */ - - if (iZrslt != Z_OK) /* on error bail out */ - MNG_ERRORZ (pData, (mng_uint32)iZrslt) - - pData->bDeflating = MNG_FALSE; /* stopped it */ - -#ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_ZLIB_DEFLATEFREE, MNG_LC_END) -#endif - - return MNG_NOERROR; /* done */ -} - -/* ************************************************************************** */ - -#endif /* MNG_INCLUDE_ZLIB */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ - diff --git a/freeimage241/Source/LibMNG/libmng_zlib.h b/freeimage241/Source/LibMNG/libmng_zlib.h deleted file mode 100644 index e5bfbdb..0000000 --- a/freeimage241/Source/LibMNG/libmng_zlib.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ************************************************************************** */ -/* * For conditions of distribution and use, * */ -/* * see copyright notice in libmng.h * */ -/* ************************************************************************** */ -/* * * */ -/* * project : libmng * */ -/* * file : libmng_zlib.h copyright (c) 2000 G.Juyn * */ -/* * version : 1.0.0 * */ -/* * * */ -/* * purpose : ZLIB package interface (definition) * */ -/* * * */ -/* * author : G.Juyn * */ -/* * web : http://www.3-t.com * */ -/* * email : mailto:info@3-t.com * */ -/* * * */ -/* * comment : Definition of the ZLIB package interface * */ -/* * * */ -/* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */ -/* * - changed strict-ANSI stuff * */ -/* * * */ -/* * 0.9.2 - 08/05/2000 - G.Juyn * */ -/* * - changed file-prefixes * */ -/* * * */ -/* ************************************************************************** */ - -#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI) -#pragma option -A /* force ANSI-C */ -#endif - -#ifndef _libmng_zlib_h_ -#define _libmng_zlib_h_ - -/* ************************************************************************** */ - -mng_retcode mngzlib_initialize (mng_datap pData); -mng_retcode mngzlib_cleanup (mng_datap pData); - -mng_retcode mngzlib_inflateinit (mng_datap pData); -mng_retcode mngzlib_inflaterows (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata); -mng_retcode mngzlib_inflatedata (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata); -mng_retcode mngzlib_inflatefree (mng_datap pData); - -mng_retcode mngzlib_deflateinit (mng_datap pData); -mng_retcode mngzlib_deflaterows (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata); -mng_retcode mngzlib_deflatedata (mng_datap pData, - mng_uint32 iInlen, - mng_uint8p pIndata); -mng_retcode mngzlib_deflatefree (mng_datap pData); - -/* ************************************************************************** */ - -#endif /* _libmng_zlib_h_ */ - -/* ************************************************************************** */ -/* * end of file * */ -/* ************************************************************************** */ diff --git a/freeimage241/Source/LibPNG/ANNOUNCE b/freeimage241/Source/LibPNG/ANNOUNCE deleted file mode 100644 index 7827622..0000000 --- a/freeimage241/Source/LibPNG/ANNOUNCE +++ /dev/null @@ -1,28 +0,0 @@ - -Libpng 1.0.10 - March 30, 2001 - -This is a public release of libpng, intended for use in production codes. - -Changes since the last public release (1.0.9): - - Revised makefile.dec - Reformatted libpng.3 to eliminate bad line breaks. - Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c - Added prototype for png_mmx_support() near the top of pnggccrd.c - Moved some error checking from png_handle_IHDR to png_set_IHDR. - Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros. - Revised png_mmx_support() function in pnggccrd.c - Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c - Fixed memory leak in contrib/visupng/PngFile.c - Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version) - Added warnings when retrieving or setting gamma=0. - Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy, - and png_strlen. - Fixed bug in progressive reading (pngpread.c) with small images (height < 8). - Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin - Added beos project files (Chris Herborth) - -Send comments/corrections/commendations to -png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu - -Glenn R-P diff --git a/freeimage241/Source/LibPNG/CHANGES b/freeimage241/Source/LibPNG/CHANGES deleted file mode 100644 index 0915330..0000000 --- a/freeimage241/Source/LibPNG/CHANGES +++ /dev/null @@ -1,960 +0,0 @@ -CHANGES - changes for libpng - -version 0.2 - added reader into png.h - fixed small problems in stub file -version 0.3 - added pull reader - split up pngwrite.c to several files - added pnglib.txt - added example.c - cleaned up writer, adding a few new tranformations - fixed some bugs in writer - interfaced with zlib 0.5 - added K&R support - added check for 64 KB blocks for 16 bit machines -version 0.4 - cleaned up code and commented code - simplified time handling into png_time - created png_color_16 and png_color_8 to handle color needs - cleaned up color type defines - fixed various bugs - made various names more consistant - interfaced with zlib 0.71 - cleaned up zTXt reader and writer (using zlib's Reset functions) - split transformations into pngrtran.c and pngwtran.c -version 0.5 - interfaced with zlib 0.8 - fixed many reading and writing bugs - saved using 3 spaces instead of tabs -version 0.6 - added png_large_malloc() and png_large_free() - added png_size_t - cleaned up some compiler warnings - added png_start_read_image() -version 0.7 - cleaned up lots of bugs - finished dithering and other stuff - added test program - changed name from pnglib to libpng -version 0.71 [June, 1995] - changed pngtest.png for zlib 0.93 - fixed error in libpng.txt and example.c -version 0.8 - cleaned up some bugs - added png_set_filler() - split up pngstub.c into pngmem.c, pngio.c, and pngerror.c - added #define's to remove unwanted code - moved png_info_init() to png.c - added old_size into png_realloc() - added functions to manually set filtering and compression info - changed compression parameters based on image type - optimized filter selection code - added version info - changed external functions passing floats to doubles (k&r problems?) - put all the configurable stuff in pngconf.h - enabled png_set_shift to work with paletted images on read - added png_read_update_info() - updates info structure with - transformations -version 0.81 [August, 1995] - incorporated Tim Wegner's medium model code (thanks, Tim) -version 0.82 [September, 1995] - [unspecified changes] -version 0.85 [December, 1995] - added more medium model code (almost everything's a far) - added i/o, error, and memory callback functions - fixed some bugs (16 bit, 4 bit interlaced, etc.) - added first run progressive reader (barely tested) -version 0.86 [January, 1996] - fixed bugs - improved documentation -version 0.87 [January, 1996] - fixed medium model bugs - fixed other bugs introduced in 0.85 and 0.86 - added some minor documentation -version 0.88 [January, 1996] - fixed progressive bugs - replaced tabs with spaces - cleaned up documentation - added callbacks for read/write and warning/error functions -version 0.89 [July, 1996] - added new initialization API to make libpng work better with shared libs - we now have png_create_read_struct(), png_create_write_struct(), - png_create_info_struct(), png_destroy_read_struct(), and - png_destroy_write_struct() instead of the separate calls to - malloc and png_read_init(), png_info_init(), and png_write_init() - changed warning/error callback functions to fix bug - this means you - should use the new initialization API if you were using the old - png_set_message_fn() calls, and that the old API no longer exists - so that people are aware that they need to change their code - changed filter selection API to allow selection of multiple filters - since it didn't work in previous versions of libpng anyways - optimized filter selection code - fixed png_set_background() to allow using an arbitrary RGB color for - paletted images - fixed gamma and background correction for paletted images, so - png_correct_palette is not needed unless you are correcting an - external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED - in pngconf.h) - if nobody uses this, it may disappear in the future. - fixed bug with Borland 64K memory allocation (Alexander Lehmann) - fixed bug in interlace handling (Smarasderagd, I think) - added more error checking for writing and image to reduce invalid files - separated read and write functions so that they won't both be linked - into a binary when only reading or writing functionality is used - new pngtest image also has interlacing and zTXt - updated documentation to reflect new API -version 0.90 [January, 1997] - made CRC errors/warnings on critical and ancillary chunks configurable - libpng will use the zlib CRC routines by (compile-time) default - changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner) - added external C++ wrapper statements to png.h (Gilles Dauphin) - allow PNG file to be read when some or all of file signature has already - been read from the beginning of the stream. ****This affects the size - of info_struct and invalidates all programs that use a shared libpng**** - fixed png_filler() declarations - fixed? background color conversions - fixed order of error function pointers to match documentation - current chunk name is now available in png_struct to reduce the number - of nearly identical error messages (will simplify multi-lingual - support when available) - try to get ready for unknown-chunk callback functions: - - previously read critical chunks are flagged, so the chunk handling - routines can determine if the chunk is in the right place - - all chunk handling routines have the same prototypes, so we will - be able to handle all chunks via a callback mechanism - try to fix Linux "setjmp" buffer size problems - removed png_large_malloc, png_large_free, and png_realloc functions. -version 0.95 [March, 1997] - fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never - fixed bug in PNG file signature compares when start != 0 - changed parameter type of png_set_filler(...filler...) from png_byte - to png_uint_32 - added test for MACOS to ensure that both math.h and fp.h are not #included - added macros for libpng to be compiled as a Windows DLL (Andreas Kupries) - added "packswap" transformation, which changes the endianness of - packed-pixel bytes (Kevin Bracey) - added "strip_alpha" transformation, which removes the alpha channel of - input images without using it (not neccesarily a good idea) - added "swap_alpha" transformation, which puts the alpha channel in front - of the color bytes instead of after - removed all implicit variable tests which assume NULL == 0 (I think) - changed several variables to "png_size_t" to show 16/32-bit limitations - added new pCAL chunk read/write support - added experimental filter selection weighting (Greg Roelofs) - removed old png_set_rgbx() and png_set_xrgb() functions that have been - obsolete for about 2 years now (use png_set_filler() instead) - added macros to read 16- and 32-bit ints directly from buffer, to be - used only on those systems that support it (namely PowerPC and 680x0) - With some testing, this may become the default for MACOS/PPC systems. - only calculate CRC on data if we are going to use it - added macros for zTXt compression type PNG_zTXt_COMPRESSION_??? - added macros for simple libpng debugging output selectable at compile time - removed PNG_READ_END_MODE in progressive reader (Smarasderagd) - more description of info_struct in libpng.txt and png.h - more instructions in example.c - more chunk types tested in pngtest.c - renamed pngrcb.c to pngset.c, and all png_read_ functions to be - png_set_. We now have corresponding png_get_ - functions in pngget.c to get infomation in info_ptr. This isolates - the application from the internal organization of png_info_struct - (good for shared library implementations). -version 0.96 [May, 1997] - fixed serious bug with < 8bpp images introduced in 0.95 - fixed 256-color transparency bug (Greg Roelofs) - fixed up documentation (Greg Roelofs, Laszlo Nyul) - fixed "error" in pngconf.h for Linux setjmp() behaviour - fixed DOS medium model support (Tim Wegner) - fixed png_check_keyword() for case with error in static string text - added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul) - added typecasts to quiet compiler errors - added more debugging info -version 0.97 [January, 1998] - removed PNG_USE_OWN_CRC capability - relocated png_set_crc_action from pngrutil.c to pngrtran.c - fixed typecasts of "new_key", etc. (Andreas Dilger) - added RFC 1152 [sic] date support - fixed bug in gamma handling of 4-bit grayscale - added 2-bit grayscale gamma handling (Glenn R-P) - added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P) - minor corrections in libpng.txt - added simple sRGB support (Glenn R-P) - easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; - all configurable options can be selected from command-line instead - of having to edit pngconf.h (Glenn R-P) - fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) - added more conditions for png_do_background, to avoid changing - black pixels to background when a background is supplied and - no pixels are transparent - repaired PNG_NO_STDIO behaviour - tested NODIV support and made it default behaviour (Greg Roelofs) - added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler) - regularized version numbering scheme and bumped shared-library major - version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs) -version 0.98 [January, 1998] - cleaned up some typos in libpng.txt and in code documentation - fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler) - cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c - changed recommendation about file_gamma for PC images to .51 from .45, - in example.c and libpng.txt, added comments to distinguish between - screen_gamma, viewing_gamma, and display_gamma. - changed all references to RFC1152 to read RFC1123 and changed the - PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED - added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent) - changed srgb_intent from png_byte to int to avoid compiler bugs -version 0.99 [January 30, 1998] - free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler) - fixed a longstanding "packswap" bug in pngtrans.c - fixed some inconsistencies in pngconf.h that prevented compiling with - PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined - fixed some typos and made other minor rearrangement of libpng.txt (Andreas) - changed recommendation about file_gamma for PC images to .50 from .51 in - example.c and libpng.txt, and changed file_gamma for sRGB images to .45 - added a number of functions to access information from the png structure - png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit) - added TARGET_MACOS similar to zlib-1.0.8 - define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined - added type casting to all png_malloc() function calls -version 0.99a [January 31, 1998] - Added type casts and parentheses to all returns that return a value.(Tim W.) -version 0.99b [February 4, 1998] - Added type cast png_uint_32 on malloc function calls where needed. - Changed type of num_hist from png_uint_32 to int (same as num_palette). - Added checks for rowbytes overflow, in case png_size_t is less than 32 bits. - Renamed makefile.elf to makefile.lnx. -version 0.99c [February 7, 1998] - More type casting. Removed erroneous overflow test in pngmem.c. - Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes. - Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5. -version 0.99d [February 11, 1998] - Renamed "far_to_near()" "png_far_to_near()" - Revised libpng.3 - Version 99c "buffered" operations didn't work as intended. Replaced them - with png_memcpy_check() and png_memset_check(). - Added many "if (png_ptr == NULL) return" to quell compiler warnings about - unused png_ptr, mostly in pngget.c and pngset.c. - Check for overlength tRNS chunk present when indexed-color PLTE is read. - Cleaned up spelling errors in libpng.3/libpng.txt - Corrected a problem with png_get_tRNS() which returned undefined trans array -version 0.99e [February 28, 1998] - Corrected png_get_tRNS() again. - Add parentheses for easier reading of pngget.c, fixed "||" should be "&&". - Touched up example.c to make more of it compileable, although the entire - file still can't be compiled (Willem van Schaik) - Fixed a bug in png_do_shift() (Bryan Tsai) - Added a space in png.h prototype for png_write_chunk_start() - Replaced pngtest.png with one created with zlib 1.1.1 - Changed pngtest to report PASS even when file size is different (Jean-loup G.) - Corrected some logic errors in png_do_invert_alpha() (Chris Patterson) -version 0.99f [March 5, 1998] - Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey) - Moved makefiles into a "scripts" directory, and added INSTALL instruction file - Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok) - Added pointers to "note on libpng versions" in makefile.lnx and README - Added row callback feature when reading and writing nonprogressive rows - and added a test of this feature in pngtest.c - Added user transform callbacks, with test of the feature in pngtest.c -version 0.99g [March 6, 1998, morning] - Minor changes to pngtest.c to suppress compiler warnings. - Removed "beta" language from documentation. -version 0.99h [March 6, 1998, evening] - Minor changes to previous minor changes to pngtest.c - Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED - and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro - Added user transform capability -version 1.00 [March 7, 1998] - Changed several typedefs in pngrutil.c - Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik) - replaced "while(1)" with "for(;;)" - added PNGARG() to prototypes in pngtest.c and removed some prototypes - updated some of the makefiles (Tom Lane) - changed some typedefs (s_start, etc.) in pngrutil.c - fixed dimensions of "short_months" array in pngwrite.c - Replaced ansi2knr.c with the one from jpeg-v6 -version 1.0.0 [March 8, 1998] - Changed name from 1.00 to 1.0.0 (Adam Costello) - Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert) -version 1.0.0a [March 9, 1998] - Fixed three bugs in pngrtran.c to make gamma+background handling consistent - (Greg Roelofs) - Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz - for major, minor, and bugfix releases. This is 10001. (Adam Costello, - Tom Lane) - Make months range from 1-12 in png_convert_to_rfc1123 -version 1.0.0b [March 13, 1998] - Quieted compiler complaints about two empty "for" loops in pngrutil.c - Minor changes to makefile.s2x - Removed #ifdef/#endif around a png_free() in pngread.c -version 1.0.1 [March 14, 1998] - Changed makefile.s2x to reduce security risk of using a relative pathname - Fixed some typos in the documentation (Greg). - Fixed a problem with value of "channels" returned by png_read_update_info() -version 1.0.1a [April 21, 1998] - Optimized Paeth calculations by replacing abs() function calls with intrinsics - plus other loop optimizations. Improves avg decoding speed by about 20%. - Commented out i386istic "align" compiler flags in makefile.lnx. - Reduced the default warning level in some makefiles, to make them consistent. - Removed references to IJG and JPEG in the ansi2knr.c copyright statement. - Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation. - Added grayscale and 16-bit capability to png_do_read_filler(). - Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes - too large when writing an image with bit_depth < 8 (Bob Dellaca). - Corrected some bugs in the experimental weighted filtering heuristics. - Moved a misplaced pngrutil code block that truncates tRNS if it has more - than num_palette entries -- test was done before num_palette was defined. - Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins). - Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen). -version 1.0.1b [May 2, 1998] - Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg). - Relocated the png_composite macros from pngrtran.c to png.h (Greg). - Added makefile.sco (contributed by Mike Hopkirk). - Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a. - Fixed a bug in pngrtran.c that would set channels=5 under some circumstances. - More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert). - More work on loop optimization which may help when compiled with C++ compilers. - Added warnings when people try to use transforms they've defined out. - Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran. - Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg) -version 1.0.1c [May 11, 1998] - Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for - filler bytes should have been 0xff instead of 0xf. - Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images. - Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED - out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h - Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED, - for consistency, in pngconf.h - Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier - to remove unwanted capabilities via the compile line - Made some corrections to grammar (which, it's) in documentation (Greg). - Corrected example.c, use of row_pointers in png_write_image(). -version 1.0.1d [May 24, 1998] - Corrected several statements that used side effects illegally in pngrutil.c - and pngtrans.c, that were introduced in version 1.0.1b - Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert) - More corrections to example.c, use of row_pointers in png_write_image() - and png_read_rows(). - Added pngdll.mak and pngdef.pas to scripts directory, contributed by - Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5 - Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.) - Changed several loops from count-down to count-up, for consistency. -version 1.0.1e [June 6, 1998] - Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and - added warnings when people try to set png_read_fn and png_write_fn in - the same structure. - Added a test such that png_do_gamma will be done when num_trans==0 - for truecolor images that have defined a background. This corrects an - error that was introduced in libpng-0.90 that can cause gamma processing - to be skipped. - Added tests in png.h to include "trans" and "trans_values" in structures - when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined. - Add png_free(png_ptr->time_buffer) in png_destroy_read_struct() - Moved png_convert_to_rfc_1123() from pngwrite.c to png.c - Added capability for user-provided malloc_fn() and free_fn() functions, - and revised pngtest.c to demonstrate their use, replacing the - PNGTEST_DEBUG_MEM feature. - Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner). -version 1.0.2 [June 14, 1998] - Fixed two bugs in makefile.bor . -version 1.0.2a [December 30, 1998] - Replaced and extended code that was removed from png_set_filler() in 1.0.1a. - Fixed a bug in png_do_filler() that made it fail to write filler bytes in - the left-most pixel of each row (Kevin Bracey). - Changed "static pngcharp tIME_string" to "static char tIME_string[30]" - in pngtest.c (Duncan Simpson). - Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk - even when no tIME chunk was present in the source file. - Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit. - Fixed a problem in png_read_push_finish_row(), which would not skip some - passes that it should skip, for images that are less than 3 pixels high. - Interchanged the order of calls to png_do_swap() and png_do_shift() - in pngwtran.c (John Cromer). - Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h . - Changed "bad adaptive filter type" from error to warning in pngrutil.c . - Fixed a documentation error about default filtering with 8-bit indexed-color. - Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO - (L. Peter Deutsch). - Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions. - Added png_get_copyright() and png_get_header_version() functions. - Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c - Added information about debugging in libpng.txt and libpng.3 . - Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco. - Removed lines after Dynamic Dependencies" in makefile.aco . - Revised makefile.dec to make a shared library (Jeremie Petit). - Removed trailing blanks from all files. -version 1.0.2a [January 6, 1999] - Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h - Added "if" tests to silence complaints about unused png_ptr in png.h and png.c - Changed "check_if_png" function in example.c to return true (nonzero) if PNG. - Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig() - which is obsolete. -version 1.0.3 [January 14, 1999] - Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice) - Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO. -version 1.0.3a [August 12, 1999] - Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning - if an attempt is made to read an interlaced image when it's not supported. - Added check if png_ptr->trans is defined before freeing it in pngread.c - Modified the Y2K statement to include versions back to version 0.71 - Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c - Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments) - Replaced leading blanks with tab characters in makefile.hux - Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents. - Changed (float)red and (float)green to (double)red, (double)green - in png_set_rgb_to_gray() to avoid "promotion" problems in AIX. - Fixed a bug in pngconf.h that omitted when PNG_DEBUG==0 (K Bracey). - Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt). - Updated documentation to refer to the PNG-1.2 specification. - Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c - in makefile.knr, INSTALL, and README (L. Peter Deutsch) - Fixed bugs in calculation of the length of rowbytes when adding alpha - channels to 16-bit images, in pngrtran.c (Chris Nokleberg) - Added function png_set_user_transform_info() to store user_transform_ptr, - user_depth, and user_channels into the png_struct, and a function - png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg) - Added function png_set_empty_plte_permitted() to make libpng useable - in MNG applications. - Corrected the typedef for png_free_ptr in png.h (Jesse Jones). - Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be - consistent with PNG-1.2, and allow variance of 500 before complaining. - Added assembler code contributed by Intel in file pngvcrd.c and modified - makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant) - Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy. - Added some aliases for png_set_expand() in pngrtran.c, namely - png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS() - (Greg Roelofs, in "PNG: The Definitive Guide"). - Added makefile.beo for BEOS on X86, contributed by Sander Stok. -version 1.0.3b [August 26, 1999] - Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h - Changed leading blanks to tabs in all makefiles. - Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code. - Made alternate versions of png_set_expand() in pngrtran.c, namely - png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha - (Greg Roelofs, in "PNG: The Definitive Guide"). Deleted the 1.0.3a aliases. - Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h - Revised calculation of num_blocks in pngmem.c to avoid a potentially - negative shift distance, whose results are undefined in the C language. - Added a check in pngset.c to prevent writing multiple tIME chunks. - Added a check in pngwrite.c to detect invalid small window_bits sizes. -version 1.0.3d [September 4, 1999] - Fixed type casting of igamma in pngrutil.c - Added new png_expand functions to scripts/pngdef.pas and pngos2.def - Added a demo read_user_transform_fn that examines the row filters in pngtest.c -version 1.0.4 [September 24, 1999] - Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined - Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h - Made several minor corrections to pngtest.c - Renamed the makefiles with longer but more user friendly extensions. - Copied the PNG copyright and license to a separate LICENSE file. - Revised documentation, png.h, and example.c to remove reference to - "viewing_gamma" which no longer appears in the PNG specification. - Revised pngvcrd.c to use MMX code for interlacing only on the final pass. - Updated pngvcrd.c to use the faster C filter algorithms from libpng-1.0.1a - Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX - assembler code) and makefile.vcwin32 (doesn't). - Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING) - Added a copy of pngnow.png to the distribution. -version 1.0.4a [September 25, 1999] - Increase max_pixel_depth in pngrutil.c if a user transform needs it. - Changed several division operations to right-shifts in pngvcrd.c -version 1.0.4b [September 30, 1999] - Added parentheses in line 3732 of pngvcrd.c - Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1 -version 1.0.4c [October 1, 1999] - Added a "png_check_version" function in png.c and pngtest.c that will generate - a helpful compiler error if an old png.h is found in the search path. - Changed type of png_user_transform_depth|channels from int to png_byte. -version 1.0.4d [October 6, 1999] - Changed 0.45 to 0.45455 in png_set_sRGB() - Removed unused PLTE entries from pngnow.png - Re-enabled some parts of pngvcrd.c (png_combine_row) that work properly. -version 1.0.4e [October 10, 1999] - Fixed sign error in pngvcrd.c (Greg Roelofs) - Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P) -version 1.0.4f [October 15, 1999] - Surrounded example.c code with #if 0 .. #endif to prevent people from - inadvertently trying to compile it. - Changed png_get_header_version() from a function to a macro in png.h - Added type casting mostly in pngrtran.c and pngwtran.c - Removed some pointless "ptr = NULL" in pngmem.c - Added a "contrib" directory containing the source code from Greg's book. -version 1.0.5 [October 15, 1999] - Minor editing of the INSTALL and README files. -version 1.0.5a [October 23, 1999] - Added contrib/pngsuite and contrib/pngminus (Willem van Schaik) - Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans) - Further optimization and bugfix of pngvcrd.c - Revised pngset.c so that it does not allocate or free memory in the user's - text_ptr structure. Instead, it makes its own copy. - Created separate write_end_info_struct in pngtest.c for a more severe test. - Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak. -version 1.0.5b [November 23, 1999] - Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and - PNG_FLAG_WROTE_tIME from flags to mode. - Added png_write_info_before_PLTE() function. - Fixed some typecasting in contrib/gregbook/*.c - Updated scripts/makevms.com and added makevms.com to contrib/gregbook - and contrib/pngminus (Martin Zinser) -version 1.0.5c [November 26, 1999] - Moved png_get_header_version from png.h to png.c, to accomodate ansi2knr. - Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to - accomodate making DLL's: Moved usr_png_ver from global variable to function - png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and - eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays - into pngtypes.h. Eliminated use of global png_pass arrays. Declared the - png_CHNK and png_pass arrays to be "const". Made the global arrays - available to applications (although none are used in libpng itself) when - PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined. - Removed some extraneous "-I" from contrib/pngminus/makefile.std - Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2. - Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3 -version 1.0.5d [November 29, 1999] - Add type cast (png_const_charp) two places in png.c - Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays. - Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available - to applications a macro "PNG_USE_LOCAL_ARRAYS". - #ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined. - Added PNG_EXPORT_VAR macro to accommodate making DLL's. -version 1.0.5e [November 30, 1999] - Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text - structure; refactored the inflate/deflate support to make adding new chunks - with trailing compressed parts easier in the future, and added new functions - png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP, - png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond). - NOTE: Applications that write text chunks MUST define png_text->lang - before calling png_set_text(). It must be set to NULL if you want to - write tEXt or zTXt chunks. If you want your application to be able to - run with older versions of libpng, use - - #ifdef PNG_iTXt_SUPPORTED - png_text[i].lang = NULL; - #endif - - Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned - offsets (Eric S. Raymond). - Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into - PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED - macros, leaving the separate macros also available. - Removed comments on #endifs at the end of many short, non-nested #if-blocks. -version 1.0.5f [December 6, 1999] - Changed makefile.solaris to issue a warning about potential problems when - the ucb "ld" is in the path ahead of the ccs "ld". - Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3. - Added sCAL chunk support (Eric S. Raymond). -version 1.0.5g [December 7, 1999] - Fixed "png_free_spallettes" typo in png.h - Added code to handle new chunks in pngpread.c - Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block - Added "translated_key" to png_text structure and png_write_iTXt(). - Added code in pngwrite.c to work around a newly discovered zlib bug. -version 1.0.5h [December 10, 1999] - NOTE: regarding the note for version 1.0.5e, the following must also - be included in your code: - png_text[i].translated_key = NULL; - Unknown chunk handling is now supported. - Option to eliminate all floating point support was added. Some new - fixed-point functions such as png_set_gAMA_fixed() were added. - Expanded tabs and removed trailing blanks in source files. -version 1.0.5i [December 13, 1999] - Added some type casts to silence compiler warnings. - Renamed "png_free_spalette" to "png_free_spalettes" for consistency. - Removed leading blanks from a #define in pngvcrd.c - Added some parameters to the new png_set_keep_unknown_chunks() function. - Added a test for up->location != 0 in the first instance of writing - unknown chunks in pngwrite.c - Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to - prevent recursion. - Added png_free_hIST() function. - Various patches to fix bugs in the sCAL and integer cHRM processing, - and to add some convenience macros for use with sCAL. -version 1.0.5j [December 21, 1999] - Changed "unit" parameter of png_write_sCAL from png_byte to int, to work - around buggy compilers. - Added new type "png_fixed_point" for integers that hold float*100000 values - Restored backward compatibility of tEXt/zTXt chunk processing: - Restored the first four members of png_text to the same order as v.1.0.5d. - Added members "lang_key" and "itxt_length" to png_text struct. Set - text_length=0 when "text" contains iTXt data. Use the "compression" - member to distinguish among tEXt/zTXt/iTXt types. Added - PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros. - The "Note" above, about backward incompatibility of libpng-1.0.5e, no - longer applies. - Fixed png_read|write_iTXt() to read|write parameters in the right order, - and to write the iTXt chunk after IDAT if it appears in the end_ptr. - Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs) - Reversed the order of trying to write floating-point and fixed-point gAMA. -version 1.0.5k [December 27, 1999] - Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))" - Added png_handle_as_unknown() function (Glenn) - Added png_free_chunk_list() function and chunk_list and num_chunk_list members - of png_ptr. - Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE. - Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings - about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored) - Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR). - Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is. - Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP(). -version 1.0.5l [January 1, 2000] - Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr() - for setting a callback function to handle unknown chunks and for - retrieving the associated user pointer (Glenn). -version 1.0.5m [January 7, 2000] - Added high-level functions png_read_png(), png_write_png(), png_free_pixels(). -version 1.0.5n [January 9, 2000] - Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its - own memory for info_ptr->palette. This makes it safe for the calling - application to free its copy of the palette any time after it calls - png_set_PLTE(). -version 1.0.5o [January 20, 2000] - Cosmetic changes only (removed some trailing blanks and TABs) -version 1.0.5p [January 31, 2000] - Renamed pngdll.mak to makefile.bd32 - Cosmetic changes in pngtest.c -version 1.0.5q [February 5, 2000] - Relocated the makefile.solaris warning about PATH problems. - Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg) - Revised makefile.gcmmx - Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros -version 1.0.5r [February 7, 2000] - Removed superfluous prototype for png_get_itxt from png.h - Fixed a bug in pngrtran.c that improperly expanded the background color. - Return *num_text=0 from png_get_text() when appropriate, and fix documentation - of png_get_text() in libpng.txt/libpng.3. -version 1.0.5s [February 18, 2000] - Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the - new error handler that's planned for the next libpng release, and changed - example.c, pngtest.c, and contrib programs to use this macro. - Revised some of the DLL-export macros in pngconf.h (Greg Roelofs) - Fixed a bug in png_read_png() that caused it to fail to expand some images - that it should have expanded. - Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions - in pngget.c - Changed the allocation of palette, history, and trans arrays back to - the version 1.0.5 method (linking instead of copying) which restores - backward compatibility with version 1.0.5. Added some remarks about - that in example.c. Added "free_me" member to info_ptr and png_ptr - and added png_free_data() function. - Updated makefile.linux and makefile.gccmmx to make directories conditionally. - Made cosmetic changes to pngasmrd.h - Added png_set_rows() and png_get_rows(), for use with png_read|write_png(). - Modified png_read_png() to allocate info_ptr->row_pointers only if it - hasn't already been allocated. -version 1.0.5t [March 4, 2000] - Changed png_jmp_env() migration aiding macro to png_jmpbuf(). - Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c - Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when - PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b - Files in contrib/gregbook were revised to use png_jmpbuf() and to select - a 24-bit visual if one is available, and to allow abbreviated options. - Files in contrib/pngminus were revised to use the png_jmpbuf() macro. - Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s -version 1.0.5u [March 5, 2000] - Simplified the code that detects old png.h in png.c and pngtest.c - Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp) - Increased precision of rgb_to_gray calculations from 8 to 15 bits and - added png_set_rgb_to_gray_fixed() function. - Added makefile.bc32 (32-bit Borland C++, C mode) -version 1.0.5v [March 11, 2000] - Added some parentheses to the png_jmpbuf macro definition. - Updated references to the zlib home page, which has moved to freesoftware.com. - Corrected bugs in documentation regarding png_read_row() and png_write_row(). - Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt. - Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3, - revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin) -version 1.0.6 [March 20, 2000] - Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c - Added makefile.sggcc (SGI IRIX with gcc) -version 1.0.6d [April 7, 2000] - Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO - Added data_length parameter to png_decompress_chunk() function - Revised documentation to remove reference to abandoned png_free_chnk functions - Fixed an error in png_rgb_to_gray_fixed() - Revised example.c, usage of png_destroy_write_struct(). - Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file - Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c - Simplify png_sig_bytes() function to remove use of non-ISO-C strdup(). -version 1.0.6e [April 9, 2000] - Added png_data_freer() function. - In the code that checks for over-length tRNS chunks, added check of - info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann) - Minor revisions of libpng.txt/libpng.3. - Check for existing data and free it if the free_me flag is set, in png_set_*() - and png_handle_*(). - Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED - is defined. - Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c - and mentioned the purposes of the two macros in libpng.txt/libpng.3. -version 1.0.6f [April 14, 2000] - Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data. - Add checks in png_set_text() for NULL members of the input text structure. - Revised libpng.txt/libpng.3. - Removed superfluous prototype for png_set_itxt from png.h - Removed "else" from pngread.c, after png_error(), and changed "0" to "length". - Changed several png_errors about malformed ancillary chunks to png_warnings. -version 1.0.6g [April 24, 2000] - Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined. - Relocated paragraph about png_set_background() in libpng.3/libpng.txt - and other revisions (Matthias Benckmann) - Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and - png_ptr members to restore binary compatibility with libpng-1.0.5 - (breaks compatibility with libpng-1.0.6). -version 1.0.6h [April 24, 2000] - Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds - libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h) - This is a temporary change for test purposes. -version 1.0.6i [May 2, 2000] - Rearranged some members at the end of png_info and png_struct, to put - unknown_chunks_num and free_me within the original size of the png_structs - and free_me, png_read_user_fn, and png_free_fn within the original png_info, - because some old applications allocate the structs directly instead of - using png_create_*(). - Added documentation of user memory functions in libpng.txt/libpng.3 - Modified png_read_png so that it will use user_allocated row_pointers - if present, unless free_me directs that it be freed, and added description - of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3. - Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version - 1.00) members of png_struct and png_info, to regain binary compatibility - when you define this macro. Capabilities lost in this event - are user transforms (new in version 1.0.0),the user transform pointer - (new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT, - the high-level interface, and unknown chunks support (all new in 1.0.6). - This was necessary because of old applications that allocate the structs - directly as authors were instructed to do in libpng-0.88 and earlier, - instead of using png_create_*(). - Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which - can be used to detect codes that directly allocate the structs, and - code to check these modes in png_read_init() and png_write_init() and - generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED - was not defined. - Added makefile.intel and updated makefile.watcom (Pawel Mrochen) -version 1.0.6j [May 3, 2000] - Overloaded png_read_init() and png_write_init() with macros that convert - calls to png_read_init_2() or png_write_init_2() that check the version - and structure sizes. -version 1.0.7beta11 [May 7, 2000] - Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes - which are no longer used. - Eliminated the three new members of png_text when PNG_NO_iTXt_SUPPORTED - or PNG_LEGACY_SUPPORTED is defined. - Made PNG_NO_ITXT_SUPPORTED the default setting, to avoid memory overrun - when old applications fill the info_ptr->text structure directly. - Added PNGAPI macro, and added it to the definitions of all exported functions. - Relocated version macro definitions ahead of the includes of zlib.h and - pngconf.h in png.h. -version 1.0.7beta12 [May 12, 2000] - Revised pngset.c to avoid a problem with expanding the png_debug macro. - Deleted some extraneous defines from pngconf.h - Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined. - Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined. - Added png_access_version_number() function. - Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data(). - Expanded libpng.3/libpng.txt information about png_data_freer(). -version 1.0.7beta14 [May 17, 2000] (beta13 was not published) - Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as - warnings instead of errors, as pngrutil.c does. - Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png() - will actually write IDATs. - Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32. - Make png_free_data() ignore its final parameter except when freeing data - that can have multiple instances (text, sPLT, unknowns). - Fixed a new bug in png_set_rows(). - Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5. - Added png_set_invalid() function. - Fixed incorrect illustrations of png_destroy_write_struct() in example.c. -version 1.0.7beta15 [May 30, 2000] - Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce - fewer error messages. - Rearranged checks for Z_OK to check the most likely path first in pngpread.c - and pngwutil.c. - Added checks in pngtest.c for png_create_*() returning NULL, and mentioned - in libpng.txt/libpng.3 the need for applications to check this. - Changed names of png_default_*() functions in pngtest to pngtest_*(). - Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32. - Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c - Set each pointer to NULL after freeing it in png_free_data(). - Worked around a problem in pngconf.h; AIX's strings.h defines an "index" - macro that conflicts with libpng's png_color_16.index. (Dimitri Papadapoulos) - Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux). -version 1.0.7beta16 [June 4, 2000] - Revised the workaround of AIX string.h "index" bug. - Added a check for overlength PLTE chunk in pngrutil.c. - Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer - indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler. - Added a warning in png_decompress_chunk() when it runs out of data, e.g. - when it tries to read an erroneous PhotoShop iCCP chunk. - Added PNG_USE_DLL macro. - Revised the copyright/disclaimer/license notice. - Added contrib/msvctest directory -version 1.0.7rc1 [June 9, 2000] - Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200) - Added contrib/visupng directory (Willem van Schaik) -version 1.0.7beta18 [June 23, 2000] - Revised PNGAPI definition, and pngvcrd.c to work with __GCC__ - and do not redefine PNGAPI if it is passed in via a compiler directive. - Revised visupng/PngFile.c to remove returns from within the Try block. - Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros. - Updated contrib/visupng/cexcept.h to version 1.0.0. - Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks. -version 1.0.7rc2 [June 28, 2000] - Updated license to include disclaimers required by UCITA. - Fixed "DJBPP" typo in pnggccrd.c introduced in beta18. -version 1.0.7 [July 1, 2000] - Revised the definition of "trans_values" in libpng.3/libpng.txt -version 1.0.8beta1 [July 8, 2000] - Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks. - Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and - pngwutil.c. - Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h. - Removed unused "#include " from png.c - Added WindowsCE support. - Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment. -version 1.0.8beta2 [July 10, 2000] - Added project files to the wince directory and made further revisions - of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE. -version 1.0.8beta3 [July 11, 2000] - Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS() - for indexed-color input files to avoid potential double-freeing trans array - under some unusual conditions; problem was introduced in version 1.0.6f. - Further revisions to pngtest.c and files in the wince subdirectory. -version 1.0.8beta4 [July 14, 2000] - Added the files pngbar.png and pngbar.jpg to the distribution. - Added makefile.cygwin, and cygwin support in pngconf.h - Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory) -version 1.0.8rc1 [July 16, 2000] - Revised png_debug() macros and statements to eliminate compiler warnings. -version 1.0.8 [July 24, 2000] - Added png_flush() in pngwrite.c, after png_write_IEND(). - Updated makefile.hpux to build a shared library. -version 1.0.9beta1 [November 10, 2000] - Fixed typo in scripts/makefile.hpux - Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) - Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) - Changed "cdrom.com" in documentation to "libpng.org" - Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg). - Changed type of "params" from voidp to png_voidp in png_read|write_png(). - Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h. - Revised the 3 instances of WRITEFILE in pngtest.c. - Relocated "msvc" and "wince" project subdirectories into "dll" subdirectory. - Updated png.rc in dll/msvc project - Revised makefile.dec to define and use LIBPATH and INCPATH - Increased size of global png_libpng_ver[] array from 12 to 18 chars. - Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const. - Removed duplicate png_crc_finish() from png_handle_bKGD() function. - Added a warning when application calls png_read_update_info() multiple times. - Revised makefile.cygwin - Fixed bugs in iCCP support in pngrutil.c and pngwutil.c. - Replaced png_set_empty_plte_permitted() with png_permit_mng_features(). -version 1.0.9beta2 [November 19, 2000] - Renamed the "dll" subdirectory "projects". - Added borland project files to "projects" subdirectory. - Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate. - Add error message in png_set_compression_buffer_size() when malloc fails. -version 1.0.9beta3 [November 23, 2000] - Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project. - Removed the png_flush() in pngwrite.c that crashes some applications - that don't set png_output_flush_fn. - Added makefile.macosx and makefile.aix to scripts directory. -version 1.0.9beta4 [December 1, 2000] - Change png_chunk_warning to png_warning in png_check_keyword(). - Increased the first part of msg buffer from 16 to 18 in png_chunk_error(). -version 1.0.9beta5 [December 15, 2000] - Added support for filter method 64 (for PNG datastreams embedded in MNG). -version 1.0.9beta6 [December 18, 2000] - Revised png_set_filter() to accept filter method 64 when appropriate. - Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to - help prevent applications from using MNG features in PNG datastreams. - Added png_permit_mng_features() function. - Revised libpng.3/libpng.txt. Changed "filter type" to "filter method". -version 1.0.9rc1 [December 23, 2000] - Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c - Fixed error handling of unknown compression type in png_decompress_chunk(). - In pngconf.h, define __cdecl when _MSC_VER is defined. -version 1.0.9beta7 [December 28, 2000] - Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places. - Revised memory management in png_set_hIST and png_handle_hIST in a backward - compatible manner. PLTE and tRNS were revised similarly. - Revised the iCCP chunk reader to ignore trailing garbage. -version 1.0.9beta8 [January 12, 2001] - Moved pngasmrd.h into pngconf.h. - Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop. -version 1.0.9beta9 [January 15, 2001] - Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to - wince and msvc project module definition files. - Minor revision of makefile.cygwin. - Fixed bug with progressive reading of narrow interlaced images in pngpread.c -version 1.0.9beta10 [January 16, 2001] - Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined. - Fixed "png_mmx_supported" typo in project definition files. -version 1.0.9beta11 [January 19, 2001] - Updated makefile.sgi to make shared library. - Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED - by default, for the benefit of DLL forward compatibility. These will - be re-enabled in version 1.2.0. -version 1.0.9rc2 [January 22, 2001] - Revised cygwin support. -version 1.0.9 [January 31, 2001] - Added check of cygwin's ALL_STATIC in pngconf.h - Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos. -version 1.0.10beta1 [March 14, 2001] - Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc. - Reformatted libpng.3 to eliminate bad line breaks. - Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c - Added prototype for png_mmx_support() near the top of pnggccrd.c - Moved some error checking from png_handle_IHDR to png_set_IHDR. - Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros. - Revised png_mmx_support() function in pnggccrd.c - Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c - Fixed memory leak in contrib/visupng/PngFile.c - Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version) - Added warnings when retrieving or setting gamma=0. - Increased the first part of msg buffer from 16 to 18 in png_chunk_warning(). -version 1.0.10rc1 [March 23, 2001] - Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy, - and png_strlen. - Revised png_mmx_supported() function in pnggccrd.c to return proper value. - Fixed bug in progressive reading (pngpread.c) with small images (height < 8). -version 1.0.10 [March 30, 2001] - Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin - Added beos project files (Chris Herborth) -version 1.0.11beta1 [April 3, 2001] - Added type casts on several png_malloc() calls (Dimitri Papadapoulos). - Removed a no-longer needed AIX work-around from pngconf.h - Changed several "//" single-line comments to C-style in pnggccrd.c -version 1.0.11beta2 [April 11, 2001] - Removed PNGAPI from several functions whose prototypes did not have PNGAPI. - Updated scripts/pngos2.def -version 1.0.11beta3 [April 14, 2001] - Added checking the results of many instances of png_malloc() for NULL -version 1.0.11beta4 [April 20, 2001] - Undid the changes from version 1.0.11beta3. Added a check for NULL return - from user's malloc_fn(). - Removed some useless type casts of the NULL pointer. - Added makefile.netbsd -version 1.0.11 [April 27, 2001] - Revised makefile.netbsd -version 1.0.12beta1 [May 17, 2001] - Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot) - Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h - Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings. - Bumped DLLNUM to 2. - Added a check for attempts to read or write PLTE in grayscale PNG datastreams. - Eliminated the png_error about apps using png_read|write_init(). Instead, - libpng will reallocate the png_struct and info_struct if they are too small. - This achieves future binary compatibility for old applications written for - libpng-0.88 and earlier. - Modified png_create_struct so it passes user mem_ptr to user memory allocator. -version 1.0.12rc1 [May 30, 2001] - Check for missing profile length field in iCCP chunk and free chunk_data - in case of truncated iCCP chunk. - Updated makefile.sgi and makefile.sggcc - Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly - if user attempts to run it on an 8-bit display. - Expanded the warnings about incompatible library and application. - Added netware project, distributed in a separate zip file. - Began distributing wince project in a separate zip file. -version 1.0.12 [June 8, 2001] - Fixed new "PLTE_PERMITTED" typo (should be PLTE_SUPPORTED) in pngwutil.c. - Updated contrib/gregbook - -Send comments/corrections/commendations to -png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu - -Glenn R-P diff --git a/freeimage241/Source/LibPNG/INSTALL b/freeimage241/Source/LibPNG/INSTALL deleted file mode 100644 index 1dc078e..0000000 --- a/freeimage241/Source/LibPNG/INSTALL +++ /dev/null @@ -1,136 +0,0 @@ - -Installing libpng version 1.0.10 - March 30, 2001 - -Before installing libpng, you must first install zlib. zlib -can usually be found wherever you got libpng. zlib can be -placed in another directory, at the same level as libpng. -Note that your system might already have a preinstalled -zlib, but you will still need to have access to the -zlib.h and zconf.h include files that correspond to the -version of zlib that's installed. - -You can rename the directories that you downloaded (they -might be called "libpng-1.0.10" or "lpng109" and "zlib-1.1.3" -or "zlib113") so that you have directories called "zlib" and "libpng". - -Your directory structure should look like this: - - .. (the parent directory) - libpng (this directory) - INSTALL (this file) - README - *.h - *.c - contrib - gregbook - msvctest - pngminus - pngsuite - visupng - projects - beos - borland - msvc - wince - scripts - makefile.* - pngtest.png - etc. - zlib - README - *.h - *.c - contrib - etc. - -If the line endings in the files look funny, you may wish to get the other -distribution of libpng. It is available in both tar.gz (UNIX style line -endings) and zip (DOS style line endings) formats. - -If you are building libpng with MSVC, you can enter the libpng\msvc directory -and follow the instructions in msvc\README.txt. You can build libpng for -WindowsCE by entering the libpng\wince directory and following the -instructions in the README* files. - -Else enter the zlib directory and follow the instructions in zlib/README, -then come back here and choose the appropriate makefile.sys in the scripts -directory. - -The files that are presently available in the scripts directory -include - - makefile.std => Generic UNIX makefile (cc, creates static libpng.a) - makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.10) - makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.10, - uses assembler code tuned for Intel MMX platform) - makefile.gcc => Generic makefile (gcc, creates static libpng.a) - makefile.knr => Archaic UNIX Makefile that converts files with - ansi2knr (Requires ansi2knr.c from - ftp://ftp.cs.wisc.edu/ghost) - makefile.aix => AIX makefile - makefile.cygwin => Cygwin/gcc makefile - makefile.dec => DEC Alpha UNIX makefile - makefile.hpgcc => HPUX makefile using gcc - makefile.hpux => HPUX (10.20 and 11.00) makefile - makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) - makefile.intel => Intel C/C++ version 4.0 and later - libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later - makefile.macosx => MACOS X Makefile - makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) - makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.10) - makefile.sunos => Sun makefile - makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.10) - makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc - makefile.mips => MIPS makefile - makefile.acorn => Acorn makefile - makefile.amiga => Amiga makefile - smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler - (Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc) - makefile.atari => Atari makefile - makefile.beos => BEOS makefile for X86 - makefile.bor => Borland makefile (uses bcc) - makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) - makefile.bd32 => To make a png32bd.dll with Borland C++ 4.5 - makefile.tc3 => Turbo C 3.0 makefile - makefile.dj2 => DJGPP 2 makefile - makefile.msc => Microsoft C makefile - makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses - assembler code tuned for Intel MMX platform) - makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later (does - not use assembler code) - makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) - pngos2.def => OS/2 module definition file used by makefile.os2 - makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model - makevms.com => VMS build script - descrip.mms => VMS makefile for MMS or MMK - pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5 - SCOPTIONS.ppc => Used with smakefile.ppc - -Copy the file (or files) that you need from the -scripts directory into this directory, for example - - MSDOS example: copy scripts\makefile.msc makefile - UNIX example: cp scripts/makefile.std makefile - -Read the makefile to see if you need to change any source or -target directories to match your preferences. - -Then read pngconf.h to see if you want to make any configuration -changes. - -Then just run "make test" which will create the libpng library in -this directory and run a quick test that reads the "pngtest.png" -file and writes a "pngout.png" file that should be identical to it. -Look for "9782 zero samples" in the output of the test. For more -confidence, you can run another test by typing "pngtest pngnow.png" -and looking for "289 zero samples" in the output. Also, you can -run "pngtest -m *.png" in the "contrib/pngsuite" directory and compare -your output with the result shown in contrib/pngsuite/README. - -Most of the makefiles will allow you to run "make install" to -put the library in its final resting place (if you want to -do that, run "make install" in the zlib directory first if necessary). - -Further information can be found in the README and libpng.txt -files, in the individual makefiles, in png.h, in the README files in -subdirectories of the LIB directory, and the manual pages libpng.3 and png.5. diff --git a/freeimage241/Source/LibPNG/KNOWNBUG b/freeimage241/Source/LibPNG/KNOWNBUG deleted file mode 100644 index fb09e2f..0000000 --- a/freeimage241/Source/LibPNG/KNOWNBUG +++ /dev/null @@ -1,7 +0,0 @@ - -Known bugs in libpng-1.0.12 - -1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when - reading interlaced PNG files, when assembler code is enabled. - - STATUS: Under investigation. diff --git a/freeimage241/Source/LibPNG/LICENSE b/freeimage241/Source/LibPNG/LICENSE deleted file mode 100644 index 68f7381..0000000 --- a/freeimage241/Source/LibPNG/LICENSE +++ /dev/null @@ -1,102 +0,0 @@ - -This copy of the libpng notices is provided for your convenience. In case of -any discrepancy between this copy and the notices in the file png.h that is -included in the libpng distribution, the latter shall prevail. - -COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - -If you modify libpng you may insert additional notices immediately following -this sentence. - -libpng versions 1.0.7, July 1, 2000, through 1.0.11, April 27, 2001, are -Copyright (c) 2000, 2001 Glenn Randers-Pehrson -and are distributed according to the same disclaimer and license as libpng-1.0.6 -with the following individuals added to the list of Contributing Authors - - Simon-Pierre Cadieux - Eric S. Raymond - Gilles Vollant - -and with the following additions to the disclaimer: - - There is no warranty against interference with your enjoyment of the - library or against infringement. There is no warranty that our - efforts or the library will fulfill any of your particular purposes - or needs. This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and effort is with - the user. - -libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are -Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-0.96, -with the following individuals added to the list of Contributing Authors: - - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik - -libpng versions 0.89, June 1996, through 0.96, May 1997, are -Copyright (c) 1996, 1997 Andreas Dilger -Distributed according to the same disclaimer and license as libpng-0.88, -with the following individuals added to the list of Contributing Authors: - - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner - -libpng versions 0.5, May 1995, through 0.88, January 1996, are -Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - -For the purposes of this copyright and license, "Contributing Authors" -is defined as the following set of individuals: - - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner - -The PNG Reference Library is supplied "AS IS". The Contributing Authors -and Group 42, Inc. disclaim all warranties, expressed or implied, -including, without limitation, the warranties of merchantability and of -fitness for any purpose. The Contributing Authors and Group 42, Inc. -assume no liability for direct, indirect, incidental, special, exemplary, -or consequential damages, which may result from the use of the PNG -Reference Library, even if advised of the possibility of such damage. - -Permission is hereby granted to use, copy, modify, and distribute this -source code, or portions hereof, for any purpose, without fee, subject -to the following restrictions: - -1. The origin of this source code must not be misrepresented. - -2. Altered versions must be plainly marked as such and - must not be misrepresented as being the original source. - -3. This Copyright notice may not be removed or altered from - any source or altered source distribution. - -The Contributing Authors and Group 42, Inc. specifically permit, without -fee, and encourage the use of this source code as a component to -supporting the PNG file format in commercial products. If you use this -source code in a product, acknowledgment is not required but would be -appreciated. - - -A "png_get_copyright" function is available, for convenient use in "about" -boxes and the like: - - printf("%s",png_get_copyright(NULL)); - -Also, the PNG logo (in PNG format, of course) is supplied in the -files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - -Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a -certification mark of the Open Source Initiative. - -Glenn Randers-Pehrson -randeg@alum.rpi.edu -April 27, 2001 diff --git a/freeimage241/Source/LibPNG/LibPNG.dsp b/freeimage241/Source/LibPNG/LibPNG.dsp deleted file mode 100644 index b700b89..0000000 --- a/freeimage241/Source/LibPNG/LibPNG.dsp +++ /dev/null @@ -1,172 +0,0 @@ -# Microsoft Developer Studio Project File - Name="LibPNG" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=LibPNG - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "LibPNG.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "LibPNG.mak" CFG="LibPNG - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "LibPNG - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "LibPNG - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName ""$/FreeImage/LibPNG", PJAAAAAA" -# PROP Scc_LocalPath "." -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "LibPNG - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G6 /Gd /MT /W3 /GX /O1 /I "..\zlib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "LibPNG - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\zlib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "LibPNG - Win32 Release" -# Name "LibPNG - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\png.c -# End Source File -# Begin Source File - -SOURCE=.\pngerror.c -# End Source File -# Begin Source File - -SOURCE=.\pnggccrd.c -# End Source File -# Begin Source File - -SOURCE=.\pngget.c -# End Source File -# Begin Source File - -SOURCE=.\pngmem.c -# End Source File -# Begin Source File - -SOURCE=.\pngpread.c -# End Source File -# Begin Source File - -SOURCE=.\pngread.c -# End Source File -# Begin Source File - -SOURCE=.\pngrio.c -# End Source File -# Begin Source File - -SOURCE=.\pngrtran.c -# End Source File -# Begin Source File - -SOURCE=.\pngrutil.c -# End Source File -# Begin Source File - -SOURCE=.\pngset.c -# End Source File -# Begin Source File - -SOURCE=.\pngtest.c -# End Source File -# Begin Source File - -SOURCE=.\pngtrans.c -# End Source File -# Begin Source File - -SOURCE=.\pngvcrd.c -# End Source File -# Begin Source File - -SOURCE=.\pngwio.c -# End Source File -# Begin Source File - -SOURCE=.\pngwrite.c -# End Source File -# Begin Source File - -SOURCE=.\pngwtran.c -# End Source File -# Begin Source File - -SOURCE=.\pngwutil.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\png.h -# End Source File -# Begin Source File - -SOURCE=.\pngconf.h -# End Source File -# End Group -# End Target -# End Project diff --git a/freeimage241/Source/LibPNG/README b/freeimage241/Source/LibPNG/README deleted file mode 100644 index 08b88aa..0000000 --- a/freeimage241/Source/LibPNG/README +++ /dev/null @@ -1,251 +0,0 @@ -README for libpng 1.0.12 - June 8, 2001 (shared library 2.1) -See the note about version numbers near the top of png.h - -See INSTALL for instructions on how to install libpng. - -Libpng comes in two distribution formats. Get libpng-*.tar.gz if you -want UNIX-style line endings in the text files, or lpng*.zip if you want -DOS-style line endings. - -Version 0.89 was the first official release of libpng. Don't let the -fact that it's the first release fool you. The libpng library has been in -extensive use and testing since mid-1995. By late 1997 it had -finally gotten to the stage where there hadn't been significant -changes to the API in some time, and people have a bad feeling about -libraries with versions < 1.0. Version 1.0.0 was released in -March 1998. - -**** -Note that some of the changes to the png_info structure render this -version of the library binary incompatible with libpng-0.89 or -earlier versions if you are using a shared library. The type of the -"filler" parameter for png_set_filler() has changed from png_byte to -png_uint_32, which will affect shared-library applications that use -this function. - -To avoid problems with changes to the internals of png_info_struct, -new APIs have been made available in 0.95 to avoid direct application -access to info_ptr. These functions are the png_set_ and -png_get_ functions. These functions should be used when -accessing/storing the info_struct data, rather than manipulating it -directly, to avoid such problems in the future. - -It is important to note that the APIs do not make current programs -that access the info struct directly incompatible with the new -library. However, it is strongly suggested that new programs use -the new APIs (as shown in example.c and pngtest.c), and older programs -be converted to the new format, to facilitate upgrades in the future. -**** - -Additions since 0.90 include the ability to compile libpng as a -Windows DLL, and new APIs for accessing data in the info struct. -Experimental functions include the ability to set weighting and cost -factors for row filter selection, direct reads of integers from buffers -on big-endian processors that support misaligned data access, faster -methods of doing alpha composition, and more accurate 16->8 bit color -conversion. - -The additions since 0.89 include the ability to read from a PNG stream -which has had some (or all) of the signature bytes read by the calling -application. This also allows the reading of embedded PNG streams that -do not have the PNG file signature. As well, it is now possible to set -the library action on the detection of chunk CRC errors. It is possible -to set different actions based on whether the CRC error occurred in a -critical or an ancillary chunk. - -The changes made to the library, and bugs fixed are based on discussions -on the PNG implementation mailing list -and not on material submitted privately to Guy, Andreas, or Glenn. They will -forward any good suggestions to the list. - -For a detailed description on using libpng, read libpng.txt. For -examples of libpng in a program, see example.c and pngtest.c. For usage -information and restrictions (what little they are) on libpng, see -png.h. For a description on using zlib (the compression library used by -libpng) and zlib's restrictions, see zlib.h - -I have included a general makefile, as well as several machine and -compiler specific ones, but you may have to modify one for your own needs. - -You should use zlib 1.0.4 or later to run this, but it MAY work with -versions as old as zlib 0.95. Even so, there are bugs in older zlib -versions which can cause the output of invalid compression streams for -some images. You will definitely need zlib 1.0.4 or later if you are -taking advantage of the MS-DOS "far" structure allocation for the small -and medium memory models. You should also note that zlib is a -compression library that is useful for more things than just PNG files. -You can use zlib as a drop-in replacement for fread() and fwrite() if -you are so inclined. - -zlib should be available at the same place that libpng is. -If not, it should be at ftp.uu.net in /graphics/png -Eventually, it will be at ftp.uu.net in /pub/archiving/zip/zlib - -You may also want a copy of the PNG specification. It is available -as an RFC and a W3C Recommendation. Failing -these resources you can try ftp.uu.net in the /graphics/png directory. - -This code is currently being archived at ftp.uu.net in the -/graphics/png directory, and on CompuServe, Lib 20 (PNG SUPPORT) -at GO GRAPHSUP. If you can't find it in any of those places, -e-mail me, and I'll help you find it. - -If you have any code changes, requests, problems, etc., please e-mail -them to me. Also, I'd appreciate any make files or project files, -and any modifications you needed to make to get libpng to compile, -along with a #define variable to tell what compiler/system you are on. -If you needed to add transformations to libpng, or wish libpng would -provide the image in a different way, drop me a note (and code, if -possible), so I can consider supporting the transformation. -Finally, if you get any warning messages when compiling libpng -(note: not zlib), and they are easy to fix, I'd appreciate the -fix. Please mention "libpng" somewhere in the subject line. Thanks. - -This release was created and will be supported by myself (of course -based in a large way on Guy's and Andreas' earlier work), and the PNG group. - -randeg@alum.rpi.edu -png-implement@ccrc.wustl.edu - -You can't reach Guy, the original libpng author, at the addresses -given in previous versions of this document. He and Andreas will read mail -addressed to the png-implement list, however. - -Please do not send general questions about PNG. Send them to -the address in the specification (png-group@w3.org). At the same -time, please do not send libpng questions to that address, send them to me -or to png-implement@ccrc.wustl.edu. I'll -get them in the end anyway. If you have a question about something -in the PNG specification that is related to using libpng, send it -to me. Send me any questions that start with "I was using libpng, -and ...". If in doubt, send questions to me. I'll bounce them -to others, if necessary. - -Please do not send suggestions on how to change PNG. We have -been discussing PNG for three years now, and it is official and -finished. If you have suggestions for libpng, however, I'll -gladly listen. Even if your suggestion is not used for version -1.0, it may be used later. - -Files in this distribution: - - ANNOUNCE => Announcement of this version, with recent changes - CHANGES => Description of changes between libpng versions - KNOWNBUG => List of known bugs and deficiencies - LICENSE => License to use and redistribute libpng - README => This file - TODO => Things not implemented in the current library - Y2KINFO => Statement of Y2K compliance - example.c => Example code for using libpng functions - libpng.3 => manual page for libpng (includes libpng.txt) - libpng.txt => Description of libpng and its functions - libpngpf.3 => manual page for libpng's private functions - png.5 => manual page for the PNG format - png.c => Basic interface functions common to library - png.h => Library function and interface declarations - pngconf.h => System specific library configuration - pngasmrd.h => Header file for assembler-coded functions - pngerror.c => Error/warning message I/O functions - pngget.c => Functions for retrieving info from struct - pngmem.c => Memory handling functions - pngbar.png => PNG logo, 88x31 - pngnow.png => PNG logo, 98x31 - pngpread.c => Progressive reading functions - pngread.c => Read data/helper high-level functions - pngrio.c => Lowest-level data read I/O functions - pngrtran.c => Read data transformation functions - pngrutil.c => Read data utility functions - pngset.c => Functions for storing data into the info_struct - pngtest.c => Library test program - pngtest.png => Library test sample image - pngtrans.c => Common data transformation functions - pngwio.c => Lowest-level write I/O functions - pngwrite.c => High-level write functions - pngwtran.c => Write data transformations - pngwutil.c => Write utility functions - contrib => Contributions - gregbook => source code for PNG reading and writing, from - Greg Roelofs' "PNG: The Definitive Guide", - O'Reilly, 1999 - msvctest => Builds and runs pngtest using a MSVC workspace - pngminus => Simple pnm2png and png2pnm programs - pngsuite => Test images - visupng => Contains a MSVC workspace for VisualPng - projects => Contains project files and workspaces for building DLL - beos => Contains a Beos workspace for building libpng - borland => Contains a Borland workspace for building libpng - and zlib - msvc => Contains a Microsoft Visual C++ (MSVC) workspace - for building libpng and zlib - netware.txt => Contains instructions for downloading a set of - project files for building libpng and zlib on - Netware. - wince.txt => Contains instructions for downloading a Microsoft - Visual C++ (Windows CD Toolkit) workspace for - building libpng and zlib on WindowsCE - scripts => Directory containing scripts for building libpng: - descrip.mms => VMS makefile for MMS or MMK - makefile.std => Generic UNIX makefile (cc, creates static libpng.a) - makefile.linux => Linux/ELF makefile - (gcc, creates libpng.so.2.1.0.12) - makefile.gcmmx => Linux/ELF makefile (gcc, creates - libpng.so.2.1.0.12, uses assembler code - tuned for Intel MMX platform) - makefile.gcc => Generic makefile (gcc, creates static libpng.a) - makefile.knr => Archaic UNIX Makefile that converts files with - ansi2knr (Requires ansi2knr.c from - ftp://ftp.cs.wisc.edu/ghost) - makefile.aix => AIX makefile - makefile.cygwin => Cygwin/gcc makefile - makefile.dec => DEC Alpha UNIX makefile - makefile.hpgcc => HPUX makefile using gcc - makefile.hpux => HPUX (10.20 and 11.00) makefile - makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) - makefile.intel => Intel C/C++ version 4.0 and later - libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later - makefile.macosx => MACOS X Makefile - makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD - makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) - makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.12) - makefile.sunos => Sun makefile - makefile.solaris => Solaris 2.X makefile - (gcc, creates libpng.so.2.1.0.12) - makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc - makefile.mips => MIPS makefile - makefile.acorn => Acorn makefile - makefile.amiga => Amiga makefile - smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC - compiler (Requires SCOPTIONS, copied from - scripts/SCOPTIONS.ppc) - makefile.atari => Atari makefile - makefile.beos => BEOS makefile for X86 - makefile.bor => Borland makefile (uses bcc) - makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) - makefile.bd32 => To make a png32bd.dll with Borland C++ 4.5 - makefile.tc3 => Turbo C 3.0 makefile - makefile.dj2 => DJGPP 2 makefile - makefile.msc => Microsoft C makefile - makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and - later (uses assembler code tuned for Intel MMX - platform) - makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and - later (does not use assembler code) - makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) - pngos2.def => OS/2 module definition file used by makefile.os2 - makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model - makevms.com => VMS build script - pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5 - SCOPTIONS.ppc => Used with smakefile.ppc - -Good luck, and happy coding. - --Glenn Randers-Pehrson - Internet: randeg@alum.rpi.edu - --Andreas Eric Dilger - Internet: adilger@enel.ucalgary.ca - Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/ - --Guy Eric Schalnat - (formerly of Group 42, Inc) - Internet: gschal@infinet.com diff --git a/freeimage241/Source/LibPNG/TODO b/freeimage241/Source/LibPNG/TODO deleted file mode 100644 index a5f6395..0000000 --- a/freeimage241/Source/LibPNG/TODO +++ /dev/null @@ -1,24 +0,0 @@ -TODO - list of things to do for libpng: - -Final bug fixes. -Improve API by hiding the png_struct and png_info structs. -Finish work on the no-floating-point version (including gamma compensation) -Better C++ wrapper/full C++ implementation? -Fix problem with C++ and EXTERN "C". -cHRM transformation. -Improve setjmp/longjmp usage or remove it in favor of returning error codes. -Add "grayscale->palette" transformation and "palette->grayscale" detection. -Improved dithering. -Multi-lingual error and warning message support. -Complete sRGB transformation (presently it simply uses gamma=0.45455). -Man pages for function calls. -Better documentation. -Better filter selection - (counting huffman bits/precompression? filter inertia? filter costs?). -Histogram creation. -Text conversion between different code pages (Latin-1 -> Mac and DOS). -Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety? -Build gamma tables using fixed point (and do away with floating point entirely). -Use greater precision when changing to linear gamma for compositing against - background and doing rgb-to-gray transformation. -Investigate pre-incremented loop counters and other loop constructions. diff --git a/freeimage241/Source/LibPNG/Y2KINFO b/freeimage241/Source/LibPNG/Y2KINFO deleted file mode 100644 index 84feed2..0000000 --- a/freeimage241/Source/LibPNG/Y2KINFO +++ /dev/null @@ -1,55 +0,0 @@ - Y2K compliance in libpng: - ========================= - - April 27, 2001 - - Since the PNG Development group is an ad-hoc body, we can't make - an official declaration. - - This is your unofficial assurance that libpng from version 0.71 and - upward through 1.0.11 are Y2K compliant. It is my belief that earlier - versions were also Y2K compliant. - - Libpng only has three year fields. One is a 2-byte unsigned integer - that will hold years up to 65535. The other two hold the date in text - format, and will hold years up to 9999. - - The integer is - "png_uint_16 year" in png_time_struct. - - The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - - There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - - All appear to handle dates properly in a Y2K environment. The - png_convert_from_time_t() function calls gmtime() to convert from system - clock time, which returns (year - 1900), which we properly convert to - the full 4-digit year. There is a possibility that applications using - libpng are not passing 4-digit years into the png_convert_to_rfc_1123() - function, or that they are incorrectly passing only a 2-digit year - instead of "year - 1900" into the png_convert_from_struct_tm() function, - but this is not under our control. The libpng documentation has always - stated that it works with 4-digit years, and the APIs have been - documented as such. - - The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - integer to hold the year, and can hold years as large as 65535. - - zlib, upon which libpng depends, is also Y2K compliant. It contains - no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group diff --git a/freeimage241/Source/LibPNG/configure b/freeimage241/Source/LibPNG/configure deleted file mode 100644 index 18b0cdc..0000000 --- a/freeimage241/Source/LibPNG/configure +++ /dev/null @@ -1,6 +0,0 @@ -echo " - There is no \"configure\" script for Libpng-1.0.10. Instead, please - copy the appropriate makefile for your system from the \"scripts\" - directory. Read the INSTALL file for more details. -" - diff --git a/freeimage241/Source/LibPNG/example.c b/freeimage241/Source/LibPNG/example.c deleted file mode 100644 index f0fe688..0000000 --- a/freeimage241/Source/LibPNG/example.c +++ /dev/null @@ -1,778 +0,0 @@ - -#if 0 /* in case someone actually tries to compile this */ - -/* example.c - an example of using libpng */ - -/* This is an example of how to use libpng to read and write PNG files. - * The file libpng.txt is much more verbose then this. If you have not - * read it, do so first. This was designed to be a starting point of an - * implementation. This is not officially part of libpng, is hereby placed - * in the public domain, and therefore does not require a copyright notice. - * - * This file does not currently compile, because it is missing certain - * parts, like allocating memory to hold an image. You will have to - * supply these parts to get it to compile. For an example of a minimal - * working PNG reader/writer, see pngtest.c, included in this distribution; - * see also the programs in the contrib directory. - */ - -#include "png.h" - - /* The png_jmpbuf() macro, used in error handling, became available in - * libpng version 1.0.6. If you want to be able to run your code with older - * versions of libpng, you must define the macro yourself (but only if it - * is not already defined by libpng!). - */ - -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() - * returns zero if the image is a PNG and nonzero if it isn't a PNG. - * - * The function check_if_png() shown here, but not used, returns nonzero (true) - * if the file can be opened and is a PNG, 0 (false) otherwise. - * - * If this call is successful, and you are going to keep the file open, - * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once - * you have created the png_ptr, so that libpng knows your application - * has read that many bytes from the start of the file. Make sure you - * don't call png_set_sig_bytes() with more than 8 bytes read or give it - * an incorrect number of bytes read, or you will either have read too - * many bytes (your fault), or you are telling libpng to read the wrong - * number of magic bytes (also your fault). - * - * Many applications already read the first 2 or 4 bytes from the start - * of the image to determine the file type, so it would be easiest just - * to pass the bytes to png_sig_cmp() or even skip that if you know - * you have a PNG file, and call png_set_sig_bytes(). - */ -#define PNG_BYTES_TO_CHECK 4 -int check_if_png(char *file_name, FILE **fp) -{ - char buf[PNG_BYTES_TO_CHECK]; - - /* Open the prospective PNG file. */ - if ((*fp = fopen(file_name, "rb")) == NULL) - return 0; - - /* Read in some of the signature bytes */ - if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK) - return 0; - - /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. - Return nonzero (true) if they match */ - - return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); -} - -/* Read a PNG file. You may want to return an error code if the read - * fails (depending upon the failure). There are two "prototypes" given - * here - one where we are given the filename, and we need to open the - * file, and the other where we are given an open file (possibly with - * some or all of the magic bytes read - see comments above). - */ -#ifdef open_file /* prototype 1 */ -void read_png(char *file_name) /* We need to open the file */ -{ - png_structp png_ptr; - png_infop info_ptr; - unsigned int sig_read = 0; - png_uint_32 width, height; - int bit_depth, color_type, interlace_type; - FILE *fp; - - if ((fp = fopen(file_name, "rb")) == NULL) - return (ERROR); -#else no_open_file /* prototype 2 */ -void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ -{ - png_structp png_ptr; - png_infop info_ptr; - png_uint_32 width, height; - int bit_depth, color_type, interlace_type; -#endif no_open_file /* only use one prototype! */ - - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also supply the - * the compiler header file version, so that we know if the application - * was compiled with a compatible version of the library. REQUIRED - */ - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (png_ptr == NULL) - { - fclose(fp); - return (ERROR); - } - - /* Allocate/initialize the memory for image information. REQUIRED. */ - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) - { - fclose(fp); - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); - } - - /* Set error handling if you are using the setjmp/longjmp method (this is - * the normal method of doing things with libpng). REQUIRED unless you - * set up your own error handlers in the png_create_read_struct() earlier. - */ - - if (setjmp(png_jmpbuf(png_ptr))) - { - /* Free all of the memory associated with the png_ptr and info_ptr */ - png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); - fclose(fp); - /* If we get here, we had a problem reading the file */ - return (ERROR); - } - - /* One of the following I/O initialization methods is REQUIRED */ -#ifdef streams /* PNG file I/O method 1 */ - /* Set up the input control if you are using standard C streams */ - png_init_io(png_ptr, fp); - -#else no_streams /* PNG file I/O method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call: - */ - png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn); - /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* Use only one I/O method! */ - - /* If we have already read some of the signature */ - png_set_sig_bytes(png_ptr, sig_read); - -#ifdef hilevel - /* - * If you have enough memory to read in the entire image at once, - * and you need to specify only transforms that can be controlled - * with one of the PNG_TRANSFORM_* bits (this presently excludes - * dithering, filling, setting background, and doing gamma - * adjustment), then you can read the entire image (including - * pixels) into the info structure with this call: - */ - png_read_png(png_ptr, info_ptr, png_transforms, NULL); -#else - /* OK, you're doing it the hard way, with the lower-level functions */ - - /* The call to png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). REQUIRED - */ - png_read_info(png_ptr, info_ptr); - - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - &interlace_type, NULL, NULL); - -/**** Set up the data transformations you want. Note that these are all - **** optional. Only call them if you want/need them. Many of the - **** transformations only work on specific types of images, and many - **** are mutually exclusive. - ****/ - - /* tell libpng to strip 16 bit/color files down to 8 bits/color */ - png_set_strip_16(png_ptr); - - /* Strip alpha bytes from the input data without combining with the - * background (not recommended). - */ - png_set_strip_alpha(png_ptr); - - /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - png_set_packing(png_ptr); - - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). */ - png_set_packswap(png_ptr); - - /* Expand paletted colors into true RGB triplets */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand(png_ptr); - - /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand(png_ptr); - - /* Expand paletted or RGB images with transparency to full alpha channels - * so the data will be available as RGBA quartets. - */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand(png_ptr); - - /* Set the background color to draw transparent and alpha images over. - * It is possible to set the red, green, and blue components directly - * for paletted images instead of supplying a palette index. Note that - * even if the PNG file supplies a background, you are not required to - * use it - you should use the (solid) application background if it has one. - */ - - png_color_16 my_background, *image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - - /* Some suggestions as to how to get a screen gamma value */ - - /* Note that screen gamma is the display_exponent, which includes - * the CRT_exponent and any correction for viewing conditions */ - if (/* We have a user-defined screen gamma value */) - { - screen_gamma = user-defined screen_gamma; - } - /* This is one way that applications share the same screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL) - { - screen_gamma = atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly - lit room */ - screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ - } - - /* Tell libpng to handle the gamma conversion for you. The final call - * is a good guess for PC generated images, but it should be configurable - * by the user at run time by the user. It is strongly suggested that - * your application support gamma correction. - */ - - int intent; - - if (png_get_sRGB(png_ptr, info_ptr, &intent)) - png_set_gamma(png_ptr, screen_gamma, 0.45455); - else - { - double image_gamma; - if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)) - png_set_gamma(png_ptr, screen_gamma, image_gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - } - - /* Dither RGB files down to 8 bit palette or reduce palettes - * to the number of colors available on your screen. - */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - int num_palette; - png_colorp palette; - - /* This reduces the image to the application supplied palette */ - if (/* we have our own palette */) - { - /* An array of colors to which the image should be dithered */ - png_color std_color_cube[MAX_SCREEN_COLORS]; - - png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, - MAX_SCREEN_COLORS, NULL, 0); - } - /* This reduces the image to the palette supplied in the file */ - else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) - { - png_uint_16p histogram; - - png_get_hIST(png_ptr, info_ptr, &histogram); - - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 0); - } - } - - /* invert monochrome files to have 0 as white and 1 as black */ - png_set_invert_mono(png_ptr); - - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) - { - png_color_8p sig_bit; - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); - } - - /* flip the RGB pixels to BGR (or RGBA to BGRA) */ - if (color_type & PNG_COLOR_MASK_COLOR) - png_set_bgr(png_ptr); - - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ - png_set_swap_alpha(png_ptr); - - /* swap bytes of 16 bit files to least significant byte first */ - png_set_swap(png_ptr); - - /* Add filler (or alpha) byte (before/after each RGB triplet) */ - png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); - - /* Turn on interlace handling. REQUIRED if you are not using - * png_read_image(). To see how to handle interlacing passes, - * see the png_read_row() method below: - */ - number_passes = png_set_interlace_handling(png_ptr); - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. REQUIRED if you are expecting libpng to - * update the palette for you (ie you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* Allocate the memory to hold the image using the fields of info_ptr. */ - - /* The easiest way to read the image: */ - png_bytep row_pointers[height]; - - for (row = 0; row < height; row++) - { - row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, - info_ptr)); - } - - /* Now it's time to read the image. One of these methods is REQUIRED */ -#ifdef entire /* Read the entire image in one go */ - png_read_image(png_ptr, row_pointers); - -#else no_entire /* Read the image one or more scanlines at a time */ - /* The other way to read images - deal with interlacing: */ - - for (pass = 0; pass < number_passes; pass++) - { -#ifdef single /* Read the image a single row at a time */ - for (y = 0; y < height; y++) - { - png_read_rows(png_ptr, &row_pointers[y], NULL, 1); - } - -#else no_single /* Read the image several rows at a time */ - for (y = 0; y < height; y += number_of_rows) - { -#ifdef sparkle /* Read the image using the "sparkle" effect. */ - png_read_rows(png_ptr, &row_pointers[y], NULL, number_of_rows); - - png_read_rows(png_ptr, NULL, row_pointers[y], number_of_rows); -#else no_sparkle /* Read the image using the "rectangle" effect */ - png_read_rows(png_ptr, NULL, &row_pointers[y], number_of_rows); -#endif no_sparkle /* use only one of these two methods */ - } - - /* if you want to display the image after every pass, do - so here */ -#endif no_single /* use only one of these two methods */ - } -#endif no_entire /* use only one of these two methods */ - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end(png_ptr, info_ptr); -#endif hilevel - - /* At this point you have read the entire image */ - - /* clean up after the read, and free any memory allocated - REQUIRED */ - png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); - - /* close the file */ - fclose(fp); - - /* that's it */ - return (OK); -} - -/* progressively read a file */ - -int -initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) -{ - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also check that - * the library version is compatible in case we are using dynamically - * linked libraries. - */ - *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (*png_ptr == NULL) - { - *info_ptr = NULL; - return (ERROR); - } - - *info_ptr = png_create_info_struct(png_ptr); - - if (*info_ptr == NULL) - { - png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf((*png_ptr)))) - { - png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL); - return (ERROR); - } - - /* This one's new. You will need to provide all three - * function callbacks, even if you aren't using them all. - * If you aren't using all functions, you can specify NULL - * parameters. Even when all three functions are NULL, - * you need to call png_set_progressive_read_fn(). - * These functions shouldn't be dependent on global or - * static variables if you are decoding several images - * simultaneously. You should store stream specific data - * in a separate struct, given as the second parameter, - * and retrieve the pointer from inside the callbacks using - * the function png_get_progressive_ptr(png_ptr). - */ - png_set_progressive_read_fn(*png_ptr, (void *)stream_data, - info_callback, row_callback, end_callback); - - return (OK); -} - -int -process_data(png_structp *png_ptr, png_infop *info_ptr, - png_bytep buffer, png_uint_32 length) -{ - if (setjmp(png_jmpbuf((*png_ptr)))) - { - /* Free the png_ptr and info_ptr memory on error */ - png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL); - return (ERROR); - } - - /* This one's new also. Simply give it chunks of data as - * they arrive from the data stream (in order, of course). - * On Segmented machines, don't give it any more than 64K. - * The library seems to run fine with sizes of 4K, although - * you can give it much less if necessary (I assume you can - * give it chunks of 1 byte, but I haven't tried with less - * than 256 bytes yet). When this function returns, you may - * want to display any rows that were generated in the row - * callback, if you aren't already displaying them there. - */ - png_process_data(*png_ptr, *info_ptr, buffer, length); - return (OK); -} - -info_callback(png_structp png_ptr, png_infop info) -{ -/* do any setup here, including setting any of the transformations - * mentioned in the Reading PNG files section. For now, you _must_ - * call either png_start_read_image() or png_read_update_info() - * after all the transformations are set (even if you don't set - * any). You may start getting rows before png_process_data() - * returns, so this is your last chance to prepare for that. - */ -} - -row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) -{ -/* this function is called for every row in the image. If the - * image is interlacing, and you turned on the interlace handler, - * this function will be called for every row in every pass. - * Some of these rows will not be changed from the previous pass. - * When the row is not changed, the new_row variable will be NULL. - * The rows and passes are called in order, so you don't really - * need the row_num and pass, but I'm supplying them because it - * may make your life easier. - * - * For the non-NULL rows of interlaced images, you must call - * png_progressive_combine_row() passing in the row and the - * old row. You can call this function for NULL rows (it will - * just return) and for non-interlaced images (it just does the - * png_memcpy for you) if it will make the code easier. Thus, you - * can just do this for all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, new_row); - -/* where old_row is what was displayed for previous rows. Note - * that the first pass (pass == 0 really) will completely cover - * the old row, so the rows do not have to be initialized. After - * the first pass (and only for interlaced images), you will have - * to pass the current row, and the function will combine the - * old row and the new row. - */ -} - -end_callback(png_structp png_ptr, png_infop info) -{ -/* this function is called when the whole image has been read, - * including any chunks after the image (up to and including - * the IEND). You will usually have the same info chunk as you - * had in the header, although some data may have been added - * to the comments and time fields. - * - * Most people won't do much here, perhaps setting a flag that - * marks the image as finished. - */ -} - -/* write a png file */ -void write_png(char *file_name /* , ... other image information ... */) -{ - FILE *fp; - png_structp png_ptr; - png_infop info_ptr; - png_colorp palette; - - /* open the file */ - fp = fopen(file_name, "wb"); - if (fp == NULL) - return (ERROR); - - /* Create and initialize the png_struct with the desired error handler - * functions. If you want to use the default stderr and longjump method, - * you can supply NULL for the last three parameters. We also check that - * the library version is compatible with the one used at compile time, - * in case we are using dynamically linked libraries. REQUIRED. - */ - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - png_voidp user_error_ptr, user_error_fn, user_warning_fn); - - if (png_ptr == NULL) - { - fclose(fp); - return (ERROR); - } - - /* Allocate/initialize the image information data. REQUIRED */ - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) - { - fclose(fp); - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - return (ERROR); - } - - /* Set error handling. REQUIRED if you aren't supplying your own - * error handling functions in the png_create_write_struct() call. - */ - if (setjmp(png_jmpbuf(png_ptr))) - { - /* If we get here, we had a problem reading the file */ - fclose(fp); - png_destroy_write_struct(&png_ptr, &info_ptr); - return (ERROR); - } - - /* One of the following I/O initialization functions is REQUIRED */ -#ifdef streams /* I/O initialization method 1 */ - /* set up the output control if you are using standard C streams */ - png_init_io(png_ptr, fp); -#else no_streams /* I/O initialization method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call */ - png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, - user_IO_flush_function); - /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* only use one initialization method */ - -#ifdef hilevel - /* This is the easy way. Use it if you already have all the - * image info living info in the structure. You could "|" many - * PNG_TRANSFORM flags into the png_transforms integer here. - */ - png_write_png(png_ptr, info_ptr, png_transforms, NULL); -#else - /* This is the hard way */ - - /* Set the image information here. Width and height are up to 2^31, - * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on - * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, - * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, - * or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or - * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST - * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED - */ - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, - PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - /* set the palette if there is one. REQUIRED for indexed-color images */ - palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH - * sizeof (png_color)); - /* ... set palette colors ... */ - png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); - /* You must not free palette here, because png_set_PLTE only makes a link to - the palette that you malloced. Wait until you are about to destroy - the png structure. */ - - /* optional significant bit chunk */ - /* if we are dealing with a grayscale image then */ - sig_bit.gray = true_bit_depth; - /* otherwise, if we are dealing with a color image then */ - sig_bit.red = true_red_bit_depth; - sig_bit.green = true_green_bit_depth; - sig_bit.blue = true_blue_bit_depth; - /* if the image has an alpha channel then */ - sig_bit.alpha = true_alpha_bit_depth; - png_set_sBIT(png_ptr, info_ptr, sig_bit); - - - /* Optional gamma chunk is strongly suggested if you have any guess - * as to the correct gamma of the image. - */ - png_set_gAMA(png_ptr, info_ptr, gamma); - - /* Optionally write comments into the image */ - text_ptr[0].key = "Title"; - text_ptr[0].text = "Mona Lisa"; - text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[1].key = "Author"; - text_ptr[1].text = "Leonardo DaVinci"; - text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[2].key = "Description"; - text_ptr[2].text = ""; - text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; -#ifdef PNG_iTXt_SUPPORTED - text_ptr[0].lang = NULL; - text_ptr[1].lang = NULL; - text_ptr[2].lang = NULL; -#endif - png_set_text(png_ptr, info_ptr, text_ptr, 3); - - /* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */ - /* note that if sRGB is present the gAMA and cHRM chunks must be ignored - * on read and must be written in accordance with the sRGB profile */ - - /* Write the file header information. REQUIRED */ - png_write_info(png_ptr, info_ptr); - - /* If you want, you can write the info in two steps, in case you need to - * write your private chunk ahead of PLTE: - * - * png_write_info_before_PLTE(write_ptr, write_info_ptr); - * write_my_chunk(); - * png_write_info(png_ptr, info_ptr); - * - * However, given the level of known- and unknown-chunk support in 1.1.0 - * and up, this should no longer be necessary. - */ - - /* Once we write out the header, the compression type on the text - * chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or - * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again - * at the end. - */ - - /* set up the transformations you want. Note that these are - * all optional. Only call them if you want them. - */ - - /* invert monochrome pixels */ - png_set_invert_mono(png_ptr); - - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - png_set_shift(png_ptr, &sig_bit); - - /* pack pixels into bytes */ - png_set_packing(png_ptr); - - /* swap location of alpha bytes from ARGB to RGBA */ - png_set_swap_alpha(png_ptr); - - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - - /* flip BGR pixels to RGB */ - png_set_bgr(png_ptr); - - /* swap bytes of 16-bit files to most significant byte first */ - png_set_swap(png_ptr); - - /* swap bits of 1, 2, 4 bit packed pixel formats */ - png_set_packswap(png_ptr); - - /* turn on interlace handling if you are not using png_write_image() */ - if (interlacing) - number_passes = png_set_interlace_handling(png_ptr); - else - number_passes = 1; - - /* The easiest way to write the image (you may have a different memory - * layout, however, so choose what fits your needs best). You need to - * use the first method if you aren't handling interlacing yourself. - */ - png_uint_32 k, height, width; - png_byte image[height][width*bytes_per_pixel]; - png_bytep row_pointers[height]; - for (k = 0; k < height; k++) - row_pointers[k] = image + k*width*bytes_per_pixel; - - /* One of the following output methods is REQUIRED */ -#ifdef entire /* write out the entire image data in one call */ - png_write_image(png_ptr, row_pointers); - - /* the other way to write the image - deal with interlacing */ - -#else no_entire /* write out the image data by one or more scanlines */ - /* The number of passes is either 1 for non-interlaced images, - * or 7 for interlaced images. - */ - for (pass = 0; pass < number_passes; pass++) - { - /* Write a few rows at a time. */ - png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows); - - /* If you are only writing one row at a time, this works */ - for (y = 0; y < height; y++) - { - png_write_rows(png_ptr, &row_pointers[y], 1); - } - } -#endif no_entire /* use only one output method */ - - /* You can write optional chunks like tEXt, zTXt, and tIME at the end - * as well. Shouldn't be necessary in 1.1.0 and up as all the public - * chunks are supported and you can use png_set_unknown_chunks() to - * register unknown chunks into the info structure to be written out. - */ - - /* It is REQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); -#endif hilevel - - /* If you png_malloced a palette, free it here (don't free info_ptr->palette, - as recommended in versions 1.0.5m and earlier of this example; if - libpng mallocs info_ptr->palette, libpng will free it). If you - allocated it with malloc() instead of png_malloc(), use free() instead - of png_free(). */ - png_free(png_ptr, palette); - palette=NULL; - - /* Similarly, if you png_malloced any data that you passed in with - png_set_something(), such as a hist or trans array, free it here, - when you can be sure that libpng is through with it. */ - png_free(png_ptr, trans); - trans=NULL; - - /* clean up after the write, and free any memory allocated */ - png_destroy_write_struct(&png_ptr, &info_ptr); - - /* close the file */ - fclose(fp); - - /* that's it */ - return (OK); -} - -#endif /* if 0 */ diff --git a/freeimage241/Source/LibPNG/libpng.txt b/freeimage241/Source/LibPNG/libpng.txt deleted file mode 100644 index 6164057..0000000 --- a/freeimage241/Source/LibPNG/libpng.txt +++ /dev/null @@ -1,2776 +0,0 @@ -libpng.txt - A description on how to use and modify libpng - - libpng version 1.0.12 - June 8, 2001 - Updated and distributed by Glenn Randers-Pehrson - - Copyright (c) 1998-2001 Glenn Randers-Pehrson - For conditions of distribution and use, see copyright - notice in png.h. - - based on: - - libpng 1.0 beta 6 version 0.96 May 28, 1997 - Updated and distributed by Andreas Dilger - Copyright (c) 1996, 1997 Andreas Dilger - - libpng 1.0 beta 2 - version 0.88 January 26, 1996 - For conditions of distribution and use, see copyright - notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. - - Updated/rewritten per request in the libpng FAQ - Copyright (c) 1995, 1996 Frank J. T. Wojcik - December 18, 1995 & January 20, 1996 - -I. Introduction - -This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this -file, example.c is a good starting point for using the library, as -it is heavily commented and should include everything most people -will need. We assume that libpng is already installed; see the -INSTALL file for instructions on how to install libpng. - -Libpng was written as a companion to the PNG specification, as a way -of reducing the amount of time and effort it takes to support the PNG -file format in application programs. - -The PNG-1.2 specification is available at -and at . - -The PNG-1.0 specification is available -as RFC 2083 and as a -W3C Recommendation . Some -additional chunks are described in the special-purpose public chunks -documents at . - -Other information -about PNG, and the latest version of libpng, can be found at the PNG home -page, -and at . - -Most users will not have to modify the library significantly; advanced -users may want to modify it more. All attempts were made to make it as -complete as possible, while keeping the code easy to understand. -Currently, this library only supports C. Support for other languages -is being considered. - -Libpng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy -to use. The ultimate goal of libpng is to promote the acceptance of -the PNG file format in whatever way possible. While there is still -work to be done (see the TODO file), libpng should cover the -majority of the needs of its users. - -Libpng uses zlib for its compression and decompression of PNG files. -Further information about zlib, and the latest version of zlib, can -be found at the zlib home page, . -The zlib compression utility is a general purpose utility that is -useful for more than PNG files, and can be used without libpng. -See the documentation delivered with zlib for more details. -You can usually find the source files for the zlib utility wherever you -find the libpng source files. - -Libpng is thread safe, provided the threads are using different -instances of the structures. Each thread should have its own -png_struct and png_info instances, and thus its own image. -Libpng does not protect itself against two threads using the -same instance of a structure. - - -II. Structures - -There are two main structures that are important to libpng, png_struct -and png_info. The first, png_struct, is an internal structure that -will not, for the most part, be used by a user except as the first -variable passed to every libpng function call. - -The png_info structure is designed to provide information about the -PNG file. At one time, the fields of png_info were intended to be -directly accessible to the user. However, this tended to cause problems -with applications using dynamically loaded libraries, and as a result -a set of interface functions for png_info (the png_get_*() and png_set_*() -functions) was developed. The fields of png_info are still available for -older applications, but it is suggested that applications use the new -interfaces if at all possible. - -Applications that do make direct access to the members of png_struct (except -for png_ptr->jmpbuf) must be recompiled whenever the library is updated, -and applications that make direct access to the members of png_info must -be recompiled if they were compiled or loaded with libpng version 1.0.6, -in which the members were in a different order. In version 1.0.7, the -members of the png_info structure reverted to the old order, as they were -in versions 0.97c through 1.0.5. Starting with version 2.0.0, both -structures are going to be hidden, and the contents of the structures will -only be accessible through the png_get/png_set functions. - -The png.h header file is an invaluable reference for programming with libpng. -And while I'm on the topic, make sure you include the libpng header file: - -#include - -III. Reading - -We'll now walk you through the possible functions to call when reading -in a PNG file sequentially, briefly explaining the syntax and purpose -of each one. See example.c and png.h for more detail. While -progressive reading is covered in the next section, you will still -need some of the functions discussed in this section to read a PNG -file. - -Setup - -You will want to do the I/O initialization(*) before you get into libpng, -so if it doesn't work, you don't have much to undo. Of course, you -will also want to insure that you are, in fact, dealing with a PNG -file. Libpng provides a simple check to see if a file is a PNG file. -To use it, pass in the first 1 to 8 bytes of the file to the function -png_sig_cmp(), and it will return 0 if the bytes match the corresponding -bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes -you pass in, the greater the accuracy of the prediction. - -If you are intending to keep the file pointer open for use in libpng, -you must ensure you don't read more than 8 bytes from the beginning -of the file, and you also have to make a call to png_set_sig_bytes_read() -with the number of bytes you read from the beginning. Libpng will -then only check the bytes (if any) that your program didn't read. - -(*): If you are not using the standard I/O functions, you will need -to replace them with custom functions. See the discussion under -Customizing libpng. - - - FILE *fp = fopen(file_name, "rb"); - if (!fp) - { - return (ERROR); - } - fread(header, 1, number, fp); - is_png = !png_sig_cmp(header, 0, number); - if (!is_png) - { - return (NOT_PNG); - } - - -Next, png_struct and png_info need to be allocated and initialized. In -order to ensure that the size of these structures is correct even with a -dynamically linked libpng, there are functions to initialize and -allocate the structures. We also pass the library version, optional -pointers to error handling functions, and a pointer to a data struct for -use by the error functions, if necessary (the pointer and functions can -be NULL if the default error handlers are to be used). See the section -on Changes to Libpng below regarding the old initialization functions. -The structure allocation functions quietly return NULL if they fail to -create the structure, so your application should check for that. - - png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, - (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); - } - - png_infop end_info = png_create_info_struct(png_ptr); - if (!end_info) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_read_struct_2() instead of png_create_read_struct(): - - png_structp png_ptr = png_create_read_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -The error handling routines passed to png_create_read_struct() -and the memory alloc/free routines passed to png_create_struct_2() -are only necessary if you are not using the libpng supplied error -handling and memory alloc/free functions. - -When libpng encounters an error, it expects to longjmp back -to your routine. Therefore, you will need to call setjmp and pass -your png_jmpbuf(png_ptr). If you read the file from different -routines, you will need to update the jmpbuf field every time you enter -a new routine that will call a png_*() function. - -See your documentation of setjmp/longjmp for your compiler for more -information on setjmp/longjmp. See the discussion on libpng error -handling in the Customizing Libpng section below for more information -on the libpng error handling. If an error occurs, and libpng longjmp's -back to your setjmp, you will want to call png_destroy_read_struct() to -free any memory. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - fclose(fp); - return (ERROR); - } - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the input code. The default for libpng is to -use the C function fread(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. If you wish to handle reading data in another -way, you need not call the png_init_io() function, but you must then -implement the libpng I/O methods discussed in the Customizing Libpng -section below. - - png_init_io(png_ptr, fp); - -If you had previously opened the file and read any of the signature from -the beginning in order to see if this was a PNG file, you need to let -libpng know that there are some bytes missing from the start of the file. - - png_set_sig_bytes(png_ptr, number); - -Setting up callback code - -You can set up a callback function to handle any unknown chunks in the -input stream. You must supply the function - - read_chunk_callback(png_ptr ptr, - png_unknown_chunkp chunk); - { - /* The unknown chunk structure contains your - chunk data: */ - png_byte name[5]; - png_byte *data; - png_size_t size; - /* Note that libpng has already taken care of - the CRC handling */ - - /* put your code here. Return one of the - following: */ - - return (-n); /* chunk had an error */ - return (0); /* did not recognize */ - return (n); /* success */ - } - -(You can give your function another name that you like instead of -"read_chunk_callback") - -To inform libpng about your function, use - - png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, - read_chunk_callback); - -This names not only the callback function, but also a user pointer that -you can retrieve with - - png_get_user_chunk_ptr(png_ptr); - -At this point, you can set up a callback function that will be -called after each row has been read, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void read_row_callback(png_ptr ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "read_row_callback") - -To inform libpng about your function, use - - png_set_read_status_fn(png_ptr, read_row_callback); - -Unknown-chunk handling - -Now you get to set the way the library processes unknown chunks in the -input PNG stream. Both known and unknown chunks will be read. Normal -behavior is that known chunks will be parsed into information in -various info_ptr members; unknown chunks will be discarded. To change -this, you can call: - - png_set_keep_unknown_chunks(png_ptr, info_ptr, keep, - chunk_list, num_chunks); - keep - 0: do not keep - 1: keep only if safe-to-copy - 2: keep even if unsafe-to-copy - chunk_list - list of chunks affected (a byte string, - five bytes per chunk, NULL or '\0' if - num_chunks is 0) - num_chunks - number of chunks affected; if 0, all - unknown chunks are affected - -Unknown chunks declared in this way will be saved as raw data onto a -list of png_unknown_chunk structures. If a chunk that is normally -known to libpng is named in the list, it will be handled as unknown, -according to the "keep" directive. If a chunk is named in successive -instances of png_set_keep_unknown_chunks(), the final instance will -take precedence. - -The high-level read interface - -At this point there are two ways to proceed; through the high-level -read interface, or through a sequence of low-level read operations. -You can use the high-level interface if (a) you are willing to read -the entire image into memory, and (b) the input transformations -you want to do are limited to the following set: - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to - 8 bits - PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel - PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit - samples to bytes - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_EXPAND Perform set_expand() - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - -(This excludes setting a background color, doing gamma transformation, -dithering, and setting filler.) If this is the case, simply do this: - - png_read_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the logical OR of -some set of transformation flags. This call is equivalent to png_read_info(), -followed the set of transformations indicated by the transform mask, -then png_read_image(), and finally png_read_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future input transform.) - -After you have called png_read_png(), you can retrieve the image data -with - - row_pointers = png_get_rows(png_ptr, info_ptr); - -where row_pointers is an array of pointers to the pixel data for each row: - - png_bytep row_pointers[height]; - -If you know your image size and pixel size ahead of time, you can allocate -row_pointers prior to calling png_read_png() with - - row_pointers = png_malloc(png_ptr, - height*sizeof(png_bytep)); - for (int i=0; i) and -png_get_(png_ptr, info_ptr, ...) functions return non-zero if the -data has been read, or zero if it is missing. The parameters to the -png_get_ are set directly if they are simple data types, or a pointer -into the info_ptr is returned for any complex types. - - png_get_PLTE(png_ptr, info_ptr, &palette, - &num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_get_gAMA(png_ptr, info_ptr, &gamma); - gamma - the gamma the file is written - at (PNG_INFO_gAMA) - - png_get_sRGB(png_ptr, info_ptr, &srgb_intent); - srgb_intent - the rendering intent (PNG_INFO_sRGB) - The presence of the sRGB chunk - means that the pixel data is in the - sRGB color space. This chunk also - implies specific values of gAMA and - cHRM. - - png_get_iCCP(png_ptr, info_ptr, &name, - &compression_type, &profile, &proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, - red, green, and blue channels, - whichever are appropriate for the - given color type (png_color_16) - - png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, - &trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_get_hIST(png_ptr, info_ptr, &hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_get_tIME(png_ptr, info_ptr, &mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_get_bKGD(png_ptr, info_ptr, &background); - background - background color (PNG_VALID_bKGD) - valid 16-bit red, green and blue - values, regardless of color_type - - num_comments = png_get_text(png_ptr, info_ptr, - &text_ptr, &num_text); - num_comments - number of comments - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (empty - string for unknown). - text_ptr[i].translated_keyword - keyword in UTF-8 - (empty string for unknown). - num_text - number of comments (same as - num_comments; you can put NULL here - to avoid the duplication) - Note while png_set_text() will accept text, language, - and translated keywords that can be NULL pointers, the - structure returned by png_get_text will always contain - regular zero-terminated C strings. They might be - empty strings but they will never be NULL pointers. - - num_spalettes = png_get_sPLT(png_ptr, info_ptr, - &palette_ptr); - palette_ptr - array of palette structures holding - contents of one or more sPLT chunks - read. - num_spalettes - number of sPLT chunks read. - - png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, - &unit_type); - offset_x - positive offset from the left edge - of the screen - offset_y - positive offset from the top edge - of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, - &unit_type); - res_x - pixels/unit physical resolution in - x direction - res_y - pixels/unit physical resolution in - x direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_get_sCAL(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - num_unknown_chunks = png_get_unknown_chunks(png_ptr, - info_ptr, &unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position of chunk in file - - The value of "i" corresponds to the order in which the - chunks were read from the PNG file or inserted with the - png_set_unknown_chunks() function. - -The data from the pHYs chunk can be retrieved in several convenient -forms: - - res_x = png_get_x_pixels_per_meter(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_meter(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_meter(png_ptr, - info_ptr) - res_x = png_get_x_pixels_per_inch(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_inch(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_inch(png_ptr, - info_ptr) - aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, - info_ptr) - - (Each of these returns 0 [signifying "unknown"] if - the data is not present or if res_x is 0; - res_x_and_y is 0 if res_x != res_y) - -The data from the oFFs chunk can be retrieved in several convenient -forms: - - x_offset = png_get_x_offset_microns(png_ptr, info_ptr); - y_offset = png_get_y_offset_microns(png_ptr, info_ptr); - x_offset = png_get_x_offset_inches(png_ptr, info_ptr); - y_offset = png_get_y_offset_inches(png_ptr, info_ptr); - - (Each of these returns 0 [signifying "unknown" if both - x and y are 0] if the data is not present or if the - chunk is present but the unit is the pixel) - -For more information, see the png_info definition in png.h and the -PNG specification for chunk contents. Be careful with trusting -rowbytes, as some of the transformations could increase the space -needed to hold a row (expand, filler, gray_to_rgb, etc.). -See png_read_update_info(), below. - -A quick word about text_ptr and num_text. PNG stores comments in -keyword/text pairs, one pair per chunk, with no limit on the number -of text chunks, and a 2^31 byte limit on their size. While there are -suggested keywords, there is no requirement to restrict the use to these -strings. It is strongly suggested that keywords and text be sensible -to humans (that's the point), so don't use abbreviations. Non-printing -symbols are not allowed. See the PNG specification for more details. -There is also no requirement to have text after the keyword. - -Keywords should be limited to 79 Latin-1 characters without leading or -trailing spaces, but non-consecutive spaces are allowed within the -keyword. It is possible to have the same keyword any number of times. -The text_ptr is an array of png_text structures, each holding a -pointer to a language string, a pointer to a keyword and a pointer to -a text string. The text string, language code, and translated -keyword may be empty or NULL pointers. The keyword/text -pairs are put into the array in the order that they are received. -However, some or all of the text chunks may be after the image, so, to -make sure you have read all the text chunks, don't mess with these -until after you read the stuff after the image. This will be -mentioned again below in the discussion that goes with png_read_end(). - -Input transformations - -After you've read the header information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -The colors used for the background and transparency values should be -supplied in the same format/depth as the current image data. They -are stored in the same format/depth as the image data in a bKGD or tRNS -chunk, so this is what libpng expects for this data. The colors are -transformed to keep in sync with the image data when an application -calls the png_read_update_info() routine (see below). - -Data will be decoded into the supplied row buffers packed into bytes -unless the library has been told to transform it into another format. -For example, 4 bit/pixel paletted or grayscale data will be returned -2 pixels/byte with the leftmost pixel in the high-order bits of the -byte, unless png_set_packing() is called. 8-bit RGB data will be stored -in RGB RGB RGB format unless png_set_filler() is called to insert filler -bytes, either before or after each RGB triplet. 16-bit RGB data will -be returned RRGGBB RRGGBB, with the most significant byte of the color -value first, unless png_set_strip_16() is called to transform it to -regular RGB RGB triplets, or png_set_filler() is called to insert -filler bytes, either before or after each RRGGBB triplet. Similarly, -8-bit or 16-bit grayscale data can be modified with png_set_filler() -or png_set_strip_16(). - -The following code transforms grayscale images of less than 8 to 8 bits, -changes paletted images to RGB, and adds a full alpha channel if there is -transparency information in a tRNS chunk. This is most useful on -grayscale images with bit depths of 2 or 4 or if there is a multiple-image -viewing application that wishes to treat all images in the same way. - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && - bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); - -These three functions are actually aliases for png_set_expand(), added -in libpng version 1.0.4, with the function names expanded to improve code -readability. In some future version they may actually do different -things. - -PNG can have files with 16 bits per channel. If you only can handle -8 bits per channel, this will strip the pixels down to 8 bit. - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - -If, for some reason, you don't need the alpha channel on an image, -and you want to remove it rather than combining it with the background -(but the image author certainly had in mind that you *would* combine -it with the background, so that's what you should probably do): - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_strip_alpha(png_ptr); - -In PNG files, the alpha channel in an image -is the level of opacity. If you need the alpha channel in an image to -be the level of transparency instead of opacity, you can invert the -alpha channel (or the tRNS chunk data) after it's read, so that 0 is -fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit -images) is fully transparent, with - - png_set_invert_alpha(png_ptr); - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit -files. This code expands to 1 pixel per byte without changing the -values of the pixels: - - if (bit_depth < 8) - png_set_packing(png_ptr); - -PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels -stored in a PNG image have been "scaled" or "shifted" up to the next -higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to -8 bits/sample in the range [0, 255]). However, it is also possible to -convert the PNG pixel data back to the original bit depth of the image. -This call reduces the pixels back down to the original bit depth: - - png_color_16p sig_bit; - - if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) - png_set_shift(png_ptr, sig_bit); - -PNG files store 3-color pixels in red, green, blue order. This code -changes the storage of the pixels to blue, green, red: - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_bgr(png_ptr); - -PNG files store RGB pixels packed into 3 bytes. This code expands them -into 4 bytes for windowing systems that need them in this format: - - if (bit_depth == 8 && color_type == - PNG_COLOR_TYPE_RGB) png_set_filler(png_ptr, - filler, PNG_FILLER_BEFORE); - -where "filler" is the 8 or 16-bit number to fill with, and the location is -either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether -you want the filler before the RGB or after. This transformation -does not affect images that already have full alpha channels. - -If you are reading an image with an alpha channel, and you need the -data as ARGB instead of the normal PNG format RGBA: - - if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_swap_alpha(png_ptr); - -For some uses, you may want a grayscale image to be represented as -RGB. This code will do that conversion: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - -Conversely, you can convert an RGB or RGBA image to grayscale or grayscale -with alpha. - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_rgb_to_gray_fixed(png_ptr, error_action, - int red_weight, int green_weight); - - error_action = 1: silently do the conversion - error_action = 2: issue a warning if the original - image has any pixel where - red != green or red != blue - error_action = 3: issue an error and abort the - conversion if the original - image has any pixel where - red != green or red != blue - - red_weight: weight of red component times 100000 - green_weight: weight of green component times 100000 - If either weight is negative, default - weights (21268, 71514) are used. - -If you have set error_action = 1 or 2, you can -later check whether the image really was gray, after processing -the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. -It will return a png_byte that is zero if the image was gray or -1 if there were any non-gray pixels. bKGD and sBIT data -will be silently converted to grayscale, using the green channel -data, regardless of the error_action setting. - -With red_weight+green_weight<=100000, -the normalized graylevel is computed: - - int rw = red_weight * 65536; - int gw = green_weight * 65536; - int bw = 65536 - (rw + gw); - gray = (rw*red + gw*green + bw*blue)/65536; - -The default values approximate those recommended in the Charles -Poynton's Color FAQ, -Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net - - Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - -Libpng approximates this with - - Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - -which can be expressed with integers as - - Y = (6969 * R + 23434 * G + 2365 * B)/32768 - -The calculation is done in a linear colorspace, if the image gamma -is known. - -If you have a grayscale and you are using png_set_expand_depth() or -png_set_expand() to change to -a higher bit-depth, you must either supply the background color as a gray -value at the original file bit-depth (need_expand = 1) or else supply the -background color as an RGB triplet at the final, expanded bit depth -(need_expand = 0). Similarly, if you are reading a paletted image, you -must either supply the background color as a palette index (need_expand = 1) -or as an RGB triplet that may or may not be in the palette (need_expand = 0). - - png_color_16 my_background; - png_color_16p image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - -The png_set_background() function tells libpng to composite images -with alpha or simple transparency against the supplied background -color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), -you may use this color, or supply another color more suitable for -the current display (e.g., the background color from a web page). You -need to tell libpng whether the color is in the gamma space of the -display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file -(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one -that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't -know why anyone would use this, but it's here). - -To properly display PNG images on any kind of system, the application needs -to know what the display gamma is. Ideally, the user will know this, and -the application will allow them to set it. One method of allowing the user -to set the display gamma separately for each system is to check for a -SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be -correctly set. - -Note that display_gamma is the overall gamma correction required to produce -pleasing results, which depends on the lighting conditions in the surrounding -environment. In a dim or brightly lit room, no compensation other than -the physical gamma exponent of the monitor is needed, while in a dark room -a slightly smaller exponent is better. - - double gamma, screen_gamma; - - if (/* We have a user-defined screen - gamma value */) - { - screen_gamma = user_defined_screen_gamma; - } - /* One way that applications can share the same - screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) - != NULL) - { - screen_gamma = (double)atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a - PC monitor in a bright office or a dim room */ - screen_gamma = 2.0; /* A good guess for a - PC monitor in a dark room */ - screen_gamma = 1.7 or 1.0; /* A good - guess for Mac systems */ - } - -The png_set_gamma() function handles gamma transformations of the data. -Pass both the file gamma and the current screen_gamma. If the file does -not have a gamma value, you can pass one anyway if you have an idea what -it is (usually 0.45455 is a good guess for GIF images on PCs). Note -that file gammas are inverted from screen gammas. See the discussions -on gamma in the PNG specification for an excellent description of what -gamma is, and why all applications should support it. It is strongly -recommended that PNG viewers support gamma correction. - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - -If you need to reduce an RGB file to a paletted file, or if a paletted -file has more entries then will fit on your screen, png_set_dither() -will do that. Note that this is a simple match dither that merely -finds the closest color available. This should work fairly well with -optimized palettes, and fairly badly with linear color cubes. If you -pass a palette that is larger then maximum_colors, the file will -reduce the number of colors in the palette so it will fit into -maximum_colors. If there is a histogram, it will use it to make -more intelligent choices when reducing the palette. If there is no -histogram, it may not do as good a job. - - if (color_type & PNG_COLOR_MASK_COLOR) - { - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_PLTE)) - { - png_uint_16p histogram; - - png_get_hIST(png_ptr, info_ptr, - &histogram); - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 1); - } - else - { - png_color std_color_cube[MAX_SCREEN_COLORS] = - { ... colors ... }; - - png_set_dither(png_ptr, std_color_cube, - MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, - NULL,0); - } - } - -PNG files describe monochrome as black being zero and white being one. -The following code will reverse this (make black be one and white be -zero): - - if (bit_depth == 1 && color_type == PNG_COLOR_GRAY) - png_set_invert_mono(png_ptr); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code changes the storage to the -other way (little-endian, i.e. least significant bits first, the -way PCs store them): - - if (bit_depth == 16) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_read_user_transform_fn(png_ptr, - read_transform_fn); - -You must supply the function - - void read_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -after all of the other transformations have been processed. - -You can also set up a pointer to a user structure for use by your -callback function, and you can inform libpng that your transform -function will change the number of channels or bit depth with the -function - - png_set_user_transform_info(png_ptr, user_ptr, - user_depth, user_channels); - -The user's application, not libpng, is responsible for allocating and -freeing any memory required for the user structure. - -You can retrieve the pointer via the function -png_get_user_transform_ptr(). For example: - - voidp read_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -The last thing to handle is interlacing; this is covered in detail below, -but you must call the function here if you want libpng to handle expansion -of the interlaced image. - - number_of_passes = png_set_interlace_handling(png_ptr); - -After setting the transformations, libpng can update your png_info -structure to reflect any transformations you've requested with this -call. This is most useful to update the info structure's rowbytes -field so you can use it to allocate your image memory. This function -will also update your palette with the correct screen_gamma and -background if these have been given with the calls above. - - png_read_update_info(png_ptr, info_ptr); - -After you call png_read_update_info(), you can allocate any -memory you need to hold the image. The row data is simply -raw byte data for all forms of images. As the actual allocation -varies among applications, no example will be given. If you -are allocating one large chunk, you will need to build an -array of pointers to each row, as it will be needed for some -of the functions below. - -Reading image data - -After you've allocated memory, you can read the image data. -The simplest way to do this is in one function call. If you are -allocating enough memory to hold the whole image, you can just -call png_read_image() and libpng will read in all the image data -and put it in the memory area supplied. You will need to pass in -an array of pointers to each row. - -This function automatically handles interlacing, so you don't need -to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_read_rows(). - - png_read_image(png_ptr, row_pointers); - -where row_pointers is: - - png_bytep row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to read in the whole image at once, you can -use png_read_rows() instead. If there is no interlacing (check -interlace_type == PNG_INTERLACE_NONE), this is simple: - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -where row_pointers is the same as in the png_read_image() call. - -If you are doing this just one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - png_read_row(png_ptr, row_pointer, NULL); - -If the file is interlaced (interlace_type != 0 in the IHDR chunk), things -get somewhat harder. The only current (PNG Specification version 1.2) -interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) -is a somewhat complicated 2D interlace scheme, known as Adam7, that -breaks down an image into seven smaller images of varying size, based -on an 8x8 grid. - -libpng can fill out those images or it can give them to you "as is". -If you want them filled out, there are two ways to do that. The one -mentioned in the PNG specification is to expand each pixel to cover -those pixels that have not been read yet (the "rectangle" method). -This results in a blocky image for the first pass, which gradually -smooths out as more pixels are read. The other method is the "sparkle" -method, where pixels are drawn only in their final locations, with the -rest of the image remaining whatever colors they were initialized to -before the start of the read. The first method usually looks better, -but tends to be slower, as there are more pixels to put in the rows. - -If you don't want libpng to handle the interlacing details, just call -png_read_rows() seven times to read in all seven images. Each of the -images is a valid image by itself, or they can all be combined on an -8x8 grid to form a single image (although if you intend to combine them -you would be far better off using the libpng interlace handling). - -The first pass will return an image 1/8 as wide as the entire image -(every 8th column starting in column 0) and 1/8 as high as the original -(every 8th row starting in row 0), the second will be 1/8 as wide -(starting in column 4) and 1/8 as high (also starting in row 0). The -third pass will be 1/4 as wide (every 4th pixel starting in column 0) and -1/8 as high (every 8th row starting in row 4), and the fourth pass will -be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, -and every 4th row starting in row 0). The fifth pass will return an -image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), -while the sixth pass will be 1/2 as wide and 1/2 as high as the original -(starting in column 1 and row 0). The seventh and final pass will be as -wide as the original, and 1/2 as high, containing all of the odd -numbered scanlines. Phew! - -If you want libpng to expand the images, call this before calling -png_start_read_image() or png_read_update_info(): - - if (interlace_type == PNG_INTERLACE_ADAM7) - number_of_passes - = png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. -This function can be called even if the file is not interlaced, -where it will return one pass. - -If you are not going to display the image after each pass, but are -going to wait until the entire image is read in, use the sparkle -effect. This effect is faster and the end result of either method -is exactly the same. If you are planning on displaying the image -after each pass, the "rectangle" effect is generally considered the -better looking one. - -If you only want the "sparkle" effect, just call png_read_rows() as -normal, with the third parameter NULL. Make sure you make pass over -the image number_of_passes times, and you don't change the data in the -rows between calls. You can change the locations of the data, just -not the data. Each pass only writes the pixels appropriate for that -pass, and assumes the data from previous passes is still valid. - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -If you only want the first effect (the rectangles), do the same as -before except pass the row buffer in the third parameter, and leave -the second parameter NULL. - - png_read_rows(png_ptr, NULL, row_pointers, - number_of_rows); - -Finishing a sequential read - -After you are finished reading the image through either the high- or -low-level interfaces, you can finish reading the file. If you are -interested in comments or time, which may be stored either before or -after the image data, you should pass the separate png_info struct if -you want to keep the comments from before and after the image -separate. If you are not interested, you can pass NULL. - - png_read_end(png_ptr, end_info); - -When you are done, you can free all memory allocated by libpng like this: - - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the logical OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -This function only affects data that has already been allocated. -You can call this function after reading the PNG data but before calling -any png_set_*() functions, to control whether the user or the png_set_*() -function is responsible for freeing any existing data that might be present, -and again after the png_set_*() functions to control whether the user -or png_destroy_*() is supposed to free the data. When the user assumes -responsibility for libpng-allocated data, the application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated your row_pointers in a single block, as suggested above in -the description of the high level read interface, you must not transfer -responsibility for freeing it to the png_set_rows or png_read_destroy function, -because they would also try to free the individual row_pointers[i]. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. - -The png_free_data() function will turn off the "valid" flag for anything -it frees. If you need to turn the flag off for a chunk that was freed by your -application instead of by libpng, you can use - - png_set_invalid(png_ptr, info_ptr, mask); - mask - identifies the chunks to be made invalid, - containing the logical OR of one or - more of - PNG_INFO_gAMA, PNG_INFO_sBIT, - PNG_INFO_cHRM, PNG_INFO_PLTE, - PNG_INFO_tRNS, PNG_INFO_bKGD, - PNG_INFO_hIST, PNG_INFO_pHYs, - PNG_INFO_oFFs, PNG_INFO_tIME, - PNG_INFO_pCAL, PNG_INFO_sRGB, - PNG_INFO_iCCP, PNG_INFO_sPLT, - PNG_INFO_sCAL, PNG_INFO_IDAT - -For a more compact example of reading a PNG image, see the file example.c. - -Reading PNG files progressively - -The progressive reader is slightly different then the non-progressive -reader. Instead of calling png_read_info(), png_read_rows(), and -png_read_end(), you make one call to png_process_data(), which calls -callbacks when it has the info, a row, or the end of the image. You -set up these callbacks with png_set_progressive_read_fn(). You don't -have to worry about the input/output functions of libpng, as you are -giving the library the data directly in png_process_data(). I will -assume that you have read the section on reading PNG files above, -so I will only highlight the differences (although I will show -all of the code). - -png_structp png_ptr; -png_infop info_ptr; - - /* An example code fragment of how you would - initialize the progressive reader in your - application. */ - int - initialize_png_reader() - { - png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, - (png_infopp)NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new. You can provide functions - to be called when the header info is valid, - when each row is completed, and when the image - is finished. If you aren't using all functions, - you can specify NULL parameters. Even when all - three functions are NULL, you need to call - png_set_progressive_read_fn(). You can use - any struct as the user_ptr (cast to a void pointer - for the function call), and retrieve the pointer - from inside the callbacks using the function - - png_get_progressive_ptr(png_ptr); - - which will return a void pointer, which you have - to cast appropriately. - */ - png_set_progressive_read_fn(png_ptr, (void *)user_ptr, - info_callback, row_callback, end_callback); - - return 0; - } - - /* A code fragment that you call as you receive blocks - of data */ - int - process_data(png_bytep buffer, png_uint_32 length) - { - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new also. Simply give it a chunk - of data from the file stream (in order, of - course). On machines with segmented memory - models machines, don't give it any more than - 64K. The library seems to run fine with sizes - of 4K. Although you can give it much less if - necessary (I assume you can give it chunks of - 1 byte, I haven't tried less then 256 bytes - yet). When this function returns, you may - want to display any rows that were generated - in the row callback if you don't already do - so there. - */ - png_process_data(png_ptr, info_ptr, buffer, length); - return 0; - } - - /* This function is called (as set by - png_set_progressive_read_fn() above) when enough data - has been supplied so all of the header has been - read. - */ - void - info_callback(png_structp png_ptr, png_infop info) - { - /* Do any setup here, including setting any of - the transformations mentioned in the Reading - PNG files section. For now, you _must_ call - either png_start_read_image() or - png_read_update_info() after all the - transformations are set (even if you don't set - any). You may start getting rows before - png_process_data() returns, so this is your - last chance to prepare for that. - */ - } - - /* This function is called when each row of image - data is complete */ - - void - row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) - { - /* If the image is interlaced, and you turned - on the interlace handler, this function will - be called for every row in every pass. Some - of these rows will not be changed from the - previous pass. When the row is not changed, - the new_row variable will be NULL. The rows - and passes are called in order, so you don't - really need the row_num and pass, but I'm - supplying them because it may make your life - easier. - - For the non-NULL rows of interlaced images, - you must call png_progressive_combine_row() - passing in the row and the old row. You can - call this function for NULL rows (it will just - return) and for non-interlaced images (it just - does the memcpy for you) if it will make the - code easier. Thus, you can just do this for - all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, - new_row); - - /* where old_row is what was displayed for - previously for the row. Note that the first - pass (pass == 0, really) will completely cover - the old row, so the rows do not have to be - initialized. After the first pass (and only - for interlaced images), you will have to pass - the current row, and the function will combine - the old row and the new row. - */ - } - - void - end_callback(png_structp png_ptr, png_infop info) - { - /* This function is called after the whole image - has been read, including any chunks after the - image (up to and including the IEND). You - will usually have the same info chunk as you - had in the header, although some data may have - been added to the comments and time fields. - - Most people won't do much here, perhaps setting - a flag that marks the image as finished. - */ - } - - - -IV. Writing - -Much of this is very similar to reading. However, everything of -importance is repeated here, so you won't have to constantly look -back up in the reading section to understand writing. - -Setup - -You will want to do the I/O initialization before you get into libpng, -so if it doesn't work, you don't have anything to undo. If you are not -using the standard I/O functions, you will need to replace them with -custom writing functions. See the discussion under Customizing libpng. - - FILE *fp = fopen(file_name, "wb"); - if (!fp) - { - return (ERROR); - } - -Next, png_struct and png_info need to be allocated and initialized. -As these can be both relatively large, you may not want to store these -on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. If you are also reading, -you won't want to name your read structure and your write structure -both "png_ptr"; you can call them anything you like, such as -"read_ptr" and "write_ptr". Look at pngtest.c, for example. - - png_structp png_ptr = png_create_write_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_write_struct_2() instead of png_create_write_struct(): - - png_structp png_ptr = png_create_write_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -After you have these structures, you will need to set up the -error handling. When libpng encounters an error, it expects to -longjmp() back to your routine. Therefore, you will need to call -setjmp() and pass the png_jmpbuf(png_ptr). If you -write the file from different routines, you will need to update -the png_jmpbuf(png_ptr) every time you enter a new routine that will -call a png_*() function. See your documentation of setjmp/longjmp -for your compiler for more information on setjmp/longjmp. See -the discussion on libpng error handling in the Customizing Libpng -section below for more information on the libpng error handling. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - return (ERROR); - } - ... - return; - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the output code. The default for libpng is to -use the C function fwrite(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. Again, if you wish to handle writing data in -another way, see the discussion on libpng I/O handling in the Customizing -Libpng section below. - - png_init_io(png_ptr, fp); - -Write callbacks - -At this point, you can set up a callback function that will be -called after each row has been written, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void write_row_callback(png_ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "write_row_callback") - -To inform libpng about your function, use - - png_set_write_status_fn(png_ptr, write_row_callback); - -You now have the option of modifying how the compression library will -run. The following functions are mainly for testing, but may be useful -in some cases, like if you need to write PNG files extremely fast and -are willing to give up some compression, or if you want to get the -maximum possible compression at the expense of slower writing. If you -have no special needs in this area, let the library do what it wants by -not calling this function at all, as it has been tuned to deliver a good -speed/compression ratio. The second parameter to png_set_filter() is -the filter method, for which the only valid values are 0 (as of the -July 1999 PNG specification, version 1.2) or 64 (if you are writing -a PNG datastream that is to be embedded in a MNG datastream). The third -parameter is a flag that indicates which filter type(s) are to be tested -for each scanline. See the PNG specification for details on the specific filter -types. - - - /* turn on or off filtering, and/or choose - specific filters. You can use either a single - PNG_FILTER_VALUE_NAME or the logical OR of one - or more PNG_FILTER_NAME masks. */ - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); - -If an application -wants to start and stop using particular filters during compression, -it should start out with all of the filters (to ensure that the previous -row of pixels will be stored in case it's needed later), and then add -and remove them after the start of compression. - -If you are writing a PNG datastream that is to be embedded in a MNG -datastream, the second parameter can be either 0 or 64. - -The png_set_compression_*() functions interface to the zlib compression -library, and should mostly be ignored unless you really know what you are -doing. The only generally useful call is png_set_compression_level() -which changes how much time zlib spends on trying to compress the image -data. See the Compression Library (zlib.h and algorithm.txt, distributed -with zlib) for details on the compression levels. - - /* set the zlib compression level */ - png_set_compression_level(png_ptr, - Z_BEST_COMPRESSION); - - /* set other zlib parameters */ - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_strategy(png_ptr, - Z_DEFAULT_STRATEGY); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - png_set_compression_buffer_size(png_ptr, 8192) - -extern PNG_EXPORT(void,png_set_zbuf_size) - -Setting the contents of info for output - -You now need to fill in the png_info structure with all the data you -wish to write before the actual image. Note that the only thing you -are allowed to write after the image is the text chunks and the time -chunk (as of PNG Specification 1.2, anyway). See png_write_end() and -the latest PNG specification for more information on that. If you -wish to write them before the image, fill them in now, and flag that -data as being valid. If you want to wait until after the data, don't -fill them until png_write_end(). For all the fields in png_info and -their data types, see png.h. For explanations of what the fields -contain, see the PNG specification. - -Some of the more important parts of the png_info are: - - png_set_IHDR(png_ptr, info_ptr, width, height, - bit_depth, color_type, interlace_type, - compression_type, filter_method) - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. - (valid values are 1, 2, 4, 8, 16 - and depend also on the - color_type. See also significant - bits (sBIT) below). - color_type - describes which color/alpha - channels are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - interlace_type - PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7 - compression_type - (must be - PNG_COMPRESSION_TYPE_DEFAULT) - filter_method - (must be PNG_FILTER_TYPE_DEFAULT - or, if you are writing a PNG to - be embedded in a MNG datastream, - can also be - PNG_INTRAPIXEL_DIFFERENCING) - - png_set_PLTE(png_ptr, info_ptr, palette, - num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_set_gAMA(png_ptr, info_ptr, gamma); - gamma - the gamma the image was created - at (PNG_INFO_gAMA) - - png_set_sRGB(png_ptr, info_ptr, srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of - the sRGB chunk means that the pixel - data is in the sRGB color space. - This chunk also implies specific - values of gAMA and cHRM. Rendering - intent is the CSS-1 property that - has been defined by the International - Color Consortium - (http://www.color.org). - It can be one of - PNG_sRGB_INTENT_SATURATION, - PNG_sRGB_INTENT_PERCEPTUAL, - PNG_sRGB_INTENT_ABSOLUTE, or - PNG_sRGB_INTENT_RELATIVE. - - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, - srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of the - sRGB chunk means that the pixel - data is in the sRGB color space. - This function also causes gAMA and - cHRM chunks with the specific values - that are consistent with sRGB to be - written. - - png_set_iCCP(png_ptr, info_ptr, name, compression_type, - profile, proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_set_sBIT(png_ptr, info_ptr, sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, red, - green, and blue channels, whichever are - appropriate for the given color type - (png_color_16) - - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, - trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_set_hIST(png_ptr, info_ptr, hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_set_tIME(png_ptr, info_ptr, mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_set_bKGD(png_ptr, info_ptr, background); - background - background color (PNG_VALID_bKGD) - - png_set_text(png_ptr, info_ptr, text_ptr, num_text); - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be NULL or empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (NULL or - empty for unknown). - text_ptr[i].translated_keyword - keyword in UTF-8 (NULL - or empty for unknown). - num_text - number of comments - - png_set_sPLT(png_ptr, info_ptr, &palette_ptr, - num_spalettes); - palette_ptr - array of png_sPLT_struct structures - to be added to the list of palettes - in the info structure. - num_spalettes - number of palette structures to be - added. - - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, - unit_type); - offset_x - positive offset from the left - edge of the screen - offset_y - positive offset from the top - edge of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, - unit_type); - res_x - pixels/unit physical resolution - in x direction - res_y - pixels/unit physical resolution - in y direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_set_sCAL(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, - num_unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position to write chunk in file - 0: do not write chunk - PNG_HAVE_IHDR: before PLTE - PNG_HAVE_PLTE: before IDAT - PNG_AFTER_IDAT: after IDAT - -The "location" member is set automatically according to -what part of the output file has already been written. -You can change its value after calling png_set_unknown_chunks() -as demonstrated in pngtest.c. Within each of the "locations", -the chunks are sequenced according to their position in the -structure (that is, the value of "i", which is the order in which -the chunk was either read from the input file or defined with -png_set_unknown_chunks). - -A quick word about text and num_text. text is an array of png_text -structures. num_text is the number of valid structures in the array. -Each png_text structure holds a language code, a keyword, a text value, -and a compression type. - -The compression types have the same valid numbers as the compression -types of the image data. Currently, the only valid number is zero. -However, you can store text either compressed or uncompressed, unlike -images, which always have to be compressed. So if you don't want the -text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. -Because tEXt and zTXt chunks don't have a language field, if you -specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt -any language code or translated keyword will not be written out. - -Until text gets around 1000 bytes, it is not worth compressing it. -After the text has been written out to the file, the compression type -is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, -so that it isn't written out again at the end (in case you are calling -png_write_end() with the same struct. - -The keywords that are given in the PNG Specification are: - - Title Short (one line) title or - caption for image - Author Name of image's creator - Description Description of image (possibly long) - Copyright Copyright notice - Creation Time Time of original image creation - (usually RFC 1123 format, see below) - Software Software used to create the image - Disclaimer Legal disclaimer - Warning Warning of nature of content - Source Device used to create the image - Comment Miscellaneous comment; conversion - from other image format - -The keyword-text pairs work like this. Keywords should be short -simple descriptions of what the comment is about. Some typical -keywords are found in the PNG specification, as is some recommendations -on keywords. You can repeat keywords in a file. You can even write -some text before the image and some after. For example, you may want -to put a description of the image before the image, but leave the -disclaimer until after, so viewers working over modem connections -don't have to wait for the disclaimer to go over the modem before -they start seeing the image. Finally, keywords should be full -words, not abbreviations. Keywords and text are in the ISO 8859-1 -(Latin-1) character set (a superset of regular ASCII) and can not -contain NUL characters, and should not contain control or other -unprintable characters. To make the comments widely readable, stick -with basic ASCII, and avoid machine specific character set extensions -like the IBM-PC character set. The keyword must be present, but -you can leave off the text string on non-compressed pairs. -Compressed pairs must have a text string, as only the text string -is compressed anyway, so the compression would be meaningless. - -PNG supports modification time via the png_time structure. Two -conversion routines are provided, png_convert_from_time_t() for -time_t and png_convert_from_struct_tm() for struct tm. The -time_t routine uses gmtime(). You don't have to use either of -these, but if you wish to fill in the png_time structure directly, -you should provide the time in universal time (GMT) if possible -instead of your local time. Note that the year number is the full -year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and -that months start with 1. - -If you want to store the time of the original image creation, you should -use a plain tEXt chunk with the "Creation Time" keyword. This is -necessary because the "creation time" of a PNG image is somewhat vague, -depending on whether you mean the PNG file, the time the image was -created in a non-PNG format, a still photo from which the image was -scanned, or possibly the subject matter itself. In order to facilitate -machine-readable dates, it is recommended that the "Creation Time" -tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), -although this isn't a requirement. Unlike the tIME chunk, the -"Creation Time" tEXt chunk is not expected to be automatically changed -by the software. To facilitate the use of RFC 1123 dates, a function -png_convert_to_rfc1123(png_timep) is provided to convert from PNG -time to an RFC 1123 format string. - -Writing unknown chunks - -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. - -The high-level write interface - -At this point there are two ways to proceed; through the high-level -write interface, or through a sequence of low-level write operations. -You can use the high-level interface if your image data is present -in the info structure. All defined output -transformations are permitted, enabled by the following masks. - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. - -If you have valid image data in the info structure (you can use -png_set_rows() to put image data in the info structure), simply do this: - - png_write_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the logical OR of some set of -transformation flags. This call is equivalent to png_write_info(), -followed the set of transformations indicated by the transform mask, -then png_write_image(), and finally png_write_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future output transform.) - -The low-level write interface - -If you are going the low-level route instead, you are now ready to -write all the file information up to the actual image data. You do -this with a call to png_write_info(). - - png_write_info(png_ptr, info_ptr); - -Note that there is one transformation you may need to do before -png_write_info(). In PNG files, the alpha channel in an image is the -level of opacity. If your data is supplied as a level of -transparency, you can invert the alpha channel before you write it, so -that 0 is fully transparent and 255 (in 8-bit or paletted images) or -65535 (in 16-bit images) is fully opaque, with - - png_set_invert_alpha(png_ptr); - -This must appear before png_write_info() instead of later with the -other transformations because in the case of paletted images the tRNS -chunk data has to be inverted before the tRNS chunk is written. If -your image is not a paletted image, the tRNS data (which in such cases -represents a single color to be rendered as transparent) won't need to -be changed, and you can safely do this transformation after your -png_write_info() call. - -If you need to write a private chunk that you want to appear before -the PLTE chunk when PLTE is present, you can write the PNG info in -two steps, and insert code to write your own chunk between them: - - png_write_info_before_PLTE(png_ptr, info_ptr); - png_set_unknown_chunks(png_ptr, info_ptr, ...); - png_write_info(png_ptr, info_ptr); - -After you've written the file information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -PNG files store RGB pixels packed into 3 or 6 bytes. This code tells -the library to strip input data that has 4 or 8 bytes per pixel down -to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 -bytes per pixel). - - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - -where the 0 is unused, and the location is either PNG_FILLER_BEFORE or -PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel -is stored XRGB or RGBX. - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit files. -If the data is supplied at 1 pixel per byte, use this code, which will -correctly pack the pixels into a single byte: - - png_set_packing(png_ptr); - -PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your -data is of another bit depth, you can write an sBIT chunk into the -file so that decoders can recover the original data if desired. - - /* Set the true bit depth of the image data */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit.red = true_bit_depth; - sig_bit.green = true_bit_depth; - sig_bit.blue = true_bit_depth; - } - else - { - sig_bit.gray = true_bit_depth; - } - if (color_type & PNG_COLOR_MASK_ALPHA) - { - sig_bit.alpha = true_bit_depth; - } - - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - -If the data is stored in the row buffer in a bit depth other than -one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), -this will scale the values to appear to be the correct bit depth as -is required by PNG. - - png_set_shift(png_ptr, &sig_bit); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code would be used if they are -supplied the other way (little-endian, i.e. least significant bits -first, the way PCs store them): - - if (bit_depth > 8) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -PNG files store 3 color pixels in red, green, blue order. This code -would be used if they are supplied as blue, green, red: - - png_set_bgr(png_ptr); - -PNG files describe monochrome as black being zero and white being -one. This code would be used if the pixels are supplied with this reversed -(black being one and white being zero): - - png_set_invert_mono(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_write_user_transform_fn(png_ptr, - write_transform_fn); - -You must supply the function - - void write_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -before any of the other transformations are processed. - -You can also set up a pointer to a user structure for use by your -callback function. - - png_set_user_transform_info(png_ptr, user_ptr, 0, 0); - -The user_channels and user_depth parameters of this function are ignored -when writing; you can set them to zero as shown. - -You can retrieve the pointer via the function png_get_user_transform_ptr(). -For example: - - voidp write_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -It is possible to have libpng flush any pending output, either manually, -or automatically after a certain number of lines have been written. To -flush the output stream a single time call: - - png_write_flush(png_ptr); - -and to have libpng flush the output stream periodically after a certain -number of scanlines have been written, call: - - png_set_flush(png_ptr, nrows); - -Note that the distance between rows is from the last time png_write_flush() -was called, or the first row of the image if it has never been called. -So if you write 50 lines, and then png_set_flush 25, it will flush the -output on the next scanline, and every 25 lines thereafter, unless -png_write_flush() is called before 25 more lines have been written. -If nrows is too small (less than about 10 lines for a 640 pixel wide -RGB image) the image compression may decrease noticeably (although this -may be acceptable for real-time applications). Infrequent flushing will -only degrade the compression performance by a few percent over images -that do not use flushing. - -Writing the image data - -That's it for the transformations. Now you can write the image data. -The simplest way to do this is in one function call. If you have the -whole image in memory, you can just call png_write_image() and libpng -will write the image. You will need to pass in an array of pointers to -each row. This function automatically handles interlacing, so you don't -need to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_write_rows(). - - png_write_image(png_ptr, row_pointers); - -where row_pointers is: - - png_byte *row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to write the whole image at once, you can -use png_write_rows() instead. If the file is not interlaced, -this is simple: - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -row_pointers is the same as in the png_write_image() call. - -If you are just writing one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - - png_write_row(png_ptr, row_pointer); - -When the file is interlaced, things can get a good deal more -complicated. The only currently (as of the PNG Specification -version 1.2, dated July 1999) defined interlacing scheme for PNG files -is the "Adam7" interlace scheme, that breaks down an -image into seven smaller images of varying size. libpng will build -these images for you, or you can do them yourself. If you want to -build them yourself, see the PNG specification for details of which -pixels to write when. - -If you don't want libpng to handle the interlacing details, just -use png_set_interlace_handling() and call png_write_rows() the -correct number of times to write all seven sub-images. - -If you want libpng to build the sub-images, call this before you start -writing any rows: - - number_of_passes = - png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. - -Then write the complete image number_of_passes times. - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -As some of these rows are not used, and thus return immediately, -you may want to read about interlacing in the PNG specification, -and only update the rows that are actually used. - -Finishing a sequential write - -After you are finished writing the image, you should finish writing -the file. If you are interested in writing comments or time, you should -pass an appropriately filled png_info pointer. If you are not interested, -you can pass NULL. - - png_write_end(png_ptr, info_ptr); - -When you are done, you can free all memory used by libpng like this: - - png_destroy_write_struct(&png_ptr, &info_ptr); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the logical OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -If you allocated data such as a palette that you passed -in to libpng with png_set_*, you must not free it until just before the call to -png_destroy_write_struct(). - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -For example, to transfer responsibility for some data from a read structure -to a write structure, you could use - - png_data_freer(read_ptr, read_info_ptr, - PNG_USER_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - png_data_freer(write_ptr, write_info_ptr, - PNG_DESTROY_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - -thereby briefly reassigning responsibility for freeing to the user but -immediately afterwards reassigning it once more to the write_destroy -function. Having done this, it would then be safe to destroy the read -structure and continue to use the PLTE, tRNS, and hIST data in the write -structure. - -This function only affects data that has already been allocated. -You can call this function before calling after the png_set_*() functions -to control whether the user or png_destroy_*() is supposed to free the data. -When the user assumes responsibility for libpng-allocated data, the -application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. -For a more compact example of writing a PNG image, see the file example.c. - -V. Modifying/Customizing libpng: - -There are three issues here. The first is changing how libpng does -standard things like memory allocation, input/output, and error handling. -The second deals with more complicated things like adding new chunks, -adding new transformations, and generally changing how libpng works. -Both of those are compile-time issues; that is, they are generally -determined at the time the code is written, and there is rarely a need -to provide the user with a means of changing them. The third is a -run-time issue: choosing between and/or tuning one or more alternate -versions of computationally intensive routines; specifically, optimized -assembly-language (and therefore compiler- and platform-dependent) -versions. - -Memory allocation, input/output, and error handling - -All of the memory allocation, input/output, and error handling in libpng -goes through callbacks that are user-settable. The default routines are -in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change -these functions, call the appropriate png_set_*_fn() function. - -Memory allocation is done through the functions png_malloc(), png_zalloc(), -and png_free(). These currently just call the standard C functions. If -your pointers can't access more then 64K at a time, you will want to set -MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling -memory allocation on a platform will change between applications, these -functions must be modified in the library at compile time. If you prefer -to use a different method of allocating and freeing data, you can use - - png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) - -This function also provides a void pointer that can be retrieved via - - mem_ptr=png_get_mem_ptr(png_ptr); - -Your replacement memory functions must have prototypes as follows: - - png_voidp malloc_fn(png_structp png_ptr, - png_uint_32 size); - void free_fn(png_structp png_ptr, png_voidp ptr); - -Your malloc_fn() can return NULL in case of failure. The png_malloc() -function will call png_error() if it receives a NULL from the system -memory allocator or from your replacement malloc_fn(). - -Input/Output in libpng is done through png_read() and png_write(), -which currently just call fread() and fwrite(). The FILE * is stored in -png_struct and is initialized via png_init_io(). If you wish to change -the method of I/O, the library supplies callbacks that you can set -through the function png_set_read_fn() and png_set_write_fn() at run -time, instead of calling the png_init_io() function. These functions -also provide a void pointer that can be retrieved via the function -png_get_io_ptr(). For example: - - png_set_read_fn(png_structp read_ptr, - voidp read_io_ptr, png_rw_ptr read_data_fn) - - png_set_write_fn(png_structp write_ptr, - voidp write_io_ptr, png_rw_ptr write_data_fn, - png_flush_ptr output_flush_fn); - - voidp read_io_ptr = png_get_io_ptr(read_ptr); - voidp write_io_ptr = png_get_io_ptr(write_ptr); - -The replacement I/O functions must have prototypes as follows: - - void user_read_data(png_structp png_ptr, - png_bytep data, png_uint_32 length); - void user_write_data(png_structp png_ptr, - png_bytep data, png_uint_32 length); - void user_flush_data(png_structp png_ptr); - -Supplying NULL for the read, write, or flush functions sets them back -to using the default C stream functions. It is an error to read from -a write stream, and vice versa. - -Error handling in libpng is done through png_error() and png_warning(). -Errors handled through png_error() are fatal, meaning that png_error() -should never return to its caller. Currently, this is handled via -setjmp() and longjmp() (unless you have compiled libpng with -PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), -but you could change this to do things like exit() if you should wish. - -On non-fatal errors, png_warning() is called -to print a warning message, and then control returns to the calling code. -By default png_error() and png_warning() print a message on stderr via -fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined -(because you don't want the messages) or PNG_NO_STDIO defined (because -fprintf() isn't available). If you wish to change the behavior of the error -functions, you will need to set up your own message callbacks. These -functions are normally supplied at the time that the png_struct is created. -It is also possible to redirect errors and warnings to your own replacement -functions after png_create_*_struct() has been called by calling: - - png_set_error_fn(png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warning_fn); - - png_voidp error_ptr = png_get_error_ptr(png_ptr); - -If NULL is supplied for either error_fn or warning_fn, then the libpng -default function will be used, calling fprintf() and/or longjmp() if a -problem is encountered. The replacement error functions should have -parameters as follows: - - void user_error_fn(png_structp png_ptr, - png_const_charp error_msg); - void user_warning_fn(png_structp png_ptr, - png_const_charp warning_msg); - -The motivation behind using setjmp() and longjmp() is the C++ throw and -catch exception handling methods. This makes the code much easier to write, -as there is no need to check every return code of every function call. -However, there are some uncertainties about the status of local variables -after a longjmp, so the user may want to be careful about doing anything after -setjmp returns non-zero besides returning itself. Consult your compiler -documentation for more details. For an alternative approach, you may wish -to use the "cexcept" facility (see http://cexcept.sourceforge.net). - -Custom chunks - -If you need to read or write custom chunks, you may need to get deeper -into the libpng code. The library now has mechanisms for storing -and writing chunks of unknown type; you can even declare callbacks -for custom chunks. Hoewver, this may not be good enough if the -library code itself needs to know about interactions between your -chunk and existing `intrinsic' chunks. - -If you need to write a new intrinsic chunk, first read the PNG -specification. Acquire a first level of -understanding of how it works. Pay particular attention to the -sections that describe chunk names, and look at how other chunks were -designed, so you can do things similarly. Second, check out the -sections of libpng that read and write chunks. Try to find a chunk -that is similar to yours and use it as a template. More details can -be found in the comments inside the code. It is best to handle unknown -chunks in a generic method, via callback functions, instead of by -modifying libpng functions. - -If you wish to write your own transformation for the data, look through -the part of the code that does the transformations, and check out some of -the simpler ones to get an idea of how they work. Try to find a similar -transformation to the one you want to add and copy off of it. More details -can be found in the comments inside the code itself. - -Configuring for 16 bit platforms - -You will want to look into zconf.h to tell zlib (and thus libpng) that -it cannot allocate more then 64K at a time. Even if you can, the memory -won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. - -Configuring for DOS - -For DOS users who only have access to the lower 640K, you will -have to limit zlib's memory usage via a png_set_compression_mem_level() -call. See zlib.h or zconf.h in the zlib library for more information. - -Configuring for Medium Model - -Libpng's support for medium model has been tested on most of the popular -compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets -defined, and FAR gets defined to far in pngconf.h, and you should be -all set. Everything in the library (except for zlib's structure) is -expecting far data. You must use the typedefs with the p or pp on -the end for pointers (or at least look at them and be careful). Make -note that the rows of data are defined as png_bytepp, which is an -unsigned char far * far *. - -Configuring for gui/windowing platforms: - -You will need to write new error and warning functions that use the GUI -interface, as described previously, and set them to be the error and -warning functions at the time that png_create_*_struct() is called, -in order to have them available during the structure initialization. -They can be changed later via png_set_error_fn(). On some compilers, -you may also have to change the memory allocators (png_malloc, etc.). - -Configuring for compiler xxx: - -All includes for libpng are in pngconf.h. If you need to add/change/delete -an include, this is the place to do it. The includes that are not -needed outside libpng are protected by the PNG_INTERNAL definition, -which is only defined for those routines inside libpng itself. The -files in libpng proper only include png.h, which includes pngconf.h. - -Configuring zlib: - -There are special functions to configure the compression. Perhaps the -most useful one changes the compression level, which currently uses -input compression values in the range 0 - 9. The library normally -uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests -have shown that for a large majority of images, compression values in -the range 3-6 compress nearly as well as higher levels, and do so much -faster. For online applications it may be desirable to have maximum speed -(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also -specify no compression (Z_NO_COMPRESSION = 0), but this would create -files larger than just storing the raw bitmap. You can specify the -compression level by calling: - - png_set_compression_level(png_ptr, level); - -Another useful one is to reduce the memory level used by the library. -The memory level defaults to 8, but it can be lowered if you are -short on memory (running DOS, for example, where you only have 640K). - - png_set_compression_mem_level(png_ptr, level); - -The other functions are for configuring zlib. They are not recommended -for normal use and may result in writing an invalid PNG file. See -zlib.h for more information on what these mean. - - png_set_compression_strategy(png_ptr, - strategy); - png_set_compression_window_bits(png_ptr, - window_bits); - png_set_compression_method(png_ptr, method); - png_set_compression_buffer_size(png_ptr, size); - -Controlling row filtering - -If you want to control whether libpng uses filtering or not, which -filters are used, and how it goes about picking row filters, you -can call one of these functions. The selection and configuration -of row filters can have a significant impact on the size and -encoding speed and a somewhat lesser impact on the decoding speed -of an image. Filtering is enabled by default for RGB and grayscale -images (with and without alpha), but not for paletted images nor -for any images with bit depths less than 8 bits/pixel. - -The 'method' parameter sets the main filtering method, which is -currently only '0' in the PNG 1.2 specification. The 'filters' -parameter sets which filter(s), if any, should be used for each -scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS -to turn filtering on and off, respectively. - -Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, -PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise -ORed together with '|' to specify one or more filters to use. -These filters are described in more detail in the PNG specification. If -you intend to change the filter type during the course of writing -the image, you should start with flags set for all of the filters -you intend to use so that libpng can initialize its internal -structures appropriately for all of the filter types. - - filters = PNG_FILTER_NONE | PNG_FILTER_SUB - PNG_FILTER_UP | PNG_FILTER_AVE | - PNG_FILTER_PAETH | PNG_ALL_FILTERS; - or - filters = one of PNG_FILTER_VALUE_NONE, - PNG_FILTER_VALUE_SUB, PNG_FILTER_VALUE_UP, - PNG_FILTER_VALUE_AVE, PNG_FILTER_VALUE_PAETH - - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, - filters); - The second parameter can also be - PNG_INTRAPIXEL_DIFFERENCING if you are - writing a PNG to be embedded in a MNG - datastream. This parameter must be the - same as the value of filter_method used - in png_set_IHDR(). - -It is also possible to influence how libpng chooses from among the -available filters. This is done in two ways - by telling it how -important it is to keep the same filter for successive rows, and -by telling it the relative computational costs of the filters. - - double weights[3] = {1.5, 1.3, 1.1}, - costs[PNG_FILTER_VALUE_LAST] = - {1.0, 1.3, 1.3, 1.5, 1.7}; - - png_set_filter_selection(png_ptr, - PNG_FILTER_SELECTION_WEIGHTED, 3, - weights, costs); - -The weights are multiplying factors that indicate to libpng that the -row filter should be the same for successive rows unless another row filter -is that many times better than the previous filter. In the above example, -if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a -"sum of absolute differences" 1.5 x 1.3 times higher than other filters -and still be chosen, while the NONE filter could have a sum 1.1 times -higher than other filters and still be chosen. Unspecified weights are -taken to be 1.0, and the specified weights should probably be declining -like those above in order to emphasize recent filters over older filters. - -The filter costs specify for each filter type a relative decoding cost -to be considered when selecting row filters. This means that filters -with higher costs are less likely to be chosen over filters with lower -costs, unless their "sum of absolute differences" is that much smaller. -The costs do not necessarily reflect the exact computational speeds of -the various filters, since this would unduly influence the final image -size. - -Note that the numbers above were invented purely for this example and -are given only to help explain the function usage. Little testing has -been done to find optimum values for either the costs or the weights. - -Removing unwanted object code - -There are a bunch of #define's in pngconf.h that control what parts of -libpng are compiled. All the defines end in _SUPPORTED. If you are -never going to use a capability, you can change the #define to #undef -before recompiling libpng and save yourself code and data space, or -you can turn off individual capabilities with defines that begin with -PNG_NO_. - -You can also turn all of the transforms and ancillary chunk capabilities -off en masse with compiler directives that define -PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, -or all four, -along with directives to turn on any of the capabilities that you do -want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable -the extra transformations but still leave the library fully capable of reading -and writing PNG files with all known public chunks -Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive -produces a library that is incapable of reading or writing ancillary chunks. -If you are not using the progressive reading capability, you can -turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse -this with the INTERLACING capability, which you'll still have). - -All the reading and writing specific code are in separate files, so the -linker should only grab the files it needs. However, if you want to -make sure, or if you are building a stand alone library, all the -reading files start with pngr and all the writing files start with -pngw. The files that don't match either (like png.c, pngtrans.c, etc.) -are used for both reading and writing, and always need to be included. -The progressive reader is in pngpread.c - -If you are creating or distributing a dynamically linked library (a .so -or DLL file), you should not remove or disable any parts of the library, -as this will cause applications linked with different versions of the -library to fail if they call functions not available in your library. -The size of the library itself should not be an issue, because only -those sections that are actually used will be loaded into memory. - -Requesting debug printout - -The macro definition PNG_DEBUG can be used to request debugging -printout. Set it to an integer value in the range 0 to 3. Higher -numbers result in increasing amounts of debugging information. The -information is printed to the "stderr" file, unless another file -name is specified in the PNG_DEBUG_FILE macro definition. - -When PNG_DEBUG > 0, the following functions (macros) become available: - - png_debug(level, message) - png_debug1(level, message, p1) - png_debug2(level, message, p1, p2) - -in which "level" is compared to PNG_DEBUG to decide whether to print -the message, "message" is the formatted string to be printed, -and p1 and p2 are parameters that are to be embedded in the string -according to printf-style formatting directives. For example, - - png_debug1(2, "foo=%d\n", foo); - -is expanded to - - if(PNG_DEBUG > 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); - -When PNG_DEBUG is defined but is zero, the macros aren't defined, but you -can still use PNG_DEBUG to control your own debugging: - - #ifdef PNG_DEBUG - fprintf(stderr, ... - #endif - -When PNG_DEBUG = 1, the macros are defined, but only png_debug statements -having level = 0 will be printed. There aren't any such statements in -this version of libpng, but if you insert some they will be printed. - - -VI. MNG support - -The MNG specification (available at http://www.libpng.org/pub/mng) allows -certain extensions to PNG for PNG images that are embedded in MNG datastreams. -Libpng can support some of these extensions. To enable them, use the -png_permit_mng_features() function: - - feature_set = png_permit_mng_features(png_ptr, mask) - mask is a png_uint_32 containing the logical OR of the - features you want to enable. These include - PNG_FLAG_MNG_EMPTY_PLTE - PNG_FLAG_MNG_FILTER_64 - PNG_ALL_MNG_FEATURES - feature_set is a png_32_uint that is the logical AND of - your mask with the set of MNG features that is - supported by the version of libpng that you are using. - -It is an error to use this function when reading or writing a standalone -PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped -in a MNG datastream. As a minimum, it must have the MNG 8-byte signature -and the MHDR and MEND chunks. Libpng does not provide support for these -or any other MNG chunks; your application must provide its own support for -them. You may wish to consider using libmng (available at -http://www.libmng.com) instead. - -VII. Changes to Libpng from version 0.88 - -It should be noted that versions of libpng later than 0.96 are not -distributed by the original libpng author, Guy Schalnat, nor by -Andreas Dilger, who had taken over from Guy during 1996 and 1997, and -distributed versions 0.89 through 0.96, but rather by another member -of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are -still alive and well, but they have moved on to other things. - -The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been -moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. - -The preferred method of creating and initializing the libpng structures is -via the png_create_read_struct(), png_create_write_struct(), and -png_create_info_struct() because they isolate the size of the structures -from the application, allow version error checking, and also allow the -use of custom error handling routines during the initialization, which -the old functions do not. The functions png_read_destroy() and -png_write_destroy() do not actually free the memory that libpng -allocated for these structs, but just reset the data structures, so they -can be used instead of png_destroy_read_struct() and -png_destroy_write_struct() if you feel there is too much system overhead -allocating and freeing the png_struct for each image read. - -Setting the error callbacks via png_set_message_fn() before -png_read_init() as was suggested in libpng-0.88 is no longer supported -because this caused applications that do not use custom error functions -to fail if the png_ptr was not initialized to zero. It is still possible -to set the error callbacks AFTER png_read_init(), or to change them with -png_set_error_fn(), which is essentially the same function, but with a new -name to force compilation errors with applications that try to use the old -method. - -Starting with version 1.0.7, you can find out which version of the library -you are using at run-time: - - png_uint_32 libpng_vn = png_access_version_number(); - -The number libpng_vn is constructed from the major version, minor -version with leading zero, and release number with leading zero, -(e.g., libpng_vn for version 1.0.7 is 10007). - -You can also check which version of png.h you used when compiling your -application: - - png_uint_32 application_vn = PNG_LIBPNG_VER; - -VIII. Y2K Compliance in libpng - -June 8, 2001 - -Since the PNG Development group is an ad-hoc body, we can't make -an official declaration. - -This is your unofficial assurance that libpng from version 0.71 and -upward through 1.0.12 are Y2K compliant. It is my belief that earlier -versions were also Y2K compliant. - -Libpng only has three year fields. One is a 2-byte unsigned integer that -will hold years up to 65535. The other two hold the date in text -format, and will hold years up to 9999. - -The integer is - "png_uint_16 year" in png_time_struct. - -The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - -There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called - in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - -All appear to handle dates properly in a Y2K environment. The -png_convert_from_time_t() function calls gmtime() to convert from system -clock time, which returns (year - 1900), which we properly convert to -the full 4-digit year. There is a possibility that applications using -libpng are not passing 4-digit years into the png_convert_to_rfc_1123() -function, or that they are incorrectly passing only a 2-digit year -instead of "year - 1900" into the png_convert_from_struct_tm() function, -but this is not under our control. The libpng documentation has always -stated that it works with 4-digit years, and the APIs have been -documented as such. - -The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned -integer to hold the year, and can hold years as large as 65535. - -zlib, upon which libpng depends, is also Y2K compliant. It contains -no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group diff --git a/freeimage241/Source/LibPNG/png.c b/freeimage241/Source/LibPNG/png.c deleted file mode 100644 index 0cc4e8e..0000000 --- a/freeimage241/Source/LibPNG/png.c +++ /dev/null @@ -1,729 +0,0 @@ - -/* png.c - location for general purpose libpng functions - * - * libpng version 1.0.12 - June 8, 2001 - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - */ - -#define PNG_INTERNAL -#define PNG_NO_EXTERN -#include "png.h" - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_0_12 Your_png_h_is_not_version_1_0_12; - -/* Version information for C files. This had better match the version - * string defined in png.h. */ - -#ifdef PNG_USE_GLOBAL_ARRAYS -/* png_libpng_ver was changed to a function in version 1.0.5c */ -const char png_libpng_ver[18] = "1.0.12"; - -/* png_sig was changed to a function in version 1.0.5c */ -/* Place to hold the signature string for a PNG file. */ -const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - -/* Invoke global declarations for constant strings for known chunk types */ -PNG_IHDR; -PNG_IDAT; -PNG_IEND; -PNG_PLTE; -PNG_bKGD; -PNG_cHRM; -PNG_gAMA; -PNG_hIST; -PNG_iCCP; -PNG_iTXt; -PNG_oFFs; -PNG_pCAL; -PNG_sCAL; -PNG_pHYs; -PNG_sBIT; -PNG_sPLT; -PNG_sRGB; -PNG_tEXt; -PNG_tIME; -PNG_tRNS; -PNG_zTXt; - -/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - -/* start of interlace block */ -const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - -/* offset to next interlace block */ -const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - -/* start of interlace block in the y direction */ -const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - -/* offset to next interlace block in the y direction */ -const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - -/* width of interlace block (used in assembler routines only) */ -#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW -const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; -#endif - -/* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h -const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; -*/ - -/* Mask to determine which pixels are valid in a pass */ -const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; - -/* Mask to determine which pixels to overwrite while displaying */ -const int FARDATA png_pass_dsp_mask[] - = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - -#endif - -/* Tells libpng that we have already handled the first "num_bytes" bytes - * of the PNG file signature. If the PNG data is embedded into another - * stream we can set num_bytes = 8 so that libpng will not attempt to read - * or write any of the magic bytes before it starts on the IHDR. - */ - -void PNGAPI -png_set_sig_bytes(png_structp png_ptr, int num_bytes) -{ - png_debug(1, "in png_set_sig_bytes\n"); - if (num_bytes > 8) - png_error(png_ptr, "Too many bytes for PNG signature."); - - png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); -} - -/* Checks whether the supplied bytes match the PNG signature. We allow - * checking less than the full 8-byte signature so that those apps that - * already read the first few bytes of a file to determine the file type - * can simply check the remaining bytes for extra assurance. Returns - * an integer less than, equal to, or greater than zero if sig is found, - * respectively, to be less than, to match, or be greater than the correct - * PNG signature (this is the same behaviour as strcmp, memcmp, etc). - */ -int PNGAPI -png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - if (num_to_check > 8) - num_to_check = 8; - else if (num_to_check < 1) - return (0); - - if (start > 7) - return (0); - - if (start + num_to_check > 8) - num_to_check = 8 - start; - - return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); -} - -/* (Obsolete) function to check signature bytes. It does not allow one - * to check a partial signature. This function might be removed in the - * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. - */ -int PNGAPI -png_check_sig(png_bytep sig, int num) -{ - return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); -} - -/* Function to allocate memory for zlib and clear it to 0. */ -voidpf /* PRIVATE */ -png_zalloc(voidpf png_ptr, uInt items, uInt size) -{ - png_uint_32 num_bytes = (png_uint_32)items * size; - png_voidp ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); - -#ifndef PNG_NO_ZALLOC_ZERO - if (num_bytes > (png_uint_32)0x8000L) - { - png_memset(ptr, 0, (png_size_t)0x8000L); - png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, - (png_size_t)(num_bytes - (png_uint_32)0x8000L)); - } - else - { - png_memset(ptr, 0, (png_size_t)num_bytes); - } -#endif - return ((voidpf)ptr); -} - -/* function to free memory for zlib */ -void /* PRIVATE */ -png_zfree(voidpf png_ptr, voidpf ptr) -{ - png_free((png_structp)png_ptr, (png_voidp)ptr); -} - -/* Reset the CRC variable to 32 bits of 1's. Care must be taken - * in case CRC is > 32 bits to leave the top bits 0. - */ -void /* PRIVATE */ -png_reset_crc(png_structp png_ptr) -{ - png_ptr->crc = crc32(0, Z_NULL, 0); -} - -/* Calculate the CRC over a section of data. We can only pass as - * much data to this routine as the largest single buffer size. We - * also check that this data will actually be used before going to the - * trouble of calculating it. - */ -void /* PRIVATE */ -png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) -{ - int need_crc = 1; - - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - else /* critical */ - { - if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) - need_crc = 0; - } - - if (need_crc) - png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); -} - -/* Allocate the memory for an info_struct for the application. We don't - * really need the png_ptr, but it could potentially be useful in the - * future. This should be used in favour of malloc(sizeof(png_info)) - * and png_info_init() so that applications that want to use a shared - * libpng don't have to be recompiled if png_info changes size. - */ -png_infop PNGAPI -png_create_info_struct(png_structp png_ptr) -{ - png_infop info_ptr; - - png_debug(1, "in png_create_info_struct\n"); - if(png_ptr == NULL) return (NULL); -#ifdef PNG_USER_MEM_SUPPORTED - if ((info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, - png_ptr->malloc_fn, png_ptr->mem_ptr)) != NULL) -#else - if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL) -#endif - { - png_info_init_3(&info_ptr, sizeof(png_info)); - } - - return (info_ptr); -} - -/* This function frees the memory associated with a single info struct. - * Normally, one would use either png_destroy_read_struct() or - * png_destroy_write_struct() to free an info struct, but this may be - * useful for some applications. - */ -void PNGAPI -png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) -{ - png_infop info_ptr = NULL; - - png_debug(1, "in png_destroy_info_struct\n"); - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - png_info_destroy(png_ptr, info_ptr); - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, - png_ptr->mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = (png_infop)NULL; - } -} - -/* Initialize the info structure. This is now an internal function (0.89) - * and applications using it are urged to use png_create_info_struct() - * instead. - */ -#undef png_info_init -void PNGAPI -png_info_init(png_infop info_ptr) -{ - /* We only come here via pre-1.0.12-compiled applications */ - png_info_init_3(&info_ptr, 0); -} - -void PNGAPI -png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) -{ - png_infop info_ptr = *ptr_ptr; - - png_debug(1, "in png_info_init_3\n"); - - if(sizeof(png_info) > png_info_struct_size) - { - png_destroy_struct(info_ptr); - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); - *ptr_ptr = info_ptr; - } - - /* set everything to 0 */ - png_memset(info_ptr, 0, sizeof (png_info)); -} - -#ifdef PNG_FREE_ME_SUPPORTED -void PNGAPI -png_data_freer(png_structp png_ptr, png_infop info_ptr, - int freer, png_uint_32 mask) -{ - png_debug(1, "in png_data_freer\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if(freer == PNG_DESTROY_WILL_FREE_DATA) - info_ptr->free_me |= mask; - else if(freer == PNG_USER_WILL_FREE_DATA) - info_ptr->free_me &= ~mask; - else - png_warning(png_ptr, - "Unknown freer parameter in png_data_freer."); -} -#endif - -void PNGAPI -png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, - int num) -{ - png_debug(1, "in png_free_data\n"); - if (png_ptr == NULL || info_ptr == NULL) - return; - -#if defined(PNG_TEXT_SUPPORTED) -/* free text item num or (if num == -1) all text items */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_TEXT) -#endif -{ - if (num != -1) - { - if (info_ptr->text && info_ptr->text[num].key) - { - png_free(png_ptr, info_ptr->text[num].key); - info_ptr->text[num].key = NULL; - } - } - else - { - int i; - for (i = 0; i < info_ptr->num_text; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); - png_free(png_ptr, info_ptr->text); - info_ptr->text = NULL; - info_ptr->num_text=0; - } -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -/* free any tRNS entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) -#endif -{ - png_free(png_ptr, info_ptr->trans); - info_ptr->valid &= ~PNG_INFO_tRNS; - info_ptr->trans = NULL; -} -#endif - -#if defined(PNG_sCAL_SUPPORTED) -/* free any sCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SCAL) -#endif -{ -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, info_ptr->scal_s_width); - png_free(png_ptr, info_ptr->scal_s_height); - info_ptr->scal_s_width = NULL; - info_ptr->scal_s_height = NULL; -#endif - info_ptr->valid &= ~PNG_INFO_sCAL; -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -/* free any pCAL entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) -#else -if (mask & PNG_FREE_PCAL) -#endif -{ - png_free(png_ptr, info_ptr->pcal_purpose); - png_free(png_ptr, info_ptr->pcal_units); - info_ptr->pcal_purpose = NULL; - info_ptr->pcal_units = NULL; - if (info_ptr->pcal_params != NULL) - { - int i; - for (i = 0; i < (int)info_ptr->pcal_nparams; i++) - { - png_free(png_ptr, info_ptr->pcal_params[i]); - info_ptr->pcal_params[i]=NULL; - } - png_free(png_ptr, info_ptr->pcal_params); - info_ptr->pcal_params = NULL; - } - info_ptr->valid &= ~PNG_INFO_pCAL; -} -#endif - -#if defined(PNG_iCCP_SUPPORTED) -/* free any iCCP entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ICCP) -#endif -{ - png_free(png_ptr, info_ptr->iccp_name); - png_free(png_ptr, info_ptr->iccp_profile); - info_ptr->iccp_name = NULL; - info_ptr->iccp_profile = NULL; - info_ptr->valid &= ~PNG_INFO_iCCP; -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -/* free a given sPLT entry, or (if num == -1) all sPLT entries */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) -#else -if (mask & PNG_FREE_SPLT) -#endif -{ - if (num != -1) - { - if(info_ptr->splt_palettes) - { - png_free(png_ptr, info_ptr->splt_palettes[num].name); - png_free(png_ptr, info_ptr->splt_palettes[num].entries); - info_ptr->splt_palettes[num].name = NULL; - info_ptr->splt_palettes[num].entries = NULL; - } - } - else - { - if(info_ptr->splt_palettes_num) - { - int i; - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); - - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = NULL; - info_ptr->splt_palettes_num = 0; - } - info_ptr->valid &= ~PNG_INFO_sPLT; - } -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) -#else -if (mask & PNG_FREE_UNKN) -#endif -{ - if (num != -1) - { - if(info_ptr->unknown_chunks) - { - png_free(png_ptr, info_ptr->unknown_chunks[num].data); - info_ptr->unknown_chunks[num].data = NULL; - } - } - else - { - int i; - - if(info_ptr->unknown_chunks_num) - { - for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); - - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = NULL; - info_ptr->unknown_chunks_num = 0; - } - } -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -/* free any hIST entry */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_HIST) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) -#endif -{ - png_free(png_ptr, info_ptr->hist); - info_ptr->hist = NULL; - info_ptr->valid &= ~PNG_INFO_hIST; -} -#endif - -/* free any PLTE entry that was internally allocated */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) -#else -if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) -#endif -{ - png_zfree(png_ptr, info_ptr->palette); - info_ptr->palette = NULL; - info_ptr->valid &= ~PNG_INFO_PLTE; - info_ptr->num_palette = 0; -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* free any image bits attached to the info structure */ -#ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) -#else -if (mask & PNG_FREE_ROWS) -#endif -{ - if(info_ptr->row_pointers) - { - int row; - for (row = 0; row < (int)info_ptr->height; row++) - { - png_free(png_ptr, info_ptr->row_pointers[row]); - info_ptr->row_pointers[row]=NULL; - } - png_free(png_ptr, info_ptr->row_pointers); - info_ptr->row_pointers=NULL; - } - info_ptr->valid &= ~PNG_INFO_IDAT; -} -#endif - -#ifdef PNG_FREE_ME_SUPPORTED - if(num == -1) - info_ptr->free_me &= ~mask; - else - info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); -#endif -} - -/* This is an internal routine to free any memory that the info struct is - * pointing to before re-using it or freeing the struct itself. Recall - * that png_free() checks for NULL pointers for us. - */ -void /* PRIVATE */ -png_info_destroy(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_info_destroy\n"); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } -#endif - - png_info_init_3(&info_ptr, sizeof(png_info)); -} - -/* This function returns a pointer to the io_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy() or png_read_destroy() are called. - */ -png_voidp PNGAPI -png_get_io_ptr(png_structp png_ptr) -{ - return (png_ptr->io_ptr); -} - -#if !defined(PNG_NO_STDIO) -/* Initialize the default input/output functions for the PNG file. If you - * use your own read or write routines, you can call either png_set_read_fn() - * or png_set_write_fn() instead of png_init_io(). If you have defined - * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't - * necessarily available. - */ -void PNGAPI -png_init_io(png_structp png_ptr, png_FILE_p fp) -{ - png_debug(1, "in png_init_io\n"); - png_ptr->io_ptr = (png_voidp)fp; -} -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -/* Convert the supplied time into an RFC 1123 string suitable for use in - * a "Creation Time" or other text-based time string. - */ -png_charp PNGAPI -png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) -{ - static PNG_CONST char short_months[12][4] = - {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - - if (png_ptr->time_buffer == NULL) - { - png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* - sizeof(char))); - } - -#if defined(_WIN32_WCE) - { - wchar_t time_buf[29]; - wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, - NULL, NULL); - } -#else -#ifdef USE_FAR_KEYWORD - { - char near_time_buf[29]; - sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - png_memcpy(png_ptr->time_buffer, near_time_buf, - 29*sizeof(char)); - } -#else - sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); -#endif -#endif /* _WIN32_WCE */ - return ((png_charp)png_ptr->time_buffer); -} -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - -#if 0 -/* Signature string for a PNG file. */ -png_bytep PNGAPI -png_sig_bytes(void) -{ - return ((png_bytep)"\211\120\116\107\015\012\032\012"); -} -#endif - -png_charp PNGAPI -png_get_copyright(png_structp png_ptr) -{ - if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */ - return ((png_charp) "\n libpng version 1.0.12 - June 8, 2001\n\ - Copyright (c) 1998-2001 Glenn Randers-Pehrson\n\ - Copyright (c) 1996, 1997 Andreas Dilger\n\ - Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n"); - return ((png_charp) ""); -} - -/* The following return the library version as a short string in the - * format 1.0.0 through 99.99.99zz. To get the version of *.h files used - * with your application, print out PNG_LIBPNG_VER_STRING, which is defined - * in png.h. - */ - -png_charp PNGAPI -png_get_libpng_ver(png_structp png_ptr) -{ - /* Version of *.c files used when building libpng */ - if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return((png_charp) "1.0.12"); - return((png_charp) "1.0.12"); -} - -png_charp PNGAPI -png_get_header_ver(png_structp png_ptr) -{ - /* Version of *.h files used when building libpng */ - if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return((png_charp) PNG_LIBPNG_VER_STRING); - return((png_charp) PNG_LIBPNG_VER_STRING); -} - -png_charp PNGAPI -png_get_header_version(png_structp png_ptr) -{ - /* Returns longer string containing both version and date */ - if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return((png_charp) PNG_HEADER_VERSION_STRING); - return((png_charp) PNG_HEADER_VERSION_STRING); -} - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -int /* PRIVATE */ -png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) -{ - /* check chunk_name and return "keep" value if it's on the list, else 0 */ - int i; - png_bytep p; - if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0) - return 0; - p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; - for (i = png_ptr->num_chunk_list; i; i--, p-=5) - if (!png_memcmp(chunk_name, p, 4)) - return ((int)*(p+4)); - return 0; -} -#endif - -/* This function, added to libpng-1.0.6g, is untested. */ -int PNGAPI -png_reset_zstream(png_structp png_ptr) -{ - return (inflateReset(&png_ptr->zstream)); -} - -/* This function was added to libpng-1.0.7 */ -png_uint_32 PNGAPI -png_access_version_number(void) -{ - /* Version of *.c files used when building libpng */ - return((png_uint_32) 10012L); -} - -/* this function was added to libpng 1.2.0 */ -#if !defined(PNG_USE_PNGGCCRD) && \ - !(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)) -int PNGAPI -png_mmx_support(void) -{ - return -1; -} -#endif diff --git a/freeimage241/Source/LibPNG/png.h b/freeimage241/Source/LibPNG/png.h deleted file mode 100644 index 7f99453..0000000 --- a/freeimage241/Source/LibPNG/png.h +++ /dev/null @@ -1,3088 +0,0 @@ - -/* png.h - header file for PNG reference library - * - * libpng version 1.0.12 - June 8, 2001 - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.0.12 - June 8, 2001: Glenn - * See also "Contributing Authors", below. - * - * Note about libpng version numbers: - * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: - * - * source png.h png.h shared-lib - * version string int version - * ------- ------ ----- ---------- - * 0.89c "1.0 beta 3" 0.89 89 1.0.89 - * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] - * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] - * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] - * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] - * 0.97c 0.97 97 2.0.97 - * 0.98 0.98 98 2.0.98 - * 0.99 0.99 98 2.0.99 - * 0.99a-m 0.99 99 2.0.99 - * 1.00 1.00 100 2.1.0 [100 should be 10000] - * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] - * 1.0.1 png.h string is 10001 2.1.0 - * 1.0.1a-e identical to the 10002 from here on, the shared library - * 1.0.2 source version) 10002 is 2.V where V is the source code - * 1.0.2a-b 10003 version, except as noted. - * 1.0.3 10003 - * 1.0.3a-d 10004 - * 1.0.4 10004 - * 1.0.4a-f 10005 - * 1.0.5 (+ 2 patches) 10005 - * 1.0.5a-d 10006 - * 1.0.5e-r 10100 (not source compatible) - * 1.0.5s-v 10006 (not binary compatible) - * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) - * 1.0.6d-f 10007 (still binary incompatible) - * 1.0.6g 10007 - * 1.0.6h 10007 10.6h (testing xy.z so-numbering) - * 1.0.6i 10007 10.6i - * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) - * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) - * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) - * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) - * 1.0.7 1 10007 (still compatible) - * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 - * 1.0.8rc1 1 10008 2.1.0.8rc1 - * 1.0.8 1 10008 2.1.0.8 - * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 - * 1.0.9rc1 1 10009 2.1.0.9rc1 - * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 - * 1.0.9rc2 1 10009 2.1.0.9rc2 - * 1.0.9 1 10009 2.1.0.9 - * 1.0.10beta1 1 10010 2.1.0.10beta1 - * 1.0.10rc1 1 10010 2.1.0.10rc1 - * 1.0.10 1 10010 2.1.0.10 - * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 - * 1.0.11rc1 1 10011 2.1.0.11rc1 - * 1.0.11 1 10011 2.1.0.11 - * 1.0.12beta1-2 2 10012 2.1.0.11beta1-2 - * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcN". - * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. - * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). - * - * See libpng.txt or libpng.3 for more information. The PNG specification - * is available as RFC 2083 - * and as a W3C Recommendation - */ - -/* - * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - * - * If you modify libpng you may insert additional notices immediately following - * this sentence. - * - * libpng versions 1.0.7, July 1, 2000, through 1.0.12, June 8, 2001, are - * Copyright (c) 2000, 2001 Glenn Randers-Pehrson, and are - * distributed according to the same disclaimer and license as libpng-1.0.6 - * with the following individuals added to the list of Contributing Authors - * - * Simon-Pierre Cadieux - * Eric S. Raymond - * Gilles Vollant - * - * and with the following additions to the disclaimer: - * - * There is no warranty against interference with your enjoyment of the - * library or against infringement. There is no warranty that our - * efforts or the library will fulfill any of your particular purposes - * or needs. This library is provided with all faults, and the entire - * risk of satisfactory quality, performance, accuracy, and effort is with - * the user. - * - * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are - * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson - * Distributed according to the same disclaimer and license as libpng-0.96, - * with the following individuals added to the list of Contributing Authors: - * - * Tom Lane - * Glenn Randers-Pehrson - * Willem van Schaik - * - * libpng versions 0.89, June 1996, through 0.96, May 1997, are - * Copyright (c) 1996, 1997 Andreas Dilger - * Distributed according to the same disclaimer and license as libpng-0.88, - * with the following individuals added to the list of Contributing Authors: - * - * John Bowler - * Kevin Bracey - * Sam Bushell - * Magnus Holmgren - * Greg Roelofs - * Tom Tanner - * - * libpng versions 0.5, May 1995, through 0.88, January 1996, are - * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - * - * For the purposes of this copyright and license, "Contributing Authors" - * is defined as the following set of individuals: - * - * Andreas Dilger - * Dave Martindale - * Guy Eric Schalnat - * Paul Schmidt - * Tim Wegner - * - * The PNG Reference Library is supplied "AS IS". The Contributing Authors - * and Group 42, Inc. disclaim all warranties, expressed or implied, - * including, without limitation, the warranties of merchantability and of - * fitness for any purpose. The Contributing Authors and Group 42, Inc. - * assume no liability for direct, indirect, incidental, special, exemplary, - * or consequential damages, which may result from the use of the PNG - * Reference Library, even if advised of the possibility of such damage. - * - * Permission is hereby granted to use, copy, modify, and distribute this - * source code, or portions hereof, for any purpose, without fee, subject - * to the following restrictions: - * - * 1. The origin of this source code must not be misrepresented. - * - * 2. Altered versions must be plainly marked as such and - * must not be misrepresented as being the original source. - * - * 3. This Copyright notice may not be removed or altered from - * any source or altered source distribution. - * - * The Contributing Authors and Group 42, Inc. specifically permit, without - * fee, and encourage the use of this source code as a component to - * supporting the PNG file format in commercial products. If you use this - * source code in a product, acknowledgment is not required but would be - * appreciated. - */ - -/* - * A "png_get_copyright" function is available, for convenient use in "about" - * boxes and the like: - * - * printf("%s",png_get_copyright(NULL)); - * - * Also, the PNG logo (in PNG format, of course) is supplied in the - * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - */ - -/* - * Libpng is OSI Certified Open Source Software. OSI Certified is a - * certification mark of the Open Source Initiative. - */ - -/* - * The contributing authors would like to thank all those who helped - * with testing, bug fixes, and patience. This wouldn't have been - * possible without all of you. - * - * Thanks to Frank J. T. Wojcik for helping with the documentation. - */ - -/* - * Y2K compliance in libpng: - * ========================= - * - * June 8, 2001 - * - * Since the PNG Development group is an ad-hoc body, we can't make - * an official declaration. - * - * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.0.12 are Y2K compliant. It is my belief that earlier - * versions were also Y2K compliant. - * - * Libpng only has three year fields. One is a 2-byte unsigned integer - * that will hold years up to 65535. The other two hold the date in text - * format, and will hold years up to 9999. - * - * The integer is - * "png_uint_16 year" in png_time_struct. - * - * The strings are - * "png_charp time_buffer" in png_struct and - * "near_time_buffer", which is a local character string in png.c. - * - * There are seven time-related functions: - * png.c: png_convert_to_rfc_1123() in png.c - * (formerly png_convert_to_rfc_1152() in error) - * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - * png_convert_from_time_t() in pngwrite.c - * png_get_tIME() in pngget.c - * png_handle_tIME() in pngrutil.c, called in pngread.c - * png_set_tIME() in pngset.c - * png_write_tIME() in pngwutil.c, called in pngwrite.c - * - * All handle dates properly in a Y2K environment. The - * png_convert_from_time_t() function calls gmtime() to convert from system - * clock time, which returns (year - 1900), which we properly convert to - * the full 4-digit year. There is a possibility that applications using - * libpng are not passing 4-digit years into the png_convert_to_rfc_1123() - * function, or that they are incorrectly passing only a 2-digit year - * instead of "year - 1900" into the png_convert_from_struct_tm() function, - * but this is not under our control. The libpng documentation has always - * stated that it works with 4-digit years, and the APIs have been - * documented as such. - * - * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - * integer to hold the year, and can hold years as large as 65535. - * - * zlib, upon which libpng depends, is also Y2K compliant. It contains - * no date-related code. - * - * Glenn Randers-Pehrson - * libpng maintainer - * PNG Development Group - */ - -#ifndef PNG_H -#define PNG_H - -/* This is not the place to learn how to use libpng. The file libpng.txt - * describes how to use libpng, and the file example.c summarizes it - * with some code on which to build. This file is useful for looking - * at the actual function definitions and structure components. - */ - -/* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.0.12" - -#define PNG_LIBPNG_VER_SONUM 2 -#define PNG_LIBPNG_VER_DLLNUM %DLLNUM% - -/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ -#define PNG_LIBPNG_VER_MAJOR 1 -#define PNG_LIBPNG_VER_MINOR 0 -#define PNG_LIBPNG_VER_RELEASE 12 -/* This should match the numeric part of the final component of - * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ - -#define PNG_LIBPNG_VER_BUILD 0 - -#define PNG_LIBPNG_BUILD_ALPHA 1 -#define PNG_LIBPNG_BUILD_BETA 2 -#define PNG_LIBPNG_BUILD_RC 3 -#define PNG_LIBPNG_BUILD_STABLE 4 -#define PNG_LIBPNG_BUILD_TYPEMASK 7 -#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with STABLE only */ -#define PNG_LIBPNG_BUILD_TYPE 4 - -/* Careful here. At one time, Guy wanted to use 082, but that would be octal. - * We must not include leading zeros. - * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only - * version 1.0.0 was mis-numbered 100 instead of 10000). From - * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10012 /* 1.0.12 */ - -#ifndef PNG_VERSION_INFO_ONLY - -/* include the compression library's header */ -#include "..\Zlib\zlib.h" - -/* include all user configurable info, including optional assembler routines */ -#include "pngconf.h" - -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* This file is arranged in several sections. The first section contains - * structure and type definitions. The second section contains the external - * library functions, while the third has the internal library functions, - * which applications aren't expected to use directly. - */ - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* Version information for C files, stored in png.c. This had better match - * the version above. - */ -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (const char) png_libpng_ver[18]; - /* need room for 99.99.99beta99z*/ -#else -#define png_libpng_ver png_get_header_ver(NULL) -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -/* This was removed in version 1.0.5c */ -/* Structures to facilitate easy interlacing. See png.c for more details */ -PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; -PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; -#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW -PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; -#endif -/* This isn't currently used. If you need it, see png.c for more details. -PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7]; -*/ -#endif - -#endif /* PNG_NO_EXTERN */ - -/* Three color definitions. The order of the red, green, and blue, (and the - * exact size) is not important, although the size of the fields need to - * be png_byte or png_uint_16 (as defined below). - */ -typedef struct png_color_struct -{ - png_byte red; - png_byte green; - png_byte blue; -} png_color; -typedef png_color FAR * png_colorp; -typedef png_color FAR * FAR * png_colorpp; - -typedef struct png_color_16_struct -{ - png_byte index; /* used for palette files */ - png_uint_16 red; /* for use in red green blue files */ - png_uint_16 green; - png_uint_16 blue; - png_uint_16 gray; /* for use in grayscale files */ -} png_color_16; -typedef png_color_16 FAR * png_color_16p; -typedef png_color_16 FAR * FAR * png_color_16pp; - -typedef struct png_color_8_struct -{ - png_byte red; /* for use in red green blue files */ - png_byte green; - png_byte blue; - png_byte gray; /* for use in grayscale files */ - png_byte alpha; /* for alpha channel files */ -} png_color_8; -typedef png_color_8 FAR * png_color_8p; -typedef png_color_8 FAR * FAR * png_color_8pp; - -/* - * The following two structures are used for the in-core representation - * of sPLT chunks. - */ -typedef struct png_sPLT_entry_struct -{ - png_uint_16 red; - png_uint_16 green; - png_uint_16 blue; - png_uint_16 alpha; - png_uint_16 frequency; -} png_sPLT_entry; -typedef png_sPLT_entry FAR * png_sPLT_entryp; -typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; - -/* When the depth of the sPLT palette is 8 bits, the color and alpha samples - * occupy the LSB of their respective members, and the MSB of each member - * is zero-filled. The frequency member always occupies the full 16 bits. - */ - -typedef struct png_sPLT_struct -{ - png_charp name; /* palette name */ - png_byte depth; /* depth of palette samples */ - png_sPLT_entryp entries; /* palette entries */ - png_int_32 nentries; /* number of palette entries */ -} png_sPLT_t; -typedef png_sPLT_t FAR * png_sPLT_tp; -typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; - -#ifdef PNG_TEXT_SUPPORTED -/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, - * and whether that contents is compressed or not. The "key" field - * points to a regular zero-terminated C string. The "text", "lang", and - * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. - * However, the * structure returned by png_get_text() will always contain - * regular zero-terminated C strings (possibly empty), never NULL pointers, - * so they can be safely used in printf() and other string-handling functions. - */ -typedef struct png_text_struct -{ - int compression; /* compression value: - -1: tEXt, none - 0: zTXt, deflate - 1: iTXt, none - 2: iTXt, deflate */ - png_charp key; /* keyword, 1-79 character description of "text" */ - png_charp text; /* comment, may be an empty string (ie "") - or a NULL pointer */ - png_size_t text_length; /* length of the text string */ -#ifdef PNG_iTXt_SUPPORTED - png_size_t itxt_length; /* length of the itxt string */ - png_charp lang; /* language code, 0-79 characters - or a NULL pointer */ - png_charp lang_key; /* keyword translated UTF-8 string, 0 or more - chars or a NULL pointer */ -#endif -} png_text; -typedef png_text FAR * png_textp; -typedef png_text FAR * FAR * png_textpp; -#endif - -/* Supported compression types for text in PNG files (tEXt, and zTXt). - * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ -#define PNG_TEXT_COMPRESSION_NONE_WR -3 -#define PNG_TEXT_COMPRESSION_zTXt_WR -2 -#define PNG_TEXT_COMPRESSION_NONE -1 -#define PNG_TEXT_COMPRESSION_zTXt 0 -#define PNG_ITXT_COMPRESSION_NONE 1 -#define PNG_ITXT_COMPRESSION_zTXt 2 -#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ - -/* png_time is a way to hold the time in an machine independent way. - * Two conversions are provided, both from time_t and struct tm. There - * is no portable way to convert to either of these structures, as far - * as I know. If you know of a portable way, send it to me. As a side - * note - PNG has always been Year 2000 compliant! - */ -typedef struct png_time_struct -{ - png_uint_16 year; /* full year, as in, 1995 */ - png_byte month; /* month of year, 1 - 12 */ - png_byte day; /* day of month, 1 - 31 */ - png_byte hour; /* hour of day, 0 - 23 */ - png_byte minute; /* minute of hour, 0 - 59 */ - png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ -} png_time; -typedef png_time FAR * png_timep; -typedef png_time FAR * FAR * png_timepp; - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* png_unknown_chunk is a structure to hold queued chunks for which there is - * no specific support. The idea is that we can use this to queue - * up private chunks for output even though the library doesn't actually - * know about their semantics. - */ -typedef struct png_unknown_chunk_t -{ - png_byte name[5]; - png_byte *data; - png_size_t size; - - /* libpng-using applications should NOT directly modify this byte. */ - png_byte location; /* mode of operation at read time */ -} -png_unknown_chunk; -typedef png_unknown_chunk FAR * png_unknown_chunkp; -typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; -#endif - -/* png_info is a structure that holds the information in a PNG file so - * that the application can find out the characteristics of the image. - * If you are reading the file, this structure will tell you what is - * in the PNG file. If you are writing the file, fill in the information - * you want to put into the PNG file, then call png_write_info(). - * The names chosen should be very close to the PNG specification, so - * consult that document for information about the meaning of each field. - * - * With libpng < 0.95, it was only possible to directly set and read the - * the values in the png_info_struct, which meant that the contents and - * order of the values had to remain fixed. With libpng 0.95 and later, - * however, there are now functions that abstract the contents of - * png_info_struct from the application, so this makes it easier to use - * libpng with dynamic libraries, and even makes it possible to use - * libraries that don't have all of the libpng ancillary chunk-handing - * functionality. - * - * In any case, the order of the parameters in png_info_struct should NOT - * be changed for as long as possible to keep compatibility with applications - * that use the old direct-access method with png_info_struct. - * - * The following members may have allocated storage attached that should be - * cleaned up before the structure is discarded: palette, trans, text, - * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, - * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these - * are automatically freed when the info structure is deallocated, if they were - * allocated internally by libpng. This behavior can be changed by means - * of the png_data_freer() function. - * - * More allocation details: all the chunk-reading functions that - * change these members go through the corresponding png_set_* - * functions. A function to clear these members is available: see - * png_free_data(). The png_set_* functions do not depend on being - * able to point info structure members to any of the storage they are - * passed (they make their own copies), EXCEPT that the png_set_text - * functions use the same storage passed to them in the text_ptr or - * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns - * functions do not make their own copies. - */ -typedef struct png_info_struct -{ - /* the following are necessary for every PNG file */ - png_uint_32 width; /* width of image in pixels (from IHDR) */ - png_uint_32 height; /* height of image in pixels (from IHDR) */ - png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ - png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ - png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ - png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ - png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ - png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ - png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ - /* The following three should have been named *_method not *_type */ - png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ - png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ - png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - - /* The following is informational only on read, and not used on writes. */ - png_byte channels; /* number of data channels per pixel (1, 2, 3, 4)*/ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte spare_byte; /* to align the data, and for future use */ - png_byte signature[8]; /* magic bytes read by libpng from start of file */ - - /* The rest of the data is optional. If you are reading, check the - * valid field to see if the information in these are valid. If you - * are writing, set the valid field to those chunks you want written, - * and initialize the appropriate fields below. - */ - -#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - /* The gAMA chunk describes the gamma characteristics of the system - * on which the image was created, normally in the range [1.0, 2.5]. - * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. - */ - float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ -#endif - -#if defined(PNG_sRGB_SUPPORTED) - /* GR-P, 0.96a */ - /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ - png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ -#endif - -#if defined(PNG_TEXT_SUPPORTED) - /* The tEXt, and zTXt chunks contain human-readable textual data in - * uncompressed, compressed, and optionally compressed forms, respectively. - * The data in "text" is an array of pointers to uncompressed, - * null-terminated C strings. Each chunk has a keyword that describes the - * textual data contained in that chunk. Keywords are not required to be - * unique, and the text string may be empty. Any number of text chunks may - * be in an image. - */ - int num_text; /* number of comments read/to write */ - int max_text; /* current size of text array */ - png_textp text; /* array of comments read/to write */ -#endif /* PNG_TEXT_SUPPORTED */ - -#if defined(PNG_tIME_SUPPORTED) - /* The tIME chunk holds the last time the displayed image data was - * modified. See the png_time struct for the contents of this struct. - */ - png_time mod_time; -#endif - -#if defined(PNG_sBIT_SUPPORTED) - /* The sBIT chunk specifies the number of significant high-order bits - * in the pixel data. Values are in the range [1, bit_depth], and are - * only specified for the channels in the pixel data. The contents of - * the low-order bits is not specified. Data is valid if - * (valid & PNG_INFO_sBIT) is non-zero. - */ - png_color_8 sig_bit; /* significant bits in color channels */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ -defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The tRNS chunk supplies transparency data for paletted images and - * other image types that don't need a full alpha channel. There are - * "num_trans" transparency values for a paletted image, stored in the - * same order as the palette colors, starting from index 0. Values - * for the data are in the range [0, 255], ranging from fully transparent - * to fully opaque, respectively. For non-paletted images, there is a - * single color specified that should be treated as fully transparent. - * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. - */ - png_bytep trans; /* transparent values for paletted image */ - png_color_16 trans_values; /* transparent color for non-palette image */ -#endif - -#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The bKGD chunk gives the suggested image background color if the - * display program does not have its own background color and the image - * is needs to composited onto a background before display. The colors - * in "background" are normally in the same color space/depth as the - * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. - */ - png_color_16 background; -#endif - -#if defined(PNG_oFFs_SUPPORTED) - /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards - * and downwards from the top-left corner of the display, page, or other - * application-specific co-ordinate space. See the PNG_OFFSET_ defines - * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. - */ - png_int_32 x_offset; /* x offset on page */ - png_int_32 y_offset; /* y offset on page */ - png_byte offset_unit_type; /* offset units type */ -#endif - -#if defined(PNG_pHYs_SUPPORTED) - /* The pHYs chunk gives the physical pixel density of the image for - * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ - * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. - */ - png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ - png_uint_32 y_pixels_per_unit; /* vertical pixel density */ - png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ -#endif - -#if defined(PNG_hIST_SUPPORTED) - /* The hIST chunk contains the relative frequency or importance of the - * various palette entries, so that a viewer can intelligently select a - * reduced-color palette, if required. Data is an array of "num_palette" - * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) - * is non-zero. - */ - png_uint_16p hist; -#endif - -#ifdef PNG_cHRM_SUPPORTED - /* The cHRM chunk describes the CIE color characteristics of the monitor - * on which the PNG was created. This data allows the viewer to do gamut - * mapping of the input image to ensure that the viewer sees the same - * colors in the image as the creator. Values are in the range - * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float x_white; - float y_white; - float x_red; - float y_red; - float x_green; - float y_green; - float x_blue; - float y_blue; -#endif -#endif - -#if defined(PNG_pCAL_SUPPORTED) - /* The pCAL chunk describes a transformation between the stored pixel - * values and original physical data values used to create the image. - * The integer range [0, 2^bit_depth - 1] maps to the floating-point - * range given by [pcal_X0, pcal_X1], and are further transformed by a - * (possibly non-linear) transformation function given by "pcal_type" - * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ - * defines below, and the PNG-Group's PNG extensions document for a - * complete description of the transformations and how they should be - * implemented, and for a description of the ASCII parameter strings. - * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. - */ - png_charp pcal_purpose; /* pCAL chunk description string */ - png_int_32 pcal_X0; /* minimum value */ - png_int_32 pcal_X1; /* maximum value */ - png_charp pcal_units; /* Latin-1 string giving physical units */ - png_charpp pcal_params; /* ASCII strings containing parameter values */ - png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ - png_byte pcal_nparams; /* number of parameters given in pcal_params */ -#endif - -/* New members added in libpng-1.0.6 */ -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* storage for unknown chunks that the library doesn't recognize. */ - png_unknown_chunkp unknown_chunks; - png_size_t unknown_chunks_num; -#endif - -#if defined(PNG_iCCP_SUPPORTED) - /* iCCP chunk data. */ - png_charp iccp_name; /* profile name */ - png_charp iccp_profile; /* International Color Consortium profile data */ - /* Note to maintainer: should be png_bytep */ - png_uint_32 iccp_proflen; /* ICC profile data length */ - png_byte iccp_compression; /* Always zero */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) - /* data on sPLT chunks (there may be more than one). */ - png_sPLT_tp splt_palettes; - png_uint_32 splt_palettes_num; -#endif - -#if defined(PNG_sCAL_SUPPORTED) - /* The sCAL chunk describes the actual physical dimensions of the - * subject matter of the graphic. The chunk contains a unit specification - * a byte value, and two ASCII strings representing floating-point - * values. The values are width and height corresponsing to one pixel - * in the image. This external representation is converted to double - * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. - */ - png_byte scal_unit; /* unit of physical scale */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - double scal_pixel_width; /* width of one pixel */ - double scal_pixel_height; /* height of one pixel */ -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp scal_s_width; /* string containing height */ - png_charp scal_s_height; /* string containing width */ -#endif -#endif - -#if defined(PNG_INFO_IMAGE_SUPPORTED) - /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ - /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ - png_bytepp row_pointers; /* the image bits */ -#endif - -#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) - png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ -#endif - -#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) - png_fixed_point int_x_white; - png_fixed_point int_y_white; - png_fixed_point int_x_red; - png_fixed_point int_y_red; - png_fixed_point int_x_green; - png_fixed_point int_y_green; - png_fixed_point int_x_blue; - png_fixed_point int_y_blue; -#endif - -} png_info; - -typedef png_info FAR * png_infop; -typedef png_info FAR * FAR * png_infopp; - -/* Maximum positive integer used in PNG is (2^31)-1 */ -#define PNG_MAX_UINT ((png_uint_32)0x7fffffffL) - -/* These describe the color_type field in png_info. */ -/* color type masks */ -#define PNG_COLOR_MASK_PALETTE 1 -#define PNG_COLOR_MASK_COLOR 2 -#define PNG_COLOR_MASK_ALPHA 4 - -/* color types. Note that not all combinations are legal */ -#define PNG_COLOR_TYPE_GRAY 0 -#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) -#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) -#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) -#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) -/* aliases */ -#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA -#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA - -/* This is for compression type. PNG 1.0-1.2 only define the single type. */ -#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ -#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE - -/* This is for filter type. PNG 1.0-1.2 only define the single type. */ -#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ -#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ -#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE - -/* These are for the interlacing type. These values should NOT be changed. */ -#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ -#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ -#define PNG_INTERLACE_LAST 2 /* Not a valid value */ - -/* These are for the oFFs chunk. These values should NOT be changed. */ -#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ -#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ -#define PNG_OFFSET_LAST 2 /* Not a valid value */ - -/* These are for the pCAL chunk. These values should NOT be changed. */ -#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ -#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ -#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ -#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ -#define PNG_EQUATION_LAST 4 /* Not a valid value */ - -/* These are for the sCAL chunk. These values should NOT be changed. */ -#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ -#define PNG_SCALE_METER 1 /* meters per pixel */ -#define PNG_SCALE_RADIAN 2 /* radians per pixel */ -#define PNG_SCALE_LAST 3 /* Not a valid value */ - -/* These are for the pHYs chunk. These values should NOT be changed. */ -#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ -#define PNG_RESOLUTION_METER 1 /* pixels/meter */ -#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ - -/* These are for the sRGB chunk. These values should NOT be changed. */ -#define PNG_sRGB_INTENT_PERCEPTUAL 0 -#define PNG_sRGB_INTENT_RELATIVE 1 -#define PNG_sRGB_INTENT_SATURATION 2 -#define PNG_sRGB_INTENT_ABSOLUTE 3 -#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ - -/* This is for text chunks */ -#define PNG_KEYWORD_MAX_LENGTH 79 - -/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ -#define PNG_MAX_PALETTE_LENGTH 256 - -/* These determine if an ancillary chunk's data has been successfully read - * from the PNG header, or if the application has filled in the corresponding - * data in the info_struct to be written into the output file. The values - * of the PNG_INFO_ defines should NOT be changed. - */ -#define PNG_INFO_gAMA 0x0001 -#define PNG_INFO_sBIT 0x0002 -#define PNG_INFO_cHRM 0x0004 -#define PNG_INFO_PLTE 0x0008 -#define PNG_INFO_tRNS 0x0010 -#define PNG_INFO_bKGD 0x0020 -#define PNG_INFO_hIST 0x0040 -#define PNG_INFO_pHYs 0x0080 -#define PNG_INFO_oFFs 0x0100 -#define PNG_INFO_tIME 0x0200 -#define PNG_INFO_pCAL 0x0400 -#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ -#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ -#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ -#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ -#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ - -/* This is used for the transformation routines, as some of them - * change these values for the row. It also should enable using - * the routines for other purposes. - */ -typedef struct png_row_info_struct -{ - png_uint_32 width; /* width of row */ - png_uint_32 rowbytes; /* number of bytes in row */ - png_byte color_type; /* color type of row */ - png_byte bit_depth; /* bit depth of row */ - png_byte channels; /* number of channels (1, 2, 3, or 4) */ - png_byte pixel_depth; /* bits per pixel (depth * channels) */ -} png_row_info; - -typedef png_row_info FAR * png_row_infop; -typedef png_row_info FAR * FAR * png_row_infopp; - -/* These are the function types for the I/O functions and for the functions - * that allow the user to override the default I/O functions with his or her - * own. The png_error_ptr type should match that of user-supplied warning - * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. - */ -typedef struct png_struct_def png_struct; -typedef png_struct FAR * png_structp; - -typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); -typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); -typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); -typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, - int)); -typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, - int)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, - png_uint_32, int)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, - png_row_infop, png_bytep)); -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); -#endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); -#endif - -/* Transform masks for the high-level interface */ -#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ -#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ -#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ -#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ -#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ -#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ -#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ -#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ -#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ -#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ -#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ -#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ - -/* Flags for MNG supported features */ -#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 -#define PNG_FLAG_MNG_FILTER_64 0x04 -#define PNG_ALL_MNG_FEATURES 0x05 - -typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); -typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); - -/* The structure that holds the information to read and write PNG files. - * The only people who need to care about what is inside of this are the - * people who will be modifying the library for their own special needs. - * It should NOT be accessed directly by an application, except to store - * the jmp_buf. - */ - -struct png_struct_def -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf jmpbuf; /* used in png_error */ -#endif - png_error_ptr error_fn; /* function for printing errors and aborting */ - png_error_ptr warning_fn; /* function for printing warnings */ - png_voidp error_ptr; /* user supplied struct for error functions */ - png_rw_ptr write_data_fn; /* function for writing output data */ - png_rw_ptr read_data_fn; /* function for reading input data */ - png_voidp io_ptr; /* ptr to application struct for I/O functions*/ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr read_user_transform_fn; /* user read transform */ -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr write_user_transform_fn; /* user write transform */ -#endif - -/* These were added in libpng-1.0.2 */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_voidp user_transform_ptr; /* user supplied struct for user transform */ - png_byte user_transform_depth; /* bit depth of user transformed pixels */ - png_byte user_transform_channels; /* channels in user transformed pixels */ -#endif -#endif - - png_uint_32 mode; /* tells us where we are in the PNG file */ - png_uint_32 flags; /* flags indicating various things to libpng */ - png_uint_32 transformations; /* which transformations to perform */ - - z_stream zstream; /* pointer to decompression structure (below) */ - png_bytep zbuf; /* buffer for zlib */ - png_size_t zbuf_size; /* size of zbuf */ - int zlib_level; /* holds zlib compression level */ - int zlib_method; /* holds zlib compression method */ - int zlib_window_bits; /* holds zlib compression window bits */ - int zlib_mem_level; /* holds zlib compression memory level */ - int zlib_strategy; /* holds zlib compression strategy */ - - png_uint_32 width; /* width of image in pixels */ - png_uint_32 height; /* height of image in pixels */ - png_uint_32 num_rows; /* number of rows in current pass */ - png_uint_32 usr_width; /* width of row at start of write */ - png_uint_32 rowbytes; /* size of row in bytes */ - png_uint_32 irowbytes; /* size of current interlaced row in bytes */ - png_uint_32 iwidth; /* width of current interlaced row in pixels */ - png_uint_32 row_number; /* current row in interlace pass */ - png_bytep prev_row; /* buffer to save previous (unfiltered) row */ - png_bytep row_buf; /* buffer to save current (unfiltered) row */ - png_bytep sub_row; /* buffer to save "sub" row when filtering */ - png_bytep up_row; /* buffer to save "up" row when filtering */ - png_bytep avg_row; /* buffer to save "avg" row when filtering */ - png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ - png_row_info row_info; /* used for transformation routines */ - - png_uint_32 idat_size; /* current IDAT size for read */ - png_uint_32 crc; /* current chunk CRC value */ - png_colorp palette; /* palette from the input file */ - png_uint_16 num_palette; /* number of color entries in palette */ - png_uint_16 num_trans; /* number of transparency values */ - png_byte chunk_name[5]; /* null-terminated name of current chunk */ - png_byte compression; /* file compression type (always 0) */ - png_byte filter; /* file filter type (always 0) */ - png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - png_byte pass; /* current interlace pass (0 - 6) */ - png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ - png_byte color_type; /* color type of file */ - png_byte bit_depth; /* bit depth of file */ - png_byte usr_bit_depth; /* bit depth of users row */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte channels; /* number of channels in file */ - png_byte usr_channels; /* channels at start of write */ - png_byte sig_bytes; /* magic bytes read/written from start of file */ - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -#ifdef PNG_LEGACY_SUPPORTED - png_byte filler; /* filler byte for pixel expansion */ -#else - png_uint_16 filler; /* filler bytes for pixel expansion */ -#endif -#endif - -#if defined(PNG_bKGD_SUPPORTED) - png_byte background_gamma_type; -# ifdef PNG_FLOATING_POINT_SUPPORTED - float background_gamma; -# endif - png_color_16 background; /* background color in screen gamma space */ -# if defined(PNG_READ_GAMMA_SUPPORTED) - png_color_16 background_1; /* background normalized to gamma 1.0 */ -# endif /* PNG_READ_GAMMA && PNG_bKGD_SUPPORTED */ -#endif /* PNG_bKGD_SUPPORTED */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_flush_ptr output_flush_fn;/* Function for flushing output */ - png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ - png_uint_32 flush_rows; /* number of rows written since last flush */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float gamma; /* file gamma value */ - float screen_gamma; /* screen gamma value (display_exponent) */ -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep gamma_table; /* gamma table for 8-bit depth files */ - png_bytep gamma_from_1; /* converts from 1.0 to screen */ - png_bytep gamma_to_1; /* converts from file to 1.0 */ - png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ - png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ - png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) - png_color_8 sig_bit; /* significant bits in each available channel */ -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) - png_color_8 shift; /* shift for significant bit tranformation */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ - || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep trans; /* transparency values for paletted files */ - png_color_16 trans_values; /* transparency values for non-paletted files */ -#endif - - png_read_status_ptr read_row_fn; /* called after each row is decoded */ - png_write_status_ptr write_row_fn; /* called after each row is encoded */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_progressive_info_ptr info_fn; /* called after header data fully read */ - png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ - png_progressive_end_ptr end_fn; /* called after image is complete */ - png_bytep save_buffer_ptr; /* current location in save_buffer */ - png_bytep save_buffer; /* buffer for previously read data */ - png_bytep current_buffer_ptr; /* current location in current_buffer */ - png_bytep current_buffer; /* buffer for recently used data */ - png_uint_32 push_length; /* size of current input chunk */ - png_uint_32 skip_length; /* bytes to skip in input data */ - png_size_t save_buffer_size; /* amount of data now in save_buffer */ - png_size_t save_buffer_max; /* total size of save_buffer */ - png_size_t buffer_size; /* total amount of available input data */ - png_size_t current_buffer_size; /* amount of data now in current_buffer */ - int process_mode; /* what push library is currently doing */ - int cur_palette; /* current push library palette index */ - -# if defined(PNG_TEXT_SUPPORTED) - png_size_t current_text_size; /* current size of text input data */ - png_size_t current_text_left; /* how much text left to read in input */ - png_charp current_text; /* current text chunk buffer */ - png_charp current_text_ptr; /* current location in current_text */ -# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* for the Borland special 64K segment handler */ - png_bytepp offset_table_ptr; - png_bytep offset_table; - png_uint_16 offset_table_number; - png_uint_16 offset_table_count; - png_uint_16 offset_table_count_free; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - png_bytep palette_lookup; /* lookup table for dithering */ - png_bytep dither_index; /* index translation for palette files */ -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) - png_uint_16p hist; /* histogram */ -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_byte heuristic_method; /* heuristic for row filter selection */ - png_byte num_prev_filters; /* number of weights for previous rows */ - png_bytep prev_filters; /* filter type(s) of previous row(s) */ - png_uint_16p filter_weights; /* weight(s) for previous line(s) */ - png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ - png_uint_16p filter_costs; /* relative filter calculation cost */ - png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_charp time_buffer; /* String to hold RFC 1123 time text */ -#endif - -/* New members added in libpng-1.0.6 */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) - png_voidp user_chunk_ptr; - png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - int num_chunk_list; - png_bytep chunk_list; -#endif - -/* New members added in libpng-1.0.3 */ -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_byte rgb_to_gray_status; - /* These were changed from png_byte in libpng-1.0.6 */ - png_uint_16 rgb_to_gray_red_coeff; - png_uint_16 rgb_to_gray_green_coeff; - png_uint_16 rgb_to_gray_blue_coeff; -#endif - -/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ - defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* changed from png_byte to png_uint_32 at version 1.2.0 */ - png_byte mng_features_permitted; -#endif - -/* New member added in libpng-1.0.7 */ -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_fixed_point int_gamma; -#endif - -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_byte filter_type; -#endif - -#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) -/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ - png_uint_32 row_buf_size; -#endif - -/* New members added in libpng-1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - png_byte mmx_bitdepth_threshold; - png_uint_32 mmx_rowbytes_threshold; - png_uint_32 asm_flags; -#endif - -/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ -#ifdef PNG_USER_MEM_SUPPORTED - png_voidp mem_ptr; /* user supplied struct for mem functions */ - png_malloc_ptr malloc_fn; /* function for allocating memory */ - png_free_ptr free_fn; /* function for freeing memory */ -#endif - -}; - - -/* This prevents a compiler error in png_get_copyright() in png.c if png.c - and png.h are both at version 1.0.12 - */ -typedef png_structp version_1_0_12; - -typedef png_struct FAR * FAR * png_structpp; - -/* Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng.txt for the - * full explanation, see example.c for the summary. This just provides - * a simple one line description of the use of each function. - */ - -/* Returns the version number of the library */ -extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); - -/* Tell lib we have already handled the first magic bytes. - * Handling more than 8 bytes from the beginning of the file is an error. - */ -extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, - int num_bytes)); - -/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a - * PNG file. Returns zero if the supplied bytes match the 8-byte PNG - * signature, and non-zero otherwise. Having num_to_check == 0 or - * start > 7 will always fail (ie return non-zero). - */ -extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, - png_size_t num_to_check)); - -/* Simple signature checking function. This is the same as calling - * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). - */ -extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); - -/* Allocate and initialize png_ptr struct for reading, and any other memory. */ -extern PNG_EXPORT(png_structp,png_create_read_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -/* Allocate and initialize png_ptr struct for writing, and any other memory */ -extern PNG_EXPORT(png_structp,png_create_write_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) - PNGARG((png_structp png_ptr)); - -extern PNG_EXPORT(void,png_set_compression_buffer_size) - PNGARG((png_structp png_ptr, png_uint_32 size)); - -/* Reset the compression stream */ -extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); - -/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_structp,png_create_read_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -extern PNG_EXPORT(png_structp,png_create_write_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -#endif - -/* Write a PNG chunk - size, type, (optional) data, CRC. */ -extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_bytep data, png_size_t length)); - -/* Write the start of a PNG chunk - length and chunk name. */ -extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_uint_32 length)); - -/* Write the data of a PNG chunk started with png_write_chunk_start(). */ -extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); - -/* Allocate and initialize the info structure */ -extern PNG_EXPORT(png_infop,png_create_info_struct) - PNGARG((png_structp png_ptr)); - -/* Initialize the info structure (old interface - DEPRECATED) */ -extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); -#define png_info_init(info_ptr) png_info_init_3(&info_ptr, sizeof(png_info)); -extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, - png_size_t png_info_struct_size)); - -/* Writes all the PNG information before the image. */ -extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* read the information before the actual image data. */ -extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) - PNGARG((png_structp png_ptr, png_timep ptime)); -#endif - -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* convert from a struct tm to png_time */ -extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, - struct tm FAR * ttime)); - -/* convert from time_t to png_time. Uses gmtime() */ -extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, - time_t ttime)); -#endif /* PNG_WRITE_tIME_SUPPORTED */ -#endif /* _WIN32_WCE */ - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Use blue, green, red order for pixels. */ -extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* Expand the grayscale to 24-bit RGB if necessary. */ -extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* Reduce RGB to grayscale. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, - int error_action, double red, double green )); -#endif -extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green )); -extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp - png_ptr)); -#endif - -extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, - png_colorp palette)); - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte to 24-bit RGB images. */ -extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -/* The values of the PNG_FILLER_ defines should NOT be changed */ -#define PNG_FILLER_BEFORE 0 -#define PNG_FILLER_AFTER 1 -#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swap bytes in 16-bit depth files. */ -extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Swap packing order of pixels in bytes. */ -extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Converts files to legal bit depths. */ -extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, - png_color_8p true_bits)); -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. */ -extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -/* Invert monochrome files */ -extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Handle alpha and tRNS by replacing with a background color. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)); -#endif -#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -#define PNG_BACKGROUND_GAMMA_SCREEN 1 -#define PNG_BACKGROUND_GAMMA_FILE 2 -#define PNG_BACKGROUND_GAMMA_UNIQUE 3 -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip the second byte of information from a 16-bit depth file. */ -extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Turn on dithering, and reduce the palette to the number of colors available. */ -extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_uint_16p histogram, int full_dither)); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Handle gamma correction. Screen_gamma=(display_exponent) */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, - double screen_gamma, double default_file_gamma)); -#endif -#endif - -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ -/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ -extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, - int empty_plte_permitted)); -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set how many lines between output flushes - 0 for no flushing */ -extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); -/* Flush the current PNG output buffer */ -extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); -#endif - -/* optional update palette with requested transformations */ -extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); - -/* optional call to update the users info structure */ -extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* read a one or more rows of image data.*/ -extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); - -/* read a row of data.*/ -extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, - png_bytep row, - png_bytep display_row)); - -/* read the whole image into memory at once. */ -extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, - png_bytepp image)); - -/* write a row of image data */ -extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, - png_bytep row)); - -/* write a few rows of image data */ -extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_uint_32 num_rows)); - -/* write the image data */ -extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, - png_bytepp image)); - -/* writes the end of the PNG file. */ -extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* read the end of the PNG file. */ -extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* free any memory associated with the png_info_struct */ -extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, - png_infopp info_ptr_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp - png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); - -/* free all memory used by the read (old method - NOT DLL EXPORTED) */ -extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, - png_infop end_info_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_write_struct) - PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); - -/* free any memory used in info_ptr struct (old method - NOT DLL EXPORTED) */ -extern void png_write_destroy_info PNGARG((png_infop info_ptr)); - -/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ -extern void png_write_destroy PNGARG((png_structp png_ptr)); - -/* set the libpng method of handling chunk CRC errors */ -extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, - int crit_action, int ancil_action)); - -/* Values for png_set_crc_action() to say how to handle CRC errors in - * ancillary and critical chunks, and whether to use the data contained - * therein. Note that it is impossible to "discard" data in a critical - * chunk. For versions prior to 0.90, the action was always error/quit, - * whereas in version 0.90 and later, the action for CRC errors in ancillary - * chunks is warn/discard. These values should NOT be changed. - * - * value action:critical action:ancillary - */ -#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ -#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ -#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ -#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ -#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ -#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ - -/* These functions give the user control over the scan-line filtering in - * libpng and the compression methods used by zlib. These functions are - * mainly useful for testing, as the defaults should work with most users. - * Those users who are tight on memory or want faster performance at the - * expense of compression can modify them. See the compression library - * header file (zlib.h) for an explination of the compression functions. - */ - -/* set the filtering method(s) used by libpng. Currently, the only valid - * value for "method" is 0. - */ -extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, - int filters)); - -/* Flags for png_set_filter() to say which filters to use. The flags - * are chosen so that they don't conflict with real filter types - * below, in case they are supplied instead of the #defined constants. - * These values should NOT be changed. - */ -#define PNG_NO_FILTERS 0x00 -#define PNG_FILTER_NONE 0x08 -#define PNG_FILTER_SUB 0x10 -#define PNG_FILTER_UP 0x20 -#define PNG_FILTER_AVG 0x40 -#define PNG_FILTER_PAETH 0x80 -#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ - PNG_FILTER_AVG | PNG_FILTER_PAETH) - -/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. - * These defines should NOT be changed. - */ -#define PNG_FILTER_VALUE_NONE 0 -#define PNG_FILTER_VALUE_SUB 1 -#define PNG_FILTER_VALUE_UP 2 -#define PNG_FILTER_VALUE_AVG 3 -#define PNG_FILTER_VALUE_PAETH 4 -#define PNG_FILTER_VALUE_LAST 5 - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ -/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ - * defines, either the default (minimum-sum-of-absolute-differences), or - * the experimental method (weighted-minimum-sum-of-absolute-differences). - * - * Weights are factors >= 1.0, indicating how important it is to keep the - * filter type consistent between rows. Larger numbers mean the current - * filter is that many times as likely to be the same as the "num_weights" - * previous filters. This is cumulative for each previous row with a weight. - * There needs to be "num_weights" values in "filter_weights", or it can be - * NULL if the weights aren't being specified. Weights have no influence on - * the selection of the first row filter. Well chosen weights can (in theory) - * improve the compression for a given image. - * - * Costs are factors >= 1.0 indicating the relative decoding costs of a - * filter type. Higher costs indicate more decoding expense, and are - * therefore less likely to be selected over a filter with lower computational - * costs. There needs to be a value in "filter_costs" for each valid filter - * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't - * setting the costs. Costs try to improve the speed of decompression without - * unduly increasing the compressed image size. - * - * A negative weight or cost indicates the default value is to be used, and - * values in the range [0.0, 1.0) indicate the value is to remain unchanged. - * The default values for both weights and costs are currently 1.0, but may - * change if good general weighting/cost heuristics can be found. If both - * the weights and costs are set to 1.0, this degenerates the WEIGHTED method - * to the UNWEIGHTED method, but with added encoding time/computation. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, - int heuristic_method, int num_weights, png_doublep filter_weights, - png_doublep filter_costs)); -#endif -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -/* Heuristic used for row filter selection. These defines should NOT be - * changed. - */ -#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ -#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ -#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ -#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ - -/* Set the library compression level. Currently, valid values range from - * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 - * (0 - no compression, 9 - "maximal" compression). Note that tests have - * shown that zlib compression levels 3-6 usually perform as well as level 9 - * for PNG images, and do considerably fewer caclulations. In the future, - * these values may not correspond directly to the zlib compression levels. - */ -extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, - int level)); - -extern PNG_EXPORT(void,png_set_compression_mem_level) - PNGARG((png_structp png_ptr, int mem_level)); - -extern PNG_EXPORT(void,png_set_compression_strategy) - PNGARG((png_structp png_ptr, int strategy)); - -extern PNG_EXPORT(void,png_set_compression_window_bits) - PNGARG((png_structp png_ptr, int window_bits)); - -extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, - int method)); - -/* These next functions are called for input/output, memory, and error - * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, - * and call standard C I/O routines such as fread(), fwrite(), and - * fprintf(). These functions can be made to use other I/O routines - * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng.txt for - * more information. - */ - -#if !defined(PNG_NO_STDIO) -/* Initialize the input/output for the PNG file to the default functions. */ -extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); -#endif - -/* Replace the (error and abort), and warning functions with user - * supplied functions. If no messages are to be printed you must still - * write and use replacement functions. The replacement error_fn should - * still do a longjmp to the last setjmp location if you are using this - * method of error handling. If error_fn or warning_fn is NULL, the - * default function will be used. - */ - -extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); - -/* Return the user pointer associated with the error functions */ -extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); - -/* Replace the default data output functions with a user supplied one(s). - * If buffered output is not used, then output_flush_fn can be set to NULL. - * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time - * output_flush_fn will be ignored (and thus can be NULL). - */ -extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); - -/* Replace the default data input function with a user supplied one. */ -extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr read_data_fn)); - -/* Return the user pointer associated with the I/O functions */ -extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); - -extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, - png_read_status_ptr read_row_fn)); - -extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, - png_write_status_ptr write_row_fn)); - -#ifdef PNG_USER_MEM_SUPPORTED -/* Replace the default memory allocation functions with user supplied one(s). */ -extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -/* Return the user pointer associated with the memory functions */ -extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr read_user_transform_fn)); -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr write_user_transform_fn)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp - png_ptr, png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); -/* Return the user pointer associated with the user transform functions */ -extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) - PNGARG((png_structp png_ptr)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp - png_ptr)); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* Sets the function callbacks for the push reader, and a pointer to a - * user-defined structure available to the callback functions. - */ -extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, - png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn)); - -/* returns the user pointer associated with the push read functions */ -extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) - PNGARG((png_structp png_ptr)); - -/* function to be called when data becomes available */ -extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); - -/* function that combines rows. Not very much different than the - * png_combine_row() call. Is this even used????? - */ -extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, - png_bytep old_row, png_bytep new_row)); -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, - png_uint_32 size)); - -/* frees a pointer allocated by png_malloc() */ -extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); - -/* Free data that was allocated internally */ -extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 free_me, int num)); -#ifdef PNG_FREE_ME_SUPPORTED -/* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application */ -extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, - png_infop info_ptr, int freer, png_uint_32 mask)); -#endif -/* assignments for png_data_freer */ -#define PNG_DESTROY_WILL_FREE_DATA 1 -#define PNG_SET_WILL_FREE_DATA 1 -#define PNG_USER_WILL_FREE_DATA 2 -/* Flags for png_ptr->free_me and info_ptr->free_me */ -#define PNG_FREE_HIST 0x0008 -#define PNG_FREE_ICCP 0x0010 -#define PNG_FREE_SPLT 0x0020 -#define PNG_FREE_ROWS 0x0040 -#define PNG_FREE_PCAL 0x0080 -#define PNG_FREE_SCAL 0x0100 -#define PNG_FREE_UNKN 0x0200 -#define PNG_FREE_LIST 0x0400 -#define PNG_FREE_PLTE 0x1000 -#define PNG_FREE_TRNS 0x2000 -#define PNG_FREE_TEXT 0x4000 -#define PNG_FREE_ALL 0x7fff -#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ - -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, - png_uint_32 size)); -extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, - png_voidp ptr)); -#endif - -extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, - png_voidp s1, png_voidp s2, png_uint_32 size)); - -extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, - png_voidp s1, int value, png_uint_32 size)); - -#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ -extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, - int check)); -#endif /* USE_FAR_KEYWORD */ - -/* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, - png_const_charp error)); - -/* The same, but the chunk name is prepended to the error string. */ -extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, - png_const_charp error)); - -/* Non-fatal error in libpng. Can continue, but may have a problem. */ -extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, - png_const_charp message)); - -/* Non-fatal error in libpng, chunk name is prepended to message. */ -extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, - png_const_charp message)); - -/* The png_set_ functions are for storing values in the png_info_struct. - * Similarly, the png_get_ calls are used to read values from the - * png_info_struct, either storing the parameters in the passed variables, or - * setting pointers into the png_info_struct where the data is stored. The - * png_get_ functions return a non-zero value if the data was available - * in info_ptr, or return zero and do not change any of the parameters if the - * data was not available. - * - * These functions should be used instead of directly accessing png_info - * to avoid problems with future changes in the size and internal layout of - * png_info_struct. - */ -/* Returns "flag" if chunk data is valid in info_ptr. */ -extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 flag)); - -/* Returns number of bytes needed to hold a transformed row. */ -extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* Returns row_pointers, which is an array of pointers to scanlines that was -returned from png_read_png(). */ -extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, -png_infop info_ptr)); -/* Set row_pointers, which is an array of pointers to scanlines for use -by png_write_png(). */ -extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytepp row_pointers)); -#endif - -/* Returns number of color channels in image. */ -extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* Returns image width in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image height in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image bit_depth. */ -extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image color_type. */ -extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image filter_type. */ -extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image interlace_type. */ -extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image compression_type. */ -extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image resolution in pixels per meter, from pHYs chunk data. */ -extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns pixel aspect ratio, computed from pHYs chunk data. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -#endif - -/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -/* Returns pointer to signature string read from PNG header */ -extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p *background)); -#endif - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p background)); -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point - *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, - png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point - *int_blue_x, png_fixed_point *int_blue_y)); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double white_x, double white_y, double red_x, - double red_y, double green_x, double green_y, double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *file_gamma)); -#endif -extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_file_gamma)); -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double file_gamma)); -#endif -extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_file_gamma)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p *hist)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p hist)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); - -extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, - int *unit_type)); -#endif - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, - int *type, int *nparams, png_charp *units, png_charpp *params)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, - int type, int nparams, png_charp units, png_charpp params)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp *palette, int *num_palette)); - -extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp palette, int num_palette)); - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p *sig_bit)); -#endif - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p sig_bit)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *intent)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen)); - /* Note to maintainer: profile should be png_bytepp */ -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tpp entries)); -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) -/* png_get_text also returns the number of text chunks in *num_text */ -extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp *text_ptr, int *num_text)); -#endif - -/* - * Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. - */ - -#if defined(PNG_TEXT_SUPPORTED) -extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep *mod_time)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep mod_time)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep *trans, int *num_trans, - png_color_16p *trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep trans, int num_trans, - png_color_16p trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, double *width, double *height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED */ - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, double width, double height)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); -#endif -#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* provide a list of chunks and how they are to be handled, if the built-in - handling or default unknown chunk handling is not desired. Any chunks not - listed will be handled in the default manner. The IHDR and IEND chunks - must not be listed. - keep = 0: follow default behavour - = 1: do not keep - = 2: keep only if safe-to-copy - = 3: keep even if unsafe-to-copy -*/ -extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp - png_ptr, int keep, png_bytep chunk_list, int num_chunks)); -extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); -extern PNG_EXPORT(void, png_set_unknown_chunk_location) - PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); -extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp - png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); -#endif - -/* Png_free_data() will turn off the "valid" flag for anything it frees. - If you need to turn it off for a chunk that your application has freed, - you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ -extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, - png_infop info_ptr, int mask)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* The "params" pointer is currently not used and is for future expansion. */ -extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -#endif - -/* Define PNG_DEBUG at compile time for debugging information. Higher - * numbers for PNG_DEBUG mean more debugging information. This has - * only been added since version 0.95 so it is not implemented throughout - * libpng yet, but more support will be added as needed. - */ -#ifdef PNG_DEBUG -#if (PNG_DEBUG > 0) -#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) -#include -#if (PNG_DEBUG > 1) -#define png_debug(l,m) _RPT0(_CRT_WARN,m) -#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) -#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) -#endif -#else /* PNG_DEBUG_FILE || !_MSC_VER */ -#ifndef PNG_DEBUG_FILE -#define PNG_DEBUG_FILE stderr -#endif /* PNG_DEBUG_FILE */ -#if (PNG_DEBUG > 1) -#define png_debug(l,m) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ -} -#define png_debug1(l,m,p1) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ -} -#define png_debug2(l,m,p1,p2) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ -} -#endif /* (PNG_DEBUG > 1) */ -#endif /* _MSC_VER */ -#endif /* (PNG_DEBUG > 0) */ -#endif /* PNG_DEBUG */ -#ifndef png_debug -#define png_debug(l, m) -#endif -#ifndef png_debug1 -#define png_debug1(l, m, p1) -#endif -#ifndef png_debug2 -#define png_debug2(l, m, p1, p2) -#endif - -extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); - -extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); - -#ifdef PNG_MNG_FEATURES_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp - png_ptr, png_uint_32 mng_features_permitted)); -#endif - -/* png_mmx_support will be included unconditionally starting in version 1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) || defined(PNG_USE_PNGGCCRD) -/* png.c, pnggccrd.c, or pngvcrd.c */ -extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - -/* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. */ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp - png_ptr, png_uint_32 strip_mode)); -#endif - -/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ - -#define PNG_HEADER_VERSION_STRING \ - " libpng version 1.0.12 - June 8, 2001 (header)\n" - -#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED -/* With these routines we avoid an integer divide, which will be slower on - * most machines. However, it does take more operations than the corresponding - * divide method, so it may be slower on a few RISC systems. There are two - * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. - * - * Note that the rounding factors are NOT supposed to be the same! 128 and - * 32768 are correct for the NODIV code; 127 and 32767 are correct for the - * standard method. - * - * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] - */ - - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ - -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 - \ - (png_uint_16)(alpha)) + (png_uint_16)128); \ - (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } - -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(png_uint_32)(65535L - \ - (png_uint_32)(alpha)) + (png_uint_32)32768L); \ - (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } - -#else /* standard method using integer division */ - -# define png_composite(composite, fg, alpha, bg) \ - (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - (png_uint_16)127) / 255) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ - (png_uint_32)32767) / (png_uint_32)65535L) - -#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ - -/* These next functions are used internally in the code. They generally - * shouldn't be used unless you are writing code to add or replace some - * functionality in libpng. More information about most functions can - * be found in the files where the functions are located. - */ - -#if defined(PNG_INTERNAL) - -/* Various modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. - */ -#define PNG_HAVE_IHDR 0x01 -#define PNG_HAVE_PLTE 0x02 -#define PNG_HAVE_IDAT 0x04 -#define PNG_AFTER_IDAT 0x08 -#define PNG_HAVE_IEND 0x10 -#define PNG_HAVE_gAMA 0x20 -#define PNG_HAVE_cHRM 0x40 -#define PNG_HAVE_sRGB 0x80 -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 - -/* flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_DITHER 0x0040 -#define PNG_BACKGROUND 0x0080 -#define PNG_BACKGROUND_EXPAND 0x0100 - /* 0x0200 unused */ -#define PNG_16_TO_8 0x0400 -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000L -#define PNG_PACKSWAP 0x10000L -#define PNG_SWAP_ALPHA 0x20000L -#define PNG_STRIP_ALPHA 0x40000L -#define PNG_INVERT_ALPHA 0x80000L -#define PNG_USER_TRANSFORM 0x100000L -#define PNG_RGB_TO_GRAY_ERR 0x200000L -#define PNG_RGB_TO_GRAY_WARN 0x400000L -#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ - -/* flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 - -/* Scaling factor for filter heuristic weighting calculations */ -#define PNG_WEIGHT_SHIFT 8 -#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) -#define PNG_COST_SHIFT 3 -#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) - -/* flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 -#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 -#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 -#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 -#define PNG_FLAG_ZLIB_FINISHED 0x0020 -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_FREE_PLTE 0x1000 -#define PNG_FLAG_FREE_TRNS 0x2000 -#define PNG_FLAG_FREE_HIST 0x4000 -#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L -#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L - -/* For use in png_set_keep_unknown, png_handle_as_unknown */ -#define HANDLE_CHUNK_AS_DEFAULT 0 -#define HANDLE_CHUNK_NEVER 1 -#define HANDLE_CHUNK_IF_SAFE 2 -#define HANDLE_CHUNK_ALWAYS 3 - -#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ - PNG_FLAG_CRC_ANCILLARY_NOWARN) - -#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ - PNG_FLAG_CRC_CRITICAL_IGNORE) - -#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ - PNG_FLAG_CRC_CRITICAL_MASK) - -/* save typing and make code easier to understand */ -#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ - abs((int)((c1).green) - (int)((c2).green)) + \ - abs((int)((c1).blue) - (int)((c2).blue))) - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* place to hold the signature string for a PNG file. */ -#ifdef PNG_USE_GLOBAL_ARRAYS - PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; -#else -#define png_sig png_sig_bytes(NULL) -#endif -#endif /* PNG_NO_EXTERN */ - -/* Constant strings for known chunk types. If you need to add a chunk, - * define the name here, and add an invocation of the macro in png.c and - * wherever it's needed. - */ -#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} -#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} -#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} -#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} -#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} -#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} -#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} -#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} -#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} -#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} -#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} -#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} -#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} -#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} -#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} -#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} -#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} -#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} -#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} -#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} -#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} - -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; -PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; -#endif /* PNG_USE_GLOBAL_ARRAYS */ - - -/* Inline macros to do direct reads of bytes from the input buffer. These - * require that you are using an architecture that uses PNG byte ordering - * (MSB first) and supports unaligned data storage. I think that PowerPC - * in big-endian mode and 680x0 are the only ones that will support this. - * The x86 line of processors definitely do not. The png_get_int_32() - * routine also assumes we are using two's complement format for negative - * values, which is almost certainly true. - */ -#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) -# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) -# define png_get_int_32(buf) ( *((png_int_32p) (buf))) -# endif -# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) -# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) -#else -# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) -PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf)); -# endif -PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf)); -PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf)); -#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ - -/* Initialize png_ptr struct for reading, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_read_struct instead). - */ -extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); -#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, sizeof(png_struct)); -extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); - -/* Initialize png_ptr struct for writing, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_write_struct instead). - */ -extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); -#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, sizeof(png_struct)); -extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); - -/* Allocate memory for an internal libpng struct */ -PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); - -/* Free memory from internal libpng struct */ -PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); - -PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr - malloc_fn, png_voidp mem_ptr)); -PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, - png_free_ptr free_fn, png_voidp mem_ptr)); - -/* Free any memory that info_ptr points to and reset struct. */ -PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* Function to allocate memory for zlib. */ -PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); - -/* Function to free memory for zlib */ -PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); - -/* Reset the CRC variable */ -PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); - -/* Write the "data" buffer to whatever output you are using. */ -PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read data from whatever input you are using into the "data" buffer */ -PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read bytes into buf, and update png_ptr->crc */ -PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, - png_size_t length)); - -/* Decompress data in a chunk that uses compression */ -#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ - defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_length, png_size_t *data_length)); -#endif - -/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ -PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); - -/* Read the CRC from the file and compare it to the libpng calculated CRC */ -PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); - -/* Calculate the CRC over a section of data. Note that we are only - * passing a maximum of 64K on systems that have this as a memory limit, - * since this is the maximum buffer size we can specify. - */ -PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, - png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); -#endif - -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). - * The only currently known PNG chunks that use signed numbers are - * the ancillary extension chunks, oFFs and pCAL. - */ -PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i)); - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i)); -#endif - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i)); - -/* simple function to write the signature */ -PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); - -/* write various chunks */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. - */ -PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, - png_uint_32 height, - int bit_depth, int color_type, int compression_method, int filter_method, - int interlace_method)); - -PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, - png_uint_32 num_pal)); - -PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point - file_gamma)); -#endif -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, - int color_type)); -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, - double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, - png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, - int intent)); -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, - png_charp name, int compression_type, - png_charp profile, int proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, - png_sPLT_tp palette)); -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, - png_color_16p values, int number, int color_type)); -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, - png_color_16p values, int color_type)); -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, - int num_hist)); -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, - png_charp key, png_charpp new_key)); -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len)); -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len, int compression)); -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, - int compression, png_charp key, png_charp lang, png_charp lang_key, - png_charp text)); -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, - png_uint_32 x_offset, png_uint_32 y_offset, int unit_type)); -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, - png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params)); -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, - png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, - int unit_type)); -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, - png_timep mod_time)); -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, - int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, - int unit, png_charp width, png_charp height)); -#endif -#endif -#endif - -/* Called when finished processing a row of data */ -PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); - -/* Internal use only. Called before first row of data */ -PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); -#endif - -/* combine a row of data, dealing with alpha, etc. if requested */ -PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, - int mask)); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -/* expand an interlaced row */ -/* OLD pre-1.0.9 interface: -PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass, png_uint_32 transformations)); - */ -PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); -#endif - -/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* grab pixels out of a row for an interlaced pass */ -PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass)); -#endif - -/* unfilter a row */ -PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, - png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); - -/* Choose the best filter to use and filter the row data */ -PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, - png_row_infop row_info)); - -/* Write out the filtered row. */ -PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, - png_bytep filtered_row)); -/* finish a row while reading, dealing with interlacing passes, etc. */ -PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); - -/* initialize the row buffers, etc. */ -PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); -/* optional call to update the users info structure */ -PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* these are the functions that do the transformations */ -#if defined(PNG_READ_FILLER_SUPPORTED) -PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 filler, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop - row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) -PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p sig_bits)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, - png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); - -# if defined(PNG_CORRECT_PALETTE_SUPPORTED) -PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette)); -# endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) -PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 bit_depth)); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p bit_depth)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background, - png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift)); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift)); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, - png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); -PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, - png_bytep row, png_color_16p trans_value)); -#endif - -/* The following decodes the appropriate chunks, and does error correction, - * then calls the appropriate callback for the chunk if it is valid. - */ - -/* decode the IHDR chunk */ -PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); - -#if defined(PNG_READ_bKGD_SUPPORTED) -PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_gAMA_SUPPORTED) -PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_iCCP_SUPPORTED) -extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sPLT_SUPPORTED) -extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_sRGB_SUPPORTED) -PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tRNS_SUPPORTED) -PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -PNG_EXTERN int png_handle_as_unknown PNGARG((png_structp png_ptr, png_bytep - chunk_name)); -#endif - -PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); - -PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, - png_bytep chunk_name)); - -/* handle the transformations for reading and writing */ -PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); - -PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, - png_uint_32 length)); -PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); -PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ - -#endif /* PNG_INTERNAL */ - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -/* do not put anything past this line */ -#endif /* PNG_H */ diff --git a/freeimage241/Source/LibPNG/pngasmrd.h b/freeimage241/Source/LibPNG/pngasmrd.h deleted file mode 100644 index 2db1852..0000000 --- a/freeimage241/Source/LibPNG/pngasmrd.h +++ /dev/null @@ -1,11 +0,0 @@ -/* pngasmrd.h - assembler version of utilities to read a PNG file - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 2001 Glenn Randers-Pehrson - * - */ - -/* This file is obsolete in libpng-1.0.9 and later; its contents now appear - * at the end of pngconf.h. - */ diff --git a/freeimage241/Source/LibPNG/pngconf.h b/freeimage241/Source/LibPNG/pngconf.h deleted file mode 100644 index 0ce1b44..0000000 --- a/freeimage241/Source/LibPNG/pngconf.h +++ /dev/null @@ -1,1336 +0,0 @@ -/* pngconf.h - machine configurable file for libpng - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* Any machine specific code is near the front of this file, so if you - * are configuring libpng for a machine, you may want to read the section - * starting here down to where it starts to typedef png_color, png_text, - * and png_info. - */ - -#ifndef PNGCONF_H -#define PNGCONF_H - -/* This is the size of the compression buffer, and thus the size of - * an IDAT chunk. Make this whatever size you feel is best for your - * machine. One of these will be allocated per png_struct. When this - * is full, it writes the data to the disk, and does some other - * calculations. Making this an extremely small size will slow - * the library down, but you may want to experiment to determine - * where it becomes significant, if you are concerned with memory - * usage. Note that zlib allocates at least 32Kb also. For readers, - * this describes the size of the buffer available to read the data in. - * Unless this gets smaller than the size of a row (compressed), - * it should not make much difference how big this is. - */ - -#ifndef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 8192 -#endif - -/* Enable if you want a write-only libpng */ - -#ifndef PNG_NO_READ_SUPPORTED -# define PNG_READ_SUPPORTED -#endif - -/* Enable if you want a read-only libpng */ - -#ifndef PNG_NO_WRITE_SUPPORTED -# define PNG_WRITE_SUPPORTED -#endif - -/* Enabled by default in 1.2.0. You can disable this if you don't need to - support PNGs that are embedded in MNG datastreams */ -/* -#ifndef PNG_NO_MNG_FEATURES -# ifndef PNG_MNG_FEATURES_SUPPORTED -# define PNG_MNG_FEATURES_SUPPORTED -# endif -#endif -*/ - -#ifndef PNG_NO_FLOATING_POINT_SUPPORTED -# ifndef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FLOATING_POINT_SUPPORTED -# endif -#endif - -/* If you are running on a machine where you cannot allocate more - * than 64K of memory at once, uncomment this. While libpng will not - * normally need that much memory in a chunk (unless you load up a very - * large file), zlib needs to know how big of a chunk it can use, and - * libpng thus makes sure to check any memory allocation to verify it - * will fit into memory. -#define PNG_MAX_MALLOC_64K - */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) -# define PNG_MAX_MALLOC_64K -#endif - -/* Special munging to support doing things the 'cygwin' way: - * 'Normal' png-on-win32 defines/defaults: - * PNG_BUILD_DLL -- building dll - * PNG_USE_DLL -- building an application, linking to dll - * (no define) -- building static library, or building an - * application and linking to the static lib - * 'Cygwin' defines/defaults: - * PNG_BUILD_DLL -- building the dll - * (no define) -- building an application, linking to the dll - * PNG_STATIC -- building the static lib, or building an application - * that links to the static lib. - * ALL_STATIC -- building various static libs, or building an application - * that links to the static libs. - * Thus, - * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and - * this bit of #ifdefs will define the 'correct' config variables based on - * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but - * unnecessary. - * - * Also, the precedence order is: - * ALL_STATIC (since we can't #undef something outside our namespace) - * PNG_BUILD_DLL - * PNG_STATIC - * (nothing) == PNG_USE_DLL - */ -#if defined(__CYGWIN__) -# if defined(ALL_STATIC) -# if defined(PNG_BUILD_DLL) -# undef PNG_BUILD_DLL -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# if !defined(PNG_STATIC) -# define PNG_STATIC -# endif -# else -# if defined (PNG_BUILD_DLL) -# if defined(PNG_STATIC) -# undef PNG_STATIC -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# else -# if defined(PNG_STATIC) -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# else -# if !defined(PNG_USE_DLL) -# define PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# endif -# endif -# endif -#endif - -/* This protects us against compilers that run on a windowing system - * and thus don't have or would rather us not use the stdio types: - * stdin, stdout, and stderr. The only one currently used is stderr - * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will - * prevent these from being compiled and used. #defining PNG_NO_STDIO - * will also prevent these, plus will prevent the entire set of stdio - * macros and functions (FILE *, printf, etc.) from being compiled and used, - * unless (PNG_DEBUG > 0) has been #defined. - * - * #define PNG_NO_CONSOLE_IO - * #define PNG_NO_STDIO - */ - -#if defined(_WIN32_WCE) -# include - /* Console I/O functions are not supported on WindowsCE */ -# define PNG_NO_CONSOLE_IO -# ifdef PNG_DEBUG -# undef PNG_DEBUG -# endif -#endif - -#ifdef PNG_BUILD_DLL -# ifndef PNG_CONSOLE_IO_SUPPORTED -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# endif -#endif - -# ifdef PNG_NO_STDIO -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# ifdef PNG_DEBUG -# if (PNG_DEBUG > 0) -# include -# endif -# endif -# else -# if !defined(_WIN32_WCE) -/* "stdio.h" functions are not supported on WindowsCE */ -# include -# endif -# endif - -/* This macro protects us against machines that don't have function - * prototypes (ie K&R style headers). If your compiler does not handle - * function prototypes, define this macro and use the included ansi2knr. - * I've always been able to use _NO_PROTO as the indicator, but you may - * need to drag the empty declaration out in front of here, or change the - * ifdef to suit your own needs. - */ -#ifndef PNGARG - -#ifdef OF /* zlib prototype munger */ -# define PNGARG(arglist) OF(arglist) -#else - -#ifdef _NO_PROTO -# define PNGARG(arglist) () -#else -# define PNGARG(arglist) arglist -#endif /* _NO_PROTO */ - -#endif /* OF */ - -#endif /* PNGARG */ - -/* Try to determine if we are compiling on a Mac. Note that testing for - * just __MWERKS__ is not good enough, because the Codewarrior is now used - * on non-Mac platforms. - */ -#ifndef MACOS -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) -# define MACOS -# endif -#endif - -/* enough people need this for various reasons to include it here */ -#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) -# include -#endif - -#ifndef PNG_SETJMP_NOT_SUPPORTED -# define PNG_SETJMP_SUPPORTED -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This is an attempt to force a single setjmp behaviour on Linux. If - * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. - */ - -# ifdef __linux__ -# ifdef _BSD_SOURCE -# define PNG_SAVE_BSD_SOURCE -# undef _BSD_SOURCE -# endif -# ifdef _SETJMP_H - __png.h__ already includes setjmp.h; - __dont__ include it again.; -# endif -# endif /* __linux__ */ - - /* include setjmp.h for error handling */ -# include - -# ifdef __linux__ -# ifdef PNG_SAVE_BSD_SOURCE -# define _BSD_SOURCE -# undef PNG_SAVE_BSD_SOURCE -# endif -# endif /* __linux__ */ -#endif /* PNG_SETJMP_SUPPORTED */ - -#ifdef BSD -# include -#else -# include -#endif - -/* Other defines for things like memory and the like can go here. */ -#ifdef PNG_INTERNAL - -#include - -/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which - * aren't usually used outside the library (as far as I know), so it is - * debatable if they should be exported at all. In the future, when it is - * possible to have run-time registry of chunk-handling functions, some of - * these will be made available again. -#define PNG_EXTERN extern - */ -#define PNG_EXTERN - -/* Other defines specific to compilers can go here. Try to keep - * them inside an appropriate ifdef/endif pair for portability. - */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) -# if defined(MACOS) - /* We need to check that hasn't already been included earlier - * as it seems it doesn't agree with , yet we should really use - * if possible. - */ -# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) -# include -# endif -# else -# include -# endif -# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ -# include -# endif -#endif - -/* Codewarrior on NT has linking problems without this. */ -#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) -# define PNG_ALWAYS_EXTERN -#endif - -/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not - * stdlib.h like it should (I think). Or perhaps this is a C++ - * "feature"? - */ -#ifdef __TURBOC__ -# include -# include "alloc.h" -#endif - -#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ - defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) -# include -#endif - -/* This controls how fine the dithering gets. As this allocates - * a largish chunk of memory (32K), those who are not as concerned - * with dithering quality can decrease some or all of these. - */ -#ifndef PNG_DITHER_RED_BITS -# define PNG_DITHER_RED_BITS 5 -#endif -#ifndef PNG_DITHER_GREEN_BITS -# define PNG_DITHER_GREEN_BITS 5 -#endif -#ifndef PNG_DITHER_BLUE_BITS -# define PNG_DITHER_BLUE_BITS 5 -#endif - -/* This controls how fine the gamma correction becomes when you - * are only interested in 8 bits anyway. Increasing this value - * results in more memory being used, and more pow() functions - * being called to fill in the gamma tables. Don't set this value - * less then 8, and even that may not work (I haven't tested it). - */ - -#ifndef PNG_MAX_GAMMA_8 -# define PNG_MAX_GAMMA_8 11 -#endif - -/* This controls how much a difference in gamma we can tolerate before - * we actually start doing gamma conversion. - */ -#ifndef PNG_GAMMA_THRESHOLD -# define PNG_GAMMA_THRESHOLD 0.05 -#endif - -#endif /* PNG_INTERNAL */ - -/* The following uses const char * instead of char * for error - * and warning message functions, so some compilers won't complain. - * If you do not want to use const, define PNG_NO_CONST here. - */ - -#ifndef PNG_NO_CONST -# define PNG_CONST const -#else -# define PNG_CONST -#endif - -/* The following defines give you the ability to remove code from the - * library that you will not be using. I wish I could figure out how to - * automate this, but I can't do that without making it seriously hard - * on the users. So if you are not using an ability, change the #define - * to and #undef, and that part of the library will not be compiled. If - * your linker can't find a function, you may want to make sure the - * ability is defined here. Some of these depend upon some others being - * defined. I haven't figured out all the interactions here, so you may - * have to experiment awhile to get everything to compile. If you are - * creating or using a shared library, you probably shouldn't touch this, - * as it will affect the size of the structures, and this will cause bad - * things to happen if the library and/or application ever change. - */ - -/* Any features you will not be using can be undef'ed here */ - -/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user - * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS - * on the compile line, then pick and choose which ones to define without - * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED - * if you only want to have a png-compliant reader/writer but don't need - * any of the extra transformations. This saves about 80 kbytes in a - * typical installation of the library. (PNG_NO_* form added in version - * 1.0.1c, for consistency) - */ - -/* The size of the png_text structure changed in libpng-1.0.6 when - * iTXt is supported. It is turned off by default, to support old apps - * that malloc the png_text structure instead of calling png_set_text() - * and letting libpng malloc it. It will be turned on by default in - * libpng-1.3.0. - */ - -#ifndef PNG_iTXt_SUPPORTED -# ifndef PNG_READ_iTXt_SUPPORTED -# define PNG_NO_READ_iTXt -# endif -# ifndef PNG_WRITE_iTXt_SUPPORTED -# define PNG_NO_WRITE_iTXt -# endif -#endif - -/* The following support, added after version 1.0.0, can be turned off here en - * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility - * with old applications that require the length of png_struct and png_info - * to remain unchanged. - */ - -#ifdef PNG_LEGACY_SUPPORTED -# define PNG_NO_FREE_ME -# define PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_NO_READ_USER_CHUNKS -# define PNG_NO_READ_iCCP -# define PNG_NO_WRITE_iCCP -# define PNG_NO_READ_iTXt -# define PNG_NO_WRITE_iTXt -# define PNG_NO_READ_sCAL -# define PNG_NO_WRITE_sCAL -# define PNG_NO_READ_sPLT -# define PNG_NO_WRITE_sPLT -# define PNG_NO_INFO_IMAGE -# define PNG_NO_READ_RGB_TO_GRAY -# define PNG_NO_READ_USER_TRANSFORM -# define PNG_NO_WRITE_USER_TRANSFORM -# define PNG_NO_USER_MEM -# define PNG_NO_READ_EMPTY_PLTE -# define PNG_NO_MNG_FEATURES -# define PNG_NO_FIXED_POINT_SUPPORTED -#endif - -/* Ignore attempt to turn off both floating and fixed point support */ -#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ - !defined(PNG_NO_FIXED_POINT_SUPPORTED) -# define PNG_FIXED_POINT_SUPPORTED -#endif - -#ifndef PNG_NO_FREE_ME -# define PNG_FREE_ME_SUPPORTED -#endif - -#if defined(PNG_READ_SUPPORTED) - -#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_TRANSFORMS) -# define PNG_READ_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_READ_EXPAND -# define PNG_READ_EXPAND_SUPPORTED -# endif -# ifndef PNG_NO_READ_SHIFT -# define PNG_READ_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACK -# define PNG_READ_PACK_SUPPORTED -# endif -# ifndef PNG_NO_READ_BGR -# define PNG_READ_BGR_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP -# define PNG_READ_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACKSWAP -# define PNG_READ_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT -# define PNG_READ_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_READ_DITHER -# define PNG_READ_DITHER_SUPPORTED -# endif -# ifndef PNG_NO_READ_BACKGROUND -# define PNG_READ_BACKGROUND_SUPPORTED -# endif -# ifndef PNG_NO_READ_16_TO_8 -# define PNG_READ_16_TO_8_SUPPORTED -# endif -# ifndef PNG_NO_READ_FILLER -# define PNG_READ_FILLER_SUPPORTED -# endif -# ifndef PNG_NO_READ_GAMMA -# define PNG_READ_GAMMA_SUPPORTED -# endif -# ifndef PNG_NO_READ_GRAY_TO_RGB -# define PNG_READ_GRAY_TO_RGB_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP_ALPHA -# define PNG_READ_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT_ALPHA -# define PNG_READ_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_STRIP_ALPHA -# define PNG_READ_STRIP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_USER_TRANSFORM -# define PNG_READ_USER_TRANSFORM_SUPPORTED -# endif -# ifndef PNG_NO_READ_RGB_TO_GRAY -# define PNG_READ_RGB_TO_GRAY_SUPPORTED -# endif -#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_PROGRESSIVE_READ) && \ - !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ -# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ -#endif /* about interlacing capability! You'll */ - /* still have interlacing unless you change the following line: */ - -#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ - -#ifndef PNG_NO_READ_COMPOSITE_NODIV -# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ -# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ -# endif -#endif - -/* Deprecated, will be removed from version 2.0.0. - Use PNG_MNG_FEATURES_SUPPORTED instead. */ -#ifndef PNG_NO_READ_EMPTY_PLTE -# define PNG_READ_EMPTY_PLTE_SUPPORTED -#endif - -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_WRITE_SUPPORTED) - -# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_TRANSFORMS) -# define PNG_WRITE_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_WRITE_SHIFT -# define PNG_WRITE_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACK -# define PNG_WRITE_PACK_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_BGR -# define PNG_WRITE_BGR_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_SWAP -# define PNG_WRITE_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACKSWAP -# define PNG_WRITE_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT -# define PNG_WRITE_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_FILLER -# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ -# endif -# ifndef PNG_NO_WRITE_SWAP_ALPHA -# define PNG_WRITE_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT_ALPHA -# define PNG_WRITE_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_USER_TRANSFORM -# define PNG_WRITE_USER_TRANSFORM_SUPPORTED -# endif -#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -# ifndef PNG_NO_USER_TRANSFORM_PTR -# define PNG_USER_TRANSFORM_PTR_SUPPORTED -# endif -#endif - -#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant - encoders, but can cause trouble - if left undefined */ - -#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#endif - -/* Will be enabled in libpng-1.2.0 */ -/* -#ifndef PNG_NO_ERROR_NUMBERS -#define PNG_ERROR_NUMBERS_SUPPORTED -#endif -*/ - -#ifndef PNG_NO_WRITE_FLUSH -# define PNG_WRITE_FLUSH_SUPPORTED -#endif - -/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ -#ifndef PNG_NO_WRITE_EMPTY_PLTE -# define PNG_WRITE_EMPTY_PLTE_SUPPORTED -#endif - -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef PNG_NO_STDIO -# define PNG_TIME_RFC1123_SUPPORTED -#endif - -/* This adds extra functions in pngget.c for accessing data from the - * info pointer (added in version 0.99) - * png_get_image_width() - * png_get_image_height() - * png_get_bit_depth() - * png_get_color_type() - * png_get_compression_type() - * png_get_filter_type() - * png_get_interlace_type() - * png_get_pixel_aspect_ratio() - * png_get_pixels_per_meter() - * png_get_x_offset_pixels() - * png_get_y_offset_pixels() - * png_get_x_offset_microns() - * png_get_y_offset_microns() - */ -#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) -# define PNG_EASY_ACCESS_SUPPORTED -#endif - -/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 - even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */ -/* -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) -# ifndef PNG_ASSEMBLER_CODE_SUPPORTED -# define PNG_ASSEMBLER_CODE_SUPPORTED -# endif -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_MMX_CODE_SUPPORTED -# endif -#endif -*/ -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) -# if defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD) -# ifndef PNG_ASSEMBLER_CODE_SUPPORTED -# define PNG_ASSEMBLER_CODE_SUPPORTED -# endif -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_MMX_CODE_SUPPORTED -# endif -# endif -#endif - -/* This will be enabled by default in libpng-1.2.0 */ -/* -#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) -# define PNG_USER_MEM_SUPPORTED -#endif -*/ - -/* These are currently experimental features, define them if you want */ - -/* very little testing */ -/* -#ifdef PNG_READ_SUPPORTED -# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# endif -#endif -*/ - -/* This is only for PowerPC big-endian and 680x0 systems */ -/* some testing */ -/* -#ifdef PNG_READ_SUPPORTED -# ifndef PNG_PNG_READ_BIG_ENDIAN_SUPPORTED -# define PNG_READ_BIG_ENDIAN_SUPPORTED -# endif -#endif -*/ - -/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ -/* -#define PNG_NO_POINTER_INDEXING -*/ - -/* These functions are turned off by default, as they will be phased out. */ -/* -#define PNG_USELESS_TESTS_SUPPORTED -#define PNG_CORRECT_PALETTE_SUPPORTED -*/ - -/* Any chunks you are not interested in, you can undef here. The - * ones that allocate memory may be expecially important (hIST, - * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info - * a bit smaller. - */ - -#if defined(PNG_READ_SUPPORTED) && \ - !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_ANCILLARY_CHUNKS) -# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#if defined(PNG_WRITE_SUPPORTED) && \ - !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) -# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_READ_TEXT -# define PNG_NO_READ_iTXt -# define PNG_NO_READ_tEXt -# define PNG_NO_READ_zTXt -#endif -#ifndef PNG_NO_READ_bKGD -# define PNG_READ_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -#endif -#ifndef PNG_NO_READ_cHRM -# define PNG_READ_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -#endif -#ifndef PNG_NO_READ_gAMA -# define PNG_READ_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -#endif -#ifndef PNG_NO_READ_hIST -# define PNG_READ_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -#endif -#ifndef PNG_NO_READ_iCCP -# define PNG_READ_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -#endif -#ifndef PNG_NO_READ_iTXt -# define PNG_READ_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_oFFs -# define PNG_READ_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -#endif -#ifndef PNG_NO_READ_pCAL -# define PNG_READ_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_sCAL -# define PNG_READ_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_pHYs -# define PNG_READ_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -#endif -#ifndef PNG_NO_READ_sBIT -# define PNG_READ_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sPLT -# define PNG_READ_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sRGB -# define PNG_READ_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -#endif -#ifndef PNG_NO_READ_tEXt -# define PNG_READ_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_tIME -# define PNG_READ_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -#endif -#ifndef PNG_NO_READ_tRNS -# define PNG_READ_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -#endif -#ifndef PNG_NO_READ_zTXt -# define PNG_READ_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -#endif -#if !defined(PNG_NO_READ_USER_CHUNKS) && \ - defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) -# define PNG_READ_USER_CHUNKS_SUPPORTED -# define PNG_USER_CHUNKS_SUPPORTED -# ifdef PNG_NO_READ_UNKNOWN_CHUNKS -# undef PNG_NO_READ_UNKNOWN_CHUNKS -# endif -# ifdef PNG_NO_HANDLE_AS_UNKNOWN -# undef PNG_NO_HANDLE_AS_UNKNOWN -# endif -#endif -#ifndef PNG_NO_READ_OPT_PLTE -# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ -#endif /* optional PLTE chunk in RGB and RGBA images */ -#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ - defined(PNG_READ_zTXt_SUPPORTED) -# define PNG_READ_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -#endif - -#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ - -#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_WRITE_TEXT -# define PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_tEXt -# define PNG_NO_WRITE_zTXt -#endif -#ifndef PNG_NO_WRITE_bKGD -# define PNG_WRITE_bKGD_SUPPORTED -# ifndef PNG_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_cHRM -# define PNG_WRITE_cHRM_SUPPORTED -# ifndef PNG_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_gAMA -# define PNG_WRITE_gAMA_SUPPORTED -# ifndef PNG_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_hIST -# define PNG_WRITE_hIST_SUPPORTED -# ifndef PNG_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iCCP -# define PNG_WRITE_iCCP_SUPPORTED -# ifndef PNG_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iTXt -# define PNG_WRITE_iTXt_SUPPORTED -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_oFFs -# define PNG_WRITE_oFFs_SUPPORTED -# ifndef PNG_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pCAL -# define PNG_WRITE_pCAL_SUPPORTED -# ifndef PNG_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sCAL -# define PNG_WRITE_sCAL_SUPPORTED -# ifndef PNG_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pHYs -# define PNG_WRITE_pHYs_SUPPORTED -# ifndef PNG_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sBIT -# define PNG_WRITE_sBIT_SUPPORTED -# ifndef PNG_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sPLT -# define PNG_WRITE_sPLT_SUPPORTED -# ifndef PNG_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sRGB -# define PNG_WRITE_sRGB_SUPPORTED -# ifndef PNG_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tEXt -# define PNG_WRITE_tEXt_SUPPORTED -# ifndef PNG_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tIME -# define PNG_WRITE_tIME_SUPPORTED -# ifndef PNG_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tRNS -# define PNG_WRITE_tRNS_SUPPORTED -# ifndef PNG_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_zTXt -# define PNG_WRITE_zTXt_SUPPORTED -# ifndef PNG_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -# endif -#endif -#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ - defined(PNG_WRITE_zTXt_SUPPORTED) -# define PNG_WRITE_TEXT_SUPPORTED -# ifndef PNG_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -# endif -#endif - -#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ - -/* Turn this off to disable png_read_png() and - * png_write_png() and leave the row_pointers member - * out of the info structure. - */ -#ifndef PNG_NO_INFO_IMAGE -# define PNG_INFO_IMAGE_SUPPORTED -#endif - -/* need the time information for reading tIME chunks */ -#if defined(PNG_tIME_SUPPORTED) -# if !defined(_WIN32_WCE) - /* "time.h" functions are not supported on WindowsCE */ -# include -# endif -#endif - -/* Some typedefs to get us started. These should be safe on most of the - * common platforms. The typedefs should be at least as large as the - * numbers suggest (a png_uint_32 must be at least 32 bits long), but they - * don't have to be exactly that size. Some compilers dislike passing - * unsigned shorts as function parameters, so you may be better off using - * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may - * want to have unsigned int for png_uint_32 instead of unsigned long. - */ - -typedef unsigned long png_uint_32; -typedef long png_int_32; -typedef unsigned short png_uint_16; -typedef short png_int_16; -typedef unsigned char png_byte; - -/* This is usually size_t. It is typedef'ed just in case you need it to - change (I'm not sure if you will or not, so I thought I'd be safe) */ -typedef size_t png_size_t; - -/* The following is needed for medium model support. It cannot be in the - * PNG_INTERNAL section. Needs modification for other compilers besides - * MSC. Model independent support declares all arrays and pointers to be - * large using the far keyword. The zlib version used must also support - * model independent data. As of version zlib 1.0.4, the necessary changes - * have been made in zlib. The USE_FAR_KEYWORD define triggers other - * changes that are needed. (Tim Wegner) - */ - -/* Separate compiler dependencies (problem here is that zlib.h always - defines FAR. (SJT) */ -#ifdef __BORLANDC__ -# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) -# define LDATA 1 -# else -# define LDATA 0 -# endif - /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ -# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) -# define PNG_MAX_MALLOC_64K -# if (LDATA != 1) -# ifndef FAR -# define FAR __far -# endif -# define USE_FAR_KEYWORD -# endif /* LDATA != 1 */ - /* Possibly useful for moving data out of default segment. - * Uncomment it if you want. Could also define FARDATA as - * const if your compiler supports it. (SJT) -# define FARDATA FAR - */ -# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ -#endif /* __BORLANDC__ */ - - -/* Suggest testing for specific compiler first before testing for - * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, - * making reliance oncertain keywords suspect. (SJT) - */ - -/* MSC Medium model */ -#if defined(FAR) -# if defined(M_I86MM) -# define USE_FAR_KEYWORD -# define FARDATA FAR -# include -# endif -#endif - -/* SJT: default case */ -#ifndef FAR -# define FAR -#endif - -/* At this point FAR is always defined */ -#ifndef FARDATA -# define FARDATA -#endif - -/* Typedef for floating-point numbers that are converted - to fixed-point with a multiple of 100,000, e.g., int_gamma */ -typedef png_int_32 png_fixed_point; - -/* Add typedefs for pointers */ -typedef void FAR * png_voidp; -typedef png_byte FAR * png_bytep; -typedef png_uint_32 FAR * png_uint_32p; -typedef png_int_32 FAR * png_int_32p; -typedef png_uint_16 FAR * png_uint_16p; -typedef png_int_16 FAR * png_int_16p; -typedef PNG_CONST char FAR * png_const_charp; -typedef char FAR * png_charp; -typedef png_fixed_point FAR * png_fixed_point_p; - -#ifndef PNG_NO_STDIO -#if defined(_WIN32_WCE) -typedef HANDLE png_FILE_p; -#else -typedef FILE * png_FILE_p; -#endif -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * png_doublep; -#endif - -/* Pointers to pointers; i.e. arrays */ -typedef png_byte FAR * FAR * png_bytepp; -typedef png_uint_32 FAR * FAR * png_uint_32pp; -typedef png_int_32 FAR * FAR * png_int_32pp; -typedef png_uint_16 FAR * FAR * png_uint_16pp; -typedef png_int_16 FAR * FAR * png_int_16pp; -typedef PNG_CONST char FAR * FAR * png_const_charpp; -typedef char FAR * FAR * png_charpp; -typedef png_fixed_point FAR * FAR * png_fixed_point_pp; -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * FAR * png_doublepp; -#endif - -/* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char FAR * FAR * FAR * png_charppp; - -/* libpng typedefs for types in zlib. If zlib changes - * or another compression library is used, then change these. - * Eliminates need to change all the source files. - */ -typedef charf * png_zcharp; -typedef charf * FAR * png_zcharpp; -typedef z_stream FAR * png_zstreamp; - -/* - * Define PNG_BUILD_DLL if the module being built is a Windows - * LIBPNG DLL. - * - * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. - * It is equivalent to Microsoft predefined macro _DLL that is - * automatically defined when you compile using the share - * version of the CRT (C Run-Time library) - * - * The cygwin mods make this behavior a little different: - * Define PNG_BUILD_DLL if you are building a dll for use with cygwin - * Define PNG_STATIC if you are building a static library for use with cygwin, - * -or- if you are building an application that you want to link to the - * static library. - * PNG_USE_DLL is defined by default (no user action needed) unless one of - * the other flags is defined. - */ - -#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) -# define PNG_DLL -#endif -/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. - * When building a static lib, default to no GLOBAL ARRAYS, but allow - * command-line override - */ -#if defined(__CYGWIN__) -# if !defined(PNG_STATIC) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -# else -# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# endif -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -#endif - -/* Do not use global arrays (helps with building DLL's) - * They are no longer used in libpng itself, since version 1.0.5c, - * but might be required for some pre-1.0.5c applications. - */ -#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) -# define PNG_USE_LOCAL_ARRAYS -# else -# define PNG_USE_GLOBAL_ARRAYS -# endif -#endif - - -#ifndef PNGAPI - -#if defined(__MINGW32__) || defined(__CYGWIN__) && !defined(PNG_MODULEDEF) -# ifndef PNG_NO_MODULEDEF -# define PNG_NO_MODULEDEF -# endif -#endif - -#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) -# define PNG_IMPEXP -#endif - -#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ - (( defined(_Windows) || defined(_WINDOWS) || \ - defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \ - ) && !defined(__CYGWIN__)) - -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) -# define PNGAPI __cdecl -# else -# define PNGAPI _cdecl -# endif - -# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ - 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) -# define PNG_IMPEXP -# endif - -# if !defined(PNG_IMPEXP) - -# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol -# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol - - /* Borland/Microsoft */ -# if defined(_MSC_VER) || defined(__BORLANDC__) -# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) -# define PNG_EXPORT PNG_EXPORT_TYPE1 -# else -# define PNG_EXPORT PNG_EXPORT_TYPE2 -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __export -# else -# define PNG_IMPEXP /*__import*/ /* doesn't exist AFAIK in - VC++*/ -# endif /* Exists in Borland C++ for - C++ classes (== huge) */ -# endif -# endif - -# if !defined(PNG_IMPEXP) -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __declspec(dllexport) -# else -# define PNG_IMPEXP __declspec(dllimport) -# endif -# endif -# endif /* PNG_IMPEXP */ -#else /* !(DLL || non-cygwin WINDOWS) */ -# if defined(__CYGWIN__) && !defined(PNG_DLL) -# if !defined(PNG_IMPEXP) -# define PNG_IMPEXP -# endif -# define PNGAPI __cdecl -# else -# if (defined(__IBMC__) || defined(IBMCPP__)) && defined(__OS2__) -# define PNGAPI _System -# define PNG_IMPEXP -# else -# if 0 /* ... other platforms, with other meanings */ -# else -# define PNGAPI -# define PNG_IMPEXP -# endif -# endif -# endif -#endif -#endif - -#ifndef PNGAPI -# define PNGAPI -#endif -#ifndef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -#ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type -# endif -#endif - -/* User may want to use these so they are not in PNG_INTERNAL. Any library - * functions that are passed far data must be model independent. - */ - -#ifndef PNG_ABORT -# define PNG_ABORT() abort() -#endif - -#ifdef PNG_SETJMP_SUPPORTED -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) -#endif - -#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ -/* use this to make far-to-near assignments */ -# define CHECK 1 -# define NOCHECK 0 -# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) -# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) -# define png_strcpy _fstrcpy -# define png_strlen _fstrlen -# define png_memcmp _fmemcmp /* SJT: added */ -# define png_memcpy _fmemcpy -# define png_memset _fmemset -#else /* use the usual functions */ -# define CVT_PTR(ptr) (ptr) -# define CVT_PTR_NOCHECK(ptr) (ptr) -# define png_strcpy strcpy -# define png_strlen strlen -# define png_memcmp memcmp /* SJT: added */ -# define png_memcpy memcpy -# define png_memset memset -#endif -/* End of memory model independent support */ - -/* Just a little check that someone hasn't tried to define something - * contradictory. - */ -#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K) -# undef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 65536 -#endif - -#ifdef PNG_READ_SUPPORTED -/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ -#if defined(PNG_INTERNAL) - -/* These are the default thresholds before the MMX code kicks in; if either - * rowbytes or bitdepth is below the threshold, plain C code is used. These - * can be overridden at runtime via the png_set_mmx_thresholds() call in - * libpng 1.2.0 and later. The values below were chosen by Intel. - */ - -#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT -# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */ -#endif -#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT -# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */ -#endif - -/* Set this in the makefile for VC++ on Pentium, not here. */ -/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c . - * MMX will be detected at run time and used if present. - */ -#ifdef PNG_USE_PNGVCRD -# define PNG_HAVE_ASSEMBLER_COMBINE_ROW -# define PNG_HAVE_ASSEMBLER_READ_INTERLACE -# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW -#endif - -/* Set this in the makefile for gcc/as on Pentium, not here. */ -/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c . - * MMX will be detected at run time and used if present. - */ -#ifdef PNG_USE_PNGGCCRD -# define PNG_HAVE_ASSEMBLER_COMBINE_ROW -# define PNG_HAVE_ASSEMBLER_READ_INTERLACE -# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW -#endif -/* - see pnggccrd.c for info about what is currently enabled */ - -#endif /* PNG_INTERNAL */ -#endif /* PNG_READ_SUPPORTED */ - -#endif /* PNGCONF_H */ - diff --git a/freeimage241/Source/LibPNG/pngerror.c b/freeimage241/Source/LibPNG/pngerror.c deleted file mode 100644 index c2285ff..0000000 --- a/freeimage241/Source/LibPNG/pngerror.c +++ /dev/null @@ -1,290 +0,0 @@ - -/* pngerror.c - stub functions for i/o and memory allocation - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all error handling. Users who - * need special error handling are expected to write replacement functions - * and use png_set_error_fn() to use those functions. See the instructions - * at each function. - */ - -#define PNG_INTERNAL -#include "png.h" - -static void /* PRIVATE */ -png_default_error PNGARG((png_structp png_ptr, - png_const_charp message)); -static void /* PRIVATE */ -png_default_warning PNGARG((png_structp png_ptr, - png_const_charp message)); - -/* This function is called whenever there is a fatal error. This function - * should not be changed. If there is a need to handle errors differently, - * you should supply a replacement error function and use png_set_error_fn() - * to replace the error function at run-time. - */ -void PNGAPI -png_error(png_structp png_ptr, png_const_charp message) -{ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - char msg[16]; - if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) - { - int offset = 0; - if (*message == '#') - { - for (offset=1; offset<15; offset++) - if (*(message+offset) == ' ') - break; - if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) - { - int i; - for (i=0; iflags&PNG_FLAG_STRIP_ERROR_TEXT) - { - msg[0]='0'; - msg[1]='\0'; - message=msg; - } - } - } -#endif - if (png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_ptr, message); - - /* if the following returns or doesn't exist, use the default function, - which will not return */ - png_default_error(png_ptr, message); -} - -/* This function is called whenever there is a non-fatal error. This function - * should not be changed. If there is a need to handle warnings differently, - * you should supply a replacement warning function and use - * png_set_error_fn() to replace the warning function at run-time. - */ -void PNGAPI -png_warning(png_structp png_ptr, png_const_charp message) -{ - int offset = 0; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) -#endif - { - if (*message == '#') - { - for (offset=1; offset<15; offset++) - if (*(message+offset) == ' ') - break; - } - } - if (png_ptr->warning_fn != NULL) - (*(png_ptr->warning_fn))(png_ptr, (png_const_charp)(message+offset)); - else - png_default_warning(png_ptr, (png_const_charp)(message+offset)); -} - -/* These utilities are used internally to build an error message that relates - * to the current chunk. The chunk name comes from png_ptr->chunk_name, - * this is used to prefix the message. The message is limited in length - * to 63 bytes, the name characters are output as hex digits wrapped in [] - * if the character is invalid. - */ -#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97)) -static PNG_CONST char png_digit[16] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', - 'F' }; - -static void /* PRIVATE */ -png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp - message) -{ - int iout = 0, iin = 0; - - while (iin < 4) - { - int c = png_ptr->chunk_name[iin++]; - if (isnonalpha(c)) - { - buffer[iout++] = '['; - buffer[iout++] = png_digit[(c & 0xf0) >> 4]; - buffer[iout++] = png_digit[c & 0x0f]; - buffer[iout++] = ']'; - } - else - { - buffer[iout++] = (png_byte)c; - } - } - - if (message == NULL) - buffer[iout] = 0; - else - { - buffer[iout++] = ':'; - buffer[iout++] = ' '; - png_memcpy(buffer+iout, message, 64); - buffer[iout+63] = 0; - } -} - -void PNGAPI -png_chunk_error(png_structp png_ptr, png_const_charp message) -{ - char msg[18+64]; - png_format_buffer(png_ptr, msg, message); - png_error(png_ptr, msg); -} - -void PNGAPI -png_chunk_warning(png_structp png_ptr, png_const_charp message) -{ - char msg[18+64]; - png_format_buffer(png_ptr, msg, message); - png_warning(png_ptr, msg); -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void /* PRIVATE */ -png_default_error(png_structp png_ptr, png_const_charp message) -{ -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*message == '#') - { - int offset; - char error_number[16]; - for (offset=0; offset<15; offset++) - { - error_number[offset] = *(message+offset+1); - if (*(message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - error_number[offset-1]='\0'; - fprintf(stderr, "libpng error no. %s: %s\n", error_number, message+offset); - } - else - fprintf(stderr, "libpng error: %s, offset=%d\n", message,offset); - } - else -#endif - fprintf(stderr, "libpng error: %s\n", message); -#else - if (message) - /* make compiler happy */ ; -#endif - -#ifdef PNG_SETJMP_SUPPORTED -# ifdef USE_FAR_KEYWORD - { - jmp_buf jmpbuf; - png_memcpy(jmpbuf,png_ptr->jmpbuf,sizeof(jmp_buf)); - longjmp(jmpbuf, 1); - } -# else - longjmp(png_ptr->jmpbuf, 1); -# endif -#else - if (png_ptr) - /* make compiler happy */ ; - PNG_ABORT(); -#endif -} - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want them to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void /* PRIVATE */ -png_default_warning(png_structp png_ptr, png_const_charp message) -{ -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*message == '#') - { - int offset; - char warning_number[16]; - for (offset=0; offset<15; offset++) - { - warning_number[offset]=*(message+offset+1); - if (*(message+offset) == ' ') - break; - } - if((offset > 1) && (offset < 15)) - { - warning_number[offset-1]='\0'; - fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, - message+offset); - } - else - fprintf(stderr, "libpng warning: %s\n", message); - } - else -# endif - fprintf(stderr, "libpng warning: %s\n", message); -#else - if (message) - /* appease compiler */ ; -#endif - if (png_ptr) - return; -} - -/* This function is called when the application wants to use another method - * of handling errors and warnings. Note that the error function MUST NOT - * return to the calling routine or serious problems will occur. The return - * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) - */ -void PNGAPI -png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warning_fn) -{ - png_ptr->error_ptr = error_ptr; - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; -} - - -/* This function returns a pointer to the error_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_error_ptr(png_structp png_ptr) -{ - return ((png_voidp)png_ptr->error_ptr); -} - - -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -void -png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) -{ - if(png_ptr != NULL) - { - png_ptr->flags &= - ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); - } -} -#endif - diff --git a/freeimage241/Source/LibPNG/pnggccrd.c b/freeimage241/Source/LibPNG/pnggccrd.c deleted file mode 100644 index 62ea690..0000000 --- a/freeimage241/Source/LibPNG/pnggccrd.c +++ /dev/null @@ -1,5208 +0,0 @@ -/* pnggccrd.c - mixed C/assembler version of utilities to read a PNG file - * - * For Intel x86 CPU (Pentium-MMX or later) and GNU C compiler. - * - * See http://www.intel.com/drg/pentiumII/appnotes/916/916.htm - * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm - * for Intel's performance analysis of the MMX vs. non-MMX code. - * - * libpng version 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * Copyright (c) 1998, Intel Corporation - * - * Based on MSVC code contributed by Nirav Chhatrapati, Intel Corp., 1998. - * Interface to libpng contributed by Gilles Vollant, 1999. - * GNU C port by Greg Roelofs, 1999-2001. - * - * Lines 2350-4300 converted in place with intel2gas 1.3.1: - * - * intel2gas -mdI pnggccrd.c.partially-msvc -o pnggccrd.c - * - * and then cleaned up by hand. See http://hermes.terminal.at/intel2gas/ . - * - * NOTE: A sufficiently recent version of GNU as (or as.exe under DOS/Windows) - * is required to assemble the newer MMX instructions such as movq. - * For djgpp, see - * - * ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu281b.zip - * - * (or a later version in the same directory). For Linux, check your - * distribution's web site(s) or try these links: - * - * http://rufus.w3.org/linux/RPM/binutils.html - * http://www.debian.org/Packages/stable/devel/binutils.html - * ftp://ftp.slackware.com/pub/linux/slackware/slackware/slakware/d1/ - * binutils.tgz - * - * For other platforms, see the main GNU site: - * - * ftp://ftp.gnu.org/pub/gnu/binutils/ - * - * Version 2.5.2l.15 is definitely too old... - */ - -/* - * TEMPORARY PORTING NOTES AND CHANGELOG (mostly by Greg Roelofs) - * ===================================== - * - * 19991006: - * - fixed sign error in post-MMX cleanup code (16- & 32-bit cases) - * - * 19991007: - * - additional optimizations (possible or definite): - * x [DONE] write MMX code for 64-bit case (pixel_bytes == 8) [not tested] - * - write MMX code for 48-bit case (pixel_bytes == 6) - * - figure out what's up with 24-bit case (pixel_bytes == 3): - * why subtract 8 from width_mmx in the pass 4/5 case? - * (only width_mmx case) (near line 1606) - * x [DONE] replace pixel_bytes within each block with the true - * constant value (or are compilers smart enough to do that?) - * - rewrite all MMX interlacing code so it's aligned with - * the *beginning* of the row buffer, not the end. This - * would not only allow one to eliminate half of the memory - * writes for odd passes (that is, pass == odd), it may also - * eliminate some unaligned-data-access exceptions (assuming - * there's a penalty for not aligning 64-bit accesses on - * 64-bit boundaries). The only catch is that the "leftover" - * pixel(s) at the end of the row would have to be saved, - * but there are enough unused MMX registers in every case, - * so this is not a problem. A further benefit is that the - * post-MMX cleanup code (C code) in at least some of the - * cases could be done within the assembler block. - * x [DONE] the "v3 v2 v1 v0 v7 v6 v5 v4" comments are confusing, - * inconsistent, and don't match the MMX Programmer's Reference - * Manual conventions anyway. They should be changed to - * "b7 b6 b5 b4 b3 b2 b1 b0," where b0 indicates the byte that - * was lowest in memory (e.g., corresponding to a left pixel) - * and b7 is the byte that was highest (e.g., a right pixel). - * - * 19991016: - * - Brennan's Guide notwithstanding, gcc under Linux does *not* - * want globals prefixed by underscores when referencing them-- - * i.e., if the variable is const4, then refer to it as const4, - * not _const4. This seems to be a djgpp-specific requirement. - * Also, such variables apparently *must* be declared outside - * of functions; neither static nor automatic variables work if - * defined within the scope of a single function, but both - * static and truly global (multi-module) variables work fine. - * - * 19991023: - * - fixed png_combine_row() non-MMX replication bug (odd passes only?) - * - switched from string-concatenation-with-macros to cleaner method of - * renaming global variables for djgpp--i.e., always use prefixes in - * inlined assembler code (== strings) and conditionally rename the - * variables, not the other way around. Hence _const4, _mask8_0, etc. - * - * 19991024: - * - fixed mmxsupport()/png_do_read_interlace() first-row bug - * This one was severely weird: even though mmxsupport() doesn't touch - * ebx (where "row" pointer was stored), it nevertheless managed to zero - * the register (even in static/non-fPIC code--see below), which in turn - * caused png_do_read_interlace() to return prematurely on the first row of - * interlaced images (i.e., without expanding the interlaced pixels). - * Inspection of the generated assembly code didn't turn up any clues, - * although it did point at a minor optimization (i.e., get rid of - * mmx_supported_local variable and just use eax). Possibly the CPUID - * instruction is more destructive than it looks? (Not yet checked.) - * - "info gcc" was next to useless, so compared fPIC and non-fPIC assembly - * listings... Apparently register spillage has to do with ebx, since - * it's used to index the global offset table. Commenting it out of the - * input-reg lists in png_combine_row() eliminated compiler barfage, so - * ifdef'd with __PIC__ macro: if defined, use a global for unmask - * - * 19991107: - * - verified CPUID clobberage: 12-char string constant ("GenuineIntel", - * "AuthenticAMD", etc.) placed in ebx:ecx:edx. Still need to polish. - * - * 19991120: - * - made "diff" variable (now "_dif") global to simplify conversion of - * filtering routines (running out of regs, sigh). "diff" is still used - * in interlacing routines, however. - * - fixed up both versions of mmxsupport() (ORIG_THAT_USED_TO_CLOBBER_EBX - * macro determines which is used); original not yet tested. - * - * 20000213: - * - when compiling with gcc, be sure to use -fomit-frame-pointer - * - * 20000319: - * - fixed a register-name typo in png_do_read_interlace(), default (MMX) case, - * pass == 4 or 5, that caused visible corruption of interlaced images - * - * 20000623: - * - Various problems were reported with gcc 2.95.2 in the Cygwin environment, - * many of the form "forbidden register 0 (ax) was spilled for class AREG." - * This is explained at http://gcc.gnu.org/fom_serv/cache/23.html, and - * Chuck Wilson supplied a patch involving dummy output registers. See - * http://sourceforge.net/bugs/?func=detailbug&bug_id=108741&group_id=5624 - * for the original (anonymous) SourceForge bug report. - * - * 20000706: - * - Chuck Wilson passed along these remaining gcc 2.95.2 errors: - * pnggccrd.c: In function `png_combine_row': - * pnggccrd.c:525: more than 10 operands in `asm' - * pnggccrd.c:669: more than 10 operands in `asm' - * pnggccrd.c:828: more than 10 operands in `asm' - * pnggccrd.c:994: more than 10 operands in `asm' - * pnggccrd.c:1177: more than 10 operands in `asm' - * They are all the same problem and can be worked around by using the - * global _unmask variable unconditionally, not just in the -fPIC case. - * Reportedly earlier versions of gcc also have the problem with more than - * 10 operands; they just don't report it. Much strangeness ensues, etc. - * - * 20000729: - * - enabled png_read_filter_row_mmx_up() (shortest remaining unconverted - * MMX routine); began converting png_read_filter_row_mmx_sub() - * - to finish remaining sections: - * - clean up indentation and comments - * - preload local variables - * - add output and input regs (order of former determines numerical - * mapping of latter) - * - avoid all usage of ebx (including bx, bh, bl) register [20000823] - * - remove "$" from addressing of Shift and Mask variables [20000823] - * - * 20000731: - * - global union vars causing segfaults in png_read_filter_row_mmx_sub()? - * - * 20000822: - * - ARGH, stupid png_read_filter_row_mmx_sub() segfault only happens with - * shared-library (-fPIC) version! Code works just fine as part of static - * library. Damn damn damn damn damn, should have tested that sooner. - * ebx is getting clobbered again (explicitly this time); need to save it - * on stack or rewrite asm code to avoid using it altogether. Blargh! - * - * 20000823: - * - first section was trickiest; all remaining sections have ebx -> edx now. - * (-fPIC works again.) Also added missing underscores to various Shift* - * and *Mask* globals and got rid of leading "$" signs. - * - * 20000826: - * - added visual separators to help navigate microscopic printed copies - * (http://pobox.com/~newt/code/gpr-latest.zip, mode 10); started working - * on png_read_filter_row_mmx_avg() - * - * 20000828: - * - finished png_read_filter_row_mmx_avg(): only Paeth left! (930 lines...) - * What the hell, did png_read_filter_row_mmx_paeth(), too. Comments not - * cleaned up/shortened in either routine, but functionality is complete - * and seems to be working fine. - * - * 20000829: - * - ahhh, figured out last(?) bit of gcc/gas asm-fu: if register is listed - * as an input reg (with dummy output variables, etc.), then it *cannot* - * also appear in the clobber list or gcc 2.95.2 will barf. The solution - * is simple enough... - * - * 20000914: - * - bug in png_read_filter_row_mmx_avg(): 16-bit grayscale not handled - * correctly (but 48-bit RGB just fine) - * - * 20000916: - * - fixed bug in png_read_filter_row_mmx_avg(), bpp == 2 case; three errors: - * - "_ShiftBpp.use = 24;" should have been "_ShiftBpp.use = 16;" - * - "_ShiftRem.use = 40;" should have been "_ShiftRem.use = 48;" - * - "psllq _ShiftRem, %%mm2" should have been "psrlq _ShiftRem, %%mm2" - * - * 20010103: - * - renamed mmxsupport() to png_mmx_support(), with auto-set of mmx_supported, - * and made it public - * - * 20010104: - * - removed dependency on png_read_filter_row_c() (C code already duplicated - * within MMX version of png_read_filter_row()) so no longer necessary to - * compile it into pngrutil.o - * - * 20010310: - * - fixed buffer-overrun bug in png_combine_row() C code (non-MMX) - * - * STILL TO DO: - * - test png_do_read_interlace() 64-bit case (pixel_bytes == 8) - * - write MMX code for 48-bit case (pixel_bytes == 6) - * - figure out what's up with 24-bit case (pixel_bytes == 3): - * why subtract 8 from width_mmx in the pass 4/5 case? - * (only width_mmx case) (near line 1606) - * - rewrite all MMX interlacing code so it's aligned with beginning - * of the row buffer, not the end (see 19991007 for details) - * x pick one version of mmxsupport() and get rid of the other - * - add error messages to any remaining bogus default cases - * - enable pixel_depth == 8 cases in png_read_filter_row()? (test speed) - * - add support for runtime enable/disable/query of various MMX routines - */ - -/* -#ifndef PNG_DEBUG -# define PNG_DEBUG 0 -#endif -*/ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_USE_PNGGCCRD) - -int PNGAPI png_mmx_support(void); - -#ifdef PNG_USE_LOCAL_ARRAYS -static const int FARDATA png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; -static const int FARDATA png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -static const int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1}; -#endif - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -/* djgpp, Win32, and Cygwin add their own underscores to global variables, - * so define them without: */ -#if defined(__DJGPP__) || defined(WIN32) || defined(__CYGWIN__) -# define _mmx_supported mmx_supported -# define _unmask unmask -# define _const4 const4 -# define _const6 const6 -# define _mask8_0 mask8_0 -# define _mask16_1 mask16_1 -# define _mask16_0 mask16_0 -# define _mask24_2 mask24_2 -# define _mask24_1 mask24_1 -# define _mask24_0 mask24_0 -# define _mask32_3 mask32_3 -# define _mask32_2 mask32_2 -# define _mask32_1 mask32_1 -# define _mask32_0 mask32_0 -# define _mask48_5 mask48_5 -# define _mask48_4 mask48_4 -# define _mask48_3 mask48_3 -# define _mask48_2 mask48_2 -# define _mask48_1 mask48_1 -# define _mask48_0 mask48_0 -# define _FullLength FullLength -# define _MMXLength MMXLength -# define _dif dif -# define _LBCarryMask LBCarryMask -# define _HBClearMask HBClearMask -# define _ActiveMask ActiveMask -# define _ActiveMask2 ActiveMask2 -# define _ActiveMaskEnd ActiveMaskEnd -# define _ShiftBpp ShiftBpp -# define _ShiftRem ShiftRem -# define _patemp patemp -# define _pbtemp pbtemp -# define _pctemp pctemp -#endif - - -/* These constants are used in the inlined MMX assembly code. - Ignore gcc's "At top level: defined but not used" warnings. */ - -/* GRR 20000706: originally _unmask was needed only when compiling with -fPIC, - * since that case uses the %ebx register for indexing the Global Offset Table - * and there were no other registers available. But gcc 2.95 and later emit - * "more than 10 operands in `asm'" errors when %ebx is used to preload unmask - * in the non-PIC case, so we'll just use the global unconditionally now. - */ -static int _unmask; - -static unsigned long long _mask8_0 = 0x0102040810204080LL; - -static unsigned long long _mask16_1 = 0x0101020204040808LL; -static unsigned long long _mask16_0 = 0x1010202040408080LL; - -static unsigned long long _mask24_2 = 0x0101010202020404LL; -static unsigned long long _mask24_1 = 0x0408080810101020LL; -static unsigned long long _mask24_0 = 0x2020404040808080LL; - -static unsigned long long _mask32_3 = 0x0101010102020202LL; -static unsigned long long _mask32_2 = 0x0404040408080808LL; -static unsigned long long _mask32_1 = 0x1010101020202020LL; -static unsigned long long _mask32_0 = 0x4040404080808080LL; - -static unsigned long long _mask48_5 = 0x0101010101010202LL; -static unsigned long long _mask48_4 = 0x0202020204040404LL; -static unsigned long long _mask48_3 = 0x0404080808080808LL; -static unsigned long long _mask48_2 = 0x1010101010102020LL; -static unsigned long long _mask48_1 = 0x2020202040404040LL; -static unsigned long long _mask48_0 = 0x4040808080808080LL; - -static unsigned long long _const4 = 0x0000000000FFFFFFLL; -//static unsigned long long _const5 = 0x000000FFFFFF0000LL; // NOT USED -static unsigned long long _const6 = 0x00000000000000FFLL; - -// These are used in the row-filter routines and should/would be local -// variables if not for gcc addressing limitations. - -static png_uint_32 _FullLength; -static png_uint_32 _MMXLength; -static int _dif; -static int _patemp; // temp variables for Paeth routine -static int _pbtemp; -static int _pctemp; - -static void /* PRIVATE */ -png_squelch_warnings(void) -{ - _dif = _dif; - _patemp = _patemp; - _pbtemp = _pbtemp; - _pctemp = _pctemp; - _const4 = _const4; - _const6 = _const6; - _MMXLength = _MMXLength; - _mask8_0 = _mask8_0; - _mask16_1 = _mask16_1; - _mask16_0 = _mask16_0; - _mask24_2 = _mask24_2; - _mask24_1 = _mask24_1; - _mask24_0 = _mask24_0; - _mask32_3 = _mask32_3; - _mask32_2 = _mask32_2; - _mask32_1 = _mask32_1; - _mask32_0 = _mask32_0; - _mask48_5 = _mask48_5; - _mask48_4 = _mask48_4; - _mask48_3 = _mask48_3; - _mask48_2 = _mask48_2; - _mask48_1 = _mask48_1; - _mask48_0 = _mask48_0; -} -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - -static int _mmx_supported = 2; - -/*===========================================================================*/ -/* */ -/* P N G _ C O M B I N E _ R O W */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_HAVE_ASSEMBLER_COMBINE_ROW) - -#define BPP2 2 -#define BPP3 3 /* bytes per pixel (a.k.a. pixel_bytes) */ -#define BPP4 4 -#define BPP6 6 /* (defined only to help avoid cut-and-paste errors) */ -#define BPP8 8 - -/* Combines the row recently read in with the previous row. - This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined; a - zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. - If you want all pixels to be combined, pass 0xff (255) in mask. */ - -/* Use this routine for the x86 platform - it uses a faster MMX routine - if the machine supports MMX. */ - -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ - png_debug(1, "in png_combine_row (pnggccrd.c)\n"); - - if (_mmx_supported == 2) { - png_mmx_support(); - } - - if (mask == 0xff) - { - png_debug(2,"mask == 0xff: doing single png_memcpy()\n"); - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)((png_ptr->width * png_ptr->row_info.pixel_depth + 7) >> 3)); - } - else /* (png_combine_row() is never called with mask == 0) */ - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_inc, s_start, s_end; - int m; - int shift; - png_uint_32 i; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x1; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 2: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x3; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 4: /* png_ptr->row_info.pixel_depth */ - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 8: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask8_0, %%mm0 \n\t" - "pand %%mm7, %%mm0 \n\t" // nonzero if keep byte - "pcmpeqb %%mm6, %%mm0 \n\t" // zeros->1s, v versa - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" // len == 0 ? - "je mainloop8end \n\t" - - "mainloop8: \n\t" - "movq (%%esi), %%mm4 \n\t" // *srcptr - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "pandn (%%edi), %%mm6 \n\t" // *dstptr - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - "addl $8, %%esi \n\t" // inc by 8 bytes processed - "addl $8, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop8 \n\t" - - "mainloop8end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end8 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop8: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip8 \n\t" // if CF = 0 - "movb (%%esi), %%al \n\t" - "movb %%al, (%%edi) \n\t" - - "skip8: \n\t" - "incl %%esi \n\t" - "incl %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop8 \n\t" - - "end8: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm4", "%mm6", "%mm7" // clobber list -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff /* *BPP1 */ ; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - - } /* end of else (_mmx_supported) */ - - break; - } /* end 8 bpp */ - - case 16: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask16_0, %%mm0 \n\t" - "movq _mask16_1, %%mm1 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop16end \n\t" - - "mainloop16: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "addl $16, %%esi \n\t" // inc by 16 bytes processed - "addl $16, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop16 \n\t" - - "mainloop16end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end16 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop16: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip16 \n\t" // if CF = 0 - "movw (%%esi), %%ax \n\t" - "movw %%ax, (%%edi) \n\t" - - "skip16: \n\t" - "addl $2, %%esi \n\t" - "addl $2, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop16 \n\t" - - "end16: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=c" (dummy_value_c), - "=d" (dummy_value_d), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (diff), // eax // input regs -// was (unmask) " " RESERVED // ebx // Global Offset Table idx - "1" (len), // ecx - "2" (mask), // edx - "3" (srcptr), // esi - "4" (dstptr) // edi - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm4" // clobber list - , "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP2 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP2 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP2 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP2 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP2; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 16 bpp */ - - case 24: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask24_0, %%mm0 \n\t" - "movq _mask24_1, %%mm1 \n\t" - "movq _mask24_2, %%mm2 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop24end \n\t" - - "mainloop24: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm4 \n\t" - "movq 16(%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm4 \n\t" - "por %%mm4, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "addl $24, %%esi \n\t" // inc by 24 bytes processed - "addl $24, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - - "ja mainloop24 \n\t" - - "mainloop24end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end24 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop24: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip24 \n\t" // if CF = 0 - "movw (%%esi), %%ax \n\t" - "movw %%ax, (%%edi) \n\t" - "xorl %%eax, %%eax \n\t" - "movb 2(%%esi), %%al \n\t" - "movb %%al, 2(%%edi) \n\t" - - "skip24: \n\t" - "addl $3, %%esi \n\t" - "addl $3, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop24 \n\t" - - "end24: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP3 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP3 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP3 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP3 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP3; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 24 bpp */ - - case 32: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask32_0, %%mm0 \n\t" - "movq _mask32_1, %%mm1 \n\t" - "movq _mask32_2, %%mm2 \n\t" - "movq _mask32_3, %%mm3 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - "pand %%mm7, %%mm3 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - "pcmpeqb %%mm6, %%mm3 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" // lcr - "jz mainloop32end \n\t" - - "mainloop32: \n\t" - "movq (%%esi), %%mm4 \n\t" - "pand %%mm0, %%mm4 \n\t" - "movq %%mm0, %%mm6 \n\t" - "movq (%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm6 \n\t" - "por %%mm6, %%mm4 \n\t" - "movq %%mm4, (%%edi) \n\t" - - "movq 8(%%esi), %%mm5 \n\t" - "pand %%mm1, %%mm5 \n\t" - "movq %%mm1, %%mm7 \n\t" - "movq 8(%%edi), %%mm6 \n\t" - "pandn %%mm6, %%mm7 \n\t" - "por %%mm7, %%mm5 \n\t" - "movq %%mm5, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm4 \n\t" - "movq 16(%%edi), %%mm7 \n\t" - "pandn %%mm7, %%mm4 \n\t" - "por %%mm4, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "movq 24(%%esi), %%mm7 \n\t" - "pand %%mm3, %%mm7 \n\t" - "movq %%mm3, %%mm5 \n\t" - "movq 24(%%edi), %%mm4 \n\t" - "pandn %%mm4, %%mm5 \n\t" - "por %%mm5, %%mm7 \n\t" - "movq %%mm7, 24(%%edi) \n\t" - - "addl $32, %%esi \n\t" // inc by 32 bytes processed - "addl $32, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - "ja mainloop32 \n\t" - - "mainloop32end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end32 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // low byte => high byte - - "secondloop32: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip32 \n\t" // if CF = 0 - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - - "skip32: \n\t" - "addl $4, %%esi \n\t" - "addl $4, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop32 \n\t" - - "end32: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP4 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP4 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP4 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP4 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP4; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 32 bpp */ - - case 48: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) - { - png_uint_32 len; - int diff; - int dummy_value_a; // fix 'forbidden register spilled' error - int dummy_value_d; - int dummy_value_c; - int dummy_value_S; - int dummy_value_D; - _unmask = ~mask; // global variable for -fPIC version - srcptr = png_ptr->row_buf + 1; - dstptr = row; - len = png_ptr->width &~7; // reduce to multiple of 8 - diff = (int) (png_ptr->width & 7); // amount lost // - - __asm__ __volatile__ ( - "movd _unmask, %%mm7 \n\t" // load bit pattern - "psubb %%mm6, %%mm6 \n\t" // zero mm6 - "punpcklbw %%mm7, %%mm7 \n\t" - "punpcklwd %%mm7, %%mm7 \n\t" - "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks - - "movq _mask48_0, %%mm0 \n\t" - "movq _mask48_1, %%mm1 \n\t" - "movq _mask48_2, %%mm2 \n\t" - "movq _mask48_3, %%mm3 \n\t" - "movq _mask48_4, %%mm4 \n\t" - "movq _mask48_5, %%mm5 \n\t" - - "pand %%mm7, %%mm0 \n\t" - "pand %%mm7, %%mm1 \n\t" - "pand %%mm7, %%mm2 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pand %%mm7, %%mm4 \n\t" - "pand %%mm7, %%mm5 \n\t" - - "pcmpeqb %%mm6, %%mm0 \n\t" - "pcmpeqb %%mm6, %%mm1 \n\t" - "pcmpeqb %%mm6, %%mm2 \n\t" - "pcmpeqb %%mm6, %%mm3 \n\t" - "pcmpeqb %%mm6, %%mm4 \n\t" - "pcmpeqb %%mm6, %%mm5 \n\t" - -// preload "movl len, %%ecx \n\t" // load length of line -// preload "movl srcptr, %%esi \n\t" // load source -// preload "movl dstptr, %%edi \n\t" // load dest - - "cmpl $0, %%ecx \n\t" - "jz mainloop48end \n\t" - - "mainloop48: \n\t" - "movq (%%esi), %%mm7 \n\t" - "pand %%mm0, %%mm7 \n\t" - "movq %%mm0, %%mm6 \n\t" - "pandn (%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, (%%edi) \n\t" - - "movq 8(%%esi), %%mm6 \n\t" - "pand %%mm1, %%mm6 \n\t" - "movq %%mm1, %%mm7 \n\t" - "pandn 8(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 8(%%edi) \n\t" - - "movq 16(%%esi), %%mm6 \n\t" - "pand %%mm2, %%mm6 \n\t" - "movq %%mm2, %%mm7 \n\t" - "pandn 16(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 16(%%edi) \n\t" - - "movq 24(%%esi), %%mm7 \n\t" - "pand %%mm3, %%mm7 \n\t" - "movq %%mm3, %%mm6 \n\t" - "pandn 24(%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, 24(%%edi) \n\t" - - "movq 32(%%esi), %%mm6 \n\t" - "pand %%mm4, %%mm6 \n\t" - "movq %%mm4, %%mm7 \n\t" - "pandn 32(%%edi), %%mm7 \n\t" - "por %%mm7, %%mm6 \n\t" - "movq %%mm6, 32(%%edi) \n\t" - - "movq 40(%%esi), %%mm7 \n\t" - "pand %%mm5, %%mm7 \n\t" - "movq %%mm5, %%mm6 \n\t" - "pandn 40(%%edi), %%mm6 \n\t" - "por %%mm6, %%mm7 \n\t" - "movq %%mm7, 40(%%edi) \n\t" - - "addl $48, %%esi \n\t" // inc by 48 bytes processed - "addl $48, %%edi \n\t" - "subl $8, %%ecx \n\t" // dec by 8 pixels processed - - "ja mainloop48 \n\t" - - "mainloop48end: \n\t" -// preload "movl diff, %%ecx \n\t" // (diff is in eax) - "movl %%eax, %%ecx \n\t" - "cmpl $0, %%ecx \n\t" - "jz end48 \n\t" -// preload "movl mask, %%edx \n\t" - "sall $24, %%edx \n\t" // make low byte, high byte - - "secondloop48: \n\t" - "sall %%edx \n\t" // move high bit to CF - "jnc skip48 \n\t" // if CF = 0 - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - - "skip48: \n\t" - "addl $4, %%esi \n\t" - "addl $4, %%edi \n\t" - "decl %%ecx \n\t" - "jnz secondloop48 \n\t" - - "end48: \n\t" - "EMMS \n\t" // DONE - - : "=a" (dummy_value_a), // output regs (dummy) - "=d" (dummy_value_d), - "=c" (dummy_value_c), - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "3" (srcptr), // esi // input regs - "4" (dstptr), // edi - "0" (diff), // eax -// was (unmask) "b" RESERVED // ebx // Global Offset Table idx - "2" (len), // ecx - "1" (mask) // edx - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2", "%mm3" // clobber list - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - else /* mmx _not supported - Use modified C routine */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - register png_uint_32 i; - png_uint_32 initial_val = BPP6 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP6 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP6 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP6 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP6; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - } /* end of else (_mmx_supported) */ - - break; - } /* end 48 bpp */ - - case 64: /* png_ptr->row_info.pixel_depth */ - { - png_bytep srcptr; - png_bytep dstptr; - register png_uint_32 i; - png_uint_32 initial_val = BPP8 * png_pass_start[png_ptr->pass]; - /* png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; */ - register int stride = BPP8 * png_pass_inc[png_ptr->pass]; - /* png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; */ - register int rep_bytes = BPP8 * png_pass_width[png_ptr->pass]; - /* png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; */ - png_uint_32 len = png_ptr->width &~7; /* reduce to mult. of 8 */ - int diff = (int) (png_ptr->width & 7); /* amount lost */ - register png_uint_32 final_val = BPP8 * len; /* GRR bugfix */ - - srcptr = png_ptr->row_buf + 1 + initial_val; - dstptr = row + initial_val; - - for (i = initial_val; i < final_val; i += stride) - { - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - if (diff) /* number of leftover pixels: 3 for pngtest */ - { - final_val+=diff*BPP8; - for (; i < final_val; i += stride) - { - if (rep_bytes > (int)(final_val-i)) - rep_bytes = (int)(final_val-i); - png_memcpy(dstptr, srcptr, rep_bytes); - srcptr += stride; - dstptr += stride; - } - } - - break; - } /* end 64 bpp */ - - default: /* png_ptr->row_info.pixel_depth != 1,2,4,8,16,24,32,48,64 */ - { - /* this should never happen */ - fprintf(stderr, - "libpng internal error: png_ptr->row_info.pixel_depth = %d\n", - png_ptr->row_info.pixel_depth); - fflush(stderr); - break; - } - } /* end switch (png_ptr->row_info.pixel_depth) */ - - } /* end if (non-trivial mask) */ - -} /* end png_combine_row() */ - -#endif /* PNG_HAVE_ASSEMBLER_COMBINE_ROW */ - - - - -/*===========================================================================*/ -/* */ -/* P N G _ D O _ R E A D _ I N T E R L A C E */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -#if defined(PNG_HAVE_ASSEMBLER_READ_INTERLACE) - -/* png_do_read_interlace() is called after any 16-bit to 8-bit conversion - * has taken place. [GRR: what other steps come before and/or after?] - */ - -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - png_uint_32 transformations = png_ptr->transformations; -#endif - - png_debug(1, "in png_do_read_interlace (pnggccrd.c)\n"); - - if (_mmx_supported == 2) { - png_mmx_support(); - } - - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_byte v; - png_uint_32 i; - int j; - - sp = row + (png_size_t)((row_info->width - 1) >> 3); - dp = row + (png_size_t)((final_width - 1) >> 3); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = row_info->width; i; i--) - { - v = (png_byte)((*sp >> sshift) & 0x1); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 2: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 4: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 1); - dp = row + (png_size_t)((final_width - 1) >> 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0xf); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - /*====================================================================*/ - - default: /* 8-bit or larger (this is where the routine is modified) */ - { -#if 0 -// static unsigned long long _const4 = 0x0000000000FFFFFFLL; no good -// static unsigned long long const4 = 0x0000000000FFFFFFLL; no good -// unsigned long long _const4 = 0x0000000000FFFFFFLL; no good -// unsigned long long const4 = 0x0000000000FFFFFFLL; no good -#endif - png_bytep sptr, dp; - png_uint_32 i; - png_size_t pixel_bytes; - int width = (int)row_info->width; - - pixel_bytes = (row_info->pixel_depth >> 3); - - /* point sptr at the last pixel in the pre-expanded row: */ - sptr = row + (width - 1) * pixel_bytes; - - /* point dp at the last pixel position in the expanded row: */ - dp = row + (final_width - 1) * pixel_bytes; - - /* New code by Nirav Chhatrapati - Intel Corporation */ - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) - { - //-------------------------------------------------------------- - if (pixel_bytes == 3) - { - if (((pass == 0) || (pass == 1)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $21, %%edi \n\t" - // (png_pass_inc[pass] - 1)*pixel_bytes - - ".loop3_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 - "pand _const4, %%mm0 \n\t" // z z z z z 2 1 0 - "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 - "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z - "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z - "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z - "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 - "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z - "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 - "movq %%mm0, %%mm3 \n\t" // 2 1 0 2 1 0 2 1 - "psllq $16, %%mm0 \n\t" // 0 2 1 0 2 1 z z - "movq %%mm3, %%mm4 \n\t" // 2 1 0 2 1 0 2 1 - "punpckhdq %%mm0, %%mm3 \n\t" // 0 2 1 0 2 1 0 2 - "movq %%mm4, 16(%%edi) \n\t" - "psrlq $32, %%mm0 \n\t" // z z z z 0 2 1 0 - "movq %%mm3, 8(%%edi) \n\t" - "punpckldq %%mm4, %%mm0 \n\t" // 1 0 2 1 0 2 1 0 - "subl $3, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $24, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop3_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx -// doesn't work "i" (0x0000000000FFFFFFLL) // %1 (a.k.a. _const4) - -#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm3", "%mm4" -#endif - ); - } - else if (((pass == 2) || (pass == 3)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $9, %%edi \n\t" - // (png_pass_inc[pass] - 1)*pixel_bytes - - ".loop3_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0 - "pand _const4, %%mm0 \n\t" // z z z z z 2 1 0 - "movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0 - "psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z - "movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z - "psllq $24, %%mm0 \n\t" // 2 1 0 z z z z z - "psrlq $8, %%mm1 \n\t" // z z z z z z 2 1 - "por %%mm2, %%mm0 \n\t" // 2 1 0 2 1 0 z z - "por %%mm1, %%mm0 \n\t" // 2 1 0 2 1 0 2 1 - "movq %%mm0, 4(%%edi) \n\t" - "psrlq $16, %%mm0 \n\t" // z z 2 1 0 2 1 0 - "subl $3, %%esi \n\t" - "movd %%mm0, (%%edi) \n\t" - "subl $12, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop3_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0, ..., %mm2 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list -#endif - ); - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 1) << 1) - 8; // GRR: huh? - if (width_mmx < 0) - width_mmx = 0; - width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes - if (width_mmx) - { - // png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - // sptr points at last pixel in pre-expanded row - // dp points at last pixel position in expanded row - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $9, %%edi \n\t" - // (png_pass_inc[pass] + 1)*pixel_bytes - - ".loop3_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // x x 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // x x 5 4 3 2 1 0 - "movq %%mm0, %%mm2 \n\t" // x x 5 4 3 2 1 0 - "psllq $24, %%mm0 \n\t" // 4 3 2 1 0 z z z - "pand _const4, %%mm1 \n\t" // z z z z z 2 1 0 - "psrlq $24, %%mm2 \n\t" // z z z x x 5 4 3 - "por %%mm1, %%mm0 \n\t" // 4 3 2 1 0 2 1 0 - "movq %%mm2, %%mm3 \n\t" // z z z x x 5 4 3 - "psllq $8, %%mm2 \n\t" // z z x x 5 4 3 z - "movq %%mm0, (%%edi) \n\t" - "psrlq $16, %%mm3 \n\t" // z z z z z x x 5 - "pand _const6, %%mm3 \n\t" // z z z z z z z 5 - "por %%mm3, %%mm2 \n\t" // z z x x 5 4 3 5 - "subl $6, %%esi \n\t" - "movd %%mm2, 8(%%edi) \n\t" - "subl $12, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop3_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, ..., %mm3 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list - , "%mm2", "%mm3" -#endif - ); - } - - sptr -= width_mmx*3; - dp -= width_mmx*6; - for (i = width; i; i--) - { - png_byte v[8]; - int j; - - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - } /* end of pixel_bytes == 3 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 1) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $31, %%edi \n\t" - - ".loop1_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // x x x x 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "movq %%mm0, %%mm2 \n\t" // 3 3 2 2 1 1 0 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 - "movq %%mm0, %%mm3 \n\t" // 1 1 1 1 0 0 0 0 - "punpckldq %%mm0, %%mm0 \n\t" // 0 0 0 0 0 0 0 0 - "punpckhdq %%mm3, %%mm3 \n\t" // 1 1 1 1 1 1 1 1 - "movq %%mm0, (%%edi) \n\t" - "punpckhwd %%mm2, %%mm2 \n\t" // 3 3 3 3 2 2 2 2 - "movq %%mm3, 8(%%edi) \n\t" - "movq %%mm2, %%mm4 \n\t" // 3 3 3 3 2 2 2 2 - "punpckldq %%mm2, %%mm2 \n\t" // 2 2 2 2 2 2 2 2 - "punpckhdq %%mm4, %%mm4 \n\t" // 3 3 3 3 3 3 3 3 - "movq %%mm2, 16(%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm4, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "subl $4, %%ecx \n\t" - "jnz .loop1_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1", "%mm2" // clobber list - , "%mm3", "%mm4" -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*8; - for (i = width; i; i--) - { - int j; - - /* I simplified this part in version 1.0.4e - * here and in several other instances where - * pixel_bytes == 1 -- GR-P - * - * Original code: - * - * png_byte v[8]; - * png_memcpy(v, sptr, pixel_bytes); - * for (j = 0; j < png_pass_inc[pass]; j++) - * { - * png_memcpy(dp, v, pixel_bytes); - * dp -= pixel_bytes; - * } - * sptr -= pixel_bytes; - * - * Replacement code is in the next three lines: - */ - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $3, %%esi \n\t" - "subl $15, %%edi \n\t" - - ".loop1_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "movq %%mm0, %%mm1 \n\t" // 3 3 2 2 1 1 0 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 1 1 1 1 0 0 0 0 - "punpckhwd %%mm1, %%mm1 \n\t" // 3 3 3 3 2 2 2 2 - "movq %%mm0, (%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $4, %%ecx \n\t" - "jnz .loop1_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*4; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 3) << 3); - width -= width_mmx; // 0-3 pixels => 0-3 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $7, %%esi \n\t" - "subl $15, %%edi \n\t" - - ".loop1_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpcklbw %%mm0, %%mm0 \n\t" // 3 3 2 2 1 1 0 0 - "punpckhbw %%mm1, %%mm1 \n\t" // 7 7 6 6 5 5 4 4 - "movq %%mm1, 8(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $8, %%ecx \n\t" - "jnz .loop1_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (none) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= width_mmx; - dp -= width_mmx*2; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - } /* end of pixel_bytes == 1 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 2) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $30, %%edi \n\t" - - ".loop2_pass0: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm1, 16(%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*16 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $14, %%edi \n\t" - - ".loop2_pass2: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "movq %%mm0, %%mm1 \n\t" // 3 2 3 2 1 0 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 1 0 1 0 1 0 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 3 2 3 2 3 2 3 2 - "movq %%mm0, (%%edi) \n\t" - "subl $4, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*8 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,2 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $2, %%esi \n\t" - "subl $6, %%edi \n\t" - - ".loop2_pass4: \n\t" - "movd (%%esi), %%mm0 \n\t" // x x x x 3 2 1 0 - "punpcklwd %%mm0, %%mm0 \n\t" // 3 2 3 2 1 0 1 0 - "subl $4, %%esi \n\t" - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop2_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*4 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - } /* end of pixel_bytes == 2 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 4) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $60, %%edi \n\t" - - ".loop4_pass0: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "movq %%mm1, 32(%%edi) \n\t" - "movq %%mm1, 40(%%edi) \n\t" - "movq %%mm1, 48(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm1, 56(%%edi) \n\t" - "subl $64, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*32 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $28, %%edi \n\t" - - ".loop4_pass2: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm1, 16(%%edi) \n\t" - "movq %%mm1, 24(%%edi) \n\t" - "subl $8, %%esi \n\t" - "subl $32, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*16 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; // 0,1 pixels => 0,4 bytes - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $4, %%esi \n\t" - "subl $12, %%edi \n\t" - - ".loop4_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, %%mm1 \n\t" // 7 6 5 4 3 2 1 0 - "punpckldq %%mm0, %%mm0 \n\t" // 3 2 1 0 3 2 1 0 - "punpckhdq %%mm1, %%mm1 \n\t" // 7 6 5 4 7 6 5 4 - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm1, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "subl $2, %%ecx \n\t" - "jnz .loop4_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width_mmx) // ecx - -#if 0 /* %mm0, %mm1 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0", "%mm1" // clobber list -#endif - ); - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*8 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - } /* end of pixel_bytes == 4 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 8) - { -// GRR TEST: should work, but needs testing (special 64-bit version of rpng2?) - // GRR NOTE: no need to combine passes here! - if (((pass == 0) || (pass == 1)) && width) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - // source is 8-byte RRGGBBAA - // dest is 64-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA ... - __asm__ __volatile__ ( - "subl $56, %%edi \n\t" // start of last block - - ".loop8_pass0: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "movq %%mm0, 32(%%edi) \n\t" - "movq %%mm0, 40(%%edi) \n\t" - "movq %%mm0, 48(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 56(%%edi) \n\t" - "subl $64, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass0 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - else if (((pass == 2) || (pass == 3)) && width) - { - // source is 8-byte RRGGBBAA - // dest is 32-byte RRGGBBAA RRGGBBAA RRGGBBAA RRGGBBAA - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $24, %%edi \n\t" // start of last block - - ".loop8_pass2: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "movq %%mm0, 16(%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 24(%%edi) \n\t" - "subl $32, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass2 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - } - else if (width) // pass == 4 or 5 - { - // source is 8-byte RRGGBBAA - // dest is 16-byte RRGGBBAA RRGGBBAA - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - int dummy_value_c; // fix 'forbidden register spilled' - int dummy_value_S; - int dummy_value_D; - - __asm__ __volatile__ ( - "subl $8, %%edi \n\t" // start of last block - - ".loop8_pass4: \n\t" - "movq (%%esi), %%mm0 \n\t" // 7 6 5 4 3 2 1 0 - "movq %%mm0, (%%edi) \n\t" - "subl $8, %%esi \n\t" - "movq %%mm0, 8(%%edi) \n\t" - "subl $16, %%edi \n\t" - "decl %%ecx \n\t" - "jnz .loop8_pass4 \n\t" - "EMMS \n\t" // DONE - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "1" (sptr), // esi // input regs - "2" (dp), // edi - "0" (width) // ecx - -#if 0 /* %mm0 not supported by gcc 2.7.2.3 or egcs 1.1 */ - : "%mm0" // clobber list -#endif - ); - } - } - - } /* end of pixel_bytes == 8 */ - - //-------------------------------------------------------------- - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } /* end of pixel_bytes == 6 */ - - //-------------------------------------------------------------- - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr-= pixel_bytes; - } - } - } // end of _mmx_supported ======================================== - - else /* MMX not supported: use modified C code - takes advantage - * of inlining of png_memcpy for a constant */ - /* GRR 19991007: does it? or should pixel_bytes in each - * block be replaced with immediate value (e.g., 1)? */ - /* GRR 19991017: replaced with constants in each case */ -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - if (pixel_bytes == 1) - { - for (i = width; i; i--) - { - int j; - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - --sptr; - } - } - else if (pixel_bytes == 3) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - else if (pixel_bytes == 2) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 2); - dp -= 2; - } - sptr -= 2; - } - } - else if (pixel_bytes == 4) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { -#ifdef PNG_DEBUG - if (dp < row || dp+3 > row+png_ptr->row_buf_size) - { - printf("dp out of bounds: row=%d, dp=%d, rp=%d\n",row, dp, - row+png_ptr->row_buf_size); - printf("row_buf=%d\n",png_ptr->row_buf_size); - } -#endif - png_memcpy(dp, v, 4); - dp -= 4; - } - sptr -= 4; - } - } - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } - else if (pixel_bytes == 8) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 8); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 8); - dp -= 8; - } - sptr -= 8; - } - } - else /* GRR: should never be reached */ - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - - } /* end if (MMX not supported) */ - break; - } - } /* end switch (row_info->pixel_depth) */ - - row_info->width = final_width; - row_info->rowbytes = ((final_width * - (png_uint_32)row_info->pixel_depth + 7) >> 3); - } - -} /* end png_do_read_interlace() */ - -#endif /* PNG_HAVE_ASSEMBLER_READ_INTERLACE */ -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - - - - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - -// These variables are utilized in the functions below. They are declared -// globally here to ensure alignment on 8-byte boundaries. - -union uAll { - long long use; - double align; -} _LBCarryMask = {0x0101010101010101LL}, - _HBClearMask = {0x7f7f7f7f7f7f7f7fLL}, - _ActiveMask, _ActiveMask2, _ActiveMaskEnd, _ShiftBpp, _ShiftRem; - - - -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ A V G // -// // -//===========================================================================// - -// Optimized code for PNG Average filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - int bpp; - int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // get # bytes per pixel - _FullLength = row_info->rowbytes; // # of bytes to filter - - __asm__ __volatile__ ( - // initialize address pointers and offset -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif -//pre "movl row, %%edi \n\t" // edi: Avg(x) - "xorl %%ebx, %%ebx \n\t" // ebx: x - "movl %%edi, %%edx \n\t" -//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - - "xorl %%eax,%%eax \n\t" - - // Compute the Raw value for the first bpp bytes - // Raw(x) = Avg(x) + (Prior(x)/2) - "avg_rlp: \n\t" - "movb (%%esi,%%ebx,),%%al \n\t" // load al with Prior(x) - "incl %%ebx \n\t" - "shrb %%al \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,),%%al \n\t" // add Avg(x); -1 to offset inc ebx -//pre "cmpl bpp, %%ebx \n\t" // (bpp is preloaded into ecx) - "cmpl %%ecx, %%ebx \n\t" - "movb %%al,-1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx - "jb avg_rlp \n\t" // mov does not affect flags - - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl %%ebx, _dif \n\t" // add bpp - "addl $0xf, _dif \n\t" // add 7+8 to incr past alignment bdry - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start => value ebx at - "jz avg_go \n\t" // alignment - - // fix alignment - // Compute the Raw value for the bytes up to the alignment boundary - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%ecx, %%ecx \n\t" - - "avg_lp1: \n\t" - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _dif, %%ebx \n\t" // check if at alignment boundary - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write Raw(x); -1 to offset inc ebx - "jb avg_lp1 \n\t" // repeat until at alignment boundary - - "avg_go: \n\t" - "movl _FullLength, %%eax \n\t" - "movl %%eax, %%ecx \n\t" - "subl %%ebx, %%eax \n\t" // subtract alignment fix - "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 - "subl %%eax, %%ecx \n\t" // drop over bytes from original length - "movl %%ecx, _MMXLength \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - // GRR: INCLUDE "memory" as clobbered? (_dif, _MMXLength) - // (seems to work fine without...) - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000000000ffffffLL; - _ShiftBpp.use = 24; // == 3 * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( - // re-init address pointers and offset - "movq _ActiveMask, %%mm7 \n\t" - "movl _dif, %%ecx \n\t" // ecx: x = offset to - "movq _LBCarryMask, %%mm5 \n\t" // alignment boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (correct pos. in loop below) - "avg_3lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" // load mm0 with Avg(x) - "movq %%mm5, %%mm3 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // correct position Raw(x-bpp) data - "movq (%%esi,%%ecx,), %%mm1 \n\t" // load mm1 with Prior(x) - "movq %%mm7, %%mm6 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for each byte - // add 1st active group (Raw(x-bpp)/2) to average with LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover bytes 3-5 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift mm6 mask to cover last two - // bytes - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 bytes to add to Avg - "addl $8, %%ecx \n\t" - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // move updated Raw(x) to use as Raw(x-bpp) for next loop - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm0, %%mm2 \n\t" // mov updated Raw(x) to mm2 - "jb avg_3lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 3 bpp - - case 6: - case 4: - //case 7: // who wrote this? PNG doesn't support 5 or 7 bytes/pixel - //case 5: // GRR BOGUS - { - _ActiveMask.use = 0xffffffffffffffffLL; // use shift below to clear - // appropriate inactive bytes - _ShiftBpp.use = bpp << 3; - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( - "movq _HBClearMask, %%mm4 \n\t" - - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x = offset to alignment boundary - - // load _ActiveMask and clear all bytes except for 1st active group - "movq _ActiveMask, %%mm7 \n\t" -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "psrlq _ShiftRem, %%mm7 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movq %%mm7, %%mm6 \n\t" - "movq _LBCarryMask, %%mm5 \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // create mask for 2nd active group - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (we correct pos. in loop below) - "avg_4lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly - "movq (%%esi,%%ecx,), %%mm1 \n\t" - // add (Prev_row/2) to average - "movq %%mm5, %%mm3 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for each byte - // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) for each byte - "pand %%mm7, %%mm2 \n\t" // leave only Active Group 1 bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "addl $8, %%ecx \n\t" - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg for each Active - // byte - "cmpl _MMXLength, %%ecx \n\t" - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // prep Raw(x-bpp) for next loop - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "jb avg_4lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 4,6 bpp - - case 2: - { - _ActiveMask.use = 0x000000000000ffffLL; - _ShiftBpp.use = 16; // == 2 * 8 - _ShiftRem.use = 48; // == 64 - 16 - - __asm__ __volatile__ ( - // load _ActiveMask - "movq _ActiveMask, %%mm7 \n\t" - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x = offset to alignment boundary - "movq _LBCarryMask, %%mm5 \n\t" -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (we correct pos. in loop below) - "avg_2lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "psrlq _ShiftRem, %%mm2 \n\t" // shift data to pos. correctly - "movq (%%esi,%%ecx,), %%mm1 \n\t" // (GRR BUGFIX: was psllq) - // add (Prev_row/2) to average - "movq %%mm5, %%mm3 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each byte - "movq %%mm7, %%mm6 \n\t" - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for each byte - - // add 1st active group (Raw(x-bpp)/2) to average with _LBCarry - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 1 bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg for each Active byte - - // add 2nd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover bytes 2 & 3 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg for each Active byte - - // add 3rd active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover bytes 4 & 5 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg for each Active byte - - // add 4th active group (Raw(x-bpp)/2) to average with _LBCarry - "psllq _ShiftBpp, %%mm6 \n\t" // shift the mm6 mask to cover bytes 6 & 7 - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "psllq _ShiftBpp, %%mm2 \n\t" // shift data to pos. correctly - "addl $8, %%ecx \n\t" - "movq %%mm3, %%mm1 \n\t" // now use mm1 for getting LBCarrys - "pand %%mm2, %%mm1 \n\t" // get LBCarrys for each byte where both - // lsb's were == 1 (only valid for active group) - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm2 \n\t" // add LBCarrys to (Raw(x-bpp)/2) for each byte - "pand %%mm6, %%mm2 \n\t" // leave only Active Group 2 bytes to add to Avg - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) + LBCarrys to Avg for each Active byte - - "cmpl _MMXLength, %%ecx \n\t" - // now ready to write back to memory - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - // prep Raw(x-bpp) for next loop - "movq %%mm0, %%mm2 \n\t" // mov updated Raws to mm2 - "jb avg_2lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 2 bpp - - case 1: - { - __asm__ __volatile__ ( - // re-init address pointers and offset -#ifdef __PIC__ - "pushl %%ebx \n\t" // save Global Offset Table index -#endif - "movl _dif, %%ebx \n\t" // ebx: x = offset to alignment boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array - "jnb avg_1end \n\t" - // do Paeth decode for remaining bytes -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movl %%edi, %%edx \n\t" -// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx - // in loop below - "avg_1lp: \n\t" - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _FullLength, %%ebx \n\t" // check if at end of array - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - "jb avg_1lp \n\t" - - "avg_1end: \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // Global Offset Table index -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - } - return; // end 1 bpp - - case 8: - { - __asm__ __volatile__ ( - // re-init address pointers and offset - "movl _dif, %%ecx \n\t" // ecx: x == offset to alignment - "movq _LBCarryMask, %%mm5 \n\t" // boundary -// preload "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" -// preload "movl prev_row, %%esi \n\t" // esi: Prior(x) - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm2 \n\t" // load previous aligned 8 bytes - // (NO NEED to correct pos. in loop below) - - "avg_8lp: \n\t" - "movq (%%edi,%%ecx,), %%mm0 \n\t" - "movq %%mm5, %%mm3 \n\t" - "movq (%%esi,%%ecx,), %%mm1 \n\t" - "addl $8, %%ecx \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte - // where both lsb's were == 1 - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7, each byte - "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg, each byte - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7, each byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg, each - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm0, -8(%%edi,%%ecx,) \n\t" - "movq %%mm0, %%mm2 \n\t" // reuse as Raw(x-bpp) - "jb avg_8lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm5 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2" - , "%mm3", "%mm4", "%mm5" -#endif - ); - } - break; // end 8 bpp - - default: // bpp greater than 8 (!= 1,2,3,4,[5],6,[7],8) - { - - // GRR: PRINT ERROR HERE: SHOULD NEVER BE REACHED - fprintf(stderr, - "libpng: internal logic error (png_read_filter_row_mmx_avg())\n"); - -#if 0 - __asm__ __volatile__ ( - "movq _LBCarryMask, %%mm5 \n\t" - // re-init address pointers and offset - "movl _dif, %%ebx \n\t" // ebx: x = offset to alignment boundary - "movl row, %%edi \n\t" // edi: Avg(x) - "movq _HBClearMask, %%mm4 \n\t" - "movl %%edi, %%edx \n\t" - "movl prev_row, %%esi \n\t" // esi: Prior(x) - "subl bpp, %%edx \n\t" // edx: Raw(x-bpp) - "avg_Alp: \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "movq %%mm5, %%mm3 \n\t" - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "pand %%mm1, %%mm3 \n\t" // get lsb for each prev_row byte - "movq (%%edx,%%ebx,), %%mm2 \n\t" - "psrlq $1, %%mm1 \n\t" // divide prev_row bytes by 2 - "pand %%mm2, %%mm3 \n\t" // get LBCarrys for each byte where both - // lsb's were == 1 - "psrlq $1, %%mm2 \n\t" // divide raw bytes by 2 - "pand %%mm4, %%mm1 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm3, %%mm0 \n\t" // add LBCarrys to Avg for each byte - "pand %%mm4, %%mm2 \n\t" // clear invalid bit 7 of each byte - "paddb %%mm1, %%mm0 \n\t" // add (Prev_row/2) to Avg for each byte - "addl $8, %%ebx \n\t" - "paddb %%mm2, %%mm0 \n\t" // add (Raw/2) to Avg for each byte - "cmpl _MMXLength, %%ebx \n\t" - "movq %%mm0, -8(%%edi,%%ebx,) \n\t" - "jb avg_Alp \n\t" - - : // FIXASM: output regs/vars go here, e.g.: "=m" (memory_var) - - : // FIXASM: input regs, e.g.: "c" (count), "S" (src), "D" (dest) - - : "%ebx", "%edx", "%edi", "%esi" // CHECKASM: clobber list - ); -#endif /* 0 - NEVER REACHED */ - } - break; - - } // end switch (bpp) - - __asm__ __volatile__ ( - // MMX acceleration complete; now do clean-up - // check if any remaining bytes left to decode -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "movl _MMXLength, %%ebx \n\t" // ebx: x == offset bytes after MMX -//pre "movl row, %%edi \n\t" // edi: Avg(x) - "cmpl _FullLength, %%ebx \n\t" // test if offset at end of array - "jnb avg_end \n\t" - - // do Avg decode for remaining bytes -//pre "movl prev_row, %%esi \n\t" // esi: Prior(x) - "movl %%edi, %%edx \n\t" -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx: Raw(x-bpp) - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below - - "avg_lp2: \n\t" - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - "xorl %%eax, %%eax \n\t" - "movb (%%esi,%%ebx,), %%cl \n\t" // load cl with Prior(x) - "movb (%%edx,%%ebx,), %%al \n\t" // load al with Raw(x-bpp) - "addw %%cx, %%ax \n\t" - "incl %%ebx \n\t" - "shrw %%ax \n\t" // divide by 2 - "addb -1(%%edi,%%ebx,), %%al \n\t" // add Avg(x); -1 to offset inc ebx - "cmpl _FullLength, %%ebx \n\t" // check if at end of array - "movb %%al, -1(%%edi,%%ebx,) \n\t" // write back Raw(x) [mov does not - "jb avg_lp2 \n\t" // affect flags; -1 to offset inc ebx] - - "avg_end: \n\t" - "EMMS \n\t" // end MMX; prep for poss. FP instrs. -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - -} /* end png_read_filter_row_mmx_avg() */ - - - - -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ P A E T H // -// // -//===========================================================================// - -// Optimized code for PNG Paeth filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - int bpp; - int dummy_value_c; // fix 'forbidden register 2 (cx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - _FullLength = row_info->rowbytes; // # of bytes to filter - - __asm__ __volatile__ ( -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "xorl %%ebx, %%ebx \n\t" // ebx: x offset -//pre "movl row, %%edi \n\t" - "xorl %%edx, %%edx \n\t" // edx: x-bpp offset -//pre "movl prev_row, %%esi \n\t" - "xorl %%eax, %%eax \n\t" - - // Compute the Raw value for the first bpp bytes - // Note: the formula works out to be always - // Paeth(x) = Raw(x) + Prior(x) where x < bpp - "paeth_rlp: \n\t" - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" -//pre "cmpl bpp, %%ebx \n\t" (bpp is preloaded into ecx) - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" - "jb paeth_rlp \n\t" - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl %%ebx, _dif \n\t" // add bpp - "xorl %%ecx, %%ecx \n\t" - "addl $0xf, _dif \n\t" // add 7 + 8 to incr past alignment boundary - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start ==> value ebx at alignment - "jz paeth_go \n\t" - // fix alignment - - "paeth_lp1: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_pca \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_pca: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_pba \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_pba: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_paa \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_paa: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_abb \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_bbc \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth \n\t" - - "paeth_bbc: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_paeth \n\t" - - "paeth_abb: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_abc \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth \n\t" - - "paeth_abc: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_paeth: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _dif, %%ebx \n\t" - "jb paeth_lp1 \n\t" - - "paeth_go: \n\t" - "movl _FullLength, %%ecx \n\t" - "movl %%ecx, %%eax \n\t" - "subl %%ebx, %%eax \n\t" // subtract alignment fix - "andl $0x00000007, %%eax \n\t" // calc bytes over mult of 8 - "subl %%eax, %%ecx \n\t" // drop over bytes from original length - "movl %%ecx, _MMXLength \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000000000ffffffLL; - _ActiveMaskEnd.use = 0xffff000000000000LL; - _ShiftBpp.use = 24; // == bpp(3) * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "paeth_3lp: \n\t" - "psrlq _ShiftRem, %%mm1 \n\t" // shift last 3 bytes to 1st 3 bytes - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // prep c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "psrlq _ShiftRem, %%mm3 \n\t" // shift last 3 bytes to 1st 3 bytes - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as Raw(x-bpp) - // now do Paeth for 2nd set of bytes (3-5) - "psrlq _ShiftBpp, %%mm2 \n\t" // load b=Prior(x) step 2 - "punpcklbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "pxor %%mm7, %%mm7 \n\t" - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "psubw %%mm3, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = - // pav + pbv = pbv + pav - "movq %%mm5, %%mm6 \n\t" - "paddw %%mm4, %%mm6 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm5, %%mm0 \n\t" // create mask pbv bytes < 0 - "pcmpgtw %%mm4, %%mm7 \n\t" // create mask pav bytes < 0 - "pand %%mm5, %%mm0 \n\t" // only pbv bytes < 0 in mm0 - "pand %%mm4, %%mm7 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm5 \n\t" - "psubw %%mm7, %%mm4 \n\t" - "psubw %%mm0, %%mm5 \n\t" - "psubw %%mm7, %%mm4 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq %%mm2, %%mm3 \n\t" // load c=Prior(x-bpp) step 1 - "pand _ActiveMask, %%mm7 \n\t" - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "psllq _ShiftBpp, %%mm7 \n\t" // shift bytes to 2nd group of 3 bytes - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "psllq _ShiftBpp, %%mm3 \n\t" // load c=Prior(x-bpp) step 2 - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "psllq _ShiftBpp, %%mm1 \n\t" // shift bytes - // now mm1 will be used as Raw(x-bpp) - // now do Paeth for 3rd, and final, set of bytes (6-7) - "pxor %%mm7, %%mm7 \n\t" - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - "psubw %%mm3, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "paddw %%mm5, %%mm6 \n\t" - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "packuswb %%mm7, %%mm1 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "pand _ActiveMaskEnd, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - - "cmpl _MMXLength, %%ecx \n\t" - "pxor %%mm0, %%mm0 \n\t" // pxor does not affect flags - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - // mm3 ready to be used as Prior(x-bpp) next loop - "jb paeth_3lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 3 bpp - - case 6: - //case 7: // GRR BOGUS - //case 5: // GRR BOGUS - { - _ActiveMask.use = 0x00000000ffffffffLL; - _ActiveMask2.use = 0xffffffff00000000LL; - _ShiftBpp.use = bpp << 3; // == bpp * 8 - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "pxor %%mm0, %%mm0 \n\t" - - "paeth_6lp: \n\t" - // must shift to position Raw(x-bpp) data - "psrlq _ShiftRem, %%mm1 \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - // must shift to position Prior(x-bpp) data - "psrlq _ShiftRem, %%mm3 \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "psrlq _ShiftRem, %%mm3 \n\t" - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor and Raw(x) - "movq %%mm2, %%mm6 \n\t" - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" - "movq %%mm7, %%mm5 \n\t" - "psrlq _ShiftRem, %%mm1 \n\t" - "por %%mm6, %%mm3 \n\t" - "psllq _ShiftBpp, %%mm5 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "por %%mm5, %%mm1 \n\t" - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_6lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 6 bpp - - case 4: - { - _ActiveMask.use = 0x00000000ffffffffLL; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read - // a=Raw(x-bpp) bytes - "paeth_4lp: \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpckhbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm3 \n\t" // load c=Prior(x-bpp) - "pand _ActiveMask, %%mm7 \n\t" - "movq %%mm3, %%mm2 \n\t" // load b=Prior(x) step 1 - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpcklbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq %%mm7, %%mm1 \n\t" // now mm1 will be used as Raw(x-bpp) - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_4lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 4 bpp - - case 8: // bpp == 8 - { - _ActiveMask.use = 0x00000000ffffffffLL; - - __asm__ __volatile__ ( - "movl _dif, %%ecx \n\t" -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - "pxor %%mm0, %%mm0 \n\t" - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // only time should need to read - // a=Raw(x-bpp) bytes - "paeth_8lp: \n\t" - // do first set of 4 bytes - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "punpcklbw %%mm0, %%mm1 \n\t" // unpack Low bytes of a - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "punpcklbw %%mm0, %%mm2 \n\t" // unpack Low bytes of b - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" // unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "packuswb %%mm1, %%mm7 \n\t" - "movq -8(%%esi,%%ecx,), %%mm3 \n\t" // read c=Prior(x-bpp) bytes - "pand _ActiveMask, %%mm7 \n\t" - "movq (%%esi,%%ecx,), %%mm2 \n\t" // load b=Prior(x) - "paddb (%%edi,%%ecx,), %%mm7 \n\t" // add Paeth predictor with Raw(x) - "punpckhbw %%mm0, %%mm3 \n\t" // unpack High bytes of c - "movq %%mm7, (%%edi,%%ecx,) \n\t" // write back updated value - "movq -8(%%edi,%%ecx,), %%mm1 \n\t" // read a=Raw(x-bpp) bytes - - // do second set of 4 bytes - "punpckhbw %%mm0, %%mm2 \n\t" // unpack High bytes of b - "punpckhbw %%mm0, %%mm1 \n\t" // unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - "movq %%mm2, %%mm4 \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movq %%mm1, %%mm5 \n\t" - "psubw %%mm3, %%mm4 \n\t" - "pxor %%mm7, %%mm7 \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "movq %%mm4, %%mm6 \n\t" - "psubw %%mm3, %%mm5 \n\t" - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - "pcmpgtw %%mm4, %%mm0 \n\t" // create mask pav bytes < 0 - "paddw %%mm5, %%mm6 \n\t" - "pand %%mm4, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "pcmpgtw %%mm5, %%mm7 \n\t" // create mask pbv bytes < 0 - "psubw %%mm0, %%mm4 \n\t" - "pand %%mm5, %%mm7 \n\t" // only pbv bytes < 0 in mm0 - "psubw %%mm0, %%mm4 \n\t" - "psubw %%mm7, %%mm5 \n\t" - "pxor %%mm0, %%mm0 \n\t" - "pcmpgtw %%mm6, %%mm0 \n\t" // create mask pcv bytes < 0 - "pand %%mm6, %%mm0 \n\t" // only pav bytes < 0 in mm7 - "psubw %%mm7, %%mm5 \n\t" - "psubw %%mm0, %%mm6 \n\t" - // test pa <= pb - "movq %%mm4, %%mm7 \n\t" - "psubw %%mm0, %%mm6 \n\t" - "pcmpgtw %%mm5, %%mm7 \n\t" // pa > pb? - "movq %%mm7, %%mm0 \n\t" - // use mm7 mask to merge pa & pb - "pand %%mm7, %%mm5 \n\t" - // use mm0 mask copy to merge a & b - "pand %%mm0, %%mm2 \n\t" - "pandn %%mm4, %%mm7 \n\t" - "pandn %%mm1, %%mm0 \n\t" - "paddw %%mm5, %%mm7 \n\t" - "paddw %%mm2, %%mm0 \n\t" - // test ((pa <= pb)? pa:pb) <= pc - "pcmpgtw %%mm6, %%mm7 \n\t" // pab > pc? - "pxor %%mm1, %%mm1 \n\t" - "pand %%mm7, %%mm3 \n\t" - "pandn %%mm0, %%mm7 \n\t" - "pxor %%mm1, %%mm1 \n\t" - "paddw %%mm3, %%mm7 \n\t" - "pxor %%mm0, %%mm0 \n\t" - // step ecx to next set of 8 bytes and repeat loop til done - "addl $8, %%ecx \n\t" - "packuswb %%mm7, %%mm1 \n\t" - "paddb -8(%%edi,%%ecx,), %%mm1 \n\t" // add Paeth predictor with Raw(x) - "cmpl _MMXLength, %%ecx \n\t" - "movq %%mm1, -8(%%edi,%%ecx,) \n\t" // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - "jb paeth_8lp \n\t" - - : "=S" (dummy_value_S), // output regs (dummy) - "=D" (dummy_value_D) - - : "0" (prev_row), // esi // input regs - "1" (row) // edi - - : "%ecx" // clobber list -#if 0 /* %mm0, ..., %mm7 not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; // end 8 bpp - - case 1: // bpp = 1 - case 2: // bpp = 2 - default: // bpp > 8 - { - __asm__ __volatile__ ( -#ifdef __PIC__ - "pushl %%ebx \n\t" // save Global Offset Table index -#endif - "movl _dif, %%ebx \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jnb paeth_dend \n\t" - -// preload "movl row, %%edi \n\t" -// preload "movl prev_row, %%esi \n\t" - // do Paeth decode for remaining bytes - "movl %%ebx, %%edx \n\t" -// preload "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx = ebx - bpp - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx - - "paeth_dlp: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_dpca \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_dpca: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_dpba \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_dpba: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_dpaa \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_dpaa: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_dabb \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_dbbc \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dbbc: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dabb: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_dabc \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_dpaeth \n\t" - - "paeth_dabc: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_dpaeth: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jb paeth_dlp \n\t" - - "paeth_dend: \n\t" -#ifdef __PIC__ - "popl %%ebx \n\t" // index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list -#ifndef __PIC__ - , "%ebx" -#endif - ); - } - return; // No need to go further with this one - - } // end switch (bpp) - - __asm__ __volatile__ ( - // MMX acceleration complete; now do clean-up - // check if any remaining bytes left to decode -#ifdef __PIC__ - "pushl %%ebx \n\t" // save index to Global Offset Table -#endif - "movl _MMXLength, %%ebx \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jnb paeth_end \n\t" -//pre "movl row, %%edi \n\t" -//pre "movl prev_row, %%esi \n\t" - // do Paeth decode for remaining bytes - "movl %%ebx, %%edx \n\t" -//pre "subl bpp, %%edx \n\t" // (bpp is preloaded into ecx) - "subl %%ecx, %%edx \n\t" // edx = ebx - bpp - "xorl %%ecx, %%ecx \n\t" // zero ecx before using cl & cx below - - "paeth_lp2: \n\t" - "xorl %%eax, %%eax \n\t" - // pav = p - a = (a + b - c) - a = b - c - "movb (%%esi,%%ebx,), %%al \n\t" // load Prior(x) into al - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, _patemp \n\t" // Save pav for later use - "xorl %%eax, %%eax \n\t" - // pbv = p - b = (a + b - c) - b = a - c - "movb (%%edi,%%edx,), %%al \n\t" // load Raw(x-bpp) into al - "subl %%ecx, %%eax \n\t" // subtract Prior(x-bpp) - "movl %%eax, %%ecx \n\t" - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - "addl _patemp, %%eax \n\t" // pcv = pav + pbv - // pc = abs(pcv) - "testl $0x80000000, %%eax \n\t" - "jz paeth_pca2 \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_pca2: \n\t" - "movl %%eax, _pctemp \n\t" // save pc for later use - // pb = abs(pbv) - "testl $0x80000000, %%ecx \n\t" - "jz paeth_pba2 \n\t" - "negl %%ecx \n\t" // reverse sign of neg values - - "paeth_pba2: \n\t" - "movl %%ecx, _pbtemp \n\t" // save pb for later use - // pa = abs(pav) - "movl _patemp, %%eax \n\t" - "testl $0x80000000, %%eax \n\t" - "jz paeth_paa2 \n\t" - "negl %%eax \n\t" // reverse sign of neg values - - "paeth_paa2: \n\t" - "movl %%eax, _patemp \n\t" // save pa for later use - // test if pa <= pb - "cmpl %%ecx, %%eax \n\t" - "jna paeth_abb2 \n\t" - // pa > pb; now test if pb <= pc - "cmpl _pctemp, %%ecx \n\t" - "jna paeth_bbc2 \n\t" - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_bbc2: \n\t" - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - "movb (%%esi,%%ebx,), %%cl \n\t" // load Prior(x) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_abb2: \n\t" - // pa <= pb; now test if pa <= pc - "cmpl _pctemp, %%eax \n\t" - "jna paeth_abc2 \n\t" - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - "movb (%%esi,%%edx,), %%cl \n\t" // load Prior(x-bpp) into cl - "jmp paeth_paeth2 \n\t" - - "paeth_abc2: \n\t" - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - "movb (%%edi,%%edx,), %%cl \n\t" // load Raw(x-bpp) into cl - - "paeth_paeth2: \n\t" - "incl %%ebx \n\t" - "incl %%edx \n\t" - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - "addb %%cl, -1(%%edi,%%ebx,) \n\t" - "cmpl _FullLength, %%ebx \n\t" - "jb paeth_lp2 \n\t" - - "paeth_end: \n\t" - "EMMS \n\t" // end MMX; prep for poss. FP instrs. -#ifdef __PIC__ - "popl %%ebx \n\t" // restore index to Global Offset Table -#endif - - : "=c" (dummy_value_c), // output regs (dummy) - "=S" (dummy_value_S), - "=D" (dummy_value_D) - - : "0" (bpp), // ecx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%edx" // clobber list (no input regs!) -#ifndef __PIC__ - , "%ebx" -#endif - ); - -} /* end png_read_filter_row_mmx_paeth() */ - - - - -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ S U B // -// // -//===========================================================================// - -// Optimized code for PNG Sub filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) -{ - int bpp; - int dummy_value_a; - int dummy_value_D; - - bpp = (row_info->pixel_depth + 7) >> 3; // calc number of bytes per pixel - _FullLength = row_info->rowbytes - bpp; // number of bytes to filter - - __asm__ __volatile__ ( -//pre "movl row, %%edi \n\t" - "movl %%edi, %%esi \n\t" // lp = row -//pre "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp -//irr "xorl %%eax, %%eax \n\t" - // get # of bytes to alignment - "movl %%edi, _dif \n\t" // take start of row - "addl $0xf, _dif \n\t" // add 7 + 8 to incr past - // alignment boundary - "xorl %%ecx, %%ecx \n\t" - "andl $0xfffffff8, _dif \n\t" // mask to alignment boundary - "subl %%edi, _dif \n\t" // subtract from start ==> value - "jz sub_go \n\t" // ecx at alignment - - "sub_lp1: \n\t" // fix alignment - "movb (%%esi,%%ecx,), %%al \n\t" - "addb %%al, (%%edi,%%ecx,) \n\t" - "incl %%ecx \n\t" - "cmpl _dif, %%ecx \n\t" - "jb sub_lp1 \n\t" - - "sub_go: \n\t" - "movl _FullLength, %%eax \n\t" - "movl %%eax, %%edx \n\t" - "subl %%ecx, %%edx \n\t" // subtract alignment fix - "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 - "subl %%edx, %%eax \n\t" // drop over bytes from length - "movl %%eax, _MMXLength \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%ebx", "%ecx", "%edx" // clobber list - , "%esi" - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - - // now do the math for the rest of the row - switch (bpp) - { - case 3: - { - _ActiveMask.use = 0x0000ffffff000000LL; - _ShiftBpp.use = 24; // == 3 * 8 - _ShiftRem.use = 40; // == 64 - 24 - - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd - // active byte group - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "movq %%mm7, %%mm6 \n\t" - "movl _dif, %%edx \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover - // 3rd active byte group - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_3lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - // add 1st active group - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 3rd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_3lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm6", "%mm7" -#endif - ); - } - break; - - case 1: - { - __asm__ __volatile__ ( - "movl _dif, %%edx \n\t" -// preload "movl row, %%edi \n\t" - "cmpl _FullLength, %%edx \n\t" - "jnb sub_1end \n\t" - "movl %%edi, %%esi \n\t" // lp = row - "xorl %%eax, %%eax \n\t" -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - "sub_1lp: \n\t" - "movb (%%esi,%%edx,), %%al \n\t" - "addb %%al, (%%edi,%%edx,) \n\t" - "incl %%edx \n\t" - "cmpl _FullLength, %%edx \n\t" - "jb sub_1lp \n\t" - - "sub_1end: \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list - ); - } - return; - - case 6: - case 4: - //case 7: // GRR BOGUS - //case 5: // GRR BOGUS - { - _ShiftBpp.use = bpp << 3; - _ShiftRem.use = 64 - _ShiftBpp.use; - - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movl _dif, %%edx \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_4lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_4lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1" -#endif - ); - } - break; - - case 2: - { - _ActiveMask.use = 0x00000000ffff0000LL; - _ShiftBpp.use = 16; // == 2 * 8 - _ShiftRem.use = 48; // == 64 - 16 - - __asm__ __volatile__ ( - "movq _ActiveMask, %%mm7 \n\t" // load _ActiveMask for 2nd - // active byte group - "movl _dif, %%edx \n\t" - "movq %%mm7, %%mm6 \n\t" -// preload "movl row, %%edi \n\t" - "psllq _ShiftBpp, %%mm6 \n\t" // move mask in mm6 to cover - // 3rd active byte group - "movl %%edi, %%esi \n\t" // lp = row - "movq %%mm6, %%mm5 \n\t" -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "psllq _ShiftBpp, %%mm5 \n\t" // move mask in mm5 to cover - // 4th active byte group - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm1 \n\t" - - "sub_2lp: \n\t" // shift data for adding first - "psrlq _ShiftRem, %%mm1 \n\t" // bpp bytes (no need for mask; - // shift clears inactive bytes) - // add 1st active group - "movq (%%edi,%%edx,), %%mm0 \n\t" - "paddb %%mm1, %%mm0 \n\t" - - // add 2nd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm7, %%mm1 \n\t" // mask to use 2nd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 3rd active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm6, %%mm1 \n\t" // mask to use 3rd active group - "paddb %%mm1, %%mm0 \n\t" - - // add 4th active group - "movq %%mm0, %%mm1 \n\t" // mov updated Raws to mm1 - "psllq _ShiftBpp, %%mm1 \n\t" // shift data to pos. correctly - "pand %%mm5, %%mm1 \n\t" // mask to use 4th active group - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // write updated Raws to array - "movq %%mm0, %%mm1 \n\t" // prep 1st add at top of loop - "jb sub_2lp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; - - case 8: - { - __asm__ __volatile__ ( -// preload "movl row, %%edi \n\t" - "movl _dif, %%edx \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "movl _MMXLength, %%ecx \n\t" - - // prime the pump: load the first Raw(x-bpp) data set - "movq -8(%%edi,%%edx,), %%mm7 \n\t" - "andl $0x0000003f, %%ecx \n\t" // calc bytes over mult of 64 - - "sub_8lp: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" // load Sub(x) for 1st 8 bytes - "paddb %%mm7, %%mm0 \n\t" - "movq 8(%%edi,%%edx,), %%mm1 \n\t" // load Sub(x) for 2nd 8 bytes - "movq %%mm0, (%%edi,%%edx,) \n\t" // write Raw(x) for 1st 8 bytes - - // Now mm0 will be used as Raw(x-bpp) for the 2nd group of 8 bytes. - // This will be repeated for each group of 8 bytes with the 8th - // group being used as the Raw(x-bpp) for the 1st group of the - // next loop. - - "paddb %%mm0, %%mm1 \n\t" - "movq 16(%%edi,%%edx,), %%mm2 \n\t" // load Sub(x) for 3rd 8 bytes - "movq %%mm1, 8(%%edi,%%edx,) \n\t" // write Raw(x) for 2nd 8 bytes - "paddb %%mm1, %%mm2 \n\t" - "movq 24(%%edi,%%edx,), %%mm3 \n\t" // load Sub(x) for 4th 8 bytes - "movq %%mm2, 16(%%edi,%%edx,) \n\t" // write Raw(x) for 3rd 8 bytes - "paddb %%mm2, %%mm3 \n\t" - "movq 32(%%edi,%%edx,), %%mm4 \n\t" // load Sub(x) for 5th 8 bytes - "movq %%mm3, 24(%%edi,%%edx,) \n\t" // write Raw(x) for 4th 8 bytes - "paddb %%mm3, %%mm4 \n\t" - "movq 40(%%edi,%%edx,), %%mm5 \n\t" // load Sub(x) for 6th 8 bytes - "movq %%mm4, 32(%%edi,%%edx,) \n\t" // write Raw(x) for 5th 8 bytes - "paddb %%mm4, %%mm5 \n\t" - "movq 48(%%edi,%%edx,), %%mm6 \n\t" // load Sub(x) for 7th 8 bytes - "movq %%mm5, 40(%%edi,%%edx,) \n\t" // write Raw(x) for 6th 8 bytes - "paddb %%mm5, %%mm6 \n\t" - "movq 56(%%edi,%%edx,), %%mm7 \n\t" // load Sub(x) for 8th 8 bytes - "movq %%mm6, 48(%%edi,%%edx,) \n\t" // write Raw(x) for 7th 8 bytes - "addl $64, %%edx \n\t" - "paddb %%mm6, %%mm7 \n\t" - "cmpl %%ecx, %%edx \n\t" - "movq %%mm7, -8(%%edi,%%edx,) \n\t" // write Raw(x) for 8th 8 bytes - "jb sub_8lp \n\t" - - "cmpl _MMXLength, %%edx \n\t" - "jnb sub_8lt8 \n\t" - - "sub_8lpA: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" - "addl $8, %%edx \n\t" - "paddb %%mm7, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // -8 to offset early addl edx - "movq %%mm0, %%mm7 \n\t" // move calculated Raw(x) data - // to mm1 to be new Raw(x-bpp) - // for next loop - "jb sub_8lpA \n\t" - - "sub_8lt8: \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%ecx", "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - } - break; - - default: // bpp greater than 8 bytes GRR BOGUS - { - __asm__ __volatile__ ( - "movl _dif, %%edx \n\t" -// preload "movl row, %%edi \n\t" - "movl %%edi, %%esi \n\t" // lp = row -// preload "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - - "sub_Alp: \n\t" - "movq (%%edi,%%edx,), %%mm0 \n\t" - "movq (%%esi,%%edx,), %%mm1 \n\t" - "addl $8, %%edx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl _MMXLength, %%edx \n\t" - "movq %%mm0, -8(%%edi,%%edx,) \n\t" // mov does not affect flags; - // -8 to offset addl edx - "jb sub_Alp \n\t" - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1" -#endif - ); - } - break; - - } // end switch (bpp) - - __asm__ __volatile__ ( - "movl _MMXLength, %%edx \n\t" -//pre "movl row, %%edi \n\t" - "cmpl _FullLength, %%edx \n\t" - "jnb sub_end \n\t" - - "movl %%edi, %%esi \n\t" // lp = row -//pre "movl bpp, %%eax \n\t" - "addl %%eax, %%edi \n\t" // rp = row + bpp - "xorl %%eax, %%eax \n\t" - - "sub_lp2: \n\t" - "movb (%%esi,%%edx,), %%al \n\t" - "addb %%al, (%%edi,%%edx,) \n\t" - "incl %%edx \n\t" - "cmpl _FullLength, %%edx \n\t" - "jb sub_lp2 \n\t" - - "sub_end: \n\t" - "EMMS \n\t" // end MMX instructions - - : "=a" (dummy_value_a), // 0 // output regs (dummy) - "=D" (dummy_value_D) // 1 - - : "0" (bpp), // eax // input regs - "1" (row) // edi - - : "%edx", "%esi" // clobber list - ); - -} // end of png_read_filter_row_mmx_sub() - - - - -//===========================================================================// -// // -// P N G _ R E A D _ F I L T E R _ R O W _ M M X _ U P // -// // -//===========================================================================// - -// Optimized code for PNG Up filter decoder - -static void /* PRIVATE */ -png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 len; - int dummy_value_d; // fix 'forbidden register 3 (dx) was spilled' error - int dummy_value_S; - int dummy_value_D; - - len = row_info->rowbytes; // number of bytes to filter - - __asm__ __volatile__ ( -//pre "movl row, %%edi \n\t" - // get # of bytes to alignment - "movl %%edi, %%ecx \n\t" - "xorl %%ebx, %%ebx \n\t" - "addl $0x7, %%ecx \n\t" - "xorl %%eax, %%eax \n\t" - "andl $0xfffffff8, %%ecx \n\t" -//pre "movl prev_row, %%esi \n\t" - "subl %%edi, %%ecx \n\t" - "jz up_go \n\t" - - "up_lp1: \n\t" // fix alignment - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to - "jb up_lp1 \n\t" // offset incl ebx - - "up_go: \n\t" -//pre "movl len, %%edx \n\t" - "movl %%edx, %%ecx \n\t" - "subl %%ebx, %%edx \n\t" // subtract alignment fix - "andl $0x0000003f, %%edx \n\t" // calc bytes over mult of 64 - "subl %%edx, %%ecx \n\t" // drop over bytes from length - - // unrolled loop - use all MMX registers and interleave to reduce - // number of branch instructions (loops) and reduce partial stalls - "up_loop: \n\t" - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "movq 8(%%esi,%%ebx,), %%mm3 \n\t" - "paddb %%mm1, %%mm0 \n\t" - "movq 8(%%edi,%%ebx,), %%mm2 \n\t" - "movq %%mm0, (%%edi,%%ebx,) \n\t" - "paddb %%mm3, %%mm2 \n\t" - "movq 16(%%esi,%%ebx,), %%mm5 \n\t" - "movq %%mm2, 8(%%edi,%%ebx,) \n\t" - "movq 16(%%edi,%%ebx,), %%mm4 \n\t" - "movq 24(%%esi,%%ebx,), %%mm7 \n\t" - "paddb %%mm5, %%mm4 \n\t" - "movq 24(%%edi,%%ebx,), %%mm6 \n\t" - "movq %%mm4, 16(%%edi,%%ebx,) \n\t" - "paddb %%mm7, %%mm6 \n\t" - "movq 32(%%esi,%%ebx,), %%mm1 \n\t" - "movq %%mm6, 24(%%edi,%%ebx,) \n\t" - "movq 32(%%edi,%%ebx,), %%mm0 \n\t" - "movq 40(%%esi,%%ebx,), %%mm3 \n\t" - "paddb %%mm1, %%mm0 \n\t" - "movq 40(%%edi,%%ebx,), %%mm2 \n\t" - "movq %%mm0, 32(%%edi,%%ebx,) \n\t" - "paddb %%mm3, %%mm2 \n\t" - "movq 48(%%esi,%%ebx,), %%mm5 \n\t" - "movq %%mm2, 40(%%edi,%%ebx,) \n\t" - "movq 48(%%edi,%%ebx,), %%mm4 \n\t" - "movq 56(%%esi,%%ebx,), %%mm7 \n\t" - "paddb %%mm5, %%mm4 \n\t" - "movq 56(%%edi,%%ebx,), %%mm6 \n\t" - "movq %%mm4, 48(%%edi,%%ebx,) \n\t" - "addl $64, %%ebx \n\t" - "paddb %%mm7, %%mm6 \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movq %%mm6, -8(%%edi,%%ebx,) \n\t" // (+56)movq does not affect flags; - "jb up_loop \n\t" // -8 to offset addl ebx - - "cmpl $0, %%edx \n\t" // test for bytes over mult of 64 - "jz up_end \n\t" - - "cmpl $8, %%edx \n\t" // test for less than 8 bytes - "jb up_lt8 \n\t" // [added by lcreeve@netins.net] - - "addl %%edx, %%ecx \n\t" - "andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8 - "subl %%edx, %%ecx \n\t" // drop over bytes from length - "jz up_lt8 \n\t" - - "up_lpA: \n\t" // use MMX regs to update 8 bytes sim. - "movq (%%esi,%%ebx,), %%mm1 \n\t" - "movq (%%edi,%%ebx,), %%mm0 \n\t" - "addl $8, %%ebx \n\t" - "paddb %%mm1, %%mm0 \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movq %%mm0, -8(%%edi,%%ebx,) \n\t" // movq does not affect flags; -8 to - "jb up_lpA \n\t" // offset add ebx - "cmpl $0, %%edx \n\t" // test for bytes over mult of 8 - "jz up_end \n\t" - - "up_lt8: \n\t" - "xorl %%eax, %%eax \n\t" - "addl %%edx, %%ecx \n\t" // move over byte count into counter - - "up_lp2: \n\t" // use x86 regs for remaining bytes - "movb (%%edi,%%ebx,), %%al \n\t" - "addb (%%esi,%%ebx,), %%al \n\t" - "incl %%ebx \n\t" - "cmpl %%ecx, %%ebx \n\t" - "movb %%al, -1(%%edi,%%ebx,) \n\t" // mov does not affect flags; -1 to - "jb up_lp2 \n\t" // offset inc ebx - - "up_end: \n\t" - "EMMS \n\t" // conversion of filtered row complete - - : "=d" (dummy_value_d), // 0 // output regs (dummy) - "=S" (dummy_value_S), // 1 - "=D" (dummy_value_D) // 2 - - : "0" (len), // edx // input regs - "1" (prev_row), // esi - "2" (row) // edi - - : "%eax", "%ebx", "%ecx" // clobber list (no input regs!) - -#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ - , "%mm0", "%mm1", "%mm2", "%mm3" - , "%mm4", "%mm5", "%mm6", "%mm7" -#endif - ); - -} // end of png_read_filter_row_mmx_up() - -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - - - - -/*===========================================================================*/ -/* */ -/* P N G _ R E A D _ F I L T E R _ R O W */ -/* */ -/*===========================================================================*/ - -#if defined(PNG_HAVE_ASSEMBLER_READ_FILTER_ROW) - -/* Optimized png_read_filter_row routines */ - -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep - row, png_bytep prev_row, int filter) -{ -#ifdef PNG_DEBUG - char filnm[10]; -#endif - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -/* GRR: these are superseded by png_ptr->asm_flags: */ -#define UseMMX_sub 1 // GRR: converted 20000730 -#define UseMMX_up 1 // GRR: converted 20000729 -#define UseMMX_avg 1 // GRR: converted 20000828 (+ 16-bit bugfix 20000916) -#define UseMMX_paeth 1 // GRR: converted 20000828 - - if (_mmx_supported == 2) { - png_mmx_support(); - } -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - -#ifdef PNG_DEBUG - png_debug(1, "in png_read_filter_row (pnggccrd.c)\n"); - switch (filter) - { - case 0: sprintf(filnm, "none"); - break; - case 1: sprintf(filnm, "sub-%s", "MMX"); - break; - case 2: sprintf(filnm, "up-%s", "MMX"); - break; - case 3: sprintf(filnm, "avg-%s", "MMX"); - break; - case 4: sprintf(filnm, "Paeth-%s", "MMX"); - break; - default: sprintf(filnm, "unknw"); - break; - } - png_debug2(0, "row_number=%5ld, %5s, ", png_ptr->row_number, filnm); - png_debug1(0, "row=0x%08lx, ", (unsigned long)row); - png_debug2(0, "pixdepth=%2d, bytes=%d, ", (int)row_info->pixel_depth, - (int)((row_info->pixel_depth + 7) >> 3)); - png_debug1(0,"rowbytes=%8ld\n", row_info->rowbytes); -#endif /* PNG_DEBUG */ - - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - - case PNG_FILTER_VALUE_SUB: -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported && - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) - { - png_read_filter_row_mmx_sub(row_info, row); - } - else -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - } /* end !UseMMX_sub */ - break; - - case PNG_FILTER_VALUE_UP: -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported && - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) - { - png_read_filter_row_mmx_up(row_info, row, prev_row); - } - else -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; ++i) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - } /* end !UseMMX_up */ - break; - - case PNG_FILTER_VALUE_AVG: -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported && - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) - { - png_read_filter_row_mmx_avg(row_info, row, prev_row); - } - else -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) >> 1)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++ + *lp++) >> 1)) & 0xff); - rp++; - } - } /* end !UseMMX_avg */ - break; - - case PNG_FILTER_VALUE_PAETH: -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported && - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) - { - png_read_filter_row_mmx_paeth(row_info, row, prev_row); - } - else -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) /* use leftover rp,pp */ - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - } /* end !UseMMX_paeth */ - break; - - default: - png_warning(png_ptr, "Ignoring bad row-filter type"); - *row=0; - break; - } -} - -#endif /* PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */ - - -/*===========================================================================*/ -/* */ -/* P N G _ M M X _ S U P P O R T */ -/* */ -/*===========================================================================*/ - -/* GRR NOTES: (1) the following code assumes 386 or better (pushfl/popfl) - * (2) all instructions compile with gcc 2.7.2.3 and later - * (3) the function is moved down here to prevent gcc from - * inlining it in multiple places and then barfing be- - * cause the ".NOT_SUPPORTED" label is multiply defined - * [is there a way to signal that a *single* function should - * not be inlined? is there a way to modify the label for - * each inlined instance, e.g., by appending _1, _2, etc.? - * maybe if don't use leading "." in label name? (nope...sigh)] - */ - -int PNGAPI -png_mmx_support(void) -{ -#if defined(PNG_MMX_CODE_SUPPORTED) - __asm__ __volatile__ ( - "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction - "pushl %%ecx \n\t" // so does ecx... - "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) -// ".byte 0x66 \n\t" // convert 16-bit pushf to 32-bit pushfd -// "pushf \n\t" // 16-bit pushf - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack into eax - "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx - "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) - "pushl %%eax \n\t" // save modified Eflag back to stack -// ".byte 0x66 \n\t" // convert 16-bit popf to 32-bit popfd -// "popf \n\t" // 16-bit popf - "popfl \n\t" // restore modified value to Eflag reg - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack - "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag - "jz .NOT_SUPPORTED \n\t" // if same, CPUID instr. is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero -// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) - "cpuid \n\t" // get the CPU identification info - "cmpl $1, %%eax \n\t" // make sure eax return non-zero value - "jl .NOT_SUPPORTED \n\t" // if eax is zero, MMX is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero and... - "incl %%eax \n\t" // ...increment eax to 1. This pair is - // faster than the instruction "mov eax, 1" - "cpuid \n\t" // get the CPU identification info again - "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) - "cmpl $0, %%edx \n\t" // 0 = MMX not supported - "jz .NOT_SUPPORTED \n\t" // non-zero = yes, MMX IS supported - - "movl $1, %%eax \n\t" // set return value to 1 - "jmp .RETURN \n\t" // DONE: have MMX support - - ".NOT_SUPPORTED: \n\t" // target label for jump instructions - "movl $0, %%eax \n\t" // set return value to 0 - ".RETURN: \n\t" // target label for jump instructions - "movl %%eax, _mmx_supported \n\t" // save in global static variable, too - "popl %%edx \n\t" // restore edx - "popl %%ecx \n\t" // restore ecx - "popl %%ebx \n\t" // restore ebx - -// "ret \n\t" // DONE: no MMX support - // (fall through to standard C "ret") - - : // output list (none) - - : // any variables used on input (none) - - : "%eax" // clobber list -// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually -// , "memory" // if write to a variable gcc thought was in a reg -// , "cc" // "condition codes" (flag bits) - ); -#else - _mmx_supported = 0; -#endif /* PNG_MMX_CODE_SUPPORTED */ - - return _mmx_supported; -} - -#endif /* PNG_USE_PNGGCCRD */ diff --git a/freeimage241/Source/LibPNG/pngget.c b/freeimage241/Source/LibPNG/pngget.c deleted file mode 100644 index 208918f..0000000 --- a/freeimage241/Source/LibPNG/pngget.c +++ /dev/null @@ -1,829 +0,0 @@ - -/* pngget.c - retrieval of values from info struct - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -png_uint_32 PNGAPI -png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->valid & flag); - else - return(0); -} - -png_uint_32 PNGAPI -png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->rowbytes); - else - return(0); -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -png_bytepp PNGAPI -png_get_rows(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->row_pointers); - else - return(0); -} -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* easy access to info, added in libpng-0.99 */ -png_uint_32 PNGAPI -png_get_image_width(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->width; - } - return (0); -} - -png_uint_32 PNGAPI -png_get_image_height(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->height; - } - return (0); -} - -png_byte PNGAPI -png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->bit_depth; - } - return (0); -} - -png_byte PNGAPI -png_get_color_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->color_type; - } - return (0); -} - -png_byte PNGAPI -png_get_filter_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->filter_type; - } - return (0); -} - -png_byte PNGAPI -png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->interlace_type; - } - return (0); -} - -png_byte PNGAPI -png_get_compression_type(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - { - return info_ptr->compression_type; - } - return (0); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) - return (0); - else return (info_ptr->y_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -png_uint_32 PNGAPI -png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || - info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) - return (0); - else return (info_ptr->x_pixels_per_unit); - } -#else - return (0); -#endif - return (0); -} - -#ifdef PNG_FLOATING_POINT_SUPPORTED -float PNGAPI -png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) - { - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); - if (info_ptr->x_pixels_per_unit == 0) - return ((float)0.0); - else - return ((float)((float)info_ptr->y_pixels_per_unit - /(float)info_ptr->x_pixels_per_unit)); - } -#else - return (0.0); -#endif - return ((float)0.0); -} -#endif - -png_int_32 PNGAPI -png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->x_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) - return (0); - else return (info_ptr->y_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->x_offset); - } -#else - return (0); -#endif - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) - return (0); - else return (info_ptr->y_offset); - } -#else - return (0); -#endif - return (0); -} - -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -png_uint_32 PNGAPI -png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) -{ - return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); -} - -float PNGAPI -png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) -{ - return ((float)png_get_x_offset_microns(png_ptr, info_ptr) - *.00003937); -} - -float PNGAPI -png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) -{ - return ((float)png_get_y_offset_microns(png_ptr, info_ptr) - *.00003937); -} - -#if defined(PNG_pHYs_SUPPORTED) -png_uint_32 PNGAPI -png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function\n", "pHYs"); - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - if(*unit_type == 1) - { - if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); - if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); - } - } - } - return (retval); -} -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* png_get_channels really belongs in here, too, but it's been around longer */ - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -png_byte PNGAPI -png_get_channels(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->channels); - else - return (0); -} - -png_bytep PNGAPI -png_get_signature(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->signature); - else - return (NULL); -} - -#if defined(PNG_bKGD_SUPPORTED) -png_uint_32 PNGAPI -png_get_bKGD(png_structp png_ptr, png_infop info_ptr, - png_color_16p *background) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) - && background != NULL) - { - png_debug1(1, "in %s retrieval function\n", "bKGD"); - *background = &(info_ptr->background); - return (PNG_INFO_bKGD); - } - return (0); -} -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM(png_structp png_ptr, png_infop info_ptr, - double *white_x, double *white_y, double *red_x, double *red_y, - double *green_x, double *green_y, double *blue_x, double *blue_y) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - { - png_debug1(1, "in %s retrieval function\n", "cHRM"); - if (white_x != NULL) - *white_x = (double)info_ptr->x_white; - if (white_y != NULL) - *white_y = (double)info_ptr->y_white; - if (red_x != NULL) - *red_x = (double)info_ptr->x_red; - if (red_y != NULL) - *red_y = (double)info_ptr->y_red; - if (green_x != NULL) - *green_x = (double)info_ptr->x_green; - if (green_y != NULL) - *green_y = (double)info_ptr->y_green; - if (blue_x != NULL) - *blue_x = (double)info_ptr->x_blue; - if (blue_y != NULL) - *blue_y = (double)info_ptr->y_blue; - return (PNG_INFO_cHRM); - } - return (0); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, - png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, - png_fixed_point *blue_x, png_fixed_point *blue_y) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - { - png_debug1(1, "in %s retrieval function\n", "cHRM"); - if (white_x != NULL) - *white_x = info_ptr->int_x_white; - if (white_y != NULL) - *white_y = info_ptr->int_y_white; - if (red_x != NULL) - *red_x = info_ptr->int_x_red; - if (red_y != NULL) - *red_y = info_ptr->int_y_red; - if (green_x != NULL) - *green_x = info_ptr->int_x_green; - if (green_y != NULL) - *green_y = info_ptr->int_y_green; - if (blue_x != NULL) - *blue_x = info_ptr->int_x_blue; - if (blue_y != NULL) - *blue_y = info_ptr->int_y_blue; - return (PNG_INFO_cHRM); - } - return (0); -} -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && file_gamma != NULL) - { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *file_gamma = (double)info_ptr->gamma; - return (PNG_INFO_gAMA); - } - return (0); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *int_file_gamma) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && int_file_gamma != NULL) - { - png_debug1(1, "in %s retrieval function\n", "gAMA"); - *int_file_gamma = info_ptr->int_gamma; - return (PNG_INFO_gAMA); - } - return (0); -} -#endif -#endif - -#if defined(PNG_sRGB_SUPPORTED) -png_uint_32 PNGAPI -png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) - && file_srgb_intent != NULL) - { - png_debug1(1, "in %s retrieval function\n", "sRGB"); - *file_srgb_intent = (int)info_ptr->srgb_intent; - return (PNG_INFO_sRGB); - } - return (0); -} -#endif - -#if defined(PNG_iCCP_SUPPORTED) -png_uint_32 PNGAPI -png_get_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) - && name != NULL && profile != NULL && proflen != NULL) - { - png_debug1(1, "in %s retrieval function\n", "iCCP"); - *name = info_ptr->iccp_name; - *profile = info_ptr->iccp_profile; - /* compression_type is a dummy so the API won't have to change - if we introduce multiple compression types later. */ - *proflen = (int)info_ptr->iccp_proflen; - *compression_type = (int)info_ptr->iccp_compression; - return (PNG_INFO_iCCP); - } - return (0); -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sPLT(png_structp png_ptr, png_infop info_ptr, - png_sPLT_tpp spalettes) -{ - if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) - *spalettes = info_ptr->splt_palettes; - return ((png_uint_32)info_ptr->splt_palettes_num); -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -png_uint_32 PNGAPI -png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) - && hist != NULL) - { - png_debug1(1, "in %s retrieval function\n", "hIST"); - *hist = info_ptr->hist; - return (PNG_INFO_hIST); - } - return (0); -} -#endif - -png_uint_32 PNGAPI -png_get_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *width, png_uint_32 *height, int *bit_depth, - int *color_type, int *interlace_type, int *compression_type, - int *filter_type) - -{ - if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && - bit_depth != NULL && color_type != NULL) - { - int pixel_depth, channels; - png_uint_32 rowbytes_per_pixel; - - png_debug1(1, "in %s retrieval function\n", "IHDR"); - *width = info_ptr->width; - *height = info_ptr->height; - *bit_depth = info_ptr->bit_depth; - *color_type = info_ptr->color_type; - if (compression_type != NULL) - *compression_type = info_ptr->compression_type; - if (filter_type != NULL) - *filter_type = info_ptr->filter_type; - if (interlace_type != NULL) - *interlace_type = info_ptr->interlace_type; - - /* check for potential overflow of rowbytes */ - if (*color_type == PNG_COLOR_TYPE_PALETTE) - channels = 1; - else if (*color_type & PNG_COLOR_MASK_COLOR) - channels = 3; - else - channels = 1; - if (*color_type & PNG_COLOR_MASK_ALPHA) - channels++; - pixel_depth = *bit_depth * channels; - rowbytes_per_pixel = (pixel_depth + 7) >> 3; - if ((*width > PNG_MAX_UINT/rowbytes_per_pixel)) - { - png_warning(png_ptr, - "Width too large for libpng to process image data."); - } - return (1); - } - return (0); -} - -#if defined(PNG_oFFs_SUPPORTED) -png_uint_32 PNGAPI -png_get_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) - && offset_x != NULL && offset_y != NULL && unit_type != NULL) - { - png_debug1(1, "in %s retrieval function\n", "oFFs"); - *offset_x = info_ptr->x_offset; - *offset_y = info_ptr->y_offset; - *unit_type = (int)info_ptr->offset_unit_type; - return (PNG_INFO_oFFs); - } - return (0); -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -png_uint_32 PNGAPI -png_get_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, - png_charp *units, png_charpp *params) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) - && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && - nparams != NULL && units != NULL && params != NULL) - { - png_debug1(1, "in %s retrieval function\n", "pCAL"); - *purpose = info_ptr->pcal_purpose; - *X0 = info_ptr->pcal_X0; - *X1 = info_ptr->pcal_X1; - *type = (int)info_ptr->pcal_type; - *nparams = (int)info_ptr->pcal_nparams; - *units = info_ptr->pcal_units; - *params = info_ptr->pcal_params; - return (PNG_INFO_pCAL); - } - return (0); -} -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL(png_structp png_ptr, png_infop info_ptr, - int *unit, double *width, double *height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_pixel_width; - *height = info_ptr->scal_pixel_height; - return (PNG_INFO_sCAL); - } - return(0); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int *unit, png_charpp width, png_charpp height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_s_width; - *height = info_ptr->scal_s_height; - return (PNG_INFO_sCAL); - } - return(0); -} -#endif -#endif -#endif - -#if defined(PNG_pHYs_SUPPORTED) -png_uint_32 PNGAPI -png_get_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs)) - { - png_debug1(1, "in %s retrieval function\n", "pHYs"); - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - } - } - return (retval); -} -#endif - -png_uint_32 PNGAPI -png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, - int *num_palette) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) - && palette != NULL) - { - png_debug1(1, "in %s retrieval function\n", "PLTE"); - *palette = info_ptr->palette; - *num_palette = info_ptr->num_palette; - png_debug1(3, "num_palette = %d\n", *num_palette); - return (PNG_INFO_PLTE); - } - return (0); -} - -#if defined(PNG_sBIT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) - && sig_bit != NULL) - { - png_debug1(1, "in %s retrieval function\n", "sBIT"); - *sig_bit = &(info_ptr->sig_bit); - return (PNG_INFO_sBIT); - } - return (0); -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) -png_uint_32 PNGAPI -png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, - int *num_text) -{ - if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) - { - png_debug1(1, "in %s retrieval function\n", - (png_ptr->chunk_name[0] == '\0' ? "text" - : (png_const_charp)png_ptr->chunk_name)); - if (text_ptr != NULL) - *text_ptr = info_ptr->text; - if (num_text != NULL) - *num_text = info_ptr->num_text; - return ((png_uint_32)info_ptr->num_text); - } - if (num_text != NULL) - *num_text = 0; - return(0); -} -#endif - -#if defined(PNG_tIME_SUPPORTED) -png_uint_32 PNGAPI -png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) -{ - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) - && mod_time != NULL) - { - png_debug1(1, "in %s retrieval function\n", "tIME"); - *mod_time = &(info_ptr->mod_time); - return (PNG_INFO_tIME); - } - return (0); -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -png_uint_32 PNGAPI -png_get_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep *trans, int *num_trans, png_color_16p *trans_values) -{ - png_uint_32 retval = 0; - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - png_debug1(1, "in %s retrieval function\n", "tRNS"); - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (trans != NULL) - { - *trans = info_ptr->trans; - retval |= PNG_INFO_tRNS; - } - if (trans_values != NULL) - *trans_values = &(info_ptr->trans_values); - } - else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ - { - if (trans_values != NULL) - { - *trans_values = &(info_ptr->trans_values); - retval |= PNG_INFO_tRNS; - } - if(trans != NULL) - *trans = NULL; - } - if(num_trans != NULL) - { - *num_trans = info_ptr->num_trans; - retval |= PNG_INFO_tRNS; - } - } - return (retval); -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -png_uint_32 PNGAPI -png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, - png_unknown_chunkpp unknowns) -{ - if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) - *unknowns = info_ptr->unknown_chunks; - return ((png_uint_32)info_ptr->unknown_chunks_num); -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -png_byte PNGAPI -png_get_rgb_to_gray_status (png_structp png_ptr) -{ - return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); -} -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -png_voidp PNGAPI -png_get_user_chunk_ptr(png_structp png_ptr) -{ - return (png_ptr? png_ptr->user_chunk_ptr : NULL); -} -#endif - - -png_uint_32 PNGAPI -png_get_compression_buffer_size(png_structp png_ptr) -{ - return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); -} - - diff --git a/freeimage241/Source/LibPNG/pngmem.c b/freeimage241/Source/LibPNG/pngmem.c deleted file mode 100644 index dd74715..0000000 --- a/freeimage241/Source/LibPNG/pngmem.c +++ /dev/null @@ -1,531 +0,0 @@ - -/* pngmem.c - stub functions for memory allocation - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all memory allocation. Users who - * need special memory handling are expected to supply replacement - * functions for png_malloc() and png_free(), and to use - * png_create_read_struct_2() and png_create_write_struct_2() to - * identify the replacement functions. - */ - -#define PNG_INTERNAL -#include "png.h" - -/* Borland DOS special memory handler */ -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* if you change this, be sure to change the one in png.h also */ - -/* Allocate memory for a png_struct. The malloc and memset can be replaced - by a single call to calloc() if this is thought to improve performance. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, NULL, NULL)); -} - -/* Alternate version of png_create_struct, for use with user-defined malloc. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = sizeof(png_struct); - else - return ((png_voidp)NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - if (mem_ptr != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, size); - } - else - struct_ptr = (*(malloc_fn))(NULL, size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); - } -#endif /* PNG_USER_MEM_SUPPORTED */ - if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL) - { - png_memset(struct_ptr, 0, size); - } - return (struct_ptr); -} - - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL, (png_voidp)NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ - farfree (struct_ptr); - } -} - -/* Allocate memory. For reasonable files, size should never exceed - * 64K. However, zlib may allocate more then 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does - * need to allocate exactly 64K, so whatever you call here must - * have the ability to do that. - * - * Borland seems to have a problem in DOS mode for exactly 64K. - * It gives you a segment with an offset of 8 (perhaps to store its - * memory stuff). zlib doesn't like this at all, so we have to - * detect and deal with it. This code should not be needed in - * Windows or OS/2 modes, and only in 16 bit mode. This code has - * been updated by Alexander Lehmann for version 0.89 to waste less - * memory. - * - * Note that we can't use png_size_t for the "size" declaration, - * since on some systems a png_size_t is a 16-bit quantity, and as a - * result, we would be truncating potentially larger memory requests - * (which should cause a fatal error) and introducing major problems. - */ -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ -#ifndef PNG_USER_MEM_SUPPORTED - png_voidp ret; -#endif - if (png_ptr == NULL || size == 0) - return ((png_voidp)NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(png_ptr->malloc_fn != NULL) - { - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size)); - if (ret == NULL) - png_error(png_ptr, "Out of memory!"); - return (ret); - } - else - return png_malloc_default(png_ptr, size); -} - -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - png_error(png_ptr, "Cannot Allocate > 64K"); -#endif - - if (size == (png_uint_32)65536L) - { - if (png_ptr->offset_table == NULL) - { - /* try to see if we need to do any of this fancy stuff */ - ret = farmalloc(size); - if (ret == NULL || ((png_size_t)ret & 0xffff)) - { - int num_blocks; - png_uint_32 total_size; - png_bytep table; - int i; - png_byte huge * hptr; - - if (ret != NULL) - { - farfree(ret); - ret = NULL; - } - - if(png_ptr->zlib_window_bits > 14) - num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); - else - num_blocks = 1; - if (png_ptr->zlib_mem_level >= 7) - num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); - else - num_blocks++; - - total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; - - table = farmalloc(total_size); - - if (table == NULL) - { - png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ - } - - if ((png_size_t)table & 0xfff0) - { - png_error(png_ptr, "Farmalloc didn't return normalized pointer"); - } - - png_ptr->offset_table = table; - png_ptr->offset_table_ptr = farmalloc(num_blocks * - sizeof (png_bytep)); - - if (png_ptr->offset_table_ptr == NULL) - { - png_error(png_ptr, "Out Of memory."); - } - - hptr = (png_byte huge *)table; - if ((png_size_t)hptr & 0xf) - { - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */ - } - for (i = 0; i < num_blocks; i++) - { - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */ - } - - png_ptr->offset_table_number = num_blocks; - png_ptr->offset_table_count = 0; - png_ptr->offset_table_count_free = 0; - } - } - - if (png_ptr->offset_table_count >= png_ptr->offset_table_number) - png_error(png_ptr, "Out of Memory."); - - ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; - } - else - ret = farmalloc(size); - - if (ret == NULL) - { - png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ - } - - return (ret); -} - -/* free a pointer allocated by png_malloc(). In the default - configuration, png_ptr is not used, but is passed in case it - is needed. If ptr is NULL, return without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); -} - -void PNGAPI -png_free_default(png_structp png_ptr, png_voidp ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - - if (png_ptr->offset_table != NULL) - { - int i; - - for (i = 0; i < png_ptr->offset_table_count; i++) - { - if (ptr == png_ptr->offset_table_ptr[i]) - { - ptr = NULL; - png_ptr->offset_table_count_free++; - break; - } - } - if (png_ptr->offset_table_count_free == png_ptr->offset_table_count) - { - farfree(png_ptr->offset_table); - farfree(png_ptr->offset_table_ptr); - png_ptr->offset_table = NULL; - png_ptr->offset_table_ptr = NULL; - } - } - - if (ptr != NULL) - { - farfree(ptr); - } -} - -#else /* Not the Borland DOS special memory handler */ - -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably.*/ -png_voidp /* PRIVATE */ -png_create_struct(int type) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, NULL, NULL)); -} - -/* Allocate memory for a png_struct or a png_info. The malloc and - memset can be replaced by a single call to calloc() if this is thought - to improve performance noticably.*/ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_size_t size; - png_voidp struct_ptr; - - if (type == PNG_STRUCT_INFO) - size = sizeof(png_info); - else if (type == PNG_STRUCT_PNG) - size = sizeof(png_struct); - else - return ((png_voidp)NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) - { - if (mem_ptr != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, size); - } - else - struct_ptr = (*(malloc_fn))(NULL, size); - if (struct_ptr != NULL) - png_memset(struct_ptr, 0, size); - return (struct_ptr); - } -#endif /* PNG_USER_MEM_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(__FLAT__) - if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL) -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - if ((struct_ptr = (png_voidp)halloc(size,1)) != NULL) -# else - if ((struct_ptr = (png_voidp)malloc(size)) != NULL) -# endif -#endif - { - png_memset(struct_ptr, 0, size); - } - - return (struct_ptr); -} - - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct(png_voidp struct_ptr) -{ -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL, (png_voidp)NULL); -} - -/* Free memory allocated by a png_create_struct() call */ -void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - if (struct_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - (*(free_fn))(png_ptr, struct_ptr); - return; - } -#endif /* PNG_USER_MEM_SUPPORTED */ -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(struct_ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(struct_ptr); -# else - free(struct_ptr); -# endif -#endif - } -} - - -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. */ - -png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; - if (png_ptr == NULL || size == 0) - return ((png_voidp)NULL); - -#ifdef PNG_USER_MEM_SUPPORTED - if(png_ptr->malloc_fn != NULL) - { - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size)); - if (ret == NULL) - png_error(png_ptr, "Out of Memory!"); - return (ret); - } - else - return (png_malloc_default(png_ptr, size)); -} -png_voidp /* PRIVATE */ -png_malloc_default(png_structp png_ptr, png_uint_32 size) -{ - png_voidp ret; -#endif /* PNG_USER_MEM_SUPPORTED */ - -#ifdef PNG_MAX_MALLOC_64K - if (size > (png_uint_32)65536L) - png_error(png_ptr, "Cannot Allocate > 64K"); -#endif - -#if defined(__TURBOC__) && !defined(__FLAT__) - ret = farmalloc(size); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - ret = halloc(size, 1); -# else - ret = malloc((size_t)size); -# endif -#endif - - if (ret == NULL) - png_error(png_ptr, "Out of Memory"); - - return (ret); -} - -/* Free a pointer allocated by png_malloc(). If ptr is NULL, return - without taking any action. */ -void PNGAPI -png_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - { - (*(png_ptr->free_fn))(png_ptr, ptr); - return; - } - else png_free_default(png_ptr, ptr); -} -void /* PRIVATE */ -png_free_default(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#endif /* PNG_USER_MEM_SUPPORTED */ - -#if defined(__TURBOC__) && !defined(__FLAT__) - farfree(ptr); -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - hfree(ptr); -# else - free(ptr); -# endif -#endif -} - -#endif /* Not Borland DOS special memory handler */ - -png_voidp /* PRIVATE */ -png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memcpy_check."); - - return(png_memcpy (s1, s2, size)); -} - -png_voidp /* PRIVATE */ -png_memset_check (png_structp png_ptr, png_voidp s1, int value, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memset_check."); - - return (png_memset (s1, value, size)); - -} - -#ifdef PNG_USER_MEM_SUPPORTED -/* This function is called when the application wants to use another method - * of allocating and freeing memory. - */ -void PNGAPI -png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr - malloc_fn, png_free_ptr free_fn) -{ - png_ptr->mem_ptr = mem_ptr; - png_ptr->malloc_fn = malloc_fn; - png_ptr->free_fn = free_fn; -} - -/* This function returns a pointer to the mem_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_mem_ptr(png_structp png_ptr) -{ - return ((png_voidp)png_ptr->mem_ptr); -} -#endif /* PNG_USER_MEM_SUPPORTED */ diff --git a/freeimage241/Source/LibPNG/pngpread.c b/freeimage241/Source/LibPNG/pngpread.c deleted file mode 100644 index 9b4b77a..0000000 --- a/freeimage241/Source/LibPNG/pngpread.c +++ /dev/null @@ -1,1504 +0,0 @@ - -/* pngpread.c - read a png file in push mode - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - -/* push model modes */ -#define PNG_READ_SIG_MODE 0 -#define PNG_READ_CHUNK_MODE 1 -#define PNG_READ_IDAT_MODE 2 -#define PNG_SKIP_MODE 3 -#define PNG_READ_tEXt_MODE 4 -#define PNG_READ_zTXt_MODE 5 -#define PNG_READ_DONE_MODE 6 -#define PNG_READ_iTXt_MODE 7 -#define PNG_ERROR_MODE 8 - -void PNGAPI -png_process_data(png_structp png_ptr, png_infop info_ptr, - png_bytep buffer, png_size_t buffer_size) -{ - png_push_restore_buffer(png_ptr, buffer, buffer_size); - - while (png_ptr->buffer_size) - { - png_process_some_data(png_ptr, info_ptr); - } -} - -/* What we do with the incoming data depends on what we were previously - * doing before we ran out of data... - */ -void /* PRIVATE */ -png_process_some_data(png_structp png_ptr, png_infop info_ptr) -{ - switch (png_ptr->process_mode) - { - case PNG_READ_SIG_MODE: - { - png_push_read_sig(png_ptr, info_ptr); - break; - } - case PNG_READ_CHUNK_MODE: - { - png_push_read_chunk(png_ptr, info_ptr); - break; - } - case PNG_READ_IDAT_MODE: - { - png_push_read_IDAT(png_ptr); - break; - } -#if defined(PNG_READ_tEXt_SUPPORTED) - case PNG_READ_tEXt_MODE: - { - png_push_read_tEXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - case PNG_READ_zTXt_MODE: - { - png_push_read_zTXt(png_ptr, info_ptr); - break; - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - case PNG_READ_iTXt_MODE: - { - png_push_read_iTXt(png_ptr, info_ptr); - break; - } -#endif - case PNG_SKIP_MODE: - { - png_push_crc_finish(png_ptr); - break; - } - default: - { - png_ptr->buffer_size = 0; - break; - } - } -} - -/* Read any remaining signature bytes from the stream and compare them with - * the correct PNG signature. It is possible that this routine is called - * with bytes already read from the signature, either because they have been - * checked by the calling application, or because of multiple calls to this - * routine. - */ -void /* PRIVATE */ -png_push_read_sig(png_structp png_ptr, png_infop info_ptr) -{ - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; - - if (png_ptr->buffer_size < num_to_check) - { - num_to_check = png_ptr->buffer_size; - } - - png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), - num_to_check); - png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - else - { - if (png_ptr->sig_bytes >= 8) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } - } -} - -void /* PRIVATE */ -png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_USE_LOCAL_ARRAYS */ - /* First we make sure we have enough data for the 4 byte chunk name - * and the 4 byte chunk length before proceeding with decoding the - * chunk data. To fully decode each of these chunks, we also make - * sure we have enough data in the buffer for the 4 byte CRC at the - * end of every chunk (except IDAT, which is handled separately). - */ - if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) - { - png_byte chunk_length[4]; - - if (png_ptr->buffer_size < 8) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_32(chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - } - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); - } - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); - } - else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - { - /* If we reach an IDAT chunk, this means we have read all of the - * header chunks, and we can start reading the image (or if this - * is called after the image has been read - we have an error). - */ - if (png_ptr->mode & PNG_HAVE_IDAT) - { - if (png_ptr->push_length == 0) - return; - - if (png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); - } - - png_ptr->idat_size = png_ptr->push_length; - png_ptr->mode |= PNG_HAVE_IDAT; - png_ptr->process_mode = PNG_READ_IDAT_MODE; - png_push_have_info(png_ptr, info_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; - return; - } - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); - png_ptr->process_mode = PNG_READ_DONE_MODE; - png_push_have_end(png_ptr, info_ptr); - } -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - { - if (png_ptr->push_length + 4 > png_ptr->buffer_size) - { - png_push_save_buffer(png_ptr); - return; - } - - png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - { - png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - { - png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - { - png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif - else - { - png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); - } - - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; -} - -void /* PRIVATE */ -png_push_crc_skip(png_structp png_ptr, png_uint_32 skip) -{ - png_ptr->process_mode = PNG_SKIP_MODE; - png_ptr->skip_length = skip; -} - -void /* PRIVATE */ -png_push_crc_finish(png_structp png_ptr) -{ - if (png_ptr->skip_length && png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (png_ptr->skip_length < (png_uint_32)png_ptr->save_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; - else - save_size = png_ptr->save_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - - png_ptr->skip_length -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (png_ptr->skip_length && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (png_ptr->skip_length < (png_uint_32)png_ptr->current_buffer_size) - save_size = (png_size_t)png_ptr->skip_length; - else - save_size = png_ptr->current_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->skip_length -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - if (!png_ptr->skip_length) - { - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_crc_finish(png_ptr, 0); - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } -} - -void /* PRIVATE */ -png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) -{ - png_bytep ptr; - - ptr = buffer; - if (png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (length < png_ptr->save_buffer_size) - save_size = length; - else - save_size = png_ptr->save_buffer_size; - - png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size); - length -= save_size; - ptr += save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (length && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (length < png_ptr->current_buffer_size) - save_size = length; - else - save_size = png_ptr->current_buffer_size; - - png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size); - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } -} - -void /* PRIVATE */ -png_push_save_buffer(png_structp png_ptr) -{ - if (png_ptr->save_buffer_size) - { - if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) - { - png_size_t i,istop; - png_bytep sp; - png_bytep dp; - - istop = png_ptr->save_buffer_size; - for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; - i < istop; i++, sp++, dp++) - { - *dp = *sp; - } - } - } - if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > - png_ptr->save_buffer_max) - { - png_size_t new_max; - png_bytep old_buffer; - - new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; - old_buffer = png_ptr->save_buffer; - png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, - (png_uint_32)new_max); - png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); - png_free(png_ptr, old_buffer); - png_ptr->save_buffer_max = new_max; - } - if (png_ptr->current_buffer_size) - { - png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, - png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); - png_ptr->save_buffer_size += png_ptr->current_buffer_size; - png_ptr->current_buffer_size = 0; - } - png_ptr->save_buffer_ptr = png_ptr->save_buffer; - png_ptr->buffer_size = 0; -} - -void /* PRIVATE */ -png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, - png_size_t buffer_length) -{ - png_ptr->current_buffer = buffer; - png_ptr->current_buffer_size = buffer_length; - png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size; - png_ptr->current_buffer_ptr = png_ptr->current_buffer; -} - -void /* PRIVATE */ -png_push_read_IDAT(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) - { - png_byte chunk_length[4]; - - if (png_ptr->buffer_size < 8) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_32(chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - - if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - png_error(png_ptr, "Not enough compressed data"); - return; - } - - png_ptr->idat_size = png_ptr->push_length; - } - if (png_ptr->idat_size && png_ptr->save_buffer_size) - { - png_size_t save_size; - - if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } - else - save_size = png_ptr->save_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); - - png_ptr->idat_size -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (png_ptr->idat_size && png_ptr->current_buffer_size) - { - png_size_t save_size; - - if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size) - { - save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) - png_error(png_ptr, "save_size overflowed in pngpread"); - } - else - save_size = png_ptr->current_buffer_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->idat_size -= save_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - if (!png_ptr->idat_size) - { - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_crc_finish(png_ptr, 0); - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; - } -} - -void /* PRIVATE */ -png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, - png_size_t buffer_length) -{ - int ret; - - if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length) - png_error(png_ptr, "Extra compression data"); - - png_ptr->zstream.next_in = buffer; - png_ptr->zstream.avail_in = (uInt)buffer_length; - for(;;) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK) - { - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_in) - png_error(png_ptr, "Extra compressed data"); - if (!(png_ptr->zstream.avail_out)) - { - png_push_process_row(png_ptr); - } - - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - else if (ret == Z_BUF_ERROR) - break; - else - png_error(png_ptr, "Decompression Error"); - } - if (!(png_ptr->zstream.avail_out)) - { - png_push_process_row(png_ptr); - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - png_ptr->zstream.next_out = png_ptr->row_buf; - } - else - break; - } -} - -void /* PRIVATE */ -png_push_process_row(png_structp png_ptr) -{ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - - png_ptr->row_info.rowbytes = ((png_ptr->row_info.width * - (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3); - - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - - if (png_ptr->transformations) - png_do_read_transformations(png_ptr); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); - - switch (png_ptr->pass) - { - case 0: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 0; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */ - } - if (png_ptr->pass == 2) /* pass 1 might be empty */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 4 && png_ptr->height <= 4) - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 6 && png_ptr->height <= 4) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 1: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 1; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 2) /* skip top 4 generated rows */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 2: - { - int i; - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 4) /* pass 3 might be empty */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 3: - { - int i; - for (i = 0; i < 4 && png_ptr->pass == 3; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 4) /* skip top two generated rows */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - break; - } - case 4: - { - int i; - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 6) /* pass 5 might be empty */ - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 5: - { - int i; - for (i = 0; i < 2 && png_ptr->pass == 5; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - if (png_ptr->pass == 6) /* skip top generated row */ - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - break; - } - case 6: - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - if (png_ptr->pass != 6) - break; - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - } - else -#endif - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } -} - -void /* PRIVATE */ -png_read_push_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - - /* Width of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; - */ - - /* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; - */ -#endif - - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, - png_ptr->rowbytes + 1); - do - { - png_ptr->pass++; - if ((png_ptr->pass == 1 && png_ptr->width < 5) || - (png_ptr->pass == 3 && png_ptr->width < 3) || - (png_ptr->pass == 5 && png_ptr->width < 2)) - png_ptr->pass++; - - if (png_ptr->pass >= 7) - break; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->irowbytes = ((png_ptr->iwidth * - png_ptr->pixel_depth + 7) >> 3) + 1; - - if (png_ptr->transformations & PNG_INTERLACE) - break; - - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - - } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); - } -} - -#if defined(PNG_READ_tEXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place tEXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_tEXt_MODE; -} - -void /* PRIVATE */ -png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - png_ptr->current_text = 0; - - for (text = key; *text; text++) - /* empty loop */ ; - - if (text != key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = (char *)NULL; - text_ptr->lang_key = (char *)NULL; -#endif - text_ptr->text = text; - - png_set_text(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - } -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place zTXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - /* We can't handle zTXt chunks > 64K, since we don't have enough space - * to be able to store the uncompressed data. Actually, the threshold - * is probably around 32K, but it isn't as definite as 64K is. - */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "zTXt chunk too large to fit in memory"); - png_push_crc_skip(png_ptr, length); - return; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_zTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp text; - png_charp key; - int ret; - png_size_t text_size, key_size; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - - key = png_ptr->current_text; - png_ptr->current_text = 0; - - for (text = key; *text; text++) - /* empty loop */ ; - - /* zTXt can't have zero text */ - if (text == key + png_ptr->current_text_size) - { - png_free(png_ptr, key); - return; - } - - text++; - - if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ - { - png_free(png_ptr, key); - return; - } - - text++; - - png_ptr->zstream.next_in = (png_bytep )text; - png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - - (text - key)); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - key_size = text - key; - text_size = 0; - text = NULL; - ret = Z_STREAM_END; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END) - { - if (text == NULL) - { - text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + key_size + 1)); - png_memcpy(text + key_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_memcpy(text, key, key_size); - text_size = key_size + png_ptr->zbuf_size - - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc(png_ptr, text_size + - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + 1)); - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = '\0'; - } - if (ret != Z_STREAM_END) - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else - { - break; - } - - if (ret == Z_STREAM_END) - break; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (ret != Z_STREAM_END) - { - png_free(png_ptr, key); - png_free(png_ptr, text); - return; - } - - png_free(png_ptr, key); - key = text; - text += key_size; - - text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = (char *)NULL; - text_ptr->lang_key = (char *)NULL; -#endif - text_ptr->text = text; - - png_set_text(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); - } -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -void /* PRIVATE */ -png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) - { - png_error(png_ptr, "Out of place iTXt"); - /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; - } - -#ifdef PNG_MAX_MALLOC_64K - png_ptr->skip_length = 0; /* This may not be necessary */ - - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ - { - png_warning(png_ptr, "iTXt chunk too large to fit in memory"); - png_ptr->skip_length = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); - png_ptr->current_text[length] = '\0'; - png_ptr->current_text_ptr = png_ptr->current_text; - png_ptr->current_text_size = (png_size_t)length; - png_ptr->current_text_left = (png_size_t)length; - png_ptr->process_mode = PNG_READ_iTXt_MODE; -} - -void /* PRIVATE */ -png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) -{ - - if (png_ptr->buffer_size && png_ptr->current_text_left) - { - png_size_t text_size; - - if (png_ptr->buffer_size < png_ptr->current_text_left) - text_size = png_ptr->buffer_size; - else - text_size = png_ptr->current_text_left; - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); - png_ptr->current_text_left -= text_size; - png_ptr->current_text_ptr += text_size; - } - if (!(png_ptr->current_text_left)) - { - png_textp text_ptr; - png_charp key; - int comp_flag; - png_charp lang; - png_charp lang_key; - png_charp text; - - if (png_ptr->buffer_size < 4) - { - png_push_save_buffer(png_ptr); - return; - } - - png_push_crc_finish(png_ptr); - -#if defined(PNG_MAX_MALLOC_64K) - if (png_ptr->skip_length) - return; -#endif - - key = png_ptr->current_text; - png_ptr->current_text = 0; - - for (lang = key; *lang; lang++) - /* empty loop */ ; - - if (lang != key + png_ptr->current_text_size) - lang++; - - comp_flag = *lang++; - lang++; /* skip comp_type, always zero */ - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - for (text = lang_key; *text; text++) - /* empty loop */ ; - - if (text != key + png_ptr->current_text_size) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); - text_ptr->compression = comp_flag + 2; - text_ptr->key = key; - text_ptr->lang = lang; - text_ptr->lang_key = lang_key; - text_ptr->text = text; - text_ptr->text_length = 0; - text_ptr->itxt_length = png_strlen(text); - - png_set_text(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - } -} -#endif - -/* This function is called when we haven't found a handler for this - * chunk. If there isn't a problem with the chunk itself (ie a bad chunk - * name or a critical chunk), the chunk is (currently) silently ignored. - */ -void /* PRIVATE */ -png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) -{ - png_uint_32 skip=0; - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - - /* to quiet compiler warnings about unused info_ptr */ - if (info_ptr == NULL) - return; - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) - { - png_unknown_chunk chunk; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); - chunk.data = (png_bytep)png_malloc(png_ptr, length); - png_crc_read(png_ptr, chunk.data, length); - chunk.size = length; -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - HANDLE_CHUNK_ALWAYS) - png_chunk_error(png_ptr, "unknown critical chunk"); - } - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - } - else -#endif - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - png_free(png_ptr, chunk.data); - } - else -#endif - skip=length; - png_push_crc_skip(png_ptr, skip); -} - -void /* PRIVATE */ -png_push_have_info(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->info_fn != NULL) - (*(png_ptr->info_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_end(png_structp png_ptr, png_infop info_ptr) -{ - if (png_ptr->end_fn != NULL) - (*(png_ptr->end_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_row(png_structp png_ptr, png_bytep row) -{ - if (png_ptr->row_fn != NULL) - (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, - (int)png_ptr->pass); -} - -void PNGAPI -png_progressive_combine_row (png_structp png_ptr, - png_bytep old_row, png_bytep new_row) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - const int FARDATA png_pass_dsp_mask[7] = - {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; -#endif - if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ - png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); -} - -void PNGAPI -png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn) -{ - png_ptr->info_fn = info_fn; - png_ptr->row_fn = row_fn; - png_ptr->end_fn = end_fn; - - png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); -} - -png_voidp PNGAPI -png_get_progressive_ptr(png_structp png_ptr) -{ - return png_ptr->io_ptr; -} - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - diff --git a/freeimage241/Source/LibPNG/pngread.c b/freeimage241/Source/LibPNG/pngread.c deleted file mode 100644 index ca69699..0000000 --- a/freeimage241/Source/LibPNG/pngread.c +++ /dev/null @@ -1,1425 +0,0 @@ - -/* pngread.c - read a PNG file - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains routines that an application calls directly to - * read a PNG file or stream. - */ - -#define PNG_INTERNAL -#include "png.h" - -/* Create a PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) -{ - -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, NULL, NULL, NULL)); -} - -/* Alternate create PNG structure for reading, and allocate any memory needed. */ -png_structp PNGAPI -png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - - png_structp png_ptr; - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - - int i; - - png_debug(1, "in png_create_read_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr)) == NULL) -#else - if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL) -#endif - { - return (png_structp)NULL; - } - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; - png_destroy_struct(png_ptr); - return (png_structp)NULL; - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif - - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - - /* Libpng 1.0.6 was not binary compatible, due to insertion of the - info_ptr->free_me member. Libpng-1.0.1 and earlier were not - compatible due to insertion of the user transform function. Note - to maintainer: this test can be removed from version 1.2.0 and - beyond because the previous test would have already rejected it. */ - - if (user_png_ver[0] == '1' && user_png_ver[2] == '0' && - (user_png_ver[4] < '2' || user_png_ver[4] == '6') && - user_png_ver[5] == '\0') - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Application must be recompiled; versions <= 1.0.6 were incompatible"); - } - } - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, NULL, NULL); - - return (png_ptr); -} - -/* Initialize PNG structure for reading, and allocate any memory needed. - This interface is deprecated in favour of the png_create_read_struct(), - and it will eventually disappear. */ -#undef png_read_init -void PNGAPI -png_read_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -#undef png_read_init_2 -void PNGAPI -png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=(png_error_ptr)NULL; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=(png_error_ptr)NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for reading is too small."); - } - if(sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=(png_error_ptr)NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by application for reading is too small."); - } - png_read_init_3(&png_ptr, user_png_ver, png_struct_size); -} - -void PNGAPI -png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i=0; - - png_structp png_ptr=*ptr_ptr; - - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=(png_error_ptr)NULL; - png_warning(png_ptr, - "Application uses deprecated png_read_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_read_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); -#endif - - if(sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - png_ptr = *ptr_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, sizeof (png_struct)); - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); -#endif - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; - default: png_error(png_ptr, "Unknown zlib error"); - } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, NULL, NULL); -} - -/* Read the information before the actual image data. This has been - * changed in v0.90 to allow reading a file that already has the magic - * bytes read from the stream. You can tell libpng how many bytes have - * been read from the beginning of the stream (up to the maximum of 8) - * via png_set_sig_bytes(), and we will only check the remaining bytes - * here. The application can then have access to the signature bytes we - * read if it is determined that this isn't a valid PNG file. - */ -void PNGAPI -png_read_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_info\n"); - /* save jump buffer and error functions */ - /* If we haven't checked all of the PNG signature bytes, do so now. */ - if (png_ptr->sig_bytes < 8) - { - png_size_t num_checked = png_ptr->sig_bytes, - num_to_check = 8 - num_checked; - - png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); - png_ptr->sig_bytes = 8; - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - if (num_checked < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; - } - - for(;;) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_GLOBAL_ARRAYS */ - png_byte chunk_length[4]; - png_uint_32 length; - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_32(chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, - length); - - /* This should be a binary subdivision search or a hash for - * matching the chunk name rather than a linear search. - */ - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - png_handle_IEND(png_ptr, info_ptr, length); -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_ptr->mode |= PNG_HAVE_IDAT; - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - break; - } - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_handle_PLTE(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); - - png_ptr->idat_size = length; - png_ptr->mode |= PNG_HAVE_IDAT; - break; - } -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - png_handle_hIST(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - png_handle_tIME(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - else - png_handle_unknown(png_ptr, info_ptr, length); - } -} - -/* optional call to update the users info_ptr structure */ -void PNGAPI -png_read_update_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_update_info\n"); - /* save jump buffer and error functions */ - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - else - png_warning(png_ptr, - "Ignoring extra png_read_update_info() call; row buffer not reallocated"); - png_read_transform_info(png_ptr, info_ptr); -} - -/* Initialize palette, background, etc, after transformations - * are set, but before any reading takes place. This allows - * the user to obtain a gamma-corrected palette, for example. - * If the user doesn't call this, we will do it ourselves. - */ -void PNGAPI -png_start_read_image(png_structp png_ptr) -{ - png_debug(1, "in png_start_read_image\n"); - /* save jump buffer and error functions */ - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); -} - -void PNGAPI -png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; - const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; -#endif - int ret; - png_debug2(1, "in png_read_row (row %lu, pass %d)\n", - png_ptr->row_number, png_ptr->pass); - /* save jump buffer and error functions */ - if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) - png_read_start_row(png_ptr); - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* check for transforms that have been set but were defined out */ -#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); -#endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); -#endif - } - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* if interlaced and we do not need a new row, combine row and return */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - if (dsp_row != NULL && (png_ptr->row_number & 4)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 3: - if ((png_ptr->row_number & 3) || png_ptr->width < 3) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 4: - if ((png_ptr->row_number & 3) != 2) - { - if (dsp_row != NULL && (png_ptr->row_number & 2)) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 5: - if ((png_ptr->row_number & 1) || png_ptr->width < 2) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - png_read_finish_row(png_ptr); - return; - } - break; - case 6: - if (!(png_ptr->row_number & 1)) - { - png_read_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - if (!(png_ptr->mode & PNG_HAVE_IDAT)) - png_error(png_ptr, "Invalid attempt to read row data"); - - png_ptr->zstream.next_out = png_ptr->row_buf; - png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; - do - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_32(chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, - (png_size_t)png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_error(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression error"); - - } while (png_ptr->zstream.avail_out); - - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - png_ptr->row_info.rowbytes = ((png_ptr->row_info.width * - (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3); - - if(png_ptr->row_buf[0]) - png_read_filter_row(png_ptr, &(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->prev_row + 1, - (int)(png_ptr->row_buf[0])); - - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); - } -#endif - - if (png_ptr->transformations) - png_do_read_transformations(png_ptr); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ - if (png_ptr->interlaced && - (png_ptr->transformations & PNG_INTERLACE)) - { - if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ - png_do_read_interlace(png_ptr); - - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); - if (row != NULL) - png_combine_row(png_ptr, row, - png_pass_mask[png_ptr->pass]); - } - else -#endif - { - if (row != NULL) - png_combine_row(png_ptr, row, 0xff); - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 0xff); - } - png_read_finish_row(png_ptr); - - if (png_ptr->read_row_fn != NULL) - (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} - -/* Read one or more rows of image data. If the image is interlaced, - * and png_set_interlace_handling() has been called, the rows need to - * contain the contents of the rows from the previous pass. If the - * image has alpha or transparency, and png_handle_alpha()[*] has been - * called, the rows contents must be initialized to the contents of the - * screen. - * - * "row" holds the actual image, and pixels are placed in it - * as they arrive. If the image is displayed after each pass, it will - * appear to "sparkle" in. "display_row" can be used to display a - * "chunky" progressive image, with finer detail added as it becomes - * available. If you do not want this "chunky" display, you may pass - * NULL for display_row. If you do not want the sparkle display, and - * you have not called png_handle_alpha(), you may pass NULL for rows. - * If you have called png_handle_alpha(), and the image has either an - * alpha channel or a transparency chunk, you must provide a buffer for - * rows. In this case, you do not have to provide a display_row buffer - * also, but you may. If the image is not interlaced, or if you have - * not called png_set_interlace_handling(), the display_row buffer will - * be ignored, so pass NULL to it. - * - * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.12 - */ - -void PNGAPI -png_read_rows(png_structp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows) -{ - png_uint_32 i; - png_bytepp rp; - png_bytepp dp; - - png_debug(1, "in png_read_rows\n"); - /* save jump buffer and error functions */ - rp = row; - dp = display_row; - if (rp != NULL && dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp++; - png_bytep dptr = *dp++; - - png_read_row(png_ptr, rptr, dptr); - } - else if(rp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp; - png_read_row(png_ptr, rptr, NULL); - rp++; - } - else if(dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep dptr = *dp; - png_read_row(png_ptr, NULL, dptr); - dp++; - } -} - -/* Read the entire image. If the image has an alpha channel or a tRNS - * chunk, and you have called png_handle_alpha()[*], you will need to - * initialize the image to the current image that PNG will be overlaying. - * We set the num_rows again here, in case it was incorrectly set in - * png_read_start_row() by a call to png_read_update_info() or - * png_start_read_image() if png_set_interlace_handling() wasn't called - * prior to either of these functions like it should have been. You can - * only call this function once. If you desire to have an image for - * each pass of a interlaced image, use png_read_rows() instead. - * - * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.12 - */ -void PNGAPI -png_read_image(png_structp png_ptr, png_bytepp image) -{ - png_uint_32 i,image_height; - int pass, j; - png_bytepp rp; - - png_debug(1, "in png_read_image\n"); - /* save jump buffer and error functions */ - -#ifdef PNG_READ_INTERLACING_SUPPORTED - pass = png_set_interlace_handling(png_ptr); -#else - if (png_ptr->interlaced) - png_error(png_ptr, - "Cannot read interlaced image -- interlace handler disabled."); - pass = 1; -#endif - - - image_height=png_ptr->height; - png_ptr->num_rows = image_height; /* Make sure this is set correctly */ - - for (j = 0; j < pass; j++) - { - rp = image; - for (i = 0; i < image_height; i++) - { - png_read_row(png_ptr, *rp, NULL); - rp++; - } - } -} - -/* Read the end of the PNG file. Will not read past the end of the - * file, will verify the end is accurate, and will read any comments - * or time information at the end of the file, if info is not NULL. - */ -void PNGAPI -png_read_end(png_structp png_ptr, png_infop info_ptr) -{ - png_byte chunk_length[4]; - png_uint_32 length; - - png_debug(1, "in png_read_end\n"); - /* save jump buffer and error functions */ - png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ - - do - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; - PNG_IDAT; - PNG_IEND; - PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_bKGD; -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_cHRM; -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_gAMA; -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_hIST; -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_iCCP; -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_iTXt; -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_oFFs; -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_pCAL; -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_pHYs; -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_sBIT; -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_sCAL; -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_sPLT; -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_sRGB; -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_tEXt; -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_tIME; -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_tRNS; -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_zTXt; -#endif -#endif /* PNG_GLOBAL_ARRAYS */ - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_32(chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) - png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) - png_handle_IEND(png_ptr, info_ptr, length); -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) - { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); - } - else - png_ptr->mode |= PNG_AFTER_IDAT; - png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_ptr->mode |= PNG_HAVE_PLTE; - } -#endif - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - { - /* Zero length IDATs are legal after the last IDAT has been - * read, but not after other chunks have been read. - */ - if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); - png_crc_finish(png_ptr, length); - } - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) - png_handle_PLTE(png_ptr, info_ptr, length); -#if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) - png_handle_hIST(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) - png_handle_tIME(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - else - png_handle_unknown(png_ptr, info_ptr, length); - } while (!(png_ptr->mode & PNG_HAVE_IEND)); -} - -/* free all memory used by the read */ -void PNGAPI -png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, - png_infopp end_info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL, end_info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn = NULL; - png_voidp mem_ptr = NULL; -#endif - - png_debug(1, "in png_destroy_read_struct\n"); - /* save jump buffer and error functions */ - if (png_ptr_ptr != NULL) - png_ptr = *png_ptr_ptr; - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (end_info_ptr_ptr != NULL) - end_info_ptr = *end_info_ptr_ptr; - -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; - mem_ptr = png_ptr->mem_ptr; -#endif - - png_read_destroy(png_ptr, info_ptr, end_info_ptr); - - if (info_ptr != NULL) - { -#if defined(PNG_TEXT_SUPPORTED) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = (png_infop)NULL; - } - - if (end_info_ptr != NULL) - { -#if defined(PNG_READ_TEXT_SUPPORTED) - png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); -#endif -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)end_info_ptr); -#endif - *end_info_ptr_ptr = (png_infop)NULL; - } - - if (png_ptr != NULL) - { -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = (png_structp)NULL; - } -} - -/* free all memory used by the read (old method) */ -void /* PRIVATE */ -png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_read_destroy\n"); - /* save jump buffer and error functions */ - if (info_ptr != NULL) - png_info_destroy(png_ptr, info_ptr); - - if (end_info_ptr != NULL) - png_info_destroy(png_ptr, end_info_ptr); - - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->row_buf); - png_free(png_ptr, png_ptr->prev_row); -#if defined(PNG_READ_DITHER_SUPPORTED) - png_free(png_ptr, png_ptr->palette_lookup); - png_free(png_ptr, png_ptr->dither_index); -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_table); -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_from_1); - png_free(png_ptr, png_ptr->gamma_to_1); -#endif -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->free_me &= ~PNG_FREE_PLTE; -#else - if (png_ptr->flags & PNG_FLAG_FREE_PLTE) - png_zfree(png_ptr, png_ptr->palette); - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; -#endif -#if defined(PNG_tRNS_SUPPORTED) || \ - defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->free_me &= ~PNG_FREE_TRNS; -#else - if (png_ptr->flags & PNG_FLAG_FREE_TRNS) - png_free(png_ptr, png_ptr->trans); - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; -#endif -#endif -#if defined(PNG_READ_hIST_SUPPORTED) -#ifdef PNG_FREE_ME_SUPPORTED - if (png_ptr->free_me & PNG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->free_me &= ~PNG_FREE_HIST; -#else - if (png_ptr->flags & PNG_FLAG_FREE_HIST) - png_free(png_ptr, png_ptr->hist); - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; -#endif -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->gamma_16_table != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_table[i]); - } - png_free(png_ptr, png_ptr->gamma_16_table); - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_from_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_from_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_from_1); - } - if (png_ptr->gamma_16_to_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_to_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_to_1); - } -#endif -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - - inflateEnd(&png_ptr->zstream); -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_free(png_ptr, png_ptr->save_buffer); -#endif - - /* Save the important info out of the png_struct, in case it is - * being used again. - */ -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); -#endif - - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - - png_memset(png_ptr, 0, sizeof (png_struct)); - - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); -#endif - -} - -void PNGAPI -png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) -{ - png_ptr->read_row_fn = read_row_fn; -} - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_read_png(png_structp png_ptr, png_infop info_ptr, - int transforms, - voidp params) -{ - int row; - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - - /* The call to png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). - */ - png_read_info(png_ptr, info_ptr); - - /* -------------- image transformations start here ------------------- */ - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - /* tell libpng to strip 16 bit/color files down to 8 bits/color */ - if (transforms & PNG_TRANSFORM_STRIP_16) - png_set_strip_16(png_ptr); -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - /* Strip alpha bytes from the input data without combining with the - * background (not recommended). - */ - if (transforms & PNG_TRANSFORM_STRIP_ALPHA) - png_set_strip_alpha(png_ptr); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) - /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). */ - if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - /* Expand paletted colors into true RGB triplets - * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel - * Expand paletted or RGB images with transparency to full alpha - * channels so the data will be available as RGBA quartets. - */ - if (transforms & PNG_TRANSFORM_EXPAND) - if ((png_ptr->bit_depth < 8) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || - (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) - png_set_expand(png_ptr); -#endif - - /* We don't handle background color or gamma transformation or dithering. */ - -#if defined(PNG_READ_INVERT_SUPPORTED) - /* invert monochrome files to have 0 as white and 1 as black */ - if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if ((transforms & PNG_TRANSFORM_SHIFT) - && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) - { - png_color_8p sig_bit; - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); - } -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) - /* flip the RGB pixels to BGR (or RGBA to BGRA) */ - if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ - if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) - /* swap bytes of 16 bit files to least significant byte first */ - if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - - /* We don't handle adding filler bytes */ - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. REQUIRED if you are expecting libpng to - * update the palette for you (i.e., you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* -------------- image transformations end here ------------------- */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); -#endif - if(info_ptr->row_pointers == NULL) - { - info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, - info_ptr->height * sizeof(png_bytep)); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_ROWS; -#endif - for (row = 0; row < (int)info_ptr->height; row++) - { - info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, - png_get_rowbytes(png_ptr, info_ptr)); - } - } - - png_read_image(png_ptr, info_ptr->row_pointers); - info_ptr->valid |= PNG_INFO_IDAT; - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end(png_ptr, info_ptr); - - if(transforms == 0 || params == NULL) - /* quiet compiler warnings */ return; - -} -#endif diff --git a/freeimage241/Source/LibPNG/pngrio.c b/freeimage241/Source/LibPNG/pngrio.c deleted file mode 100644 index 707a139..0000000 --- a/freeimage241/Source/LibPNG/pngrio.c +++ /dev/null @@ -1,162 +0,0 @@ - -/* pngrio.c - functions for data input - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all input. Users who need - * special handling are expected to write a function that has the same - * arguments as this and performs a similar function, but that possibly - * has a different input method. Note that you shouldn't change this - * function, but rather write a replacement function and then make - * libpng use it at run time with png_set_read_fn(...). - */ - -#define PNG_INTERNAL -#include "png.h" - -/* Read the data from whatever input you are using. The default routine - reads from a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered reads. This should never be asked - to read more then 64K on a 16 bit machine. */ -void /* PRIVATE */ -png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_debug1(4,"reading %d bytes\n", (int)length); - if (png_ptr->read_data_fn != NULL) - (*(png_ptr->read_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL read function"); -} - -#if !defined(PNG_NO_STDIO) -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -static void /* PRIVATE */ -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = (png_size_t)fread(data, (png_size_t)1, length, - (png_FILE_p)png_ptr->io_ptr); -#endif - - if (check != length) - png_error(png_ptr, "Read Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void /* PRIVATE */ -png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fread(n_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) - err = 0; -#else - err = fread(buf, (png_size_t)1, read, io_ptr); -#endif - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if ((png_uint_32)check != (png_uint_32)length) - png_error(png_ptr, "read Error"); -} -#endif -#endif - -/* This function allows the application to supply a new input function - for libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png input data structure - io_ptr - pointer to user supplied structure containing info about - the input functions. May be NULL. - read_data_fn - pointer to a new input function that takes as its - arguments a pointer to a png_struct, a pointer to - a location where input data can be stored, and a 32-bit - unsigned int that is the number of bytes to be read. - To exit and output any fatal error messages the new write - function should call png_error(png_ptr, "Error msg"). */ -void PNGAPI -png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn) -{ - png_ptr->io_ptr = io_ptr; - -#if !defined(PNG_NO_STDIO) - if (read_data_fn != NULL) - png_ptr->read_data_fn = read_data_fn; - else - png_ptr->read_data_fn = png_default_read_data; -#else - png_ptr->read_data_fn = read_data_fn; -#endif - - /* It is an error to write to a read device */ - if (png_ptr->write_data_fn != NULL) - { - png_ptr->write_data_fn = NULL; - png_warning(png_ptr, - "It's an error to set both read_data_fn and write_data_fn in the "); - png_warning(png_ptr, - "same structure. Resetting write_data_fn to NULL."); - } - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_ptr->output_flush_fn = NULL; -#endif -} - diff --git a/freeimage241/Source/LibPNG/pngrtran.c b/freeimage241/Source/LibPNG/pngrtran.c deleted file mode 100644 index ef070c8..0000000 --- a/freeimage241/Source/LibPNG/pngrtran.c +++ /dev/null @@ -1,4115 +0,0 @@ - -/* pngrtran.c - transforms the data in a row for PNG readers - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains functions optionally called by an application - * in order to tell libpng how to handle data when reading a PNG. - * Transformations that are used in both reading and writing are - * in pngtrans.c. - */ - -#define PNG_INTERNAL -#include "png.h" - -/* Set the action on getting a CRC error for an ancillary or critical chunk. */ -void PNGAPI -png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) -{ - png_debug(1, "in png_set_crc_action\n"); - /* Tell libpng how we react to CRC errors in critical chunks */ - switch (crit_action) - { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ - break; - case PNG_CRC_WARN_USE: /* warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; - break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | - PNG_FLAG_CRC_CRITICAL_IGNORE; - break; - case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ - png_warning(png_ptr, "Can't discard critical data on CRC error."); - case PNG_CRC_ERROR_QUIT: /* error/quit */ - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - break; - } - - switch (ancil_action) - { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ - break; - case PNG_CRC_WARN_USE: /* warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; - break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | - PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - case PNG_CRC_ERROR_QUIT: /* error/quit */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - case PNG_CRC_WARN_DISCARD: /* warn/discard data */ - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - break; - } -} - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -/* handle alpha and tRNS via a background color */ -void PNGAPI -png_set_background(png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma) -{ - png_debug(1, "in png_set_background\n"); - if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) - { - png_warning(png_ptr, "Application must supply a known background gamma"); - return; - } - - png_ptr->transformations |= PNG_BACKGROUND; - png_memcpy(&(png_ptr->background), background_color, sizeof(png_color_16)); - png_ptr->background_gamma = (float)background_gamma; - png_ptr->background_gamma_type = (png_byte)(background_gamma_code); - png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); - - /* Note: if need_expand is set and color_type is either RGB or RGB_ALPHA - * (in which case need_expand is superfluous anyway), the background color - * might actually be gray yet not be flagged as such. This is not a problem - * for the current code, which uses PNG_BACKGROUND_IS_GRAY only to - * decide when to do the png_do_gray_to_rgb() transformation. - */ - if ((need_expand && !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) || - (!need_expand && background_color->red == background_color->green && - background_color->red == background_color->blue)) - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; -} -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip 16 bit depth files to 8 bit depth */ -void PNGAPI -png_set_strip_16(png_structp png_ptr) -{ - png_debug(1, "in png_set_strip_16\n"); - png_ptr->transformations |= PNG_16_TO_8; -} -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -void PNGAPI -png_set_strip_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_strip_alpha\n"); - png_ptr->transformations |= PNG_STRIP_ALPHA; -} -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Dither file to 8 bit. Supply a palette, the current number - * of elements in the palette, the maximum number of elements - * allowed, and a histogram if possible. If the current number - * of colors is greater then the maximum number, the palette will be - * modified to fit in the maximum number. "full_dither" indicates - * whether we need a dithering cube set up for RGB images, or if we - * simply are reducing the number of colors in a paletted image. - */ - -typedef struct png_dsort_struct -{ - struct png_dsort_struct FAR * next; - png_byte left; - png_byte right; -} png_dsort; -typedef png_dsort FAR * png_dsortp; -typedef png_dsort FAR * FAR * png_dsortpp; - -void PNGAPI -png_set_dither(png_structp png_ptr, png_colorp palette, - int num_palette, int maximum_colors, png_uint_16p histogram, - int full_dither) -{ - png_debug(1, "in png_set_dither\n"); - png_ptr->transformations |= PNG_DITHER; - - if (!full_dither) - { - int i; - - png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * sizeof (png_byte))); - for (i = 0; i < num_palette; i++) - png_ptr->dither_index[i] = (png_byte)i; - } - - if (num_palette > maximum_colors) - { - if (histogram != NULL) - { - /* This is easy enough, just throw out the least used colors. - Perhaps not the best solution, but good enough. */ - - int i; - png_bytep sort; - - /* initialize an array to sort colors */ - sort = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette - * sizeof (png_byte))); - - /* initialize the sort array */ - for (i = 0; i < num_palette; i++) - sort[i] = (png_byte)i; - - /* Find the least used palette entries by starting a - bubble sort, and running it until we have sorted - out enough colors. Note that we don't care about - sorting all the colors, just finding which are - least used. */ - - for (i = num_palette - 1; i >= maximum_colors; i--) - { - int done; /* to stop early if the list is pre-sorted */ - int j; - - done = 1; - for (j = 0; j < i; j++) - { - if (histogram[sort[j]] < histogram[sort[j + 1]]) - { - png_byte t; - - t = sort[j]; - sort[j] = sort[j + 1]; - sort[j + 1] = t; - done = 0; - } - } - if (done) - break; - } - - /* swap the palette around, and set up a table, if necessary */ - if (full_dither) - { - int j = num_palette; - - /* put all the useful colors within the max, but don't - move the others */ - for (i = 0; i < maximum_colors; i++) - { - if ((int)sort[i] >= maximum_colors) - { - do - j--; - while ((int)sort[j] >= maximum_colors); - palette[i] = palette[j]; - } - } - } - else - { - int j = num_palette; - - /* move all the used colors inside the max limit, and - develop a translation table */ - for (i = 0; i < maximum_colors; i++) - { - /* only move the colors we need to */ - if ((int)sort[i] >= maximum_colors) - { - png_color tmp_color; - - do - j--; - while ((int)sort[j] >= maximum_colors); - - tmp_color = palette[j]; - palette[j] = palette[i]; - palette[i] = tmp_color; - /* indicate where the color went */ - png_ptr->dither_index[j] = (png_byte)i; - png_ptr->dither_index[i] = (png_byte)j; - } - } - - /* find closest color for those colors we are not using */ - for (i = 0; i < num_palette; i++) - { - if ((int)png_ptr->dither_index[i] >= maximum_colors) - { - int min_d, k, min_k, d_index; - - /* find the closest color to one we threw out */ - d_index = png_ptr->dither_index[i]; - min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); - for (k = 1, min_k = 0; k < maximum_colors; k++) - { - int d; - - d = PNG_COLOR_DIST(palette[d_index], palette[k]); - - if (d < min_d) - { - min_d = d; - min_k = k; - } - } - /* point to closest color */ - png_ptr->dither_index[i] = (png_byte)min_k; - } - } - } - png_free(png_ptr, sort); - } - else - { - /* This is much harder to do simply (and quickly). Perhaps - we need to go through a median cut routine, but those - don't always behave themselves with only a few colors - as input. So we will just find the closest two colors, - and throw out one of them (chosen somewhat randomly). - [We don't understand this at all, so if someone wants to - work on improving it, be our guest - AED, GRP] - */ - int i; - int max_d; - int num_new_palette; - png_dsortpp hash; - png_bytep index_to_palette; - /* where the original index currently is in the palette */ - png_bytep palette_to_index; - /* which original index points to this palette color */ - - /* initialize palette index arrays */ - index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * sizeof (png_byte))); - palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * sizeof (png_byte))); - - /* initialize the sort array */ - for (i = 0; i < num_palette; i++) - { - index_to_palette[i] = (png_byte)i; - palette_to_index[i] = (png_byte)i; - } - - hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * - sizeof (png_dsortp))); - for (i = 0; i < 769; i++) - hash[i] = NULL; -/* png_memset(hash, 0, 769 * sizeof (png_dsortp)); */ - - num_new_palette = num_palette; - - /* initial wild guess at how far apart the farthest pixel - pair we will be eliminating will be. Larger - numbers mean more areas will be allocated, Smaller - numbers run the risk of not saving enough data, and - having to do this all over again. - - I have not done extensive checking on this number. - */ - max_d = 96; - - while (num_new_palette > maximum_colors) - { - for (i = 0; i < num_new_palette - 1; i++) - { - int j; - - for (j = i + 1; j < num_new_palette; j++) - { - int d; - - d = PNG_COLOR_DIST(palette[i], palette[j]); - - if (d <= max_d) - { - png_dsortp t; - - t = (png_dsortp)png_malloc(png_ptr, (png_uint_32)(sizeof - (png_dsort))); - t->next = hash[d]; - t->left = (png_byte)i; - t->right = (png_byte)j; - hash[d] = t; - } - } - } - - for (i = 0; i <= max_d; i++) - { - if (hash[i] != NULL) - { - png_dsortp p; - - for (p = hash[i]; p; p = p->next) - { - if ((int)index_to_palette[p->left] < num_new_palette && - (int)index_to_palette[p->right] < num_new_palette) - { - int j, next_j; - - if (num_new_palette & 0x01) - { - j = p->left; - next_j = p->right; - } - else - { - j = p->right; - next_j = p->left; - } - - num_new_palette--; - palette[index_to_palette[j]] = palette[num_new_palette]; - if (!full_dither) - { - int k; - - for (k = 0; k < num_palette; k++) - { - if (png_ptr->dither_index[k] == - index_to_palette[j]) - png_ptr->dither_index[k] = - index_to_palette[next_j]; - if ((int)png_ptr->dither_index[k] == - num_new_palette) - png_ptr->dither_index[k] = - index_to_palette[j]; - } - } - - index_to_palette[palette_to_index[num_new_palette]] = - index_to_palette[j]; - palette_to_index[index_to_palette[j]] = - palette_to_index[num_new_palette]; - - index_to_palette[j] = (png_byte)num_new_palette; - palette_to_index[num_new_palette] = (png_byte)j; - } - if (num_new_palette <= maximum_colors) - break; - } - if (num_new_palette <= maximum_colors) - break; - } - } - - for (i = 0; i < 769; i++) - { - if (hash[i] != NULL) - { - png_dsortp p = hash[i]; - while (p) - { - png_dsortp t; - - t = p->next; - png_free(png_ptr, p); - p = t; - } - } - hash[i] = 0; - } - max_d += 96; - } - png_free(png_ptr, hash); - png_free(png_ptr, palette_to_index); - png_free(png_ptr, index_to_palette); - } - num_palette = maximum_colors; - } - if (png_ptr->palette == NULL) - { - png_ptr->palette = palette; - } - png_ptr->num_palette = (png_uint_16)num_palette; - - if (full_dither) - { - int i; - png_bytep distance; - int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS + - PNG_DITHER_BLUE_BITS; - int num_red = (1 << PNG_DITHER_RED_BITS); - int num_green = (1 << PNG_DITHER_GREEN_BITS); - int num_blue = (1 << PNG_DITHER_BLUE_BITS); - png_size_t num_entries = ((png_size_t)1 << total_bits); - - png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, - (png_uint_32)(num_entries * sizeof (png_byte))); - - png_memset(png_ptr->palette_lookup, 0, num_entries * sizeof (png_byte)); - - distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * - sizeof(png_byte))); - - png_memset(distance, 0xff, num_entries * sizeof(png_byte)); - - for (i = 0; i < num_palette; i++) - { - int ir, ig, ib; - int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS)); - int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS)); - int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS)); - - for (ir = 0; ir < num_red; ir++) - { - int dr = abs(ir - r); - int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS)); - - for (ig = 0; ig < num_green; ig++) - { - int dg = abs(ig - g); - int dt = dr + dg; - int dm = ((dr > dg) ? dr : dg); - int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS); - - for (ib = 0; ib < num_blue; ib++) - { - int d_index = index_g | ib; - int db = abs(ib - b); - int dmax = ((dm > db) ? dm : db); - int d = dmax + dt + db; - - if (d < (int)distance[d_index]) - { - distance[d_index] = (png_byte)d; - png_ptr->palette_lookup[d_index] = (png_byte)i; - } - } - } - } - } - - png_free(png_ptr, distance); - } -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) -/* Transform the image from the file_gamma to the screen_gamma. We - * only do transformations on images where the file_gamma and screen_gamma - * are not close reciprocals, otherwise it slows things down slightly, and - * also needlessly introduces small errors. - */ -void PNGAPI -png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) -{ - png_debug(1, "in png_set_gamma\n"); - if (fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) - png_ptr->transformations |= PNG_GAMMA; - png_ptr->gamma = (float)file_gamma; - png_ptr->screen_gamma = (float)scrn_gamma; -} -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand paletted images to RGB, expand grayscale images of - * less than 8-bit depth to 8-bit depth, and expand tRNS chunks - * to alpha channels. - */ -void PNGAPI -png_set_expand(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= PNG_EXPAND; -} - -/* GRR 19990627: the following three functions currently are identical - * to png_set_expand(). However, it is entirely reasonable that someone - * might wish to expand an indexed image to RGB but *not* expand a single, - * fully transparent palette entry to a full alpha channel--perhaps instead - * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace - * the transparent color with a particular RGB value, or drop tRNS entirely. - * IOW, a future version of the library may make the transformations flag - * a bit more fine-grained, with separate bits for each of these three - * functions. - * - * More to the point, these functions make it obvious what libpng will be - * doing, whereas "expand" can (and does) mean any number of things. - */ - -/* Expand paletted images to RGB. */ -void PNGAPI -png_set_palette_to_rgb(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= PNG_EXPAND; -} - -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -void PNGAPI -png_set_gray_1_2_4_to_8(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= PNG_EXPAND; -} - -/* Expand tRNS chunks to alpha channels. */ -void PNGAPI -png_set_tRNS_to_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_expand\n"); - png_ptr->transformations |= PNG_EXPAND; -} -#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -void PNGAPI -png_set_gray_to_rgb(png_structp png_ptr) -{ - png_debug(1, "in png_set_gray_to_rgb\n"); - png_ptr->transformations |= PNG_GRAY_TO_RGB; -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) -/* Convert a RGB image to a grayscale of the same width. This allows us, - * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. - */ - -void PNGAPI -png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, - double green) -{ - int red_fixed = (int)((float)red*100000.0 + 0.5); - int green_fixed = (int)((float)green*100000.0 + 0.5); - png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); -} -#endif - -void PNGAPI -png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, - png_fixed_point red, png_fixed_point green) -{ - png_debug(1, "in png_set_rgb_to_gray\n"); - switch(error_action) - { - case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; - break; - case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; - break; - case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; - } - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#if defined(PNG_READ_EXPAND_SUPPORTED) - png_ptr->transformations |= PNG_EXPAND; -#else - { - png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); - png_ptr->transformations &= ~PNG_RGB_TO_GRAY; - } -#endif - { - png_uint_16 red_int, green_int; - if(red < 0 || green < 0) - { - red_int = 6968; /* .212671 * 32768 + .5 */ - green_int = 23434; /* .715160 * 32768 + .5 */ - } - else if(red + green < 100000L) - { - red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); - green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); - } - else - { - png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); - red_int = 6968; - green_int = 23434; - } - png_ptr->rgb_to_gray_red_coeff = red_int; - png_ptr->rgb_to_gray_green_coeff = green_int; - png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); - } -} -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -void PNGAPI -png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - read_user_transform_fn) -{ - png_debug(1, "in png_set_read_user_transform_fn\n"); -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->read_user_transform_fn = read_user_transform_fn; -#endif -#ifdef PNG_LEGACY_SUPPORTED - if(read_user_transform_fn) - png_warning(png_ptr, - "This version of libpng does not support user transforms"); -#endif -} -#endif - -/* Initialize everything needed for the read. This includes modifying - * the palette. - */ -void /* PRIVATE */ -png_init_read_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_init_read_transformations\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if(png_ptr != NULL) -#endif - { -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ - || defined(PNG_READ_GAMMA_SUPPORTED) - int color_type = png_ptr->color_type; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && - (png_ptr->transformations & PNG_EXPAND)) - { - if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ - { - /* expand background chunk. */ - switch (png_ptr->bit_depth) - { - case 1: - png_ptr->background.gray *= (png_uint_16)0xff; - png_ptr->background.red = png_ptr->background.green = - png_ptr->background.blue = png_ptr->background.gray; - break; - case 2: - png_ptr->background.gray *= (png_uint_16)0x55; - png_ptr->background.red = png_ptr->background.green = - png_ptr->background.blue = png_ptr->background.gray; - break; - case 4: - png_ptr->background.gray *= (png_uint_16)0x11; - png_ptr->background.red = png_ptr->background.green = - png_ptr->background.blue = png_ptr->background.gray; - break; - case 8: - case 16: - png_ptr->background.red = png_ptr->background.green = - png_ptr->background.blue = png_ptr->background.gray; - break; - } - } - else if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_ptr->background.red = - png_ptr->palette[png_ptr->background.index].red; - png_ptr->background.green = - png_ptr->palette[png_ptr->background.index].green; - png_ptr->background.blue = - png_ptr->palette[png_ptr->background.index].blue; - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - { -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (!(png_ptr->transformations & PNG_EXPAND)) -#endif - { - /* invert the alpha channel (in tRNS) unless the pixels are - going to be expanded, in which case leave it for later */ - int i,istop; - istop=(int)png_ptr->num_trans; - for (i=0; itrans[i] = (png_byte)(255 - png_ptr->trans[i]); - } - } -#endif - - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - png_ptr->background_1 = png_ptr->background; -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - if (png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) - { - png_build_gamma_table(png_ptr); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_color back, back_1; - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g, gs; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; - break; - case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - break; - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); - break; - default: - g = 1.0; /* back_1 */ - gs = 1.0; /* back */ - } - - if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - } - else - { - back.red = (png_byte)(pow( - (double)png_ptr->background.red/255, gs) * 255.0 + .5); - back.green = (png_byte)(pow( - (double)png_ptr->background.green/255, gs) * 255.0 + .5); - back.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, gs) * 255.0 + .5); - } - - back_1.red = (png_byte)(pow( - (double)png_ptr->background.red/255, g) * 255.0 + .5); - back_1.green = (png_byte)(pow( - (double)png_ptr->background.green/255, g) * 255.0 + .5); - back_1.blue = (png_byte)(pow( - (double)png_ptr->background.blue/255, g) * 255.0 + .5); - } - for (i = 0; i < num_palette; i++) - { - if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - if (png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else /* if (png_ptr->trans[i] != 0xff) */ - { - png_byte v, w; - - v = png_ptr->gamma_to_1[palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN)*/ - else - /* color_type != PNG_COLOR_TYPE_PALETTE */ - { - double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); - double g = 1.0; - double gs = 1.0; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; - break; - case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - break; - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * - png_ptr->screen_gamma); - break; - } - - if (color_type & PNG_COLOR_MASK_COLOR) - { - /* RGB or RGBA */ - png_ptr->background_1.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, g) * m + .5); - png_ptr->background_1.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, g) * m + .5); - png_ptr->background_1.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, g) * m + .5); - png_ptr->background.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, gs) * m + .5); - png_ptr->background.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, gs) * m + .5); - png_ptr->background.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, gs) * m + .5); - } - else - { - /* GRAY or GRAY ALPHA */ - png_ptr->background_1.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, g) * m + .5); - png_ptr->background.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, gs) * m + .5); - } - } - } - else - /* transformation does not include PNG_BACKGROUND */ -#endif - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - /* No GAMMA transformation */ - if ((png_ptr->transformations & PNG_BACKGROUND) && - (color_type == PNG_COLOR_TYPE_PALETTE)) - { - int i; - int istop = (int)png_ptr->num_trans; - png_color back; - png_colorp palette = png_ptr->palette; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < istop; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (png_ptr->trans[i] != 0xff) - { - /* The png_composite() macro is defined in png.h */ - png_composite(palette[i].red, palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - if ((png_ptr->transformations & PNG_SHIFT) && - (color_type == PNG_COLOR_TYPE_PALETTE)) - { - png_uint_16 i; - png_uint_16 istop = png_ptr->num_palette; - int sr = 8 - png_ptr->sig_bit.red; - int sg = 8 - png_ptr->sig_bit.green; - int sb = 8 - png_ptr->sig_bit.blue; - - if (sr < 0 || sr > 8) - sr = 0; - if (sg < 0 || sg > 8) - sg = 0; - if (sb < 0 || sb > 8) - sb = 0; - for (i = 0; i < istop; i++) - { - png_ptr->palette[i].red >>= sr; - png_ptr->palette[i].green >>= sg; - png_ptr->palette[i].blue >>= sb; - } - } -#endif - } -#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ - && !defined(PNG_READ_BACKGROUND_SUPPORTED) - if(png_ptr) - return; -#endif -} - -/* Modify the info structure to reflect the transformations. The - * info should be updated so a PNG file could be written with it, - * assuming the transformations result in valid PNG data. - */ -void /* PRIVATE */ -png_read_transform_info(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_read_transform_info\n"); -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans) - info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - else - info_ptr->color_type = PNG_COLOR_TYPE_RGB; - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - } - else - { - if (png_ptr->num_trans) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; - if (info_ptr->bit_depth < 8) - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; - info_ptr->num_trans = 0; - info_ptr->background = png_ptr->background; - } -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = png_ptr->gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = png_ptr->int_gamma; -#endif - } -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) - info_ptr->bit_depth = 8; -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) - { - if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && - png_ptr->palette_lookup && info_ptr->bit_depth == 8) - { - info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; - } - } -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) - info_ptr->bit_depth = 8; -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; -#endif - - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_ptr->channels = 3; - else - info_ptr->channels = 1; - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_STRIP_ALPHA) - info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; -#endif - - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - info_ptr->channels++; - -#if defined(PNG_READ_FILLER_SUPPORTED) - /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ - if ((png_ptr->transformations & PNG_FILLER) && - ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) - { - info_ptr->channels++; -#if 0 /* if adding a true alpha channel not just filler */ - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; -#endif - } -#endif - -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ -defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(info_ptr->bit_depth < png_ptr->user_transform_depth) - info_ptr->bit_depth = png_ptr->user_transform_depth; - if(info_ptr->channels < png_ptr->user_transform_channels) - info_ptr->channels = png_ptr->user_transform_channels; - } -#endif - - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * - info_ptr->bit_depth); - info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3); - -#if !defined(PNG_READ_EXPAND_SUPPORTED) - if(png_ptr) - return; -#endif -} - -/* Transform the row. The order of transformations is significant, - * and is very touchy. If you add a transformation, take care to - * decide how it fits in with the other transformations here. - */ -void /* PRIVATE */ -png_do_read_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_do_read_transformations\n"); -#if !defined(PNG_USELESS_TESTS_SUPPORTED) - if (png_ptr->row_buf == NULL) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - - sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number, - png_ptr->pass); - png_error(png_ptr, msg); -#else - png_error(png_ptr, "NULL row buffer"); -#endif - } -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) - { - png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette, png_ptr->trans, png_ptr->num_trans); - } - else - { - if (png_ptr->num_trans) - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values)); - else - png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - NULL); - } - } -#endif - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_STRIP_ALPHA) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - PNG_FLAG_FILLER_AFTER); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & PNG_RGB_TO_GRAY) - { - int rgb_error = - png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); - if(rgb_error) - { - png_ptr->rgb_to_gray_status=1; - if(png_ptr->transformations == PNG_RGB_TO_GRAY_WARN) - png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - if(png_ptr->transformations == PNG_RGB_TO_GRAY_ERR) - png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - } - } -#endif - -/* -From Andreas Dilger e-mail to png-implement, 26 March 1998: - - In most cases, the "simple transparency" should be done prior to doing - gray-to-RGB, or you will have to test 3x as many bytes to check if a - pixel is transparent. You would also need to make sure that the - transparency information is upgraded to RGB. - - To summarize, the current flow is: - - Gray + simple transparency -> compare 1 or 2 gray bytes and composite - with background "in place" if transparent, - convert to RGB if necessary - - Gray + alpha -> composite with gray background and remove alpha bytes, - convert to RGB if necessary - - To support RGB backgrounds for gray images we need: - - Gray + simple transparency -> convert to RGB + simple transparency, compare - 3 or 6 bytes and composite with background - "in place" if transparent (3x compare/pixel - compared to doing composite with gray bkgrnd) - - Gray + alpha -> convert to RGB + alpha, composite with background and - remove alpha bytes (3x float operations/pixel - compared with composite on gray background) - - Greg's change will do this. The reason it wasn't done before is for - performance, as this increases the per-pixel operations. If we would check - in advance if the background was gray or RGB, and position the gray-to-RGB - transform appropriately, then it would save a lot of work/time. - */ - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if background is non-gray; else do later - * for performance reasons */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if ((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0 ) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) - png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values), &(png_ptr->background), - &(png_ptr->background_1), - png_ptr->gamma_table, png_ptr->gamma_from_1, - png_ptr->gamma_to_1, png_ptr->gamma_16_table, - png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, - png_ptr->gamma_shift); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) - if ((png_ptr->transformations & PNG_GAMMA) && -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - !((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && -#endif - (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) - png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->gamma_table, png_ptr->gamma_16_table, - png_ptr->gamma_shift); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if (png_ptr->transformations & PNG_16_TO_8) - png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) - if (png_ptr->transformations & PNG_DITHER) - { - png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->palette_lookup, png_ptr->dither_index); - if(png_ptr->row_info.rowbytes == (png_uint_32)0) - png_error(png_ptr, "png_do_dither returned rowbytes=0"); - } -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if we did not do so above */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && - (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) - png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->filler, png_ptr->flags); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - { - if(png_ptr->read_user_transform_fn != NULL) - (*(png_ptr->read_user_transform_fn)) /* user read transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->user_transform_depth) - png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; - if(png_ptr->user_transform_channels) - png_ptr->row_info.channels = png_ptr->user_transform_channels; -#endif - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - png_ptr->row_info.rowbytes = (png_ptr->row_info.width * - png_ptr->row_info.pixel_depth+7)>>3; - } -#endif - -} - -#if defined(PNG_READ_PACK_SUPPORTED) -/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, - * without changing the actual values. Thus, if you had a row with - * a bit depth of 1, you would end up with bytes that only contained - * the numbers 0 or 1. If you would rather they contain 0 and 255, use - * png_do_shift() after this. - */ -void /* PRIVATE */ -png_do_unpack(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_unpack\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth < 8) -#else - if (row_info->bit_depth < 8) -#endif - { - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - switch (row_info->bit_depth) - { - case 1: - { - png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x01); - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - - png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x03); - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); - png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x0f); - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift = 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_width * row_info->channels; - } -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -/* Reverse the effects of png_do_shift. This routine merely shifts the - * pixels back to their significant bits values. Thus, if you have - * a row of bit depth 8, but only 5 are significant, this will shift - * the values back to 0 through 31. - */ -void /* PRIVATE */ -png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) -{ - png_debug(1, "in png_do_unshift\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && sig_bits != NULL && -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift[4]; - int channels = 0; - int c; - png_uint_16 value = 0; - png_uint_32 row_width = row_info->width; - - if (row_info->color_type & PNG_COLOR_MASK_COLOR) - { - shift[channels++] = row_info->bit_depth - sig_bits->red; - shift[channels++] = row_info->bit_depth - sig_bits->green; - shift[channels++] = row_info->bit_depth - sig_bits->blue; - } - else - { - shift[channels++] = row_info->bit_depth - sig_bits->gray; - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - shift[channels++] = row_info->bit_depth - sig_bits->alpha; - } - - for (c = 0; c < channels; c++) - { - if (shift[c] <= 0) - shift[c] = 0; - else - value = 1; - } - - if (!value) - return; - - switch (row_info->bit_depth) - { - case 2: - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (bp = row, i = 0; i < istop; i++) - { - *bp >>= 1; - *bp++ &= 0x55; - } - break; - } - case 4: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) | - (png_byte)((int)0xf >> shift[0])); - - for (i = 0; i < istop; i++) - { - *bp >>= shift[0]; - *bp++ &= mask; - } - break; - } - case 8: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = row_width * channels; - - for (i = 0; i < istop; i++) - { - *bp++ >>= shift[i%channels]; - } - break; - } - case 16: - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_width; - - for (i = 0; i < istop; i++) - { - value = (png_uint_16)((*bp << 8) + *(bp + 1)); - value >>= shift[i%channels]; - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)(value & 0xff); - } - break; - } - } - } -} -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* chop rows of bit depth 16 down to 8 */ -void /* PRIVATE */ -png_do_chop(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_chop\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth == 16) -#else - if (row_info->bit_depth == 16) -#endif - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - png_uint_32 istop = row_info->width * row_info->channels; - - for (i = 0; i> 8)) >> 8; - * - * Approximate calculation with shift/add instead of multiply/divide: - * *dp = ((((png_uint_32)(*sp) << 8) | - * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8; - * - * What we actually do to avoid extra shifting and conversion: - */ - - *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); -#else - /* Simply discard the low order byte */ - *dp = *sp; -#endif - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_info->width * row_info->channels; - } -} -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from RGBA to ARGB */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - /* This converts from RRGGBBAA to AARRGGBB */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from GA to AG */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - /* This converts from GGAA to AAGG */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } - } - } -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - png_uint_32 row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=3; - dp=sp; - } - } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=6; - dp=sp; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = *(--sp); - } - } - /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); -/* - *(--dp) = *(--sp); - *(--dp) = *(--sp); -*/ - sp-=2; - dp=sp; - } - } - } - } -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) -/* Add filler channel if we have RGB color */ -void /* PRIVATE */ -png_do_read_filler(png_row_infop row_info, png_bytep row, - png_uint_32 filler, png_uint_32 flags) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_byte hi_filler = (png_byte)((filler>>8) & 0xff); - png_byte lo_filler = (png_byte)(filler & 0xff); - - png_debug(1, "in png_do_read_filler\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if(row_info->bit_depth == 8) - { - /* This changes the data from G to GX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - /* This changes the data from G to XG */ - else - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - } - else if(row_info->bit_depth == 16) - { - /* This changes the data from GG to GGXX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = hi_filler; - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = hi_filler; - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - /* This changes the data from GG to XXGG */ - else - { - png_bytep sp = row + (png_size_t)row_width; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = hi_filler; - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - } /* COLOR_TYPE == GRAY */ - else if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if(row_info->bit_depth == 8) - { - /* This changes the data from RGB to RGBX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - /* This changes the data from RGB to XRGB */ - else - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - else if(row_info->bit_depth == 16) - { - /* This changes the data from RRGGBB to RRGGBBXX */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = hi_filler; - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = hi_filler; - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - /* This changes the data from RRGGBB to XXRRGGBB */ - else - { - png_bytep sp = row + (png_size_t)row_width * 3; - png_bytep dp = sp + (png_size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = hi_filler; - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - } - } /* COLOR_TYPE == RGB */ -} -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* expand grayscale files to RGB, with or without alpha */ -void /* PRIVATE */ -png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_debug(1, "in png_do_gray_to_rgb\n"); - if (row_info->bit_depth >= 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - !(row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if (row_info->bit_depth == 8) - { - png_bytep sp = row + (png_size_t)row_width - 1; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - else - { - png_bytep sp = row + (png_size_t)row_width * 2 - 1; - png_bytep dp = sp + (png_size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (row_info->bit_depth == 8) - { - png_bytep sp = row + (png_size_t)row_width * 2 - 1; - png_bytep dp = sp + (png_size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - else - { - png_bytep sp = row + (png_size_t)row_width * 4 - 1; - png_bytep dp = sp + (png_size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - row_info->channels += (png_byte)2; - row_info->color_type |= PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = ((row_width * - row_info->pixel_depth + 7) >> 3); - } -} -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* reduce RGB files to grayscale, with or without alpha - * using the equation given in Poynton's ColorFAQ at - * - * Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net - * - * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - * - * We approximate this with - * - * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - * - * which can be expressed with integers as - * - * Y = (6969 * R + 23434 * G + 2365 * B)/32768 - * - * The calculation is to be done in a linear colorspace. - * - * Other integer coefficents can be used via png_set_rgb_to_gray(). - */ -int /* PRIVATE */ -png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) - -{ - png_uint_32 i; - - png_uint_32 row_width = row_info->width; - int rgb_error = 0; - - png_debug(1, "in png_do_rgb_to_gray\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; - png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; - png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1[ - (rc*red+gc*green+bc*blue)>>15]; - } - else - *(dp++) = *(sp-1); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - { - rgb_error |= 1; - *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); - } - else - *(dp++) = *(sp-1); - } - } - } - - else /* RGB bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 - + bc*blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - } - } - } - } - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = png_ptr->gamma_to_1[*(sp++)]; - png_byte green = png_ptr->gamma_to_1[*(sp++)]; - png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1 - [(rc*red + gc*green + bc*blue)>>15]; - *(dp++) = *(sp++); /* alpha */ - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - if(red != green || red != blue) - rgb_error |= 1; - *(dp++) = (png_byte)((gc*red + gc*green + bc*blue)>>8); - *(dp++) = *(sp++); /* alpha */ - } - } - } - else /* RGBA bit_depth == 16 */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->gamma_16_to_1 != NULL && - png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - - red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - - if(red == green && red == blue) - w = red; - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc * red_1 - + gc * green_1 + bc * blue_1)>>15); - w = png_ptr->gamma_16_from_1[(gray16&0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - *(dp++) = *(sp++); /* alpha */ - *(dp++) = *(sp++); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - if(red != green || red != blue) - rgb_error |= 1; - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); - *(dp++) = (png_byte)((gray16>>8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - *(dp++) = *(sp++); /* alpha */ - *(dp++) = *(sp++); - } - } - } - } - row_info->channels -= (png_byte)2; - row_info->color_type &= ~PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = ((row_width * - row_info->pixel_depth + 7) >> 3); - } - return rgb_error; -} -#endif - -/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth - * large of png_color. This lets grayscale images be treated as - * paletted. Most useful for gamma correction and simplification - * of code. - */ -void /* PRIVATE */ -png_build_grayscale_palette(int bit_depth, png_colorp palette) -{ - int num_palette; - int color_inc; - int i; - int v; - - png_debug(1, "in png_do_build_grayscale_palette\n"); - if (palette == NULL) - return; - - switch (bit_depth) - { - case 1: - num_palette = 2; - color_inc = 0xff; - break; - case 2: - num_palette = 4; - color_inc = 0x55; - break; - case 4: - num_palette = 16; - color_inc = 0x11; - break; - case 8: - num_palette = 256; - color_inc = 1; - break; - default: - num_palette = 0; - color_inc = 0; - break; - } - - for (i = 0, v = 0; i < num_palette; i++, v += color_inc) - { - palette[i].red = (png_byte)v; - palette[i].green = (png_byte)v; - palette[i].blue = (png_byte)v; - } -} - -/* This function is currently unused. Do we really need it? */ -#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) -void /* PRIVATE */ -png_correct_palette(png_structp png_ptr, png_colorp palette, - int num_palette) -{ - png_debug(1, "in png_correct_palette\n"); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) - { - png_color back, back_1; - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g; - - g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || - fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = png_ptr->background.red; - back.green = png_ptr->background.green; - back.blue = png_ptr->background.blue; - } - else - { - back.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - g = 1.0 / png_ptr->background_gamma; - - back_1.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back_1.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back_1.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_uint_32 i; - - for (i = 0; i < (png_uint_32)num_palette; i++) - { - if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - png_byte v, w; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - else - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (palette[i].red == (png_byte)png_ptr->trans_values.gray) - { - palette[i] = back; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - } - else -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_color back; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < (int)png_ptr->num_trans; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i].red = back.red; - palette[i].green = back.green; - palette[i].blue = back.blue; - } - else if (png_ptr->trans[i] != 0xff) - { - png_composite(palette[i].red, png_ptr->palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, png_ptr->palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, png_ptr->palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } - else /* assume grayscale palette (what else could it be?) */ - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (i == (png_byte)png_ptr->trans_values.gray) - { - palette[i].red = (png_byte)png_ptr->background.red; - palette[i].green = (png_byte)png_ptr->background.green; - palette[i].blue = (png_byte)png_ptr->background.blue; - } - } - } - } -#endif -} -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Replace any alpha or transparency with the supplied background color. - * "background" is already in the screen gamma, while "background_1" is - * at a gamma of 1.0. Paletted files have already been taken care of. - */ -void /* PRIVATE */ -png_do_background(png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background, - png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - int shift; - - png_debug(1, "in png_do_background\n"); - if (background != NULL && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || - (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_GRAY: - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row; - shift = 7; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x01) - == trans_values->gray) - { - *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 7; - sp++; - } - else - shift--; - } - break; - } - case 2: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) - { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - else - { - png_byte p = (png_byte)((*sp >> shift) & 0x03); - png_byte g = (png_byte)((gamma_table [p | (p << 2) | - (p << 4) | (p << 6)] >> 6) & 0x03); - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); - } - if (!shift) - { - shift = 6; - sp++; - } - else - shift -= 2; - } - } - else -#endif - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) - { - *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 6; - sp++; - } - else - shift -= 2; - } - } - break; - } - case 4: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) - { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - else - { - png_byte p = (png_byte)((*sp >> shift) & 0x0f); - png_byte g = (png_byte)((gamma_table[p | - (p << 4)] >> 4) & 0x0f); - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(g << shift); - } - if (!shift) - { - shift = 4; - sp++; - } - else - shift -= 4; - } - } - else -#endif - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) - { - *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *sp |= (png_byte)(background->gray << shift); - } - if (!shift) - { - shift = 4; - sp++; - } - else - shift -= 4; - } - } - break; - } - case 8: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } - else - { - *sp = gamma_table[*sp]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == trans_values->gray) - { - *sp = (png_byte)background->gray; - } - } - } - break; - } - case 16: - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) - { - /* background is already in screen gamma */ - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); - } - else - { - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) - { - *sp = (png_byte)((background->gray >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->gray & 0xff); - } - } - } - break; - } - } - break; - } - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) - { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; - } - else - { - *sp = gamma_table[*sp]; - *(sp + 1) = gamma_table[*(sp + 1)]; - *(sp + 2) = gamma_table[*(sp + 2)]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) - { - *sp = (png_byte)background->red; - *(sp + 1) = (png_byte)background->green; - *(sp + 2) = (png_byte)background->blue; - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) - { - /* background is already in screen gamma */ - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(sp + 2) = (png_byte)((v >> 8) & 0xff); - *(sp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(sp + 4) = (png_byte)((v >> 8) & 0xff); - *(sp + 5) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); - png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) - { - *sp = (png_byte)((background->red >> 8) & 0xff); - *(sp + 1) = (png_byte)(background->red & 0xff); - *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(sp + 3) = (png_byte)(background->green & 0xff); - *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(sp + 5) = (png_byte)(background->blue & 0xff); - } - } - } - } - break; - } - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) - { - png_uint_16 a = *(sp + 1); - - if (a == 0xff) - { - *dp = gamma_table[*sp]; - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)background->gray; - } - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->gray); - *dp = gamma_from_1[w]; - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 2, dp++) - { - png_byte a = *(sp + 1); - - if (a == 0xff) - { - *dp = *sp; - } - else if (a == 0) - { - *dp = (png_byte)background->gray; - } - else - { - png_composite(*dp, *sp, a, background_1->gray); - } - } - } - } - else /* if (png_ptr->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) - { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); - } - else - { - png_uint_16 g, v, w; - - g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(v, g, a, background_1->gray); - w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; - *dp = (png_byte)((w >> 8) & 0xff); - *(dp + 1) = (png_byte)(w & 0xff); - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 2) - { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 2); - } - else if (a == 0) - { - *dp = (png_byte)((background->gray >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->gray & 0xff); - } - else - { - png_uint_16 g, v; - - g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_composite_16(v, g, a, background_1->gray); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - } - } - } - } - break; - } - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *dp = gamma_table[*sp]; - *(dp + 1) = gamma_table[*(sp + 1)]; - *(dp + 2) = gamma_table[*(sp + 2)]; - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; - } - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, background_1->red); - *dp = gamma_from_1[w]; - v = gamma_to_1[*(sp + 1)]; - png_composite(w, v, a, background_1->green); - *(dp + 1) = gamma_from_1[w]; - v = gamma_to_1[*(sp + 2)]; - png_composite(w, v, a, background_1->blue); - *(dp + 2) = gamma_from_1[w]; - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 4, dp += 3) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *dp = *sp; - *(dp + 1) = *(sp + 1); - *(dp + 2) = *(sp + 2); - } - else if (a == 0) - { - *dp = (png_byte)background->red; - *(dp + 1) = (png_byte)background->green; - *(dp + 2) = (png_byte)background->blue; - } - else - { - png_composite(*dp, *sp, a, background->red); - png_composite(*(dp + 1), *(sp + 1), a, - background->green); - png_composite(*(dp + 2), *(sp + 2), a, - background->blue); - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); - } - else if (a == 0) - { - /* background is already in screen gamma */ - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v, w, x; - - v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(w, v, a, background->red); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *dp = (png_byte)((x >> 8) & 0xff); - *(dp + 1) = (png_byte)(x & 0xff); - v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; - png_composite_16(w, v, a, background->green); - x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; - *(dp + 2) = (png_byte)((x >> 8) & 0xff); - *(dp + 3) = (png_byte)(x & 0xff); - v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; - png_composite_16(w, v, a, background->blue); - x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; - *(dp + 4) = (png_byte)((x >> 8) & 0xff); - *(dp + 5) = (png_byte)(x & 0xff); - } - } - } - else -#endif - { - sp = row; - dp = row; - for (i = 0; i < row_width; i++, sp += 8, dp += 6) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - if (a == (png_uint_16)0xffff) - { - png_memcpy(dp, sp, 6); - } - else if (a == 0) - { - *dp = (png_byte)((background->red >> 8) & 0xff); - *(dp + 1) = (png_byte)(background->red & 0xff); - *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); - *(dp + 3) = (png_byte)(background->green & 0xff); - *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); - *(dp + 5) = (png_byte)(background->blue & 0xff); - } - else - { - png_uint_16 v; - - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) - + *(sp + 5)); - - png_composite_16(v, r, a, background->red); - *dp = (png_byte)((v >> 8) & 0xff); - *(dp + 1) = (png_byte)(v & 0xff); - png_composite_16(v, g, a, background->green); - *(dp + 2) = (png_byte)((v >> 8) & 0xff); - *(dp + 3) = (png_byte)(v & 0xff); - png_composite_16(v, b, a, background->blue); - *(dp + 4) = (png_byte)((v >> 8) & 0xff); - *(dp + 5) = (png_byte)(v & 0xff); - } - } - } - } - break; - } - } - - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - row_info->channels--; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = ((row_width * - row_info->pixel_depth + 7) >> 3); - } - } -} -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Gamma correct the image, avoiding the alpha channel. Make sure - * you do this after you deal with the transparency issue on grayscale - * or RGB images. If your bit depth is 8, use gamma_table, if it - * is 16, use gamma_16_table and gamma_shift. Build these with - * build_gamma_table(). - */ -void /* PRIVATE */ -png_do_gamma(png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift) -{ - png_bytep sp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_gamma\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - ((row_info->bit_depth <= 8 && gamma_table != NULL) || - (row_info->bit_depth == 16 && gamma_16_table != NULL))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - sp++; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp += 2; - } - } - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - case PNG_COLOR_TYPE_GRAY: - { - if (row_info->bit_depth == 2) - { - sp = row; - for (i = 0; i < row_width; i += 4) - { - int a = *sp & 0xc0; - int b = *sp & 0x30; - int c = *sp & 0x0c; - int d = *sp & 0x03; - - *sp = (png_byte)( - ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| - ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| - ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| - ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); - sp++; - } - } - if (row_info->bit_depth == 4) - { - sp = row; - for (i = 0; i < row_width; i += 2) - { - int msb = *sp & 0xf0; - int lsb = *sp & 0x0f; - - *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) - | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); - sp++; - } - } - else if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - } - } - else if (row_info->bit_depth == 16) - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - } - } -} -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expands a palette row to an RGB or RGBA row depending - * upon whether you supply trans and num_trans. - */ -void /* PRIVATE */ -png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_colorp palette, png_bytep trans, int num_trans) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand_palette\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row + (png_size_t)((row_width - 1) >> 3); - dp = row + (png_size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 1; - else - *dp = 0; - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - sp = row + (png_size_t)((row_width - 1) >> 2); - dp = row + (png_size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)value; - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - sp = row + (png_size_t)((row_width - 1) >> 1); - dp = row + (png_size_t)row_width - 1; - shift = (int)((row_width & 0x01) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)value; - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift += 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - switch (row_info->bit_depth) - { - case 8: - { - if (trans != NULL) - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width << 2) - 1; - - for (i = 0; i < row_width; i++) - { - if ((int)(*sp) >= num_trans) - *dp-- = 0xff; - else - *dp-- = trans[*sp]; - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - row_info->color_type = 6; - row_info->channels = 4; - } - else - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width * 3) - 1; - - for (i = 0; i < row_width; i++) - { - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - row_info->color_type = 2; - row_info->channels = 3; - } - break; - } - } - } -} - -/* If the bit depth < 8, it is expanded to 8. Also, if the - * transparency value is supplied, an alpha channel is built. - */ -void /* PRIVATE */ -png_do_expand(png_row_infop row_info, png_bytep row, - png_color_16p trans_value) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); - - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - gray = (png_uint_16)(gray*0xff); - sp = row + (png_size_t)((row_width - 1) >> 3); - dp = row + (png_size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 0xff; - else - *dp = 0; - if (shift == 7) - { - shift = 0; - sp--; - } - else - shift++; - - dp--; - } - break; - } - case 2: - { - gray = (png_uint_16)(gray*0x55); - sp = row + (png_size_t)((row_width - 1) >> 2); - dp = row + (png_size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)(value | (value << 2) | (value << 4) | - (value << 6)); - if (shift == 6) - { - shift = 0; - sp--; - } - else - shift += 2; - - dp--; - } - break; - } - case 4: - { - gray = (png_uint_16)(gray*0x11); - sp = row + (png_size_t)((row_width - 1) >> 1); - dp = row + (png_size_t)row_width - 1; - shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)(value | (value << 4)); - if (shift == 4) - { - shift = 0; - sp--; - } - else - shift = 4; - - dp--; - } - break; - } - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - - if (trans_value != NULL) - { - if (row_info->bit_depth == 8) - { - sp = row + (png_size_t)row_width - 1; - dp = row + (png_size_t)(row_width << 1) - 1; - for (i = 0; i < row_width; i++) - { - if (*sp == gray) - *dp-- = 0; - else - *dp-- = 0xff; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - sp = row + row_info->rowbytes - 1; - dp = row + (row_info->rowbytes << 1) - 1; - for (i = 0; i < row_width; i++) - { - if (((png_uint_16)*(sp) | - ((png_uint_16)*(sp - 1) << 8)) == gray) - { - *dp-- = 0; - *dp-- = 0; - } - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; - row_info->channels = 2; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); - row_info->rowbytes = - ((row_width * row_info->pixel_depth) >> 3); - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value) - { - if (row_info->bit_depth == 8) - { - sp = row + (png_size_t)row_info->rowbytes - 1; - dp = row + (png_size_t)(row_width << 2) - 1; - for (i = 0; i < row_width; i++) - { - if (*(sp - 2) == trans_value->red && - *(sp - 1) == trans_value->green && - *(sp - 0) == trans_value->blue) - *dp-- = 0; - else - *dp-- = 0xff; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - sp = row + row_info->rowbytes - 1; - dp = row + (png_size_t)(row_width << 3) - 1; - for (i = 0; i < row_width; i++) - { - if ((((png_uint_16)*(sp - 4) | - ((png_uint_16)*(sp - 5) << 8)) == trans_value->red) && - (((png_uint_16)*(sp - 2) | - ((png_uint_16)*(sp - 3) << 8)) == trans_value->green) && - (((png_uint_16)*(sp - 0) | - ((png_uint_16)*(sp - 1) << 8)) == trans_value->blue)) - { - *dp-- = 0; - *dp-- = 0; - } - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - row_info->channels = 4; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); - row_info->rowbytes = - ((row_width * row_info->pixel_depth) >> 3); - } - } -} -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -void /* PRIVATE */ -png_do_dither(png_row_infop row_info, png_bytep row, - png_bytep palette_lookup, png_bytep dither_lookup) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_dither\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB && - palette_lookup && row_info->bit_depth == 8) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - - /* this looks real messy, but the compiler will reduce - it down to a reasonable formula. For example, with - 5 bits per color, we get: - p = (((r >> 3) & 0x1f) << 10) | - (((g >> 3) & 0x1f) << 5) | - ((b >> 3) & 0x1f); - */ - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = - ((row_width * row_info->pixel_depth + 7) >> 3); - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - palette_lookup != NULL && row_info->bit_depth == 8) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - sp++; - - p = (((r >> (8 - PNG_DITHER_RED_BITS)) & - ((1 << PNG_DITHER_RED_BITS) - 1)) << - (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | - (((g >> (8 - PNG_DITHER_GREEN_BITS)) & - ((1 << PNG_DITHER_GREEN_BITS) - 1)) << - (PNG_DITHER_BLUE_BITS)) | - ((b >> (8 - PNG_DITHER_BLUE_BITS)) & - ((1 << PNG_DITHER_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = - ((row_width * row_info->pixel_depth + 7) >> 3); - } - else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && - dither_lookup && row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - *sp = dither_lookup[*sp]; - } - } - } -} -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -#if defined(PNG_READ_GAMMA_SUPPORTED) -static int png_gamma_shift[] = - {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0}; - -/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit - * tables, we don't make a full table if we are reducing to 8-bit in - * the future. Note also how the gamma_16 tables are segmented so that - * we don't need to allocate > 64K chunks for a full 16-bit table. - */ -void /* PRIVATE */ -png_build_gamma_table(png_structp png_ptr) -{ - png_debug(1, "in png_build_gamma_table\n"); - if(png_ptr->gamma != 0.0) - { - if (png_ptr->bit_depth <= 8) - { - int i; - double g; - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - - - png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } - else - { - double g; - int i, j, shift, num; - int sig_bit; - png_uint_32 ig; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit = (int)png_ptr->sig_bit.red; - if ((int)png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - if ((int)png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - { - sig_bit = (int)png_ptr->sig_bit.gray; - } - - if (sig_bit > 0) - shift = 16 - sig_bit; - else - shift = 0; - - if (png_ptr->transformations & PNG_16_TO_8) - { - if (shift < (16 - PNG_MAX_GAMMA_8)) - shift = (16 - PNG_MAX_GAMMA_8); - } - - if (shift > 8) - shift = 8; - if (shift < 0) - shift = 0; - - png_ptr->gamma_shift = (png_byte)shift; - - num = (1 << (8 - shift)); - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * sizeof (png_uint_16p))); - - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) - { - double fin, fout; - png_uint_32 last, max; - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * sizeof (png_uint_16))); - } - - g = 1.0 / g; - last = 0; - for (i = 0; i < 256; i++) - { - fout = ((double)i + 0.5) / 256.0; - fin = pow(fout, g); - max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); - while (last <= max) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)( - (png_uint_16)i | ((png_uint_16)i << 8)); - last++; - } - } - while (last < ((png_uint_32)num << 8)) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)65535L; - last++; - } - } - else - { - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * sizeof (png_uint_16))); - - ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_table[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * sizeof (png_uint_16p ))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_to_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - - if(png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ - - png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * sizeof (png_uint_16p))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * sizeof (png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_from_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } - } -} -#endif -/* To do: install integer version of png_build_gamma_table here */ -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ -void /* PRIVATE */ -png_do_read_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff); - *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0=*(rp )<<8 | *(rp+1); - png_uint_32 s1=*(rp+2)<<8 | *(rp+3); - png_uint_32 s2=*(rp+4)<<8 | *(rp+5); - png_uint_32 red=(65536+s0+s1)&0xffff; - png_uint_32 blue=(65536+s2+s1)&0xffff; - *(rp ) = (png_byte)((red>>8)&0xff); - *(rp+1) = (png_byte)(red&0xff); - *(rp+4) = (png_byte)((blue>>8)&0xff); - *(rp+5) = (png_byte)(blue&0xff); - } - } - } -} -#endif /* PNG_MNG_FEATURES_SUPPORTED */ diff --git a/freeimage241/Source/LibPNG/pngrutil.c b/freeimage241/Source/LibPNG/pngrutil.c deleted file mode 100644 index ec970ce..0000000 --- a/freeimage241/Source/LibPNG/pngrutil.c +++ /dev/null @@ -1,3000 +0,0 @@ - -/* pngrutil.c - utilities to read a PNG file - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file contains routines that are only called from within - * libpng itself during the course of reading an image. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(_WIN32_WCE) -/* strtod() function is not supported on WindowsCE */ -# ifdef PNG_FLOATING_POINT_SUPPORTED -__inline double strtod(const char *nptr, char **endptr) -{ - double result = 0; - int len; - wchar_t *str, *end; - - len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); - str = (wchar_t *)malloc(len * sizeof(wchar_t)); - if ( NULL != str ) - { - MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); - result = wcstod(str, &end); - len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); - *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); - free(str); - } - return result; -} -# endif -#endif - -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ -png_uint_32 /* PRIVATE */ -png_get_uint_32(png_bytep buf) -{ - png_uint_32 i = ((png_uint_32)(*buf) << 24) + - ((png_uint_32)(*(buf + 1)) << 16) + - ((png_uint_32)(*(buf + 2)) << 8) + - (png_uint_32)(*(buf + 3)); - - return (i); -} - -#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_oFFs_SUPPORTED) -/* Grab a signed 32-bit integer from a buffer in big-endian format. The - * data is stored in the PNG file in two's complement format, and it is - * assumed that the machine format for signed integers is the same. */ -png_int_32 /* PRIVATE */ -png_get_int_32(png_bytep buf) -{ - png_int_32 i = ((png_int_32)(*buf) << 24) + - ((png_int_32)(*(buf + 1)) << 16) + - ((png_int_32)(*(buf + 2)) << 8) + - (png_int_32)(*(buf + 3)); - - return (i); -} -#endif /* PNG_READ_pCAL_SUPPORTED */ - -/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ -png_uint_16 /* PRIVATE */ -png_get_uint_16(png_bytep buf) -{ - png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + - (png_uint_16)(*(buf + 1))); - - return (i); -} -#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ - -/* Read data, and (optionally) run it through the CRC. */ -void /* PRIVATE */ -png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) -{ - png_read_data(png_ptr, buf, length); - png_calculate_crc(png_ptr, buf, length); -} - -/* Optionally skip data and then check the CRC. Depending on whether we - are reading a ancillary or critical chunk, and how the program has set - things up, we may calculate the CRC on the data and print a message. - Returns '1' if there was a CRC error, '0' otherwise. */ -int /* PRIVATE */ -png_crc_finish(png_structp png_ptr, png_uint_32 skip) -{ - png_size_t i; - png_size_t istop = png_ptr->zbuf_size; - - for (i = (png_size_t)skip; i > istop; i -= istop) - { - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - } - if (i) - { - png_crc_read(png_ptr, png_ptr->zbuf, i); - } - - if (png_crc_error(png_ptr)) - { - if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ - !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || - (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ - (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) - { - png_chunk_warning(png_ptr, "CRC error"); - } - else - { - png_chunk_error(png_ptr, "CRC error"); - } - return (1); - } - - return (0); -} - -/* Compare the CRC stored in the PNG file with that calculated by libpng from - the data it has read thus far. */ -int /* PRIVATE */ -png_crc_error(png_structp png_ptr) -{ - png_byte crc_bytes[4]; - png_uint_32 crc; - int need_crc = 1; - - if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - else /* critical */ - { - if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) - need_crc = 0; - } - - png_read_data(png_ptr, crc_bytes, 4); - - if (need_crc) - { - crc = png_get_uint_32(crc_bytes); - return ((int)(crc != png_ptr->crc)); - } - else - return (0); -} - -#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ - defined(PNG_READ_iCCP_SUPPORTED) -/* - * Decompress trailing data in a chunk. The assumption is that chunkdata - * points at an allocated area holding the contents of a chunk with a - * trailing compressed part. What we get back is an allocated area - * holding the original prefix part and an uncompressed version of the - * trailing part (the malloc area passed in is freed). - */ -png_charp /* PRIVATE */ -png_decompress_chunk(png_structp png_ptr, int comp_type, - png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_size, png_size_t *newlength) -{ - static char msg[] = "Error decoding compressed text"; - png_charp text = NULL; - png_size_t text_size; - - if (comp_type == PNG_COMPRESSION_TYPE_BASE) - { - int ret = Z_OK; - png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); - png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - text_size = 0; - text = NULL; - - while (png_ptr->zstream.avail_in) - { - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret != Z_OK && ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_warning(png_ptr, png_ptr->zstream.msg); - else - png_warning(png_ptr, msg); - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - if (text == NULL) - { - text_size = prefix_size + sizeof(msg) + 1; - text = (png_charp)png_malloc(png_ptr, text_size); - png_memcpy(text, chunkdata, prefix_size); - } - - text[text_size - 1] = 0x00; - - /* Copy what we can of the error message into the text chunk */ - text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); - text_size = sizeof(msg) > text_size ? text_size : sizeof(msg); - png_memcpy(text + prefix_size, msg, text_size + 1); - break; - } - if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) - { - if (text == NULL) - { - text_size = prefix_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out; - text = (png_charp)png_malloc(png_ptr, text_size + 1); - png_memcpy(text + prefix_size, png_ptr->zbuf, - text_size - prefix_size); - png_memcpy(text, chunkdata, prefix_size); - *(text + text_size) = 0x00; - } - else - { - png_charp tmp; - - tmp = text; - text = (png_charp)png_malloc(png_ptr, (png_uint_32)(text_size + - png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); - png_memcpy(text, tmp, text_size); - png_free(png_ptr, tmp); - png_memcpy(text + text_size, png_ptr->zbuf, - (png_ptr->zbuf_size - png_ptr->zstream.avail_out)); - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; - *(text + text_size) = 0x00; - } - if (ret == Z_STREAM_END) - break; - else - { - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - } - if (ret != Z_STREAM_END) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[50]; - - if (ret == Z_BUF_ERROR) - sprintf(umsg,"Buffer error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else if (ret == Z_DATA_ERROR) - sprintf(umsg,"Data error in compressed datastream in %s chunk", - png_ptr->chunk_name); - else - sprintf(umsg,"Incomplete compressed datastream in %s chunk", - png_ptr->chunk_name); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, - "Incomplete compressed datastream in chunk other than IDAT"); -#endif - text_size=prefix_size; - if (text == NULL) - { - text = (png_charp)png_malloc(png_ptr, text_size+1); - png_memcpy(text, chunkdata, prefix_size); - } - *(text + text_size) = 0x00; - } - - inflateReset(&png_ptr->zstream); - png_ptr->zstream.avail_in = 0; - - png_free(png_ptr, chunkdata); - chunkdata = text; - *newlength=text_size; - } - else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char umsg[50]; - - sprintf(umsg, "Unknown zTXt compression type %d", comp_type); - png_warning(png_ptr, umsg); -#else - png_warning(png_ptr, "Unknown zTXt compression type"); -#endif - - *(chunkdata + prefix_size) = 0x00; - *newlength=prefix_size; - } - - return chunkdata; -} -#endif - -/* read and check the IDHR chunk */ -void /* PRIVATE */ -png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[13]; - png_uint_32 width, height; - int bit_depth, color_type, compression_type, filter_type; - int interlace_type; - - png_debug(1, "in png_handle_IHDR\n"); - - if (png_ptr->mode & PNG_HAVE_IHDR) - png_error(png_ptr, "Out of place IHDR"); - - /* check the length */ - if (length != 13) - png_error(png_ptr, "Invalid IHDR chunk"); - - png_ptr->mode |= PNG_HAVE_IHDR; - - png_crc_read(png_ptr, buf, 13); - png_crc_finish(png_ptr, 0); - - width = png_get_uint_32(buf); - height = png_get_uint_32(buf + 4); - bit_depth = buf[8]; - color_type = buf[9]; - compression_type = buf[10]; - filter_type = buf[11]; - interlace_type = buf[12]; - - - /* set internal variables */ - png_ptr->width = width; - png_ptr->height = height; - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->interlaced = (png_byte)interlace_type; - png_ptr->color_type = (png_byte)color_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_ptr->filter_type = (png_byte)filter_type; -#endif - - /* find number of channels */ - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_PALETTE: - png_ptr->channels = 1; - break; - case PNG_COLOR_TYPE_RGB: - png_ptr->channels = 3; - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - png_ptr->channels = 2; - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - png_ptr->channels = 4; - break; - } - - /* set up other useful info */ - png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * - png_ptr->channels); - png_ptr->rowbytes = ((png_ptr->width * - (png_uint_32)png_ptr->pixel_depth + 7) >> 3); - png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); - png_debug1(3,"channels = %d\n", png_ptr->channels); - png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - color_type, interlace_type, compression_type, filter_type); -} - -/* read and check the palette */ -void /* PRIVATE */ -png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_color palette[PNG_MAX_PALETTE_LENGTH]; - int num, i; -#ifndef PNG_NO_POINTER_INDEXING - png_colorp pal_ptr; -#endif - - png_debug(1, "in png_handle_PLTE\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before PLTE"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid PLTE after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - png_error(png_ptr, "Duplicate PLTE chunk"); - - png_ptr->mode |= PNG_HAVE_PLTE; - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring PLTE chunk in grayscale PNG"); - png_crc_finish(png_ptr, length); - return; - } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_crc_finish(png_ptr, length); - return; - } -#endif - - if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) - { - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_warning(png_ptr, "Invalid palette chunk"); - png_crc_finish(png_ptr, length); - return; - } - else - { - png_error(png_ptr, "Invalid palette chunk"); - } - } - - num = (int)length / 3; - -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - pal_ptr->red = buf[0]; - pal_ptr->green = buf[1]; - pal_ptr->blue = buf[2]; - } -#else - for (i = 0; i < num; i++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - /* don't depend upon png_color being any order */ - palette[i].red = buf[0]; - palette[i].green = buf[1]; - palette[i].blue = buf[2]; - } -#endif - - /* If we actually NEED the PLTE chunk (ie for a paletted image), we do - whatever the normal CRC configuration tells us. However, if we - have an RGB image, the PLTE can be considered ancillary, so - we will act as though it is. */ -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#endif - { - png_crc_finish(png_ptr, 0); - } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) - else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ - { - /* If we don't want to use the data from an ancillary chunk, - we have two options: an error abort, or a warning and we - ignore the data in this chunk (which should be OK, since - it's considered ancillary for a RGB or RGBA image). */ - if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) - { - if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) - { - png_chunk_error(png_ptr, "CRC error"); - } - else - { - png_chunk_warning(png_ptr, "CRC error"); - return; - } - } - /* Otherwise, we (optionally) emit a warning and use the chunk. */ - else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) - { - png_chunk_warning(png_ptr, "CRC error"); - } - } -#endif - - png_set_PLTE(png_ptr, info_ptr, palette, num); - -#if defined(PNG_READ_tRNS_SUPPORTED) - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - if (png_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); - png_ptr->num_trans = (png_uint_16)num; - } - if (info_ptr->num_trans > (png_uint_16)num) - { - png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); - info_ptr->num_trans = (png_uint_16)num; - } - } - } -#endif - -} - -void /* PRIVATE */ -png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_debug(1, "in png_handle_IEND\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) - { - png_error(png_ptr, "No image in file"); - - info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */ - } - - png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); - - if (length != 0) - { - png_warning(png_ptr, "Incorrect IEND chunk length"); - } - png_crc_finish(png_ptr, length); -} - -#if defined(PNG_READ_gAMA_SUPPORTED) -void /* PRIVATE */ -png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_fixed_point igamma; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif - png_byte buf[4]; - - png_debug(1, "in png_handle_gAMA\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before gAMA"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid gAMA after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place gAMA chunk"); - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate gAMA chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 4) - { - png_warning(png_ptr, "Incorrect gAMA chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 4); - if (png_crc_finish(png_ptr, 0)) - return; - - igamma = (png_fixed_point)png_get_uint_32(buf); - /* check for zero gamma */ - if (igamma == 0) - { - png_warning(png_ptr, - "Ignoring gAMA chunk with gamma=0"); - return; - } - -#if defined(PNG_READ_sRGB_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sRGB) - if(igamma < 45000L || igamma > 46000L) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO - fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); -#endif - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float)igamma / (float)100000.0; -# ifdef PNG_READ_GAMMA_SUPPORTED - png_ptr->gamma = file_gamma; -# endif - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_gAMA_fixed(png_ptr, info_ptr, igamma); -#endif -} -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -void /* PRIVATE */ -png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_size_t truelen; - png_byte buf[4]; - - png_debug(1, "in png_handle_sBIT\n"); - - buf[0] = buf[1] = buf[2] = buf[3] = 0; - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sBIT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sBIT after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - { - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sBIT chunk"); - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)) - { - png_warning(png_ptr, "Duplicate sBIT chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 3; - else - truelen = (png_size_t)png_ptr->channels; - - if (length != truelen) - { - png_warning(png_ptr, "Incorrect sBIT chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) - return; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[1]; - png_ptr->sig_bit.blue = buf[2]; - png_ptr->sig_bit.alpha = buf[3]; - } - else - { - png_ptr->sig_bit.gray = buf[0]; - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[0]; - png_ptr->sig_bit.blue = buf[0]; - png_ptr->sig_bit.alpha = buf[1]; - } - png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); -} -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -void /* PRIVATE */ -png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[4]; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif - png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue; - - png_debug(1, "in png_handle_cHRM\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before cHRM"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid cHRM after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Missing PLTE before cHRM"); - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) -#if defined(PNG_READ_sRGB_SUPPORTED) - && !(info_ptr->valid & PNG_INFO_sRGB) -#endif - ) - { - png_warning(png_ptr, "Duplicate cHRM chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 32) - { - png_warning(png_ptr, "Incorrect cHRM chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 4); - int_x_white = (png_fixed_point)png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - int_y_white = (png_fixed_point)png_get_uint_32(buf); - - if (int_x_white > 80000L || int_y_white > 80000L || - int_x_white + int_y_white > 100000L) - { - png_warning(png_ptr, "Invalid cHRM white point"); - png_crc_finish(png_ptr, 24); - return; - } - - png_crc_read(png_ptr, buf, 4); - int_x_red = (png_fixed_point)png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - int_y_red = (png_fixed_point)png_get_uint_32(buf); - - if (int_x_red > 80000L || int_y_red > 80000L || - int_x_red + int_y_red > 100000L) - { - png_warning(png_ptr, "Invalid cHRM red point"); - png_crc_finish(png_ptr, 16); - return; - } - - png_crc_read(png_ptr, buf, 4); - int_x_green = (png_fixed_point)png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - int_y_green = (png_fixed_point)png_get_uint_32(buf); - - if (int_x_green > 80000L || int_y_green > 80000L || - int_x_green + int_y_green > 100000L) - { - png_warning(png_ptr, "Invalid cHRM green point"); - png_crc_finish(png_ptr, 8); - return; - } - - png_crc_read(png_ptr, buf, 4); - int_x_blue = (png_fixed_point)png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - int_y_blue = (png_fixed_point)png_get_uint_32(buf); - - if (int_x_blue > 80000L || int_y_blue > 80000L || - int_x_blue + int_y_blue > 100000L) - { - png_warning(png_ptr, "Invalid cHRM blue point"); - png_crc_finish(png_ptr, 0); - return; - } -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float)int_x_white / (float)100000.0; - white_y = (float)int_y_white / (float)100000.0; - red_x = (float)int_x_red / (float)100000.0; - red_y = (float)int_y_red / (float)100000.0; - green_x = (float)int_x_green / (float)100000.0; - green_y = (float)int_y_green / (float)100000.0; - blue_x = (float)int_x_blue / (float)100000.0; - blue_y = (float)int_y_blue / (float)100000.0; -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sRGB) - { - if (abs(int_x_white - 31270L) > 1000 || - abs(int_y_white - 32900L) > 1000 || - abs( int_x_red - 64000L) > 1000 || - abs( int_y_red - 33000L) > 1000 || - abs(int_x_green - 30000L) > 1000 || - abs(int_y_green - 60000L) > 1000 || - abs( int_x_blue - 15000L) > 1000 || - abs( int_y_blue - 6000L) > 1000) - { - - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -#ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", - white_x, white_y, red_x, red_y); - fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", - green_x, green_y, blue_x, blue_y); -#else - fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", - int_x_white, int_y_white, int_x_red, int_y_red); - fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", - int_x_green, int_y_green, int_x_blue, int_y_blue); -#endif -#endif /* PNG_NO_CONSOLE_IO */ - } - png_crc_finish(png_ptr, 0); - return; - } -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_cHRM_fixed(png_ptr, info_ptr, - int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue); -#endif - if (png_crc_finish(png_ptr, 0)) - return; -} -#endif - -#if defined(PNG_READ_sRGB_SUPPORTED) -void /* PRIVATE */ -png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - int intent; - png_byte buf[1]; - - png_debug(1, "in png_handle_sRGB\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sRGB"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sRGB after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place sRGB chunk"); - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) - { - png_warning(png_ptr, "Duplicate sRGB chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 1) - { - png_warning(png_ptr, "Incorrect sRGB chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 1); - if (png_crc_finish(png_ptr, 0)) - return; - - intent = buf[0]; - /* check for bad intent */ - if (intent >= PNG_sRGB_INTENT_LAST) - { - png_warning(png_ptr, "Unknown sRGB intent"); - return; - } - -#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) - if ((info_ptr->valid & PNG_INFO_gAMA)) - { - int igamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - igamma=(int)info_ptr->int_gamma; -#else -# ifdef PNG_FLOATING_POINT_SUPPORTED - igamma=(int)(info_ptr->gamma * 100000.); -# endif -#endif -#if 0 && defined(PNG_cHRM_SUPPORTED) && !defined(PNG_FIXED_POINT_SUPPORTED) -/* We need to define these here because they aren't in png.h */ - png_fixed_point int_x_white; - png_fixed_point int_y_white; - png_fixed_point int_x_red; - png_fixed_point int_y_red; - png_fixed_point int_x_green; - png_fixed_point int_y_green; - png_fixed_point int_x_blue; - png_fixed_point int_y_blue; -#endif - if(igamma < 45000L || igamma > 46000L) - { - png_warning(png_ptr, - "Ignoring incorrect gAMA value when sRGB is also present"); -#ifndef PNG_NO_CONSOLE_IO -# ifdef PNG_FIXED_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); -# else -# ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); -# endif -# endif -#endif - } - } -#endif /* PNG_READ_gAMA_SUPPORTED */ - -#ifdef PNG_READ_cHRM_SUPPORTED -#ifdef PNG_FIXED_POINT_SUPPORTED - if (info_ptr->valid & PNG_INFO_cHRM) - if (abs(info_ptr->int_x_white - 31270L) > 1000 || - abs(info_ptr->int_y_white - 32900L) > 1000 || - abs( info_ptr->int_x_red - 64000L) > 1000 || - abs( info_ptr->int_y_red - 33000L) > 1000 || - abs(info_ptr->int_x_green - 30000L) > 1000 || - abs(info_ptr->int_y_green - 60000L) > 1000 || - abs( info_ptr->int_x_blue - 15000L) > 1000 || - abs( info_ptr->int_y_blue - 6000L) > 1000) - { - png_warning(png_ptr, - "Ignoring incorrect cHRM value when sRGB is also present"); - } -#endif /* PNG_FIXED_POINT_SUPPORTED */ -#endif /* PNG_READ_cHRM_SUPPORTED */ - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); -} -#endif /* PNG_READ_sRGB_SUPPORTED */ - -#if defined(PNG_READ_iCCP_SUPPORTED) -void /* PRIVATE */ -png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_charp chunkdata; - png_byte compression_type; - png_charp profile; - png_uint_32 skip = 0; - png_uint_32 profile_size = 0; - png_uint_32 profile_length = 0; - png_size_t slength, prefix_length, data_length; - - png_debug(1, "in png_handle_iCCP\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iCCP"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid iCCP after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->mode & PNG_HAVE_PLTE) - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Out of place iCCP chunk"); - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) - { - png_warning(png_ptr, "Duplicate iCCP chunk"); - png_crc_finish(png_ptr, length); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "iCCP chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - chunkdata = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (profile = chunkdata; *profile; profile++) - /* empty loop to find end of name */ ; - - ++profile; - - /* there should be at least one zero (the compression type byte) - following the separator, and we should be on it */ - if ( profile >= chunkdata + slength) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Malformed iCCP chunk"); - return; - } - - /* compression_type should always be zero */ - compression_type = *profile++; - if (compression_type) - { - png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); - compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 - wrote nonzero) */ - } - - prefix_length = profile - chunkdata; - chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, - slength, prefix_length, &data_length); - - profile_length = data_length - prefix_length; - - if ( profile_length < 4) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Profile size field missing from iCCP chunk"); - return; - } - - /* Check the profile_size recorded in the first 32 bits of the ICC profile */ - profile_size = ((*(chunkdata+prefix_length))<<24) | - ((*(chunkdata+prefix_length+1))<<16) | - ((*(chunkdata+prefix_length+2))<< 8) | - ((*(chunkdata+prefix_length+3)) ); - - if(profile_size < profile_length) - profile_length = profile_size; - - if(profile_size > profile_length) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "Ignoring truncated iCCP profile.\n"); - return; - } - - png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, - chunkdata + prefix_length, profile_length); - png_free(png_ptr, chunkdata); -} -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_sPLT_SUPPORTED) -void /* PRIVATE */ -png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_bytep chunkdata; - png_bytep entry_start; - png_sPLT_t new_palette; -#ifdef PNG_NO_POINTER_INDEXING - png_sPLT_entryp pp; -#endif - int data_length, entry_size, i; - png_uint_32 skip = 0; - png_size_t slength; - - png_debug(1, "in png_handle_sPLT\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sPLT"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sPLT after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "sPLT chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (entry_start = chunkdata; *entry_start; entry_start++) - /* empty loop to find end of name */ ; - ++entry_start; - - /* a sample depth should follow the separator, and we should be on it */ - if (entry_start > chunkdata + slength) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "malformed sPLT chunk"); - return; - } - - new_palette.depth = *entry_start++; - entry_size = (new_palette.depth == 8 ? 6 : 10); - data_length = (slength - (entry_start - chunkdata)); - - /* integrity-check the data length */ - if (data_length % entry_size) - { - png_free(png_ptr, chunkdata); - png_warning(png_ptr, "sPLT chunk has bad length"); - return; - } - - new_palette.nentries = data_length / entry_size; - new_palette.entries = (png_sPLT_entryp)png_malloc( - png_ptr, new_palette.nentries * sizeof(png_sPLT_entry)); - -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0; i < new_palette.nentries; i++) - { - png_sPLT_entryp pp = new_palette.entries + i; - - if (new_palette.depth == 8) - { - pp->red = *entry_start++; - pp->green = *entry_start++; - pp->blue = *entry_start++; - pp->alpha = *entry_start++; - } - else - { - pp->red = png_get_uint_16(entry_start); entry_start += 2; - pp->green = png_get_uint_16(entry_start); entry_start += 2; - pp->blue = png_get_uint_16(entry_start); entry_start += 2; - pp->alpha = png_get_uint_16(entry_start); entry_start += 2; - } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#else - pp = new_palette.entries; - for (i = 0; i < new_palette.nentries; i++) - { - - if (new_palette.depth == 8) - { - pp[i].red = *entry_start++; - pp[i].green = *entry_start++; - pp[i].blue = *entry_start++; - pp[i].alpha = *entry_start++; - } - else - { - pp[i].red = png_get_uint_16(entry_start); entry_start += 2; - pp[i].green = png_get_uint_16(entry_start); entry_start += 2; - pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; - pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; - } - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#endif - - /* discard all chunk data except the name and stash that */ - new_palette.name = (png_charp)chunkdata; - - png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); - - png_free(png_ptr, chunkdata); - png_free(png_ptr, new_palette.entries); -} -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_tRNS_SUPPORTED) -void /* PRIVATE */ -png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_tRNS\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tRNS"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid tRNS after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) - { - png_warning(png_ptr, "Duplicate tRNS chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (!(png_ptr->mode & PNG_HAVE_PLTE)) - { - /* Should be an error, but we can cope with it */ - png_warning(png_ptr, "Missing PLTE before tRNS"); - } - else if (length > (png_uint_32)png_ptr->num_palette) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - if (length == 0) - { - png_warning(png_ptr, "Zero length tRNS chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, readbuf, (png_size_t)length); - png_ptr->num_trans = (png_uint_16)length; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_byte buf[6]; - - if (length != 6) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, (png_size_t)length); - png_ptr->num_trans = 1; - png_ptr->trans_values.red = png_get_uint_16(buf); - png_ptr->trans_values.green = png_get_uint_16(buf + 2); - png_ptr->trans_values.blue = png_get_uint_16(buf + 4); - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - png_byte buf[6]; - - if (length != 2) - { - png_warning(png_ptr, "Incorrect tRNS chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 2); - png_ptr->num_trans = 1; - png_ptr->trans_values.gray = png_get_uint_16(buf); - } - else - { - png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_crc_finish(png_ptr, 0)) - return; - - png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, - &(png_ptr->trans_values)); -} -#endif - -#if defined(PNG_READ_bKGD_SUPPORTED) -void /* PRIVATE */ -png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_size_t truelen; - png_byte buf[6]; - - png_debug(1, "in png_handle_bKGD\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before bKGD"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid bKGD after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - { - png_warning(png_ptr, "Missing PLTE before bKGD"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)) - { - png_warning(png_ptr, "Duplicate bKGD chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 1; - else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - truelen = 6; - else - truelen = 2; - - if (length != truelen) - { - png_warning(png_ptr, "Incorrect bKGD chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, truelen); - if (png_crc_finish(png_ptr, 0)) - return; - - /* We convert the index value into RGB components so that we can allow - * arbitrary RGB values for background when we have transparency, and - * so it is easy to determine the RGB values of the background color - * from the info_ptr struct. */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_ptr->background.index = buf[0]; - if(info_ptr->num_palette) - { - if(buf[0] > info_ptr->num_palette) - { - png_warning(png_ptr, "Incorrect bKGD chunk index value"); - return; - } - png_ptr->background.red = - (png_uint_16)png_ptr->palette[buf[0]].red; - png_ptr->background.green = - (png_uint_16)png_ptr->palette[buf[0]].green; - png_ptr->background.blue = - (png_uint_16)png_ptr->palette[buf[0]].blue; - } - } - else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ - { - png_ptr->background.red = - png_ptr->background.green = - png_ptr->background.blue = - png_ptr->background.gray = png_get_uint_16(buf); - } - else - { - png_ptr->background.red = png_get_uint_16(buf); - png_ptr->background.green = png_get_uint_16(buf + 2); - png_ptr->background.blue = png_get_uint_16(buf + 4); - } - - png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); -} -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -void /* PRIVATE */ -png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - int num, i; - png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_hIST\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before hIST"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid hIST after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (!(png_ptr->mode & PNG_HAVE_PLTE)) - { - png_warning(png_ptr, "Missing PLTE before hIST"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)) - { - png_warning(png_ptr, "Duplicate hIST chunk"); - png_crc_finish(png_ptr, length); - return; - } - - num = (int)length / 2 ; - if (num != png_ptr->num_palette) - { - png_warning(png_ptr, "Incorrect hIST chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - for (i = 0; i < num; i++) - { - png_byte buf[2]; - - png_crc_read(png_ptr, buf, 2); - readbuf[i] = png_get_uint_16(buf); - } - - if (png_crc_finish(png_ptr, 0)) - return; - - png_set_hIST(png_ptr, info_ptr, readbuf); -} -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -void /* PRIVATE */ -png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_uint_32 res_x, res_y; - int unit_type; - - png_debug(1, "in png_handle_pHYs\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pHYs"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid pHYs after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) - { - png_warning(png_ptr, "Duplicate pHYs chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 9) - { - png_warning(png_ptr, "Incorrect pHYs chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) - return; - - res_x = png_get_uint_32(buf); - res_y = png_get_uint_32(buf + 4); - unit_type = buf[8]; - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); -} -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -void /* PRIVATE */ -png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_int_32 offset_x, offset_y; - int unit_type; - - png_debug(1, "in png_handle_oFFs\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before oFFs"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid oFFs after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) - { - png_warning(png_ptr, "Duplicate oFFs chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (length != 9) - { - png_warning(png_ptr, "Incorrect oFFs chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 9); - if (png_crc_finish(png_ptr, 0)) - return; - - offset_x = png_get_int_32(buf); - offset_y = png_get_int_32(buf + 4); - unit_type = buf[8]; - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); -} -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -/* read the pCAL chunk (described in the PNG Extensions document) */ -void /* PRIVATE */ -png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_charp purpose; - png_int_32 X0, X1; - png_byte type, nparams; - png_charp buf, units, endptr; - png_charpp params; - png_size_t slength; - int i; - - png_debug(1, "in png_handle_pCAL\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before pCAL"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid pCAL after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) - { - png_warning(png_ptr, "Duplicate pCAL chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", - length + 1); - purpose = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)purpose, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, purpose); - return; - } - - purpose[slength] = 0x00; /* null terminate the last string */ - - png_debug(3, "Finding end of pCAL purpose string\n"); - for (buf = purpose; *buf; buf++) - /* empty loop */ ; - - endptr = purpose + slength; - - /* We need to have at least 12 bytes after the purpose string - in order to get the parameter information. */ - if (endptr <= buf + 12) - { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); - return; - } - - png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); - X0 = png_get_int_32((png_bytep)buf+1); - X1 = png_get_int_32((png_bytep)buf+5); - type = buf[9]; - nparams = buf[10]; - units = buf + 11; - - png_debug(3, "Checking pCAL equation type and number of parameters\n"); - /* Check that we have the right number of parameters for known - equation types. */ - if ((type == PNG_EQUATION_LINEAR && nparams != 2) || - (type == PNG_EQUATION_BASE_E && nparams != 3) || - (type == PNG_EQUATION_ARBITRARY && nparams != 3) || - (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) - { - png_warning(png_ptr, "Invalid pCAL parameters for equation type"); - png_free(png_ptr, purpose); - return; - } - else if (type >= PNG_EQUATION_LAST) - { - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - } - - for (buf = units; *buf; buf++) - /* Empty loop to move past the units string. */ ; - - png_debug(3, "Allocating pCAL parameters array\n"); - params = (png_charpp)png_malloc(png_ptr, (png_uint_32)(nparams - *sizeof(png_charp))) ; - - /* Get pointers to the start of each parameter string. */ - for (i = 0; i < (int)nparams; i++) - { - buf++; /* Skip the null string terminator from previous parameter. */ - - png_debug1(3, "Reading pCAL parameter %d\n", i); - for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++) - /* Empty loop to move past each parameter string */ ; - - /* Make sure we haven't run out of data yet */ - if (buf > endptr) - { - png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); - png_free(png_ptr, params); - return; - } - } - - png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, - units, params); - - png_free(png_ptr, purpose); - png_free(png_ptr, params); -} -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -/* read the sCAL chunk */ -void /* PRIVATE */ -png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_charp buffer, ep; -#ifdef PNG_FLOATING_POINT_SUPPORTED - double width, height; - png_charp vp; -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp swidth, sheight; -#endif -#endif - png_size_t slength; - - png_debug(1, "in png_handle_sCAL\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before sCAL"); - else if (png_ptr->mode & PNG_HAVE_IDAT) - { - png_warning(png_ptr, "Invalid sCAL after IDAT"); - png_crc_finish(png_ptr, length); - return; - } - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) - { - png_warning(png_ptr, "Duplicate sCAL chunk"); - png_crc_finish(png_ptr, length); - return; - } - - png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", - length + 1); - buffer = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)buffer, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, buffer); - return; - } - - buffer[slength] = 0x00; /* null terminate the last string */ - - ep = buffer + 1; /* skip unit byte */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - width = strtod(ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed width string in sCAL chunk"); - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - swidth = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1); - png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - - for (ep = buffer; *ep; ep++) - /* empty loop */ ; - ep++; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - height = strtod(ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed height string in sCAL chunk"); - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - sheight = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1); - png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); -#endif -#endif - - if (buffer + slength < ep -#ifdef PNG_FLOATING_POINT_SUPPORTED - || width <= 0. || height <= 0. -#endif - ) - { - png_warning(png_ptr, "Invalid sCAL data"); - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif - return; - } - - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); -#endif -#endif - - png_free(png_ptr, buffer); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif -} -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -void /* PRIVATE */ -png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_byte buf[7]; - png_time mod_time; - - png_debug(1, "in png_handle_tIME\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Out of place tIME chunk"); - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) - { - png_warning(png_ptr, "Duplicate tIME chunk"); - png_crc_finish(png_ptr, length); - return; - } - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - - if (length != 7) - { - png_warning(png_ptr, "Incorrect tIME chunk length"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buf, 7); - if (png_crc_finish(png_ptr, 0)) - return; - - mod_time.second = buf[6]; - mod_time.minute = buf[5]; - mod_time.hour = buf[4]; - mod_time.day = buf[3]; - mod_time.month = buf[2]; - mod_time.year = png_get_uint_16(buf); - - png_set_tIME(png_ptr, info_ptr, &mod_time); -} -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp key; - png_charp text; - png_uint_32 skip = 0; - png_size_t slength; - - png_debug(1, "in png_handle_tEXt\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before tEXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "tEXt chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - - key = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)key, slength); - - if (png_crc_finish(png_ptr, skip)) - { - png_free(png_ptr, key); - return; - } - - key[slength] = 0x00; - - for (text = key; *text; text++) - /* empty loop to find end of key */ ; - - if (text != key + slength) - text++; - - text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = text; - text_ptr->text_length = png_strlen(text); - - png_set_text(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, key); - png_free(png_ptr, text_ptr); -} -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp chunkdata; - png_charp text; - int comp_type; - png_size_t slength, prefix_len, data_len; - - png_debug(1, "in png_handle_zTXt\n"); - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before zTXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"zTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif - - chunkdata = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (text = chunkdata; *text; text++) - /* empty loop */ ; - - /* zTXt must have some text after the chunkdataword */ - if (text == chunkdata + slength) - { - comp_type = PNG_TEXT_COMPRESSION_NONE; - png_warning(png_ptr, "Zero length zTXt chunk"); - } - else - { - comp_type = *(++text); - if (comp_type != PNG_TEXT_COMPRESSION_zTXt) - { - png_warning(png_ptr, "Unknown compression type in zTXt chunk"); - comp_type = PNG_TEXT_COMPRESSION_zTXt; - } - text++; /* skip the compression_method byte */ - } - prefix_len = text - chunkdata; - - chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, - (png_size_t)length, prefix_len, &data_len); - - text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); - text_ptr->compression = comp_type; - text_ptr->key = chunkdata; -#ifdef PNG_iTXt_SUPPORTED - text_ptr->lang = NULL; - text_ptr->lang_key = NULL; - text_ptr->itxt_length = 0; -#endif - text_ptr->text = chunkdata + prefix_len; - text_ptr->text_length = data_len; - - png_set_text(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); -} -#endif - -#if defined(PNG_READ_iTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_textp text_ptr; - png_charp chunkdata; - png_charp key, lang, text, lang_key; - int comp_flag; - int comp_type = 0; - png_size_t slength, prefix_len, data_len; - - png_debug(1, "in png_handle_iTXt\n"); - - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before iTXt"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr,"iTXt chunk too large to fit in memory"); - png_crc_finish(png_ptr, length); - return; - } -#endif - - chunkdata = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, chunkdata); - return; - } - - chunkdata[slength] = 0x00; - - for (lang = chunkdata; *lang; lang++) - /* empty loop */ ; - lang++; /* skip NUL separator */ - - /* iTXt must have a language tag (possibly empty), two compression bytes, - translated keyword (possibly empty), and possibly some text after the - keyword */ - - if (lang >= chunkdata + slength) - { - comp_flag = PNG_TEXT_COMPRESSION_NONE; - png_warning(png_ptr, "Zero length iTXt chunk"); - } - else - { - comp_flag = *lang++; - comp_type = *lang++; - } - - for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ - - for (text = lang_key; *text; text++) - /* empty loop */ ; - text++; /* skip NUL separator */ - - prefix_len = text - chunkdata; - - key=chunkdata; - if (comp_flag) - chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, - (size_t)length, prefix_len, &data_len); - else - data_len=png_strlen(chunkdata + prefix_len); - text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); - text_ptr->compression = (int)comp_flag + 1; - text_ptr->lang_key = chunkdata+(lang_key-key); - text_ptr->lang = chunkdata+(lang-key); - text_ptr->itxt_length = data_len; - text_ptr->text_length = 0; - text_ptr->key = chunkdata; - text_ptr->text = chunkdata + prefix_len; - - png_set_text(png_ptr, info_ptr, text_ptr, 1); - - png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); -} -#endif - -/* This function is called when we haven't found a handler for a - chunk. If there isn't a problem with the chunk itself (ie bad - chunk name, CRC, or a critical chunk), the chunk is silently ignored - -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which - case it will be saved away to be written out later. */ -void /* PRIVATE */ -png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) -{ - png_uint_32 skip = 0; - - png_debug(1, "in png_handle_unknown\n"); - - if (png_ptr->mode & PNG_HAVE_IDAT) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ - png_ptr->mode |= PNG_AFTER_IDAT; - } - - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - if (!(png_ptr->chunk_name[0] & 0x20)) - { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL -#endif - ) -#endif - png_chunk_error(png_ptr, "unknown critical chunk"); - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) - { - png_unknown_chunk chunk; - -#ifdef PNG_MAX_MALLOC_64K - if (length > (png_uint_32)65535L) - { - png_warning(png_ptr, "unknown chunk too large to fit in memory"); - skip = length - (png_uint_32)65535L; - length = (png_uint_32)65535L; - } -#endif - png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); - chunk.data = (png_bytep)png_malloc(png_ptr, length); - chunk.size = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunk.data, length); -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) - { - /* callback to user unknown chunk handler */ - if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) - { - if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - HANDLE_CHUNK_ALWAYS) - png_chunk_error(png_ptr, "unknown critical chunk"); - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - } - } - else -#endif - png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); - png_free(png_ptr, chunk.data); - } - else -#endif - skip = length; - - png_crc_finish(png_ptr, skip); - -#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) - info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */ -#endif -} - -/* This function is called to verify that a chunk name is valid. - This function can't have the "critical chunk check" incorporated - into it, since in the future we will need to be able to call user - functions to handle unknown critical chunks after we check that - the chunk name itself is valid. */ - -#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97)) - -void /* PRIVATE */ -png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) -{ - png_debug(1, "in png_check_chunk_name\n"); - if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || - isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) - { - png_chunk_error(png_ptr, "invalid chunk type"); - } -} - -/* Combines the row recently read in with the existing pixels in the - row. This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined, - a zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ -#ifndef PNG_HAVE_ASSEMBLER_COMBINE_ROW -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ - png_debug(1,"in png_combine_row\n"); - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)((png_ptr->width * - png_ptr->row_info.pixel_depth + 7) >> 3)); - } - else - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_inc, s_start, s_end; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x01; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 2: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x03; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - case 4: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - int s_start, s_end, s_inc; - int m = 0x80; - int shift; - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - int value; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - default: - { - png_bytep sp = png_ptr->row_buf + 1; - png_bytep dp = row; - png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - png_uint_32 i; - png_uint_32 row_width = png_ptr->width; - png_byte m = 0x80; - - - for (i = 0; i < row_width; i++) - { - if (m & mask) - { - png_memcpy(dp, sp, pixel_bytes); - } - - sp += pixel_bytes; - dp += pixel_bytes; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - } - } -} -#endif /* !PNG_HAVE_ASSEMBLER_COMBINE_ROW */ - -#ifdef PNG_READ_INTERLACING_SUPPORTED -#ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */ -/* OLD pre-1.0.9 interface: -void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations) - */ -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_do_read_interlace (stock C version)\n"); - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); - png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; - png_byte v; - png_uint_32 i; - int j; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 0x07); - dshift = (int)((final_width + 7) & 0x07); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 0x07); - dshift = 7 - (int)((final_width + 7) & 0x07); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = 0; i < row_info->width; i++) - { - v = (png_byte)((*sp >> sshift) & 0x01); - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - case 2: - { - png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); - png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; - png_uint_32 i; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)(((row_info->width + 3) & 0x03) << 1); - dshift = (int)(((final_width + 3) & 0x03) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); - dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x03); - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - case 4: - { - png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); - png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - int jstop = png_pass_inc[pass]; - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)(((row_info->width + 1) & 0x01) << 2); - dshift = (int)(((final_width + 1) & 0x01) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); - dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v = (png_byte)((*sp >> sshift) & 0xf); - int j; - - for (j = 0; j < jstop; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - default: - { - png_size_t pixel_bytes = (row_info->pixel_depth >> 3); - png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes; - png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; - - int jstop = png_pass_inc[pass]; - png_uint_32 i; - - for (i = 0; i < row_info->width; i++) - { - png_byte v[8]; - int j; - - png_memcpy(v, sp, pixel_bytes); - for (j = 0; j < jstop; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sp -= pixel_bytes; - } - break; - } - } - row_info->width = final_width; - row_info->rowbytes = ((final_width * - (png_uint_32)row_info->pixel_depth + 7) >> 3); - } -#if !defined(PNG_READ_PACKSWAP_SUPPORTED) - transformations = transformations; /* silence compiler warning */ -#endif -} -#endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */ -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - -#ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, - png_bytep prev_row, int filter) -{ - png_debug(1, "in png_read_filter_row\n"); - png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - case PNG_FILTER_VALUE_SUB: - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_UP: - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_AVG: - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) / 2 )) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - (int)(*pp++ + *lp++) / 2 ) & 0xff); - rp++; - } - break; - } - case PNG_FILTER_VALUE_PAETH: - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) /* use leftover rp,pp */ - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - break; - } - default: - png_warning(png_ptr, "Ignoring bad adaptive filter type"); - *row=0; - break; - } -} -#endif /* !PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */ - -void /* PRIVATE */ -png_read_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_debug(1, "in png_read_finish_row\n"); - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - do - { - png_ptr->pass++; - if (png_ptr->pass >= 7) - break; - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - png_ptr->irowbytes = ((png_ptr->iwidth * - (png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1; - - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (!(png_ptr->num_rows)) - continue; - } - else /* if (png_ptr->transformations & PNG_INTERLACE) */ - break; - } while (png_ptr->iwidth == 0); - - if (png_ptr->pass < 7) - return; - } - - if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) - { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - char extra; - int ret; - - png_ptr->zstream.next_out = (Byte *)&extra; - png_ptr->zstream.avail_out = (uInt)1; - for(;;) - { - if (!(png_ptr->zstream.avail_in)) - { - while (!png_ptr->idat_size) - { - png_byte chunk_length[4]; - - png_crc_finish(png_ptr, 0); - - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_32(chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) - png_error(png_ptr, "Not enough image data"); - - } - png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_in = png_ptr->zbuf; - if (png_ptr->zbuf_size > png_ptr->idat_size) - png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; - png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); - png_ptr->idat_size -= png_ptr->zstream.avail_in; - } - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); - if (ret == Z_STREAM_END) - { - if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || - png_ptr->idat_size) - png_error(png_ptr, "Extra compressed data"); - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; - break; - } - if (ret != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : - "Decompression Error"); - - if (!(png_ptr->zstream.avail_out)) - png_error(png_ptr, "Extra compressed data"); - - } - png_ptr->zstream.avail_out = 0; - } - - if (png_ptr->idat_size || png_ptr->zstream.avail_in) - png_error(png_ptr, "Extra compression data"); - - inflateReset(&png_ptr->zstream); - - png_ptr->mode |= PNG_AFTER_IDAT; -} - -void /* PRIVATE */ -png_read_start_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - int max_pixel_depth; - png_uint_32 row_bytes; - - png_debug(1, "in png_read_start_row\n"); - png_ptr->zstream.avail_in = 0; - png_init_read_transformations(png_ptr); - if (png_ptr->interlaced) - { - if (!(png_ptr->transformations & PNG_INTERLACE)) - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - else - png_ptr->num_rows = png_ptr->height; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - row_bytes = ((png_ptr->iwidth * - (png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1; - png_ptr->irowbytes = (png_size_t)row_bytes; - if((png_uint_32)png_ptr->irowbytes != row_bytes) - png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); - } - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->iwidth = png_ptr->width; - png_ptr->irowbytes = png_ptr->rowbytes + 1; - } - max_pixel_depth = png_ptr->pixel_depth; - -#if defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) - max_pixel_depth = 8; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) - if (png_ptr->transformations & PNG_EXPAND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans) - max_pixel_depth = 32; - else - max_pixel_depth = 24; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth < 8) - max_pixel_depth = 8; - if (png_ptr->num_trans) - max_pixel_depth *= 2; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (png_ptr->num_trans) - { - max_pixel_depth *= 4; - max_pixel_depth /= 3; - } - } - } -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & (PNG_FILLER)) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - max_pixel_depth = 32; - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth <= 8) - max_pixel_depth = 16; - else - max_pixel_depth = 32; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (max_pixel_depth <= 32) - max_pixel_depth = 32; - else - max_pixel_depth = 64; - } - } -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - if (png_ptr->transformations & PNG_GRAY_TO_RGB) - { - if ( -#if defined(PNG_READ_EXPAND_SUPPORTED) - (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || -#endif -#if defined(PNG_READ_FILLER_SUPPORTED) - (png_ptr->transformations & (PNG_FILLER)) || -#endif - png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (max_pixel_depth <= 16) - max_pixel_depth = 32; - else - max_pixel_depth = 64; - } - else - { - if (max_pixel_depth <= 8) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 32; - else - max_pixel_depth = 24; - } - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 64; - else - max_pixel_depth = 48; - } - } -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ -defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) - { - int user_pixel_depth=png_ptr->user_transform_depth* - png_ptr->user_transform_channels; - if(user_pixel_depth > max_pixel_depth) - max_pixel_depth=user_pixel_depth; - } -#endif - - /* align the width on the next larger 8 pixels. Mainly used - for interlacing */ - row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); - /* calculate the maximum bytes needed, adding a byte and a pixel - for safety's sake */ - row_bytes = ((row_bytes * (png_uint_32)max_pixel_depth + 7) >> 3) + - 1 + ((max_pixel_depth + 7) >> 3); -#ifdef PNG_MAX_MALLOC_64K - if (row_bytes > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, row_bytes); -#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) - png_ptr->row_buf_size = row_bytes; -#endif - -#ifdef PNG_MAX_MALLOC_64K - if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( - png_ptr->rowbytes + 1)); - - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - - png_debug1(3, "width = %lu,\n", png_ptr->width); - png_debug1(3, "height = %lu,\n", png_ptr->height); - png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); - png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); - - png_ptr->flags |= PNG_FLAG_ROW_INIT; -} diff --git a/freeimage241/Source/LibPNG/pngset.c b/freeimage241/Source/LibPNG/pngset.c deleted file mode 100644 index ddc4d0c..0000000 --- a/freeimage241/Source/LibPNG/pngset.c +++ /dev/null @@ -1,972 +0,0 @@ - -/* pngset.c - storage of image information into info struct - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * The functions here are used during reads to store data from the file - * into the info struct, and during writes to store application data - * into the info struct for writing into the file. This abstracts the - * info struct and allows us to change the structure in the future. - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_bKGD_SUPPORTED) -void PNGAPI -png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) -{ - png_debug1(1, "in %s storage function\n", "bKGD"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_memcpy(&(info_ptr->background), background, sizeof(png_color_16)); - info_ptr->valid |= PNG_INFO_bKGD; -} -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_cHRM(png_structp png_ptr, png_infop info_ptr, - double white_x, double white_y, double red_x, double red_y, - double green_x, double green_y, double blue_x, double blue_y) -{ - png_debug1(1, "in %s storage function\n", "cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_white = (float)white_x; - info_ptr->y_white = (float)white_y; - info_ptr->x_red = (float)red_x; - info_ptr->y_red = (float)red_y; - info_ptr->x_green = (float)green_x; - info_ptr->y_green = (float)green_y; - info_ptr->x_blue = (float)blue_x; - info_ptr->y_blue = (float)blue_y; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); - info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); - info_ptr->int_x_red = (png_fixed_point)(red_x*100000.+0.5); - info_ptr->int_y_red = (png_fixed_point)(red_y*100000.+0.5); - info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); - info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); - info_ptr->int_x_blue = (png_fixed_point)(blue_x*100000.+0.5); - info_ptr->int_y_blue = (png_fixed_point)(blue_y*100000.+0.5); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, - png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, - png_fixed_point blue_x, png_fixed_point blue_y) -{ - png_debug1(1, "in %s storage function\n", "cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->int_x_white = white_x; - info_ptr->int_y_white = white_y; - info_ptr->int_x_red = red_x; - info_ptr->int_y_red = red_y; - info_ptr->int_x_green = green_x; - info_ptr->int_y_green = green_y; - info_ptr->int_x_blue = blue_x; - info_ptr->int_y_blue = blue_y; -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->x_white = (float)(white_x/100000.); - info_ptr->y_white = (float)(white_y/100000.); - info_ptr->x_red = (float)(red_x/100000.); - info_ptr->y_red = (float)(red_y/100000.); - info_ptr->x_green = (float)(green_x/100000.); - info_ptr->y_green = (float)(green_y/100000.); - info_ptr->x_blue = (float)(blue_x/100000.); - info_ptr->y_blue = (float)(blue_y/100000.); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) -{ - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->gamma = (float)file_gamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = (int)(file_gamma*100000.+.5); -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(file_gamma == 0.0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif -void PNGAPI -png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point - int_gamma) -{ - png_debug1(1, "in %s storage function\n", "gAMA"); - if (png_ptr == NULL || info_ptr == NULL) - return; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = (float)(int_gamma/100000.); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = int_gamma; -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if(int_gamma == 0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif - -#if defined(PNG_hIST_SUPPORTED) -void PNGAPI -png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) -{ - int i; - - png_debug1(1, "in %s storage function\n", "hIST"); - if (png_ptr == NULL || info_ptr == NULL) - return; - if (info_ptr->num_palette == 0) - { - png_warning(png_ptr, - "Palette size 0, hIST allocation skipped."); - return; - } - -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); -#endif - png_ptr->hist = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(info_ptr->num_palette * sizeof (png_uint_16))); - - for (i = 0; i < info_ptr->num_palette; i++) - png_ptr->hist[i] = hist[i]; - info_ptr->hist = png_ptr->hist; - info_ptr->valid |= PNG_INFO_hIST; - -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_HIST; -#else - png_ptr->flags |= PNG_FLAG_FREE_HIST; -#endif -} -#endif - -void PNGAPI -png_set_IHDR(png_structp png_ptr, png_infop info_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) -{ - int rowbytes_per_pixel; - png_debug1(1, "in %s storage function\n", "IHDR"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* check for width and height valid values */ - if (width == 0 || height == 0) - png_error(png_ptr, "Image width or height is zero in IHDR"); - if (width > PNG_MAX_UINT || height > PNG_MAX_UINT) - png_error(png_ptr, "Invalid image size in IHDR"); - - /* check other values */ - if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth in IHDR"); - - if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) - png_error(png_ptr, "Invalid color type in IHDR"); - - if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || - ((color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) - png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); - - if (interlace_type >= PNG_INTERLACE_LAST) - png_error(png_ptr, "Unknown interlace method in IHDR"); - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_error(png_ptr, "Unknown compression method in IHDR"); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Accept filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not read a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n"); - if(filter_type != PNG_FILTER_TYPE_BASE) - { - if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - png_error(png_ptr, "Unknown filter method in IHDR"); - if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) - png_warning(png_ptr, "Invalid filter method in IHDR"); - } -#else - if(filter_type != PNG_FILTER_TYPE_BASE) - png_error(png_ptr, "Unknown filter method in IHDR"); -#endif - - info_ptr->width = width; - info_ptr->height = height; - info_ptr->bit_depth = (png_byte)bit_depth; - info_ptr->color_type =(png_byte) color_type; - info_ptr->compression_type = (png_byte)compression_type; - info_ptr->filter_type = (png_byte)filter_type; - info_ptr->interlace_type = (png_byte)interlace_type; - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) - info_ptr->channels = 3; - else - info_ptr->channels = 1; - if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) - info_ptr->channels++; - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); - - /* check for overflow */ - rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3; - if (( width > PNG_MAX_UINT/rowbytes_per_pixel)) - { - png_warning(png_ptr, - "Width too large to process image data; rowbytes will overflow."); - info_ptr->rowbytes = (png_size_t)0; - } - else - info_ptr->rowbytes = (info_ptr->width * info_ptr->pixel_depth + 7) >> 3; -} - -#if defined(PNG_oFFs_SUPPORTED) -void PNGAPI -png_set_oFFs(png_structp png_ptr, png_infop info_ptr, - png_int_32 offset_x, png_int_32 offset_y, int unit_type) -{ - png_debug1(1, "in %s storage function\n", "oFFs"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_offset = offset_x; - info_ptr->y_offset = offset_y; - info_ptr->offset_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_oFFs; -} -#endif - -#if defined(PNG_pCAL_SUPPORTED) -void PNGAPI -png_set_pCAL(png_structp png_ptr, png_infop info_ptr, - png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params) -{ - png_uint_32 length; - int i; - - png_debug1(1, "in %s storage function\n", "pCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - length = png_strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); - info_ptr->pcal_purpose = (png_charp)png_malloc(png_ptr, length); - png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); - - png_debug(3, "storing X0, X1, type, and nparams in info\n"); - info_ptr->pcal_X0 = X0; - info_ptr->pcal_X1 = X1; - info_ptr->pcal_type = (png_byte)type; - info_ptr->pcal_nparams = (png_byte)nparams; - - length = png_strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)\n", length); - info_ptr->pcal_units = (png_charp)png_malloc(png_ptr, length); - png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); - - info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr, - (png_uint_32)((nparams + 1) * sizeof(png_charp))); - - info_ptr->pcal_params[nparams] = NULL; - - for (i = 0; i < nparams; i++) - { - length = png_strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); - info_ptr->pcal_params[i] = (png_charp)png_malloc(png_ptr, length); - png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); - } - - info_ptr->valid |= PNG_INFO_pCAL; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PCAL; -#endif -} -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_sCAL(png_structp png_ptr, png_infop info_ptr, - int unit, double width, double height) -{ - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->scal_unit = (png_byte)unit; - info_ptr->scal_pixel_width = width; - info_ptr->scal_pixel_height = height; - - info_ptr->valid |= PNG_INFO_sCAL; -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int unit, png_charp swidth, png_charp sheight) -{ - png_uint_32 length; - - png_debug1(1, "in %s storage function\n", "sCAL"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->scal_unit = (png_byte)unit; - - length = png_strlen(swidth) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length); - png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); - - length = png_strlen(sheight) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_height = (png_charp)png_malloc(png_ptr, length); - png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); - - info_ptr->valid |= PNG_INFO_sCAL; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SCAL; -#endif -} -#endif -#endif -#endif - -#if defined(PNG_pHYs_SUPPORTED) -void PNGAPI -png_set_pHYs(png_structp png_ptr, png_infop info_ptr, - png_uint_32 res_x, png_uint_32 res_y, int unit_type) -{ - png_debug1(1, "in %s storage function\n", "pHYs"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_pixels_per_unit = res_x; - info_ptr->y_pixels_per_unit = res_y; - info_ptr->phys_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_pHYs; -} -#endif - -void PNGAPI -png_set_PLTE(png_structp png_ptr, png_infop info_ptr, - png_colorp palette, int num_palette) -{ - - png_debug1(1, "in %s storage function\n", "PLTE"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* - * It may not actually be necessary to set png_ptr->palette here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - */ -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); -#endif - png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)num_palette, - sizeof (png_color)); - png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color)); - info_ptr->palette = png_ptr->palette; - info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; - -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PLTE; -#else - png_ptr->flags |= PNG_FLAG_FREE_PLTE; -#endif - - info_ptr->valid |= PNG_INFO_PLTE; -} - -#if defined(PNG_sBIT_SUPPORTED) -void PNGAPI -png_set_sBIT(png_structp png_ptr, png_infop info_ptr, - png_color_8p sig_bit) -{ - png_debug1(1, "in %s storage function\n", "sBIT"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_memcpy(&(info_ptr->sig_bit), sig_bit, sizeof (png_color_8)); - info_ptr->valid |= PNG_INFO_sBIT; -} -#endif - -#if defined(PNG_sRGB_SUPPORTED) -void PNGAPI -png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) -{ - png_debug1(1, "in %s storage function\n", "sRGB"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->srgb_intent = (png_byte)intent; - info_ptr->valid |= PNG_INFO_sRGB; -} - -void PNGAPI -png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, - int intent) -{ -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_file_gamma; -#endif -#endif -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, - int_green_y, int_blue_x, int_blue_y; -#endif -#endif - png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_set_sRGB(png_ptr, info_ptr, intent); - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float).45455; - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - int_file_gamma = 45455L; - png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FIXED_POINT_SUPPORTED - int_white_x = 31270L; - int_white_y = 32900L; - int_red_x = 64000L; - int_red_y = 33000L; - int_green_x = 30000L; - int_green_y = 60000L; - int_blue_x = 15000L; - int_blue_y = 6000L; - - png_set_cHRM_fixed(png_ptr, info_ptr, - int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, - int_blue_x, int_blue_y); -#endif -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float).3127; - white_y = (float).3290; - red_x = (float).64; - red_y = (float).33; - green_x = (float).30; - green_y = (float).60; - blue_x = (float).15; - blue_y = (float).06; - - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#endif -} -#endif - - -#if defined(PNG_iCCP_SUPPORTED) -void PNGAPI -png_set_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen) -{ - png_charp new_iccp_name; - png_charp new_iccp_profile; - - png_debug1(1, "in %s storage function\n", "iCCP"); - if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) - return; - - new_iccp_name = (png_charp)png_malloc(png_ptr, png_strlen(name)+1); - png_strcpy(new_iccp_name, name); - new_iccp_profile = (png_charp)png_malloc(png_ptr, proflen); - png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); - - info_ptr->iccp_proflen = proflen; - info_ptr->iccp_name = new_iccp_name; - info_ptr->iccp_profile = new_iccp_profile; - /* Compression is always zero but is here so the API and info structure - * does not have to change if we introduce multiple compression types */ - info_ptr->iccp_compression = (png_byte)compression_type; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_ICCP; -#endif - info_ptr->valid |= PNG_INFO_iCCP; -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) -void PNGAPI -png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) -{ - int i; - - png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? - "text" : (png_const_charp)png_ptr->chunk_name)); - - if (png_ptr == NULL || info_ptr == NULL || num_text == 0) - return; - - /* Make sure we have enough space in the "text" array in info_struct - * to hold all of the incoming text_ptr objects. - */ - if (info_ptr->num_text + num_text > info_ptr->max_text) - { - if (info_ptr->text != NULL) - { - png_textp old_text; - int old_max; - - old_max = info_ptr->max_text; - info_ptr->max_text = info_ptr->num_text + num_text + 8; - old_text = info_ptr->text; - info_ptr->text = (png_textp)png_malloc(png_ptr, - (png_uint_32)(info_ptr->max_text * sizeof (png_text))); - png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * - sizeof(png_text))); - png_free(png_ptr, old_text); - } - else - { - info_ptr->max_text = num_text + 8; - info_ptr->num_text = 0; - info_ptr->text = (png_textp)png_malloc(png_ptr, - (png_uint_32)(info_ptr->max_text * sizeof (png_text))); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TEXT; -#endif - } - png_debug1(3, "allocated %d entries for info_ptr->text\n", - info_ptr->max_text); - } - for (i = 0; i < num_text; i++) - { - png_size_t text_length,key_len; - png_size_t lang_len,lang_key_len; - png_textp textp = &(info_ptr->text[info_ptr->num_text]); - - if (text_ptr[i].key == NULL) - continue; - - key_len = png_strlen(text_ptr[i].key); - - if(text_ptr[i].compression <= 0) - { - lang_len = 0; - lang_key_len = 0; - } - else -#ifdef PNG_iTXt_SUPPORTED - { - /* set iTXt data */ - if (text_ptr[i].key != NULL) - lang_len = png_strlen(text_ptr[i].lang); - else - lang_len = 0; - if (text_ptr[i].lang_key != NULL) - lang_key_len = png_strlen(text_ptr[i].lang_key); - else - lang_key_len = 0; - } -#else - { - png_warning(png_ptr, "iTXt chunk not supported."); - continue; - } -#endif - - if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') - { - text_length = 0; -#ifdef PNG_iTXt_SUPPORTED - if(text_ptr[i].compression > 0) - textp->compression = PNG_ITXT_COMPRESSION_NONE; - else -#endif - textp->compression = PNG_TEXT_COMPRESSION_NONE; - } - else - { - text_length = png_strlen(text_ptr[i].text); - textp->compression = text_ptr[i].compression; - } - - textp->key = (png_charp)png_malloc(png_ptr, - (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); - png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", - (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), - (int)textp->key); - - png_memcpy(textp->key, text_ptr[i].key, - (png_size_t)(key_len)); - *(textp->key+key_len) = '\0'; -#ifdef PNG_iTXt_SUPPORTED - if (text_ptr[i].compression > 0) - { - textp->lang=textp->key + key_len + 1; - png_memcpy(textp->lang, text_ptr[i].lang, lang_len); - *(textp->lang+lang_len) = '\0'; - textp->lang_key=textp->lang + lang_len + 1; - png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); - *(textp->lang_key+lang_key_len) = '\0'; - textp->text=textp->lang_key + lang_key_len + 1; - } - else -#endif - { -#ifdef PNG_iTXt_SUPPORTED - textp->lang=(png_charp)NULL; - textp->lang_key=(png_charp)NULL; -#endif - textp->text=textp->key + key_len + 1; - } - if(text_length) - png_memcpy(textp->text, text_ptr[i].text, - (png_size_t)(text_length)); - *(textp->text+text_length) = '\0'; - -#ifdef PNG_iTXt_SUPPORTED - if(textp->compression > 0) - { - textp->text_length = 0; - textp->itxt_length = text_length; - } - else -#endif - { - textp->text_length = text_length; -#ifdef PNG_iTXt_SUPPORTED - textp->itxt_length = 0; -#endif - } - info_ptr->text[info_ptr->num_text]= *textp; - info_ptr->num_text++; - png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); - } -} -#endif - -#if defined(PNG_tIME_SUPPORTED) -void PNGAPI -png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) -{ - png_debug1(1, "in %s storage function\n", "tIME"); - if (png_ptr == NULL || info_ptr == NULL || - (png_ptr->mode & PNG_WROTE_tIME)) - return; - - png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time)); - info_ptr->valid |= PNG_INFO_tIME; -} -#endif - -#if defined(PNG_tRNS_SUPPORTED) -void PNGAPI -png_set_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep trans, int num_trans, png_color_16p trans_values) -{ - png_debug1(1, "in %s storage function\n", "tRNS"); - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (trans != NULL) - { - /* - * It may not actually be necessary to set png_ptr->trans here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - */ -#ifdef PNG_FREE_ME_SUPPORTED - png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); -#endif - png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, - num_trans); - png_memcpy(info_ptr->trans, trans, num_trans); -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_TRNS; -#else - png_ptr->flags |= PNG_FLAG_FREE_TRNS; -#endif - } - - if (trans_values != NULL) - { - png_memcpy(&(info_ptr->trans_values), trans_values, - sizeof(png_color_16)); - if (num_trans == 0) - num_trans = 1; - } - info_ptr->num_trans = (png_uint_16)num_trans; - info_ptr->valid |= PNG_INFO_tRNS; -} -#endif - -#if defined(PNG_sPLT_SUPPORTED) -void PNGAPI -png_set_sPLT(png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries) -{ - png_sPLT_tp np; - int i; - - np = (png_sPLT_tp)png_malloc(png_ptr, - (info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t)); - - png_memcpy(np, info_ptr->splt_palettes, - info_ptr->splt_palettes_num * sizeof(png_sPLT_t)); - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes=NULL; - - for (i = 0; i < nentries; i++) - { - png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; - png_sPLT_tp from = entries + i; - - to->name = (png_charp)png_malloc(png_ptr, - png_strlen(from->name) + 1); - png_strcpy(to->name, from->name); - to->entries = (png_sPLT_entryp)png_malloc(png_ptr, - from->nentries * sizeof(png_sPLT_t)); - png_memcpy(to->entries, from->entries, - from->nentries * sizeof(png_sPLT_t)); - to->nentries = from->nentries; - to->depth = from->depth; - } - - info_ptr->splt_palettes = np; - info_ptr->splt_palettes_num += nentries; - info_ptr->valid |= PNG_INFO_sPLT; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SPLT; -#endif -} -#endif /* PNG_sPLT_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_unknown_chunks(png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) -{ - png_unknown_chunkp np; - int i; - - if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) - return; - - np = (png_unknown_chunkp)png_malloc(png_ptr, - (info_ptr->unknown_chunks_num + num_unknowns) * - sizeof(png_unknown_chunk)); - - png_memcpy(np, info_ptr->unknown_chunks, - info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk)); - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks=NULL; - - for (i = 0; i < num_unknowns; i++) - { - png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; - png_unknown_chunkp from = unknowns + i; - - png_strcpy((png_charp)to->name, (png_charp)from->name); - to->data = (png_bytep)png_malloc(png_ptr, from->size); - png_memcpy(to->data, from->data, from->size); - to->size = from->size; - - /* note our location in the read or write sequence */ - to->location = (png_byte)(png_ptr->mode & 0xff); - } - - info_ptr->unknown_chunks = np; - info_ptr->unknown_chunks_num += num_unknowns; -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_UNKN; -#endif -} -void PNGAPI -png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, - int chunk, int location) -{ - if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < - (int)info_ptr->unknown_chunks_num) - info_ptr->unknown_chunks[chunk].location = (png_byte)location; -} -#endif - -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -void PNGAPI -png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) -{ - /* This function is deprecated in favor of png_permit_mng_features() - and will be removed from libpng-2.0.0 */ - png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); - if (png_ptr == NULL) - return; - png_ptr->mng_features_permitted = (png_byte) - ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) | - ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); -} -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -png_uint_32 PNGAPI -png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) -{ - png_debug(1, "in png_permit_mng_features\n"); - if (png_ptr == NULL) - return (png_uint_32)0; - png_ptr->mng_features_permitted = - (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); - return (png_uint_32)png_ptr->mng_features_permitted; -} -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -void PNGAPI -png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep - chunk_list, int num_chunks) -{ - png_bytep new_list, p; - int i, old_num_chunks; - if (num_chunks == 0) - { - if(keep == HANDLE_CHUNK_ALWAYS || keep == HANDLE_CHUNK_IF_SAFE) - png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - - if(keep == HANDLE_CHUNK_ALWAYS) - png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; - else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; - return; - } - if (chunk_list == NULL) - return; - old_num_chunks=png_ptr->num_chunk_list; - new_list=(png_bytep)png_malloc(png_ptr,5*(num_chunks+old_num_chunks)); - if(png_ptr->chunk_list != NULL) - { - png_memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks); - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - } - png_memcpy(new_list+5*old_num_chunks, chunk_list, 5*num_chunks); - for (p=new_list+5*old_num_chunks+4, i=0; inum_chunk_list=old_num_chunks+num_chunks; - png_ptr->chunk_list=new_list; -#ifdef PNG_FREE_ME_SUPPORTED - png_ptr->free_me |= PNG_FREE_LIST; -#endif -} -#endif - -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) -void PNGAPI -png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, - png_user_chunk_ptr read_user_chunk_fn) -{ - png_debug(1, "in png_set_read_user_chunk_fn\n"); - png_ptr->read_user_chunk_fn = read_user_chunk_fn; - png_ptr->user_chunk_ptr = user_chunk_ptr; -} -#endif - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) -{ - png_debug1(1, "in %s storage function\n", "rows"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); - info_ptr->row_pointers = row_pointers; - if(row_pointers) - info_ptr->valid |= PNG_INFO_IDAT; -} -#endif - -void PNGAPI -png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) -{ - if(png_ptr->zbuf) - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf_size = (png_size_t)size; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; -} - -void PNGAPI -png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) -{ - if (png_ptr && info_ptr) - info_ptr->valid &= ~(mask); -} - - diff --git a/freeimage241/Source/LibPNG/pngtest.c b/freeimage241/Source/LibPNG/pngtest.c deleted file mode 100644 index 9b954b3..0000000 --- a/freeimage241/Source/LibPNG/pngtest.c +++ /dev/null @@ -1,1514 +0,0 @@ - -/* pngtest.c - a simple test program to test libpng - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This program reads in a PNG image, writes it out again, and then - * compares the two files. If the files are identical, this shows that - * the basic chunk handling, filtering, and (de)compression code is working - * properly. It does not currently test all of the transforms, although - * it probably should. - * - * The program will report "FAIL" in certain legitimate cases: - * 1) when the compression level or filter selection method is changed. - * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192. - * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks - * exist in the input file. - * 4) others not listed here... - * In these cases, it is best to check with another tool such as "pngcheck" - * to see what the differences between the two files are. - * - * If a filename is given on the command-line, then this file is used - * for the input, rather than the default "pngtest.png". This allows - * testing a wide variety of files easily. You can also test a number - * of files at once by typing "pngtest -m file1.png file2.png ..." - */ - -#if defined(_WIN32_WCE) -# if _WIN32_WCE < 211 - __error__ (f|w)printf functions are not supported on old WindowsCE.; -# endif -# include -# include -# define READFILE(file, data, length, check) \ - if (ReadFile(file, data, length, &check,NULL)) check = 0 -# define WRITEFILE(file, data, length, check)) \ - if (WriteFile(file, data, length, &check, NULL)) check = 0 -# define FCLOSE(file) CloseHandle(file) -#else -# include -# include -# include -# define READFILE(file, data, length, check) \ - check=(png_size_t)fread(data,(png_size_t)1,length,file) -# define WRITEFILE(file, data, length, check) \ - check=(png_size_t)fwrite(data,(png_size_t)1, length, file) -# define FCLOSE(file) fclose(file) -#endif - -#if defined(PNG_NO_STDIO) -# if defined(_WIN32_WCE) - typedef HANDLE png_FILE_p; -# else - typedef FILE * png_FILE_p; -# endif -#endif - -/* Makes pngtest verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -# define PNG_DEBUG 0 -#endif - -#if !PNG_DEBUG -# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */ -#endif - -/* Turn on CPU timing -#define PNGTEST_TIMING -*/ - -#ifdef PNG_NO_FLOATING_POINT_SUPPORTED -#undef PNGTEST_TIMING -#endif - -#ifdef PNGTEST_TIMING -static float t_start, t_stop, t_decode, t_encode, t_misc; -#include -#endif - -#include "png.h" - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) png_ptr->jmpbuf -#endif - -#ifdef PNGTEST_TIMING -static float t_start, t_stop, t_decode, t_encode, t_misc; -#if !defined(PNG_tIME_SUPPORTED) -#include -#endif -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -static int tIME_chunk_present=0; -static char tIME_string[30] = "no tIME chunk present in file"; -#endif - -static int verbose = 0; - -int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname)); - -#ifdef __TURBOC__ -#include -#endif - -/* defined so I can write to a file on gui/windowing platforms */ -/* #define STDERR stderr */ -#define STDERR stdout /* for DOS */ - -/* example of using row callbacks to make a simple progress meter */ -static int status_pass=1; -static int status_dots_requested=0; -static int status_dots=1; - -void -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if(png_ptr == NULL || row_number > PNG_MAX_UINT) return; - if(status_pass != pass) - { - fprintf(stdout,"\n Pass %d: ",pass); - status_pass = pass; - status_dots = 31; - } - status_dots--; - if(status_dots == 0) - { - fprintf(stdout, "\n "); - status_dots=30; - } - fprintf(stdout, "r"); -} - -void -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if(png_ptr == NULL || row_number > PNG_MAX_UINT || pass > 7) return; - fprintf(stdout, "w"); -} - - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) -/* Example of using user transform callback (we don't transform anything, - but merely examine the row filters. We set this to 256 rather than - 5 in case illegal filter values are present.) */ -static png_uint_32 filters_used[256]; -void -count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void -count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - if(png_ptr != NULL && row_info != NULL) - ++filters_used[*(data-1)]; -} -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -/* example of using user transform callback (we don't transform anything, - but merely count the zero samples) */ - -static png_uint_32 zero_samples; - -void -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - png_bytep dp = data; - if(png_ptr == NULL)return; - - /* contents of row_info: - * png_uint_32 width width of row - * png_uint_32 rowbytes number of bytes in row - * png_byte color_type color type of pixels - * png_byte bit_depth bit depth of samples - * png_byte channels number of channels (1-4) - * png_byte pixel_depth bits per pixel (depth*channels) - */ - - - /* counts the number of zero samples (or zero pixels if color_type is 3 */ - - if(row_info->color_type == 0 || row_info->color_type == 3) - { - int pos=0; - png_uint_32 n, nstop; - for (n=0, nstop=row_info->width; nbit_depth == 1) - { - if(((*dp << pos++ ) & 0x80) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 2) - { - if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 4) - { - if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++; - if(pos == 8) - { - pos = 0; - dp++; - } - } - if(row_info->bit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) - { - if((*dp | *(dp+1)) == 0) zero_samples++; - dp+=2; - } - } - } - else /* other color types */ - { - png_uint_32 n, nstop; - int channel; - int color_channels = row_info->channels; - if(row_info->color_type > 3)color_channels--; - - for (n=0, nstop=row_info->width; nbit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) - { - if((*dp | *(dp+1)) == 0) zero_samples++; - dp+=2; - } - } - if(row_info->color_type > 3) - { - dp++; - if(row_info->bit_depth == 16)dp++; - } - } - } -} -#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */ - -static int wrote_question = 0; - -#if defined(PNG_NO_STDIO) -/* START of code to validate stdio-free compilation */ -/* These copies of the default read/write functions come from pngrio.c and */ -/* pngwio.c. They allow "don't include stdio" testing of the library. */ -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ - -#ifndef USE_FAR_KEYWORD -static void -pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_size_t check; - - /* fread() returns 0 on error, so it is OK to store this in a png_size_t - * instead of an int, which is what fread() actually returns. - */ - READFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); - - if (check != length) - { - png_error(png_ptr, "Read Error!"); - } -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void -pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - int check; - png_byte *n_data; - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - n_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)n_data == data) - { - READFILE(io_ptr, n_data, length, check); - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t read, remaining, err; - check = 0; - remaining = length; - do - { - read = MIN(NEAR_BUF_SIZE, remaining); - READFILE(io_ptr, buf, 1, err); - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) - break; - else - check += err; - data += read; - remaining -= read; - } - while (remaining != 0); - } - if (check != length) - { - png_error(png_ptr, "read Error"); - } -} -#endif /* USE_FAR_KEYWORD */ - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -static void -pngtest_flush(png_structp png_ptr) -{ -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif -} -#endif - -/* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -static void -pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - - WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void -pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { - WRITEFILE(io_ptr, near_data, length, check); - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ - WRITEFILE(io_ptr, buf, written, err); - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } - if (check != length) - { - png_error(png_ptr, "Write Error"); - } -} - -#endif /* USE_FAR_KEYWORD */ - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void -pngtest_warning(png_structp png_ptr, png_const_charp message) -{ - PNG_CONST char *name = "UNKNOWN (ERROR!)"; - if (png_ptr != NULL && png_ptr->error_ptr != NULL) - name = png_ptr->error_ptr; - fprintf(STDERR, "%s: libpng warning: %s\n", name, message); -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void -pngtest_error(png_structp png_ptr, png_const_charp message) -{ - pngtest_warning(png_ptr, message); - /* We can return because png_error calls the default handler, which is - * actually OK in this case. */ -} -#endif /* PNG_NO_STDIO */ -/* END of code to validate stdio-free compilation */ - -/* START of code to validate memory allocation and deallocation */ -#ifdef PNG_USER_MEM_SUPPORTED - -/* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. - - This piece of code can be compiled to validate max 64K allocations - by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */ -typedef struct memory_information -{ - png_uint_32 size; - png_voidp pointer; - struct memory_information FAR *next; -} memory_information; -typedef memory_information FAR *memory_infop; - -static memory_infop pinformation = NULL; -static int current_allocation = 0; -static int maximum_allocation = 0; -static int total_allocation = 0; -static int num_allocations = 0; - -extern PNG_EXPORT(png_voidp,png_debug_malloc) PNGARG((png_structp png_ptr, - png_uint_32 size)); -extern PNG_EXPORT(void,png_debug_free) PNGARG((png_structp png_ptr, - png_voidp ptr)); - -png_voidp -png_debug_malloc(png_structp png_ptr, png_uint_32 size) -{ - - /* png_malloc has already tested for NULL; png_create_struct calls - png_debug_malloc directly, with png_ptr == NULL which is OK */ - - if (size == 0) - return (png_voidp)(NULL); - - /* This calls the library allocator twice, once to get the requested - buffer and once to get a new free list entry. */ - { - memory_infop pinfo = (memory_infop)png_malloc_default(png_ptr, - sizeof *pinfo); - pinfo->size = size; - current_allocation += size; - total_allocation += size; - num_allocations ++; - if (current_allocation > maximum_allocation) - maximum_allocation = current_allocation; - pinfo->pointer = (png_voidp)png_malloc_default(png_ptr, size); - pinfo->next = pinformation; - pinformation = pinfo; - /* Make sure the caller isn't assuming zeroed memory. */ - png_memset(pinfo->pointer, 0xdd, pinfo->size); -#if PNG_DEBUG - if(verbose) - printf("png_malloc %d bytes at %x\n",size,pinfo->pointer); -#endif - assert(pinfo->size != 12345678); - return (png_voidp)(pinfo->pointer); - } -} - -/* Free a pointer. It is removed from the list at the same time. */ -void -png_debug_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL) - fprintf(STDERR, "NULL pointer to png_debug_free.\n"); - if (ptr == 0) - { -#if 0 /* This happens all the time. */ - fprintf(STDERR, "WARNING: freeing NULL pointer\n"); -#endif - return; - } - - /* Unlink the element from the list. */ - { - memory_infop FAR *ppinfo = &pinformation; - for (;;) - { - memory_infop pinfo = *ppinfo; - if (pinfo->pointer == ptr) - { - *ppinfo = pinfo->next; - current_allocation -= pinfo->size; - if (current_allocation < 0) - fprintf(STDERR, "Duplicate free of memory\n"); - /* We must free the list element too, but first kill - the memory that is to be freed. */ - png_memset(ptr, 0x55, pinfo->size); - png_free_default(png_ptr, pinfo); - pinfo=NULL; - break; - } - if (pinfo->next == NULL) - { - fprintf(STDERR, "Pointer %x not found\n", ptr); - break; - } - ppinfo = &pinfo->next; - } - } - - /* Finally free the data. */ -#if PNG_DEBUG - if(verbose) - printf("Freeing %x\n",ptr); -#endif - png_free_default(png_ptr, ptr); - ptr=NULL; -} -#endif /* PNG_USER_MEM_SUPPORTED */ -/* END of code to test memory allocation/deallocation */ - -/* Test one file */ -int -test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) -{ - static png_FILE_p fpin; - static png_FILE_p fpout; /* "static" prevents setjmp corruption */ - png_structp read_ptr; - png_infop read_info_ptr, end_info_ptr; -#ifdef PNG_WRITE_SUPPORTED - png_structp write_ptr; - png_infop write_info_ptr; - png_infop write_end_info_ptr; -#else - png_structp write_ptr = NULL; - png_infop write_info_ptr = NULL; - png_infop write_end_info_ptr = NULL; -#endif - png_bytep row_buf; - png_uint_32 y; - png_uint_32 width, height; - int num_pass, pass; - int bit_depth, color_type; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - -#if defined(_WIN32_WCE) - TCHAR path[MAX_PATH]; -#endif - char inbuf[256], outbuf[256]; - - row_buf = (png_bytep)NULL; - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpin = fopen(inname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find input file %s\n", inname); - return (1); - } - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpout = fopen(outname, "wb")) == NULL) -#endif - { - fprintf(STDERR, "Could not open output file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - png_debug(0, "Allocating read and write structures\n"); -#ifdef PNG_USER_MEM_SUPPORTED - read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, - (png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); -#else - read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, - (png_error_ptr)NULL, (png_error_ptr)NULL); -#endif -#if defined(PNG_NO_STDIO) - png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, - pngtest_warning); -#endif -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_USER_MEM_SUPPORTED - write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, - (png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); -#else - write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, - (png_error_ptr)NULL, (png_error_ptr)NULL); -#endif -#if defined(PNG_NO_STDIO) - png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, - pngtest_warning); -#endif -#endif - png_debug(0, "Allocating read_info, write_info and end_info structures\n"); - read_info_ptr = png_create_info_struct(read_ptr); - end_info_ptr = png_create_info_struct(read_ptr); -#ifdef PNG_WRITE_SUPPORTED - write_info_ptr = png_create_info_struct(write_ptr); - write_end_info_ptr = png_create_info_struct(write_ptr); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_debug(0, "Setting jmpbuf for read struct\n"); -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_jmpbuf(read_ptr))) -#endif - { - fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf)); -#endif - -#ifdef PNG_WRITE_SUPPORTED - png_debug(0, "Setting jmpbuf for write struct\n"); -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_jmpbuf(write_ptr))) -#endif - { - fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf)); -#endif -#endif -#endif - - png_debug(0, "Initializing input and output streams\n"); -#if !defined(PNG_NO_STDIO) - png_init_io(read_ptr, fpin); -# ifdef PNG_WRITE_SUPPORTED - png_init_io(write_ptr, fpout); -# endif -#else - png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); -# ifdef PNG_WRITE_SUPPORTED - png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, -# if defined(PNG_WRITE_FLUSH_SUPPORTED) - pngtest_flush); -# else - NULL); -# endif -# endif -#endif - if(status_dots_requested == 1) - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, write_row_callback); -#endif - png_set_read_status_fn(read_ptr, read_row_callback); - } - else - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, NULL); -#endif - png_set_read_status_fn(read_ptr, NULL); - } - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - { - int i; - for(i=0; i<256; i++) - filters_used[i]=0; - png_set_read_user_transform_fn(read_ptr, count_filters); - } -#endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - zero_samples=0; - png_set_write_user_transform_fn(write_ptr, count_zero_samples); -#endif - -#define HANDLE_CHUNK_IF_SAFE 2 -#define HANDLE_CHUNK_ALWAYS 3 -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - png_set_keep_unknown_chunks(read_ptr, HANDLE_CHUNK_ALWAYS, NULL, 0); -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_IF_SAFE, NULL, 0); -#endif - - png_debug(0, "Reading info struct\n"); - png_read_info(read_ptr, read_info_ptr); - - png_debug(0, "Transferring info struct\n"); - { - int interlace_type, compression_type, filter_type; - - if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, - &color_type, &interlace_type, &compression_type, &filter_type)) - { - png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - color_type, interlace_type, compression_type, filter_type); -#else - color_type, PNG_INTERLACE_NONE, compression_type, filter_type); -#endif - } - } -#if defined(PNG_FIXED_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) - { - png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y)) - { - png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#if defined(PNG_gAMA_SUPPORTED) - { - png_fixed_point gamma; - - if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) - { - png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); - } - } -#endif -#else /* Use floating point versions */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) - { - double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y)) - { - png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#if defined(PNG_gAMA_SUPPORTED) - { - double gamma; - - if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) - { - png_set_gAMA(write_ptr, write_info_ptr, gamma); - } - } -#endif -#endif /* floating point */ -#endif /* fixed point */ -#if defined(PNG_iCCP_SUPPORTED) - { - png_charp name; - png_charp profile; - png_uint_32 proflen; - int compression_type; - - if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type, - &profile, &proflen)) - { - png_set_iCCP(write_ptr, write_info_ptr, name, compression_type, - profile, proflen); - } - } -#endif -#if defined(PNG_sRGB_SUPPORTED) - { - int intent; - - if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) - { - png_set_sRGB(write_ptr, write_info_ptr, intent); - } - } -#endif - { - png_colorp palette; - int num_palette; - - if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) - { - png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); - } - } -#if defined(PNG_bKGD_SUPPORTED) - { - png_color_16p background; - - if (png_get_bKGD(read_ptr, read_info_ptr, &background)) - { - png_set_bKGD(write_ptr, write_info_ptr, background); - } - } -#endif -#if defined(PNG_hIST_SUPPORTED) - { - png_uint_16p hist; - - if (png_get_hIST(read_ptr, read_info_ptr, &hist)) - { - png_set_hIST(write_ptr, write_info_ptr, hist); - } - } -#endif -#if defined(PNG_oFFs_SUPPORTED) - { - png_int_32 offset_x, offset_y; - int unit_type; - - if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type)) - { - png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); - } - } -#endif -#if defined(PNG_pCAL_SUPPORTED) - { - png_charp purpose, units; - png_charpp params; - png_int_32 X0, X1; - int type, nparams; - - if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type, - &nparams, &units, ¶ms)) - { - png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type, - nparams, units, params); - } - } -#endif -#if defined(PNG_pHYs_SUPPORTED) - { - png_uint_32 res_x, res_y; - int unit_type; - - if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) - { - png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); - } - } -#endif -#if defined(PNG_sBIT_SUPPORTED) - { - png_color_8p sig_bit; - - if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) - { - png_set_sBIT(write_ptr, write_info_ptr, sig_bit); - } - } -#endif -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED - { - int unit; - double scal_width, scal_height; - - if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height)) - { - png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - { - int unit; - png_charp scal_width, scal_height; - - if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height)) - { - png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#endif -#endif -#endif -#if defined(PNG_TEXT_SUPPORTED) - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) - { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); - png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); - } - } -#endif -#if defined(PNG_tIME_SUPPORTED) - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, read_info_ptr, &mod_time)) - { - png_set_tIME(write_ptr, write_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_strcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ - png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); - tIME_chunk_present++; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } -#endif -#if defined(PNG_tRNS_SUPPORTED) - { - png_bytep trans; - int num_trans; - png_color_16p trans_values; - - if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans, - &trans_values)) - { - png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans, - trans_values); - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - { - png_unknown_chunkp unknowns; - int num_unknowns = (int)png_get_unknown_chunks(read_ptr, read_info_ptr, - &unknowns); - if (num_unknowns) - { - png_size_t i; - png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, - num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_info_ptr are wrong because we - haven't written anything yet */ - for (i = 0; i < (png_size_t)num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, - unknowns[i].location); - } - } -#endif - -#ifdef PNG_WRITE_SUPPORTED - png_debug(0, "\nWriting info struct\n"); - -/* If we wanted, we could write info in two steps: - png_write_info_before_PLTE(write_ptr, write_info_ptr); - */ - png_write_info(write_ptr, write_info_ptr); -#endif - -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(0, "\nAllocating row buffer..."); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf); -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(0, "Writing row data\n"); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) - num_pass = png_set_interlace_handling(read_ptr); -# ifdef PNG_WRITE_SUPPORTED - png_set_interlace_handling(write_ptr); -# endif -#else - num_pass=1; -#endif - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; -#endif - for (pass = 0; pass < num_pass; pass++) - { - png_debug1(0, "Writing row data for pass %d\n",pass); - for (y = 0; y < height; y++) - { -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf, - png_get_rowbytes(read_ptr, read_info_ptr)); -#endif /* !SINGLE_ROWBUF_ALLOC */ - png_read_rows(read_ptr, (png_bytepp)&row_buf, (png_bytepp)NULL, 1); - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_decode += (t_stop - t_start); - t_start = t_stop; -#endif - png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_encode += (t_stop - t_start); - t_start = t_stop; -#endif -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y); - png_free(read_ptr, row_buf); -#endif /* !SINGLE_ROWBUF_ALLOC */ - } - } - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1); -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); -#endif - - png_debug(0, "Reading and writing end_info data\n"); - - png_read_end(read_ptr, end_info_ptr); -#if defined(PNG_TEXT_SUPPORTED) - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) - { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); - png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); - } - } -#endif -#if defined(PNG_tIME_SUPPORTED) - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, end_info_ptr, &mod_time)) - { - png_set_tIME(write_ptr, write_end_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_strcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ - png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time)); - tIME_chunk_present++; -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - { - png_unknown_chunkp unknowns; - int num_unknowns; - num_unknowns = (int)png_get_unknown_chunks(read_ptr, end_info_ptr, - &unknowns); - if (num_unknowns) - { - png_size_t i; - png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, - num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_end_info_ptr are wrong because we - haven't written the end_info yet */ - for (i = 0; i < (png_size_t)num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, - unknowns[i].location); - } - } -#endif -#ifdef PNG_WRITE_SUPPORTED - png_write_end(write_ptr, write_end_info_ptr); -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED - if(verbose) - { - png_uint_32 iwidth, iheight; - iwidth = png_get_image_width(write_ptr, write_info_ptr); - iheight = png_get_image_height(write_ptr, write_info_ptr); - fprintf(STDERR, "Image width = %lu, height = %lu\n", - iwidth, iheight); - } -#endif - - png_debug(0, "Destroying data structs\n"); -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(1, "destroying row_buf for read_ptr\n"); - png_free(read_ptr, row_buf); - row_buf=NULL; -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n"); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_debug(1, "destroying write_end_info_ptr\n"); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_debug(1, "destroying write_ptr, write_info_ptr\n"); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - png_debug(0, "Destruction complete.\n"); - - FCLOSE(fpin); - FCLOSE(fpout); - - png_debug(0, "Opening files for comparison\n"); -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpin = fopen(inname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find file %s\n", inname); - return (1); - } - -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else - if ((fpout = fopen(outname, "rb")) == NULL) -#endif - { - fprintf(STDERR, "Could not find file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - for(;;) - { - png_size_t num_in, num_out; - - READFILE(fpin, inbuf, 1, num_in); - READFILE(fpout, outbuf, 1, num_out); - - if (num_in != num_out) - { - fprintf(STDERR, "\nFiles %s and %s are of a different size\n", - inname, outname); - if(wrote_question == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question=1; - } - FCLOSE(fpin); - FCLOSE(fpout); - return (0); - } - - if (!num_in) - break; - - if (png_memcmp(inbuf, outbuf, num_in)) - { - fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname); - if(wrote_question == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question=1; - } - FCLOSE(fpin); - FCLOSE(fpout); - return (0); - } - } - - FCLOSE(fpin); - FCLOSE(fpout); - - return (0); -} - -/* input and output filenames */ -#ifdef RISCOS -static PNG_CONST char *inname = "pngtest/png"; -static PNG_CONST char *outname = "pngout/png"; -#else -static PNG_CONST char *inname = "pngtest.png"; -static PNG_CONST char *outname = "pngout.png"; -#endif - -int -main(int argc, char *argv[]) -{ - int multiple = 0; - int ierror = 0; - - fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); - fprintf(STDERR,"%s",png_get_copyright(NULL)); - /* Show the version of libpng used in building the library */ - fprintf(STDERR," library (%lu):%s", png_access_version_number(), - png_get_header_version(NULL)); - /* Show the version of libpng used in building the application */ - fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, - PNG_HEADER_VERSION_STRING); - fprintf(STDERR," sizeof(png_struct)=%d, sizeof(png_info)=%d\n", - sizeof(png_struct), sizeof(png_info)); - - /* Do some consistency checking on the memory allocation settings, I'm - not sure this matters, but it is nice to know, the first of these - tests should be impossible because of the way the macros are set - in pngconf.h */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); -#endif - /* I think the following can happen. */ -#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n"); -#endif - - if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) - { - fprintf(STDERR, - "Warning: versions are different between png.h and png.c\n"); - fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver); - ++ierror; - } - - if (argc > 1) - { - if (strcmp(argv[1], "-m") == 0) - { - multiple = 1; - status_dots_requested = 0; - } - else if (strcmp(argv[1], "-mv") == 0 || - strcmp(argv[1], "-vm") == 0 ) - { - multiple = 1; - verbose = 1; - status_dots_requested = 1; - } - else if (strcmp(argv[1], "-v") == 0) - { - verbose = 1; - status_dots_requested = 1; - inname = argv[2]; - } - else - { - inname = argv[1]; - status_dots_requested = 0; - } - } - - if (!multiple && argc == 3+verbose) - outname = argv[2+verbose]; - - if ((!multiple && argc > 3+verbose) || (multiple && argc < 2)) - { - fprintf(STDERR, - "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n", - argv[0], argv[0]); - fprintf(STDERR, - " reads/writes one PNG file (without -m) or multiple files (-m)\n"); - fprintf(STDERR, - " with -m %s is used as a temporary file\n", outname); - exit(1); - } - - if (multiple) - { - int i; -#ifdef PNG_USER_MEM_SUPPORTED - int allocation_now = current_allocation; -#endif - for (i=2; isize, pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#ifdef PNG_USER_MEM_SUPPORTED - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - else - { - int i; - for (i=0; i<3; ++i) - { - int kerror; -#ifdef PNG_USER_MEM_SUPPORTED - int allocation_now = current_allocation; -#endif - if (i == 1) status_dots_requested = 1; - else if(verbose == 0)status_dots_requested = 0; - if (i == 0 || verbose == 1 || ierror != 0) - fprintf(STDERR, "Testing %s:",inname); - kerror = test_one_file(inname, outname); - if(kerror == 0) - { - if(verbose == 1 || i == 2) - { -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - int k; -#endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples); -#else - fprintf(STDERR, " PASS\n"); -#endif -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - for (k=0; k<256; k++) - if(filters_used[k]) - fprintf(STDERR, " Filter %d was used %lu times\n", - k,filters_used[k]); -#endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) - if(tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n",tIME_string); -#endif /* PNG_TIME_RFC1123_SUPPORTED */ - } - } - else - { - if(verbose == 0 && i != 2) - fprintf(STDERR, "Testing %s:",inname); - fprintf(STDERR, " FAIL\n"); - ierror += kerror; - } -#ifdef PNG_USER_MEM_SUPPORTED - if (allocation_now != current_allocation) - fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation-allocation_now); - if (current_allocation != 0) - { - memory_infop pinfo = pinformation; - - fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", - current_allocation); - while (pinfo != NULL) - { - fprintf(STDERR," %d bytes at %x\n", - pinfo->size, pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#ifdef PNG_USER_MEM_SUPPORTED - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; - fprintf(STDERR," CPU time used = %.3f seconds", - (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); - fprintf(STDERR," (decoding %.3f,\n", - t_decode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," encoding %.3f ,", - t_encode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," other %.3f seconds)\n\n", - t_misc/(float)CLOCKS_PER_SEC); -#endif - - if (ierror == 0) - fprintf(STDERR, "libpng passes test\n"); - else - fprintf(STDERR, "libpng FAILS test\n"); - return (int)(ierror != 0); -} - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_0_12 your_png_h_is_not_version_1_0_12; diff --git a/freeimage241/Source/LibPNG/pngtrans.c b/freeimage241/Source/LibPNG/pngtrans.c deleted file mode 100644 index 3e757c1..0000000 --- a/freeimage241/Source/LibPNG/pngtrans.c +++ /dev/null @@ -1,611 +0,0 @@ - -/* pngtrans.c - transforms the data in a row (used by both readers and writers) - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* turn on BGR-to-RGB mapping */ -void PNGAPI -png_set_bgr(png_structp png_ptr) -{ - png_debug(1, "in png_set_bgr\n"); - png_ptr->transformations |= PNG_BGR; -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* turn on 16 bit byte swapping */ -void PNGAPI -png_set_swap(png_structp png_ptr) -{ - png_debug(1, "in png_set_swap\n"); - if (png_ptr->bit_depth == 16) - png_ptr->transformations |= PNG_SWAP_BYTES; -} -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* turn on pixel packing */ -void PNGAPI -png_set_packing(png_structp png_ptr) -{ - png_debug(1, "in png_set_packing\n"); - if (png_ptr->bit_depth < 8) - { - png_ptr->transformations |= PNG_PACK; - png_ptr->usr_bit_depth = 8; - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* turn on packed pixel swapping */ -void PNGAPI -png_set_packswap(png_structp png_ptr) -{ - png_debug(1, "in png_set_packswap\n"); - if (png_ptr->bit_depth < 8) - png_ptr->transformations |= PNG_PACKSWAP; -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -void PNGAPI -png_set_shift(png_structp png_ptr, png_color_8p true_bits) -{ - png_debug(1, "in png_set_shift\n"); - png_ptr->transformations |= PNG_SHIFT; - png_ptr->shift = *true_bits; -} -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -int PNGAPI -png_set_interlace_handling(png_structp png_ptr) -{ - png_debug(1, "in png_set_interlace handling\n"); - if (png_ptr->interlaced) - { - png_ptr->transformations |= PNG_INTERLACE; - return (7); - } - - return (1); -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte on read, or remove a filler or alpha byte on write. - * The filler type has changed in v0.95 to allow future 2-byte fillers - * for 48-bit input data, as well as to avoid problems with some compilers - * that don't like bytes as parameters. - */ -void PNGAPI -png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) -{ - png_debug(1, "in png_set_filler\n"); - png_ptr->transformations |= PNG_FILLER; - png_ptr->filler = (png_byte)filler; - if (filler_loc == PNG_FILLER_AFTER) - png_ptr->flags |= PNG_FLAG_FILLER_AFTER; - else - png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; - - /* This should probably go in the "do_filler" routine. - * I attempted to do that in libpng-1.0.1a but that caused problems - * so I restored it in libpng-1.0.2a - */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_ptr->usr_channels = 4; - } - - /* Also I added this in libpng-1.0.2a (what happens when we expand - * a less-than-8-bit grayscale to GA? */ - - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) - { - png_ptr->usr_channels = 2; - } -} -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void PNGAPI -png_set_swap_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_swap_alpha\n"); - png_ptr->transformations |= PNG_SWAP_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void PNGAPI -png_set_invert_alpha(png_structp png_ptr) -{ - png_debug(1, "in png_set_invert_alpha\n"); - png_ptr->transformations |= PNG_INVERT_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -void PNGAPI -png_set_invert_mono(png_structp png_ptr) -{ - png_debug(1, "in png_set_invert_mono\n"); - png_ptr->transformations |= PNG_INVERT_MONO; -} - -/* invert monochrome grayscale data */ -void /* PRIVATE */ -png_do_invert(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_invert\n"); - if (row_info->bit_depth == 1 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(~(*rp)); - rp++; - } - } -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* swaps byte order on 16 bit depth images */ -void /* PRIVATE */ -png_do_swap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_swap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth == 16) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop= row_info->width * row_info->channels; - - for (i = 0; i < istop; i++, rp += 2) - { - png_byte t = *rp; - *rp = *(rp + 1); - *(rp + 1) = t; - } - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -static png_byte onebppswaptable[256] = { - 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, - 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, - 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, - 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, - 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, - 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, - 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, - 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, - 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, - 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, - 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, - 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, - 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, - 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, - 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, - 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, - 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, - 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, - 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, - 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, - 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, - 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, - 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, - 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, - 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, - 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, - 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, - 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, - 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, - 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, - 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, - 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF -}; - -static png_byte twobppswaptable[256] = { - 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, - 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, - 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, - 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4, - 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8, - 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, - 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC, - 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC, - 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1, - 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1, - 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5, - 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5, - 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9, - 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9, - 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD, - 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD, - 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2, - 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2, - 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6, - 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6, - 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA, - 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA, - 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE, - 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE, - 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3, - 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3, - 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7, - 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7, - 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB, - 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, - 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF, - 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF -}; - -static png_byte fourbppswaptable[256] = { - 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, - 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, - 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, - 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, - 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, - 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, - 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, - 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, - 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, - 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, - 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, - 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, - 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, - 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, - 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, - 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, - 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, - 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, - 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, - 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, - 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, - 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, - 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, - 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, - 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, - 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, - 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, - 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, - 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, - 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, - 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, - 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF -}; - -/* swaps pixel packing order within bytes */ -void /* PRIVATE */ -png_do_packswap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_packswap\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->bit_depth < 8) - { - png_bytep rp, end, table; - - end = row + row_info->rowbytes; - - if (row_info->bit_depth == 1) - table = onebppswaptable; - else if (row_info->bit_depth == 2) - table = twobppswaptable; - else if (row_info->bit_depth == 4) - table = fourbppswaptable; - else - return; - - for (rp = row; rp < end; rp++) - *rp = table[*rp]; - } -} -#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -/* remove filler or alpha byte(s) */ -void /* PRIVATE */ -png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) -{ - png_debug(1, "in png_do_strip_filler\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { -/* - if (row_info->color_type == PNG_COLOR_TYPE_RGB || - row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) -*/ - png_bytep sp=row; - png_bytep dp=row; - png_uint_32 row_width=row_info->width; - png_uint_32 i; - - if (row_info->channels == 4) - { - if (row_info->bit_depth == 8) - { - /* This converts from RGBX or RGBA to RGB */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - dp+=3; sp+=4; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp++; - } - } - /* This converts from XRGB or ARGB to RGB */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */ - sp += 8; dp += 6; - for (i = 1; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ - for (i = 0; i < row_width; i++) - { - /* This could be (although png_memcpy is probably slower): - png_memcpy(dp, sp, 6); - sp += 8; - dp += 6; - */ - - sp+=2; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 48; - row_info->rowbytes = row_width * 6; - } - row_info->channels = 3; - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - } -/* - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY || - row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) -*/ - else if (row_info->channels == 2) - { - if (row_info->bit_depth == 8) - { - /* This converts from GX or GA to G */ - if (flags & PNG_FLAG_FILLER_AFTER) - { - for (i = 0; i < row_width; i++) - { - *dp++ = *sp++; - sp++; - } - } - /* This converts from XG or AG to G */ - else - { - for (i = 0; i < row_width; i++) - { - sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - else /* if (row_info->bit_depth == 16) */ - { - if (flags & PNG_FLAG_FILLER_AFTER) - { - /* This converts from GGXX or GGAA to GG */ - sp += 4; dp += 2; - for (i = 1; i < row_width; i++) - { - *dp++ = *sp++; - *dp++ = *sp++; - sp += 2; - } - } - else - { - /* This converts from XXGG or AAGG to GG */ - for (i = 0; i < row_width; i++) - { - sp += 2; - *dp++ = *sp++; - *dp++ = *sp++; - } - } - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - row_info->channels = 1; - row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; - } - } -} -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* swaps red and blue bytes within a pixel */ -void /* PRIVATE */ -png_do_bgr(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_bgr\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 3) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 4) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - } - else if (row_info->bit_depth == 16) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 6) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 8) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - } - } -} -#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -void PNGAPI -png_set_user_transform_info(png_structp png_ptr, png_voidp - user_transform_ptr, int user_transform_depth, int user_transform_channels) -{ - png_debug(1, "in png_set_user_transform_info\n"); -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - png_ptr->user_transform_ptr = user_transform_ptr; - png_ptr->user_transform_depth = (png_byte)user_transform_depth; - png_ptr->user_transform_channels = (png_byte)user_transform_channels; -#else - if(user_transform_ptr || user_transform_depth || user_transform_channels) - png_warning(png_ptr, - "This version of libpng does not support user transform info"); -#endif -} -#endif - -/* This function returns a pointer to the user_transform_ptr associated with - * the user transform functions. The application should free any memory - * associated with this pointer before png_write_destroy and png_read_destroy - * are called. - */ -png_voidp PNGAPI -png_get_user_transform_ptr(png_structp png_ptr) -{ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - return ((png_voidp)png_ptr->user_transform_ptr); -#else - if(png_ptr) - return (NULL); - return (NULL); -#endif -} - diff --git a/freeimage241/Source/LibPNG/pngvcrd.c b/freeimage241/Source/LibPNG/pngvcrd.c deleted file mode 100644 index f464f34..0000000 --- a/freeimage241/Source/LibPNG/pngvcrd.c +++ /dev/null @@ -1,3836 +0,0 @@ -/* pngvcrd.c - mixed C/assembler version of utilities to read a PNG file - * - * For Intel x86 CPU and Microsoft Visual C++ compiler - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * Copyright (c) 1998, Intel Corporation - * - * Contributed by Nirav Chhatrapati, Intel Corporation, 1998 - * Interface to libpng contributed by Gilles Vollant, 1999 - * Debugging and cleanup by Greg Roelofs, 2000, 2001 - * - * In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d, - * a sign error in the post-MMX cleanup code for each pixel_depth resulted - * in bad pixels at the beginning of some rows of some images, and also - * (due to out-of-range memory reads and writes) caused heap corruption - * when compiled with MSVC 6.0. The error was fixed in version 1.0.4e. - * - * [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916] - * - */ - -#define PNG_INTERNAL -#include "png.h" - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD) - -static int mmx_supported=2; - - -int PNGAPI -png_mmx_support(void) -{ - int mmx_supported_local = 0; - _asm { - push ebx //CPUID will trash these - push ecx - push edx - pushfd //Save Eflag to stack - pop eax //Get Eflag from stack into eax - mov ecx, eax //Make another copy of Eflag in ecx - xor eax, 0x200000 //Toggle ID bit in Eflag [i.e. bit(21)] - push eax //Save modified Eflag back to stack - - popfd //Restored modified value back to Eflag reg - pushfd //Save Eflag to stack - pop eax //Get Eflag from stack - xor eax, ecx //Compare the new Eflag with the original Eflag - jz NOT_SUPPORTED //If the same, CPUID instruction is not supported, - //skip following instructions and jump to - //NOT_SUPPORTED label - - xor eax, eax //Set eax to zero - - _asm _emit 0x0f //CPUID instruction (two bytes opcode) - _asm _emit 0xa2 - - cmp eax, 1 //make sure eax return non-zero value - jl NOT_SUPPORTED //If eax is zero, mmx not supported - - xor eax, eax //set eax to zero - inc eax //Now increment eax to 1. This instruction is - //faster than the instruction "mov eax, 1" - - _asm _emit 0x0f //CPUID instruction - _asm _emit 0xa2 - - and edx, 0x00800000 //mask out all bits but mmx bit(24) - cmp edx, 0 // 0 = mmx not supported - jz NOT_SUPPORTED // non-zero = Yes, mmx IS supported - - mov mmx_supported_local, 1 //set return value to 1 - -NOT_SUPPORTED: - mov eax, mmx_supported_local //move return value to eax - pop edx //CPUID trashed these - pop ecx - pop ebx - } - - //mmx_supported_local=0; // test code for force don't support MMX - //printf("MMX : %u (1=MMX supported)\n",mmx_supported_local); - - mmx_supported = mmx_supported_local; - return mmx_supported_local; -} - -/* Combines the row recently read in with the previous row. - This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined; a - zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ - -/* Use this routine for x86 platform - uses faster MMX routine if machine - supports MMX */ - -void /* PRIVATE */ -png_combine_row(png_structp png_ptr, png_bytep row, int mask) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_combine_row_asm\n"); - - if (mmx_supported == 2) { - png_mmx_support(); - } - - if (mask == 0xff) - { - png_memcpy(row, png_ptr->row_buf + 1, - (png_size_t)((png_ptr->width * png_ptr->row_info.pixel_depth + 7) >> 3)); - } - /* GRR: add "else if (mask == 0)" case? - * or does png_combine_row() not even get called in that case? */ - else - { - switch (png_ptr->row_info.pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - int s_inc, s_start, s_end; - int m; - int shift; - png_uint_32 i; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 7; - s_inc = 1; - } - else -#endif - { - s_start = 7; - s_end = 0; - s_inc = -1; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - int value; - - value = (*sp >> shift) & 0x1; - *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 2: - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 6; - s_inc = 2; - } - else -#endif - { - s_start = 6; - s_end = 0; - s_inc = -2; - } - - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0x3; - *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 4: - { - png_bytep sp; - png_bytep dp; - int s_start, s_end, s_inc; - int m; - int shift; - png_uint_32 i; - int value; - - sp = png_ptr->row_buf + 1; - dp = row; - m = 0x80; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - { - s_start = 0; - s_end = 4; - s_inc = 4; - } - else -#endif - { - s_start = 4; - s_end = 0; - s_inc = -4; - } - shift = s_start; - - for (i = 0; i < png_ptr->width; i++) - { - if (m & mask) - { - value = (*sp >> shift) & 0xf; - *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); - *dp |= (png_byte)(value << shift); - } - - if (shift == s_end) - { - shift = s_start; - sp++; - dp++; - } - else - shift += s_inc; - if (m == 1) - m = 0x80; - else - m >>= 1; - } - break; - } - - case 8: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int m; - int diff, unmask; - - __int64 mask0=0x0102040810204080; - - if ( mmx_supported ) - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - m = 0x80; - unmask = ~mask; - len = png_ptr->width &~7; //reduce to multiple of 8 - diff = png_ptr->width & 7; //amount lost - - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - - pand mm0,mm7 //nonzero if keep byte - pcmpeqb mm0,mm6 //zeros->1s, v versa - - mov ecx,len //load length of line (pixels) - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 //lcr - je mainloop8end - -mainloop8: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - pandn mm6,[ebx] - por mm4,mm6 - movq [ebx],mm4 - - add esi,8 //inc by 8 bytes processed - add ebx,8 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop8 -mainloop8end: - - mov ecx,diff - cmp ecx,0 - jz end8 - - mov edx,mask - sal edx,24 //make low byte the high byte - -secondloop8: - sal edx,1 //move high bit to CF - jnc skip8 //if CF = 0 - mov al,[esi] - mov [ebx],al -skip8: - inc esi - inc ebx - - dec ecx - jnz secondloop8 -end8: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 8 bpp - - case 16: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - __int64 mask1=0x0101020204040808, - mask0=0x1010202040408080; - - if ( mmx_supported ) - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - - pand mm0,mm7 - pand mm1,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 //lcr - jz mainloop16end - -mainloop16: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - add esi,16 //inc by 16 bytes processed - add ebx,16 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop16 - -mainloop16end: - mov ecx,diff - cmp ecx,0 - jz end16 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop16: - sal edx,1 //move high bit to CF - jnc skip16 //if CF = 0 - mov ax,[esi] - mov [ebx],ax -skip16: - add esi,2 - add ebx,2 - - dec ecx - jnz secondloop16 -end16: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 16 bpp - - case 24: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask2=0x0101010202020404, //24bpp - mask1=0x0408080810101020, - mask0=0x2020404040808080; - - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - - if ( mmx_supported ) - { - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - cmp ecx,0 - jz mainloop24end - -mainloop24: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm4,mm2 - movq mm7,[ebx+16] - pandn mm4,mm7 - por mm6,mm4 - movq [ebx+16],mm6 - - add esi,24 //inc by 24 bytes processed - add ebx,24 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop24 - -mainloop24end: - mov ecx,diff - cmp ecx,0 - jz end24 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop24: - sal edx,1 //move high bit to CF - jnc skip24 //if CF = 0 - mov ax,[esi] - mov [ebx],ax - xor eax,eax - mov al,[esi+2] - mov [ebx+2],al -skip24: - add esi,3 - add ebx,3 - - dec ecx - jnz secondloop24 - -end24: - emms - } - } - else /* mmx not supported - use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 24 bpp - - case 32: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask3=0x0101010102020202, //32bpp - mask2=0x0404040408080808, - mask1=0x1010101020202020, - mask0=0x4040404080808080; - - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - - if ( mmx_supported ) - { - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - movq mm3,mask3 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - pand mm3,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - pcmpeqb mm3,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - - cmp ecx,0 //lcr - jz mainloop32end - -mainloop32: - movq mm4,[esi] - pand mm4,mm0 - movq mm6,mm0 - movq mm7,[ebx] - pandn mm6,mm7 - por mm4,mm6 - movq [ebx],mm4 - - movq mm5,[esi+8] - pand mm5,mm1 - movq mm7,mm1 - movq mm6,[ebx+8] - pandn mm7,mm6 - por mm5,mm7 - movq [ebx+8],mm5 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm4,mm2 - movq mm7,[ebx+16] - pandn mm4,mm7 - por mm6,mm4 - movq [ebx+16],mm6 - - movq mm7,[esi+24] - pand mm7,mm3 - movq mm5,mm3 - movq mm4,[ebx+24] - pandn mm5,mm4 - por mm7,mm5 - movq [ebx+24],mm7 - - add esi,32 //inc by 32 bytes processed - add ebx,32 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop32 - -mainloop32end: - mov ecx,diff - cmp ecx,0 - jz end32 - - mov edx,mask - sal edx,24 //make low byte the high byte -secondloop32: - sal edx,1 //move high bit to CF - jnc skip32 //if CF = 0 - mov eax,[esi] - mov [ebx],eax -skip32: - add esi,4 - add ebx,4 - - dec ecx - jnz secondloop32 - -end32: - emms - } - } - else /* mmx _not supported - Use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 32 bpp - - case 48: - { - png_bytep srcptr; - png_bytep dstptr; - png_uint_32 len; - int unmask, diff; - - __int64 mask5=0x0101010101010202, - mask4=0x0202020204040404, - mask3=0x0404080808080808, - mask2=0x1010101010102020, - mask1=0x2020202040404040, - mask0=0x4040808080808080; - - if ( mmx_supported ) - { - srcptr = png_ptr->row_buf + 1; - dstptr = row; - - unmask = ~mask; - len = (png_ptr->width)&~7; - diff = (png_ptr->width)&7; - _asm - { - movd mm7, unmask //load bit pattern - psubb mm6,mm6 //zero mm6 - punpcklbw mm7,mm7 - punpcklwd mm7,mm7 - punpckldq mm7,mm7 //fill register with 8 masks - - movq mm0,mask0 - movq mm1,mask1 - movq mm2,mask2 - movq mm3,mask3 - movq mm4,mask4 - movq mm5,mask5 - - pand mm0,mm7 - pand mm1,mm7 - pand mm2,mm7 - pand mm3,mm7 - pand mm4,mm7 - pand mm5,mm7 - - pcmpeqb mm0,mm6 - pcmpeqb mm1,mm6 - pcmpeqb mm2,mm6 - pcmpeqb mm3,mm6 - pcmpeqb mm4,mm6 - pcmpeqb mm5,mm6 - - mov ecx,len //load length of line - mov esi,srcptr //load source - mov ebx,dstptr //load dest - - cmp ecx,0 - jz mainloop48end - -mainloop48: - movq mm7,[esi] - pand mm7,mm0 - movq mm6,mm0 - pandn mm6,[ebx] - por mm7,mm6 - movq [ebx],mm7 - - movq mm6,[esi+8] - pand mm6,mm1 - movq mm7,mm1 - pandn mm7,[ebx+8] - por mm6,mm7 - movq [ebx+8],mm6 - - movq mm6,[esi+16] - pand mm6,mm2 - movq mm7,mm2 - pandn mm7,[ebx+16] - por mm6,mm7 - movq [ebx+16],mm6 - - movq mm7,[esi+24] - pand mm7,mm3 - movq mm6,mm3 - pandn mm6,[ebx+24] - por mm7,mm6 - movq [ebx+24],mm7 - - movq mm6,[esi+32] - pand mm6,mm4 - movq mm7,mm4 - pandn mm7,[ebx+32] - por mm6,mm7 - movq [ebx+32],mm6 - - movq mm7,[esi+40] - pand mm7,mm5 - movq mm6,mm5 - pandn mm6,[ebx+40] - por mm7,mm6 - movq [ebx+40],mm7 - - add esi,48 //inc by 32 bytes processed - add ebx,48 - sub ecx,8 //dec by 8 pixels processed - - ja mainloop48 -mainloop48end: - - mov ecx,diff - cmp ecx,0 - jz end48 - - mov edx,mask - sal edx,24 //make low byte the high byte - -secondloop48: - sal edx,1 //move high bit to CF - jnc skip48 //if CF = 0 - mov eax,[esi] - mov [ebx],eax -skip48: - add esi,4 - add ebx,4 - - dec ecx - jnz secondloop48 - -end48: - emms - } - } - else /* mmx _not supported - Use modified C routine */ - { - register unsigned int incr1, initial_val, final_val; - png_size_t pixel_bytes; - png_uint_32 i; - register int disp = png_pass_inc[png_ptr->pass]; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); - png_memcpy(dstptr, srcptr, pixel_bytes); - srcptr += incr1; - dstptr += incr1; - } - } /* end of else */ - - break; - } // end 48 bpp - - default: - { - png_bytep sptr; - png_bytep dp; - png_size_t pixel_bytes; - int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; - unsigned int i; - register int disp = png_pass_inc[png_ptr->pass]; // get the offset - register unsigned int incr1, initial_val, final_val; - - pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); - sptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* - pixel_bytes; - dp = row + offset_table[png_ptr->pass]*pixel_bytes; - initial_val = offset_table[png_ptr->pass]*pixel_bytes; - final_val = png_ptr->width*pixel_bytes; - incr1 = (disp)*pixel_bytes; - for (i = initial_val; i < final_val; i += incr1) - { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); - png_memcpy(dp, sptr, pixel_bytes); - sptr += incr1; - dp += incr1; - } - break; - } - } /* end switch (png_ptr->row_info.pixel_depth) */ - } /* end if (non-trivial mask) */ - -} /* end png_combine_row() */ - - -#if defined(PNG_READ_INTERLACING_SUPPORTED) - -void /* PRIVATE */ -png_do_read_interlace(png_structp png_ptr) -{ - png_row_infop row_info = &(png_ptr->row_info); - png_bytep row = png_ptr->row_buf + 1; - int pass = png_ptr->pass; - png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS - const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1,"in png_do_read_interlace\n"); - - if (mmx_supported == 2) { - png_mmx_support(); - } - - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_byte v; - png_uint_32 i; - int j; - - sp = row + (png_size_t)((row_info->width - 1) >> 3); - dp = row + (png_size_t)((final_width - 1) >> 3); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); - s_start = 7; - s_end = 0; - s_inc = -1; - } - else -#endif - { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = row_info->width; i; i--) - { - v = (png_byte)((*sp >> sshift) & 0x1); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 2: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - else -#endif - { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - case 4: - { - png_bytep sp, dp; - int sshift, dshift; - int s_start, s_end, s_inc; - png_uint_32 i; - - sp = row + (png_size_t)((row_info->width - 1) >> 1); - dp = row + (png_size_t)((final_width - 1) >> 1); -#if defined(PNG_READ_PACKSWAP_SUPPORTED) - if (transformations & PNG_PACKSWAP) - { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - else -#endif - { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = row_info->width; i; i--) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0xf); - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); - *dp |= (png_byte)(v << dshift); - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - else - dshift += s_inc; - } - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - else - sshift += s_inc; - } - break; - } - - default: // This is the place where the routine is modified - { - __int64 const4 = 0x0000000000FFFFFF; - // __int64 const5 = 0x000000FFFFFF0000; // unused... - __int64 const6 = 0x00000000000000FF; - png_bytep sptr, dp; - png_uint_32 i; - png_size_t pixel_bytes; - int width = row_info->width; - - pixel_bytes = (row_info->pixel_depth >> 3); - - sptr = row + (width - 1) * pixel_bytes; - dp = row + (final_width - 1) * pixel_bytes; - // New code by Nirav Chhatrapati - Intel Corporation - // sign fix by GRR - // NOTE: there is NO MMX code for 48-bit and 64-bit images - - // use MMX routine if machine supports it - if ( mmx_supported ) - { - if (pixel_bytes == 3) - { - if (((pass == 0) || (pass == 1)) && width) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width - sub edi, 21 // (png_pass_inc[pass] - 1)*pixel_bytes -loop_pass0: - movd mm0, [esi] ; X X X X X v2 v1 v0 - pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 - movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 - psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 - movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 - psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 - psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 - por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 - por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 - movq mm3, mm0 ; v2 v1 v0 v2 v1 v0 v2 v1 - psllq mm0, 16 ; v0 v2 v1 v0 v2 v1 0 0 - movq mm4, mm3 ; v2 v1 v0 v2 v1 v0 v2 v1 - punpckhdq mm3, mm0 ; v0 v2 v1 v0 v2 v1 v0 v2 - movq [edi+16] , mm4 - psrlq mm0, 32 ; 0 0 0 0 v0 v2 v1 v0 - movq [edi+8] , mm3 - punpckldq mm0, mm4 ; v1 v0 v2 v1 v0 v2 v1 v0 - sub esi, 3 - movq [edi], mm0 - sub edi, 24 - //sub esi, 3 - dec ecx - jnz loop_pass0 - EMMS - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width - sub edi, 9 // (png_pass_inc[pass] - 1)*pixel_bytes -loop_pass2: - movd mm0, [esi] ; X X X X X v2 v1 v0 - pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 - movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 - psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 - movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 - psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 - psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 - por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 - por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 - movq [edi+4], mm0 ; move to memory - psrlq mm0, 16 ; 0 0 v2 v1 v0 v2 v1 v0 - movd [edi], mm0 ; move to memory - sub esi, 3 - sub edi, 12 - dec ecx - jnz loop_pass2 - EMMS - } - } - else if (width) /* && ((pass == 4) || (pass == 5)) */ - { - int width_mmx = ((width >> 1) << 1) - 8; - if (width_mmx < 0) - width_mmx = 0; - width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 3 - sub edi, 9 -loop_pass4: - movq mm0, [esi] ; X X v2 v1 v0 v5 v4 v3 - movq mm7, mm0 ; X X v2 v1 v0 v5 v4 v3 - movq mm6, mm0 ; X X v2 v1 v0 v5 v4 v3 - psllq mm0, 24 ; v1 v0 v5 v4 v3 0 0 0 - pand mm7, const4 ; 0 0 0 0 0 v5 v4 v3 - psrlq mm6, 24 ; 0 0 0 X X v2 v1 v0 - por mm0, mm7 ; v1 v0 v5 v4 v3 v5 v4 v3 - movq mm5, mm6 ; 0 0 0 X X v2 v1 v0 - psllq mm6, 8 ; 0 0 X X v2 v1 v0 0 - movq [edi], mm0 ; move quad to memory - psrlq mm5, 16 ; 0 0 0 0 0 X X v2 - pand mm5, const6 ; 0 0 0 0 0 0 0 v2 - por mm6, mm5 ; 0 0 X X v2 v1 v0 v2 - movd [edi+8], mm6 ; move double to memory - sub esi, 6 - sub edi, 12 - sub ecx, 2 - jnz loop_pass4 - EMMS - } - } - - sptr -= width_mmx*3; - dp -= width_mmx*6; - for (i = width; i; i--) - { - png_byte v[8]; - int j; - - png_memcpy(v, sptr, 3); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 3); - dp -= 3; - } - sptr -= 3; - } - } - } /* end of pixel_bytes == 3 */ - - else if (pixel_bytes == 1) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 31 - sub esi, 3 -loop1_pass0: - movd mm0, [esi] ; X X X X v0 v1 v2 v3 - movq mm1, mm0 ; X X X X v0 v1 v2 v3 - punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - movq mm2, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - movq mm3, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - punpckldq mm0, mm0 ; v3 v3 v3 v3 v3 v3 v3 v3 - punpckhdq mm3, mm3 ; v2 v2 v2 v2 v2 v2 v2 v2 - movq [edi], mm0 ; move to memory v3 - punpckhwd mm2, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 - movq [edi+8], mm3 ; move to memory v2 - movq mm4, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 - punpckldq mm2, mm2 ; v1 v1 v1 v1 v1 v1 v1 v1 - punpckhdq mm4, mm4 ; v0 v0 v0 v0 v0 v0 v0 v0 - movq [edi+16], mm2 ; move to memory v1 - movq [edi+24], mm4 ; move to memory v0 - sub esi, 4 - sub edi, 32 - sub ecx, 4 - jnz loop1_pass0 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*8; - for (i = width; i; i--) - { - int j; - - /* I simplified this part in version 1.0.4e - * here and in several other instances where - * pixel_bytes == 1 -- GR-P - * - * Original code: - * - * png_byte v[8]; - * png_memcpy(v, sptr, pixel_bytes); - * for (j = 0; j < png_pass_inc[pass]; j++) - * { - * png_memcpy(dp, v, pixel_bytes); - * dp -= pixel_bytes; - * } - * sptr -= pixel_bytes; - * - * Replacement code is in the next three lines: - */ - - for (j = 0; j < png_pass_inc[pass]; j++) - *dp-- = *sptr; - sptr--; - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 2) << 2); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 15 - sub esi, 3 -loop1_pass2: - movd mm0, [esi] ; X X X X v0 v1 v2 v3 - punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 - punpckhwd mm1, mm1 ; v0 v0 v0 v0 v1 v1 v1 v1 - movq [edi], mm0 ; move to memory v2 and v3 - sub esi, 4 - movq [edi+8], mm1 ; move to memory v1 and v0 - sub edi, 16 - sub ecx, 4 - jnz loop1_pass2 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*4; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - sptr --; - } - } - else if (width) /* && ((pass == 4) || (pass == 5))) */ - { - int width_mmx = ((width >> 3) << 3); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub edi, 15 - sub esi, 7 -loop1_pass4: - movq mm0, [esi] ; v0 v1 v2 v3 v4 v5 v6 v7 - movq mm1, mm0 ; v0 v1 v2 v3 v4 v5 v6 v7 - punpcklbw mm0, mm0 ; v4 v4 v5 v5 v6 v6 v7 v7 - //movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 - punpckhbw mm1, mm1 ;v0 v0 v1 v1 v2 v2 v3 v3 - movq [edi+8], mm1 ; move to memory v0 v1 v2 and v3 - sub esi, 8 - movq [edi], mm0 ; move to memory v4 v5 v6 and v7 - //sub esi, 4 - sub edi, 16 - sub ecx, 8 - jnz loop1_pass4 - EMMS - } - } - - sptr -= width_mmx; - dp -= width_mmx*2; - for (i = width; i; i--) - { - int j; - - for (j = 0; j < png_pass_inc[pass]; j++) - { - *dp-- = *sptr; - } - sptr --; - } - } - } /* end of pixel_bytes == 1 */ - - else if (pixel_bytes == 2) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1); - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 30 -loop2_pass0: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 - punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi + 16], mm1 - movq [edi + 24], mm1 - sub esi, 4 - sub edi, 32 - sub ecx, 2 - jnz loop2_pass0 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*16 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 14 -loop2_pass2: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 - punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 - movq [edi], mm0 - sub esi, 4 - movq [edi + 8], mm1 - //sub esi, 4 - sub edi, 16 - sub ecx, 2 - jnz loop2_pass2 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*8 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 2 - sub edi, 6 -loop2_pass4: - movd mm0, [esi] ; X X X X v1 v0 v3 v2 - punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 - sub esi, 4 - movq [edi], mm0 - sub edi, 8 - sub ecx, 2 - jnz loop2_pass4 - EMMS - } - } - - sptr -= (width_mmx*2 - 2); // sign fixed - dp -= (width_mmx*4 - 2); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 2; - png_memcpy(v, sptr, 2); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 2; - png_memcpy(dp, v, 2); - } - } - } - } /* end of pixel_bytes == 2 */ - - else if (pixel_bytes == 4) - { - if (((pass == 0) || (pass == 1)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 60 -loop4_pass0: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi + 16], mm0 - movq [edi + 24], mm0 - movq [edi+32], mm1 - movq [edi + 40], mm1 - movq [edi+ 48], mm1 - sub esi, 8 - movq [edi + 56], mm1 - sub edi, 64 - sub ecx, 2 - jnz loop4_pass0 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*32 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (((pass == 2) || (pass == 3)) && width) - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 28 -loop4_pass2: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - movq [edi + 8], mm0 - movq [edi+16], mm1 - movq [edi + 24], mm1 - sub esi, 8 - sub edi, 32 - sub ecx, 2 - jnz loop4_pass2 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*16 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - else if (width) // pass == 4 or 5 - { - int width_mmx = ((width >> 1) << 1) ; - width -= width_mmx; - if (width_mmx) - { - _asm - { - mov esi, sptr - mov edi, dp - mov ecx, width_mmx - sub esi, 4 - sub edi, 12 -loop4_pass4: - movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 - movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 - punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 - punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 - movq [edi], mm0 - sub esi, 8 - movq [edi + 8], mm1 - sub edi, 16 - sub ecx, 2 - jnz loop4_pass4 - EMMS - } - } - - sptr -= (width_mmx*4 - 4); // sign fixed - dp -= (width_mmx*8 - 4); // sign fixed - for (i = width; i; i--) - { - png_byte v[8]; - int j; - sptr -= 4; - png_memcpy(v, sptr, 4); - for (j = 0; j < png_pass_inc[pass]; j++) - { - dp -= 4; - png_memcpy(dp, v, 4); - } - } - } - - } /* end of pixel_bytes == 4 */ - - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, 6); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, 6); - dp -= 6; - } - sptr -= 6; - } - } /* end of pixel_bytes == 6 */ - - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr-= pixel_bytes; - } - } - } /* end of mmx_supported */ - - else /* MMX not supported: use modified C code - takes advantage - * of inlining of png_memcpy for a constant */ - { - if (pixel_bytes == 1) - { - for (i = width; i; i--) - { - int j; - for (j = 0; j < png_pass_inc[pass]; j++) - *dp-- = *sptr; - sptr--; - } - } - else if (pixel_bytes == 3) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 2) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 4) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else if (pixel_bytes == 6) - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - else - { - for (i = width; i; i--) - { - png_byte v[8]; - int j; - png_memcpy(v, sptr, pixel_bytes); - for (j = 0; j < png_pass_inc[pass]; j++) - { - png_memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - sptr -= pixel_bytes; - } - } - - } /* end of MMX not supported */ - break; - } - } /* end switch (row_info->pixel_depth) */ - - row_info->width = final_width; - row_info->rowbytes = ((final_width * - (png_uint_32)row_info->pixel_depth + 7) >> 3); - } - -} - -#endif /* PNG_READ_INTERLACING_SUPPORTED */ - - -// These variables are utilized in the functions below. They are declared -// globally here to ensure alignment on 8-byte boundaries. - -union uAll { - __int64 use; - double align; -} LBCarryMask = {0x0101010101010101}, - HBClearMask = {0x7f7f7f7f7f7f7f7f}, - ActiveMask, ActiveMask2, ActiveMaskEnd, ShiftBpp, ShiftRem; - - -// Optimized code for PNG Average filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row - , png_bytep prev_row) -{ - int bpp; - png_uint_32 FullLength; - png_uint_32 MMXLength; - //png_uint_32 len; - int diff; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes; // # of bytes to filter - _asm { - // Init address pointers and offset - mov edi, row // edi ==> Avg(x) - xor ebx, ebx // ebx ==> x - mov edx, edi - mov esi, prev_row // esi ==> Prior(x) - sub edx, bpp // edx ==> Raw(x-bpp) - - xor eax, eax - // Compute the Raw value for the first bpp bytes - // Raw(x) = Avg(x) + (Prior(x)/2) -davgrlp: - mov al, [esi + ebx] // Load al with Prior(x) - inc ebx - shr al, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, bpp - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davgrlp - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, ebx // add bpp - add diff, 0xf // add 7 + 8 to incr past alignment boundary - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value ebx at alignment - jz davggo - // fix alignment - // Compute the Raw value for the bytes upto the alignment boundary - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor ecx, ecx -davglp1: - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, diff // Check if at alignment boundary - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davglp1 // Repeat until at alignment boundary -davggo: - mov eax, FullLength - mov ecx, eax - sub eax, ebx // subtract alignment fix - and eax, 0x00000007 // calc bytes over mult of 8 - sub ecx, eax // drop over bytes from original length - mov MMXLength, ecx - } // end _asm block - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000000000ffffff; - ShiftBpp.use = 24; // == 3 * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm { - // Re-init address pointers and offset - movq mm7, ActiveMask - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg3lp: - movq mm0, [edi + ebx] // Load mm0 with Avg(x) - // Add (Prev_row/2) to Average - movq mm3, mm5 - psrlq mm2, ShiftRem // Correct position Raw(x-bpp) data - movq mm1, [esi + ebx] // Load mm1 with Prior(x) - movq mm6, mm7 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 3-5 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // Add 3rd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover the last two - // bytes - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - add ebx, 8 - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Move updated Raw(x) to use as Raw(x-bpp) for next loop - cmp ebx, MMXLength - movq mm2, mm0 // mov updated Raw(x) to mm2 - jb davg3lp - } // end _asm block - } - break; - - case 6: - case 4: - case 7: - case 5: - { - ActiveMask.use = 0xffffffffffffffff; // use shift below to clear - // appropriate inactive bytes - ShiftBpp.use = bpp << 3; - ShiftRem.use = 64 - ShiftBpp.use; - _asm { - movq mm4, HBClearMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - // Load ActiveMask and clear all bytes except for 1st active group - movq mm7, ActiveMask - mov edi, row // edi ==> Avg(x) - psrlq mm7, ShiftRem - mov esi, prev_row // esi ==> Prior(x) - movq mm6, mm7 - movq mm5, LBCarryMask - psllq mm6, ShiftBpp // Create mask for 2nd active group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg4lp: - movq mm0, [edi + ebx] - psrlq mm2, ShiftRem // shift data to position correctly - movq mm1, [esi + ebx] - // Add (Prev_row/2) to Average - movq mm3, mm5 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm7 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - add ebx, 8 - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active - // byte - cmp ebx, MMXLength - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Prep Raw(x-bpp) for next loop - movq mm2, mm0 // mov updated Raws to mm2 - jb davg4lp - } // end _asm block - } - break; - case 2: - { - ActiveMask.use = 0x000000000000ffff; - ShiftBpp.use = 16; // == 2 * 8 [BUGFIX] - ShiftRem.use = 48; // == 64 - 16 [BUGFIX] - _asm { - // Load ActiveMask - movq mm7, ActiveMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (we correct position in loop below) -davg2lp: - movq mm0, [edi + ebx] - psrlq mm2, ShiftRem // shift data to position correctly [BUGFIX] - movq mm1, [esi + ebx] - // Add (Prev_row/2) to Average - movq mm3, mm5 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - movq mm6, mm7 - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 2 & 3 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - // Add rdd active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 4 & 5 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - // Add 4th active group (Raw(x-bpp)/2) to Average with LBCarry - psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 6 & 7 - movq mm2, mm0 // mov updated Raws to mm2 - psllq mm2, ShiftBpp // shift data to position correctly - // Data only needs to be shifted once here to - // get the correct x-bpp offset. - add ebx, 8 - movq mm1, mm3 // now use mm1 for getting LBCarrys - pand mm1, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 (Only valid for active group) - psrlq mm2, 1 // divide raw bytes by 2 - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte - pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg - paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte - - cmp ebx, MMXLength - // Now ready to write back to memory - movq [edi + ebx - 8], mm0 - // Prep Raw(x-bpp) for next loop - movq mm2, mm0 // mov updated Raws to mm2 - jb davg2lp - } // end _asm block - } - break; - - case 1: // bpp == 1 - { - _asm { - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - mov edi, row // edi ==> Avg(x) - cmp ebx, FullLength // Test if offset at end of array - jnb davg1end - // Do Paeth decode for remaining bytes - mov esi, prev_row // esi ==> Prior(x) - mov edx, edi - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // edx ==> Raw(x-bpp) -davg1lp: - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, FullLength // Check if at end of array - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davg1lp -davg1end: - } // end _asm block - } - return; - - case 8: // bpp == 8 - { - _asm { - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - movq mm5, LBCarryMask - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov esi, prev_row // esi ==> Prior(x) - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes - // (NO NEED to correct position in loop below) -davg8lp: - movq mm0, [edi + ebx] - movq mm3, mm5 - movq mm1, [esi + ebx] - add ebx, 8 - pand mm3, mm1 // get lsb for each prev_row byte - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm3, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 - psrlq mm2, 1 // divide raw bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm3 // add LBCarrys to Avg for each byte - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - paddb mm0, mm2 // add (Raw/2) to Avg for each byte - cmp ebx, MMXLength - movq [edi + ebx - 8], mm0 - movq mm2, mm0 // reuse as Raw(x-bpp) - jb davg8lp - } // end _asm block - } - break; - default: // bpp greater than 8 - { - _asm { - movq mm5, LBCarryMask - // Re-init address pointers and offset - mov ebx, diff // ebx ==> x = offset to alignment boundary - mov edi, row // edi ==> Avg(x) - movq mm4, HBClearMask - mov edx, edi - mov esi, prev_row // esi ==> Prior(x) - sub edx, bpp // edx ==> Raw(x-bpp) -davgAlp: - movq mm0, [edi + ebx] - movq mm3, mm5 - movq mm1, [esi + ebx] - pand mm3, mm1 // get lsb for each prev_row byte - movq mm2, [edx + ebx] - psrlq mm1, 1 // divide prev_row bytes by 2 - pand mm3, mm2 // get LBCarrys for each byte where both - // lsb's were == 1 - psrlq mm2, 1 // divide raw bytes by 2 - pand mm1, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm3 // add LBCarrys to Avg for each byte - pand mm2, mm4 // clear invalid bit 7 of each byte - paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte - add ebx, 8 - paddb mm0, mm2 // add (Raw/2) to Avg for each byte - cmp ebx, MMXLength - movq [edi + ebx - 8], mm0 - jb davgAlp - } // end _asm block - } - break; - } // end switch ( bpp ) - - _asm { - // MMX acceleration complete now do clean-up - // Check if any remaining bytes left to decode - mov ebx, MMXLength // ebx ==> x = offset bytes remaining after MMX - mov edi, row // edi ==> Avg(x) - cmp ebx, FullLength // Test if offset at end of array - jnb davgend - // Do Paeth decode for remaining bytes - mov esi, prev_row // esi ==> Prior(x) - mov edx, edi - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // edx ==> Raw(x-bpp) -davglp2: - // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) - xor eax, eax - mov cl, [esi + ebx] // load cl with Prior(x) - mov al, [edx + ebx] // load al with Raw(x-bpp) - add ax, cx - inc ebx - shr ax, 1 // divide by 2 - add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx - cmp ebx, FullLength // Check if at end of array - mov [edi+ebx-1], al // Write back Raw(x); - // mov does not affect flags; -1 to offset inc ebx - jb davglp2 -davgend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Paeth filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 FullLength; - png_uint_32 MMXLength; - //png_uint_32 len; - int bpp; - int diff; - //int ptemp; - int patemp, pbtemp, pctemp; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes; // # of bytes to filter - _asm - { - xor ebx, ebx // ebx ==> x offset - mov edi, row - xor edx, edx // edx ==> x-bpp offset - mov esi, prev_row - xor eax, eax - - // Compute the Raw value for the first bpp bytes - // Note: the formula works out to be always - // Paeth(x) = Raw(x) + Prior(x) where x < bpp -dpthrlp: - mov al, [edi + ebx] - add al, [esi + ebx] - inc ebx - cmp ebx, bpp - mov [edi + ebx - 1], al - jb dpthrlp - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, ebx // add bpp - xor ecx, ecx - add diff, 0xf // add 7 + 8 to incr past alignment boundary - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value ebx at alignment - jz dpthgo - // fix alignment -dpthlp1: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthpca - neg eax // reverse sign of neg values -dpthpca: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthpba - neg ecx // reverse sign of neg values -dpthpba: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthpaa - neg eax // reverse sign of neg values -dpthpaa: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthabb - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthbbc - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth -dpthbbc: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthpaeth -dpthabb: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthabc - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth -dpthabc: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthpaeth: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, diff - jb dpthlp1 -dpthgo: - mov ecx, FullLength - mov eax, ecx - sub eax, ebx // subtract alignment fix - and eax, 0x00000007 // calc bytes over mult of 8 - sub ecx, eax // drop over bytes from original length - mov MMXLength, ecx - } // end _asm block - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000000000ffffff; - ActiveMaskEnd.use = 0xffff000000000000; - ShiftBpp.use = 24; // == bpp(3) * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm - { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dpth3lp: - psrlq mm1, ShiftRem // shift last 3 bytes to 1st 3 bytes - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm1, mm0 // Unpack High bytes of a - movq mm3, [esi+ebx-8] // Prep c=Prior(x-bpp) bytes - punpcklbw mm2, mm0 // Unpack High bytes of b - psrlq mm3, ShiftRem // shift last 3 bytes to 1st 3 bytes - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx] // load c=Prior(x-bpp) - pand mm7, ActiveMask - movq mm2, mm3 // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpcklbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) - // Now do Paeth for 2nd set of bytes (3-5) - psrlq mm2, ShiftBpp // load b=Prior(x) step 2 - punpcklbw mm1, mm0 // Unpack High bytes of a - pxor mm7, mm7 - punpcklbw mm2, mm0 // Unpack High bytes of b - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - psubw mm5, mm3 - psubw mm4, mm3 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = - // pav + pbv = pbv + pav - movq mm6, mm5 - paddw mm6, mm4 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm5 // Create mask pbv bytes < 0 - pcmpgtw mm7, mm4 // Create mask pav bytes < 0 - pand mm0, mm5 // Only pbv bytes < 0 in mm0 - pand mm7, mm4 // Only pav bytes < 0 in mm7 - psubw mm5, mm0 - psubw mm4, mm7 - psubw mm5, mm0 - psubw mm4, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - movq mm2, [esi + ebx] // load b=Prior(x) - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, mm2 // load c=Prior(x-bpp) step 1 - pand mm7, ActiveMask - punpckhbw mm2, mm0 // Unpack High bytes of b - psllq mm7, ShiftBpp // Shift bytes to 2nd group of 3 bytes - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - psllq mm3, ShiftBpp // load c=Prior(x-bpp) step 2 - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 - punpckhbw mm3, mm0 // Unpack High bytes of c - psllq mm1, ShiftBpp // Shift bytes - // Now mm1 will be used as Raw(x-bpp) - // Now do Paeth for 3rd, and final, set of bytes (6-7) - pxor mm7, mm7 - punpckhbw mm1, mm0 // Unpack High bytes of a - psubw mm4, mm3 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - pxor mm0, mm0 - paddw mm6, mm5 - - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - pandn mm0, mm1 - pandn mm7, mm4 - paddw mm0, mm2 - paddw mm7, mm5 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm1, mm1 - packuswb mm1, mm7 - // Step ebx to next set of 8 bytes and repeat loop til done - add ebx, 8 - pand mm1, ActiveMaskEnd - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - - cmp ebx, MMXLength - pxor mm0, mm0 // pxor does not affect flags - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - // mm3 ready to be used as Prior(x-bpp) next loop - jb dpth3lp - } // end _asm block - } - break; - - case 6: - case 7: - case 5: - { - ActiveMask.use = 0x00000000ffffffff; - ActiveMask2.use = 0xffffffff00000000; - ShiftBpp.use = bpp << 3; // == bpp * 8 - ShiftRem.use = 64 - ShiftBpp.use; - _asm - { - mov ebx, diff - mov edi, row - mov esi, prev_row - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] - pxor mm0, mm0 -dpth6lp: - // Must shift to position Raw(x-bpp) data - psrlq mm1, ShiftRem - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpcklbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack Low bytes of b - // Must shift to position Prior(x-bpp) data - psrlq mm3, ShiftRem - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx - 8] // load c=Prior(x-bpp) - pand mm7, ActiveMask - psrlq mm3, ShiftRem - movq mm2, [esi + ebx] // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - movq mm6, mm2 - movq [edi + ebx], mm7 // write back updated value - movq mm1, [edi+ebx-8] - psllq mm6, ShiftBpp - movq mm5, mm7 - psrlq mm1, ShiftRem - por mm3, mm6 - psllq mm5, ShiftBpp - punpckhbw mm3, mm0 // Unpack High bytes of c - por mm1, mm5 - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack High bytes of b - punpckhbw mm1, mm0 // Unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth6lp - } // end _asm block - } - break; - - case 4: - { - ActiveMask.use = 0x00000000ffffffff; - _asm { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] // Only time should need to read - // a=Raw(x-bpp) bytes -dpth4lp: - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpckhbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack High bytes of b - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpckhbw mm3, mm0 // Unpack High bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi + ebx] // load c=Prior(x-bpp) - pand mm7, ActiveMask - movq mm2, mm3 // load b=Prior(x) step 1 - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpcklbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack Low bytes of b - punpcklbw mm1, mm0 // Unpack Low bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth4lp - } // end _asm block - } - break; - case 8: // bpp == 8 - { - ActiveMask.use = 0x00000000ffffffff; - _asm { - mov ebx, diff - mov edi, row - mov esi, prev_row - pxor mm0, mm0 - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] // Only time should need to read - // a=Raw(x-bpp) bytes -dpth8lp: - // Do first set of 4 bytes - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - punpcklbw mm1, mm0 // Unpack Low bytes of a - movq mm2, [esi + ebx] // load b=Prior(x) - punpcklbw mm2, mm0 // Unpack Low bytes of b - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - punpcklbw mm3, mm0 // Unpack Low bytes of c - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - paddw mm7, mm3 - pxor mm0, mm0 - packuswb mm7, mm1 - movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes - pand mm7, ActiveMask - movq mm2, [esi + ebx] // load b=Prior(x) - paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) - punpckhbw mm3, mm0 // Unpack High bytes of c - movq [edi + ebx], mm7 // write back updated value - movq mm1, [edi+ebx-8] // read a=Raw(x-bpp) bytes - - // Do second set of 4 bytes - punpckhbw mm2, mm0 // Unpack High bytes of b - punpckhbw mm1, mm0 // Unpack High bytes of a - // pav = p - a = (a + b - c) - a = b - c - movq mm4, mm2 - // pbv = p - b = (a + b - c) - b = a - c - movq mm5, mm1 - psubw mm4, mm3 - pxor mm7, mm7 - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - movq mm6, mm4 - psubw mm5, mm3 - // pa = abs(p-a) = abs(pav) - // pb = abs(p-b) = abs(pbv) - // pc = abs(p-c) = abs(pcv) - pcmpgtw mm0, mm4 // Create mask pav bytes < 0 - paddw mm6, mm5 - pand mm0, mm4 // Only pav bytes < 0 in mm7 - pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 - psubw mm4, mm0 - pand mm7, mm5 // Only pbv bytes < 0 in mm0 - psubw mm4, mm0 - psubw mm5, mm7 - pxor mm0, mm0 - pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 - pand mm0, mm6 // Only pav bytes < 0 in mm7 - psubw mm5, mm7 - psubw mm6, mm0 - // test pa <= pb - movq mm7, mm4 - psubw mm6, mm0 - pcmpgtw mm7, mm5 // pa > pb? - movq mm0, mm7 - // use mm7 mask to merge pa & pb - pand mm5, mm7 - // use mm0 mask copy to merge a & b - pand mm2, mm0 - pandn mm7, mm4 - pandn mm0, mm1 - paddw mm7, mm5 - paddw mm0, mm2 - // test ((pa <= pb)? pa:pb) <= pc - pcmpgtw mm7, mm6 // pab > pc? - pxor mm1, mm1 - pand mm3, mm7 - pandn mm7, mm0 - pxor mm1, mm1 - paddw mm7, mm3 - pxor mm0, mm0 - // Step ex to next set of 8 bytes and repeat loop til done - add ebx, 8 - packuswb mm1, mm7 - paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) - cmp ebx, MMXLength - movq [edi + ebx - 8], mm1 // write back updated value - // mm1 will be used as Raw(x-bpp) next loop - jb dpth8lp - } // end _asm block - } - break; - - case 1: // bpp = 1 - case 2: // bpp = 2 - default: // bpp > 8 - { - _asm { - mov ebx, diff - cmp ebx, FullLength - jnb dpthdend - mov edi, row - mov esi, prev_row - // Do Paeth decode for remaining bytes - mov edx, ebx - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // Set edx = ebx - bpp -dpthdlp: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthdpca - neg eax // reverse sign of neg values -dpthdpca: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthdpba - neg ecx // reverse sign of neg values -dpthdpba: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthdpaa - neg eax // reverse sign of neg values -dpthdpaa: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthdabb - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthdbbc - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthdpaeth -dpthdbbc: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthdpaeth -dpthdabb: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthdabc - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthdpaeth -dpthdabc: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthdpaeth: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, FullLength - jb dpthdlp -dpthdend: - } // end _asm block - } - return; // No need to go further with this one - } // end switch ( bpp ) - _asm - { - // MMX acceleration complete now do clean-up - // Check if any remaining bytes left to decode - mov ebx, MMXLength - cmp ebx, FullLength - jnb dpthend - mov edi, row - mov esi, prev_row - // Do Paeth decode for remaining bytes - mov edx, ebx - xor ecx, ecx // zero ecx before using cl & cx in loop below - sub edx, bpp // Set edx = ebx - bpp -dpthlp2: - xor eax, eax - // pav = p - a = (a + b - c) - a = b - c - mov al, [esi + ebx] // load Prior(x) into al - mov cl, [esi + edx] // load Prior(x-bpp) into cl - sub eax, ecx // subtract Prior(x-bpp) - mov patemp, eax // Save pav for later use - xor eax, eax - // pbv = p - b = (a + b - c) - b = a - c - mov al, [edi + edx] // load Raw(x-bpp) into al - sub eax, ecx // subtract Prior(x-bpp) - mov ecx, eax - // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv - add eax, patemp // pcv = pav + pbv - // pc = abs(pcv) - test eax, 0x80000000 - jz dpthpca2 - neg eax // reverse sign of neg values -dpthpca2: - mov pctemp, eax // save pc for later use - // pb = abs(pbv) - test ecx, 0x80000000 - jz dpthpba2 - neg ecx // reverse sign of neg values -dpthpba2: - mov pbtemp, ecx // save pb for later use - // pa = abs(pav) - mov eax, patemp - test eax, 0x80000000 - jz dpthpaa2 - neg eax // reverse sign of neg values -dpthpaa2: - mov patemp, eax // save pa for later use - // test if pa <= pb - cmp eax, ecx - jna dpthabb2 - // pa > pb; now test if pb <= pc - cmp ecx, pctemp - jna dpthbbc2 - // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth2 -dpthbbc2: - // pb <= pc; Raw(x) = Paeth(x) + Prior(x) - mov cl, [esi + ebx] // load Prior(x) into cl - jmp dpthpaeth2 -dpthabb2: - // pa <= pb; now test if pa <= pc - cmp eax, pctemp - jna dpthabc2 - // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) - mov cl, [esi + edx] // load Prior(x-bpp) into cl - jmp dpthpaeth2 -dpthabc2: - // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) - mov cl, [edi + edx] // load Raw(x-bpp) into cl -dpthpaeth2: - inc ebx - inc edx - // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 - add [edi + ebx - 1], cl - cmp ebx, FullLength - jb dpthlp2 -dpthend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Sub filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) -{ - //int test; - int bpp; - png_uint_32 FullLength; - png_uint_32 MMXLength; - int diff; - - bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel - FullLength = row_info->rowbytes - bpp; // # of bytes to filter - _asm { - mov edi, row - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - xor eax, eax - // get # of bytes to alignment - mov diff, edi // take start of row - add diff, 0xf // add 7 + 8 to incr past - // alignment boundary - xor ebx, ebx - and diff, 0xfffffff8 // mask to alignment boundary - sub diff, edi // subtract from start ==> value - // ebx at alignment - jz dsubgo - // fix alignment -dsublp1: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, diff - jb dsublp1 -dsubgo: - mov ecx, FullLength - mov edx, ecx - sub edx, ebx // subtract alignment fix - and edx, 0x00000007 // calc bytes over mult of 8 - sub ecx, edx // drop over bytes from length - mov MMXLength, ecx - } // end _asm block - - // Now do the math for the rest of the row - switch ( bpp ) - { - case 3: - { - ActiveMask.use = 0x0000ffffff000000; - ShiftBpp.use = 24; // == 3 * 8 - ShiftRem.use = 40; // == 64 - 24 - _asm { - mov edi, row - movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - movq mm6, mm7 - mov ebx, diff - psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active - // byte group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub3lp: - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive bytes - // Add 1st active group - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm7 // mask to use only 2nd active group - paddb mm0, mm1 - // Add 3rd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm6 // mask to use only 3rd active group - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // Write updated Raws back to array - // Prep for doing 1st add at top of loop - movq mm1, mm0 - jb dsub3lp - } // end _asm block - } - break; - - case 1: - { - // Placed here just in case this is a duplicate of the - // non-MMX code for the SUB filter in png_read_filter_row below - // - // png_bytep rp; - // png_bytep lp; - // png_uint_32 i; - // bpp = (row_info->pixel_depth + 7) >> 3; - // for (i = (png_uint_32)bpp, rp = row + bpp, lp = row; - // i < row_info->rowbytes; i++, rp++, lp++) - // { - // *rp = (png_byte)(((int)(*rp) + (int)(*lp)) & 0xff); - // } - _asm { - mov ebx, diff - mov edi, row - cmp ebx, FullLength - jnb dsub1end - mov esi, edi // lp = row - xor eax, eax - add edi, bpp // rp = row + bpp -dsub1lp: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, FullLength - jb dsub1lp -dsub1end: - } // end _asm block - } - return; - - case 6: - case 7: - case 4: - case 5: - { - ShiftBpp.use = bpp << 3; - ShiftRem.use = 64 - ShiftBpp.use; - _asm { - mov edi, row - mov ebx, diff - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub4lp: - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive bytes - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - // there is no need for any mask - // since shift clears inactive bits/bytes - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 - movq mm1, mm0 // Prep for doing 1st add at top of loop - jb dsub4lp - } // end _asm block - } - break; - - case 2: - { - ActiveMask.use = 0x00000000ffff0000; - ShiftBpp.use = 16; // == 2 * 8 - ShiftRem.use = 48; // == 64 - 16 - _asm { - movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group - mov ebx, diff - movq mm6, mm7 - mov edi, row - psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active - // byte group - mov esi, edi // lp = row - movq mm5, mm6 - add edi, bpp // rp = row + bpp - psllq mm5, ShiftBpp // Move mask in mm5 to cover 4th active - // byte group - // PRIME the pump (load the first Raw(x-bpp) data set - movq mm1, [edi+ebx-8] -dsub2lp: - // Add 1st active group - psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes - // no need for mask; shift clears inactive - // bytes - movq mm0, [edi+ebx] - paddb mm0, mm1 - // Add 2nd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm7 // mask to use only 2nd active group - paddb mm0, mm1 - // Add 3rd active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm6 // mask to use only 3rd active group - paddb mm0, mm1 - // Add 4th active group - movq mm1, mm0 // mov updated Raws to mm1 - psllq mm1, ShiftBpp // shift data to position correctly - pand mm1, mm5 // mask to use only 4th active group - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // Write updated Raws back to array - movq mm1, mm0 // Prep for doing 1st add at top of loop - jb dsub2lp - } // end _asm block - } - break; - case 8: - { - _asm { - mov edi, row - mov ebx, diff - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp - mov ecx, MMXLength - movq mm7, [edi+ebx-8] // PRIME the pump (load the first - // Raw(x-bpp) data set - and ecx, 0x0000003f // calc bytes over mult of 64 -dsub8lp: - movq mm0, [edi+ebx] // Load Sub(x) for 1st 8 bytes - paddb mm0, mm7 - movq mm1, [edi+ebx+8] // Load Sub(x) for 2nd 8 bytes - movq [edi+ebx], mm0 // Write Raw(x) for 1st 8 bytes - // Now mm0 will be used as Raw(x-bpp) for - // the 2nd group of 8 bytes. This will be - // repeated for each group of 8 bytes with - // the 8th group being used as the Raw(x-bpp) - // for the 1st group of the next loop. - paddb mm1, mm0 - movq mm2, [edi+ebx+16] // Load Sub(x) for 3rd 8 bytes - movq [edi+ebx+8], mm1 // Write Raw(x) for 2nd 8 bytes - paddb mm2, mm1 - movq mm3, [edi+ebx+24] // Load Sub(x) for 4th 8 bytes - movq [edi+ebx+16], mm2 // Write Raw(x) for 3rd 8 bytes - paddb mm3, mm2 - movq mm4, [edi+ebx+32] // Load Sub(x) for 5th 8 bytes - movq [edi+ebx+24], mm3 // Write Raw(x) for 4th 8 bytes - paddb mm4, mm3 - movq mm5, [edi+ebx+40] // Load Sub(x) for 6th 8 bytes - movq [edi+ebx+32], mm4 // Write Raw(x) for 5th 8 bytes - paddb mm5, mm4 - movq mm6, [edi+ebx+48] // Load Sub(x) for 7th 8 bytes - movq [edi+ebx+40], mm5 // Write Raw(x) for 6th 8 bytes - paddb mm6, mm5 - movq mm7, [edi+ebx+56] // Load Sub(x) for 8th 8 bytes - movq [edi+ebx+48], mm6 // Write Raw(x) for 7th 8 bytes - add ebx, 64 - paddb mm7, mm6 - cmp ebx, ecx - movq [edi+ebx-8], mm7 // Write Raw(x) for 8th 8 bytes - jb dsub8lp - cmp ebx, MMXLength - jnb dsub8lt8 -dsub8lpA: - movq mm0, [edi+ebx] - add ebx, 8 - paddb mm0, mm7 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // use -8 to offset early add to ebx - movq mm7, mm0 // Move calculated Raw(x) data to mm1 to - // be the new Raw(x-bpp) for the next loop - jb dsub8lpA -dsub8lt8: - } // end _asm block - } - break; - - default: // bpp greater than 8 bytes - { - _asm { - mov ebx, diff - mov edi, row - mov esi, edi // lp = row - add edi, bpp // rp = row + bpp -dsubAlp: - movq mm0, [edi+ebx] - movq mm1, [esi+ebx] - add ebx, 8 - paddb mm0, mm1 - cmp ebx, MMXLength - movq [edi+ebx-8], mm0 // mov does not affect flags; -8 to offset - // add ebx - jb dsubAlp - } // end _asm block - } - break; - - } // end switch ( bpp ) - - _asm { - mov ebx, MMXLength - mov edi, row - cmp ebx, FullLength - jnb dsubend - mov esi, edi // lp = row - xor eax, eax - add edi, bpp // rp = row + bpp -dsublp2: - mov al, [esi+ebx] - add [edi+ebx], al - inc ebx - cmp ebx, FullLength - jb dsublp2 -dsubend: - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - -// Optimized code for PNG Up filter decoder -void /* PRIVATE */ -png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, - png_bytep prev_row) -{ - png_uint_32 len; - len = row_info->rowbytes; // # of bytes to filter - _asm { - mov edi, row - // get # of bytes to alignment - mov ecx, edi - xor ebx, ebx - add ecx, 0x7 - xor eax, eax - and ecx, 0xfffffff8 - mov esi, prev_row - sub ecx, edi - jz dupgo - // fix alignment -duplp1: - mov al, [edi+ebx] - add al, [esi+ebx] - inc ebx - cmp ebx, ecx - mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx - jb duplp1 -dupgo: - mov ecx, len - mov edx, ecx - sub edx, ebx // subtract alignment fix - and edx, 0x0000003f // calc bytes over mult of 64 - sub ecx, edx // drop over bytes from length - // Unrolled loop - use all MMX registers and interleave to reduce - // number of branch instructions (loops) and reduce partial stalls -duploop: - movq mm1, [esi+ebx] - movq mm0, [edi+ebx] - movq mm3, [esi+ebx+8] - paddb mm0, mm1 - movq mm2, [edi+ebx+8] - movq [edi+ebx], mm0 - paddb mm2, mm3 - movq mm5, [esi+ebx+16] - movq [edi+ebx+8], mm2 - movq mm4, [edi+ebx+16] - movq mm7, [esi+ebx+24] - paddb mm4, mm5 - movq mm6, [edi+ebx+24] - movq [edi+ebx+16], mm4 - paddb mm6, mm7 - movq mm1, [esi+ebx+32] - movq [edi+ebx+24], mm6 - movq mm0, [edi+ebx+32] - movq mm3, [esi+ebx+40] - paddb mm0, mm1 - movq mm2, [edi+ebx+40] - movq [edi+ebx+32], mm0 - paddb mm2, mm3 - movq mm5, [esi+ebx+48] - movq [edi+ebx+40], mm2 - movq mm4, [edi+ebx+48] - movq mm7, [esi+ebx+56] - paddb mm4, mm5 - movq mm6, [edi+ebx+56] - movq [edi+ebx+48], mm4 - add ebx, 64 - paddb mm6, mm7 - cmp ebx, ecx - movq [edi+ebx-8], mm6 // (+56)movq does not affect flags; - // -8 to offset add ebx - jb duploop - - cmp edx, 0 // Test for bytes over mult of 64 - jz dupend - - - // 2 lines added by lcreeve@netins.net - // (mail 11 Jul 98 in png-implement list) - cmp edx, 8 //test for less than 8 bytes - jb duplt8 - - - add ecx, edx - and edx, 0x00000007 // calc bytes over mult of 8 - sub ecx, edx // drop over bytes from length - jz duplt8 - // Loop using MMX registers mm0 & mm1 to update 8 bytes simultaneously -duplpA: - movq mm1, [esi+ebx] - movq mm0, [edi+ebx] - add ebx, 8 - paddb mm0, mm1 - cmp ebx, ecx - movq [edi+ebx-8], mm0 // movq does not affect flags; -8 to offset add ebx - jb duplpA - cmp edx, 0 // Test for bytes over mult of 8 - jz dupend -duplt8: - xor eax, eax - add ecx, edx // move over byte count into counter - // Loop using x86 registers to update remaining bytes -duplp2: - mov al, [edi + ebx] - add al, [esi + ebx] - inc ebx - cmp ebx, ecx - mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx - jb duplp2 -dupend: - // Conversion of filtered row completed - emms // End MMX instructions; prep for possible FP instrs. - } // end _asm block -} - - -// Optimized png_read_filter_row routines -void /* PRIVATE */ -png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep - row, png_bytep prev_row, int filter) -{ -#ifdef PNG_DEBUG - char filnm[10]; -#endif - - if (mmx_supported == 2) { - png_mmx_support(); - } - -#ifdef PNG_DEBUG - png_debug(1, "in png_read_filter_row\n"); - switch (filter) - { - case 0: sprintf(filnm, "none"); - break; - case 1: sprintf(filnm, "sub-%s", "MMX"); - break; - case 2: sprintf(filnm, "up-%s", "MMX"); - break; - case 3: sprintf(filnm, "avg-%s", "MMX"); - break; - case 4: sprintf(filnm, "Paeth-%s", "MMX"); - break; - default: sprintf(filnm, "unknw"); - break; - } - png_debug2(0,"row=%5d, %s, ", png_ptr->row_number, filnm); - png_debug2(0, "pd=%2d, b=%d, ", (int)row_info->pixel_depth, - (int)((row_info->pixel_depth + 7) >> 3)); - png_debug1(0,"len=%8d, ", row_info->rowbytes); -#endif /* PNG_DEBUG */ - - switch (filter) - { - case PNG_FILTER_VALUE_NONE: - break; - - case PNG_FILTER_VALUE_SUB: - { - if ( - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) - { - png_read_filter_row_mmx_sub(row_info, row); - } - else - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - png_bytep lp = row; - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_UP: - { - if ( - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) - { - png_read_filter_row_mmx_up(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_uint_32 istop = row_info->rowbytes; - png_bytep rp = row; - png_bytep pp = prev_row; - - for (i = 0; i < istop; ++i) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_AVG: - { - if ( - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) - { - png_read_filter_row_mmx_avg(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) >> 1)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++ + *lp++) >> 1)) & 0xff); - rp++; - } - } - break; - } - - case PNG_FILTER_VALUE_PAETH: - { - if ( - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) - { - png_read_filter_row_mmx_paeth(row_info, row, prev_row); - } - else - { - png_uint_32 i; - png_bytep rp = row; - png_bytep pp = prev_row; - png_bytep lp = row; - png_bytep cp = prev_row; - png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; - png_uint_32 istop=row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } - - for (i = 0; i < istop; i++) // use leftover rp,pp - { - int a, b, c, pa, pb, pc, p; - - a = *lp++; - b = *pp++; - c = *cp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; - */ - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *rp = (png_byte)(((int)(*rp) + p) & 0xff); - rp++; - } - } - break; - } - - default: - png_warning(png_ptr, "Ignoring bad row filter type"); - *row=0; - break; - } -} - -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED && PNG_USE_PNGVCRD */ diff --git a/freeimage241/Source/LibPNG/pngwio.c b/freeimage241/Source/LibPNG/pngwio.c deleted file mode 100644 index 23f881e..0000000 --- a/freeimage241/Source/LibPNG/pngwio.c +++ /dev/null @@ -1,228 +0,0 @@ - -/* pngwio.c - functions for data output - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This file provides a location for all output. Users who need - * special handling are expected to write functions that have the same - * arguments as these and perform similar functions, but that possibly - * use different output methods. Note that you shouldn't change these - * functions, but rather write replacement functions and then change - * them at run time with png_set_write_fn(...). - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Write the data to whatever output you are using. The default routine - writes to a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered writes. This should never be asked - to write more than 64K on a 16 bit machine. */ - -void /* PRIVATE */ -png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - if (png_ptr->write_data_fn != NULL ) - (*(png_ptr->write_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL write function"); -} - -#if !defined(PNG_NO_STDIO) -/* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ -#ifndef USE_FAR_KEYWORD -static void /* PRIVATE */ -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - -#if defined(_WIN32_WCE) - if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); -#endif - if (check != length) - png_error(png_ptr, "Write Error"); -} -#else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ - -#define NEAR_BUF_SIZE 1024 -#define MIN(a,b) (a <= b ? a : b) - -static void /* PRIVATE */ -png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_uint_32 check; - png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ - png_FILE_p io_ptr; - - /* Check if data really is near. If so, use usual code. */ - near_data = (png_byte *)CVT_PTR_NOCHECK(data); - io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); - if ((png_bytep)near_data == data) - { -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) - check = 0; -#else - check = fwrite(near_data, 1, length, io_ptr); -#endif - } - else - { - png_byte buf[NEAR_BUF_SIZE]; - png_size_t written, remaining, err; - check = 0; - remaining = length; - do - { - written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) - err = 0; -#else - err = fwrite(buf, 1, written, io_ptr); -#endif - if (err != written) - break; - else - check += err; - data += written; - remaining -= written; - } - while (remaining != 0); - } - if (check != length) - png_error(png_ptr, "Write Error"); -} - -#endif -#endif - -/* This function is called to output any data pending writing (normally - to disk). After png_flush is called, there should be no data pending - writing in any buffers. */ -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -void /* PRIVATE */ -png_flush(png_structp png_ptr) -{ - if (png_ptr->output_flush_fn != NULL) - (*(png_ptr->output_flush_fn))(png_ptr); -} - -#if !defined(PNG_NO_STDIO) -static void /* PRIVATE */ -png_default_flush(png_structp png_ptr) -{ -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif -} -#endif -#endif - -/* This function allows the application to supply new output functions for - libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png output data structure - io_ptr - pointer to user supplied structure containing info about - the output functions. May be NULL. - write_data_fn - pointer to a new output function that takes as its - arguments a pointer to a png_struct, a pointer to - data to be written, and a 32-bit unsigned int that is - the number of bytes to be written. The new write - function should call png_error(png_ptr, "Error msg") - to exit and output any fatal error messages. - flush_data_fn - pointer to a new flush function that takes as its - arguments a pointer to a png_struct. After a call to - the flush function, there should be no data in any buffers - or pending transmission. If the output method doesn't do - any buffering of ouput, a function prototype must still be - supplied although it doesn't have to do anything. If - PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile - time, output_flush_fn will be ignored, although it must be - supplied for compatibility. */ -void PNGAPI -png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) -{ - png_ptr->io_ptr = io_ptr; - -#if !defined(PNG_NO_STDIO) - if (write_data_fn != NULL) - png_ptr->write_data_fn = write_data_fn; - else - png_ptr->write_data_fn = png_default_write_data; -#else - png_ptr->write_data_fn = write_data_fn; -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) - if (output_flush_fn != NULL) - png_ptr->output_flush_fn = output_flush_fn; - else - png_ptr->output_flush_fn = png_default_flush; -#else - png_ptr->output_flush_fn = output_flush_fn; -#endif -#endif /* PNG_WRITE_FLUSH_SUPPORTED */ - - /* It is an error to read while writing a png file */ - if (png_ptr->read_data_fn != NULL) - { - png_ptr->read_data_fn = NULL; - png_warning(png_ptr, - "Attempted to set both read_data_fn and write_data_fn in"); - png_warning(png_ptr, - "the same structure. Resetting read_data_fn to NULL."); - } -} - -#if defined(USE_FAR_KEYWORD) -#if defined(_MSC_VER) -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - FP_OFF(near_ptr) = FP_OFF(ptr); - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(FP_SEG(ptr) != FP_SEG(far_ptr)) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# else -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) -{ - void *near_ptr; - void FAR *far_ptr; - near_ptr = (void FAR *)ptr; - far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(far_ptr != ptr) - png_error(png_ptr,"segment lost in conversion"); - return(near_ptr); -} -# endif -# endif -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/freeimage241/Source/LibPNG/pngwrite.c b/freeimage241/Source/LibPNG/pngwrite.c deleted file mode 100644 index 63208b6..0000000 --- a/freeimage241/Source/LibPNG/pngwrite.c +++ /dev/null @@ -1,1448 +0,0 @@ - -/* pngwrite.c - general routines to write a PNG file - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -/* get internal access to png.h */ -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Writes all the PNG information. This is the suggested way to use the - * library. If you have a new chunk to add, make a function to write it, - * and put it in the correct location here. If you want the chunk written - * after the image data, put it in png_write_end(). I strongly encourage - * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing - * the chunk, as that will keep the code from breaking if you want to just - * write a plain PNG file. If you have long comments, I suggest writing - * them in png_write_end(), and compressing them. - */ -void PNGAPI -png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_write_info_before_PLTE\n"); - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - { - png_write_sig(png_ptr); /* write PNG signature */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) - { - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n"); - png_ptr->mng_features_permitted=0; - } -#endif - /* write IHDR information. */ - png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, - info_ptr->filter_type, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - info_ptr->interlace_type); -#else - 0); -#endif - /* the rest of these check to see if the valid field has the appropriate - flag set, and if it does, writes the chunk. */ -#if defined(PNG_WRITE_gAMA_SUPPORTED) - if (info_ptr->valid & PNG_INFO_gAMA) - { -# ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_gAMA(png_ptr, info_ptr->gamma); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma); -# endif -#endif - } -#endif -#if defined(PNG_WRITE_sRGB_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sRGB) - png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); -#endif -#if defined(PNG_WRITE_iCCP_SUPPORTED) - if (info_ptr->valid & PNG_INFO_iCCP) - png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE, - info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); -#endif -#if defined(PNG_WRITE_sBIT_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sBIT) - png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); -#endif -#if defined(PNG_WRITE_cHRM_SUPPORTED) - if (info_ptr->valid & PNG_INFO_cHRM) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_cHRM(png_ptr, - info_ptr->x_white, info_ptr->y_white, - info_ptr->x_red, info_ptr->y_red, - info_ptr->x_green, info_ptr->y_green, - info_ptr->x_blue, info_ptr->y_blue); -#else -# ifdef PNG_FIXED_POINT_SUPPORTED - png_write_cHRM_fixed(png_ptr, - info_ptr->int_x_white, info_ptr->int_y_white, - info_ptr->int_x_red, info_ptr->int_y_red, - info_ptr->int_x_green, info_ptr->int_y_green, - info_ptr->int_x_blue, info_ptr->int_y_blue); -# endif -#endif - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != HANDLE_CHUNK_NEVER && - up->location && (!(up->location & PNG_HAVE_PLTE)) && - ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif - png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; - } -} - -void PNGAPI -png_write_info(png_structp png_ptr, png_infop info_ptr) -{ -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) - int i; -#endif - - png_debug(1, "in png_write_info\n"); - - png_write_info_before_PLTE(png_ptr, info_ptr); - - if (info_ptr->valid & PNG_INFO_PLTE) - png_write_PLTE(png_ptr, info_ptr->palette, - (png_uint_32)info_ptr->num_palette); - else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Valid palette required for paletted images\n"); - -#if defined(PNG_WRITE_tRNS_SUPPORTED) - if (info_ptr->valid & PNG_INFO_tRNS) - { -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel (in tRNS) */ - if ((png_ptr->transformations & PNG_INVERT_ALPHA) && - info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - int j; - for (j=0; j<(int)info_ptr->num_trans; j++) - info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); - } -#endif - png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), - info_ptr->num_trans, info_ptr->color_type); - } -#endif -#if defined(PNG_WRITE_bKGD_SUPPORTED) - if (info_ptr->valid & PNG_INFO_bKGD) - png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); -#endif -#if defined(PNG_WRITE_hIST_SUPPORTED) - if (info_ptr->valid & PNG_INFO_hIST) - png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); -#endif -#if defined(PNG_WRITE_oFFs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_oFFs) - png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, - info_ptr->offset_unit_type); -#endif -#if defined(PNG_WRITE_pCAL_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pCAL) - png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, - info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, - info_ptr->pcal_units, info_ptr->pcal_params); -#endif -#if defined(PNG_WRITE_sCAL_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sCAL) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) - png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_s_width, info_ptr->scal_s_height); -#else - png_warning(png_ptr, - "png_write_sCAL not supported; sCAL chunk not written.\n"); -#endif -#endif -#endif -#if defined(PNG_WRITE_pHYs_SUPPORTED) - if (info_ptr->valid & PNG_INFO_pHYs) - png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, - info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - if (info_ptr->valid & PNG_INFO_tIME) - { - png_write_tIME(png_ptr, &(info_ptr->mod_time)); - png_ptr->mode |= PNG_WROTE_tIME; - } -#endif -#if defined(PNG_WRITE_sPLT_SUPPORTED) - if (info_ptr->valid & PNG_INFO_sPLT) - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* Check to see if we need to write text chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing header text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); -#else - png_warning(png_ptr, "Unable to write international text\n"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - /* If we want a compressed text chunk */ - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) - { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); -#else - png_warning(png_ptr, "Unable to write compressed text\n"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; - } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, - 0); -#else - png_warning(png_ptr, "Unable to write uncompressed text\n"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_HAVE_PLTE) && - !(up->location & PNG_HAVE_IDAT) && - ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif -} - -/* Writes the end of the PNG file. If you don't want to write comments or - * time information, you can pass NULL for info. If you already wrote these - * in png_write_info(), do not write them again here. If you have long - * comments, I suggest writing them here, and compressing them. - */ -void PNGAPI -png_write_end(png_structp png_ptr, png_infop info_ptr) -{ - png_debug(1, "in png_write_end\n"); - if (!(png_ptr->mode & PNG_HAVE_IDAT)) - png_error(png_ptr, "No IDATs written into file"); - - /* see if user wants us to write information chunks */ - if (info_ptr != NULL) - { -#if defined(PNG_WRITE_TEXT_SUPPORTED) - int i; /* local index variable */ -#endif -#if defined(PNG_WRITE_tIME_SUPPORTED) - /* check to see if user has supplied a time chunk */ - if ((info_ptr->valid & PNG_INFO_tIME) && - !(png_ptr->mode & PNG_WROTE_tIME)) - png_write_tIME(png_ptr, &(info_ptr->mod_time)); -#endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) - /* loop through comment chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing trailer text chunk %d, type %d\n", i, - info_ptr->text[i].compression); - /* an internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); -#else - png_warning(png_ptr, "Unable to write international text\n"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) - { -#if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0, - info_ptr->text[i].compression); -#else - png_warning(png_ptr, "Unable to write compressed text\n"); -#endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; - } - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0); -#else - png_warning(png_ptr, "Unable to write uncompressed text\n"); -#endif - - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - } - } -#endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) - if (info_ptr->unknown_chunks_num) - { - png_unknown_chunk *up; - - png_debug(5, "writing extra chunks\n"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { - int keep=png_handle_as_unknown(png_ptr, up->name); - if (keep != HANDLE_CHUNK_NEVER && - up->location && (up->location & PNG_AFTER_IDAT) && - ((up->name[3] & 0x20) || keep == HANDLE_CHUNK_ALWAYS || - (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS))) - { - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -#endif - } - - png_ptr->mode |= PNG_AFTER_IDAT; - - /* write end of PNG file */ - png_write_IEND(png_ptr); -#if 0 -/* This flush, added in libpng-1.0.8, causes some applications to crash - because they do not set png_ptr->output_flush_fn */ - png_flush(png_ptr); -#endif -} - -#if defined(PNG_WRITE_tIME_SUPPORTED) -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -void PNGAPI -png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) -{ - png_debug(1, "in png_convert_from_struct_tm\n"); - ptime->year = (png_uint_16)(1900 + ttime->tm_year); - ptime->month = (png_byte)(ttime->tm_mon + 1); - ptime->day = (png_byte)ttime->tm_mday; - ptime->hour = (png_byte)ttime->tm_hour; - ptime->minute = (png_byte)ttime->tm_min; - ptime->second = (png_byte)ttime->tm_sec; -} - -void PNGAPI -png_convert_from_time_t(png_timep ptime, time_t ttime) -{ - struct tm *tbuf; - - png_debug(1, "in png_convert_from_time_t\n"); - tbuf = gmtime(&ttime); - png_convert_from_struct_tm(ptime, tbuf); -} -#endif -#endif - -/* Initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn) -{ -#ifdef PNG_USER_MEM_SUPPORTED - return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, NULL, NULL, NULL)); -} - -/* Alternate initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) -{ -#endif /* PNG_USER_MEM_SUPPORTED */ - png_structp png_ptr; -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; -#endif -#endif - int i; - png_debug(1, "in png_create_write_struct\n"); -#ifdef PNG_USER_MEM_SUPPORTED - if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr)) == NULL) -#else - if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL) -#endif /* PNG_USER_MEM_SUPPORTED */ - { - return ((png_structp)NULL); - } - -#ifdef PNG_SETJMP_SUPPORTED -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) -#else - if (setjmp(png_ptr->jmpbuf)) -#endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; - png_destroy_struct(png_ptr); - return ((png_structp)NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); -#endif -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); -#endif /* PNG_USER_MEM_SUPPORTED */ - png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - - i=0; - do - { - if(user_png_ver[i] != png_libpng_ver[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - } while (png_libpng_ver[i++]); - - if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) - { - /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so - * we must recompile any applications that use any older library version. - * For versions after libpng 1.0, we will be compatible, so we need - * only check the first digit. - */ - if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || - (user_png_ver[0] == '0' && user_png_ver[2] < '9')) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Incompatible libpng version in application and library"); - } - - /* Libpng 1.0.6 was not binary compatible, due to insertion of the - info_ptr->free_me member. Libpng-1.0.1 and earlier were not - compatible due to insertion of the user transform function. Note - to maintainer: this test can be removed from version 1.2.0 and - beyond because the previous test would have already rejected it. */ - - if (user_png_ver[0] == '1' && user_png_ver[2] == '0' && - (user_png_ver[4] < '2' || user_png_ver[4] == '6') && - user_png_ver[5] == '\0') - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[80]; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); -#endif -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "Application must be recompiled; versions <= 1.0.6 were incompatible"); - } - } - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - - png_set_write_fn(png_ptr, NULL, NULL, NULL); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, NULL, NULL); -#endif - - return ((png_structp)png_ptr); -} - -/* Initialize png_ptr structure, and allocate any memory needed */ -#undef png_write_init -void PNGAPI -png_write_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -#undef png_write_init_2 -void PNGAPI -png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=(png_error_ptr)NULL; - if (user_png_ver) - { - sprintf(msg, "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - sprintf(msg, "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if(sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=(png_error_ptr)NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for writing is too small."); - } - if(sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=(png_error_ptr)NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by the application for writing is too small."); - } - png_write_init_3(&png_ptr, user_png_ver, png_struct_size); -} - - -void PNGAPI -png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ - png_structp png_ptr=*ptr_ptr; -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - int i = 0; - do - { - if (user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; -#else - png_ptr->warning_fn=(png_error_ptr)NULL; - png_warning(png_ptr, - "Application uses deprecated png_write_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_write_init_3\n"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); -#endif - - if (sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - *ptr_ptr = png_ptr; - } - - /* reset all variables to 0 */ - png_memset(png_ptr, 0, sizeof (png_struct)); - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); -#endif - - png_set_write_fn(png_ptr, NULL, NULL, NULL); - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, NULL, NULL); -#endif -} - -/* Write a few rows of image data. If the image is interlaced, - * either you will have to write the 7 sub images, or, if you - * have called png_set_interlace_handling(), you will have to - * "write" the image seven times. - */ -void PNGAPI -png_write_rows(png_structp png_ptr, png_bytepp row, - png_uint_32 num_rows) -{ - png_uint_32 i; /* row counter */ - png_bytepp rp; /* row pointer */ - - png_debug(1, "in png_write_rows\n"); - /* loop through the rows */ - for (i = 0, rp = row; i < num_rows; i++, rp++) - { - png_write_row(png_ptr, *rp); - } -} - -/* Write the image. You only need to call this function once, even - * if you are writing an interlaced image. - */ -void PNGAPI -png_write_image(png_structp png_ptr, png_bytepp image) -{ - png_uint_32 i; /* row index */ - int pass, num_pass; /* pass variables */ - png_bytepp rp; /* points to current row */ - - png_debug(1, "in png_write_image\n"); -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* intialize interlace handling. If image is not interlaced, - this will set pass to 1 */ - num_pass = png_set_interlace_handling(png_ptr); -#else - num_pass = 1; -#endif - /* loop through passes */ - for (pass = 0; pass < num_pass; pass++) - { - /* loop through image */ - for (i = 0, rp = image; i < png_ptr->height; i++, rp++) - { - png_write_row(png_ptr, *rp); - } - } -} - -/* called by user to write a row of image data */ -void PNGAPI -png_write_row(png_structp png_ptr, png_bytep row) -{ - png_debug2(1, "in png_write_row (row %ld, pass %d)\n", - png_ptr->row_number, png_ptr->pass); - /* initialize transformations and other stuff if first time */ - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* check for transforms that have been set but were defined out */ -#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); -#endif -#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); -#endif - - png_write_start_row(png_ptr); - } - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* if interlaced and not interested in row, return */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 3: - if ((png_ptr->row_number & 0x03) || png_ptr->width < 3) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 4: - if ((png_ptr->row_number & 0x03) != 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 5: - if ((png_ptr->row_number & 0x01) || png_ptr->width < 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - case 6: - if (!(png_ptr->row_number & 0x01)) - { - png_write_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - /* set up row info for transformations */ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->usr_width; - png_ptr->row_info.channels = png_ptr->usr_channels; - png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth; - png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * - png_ptr->row_info.channels); - - png_ptr->row_info.rowbytes = ((png_ptr->row_info.width * - (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3); - - png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); - png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width); - png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); - png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); - png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); - png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes); - - /* Copy user's row into buffer, leaving room for filter byte. */ - png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, - png_ptr->row_info.rowbytes); - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* handle interlacing */ - if (png_ptr->interlaced && png_ptr->pass < 6 && - (png_ptr->transformations & PNG_INTERLACE)) - { - png_do_write_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass); - /* this should always get caught above, but still ... */ - if (!(png_ptr->row_info.width)) - { - png_write_finish_row(png_ptr); - return; - } - } -#endif - - /* handle other transformations */ - if (png_ptr->transformations) - png_do_write_transformations(png_ptr); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); - } -#endif - - /* Find a filter if necessary, filter the row and write it out. */ - png_write_find_filter(png_ptr, &(png_ptr->row_info)); - - if (png_ptr->write_row_fn != NULL) - (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set the automatic flush interval or 0 to turn flushing off */ -void PNGAPI -png_set_flush(png_structp png_ptr, int nrows) -{ - png_debug(1, "in png_set_flush\n"); - png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); -} - -/* flush the current output buffers now */ -void PNGAPI -png_write_flush(png_structp png_ptr) -{ - int wrote_IDAT; - - png_debug(1, "in png_write_flush\n"); - /* We have already written out all of the data */ - if (png_ptr->row_number >= png_ptr->num_rows) - return; - - do - { - int ret; - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH); - wrote_IDAT = 0; - - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - wrote_IDAT = 1; - } - } while(wrote_IDAT == 1); - - /* If there is any data left to be output, write it into a new IDAT */ - if (png_ptr->zbuf_size != png_ptr->zstream.avail_out) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - png_ptr->flush_rows = 0; - png_flush(png_ptr); -} -#endif /* PNG_WRITE_FLUSH_SUPPORTED */ - -/* free all memory used by the write */ -void PNGAPI -png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) -{ - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn = NULL; - png_voidp mem_ptr = NULL; -#endif - - png_debug(1, "in png_destroy_write_struct\n"); - if (png_ptr_ptr != NULL) - { - png_ptr = *png_ptr_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - } - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if (png_ptr->num_chunk_list) - { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; - } -#endif - -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)info_ptr); -#endif - *info_ptr_ptr = (png_infop)NULL; - } - - if (png_ptr != NULL) - { - png_write_destroy(png_ptr); -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - *png_ptr_ptr = (png_structp)NULL; - } -} - - -/* Free any memory used in png_ptr struct (old method) */ -void /* PRIVATE */ -png_write_destroy(png_structp png_ptr) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* save jump buffer */ -#endif - png_error_ptr error_fn; - png_error_ptr warning_fn; - png_voidp error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_free_ptr free_fn; -#endif - - png_debug(1, "in png_write_destroy\n"); - /* free any memory zlib uses */ - deflateEnd(&png_ptr->zstream); - - /* free our memory. png_free checks NULL for us. */ - png_free(png_ptr, png_ptr->zbuf); - png_free(png_ptr, png_ptr->row_buf); - png_free(png_ptr, png_ptr->prev_row); - png_free(png_ptr, png_ptr->sub_row); - png_free(png_ptr, png_ptr->up_row); - png_free(png_ptr, png_ptr->avg_row); - png_free(png_ptr, png_ptr->paeth_row); - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_free(png_ptr, png_ptr->time_buffer); -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_free(png_ptr, png_ptr->prev_filters); - png_free(png_ptr, png_ptr->filter_weights); - png_free(png_ptr, png_ptr->inv_filter_weights); - png_free(png_ptr, png_ptr->filter_costs); - png_free(png_ptr, png_ptr->inv_filter_costs); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - /* reset structure */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); -#endif - - error_fn = png_ptr->error_fn; - warning_fn = png_ptr->warning_fn; - error_ptr = png_ptr->error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - free_fn = png_ptr->free_fn; -#endif - - png_memset(png_ptr, 0, sizeof (png_struct)); - - png_ptr->error_fn = error_fn; - png_ptr->warning_fn = warning_fn; - png_ptr->error_ptr = error_ptr; -#ifdef PNG_USER_MEM_SUPPORTED - png_ptr->free_fn = free_fn; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); -#endif -} - -/* Allow the application to select one or more row filters to use. */ -void PNGAPI -png_set_filter(png_structp png_ptr, int method, int filters) -{ - png_debug(1, "in png_set_filter\n"); -#if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (method == PNG_INTRAPIXEL_DIFFERENCING)) - method = PNG_FILTER_TYPE_BASE; -#endif - if (method == PNG_FILTER_TYPE_BASE) - { - switch (filters & (PNG_ALL_FILTERS | 0x07)) - { - case 5: - case 6: - case 7: png_warning(png_ptr, "Unknown row filter for method 0"); - case PNG_FILTER_VALUE_NONE: png_ptr->do_filter=PNG_FILTER_NONE; break; - case PNG_FILTER_VALUE_SUB: png_ptr->do_filter=PNG_FILTER_SUB; break; - case PNG_FILTER_VALUE_UP: png_ptr->do_filter=PNG_FILTER_UP; break; - case PNG_FILTER_VALUE_AVG: png_ptr->do_filter=PNG_FILTER_AVG; break; - case PNG_FILTER_VALUE_PAETH: png_ptr->do_filter=PNG_FILTER_PAETH;break; - default: png_ptr->do_filter = (png_byte)filters; break; - } - - /* If we have allocated the row_buf, this means we have already started - * with the image and we should have allocated all of the filter buffers - * that have been selected. If prev_row isn't already allocated, then - * it is too late to start using the filters that need it, since we - * will be missing the data in the previous row. If an application - * wants to start and stop using particular filters during compression, - * it should start out with all of the filters, and then add and - * remove them after the start of compression. - */ - if (png_ptr->row_buf != NULL) - { - if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL) - { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; - } - - if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Up filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_UP; - } - else - { - png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; - } - } - - if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Average filter after starting"); - png_ptr->do_filter &= ~PNG_FILTER_AVG; - } - else - { - png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; - } - } - - if ((png_ptr->do_filter & PNG_FILTER_PAETH) && - png_ptr->paeth_row == NULL) - { - if (png_ptr->prev_row == NULL) - { - png_warning(png_ptr, "Can't add Paeth filter after starting"); - png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH); - } - else - { - png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; - } - } - - if (png_ptr->do_filter == PNG_NO_FILTERS) - png_ptr->do_filter = PNG_FILTER_NONE; - } - } - else - png_error(png_ptr, "Unknown custom filter method"); -} - -/* This allows us to influence the way in which libpng chooses the "best" - * filter for the current scanline. While the "minimum-sum-of-absolute- - * differences metric is relatively fast and effective, there is some - * question as to whether it can be improved upon by trying to keep the - * filtered data going to zlib more consistent, hopefully resulting in - * better compression. - */ -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */ -void PNGAPI -png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, - int num_weights, png_doublep filter_weights, - png_doublep filter_costs) -{ - int i; - - png_debug(1, "in png_set_filter_heuristics\n"); - if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) - { - png_warning(png_ptr, "Unknown filter heuristic method"); - return; - } - - if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT) - { - heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; - } - - if (num_weights < 0 || filter_weights == NULL || - heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) - { - num_weights = 0; - } - - png_ptr->num_prev_filters = (png_byte)num_weights; - png_ptr->heuristic_method = (png_byte)heuristic_method; - - if (num_weights > 0) - { - if (png_ptr->prev_filters == NULL) - { - png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(sizeof(png_byte) * num_weights)); - - /* To make sure that the weighting starts out fairly */ - for (i = 0; i < num_weights; i++) - { - png_ptr->prev_filters[i] = 255; - } - } - - if (png_ptr->filter_weights == NULL) - { - png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(sizeof(png_uint_16) * num_weights)); - - png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(sizeof(png_uint_16) * num_weights)); - for (i = 0; i < num_weights; i++) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - } - - for (i = 0; i < num_weights; i++) - { - if (filter_weights[i] < 0.0) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - else - { - png_ptr->inv_filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR*filter_weights[i]+0.5); - png_ptr->filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR/filter_weights[i]+0.5); - } - } - } - - /* If, in the future, there are other filter methods, this would - * need to be based on png_ptr->filter. - */ - if (png_ptr->filter_costs == NULL) - { - png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; - } - } - - /* Here is where we set the relative costs of the different filters. We - * should take the desired compression level into account when setting - * the costs, so that Paeth, for instance, has a high relative cost at low - * compression levels, while it has a lower relative cost at higher - * compression settings. The filter types are in order of increasing - * relative cost, so it would be possible to do this with an algorithm. - */ - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - if (filter_costs == NULL || filter_costs[i] < 0.0) - { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; - } - else if (filter_costs[i] >= 1.0) - { - png_ptr->inv_filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR / filter_costs[i] + 0.5); - png_ptr->filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR * filter_costs[i] + 0.5); - } - } -} -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -void PNGAPI -png_set_compression_level(png_structp png_ptr, int level) -{ - png_debug(1, "in png_set_compression_level\n"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL; - png_ptr->zlib_level = level; -} - -void PNGAPI -png_set_compression_mem_level(png_structp png_ptr, int mem_level) -{ - png_debug(1, "in png_set_compression_mem_level\n"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL; - png_ptr->zlib_mem_level = mem_level; -} - -void PNGAPI -png_set_compression_strategy(png_structp png_ptr, int strategy) -{ - png_debug(1, "in png_set_compression_strategy\n"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; - png_ptr->zlib_strategy = strategy; -} - -void PNGAPI -png_set_compression_window_bits(png_structp png_ptr, int window_bits) -{ - if (window_bits > 15) - png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); - else if (window_bits < 8) - png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); -#ifndef WBITS_8_OK - /* avoid libpng bug with 256-byte windows */ - if (window_bits == 8) - { - png_warning(png_ptr, "Compression window is being reset to 512"); - window_bits=9; - } -#endif - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS; - png_ptr->zlib_window_bits = window_bits; -} - -void PNGAPI -png_set_compression_method(png_structp png_ptr, int method) -{ - png_debug(1, "in png_set_compression_method\n"); - if (method != 8) - png_warning(png_ptr, "Only compression method 8 is supported by PNG"); - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD; - png_ptr->zlib_method = method; -} - -void PNGAPI -png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn) -{ - png_ptr->write_row_fn = write_row_fn; -} - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -void PNGAPI -png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr - write_user_transform_fn) -{ - png_debug(1, "in png_set_write_user_transform_fn\n"); - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->write_user_transform_fn = write_user_transform_fn; -} -#endif - - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -void PNGAPI -png_write_png(png_structp png_ptr, png_infop info_ptr, - int transforms, voidp params) -{ -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency */ - if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); -#endif - - /* Write the file header information. */ - png_write_info(png_ptr, info_ptr); - - /* ------ these transformations don't touch the info structure ------- */ - -#if defined(PNG_WRITE_INVERT_SUPPORTED) - /* invert monochrome pixels */ - if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - if ((transforms & PNG_TRANSFORM_SHIFT) - && (info_ptr->valid & PNG_INFO_sBIT)) - png_set_shift(png_ptr, &info_ptr->sig_bit); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) - /* pack pixels into bytes */ - if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - /* swap location of alpha bytes from ARGB to RGBA */ - if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - if (transforms & PNG_TRANSFORM_STRIP_FILLER) - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); -#endif - -#if defined(PNG_WRITE_BGR_SUPPORTED) - /* flip BGR pixels to RGB */ - if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); -#endif - -#if defined(PNG_WRITE_SWAP_SUPPORTED) - /* swap bytes of 16-bit files to most significant byte first */ - if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); -#endif - -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - /* swap bits of 1, 2, 4 bit packed pixel formats */ - if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); -#endif - - /* ----------------------- end of transformations ------------------- */ - - /* write the bits */ - if (info_ptr->valid & PNG_INFO_IDAT) - png_write_image(png_ptr, info_ptr->row_pointers); - - /* It is REQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); - - if(transforms == 0 || params == NULL) - /* quiet compiler warnings */ return; -} -#endif -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/freeimage241/Source/LibPNG/pngwtran.c b/freeimage241/Source/LibPNG/pngwtran.c deleted file mode 100644 index 3cc6067..0000000 --- a/freeimage241/Source/LibPNG/pngwtran.c +++ /dev/null @@ -1,563 +0,0 @@ - -/* pngwtran.c - transforms the data in a row for PNG writers - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Transform the data according to the user's wishes. The order of - * transformations is significant. - */ -void /* PRIVATE */ -png_do_write_transformations(png_structp png_ptr) -{ - png_debug(1, "in png_do_write_transformations\n"); - - if (png_ptr == NULL) - return; - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - if (png_ptr->transformations & PNG_USER_TRANSFORM) - if(png_ptr->write_user_transform_fn != NULL) - (*(png_ptr->write_user_transform_fn)) /* user write transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->flags); -#endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, - (png_uint_32)png_ptr->bit_depth); -#endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -#if defined(PNG_WRITE_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif -} - -#if defined(PNG_WRITE_PACK_SUPPORTED) -/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The - * row_info bit depth should be 8 (one pixel per byte). The channels - * should be 1 (this only happens on grayscale and paletted images). - */ -void /* PRIVATE */ -png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) -{ - png_debug(1, "in png_do_pack\n"); - if (row_info->bit_depth == 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - row_info->channels == 1) - { - switch ((int)bit_depth) - { - case 1: - { - png_bytep sp, dp; - int mask, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - mask = 0x80; - v = 0; - - for (i = 0; i < row_width; i++) - { - if (*sp != 0) - v |= mask; - sp++; - if (mask > 1) - mask >>= 1; - else - { - mask = 0x80; - *dp = (png_byte)v; - dp++; - v = 0; - } - } - if (mask != 0x80) - *dp = (png_byte)v; - break; - } - case 2: - { - png_bytep sp, dp; - int shift, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 6; - v = 0; - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x03); - v |= (value << shift); - if (shift == 0) - { - shift = 6; - *dp = (png_byte)v; - dp++; - v = 0; - } - else - shift -= 2; - sp++; - } - if (shift != 6) - *dp = (png_byte)v; - break; - } - case 4: - { - png_bytep sp, dp; - int shift, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 4; - v = 0; - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x0f); - v |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp = (png_byte)v; - dp++; - v = 0; - } - else - shift -= 4; - - sp++; - } - if (shift != 4) - *dp = (png_byte)v; - break; - } - } - row_info->bit_depth = (png_byte)bit_depth; - row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); - row_info->rowbytes = - ((row_info->width * row_info->pixel_depth + 7) >> 3); - } -} -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Shift pixel values to take advantage of whole range. Pass the - * true number of bits in bit_depth. The row should be packed - * according to row_info->bit_depth. Thus, if you had a row of - * bit depth 4, but the pixels only had values from 0 to 7, you - * would pass 3 as bit_depth, and this routine would translate the - * data to 0 to 15. - */ -void /* PRIVATE */ -png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) -{ - png_debug(1, "in png_do_shift\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && -#else - if ( -#endif - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift_start[4], shift_dec[4]; - int channels = 0; - - if (row_info->color_type & PNG_COLOR_MASK_COLOR) - { - shift_start[channels] = row_info->bit_depth - bit_depth->red; - shift_dec[channels] = bit_depth->red; - channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->green; - shift_dec[channels] = bit_depth->green; - channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->blue; - shift_dec[channels] = bit_depth->blue; - channels++; - } - else - { - shift_start[channels] = row_info->bit_depth - bit_depth->gray; - shift_dec[channels] = bit_depth->gray; - channels++; - } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) - { - shift_start[channels] = row_info->bit_depth - bit_depth->alpha; - shift_dec[channels] = bit_depth->alpha; - channels++; - } - - /* with low row depths, could only be grayscale, so one channel */ - if (row_info->bit_depth < 8) - { - png_bytep bp = row; - png_uint_32 i; - png_byte mask; - png_uint_32 row_bytes = row_info->rowbytes; - - if (bit_depth->gray == 1 && row_info->bit_depth == 2) - mask = 0x55; - else if (row_info->bit_depth == 4 && bit_depth->gray == 3) - mask = 0x11; - else - mask = 0xff; - - for (i = 0; i < row_bytes; i++, bp++) - { - png_uint_16 v; - int j; - - v = *bp; - *bp = 0; - for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) - { - if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); - else - *bp |= (png_byte)((v >> (-j)) & mask); - } - } - } - else if (row_info->bit_depth == 8) - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (i = 0; i < istop; i++, bp++) - { - - png_uint_16 v; - int j; - int c = (int)(i%channels); - - v = *bp; - *bp = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - *bp |= (png_byte)((v << j) & 0xff); - else - *bp |= (png_byte)((v >> (-j)) & 0xff); - } - } - } - else - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (bp = row, i = 0; i < istop; i++) - { - int c = (int)(i%channels); - png_uint_16 value, v; - int j; - - v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); - value = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); - else - value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); - } - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)(value & 0xff); - } - } - } -} -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_swap_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from ARGB to RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - /* This converts from AARRGGBB to RRGGBBAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from AG to GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - /* This converts from AAGG to GGAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } - } - } -} -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void /* PRIVATE */ -png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_invert_alpha\n"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This inverts the alpha channel in RGBA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This inverts the alpha channel in GA */ - if (row_info->bit_depth == 8) - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - /* This inverts the alpha channel in GGAA */ - else - { - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - } - } -} -#endif - -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ -void /* PRIVATE */ -png_do_write_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_intrapixel\n"); - if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif - (row_info->color_type & PNG_COLOR_MASK_COLOR)) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((*rp - *(rp+1))&0xff); - *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0=*(rp )<<8 | *(rp+1); - png_uint_32 s1=*(rp+2)<<8 | *(rp+3); - png_uint_32 s2=*(rp+4)<<8 | *(rp+5); - png_uint_32 red=(s0-s1)&0xffff; - png_uint_32 blue=(s2-s1)&0xffff; - *(rp ) = (png_byte)((red>>8)&0xff); - *(rp+1) = (png_byte)(red&0xff); - *(rp+4) = (png_byte)((blue>>8)&0xff); - *(rp+5) = (png_byte)(blue&0xff); - } - } - } -} -#endif /* PNG_MNG_FEATURES_SUPPORTED */ -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/freeimage241/Source/LibPNG/pngwutil.c b/freeimage241/Source/LibPNG/pngwutil.c deleted file mode 100644 index a1db9c2..0000000 --- a/freeimage241/Source/LibPNG/pngwutil.c +++ /dev/null @@ -1,2646 +0,0 @@ - -/* pngwutil.c - utilities to write a PNG file - * - * libpng 1.0.12 - June 8, 2001 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2001 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - */ - -#define PNG_INTERNAL -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED - -/* Place a 32-bit number into a buffer in PNG byte order. We work - * with unsigned numbers for convenience, although one supported - * ancillary chunk uses signed (two's complement) numbers. - */ -void /* PRIVATE */ -png_save_uint_32(png_bytep buf, png_uint_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -/* The png_save_int_32 function assumes integers are stored in two's - * complement format. If this isn't the case, then this routine needs to - * be modified to write data in two's complement format. - */ -void /* PRIVATE */ -png_save_int_32(png_bytep buf, png_int_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xff); - buf[1] = (png_byte)((i >> 16) & 0xff); - buf[2] = (png_byte)((i >> 8) & 0xff); - buf[3] = (png_byte)(i & 0xff); -} -#endif - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -void /* PRIVATE */ -png_save_uint_16(png_bytep buf, unsigned int i) -{ - buf[0] = (png_byte)((i >> 8) & 0xff); - buf[1] = (png_byte)(i & 0xff); -} - -/* Write a PNG chunk all at once. The type is an array of ASCII characters - * representing the chunk name. The array must be at least 4 bytes in - * length, and does not need to be null terminated. To be safe, pass the - * pre-defined chunk names here, and if you need a new one, define it - * where the others are defined. The length is the length of the data. - * All the data must be present. If that is not possible, use the - * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() - * functions instead. - */ -void PNGAPI -png_write_chunk(png_structp png_ptr, png_bytep chunk_name, - png_bytep data, png_size_t length) -{ - png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); - png_write_chunk_data(png_ptr, data, length); - png_write_chunk_end(png_ptr); -} - -/* Write the start of a PNG chunk. The type is the chunk type. - * The total_length is the sum of the lengths of all the data you will be - * passing in png_write_chunk_data(). - */ -void PNGAPI -png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, - png_uint_32 length) -{ - png_byte buf[4]; - png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length); - - /* write the length */ - png_save_uint_32(buf, length); - png_write_data(png_ptr, buf, (png_size_t)4); - - /* write the chunk name */ - png_write_data(png_ptr, chunk_name, (png_size_t)4); - /* reset the crc and run it over the chunk name */ - png_reset_crc(png_ptr); - png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); -} - -/* Write the data of a PNG chunk started with png_write_chunk_start(). - * Note that multiple calls to this function are allowed, and that the - * sum of the lengths from these calls *must* add up to the total_length - * given to png_write_chunk_start(). - */ -void PNGAPI -png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - /* write the data, and run the CRC over it */ - if (data != NULL && length > 0) - { - png_calculate_crc(png_ptr, data, length); - png_write_data(png_ptr, data, length); - } -} - -/* Finish a chunk started with png_write_chunk_start(). */ -void PNGAPI -png_write_chunk_end(png_structp png_ptr) -{ - png_byte buf[4]; - - /* write the crc */ - png_save_uint_32(buf, png_ptr->crc); - - png_write_data(png_ptr, buf, (png_size_t)4); -} - -/* Simple function to write the signature. If we have already written - * the magic bytes of the signature, or more likely, the PNG stream is - * being embedded into another stream and doesn't need its own signature, - * we should call png_set_sig_bytes() to tell libpng how many of the - * bytes have already been written. - */ -void /* PRIVATE */ -png_write_sig(png_structp png_ptr) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - /* write the rest of the 8 byte signature */ - png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)8 - png_ptr->sig_bytes); - if(png_ptr->sig_bytes < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) -/* - * This pair of functions encapsulates the operation of (a) compressing a - * text string, and (b) issuing it later as a series of chunk data writes. - * The compression_state structure is shared context for these functions - * set up by the caller in order to make the whole mess thread-safe. - */ - -typedef struct -{ - char *input; /* the uncompressed input data */ - int input_len; /* its length */ - int num_output_ptr; /* number of output pointers used */ - int max_output_ptr; /* size of output_ptr */ - png_charpp output_ptr; /* array of pointers to output */ -} compression_state; - -/* compress given text into storage in the png_ptr structure */ -static int /* PRIVATE */ -png_text_compress(png_structp png_ptr, - png_charp text, png_size_t text_len, int compression, - compression_state *comp) -{ - int ret; - - comp->num_output_ptr = comp->max_output_ptr = 0; - comp->output_ptr = NULL; - comp->input = NULL; - - /* we may just want to pass the text right through */ - if (compression == PNG_TEXT_COMPRESSION_NONE) - { - comp->input = text; - comp->input_len = text_len; - return((int)text_len); - } - - if (compression >= PNG_TEXT_COMPRESSION_LAST) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[50]; - sprintf(msg, "Unknown compression type %d", compression); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "Unknown compression type"); -#endif - } - - /* We can't write the chunk until we find out how much data we have, - * which means we need to run the compressor first and save the - * output. This shouldn't be a problem, as the vast majority of - * comments should be reasonable, but we will set up an array of - * malloc'd pointers to be sure. - * - * If we knew the application was well behaved, we could simplify this - * greatly by assuming we can always malloc an output buffer large - * enough to hold the compressed text ((1001 * text_len / 1000) + 12) - * and malloc this directly. The only time this would be a bad idea is - * if we can't malloc more than 64K and we have 64K of random input - * data, or if the input string is incredibly large (although this - * wouldn't cause a failure, just a slowdown due to swapping). - */ - - /* set up the compression buffers */ - png_ptr->zstream.avail_in = (uInt)text_len; - png_ptr->zstream.next_in = (Bytef *)text; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; - - /* this is the same compression loop as in png_write_row() */ - do - { - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - if (ret != Z_OK) - { - /* error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - /* check to see if we need more room */ - if (!png_ptr->zstream.avail_out && png_ptr->zstream.avail_in) - { - /* make sure the output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; - - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, old_max - * sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * sizeof (png_charp))); - } - - /* save the data */ - comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; - - /* and reset the buffer */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; - } - /* continue until we don't have any more to compress */ - } while (png_ptr->zstream.avail_in); - - /* finish the compression */ - do - { - /* tell zlib we are finished */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - /* check to make sure our output array has room */ - if (comp->num_output_ptr >= comp->max_output_ptr) - { - int old_max; - - old_max = comp->max_output_ptr; - comp->max_output_ptr = comp->num_output_ptr + 4; - if (comp->output_ptr != NULL) - { - png_charpp old_ptr; - - old_ptr = comp->output_ptr; - /* This could be optimized to realloc() */ - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, - old_max * sizeof (png_charp)); - png_free(png_ptr, old_ptr); - } - else - comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * sizeof (png_charp))); - } - - /* save off the data */ - comp->output_ptr[comp->num_output_ptr] = - (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); - png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, - png_ptr->zbuf_size); - comp->num_output_ptr++; - - /* and reset the buffer pointers */ - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; - } - } - else if (ret != Z_STREAM_END) - { - /* we got an error */ - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* text length is number of buffers plus last buffer */ - text_len = png_ptr->zbuf_size * comp->num_output_ptr; - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; - - return((int)text_len); -} - -/* ship the compressed text out via chunk writes */ -static void /* PRIVATE */ -png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) -{ - int i; - - /* handle the no-compression case */ - if (comp->input) - { - png_write_chunk_data(png_ptr, (png_bytep)comp->input, comp->input_len); - return; - } - - /* write saved output buffers, if any */ - for (i = 0; i < comp->num_output_ptr; i++) - { - png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], - png_ptr->zbuf_size); - png_free(png_ptr, comp->output_ptr[i]); - comp->output_ptr[i]=NULL; - } - if (comp->max_output_ptr != 0) - png_free(png_ptr, comp->output_ptr); - comp->output_ptr=NULL; - /* write anything left in zbuf */ - if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) - png_write_chunk_data(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); - - /* reset zlib for another zTXt/iTXt or the image data */ - deflateReset(&png_ptr->zstream); - -} -#endif - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. Note that the rest of this code depends upon this - * information being correct. - */ -void /* PRIVATE */ -png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, - int bit_depth, int color_type, int compression_type, int filter_type, - int interlace_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IHDR; -#endif - png_byte buf[13]; /* buffer to store the IHDR info */ - - png_debug(1, "in png_write_IHDR\n"); - /* Check that we have valid input data from the application info */ - switch (color_type) - { - case PNG_COLOR_TYPE_GRAY: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: - case 16: png_ptr->channels = 1; break; - default: png_error(png_ptr,"Invalid bit depth for grayscale image"); - } - break; - case PNG_COLOR_TYPE_RGB: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for RGB image"); - png_ptr->channels = 3; - break; - case PNG_COLOR_TYPE_PALETTE: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: png_ptr->channels = 1; break; - default: png_error(png_ptr, "Invalid bit depth for paletted image"); - } - break; - case PNG_COLOR_TYPE_GRAY_ALPHA: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); - png_ptr->channels = 2; - break; - case PNG_COLOR_TYPE_RGB_ALPHA: - if (bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth for RGBA image"); - png_ptr->channels = 4; - break; - default: - png_error(png_ptr, "Invalid image color type specified"); - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - { - png_warning(png_ptr, "Invalid compression type specified"); - compression_type = PNG_COMPRESSION_TYPE_BASE; - } - - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) - !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && -#endif - filter_type != PNG_FILTER_TYPE_BASE) - { - png_warning(png_ptr, "Invalid filter type specified"); - filter_type = PNG_FILTER_TYPE_BASE; - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - if (interlace_type != PNG_INTERLACE_NONE && - interlace_type != PNG_INTERLACE_ADAM7) - { - png_warning(png_ptr, "Invalid interlace type specified"); - interlace_type = PNG_INTERLACE_ADAM7; - } -#else - interlace_type=PNG_INTERLACE_NONE; -#endif - - /* save off the relevent information */ - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->color_type = (png_byte)color_type; - png_ptr->interlaced = (png_byte)interlace_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_ptr->filter_type = (png_byte)filter_type; -#endif - png_ptr->width = width; - png_ptr->height = height; - - png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); - png_ptr->rowbytes = ((width * (png_size_t)png_ptr->pixel_depth + 7) >> 3); - /* set the usr info, so any transformations can modify it */ - png_ptr->usr_width = png_ptr->width; - png_ptr->usr_bit_depth = png_ptr->bit_depth; - png_ptr->usr_channels = png_ptr->channels; - - /* pack the header information into the buffer */ - png_save_uint_32(buf, width); - png_save_uint_32(buf + 4, height); - buf[8] = (png_byte)bit_depth; - buf[9] = (png_byte)color_type; - buf[10] = (png_byte)compression_type; - buf[11] = (png_byte)filter_type; - buf[12] = (png_byte)interlace_type; - - /* write the chunk */ - png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); - - /* initialize zlib with PNG info */ - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - if (!(png_ptr->do_filter)) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || - png_ptr->bit_depth < 8) - png_ptr->do_filter = PNG_FILTER_NONE; - else - png_ptr->do_filter = PNG_ALL_FILTERS; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)) - { - if (png_ptr->do_filter != PNG_FILTER_NONE) - png_ptr->zlib_strategy = Z_FILTERED; - else - png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY; - } - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL)) - png_ptr->zlib_level = Z_DEFAULT_COMPRESSION; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL)) - png_ptr->zlib_mem_level = 8; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS)) - png_ptr->zlib_window_bits = 15; - if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD)) - png_ptr->zlib_method = 8; - deflateInit2(&png_ptr->zstream, png_ptr->zlib_level, - png_ptr->zlib_method, png_ptr->zlib_window_bits, - png_ptr->zlib_mem_level, png_ptr->zlib_strategy); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_ptr->mode = PNG_HAVE_IHDR; -} - -/* write the palette. We are careful not to trust png_color to be in the - * correct order for PNG, so people can redefine it to any convenient - * structure. - */ -void /* PRIVATE */ -png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_PLTE; -#endif - png_uint_32 i; - png_colorp pal_ptr; - png_byte buf[3]; - - png_debug(1, "in png_write_PLTE\n"); - if (( -#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) - !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && -#endif - num_pal == 0) || num_pal > 256) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_error(png_ptr, "Invalid number of colors in palette"); - } - else - { - png_warning(png_ptr, "Invalid number of colors in palette"); - return; - } - } - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring request to write a PLTE chunk in grayscale PNG"); - return; - } - - png_ptr->num_palette = (png_uint_16)num_pal; - png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); - - png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3); -#ifndef PNG_NO_POINTER_INDEXING - for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) - { - buf[0] = pal_ptr->red; - buf[1] = pal_ptr->green; - buf[2] = pal_ptr->blue; - png_write_chunk_data(png_ptr, buf, (png_size_t)3); - } -#else - /* This is a little slower but some buggy compilers need to do this instead */ - pal_ptr=palette; - for (i = 0; i < num_pal; i++) - { - buf[0] = pal_ptr[i].red; - buf[1] = pal_ptr[i].green; - buf[2] = pal_ptr[i].blue; - png_write_chunk_data(png_ptr, buf, (png_size_t)3); - } -#endif - png_write_chunk_end(png_ptr); - png_ptr->mode |= PNG_HAVE_PLTE; -} - -/* write an IDAT chunk */ -void /* PRIVATE */ -png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IDAT; -#endif - png_debug(1, "in png_write_IDAT\n"); - png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); - png_ptr->mode |= PNG_HAVE_IDAT; -} - -/* write an IEND chunk */ -void /* PRIVATE */ -png_write_IEND(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_IEND; -#endif - png_debug(1, "in png_write_IEND\n"); - png_write_chunk(png_ptr, (png_bytep)png_IEND, NULL, (png_size_t)0); - png_ptr->mode |= PNG_HAVE_IEND; -} - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -/* write a gAMA chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA(png_structp png_ptr, double file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_uint_32 igamma; - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); - png_save_uint_32(buf, igamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_gAMA; -#endif - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA\n"); - /* file_gamma is saved in 1/100,000ths */ - png_save_uint_32(buf, file_gamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -/* write a sRGB chunk */ -void /* PRIVATE */ -png_write_sRGB(png_structp png_ptr, int srgb_intent) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sRGB; -#endif - png_byte buf[1]; - - png_debug(1, "in png_write_sRGB\n"); - if(srgb_intent >= PNG_sRGB_INTENT_LAST) - png_warning(png_ptr, - "Invalid sRGB rendering intent specified"); - buf[0]=(png_byte)srgb_intent; - png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); -} -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -/* write an iCCP chunk */ -void /* PRIVATE */ -png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, - png_charp profile, int profile_len) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iCCP; -#endif - png_size_t name_len; - png_charp new_name; - compression_state comp; - - png_debug(1, "in png_write_iCCP\n"); - if (name == NULL || (name_len = png_check_keyword(png_ptr, name, - &new_name)) == 0) - { - png_warning(png_ptr, "Empty keyword in iCCP chunk"); - return; - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_warning(png_ptr, "Unknown compression type in iCCP chunk"); - - if (profile == NULL) - profile_len = 0; - - if (profile_len) - profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, - PNG_COMPRESSION_TYPE_BASE, &comp); - - /* make sure we include the NULL after the name and the compression type */ - png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, - (png_uint_32)name_len+profile_len+2); - new_name[name_len+1]=0x00; - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); - - if (profile_len) - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); -} -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -/* write a sPLT chunk */ -void /* PRIVATE */ -png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sPLT; -#endif - png_size_t name_len; - png_charp new_name; - png_byte entrybuf[10]; - int entry_size = (spalette->depth == 8 ? 6 : 10); - int palette_size = entry_size * spalette->nentries; - png_sPLT_entryp ep; -#ifdef PNG_NO_POINTER_INDEXING - int i; -#endif - - png_debug(1, "in png_write_sPLT\n"); - if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, - spalette->name, &new_name))==0) - { - png_warning(png_ptr, "Empty keyword in sPLT chunk"); - return; - } - - /* make sure we include the NULL after the name */ - png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, - (png_uint_32)(name_len + 2 + palette_size)); - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); - png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); - - /* loop through each palette entry, writing appropriately */ -#ifndef PNG_NO_POINTER_INDEXING - for (ep = spalette->entries; epentries+spalette->nentries; ep++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep->red; - entrybuf[1] = (png_byte)ep->green; - entrybuf[2] = (png_byte)ep->blue; - entrybuf[3] = (png_byte)ep->alpha; - png_save_uint_16(entrybuf + 4, ep->frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep->red); - png_save_uint_16(entrybuf + 2, ep->green); - png_save_uint_16(entrybuf + 4, ep->blue); - png_save_uint_16(entrybuf + 6, ep->alpha); - png_save_uint_16(entrybuf + 8, ep->frequency); - } - png_write_chunk_data(png_ptr, entrybuf, entry_size); - } -#else - ep=spalette->entries; - for (i=0; i>spalette->nentries; i++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep[i].red; - entrybuf[1] = (png_byte)ep[i].green; - entrybuf[2] = (png_byte)ep[i].blue; - entrybuf[3] = (png_byte)ep[i].alpha; - png_save_uint_16(entrybuf + 4, ep[i].frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep[i].red); - png_save_uint_16(entrybuf + 2, ep[i].green); - png_save_uint_16(entrybuf + 4, ep[i].blue); - png_save_uint_16(entrybuf + 6, ep[i].alpha); - png_save_uint_16(entrybuf + 8, ep[i].frequency); - } - png_write_chunk_data(png_ptr, entrybuf, entry_size); - } -#endif - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_name); -} -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -/* write the sBIT chunk */ -void /* PRIVATE */ -png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sBIT; -#endif - png_byte buf[4]; - png_size_t size; - - png_debug(1, "in png_write_sBIT\n"); - /* make sure we don't depend upon the order of PNG_COLOR_8 */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - png_byte maxbits; - - maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 : - png_ptr->usr_bit_depth); - if (sbit->red == 0 || sbit->red > maxbits || - sbit->green == 0 || sbit->green > maxbits || - sbit->blue == 0 || sbit->blue > maxbits) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[0] = sbit->red; - buf[1] = sbit->green; - buf[2] = sbit->blue; - size = 3; - } - else - { - if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[0] = sbit->gray; - size = 1; - } - - if (color_type & PNG_COLOR_MASK_ALPHA) - { - if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - buf[size++] = sbit->alpha; - } - - png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); -} -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -/* write the cHRM chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM(png_structp png_ptr, double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; - png_uint_32 itemp; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 || - white_x + white_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y); -#endif - return; - } - itemp = (png_uint_32)(white_x * 100000.0 + 0.5); - png_save_uint_32(buf, itemp); - itemp = (png_uint_32)(white_y * 100000.0 + 0.5); - png_save_uint_32(buf + 4, itemp); - - if (red_x < 0 || red_x > 0.8 || red_y < 0 || red_y > 0.8 || - red_x + red_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM red point specified"); - return; - } - itemp = (png_uint_32)(red_x * 100000.0 + 0.5); - png_save_uint_32(buf + 8, itemp); - itemp = (png_uint_32)(red_y * 100000.0 + 0.5); - png_save_uint_32(buf + 12, itemp); - - if (green_x < 0 || green_x > 0.8 || green_y < 0 || green_y > 0.8 || - green_x + green_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM green point specified"); - return; - } - itemp = (png_uint_32)(green_x * 100000.0 + 0.5); - png_save_uint_32(buf + 16, itemp); - itemp = (png_uint_32)(green_y * 100000.0 + 0.5); - png_save_uint_32(buf + 20, itemp); - - if (blue_x < 0 || blue_x > 0.8 || blue_y < 0 || blue_y > 0.8 || - blue_x + blue_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM blue point specified"); - return; - } - itemp = (png_uint_32)(blue_x * 100000.0 + 0.5); - png_save_uint_32(buf + 24, itemp); - itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); - png_save_uint_32(buf + 28, itemp); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, - png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, - png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, - png_fixed_point blue_y) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_cHRM; -#endif - png_byte buf[32]; - - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y); -#endif - return; - } - png_save_uint_32(buf, white_x); - png_save_uint_32(buf + 4, white_y); - - if (red_x > 80000L || red_y > 80000L || red_x + red_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM fixed red point specified"); - return; - } - png_save_uint_32(buf + 8, red_x); - png_save_uint_32(buf + 12, red_y); - - if (green_x > 80000L || green_y > 80000L || green_x + green_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM green point specified"); - return; - } - png_save_uint_32(buf + 16, green_x); - png_save_uint_32(buf + 20, green_y); - - if (blue_x > 80000L || blue_y > 80000L || blue_x + blue_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); - return; - } - png_save_uint_32(buf + 24, blue_x); - png_save_uint_32(buf + 28, blue_y); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); -} -#endif -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -/* write the tRNS chunk */ -void /* PRIVATE */ -png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, - int num_trans, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tRNS; -#endif - png_byte buf[6]; - - png_debug(1, "in png_write_tRNS\n"); - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) - { - png_warning(png_ptr,"Invalid number of transparent colors specified"); - return; - } - /* write the chunk out as it is */ - png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, (png_size_t)num_trans); - } - else if (color_type == PNG_COLOR_TYPE_GRAY) - { - /* one 16 bit value */ - png_save_uint_16(buf, tran->gray); - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); - } - else if (color_type == PNG_COLOR_TYPE_RGB) - { - /* three 16 bit values */ - png_save_uint_16(buf, tran->red); - png_save_uint_16(buf + 2, tran->green); - png_save_uint_16(buf + 4, tran->blue); - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); - } - else - { - png_warning(png_ptr, "Can't write tRNS with an alpha channel"); - } -} -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -/* write the background chunk */ -void /* PRIVATE */ -png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_bKGD; -#endif - png_byte buf[6]; - - png_debug(1, "in png_write_bKGD\n"); - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) - (png_ptr->num_palette || - (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && -#endif - back->index > png_ptr->num_palette) - { - png_warning(png_ptr, "Invalid background palette index"); - return; - } - buf[0] = back->index; - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1); - } - else if (color_type & PNG_COLOR_MASK_COLOR) - { - png_save_uint_16(buf, back->red); - png_save_uint_16(buf + 2, back->green); - png_save_uint_16(buf + 4, back->blue); - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); - } - else - { - png_save_uint_16(buf, back->gray); - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); - } -} -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -/* write the histogram */ -void /* PRIVATE */ -png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_hIST; -#endif - int i; - png_byte buf[3]; - - png_debug(1, "in png_write_hIST\n"); - if (num_hist > (int)png_ptr->num_palette) - { - png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist, - png_ptr->num_palette); - png_warning(png_ptr, "Invalid number of histogram entries specified"); - return; - } - - png_write_chunk_start(png_ptr, (png_bytep)png_hIST, (png_uint_32)(num_hist * 2)); - for (i = 0; i < num_hist; i++) - { - png_save_uint_16(buf, hist[i]); - png_write_chunk_data(png_ptr, buf, (png_size_t)2); - } - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, - * and if invalid, correct the keyword rather than discarding the entire - * chunk. The PNG 1.0 specification requires keywords 1-79 characters in - * length, forbids leading or trailing whitespace, multiple internal spaces, - * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. - * - * The new_key is allocated to hold the corrected keyword and must be freed - * by the calling routine. This avoids problems with trying to write to - * static keywords without having to have duplicate copies of the strings. - */ -png_size_t /* PRIVATE */ -png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) -{ - png_size_t key_len; - png_charp kp, dp; - int kflag; - int kwarn=0; - - png_debug(1, "in png_check_keyword\n"); - *new_key = NULL; - - if (key == NULL || (key_len = png_strlen(key)) == 0) - { - png_warning(png_ptr, "zero length keyword"); - return ((png_size_t)0); - } - - png_debug1(2, "Keyword to be checked is '%s'\n", key); - - *new_key = (png_charp)png_malloc(png_ptr, (png_uint_32)(key_len + 2)); - - /* Replace non-printing characters with a blank and print a warning */ - for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++) - { - if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1)) - { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - char msg[40]; - - sprintf(msg, "invalid keyword character 0x%02X", *kp); - png_warning(png_ptr, msg); -#else - png_warning(png_ptr, "invalid character in keyword"); -#endif - *dp = ' '; - } - else - { - *dp = *kp; - } - } - *dp = '\0'; - - /* Remove any trailing white space. */ - kp = *new_key + key_len - 1; - if (*kp == ' ') - { - png_warning(png_ptr, "trailing spaces removed from keyword"); - - while (*kp == ' ') - { - *(kp--) = '\0'; - key_len--; - } - } - - /* Remove any leading white space. */ - kp = *new_key; - if (*kp == ' ') - { - png_warning(png_ptr, "leading spaces removed from keyword"); - - while (*kp == ' ') - { - kp++; - key_len--; - } - } - - png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp); - - /* Remove multiple internal spaces. */ - for (kflag = 0, dp = *new_key; *kp != '\0'; kp++) - { - if (*kp == ' ' && kflag == 0) - { - *(dp++) = *kp; - kflag = 1; - } - else if (*kp == ' ') - { - key_len--; - kwarn=1; - } - else - { - *(dp++) = *kp; - kflag = 0; - } - } - *dp = '\0'; - if(kwarn) - png_warning(png_ptr, "extra interior spaces removed from keyword"); - - if (key_len == 0) - { - png_free(png_ptr, *new_key); - *new_key=NULL; - png_warning(png_ptr, "Zero length keyword"); - } - - if (key_len > 79) - { - png_warning(png_ptr, "keyword length must be 1 - 79 characters"); - new_key[79] = '\0'; - key_len = 79; - } - - return (key_len); -} -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -/* write a tEXt chunk */ -void /* PRIVATE */ -png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tEXt; -#endif - png_size_t key_len; - png_charp new_key; - - png_debug(1, "in png_write_tEXt\n"); - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in tEXt chunk"); - return; - } - - if (text == NULL || *text == '\0') - text_len = 0; - else - text_len = png_strlen(text); - - /* make sure we include the 0 after the key */ - png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1); - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - if (text_len) - png_write_chunk_data(png_ptr, (png_bytep)text, text_len); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); -} -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -/* write a compressed text chunk */ -void /* PRIVATE */ -png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, - png_size_t text_len, int compression) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_zTXt; -#endif - png_size_t key_len; - char buf[1]; - png_charp new_key; - compression_state comp; - - png_debug(1, "in png_write_zTXt\n"); - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in zTXt chunk"); - return; - } - - if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE) - { - png_write_tEXt(png_ptr, new_key, text, (png_size_t)0); - png_free(png_ptr, new_key); - return; - } - - text_len = png_strlen(text); - - png_free(png_ptr, new_key); - - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression, - &comp); - - /* write start of chunk */ - png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32) - (key_len+text_len+2)); - /* write key */ - png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1); - buf[0] = (png_byte)compression; - /* write compression */ - png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); - /* write the compressed data */ - png_write_compressed_data_out(png_ptr, &comp); - - /* close the chunk */ - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -/* write an iTXt chunk */ -void /* PRIVATE */ -png_write_iTXt(png_structp png_ptr, int compression, png_charp key, - png_charp lang, png_charp lang_key, png_charp text) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_iTXt; -#endif - png_size_t lang_len, key_len, lang_key_len, text_len; - png_charp new_lang, new_key; - png_byte cbuf[2]; - compression_state comp; - - png_debug(1, "in png_write_iTXt\n"); - - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in iTXt chunk"); - return; - } - if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, - &new_lang))==0) - { - png_warning(png_ptr, "Empty language field in iTXt chunk"); - return; - } - lang_key_len = png_strlen(lang_key); - text_len = png_strlen(text); - - if (text == NULL || *text == '\0') - text_len = 0; - - /* compute the compressed data; do it now for the length */ - text_len = png_text_compress(png_ptr, text, text_len, compression-2, - &comp); - - /* make sure we include the compression flag, the compression byte, - * and the NULs after the key, lang, and lang_key parts */ - - png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, - (png_uint_32)( - 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ - + key_len - + lang_len - + lang_key_len - + text_len)); - - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); - - /* set the compression flag */ - if (compression == PNG_ITXT_COMPRESSION_NONE || \ - compression == PNG_TEXT_COMPRESSION_NONE) - cbuf[0] = 0; - else /* compression == PNG_ITXT_COMPRESSION_zTXt */ - cbuf[0] = 1; - /* set the compression method */ - cbuf[1] = 0; - png_write_chunk_data(png_ptr, cbuf, 2); - - png_write_chunk_data(png_ptr, (png_bytep)new_lang, lang_len + 1); - png_write_chunk_data(png_ptr, (png_bytep)lang_key, lang_key_len+1); - png_write_chunk_data(png_ptr, '\0', 1); - - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); - png_free(png_ptr, new_key); - png_free(png_ptr, new_lang); -} -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -/* write the oFFs chunk */ -void /* PRIVATE */ -png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset, - png_uint_32 y_offset, - int unit_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_oFFs; -#endif - png_byte buf[9]; - - png_debug(1, "in png_write_oFFs\n"); - if (unit_type >= PNG_OFFSET_LAST) - png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); - - png_save_uint_32(buf, x_offset); - png_save_uint_32(buf + 4, y_offset); - buf[8] = (png_byte)unit_type; - - png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); -} -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -/* write the pCAL chunk (described in the PNG extensions document) */ -void /* PRIVATE */ -png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, - png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pCAL; -#endif - png_size_t purpose_len, units_len, total_len; - png_uint_32p params_len; - png_byte buf[10]; - png_charp new_purpose; - int i; - - png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); - if (type >= PNG_EQUATION_LAST) - png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); - - purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; - png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); - units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d\n", (int)units_len); - total_len = purpose_len + units_len + 10; - - params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams - *sizeof(png_uint_32))); - - /* Find the length of each parameter, making sure we don't count the - null terminator for the last parameter. */ - for (i = 0; i < nparams; i++) - { - params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]); - total_len += (png_size_t)params_len[i]; - } - - png_debug1(3, "pCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); - png_save_int_32(buf, X0); - png_save_int_32(buf + 4, X1); - buf[8] = (png_byte)type; - buf[9] = (png_byte)nparams; - png_write_chunk_data(png_ptr, buf, (png_size_t)10); - png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len); - - png_free(png_ptr, new_purpose); - - for (i = 0; i < nparams; i++) - { - png_write_chunk_data(png_ptr, (png_bytep)params[i], - (png_size_t)params_len[i]); - } - - png_free(png_ptr, params_len); - png_write_chunk_end(png_ptr); -} -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -/* write the sCAL chunk */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -void /* PRIVATE */ -png_write_sCAL(png_structp png_ptr, int unit, double width,double height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - png_size_t total_len; - char wbuf[32], hbuf[32]; - - png_debug(1, "in png_write_sCAL\n"); - -#if defined(_WIN32_WCE) -/* sprintf() function is not supported on WindowsCE */ - { - wchar_t wc_buf[32]; - swprintf(wc_buf, TEXT("%12.12e"), width); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, wbuf, 32, NULL, NULL); - swprintf(wc_buf, TEXT("%12.12e"), height); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, hbuf, 32, NULL, NULL); - } -#else - sprintf(wbuf, "%12.12e", width); - sprintf(hbuf, "%12.12e", height); -#endif - total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); - - png_debug1(3, "sCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)&unit, 1); - png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); - png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf)); - - png_write_chunk_end(png_ptr); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void /* PRIVATE */ -png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, - png_charp height) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_sCAL; -#endif - png_size_t total_len; - char wbuf[32], hbuf[32]; - - png_debug(1, "in png_write_sCAL_s\n"); - - png_strcpy(wbuf,(const char *)width); - png_strcpy(hbuf,(const char *)height); - total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); - - png_debug1(3, "sCAL total length = %d\n", total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)&unit, 1); - png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); - png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf)); - - png_write_chunk_end(png_ptr); -} -#endif -#endif -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -/* write the pHYs chunk */ -void /* PRIVATE */ -png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, - png_uint_32 y_pixels_per_unit, - int unit_type) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_pHYs; -#endif - png_byte buf[9]; - - png_debug(1, "in png_write_pHYs\n"); - if (unit_type >= PNG_RESOLUTION_LAST) - png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); - - png_save_uint_32(buf, x_pixels_per_unit); - png_save_uint_32(buf + 4, y_pixels_per_unit); - buf[8] = (png_byte)unit_type; - - png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); -} -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* Write the tIME chunk. Use either png_convert_from_struct_tm() - * or png_convert_from_time_t(), or fill in the structure yourself. - */ -void /* PRIVATE */ -png_write_tIME(png_structp png_ptr, png_timep mod_time) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_tIME; -#endif - png_byte buf[7]; - - png_debug(1, "in png_write_tIME\n"); - if (mod_time->month > 12 || mod_time->month < 1 || - mod_time->day > 31 || mod_time->day < 1 || - mod_time->hour > 23 || mod_time->second > 60) - { - png_warning(png_ptr, "Invalid time specified for tIME chunk"); - return; - } - - png_save_uint_16(buf, mod_time->year); - buf[2] = mod_time->month; - buf[3] = mod_time->day; - buf[4] = mod_time->hour; - buf[5] = mod_time->minute; - buf[6] = mod_time->second; - - png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); -} -#endif - -/* initializes the row writing capability of libpng */ -void /* PRIVATE */ -png_write_start_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_size_t buf_size; - - png_debug(1, "in png_write_start_row\n"); - buf_size = (png_size_t)(((png_ptr->width * png_ptr->usr_channels * - png_ptr->usr_bit_depth + 7) >> 3) + 1); - - /* set up row buffer */ - png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; - - /* set up filtering buffer, if using this filter */ - if (png_ptr->do_filter & PNG_FILTER_SUB) - { - png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; - } - - /* We only need to keep the previous row if we are using one of these. */ - if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) - { - /* set up previous row buffer */ - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_memset(png_ptr->prev_row, 0, buf_size); - - if (png_ptr->do_filter & PNG_FILTER_UP) - { - png_ptr->up_row = (png_bytep )png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; - } - - if (png_ptr->do_filter & PNG_FILTER_AVG) - { - png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; - } - - if (png_ptr->do_filter & PNG_FILTER_PAETH) - { - png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); - png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; - } - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, we need to set up width and height of pass */ - if (png_ptr->interlaced) - { - if (!(png_ptr->transformations & PNG_INTERLACE)) - { - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - - png_pass_start[0]) / png_pass_inc[0]; - } - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - } - else -#endif - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - png_ptr->zstream.next_out = png_ptr->zbuf; -} - -/* Internal use only. Called when finished processing a row of data. */ -void /* PRIVATE */ -png_write_finish_row(png_structp png_ptr) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* start of interlace block in the y direction */ - int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* offset to next interlace block in the y direction */ - int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - int ret; - - png_debug(1, "in png_write_finish_row\n"); - /* next row */ - png_ptr->row_number++; - - /* see if we are done */ - if (png_ptr->row_number < png_ptr->num_rows) - return; - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, go to next pass */ - if (png_ptr->interlaced) - { - png_ptr->row_number = 0; - if (png_ptr->transformations & PNG_INTERLACE) - { - png_ptr->pass++; - } - else - { - /* loop until we find a non-zero width or height pass */ - do - { - png_ptr->pass++; - if (png_ptr->pass >= 7) - break; - png_ptr->usr_width = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - if (png_ptr->transformations & PNG_INTERLACE) - break; - } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); - - } - - /* reset the row above the image for the next pass */ - if (png_ptr->pass < 7) - { - if (png_ptr->prev_row != NULL) - png_memset(png_ptr->prev_row, 0, - (png_size_t) (((png_uint_32)png_ptr->usr_channels * - (png_uint_32)png_ptr->usr_bit_depth * - png_ptr->width + 7) >> 3) + 1); - return; - } - } -#endif - - /* if we get here, we've just written the last row, so we need - to flush the compressor */ - do - { - /* tell the compressor we are done */ - ret = deflate(&png_ptr->zstream, Z_FINISH); - /* check for an error */ - if (ret == Z_OK) - { - /* check to see if we need more room */ - if (!(png_ptr->zstream.avail_out)) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - } - else if (ret != Z_STREAM_END) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - } while (ret != Z_STREAM_END); - - /* write any extra space */ - if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) - { - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - - png_ptr->zstream.avail_out); - } - - deflateReset(&png_ptr->zstream); -} - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Pick out the correct pixels for the interlace pass. - * The basic idea here is to go through the row with a source - * pointer and a destination pointer (sp and dp), and copy the - * correct pixels for the pass. As the row gets compacted, - * sp will always be >= dp, so we should never overwrite anything. - * See the default: case for the easiest code to understand. - */ -void /* PRIVATE */ -png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) -{ -#ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* start of interlace block */ - int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* offset to next interlace block */ - int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif - - png_debug(1, "in png_do_write_interlace\n"); - /* we don't have to do anything on the last pass (6) */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && pass < 6) -#else - if (pass < 6) -#endif - { - /* each pixel depth is handled separately */ - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - d = 0; - shift = 7; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 3); - value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01; - d |= (value << shift); - - if (shift == 0) - { - shift = 7; - *dp++ = (png_byte)d; - d = 0; - } - else - shift--; - - } - if (shift != 7) - *dp = (png_byte)d; - break; - } - case 2: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 6; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 2); - value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03; - d |= (value << shift); - - if (shift == 0) - { - shift = 6; - *dp++ = (png_byte)d; - d = 0; - } - else - shift -= 2; - } - if (shift != 6) - *dp = (png_byte)d; - break; - } - case 4: - { - png_bytep sp; - png_bytep dp; - int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 4; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (png_size_t)(i >> 1); - value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f; - d |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp++ = (png_byte)d; - d = 0; - } - else - shift -= 4; - } - if (shift != 4) - *dp = (png_byte)d; - break; - } - default: - { - png_bytep sp; - png_bytep dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - png_size_t pixel_bytes; - - /* start at the beginning */ - dp = row; - /* find out how many bytes each pixel takes up */ - pixel_bytes = (row_info->pixel_depth >> 3); - /* loop through the row, only looking at the pixels that - matter */ - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - /* find out where the original pixel is */ - sp = row + (png_size_t)i * pixel_bytes; - /* move the pixel */ - if (dp != sp) - png_memcpy(dp, sp, pixel_bytes); - /* next pixel */ - dp += pixel_bytes; - } - break; - } - } - /* set new row width */ - row_info->width = (row_info->width + - png_pass_inc[pass] - 1 - - png_pass_start[pass]) / - png_pass_inc[pass]; - row_info->rowbytes = ((row_info->width * - row_info->pixel_depth + 7) >> 3); - } -} -#endif - -/* This filters the row, chooses which filter to use, if it has not already - * been specified by the application, and then writes the row out with the - * chosen filter. - */ -#define PNG_MAXSUM (~((png_uint_32)0) >> 1) -#define PNG_HISHIFT 10 -#define PNG_LOMASK ((png_uint_32)0xffffL) -#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)) -void /* PRIVATE */ -png_write_find_filter(png_structp png_ptr, png_row_infop row_info) -{ - png_bytep prev_row, best_row, row_buf; - png_uint_32 mins, bpp; - png_byte filter_to_do = png_ptr->do_filter; - png_uint_32 row_bytes = row_info->rowbytes; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - int num_p_filters = (int)png_ptr->num_prev_filters; -#endif - - png_debug(1, "in png_write_find_filter\n"); - /* find out how many bytes offset each pixel is */ - bpp = (row_info->pixel_depth + 7) / 8; - - prev_row = png_ptr->prev_row; - best_row = row_buf = png_ptr->row_buf; - mins = PNG_MAXSUM; - - /* The prediction method we use is to find which method provides the - * smallest value when summing the absolute values of the distances - * from zero, using anything >= 128 as negative numbers. This is known - * as the "minimum sum of absolute differences" heuristic. Other - * heuristics are the "weighted minimum sum of absolute differences" - * (experimental and can in theory improve compression), and the "zlib - * predictive" method (not implemented yet), which does test compressions - * of lines using different filter methods, and then chooses the - * (series of) filter(s) that give minimum compressed data size (VERY - * computationally expensive). - * - * GRR 980525: consider also - * (1) minimum sum of absolute differences from running average (i.e., - * keep running sum of non-absolute differences & count of bytes) - * [track dispersion, too? restart average if dispersion too large?] - * (1b) minimum sum of absolute differences from sliding average, probably - * with window size <= deflate window (usually 32K) - * (2) minimum sum of squared differences from zero or running average - * (i.e., ~ root-mean-square approach) - */ - - - /* We don't need to test the 'no filter' case if this is the only filter - * that has been chosen, as it doesn't actually do anything to the data. - */ - if ((filter_to_do & PNG_FILTER_NONE) && - filter_to_do != PNG_FILTER_NONE) - { - png_bytep rp; - png_uint_32 sum = 0; - png_uint_32 i; - int v; - - for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) - { - v = *rp; - sum += (v < 128) ? v : 256 - v; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - png_uint_32 sumhi, sumlo; - int j; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */ - - /* Reduce the sum if we match any of the previous rows */ - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - /* Factor in the cost of this filter (this is here for completeness, - * but it makes no sense to have a "cost" for the NONE filter, as - * it has the minimum possible computational cost - none). - */ - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - mins = sum; - } - - /* sub filter */ - if (filter_to_do == PNG_FILTER_SUB) - /* it's the only filter so no testing is needed */ - { - png_bytep rp, lp, dp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; - i++, rp++, dp++) - { - *dp = *rp; - } - for (lp = row_buf + 1; i < row_bytes; - i++, rp++, lp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - } - best_row = png_ptr->sub_row; - } - - else if (filter_to_do & PNG_FILTER_SUB) - { - png_bytep rp, dp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - /* We temporarily increase the "minimum sum" by the factor we - * would reduce the sum of this filter, so that we can do the - * early exit comparison without scaling the sum each time. - */ - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; - i++, rp++, dp++) - { - v = *dp = *rp; - - sum += (v < 128) ? v : 256 - v; - } - for (lp = row_buf + 1; i < row_info->rowbytes; - i++, rp++, lp++, dp++) - { - v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) - { - sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->sub_row; - } - } - - /* up filter */ - if (filter_to_do == PNG_FILTER_UP) - { - png_bytep rp, dp, pp; - png_uint_32 i; - - for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; - i++, rp++, pp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); - } - best_row = png_ptr->up_row; - } - - else if (filter_to_do & PNG_FILTER_UP) - { - png_bytep rp, dp, pp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, - pp = prev_row + 1; i < row_bytes; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->up_row; - } - } - - /* avg filter */ - if (filter_to_do == PNG_FILTER_AVG) - { - png_bytep rp, dp, pp, lp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - } - for (lp = row_buf + 1; i < row_bytes; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) - & 0xff); - } - best_row = png_ptr->avg_row; - } - - else if (filter_to_do & PNG_FILTER_AVG) - { - png_bytep rp, dp, pp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - - sum += (v < 128) ? v : 256 - v; - } - for (lp = row_buf + 1; i < row_bytes; i++) - { - v = *dp++ = - (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->avg_row; - } - } - - /* Paeth filter */ - if (filter_to_do == PNG_FILTER_PAETH) - { - png_bytep rp, dp, pp, cp, lp; - png_uint_32 i; - for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - } - - for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - } - best_row = png_ptr->paeth_row; - } - - else if (filter_to_do & PNG_FILTER_PAETH) - { - png_bytep rp, dp, pp, cp, lp; - png_uint_32 sum = 0, lmins = mins; - png_uint_32 i; - int v; - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 lmhi, lmlo; - lmlo = lmins & PNG_LOMASK; - lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) - { - lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - - if (lmhi > PNG_HIMASK) - lmins = PNG_MAXSUM; - else - lmins = (lmhi << PNG_HISHIFT) + lmlo; - } -#endif - - for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, - pp = prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - - sum += (v < 128) ? v : 256 - v; - } - - for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - -#ifndef PNG_SLOW_PAETH - p = b - c; - pc = a - c; -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; -#else /* PNG_SLOW_PAETH */ - p = a + b - c; - pa = abs(p - a); - pb = abs(p - b); - pc = abs(p - c); - if (pa <= pb && pa <= pc) - p = a; - else if (pb <= pc) - p = b; - else - p = c; -#endif /* PNG_SLOW_PAETH */ - - v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - - sum += (v < 128) ? v : 256 - v; - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) - { - int j; - png_uint_32 sumhi, sumlo; - sumlo = sum & PNG_LOMASK; - sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; - - for (j = 0; j < num_p_filters; j++) - { - if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) - { - sumlo = (sumlo * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - sumhi = (sumhi * png_ptr->filter_weights[j]) >> - PNG_WEIGHT_SHIFT; - } - } - - sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> - PNG_COST_SHIFT; - - if (sumhi > PNG_HIMASK) - sum = PNG_MAXSUM; - else - sum = (sumhi << PNG_HISHIFT) + sumlo; - } -#endif - - if (sum < mins) - { - best_row = png_ptr->paeth_row; - } - } - - /* Do the actual writing of the filtered row data from the chosen filter. */ - - png_write_filtered_row(png_ptr, best_row); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - /* Save the type of filter we picked this time for future calculations */ - if (png_ptr->num_prev_filters > 0) - { - int j; - for (j = 1; j < num_p_filters; j++) - { - png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1]; - } - png_ptr->prev_filters[j] = best_row[0]; - } -#endif -} - - -/* Do the actual writing of a previously filtered row. */ -void /* PRIVATE */ -png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) -{ - png_debug(1, "in png_write_filtered_row\n"); - png_debug1(2, "filter = %d\n", filtered_row[0]); - /* set up the zlib input buffer */ - - png_ptr->zstream.next_in = filtered_row; - png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; - /* repeat until we have compressed all the data */ - do - { - int ret; /* return of zlib */ - - /* compress the data */ - ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - /* check for compression errors */ - if (ret != Z_OK) - { - if (png_ptr->zstream.msg != NULL) - png_error(png_ptr, png_ptr->zstream.msg); - else - png_error(png_ptr, "zlib error"); - } - - /* see if it is time to write another IDAT */ - if (!(png_ptr->zstream.avail_out)) - { - /* write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - } - /* repeat until all data has been compressed */ - } while (png_ptr->zstream.avail_in); - - /* swap the current and previous rows */ - if (png_ptr->prev_row != NULL) - { - png_bytep tptr; - - tptr = png_ptr->prev_row; - png_ptr->prev_row = png_ptr->row_buf; - png_ptr->row_buf = tptr; - } - - /* finish row - updates counters and flushes zlib if last row */ - png_write_finish_row(png_ptr); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_ptr->flush_rows++; - - if (png_ptr->flush_dist > 0 && - png_ptr->flush_rows >= png_ptr->flush_dist) - { - png_write_flush(png_ptr); - } -#endif -} -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/freeimage241/Source/LibTIFF/LibTIFF.dsp b/freeimage241/Source/LibTIFF/LibTIFF.dsp deleted file mode 100644 index b9050a7..0000000 --- a/freeimage241/Source/LibTIFF/LibTIFF.dsp +++ /dev/null @@ -1,260 +0,0 @@ -# Microsoft Developer Studio Project File - Name="LibTIFF" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=LibTIFF - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "LibTIFF.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "LibTIFF.mak" CFG="LibTIFF - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "LibTIFF - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "LibTIFF - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName ""$/FreeImage/LibTIFF", MKAAAAAA" -# PROP Scc_LocalPath "." -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "LibTIFF - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G6 /Gd /MT /W3 /GX /O1 /I "..\libtiff\libtiff" /I "..\zlib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "LibTIFF - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\libtiff\libtiff" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "LibTIFF - Win32 Release" -# Name "LibTIFF - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\fax3sm_winnt.c -# End Source File -# Begin Source File - -SOURCE=.\tif_aux.c -# End Source File -# Begin Source File - -SOURCE=.\tif_close.c -# End Source File -# Begin Source File - -SOURCE=.\tif_codec.c -# End Source File -# Begin Source File - -SOURCE=.\tif_compress.c -# End Source File -# Begin Source File - -SOURCE=.\tif_dir.c -# End Source File -# Begin Source File - -SOURCE=.\tif_dirinfo.c -# End Source File -# Begin Source File - -SOURCE=.\tif_dirread.c -# End Source File -# Begin Source File - -SOURCE=.\tif_dirwrite.c -# End Source File -# Begin Source File - -SOURCE=.\tif_dumpmode.c -# End Source File -# Begin Source File - -SOURCE=.\tif_error.c -# End Source File -# Begin Source File - -SOURCE=.\tif_fax3.c -# End Source File -# Begin Source File - -SOURCE=.\tif_flush.c -# End Source File -# Begin Source File - -SOURCE=.\tif_getimage.c -# End Source File -# Begin Source File - -SOURCE=.\tif_jpeg.c -# End Source File -# Begin Source File - -SOURCE=.\tif_luv.c -# End Source File -# Begin Source File - -SOURCE=.\tif_lzw.c -# End Source File -# Begin Source File - -SOURCE=.\tif_next.c -# End Source File -# Begin Source File - -SOURCE=.\tif_open.c -# End Source File -# Begin Source File - -SOURCE=.\tif_packbits.c -# End Source File -# Begin Source File - -SOURCE=.\tif_pixarlog.c -# End Source File -# Begin Source File - -SOURCE=.\tif_predict.c -# End Source File -# Begin Source File - -SOURCE=.\tif_print.c -# End Source File -# Begin Source File - -SOURCE=.\tif_read.c -# End Source File -# Begin Source File - -SOURCE=.\tif_strip.c -# End Source File -# Begin Source File - -SOURCE=.\tif_swab.c -# End Source File -# Begin Source File - -SOURCE=.\tif_thunder.c -# End Source File -# Begin Source File - -SOURCE=.\tif_tile.c -# End Source File -# Begin Source File - -SOURCE=.\tif_version.c -# End Source File -# Begin Source File - -SOURCE=.\tif_warning.c -# End Source File -# Begin Source File - -SOURCE=.\tif_write.c -# End Source File -# Begin Source File - -SOURCE=.\tif_zip.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\t4.h -# End Source File -# Begin Source File - -SOURCE=.\tif_dir.h -# End Source File -# Begin Source File - -SOURCE=.\tif_fax3.h -# End Source File -# Begin Source File - -SOURCE=.\tif_predict.h -# End Source File -# Begin Source File - -SOURCE=.\tiff.h -# End Source File -# Begin Source File - -SOURCE=.\tiffcomp.h -# End Source File -# Begin Source File - -SOURCE=.\tiffconf.h -# End Source File -# Begin Source File - -SOURCE=.\tiffio.h -# End Source File -# Begin Source File - -SOURCE=.\tiffiop.h -# End Source File -# Begin Source File - -SOURCE=.\uvcode.h -# End Source File -# End Group -# End Target -# End Project diff --git a/freeimage241/Source/LibTIFF/Makefile.in b/freeimage241/Source/LibTIFF/Makefile.in deleted file mode 100644 index e36747e..0000000 --- a/freeimage241/Source/LibTIFF/Makefile.in +++ /dev/null @@ -1,376 +0,0 @@ -# $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\Makefile.in,v 1.0 2001-04-13 00:42:24+02 floris_van_den_berg Exp floris_van_den_berg $ -# -# Tag Image File Format Library -# -# Copyright (c) 1988-1997 Sam Leffler -# Copyright (c) 1991-1997 Silicon Graphics, Inc. -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# - -SRCDIR = @LIBSRCDIR@ - -# -# VERSION: @VERSION@ -# DATE: @DATE@ -# TARGET: @TARGET@ -# CCOMPILER: @CCOMPILER@ -# -SHELL = @SCRIPT_SH@ -NULL = -CC = @CCOMPILER@ -AR = @AR@ -AROPTS = @AROPTS@ -RANLIB = @RANLIB@ -INSTALL = @INSTALL@ - -# -# If JPEG support is to be included and the Independent JPEG -# Software distribution is not installed then DIR_JPEG must -# refer to the directory where the include files reside. -# -# Similarly, if the libgz distribution is not installed, then -# DIR_LIBGZ must refer to the directory where the include files -# are located. Note that recent versions -# -IPATH = -I. -I${SRCDIR} @COPT_LIBINC@ -# -# To enable JPEG support include -DJPEG_SUPPORT here. -# To enable Deflate support add a -DZIP_SUPPORT here. -# Note that where the configure script is used these defines -# are automatically setup when JPEG/ZIP is set to "yes". -# -# Otherwise, consult tiffconf.h for information on controlling -# the configuration of optional library support. -# -CONF_LIBRARY=@CONF_JPEG@ @CONF_ZIP@ -COPTS = @GCOPTS@ -OPTIMIZER=-O -CFLAGS = @ENVOPTS@ @LIBCOPTS@ ${COPTS} ${OPTIMIZER} ${IPATH} ${CONF_LIBRARY} -# -SRCS = \ - tif_aux.c \ - tif_close.c \ - tif_codec.c \ - tif_compress.c \ - tif_dir.c \ - tif_dirinfo.c \ - tif_dirread.c \ - tif_dirwrite.c \ - tif_dumpmode.c \ - tif_error.c \ - tif_fax3.c \ - tif_fax3sm.c \ - tif_getimage.c \ - tif_jpeg.c \ - tif_flush.c \ - tif_luv.c \ - tif_lzw.c \ - tif_next.c \ - tif_open.c \ - tif_packbits.c \ - tif_pixarlog.c \ - tif_predict.c \ - tif_print.c \ - tif_read.c \ - tif_swab.c \ - tif_strip.c \ - tif_thunder.c \ - tif_tile.c \ - tif_unix.c \ - tif_version.c \ - tif_warning.c \ - tif_write.c \ - tif_zip.c \ - ${NULL} -OBJS = \ - tif_aux.o \ - tif_close.o \ - tif_codec.o \ - tif_compress.o \ - tif_dir.o \ - tif_dirinfo.o \ - tif_dirread.o \ - tif_dirwrite.o \ - tif_dumpmode.o \ - tif_error.o \ - tif_fax3.o \ - tif_fax3sm.o \ - tif_getimage.o \ - tif_jpeg.o \ - tif_flush.o \ - tif_luv.o \ - tif_lzw.o \ - tif_next.o \ - tif_open.o \ - tif_packbits.o \ - tif_pixarlog.o \ - tif_predict.o \ - tif_print.o \ - tif_read.o \ - tif_swab.o \ - tif_strip.o \ - tif_thunder.o \ - tif_tile.o \ - tif_unix.o \ - tif_version.o \ - tif_warning.o \ - tif_write.o \ - tif_zip.o \ - ${NULL} -TARGETS = libtiff.a - -all: ${TARGETS} - if [ @DSO@dso != nodso ]; then \ - ${MAKE} @DSO@dso; \ - else \ - true; \ - fi - -libtiff.a: ${OBJS} - ${AR} ${AROPTS} libtiff.a $? - ${RANLIB} libtiff.a - -# -# NB: The configure script verifies that the configured -# tools are capable of producing a DSO before enabling -# their creation/use. The following rules are effectively -# duplicated in the configure script to do this verification. -# This means that if you want to add support for building a -# DSO on another system you'll need to modify this file *and* -# configure if you want the right thing to happen automatically -# (should probably be fixed up). -# - -# default IRIX DSO building rule -IRIXdso: ${OBJS} - @if [ "`basename ${CC}`" = "gcc" ]; then \ - ${LD} -n32 @ENVOPTS@ -o libtiff.@DSOSUF@ -shared -rdata_shared \ - ${OBJS}; \ - else \ - ${CC} @ENVOPTS@ -o libtiff.@DSOSUF@ -shared -rdata_shared \ - -check_registry ${SRCDIR}/../port/irix/so_locations \ - -quickstart_info \ - ${OBJS} @LIBJPEG@ @LIBGZ@; \ - fi - touch $@ -# special rule for IRIX 5.2 -IRIX52dso: ${OBJS} - ${LD} -elf -o libtiff.@DSOSUF@ -shared -no_unresolved -all ${OBJS} \ - @LIBJPEG@ @LIBGZ@ -lc -lm - touch $@ -# Solaris 2.x -SOLARISdso: ${OBJS} - ${LD} -L@DIR_LIB@ -G -h libtiff.@DSOSUF@ -o libtiff.@DSOSUF@ ${OBJS} - touch $@ -# HP-UX A.09.03 -HPUXdso: ${OBJS} - ${LD} +b@DIR_LIB@ -b -o libtiff.@DSOSUF@ ${OBJS} - touch $@ -# AIX 2.3.5 and 4.1.1 -AIXdso: ${OBJS} - rm -f libtiff.syms shr.o - echo "#!" > libtiff.syms - /bin/dump -g libtiff.a | sed -n -e \ - 's/^[ ]*[0-9][0-9]*[ ]*\([^ .][^ ]*\)$$/\1/p' \ - >> libtiff.syms - ${LD} -o shr.o libtiff.a -H512 -T512 -bM\:SRE \ - -bE\:libtiff.syms @LIBJPEG@ @LIBGZ@ -lc -lm -L@DIR_LIB@ - rm -f libtiff.syms libtiff.@DSOSUF@ - ${AR} ${AROPTS} libtiff.@DSOSUF@ shr.o - rm -f shr.o - touch $@ -# GNU linker shared libraries -GNULDdso: ${OBJS} - ${CC} -shared -Wl,-soname,libtiff.@DSOSUF@ \ - -o libtiff.@DSOSUF_VERSION@ ${OBJS} \ - @LIBJPEG@ @LIBGZ@ @MACHDEPLIBS@ - rm -f libtiff.@DSOSUF@ - if [ @DSOSUB_VERSION != @DSOSUF ] ; then \ - @LN@ @LN_S@ libtiff.@DSOSUF_VERSION@ libtiff.@DSOSUF@; \ - fi - touch $@ -# NetBSD 1.1 or FreeBSD (old style) -NETBSDdso FREEBSDdso: ${OBJS} - @rm -f libtiff_pic.a - @${AR} cq libtiff_pic.a `lorder ${OBJS} | tsort -q` - ${RANLIB} libtiff_pic.a - ${LD} -x -Bshareable -Bforcearchive -o libtiff.@DSOSUF@ libtiff_pic.a - rm -f libtiff_pic.a - touch $@ -# linux ELF shared lib rule -LINUXdso: ${OBJS} - ${CC} -shared -Wl,-soname,libtiff.@DSOSUF@ \ - -o libtiff.@DSOSUF_VERSION@ ${OBJS} \ - @LIBJPEG@ @LIBGZ@ @MACHLIBDEPS@ - rm -f libtiff.@DSOSUF@ - @LN@ @LN_S@ libtiff.@DSOSUF_VERSION@ libtiff.@DSOSUF@ - touch $@ -# OSF/1 3.2 shared lib rule -OSFdso: ${OBJS} - ${LD} -o libtiff.@DSOSUF@ -shared -error_unresolved ${OBJS} @LIBJPEG@ @LIBGZ@ -lc -lm - - -${OBJS}: ${SRCDIR}/tiffio.h ${SRCDIR}/tiff.h ${SRCDIR}/tif_dir.h -${OBJS}: ${SRCDIR}/tiffcomp.h ${SRCDIR}/tiffiop.h ${SRCDIR}/tiffconf.h -${OBJS}: ${SRCDIR}/tiffvers.h - -VERSION = @VERSIONFILE@ - -${SRCDIR}/tiffvers.h: ${VERSION} ${SRCDIR}/mkversion.c - ${CC} -o mkversion ${CFLAGS} ${SRCDIR}/mkversion.c - rm -f ${SRCDIR}/tiffvers.h - ./mkversion -v ${VERSION} ${SRCDIR}/tiffvers.h - -# -# The finite state machine tables used by the G3/G4 decoders -# are generated by the mkg3states program. On systems without -# make these rules have to be manually carried out. -# -tif_fax3sm.c: ${SRCDIR}/mkg3states.c ${SRCDIR}/tif_fax3.h - ${CC} -o mkg3states ${CFLAGS} ${SRCDIR}/mkg3states.c - rm -f tif_fax3sm.c; ./mkg3states -c const tif_fax3sm.c - -tif_aux.o: ${SRCDIR}/tif_aux.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_aux.c -tif_close.o: ${SRCDIR}/tif_close.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_close.c -tif_codec.o: ${SRCDIR}/tif_codec.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_codec.c -tif_compress.o: ${SRCDIR}/tif_compress.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_compress.c -tif_dir.o: ${SRCDIR}/tif_dir.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_dir.c -tif_dirinfo.o: ${SRCDIR}/tif_dirinfo.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_dirinfo.c -tif_dirread.o: ${SRCDIR}/tif_dirread.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_dirread.c -tif_dirwrite.o: ${SRCDIR}/tif_dirwrite.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_dirwrite.c -tif_dumpmode.o: ${SRCDIR}/tif_dumpmode.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_dumpmode.c -tif_error.o: ${SRCDIR}/tif_error.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_error.c -tif_fax3.o: ${SRCDIR}/tif_fax3.c ${SRCDIR}/t4.h ${SRCDIR}/tif_fax3.h - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_fax3.c -tif_getimage.o: ${SRCDIR}/tif_getimage.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_getimage.c -tif_jpeg.o: ${SRCDIR}/tif_jpeg.c @DEPEND_JPEGLIB@ - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_jpeg.c -tif_flush.o: ${SRCDIR}/tif_flush.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_flush.c -tif_luv.o: ${SRCDIR}/tif_luv.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_luv.c -tif_lzw.o: ${SRCDIR}/tif_lzw.c ${SRCDIR}/tif_predict.h - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_lzw.c -tif_next.o: ${SRCDIR}/tif_next.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_next.c -tif_open.o: ${SRCDIR}/tif_open.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_open.c -tif_packbits.o: ${SRCDIR}/tif_packbits.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_packbits.c -tif_pixarlog.o: ${SRCDIR}/tif_pixarlog.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_pixarlog.c -tif_predict.o: ${SRCDIR}/tif_predict.c ${SRCDIR}/tif_predict.h - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_predict.c -tif_print.o: ${SRCDIR}/tif_print.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_print.c -tif_read.o: ${SRCDIR}/tif_read.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_read.c -tif_swab.o: ${SRCDIR}/tif_swab.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_swab.c -tif_strip.o: ${SRCDIR}/tif_strip.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_strip.c -tif_thunder.o: ${SRCDIR}/tif_thunder.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_thunder.c -tif_tile.o: ${SRCDIR}/tif_tile.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_tile.c -tif_unix.o: ${SRCDIR}/tif_unix.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_unix.c -tif_version.o: ${SRCDIR}/tif_version.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_version.c -tif_warning.o: ${SRCDIR}/tif_warning.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_warning.c -tif_write.o: ${SRCDIR}/tif_write.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_write.c -tif_zip.o: ${SRCDIR}/tif_zip.c ${SRCDIR}/tif_predict.h @DEPEND_ZLIB@ - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_zip.c - -tif_apple.o: ${SRCDIR}/tif_apple.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_apple.c -tif_atari.o: ${SRCDIR}/tif_atari.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_atari.c -tif_msdos.o: ${SRCDIR}/tif_msdos.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_msdos.c -tif_vms.o: ${SRCDIR}/tif_vms.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_vms.c -tif_win3.o: ${SRCDIR}/tif_win3.c - ${CC} -c ${CFLAGS} ${SRCDIR}/tif_win3.c - -INCS = ${SRCDIR}/tiff.h ${SRCDIR}/tiffio.h ${SRCDIR}/tiffconf.h \ - ${SRCDIR}/tiffvers.h - -INCS_PRIVATE = ${SRCDIR}/tiffiop.h ${SRCDIR}/tif_dir.h ${SRCDIR}/port.h - -installHdrs: ${INCS} - ${INSTALL} -idb tiff.sw.dev -m 755 -dir @DIR_INC@ - for i in ${INCS}; do \ - f=`basename $$i`; \ - ${INSTALL} -idb tiff.sw.dev -m 444 -F @DIR_INC@ \ - -src $$i -O $$f; \ - done - -installPrivateHdrs: ${INCS_PRIVATE} - ${INSTALL} -idb tiff.sw.dev -m 755 -dir @DIR_INC@ - for i in ${INCS_PRIVATE}; do \ - f=`basename $$i`; \ - ${INSTALL} -idb tiff.sw.dev -m 444 -F @DIR_INC@ \ - -src $$i -O $$f; \ - done - -installDSO: @DSO@dso - if [ @DSOSUF_VERSION@ != @DSOSUF@ ]; then \ - ${INSTALL} -idb tiff.sw.tools -m 555 -F @DIR_LIB@ \ - -O libtiff.@DSOSUF_VERSION@; \ - ${INSTALL} -idb tiff.sw.tools -F @DIR_LIB@ \ - -lns libtiff.@DSOSUF_VERSION@ -O libtiff.@DSOSUF@; \ - ${INSTALL} -idb tiff.sw.tools -F @DIR_LIB@ \ - -lns libtiff.@DSOSUF@ -O libtiff.so; \ - else \ - ${INSTALL} -idb tiff.sw.tools -m 555 -F @DIR_LIB@ \ - -O libtiff.@DSOSUF@; \ - fi - -install: all installHdrs - ${INSTALL} -idb tiff.sw.dev -m 755 -dir @DIR_LIB@ - ${INSTALL} -idb tiff.sw.dev -m 444 -F @DIR_LIB@ -O libtiff.a - if [ @DSO@dso != nodso ]; then \ - ${MAKE} installDSO; \ - else \ - true; \ - fi - -install-private: install installPrivateHdrs - -clean: - rm -f ${TARGETS} ${OBJS} core a.out \ - mkg3states tif_fax3sm.c \ - mkversion ${SRCDIR}/tiffvers.h \ - libtiff.a libtiff.@DSOSUF@ libtiff.@DSOSUF_VERSION@ *dso diff --git a/freeimage241/Source/LibTIFF/Makefile.lcc b/freeimage241/Source/LibTIFF/Makefile.lcc deleted file mode 100644 index 5afcc1b..0000000 --- a/freeimage241/Source/LibTIFF/Makefile.lcc +++ /dev/null @@ -1,129 +0,0 @@ -# $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\Makefile.lcc,v 1.0 2001-04-13 00:42:24+02 floris_van_den_berg Exp floris_van_den_berg $ -# -# Tag Image File Format Library -# -# Copyright (c) 1988-1997 Sam Leffler -# Copyright (c) 1991-1997 Silicon Graphics, Inc. -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Stanford and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# -DESTDIR=. -# -INSTALL=install -NULL= - -IPATH= -I. -I../jpeg -CONF_LIBRARY=\ - ${NULL} -COPTS= -Oloop -cwagshf -d1 -b0 -v -DNDEBUG -rr -j135i -CFLAGS= ${COPTS} ${IPATH} ${CONF_LIBRARY} -# -INCS= tiff.h tiffio.h -SRCS= tif_fax3.c \ - tif_fax4.c \ - tif_aux.c \ - tif_atari.c \ - tif_ccittrle.c \ - tif_close.c \ - tif_compress.c \ - tif_dir.c \ - tif_dirinfo.c \ - tif_dirread.c \ - tif_dirwrite.c \ - tif_dumpmode.c \ - tif_error.c \ - tif_getimage.c \ - tif_jpeg.c \ - tif_flush.c \ - tif_lzw.c \ - tif_next.c \ - tif_open.c \ - tif_packbits.c \ - tif_print.c \ - tif_read.c \ - tif_swab.c \ - tif_strip.c \ - tif_thunder.c \ - tif_tile.c \ - tif_version.c \ - tif_warning.c \ - tif_write.c \ - ${NULL} -OBJS= tif_fax3.o \ - tif_fax4.o \ - tif_aux.o \ - tif_atari.o \ - tif_ccittrle.o \ - tif_close.o \ - tif_compress.o \ - tif_dir.o \ - tif_dirinfo.o \ - tif_dirread.o \ - tif_dirwrite.o \ - tif_dumpmode.o \ - tif_error.o \ - tif_getimage.o \ - tif_jpeg.o \ - tif_flush.o \ - tif_lzw.o \ - tif_next.o \ - tif_open.o \ - tif_packbits.o \ - tif_print.o \ - tif_read.o \ - tif_swab.o \ - tif_strip.o \ - tif_thunder.o \ - tif_tile.o \ - tif_version.o \ - tif_warning.o \ - tif_write.o \ - ${NULL} -ALL= tiffrnb.lib - -all: ${ALL} - -${ALL}: ${OBJS} - ${AR} ${ARFLAGS} $@ r $< - -${OBJS}: tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h -tif_fax3.o: tif_fax3.c g3states.h t4.h tif_fax3.h - -g3states.h: mkg3states.c t4.h - ${CC} -o mkg3states.ttp ${CFLAGS} mkg3states.c - ./mkg3states -c > g3states.h - -install: all installh - -for i in ${ALL}; do \ - ${INSTALL} -c -m 644 $$i ${DESTDIR}/lib/$$i; \ - done - -installh: ${INCS} - -for i in ${INCS}; do \ - h=`basename $$i`; \ - cmp -s $$i ${DESTDIR}/include/$$h || \ - ${INSTALL} -c -m 444 $$i ${DESTDIR}/include/$$h; \ - done - -clean: - rm -f ${ALL} ${OBJS} mkg3states.ttp mkg3states.o g3states.h - -tags: ${SRCS} - ${CTAGS} ${SRCS} diff --git a/freeimage241/Source/LibTIFF/fax3sm_winnt.c b/freeimage241/Source/LibTIFF/fax3sm_winnt.c deleted file mode 100644 index 564c9aa..0000000 --- a/freeimage241/Source/LibTIFF/fax3sm_winnt.c +++ /dev/null @@ -1,1046 +0,0 @@ -/* WARNING, this file was automatically generated by the - mkg3states program */ -#include "tiff.h" -#include "tif_fax3.h" - const TIFFFaxTabEnt TIFFFaxMainTable[128] = { -12,7,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0,1,4,0,3,1,0,5,3,1,3,1,0, -2,3,0,3,1,0,4,3,1,3,1,0,5,6,2,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0, -1,4,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0,5,7,3,3,1,0,5,3,1,3,1,0, -2,3,0,3,1,0,4,3,1,3,1,0,1,4,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0, -4,6,2,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0,1,4,0,3,1,0,5,3,1,3,1,0, -2,3,0,3,1,0,4,3,1,3,1,0,6,7,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0, -1,4,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0,5,6,2,3,1,0,5,3,1,3,1,0, -2,3,0,3,1,0,4,3,1,3,1,0,1,4,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0, -4,7,3,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0,1,4,0,3,1,0,5,3,1,3,1,0, -2,3,0,3,1,0,4,3,1,3,1,0,4,6,2,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0, -1,4,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0 -}; -const TIFFFaxTabEnt TIFFFaxWhiteTable[4096] = { -12,11,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, -7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, -7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1472,7,4,5,7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, -7,8,41,7,6,16,9,9,960,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, -9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,11,1792,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, -7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5, -7,8,44,7,6,17,9,9,1344,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, -7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6, -7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, -7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15, -7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7, -7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6, -7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, -7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -11,11,1856,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6, -7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5, -7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1728,7,4,5,7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5, -7,8,42,7,6,16,9,9,1152,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15, -9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6, -7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1472,7,4,5, -7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14, -7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,960,7,4,6, -7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,11,12,2112,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, -7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15, -7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5,7,8,44,7,6,17,9,9,1344,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7, -7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6, -7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, -7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, -7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, -7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, -7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, -9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,12,2368,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, -7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1728,7,4,5, -7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, -7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1152,7,4,6, -7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, -7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15, -7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1472,7,4,5,7,8,43,7,6,17,9,9,1216,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7, -7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,960,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,704,7,4,6, -7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, -7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -11,12,1984,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,832,7,4,6, -7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5, -7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1600,7,4,5,7,8,44,7,6,17,9,9,1344,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5, -7,8,42,7,6,16,9,9,1088,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15, -9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6, -7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1536,7,4,5, -7,8,43,7,6,17,9,9,1280,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14, -7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,1024,7,4,6, -7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,9,768,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,11,11,1920,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, -7,8,40,7,6,16,9,9,896,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15, -7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1728,7,4,5,7,8,44,7,6,17,9,9,1408,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7, -7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1152,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6, -7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, -7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, -7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, -7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1472,7,4,5,7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, -7,8,41,7,6,16,9,9,960,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, -9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,12,2240,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, -7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5, -7,8,44,7,6,17,9,9,1344,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, -7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6, -7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, -7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15, -7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7, -7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6, -7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, -7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -11,12,2496,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6, -7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5, -7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1728,7,4,5,7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5, -7,8,42,7,6,16,9,9,1152,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15, -9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,12,11,0,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6, -7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1472,7,4,5, -7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14, -7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,960,7,4,6, -7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,11,11,1792,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, -7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15, -7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5,7,8,44,7,6,17,9,9,1344,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7, -7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6, -7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, -7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, -7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, -7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, -7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, -9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,11,1856,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, -7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1728,7,4,5, -7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, -7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1152,7,4,6, -7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, -7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15, -7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1472,7,4,5,7,8,43,7,6,17,9,9,1216,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7, -7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,960,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,704,7,4,6, -7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, -7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -11,12,2176,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,832,7,4,6, -7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5, -7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1600,7,4,5,7,8,44,7,6,17,9,9,1344,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5, -7,8,42,7,6,16,9,9,1088,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15, -9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6, -7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1536,7,4,5, -7,8,43,7,6,17,9,9,1280,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14, -7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,1024,7,4,6, -7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,9,768,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,11,12,2432,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, -7,8,40,7,6,16,9,9,896,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15, -7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1728,7,4,5,7,8,44,7,6,17,9,9,1408,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7, -7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1152,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6, -7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, -7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, -7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, -7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1472,7,4,5,7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, -7,8,41,7,6,16,9,9,960,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, -9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,12,2048,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, -7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5, -7,8,44,7,6,17,9,9,1344,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, -7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6, -7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, -7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15, -7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7, -7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6, -7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, -7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -11,11,1920,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6, -7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5, -7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1728,7,4,5,7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5, -7,8,42,7,6,16,9,9,1152,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15, -9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6, -7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1472,7,4,5, -7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14, -7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,960,7,4,6, -7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,11,12,2304,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, -7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15, -7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5,7,8,44,7,6,17,9,9,1344,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7, -7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6, -7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, -7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, -7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, -7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, -7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, -7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, -7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, -9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, -7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,12,2560,7,4,3,7,5,11,7,4,5, -7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, -7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, -7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1728,7,4,5, -7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, -7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, -7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1152,7,4,6, -7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, -7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, -7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, -7,5,10,7,4,4,7,4,2,7,4,7 -}; -const TIFFFaxTabEnt TIFFFaxBlackTable[8192] = { -12,11,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,11,1792,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,11,23,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,20,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,11,25,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,12,128,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,56,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,30,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,11,1856,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,57,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,11,21,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,54,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,52,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,48,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,11,12,2112,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,44,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,36,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,12,384,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,28,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,60,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,40,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2368,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,12,1984,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,50,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,34,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,13,1664,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,26,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,13,1408,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,32,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,11,11,1920,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,61,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,42,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,1024,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,13,768,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,62,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2240,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,46,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,38,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,13,512,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,11,19,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,24,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,11,22,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,12,2496,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,10,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,12,11,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,10,18,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,17,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,11,11,1792,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,11,23,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,11,20,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,25,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,12,192,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,13,1280,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,31,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,11,1856,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,58,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,21,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,13,896,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,640,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,49,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,12,2176,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,45,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,37,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,12,448,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,29,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,13,1536,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,41,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,11,12,2432,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,10,16,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,10,64,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2048,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,51,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,35,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,12,320,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,27,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,59,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,33,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,11,1920,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,12,256,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,43,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,13,1152,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,55,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,63,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,11,12,2304,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,47,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,39,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,53,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,11,19,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,11,24,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,11,22,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2560,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,12,11,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,11,1792,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,23,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,11,20,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,11,25,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,12,128,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,56,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,30,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,11,11,1856,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,57,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,11,21,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,54,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,52,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,48,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2112,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,44,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,36,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,12,384,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,28,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,60,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,40,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,12,2368,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,10,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,10,18,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,17,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,11,12,1984,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,50,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,34,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,1728,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,26,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,13,1472,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,32,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,11,1920,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,61,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,42,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,13,1088,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,832,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,62,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,12,2240,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,46,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,38,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,13,576,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,19,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,11,24,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,22,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,11,12,2496,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,10,16,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,10,64,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -12,11,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,11,1792,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,11,23,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,20,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,11,25,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,12,192,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,1344,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,31,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,11,1856,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,58,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,11,21,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,13,960,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,13,704,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,49,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,11,12,2176,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,45,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,37,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,12,448,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,29,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,13,1600,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,41,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2432,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,12,2048,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,51,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,35,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,12,320,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,27,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,59,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,33,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,11,11,1920,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -10,12,256,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,43,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,1216,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,55,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,63,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2304,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,12,47,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,39,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,12,53,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,11,19,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,24,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,11,22,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -11,12,2560,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,10,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, -8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, -8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, -8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, -8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2 -}; diff --git a/freeimage241/Source/LibTIFF/libtiff.def b/freeimage241/Source/LibTIFF/libtiff.def deleted file mode 100644 index 74ded6c..0000000 --- a/freeimage241/Source/LibTIFF/libtiff.def +++ /dev/null @@ -1,77 +0,0 @@ -LIBRARY libtiff -EXPORTS TIFFOpen - TIFFGetVersion - TIFFClose - TIFFFlush - TIFFFlushData - TIFFGetField - TIFFVGetField - TIFFGetFieldDefaulted - TIFFVGetFieldDefaulted - TIFFReadDirectory - TIFFScanlineSize - TIFFStripSize - TIFFVStripSize - TIFFTileRowSize - TIFFTileSize - TIFFVTileSize - TIFFFileno - TIFFGetMode - TIFFIsTiled - TIFFIsByteSwapped - TIFFCurrentRow - TIFFCurrentDirectory - TIFFCurrentStrip - TIFFCurrentTile - TIFFReadBufferSetup - TIFFLastDirectory - TIFFSetDirectory - TIFFSetSubDirectory - TIFFUnlinkDirectory - TIFFSetField - TIFFVSetField - TIFFWriteDirectory - TIFFPrintDirectory - TIFFReadScanline - TIFFWriteScanline - TIFFReadRGBAImage - TIFFPrintDirectory - TIFFReadScanline - TIFFWriteScanline - TIFFReadRGBAImage - TIFFFdOpen - TIFFClientOpen - TIFFFileName - TIFFError - TIFFWarning - TIFFSetErrorHandler - TIFFSetWarningHandler - TIFFComputeTile - TIFFCheckTile - TIFFNumberOfTiles - TIFFReadTile - TIFFWriteTile - TIFFComputeStrip - TIFFNumberOfStrips - TIFFReadEncodedStrip - TIFFReadRawStrip - TIFFReadEncodedTile - TIFFReadRawTile - TIFFWriteEncodedStrip - TIFFWriteRawStrip - TIFFWriteEncodedTile - TIFFWriteRawTile - TIFFSetWriteOffset - TIFFSwabShort - TIFFSwabLong - TIFFSwabArrayOfShort - TIFFSwabArrayOfLong - TIFFReverseBits - TIFFGetBitRevTable - _TIFFmalloc - _TIFFrealloc - _TIFFfree - _TIFFmemset - _TIFFmemcpy - _TIFFmemcmp - diff --git a/freeimage241/Source/LibTIFF/makefile.vc b/freeimage241/Source/LibTIFF/makefile.vc deleted file mode 100644 index afefc69..0000000 --- a/freeimage241/Source/LibTIFF/makefile.vc +++ /dev/null @@ -1,79 +0,0 @@ -# -# Simple MS VC++ Makefile -# -# To build: -# C:\libtiff\libtiff> nmake /f makefile.vc all -# - -# -# Select _CONSOLE to build a library which reports errors to stderr, or -# _WINDOWED to build such that errors are reported via MessageBox(). -# -WINMODE = -DTIF_PLATFORM_CONSOLE -#WINMODE = -DTIF_PLATFORM_WINDOWED - -CC = cl -INCL = -I. -LIBS = -CFLAGS = /nologo /W3 $(INCL) $(WINMODE) - -OBJ = \ - tif_aux.obj \ - tif_close.obj \ - tif_codec.obj \ - tif_compress.obj \ - tif_dir.obj \ - tif_dirinfo.obj \ - tif_dirread.obj \ - tif_dirwrite.obj \ - tif_dumpmode.obj \ - tif_error.obj \ - tif_fax3.obj \ - fax3sm_winnt.obj \ - tif_getimage.obj \ - tif_jpeg.obj \ - tif_flush.obj \ - tif_luv.obj \ - tif_lzw.obj \ - tif_next.obj \ - tif_open.obj \ - tif_packbits.obj \ - tif_pixarlog.obj \ - tif_predict.obj \ - tif_print.obj \ - tif_read.obj \ - tif_swab.obj \ - tif_strip.obj \ - tif_thunder.obj \ - tif_tile.obj \ - tif_win32.obj \ - tif_version.obj \ - tif_warning.obj \ - tif_write.obj \ - tif_zip.obj - -VERSION = ..\VERSION -ALPHA = ..\dist\tiff.alpha - -default: libtiff.lib - -all: libtiff.lib libtiff.dll - -libtiff.lib: tiffvers.h $(OBJ) - lib /out:libtiff.lib $(OBJ) - -libtiff.dll: $(OBJ) - link /dll /def:libtiff.def /out:libtiff.dll /implib:libtiff_i.lib \ - $(OBJ) $(LIBS) - -tiffvers.h: $(VERSION) mkversion.c - $(CC) mkversion.c - if exist tiffvers.h del tiffvers.h - .\mkversion.exe -v $(VERSION) tiffvers.h - -clean: - del *.obj *.lib libtiff.dll - -tif_version.obj: tiffvers.h - - diff --git a/freeimage241/Source/LibTIFF/t4.h b/freeimage241/Source/LibTIFF/t4.h deleted file mode 100644 index 2565366..0000000 --- a/freeimage241/Source/LibTIFF/t4.h +++ /dev/null @@ -1,285 +0,0 @@ -/* $Id: t4.h,v 1.0 2001-04-13 00:42:26+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _T4_ -#define _T4_ -/* - * CCITT T.4 1D Huffman runlength codes and - * related definitions. Given the small sizes - * of these tables it does not seem - * worthwhile to make code & length 8 bits. - */ -typedef struct tableentry { - unsigned short length; /* bit length of g3 code */ - unsigned short code; /* g3 code */ - short runlen; /* run length in bits */ -} tableentry; - -#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ - -/* status values returned instead of a run length */ -#define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */ -#define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */ -#define G3CODE_EOF -3 /* end of input data */ -#define G3CODE_INCOMP -4 /* incomplete run code */ - -/* - * Note that these tables are ordered such that the - * index into the table is known to be either the - * run length, or (run length / 64) + a fixed offset. - * - * NB: The G3CODE_INVALID entries are only used - * during state generation (see mkg3states.c). - */ -#ifdef G3CODES -const tableentry TIFFFaxWhiteCodes[] = { - { 8, 0x35, 0 }, /* 0011 0101 */ - { 6, 0x7, 1 }, /* 0001 11 */ - { 4, 0x7, 2 }, /* 0111 */ - { 4, 0x8, 3 }, /* 1000 */ - { 4, 0xB, 4 }, /* 1011 */ - { 4, 0xC, 5 }, /* 1100 */ - { 4, 0xE, 6 }, /* 1110 */ - { 4, 0xF, 7 }, /* 1111 */ - { 5, 0x13, 8 }, /* 1001 1 */ - { 5, 0x14, 9 }, /* 1010 0 */ - { 5, 0x7, 10 }, /* 0011 1 */ - { 5, 0x8, 11 }, /* 0100 0 */ - { 6, 0x8, 12 }, /* 0010 00 */ - { 6, 0x3, 13 }, /* 0000 11 */ - { 6, 0x34, 14 }, /* 1101 00 */ - { 6, 0x35, 15 }, /* 1101 01 */ - { 6, 0x2A, 16 }, /* 1010 10 */ - { 6, 0x2B, 17 }, /* 1010 11 */ - { 7, 0x27, 18 }, /* 0100 111 */ - { 7, 0xC, 19 }, /* 0001 100 */ - { 7, 0x8, 20 }, /* 0001 000 */ - { 7, 0x17, 21 }, /* 0010 111 */ - { 7, 0x3, 22 }, /* 0000 011 */ - { 7, 0x4, 23 }, /* 0000 100 */ - { 7, 0x28, 24 }, /* 0101 000 */ - { 7, 0x2B, 25 }, /* 0101 011 */ - { 7, 0x13, 26 }, /* 0010 011 */ - { 7, 0x24, 27 }, /* 0100 100 */ - { 7, 0x18, 28 }, /* 0011 000 */ - { 8, 0x2, 29 }, /* 0000 0010 */ - { 8, 0x3, 30 }, /* 0000 0011 */ - { 8, 0x1A, 31 }, /* 0001 1010 */ - { 8, 0x1B, 32 }, /* 0001 1011 */ - { 8, 0x12, 33 }, /* 0001 0010 */ - { 8, 0x13, 34 }, /* 0001 0011 */ - { 8, 0x14, 35 }, /* 0001 0100 */ - { 8, 0x15, 36 }, /* 0001 0101 */ - { 8, 0x16, 37 }, /* 0001 0110 */ - { 8, 0x17, 38 }, /* 0001 0111 */ - { 8, 0x28, 39 }, /* 0010 1000 */ - { 8, 0x29, 40 }, /* 0010 1001 */ - { 8, 0x2A, 41 }, /* 0010 1010 */ - { 8, 0x2B, 42 }, /* 0010 1011 */ - { 8, 0x2C, 43 }, /* 0010 1100 */ - { 8, 0x2D, 44 }, /* 0010 1101 */ - { 8, 0x4, 45 }, /* 0000 0100 */ - { 8, 0x5, 46 }, /* 0000 0101 */ - { 8, 0xA, 47 }, /* 0000 1010 */ - { 8, 0xB, 48 }, /* 0000 1011 */ - { 8, 0x52, 49 }, /* 0101 0010 */ - { 8, 0x53, 50 }, /* 0101 0011 */ - { 8, 0x54, 51 }, /* 0101 0100 */ - { 8, 0x55, 52 }, /* 0101 0101 */ - { 8, 0x24, 53 }, /* 0010 0100 */ - { 8, 0x25, 54 }, /* 0010 0101 */ - { 8, 0x58, 55 }, /* 0101 1000 */ - { 8, 0x59, 56 }, /* 0101 1001 */ - { 8, 0x5A, 57 }, /* 0101 1010 */ - { 8, 0x5B, 58 }, /* 0101 1011 */ - { 8, 0x4A, 59 }, /* 0100 1010 */ - { 8, 0x4B, 60 }, /* 0100 1011 */ - { 8, 0x32, 61 }, /* 0011 0010 */ - { 8, 0x33, 62 }, /* 0011 0011 */ - { 8, 0x34, 63 }, /* 0011 0100 */ - { 5, 0x1B, 64 }, /* 1101 1 */ - { 5, 0x12, 128 }, /* 1001 0 */ - { 6, 0x17, 192 }, /* 0101 11 */ - { 7, 0x37, 256 }, /* 0110 111 */ - { 8, 0x36, 320 }, /* 0011 0110 */ - { 8, 0x37, 384 }, /* 0011 0111 */ - { 8, 0x64, 448 }, /* 0110 0100 */ - { 8, 0x65, 512 }, /* 0110 0101 */ - { 8, 0x68, 576 }, /* 0110 1000 */ - { 8, 0x67, 640 }, /* 0110 0111 */ - { 9, 0xCC, 704 }, /* 0110 0110 0 */ - { 9, 0xCD, 768 }, /* 0110 0110 1 */ - { 9, 0xD2, 832 }, /* 0110 1001 0 */ - { 9, 0xD3, 896 }, /* 0110 1001 1 */ - { 9, 0xD4, 960 }, /* 0110 1010 0 */ - { 9, 0xD5, 1024 }, /* 0110 1010 1 */ - { 9, 0xD6, 1088 }, /* 0110 1011 0 */ - { 9, 0xD7, 1152 }, /* 0110 1011 1 */ - { 9, 0xD8, 1216 }, /* 0110 1100 0 */ - { 9, 0xD9, 1280 }, /* 0110 1100 1 */ - { 9, 0xDA, 1344 }, /* 0110 1101 0 */ - { 9, 0xDB, 1408 }, /* 0110 1101 1 */ - { 9, 0x98, 1472 }, /* 0100 1100 0 */ - { 9, 0x99, 1536 }, /* 0100 1100 1 */ - { 9, 0x9A, 1600 }, /* 0100 1101 0 */ - { 6, 0x18, 1664 }, /* 0110 00 */ - { 9, 0x9B, 1728 }, /* 0100 1101 1 */ - { 11, 0x8, 1792 }, /* 0000 0001 000 */ - { 11, 0xC, 1856 }, /* 0000 0001 100 */ - { 11, 0xD, 1920 }, /* 0000 0001 101 */ - { 12, 0x12, 1984 }, /* 0000 0001 0010 */ - { 12, 0x13, 2048 }, /* 0000 0001 0011 */ - { 12, 0x14, 2112 }, /* 0000 0001 0100 */ - { 12, 0x15, 2176 }, /* 0000 0001 0101 */ - { 12, 0x16, 2240 }, /* 0000 0001 0110 */ - { 12, 0x17, 2304 }, /* 0000 0001 0111 */ - { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ - { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ - { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ - { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ - { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ - { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ - { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ - { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ - { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ -}; - -const tableentry TIFFFaxBlackCodes[] = { - { 10, 0x37, 0 }, /* 0000 1101 11 */ - { 3, 0x2, 1 }, /* 010 */ - { 2, 0x3, 2 }, /* 11 */ - { 2, 0x2, 3 }, /* 10 */ - { 3, 0x3, 4 }, /* 011 */ - { 4, 0x3, 5 }, /* 0011 */ - { 4, 0x2, 6 }, /* 0010 */ - { 5, 0x3, 7 }, /* 0001 1 */ - { 6, 0x5, 8 }, /* 0001 01 */ - { 6, 0x4, 9 }, /* 0001 00 */ - { 7, 0x4, 10 }, /* 0000 100 */ - { 7, 0x5, 11 }, /* 0000 101 */ - { 7, 0x7, 12 }, /* 0000 111 */ - { 8, 0x4, 13 }, /* 0000 0100 */ - { 8, 0x7, 14 }, /* 0000 0111 */ - { 9, 0x18, 15 }, /* 0000 1100 0 */ - { 10, 0x17, 16 }, /* 0000 0101 11 */ - { 10, 0x18, 17 }, /* 0000 0110 00 */ - { 10, 0x8, 18 }, /* 0000 0010 00 */ - { 11, 0x67, 19 }, /* 0000 1100 111 */ - { 11, 0x68, 20 }, /* 0000 1101 000 */ - { 11, 0x6C, 21 }, /* 0000 1101 100 */ - { 11, 0x37, 22 }, /* 0000 0110 111 */ - { 11, 0x28, 23 }, /* 0000 0101 000 */ - { 11, 0x17, 24 }, /* 0000 0010 111 */ - { 11, 0x18, 25 }, /* 0000 0011 000 */ - { 12, 0xCA, 26 }, /* 0000 1100 1010 */ - { 12, 0xCB, 27 }, /* 0000 1100 1011 */ - { 12, 0xCC, 28 }, /* 0000 1100 1100 */ - { 12, 0xCD, 29 }, /* 0000 1100 1101 */ - { 12, 0x68, 30 }, /* 0000 0110 1000 */ - { 12, 0x69, 31 }, /* 0000 0110 1001 */ - { 12, 0x6A, 32 }, /* 0000 0110 1010 */ - { 12, 0x6B, 33 }, /* 0000 0110 1011 */ - { 12, 0xD2, 34 }, /* 0000 1101 0010 */ - { 12, 0xD3, 35 }, /* 0000 1101 0011 */ - { 12, 0xD4, 36 }, /* 0000 1101 0100 */ - { 12, 0xD5, 37 }, /* 0000 1101 0101 */ - { 12, 0xD6, 38 }, /* 0000 1101 0110 */ - { 12, 0xD7, 39 }, /* 0000 1101 0111 */ - { 12, 0x6C, 40 }, /* 0000 0110 1100 */ - { 12, 0x6D, 41 }, /* 0000 0110 1101 */ - { 12, 0xDA, 42 }, /* 0000 1101 1010 */ - { 12, 0xDB, 43 }, /* 0000 1101 1011 */ - { 12, 0x54, 44 }, /* 0000 0101 0100 */ - { 12, 0x55, 45 }, /* 0000 0101 0101 */ - { 12, 0x56, 46 }, /* 0000 0101 0110 */ - { 12, 0x57, 47 }, /* 0000 0101 0111 */ - { 12, 0x64, 48 }, /* 0000 0110 0100 */ - { 12, 0x65, 49 }, /* 0000 0110 0101 */ - { 12, 0x52, 50 }, /* 0000 0101 0010 */ - { 12, 0x53, 51 }, /* 0000 0101 0011 */ - { 12, 0x24, 52 }, /* 0000 0010 0100 */ - { 12, 0x37, 53 }, /* 0000 0011 0111 */ - { 12, 0x38, 54 }, /* 0000 0011 1000 */ - { 12, 0x27, 55 }, /* 0000 0010 0111 */ - { 12, 0x28, 56 }, /* 0000 0010 1000 */ - { 12, 0x58, 57 }, /* 0000 0101 1000 */ - { 12, 0x59, 58 }, /* 0000 0101 1001 */ - { 12, 0x2B, 59 }, /* 0000 0010 1011 */ - { 12, 0x2C, 60 }, /* 0000 0010 1100 */ - { 12, 0x5A, 61 }, /* 0000 0101 1010 */ - { 12, 0x66, 62 }, /* 0000 0110 0110 */ - { 12, 0x67, 63 }, /* 0000 0110 0111 */ - { 10, 0xF, 64 }, /* 0000 0011 11 */ - { 12, 0xC8, 128 }, /* 0000 1100 1000 */ - { 12, 0xC9, 192 }, /* 0000 1100 1001 */ - { 12, 0x5B, 256 }, /* 0000 0101 1011 */ - { 12, 0x33, 320 }, /* 0000 0011 0011 */ - { 12, 0x34, 384 }, /* 0000 0011 0100 */ - { 12, 0x35, 448 }, /* 0000 0011 0101 */ - { 13, 0x6C, 512 }, /* 0000 0011 0110 0 */ - { 13, 0x6D, 576 }, /* 0000 0011 0110 1 */ - { 13, 0x4A, 640 }, /* 0000 0010 0101 0 */ - { 13, 0x4B, 704 }, /* 0000 0010 0101 1 */ - { 13, 0x4C, 768 }, /* 0000 0010 0110 0 */ - { 13, 0x4D, 832 }, /* 0000 0010 0110 1 */ - { 13, 0x72, 896 }, /* 0000 0011 1001 0 */ - { 13, 0x73, 960 }, /* 0000 0011 1001 1 */ - { 13, 0x74, 1024 }, /* 0000 0011 1010 0 */ - { 13, 0x75, 1088 }, /* 0000 0011 1010 1 */ - { 13, 0x76, 1152 }, /* 0000 0011 1011 0 */ - { 13, 0x77, 1216 }, /* 0000 0011 1011 1 */ - { 13, 0x52, 1280 }, /* 0000 0010 1001 0 */ - { 13, 0x53, 1344 }, /* 0000 0010 1001 1 */ - { 13, 0x54, 1408 }, /* 0000 0010 1010 0 */ - { 13, 0x55, 1472 }, /* 0000 0010 1010 1 */ - { 13, 0x5A, 1536 }, /* 0000 0010 1101 0 */ - { 13, 0x5B, 1600 }, /* 0000 0010 1101 1 */ - { 13, 0x64, 1664 }, /* 0000 0011 0010 0 */ - { 13, 0x65, 1728 }, /* 0000 0011 0010 1 */ - { 11, 0x8, 1792 }, /* 0000 0001 000 */ - { 11, 0xC, 1856 }, /* 0000 0001 100 */ - { 11, 0xD, 1920 }, /* 0000 0001 101 */ - { 12, 0x12, 1984 }, /* 0000 0001 0010 */ - { 12, 0x13, 2048 }, /* 0000 0001 0011 */ - { 12, 0x14, 2112 }, /* 0000 0001 0100 */ - { 12, 0x15, 2176 }, /* 0000 0001 0101 */ - { 12, 0x16, 2240 }, /* 0000 0001 0110 */ - { 12, 0x17, 2304 }, /* 0000 0001 0111 */ - { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ - { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ - { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ - { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ - { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ - { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ - { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ - { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ - { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ -}; -#else -extern const tableentry TIFFFaxWhiteCodes[]; -extern const tableentry TIFFFaxBlackCodes[]; -#endif -#endif /* _T4_ */ diff --git a/freeimage241/Source/LibTIFF/tif_acorn.c b/freeimage241/Source/LibTIFF/tif_acorn.c deleted file mode 100644 index f1b4ea4..0000000 --- a/freeimage241/Source/LibTIFF/tif_acorn.c +++ /dev/null @@ -1,519 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_acorn.c,v 1.0 2001-04-13 00:42:27+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library RISC OS specific Routines. - * Developed out of the Unix version. - * Peter Greenham, May 1995 - */ -#include "tiffiop.h" -#include -#include - -/* -Low-level file handling -~~~~~~~~~~~~~~~~~~~~~~~ -The functions in osfcn.h are unavailable when compiling under C, as it's a -C++ header. Therefore they have been implemented here. - -Now, why have I done it this way? - -The definitive API library for RISC OS is Jonathan Coxhead's OSLib, which -uses heavily optimised ARM assembler or even plain inline SWI calls for -maximum performance and minimum runtime size. However, I don't want to make -LIBTIFF need that to survive. Therefore I have also emulated the functions -using macros to _swi() and _swix() defined in the swis.h header, and -borrowing types from kernel.h, which is less efficient but doesn't need any -third-party libraries. - */ - -#ifdef INCLUDE_OSLIB - -#include "osfile.h" -#include "osgbpb.h" -#include "osargs.h" -#include "osfind.h" - -#else - -/* OSLIB EMULATION STARTS */ - -#include "kernel.h" -#include "swis.h" - -/* From oslib:types.h */ -typedef unsigned int bits; -typedef unsigned char byte; -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef NULL -#define NULL 0 -#endif -#ifndef SKIP -#define SKIP 0 -#endif - -/* From oslib:os.h */ -typedef _kernel_oserror os_error; -typedef byte os_f; - -/* From oslib:osfile.h */ -#undef OS_File -#define OS_File 0x8 - -/* From oslib:osgbpb.h */ -#undef OS_GBPB -#define OS_GBPB 0xC -#undef OSGBPB_Write -#define OSGBPB_Write 0x2 -#undef OSGBPB_Read -#define OSGBPB_Read 0x4 - -extern os_error *xosgbpb_write (os_f file, - byte *data, - int size, - int *unwritten); -extern int osgbpb_write (os_f file, - byte *data, - int size); - -#define xosgbpb_write(file, data, size, unwritten) \ - (os_error*) _swix(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_IN(4)|_OUT(3), \ - OSGBPB_WriteAt, \ - file, \ - data, \ - size, \ - unwritten) - -#define osgbpb_write(file, data, size) \ - _swi(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_RETURN(3), \ - OSGBPB_Write, \ - file, \ - data, \ - size) - -extern os_error *xosgbpb_read (os_f file, - byte *buffer, - int size, - int *unread); -extern int osgbpb_read (os_f file, - byte *buffer, - int size); - -#define xosgbpb_read(file, buffer, size, unread) \ - (os_error*) _swix(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(3), \ - OSGBPB_Read, \ - file, \ - buffer, \ - size, \ - unread) - -#define osgbpb_read(file, buffer, size) \ - _swi(OS_GBPB, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_RETURN(3), \ - OSGBPB_Read, \ - file, \ - buffer, \ - size) - -/* From oslib:osfind.h */ -#undef OS_Find -#define OS_Find 0xD -#undef OSFind_Openin -#define OSFind_Openin 0x40 -#undef OSFind_Openout -#define OSFind_Openout 0x80 -#undef OSFind_Openup -#define OSFind_Openup 0xC0 -#undef OSFind_Close -#define OSFind_Close 0x0 - -#define xosfind_open(reason, file_name, path, file) \ - (os_error*) _swix(OS_Find, _IN(0)|_IN(1)|_IN(2)|_OUT(0), \ - reason, file_name, path, file) - -#define osfind_open(reason, file_name, path) \ - (os_f) _swi(OS_Find, _IN(0)|_IN(1)|_IN(2)|_RETURN(0), \ - reason, file_name, path) - -extern os_error *xosfind_openin (bits flags, - char *file_name, - char *path, - os_f *file); -extern os_f osfind_openin (bits flags, - char *file_name, - char *path); - -#define xosfind_openin(flags, file_name, path, file) \ - xosfind_open(flags | OSFind_Openin, file_name, path, file) - -#define osfind_openin(flags, file_name, path) \ - osfind_open(flags | OSFind_Openin, file_name, path) - -extern os_error *xosfind_openout (bits flags, - char *file_name, - char *path, - os_f *file); -extern os_f osfind_openout (bits flags, - char *file_name, - char *path); - -#define xosfind_openout(flags, file_name, path, file) \ - xosfind_open(flags | OSFind_Openout, file_name, path, file) - -#define osfind_openout(flags, file_name, path) \ - osfind_open(flags | OSFind_Openout, file_name, path) - -extern os_error *xosfind_openup (bits flags, - char *file_name, - char *path, - os_f *file); -extern os_f osfind_openup (bits flags, - char *file_name, - char *path); - -#define xosfind_openup(flags, file_name, path, file) \ - xosfind_open(flags | OSFind_Openup, file_name, path, file) - -#define osfind_openup(flags, file_name, path) \ - osfind_open(flags | OSFind_Openup, file_name, path) - -extern os_error *xosfind_close (os_f file); -extern void osfind_close (os_f file); - -#define xosfind_close(file) \ - (os_error*) _swix(OS_Find, _IN(0)|_IN(1), \ - OSFind_Close, \ - file) - -#define osfind_close(file) \ - (void) _swi(OS_Find, _IN(0)|_IN(1), \ - OSFind_Close, \ - file) - -/* From oslib:osargs.h */ -#undef OS_Args -#define OS_Args 0x9 -#undef OSArgs_ReadPtr -#define OSArgs_ReadPtr 0x0 -#undef OSArgs_SetPtr -#define OSArgs_SetPtr 0x1 -#undef OSArgs_ReadExt -#define OSArgs_ReadExt 0x2 - -extern os_error *xosargs_read_ptr (os_f file, - int *ptr); -extern int osargs_read_ptr (os_f file); - -#define xosargs_read_ptr(file, ptr) \ - (os_error*) _swix(OS_Args, _IN(0)|_IN(1)|_OUT(2), \ - OSArgs_ReadPtr, \ - file, \ - ptr) - -#define osargs_read_ptr(file) \ - _swi(OS_Args, _IN(0)|_IN(1)|_RETURN(2), \ - OSArgs_ReadPtr, \ - file) - -extern os_error *xosargs_set_ptr (os_f file, - int ptr); -extern void osargs_set_ptr (os_f file, - int ptr); - -#define xosargs_set_ptr(file, ptr) \ - (os_error*) _swix(OS_Args, _IN(0)|_IN(1)|_IN(2), \ - OSArgs_SetPtr, \ - file, \ - ptr) - -#define osargs_set_ptr(file, ptr) \ - (void) _swi(OS_Args, _IN(0)|_IN(1)|_IN(2), \ - OSArgs_SetPtr, \ - file, \ - ptr) - -extern os_error *xosargs_read_ext (os_f file, - int *ext); -extern int osargs_read_ext (os_f file); - -#define xosargs_read_ext(file, ext) \ - (os_error*) _swix(OS_Args, _IN(0)|_IN(1)|_OUT(2), \ - OSArgs_ReadExt, \ - file, \ - ext) - -#define osargs_read_ext(file) \ - _swi(OS_Args, _IN(0)|_IN(1)|_RETURN(2), \ - OSArgs_ReadExt, \ - file) - -/* OSLIB EMULATION ENDS */ - -#endif - -#ifndef __osfcn_h -/* Will be set or not during tiffcomp.h */ -/* You get this to compile under C++? Please say how! */ - -extern int open(const char* name, int flags, int mode) -{ - /* From what I can tell, should return <0 for failure */ - os_error* e = (os_error*) 1; /* Cheeky way to use a pointer eh? :-) */ - os_f file = (os_f) -1; - - flags = flags; - - switch(mode) - { - case O_RDONLY: - { - e = xosfind_openin(SKIP, name, SKIP, &file); - break; - } - case O_WRONLY: - case O_RDWR|O_CREAT: - case O_RDWR|O_CREAT|O_TRUNC: - { - e = xosfind_openout(SKIP, name, SKIP, &file); - break; - } - case O_RDWR: - { - e = xosfind_openup(SKIP, name, SKIP, &file); - break; - } - } - if (e) - { - file = (os_f) -1; - } - return (file); -} - -extern int close(int fd) -{ - return ((int) xosfind_close((os_f) fd)); -} - -extern int write(int fd, const char *buf, int nbytes) -{ - /* Returns number of bytes written */ - return (nbytes - osgbpb_write((os_f) fd, (const byte*) buf, nbytes)); -} - -extern int read(int fd, char *buf, int nbytes) -{ - /* Returns number of bytes read */ - return (nbytes - osgbpb_read((os_f) fd, (byte*) buf, nbytes)); -} - -extern off_t lseek(int fd, off_t offset, int whence) -{ - int absolute = 0; - - switch (whence) - { - case SEEK_SET: - { - absolute = (int) offset; - break; - } - case SEEK_CUR: - { - absolute = osargs_read_ptr((os_f) fd) + (int) offset; - break; - } - case SEEK_END: - { - absolute = osargs_read_ext((os_f) fd) + (int) offset; - break; - } - } - - osargs_set_ptr((os_f) fd, absolute); - - return ((off_t) osargs_read_ptr((os_f) fd)); -} -#endif - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return ((tsize_t) read((int) fd, buf, (size_t) size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return ((tsize_t) write((int) fd, buf, (size_t) size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return ((toff_t) lseek((int) fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (close((int) fd)); -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - return (lseek((int) fd, SEEK_END, SEEK_SET)); -} - -#ifdef HAVE_MMAP -#error "I didn't know Acorn had that!" -#endif - -/* !HAVE_MMAP */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - (void) fd; (void) pbase; (void) psize; - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - (void) fd; (void) base; (void) size; -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, - _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, - _tiffMapProc, _tiffUnmapProc); - if (tif) - { - tif->tif_fd = fd; - } - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - - m = _TIFFgetMode(mode, module); - - if (m == -1) - { - return ((TIFF*) 0); - } - - fd = open(name, 0, m); - - if (fd < 0) - { - TIFFError(module, "%s: Cannot open", name); - return ((TIFF *)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -void* -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -void* -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -acornWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - { - fprintf(stderr, "%s: ", module); - } - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = acornWarningHandler; - -static void -acornErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - { - fprintf(stderr, "%s: ", module); - } - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = acornErrorHandler; diff --git a/freeimage241/Source/LibTIFF/tif_apple.c b/freeimage241/Source/LibTIFF/tif_apple.c deleted file mode 100644 index 05dc229..0000000 --- a/freeimage241/Source/LibTIFF/tif_apple.c +++ /dev/null @@ -1,274 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_apple.c,v 1.0 2001-04-13 00:42:28+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library Macintosh-specific routines. - * - * These routines use only Toolbox and high-level File Manager traps. - * They make no calls to the THINK C "unix" compatibility library. Also, - * malloc is not used directly but it is still referenced internally by - * the ANSI library in rare cases. Heap fragmentation by the malloc ring - * buffer is therefore minimized. - * - * O_RDONLY and O_RDWR are treated identically here. The tif_mode flag is - * checked in TIFFWriteCheck(). - * - * Create below fills in a blank creator signature and sets the file type - * to 'TIFF'. It is much better for the application to do this by Create'ing - * the file first and TIFFOpen'ing it later. - * --------- - * This code has been "Carbonized", and may not work with older MacOS versions. - * If so, grab the tif_apple.c out of an older libtiff distribution, like - * 3.5.5 from www.libtiff.org. - */ - -#include "tiffiop.h" -#include -#include -#include -#include - -#if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) || defined(applec) -#define CtoPstr c2pstr -#endif - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (FSRead((short) fd, (long*) &size, (char*) buf) == noErr ? - size : (tsize_t) -1); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (FSWrite((short) fd, (long*) &size, (char*) buf) == noErr ? - size : (tsize_t) -1); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - long fpos, size; - - if (GetEOF((short) fd, &size) != noErr) - return EOF; - (void) GetFPos((short) fd, &fpos); - - switch (whence) { - case SEEK_CUR: - if (off + fpos > size) - SetEOF((short) fd, off + fpos); - if (SetFPos((short) fd, fsFromMark, off) != noErr) - return EOF; - break; - case SEEK_END: - if (off > 0) - SetEOF((short) fd, off + size); - if (SetFPos((short) fd, fsFromStart, off + size) != noErr) - return EOF; - break; - case SEEK_SET: - if (off > size) - SetEOF((short) fd, off); - if (SetFPos((short) fd, fsFromStart, off) != noErr) - return EOF; - break; - } - - return (toff_t)(GetFPos((short) fd, &fpos) == noErr ? fpos : EOF); -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (FSClose((short) fd)); -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - long size; - - if (GetEOF((short) fd, &size) != noErr) { - TIFFError("_tiffSizeProc", "%s: Cannot get file size"); - return (-1L); - } - return ((toff_t) size); -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -static void ourc2pstr( char* inString ) -{ - int sLen = strlen( inString ); - BlockMoveData( inString, &inString[1], sLen ); - inString[0] = sLen; -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - Str255 pname; - FInfo finfo; - short fref; - OSErr err; - FSSpec fSpec; - - strcpy((char*) pname, name); - ourc2pstr((char*) pname); - - err = FSMakeFSSpec( 0, 0, pname, &fSpec ); - - switch (_TIFFgetMode(mode, module)) { - default: - return ((TIFF*) 0); - case O_RDWR | O_CREAT | O_TRUNC: - if (FSpGetFInfo(&fSpec, &finfo) == noErr) - FSpDelete(&fSpec); - /* fall through */ - case O_RDWR | O_CREAT: - if ((err = FSpGetFInfo(&fSpec, &finfo)) == fnfErr) { - if (FSpCreate(&fSpec, ' ', 'TIFF', smSystemScript) != noErr) - goto badCreate; - if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) - goto badOpen; - } else if (err == noErr) { - if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) - goto badOpen; - } else - goto badOpen; - break; - case O_RDONLY: - if (FSpOpenDF(&fSpec, fsRdPerm, &fref) != noErr) - goto badOpen; - break; - case O_RDWR: - if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr) - goto badOpen; - break; - } - return (TIFFFdOpen((int) fref, name, mode)); -badCreate: - TIFFError(module, "%s: Cannot create", name); - return ((TIFF*) 0); -badOpen: - TIFFError(module, "%s: Cannot open", name); - return ((TIFF*) 0); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (NewPtr((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - DisposePtr(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - Ptr n = p; - - SetPtrSize(p, (size_t) s); - if (MemError() && (n = NewPtr((size_t) s)) != NULL) { - BlockMove(p, n, GetPtrSize(p)); - DisposePtr(p); - } - return ((tdata_t) n); -} - -static void -appleWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = appleWarningHandler; - -static void -appleErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = appleErrorHandler; diff --git a/freeimage241/Source/LibTIFF/tif_atari.c b/freeimage241/Source/LibTIFF/tif_atari.c deleted file mode 100644 index cd4560a..0000000 --- a/freeimage241/Source/LibTIFF/tif_atari.c +++ /dev/null @@ -1,243 +0,0 @@ -/* "$Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_atari.c,v 1.0 2001-04-13 00:42:28+02 floris_van_den_berg Exp floris_van_den_berg $" */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library ATARI-specific Routines. - */ -#include "tiffiop.h" -#if defined(__TURBOC__) -#include -#include -#else -#include -#include -#endif - -#ifndef O_ACCMODE -#define O_ACCMODE 3 -#endif - -#include - -#define AEFILNF -33 - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - long r; - - r = Fread((int) fd, size, buf); - if (r < 0) { - errno = (int)-r; - r = -1; - } - return r; -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - long r; - - r = Fwrite((int) fd, size, buf); - if (r < 0) { - errno = (int)-r; - r = -1; - } - return r; -} - -static toff_t -_tiffSeekProc(thandle_t fd, off_t off, int whence) -{ - char buf[256]; - long current_off, expected_off, new_off; - - if (whence == SEEK_END || off <= 0) - return Fseek(off, (int) fd, whence); - current_off = Fseek(0, (int) fd, SEEK_CUR); /* find out where we are */ - if (whence == SEEK_SET) - expected_off = off; - else - expected_off = off + current_off; - new_off = Fseek(off, (int) fd, whence); - if (new_off == expected_off) - return new_off; - /* otherwise extend file -- zero filling the hole */ - if (new_off < 0) /* error? */ - new_off = Fseek(0, (int) fd, SEEK_END); /* go to eof */ - _TIFFmemset(buf, 0, sizeof(buf)); - while (expected_off > new_off) { - off = expected_off - new_off; - if (off > sizeof(buf)) - off = sizeof(buf); - if ((current_off = Fwrite((int) fd, off, buf)) != off) - return (current_off > 0) ? - new_off + current_off : new_off; - new_off += off; - } - return new_off; -} - -static int -_tiffCloseProc(thandle_t fd) -{ - long r; - - r = Fclose((int) fd); - if (r < 0) { - errno = (int)-r; - r = -1; - } - return (int)r; -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - long pos, eof; - - pos = Fseek(0, (int) fd, SEEK_CUR); - eof = Fseek(0, (int) fd, SEEK_END); - Fseek(pos, (int) fd, SEEK_SET); - return eof; -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -/* -* Open a TIFF file descriptor for read/writing. -*/ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* -* Open a TIFF file for read/writing. -*/ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m; - long fd; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - if (m & O_TRUNC) { - fd = Fcreate(name, 0); - } else { - fd = Fopen(name, m & O_ACCMODE); - if (fd == AEFILNF && m & O_CREAT) - fd = Fcreate(name, 0); - } - if (fd < 0) - errno = (int)fd; - if (fd < 0) { - TIFFError(module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -#include - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, size_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, size_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -atariWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = atariWarningHandler; - -static void -atariErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = atariErrorHandler; diff --git a/freeimage241/Source/LibTIFF/tif_aux.c b/freeimage241/Source/LibTIFF/tif_aux.c deleted file mode 100644 index 7d331b7..0000000 --- a/freeimage241/Source/LibTIFF/tif_aux.c +++ /dev/null @@ -1,206 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_aux.c,v 1.0 2001-04-13 00:42:28+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1991-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Auxiliary Support Routines. - */ -#include "tiffiop.h" - -#ifdef COLORIMETRY_SUPPORT -#include - -static void -TIFFDefaultTransferFunction(TIFFDirectory* td) -{ - uint16 **tf = td->td_transferfunction; - long i, n = 1<td_bitspersample; - - tf[0] = (uint16 *)_TIFFmalloc(n * sizeof (uint16)); - tf[0][0] = 0; - for (i = 1; i < n; i++) { - double t = (double)i/((double) n-1.); - tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5); - } - if (td->td_samplesperpixel - td->td_extrasamples > 1) { - tf[1] = (uint16 *)_TIFFmalloc(n * sizeof (uint16)); - _TIFFmemcpy(tf[1], tf[0], n * sizeof (uint16)); - tf[2] = (uint16 *)_TIFFmalloc(n * sizeof (uint16)); - _TIFFmemcpy(tf[2], tf[0], n * sizeof (uint16)); - } -} - -static void -TIFFDefaultRefBlackWhite(TIFFDirectory* td) -{ - int i; - - td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float)); - for (i = 0; i < 3; i++) { - td->td_refblackwhite[2*i+0] = 0; - td->td_refblackwhite[2*i+1] = (float)((1L<td_bitspersample)-1L); - } -} -#endif - -/* - * Like TIFFGetField, but return any default - * value if the tag is not present in the directory. - * - * NB: We use the value in the directory, rather than - * explcit values so that defaults exist only one - * place in the library -- in TIFFDefaultDirectory. - */ -int -TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (TIFFVGetField(tif, tag, ap)) - return (1); - switch (tag) { - case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32 *) = td->td_subfiletype; - return (1); - case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16 *) = td->td_bitspersample; - return (1); - case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16 *) = td->td_threshholding; - return (1); - case TIFFTAG_FILLORDER: - *va_arg(ap, uint16 *) = td->td_fillorder; - return (1); - case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16 *) = td->td_orientation; - return (1); - case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16 *) = td->td_samplesperpixel; - return (1); - case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32 *) = td->td_rowsperstrip; - return (1); - case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16 *) = td->td_minsamplevalue; - return (1); - case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16 *) = td->td_maxsamplevalue; - return (1); - case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16 *) = td->td_planarconfig; - return (1); - case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16 *) = td->td_resolutionunit; - return (1); -#ifdef CMYK_SUPPORT - case TIFFTAG_DOTRANGE: - *va_arg(ap, uint16 *) = 0; - *va_arg(ap, uint16 *) = (1<td_bitspersample)-1; - return (1); - case TIFFTAG_INKSET: - *va_arg(ap, uint16 *) = td->td_inkset; - return (1); - case TIFFTAG_NUMBEROFINKS: - *va_arg(ap, uint16 *) = td->td_ninks; - return (1); -#endif - case TIFFTAG_EXTRASAMPLES: - *va_arg(ap, uint16 *) = td->td_extrasamples; - *va_arg(ap, uint16 **) = td->td_sampleinfo; - return (1); - case TIFFTAG_MATTEING: - *va_arg(ap, uint16 *) = - (td->td_extrasamples == 1 && - td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); - return (1); - case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32 *) = td->td_tiledepth; - return (1); - case TIFFTAG_DATATYPE: - *va_arg(ap, uint16 *) = td->td_sampleformat-1; - return (1); - case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16 *) = td->td_sampleformat; - return(1); - case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32 *) = td->td_imagedepth; - return (1); -#ifdef YCBCR_SUPPORT - case TIFFTAG_YCBCRCOEFFICIENTS: - if (!td->td_ycbcrcoeffs) { - td->td_ycbcrcoeffs = (float *) - _TIFFmalloc(3*sizeof (float)); - /* defaults are from CCIR Recommendation 601-1 */ - td->td_ycbcrcoeffs[0] = 0.299f; - td->td_ycbcrcoeffs[1] = 0.587f; - td->td_ycbcrcoeffs[2] = 0.114f; - } - *va_arg(ap, float **) = td->td_ycbcrcoeffs; - return (1); - case TIFFTAG_YCBCRSUBSAMPLING: - *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0]; - *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1]; - return (1); - case TIFFTAG_YCBCRPOSITIONING: - *va_arg(ap, uint16 *) = td->td_ycbcrpositioning; - return (1); -#endif -#ifdef COLORIMETRY_SUPPORT - case TIFFTAG_TRANSFERFUNCTION: - if (!td->td_transferfunction[0]) - TIFFDefaultTransferFunction(td); - *va_arg(ap, uint16 **) = td->td_transferfunction[0]; - if (td->td_samplesperpixel - td->td_extrasamples > 1) { - *va_arg(ap, uint16 **) = td->td_transferfunction[1]; - *va_arg(ap, uint16 **) = td->td_transferfunction[2]; - } - return (1); - case TIFFTAG_REFERENCEBLACKWHITE: - if (!td->td_refblackwhite) - TIFFDefaultRefBlackWhite(td); - *va_arg(ap, float **) = td->td_refblackwhite; - return (1); -#endif - } - return (0); -} - -/* - * Like TIFFGetField, but return any default - * value if the tag is not present in the directory. - */ -int -TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...) -{ - int ok; - va_list ap; - - va_start(ap, tag); - ok = TIFFVGetFieldDefaulted(tif, tag, ap); - va_end(ap); - return (ok); -} diff --git a/freeimage241/Source/LibTIFF/tif_close.c b/freeimage241/Source/LibTIFF/tif_close.c deleted file mode 100644 index 85bb40e..0000000 --- a/freeimage241/Source/LibTIFF/tif_close.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_close.c,v 1.0 2001-04-13 00:42:29+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - */ -#include "tiffiop.h" - -void -TIFFClose(TIFF* tif) -{ - if (tif->tif_mode != O_RDONLY) - /* - * Flush buffered data and directory (if dirty). - */ - TIFFFlush(tif); - (*tif->tif_cleanup)(tif); - TIFFFreeDirectory(tif); - if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER)) - _TIFFfree(tif->tif_rawdata); - if (isMapped(tif)) - TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size); - (void) TIFFCloseFile(tif); - if (tif->tif_fieldinfo) - _TIFFfree(tif->tif_fieldinfo); - _TIFFfree(tif); -} diff --git a/freeimage241/Source/LibTIFF/tif_codec.c b/freeimage241/Source/LibTIFF/tif_codec.c deleted file mode 100644 index 5b35272..0000000 --- a/freeimage241/Source/LibTIFF/tif_codec.c +++ /dev/null @@ -1,117 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_codec.c,v 1.0 2001-04-13 00:42:29+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library - * - * Builtin Compression Scheme Configuration Support. - */ -#include "tiffiop.h" - -static int NotConfigured(TIFF*, int); - -#ifndef LZW_SUPPORT -#define TIFFInitLZW NotConfigured -#endif -#ifndef PACKBITS_SUPPORT -#define TIFFInitPackbits NotConfigured -#endif -#ifndef THUNDER_SUPPORT -#define TIFFInitThunderScan NotConfigured -#endif -#ifndef NEXT_SUPPORT -#define TIFFInitNeXT NotConfigured -#endif -#ifndef JPEG_SUPPORT -#define TIFFInitJPEG NotConfigured -#endif -#ifndef OJPEG_SUPPORT -#define TIFFInitOJPEG NotConfigured -#endif -#ifndef CCITT_SUPPORT -#define TIFFInitCCITTRLE NotConfigured -#define TIFFInitCCITTRLEW NotConfigured -#define TIFFInitCCITTFax3 NotConfigured -#define TIFFInitCCITTFax4 NotConfigured -#endif -#ifndef JBIG_SUPPORT -#define TIFFInitJBIG NotConfigured -#endif -#ifndef ZIP_SUPPORT -#define TIFFInitZIP NotConfigured -#endif -#ifndef PIXARLOG_SUPPORT -#define TIFFInitPixarLog NotConfigured -#endif -#ifndef LOGLUV_SUPPORT -#define TIFFInitSGILog NotConfigured -#endif - -/* - * Compression schemes statically built into the library. - */ -#ifdef VMS -const TIFFCodec _TIFFBuiltinCODECS[] = { -#else -TIFFCodec _TIFFBuiltinCODECS[] = { -#endif - { "None", COMPRESSION_NONE, TIFFInitDumpMode }, - { "LZW", COMPRESSION_LZW, TIFFInitLZW }, - { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, - { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan }, - { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT }, - { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG }, - { "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG }, - { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE }, - { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW }, - { "CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 }, - { "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }, - { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG }, - { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP }, - { "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP }, - { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog }, - { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog }, - { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog }, - { NULL } -}; - -static int -_notConfigured(TIFF* tif) -{ - const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); - - TIFFError(tif->tif_name, - "%s compression support is not configured", c->name); - return (0); -} - -static int -NotConfigured(TIFF* tif, int scheme) -{ - tif->tif_setupdecode = _notConfigured; - tif->tif_setupencode = _notConfigured; - return (1); -} diff --git a/freeimage241/Source/LibTIFF/tif_compress.c b/freeimage241/Source/LibTIFF/tif_compress.c deleted file mode 100644 index 2feb264..0000000 --- a/freeimage241/Source/LibTIFF/tif_compress.c +++ /dev/null @@ -1,231 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_compress.c,v 1.0 2001-04-13 00:42:29+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library - * - * Compression Scheme Configuration Support. - */ -#include "tiffiop.h" - -static int -TIFFNoEncode(TIFF* tif, char* method) -{ - const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); - - if (c) { - if (! strncmp(c->name, "LZW", 3) ){ - TIFFError(tif->tif_name, - "%s %s encoding is no longer implemented due to Unisys patent enforcement", - c->name, method); - } else { - TIFFError(tif->tif_name, "%s %s encoding is not implemented", - c->name, method); - } - } - else { - TIFFError(tif->tif_name, - "Compression scheme %u %s encoding is not implemented", - tif->tif_dir.td_compression, method); - } - return (-1); -} - -int -_TIFFNoRowEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoEncode(tif, "scanline")); -} - -int -_TIFFNoStripEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoEncode(tif, "strip")); -} - -int -_TIFFNoTileEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoEncode(tif, "tile")); -} - -static int -TIFFNoDecode(TIFF* tif, char* method) -{ - const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); - - if (c) - TIFFError(tif->tif_name, "%s %s decoding is not implemented", - c->name, method); - else - TIFFError(tif->tif_name, - "Compression scheme %u %s decoding is not implemented", - tif->tif_dir.td_compression, method); - return (-1); -} - -int -_TIFFNoRowDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoDecode(tif, "scanline")); -} - -int -_TIFFNoStripDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoDecode(tif, "strip")); -} - -int -_TIFFNoTileDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) pp; (void) cc; (void) s; - return (TIFFNoDecode(tif, "tile")); -} - -int -_TIFFNoSeek(TIFF* tif, uint32 off) -{ - (void) off; - TIFFError(tif->tif_name, - "Compression algorithm does not support random access"); - return (0); -} - -int -_TIFFNoPreCode(TIFF* tif, tsample_t s) -{ - (void) tif; (void) s; - return (1); -} - -static int _TIFFtrue(TIFF* tif) { (void) tif; return (1); } -static void _TIFFvoid(TIFF* tif) { (void) tif; } - -void -_TIFFSetDefaultCompressionState(TIFF* tif) -{ - tif->tif_setupdecode = _TIFFtrue; - tif->tif_predecode = _TIFFNoPreCode; - tif->tif_decoderow = _TIFFNoRowDecode; - tif->tif_decodestrip = _TIFFNoStripDecode; - tif->tif_decodetile = _TIFFNoTileDecode; - tif->tif_setupencode = _TIFFtrue; - tif->tif_preencode = _TIFFNoPreCode; - tif->tif_postencode = _TIFFtrue; - tif->tif_encoderow = _TIFFNoRowEncode; - tif->tif_encodestrip = _TIFFNoStripEncode; - tif->tif_encodetile = _TIFFNoTileEncode; - tif->tif_close = _TIFFvoid; - tif->tif_seek = _TIFFNoSeek; - tif->tif_cleanup = _TIFFvoid; - tif->tif_defstripsize = _TIFFDefaultStripSize; - tif->tif_deftilesize = _TIFFDefaultTileSize; - tif->tif_flags &= ~TIFF_NOBITREV; -} - -int -TIFFSetCompressionScheme(TIFF* tif, int scheme) -{ - const TIFFCodec *c = TIFFFindCODEC((uint16) scheme); - - _TIFFSetDefaultCompressionState(tif); - /* - * Don't treat an unknown compression scheme as an error. - * This permits applications to open files with data that - * the library does not have builtin support for, but which - * may still be meaningful. - */ - return (c ? (*c->init)(tif, scheme) : 1); -} - -/* - * Other compression schemes may be registered. Registered - * schemes can also override the builtin versions provided - * by this library. - */ -typedef struct _codec { - struct _codec* next; - TIFFCodec* info; -} codec_t; -static codec_t* registeredCODECS = NULL; - -const TIFFCodec* -TIFFFindCODEC(uint16 scheme) -{ - const TIFFCodec* c; - codec_t* cd; - - for (cd = registeredCODECS; cd; cd = cd->next) - if (cd->info->scheme == scheme) - return ((const TIFFCodec*) cd->info); - for (c = _TIFFBuiltinCODECS; c->name; c++) - if (c->scheme == scheme) - return (c); - return ((const TIFFCodec*) 0); -} - -TIFFCodec* -TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init) -{ - codec_t* cd = (codec_t*) - _TIFFmalloc(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1); - - if (cd != NULL) { - cd->info = (TIFFCodec*) ((tidata_t) cd + sizeof (codec_t)); - cd->info->name = (char*) - ((tidata_t) cd->info + sizeof (TIFFCodec)); - strcpy(cd->info->name, name); - cd->info->scheme = scheme; - cd->info->init = init; - cd->next = registeredCODECS; - registeredCODECS = cd; - } else - TIFFError("TIFFRegisterCODEC", - "No space to register compression scheme %s", name); - return (cd->info); -} - -void -TIFFUnRegisterCODEC(TIFFCodec* c) -{ - codec_t* cd; - codec_t** pcd; - - for (pcd = ®isteredCODECS; (cd = *pcd); pcd = &cd->next) - if (cd->info == c) { - *pcd = cd->next; - _TIFFfree(cd); - return; - } - TIFFError("TIFFUnRegisterCODEC", - "Cannot remove compression scheme %s; not registered", c->name); -} diff --git a/freeimage241/Source/LibTIFF/tif_dir.c b/freeimage241/Source/LibTIFF/tif_dir.c deleted file mode 100644 index affacdf..0000000 --- a/freeimage241/Source/LibTIFF/tif_dir.c +++ /dev/null @@ -1,1303 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_dir.c,v 1.0 2001-04-13 00:42:29+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Tag Get & Set Routines. - * (and also some miscellaneous stuff) - */ -#include "tiffiop.h" - -/* - * These are used in the backwards compatibility code... - */ -#define DATATYPE_VOID 0 /* !untyped data */ -#define DATATYPE_INT 1 /* !signed integer data */ -#define DATATYPE_UINT 2 /* !unsigned integer data */ -#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */ - -void -_TIFFsetByteArray(void** vpp, void* vp, long n) -{ - if (*vpp) - _TIFFfree(*vpp), *vpp = 0; - if (vp && (*vpp = (void*) _TIFFmalloc(n))) - _TIFFmemcpy(*vpp, vp, n); -} -void _TIFFsetString(char** cpp, char* cp) - { _TIFFsetByteArray((void**) cpp, (void*) cp, (long) (strlen(cp)+1)); } -void _TIFFsetNString(char** cpp, char* cp, long n) - { _TIFFsetByteArray((void**) cpp, (void*) cp, n); } -void _TIFFsetShortArray(uint16** wpp, uint16* wp, long n) - { _TIFFsetByteArray((void**) wpp, (void*) wp, n*sizeof (uint16)); } -void _TIFFsetLongArray(uint32** lpp, uint32* lp, long n) - { _TIFFsetByteArray((void**) lpp, (void*) lp, n*sizeof (uint32)); } -void _TIFFsetFloatArray(float** fpp, float* fp, long n) - { _TIFFsetByteArray((void**) fpp, (void*) fp, n*sizeof (float)); } -void _TIFFsetDoubleArray(double** dpp, double* dp, long n) - { _TIFFsetByteArray((void**) dpp, (void*) dp, n*sizeof (double)); } - -/* - * Install extra samples information. - */ -static int -setExtraSamples(TIFFDirectory* td, va_list ap, int* v) -{ - uint16* va; - int i; - - *v = va_arg(ap, int); - if ((uint16) *v > td->td_samplesperpixel) - return (0); - va = va_arg(ap, uint16*); - if (*v > 0 && va == NULL) /* typically missing param */ - return (0); - for (i = 0; i < *v; i++) - if (va[i] > EXTRASAMPLE_UNASSALPHA) - return (0); - td->td_extrasamples = (uint16) *v; - _TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples); - return (1); -} - -#ifdef CMYK_SUPPORT -static int -checkInkNamesString(TIFF* tif, int slen, const char* s) -{ - TIFFDirectory* td = &tif->tif_dir; - int i = td->td_samplesperpixel; - - if (slen > 0) { - const char* ep = s+slen; - const char* cp = s; - for (; i > 0; i--) { - for (; *cp != '\0'; cp++) - if (cp >= ep) - goto bad; - cp++; /* skip \0 */ - } - return (cp-s); - } -bad: - TIFFError("TIFFSetField", - "%s: Invalid InkNames value; expecting %d names, found %d", - tif->tif_name, - td->td_samplesperpixel, - td->td_samplesperpixel-i); - return (0); -} -#endif - -static int -_TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - TIFFDirectory* td = &tif->tif_dir; - int status = 1; - uint32 v32; - int i, v; - double d; - char* s; - - switch (tag) { - case TIFFTAG_SUBFILETYPE: - td->td_subfiletype = va_arg(ap, uint32); - break; - case TIFFTAG_IMAGEWIDTH: - td->td_imagewidth = va_arg(ap, uint32); - break; - case TIFFTAG_IMAGELENGTH: - td->td_imagelength = va_arg(ap, uint32); - break; - case TIFFTAG_BITSPERSAMPLE: - td->td_bitspersample = (uint16) va_arg(ap, int); - /* - * If the data require post-decoding processing - * to byte-swap samples, set it up here. Note - * that since tags are required to be ordered, - * compression code can override this behaviour - * in the setup method if it wants to roll the - * post decoding work in with its normal work. - */ - if (tif->tif_flags & TIFF_SWAB) { - if (td->td_bitspersample == 16) - tif->tif_postdecode = _TIFFSwab16BitData; - else if (td->td_bitspersample == 32) - tif->tif_postdecode = _TIFFSwab32BitData; - else if (td->td_bitspersample == 64) - tif->tif_postdecode = _TIFFSwab64BitData; - } - break; - case TIFFTAG_COMPRESSION: - v = va_arg(ap, int) & 0xffff; - /* - * If we're changing the compression scheme, - * the notify the previous module so that it - * can cleanup any state it's setup. - */ - if (TIFFFieldSet(tif, FIELD_COMPRESSION)) { - if (td->td_compression == v) - break; - (*tif->tif_cleanup)(tif); - tif->tif_flags &= ~TIFF_CODERSETUP; - } - /* - * Setup new compression routine state. - */ - if ( ! tif->tif_mode == O_RDONLY ) { - /* Handle removal of LZW compression */ - if ( v == COMPRESSION_LZW ) { - TIFFError(tif->tif_name, - "LZW compression no longer supported due to Unisys patent enforcement"); - v=COMPRESSION_NONE; - } - } - if( (status = TIFFSetCompressionScheme(tif, v)) != 0 ) - td->td_compression = v; - break; - case TIFFTAG_PHOTOMETRIC: - td->td_photometric = (uint16) va_arg(ap, int); - break; - case TIFFTAG_THRESHHOLDING: - td->td_threshholding = (uint16) va_arg(ap, int); - break; - case TIFFTAG_FILLORDER: - v = va_arg(ap, int); - if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) - goto badvalue; - td->td_fillorder = (uint16) v; - break; - case TIFFTAG_DOCUMENTNAME: - _TIFFsetString(&td->td_documentname, va_arg(ap, char*)); - break; - case TIFFTAG_ARTIST: - _TIFFsetString(&td->td_artist, va_arg(ap, char*)); - break; - case TIFFTAG_DATETIME: - _TIFFsetString(&td->td_datetime, va_arg(ap, char*)); - break; - case TIFFTAG_HOSTCOMPUTER: - _TIFFsetString(&td->td_hostcomputer, va_arg(ap, char*)); - break; - case TIFFTAG_IMAGEDESCRIPTION: - _TIFFsetString(&td->td_imagedescription, va_arg(ap, char*)); - break; - case TIFFTAG_MAKE: - _TIFFsetString(&td->td_make, va_arg(ap, char*)); - break; - case TIFFTAG_MODEL: - _TIFFsetString(&td->td_model, va_arg(ap, char*)); - break; - case TIFFTAG_SOFTWARE: - _TIFFsetString(&td->td_software, va_arg(ap, char*)); - break; - case TIFFTAG_ORIENTATION: - v = va_arg(ap, int); - if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) { - TIFFWarning(tif->tif_name, - "Bad value %ld for \"%s\" tag ignored", - v, _TIFFFieldWithTag(tif, tag)->field_name); - } else - td->td_orientation = (uint16) v; - break; - case TIFFTAG_SAMPLESPERPIXEL: - /* XXX should cross check -- e.g. if pallette, then 1 */ - v = va_arg(ap, int); - if (v == 0) - goto badvalue; - td->td_samplesperpixel = (uint16) v; - break; - case TIFFTAG_ROWSPERSTRIP: - v32 = va_arg(ap, uint32); - if (v32 == 0) - goto badvalue32; - td->td_rowsperstrip = v32; - if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { - td->td_tilelength = v32; - td->td_tilewidth = td->td_imagewidth; - } - break; - case TIFFTAG_MINSAMPLEVALUE: - td->td_minsamplevalue = (uint16) va_arg(ap, int); - break; - case TIFFTAG_MAXSAMPLEVALUE: - td->td_maxsamplevalue = (uint16) va_arg(ap, int); - break; - case TIFFTAG_SMINSAMPLEVALUE: - td->td_sminsamplevalue = (double) va_arg(ap, dblparam_t); - break; - case TIFFTAG_SMAXSAMPLEVALUE: - td->td_smaxsamplevalue = (double) va_arg(ap, dblparam_t); - break; - case TIFFTAG_XRESOLUTION: - td->td_xresolution = (float) va_arg(ap, dblparam_t); - break; - case TIFFTAG_YRESOLUTION: - td->td_yresolution = (float) va_arg(ap, dblparam_t); - break; - case TIFFTAG_PLANARCONFIG: - v = va_arg(ap, int); - if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) - goto badvalue; - td->td_planarconfig = (uint16) v; - break; - case TIFFTAG_PAGENAME: - _TIFFsetString(&td->td_pagename, va_arg(ap, char*)); - break; - case TIFFTAG_XPOSITION: - td->td_xposition = (float) va_arg(ap, dblparam_t); - break; - case TIFFTAG_YPOSITION: - td->td_yposition = (float) va_arg(ap, dblparam_t); - break; - case TIFFTAG_RESOLUTIONUNIT: - v = va_arg(ap, int); - if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) - goto badvalue; - td->td_resolutionunit = (uint16) v; - break; - case TIFFTAG_PAGENUMBER: - td->td_pagenumber[0] = (uint16) va_arg(ap, int); - td->td_pagenumber[1] = (uint16) va_arg(ap, int); - break; - case TIFFTAG_HALFTONEHINTS: - td->td_halftonehints[0] = (uint16) va_arg(ap, int); - td->td_halftonehints[1] = (uint16) va_arg(ap, int); - break; - case TIFFTAG_COLORMAP: - v32 = (uint32)(1L<td_bitspersample); - _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32); - _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32); - _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32); - break; - case TIFFTAG_EXTRASAMPLES: - if (!setExtraSamples(td, ap, &v)) - goto badvalue; - break; - case TIFFTAG_MATTEING: - td->td_extrasamples = (uint16) (va_arg(ap, int) != 0); - if (td->td_extrasamples) { - uint16 sv = EXTRASAMPLE_ASSOCALPHA; - _TIFFsetShortArray(&td->td_sampleinfo, &sv, 1); - } - break; - case TIFFTAG_TILEWIDTH: - v32 = va_arg(ap, uint32); - if (v32 % 16) { - if (tif->tif_mode != O_RDONLY) - goto badvalue32; - TIFFWarning(tif->tif_name, - "Nonstandard tile width %d, convert file", v32); - } - td->td_tilewidth = v32; - tif->tif_flags |= TIFF_ISTILED; - break; - case TIFFTAG_TILELENGTH: - v32 = va_arg(ap, uint32); - if (v32 % 16) { - if (tif->tif_mode != O_RDONLY) - goto badvalue32; - TIFFWarning(tif->tif_name, - "Nonstandard tile length %d, convert file", v32); - } - td->td_tilelength = v32; - tif->tif_flags |= TIFF_ISTILED; - break; - case TIFFTAG_TILEDEPTH: - v32 = va_arg(ap, uint32); - if (v32 == 0) - goto badvalue32; - td->td_tiledepth = v32; - break; - case TIFFTAG_DATATYPE: - v = va_arg(ap, int); - switch (v) { - case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break; - case DATATYPE_INT: v = SAMPLEFORMAT_INT; break; - case DATATYPE_UINT: v = SAMPLEFORMAT_UINT; break; - case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break; - default: goto badvalue; - } - td->td_sampleformat = (uint16) v; - break; - case TIFFTAG_SAMPLEFORMAT: - v = va_arg(ap, int); - if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v) - goto badvalue; - td->td_sampleformat = (uint16) v; - break; - case TIFFTAG_IMAGEDEPTH: - td->td_imagedepth = va_arg(ap, uint32); - break; - case TIFFTAG_STONITS: - d = va_arg(ap, dblparam_t); - if (d <= 0.) - goto badvaluedbl; - td->td_stonits = d; - break; - - /* Begin Pixar Tags */ - case TIFFTAG_PIXAR_IMAGEFULLWIDTH: - td->td_imagefullwidth = va_arg(ap, uint32); - break; - case TIFFTAG_PIXAR_IMAGEFULLLENGTH: - td->td_imagefulllength = va_arg(ap, uint32); - break; - case TIFFTAG_PIXAR_TEXTUREFORMAT: - _TIFFsetString(&td->td_textureformat, va_arg(ap, char*)); - break; - case TIFFTAG_PIXAR_WRAPMODES: - _TIFFsetString(&td->td_wrapmodes, va_arg(ap, char*)); - break; - case TIFFTAG_PIXAR_FOVCOT: - td->td_fovcot = (float) va_arg(ap, dblparam_t); - break; - case TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN: - _TIFFsetFloatArray(&td->td_matrixWorldToScreen, - va_arg(ap, float*), 16); - break; - case TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA: - _TIFFsetFloatArray(&td->td_matrixWorldToCamera, - va_arg(ap, float*), 16); - break; - /* End Pixar Tags */ - -#if SUBIFD_SUPPORT - case TIFFTAG_SUBIFD: - if ((tif->tif_flags & TIFF_INSUBIFD) == 0) { - td->td_nsubifd = (uint16) va_arg(ap, int); - _TIFFsetLongArray(&td->td_subifd, va_arg(ap, uint32*), - (long) td->td_nsubifd); - } else { - TIFFError(tif->tif_name, "Sorry, cannot nest SubIFDs"); - status = 0; - } - break; -#endif -#ifdef YCBCR_SUPPORT - case TIFFTAG_YCBCRCOEFFICIENTS: - _TIFFsetFloatArray(&td->td_ycbcrcoeffs, va_arg(ap, float*), 3); - break; - case TIFFTAG_YCBCRPOSITIONING: - td->td_ycbcrpositioning = (uint16) va_arg(ap, int); - break; - case TIFFTAG_YCBCRSUBSAMPLING: - td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, int); - td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, int); - break; -#endif -#ifdef COLORIMETRY_SUPPORT - case TIFFTAG_WHITEPOINT: - _TIFFsetFloatArray(&td->td_whitepoint, va_arg(ap, float*), 2); - break; - case TIFFTAG_PRIMARYCHROMATICITIES: - _TIFFsetFloatArray(&td->td_primarychromas, va_arg(ap, float*), 6); - break; - case TIFFTAG_TRANSFERFUNCTION: - v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1; - for (i = 0; i < v; i++) - _TIFFsetShortArray(&td->td_transferfunction[i], - va_arg(ap, uint16*), 1L<td_bitspersample); - break; - case TIFFTAG_REFERENCEBLACKWHITE: - /* XXX should check for null range */ - _TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6); - break; -#endif -#ifdef CMYK_SUPPORT - case TIFFTAG_INKSET: - td->td_inkset = (uint16) va_arg(ap, int); - break; - case TIFFTAG_DOTRANGE: - /* XXX should check for null range */ - td->td_dotrange[0] = (uint16) va_arg(ap, int); - td->td_dotrange[1] = (uint16) va_arg(ap, int); - break; - case TIFFTAG_INKNAMES: - i = va_arg(ap, int); - s = va_arg(ap, char*); - i = checkInkNamesString(tif, i, s); - status = i > 0; - if( i > 0 ) { - _TIFFsetNString(&td->td_inknames, s, i); - td->td_inknameslen = i; - } - break; - case TIFFTAG_NUMBEROFINKS: - td->td_ninks = (uint16) va_arg(ap, int); - break; - case TIFFTAG_TARGETPRINTER: - _TIFFsetString(&td->td_targetprinter, va_arg(ap, char*)); - break; -#endif -#ifdef ICC_SUPPORT - case TIFFTAG_ICCPROFILE: - td->td_profileLength = (uint32) va_arg(ap, uint32); - _TIFFsetByteArray(&td->td_profileData, va_arg(ap, void*), - td->td_profileLength); - break; -#endif -#ifdef PHOTOSHOP_SUPPORT - case TIFFTAG_PHOTOSHOP: - td->td_photoshopLength = (uint32) va_arg(ap, uint32); - _TIFFsetByteArray (&td->td_photoshopData, va_arg(ap, void*), - td->td_photoshopLength); - break; -#endif -#ifdef IPTC_SUPPORT - case TIFFTAG_RICHTIFFIPTC: - td->td_richtiffiptcLength = (uint32) va_arg(ap, uint32); -#ifdef PHOTOSHOP_SUPPORT - _TIFFsetLongArray ((uint32**)&td->td_richtiffiptcData, va_arg(ap, uint32*), - td->td_richtiffiptcLength); -#else - _TIFFsetByteArray (&td->td_photoshopData, va_arg(ap, void*), - td->td_photoshopLength); -#endif - break; -#endif - default: - /* - * This can happen if multiple images are open with - * different codecs which have private tags. The - * global tag information table may then have tags - * that are valid for one file but not the other. - * If the client tries to set a tag that is not valid - * for the image's codec then we'll arrive here. This - * happens, for example, when tiffcp is used to convert - * between compression schemes and codec-specific tags - * are blindly copied. - */ - TIFFError("TIFFSetField", - "%s: Invalid %stag \"%s\" (not supported by codec)", - tif->tif_name, isPseudoTag(tag) ? "pseduo-" : "", - _TIFFFieldWithTag(tif, tag)->field_name); - status = 0; - break; - } - if (status) { - TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); - tif->tif_flags |= TIFF_DIRTYDIRECT; - } - va_end(ap); - return (status); -badvalue: - TIFFError(tif->tif_name, "%d: Bad value for \"%s\"", v, - _TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); - return (0); -badvalue32: - TIFFError(tif->tif_name, "%ld: Bad value for \"%s\"", v32, - _TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); - return (0); -badvaluedbl: - TIFFError(tif->tif_name, "%f: Bad value for \"%s\"", d, - _TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); - return (0); -} - -/* - * Return 1/0 according to whether or not - * it is permissible to set the tag's value. - * Note that we allow ImageLength to be changed - * so that we can append and extend to images. - * Any other tag may not be altered once writing - * has commenced, unless its value has no effect - * on the format of the data that is written. - */ -static int -OkToChangeTag(TIFF* tif, ttag_t tag) -{ - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - if (!fip) { /* unknown tag */ - TIFFError("TIFFSetField", "%s: Unknown %stag %u", - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); - return (0); - } - if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) && - !fip->field_oktochange) { - /* - * Consult info table to see if tag can be changed - * after we've started writing. We only allow changes - * to those tags that don't/shouldn't affect the - * compression and/or format of the data. - */ - TIFFError("TIFFSetField", - "%s: Cannot modify tag \"%s\" while writing", - tif->tif_name, fip->field_name); - return (0); - } - return (1); -} - -/* - * Record the value of a field in the - * internal directory structure. The - * field will be written to the file - * when/if the directory structure is - * updated. - */ -int -TIFFSetField(TIFF* tif, ttag_t tag, ...) -{ - va_list ap; - int status; - - va_start(ap, tag); - status = TIFFVSetField(tif, tag, ap); - va_end(ap); - return (status); -} - -/* - * Like TIFFSetField, but taking a varargs - * parameter list. This routine is useful - * for building higher-level interfaces on - * top of the library. - */ -int -TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - return OkToChangeTag(tif, tag) ? - (*tif->tif_vsetfield)(tif, tag, ap) : 0; -} - -static int -_TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - TIFFDirectory* td = &tif->tif_dir; - - switch (tag) { - case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32*) = td->td_subfiletype; - break; - case TIFFTAG_IMAGEWIDTH: - *va_arg(ap, uint32*) = td->td_imagewidth; - break; - case TIFFTAG_IMAGELENGTH: - *va_arg(ap, uint32*) = td->td_imagelength; - break; - case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16*) = td->td_bitspersample; - break; - case TIFFTAG_COMPRESSION: - *va_arg(ap, uint16*) = td->td_compression; - break; - case TIFFTAG_PHOTOMETRIC: - *va_arg(ap, uint16*) = td->td_photometric; - break; - case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16*) = td->td_threshholding; - break; - case TIFFTAG_FILLORDER: - *va_arg(ap, uint16*) = td->td_fillorder; - break; - case TIFFTAG_DOCUMENTNAME: - *va_arg(ap, char**) = td->td_documentname; - break; - case TIFFTAG_ARTIST: - *va_arg(ap, char**) = td->td_artist; - break; - case TIFFTAG_DATETIME: - *va_arg(ap, char**) = td->td_datetime; - break; - case TIFFTAG_HOSTCOMPUTER: - *va_arg(ap, char**) = td->td_hostcomputer; - break; - case TIFFTAG_IMAGEDESCRIPTION: - *va_arg(ap, char**) = td->td_imagedescription; - break; - case TIFFTAG_MAKE: - *va_arg(ap, char**) = td->td_make; - break; - case TIFFTAG_MODEL: - *va_arg(ap, char**) = td->td_model; - break; - case TIFFTAG_SOFTWARE: - *va_arg(ap, char**) = td->td_software; - break; - case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16*) = td->td_orientation; - break; - case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16*) = td->td_samplesperpixel; - break; - case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32*) = td->td_rowsperstrip; - break; - case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16*) = td->td_minsamplevalue; - break; - case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16*) = td->td_maxsamplevalue; - break; - case TIFFTAG_SMINSAMPLEVALUE: - *va_arg(ap, double*) = td->td_sminsamplevalue; - break; - case TIFFTAG_SMAXSAMPLEVALUE: - *va_arg(ap, double*) = td->td_smaxsamplevalue; - break; - case TIFFTAG_XRESOLUTION: - *va_arg(ap, float*) = td->td_xresolution; - break; - case TIFFTAG_YRESOLUTION: - *va_arg(ap, float*) = td->td_yresolution; - break; - case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16*) = td->td_planarconfig; - break; - case TIFFTAG_XPOSITION: - *va_arg(ap, float*) = td->td_xposition; - break; - case TIFFTAG_YPOSITION: - *va_arg(ap, float*) = td->td_yposition; - break; - case TIFFTAG_PAGENAME: - *va_arg(ap, char**) = td->td_pagename; - break; - case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16*) = td->td_resolutionunit; - break; - case TIFFTAG_PAGENUMBER: - *va_arg(ap, uint16*) = td->td_pagenumber[0]; - *va_arg(ap, uint16*) = td->td_pagenumber[1]; - break; - case TIFFTAG_HALFTONEHINTS: - *va_arg(ap, uint16*) = td->td_halftonehints[0]; - *va_arg(ap, uint16*) = td->td_halftonehints[1]; - break; - case TIFFTAG_COLORMAP: - *va_arg(ap, uint16**) = td->td_colormap[0]; - *va_arg(ap, uint16**) = td->td_colormap[1]; - *va_arg(ap, uint16**) = td->td_colormap[2]; - break; - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_TILEOFFSETS: - *va_arg(ap, uint32**) = td->td_stripoffset; - break; - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEBYTECOUNTS: - *va_arg(ap, uint32**) = td->td_stripbytecount; - break; - case TIFFTAG_MATTEING: - *va_arg(ap, uint16*) = - (td->td_extrasamples == 1 && - td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); - break; - case TIFFTAG_EXTRASAMPLES: - *va_arg(ap, uint16*) = td->td_extrasamples; - *va_arg(ap, uint16**) = td->td_sampleinfo; - break; - case TIFFTAG_TILEWIDTH: - *va_arg(ap, uint32*) = td->td_tilewidth; - break; - case TIFFTAG_TILELENGTH: - *va_arg(ap, uint32*) = td->td_tilelength; - break; - case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32*) = td->td_tiledepth; - break; - case TIFFTAG_DATATYPE: - switch (td->td_sampleformat) { - case SAMPLEFORMAT_UINT: - *va_arg(ap, uint16*) = DATATYPE_UINT; - break; - case SAMPLEFORMAT_INT: - *va_arg(ap, uint16*) = DATATYPE_INT; - break; - case SAMPLEFORMAT_IEEEFP: - *va_arg(ap, uint16*) = DATATYPE_IEEEFP; - break; - case SAMPLEFORMAT_VOID: - *va_arg(ap, uint16*) = DATATYPE_VOID; - break; - } - break; - case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16*) = td->td_sampleformat; - break; - case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32*) = td->td_imagedepth; - break; - case TIFFTAG_STONITS: - *va_arg(ap, double*) = td->td_stonits; - break; -#if SUBIFD_SUPPORT - case TIFFTAG_SUBIFD: - *va_arg(ap, uint16*) = td->td_nsubifd; - *va_arg(ap, uint32**) = td->td_subifd; - break; -#endif -#ifdef YCBCR_SUPPORT - case TIFFTAG_YCBCRCOEFFICIENTS: - *va_arg(ap, float**) = td->td_ycbcrcoeffs; - break; - case TIFFTAG_YCBCRPOSITIONING: - *va_arg(ap, uint16*) = td->td_ycbcrpositioning; - break; - case TIFFTAG_YCBCRSUBSAMPLING: - *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0]; - *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1]; - break; -#endif -#ifdef COLORIMETRY_SUPPORT - case TIFFTAG_WHITEPOINT: - *va_arg(ap, float**) = td->td_whitepoint; - break; - case TIFFTAG_PRIMARYCHROMATICITIES: - *va_arg(ap, float**) = td->td_primarychromas; - break; - case TIFFTAG_TRANSFERFUNCTION: - *va_arg(ap, uint16**) = td->td_transferfunction[0]; - if (td->td_samplesperpixel - td->td_extrasamples > 1) { - *va_arg(ap, uint16**) = td->td_transferfunction[1]; - *va_arg(ap, uint16**) = td->td_transferfunction[2]; - } - break; - case TIFFTAG_REFERENCEBLACKWHITE: - *va_arg(ap, float**) = td->td_refblackwhite; - break; -#endif -#ifdef CMYK_SUPPORT - case TIFFTAG_INKSET: - *va_arg(ap, uint16*) = td->td_inkset; - break; - case TIFFTAG_DOTRANGE: - *va_arg(ap, uint16*) = td->td_dotrange[0]; - *va_arg(ap, uint16*) = td->td_dotrange[1]; - break; - case TIFFTAG_INKNAMES: - *va_arg(ap, char**) = td->td_inknames; - break; - case TIFFTAG_NUMBEROFINKS: - *va_arg(ap, uint16*) = td->td_ninks; - break; - case TIFFTAG_TARGETPRINTER: - *va_arg(ap, char**) = td->td_targetprinter; - break; -#endif -#ifdef ICC_SUPPORT - case TIFFTAG_ICCPROFILE: - *va_arg(ap, uint32*) = td->td_profileLength; - *va_arg(ap, void**) = td->td_profileData; - break; -#endif -#ifdef PHOTOSHOP_SUPPORT - case TIFFTAG_PHOTOSHOP: - *va_arg(ap, uint32*) = td->td_photoshopLength; - *va_arg(ap, void**) = td->td_photoshopData; - break; -#endif -#ifdef IPTC_SUPPORT - case TIFFTAG_RICHTIFFIPTC: - *va_arg(ap, uint32*) = td->td_richtiffiptcLength; - *va_arg(ap, void**) = td->td_richtiffiptcData; - break; -#endif - /* Begin Pixar Tags */ - case TIFFTAG_PIXAR_IMAGEFULLWIDTH: - *va_arg(ap, uint32*) = td->td_imagefullwidth; - break; - case TIFFTAG_PIXAR_IMAGEFULLLENGTH: - *va_arg(ap, uint32*) = td->td_imagefulllength; - break; - case TIFFTAG_PIXAR_TEXTUREFORMAT: - *va_arg(ap, char**) = td->td_textureformat; - break; - case TIFFTAG_PIXAR_WRAPMODES: - *va_arg(ap, char**) = td->td_wrapmodes; - break; - case TIFFTAG_PIXAR_FOVCOT: - *va_arg(ap, float*) = td->td_fovcot; - break; - case TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN: - *va_arg(ap, float**) = td->td_matrixWorldToScreen; - break; - case TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA: - *va_arg(ap, float**) = td->td_matrixWorldToCamera; - break; - /* End Pixar Tags */ - - default: - /* - * This can happen if multiple images are open with - * different codecs which have private tags. The - * global tag information table may then have tags - * that are valid for one file but not the other. - * If the client tries to get a tag that is not valid - * for the image's codec then we'll arrive here. - */ - TIFFError("TIFFGetField", - "%s: Invalid %stag \"%s\" (not supported by codec)", - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", - _TIFFFieldWithTag(tif, tag)->field_name); - break; - } - return (1); -} - -/* - * Return the value of a field in the - * internal directory structure. - */ -int -TIFFGetField(TIFF* tif, ttag_t tag, ...) -{ - int status; - va_list ap; - - va_start(ap, tag); - status = TIFFVGetField(tif, tag, ap); - va_end(ap); - return (status); -} - -/* - * Like TIFFGetField, but taking a varargs - * parameter list. This routine is useful - * for building higher-level interfaces on - * top of the library. - */ -int -TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ? - (*tif->tif_vgetfield)(tif, tag, ap) : 0); -} - -#define CleanupField(member) { \ - if (td->member) { \ - _TIFFfree(td->member); \ - td->member = 0; \ - } \ -} - -/* - * Release storage associated with a directory. - */ -void -TIFFFreeDirectory(TIFF* tif) -{ - register TIFFDirectory *td = &tif->tif_dir; - - CleanupField(td_colormap[0]); - CleanupField(td_colormap[1]); - CleanupField(td_colormap[2]); - CleanupField(td_documentname); - CleanupField(td_artist); - CleanupField(td_datetime); - CleanupField(td_hostcomputer); - CleanupField(td_imagedescription); - CleanupField(td_make); - CleanupField(td_model); - CleanupField(td_software); - CleanupField(td_pagename); - CleanupField(td_sampleinfo); -#if SUBIFD_SUPPORT - CleanupField(td_subifd); -#endif -#ifdef YCBCR_SUPPORT - CleanupField(td_ycbcrcoeffs); -#endif -#ifdef CMYK_SUPPORT - CleanupField(td_inknames); - CleanupField(td_targetprinter); -#endif -#ifdef COLORIMETRY_SUPPORT - CleanupField(td_whitepoint); - CleanupField(td_primarychromas); - CleanupField(td_refblackwhite); - CleanupField(td_transferfunction[0]); - CleanupField(td_transferfunction[1]); - CleanupField(td_transferfunction[2]); -#endif -#ifdef ICC_SUPPORT - CleanupField(td_profileData); -#endif -#ifdef PHOTOSHOP_SUPPORT - CleanupField(td_photoshopData); -#endif -#ifdef IPTC_SUPPORT - CleanupField(td_richtiffiptcData); -#endif - CleanupField(td_stripoffset); - CleanupField(td_stripbytecount); - /* Begin Pixar Tags */ - CleanupField(td_textureformat); - CleanupField(td_wrapmodes); - CleanupField(td_matrixWorldToScreen); - CleanupField(td_matrixWorldToCamera); - /* End Pixar Tags */ -} -#undef CleanupField - -/* - * Client Tag extension support (from Niles Ritter). - */ -static TIFFExtendProc _TIFFextender = (TIFFExtendProc) NULL; - -TIFFExtendProc -TIFFSetTagExtender(TIFFExtendProc extender) -{ - TIFFExtendProc prev = _TIFFextender; - _TIFFextender = extender; - return (prev); -} - -/* - * Setup for a new directory. Should we automatically call - * TIFFWriteDirectory() if the current one is dirty? - * - * The newly created directory will not exist on the file till - * TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called. - */ -int -TIFFCreateDirectory(TIFF* tif) -{ - TIFFDefaultDirectory(tif); - tif->tif_diroff = 0; - tif->tif_nextdiroff = 0; - tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; - - return 0; -} - -/* - * Setup a default directory structure. - */ -int -TIFFDefaultDirectory(TIFF* tif) -{ - register TIFFDirectory* td = &tif->tif_dir; - - _TIFFSetupFieldInfo(tif); - _TIFFmemset(td, 0, sizeof (*td)); - td->td_fillorder = FILLORDER_MSB2LSB; - td->td_bitspersample = 1; - td->td_threshholding = THRESHHOLD_BILEVEL; - td->td_orientation = ORIENTATION_TOPLEFT; - td->td_samplesperpixel = 1; - td->td_rowsperstrip = (uint32) -1; - td->td_tilewidth = (uint32) -1; - td->td_tilelength = (uint32) -1; - td->td_tiledepth = 1; - td->td_resolutionunit = RESUNIT_INCH; - td->td_sampleformat = SAMPLEFORMAT_UINT; - td->td_imagedepth = 1; -#ifdef YCBCR_SUPPORT - td->td_ycbcrsubsampling[0] = 2; - td->td_ycbcrsubsampling[1] = 2; - td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED; -#endif -#ifdef CMYK_SUPPORT - td->td_inkset = INKSET_CMYK; - td->td_ninks = 4; -#endif - tif->tif_postdecode = _TIFFNoPostDecode; - tif->tif_vsetfield = _TIFFVSetField; - tif->tif_vgetfield = _TIFFVGetField; - tif->tif_printdir = NULL; - /* - * Give client code a chance to install their own - * tag extensions & methods, prior to compression overloads. - */ - if (_TIFFextender) - (*_TIFFextender)(tif); - (void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - /* - * NB: The directory is marked dirty as a result of setting - * up the default compression scheme. However, this really - * isn't correct -- we want TIFF_DIRTYDIRECT to be set only - * if the user does something. We could just do the setup - * by hand, but it seems better to use the normal mechanism - * (i.e. TIFFSetField). - */ - tif->tif_flags &= ~TIFF_DIRTYDIRECT; - - /* - * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19 - * we clear the ISTILED flag when setting up a new directory. - * Should we also be clearing stuff like INSUBIFD? - */ - tif->tif_flags &= ~TIFF_ISTILED; - - return (1); -} - -static int -TIFFAdvanceDirectory(TIFF* tif, uint32* nextdir, toff_t* off) -{ - static const char module[] = "TIFFAdvanceDirectory"; - uint16 dircount; - if (isMapped(tif)) - { - toff_t poff=*nextdir; - if (poff+sizeof(uint16) > tif->tif_size) - { - TIFFError(module, "%s: Error fetching directory count", - tif->tif_name); - return (0); - } - _TIFFmemcpy(&dircount, tif->tif_base+poff, sizeof (uint16)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - poff+=sizeof (uint16)+dircount*sizeof (TIFFDirEntry); - if (off != NULL) - *off = poff; - if (((toff_t) (poff+sizeof (uint32))) > tif->tif_size) - { - TIFFError(module, "%s: Error fetching directory link", - tif->tif_name); - return (0); - } - _TIFFmemcpy(nextdir, tif->tif_base+poff, sizeof (uint32)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(nextdir); - return (1); - } - else - { - if (!SeekOK(tif, *nextdir) || - !ReadOK(tif, &dircount, sizeof (uint16))) { - TIFFError(module, "%s: Error fetching directory count", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - if (off != NULL) - *off = TIFFSeekFile(tif, - dircount*sizeof (TIFFDirEntry), SEEK_CUR); - else - (void) TIFFSeekFile(tif, - dircount*sizeof (TIFFDirEntry), SEEK_CUR); - if (!ReadOK(tif, nextdir, sizeof (uint32))) { - TIFFError(module, "%s: Error fetching directory link", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(nextdir); - return (1); - } -} - -/* - * Count the number of directories in a file. - */ -tdir_t -TIFFNumberOfDirectories(TIFF* tif) -{ - toff_t nextdir = tif->tif_header.tiff_diroff; - tdir_t n = 0; - - while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL)) - n++; - return (n); -} - -/* - * Set the n-th directory as the current directory. - * NB: Directories are numbered starting at 0. - */ -int -TIFFSetDirectory(TIFF* tif, tdir_t dirn) -{ - toff_t nextdir; - tdir_t n; - - nextdir = tif->tif_header.tiff_diroff; - for (n = dirn; n > 0 && nextdir != 0; n--) - if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) - return (0); - tif->tif_nextdiroff = nextdir; - /* - * Set curdir to the actual directory index. The - * -1 is because TIFFReadDirectory will increment - * tif_curdir after successfully reading the directory. - */ - tif->tif_curdir = (dirn - n) - 1; - return (TIFFReadDirectory(tif)); -} - -/* - * Set the current directory to be the directory - * located at the specified file offset. This interface - * is used mainly to access directories linked with - * the SubIFD tag (e.g. thumbnail images). - */ -int -TIFFSetSubDirectory(TIFF* tif, uint32 diroff) -{ - tif->tif_nextdiroff = diroff; - return (TIFFReadDirectory(tif)); -} - -/* - * Return file offset of the current directory. - */ -uint32 -TIFFCurrentDirOffset(TIFF* tif) -{ - return (tif->tif_diroff); -} - -/* - * Return an indication of whether or not we are - * at the last directory in the file. - */ -int -TIFFLastDirectory(TIFF* tif) -{ - return (tif->tif_nextdiroff == 0); -} - -/* - * Unlink the specified directory from the directory chain. - */ -int -TIFFUnlinkDirectory(TIFF* tif, tdir_t dirn) -{ - static const char module[] = "TIFFUnlinkDirectory"; - toff_t nextdir; - toff_t off; - tdir_t n; - - if (tif->tif_mode == O_RDONLY) { - TIFFError(module, "Can not unlink directory in read-only file"); - return (0); - } - /* - * Go to the directory before the one we want - * to unlink and nab the offset of the link - * field we'll need to patch. - */ - nextdir = tif->tif_header.tiff_diroff; - off = sizeof (uint16) + sizeof (uint16); - for (n = dirn-1; n > 0; n--) { - if (nextdir == 0) { - TIFFError(module, "Directory %d does not exist", dirn); - return (0); - } - if (!TIFFAdvanceDirectory(tif, &nextdir, &off)) - return (0); - } - /* - * Advance to the directory to be unlinked and fetch - * the offset of the directory that follows. - */ - if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) - return (0); - /* - * Go back and patch the link field of the preceding - * directory to point to the offset of the directory - * that follows. - */ - (void) TIFFSeekFile(tif, off, SEEK_SET); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir); - if (!WriteOK(tif, &nextdir, sizeof (uint32))) { - TIFFError(module, "Error writing directory link"); - return (0); - } - /* - * Leave directory state setup safely. We don't have - * facilities for doing inserting and removing directories, - * so it's safest to just invalidate everything. This - * means that the caller can only append to the directory - * chain. - */ - (*tif->tif_cleanup)(tif); - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { - _TIFFfree(tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawcc = 0; - } - tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP|TIFF_POSTENCODE); - TIFFFreeDirectory(tif); - TIFFDefaultDirectory(tif); - tif->tif_diroff = 0; /* force link on next write */ - tif->tif_nextdiroff = 0; /* next write must be at end */ - tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; - return (1); -} - -/* [BFC] - * - * Author: Bruce Cameron - * - * Set a table of tags that are to be replaced during directory process by the - * 'IGNORE' state - or return TRUE/FALSE for the requested tag such that - * 'ReadDirectory' can use the stored information. - */ -int -TIFFReassignTagToIgnore (enum TIFFIgnoreSense task, int TIFFtagID) -{ - static int TIFFignoretags [FIELD_LAST]; - static int tagcount = 0 ; - int i; /* Loop index */ - int j; /* Loop index */ - - switch (task) - { - case TIS_STORE: - if ( tagcount < (FIELD_LAST - 1) ) - { - for ( j = 0 ; j < tagcount ; ++j ) - { /* Do not add duplicate tag */ - if ( TIFFignoretags [j] == TIFFtagID ) - return (TRUE) ; - } - TIFFignoretags [tagcount++] = TIFFtagID ; - return (TRUE) ; - } - break ; - - case TIS_EXTRACT: - for ( i = 0 ; i < tagcount ; ++i ) - { - if ( TIFFignoretags [i] == TIFFtagID ) - return (TRUE) ; - } - break; - - case TIS_EMPTY: - tagcount = 0 ; /* Clear the list */ - return (TRUE) ; - - default: - break; - } - - return (FALSE); -} diff --git a/freeimage241/Source/LibTIFF/tif_dir.h b/freeimage241/Source/LibTIFF/tif_dir.h deleted file mode 100644 index e0d08fe..0000000 --- a/freeimage241/Source/LibTIFF/tif_dir.h +++ /dev/null @@ -1,268 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_dir.h,v 1.0 2001-04-13 00:42:30+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFDIR_ -#define _TIFFDIR_ -/* - * ``Library-private'' Directory-related Definitions. - */ - -/* - * Internal format of a TIFF directory entry. - */ -typedef struct { -#define FIELD_SETLONGS 3 - /* bit vector of fields that are set */ - u_long td_fieldsset[FIELD_SETLONGS]; - - uint32 td_imagewidth, td_imagelength, td_imagedepth; - uint32 td_tilewidth, td_tilelength, td_tiledepth; - uint32 td_subfiletype; - uint16 td_bitspersample; - uint16 td_sampleformat; - uint16 td_compression; - uint16 td_photometric; - uint16 td_threshholding; - uint16 td_fillorder; - uint16 td_orientation; - uint16 td_samplesperpixel; - uint32 td_rowsperstrip; - uint16 td_minsamplevalue, td_maxsamplevalue; - double td_sminsamplevalue, td_smaxsamplevalue; - float td_xresolution, td_yresolution; - uint16 td_resolutionunit; - uint16 td_planarconfig; - float td_xposition, td_yposition; - uint16 td_pagenumber[2]; - uint16* td_colormap[3]; - uint16 td_halftonehints[2]; - uint16 td_extrasamples; - uint16* td_sampleinfo; - double td_stonits; - char* td_documentname; - char* td_artist; - char* td_datetime; - char* td_hostcomputer; - char* td_imagedescription; - char* td_make; - char* td_model; - char* td_software; - char* td_pagename; - tstrip_t td_stripsperimage; - tstrip_t td_nstrips; /* size of offset & bytecount arrays */ - uint32* td_stripoffset; - uint32* td_stripbytecount; -#if SUBIFD_SUPPORT - uint16 td_nsubifd; - uint32* td_subifd; -#endif -#ifdef YCBCR_SUPPORT - float* td_ycbcrcoeffs; - uint16 td_ycbcrsubsampling[2]; - uint16 td_ycbcrpositioning; -#endif -#ifdef COLORIMETRY_SUPPORT - float* td_whitepoint; - float* td_primarychromas; - float* td_refblackwhite; - uint16* td_transferfunction[3]; -#endif -#ifdef CMYK_SUPPORT - uint16 td_inkset; - uint16 td_ninks; - uint16 td_dotrange[2]; - int td_inknameslen; - char* td_inknames; - char* td_targetprinter; -#endif -#ifdef ICC_SUPPORT - uint32 td_profileLength; - void *td_profileData; -#endif -#ifdef PHOTOSHOP_SUPPORT - uint32 td_photoshopLength; - void *td_photoshopData; -#endif -#ifdef IPTC_SUPPORT - uint32 td_richtiffiptcLength; - void *td_richtiffiptcData; -#endif - /* Begin Pixar Tag values. */ - uint32 td_imagefullwidth, td_imagefulllength; - char* td_textureformat; - char* td_wrapmodes; - float td_fovcot; - float* td_matrixWorldToScreen; - float* td_matrixWorldToCamera; - /* End Pixar Tag Values. */ -} TIFFDirectory; - -/* - * Field flags used to indicate fields that have - * been set in a directory, and to reference fields - * when manipulating a directory. - */ - -/* - * FIELD_IGNORE is used to signify tags that are to - * be processed but otherwise ignored. This permits - * antiquated tags to be quietly read and discarded. - * Note that a bit *is* allocated for ignored tags; - * this is understood by the directory reading logic - * which uses this fact to avoid special-case handling - */ -#define FIELD_IGNORE 0 - -/* multi-item fields */ -#define FIELD_IMAGEDIMENSIONS 1 -#define FIELD_TILEDIMENSIONS 2 -#define FIELD_RESOLUTION 3 -#define FIELD_POSITION 4 - -/* single-item fields */ -#define FIELD_SUBFILETYPE 5 -#define FIELD_BITSPERSAMPLE 6 -#define FIELD_COMPRESSION 7 -#define FIELD_PHOTOMETRIC 8 -#define FIELD_THRESHHOLDING 9 -#define FIELD_FILLORDER 10 -#define FIELD_DOCUMENTNAME 11 -#define FIELD_IMAGEDESCRIPTION 12 -#define FIELD_MAKE 13 -#define FIELD_MODEL 14 -#define FIELD_ORIENTATION 15 -#define FIELD_SAMPLESPERPIXEL 16 -#define FIELD_ROWSPERSTRIP 17 -#define FIELD_MINSAMPLEVALUE 18 -#define FIELD_MAXSAMPLEVALUE 19 -#define FIELD_PLANARCONFIG 20 -#define FIELD_PAGENAME 21 -#define FIELD_RESOLUTIONUNIT 22 -#define FIELD_PAGENUMBER 23 -#define FIELD_STRIPBYTECOUNTS 24 -#define FIELD_STRIPOFFSETS 25 -#define FIELD_COLORMAP 26 -#define FIELD_ARTIST 27 -#define FIELD_DATETIME 28 -#define FIELD_HOSTCOMPUTER 29 -#define FIELD_SOFTWARE 30 -#define FIELD_EXTRASAMPLES 31 -#define FIELD_SAMPLEFORMAT 32 -#define FIELD_SMINSAMPLEVALUE 33 -#define FIELD_SMAXSAMPLEVALUE 34 -#define FIELD_IMAGEDEPTH 35 -#define FIELD_TILEDEPTH 36 -#define FIELD_HALFTONEHINTS 37 -#define FIELD_YCBCRCOEFFICIENTS 38 -#define FIELD_YCBCRSUBSAMPLING 39 -#define FIELD_YCBCRPOSITIONING 40 -#define FIELD_REFBLACKWHITE 41 -#define FIELD_WHITEPOINT 42 -#define FIELD_PRIMARYCHROMAS 43 -#define FIELD_TRANSFERFUNCTION 44 -#define FIELD_INKSET 45 -#define FIELD_INKNAMES 46 -#define FIELD_DOTRANGE 47 -#define FIELD_TARGETPRINTER 48 -#define FIELD_SUBIFD 49 -#define FIELD_NUMBEROFINKS 50 -#define FIELD_ICCPROFILE 51 -#define FIELD_PHOTOSHOP 52 -#define FIELD_RICHTIFFIPTC 53 -#define FIELD_STONITS 54 -/* Begin PIXAR */ -#define FIELD_IMAGEFULLWIDTH 55 -#define FIELD_IMAGEFULLLENGTH 56 -#define FIELD_TEXTUREFORMAT 57 -#define FIELD_WRAPMODES 58 -#define FIELD_FOVCOT 59 -#define FIELD_MATRIX_WORLDTOSCREEN 60 -#define FIELD_MATRIX_WORLDTOCAMERA 61 -/* end of support for well-known tags; codec-private tags follow */ -#define FIELD_CODEC 62 /* base of codec-private tags */ -/* - * Pseudo-tags don't normally need field bits since they - * are not written to an output file (by definition). - * The library also has express logic to always query a - * codec for a pseudo-tag so allocating a field bit for - * one is a waste. If codec wants to promote the notion - * of a pseudo-tag being ``set'' or ``unset'' then it can - * do using internal state flags without polluting the - * field bit space defined for real tags. - */ -#define FIELD_PSEUDO 0 - -#define FIELD_LAST (32*FIELD_SETLONGS-1) - -#define TIFFExtractData(tif, type, v) \ - ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ - ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \ - (v) & (tif)->tif_typemask[type])) -#define TIFFInsertData(tif, type, v) \ - ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ - ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \ - (v) & (tif)->tif_typemask[type])) - -typedef struct { - ttag_t field_tag; /* field's tag */ - short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ - short field_writecount; /* write count/TIFF_VARIABLE */ - TIFFDataType field_type; /* type of associated data */ - u_short field_bit; /* bit in fieldsset bit vector */ - u_char field_oktochange; /* if true, can change while writing */ - u_char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ -} TIFFFieldInfo; - -#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ -#define TIFF_VARIABLE -1 /* marker for variable length tags */ -#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ -#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ - -extern const int tiffDataWidth[]; /* table of tag datatype widths */ - -#define BITn(n) (((u_long)1L)<<((n)&0x1f)) -#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) -#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) -#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) -#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) - -#define FieldSet(fields, f) (fields[(f)/32] & BITn(f)) -#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) - -#if defined(__cplusplus) -extern "C" { -#endif -extern void _TIFFSetupFieldInfo(TIFF*); -extern void _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); -extern void _TIFFPrintFieldInfo(TIFF*, FILE*); -extern const TIFFFieldInfo* _TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType); -extern const TIFFFieldInfo* _TIFFFieldWithTag(TIFF*, ttag_t); -extern TIFFDataType _TIFFSampleToTagType(TIFF*); -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFDIR_ */ diff --git a/freeimage241/Source/LibTIFF/tif_dirinfo.c b/freeimage241/Source/LibTIFF/tif_dirinfo.c deleted file mode 100644 index 557dde6..0000000 --- a/freeimage241/Source/LibTIFF/tif_dirinfo.c +++ /dev/null @@ -1,402 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_dirinfo.c,v 1.0 2001-04-13 00:42:30+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Core Directory Tag Support. - */ -#include "tiffiop.h" -#include - -/* - * NB: NB: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG. - * If a tag can have both LONG and SHORT types - * then the LONG must be placed before the SHORT for - * writing to work properly. - */ -static const TIFFFieldInfo tiffFieldInfo[] = { - { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, FIELD_SUBFILETYPE, - TRUE, FALSE, "SubfileType" }, -/* XXX SHORT for compatibility w/ old versions of the library */ - { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, - TRUE, FALSE, "SubfileType" }, - { TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, - TRUE, FALSE, "OldSubfileType" }, - { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, - FALSE, FALSE, "ImageWidth" }, - { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, - FALSE, FALSE, "ImageWidth" }, - { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, - TRUE, FALSE, "ImageLength" }, - { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, - TRUE, FALSE, "ImageLength" }, - { TIFFTAG_BITSPERSAMPLE, -1,-1, TIFF_SHORT, FIELD_BITSPERSAMPLE, - FALSE, FALSE, "BitsPerSample" }, - { TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, FIELD_COMPRESSION, - FALSE, FALSE, "Compression" }, - { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, FIELD_PHOTOMETRIC, - FALSE, FALSE, "PhotometricInterpretation" }, - { TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, FIELD_THRESHHOLDING, - TRUE, FALSE, "Threshholding" }, - { TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, - TRUE, FALSE, "CellWidth" }, - { TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, - TRUE, FALSE, "CellLength" }, - { TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, FIELD_FILLORDER, - FALSE, FALSE, "FillOrder" }, - { TIFFTAG_DOCUMENTNAME, -1,-1, TIFF_ASCII, FIELD_DOCUMENTNAME, - TRUE, FALSE, "DocumentName" }, - { TIFFTAG_IMAGEDESCRIPTION, -1,-1, TIFF_ASCII, FIELD_IMAGEDESCRIPTION, - TRUE, FALSE, "ImageDescription" }, - { TIFFTAG_MAKE, -1,-1, TIFF_ASCII, FIELD_MAKE, - TRUE, FALSE, "Make" }, - { TIFFTAG_MODEL, -1,-1, TIFF_ASCII, FIELD_MODEL, - TRUE, FALSE, "Model" }, - { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_LONG, FIELD_STRIPOFFSETS, - FALSE, FALSE, "StripOffsets" }, - { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_SHORT, FIELD_STRIPOFFSETS, - FALSE, FALSE, "StripOffsets" }, - { TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, FIELD_ORIENTATION, - FALSE, FALSE, "Orientation" }, - { TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, FIELD_SAMPLESPERPIXEL, - FALSE, FALSE, "SamplesPerPixel" }, - { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, FIELD_ROWSPERSTRIP, - FALSE, FALSE, "RowsPerStrip" }, - { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_SHORT, FIELD_ROWSPERSTRIP, - FALSE, FALSE, "RowsPerStrip" }, - { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, - FALSE, FALSE, "StripByteCounts" }, - { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, - FALSE, FALSE, "StripByteCounts" }, - { TIFFTAG_MINSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MINSAMPLEVALUE, - TRUE, FALSE, "MinSampleValue" }, - { TIFFTAG_MAXSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MAXSAMPLEVALUE, - TRUE, FALSE, "MaxSampleValue" }, - { TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, - FALSE, FALSE, "XResolution" }, - { TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, - FALSE, FALSE, "YResolution" }, - { TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, FIELD_PLANARCONFIG, - FALSE, FALSE, "PlanarConfiguration" }, - { TIFFTAG_PAGENAME, -1,-1, TIFF_ASCII, FIELD_PAGENAME, - TRUE, FALSE, "PageName" }, - { TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, - TRUE, FALSE, "XPosition" }, - { TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, - TRUE, FALSE, "YPosition" }, - { TIFFTAG_FREEOFFSETS, -1,-1, TIFF_LONG, FIELD_IGNORE, - FALSE, FALSE, "FreeOffsets" }, - { TIFFTAG_FREEBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_IGNORE, - FALSE, FALSE, "FreeByteCounts" }, - { TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, - TRUE, FALSE, "GrayResponseUnit" }, - { TIFFTAG_GRAYRESPONSECURVE,-1,-1, TIFF_SHORT, FIELD_IGNORE, - TRUE, FALSE, "GrayResponseCurve" }, - { TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, FIELD_RESOLUTIONUNIT, - FALSE, FALSE, "ResolutionUnit" }, - { TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, FIELD_PAGENUMBER, - TRUE, FALSE, "PageNumber" }, - { TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, - TRUE, FALSE, "ColorResponseUnit" }, -#ifdef COLORIMETRY_SUPPORT - { TIFFTAG_TRANSFERFUNCTION, -1,-1, TIFF_SHORT, FIELD_TRANSFERFUNCTION, - TRUE, FALSE, "TransferFunction" }, -#endif - { TIFFTAG_SOFTWARE, -1,-1, TIFF_ASCII, FIELD_SOFTWARE, - TRUE, FALSE, "Software" }, - { TIFFTAG_DATETIME, 20,20, TIFF_ASCII, FIELD_DATETIME, - TRUE, FALSE, "DateTime" }, - { TIFFTAG_ARTIST, -1,-1, TIFF_ASCII, FIELD_ARTIST, - TRUE, FALSE, "Artist" }, - { TIFFTAG_HOSTCOMPUTER, -1,-1, TIFF_ASCII, FIELD_HOSTCOMPUTER, - TRUE, FALSE, "HostComputer" }, -#ifdef COLORIMETRY_SUPPORT - { TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL,FIELD_WHITEPOINT, - TRUE, FALSE, "WhitePoint" }, - { TIFFTAG_PRIMARYCHROMATICITIES,6,6,TIFF_RATIONAL,FIELD_PRIMARYCHROMAS, - TRUE, FALSE, "PrimaryChromaticities" }, -#endif - { TIFFTAG_COLORMAP, -1,-1, TIFF_SHORT, FIELD_COLORMAP, - TRUE, FALSE, "ColorMap" }, - { TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, FIELD_HALFTONEHINTS, - TRUE, FALSE, "HalftoneHints" }, - { TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, - FALSE, FALSE, "TileWidth" }, - { TIFFTAG_TILEWIDTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, - FALSE, FALSE, "TileWidth" }, - { TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, - FALSE, FALSE, "TileLength" }, - { TIFFTAG_TILELENGTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, - FALSE, FALSE, "TileLength" }, - { TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG, FIELD_STRIPOFFSETS, - FALSE, FALSE, "TileOffsets" }, - { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, - FALSE, FALSE, "TileByteCounts" }, - { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, - FALSE, FALSE, "TileByteCounts" }, -#ifdef TIFFTAG_SUBIFD - { TIFFTAG_SUBIFD, -1,-1, TIFF_LONG, FIELD_SUBIFD, - TRUE, TRUE, "SubIFD" }, -#endif -#ifdef CMYK_SUPPORT /* 6.0 CMYK tags */ - { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, FIELD_INKSET, - FALSE, FALSE, "InkSet" }, - { TIFFTAG_INKNAMES, -1,-1, TIFF_ASCII, FIELD_INKNAMES, - TRUE, TRUE, "InkNames" }, - { TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, FIELD_NUMBEROFINKS, - TRUE, FALSE, "NumberOfInks" }, - { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, FIELD_DOTRANGE, - FALSE, FALSE, "DotRange" }, - { TIFFTAG_DOTRANGE, 2, 2, TIFF_BYTE, FIELD_DOTRANGE, - FALSE, FALSE, "DotRange" }, - { TIFFTAG_TARGETPRINTER, -1,-1, TIFF_ASCII, FIELD_TARGETPRINTER, - TRUE, FALSE, "TargetPrinter" }, -#endif - { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_SHORT, FIELD_EXTRASAMPLES, - FALSE, FALSE, "ExtraSamples" }, -/* XXX for bogus Adobe Photoshop v2.5 files */ - { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_BYTE, FIELD_EXTRASAMPLES, - FALSE, FALSE, "ExtraSamples" }, - { TIFFTAG_SAMPLEFORMAT, -1,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, - FALSE, FALSE, "SampleFormat" }, - { TIFFTAG_SMINSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMINSAMPLEVALUE, - TRUE, FALSE, "SMinSampleValue" }, - { TIFFTAG_SMAXSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMAXSAMPLEVALUE, - TRUE, FALSE, "SMaxSampleValue" }, -#ifdef YCBCR_SUPPORT /* 6.0 YCbCr tags */ - { TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, FIELD_YCBCRCOEFFICIENTS, - FALSE, FALSE, "YCbCrCoefficients" }, - { TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, FIELD_YCBCRSUBSAMPLING, - FALSE, FALSE, "YCbCrSubsampling" }, - { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, FIELD_YCBCRPOSITIONING, - FALSE, FALSE, "YCbCrPositioning" }, -#endif -#ifdef COLORIMETRY_SUPPORT - { TIFFTAG_REFERENCEBLACKWHITE,6,6,TIFF_RATIONAL, FIELD_REFBLACKWHITE, - TRUE, FALSE, "ReferenceBlackWhite" }, -/* XXX temporarily accept LONG for backwards compatibility */ - { TIFFTAG_REFERENCEBLACKWHITE,6,6,TIFF_LONG, FIELD_REFBLACKWHITE, - TRUE, FALSE, "ReferenceBlackWhite" }, -#endif -/* begin SGI tags */ - { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, FIELD_EXTRASAMPLES, - FALSE, FALSE, "Matteing" }, - { TIFFTAG_DATATYPE, -2,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, - FALSE, FALSE, "DataType" }, - { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, FIELD_IMAGEDEPTH, - FALSE, FALSE, "ImageDepth" }, - { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDEPTH, - FALSE, FALSE, "ImageDepth" }, - { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, FIELD_TILEDEPTH, - FALSE, FALSE, "TileDepth" }, - { TIFFTAG_TILEDEPTH, 1, 1, TIFF_SHORT, FIELD_TILEDEPTH, - FALSE, FALSE, "TileDepth" }, -/* end SGI tags */ -#ifdef IPTC_SUPPORT -#ifdef PHOTOSHOP_SUPPORT - { TIFFTAG_RICHTIFFIPTC, -1,-1, TIFF_LONG, FIELD_RICHTIFFIPTC, - FALSE, TRUE, "RichTIFFIPTC" }, -#else - { TIFFTAG_RICHTIFFIPTC, -1,-3, TIFF_UNDEFINED, FIELD_RICHTIFFIPTC, - FALSE, TRUE, "RichTIFFIPTC" }, -#endif -#endif -#ifdef PHOTOSHOP_SUPPORT - { TIFFTAG_PHOTOSHOP, -1,-3, TIFF_UNDEFINED, FIELD_PHOTOSHOP, - FALSE, TRUE, "Photoshop" }, - { TIFFTAG_PHOTOSHOP, -1,-1, TIFF_BYTE, FIELD_PHOTOSHOP, - FALSE, TRUE, "Photoshop" }, -#endif -#ifdef ICC_SUPPORT - { TIFFTAG_ICCPROFILE, -1,-3, TIFF_UNDEFINED, FIELD_ICCPROFILE, - FALSE, TRUE, "ICC Profile" }, -#endif - { TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, FIELD_STONITS, - FALSE, FALSE, "StoNits" }, -/* begin Pixar tags */ - { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, FIELD_IMAGEFULLWIDTH, - TRUE, FALSE, "ImageFullWidth" }, - { TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, FIELD_IMAGEFULLLENGTH, - TRUE, FALSE, "ImageFullLength" }, - { TIFFTAG_PIXAR_TEXTUREFORMAT, -1,-1, TIFF_ASCII, FIELD_TEXTUREFORMAT, - TRUE, FALSE, "TextureFormat" }, - { TIFFTAG_PIXAR_WRAPMODES, -1,-1, TIFF_ASCII, FIELD_WRAPMODES, - TRUE, FALSE, "TextureWrapModes" }, - { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, FIELD_FOVCOT, - TRUE, FALSE, "FieldOfViewCotan" }, - { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16,16, TIFF_FLOAT, - FIELD_MATRIX_WORLDTOSCREEN, TRUE, FALSE, "MatrixWorldToScreen" }, - { TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16,16, TIFF_FLOAT, - FIELD_MATRIX_WORLDTOCAMERA, TRUE, FALSE, "MatrixWorldToCamera" }, -/* end Pixar tags */ -}; -#define N(a) (sizeof (a) / sizeof (a[0])) - -void -_TIFFSetupFieldInfo(TIFF* tif) -{ - if (tif->tif_fieldinfo) { - _TIFFfree(tif->tif_fieldinfo); - tif->tif_nfields = 0; - } - _TIFFMergeFieldInfo(tif, tiffFieldInfo, N(tiffFieldInfo)); -} - -static int -tagCompare(const void* a, const void* b) -{ - const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a; - const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b; - /* NB: be careful of return values for 16-bit platforms */ - if (ta->field_tag != tb->field_tag) - return (ta->field_tag < tb->field_tag ? -1 : 1); - else - return (tb->field_type < ta->field_type ? -1 : 1); -} - -void -_TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n) -{ - TIFFFieldInfo** tp; - int i; - - if (tif->tif_nfields > 0) { - tif->tif_fieldinfo = (TIFFFieldInfo**) - _TIFFrealloc(tif->tif_fieldinfo, - (tif->tif_nfields+n) * sizeof (TIFFFieldInfo*)); - } else { - tif->tif_fieldinfo = (TIFFFieldInfo**) - _TIFFmalloc(n * sizeof (TIFFFieldInfo*)); - } - tp = &tif->tif_fieldinfo[tif->tif_nfields]; - for (i = 0; i < n; i++) - tp[i] = (TIFFFieldInfo*) &info[i]; /* XXX */ - /* - * NB: the core tags are presumed sorted correctly. - */ - if (tif->tif_nfields > 0) - qsort(tif->tif_fieldinfo, (size_t) (tif->tif_nfields += n), - sizeof (TIFFFieldInfo*), tagCompare); - else - tif->tif_nfields += n; -} - -void -_TIFFPrintFieldInfo(TIFF* tif, FILE* fd) -{ - int i; - - fprintf(fd, "%s: \n", tif->tif_name); - for (i = 0; i < tif->tif_nfields; i++) { - const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; - fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n" - , i - , (unsigned long) fip->field_tag - , fip->field_readcount, fip->field_writecount - , fip->field_type - , fip->field_bit - , fip->field_oktochange ? "TRUE" : "FALSE" - , fip->field_passcount ? "TRUE" : "FALSE" - , fip->field_name - ); - } -} - -const int tiffDataWidth[] = { - 1, /* nothing */ - 1, /* TIFF_BYTE */ - 1, /* TIFF_ASCII */ - 2, /* TIFF_SHORT */ - 4, /* TIFF_LONG */ - 8, /* TIFF_RATIONAL */ - 1, /* TIFF_SBYTE */ - 1, /* TIFF_UNDEFINED */ - 2, /* TIFF_SSHORT */ - 4, /* TIFF_SLONG */ - 8, /* TIFF_SRATIONAL */ - 4, /* TIFF_FLOAT */ - 8, /* TIFF_DOUBLE */ -}; - -/* - * Return nearest TIFFDataType to the sample type of an image. - */ -TIFFDataType -_TIFFSampleToTagType(TIFF* tif) -{ - int bps = (int) TIFFhowmany(tif->tif_dir.td_bitspersample, 8); - - switch (tif->tif_dir.td_sampleformat) { - case SAMPLEFORMAT_IEEEFP: - return (bps == 4 ? TIFF_FLOAT : TIFF_DOUBLE); - case SAMPLEFORMAT_INT: - return (bps <= 1 ? TIFF_SBYTE : - bps <= 2 ? TIFF_SSHORT : TIFF_SLONG); - case SAMPLEFORMAT_UINT: - return (bps <= 1 ? TIFF_BYTE : - bps <= 2 ? TIFF_SHORT : TIFF_LONG); - case SAMPLEFORMAT_VOID: - return (TIFF_UNDEFINED); - } - /*NOTREACHED*/ - return (TIFF_UNDEFINED); -} - -const TIFFFieldInfo* -_TIFFFindFieldInfo(TIFF* tif, ttag_t tag, TIFFDataType dt) -{ - static const TIFFFieldInfo *last = NULL; - int i, n; - - if (last && last->field_tag == tag && - (dt == TIFF_ANY || dt == last->field_type)) - return (last); - /* NB: if table gets big, use sorted search (e.g. binary search) */ - for (i = 0, n = tif->tif_nfields; i < n; i++) { - const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; - if (fip->field_tag == tag && - (dt == TIFF_ANY || fip->field_type == dt)) - return (last = fip); - } - return ((const TIFFFieldInfo *)0); -} - -#include -#include - -const TIFFFieldInfo* -_TIFFFieldWithTag(TIFF* tif, ttag_t tag) -{ - const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); - if (!fip) { - TIFFError("TIFFFieldWithTag", - "Internal error, unknown tag 0x%x", (u_int) tag); - assert(fip != NULL); - /*NOTREACHED*/ - } - return (fip); -} diff --git a/freeimage241/Source/LibTIFF/tif_dirread.c b/freeimage241/Source/LibTIFF/tif_dirread.c deleted file mode 100644 index 5f53d82..0000000 --- a/freeimage241/Source/LibTIFF/tif_dirread.c +++ /dev/null @@ -1,1375 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_dirread.c,v 1.0 2001-04-13 00:42:30+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Read Support Routines. - */ -#include "tiffiop.h" - -#define IGNORE 0 /* tag placeholder used below */ - -#if HAVE_IEEEFP -#define TIFFCvtIEEEFloatToNative(tif, n, fp) -#define TIFFCvtIEEEDoubleToNative(tif, n, dp) -#else -extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); -extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*); -#endif - -static void EstimateStripByteCounts(TIFF*, TIFFDirEntry*, uint16); -static void MissingRequired(TIFF*, const char*); -static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32); -static tsize_t TIFFFetchData(TIFF*, TIFFDirEntry*, char*); -static tsize_t TIFFFetchString(TIFF*, TIFFDirEntry*, char*); -static float TIFFFetchRational(TIFF*, TIFFDirEntry*); -static int TIFFFetchNormalTag(TIFF*, TIFFDirEntry*); -static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, int*); -static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*); -static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*); -static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32**); -static int TIFFFetchExtraSamples(TIFF*, TIFFDirEntry*); -static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*); -static float TIFFFetchFloat(TIFF*, TIFFDirEntry*); -static int TIFFFetchFloatArray(TIFF*, TIFFDirEntry*, float*); -static int TIFFFetchDoubleArray(TIFF*, TIFFDirEntry*, double*); -static int TIFFFetchAnyArray(TIFF*, TIFFDirEntry*, double*); -static int TIFFFetchShortPair(TIFF*, TIFFDirEntry*); -static void ChopUpSingleUncompressedStrip(TIFF*); - -static char * -CheckMalloc(TIFF* tif, tsize_t n, const char* what) -{ - char *cp = (char*)_TIFFmalloc(n); - if (cp == NULL) - TIFFError(tif->tif_name, "No space %s", what); - return (cp); -} - -/* - * Read the next TIFF directory from a file - * and convert it to the internal format. - * We read directories sequentially. - */ -int -TIFFReadDirectory(TIFF* tif) -{ - register TIFFDirEntry* dp; - register int n; - register TIFFDirectory* td; - TIFFDirEntry* dir; - int iv; - long v; - double dv; - const TIFFFieldInfo* fip; - int fix; - uint16 dircount; - toff_t nextdiroff; - char* cp; - int diroutoforderwarning = 0; - - tif->tif_diroff = tif->tif_nextdiroff; - if (tif->tif_diroff == 0) /* no more directories */ - return (0); - /* - * Cleanup any previous compression state. - */ - (*tif->tif_cleanup)(tif); - tif->tif_curdir++; - nextdiroff = 0; - if (!isMapped(tif)) { - if (!SeekOK(tif, tif->tif_diroff)) { - TIFFError(tif->tif_name, - "Seek error accessing TIFF directory"); - return (0); - } - if (!ReadOK(tif, &dircount, sizeof (uint16))) { - TIFFError(tif->tif_name, - "Can not read TIFF directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)CheckMalloc(tif, - dircount * sizeof (TIFFDirEntry), "to read TIFF directory"); - if (dir == NULL) - return (0); - if (!ReadOK(tif, dir, dircount*sizeof (TIFFDirEntry))) { - TIFFError(tif->tif_name, "Can not read TIFF directory"); - goto bad; - } - /* - * Read offset to next directory for sequential scans. - */ - (void) ReadOK(tif, &nextdiroff, sizeof (uint32)); - } else { - toff_t off = tif->tif_diroff; - - if (off + sizeof (uint16) > tif->tif_size) { - TIFFError(tif->tif_name, - "Can not read TIFF directory count"); - return (0); - } else - _TIFFmemcpy(&dircount, tif->tif_base + off, sizeof (uint16)); - off += sizeof (uint16); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)CheckMalloc(tif, - dircount * sizeof (TIFFDirEntry), "to read TIFF directory"); - if (dir == NULL) - return (0); - if (off + dircount*sizeof (TIFFDirEntry) > tif->tif_size) { - TIFFError(tif->tif_name, "Can not read TIFF directory"); - goto bad; - } else - _TIFFmemcpy(dir, tif->tif_base + off, - dircount*sizeof (TIFFDirEntry)); - off += dircount* sizeof (TIFFDirEntry); - if (off + sizeof (uint32) <= tif->tif_size) - _TIFFmemcpy(&nextdiroff, tif->tif_base+off, sizeof (uint32)); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdiroff); - tif->tif_nextdiroff = nextdiroff; - - tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ - /* - * Setup default value and then make a pass over - * the fields to check type and tag information, - * and to extract info required to size data - * structures. A second pass is made afterwards - * to read in everthing not taken in the first pass. - */ - td = &tif->tif_dir; - /* free any old stuff and reinit */ - TIFFFreeDirectory(tif); - TIFFDefaultDirectory(tif); - /* - * Electronic Arts writes gray-scale TIFF files - * without a PlanarConfiguration directory entry. - * Thus we setup a default value here, even though - * the TIFF spec says there is no default value. - */ - TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - - /* - * Sigh, we must make a separate pass through the - * directory for the following reason: - * - * We must process the Compression tag in the first pass - * in order to merge in codec-private tag definitions (otherwise - * we may get complaints about unknown tags). However, the - * Compression tag may be dependent on the SamplesPerPixel - * tag value because older TIFF specs permited Compression - * to be written as a SamplesPerPixel-count tag entry. - * Thus if we don't first figure out the correct SamplesPerPixel - * tag value then we may end up ignoring the Compression tag - * value because it has an incorrect count value (if the - * true value of SamplesPerPixel is not 1). - * - * It sure would have been nice if Aldus had really thought - * this stuff through carefully. - */ - for (dp = dir, n = dircount; n > 0; n--, dp++) { - if (tif->tif_flags & TIFF_SWAB) { - TIFFSwabArrayOfShort(&dp->tdir_tag, 2); - TIFFSwabArrayOfLong(&dp->tdir_count, 2); - } - if (dp->tdir_tag == TIFFTAG_SAMPLESPERPIXEL) { - if (!TIFFFetchNormalTag(tif, dp)) - goto bad; - dp->tdir_tag = IGNORE; - } - } - /* - * First real pass over the directory. - */ - fix = 0; - for (dp = dir, n = dircount; n > 0; n--, dp++) { - - /* - * Find the field information entry for this tag. - * Added check for tags to ignore ... [BFC] - */ - if( TIFFReassignTagToIgnore(TIS_EXTRACT, dp->tdir_tag) ) - dp->tdir_tag = IGNORE; - - if (dp->tdir_tag == IGNORE) - continue; - - /* - * Silicon Beach (at least) writes unordered - * directory tags (violating the spec). Handle - * it here, but be obnoxious (maybe they'll fix it?). - */ - if (dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) { - if (!diroutoforderwarning) { - TIFFWarning(tif->tif_name, - "invalid TIFF directory; tags are not sorted in ascending order"); - diroutoforderwarning = 1; - } - fix = 0; /* O(n^2) */ - } - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; - if (fix == tif->tif_nfields || - tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { - TIFFWarning(tif->tif_name, - "unknown field with tag %d (0x%x) ignored", - dp->tdir_tag, dp->tdir_tag); - dp->tdir_tag = IGNORE; - fix = 0; /* restart search */ - continue; - } - /* - * Null out old tags that we ignore. - */ - if (tif->tif_fieldinfo[fix]->field_bit == FIELD_IGNORE) { - ignore: - dp->tdir_tag = IGNORE; - continue; - } - /* - * Check data type. - */ - fip = tif->tif_fieldinfo[fix]; - while (dp->tdir_type != (u_short) fip->field_type) { - if (fip->field_type == TIFF_ANY) /* wildcard */ - break; - fip++, fix++; - if (fix == tif->tif_nfields || - fip->field_tag != dp->tdir_tag) { - TIFFWarning(tif->tif_name, - "wrong data type %d for \"%s\"; tag ignored", - dp->tdir_type, fip[-1].field_name); - goto ignore; - } - } - /* - * Check count if known in advance. - */ - if (fip->field_readcount != TIFF_VARIABLE) { - uint32 expected = (fip->field_readcount == TIFF_SPP) ? - (uint32) td->td_samplesperpixel : - (uint32) fip->field_readcount; - if (!CheckDirCount(tif, dp, expected)) - goto ignore; - } - - switch (dp->tdir_tag) { - case TIFFTAG_COMPRESSION: - /* - * The 5.0 spec says the Compression tag has - * one value, while earlier specs say it has - * one value per sample. Because of this, we - * accept the tag if one value is supplied. - */ - if (dp->tdir_count == 1) { - v = TIFFExtractData(tif, - dp->tdir_type, dp->tdir_offset); - if (!TIFFSetField(tif, dp->tdir_tag, (int)v)) - goto bad; - break; - } - if (!TIFFFetchPerSampleShorts(tif, dp, &iv) || - !TIFFSetField(tif, dp->tdir_tag, iv)) - goto bad; - dp->tdir_tag = IGNORE; - break; - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEOFFSETS: - case TIFFTAG_TILEBYTECOUNTS: - TIFFSetFieldBit(tif, fip->field_bit); - break; - case TIFFTAG_IMAGEWIDTH: - case TIFFTAG_IMAGELENGTH: - case TIFFTAG_IMAGEDEPTH: - case TIFFTAG_TILELENGTH: - case TIFFTAG_TILEWIDTH: - case TIFFTAG_TILEDEPTH: - case TIFFTAG_PLANARCONFIG: - case TIFFTAG_ROWSPERSTRIP: - if (!TIFFFetchNormalTag(tif, dp)) - goto bad; - dp->tdir_tag = IGNORE; - break; - case TIFFTAG_EXTRASAMPLES: - (void) TIFFFetchExtraSamples(tif, dp); - dp->tdir_tag = IGNORE; - break; - } - } - - /* - * Allocate directory structure and setup defaults. - */ - if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { - MissingRequired(tif, "ImageLength"); - goto bad; - } - if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { - MissingRequired(tif, "PlanarConfiguration"); - goto bad; - } - /* - * Setup appropriate structures (by strip or by tile) - */ - if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { - td->td_nstrips = TIFFNumberOfStrips(tif); - td->td_tilewidth = td->td_imagewidth; - td->td_tilelength = td->td_rowsperstrip; - td->td_tiledepth = td->td_imagedepth; - tif->tif_flags &= ~TIFF_ISTILED; - } else { - td->td_nstrips = TIFFNumberOfTiles(tif); - tif->tif_flags |= TIFF_ISTILED; - } - td->td_stripsperimage = td->td_nstrips; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - td->td_stripsperimage /= td->td_samplesperpixel; - if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { - MissingRequired(tif, - isTiled(tif) ? "TileOffsets" : "StripOffsets"); - goto bad; - } - - /* - * Second pass: extract other information. - */ - for (dp = dir, n = dircount; n > 0; n--, dp++) { - if (dp->tdir_tag == IGNORE) - continue; - switch (dp->tdir_tag) { - case TIFFTAG_MINSAMPLEVALUE: - case TIFFTAG_MAXSAMPLEVALUE: - case TIFFTAG_BITSPERSAMPLE: - /* - * The 5.0 spec says the Compression tag has - * one value, while earlier specs say it has - * one value per sample. Because of this, we - * accept the tag if one value is supplied. - * - * The MinSampleValue, MaxSampleValue and - * BitsPerSample tags are supposed to be written - * as one value/sample, but some vendors incorrectly - * write one value only -- so we accept that - * as well (yech). - */ - if (dp->tdir_count == 1) { - v = TIFFExtractData(tif, - dp->tdir_type, dp->tdir_offset); - if (!TIFFSetField(tif, dp->tdir_tag, (int)v)) - goto bad; - break; - } - /* fall thru... */ - case TIFFTAG_DATATYPE: - case TIFFTAG_SAMPLEFORMAT: - if (!TIFFFetchPerSampleShorts(tif, dp, &iv) || - !TIFFSetField(tif, dp->tdir_tag, iv)) - goto bad; - break; - case TIFFTAG_SMINSAMPLEVALUE: - case TIFFTAG_SMAXSAMPLEVALUE: - if (!TIFFFetchPerSampleAnys(tif, dp, &dv) || - !TIFFSetField(tif, dp->tdir_tag, dv)) - goto bad; - break; - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_TILEOFFSETS: - if (!TIFFFetchStripThing(tif, dp, - td->td_nstrips, &td->td_stripoffset)) - goto bad; - break; - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEBYTECOUNTS: - if (!TIFFFetchStripThing(tif, dp, - td->td_nstrips, &td->td_stripbytecount)) - goto bad; - break; - case TIFFTAG_COLORMAP: - case TIFFTAG_TRANSFERFUNCTION: - /* - * TransferFunction can have either 1x or 3x data - * values; Colormap can have only 3x items. - */ - v = 1L<td_bitspersample; - if (dp->tdir_tag == TIFFTAG_COLORMAP || - dp->tdir_count != (uint32) v) { - if (!CheckDirCount(tif, dp, (uint32)(3*v))) - break; - } - v *= sizeof (uint16); - cp = CheckMalloc(tif, dp->tdir_count * sizeof (uint16), - "to read \"TransferFunction\" tag"); - if (cp != NULL) { - if (TIFFFetchData(tif, dp, cp)) { - /* - * This deals with there being only - * one array to apply to all samples. - */ - uint32 c = - (uint32)1 << td->td_bitspersample; - if (dp->tdir_count == c) - v = 0; - TIFFSetField(tif, dp->tdir_tag, - cp, cp+v, cp+2*v); - } - _TIFFfree(cp); - } - break; - case TIFFTAG_PAGENUMBER: - case TIFFTAG_HALFTONEHINTS: - case TIFFTAG_YCBCRSUBSAMPLING: - case TIFFTAG_DOTRANGE: - (void) TIFFFetchShortPair(tif, dp); - break; -#ifdef COLORIMETRY_SUPPORT - case TIFFTAG_REFERENCEBLACKWHITE: - (void) TIFFFetchRefBlackWhite(tif, dp); - break; -#endif -/* BEGIN REV 4.0 COMPATIBILITY */ - case TIFFTAG_OSUBFILETYPE: - v = 0; - switch (TIFFExtractData(tif, dp->tdir_type, - dp->tdir_offset)) { - case OFILETYPE_REDUCEDIMAGE: - v = FILETYPE_REDUCEDIMAGE; - break; - case OFILETYPE_PAGE: - v = FILETYPE_PAGE; - break; - } - if (v) - (void) TIFFSetField(tif, - TIFFTAG_SUBFILETYPE, (int)v); - break; -/* END REV 4.0 COMPATIBILITY */ - default: - (void) TIFFFetchNormalTag(tif, dp); - break; - } - } - /* - * Verify Palette image has a Colormap. - */ - if (td->td_photometric == PHOTOMETRIC_PALETTE && - !TIFFFieldSet(tif, FIELD_COLORMAP)) { - MissingRequired(tif, "Colormap"); - goto bad; - } - /* - * Attempt to deal with a missing StripByteCounts tag. - */ - if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { - /* - * Some manufacturers violate the spec by not giving - * the size of the strips. In this case, assume there - * is one uncompressed strip of data. - */ - if ((td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_nstrips > 1) || - (td->td_planarconfig == PLANARCONFIG_SEPARATE && - td->td_nstrips != td->td_samplesperpixel)) { - MissingRequired(tif, "StripByteCounts"); - goto bad; - } - TIFFWarning(tif->tif_name, -"TIFF directory is missing required \"%s\" field, calculating from imagelength", - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); - EstimateStripByteCounts(tif, dir, dircount); -#define BYTECOUNTLOOKSBAD \ - ((td->td_stripbytecount[0] == 0 && td->td_stripoffset[0] != 0) || \ - (td->td_compression == COMPRESSION_NONE && \ - td->td_stripbytecount[0] > TIFFGetFileSize(tif) - td->td_stripoffset[0])) - } else if (td->td_nstrips == 1 && BYTECOUNTLOOKSBAD) { - /* - * Plexus (and others) sometimes give a value - * of zero for a tag when they don't know what - * the correct value is! Try and handle the - * simple case of estimating the size of a one - * strip image. - */ - TIFFWarning(tif->tif_name, - "Bogus \"%s\" field, ignoring and calculating from imagelength", - _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); - EstimateStripByteCounts(tif, dir, dircount); - } - if (dir) - _TIFFfree((char *)dir); - if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) - td->td_maxsamplevalue = (uint16)((1L<td_bitspersample)-1); - /* - * Setup default compression scheme. - */ - if (!TIFFFieldSet(tif, FIELD_COMPRESSION)) - TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - /* - * Some manufacturers make life difficult by writing - * large amounts of uncompressed data as a single strip. - * This is contrary to the recommendations of the spec. - * The following makes an attempt at breaking such images - * into strips closer to the recommended 8k bytes. A - * side effect, however, is that the RowsPerStrip tag - * value may be changed. - */ - if (td->td_nstrips == 1 && td->td_compression == COMPRESSION_NONE && - (tif->tif_flags & (TIFF_STRIPCHOP|TIFF_ISTILED)) == TIFF_STRIPCHOP) - ChopUpSingleUncompressedStrip(tif); - /* - * Reinitialize i/o since we are starting on a new directory. - */ - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; - tif->tif_col = (uint32) -1; - tif->tif_curtile = (ttile_t) -1; - tif->tif_tilesize = TIFFTileSize(tif); - tif->tif_scanlinesize = TIFFScanlineSize(tif); - return (1); -bad: - if (dir) - _TIFFfree(dir); - return (0); -} - -static void -EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) -{ - register TIFFDirEntry *dp; - register TIFFDirectory *td = &tif->tif_dir; - uint16 i; - - if (td->td_stripbytecount) - _TIFFfree(td->td_stripbytecount); - td->td_stripbytecount = (uint32*) - CheckMalloc(tif, td->td_nstrips * sizeof (uint32), - "for \"StripByteCounts\" array"); - if (td->td_compression != COMPRESSION_NONE) { - uint32 space = (uint32)(sizeof (TIFFHeader) - + sizeof (uint16) - + (dircount * sizeof (TIFFDirEntry)) - + sizeof (uint32)); - toff_t filesize = TIFFGetFileSize(tif); - uint16 n; - - /* calculate amount of space used by indirect values */ - for (dp = dir, n = dircount; n > 0; n--, dp++) { - uint32 cc = dp->tdir_count*tiffDataWidth[dp->tdir_type]; - if (cc > sizeof (uint32)) - space += cc; - } - space = filesize - space; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - space /= td->td_samplesperpixel; - for (i = 0; i < td->td_nstrips; i++) - td->td_stripbytecount[i] = space; - /* - * This gross hack handles the case were the offset to - * the last strip is past the place where we think the strip - * should begin. Since a strip of data must be contiguous, - * it's safe to assume that we've overestimated the amount - * of data in the strip and trim this number back accordingly. - */ - i--; - if (((toff_t)(td->td_stripoffset[i]+td->td_stripbytecount[i])) - > filesize) - td->td_stripbytecount[i] = - filesize - td->td_stripoffset[i]; - } else { - uint32 rowbytes = TIFFScanlineSize(tif); - uint32 rowsperstrip = td->td_imagelength/td->td_stripsperimage; - for (i = 0; i < td->td_nstrips; i++) - td->td_stripbytecount[i] = rowbytes*rowsperstrip; - } - TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); - if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) - td->td_rowsperstrip = td->td_imagelength; -} - -static void -MissingRequired(TIFF* tif, const char* tagname) -{ - TIFFError(tif->tif_name, - "TIFF directory is missing required \"%s\" field", tagname); -} - -/* - * Check the count field of a directory - * entry against a known value. The caller - * is expected to skip/ignore the tag if - * there is a mismatch. - */ -static int -CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) -{ - if (count != dir->tdir_count) { - TIFFWarning(tif->tif_name, - "incorrect count for field \"%s\" (%lu, expecting %lu); tag ignored", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, - dir->tdir_count, count); - return (0); - } - return (1); -} - -/* - * Fetch a contiguous directory item. - */ -static tsize_t -TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - int w = tiffDataWidth[dir->tdir_type]; - tsize_t cc = dir->tdir_count * w; - - if (!isMapped(tif)) { - if (!SeekOK(tif, dir->tdir_offset)) - goto bad; - if (!ReadOK(tif, cp, cc)) - goto bad; - } else { - if (dir->tdir_offset + cc > tif->tif_size) - goto bad; - _TIFFmemcpy(cp, tif->tif_base + dir->tdir_offset, cc); - } - if (tif->tif_flags & TIFF_SWAB) { - switch (dir->tdir_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); - break; - case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); - break; - } - } - return (cc); -bad: - TIFFError(tif->tif_name, "Error fetching data for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return ((tsize_t) 0); -} - -/* - * Fetch an ASCII item from the file. - */ -static tsize_t -TIFFFetchString(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - if (dir->tdir_count <= 4) { - uint32 l = dir->tdir_offset; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&l); - _TIFFmemcpy(cp, &l, dir->tdir_count); - return (1); - } - return (TIFFFetchData(tif, dir, cp)); -} - -/* - * Convert numerator+denominator to float. - */ -static int -cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv) -{ - if (denom == 0) { - TIFFError(tif->tif_name, - "%s: Rational with zero denominator (num = %lu)", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, num); - return (0); - } else { - if (dir->tdir_type == TIFF_RATIONAL) - *rv = ((float)num / (float)denom); - else - *rv = ((float)(int32)num / (float)(int32)denom); - return (1); - } -} - -/* - * Fetch a rational item from the file - * at offset off and return the value - * as a floating point number. - */ -static float -TIFFFetchRational(TIFF* tif, TIFFDirEntry* dir) -{ - uint32 l[2]; - float v; - - return (!TIFFFetchData(tif, dir, (char *)l) || - !cvtRational(tif, dir, l[0], l[1], &v) ? 1.0f : v); -} - -/* - * Fetch a single floating point value - * from the offset field and return it - * as a native float. - */ -static float -TIFFFetchFloat(TIFF* tif, TIFFDirEntry* dir) -{ - long l = TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); - float v = *(float*) &l; - TIFFCvtIEEEFloatToNative(tif, 1, &v); - return (v); -} - -/* - * Fetch an array of BYTE or SBYTE values. - */ -static int -TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) -{ - if (dir->tdir_count <= 4) { - /* - * Extract data from offset field. - */ - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - switch (dir->tdir_count) { - case 4: v[3] = (uint16)(dir->tdir_offset & 0xff); - case 3: v[2] = (uint16)((dir->tdir_offset >> 8) & 0xff); - case 2: v[1] = (uint16)((dir->tdir_offset >> 16) & 0xff); - case 1: v[0] = (uint16)(dir->tdir_offset >> 24); - } - } else { - switch (dir->tdir_count) { - case 4: v[3] = (uint16)(dir->tdir_offset >> 24); - case 3: v[2] = (uint16)((dir->tdir_offset >> 16) & 0xff); - case 2: v[1] = (uint16)((dir->tdir_offset >> 8) & 0xff); - case 1: v[0] = (uint16)(dir->tdir_offset & 0xff); - } - } - return (1); - } else - return (TIFFFetchData(tif, dir, (char*) v) != 0); /* XXX */ -} - -/* - * Fetch an array of SHORT or SSHORT values. - */ -static int -TIFFFetchShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) -{ - if (dir->tdir_count <= 2) { - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - switch (dir->tdir_count) { - case 2: v[1] = (uint16) (dir->tdir_offset & 0xffff); - case 1: v[0] = (uint16) (dir->tdir_offset >> 16); - } - } else { - switch (dir->tdir_count) { - case 2: v[1] = (uint16) (dir->tdir_offset >> 16); - case 1: v[0] = (uint16) (dir->tdir_offset & 0xffff); - } - } - return (1); - } else - return (TIFFFetchData(tif, dir, (char *)v) != 0); -} - -/* - * Fetch a pair of SHORT or BYTE values. - */ -static int -TIFFFetchShortPair(TIFF* tif, TIFFDirEntry* dir) -{ - uint16 v[2]; - int ok = 0; - - switch (dir->tdir_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - ok = TIFFFetchShortArray(tif, dir, v); - break; - case TIFF_BYTE: - case TIFF_SBYTE: - ok = TIFFFetchByteArray(tif, dir, v); - break; - } - if (ok) - TIFFSetField(tif, dir->tdir_tag, v[0], v[1]); - return (ok); -} - -/* - * Fetch an array of LONG or SLONG values. - */ -static int -TIFFFetchLongArray(TIFF* tif, TIFFDirEntry* dir, uint32* v) -{ - if (dir->tdir_count == 1) { - v[0] = dir->tdir_offset; - return (1); - } else - return (TIFFFetchData(tif, dir, (char*) v) != 0); -} - -/* - * Fetch an array of RATIONAL or SRATIONAL values. - */ -static int -TIFFFetchRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v) -{ - int ok = 0; - uint32* l; - - l = (uint32*)CheckMalloc(tif, - dir->tdir_count*tiffDataWidth[dir->tdir_type], - "to fetch array of rationals"); - if (l) { - if (TIFFFetchData(tif, dir, (char *)l)) { - uint32 i; - for (i = 0; i < dir->tdir_count; i++) { - ok = cvtRational(tif, dir, - l[2*i+0], l[2*i+1], &v[i]); - if (!ok) - break; - } - } - _TIFFfree((char *)l); - } - return (ok); -} - -/* - * Fetch an array of FLOAT values. - */ -static int -TIFFFetchFloatArray(TIFF* tif, TIFFDirEntry* dir, float* v) -{ - - if (dir->tdir_count == 1) { - v[0] = *(float*) &dir->tdir_offset; - TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); - return (1); - } else if (TIFFFetchData(tif, dir, (char*) v)) { - TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); - return (1); - } else - return (0); -} - -/* - * Fetch an array of DOUBLE values. - */ -static int -TIFFFetchDoubleArray(TIFF* tif, TIFFDirEntry* dir, double* v) -{ - if (TIFFFetchData(tif, dir, (char*) v)) { - TIFFCvtIEEEDoubleToNative(tif, dir->tdir_count, v); - return (1); - } else - return (0); -} - -/* - * Fetch an array of ANY values. The actual values are - * returned as doubles which should be able hold all the - * types. Yes, there really should be an tany_t to avoid - * this potential non-portability ... Note in particular - * that we assume that the double return value vector is - * large enough to read in any fundamental type. We use - * that vector as a buffer to read in the base type vector - * and then convert it in place to double (from end - * to front of course). - */ -static int -TIFFFetchAnyArray(TIFF* tif, TIFFDirEntry* dir, double* v) -{ - int i; - - switch (dir->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - if (!TIFFFetchByteArray(tif, dir, (uint16*) v)) - return (0); - if (dir->tdir_type == TIFF_BYTE) { - uint16* vp = (uint16*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } else { - int16* vp = (int16*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_SHORT: - case TIFF_SSHORT: - if (!TIFFFetchShortArray(tif, dir, (uint16*) v)) - return (0); - if (dir->tdir_type == TIFF_SHORT) { - uint16* vp = (uint16*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } else { - int16* vp = (int16*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_LONG: - case TIFF_SLONG: - if (!TIFFFetchLongArray(tif, dir, (uint32*) v)) - return (0); - if (dir->tdir_type == TIFF_LONG) { - uint32* vp = (uint32*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } else { - int32* vp = (int32*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - if (!TIFFFetchRationalArray(tif, dir, (float*) v)) - return (0); - { float* vp = (float*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_FLOAT: - if (!TIFFFetchFloatArray(tif, dir, (float*) v)) - return (0); - { float* vp = (float*) v; - for (i = dir->tdir_count-1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_DOUBLE: - return (TIFFFetchDoubleArray(tif, dir, (double*) v)); - default: - /* TIFF_NOTYPE */ - /* TIFF_ASCII */ - /* TIFF_UNDEFINED */ - TIFFError(tif->tif_name, - "Cannot read TIFF_ANY type %d for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return (0); - } - return (1); -} - -/* - * Fetch a tag that is not handled by special case code. - */ -static int -TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp) -{ - static const char mesg[] = "to fetch tag value"; - int ok = 0; - const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dp->tdir_tag); - - if (dp->tdir_count > 1) { /* array of values */ - char* cp = NULL; - - switch (dp->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - /* NB: always expand BYTE values to shorts */ - cp = CheckMalloc(tif, - dp->tdir_count * sizeof (uint16), mesg); - ok = cp && TIFFFetchByteArray(tif, dp, (uint16*) cp); - break; - case TIFF_SHORT: - case TIFF_SSHORT: - cp = CheckMalloc(tif, - dp->tdir_count * sizeof (uint16), mesg); - ok = cp && TIFFFetchShortArray(tif, dp, (uint16*) cp); - break; - case TIFF_LONG: - case TIFF_SLONG: - cp = CheckMalloc(tif, - dp->tdir_count * sizeof (uint32), mesg); - ok = cp && TIFFFetchLongArray(tif, dp, (uint32*) cp); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - cp = CheckMalloc(tif, - dp->tdir_count * sizeof (float), mesg); - ok = cp && TIFFFetchRationalArray(tif, dp, (float*) cp); - break; - case TIFF_FLOAT: - cp = CheckMalloc(tif, - dp->tdir_count * sizeof (float), mesg); - ok = cp && TIFFFetchFloatArray(tif, dp, (float*) cp); - break; - case TIFF_DOUBLE: - cp = CheckMalloc(tif, - dp->tdir_count * sizeof (double), mesg); - ok = cp && TIFFFetchDoubleArray(tif, dp, (double*) cp); - break; - case TIFF_ASCII: - case TIFF_UNDEFINED: /* bit of a cheat... */ - /* - * Some vendors write strings w/o the trailing - * NULL byte, so always append one just in case. - */ - cp = CheckMalloc(tif, dp->tdir_count+1, mesg); - if( (ok = (cp && TIFFFetchString(tif, dp, cp))) != 0 ) - cp[dp->tdir_count] = '\0'; /* XXX */ - break; - } - if (ok) { - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, dp->tdir_count, cp) - : TIFFSetField(tif, dp->tdir_tag, cp)); - } - if (cp != NULL) - _TIFFfree(cp); - } else if (CheckDirCount(tif, dp, 1)) { /* singleton value */ - switch (dp->tdir_type) { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - /* - * If the tag is also acceptable as a LONG or SLONG - * then TIFFSetField will expect an uint32 parameter - * passed to it (through varargs). Thus, for machines - * where sizeof (int) != sizeof (uint32) we must do - * a careful check here. It's hard to say if this - * is worth optimizing. - * - * NB: We use TIFFFieldWithTag here knowing that - * it returns us the first entry in the table - * for the tag and that that entry is for the - * widest potential data type the tag may have. - */ - { TIFFDataType type = fip->field_type; - if (type != TIFF_LONG && type != TIFF_SLONG) { - uint16 v = (uint16) - TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v) - : TIFFSetField(tif, dp->tdir_tag, v)); - break; - } - } - /* fall thru... */ - case TIFF_LONG: - case TIFF_SLONG: - { uint32 v32 = - TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v32) - : TIFFSetField(tif, dp->tdir_tag, v32)); - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - { float v = (dp->tdir_type == TIFF_FLOAT ? - TIFFFetchFloat(tif, dp) - : TIFFFetchRational(tif, dp)); - ok = (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v) - : TIFFSetField(tif, dp->tdir_tag, v)); - } - break; - case TIFF_DOUBLE: - { double v; - ok = (TIFFFetchDoubleArray(tif, dp, &v) && - (fip->field_passcount ? - TIFFSetField(tif, dp->tdir_tag, 1, &v) - : TIFFSetField(tif, dp->tdir_tag, v)) - ); - } - break; - case TIFF_ASCII: - case TIFF_UNDEFINED: /* bit of a cheat... */ - { char c[2]; - if( (ok = (TIFFFetchString(tif, dp, c) != 0)) != 0 ){ - c[1] = '\0'; /* XXX paranoid */ - ok = TIFFSetField(tif, dp->tdir_tag, c); - } - } - break; - } - } - return (ok); -} - -#define NITEMS(x) (sizeof (x) / sizeof (x[0])) -/* - * Fetch samples/pixel short values for - * the specified tag and verify that - * all values are the same. - */ -static int -TIFFFetchPerSampleShorts(TIFF* tif, TIFFDirEntry* dir, int* pl) -{ - int samples = tif->tif_dir.td_samplesperpixel; - int status = 0; - - if (CheckDirCount(tif, dir, (uint32) samples)) { - uint16 buf[10]; - uint16* v = buf; - - if (samples > NITEMS(buf)) - v = (uint16*) _TIFFmalloc(samples * sizeof (uint16)); - if (TIFFFetchShortArray(tif, dir, v)) { - int i; - for (i = 1; i < samples; i++) - if (v[i] != v[0]) { - TIFFError(tif->tif_name, - "Cannot handle different per-sample values for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - goto bad; - } - *pl = v[0]; - status = 1; - } - bad: - if (v != buf) - _TIFFfree((char*) v); - } - return (status); -} - -/* - * Fetch samples/pixel ANY values for - * the specified tag and verify that - * all values are the same. - */ -static int -TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl) -{ - int samples = (int) tif->tif_dir.td_samplesperpixel; - int status = 0; - - if (CheckDirCount(tif, dir, (uint32) samples)) { - double buf[10]; - double* v = buf; - - if (samples > NITEMS(buf)) - v = (double*) _TIFFmalloc(samples * sizeof (double)); - if (TIFFFetchAnyArray(tif, dir, v)) { - int i; - for (i = 1; i < samples; i++) - if (v[i] != v[0]) { - TIFFError(tif->tif_name, - "Cannot handle different per-sample values for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - goto bad; - } - *pl = v[0]; - status = 1; - } - bad: - if (v != buf) - _TIFFfree(v); - } - return (status); -} -#undef NITEMS - -/* - * Fetch a set of offsets or lengths. - * While this routine says "strips", - * in fact it's also used for tiles. - */ -static int -TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32** lpp) -{ - register uint32* lp; - int status; - - if (!CheckDirCount(tif, dir, (uint32) nstrips)) - return (0); - /* - * Allocate space for strip information. - */ - if (*lpp == NULL && - (*lpp = (uint32 *)CheckMalloc(tif, - nstrips * sizeof (uint32), "for strip array")) == NULL) - return (0); - lp = *lpp; - if (dir->tdir_type == (int)TIFF_SHORT) { - /* - * Handle uint16->uint32 expansion. - */ - uint16* dp = (uint16*) CheckMalloc(tif, - dir->tdir_count* sizeof (uint16), "to fetch strip tag"); - if (dp == NULL) - return (0); - if( (status = TIFFFetchShortArray(tif, dir, dp)) != 0 ) { - register uint16* wp = dp; - while (nstrips-- > 0) - *lp++ = *wp++; - } - _TIFFfree((char*) dp); - } else - status = TIFFFetchLongArray(tif, dir, lp); - return (status); -} - -#define NITEMS(x) (sizeof (x) / sizeof (x[0])) -/* - * Fetch and set the ExtraSamples tag. - */ -static int -TIFFFetchExtraSamples(TIFF* tif, TIFFDirEntry* dir) -{ - uint16 buf[10]; - uint16* v = buf; - int status; - - if (dir->tdir_count > NITEMS(buf)) - v = (uint16*) _TIFFmalloc(dir->tdir_count * sizeof (uint16)); - if (dir->tdir_type == TIFF_BYTE) - status = TIFFFetchByteArray(tif, dir, v); - else - status = TIFFFetchShortArray(tif, dir, v); - if (status) - status = TIFFSetField(tif, dir->tdir_tag, dir->tdir_count, v); - if (v != buf) - _TIFFfree((char*) v); - return (status); -} -#undef NITEMS - -#ifdef COLORIMETRY_SUPPORT -/* - * Fetch and set the RefBlackWhite tag. - */ -static int -TIFFFetchRefBlackWhite(TIFF* tif, TIFFDirEntry* dir) -{ - static const char mesg[] = "for \"ReferenceBlackWhite\" array"; - char* cp; - int ok; - - if (dir->tdir_type == TIFF_RATIONAL) - return (TIFFFetchNormalTag(tif, dir)); - /* - * Handle LONG's for backward compatibility. - */ - cp = CheckMalloc(tif, dir->tdir_count * sizeof (uint32), mesg); - if( (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32*) cp))) != 0) { - float* fp = (float*) - CheckMalloc(tif, dir->tdir_count * sizeof (float), mesg); - if( (ok = (fp != NULL)) != 0 ) { - uint32 i; - for (i = 0; i < dir->tdir_count; i++) - fp[i] = (float)((uint32*) cp)[i]; - ok = TIFFSetField(tif, dir->tdir_tag, fp); - _TIFFfree((char*) fp); - } - } - if (cp) - _TIFFfree(cp); - return (ok); -} -#endif - -/* - * Replace a single strip (tile) of uncompressed data by - * multiple strips (tiles), each approximately 8Kbytes. - * This is useful for dealing with large images or - * for dealing with machines with a limited amount - * memory. - */ -static void -ChopUpSingleUncompressedStrip(TIFF* tif) -{ - register TIFFDirectory *td = &tif->tif_dir; - uint32 bytecount = td->td_stripbytecount[0]; - uint32 offset = td->td_stripoffset[0]; - tsize_t rowbytes = TIFFVTileSize(tif, 1), stripbytes; - tstrip_t strip, nstrips, rowsperstrip; - uint32* newcounts; - uint32* newoffsets; - - /* - * Make the rows hold at least one - * scanline, but fill 8k if possible. - */ - if (rowbytes > 8192) { - stripbytes = rowbytes; - rowsperstrip = 1; - } else { - rowsperstrip = 8192 / rowbytes; - stripbytes = rowbytes * rowsperstrip; - } - /* never increase the number of strips in an image */ - if (rowsperstrip >= td->td_rowsperstrip) - return; - nstrips = (tstrip_t) TIFFhowmany(bytecount, stripbytes); - newcounts = (uint32*) CheckMalloc(tif, nstrips * sizeof (uint32), - "for chopped \"StripByteCounts\" array"); - newoffsets = (uint32*) CheckMalloc(tif, nstrips * sizeof (uint32), - "for chopped \"StripOffsets\" array"); - if (newcounts == NULL || newoffsets == NULL) { - /* - * Unable to allocate new strip information, give - * up and use the original one strip information. - */ - if (newcounts != NULL) - _TIFFfree(newcounts); - if (newoffsets != NULL) - _TIFFfree(newoffsets); - return; - } - /* - * Fill the strip information arrays with - * new bytecounts and offsets that reflect - * the broken-up format. - */ - for (strip = 0; strip < nstrips; strip++) { - if (stripbytes > (tsize_t) bytecount) - stripbytes = bytecount; - newcounts[strip] = stripbytes; - newoffsets[strip] = offset; - offset += stripbytes; - bytecount -= stripbytes; - } - /* - * Replace old single strip info with multi-strip info. - */ - td->td_stripsperimage = td->td_nstrips = nstrips; - TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - - _TIFFfree(td->td_stripbytecount); - _TIFFfree(td->td_stripoffset); - td->td_stripbytecount = newcounts; - td->td_stripoffset = newoffsets; -} diff --git a/freeimage241/Source/LibTIFF/tif_dirwrite.c b/freeimage241/Source/LibTIFF/tif_dirwrite.c deleted file mode 100644 index 2cf02ff..0000000 --- a/freeimage241/Source/LibTIFF/tif_dirwrite.c +++ /dev/null @@ -1,1021 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_dirwrite.c,v 1.0 2001-04-13 00:42:31+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Write Support Routines. - */ -#include "tiffiop.h" - -#if HAVE_IEEEFP -#define TIFFCvtNativeToIEEEFloat(tif, n, fp) -#define TIFFCvtNativeToIEEEDouble(tif, n, dp) -#else -extern void TIFFCvtNativeToIEEEFloat(TIFF*, uint32, float*); -extern void TIFFCvtNativeToIEEEDouble(TIFF*, uint32, double*); -#endif - -static int TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*); -static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32); -static int TIFFSetupShortPair(TIFF*, ttag_t, TIFFDirEntry*); -static int TIFFWritePerSampleShorts(TIFF*, ttag_t, TIFFDirEntry*); -static int TIFFWritePerSampleAnys(TIFF*, TIFFDataType, ttag_t, TIFFDirEntry*); -static int TIFFWriteShortTable(TIFF*, ttag_t, TIFFDirEntry*, uint32, uint16**); -static int TIFFWriteShortArray(TIFF*, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, uint16*); -static int TIFFWriteLongArray(TIFF *, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, uint32*); -static int TIFFWriteRationalArray(TIFF *, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, float*); -static int TIFFWriteFloatArray(TIFF *, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, float*); -static int TIFFWriteDoubleArray(TIFF *, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*); -static int TIFFWriteByteArray(TIFF*, TIFFDirEntry*, char*); -static int TIFFWriteAnyArray(TIFF*, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*); -#ifdef COLORIMETRY_SUPPORT -static int TIFFWriteTransferFunction(TIFF*, TIFFDirEntry*); -#endif -#ifdef CMYK_SUPPORT -static int TIFFWriteInkNames(TIFF*, TIFFDirEntry*); -#endif -static int TIFFWriteData(TIFF*, TIFFDirEntry*, char*); -static int TIFFLinkDirectory(TIFF*); - -#define WriteRationalPair(type, tag1, v1, tag2, v2) { \ - if (!TIFFWriteRational(tif, type, tag1, dir, v1)) \ - goto bad; \ - if (!TIFFWriteRational(tif, type, tag2, dir+1, v2)) \ - goto bad; \ - dir++; \ -} -#define TIFFWriteRational(tif, type, tag, dir, v) \ - TIFFWriteRationalArray((tif), (type), (tag), (dir), 1, &(v)) -#ifndef TIFFWriteRational -static int TIFFWriteRational(TIFF*, - TIFFDataType, ttag_t, TIFFDirEntry*, float); -#endif - -/* - * Write the contents of the current directory - * to the specified file. This routine doesn't - * handle overwriting a directory with auxiliary - * storage that's been changed. - */ -int -TIFFWriteDirectory(TIFF* tif) -{ - uint16 dircount; - toff_t diroff; - ttag_t tag; - uint32 nfields; - tsize_t dirsize; - char* data; - TIFFDirEntry* dir; - TIFFDirectory* td; - u_long b, fields[FIELD_SETLONGS]; - int fi, nfi; - - if (tif->tif_mode == O_RDONLY) - return (1); - /* - * Clear write state so that subsequent images with - * different characteristics get the right buffers - * setup for them. - */ - if (tif->tif_flags & TIFF_POSTENCODE) { - tif->tif_flags &= ~TIFF_POSTENCODE; - if (!(*tif->tif_postencode)(tif)) { - TIFFError(tif->tif_name, - "Error post-encoding before directory write"); - return (0); - } - } - (*tif->tif_close)(tif); /* shutdown encoder */ - /* - * Flush any data that might have been written - * by the compression close+cleanup routines. - */ - if (tif->tif_rawcc > 0 && !TIFFFlushData1(tif)) { - TIFFError(tif->tif_name, - "Error flushing data before directory write"); - return (0); - } - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { - _TIFFfree(tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawcc = 0; - tif->tif_rawdatasize = 0; - } - tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP); - - td = &tif->tif_dir; - /* - * Size the directory so that we can calculate - * offsets for the data items that aren't kept - * in-place in each field. - */ - nfields = 0; - for (b = 0; b <= FIELD_LAST; b++) - if (TIFFFieldSet(tif, b)) - nfields += (b < FIELD_SUBFILETYPE ? 2 : 1); - dirsize = nfields * sizeof (TIFFDirEntry); - data = (char*) _TIFFmalloc(dirsize); - if (data == NULL) { - TIFFError(tif->tif_name, - "Cannot write directory, out of space"); - return (0); - } - /* - * Directory hasn't been placed yet, put - * it at the end of the file and link it - * into the existing directory structure. - */ - if (tif->tif_diroff == 0 && !TIFFLinkDirectory(tif)) - goto bad; - tif->tif_dataoff = (toff_t)( - tif->tif_diroff + sizeof (uint16) + dirsize + sizeof (toff_t)); - if (tif->tif_dataoff & 1) - tif->tif_dataoff++; - (void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET); - tif->tif_curdir++; - dir = (TIFFDirEntry*) data; - /* - * Setup external form of directory - * entries and write data items. - */ - _TIFFmemcpy(fields, td->td_fieldsset, sizeof (fields)); - /* - * Write out ExtraSamples tag only if - * extra samples are present in the data. - */ - if (FieldSet(fields, FIELD_EXTRASAMPLES) && !td->td_extrasamples) { - ResetFieldBit(fields, FIELD_EXTRASAMPLES); - nfields--; - dirsize -= sizeof (TIFFDirEntry); - } /*XXX*/ - for (fi = 0, nfi = tif->tif_nfields; nfi > 0; nfi--, fi++) { - const TIFFFieldInfo* fip = tif->tif_fieldinfo[fi]; - if (!FieldSet(fields, fip->field_bit)) - continue; - switch (fip->field_bit) { - case FIELD_STRIPOFFSETS: - /* - * We use one field bit for both strip and tile - * offsets, and so must be careful in selecting - * the appropriate field descriptor (so that tags - * are written in sorted order). - */ - tag = isTiled(tif) ? - TIFFTAG_TILEOFFSETS : TIFFTAG_STRIPOFFSETS; - if (tag != fip->field_tag) - continue; - if (!TIFFWriteLongArray(tif, TIFF_LONG, tag, dir, - (uint32) td->td_nstrips, td->td_stripoffset)) - goto bad; - break; - case FIELD_STRIPBYTECOUNTS: - /* - * We use one field bit for both strip and tile - * byte counts, and so must be careful in selecting - * the appropriate field descriptor (so that tags - * are written in sorted order). - */ - tag = isTiled(tif) ? - TIFFTAG_TILEBYTECOUNTS : TIFFTAG_STRIPBYTECOUNTS; - if (tag != fip->field_tag) - continue; - if (!TIFFWriteLongArray(tif, TIFF_LONG, tag, dir, - (uint32) td->td_nstrips, td->td_stripbytecount)) - goto bad; - break; - case FIELD_ROWSPERSTRIP: - TIFFSetupShortLong(tif, TIFFTAG_ROWSPERSTRIP, - dir, td->td_rowsperstrip); - break; - case FIELD_COLORMAP: - if (!TIFFWriteShortTable(tif, TIFFTAG_COLORMAP, dir, - 3, td->td_colormap)) - goto bad; - break; - case FIELD_IMAGEDIMENSIONS: - TIFFSetupShortLong(tif, TIFFTAG_IMAGEWIDTH, - dir++, td->td_imagewidth); - TIFFSetupShortLong(tif, TIFFTAG_IMAGELENGTH, - dir, td->td_imagelength); - break; - case FIELD_TILEDIMENSIONS: - TIFFSetupShortLong(tif, TIFFTAG_TILEWIDTH, - dir++, td->td_tilewidth); - TIFFSetupShortLong(tif, TIFFTAG_TILELENGTH, - dir, td->td_tilelength); - break; - case FIELD_POSITION: - WriteRationalPair(TIFF_RATIONAL, - TIFFTAG_XPOSITION, td->td_xposition, - TIFFTAG_YPOSITION, td->td_yposition); - break; - case FIELD_RESOLUTION: - WriteRationalPair(TIFF_RATIONAL, - TIFFTAG_XRESOLUTION, td->td_xresolution, - TIFFTAG_YRESOLUTION, td->td_yresolution); - break; - case FIELD_BITSPERSAMPLE: - case FIELD_MINSAMPLEVALUE: - case FIELD_MAXSAMPLEVALUE: - case FIELD_SAMPLEFORMAT: - if (!TIFFWritePerSampleShorts(tif, fip->field_tag, dir)) - goto bad; - break; - case FIELD_SMINSAMPLEVALUE: - case FIELD_SMAXSAMPLEVALUE: - if (!TIFFWritePerSampleAnys(tif, - _TIFFSampleToTagType(tif), fip->field_tag, dir)) - goto bad; - break; - case FIELD_PAGENUMBER: - case FIELD_HALFTONEHINTS: -#ifdef YCBCR_SUPPORT - case FIELD_YCBCRSUBSAMPLING: -#endif -#ifdef CMYK_SUPPORT - case FIELD_DOTRANGE: -#endif - if (!TIFFSetupShortPair(tif, fip->field_tag, dir)) - goto bad; - break; -#ifdef CMYK_SUPPORT - case FIELD_INKNAMES: - if (!TIFFWriteInkNames(tif, dir)) - goto bad; - break; -#endif -#ifdef COLORIMETRY_SUPPORT - case FIELD_TRANSFERFUNCTION: - if (!TIFFWriteTransferFunction(tif, dir)) - goto bad; - break; -#endif -#if SUBIFD_SUPPORT - case FIELD_SUBIFD: - if (!TIFFWriteNormalTag(tif, dir, fip)) - goto bad; - /* - * Total hack: if this directory includes a SubIFD - * tag then force the next directories to be - * written as ``sub directories'' of this one. This - * is used to write things like thumbnails and - * image masks that one wants to keep out of the - * normal directory linkage access mechanism. - */ - if (dir->tdir_count > 0) { - tif->tif_flags |= TIFF_INSUBIFD; - tif->tif_nsubifd = (uint16) dir->tdir_count; - if (dir->tdir_count > 1) - tif->tif_subifdoff = dir->tdir_offset; - else - tif->tif_subifdoff = (uint32)( - tif->tif_diroff - + sizeof (uint16) - + ((char*)&dir->tdir_offset-data)); - } - break; -#endif - default: - if (!TIFFWriteNormalTag(tif, dir, fip)) - goto bad; - break; - } - dir++; - ResetFieldBit(fields, fip->field_bit); - } - /* - * Write directory. - */ - dircount = (uint16) nfields; - diroff = (uint32) tif->tif_nextdiroff; - if (tif->tif_flags & TIFF_SWAB) { - /* - * The file's byte order is opposite to the - * native machine architecture. We overwrite - * the directory information with impunity - * because it'll be released below after we - * write it to the file. Note that all the - * other tag construction routines assume that - * we do this byte-swapping; i.e. they only - * byte-swap indirect data. - */ - for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) { - TIFFSwabArrayOfShort(&dir->tdir_tag, 2); - TIFFSwabArrayOfLong(&dir->tdir_count, 2); - } - dircount = (uint16) nfields; - TIFFSwabShort(&dircount); - TIFFSwabLong(&diroff); - } - (void) TIFFSeekFile(tif, tif->tif_diroff, SEEK_SET); - if (!WriteOK(tif, &dircount, sizeof (dircount))) { - TIFFError(tif->tif_name, "Error writing directory count"); - goto bad; - } - if (!WriteOK(tif, data, dirsize)) { - TIFFError(tif->tif_name, "Error writing directory contents"); - goto bad; - } - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFError(tif->tif_name, "Error writing directory link"); - goto bad; - } - TIFFFreeDirectory(tif); - _TIFFfree(data); - tif->tif_flags &= ~TIFF_DIRTYDIRECT; - (*tif->tif_cleanup)(tif); - - /* - * Reset directory-related state for subsequent - * directories. - */ - TIFFCreateDirectory(tif); - return (1); -bad: - _TIFFfree(data); - return (0); -} -#undef WriteRationalPair - -/* - * Process tags that are not special cased. - */ -static int -TIFFWriteNormalTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip) -{ - u_short wc = (u_short) fip->field_writecount; - uint32 wc2; - - dir->tdir_tag = (uint16) fip->field_tag; - dir->tdir_type = (u_short) fip->field_type; - dir->tdir_count = wc; -#define WRITEF(x,y) x(tif, fip->field_type, fip->field_tag, dir, wc, y) - switch (fip->field_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - if (wc > 1) { - uint16* wp; - if (wc == (u_short) TIFF_VARIABLE) - TIFFGetField(tif, fip->field_tag, &wc, &wp); - else - TIFFGetField(tif, fip->field_tag, &wp); - if (!WRITEF(TIFFWriteShortArray, wp)) - return (0); - } else { - uint16 sv; - TIFFGetField(tif, fip->field_tag, &sv); - dir->tdir_offset = - TIFFInsertData(tif, dir->tdir_type, sv); - } - break; - case TIFF_LONG: - case TIFF_SLONG: - if (wc > 1) { - uint32* lp; - if (wc == (u_short) TIFF_VARIABLE) - TIFFGetField(tif, fip->field_tag, &wc, &lp); - else - TIFFGetField(tif, fip->field_tag, &lp); - if (!WRITEF(TIFFWriteLongArray, lp)) - return (0); - } else { - /* XXX handle LONG->SHORT conversion */ - TIFFGetField(tif, fip->field_tag, &dir->tdir_offset); - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - if (wc > 1) { - float* fp; - if (wc == (u_short) TIFF_VARIABLE) - TIFFGetField(tif, fip->field_tag, &wc, &fp); - else - TIFFGetField(tif, fip->field_tag, &fp); - if (!WRITEF(TIFFWriteRationalArray, fp)) - return (0); - } else { - float fv; - TIFFGetField(tif, fip->field_tag, &fv); - if (!WRITEF(TIFFWriteRationalArray, &fv)) - return (0); - } - break; - case TIFF_FLOAT: - if (wc > 1) { - float* fp; - if (wc == (u_short) TIFF_VARIABLE) - TIFFGetField(tif, fip->field_tag, &wc, &fp); - else - TIFFGetField(tif, fip->field_tag, &fp); - if (!WRITEF(TIFFWriteFloatArray, fp)) - return (0); - } else { - float fv; - TIFFGetField(tif, fip->field_tag, &fv); - if (!WRITEF(TIFFWriteFloatArray, &fv)) - return (0); - } - break; - case TIFF_DOUBLE: - if (wc > 1) { - double* dp; - if (wc == (u_short) TIFF_VARIABLE) - TIFFGetField(tif, fip->field_tag, &wc, &dp); - else - TIFFGetField(tif, fip->field_tag, &dp); - if (!WRITEF(TIFFWriteDoubleArray, dp)) - return (0); - } else { - double dv; - TIFFGetField(tif, fip->field_tag, &dv); - if (!WRITEF(TIFFWriteDoubleArray, &dv)) - return (0); - } - break; - case TIFF_ASCII: - { char* cp; - TIFFGetField(tif, fip->field_tag, &cp); - dir->tdir_count = (uint32) (strlen(cp) + 1); - if (!TIFFWriteByteArray(tif, dir, cp)) - return (0); - } - break; - - /* added based on patch request from MARTIN.MCBRIDE.MM@agfa.co.uk, - correctness not verified (FW, 99/08) */ - case TIFF_BYTE: - case TIFF_SBYTE: - if (wc > 1) { - char* cp; - if (wc == (u_short) TIFF_VARIABLE) { - TIFFGetField(tif, fip->field_tag, &wc, &cp); - dir->tdir_count = wc; - } else - TIFFGetField(tif, fip->field_tag, &cp); - if (!TIFFWriteByteArray(tif, dir, cp)) - return (0); - } else { - char cv; - TIFFGetField(tif, fip->field_tag, &cv); - if (!TIFFWriteByteArray(tif, dir, &cv)) - return (0); - } - break; - - case TIFF_UNDEFINED: - { char* cp; - if (wc == (u_short) TIFF_VARIABLE) { - TIFFGetField(tif, fip->field_tag, &wc, &cp); - dir->tdir_count = wc; - } else if (wc == (u_short) TIFF_VARIABLE2) { - TIFFGetField(tif, fip->field_tag, &wc2, &cp); - dir->tdir_count = wc2; - } else - TIFFGetField(tif, fip->field_tag, &cp); - if (!TIFFWriteByteArray(tif, dir, cp)) - return (0); - } - break; - - case TIFF_NOTYPE: - break; - } - return (1); -} -#undef WRITEF - -/* - * Setup a directory entry with either a SHORT - * or LONG type according to the value. - */ -static void -TIFFSetupShortLong(TIFF* tif, ttag_t tag, TIFFDirEntry* dir, uint32 v) -{ - dir->tdir_tag = (uint16) tag; - dir->tdir_count = 1; - if (v > 0xffffL) { - dir->tdir_type = (short) TIFF_LONG; - dir->tdir_offset = v; - } else { - dir->tdir_type = (short) TIFF_SHORT; - dir->tdir_offset = TIFFInsertData(tif, (int) TIFF_SHORT, v); - } -} -#undef MakeShortDirent - -#ifndef TIFFWriteRational -/* - * Setup a RATIONAL directory entry and - * write the associated indirect value. - */ -static int -TIFFWriteRational(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, float v) -{ - return (TIFFWriteRationalArray(tif, type, tag, dir, 1, &v)); -} -#endif - -#define NITEMS(x) (sizeof (x) / sizeof (x[0])) -/* - * Setup a directory entry that references a - * samples/pixel array of SHORT values and - * (potentially) write the associated indirect - * values. - */ -static int -TIFFWritePerSampleShorts(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) -{ - uint16 buf[10], v; - uint16* w = buf; - int i, status, samples = tif->tif_dir.td_samplesperpixel; - - if (samples > NITEMS(buf)) - w = (uint16*) _TIFFmalloc(samples * sizeof (uint16)); - TIFFGetField(tif, tag, &v); - for (i = 0; i < samples; i++) - w[i] = v; - status = TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, samples, w); - if (w != buf) - _TIFFfree((char*) w); - return (status); -} - -/* - * Setup a directory entry that references a samples/pixel array of ``type'' - * values and (potentially) write the associated indirect values. The source - * data from TIFFGetField() for the specified tag must be returned as double. - */ -static int -TIFFWritePerSampleAnys(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir) -{ - double buf[10], v; - double* w = buf; - int i, status; - int samples = (int) tif->tif_dir.td_samplesperpixel; - - if (samples > NITEMS(buf)) - w = (double*) _TIFFmalloc(samples * sizeof (double)); - TIFFGetField(tif, tag, &v); - for (i = 0; i < samples; i++) - w[i] = v; - status = TIFFWriteAnyArray(tif, type, tag, dir, samples, w); - if (w != buf) - _TIFFfree(w); - return (status); -} -#undef NITEMS - -/* - * Setup a pair of shorts that are returned by - * value, rather than as a reference to an array. - */ -static int -TIFFSetupShortPair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) -{ - uint16 v[2]; - - TIFFGetField(tif, tag, &v[0], &v[1]); - return (TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, 2, v)); -} - -/* - * Setup a directory entry for an NxM table of shorts, - * where M is known to be 2**bitspersample, and write - * the associated indirect data. - */ -static int -TIFFWriteShortTable(TIFF* tif, - ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16** table) -{ - uint32 i, off; - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (short) TIFF_SHORT; - /* XXX -- yech, fool TIFFWriteData */ - dir->tdir_count = (uint32) (1L<tif_dir.td_bitspersample); - off = tif->tif_dataoff; - for (i = 0; i < n; i++) - if (!TIFFWriteData(tif, dir, (char *)table[i])) - return (0); - dir->tdir_count *= n; - dir->tdir_offset = off; - return (1); -} - -/* - * Write/copy data associated with an ASCII or opaque tag value. - */ -static int -TIFFWriteByteArray(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - if (dir->tdir_count > 4) { - if (!TIFFWriteData(tif, dir, cp)) - return (0); - } else - _TIFFmemcpy(&dir->tdir_offset, cp, dir->tdir_count); - return (1); -} - -/* - * Setup a directory entry of an array of SHORT - * or SSHORT and write the associated indirect values. - */ -static int -TIFFWriteShortArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16* v) -{ - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (short) type; - dir->tdir_count = n; - if (n <= 2) { - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - dir->tdir_offset = (uint32) ((long) v[0] << 16); - if (n == 2) - dir->tdir_offset |= v[1] & 0xffff; - } else { - dir->tdir_offset = v[0] & 0xffff; - if (n == 2) - dir->tdir_offset |= (long) v[1] << 16; - } - return (1); - } else - return (TIFFWriteData(tif, dir, (char*) v)); -} - -/* - * Setup a directory entry of an array of LONG - * or SLONG and write the associated indirect values. - */ -static int -TIFFWriteLongArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, uint32* v) -{ - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (short) type; - dir->tdir_count = n; - if (n == 1) { - dir->tdir_offset = v[0]; - return (1); - } else - return (TIFFWriteData(tif, dir, (char*) v)); -} - -/* - * Setup a directory entry of an array of RATIONAL - * or SRATIONAL and write the associated indirect values. - */ -static int -TIFFWriteRationalArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v) -{ - uint32 i; - uint32* t; - int status; - - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (short) type; - dir->tdir_count = n; - t = (uint32*) _TIFFmalloc(2*n * sizeof (uint32)); - for (i = 0; i < n; i++) { - float fv = v[i]; - int sign = 1; - uint32 den; - - if (fv < 0) { - if (type == TIFF_RATIONAL) { - TIFFWarning(tif->tif_name, - "\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL", - _TIFFFieldWithTag(tif,tag)->field_name, fv); - fv = 0; - } else - fv = -fv, sign = -1; - } - den = 1L; - if (fv > 0) { - while (fv < 1L<<(31-3) && den < 1L<<(31-3)) - fv *= 1<<3, den *= 1L<<3; - } - t[2*i+0] = (uint32) (sign * (fv + 0.5)); - t[2*i+1] = den; - } - status = TIFFWriteData(tif, dir, (char *)t); - _TIFFfree((char*) t); - return (status); -} - -static int -TIFFWriteFloatArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v) -{ - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (short) type; - dir->tdir_count = n; - TIFFCvtNativeToIEEEFloat(tif, n, v); - if (n == 1) { - dir->tdir_offset = *(uint32*) &v[0]; - return (1); - } else - return (TIFFWriteData(tif, dir, (char*) v)); -} - -static int -TIFFWriteDoubleArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v) -{ - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (short) type; - dir->tdir_count = n; - TIFFCvtNativeToIEEEDouble(tif, n, v); - return (TIFFWriteData(tif, dir, (char*) v)); -} - -/* - * Write an array of ``type'' values for a specified tag (i.e. this is a tag - * which is allowed to have different types, e.g. SMaxSampleType). - * Internally the data values are represented as double since a double can - * hold any of the TIFF tag types (yes, this should really be an abstract - * type tany_t for portability). The data is converted into the specified - * type in a temporary buffer and then handed off to the appropriate array - * writer. - */ -static int -TIFFWriteAnyArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v) -{ - char buf[10 * sizeof(double)]; - char* w = buf; - int i, status = 0; - - if (n * tiffDataWidth[type] > sizeof buf) - w = (char*) _TIFFmalloc(n * tiffDataWidth[type]); - switch (type) { - case TIFF_BYTE: - { uint8* bp = (uint8*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (uint8) v[i]; - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (short) type; - dir->tdir_count = n; - if (!TIFFWriteByteArray(tif, dir, (char*) bp)) - goto out; - } - break; - case TIFF_SBYTE: - { int8* bp = (int8*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (int8) v[i]; - dir->tdir_tag = (uint16) tag; - dir->tdir_type = (short) type; - dir->tdir_count = n; - if (!TIFFWriteByteArray(tif, dir, (char*) bp)) - goto out; - } - break; - case TIFF_SHORT: - { uint16* bp = (uint16*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (uint16) v[i]; - if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16*)bp)) - goto out; - } - break; - case TIFF_SSHORT: - { int16* bp = (int16*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (int16) v[i]; - if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16*)bp)) - goto out; - } - break; - case TIFF_LONG: - { uint32* bp = (uint32*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (uint32) v[i]; - if (!TIFFWriteLongArray(tif, type, tag, dir, n, bp)) - goto out; - } - break; - case TIFF_SLONG: - { int32* bp = (int32*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (int32) v[i]; - if (!TIFFWriteLongArray(tif, type, tag, dir, n, (uint32*) bp)) - goto out; - } - break; - case TIFF_FLOAT: - { float* bp = (float*) w; - for (i = 0; i < (int) n; i++) - bp[i] = (float) v[i]; - if (!TIFFWriteFloatArray(tif, type, tag, dir, n, bp)) - goto out; - } - break; - case TIFF_DOUBLE: - return (TIFFWriteDoubleArray(tif, type, tag, dir, n, v)); - default: - /* TIFF_NOTYPE */ - /* TIFF_ASCII */ - /* TIFF_UNDEFINED */ - /* TIFF_RATIONAL */ - /* TIFF_SRATIONAL */ - goto out; - } - status = 1; - out: - if (w != buf) - _TIFFfree(w); - return (status); -} - -#ifdef COLORIMETRY_SUPPORT -static int -TIFFWriteTransferFunction(TIFF* tif, TIFFDirEntry* dir) -{ - TIFFDirectory* td = &tif->tif_dir; - tsize_t n = (1L<td_bitspersample) * sizeof (uint16); - uint16** tf = td->td_transferfunction; - int ncols; - - /* - * Check if the table can be written as a single column, - * or if it must be written as 3 columns. Note that we - * write a 3-column tag if there are 2 samples/pixel and - * a single column of data won't suffice--hmm. - */ - switch (td->td_samplesperpixel - td->td_extrasamples) { - default: if (_TIFFmemcmp(tf[0], tf[2], n)) { ncols = 3; break; } - case 2: if (_TIFFmemcmp(tf[0], tf[1], n)) { ncols = 3; break; } - case 1: case 0: ncols = 1; - } - return (TIFFWriteShortTable(tif, - TIFFTAG_TRANSFERFUNCTION, dir, ncols, tf)); -} -#endif - -#ifdef CMYK_SUPPORT -static int -TIFFWriteInkNames(TIFF* tif, TIFFDirEntry* dir) -{ - TIFFDirectory* td = &tif->tif_dir; - - dir->tdir_tag = TIFFTAG_INKNAMES; - dir->tdir_type = (short) TIFF_ASCII; - dir->tdir_count = td->td_inknameslen; - return (TIFFWriteByteArray(tif, dir, td->td_inknames)); -} -#endif - -/* - * Write a contiguous directory item. - */ -static int -TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp) -{ - tsize_t cc; - - if (tif->tif_flags & TIFF_SWAB) { - switch (dir->tdir_type) { - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); - break; - case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); - break; - } - } - dir->tdir_offset = tif->tif_dataoff; - cc = dir->tdir_count * tiffDataWidth[dir->tdir_type]; - if (SeekOK(tif, dir->tdir_offset) && - WriteOK(tif, cp, cc)) { - tif->tif_dataoff += (cc + 1) & ~1; - return (1); - } - TIFFError(tif->tif_name, "Error writing data for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return (0); -} - -/* - * Link the current directory into the - * directory chain for the file. - */ -static int -TIFFLinkDirectory(TIFF* tif) -{ - static const char module[] = "TIFFLinkDirectory"; - toff_t nextdir; - toff_t diroff, off; - - tif->tif_diroff = (TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1; - diroff = tif->tif_diroff; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&diroff); -#if SUBIFD_SUPPORT - if (tif->tif_flags & TIFF_INSUBIFD) { - (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFError(module, - "%s: Error writing SubIFD directory link", - tif->tif_name); - return (0); - } - /* - * Advance to the next SubIFD or, if this is - * the last one configured, revert back to the - * normal directory linkage. - */ - if (--tif->tif_nsubifd) - tif->tif_subifdoff += sizeof (diroff); - else - tif->tif_flags &= ~TIFF_INSUBIFD; - return (1); - } -#endif - if (tif->tif_header.tiff_diroff == 0) { - /* - * First directory, overwrite offset in header. - */ - tif->tif_header.tiff_diroff = tif->tif_diroff; -#define HDROFF(f) ((toff_t) &(((TIFFHeader*) 0)->f)) - (void) TIFFSeekFile(tif, HDROFF(tiff_diroff), SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFError(tif->tif_name, "Error writing TIFF header"); - return (0); - } - return (1); - } - /* - * Not the first directory, search to the last and append. - */ - nextdir = tif->tif_header.tiff_diroff; - do { - uint16 dircount; - - if (!SeekOK(tif, nextdir) || - !ReadOK(tif, &dircount, sizeof (dircount))) { - TIFFError(module, "Error fetching directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - (void) TIFFSeekFile(tif, - dircount * sizeof (TIFFDirEntry), SEEK_CUR); - if (!ReadOK(tif, &nextdir, sizeof (nextdir))) { - TIFFError(module, "Error fetching directory link"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir); - } while (nextdir != 0); - off = TIFFSeekFile(tif, 0, SEEK_CUR); /* get current offset */ - (void) TIFFSeekFile(tif, off - (toff_t)sizeof(nextdir), SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof (diroff))) { - TIFFError(module, "Error writing directory link"); - return (0); - } - return (1); -} diff --git a/freeimage241/Source/LibTIFF/tif_dumpmode.c b/freeimage241/Source/LibTIFF/tif_dumpmode.c deleted file mode 100644 index b3d1de7..0000000 --- a/freeimage241/Source/LibTIFF/tif_dumpmode.c +++ /dev/null @@ -1,118 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_dumpmode.c,v 1.0 2001-04-13 00:42:31+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * "Null" Compression Algorithm Support. - */ -#include "tiffiop.h" -#include - -/* - * Encode a hunk of pixels. - */ -static int -DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) -{ - (void) s; - while (cc > 0) { - tsize_t n; - - n = cc; - if (tif->tif_rawcc + n > tif->tif_rawdatasize) - n = tif->tif_rawdatasize - tif->tif_rawcc; - - assert( n > 0 ); - - /* - * Avoid copy if client has setup raw - * data buffer to avoid extra copy. - */ - if (tif->tif_rawcp != pp) - _TIFFmemcpy(tif->tif_rawcp, pp, n); - tif->tif_rawcp += n; - tif->tif_rawcc += n; - pp += n; - cc -= n; - if (tif->tif_rawcc >= tif->tif_rawdatasize && - !TIFFFlushData1(tif)) - return (-1); - } - return (1); -} - -/* - * Decode a hunk of pixels. - */ -static int -DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - (void) s; - if (tif->tif_rawcc < cc) { - TIFFError(tif->tif_name, - "DumpModeDecode: Not enough data for scanline %d", - tif->tif_row); - return (0); - } - /* - * Avoid copy if client has setup raw - * data buffer to avoid extra copy. - */ - if (tif->tif_rawcp != buf) - _TIFFmemcpy(buf, tif->tif_rawcp, cc); - tif->tif_rawcp += cc; - tif->tif_rawcc -= cc; - return (1); -} - -/* - * Seek forwards nrows in the current strip. - */ -static int -DumpModeSeek(TIFF* tif, uint32 nrows) -{ - tif->tif_rawcp += nrows * tif->tif_scanlinesize; - tif->tif_rawcc -= nrows * tif->tif_scanlinesize; - return (1); -} - -/* - * Initialize dump mode. - */ -int -TIFFInitDumpMode(TIFF* tif, int scheme) -{ - (void) scheme; - tif->tif_decoderow = DumpModeDecode; - tif->tif_decodestrip = DumpModeDecode; - tif->tif_decodetile = DumpModeDecode; - tif->tif_encoderow = DumpModeEncode; - tif->tif_encodestrip = DumpModeEncode; - tif->tif_encodetile = DumpModeEncode; - tif->tif_seek = DumpModeSeek; - return (1); -} diff --git a/freeimage241/Source/LibTIFF/tif_error.c b/freeimage241/Source/LibTIFF/tif_error.c deleted file mode 100644 index 12e977e..0000000 --- a/freeimage241/Source/LibTIFF/tif_error.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_error.c,v 1.0 2001-04-13 00:42:31+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - */ -#include "tiffiop.h" - -TIFFErrorHandler -TIFFSetErrorHandler(TIFFErrorHandler handler) -{ - TIFFErrorHandler prev = _TIFFerrorHandler; - _TIFFerrorHandler = handler; - return (prev); -} - -void -TIFFError(const char* module, const char* fmt, ...) -{ - if (_TIFFerrorHandler) { - va_list ap; - va_start(ap, fmt); - (*_TIFFerrorHandler)(module, fmt, ap); - va_end(ap); - } -} diff --git a/freeimage241/Source/LibTIFF/tif_fax3.c b/freeimage241/Source/LibTIFF/tif_fax3.c deleted file mode 100644 index d0cc302..0000000 --- a/freeimage241/Source/LibTIFF/tif_fax3.c +++ /dev/null @@ -1,1552 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_fax3.c,v 1.0 2001-04-13 00:42:31+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1990-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef CCITT_SUPPORT -/* - * TIFF Library. - * - * CCITT Group 3 (T.4) and Group 4 (T.6) Compression Support. - * - * This file contains support for decoding and encoding TIFF - * compression algorithms 2, 3, 4, and 32771. - * - * Decoder support is derived, with permission, from the code - * in Frank Cringle's viewfax program; - * Copyright (C) 1990, 1995 Frank D. Cringle. - */ -#include "tif_fax3.h" -#define G3CODES -#include "t4.h" -#include -#include - -/* - * NB: define PURIFY if you're using purify and you want - * to avoid some harmless array bounds complaints that - * can happen in the _TIFFFax3fillruns routine. - */ - -/* - * Compression+decompression state blocks are - * derived from this ``base state'' block. - */ -typedef struct { - int rw_mode; /* O_RDONLY for decode, else encode */ - int mode; /* operating mode */ - uint32 rowbytes; /* bytes in a decoded scanline */ - uint32 rowpixels; /* pixels in a scanline */ - - uint16 cleanfaxdata; /* CleanFaxData tag */ - uint32 badfaxrun; /* BadFaxRun tag */ - uint32 badfaxlines; /* BadFaxLines tag */ - uint32 groupoptions; /* Group 3/4 options tag */ - uint32 recvparams; /* encoded Class 2 session params */ - char* subaddress; /* subaddress string */ - uint32 recvtime; /* time spent receiving (secs) */ - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ -} Fax3BaseState; -#define Fax3State(tif) ((Fax3BaseState*) (tif)->tif_data) - -typedef struct { - Fax3BaseState b; - const u_char* bitmap; /* bit reversal table */ - uint32 data; /* current i/o byte/word */ - int bit; /* current i/o bit in byte */ - int EOLcnt; /* count of EOL codes recognized */ - TIFFFaxFillFunc fill; /* fill routine */ - uint32* runs; /* b&w runs for current/previous row */ - uint32* refruns; /* runs for reference line */ - uint32* curruns; /* runs for current line */ -} Fax3DecodeState; -#define DecoderState(tif) ((Fax3DecodeState*) Fax3State(tif)) - -typedef enum { G3_1D, G3_2D } Ttag; -typedef struct { - Fax3BaseState b; - int data; /* current i/o byte */ - int bit; /* current i/o bit in byte */ - Ttag tag; /* encoding state */ - u_char* refline; /* reference line for 2d decoding */ - int k; /* #rows left that can be 2d encoded */ - int maxk; /* max #rows that can be 2d encoded */ -} Fax3EncodeState; -#define EncoderState(tif) ((Fax3EncodeState*) Fax3State(tif)) - -#define is2DEncoding(sp) \ - (sp->b.groupoptions & GROUP3OPT_2DENCODING) -#define isAligned(p,t) ((((u_long)(p)) & (sizeof (t)-1)) == 0) - -/* - * Group 3 and Group 4 Decoding. - */ - -/* - * These macros glue the TIFF library state to - * the state expected by Frank's decoder. - */ -#define DECLARE_STATE(tif, sp, mod) \ - static const char module[] = mod; \ - Fax3DecodeState* sp = DecoderState(tif); \ - int a0; /* reference element */ \ - int lastx = sp->b.rowpixels; /* last element in row */ \ - uint32 BitAcc; /* bit accumulator */ \ - int BitsAvail; /* # valid bits in BitAcc */ \ - int RunLength; /* length of current run */ \ - u_char* cp; /* next byte of input data */ \ - u_char* ep; /* end of input data */ \ - uint32* pa; /* place to stuff next run */ \ - uint32* thisrun; /* current row's run array */ \ - int EOLcnt; /* # EOL codes recognized */ \ - const u_char* bitmap = sp->bitmap; /* input data bit reverser */ \ - const TIFFFaxTabEnt* TabEnt -#define DECLARE_STATE_2D(tif, sp, mod) \ - DECLARE_STATE(tif, sp, mod); \ - int b1; /* next change on prev line */ \ - uint32* pb /* next run in reference line */\ -/* - * Load any state that may be changed during decoding. - */ -#define CACHE_STATE(tif, sp) do { \ - BitAcc = sp->data; \ - BitsAvail = sp->bit; \ - EOLcnt = sp->EOLcnt; \ - cp = (unsigned char*) tif->tif_rawcp; \ - ep = cp + tif->tif_rawcc; \ -} while (0) -/* - * Save state possibly changed during decoding. - */ -#define UNCACHE_STATE(tif, sp) do { \ - sp->bit = BitsAvail; \ - sp->data = BitAcc; \ - sp->EOLcnt = EOLcnt; \ - tif->tif_rawcc -= (tidata_t) cp - tif->tif_rawcp; \ - tif->tif_rawcp = (tidata_t) cp; \ -} while (0) - -/* - * Setup state for decoding a strip. - */ -static int -Fax3PreDecode(TIFF* tif, tsample_t s) -{ - Fax3DecodeState* sp = DecoderState(tif); - - (void) s; - assert(sp != NULL); - sp->bit = 0; /* force initial read */ - sp->data = 0; - sp->EOLcnt = 0; /* force initial scan for EOL */ - /* - * Decoder assumes lsb-to-msb bit order. Note that we select - * this here rather than in Fax3SetupState so that viewers can - * hold the image open, fiddle with the FillOrder tag value, - * and then re-decode the image. Otherwise they'd need to close - * and open the image to get the state reset. - */ - sp->bitmap = - TIFFGetBitRevTable(tif->tif_dir.td_fillorder != FILLORDER_LSB2MSB); - if (sp->refruns) { /* init reference line to white */ - sp->refruns[0] = (uint32) sp->b.rowpixels; - sp->refruns[1] = 0; - } - return (1); -} - -/* - * Routine for handling various errors/conditions. - * Note how they are "glued into the decoder" by - * overriding the definitions used by the decoder. - */ - -static void -Fax3Unexpected(const char* module, TIFF* tif, uint32 a0) -{ - TIFFError(module, "%s: Bad code word at scanline %d (x %lu)", - tif->tif_name, tif->tif_row, (u_long) a0); -} -#define unexpected(table, a0) Fax3Unexpected(module, tif, a0) - -static void -Fax3Extension(const char* module, TIFF* tif, uint32 a0) -{ - TIFFError(module, - "%s: Uncompressed data (not supported) at scanline %d (x %lu)", - tif->tif_name, tif->tif_row, (u_long) a0); -} -#define extension(a0) Fax3Extension(module, tif, a0) - -static void -Fax3BadLength(const char* module, TIFF* tif, uint32 a0, uint32 lastx) -{ - TIFFWarning(module, "%s: %s at scanline %d (got %lu, expected %lu)", - tif->tif_name, - a0 < lastx ? "Premature EOL" : "Line length mismatch", - tif->tif_row, (u_long) a0, (u_long) lastx); -} -#define badlength(a0,lastx) Fax3BadLength(module, tif, a0, lastx) - -static void -Fax3PrematureEOF(const char* module, TIFF* tif, uint32 a0) -{ - TIFFWarning(module, "%s: Premature EOF at scanline %d (x %lu)", - tif->tif_name, tif->tif_row, (u_long) a0); -} -#define prematureEOF(a0) Fax3PrematureEOF(module, tif, a0) - -#define Nop - -/* - * Decode the requested amount of G3 1D-encoded data. - */ -static int -Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - DECLARE_STATE(tif, sp, "Fax3Decode1D"); - - (void) s; - CACHE_STATE(tif, sp); - thisrun = sp->curruns; - while ((long)occ > 0) { - a0 = 0; - RunLength = 0; - pa = thisrun; -#ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); - fflush(stdout); -#endif - SYNC_EOL(EOF1D); - EXPAND1D(EOF1Da); - (*sp->fill)(buf, thisrun, pa, lastx); - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - if (occ != 0) - tif->tif_row++; - continue; - EOF1D: /* premature EOF */ - CLEANUP_RUNS(); - EOF1Da: /* premature EOF */ - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (-1); - } - UNCACHE_STATE(tif, sp); - return (1); -} - -#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } -/* - * Decode the requested amount of G3 2D-encoded data. - */ -static int -Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); - int is1D; /* current line is 1d/2d-encoded */ - - (void) s; - CACHE_STATE(tif, sp); - while ((long)occ > 0) { - a0 = 0; - RunLength = 0; - pa = thisrun = sp->curruns; -#ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d EOLcnt = %d", - BitAcc, BitsAvail, EOLcnt); -#endif - SYNC_EOL(EOF2D); - NeedBits8(1, EOF2D); - is1D = GetBits(1); /* 1D/2D-encoding tag bit */ - ClrBits(1); -#ifdef FAX3_DEBUG - printf(" %s\n-------------------- %d\n", - is1D ? "1D" : "2D", tif->tif_row); - fflush(stdout); -#endif - pb = sp->refruns; - b1 = *pb++; - if (is1D) - EXPAND1D(EOF2Da); - else - EXPAND2D(EOF2Da); - (*sp->fill)(buf, thisrun, pa, lastx); - SETVAL(0); /* imaginary change for reference */ - SWAP(uint32*, sp->curruns, sp->refruns); - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - if (occ != 0) - tif->tif_row++; - continue; - EOF2D: /* premature EOF */ - CLEANUP_RUNS(); - EOF2Da: /* premature EOF */ - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (-1); - } - UNCACHE_STATE(tif, sp); - return (1); -} -#undef SWAP - -/* - * The ZERO & FILL macros must handle spans < 2*sizeof(long) bytes. - * For machines with 64-bit longs this is <16 bytes; otherwise - * this is <8 bytes. We optimize the code here to reflect the - * machine characteristics. - */ -#if defined(__alpha) || _MIPS_SZLONG == 64 -#define FILL(n, cp) \ - switch (n) { \ - case 15:(cp)[14] = 0xff; case 14:(cp)[13] = 0xff; case 13: (cp)[12] = 0xff;\ - case 12:(cp)[11] = 0xff; case 11:(cp)[10] = 0xff; case 10: (cp)[9] = 0xff;\ - case 9: (cp)[8] = 0xff; case 8: (cp)[7] = 0xff; case 7: (cp)[6] = 0xff;\ - case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; case 4: (cp)[3] = 0xff;\ - case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \ - case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \ - } -#define ZERO(n, cp) \ - switch (n) { \ - case 15:(cp)[14] = 0; case 14:(cp)[13] = 0; case 13: (cp)[12] = 0; \ - case 12:(cp)[11] = 0; case 11:(cp)[10] = 0; case 10: (cp)[9] = 0; \ - case 9: (cp)[8] = 0; case 8: (cp)[7] = 0; case 7: (cp)[6] = 0; \ - case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; case 4: (cp)[3] = 0; \ - case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \ - case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \ - } -#else -#define FILL(n, cp) \ - switch (n) { \ - case 7: (cp)[6] = 0xff; case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; \ - case 4: (cp)[3] = 0xff; case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \ - case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \ - } -#define ZERO(n, cp) \ - switch (n) { \ - case 7: (cp)[6] = 0; case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; \ - case 4: (cp)[3] = 0; case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \ - case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \ - } -#endif - -/* - * Bit-fill a row according to the white/black - * runs generated during G3/G4 decoding. - */ -void -_TIFFFax3fillruns(u_char* buf, uint32* runs, uint32* erun, uint32 lastx) -{ - static const unsigned char _fillmasks[] = - { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; - u_char* cp; - uint32 x, bx, run; - int32 n, nw; - long* lp; - - if ((erun-runs)&1) - *erun++ = 0; - x = 0; - for (; runs < erun; runs += 2) { - run = runs[0]; - if (x+run > lastx || run > lastx ) - run = runs[0] = (uint32) (lastx - x); - if (run) { - cp = buf + (x>>3); - bx = x&7; - if (run > 8-bx) { - if (bx) { /* align to byte boundary */ - *cp++ &= 0xff << (8-bx); - run -= 8-bx; - } - if( (n = run >> 3) != 0 ) { /* multiple bytes to fill */ - if ((n/sizeof (long)) > 1) { - /* - * Align to longword boundary and fill. - */ - for (; n && !isAligned(cp, long); n--) - *cp++ = 0x00; - lp = (long*) cp; - nw = (int32)(n / sizeof (long)); - n -= nw * sizeof (long); - do { - *lp++ = 0L; - } while (--nw); - cp = (u_char*) lp; - } - ZERO(n, cp); - run &= 7; - } -#ifdef PURIFY - if (run) - cp[0] &= 0xff >> run; -#else - cp[0] &= 0xff >> run; -#endif - } else - cp[0] &= ~(_fillmasks[run]>>bx); - x += runs[0]; - } - run = runs[1]; - if (x+run > lastx || run > lastx ) - run = runs[1] = lastx - x; - if (run) { - cp = buf + (x>>3); - bx = x&7; - if (run > 8-bx) { - if (bx) { /* align to byte boundary */ - *cp++ |= 0xff >> bx; - run -= 8-bx; - } - if( (n = run>>3) != 0 ) { /* multiple bytes to fill */ - if ((n/sizeof (long)) > 1) { - /* - * Align to longword boundary and fill. - */ - for (; n && !isAligned(cp, long); n--) - *cp++ = 0xff; - lp = (long*) cp; - nw = (int32)(n / sizeof (long)); - n -= nw * sizeof (long); - do { - *lp++ = -1L; - } while (--nw); - cp = (u_char*) lp; - } - FILL(n, cp); - run &= 7; - } -#ifdef PURIFY - if (run) - cp[0] |= 0xff00 >> run; -#else - cp[0] |= 0xff00 >> run; -#endif - } else - cp[0] |= _fillmasks[run]>>bx; - x += runs[1]; - } - } - assert(x == lastx); -} -#undef ZERO -#undef FILL - -/* - * Setup G3/G4-related compression/decompression state - * before data is processed. This routine is called once - * per image -- it sets up different state based on whether - * or not decoding or encoding is being done and whether - * 1D- or 2D-encoded data is involved. - */ -static int -Fax3SetupState(TIFF* tif) -{ - TIFFDirectory* td = &tif->tif_dir; - Fax3BaseState* sp = Fax3State(tif); - long rowbytes, rowpixels; - int needsRefLine; - - if (td->td_bitspersample != 1) { - TIFFError(tif->tif_name, - "Bits/sample must be 1 for Group 3/4 encoding/decoding"); - return (0); - } - /* - * Calculate the scanline/tile widths. - */ - if (isTiled(tif)) { - rowbytes = TIFFTileRowSize(tif); - rowpixels = td->td_tilewidth; - } else { - rowbytes = TIFFScanlineSize(tif); - rowpixels = td->td_imagewidth; - } - sp->rowbytes = (uint32) rowbytes; - sp->rowpixels = (uint32) rowpixels; - /* - * Allocate any additional space required for decoding/encoding. - */ - needsRefLine = ( - (sp->groupoptions & GROUP3OPT_2DENCODING) || - td->td_compression == COMPRESSION_CCITTFAX4 - ); - if (sp->rw_mode == O_RDONLY) { /* 1d/2d decoding */ - Fax3DecodeState* dsp = DecoderState(tif); - uint32 nruns = needsRefLine ? - 2*TIFFroundup(rowpixels,32) : rowpixels; - - dsp->runs = (uint32*) _TIFFmalloc((2*nruns+3)*sizeof (uint32)); - if (dsp->runs == NULL) { - TIFFError("Fax3SetupState", - "%s: No space for Group 3/4 run arrays", - tif->tif_name); - return (0); - } - dsp->curruns = dsp->runs; - if (needsRefLine) - dsp->refruns = dsp->runs + (nruns>>1); - else - dsp->refruns = NULL; - if (is2DEncoding(dsp)) { /* NB: default is 1D routine */ - tif->tif_decoderow = Fax3Decode2D; - tif->tif_decodestrip = Fax3Decode2D; - tif->tif_decodetile = Fax3Decode2D; - } - } else if (needsRefLine) { /* 2d encoding */ - Fax3EncodeState* esp = EncoderState(tif); - /* - * 2d encoding requires a scanline - * buffer for the ``reference line''; the - * scanline against which delta encoding - * is referenced. The reference line must - * be initialized to be ``white'' (done elsewhere). - */ - esp->refline = (u_char*) _TIFFmalloc(rowbytes); - if (esp->refline == NULL) { - TIFFError("Fax3SetupState", - "%s: No space for Group 3/4 reference line", - tif->tif_name); - return (0); - } - } else /* 1d encoding */ - EncoderState(tif)->refline = NULL; - return (1); -} - -/* - * CCITT Group 3 FAX Encoding. - */ - -#define Fax3FlushBits(tif, sp) { \ - if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ - (void) TIFFFlushData1(tif); \ - *(tif)->tif_rawcp++ = (sp)->data; \ - (tif)->tif_rawcc++; \ - (sp)->data = 0, (sp)->bit = 8; \ -} -#define _FlushBits(tif) { \ - if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ - (void) TIFFFlushData1(tif); \ - *(tif)->tif_rawcp++ = data; \ - (tif)->tif_rawcc++; \ - data = 0, bit = 8; \ -} -static const int _msbmask[9] = - { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff }; -#define _PutBits(tif, bits, length) { \ - while (length > bit) { \ - data |= bits >> (length - bit); \ - length -= bit; \ - _FlushBits(tif); \ - } \ - data |= (bits & _msbmask[length]) << (bit - length); \ - bit -= length; \ - if (bit == 0) \ - _FlushBits(tif); \ -} - -/* - * Write a variable-length bit-value to - * the output stream. Values are - * assumed to be at most 16 bits. - */ -static void -Fax3PutBits(TIFF* tif, u_int bits, u_int length) -{ - Fax3EncodeState* sp = EncoderState(tif); - u_int bit = sp->bit; - int data = sp->data; - - _PutBits(tif, bits, length); - - sp->data = data; - sp->bit = bit; -} - -/* - * Write a code to the output stream. - */ -#define putcode(tif, te) Fax3PutBits(tif, (te)->code, (te)->length) - -#ifdef FAX3_DEBUG -#define DEBUG_COLOR(w) (tab == TIFFFaxWhiteCodes ? w "W" : w "B") -#define DEBUG_PRINT(what,len) { \ - int t; \ - printf("%08X/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \ - for (t = length-1; t >= 0; t--) \ - putchar(code & (1<bit; - int data = sp->data; - u_int code, length; - - while (span >= 2624) { - const tableentry* te = &tab[63 + (2560>>6)]; - code = te->code, length = te->length; -#ifdef FAX3_DEBUG - DEBUG_PRINT("MakeUp", te->runlen); -#endif - _PutBits(tif, code, length); - span -= te->runlen; - } - if (span >= 64) { - const tableentry* te = &tab[63 + (span>>6)]; - assert(te->runlen == 64*(span>>6)); - code = te->code, length = te->length; -#ifdef FAX3_DEBUG - DEBUG_PRINT("MakeUp", te->runlen); -#endif - _PutBits(tif, code, length); - span -= te->runlen; - } - code = tab[span].code, length = tab[span].length; -#ifdef FAX3_DEBUG - DEBUG_PRINT(" Term", tab[span].runlen); -#endif - _PutBits(tif, code, length); - - sp->data = data; - sp->bit = bit; -} - -/* - * Write an EOL code to the output stream. The zero-fill - * logic for byte-aligning encoded scanlines is handled - * here. We also handle writing the tag bit for the next - * scanline when doing 2d encoding. - */ -static void -Fax3PutEOL(TIFF* tif) -{ - Fax3EncodeState* sp = EncoderState(tif); - u_int bit = sp->bit; - int data = sp->data; - u_int code, length, tparm; - - if (sp->b.groupoptions & GROUP3OPT_FILLBITS) { - /* - * Force bit alignment so EOL will terminate on - * a byte boundary. That is, force the bit alignment - * to 16-12 = 4 before putting out the EOL code. - */ - int align = 8 - 4; - if (align != sp->bit) { - if (align > sp->bit) - align = sp->bit + (8 - align); - else - align = sp->bit - align; - code = 0; - tparm=align; - _PutBits(tif, 0, tparm); - } - } - code = EOL, length = 12; - if (is2DEncoding(sp)) - code = (code<<1) | (sp->tag == G3_1D), length++; - _PutBits(tif, code, length); - - sp->data = data; - sp->bit = bit; -} - -/* - * Reset encoding state at the start of a strip. - */ -static int -Fax3PreEncode(TIFF* tif, tsample_t s) -{ - Fax3EncodeState* sp = EncoderState(tif); - - (void) s; - assert(sp != NULL); - sp->bit = 8; - sp->data = 0; - sp->tag = G3_1D; - /* - * This is necessary for Group 4; otherwise it isn't - * needed because the first scanline of each strip ends - * up being copied into the refline. - */ - if (sp->refline) - _TIFFmemset(sp->refline, 0x00, sp->b.rowbytes); - if (is2DEncoding(sp)) { - float res = tif->tif_dir.td_yresolution; - /* - * The CCITT spec says that when doing 2d encoding, you - * should only do it on K consecutive scanlines, where K - * depends on the resolution of the image being encoded - * (2 for <= 200 lpi, 4 for > 200 lpi). Since the directory - * code initializes td_yresolution to 0, this code will - * select a K of 2 unless the YResolution tag is set - * appropriately. (Note also that we fudge a little here - * and use 150 lpi to avoid problems with units conversion.) - */ - if (tif->tif_dir.td_resolutionunit == RESUNIT_CENTIMETER) - res *= 2.54f; /* convert to inches */ - sp->maxk = (res > 150 ? 4 : 2); - sp->k = sp->maxk-1; - } else - sp->k = sp->maxk = 0; - return (1); -} - -static const u_char zeroruns[256] = { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0f */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1f */ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x20 - 0x2f */ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x30 - 0x3f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x5f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x7f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 - 0xaf */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 - 0xbf */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 - 0xcf */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 - 0xdf */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 - 0xef */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xf0 - 0xff */ -}; -static const u_char oneruns[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 - 0x0f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x1f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 - 0x2f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 - 0x3f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x4f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 - 0x5f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6f */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 - 0x8f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 - 0x9f */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xa0 - 0xaf */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xb0 - 0xbf */ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xc0 - 0xcf */ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xd0 - 0xdf */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xe0 - 0xef */ - 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, /* 0xf0 - 0xff */ -}; - -/* - * On certain systems it pays to inline - * the routines that find pixel spans. - */ -#ifdef VAXC -static int32 find0span(u_char*, int32, int32); -static int32 find1span(u_char*, int32, int32); -#pragma inline(find0span,find1span) -#endif - -/* - * Find a span of ones or zeros using the supplied - * table. The ``base'' of the bit string is supplied - * along with the start+end bit indices. - */ -INLINE static int32 -find0span(u_char* bp, int32 bs, int32 be) -{ - int32 bits = be - bs; - int32 n, span; - - bp += bs>>3; - /* - * Check partial byte on lhs. - */ - if (bits > 0 && (n = (bs & 7))) { - span = zeroruns[(*bp << n) & 0xff]; - if (span > 8-n) /* table value too generous */ - span = 8-n; - if (span > bits) /* constrain span to bit range */ - span = bits; - if (n+span < 8) /* doesn't extend to edge of byte */ - return (span); - bits -= span; - bp++; - } else - span = 0; - if (bits >= 2*8*sizeof (long)) { - long* lp; - /* - * Align to longword boundary and check longwords. - */ - while (!isAligned(bp, long)) { - if (*bp != 0x00) - return (span + zeroruns[*bp]); - span += 8, bits -= 8; - bp++; - } - lp = (long*) bp; - while (bits >= 8*sizeof (long) && *lp == 0) { - span += 8*sizeof (long), bits -= 8*sizeof (long); - lp++; - } - bp = (u_char*) lp; - } - /* - * Scan full bytes for all 0's. - */ - while (bits >= 8) { - if (*bp != 0x00) /* end of run */ - return (span + zeroruns[*bp]); - span += 8, bits -= 8; - bp++; - } - /* - * Check partial byte on rhs. - */ - if (bits > 0) { - n = zeroruns[*bp]; - span += (n > bits ? bits : n); - } - return (span); -} - -INLINE static int32 -find1span(u_char* bp, int32 bs, int32 be) -{ - int32 bits = be - bs; - int32 n, span; - - bp += bs>>3; - /* - * Check partial byte on lhs. - */ - if (bits > 0 && (n = (bs & 7))) { - span = oneruns[(*bp << n) & 0xff]; - if (span > 8-n) /* table value too generous */ - span = 8-n; - if (span > bits) /* constrain span to bit range */ - span = bits; - if (n+span < 8) /* doesn't extend to edge of byte */ - return (span); - bits -= span; - bp++; - } else - span = 0; - if (bits >= 2*8*sizeof (long)) { - long* lp; - /* - * Align to longword boundary and check longwords. - */ - while (!isAligned(bp, long)) { - if (*bp != 0xff) - return (span + oneruns[*bp]); - span += 8, bits -= 8; - bp++; - } - lp = (long*) bp; - while (bits >= 8*sizeof (long) && *lp == ~0) { - span += 8*sizeof (long), bits -= 8*sizeof (long); - lp++; - } - bp = (u_char*) lp; - } - /* - * Scan full bytes for all 1's. - */ - while (bits >= 8) { - if (*bp != 0xff) /* end of run */ - return (span + oneruns[*bp]); - span += 8, bits -= 8; - bp++; - } - /* - * Check partial byte on rhs. - */ - if (bits > 0) { - n = oneruns[*bp]; - span += (n > bits ? bits : n); - } - return (span); -} - -/* - * Return the offset of the next bit in the range - * [bs..be] that is different from the specified - * color. The end, be, is returned if no such bit - * exists. - */ -#define finddiff(_cp, _bs, _be, _color) \ - (_bs + (_color ? find1span(_cp,_bs,_be) : find0span(_cp,_bs,_be))) -/* - * Like finddiff, but also check the starting bit - * against the end in case start > end. - */ -#define finddiff2(_cp, _bs, _be, _color) \ - (_bs < _be ? finddiff(_cp,_bs,_be,_color) : _be) - -/* - * 1d-encode a row of pixels. The encoding is - * a sequence of all-white or all-black spans - * of pixels encoded with Huffman codes. - */ -static int -Fax3Encode1DRow(TIFF* tif, u_char* bp, uint32 bits) -{ - Fax3EncodeState* sp = EncoderState(tif); - int32 span; - uint32 bs = 0; - - for (;;) { - span = find0span(bp, bs, bits); /* white span */ - putspan(tif, span, TIFFFaxWhiteCodes); - bs += span; - if (bs >= bits) - break; - span = find1span(bp, bs, bits); /* black span */ - putspan(tif, span, TIFFFaxBlackCodes); - bs += span; - if (bs >= bits) - break; - } - if (sp->b.mode & (FAXMODE_BYTEALIGN|FAXMODE_WORDALIGN)) { - if (sp->bit != 8) /* byte-align */ - Fax3FlushBits(tif, sp); - if ((sp->b.mode&FAXMODE_WORDALIGN) && - !isAligned(tif->tif_rawcp, uint16)) - Fax3FlushBits(tif, sp); - } - return (1); -} - -static const tableentry horizcode = - { 3, 0x1 }; /* 001 */ -static const tableentry passcode = - { 4, 0x1 }; /* 0001 */ -static const tableentry vcodes[7] = { - { 7, 0x03 }, /* 0000 011 */ - { 6, 0x03 }, /* 0000 11 */ - { 3, 0x03 }, /* 011 */ - { 1, 0x1 }, /* 1 */ - { 3, 0x2 }, /* 010 */ - { 6, 0x02 }, /* 0000 10 */ - { 7, 0x02 } /* 0000 010 */ -}; - -/* - * 2d-encode a row of pixels. Consult the CCITT - * documentation for the algorithm. - */ -static int -Fax3Encode2DRow(TIFF* tif, u_char* bp, u_char* rp, uint32 bits) -{ -#define PIXEL(buf,ix) ((((buf)[(ix)>>3]) >> (7-((ix)&7))) & 1) - uint32 a0 = 0; - uint32 a1 = (PIXEL(bp, 0) != 0 ? 0 : finddiff(bp, 0, bits, 0)); - uint32 b1 = (PIXEL(rp, 0) != 0 ? 0 : finddiff(rp, 0, bits, 0)); - uint32 a2, b2; - - for (;;) { - b2 = finddiff2(rp, b1, bits, PIXEL(rp,b1)); - if (b2 >= a1) { - int32 d = b1 - a1; - if (!(-3 <= d && d <= 3)) { /* horizontal mode */ - a2 = finddiff2(bp, a1, bits, PIXEL(bp,a1)); - putcode(tif, &horizcode); - if (a0+a1 == 0 || PIXEL(bp, a0) == 0) { - putspan(tif, a1-a0, TIFFFaxWhiteCodes); - putspan(tif, a2-a1, TIFFFaxBlackCodes); - } else { - putspan(tif, a1-a0, TIFFFaxBlackCodes); - putspan(tif, a2-a1, TIFFFaxWhiteCodes); - } - a0 = a2; - } else { /* vertical mode */ - putcode(tif, &vcodes[d+3]); - a0 = a1; - } - } else { /* pass mode */ - putcode(tif, &passcode); - a0 = b2; - } - if (a0 >= bits) - break; - a1 = finddiff(bp, a0, bits, PIXEL(bp,a0)); - b1 = finddiff(rp, a0, bits, !PIXEL(bp,a0)); - b1 = finddiff(rp, b1, bits, PIXEL(bp,a0)); - } - return (1); -#undef PIXEL -} - -/* - * Encode a buffer of pixels. - */ -static int -Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - Fax3EncodeState* sp = EncoderState(tif); - - (void) s; - while ((long)cc > 0) { - if ((sp->b.mode & FAXMODE_NOEOL) == 0) - Fax3PutEOL(tif); - if (is2DEncoding(sp)) { - if (sp->tag == G3_1D) { - if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) - return (0); - sp->tag = G3_2D; - } else { - if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) - return (0); - sp->k--; - } - if (sp->k == 0) { - sp->tag = G3_1D; - sp->k = sp->maxk-1; - } else - _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); - } else { - if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) - return (0); - } - bp += sp->b.rowbytes; - cc -= sp->b.rowbytes; - if (cc != 0) - tif->tif_row++; - } - return (1); -} - -static int -Fax3PostEncode(TIFF* tif) -{ - Fax3EncodeState* sp = EncoderState(tif); - - if (sp->bit != 8) - Fax3FlushBits(tif, sp); - return (1); -} - -static void -Fax3Close(TIFF* tif) -{ - if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0) { - Fax3EncodeState* sp = EncoderState(tif); - u_int code = EOL; - u_int length = 12; - int i; - - if (is2DEncoding(sp)) - code = (code<<1) | (sp->tag == G3_1D), length++; - for (i = 0; i < 6; i++) - Fax3PutBits(tif, code, length); - Fax3FlushBits(tif, sp); - } -} - -static void -Fax3Cleanup(TIFF* tif) -{ - if (tif->tif_data) { - if (Fax3State(tif)->rw_mode == O_RDONLY) { - Fax3DecodeState* sp = DecoderState(tif); - if (sp->runs) - _TIFFfree(sp->runs); - } else { - Fax3EncodeState* sp = EncoderState(tif); - if (sp->refline) - _TIFFfree(sp->refline); - } - if (Fax3State(tif)->subaddress) - _TIFFfree(Fax3State(tif)->subaddress); - _TIFFfree(tif->tif_data); - tif->tif_data = NULL; - } -} - -#define FIELD_BADFAXLINES (FIELD_CODEC+0) -#define FIELD_CLEANFAXDATA (FIELD_CODEC+1) -#define FIELD_BADFAXRUN (FIELD_CODEC+2) -#define FIELD_RECVPARAMS (FIELD_CODEC+3) -#define FIELD_SUBADDRESS (FIELD_CODEC+4) -#define FIELD_RECVTIME (FIELD_CODEC+5) - -#define FIELD_OPTIONS (FIELD_CODEC+6) - -static const TIFFFieldInfo faxFieldInfo[] = { - { TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "FaxMode" }, - { TIFFTAG_FAXFILLFUNC, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "FaxFillFunc" }, - { TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, FIELD_BADFAXLINES, - TRUE, FALSE, "BadFaxLines" }, - { TIFFTAG_BADFAXLINES, 1, 1, TIFF_SHORT, FIELD_BADFAXLINES, - TRUE, FALSE, "BadFaxLines" }, - { TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, FIELD_CLEANFAXDATA, - TRUE, FALSE, "CleanFaxData" }, - { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_LONG, FIELD_BADFAXRUN, - TRUE, FALSE, "ConsecutiveBadFaxLines" }, - { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_SHORT, FIELD_BADFAXRUN, - TRUE, FALSE, "ConsecutiveBadFaxLines" }, - { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, FIELD_RECVPARAMS, - TRUE, FALSE, "FaxRecvParams" }, - { TIFFTAG_FAXSUBADDRESS, -1,-1, TIFF_ASCII, FIELD_SUBADDRESS, - TRUE, FALSE, "FaxSubAddress" }, - { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, - TRUE, FALSE, "FaxRecvTime" }, -}; -static const TIFFFieldInfo fax3FieldInfo[] = { - { TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, - FALSE, FALSE, "Group3Options" }, -}; -static const TIFFFieldInfo fax4FieldInfo[] = { - { TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, - FALSE, FALSE, "Group4Options" }, -}; -#define N(a) (sizeof (a) / sizeof (a[0])) - -static int -Fax3VSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - Fax3BaseState* sp = Fax3State(tif); - - switch (tag) { - case TIFFTAG_FAXMODE: - sp->mode = va_arg(ap, int); - return (1); /* NB: pseudo tag */ - case TIFFTAG_FAXFILLFUNC: - if (sp->rw_mode == O_RDONLY) - DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc); - return (1); /* NB: pseudo tag */ - case TIFFTAG_GROUP3OPTIONS: - case TIFFTAG_GROUP4OPTIONS: - sp->groupoptions = va_arg(ap, uint32); - break; - case TIFFTAG_BADFAXLINES: - sp->badfaxlines = va_arg(ap, uint32); - break; - case TIFFTAG_CLEANFAXDATA: - sp->cleanfaxdata = (uint16) va_arg(ap, int); - break; - case TIFFTAG_CONSECUTIVEBADFAXLINES: - sp->badfaxrun = va_arg(ap, uint32); - break; - case TIFFTAG_FAXRECVPARAMS: - sp->recvparams = va_arg(ap, uint32); - break; - case TIFFTAG_FAXSUBADDRESS: - _TIFFsetString(&sp->subaddress, va_arg(ap, char*)); - break; - case TIFFTAG_FAXRECVTIME: - sp->recvtime = va_arg(ap, uint32); - break; - default: - return (*sp->vsetparent)(tif, tag, ap); - } - TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); - tif->tif_flags |= TIFF_DIRTYDIRECT; - return (1); -} - -static int -Fax3VGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - Fax3BaseState* sp = Fax3State(tif); - - switch (tag) { - case TIFFTAG_FAXMODE: - *va_arg(ap, int*) = sp->mode; - break; - case TIFFTAG_FAXFILLFUNC: - if (sp->rw_mode == O_RDONLY) - *va_arg(ap, TIFFFaxFillFunc*) = DecoderState(tif)->fill; - break; - case TIFFTAG_GROUP3OPTIONS: - case TIFFTAG_GROUP4OPTIONS: - *va_arg(ap, uint32*) = sp->groupoptions; - break; - case TIFFTAG_BADFAXLINES: - *va_arg(ap, uint32*) = sp->badfaxlines; - break; - case TIFFTAG_CLEANFAXDATA: - *va_arg(ap, uint16*) = sp->cleanfaxdata; - break; - case TIFFTAG_CONSECUTIVEBADFAXLINES: - *va_arg(ap, uint32*) = sp->badfaxrun; - break; - case TIFFTAG_FAXRECVPARAMS: - *va_arg(ap, uint32*) = sp->recvparams; - break; - case TIFFTAG_FAXSUBADDRESS: - *va_arg(ap, char**) = sp->subaddress; - break; - case TIFFTAG_FAXRECVTIME: - *va_arg(ap, uint32*) = sp->recvtime; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); -} - -static void -Fax3PrintDir(TIFF* tif, FILE* fd, long flags) -{ - Fax3BaseState* sp = Fax3State(tif); - - (void) flags; - if (TIFFFieldSet(tif,FIELD_OPTIONS)) { - const char* sep = " "; - if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) { - fprintf(fd, " Group 4 Options:"); - if (sp->groupoptions & GROUP4OPT_UNCOMPRESSED) - fprintf(fd, "%suncompressed data", sep); - } else { - - fprintf(fd, " Group 3 Options:"); - if (sp->groupoptions & GROUP3OPT_2DENCODING) - fprintf(fd, "%s2-d encoding", sep), sep = "+"; - if (sp->groupoptions & GROUP3OPT_FILLBITS) - fprintf(fd, "%sEOL padding", sep), sep = "+"; - if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED) - fprintf(fd, "%suncompressed data", sep); - } - fprintf(fd, " (%lu = 0x%lx)\n", - (u_long) sp->groupoptions, (u_long) sp->groupoptions); - } - if (TIFFFieldSet(tif,FIELD_CLEANFAXDATA)) { - fprintf(fd, " Fax Data:"); - switch (sp->cleanfaxdata) { - case CLEANFAXDATA_CLEAN: - fprintf(fd, " clean"); - break; - case CLEANFAXDATA_REGENERATED: - fprintf(fd, " receiver regenerated"); - break; - case CLEANFAXDATA_UNCLEAN: - fprintf(fd, " uncorrected errors"); - break; - } - fprintf(fd, " (%u = 0x%x)\n", - sp->cleanfaxdata, sp->cleanfaxdata); - } - if (TIFFFieldSet(tif,FIELD_BADFAXLINES)) - fprintf(fd, " Bad Fax Lines: %lu\n", (u_long) sp->badfaxlines); - if (TIFFFieldSet(tif,FIELD_BADFAXRUN)) - fprintf(fd, " Consecutive Bad Fax Lines: %lu\n", - (u_long) sp->badfaxrun); - if (TIFFFieldSet(tif,FIELD_RECVPARAMS)) - fprintf(fd, " Fax Receive Parameters: %08lx\n", - (u_long) sp->recvparams); - if (TIFFFieldSet(tif,FIELD_SUBADDRESS)) - fprintf(fd, " Fax SubAddress: %s\n", sp->subaddress); - if (TIFFFieldSet(tif,FIELD_RECVTIME)) - fprintf(fd, " Fax Receive Time: %lu secs\n", - (u_long) sp->recvtime); -} - -static int -InitCCITTFax3(TIFF* tif) -{ - Fax3BaseState* sp; - - /* - * Allocate state block so tag methods have storage to record values. - */ - if (tif->tif_mode == O_RDONLY) - tif->tif_data = (tidata_t) - _TIFFmalloc(sizeof (Fax3DecodeState)); - else - tif->tif_data = (tidata_t) - _TIFFmalloc(sizeof (Fax3EncodeState)); - - if (tif->tif_data == NULL) { - TIFFError("TIFFInitCCITTFax3", - "%s: No space for state block", tif->tif_name); - return (0); - } - - sp = Fax3State(tif); - sp->rw_mode = tif->tif_mode; - - /* - * Merge codec-specific tag information and - * override parent get/set field methods. - */ - _TIFFMergeFieldInfo(tif, faxFieldInfo, N(faxFieldInfo)); - sp->vgetparent = tif->tif_vgetfield; - tif->tif_vgetfield = Fax3VGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_vsetfield; - tif->tif_vsetfield = Fax3VSetField; /* hook for codec tags */ - tif->tif_printdir = Fax3PrintDir; /* hook for codec tags */ - sp->groupoptions = 0; - sp->recvparams = 0; - sp->subaddress = NULL; - - if (sp->rw_mode == O_RDONLY) { - tif->tif_flags |= TIFF_NOBITREV;/* decoder does bit reversal */ - DecoderState(tif)->runs = NULL; - TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns); - } else - EncoderState(tif)->refline = NULL; - - /* - * Install codec methods. - */ - tif->tif_setupdecode = Fax3SetupState; - tif->tif_predecode = Fax3PreDecode; - tif->tif_decoderow = Fax3Decode1D; - tif->tif_decodestrip = Fax3Decode1D; - tif->tif_decodetile = Fax3Decode1D; - tif->tif_setupencode = Fax3SetupState; - tif->tif_preencode = Fax3PreEncode; - tif->tif_postencode = Fax3PostEncode; - tif->tif_encoderow = Fax3Encode; - tif->tif_encodestrip = Fax3Encode; - tif->tif_encodetile = Fax3Encode; - tif->tif_close = Fax3Close; - tif->tif_cleanup = Fax3Cleanup; - - return (1); -} - -int -TIFFInitCCITTFax3(TIFF* tif, int scheme) -{ - if (InitCCITTFax3(tif)) { - _TIFFMergeFieldInfo(tif, fax3FieldInfo, N(fax3FieldInfo)); - - /* - * The default format is Class/F-style w/o RTC. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF); - } else - return (0); -} - -/* - * CCITT Group 4 (T.6) Facsimile-compatible - * Compression Scheme Support. - */ - -#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } -/* - * Decode the requested amount of G4-encoded data. - */ -static int -Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - DECLARE_STATE_2D(tif, sp, "Fax4Decode"); - - (void) s; - CACHE_STATE(tif, sp); - while ((long)occ > 0) { - a0 = 0; - RunLength = 0; - pa = thisrun = sp->curruns; - pb = sp->refruns; - b1 = *pb++; -#ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); - fflush(stdout); -#endif - EXPAND2D(EOFG4); - if (EOLcnt) - goto EOFG4; - (*sp->fill)(buf, thisrun, pa, lastx); - SETVAL(0); /* imaginary change for reference */ - SWAP(uint32*, sp->curruns, sp->refruns); - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - if (occ != 0) - tif->tif_row++; - continue; - EOFG4: - NeedBits16( 13, BADG4 ); - BADG4: -#ifdef FAX3_DEBUG - if( GetBits(13) != 0x1001 ) - fputs( "Bad RTC\n", stderr ); -#endif - ClrBits( 13 ); - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (-1); - } - UNCACHE_STATE(tif, sp); - return (1); -} -#undef SWAP - -/* - * Encode the requested amount of data. - */ -static int -Fax4Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - Fax3EncodeState *sp = EncoderState(tif); - - (void) s; - while ((long)cc > 0) { - if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) - return (0); - _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); - bp += sp->b.rowbytes; - cc -= sp->b.rowbytes; - if (cc != 0) - tif->tif_row++; - } - return (1); -} - -static int -Fax4PostEncode(TIFF* tif) -{ - Fax3EncodeState *sp = EncoderState(tif); - - /* terminate strip w/ EOFB */ - Fax3PutBits(tif, EOL, 12); - Fax3PutBits(tif, EOL, 12); - if (sp->bit != 8) - Fax3FlushBits(tif, sp); - return (1); -} - -int -TIFFInitCCITTFax4(TIFF* tif, int scheme) -{ - if (InitCCITTFax3(tif)) { /* reuse G3 support */ - _TIFFMergeFieldInfo(tif, fax4FieldInfo, N(fax4FieldInfo)); - - tif->tif_decoderow = Fax4Decode; - tif->tif_decodestrip = Fax4Decode; - tif->tif_decodetile = Fax4Decode; - tif->tif_encoderow = Fax4Encode; - tif->tif_encodestrip = Fax4Encode; - tif->tif_encodetile = Fax4Encode; - tif->tif_postencode = Fax4PostEncode; - /* - * Suppress RTC at the end of each strip. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC); - } else - return (0); -} - -/* - * CCITT Group 3 1-D Modified Huffman RLE Compression Support. - * (Compression algorithms 2 and 32771) - */ - -/* - * Decode the requested amount of RLE-encoded data. - */ -static int -Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); - int mode = sp->b.mode; - - (void) s; - CACHE_STATE(tif, sp); - thisrun = sp->curruns; - while ((long)occ > 0) { - a0 = 0; - RunLength = 0; - pa = thisrun; -#ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); - fflush(stdout); -#endif - EXPAND1D(EOFRLE); - (*sp->fill)(buf, thisrun, pa, lastx); - /* - * Cleanup at the end of the row. - */ - if (mode & FAXMODE_BYTEALIGN) { - int n = BitsAvail - (BitsAvail &~ 7); - ClrBits(n); - } else if (mode & FAXMODE_WORDALIGN) { - int n = BitsAvail - (BitsAvail &~ 15); - ClrBits(n); - if (BitsAvail == 0 && !isAligned(cp, uint16)) - cp++; - } - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - if (occ != 0) - tif->tif_row++; - continue; - EOFRLE: /* premature EOF */ - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (-1); - } - UNCACHE_STATE(tif, sp); - return (1); -} - -int -TIFFInitCCITTRLE(TIFF* tif, int scheme) -{ - if (InitCCITTFax3(tif)) { /* reuse G3 support */ - tif->tif_decoderow = Fax3DecodeRLE; - tif->tif_decodestrip = Fax3DecodeRLE; - tif->tif_decodetile = Fax3DecodeRLE; - /* - * Suppress RTC+EOLs when encoding and byte-align data. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, - FAXMODE_NORTC|FAXMODE_NOEOL|FAXMODE_BYTEALIGN); - } else - return (0); -} - -int -TIFFInitCCITTRLEW(TIFF* tif, int scheme) -{ - if (InitCCITTFax3(tif)) { /* reuse G3 support */ - tif->tif_decoderow = Fax3DecodeRLE; - tif->tif_decodestrip = Fax3DecodeRLE; - tif->tif_decodetile = Fax3DecodeRLE; - /* - * Suppress RTC+EOLs when encoding and word-align data. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, - FAXMODE_NORTC|FAXMODE_NOEOL|FAXMODE_WORDALIGN); - } else - return (0); -} -#endif /* CCITT_SUPPORT */ diff --git a/freeimage241/Source/LibTIFF/tif_fax3.h b/freeimage241/Source/LibTIFF/tif_fax3.h deleted file mode 100644 index bd942c3..0000000 --- a/freeimage241/Source/LibTIFF/tif_fax3.h +++ /dev/null @@ -1,525 +0,0 @@ -/* $Id: tif_fax3.h,v 1.0 2001-04-13 00:42:32+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1990-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _FAX3_ -#define _FAX3_ -/* - * TIFF Library. - * - * CCITT Group 3 (T.4) and Group 4 (T.6) Decompression Support. - * - * Decoder support is derived, with permission, from the code - * in Frank Cringle's viewfax program; - * Copyright (C) 1990, 1995 Frank D. Cringle. - */ -#include "tiff.h" - -/* - * To override the default routine used to image decoded - * spans one can use the pseduo tag TIFFTAG_FAXFILLFUNC. - * The routine must have the type signature given below; - * for example: - * - * fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) - * - * where buf is place to set the bits, runs is the array of b&w run - * lengths (white then black), erun is the last run in the array, and - * lastx is the width of the row in pixels. Fill routines can assume - * the run array has room for at least lastx runs and can overwrite - * data in the run array as needed (e.g. to append zero runs to bring - * the count up to a nice multiple). - */ -typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); - -/* - * The default run filler; made external for other decoders. - */ -#if defined(__cplusplus) -extern "C" { -#endif -extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); -#if defined(__cplusplus) -} -#endif - - -/* finite state machine codes */ -#define S_Null 0 -#define S_Pass 1 -#define S_Horiz 2 -#define S_V0 3 -#define S_VR 4 -#define S_VL 5 -#define S_Ext 6 -#define S_TermW 7 -#define S_TermB 8 -#define S_MakeUpW 9 -#define S_MakeUpB 10 -#define S_MakeUp 11 -#define S_EOL 12 - -typedef struct { /* state table entry */ - unsigned char State; /* see above */ - unsigned char Width; /* width of code in bits */ - uint32 Param; /* unsigned 32-bit run length in bits */ -} TIFFFaxTabEnt; - -extern const TIFFFaxTabEnt TIFFFaxMainTable[]; -extern const TIFFFaxTabEnt TIFFFaxWhiteTable[]; -extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; - -/* - * The following macros define the majority of the G3/G4 decoder - * algorithm using the state tables defined elsewhere. To build - * a decoder you need some setup code and some glue code. Note - * that you may also need/want to change the way the NeedBits* - * macros get input data if, for example, you know the data to be - * decoded is properly aligned and oriented (doing so before running - * the decoder can be a big performance win). - * - * Consult the decoder in the TIFF library for an idea of what you - * need to define and setup to make use of these definitions. - * - * NB: to enable a debugging version of these macros define FAX3_DEBUG - * before including this file. Trace output goes to stdout. - */ - -#ifndef EndOfData -#define EndOfData() (cp >= ep) -#endif -/* - * Need <=8 or <=16 bits of input data. Unlike viewfax we - * cannot use/assume a word-aligned, properly bit swizzled - * input data set because data may come from an arbitrarily - * aligned, read-only source such as a memory-mapped file. - * Note also that the viewfax decoder does not check for - * running off the end of the input data buffer. This is - * possible for G3-encoded data because it prescans the input - * data to count EOL markers, but can cause problems for G4 - * data. In any event, we don't prescan and must watch for - * running out of data since we can't permit the library to - * scan past the end of the input data buffer. - * - * Finally, note that we must handle remaindered data at the end - * of a strip specially. The coder asks for a fixed number of - * bits when scanning for the next code. This may be more bits - * than are actually present in the data stream. If we appear - * to run out of data but still have some number of valid bits - * remaining then we makeup the requested amount with zeros and - * return successfully. If the returned data is incorrect then - * we should be called again and get a premature EOF error; - * otherwise we should get the right answer. - */ -#ifndef NeedBits8 -#define NeedBits8(n,eoflab) do { \ - if (BitsAvail < (n)) { \ - if (EndOfData()) { \ - if (BitsAvail == 0) /* no valid bits */ \ - goto eoflab; \ - BitsAvail = (n); /* pad with zeros */ \ - } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<>= (n); \ -} while (0) - -#ifdef FAX3_DEBUG -static const char* StateNames[] = { - "Null ", - "Pass ", - "Horiz ", - "V0 ", - "VR ", - "VL ", - "Ext ", - "TermW ", - "TermB ", - "MakeUpW", - "MakeUpB", - "MakeUp ", - "EOL ", -}; -#define DEBUG_SHOW putchar(BitAcc & (1 << t) ? '1' : '0') -#define LOOKUP8(wid,tab,eoflab) do { \ - int t; \ - NeedBits8(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ - StateNames[TabEnt->State], TabEnt->Param); \ - for (t = 0; t < TabEnt->Width; t++) \ - DEBUG_SHOW; \ - putchar('\n'); \ - fflush(stdout); \ - ClrBits(TabEnt->Width); \ -} while (0) -#define LOOKUP16(wid,tab,eoflab) do { \ - int t; \ - NeedBits16(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ - StateNames[TabEnt->State], TabEnt->Param); \ - for (t = 0; t < TabEnt->Width; t++) \ - DEBUG_SHOW; \ - putchar('\n'); \ - fflush(stdout); \ - ClrBits(TabEnt->Width); \ -} while (0) - -#define SETVAL(x) do { \ - *pa++ = RunLength + (x); \ - printf("SETVAL: %d\t%d\n", RunLength + (x), a0); \ - a0 += x; \ - RunLength = 0; \ -} while (0) -#else -#define LOOKUP8(wid,tab,eoflab) do { \ - NeedBits8(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - ClrBits(TabEnt->Width); \ -} while (0) -#define LOOKUP16(wid,tab,eoflab) do { \ - NeedBits16(wid,eoflab); \ - TabEnt = tab + GetBits(wid); \ - ClrBits(TabEnt->Width); \ -} while (0) - -/* - * Append a run to the run length array for the - * current row and reset decoding state. - */ -#define SETVAL(x) do { \ - *pa++ = RunLength + (x); \ - a0 += (x); \ - RunLength = 0; \ -} while (0) -#endif - -/* - * Synchronize input decoding at the start of each - * row by scanning for an EOL (if appropriate) and - * skipping any trash data that might be present - * after a decoding error. Note that the decoding - * done elsewhere that recognizes an EOL only consumes - * 11 consecutive zero bits. This means that if EOLcnt - * is non-zero then we still need to scan for the final flag - * bit that is part of the EOL code. - */ -#define SYNC_EOL(eoflab) do { \ - if (EOLcnt == 0) { \ - for (;;) { \ - NeedBits16(11,eoflab); \ - if (GetBits(11) == 0) \ - break; \ - ClrBits(1); \ - } \ - } \ - for (;;) { \ - NeedBits8(8,eoflab); \ - if (GetBits(8)) \ - break; \ - ClrBits(8); \ - } \ - while (GetBits(1) == 0) \ - ClrBits(1); \ - ClrBits(1); /* EOL bit */ \ - EOLcnt = 0; /* reset EOL counter/flag */ \ -} while (0) - -/* - * Cleanup the array of runs after decoding a row. - * We adjust final runs to insure the user buffer is not - * overwritten and/or undecoded area is white filled. - */ -#define CLEANUP_RUNS() do { \ - if (RunLength) \ - SETVAL(0); \ - if (a0 != lastx) { \ - badlength(a0, lastx); \ - while (a0 > lastx && pa > thisrun) \ - a0 -= *--pa; \ - if (a0 < lastx) { \ - if (a0 < 0) \ - a0 = 0; \ - if ((pa-thisrun)&1) \ - SETVAL(0); \ - SETVAL(lastx - a0); \ - } else if (a0 > lastx) { \ - SETVAL(lastx); \ - SETVAL(0); \ - } \ - } \ -} while (0) - -/* - * Decode a line of 1D-encoded data. - * - * The line expanders are written as macros so that they can be reused - * but still have direct access to the local variables of the "calling" - * function. - * - * Note that unlike the original version we have to explicitly test for - * a0 >= lastx after each black/white run is decoded. This is because - * the original code depended on the input data being zero-padded to - * insure the decoder recognized an EOL before running out of data. - */ -#define EXPAND1D(eoflab) do { \ - for (;;) { \ - for (;;) { \ - LOOKUP16(12, TIFFFaxWhiteTable, eof1d); \ - switch (TabEnt->State) { \ - case S_EOL: \ - EOLcnt = 1; \ - goto done1d; \ - case S_TermW: \ - SETVAL(TabEnt->Param); \ - goto doneWhite1d; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - unexpected("WhiteTable", a0); \ - goto done1d; \ - } \ - } \ - doneWhite1d: \ - if (a0 >= lastx) \ - goto done1d; \ - for (;;) { \ - LOOKUP16(13, TIFFFaxBlackTable, eof1d); \ - switch (TabEnt->State) { \ - case S_EOL: \ - EOLcnt = 1; \ - goto done1d; \ - case S_TermB: \ - SETVAL(TabEnt->Param); \ - goto doneBlack1d; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - unexpected("BlackTable", a0); \ - goto done1d; \ - } \ - } \ - doneBlack1d: \ - if (a0 >= lastx) \ - goto done1d; \ - if( *(pa-1) == 0 && *(pa-2) == 0 ) \ - pa -= 2; \ - } \ -eof1d: \ - prematureEOF(a0); \ - CLEANUP_RUNS(); \ - goto eoflab; \ -done1d: \ - CLEANUP_RUNS(); \ -} while (0) - -/* - * Update the value of b1 using the array - * of runs for the reference line. - */ -#define CHECK_b1 do { \ - if (pa != thisrun) while (b1 <= a0 && b1 < lastx) { \ - b1 += pb[0] + pb[1]; \ - pb += 2; \ - } \ -} while (0) - -/* - * Expand a row of 2D-encoded data. - */ -#define EXPAND2D(eoflab) do { \ - while (a0 < lastx) { \ - LOOKUP8(7, TIFFFaxMainTable, eof2d); \ - switch (TabEnt->State) { \ - case S_Pass: \ - CHECK_b1; \ - b1 += *pb++; \ - RunLength += b1 - a0; \ - a0 = b1; \ - b1 += *pb++; \ - break; \ - case S_Horiz: \ - if ((pa-thisrun)&1) { \ - for (;;) { /* black first */ \ - LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermB: \ - SETVAL(TabEnt->Param); \ - goto doneWhite2da; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badBlack2d; \ - } \ - } \ - doneWhite2da:; \ - for (;;) { /* then white */ \ - LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermW: \ - SETVAL(TabEnt->Param); \ - goto doneBlack2da; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badWhite2d; \ - } \ - } \ - doneBlack2da:; \ - } else { \ - for (;;) { /* white first */ \ - LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermW: \ - SETVAL(TabEnt->Param); \ - goto doneWhite2db; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badWhite2d; \ - } \ - } \ - doneWhite2db:; \ - for (;;) { /* then black */ \ - LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ - switch (TabEnt->State) { \ - case S_TermB: \ - SETVAL(TabEnt->Param); \ - goto doneBlack2db; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badBlack2d; \ - } \ - } \ - doneBlack2db:; \ - } \ - CHECK_b1; \ - break; \ - case S_V0: \ - CHECK_b1; \ - SETVAL(b1 - a0); \ - b1 += *pb++; \ - break; \ - case S_VR: \ - CHECK_b1; \ - SETVAL(b1 - a0 + TabEnt->Param); \ - b1 += *pb++; \ - break; \ - case S_VL: \ - CHECK_b1; \ - SETVAL(b1 - a0 - TabEnt->Param); \ - b1 -= *--pb; \ - break; \ - case S_Ext: \ - *pa++ = lastx - a0; \ - extension(a0); \ - goto eol2d; \ - case S_EOL: \ - *pa++ = lastx - a0; \ - NeedBits8(4,eof2d); \ - if (GetBits(4)) \ - unexpected("EOL", a0); \ - ClrBits(4); \ - EOLcnt = 1; \ - goto eol2d; \ - default: \ - badMain2d: \ - unexpected("MainTable", a0); \ - goto eol2d; \ - badBlack2d: \ - unexpected("BlackTable", a0); \ - goto eol2d; \ - badWhite2d: \ - unexpected("WhiteTable", a0); \ - goto eol2d; \ - eof2d: \ - prematureEOF(a0); \ - CLEANUP_RUNS(); \ - goto eoflab; \ - } \ - } \ - if (RunLength) { \ - if (RunLength + a0 < lastx) { \ - /* expect a final V0 */ \ - NeedBits8(1,eof2d); \ - if (!GetBits(1)) \ - goto badMain2d; \ - ClrBits(1); \ - } \ - SETVAL(0); \ - } \ -eol2d: \ - CLEANUP_RUNS(); \ -} while (0) -#endif /* _FAX3_ */ diff --git a/freeimage241/Source/LibTIFF/tif_flush.c b/freeimage241/Source/LibTIFF/tif_flush.c deleted file mode 100644 index f105607..0000000 --- a/freeimage241/Source/LibTIFF/tif_flush.c +++ /dev/null @@ -1,67 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_flush.c,v 1.0 2001-04-13 00:42:32+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - */ -#include "tiffiop.h" - -int -TIFFFlush(TIFF* tif) -{ - - if (tif->tif_mode != O_RDONLY) { - if (!TIFFFlushData(tif)) - return (0); - if ((tif->tif_flags & TIFF_DIRTYDIRECT) && - !TIFFWriteDirectory(tif)) - return (0); - } - return (1); -} - -/* - * Flush buffered data to the file. - * - * Frank Warmerdam'2000: I modified this to return 1 if TIFF_BEENWRITING - * is not set, so that TIFFFlush() will proceed to write out the directory. - * The documentation says returning 1 is an error indicator, but not having - * been writing isn't exactly a an error. Hopefully this doesn't cause - * problems for other people. - */ -int -TIFFFlushData(TIFF* tif) -{ - if ((tif->tif_flags & TIFF_BEENWRITING) == 0) - return (0); - if (tif->tif_flags & TIFF_POSTENCODE) { - tif->tif_flags &= ~TIFF_POSTENCODE; - if (!(*tif->tif_postencode)(tif)) - return (0); - } - return (TIFFFlushData1(tif)); -} - diff --git a/freeimage241/Source/LibTIFF/tif_getimage.c b/freeimage241/Source/LibTIFF/tif_getimage.c deleted file mode 100644 index 6edaed3..0000000 --- a/freeimage241/Source/LibTIFF/tif_getimage.c +++ /dev/null @@ -1,2291 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_getimage.c,v 1.0 2001-04-13 00:42:33+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1991-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library - * - * Read and return a packed RGBA image. - */ - -#pragma warning (disable : 4550) - -#include "tiffiop.h" -#include -#include - -static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtStripContig(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtStripSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); -static int pickTileContigCase(TIFFRGBAImage*); -static int pickTileSeparateCase(TIFFRGBAImage*); - -static const char photoTag[] = "PhotometricInterpretation"; - -/* - * Check the image to see if TIFFReadRGBAImage can deal with it. - * 1/0 is returned according to whether or not the image can - * be handled. If 0 is returned, emsg contains the reason - * why it is being rejected. - */ -int -TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) -{ - TIFFDirectory* td = &tif->tif_dir; - uint16 photometric; - int colorchannels; - - switch (td->td_bitspersample) { - case 1: case 2: case 4: - case 8: case 16: - break; - default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", - td->td_bitspersample); - return (0); - } - colorchannels = td->td_samplesperpixel - td->td_extrasamples; - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) { - switch (colorchannels) { - case 1: - photometric = PHOTOMETRIC_MINISBLACK; - break; - case 3: - photometric = PHOTOMETRIC_RGB; - break; - default: - sprintf(emsg, "Missing needed %s tag", photoTag); - return (0); - } - } - switch (photometric) { - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_PALETTE: - if (td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_samplesperpixel != 1) { - sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, and %s=%d", - photoTag, photometric, - "Samples/pixel", td->td_samplesperpixel); - return (0); - } - break; - case PHOTOMETRIC_YCBCR: - if (td->td_planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d", - "Planarconfiguration", td->td_planarconfig); - return (0); - } - break; - case PHOTOMETRIC_RGB: - if (colorchannels < 3) { - sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", - "Color channels", colorchannels); - return (0); - } - break; -#ifdef CMYK_SUPPORT - case PHOTOMETRIC_SEPARATED: - if (td->td_inkset != INKSET_CMYK) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", - "InkSet", td->td_inkset); - return (0); - } - if (td->td_samplesperpixel != 4) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", - "Samples/pixel", td->td_samplesperpixel); - return (0); - } - break; -#endif - case PHOTOMETRIC_LOGL: - if (td->td_compression != COMPRESSION_SGILOG) { - sprintf(emsg, "Sorry, LogL data must have %s=%d", - "Compression", COMPRESSION_SGILOG); - return (0); - } - break; - case PHOTOMETRIC_LOGLUV: - if (td->td_compression != COMPRESSION_SGILOG && - td->td_compression != COMPRESSION_SGILOG24) { - sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", - "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); - return (0); - } - if (td->td_planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", - "Planarconfiguration", td->td_planarconfig); - return (0); - } - break; - default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", - photoTag, photometric); - return (0); - } - return (1); -} - -void -TIFFRGBAImageEnd(TIFFRGBAImage* img) -{ - if (img->Map) - _TIFFfree(img->Map), img->Map = NULL; - if (img->BWmap) - _TIFFfree(img->BWmap), img->BWmap = NULL; - if (img->PALmap) - _TIFFfree(img->PALmap), img->PALmap = NULL; - if (img->ycbcr) - _TIFFfree(img->ycbcr), img->ycbcr = NULL; - - if( img->redcmap ) { - _TIFFfree( img->redcmap ); - _TIFFfree( img->greencmap ); - _TIFFfree( img->bluecmap ); - } -} - -static int -isCCITTCompression(TIFF* tif) -{ - uint16 compress; - TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); - return (compress == COMPRESSION_CCITTFAX3 || - compress == COMPRESSION_CCITTFAX4 || - compress == COMPRESSION_CCITTRLE || - compress == COMPRESSION_CCITTRLEW); -} - -int -TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) -{ - uint16* sampleinfo; - uint16 extrasamples; - uint16 planarconfig; - uint16 compress; - int colorchannels; - uint16 *red_orig, *green_orig, *blue_orig; - int n_color; - - /* Initialize to normal values */ - img->row_offset = 0; - img->col_offset = 0; - img->redcmap = NULL; - img->greencmap = NULL; - img->bluecmap = NULL; - - img->tif = tif; - img->stoponerr = stop; - TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample); - switch (img->bitspersample) { - case 1: case 2: case 4: - case 8: case 16: - break; - default: - sprintf(emsg, "Sorry, can not image with %d-bit samples", - img->bitspersample); - return (0); - } - img->alpha = 0; - TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel); - TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, - &extrasamples, &sampleinfo); - if (extrasamples == 1) - switch (sampleinfo[0]) { - case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */ - case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */ - img->alpha = sampleinfo[0]; - break; - } - colorchannels = img->samplesperpixel - extrasamples; - TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress); - TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig); - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) { - switch (colorchannels) { - case 1: - if (isCCITTCompression(tif)) - img->photometric = PHOTOMETRIC_MINISWHITE; - else - img->photometric = PHOTOMETRIC_MINISBLACK; - break; - case 3: - img->photometric = PHOTOMETRIC_RGB; - break; - default: - sprintf(emsg, "Missing needed %s tag", photoTag); - return (0); - } - } - switch (img->photometric) { - case PHOTOMETRIC_PALETTE: - if (!TIFFGetField(tif, TIFFTAG_COLORMAP, - &red_orig, &green_orig, &blue_orig)) { - TIFFError(TIFFFileName(tif), "Missing required \"Colormap\" tag"); - return (0); - } - - /* copy the colormaps so we can modify them */ - n_color = (1L << img->bitspersample); - img->redcmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - img->greencmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - img->bluecmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - if( !img->redcmap || !img->greencmap || !img->bluecmap ) { - TIFFError(TIFFFileName(tif), "Out of memory for colormap copy"); - return (0); - } - - memcpy( img->redcmap, red_orig, n_color * 2 ); - memcpy( img->greencmap, green_orig, n_color * 2 ); - memcpy( img->bluecmap, blue_orig, n_color * 2 ); - - /* fall thru... */ - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - if (planarconfig == PLANARCONFIG_CONTIG && img->samplesperpixel != 1) { - sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, and %s=%d", - photoTag, img->photometric, - "Samples/pixel", img->samplesperpixel); - return (0); - } - break; - case PHOTOMETRIC_YCBCR: - if (planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d", - "Planarconfiguration", planarconfig); - return (0); - } - /* It would probably be nice to have a reality check here. */ - if (compress == COMPRESSION_JPEG && planarconfig == PLANARCONFIG_CONTIG) { - /* can rely on libjpeg to convert to RGB */ - /* XXX should restore current state on exit */ - TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - img->photometric = PHOTOMETRIC_RGB; - } - break; - case PHOTOMETRIC_RGB: - if (colorchannels < 3) { - sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", - "Color channels", colorchannels); - return (0); - } - break; - case PHOTOMETRIC_SEPARATED: { - uint16 inkset; - TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); - if (inkset != INKSET_CMYK) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", - "InkSet", inkset); - return (0); - } - if (img->samplesperpixel != 4) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", - "Samples/pixel", img->samplesperpixel); - return (0); - } - break; - } - case PHOTOMETRIC_LOGL: - if (compress != COMPRESSION_SGILOG) { - sprintf(emsg, "Sorry, LogL data must have %s=%d", - "Compression", COMPRESSION_SGILOG); - return (0); - } - TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); - img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */ - img->bitspersample = 8; - break; - case PHOTOMETRIC_LOGLUV: - if (compress != COMPRESSION_SGILOG && compress != COMPRESSION_SGILOG24) { - sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", - "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); - return (0); - } - if (planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", - "Planarconfiguration", planarconfig); - return (0); - } - TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); - img->photometric = PHOTOMETRIC_RGB; /* little white lie */ - img->bitspersample = 8; - break; - default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", - photoTag, img->photometric); - return (0); - } - img->Map = NULL; - img->BWmap = NULL; - img->PALmap = NULL; - img->ycbcr = NULL; - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height); - TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation); - img->isContig = - !(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1); - if (img->isContig) { - img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig; - (void) pickTileContigCase(img); - } else { - img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate; - (void) pickTileSeparateCase(img); - } - return (1); -} - -int -TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) -{ - if (img->get == NULL) { - TIFFError(TIFFFileName(img->tif), "No \"get\" routine setup"); - return (0); - } - if (img->put.any == NULL) { - TIFFError(TIFFFileName(img->tif), - "No \"put\" routine setupl; probably can not handle image format"); - return (0); - } - return (*img->get)(img, raster, w, h); -} - -/* - * Read the specified image into an ABGR-format raster. - */ -int -TIFFReadRGBAImage(TIFF* tif, - uint32 rwidth, uint32 rheight, uint32* raster, int stop) -{ - char emsg[1024]; - TIFFRGBAImage img; - int ok; - - if (TIFFRGBAImageBegin(&img, tif, stop, emsg)) { - /* XXX verify rwidth and rheight against width and height */ - ok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth, - rwidth, img.height); - TIFFRGBAImageEnd(&img); - } else { - TIFFError(TIFFFileName(tif), emsg); - ok = 0; - } - return (ok); -} - -static uint32 -setorientation(TIFFRGBAImage* img, uint32 h) -{ - TIFF* tif = img->tif; - uint32 y; - - switch (img->orientation) { - case ORIENTATION_BOTRIGHT: - case ORIENTATION_RIGHTBOT: /* XXX */ - case ORIENTATION_LEFTBOT: /* XXX */ - TIFFWarning(TIFFFileName(tif), "using bottom-left orientation"); - img->orientation = ORIENTATION_BOTLEFT; - /* fall thru... */ - case ORIENTATION_BOTLEFT: - y = 0; - break; - case ORIENTATION_TOPRIGHT: - case ORIENTATION_RIGHTTOP: /* XXX */ - case ORIENTATION_LEFTTOP: /* XXX */ - default: - TIFFWarning(TIFFFileName(tif), "using top-left orientation"); - img->orientation = ORIENTATION_TOPLEFT; - /* fall thru... */ - case ORIENTATION_TOPLEFT: - y = h-1; - break; - } - return (y); -} - -/* - * Get an tile-organized image that has - * PlanarConfiguration contiguous if SamplesPerPixel > 1 - * or - * SamplesPerPixel == 1 - */ -static int -gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) -{ - TIFF* tif = img->tif; - tileContigRoutine put = img->put.contig; - uint16 orientation; - uint32 col, row, y; - uint32 tw, th; - u_char* buf; - int32 fromskew, toskew; - uint32 nrow; - - buf = (u_char*) _TIFFmalloc(TIFFTileSize(tif)); - if (buf == 0) { - TIFFError(TIFFFileName(tif), "No space for tile buffer"); - return (0); - } - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); - y = setorientation(img, h); - orientation = img->orientation; - toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? tw+w : tw-w); - for (row = 0; row < h; row += th) { - nrow = (row + th > h ? h - row : th); - for (col = 0; col < w; col += tw) { - if (TIFFReadTile(tif, buf, col+img->col_offset, - row+img->row_offset, 0, 0) < 0 && img->stoponerr) - break; - if (col + tw > w) { - /* - * Tile is clipped horizontally. Calculate - * visible portion and skewing factors. - */ - uint32 npix = w - col; - fromskew = tw - npix; - (*put)(img, raster+y*w+col, col, y, - npix, nrow, fromskew, toskew + fromskew, buf); - } else { - (*put)(img, raster+y*w+col, col, y, tw, nrow, 0, toskew, buf); - } - } - y += (orientation == ORIENTATION_TOPLEFT ? - -(int32) nrow : (int32) nrow); - } - _TIFFfree(buf); - return (1); -} - -/* - * Get an tile-organized image that has - * SamplesPerPixel > 1 - * PlanarConfiguration separated - * We assume that all such images are RGB. - */ -static int -gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) -{ - TIFF* tif = img->tif; - tileSeparateRoutine put = img->put.separate; - uint16 orientation; - uint32 col, row, y; - uint32 tw, th; - u_char* buf; - u_char* r; - u_char* g; - u_char* b; - u_char* a; - tsize_t tilesize; - int32 fromskew, toskew; - int alpha = img->alpha; - uint32 nrow; - - tilesize = TIFFTileSize(tif); - buf = (u_char*) _TIFFmalloc(4*tilesize); - if (buf == 0) { - TIFFError(TIFFFileName(tif), "No space for tile buffer"); - return (0); - } - r = buf; - g = r + tilesize; - b = g + tilesize; - a = b + tilesize; - if (!alpha) - memset(a, 0xff, tilesize); - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); - y = setorientation(img, h); - orientation = img->orientation; - toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? tw+w : tw-w); - for (row = 0; row < h; row += th) { - nrow = (row + th > h ? h - row : th); - for (col = 0; col < w; col += tw) { - if (TIFFReadTile(tif, r, col+img->col_offset, - row+img->row_offset,0,0) < 0 && img->stoponerr) - break; - if (TIFFReadTile(tif, g, col+img->col_offset, - row+img->row_offset,0,1) < 0 && img->stoponerr) - break; - if (TIFFReadTile(tif, b, col+img->col_offset, - row+img->row_offset,0,2) < 0 && img->stoponerr) - break; - if (alpha && TIFFReadTile(tif,a,col+img->col_offset, - row+img->row_offset,0,3) < 0 && img->stoponerr) - break; - if (col + tw > w) { - /* - * Tile is clipped horizontally. Calculate - * visible portion and skewing factors. - */ - uint32 npix = w - col; - fromskew = tw - npix; - (*put)(img, raster+y*w+col, col, y, - npix, nrow, fromskew, toskew + fromskew, r, g, b, a); - } else { - (*put)(img, raster+y*w+col, col, y, - tw, nrow, 0, toskew, r, g, b, a); - } - } - y += (orientation == ORIENTATION_TOPLEFT ? - -(int32) nrow : (int32) nrow); - } - _TIFFfree(buf); - return (1); -} - -/* - * Get a strip-organized image that has - * PlanarConfiguration contiguous if SamplesPerPixel > 1 - * or - * SamplesPerPixel == 1 - */ -static int -gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) -{ - TIFF* tif = img->tif; - tileContigRoutine put = img->put.contig; - uint16 orientation; - uint32 row, y, nrow; - u_char* buf; - uint32 rowsperstrip; - uint32 imagewidth = img->width; - tsize_t scanline; - int32 fromskew, toskew; - - buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif)); - if (buf == 0) { - TIFFError(TIFFFileName(tif), "No space for strip buffer"); - return (0); - } - y = setorientation(img, h); - orientation = img->orientation; - toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? w+w : w-w); - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - scanline = TIFFScanlineSize(tif); - fromskew = (w < imagewidth ? imagewidth - w : 0); - for (row = 0; row < h; row += rowsperstrip) { - nrow = (row + rowsperstrip > h ? h - row : rowsperstrip); - if (TIFFReadEncodedStrip(tif, - TIFFComputeStrip(tif,row+img->row_offset, 0), - buf, nrow*scanline) < 0 - && img->stoponerr) - break; - (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf); - y += (orientation == ORIENTATION_TOPLEFT ? - -(int32) nrow : (int32) nrow); - } - _TIFFfree(buf); - return (1); -} - -/* - * Get a strip-organized image with - * SamplesPerPixel > 1 - * PlanarConfiguration separated - * We assume that all such images are RGB. - */ -static int -gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) -{ - TIFF* tif = img->tif; - tileSeparateRoutine put = img->put.separate; - uint16 orientation; - u_char *buf; - u_char *r, *g, *b, *a; - uint32 row, y, nrow; - tsize_t scanline; - uint32 rowsperstrip, offset_row; - uint32 imagewidth = img->width; - tsize_t stripsize; - int32 fromskew, toskew; - int alpha = img->alpha; - - stripsize = TIFFStripSize(tif); - r = buf = (u_char *)_TIFFmalloc(4*stripsize); - if (buf == 0) { - TIFFError(TIFFFileName(tif), "No space for tile buffer"); - return (0); - } - g = r + stripsize; - b = g + stripsize; - a = b + stripsize; - if (!alpha) - memset(a, 0xff, stripsize); - y = setorientation(img, h); - orientation = img->orientation; - toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? w+w : w-w); - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - scanline = TIFFScanlineSize(tif); - fromskew = (w < imagewidth ? imagewidth - w : 0); - for (row = 0; row < h; row += rowsperstrip) { - nrow = (row + rowsperstrip > h ? h - row : rowsperstrip); - offset_row = row + img->row_offset; - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0), - r, nrow*scanline) < 0 && img->stoponerr) - break; - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), - g, nrow*scanline) < 0 && img->stoponerr) - break; - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), - b, nrow*scanline) < 0 && img->stoponerr) - break; - if (alpha && - (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 3), - a, nrow*scanline) < 0 && img->stoponerr)) - break; - (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, r, g, b, a); - y += (orientation == ORIENTATION_TOPLEFT ? - -(int32) nrow : (int32) nrow); - } - _TIFFfree(buf); - return (1); -} - -/* - * The following routines move decoded data returned - * from the TIFF library into rasters filled with packed - * ABGR pixels (i.e. suitable for passing to lrecwrite.) - * - * The routines have been created according to the most - * important cases and optimized. pickTileContigCase and - * pickTileSeparateCase analyze the parameters and select - * the appropriate "put" routine to use. - */ -#define REPEAT8(op) REPEAT4(op); REPEAT4(op) -#define REPEAT4(op) REPEAT2(op); REPEAT2(op) -#define REPEAT2(op) op; op -#define CASE8(x,op) \ - switch (x) { \ - case 7: op; case 6: op; case 5: op; \ - case 4: op; case 3: op; case 2: op; \ - case 1: op; \ - } -#define CASE4(x,op) switch (x) { case 3: op; case 2: op; case 1: op; } -#define NOP - -#define UNROLL8(w, op1, op2) { \ - uint32 _x; \ - for (_x = w; _x >= 8; _x -= 8) { \ - op1; \ - REPEAT8(op2); \ - } \ - if (_x > 0) { \ - op1; \ - CASE8(_x,op2); \ - } \ -} -#define UNROLL4(w, op1, op2) { \ - uint32 _x; \ - for (_x = w; _x >= 4; _x -= 4) { \ - op1; \ - REPEAT4(op2); \ - } \ - if (_x > 0) { \ - op1; \ - CASE4(_x,op2); \ - } \ -} -#define UNROLL2(w, op1, op2) { \ - uint32 _x; \ - for (_x = w; _x >= 2; _x -= 2) { \ - op1; \ - REPEAT2(op2); \ - } \ - if (_x) { \ - op1; \ - op2; \ - } \ -} - -#define SKEW(r,g,b,skew) { r += skew; g += skew; b += skew; } -#define SKEW4(r,g,b,a,skew) { r += skew; g += skew; b += skew; a+= skew; } - -#define A1 ((uint32)(0xffL<<24)) -#define PACK(r,g,b) \ - ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|A1) -#define PACK4(r,g,b,a) \ - ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|((uint32)(a)<<24)) -#define W2B(v) (((v)>>8)&0xff) -#define PACKW(r,g,b) \ - ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|A1) -#define PACKW4(r,g,b,a) \ - ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|((uint32)W2B(a)<<24)) - -#define DECLAREContigPutFunc(name) \ -static void name(\ - TIFFRGBAImage* img, \ - uint32* cp, \ - uint32 x, uint32 y, \ - uint32 w, uint32 h, \ - int32 fromskew, int32 toskew, \ - u_char* pp \ -) - -/* - * 8-bit palette => colormap/RGB - */ -DECLAREContigPutFunc(put8bitcmaptile) -{ - uint32** PALmap = img->PALmap; - - (void) x; (void) y; - while (h-- > 0) { - UNROLL8(w, NOP, *cp++ = PALmap[*pp++][0]); - cp += toskew; - pp += fromskew; - } -} - -/* - * 4-bit palette => colormap/RGB - */ -DECLAREContigPutFunc(put4bitcmaptile) -{ - uint32** PALmap = img->PALmap; - - (void) x; (void) y; - fromskew /= 2; - while (h-- > 0) { - uint32* bw; - UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 2-bit palette => colormap/RGB - */ -DECLAREContigPutFunc(put2bitcmaptile) -{ - uint32** PALmap = img->PALmap; - - (void) x; (void) y; - fromskew /= 4; - while (h-- > 0) { - uint32* bw; - UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 1-bit palette => colormap/RGB - */ -DECLAREContigPutFunc(put1bitcmaptile) -{ - uint32** PALmap = img->PALmap; - - (void) x; (void) y; - fromskew /= 8; - while (h-- > 0) { - uint32* bw; - UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 8-bit greyscale => colormap/RGB - */ -DECLAREContigPutFunc(putgreytile) -{ - uint32** BWmap = img->BWmap; - - (void) y; - while (h-- > 0) { - for (x = w; x-- > 0;) - *cp++ = BWmap[*pp++][0]; - cp += toskew; - pp += fromskew; - } -} - -/* - * 1-bit bilevel => colormap/RGB - */ -DECLAREContigPutFunc(put1bitbwtile) -{ - uint32** BWmap = img->BWmap; - - (void) x; (void) y; - fromskew /= 8; - while (h-- > 0) { - uint32* bw; - UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 2-bit greyscale => colormap/RGB - */ -DECLAREContigPutFunc(put2bitbwtile) -{ - uint32** BWmap = img->BWmap; - - (void) x; (void) y; - fromskew /= 4; - while (h-- > 0) { - uint32* bw; - UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 4-bit greyscale => colormap/RGB - */ -DECLAREContigPutFunc(put4bitbwtile) -{ - uint32** BWmap = img->BWmap; - - (void) x; (void) y; - fromskew /= 2; - while (h-- > 0) { - uint32* bw; - UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; - } -} - -/* - * 8-bit packed samples, no Map => RGB - */ -DECLAREContigPutFunc(putRGBcontig8bittile) -{ - int samplesperpixel = img->samplesperpixel; - - (void) x; (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - UNROLL8(w, NOP, - *cp++ = PACK(pp[0], pp[1], pp[2]); - pp += samplesperpixel); - cp += toskew; - pp += fromskew; - } -} - -/* - * 8-bit packed samples, w/ Map => RGB - */ -DECLAREContigPutFunc(putRGBcontig8bitMaptile) -{ - TIFFRGBValue* Map = img->Map; - int samplesperpixel = img->samplesperpixel; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - for (x = w; x-- > 0;) { - *cp++ = PACK(Map[pp[0]], Map[pp[1]], Map[pp[2]]); - pp += samplesperpixel; - } - pp += fromskew; - cp += toskew; - } -} - -/* - * 8-bit packed samples => RGBA w/ associated alpha - * (known to have Map == NULL) - */ -DECLAREContigPutFunc(putRGBAAcontig8bittile) -{ - int samplesperpixel = img->samplesperpixel; - - (void) x; (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - UNROLL8(w, NOP, - *cp++ = PACK4(pp[0], pp[1], pp[2], pp[3]); - pp += samplesperpixel); - cp += toskew; - pp += fromskew; - } -} - -/* - * 8-bit packed samples => RGBA w/ unassociated alpha - * (known to have Map == NULL) - */ -DECLAREContigPutFunc(putRGBUAcontig8bittile) -{ - int samplesperpixel = img->samplesperpixel; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - uint32 r, g, b, a; - for (x = w; x-- > 0;) { - a = pp[3]; - r = (pp[0] * a) / 255; - g = (pp[1] * a) / 255; - b = (pp[2] * a) / 255; - *cp++ = PACK4(r,g,b,a); - pp += samplesperpixel; - } - cp += toskew; - pp += fromskew; - } -} - -/* - * 16-bit packed samples => RGB - */ -DECLAREContigPutFunc(putRGBcontig16bittile) -{ - int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - for (x = w; x-- > 0;) { - *cp++ = PACKW(wp[0], wp[1], wp[2]); - wp += samplesperpixel; - } - cp += toskew; - wp += fromskew; - } -} - -/* - * 16-bit packed samples => RGBA w/ associated alpha - * (known to have Map == NULL) - */ -DECLAREContigPutFunc(putRGBAAcontig16bittile) -{ - int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - for (x = w; x-- > 0;) { - *cp++ = PACKW4(wp[0], wp[1], wp[2], wp[3]); - wp += samplesperpixel; - } - cp += toskew; - wp += fromskew; - } -} - -/* - * 16-bit packed samples => RGBA w/ unassociated alpha - * (known to have Map == NULL) - */ -DECLAREContigPutFunc(putRGBUAcontig16bittile) -{ - int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - uint32 r,g,b,a; - /* - * We shift alpha down four bits just in case unsigned - * arithmetic doesn't handle the full range. - * We still have plenty of accuracy, since the output is 8 bits. - * So we have (r * 0xffff) * (a * 0xfff)) = r*a * (0xffff*0xfff) - * Since we want r*a * 0xff for eight bit output, - * we divide by (0xffff * 0xfff) / 0xff == 0x10eff. - */ - for (x = w; x-- > 0;) { - a = wp[3] >> 4; - r = (wp[0] * a) / 0x10eff; - g = (wp[1] * a) / 0x10eff; - b = (wp[2] * a) / 0x10eff; - *cp++ = PACK4(r,g,b,a); - wp += samplesperpixel; - } - cp += toskew; - wp += fromskew; - } -} - -/* - * 8-bit packed CMYK samples w/o Map => RGB - * - * NB: The conversion of CMYK->RGB is *very* crude. - */ -DECLAREContigPutFunc(putRGBcontig8bitCMYKtile) -{ - int samplesperpixel = img->samplesperpixel; - uint16 r, g, b, k; - - (void) x; (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - UNROLL8(w, NOP, - k = 255 - pp[3]; - r = (k*(255-pp[0]))/255; - g = (k*(255-pp[1]))/255; - b = (k*(255-pp[2]))/255; - *cp++ = PACK(r, g, b); - pp += samplesperpixel); - cp += toskew; - pp += fromskew; - } -} - -/* - * 8-bit packed CMYK samples w/Map => RGB - * - * NB: The conversion of CMYK->RGB is *very* crude. - */ -DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile) -{ - int samplesperpixel = img->samplesperpixel; - TIFFRGBValue* Map = img->Map; - uint16 r, g, b, k; - - (void) y; - fromskew *= samplesperpixel; - while (h-- > 0) { - for (x = w; x-- > 0;) { - k = 255 - pp[3]; - r = (k*(255-pp[0]))/255; - g = (k*(255-pp[1]))/255; - b = (k*(255-pp[2]))/255; - *cp++ = PACK(Map[r], Map[g], Map[b]); - pp += samplesperpixel; - } - pp += fromskew; - cp += toskew; - } -} - -#define DECLARESepPutFunc(name) \ -static void name(\ - TIFFRGBAImage* img,\ - uint32* cp,\ - uint32 x, uint32 y, \ - uint32 w, uint32 h,\ - int32 fromskew, int32 toskew,\ - u_char* r, u_char* g, u_char* b, u_char* a\ -) - -/* - * 8-bit unpacked samples => RGB - */ -DECLARESepPutFunc(putRGBseparate8bittile) -{ - (void) img; (void) x; (void) y; (void) a; - while (h-- > 0) { - UNROLL8(w, NOP, *cp++ = PACK(*r++, *g++, *b++)); - SKEW(r, g, b, fromskew); - cp += toskew; - } -} - -/* - * 8-bit unpacked samples => RGB - */ -DECLARESepPutFunc(putRGBseparate8bitMaptile) -{ - TIFFRGBValue* Map = img->Map; - - (void) y; (void) a; - while (h-- > 0) { - for (x = w; x > 0; x--) - *cp++ = PACK(Map[*r++], Map[*g++], Map[*b++]); - SKEW(r, g, b, fromskew); - cp += toskew; - } -} - -/* - * 8-bit unpacked samples => RGBA w/ associated alpha - */ -DECLARESepPutFunc(putRGBAAseparate8bittile) -{ - (void) img; (void) x; (void) y; - while (h-- > 0) { - UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++)); - SKEW4(r, g, b, a, fromskew); - cp += toskew; - } -} - -/* - * 8-bit unpacked samples => RGBA w/ unassociated alpha - */ -DECLARESepPutFunc(putRGBUAseparate8bittile) -{ - (void) img; (void) y; - while (h-- > 0) { - uint32 rv, gv, bv, av; - for (x = w; x-- > 0;) { - av = *a++; - rv = (*r++ * av) / 255; - gv = (*g++ * av) / 255; - bv = (*b++ * av) / 255; - *cp++ = PACK4(rv,gv,bv,av); - } - SKEW4(r, g, b, a, fromskew); - cp += toskew; - } -} - -/* - * 16-bit unpacked samples => RGB - */ -DECLARESepPutFunc(putRGBseparate16bittile) -{ - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - - (void) img; (void) y; (void) a; - while (h-- > 0) { - for (x = 0; x < w; x++) - *cp++ = PACKW(*wr++, *wg++, *wb++); - SKEW(wr, wg, wb, fromskew); - cp += toskew; - } -} - -/* - * 16-bit unpacked samples => RGBA w/ associated alpha - */ -DECLARESepPutFunc(putRGBAAseparate16bittile) -{ - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - uint16 *wa = (uint16*) a; - - (void) img; (void) y; - while (h-- > 0) { - for (x = 0; x < w; x++) - *cp++ = PACKW4(*wr++, *wg++, *wb++, *wa++); - SKEW4(wr, wg, wb, wa, fromskew); - cp += toskew; - } -} - -/* - * 16-bit unpacked samples => RGBA w/ unassociated alpha - */ -DECLARESepPutFunc(putRGBUAseparate16bittile) -{ - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - uint16 *wa = (uint16*) a; - - (void) img; (void) y; - while (h-- > 0) { - uint32 r,g,b,a; - /* - * We shift alpha down four bits just in case unsigned - * arithmetic doesn't handle the full range. - * We still have plenty of accuracy, since the output is 8 bits. - * So we have (r * 0xffff) * (a * 0xfff)) = r*a * (0xffff*0xfff) - * Since we want r*a * 0xff for eight bit output, - * we divide by (0xffff * 0xfff) / 0xff == 0x10eff. - */ - for (x = w; x-- > 0;) { - a = *wa++ >> 4; - r = (*wr++ * a) / 0x10eff; - g = (*wg++ * a) / 0x10eff; - b = (*wb++ * a) / 0x10eff; - *cp++ = PACK4(r,g,b,a); - } - SKEW4(wr, wg, wb, wa, fromskew); - cp += toskew; - } -} - -/* - * YCbCr -> RGB conversion and packing routines. The colorspace - * conversion algorithm comes from the IJG v5a code; see below - * for more information on how it works. - */ - -#define YCbCrtoRGB(dst, yc) { \ - int Y = (yc); \ - dst = PACK( \ - clamptab[Y+Crrtab[Cr]], \ - clamptab[Y + (int)((Cbgtab[Cb]+Crgtab[Cr])>>16)], \ - clamptab[Y+Cbbtab[Cb]]); \ -} -#define YCbCrSetup \ - TIFFYCbCrToRGB* ycbcr = img->ycbcr; \ - int* Crrtab = ycbcr->Cr_r_tab; \ - int* Cbbtab = ycbcr->Cb_b_tab; \ - int32* Crgtab = ycbcr->Cr_g_tab; \ - int32* Cbgtab = ycbcr->Cb_g_tab; \ - TIFFRGBValue* clamptab = ycbcr->clamptab - -/* - * 8-bit packed YCbCr samples => RGB - * This function is generic for different sampling sizes, - * and can handle blocks sizes that aren't multiples of the - * sampling size. However, it is substantially less optimized - * than the specific sampling cases. It is used as a fallback - * for difficult blocks. - */ -#ifdef notdef -static void putcontig8bitYCbCrGenericTile( - TIFFRGBAImage* img, - uint32* cp, - uint32 x, uint32 y, - uint32 w, uint32 h, - int32 fromskew, int32 toskew, - u_char* pp, - int h_group, - int v_group ) - -{ - YCbCrSetup; - - uint32* cp1 = cp+w+toskew; - uint32* cp2 = cp1+w+toskew; - uint32* cp3 = cp2+w+toskew; - int32 incr = 3*w+4*toskew; - int Cb, Cr; - int group_size = v_group * h_group + 2; - - (void) y; - fromskew = (fromskew * group_size) / h_group; - - for( yy = 0; yy < h; yy++ ) - { - u_char *pp_line; - int y_line_group = yy / v_group; - int y_remainder = yy - y_line_group * v_group; - - pp_line = pp + v_line_group * - - - for( xx = 0; xx < w; xx++ ) - { - Cb = pp - } - } - for (; h >= 4; h -= 4) { - x = w>>2; - do { - Cb = pp[16]; - Cr = pp[17]; - - YCbCrtoRGB(cp [0], pp[ 0]); - YCbCrtoRGB(cp [1], pp[ 1]); - YCbCrtoRGB(cp [2], pp[ 2]); - YCbCrtoRGB(cp [3], pp[ 3]); - YCbCrtoRGB(cp1[0], pp[ 4]); - YCbCrtoRGB(cp1[1], pp[ 5]); - YCbCrtoRGB(cp1[2], pp[ 6]); - YCbCrtoRGB(cp1[3], pp[ 7]); - YCbCrtoRGB(cp2[0], pp[ 8]); - YCbCrtoRGB(cp2[1], pp[ 9]); - YCbCrtoRGB(cp2[2], pp[10]); - YCbCrtoRGB(cp2[3], pp[11]); - YCbCrtoRGB(cp3[0], pp[12]); - YCbCrtoRGB(cp3[1], pp[13]); - YCbCrtoRGB(cp3[2], pp[14]); - YCbCrtoRGB(cp3[3], pp[15]); - - cp += 4, cp1 += 4, cp2 += 4, cp3 += 4; - pp += 18; - } while (--x); - cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; - pp += fromskew; - } -} -#endif - -/* - * 8-bit packed YCbCr samples w/ 4,4 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr44tile) -{ - YCbCrSetup; - uint32* cp1 = cp+w+toskew; - uint32* cp2 = cp1+w+toskew; - uint32* cp3 = cp2+w+toskew; - int32 incr = 3*w+4*toskew; - - (void) y; - /* adjust fromskew */ - fromskew = (fromskew * 18) / 4; - if ((h & 3) == 0 && (w & 3) == 0) { - for (; h >= 4; h -= 4) { - x = w>>2; - do { - int Cb = pp[16]; - int Cr = pp[17]; - - YCbCrtoRGB(cp [0], pp[ 0]); - YCbCrtoRGB(cp [1], pp[ 1]); - YCbCrtoRGB(cp [2], pp[ 2]); - YCbCrtoRGB(cp [3], pp[ 3]); - YCbCrtoRGB(cp1[0], pp[ 4]); - YCbCrtoRGB(cp1[1], pp[ 5]); - YCbCrtoRGB(cp1[2], pp[ 6]); - YCbCrtoRGB(cp1[3], pp[ 7]); - YCbCrtoRGB(cp2[0], pp[ 8]); - YCbCrtoRGB(cp2[1], pp[ 9]); - YCbCrtoRGB(cp2[2], pp[10]); - YCbCrtoRGB(cp2[3], pp[11]); - YCbCrtoRGB(cp3[0], pp[12]); - YCbCrtoRGB(cp3[1], pp[13]); - YCbCrtoRGB(cp3[2], pp[14]); - YCbCrtoRGB(cp3[3], pp[15]); - - cp += 4, cp1 += 4, cp2 += 4, cp3 += 4; - pp += 18; - } while (--x); - cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; - pp += fromskew; - } - } else { - while (h > 0) { - for (x = w; x > 0;) { - int Cb = pp[16]; - int Cr = pp[17]; - switch (x) { - default: - switch (h) { - default: YCbCrtoRGB(cp3[3], pp[15]); /* FALLTHROUGH */ - case 3: YCbCrtoRGB(cp2[3], pp[11]); /* FALLTHROUGH */ - case 2: YCbCrtoRGB(cp1[3], pp[ 7]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [3], pp[ 3]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 3: - switch (h) { - default: YCbCrtoRGB(cp3[2], pp[14]); /* FALLTHROUGH */ - case 3: YCbCrtoRGB(cp2[2], pp[10]); /* FALLTHROUGH */ - case 2: YCbCrtoRGB(cp1[2], pp[ 6]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [2], pp[ 2]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 2: - switch (h) { - default: YCbCrtoRGB(cp3[1], pp[13]); /* FALLTHROUGH */ - case 3: YCbCrtoRGB(cp2[1], pp[ 9]); /* FALLTHROUGH */ - case 2: YCbCrtoRGB(cp1[1], pp[ 5]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 1: - switch (h) { - default: YCbCrtoRGB(cp3[0], pp[12]); /* FALLTHROUGH */ - case 3: YCbCrtoRGB(cp2[0], pp[ 8]); /* FALLTHROUGH */ - case 2: YCbCrtoRGB(cp1[0], pp[ 4]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - } - if (x < 4) { - cp += x; cp1 += x; cp2 += x; cp3 += x; - x = 0; - } - else { - cp += 4; cp1 += 4; cp2 += 4; cp3 += 4; - x -= 4; - } - pp += 18; - } - if (h <= 4) - break; - h -= 4; - cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; - pp += fromskew; - } - } -} - -/* - * 8-bit packed YCbCr samples w/ 4,2 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr42tile) -{ - YCbCrSetup; - uint32* cp1 = cp+w+toskew; - int32 incr = 2*toskew+w; - - (void) y; - fromskew = (fromskew * 10) / 4; - if ((h & 3) == 0 && (w & 1) == 0) { - for (; h >= 2; h -= 2) { - x = w>>2; - do { - int Cb = pp[8]; - int Cr = pp[9]; - - YCbCrtoRGB(cp [0], pp[0]); - YCbCrtoRGB(cp [1], pp[1]); - YCbCrtoRGB(cp [2], pp[2]); - YCbCrtoRGB(cp [3], pp[3]); - YCbCrtoRGB(cp1[0], pp[4]); - YCbCrtoRGB(cp1[1], pp[5]); - YCbCrtoRGB(cp1[2], pp[6]); - YCbCrtoRGB(cp1[3], pp[7]); - - cp += 4, cp1 += 4; - pp += 10; - } while (--x); - cp += incr, cp1 += incr; - pp += fromskew; - } - } else { - while (h > 0) { - for (x = w; x > 0;) { - int Cb = pp[8]; - int Cr = pp[9]; - switch (x) { - default: - switch (h) { - default: YCbCrtoRGB(cp1[3], pp[ 7]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [3], pp[ 3]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 3: - switch (h) { - default: YCbCrtoRGB(cp1[2], pp[ 6]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [2], pp[ 2]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 2: - switch (h) { - default: YCbCrtoRGB(cp1[1], pp[ 5]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 1: - switch (h) { - default: YCbCrtoRGB(cp1[0], pp[ 4]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - } - if (x < 4) { - cp += x; cp1 += x; - x = 0; - } - else { - cp += 4; cp1 += 4; - x -= 4; - } - pp += 10; - } - if (h <= 2) - break; - h -= 2; - cp += incr, cp1 += incr; - pp += fromskew; - } - } -} - -/* - * 8-bit packed YCbCr samples w/ 4,1 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr41tile) -{ - YCbCrSetup; - - (void) y; - /* XXX adjust fromskew */ - do { - x = w>>2; - do { - int Cb = pp[4]; - int Cr = pp[5]; - - YCbCrtoRGB(cp [0], pp[0]); - YCbCrtoRGB(cp [1], pp[1]); - YCbCrtoRGB(cp [2], pp[2]); - YCbCrtoRGB(cp [3], pp[3]); - - cp += 4; - pp += 6; - } while (--x); - - if( (w&3) != 0 ) - { - int Cb = pp[4]; - int Cr = pp[5]; - - switch( (w&3) ) { - case 3: YCbCrtoRGB(cp [2], pp[2]); - case 2: YCbCrtoRGB(cp [1], pp[1]); - case 1: YCbCrtoRGB(cp [0], pp[0]); - case 0: break; - } - - cp += (w&3); - pp += 6; - } - - cp += toskew; - pp += fromskew; - } while (--h); - -} - -/* - * 8-bit packed YCbCr samples w/ 2,2 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr22tile) -{ - YCbCrSetup; - uint32* cp1 = cp+w+toskew; - int32 incr = 2*toskew+w; - - (void) y; - fromskew = (fromskew * 6) / 2; - if ((h & 1) == 0 && (w & 1) == 0) { - for (; h >= 2; h -= 2) { - x = w>>1; - do { - int Cb = pp[4]; - int Cr = pp[5]; - - YCbCrtoRGB(cp [0], pp[0]); - YCbCrtoRGB(cp [1], pp[1]); - YCbCrtoRGB(cp1[0], pp[2]); - YCbCrtoRGB(cp1[1], pp[3]); - - cp += 2, cp1 += 2; - pp += 6; - } while (--x); - cp += incr, cp1 += incr; - pp += fromskew; - } - } else { - while (h > 0) { - for (x = w; x > 0;) { - int Cb = pp[4]; - int Cr = pp[5]; - switch (x) { - default: - switch (h) { - default: YCbCrtoRGB(cp1[1], pp[ 3]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 1: - switch (h) { - default: YCbCrtoRGB(cp1[0], pp[ 2]); /* FALLTHROUGH */ - case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - } - if (x < 2) { - cp += x; cp1 += x; - x = 0; - } - else { - cp += 2; cp1 += 2; - x -= 2; - } - pp += 6; - } - if (h <= 2) - break; - h -= 2; - cp += incr, cp1 += incr; - pp += fromskew; - } - } -} - -/* - * 8-bit packed YCbCr samples w/ 2,1 subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr21tile) -{ - YCbCrSetup; - - (void) y; - fromskew = (fromskew * 4) / 2; - do { - x = w>>1; - do { - int Cb = pp[2]; - int Cr = pp[3]; - - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); - - cp += 2; - pp += 4; - } while (--x); - - if( (w&1) != 0 ) - { - int Cb = pp[2]; - int Cr = pp[3]; - - YCbCrtoRGB(cp [0], pp[0]); - - cp += 1; - pp += 4; - } - - cp += toskew; - pp += fromskew; - } while (--h); -} - -/* - * 8-bit packed YCbCr samples w/ no subsampling => RGB - */ -DECLAREContigPutFunc(putcontig8bitYCbCr11tile) -{ - YCbCrSetup; - - (void) y; - fromskew *= 3; - do { - x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */ - do { - int Cb = pp[1]; - int Cr = pp[2]; - - YCbCrtoRGB(*cp++, pp[0]); - - pp += 3; - } while (--x); - cp += toskew; - pp += fromskew; - } while (--h); -} -#undef YCbCrSetup -#undef YCbCrtoRGB - -#define LumaRed coeffs[0] -#define LumaGreen coeffs[1] -#define LumaBlue coeffs[2] -#define SHIFT 16 -#define FIX(x) ((int32)((x) * (1L<RGB conversion tables. The conversion - * is done according to the 6.0 spec: - * - * R = Y + Cr*(2 - 2*LumaRed) - * B = Y + Cb*(2 - 2*LumaBlue) - * G = Y - * - LumaBlue*Cb*(2-2*LumaBlue)/LumaGreen - * - LumaRed*Cr*(2-2*LumaRed)/LumaGreen - * - * To avoid floating point arithmetic the fractional constants that - * come out of the equations are represented as fixed point values - * in the range 0...2^16. We also eliminate multiplications by - * pre-calculating possible values indexed by Cb and Cr (this code - * assumes conversion is being done for 8-bit samples). - */ -static void -TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, TIFF* tif) -{ - TIFFRGBValue* clamptab; - float* coeffs; - int i; - - clamptab = (TIFFRGBValue*)( - (tidata_t) ycbcr+TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long))); - _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ - ycbcr->clamptab = (clamptab += 256); - for (i = 0; i < 256; i++) - clamptab[i] = i; - _TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */ - TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, &coeffs); - _TIFFmemcpy(ycbcr->coeffs, coeffs, 3*sizeof (float)); - { float f1 = 2-2*LumaRed; int32 D1 = FIX(f1); - float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(f2); - float f3 = 2-2*LumaBlue; int32 D3 = FIX(f3); - float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(f4); - int x; - - ycbcr->Cr_r_tab = (int*) (clamptab + 3*256); - ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256; - ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256); - ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256; - /* - * i is the actual input pixel value in the range 0..255 - * Cb and Cr values are in the range -128..127 (actually - * they are in a range defined by the ReferenceBlackWhite - * tag) so there is some range shifting to do here when - * constructing tables indexed by the raw pixel data. - * - * XXX handle ReferenceBlackWhite correctly to calculate - * Cb/Cr values to use in constructing the tables. - */ - for (i = 0, x = -128; i < 256; i++, x++) { - ycbcr->Cr_r_tab[i] = (int)((D1*x + ONE_HALF)>>SHIFT); - ycbcr->Cb_b_tab[i] = (int)((D3*x + ONE_HALF)>>SHIFT); - ycbcr->Cr_g_tab[i] = D2*x; - ycbcr->Cb_g_tab[i] = D4*x + ONE_HALF; - } - } -} -#undef SHIFT -#undef ONE_HALF -#undef FIX -#undef LumaBlue -#undef LumaGreen -#undef LumaRed - -static tileContigRoutine -initYCbCrConversion(TIFFRGBAImage* img) -{ - uint16 hs, vs; - - if (img->ycbcr == NULL) { - img->ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc( - TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long)) - + 4*256*sizeof (TIFFRGBValue) - + 2*256*sizeof (int) - + 2*256*sizeof (int32) - ); - if (img->ycbcr == NULL) { - TIFFError(TIFFFileName(img->tif), - "No space for YCbCr->RGB conversion state"); - return (NULL); - } - TIFFYCbCrToRGBInit(img->ycbcr, img->tif); - } else { - float* coeffs; - - TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &coeffs); - if (_TIFFmemcmp(coeffs, img->ycbcr->coeffs, 3*sizeof (float)) != 0) - TIFFYCbCrToRGBInit(img->ycbcr, img->tif); - } - /* - * The 6.0 spec says that subsampling must be - * one of 1, 2, or 4, and that vertical subsampling - * must always be <= horizontal subsampling; so - * there are only a few possibilities and we just - * enumerate the cases. - */ - TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); - switch ((hs<<4)|vs) { - case 0x44: return (putcontig8bitYCbCr44tile); - case 0x42: return (putcontig8bitYCbCr42tile); - case 0x41: return (putcontig8bitYCbCr41tile); - case 0x22: return (putcontig8bitYCbCr22tile); - case 0x21: return (putcontig8bitYCbCr21tile); - case 0x11: return (putcontig8bitYCbCr11tile); - } - return (NULL); -} - -/* - * Greyscale images with less than 8 bits/sample are handled - * with a table to avoid lots of shifts and masks. The table - * is setup so that put*bwtile (below) can retrieve 8/bitspersample - * pixel values simply by indexing into the table with one - * number. - */ -static int -makebwmap(TIFFRGBAImage* img) -{ - TIFFRGBValue* Map = img->Map; - int bitspersample = img->bitspersample; - int nsamples = 8 / bitspersample; - int i; - uint32* p; - - img->BWmap = (uint32**) _TIFFmalloc( - 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); - if (img->BWmap == NULL) { - TIFFError(TIFFFileName(img->tif), "No space for B&W mapping table"); - return (0); - } - p = (uint32*)(img->BWmap + 256); - for (i = 0; i < 256; i++) { - TIFFRGBValue c; - img->BWmap[i] = p; - switch (bitspersample) { -#define GREY(x) c = Map[x]; *p++ = PACK(c,c,c); - case 1: - GREY(i>>7); - GREY((i>>6)&1); - GREY((i>>5)&1); - GREY((i>>4)&1); - GREY((i>>3)&1); - GREY((i>>2)&1); - GREY((i>>1)&1); - GREY(i&1); - break; - case 2: - GREY(i>>6); - GREY((i>>4)&3); - GREY((i>>2)&3); - GREY(i&3); - break; - case 4: - GREY(i>>4); - GREY(i&0xf); - break; - case 8: - GREY(i); - break; - } -#undef GREY - } - return (1); -} - -/* - * Construct a mapping table to convert from the range - * of the data samples to [0,255] --for display. This - * process also handles inverting B&W images when needed. - */ -static int -setupMap(TIFFRGBAImage* img) -{ - int32 x, range; - - range = (int32)((1L<bitspersample)-1); - img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue)); - if (img->Map == NULL) { - TIFFError(TIFFFileName(img->tif), - "No space for photometric conversion table"); - return (0); - } - if (img->photometric == PHOTOMETRIC_MINISWHITE) { - for (x = 0; x <= range; x++) - img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range); - } else { - for (x = 0; x <= range; x++) - img->Map[x] = (TIFFRGBValue) ((x * 255) / range); - } - if (img->bitspersample <= 8 && - (img->photometric == PHOTOMETRIC_MINISBLACK || - img->photometric == PHOTOMETRIC_MINISWHITE)) { - /* - * Use photometric mapping table to construct - * unpacking tables for samples <= 8 bits. - */ - if (!makebwmap(img)) - return (0); - /* no longer need Map, free it */ - _TIFFfree(img->Map), img->Map = NULL; - } - return (1); -} - -static int -checkcmap(TIFFRGBAImage* img) -{ - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; - long n = 1L<bitspersample; - - while (n-- > 0) - if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) - return (16); - return (8); -} - -static void -cvtcmap(TIFFRGBAImage* img) -{ - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; - long i; - - for (i = (1L<bitspersample)-1; i >= 0; i--) { -#define CVT(x) ((uint16)((x)>>8)) - r[i] = CVT(r[i]); - g[i] = CVT(g[i]); - b[i] = CVT(b[i]); -#undef CVT - } -} - -/* - * Palette images with <= 8 bits/sample are handled - * with a table to avoid lots of shifts and masks. The table - * is setup so that put*cmaptile (below) can retrieve 8/bitspersample - * pixel values simply by indexing into the table with one - * number. - */ -static int -makecmap(TIFFRGBAImage* img) -{ - int bitspersample = img->bitspersample; - int nsamples = 8 / bitspersample; - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; - uint32 *p; - int i; - - img->PALmap = (uint32**) _TIFFmalloc( - 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); - if (img->PALmap == NULL) { - TIFFError(TIFFFileName(img->tif), "No space for Palette mapping table"); - return (0); - } - p = (uint32*)(img->PALmap + 256); - for (i = 0; i < 256; i++) { - TIFFRGBValue c; - img->PALmap[i] = p; -#define CMAP(x) c = x; *p++ = PACK(r[c]&0xff, g[c]&0xff, b[c]&0xff); - switch (bitspersample) { - case 1: - CMAP(i>>7); - CMAP((i>>6)&1); - CMAP((i>>5)&1); - CMAP((i>>4)&1); - CMAP((i>>3)&1); - CMAP((i>>2)&1); - CMAP((i>>1)&1); - CMAP(i&1); - break; - case 2: - CMAP(i>>6); - CMAP((i>>4)&3); - CMAP((i>>2)&3); - CMAP(i&3); - break; - case 4: - CMAP(i>>4); - CMAP(i&0xf); - break; - case 8: - CMAP(i); - break; - } -#undef CMAP - } - return (1); -} - -/* - * Construct any mapping table used - * by the associated put routine. - */ -static int -buildMap(TIFFRGBAImage* img) -{ - switch (img->photometric) { - case PHOTOMETRIC_RGB: - case PHOTOMETRIC_YCBCR: - case PHOTOMETRIC_SEPARATED: - if (img->bitspersample == 8) - break; - /* fall thru... */ - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_MINISWHITE: - if (!setupMap(img)) - return (0); - break; - case PHOTOMETRIC_PALETTE: - /* - * Convert 16-bit colormap to 8-bit (unless it looks - * like an old-style 8-bit colormap). - */ - if (checkcmap(img) == 16) - cvtcmap(img); - else - TIFFWarning(TIFFFileName(img->tif), "Assuming 8-bit colormap"); - /* - * Use mapping table and colormap to construct - * unpacking tables for samples < 8 bits. - */ - if (img->bitspersample <= 8 && !makecmap(img)) - return (0); - break; - } - return (1); -} - -/* - * Select the appropriate conversion routine for packed data. - */ -static int -pickTileContigCase(TIFFRGBAImage* img) -{ - tileContigRoutine put = 0; - - if (buildMap(img)) { - switch (img->photometric) { - case PHOTOMETRIC_RGB: - switch (img->bitspersample) { - case 8: - if (!img->Map) { - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - put = putRGBAAcontig8bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - put = putRGBUAcontig8bittile; - else - put = putRGBcontig8bittile; - } else - put = putRGBcontig8bitMaptile; - break; - case 16: - put = putRGBcontig16bittile; - if (!img->Map) { - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - put = putRGBAAcontig16bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - put = putRGBUAcontig16bittile; - } - break; - } - break; - case PHOTOMETRIC_SEPARATED: - if (img->bitspersample == 8) { - if (!img->Map) - put = putRGBcontig8bitCMYKtile; - else - put = putRGBcontig8bitCMYKMaptile; - } - break; - case PHOTOMETRIC_PALETTE: - switch (img->bitspersample) { - case 8: put = put8bitcmaptile; break; - case 4: put = put4bitcmaptile; break; - case 2: put = put2bitcmaptile; break; - case 1: put = put1bitcmaptile; break; - } - break; - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - switch (img->bitspersample) { - case 8: put = putgreytile; break; - case 4: put = put4bitbwtile; break; - case 2: put = put2bitbwtile; break; - case 1: put = put1bitbwtile; break; - } - break; - case PHOTOMETRIC_YCBCR: - if (img->bitspersample == 8) - put = initYCbCrConversion(img); - break; - } - } - return ((img->put.contig = put) != 0); -} - -/* - * Select the appropriate conversion routine for unpacked data. - * - * NB: we assume that unpacked single channel data is directed - * to the "packed routines. - */ -static int -pickTileSeparateCase(TIFFRGBAImage* img) -{ - tileSeparateRoutine put = 0; - - if (buildMap(img)) { - switch (img->photometric) { - case PHOTOMETRIC_RGB: - switch (img->bitspersample) { - case 8: - if (!img->Map) { - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - put = putRGBAAseparate8bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - put = putRGBUAseparate8bittile; - else - put = putRGBseparate8bittile; - } else - put = putRGBseparate8bitMaptile; - break; - case 16: - put = putRGBseparate16bittile; - if (!img->Map) { - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - put = putRGBAAseparate16bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - put = putRGBUAseparate16bittile; - } - break; - } - break; - } - } - return ((img->put.separate = put) != 0); -} - -/* - * Read a whole strip off data from the file, and convert to RGBA form. - * If this is the last strip, then it will only contain the portion of - * the strip that is actually within the image space. The result is - * organized in bottom to top form. - */ - - -int -TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster ) - -{ - char emsg[1024]; - TIFFRGBAImage img; - int ok; - uint32 rowsperstrip, rows_to_read; - - if( TIFFIsTiled( tif ) ) - { - TIFFError(TIFFFileName(tif), - "Can't use TIFFReadRGBAStrip() with tiled file."); - return (0); - } - - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - if( (row % rowsperstrip) != 0 ) - { - TIFFError(TIFFFileName(tif), - "Row passed to TIFFReadRGBAStrip() must be first in a strip."); - return (0); - } - - if (TIFFRGBAImageBegin(&img, tif, 0, emsg)) { - - img.row_offset = row; - img.col_offset = 0; - - if( row + rowsperstrip > img.height ) - rows_to_read = img.height - row; - else - rows_to_read = rowsperstrip; - - ok = TIFFRGBAImageGet(&img, raster, img.width, rows_to_read ); - - TIFFRGBAImageEnd(&img); - } else { - TIFFError(TIFFFileName(tif), emsg); - ok = 0; - } - - return (ok); -} - -/* - * Read a whole tile off data from the file, and convert to RGBA form. - * The returned RGBA data is organized from bottom to top of tile, - * and may include zeroed areas if the tile extends off the image. - */ - -int -TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) - -{ - char emsg[1024]; - TIFFRGBAImage img; - int ok; - uint32 tile_xsize, tile_ysize; - uint32 read_xsize, read_ysize; - uint32 i_row; - - /* - * Verify that our request is legal - on a tile file, and on a - * tile boundary. - */ - - if( !TIFFIsTiled( tif ) ) - { - TIFFError(TIFFFileName(tif), - "Can't use TIFFReadRGBATile() with stripped file."); - return (0); - } - - TIFFGetFieldDefaulted(tif, TIFFTAG_TILEWIDTH, &tile_xsize); - TIFFGetFieldDefaulted(tif, TIFFTAG_TILELENGTH, &tile_ysize); - if( (col % tile_xsize) != 0 || (row % tile_ysize) != 0 ) - { - TIFFError(TIFFFileName(tif), - "Row/col passed to TIFFReadRGBATile() must be top" - "left corner of a tile."); - return (0); - } - - /* - * Setup the RGBA reader. - */ - - if ( !TIFFRGBAImageBegin(&img, tif, 0, emsg)) { - TIFFError(TIFFFileName(tif), emsg); - return( 0 ); - } - - /* - * The TIFFRGBAImageGet() function doesn't allow us to get off the - * edge of the image, even to fill an otherwise valid tile. So we - * figure out how much we can read, and fix up the tile buffer to - * a full tile configuration afterwards. - */ - - if( row + tile_ysize > img.height ) - read_ysize = img.height - row; - else - read_ysize = tile_ysize; - - if( col + tile_xsize > img.width ) - read_xsize = img.width - col; - else - read_xsize = tile_xsize; - - /* - * Read the chunk of imagery. - */ - - img.row_offset = row; - img.col_offset = col; - - ok = TIFFRGBAImageGet(&img, raster, read_xsize, read_ysize ); - - TIFFRGBAImageEnd(&img); - - /* - * If our read was incomplete we will need to fix up the tile by - * shifting the data around as if a full tile of data is being returned. - * - * This is all the more complicated because the image is organized in - * bottom to top format. - */ - - if( read_xsize == tile_xsize && read_ysize == tile_ysize ) - return( ok ); - - for( i_row = 0; i_row < read_ysize; i_row++ ) - { - _TIFFmemcpy( raster + (tile_ysize - i_row - 1) * tile_xsize, - raster + (read_ysize - i_row - 1) * read_xsize, - read_xsize * sizeof(uint32) ); - _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize+read_xsize, - 0, sizeof(uint32) * (tile_xsize - read_xsize) ); - } - - for( i_row = read_ysize; i_row < tile_ysize; i_row++ ) - { - _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize, - 0, sizeof(uint32) * tile_xsize ); - } - - return (ok); -} diff --git a/freeimage241/Source/LibTIFF/tif_jpeg.c b/freeimage241/Source/LibTIFF/tif_jpeg.c deleted file mode 100644 index 912f278..0000000 --- a/freeimage241/Source/LibTIFF/tif_jpeg.c +++ /dev/null @@ -1,1485 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_jpeg.c,v 1.0 2001-04-13 00:42:33+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1994-1997 Sam Leffler - * Copyright (c) 1994-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef JPEG_SUPPORT -/* - * TIFF Library - * - * JPEG Compression support per TIFF Technical Note #2 - * (*not* per the original TIFF 6.0 spec). - * - * This file is simply an interface to the libjpeg library written by - * the Independent JPEG Group. You need release 5 or later of the IJG - * code, which you can find on the Internet at ftp.uu.net:/graphics/jpeg/. - * - * Contributed by Tom Lane . - */ -#include -#include -#include - -/* We undefine FAR to avoid conflict with JPEG definition */ - -#ifdef FAR -#undef FAR -#endif - -#include "jpeglib.h" -#include "jerror.h" - -/* - * On some machines it may be worthwhile to use _setjmp or sigsetjmp - * in place of plain setjmp. These macros will make it easier. - */ -#define SETJMP(jbuf) setjmp(jbuf) -#define LONGJMP(jbuf,code) longjmp(jbuf,code) -#define JMP_BUF jmp_buf - -typedef struct jpeg_destination_mgr jpeg_destination_mgr; -typedef struct jpeg_source_mgr jpeg_source_mgr; -typedef struct jpeg_error_mgr jpeg_error_mgr; - -/* - * State block for each open TIFF file using - * libjpeg to do JPEG compression/decompression. - * - * libjpeg's visible state is either a jpeg_compress_struct - * or jpeg_decompress_struct depending on which way we - * are going. comm can be used to refer to the fields - * which are common to both. - * - * NB: cinfo is required to be the first member of JPEGState, - * so we can safely cast JPEGState* -> jpeg_xxx_struct* - * and vice versa! - */ -typedef struct { - union { - struct jpeg_compress_struct c; - struct jpeg_decompress_struct d; - struct jpeg_common_struct comm; - } cinfo; /* NB: must be first */ - jpeg_error_mgr err; /* libjpeg error manager */ - JMP_BUF exit_jmpbuf; /* for catching libjpeg failures */ - /* - * The following two members could be a union, but - * they're small enough that it's not worth the effort. - */ - jpeg_destination_mgr dest; /* data dest for compression */ - jpeg_source_mgr src; /* data source for decompression */ - /* private state */ - TIFF* tif; /* back link needed by some code */ - uint16 photometric; /* copy of PhotometricInterpretation */ - uint16 h_sampling; /* luminance sampling factors */ - uint16 v_sampling; - tsize_t bytesperline; /* decompressed bytes per scanline */ - /* pointers to intermediate buffers when processing downsampled data */ - JSAMPARRAY ds_buffer[MAX_COMPONENTS]; - int scancount; /* number of "scanlines" accumulated */ - int samplesperclump; - - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - TIFFStripMethod defsparent; /* super-class method */ - TIFFTileMethod deftparent; /* super-class method */ - /* pseudo-tag fields */ - void* jpegtables; /* JPEGTables tag value, or NULL */ - uint32 jpegtables_length; /* number of bytes in same */ - int jpegquality; /* Compression quality level */ - int jpegcolormode; /* Auto RGB<=>YCbCr convert? */ - int jpegtablesmode; /* What to put in JPEGTables */ -} JPEGState; - -#define JState(tif) ((JPEGState*)(tif)->tif_data) - -static int JPEGDecode(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGDecodeRaw(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGEncodeRaw(TIFF*, tidata_t, tsize_t, tsample_t); - -#define FIELD_JPEGTABLES (FIELD_CODEC+0) - -static const TIFFFieldInfo jpegFieldInfo[] = { - { TIFFTAG_JPEGTABLES, -1,-1, TIFF_UNDEFINED, FIELD_JPEGTABLES, - FALSE, TRUE, "JPEGTables" }, - { TIFFTAG_JPEGQUALITY, 0, 0, TIFF_ANY, FIELD_PSEUDO, - TRUE, FALSE, "" }, - { TIFFTAG_JPEGCOLORMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "" }, - { TIFFTAG_JPEGTABLESMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "" }, -}; -#define N(a) (sizeof (a) / sizeof (a[0])) - -/* - * libjpeg interface layer. - * - * We use setjmp/longjmp to return control to libtiff - * when a fatal error is encountered within the JPEG - * library. We also direct libjpeg error and warning - * messages through the appropriate libtiff handlers. - */ - -/* - * Error handling routines (these replace corresponding - * IJG routines from jerror.c). These are used for both - * compression and decompression. - */ -static void -TIFFjpeg_error_exit(j_common_ptr cinfo) -{ - JPEGState *sp = (JPEGState *) cinfo; /* NB: cinfo assumed first */ - char buffer[JMSG_LENGTH_MAX]; - - (*cinfo->err->format_message) (cinfo, buffer); - TIFFError("JPEGLib", buffer); /* display the error message */ - jpeg_abort(cinfo); /* clean up libjpeg state */ - LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */ -} - -/* - * This routine is invoked only for warning messages, - * since error_exit does its own thing and trace_level - * is never set > 0. - */ -static void -TIFFjpeg_output_message(j_common_ptr cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - - (*cinfo->err->format_message) (cinfo, buffer); - TIFFWarning("JPEGLib", buffer); -} - -/* - * Interface routines. This layer of routines exists - * primarily to limit side-effects from using setjmp. - * Also, normal/error returns are converted into return - * values per libtiff practice. - */ -#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op)) -#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op),1)) - -static int -TIFFjpeg_create_compress(JPEGState* sp) -{ - /* initialize JPEG error handling */ - sp->cinfo.c.err = jpeg_std_error(&sp->err); - sp->err.error_exit = TIFFjpeg_error_exit; - sp->err.output_message = TIFFjpeg_output_message; - - return CALLVJPEG(sp, jpeg_create_compress(&sp->cinfo.c)); -} - -static int -TIFFjpeg_create_decompress(JPEGState* sp) -{ - /* initialize JPEG error handling */ - sp->cinfo.d.err = jpeg_std_error(&sp->err); - sp->err.error_exit = TIFFjpeg_error_exit; - sp->err.output_message = TIFFjpeg_output_message; - - return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d)); -} - -static int -TIFFjpeg_set_defaults(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_set_defaults(&sp->cinfo.c)); -} - -static int -TIFFjpeg_set_colorspace(JPEGState* sp, J_COLOR_SPACE colorspace) -{ - return CALLVJPEG(sp, jpeg_set_colorspace(&sp->cinfo.c, colorspace)); -} - -static int -TIFFjpeg_set_quality(JPEGState* sp, int quality, boolean force_baseline) -{ - return CALLVJPEG(sp, - jpeg_set_quality(&sp->cinfo.c, quality, force_baseline)); -} - -static int -TIFFjpeg_suppress_tables(JPEGState* sp, boolean suppress) -{ - return CALLVJPEG(sp, jpeg_suppress_tables(&sp->cinfo.c, suppress)); -} - -static int -TIFFjpeg_start_compress(JPEGState* sp, boolean write_all_tables) -{ - return CALLVJPEG(sp, - jpeg_start_compress(&sp->cinfo.c, write_all_tables)); -} - -static int -TIFFjpeg_write_scanlines(JPEGState* sp, JSAMPARRAY scanlines, int num_lines) -{ - return CALLJPEG(sp, -1, (int) jpeg_write_scanlines(&sp->cinfo.c, - scanlines, (JDIMENSION) num_lines)); -} - -static int -TIFFjpeg_write_raw_data(JPEGState* sp, JSAMPIMAGE data, int num_lines) -{ - return CALLJPEG(sp, -1, (int) jpeg_write_raw_data(&sp->cinfo.c, - data, (JDIMENSION) num_lines)); -} - -static int -TIFFjpeg_finish_compress(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_finish_compress(&sp->cinfo.c)); -} - -static int -TIFFjpeg_write_tables(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_write_tables(&sp->cinfo.c)); -} - -static int -TIFFjpeg_read_header(JPEGState* sp, boolean require_image) -{ - return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image)); -} - -static int -TIFFjpeg_start_decompress(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_start_decompress(&sp->cinfo.d)); -} - -static int -TIFFjpeg_read_scanlines(JPEGState* sp, JSAMPARRAY scanlines, int max_lines) -{ - return CALLJPEG(sp, -1, (int) jpeg_read_scanlines(&sp->cinfo.d, - scanlines, (JDIMENSION) max_lines)); -} - -static int -TIFFjpeg_read_raw_data(JPEGState* sp, JSAMPIMAGE data, int max_lines) -{ - return CALLJPEG(sp, -1, (int) jpeg_read_raw_data(&sp->cinfo.d, - data, (JDIMENSION) max_lines)); -} - -static int -TIFFjpeg_finish_decompress(JPEGState* sp) -{ - return CALLJPEG(sp, -1, (int) jpeg_finish_decompress(&sp->cinfo.d)); -} - -static int -TIFFjpeg_abort(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm)); -} - -static int -TIFFjpeg_destroy(JPEGState* sp) -{ - return CALLVJPEG(sp, jpeg_destroy(&sp->cinfo.comm)); -} - -static JSAMPARRAY -TIFFjpeg_alloc_sarray(JPEGState* sp, int pool_id, - JDIMENSION samplesperrow, JDIMENSION numrows) -{ - return CALLJPEG(sp, (JSAMPARRAY) NULL, - (*sp->cinfo.comm.mem->alloc_sarray) - (&sp->cinfo.comm, pool_id, samplesperrow, numrows)); -} - -/* - * JPEG library destination data manager. - * These routines direct compressed data from libjpeg into the - * libtiff output buffer. - */ - -static void -std_init_destination(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - TIFF* tif = sp->tif; - - sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; - sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; -} - -static boolean -std_empty_output_buffer(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - TIFF* tif = sp->tif; - - /* the entire buffer has been filled */ - tif->tif_rawcc = tif->tif_rawdatasize; - TIFFFlushData1(tif); - sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; - sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; - - return (TRUE); -} - -static void -std_term_destination(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - TIFF* tif = sp->tif; - - tif->tif_rawcp = (tidata_t) sp->dest.next_output_byte; - tif->tif_rawcc = - tif->tif_rawdatasize - (tsize_t) sp->dest.free_in_buffer; - /* NB: libtiff does the final buffer flush */ -} - -static void -TIFFjpeg_data_dest(JPEGState* sp, TIFF* tif) -{ - (void) tif; - sp->cinfo.c.dest = &sp->dest; - sp->dest.init_destination = std_init_destination; - sp->dest.empty_output_buffer = std_empty_output_buffer; - sp->dest.term_destination = std_term_destination; -} - -/* - * Alternate destination manager for outputting to JPEGTables field. - */ - -static void -tables_init_destination(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - - /* while building, jpegtables_length is allocated buffer size */ - sp->dest.next_output_byte = (JOCTET*) sp->jpegtables; - sp->dest.free_in_buffer = (size_t) sp->jpegtables_length; -} - -static boolean -tables_empty_output_buffer(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - void* newbuf; - - /* the entire buffer has been filled; enlarge it by 1000 bytes */ - newbuf = _TIFFrealloc((tdata_t) sp->jpegtables, - (tsize_t) (sp->jpegtables_length + 1000)); - if (newbuf == NULL) - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 100); - sp->dest.next_output_byte = (JOCTET*) newbuf + sp->jpegtables_length; - sp->dest.free_in_buffer = (size_t) 1000; - sp->jpegtables = newbuf; - sp->jpegtables_length += 1000; - return (TRUE); -} - -static void -tables_term_destination(j_compress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - - /* set tables length to number of bytes actually emitted */ - sp->jpegtables_length -= sp->dest.free_in_buffer; -} - -static int -TIFFjpeg_tables_dest(JPEGState* sp, TIFF* tif) -{ - (void) tif; - /* - * Allocate a working buffer for building tables. - * Initial size is 1000 bytes, which is usually adequate. - */ - if (sp->jpegtables) - _TIFFfree(sp->jpegtables); - sp->jpegtables_length = 1000; - sp->jpegtables = (void*) _TIFFmalloc((tsize_t) sp->jpegtables_length); - if (sp->jpegtables == NULL) { - sp->jpegtables_length = 0; - TIFFError("TIFFjpeg_tables_dest", "No space for JPEGTables"); - return (0); - } - sp->cinfo.c.dest = &sp->dest; - sp->dest.init_destination = tables_init_destination; - sp->dest.empty_output_buffer = tables_empty_output_buffer; - sp->dest.term_destination = tables_term_destination; - return (1); -} - -/* - * JPEG library source data manager. - * These routines supply compressed data to libjpeg. - */ - -static void -std_init_source(j_decompress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - TIFF* tif = sp->tif; - - sp->src.next_input_byte = (const JOCTET*) tif->tif_rawdata; - sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; -} - -static boolean -std_fill_input_buffer(j_decompress_ptr cinfo) -{ - JPEGState* sp = (JPEGState* ) cinfo; - static const JOCTET dummy_EOI[2] = { 0xFF, JPEG_EOI }; - - /* - * Should never get here since entire strip/tile is - * read into memory before the decompressor is called, - * and thus was supplied by init_source. - */ - WARNMS(cinfo, JWRN_JPEG_EOF); - /* insert a fake EOI marker */ - sp->src.next_input_byte = dummy_EOI; - sp->src.bytes_in_buffer = 2; - return (TRUE); -} - -static void -std_skip_input_data(j_decompress_ptr cinfo, long num_bytes) -{ - JPEGState* sp = (JPEGState*) cinfo; - - if (num_bytes > 0) { - if (num_bytes > (long) sp->src.bytes_in_buffer) { - /* oops, buffer overrun */ - (void) std_fill_input_buffer(cinfo); - } else { - sp->src.next_input_byte += (size_t) num_bytes; - sp->src.bytes_in_buffer -= (size_t) num_bytes; - } - } -} - -static void -std_term_source(j_decompress_ptr cinfo) -{ - /* No work necessary here */ - /* Or must we update tif->tif_rawcp, tif->tif_rawcc ??? */ - /* (if so, need empty tables_term_source!) */ - (void) cinfo; -} - -static void -TIFFjpeg_data_src(JPEGState* sp, TIFF* tif) -{ - (void) tif; - sp->cinfo.d.src = &sp->src; - sp->src.init_source = std_init_source; - sp->src.fill_input_buffer = std_fill_input_buffer; - sp->src.skip_input_data = std_skip_input_data; - sp->src.resync_to_restart = jpeg_resync_to_restart; - sp->src.term_source = std_term_source; - sp->src.bytes_in_buffer = 0; /* for safety */ - sp->src.next_input_byte = NULL; -} - -/* - * Alternate source manager for reading from JPEGTables. - * We can share all the code except for the init routine. - */ - -static void -tables_init_source(j_decompress_ptr cinfo) -{ - JPEGState* sp = (JPEGState*) cinfo; - - sp->src.next_input_byte = (const JOCTET*) sp->jpegtables; - sp->src.bytes_in_buffer = (size_t) sp->jpegtables_length; -} - -static void -TIFFjpeg_tables_src(JPEGState* sp, TIFF* tif) -{ - TIFFjpeg_data_src(sp, tif); - sp->src.init_source = tables_init_source; -} - -/* - * Allocate downsampled-data buffers needed for downsampled I/O. - * We use values computed in jpeg_start_compress or jpeg_start_decompress. - * We use libjpeg's allocator so that buffers will be released automatically - * when done with strip/tile. - * This is also a handy place to compute samplesperclump, bytesperline. - */ -static int -alloc_downsampled_buffers(TIFF* tif, jpeg_component_info* comp_info, - int num_components) -{ - JPEGState* sp = JState(tif); - int ci; - jpeg_component_info* compptr; - JSAMPARRAY buf; - int samples_per_clump = 0; - - for (ci = 0, compptr = comp_info; ci < num_components; - ci++, compptr++) { - samples_per_clump += compptr->h_samp_factor * - compptr->v_samp_factor; - buf = TIFFjpeg_alloc_sarray(sp, JPOOL_IMAGE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor*DCTSIZE)); - if (buf == NULL) - return (0); - sp->ds_buffer[ci] = buf; - } - sp->samplesperclump = samples_per_clump; - /* Cb,Cr both have sampling factors 1 */ - /* so downsampled width of Cb is # of clumps per line */ - sp->bytesperline = sizeof(JSAMPLE) * samples_per_clump * - comp_info[1].downsampled_width; - return (1); -} - - -/* - * JPEG Decoding. - */ - -static int -JPEGSetupDecode(TIFF* tif) -{ - JPEGState* sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - - assert(sp != NULL); - assert(sp->cinfo.comm.is_decompressor); - - /* Read JPEGTables if it is present */ - if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) { - TIFFjpeg_tables_src(sp, tif); - if(TIFFjpeg_read_header(sp,FALSE) != JPEG_HEADER_TABLES_ONLY) { - TIFFError("JPEGSetupDecode", "Bogus JPEGTables field"); - return (0); - } - } - - /* Grab parameters that are same for all strips/tiles */ - sp->photometric = td->td_photometric; - switch (sp->photometric) { - case PHOTOMETRIC_YCBCR: - sp->h_sampling = td->td_ycbcrsubsampling[0]; - sp->v_sampling = td->td_ycbcrsubsampling[1]; - break; - default: - /* TIFF 6.0 forbids subsampling of all other color spaces */ - sp->h_sampling = 1; - sp->v_sampling = 1; - break; - } - - /* Set up for reading normal data */ - TIFFjpeg_data_src(sp, tif); - tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */ - return (1); -} - -/* - * Set up for decoding a strip or tile. - */ -static int -JPEGPreDecode(TIFF* tif, tsample_t s) -{ - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "JPEGPreDecode"; - uint32 segment_width, segment_height; - int downsampled_output; - int ci; - - assert(sp != NULL); - assert(sp->cinfo.comm.is_decompressor); - /* - * Reset decoder state from any previous strip/tile, - * in case application didn't read the whole strip. - */ - if (!TIFFjpeg_abort(sp)) - return (0); - /* - * Read the header for this strip/tile. - */ - if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK) - return (0); - /* - * Check image parameters and set decompression parameters. - */ - if (isTiled(tif)) { - segment_width = td->td_tilewidth; - segment_height = td->td_tilelength; - sp->bytesperline = TIFFTileRowSize(tif); - } else { - segment_width = td->td_imagewidth; - segment_height = td->td_imagelength - tif->tif_row; - if (segment_height > td->td_rowsperstrip) - segment_height = td->td_rowsperstrip; - sp->bytesperline = TIFFScanlineSize(tif); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) { - /* - * For PC 2, scale down the expected strip/tile size - * to match a downsampled component - */ - segment_width = TIFFhowmany(segment_width, sp->h_sampling); - segment_height = TIFFhowmany(segment_height, sp->v_sampling); - } - if (sp->cinfo.d.image_width != segment_width || - sp->cinfo.d.image_height != segment_height) { - TIFFError(module, "Improper JPEG strip/tile size"); - return (0); - } - if (sp->cinfo.d.num_components != - (td->td_planarconfig == PLANARCONFIG_CONTIG ? - td->td_samplesperpixel : 1)) { - TIFFError(module, "Improper JPEG component count"); - return (0); - } - if (sp->cinfo.d.data_precision != td->td_bitspersample) { - TIFFError(module, "Improper JPEG data precision"); - return (0); - } - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - /* Component 0 should have expected sampling factors */ - if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling || - sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { - TIFFError(module, "Improper JPEG sampling factors"); - return (0); - } - /* Rest should have sampling factors 1,1 */ - for (ci = 1; ci < sp->cinfo.d.num_components; ci++) { - if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 || - sp->cinfo.d.comp_info[ci].v_samp_factor != 1) { - TIFFError(module, "Improper JPEG sampling factors"); - return (0); - } - } - } else { - /* PC 2's single component should have sampling factors 1,1 */ - if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 || - sp->cinfo.d.comp_info[0].v_samp_factor != 1) { - TIFFError(module, "Improper JPEG sampling factors"); - return (0); - } - } - downsampled_output = FALSE; - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - sp->photometric == PHOTOMETRIC_YCBCR && - sp->jpegcolormode == JPEGCOLORMODE_RGB) { - /* Convert YCbCr to RGB */ - sp->cinfo.d.jpeg_color_space = JCS_YCbCr; - sp->cinfo.d.out_color_space = JCS_RGB; - } else { - /* Suppress colorspace handling */ - sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN; - sp->cinfo.d.out_color_space = JCS_UNKNOWN; - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - (sp->h_sampling != 1 || sp->v_sampling != 1)) - downsampled_output = TRUE; - /* XXX what about up-sampling? */ - } - if (downsampled_output) { - /* Need to use raw-data interface to libjpeg */ - sp->cinfo.d.raw_data_out = TRUE; - tif->tif_decoderow = JPEGDecodeRaw; - tif->tif_decodestrip = JPEGDecodeRaw; - tif->tif_decodetile = JPEGDecodeRaw; - } else { - /* Use normal interface to libjpeg */ - sp->cinfo.d.raw_data_out = FALSE; - tif->tif_decoderow = JPEGDecode; - tif->tif_decodestrip = JPEGDecode; - tif->tif_decodetile = JPEGDecode; - } - /* Start JPEG decompressor */ - if (!TIFFjpeg_start_decompress(sp)) - return (0); - /* Allocate downsampled-data buffers if needed */ - if (downsampled_output) { - if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info, - sp->cinfo.d.num_components)) - return (0); - sp->scancount = DCTSIZE; /* mark buffer empty */ - } - return (1); -} - -/* - * Decode a chunk of pixels. - * "Standard" case: returned data is not downsampled. - */ -static int -JPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - JPEGState *sp = JState(tif); - tsize_t nrows; - JSAMPROW bufptr[1]; - - (void) s; - assert(sp != NULL); - /* data is expected to be read in multiples of a scanline */ - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarning(tif->tif_name, "fractional scanline not read"); - - while (nrows-- > 0) { - bufptr[0] = (JSAMPROW) buf; - if (TIFFjpeg_read_scanlines(sp, bufptr, 1) != 1) - return (0); - if (nrows > 0) - tif->tif_row++; - buf += sp->bytesperline; - } - /* Close down the decompressor if we've finished the strip or tile. */ - if (sp->cinfo.d.output_scanline == sp->cinfo.d.output_height) { - if (TIFFjpeg_finish_decompress(sp) != TRUE) - return (0); - } - return (1); -} - -/* - * Decode a chunk of pixels. - * Returned data is downsampled per sampling factors. - */ -static int -JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - JPEGState *sp = JState(tif); - JSAMPLE* inptr; - JSAMPLE* outptr; - tsize_t nrows; - JDIMENSION clumps_per_line, nclump; - int clumpoffset, ci, xpos, ypos; - jpeg_component_info* compptr; - int samples_per_clump = sp->samplesperclump; - - (void) s; - assert(sp != NULL); - /* data is expected to be read in multiples of a scanline */ - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarning(tif->tif_name, "fractional scanline not read"); - - /* Cb,Cr both have sampling factors 1, so this is correct */ - clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width; - - while (nrows-- > 0) { - /* Reload downsampled-data buffer if needed */ - if (sp->scancount >= DCTSIZE) { - int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE; - if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) != n) - return (0); - sp->scancount = 0; - } - /* - * Fastest way to unseparate the data is to make one pass - * over the scanline for each row of each component. - */ - clumpoffset = 0; /* first sample in clump */ - for (ci = 0, compptr = sp->cinfo.d.comp_info; - ci < sp->cinfo.d.num_components; - ci++, compptr++) { - int hsamp = compptr->h_samp_factor; - int vsamp = compptr->v_samp_factor; - for (ypos = 0; ypos < vsamp; ypos++) { - inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; - outptr = ((JSAMPLE*) buf) + clumpoffset; - if (hsamp == 1) { - /* fast path for at least Cb and Cr */ - for (nclump = clumps_per_line; nclump-- > 0; ) { - outptr[0] = *inptr++; - outptr += samples_per_clump; - } - } else { - /* general case */ - for (nclump = clumps_per_line; nclump-- > 0; ) { - for (xpos = 0; xpos < hsamp; xpos++) - outptr[xpos] = *inptr++; - outptr += samples_per_clump; - } - } - clumpoffset += hsamp; - } - } - sp->scancount++; - if (nrows > 0) - tif->tif_row++; - buf += sp->bytesperline; - } - - /* Close down the decompressor if done. */ - if (sp->cinfo.d.output_scanline >= sp->cinfo.d.output_height) { - if (TIFFjpeg_finish_decompress(sp) != TRUE) - return (0); - } - - return (1); -} - - -/* - * JPEG Encoding. - */ - -static void -unsuppress_quant_table (JPEGState* sp, int tblno) -{ - JQUANT_TBL* qtbl; - - if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) - qtbl->sent_table = FALSE; -} - -static void -unsuppress_huff_table (JPEGState* sp, int tblno) -{ - JHUFF_TBL* htbl; - - if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) - htbl->sent_table = FALSE; - if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) - htbl->sent_table = FALSE; -} - -static int -prepare_JPEGTables(TIFF* tif) -{ - JPEGState* sp = JState(tif); - - /* Initialize quant tables for current quality setting */ - if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) - return (0); - /* Mark only the tables we want for output */ - /* NB: chrominance tables are currently used only with YCbCr */ - if (!TIFFjpeg_suppress_tables(sp, TRUE)) - return (0); - if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) { - unsuppress_quant_table(sp, 0); - if (sp->photometric == PHOTOMETRIC_YCBCR) - unsuppress_quant_table(sp, 1); - } - if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) { - unsuppress_huff_table(sp, 0); - if (sp->photometric == PHOTOMETRIC_YCBCR) - unsuppress_huff_table(sp, 1); - } - /* Direct libjpeg output into jpegtables */ - if (!TIFFjpeg_tables_dest(sp, tif)) - return (0); - /* Emit tables-only datastream */ - if (!TIFFjpeg_write_tables(sp)) - return (0); - - return (1); -} - -static int -JPEGSetupEncode(TIFF* tif) -{ - JPEGState* sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "JPEGSetupEncode"; - - assert(sp != NULL); - assert(!sp->cinfo.comm.is_decompressor); - - /* - * Initialize all JPEG parameters to default values. - * Note that jpeg_set_defaults needs legal values for - * in_color_space and input_components. - */ - sp->cinfo.c.in_color_space = JCS_UNKNOWN; - sp->cinfo.c.input_components = 1; - if (!TIFFjpeg_set_defaults(sp)) - return (0); - /* Set per-file parameters */ - sp->photometric = td->td_photometric; - switch (sp->photometric) { - case PHOTOMETRIC_YCBCR: - sp->h_sampling = td->td_ycbcrsubsampling[0]; - sp->v_sampling = td->td_ycbcrsubsampling[1]; - /* - * A ReferenceBlackWhite field *must* be present since the - * default value is inappropriate for YCbCr. Fill in the - * proper value if application didn't set it. - */ -#ifdef COLORIMETRY_SUPPORT - if (!TIFFFieldSet(tif, FIELD_REFBLACKWHITE)) { - float refbw[6]; - long top = 1L << td->td_bitspersample; - refbw[0] = 0; - refbw[1] = (float)(top-1L); - refbw[2] = (float)(top>>1); - refbw[3] = refbw[1]; - refbw[4] = refbw[2]; - refbw[5] = refbw[1]; - TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refbw); - } -#endif - break; - case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */ - case PHOTOMETRIC_MASK: - TIFFError(module, - "PhotometricInterpretation %d not allowed for JPEG", - (int) sp->photometric); - return (0); - default: - /* TIFF 6.0 forbids subsampling of all other color spaces */ - sp->h_sampling = 1; - sp->v_sampling = 1; - break; - } - - /* Verify miscellaneous parameters */ - - /* - * This would need work if libtiff ever supports different - * depths for different components, or if libjpeg ever supports - * run-time selection of depth. Neither is imminent. - */ - if (td->td_bitspersample != BITS_IN_JSAMPLE) { - TIFFError(module, "BitsPerSample %d not allowed for JPEG", - (int) td->td_bitspersample); - return (0); - } - sp->cinfo.c.data_precision = td->td_bitspersample; - if (isTiled(tif)) { - if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) { - TIFFError(module, - "JPEG tile height must be multiple of %d", - sp->v_sampling * DCTSIZE); - return (0); - } - if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) { - TIFFError(module, - "JPEG tile width must be multiple of %d", - sp->h_sampling * DCTSIZE); - return (0); - } - } else { - if (td->td_rowsperstrip < td->td_imagelength && - (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) { - TIFFError(module, - "RowsPerStrip must be multiple of %d for JPEG", - sp->v_sampling * DCTSIZE); - return (0); - } - } - - /* Create a JPEGTables field if appropriate */ - if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) { - if (!prepare_JPEGTables(tif)) - return (0); - /* Mark the field present */ - /* Can't use TIFFSetField since BEENWRITING is already set! */ - TIFFSetFieldBit(tif, FIELD_JPEGTABLES); - tif->tif_flags |= TIFF_DIRTYDIRECT; - } else { - /* We do not support application-supplied JPEGTables, */ - /* so mark the field not present */ - TIFFClrFieldBit(tif, FIELD_JPEGTABLES); - } - - /* Direct libjpeg output to libtiff's output buffer */ - TIFFjpeg_data_dest(sp, tif); - - return (1); -} - -/* - * Set encoding state at the start of a strip or tile. - */ -static int -JPEGPreEncode(TIFF* tif, tsample_t s) -{ - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "JPEGPreEncode"; - uint32 segment_width, segment_height; - int downsampled_input; - - assert(sp != NULL); - assert(!sp->cinfo.comm.is_decompressor); - /* - * Set encoding parameters for this strip/tile. - */ - if (isTiled(tif)) { - segment_width = td->td_tilewidth; - segment_height = td->td_tilelength; - sp->bytesperline = TIFFTileRowSize(tif); - } else { - segment_width = td->td_imagewidth; - segment_height = td->td_imagelength - tif->tif_row; - if (segment_height > td->td_rowsperstrip) - segment_height = td->td_rowsperstrip; - sp->bytesperline = TIFFScanlineSize(tif); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) { - /* for PC 2, scale down the strip/tile size - * to match a downsampled component - */ - segment_width = TIFFhowmany(segment_width, sp->h_sampling); - segment_height = TIFFhowmany(segment_height, sp->v_sampling); - } - if (segment_width > 65535 || segment_height > 65535) { - TIFFError(module, "Strip/tile too large for JPEG"); - return (0); - } - sp->cinfo.c.image_width = segment_width; - sp->cinfo.c.image_height = segment_height; - downsampled_input = FALSE; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - sp->cinfo.c.input_components = td->td_samplesperpixel; - if (sp->photometric == PHOTOMETRIC_YCBCR) { - if (sp->jpegcolormode == JPEGCOLORMODE_RGB) { - sp->cinfo.c.in_color_space = JCS_RGB; - } else { - sp->cinfo.c.in_color_space = JCS_YCbCr; - if (sp->h_sampling != 1 || sp->v_sampling != 1) - downsampled_input = TRUE; - } - if (!TIFFjpeg_set_colorspace(sp, JCS_YCbCr)) - return (0); - /* - * Set Y sampling factors; - * we assume jpeg_set_colorspace() set the rest to 1 - */ - sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling; - sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling; - } else { - sp->cinfo.c.in_color_space = JCS_UNKNOWN; - if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) - return (0); - /* jpeg_set_colorspace set all sampling factors to 1 */ - } - } else { - sp->cinfo.c.input_components = 1; - sp->cinfo.c.in_color_space = JCS_UNKNOWN; - if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) - return (0); - sp->cinfo.c.comp_info[0].component_id = s; - /* jpeg_set_colorspace() set sampling factors to 1 */ - if (sp->photometric == PHOTOMETRIC_YCBCR && s > 0) { - sp->cinfo.c.comp_info[0].quant_tbl_no = 1; - sp->cinfo.c.comp_info[0].dc_tbl_no = 1; - sp->cinfo.c.comp_info[0].ac_tbl_no = 1; - } - } - /* ensure libjpeg won't write any extraneous markers */ - sp->cinfo.c.write_JFIF_header = FALSE; - sp->cinfo.c.write_Adobe_marker = FALSE; - /* set up table handling correctly */ - if (! (sp->jpegtablesmode & JPEGTABLESMODE_QUANT)) { - if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) - return (0); - unsuppress_quant_table(sp, 0); - unsuppress_quant_table(sp, 1); - } - if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) - sp->cinfo.c.optimize_coding = FALSE; - else - sp->cinfo.c.optimize_coding = TRUE; - if (downsampled_input) { - /* Need to use raw-data interface to libjpeg */ - sp->cinfo.c.raw_data_in = TRUE; - tif->tif_encoderow = JPEGEncodeRaw; - tif->tif_encodestrip = JPEGEncodeRaw; - tif->tif_encodetile = JPEGEncodeRaw; - } else { - /* Use normal interface to libjpeg */ - sp->cinfo.c.raw_data_in = FALSE; - tif->tif_encoderow = JPEGEncode; - tif->tif_encodestrip = JPEGEncode; - tif->tif_encodetile = JPEGEncode; - } - /* Start JPEG compressor */ - if (!TIFFjpeg_start_compress(sp, FALSE)) - return (0); - /* Allocate downsampled-data buffers if needed */ - if (downsampled_input) { - if (!alloc_downsampled_buffers(tif, sp->cinfo.c.comp_info, - sp->cinfo.c.num_components)) - return (0); - } - sp->scancount = 0; - - return (1); -} - -/* - * Encode a chunk of pixels. - * "Standard" case: incoming data is not downsampled. - */ -static int -JPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - JPEGState *sp = JState(tif); - tsize_t nrows; - JSAMPROW bufptr[1]; - - (void) s; - assert(sp != NULL); - /* data is expected to be supplied in multiples of a scanline */ - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarning(tif->tif_name, "fractional scanline discarded"); - - while (nrows-- > 0) { - bufptr[0] = (JSAMPROW) buf; - if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1) - return (0); - if (nrows > 0) - tif->tif_row++; - buf += sp->bytesperline; - } - return (1); -} - -/* - * Encode a chunk of pixels. - * Incoming data is expected to be downsampled per sampling factors. - */ -static int -JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - JPEGState *sp = JState(tif); - JSAMPLE* inptr; - JSAMPLE* outptr; - tsize_t nrows; - JDIMENSION clumps_per_line, nclump; - int clumpoffset, ci, xpos, ypos; - jpeg_component_info* compptr; - int samples_per_clump = sp->samplesperclump; - - (void) s; - assert(sp != NULL); - /* data is expected to be supplied in multiples of a scanline */ - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarning(tif->tif_name, "fractional scanline discarded"); - - /* Cb,Cr both have sampling factors 1, so this is correct */ - clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width; - - while (nrows-- > 0) { - /* - * Fastest way to separate the data is to make one pass - * over the scanline for each row of each component. - */ - clumpoffset = 0; /* first sample in clump */ - for (ci = 0, compptr = sp->cinfo.c.comp_info; - ci < sp->cinfo.c.num_components; - ci++, compptr++) { - int hsamp = compptr->h_samp_factor; - int vsamp = compptr->v_samp_factor; - int padding = (int) (compptr->width_in_blocks * DCTSIZE - - clumps_per_line * hsamp); - for (ypos = 0; ypos < vsamp; ypos++) { - inptr = ((JSAMPLE*) buf) + clumpoffset; - outptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; - if (hsamp == 1) { - /* fast path for at least Cb and Cr */ - for (nclump = clumps_per_line; nclump-- > 0; ) { - *outptr++ = inptr[0]; - inptr += samples_per_clump; - } - } else { - /* general case */ - for (nclump = clumps_per_line; nclump-- > 0; ) { - for (xpos = 0; xpos < hsamp; xpos++) - *outptr++ = inptr[xpos]; - inptr += samples_per_clump; - } - } - /* pad each scanline as needed */ - for (xpos = 0; xpos < padding; xpos++) { - *outptr = outptr[-1]; - outptr++; - } - clumpoffset += hsamp; - } - } - sp->scancount++; - if (sp->scancount >= DCTSIZE) { - int n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; - if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) - return (0); - sp->scancount = 0; - } - if (nrows > 0) - tif->tif_row++; - buf += sp->bytesperline; - } - return (1); -} - -/* - * Finish up at the end of a strip or tile. - */ -static int -JPEGPostEncode(TIFF* tif) -{ - JPEGState *sp = JState(tif); - - if (sp->scancount > 0) { - /* - * Need to emit a partial bufferload of downsampled data. - * Pad the data vertically. - */ - int ci, ypos, n; - jpeg_component_info* compptr; - - for (ci = 0, compptr = sp->cinfo.c.comp_info; - ci < sp->cinfo.c.num_components; - ci++, compptr++) { - int vsamp = compptr->v_samp_factor; - tsize_t row_width = compptr->width_in_blocks * DCTSIZE - * sizeof(JSAMPLE); - for (ypos = sp->scancount * vsamp; - ypos < DCTSIZE * vsamp; ypos++) { - _TIFFmemcpy((tdata_t)sp->ds_buffer[ci][ypos], - (tdata_t)sp->ds_buffer[ci][ypos-1], - row_width); - - } - } - n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; - if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) - return (0); - } - - return (TIFFjpeg_finish_compress(JState(tif))); -} - -static void -JPEGCleanup(TIFF* tif) -{ - if (tif->tif_data) { - JPEGState *sp = JState(tif); - TIFFjpeg_destroy(sp); /* release libjpeg resources */ - if (sp->jpegtables) /* tag value */ - _TIFFfree(sp->jpegtables); - _TIFFfree(tif->tif_data); /* release local state */ - tif->tif_data = NULL; - } -} - -static int -JPEGVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - JPEGState* sp = JState(tif); - TIFFDirectory* td = &tif->tif_dir; - uint32 v32; - - switch (tag) { - case TIFFTAG_JPEGTABLES: - v32 = va_arg(ap, uint32); - if (v32 == 0) { - /* XXX */ - return (0); - } - _TIFFsetByteArray(&sp->jpegtables, va_arg(ap, void*), - (long) v32); - sp->jpegtables_length = v32; - TIFFSetFieldBit(tif, FIELD_JPEGTABLES); - break; - case TIFFTAG_JPEGQUALITY: - sp->jpegquality = va_arg(ap, int); - return (1); /* pseudo tag */ - case TIFFTAG_JPEGCOLORMODE: - sp->jpegcolormode = va_arg(ap, int); - /* - * Mark whether returned data is up-sampled or not - * so TIFFStripSize and TIFFTileSize return values - * that reflect the true amount of data. - */ - tif->tif_flags &= ~TIFF_UPSAMPLED; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - if (td->td_photometric == PHOTOMETRIC_YCBCR && - sp->jpegcolormode == JPEGCOLORMODE_RGB) { - tif->tif_flags |= TIFF_UPSAMPLED; - } else { - if (td->td_ycbcrsubsampling[0] != 1 || - td->td_ycbcrsubsampling[1] != 1) - ; /* XXX what about up-sampling? */ - } - } - /* - * Must recalculate cached tile size - * in case sampling state changed. - */ - tif->tif_tilesize = TIFFTileSize(tif); - return (1); /* pseudo tag */ - case TIFFTAG_JPEGTABLESMODE: - sp->jpegtablesmode = va_arg(ap, int); - return (1); /* pseudo tag */ - default: - return (*sp->vsetparent)(tif, tag, ap); - } - tif->tif_flags |= TIFF_DIRTYDIRECT; - return (1); -} - -static int -JPEGVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - JPEGState* sp = JState(tif); - - switch (tag) { - case TIFFTAG_JPEGTABLES: - /* u_short is bogus --- should be uint32 ??? */ - /* TIFFWriteNormalTag needs fixed XXX */ - *va_arg(ap, u_short*) = (u_short) sp->jpegtables_length; - *va_arg(ap, void**) = sp->jpegtables; - break; - case TIFFTAG_JPEGQUALITY: - *va_arg(ap, int*) = sp->jpegquality; - break; - case TIFFTAG_JPEGCOLORMODE: - *va_arg(ap, int*) = sp->jpegcolormode; - break; - case TIFFTAG_JPEGTABLESMODE: - *va_arg(ap, int*) = sp->jpegtablesmode; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); -} - -static void -JPEGPrintDir(TIFF* tif, FILE* fd, long flags) -{ - JPEGState* sp = JState(tif); - - (void) flags; - if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) - fprintf(fd, " JPEG Tables: (%lu bytes)\n", - (u_long) sp->jpegtables_length); -} - -static uint32 -JPEGDefaultStripSize(TIFF* tif, uint32 s) -{ - JPEGState* sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - - s = (*sp->defsparent)(tif, s); - if (s < td->td_imagelength) - s = TIFFroundup(s, td->td_ycbcrsubsampling[1] * DCTSIZE); - return (s); -} - -static void -JPEGDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) -{ - JPEGState* sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - - (*sp->deftparent)(tif, tw, th); - *tw = TIFFroundup(*tw, td->td_ycbcrsubsampling[0] * DCTSIZE); - *th = TIFFroundup(*th, td->td_ycbcrsubsampling[1] * DCTSIZE); -} - -int -TIFFInitJPEG(TIFF* tif, int scheme) -{ - JPEGState* sp; - - assert(scheme == COMPRESSION_JPEG); - - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (JPEGState)); - if (tif->tif_data == NULL) { - TIFFError("TIFFInitJPEG", "No space for JPEG state block"); - return (0); - } - sp = JState(tif); - sp->tif = tif; /* back link */ - - /* - * Merge codec-specific tag information and - * override parent get/set field methods. - */ - _TIFFMergeFieldInfo(tif, jpegFieldInfo, N(jpegFieldInfo)); - sp->vgetparent = tif->tif_vgetfield; - tif->tif_vgetfield = JPEGVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_vsetfield; - tif->tif_vsetfield = JPEGVSetField; /* hook for codec tags */ - tif->tif_printdir = JPEGPrintDir; /* hook for codec tags */ - - /* Default values for codec-specific fields */ - sp->jpegtables = NULL; - sp->jpegtables_length = 0; - sp->jpegquality = 75; /* Default IJG quality */ - sp->jpegcolormode = JPEGCOLORMODE_RAW; - sp->jpegtablesmode = JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF; - - /* - * Install codec methods. - */ - tif->tif_setupdecode = JPEGSetupDecode; - tif->tif_predecode = JPEGPreDecode; - tif->tif_decoderow = JPEGDecode; - tif->tif_decodestrip = JPEGDecode; - tif->tif_decodetile = JPEGDecode; - tif->tif_setupencode = JPEGSetupEncode; - tif->tif_preencode = JPEGPreEncode; - tif->tif_postencode = JPEGPostEncode; - tif->tif_encoderow = JPEGEncode; - tif->tif_encodestrip = JPEGEncode; - tif->tif_encodetile = JPEGEncode; - tif->tif_cleanup = JPEGCleanup; - sp->defsparent = tif->tif_defstripsize; - tif->tif_defstripsize = JPEGDefaultStripSize; - sp->deftparent = tif->tif_deftilesize; - tif->tif_deftilesize = JPEGDefaultTileSize; - tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */ - - /* - * Initialize libjpeg. - */ - if (tif->tif_mode == O_RDONLY) { - if (!TIFFjpeg_create_decompress(sp)) - return (0); - } else { - if (!TIFFjpeg_create_compress(sp)) - return (0); - } - - return (1); -} -#endif /* JPEG_SUPPORT */ diff --git a/freeimage241/Source/LibTIFF/tif_luv.c b/freeimage241/Source/LibTIFF/tif_luv.c deleted file mode 100644 index fc900ec..0000000 --- a/freeimage241/Source/LibTIFF/tif_luv.c +++ /dev/null @@ -1,1425 +0,0 @@ -/* - * Copyright (c) 1997 Greg Ward Larson - * Copyright (c) 1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler, Greg Larson and Silicon Graphics may not be used in any - * advertising or publicity relating to the software without the specific, - * prior written permission of Sam Leffler, Greg Larson and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER, GREG LARSON OR SILICON GRAPHICS BE LIABLE - * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef LOGLUV_SUPPORT - -/* - * TIFF Library. - * LogLuv compression support for high dynamic range images. - * - * Contributed by Greg Larson. - * - * LogLuv image support uses the TIFF library to store 16 or 10-bit - * log luminance values with 8 bits each of u and v or a 14-bit index. - * - * The codec can take as input and produce as output 32-bit IEEE float values - * as well as 16-bit integer values. A 16-bit luminance is interpreted - * as a sign bit followed by a 15-bit integer that is converted - * to and from a linear magnitude using the transformation: - * - * L = 2^( (Le+.5)/256 - 64 ) # real from 15-bit - * - * Le = floor( 256*(log2(L) + 64) ) # 15-bit from real - * - * The actual conversion to world luminance units in candelas per sq. meter - * requires an additional multiplier, which is stored in the TIFFTAG_STONITS. - * This value is usually set such that a reasonable exposure comes from - * clamping decoded luminances above 1 to 1 in the displayed image. - * - * The 16-bit values for u and v may be converted to real values by dividing - * each by 32768. (This allows for negative values, which aren't useful as - * far as we know, but are left in case of future improvements in human - * color vision.) - * - * Conversion from (u,v), which is actually the CIE (u',v') system for - * you color scientists, is accomplished by the following transformation: - * - * u = 4*x / (-2*x + 12*y + 3) - * v = 9*y / (-2*x + 12*y + 3) - * - * x = 9*u / (6*u - 16*v + 12) - * y = 4*v / (6*u - 16*v + 12) - * - * This process is greatly simplified by passing 32-bit IEEE floats - * for each of three CIE XYZ coordinates. The codec then takes care - * of conversion to and from LogLuv, though the application is still - * responsible for interpreting the TIFFTAG_STONITS calibration factor. - * - * The information is compressed into one of two basic encodings, depending on - * the setting of the compression tag, which is one of COMPRESSION_SGILOG - * or COMPRESSION_SGILOG24. For COMPRESSION_SGILOG, greyscale data is - * stored as: - * - * 1 15 - * |-+---------------| - * - * COMPRESSION_SGILOG color data is stored as: - * - * 1 15 8 8 - * |-+---------------|--------+--------| - * S Le ue ve - * - * For the 24-bit COMPRESSION_SGILOG24 color format, the data is stored as: - * - * 10 14 - * |----------|--------------| - * Le' Ce - * - * There is no sign bit in the 24-bit case, and the (u,v) chromaticity is - * encoded as an index for optimal color resolution. The 10 log bits are - * defined by the following conversions: - * - * L = 2^((Le'+.5)/64 - 12) # real from 10-bit - * - * Le' = floor( 64*(log2(L) + 12) ) # 10-bit from real - * - * The 10 bits of the smaller format may be converted into the 15 bits of - * the larger format by multiplying by 4 and adding 13314. Obviously, - * a smaller range of magnitudes is covered (about 5 orders of magnitude - * instead of 38), and the lack of a sign bit means that negative luminances - * are not allowed. (Well, they aren't allowed in the real world, either, - * but they are useful for certain types of image processing.) - * - * The desired user format is controlled by the setting the internal - * pseudo tag TIFFTAG_SGILOGDATAFMT to one of: - * SGILOGDATAFMT_FLOAT = IEEE 32-bit float XYZ values - * SGILOGDATAFMT_16BIT = 16-bit integer encodings of logL, u and v - * Raw data i/o is also possible using: - * SGILOGDATAFMT_RAW = 32-bit unsigned integer with encoded pixel - * In addition, the following decoding is provided for ease of display: - * SGILOGDATAFMT_8BIT = 8-bit default RGB gamma-corrected values - * - * For grayscale images, we provide the following data formats: - * SGILOGDATAFMT_FLOAT = IEEE 32-bit float Y values - * SGILOGDATAFMT_16BIT = 16-bit integer w/ encoded luminance - * SGILOGDATAFMT_8BIT = 8-bit gray monitor values - * - * Note that the COMPRESSION_SGILOG applies a simple run-length encoding - * scheme by separating the logL, u and v bytes for each row and applying - * a PackBits type of compression. Since the 24-bit encoding is not - * adaptive, the 32-bit color format takes less space in many cases. - */ - -#include -#include -#include -#include - -/* - * State block for each open TIFF - * file using LogLuv compression/decompression. - */ -typedef struct logLuvState LogLuvState; - -struct logLuvState { - int user_datafmt; /* user data format */ - int pixel_size; /* bytes per pixel */ - - tidata_t* tbuf; /* translation buffer */ - short tbuflen; /* buffer length */ - void (*tfunc)(LogLuvState*, tidata_t, int); - - TIFFVSetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ -}; - -#define DecoderState(tif) ((LogLuvState*) (tif)->tif_data) -#define EncoderState(tif) ((LogLuvState*) (tif)->tif_data) - -#define N(a) (sizeof(a)/sizeof(a[0])) -#define SGILOGDATAFMT_UNKNOWN -1 - -#define MINRUN 4 /* minimum run length */ - -/* - * Decode a string of 16-bit gray pixels. - */ -static int -LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - LogLuvState* sp = DecoderState(tif); - int shft, i, npixels; - u_char* bp; - int16* tp; - int16 b; - int cc, rc; - - assert(s == 0); - assert(sp != NULL); - - npixels = occ / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16*) op; - else { - assert(sp->tbuflen >= npixels); - tp = (int16*) sp->tbuf; - } - _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); - - bp = (u_char*) tif->tif_rawcp; - cc = tif->tif_rawcc; - /* get each byte string */ - for (shft = 2*8; (shft -= 8) >= 0; ) { - for (i = 0; i < npixels && cc > 0; ) - if (*bp >= 128) { /* run */ - rc = *bp++ + (2-128); - b = (int16)*bp++ << shft; - cc -= 2; - while (rc--) - tp[i++] |= b; - } else { /* non-run */ - rc = *bp++; /* nul is noop */ - while (--cc && rc--) - tp[i++] |= (int16)*bp++ << shft; - } - if (i != npixels) { - TIFFError(tif->tif_name, - "LogL16Decode: Not enough data at row %d (short %d pixels)", - tif->tif_row, npixels - i); - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - return (0); - } - } - (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - return (1); -} - -/* - * Decode a string of 24-bit pixels. - */ -static int -LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - LogLuvState* sp = DecoderState(tif); - int cc, i, npixels; - u_char* bp; - uint32* tp; - - assert(s == 0); - assert(sp != NULL); - - npixels = occ / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32 *)op; - else { - assert(sp->tbuflen >= npixels); - tp = (uint32 *) sp->tbuf; - } - _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); - /* copy to array of uint32 */ - bp = (u_char*) tif->tif_rawcp; - cc = tif->tif_rawcc; - for (i = 0; i < npixels && cc > 0; i++) { - tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2]; - bp += 3; - cc -= 3; - } - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - if (i != npixels) { - TIFFError(tif->tif_name, - "LogLuvDecode24: Not enough data at row %d (short %d pixels)", - tif->tif_row, npixels - i); - return (0); - } - (*sp->tfunc)(sp, op, npixels); - return (1); -} - -/* - * Decode a string of 32-bit pixels. - */ -static int -LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - LogLuvState* sp; - int shft, i, npixels; - u_char* bp; - uint32* tp; - uint32 b; - int cc, rc; - - assert(s == 0); - sp = DecoderState(tif); - assert(sp != NULL); - - npixels = occ / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) op; - else { - assert(sp->tbuflen >= npixels); - tp = (uint32*) sp->tbuf; - } - _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); - - bp = (u_char*) tif->tif_rawcp; - cc = tif->tif_rawcc; - /* get each byte string */ - for (shft = 4*8; (shft -= 8) >= 0; ) { - for (i = 0; i < npixels && cc > 0; ) - if (*bp >= 128) { /* run */ - rc = *bp++ + (2-128); - b = (uint32)*bp++ << shft; - cc -= 2; - while (rc--) - tp[i++] |= b; - } else { /* non-run */ - rc = *bp++; /* nul is noop */ - while (--cc && rc--) - tp[i++] |= (uint32)*bp++ << shft; - } - if (i != npixels) { - TIFFError(tif->tif_name, - "LogLuvDecode32: Not enough data at row %d (short %d pixels)", - tif->tif_row, npixels - i); - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - return (0); - } - } - (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - return (1); -} - -/* - * Decode a strip of pixels. We break it into rows to - * maintain synchrony with the encode algorithm, which - * is row by row. - */ -static int -LogLuvDecodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - tsize_t rowlen = TIFFScanlineSize(tif); - - assert(cc%rowlen == 0); - while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) - bp += rowlen, cc -= rowlen; - return (cc == 0); -} - -/* - * Decode a tile of pixels. We break it into rows to - * maintain synchrony with the encode algorithm, which - * is row by row. - */ -static int -LogLuvDecodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - tsize_t rowlen = TIFFTileRowSize(tif); - - assert(cc%rowlen == 0); - while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) - bp += rowlen, cc -= rowlen; - return (cc == 0); -} - -/* - * Encode a row of 16-bit pixels. - */ -static int -LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - LogLuvState* sp = EncoderState(tif); - int shft, i, j, npixels; - tidata_t op; - int16* tp; - int16 b; - int occ, rc=0, mask, beg; - - assert(s == 0); - assert(sp != NULL); - npixels = cc / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16*) bp; - else { - tp = (int16*) sp->tbuf; - assert(sp->tbuflen >= npixels); - (*sp->tfunc)(sp, bp, npixels); - } - /* compress each byte string */ - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - for (shft = 2*8; (shft -= 8) >= 0; ) - for (i = 0; i < npixels; i += rc) { - if (occ < 4) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - mask = 0xff << shft; /* find next run */ - for (beg = i; beg < npixels; beg += rc) { - b = tp[beg] & mask; - rc = 1; - while (rc < 127+2 && beg+rc < npixels && - (tp[beg+rc] & mask) == b) - rc++; - if (rc >= MINRUN) - break; /* long enough */ - } - if (beg-i > 1 && beg-i < MINRUN) { - b = tp[i] & mask; /* check short run */ - j = i+1; - while ((tp[j++] & mask) == b) - if (j == beg) { - *op++ = 128-2+j-i; - *op++ = b >> shft; - occ -= 2; - i = beg; - break; - } - } - while (i < beg) { /* write out non-run */ - if ((j = beg-i) > 127) j = 127; - if (occ < j+3) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - *op++ = j; occ--; - while (j--) { - *op++ = tp[i++] >> shft & 0xff; - occ--; - } - } - if (rc >= MINRUN) { /* write out run */ - *op++ = 128-2+rc; - *op++ = tp[beg] >> shft & 0xff; - occ -= 2; - } else - rc = 0; - } - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - - return (0); -} - -/* - * Encode a row of 24-bit pixels. - */ -static int -LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - LogLuvState* sp = EncoderState(tif); - int i, npixels, occ; - tidata_t op; - uint32* tp; - - assert(s == 0); - assert(sp != NULL); - npixels = cc / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) bp; - else { - tp = (uint32*) sp->tbuf; - assert(sp->tbuflen >= npixels); - (*sp->tfunc)(sp, bp, npixels); - } - /* write out encoded pixels */ - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - for (i = npixels; i--; ) { - if (occ < 3) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - *op++ = (tidataval_t)(*tp >> 16); - *op++ = (tidataval_t)(*tp >> 8 & 0xff); - *op++ = (tidataval_t)(*tp++ & 0xff); - occ -= 3; - } - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - - return (0); -} - -/* - * Encode a row of 32-bit pixels. - */ -static int -LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - LogLuvState* sp = EncoderState(tif); - int shft, i, j, npixels; - tidata_t op; - uint32* tp; - uint32 b; - int occ, rc=0, mask, beg; - - assert(s == 0); - assert(sp != NULL); - - npixels = cc / sp->pixel_size; - - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) bp; - else { - tp = (uint32*) sp->tbuf; - assert(sp->tbuflen >= npixels); - (*sp->tfunc)(sp, bp, npixels); - } - /* compress each byte string */ - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - for (shft = 4*8; (shft -= 8) >= 0; ) - for (i = 0; i < npixels; i += rc) { - if (occ < 4) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - mask = 0xff << shft; /* find next run */ - for (beg = i; beg < npixels; beg += rc) { - b = tp[beg] & mask; - rc = 1; - while (rc < 127+2 && beg+rc < npixels && - (tp[beg+rc] & mask) == b) - rc++; - if (rc >= MINRUN) - break; /* long enough */ - } - if (beg-i > 1 && beg-i < MINRUN) { - b = tp[i] & mask; /* check short run */ - j = i+1; - while ((tp[j++] & mask) == b) - if (j == beg) { - *op++ = (tidataval_t)(128-2+j-i); - *op++ = (tidataval_t)(b >> shft); - occ -= 2; - i = beg; - break; - } - } - while (i < beg) { /* write out non-run */ - if ((j = beg-i) > 127) j = 127; - if (occ < j+3) { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - *op++ = j; occ--; - while (j--) { - *op++ = (tidataval_t)(tp[i++] >> shft & 0xff); - occ--; - } - } - if (rc >= MINRUN) { /* write out run */ - *op++ = 128-2+rc; - *op++ = (tidataval_t)(tp[beg] >> shft & 0xff); - occ -= 2; - } else - rc = 0; - } - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - - return (0); -} - -/* - * Encode a strip of pixels. We break it into rows to - * avoid encoding runs across row boundaries. - */ -static int -LogLuvEncodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - tsize_t rowlen = TIFFScanlineSize(tif); - - assert(cc%rowlen == 0); - while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0) - bp += rowlen, cc -= rowlen; - return (cc == 0); -} - -/* - * Encode a tile of pixels. We break it into rows to - * avoid encoding runs across row boundaries. - */ -static int -LogLuvEncodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - tsize_t rowlen = TIFFTileRowSize(tif); - - assert(cc%rowlen == 0); - while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0) - bp += rowlen, cc -= rowlen; - return (cc == 0); -} - -/* - * Encode/Decode functions for converting to and from user formats. - */ -#include "uvcode.h" - -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 - -#ifdef M_LN2 -#define LOGOF2 M_LN2 -#else -#define LOGOF2 0.69314718055994530942 -#endif -#define log2(x) ((1./LOGOF2)*log(x)) -#define exp2(x) exp(LOGOF2*(x)) - -#define UVSCALE 410. - -static double -pix16toY(int p16) -{ - int Le = p16 & 0x7fff; - double Y; - - if (!Le) - return (0.); - Y = exp(LOGOF2/256.*(Le+.5) - LOGOF2*64.); - if (p16 & 0x8000) - return (-Y); - return (Y); -} - -static int -pix16fromY(double Y) -{ - if (Y >= 1.84467e19) - return (0x7fff); - if (Y <= -1.84467e19) - return (0xffff); - if (Y > 5.43571e-20) - return (int)(256.*(log2(Y) + 64.)); - if (Y < -5.43571e-20) - return (~0x7fff | (int)(256.*(log2(-Y) + 64.))); - return (0); -} - -static void -L16toY(LogLuvState* sp, tidata_t op, int n) -{ - int16* l16 = (int16*) sp->tbuf; - float* yp = (float*) op; - - while (n-- > 0) - *yp++ = (float)pix16toY(*l16++); -} - -static void -L16toGry(LogLuvState* sp, tidata_t op, int n) -{ - int16* l16 = (int16*) sp->tbuf; - uint8* gp = (uint8*) op; - - while (n-- > 0) { - double Y = pix16toY(*l16++); - *gp++ = (Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256.*sqrt(Y)); - } -} - -static void -L16fromY(LogLuvState* sp, tidata_t op, int n) -{ - int16* l16 = (int16*) sp->tbuf; - float* yp = (float*) op; - - while (n-- > 0) - *l16++ = pix16fromY(*yp++); -} - -static void -XYZtoRGB24(float xyz[3], uint8 rgb[3]) -{ - double r, g, b; - /* assume CCIR-709 primaries */ - r = 2.690*xyz[0] + -1.276*xyz[1] + -0.414*xyz[2]; - g = -1.022*xyz[0] + 1.978*xyz[1] + 0.044*xyz[2]; - b = 0.061*xyz[0] + -0.224*xyz[1] + 1.163*xyz[2]; - /* assume 2.0 gamma for speed */ - /* could use integer sqrt approx., but this is probably faster */ - rgb[0] = (r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256.*sqrt(r)); - rgb[1] = (g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256.*sqrt(g)); - rgb[2] = (b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256.*sqrt(b)); -} - -static int -uv_encode(double u, double v) /* encode (u',v') coordinates */ -{ - register int vi, ui; - - if (v < UV_VSTART) - return(-1); - vi = (int)((v - UV_VSTART)*(1./UV_SQSIZ)); - if (vi >= UV_NVS) - return(-1); - if (u < uv_row[vi].ustart) - return(-1); - ui = (int)((u - uv_row[vi].ustart)*(1./UV_SQSIZ)); - if (ui >= uv_row[vi].nus) - return(-1); - return(uv_row[vi].ncum + ui); -} - -static int -uv_decode(double *up, double *vp, int c) /* decode (u',v') index */ -{ - int upper, lower; - register int ui, vi; - - if (c < 0 || c >= UV_NDIVS) - return(-1); - lower = 0; /* binary search */ - upper = UV_NVS; - do { - vi = (lower + upper) >> 1; - ui = c - uv_row[vi].ncum; - if (ui > 0) - lower = vi; - else if (ui < 0) - upper = vi; - else - break; - } while (upper - lower > 1); - vi = lower; - ui = c - uv_row[vi].ncum; - *up = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ; - *vp = UV_VSTART + (vi+.5)*UV_SQSIZ; - return(0); -} - -static void -pix24toXYZ(uint32 p, float XYZ[3]) -{ - int Le, Ce; - double L, u, v, s, x, y; - /* decode luminance */ - Le = p >> 14 & 0x3ff; - if (Le == 0) { - XYZ[0] = XYZ[1] = XYZ[2] = 0.; - return; - } - L = exp(LOGOF2/64.*(Le+.5) - LOGOF2*12.); - /* decode color */ - Ce = p & 0x3fff; - if (uv_decode(&u, &v, Ce) < 0) { - u = U_NEU; v = V_NEU; - } - s = 1./(6.*u - 16.*v + 12.); - x = 9.*u * s; - y = 4.*v * s; - /* convert to XYZ */ - XYZ[0] = (float)(x/y * L); - XYZ[1] = (float)L; - XYZ[2] = (float)((1.-x-y)/y * L); -} - -static uint32 -pix24fromXYZ(float XYZ[3]) -{ - int Le, Ce; - double L, u, v, s; - /* encode luminance */ - L = XYZ[1]; - if (L >= 16.) - Le = 0x3ff; - else if (L <= 1./4096.) - Le = 0; - else - Le = (int)(64.*(log2(L) + 12.)); - /* encode color */ - s = XYZ[0] + 15.*XYZ[1] + 3.*XYZ[2]; - if (s == 0.) { - u = U_NEU; - v = V_NEU; - } else { - u = 4.*XYZ[0] / s; - v = 9.*XYZ[1] / s; - } - Ce = uv_encode(u, v); - if (Ce < 0) - Ce = uv_encode(U_NEU, V_NEU); - /* combine encodings */ - return (Le << 14 | Ce); -} - -static void -Luv24toXYZ(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - float* xyz = (float*) op; - - while (n-- > 0) { - pix24toXYZ(*luv, xyz); - xyz += 3; - luv++; - } -} - -static void -Luv24toLuv48(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; - - while (n-- > 0) { - double u, v; - - *luv3++ = (int16)((*luv >> 12 & 0xffd) + 13314); - if (uv_decode(&u, &v, *luv&0x3fff) < 0) { - u = U_NEU; - v = V_NEU; - } - *luv3++ = (int16)(u * (1L<<15)); - *luv3++ = (int16)(v * (1L<<15)); - luv++; - } -} - -static void -Luv24toRGB(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - uint8* rgb = (uint8*) op; - - while (n-- > 0) { - float xyz[3]; - - pix24toXYZ(*luv++, xyz); - XYZtoRGB24(xyz, rgb); - rgb += 3; - } -} - -static void -Luv24fromXYZ(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - float* xyz = (float*) op; - - while (n-- > 0) { - *luv++ = pix24fromXYZ(xyz); - xyz += 3; - } -} - -static void -Luv24fromLuv48(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; - - while (n-- > 0) { - int Le, Ce; - - if (luv3[0] <= 0) - Le = 0; - else if (luv3[0] >= (1<<12)+3314) - Le = (1<<10) - 1; - else - Le = (luv3[0]-3314) >> 2; - Ce = uv_encode((luv[1]+.5)/(1<<15), (luv[2]+.5)/(1<<15)); - if (Ce < 0) - Ce = uv_encode(U_NEU, V_NEU); - *luv++ = (uint32)Le << 14 | Ce; - luv3 += 3; - } -} - -static void -pix32toXYZ(uint32 p, float XYZ[3]) -{ - double L, u, v, s, x, y; - /* decode luminance */ - L = pix16toY((int)p >> 16); - if (L == 0.) { - XYZ[0] = XYZ[1] = XYZ[2] = 0.; - return; - } - /* decode color */ - u = 1./UVSCALE * ((p>>8 & 0xff) + .5); - v = 1./UVSCALE * ((p & 0xff) + .5); - s = 1./(6.*u - 16.*v + 12.); - x = 9.*u * s; - y = 4.*v * s; - /* convert to XYZ */ - XYZ[0] = (float)(x/y * L); - XYZ[1] = (float)L; - XYZ[2] = (float)((1.-x-y)/y * L); -} - -static uint32 -pix32fromXYZ(float XYZ[3]) -{ - unsigned int Le, ue, ve; - double u, v, s; - /* encode luminance */ - Le = (unsigned int)pix16fromY(XYZ[1]); - /* encode color */ - s = XYZ[0] + 15.*XYZ[1] + 3.*XYZ[2]; - if (s == 0.) { - u = U_NEU; - v = V_NEU; - } else { - u = 4.*XYZ[0] / s; - v = 9.*XYZ[1] / s; - } - if (u <= 0.) ue = 0; - else ue = (unsigned int)(UVSCALE * u); - if (ue > 255) ue = 255; - if (v <= 0.) ve = 0; - else ve = (unsigned int)(UVSCALE * v); - if (ve > 255) ve = 255; - /* combine encodings */ - return (Le << 16 | ue << 8 | ve); -} - -static void -Luv32toXYZ(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - float* xyz = (float*) op; - - while (n-- > 0) { - pix32toXYZ(*luv++, xyz); - xyz += 3; - } -} - -static void -Luv32toLuv48(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; - - while (n-- > 0) { - double u, v; - - *luv3++ = (int16)(*luv >> 16); - u = 1./UVSCALE * ((*luv>>8 & 0xff) + .5); - v = 1./UVSCALE * ((*luv & 0xff) + .5); - *luv3++ = (int16)(u * (1L<<15)); - *luv3++ = (int16)(v * (1L<<15)); - luv++; - } -} - -static void -Luv32toRGB(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - uint8* rgb = (uint8*) op; - - while (n-- > 0) { - float xyz[3]; - - pix32toXYZ(*luv++, xyz); - XYZtoRGB24(xyz, rgb); - rgb += 3; - } -} - -static void -Luv32fromXYZ(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - float* xyz = (float*) op; - - while (n-- > 0) { - *luv++ = pix32fromXYZ(xyz); - xyz += 3; - } -} - -static void -Luv32fromLuv48(LogLuvState* sp, tidata_t op, int n) -{ - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; - - while (n-- > 0) { - *luv++ = (uint32)luv3[0] << 16 | - (luv3[1]*(uint32)(UVSCALE+.5) >> 7 & 0xff00) | - (luv3[2]*(uint32)(UVSCALE+.5) >> 15 & 0xff); - luv3 += 3; - } -} - -static void -_logLuvNop(LogLuvState* sp, tidata_t op, int n) -{ - (void) sp; (void) op; (void) n; -} - -static int -LogL16GuessDataFmt(TIFFDirectory *td) -{ -#define PACK(s,b,f) (((b)<<6)|((s)<<3)|(f)) - switch (PACK(td->td_samplesperpixel, td->td_bitspersample, td->td_sampleformat)) { - case PACK(1, 32, SAMPLEFORMAT_IEEEFP): - return (SGILOGDATAFMT_FLOAT); - case PACK(1, 16, SAMPLEFORMAT_VOID): - case PACK(1, 16, SAMPLEFORMAT_INT): - case PACK(1, 16, SAMPLEFORMAT_UINT): - return (SGILOGDATAFMT_16BIT); - case PACK(1, 8, SAMPLEFORMAT_VOID): - case PACK(1, 8, SAMPLEFORMAT_UINT): - return (SGILOGDATAFMT_8BIT); - } -#undef PACK - return (SGILOGDATAFMT_UNKNOWN); -} - -static int -LogL16InitState(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - LogLuvState* sp = DecoderState(tif); - static const char module[] = "LogL16InitState"; - - assert(sp != NULL); - assert(td->td_photometric == PHOTOMETRIC_LOGL); - - /* for some reason, we can't do this in TIFFInitLogL16 */ - if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN) - sp->user_datafmt = LogL16GuessDataFmt(td); - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->pixel_size = sizeof (float); - break; - case SGILOGDATAFMT_16BIT: - sp->pixel_size = sizeof (int16); - break; - case SGILOGDATAFMT_8BIT: - sp->pixel_size = sizeof (uint8); - break; - default: - TIFFError(tif->tif_name, - "No support for converting user data format to LogL"); - return (0); - } - sp->tbuflen = (short)(td->td_imagewidth * td->td_rowsperstrip); - sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (int16)); - if (sp->tbuf == NULL) { - TIFFError(module, "%s: No space for SGILog translation buffer", - tif->tif_name); - return (0); - } - return (1); -} - -static int -LogLuvGuessDataFmt(TIFFDirectory *td) -{ - int guess; - - /* - * If the user didn't tell us their datafmt, - * take our best guess from the bitspersample. - */ -#define PACK(a,b) (((a)<<3)|(b)) - switch (PACK(td->td_bitspersample, td->td_sampleformat)) { - case PACK(32, SAMPLEFORMAT_IEEEFP): - guess = SGILOGDATAFMT_FLOAT; - break; - case PACK(32, SAMPLEFORMAT_VOID): - case PACK(32, SAMPLEFORMAT_UINT): - case PACK(32, SAMPLEFORMAT_INT): - guess = SGILOGDATAFMT_RAW; - break; - case PACK(16, SAMPLEFORMAT_VOID): - case PACK(16, SAMPLEFORMAT_INT): - case PACK(16, SAMPLEFORMAT_UINT): - guess = SGILOGDATAFMT_16BIT; - break; - case PACK( 8, SAMPLEFORMAT_VOID): - case PACK( 8, SAMPLEFORMAT_UINT): - guess = SGILOGDATAFMT_8BIT; - break; - default: - guess = SGILOGDATAFMT_UNKNOWN; - break; -#undef PACK - } - /* - * Double-check samples per pixel. - */ - switch (td->td_samplesperpixel) { - case 1: - if (guess != SGILOGDATAFMT_RAW) - guess = SGILOGDATAFMT_UNKNOWN; - break; - case 3: - if (guess == SGILOGDATAFMT_RAW) - guess = SGILOGDATAFMT_UNKNOWN; - break; - default: - guess = SGILOGDATAFMT_UNKNOWN; - break; - } - return (guess); -} - -static int -LogLuvInitState(TIFF* tif) -{ - TIFFDirectory* td = &tif->tif_dir; - LogLuvState* sp = DecoderState(tif); - static const char module[] = "LogLuvInitState"; - - assert(sp != NULL); - assert(td->td_photometric == PHOTOMETRIC_LOGLUV); - - /* for some reason, we can't do this in TIFFInitLogLuv */ - if (td->td_planarconfig != PLANARCONFIG_CONTIG) { - TIFFError(module, - "SGILog compression cannot handle non-contiguous data"); - return (0); - } - if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN) - sp->user_datafmt = LogLuvGuessDataFmt(td); - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->pixel_size = 3*sizeof (float); - break; - case SGILOGDATAFMT_16BIT: - sp->pixel_size = 3*sizeof (int16); - break; - case SGILOGDATAFMT_RAW: - sp->pixel_size = sizeof (uint32); - break; - case SGILOGDATAFMT_8BIT: - sp->pixel_size = 3*sizeof (uint8); - break; - default: - TIFFError(tif->tif_name, - "No support for converting user data format to LogLuv"); - return (0); - } - sp->tbuflen = (short)(td->td_imagewidth * td->td_rowsperstrip); - sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (uint32)); - if (sp->tbuf == NULL) { - TIFFError(module, "%s: No space for SGILog translation buffer", - tif->tif_name); - return (0); - } - return (1); -} - -static int -LogLuvSetupDecode(TIFF* tif) -{ - LogLuvState* sp = DecoderState(tif); - TIFFDirectory* td = &tif->tif_dir; - - tif->tif_postdecode = _TIFFNoPostDecode; - switch (td->td_photometric) { - case PHOTOMETRIC_LOGLUV: - if (!LogLuvInitState(tif)) - break; - if (td->td_compression == COMPRESSION_SGILOG24) { - tif->tif_decoderow = LogLuvDecode24; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv24toXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv24toLuv48; - break; - case SGILOGDATAFMT_8BIT: - sp->tfunc = Luv24toRGB; - break; - } - } else { - tif->tif_decoderow = LogLuvDecode32; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv32toXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv32toLuv48; - break; - case SGILOGDATAFMT_8BIT: - sp->tfunc = Luv32toRGB; - break; - } - } - return (1); - case PHOTOMETRIC_LOGL: - if (!LogL16InitState(tif)) - break; - tif->tif_decoderow = LogL16Decode; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = L16toY; - break; - case SGILOGDATAFMT_8BIT: - sp->tfunc = L16toGry; - break; - } - return (1); - default: - TIFFError(tif->tif_name, - "Inappropriate photometric interpretation %d for SGILog compression; %s", - td->td_photometric, "must be either LogLUV or LogL"); - break; - } - return (0); -} - -static int -LogLuvSetupEncode(TIFF* tif) -{ - LogLuvState* sp = EncoderState(tif); - TIFFDirectory* td = &tif->tif_dir; - - switch (td->td_photometric) { - case PHOTOMETRIC_LOGLUV: - if (!LogLuvInitState(tif)) - break; - if (td->td_compression == COMPRESSION_SGILOG24) { - tif->tif_encoderow = LogLuvEncode24; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv24fromXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv24fromLuv48; - break; - case SGILOGDATAFMT_RAW: - break; - default: - goto notsupported; - } - } else { - tif->tif_encoderow = LogLuvEncode32; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv32fromXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv32fromLuv48; - break; - case SGILOGDATAFMT_RAW: - break; - default: - goto notsupported; - } - } - break; - case PHOTOMETRIC_LOGL: - if (!LogL16InitState(tif)) - break; - tif->tif_encoderow = LogL16Encode; - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = L16fromY; - break; - case SGILOGDATAFMT_16BIT: - break; - default: - goto notsupported; - } - break; - default: - TIFFError(tif->tif_name, - "Inappropriate photometric interpretation %d for SGILog compression; %s", - td->td_photometric, "must be either LogLUV or LogL"); - break; - } - return (1); -notsupported: - TIFFError(tif->tif_name, - "SGILog compression supported only for %s, or raw data", - td->td_photometric == PHOTOMETRIC_LOGL ? "Y, L" : "XYZ, Luv"); - return (0); -} - -static void -LogLuvClose(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - - /* - * For consistency, we always want to write out the same - * bitspersample and sampleformat for our TIFF file, - * regardless of the data format being used by the application. - * Since this routine is called after tags have been set but - * before they have been recorded in the file, we reset them here. - */ - td->td_samplesperpixel = - (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3; - td->td_bitspersample = 16; - td->td_sampleformat = SAMPLEFORMAT_INT; -} - -static void -LogLuvCleanup(TIFF* tif) -{ - LogLuvState* sp = (LogLuvState *)tif->tif_data; - - if (sp) { - if (sp->tbuf) - _TIFFfree(sp->tbuf); - _TIFFfree(sp); - tif->tif_data = NULL; - } -} - -static int -LogLuvVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - LogLuvState* sp = DecoderState(tif); - int bps, fmt; - - switch (tag) { - case TIFFTAG_SGILOGDATAFMT: - sp->user_datafmt = va_arg(ap, int); - /* - * Tweak the TIFF header so that the rest of libtiff knows what - * size of data will be passed between app and library, and - * assume that the app knows what it is doing and is not - * confused by these header manipulations... - */ - switch (sp->user_datafmt) { - case SGILOGDATAFMT_FLOAT: - bps = 32, fmt = SAMPLEFORMAT_IEEEFP; - break; - case SGILOGDATAFMT_16BIT: - bps = 16, fmt = SAMPLEFORMAT_INT; - break; - case SGILOGDATAFMT_RAW: - bps = 32, fmt = SAMPLEFORMAT_UINT; - break; - case SGILOGDATAFMT_8BIT: - bps = 8, fmt = SAMPLEFORMAT_UINT; - break; - default: - TIFFError(tif->tif_name, - "Unknown data format %d for LogLuv compression", - sp->user_datafmt); - return (0); - } - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, fmt); - /* - * Must recalculate sizes should bits/sample change. - */ - tif->tif_tilesize = TIFFTileSize(tif); - tif->tif_scanlinesize = TIFFScanlineSize(tif); - return (1); - default: - return (*sp->vsetparent)(tif, tag, ap); - } -} - -static int -LogLuvVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - LogLuvState *sp = (LogLuvState *)tif->tif_data; - - switch (tag) { - case TIFFTAG_SGILOGDATAFMT: - *va_arg(ap, int*) = sp->user_datafmt; - return (1); - default: - return (*sp->vgetparent)(tif, tag, ap); - } -} - -static const TIFFFieldInfo LogLuvFieldInfo[] = { - { TIFFTAG_SGILOGDATAFMT, 0, 0, TIFF_SHORT, FIELD_PSEUDO, - TRUE, FALSE, "SGILogDataFmt"} -}; - -int -TIFFInitSGILog(TIFF* tif, int scheme) -{ - static const char module[] = "TIFFInitSGILog"; - LogLuvState* sp; - - assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG); - - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LogLuvState)); - if (tif->tif_data == NULL) - goto bad; - sp = (LogLuvState*) tif->tif_data; - memset(sp, 0, sizeof (*sp)); - sp->user_datafmt = SGILOGDATAFMT_UNKNOWN; - sp->tfunc = _logLuvNop; - - /* - * Install codec methods. - * NB: tif_decoderow & tif_encoderow are filled - * in at setup time. - */ - tif->tif_setupdecode = LogLuvSetupDecode; - tif->tif_decodestrip = LogLuvDecodeStrip; - tif->tif_decodetile = LogLuvDecodeTile; - tif->tif_setupencode = LogLuvSetupEncode; - tif->tif_encodestrip = LogLuvEncodeStrip; - tif->tif_encodetile = LogLuvEncodeTile; - tif->tif_close = LogLuvClose; - tif->tif_cleanup = LogLuvCleanup; - - /* override SetField so we can handle our private pseudo-tag */ - _TIFFMergeFieldInfo(tif, LogLuvFieldInfo, N(LogLuvFieldInfo)); - sp->vgetparent = tif->tif_vgetfield; - tif->tif_vgetfield = LogLuvVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_vsetfield; - tif->tif_vsetfield = LogLuvVSetField; /* hook for codec tags */ - - return (1); -bad: - TIFFError(module, "%s: No space for LogLuv state block", tif->tif_name); - return (0); -} -#endif /* LOGLUV_SUPPORT */ diff --git a/freeimage241/Source/LibTIFF/tif_lzw.c b/freeimage241/Source/LibTIFF/tif_lzw.c deleted file mode 100644 index 1e27e6b..0000000 --- a/freeimage241/Source/LibTIFF/tif_lzw.c +++ /dev/null @@ -1,708 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_lzw.c,v 1.0 2001-04-13 00:42:33+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef LZW_SUPPORT -/* - * TIFF Library. - * Rev 5.0 Lempel-Ziv & Welch Compression Support - * - * This code is derived from the compress program whose code is - * derived from software contributed to Berkeley by James A. Woods, - * derived from original work by Spencer Thomas and Joseph Orost. - * - * The original Berkeley copyright notice appears below in its entirety. - */ -#include "tif_predict.h" - -#include -#include - -/* - * NB: The 5.0 spec describes a different algorithm than Aldus - * implements. Specifically, Aldus does code length transitions - * one code earlier than should be done (for real LZW). - * Earlier versions of this library implemented the correct - * LZW algorithm, but emitted codes in a bit order opposite - * to the TIFF spec. Thus, to maintain compatibility w/ Aldus - * we interpret MSB-LSB ordered codes to be images written w/ - * old versions of this library, but otherwise adhere to the - * Aldus "off by one" algorithm. - * - * Future revisions to the TIFF spec are expected to "clarify this issue". - */ -#define LZW_COMPAT /* include backwards compatibility code */ -/* - * Each strip of data is supposed to be terminated by a CODE_EOI. - * If the following #define is included, the decoder will also - * check for end-of-strip w/o seeing this code. This makes the - * library more robust, but also slower. - */ -#define LZW_CHECKEOS /* include checks for strips w/o EOI code */ - -#define MAXCODE(n) ((1L<<(n))-1) -/* - * The TIFF spec specifies that encoded bit - * strings range from 9 to 12 bits. - */ -#define BITS_MIN 9 /* start with 9 bits */ -#define BITS_MAX 12 /* max of 12 bit strings */ -/* predefined codes */ -#define CODE_CLEAR 256 /* code to clear string table */ -#define CODE_EOI 257 /* end-of-information code */ -#define CODE_FIRST 258 /* first free code entry */ -#define CODE_MAX MAXCODE(BITS_MAX) -#define HSIZE 9001L /* 91% occupancy */ -#define HSHIFT (13-8) -#ifdef LZW_COMPAT -/* NB: +1024 is for compatibility with old files */ -#define CSIZE (MAXCODE(BITS_MAX)+1024L) -#else -#define CSIZE (MAXCODE(BITS_MAX)+1L) -#endif - -/* - * State block for each open TIFF file using LZW - * compression/decompression. Note that the predictor - * state block must be first in this data structure. - */ -typedef struct { - TIFFPredictorState predict; /* predictor super class */ - - u_short nbits; /* # of bits/code */ - u_short maxcode; /* maximum code for lzw_nbits */ - u_short free_ent; /* next free entry in hash table */ - long nextdata; /* next bits of i/o */ - long nextbits; /* # of valid bits in lzw_nextdata */ -} LZWBaseState; - -#define lzw_nbits base.nbits -#define lzw_maxcode base.maxcode -#define lzw_free_ent base.free_ent -#define lzw_nextdata base.nextdata -#define lzw_nextbits base.nextbits - -/* - * Decoding-specific state. - */ -typedef struct code_ent { - struct code_ent *next; - u_short length; /* string len, including this token */ - u_char value; /* data value */ - u_char firstchar; /* first token of string */ -} code_t; - -typedef int (*decodeFunc)(TIFF*, tidata_t, tsize_t, tsample_t); - -typedef struct { - LZWBaseState base; - long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ - long dec_restart; /* restart count */ -#ifdef LZW_CHECKEOS - long dec_bitsleft; /* available bits in raw data */ -#endif - decodeFunc dec_decode; /* regular or backwards compatible */ - code_t* dec_codep; /* current recognized code */ - code_t* dec_oldcodep; /* previously recognized code */ - code_t* dec_free_entp; /* next free entry */ - code_t* dec_maxcodep; /* max available entry */ - code_t* dec_codetab; /* kept separate for small machines */ -} LZWDecodeState; - -/* - * Encoding-specific state. - */ -typedef uint16 hcode_t; /* codes fit in 16 bits */ -typedef struct { - long hash; - hcode_t code; -} hash_t; - -typedef struct { - LZWBaseState base; - int enc_oldcode; /* last code encountered */ - long enc_checkpoint; /* point at which to clear table */ -#define CHECK_GAP 10000 /* enc_ratio check interval */ - long enc_ratio; /* current compression ratio */ - long enc_incount; /* (input) data bytes encoded */ - long enc_outcount; /* encoded (output) bytes */ - tidata_t enc_rawlimit; /* bound on tif_rawdata buffer */ - hash_t* enc_hashtab; /* kept separate for small machines */ -} LZWEncodeState; - -#define LZWState(tif) ((LZWBaseState*) (tif)->tif_data) -#define DecoderState(tif) ((LZWDecodeState*) LZWState(tif)) -#define EncoderState(tif) ((LZWEncodeState*) LZWState(tif)) - -static int LZWDecode(TIFF*, tidata_t, tsize_t, tsample_t); -#ifdef LZW_COMPAT -static int LZWDecodeCompat(TIFF*, tidata_t, tsize_t, tsample_t); -#endif -static void cl_hash(LZWEncodeState*); - -/* - * LZW Decoder. - */ - -#ifdef LZW_CHECKEOS -/* - * This check shouldn't be necessary because each - * strip is suppose to be terminated with CODE_EOI. - */ -#define NextCode(_tif, _sp, _bp, _code, _get) { \ - if ((_sp)->dec_bitsleft < nbits) { \ - TIFFWarning(_tif->tif_name, \ - "LZWDecode: Strip %d not terminated with EOI code", \ - _tif->tif_curstrip); \ - _code = CODE_EOI; \ - } else { \ - _get(_sp,_bp,_code); \ - (_sp)->dec_bitsleft -= nbits; \ - } \ -} -#else -#define NextCode(tif, sp, bp, code, get) get(sp, bp, code) -#endif - -static int -LZWSetupDecode(TIFF* tif) -{ - LZWDecodeState* sp = DecoderState(tif); - static const char module[] = " LZWSetupDecode"; - int code; - - assert(sp != NULL); - if (sp->dec_codetab == NULL) { - sp->dec_codetab = (code_t*)_TIFFmalloc(CSIZE*sizeof (code_t)); - if (sp->dec_codetab == NULL) { - TIFFError(module, "No space for LZW code table"); - return (0); - } - /* - * Pre-load the table. - */ - for (code = 255; code >= 0; code--) { - sp->dec_codetab[code].value = code; - sp->dec_codetab[code].firstchar = code; - sp->dec_codetab[code].length = 1; - sp->dec_codetab[code].next = NULL; - } - } - return (1); -} - -/* - * Setup state for decoding a strip. - */ -static int -LZWPreDecode(TIFF* tif, tsample_t s) -{ - LZWDecodeState *sp = DecoderState(tif); - - (void) s; - assert(sp != NULL); - /* - * Check for old bit-reversed codes. - */ - if (tif->tif_rawdata[0] == 0 && (tif->tif_rawdata[1] & 0x1)) { -#ifdef LZW_COMPAT - if (!sp->dec_decode) { - TIFFWarning(tif->tif_name, - "Old-style LZW codes, convert file"); - /* - * Override default decoding methods with - * ones that deal with the old coding. - * Otherwise the predictor versions set - * above will call the compatibility routines - * through the dec_decode method. - */ - tif->tif_decoderow = LZWDecodeCompat; - tif->tif_decodestrip = LZWDecodeCompat; - tif->tif_decodetile = LZWDecodeCompat; - /* - * If doing horizontal differencing, must - * re-setup the predictor logic since we - * switched the basic decoder methods... - */ - (*tif->tif_setupdecode)(tif); - sp->dec_decode = LZWDecodeCompat; - } - sp->lzw_maxcode = MAXCODE(BITS_MIN); -#else /* !LZW_COMPAT */ - if (!sp->dec_decode) { - TIFFError(tif->tif_name, - "Old-style LZW codes not supported"); - sp->dec_decode = LZWDecode; - } - return (0); -#endif/* !LZW_COMPAT */ - } else { - sp->lzw_maxcode = MAXCODE(BITS_MIN)-1; - sp->dec_decode = LZWDecode; - } - sp->lzw_nbits = BITS_MIN; - sp->lzw_nextbits = 0; - sp->lzw_nextdata = 0; - - sp->dec_restart = 0; - sp->dec_nbitsmask = MAXCODE(BITS_MIN); -#ifdef LZW_CHECKEOS - sp->dec_bitsleft = tif->tif_rawcc << 3; -#endif - sp->dec_free_entp = sp->dec_codetab + CODE_FIRST; - /* - * Zero entries that are not yet filled in. We do - * this to guard against bogus input data that causes - * us to index into undefined entries. If you can - * come up with a way to safely bounds-check input codes - * while decoding then you can remove this operation. - */ - _TIFFmemset(sp->dec_free_entp, 0, (CSIZE-CODE_FIRST)*sizeof (code_t)); - sp->dec_oldcodep = &sp->dec_codetab[-1]; - sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask-1]; - return (1); -} - -/* - * Decode a "hunk of data". - */ -#define GetNextCode(sp, bp, code) { \ - nextdata = (nextdata<<8) | *(bp)++; \ - nextbits += 8; \ - if (nextbits < nbits) { \ - nextdata = (nextdata<<8) | *(bp)++; \ - nextbits += 8; \ - } \ - code = (hcode_t)((nextdata >> (nextbits-nbits)) & nbitsmask); \ - nextbits -= nbits; \ -} - -static void -codeLoop(TIFF* tif) -{ - TIFFError(tif->tif_name, - "LZWDecode: Bogus encoding, loop in the code table; scanline %d", - tif->tif_row); -} - -static int -LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) -{ - LZWDecodeState *sp = DecoderState(tif); - char *op = (char*) op0; - long occ = (long) occ0; - char *tp; - u_char *bp; - hcode_t code; - int len; - long nbits, nextbits, nextdata, nbitsmask; - code_t *codep, *free_entp, *maxcodep, *oldcodep; - - (void) s; - assert(sp != NULL); - /* - * Restart interrupted output operation. - */ - if (sp->dec_restart) { - long residue; - - codep = sp->dec_codep; - residue = codep->length - sp->dec_restart; - if (residue > occ) { - /* - * Residue from previous decode is sufficient - * to satisfy decode request. Skip to the - * start of the decoded string, place decoded - * values in the output buffer, and return. - */ - sp->dec_restart += occ; - do { - codep = codep->next; - } while (--residue > occ && codep); - if (codep) { - tp = op + occ; - do { - *--tp = codep->value; - codep = codep->next; - } while (--occ && codep); - } - return (1); - } - /* - * Residue satisfies only part of the decode request. - */ - op += residue, occ -= residue; - tp = op; - do { - int t; - --tp; - t = codep->value; - codep = codep->next; - *tp = t; - } while (--residue && codep); - sp->dec_restart = 0; - } - - bp = (u_char *)tif->tif_rawcp; - nbits = sp->lzw_nbits; - nextdata = sp->lzw_nextdata; - nextbits = sp->lzw_nextbits; - nbitsmask = sp->dec_nbitsmask; - oldcodep = sp->dec_oldcodep; - free_entp = sp->dec_free_entp; - maxcodep = sp->dec_maxcodep; - - while (occ > 0) { - NextCode(tif, sp, bp, code, GetNextCode); - if (code == CODE_EOI) - break; - if (code == CODE_CLEAR) { - free_entp = sp->dec_codetab + CODE_FIRST; - nbits = BITS_MIN; - nbitsmask = MAXCODE(BITS_MIN); - maxcodep = sp->dec_codetab + nbitsmask-1; - NextCode(tif, sp, bp, code, GetNextCode); - if (code == CODE_EOI) - break; - *op++ = (char)code, occ--; - oldcodep = sp->dec_codetab + code; - continue; - } - codep = sp->dec_codetab + code; - - /* - * Add the new entry to the code table. - */ - assert(&sp->dec_codetab[0] <= free_entp && free_entp < &sp->dec_codetab[CSIZE]); - free_entp->next = oldcodep; - free_entp->firstchar = free_entp->next->firstchar; - free_entp->length = free_entp->next->length+1; - free_entp->value = (codep < free_entp) ? - codep->firstchar : free_entp->firstchar; - if (++free_entp > maxcodep) { - if (++nbits > BITS_MAX) /* should not happen */ - nbits = BITS_MAX; - nbitsmask = MAXCODE(nbits); - maxcodep = sp->dec_codetab + nbitsmask-1; - } - oldcodep = codep; - if (code >= 256) { - /* - * Code maps to a string, copy string - * value to output (written in reverse). - */ - if (codep->length > occ) { - /* - * String is too long for decode buffer, - * locate portion that will fit, copy to - * the decode buffer, and setup restart - * logic for the next decoding call. - */ - sp->dec_codep = codep; - do { - codep = codep->next; - } while (codep && codep->length > occ); - if (codep) { - sp->dec_restart = occ; - tp = op + occ; - do { - *--tp = codep->value; - codep = codep->next; - } while (--occ && codep); - if (codep) - codeLoop(tif); - } - break; - } - len = codep->length; - tp = op + len; - do { - int t; - --tp; - t = codep->value; - codep = codep->next; - *tp = t; - } while (codep && tp > op); - if (codep) { - codeLoop(tif); - break; - } - op += len, occ -= len; - } else - *op++ = (char)code, occ--; - } - - tif->tif_rawcp = (tidata_t) bp; - sp->lzw_nbits = (u_short) nbits; - sp->lzw_nextdata = nextdata; - sp->lzw_nextbits = nextbits; - sp->dec_nbitsmask = nbitsmask; - sp->dec_oldcodep = oldcodep; - sp->dec_free_entp = free_entp; - sp->dec_maxcodep = maxcodep; - - if (occ > 0) { - TIFFError(tif->tif_name, - "LZWDecode: Not enough data at scanline %d (short %d bytes)", - tif->tif_row, occ); - return (0); - } - return (1); -} - -#ifdef LZW_COMPAT -/* - * Decode a "hunk of data" for old images. - */ -#define GetNextCodeCompat(sp, bp, code) { \ - nextdata |= (u_long) *(bp)++ << nextbits; \ - nextbits += 8; \ - if (nextbits < nbits) { \ - nextdata |= (u_long) *(bp)++ << nextbits; \ - nextbits += 8; \ - } \ - code = (hcode_t)(nextdata & nbitsmask); \ - nextdata >>= nbits; \ - nextbits -= nbits; \ -} - -static int -LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) -{ - LZWDecodeState *sp = DecoderState(tif); - char *op = (char*) op0; - long occ = (long) occ0; - char *tp; - u_char *bp; - int code, nbits; - long nextbits, nextdata, nbitsmask; - code_t *codep, *free_entp, *maxcodep, *oldcodep; - - (void) s; - assert(sp != NULL); - /* - * Restart interrupted output operation. - */ - if (sp->dec_restart) { - long residue; - - codep = sp->dec_codep; - residue = codep->length - sp->dec_restart; - if (residue > occ) { - /* - * Residue from previous decode is sufficient - * to satisfy decode request. Skip to the - * start of the decoded string, place decoded - * values in the output buffer, and return. - */ - sp->dec_restart += occ; - do { - codep = codep->next; - } while (--residue > occ); - tp = op + occ; - do { - *--tp = codep->value; - codep = codep->next; - } while (--occ); - return (1); - } - /* - * Residue satisfies only part of the decode request. - */ - op += residue, occ -= residue; - tp = op; - do { - *--tp = codep->value; - codep = codep->next; - } while (--residue); - sp->dec_restart = 0; - } - - bp = (u_char *)tif->tif_rawcp; - nbits = sp->lzw_nbits; - nextdata = sp->lzw_nextdata; - nextbits = sp->lzw_nextbits; - nbitsmask = sp->dec_nbitsmask; - oldcodep = sp->dec_oldcodep; - free_entp = sp->dec_free_entp; - maxcodep = sp->dec_maxcodep; - - while (occ > 0) { - NextCode(tif, sp, bp, code, GetNextCodeCompat); - if (code == CODE_EOI) - break; - if (code == CODE_CLEAR) { - free_entp = sp->dec_codetab + CODE_FIRST; - nbits = BITS_MIN; - nbitsmask = MAXCODE(BITS_MIN); - maxcodep = sp->dec_codetab + nbitsmask; - NextCode(tif, sp, bp, code, GetNextCodeCompat); - if (code == CODE_EOI) - break; - *op++ = code, occ--; - oldcodep = sp->dec_codetab + code; - continue; - } - codep = sp->dec_codetab + code; - - /* - * Add the new entry to the code table. - */ - assert(&sp->dec_codetab[0] <= free_entp && free_entp < &sp->dec_codetab[CSIZE]); - free_entp->next = oldcodep; - free_entp->firstchar = free_entp->next->firstchar; - free_entp->length = free_entp->next->length+1; - free_entp->value = (codep < free_entp) ? - codep->firstchar : free_entp->firstchar; - if (++free_entp > maxcodep) { - if (++nbits > BITS_MAX) /* should not happen */ - nbits = BITS_MAX; - nbitsmask = MAXCODE(nbits); - maxcodep = sp->dec_codetab + nbitsmask; - } - oldcodep = codep; - if (code >= 256) { - /* - * Code maps to a string, copy string - * value to output (written in reverse). - */ - if (codep->length > occ) { - /* - * String is too long for decode buffer, - * locate portion that will fit, copy to - * the decode buffer, and setup restart - * logic for the next decoding call. - */ - sp->dec_codep = codep; - do { - codep = codep->next; - } while (codep->length > occ); - sp->dec_restart = occ; - tp = op + occ; - do { - *--tp = codep->value; - codep = codep->next; - } while (--occ); - break; - } - op += codep->length, occ -= codep->length; - tp = op; - do { - *--tp = codep->value; - } while( (codep = codep->next) != NULL); - } else - *op++ = code, occ--; - } - - tif->tif_rawcp = (tidata_t) bp; - sp->lzw_nbits = nbits; - sp->lzw_nextdata = nextdata; - sp->lzw_nextbits = nextbits; - sp->dec_nbitsmask = nbitsmask; - sp->dec_oldcodep = oldcodep; - sp->dec_free_entp = free_entp; - sp->dec_maxcodep = maxcodep; - - if (occ > 0) { - TIFFError(tif->tif_name, - "LZWDecodeCompat: Not enough data at scanline %d (short %d bytes)", - tif->tif_row, occ); - return (0); - } - return (1); -} -#endif /* LZW_COMPAT */ - - - -static void -LZWCleanup(TIFF* tif) -{ - if (tif->tif_data) { - if (tif->tif_mode == O_RDONLY) { - if (DecoderState(tif)->dec_codetab) - _TIFFfree(DecoderState(tif)->dec_codetab); - } - _TIFFfree(tif->tif_data); - tif->tif_data = NULL; - } -} - -int -TIFFInitLZW(TIFF* tif, int scheme) -{ - assert(scheme == COMPRESSION_LZW); - /* - * Allocate state block so tag methods have storage to record values. - */ - if (tif->tif_mode == O_RDONLY) { - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWDecodeState)); - if (tif->tif_data == NULL) - goto bad; - DecoderState(tif)->dec_codetab = NULL; - DecoderState(tif)->dec_decode = NULL; - } - - /* - * Install codec methods. - */ - tif->tif_setupdecode = LZWSetupDecode; - tif->tif_predecode = LZWPreDecode; - tif->tif_decoderow = LZWDecode; - tif->tif_decodestrip = LZWDecode; - tif->tif_decodetile = LZWDecode; - tif->tif_cleanup = LZWCleanup; - /* - * Setup predictor setup. - */ - (void) TIFFPredictorInit(tif); - return (1); -bad: - TIFFError("TIFFInitLZW", "No space for LZW state block"); - return (0); -} - -/* - * Copyright (c) 1985, 1986 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * James A. Woods, derived from original work by Spencer Thomas - * and Joseph Orost. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ -#endif /* LZW_SUPPORT */ diff --git a/freeimage241/Source/LibTIFF/tif_msdos.c b/freeimage241/Source/LibTIFF/tif_msdos.c deleted file mode 100644 index 4cc0927..0000000 --- a/freeimage241/Source/LibTIFF/tif_msdos.c +++ /dev/null @@ -1,179 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_msdos.c,v 1.0 2001-04-13 00:42:34+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library MSDOS-specific Routines. - */ -#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(_MSC_VER) -#include /* for open, close, etc. function prototypes */ -#include -#endif -#include "tiffiop.h" - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (read((int) fd, buf, size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (write((int) fd, buf, size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return (lseek((int) fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (close((int) fd)); -} - -#include - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - struct stat sb; - return (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (void*) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - fd = open(name, m|O_BINARY, 0666); - if (fd < 0) { - TIFFError(module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -#ifdef __GNUC__ -extern char* malloc(); -extern char* realloc(); -#else -#include -#endif - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -msdosWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = msdosWarningHandler; - -static void -msdosErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler; diff --git a/freeimage241/Source/LibTIFF/tif_next.c b/freeimage241/Source/LibTIFF/tif_next.c deleted file mode 100644 index 22a1e4b..0000000 --- a/freeimage241/Source/LibTIFF/tif_next.c +++ /dev/null @@ -1,142 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_next.c,v 1.0 2001-04-13 00:42:34+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef NEXT_SUPPORT -/* - * TIFF Library. - * - * NeXT 2-bit Grey Scale Compression Algorithm Support - */ - -#define SETPIXEL(op, v) { \ - switch (npixels++ & 3) { \ - case 0: op[0] = (v) << 6; break; \ - case 1: op[0] |= (v) << 4; break; \ - case 2: op[0] |= (v) << 2; break; \ - case 3: *op++ |= (v); break; \ - } \ -} - -#define LITERALROW 0x00 -#define LITERALSPAN 0x40 -#define WHITE ((1<<2)-1) - -static int -NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - register u_char *bp, *op; - register tsize_t cc; - register int n; - tidata_t row; - tsize_t scanline; - - (void) s; - /* - * Each scanline is assumed to start off as all - * white (we assume a PhotometricInterpretation - * of ``min-is-black''). - */ - for (op = buf, cc = occ; cc-- > 0;) - *op++ = 0xff; - - bp = (u_char *)tif->tif_rawcp; - cc = tif->tif_rawcc; - scanline = tif->tif_scanlinesize; - for (row = buf; (long)occ > 0; occ -= scanline, row += scanline) { - n = *bp++, cc--; - switch (n) { - case LITERALROW: - /* - * The entire scanline is given as literal values. - */ - if (cc < scanline) - goto bad; - _TIFFmemcpy(row, bp, scanline); - bp += scanline; - cc -= scanline; - break; - case LITERALSPAN: { - int off; - /* - * The scanline has a literal span - * that begins at some offset. - */ - off = (bp[0] * 256) + bp[1]; - n = (bp[2] * 256) + bp[3]; - if (cc < 4+n) - goto bad; - _TIFFmemcpy(row+off, bp+4, n); - bp += 4+n; - cc -= 4+n; - break; - } - default: { - register int npixels = 0, grey; - u_long imagewidth = tif->tif_dir.td_imagewidth; - - /* - * The scanline is composed of a sequence - * of constant color ``runs''. We shift - * into ``run mode'' and interpret bytes - * as codes of the form - * until we've filled the scanline. - */ - op = row; - for (;;) { - grey = (n>>6) & 0x3; - n &= 0x3f; - while (n-- > 0) - SETPIXEL(op, grey); - if (npixels >= (int) imagewidth) - break; - if (cc == 0) - goto bad; - n = *bp++, cc--; - } - break; - } - } - } - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - return (1); -bad: - TIFFError(tif->tif_name, "NeXTDecode: Not enough data for scanline %ld", - (long) tif->tif_row); - return (0); -} - -int -TIFFInitNeXT(TIFF* tif, int scheme) -{ - (void) scheme; - tif->tif_decoderow = NeXTDecode; - tif->tif_decodestrip = NeXTDecode; - tif->tif_decodetile = NeXTDecode; - return (1); -} -#endif /* NEXT_SUPPORT */ diff --git a/freeimage241/Source/LibTIFF/tif_open.c b/freeimage241/Source/LibTIFF/tif_open.c deleted file mode 100644 index 2b68247..0000000 --- a/freeimage241/Source/LibTIFF/tif_open.c +++ /dev/null @@ -1,486 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_open.c,v 1.0 2001-04-13 00:42:34+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - */ -#include "tiffiop.h" - -void _TIFFSetDefaultCompressionState(TIFF* tif); - -static const long typemask[13] = { - 0L, /* TIFF_NOTYPE */ - 0x000000ffL, /* TIFF_BYTE */ - 0xffffffffL, /* TIFF_ASCII */ - 0x0000ffffL, /* TIFF_SHORT */ - 0xffffffffL, /* TIFF_LONG */ - 0xffffffffL, /* TIFF_RATIONAL */ - 0x000000ffL, /* TIFF_SBYTE */ - 0x000000ffL, /* TIFF_UNDEFINED */ - 0x0000ffffL, /* TIFF_SSHORT */ - 0xffffffffL, /* TIFF_SLONG */ - 0xffffffffL, /* TIFF_SRATIONAL */ - 0xffffffffL, /* TIFF_FLOAT */ - 0xffffffffL, /* TIFF_DOUBLE */ -}; -static const int bigTypeshift[13] = { - 0, /* TIFF_NOTYPE */ - 24, /* TIFF_BYTE */ - 0, /* TIFF_ASCII */ - 16, /* TIFF_SHORT */ - 0, /* TIFF_LONG */ - 0, /* TIFF_RATIONAL */ - 24, /* TIFF_SBYTE */ - 24, /* TIFF_UNDEFINED */ - 16, /* TIFF_SSHORT */ - 0, /* TIFF_SLONG */ - 0, /* TIFF_SRATIONAL */ - 0, /* TIFF_FLOAT */ - 0, /* TIFF_DOUBLE */ -}; -static const int litTypeshift[13] = { - 0, /* TIFF_NOTYPE */ - 0, /* TIFF_BYTE */ - 0, /* TIFF_ASCII */ - 0, /* TIFF_SHORT */ - 0, /* TIFF_LONG */ - 0, /* TIFF_RATIONAL */ - 0, /* TIFF_SBYTE */ - 0, /* TIFF_UNDEFINED */ - 0, /* TIFF_SSHORT */ - 0, /* TIFF_SLONG */ - 0, /* TIFF_SRATIONAL */ - 0, /* TIFF_FLOAT */ - 0, /* TIFF_DOUBLE */ -}; - -/* - * Initialize the shift & mask tables, and the - * byte swapping state according to the file - * contents and the machine architecture. - */ -static void -TIFFInitOrder(TIFF* tif, int magic, int bigendian) -{ - tif->tif_typemask = typemask; - if (magic == TIFF_BIGENDIAN) { - tif->tif_typeshift = bigTypeshift; - if (!bigendian) - tif->tif_flags |= TIFF_SWAB; - } else { - tif->tif_typeshift = litTypeshift; - if (bigendian) - tif->tif_flags |= TIFF_SWAB; - } -} - -int -_TIFFgetMode(const char* mode, const char* module) -{ - int m = -1; - - switch (mode[0]) { - case 'r': - m = O_RDONLY; - if (mode[1] == '+') - m = O_RDWR; - break; - case 'w': - case 'a': - m = O_RDWR|O_CREAT; - if (mode[0] == 'w') - m |= O_TRUNC; - break; - default: - TIFFError(module, "\"%s\": Bad mode", mode); - break; - } - return (m); -} - -TIFF* -TIFFClientOpen( - const char* name, const char* mode, - thandle_t clientdata, - TIFFReadWriteProc readproc, - TIFFReadWriteProc writeproc, - TIFFSeekProc seekproc, - TIFFCloseProc closeproc, - TIFFSizeProc sizeproc, - TIFFMapFileProc mapproc, - TIFFUnmapFileProc unmapproc -) -{ - static const char module[] = "TIFFClientOpen"; - TIFF *tif; - int m, bigendian; - const char* cp; - - m = _TIFFgetMode(mode, module); - if (m == -1) - goto bad2; - tif = (TIFF *)_TIFFmalloc(sizeof (TIFF) + strlen(name) + 1); - if (tif == NULL) { - TIFFError(module, "%s: Out of memory (TIFF structure)", name); - goto bad2; - } - _TIFFmemset(tif, 0, sizeof (*tif)); - tif->tif_name = (char *)tif + sizeof (TIFF); - strcpy(tif->tif_name, name); - tif->tif_mode = m &~ (O_CREAT|O_TRUNC); - tif->tif_curdir = (tdir_t) -1; /* non-existent directory */ - tif->tif_curoff = 0; - tif->tif_curstrip = (tstrip_t) -1; /* invalid strip */ - tif->tif_row = (uint32) -1; /* read/write pre-increment */ - tif->tif_clientdata = clientdata; - tif->tif_readproc = readproc; - tif->tif_writeproc = writeproc; - tif->tif_seekproc = seekproc; - tif->tif_closeproc = closeproc; - tif->tif_sizeproc = sizeproc; - tif->tif_mapproc = mapproc; - tif->tif_unmapproc = unmapproc; - _TIFFSetDefaultCompressionState(tif); /* setup default state */ - /* - * Default is to return data MSB2LSB and enable the - * use of memory-mapped files and strip chopping when - * a file is opened read-only. - */ - tif->tif_flags = FILLORDER_MSB2LSB; - if (m == O_RDONLY ) - tif->tif_flags |= TIFF_MAPPED; - -#ifdef STRIPCHOP_DEFAULT - if (m == O_RDONLY || m == O_RDWR) - tif->tif_flags |= STRIPCHOP_DEFAULT; -#endif - - { union { int32 i; char c[4]; } u; u.i = 1; bigendian = u.c[0] == 0; } - /* - * Process library-specific flags in the open mode string. - * The following flags may be used to control intrinsic library - * behaviour that may or may not be desirable (usually for - * compatibility with some application that claims to support - * TIFF but only supports some braindead idea of what the - * vendor thinks TIFF is): - * - * 'l' use little-endian byte order for creating a file - * 'b' use big-endian byte order for creating a file - * 'L' read/write information using LSB2MSB bit order - * 'B' read/write information using MSB2LSB bit order - * 'H' read/write information using host bit order - * 'M' enable use of memory-mapped files when supported - * 'm' disable use of memory-mapped files - * 'C' enable strip chopping support when reading - * 'c' disable strip chopping support - * - * The use of the 'l' and 'b' flags is strongly discouraged. - * These flags are provided solely because numerous vendors, - * typically on the PC, do not correctly support TIFF; they - * only support the Intel little-endian byte order. This - * support is not configured by default because it supports - * the violation of the TIFF spec that says that readers *MUST* - * support both byte orders. It is strongly recommended that - * you not use this feature except to deal with busted apps - * that write invalid TIFF. And even in those cases you should - * bang on the vendors to fix their software. - * - * The 'L', 'B', and 'H' flags are intended for applications - * that can optimize operations on data by using a particular - * bit order. By default the library returns data in MSB2LSB - * bit order for compatibiltiy with older versions of this - * library. Returning data in the bit order of the native cpu - * makes the most sense but also requires applications to check - * the value of the FillOrder tag; something they probabyl do - * not do right now. - * - * The 'M' and 'm' flags are provided because some virtual memory - * systems exhibit poor behaviour when large images are mapped. - * These options permit clients to control the use of memory-mapped - * files on a per-file basis. - * - * The 'C' and 'c' flags are provided because the library support - * for chopping up large strips into multiple smaller strips is not - * application-transparent and as such can cause problems. The 'c' - * option permits applications that only want to look at the tags, - * for example, to get the unadulterated TIFF tag information. - */ - for (cp = mode; *cp; cp++) - switch (*cp) { - case 'b': - if ((m&O_CREAT) && !bigendian) - tif->tif_flags |= TIFF_SWAB; - break; - case 'l': - if ((m&O_CREAT) && bigendian) - tif->tif_flags |= TIFF_SWAB; - break; - case 'B': - tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | - FILLORDER_MSB2LSB; - break; - case 'L': - tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | - FILLORDER_LSB2MSB; - break; - case 'H': - tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | - HOST_FILLORDER; - break; - case 'M': - if (m == O_RDONLY) - tif->tif_flags |= TIFF_MAPPED; - break; - case 'm': - if (m == O_RDONLY) - tif->tif_flags &= ~TIFF_MAPPED; - break; - case 'C': - if (m == O_RDONLY) - tif->tif_flags |= TIFF_STRIPCHOP; - break; - case 'c': - if (m == O_RDONLY) - tif->tif_flags &= ~TIFF_STRIPCHOP; - break; - } - /* - * Read in TIFF header. - */ - if (!ReadOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { - if (tif->tif_mode == O_RDONLY) { - TIFFError(name, "Cannot read TIFF header"); - goto bad; - } - /* - * Setup header and write. - */ - tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB - ? (bigendian ? TIFF_LITTLEENDIAN : TIFF_BIGENDIAN) - : (bigendian ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN); - tif->tif_header.tiff_version = TIFF_VERSION; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&tif->tif_header.tiff_version); - tif->tif_header.tiff_diroff = 0; /* filled in later */ - if (!WriteOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { - TIFFError(name, "Error writing TIFF header"); - goto bad; - } - /* - * Setup the byte order handling. - */ - TIFFInitOrder(tif, tif->tif_header.tiff_magic, bigendian); - /* - * Setup default directory. - */ - if (!TIFFDefaultDirectory(tif)) - goto bad; - tif->tif_diroff = 0; - return (tif); - } - /* - * Setup the byte order handling. - */ - if (tif->tif_header.tiff_magic != TIFF_BIGENDIAN && - tif->tif_header.tiff_magic != TIFF_LITTLEENDIAN) { - TIFFError(name, "Not a TIFF file, bad magic number %d (0x%x)", - tif->tif_header.tiff_magic, - tif->tif_header.tiff_magic); - goto bad; - } - TIFFInitOrder(tif, tif->tif_header.tiff_magic, bigendian); - /* - * Swap header if required. - */ - if (tif->tif_flags & TIFF_SWAB) { - TIFFSwabShort(&tif->tif_header.tiff_version); - TIFFSwabLong(&tif->tif_header.tiff_diroff); - } - /* - * Now check version (if needed, it's been byte-swapped). - * Note that this isn't actually a version number, it's a - * magic number that doesn't change (stupid). - */ - if (tif->tif_header.tiff_version != TIFF_VERSION) { - TIFFError(name, - "Not a TIFF file, bad version number %d (0x%x)", - tif->tif_header.tiff_version, - tif->tif_header.tiff_version); - goto bad; - } - tif->tif_flags |= TIFF_MYBUFFER; - tif->tif_rawcp = tif->tif_rawdata = 0; - tif->tif_rawdatasize = 0; - /* - * Setup initial directory. - */ - switch (mode[0]) { - case 'r': - tif->tif_nextdiroff = tif->tif_header.tiff_diroff; - /* - * Try to use a memory-mapped file if the client - * has not explicitly suppressed usage with the - * 'm' flag in the open mode (see above). - */ - if ((tif->tif_flags & TIFF_MAPPED) && - !TIFFMapFileContents(tif, (tdata_t*) &tif->tif_base, &tif->tif_size)) - tif->tif_flags &= ~TIFF_MAPPED; - if (TIFFReadDirectory(tif)) { - if( m != O_RDONLY - && tif->tif_dir.td_compression != COMPRESSION_NONE ) - { - TIFFError( name, - "Can't open a compressed TIFF file" - " with compression for update." ); - goto bad; - } - tif->tif_rawcc = -1; - tif->tif_flags |= TIFF_BUFFERSETUP; - return (tif); - } - break; - case 'a': - /* - * New directories are automatically append - * to the end of the directory chain when they - * are written out (see TIFFWriteDirectory). - */ - if (!TIFFDefaultDirectory(tif)) - goto bad; - return (tif); - } -bad: - tif->tif_mode = O_RDONLY; /* XXX avoid flush */ - TIFFClose(tif); - return ((TIFF*)0); -bad2: - (void) (*closeproc)(clientdata); - return ((TIFF*)0); -} - -/* - * Query functions to access private data. - */ - -/* - * Return open file's name. - */ -const char * -TIFFFileName(TIFF* tif) -{ - return (tif->tif_name); -} - -/* - * Return open file's I/O descriptor. - */ -int -TIFFFileno(TIFF* tif) -{ - return (tif->tif_fd); -} - -/* - * Return read/write mode. - */ -int -TIFFGetMode(TIFF* tif) -{ - return (tif->tif_mode); -} - -/* - * Return nonzero if file is organized in - * tiles; zero if organized as strips. - */ -int -TIFFIsTiled(TIFF* tif) -{ - return (isTiled(tif)); -} - -/* - * Return current row being read/written. - */ -uint32 -TIFFCurrentRow(TIFF* tif) -{ - return (tif->tif_row); -} - -/* - * Return index of the current directory. - */ -tdir_t -TIFFCurrentDirectory(TIFF* tif) -{ - return (tif->tif_curdir); -} - -/* - * Return current strip. - */ -tstrip_t -TIFFCurrentStrip(TIFF* tif) -{ - return (tif->tif_curstrip); -} - -/* - * Return current tile. - */ -ttile_t -TIFFCurrentTile(TIFF* tif) -{ - return (tif->tif_curtile); -} - -/* - * Return nonzero if the file has byte-swapped data. - */ -int -TIFFIsByteSwapped(TIFF* tif) -{ - return ((tif->tif_flags & TIFF_SWAB) != 0); -} - -/* - * Return nonzero if the data is returned up-sampled. - */ -int -TIFFIsUpSampled(TIFF* tif) -{ - return (isUpSampled(tif)); -} - -/* - * Return nonzero if the data is returned in MSB-to-LSB bit order. - */ -int -TIFFIsMSB2LSB(TIFF* tif) -{ - return (isFillOrder(tif, FILLORDER_MSB2LSB)); -} diff --git a/freeimage241/Source/LibTIFF/tif_packbits.c b/freeimage241/Source/LibTIFF/tif_packbits.c deleted file mode 100644 index 75cd86a..0000000 --- a/freeimage241/Source/LibTIFF/tif_packbits.c +++ /dev/null @@ -1,290 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_packbits.c,v 1.0 2001-04-13 00:42:35+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef PACKBITS_SUPPORT -/* - * TIFF Library. - * - * PackBits Compression Algorithm Support - */ -#include -#include - -static int -PackBitsPreEncode(TIFF* tif, tsample_t s) -{ - (void) s; - /* - * Calculate the scanline/tile-width size in bytes. - */ - if (isTiled(tif)) - tif->tif_data = (tidata_t) TIFFTileRowSize(tif); - else - tif->tif_data = (tidata_t) TIFFScanlineSize(tif); - return (1); -} - -/* - * NB: tidata is the type representing *(tidata_t); - * if tidata_t is made signed then this type must - * be adjusted accordingly. - */ -typedef unsigned char tidata; - -/* - * Encode a run of pixels. - */ -static int -PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) -{ - u_char* bp = (u_char*) buf; - tidata_t op, ep, lastliteral; - long n, slop; - int b; - enum { BASE, LITERAL, RUN, LITERAL_RUN } state; - - (void) s; - op = tif->tif_rawcp; - ep = tif->tif_rawdata + tif->tif_rawdatasize; - state = BASE; - lastliteral = 0; - while (cc > 0) { - /* - * Find the longest string of identical bytes. - */ - b = *bp++, cc--, n = 1; - for (; cc > 0 && b == *bp; cc--, bp++) - n++; - again: - if (op + 2 >= ep) { /* insure space for new data */ - /* - * Be careful about writing the last - * literal. Must write up to that point - * and then copy the remainder to the - * front of the buffer. - */ - if (state == LITERAL || state == LITERAL_RUN) { - slop = op - lastliteral; - tif->tif_rawcc += lastliteral - tif->tif_rawcp; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - while (slop-- > 0) - *op++ = *lastliteral++; - lastliteral = tif->tif_rawcp; - } else { - tif->tif_rawcc += op - tif->tif_rawcp; - if (!TIFFFlushData1(tif)) - return (-1); - op = tif->tif_rawcp; - } - } - switch (state) { - case BASE: /* initial state, set run/literal */ - if (n > 1) { - state = RUN; - if (n > 128) { - *op++ = (tidata) -127; - *op++ = b; - n -= 128; - goto again; - } - *op++ = (tidataval_t)(-(n-1)); - *op++ = b; - } else { - lastliteral = op; - *op++ = 0; - *op++ = b; - state = LITERAL; - } - break; - case LITERAL: /* last object was literal string */ - if (n > 1) { - state = LITERAL_RUN; - if (n > 128) { - *op++ = (tidata) -127; - *op++ = b; - n -= 128; - goto again; - } - *op++ = (tidataval_t)(-(n-1)); /* encode run */ - *op++ = b; - } else { /* extend literal */ - if (++(*lastliteral) == 127) - state = BASE; - *op++ = b; - } - break; - case RUN: /* last object was run */ - if (n > 1) { - if (n > 128) { - *op++ = (tidata) -127; - *op++ = b; - n -= 128; - goto again; - } - *op++ = (tidataval_t)(-(n-1)); - *op++ = b; - } else { - lastliteral = op; - *op++ = 0; - *op++ = b; - state = LITERAL; - } - break; - case LITERAL_RUN: /* literal followed by a run */ - /* - * Check to see if previous run should - * be converted to a literal, in which - * case we convert literal-run-literal - * to a single literal. - */ - if (n == 1 && op[-2] == (tidata) -1 && - *lastliteral < 126) { - state = (((*lastliteral) += 2) == 127 ? - BASE : LITERAL); - op[-2] = op[-1]; /* replicate */ - } else - state = RUN; - goto again; - } - } - tif->tif_rawcc += op - tif->tif_rawcp; - tif->tif_rawcp = op; - return (1); -} - -/* - * Encode a rectangular chunk of pixels. We break it up - * into row-sized pieces to insure that encoded runs do - * not span rows. Otherwise, there can be problems with - * the decoder if data is read, for example, by scanlines - * when it was encoded by strips. - */ -static int -PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - tsize_t rowsize = (tsize_t) tif->tif_data; - - assert(rowsize > 0); - -#ifdef YCBCR_SUPPORT - /* - * YCBCR data isn't really separable into rows, so we - * might as well encode the whole tile/strip as one chunk. - */ - if( tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR ) - rowsize = (tsize_t) tif->tif_data; -#endif - - while ((long)cc > 0) { - int chunk = rowsize; - - if( cc < chunk ) - chunk = cc; - - if (PackBitsEncode(tif, bp, chunk, s) < 0) - return (-1); - bp += chunk; - cc -= chunk; - } - return (1); -} - -static int -PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - char *bp; - tsize_t cc; - long n; - int b; - - (void) s; - bp = (char*) tif->tif_rawcp; - cc = tif->tif_rawcc; - while (cc > 0 && (long)occ > 0) { - n = (long) *bp++, cc--; - /* - * Watch out for compilers that - * don't sign extend chars... - */ - if (n >= 128) - n -= 256; - if (n < 0) { /* replicate next byte -n+1 times */ - if (n == -128) /* nop */ - continue; - n = -n + 1; - if( occ < n ) - { - TIFFWarning(tif->tif_name, - "PackBitsDecode: discarding %d bytes " - "to avoid buffer overrun", - n - occ); - } - occ -= n; - b = *bp++, cc--; - while (n-- > 0) - *op++ = b; - } else { /* copy next n+1 bytes literally */ - if (occ < n + 1) - { - TIFFWarning(tif->tif_name, - "PackBitsDecode: discarding %d bytes " - "to avoid buffer overrun", - n - occ + 1); - n = occ - 1; - } - _TIFFmemcpy(op, bp, ++n); - op += n; occ -= n; - bp += n; cc -= n; - } - } - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - if (occ > 0) { - TIFFError(tif->tif_name, - "PackBitsDecode: Not enough data for scanline %ld", - (long) tif->tif_row); - return (0); - } - return (1); -} - -int -TIFFInitPackBits(TIFF* tif, int scheme) -{ - (void) scheme; - tif->tif_decoderow = PackBitsDecode; - tif->tif_decodestrip = PackBitsDecode; - tif->tif_decodetile = PackBitsDecode; - tif->tif_preencode = PackBitsPreEncode; - tif->tif_encoderow = PackBitsEncode; - tif->tif_encodestrip = PackBitsEncodeChunk; - tif->tif_encodetile = PackBitsEncodeChunk; - return (1); -} -#endif /* PACKBITS_SUPPORT */ diff --git a/freeimage241/Source/LibTIFF/tif_pixarlog.c b/freeimage241/Source/LibTIFF/tif_pixarlog.c deleted file mode 100644 index 27f2a9d..0000000 --- a/freeimage241/Source/LibTIFF/tif_pixarlog.c +++ /dev/null @@ -1,1309 +0,0 @@ -/* - * Copyright (c) 1996-1997 Sam Leffler - * Copyright (c) 1996 Pixar - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Pixar, Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Pixar, Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef PIXARLOG_SUPPORT - -/* - * TIFF Library. - * PixarLog Compression Support - * - * Contributed by Dan McCoy. - * - * PixarLog film support uses the TIFF library to store companded - * 11 bit values into a tiff file, which are compressed using the - * zip compressor. - * - * The codec can take as input and produce as output 32-bit IEEE float values - * as well as 16-bit or 8-bit unsigned integer values. - * - * On writing any of the above are converted into the internal - * 11-bit log format. In the case of 8 and 16 bit values, the - * input is assumed to be unsigned linear color values that represent - * the range 0-1. In the case of IEEE values, the 0-1 range is assumed to - * be the normal linear color range, in addition over 1 values are - * accepted up to a value of about 25.0 to encode "hot" hightlights and such. - * The encoding is lossless for 8-bit values, slightly lossy for the - * other bit depths. The actual color precision should be better - * than the human eye can perceive with extra room to allow for - * error introduced by further image computation. As with any quantized - * color format, it is possible to perform image calculations which - * expose the quantization error. This format should certainly be less - * susceptable to such errors than standard 8-bit encodings, but more - * susceptable than straight 16-bit or 32-bit encodings. - * - * On reading the internal format is converted to the desired output format. - * The program can request which format it desires by setting the internal - * pseudo tag TIFFTAG_PIXARLOGDATAFMT to one of these possible values: - * PIXARLOGDATAFMT_FLOAT = provide IEEE float values. - * PIXARLOGDATAFMT_16BIT = provide unsigned 16-bit integer values - * PIXARLOGDATAFMT_8BIT = provide unsigned 8-bit integer values - * - * alternately PIXARLOGDATAFMT_8BITABGR provides unsigned 8-bit integer - * values with the difference that if there are exactly three or four channels - * (rgb or rgba) it swaps the channel order (bgr or abgr). - * - * PIXARLOGDATAFMT_11BITLOG provides the internal encoding directly - * packed in 16-bit values. However no tools are supplied for interpreting - * these values. - * - * "hot" (over 1.0) areas written in floating point get clamped to - * 1.0 in the integer data types. - * - * When the file is closed after writing, the bit depth and sample format - * are set always to appear as if 8-bit data has been written into it. - * That way a naive program unaware of the particulars of the encoding - * gets the format it is most likely able to handle. - * - * The codec does it's own horizontal differencing step on the coded - * values so the libraries predictor stuff should be turned off. - * The codec also handle byte swapping the encoded values as necessary - * since the library does not have the information necessary - * to know the bit depth of the raw unencoded buffer. - * - */ - -#include "tif_predict.h" -#include "zlib.h" -#include "zutil.h" - -#include -#include -#include -#include - -/* Tables for converting to/from 11 bit coded values */ - -#define TSIZE 2048 /* decode table size (11-bit tokens) */ -#define TSIZEP1 2049 /* Plus one for slop */ -#define ONE 1250 /* token value of 1.0 exactly */ -#define RATIO 1.004 /* nominal ratio for log part */ - -#define CODE_MASK 0x7ff /* 11 bits. */ - -static float Fltsize; -static float LogK1, LogK2; - -#define REPEAT(n, op) { int i; i=n; do { i--; op; } while (i>0); } - -static void -horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, - float *ToLinearF) -{ - register unsigned int cr, cg, cb, ca, mask; - register float t0, t1, t2, t3; - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - t0 = ToLinearF[cr = wp[0]]; - t1 = ToLinearF[cg = wp[1]]; - t2 = ToLinearF[cb = wp[2]]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - n -= 3; - while (n > 0) { - wp += 3; - op += 3; - n -= 3; - t0 = ToLinearF[(cr += wp[0]) & mask]; - t1 = ToLinearF[(cg += wp[1]) & mask]; - t2 = ToLinearF[(cb += wp[2]) & mask]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - } - } else if (stride == 4) { - t0 = ToLinearF[cr = wp[0]]; - t1 = ToLinearF[cg = wp[1]]; - t2 = ToLinearF[cb = wp[2]]; - t3 = ToLinearF[ca = wp[3]]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - n -= 4; - while (n > 0) { - wp += 4; - op += 4; - n -= 4; - t0 = ToLinearF[(cr += wp[0]) & mask]; - t1 = ToLinearF[(cg += wp[1]) & mask]; - t2 = ToLinearF[(cb += wp[2]) & mask]; - t3 = ToLinearF[(ca += wp[3]) & mask]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - } - } else { - REPEAT(stride, *op = ToLinearF[*wp&mask]; wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; *op = ToLinearF[*wp&mask]; wp++; op++) - n -= stride; - } - } - } -} - -static void -horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, - float *ToLinearF) -{ - register unsigned int cr, cg, cb, ca, mask; - register float t0, t1, t2, t3; - -#define SCALE12 2048.0 -#define CLAMP12(t) (((t) < 3071) ? (uint16) (t) : 3071) - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - t0 = ToLinearF[cr = wp[0]] * SCALE12; - t1 = ToLinearF[cg = wp[1]] * SCALE12; - t2 = ToLinearF[cb = wp[2]] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - n -= 3; - while (n > 0) { - wp += 3; - op += 3; - n -= 3; - t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12; - t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12; - t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - } - } else if (stride == 4) { - t0 = ToLinearF[cr = wp[0]] * SCALE12; - t1 = ToLinearF[cg = wp[1]] * SCALE12; - t2 = ToLinearF[cb = wp[2]] * SCALE12; - t3 = ToLinearF[ca = wp[3]] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - op[3] = CLAMP12(t3); - n -= 4; - while (n > 0) { - wp += 4; - op += 4; - n -= 4; - t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12; - t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12; - t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12; - t3 = ToLinearF[(ca += wp[3]) & mask] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - op[3] = CLAMP12(t3); - } - } else { - REPEAT(stride, t0 = ToLinearF[*wp&mask] * SCALE12; - *op = CLAMP12(t0); wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; t0 = ToLinearF[wp[stride]&mask]*SCALE12; - *op = CLAMP12(t0); wp++; op++) - n -= stride; - } - } - } -} - -static void -horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, - uint16 *ToLinear16) -{ - register unsigned int cr, cg, cb, ca, mask; - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - op[0] = ToLinear16[cr = wp[0]]; - op[1] = ToLinear16[cg = wp[1]]; - op[2] = ToLinear16[cb = wp[2]]; - n -= 3; - while (n > 0) { - wp += 3; - op += 3; - n -= 3; - op[0] = ToLinear16[(cr += wp[0]) & mask]; - op[1] = ToLinear16[(cg += wp[1]) & mask]; - op[2] = ToLinear16[(cb += wp[2]) & mask]; - } - } else if (stride == 4) { - op[0] = ToLinear16[cr = wp[0]]; - op[1] = ToLinear16[cg = wp[1]]; - op[2] = ToLinear16[cb = wp[2]]; - op[3] = ToLinear16[ca = wp[3]]; - n -= 4; - while (n > 0) { - wp += 4; - op += 4; - n -= 4; - op[0] = ToLinear16[(cr += wp[0]) & mask]; - op[1] = ToLinear16[(cg += wp[1]) & mask]; - op[2] = ToLinear16[(cb += wp[2]) & mask]; - op[3] = ToLinear16[(ca += wp[3]) & mask]; - } - } else { - REPEAT(stride, *op = ToLinear16[*wp&mask]; wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; *op = ToLinear16[*wp&mask]; wp++; op++) - n -= stride; - } - } - } -} - -/* - * Returns the log encoded 11-bit values with the horizontal - * differencing undone. - */ -static void -horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) -{ - register unsigned int cr, cg, cb, ca, mask; - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - op[0] = cr = wp[0]; op[1] = cg = wp[1]; op[2] = cb = wp[2]; - n -= 3; - while (n > 0) { - wp += 3; - op += 3; - n -= 3; - op[0] = (cr += wp[0]) & mask; - op[1] = (cg += wp[1]) & mask; - op[2] = (cb += wp[2]) & mask; - } - } else if (stride == 4) { - op[0] = cr = wp[0]; op[1] = cg = wp[1]; - op[2] = cb = wp[2]; op[3] = ca = wp[3]; - n -= 4; - while (n > 0) { - wp += 4; - op += 4; - n -= 4; - op[0] = (cr += wp[0]) & mask; - op[1] = (cg += wp[1]) & mask; - op[2] = (cb += wp[2]) & mask; - op[3] = (ca += wp[3]) & mask; - } - } else { - REPEAT(stride, *op = *wp&mask; wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; *op = *wp&mask; wp++; op++) - n -= stride; - } - } - } -} - -static void -horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, - unsigned char *ToLinear8) -{ - register unsigned int cr, cg, cb, ca, mask; - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - op[0] = ToLinear8[cr = wp[0]]; - op[1] = ToLinear8[cg = wp[1]]; - op[2] = ToLinear8[cb = wp[2]]; - n -= 3; - while (n > 0) { - n -= 3; - wp += 3; - op += 3; - op[0] = ToLinear8[(cr += wp[0]) & mask]; - op[1] = ToLinear8[(cg += wp[1]) & mask]; - op[2] = ToLinear8[(cb += wp[2]) & mask]; - } - } else if (stride == 4) { - op[0] = ToLinear8[cr = wp[0]]; - op[1] = ToLinear8[cg = wp[1]]; - op[2] = ToLinear8[cb = wp[2]]; - op[3] = ToLinear8[ca = wp[3]]; - n -= 4; - while (n > 0) { - n -= 4; - wp += 4; - op += 4; - op[0] = ToLinear8[(cr += wp[0]) & mask]; - op[1] = ToLinear8[(cg += wp[1]) & mask]; - op[2] = ToLinear8[(cb += wp[2]) & mask]; - op[3] = ToLinear8[(ca += wp[3]) & mask]; - } - } else { - REPEAT(stride, *op = ToLinear8[*wp&mask]; wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; *op = ToLinear8[*wp&mask]; wp++; op++) - n -= stride; - } - } - } -} - - -static void -horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op, - unsigned char *ToLinear8) -{ - register unsigned int cr, cg, cb, ca, mask; - register unsigned char t0, t1, t2, t3; - - if (n >= stride) { - mask = CODE_MASK; - if (stride == 3) { - op[0] = 0; - t1 = ToLinear8[cb = wp[2]]; - t2 = ToLinear8[cg = wp[1]]; - t3 = ToLinear8[cr = wp[0]]; - op[1] = t1; - op[2] = t2; - op[3] = t3; - n -= 3; - while (n > 0) { - n -= 3; - wp += 3; - op += 4; - op[0] = 0; - t1 = ToLinear8[(cb += wp[2]) & mask]; - t2 = ToLinear8[(cg += wp[1]) & mask]; - t3 = ToLinear8[(cr += wp[0]) & mask]; - op[1] = t1; - op[2] = t2; - op[3] = t3; - } - } else if (stride == 4) { - t0 = ToLinear8[ca = wp[3]]; - t1 = ToLinear8[cb = wp[2]]; - t2 = ToLinear8[cg = wp[1]]; - t3 = ToLinear8[cr = wp[0]]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - n -= 4; - while (n > 0) { - n -= 4; - wp += 4; - op += 4; - t0 = ToLinear8[(ca += wp[3]) & mask]; - t1 = ToLinear8[(cb += wp[2]) & mask]; - t2 = ToLinear8[(cg += wp[1]) & mask]; - t3 = ToLinear8[(cr += wp[0]) & mask]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - } - } else { - REPEAT(stride, *op = ToLinear8[*wp&mask]; wp++; op++) - n -= stride; - while (n > 0) { - REPEAT(stride, - wp[stride] += *wp; *op = ToLinear8[*wp&mask]; wp++; op++) - n -= stride; - } - } - } -} - -/* - * State block for each open TIFF - * file using PixarLog compression/decompression. - */ -typedef struct { - TIFFPredictorState predict; - z_stream stream; - uint16 *tbuf; - uint16 stride; - int state; - int user_datafmt; - int quality; -#define PLSTATE_INIT 1 - - TIFFVSetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - - float *ToLinearF; - uint16 *ToLinear16; - unsigned char *ToLinear8; - uint16 *FromLT2; - uint16 *From14; /* Really for 16-bit data, but we shift down 2 */ - uint16 *From8; - -} PixarLogState; - -static int -PixarLogMakeTables(PixarLogState *sp) -{ - -/* - * We make several tables here to convert between various external - * representations (float, 16-bit, and 8-bit) and the internal - * 11-bit companded representation. The 11-bit representation has two - * distinct regions. A linear bottom end up through .018316 in steps - * of about .000073, and a region of constant ratio up to about 25. - * These floating point numbers are stored in the main table ToLinearF. - * All other tables are derived from this one. The tables (and the - * ratios) are continuous at the internal seam. - */ - - int nlin, lt2size; - int i, j; - double b, c, linstep, max; - double k, v, dv, r, lr2, r2; - float *ToLinearF; - uint16 *ToLinear16; - unsigned char *ToLinear8; - uint16 *FromLT2; - uint16 *From14; /* Really for 16-bit data, but we shift down 2 */ - uint16 *From8; - - c = log(RATIO); - nlin = 1./c; /* nlin must be an integer */ - c = 1./nlin; - b = exp(-c*ONE); /* multiplicative scale factor [b*exp(c*ONE) = 1] */ - linstep = b*c*exp(1.); - - LogK1 = 1./c; /* if (v >= 2) token = k1*log(v*k2) */ - LogK2 = 1./b; - lt2size = (2./linstep)+1; - FromLT2 = (uint16 *)_TIFFmalloc(lt2size*sizeof(uint16)); - From14 = (uint16 *)_TIFFmalloc(16384*sizeof(uint16)); - From8 = (uint16 *)_TIFFmalloc(256*sizeof(uint16)); - ToLinearF = (float *)_TIFFmalloc(TSIZEP1 * sizeof(float)); - ToLinear16 = (uint16 *)_TIFFmalloc(TSIZEP1 * sizeof(uint16)); - ToLinear8 = (unsigned char *)_TIFFmalloc(TSIZEP1 * sizeof(unsigned char)); - if (FromLT2 == NULL || From14 == NULL || From8 == NULL || - ToLinearF == NULL || ToLinear16 == NULL || ToLinear8 == NULL) { - if (FromLT2) _TIFFfree(FromLT2); - if (From14) _TIFFfree(From14); - if (From8) _TIFFfree(From8); - if (ToLinearF) _TIFFfree(ToLinearF); - if (ToLinear16) _TIFFfree(ToLinear16); - if (ToLinear8) _TIFFfree(ToLinear8); - sp->FromLT2 = NULL; - sp->From14 = NULL; - sp->From8 = NULL; - sp->ToLinearF = NULL; - sp->ToLinear16 = NULL; - sp->ToLinear8 = NULL; - return 0; - } - - j = 0; - - for (i = 0; i < nlin; i++) { - v = i * linstep; - ToLinearF[j++] = v; - } - - for (i = nlin; i < TSIZE; i++) - ToLinearF[j++] = b*exp(c*i); - - ToLinearF[2048] = ToLinearF[2047]; - - for (i = 0; i < TSIZEP1; i++) { - v = ToLinearF[i]*65535.0 + 0.5; - ToLinear16[i] = (v > 65535.0) ? 65535 : v; - v = ToLinearF[i]*255.0 + 0.5; - ToLinear8[i] = (v > 255.0) ? 255 : v; - } - - j = 0; - for (i = 0; i < lt2size; i++) { - if ((i*linstep)*(i*linstep) > ToLinearF[j]*ToLinearF[j+1]) - j++; - FromLT2[i] = j; - } - - /* - * Since we lose info anyway on 16-bit data, we set up a 14-bit - * table and shift 16-bit values down two bits on input. - * saves a little table space. - */ - j = 0; - for (i = 0; i < 16384; i++) { - while ((i/16383.)*(i/16383.) > ToLinearF[j]*ToLinearF[j+1]) - j++; - From14[i] = j; - } - - j = 0; - for (i = 0; i < 256; i++) { - while ((i/255.)*(i/255.) > ToLinearF[j]*ToLinearF[j+1]) - j++; - From8[i] = j; - } - - Fltsize = lt2size/2; - - sp->ToLinearF = ToLinearF; - sp->ToLinear16 = ToLinear16; - sp->ToLinear8 = ToLinear8; - sp->FromLT2 = FromLT2; - sp->From14 = From14; - sp->From8 = From8; - - return 1; -} - -#define DecoderState(tif) ((PixarLogState*) (tif)->tif_data) -#define EncoderState(tif) ((PixarLogState*) (tif)->tif_data) - -static int PixarLogEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int PixarLogDecode(TIFF*, tidata_t, tsize_t, tsample_t); - -#define N(a) (sizeof(a)/sizeof(a[0])) -#define PIXARLOGDATAFMT_UNKNOWN -1 - -static int -PixarLogGuessDataFmt(TIFFDirectory *td) -{ - int guess = PIXARLOGDATAFMT_UNKNOWN; - int format = td->td_sampleformat; - - /* If the user didn't tell us his datafmt, - * take our best guess from the bitspersample. - */ - switch (td->td_bitspersample) { - case 32: - if (format == SAMPLEFORMAT_IEEEFP) - guess = PIXARLOGDATAFMT_FLOAT; - break; - case 16: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) - guess = PIXARLOGDATAFMT_16BIT; - break; - case 12: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_INT) - guess = PIXARLOGDATAFMT_12BITPICIO; - break; - case 11: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) - guess = PIXARLOGDATAFMT_11BITLOG; - break; - case 8: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) - guess = PIXARLOGDATAFMT_8BIT; - break; - } - - return guess; -} - -static int -PixarLogSetupDecode(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - PixarLogState* sp = DecoderState(tif); - static const char module[] = "PixarLogSetupDecode"; - - assert(sp != NULL); - - /* Make sure no byte swapping happens on the data - * after decompression. */ - tif->tif_postdecode = _TIFFNoPostDecode; - - /* for some reason, we can't do this in TIFFInitPixarLog */ - - sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? - td->td_samplesperpixel : 1); - sp->tbuf = (uint16 *) _TIFFmalloc(sp->stride * - td->td_imagewidth * td->td_rowsperstrip * sizeof(uint16)); - if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) - sp->user_datafmt = PixarLogGuessDataFmt(td); - if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) { - TIFFError(module, - "PixarLog compression can't handle bits depth/data format combination (depth: %d)", - td->td_bitspersample); - return (0); - } - - if (inflateInit(&sp->stream) != Z_OK) { - TIFFError(module, "%s: %s", tif->tif_name, sp->stream.msg); - return (0); - } else { - sp->state |= PLSTATE_INIT; - return (1); - } -} - -/* - * Setup state for decoding a strip. - */ -static int -PixarLogPreDecode(TIFF* tif, tsample_t s) -{ - TIFFDirectory *td = &tif->tif_dir; - PixarLogState* sp = DecoderState(tif); - - (void) s; - assert(sp != NULL); - sp->stream.next_in = tif->tif_rawdata; - sp->stream.avail_in = tif->tif_rawcc; - return (inflateReset(&sp->stream) == Z_OK); -} - -static int -PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - TIFFDirectory *td = &tif->tif_dir; - PixarLogState* sp = DecoderState(tif); - static const char module[] = "PixarLogDecode"; - int i, nsamples, llen; - uint16 *up; - - switch (sp->user_datafmt) { - case PIXARLOGDATAFMT_FLOAT: - nsamples = occ / sizeof(float); /* XXX float == 32 bits */ - break; - case PIXARLOGDATAFMT_16BIT: - case PIXARLOGDATAFMT_12BITPICIO: - case PIXARLOGDATAFMT_11BITLOG: - nsamples = occ / sizeof(uint16); /* XXX uint16 == 16 bits */ - break; - case PIXARLOGDATAFMT_8BIT: - case PIXARLOGDATAFMT_8BITABGR: - nsamples = occ; - break; - default: - TIFFError(tif->tif_name, - "%d bit input not supported in PixarLog", - td->td_bitspersample); - return 0; - } - - llen = sp->stride * td->td_imagewidth; - - (void) s; - assert(sp != NULL); - sp->stream.next_out = (unsigned char *) sp->tbuf; - sp->stream.avail_out = nsamples * sizeof(uint16); - do { - int state = inflate(&sp->stream, Z_PARTIAL_FLUSH); - if (state == Z_STREAM_END) { - break; /* XXX */ - } - if (state == Z_DATA_ERROR) { - TIFFError(module, - "%s: Decoding error at scanline %d, %s", - tif->tif_name, tif->tif_row, sp->stream.msg); - if (inflateSync(&sp->stream) != Z_OK) - return (0); - continue; - } - if (state != Z_OK) { - TIFFError(module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } while (sp->stream.avail_out > 0); - - /* hopefully, we got all the bytes we needed */ - if (sp->stream.avail_out != 0) { - TIFFError(module, - "%s: Not enough data at scanline %d (short %d bytes)", - tif->tif_name, tif->tif_row, sp->stream.avail_out); - return (0); - } - - up = sp->tbuf; - /* Swap bytes in the data if from a different endian machine. */ - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfShort(up, nsamples); - - for (i = 0; i < nsamples; i += llen, up += llen) { - switch (sp->user_datafmt) { - case PIXARLOGDATAFMT_FLOAT: - horizontalAccumulateF(up, llen, sp->stride, - (float *)op, sp->ToLinearF); - op += llen * sizeof(float); - break; - case PIXARLOGDATAFMT_16BIT: - horizontalAccumulate16(up, llen, sp->stride, - (uint16 *)op, sp->ToLinear16); - op += llen * sizeof(uint16); - break; - case PIXARLOGDATAFMT_12BITPICIO: - horizontalAccumulate12(up, llen, sp->stride, - (int16 *)op, sp->ToLinearF); - op += llen * sizeof(int16); - break; - case PIXARLOGDATAFMT_11BITLOG: - horizontalAccumulate11(up, llen, sp->stride, - (uint16 *)op); - op += llen * sizeof(uint16); - break; - case PIXARLOGDATAFMT_8BIT: - horizontalAccumulate8(up, llen, sp->stride, - (unsigned char *)op, sp->ToLinear8); - op += llen * sizeof(unsigned char); - break; - case PIXARLOGDATAFMT_8BITABGR: - horizontalAccumulate8abgr(up, llen, sp->stride, - (unsigned char *)op, sp->ToLinear8); - op += llen * sizeof(unsigned char); - break; - default: - TIFFError(tif->tif_name, - "PixarLogDecode: unsupported bits/sample: %d", - td->td_bitspersample); - return (0); - } - } - - return (1); -} - -static int -PixarLogSetupEncode(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - PixarLogState* sp = EncoderState(tif); - static const char module[] = "PixarLogSetupEncode"; - - assert(sp != NULL); - - /* for some reason, we can't do this in TIFFInitPixarLog */ - - sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? - td->td_samplesperpixel : 1); - sp->tbuf = (uint16 *) _TIFFmalloc(sp->stride * - td->td_imagewidth * td->td_rowsperstrip * sizeof(uint16)); - if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) - sp->user_datafmt = PixarLogGuessDataFmt(td); - if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) { - TIFFError(module, "PixarLog compression can't handle %d bit linear encodings", td->td_bitspersample); - return (0); - } - - if (deflateInit(&sp->stream, sp->quality) != Z_OK) { - TIFFError(module, "%s: %s", tif->tif_name, sp->stream.msg); - return (0); - } else { - sp->state |= PLSTATE_INIT; - return (1); - } -} - -/* - * Reset encoding state at the start of a strip. - */ -static int -PixarLogPreEncode(TIFF* tif, tsample_t s) -{ - TIFFDirectory *td = &tif->tif_dir; - PixarLogState *sp = EncoderState(tif); - - (void) s; - assert(sp != NULL); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - return (deflateReset(&sp->stream) == Z_OK); -} - -static void -horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) -{ - - register int r1, g1, b1, a1, r2, g2, b2, a2, mask; - register float fltsize = Fltsize; - -#define CLAMP(v) ( (v<(float)0.) ? 0 \ - : (v<(float)2.) ? FromLT2[(int)(v*fltsize)] \ - : (v>(float)24.2) ? 2047 \ - : LogK1*log(v*LogK2) + 0.5 ) - - mask = CODE_MASK; - if (n >= stride) { - if (stride == 3) { - r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); - n -= 3; - while (n > 0) { - n -= 3; - wp += 3; - ip += 3; - r1 = CLAMP(ip[0]); wp[0] = (r1-r2) & mask; r2 = r1; - g1 = CLAMP(ip[1]); wp[1] = (g1-g2) & mask; g2 = g1; - b1 = CLAMP(ip[2]); wp[2] = (b1-b2) & mask; b2 = b1; - } - } else if (stride == 4) { - r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]); - n -= 4; - while (n > 0) { - n -= 4; - wp += 4; - ip += 4; - r1 = CLAMP(ip[0]); wp[0] = (r1-r2) & mask; r2 = r1; - g1 = CLAMP(ip[1]); wp[1] = (g1-g2) & mask; g2 = g1; - b1 = CLAMP(ip[2]); wp[2] = (b1-b2) & mask; b2 = b1; - a1 = CLAMP(ip[3]); wp[3] = (a1-a2) & mask; a2 = a1; - } - } else { - ip += n - 1; /* point to last one */ - wp += n - 1; /* point to last one */ - n -= stride; - while (n > 0) { - REPEAT(stride, wp[0] = CLAMP(ip[0]); - wp[stride] -= wp[0]; - wp[stride] &= mask; - wp--; ip--) - n -= stride; - } - REPEAT(stride, wp[0] = CLAMP(ip[0]); wp--; ip--) - } - } -} - -static void -horizontalDifference16(unsigned short *ip, int n, int stride, - unsigned short *wp, uint16 *From14) -{ - register int r1, g1, b1, a1, r2, g2, b2, a2, mask; - -/* assumption is unsigned pixel values */ -#undef CLAMP -#define CLAMP(v) From14[(v) >> 2] - - mask = CODE_MASK; - if (n >= stride) { - if (stride == 3) { - r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); - n -= 3; - while (n > 0) { - n -= 3; - wp += 3; - ip += 3; - r1 = CLAMP(ip[0]); wp[0] = (r1-r2) & mask; r2 = r1; - g1 = CLAMP(ip[1]); wp[1] = (g1-g2) & mask; g2 = g1; - b1 = CLAMP(ip[2]); wp[2] = (b1-b2) & mask; b2 = b1; - } - } else if (stride == 4) { - r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]); - n -= 4; - while (n > 0) { - n -= 4; - wp += 4; - ip += 4; - r1 = CLAMP(ip[0]); wp[0] = (r1-r2) & mask; r2 = r1; - g1 = CLAMP(ip[1]); wp[1] = (g1-g2) & mask; g2 = g1; - b1 = CLAMP(ip[2]); wp[2] = (b1-b2) & mask; b2 = b1; - a1 = CLAMP(ip[3]); wp[3] = (a1-a2) & mask; a2 = a1; - } - } else { - ip += n - 1; /* point to last one */ - wp += n - 1; /* point to last one */ - n -= stride; - while (n > 0) { - REPEAT(stride, wp[0] = CLAMP(ip[0]); - wp[stride] -= wp[0]; - wp[stride] &= mask; - wp--; ip--) - n -= stride; - } - REPEAT(stride, wp[0] = CLAMP(ip[0]); wp--; ip--) - } - } -} - - -static void -horizontalDifference8(unsigned char *ip, int n, int stride, - unsigned short *wp, uint16 *From8) -{ - register int r1, g1, b1, a1, r2, g2, b2, a2, mask; - -#undef CLAMP -#define CLAMP(v) (From8[(v)]) - - mask = CODE_MASK; - if (n >= stride) { - if (stride == 3) { - r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); - n -= 3; - while (n > 0) { - n -= 3; - r1 = CLAMP(ip[3]); wp[3] = (r1-r2) & mask; r2 = r1; - g1 = CLAMP(ip[4]); wp[4] = (g1-g2) & mask; g2 = g1; - b1 = CLAMP(ip[5]); wp[5] = (b1-b2) & mask; b2 = b1; - wp += 3; - ip += 3; - } - } else if (stride == 4) { - r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]); - n -= 4; - while (n > 0) { - n -= 4; - r1 = CLAMP(ip[4]); wp[4] = (r1-r2) & mask; r2 = r1; - g1 = CLAMP(ip[5]); wp[5] = (g1-g2) & mask; g2 = g1; - b1 = CLAMP(ip[6]); wp[6] = (b1-b2) & mask; b2 = b1; - a1 = CLAMP(ip[7]); wp[7] = (a1-a2) & mask; a2 = a1; - wp += 4; - ip += 4; - } - } else { - wp += n + stride - 1; /* point to last one */ - ip += n + stride - 1; /* point to last one */ - n -= stride; - while (n > 0) { - REPEAT(stride, wp[0] = CLAMP(ip[0]); - wp[stride] -= wp[0]; - wp[stride] &= mask; - wp--; ip--) - n -= stride; - } - REPEAT(stride, wp[0] = CLAMP(ip[0]); wp--; ip--) - } - } -} - -/* - * Encode a chunk of pixels. - */ -static int -PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - TIFFDirectory *td = &tif->tif_dir; - PixarLogState *sp = EncoderState(tif); - static const char module[] = "PixarLogEncode"; - int i, n, llen; - unsigned short * up; - - (void) s; - - switch (sp->user_datafmt) { - case PIXARLOGDATAFMT_FLOAT: - n = cc / sizeof(float); /* XXX float == 32 bits */ - break; - case PIXARLOGDATAFMT_16BIT: - case PIXARLOGDATAFMT_12BITPICIO: - case PIXARLOGDATAFMT_11BITLOG: - n = cc / sizeof(uint16); /* XXX uint16 == 16 bits */ - break; - case PIXARLOGDATAFMT_8BIT: - case PIXARLOGDATAFMT_8BITABGR: - n = cc; - break; - default: - TIFFError(tif->tif_name, - "%d bit input not supported in PixarLog", - td->td_bitspersample); - return 0; - } - - llen = sp->stride * td->td_imagewidth; - - for (i = 0, up = sp->tbuf; i < n; i += llen, up += llen) { - switch (sp->user_datafmt) { - case PIXARLOGDATAFMT_FLOAT: - horizontalDifferenceF((float *)bp, llen, - sp->stride, up, sp->FromLT2); - bp += llen * sizeof(float); - break; - case PIXARLOGDATAFMT_16BIT: - horizontalDifference16((uint16 *)bp, llen, - sp->stride, up, sp->From14); - bp += llen * sizeof(uint16); - break; - case PIXARLOGDATAFMT_8BIT: - horizontalDifference8((unsigned char *)bp, llen, - sp->stride, up, sp->From8); - bp += llen * sizeof(unsigned char); - break; - default: - TIFFError(tif->tif_name, - "%d bit input not supported in PixarLog", - td->td_bitspersample); - return 0; - } - } - - sp->stream.next_in = (unsigned char *) sp->tbuf; - sp->stream.avail_in = n * sizeof(uint16); - - do { - if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { - TIFFError(module, "%s: Encoder error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - if (sp->stream.avail_out == 0) { - tif->tif_rawcc = tif->tif_rawdatasize; - TIFFFlushData1(tif); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - } - } while (sp->stream.avail_in > 0); - return (1); -} - -/* - * Finish off an encoded strip by flushing the last - * string and tacking on an End Of Information code. - */ - -static int -PixarLogPostEncode(TIFF* tif) -{ - PixarLogState *sp = EncoderState(tif); - static const char module[] = "PixarLogPostEncode"; - int state; - - sp->stream.avail_in = 0; - - do { - state = deflate(&sp->stream, Z_FINISH); - switch (state) { - case Z_STREAM_END: - case Z_OK: - if (sp->stream.avail_out != tif->tif_rawdatasize) { - tif->tif_rawcc = - tif->tif_rawdatasize - sp->stream.avail_out; - TIFFFlushData1(tif); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - } - break; - default: - TIFFError(module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } while (state != Z_STREAM_END); - return (1); -} - -static void -PixarLogClose(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - - /* In a really sneaky maneuver, on close, we covertly modify both - * bitspersample and sampleformat in the directory to indicate - * 8-bit linear. This way, the decode "just works" even for - * readers that don't know about PixarLog, or how to set - * the PIXARLOGDATFMT pseudo-tag. - */ - td->td_bitspersample = 8; - td->td_sampleformat = SAMPLEFORMAT_UINT; -} - -static void -PixarLogCleanup(TIFF* tif) -{ - PixarLogState* sp = (PixarLogState*) tif->tif_data; - - if (sp) { - if (sp->FromLT2) _TIFFfree(sp->FromLT2); - if (sp->From14) _TIFFfree(sp->From14); - if (sp->From8) _TIFFfree(sp->From8); - if (sp->ToLinearF) _TIFFfree(sp->ToLinearF); - if (sp->ToLinear16) _TIFFfree(sp->ToLinear16); - if (sp->ToLinear8) _TIFFfree(sp->ToLinear8); - if (sp->state&PLSTATE_INIT) { - if (tif->tif_mode == O_RDONLY) - inflateEnd(&sp->stream); - else - deflateEnd(&sp->stream); - } - if (sp->tbuf) - _TIFFfree(sp->tbuf); - _TIFFfree(sp); - tif->tif_data = NULL; - } -} - -static int -PixarLogVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - PixarLogState *sp = (PixarLogState *)tif->tif_data; - int result; - static const char module[] = "PixarLogVSetField"; - - switch (tag) { - case TIFFTAG_PIXARLOGQUALITY: - sp->quality = va_arg(ap, int); - if (tif->tif_mode != O_RDONLY && (sp->state&PLSTATE_INIT)) { - if (deflateParams(&sp->stream, - sp->quality, Z_DEFAULT_STRATEGY) != Z_OK) { - TIFFError(module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } - return (1); - case TIFFTAG_PIXARLOGDATAFMT: - sp->user_datafmt = va_arg(ap, int); - /* Tweak the TIFF header so that the rest of libtiff knows what - * size of data will be passed between app and library, and - * assume that the app knows what it is doing and is not - * confused by these header manipulations... - */ - switch (sp->user_datafmt) { - case PIXARLOGDATAFMT_8BIT: - case PIXARLOGDATAFMT_8BITABGR: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - break; - case PIXARLOGDATAFMT_11BITLOG: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - break; - case PIXARLOGDATAFMT_12BITPICIO: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); - break; - case PIXARLOGDATAFMT_16BIT: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - break; - case PIXARLOGDATAFMT_FLOAT: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 32); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); - break; - } - /* - * Must recalculate sizes should bits/sample change. - */ - tif->tif_tilesize = TIFFTileSize(tif); - tif->tif_scanlinesize = TIFFScanlineSize(tif); - result = 1; /* NB: pseudo tag */ - break; - default: - result = (*sp->vsetparent)(tif, tag, ap); - } - return (result); -} - -static int -PixarLogVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - PixarLogState *sp = (PixarLogState *)tif->tif_data; - - switch (tag) { - case TIFFTAG_PIXARLOGQUALITY: - *va_arg(ap, int*) = sp->quality; - break; - case TIFFTAG_PIXARLOGDATAFMT: - *va_arg(ap, int*) = sp->user_datafmt; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); -} - -static const TIFFFieldInfo pixarlogFieldInfo[] = { - {TIFFTAG_PIXARLOGDATAFMT,0,0,TIFF_ANY, FIELD_PSEUDO,FALSE,FALSE,""}, - {TIFFTAG_PIXARLOGQUALITY,0,0,TIFF_ANY, FIELD_PSEUDO,FALSE,FALSE,""} -}; - -int -TIFFInitPixarLog(TIFF* tif, int scheme) -{ - PixarLogState* sp; - - assert(scheme == COMPRESSION_PIXARLOG); - - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (PixarLogState)); - if (tif->tif_data == NULL) - goto bad; - sp = (PixarLogState*) tif->tif_data; - memset(sp, 0, sizeof (*sp)); - sp->stream.data_type = Z_BINARY; - sp->user_datafmt = PIXARLOGDATAFMT_UNKNOWN; - - /* - * Install codec methods. - */ - tif->tif_setupdecode = PixarLogSetupDecode; - tif->tif_predecode = PixarLogPreDecode; - tif->tif_decoderow = PixarLogDecode; - tif->tif_decodestrip = PixarLogDecode; - tif->tif_decodetile = PixarLogDecode; - tif->tif_setupencode = PixarLogSetupEncode; - tif->tif_preencode = PixarLogPreEncode; - tif->tif_postencode = PixarLogPostEncode; - tif->tif_encoderow = PixarLogEncode; - tif->tif_encodestrip = PixarLogEncode; - tif->tif_encodetile = PixarLogEncode; - tif->tif_close = PixarLogClose; - tif->tif_cleanup = PixarLogCleanup; - - /* Override SetField so we can handle our private pseudo-tag */ - _TIFFMergeFieldInfo(tif, pixarlogFieldInfo, N(pixarlogFieldInfo)); - sp->vgetparent = tif->tif_vgetfield; - tif->tif_vgetfield = PixarLogVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_vsetfield; - tif->tif_vsetfield = PixarLogVSetField; /* hook for codec tags */ - - /* Default values for codec-specific fields */ - sp->quality = Z_DEFAULT_COMPRESSION; /* default comp. level */ - sp->state = 0; - - /* we don't wish to use the predictor, - * the default is none, which predictor value 1 - */ - (void) TIFFPredictorInit(tif); - - /* - * build the companding tables - */ - PixarLogMakeTables(sp); - - return (1); -bad: - TIFFError("TIFFInitPixarLog", "No space for PixarLog state block"); - return (0); -} -#endif /* PIXARLOG_SUPPORT */ diff --git a/freeimage241/Source/LibTIFF/tif_predict.c b/freeimage241/Source/LibTIFF/tif_predict.c deleted file mode 100644 index c4d0a29..0000000 --- a/freeimage241/Source/LibTIFF/tif_predict.c +++ /dev/null @@ -1,461 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_predict.c,v 1.0 2001-04-13 00:42:35+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Predictor Tag Support (used by multiple codecs). - */ -#include "tiffiop.h" -#include "tif_predict.h" - -#include - -#define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data) - -static void horAcc8(TIFF*, tidata_t, tsize_t); -static void horAcc16(TIFF*, tidata_t, tsize_t); -static void swabHorAcc16(TIFF*, tidata_t, tsize_t); -static void horDiff8(TIFF*, tidata_t, tsize_t); -static void horDiff16(TIFF*, tidata_t, tsize_t); -static int PredictorDecodeRow(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorDecodeTile(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorEncodeRow(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorEncodeTile(TIFF*, tidata_t, tsize_t, tsample_t); - -static int -PredictorSetup(TIFF* tif) -{ - TIFFPredictorState* sp = PredictorState(tif); - TIFFDirectory* td = &tif->tif_dir; - - if (sp->predictor == 1) /* no differencing */ - return (1); - if (sp->predictor != 2) { - TIFFError(tif->tif_name, "\"Predictor\" value %d not supported", - sp->predictor); - return (0); - } - if (td->td_bitspersample != 8 && td->td_bitspersample != 16) { - TIFFError(tif->tif_name, - "Horizontal differencing \"Predictor\" not supported with %d-bit samples", - td->td_bitspersample); - return (0); - } - sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? - td->td_samplesperpixel : 1); - /* - * Calculate the scanline/tile-width size in bytes. - */ - if (isTiled(tif)) - sp->rowsize = TIFFTileRowSize(tif); - else - sp->rowsize = TIFFScanlineSize(tif); - return (1); -} - -static int -PredictorSetupDecode(TIFF* tif) -{ - TIFFPredictorState* sp = PredictorState(tif); - TIFFDirectory* td = &tif->tif_dir; - - if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif)) - return (0); - if (sp->predictor == 2) { - switch (td->td_bitspersample) { - case 8: sp->pfunc = horAcc8; break; - case 16: sp->pfunc = horAcc16; break; - } - /* - * Override default decoding method with - * one that does the predictor stuff. - */ - sp->coderow = tif->tif_decoderow; - tif->tif_decoderow = PredictorDecodeRow; - sp->codestrip = tif->tif_decodestrip; - tif->tif_decodestrip = PredictorDecodeTile; - sp->codetile = tif->tif_decodetile; - tif->tif_decodetile = PredictorDecodeTile; - /* - * If the data is horizontally differenced - * 16-bit data that requires byte-swapping, - * then it must be byte swapped before the - * accumulation step. We do this with a - * special-purpose routine and override the - * normal post decoding logic that the library - * setup when the directory was read. - */ - if (tif->tif_flags&TIFF_SWAB) { - if (sp->pfunc == horAcc16) { - sp->pfunc = swabHorAcc16; - tif->tif_postdecode = _TIFFNoPostDecode; - } /* else handle 32-bit case... */ - } - } - return (1); -} - -static int -PredictorSetupEncode(TIFF* tif) -{ - TIFFPredictorState* sp = PredictorState(tif); - TIFFDirectory* td = &tif->tif_dir; - - if (!(*sp->setupencode)(tif) || !PredictorSetup(tif)) - return (0); - if (sp->predictor == 2) { - switch (td->td_bitspersample) { - case 8: sp->pfunc = horDiff8; break; - case 16: sp->pfunc = horDiff16; break; - } - /* - * Override default encoding method with - * one that does the predictor stuff. - */ - sp->coderow = tif->tif_encoderow; - tif->tif_encoderow = PredictorEncodeRow; - sp->codestrip = tif->tif_encodestrip; - tif->tif_encodestrip = PredictorEncodeTile; - sp->codetile = tif->tif_encodetile; - tif->tif_encodetile = PredictorEncodeTile; - } - return (1); -} - -#define REPEAT4(n, op) \ - switch (n) { \ - default: { int i; for (i = n-4; i > 0; i--) { op; } } \ - case 4: op; \ - case 3: op; \ - case 2: op; \ - case 1: op; \ - case 0: ; \ - } - -static void -horAcc8(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - TIFFPredictorState* sp = PredictorState(tif); - tsize_t stride = sp->stride; - - char* cp = (char*) cp0; - if (cc > stride) { - cc -= stride; - /* - * Pipeline the most common cases. - */ - if (stride == 3) { - u_int cr = cp[0]; - u_int cg = cp[1]; - u_int cb = cp[2]; - do { - cc -= 3, cp += 3; - cp[0] = (cr += cp[0]); - cp[1] = (cg += cp[1]); - cp[2] = (cb += cp[2]); - } while ((int32) cc > 0); - } else if (stride == 4) { - u_int cr = cp[0]; - u_int cg = cp[1]; - u_int cb = cp[2]; - u_int ca = cp[3]; - do { - cc -= 4, cp += 4; - cp[0] = (cr += cp[0]); - cp[1] = (cg += cp[1]); - cp[2] = (cb += cp[2]); - cp[3] = (ca += cp[3]); - } while ((int32) cc > 0); - } else { - do { - REPEAT4(stride, cp[stride] += *cp; cp++) - cc -= stride; - } while ((int32) cc > 0); - } - } -} - -static void -swabHorAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - TIFFPredictorState* sp = PredictorState(tif); - tsize_t stride = sp->stride; - uint16* wp = (uint16*) cp0; - tsize_t wc = cc / 2; - - if (wc > stride) { - TIFFSwabArrayOfShort(wp, wc); - wc -= stride; - do { - REPEAT4(stride, wp[stride] += wp[0]; wp++) - wc -= stride; - } while ((int32) wc > 0); - } -} - -static void -horAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - tsize_t stride = PredictorState(tif)->stride; - uint16* wp = (uint16*) cp0; - tsize_t wc = cc / 2; - - if (wc > stride) { - wc -= stride; - do { - REPEAT4(stride, wp[stride] += wp[0]; wp++) - wc -= stride; - } while ((int32) wc > 0); - } -} - -/* - * Decode a scanline and apply the predictor routine. - */ -static int -PredictorDecodeRow(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) -{ - TIFFPredictorState *sp = PredictorState(tif); - - assert(sp != NULL); - assert(sp->coderow != NULL); - assert(sp->pfunc != NULL); - if ((*sp->coderow)(tif, op0, occ0, s)) { - (*sp->pfunc)(tif, op0, occ0); - return (1); - } else - return (0); -} - -/* - * Decode a tile/strip and apply the predictor routine. - * Note that horizontal differencing must be done on a - * row-by-row basis. The width of a "row" has already - * been calculated at pre-decode time according to the - * strip/tile dimensions. - */ -static int -PredictorDecodeTile(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) -{ - TIFFPredictorState *sp = PredictorState(tif); - - assert(sp != NULL); - assert(sp->codetile != NULL); - if ((*sp->codetile)(tif, op0, occ0, s)) { - tsize_t rowsize = sp->rowsize; - assert(rowsize > 0); - assert(sp->pfunc != NULL); - while ((long)occ0 > 0) { - (*sp->pfunc)(tif, op0, (tsize_t) rowsize); - occ0 -= rowsize; - op0 += rowsize; - } - return (1); - } else - return (0); -} - -static void -horDiff8(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - TIFFPredictorState* sp = PredictorState(tif); - tsize_t stride = sp->stride; - char* cp = (char*) cp0; - - if (cc > stride) { - cc -= stride; - /* - * Pipeline the most common cases. - */ - if (stride == 3) { - int r1, g1, b1; - int r2 = cp[0]; - int g2 = cp[1]; - int b2 = cp[2]; - do { - r1 = cp[3]; cp[3] = r1-r2; r2 = r1; - g1 = cp[4]; cp[4] = g1-g2; g2 = g1; - b1 = cp[5]; cp[5] = b1-b2; b2 = b1; - cp += 3; - } while ((int32)(cc -= 3) > 0); - } else if (stride == 4) { - int r1, g1, b1, a1; - int r2 = cp[0]; - int g2 = cp[1]; - int b2 = cp[2]; - int a2 = cp[3]; - do { - r1 = cp[4]; cp[4] = r1-r2; r2 = r1; - g1 = cp[5]; cp[5] = g1-g2; g2 = g1; - b1 = cp[6]; cp[6] = b1-b2; b2 = b1; - a1 = cp[7]; cp[7] = a1-a2; a2 = a1; - cp += 4; - } while ((int32)(cc -= 4) > 0); - } else { - cp += cc - 1; - do { - REPEAT4(stride, cp[stride] -= cp[0]; cp--) - } while ((int32)(cc -= stride) > 0); - } - } -} - -static void -horDiff16(TIFF* tif, tidata_t cp0, tsize_t cc) -{ - TIFFPredictorState* sp = PredictorState(tif); - tsize_t stride = sp->stride; - int16 *wp = (int16*) cp0; - tsize_t wc = cc/2; - - if (wc > stride) { - wc -= stride; - wp += wc - 1; - do { - REPEAT4(stride, wp[stride] -= wp[0]; wp--) - wc -= stride; - } while ((int32) wc > 0); - } -} - -static int -PredictorEncodeRow(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - TIFFPredictorState *sp = PredictorState(tif); - - assert(sp != NULL); - assert(sp->pfunc != NULL); - assert(sp->coderow != NULL); -/* XXX horizontal differencing alters user's data XXX */ - (*sp->pfunc)(tif, bp, cc); - return ((*sp->coderow)(tif, bp, cc, s)); -} - -static int -PredictorEncodeTile(TIFF* tif, tidata_t bp0, tsize_t cc0, tsample_t s) -{ - TIFFPredictorState *sp = PredictorState(tif); - tsize_t cc = cc0, rowsize; - u_char* bp = bp0; - - assert(sp != NULL); - assert(sp->pfunc != NULL); - assert(sp->codetile != NULL); - rowsize = sp->rowsize; - assert(rowsize > 0); - while ((long)cc > 0) { - (*sp->pfunc)(tif, bp, (tsize_t) rowsize); - cc -= rowsize; - bp += rowsize; - } - return ((*sp->codetile)(tif, bp0, cc0, s)); -} - -#define FIELD_PREDICTOR (FIELD_CODEC+0) /* XXX */ - -static const TIFFFieldInfo predictFieldInfo[] = { - { TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, FIELD_PREDICTOR, - FALSE, FALSE, "Predictor" }, -}; -#define N(a) (sizeof (a) / sizeof (a[0])) - -static int -PredictorVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - TIFFPredictorState *sp = PredictorState(tif); - - switch (tag) { - case TIFFTAG_PREDICTOR: - sp->predictor = (uint16) va_arg(ap, int); - TIFFSetFieldBit(tif, FIELD_PREDICTOR); - break; - default: - return (*sp->vsetparent)(tif, tag, ap); - } - tif->tif_flags |= TIFF_DIRTYDIRECT; - return (1); -} - -static int -PredictorVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - TIFFPredictorState *sp = PredictorState(tif); - - switch (tag) { - case TIFFTAG_PREDICTOR: - *va_arg(ap, uint16*) = sp->predictor; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); -} - -static void -PredictorPrintDir(TIFF* tif, FILE* fd, long flags) -{ - TIFFPredictorState* sp = PredictorState(tif); - - (void) flags; - if (TIFFFieldSet(tif,FIELD_PREDICTOR)) { - fprintf(fd, " Predictor: "); - switch (sp->predictor) { - case 1: fprintf(fd, "none "); break; - case 2: fprintf(fd, "horizontal differencing "); break; - } - fprintf(fd, "%u (0x%x)\n", sp->predictor, sp->predictor); - } - if (sp->printdir) - (*sp->printdir)(tif, fd, flags); -} - -int -TIFFPredictorInit(TIFF* tif) -{ - TIFFPredictorState* sp = PredictorState(tif); - - /* - * Merge codec-specific tag information and - * override parent get/set field methods. - */ - _TIFFMergeFieldInfo(tif, predictFieldInfo, N(predictFieldInfo)); - sp->vgetparent = tif->tif_vgetfield; - tif->tif_vgetfield = PredictorVGetField;/* hook for predictor tag */ - sp->vsetparent = tif->tif_vsetfield; - tif->tif_vsetfield = PredictorVSetField;/* hook for predictor tag */ - sp->printdir = tif->tif_printdir; - tif->tif_printdir = PredictorPrintDir; /* hook for predictor tag */ - - sp->setupdecode = tif->tif_setupdecode; - tif->tif_setupdecode = PredictorSetupDecode; - sp->setupencode = tif->tif_setupencode; - tif->tif_setupencode = PredictorSetupEncode; - - sp->predictor = 1; /* default value */ - sp->pfunc = NULL; /* no predictor routine */ - return (1); -} diff --git a/freeimage241/Source/LibTIFF/tif_predict.h b/freeimage241/Source/LibTIFF/tif_predict.h deleted file mode 100644 index 475aca1..0000000 --- a/freeimage241/Source/LibTIFF/tif_predict.h +++ /dev/null @@ -1,61 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_predict.h,v 1.0 2001-04-13 00:42:35+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1995-1997 Sam Leffler - * Copyright (c) 1995-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFPREDICT_ -#define _TIFFPREDICT_ -/* - * ``Library-private'' Support for the Predictor Tag - */ - -/* - * Codecs that want to support the Predictor tag must place - * this structure first in their private state block so that - * the predictor code can cast tif_data to find its state. - */ -typedef struct { - int predictor; /* predictor tag value */ - int stride; /* sample stride over data */ - tsize_t rowsize; /* tile/strip row size */ - - TIFFPostMethod pfunc; /* horizontal differencer/accumulator */ - TIFFCodeMethod coderow; /* parent codec encode/decode row */ - TIFFCodeMethod codestrip; /* parent codec encode/decode strip */ - TIFFCodeMethod codetile; /* parent codec encode/decode tile */ - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - TIFFPrintMethod printdir; /* super-class method */ - TIFFBoolMethod setupdecode; /* super-class method */ - TIFFBoolMethod setupencode; /* super-class method */ -} TIFFPredictorState; - -#if defined(__cplusplus) -extern "C" { -#endif -extern int TIFFPredictorInit(TIFF*); -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFPREDICT_ */ diff --git a/freeimage241/Source/LibTIFF/tif_print.c b/freeimage241/Source/LibTIFF/tif_print.c deleted file mode 100644 index be61108..0000000 --- a/freeimage241/Source/LibTIFF/tif_print.c +++ /dev/null @@ -1,525 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_print.c,v 1.0 2001-04-13 00:42:36+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Directory Printing Support - */ -#include "tiffiop.h" -#include - -#include - -static const char *photoNames[] = { - "min-is-white", /* PHOTOMETRIC_MINISWHITE */ - "min-is-black", /* PHOTOMETRIC_MINISBLACK */ - "RGB color", /* PHOTOMETRIC_RGB */ - "palette color (RGB from colormap)", /* PHOTOMETRIC_PALETTE */ - "transparency mask", /* PHOTOMETRIC_MASK */ - "separated", /* PHOTOMETRIC_SEPARATED */ - "YCbCr", /* PHOTOMETRIC_YCBCR */ - "7 (0x7)", - "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */ -}; -#define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0])) - -static const char *orientNames[] = { - "0 (0x0)", - "row 0 top, col 0 lhs", /* ORIENTATION_TOPLEFT */ - "row 0 top, col 0 rhs", /* ORIENTATION_TOPRIGHT */ - "row 0 bottom, col 0 rhs", /* ORIENTATION_BOTRIGHT */ - "row 0 bottom, col 0 lhs", /* ORIENTATION_BOTLEFT */ - "row 0 lhs, col 0 top", /* ORIENTATION_LEFTTOP */ - "row 0 rhs, col 0 top", /* ORIENTATION_RIGHTTOP */ - "row 0 rhs, col 0 bottom", /* ORIENTATION_RIGHTBOT */ - "row 0 lhs, col 0 bottom", /* ORIENTATION_LEFTBOT */ -}; -#define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0])) - -/* - * Print the contents of the current directory - * to the specified stdio file stream. - */ -void -TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) -{ - register TIFFDirectory *td; - char *sep; - uint16 i; - long l, n; - - fprintf(fd, "TIFF Directory at offset 0x%lx\n", tif->tif_diroff); - td = &tif->tif_dir; - if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) { - fprintf(fd, " Subfile Type:"); - sep = " "; - if (td->td_subfiletype & FILETYPE_REDUCEDIMAGE) { - fprintf(fd, "%sreduced-resolution image", sep); - sep = "/"; - } - if (td->td_subfiletype & FILETYPE_PAGE) { - fprintf(fd, "%smulti-page document", sep); - sep = "/"; - } - if (td->td_subfiletype & FILETYPE_MASK) - fprintf(fd, "%stransparency mask", sep); - fprintf(fd, " (%lu = 0x%lx)\n", - (long) td->td_subfiletype, (long) td->td_subfiletype); - } - if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) { - fprintf(fd, " Image Width: %lu Image Length: %lu", - (u_long) td->td_imagewidth, (u_long) td->td_imagelength); - if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) - fprintf(fd, " Image Depth: %lu", - (u_long) td->td_imagedepth); - fprintf(fd, "\n"); - } - - /* Begin Pixar */ - if (TIFFFieldSet(tif,FIELD_IMAGEFULLWIDTH) || - TIFFFieldSet(tif,FIELD_IMAGEFULLLENGTH)) { - fprintf(fd, " Pixar Full Image Width: %lu Full Image Length: %lu\n", - (u_long) td->td_imagefullwidth, - (u_long) td->td_imagefulllength); - } - if (TIFFFieldSet(tif,FIELD_TEXTUREFORMAT)) - _TIFFprintAsciiTag(fd, "Texture Format", td->td_textureformat); - if (TIFFFieldSet(tif,FIELD_WRAPMODES)) - _TIFFprintAsciiTag(fd, "Texture Wrap Modes", td->td_wrapmodes); - if (TIFFFieldSet(tif,FIELD_FOVCOT)) - fprintf(fd, " Field of View Cotangent: %g\n", td->td_fovcot); - if (TIFFFieldSet(tif,FIELD_MATRIX_WORLDTOSCREEN)) { - typedef float Matrix[4][4]; - Matrix* m = (Matrix*)td->td_matrixWorldToScreen; - - fprintf(fd, " Matrix NP:\n\t%g %g %g %g\n\t%g %g %g %g\n\t%g %g %g %g\n\t%g %g %g %g\n", - (*m)[0][0], (*m)[0][1], (*m)[0][2], (*m)[0][3], - (*m)[1][0], (*m)[1][1], (*m)[1][2], (*m)[1][3], - (*m)[2][0], (*m)[2][1], (*m)[2][2], (*m)[2][3], - (*m)[3][0], (*m)[3][1], (*m)[3][2], (*m)[3][3]); - } - if (TIFFFieldSet(tif,FIELD_MATRIX_WORLDTOCAMERA)) { - typedef float Matrix[4][4]; - Matrix* m = (Matrix*)td->td_matrixWorldToCamera; - - fprintf(fd, " Matrix Nl:\n\t%g %g %g %g\n\t%g %g %g %g\n\t%g %g %g %g\n\t%g %g %g %g\n", - (*m)[0][0], (*m)[0][1], (*m)[0][2], (*m)[0][3], - (*m)[1][0], (*m)[1][1], (*m)[1][2], (*m)[1][3], - (*m)[2][0], (*m)[2][1], (*m)[2][2], (*m)[2][3], - (*m)[3][0], (*m)[3][1], (*m)[3][2], (*m)[3][3]); - } - /* End Pixar */ - - if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) { - fprintf(fd, " Tile Width: %lu Tile Length: %lu", - (u_long) td->td_tilewidth, (u_long) td->td_tilelength); - if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) - fprintf(fd, " Tile Depth: %lu", - (u_long) td->td_tiledepth); - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif,FIELD_RESOLUTION)) { - fprintf(fd, " Resolution: %g, %g", - td->td_xresolution, td->td_yresolution); - if (TIFFFieldSet(tif,FIELD_RESOLUTIONUNIT)) { - switch (td->td_resolutionunit) { - case RESUNIT_NONE: - fprintf(fd, " (unitless)"); - break; - case RESUNIT_INCH: - fprintf(fd, " pixels/inch"); - break; - case RESUNIT_CENTIMETER: - fprintf(fd, " pixels/cm"); - break; - default: - fprintf(fd, " (unit %u = 0x%x)", - td->td_resolutionunit, - td->td_resolutionunit); - break; - } - } - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif,FIELD_POSITION)) - fprintf(fd, " Position: %g, %g\n", - td->td_xposition, td->td_yposition); - if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) - fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample); - if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) { - fprintf(fd, " Sample Format: "); - switch (td->td_sampleformat) { - case SAMPLEFORMAT_VOID: - fprintf(fd, "void\n"); - break; - case SAMPLEFORMAT_INT: - fprintf(fd, "signed integer\n"); - break; - case SAMPLEFORMAT_UINT: - fprintf(fd, "unsigned integer\n"); - break; - case SAMPLEFORMAT_IEEEFP: - fprintf(fd, "IEEE floating point\n"); - break; - case SAMPLEFORMAT_COMPLEXINT: - fprintf(fd, "complex signed integer\n"); - break; - case SAMPLEFORMAT_COMPLEXIEEEFP: - fprintf(fd, "complex IEEE floating point\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_sampleformat, td->td_sampleformat); - break; - } - } - if (TIFFFieldSet(tif,FIELD_COMPRESSION)) { - const TIFFCodec* c = TIFFFindCODEC(td->td_compression); - fprintf(fd, " Compression Scheme: "); - if (c) - fprintf(fd, "%s\n", c->name); - else - fprintf(fd, "%u (0x%x)\n", - td->td_compression, td->td_compression); - } - if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) { - fprintf(fd, " Photometric Interpretation: "); - if (td->td_photometric < NPHOTONAMES) - fprintf(fd, "%s\n", photoNames[td->td_photometric]); - else { - switch (td->td_photometric) { - case PHOTOMETRIC_LOGL: - fprintf(fd, "CIE Log2(L)\n"); - break; - case PHOTOMETRIC_LOGLUV: - fprintf(fd, "CIE Log2(L) (u',v')\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_photometric, td->td_photometric); - break; - } - } - } - if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES) && td->td_extrasamples) { - fprintf(fd, " Extra Samples: %u<", td->td_extrasamples); - sep = ""; - for (i = 0; i < td->td_extrasamples; i++) { - switch (td->td_sampleinfo[i]) { - case EXTRASAMPLE_UNSPECIFIED: - fprintf(fd, "%sunspecified", sep); - break; - case EXTRASAMPLE_ASSOCALPHA: - fprintf(fd, "%sassoc-alpha", sep); - break; - case EXTRASAMPLE_UNASSALPHA: - fprintf(fd, "%sunassoc-alpha", sep); - break; - default: - fprintf(fd, "%s%u (0x%x)", sep, - td->td_sampleinfo[i], td->td_sampleinfo[i]); - break; - } - sep = ", "; - } - fprintf(fd, ">\n"); - } - if (TIFFFieldSet(tif,FIELD_STONITS)) { - fprintf(fd, " Sample to Nits conversion factor: %.4e\n", - td->td_stonits); - } -#ifdef CMYK_SUPPORT - if (TIFFFieldSet(tif,FIELD_INKSET)) { - fprintf(fd, " Ink Set: "); - switch (td->td_inkset) { - case INKSET_CMYK: - fprintf(fd, "CMYK\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_inkset, td->td_inkset); - break; - } - } - if (TIFFFieldSet(tif,FIELD_INKNAMES)) { - char* cp; - fprintf(fd, " Ink Names: "); - i = td->td_samplesperpixel; - sep = ""; - for (cp = td->td_inknames; i > 0; cp = strchr(cp,'\0')+1, i--) { - fprintf(fd, "%s", sep); - _TIFFprintAscii(fd, cp); - sep = ", "; - } - } - if (TIFFFieldSet(tif,FIELD_NUMBEROFINKS)) - fprintf(fd, " Number of Inks: %u\n", td->td_ninks); - if (TIFFFieldSet(tif,FIELD_DOTRANGE)) - fprintf(fd, " Dot Range: %u-%u\n", - td->td_dotrange[0], td->td_dotrange[1]); - if (TIFFFieldSet(tif,FIELD_TARGETPRINTER)) - _TIFFprintAsciiTag(fd, "Target Printer", td->td_targetprinter); -#endif - if (TIFFFieldSet(tif,FIELD_THRESHHOLDING)) { - fprintf(fd, " Thresholding: "); - switch (td->td_threshholding) { - case THRESHHOLD_BILEVEL: - fprintf(fd, "bilevel art scan\n"); - break; - case THRESHHOLD_HALFTONE: - fprintf(fd, "halftone or dithered scan\n"); - break; - case THRESHHOLD_ERRORDIFFUSE: - fprintf(fd, "error diffused\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_threshholding, td->td_threshholding); - break; - } - } - if (TIFFFieldSet(tif,FIELD_FILLORDER)) { - fprintf(fd, " FillOrder: "); - switch (td->td_fillorder) { - case FILLORDER_MSB2LSB: - fprintf(fd, "msb-to-lsb\n"); - break; - case FILLORDER_LSB2MSB: - fprintf(fd, "lsb-to-msb\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_fillorder, td->td_fillorder); - break; - } - } -#ifdef YCBCR_SUPPORT - if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) - fprintf(fd, " YCbCr Subsampling: %u, %u\n", - td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1]); - if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { - fprintf(fd, " YCbCr Positioning: "); - switch (td->td_ycbcrpositioning) { - case YCBCRPOSITION_CENTERED: - fprintf(fd, "centered\n"); - break; - case YCBCRPOSITION_COSITED: - fprintf(fd, "cosited\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_ycbcrpositioning, td->td_ycbcrpositioning); - break; - } - } - if (TIFFFieldSet(tif,FIELD_YCBCRCOEFFICIENTS)) - fprintf(fd, " YCbCr Coefficients: %g, %g, %g\n", - td->td_ycbcrcoeffs[0], - td->td_ycbcrcoeffs[1], - td->td_ycbcrcoeffs[2]); -#endif - if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) - fprintf(fd, " Halftone Hints: light %u dark %u\n", - td->td_halftonehints[0], td->td_halftonehints[1]); - if (TIFFFieldSet(tif,FIELD_ARTIST)) - _TIFFprintAsciiTag(fd, "Artist", td->td_artist); - if (TIFFFieldSet(tif,FIELD_DATETIME)) - _TIFFprintAsciiTag(fd, "Date & Time", td->td_datetime); - if (TIFFFieldSet(tif,FIELD_HOSTCOMPUTER)) - _TIFFprintAsciiTag(fd, "Host Computer", td->td_hostcomputer); - if (TIFFFieldSet(tif,FIELD_SOFTWARE)) - _TIFFprintAsciiTag(fd, "Software", td->td_software); - if (TIFFFieldSet(tif,FIELD_DOCUMENTNAME)) - _TIFFprintAsciiTag(fd, "Document Name", td->td_documentname); - if (TIFFFieldSet(tif,FIELD_IMAGEDESCRIPTION)) - _TIFFprintAsciiTag(fd, "Image Description", td->td_imagedescription); - if (TIFFFieldSet(tif,FIELD_MAKE)) - _TIFFprintAsciiTag(fd, "Make", td->td_make); - if (TIFFFieldSet(tif,FIELD_MODEL)) - _TIFFprintAsciiTag(fd, "Model", td->td_model); - if (TIFFFieldSet(tif,FIELD_ORIENTATION)) { - fprintf(fd, " Orientation: "); - if (td->td_orientation < NORIENTNAMES) - fprintf(fd, "%s\n", orientNames[td->td_orientation]); - else - fprintf(fd, "%u (0x%x)\n", - td->td_orientation, td->td_orientation); - } - if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) - fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel); - if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) { - fprintf(fd, " Rows/Strip: "); - if (td->td_rowsperstrip == (uint32) -1) - fprintf(fd, "(infinite)\n"); - else - fprintf(fd, "%lu\n", (u_long) td->td_rowsperstrip); - } - if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) - fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue); - if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) - fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); - if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) - fprintf(fd, " SMin Sample Value: %g\n", - td->td_sminsamplevalue); - if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) - fprintf(fd, " SMax Sample Value: %g\n", - td->td_smaxsamplevalue); - if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) { - fprintf(fd, " Planar Configuration: "); - switch (td->td_planarconfig) { - case PLANARCONFIG_CONTIG: - fprintf(fd, "single image plane\n"); - break; - case PLANARCONFIG_SEPARATE: - fprintf(fd, "separate image planes\n"); - break; - default: - fprintf(fd, "%u (0x%x)\n", - td->td_planarconfig, td->td_planarconfig); - break; - } - } - if (TIFFFieldSet(tif,FIELD_PAGENAME)) - _TIFFprintAsciiTag(fd, "Page Name", td->td_pagename); - if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) - fprintf(fd, " Page Number: %u-%u\n", - td->td_pagenumber[0], td->td_pagenumber[1]); - if (TIFFFieldSet(tif,FIELD_COLORMAP)) { - fprintf(fd, " Color Map: "); - if (flags & TIFFPRINT_COLORMAP) { - fprintf(fd, "\n"); - n = 1L<td_bitspersample; - for (l = 0; l < n; l++) - fprintf(fd, " %5lu: %5u %5u %5u\n", - l, - td->td_colormap[0][l], - td->td_colormap[1][l], - td->td_colormap[2][l]); - } else - fprintf(fd, "(present)\n"); - } -#ifdef COLORIMETRY_SUPPORT - if (TIFFFieldSet(tif,FIELD_WHITEPOINT)) - fprintf(fd, " White Point: %g-%g\n", - td->td_whitepoint[0], td->td_whitepoint[1]); - if (TIFFFieldSet(tif,FIELD_PRIMARYCHROMAS)) - fprintf(fd, " Primary Chromaticities: %g,%g %g,%g %g,%g\n", - td->td_primarychromas[0], td->td_primarychromas[1], - td->td_primarychromas[2], td->td_primarychromas[3], - td->td_primarychromas[4], td->td_primarychromas[5]); - if (TIFFFieldSet(tif,FIELD_REFBLACKWHITE)) { - fprintf(fd, " Reference Black/White:\n"); - for (i = 0; i < td->td_samplesperpixel; i++) - fprintf(fd, " %2d: %5g %5g\n", - i, - td->td_refblackwhite[2*i+0], - td->td_refblackwhite[2*i+1]); - } - if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) { - fprintf(fd, " Transfer Function: "); - if (flags & TIFFPRINT_CURVES) { - fprintf(fd, "\n"); - n = 1L<td_bitspersample; - for (l = 0; l < n; l++) { - fprintf(fd, " %2lu: %5u", - l, td->td_transferfunction[0][l]); - for (i = 1; i < td->td_samplesperpixel; i++) - fprintf(fd, " %5u", - td->td_transferfunction[i][l]); - fputc('\n', fd); - } - } else - fprintf(fd, "(present)\n"); - } -#endif -#ifdef ICC_SUPPORT - if (TIFFFieldSet(tif,FIELD_ICCPROFILE)) - fprintf(fd, " ICC Profile: , %lu bytes\n", - (u_long) td->td_profileLength); -#endif -#ifdef PHOTOSHOP_SUPPORT - if (TIFFFieldSet(tif,FIELD_PHOTOSHOP)) - fprintf(fd, " Photoshop Data: , %lu bytes\n", - (u_long) td->td_photoshopLength); -#endif -#ifdef IPTC_SUPPORT - if (TIFFFieldSet(tif,FIELD_RICHTIFFIPTC)) - fprintf(fd, " RichTIFFIPTC Data: , %lu bytes\n", - (u_long) td->td_richtiffiptcLength); -#endif -#if SUBIFD_SUPPORT - if (TIFFFieldSet(tif, FIELD_SUBIFD)) { - fprintf(fd, " SubIFD Offsets:"); - for (i = 0; i < td->td_nsubifd; i++) - fprintf(fd, " %5lu", (long) td->td_subifd[i]); - fputc('\n', fd); - } -#endif - if (tif->tif_printdir) - (*tif->tif_printdir)(tif, fd, flags); - if ((flags & TIFFPRINT_STRIPS) && - TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { - tstrip_t s; - - fprintf(fd, " %lu %s:\n", - (long) td->td_nstrips, - isTiled(tif) ? "Tiles" : "Strips"); - for (s = 0; s < td->td_nstrips; s++) - fprintf(fd, " %3lu: [%8lu, %8lu]\n", - (u_long) s, - (u_long) td->td_stripoffset[s], - (u_long) td->td_stripbytecount[s]); - } -} - -void -_TIFFprintAscii(FILE* fd, const char* cp) -{ - for (; *cp != '\0'; cp++) { - const char* tp; - - if (isprint(*cp)) { - fputc(*cp, fd); - continue; - } - for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++) - if (*tp++ == *cp) - break; - if (*tp) - fprintf(fd, "\\%c", *tp); - else - fprintf(fd, "\\%03o", *cp & 0xff); - } -} - -void -_TIFFprintAsciiTag(FILE* fd, const char* name, const char* value) -{ - fprintf(fd, " %s: \"", name); - _TIFFprintAscii(fd, value); - fprintf(fd, "\"\n"); -} diff --git a/freeimage241/Source/LibTIFF/tif_read.c b/freeimage241/Source/LibTIFF/tif_read.c deleted file mode 100644 index c662cfa..0000000 --- a/freeimage241/Source/LibTIFF/tif_read.c +++ /dev/null @@ -1,633 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_read.c,v 1.0 2001-04-13 00:42:36+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * Scanline-oriented Read Support - */ -#include "tiffiop.h" -#include -#include - -static int TIFFFillStrip(TIFF*, tstrip_t); -static int TIFFFillTile(TIFF*, ttile_t); -static int TIFFStartStrip(TIFF*, tstrip_t); -static int TIFFStartTile(TIFF*, ttile_t); -static int TIFFCheckRead(TIFF*, int); - -#define NOSTRIP ((tstrip_t) -1) /* undefined state */ -#define NOTILE ((ttile_t) -1) /* undefined state */ - -/* - * Seek to a random row+sample in a file. - */ -static int -TIFFSeek(TIFF* tif, uint32 row, tsample_t sample) -{ - register TIFFDirectory *td = &tif->tif_dir; - tstrip_t strip; - - if (row >= td->td_imagelength) { /* out of range */ - TIFFError(tif->tif_name, "%lu: Row out of range, max %lu", - (u_long) row, (u_long) td->td_imagelength); - return (0); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - if (sample >= td->td_samplesperpixel) { - TIFFError(tif->tif_name, - "%lu: Sample out of range, max %lu", - (u_long) sample, (u_long) td->td_samplesperpixel); - return (0); - } - strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; - } else - strip = row / td->td_rowsperstrip; - if (strip != tif->tif_curstrip) { /* different strip, refill */ - if (!TIFFFillStrip(tif, strip)) - return (0); - } else if (row < tif->tif_row) { - /* - * Moving backwards within the same strip: backup - * to the start and then decode forward (below). - * - * NB: If you're planning on lots of random access within a - * strip, it's better to just read and decode the entire - * strip, and then access the decoded data in a random fashion. - */ - if (!TIFFStartStrip(tif, strip)) - return (0); - } - if (row != tif->tif_row) { - /* - * Seek forward to the desired row. - */ - if (!(*tif->tif_seek)(tif, row - tif->tif_row)) - return (0); - tif->tif_row = row; - } - return (1); -} - -int -TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) -{ - int e; - - if (!TIFFCheckRead(tif, 0)) - return (-1); - if( (e = TIFFSeek(tif, row, sample)) != 0) { - /* - * Decompress desired row into user buffer. - */ - e = (*tif->tif_decoderow) - (tif, (tidata_t) buf, tif->tif_scanlinesize, sample); - tif->tif_row++; - if (e) - (*tif->tif_postdecode)(tif, (tidata_t) buf, - tif->tif_scanlinesize); - } - return (e > 0 ? 1 : -1); -} - -/* - * Read a strip of data and decompress the specified - * amount into the user-supplied buffer. - */ -tsize_t -TIFFReadEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) -{ - TIFFDirectory *td = &tif->tif_dir; - uint32 nrows; - tsize_t stripsize; - tstrip_t sep_strip, strips_per_sep; - - if (!TIFFCheckRead(tif, 0)) - return (-1); - if (strip >= td->td_nstrips) { - TIFFError(tif->tif_name, "%ld: Strip out of range, max %ld", - (long) strip, (long) td->td_nstrips); - return (-1); - } - /* - * Calculate the strip size according to the number of - * rows in the strip (check for truncated last strip on any - * of the separations). - */ - if( td->td_rowsperstrip >= td->td_imagelength ) - strips_per_sep = 1; - else - strips_per_sep = (td->td_imagelength+td->td_rowsperstrip-1) - / td->td_rowsperstrip; - - sep_strip = strip % strips_per_sep; - - if (sep_strip != strips_per_sep-1 || - (nrows = td->td_imagelength % td->td_rowsperstrip) == 0) - nrows = td->td_rowsperstrip; - - stripsize = TIFFVStripSize(tif, nrows); - if (size == (tsize_t) -1) - size = stripsize; - else if (size > stripsize) - size = stripsize; - if (TIFFFillStrip(tif, strip) && (*tif->tif_decodestrip)(tif, - (tidata_t) buf, size, (tsample_t)(strip / td->td_stripsperimage))) { - (*tif->tif_postdecode)(tif, (tidata_t) buf, size); - return (size); - } else - return ((tsize_t) -1); -} - -static tsize_t -TIFFReadRawStrip1(TIFF* tif, - tstrip_t strip, tdata_t buf, tsize_t size, const char* module) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (!isMapped(tif)) { - tsize_t cc; - - if (!SeekOK(tif, td->td_stripoffset[strip])) { - TIFFError(module, - "%s: Seek error at scanline %lu, strip %lu", - tif->tif_name, - (u_long) tif->tif_row, (u_long) strip); - return (-1); - } - cc = TIFFReadFile(tif, buf, size); - if (cc != size) { - TIFFError(module, - "%s: Read error at scanline %lu; got %lu bytes, expected %lu", - tif->tif_name, - (u_long) tif->tif_row, - (u_long) cc, - (u_long) size); - return (-1); - } - } else { - if (td->td_stripoffset[strip] + size > tif->tif_size) { - TIFFError(module, - "%s: Read error at scanline %lu, strip %lu; got %lu bytes, expected %lu", - tif->tif_name, - (u_long) tif->tif_row, - (u_long) strip, - (u_long) tif->tif_size - td->td_stripoffset[strip], - (u_long) size); - return (-1); - } - _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[strip], size); - } - return (size); -} - -/* - * Read a strip of data from the file. - */ -tsize_t -TIFFReadRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) -{ - static const char module[] = "TIFFReadRawStrip"; - TIFFDirectory *td = &tif->tif_dir; - tsize_t bytecount; - - if (!TIFFCheckRead(tif, 0)) - return ((tsize_t) -1); - if (strip >= td->td_nstrips) { - TIFFError(tif->tif_name, "%lu: Strip out of range, max %lu", - (u_long) strip, (u_long) td->td_nstrips); - return ((tsize_t) -1); - } - bytecount = td->td_stripbytecount[strip]; - if (bytecount <= 0) { - TIFFError(tif->tif_name, - "%lu: Invalid strip byte count, strip %lu", - (u_long) bytecount, (u_long) strip); - return ((tsize_t) -1); - } - if (size != (tsize_t)-1 && size < bytecount) - bytecount = size; - return (TIFFReadRawStrip1(tif, strip, buf, bytecount, module)); -} - -/* - * Read the specified strip and setup for decoding. - * The data buffer is expanded, as necessary, to - * hold the strip's data. - */ -static int -TIFFFillStrip(TIFF* tif, tstrip_t strip) -{ - static const char module[] = "TIFFFillStrip"; - TIFFDirectory *td = &tif->tif_dir; - tsize_t bytecount; - - bytecount = td->td_stripbytecount[strip]; - if (bytecount <= 0) { - TIFFError(tif->tif_name, - "%lu: Invalid strip byte count, strip %lu", - (u_long) bytecount, (u_long) strip); - return (0); - } - if (isMapped(tif) && - (isFillOrder(tif, td->td_fillorder) || (tif->tif_flags & TIFF_NOBITREV))) { - /* - * The image is mapped into memory and we either don't - * need to flip bits or the compression routine is going - * to handle this operation itself. In this case, avoid - * copying the raw data and instead just reference the - * data from the memory mapped file image. This assumes - * that the decompression routines do not modify the - * contents of the raw data buffer (if they try to, - * the application will get a fault since the file is - * mapped read-only). - */ - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) - _TIFFfree(tif->tif_rawdata); - tif->tif_flags &= ~TIFF_MYBUFFER; - if ( td->td_stripoffset[strip] + bytecount > tif->tif_size) { - /* - * This error message might seem strange, but it's - * what would happen if a read were done instead. - */ - TIFFError(module, - "%s: Read error on strip %lu; got %lu bytes, expected %lu", - tif->tif_name, - (u_long) strip, - (u_long) tif->tif_size - td->td_stripoffset[strip], - (u_long) bytecount); - tif->tif_curstrip = NOSTRIP; - return (0); - } - tif->tif_rawdatasize = bytecount; - tif->tif_rawdata = tif->tif_base + td->td_stripoffset[strip]; - } else { - /* - * Expand raw data buffer, if needed, to - * hold data strip coming from file - * (perhaps should set upper bound on - * the size of a buffer we'll use?). - */ - if (bytecount > tif->tif_rawdatasize) { - tif->tif_curstrip = NOSTRIP; - if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { - TIFFError(module, - "%s: Data buffer too small to hold strip %lu", - tif->tif_name, (u_long) strip); - return (0); - } - if (!TIFFReadBufferSetup(tif, 0, - TIFFroundup(bytecount, 1024))) - return (0); - } - if (TIFFReadRawStrip1(tif, strip, (u_char *)tif->tif_rawdata, - bytecount, module) != bytecount) - return (0); - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(tif->tif_rawdata, bytecount); - } - return (TIFFStartStrip(tif, strip)); -} - -/* - * Tile-oriented Read Support - * Contributed by Nancy Cam (Silicon Graphics). - */ - -/* - * Read and decompress a tile of data. The - * tile is selected by the (x,y,z,s) coordinates. - */ -tsize_t -TIFFReadTile(TIFF* tif, - tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) -{ - if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) - return (-1); - return (TIFFReadEncodedTile(tif, - TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); -} - -/* - * Read a tile of data and decompress the specified - * amount into the user-supplied buffer. - */ -tsize_t -TIFFReadEncodedTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t tilesize = tif->tif_tilesize; - - if (!TIFFCheckRead(tif, 1)) - return (-1); - if (tile >= td->td_nstrips) { - TIFFError(tif->tif_name, "%ld: Tile out of range, max %ld", - (long) tile, (u_long) td->td_nstrips); - return (-1); - } - if (size == (tsize_t) -1) - size = tilesize; - else if (size > tilesize) - size = tilesize; - if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, - (tidata_t) buf, size, (tsample_t)(tile/td->td_stripsperimage))) { - (*tif->tif_postdecode)(tif, (tidata_t) buf, size); - return (size); - } else - return (-1); -} - -static tsize_t -TIFFReadRawTile1(TIFF* tif, - ttile_t tile, tdata_t buf, tsize_t size, const char* module) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (!isMapped(tif)) { - tsize_t cc; - - if (!SeekOK(tif, td->td_stripoffset[tile])) { - TIFFError(module, - "%s: Seek error at row %ld, col %ld, tile %ld", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (long) tile); - return ((tsize_t) -1); - } - cc = TIFFReadFile(tif, buf, size); - if (cc != size) { - TIFFError(module, - "%s: Read error at row %ld, col %ld; got %lu bytes, expected %lu", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (u_long) cc, - (u_long) size); - return ((tsize_t) -1); - } - } else { - if (td->td_stripoffset[tile] + size > tif->tif_size) { - TIFFError(module, - "%s: Read error at row %ld, col %ld, tile %ld; got %lu bytes, expected %lu", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (long) tile, - (u_long) tif->tif_size - td->td_stripoffset[tile], - (u_long) size); - return ((tsize_t) -1); - } - _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[tile], size); - } - return (size); -} - -/* - * Read a tile of data from the file. - */ -tsize_t -TIFFReadRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) -{ - static const char module[] = "TIFFReadRawTile"; - TIFFDirectory *td = &tif->tif_dir; - tsize_t bytecount; - - if (!TIFFCheckRead(tif, 1)) - return ((tsize_t) -1); - if (tile >= td->td_nstrips) { - TIFFError(tif->tif_name, "%lu: Tile out of range, max %lu", - (u_long) tile, (u_long) td->td_nstrips); - return ((tsize_t) -1); - } - bytecount = td->td_stripbytecount[tile]; - if (size != (tsize_t) -1 && size < bytecount) - bytecount = size; - return (TIFFReadRawTile1(tif, tile, buf, bytecount, module)); -} - -/* - * Read the specified tile and setup for decoding. - * The data buffer is expanded, as necessary, to - * hold the tile's data. - */ -static int -TIFFFillTile(TIFF* tif, ttile_t tile) -{ - static const char module[] = "TIFFFillTile"; - TIFFDirectory *td = &tif->tif_dir; - tsize_t bytecount; - - bytecount = td->td_stripbytecount[tile]; - if (bytecount <= 0) { - TIFFError(tif->tif_name, - "%lu: Invalid tile byte count, tile %lu", - (u_long) bytecount, (u_long) tile); - return (0); - } - if (isMapped(tif) && - (isFillOrder(tif, td->td_fillorder) || (tif->tif_flags & TIFF_NOBITREV))) { - /* - * The image is mapped into memory and we either don't - * need to flip bits or the compression routine is going - * to handle this operation itself. In this case, avoid - * copying the raw data and instead just reference the - * data from the memory mapped file image. This assumes - * that the decompression routines do not modify the - * contents of the raw data buffer (if they try to, - * the application will get a fault since the file is - * mapped read-only). - */ - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) - _TIFFfree(tif->tif_rawdata); - tif->tif_flags &= ~TIFF_MYBUFFER; - if ( td->td_stripoffset[tile] + bytecount > tif->tif_size) { - tif->tif_curtile = NOTILE; - return (0); - } - tif->tif_rawdatasize = bytecount; - tif->tif_rawdata = tif->tif_base + td->td_stripoffset[tile]; - } else { - /* - * Expand raw data buffer, if needed, to - * hold data tile coming from file - * (perhaps should set upper bound on - * the size of a buffer we'll use?). - */ - if (bytecount > tif->tif_rawdatasize) { - tif->tif_curtile = NOTILE; - if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { - TIFFError(module, - "%s: Data buffer too small to hold tile %ld", - tif->tif_name, (long) tile); - return (0); - } - if (!TIFFReadBufferSetup(tif, 0, - TIFFroundup(bytecount, 1024))) - return (0); - } - if (TIFFReadRawTile1(tif, tile, (u_char *)tif->tif_rawdata, - bytecount, module) != bytecount) - return (0); - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(tif->tif_rawdata, bytecount); - } - return (TIFFStartTile(tif, tile)); -} - -/* - * Setup the raw data buffer in preparation for - * reading a strip of raw data. If the buffer - * is specified as zero, then a buffer of appropriate - * size is allocated by the library. Otherwise, - * the client must guarantee that the buffer is - * large enough to hold any individual strip of - * raw data. - */ -int -TIFFReadBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) -{ - static const char module[] = "TIFFReadBufferSetup"; - - if (tif->tif_rawdata) { - if (tif->tif_flags & TIFF_MYBUFFER) - _TIFFfree(tif->tif_rawdata); - tif->tif_rawdata = NULL; - } - if (bp) { - tif->tif_rawdatasize = size; - tif->tif_rawdata = (tidata_t) bp; - tif->tif_flags &= ~TIFF_MYBUFFER; - } else { - tif->tif_rawdatasize = TIFFroundup(size, 1024); - tif->tif_rawdata = (tidata_t) _TIFFmalloc(tif->tif_rawdatasize); - tif->tif_flags |= TIFF_MYBUFFER; - } - if (tif->tif_rawdata == NULL) { - TIFFError(module, - "%s: No space for data buffer at scanline %ld", - tif->tif_name, (long) tif->tif_row); - tif->tif_rawdatasize = 0; - return (0); - } - return (1); -} - -/* - * Set state to appear as if a - * strip has just been read in. - */ -static int -TIFFStartStrip(TIFF* tif, tstrip_t strip) -{ - TIFFDirectory *td = &tif->tif_dir; - - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupdecode)(tif)) - return (0); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_curstrip = strip; - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - tif->tif_rawcp = tif->tif_rawdata; - tif->tif_rawcc = td->td_stripbytecount[strip]; - return ((*tif->tif_predecode)(tif, - (tsample_t)(strip / td->td_stripsperimage))); -} - -/* - * Set state to appear as if a - * tile has just been read in. - */ -static int -TIFFStartTile(TIFF* tif, ttile_t tile) -{ - TIFFDirectory *td = &tif->tif_dir; - - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupdecode)(tif)) - return (0); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_curtile = tile; - tif->tif_row = - (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth)) * - td->td_tilelength; - tif->tif_col = - (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) * - td->td_tilewidth; - tif->tif_rawcp = tif->tif_rawdata; - tif->tif_rawcc = td->td_stripbytecount[tile]; - return ((*tif->tif_predecode)(tif, - (tsample_t)(tile/td->td_stripsperimage))); -} - -static int -TIFFCheckRead(TIFF* tif, int tiles) -{ - if (tif->tif_mode == O_WRONLY) { - TIFFError(tif->tif_name, "File not open for reading"); - return (0); - } - if (tiles ^ isTiled(tif)) { - TIFFError(tif->tif_name, tiles ? - "Can not read tiles from a stripped image" : - "Can not read scanlines from a tiled image"); - return (0); - } - return (1); -} - -void -_TIFFNoPostDecode(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; (void) buf; (void) cc; -} - -void -_TIFFSwab16BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc & 1) == 0); - TIFFSwabArrayOfShort((uint16*) buf, cc/2); -} - -void -_TIFFSwab32BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc & 3) == 0); - TIFFSwabArrayOfLong((uint32*) buf, cc/4); -} - -void -_TIFFSwab64BitData(TIFF* tif, tidata_t buf, tsize_t cc) -{ - (void) tif; - assert((cc & 7) == 0); - TIFFSwabArrayOfDouble((double*) buf, cc/8); -} diff --git a/freeimage241/Source/LibTIFF/tif_strip.c b/freeimage241/Source/LibTIFF/tif_strip.c deleted file mode 100644 index 293f29b..0000000 --- a/freeimage241/Source/LibTIFF/tif_strip.c +++ /dev/null @@ -1,192 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_strip.c,v 1.0 2001-04-13 00:42:36+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1991-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Strip-organized Image Support Routines. - */ -#include "tiffiop.h" - -/* - * Compute which strip a (row,sample) value is in. - */ -tstrip_t -TIFFComputeStrip(TIFF* tif, uint32 row, tsample_t sample) -{ - TIFFDirectory *td = &tif->tif_dir; - tstrip_t strip; - - strip = row / td->td_rowsperstrip; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - if (sample >= td->td_samplesperpixel) { - TIFFError(tif->tif_name, - "%u: Sample out of range, max %u", - sample, td->td_samplesperpixel); - return ((tstrip_t) 0); - } - strip += sample*td->td_stripsperimage; - } - return (strip); -} - -/* - * Compute how many strips are in an image. - */ -tstrip_t -TIFFNumberOfStrips(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tstrip_t nstrips; - - nstrips = (td->td_rowsperstrip == (uint32) -1 ? - (td->td_imagelength != 0 ? 1 : 0) : - TIFFhowmany(td->td_imagelength, td->td_rowsperstrip)); - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - nstrips *= td->td_samplesperpixel; - return (nstrips); -} - -/* - * Compute the # bytes in a variable height, row-aligned strip. - */ -tsize_t -TIFFVStripSize(TIFF* tif, uint32 nrows) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (nrows == (uint32) -1) - nrows = td->td_imagelength; -#ifdef YCBCR_SUPPORT - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_photometric == PHOTOMETRIC_YCBCR && - !isUpSampled(tif)) { - /* - * Packed YCbCr data contain one Cb+Cr for every - * HorizontalSampling*VerticalSampling Y values. - * Must also roundup width and height when calculating - * since images that are not a multiple of the - * horizontal/vertical subsampling area include - * YCbCr data for the extended image. - */ - tsize_t w = - TIFFroundup(td->td_imagewidth, td->td_ycbcrsubsampling[0]); - tsize_t scanline = TIFFhowmany(w*td->td_bitspersample, 8); - tsize_t samplingarea = - td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; - nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); - /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ - return ((tsize_t) - (nrows*scanline + 2*(nrows*scanline / samplingarea))); - } else -#endif - return ((tsize_t)(nrows * TIFFScanlineSize(tif))); -} - -/* - * Compute the # bytes in a (row-aligned) strip. - * - * Note that if RowsPerStrip is larger than the - * recorded ImageLength, then the strip size is - * truncated to reflect the actual space required - * to hold the strip. - */ -tsize_t -TIFFStripSize(TIFF* tif) -{ - TIFFDirectory* td = &tif->tif_dir; - uint32 rps = td->td_rowsperstrip; - if (rps > td->td_imagelength) - rps = td->td_imagelength; - return (TIFFVStripSize(tif, rps)); -} - -/* - * Compute a default strip size based on the image - * characteristics and a requested value. If the - * request is <1 then we choose a strip size according - * to certain heuristics. - */ -uint32 -TIFFDefaultStripSize(TIFF* tif, uint32 request) -{ - return (*tif->tif_defstripsize)(tif, request); -} - -uint32 -_TIFFDefaultStripSize(TIFF* tif, uint32 s) -{ - if ((int32) s < 1) { - /* - * If RowsPerStrip is unspecified, try to break the - * image up into strips that are approximately 8Kbytes. - */ - tsize_t scanline = TIFFScanlineSize(tif); - s = (uint32)(8*1024) / (scanline == 0 ? 1 : scanline); - if (s == 0) /* very wide images */ - s = 1; - } - return (s); -} - -/* - * Return the number of bytes to read/write in a call to - * one of the scanline-oriented i/o routines. Note that - * this number may be 1/samples-per-pixel if data is - * stored as separate planes. - */ -tsize_t -TIFFScanlineSize(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t scanline; - - scanline = td->td_bitspersample * td->td_imagewidth; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - scanline *= td->td_samplesperpixel; - return ((tsize_t) TIFFhowmany(scanline, 8)); -} - -/* - * Return the number of bytes required to store a complete - * decoded and packed raster scanline (as opposed to the - * I/O size returned by TIFFScanlineSize which may be less - * if data is store as separate planes). - */ -tsize_t -TIFFRasterScanlineSize(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t scanline; - - scanline = td->td_bitspersample * td->td_imagewidth; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) { - scanline *= td->td_samplesperpixel; - return ((tsize_t) TIFFhowmany(scanline, 8)); - } else - return ((tsize_t) - TIFFhowmany(scanline, 8)*td->td_samplesperpixel); -} diff --git a/freeimage241/Source/LibTIFF/tif_swab.c b/freeimage241/Source/LibTIFF/tif_swab.c deleted file mode 100644 index 38639f3..0000000 --- a/freeimage241/Source/LibTIFF/tif_swab.c +++ /dev/null @@ -1,217 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_swab.c,v 1.0 2001-04-13 00:42:37+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library Bit & Byte Swapping Support. - * - * XXX We assume short = 16-bits and long = 32-bits XXX - */ -#include "tiffiop.h" - -#ifndef TIFFSwabShort -void -TIFFSwabShort(uint16* wp) -{ - register u_char* cp = (u_char*) wp; - int t; - - t = cp[1]; cp[1] = cp[0]; cp[0] = t; -} -#endif - -#ifndef TIFFSwabLong -void -TIFFSwabLong(uint32* lp) -{ - register u_char* cp = (u_char*) lp; - int t; - - t = cp[3]; cp[3] = cp[0]; cp[0] = t; - t = cp[2]; cp[2] = cp[1]; cp[1] = t; -} -#endif - -#ifndef TIFFSwabArrayOfShort -void -TIFFSwabArrayOfShort(uint16* wp, register u_long n) -{ - register u_char* cp; - register int t; - - /* XXX unroll loop some */ - while (n-- > 0) { - cp = (u_char*) wp; - t = cp[1]; cp[1] = cp[0]; cp[0] = t; - wp++; - } -} -#endif - -#ifndef TIFFSwabArrayOfLong -void -TIFFSwabArrayOfLong(register uint32* lp, register u_long n) -{ - register unsigned char *cp; - register int t; - - /* XXX unroll loop some */ - while (n-- > 0) { - cp = (unsigned char *)lp; - t = cp[3]; cp[3] = cp[0]; cp[0] = t; - t = cp[2]; cp[2] = cp[1]; cp[1] = t; - lp++; - } -} -#endif - -#ifndef TIFFSwabDouble -void -TIFFSwabDouble(double *dp) -{ - register uint32* lp = (uint32*) dp; - uint32 t; - - TIFFSwabArrayOfLong(lp, 2); - t = lp[0]; lp[0] = lp[1]; lp[1] = t; -} -#endif - -#ifndef TIFFSwabArrayOfDouble -void -TIFFSwabArrayOfDouble(double* dp, register u_long n) -{ - register uint32* lp = (uint32*) dp; - register uint32 t; - - TIFFSwabArrayOfLong(lp, n + n); - while (n-- > 0) { - t = lp[0]; lp[0] = lp[1]; lp[1] = t; - lp += 2; - } -} -#endif - -/* - * Bit reversal tables. TIFFBitRevTable[] gives - * the bit reversed value of . Used in various - * places in the library when the FillOrder requires - * bit reversal of byte values (e.g. CCITT Fax 3 - * encoding/decoding). TIFFNoBitRevTable is provided - * for algorithms that want an equivalent table that - * do not reverse bit values. - */ -static const unsigned char TIFFBitRevTable[256] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff -}; -static const unsigned char TIFFNoBitRevTable[256] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, -}; - -const unsigned char* -TIFFGetBitRevTable(int reversed) -{ - return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable); -} - -void -TIFFReverseBits(register u_char* cp, register u_long n) -{ - for (; n > 8; n -= 8) { - cp[0] = TIFFBitRevTable[cp[0]]; - cp[1] = TIFFBitRevTable[cp[1]]; - cp[2] = TIFFBitRevTable[cp[2]]; - cp[3] = TIFFBitRevTable[cp[3]]; - cp[4] = TIFFBitRevTable[cp[4]]; - cp[5] = TIFFBitRevTable[cp[5]]; - cp[6] = TIFFBitRevTable[cp[6]]; - cp[7] = TIFFBitRevTable[cp[7]]; - cp += 8; - } - while (n-- > 0) - *cp = TIFFBitRevTable[*cp], cp++; -} diff --git a/freeimage241/Source/LibTIFF/tif_thunder.c b/freeimage241/Source/LibTIFF/tif_thunder.c deleted file mode 100644 index 344d977..0000000 --- a/freeimage241/Source/LibTIFF/tif_thunder.c +++ /dev/null @@ -1,154 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_thunder.c,v 1.0 2001-04-13 00:42:37+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef THUNDER_SUPPORT -/* - * TIFF Library. - * - * ThunderScan 4-bit Compression Algorithm Support - */ - -/* - * ThunderScan uses an encoding scheme designed for - * 4-bit pixel values. Data is encoded in bytes, with - * each byte split into a 2-bit code word and a 6-bit - * data value. The encoding gives raw data, runs of - * pixels, or pixel values encoded as a delta from the - * previous pixel value. For the latter, either 2-bit - * or 3-bit delta values are used, with the deltas packed - * into a single byte. - */ -#define THUNDER_DATA 0x3f /* mask for 6-bit data */ -#define THUNDER_CODE 0xc0 /* mask for 2-bit code word */ -/* code values */ -#define THUNDER_RUN 0x00 /* run of pixels w/ encoded count */ -#define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */ -#define DELTA2_SKIP 2 /* skip code for 2-bit deltas */ -#define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */ -#define DELTA3_SKIP 4 /* skip code for 3-bit deltas */ -#define THUNDER_RAW 0xc0 /* raw data encoded */ - -static const int twobitdeltas[4] = { 0, 1, 0, -1 }; -static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 }; - -#define SETPIXEL(op, v) { \ - lastpixel = (v) & 0xf; \ - if (npixels++ & 1) \ - *op++ |= lastpixel; \ - else \ - op[0] = lastpixel << 4; \ -} - -static int -ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) -{ - register u_char *bp; - register tsize_t cc; - u_int lastpixel; - tsize_t npixels; - - bp = (u_char *)tif->tif_rawcp; - cc = tif->tif_rawcc; - lastpixel = 0; - npixels = 0; - while (cc > 0 && npixels < maxpixels) { - int n, delta; - - n = *bp++, cc--; - switch (n & THUNDER_CODE) { - case THUNDER_RUN: /* pixel run */ - /* - * Replicate the last pixel n times, - * where n is the lower-order 6 bits. - */ - if (npixels & 1) { - op[0] |= lastpixel; - lastpixel = *op++; npixels++; n--; - } else - lastpixel |= lastpixel << 4; - npixels += n; - for (; n > 0; n -= 2) - *op++ = lastpixel; - if (n == -1) - *--op &= 0xf0; - lastpixel &= 0xf; - break; - case THUNDER_2BITDELTAS: /* 2-bit deltas */ - if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP) - SETPIXEL(op, lastpixel + twobitdeltas[delta]); - if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP) - SETPIXEL(op, lastpixel + twobitdeltas[delta]); - if ((delta = (n & 3)) != DELTA2_SKIP) - SETPIXEL(op, lastpixel + twobitdeltas[delta]); - break; - case THUNDER_3BITDELTAS: /* 3-bit deltas */ - if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP) - SETPIXEL(op, lastpixel + threebitdeltas[delta]); - if ((delta = (n & 7)) != DELTA3_SKIP) - SETPIXEL(op, lastpixel + threebitdeltas[delta]); - break; - case THUNDER_RAW: /* raw data */ - SETPIXEL(op, n); - break; - } - } - tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; - if (npixels != maxpixels) { - TIFFError(tif->tif_name, - "ThunderDecode: %s data at scanline %ld (%lu != %lu)", - npixels < maxpixels ? "Not enough" : "Too much", - (long) tif->tif_row, (long) npixels, (long) maxpixels); - return (0); - } - return (1); -} - -static int -ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) -{ - tidata_t row = buf; - - (void) s; - while ((long)occ > 0) { - if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) - return (0); - occ -= tif->tif_scanlinesize; - row += tif->tif_scanlinesize; - } - return (1); -} - -int -TIFFInitThunderScan(TIFF* tif, int scheme) -{ - (void) scheme; - tif->tif_decoderow = ThunderDecodeRow; - tif->tif_decodestrip = ThunderDecodeRow; - return (1); -} -#endif /* THUNDER_SUPPORT */ diff --git a/freeimage241/Source/LibTIFF/tif_tile.c b/freeimage241/Source/LibTIFF/tif_tile.c deleted file mode 100644 index 00bd3a0..0000000 --- a/freeimage241/Source/LibTIFF/tif_tile.c +++ /dev/null @@ -1,219 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_tile.c,v 1.0 2001-04-13 00:42:37+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1991-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Tiled Image Support Routines. - */ -#include "tiffiop.h" - -/* - * Compute which tile an (x,y,z,s) value is in. - */ -ttile_t -TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) -{ - TIFFDirectory *td = &tif->tif_dir; - uint32 dx = td->td_tilewidth; - uint32 dy = td->td_tilelength; - uint32 dz = td->td_tiledepth; - ttile_t tile = 1; - - if (td->td_imagedepth == 1) - z = 0; - if (dx == (uint32) -1) - dx = td->td_imagewidth; - if (dy == (uint32) -1) - dy = td->td_imagelength; - if (dz == (uint32) -1) - dz = td->td_imagedepth; - if (dx != 0 && dy != 0 && dz != 0) { - uint32 xpt = TIFFhowmany(td->td_imagewidth, dx); - uint32 ypt = TIFFhowmany(td->td_imagelength, dy); - uint32 zpt = TIFFhowmany(td->td_imagedepth, dz); - - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - tile = (xpt*ypt*zpt)*s + - (xpt*ypt)*(z/dz) + - xpt*(y/dy) + - x/dx; - else - tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx + s; - } - return (tile); -} - -/* - * Check an (x,y,z,s) coordinate - * against the image bounds. - */ -int -TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) -{ - TIFFDirectory *td = &tif->tif_dir; - - if (x >= td->td_imagewidth) { - TIFFError(tif->tif_name, "Col %ld out of range, max %lu", - (long) x, (u_long) td->td_imagewidth); - return (0); - } - if (y >= td->td_imagelength) { - TIFFError(tif->tif_name, "Row %ld out of range, max %lu", - (long) y, (u_long) td->td_imagelength); - return (0); - } - if (z >= td->td_imagedepth) { - TIFFError(tif->tif_name, "Depth %ld out of range, max %lu", - (long) z, (u_long) td->td_imagedepth); - return (0); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE && - s >= td->td_samplesperpixel) { - TIFFError(tif->tif_name, "Sample %d out of range, max %u", - (int) s, td->td_samplesperpixel); - return (0); - } - return (1); -} - -/* - * Compute how many tiles are in an image. - */ -ttile_t -TIFFNumberOfTiles(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - uint32 dx = td->td_tilewidth; - uint32 dy = td->td_tilelength; - uint32 dz = td->td_tiledepth; - ttile_t ntiles; - - if (dx == (uint32) -1) - dx = td->td_imagewidth; - if (dy == (uint32) -1) - dy = td->td_imagelength; - if (dz == (uint32) -1) - dz = td->td_imagedepth; - ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 : - (TIFFhowmany(td->td_imagewidth, dx) * - TIFFhowmany(td->td_imagelength, dy) * - TIFFhowmany(td->td_imagedepth, dz)); - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - ntiles *= td->td_samplesperpixel; - return (ntiles); -} - -/* - * Compute the # bytes in each row of a tile. - */ -tsize_t -TIFFTileRowSize(TIFF* tif) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t rowsize; - - if (td->td_tilelength == 0 || td->td_tilewidth == 0) - return ((tsize_t) 0); - rowsize = td->td_bitspersample * td->td_tilewidth; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - rowsize *= td->td_samplesperpixel; - return ((tsize_t) TIFFhowmany(rowsize, 8)); -} - -/* - * Compute the # bytes in a variable length, row-aligned tile. - */ -tsize_t -TIFFVTileSize(TIFF* tif, uint32 nrows) -{ - TIFFDirectory *td = &tif->tif_dir; - tsize_t tilesize; - - if (td->td_tilelength == 0 || td->td_tilewidth == 0 || - td->td_tiledepth == 0) - return ((tsize_t) 0); -#ifdef YCBCR_SUPPORT - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_photometric == PHOTOMETRIC_YCBCR && - !isUpSampled(tif)) { - /* - * Packed YCbCr data contain one Cb+Cr for every - * HorizontalSampling*VerticalSampling Y values. - * Must also roundup width and height when calculating - * since images that are not a multiple of the - * horizontal/vertical subsampling area include - * YCbCr data for the extended image. - */ - tsize_t w = - TIFFroundup(td->td_tilewidth, td->td_ycbcrsubsampling[0]); - tsize_t rowsize = TIFFhowmany(w*td->td_bitspersample, 8); - tsize_t samplingarea = - td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; - nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); - /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ - tilesize = nrows*rowsize + 2*(nrows*rowsize / samplingarea); - } else -#endif - tilesize = nrows * TIFFTileRowSize(tif); - return ((tsize_t)(tilesize * td->td_tiledepth)); -} - -/* - * Compute the # bytes in a row-aligned tile. - */ -tsize_t -TIFFTileSize(TIFF* tif) -{ - return (TIFFVTileSize(tif, tif->tif_dir.td_tilelength)); -} - -/* - * Compute a default tile size based on the image - * characteristics and a requested value. If a - * request is <1 then we choose a size according - * to certain heuristics. - */ -void -TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) -{ - (*tif->tif_deftilesize)(tif, tw, th); -} - -void -_TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) -{ - (void) tif; - if (*(int32*) tw < 1) - *tw = 256; - if (*(int32*) th < 1) - *th = 256; - /* roundup to a multiple of 16 per the spec */ - if (*tw & 0xf) - *tw = TIFFroundup(*tw, 16); - if (*th & 0xf) - *th = TIFFroundup(*th, 16); -} diff --git a/freeimage241/Source/LibTIFF/tif_unix.c b/freeimage241/Source/LibTIFF/tif_unix.c deleted file mode 100644 index 5409516..0000000 --- a/freeimage241/Source/LibTIFF/tif_unix.c +++ /dev/null @@ -1,224 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_unix.c,v 1.0 2001-04-13 00:42:38+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library UNIX-specific Routines. - */ -#include "tiffiop.h" -#include -#include -#include - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return ((tsize_t) read((int) fd, buf, (size_t) size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return ((tsize_t) write((int) fd, buf, (size_t) size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ -#if USE_64BIT_API == 1 - return ((toff_t) lseek64((int) fd, (off64_t) off, whence)); -#else - return ((toff_t) lseek((int) fd, (off_t) off, whence)); -#endif -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (close((int) fd)); -} - -#include - -static toff_t -_tiffSizeProc(thandle_t fd) -{ -#ifdef _AM29K - long fsize; - return ((fsize = lseek((int) fd, 0, SEEK_END)) < 0 ? 0 : fsize); -#else -#if USE_64BIT_API == 1 - struct stat64 sb; - return (toff_t) (fstat64((int) fd, &sb) < 0 ? 0 : sb.st_size); -#else - struct stat sb; - return (toff_t) (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -#endif -#endif -} - -#ifdef HAVE_MMAP -#include - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - toff_t size = _tiffSizeProc(fd); - if (size != (toff_t) -1) { - *pbase = (tdata_t) - mmap(0, size, PROT_READ, MAP_SHARED, (int) fd, 0); - if (*pbase != (tdata_t) -1) { - *psize = size; - return (1); - } - } - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - (void) fd; - (void) munmap(base, (off_t) size); -} -#else /* !HAVE_MMAP */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - (void) fd; (void) pbase; (void) psize; - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - (void) fd; (void) base; (void) size; -} -#endif /* !HAVE_MMAP */ - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, - _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, - _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - -/* for cygwin */ -#ifdef O_BINARY - m |= O_BINARY; -#endif - -#ifdef _AM29K - fd = open(name, m); -#else - fd = open(name, m, 0666); -#endif - if (fd < 0) { - TIFFError(module, "%s: Cannot open", name); - return ((TIFF *)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -void* -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -void* -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -static void -unixWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler; - -static void -unixErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} -TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler; diff --git a/freeimage241/Source/LibTIFF/tif_version.c b/freeimage241/Source/LibTIFF/tif_version.c deleted file mode 100644 index 5664c94..0000000 --- a/freeimage241/Source/LibTIFF/tif_version.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_version.c,v 1.0 2001-04-13 00:42:38+02 floris_van_den_berg Exp floris_van_den_berg $ */ -/* - * Copyright (c) 1992-1997 Sam Leffler - * Copyright (c) 1992-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ -#include "tiffiop.h" - -static const char TIFFVersion[] = "LibTIFF 3.5.6. Beta"; - -const char* -TIFFGetVersion(void) -{ - return (TIFFVersion); -} diff --git a/freeimage241/Source/LibTIFF/tif_vms.c b/freeimage241/Source/LibTIFF/tif_vms.c deleted file mode 100644 index f48b4b5..0000000 --- a/freeimage241/Source/LibTIFF/tif_vms.c +++ /dev/null @@ -1,588 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_vms.c,v 1.0 2001-04-13 00:42:38+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library VMS-specific Routines. - */ - -#include -#include -#include "tiffiop.h" -#if !HAVE_IEEEFP -#include -#endif - -#ifdef VAXC -#define NOSHARE noshare -#else -#define NOSHARE -#endif - -#ifdef __alpha -/* Dummy entry point for backwards compatibility */ -void TIFFModeCCITTFax3(void){} -#endif - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (read((int) fd, buf, size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (write((int) fd, buf, size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return ((toff_t) lseek((int) fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (close((int) fd)); -} - -#include - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - struct stat sb; - return (toff_t) (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -} - -#ifdef HAVE_MMAP -#include -#include -#include - -/* - * Table for storing information on current open sections. - * (Should really be a linked list) - */ -#define MAX_MAPPED 100 -static int no_mapped = 0; -static struct { - char *base; - char *top; - unsigned short channel; -} map_table[MAX_MAPPED]; - -/* - * This routine maps a file into a private section. Note that this - * method of accessing a file is by far the fastest under VMS. - * The routine may fail (i.e. return 0) for several reasons, for - * example: - * - There is no more room for storing the info on sections. - * - The process is out of open file quota, channels, ... - * - fd does not describe an opened file. - * - The file is already opened for write access by this process - * or another process - * - There is no free "hole" in virtual memory that fits the - * size of the file - */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - char name[256]; - struct FAB fab; - unsigned short channel; - char *inadr[2], *retadr[2]; - unsigned long status; - long size; - - if (no_mapped >= MAX_MAPPED) - return(0); - /* - * We cannot use a file descriptor, we - * must open the file once more. - */ - if (getname((int)fd, name, 1) == NULL) - return(0); - /* prepare the FAB for a user file open */ - fab = cc$rms_fab; - fab.fab$l_fop |= FAB$V_UFO; - fab.fab$b_fac = FAB$M_GET; - fab.fab$b_shr = FAB$M_SHRGET; - fab.fab$l_fna = name; - fab.fab$b_fns = strlen(name); - status = sys$open(&fab); /* open file & get channel number */ - if ((status&1) == 0) - return(0); - channel = (unsigned short)fab.fab$l_stv; - inadr[0] = inadr[1] = (char *)0; /* just an address in P0 space */ - /* - * Map the blocks of the file up to - * the EOF block into virtual memory. - */ - size = _tiffSizeProc(fd); - status = sys$crmpsc(inadr, retadr, 0, SEC$M_EXPREG, 0,0,0, channel, - TIFFhowmany(size,512), 0,0,0); - if ((status&1) == 0){ - sys$dassgn(channel); - return(0); - } - *pbase = (tdata_t) retadr[0]; /* starting virtual address */ - /* - * Use the size of the file up to the - * EOF mark for UNIX compatibility. - */ - *psize = (toff_t) size; - /* Record the section in the table */ - map_table[no_mapped].base = retadr[0]; - map_table[no_mapped].top = retadr[1]; - map_table[no_mapped].channel = channel; - no_mapped++; - - return(1); -} - -/* - * This routine unmaps a section from the virtual address space of - * the process, but only if the base was the one returned from a - * call to TIFFMapFileContents. - */ -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - char *inadr[2]; - int i, j; - - /* Find the section in the table */ - for (i = 0;i < no_mapped; i++) { - if (map_table[i].base == (char *) base) { - /* Unmap the section */ - inadr[0] = (char *) base; - inadr[1] = map_table[i].top; - sys$deltva(inadr, 0, 0); - sys$dassgn(map_table[i].channel); - /* Remove this section from the list */ - for (j = i+1; j < no_mapped; j++) - map_table[j-1] = map_table[j]; - no_mapped--; - return; - } - } -} -#else /* !HAVE_MMAP */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} -#endif /* !HAVE_MMAP */ - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - if (m&O_TRUNC){ - /* - * There is a bug in open in VAXC. If you use - * open w/ m=O_RDWR|O_CREAT|O_TRUNC the - * wrong thing happens. On the other hand - * creat does the right thing. - */ - fd = creat((char *) /* bug in stdio.h */ name, 0666, - "alq = 128", "deq = 64", "mbc = 32", - "fop = tef"); - } else if (m&O_RDWR) { - fd = open(name, m, 0666, - "deq = 64", "mbc = 32", "fop = tef", "ctx = stm"); - } else - fd = open(name, m, 0666, "mbc = 32", "ctx = stm"); - if (fd < 0) { - TIFFError(module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (malloc((size_t) s)); -} - -void -_TIFFfree(tdata_t p) -{ - free(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (realloc(p, (size_t) s)); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - memset(p, v, (size_t) c); -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - return (memcmp(p1, p2, (size_t) c)); -} - -/* - * On the VAX, we need to make those global, writable pointers - * non-shareable, otherwise they would be made shareable by default. - * On the AXP, this brain damage has been corrected. - * - * I (Karsten Spang, krs@kampsax.dk) have dug around in the GCC - * manual and the GAS code and have come up with the following - * construct, but I don't have GCC on my VAX, so it is untested. - * Please tell me if it does not work. - */ - -static void -vmsWarningHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} - -NOSHARE TIFFErrorHandler _TIFFwarningHandler = vmsWarningHandler -#if defined(VAX) && defined(__GNUC__) -asm("_$$PsectAttributes_NOSHR$$_TIFFwarningHandler") -#endif -; - -static void -vmsErrorHandler(const char* module, const char* fmt, va_list ap) -{ - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -} - -NOSHARE TIFFErrorHandler _TIFFerrorHandler = vmsErrorHandler -#if defined(VAX) && defined(__GNUC__) -asm("_$$PsectAttributes_NOSHR$$_TIFFerrorHandler") -#endif -; - - -#if !HAVE_IEEEFP -/* IEEE floting point handling */ - -typedef struct ieeedouble { - u_long mant2; /* fix NDR: full 8-byte swap */ - u_long mant : 20, - exp : 11, - sign : 1; -} ieeedouble; -typedef struct ieeefloat { - u_long mant : 23, - exp : 8, - sign : 1; -} ieeefloat; - -/* - * NB: These are D_FLOAT's, not G_FLOAT's. A G_FLOAT is - * simply a reverse-IEEE float/double. - */ - -typedef struct { - u_long mant1 : 7, - exp : 8, - sign : 1, - mant2 : 16, - mant3 : 16, - mant4 : 16; -} nativedouble; -typedef struct { - u_long mant1 : 7, - exp : 8, - sign : 1, - mant2 : 16; -} nativefloat; - -typedef union { - ieeedouble ieee; - nativedouble native; - char b[8]; - uint32 l[2]; - double d; -} double_t; - -typedef union { - ieeefloat ieee; - nativefloat native; - char b[4]; - uint32 l; - float f; -} float_t; - -#if defined(VAXC) || defined(DECC) -#pragma inline(ieeetod,dtoieee) -#endif - -/* - * Convert an IEEE double precision number to native double precision. - * The source is contained in two longwords, the second holding the sign, - * exponent and the higher order bits of the mantissa, and the first - * holding the rest of the mantissa as follows: - * (Note: It is assumed that the number has been eight-byte swapped to - * LSB first.) - * - * First longword: - * 32 least significant bits of mantissa - * Second longword: - * 0-19: 20 most significant bits of mantissa - * 20-30: exponent - * 31: sign - * The exponent is stored as excess 1023. - * The most significant bit of the mantissa is implied 1, and not stored. - * If the exponent and mantissa are zero, the number is zero. - * If the exponent is 0 (i.e. -1023) and the mantissa is non-zero, it is an - * unnormalized number with the most significant bit NOT implied. - * If the exponent is 2047, the number is invalid, in case the mantissa is zero, - * this means overflow (+/- depending of the sign bit), otherwise - * it simply means invalid number. - * - * If the number is too large for the machine or was specified as overflow, - * +/-HUGE_VAL is returned. - */ -INLINE static void -ieeetod(double *dp) -{ - double_t source; - long sign,exp,mant; - double dmant; - - source.ieee = ((double_t*)dp)->ieee; - sign = source.ieee.sign; - exp = source.ieee.exp; - mant = source.ieee.mant; - - if (exp == 2047) { - if (mant) /* Not a Number (NAN) */ - *dp = HUGE_VAL; - else /* +/- infinity */ - *dp = (sign ? -HUGE_VAL : HUGE_VAL); - return; - } - if (!exp) { - if (!(mant || source.ieee.mant2)) { /* zero */ - *dp=0; - return; - } else { /* Unnormalized number */ - /* NB: not -1023, the 1 bit is not implied */ - exp= -1022; - } - } else { - mant |= 1<<20; - exp -= 1023; - } - dmant = (((double) mant) + - ((double) source.ieee.mant2) / (((double) (1<<16)) * - ((double) (1<<16)))) / (double) (1<<20); - dmant = ldexp(dmant, exp); - if (sign) - dmant= -dmant; - *dp = dmant; -} - -INLINE static void -dtoieee(double *dp) -{ - double_t num; - double x; - int exp; - - num.d = *dp; - if (!num.d) { /* Zero is just binary all zeros */ - num.l[0] = num.l[1] = 0; - return; - } - - if (num.d < 0) { /* Sign is encoded separately */ - num.d = -num.d; - num.ieee.sign = 1; - } else { - num.ieee.sign = 0; - } - - /* Now separate the absolute value into mantissa and exponent */ - x = frexp(num.d, &exp); - - /* - * Handle cases where the value is outside the - * range for IEEE floating point numbers. - * (Overflow cannot happen on a VAX, but underflow - * can happen for G float.) - */ - if (exp < -1022) { /* Unnormalized number */ - x = ldexp(x, -1023-exp); - exp = 0; - } else if (exp > 1023) { /* +/- infinity */ - x = 0; - exp = 2047; - } else { /* Get rid of most significant bit */ - x *= 2; - x -= 1; - exp += 1022; /* fix NDR: 1.0 -> x=0.5, exp=1 -> ieee.exp = 1023 */ - } - num.ieee.exp = exp; - - x *= (double) (1<<20); - num.ieee.mant = (long) x; - x -= (double) num.ieee.mant; - num.ieee.mant2 = (long) (x*((double) (1<<16)*(double) (1<<16))); - - if (!(num.ieee.mant || num.ieee.exp || num.ieee.mant2)) { - /* Avoid negative zero */ - num.ieee.sign = 0; - } - ((double_t*)dp)->ieee = num.ieee; -} - -/* - * Beware, these do not handle over/under-flow - * during conversion from ieee to native format. - */ -#define NATIVE2IEEEFLOAT(fp) { \ - float_t t; \ - if (t.ieee.exp = (fp)->native.exp) \ - t.ieee.exp += -129 + 127; \ - t.ieee.sign = (fp)->native.sign; \ - t.ieee.mant = ((fp)->native.mant1<<16)|(fp)->native.mant2; \ - *(fp) = t; \ -} -#define IEEEFLOAT2NATIVE(fp) { \ - float_t t; int v = (fp)->ieee.exp; \ - if (v) v += -127 + 129; /* alter bias of exponent */\ - t.native.exp = v; /* implicit truncation of exponent */\ - t.native.sign = (fp)->ieee.sign; \ - v = (fp)->ieee.mant; \ - t.native.mant1 = v >> 16; \ - t.native.mant2 = v;\ - *(fp) = t; \ -} - -#define IEEEDOUBLE2NATIVE(dp) ieeetod(dp) - -#define NATIVE2IEEEDOUBLE(dp) dtoieee(dp) - - -/* - * These unions are used during floating point - * conversions. The above macros define the - * conversion operations. - */ -void -TIFFCvtIEEEFloatToNative(TIFF* tif, u_int n, float* f) -{ - float_t* fp = (float_t*) f; - - while (n-- > 0) { - IEEEFLOAT2NATIVE(fp); - fp++; - } -} - -void -TIFFCvtNativeToIEEEFloat(TIFF* tif, u_int n, float* f) -{ - float_t* fp = (float_t*) f; - - while (n-- > 0) { - NATIVE2IEEEFLOAT(fp); - fp++; - } -} -void -TIFFCvtIEEEDoubleToNative(TIFF* tif, u_int n, double* f) -{ - double_t* fp = (double_t*) f; - - while (n-- > 0) { - IEEEDOUBLE2NATIVE(fp); - fp++; - } -} - -void -TIFFCvtNativeToIEEEDouble(TIFF* tif, u_int n, double* f) -{ - double_t* fp = (double_t*) f; - - while (n-- > 0) { - NATIVE2IEEEDOUBLE(fp); - fp++; - } -} -#endif diff --git a/freeimage241/Source/LibTIFF/tif_warning.c b/freeimage241/Source/LibTIFF/tif_warning.c deleted file mode 100644 index 0eb08b1..0000000 --- a/freeimage241/Source/LibTIFF/tif_warning.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_warning.c,v 1.0 2001-04-13 00:42:38+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - */ -#include "tiffiop.h" - -TIFFErrorHandler -TIFFSetWarningHandler(TIFFErrorHandler handler) -{ - TIFFErrorHandler prev = _TIFFwarningHandler; - _TIFFwarningHandler = handler; - return (prev); -} - -void -TIFFWarning(const char* module, const char* fmt, ...) -{ - if (_TIFFwarningHandler) { - va_list ap; - va_start(ap, fmt); - (*_TIFFwarningHandler)(module, fmt, ap); - va_end(ap); - } -} diff --git a/freeimage241/Source/LibTIFF/tif_win3.c b/freeimage241/Source/LibTIFF/tif_win3.c deleted file mode 100644 index 58b0463..0000000 --- a/freeimage241/Source/LibTIFF/tif_win3.c +++ /dev/null @@ -1,225 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_win3.c,v 1.0 2001-04-13 00:42:39+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library Windows 3.x-specific Routines. - */ -#include "tiffiop.h" -#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(_MSC_VER) -#include /* for open, close, etc. function prototypes */ -#endif - -#include -#include -#include - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (_hread(fd, buf, size)); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - return (_hwrite(fd, buf, size)); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - return (_llseek(fd, (off_t) off, whence)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (_lclose(fd)); -} - -#include - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - struct stat sb; - return (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); -} - -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -/* - * Open a TIFF file descriptor for read/writing. - */ -TIFF* -TIFFFdOpen(int fd, const char* name, const char* mode) -{ - TIFF* tif; - - tif = TIFFClientOpen(name, mode, - (thandle_t) fd, - _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, - _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); - if (tif) - tif->tif_fd = fd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - OFSTRUCT of; - int mm = 0; - - m = _TIFFgetMode(mode, module); - if (m == -1) - return ((TIFF*)0); - if (m & O_CREAT) { - if ((m & O_TRUNC) || OpenFile(name, &of, OF_EXIST) != HFILE_ERROR) - mm |= OF_CREATE; - } - if (m & O_WRONLY) - mm |= OF_WRITE; - if (m & O_RDWR) - mm |= OF_READWRITE; - fd = OpenFile(name, &of, mm); - if (fd < 0) { - TIFFError(module, "%s: Cannot open", name); - return ((TIFF*)0); - } - return (TIFFFdOpen(fd, name, mode)); -} - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return (tdata_t) GlobalAllocPtr(GHND, (DWORD) s); -} - -void -_TIFFfree(tdata_t p) -{ - GlobalFreePtr(p); -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - return (tdata_t) GlobalReAllocPtr(p, (DWORD) s, GHND); -} - -void -_TIFFmemset(tdata_t p, int v, tsize_t c) -{ - char* pp = (char*) p; - - while (c > 0) { - tsize_t chunk = 0x10000 - ((uint32) pp & 0xffff);/* What's left in segment */ - if (chunk > 0xff00) /* No more than 0xff00 */ - chunk = 0xff00; - if (chunk > c) /* No more than needed */ - chunk = c; - memset(pp, v, chunk); - pp = (char*) (chunk + (char huge*) pp); - c -= chunk; - } -} - -void -_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) -{ - if (c > 0xFFFF) - hmemcpy((void _huge*) d, (void _huge*) s, c); - else - (void) memcpy(d, s, (size_t) c); -} - -int -_TIFFmemcmp(const tdata_t d, const tdata_t s, tsize_t c) -{ - char* dd = (char*) d; - char* ss = (char*) s; - tsize_t chunks, chunkd, chunk; - int result; - - while (c > 0) { - chunks = 0x10000 - ((uint32) ss & 0xffff); /* What's left in segment */ - chunkd = 0x10000 - ((uint32) dd & 0xffff); /* What's left in segment */ - chunk = c; /* Get the largest of */ - if (chunk > chunks) /* c, chunks, chunkd, */ - chunk = chunks; /* 0xff00 */ - if (chunk > chunkd) - chunk = chunkd; - if (chunk > 0xff00) - chunk = 0xff00; - result = memcmp(dd, ss, chunk); - if (result != 0) - return (result); - dd = (char*) (chunk + (char huge*) dd); - ss = (char*) (chunk + (char huge*) ss); - c -= chunk; - } - return (0); -} - -static void -win3WarningHandler(const char* module, const char* fmt, va_list ap) -{ - char e[512] = { '\0' }; - if (module != NULL) - strcat(strcpy(e, module), ":"); - vsprintf(e+strlen(e), fmt, ap); - strcat(e, "."); - MessageBox(GetActiveWindow(), e, "LibTIFF Warning", - MB_OK|MB_ICONEXCLAMATION); -} -TIFFErrorHandler _TIFFwarningHandler = win3WarningHandler; - -static void -win3ErrorHandler(const char* module, const char* fmt, va_list ap) -{ - char e[512] = { '\0' }; - if (module != NULL) - strcat(strcpy(e, module), ":"); - vsprintf(e+strlen(e), fmt, ap); - strcat(e, "."); - MessageBox(GetActiveWindow(), e, "LibTIFF Error", MB_OK|MB_ICONSTOP); -} -TIFFErrorHandler _TIFFerrorHandler = win3ErrorHandler; diff --git a/freeimage241/Source/LibTIFF/tif_win32.c b/freeimage241/Source/LibTIFF/tif_win32.c deleted file mode 100644 index 266d652..0000000 --- a/freeimage241/Source/LibTIFF/tif_win32.c +++ /dev/null @@ -1,323 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_win32.c,v 1.0 2001-04-13 00:42:39+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library Win32-specific Routines. Adapted from tif_unix.c 4/5/95 by - * Scott Wagner (wagner@itek.com), Itek Graphix, Rochester, NY USA - */ -#include -#include "tiffiop.h" - -static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - DWORD dwSizeRead; - if (!ReadFile(fd, buf, size, &dwSizeRead, NULL)) - return(0); - return ((tsize_t) dwSizeRead); -} - -static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) -{ - DWORD dwSizeWritten; - if (!WriteFile(fd, buf, size, &dwSizeWritten, NULL)) - return(0); - return ((tsize_t) dwSizeWritten); -} - -static toff_t -_tiffSeekProc(thandle_t fd, toff_t off, int whence) -{ - DWORD dwMoveMethod, dwMoveHigh; - - /* we use this as a special code, so avoid accepting it */ - if( off == 0xFFFFFFFF ) - return 0xFFFFFFFF; - - switch(whence) - { - case SEEK_SET: - dwMoveMethod = FILE_BEGIN; - break; - case SEEK_CUR: - dwMoveMethod = FILE_CURRENT; - break; - case SEEK_END: - dwMoveMethod = FILE_END; - break; - default: - dwMoveMethod = FILE_BEGIN; - break; - } - dwMoveHigh = 0; - return ((toff_t)SetFilePointer(fd, (LONG) off, (PLONG)&dwMoveHigh, - dwMoveMethod)); -} - -static int -_tiffCloseProc(thandle_t fd) -{ - return (CloseHandle(fd) ? 0 : -1); -} - -static toff_t -_tiffSizeProc(thandle_t fd) -{ - return ((toff_t)GetFileSize(fd, NULL)); -} - -#ifdef __BORLANDC__ -#pragma argsused -#endif -static int -_tiffDummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - return (0); -} - -/* - * From "Hermann Josef Hill" : - * - * Windows uses both a handle and a pointer for file mapping, - * but according to the SDK documentation and Richter's book - * "Advanced Windows Programming" it is safe to free the handle - * after obtaining the file mapping pointer - * - * This removes a nasty OS dependency and cures a problem - * with Visual C++ 5.0 - */ -static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) -{ - toff_t size; - HANDLE hMapFile; - - if ((size = _tiffSizeProc(fd)) == 0xFFFFFFFF) - return (0); - hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, size, NULL); - if (hMapFile == NULL) - return (0); - *pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0); - CloseHandle(hMapFile); - if (*pbase == NULL) - return (0); - *psize = size; - return(1); -} - -#ifdef __BORLANDC__ -#pragma argsused -#endif -static void -_tiffDummyUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ -} - -static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) -{ - UnmapViewOfFile(base); -} - -/* - * Open a TIFF file descriptor for read/writing. - * Note that TIFFFdOpen and TIFFOpen recognise the character 'u' in the mode - * string, which forces the file to be opened unmapped. - */ -TIFF* -TIFFFdOpen(int ifd, const char* name, const char* mode) -{ - TIFF* tif; - BOOL fSuppressMap = (mode[1] == 'u' || (mode[1]!=0 && mode[2] == 'u')); - - tif = TIFFClientOpen(name, mode, - (thandle_t)ifd, - _tiffReadProc, _tiffWriteProc, - _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, - fSuppressMap ? _tiffDummyMapProc : _tiffMapProc, - fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc); - if (tif) - tif->tif_fd = ifd; - return (tif); -} - -/* - * Open a TIFF file for read/writing. - */ -TIFF* -TIFFOpen(const char* name, const char* mode) -{ - static const char module[] = "TIFFOpen"; - thandle_t fd; - int m; - DWORD dwMode; - - m = _TIFFgetMode(mode, module); - - switch(m) - { - case O_RDONLY: - dwMode = OPEN_EXISTING; - break; - case O_RDWR: - dwMode = OPEN_ALWAYS; - break; - case O_RDWR|O_CREAT: - dwMode = OPEN_ALWAYS; - break; - case O_RDWR|O_TRUNC: - dwMode = CREATE_ALWAYS; - break; - case O_RDWR|O_CREAT|O_TRUNC: - dwMode = CREATE_ALWAYS; - break; - default: - return ((TIFF*)0); - } - fd = (thandle_t)CreateFile(name, (m == O_RDONLY) ? GENERIC_READ : - (GENERIC_READ | GENERIC_WRITE), FILE_SHARE_READ, NULL, dwMode, - (m == O_RDONLY) ? FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_NORMAL, NULL); - if (fd == INVALID_HANDLE_VALUE) { - TIFFError(module, "%s: Cannot open", name); - return ((TIFF *)0); - } - return (TIFFFdOpen((int)fd, name, mode)); -} - -tdata_t -_TIFFmalloc(tsize_t s) -{ - return ((tdata_t)GlobalAlloc(GMEM_FIXED, s)); -} - -void -_TIFFfree(tdata_t p) -{ - GlobalFree(p); - return; -} - -tdata_t -_TIFFrealloc(tdata_t p, tsize_t s) -{ - void* pvTmp; - tsize_t old=GlobalSize(p); - if (old>=s) - { - if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { - CopyMemory(pvTmp, p, s); - GlobalFree(p); - } - } - else - { - if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { - CopyMemory(pvTmp, p, old); - GlobalFree(p); - } - } - return ((tdata_t)pvTmp); -} - -void -_TIFFmemset(void* p, int v, tsize_t c) -{ - FillMemory(p, c, (BYTE)v); -} - -void -_TIFFmemcpy(void* d, const tdata_t s, tsize_t c) -{ - CopyMemory(d, s, c); -} - -int -_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) -{ - register const BYTE *pb1 = (const BYTE *) p1; - register const BYTE *pb2 = (const BYTE *) p2; - register DWORD dwTmp = c; - register int iTmp; - for (iTmp = 0; dwTmp-- && !iTmp; iTmp = (int)*pb1++ - (int)*pb2++) - ; - return (iTmp); -} - -static void -Win32WarningHandler(const char* module, const char* fmt, va_list ap) -{ -#ifndef TIF_PLATFORM_CONSOLE - LPTSTR szTitle; - LPTSTR szTmp; - LPCTSTR szTitleText = "%s Warning"; - LPCTSTR szDefaultModule = "TIFFLIB"; - szTmp = (module == NULL) ? (LPTSTR)szDefaultModule : (LPTSTR)module; - if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (lstrlen(szTmp) + - lstrlen(szTitleText) + lstrlen(fmt) + 128)*sizeof(TCHAR))) == NULL) - return; - wsprintf(szTitle, szTitleText, szTmp); - szTmp = szTitle + (lstrlen(szTitle)+2)*sizeof(TCHAR); - wvsprintf(szTmp, fmt, ap); - MessageBox(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION); - LocalFree(szTitle); - return; -#else - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -#endif -} -TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler; - -static void -Win32ErrorHandler(const char* module, const char* fmt, va_list ap) -{ -#ifndef TIF_PLATFORM_CONSOLE - LPTSTR szTitle; - LPTSTR szTmp; - LPCTSTR szTitleText = "%s Error"; - LPCTSTR szDefaultModule = "TIFFLIB"; - szTmp = (module == NULL) ? (LPTSTR)szDefaultModule : (LPTSTR)module; - if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (lstrlen(szTmp) + - lstrlen(szTitleText) + lstrlen(fmt) + 128)*sizeof(TCHAR))) == NULL) - return; - wsprintf(szTitle, szTitleText, szTmp); - szTmp = szTitle + (lstrlen(szTitle)+2)*sizeof(TCHAR); - wvsprintf(szTmp, fmt, ap); - MessageBox(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION); - LocalFree(szTitle); - return; -#else - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); -#endif -} -TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler; diff --git a/freeimage241/Source/LibTIFF/tif_write.c b/freeimage241/Source/LibTIFF/tif_write.c deleted file mode 100644 index d0bfc70..0000000 --- a/freeimage241/Source/LibTIFF/tif_write.c +++ /dev/null @@ -1,659 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_write.c,v 1.0 2001-04-13 00:42:39+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library. - * - * Scanline-oriented Write Support - */ -#include "tiffiop.h" -#include -#include - -#define REWRITE_HACK - -#define STRIPINCR 20 /* expansion factor on strip array */ - -#define WRITECHECKSTRIPS(tif, module) \ - (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),0,module)) -#define WRITECHECKTILES(tif, module) \ - (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),1,module)) -#define BUFFERCHECK(tif) \ - ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \ - TIFFWriteBufferSetup((tif), NULL, (tsize_t) -1)) - -static int TIFFGrowStrips(TIFF*, int, const char*); -static int TIFFAppendToStrip(TIFF*, tstrip_t, tidata_t, tsize_t); -static int TIFFSetupStrips(TIFF*); - -int -TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) -{ - static const char module[] = "TIFFWriteScanline"; - register TIFFDirectory *td; - int status, imagegrew = 0; - tstrip_t strip; - - if (!WRITECHECKSTRIPS(tif, module)) - return (-1); - /* - * Handle delayed allocation of data buffer. This - * permits it to be sized more intelligently (using - * directory information). - */ - if (!BUFFERCHECK(tif)) - return (-1); - td = &tif->tif_dir; - /* - * Extend image length if needed - * (but only for PlanarConfig=1). - */ - if (row >= td->td_imagelength) { /* extend image */ - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFError(tif->tif_name, - "Can not change \"ImageLength\" when using separate planes"); - return (-1); - } - td->td_imagelength = row+1; - imagegrew = 1; - } - /* - * Calculate strip and check for crossings. - */ - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - if (sample >= td->td_samplesperpixel) { - TIFFError(tif->tif_name, - "%d: Sample out of range, max %d", - sample, td->td_samplesperpixel); - return (-1); - } - strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; - } else - strip = row / td->td_rowsperstrip; - if (strip != tif->tif_curstrip) { - /* - * Changing strips -- flush any data present. - */ - if (!TIFFFlushData(tif)) - return (-1); - tif->tif_curstrip = strip; - /* - * Watch out for a growing image. The value of - * strips/image will initially be 1 (since it - * can't be deduced until the imagelength is known). - */ - if (strip >= td->td_stripsperimage && imagegrew) - td->td_stripsperimage = - TIFFhowmany(td->td_imagelength,td->td_rowsperstrip); - tif->tif_row = - (strip % td->td_stripsperimage) * td->td_rowsperstrip; - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupencode)(tif)) - return (-1); - tif->tif_flags |= TIFF_CODERSETUP; - } - if (!(*tif->tif_preencode)(tif, sample)) - return (-1); - tif->tif_flags |= TIFF_POSTENCODE; - } - /* - * Check strip array to make sure there's space. - * We don't support dynamically growing files that - * have data organized in separate bitplanes because - * it's too painful. In that case we require that - * the imagelength be set properly before the first - * write (so that the strips array will be fully - * allocated above). - */ - if (strip >= td->td_nstrips && !TIFFGrowStrips(tif, 1, module)) - return (-1); - /* - * Ensure the write is either sequential or at the - * beginning of a strip (or that we can randomly - * access the data -- i.e. no encoding). - */ - if (row != tif->tif_row) { - if (row < tif->tif_row) { - /* - * Moving backwards within the same strip: - * backup to the start and then decode - * forward (below). - */ - tif->tif_row = (strip % td->td_stripsperimage) * - td->td_rowsperstrip; - tif->tif_rawcp = tif->tif_rawdata; - } - /* - * Seek forward to the desired row. - */ - if (!(*tif->tif_seek)(tif, row - tif->tif_row)) - return (-1); - tif->tif_row = row; - } - status = (*tif->tif_encoderow)(tif, (tidata_t) buf, - tif->tif_scanlinesize, sample); - tif->tif_row++; - return (status); -} - -/* - * Encode the supplied data and write it to the - * specified strip. There must be space for the - * data; we don't check if strips overlap! - * - * NB: Image length must be setup before writing. - */ -tsize_t -TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) -{ - static const char module[] = "TIFFWriteEncodedStrip"; - TIFFDirectory *td = &tif->tif_dir; - tsample_t sample; - - if (!WRITECHECKSTRIPS(tif, module)) - return ((tsize_t) -1); - /* - * Check strip array to make sure there's space. - * We don't support dynamically growing files that - * have data organized in separate bitplanes because - * it's too painful. In that case we require that - * the imagelength be set properly before the first - * write (so that the strips array will be fully - * allocated above). - */ - if (strip >= td->td_nstrips) { - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFError(tif->tif_name, - "Can not grow image by strips when using separate planes"); - return ((tsize_t) -1); - } - if (!TIFFGrowStrips(tif, 1, module)) - return ((tsize_t) -1); - td->td_stripsperimage = - TIFFhowmany(td->td_imagelength, td->td_rowsperstrip); - } - /* - * Handle delayed allocation of data buffer. This - * permits it to be sized according to the directory - * info. - */ - if (!BUFFERCHECK(tif)) - return ((tsize_t) -1); - tif->tif_curstrip = strip; - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupencode)(tif)) - return ((tsize_t) -1); - tif->tif_flags |= TIFF_CODERSETUP; - } - -#ifdef REWRITE_HACK - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - - if( td->td_stripbytecount[strip] > 0 ) - { - /* if we are writing over existing tiles, zero length. */ - td->td_stripbytecount[strip] = 0; - - /* this forces TIFFAppendToStrip() to do a seek */ - tif->tif_curoff = 0; - } -#endif - - tif->tif_flags &= ~TIFF_POSTENCODE; - sample = (tsample_t)(strip / td->td_stripsperimage); - if (!(*tif->tif_preencode)(tif, sample)) - return ((tsize_t) -1); - if (!(*tif->tif_encodestrip)(tif, (tidata_t) data, cc, sample)) - return ((tsize_t) 0); - if (!(*tif->tif_postencode)(tif)) - return ((tsize_t) -1); - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(tif->tif_rawdata, tif->tif_rawcc); - if (tif->tif_rawcc > 0 && - !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc)) - return ((tsize_t) -1); - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - return (cc); -} - -/* - * Write the supplied data to the specified strip. - * There must be space for the data; we don't check - * if strips overlap! - * - * NB: Image length must be setup before writing. - */ -tsize_t -TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) -{ - static const char module[] = "TIFFWriteRawStrip"; - TIFFDirectory *td = &tif->tif_dir; - - if (!WRITECHECKSTRIPS(tif, module)) - return ((tsize_t) -1); - /* - * Check strip array to make sure there's space. - * We don't support dynamically growing files that - * have data organized in separate bitplanes because - * it's too painful. In that case we require that - * the imagelength be set properly before the first - * write (so that the strips array will be fully - * allocated above). - */ - if (strip >= td->td_nstrips) { - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFError(tif->tif_name, - "Can not grow image by strips when using separate planes"); - return ((tsize_t) -1); - } - /* - * Watch out for a growing image. The value of - * strips/image will initially be 1 (since it - * can't be deduced until the imagelength is known). - */ - if (strip >= td->td_stripsperimage) - td->td_stripsperimage = - TIFFhowmany(td->td_imagelength,td->td_rowsperstrip); - if (!TIFFGrowStrips(tif, 1, module)) - return ((tsize_t) -1); - } - tif->tif_curstrip = strip; - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - return (TIFFAppendToStrip(tif, strip, (tidata_t) data, cc) ? - cc : (tsize_t) -1); -} - -/* - * Write and compress a tile of data. The - * tile is selected by the (x,y,z,s) coordinates. - */ -tsize_t -TIFFWriteTile(TIFF* tif, - tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) -{ - if (!TIFFCheckTile(tif, x, y, z, s)) - return (-1); - /* - * NB: A tile size of -1 is used instead of tif_tilesize knowing - * that TIFFWriteEncodedTile will clamp this to the tile size. - * This is done because the tile size may not be defined until - * after the output buffer is setup in TIFFWriteBufferSetup. - */ - return (TIFFWriteEncodedTile(tif, - TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); -} - -/* - * Encode the supplied data and write it to the - * specified tile. There must be space for the - * data. The function clamps individual writes - * to a tile to the tile size, but does not (and - * can not) check that multiple writes to the same - * tile do not write more than tile size data. - * - * NB: Image length must be setup before writing; this - * interface does not support automatically growing - * the image on each write (as TIFFWriteScanline does). - */ -tsize_t -TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) -{ - static const char module[] = "TIFFWriteEncodedTile"; - TIFFDirectory *td; - tsample_t sample; - - if (!WRITECHECKTILES(tif, module)) - return ((tsize_t) -1); - td = &tif->tif_dir; - if (tile >= td->td_nstrips) { - TIFFError(module, "%s: Tile %lu out of range, max %lu", - tif->tif_name, (u_long) tile, (u_long) td->td_nstrips); - return ((tsize_t) -1); - } - /* - * Handle delayed allocation of data buffer. This - * permits it to be sized more intelligently (using - * directory information). - */ - if (!BUFFERCHECK(tif)) - return ((tsize_t) -1); - tif->tif_curtile = tile; - -#ifdef REWRITE_HACK - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - - if( td->td_stripbytecount[tile] > 0 ) - { - /* if we are writing over existing tiles, zero length. */ - td->td_stripbytecount[tile] = 0; - - /* this forces TIFFAppendToStrip() to do a seek */ - tif->tif_curoff = 0; - } -#endif - - /* - * Compute tiles per row & per column to compute - * current row and column - */ - tif->tif_row = (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) - * td->td_tilelength; - tif->tif_col = (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth)) - * td->td_tilewidth; - - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { - if (!(*tif->tif_setupencode)(tif)) - return ((tsize_t) -1); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_flags &= ~TIFF_POSTENCODE; - sample = (tsample_t)(tile/td->td_stripsperimage); - if (!(*tif->tif_preencode)(tif, sample)) - return ((tsize_t) -1); - /* - * Clamp write amount to the tile size. This is mostly - * done so that callers can pass in some large number - * (e.g. -1) and have the tile size used instead. - */ - if ( cc < 1 || cc > tif->tif_tilesize) - cc = tif->tif_tilesize; - if (!(*tif->tif_encodetile)(tif, (tidata_t) data, cc, sample)) - return ((tsize_t) 0); - if (!(*tif->tif_postencode)(tif)) - return ((tsize_t) -1); - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((u_char *)tif->tif_rawdata, tif->tif_rawcc); - if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, - tif->tif_rawdata, tif->tif_rawcc)) - return ((tsize_t) -1); - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - return (cc); -} - -/* - * Write the supplied data to the specified strip. - * There must be space for the data; we don't check - * if strips overlap! - * - * NB: Image length must be setup before writing; this - * interface does not support automatically growing - * the image on each write (as TIFFWriteScanline does). - */ -tsize_t -TIFFWriteRawTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) -{ - static const char module[] = "TIFFWriteRawTile"; - - if (!WRITECHECKTILES(tif, module)) - return ((tsize_t) -1); - if (tile >= tif->tif_dir.td_nstrips) { - TIFFError(module, "%s: Tile %lu out of range, max %lu", - tif->tif_name, (u_long) tile, - (u_long) tif->tif_dir.td_nstrips); - return ((tsize_t) -1); - } - return (TIFFAppendToStrip(tif, tile, (tidata_t) data, cc) ? - cc : (tsize_t) -1); -} - -#define isUnspecified(tif, f) \ - (TIFFFieldSet(tif,f) && (tif)->tif_dir.td_imagelength == 0) - -static int -TIFFSetupStrips(TIFF* tif) -{ - TIFFDirectory* td = &tif->tif_dir; - - if (isTiled(tif)) - td->td_stripsperimage = - isUnspecified(tif, FIELD_TILEDIMENSIONS) ? - td->td_samplesperpixel : TIFFNumberOfTiles(tif); - else - td->td_stripsperimage = - isUnspecified(tif, FIELD_ROWSPERSTRIP) ? - td->td_samplesperpixel : TIFFNumberOfStrips(tif); - td->td_nstrips = td->td_stripsperimage; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - td->td_stripsperimage /= td->td_samplesperpixel; - td->td_stripoffset = (uint32 *) - _TIFFmalloc(td->td_nstrips * sizeof (uint32)); - td->td_stripbytecount = (uint32 *) - _TIFFmalloc(td->td_nstrips * sizeof (uint32)); - if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL) - return (0); - /* - * Place data at the end-of-file - * (by setting offsets to zero). - */ - _TIFFmemset(td->td_stripoffset, 0, td->td_nstrips*sizeof (uint32)); - _TIFFmemset(td->td_stripbytecount, 0, td->td_nstrips*sizeof (uint32)); - TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); - TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); - return (1); -} -#undef isUnspecified - -/* - * Verify file is writable and that the directory - * information is setup properly. In doing the latter - * we also "freeze" the state of the directory so - * that important information is not changed. - */ -int -TIFFWriteCheck(TIFF* tif, int tiles, const char* module) -{ - if (tif->tif_mode == O_RDONLY) { - TIFFError(module, "%s: File not open for writing", - tif->tif_name); - return (0); - } - if (tiles ^ isTiled(tif)) { - TIFFError(tif->tif_name, tiles ? - "Can not write tiles to a stripped image" : - "Can not write scanlines to a tiled image"); - return (0); - } - /* - * On the first write verify all the required information - * has been setup and initialize any data structures that - * had to wait until directory information was set. - * Note that a lot of our work is assumed to remain valid - * because we disallow any of the important parameters - * from changing after we start writing (i.e. once - * TIFF_BEENWRITING is set, TIFFSetField will only allow - * the image's length to be changed). - */ - if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { - TIFFError(module, - "%s: Must set \"ImageWidth\" before writing data", - tif->tif_name); - return (0); - } - if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { - TIFFError(module, - "%s: Must set \"PlanarConfiguration\" before writing data", - tif->tif_name); - return (0); - } - if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) { - tif->tif_dir.td_nstrips = 0; - TIFFError(module, "%s: No space for %s arrays", - tif->tif_name, isTiled(tif) ? "tile" : "strip"); - return (0); - } - tif->tif_tilesize = TIFFTileSize(tif); - tif->tif_scanlinesize = TIFFScanlineSize(tif); - tif->tif_flags |= TIFF_BEENWRITING; - return (1); -} - -/* - * Setup the raw data buffer used for encoding. - */ -int -TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) -{ - static const char module[] = "TIFFWriteBufferSetup"; - - if (tif->tif_rawdata) { - if (tif->tif_flags & TIFF_MYBUFFER) { - _TIFFfree(tif->tif_rawdata); - tif->tif_flags &= ~TIFF_MYBUFFER; - } - tif->tif_rawdata = NULL; - } - if (size == (tsize_t) -1) { - size = (isTiled(tif) ? - tif->tif_tilesize : tif->tif_scanlinesize); - /* - * Make raw data buffer at least 8K - */ - if (size < 8*1024) - size = 8*1024; - bp = NULL; /* NB: force malloc */ - } - if (bp == NULL) { - bp = _TIFFmalloc(size); - if (bp == NULL) { - TIFFError(module, "%s: No space for output buffer", - tif->tif_name); - return (0); - } - tif->tif_flags |= TIFF_MYBUFFER; - } else - tif->tif_flags &= ~TIFF_MYBUFFER; - tif->tif_rawdata = (tidata_t) bp; - tif->tif_rawdatasize = size; - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - tif->tif_flags |= TIFF_BUFFERSETUP; - return (1); -} - -/* - * Grow the strip data structures by delta strips. - */ -static int -TIFFGrowStrips(TIFF* tif, int delta, const char* module) -{ - TIFFDirectory *td = &tif->tif_dir; - - assert(td->td_planarconfig == PLANARCONFIG_CONTIG); - td->td_stripoffset = (uint32*)_TIFFrealloc(td->td_stripoffset, - (td->td_nstrips + delta) * sizeof (uint32)); - td->td_stripbytecount = (uint32*)_TIFFrealloc(td->td_stripbytecount, - (td->td_nstrips + delta) * sizeof (uint32)); - if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL) { - td->td_nstrips = 0; - TIFFError(module, "%s: No space to expand strip arrays", - tif->tif_name); - return (0); - } - _TIFFmemset(td->td_stripoffset+td->td_nstrips, 0, delta*sizeof (uint32)); - _TIFFmemset(td->td_stripbytecount+td->td_nstrips, 0, delta*sizeof (uint32)); - td->td_nstrips += delta; - return (1); -} - -/* - * Append the data to the specified strip. - * - * NB: We don't check that there's space in the - * file (i.e. that strips do not overlap). - */ -static int -TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) -{ - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "TIFFAppendToStrip"; - - if (td->td_stripoffset[strip] == 0 || tif->tif_curoff == 0) { - /* - * No current offset, set the current strip. - */ - if (td->td_stripoffset[strip] != 0) { - if (!SeekOK(tif, td->td_stripoffset[strip])) { - TIFFError(module, - "%s: Seek error at scanline %lu", - tif->tif_name, (u_long) tif->tif_row); - return (0); - } - } else - td->td_stripoffset[strip] = - TIFFSeekFile(tif, (toff_t) 0, SEEK_END); - tif->tif_curoff = td->td_stripoffset[strip]; - } - if (!WriteOK(tif, data, cc)) { - TIFFError(module, "%s: Write error at scanline %lu", - tif->tif_name, (u_long) tif->tif_row); - return (0); - } - tif->tif_curoff += cc; - td->td_stripbytecount[strip] += cc; - return (1); -} - -/* - * Internal version of TIFFFlushData that can be - * called by ``encodestrip routines'' w/o concern - * for infinite recursion. - */ -int -TIFFFlushData1(TIFF* tif) -{ - if (tif->tif_rawcc > 0) { - if (!isFillOrder(tif, tif->tif_dir.td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((u_char *)tif->tif_rawdata, - tif->tif_rawcc); - if (!TIFFAppendToStrip(tif, - isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, - tif->tif_rawdata, tif->tif_rawcc)) - return (0); - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - } - return (1); -} - -/* - * Set the current write offset. This should only be - * used to set the offset to a known previous location - * (very carefully), or to 0 so that the next write gets - * appended to the end of the file. - */ -void -TIFFSetWriteOffset(TIFF* tif, toff_t off) -{ - tif->tif_curoff = off; -} diff --git a/freeimage241/Source/LibTIFF/tif_zip.c b/freeimage241/Source/LibTIFF/tif_zip.c deleted file mode 100644 index d8b4d10..0000000 --- a/freeimage241/Source/LibTIFF/tif_zip.c +++ /dev/null @@ -1,367 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tif_zip.c,v 1.0 2001-04-13 00:42:40+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1995-1997 Sam Leffler - * Copyright (c) 1995-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "tiffiop.h" -#ifdef ZIP_SUPPORT -/* - * TIFF Library. - * - * ZIP (aka Deflate) Compression Support - * - * This file is simply an interface to the zlib library written by - * Jean-loup Gailly and Mark Adler. You must use version 1.0 or later - * of the library: this code assumes the 1.0 API and also depends on - * the ability to write the zlib header multiple times (one per strip) - * which was not possible with versions prior to 0.95. Note also that - * older versions of this codec avoided this bug by supressing the header - * entirely. This means that files written with the old library cannot - * be read; they should be converted to a different compression scheme - * and then reconverted. - * - * The data format used by the zlib library is described in the files - * zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available in the - * directory ftp://ftp.uu.net/pub/archiving/zip/doc. The library was - * last found at ftp://ftp.uu.net/pub/archiving/zip/zlib/zlib-0.99.tar.gz. - */ -#include "tif_predict.h" -#include "zlib.h" - -#include -#include - -/* - * Sigh, ZLIB_VERSION is defined as a string so there's no - * way to do a proper check here. Instead we guess based - * on the presence of #defines that were added between the - * 0.95 and 1.0 distributions. - */ -#if !defined(Z_NO_COMPRESSION) || !defined(Z_DEFLATED) -#error "Antiquated ZLIB software; you must use version 1.0 or later" -#endif - -/* - * State block for each open TIFF - * file using ZIP compression/decompression. - */ -typedef struct { - TIFFPredictorState predict; - z_stream stream; - int zipquality; /* compression level */ - int state; /* state flags */ -#define ZSTATE_INIT 0x1 /* zlib setup successfully */ - - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ -} ZIPState; - -#define ZState(tif) ((ZIPState*) (tif)->tif_data) -#define DecoderState(tif) ZState(tif) -#define EncoderState(tif) ZState(tif) - -static int ZIPEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int ZIPDecode(TIFF*, tidata_t, tsize_t, tsample_t); - -static int -ZIPSetupDecode(TIFF* tif) -{ - ZIPState* sp = DecoderState(tif); - static const char module[] = "ZIPSetupDecode"; - - assert(sp != NULL); - if (inflateInit(&sp->stream) != Z_OK) { - TIFFError(module, "%s: %s", tif->tif_name, sp->stream.msg); - return (0); - } else { - sp->state |= ZSTATE_INIT; - return (1); - } -} - -/* - * Setup state for decoding a strip. - */ -static int -ZIPPreDecode(TIFF* tif, tsample_t s) -{ - ZIPState* sp = DecoderState(tif); - - (void) s; - assert(sp != NULL); - sp->stream.next_in = tif->tif_rawdata; - sp->stream.avail_in = tif->tif_rawcc; - return (inflateReset(&sp->stream) == Z_OK); -} - -static int -ZIPDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) -{ - ZIPState* sp = DecoderState(tif); - static const char module[] = "ZIPDecode"; - - (void) s; - assert(sp != NULL); - sp->stream.next_out = op; - sp->stream.avail_out = occ; - do { - int state = inflate(&sp->stream, Z_PARTIAL_FLUSH); - if (state == Z_STREAM_END) - break; - if (state == Z_DATA_ERROR) { - TIFFError(module, - "%s: Decoding error at scanline %d, %s", - tif->tif_name, tif->tif_row, sp->stream.msg); - if (inflateSync(&sp->stream) != Z_OK) - return (0); - continue; - } - if (state != Z_OK) { - TIFFError(module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } while (sp->stream.avail_out > 0); - if (sp->stream.avail_out != 0) { - TIFFError(module, - "%s: Not enough data at scanline %d (short %d bytes)", - tif->tif_name, tif->tif_row, sp->stream.avail_out); - return (0); - } - return (1); -} - -static int -ZIPSetupEncode(TIFF* tif) -{ - ZIPState* sp = EncoderState(tif); - static const char module[] = "ZIPSetupEncode"; - - assert(sp != NULL); - if (deflateInit(&sp->stream, sp->zipquality) != Z_OK) { - TIFFError(module, "%s: %s", tif->tif_name, sp->stream.msg); - return (0); - } else { - sp->state |= ZSTATE_INIT; - return (1); - } -} - -/* - * Reset encoding state at the start of a strip. - */ -static int -ZIPPreEncode(TIFF* tif, tsample_t s) -{ - ZIPState *sp = EncoderState(tif); - - (void) s; - assert(sp != NULL); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - return (deflateReset(&sp->stream) == Z_OK); -} - -/* - * Encode a chunk of pixels. - */ -static int -ZIPEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) -{ - ZIPState *sp = EncoderState(tif); - static const char module[] = "ZIPEncode"; - - (void) s; - sp->stream.next_in = bp; - sp->stream.avail_in = cc; - do { - if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { - TIFFError(module, "%s: Encoder error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - if (sp->stream.avail_out == 0) { - tif->tif_rawcc = tif->tif_rawdatasize; - TIFFFlushData1(tif); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - } - } while (sp->stream.avail_in > 0); - return (1); -} - -/* - * Finish off an encoded strip by flushing the last - * string and tacking on an End Of Information code. - */ -static int -ZIPPostEncode(TIFF* tif) -{ - ZIPState *sp = EncoderState(tif); - static const char module[] = "ZIPPostEncode"; - int state; - - sp->stream.avail_in = 0; - do { - state = deflate(&sp->stream, Z_FINISH); - switch (state) { - case Z_STREAM_END: - case Z_OK: - if (sp->stream.avail_out != tif->tif_rawdatasize) { - tif->tif_rawcc = - tif->tif_rawdatasize - sp->stream.avail_out; - TIFFFlushData1(tif); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; - } - break; - default: - TIFFError(module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } while (state != Z_STREAM_END); - return (1); -} - -static void -ZIPCleanup(TIFF* tif) -{ - ZIPState* sp = ZState(tif); - if (sp) { - if (sp->state&ZSTATE_INIT) { - /* NB: avoid problems in the library */ - if (tif->tif_mode == O_RDONLY) - inflateEnd(&sp->stream); - else - deflateEnd(&sp->stream); - } - _TIFFfree(sp); - tif->tif_data = NULL; - } -} - -static int -ZIPVSetField(TIFF* tif, ttag_t tag, va_list ap) -{ - ZIPState* sp = ZState(tif); - static const char module[] = "ZIPVSetField"; - - switch (tag) { - case TIFFTAG_ZIPQUALITY: - sp->zipquality = va_arg(ap, int); - if (tif->tif_mode != O_RDONLY && (sp->state&ZSTATE_INIT)) { - if (deflateParams(&sp->stream, - sp->zipquality, Z_DEFAULT_STRATEGY) != Z_OK) { - TIFFError(module, "%s: zlib error: %s", - tif->tif_name, sp->stream.msg); - return (0); - } - } - return (1); - default: - return (*sp->vsetparent)(tif, tag, ap); - } - /*NOTREACHED*/ -} - -static int -ZIPVGetField(TIFF* tif, ttag_t tag, va_list ap) -{ - ZIPState* sp = ZState(tif); - - switch (tag) { - case TIFFTAG_ZIPQUALITY: - *va_arg(ap, int*) = sp->zipquality; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); -} - -static const TIFFFieldInfo zipFieldInfo[] = { - { TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, FIELD_PSEUDO, - TRUE, FALSE, "" }, -}; -#define N(a) (sizeof (a) / sizeof (a[0])) - -int -TIFFInitZIP(TIFF* tif, int scheme) -{ - ZIPState* sp; - - assert( (scheme == COMPRESSION_DEFLATE) || (scheme == COMPRESSION_ADOBE_DEFLATE)); - - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (ZIPState)); - if (tif->tif_data == NULL) - goto bad; - sp = ZState(tif); - sp->stream.zalloc = NULL; - sp->stream.zfree = NULL; - sp->stream.opaque = NULL; - sp->stream.data_type = Z_BINARY; - - /* - * Merge codec-specific tag information and - * override parent get/set field methods. - */ - _TIFFMergeFieldInfo(tif, zipFieldInfo, N(zipFieldInfo)); - sp->vgetparent = tif->tif_vgetfield; - tif->tif_vgetfield = ZIPVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_vsetfield; - tif->tif_vsetfield = ZIPVSetField; /* hook for codec tags */ - - /* Default values for codec-specific fields */ - sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */ - sp->state = 0; - - /* - * Install codec methods. - */ - tif->tif_setupdecode = ZIPSetupDecode; - tif->tif_predecode = ZIPPreDecode; - tif->tif_decoderow = ZIPDecode; - tif->tif_decodestrip = ZIPDecode; - tif->tif_decodetile = ZIPDecode; - tif->tif_setupencode = ZIPSetupEncode; - tif->tif_preencode = ZIPPreEncode; - tif->tif_postencode = ZIPPostEncode; - tif->tif_encoderow = ZIPEncode; - tif->tif_encodestrip = ZIPEncode; - tif->tif_encodetile = ZIPEncode; - tif->tif_cleanup = ZIPCleanup; - /* - * Setup predictor setup. - */ - (void) TIFFPredictorInit(tif); - return (1); -bad: - TIFFError("TIFFInitZIP", "No space for ZIP state block"); - return (0); -} -#endif /* ZIP_SUPORT */ diff --git a/freeimage241/Source/LibTIFF/tiff.h b/freeimage241/Source/LibTIFF/tiff.h deleted file mode 100644 index b822347..0000000 --- a/freeimage241/Source/LibTIFF/tiff.h +++ /dev/null @@ -1,441 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tiff.h,v 1.0 2001-04-13 00:42:26+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFF_ -#define _TIFF_ -/* - * Tag Image File Format (TIFF) - * - * Based on Rev 6.0 from: - * Developer's Desk - * Aldus Corporation - * 411 First Ave. South - * Suite 200 - * Seattle, WA 98104 - * 206-622-5500 - */ -#define TIFF_VERSION 42 - -#define TIFF_BIGENDIAN 0x4d4d -#define TIFF_LITTLEENDIAN 0x4949 - -#ifndef _TIFF_DATA_TYPEDEFS_ -#define _TIFF_DATA_TYPEDEFS_ -/* - * Intrinsic data types required by the file format: - * - * 8-bit quantities int8/uint8 - * 16-bit quantities int16/uint16 - * 32-bit quantities int32/uint32 - * strings unsigned char* - */ -#ifdef __STDC__ -typedef signed char int8; /* NB: non-ANSI compilers may not grok */ -#else -typedef char int8; -#endif -typedef unsigned char uint8; -typedef short int16; -typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ -#if defined(__alpha) || (defined(_MIPS_SZLONG) && _MIPS_SZLONG == 64) -typedef int int32; -typedef unsigned int uint32; /* sizeof (uint32) must == 4 */ -#else -typedef long int32; -typedef unsigned long uint32; /* sizeof (uint32) must == 4 */ -#endif -#endif /* _TIFF_DATA_TYPEDEFS_ */ - -/* For TIFFReassignTagToIgnore */ -enum TIFFIgnoreSense /* IGNORE tag table */ -{ - TIS_STORE, - TIS_EXTRACT, - TIS_EMPTY -}; - -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint32 tiff_diroff; /* byte offset to first directory */ -} TIFFHeader; - -/* - * TIFF Image File Directories are comprised of - * a table of field descriptors of the form shown - * below. The table is sorted in ascending order - * by tag. The values associated with each entry - * are disjoint and may appear anywhere in the file - * (so long as they are placed on a word boundary). - * - * If the value is 4 bytes or less, then it is placed - * in the offset field to save space. If the value - * is less than 4 bytes, it is left-justified in the - * offset field. - */ -typedef struct { - uint16 tdir_tag; /* see below */ - uint16 tdir_type; /* data type; see below */ - uint32 tdir_count; /* number of items; length in spec */ - uint32 tdir_offset; /* byte offset to field data */ -} TIFFDirEntry; - -/* - * NB: In the comments below, - * - items marked with a + are obsoleted by revision 5.0, - * - items marked with a ! are introduced in revision 6.0. - * - items marked with a % are introduced post revision 6.0. - * - items marked with a $ are obsoleted by revision 6.0. - */ - -/* - * Tag data type information. - * - * Note: RATIONALs are the ratio of two 32-bit integer values. - */ -typedef enum { - TIFF_NOTYPE = 0, /* placeholder */ - TIFF_BYTE = 1, /* 8-bit unsigned integer */ - TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ - TIFF_SHORT = 3, /* 16-bit unsigned integer */ - TIFF_LONG = 4, /* 32-bit unsigned integer */ - TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ - TIFF_SBYTE = 6, /* !8-bit signed integer */ - TIFF_UNDEFINED = 7, /* !8-bit untyped data */ - TIFF_SSHORT = 8, /* !16-bit signed integer */ - TIFF_SLONG = 9, /* !32-bit signed integer */ - TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ - TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ - TIFF_DOUBLE = 12 /* !64-bit IEEE floating point */ -} TIFFDataType; - -/* - * TIFF Tag Definitions. - */ -#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ -#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ -#define FILETYPE_PAGE 0x2 /* one page of many */ -#define FILETYPE_MASK 0x4 /* transparency mask */ -#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ -#define OFILETYPE_IMAGE 1 /* full resolution image data */ -#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ -#define OFILETYPE_PAGE 3 /* one page of many */ -#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ -#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ -#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ -#define TIFFTAG_COMPRESSION 259 /* data compression technique */ -#define COMPRESSION_NONE 1 /* dump mode */ -#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ -#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ -#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ -#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ -#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ -#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ -#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ -#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ -#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ -#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ -/* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ -#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ -#define COMPRESSION_JBIG 34661 /* ISO JBIG */ -#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ -#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ -#define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ -#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ -#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ -#define PHOTOMETRIC_RGB 2 /* RGB color model */ -#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ -#define PHOTOMETRIC_MASK 4 /* $holdout mask */ -#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ -#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ -#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ -#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ -#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ -#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ -#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ -#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ -#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ -#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ -#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ -#define TIFFTAG_FILLORDER 266 /* data order within a byte */ -#define FILLORDER_MSB2LSB 1 /* most significant -> least */ -#define FILLORDER_LSB2MSB 2 /* least significant -> most */ -#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ -#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ -#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ -#define TIFFTAG_MODEL 272 /* scanner model name/number */ -#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ -#define TIFFTAG_ORIENTATION 274 /* +image orientation */ -#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ -#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ -#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ -#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ -#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ -#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ -#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ -#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ -#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ -#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ -#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ -#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ -#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ -#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ -#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ -#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ -#define PLANARCONFIG_CONTIG 1 /* single image plane */ -#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ -#define TIFFTAG_PAGENAME 285 /* page name image is from */ -#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ -#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ -#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ -#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ -#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ -#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ -#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ -#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ -#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ -#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ -#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ -#define RESUNIT_NONE 1 /* no meaningful units */ -#define RESUNIT_INCH 2 /* english */ -#define RESUNIT_CENTIMETER 3 /* metric */ -#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ -#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ -#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ -#define TIFFTAG_SOFTWARE 305 /* name & release */ -#define TIFFTAG_DATETIME 306 /* creation date and time */ -#define TIFFTAG_ARTIST 315 /* creator of image */ -#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ -#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ -#define TIFFTAG_WHITEPOINT 318 /* image white point */ -#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ -#define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ -#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ -#define TIFFTAG_TILEWIDTH 322 /* !rows/data tile */ -#define TIFFTAG_TILELENGTH 323 /* !cols/data tile */ -#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ -#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ -#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ -#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ -#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ -#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ -#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ -#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ -#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ -#define TIFFTAG_INKSET 332 /* !inks in separated image */ -#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black */ -#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ -#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ -#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ -#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ -#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ -#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ -#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ -#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ -#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ -#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ -#define SAMPLEFORMAT_INT 2 /* !signed integer data */ -#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ -#define SAMPLEFORMAT_VOID 4 /* !untyped data */ -#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ -#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ -#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ -#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ -#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ -/* - * Tags 512-521 are obsoleted by Technical Note #2 - * which specifies a revised JPEG-in-TIFF scheme. - */ -#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ -#define JPEGPROC_BASELINE 1 /* !baseline sequential */ -#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ -#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ -#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ -#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ -#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ -#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ -#define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ -#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ -#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ -#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ -#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ -#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ -#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ -#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ -#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ -/* tags 32952-32956 are private tags registered to Island Graphics */ -#define TIFFTAG_REFPTS 32953 /* image reference points */ -#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ -#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ -#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ -/* tags 32995-32999 are private tags registered to SGI */ -#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ -#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ -#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ -#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ -/* tags 33300-33309 are private tags registered to Pixar */ -/* - * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH - * are set when an image has been cropped out of a larger image. - * They reflect the size of the original uncropped image. - * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used - * to determine the position of the smaller image in the larger one. - */ -#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ -#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ - /* Tags 33302-33306 are used to identify special image modes and data - * used by Pixar's texture formats. - */ -#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ -#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ -#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ -#define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 -#define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 -/* tag 33405 is a private tag registered to Eastman Kodak */ -#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ -/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ -#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ -/* IPTC TAG from RichTIFF specifications */ -#define TIFFTAG_RICHTIFFIPTC 33723 -/* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ -#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ -/* tag 34929 is a private tag registered to FedEx */ -#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ -/* tag 65535 is an undefined tag used by Eastman Kodak */ -#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ - -/* - * The following are ``pseudo tags'' that can be - * used to control codec-specific functionality. - * These tags are not written to file. Note that - * these values start at 0xffff+1 so that they'll - * never collide with Aldus-assigned tags. - * - * If you want your private pseudo tags ``registered'' - * (i.e. added to this file), send mail to sam@sgi.com - * with the appropriate C definitions to add. - */ -#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ -#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ -#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ -#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ -#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ -#define FAXMODE_WORDALIGN 0x0008 /* word align row */ -#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ -#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ -/* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ -#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ -#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ -#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ -#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ -#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ -#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ -/* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ -#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ -#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ -#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ -#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ -#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ -#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ -#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ -#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ -/* 65550-65556 are allocated to Oceana Matrix */ -#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ -#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ -#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ -#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ -#define DCSIMAGERFILTER_IR 0 /* infrared filter */ -#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ -#define DCSIMAGERFILTER_CFA 2 /* color filter array */ -#define DCSIMAGERFILTER_OTHER 3 /* other filter */ -#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ -#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ -#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ -#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ -#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ -#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ -#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ -#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ -/* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ -#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ -#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ -/* 65559 is allocated to Oceana Matrix */ -#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ -#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ -#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ -#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ -#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ -#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ -#endif /* _TIFF_ */ diff --git a/freeimage241/Source/LibTIFF/tiffcomp.h b/freeimage241/Source/LibTIFF/tiffcomp.h deleted file mode 100644 index 5ad8264..0000000 --- a/freeimage241/Source/LibTIFF/tiffcomp.h +++ /dev/null @@ -1,214 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tiffcomp.h,v 1.0 2001-04-13 00:42:26+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1990-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _COMPAT_ -#define _COMPAT_ -/* - * This file contains a hodgepodge of definitions and - * declarations that are needed to provide compatibility - * between the native system and the base implementation - * that the library assumes. - * - * NB: This file is a mess. - */ - -/* - * Setup basic type definitions and function declaratations. - */ - -/* - * Simplify Acorn RISC OS identifier (to avoid confusion with Acorn RISC iX - * and with defunct Unix Risc OS) - * No need to specify __arm - hey, Acorn might port the OS, no problem here! - */ -#ifdef __acornriscos -#undef __acornriscos -#endif -#if defined(__acorn) && defined(__riscos) -#define __acornriscos -#endif - -#if defined(__MWERKS__) || defined(THINK_C) -#include -#include -#endif - -#include - -#if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) -#include -#elif !defined(__MWERKS__) && !defined(THINK_C) && !defined(__acornriscos) && !defined(applec) -#include -#endif - -#if defined(VMS) -#include -#include -#elif !defined(__acornriscos) -#include -#endif - -/* - * This maze of checks controls defines or not the - * target system has BSD-style typdedefs declared in - * an include file and/or whether or not to include - * to get the SEEK_* definitions. Some - * additional includes are also done to pull in the - * appropriate definitions we're looking for. - */ -#if defined(__MWERKS__) || defined(THINK_C) || defined(__PPCC__) || defined(__SC__) || defined(__MRC__) -#include -#define BSDTYPES -#define HAVE_UNISTD_H 0 -#elif (defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) || defined(_WIN32)) && !defined(unix) -#define BSDTYPES -#elif defined(OS2_16) || defined(OS2_32) -#define BSDTYPES -#elif defined(__acornriscos) -#include -#define BSDTYPES -#define HAVE_UNISTD_H 0 -#elif defined(VMS) -#define HAVE_UNISTD_H 0 -#else -#define HAVE_UNISTD_H 1 -#endif - -/* - * The library uses the ANSI C/POSIX SEEK_* - * definitions that should be defined in unistd.h - * (except on system where they are in stdio.h and - * there is no unistd.h). - */ -#if !defined(SEEK_SET) && HAVE_UNISTD_H -#include -#endif - -/* - * The library uses memset, memcpy, and memcmp. - * ANSI C and System V define these in string.h. - */ -#include - -/* - * The BSD typedefs are used throughout the library. - * If your system doesn't have them in , - * then define BSDTYPES in your Makefile. - */ -#if defined(BSDTYPES) -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; -#endif - -/* - * dblparam_t is the type that a double precision - * floating point value will have on the parameter - * stack (when coerced by the compiler). - */ -/* Note: on MacPowerPC "extended" is undefined. So only use it for 68K-Macs */ -#if defined(__SC__) || defined(THINK_C) -typedef extended dblparam_t; -#else -typedef double dblparam_t; -#endif - -/* - * If your compiler supports inline functions, then - * set INLINE appropriately to get the known hotspots - * in the library expanded inline. - */ -#if defined(__GNUC__) -#if defined(__STRICT_ANSI__) -#define INLINE __inline__ -#else -#define INLINE inline -#endif -#else /* !__GNUC__ */ -#define INLINE -#endif - -/* - * GLOBALDATA is a macro that is used to define global variables - * private to the library. We use this indirection to hide - * brain-damage in VAXC (and GCC) under VAX/VMS. In these - * environments the macro places the variable in a non-shareable - * program section, which ought to be done by default (sigh!) - * - * Apparently DEC are aware of the problem as this behaviour is the - * default under VMS on AXP. - * - * The GNU C variant is untested. - */ -#if defined(VAX) && defined(VMS) -#if defined(VAXC) -#define GLOBALDATA(TYPE,NAME) extern noshare TYPE NAME -#endif -#if defined(__GNUC__) -#define GLOBALDATA(TYPE,NAME) extern TYPE NAME \ - asm("_$$PsectAttributes_NOSHR$$" #NAME) -#endif -#else /* !VAX/VMS */ -#define GLOBALDATA(TYPE,NAME) extern TYPE NAME -#endif - -#if defined(__acornriscos) -/* - * osfcn.h is part of C++Lib on Acorn C/C++, and as such can't be used - * on C alone. For that reason, the relevant functions are - * implemented in tif_acorn.c, and the elements from the header - * file are included here. - */ -#if defined(__cplusplus) -#include -#else -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#define O_APPEND 8 -#define O_CREAT 0x200 -#define O_TRUNC 0x400 -typedef long off_t; -extern int open(const char *name, int flags, int mode); -extern int close(int fd); -extern int write(int fd, const char *buf, int nbytes); -extern int read(int fd, char *buf, int nbytes); -extern off_t lseek(int fd, off_t offset, int whence); -extern int creat(const char *path, int mode); -#endif /* __cplusplus */ -#endif /* __acornriscos */ - -/* Bit and byte order, the default is MSB to LSB */ -#ifdef VMS -#undef HOST_FILLORDER -#undef HOST_BIGENDIAN -#define HOST_FILLORDER FILLORDER_LSB2MSB -#define HOST_BIGENDIAN 0 -#endif - - -#endif /* _COMPAT_ */ diff --git a/freeimage241/Source/LibTIFF/tiffconf.h b/freeimage241/Source/LibTIFF/tiffconf.h deleted file mode 100644 index 65cbbcd..0000000 --- a/freeimage241/Source/LibTIFF/tiffconf.h +++ /dev/null @@ -1,143 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tiffconf.h,v 1.0 2001-04-13 00:42:26+02 floris_van_den_berg Exp floris_van_den_berg $ */ -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFCONF_ -#define _TIFFCONF_ -/* - * Library Configuration Definitions. - * - * This file defines the default configuration for the library. - * If the target system does not have make or a way to specify - * #defines on the command line, this file can be edited to - * configure the library. Otherwise, one can override portability - * and configuration-related definitions from a Makefile or command - * line by defining FEATURE_SUPPORT and COMPRESSION_SUPPORT (see below). - */ - -/* - * General portability-related defines: - * - * HAVE_IEEEFP define as 0 or 1 according to the floating point - * format suported by the machine - * BSDTYPES define this if your system does NOT define the - * usual 4BSD typedefs u_int et. al. - * HAVE_MMAP enable support for memory mapping read-only files; - * this is typically deduced by the configure script - * HOST_FILLORDER native cpu bit order: one of FILLORDER_MSB2LSB - * or FILLODER_LSB2MSB; this is typically set by the - * configure script - * HOST_BIGENDIAN native cpu byte order: 1 if big-endian (Motorola) - * or 0 if little-endian (Intel); this may be used - * in codecs to optimize code - * USE_64BIT_API set to 1 if tif_unix.c should use lseek64(), - * fstat64() and stat64 allowing 2-4GB files. - */ -#ifndef HAVE_IEEEFP -#define HAVE_IEEEFP 1 -#endif -#ifndef HOST_FILLORDER -#define HOST_FILLORDER FILLORDER_MSB2LSB -#endif -#ifndef HOST_BIGENDIAN -#define HOST_BIGENDIAN 1 -#endif - -#ifndef USE_64BIT_API -# define USE_64BIT_API 0 -#endif - -#ifndef FEATURE_SUPPORT -/* - * Feature support definitions: - * - * COLORIMETRY_SUPPORT enable support for 6.0 colorimetry tags - * YCBCR_SUPPORT enable support for 6.0 YCbCr tags - * CMYK_SUPPORT enable support for 6.0 CMYK tags - * ICC_SUPPORT enable support for ICC profile tag - * PHOTOSHOP_SUPPORT enable support for PHOTOSHOP resource tag - * IPTC_SUPPORT enable support for RichTIFF IPTC tag - */ -#define COLORIMETRY_SUPPORT -#define YCBCR_SUPPORT -#define CMYK_SUPPORT -#define ICC_SUPPORT -#define PHOTOSHOP_SUPPORT -#define IPTC_SUPPORT -#endif /* FEATURE_SUPPORT */ - -#ifndef COMPRESSION_SUPPORT -/* - * Compression support defines: - * - * CCITT_SUPPORT enable support for CCITT Group 3 & 4 algorithms - * PACKBITS_SUPPORT enable support for Macintosh PackBits algorithm - * LZW_SUPPORT enable support for LZW algorithm - * THUNDER_SUPPORT enable support for ThunderScan 4-bit RLE algorithm - * NEXT_SUPPORT enable support for NeXT 2-bit RLE algorithm - * OJPEG_SUPPORT enable support for 6.0-style JPEG DCT algorithms - * (no builtin support, only a codec hook) - * JPEG_SUPPORT enable support for post-6.0-style JPEG DCT algorithms - * (requires freely available IJG software, see tif_jpeg.c) - * ZIP_SUPPORT enable support for Deflate algorithm - * (requires freely available zlib software, see tif_zip.c) - * PIXARLOG_SUPPORT enable support for Pixar log-format algorithm - * LOGLUV_SUPPORT enable support for LogLuv high dynamic range encoding - */ -#define CCITT_SUPPORT -#define PACKBITS_SUPPORT -#define LZW_SUPPORT -#define THUNDER_SUPPORT -#define NEXT_SUPPORT -#define LOGLUV_SUPPORT -#endif /* COMPRESSION_SUPPORT */ - -/* - * If JPEG compression is enabled then we must also include - * support for the colorimetry and YCbCr-related tags. - */ -#ifdef JPEG_SUPPORT -#ifndef YCBCR_SUPPORT -#define YCBCR_SUPPORT -#endif -#ifndef COLORIMETRY_SUPPORT -#define COLORIMETRY_SUPPORT -#endif -#endif /* JPEG_SUPPORT */ - -/* - * ``Orthogonal Features'' - * - * STRIPCHOP_DEFAULT default handling of strip chopping support (whether - * or not to convert single-strip uncompressed images - * to mutiple strips of ~8Kb--to reduce memory use) - * SUBIFD_SUPPORT enable support for SubIFD tag (thumbnails and such) - */ -#ifndef STRIPCHOP_DEFAULT -#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* default is to enable */ -#endif -#ifndef SUBIFD_SUPPORT -#define SUBIFD_SUPPORT 1 /* enable SubIFD tag (330) support */ -#endif -#endif /* _TIFFCONF_ */ diff --git a/freeimage241/Source/LibTIFF/tiffio.h b/freeimage241/Source/LibTIFF/tiffio.h deleted file mode 100644 index c4de583..0000000 --- a/freeimage241/Source/LibTIFF/tiffio.h +++ /dev/null @@ -1,334 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tiffio.h,v 1.0 2001-04-13 00:42:27+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIO_ -#define _TIFFIO_ - -/* - * TIFF I/O Library Definitions. - */ -#include "tiff.h" -//#include "tiffvers.h" - -/* - * TIFF is defined as an incomplete type to hide the - * library's internal data structures from clients. - */ -typedef struct tiff TIFF; - -/* - * The following typedefs define the intrinsic size of - * data types used in the *exported* interfaces. These - * definitions depend on the proper definition of types - * in tiff.h. Note also that the varargs interface used - * to pass tag types and values uses the types defined in - * tiff.h directly. - * - * NB: ttag_t is unsigned int and not unsigned short because - * ANSI C requires that the type before the ellipsis be a - * promoted type (i.e. one of int, unsigned int, pointer, - * or double) and because we defined pseudo-tags that are - * outside the range of legal Aldus-assigned tags. - * NB: tsize_t is int32 and not uint32 because some functions - * return -1. - * NB: toff_t is not off_t for many reasons; TIFFs max out at - * 32-bit file offsets being the most important, and to ensure - * that it is unsigned, rather than signed. - */ -typedef uint32 ttag_t; /* directory tag */ -typedef uint16 tdir_t; /* directory index */ -typedef uint16 tsample_t; /* sample number */ -typedef uint32 tstrip_t; /* strip number */ -typedef uint32 ttile_t; /* tile number */ -typedef int32 tsize_t; /* i/o size in bytes */ -typedef void* tdata_t; /* image data ref */ -typedef uint32 toff_t; /* file offset */ - -#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) -#define __WIN32__ -#endif - -/* - * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c - * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). - * - * By default tif_win32.c is assumed on windows if not using the cygwin - * environment. - */ - -#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) -# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILIO) -# define USE_WIN32_FILEIO -# endif -#endif - -#if defined(USE_WIN32_FILEIO) -#include -#ifdef __WIN32__ -DECLARE_HANDLE(thandle_t); /* Win32 file handle */ -#else -typedef HFILE thandle_t; /* client data handle */ -#endif -#else -typedef void* thandle_t; /* client data handle */ -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* - * Flags to pass to TIFFPrintDirectory to control - * printing of data structures that are potentially - * very large. Bit-or these flags to enable printing - * multiple items. - */ -#define TIFFPRINT_NONE 0x0 /* no extra info */ -#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ -#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ -#define TIFFPRINT_COLORMAP 0x4 /* colormap */ -#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ -#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ -#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ - -/* - * RGBA-style image support. - */ -typedef unsigned char TIFFRGBValue; /* 8-bit samples */ -typedef struct _TIFFRGBAImage TIFFRGBAImage; -/* - * The image reading and conversion routines invoke - * ``put routines'' to copy/image/whatever tiles of - * raw image data. A default set of routines are - * provided to convert/copy raw image data to 8-bit - * packed ABGR format rasters. Applications can supply - * alternate routines that unpack the data into a - * different format or, for example, unpack the data - * and draw the unpacked raster on the display. - */ -typedef void (*tileContigRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*); -typedef void (*tileSeparateRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*, unsigned char*, unsigned char*, unsigned char*); -/* - * RGBA-reader state. - */ -typedef struct { /* YCbCr->RGB support */ - TIFFRGBValue* clamptab; /* range clamping table */ - int* Cr_r_tab; - int* Cb_b_tab; - int32* Cr_g_tab; - int32* Cb_g_tab; - float coeffs[3]; /* cached for repeated use */ -} TIFFYCbCrToRGB; - -struct _TIFFRGBAImage { - TIFF* tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - uint32 width; /* image width */ - uint32 height; /* image height */ - uint16 bitspersample; /* image bits/sample */ - uint16 samplesperpixel; /* image samples/pixel */ - uint16 orientation; /* image orientation */ - uint16 photometric; /* image photometric interp */ - uint16* redcmap; /* colormap pallete */ - uint16* greencmap; - uint16* bluecmap; - /* get image data routine */ - int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); - union { - void (*any)(TIFFRGBAImage*); - tileContigRoutine contig; - tileSeparateRoutine separate; - } put; /* put decoded strip/tile */ - TIFFRGBValue* Map; /* sample mapping array */ - uint32** BWmap; /* black&white map */ - uint32** PALmap; /* palette image map */ - TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ - - int row_offset; - int col_offset; -}; - -/* - * Macros for extracting components from the - * packed ABGR form returned by TIFFReadRGBAImage. - */ -#define TIFFGetR(abgr) ((abgr) & 0xff) -#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) -#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) -#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) - -/* - * A CODEC is a software package that implements decoding, - * encoding, or decoding+encoding of a compression algorithm. - * The library provides a collection of builtin codecs. - * More codecs may be registered through calls to the library - * and/or the builtin implementations may be overridden. - */ -typedef int (*TIFFInitMethod)(TIFF*, int); -typedef struct { - char* name; - uint16 scheme; - TIFFInitMethod init; -} TIFFCodec; - -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif -typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); -typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t); -typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); -typedef int (*TIFFCloseProc)(thandle_t); -typedef toff_t (*TIFFSizeProc)(thandle_t); -typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*); -typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t); -typedef void (*TIFFExtendProc)(TIFF*); - -extern const char* TIFFGetVersion(void); - -extern const TIFFCodec* TIFFFindCODEC(uint16); -extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); -extern void TIFFUnRegisterCODEC(TIFFCodec*); - -extern tdata_t _TIFFmalloc(tsize_t); -extern tdata_t _TIFFrealloc(tdata_t, tsize_t); -extern void _TIFFmemset(tdata_t, int, tsize_t); -extern void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t); -extern int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t); -extern void _TIFFfree(tdata_t); - -extern void TIFFClose(TIFF*); -extern int TIFFFlush(TIFF*); -extern int TIFFFlushData(TIFF*); -extern int TIFFGetField(TIFF*, ttag_t, ...); -extern int TIFFVGetField(TIFF*, ttag_t, va_list); -extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...); -extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list); -extern int TIFFReadDirectory(TIFF*); -extern tsize_t TIFFScanlineSize(TIFF*); -extern tsize_t TIFFRasterScanlineSize(TIFF*); -extern tsize_t TIFFStripSize(TIFF*); -extern tsize_t TIFFVStripSize(TIFF*, uint32); -extern tsize_t TIFFTileRowSize(TIFF*); -extern tsize_t TIFFTileSize(TIFF*); -extern tsize_t TIFFVTileSize(TIFF*, uint32); -extern uint32 TIFFDefaultStripSize(TIFF*, uint32); -extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); -extern int TIFFFileno(TIFF*); -extern int TIFFGetMode(TIFF*); -extern int TIFFIsTiled(TIFF*); -extern int TIFFIsByteSwapped(TIFF*); -extern int TIFFIsUpSampled(TIFF*); -extern int TIFFIsMSB2LSB(TIFF*); -extern uint32 TIFFCurrentRow(TIFF*); -extern tdir_t TIFFCurrentDirectory(TIFF*); -extern tdir_t TIFFNumberOfDirectories(TIFF*); -extern uint32 TIFFCurrentDirOffset(TIFF*); -extern tstrip_t TIFFCurrentStrip(TIFF*); -extern ttile_t TIFFCurrentTile(TIFF*); -extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t); -extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t); -extern int TIFFWriteCheck(TIFF*, int, const char *); -extern int TIFFCreateDirectory(TIFF*); -extern int TIFFLastDirectory(TIFF*); -extern int TIFFSetDirectory(TIFF*, tdir_t); -extern int TIFFSetSubDirectory(TIFF*, uint32); -extern int TIFFUnlinkDirectory(TIFF*, tdir_t); -extern int TIFFSetField(TIFF*, ttag_t, ...); -extern int TIFFVSetField(TIFF*, ttag_t, va_list); -extern int TIFFWriteDirectory(TIFF *); -extern int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int); - -#if defined(c_plusplus) || defined(__cplusplus) -extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0); -extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); -#else -extern void TIFFPrintDirectory(TIFF*, FILE*, long); -extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t); -extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); -#endif - -extern int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * ); -extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); -extern int TIFFRGBAImageOK(TIFF*, char [1024]); -extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); -extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); -extern void TIFFRGBAImageEnd(TIFFRGBAImage*); -extern TIFF* TIFFOpen(const char*, const char*); -extern TIFF* TIFFFdOpen(int, const char*, const char*); -extern TIFF* TIFFClientOpen(const char*, const char*, - thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, - TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc); -extern const char* TIFFFileName(TIFF*); -extern void TIFFError(const char*, const char*, ...); -extern void TIFFWarning(const char*, const char*, ...); -extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); -extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); -extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t); -extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t); -extern ttile_t TIFFNumberOfTiles(TIFF*); -extern tsize_t TIFFReadTile(TIFF*, - tdata_t, uint32, uint32, uint32, tsample_t); -extern tsize_t TIFFWriteTile(TIFF*, - tdata_t, uint32, uint32, uint32, tsample_t); -extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t); -extern tstrip_t TIFFNumberOfStrips(TIFF*); -extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern void TIFFSetWriteOffset(TIFF*, toff_t); -extern void TIFFSwabShort(uint16*); -extern void TIFFSwabLong(uint32*); -extern void TIFFSwabDouble(double*); -extern void TIFFSwabArrayOfShort(uint16*, unsigned long); -extern void TIFFSwabArrayOfLong(uint32*, unsigned long); -extern void TIFFSwabArrayOfDouble(double*, unsigned long); -extern void TIFFReverseBits(unsigned char *, unsigned long); -extern const unsigned char* TIFFGetBitRevTable(int); -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFIO_ */ diff --git a/freeimage241/Source/LibTIFF/tiffiop.h b/freeimage241/Source/LibTIFF/tiffiop.h deleted file mode 100644 index 788b853..0000000 --- a/freeimage241/Source/LibTIFF/tiffiop.h +++ /dev/null @@ -1,279 +0,0 @@ -/* $Header: C:\\RCS\\D\\FreeImage\\Source\\LibTIFF\\tiffiop.h,v 1.0 2001-04-13 00:42:27+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIOP_ -#define _TIFFIOP_ -/* - * ``Library-private'' definitions. - */ -/* - * UNIX systems should run the configure script to generate - * a port.h file that reflects the system capabilities. - * Doing this obviates all the dreck done in tiffcomp.h. - */ -#if defined(unix) || defined(__unix) -#include "port.h" -#include "tiffconf.h" -#else -#include "tiffconf.h" -#include "tiffcomp.h" -#endif -#include "tiffio.h" -#include "tif_dir.h" - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -/* - * Typedefs for ``method pointers'' used internally. - */ -typedef unsigned char tidataval_t; /* internal image data value type */ -typedef tidataval_t* tidata_t; /* reference to internal image data */ - -typedef void (*TIFFVoidMethod)(TIFF*); -typedef int (*TIFFBoolMethod)(TIFF*); -typedef int (*TIFFPreMethod)(TIFF*, tsample_t); -typedef int (*TIFFCodeMethod)(TIFF*, tidata_t, tsize_t, tsample_t); -typedef int (*TIFFSeekMethod)(TIFF*, uint32); -typedef void (*TIFFPostMethod)(TIFF*, tidata_t, tsize_t); -typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list); -typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list); -typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); -typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); -typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); - -struct tiff { - char* tif_name; /* name of open file */ - int tif_fd; /* open file descriptor */ - int tif_mode; /* open mode (O_*) */ - uint32 tif_flags; -#define TIFF_FILLORDER 0x0003 /* natural bit fill order for machine */ -#define TIFF_DIRTYHEADER 0x0004 /* header must be written on close */ -#define TIFF_DIRTYDIRECT 0x0008 /* current directory must be written */ -#define TIFF_BUFFERSETUP 0x0010 /* data buffers setup */ -#define TIFF_CODERSETUP 0x0020 /* encoder/decoder setup done */ -#define TIFF_BEENWRITING 0x0040 /* written 1+ scanlines to file */ -#define TIFF_SWAB 0x0080 /* byte swap file information */ -#define TIFF_NOBITREV 0x0100 /* inhibit bit reversal logic */ -#define TIFF_MYBUFFER 0x0200 /* my raw data buffer; free on close */ -#define TIFF_ISTILED 0x0400 /* file is tile, not strip- based */ -#define TIFF_MAPPED 0x0800 /* file is mapped into memory */ -#define TIFF_POSTENCODE 0x1000 /* need call to postencode routine */ -#define TIFF_INSUBIFD 0x2000 /* currently writing a subifd */ -#define TIFF_UPSAMPLED 0x4000 /* library is doing data up-sampling */ -#define TIFF_STRIPCHOP 0x8000 /* enable strip chopping support */ - toff_t tif_diroff; /* file offset of current directory */ - toff_t tif_nextdiroff; /* file offset of following directory */ - TIFFDirectory tif_dir; /* internal rep of current directory */ - TIFFHeader tif_header; /* file's header block */ - tidata_t tif_clientdir; /* client TIFF directory */ - const int* tif_typeshift; /* data type shift counts */ - const long* tif_typemask; /* data type masks */ - uint32 tif_row; /* current scanline */ - tdir_t tif_curdir; /* current directory (index) */ - tstrip_t tif_curstrip; /* current strip for read/write */ - toff_t tif_curoff; /* current offset for read/write */ - toff_t tif_dataoff; /* current offset for writing dir */ -#if SUBIFD_SUPPORT - uint16 tif_nsubifd; /* remaining subifds to write */ - toff_t tif_subifdoff; /* offset for patching SubIFD link */ -#endif -/* tiling support */ - uint32 tif_col; /* current column (offset by row too) */ - ttile_t tif_curtile; /* current tile for read/write */ - tsize_t tif_tilesize; /* # of bytes in a tile */ -/* compression scheme hooks */ - TIFFBoolMethod tif_setupdecode;/* called once before predecode */ - TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */ - TIFFBoolMethod tif_setupencode;/* called once before preencode */ - TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ - TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ - TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ - TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ - TIFFCodeMethod tif_decodestrip;/* strip decoding routine */ - TIFFCodeMethod tif_encodestrip;/* strip encoding routine */ - TIFFCodeMethod tif_decodetile; /* tile decoding routine */ - TIFFCodeMethod tif_encodetile; /* tile encoding routine */ - TIFFVoidMethod tif_close; /* cleanup-on-close routine */ - TIFFSeekMethod tif_seek; /* position within a strip routine */ - TIFFVoidMethod tif_cleanup; /* cleanup state routine */ - TIFFStripMethod tif_defstripsize;/* calculate/constrain strip size */ - TIFFTileMethod tif_deftilesize;/* calculate/constrain tile size */ - tidata_t tif_data; /* compression scheme private data */ -/* input/output buffering */ - tsize_t tif_scanlinesize;/* # of bytes in a scanline */ - tsize_t tif_scanlineskew;/* scanline skew for reading strips */ - tidata_t tif_rawdata; /* raw data buffer */ - tsize_t tif_rawdatasize;/* # of bytes in raw data buffer */ - tidata_t tif_rawcp; /* current spot in raw buffer */ - tsize_t tif_rawcc; /* bytes unread from raw buffer */ -/* memory-mapped file support */ - tidata_t tif_base; /* base of mapped file */ - toff_t tif_size; /* size of mapped file region (bytes) */ - TIFFMapFileProc tif_mapproc; /* map file method */ - TIFFUnmapFileProc tif_unmapproc;/* unmap file method */ -/* input/output callback methods */ - thandle_t tif_clientdata; /* callback parameter */ - TIFFReadWriteProc tif_readproc; /* read method */ - TIFFReadWriteProc tif_writeproc;/* write method */ - TIFFSeekProc tif_seekproc; /* lseek method */ - TIFFCloseProc tif_closeproc; /* close method */ - TIFFSizeProc tif_sizeproc; /* filesize method */ -/* post-decoding support */ - TIFFPostMethod tif_postdecode; /* post decoding routine */ -/* tag support */ - TIFFFieldInfo** tif_fieldinfo; /* sorted table of registered tags */ - int tif_nfields; /* # entries in registered tag table */ - TIFFVSetMethod tif_vsetfield; /* tag set routine */ - TIFFVGetMethod tif_vgetfield; /* tag get routine */ - TIFFPrintMethod tif_printdir; /* directory print routine */ -}; - -#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */ - -#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0) -#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0) -#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0) -#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0) -#define TIFFReadFile(tif, buf, size) \ - ((*(tif)->tif_readproc)((tif)->tif_clientdata,buf,size)) -#define TIFFWriteFile(tif, buf, size) \ - ((*(tif)->tif_writeproc)((tif)->tif_clientdata,buf,size)) -#define TIFFSeekFile(tif, off, whence) \ - ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(toff_t)(off),whence)) -#define TIFFCloseFile(tif) \ - ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) -#define TIFFGetFileSize(tif) \ - ((*(tif)->tif_sizeproc)((tif)->tif_clientdata)) -#define TIFFMapFileContents(tif, paddr, psize) \ - ((*(tif)->tif_mapproc)((tif)->tif_clientdata,paddr,psize)) -#define TIFFUnmapFileContents(tif, addr, size) \ - ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,size)) - -/* - * Default Read/Seek/Write definitions. - */ -#ifndef ReadOK -#define ReadOK(tif, buf, size) \ - (TIFFReadFile(tif, (tdata_t) buf, (tsize_t)(size)) == (tsize_t)(size)) -#endif -#ifndef SeekOK -#define SeekOK(tif, off) \ - (TIFFSeekFile(tif, (toff_t) off, SEEK_SET) == (toff_t) off) -#endif -#ifndef WriteOK -#define WriteOK(tif, buf, size) \ - (TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) -#endif - -/* NB: the uint32 casts are to silence certain ANSI-C compilers */ -#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) -#define TIFFroundup(x, y) (TIFFhowmany(x,y)*((uint32)(y))) - -#if defined(__cplusplus) -extern "C" { -#endif -extern int _TIFFgetMode(const char*, const char*); -extern int _TIFFNoRowEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoStripEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoTileEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoRowDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoStripDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoTileDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern void _TIFFNoPostDecode(TIFF*, tidata_t, tsize_t); -extern int _TIFFNoPreCode (TIFF*, tsample_t); -extern int _TIFFNoSeek(TIFF*, uint32); -extern void _TIFFSwab16BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab32BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab64BitData(TIFF*, tidata_t, tsize_t); -extern int TIFFFlushData1(TIFF*); -extern void TIFFFreeDirectory(TIFF*); -extern int TIFFDefaultDirectory(TIFF*); -extern int TIFFSetCompressionScheme(TIFF*, int); -extern int TIFFSetDefaultCompressionState(TIFF*); -extern uint32 _TIFFDefaultStripSize(TIFF*, uint32); -extern void _TIFFDefaultTileSize(TIFF*, uint32*, uint32*); - -extern void _TIFFsetByteArray(void**, void*, long); -extern void _TIFFsetString(char**, char*); -extern void _TIFFsetShortArray(uint16**, uint16*, long); -extern void _TIFFsetLongArray(uint32**, uint32*, long); -extern void _TIFFsetFloatArray(float**, float*, long); -extern void _TIFFsetDoubleArray(double**, double*, long); - -extern void _TIFFprintAscii(FILE*, const char*); -extern void _TIFFprintAsciiTag(FILE*, const char*, const char*); - -GLOBALDATA(TIFFErrorHandler,_TIFFwarningHandler); -GLOBALDATA(TIFFErrorHandler,_TIFFerrorHandler); - -extern int TIFFInitDumpMode(TIFF*, int); -#ifdef PACKBITS_SUPPORT -extern int TIFFInitPackBits(TIFF*, int); -#endif -#ifdef CCITT_SUPPORT -extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int); -extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int); -#endif -#ifdef THUNDER_SUPPORT -extern int TIFFInitThunderScan(TIFF*, int); -#endif -#ifdef NEXT_SUPPORT -extern int TIFFInitNeXT(TIFF*, int); -#endif -#ifdef LZW_SUPPORT -extern int TIFFInitLZW(TIFF*, int); -#endif -#ifdef OJPEG_SUPPORT -extern int TIFFInitOJPEG(TIFF*, int); -#endif -#ifdef JPEG_SUPPORT -extern int TIFFInitJPEG(TIFF*, int); -#endif -#ifdef JBIG_SUPPORT -extern int TIFFInitJBIG(TIFF*, int); -#endif -#ifdef ZIP_SUPPORT -extern int TIFFInitZIP(TIFF*, int); -#endif -#ifdef PIXARLOG_SUPPORT -extern int TIFFInitPixarLog(TIFF*, int); -#endif -#ifdef LOGLUV_SUPPORT -extern int TIFFInitSGILog(TIFF*, int); -#endif -#ifdef VMS -extern const TIFFCodec _TIFFBuiltinCODECS[]; -#else -extern TIFFCodec _TIFFBuiltinCODECS[]; -#endif - -#if defined(__cplusplus) -} -#endif -#endif /* _TIFFIOP_ */ diff --git a/freeimage241/Source/LibTIFF/uvcode.h b/freeimage241/Source/LibTIFF/uvcode.h deleted file mode 100644 index 8d96e44..0000000 --- a/freeimage241/Source/LibTIFF/uvcode.h +++ /dev/null @@ -1,173 +0,0 @@ -/* Version 1.0 generated April 7, 1997 by Greg Ward Larson, SGI */ -#define UV_SQSIZ (float)0.003500 -#define UV_NDIVS 16289 -#define UV_VSTART (float)0.016940 -#define UV_NVS 163 -static struct { - float ustart; - short nus, ncum; -} uv_row[UV_NVS] = { - (float)0.247663, 4, 0, - (float)0.243779, 6, 4, - (float)0.241684, 7, 10, - (float)0.237874, 9, 17, - (float)0.235906, 10, 26, - (float)0.232153, 12, 36, - (float)0.228352, 14, 48, - (float)0.226259, 15, 62, - (float)0.222371, 17, 77, - (float)0.220410, 18, 94, - (float)0.214710, 21, 112, - (float)0.212714, 22, 133, - (float)0.210721, 23, 155, - (float)0.204976, 26, 178, - (float)0.202986, 27, 204, - (float)0.199245, 29, 231, - (float)0.195525, 31, 260, - (float)0.193560, 32, 291, - (float)0.189878, 34, 323, - (float)0.186216, 36, 357, - (float)0.186216, 36, 393, - (float)0.182592, 38, 429, - (float)0.179003, 40, 467, - (float)0.175466, 42, 507, - (float)0.172001, 44, 549, - (float)0.172001, 44, 593, - (float)0.168612, 46, 637, - (float)0.168612, 46, 683, - (float)0.163575, 49, 729, - (float)0.158642, 52, 778, - (float)0.158642, 52, 830, - (float)0.158642, 52, 882, - (float)0.153815, 55, 934, - (float)0.153815, 55, 989, - (float)0.149097, 58, 1044, - (float)0.149097, 58, 1102, - (float)0.142746, 62, 1160, - (float)0.142746, 62, 1222, - (float)0.142746, 62, 1284, - (float)0.138270, 65, 1346, - (float)0.138270, 65, 1411, - (float)0.138270, 65, 1476, - (float)0.132166, 69, 1541, - (float)0.132166, 69, 1610, - (float)0.126204, 73, 1679, - (float)0.126204, 73, 1752, - (float)0.126204, 73, 1825, - (float)0.120381, 77, 1898, - (float)0.120381, 77, 1975, - (float)0.120381, 77, 2052, - (float)0.120381, 77, 2129, - (float)0.112962, 82, 2206, - (float)0.112962, 82, 2288, - (float)0.112962, 82, 2370, - (float)0.107450, 86, 2452, - (float)0.107450, 86, 2538, - (float)0.107450, 86, 2624, - (float)0.107450, 86, 2710, - (float)0.100343, 91, 2796, - (float)0.100343, 91, 2887, - (float)0.100343, 91, 2978, - (float)0.095126, 95, 3069, - (float)0.095126, 95, 3164, - (float)0.095126, 95, 3259, - (float)0.095126, 95, 3354, - (float)0.088276, 100, 3449, - (float)0.088276, 100, 3549, - (float)0.088276, 100, 3649, - (float)0.088276, 100, 3749, - (float)0.081523, 105, 3849, - (float)0.081523, 105, 3954, - (float)0.081523, 105, 4059, - (float)0.081523, 105, 4164, - (float)0.074861, 110, 4269, - (float)0.074861, 110, 4379, - (float)0.074861, 110, 4489, - (float)0.074861, 110, 4599, - (float)0.068290, 115, 4709, - (float)0.068290, 115, 4824, - (float)0.068290, 115, 4939, - (float)0.068290, 115, 5054, - (float)0.063573, 119, 5169, - (float)0.063573, 119, 5288, - (float)0.063573, 119, 5407, - (float)0.063573, 119, 5526, - (float)0.057219, 124, 5645, - (float)0.057219, 124, 5769, - (float)0.057219, 124, 5893, - (float)0.057219, 124, 6017, - (float)0.050985, 129, 6141, - (float)0.050985, 129, 6270, - (float)0.050985, 129, 6399, - (float)0.050985, 129, 6528, - (float)0.050985, 129, 6657, - (float)0.044859, 134, 6786, - (float)0.044859, 134, 6920, - (float)0.044859, 134, 7054, - (float)0.044859, 134, 7188, - (float)0.040571, 138, 7322, - (float)0.040571, 138, 7460, - (float)0.040571, 138, 7598, - (float)0.040571, 138, 7736, - (float)0.036339, 142, 7874, - (float)0.036339, 142, 8016, - (float)0.036339, 142, 8158, - (float)0.036339, 142, 8300, - (float)0.032139, 146, 8442, - (float)0.032139, 146, 8588, - (float)0.032139, 146, 8734, - (float)0.032139, 146, 8880, - (float)0.027947, 150, 9026, - (float)0.027947, 150, 9176, - (float)0.027947, 150, 9326, - (float)0.023739, 154, 9476, - (float)0.023739, 154, 9630, - (float)0.023739, 154, 9784, - (float)0.023739, 154, 9938, - (float)0.019504, 158, 10092, - (float)0.019504, 158, 10250, - (float)0.019504, 158, 10408, - (float)0.016976, 161, 10566, - (float)0.016976, 161, 10727, - (float)0.016976, 161, 10888, - (float)0.016976, 161, 11049, - (float)0.012639, 165, 11210, - (float)0.012639, 165, 11375, - (float)0.012639, 165, 11540, - (float)0.009991, 168, 11705, - (float)0.009991, 168, 11873, - (float)0.009991, 168, 12041, - (float)0.009016, 170, 12209, - (float)0.009016, 170, 12379, - (float)0.009016, 170, 12549, - (float)0.006217, 173, 12719, - (float)0.006217, 173, 12892, - (float)0.005097, 175, 13065, - (float)0.005097, 175, 13240, - (float)0.005097, 175, 13415, - (float)0.003909, 177, 13590, - (float)0.003909, 177, 13767, - (float)0.002340, 177, 13944, - (float)0.002389, 170, 14121, - (float)0.001068, 164, 14291, - (float)0.001653, 157, 14455, - (float)0.000717, 150, 14612, - (float)0.001614, 143, 14762, - (float)0.000270, 136, 14905, - (float)0.000484, 129, 15041, - (float)0.001103, 123, 15170, - (float)0.001242, 115, 15293, - (float)0.001188, 109, 15408, - (float)0.001011, 103, 15517, - (float)0.000709, 97, 15620, - (float)0.000301, 89, 15717, - (float)0.002416, 82, 15806, - (float)0.003251, 76, 15888, - (float)0.003246, 69, 15964, - (float)0.004141, 62, 16033, - (float)0.005963, 55, 16095, - (float)0.008839, 47, 16150, - (float)0.010490, 40, 16197, - (float)0.016994, 31, 16237, - (float)0.023659, 21, 16268, -}; diff --git a/freeimage241/Source/Plugin.h b/freeimage241/Source/Plugin.h deleted file mode 100644 index 43e639c..0000000 --- a/freeimage241/Source/Plugin.h +++ /dev/null @@ -1,66 +0,0 @@ -// ========================================================== -// Internal plugins -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifndef PLUGIN_H -#define PLUGIN_H - -#ifndef FREEIMAGE_H -#include "FreeImage.h" -#endif - -// ========================================================== - -struct Plugin; - -// ========================================================== -// Plugin Initialisation Callback -// ========================================================== - -void DLL_CALLCONV FreeImage_OutputMessage(int fif, const char *message); - -// ========================================================== -// Plugin validation -// ========================================================== - -extern "C" { BOOL DLL_CALLCONV FreeImage_Validate(FREE_IMAGE_FORMAT fif, FreeImageIO &io, fi_handle handle); } - -// ========================================================== -// Internal plugins -// ========================================================== - -void DLL_CALLCONV InitBMP(Plugin &plugin, int format_id); -void DLL_CALLCONV InitICO(Plugin &plugin, int format_id); -void DLL_CALLCONV InitIFF(Plugin &plugin, int format_id); -void DLL_CALLCONV InitJPEG(Plugin &plugin, int format_id); -void DLL_CALLCONV InitKOALA(Plugin &plugin, int format_id); -void DLL_CALLCONV InitLBM(Plugin &plugin, int format_id); -void DLL_CALLCONV InitMNG(Plugin &plugin, int format_id); -void DLL_CALLCONV InitPCD(Plugin &plugin, int format_id); -void DLL_CALLCONV InitPCX(Plugin &plugin, int format_id); -void DLL_CALLCONV InitPNG(Plugin &plugin, int format_id); -void DLL_CALLCONV InitPNM(Plugin &plugin, int format_id); -void DLL_CALLCONV InitPSD(Plugin &plugin, int format_id); -void DLL_CALLCONV InitRAS(Plugin &plugin, int format_id); -void DLL_CALLCONV InitTARGA(Plugin &plugin, int format_id); -void DLL_CALLCONV InitTIFF(Plugin &plugin, int format_id); -void DLL_CALLCONV InitWBMP(Plugin &plugin, int format_id); - -#endif //!PLUGIN_H diff --git a/freeimage241/Source/Quantizers.h b/freeimage241/Source/Quantizers.h deleted file mode 100644 index 154f6a2..0000000 --- a/freeimage241/Source/Quantizers.h +++ /dev/null @@ -1,90 +0,0 @@ -// ============================================================= -// Quantizer objects and functions -// -// Design and implementation by: -// - Hervé Drolon -// -// This file is part of FreeImage -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ============================================================= - -// Xiaolin Wu color quantization algorithm -//////////////////////////////////////////////////////////////// - -#include "FreeImage.h" - -//////////////////////////////////////////////////////////////// - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned long uint32; -typedef long int32; - -typedef struct { - int r0; // min value, exclusive - int r1; // max value, inclusive - int g0; - int g1; - int b0; - int b1; - int vol; -} Box; - - -class WuQuantizer -{ - protected: - float *gm2; - int32 *wt, *mr, *mg, *mb; - uint16 *Qadd; - - // DIB data - uint16 width, height; - uint16 pitch; - FIBITMAP *m_dib; - - protected: - void Hist3D(int32 *vwt, int32 *vmr, int32 *vmg, int32 *vmb, float *m2) ; - void M3D(int32 *vwt, int32 *vmr, int32 *vmg, int32 *vmb, float *m2); - int32 Vol(Box *cube, int32 *mmt); - int32 Bottom(Box *cube, uint8 dir, int32 *mmt); - int32 Top(Box *cube, uint8 dir, int pos, int32 *mmt); - float Var(Box *cube); - float Maximize(Box *cube, uint8 dir, int first, int last , int *cut, - int32 whole_r, int32 whole_g, int32 whole_b, int32 whole_w); - bool Cut(Box *set1, Box *set2); - void Mark(Box *cube, int label, uint8 *tag); - - public: - // Constructor - Input parameter: DIB 24-bit to be quantized - WuQuantizer(FIBITMAP *dib); - // Destructor - ~WuQuantizer(); - // Quantizer - Return value: quantized 8-bit (color palette) DIB - FIBITMAP* Quantize(); -}; - -// NEUQUANT Neural-Net quantization algorithm by Anthony Dekker -//////////////////////////////////////////////////////////////// - -// Input parameters: -// - void* dib: DIB 24-bit to be quantized -// - int sampling: a sampling factor in range 1..30 -// 1 => slower, 30 => faster. Default value is 15 -// Return value: -// - NULL if the DIB is not valid or if it's not a 24-bit DIB -// - the quantized 8-bit (color palette) DIB otherwise - -FIBITMAP *NNQuantizer(FIBITMAP *dib, int sampling = 15); - diff --git a/freeimage241/Source/Test/Test.cpp b/freeimage241/Source/Test/Test.cpp deleted file mode 100644 index 99422ad..0000000 --- a/freeimage241/Source/Test/Test.cpp +++ /dev/null @@ -1,293 +0,0 @@ -// ========================================================== -// FreeImage 2 Test Script -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -//#define QT -#define API - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -#ifdef QT -#include -#include -#include -#include -#include -#include "FreeImageQt.h" -#endif - -#ifdef API -#include "FreeImage.h" -#endif - -// ---------------------------------------------------------- - -/* -FIBITMAP * -FreeImage_ExtractTransparency(FIBITMAP *dib) { - if (FreeImage_GetBPP(dib) == 32) { - FIBITMAP *new_dib = FreeImage_Allocate(FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), 8); - - // make a grayscale palette - - RGBQUAD *quad = FreeImage_GetPalette(new_dib); - - for (int i = 0; i < 256; ++i) { - quad[i].rgbRed = - quad[i].rgbGreen = - quad[i].rgbBlue = i; - } - - // copy the alpha channel - - for (unsigned y = 0; y < FreeImage_GetHeight(dib); ++y) { - BYTE *t = FreeImage_GetScanLine(new_dib, y); - RGBQUAD *s = (RGBQUAD *)FreeImage_GetScanLine(dib, y); - - for (unsigned x = 0; x < FreeImage_GetWidth(dib); ++x) { - t[x] = s[x].rgbReserved; - } - } - - return new_dib; - } - - return NULL; -} -*/ - -// ---------------------------------------------------------- - -struct Extensions { - char *ext; - void *function; -}; - -static Extensions s_extensions[] = { - "bmp", FreeImage_SaveBMP, - "jpg", FreeImage_SaveJPEG, - "png", FreeImage_SavePNG, - "pnm", FreeImage_SavePNM, - "tif", FreeImage_SaveTIFF, - "wbmp", FreeImage_SaveWBMP, -}; - -// ---------------------------------------------------------- - -#ifdef API -int __cdecl -TestAPI(int argc, char *argv[]) { - FreeImage_Initialise(); - - FIBITMAP *dib = NULL; - int id = 1; - - printf(FreeImage_GetVersion()); - printf(FreeImage_GetCopyrightMessage()); - - // open the log file - - FILE *log_file = fopen("log_file.txt", "w"); - - // batch convert all supported bitmaps - - _finddata_t finddata; - - long handle; - - if ((handle = _findfirst("c:\\projects\\test images\\*.bmp", &finddata)) != -1) { - do { - dib = NULL; - - // grab the extension - - char ext[4]; - ext[3] = 0; - strncpy(ext, finddata.name + strlen(finddata.name) - 3, 3); - - // make a path to a directory - - char directory[128]; - strcpy(directory, "c:\\projects\\test images\\"); - strcat(directory, finddata.name); - - // open the file - - switch(FreeImage_GetFIFFromFilename(directory)) { - case FIF_BMP : - dib = FreeImage_LoadBMP(directory, BMP_DEFAULT); - break; - - case FIF_ICO : - dib = FreeImage_LoadICO(directory, ICO_DEFAULT); - break; - - case FIF_LBM : - dib = FreeImage_LoadLBM(directory, LBM_DEFAULT); - break; - - case FIF_JPEG : - dib = FreeImage_LoadJPEG(directory, JPEG_DEFAULT); - break; - - case FIF_KOALA : - dib = FreeImage_LoadKOALA(directory, KOALA_DEFAULT); - break; - - case FIF_PCD : - dib = FreeImage_LoadPCD(directory, PCD_DEFAULT); - break; - - case FIF_PCX : - dib = FreeImage_LoadPCX(directory, PCX_DEFAULT); - break; - - case FIF_PNG : - dib = FreeImage_LoadPNG(directory, PNG_DEFAULT); - break; - - case FIF_PBM : - dib = FreeImage_LoadPNM(directory, PNM_DEFAULT); - break; - - case FIF_PGM : - dib = FreeImage_LoadPNM(directory, PNM_DEFAULT); - break; - - case FIF_PPM : - dib = FreeImage_LoadPNM(directory, PNM_DEFAULT); - break; - - case FIF_PSD : - dib = FreeImage_LoadPSD(directory, PSD_DEFAULT); - break; - - case FIF_RAS : - dib = FreeImage_LoadRAS(directory, RAS_DEFAULT); - break; - - case FIF_TARGA : - dib = FreeImage_LoadTARGA(directory, TARGA_DEFAULT); - break; - - case FIF_TIFF : - dib = FreeImage_LoadTIFF(directory, TIFF_DEFAULT); - break; - }; - - if (dib != NULL) { - char unique[128]; - - FreeImage_SetTransparent(dib, FALSE); - - for (int i = 0; i < 1; ++i) { -// for (int i = 0; i < sizeof(s_extensions) / sizeof(s_extensions[0]); ++i) { - itoa(id, unique, 10); - strcat(unique, "."); - strcat(unique, s_extensions[i].ext); - static_cast(s_extensions[i].function)(dib, unique, BMP_DEFAULT); - } - - FreeImage_Free(dib); - - fwrite(unique, strlen(unique), 1, log_file); - fwrite(" >> ", 4, 1, log_file); - fwrite(directory, strlen(directory), 1, log_file); - fwrite("\n", 1, 1, log_file); - - id++; - } - } while (_findnext(handle, &finddata) == 0); - - _findclose(handle); - } - - fclose(log_file); - - FreeImage_DeInitialise(); - - return 0; -} -#endif - -// ---------------------------------------------------------- - -#ifdef QT -int __cdecl -TestQt(int argc, char *argv[]) { - FIQT_Register(false); - - QApplication application(argc, argv); - - QMainWindow window(NULL); - - _finddata_t finddata; - - int count = 0; - - long handle; - - int i = FIQT_GetFIFCount(); - - printf("supported bitmaps: %d\n", i); - - for (int j = 0; j < i; ++j) - printf("bitmap type %d (%s): %s (%s)\n", j, FIQT_GetFormatFromFIF((FREE_IMAGE_FORMAT)j), FIQT_GetFIFDescription((FREE_IMAGE_FORMAT)j), FIQT_GetFIFExtensionList((FREE_IMAGE_FORMAT)j)); - - if ((handle = _findfirst("d:\\test images\\*.jpg", &finddata)) != -1) { - do { - QPixmap pixmap(QObject::tr("d:\\test images\\%1").arg(finddata.name)); - - if (FIQT_FIFSupportsWriting(FIQT_GetFIFFromFormat("PNG"))) - pixmap.save(QObject::tr("%1.png").arg(count++), "PNG"); - } while (_findnext(handle, &finddata) == 0); - - _findclose(handle); - } - - return 0; -} -#endif -// ---------------------------------------------------------- - -int __cdecl -main(int argc, char *argv[]) { -#ifdef API - for (int j = FreeImage_GetFIFCount() - 1; j >= 0; --j) - printf("bitmap type %d (%s): %s (%s)\n", j, FreeImage_GetFormatFromFIF((FREE_IMAGE_FORMAT)j), FreeImage_GetFIFDescription((FREE_IMAGE_FORMAT)j), FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)j)); - - return TestAPI(argc, argv); -#endif -#ifdef QT - return TestQt(argc, argv); -#endif - - return 0; -} diff --git a/freeimage241/Source/Test/Test.dsp b/freeimage241/Source/Test/Test.dsp deleted file mode 100644 index c5b6b29..0000000 --- a/freeimage241/Source/Test/Test.dsp +++ /dev/null @@ -1,105 +0,0 @@ -# Microsoft Developer Studio Project File - Name="Test" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=Test - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "Test.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "Test.mak" CFG="Test - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "Test - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "Test - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "Test - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# 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 /G6 /Gd /MT /W3 /GX /O1 /I "..\\" /I "..\zlib" /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" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# 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 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 winmm.lib Imm32.lib Ws2_32.lib freeimage.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "Test - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# 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 /Gm /GX /ZI /Od /I "..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# 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 /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.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 winmm.lib Imm32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# SUBTRACT LINK32 /pdb:none /nodefaultlib - -!ENDIF - -# Begin Target - -# Name "Test - Win32 Release" -# Name "Test - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\Test.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/freeimage241/Source/Test/Test.dsw b/freeimage241/Source/Test/Test.dsw deleted file mode 100644 index d4e2b94..0000000 --- a/freeimage241/Source/Test/Test.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "Test"=.\Test.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/freeimage241/Source/Utilities.h b/freeimage241/Source/Utilities.h deleted file mode 100644 index 927469d..0000000 --- a/freeimage241/Source/Utilities.h +++ /dev/null @@ -1,98 +0,0 @@ -// ========================================================== -// Utility functions -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifndef UTILITIES_H -#define UTILITIES_H - -#ifndef _INC_MATH -#include -#endif - -#ifndef _INC_STDLIB -#include -#endif - -#ifndef _INC_MEMORY -#include -#endif - -#ifndef _INC_STDIO -#include -#endif - -// ========================================================== -// Utility functions -// ========================================================== - -inline int -round(double x) { - return (int)floor(x + 0.5); -} - -inline unsigned char -HINIBBLE (unsigned char byte) { - return byte & 240; -} - -inline unsigned char -LOWNIBBLE (unsigned char byte) { - return byte & 15; -} - -inline int -CalculateUsedBits(int bits) { - int bit_count = 0; - unsigned bit = 1; - - for (unsigned i = 0; i < 32; i++) { - if ((bits & bit) == bit) { - bit_count++; - } - - bit <<= 1; - } - - return bit_count; -} - -inline int -CalculateLine(int width, int bitdepth) { - return ((width * bitdepth) + 7) / 8; -} - -inline int -CalculatePitch(int line) { - return line + 3 & ~3; -} - -inline int -CalculateUsedColors(int bitcount) { - int c = 1 << bitcount; - - return ((c <= 256) && (c > 1)) ? c : 0; -} - -inline unsigned char * -CalculateScanLine(unsigned char *bits, unsigned pitch, int scanline) { - return (bits + (pitch * scanline)); -} - -#endif diff --git a/freeimage241/Source/ZLib/ZLib.dsp b/freeimage241/Source/ZLib/ZLib.dsp deleted file mode 100644 index f541f8e..0000000 --- a/freeimage241/Source/ZLib/ZLib.dsp +++ /dev/null @@ -1,192 +0,0 @@ -# Microsoft Developer Studio Project File - Name="ZLib" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=ZLib - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "ZLib.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "ZLib.mak" CFG="ZLib - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "ZLib - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "ZLib - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName ""$/FreeImage/ZLib", KNAAAAAA" -# PROP Scc_LocalPath "." -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "ZLib - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G6 /Gd /MT /W3 /GX /O1 /I "..\zlib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "ZLib - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "ZLib - Win32 Release" -# Name "ZLib - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\adler32.c -# End Source File -# Begin Source File - -SOURCE=.\compress.c -# End Source File -# Begin Source File - -SOURCE=.\crc32.c -# End Source File -# Begin Source File - -SOURCE=.\deflate.c -# End Source File -# Begin Source File - -SOURCE=.\gzio.c -# End Source File -# Begin Source File - -SOURCE=.\infblock.c -# End Source File -# Begin Source File - -SOURCE=.\infcodes.c -# End Source File -# Begin Source File - -SOURCE=.\inffast.c -# End Source File -# Begin Source File - -SOURCE=.\inflate.c -# End Source File -# Begin Source File - -SOURCE=.\inftrees.c -# End Source File -# Begin Source File - -SOURCE=.\infutil.c -# End Source File -# Begin Source File - -SOURCE=.\trees.c -# End Source File -# Begin Source File - -SOURCE=.\uncompr.c -# End Source File -# Begin Source File - -SOURCE=.\zutil.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\deflate.h -# End Source File -# Begin Source File - -SOURCE=.\infblock.h -# End Source File -# Begin Source File - -SOURCE=.\infcodes.h -# End Source File -# Begin Source File - -SOURCE=.\inffast.h -# End Source File -# Begin Source File - -SOURCE=.\inffixed.h -# End Source File -# Begin Source File - -SOURCE=.\inftrees.h -# End Source File -# Begin Source File - -SOURCE=.\infutil.h -# End Source File -# Begin Source File - -SOURCE=.\trees.h -# End Source File -# Begin Source File - -SOURCE=.\zconf.h -# End Source File -# Begin Source File - -SOURCE=.\zlib.h -# End Source File -# Begin Source File - -SOURCE=.\zutil.h -# End Source File -# End Group -# End Target -# End Project diff --git a/freeimage241/Source/ZLib/adler32.c b/freeimage241/Source/ZLib/adler32.c deleted file mode 100644 index 4bbea6a..0000000 --- a/freeimage241/Source/ZLib/adler32.c +++ /dev/null @@ -1,48 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: adler32.c,v 1.0 2001-04-13 00:42:43+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -#include "zlib.h" - -#define BASE 65521L /* largest prime smaller than 65536 */ -#define NMAX 5552 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - -#define DO1(buf,i) {s1 += buf[i]; s2 += s1;} -#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); -#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); -#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); -#define DO16(buf) DO8(buf,0); DO8(buf,8); - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - unsigned long s1 = adler & 0xffff; - unsigned long s2 = (adler >> 16) & 0xffff; - int k; - - if (buf == Z_NULL) return 1L; - - while (len > 0) { - k = len < NMAX ? len : NMAX; - len -= k; - while (k >= 16) { - DO16(buf); - buf += 16; - k -= 16; - } - if (k != 0) do { - s1 += *buf++; - s2 += s1; - } while (--k); - s1 %= BASE; - s2 %= BASE; - } - return (s2 << 16) | s1; -} diff --git a/freeimage241/Source/ZLib/compress.c b/freeimage241/Source/ZLib/compress.c deleted file mode 100644 index 774f3a2..0000000 --- a/freeimage241/Source/ZLib/compress.c +++ /dev/null @@ -1,68 +0,0 @@ -/* compress.c -- compress a memory buffer - * Copyright (C) 1995-1998 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: compress.c,v 1.0 2001-04-13 00:42:43+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -#include "zlib.h" - -/* =========================================================================== - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least 0.1% larger than sourceLen plus - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ - z_stream stream; - int err; - - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; -#ifdef MAXSEG_64K - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; -#endif - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - - err = deflateInit(&stream, level); - if (err != Z_OK) return err; - - err = deflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - deflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = deflateEnd(&stream); - return err; -} - -/* =========================================================================== - */ -int ZEXPORT compress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); -} diff --git a/freeimage241/Source/ZLib/crc32.c b/freeimage241/Source/ZLib/crc32.c deleted file mode 100644 index fafce59..0000000 --- a/freeimage241/Source/ZLib/crc32.c +++ /dev/null @@ -1,162 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: crc32.c,v 1.0 2001-04-13 00:42:43+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -#include "zlib.h" - -#define local static - -#ifdef DYNAMIC_CRC_TABLE - -local int crc_table_empty = 1; -local uLongf crc_table[256]; -local void make_crc_table OF((void)); - -/* - Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The table is simply the CRC of all possible eight bit values. This is all - the information needed to generate CRC's on data a byte at a time for all - combinations of CRC register values and incoming bytes. -*/ -local void make_crc_table() -{ - uLong c; - int n, k; - uLong poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* make exclusive-or pattern from polynomial (0xedb88320L) */ - poly = 0L; - for (n = 0; n < sizeof(p)/sizeof(Byte); n++) - poly |= 1L << (31 - p[n]); - - for (n = 0; n < 256; n++) - { - c = (uLong)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[n] = c; - } - crc_table_empty = 0; -} -#else -/* ======================================================================== - * Table of CRC-32's of all single-byte values (made by make_crc_table) - */ -local const uLongf crc_table[256] = { - 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, - 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, - 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, - 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, - 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, - 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, - 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, - 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, - 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, - 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, - 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, - 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, - 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, - 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, - 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, - 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, - 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, - 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, - 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, - 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, - 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, - 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, - 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, - 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, - 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, - 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, - 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, - 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, - 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, - 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, - 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, - 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, - 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, - 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, - 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, - 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, - 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, - 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, - 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, - 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, - 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, - 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, - 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, - 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, - 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, - 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, - 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, - 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, - 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, - 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, - 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, - 0x2d02ef8dL -}; -#endif - -/* ========================================================================= - * This function can be used by asm versions of crc32() - */ -const uLongf * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) make_crc_table(); -#endif - return (const uLongf *)crc_table; -} - -/* ========================================================================= */ -#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); -#define DO2(buf) DO1(buf); DO1(buf); -#define DO4(buf) DO2(buf); DO2(buf); -#define DO8(buf) DO4(buf); DO4(buf); - -/* ========================================================================= */ -uLong ZEXPORT crc32(crc, buf, len) - uLong crc; - const Bytef *buf; - uInt len; -{ - if (buf == Z_NULL) return 0L; -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif - crc = crc ^ 0xffffffffL; - while (len >= 8) - { - DO8(buf); - len -= 8; - } - if (len) do { - DO1(buf); - } while (--len); - return crc ^ 0xffffffffL; -} diff --git a/freeimage241/Source/ZLib/deflate.c b/freeimage241/Source/ZLib/deflate.c deleted file mode 100644 index fef91d9..0000000 --- a/freeimage241/Source/ZLib/deflate.c +++ /dev/null @@ -1,1350 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-1998 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many people for bug reports and testing. - * - * REFERENCES - * - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in ftp://ds.internic.net/rfc/rfc1951.txt - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - */ - -/* @(#) $Id: deflate.c,v 1.0 2001-04-13 00:42:44+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -#include "deflate.h" - -const char deflate_copyright[] = - " deflate 1.1.3 Copyright 1995-1998 Jean-loup Gailly "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* =========================================================================== - * Function prototypes. - */ -typedef enum { - need_more, /* block not completed, need more input or more output */ - block_done, /* block flush performed */ - finish_started, /* finish started, need only more output at next deflate */ - finish_done /* finish done, accept no more input or output */ -} block_state; - -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); -/* Compression function. Returns the block state after the call. */ - -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); -local block_state deflate_slow OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -#ifdef ASMV - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); -#else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); -#endif - -#ifdef DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); -#endif - -/* =========================================================================== - * Local data - */ - -#define NIL 0 -/* Tail of hash chains */ - -#ifndef TOO_FAR -# define TOO_FAR 4096 -#endif -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ -typedef struct config_s { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; - compress_func func; -} config; - -local const config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* maximum speed, no lazy matches */ -/* 2 */ {4, 5, 16, 8, deflate_fast}, -/* 3 */ {4, 6, 32, 32, deflate_fast}, - -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ -/* 5 */ {8, 16, 32, 32, deflate_slow}, -/* 6 */ {8, 16, 128, 128, deflate_slow}, -/* 7 */ {8, 32, 128, 256, deflate_slow}, -/* 8 */ {32, 128, 258, 1024, deflate_slow}, -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* maximum compression */ - -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different - * meaning. - */ - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. - */ -#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) - - -/* =========================================================================== - * Insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - * If this file is compiled with -DFASTEST, the compression level is forced - * to 1, and no hash chains are maintained. - * IN assertion: all calls to to INSERT_STRING are made with consecutive - * input characters and the first MIN_MATCH bytes of str are valid - * (except for the last MIN_MATCH-1 bytes of the input file). - */ -#ifdef FASTEST -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#else -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#endif - -/* =========================================================================== - * Initialize the hash table (avoiding 64K overflow for 16 bit systems). - * prev[] will be initialized on the fly. - */ -#define CLEAR_HASH(s) \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); - -/* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); - /* To do: ignore strm->next_in if we use it as window */ -} - -/* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ - deflate_state *s; - int noheader = 0; - static const char* my_version = ZLIB_VERSION; - - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - - if (version == Z_NULL || version[0] != my_version[0] || - stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; - } - if (strm == Z_NULL) return Z_STREAM_ERROR; - - strm->msg = Z_NULL; - if (strm->zalloc == Z_NULL) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == Z_NULL) strm->zfree = zcfree; - - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#ifdef FASTEST - level = 1; -#endif - - if (windowBits < 0) { /* undocumented feature: suppress zlib header */ - noheader = 1; - windowBits = -windowBits; - } - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_HUFFMAN_ONLY) { - return Z_STREAM_ERROR; - } - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - - s->noheader = noheader; - s->w_bits = windowBits; - s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; - - s->hash_bits = memLevel + 7; - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); - - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); - - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); - - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || - s->pending_buf == Z_NULL) { - strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); - deflateEnd (strm); - return Z_MEM_ERROR; - } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; - - s->level = level; - s->strategy = strategy; - s->method = (Byte)method; - - return deflateReset(strm); -} - -/* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ - deflate_state *s; - uInt length = dictLength; - uInt n; - IPos hash_head = 0; - - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || - strm->state->status != INIT_STATE) return Z_STREAM_ERROR; - - s = strm->state; - strm->adler = adler32(strm->adler, dictionary, dictLength); - - if (length < MIN_MATCH) return Z_OK; - if (length > MAX_DIST(s)) { - length = MAX_DIST(s); -#ifndef USE_DICT_HEAD - dictionary += dictLength - length; /* use the tail of the dictionary */ -#endif - } - zmemcpy(s->window, dictionary, length); - s->strstart = length; - s->block_start = (long)length; - - /* Insert all strings in the hash table (except for the last two bytes). - * s->lookahead stays null, so s->ins_h will be recomputed at the next - * call of fill_window. - */ - s->ins_h = s->window[0]; - UPDATE_HASH(s, s->ins_h, s->window[1]); - for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); - } - if (hash_head) hash_head = 0; /* to make compiler happy */ - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR; - - strm->total_in = strm->total_out = 0; - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ - strm->data_type = Z_UNKNOWN; - - s = (deflate_state *)strm->state; - s->pending = 0; - s->pending_out = s->pending_buf; - - if (s->noheader < 0) { - s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */ - } - s->status = s->noheader ? BUSY_STATE : INIT_STATE; - strm->adler = 1; - s->last_flush = Z_NO_FLUSH; - - _tr_init(s); - lm_init(s); - - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ - deflate_state *s; - compress_func func; - int err = Z_OK; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - - if (level == Z_DEFAULT_COMPRESSION) { - level = 6; - } - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if (func != configuration_table[level].func && strm->total_in != 0) { - /* Flush the last buffer: */ - err = deflate(strm, Z_PARTIAL_FLUSH); - } - if (s->level != level) { - s->level = level; - s->max_lazy_match = configuration_table[level].max_lazy; - s->good_match = configuration_table[level].good_length; - s->nice_match = configuration_table[level].nice_length; - s->max_chain_length = configuration_table[level].max_chain; - } - s->strategy = strategy; - return err; -} - -/* ========================================================================= - * Put a short in the pending buffer. The 16-bit value is put in MSB order. - * IN assertion: the stream state is correct and there is enough room in - * pending_buf. - */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; -{ - put_byte(s, (Byte)(b >> 8)); - put_byte(s, (Byte)(b & 0xff)); -} - -/* ========================================================================= - * Flush as much pending output as possible. All deflate() output goes - * through this function so some applications may wish to modify it - * to avoid allocating a large strm->next_out buffer and copying into it. - * (See also read_buf()). - */ -local void flush_pending(strm) - z_streamp strm; -{ - unsigned len = strm->state->pending; - - if (len > strm->avail_out) len = strm->avail_out; - if (len == 0) return; - - zmemcpy(strm->next_out, strm->state->pending_out, len); - strm->next_out += len; - strm->state->pending_out += len; - strm->total_out += len; - strm->avail_out -= len; - strm->state->pending -= len; - if (strm->state->pending == 0) { - strm->state->pending_out = strm->state->pending_buf; - } -} - -/* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; -{ - int old_flush; /* value of flush param for previous deflate call */ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_FINISH || flush < 0) { - return Z_STREAM_ERROR; - } - s = strm->state; - - if (strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { - ERR_RETURN(strm, Z_STREAM_ERROR); - } - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - - s->strm = strm; /* just in case */ - old_flush = s->last_flush; - s->last_flush = flush; - - /* Write the zlib header */ - if (s->status == INIT_STATE) { - - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags = (s->level-1) >> 1; - - if (level_flags > 3) level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - s->status = BUSY_STATE; - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = 1L; - } - - /* Flush as much pending output as possible */ - if (s->pending != 0) { - flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s->last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUFF_ERROR. - */ - } else if (strm->avail_in == 0 && flush <= old_flush && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* Start a new block or continue the current one. - */ - if (strm->avail_in != 0 || s->lookahead != 0 || - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { - block_state bstate; - - bstate = (*(configuration_table[s->level].func))(s, flush); - - if (bstate == finish_started || bstate == finish_done) { - s->status = FINISH_STATE; - } - if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate == block_done) { - if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); - } else { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush == Z_FULL_FLUSH) { - CLEAR_HASH(s); /* forget history */ - } - } - flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - Assert(strm->avail_out > 0, "bug2"); - - if (flush != Z_FINISH) return Z_OK; - if (s->noheader) return Z_STREAM_END; - - /* Write the zlib trailer (adler32) */ - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - s->noheader = -1; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; -} - -/* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; -{ - int status; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - - status = strm->state->status; - if (status != INIT_STATE && status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, strm->state->pending_buf); - TRY_FREE(strm, strm->state->head); - TRY_FREE(strm, strm->state->prev); - TRY_FREE(strm, strm->state->window); - - ZFREE(strm, strm->state); - strm->state = Z_NULL; - - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; -} - -/* ========================================================================= - * Copy the source state to the destination state. - * To simplify the source, this is not supported for 16-bit MSDOS (which - * doesn't have enough memory anyway to duplicate compression states). - */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; -{ -#ifdef MAXSEG_64K - return Z_STREAM_ERROR; -#else - deflate_state *ds; - deflate_state *ss; - ushf *overlay; - - - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { - return Z_STREAM_ERROR; - } - - ss = source->state; - - *dest = *source; - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - *ds = *ss; - ds->strm = dest; - - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); - ds->pending_buf = (uchf *) overlay; - - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || - ds->pending_buf == Z_NULL) { - deflateEnd (dest); - return Z_MEM_ERROR; - } - /* following zmemcpy do not work for 16-bit MSDOS */ - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); - - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; - - ds->l_desc.dyn_tree = ds->dyn_ltree; - ds->d_desc.dyn_tree = ds->dyn_dtree; - ds->bl_desc.dyn_tree = ds->bl_tree; - - return Z_OK; -#endif -} - -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local int read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - if (!strm->state->noheader) { - strm->adler = adler32(strm->adler, strm->next_in, len); - } - zmemcpy(buf, strm->next_in, len); - strm->next_in += len; - strm->total_in += len; - - return (int)len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init (s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -} - -/* =========================================================================== - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - * OUT assertion: the match length is not greater than s->lookahead. - */ -#ifndef ASMV -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or - * match.S. The code will be functionally equivalent. - */ -#ifndef FASTEST -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - unsigned chain_length = s->max_chain_length;/* max hash chain length */ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - int best_len = s->prev_length; /* best match length so far */ - int nice_match = s->nice_match; /* stop if match long enough */ - IPos limit = s->strstart > (IPos)MAX_DIST(s) ? - s->strstart - (IPos)MAX_DIST(s) : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - Posf *prev = s->prev; - uInt wmask = s->w_mask; - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; - register ush scan_start = *(ushf*)scan; - register ush scan_end = *(ushf*)(scan+best_len-1); -#else - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - register Byte scan_end1 = scan[best_len-1]; - register Byte scan_end = scan[best_len]; -#endif - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - /* Do not waste too much time if we already have a good match: */ - if (s->prev_length >= s->good_match) { - chain_length >>= 2; - } - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - do { - Assert(cur_match < s->strstart, "no future"); - match = s->window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2: - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ushf*)(match+best_len-1) != scan_end || - *(ushf*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - Assert(scan[2] == match[2], "scan[2]?"); - scan++, match++; - do { - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - s->match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ushf*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & wmask]) > limit - && --chain_length != 0); - - if ((uInt)best_len <= s->lookahead) return (uInt)best_len; - return s->lookahead; -} - -#else /* FASTEST */ -/* --------------------------------------------------------------------------- - * Optimized version for level == 1 only - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - Assert(cur_match < s->strstart, "no future"); - - match = s->window + cur_match; - - /* Return failure if the match length is less than 2: - */ - if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match += 2; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - - if (len < MIN_MATCH) return MIN_MATCH - 1; - - s->match_start = cur_match; - return len <= s->lookahead ? len : s->lookahead; -} -#endif /* FASTEST */ -#endif /* ASMV */ - -#ifdef DEBUG -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); - do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); - z_error("invalid match"); - } - if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(s, start, match, length) -#endif - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - register unsigned n, m; - register Posf *p; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if strstart == 0 - * and lookahead == 1 (input done one byte at time) - */ - more--; - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - } else if (s->strstart >= wsize+MAX_DIST(s)) { - - zmemcpy(s->window, s->window+wsize, (unsigned)wsize); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - - /* Slide the hash table (could be avoided with 32 bit values - at the expense of memory usage). We slide even when level == 0 - to keep the hash table consistent if we switch back to level > 0 - later. (Using level 0 permanently is not an optimal usage of - zlib, so we don't care about this pathological case.) - */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); - - n = wsize; -#ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); -#endif - more += wsize; - } - if (s->strm->avail_in == 0) return; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead >= MIN_MATCH) { - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK_ONLY(s, eof) { \ - _tr_flush_block(s, (s->block_start >= 0L ? \ - (charf *)&s->window[(unsigned)s->block_start] : \ - (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (eof)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, eof) { \ - FLUSH_BLOCK_ONLY(s, eof); \ - if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ -} - -/* =========================================================================== - * Copy without compression as much as possible from the input stream, return - * the current block state. - * This function does not insert new strings in the dictionary since - * uncompressible data is probably not useful. This function is used - * only for the level=0 compression option. - * NOTE: this function should be optimized to avoid extra copying from - * window to pending_buf. - */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited - * to pending_buf_size, and each stored block has a 5 byte header: - */ - ulg max_block_size = 0xffff; - ulg max_start; - - if (max_block_size > s->pending_buf_size - 5) { - max_block_size = s->pending_buf_size - 5; - } - - /* Copy as much as possible from input to output: */ - for (;;) { - /* Fill the window as much as possible: */ - if (s->lookahead <= 1) { - - Assert(s->strstart < s->w_size+MAX_DIST(s) || - s->block_start >= (long)s->w_size, "slide too late"); - - fill_window(s); - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; - - if (s->lookahead == 0) break; /* flush the current block */ - } - Assert(s->block_start >= 0L, "block gone"); - - s->strstart += s->lookahead; - s->lookahead = 0; - - /* Emit a stored block if pending_buf will be full: */ - max_start = s->block_start + max_block_size; - if (s->strstart == 0 || (ulg)s->strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s->lookahead = (uInt)(s->strstart - max_start); - s->strstart = (uInt)max_start; - FLUSH_BLOCK(s, 0); - } - /* Flush if we may have to slide, otherwise block_start may become - * negative and the data will be gone: - */ - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { - FLUSH_BLOCK(s, 0); - } - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -/* =========================================================================== - * Compress as much as possible from the input stream, return the current - * block state. - * This function does not perform lazy evaluation of matches and inserts - * new strings in the dictionary only for unmatched strings or for short - * matches. It is used only for the fast compression options. - */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - if (s->strategy != Z_HUFFMAN_ONLY) { - s->match_length = longest_match (s, hash_head); - } - /* longest_match() sets match_start */ - } - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->match_start, s->match_length); - - _tr_tally_dist(s, s->strstart - s->match_start, - s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ -#ifndef FASTEST - if (s->match_length <= s->max_insert_length && - s->lookahead >= MIN_MATCH) { - s->match_length--; /* string at strstart already in hash table */ - do { - s->strstart++; - INSERT_STRING(s, s->strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--s->match_length != 0); - s->strstart++; - } else -#endif - { - s->strstart += s->match_length; - s->match_length = 0; - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* head of hash chain */ - int bflush; /* set if current block must be flushed */ - - /* Process the input block. */ - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - */ - s->prev_length = s->match_length, s->prev_match = s->match_start; - s->match_length = MIN_MATCH-1; - - if (hash_head != NIL && s->prev_length < s->max_lazy_match && - s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - if (s->strategy != Z_HUFFMAN_ONLY) { - s->match_length = longest_match (s, hash_head); - } - /* longest_match() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED || - (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR))) { - - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - s->match_length = MIN_MATCH-1; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - - check_match(s, s->strstart-1, s->prev_match, s->prev_length); - - _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not - * enough lookahead, the last two strings are not inserted in - * the hash table. - */ - s->lookahead -= s->prev_length-1; - s->prev_length -= 2; - do { - if (++s->strstart <= max_insert) { - INSERT_STRING(s, s->strstart, hash_head); - } - } while (--s->prev_length != 0); - s->match_available = 0; - s->match_length = MIN_MATCH-1; - s->strstart++; - - if (bflush) FLUSH_BLOCK(s, 0); - - } else if (s->match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - if (bflush) { - FLUSH_BLOCK_ONLY(s, 0); - } - s->strstart++; - s->lookahead--; - if (s->strm->avail_out == 0) return need_more; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - s->match_available = 1; - s->strstart++; - s->lookahead--; - } - } - Assert (flush != Z_NO_FLUSH, "no flush?"); - if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - s->match_available = 0; - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} diff --git a/freeimage241/Source/ZLib/deflate.h b/freeimage241/Source/ZLib/deflate.h deleted file mode 100644 index 2978fe3..0000000 --- a/freeimage241/Source/ZLib/deflate.h +++ /dev/null @@ -1,318 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-1998 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id: deflate.h,v 1.0 2001-04-13 00:42:44+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -#ifndef _DEFLATE_H -#define _DEFLATE_H - -#include "zutil.h" - -/* =========================================================================== - * Internal compression state. - */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define INIT_STATE 42 -#define BUSY_STATE 113 -#define FINISH_STATE 666 -/* Stream status */ - - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data_s { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} FAR ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -typedef struct static_tree_desc_s static_tree_desc; - -typedef struct tree_desc_s { - ct_data *dyn_tree; /* the dynamic tree */ - int max_code; /* largest code with non zero frequency */ - static_tree_desc *stat_desc; /* the corresponding static tree */ -} FAR tree_desc; - -typedef ush Pos; -typedef Pos FAR Posf; -typedef unsigned IPos; - -/* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. IPos is used only for parameter passing. - */ - -typedef struct internal_state { - z_streamp strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - Bytef *pending_buf; /* output still pending */ - ulg pending_buf_size; /* size of pending_buf */ - Bytef *pending_out; /* next pending byte to output to the stream */ - int pending; /* nb of bytes in the pending buffer */ - int noheader; /* suppress zlib header and adler32 */ - Byte data_type; /* UNKNOWN, BINARY or ASCII */ - Byte method; /* STORED (for zip only) or DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ - - /* used by deflate.c: */ - - uInt w_size; /* LZ77 window size (32K by default) */ - uInt w_bits; /* log2(w_size) (8..16) */ - uInt w_mask; /* w_size - 1 */ - - Bytef *window; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. Also, it limits - * the window size to 64K, which is quite useful on MSDOS. - * To do: use the user input buffer as sliding window. - */ - - ulg window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - Posf *prev; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - Posf *head; /* Heads of the hash chains or NIL. */ - - uInt ins_h; /* hash index of string to be inserted */ - uInt hash_size; /* number of elements in hash table */ - uInt hash_bits; /* log2(hash_size) */ - uInt hash_mask; /* hash_size-1 */ - - uInt hash_shift; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to supress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *l_buf; /* buffer for literals or lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - int last_eob_len; /* bit length of EOB code for last block */ - -#ifdef DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - - /* in trees.c */ -void _tr_init OF((deflate_state *s)); -int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); -void _tr_align OF((deflate_state *s)); -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); - -#define d_code(dist) \ - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never - * used. - */ - -#ifndef DEBUG -/* Inline versions of _tr_tally for speed: */ - -#if defined(GEN_TREES_H) || !defined(STDC) - extern uch _length_code[]; - extern uch _dist_code[]; -#else - extern const uch _length_code[]; - extern const uch _dist_code[]; -#endif - -# define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ - s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -# define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ - ush dist = (distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ - dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ - s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -#else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) -#endif - -#endif diff --git a/freeimage241/Source/ZLib/gzio.c b/freeimage241/Source/ZLib/gzio.c deleted file mode 100644 index e9d26e7..0000000 --- a/freeimage241/Source/ZLib/gzio.c +++ /dev/null @@ -1,875 +0,0 @@ -/* gzio.c -- IO on .gz files - * Copyright (C) 1995-1998 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Compile this file with -DNO_DEFLATE to avoid the compression code. - */ - -/* @(#) $Id: gzio.c,v 1.0 2001-04-13 00:42:44+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -#include - -#include "zutil.h" - -struct internal_state {int dummy;}; /* for buggy compilers */ - -#ifndef Z_BUFSIZE -# ifdef MAXSEG_64K -# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ -# else -# define Z_BUFSIZE 16384 -# endif -#endif -#ifndef Z_PRINTF_BUFSIZE -# define Z_PRINTF_BUFSIZE 4096 -#endif - -#define ALLOC(size) malloc(size) -#define TRYFREE(p) {if (p) free(p);} - -static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ - -/* gzip flag byte */ -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define RESERVED 0xE0 /* bits 5..7: reserved */ - -typedef struct gz_stream { - z_stream stream; - int z_err; /* error code for last stream operation */ - int z_eof; /* set if end of input file */ - FILE *file; /* .gz file */ - Byte *inbuf; /* input buffer */ - Byte *outbuf; /* output buffer */ - uLong crc; /* crc32 of uncompressed data */ - char *msg; /* error message */ - char *path; /* path name for debugging only */ - int transparent; /* 1 if input file is not a .gz file */ - char mode; /* 'w' or 'r' */ - long startpos; /* start of compressed data in file (header skipped) */ -} gz_stream; - - -local gzFile gz_open OF((const char *path, const char *mode, int fd)); -local int do_flush OF((gzFile file, int flush)); -local int get_byte OF((gz_stream *s)); -local void check_header OF((gz_stream *s)); -local int destroy OF((gz_stream *s)); -local void putLong OF((FILE *file, uLong x)); -local uLong getLong OF((gz_stream *s)); - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb"). The file is given either by file descriptor - or path name (if fd == -1). - gz_open return NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). -*/ -local gzFile gz_open (path, mode, fd) - const char *path; - const char *mode; - int fd; -{ - int err; - int level = Z_DEFAULT_COMPRESSION; /* compression level */ - int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ - char *p = (char*)mode; - gz_stream *s; - char fmode[80]; /* copy of mode, without the compression level */ - char *m = fmode; - - if (!path || !mode) return Z_NULL; - - s = (gz_stream *)ALLOC(sizeof(gz_stream)); - if (!s) return Z_NULL; - - s->stream.zalloc = (alloc_func)0; - s->stream.zfree = (free_func)0; - s->stream.opaque = (voidpf)0; - s->stream.next_in = s->inbuf = Z_NULL; - s->stream.next_out = s->outbuf = Z_NULL; - s->stream.avail_in = s->stream.avail_out = 0; - s->file = NULL; - s->z_err = Z_OK; - s->z_eof = 0; - s->crc = crc32(0L, Z_NULL, 0); - s->msg = NULL; - s->transparent = 0; - - s->path = (char*)ALLOC(strlen(path)+1); - if (s->path == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - strcpy(s->path, path); /* do this early for debugging */ - - s->mode = '\0'; - do { - if (*p == 'r') s->mode = 'r'; - if (*p == 'w' || *p == 'a') s->mode = 'w'; - if (*p >= '0' && *p <= '9') { - level = *p - '0'; - } else if (*p == 'f') { - strategy = Z_FILTERED; - } else if (*p == 'h') { - strategy = Z_HUFFMAN_ONLY; - } else { - *m++ = *p; /* copy the mode */ - } - } while (*p++ && m != fmode + sizeof(fmode)); - if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; - - if (s->mode == 'w') { -#ifdef NO_DEFLATE - err = Z_STREAM_ERROR; -#else - err = deflateInit2(&(s->stream), level, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); - /* windowBits is passed < 0 to suppress zlib header */ - - s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); -#endif - if (err != Z_OK || s->outbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } else { - s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); - - err = inflateInit2(&(s->stream), -MAX_WBITS); - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are - * present after the compressed stream. - */ - if (err != Z_OK || s->inbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } - s->stream.avail_out = Z_BUFSIZE; - - errno = 0; - s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode); - - if (s->file == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - if (s->mode == 'w') { - /* Write a very simple .gz header: - */ - fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); - s->startpos = 10L; - /* We use 10L instead of ftell(s->file) to because ftell causes an - * fflush on some systems. This version of the library doesn't use - * startpos anyway in write mode, so this initialization is not - * necessary. - */ - } else { - check_header(s); /* skip the .gz header */ - s->startpos = (ftell(s->file) - s->stream.avail_in); - } - - return (gzFile)s; -} - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. -*/ -gzFile ZEXPORT gzopen (path, mode) - const char *path; - const char *mode; -{ - return gz_open (path, mode, -1); -} - -/* =========================================================================== - Associate a gzFile with the file descriptor fd. fd is not dup'ed here - to mimic the behavio(u)r of fdopen. -*/ -gzFile ZEXPORT gzdopen (fd, mode) - int fd; - const char *mode; -{ - char name[20]; - - if (fd < 0) return (gzFile)Z_NULL; - sprintf(name, "", fd); /* for debugging */ - - return gz_open (name, mode, fd); -} - -/* =========================================================================== - * Update the compression level and strategy - */ -int ZEXPORT gzsetparams (file, level, strategy) - gzFile file; - int level; - int strategy; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - /* Make room to allow flushing */ - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - } - s->stream.avail_out = Z_BUFSIZE; - } - - return deflateParams (&(s->stream), level, strategy); -} - -/* =========================================================================== - Read a byte from a gz_stream; update next_in and avail_in. Return EOF - for end of file. - IN assertion: the stream s has been sucessfully opened for reading. -*/ -local int get_byte(s) - gz_stream *s; -{ - if (s->z_eof) return EOF; - if (s->stream.avail_in == 0) { - errno = 0; - s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) s->z_err = Z_ERRNO; - return EOF; - } - s->stream.next_in = s->inbuf; - } - s->stream.avail_in--; - return *(s->stream.next_in)++; -} - -/* =========================================================================== - Check the gzip header of a gz_stream opened for reading. Set the stream - mode to transparent if the gzip magic header is not present; set s->err - to Z_DATA_ERROR if the magic header is present but the rest of the header - is incorrect. - IN assertion: the stream s has already been created sucessfully; - s->stream.avail_in is zero for the first time, but may be non-zero - for concatenated .gz files. -*/ -local void check_header(s) - gz_stream *s; -{ - int method; /* method byte */ - int flags; /* flags byte */ - uInt len; - int c; - - /* Check the gzip magic header */ - for (len = 0; len < 2; len++) { - c = get_byte(s); - if (c != gz_magic[len]) { - if (len != 0) s->stream.avail_in++, s->stream.next_in--; - if (c != EOF) { - s->stream.avail_in++, s->stream.next_in--; - s->transparent = 1; - } - s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END; - return; - } - } - method = get_byte(s); - flags = get_byte(s); - if (method != Z_DEFLATED || (flags & RESERVED) != 0) { - s->z_err = Z_DATA_ERROR; - return; - } - - /* Discard time, xflags and OS code: */ - for (len = 0; len < 6; len++) (void)get_byte(s); - - if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ - len = (uInt)get_byte(s); - len += ((uInt)get_byte(s))<<8; - /* len is garbage if EOF but the loop below will quit anyway */ - while (len-- != 0 && get_byte(s) != EOF) ; - } - if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ - for (len = 0; len < 2; len++) (void)get_byte(s); - } - s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; -} - - /* =========================================================================== - * Cleanup then free the given gz_stream. Return a zlib error code. - Try freeing in the reverse order of allocations. - */ -local int destroy (s) - gz_stream *s; -{ - int err = Z_OK; - - if (!s) return Z_STREAM_ERROR; - - TRYFREE(s->msg); - - if (s->stream.state != NULL) { - if (s->mode == 'w') { -#ifdef NO_DEFLATE - err = Z_STREAM_ERROR; -#else - err = deflateEnd(&(s->stream)); -#endif - } else if (s->mode == 'r') { - err = inflateEnd(&(s->stream)); - } - } - if (s->file != NULL && fclose(s->file)) { -#ifdef ESPIPE - if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ -#endif - err = Z_ERRNO; - } - if (s->z_err < 0) err = s->z_err; - - TRYFREE(s->inbuf); - TRYFREE(s->outbuf); - TRYFREE(s->path); - TRYFREE(s); - return err; -} - -/* =========================================================================== - Reads the given number of uncompressed bytes from the compressed file. - gzread returns the number of bytes actually read (0 for end of file). -*/ -int ZEXPORT gzread (file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ - gz_stream *s = (gz_stream*)file; - Bytef *start = (Bytef*)buf; /* starting point for crc computation */ - Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ - - if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; - - if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; - if (s->z_err == Z_STREAM_END) return 0; /* EOF */ - - next_out = (Byte*)buf; - s->stream.next_out = (Bytef*)buf; - s->stream.avail_out = len; - - while (s->stream.avail_out != 0) { - - if (s->transparent) { - /* Copy first the lookahead bytes: */ - uInt n = s->stream.avail_in; - if (n > s->stream.avail_out) n = s->stream.avail_out; - if (n > 0) { - zmemcpy(s->stream.next_out, s->stream.next_in, n); - next_out += n; - s->stream.next_out = next_out; - s->stream.next_in += n; - s->stream.avail_out -= n; - s->stream.avail_in -= n; - } - if (s->stream.avail_out > 0) { - s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out, - s->file); - } - len -= s->stream.avail_out; - s->stream.total_in += (uLong)len; - s->stream.total_out += (uLong)len; - if (len == 0) s->z_eof = 1; - return (int)len; - } - if (s->stream.avail_in == 0 && !s->z_eof) { - - errno = 0; - s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) { - s->z_err = Z_ERRNO; - break; - } - } - s->stream.next_in = s->inbuf; - } - s->z_err = inflate(&(s->stream), Z_NO_FLUSH); - - if (s->z_err == Z_STREAM_END) { - /* Check CRC and original size */ - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - start = s->stream.next_out; - - if (getLong(s) != s->crc) { - s->z_err = Z_DATA_ERROR; - } else { - (void)getLong(s); - /* The uncompressed length returned by above getlong() may - * be different from s->stream.total_out) in case of - * concatenated .gz files. Check for such files: - */ - check_header(s); - if (s->z_err == Z_OK) { - uLong total_in = s->stream.total_in; - uLong total_out = s->stream.total_out; - - inflateReset(&(s->stream)); - s->stream.total_in = total_in; - s->stream.total_out = total_out; - s->crc = crc32(0L, Z_NULL, 0); - } - } - } - if (s->z_err != Z_OK || s->z_eof) break; - } - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - - return (int)(len - s->stream.avail_out); -} - - -/* =========================================================================== - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ -int ZEXPORT gzgetc(file) - gzFile file; -{ - unsigned char c; - - return gzread(file, &c, 1) == 1 ? c : -1; -} - - -/* =========================================================================== - Reads bytes from the compressed file until len-1 characters are - read, or a newline character is read and transferred to buf, or an - end-of-file condition is encountered. The string is then terminated - with a null character. - gzgets returns buf, or Z_NULL in case of error. - - The current implementation is not optimized at all. -*/ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ - char *b = buf; - if (buf == Z_NULL || len <= 0) return Z_NULL; - - while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ; - *buf = '\0'; - return b == buf && len > 0 ? Z_NULL : b; -} - - -#ifndef NO_DEFLATE -/* =========================================================================== - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of bytes actually written (0 in case of error). -*/ -int ZEXPORT gzwrite (file, buf, len) - gzFile file; - const voidp buf; - unsigned len; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.next_in = (Bytef*)buf; - s->stream.avail_in = len; - - while (s->stream.avail_in != 0) { - - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - break; - } - s->stream.avail_out = Z_BUFSIZE; - } - s->z_err = deflate(&(s->stream), Z_NO_FLUSH); - if (s->z_err != Z_OK) break; - } - s->crc = crc32(s->crc, (const Bytef *)buf, len); - - return (int)(len - s->stream.avail_in); -} - -/* =========================================================================== - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). -*/ -#ifdef STDC -#include - -int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) -{ - char buf[Z_PRINTF_BUFSIZE]; - va_list va; - int len; - - va_start(va, format); -#ifdef HAS_vsnprintf - (void)vsnprintf(buf, sizeof(buf), format, va); -#else - (void)vsprintf(buf, format, va); -#endif - va_end(va); - len = strlen(buf); /* some *sprintf don't return the nb of bytes written */ - if (len <= 0) return 0; - - return gzwrite(file, buf, (unsigned)len); -} -#else /* not ANSI C */ - -int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ - char buf[Z_PRINTF_BUFSIZE]; - int len; - -#ifdef HAS_snprintf - snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -#else - sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -#endif - len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */ - if (len <= 0) return 0; - - return gzwrite(file, buf, len); -} -#endif - -/* =========================================================================== - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ - unsigned char cc = (unsigned char) c; /* required for big endian systems */ - - return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; -} - - -/* =========================================================================== - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ -int ZEXPORT gzputs(file, s) - gzFile file; - const char *s; -{ - return gzwrite(file, (char*)s, (unsigned)strlen(s)); -} - - -/* =========================================================================== - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. -*/ -local int do_flush (file, flush) - gzFile file; - int flush; -{ - uInt len; - int done = 0; - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.avail_in = 0; /* should be zero already anyway */ - - for (;;) { - len = Z_BUFSIZE - s->stream.avail_out; - - if (len != 0) { - if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { - s->z_err = Z_ERRNO; - return Z_ERRNO; - } - s->stream.next_out = s->outbuf; - s->stream.avail_out = Z_BUFSIZE; - } - if (done) break; - s->z_err = deflate(&(s->stream), flush); - - /* Ignore the second of two consecutive flushes: */ - if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; - - /* deflate has finished flushing only when it hasn't used up - * all the available space in the output buffer: - */ - done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); - - if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; - } - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} - -int ZEXPORT gzflush (file, flush) - gzFile file; - int flush; -{ - gz_stream *s = (gz_stream*)file; - int err = do_flush (file, flush); - - if (err) return err; - fflush(s->file); - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} -#endif /* NO_DEFLATE */ - -/* =========================================================================== - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error. - SEEK_END is not implemented, returns error. - In this version of the library, gzseek can be extremely slow. -*/ -z_off_t ZEXPORT gzseek (file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || whence == SEEK_END || - s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { - return -1L; - } - - if (s->mode == 'w') { -#ifdef NO_DEFLATE - return -1L; -#else - if (whence == SEEK_SET) { - offset -= s->stream.total_in; - } - if (offset < 0) return -1L; - - /* At this point, offset is the number of zero bytes to write. */ - if (s->inbuf == Z_NULL) { - s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ - zmemzero(s->inbuf, Z_BUFSIZE); - } - while (offset > 0) { - uInt size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (uInt)offset; - - size = gzwrite(file, s->inbuf, size); - if (size == 0) return -1L; - - offset -= size; - } - return (z_off_t)s->stream.total_in; -#endif - } - /* Rest of function is for reading only */ - - /* compute absolute position */ - if (whence == SEEK_CUR) { - offset += s->stream.total_out; - } - if (offset < 0) return -1L; - - if (s->transparent) { - /* map to fseek */ - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; - - s->stream.total_in = s->stream.total_out = (uLong)offset; - return offset; - } - - /* For a negative seek, rewind and use positive seek */ - if ((uLong)offset >= s->stream.total_out) { - offset -= s->stream.total_out; - } else if (gzrewind(file) < 0) { - return -1L; - } - /* offset is now the number of bytes to skip. */ - - if (offset != 0 && s->outbuf == Z_NULL) { - s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); - } - while (offset > 0) { - int size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (int)offset; - - size = gzread(file, s->outbuf, (uInt)size); - if (size <= 0) return -1L; - offset -= size; - } - return (z_off_t)s->stream.total_out; -} - -/* =========================================================================== - Rewinds input file. -*/ -int ZEXPORT gzrewind (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r') return -1; - - s->z_err = Z_OK; - s->z_eof = 0; - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - s->crc = crc32(0L, Z_NULL, 0); - - if (s->startpos == 0) { /* not a compressed file */ - rewind(s->file); - return 0; - } - - (void) inflateReset(&s->stream); - return fseek(s->file, s->startpos, SEEK_SET); -} - -/* =========================================================================== - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. -*/ -z_off_t ZEXPORT gztell (file) - gzFile file; -{ - return gzseek(file, 0L, SEEK_CUR); -} - -/* =========================================================================== - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ -int ZEXPORT gzeof (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - return (s == NULL || s->mode != 'r') ? 0 : s->z_eof; -} - -/* =========================================================================== - Outputs a long in LSB order to the given file -*/ -local void putLong (file, x) - FILE *file; - uLong x; -{ - int n; - for (n = 0; n < 4; n++) { - fputc((int)(x & 0xff), file); - x >>= 8; - } -} - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets z_err in case - of error. -*/ -local uLong getLong (s) - gz_stream *s; -{ - uLong x = (uLong)get_byte(s); - int c; - - x += ((uLong)get_byte(s))<<8; - x += ((uLong)get_byte(s))<<16; - c = get_byte(s); - if (c == EOF) s->z_err = Z_DATA_ERROR; - x += ((uLong)c)<<24; - return x; -} - -/* =========================================================================== - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. -*/ -int ZEXPORT gzclose (file) - gzFile file; -{ - int err; - gz_stream *s = (gz_stream*)file; - - if (s == NULL) return Z_STREAM_ERROR; - - if (s->mode == 'w') { -#ifdef NO_DEFLATE - return Z_STREAM_ERROR; -#else - err = do_flush (file, Z_FINISH); - if (err != Z_OK) return destroy((gz_stream*)file); - - putLong (s->file, s->crc); - putLong (s->file, s->stream.total_in); -#endif - } - return destroy((gz_stream*)file); -} - -/* =========================================================================== - Returns the error message for the last error which occured on the - given compressed file. errnum is set to zlib error number. If an - error occured in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ -const char* ZEXPORT gzerror (file, errnum) - gzFile file; - int *errnum; -{ - char *m; - gz_stream *s = (gz_stream*)file; - - if (s == NULL) { - *errnum = Z_STREAM_ERROR; - return (const char*)ERR_MSG(Z_STREAM_ERROR); - } - *errnum = s->z_err; - if (*errnum == Z_OK) return (const char*)""; - - m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); - - if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); - - TRYFREE(s->msg); - s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); - strcpy(s->msg, s->path); - strcat(s->msg, ": "); - strcat(s->msg, m); - return (const char*)s->msg; -} diff --git a/freeimage241/Source/ZLib/infblock.c b/freeimage241/Source/ZLib/infblock.c deleted file mode 100644 index f4920fa..0000000 --- a/freeimage241/Source/ZLib/infblock.c +++ /dev/null @@ -1,398 +0,0 @@ -/* infblock.c -- interpret and process block types to last block - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infblock.h" -#include "inftrees.h" -#include "infcodes.h" -#include "infutil.h" - -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -/* Table for deflate from PKZIP's appnote.txt. */ -local const uInt border[] = { /* Order of the bit length code lengths */ - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - -/* - Notes beyond the 1.93a appnote.txt: - - 1. Distance pointers never point before the beginning of the output - stream. - 2. Distance pointers can point back across blocks, up to 32k away. - 3. There is an implied maximum of 7 bits for the bit length table and - 15 bits for the actual data. - 4. If only one code exists, then it is encoded using one bit. (Zero - would be more efficient, but perhaps a little confusing.) If two - codes exist, they are coded using one bit each (0 and 1). - 5. There is no way of sending zero distance codes--a dummy must be - sent if there are none. (History: a pre 2.0 version of PKZIP would - store blocks with no distance codes, but this was discovered to be - too harsh a criterion.) Valid only for 1.93a. 2.04c does allow - zero distance codes, which is sent as one code of zero bits in - length. - 6. There are up to 286 literal/length codes. Code 256 represents the - end-of-block. Note however that the static length tree defines - 288 codes just to fill out the Huffman codes. Codes 286 and 287 - cannot be used though, since there is no length base or extra bits - defined for them. Similarily, there are up to 30 distance codes. - However, static trees define 32 codes (all 5 bits) to fill out the - Huffman codes, but the last two had better not show up in the data. - 7. Unzip can check dynamic Huffman blocks for complete code sets. - The exception is that a single code would not be complete (see #4). - 8. The five bits following the block type is really the number of - literal codes sent minus 257. - 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits - (1+6+6). Therefore, to output three times the length, you output - three codes (1+1+1), whereas to output four times the same length, - you only need two codes (1+3). Hmm. - 10. In the tree reconstruction algorithm, Code = Code + Increment - only if BitLength(i) is not zero. (Pretty obvious.) - 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) - 12. Note: length code 284 can represent 227-258, but length code 285 - really is 258. The last length deserves its own, short code - since it gets used a lot in very redundant files. The length - 258 is special since 258 - 3 (the min match length) is 255. - 13. The literal/length and distance code bit lengths are read as a - single stream of lengths. It is possible (and advantageous) for - a repeat code (16, 17, or 18) to go across the boundary between - the two sets of lengths. - */ - - -void inflate_blocks_reset(s, z, c) -inflate_blocks_statef *s; -z_streamp z; -uLongf *c; -{ - if (c != Z_NULL) - *c = s->check; - if (s->mode == BTREE || s->mode == DTREE) - ZFREE(z, s->sub.trees.blens); - if (s->mode == CODES) - inflate_codes_free(s->sub.decode.codes, z); - s->mode = TYPE; - s->bitk = 0; - s->bitb = 0; - s->read = s->write = s->window; - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0); - Tracev((stderr, "inflate: blocks reset\n")); -} - - -inflate_blocks_statef *inflate_blocks_new(z, c, w) -z_streamp z; -check_func c; -uInt w; -{ - inflate_blocks_statef *s; - - if ((s = (inflate_blocks_statef *)ZALLOC - (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL) - return s; - if ((s->hufts = - (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL) - { - ZFREE(z, s); - return Z_NULL; - } - if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL) - { - ZFREE(z, s->hufts); - ZFREE(z, s); - return Z_NULL; - } - s->end = s->window + w; - s->checkfn = c; - s->mode = TYPE; - Tracev((stderr, "inflate: blocks allocated\n")); - inflate_blocks_reset(s, z, Z_NULL); - return s; -} - - -int inflate_blocks(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt t; /* temporary storage */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - - /* copy input/output information to locals (UPDATE macro restores) */ - LOAD - - /* process input based on current state */ - while (1) switch (s->mode) - { - case TYPE: - NEEDBITS(3) - t = (uInt)b & 7; - s->last = t & 1; - switch (t >> 1) - { - case 0: /* stored */ - Tracev((stderr, "inflate: stored block%s\n", - s->last ? " (last)" : "")); - DUMPBITS(3) - t = k & 7; /* go to byte boundary */ - DUMPBITS(t) - s->mode = LENS; /* get length of stored block */ - break; - case 1: /* fixed */ - Tracev((stderr, "inflate: fixed codes block%s\n", - s->last ? " (last)" : "")); - { - uInt bl, bd; - inflate_huft *tl, *td; - - inflate_trees_fixed(&bl, &bd, &tl, &td, z); - s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); - if (s->sub.decode.codes == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - } - DUMPBITS(3) - s->mode = CODES; - break; - case 2: /* dynamic */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - s->last ? " (last)" : "")); - DUMPBITS(3) - s->mode = TABLE; - break; - case 3: /* illegal */ - DUMPBITS(3) - s->mode = BAD; - z->msg = (char*)"invalid block type"; - r = Z_DATA_ERROR; - LEAVE - } - break; - case LENS: - NEEDBITS(32) - if ((((~b) >> 16) & 0xffff) != (b & 0xffff)) - { - s->mode = BAD; - z->msg = (char*)"invalid stored block lengths"; - r = Z_DATA_ERROR; - LEAVE - } - s->sub.left = (uInt)b & 0xffff; - b = k = 0; /* dump bits */ - Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); - s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE); - break; - case STORED: - if (n == 0) - LEAVE - NEEDOUT - t = s->sub.left; - if (t > n) t = n; - if (t > m) t = m; - zmemcpy(q, p, t); - p += t; n -= t; - q += t; m -= t; - if ((s->sub.left -= t) != 0) - break; - Tracev((stderr, "inflate: stored end, %lu total out\n", - z->total_out + (q >= s->read ? q - s->read : - (s->end - s->read) + (q - s->window)))); - s->mode = s->last ? DRY : TYPE; - break; - case TABLE: - NEEDBITS(14) - s->sub.trees.table = t = (uInt)b & 0x3fff; -#ifndef PKZIP_BUG_WORKAROUND - if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) - { - s->mode = BAD; - z->msg = (char*)"too many length or distance symbols"; - r = Z_DATA_ERROR; - LEAVE - } -#endif - t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); - if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - DUMPBITS(14) - s->sub.trees.index = 0; - Tracev((stderr, "inflate: table sizes ok\n")); - s->mode = BTREE; - case BTREE: - while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) - { - NEEDBITS(3) - s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7; - DUMPBITS(3) - } - while (s->sub.trees.index < 19) - s->sub.trees.blens[border[s->sub.trees.index++]] = 0; - s->sub.trees.bb = 7; - t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, - &s->sub.trees.tb, s->hufts, z); - if (t != Z_OK) - { - ZFREE(z, s->sub.trees.blens); - r = t; - if (r == Z_DATA_ERROR) - s->mode = BAD; - LEAVE - } - s->sub.trees.index = 0; - Tracev((stderr, "inflate: bits tree ok\n")); - s->mode = DTREE; - case DTREE: - while (t = s->sub.trees.table, - s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) - { - inflate_huft *h; - uInt i, j, c; - - t = s->sub.trees.bb; - NEEDBITS(t) - h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); - t = h->bits; - c = h->base; - if (c < 16) - { - DUMPBITS(t) - s->sub.trees.blens[s->sub.trees.index++] = c; - } - else /* c == 16..18 */ - { - i = c == 18 ? 7 : c - 14; - j = c == 18 ? 11 : 3; - NEEDBITS(t + i) - DUMPBITS(t) - j += (uInt)b & inflate_mask[i]; - DUMPBITS(i) - i = s->sub.trees.index; - t = s->sub.trees.table; - if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || - (c == 16 && i < 1)) - { - ZFREE(z, s->sub.trees.blens); - s->mode = BAD; - z->msg = (char*)"invalid bit length repeat"; - r = Z_DATA_ERROR; - LEAVE - } - c = c == 16 ? s->sub.trees.blens[i - 1] : 0; - do { - s->sub.trees.blens[i++] = c; - } while (--j); - s->sub.trees.index = i; - } - } - s->sub.trees.tb = Z_NULL; - { - uInt bl, bd; - inflate_huft *tl, *td; - inflate_codes_statef *c; - - bl = 9; /* must be <= 9 for lookahead assumptions */ - bd = 6; /* must be <= 9 for lookahead assumptions */ - t = s->sub.trees.table; - t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), - s->sub.trees.blens, &bl, &bd, &tl, &td, - s->hufts, z); - ZFREE(z, s->sub.trees.blens); - if (t != Z_OK) - { - if (t == (uInt)Z_DATA_ERROR) - s->mode = BAD; - r = t; - LEAVE - } - Tracev((stderr, "inflate: trees ok\n")); - if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - s->sub.decode.codes = c; - } - s->mode = CODES; - case CODES: - UPDATE - if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) - return inflate_flush(s, z, r); - r = Z_OK; - inflate_codes_free(s->sub.decode.codes, z); - LOAD - Tracev((stderr, "inflate: codes end, %lu total out\n", - z->total_out + (q >= s->read ? q - s->read : - (s->end - s->read) + (q - s->window)))); - if (!s->last) - { - s->mode = TYPE; - break; - } - s->mode = DRY; - case DRY: - FLUSH - if (s->read != s->write) - LEAVE - s->mode = DONE; - case DONE: - r = Z_STREAM_END; - LEAVE - case BAD: - r = Z_DATA_ERROR; - LEAVE - default: - r = Z_STREAM_ERROR; - LEAVE - } -} - - -int inflate_blocks_free(s, z) -inflate_blocks_statef *s; -z_streamp z; -{ - inflate_blocks_reset(s, z, Z_NULL); - ZFREE(z, s->window); - ZFREE(z, s->hufts); - ZFREE(z, s); - Tracev((stderr, "inflate: blocks freed\n")); - return Z_OK; -} - - -void inflate_set_dictionary(s, d, n) -inflate_blocks_statef *s; -const Bytef *d; -uInt n; -{ - zmemcpy(s->window, d, n); - s->read = s->write = s->window + n; -} - - -/* Returns true if inflate is currently at the end of a block generated - * by Z_SYNC_FLUSH or Z_FULL_FLUSH. - * IN assertion: s != Z_NULL - */ -int inflate_blocks_sync_point(s) -inflate_blocks_statef *s; -{ - return s->mode == LENS; -} diff --git a/freeimage241/Source/ZLib/infblock.h b/freeimage241/Source/ZLib/infblock.h deleted file mode 100644 index bd25c80..0000000 --- a/freeimage241/Source/ZLib/infblock.h +++ /dev/null @@ -1,39 +0,0 @@ -/* infblock.h -- header to use infblock.c - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -struct inflate_blocks_state; -typedef struct inflate_blocks_state FAR inflate_blocks_statef; - -extern inflate_blocks_statef * inflate_blocks_new OF(( - z_streamp z, - check_func c, /* check function */ - uInt w)); /* window size */ - -extern int inflate_blocks OF(( - inflate_blocks_statef *, - z_streamp , - int)); /* initial return code */ - -extern void inflate_blocks_reset OF(( - inflate_blocks_statef *, - z_streamp , - uLongf *)); /* check value on output */ - -extern int inflate_blocks_free OF(( - inflate_blocks_statef *, - z_streamp)); - -extern void inflate_set_dictionary OF(( - inflate_blocks_statef *s, - const Bytef *d, /* dictionary */ - uInt n)); /* dictionary length */ - -extern int inflate_blocks_sync_point OF(( - inflate_blocks_statef *s)); diff --git a/freeimage241/Source/ZLib/infcodes.c b/freeimage241/Source/ZLib/infcodes.c deleted file mode 100644 index d4e5ee9..0000000 --- a/freeimage241/Source/ZLib/infcodes.c +++ /dev/null @@ -1,257 +0,0 @@ -/* infcodes.c -- process literals and length/distance pairs - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "infblock.h" -#include "infcodes.h" -#include "infutil.h" -#include "inffast.h" - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ - START, /* x: set up for LEN */ - LEN, /* i: get length/literal/eob next */ - LENEXT, /* i: getting length extra (have base) */ - DIST, /* i: get distance next */ - DISTEXT, /* i: getting distance extra */ - COPY, /* o: copying bytes in window, waiting for space */ - LIT, /* o: got literal, waiting for output space */ - WASH, /* o: got eob, possibly still output waiting */ - END, /* x: got eob and all data flushed */ - BADCODE} /* x: got error */ -inflate_codes_mode; - -/* inflate codes private state */ -struct inflate_codes_state { - - /* mode */ - inflate_codes_mode mode; /* current inflate_codes mode */ - - /* mode dependent information */ - uInt len; - union { - struct { - inflate_huft *tree; /* pointer into tree */ - uInt need; /* bits needed */ - } code; /* if LEN or DIST, where in tree */ - uInt lit; /* if LIT, literal */ - struct { - uInt get; /* bits to get for extra */ - uInt dist; /* distance back to copy from */ - } copy; /* if EXT or COPY, where and how much */ - } sub; /* submode */ - - /* mode independent information */ - Byte lbits; /* ltree bits decoded per branch */ - Byte dbits; /* dtree bits decoder per branch */ - inflate_huft *ltree; /* literal/length/eob tree */ - inflate_huft *dtree; /* distance tree */ - -}; - - -inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) -uInt bl, bd; -inflate_huft *tl; -inflate_huft *td; /* need separate declaration for Borland C++ */ -z_streamp z; -{ - inflate_codes_statef *c; - - if ((c = (inflate_codes_statef *) - ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL) - { - c->mode = START; - c->lbits = (Byte)bl; - c->dbits = (Byte)bd; - c->ltree = tl; - c->dtree = td; - Tracev((stderr, "inflate: codes new\n")); - } - return c; -} - - -int inflate_codes(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt j; /* temporary storage */ - inflate_huft *t; /* temporary pointer */ - uInt e; /* extra bits or operation */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - Bytef *f; /* pointer to copy strings from */ - inflate_codes_statef *c = s->sub.decode.codes; /* codes state */ - - /* copy input/output information to locals (UPDATE macro restores) */ - LOAD - - /* process input and output based on current state */ - while (1) switch (c->mode) - { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ - case START: /* x: set up for LEN */ -#ifndef SLOW - if (m >= 258 && n >= 10) - { - UPDATE - r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); - LOAD - if (r != Z_OK) - { - c->mode = r == Z_STREAM_END ? WASH : BADCODE; - break; - } - } -#endif /* !SLOW */ - c->sub.code.need = c->lbits; - c->sub.code.tree = c->ltree; - c->mode = LEN; - case LEN: /* i: get length/literal/eob next */ - j = c->sub.code.need; - NEEDBITS(j) - t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); - DUMPBITS(t->bits) - e = (uInt)(t->exop); - if (e == 0) /* literal */ - { - c->sub.lit = t->base; - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", t->base)); - c->mode = LIT; - break; - } - if (e & 16) /* length */ - { - c->sub.copy.get = e & 15; - c->len = t->base; - c->mode = LENEXT; - break; - } - if ((e & 64) == 0) /* next table */ - { - c->sub.code.need = e; - c->sub.code.tree = t + t->base; - break; - } - if (e & 32) /* end of block */ - { - Tracevv((stderr, "inflate: end of block\n")); - c->mode = WASH; - break; - } - c->mode = BADCODE; /* invalid code */ - z->msg = (char*)"invalid literal/length code"; - r = Z_DATA_ERROR; - LEAVE - case LENEXT: /* i: getting length extra (have base) */ - j = c->sub.copy.get; - NEEDBITS(j) - c->len += (uInt)b & inflate_mask[j]; - DUMPBITS(j) - c->sub.code.need = c->dbits; - c->sub.code.tree = c->dtree; - Tracevv((stderr, "inflate: length %u\n", c->len)); - c->mode = DIST; - case DIST: /* i: get distance next */ - j = c->sub.code.need; - NEEDBITS(j) - t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); - DUMPBITS(t->bits) - e = (uInt)(t->exop); - if (e & 16) /* distance */ - { - c->sub.copy.get = e & 15; - c->sub.copy.dist = t->base; - c->mode = DISTEXT; - break; - } - if ((e & 64) == 0) /* next table */ - { - c->sub.code.need = e; - c->sub.code.tree = t + t->base; - break; - } - c->mode = BADCODE; /* invalid code */ - z->msg = (char*)"invalid distance code"; - r = Z_DATA_ERROR; - LEAVE - case DISTEXT: /* i: getting distance extra */ - j = c->sub.copy.get; - NEEDBITS(j) - c->sub.copy.dist += (uInt)b & inflate_mask[j]; - DUMPBITS(j) - Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); - c->mode = COPY; - case COPY: /* o: copying bytes in window, waiting for space */ -#ifndef __TURBOC__ /* Turbo C bug for following expression */ - f = (uInt)(q - s->window) < c->sub.copy.dist ? - s->end - (c->sub.copy.dist - (q - s->window)) : - q - c->sub.copy.dist; -#else - f = q - c->sub.copy.dist; - if ((uInt)(q - s->window) < c->sub.copy.dist) - f = s->end - (c->sub.copy.dist - (uInt)(q - s->window)); -#endif - while (c->len) - { - NEEDOUT - OUTBYTE(*f++) - if (f == s->end) - f = s->window; - c->len--; - } - c->mode = START; - break; - case LIT: /* o: got literal, waiting for output space */ - NEEDOUT - OUTBYTE(c->sub.lit) - c->mode = START; - break; - case WASH: /* o: got eob, possibly more output */ - if (k > 7) /* return unused byte, if any */ - { - Assert(k < 16, "inflate_codes grabbed too many bytes") - k -= 8; - n++; - p--; /* can always return one */ - } - FLUSH - if (s->read != s->write) - LEAVE - c->mode = END; - case END: - r = Z_STREAM_END; - LEAVE - case BADCODE: /* x: got error */ - r = Z_DATA_ERROR; - LEAVE - default: - r = Z_STREAM_ERROR; - LEAVE - } -#ifdef NEED_DUMMY_RETURN - return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ -#endif -} - - -void inflate_codes_free(c, z) -inflate_codes_statef *c; -z_streamp z; -{ - ZFREE(z, c); - Tracev((stderr, "inflate: codes free\n")); -} diff --git a/freeimage241/Source/ZLib/infcodes.h b/freeimage241/Source/ZLib/infcodes.h deleted file mode 100644 index 6c750d8..0000000 --- a/freeimage241/Source/ZLib/infcodes.h +++ /dev/null @@ -1,27 +0,0 @@ -/* infcodes.h -- header to use infcodes.c - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -struct inflate_codes_state; -typedef struct inflate_codes_state FAR inflate_codes_statef; - -extern inflate_codes_statef *inflate_codes_new OF(( - uInt, uInt, - inflate_huft *, inflate_huft *, - z_streamp )); - -extern int inflate_codes OF(( - inflate_blocks_statef *, - z_streamp , - int)); - -extern void inflate_codes_free OF(( - inflate_codes_statef *, - z_streamp )); - diff --git a/freeimage241/Source/ZLib/inffast.c b/freeimage241/Source/ZLib/inffast.c deleted file mode 100644 index 61a78ee..0000000 --- a/freeimage241/Source/ZLib/inffast.c +++ /dev/null @@ -1,170 +0,0 @@ -/* inffast.c -- process literals and length/distance pairs fast - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "infblock.h" -#include "infcodes.h" -#include "infutil.h" -#include "inffast.h" - -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -/* macros for bit input with no checking and for returning unused bytes */ -#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<avail_in-n;c=(k>>3)>3:c;n+=c;p-=c;k-=c<<3;} - -/* Called with number of bytes left to write in window at least 258 - (the maximum string length) and number of input bytes available - at least ten. The ten bytes are six bytes for the longest length/ - distance pair plus four bytes for overloading the bit buffer. */ - -int inflate_fast(bl, bd, tl, td, s, z) -uInt bl, bd; -inflate_huft *tl; -inflate_huft *td; /* need separate declaration for Borland C++ */ -inflate_blocks_statef *s; -z_streamp z; -{ - inflate_huft *t; /* temporary pointer */ - uInt e; /* extra bits or operation */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - uInt ml; /* mask for literal/length tree */ - uInt md; /* mask for distance tree */ - uInt c; /* bytes to copy */ - uInt d; /* distance back to copy from */ - Bytef *r; /* copy source pointer */ - - /* load input, output, bit values */ - LOAD - - /* initialize masks */ - ml = inflate_mask[bl]; - md = inflate_mask[bd]; - - /* do until not enough input or output space for fast loop */ - do { /* assume called with m >= 258 && n >= 10 */ - /* get literal/length code */ - GRABBITS(20) /* max bits for literal/length code */ - if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) - { - DUMPBITS(t->bits) - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: * literal '%c'\n" : - "inflate: * literal 0x%02x\n", t->base)); - *q++ = (Byte)t->base; - m--; - continue; - } - do { - DUMPBITS(t->bits) - if (e & 16) - { - /* get extra bits for length */ - e &= 15; - c = t->base + ((uInt)b & inflate_mask[e]); - DUMPBITS(e) - Tracevv((stderr, "inflate: * length %u\n", c)); - - /* decode distance base of block to copy */ - GRABBITS(15); /* max bits for distance code */ - e = (t = td + ((uInt)b & md))->exop; - do { - DUMPBITS(t->bits) - if (e & 16) - { - /* get extra bits to add to distance base */ - e &= 15; - GRABBITS(e) /* get extra bits (up to 13) */ - d = t->base + ((uInt)b & inflate_mask[e]); - DUMPBITS(e) - Tracevv((stderr, "inflate: * distance %u\n", d)); - - /* do the copy */ - m -= c; - if ((uInt)(q - s->window) >= d) /* offset before dest */ - { /* just copy */ - r = q - d; - *q++ = *r++; c--; /* minimum count is three, */ - *q++ = *r++; c--; /* so unroll loop a little */ - } - else /* else offset after destination */ - { - e = d - (uInt)(q - s->window); /* bytes from offset to end */ - r = s->end - e; /* pointer to offset */ - if (c > e) /* if source crosses, */ - { - c -= e; /* copy to end of window */ - do { - *q++ = *r++; - } while (--e); - r = s->window; /* copy rest from start of window */ - } - } - do { /* copy all or what's left */ - *q++ = *r++; - } while (--c); - break; - } - else if ((e & 64) == 0) - { - t += t->base; - e = (t += ((uInt)b & inflate_mask[e]))->exop; - } - else - { - z->msg = (char*)"invalid distance code"; - UNGRAB - UPDATE - return Z_DATA_ERROR; - } - } while (1); - break; - } - if ((e & 64) == 0) - { - t += t->base; - if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) - { - DUMPBITS(t->bits) - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: * literal '%c'\n" : - "inflate: * literal 0x%02x\n", t->base)); - *q++ = (Byte)t->base; - m--; - break; - } - } - else if (e & 32) - { - Tracevv((stderr, "inflate: * end of block\n")); - UNGRAB - UPDATE - return Z_STREAM_END; - } - else - { - z->msg = (char*)"invalid literal/length code"; - UNGRAB - UPDATE - return Z_DATA_ERROR; - } - } while (1); - } while (m >= 258 && n >= 10); - - /* not enough input or output--restore pointers and return */ - UNGRAB - UPDATE - return Z_OK; -} diff --git a/freeimage241/Source/ZLib/inffast.h b/freeimage241/Source/ZLib/inffast.h deleted file mode 100644 index 8facec5..0000000 --- a/freeimage241/Source/ZLib/inffast.h +++ /dev/null @@ -1,17 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -extern int inflate_fast OF(( - uInt, - uInt, - inflate_huft *, - inflate_huft *, - inflate_blocks_statef *, - z_streamp )); diff --git a/freeimage241/Source/ZLib/inffixed.h b/freeimage241/Source/ZLib/inffixed.h deleted file mode 100644 index 77f7e76..0000000 --- a/freeimage241/Source/ZLib/inffixed.h +++ /dev/null @@ -1,151 +0,0 @@ -/* inffixed.h -- table for decoding fixed codes - * Generated automatically by the maketree.c program - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -local uInt fixed_bl = 9; -local uInt fixed_bd = 5; -local inflate_huft fixed_tl[] = { - {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, - {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192}, - {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160}, - {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224}, - {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144}, - {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208}, - {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176}, - {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240}, - {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, - {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200}, - {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168}, - {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232}, - {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152}, - {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216}, - {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184}, - {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248}, - {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, - {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196}, - {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164}, - {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228}, - {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148}, - {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212}, - {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180}, - {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244}, - {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204}, - {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172}, - {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236}, - {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156}, - {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220}, - {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188}, - {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252}, - {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, - {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194}, - {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162}, - {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226}, - {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146}, - {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210}, - {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178}, - {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242}, - {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, - {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202}, - {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170}, - {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234}, - {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154}, - {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218}, - {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186}, - {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250}, - {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, - {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198}, - {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166}, - {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230}, - {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150}, - {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214}, - {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182}, - {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246}, - {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206}, - {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174}, - {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238}, - {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158}, - {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222}, - {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190}, - {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254}, - {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, - {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193}, - {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161}, - {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225}, - {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145}, - {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209}, - {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177}, - {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241}, - {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, - {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201}, - {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169}, - {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233}, - {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153}, - {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217}, - {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185}, - {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249}, - {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, - {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197}, - {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165}, - {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229}, - {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149}, - {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213}, - {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181}, - {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245}, - {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205}, - {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173}, - {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237}, - {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157}, - {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221}, - {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189}, - {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253}, - {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, - {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195}, - {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163}, - {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227}, - {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147}, - {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211}, - {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179}, - {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243}, - {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, - {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203}, - {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171}, - {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235}, - {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155}, - {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219}, - {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187}, - {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251}, - {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, - {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199}, - {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167}, - {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231}, - {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151}, - {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215}, - {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183}, - {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247}, - {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207}, - {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175}, - {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239}, - {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159}, - {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223}, - {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191}, - {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255} - }; -local inflate_huft fixed_td[] = { - {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097}, - {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385}, - {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193}, - {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577}, - {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145}, - {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577}, - {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289}, - {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577} - }; diff --git a/freeimage241/Source/ZLib/inflate.c b/freeimage241/Source/ZLib/inflate.c deleted file mode 100644 index 32e9b8d..0000000 --- a/freeimage241/Source/ZLib/inflate.c +++ /dev/null @@ -1,366 +0,0 @@ -/* inflate.c -- zlib interface to inflate modules - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infblock.h" - -struct inflate_blocks_state {int dummy;}; /* for buggy compilers */ - -typedef enum { - METHOD, /* waiting for method byte */ - FLAG, /* waiting for flag byte */ - DICT4, /* four dictionary check bytes to go */ - DICT3, /* three dictionary check bytes to go */ - DICT2, /* two dictionary check bytes to go */ - DICT1, /* one dictionary check byte to go */ - DICT0, /* waiting for inflateSetDictionary */ - BLOCKS, /* decompressing blocks */ - CHECK4, /* four check bytes to go */ - CHECK3, /* three check bytes to go */ - CHECK2, /* two check bytes to go */ - CHECK1, /* one check byte to go */ - DONE, /* finished check, done */ - BAD} /* got an error--stay here */ -inflate_mode; - -/* inflate private state */ -struct internal_state { - - /* mode */ - inflate_mode mode; /* current inflate mode */ - - /* mode dependent information */ - union { - uInt method; /* if FLAGS, method byte */ - struct { - uLong was; /* computed check value */ - uLong need; /* stream check value */ - } check; /* if CHECK, check values to compare */ - uInt marker; /* if BAD, inflateSync's marker bytes count */ - } sub; /* submode */ - - /* mode independent information */ - int nowrap; /* flag for no wrapper */ - uInt wbits; /* log2(window size) (8..15, defaults to 15) */ - inflate_blocks_statef - *blocks; /* current inflate_blocks state */ - -}; - - -int ZEXPORT inflateReset(z) -z_streamp z; -{ - if (z == Z_NULL || z->state == Z_NULL) - return Z_STREAM_ERROR; - z->total_in = z->total_out = 0; - z->msg = Z_NULL; - z->state->mode = z->state->nowrap ? BLOCKS : METHOD; - inflate_blocks_reset(z->state->blocks, z, Z_NULL); - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - - -int ZEXPORT inflateEnd(z) -z_streamp z; -{ - if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) - return Z_STREAM_ERROR; - if (z->state->blocks != Z_NULL) - inflate_blocks_free(z->state->blocks, z); - ZFREE(z, z->state); - z->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - - -int ZEXPORT inflateInit2_(z, w, version, stream_size) -z_streamp z; -int w; -const char *version; -int stream_size; -{ - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != sizeof(z_stream)) - return Z_VERSION_ERROR; - - /* initialize state */ - if (z == Z_NULL) - return Z_STREAM_ERROR; - z->msg = Z_NULL; - if (z->zalloc == Z_NULL) - { - z->zalloc = zcalloc; - z->opaque = (voidpf)0; - } - if (z->zfree == Z_NULL) z->zfree = zcfree; - if ((z->state = (struct internal_state FAR *) - ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL) - return Z_MEM_ERROR; - z->state->blocks = Z_NULL; - - /* handle undocumented nowrap option (no zlib header or check) */ - z->state->nowrap = 0; - if (w < 0) - { - w = - w; - z->state->nowrap = 1; - } - - /* set window size */ - if (w < 8 || w > 15) - { - inflateEnd(z); - return Z_STREAM_ERROR; - } - z->state->wbits = (uInt)w; - - /* create inflate_blocks state */ - if ((z->state->blocks = - inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w)) - == Z_NULL) - { - inflateEnd(z); - return Z_MEM_ERROR; - } - Tracev((stderr, "inflate: allocated\n")); - - /* reset state */ - inflateReset(z); - return Z_OK; -} - - -int ZEXPORT inflateInit_(z, version, stream_size) -z_streamp z; -const char *version; -int stream_size; -{ - return inflateInit2_(z, DEF_WBITS, version, stream_size); -} - - -#define NEEDBYTE {if(z->avail_in==0)return r;r=f;} -#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) - -int ZEXPORT inflate(z, f) -z_streamp z; -int f; -{ - int r; - uInt b; - - if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL) - return Z_STREAM_ERROR; - f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; - r = Z_BUF_ERROR; - while (1) switch (z->state->mode) - { - case METHOD: - NEEDBYTE - if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED) - { - z->state->mode = BAD; - z->msg = (char*)"unknown compression method"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - if ((z->state->sub.method >> 4) + 8 > z->state->wbits) - { - z->state->mode = BAD; - z->msg = (char*)"invalid window size"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - z->state->mode = FLAG; - case FLAG: - NEEDBYTE - b = NEXTBYTE; - if (((z->state->sub.method << 8) + b) % 31) - { - z->state->mode = BAD; - z->msg = (char*)"incorrect header check"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - Tracev((stderr, "inflate: zlib header ok\n")); - if (!(b & PRESET_DICT)) - { - z->state->mode = BLOCKS; - break; - } - z->state->mode = DICT4; - case DICT4: - NEEDBYTE - z->state->sub.check.need = (uLong)NEXTBYTE << 24; - z->state->mode = DICT3; - case DICT3: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 16; - z->state->mode = DICT2; - case DICT2: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 8; - z->state->mode = DICT1; - case DICT1: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE; - z->adler = z->state->sub.check.need; - z->state->mode = DICT0; - return Z_NEED_DICT; - case DICT0: - z->state->mode = BAD; - z->msg = (char*)"need dictionary"; - z->state->sub.marker = 0; /* can try inflateSync */ - return Z_STREAM_ERROR; - case BLOCKS: - r = inflate_blocks(z->state->blocks, z, r); - if (r == Z_DATA_ERROR) - { - z->state->mode = BAD; - z->state->sub.marker = 0; /* can try inflateSync */ - break; - } - if (r == Z_OK) - r = f; - if (r != Z_STREAM_END) - return r; - r = f; - inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); - if (z->state->nowrap) - { - z->state->mode = DONE; - break; - } - z->state->mode = CHECK4; - case CHECK4: - NEEDBYTE - z->state->sub.check.need = (uLong)NEXTBYTE << 24; - z->state->mode = CHECK3; - case CHECK3: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 16; - z->state->mode = CHECK2; - case CHECK2: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 8; - z->state->mode = CHECK1; - case CHECK1: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE; - - if (z->state->sub.check.was != z->state->sub.check.need) - { - z->state->mode = BAD; - z->msg = (char*)"incorrect data check"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - Tracev((stderr, "inflate: zlib check ok\n")); - z->state->mode = DONE; - case DONE: - return Z_STREAM_END; - case BAD: - return Z_DATA_ERROR; - default: - return Z_STREAM_ERROR; - } -#ifdef NEED_DUMMY_RETURN - return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ -#endif -} - - -int ZEXPORT inflateSetDictionary(z, dictionary, dictLength) -z_streamp z; -const Bytef *dictionary; -uInt dictLength; -{ - uInt length = dictLength; - - if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0) - return Z_STREAM_ERROR; - - if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR; - z->adler = 1L; - - if (length >= ((uInt)1<state->wbits)) - { - length = (1<state->wbits)-1; - dictionary += dictLength - length; - } - inflate_set_dictionary(z->state->blocks, dictionary, length); - z->state->mode = BLOCKS; - return Z_OK; -} - - -int ZEXPORT inflateSync(z) -z_streamp z; -{ - uInt n; /* number of bytes to look at */ - Bytef *p; /* pointer to bytes */ - uInt m; /* number of marker bytes found in a row */ - uLong r, w; /* temporaries to save total_in and total_out */ - - /* set up */ - if (z == Z_NULL || z->state == Z_NULL) - return Z_STREAM_ERROR; - if (z->state->mode != BAD) - { - z->state->mode = BAD; - z->state->sub.marker = 0; - } - if ((n = z->avail_in) == 0) - return Z_BUF_ERROR; - p = z->next_in; - m = z->state->sub.marker; - - /* search */ - while (n && m < 4) - { - static const Byte mark[4] = {0, 0, 0xff, 0xff}; - if (*p == mark[m]) - m++; - else if (*p) - m = 0; - else - m = 4 - m; - p++, n--; - } - - /* restore */ - z->total_in += p - z->next_in; - z->next_in = p; - z->avail_in = n; - z->state->sub.marker = m; - - /* return no joy or set up to restart on a new block */ - if (m != 4) - return Z_DATA_ERROR; - r = z->total_in; w = z->total_out; - inflateReset(z); - z->total_in = r; z->total_out = w; - z->state->mode = BLOCKS; - return Z_OK; -} - - -/* Returns true if inflate is currently at the end of a block generated - * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH - * but removes the length bytes of the resulting empty stored block. When - * decompressing, PPP checks that at the end of input packet, inflate is - * waiting for these length bytes. - */ -int ZEXPORT inflateSyncPoint(z) -z_streamp z; -{ - if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL) - return Z_STREAM_ERROR; - return inflate_blocks_sync_point(z->state->blocks); -} diff --git a/freeimage241/Source/ZLib/inftrees.c b/freeimage241/Source/ZLib/inftrees.c deleted file mode 100644 index ef1e0b6..0000000 --- a/freeimage241/Source/ZLib/inftrees.c +++ /dev/null @@ -1,455 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" - -#if !defined(BUILDFIXED) && !defined(STDC) -# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */ -#endif - -const char inflate_copyright[] = - " inflate 1.1.3 Copyright 1995-1998 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ -struct internal_state {int dummy;}; /* for buggy compilers */ - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - - -local int huft_build OF(( - uIntf *, /* code lengths in bits */ - uInt, /* number of codes */ - uInt, /* number of "simple" codes */ - const uIntf *, /* list of base values for non-simple codes */ - const uIntf *, /* list of extra bits for non-simple codes */ - inflate_huft * FAR*,/* result: starting table */ - uIntf *, /* maximum lookup bits (returns actual) */ - inflate_huft *, /* space for trees */ - uInt *, /* hufts used in space */ - uIntf * )); /* space for values */ - -/* Tables for deflate from PKZIP's appnote.txt. */ -local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - /* see note #13 above about 258 */ -local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */ -local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577}; -local const uInt cpdext[30] = { /* Extra bits for distance codes */ - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, - 12, 12, 13, 13}; - -/* - Huffman code decoding is performed using a multi-level table lookup. - The fastest way to decode is to simply build a lookup table whose - size is determined by the longest code. However, the time it takes - to build this table can also be a factor if the data being decoded - is not very long. The most common codes are necessarily the - shortest codes, so those codes dominate the decoding time, and hence - the speed. The idea is you can have a shorter table that decodes the - shorter, more probable codes, and then point to subsidiary tables for - the longer codes. The time it costs to decode the longer codes is - then traded against the time it takes to make longer tables. - - This results of this trade are in the variables lbits and dbits - below. lbits is the number of bits the first level table for literal/ - length codes can decode in one step, and dbits is the same thing for - the distance codes. Subsequent tables are also less than or equal to - those sizes. These values may be adjusted either when all of the - codes are shorter than that, in which case the longest code length in - bits is used, or when the shortest code is *longer* than the requested - table size, in which case the length of the shortest code in bits is - used. - - There are two different values for the two tables, since they code a - different number of possibilities each. The literal/length table - codes 286 possible values, or in a flat code, a little over eight - bits. The distance table codes 30 possible values, or a little less - than five bits, flat. The optimum values for speed end up being - about one bit more than those, so lbits is 8+1 and dbits is 5+1. - The optimum values may differ though from machine to machine, and - possibly even between compilers. Your mileage may vary. - */ - - -/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */ -#define BMAX 15 /* maximum bit length of any code */ - -local int huft_build(b, n, s, d, e, t, m, hp, hn, v) -uIntf *b; /* code lengths in bits (all assumed <= BMAX) */ -uInt n; /* number of codes (assumed <= 288) */ -uInt s; /* number of simple-valued codes (0..s-1) */ -const uIntf *d; /* list of base values for non-simple codes */ -const uIntf *e; /* list of extra bits for non-simple codes */ -inflate_huft * FAR *t; /* result: starting table */ -uIntf *m; /* maximum lookup bits, returns actual */ -inflate_huft *hp; /* space for trees */ -uInt *hn; /* hufts used in space */ -uIntf *v; /* working area: values in order of bit length */ -/* Given a list of code lengths and a maximum table size, make a set of - tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR - if the given code set is incomplete (the tables are still built in this - case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of - lengths), or Z_MEM_ERROR if not enough memory. */ -{ - - uInt a; /* counter for codes of length k */ - uInt c[BMAX+1]; /* bit length count table */ - uInt f; /* i repeats in table every f entries */ - int g; /* maximum code length */ - int h; /* table level */ - register uInt i; /* counter, current code */ - register uInt j; /* counter */ - register int k; /* number of bits in current code */ - int l; /* bits per table (returned in m) */ - uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */ - register uIntf *p; /* pointer into c[], b[], or v[] */ - inflate_huft *q; /* points to current table */ - struct inflate_huft_s r; /* table entry for structure assignment */ - inflate_huft *u[BMAX]; /* table stack */ - register int w; /* bits before this table == (l * h) */ - uInt x[BMAX+1]; /* bit offsets, then code stack */ - uIntf *xp; /* pointer into x */ - int y; /* number of dummy codes added */ - uInt z; /* number of entries in current table */ - - - /* Generate counts for each bit length */ - p = c; -#define C0 *p++ = 0; -#define C2 C0 C0 C0 C0 -#define C4 C2 C2 C2 C2 - C4 /* clear c[]--assume BMAX+1 is 16 */ - p = b; i = n; - do { - c[*p++]++; /* assume all entries <= BMAX */ - } while (--i); - if (c[0] == n) /* null input--all zero length codes */ - { - *t = (inflate_huft *)Z_NULL; - *m = 0; - return Z_OK; - } - - - /* Find minimum and maximum length, bound *m by those */ - l = *m; - for (j = 1; j <= BMAX; j++) - if (c[j]) - break; - k = j; /* minimum code length */ - if ((uInt)l < j) - l = j; - for (i = BMAX; i; i--) - if (c[i]) - break; - g = i; /* maximum code length */ - if ((uInt)l > i) - l = i; - *m = l; - - - /* Adjust last length count to fill out codes, if needed */ - for (y = 1 << j; j < i; j++, y <<= 1) - if ((y -= c[j]) < 0) - return Z_DATA_ERROR; - if ((y -= c[i]) < 0) - return Z_DATA_ERROR; - c[i] += y; - - - /* Generate starting offsets into the value table for each length */ - x[1] = j = 0; - p = c + 1; xp = x + 2; - while (--i) { /* note that i == g from above */ - *xp++ = (j += *p++); - } - - - /* Make a table of values in order of bit lengths */ - p = b; i = 0; - do { - if ((j = *p++) != 0) - v[x[j]++] = i; - } while (++i < n); - n = x[g]; /* set n to length of v */ - - - /* Generate the Huffman codes and for each, make the table entries */ - x[0] = i = 0; /* first Huffman code is zero */ - p = v; /* grab values in bit order */ - h = -1; /* no tables yet--level -1 */ - w = -l; /* bits decoded == (l * h) */ - u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ - q = (inflate_huft *)Z_NULL; /* ditto */ - z = 0; /* ditto */ - - /* go through the bit lengths (k already is bits in shortest code) */ - for (; k <= g; k++) - { - a = c[k]; - while (a--) - { - /* here i is the Huffman code of length k bits for value *p */ - /* make tables up to required level */ - while (k > w + l) - { - h++; - w += l; /* previous table always l bits */ - - /* compute minimum size table less than or equal to l bits */ - z = g - w; - z = z > (uInt)l ? l : z; /* table size upper limit */ - if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ - { /* too few codes for k-w bit table */ - f -= a + 1; /* deduct codes from patterns left */ - xp = c + k; - if (j < z) - while (++j < z) /* try smaller tables up to z bits */ - { - if ((f <<= 1) <= *++xp) - break; /* enough codes to use up j bits */ - f -= *xp; /* else deduct codes from patterns */ - } - } - z = 1 << j; /* table entries for j-bit table */ - - /* allocate new table */ - if (*hn + z > MANY) /* (note: doesn't matter for fixed) */ - return Z_MEM_ERROR; /* not enough memory */ - u[h] = q = hp + *hn; - *hn += z; - - /* connect to last table, if there is one */ - if (h) - { - x[h] = i; /* save pattern for backing up */ - r.bits = (Byte)l; /* bits to dump before this table */ - r.exop = (Byte)j; /* bits in this table */ - j = i >> (w - l); - r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ - u[h-1][j] = r; /* connect to last table */ - } - else - *t = q; /* first table is returned result */ - } - - /* set up table entry in r */ - r.bits = (Byte)(k - w); - if (p >= v + n) - r.exop = 128 + 64; /* out of values--invalid code */ - else if (*p < s) - { - r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ - r.base = *p++; /* simple code is just the value */ - } - else - { - r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ - r.base = d[*p++ - s]; - } - - /* fill code-like entries with r */ - f = 1 << (k - w); - for (j = i >> w; j < z; j += f) - q[j] = r; - - /* backwards increment the k-bit code i */ - for (j = 1 << (k - 1); i & j; j >>= 1) - i ^= j; - i ^= j; - - /* backup over finished tables */ - mask = (1 << w) - 1; /* needed on HP, cc -O bug */ - while ((i & mask) != x[h]) - { - h--; /* don't need to update q */ - w -= l; - mask = (1 << w) - 1; - } - } - } - - - /* Return Z_BUF_ERROR if we were given an incomplete table */ - return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; -} - - -int inflate_trees_bits(c, bb, tb, hp, z) -uIntf *c; /* 19 code lengths */ -uIntf *bb; /* bits tree desired/actual depth */ -inflate_huft * FAR *tb; /* bits tree result */ -inflate_huft *hp; /* space for trees */ -z_streamp z; /* for messages */ -{ - int r; - uInt hn = 0; /* hufts used in space */ - uIntf *v; /* work area for huft_build */ - - if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL) - return Z_MEM_ERROR; - r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, - tb, bb, hp, &hn, v); - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed dynamic bit lengths tree"; - else if (r == Z_BUF_ERROR || *bb == 0) - { - z->msg = (char*)"incomplete dynamic bit lengths tree"; - r = Z_DATA_ERROR; - } - ZFREE(z, v); - return r; -} - - -int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp, z) -uInt nl; /* number of literal/length codes */ -uInt nd; /* number of distance codes */ -uIntf *c; /* that many (total) code lengths */ -uIntf *bl; /* literal desired/actual bit depth */ -uIntf *bd; /* distance desired/actual bit depth */ -inflate_huft * FAR *tl; /* literal/length tree result */ -inflate_huft * FAR *td; /* distance tree result */ -inflate_huft *hp; /* space for trees */ -z_streamp z; /* for messages */ -{ - int r; - uInt hn = 0; /* hufts used in space */ - uIntf *v; /* work area for huft_build */ - - /* allocate work area */ - if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) - return Z_MEM_ERROR; - - /* build literal/length tree */ - r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v); - if (r != Z_OK || *bl == 0) - { - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed literal/length tree"; - else if (r != Z_MEM_ERROR) - { - z->msg = (char*)"incomplete literal/length tree"; - r = Z_DATA_ERROR; - } - ZFREE(z, v); - return r; - } - - /* build distance tree */ - r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v); - if (r != Z_OK || (*bd == 0 && nl > 257)) - { - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed distance tree"; - else if (r == Z_BUF_ERROR) { -#ifdef PKZIP_BUG_WORKAROUND - r = Z_OK; - } -#else - z->msg = (char*)"incomplete distance tree"; - r = Z_DATA_ERROR; - } - else if (r != Z_MEM_ERROR) - { - z->msg = (char*)"empty distance tree with lengths"; - r = Z_DATA_ERROR; - } - ZFREE(z, v); - return r; -#endif - } - - /* done */ - ZFREE(z, v); - return Z_OK; -} - - -/* build fixed tables only once--keep them here */ -#ifdef BUILDFIXED -local int fixed_built = 0; -#define FIXEDH 544 /* number of hufts used by fixed tables */ -local inflate_huft fixed_mem[FIXEDH]; -local uInt fixed_bl; -local uInt fixed_bd; -local inflate_huft *fixed_tl; -local inflate_huft *fixed_td; -#else -#include "inffixed.h" -#endif - - -int inflate_trees_fixed(bl, bd, tl, td, z) -uIntf *bl; /* literal desired/actual bit depth */ -uIntf *bd; /* distance desired/actual bit depth */ -inflate_huft * FAR *tl; /* literal/length tree result */ -inflate_huft * FAR *td; /* distance tree result */ -z_streamp z; /* for memory allocation */ -{ -#ifdef BUILDFIXED - /* build fixed tables if not already */ - if (!fixed_built) - { - int k; /* temporary variable */ - uInt f = 0; /* number of hufts used in fixed_mem */ - uIntf *c; /* length list for huft_build */ - uIntf *v; /* work area for huft_build */ - - /* allocate memory */ - if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) - return Z_MEM_ERROR; - if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) - { - ZFREE(z, c); - return Z_MEM_ERROR; - } - - /* literal table */ - for (k = 0; k < 144; k++) - c[k] = 8; - for (; k < 256; k++) - c[k] = 9; - for (; k < 280; k++) - c[k] = 7; - for (; k < 288; k++) - c[k] = 8; - fixed_bl = 9; - huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, - fixed_mem, &f, v); - - /* distance table */ - for (k = 0; k < 30; k++) - c[k] = 5; - fixed_bd = 5; - huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, - fixed_mem, &f, v); - - /* done */ - ZFREE(z, v); - ZFREE(z, c); - fixed_built = 1; - } -#endif - *bl = fixed_bl; - *bd = fixed_bd; - *tl = fixed_tl; - *td = fixed_td; - return Z_OK; -} diff --git a/freeimage241/Source/ZLib/inftrees.h b/freeimage241/Source/ZLib/inftrees.h deleted file mode 100644 index 85853e0..0000000 --- a/freeimage241/Source/ZLib/inftrees.h +++ /dev/null @@ -1,58 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Huffman code lookup table entry--this entry is four bytes for machines - that have 16-bit pointers (e.g. PC's in the small or medium model). */ - -typedef struct inflate_huft_s FAR inflate_huft; - -struct inflate_huft_s { - union { - struct { - Byte Exop; /* number of extra bits or operation */ - Byte Bits; /* number of bits in this code or subcode */ - } what; - uInt pad; /* pad structure to a power of 2 (4 bytes for */ - } word; /* 16-bit, 8 bytes for 32-bit int's) */ - uInt base; /* literal, length base, distance base, - or table offset */ -}; - -/* Maximum size of dynamic tree. The maximum found in a long but non- - exhaustive search was 1004 huft structures (850 for length/literals - and 154 for distances, the latter actually the result of an - exhaustive search). The actual maximum is not known, but the - value below is more than safe. */ -#define MANY 1440 - -extern int inflate_trees_bits OF(( - uIntf *, /* 19 code lengths */ - uIntf *, /* bits tree desired/actual depth */ - inflate_huft * FAR *, /* bits tree result */ - inflate_huft *, /* space for trees */ - z_streamp)); /* for messages */ - -extern int inflate_trees_dynamic OF(( - uInt, /* number of literal/length codes */ - uInt, /* number of distance codes */ - uIntf *, /* that many (total) code lengths */ - uIntf *, /* literal desired/actual bit depth */ - uIntf *, /* distance desired/actual bit depth */ - inflate_huft * FAR *, /* literal/length tree result */ - inflate_huft * FAR *, /* distance tree result */ - inflate_huft *, /* space for trees */ - z_streamp)); /* for messages */ - -extern int inflate_trees_fixed OF(( - uIntf *, /* literal desired/actual bit depth */ - uIntf *, /* distance desired/actual bit depth */ - inflate_huft * FAR *, /* literal/length tree result */ - inflate_huft * FAR *, /* distance tree result */ - z_streamp)); /* for memory allocation */ diff --git a/freeimage241/Source/ZLib/infutil.c b/freeimage241/Source/ZLib/infutil.c deleted file mode 100644 index 824dab5..0000000 --- a/freeimage241/Source/ZLib/infutil.c +++ /dev/null @@ -1,87 +0,0 @@ -/* inflate_util.c -- data and routines common to blocks and codes - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infblock.h" -#include "inftrees.h" -#include "infcodes.h" -#include "infutil.h" - -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ - -/* And'ing with mask[n] masks the lower n bits */ -uInt inflate_mask[17] = { - 0x0000, - 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff -}; - - -/* copy as much as possible from the sliding window to the output area */ -int inflate_flush(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt n; - Bytef *p; - Bytef *q; - - /* local copies of source and destination pointers */ - p = z->next_out; - q = s->read; - - /* compute number of bytes to copy as far as end of window */ - n = (uInt)((q <= s->write ? s->write : s->end) - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy as far as end of window */ - zmemcpy(p, q, n); - p += n; - q += n; - - /* see if more to copy at beginning of window */ - if (q == s->end) - { - /* wrap pointers */ - q = s->window; - if (s->write == s->end) - s->write = s->window; - - /* compute bytes to copy */ - n = (uInt)(s->write - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy */ - zmemcpy(p, q, n); - p += n; - q += n; - } - - /* update pointers */ - z->next_out = p; - s->read = q; - - /* done */ - return r; -} diff --git a/freeimage241/Source/ZLib/infutil.h b/freeimage241/Source/ZLib/infutil.h deleted file mode 100644 index 99d1135..0000000 --- a/freeimage241/Source/ZLib/infutil.h +++ /dev/null @@ -1,98 +0,0 @@ -/* infutil.h -- types and macros common to blocks and codes - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -#ifndef _INFUTIL_H -#define _INFUTIL_H - -typedef enum { - TYPE, /* get type bits (3, including end bit) */ - LENS, /* get lengths for stored */ - STORED, /* processing stored block */ - TABLE, /* get table lengths */ - BTREE, /* get bit lengths tree for a dynamic block */ - DTREE, /* get length, distance trees for a dynamic block */ - CODES, /* processing fixed or dynamic block */ - DRY, /* output remaining window bytes */ - DONE, /* finished last block, done */ - BAD} /* got a data error--stuck here */ -inflate_block_mode; - -/* inflate blocks semi-private state */ -struct inflate_blocks_state { - - /* mode */ - inflate_block_mode mode; /* current inflate_block mode */ - - /* mode dependent information */ - union { - uInt left; /* if STORED, bytes left to copy */ - struct { - uInt table; /* table lengths (14 bits) */ - uInt index; /* index into blens (or border) */ - uIntf *blens; /* bit lengths of codes */ - uInt bb; /* bit length tree depth */ - inflate_huft *tb; /* bit length decoding tree */ - } trees; /* if DTREE, decoding info for trees */ - struct { - inflate_codes_statef - *codes; - } decode; /* if CODES, current state */ - } sub; /* submode */ - uInt last; /* true if this block is the last block */ - - /* mode independent information */ - uInt bitk; /* bits in bit buffer */ - uLong bitb; /* bit buffer */ - inflate_huft *hufts; /* single malloc for tree space */ - Bytef *window; /* sliding window */ - Bytef *end; /* one byte after sliding window */ - Bytef *read; /* window read pointer */ - Bytef *write; /* window write pointer */ - check_func checkfn; /* check function */ - uLong check; /* check on output */ - -}; - - -/* defines for inflate input/output */ -/* update pointers and return */ -#define UPDBITS {s->bitb=b;s->bitk=k;} -#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} -#define UPDOUT {s->write=q;} -#define UPDATE {UPDBITS UPDIN UPDOUT} -#define LEAVE {UPDATE return inflate_flush(s,z,r);} -/* get bytes and bits */ -#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} -#define NEEDBYTE {if(n)r=Z_OK;else LEAVE} -#define NEXTBYTE (n--,*p++) -#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<>=(j);k-=(j);} -/* output bytes */ -#define WAVAIL (uInt)(qread?s->read-q-1:s->end-q) -#define LOADOUT {q=s->write;m=(uInt)WAVAIL;} -#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} -#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} -#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} -#define OUTBYTE(a) {*q++=(Byte)(a);m--;} -/* load local pointers */ -#define LOAD {LOADIN LOADOUT} - -/* masks for lower bits (size given to avoid silly warnings with Visual C++) */ -extern uInt inflate_mask[17]; - -/* copy as much as possible from the sliding window to the output area */ -extern int inflate_flush OF(( - inflate_blocks_statef *, - z_streamp , - int)); - -struct internal_state {int dummy;}; /* for buggy compilers */ - -#endif diff --git a/freeimage241/Source/ZLib/maketree.c b/freeimage241/Source/ZLib/maketree.c deleted file mode 100644 index 949d786..0000000 --- a/freeimage241/Source/ZLib/maketree.c +++ /dev/null @@ -1,85 +0,0 @@ -/* maketree.c -- make inffixed.h table for decoding fixed codes - * Copyright (C) 1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* This program is included in the distribution for completeness. - You do not need to compile or run this program since inffixed.h - is already included in the distribution. To use this program - you need to compile zlib with BUILDFIXED defined and then compile - and link this program with the zlib library. Then the output of - this program can be piped to inffixed.h. */ - -#include -#include -#include "zutil.h" -#include "inftrees.h" - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -/* generate initialization table for an inflate_huft structure array */ -void maketree(uInt b, inflate_huft *t) -{ - int i, e; - - i = 0; - while (1) - { - e = t[i].exop; - if (e && (e & (16+64)) == 0) /* table pointer */ - { - fprintf(stderr, "maketree: cannot initialize sub-tables!\n"); - exit(1); - } - if (i % 4 == 0) - printf("\n "); - printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base); - if (++i == (1< -#include "zlib.h" - -#ifdef STDC -# include -# include -#else - extern void exit OF((int)); -#endif - -#ifdef USE_MMAP -# include -# include -# include -#endif - -#if defined(MSDOS) || defined(OS2) || defined(WIN32) -# include -# include -# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif - -#ifdef VMS -# define unlink delete -# define GZ_SUFFIX "-gz" -#endif -#ifdef RISCOS -# define unlink remove -# define GZ_SUFFIX "-gz" -# define fileno(file) file->__file -#endif -#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fileno */ -#endif - -#ifndef WIN32 /* unlink already in stdio.h for WIN32 */ - extern int unlink OF((const char *)); -#endif - -#ifndef GZ_SUFFIX -# define GZ_SUFFIX ".gz" -#endif -#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) - -#define BUFLEN 16384 -#define MAX_NAME_LEN 1024 - -#ifdef MAXSEG_64K -# define local static - /* Needed for systems with limitation on stack size. */ -#else -# define local -#endif - -char *prog; - -void error OF((const char *msg)); -void gz_compress OF((FILE *in, gzFile out)); -#ifdef USE_MMAP -int gz_compress_mmap OF((FILE *in, gzFile out)); -#endif -void gz_uncompress OF((gzFile in, FILE *out)); -void file_compress OF((char *file, char *mode)); -void file_uncompress OF((char *file)); -int main OF((int argc, char *argv[])); - -/* =========================================================================== - * Display error message and exit - */ -void error(msg) - const char *msg; -{ - fprintf(stderr, "%s: %s\n", prog, msg); - exit(1); -} - -/* =========================================================================== - * Compress input to output then close both files. - */ - -void gz_compress(in, out) - FILE *in; - gzFile out; -{ - local char buf[BUFLEN]; - int len; - int err; - -#ifdef USE_MMAP - /* Try first compressing with mmap. If mmap fails (minigzip used in a - * pipe), use the normal fread loop. - */ - if (gz_compress_mmap(in, out) == Z_OK) return; -#endif - for (;;) { - len = fread(buf, 1, sizeof(buf), in); - if (ferror(in)) { - perror("fread"); - exit(1); - } - if (len == 0) break; - - if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); - } - fclose(in); - if (gzclose(out) != Z_OK) error("failed gzclose"); -} - -#ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ - -/* Try compressing the input file at once using mmap. Return Z_OK if - * if success, Z_ERRNO otherwise. - */ -int gz_compress_mmap(in, out) - FILE *in; - gzFile out; -{ - int len; - int err; - int ifd = fileno(in); - caddr_t buf; /* mmap'ed buffer for the entire input file */ - off_t buf_len; /* length of the input file */ - struct stat sb; - - /* Determine the size of the file, needed for mmap: */ - if (fstat(ifd, &sb) < 0) return Z_ERRNO; - buf_len = sb.st_size; - if (buf_len <= 0) return Z_ERRNO; - - /* Now do the actual mmap: */ - buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); - if (buf == (caddr_t)(-1)) return Z_ERRNO; - - /* Compress the whole file at once: */ - len = gzwrite(out, (char *)buf, (unsigned)buf_len); - - if (len != (int)buf_len) error(gzerror(out, &err)); - - munmap(buf, buf_len); - fclose(in); - if (gzclose(out) != Z_OK) error("failed gzclose"); - return Z_OK; -} -#endif /* USE_MMAP */ - -/* =========================================================================== - * Uncompress input to output then close both files. - */ -void gz_uncompress(in, out) - gzFile in; - FILE *out; -{ - local char buf[BUFLEN]; - int len; - int err; - - for (;;) { - len = gzread(in, buf, sizeof(buf)); - if (len < 0) error (gzerror(in, &err)); - if (len == 0) break; - - if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { - error("failed fwrite"); - } - } - if (fclose(out)) error("failed fclose"); - - if (gzclose(in) != Z_OK) error("failed gzclose"); -} - - -/* =========================================================================== - * Compress the given file: create a corresponding .gz file and remove the - * original. - */ -void file_compress(file, mode) - char *file; - char *mode; -{ - local char outfile[MAX_NAME_LEN]; - FILE *in; - gzFile out; - - strcpy(outfile, file); - strcat(outfile, GZ_SUFFIX); - - in = fopen(file, "rb"); - if (in == NULL) { - perror(file); - exit(1); - } - out = gzopen(outfile, mode); - if (out == NULL) { - fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); - exit(1); - } - gz_compress(in, out); - - unlink(file); -} - - -/* =========================================================================== - * Uncompress the given file and remove the original. - */ -void file_uncompress(file) - char *file; -{ - local char buf[MAX_NAME_LEN]; - char *infile, *outfile; - FILE *out; - gzFile in; - int len = strlen(file); - - strcpy(buf, file); - - if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) { - infile = file; - outfile = buf; - outfile[len-3] = '\0'; - } else { - outfile = file; - infile = buf; - strcat(infile, GZ_SUFFIX); - } - in = gzopen(infile, "rb"); - if (in == NULL) { - fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); - exit(1); - } - out = fopen(outfile, "wb"); - if (out == NULL) { - perror(file); - exit(1); - } - - gz_uncompress(in, out); - - unlink(infile); -} - - -/* =========================================================================== - * Usage: minigzip [-d] [-f] [-h] [-1 to -9] [files...] - * -d : decompress - * -f : compress with Z_FILTERED - * -h : compress with Z_HUFFMAN_ONLY - * -1 to -9 : compression level - */ - -int main(argc, argv) - int argc; - char *argv[]; -{ - int uncompr = 0; - gzFile file; - char outmode[20]; - - strcpy(outmode, "wb6 "); - - prog = argv[0]; - argc--, argv++; - - while (argc > 0) { - if (strcmp(*argv, "-d") == 0) - uncompr = 1; - else if (strcmp(*argv, "-f") == 0) - outmode[3] = 'f'; - else if (strcmp(*argv, "-h") == 0) - outmode[3] = 'h'; - else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' && - (*argv)[2] == 0) - outmode[2] = (*argv)[1]; - else - break; - argc--, argv++; - } - if (argc == 0) { - SET_BINARY_MODE(stdin); - SET_BINARY_MODE(stdout); - if (uncompr) { - file = gzdopen(fileno(stdin), "rb"); - if (file == NULL) error("can't gzdopen stdin"); - gz_uncompress(file, stdout); - } else { - file = gzdopen(fileno(stdout), outmode); - if (file == NULL) error("can't gzdopen stdout"); - gz_compress(stdin, file); - } - } else { - do { - if (uncompr) { - file_uncompress(*argv); - } else { - file_compress(*argv, outmode); - } - } while (argv++, --argc); - } - exit(0); - return 0; /* to avoid warning */ -} diff --git a/freeimage241/Source/ZLib/mssccprj.scc b/freeimage241/Source/ZLib/mssccprj.scc deleted file mode 100644 index c2433a7..0000000 --- a/freeimage241/Source/ZLib/mssccprj.scc +++ /dev/null @@ -1,5 +0,0 @@ -SCC = This is a Source Code Control file - -[ZLib.dsp] -SCC_Aux_Path = "\\ASIMOV\Magenta\SourceSafe" -SCC_Project_Name = "$/FreeImage/ZLib", KNAAAAAA diff --git a/freeimage241/Source/ZLib/trees.c b/freeimage241/Source/ZLib/trees.c deleted file mode 100644 index 688462f..0000000 --- a/freeimage241/Source/ZLib/trees.c +++ /dev/null @@ -1,1214 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-1998 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in a compressed form which is itself - * a Huffman encoding of the lengths of all the code strings (in - * ascending order by source values). The actual code strings are - * reconstructed from the lengths in the inflate process, as described - * in the deflate specification. - * - * REFERENCES - * - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - */ - -/* @(#) $Id: trees.c,v 1.0 2001-04-13 00:42:49+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -/* #define GEN_TREES_H */ - -#include "deflate.h" - -#ifdef DEBUG -# include -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local const int extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -local const uch bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -#define Buf_size (8 * 2*sizeof(char)) -/* Number of bits used within bi_buf. (bi_buf might be implemented on - * more than 16 bits on some systems.) - */ - -/* =========================================================================== - * Local data. These are initialized only once. - */ - -#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ - -#if defined(GEN_TREES_H) || !defined(STDC) -/* non ANSI compilers may not accept trees.h */ - -local ct_data static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init - * below). - */ - -local ct_data static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -uch _dist_code[DIST_CODE_LEN]; -/* Distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -uch _length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local int base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -#else -# include "trees.h" -#endif /* GEN_TREES_H */ - -struct static_tree_desc_s { - const ct_data *static_tree; /* static tree or NULL */ - const intf *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ -}; - -local static_tree_desc static_l_desc = -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; - -local static_tree_desc static_d_desc = -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; - -local static_tree_desc static_bl_desc = -{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, ct_data *ltree, - ct_data *dtree)); -local void set_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned value, int length)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); -local void copy_block OF((deflate_state *s, charf *buf, unsigned len, - int header)); - -#ifdef GEN_TREES_H -local void gen_trees_header OF((void)); -#endif - -#ifndef DEBUG -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* DEBUG */ -# define send_code(s, c, tree) \ - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(s, tree[c].Code, tree[c].Len); } -#endif - -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -#ifdef DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - Tracevv((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; - - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (s->bi_valid > (int)Buf_size - length) { - s->bi_buf |= (value << s->bi_valid); - put_short(s, s->bi_buf); - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); - s->bi_valid += length - Buf_size; - } else { - s->bi_buf |= value << s->bi_valid; - s->bi_valid += length; - } -} -#else /* !DEBUG */ - -#define send_bits(s, value, length) \ -{ int len = length;\ - if (s->bi_valid > (int)Buf_size - len) {\ - int val = value;\ - s->bi_buf |= (val << s->bi_valid);\ - put_short(s, s->bi_buf);\ - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ - s->bi_valid += len - Buf_size;\ - } else {\ - s->bi_buf |= (value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* DEBUG */ - - -#define MAX(a,b) (a >= b ? a : b) -/* the arguments must not have side effects */ - -/* =========================================================================== - * Initialize the various 'constant' tables. - */ -local void tr_static_init() -{ -#if defined(GEN_TREES_H) || !defined(STDC) - static int static_init_done = 0; - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - if (static_init_done) return; - - /* For some embedded targets, global variables are not initialized: */ - static_l_desc.static_tree = static_ltree; - static_l_desc.extra_bits = extra_lbits; - static_d_desc.static_tree = static_dtree; - static_d_desc.extra_bits = extra_dbits; - static_bl_desc.extra_bits = extra_blbits; - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - _dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse((unsigned)n, 5); - } - static_init_done = 1; - -# ifdef GEN_TREES_H - gen_trees_header(); -# endif -#endif /* defined(GEN_TREES_H) || !defined(STDC) */ -} - -/* =========================================================================== - * Genererate the file trees.h describing the static trees. - */ -#ifdef GEN_TREES_H -# ifndef DEBUG -# include -# endif - -# define SEPARATOR(i, last, width) \ - ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) - -void gen_trees_header() -{ - FILE *header = fopen("trees.h", "w"); - int i; - - Assert (header != NULL, "Can't open trees.h"); - fprintf(header, - "/* header created automatically with -DGEN_TREES_H */\n\n"); - - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); - for (i = 0; i < L_CODES+2; i++) { - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); - } - - fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); - } - - fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); - for (i = 0; i < DIST_CODE_LEN; i++) { - fprintf(header, "%2u%s", _dist_code[i], - SEPARATOR(i, DIST_CODE_LEN-1, 20)); - } - - fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - fprintf(header, "%2u%s", _length_code[i], - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); - } - - fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); - for (i = 0; i < LENGTH_CODES; i++) { - fprintf(header, "%1u%s", base_length[i], - SEPARATOR(i, LENGTH_CODES-1, 20)); - } - - fprintf(header, "local const int base_dist[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "%5u%s", base_dist[i], - SEPARATOR(i, D_CODES-1, 10)); - } - - fclose(header); -} -#endif /* GEN_TREES_H */ - -/* =========================================================================== - * Initialize the tree data structures for a new zlib stream. - */ -void _tr_init(s) - deflate_state *s; -{ - tr_static_init(); - - s->l_desc.dyn_tree = s->dyn_ltree; - s->l_desc.stat_desc = &static_l_desc; - - s->d_desc.dyn_tree = s->dyn_dtree; - s->d_desc.stat_desc = &static_d_desc; - - s->bl_desc.dyn_tree = s->bl_tree; - s->bl_desc.stat_desc = &static_bl_desc; - - s->bi_buf = 0; - s->bi_valid = 0; - s->last_eob_len = 8; /* enough lookahead for inflate */ -#ifdef DEBUG - s->compressed_len = 0L; - s->bits_sent = 0L; -#endif - - /* Initialize the first block of the first file: */ - init_block(s); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->last_lit = s->matches = 0; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(s, tree, top) \ -{\ - top = s->heap[SMALLEST]; \ - s->heap[SMALLEST] = s->heap[s->heap_len--]; \ - pqdownheap(s, tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m, depth) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = s->heap[k]; - int j = k << 1; /* left son of k */ - while (j <= s->heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < s->heap_len && - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { - j++; - } - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, s->heap[j], s->depth)) break; - - /* Exchange v with the smallest son */ - s->heap[k] = s->heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - s->heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - ct_data *tree = desc->dyn_tree; - int max_code = desc->max_code; - const ct_data *stree = desc->stat_desc->static_tree; - const intf *extra = desc->stat_desc->extra_bits; - int base = desc->stat_desc->extra_base; - int max_length = desc->stat_desc->max_length; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - - for (h = s->heap_max+1; h < HEAP_SIZE; h++) { - n = s->heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - s->bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - s->opt_len += (ulg)f * (bits + xbits); - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); - } - if (overflow == 0) return; - - Trace((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ - s->bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = s->bl_count[bits]; - while (n != 0) { - m = s->heap[--h]; - if (m > max_code) continue; - if (tree[m].Len != (unsigned) bits) { - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s->opt_len += ((long)bits - (long)tree[m].Len) - *(long)tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; - const ct_data *stree = desc->stat_desc->static_tree; - int elems = desc->stat_desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node; /* new node being created */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - s->heap_len = 0, s->heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - s->heap[++(s->heap_len)] = max_code = n; - s->depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (s->heap_len < 2) { - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); - tree[node].Freq = 1; - s->depth[node] = 0; - s->opt_len--; if (stree) s->static_len -= stree[node].Len; - /* node is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - node = elems; /* next internal node of the tree */ - do { - pqremove(s, tree, n); /* n = node of least frequency */ - m = s->heap[SMALLEST]; /* m = node of next least frequency */ - - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ - s->heap[--(s->heap_max)] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - s->depth[node] = (uch) (MAX(s->depth[n], s->depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == s->bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - s->heap[SMALLEST] = node++; - pqdownheap(s, tree, SMALLEST); - - } while (s->heap_len >= 2); - - s->heap[--(s->heap_max)] = s->heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen(s, (tree_desc *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data *)tree, max_code, s->bl_count); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. - */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - s->bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) s->bl_tree[curlen].Freq++; - s->bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - s->bl_tree[REPZ_3_10].Freq++; - } else { - s->bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(s, curlen, s->bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(s, curlen, s->bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); - - } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); - - } else { - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree(s) - deflate_state *s; -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); - - /* Build the bit length tree: */ - build_tree(s, (tree_desc *)(&(s->bl_desc))); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*(max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", - s->opt_len, s->static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); -} - -/* =========================================================================== - * Send a stored block - */ -void _tr_stored_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ -#ifdef DEBUG - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; - s->compressed_len += (stored_len + 4) << 3; -#endif - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ -} - -/* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - * The current inflate code requires 9 bits of lookahead. If the - * last two codes for the previous block (real code plus EOB) were coded - * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode - * the last real code. In this case we send two empty static blocks instead - * of one. (There are no problems if the previous block is stored or fixed.) - * To simplify the code, we assume the worst case of last real code encoded - * on one bit only. - */ -void _tr_align(s) - deflate_state *s; -{ - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ -#endif - bi_flush(s); - /* Of the 10 bits for the empty block, we have already sent - * (10 - bi_valid) bits. The lookahead for the last real code (before - * the EOB of the previous block) was thus at least one plus the length - * of the EOB plus what we have just sent of the empty static block. - */ - if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; -#endif - bi_flush(s); - } - s->last_eob_len = 7; -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. - */ -void _tr_flush_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex = 0; /* index of last bit length code of non zero freq */ - - /* Build the Huffman trees unless a stored block is forced */ - if (s->level > 0) { - - /* Check if the file is ascii or binary */ - if (s->data_type == Z_UNKNOWN) set_data_type(s); - - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); - - /* Determine the best encoding. Compute first the block length in bytes*/ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; - - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - } else { - Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ - } - -#ifdef FORCE_STORED - if (buf != (char*)0) { /* force stored block */ -#else - if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - _tr_stored_block(s, buf, stored_len, eof); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+eof, 3); - compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->static_len; -#endif - } else { - send_bits(s, (DYN_TREES<<1)+eof, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); - compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->opt_len; -#endif - } - Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - /* The above check is made mod 2^32, for files larger than 512 MB - * and uLong implemented on 32 bits. - */ - init_block(s); - - if (eof) { - bi_windup(s); -#ifdef DEBUG - s->compressed_len += 7; /* align on byte boundary */ -#endif - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - s->compressed_len-7*eof)); -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - s->d_buf[s->last_lit] = (ush)dist; - s->l_buf[s->last_lit++] = (uch)lc; - if (dist == 0) { - /* lc is the unmatched char */ - s->dyn_ltree[lc].Freq++; - } else { - s->matches++; - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST(s) && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; - s->dyn_dtree[d_code(dist)].Freq++; - } - -#ifdef TRUNCATE_BLOCK - /* Try to guess if it is profitable to stop the current block here */ - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)s->last_lit*8L; - ulg in_length = (ulg)((long)s->strstart - s->block_start); - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * - (5L+extra_dbits[dcode]); - } - out_length >>= 3; - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - s->last_lit, in_length, out_length, - 100L - out_length*100L/in_length)); - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; - } -#endif - return (s->last_lit == s->lit_bufsize-1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - ct_data *ltree; /* literal tree */ - ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->last_lit != 0) do { - dist = s->d_buf[lx]; - lc = s->l_buf[lx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - Assert(s->pending < s->lit_bufsize + 2*lx, "pendingBuf overflow"); - - } while (lx < s->last_lit); - - send_code(s, END_BLOCK, ltree); - s->last_eob_len = ltree[END_BLOCK].Len; -} - -/* =========================================================================== - * Set the data type to ASCII or BINARY, using a crude approximation: - * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. - * IN assertion: the fields freq of dyn_ltree are set and the total of all - * frequencies does not exceed 64K (to fit in an int on 16 bit machines). - */ -local void set_data_type(s) - deflate_state *s; -{ - int n = 0; - unsigned ascii_freq = 0; - unsigned bin_freq = 0; - while (n < 7) bin_freq += s->dyn_ltree[n++].Freq; - while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq; - while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq; - s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII); -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef DEBUG - s->bits_sent = (s->bits_sent+7) & ~7; -#endif -} - -/* =========================================================================== - * Copy a stored block, storing first the length and its - * one's complement if requested. - */ -local void copy_block(s, buf, len, header) - deflate_state *s; - charf *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(s); /* align on byte boundary */ - s->last_eob_len = 8; /* enough lookahead for inflate */ - - if (header) { - put_short(s, (ush)len); - put_short(s, (ush)~len); -#ifdef DEBUG - s->bits_sent += 2*16; -#endif - } -#ifdef DEBUG - s->bits_sent += (ulg)len<<3; -#endif - while (len--) { - put_byte(s, *buf++); - } -} diff --git a/freeimage241/Source/ZLib/trees.h b/freeimage241/Source/ZLib/trees.h deleted file mode 100644 index 72facf9..0000000 --- a/freeimage241/Source/ZLib/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_TREES_H */ - -local const ct_data static_ltree[L_CODES+2] = { -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} -}; - -local const ct_data static_dtree[D_CODES] = { -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} -}; - -const uch _dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -local const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -local const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - diff --git a/freeimage241/Source/ZLib/uncompr.c b/freeimage241/Source/ZLib/uncompr.c deleted file mode 100644 index 42a17ee..0000000 --- a/freeimage241/Source/ZLib/uncompr.c +++ /dev/null @@ -1,58 +0,0 @@ -/* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-1998 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: uncompr.c,v 1.0 2001-04-13 00:42:49+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -#include "zlib.h" - -/* =========================================================================== - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. -*/ -int ZEXPORT uncompress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - z_stream stream; - int err; - - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - err = inflateInit(&stream); - if (err != Z_OK) return err; - - err = inflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - inflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = inflateEnd(&stream); - return err; -} diff --git a/freeimage241/Source/ZLib/vssver.scc b/freeimage241/Source/ZLib/vssver.scc deleted file mode 100644 index 05119d1..0000000 Binary files a/freeimage241/Source/ZLib/vssver.scc and /dev/null differ diff --git a/freeimage241/Source/ZLib/zconf.h b/freeimage241/Source/ZLib/zconf.h deleted file mode 100644 index bc02462..0000000 --- a/freeimage241/Source/ZLib/zconf.h +++ /dev/null @@ -1,279 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-1998 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: zconf.h,v 1.0 2001-04-13 00:42:50+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -#ifndef _ZCONF_H -#define _ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateReset z_inflateReset -# define compress z_compress -# define compress2 z_compress2 -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table - -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp -#endif - -#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) -# define WIN32 -#endif -#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) -# ifndef __32BIT__ -# define __32BIT__ -# endif -#endif -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#if defined(MSDOS) && !defined(__32BIT__) -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) -# define STDC -#endif -#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) -# ifndef STDC -# define STDC -# endif -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Old Borland C incorrectly complains about missing returns: */ -#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) -# define NEED_DUMMY_RETURN -#endif - - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -#endif -#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) -# ifndef __32BIT__ -# define SMALL_MEDIUM -# define FAR _far -# endif -#endif - -/* Compile with -DZLIB_DLL for Windows DLL support */ -#if defined(ZLIB_DLL) -# if defined(_WINDOWS) || defined(WINDOWS) -# ifdef FAR -# undef FAR -# endif -# include -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR _cdecl _export -# endif -# endif -# if defined (__BORLANDC__) -# if (__BORLANDC__ >= 0x0500) && defined (WIN32) -# include -# define ZEXPORT __declspec(dllexport) WINAPI -# define ZEXPORTRVA __declspec(dllexport) WINAPIV -# else -# if defined (_Windows) && defined (__DLL__) -# define ZEXPORT _export -# define ZEXPORTVA _export -# endif -# endif -# endif -#endif - -#if defined (__BEOS__) -# if defined (ZLIB_DLL) -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -#endif - -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif -#ifndef ZEXTERN -# define ZEXTERN extern -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(MACOS) && !defined(TARGET_OS_MAC) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#ifdef HAVE_UNISTD_H -# include /* for off_t */ -# include /* for SEEK_* and off_t */ -# define z_off_t off_t -#endif -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif -#ifndef z_off_t -# define z_off_t long -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) -# pragma map(deflateInit_,"DEIN") -# pragma map(deflateInit2_,"DEIN2") -# pragma map(deflateEnd,"DEEND") -# pragma map(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(inflate_blocks,"INBL") -# pragma map(inflate_blocks_new,"INBLNE") -# pragma map(inflate_blocks_free,"INBLFR") -# pragma map(inflate_blocks_reset,"INBLRE") -# pragma map(inflate_codes_free,"INCOFR") -# pragma map(inflate_codes,"INCO") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_flush,"INFLU") -# pragma map(inflate_mask,"INMA") -# pragma map(inflate_set_dictionary,"INSEDI2") -# pragma map(inflate_copyright,"INCOPY") -# pragma map(inflate_trees_bits,"INTRBI") -# pragma map(inflate_trees_dynamic,"INTRDY") -# pragma map(inflate_trees_fixed,"INTRFI") -# pragma map(inflate_trees_free,"INTRFR") -#endif - -#endif /* _ZCONF_H */ diff --git a/freeimage241/Source/ZLib/zlib.h b/freeimage241/Source/ZLib/zlib.h deleted file mode 100644 index 49f56b4..0000000 --- a/freeimage241/Source/ZLib/zlib.h +++ /dev/null @@ -1,893 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.1.3, July 9th, 1998 - - Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef _ZLIB_H -#define _ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.1.3" - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms will be added later and will have the same - stream interface. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output - (providing more output space) before each call. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never - crash even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: ascii or binary */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -/* Allowed flush values; see deflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_ASCII 1 -#define Z_UNKNOWN 2 -/* Possible values of the data_type field */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce some - output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In particular - avail_in is zero after the call if enough output space has been provided - before the call.) Flushing may degrade compression for some compression - algorithms and so it should be used only when necessary. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - the compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - 0.1% larger than avail_in plus 12 bytes. If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update data_type if it can make a good guess about - the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact - value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may some - introduce some output latency (reading input without producing any output) - except when forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much - output as possible to the output buffer. The flushing behavior of inflate is - not specified for values of the flush parameter other than Z_SYNC_FLUSH - and Z_FINISH, but the current implementation actually flushes as much output - as possible anyway. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster routine - may be used for the single inflate() call. - - If a preset dictionary is needed at this point (see inflateSetDictionary - below), inflate sets strm-adler to the adler32 checksum of the - dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise - it sets strm->adler to the adler32 checksum of all output produced - so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or - an error code as described below. At the end of the stream, inflate() - checks that its computed adler32 checksum is equal to that saved by the - compressor and returns Z_STREAM_END only if the checksum is correct. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect - adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent - (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if no progress is possible or if there was not - enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR - case, the application may then call inflateSync to look for a good - compression block. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match). Filtered data consists mostly of small values with a - somewhat random distribution. In this case, the compression algorithm is - tuned to compress them better. The effect of Z_FILTERED is to force more - Huffman coding and less string matching; it is somewhat intermediate - between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects - the compression ratio but not the correctness of the compressed output even - if it is not set appropriately. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. - - Upon return of this function, strm->adler is set to the Adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The Adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different - strategy. If the compression level is changed, the input available so far - is compressed with the old level (and may be flushed); the new level will - take effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. If a compressed stream with a larger window size is given as - input, inflate() will return with the error code Z_DATA_ERROR instead of - trying to allocate a larger window. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative - memLevel). msg is set to null if there is no error message. inflateInit2 - does not perform any decompression apart from reading the zlib header if - present: this will be done by inflate(). (So next_in and avail_in may be - modified, but next_out and avail_out are unchanged.) -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate - if this call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the Adler32 value returned by this call of - inflate. The compressor and decompressor must use exactly the same - dictionary (see deflateSetDictionary). - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect Adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been found, - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current current value of total_in which - indicates where valid compressed data was found. In the error case, the - application may repeatedly call inflateSync, providing more input each time, - until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. - The stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the - basic stream-oriented functions. To simplify the interface, some - default options are assumed (compression level and memory usage, - standard memory allocation functions). The source code of these - utility functions can easily be modified if you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be at least 0.1% larger than - sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least 0.1% larger than sourceLen plus - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. -*/ - - -typedef voidp gzFile; - -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); -/* - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb") but can also include a compression level - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for - Huffman only compression as in "wb1h". (See the description - of deflateInit2 for more information about the strategy parameter.) - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen() associates a gzFile with the file descriptor fd. File - descriptors are obtained from calls like open, dup, creat, pipe or - fileno (in the file has been previously opened with fopen). - The mode parameter is as in gzopen. - The next call of gzclose on the returned gzFile will also close the - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - const voidp buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or - a newline character is read and transferred to buf, or an end-of-file - condition is encountered. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. The return value is the zlib - error number (see function gzerror below). gzflush returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); -/* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); -/* - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); - -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running crc with the bytes buf[0..len-1] and return the updated - crc. If buf is NULL, this function returns the required initial value - for the crc. Pre- and post-conditioning (one's complement) is performed - within this function so it shouldn't be done by the application. - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) - - -#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int err)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* _ZLIB_H */ diff --git a/freeimage241/Source/ZLib/zutil.c b/freeimage241/Source/ZLib/zutil.c deleted file mode 100644 index 89e5d02..0000000 --- a/freeimage241/Source/ZLib/zutil.c +++ /dev/null @@ -1,225 +0,0 @@ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-1998 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: zutil.c,v 1.0 2001-04-13 00:42:51+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -#include "zutil.h" - -struct internal_state {int dummy;}; /* for buggy compilers */ - -#ifndef STDC -extern void exit OF((int)); -#endif - -const char *z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; - - -const char * ZEXPORT zlibVersion() -{ - return ZLIB_VERSION; -} - -#ifdef DEBUG - -# ifndef verbose -# define verbose 0 -# endif -int z_verbose = verbose; - -void z_error (m) - char *m; -{ - fprintf(stderr, "%s\n", m); - exit(1); -} -#endif - -/* exported to allow conversion of error code to string for compress() and - * uncompress() - */ -const char * ZEXPORT zError(err) - int err; -{ - return ERR_MSG(err); -} - - -#ifndef HAVE_MEMCPY - -void zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); -} - -int zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ - uInt j; - - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; -} - -void zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - -#ifdef __TURBOC__ -#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) -/* Small and medium model in Turbo C are for now limited to near allocation - * with reduced MAX_WBITS and MAX_MEM_LEVEL - */ -# define MY_ZCALLOC - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use zcfree(). - */ - -#define MAX_PTR 10 -/* 10*64K = 640K */ - -local int next_ptr = 0; - -typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; -} ptr_table; - -local ptr_table table[MAX_PTR]; -/* This table is used to remember the original form of pointers - * to large buffers (64K). Such pointers are normalized with a zero offset. - * Since MSDOS is not a preemptive multitasking OS, this table is not - * protected from concurrent access. This hack doesn't work anyway on - * a protected system like OS/2. Use Microsoft C instead. - */ - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - voidpf buf = opaque; /* just to make some compilers happy */ - ulg bsize = (ulg)items*size; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - int n; - if (*(ush*)&ptr != 0) { /* object < 64K */ - farfree(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - farfree(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - ptr = opaque; /* just to make some compilers happy */ - Assert(0, "zcfree: ptr not found"); -} -#endif -#endif /* __TURBOC__ */ - - -#if defined(M_I86) && !defined(__32BIT__) -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - return _halloc((long)items, size); -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - _hfree(ptr); -} - -#endif /* MSC */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - if (opaque) items += size - size; /* make compiler happy */ - return (voidpf)calloc(items, size); -} - -void zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - free(ptr); - if (opaque) return; /* make compiler happy */ -} - -#endif /* MY_ZCALLOC */ diff --git a/freeimage241/Source/ZLib/zutil.h b/freeimage241/Source/ZLib/zutil.h deleted file mode 100644 index 8d5313e..0000000 --- a/freeimage241/Source/ZLib/zutil.h +++ /dev/null @@ -1,220 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-1998 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id: zutil.h,v 1.0 2001-04-13 00:42:51+02 floris_van_den_berg Exp floris_van_den_berg $ */ - -#ifndef _Z_UTIL_H -#define _Z_UTIL_H - -#include "zlib.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#ifdef MSDOS -# define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -#endif - -#ifdef WIN32 /* Window 95 & Windows NT */ -# define OS_CODE 0x0b -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0F -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) -# define fdopen(fd,type) _fdopen(fd,type) -#endif - - - /* Common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#ifdef HAVE_STRERROR - extern char *strerror OF((int)); -# define zstrerror(errnum) strerror(errnum) -#else -# define zstrerror(errnum) "" -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int z_verbose; - extern void z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, - uInt len)); -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* _Z_UTIL_H */ diff --git a/freeimage241/Source/freeimage.h b/freeimage241/Source/freeimage.h deleted file mode 100644 index d95d1de..0000000 --- a/freeimage241/Source/freeimage.h +++ /dev/null @@ -1,579 +0,0 @@ -// ========================================================== -// FreeImage 2 -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// -// Contributors: -// - Adam Gates (adam.gates@str.com.au) -// - Alex Kwak -// - Alexander Dymerets (sashad@te.net.ua) -// - Hervé Drolon (drolon@iut.univ-lehavre.fr) -// - Jan L. Nauta (jln@magentammt.com) -// - Jani Kajala (janik@remedy.fi) -// - Luca Piergentili (l.pierge@terra.es) -// - Machiel ten Brinke (brinkem@uni-one.nl) -// - Markus Loibl (markus.loibl@epost.de) -// - Martin Weber (martweb@gmx.net) -// -// This file is part of FreeImage 2 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifndef FREEIMAGE_H -#define FREEIMAGE_H - -#if defined(_LIB) || defined(FREEIMAGE_LIB) || !defined(WIN32) -#define DLL_API -#define DLL_CALLCONV _cdecl -#else -#define WIN32_LEAN_AND_MEAN -#define DLL_CALLCONV _stdcall -#ifdef FREEIMAGE_EXPORTS -#define DLL_API __declspec(dllexport) -#else -#define DLL_API __declspec(dllimport) -#endif -#endif - -// For C compatility -------------------------------------------------------- - -#ifdef __cplusplus -#define FI_DEFAULT(x) = x -#define FI_ENUM(x) enum x -#define FI_STRUCT(x) struct x -#else -#define FI_DEFAULT(x) -#define FI_ENUM(x) typedef int x; enum x -#define FI_STRUCT(x) typedef struct x x; struct x -#endif - -// Bitmap types ------------------------------------------------------------- - -FI_STRUCT (FIBITMAP) { void *data; }; - -// Types used in the library (directly copied from Windows) ----------------- - -#ifndef _WINDOWS_ -#define _WINDOWS_ - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef NULL -#define NULL 0 -#endif - -typedef long BOOL; -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef long LONG; - -#ifndef SEEK_SET -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#define BI_RGB 0L -#define BI_RLE8 1L -#define BI_RLE4 2L -#define BI_BITFIELDS 3L - -typedef struct tagRGBQUAD { - BYTE rgbBlue; - BYTE rgbGreen; - BYTE rgbRed; - BYTE rgbReserved; -} RGBQUAD; - -typedef struct tagBITMAPINFOHEADER{ - DWORD biSize; - LONG biWidth; - LONG biHeight; - WORD biPlanes; - WORD biBitCount; - DWORD biCompression; - DWORD biSizeImage; - LONG biXPelsPerMeter; - LONG biYPelsPerMeter; - DWORD biClrUsed; - DWORD biClrImportant; -} BITMAPINFOHEADER, *PBITMAPINFOHEADER; - -typedef struct tagBITMAPINFO { - BITMAPINFOHEADER bmiHeader; - RGBQUAD bmiColors[1]; -} BITMAPINFO, *PBITMAPINFO; - -#endif - -// Important enums ---------------------------------------------------------- - -FI_ENUM(FREE_IMAGE_FORMAT) { - FIF_UNKNOWN = -1, - FIF_BMP = 0, -// FIF_ICO, - FIF_JPEG, -// FIF_JNG, -// FIF_KOALA, - FIF_LBM, -// FIF_MNG, -// FIF_PBM, -// FIF_PBMRAW, -// FIF_PCD, - FIF_PCX, -// FIF_PGM, -// FIF_PGMRAW, - FIF_PNG, -// FIF_PPM, -// FIF_PPMRAW, -// FIF_RAS, - FIF_TARGA, -// FIF_TIFF, -// FIF_WBMP, -// FIF_PSD, - FIF_IFF = FIF_LBM, -}; - -FI_ENUM(FREE_IMAGE_COLOR_TYPE) { - FIC_MINISWHITE = 0, // min value is white - FIC_MINISBLACK = 1, // min value is black - FIC_RGB = 2, // RGB color model - FIC_PALETTE = 3, // color map indexed - FIC_RGBALPHA = 4, // RGB color model with alpha channel -}; - -FI_ENUM(FREE_IMAGE_QUANTIZE) { - FIQ_WUQUANT = 0, // Xiaolin Wu color quantization algorithm - FIQ_NNQUANT = 1 // NeuQuant neural-net quantization algorithm by Anthony Dekker -}; - -// File IO routines --------------------------------------------------------- - -#ifndef FREEIMAGE_IO -#define FREEIMAGE_IO - -#define fi_handle void* - -typedef unsigned (*FI_ReadProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); -typedef unsigned (*FI_WriteProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); -typedef int (*FI_SeekProc) (fi_handle handle, long offset, int origin); -typedef long (*FI_TellProc) (fi_handle handle); - -#ifdef WIN32 -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif - -FI_STRUCT(FreeImageIO) { - FI_ReadProc read_proc; // pointer to the function used to read data - FI_WriteProc write_proc; // pointer to the function used to write data - FI_SeekProc seek_proc; // pointer to the function used to seek - FI_TellProc tell_proc; // pointer to the function used to aquire the current position -}; - -#ifdef WIN32 -#pragma pack(pop) -#else -#pragma pack(4) -#endif - -// Plugin routines ---------------------------------------------------------- - -#ifndef PLUGINS -#define PLUGINS - -FI_STRUCT (Plugin); -FI_STRUCT (FreeImage); - -typedef FIBITMAP *(DLL_CALLCONV * FI_AllocateProc)(int width, int height, int bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask); -typedef void (DLL_CALLCONV *FI_FreeProc)(FIBITMAP *dib); -typedef void (DLL_CALLCONV *FI_UnloadProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetColorsUsedProc)(FIBITMAP *dib); -typedef BYTE *(DLL_CALLCONV *FI_GetBitsProc)(FIBITMAP *dib); -typedef BYTE *(DLL_CALLCONV *FI_GetBitsRowColProc)(FIBITMAP *dib, int col, int row); -typedef BYTE *(DLL_CALLCONV *FI_GetScanLineProc)(FIBITMAP *dib, int scanline); -typedef unsigned (DLL_CALLCONV *FI_GetBPPProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetWidthProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetHeightProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetLineProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetPitchProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetDIBSizeProc)(FIBITMAP *dib); -typedef RGBQUAD *(DLL_CALLCONV *FI_GetPaletteProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetDotsPerMeterXProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetDotsPerMeterYProc)(FIBITMAP *dib); -typedef BITMAPINFOHEADER *(DLL_CALLCONV *FI_GetInfoHeaderProc)(FIBITMAP *dib); -typedef BITMAPINFO *(DLL_CALLCONV *FI_GetInfoProc)(FIBITMAP *dib); -typedef FREE_IMAGE_COLOR_TYPE (DLL_CALLCONV *FI_GetColorTypeProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetRedMaskProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetGreenMaskProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetBlueMaskProc)(FIBITMAP *dib); -typedef unsigned (DLL_CALLCONV *FI_GetTransparencyCountProc)(FIBITMAP *dib); -typedef BYTE * (DLL_CALLCONV *FI_GetTransparencyTableProc)(FIBITMAP *dib); -typedef void (DLL_CALLCONV *FI_SetTransparencyTableProc)(FIBITMAP *dib, BYTE *table, BYTE count); -typedef BOOL (DLL_CALLCONV *FI_IsTransparentProc)(FIBITMAP *dib); -typedef void (DLL_CALLCONV *FI_SetTransparentProc)(FIBITMAP *dib, BOOL enabled); -typedef void (DLL_CALLCONV *FI_OutputMessageProc)(int fif, const char *msg); -typedef void (DLL_CALLCONV *FI_ConvertLine1To8Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine4To8Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine16To8_555Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine16To8_565Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine24To8Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine32To8Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine1To16_555Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine4To16_555Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine8To16_555Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine16_565_To16_555Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine24To16_555Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine32To16_555Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine1To16_565Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine4To16_565Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine8To16_565Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine16_555_To16_565Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine24To16_565Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine32To16_565Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine1To24Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine4To24Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine8To24Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine16To24_555Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine16To24_565Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine32To24Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine1To32Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine4To32Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine8To32Proc)(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -typedef void (DLL_CALLCONV *FI_ConvertLine16To32_555Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine16To32_565Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_ConvertLine24To32Proc)(BYTE *target, BYTE *source, int width_in_pixels); -typedef void (DLL_CALLCONV *FI_InitProc)(Plugin &plugin, int format_id); - -typedef unsigned (*FI_ReadProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); -typedef unsigned (*FI_WriteProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); -typedef int (*FI_SeekProc) (fi_handle handle, long offset, int origin); -typedef long (*FI_TellProc) (fi_handle handle); - -typedef const char *(DLL_CALLCONV *FI_FormatProc) (); -typedef const char *(DLL_CALLCONV *FI_DescriptionProc) (); -typedef const char *(DLL_CALLCONV *FI_ExtensionListProc) (); -typedef const char *(DLL_CALLCONV *FI_RegExprProc) (); -typedef void *(DLL_CALLCONV *FI_OpenProc)(FreeImageIO &io, fi_handle handle, BOOL read); -typedef void (DLL_CALLCONV *FI_CloseProc)(FreeImageIO &io, fi_handle handle, void *data); -typedef int (DLL_CALLCONV *FI_PageCountProc)(FreeImageIO &io, fi_handle handle, void *data); -typedef int (DLL_CALLCONV *FI_PageCapabilityProc)(FreeImageIO &io, fi_handle handle, void *data); -typedef FIBITMAP *(DLL_CALLCONV *FI_LoadProc)(FreeImage &freeimage, FreeImageIO &io, fi_handle handle, int page, int flags, void *data); -typedef BOOL (DLL_CALLCONV *FI_SaveProc)(FreeImage &freeimage, FreeImageIO &io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data); -typedef BOOL (DLL_CALLCONV *FI_ValidateProc)(FreeImageIO &io, fi_handle handle); -typedef const char *(DLL_CALLCONV *FI_MimeProc) (); - -FI_STRUCT(FreeImage) { - FI_AllocateProc allocate_proc; - FI_UnloadProc unload_proc; - FI_FreeProc free_proc; - FI_GetColorsUsedProc get_colors_used_proc; - FI_GetBitsProc get_bits_proc; - FI_GetBitsRowColProc get_bits_row_col_proc; - FI_GetScanLineProc get_scanline_proc; - FI_GetBPPProc get_bpp_proc; - FI_GetWidthProc get_width_proc; - FI_GetHeightProc get_height_proc; - FI_GetLineProc get_line_proc; - FI_GetPitchProc get_pitch_proc; - FI_GetDIBSizeProc get_dib_size_proc; - FI_GetPaletteProc get_palette_proc; - FI_GetDotsPerMeterXProc get_dots_per_meter_x_proc; - FI_GetDotsPerMeterYProc get_dots_per_meter_y_proc; - FI_GetInfoHeaderProc get_info_header_proc; - FI_GetInfoProc get_info_proc; - FI_GetColorTypeProc get_color_type_proc; - FI_GetRedMaskProc get_red_mask_proc; - FI_GetGreenMaskProc get_green_mask_proc; - FI_GetBlueMaskProc get_blue_mask_proc; - FI_GetTransparencyCountProc get_transparency_count_proc; - FI_GetTransparencyTableProc get_transparency_table_proc; - FI_SetTransparencyTableProc set_transparency_table_proc; - FI_IsTransparentProc is_transparent_proc; - FI_SetTransparentProc set_transparent_proc; - FI_OutputMessageProc output_message_proc; - FI_ConvertLine1To8Proc convert_line1to8_proc; - FI_ConvertLine4To8Proc convert_line_4to8_proc; - FI_ConvertLine16To8_555Proc convert_line_16to8_555_proc; - FI_ConvertLine16To8_565Proc convert_line_16to8_565_proc; - FI_ConvertLine24To8Proc convert_line_24to8_proc; - FI_ConvertLine32To8Proc convert_line_32to8_proc; - FI_ConvertLine1To16_555Proc convert_line_1to16_555_proc; - FI_ConvertLine4To16_555Proc convert_line_4to16_555_proc; - FI_ConvertLine8To16_555Proc convert_line_8to16_555_proc; - FI_ConvertLine16_565_To16_555Proc convert_line_16_565_to_16_555_proc; - FI_ConvertLine24To16_555Proc convert_line_24to16_555_proc; - FI_ConvertLine32To16_555Proc convert_line_32to16_555_proc; - FI_ConvertLine1To16_565Proc convert_line_1to16_565_proc; - FI_ConvertLine4To16_565Proc convert_line_4to16_565_proc; - FI_ConvertLine8To16_565Proc convert_line_8to16_565_proc; - FI_ConvertLine16_555_To16_565Proc convert_line_16_555_to_16_565_proc; - FI_ConvertLine24To16_565Proc convert_line_24to16_565_proc; - FI_ConvertLine32To16_565Proc convert_line_32to16_565_proc; - FI_ConvertLine1To24Proc convert_line_1to24_proc; - FI_ConvertLine4To24Proc convert_line_4to24_proc; - FI_ConvertLine8To24Proc convert_line_8to24_proc; - FI_ConvertLine16To24_555Proc convert_line_16to24_555_proc; - FI_ConvertLine16To24_565Proc convert_line_16to24_565_proc; - FI_ConvertLine32To24Proc convert_line_32to24_proc; - FI_ConvertLine1To32Proc convert_line_1to32_proc; - FI_ConvertLine4To32Proc convert_line_4to32_proc; - FI_ConvertLine8To32Proc convert_line_8to32_proc; - FI_ConvertLine16To32_555Proc convert_line_16to32_555_proc; - FI_ConvertLine16To32_565Proc convert_line_16to32_565_proc; - FI_ConvertLine24To32Proc convert_line_24to32_proc; -}; - -FI_STRUCT (Plugin) { - FI_FormatProc format_proc; - FI_DescriptionProc description_proc; - FI_ExtensionListProc extension_proc; - FI_RegExprProc regexpr_proc; - FI_OpenProc open_proc; - FI_CloseProc close_proc; - FI_PageCountProc pagecount_proc; - FI_PageCapabilityProc pagecapability_proc; - FI_LoadProc load_proc; - FI_SaveProc save_proc; - FI_ValidateProc validate_proc; - FI_MimeProc mime_proc; -}; - -#endif -#endif - -// Load/Save flag constants ----------------------------------------------------- - -#define BMP_DEFAULT 0 -#define ICO_DEFAULT 0 -#define ICO_FIRST 0 -#define ICO_SECOND 0 -#define ICO_THIRD 0 -#define IFF_DEFAULT 0 -#define JPEG_DEFAULT 0 -#define JPEG_FAST 1 -#define JPEG_ACCURATE 2 -#define JPEG_QUALITYSUPERB 0x80 -#define JPEG_QUALITYGOOD 0x100 -#define JPEG_QUALITYNORMAL 0x200 -#define JPEG_QUALITYAVERAGE 0x400 -#define JPEG_QUALITYBAD 0x800 -#define KOALA_DEFAULT 0 -#define LBM_DEFAULT 0 -#define MNG_DEFAULT 0 -#define PCD_DEFAULT 0 -#define PCD_BASE 1 -#define PCD_BASEDIV4 2 -#define PCD_BASEDIV16 3 -#define PCX_DEFAULT 0 -#define PNG_DEFAULT 0 -#define PNM_DEFAULT 0 -#define PNM_SAVE_RAW 0 // If set the writer saves in RAW format (i.e. P4, P5 or P6) -#define PNM_SAVE_ASCII 1 // If set the writer saves in ASCII format (i.e. P1, P2 or P3) -#define RAS_DEFAULT 0 -#define TARGA_DEFAULT 0 -#define TARGA_LOAD_RGB888 1 // If set the loader converts RGB555 and ARGB8888 -> RGB888. -#define TARGA_LOAD_RGB555 2 // This flag is obsolete -#define TIFF_DEFAULT 0 -#define WBMP_DEFAULT 0 -#define PSD_DEFAULT 0 - -#ifdef __cplusplus -extern "C" { -#endif - -// Init/Error routines ------------------------------------------------------ - -DLL_API void DLL_CALLCONV FreeImage_Initialise(BOOL load_local_plugins_only = FALSE); -DLL_API void DLL_CALLCONV FreeImage_DeInitialise(); - -// Version routines --------------------------------------------------------- - -DLL_API const char *DLL_CALLCONV FreeImage_GetVersion(); -DLL_API const char *DLL_CALLCONV FreeImage_GetCopyrightMessage(); - -// Message output functions ------------------------------------------------- - -typedef void (*FreeImage_OutputMessageFunction)(FREE_IMAGE_FORMAT fif, const char *msg); -DLL_API void DLL_CALLCONV FreeImage_SetOutputMessage(FreeImage_OutputMessageFunction omf); - -// Allocate/Unload routines ------------------------------------------------ - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Allocate(int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); -DLL_API void DLL_CALLCONV FreeImage_Free(FIBITMAP *dib); -DLL_API void DLL_CALLCONV FreeImage_Unload(FIBITMAP *dib); - -// Plugin Interface -------------------------------------------------------- - -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterLocalPlugin(FI_InitProc proc_address, const char *format = 0, const char *description = 0, const char *extension = 0, const char *regexpr = 0); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterExternalPlugin(const char *path, const char *format = 0, const char *description = 0, const char *extension = 0, const char *regexpr = 0); -DLL_API int DLL_CALLCONV FreeImage_SetPluginEnabled(FREE_IMAGE_FORMAT fif, BOOL enable); -DLL_API int DLL_CALLCONV FreeImage_IsPluginEnabled(FREE_IMAGE_FORMAT fif); -DLL_API int DLL_CALLCONV FreeImage_GetFIFCount(); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFormat(const char *format); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromMime(const char *mime); -DLL_API const char *DLL_CALLCONV FreeImage_GetFormatFromFIF(FREE_IMAGE_FORMAT fif); -DLL_API const char *DLL_CALLCONV FreeImage_GetFIFExtensionList(FREE_IMAGE_FORMAT fif); -DLL_API const char *DLL_CALLCONV FreeImage_GetFIFDescription(FREE_IMAGE_FORMAT fif); -DLL_API const char * DLL_CALLCONV FreeImage_GetFIFRegExpr(FREE_IMAGE_FORMAT fif); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilename(const char *filename); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsReading(FREE_IMAGE_FORMAT fif); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsWriting(FREE_IMAGE_FORMAT fif); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif, const char *filename, int flags FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); - -// Old style bitmap load routines ------------------------------------------ - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadBMP(const char *filename, int flags FI_DEFAULT(BMP_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadBMPFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(BMP_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadICO(const char *filename, int flags FI_DEFAULT(ICO_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadICOFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(ICO_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadIFF(const char *filename, int flags FI_DEFAULT(IFF_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadIFFFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(IFF_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadJPEG(const char *filename, int flags FI_DEFAULT(JPEG_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadJPEGFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(JPEG_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadKOALA(const char *filename, int flags FI_DEFAULT(KOALA_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadKOALAFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(KOALA_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadLBM(const char *filename, int flags FI_DEFAULT(LBM_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadLBMFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(LBM_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadMNG(const char *filename, int flags FI_DEFAULT(MNG_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadMNGFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(MNG_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadPCD(const char *filename, int flags FI_DEFAULT(PCD_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadPCDFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(PCD_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadPCX(const char *filename, int flags FI_DEFAULT(PCX_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadPCXFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(PCX_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadPNG(const char *filename, int flags FI_DEFAULT(PNG_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadPNGFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(PNG_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadPNM(const char *filename, int flags FI_DEFAULT(PNM_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadPNMFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(PNM_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadPSD(const char *filename, int flags FI_DEFAULT(PSD_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadPSDFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(PSD_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadRAS(const char *filename, int flags FI_DEFAULT(RAS_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadRASFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(RAS_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadTARGA(const char *filename, int flags FI_DEFAULT(TARGA_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadTARGAFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(TARGA_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadTIFF(const char *filename, int flags FI_DEFAULT(TIFF_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadTIFFFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(TIFF_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadWBMP(const char *filename, int flags FI_DEFAULT(WBMP_DEFAULT)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadWBMPFromHandle(FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(WBMP_DEFAULT)); - -// Bitmap save routines ----------------------------------------------------- - -DLL_API BOOL DLL_CALLCONV FreeImage_SaveBMP(FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(BMP_DEFAULT)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveBMPToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(BMP_DEFAULT)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveJPEG(FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(JPEG_DEFAULT)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveJPEGToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(JPEG_DEFAULT)); -DLL_API BOOL DLL_CALLCONV FreeImage_SavePNG(FIBITMAP *dib, const char *filename, int flags FI_DEFAULT( PNG_DEFAULT ) ); -DLL_API BOOL DLL_CALLCONV FreeImage_SavePNGToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(PNG_DEFAULT)); -DLL_API BOOL DLL_CALLCONV FreeImage_SavePNM(FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(PNM_DEFAULT)); -DLL_API BOOL DLL_CALLCONV FreeImage_SavePNMToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(PNM_DEFAULT)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveTIFF(FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(TIFF_DEFAULT)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveTIFFToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(TIFF_DEFAULT)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveWBMP(FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(WBMP_DEFAULT)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveWBMPToHandle(FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(WBMP_DEFAULT)); - -// Filetype request routines ----------------------------------------------- - -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileType(const char *filename, int size); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size); -DLL_API const char * DLL_CALLCONV FreeImage_GetFileTypeFromFormat(FREE_IMAGE_FORMAT fif); // this function is deprecated -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromExt(const char *filename); // this function is deprecated - -// FreeImage info routines ------------------------------------------------- - -DLL_API unsigned DLL_CALLCONV FreeImage_GetRedMask(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetGreenMask(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetBlueMask(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetTransparencyCount(FIBITMAP *dib); -DLL_API BYTE * DLL_CALLCONV FreeImage_GetTransparencyTable(FIBITMAP *dib); -DLL_API void DLL_CALLCONV FreeImage_SetTransparent(FIBITMAP *dib, BOOL enabled); -DLL_API void DLL_CALLCONV FreeImage_SetTransparencyTable(FIBITMAP *dib, BYTE *table, BYTE count); -DLL_API BOOL DLL_CALLCONV FreeImage_IsTransparent(FIBITMAP *dib); - -// DIB info routines ------------------------------------------------------- - -DLL_API unsigned DLL_CALLCONV FreeImage_GetColorsUsed(FIBITMAP *dib); -DLL_API BYTE *DLL_CALLCONV FreeImage_GetBits(FIBITMAP *dib); -DLL_API BYTE *DLL_CALLCONV FreeImage_GetBitsRowCol(FIBITMAP *dib, int col, int row); -DLL_API BYTE *DLL_CALLCONV FreeImage_GetScanLine(FIBITMAP *dib, int scanline); -DLL_API unsigned DLL_CALLCONV FreeImage_GetBPP(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetWidth(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetHeight(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetLine(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetPitch(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetDIBSize(FIBITMAP *dib); -DLL_API RGBQUAD *DLL_CALLCONV FreeImage_GetPalette(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterX(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterY(FIBITMAP *dib); -DLL_API BITMAPINFOHEADER *DLL_CALLCONV FreeImage_GetInfoHeader(FIBITMAP *dib); -DLL_API BITMAPINFO *DLL_CALLCONV FreeImage_GetInfo(FIBITMAP *dib); -DLL_API FREE_IMAGE_COLOR_TYPE DLL_CALLCONV FreeImage_GetColorType(FIBITMAP *dib); - -// Conversion routines ----------------------------------------------------- - -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_565_To16_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_555_To16_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To24(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To32(BYTE *target, BYTE *source, int width_in_pixels); - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo8Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits555(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits565(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo24Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo32Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantize(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize); - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertFromRawBits(BYTE *bits, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); -DLL_API void DLL_CALLCONV FreeImage_ConvertToRawBits(BYTE *bits, FIBITMAP *dib, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); - -#ifdef __cplusplus -} -#endif - -#endif // !FREEIMAGE_H diff --git a/freeimage241/Todo.txt b/freeimage241/Todo.txt deleted file mode 100644 index 8b55f40..0000000 --- a/freeimage241/Todo.txt +++ /dev/null @@ -1,4 +0,0 @@ -What's there to do for FreeImage - -* add a movie plugin (DirectShow based) -* start using c++ (stl) instead of c, since most things are now c++ anyway diff --git a/freeimage241/Whatsnew.txt b/freeimage241/Whatsnew.txt deleted file mode 100644 index 6c79510..0000000 --- a/freeimage241/Whatsnew.txt +++ /dev/null @@ -1,373 +0,0 @@ -Whats New for FreeImage - -* : fixed -- : removed -! : changed -+ : added - -July 30th 2001 - 2.4.1 -* [Jan Nauta] fixed some plugin ids not being passed to plugins -* [Jan Nauta] fixed some functions being natively called instead of indirect -* [Jan Nauta] fixed BMPs with signature BA not being regognised -* [Remo Eichenberger] fixed memory leak in the plugin system -* fixed seek bug in PluginIFF's Validate -* fixed transparency issue in PluginPNG -* fixed uncaught exceptions in WUQuantizer and NNQuantizer -* fixed some problems with PluginTARGA -* fixed some problems with PluginICO -* fixed some problems with PluginBMP -! improved FreeImageQt's load function a little -! tell/seek control for validation is now handled inside the plugin framework - -July 22th 2001 - 2.4.0 -* (Yours Detlev) fixed memory leak in FreeImage_GetFIFFromFilename -* (Yours Detlev) fixed memory leak in the ICO plugin -* (Yours Detlev) fixed memory leak in the PNG plugin -* fixed potential NULL-pointer access bug in Plugin::AddNode -* fixed problems with linking the static lib -- removed LBM plugin. Its functionality is placed in the IFF plugin now -- removed FreeImage_GetFIFByIndex -! FreeImage now uses LibMNG 1.0.2 -! FreeImage_SetTransparent now only enables alpha when the bitmap is 8 or 32 bit -! FreeImage_SetTransparencyTable now only enables alpha when the bitmap is 8 bit -! FreeImage_LoadLBM now uses Mark Sibly's IFF plugin -! FreeImage_SaveBMP now converts to 24-bit when bpp is 32 and transparency is off -! FreeImage_SaveJPEG now converts to 24-bit when bpp is 32 and transparency is off -! FreeImage_SavePNM now converts to 24-bit when bpp is 32 and transparency is off -! FreeImage_SaveTIFF now converts to 24-bit when bpp is 32 and transparency is off -+ [Mark Sibly] added IFF (ILBM) support -+ added basic support for Photoshop files -+ added mime type support (FreeImage_GetFIFFromMime) -+ added functions FreeImage_SetPluginEnabled and FreeImage_IsPluginEnabled - Disabling plugins modifies the behaviour of the following functions: - * FreeImage_LoadFromHandle - * FreeImage_SaveToHandle - * FreeImage_FIFSupportsReading - * FreeImage_FIFSupportsWriting - * FreeImage_GetFIFFromFormat - * FreeImage_GetFIFFromFilename - * FreeImage_GetFIFFromMime - * FreeImage_Validate - -June 30th 2001 - 2.3.2 -* fixed missing "targa" extension in targa extension list -* fixed small memory leak in PluginList::AddNode -* fixed 32 bit PNG saving suddenly disappeared from the distro? -* fixed 'black line' bug in LoadTARGA -- removed project FreeImageM2 -- removed FreeImage_Combine -! FreeImage_RegisterLocalPlugin now receives a FI_InitProc as first parameter -! FreeImage_GetFIFFromFilename now also takes the format id into account -! cleanup up the code a little for PluginPCD and PluginPCX -+ added static lib project - -June 11th 2001 - 2.3.1 -* [Machiel ten Brinke] fixed the loading of some 'ancient' TARGAs -* [Rui Lopes] fixed some bugs in the external plugin registration -* fixed the plugin system crashing when the init function isn't called -- removed project FreeImagePy -- removed 32 to 24 bit conversion while saving PNG in FreeImageQt -! the scanline convert functions are now accessable in plugins -! FreeImage now uses an STL map to store the plugin list -! PluginSDK.h is now integrated into FreeImage.h -! FreeImage_Register now receives the boolean parameter 'load_local_plugins_only' -! FreeImage now uses LibPNG 1.0.12 -+ [Rui Lopes] added plugin for GIF reading/writing support -+ added function FreeImage_SetTransparencyCount -+ added support for 32 bit PNG saving -+ added FreeImage_RegisterLocalPlugin to allow plugins inside apps -+ added FreeImage_RegisterExternalPlugin to manually load DLLs -+ added plugin for JBIG reading/writing support - -May 4th 2001 - 2.3.0 -* [Martin Weber] fixed some small bugs in the TARGA and BMP plugins -* [Martin Weber] fixed tiny bug in new 16 bit conversions -* [Martin Weber] fixed load flag inconsistency in the TARGA plugin -* [Martin Weber] fixed plugin id / load reference inconsistency for PNM -* [Jan Nauta] fixed bug in conversion 16 -> 16 -* [Herve Drolon] fixed small bug in 4-bit PCX loader -- removed code that loads BMPs renamed to ICO in PluginICO -! the flag TARGA_LOAD_RGB555 is now obsolete -! the plugin list is now sorted internally -! ConvertTo32Bits now stores the transparency table as alpha mask -! FreeImage now uses LibMNG 1.0,1 -! FreeImage now uses LibPNG 1.0.11 -+ added external plugin support via DLLs -+ added function FreeImage_GetFIFByIndex -+ added internal function CalculateScanLine -+ added transparency support for high-color PNGs -+ added transparency support for high-color TIFFs -+ added functions FreeImage_SetTransparent and FreeImage_IsTransparent -+ added constant FIC_RGBALPHA to FREE_IMAGE_COLOR_TYPE - -April 5th 2001 - 2.2.0 -* [Remo Eichenberger] fixed small bug concerning DLLMain and static LIB generation -* fixed 1-bit bitmaps not properly loading in FreeImageQt -* fixed bug in conversion 16->16 -* FreeImage now uses LibPNG 1.0.10 -! [Martin Weber] improved loading of BMP files -! [Martin Weber] improved loading of TARGA files -! [Dave Larson] improved visual appearance after 16 conversions -! FreeImageQt now converts 32-bit bitmaps to 24-bit when saving PNGs and JPEGs -+ added functions FreeImage_Initialise and FreeImage_DeInitialise -+ added internal plugins -+ re-added combine/alphablend functions - -March 8th 2001 - 2.1.0 -* [Martin Hemming] fixed bug in 16-bit TARGA loading code -* fixed PNG's with alpha masks not loading correctly -! FreeImage is now dual-licensed: the FI-License and the GPL license -! FreeImage now uses LibPNG 1.0.9 -! FreeImage now uses LibTIFF 3.5.6 Beta -! FreeImage now uses LiBMNG 1.0.0 -! changed the ordering of the FREE_IMAGE_FORMAT table -! improved linux support -! improved test script -+ added transparency table support to SavePNG -+ added BI_BITFIELDS support to LoadBMP and SaveBMP -+ added reading support for OS/2 2.x BMPs -+ added support for MNG and JNG reading using LibMNG -+ added support for Deluxe Paint reading -+ added 'hot swap' support to the Core DLL -+ added 'hot swap' support to FreeImage Qt -+ added functions GetFIFFromFormat and GetFIFFromFilename -+ added functions FIFSupportsReading and FIFSupportsWriting -+ added function GetFIFRegExpr - -January 14th 2001 - 2.0.0 -* [Herve Drolon] fixed a bug in the conversion 4->8 -* [Herve Drolon] fixed a bug in metrics handling in SaveJPEG -* [Herve Drolon] fixed a bug in the return value of the function SaveTIFF -* fixed the presence of two WuQuantizer.cpp files in the distribution -* fixed bug where a BMP renamed to ICO isn't loaded -- removed FreeImage_ConvertToGreyScale. Use FreeImage_ConvertTo8Bits instead. -- removed the boolean parameters from all conversion routines -- removed page handling in LoadTIFF. A new range of functions will be added. -! The void pointers used in FreeImage are now typed -! LoadBMP now takes palettes in 24/32 bit images in respect -! All effects and MMX functions are now stored in a new library (FreeEffects) -! [Herve Drolon] fixed bug in FreeImage_GetColorType -! [Herve Drolon] improved PCX loader. It can now read 1, 4, 8 and 24-bit images -! [Manfred Tausch] improved FreeImage_Rotate -! [Luca Piergentili] fixed crash bug when saving some 1-bit TIFFs -! rewrote all bitdepth conversion routines making use of the new scanline converters -! rewrote bitdepth conversion in FreeImageQt (uses less memory) -! FreeImage is now compiled __stdcall -+ [Herve Drolon] added WBMP (Wireless Bitmap Format) support: loading and saving -+ [Herve Drolon] added 4, 16 and 32 bitdepth handling in GetColorType -+ [Herve Drolon] added handling of 8-bit greyscale bitmaps in SaveJPEG -+ [Herve Drolon] added NeuQuant color reduction algorithm to ColorQuantize -+ added DLL_CALLCONV (calling convention) flag -+ added bitmask support to all bitmaps -+ added a series of functions converting scanlines from one bitdepth to another -+ added functions ConvertFromRawBits and ConvertToRawBits -+ added project FreeImageM2: Magenta II MMT bindings for FreeImage -+ added basic foundation for linux support - -December 2th 2000 - 1.4.4 -* fixed small bug related to TIFFSetDirectory in FreeImage_LoadTIFF -* fixed FreeImage_Rotate sometimes clipping too much pixels -* fixed other small bug in FreeImage_Rotate -* fixed FreeImage_Clone not taking the FREEIMAGEHEADER in account -* fixed bug in FreeImageQt where 1-bit images are not correctly allocated -* fixed FreeImage_Crop not copying the palette -* fixed message function pointer crash bug -* fixed bug where the palette wasn't copied when saving in FreeImageQt -* fixed FreeImage_Clone not copying the transparency table -- removed FreeImage_WritePaletteEntry -! [Adam Gates] rewrote parts of FreeImage so that c compilers can handle it better -! FreeImageQt doesn't statically link with the FreeImage lib anymore -! FreeImageQt now uses atexit() to automatically unregister -! rewrote parts of FreeImage_LoadBMP to increase speed -+ [Markus Loibl] added metrics handling code to LoadBMP, LoadJPEG, LoadTIFF and LoadPCX -+ added metrics handling code to FreeImageQt -+ added functions FIQT_IsLoaded, FIQT_GetVersion and FIQT_GetCopyrightMessage -+ added conversion 1 -> 16 -+ added FreeImage_SaveJPEG and JPEG quality settings -+ added FreeImage_GetBitsRowCol -+ added function FIQT_SetOutputMessage to FreeImageQt -+ added FreeImage_GetFileTypeFromExtension and FIQT_GetFileTypeFromFormat -+ added project FreeImagePy: python bindings for FreeImage - -November 7th 2000 - 1.4.3 -* fixed FreeImage_SavePNG crash bug -* fixed slighly corrupt size filter in FreeImage_Combine -* fixed FreeImage_SaveTIFF not saving 4-bit images -* [Herve Drolon] fixed bug in FreeImage_LoadTIFF -* [Herve Drolon] fixed bug in FreeImage_GetColorType -- removed fclose from FreeImage_SavePNM (who put it there?) -! rewrote FreeImage_Rotate -! FreeImageQt now automatically detects which formats are supported by Qt and which not -! FreeImage_Allocate now returns a void pointer -! FreeImage_Unload is now called FreeImage_Free -+ added 16-bit 5-5-5 support to FreeImage_LoadBMP -+ added RLE_DELTA support to FreeImage_LoadBMP -+ added directory support to FreeImage_LoadTIFF -+ added functions dealing with transparency -+ added transparency support to 8-bit PNG's in Qt -+ added FREE_IMAGE_QUANTIZE parameter to FreeImage_ColorQuantize -+ added custom FREEIMAGEHEADER header prepended to internal bitmaps -+ added new documentation - -October 18th 2000 - 1.4.2 -* fixed FreeImage_SaveBMP storing an incorrect bfSize value in the BITMAPFILEHEADER -* fixed bug where JPEG and PNG wouldn't load in FreeImageQt -* fixed FreeImage_Mirror mirroring one pixel less than needed -! FreeImage_MaskedCombine24 is now called FreeImage_MaskedCombine24Ex -! FreeImage_MaskedCombine32 is now called FreeImage_MaskedCombine32Ex -+ added 16-bit bitmap support to FreeImage_Mirror -+ added 16-bit bitmap support to FreeImage_ConvertTo8Bits -+ added simple version of FreeImage_MaskedCombine24 -+ added simple version of FreeImage_MaskedCombine32 - -October 17th 2000 - 1.4.1 -* [Herve Drolon] fixed bug in FreeImage_ConvertTo8Bits -* fixed bug in conversion with 16 -> 24 and 16 -> 32 -- removed static library support -- removed all unnecessary files from LibTIFF, LibPNG, LibJPEG and ZLib -- removed all absolute seeks from the library -! FreeImageQt now makes use of the DLL distro -! rebuilt the entire directory structure -! improved handling of BMP -! renamed FreeImage_MaskedCombine to FreeImage_MaskedCombine32 -+ [Alexander Dymerets] added 24-bit masked alpha blending with a seperate alpha mask -+ added FreeImage_Rotate (known bug in degrees 76 to 106) -+ added 4-bit bitmap support to FreeImage_ConvertTo16Bits -+ added 8-bit bitmap support to FreeImage_ConvertTo16Bits -+ added 32-bit bitmap support to FreeImage_ConvertTo16Bits -+ added 32-bit bitmap support to FreeImage_Mirror -+ added 16-bit 5-5-5 support to FreeImage_ConvertTo24Bits -+ added 16-bit 5-5-5 support to FreeImage_ConvertTo32Bits - -October 2th 2000 - 1.4.0 -* [Jani Kajala] fixed bug in conversion with 4 -> 24 and 8 -> 32 -* [Jani Kajala] fixed bug in FreeImage_Flip -* [Jani Kajala] fixed minor bug in FreeImage_LoadBMP -- [Herve Drolon] removed PBMFlags, PGMFlags and PPMFlags -- [Herve Drolon] removed FI_LoadGeneric -- removed FreeImage_Win32.h -! [Herve Drolon] changed FI_GetFileType -! [Herve Drolon] replaced FI_LoadPBM, FI_LoadPGM and FI_LoadPPM with FI_LoadPNM -! [Herve Drolon] improved FreeImage_LoadPNG -! FreeImage_WritePaletteEntry is now exported -+ [Herve Drolon] added FreeImage_SavePNG -+ [Herve Drolon] added FreeImage_SavePNM and PNMFlags -+ [Herve Drolon] added XXXFlags parameter to save functions -+ [Herve Drolon] added FreeImage_LoadRAS and FIF_RAS -+ added FreeImage_GetFileTypeFromExt - -September 7th 2000 - 1.3.5 -+ added conversion 4 -> 8 to FI_ConvertTo8Bits -+ added simple version of FI_GetFileType -+ added project FreeImageQt; a port of the library to the TrollTech library - -August 31th 2000 - 1.3.4 -* fixed 'ice effect' bug in new 24 bit PCX code -* fixed some bugs with the conversion 16 -> 24 and 16 -> 32 -! FI_Blur now returns void -! A debug build of the library now produces FreeImaged.dll and FreeImaged.lib -! TARGA_LOAD_ARGB8888 is now called TARGA_LOAD_RGB888 -! Alpha channels are now automatically loaded unless TARGA_LOAD_RGB888 is specified -! cleaned up the code a lot -+ added 32-bit bitmap support to FreeImage_ConvertToGreyscale -+ added support for 32-bit bottom-left TARGA images -+ added internal functions FreeImage_WritePaletteEntry() and FreeImage_GetScanLine() -+ added FreeImage_Win32.h, containing Windows functions needed to create DIBs -+ added documentation through Doxygen - -July 30th 2000 - 1.3.3 -* [Jani Kajala] fixed some bugs with the conversion 4 -> 24 and 8 -> 24 -* [Jani Kajala] fixed some bugs with the conversion 4 -> 32 and 8 -> 32 -* fixed bug in FI_LoadPNM's ASCII number loader -! [Herve Drolon] improved FI_LoadPNG -! [Herve Drolon] changed FI_ConvertToGreyScale (added changeable macro for conversion) -! improved FI_ConvertTo24Bits -! improved FI_ConvertTo32Bits -! freeImage now uses LibPNG 1.0.8 -+ [Herve Drolon] added FI_ColorQuantize, based on Wu's color quantizer -+ added the conversion 1 -> 24 -+ added the conversion 1 -> 32 -+ added FI_ConvertTo8Bits -+ added FI_Invert (very useful for image processing) -+ added FI_GetColorType and 'enum FREE_IMAGE_COLOR_TYPE' - -June 30th 2000 - 1.3.2 -- removed color reduction functions from the project -! [Herve Drolon] Improved FI_LoadTIFF code -! renamed FI_ToGrayscale to FI_ConvertToGreyScale -! renamed FI_IncreaseColors to FI_ConvertTo24Bits -! LoadBMP now supports 32-bit bitmaps -! [Jani Kajala] Improved FI_LoadTARGA and FI_LoadPCX code -+ added FI_ConvertTo32Bits to convert a bitmap to 32-bit -+ added FI_MaskCombine to combine two 32-bit bitmaps using a alpha mask -+ added FI_AddAlphaMask to enrich a 32-bit bitmap with an alpha mask -+ added FI_SaveTIFF -+ added 16-bit bitmap (565) support to the ConvertToXXX functions. -+ added FI_ConvertTo16Bits (555 and 565) - -June 1th 2000 - 1.3.1 -- removed Standard Template Library (STL) code -* [Jani Kajala] fixed minor bug in FI_LoadTARGA -* [Jani Kajala] fixed some minor bugs in FI_LoadPCX -! streamlined FI_LoadJPEG a little -! FreeImage now uses LibPNG 1.0.6 -! FreeImage now uses LibTIFF 3.5.5 -! FreeImage now uses malloc and free instead of new and delete -+ introduced compiler flags to disable certain features in the DLL -+ added experimental nearest color reduction (FI_ReduceColorsNearestColor) - -April 13th 2000 - 1.3.0 -* fixed some 8 bit PCX files loading incorrectly -* fixed tiny bug in internally used CalculateUsedColors function -- removed FI_SaveXPM. Only BMP is supported now. -- removed Windows dependencies for easier porting -! optimized FI_LoadKOALA a little -! optimized FI_Combine using MMX technology -! FI_Combine now receives an 'unsigned integer' as alpha blend parameter -! FI_InCreaseColors and FI_ReduceColors don't dispose the old bitmap anymore -+ added PNM support (PGM, PPM and PBM; both binary and ascii) -+ [Alexander Dymerets] added FI_EnableMMX and FI_DisableMMX -+ added various effect functions (FI_Blur, FI_Brighten and FI_Crop) - -March 1st 2000 - 1.2.1 -* fixed some 24 bit PCX files loading incorrectly - -February 8th 2000 - 1.2.0 -* fixed last bitmap data block in JPEG files being truncated -* fixed 4/8 bit BMP's incorrectly loading when the palette is smaller than the bitcount predicts -- removed FI_Load. There is no reliable way to identify all image formats -- removed FI_SetJpegDecodeMode. - Mode selection is now done using the 'DataEnum data' parameter of FI_LoadJPEG -! read_proc/write_proc/tell_proc in FreeImageIO now are same as fread/fwrite/ftell -+ added a 'DataEnum data' parameter to all FI_LoadXXX functions. -+ added 16 bit TARGA support -+ added RLE support for TARGA images -+ added FI_GetDIBSize to get the size of a DIB in bytes -+ added Kodak PhotoCD support (Base, Base/4 and Base/16 encoding) -+ added KOALA support -+ added FI_GetFileType. Note: there is no reliable way to identify TARGA, ICO and PCD. Therefore they have been excluded -In KOALA files only the files converted by a C64 emulator can be identified. -+ added FI_Combine to combine two 24-bit bitmaps with (optional) alpha blending - -January 15th 2000 - 1.1.1 -! FI_Copy is now called FI_Clone -+ added FI_ToGrayscale to convert a color bitmap to grayscale -+ added 32 bit TARGA support -+ added FI_IncreaseColors to increase the bitmap bitdepth from 4/8 bit to 24 bit - -January 14th 2000 - 1.1.0 -* FI_MIRROR: fixed nibbles not being mirrored in 4 bit images -* FI_MIRROR: fixed bits not being mirrored in 1 bit images -* fixed improper loading of 1, 4 and 8 bit OS/2 BMP's -* fixed some inconsistensies in the calculation of lines and pitches -* fixed incorrectly loading of Huffman and FAX encoded TIFFs -* fixed LoadTGA accepting 16 bit TGA's and returning corrupt DIB's -- removed LZW support for TIFFs -! FreeImage now uses LibTIFF 3.5.4 -+ added ICO support -+ added overridable file I/O support in the form of FreeImageIO and fi_handle -+ added FI_Load for generic image loading -+ added FI_ReduceColors for color reduction -+ added FI_Copy to copy a bitmap in memory - -January 5th 2000 - 1.0.0 diff --git a/freeimage241/archive.bat b/freeimage241/archive.bat deleted file mode 100644 index 7ec461f..0000000 --- a/freeimage241/archive.bat +++ /dev/null @@ -1 +0,0 @@ -C:\TOOLS\JAR32 a -m4 -r FreeImage diff --git a/freeimage241/clean.bat b/freeimage241/clean.bat deleted file mode 100644 index 19089e4..0000000 --- a/freeimage241/clean.bat +++ /dev/null @@ -1,43 +0,0 @@ -rd Release /s -rd Debug /s -rd Source\FreeImageQt\Release /s -rd Source\FreeImageQt\Debug /s -rd Source\Source\Release /s -rd Source\Source\Debug /s -rd Source\LibJPEG\Debug /s -rd Source\LibJPEG\Release /s -rd Source\LibPNG\Debug /s -rd Source\LibPNG\Release /s -rd Source\LibMNG\Debug /s -rd Source\LibMNG\Release /s -rd Source\LibTIFF\Debug /s -rd Source\LibTIFF\Release /s -rd Source\Zlib\Debug /s -rd Source\Zlib\Release /s -rd Source\Test\Debug /s -rd Source\Test\Release /s -del Source\Test\FreeImage*.* -del Source\Test\*.txt -del Dist\*.* -del *.pch /s -del *.ncb /s -del *.obj /s -del *.dll /s -del *.exe /s -del *.bsc /s -del *.bak /s -del *.pdb /s -del *.sql /s -del *.mdb /s -del *.lib /s -del *.exp /s -del *.ilk /s -del *.bmp /s -del *.tga /s -del *.tif /s -del *.tiff /s -del *.ras /s -del *.jpg /s -del *.koa /s -del *.fip /s -del *.pyd /s diff --git a/freeimage241/license-gpl.txt b/freeimage241/license-gpl.txt deleted file mode 100644 index 1bcc46f..0000000 --- a/freeimage241/license-gpl.txt +++ /dev/null @@ -1,342 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. - - diff --git a/gxruntime/GraphicsRuntime.h b/gxruntime/GraphicsRuntime.h new file mode 100644 index 0000000..aabca7e --- /dev/null +++ b/gxruntime/GraphicsRuntime.h @@ -0,0 +1,45 @@ +#pragma once +// Direct Draw +#define DIRECTDRAW_VERSION 0x0700 +#include + +// Direct3D +#define DIRECT3D_VERSION 0x0700 +#include + +// Direct Input +#define DIRECTINPUT_VERSION 0x0800 +#include + +// Redefine GUIDs +DEFINE_GUID(CLSID_DirectDraw, 0xD7B70EE0, 0x4340, 0x11CF, 0xB0, 0x63, 0x00, 0x20, 0xAF, 0xC2, 0xCD, 0x35); +DEFINE_GUID(CLSID_DirectDraw7, 0x3c305196, 0x50db, 0x11d3, 0x9c, 0xfe, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5); +DEFINE_GUID(CLSID_DirectDrawClipper, 0x593817A0, 0x7DB3, 0x11CF, 0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xb9, 0x33, 0x56); +DEFINE_GUID(IID_IDirectDraw, 0x6C14DB80, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); +DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0, 0x2B43, 0x11CF, 0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56); +DEFINE_GUID(IID_IDirectDraw4, 0x9c59509a, 0x39bd, 0x11d1, 0x8c, 0x4a, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5); +DEFINE_GUID(IID_IDirectDraw7, 0x15e65ec0, 0x3b9c, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b); +DEFINE_GUID(IID_IDirectDrawSurface, 0x6C14DB81, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); +DEFINE_GUID(IID_IDirectDrawSurface2, 0x57805885, 0x6eec, 0x11cf, 0x94, 0x41, 0xa8, 0x23, 0x03, 0xc1, 0x0e, 0x27); +DEFINE_GUID(IID_IDirectDrawSurface3, 0xDA044E00, 0x69B2, 0x11D0, 0xA1, 0xD5, 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xBB); +DEFINE_GUID(IID_IDirectDrawSurface4, 0x0B2B8630, 0xAD35, 0x11D0, 0x8E, 0xA6, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x5B); +DEFINE_GUID(IID_IDirectDrawSurface7, 0x06675a80, 0x3b9b, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b); +DEFINE_GUID(IID_IDirectDrawPalette, 0x6C14DB84, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); +DEFINE_GUID(IID_IDirectDrawClipper, 0x6C14DB85, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); +DEFINE_GUID(IID_IDirectDrawColorControl, 0x4B9F0EE0, 0x0D7E, 0x11D0, 0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8); +DEFINE_GUID(IID_IDirectDrawGammaControl, 0x69C11C3E, 0xB46B, 0x11D1, 0xAD, 0x7A, 0x00, 0xC0, 0x4F, 0xC2, 0x9B, 0x4E); +DEFINE_GUID(CLSID_AMMultiMediaStream, 0x49c47ce5, 0x9ba4, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); +DEFINE_GUID(CLSID_AMDirectDrawStream, 0x49c47ce4, 0x9ba4, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); +DEFINE_GUID(CLSID_AMAudioStream, 0x8496e040, 0xaf4c, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); +DEFINE_GUID(CLSID_AMAudioData, 0xf2468580, 0xaf8a, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); +DEFINE_GUID(CLSID_AMMediaTypeStream, 0xcf0f2f7c, 0xf7bf, 0x11d0, 0x90, 0xd, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d); +DEFINE_GUID(MSPID_PrimaryVideo, 0xa35ff56a, 0x9fda, 0x11d0, 0x8f, 0xdf, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d); +DEFINE_GUID(MSPID_PrimaryAudio, 0xa35ff56b, 0x9fda, 0x11d0, 0x8f, 0xdf, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d); +DEFINE_GUID(IID_IDirect3D7, 0xf5049e77, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); +DEFINE_GUID(IID_IDirect3DRampDevice, 0xF2086B20, 0x259F, 0x11CF, 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56); +DEFINE_GUID(IID_IDirect3DRGBDevice, 0xA4665C60, 0x2673, 0x11CF, 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56); +DEFINE_GUID(IID_IDirect3DHALDevice, 0x84E63dE0, 0x46AA, 0x11CF, 0x81, 0x6F, 0x00, 0x00, 0xC0, 0x20, 0x15, 0x6E); +DEFINE_GUID(IID_IDirect3DMMXDevice, 0x881949a1, 0xd6f3, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29); +DEFINE_GUID(IID_IDirect3DRefDevice, 0x50936643, 0x13e9, 0x11d1, 0x89, 0xaa, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); +DEFINE_GUID(IID_IDirect3DNullDevice, 0x8767df22, 0xbacc, 0x11d1, 0x89, 0x69, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); +DEFINE_GUID(IID_IDirect3DTnLHalDevice, 0xf5049e78, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); diff --git a/gxruntime/ddutil.cpp b/gxruntime/ddutil.cpp index 133cfcf..6688fa6 100644 --- a/gxruntime/ddutil.cpp +++ b/gxruntime/ddutil.cpp @@ -1,4 +1,5 @@ +#include "GraphicsRuntime.h" #include "std.h" #include "ddutil.h" #include "asmcoder.h" @@ -7,321 +8,327 @@ extern gxRuntime *gx_runtime; -#include "..\freeimage241\source\freeimage.h" +#include "..\#ThirdParty\FreeImage\Dist\x32\freeimage.h" static AsmCoder asm_coder; -static void calcShifts( unsigned mask,unsigned char *shr,unsigned char *shl ){ - if( mask ){ - for( *shl=0;!(mask&1);++*shl,mask>>=1 ){} - for( *shr=8;mask&1;--*shr,mask>>=1 ){} - }else *shr=*shl=0; +static void calcShifts(unsigned mask, unsigned char *shr, unsigned char *shl) { + if (mask) { + for (*shl = 0; !(mask & 1); ++*shl, mask >>= 1) {} + for (*shr = 8; mask & 1; --*shr, mask >>= 1) {} + } else *shr = *shl = 0; } -PixelFormat::~PixelFormat(){ - if( plot_code ){ - VirtualFree( plot_code,0,MEM_RELEASE ); +PixelFormat::~PixelFormat() { + if (plot_code) { + VirtualFree(plot_code, 0, MEM_RELEASE); } } -void PixelFormat::setFormat( const DDPIXELFORMAT &pf ){ - if( plot_code ){ - VirtualFree( plot_code,0,MEM_RELEASE ); +void PixelFormat::setFormat(const DDPIXELFORMAT &pf) { + if (plot_code) { + VirtualFree(plot_code, 0, MEM_RELEASE); } - if( !(pf.dwFlags & DDPF_RGB) ){ - memset( this,0,sizeof(*this) ); + if (!(pf.dwFlags & DDPF_RGB)) { + memset(this, 0, sizeof(*this)); return; } - plot_code=(char*)VirtualAlloc( 0,128,MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE ); - point_code=plot_code+64; + plot_code = (char*)VirtualAlloc(0, 128, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); + point_code = plot_code + 64; - depth=pf.dwRGBBitCount; - amask=pf.dwRGBAlphaBitMask; - rmask=pf.dwRBitMask; - gmask=pf.dwGBitMask; - bmask=pf.dwBBitMask; - pitch=depth/8;argbfill=0; - if( !amask ) argbfill|=0xff000000; - if( !rmask ) argbfill|=0x00ff0000; - if( !gmask ) argbfill|=0x0000ff00; - if( !bmask ) argbfill|=0x000000ff; - calcShifts( amask,&ashr,&ashl );ashr+=24; - calcShifts( rmask,&rshr,&rshl );rshr+=16; - calcShifts( gmask,&gshr,&gshl );gshr+=8; - calcShifts( bmask,&bshr,&bshl ); - plot=(Plot)(void*)plot_code; - point=(Point)(void*)point_code; - asm_coder.CodePlot( plot_code,depth,amask,rmask,gmask,bmask ); - asm_coder.CodePoint( point_code,depth,amask,rmask,gmask,bmask ); + depth = pf.dwRGBBitCount; + amask = pf.dwRGBAlphaBitMask; + rmask = pf.dwRBitMask; + gmask = pf.dwGBitMask; + bmask = pf.dwBBitMask; + pitch = depth / 8; argbfill = 0; + if (!amask) argbfill |= 0xff000000; + if (!rmask) argbfill |= 0x00ff0000; + if (!gmask) argbfill |= 0x0000ff00; + if (!bmask) argbfill |= 0x000000ff; + calcShifts(amask, &ashr, &ashl); ashr += 24; + calcShifts(rmask, &rshr, &rshl); rshr += 16; + calcShifts(gmask, &gshr, &gshl); gshr += 8; + calcShifts(bmask, &bshr, &bshl); + plot = (Plot)(void*)plot_code; + point = (Point)(void*)point_code; + asm_coder.CodePlot(plot_code, depth, amask, rmask, gmask, bmask); + asm_coder.CodePoint(point_code, depth, amask, rmask, gmask, bmask); } -static void adjustTexSize( int *width,int *height,IDirect3DDevice7 *dir3dDev ){ - D3DDEVICEDESC7 ddDesc={0}; - if( dir3dDev->GetCaps( &ddDesc )<0 ){ - *width=*height=256; +static void adjustTexSize(int *width, int *height, IDirect3DDevice7 *dir3dDev) { + D3DDEVICEDESC7 ddDesc = { 0 }; + if (dir3dDev->GetCaps(&ddDesc) < 0) { + *width = *height = 256; return; } - int w=*width,h=*height,min,max; + int w = *width, h = *height, min, max; //make power of 2 //Try *always* making POW2 size to fix GF6800 non-pow2 tex issue // if( ddDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2 ){ - for( w=1;w<*width;w<<=1 ){} - for( h=1;h<*height;h<<=1 ){} -// } - //make square - if( ddDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ){ - if( w>h ) h=w; - else w=h; + for (w = 1; w < *width; w <<= 1) {} + for (h = 1; h < *height; h <<= 1) {} + // } + //make square + if (ddDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY) { + if (w > h) h = w; + else w = h; } //check aspect ratio - if( max=ddDesc.dwMaxTextureAspectRatio ){ - int asp=w>h ? w/h : h/w; - if( asp>max ){ - if( w>h ) h=w/max; - else w=h/max; + if (max = ddDesc.dwMaxTextureAspectRatio) { + int asp = w > h ? w / h : h / w; + if (asp > max) { + if (w > h) h = w / max; + else w = h / max; } } //clamp size - if( (min=ddDesc.dwMinTextureWidth) && wmax ) w=max; - if( (max=ddDesc.dwMaxTextureHeight) && h>max ) h=max; + if ((min = ddDesc.dwMinTextureWidth) && w < min) w = min; + if ((min = ddDesc.dwMinTextureHeight) && h < min) h = min; + if ((max = ddDesc.dwMaxTextureWidth) && w > max) w = max; + if ((max = ddDesc.dwMaxTextureHeight) && h > max) h = max; - *width=w;*height=h; + *width = w; *height = h; } -static ddSurf *createSurface( int width,int height,int pitch,void *bits,IDirectDraw7 *dirDraw ){ - DDSURFACEDESC2 desc={sizeof(desc)}; - desc.dwFlags=DDSD_WIDTH|DDSD_HEIGHT|DDSD_LPSURFACE|DDSD_PITCH|DDSD_PIXELFORMAT|DDSD_CAPS; - desc.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY; - desc.dwWidth=width;desc.dwHeight=height; - desc.lPitch=pitch;desc.lpSurface=bits; - desc.ddpfPixelFormat.dwSize=sizeof(DDPIXELFORMAT); - desc.ddpfPixelFormat.dwFlags=DDPF_RGB|DDPF_ALPHAPIXELS; - desc.ddpfPixelFormat.dwRGBBitCount=32; - desc.ddpfPixelFormat.dwRBitMask=0xff0000; - desc.ddpfPixelFormat.dwGBitMask=0x00ff00; - desc.ddpfPixelFormat.dwBBitMask=0x0000ff; - desc.ddpfPixelFormat.dwRGBAlphaBitMask=0xff000000; +static ddSurf *createSurface(int width, int height, int pitch, void *bits, IDirectDraw7 *dirDraw) { + DDSURFACEDESC2 desc = { sizeof(desc) }; + desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT | DDSD_CAPS; + desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + desc.dwWidth = width; desc.dwHeight = height; + desc.lPitch = pitch; desc.lpSurface = bits; + desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); + desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; + desc.ddpfPixelFormat.dwRGBBitCount = 32; + desc.ddpfPixelFormat.dwRBitMask = 0xff0000; + desc.ddpfPixelFormat.dwGBitMask = 0x00ff00; + desc.ddpfPixelFormat.dwBBitMask = 0x0000ff; + desc.ddpfPixelFormat.dwRGBAlphaBitMask = 0xff000000; ddSurf *surf; - if( dirDraw->CreateSurface( &desc,&surf,0 )>=0 ) return surf; + if (dirDraw->CreateSurface(&desc, &surf, 0) >= 0) return surf; return 0; } -static void buildMask( ddSurf *surf ){ - DDSURFACEDESC2 desc={sizeof(desc)}; - surf->Lock( 0,&desc,DDLOCK_WAIT,0 ); - unsigned char *surf_p=(unsigned char*)desc.lpSurface; - PixelFormat fmt( desc.ddpfPixelFormat ); +static void buildMask(ddSurf *surf) { + DDSURFACEDESC2 desc = { sizeof(desc) }; + surf->Lock(0, &desc, DDLOCK_WAIT, 0); + unsigned char *surf_p = (unsigned char*)desc.lpSurface; + PixelFormat fmt(desc.ddpfPixelFormat); - for( int y=0;yUnlock( 0 ); + surf->Unlock(0); } -static void buildAlpha( ddSurf *surf,bool whiten ){ +static void buildAlpha(ddSurf *surf, bool whiten) { - DDSURFACEDESC2 desc={sizeof(desc)}; - surf->Lock( 0,&desc,DDLOCK_WAIT,0 ); - unsigned char *surf_p=(unsigned char*)desc.lpSurface; - PixelFormat fmt( desc.ddpfPixelFormat ); + DDSURFACEDESC2 desc = { sizeof(desc) }; + surf->Lock(0, &desc, DDLOCK_WAIT, 0); + unsigned char *surf_p = (unsigned char*)desc.lpSurface; + PixelFormat fmt(desc.ddpfPixelFormat); - for( int y=0;y>16)&0xff)+((argb>>8)&0xff)+(argb&0xff))/3; - argb=(alpha<<24) | (argb & 0xffffff); - if( whiten ) argb|=0xffffff; - fmt.setPixel( p,argb ); - p+=fmt.getPitch(); + for (int y = 0; y < desc.dwHeight; ++y) { + unsigned char *p = surf_p; + for (int x = 0; x < desc.dwWidth; ++x) { + unsigned argb = fmt.getPixel(p); + unsigned alpha = (((argb >> 16) & 0xff) + ((argb >> 8) & 0xff) + (argb & 0xff)) / 3; + argb = (alpha << 24) | (argb & 0xffffff); + if (whiten) argb |= 0xffffff; + fmt.setPixel(p, argb); + p += fmt.getPitch(); } - surf_p+=desc.lPitch; + surf_p += desc.lPitch; } - surf->Unlock( 0 ); + surf->Unlock(0); } -void ddUtil::buildMipMaps( ddSurf *surf ){ +void ddUtil::buildMipMaps(ddSurf *surf) { - DDSURFACEDESC2 desc={sizeof(desc)}; - surf->GetSurfaceDesc( &desc ); - if( !(desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) ) return; - if( !(desc.ddpfPixelFormat.dwFlags & DDPF_RGB) ) return; + DDSURFACEDESC2 desc = { sizeof(desc) }; + surf->GetSurfaceDesc(&desc); + if (!(desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE)) return; + if (!(desc.ddpfPixelFormat.dwFlags & DDPF_RGB)) return; - DDSCAPS2 caps={0}; - caps.dwCaps=DDSCAPS_TEXTURE; - caps.dwCaps2=DDSCAPS2_MIPMAPSUBLEVEL; + DDSCAPS2 caps = { 0 }; + caps.dwCaps = DDSCAPS_TEXTURE; + caps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL; - IDirectDrawSurface7 *src=surf,*dest; + IDirectDrawSurface7 *src = surf, *dest; - while( src->GetAttachedSurface( &caps,&dest )>=0 ){ + while (src->GetAttachedSurface(&caps, &dest) >= 0) { - DDSURFACEDESC2 src_desc={sizeof(src_desc)}; - if( src->Lock( 0,&src_desc,DDLOCK_WAIT,0 )<0 ) abort(); - unsigned char *src_p=(unsigned char*)src_desc.lpSurface; - PixelFormat src_fmt( src_desc.ddpfPixelFormat ); + DDSURFACEDESC2 src_desc = { sizeof(src_desc) }; + if (src->Lock(0, &src_desc, DDLOCK_WAIT, 0) < 0) abort(); + unsigned char *src_p = (unsigned char*)src_desc.lpSurface; + PixelFormat src_fmt(src_desc.ddpfPixelFormat); - DDSURFACEDESC2 dest_desc={sizeof(dest_desc)}; - if( dest->Lock( 0,&dest_desc,DDLOCK_WAIT,0 )<0 ) abort(); - unsigned char *dest_p=(unsigned char *)dest_desc.lpSurface; - PixelFormat dest_fmt( dest_desc.ddpfPixelFormat ); + DDSURFACEDESC2 dest_desc = { sizeof(dest_desc) }; + if (dest->Lock(0, &dest_desc, DDLOCK_WAIT, 0) < 0) abort(); + unsigned char *dest_p = (unsigned char *)dest_desc.lpSurface; + PixelFormat dest_fmt(dest_desc.ddpfPixelFormat); - if( src_desc.dwWidth==1 ){ - for( int y=0;y>1)+((p2&0xfefefefe)>>1); - argb+=( ( - (p1&0x01010101)+(p2&0x01010101) )>>1 ) & 0x01010101; - dest_fmt.setPixel( dest_p,argb ); - src_p+=src_desc.lPitch*2; - dest_p+=dest_desc.lPitch; + if (src_desc.dwWidth == 1) { + for (int y = 0; y < dest_desc.dwHeight; ++y) { + unsigned p1 = src_fmt.getPixel(src_p); + unsigned p2 = src_fmt.getPixel(src_p + src_desc.lPitch); + unsigned argb = + ((p1 & 0xfefefefe) >> 1) + ((p2 & 0xfefefefe) >> 1); + argb += (( + (p1 & 0x01010101) + (p2 & 0x01010101)) >> 1) & 0x01010101; + dest_fmt.setPixel(dest_p, argb); + src_p += src_desc.lPitch * 2; + dest_p += dest_desc.lPitch; } - }else if( src_desc.dwHeight==1 ){ - for( int x=0;x>1)+((p2&0xfefefefe)>>1); - argb+=( ( - (p1&0x01010101)+(p2&0x01010101) )>>1 ) & 0x01010101; - dest_fmt.setPixel( dest_p,argb ); - src_p+=src_fmt.getPitch()*2; - dest_p+=dest_fmt.getPitch(); + } else if (src_desc.dwHeight == 1) { + for (int x = 0; x < dest_desc.dwWidth; ++x) { + unsigned p1 = src_fmt.getPixel(src_p); + unsigned p2 = src_fmt.getPixel(src_p + src_fmt.getPitch()); + unsigned argb = + ((p1 & 0xfefefefe) >> 1) + ((p2 & 0xfefefefe) >> 1); + argb += (( + (p1 & 0x01010101) + (p2 & 0x01010101)) >> 1) & 0x01010101; + dest_fmt.setPixel(dest_p, argb); + src_p += src_fmt.getPitch() * 2; + dest_p += dest_fmt.getPitch(); } - }else{ - for( int y=0;y>2)+((p2&0xfcfcfcfc)>>2)+ - ((p3&0xfcfcfcfc)>>2)+((p4&0xfcfcfcfc)>>2); - argb+=( ( - (p1&0x03030303)+(p2&0x03030303)+ - (p3&0x03030303)+(p4&0x03030303) )>>2 ) & 0x03030303; + unsigned argb = + ((p1 & 0xfcfcfcfc) >> 2) + ((p2 & 0xfcfcfcfc) >> 2) + + ((p3 & 0xfcfcfcfc) >> 2) + ((p4 & 0xfcfcfcfc) >> 2); + argb += (( + (p1 & 0x03030303) + (p2 & 0x03030303) + + (p3 & 0x03030303) + (p4 & 0x03030303)) >> 2) & 0x03030303; - dest_fmt.setPixel( dest_t,argb ); - src_t+=src_fmt.getPitch()*2; - dest_t+=dest_fmt.getPitch(); + dest_fmt.setPixel(dest_t, argb); + src_t += src_fmt.getPitch() * 2; + dest_t += dest_fmt.getPitch(); } - src_p+=src_desc.lPitch*2; - dest_p+=dest_desc.lPitch; + src_p += src_desc.lPitch * 2; + dest_p += dest_desc.lPitch; } } - src->Unlock( 0 ); - dest->Unlock( 0 ); + src->Unlock(0); + dest->Unlock(0); dest->Release(); - src=dest; + src = dest; } } -void ddUtil::copy( ddSurf *dest,int dx,int dy,int dw,int dh,ddSurf *src,int sx,int sy,int sw,int sh ){ +void ddUtil::copy(ddSurf *dest, int dx, int dy, int dw, int dh, ddSurf *src, int sx, int sy, int sw, int sh) { - DDSURFACEDESC2 src_desc={sizeof(src_desc)}; - src->Lock( 0,&src_desc,DDLOCK_WAIT,0 ); - PixelFormat src_fmt( src_desc.ddpfPixelFormat ); - unsigned char *src_p=(unsigned char*)src_desc.lpSurface; - src_p+=src_desc.lPitch*sy+src_fmt.getPitch()*sx; + DDSURFACEDESC2 src_desc = { sizeof(src_desc) }; + src->Lock(0, &src_desc, DDLOCK_WAIT, 0); + PixelFormat src_fmt(src_desc.ddpfPixelFormat); + unsigned char *src_p = (unsigned char*)src_desc.lpSurface; + src_p += src_desc.lPitch*sy + src_fmt.getPitch()*sx; - DDSURFACEDESC2 dest_desc={sizeof(dest_desc)}; - dest->Lock( 0,&dest_desc,DDLOCK_WAIT,0 ); - PixelFormat dest_fmt( dest_desc.ddpfPixelFormat ); - unsigned char *dest_p=(unsigned char *)dest_desc.lpSurface; - dest_p+=dest_desc.lPitch*dy+dest_fmt.getPitch()*dx; + DDSURFACEDESC2 dest_desc = { sizeof(dest_desc) }; + dest->Lock(0, &dest_desc, DDLOCK_WAIT, 0); + PixelFormat dest_fmt(dest_desc.ddpfPixelFormat); + unsigned char *dest_p = (unsigned char *)dest_desc.lpSurface; + dest_p += dest_desc.lPitch*dy + dest_fmt.getPitch()*dx; - for( int y=0;yUnlock( 0 ); - dest->Unlock( 0 ); + src->Unlock(0); + dest->Unlock(0); } -ddSurf *ddUtil::createSurface( int w,int h,int flags,gxGraphics *gfx ){ +ddSurf *ddUtil::createSurface(int w, int h, int flags, gxGraphics *gfx) { - DDSURFACEDESC2 desc={sizeof(desc)}; + DDSURFACEDESC2 desc = { sizeof(desc) }; - desc.dwFlags=DDSD_CAPS; + desc.dwFlags = DDSD_CAPS; - int hi=flags & gxCanvas::CANVAS_TEX_HICOLOR?1:0; + int hi = flags & gxCanvas::CANVAS_TEX_HICOLOR ? 1 : 0; - if( w ){ desc.dwWidth=w;desc.dwFlags|=DDSD_WIDTH; } - if( h ){ desc.dwHeight=h;desc.dwFlags|=DDSD_HEIGHT; } + if (w) { desc.dwWidth = w; desc.dwFlags |= DDSD_WIDTH; } + if (h) { desc.dwHeight = h; desc.dwFlags |= DDSD_HEIGHT; } - if( flags & gxCanvas::CANVAS_TEX_MASK ){ - desc.dwFlags|=DDSD_PIXELFORMAT; - desc.ddpfPixelFormat=gfx->texRGBMaskFmt[hi]; - }else if( flags & gxCanvas::CANVAS_TEX_RGB ){ - desc.dwFlags|=DDSD_PIXELFORMAT; - desc.ddpfPixelFormat=(flags&gxCanvas::CANVAS_TEX_ALPHA)?gfx->texRGBAlphaFmt[hi]:gfx->texRGBFmt[hi]; - }else if( flags & gxCanvas::CANVAS_TEX_ALPHA ){ - desc.dwFlags|=DDSD_PIXELFORMAT; - desc.ddpfPixelFormat=gfx->texAlphaFmt[hi]; - }else if( flags & gxCanvas::CANVAS_TEXTURE ){ - desc.dwFlags|=DDSD_PIXELFORMAT; - desc.ddpfPixelFormat=gfx->primFmt; + if (flags & gxCanvas::CANVAS_TEX_MASK) { + desc.dwFlags |= DDSD_PIXELFORMAT; + desc.ddpfPixelFormat = gfx->texRGBMaskFmt[hi]; + } else if (flags & gxCanvas::CANVAS_TEX_RGB) { + desc.dwFlags |= DDSD_PIXELFORMAT; + desc.ddpfPixelFormat = (flags&gxCanvas::CANVAS_TEX_ALPHA) ? gfx->texRGBAlphaFmt[hi] : gfx->texRGBFmt[hi]; + } else if (flags & gxCanvas::CANVAS_TEX_ALPHA) { + desc.dwFlags |= DDSD_PIXELFORMAT; + desc.ddpfPixelFormat = gfx->texAlphaFmt[hi]; + } else if (flags & gxCanvas::CANVAS_TEXTURE) { + desc.dwFlags |= DDSD_PIXELFORMAT; + desc.ddpfPixelFormat = gfx->primFmt; } - if( flags & gxCanvas::CANVAS_TEXTURE ){ - desc.ddsCaps.dwCaps|=DDSCAPS_TEXTURE; - if( !(flags & gxCanvas::CANVAS_TEX_VIDMEM) ){ - desc.ddsCaps.dwCaps2|=DDSCAPS2_TEXTUREMANAGE; - if( flags & gxCanvas::CANVAS_TEX_MIPMAP ){ - desc.ddsCaps.dwCaps|=DDSCAPS_MIPMAP|DDSCAPS_COMPLEX; + + if (flags & gxCanvas::CANVAS_TEXTURE) { + desc.ddsCaps.dwCaps |= DDSCAPS_TEXTURE; + if (!(flags & gxCanvas::CANVAS_TEX_VIDMEM)) { + desc.ddsCaps.dwCaps2 |= DDSCAPS2_TEXTUREMANAGE; + if (flags & gxCanvas::CANVAS_TEX_MIPMAP) { + desc.ddsCaps.dwCaps |= DDSCAPS_MIPMAP | DDSCAPS_COMPLEX; } } - if( flags & (gxCanvas::CANVAS_TEX_CUBE) ){ - desc.ddsCaps.dwCaps|=DDSCAPS_COMPLEX; - desc.ddsCaps.dwCaps2|=DDSCAPS2_CUBEMAP|DDSCAPS2_CUBEMAP_ALLFACES; + if (flags & (gxCanvas::CANVAS_TEX_CUBE)) { + desc.ddsCaps.dwCaps |= DDSCAPS_COMPLEX; + desc.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_ALLFACES; } - adjustTexSize( (int*)&desc.dwWidth,(int*)&desc.dwHeight,gfx->dir3dDev ); - }else{ - desc.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN; - if( flags & gxCanvas::CANVAS_HIGHCOLOR ){ - desc.dwFlags|=DDSD_PIXELFORMAT; - desc.ddsCaps.dwCaps|=DDSCAPS_SYSTEMMEMORY; - desc.ddpfPixelFormat.dwSize=sizeof(DDPIXELFORMAT); - desc.ddpfPixelFormat.dwFlags=DDPF_RGB|DDPF_ALPHAPIXELS; - desc.ddpfPixelFormat.dwRGBBitCount=32; - desc.ddpfPixelFormat.dwRBitMask=0xff0000; - desc.ddpfPixelFormat.dwGBitMask=0x00ff00; - desc.ddpfPixelFormat.dwBBitMask=0x0000ff; - desc.ddpfPixelFormat.dwRGBAlphaBitMask=0xff000000; - }else if( flags & gxCanvas::CANVAS_NONDISPLAY ){ - desc.ddsCaps.dwCaps|=DDSCAPS_SYSTEMMEMORY; + adjustTexSize((int*)&desc.dwWidth, (int*)&desc.dwHeight, gfx->dir3dDev); + } else { + desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + if (flags & gxCanvas::CANVAS_HIGHCOLOR) { + desc.dwFlags |= DDSD_PIXELFORMAT; + desc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; + desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); + desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; + desc.ddpfPixelFormat.dwRGBBitCount = 32; + desc.ddpfPixelFormat.dwRBitMask = 0xff0000; + desc.ddpfPixelFormat.dwGBitMask = 0x00ff00; + desc.ddpfPixelFormat.dwBBitMask = 0x0000ff; + desc.ddpfPixelFormat.dwRGBAlphaBitMask = 0xff000000; + } else if (flags & gxCanvas::CANVAS_NONDISPLAY) { + desc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; } } + + if (flags & gxCanvas::CANVAS_3DRENDER) { + desc.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_LOCALVIDMEM; + } + ddSurf *surf; - if( gfx->dirDraw->CreateSurface( &desc,&surf,0 )>=0 ) return surf; - if( desc.ddsCaps.dwCaps & DDSCAPS_OFFSCREENPLAIN ){ - if( !(desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) ){ + if (gfx->dirDraw->CreateSurface(&desc, &surf, 0) >= 0) return surf; + if (desc.ddsCaps.dwCaps & DDSCAPS_OFFSCREENPLAIN) { + if (!(desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)) { //try again in system memory! - desc.ddsCaps.dwCaps|=DDSCAPS_SYSTEMMEMORY; - if( gfx->dirDraw->CreateSurface( &desc,&surf,0 )>=0 ) return surf; + desc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; + if (gfx->dirDraw->CreateSurface(&desc, &surf, 0) >= 0) return surf; } } return 0; @@ -329,8 +336,7 @@ ddSurf *ddUtil::createSurface( int w,int h,int flags,gxGraphics *gfx ){ //Tom Speed's DXTC loader // -IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx) -{ +IDirectDrawSurface7 *loadDXTC(const char* filename, gxGraphics *gfx) { HRESULT hr; DDSURFACEDESC2 ddsd; DDSURFACEDESC2 fileddsd; @@ -339,12 +345,11 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx) /* try to open the file */ fp = fopen(filename, "rb"); - if(!fp) return NULL; + if (!fp) return NULL; /* valid DDS? */ fread(magicID, 1, 4, fp); - if (strncmp(magicID, "DDS ", 4) != 0) - { + if (strncmp(magicID, "DDS ", 4) != 0) { fclose(fp); return NULL; } @@ -352,15 +357,14 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx) /* get the DXTC file surface description */ fread(&fileddsd, sizeof(DDSURFACEDESC2), 1, fp); - if (fileddsd.dwSize != sizeof(DDSURFACEDESC2)) - { + if (fileddsd.dwSize != sizeof(DDSURFACEDESC2)) { fclose(fp); return NULL; } /* copy the fileddsd before we manipulate it so you can get neccessary info you want about it later */ - memcpy(&ddsd, &fileddsd,sizeof(DDSURFACEDESC2)); + memcpy(&ddsd, &fileddsd, sizeof(DDSURFACEDESC2)); /* remove unwanted flags if they exist */ //not sure if this is needed, works without it though @@ -369,29 +373,27 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx) int blockSize = 0; int chunkSize = 0; - if(ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1) + if (ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1) blockSize = 8; // DXT1 - if(ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT3) + if (ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT3) blockSize = 16; // DXT3 - if(ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT5) + if (ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT5) blockSize = 16; // DXT5 /* if it isn't a format we support, exit */ - if (blockSize == 0) - { + if (blockSize == 0) { fclose(fp); return NULL; } /* add texture manage flag */ - ddsd.ddsCaps.dwCaps2|=DDSCAPS2_TEXTUREMANAGE; + ddsd.ddsCaps.dwCaps2 |= DDSCAPS2_TEXTUREMANAGE; /* Create the new DXTC surface using the DDSURFACEDESC2 we read in from the file */ IDirectDrawSurface7 * newSurf = NULL; hr = gfx->dirDraw->CreateSurface(&ddsd, &newSurf, NULL); - if(FAILED(hr)) - { + if (FAILED(hr)) { fclose(fp); return NULL; } @@ -399,8 +401,8 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx) /* Define what type of child surfaces we may wish to access, in this case MipMaps */ DDSCAPS2 mipmapddsd; - ZeroMemory(&mipmapddsd,sizeof(DDSCAPS2)); - mipmapddsd.dwCaps = DDSCAPS_TEXTURE|DDSCAPS_MIPMAP|DDSCAPS_COMPLEX; + ZeroMemory(&mipmapddsd, sizeof(DDSCAPS2)); + mipmapddsd.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP | DDSCAPS_COMPLEX; /* pointers used when iterating through mipmaps */ IDirectDrawSurface7 *topDDS = NULL; @@ -409,12 +411,10 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx) topDDS = newSurf; topDDS->AddRef(); - while(TRUE) - { + while (TRUE) { /* get a description of this surface */ - hr = topDDS->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL); - if(FAILED(hr)) - { + hr = topDDS->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL); + if (FAILED(hr)) { fclose(fp); topDDS->Release(); newSurf->Release(); @@ -423,11 +423,10 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx) } /* how big the raw data is for this surface */ - chunkSize = ((ddsd.dwWidth+3)/4) * ((ddsd.dwHeight+3)/4) * blockSize; + chunkSize = ((ddsd.dwWidth + 3) / 4) * ((ddsd.dwHeight + 3) / 4) * blockSize; /* read in the raw DXTC surface data */ - if(!fread(ddsd.lpSurface, chunkSize, 1, fp)) - { + if (!fread(ddsd.lpSurface, chunkSize, 1, fp)) { fclose(fp); topDDS->Release(); newSurf->Release(); @@ -438,9 +437,8 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx) /* Get next mipmap in chain, or exit the loop if there's no more */ - hr = topDDS->GetAttachedSurface(&mipmapddsd,&nextDDS); - if(FAILED(hr)) - { + hr = topDDS->GetAttachedSurface(&mipmapddsd, &nextDDS); + if (FAILED(hr)) { fclose(fp); topDDS->Release(); break; @@ -454,72 +452,72 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx) return newSurf; } -ddSurf *ddUtil::loadSurface( const std::string &f,int flags,gxGraphics *gfx ){ +ddSurf *ddUtil::loadSurface(const std::string &f, int flags, gxGraphics *gfx) { - int i=f.find( ".dds" ); - if( i!=string::npos && i+4==f.size() ){ + int i = f.find(".dds"); + if (i != string::npos && i + 4 == f.size()) { //dds file! - ddSurf *surf=loadDXTC( f.c_str(),gfx ); + ddSurf *surf = loadDXTC(f.c_str(), gfx); return surf; } FreeImage_Initialise(); - FREE_IMAGE_FORMAT fmt=FreeImage_GetFileType( f.c_str(),f.size() ); - if( fmt==FIF_UNKNOWN ){ - int n=f.find( "." );if( n==string::npos ) return 0; - fmt=FreeImage_GetFileTypeFromExt( f.substr(n+1).c_str() ); - if( fmt==FIF_UNKNOWN ) return 0; + FREE_IMAGE_FORMAT fmt = FreeImage_GetFileType(f.c_str(), f.size()); + if (fmt == FIF_UNKNOWN) { + int n = f.find("."); if (n == string::npos) return 0; + fmt = FreeImage_GetFileType(f.c_str()); + if (fmt == FIF_UNKNOWN) return 0; } - FIBITMAP *t_dib=FreeImage_Load( fmt,f.c_str(),0 ); - if( !t_dib ) return 0; + FIBITMAP *t_dib = FreeImage_Load(fmt, f.c_str(), 0); + if (!t_dib) return 0; - bool trans=FreeImage_GetBPP( t_dib )==32 || FreeImage_IsTransparent( t_dib ); + bool trans = FreeImage_GetBPP(t_dib) == 32 || FreeImage_IsTransparent(t_dib); - FIBITMAP *dib=FreeImage_ConvertTo32Bits( t_dib ); - - if( dib ) FreeImage_Unload( t_dib ); - else dib=t_dib; + FIBITMAP *dib = FreeImage_ConvertTo32Bits(t_dib); - int width=FreeImage_GetWidth(dib); - int height=FreeImage_GetHeight(dib); - int pitch=FreeImage_GetPitch(dib); - void *bits=FreeImage_GetBits(dib); + if (dib) FreeImage_Unload(t_dib); + else dib = t_dib; - ddSurf *src=::createSurface( width,height,pitch,bits,gfx->dirDraw ); - if( !src ){ - FreeImage_Unload( dib ); + int width = FreeImage_GetWidth(dib); + int height = FreeImage_GetHeight(dib); + int pitch = FreeImage_GetPitch(dib); + void *bits = FreeImage_GetBits(dib); + + ddSurf *src = ::createSurface(width, height, pitch, bits, gfx->dirDraw); + if (!src) { + FreeImage_Unload(dib); return 0; } - if( flags & gxCanvas::CANVAS_TEX_ALPHA ){ - if( flags & gxCanvas::CANVAS_TEX_MASK ){ - buildMask( src ); - }else if( !trans ){ - buildAlpha( src,(flags & gxCanvas::CANVAS_TEX_RGB)?false:true ); + if (flags & gxCanvas::CANVAS_TEX_ALPHA) { + if (flags & gxCanvas::CANVAS_TEX_MASK) { + buildMask(src); + } else if (!trans) { + buildAlpha(src, (flags & gxCanvas::CANVAS_TEX_RGB) ? false : true); } - }else{ - unsigned char *p=(unsigned char *)bits; - for( int k=0;kRelease(); - FreeImage_Unload( dib ); + FreeImage_Unload(dib); return 0; } - int t_w=width,t_h=height; - if( flags & gxCanvas::CANVAS_TEXTURE ) adjustTexSize( &t_w,&t_h,gfx->dir3dDev ); - copy( dest,0,0,t_w,t_h,src,0,height-1,width,-height ); + int t_w = width, t_h = height; + if (flags & gxCanvas::CANVAS_TEXTURE) adjustTexSize(&t_w, &t_h, gfx->dir3dDev); + copy(dest, 0, 0, t_w, t_h, src, 0, height - 1, width, -height); src->Release(); - FreeImage_Unload( dib ); + FreeImage_Unload(dib); return dest; } diff --git a/gxruntime/ddutil.h b/gxruntime/ddutil.h index eaab851..743a8e9 100644 --- a/gxruntime/ddutil.h +++ b/gxruntime/ddutil.h @@ -2,7 +2,7 @@ #ifndef DDUTIL_H #define DDUTIL_H -#include +#include "GraphicsRuntime.h" class gxGraphics; typedef IDirectDrawSurface7 ddSurf; diff --git a/gxruntime/gxcanvas.h b/gxruntime/gxcanvas.h index 84a8141..69d8c3c 100644 --- a/gxruntime/gxcanvas.h +++ b/gxruntime/gxcanvas.h @@ -9,35 +9,35 @@ class gxGraphics; typedef IDirectDrawSurface7 ddSurf; -class gxCanvas{ +class gxCanvas { public: - gxCanvas( gxGraphics *graphics,ddSurf *surface,int flags ); + gxCanvas(gxGraphics *graphics, ddSurf *surface, int flags); ~gxCanvas(); void backup()const; void restore()const; ddSurf *getSurface()const; ddSurf *getTexSurface()const; - void setModify( int n ); + void setModify(int n); int getModify()const; bool attachZBuffer(); void releaseZBuffer(); - bool clip( RECT *d )const; - bool clip( RECT *d,RECT *s )const; - void damage( const RECT &r )const; + bool clip(RECT *d)const; + bool clip(RECT *d, RECT *s)const; + void damage(const RECT &r)const; private: - int flags,cube_mode; + int flags, cube_mode; gxGraphics *graphics; - ddSurf *main_surf,*surf,*z_surf,*cube_surfs[6]; + ddSurf *main_surf, *surf, *z_surf, *cube_surfs[6]; mutable int mod_cnt; mutable ddSurf *t_surf; - mutable int locked_pitch,locked_cnt,lock_mod_cnt,remip_cnt; + mutable int locked_pitch, locked_cnt, lock_mod_cnt, remip_cnt; mutable unsigned char *locked_surf; mutable int cm_pitch; @@ -49,85 +49,88 @@ private: gxFont *font; RECT viewport; - int origin_x,origin_y,handle_x,handle_y; - unsigned mask_surf,color_surf,color_argb,clsColor_surf; + int origin_x, origin_y, handle_x, handle_y; + unsigned mask_surf, color_surf, color_argb, clsColor_surf; - void updateBitMask( const RECT &r )const; + void updateBitMask(const RECT &r)const; /***** GX INTERFACE *****/ public: - enum{ - CANVAS_TEX_RGB= 0x0001, - CANVAS_TEX_ALPHA= 0x0002, - CANVAS_TEX_MASK= 0x0004, - CANVAS_TEX_MIPMAP= 0x0008, - CANVAS_TEX_CLAMPU= 0x0010, - CANVAS_TEX_CLAMPV= 0x0020, - CANVAS_TEX_SPHERE= 0x0040, - CANVAS_TEX_CUBE= 0x0080, - CANVAS_TEX_VIDMEM= 0x0100, - CANVAS_TEX_HICOLOR= 0x0200, + enum { + CANVAS_TEX_RGB = 0x0001, + CANVAS_TEX_ALPHA = 0x0002, + CANVAS_TEX_MASK = 0x0004, + CANVAS_TEX_MIPMAP = 0x0008, + CANVAS_TEX_CLAMPU = 0x0010, + CANVAS_TEX_CLAMPV = 0x0020, + CANVAS_TEX_SPHERE = 0x0040, + CANVAS_TEX_CUBE = 0x0080, + CANVAS_TEX_VIDMEM = 0x0100, + CANVAS_TEX_HICOLOR = 0x0200, - CANVAS_TEXTURE= 0x10000, - CANVAS_NONDISPLAY= 0x20000, - CANVAS_HIGHCOLOR= 0x40000 + CANVAS_TEXTURE = 0x10000, + CANVAS_NONDISPLAY = 0x20000, + CANVAS_HIGHCOLOR = 0x40000, + + CANVAS_3DRENDER = 0x1000, + CANVAS_3DZRENDER = 0x2000, }; - enum{ - CUBEMODE_REFLECTION=1, - CUBEMODE_NORMAL=2, - CUBEMODE_POSITION=3, + enum { + CUBEMODE_REFLECTION = 1, + CUBEMODE_NORMAL = 2, + CUBEMODE_POSITION = 3, - CUBESPACE_WORLD=0, - CUBESPACE_CAMERA=4 + CUBESPACE_WORLD = 0, + CUBESPACE_CAMERA = 4 }; //MANIPULATORS - void setFont( gxFont *font ); - void setMask( unsigned argb ); - void setColor( unsigned argb ); - void setClsColor( unsigned argb ); - void setOrigin( int x,int y ); - void setHandle( int x,int y ); - void setViewport( int x,int y,int w,int h ); + void setFont(gxFont *font); + void setMask(unsigned argb); + void setColor(unsigned argb); + void setClsColor(unsigned argb); + void setOrigin(int x, int y); + void setHandle(int x, int y); + void setViewport(int x, int y, int w, int h); void cls(); - void plot( int x,int y ); - void line( int x,int y,int x2,int y2 ); - void rect( int x,int y,int w,int h,bool solid ); - void oval( int x,int y,int w,int h,bool solid ); - void text( int x,int y,const std::string &t ); - void blit( int x,int y,gxCanvas *src,int src_x,int src_y,int src_w,int src_h,bool solid ); + void plot(int x, int y); + void line(int x, int y, int x2, int y2); + void rect(int x, int y, int w, int h, bool solid); + void oval(int x, int y, int w, int h, bool solid); + void text(int x, int y, const std::string &t); + void blit(int x, int y, gxCanvas *src, int src_x, int src_y, int src_w, int src_h, bool solid); - bool collide( int x,int y,const gxCanvas *src,int src_x,int src_y,bool solid )const; - bool rect_collide( int x,int y,int rect_x,int rect_y,int rect_w,int rect_h,bool solid )const; + bool collide(int x, int y, const gxCanvas *src, int src_x, int src_y, bool solid)const; + bool rect_collide(int x, int y, int rect_x, int rect_y, int rect_w, int rect_h, bool solid)const; bool lock()const; - void setPixel( int x,int y,unsigned argb ); - void setPixelFast( int x,int y,unsigned argb ){ - format.setPixel( locked_surf+y*locked_pitch+x*format.getPitch(),argb ); + void setPixel(int x, int y, unsigned argb); + void setPixelFast(int x, int y, unsigned argb) { + format.setPixel(locked_surf + y*locked_pitch + x*format.getPitch(), argb); ++mod_cnt; } - void copyPixel( int x,int y,gxCanvas *src,int src_x,int src_y ); - void copyPixelFast( int x,int y,gxCanvas *src,int src_x,int src_y ); - unsigned getPixel( int x,int y )const; - unsigned getPixelFast( int x,int y )const{ - return format.getPixel( locked_surf+y*locked_pitch+x*format.getPitch() ); + void copyPixel(int x, int y, gxCanvas *src, int src_x, int src_y); + void copyPixelFast(int x, int y, gxCanvas *src, int src_x, int src_y); + unsigned getPixel(int x, int y)const; + unsigned getPixelFast(int x, int y)const { + return format.getPixel(locked_surf + y*locked_pitch + x*format.getPitch()); }; void unlock()const; - void setCubeMode( int mode ); - void setCubeFace( int face ); + void setCubeMode(int mode); + void setCubeFace(int face); //ACCESSORS int getWidth()const; int getHeight()const; int getDepth()const; - int getFlags()const{ return flags; } - int cubeMode()const{ return cube_mode; } - void getOrigin( int *x,int *y )const; - void getHandle( int *x,int *y )const; - void getViewport( int *x,int *y,int *w,int *h )const; + int getFlags()const { return flags; } + int cubeMode()const { return cube_mode; } + void getOrigin(int *x, int *y)const; + void getHandle(int *x, int *y)const; + void getViewport(int *x, int *y, int *w, int *h)const; unsigned getMask()const; unsigned getColor()const; unsigned getClsColor()const; diff --git a/gxruntime/gxgraphics.cpp b/gxruntime/gxgraphics.cpp index e59c09d..c51a417 100644 --- a/gxruntime/gxgraphics.cpp +++ b/gxruntime/gxgraphics.cpp @@ -5,49 +5,47 @@ extern gxRuntime *gx_runtime; -gxGraphics::gxGraphics( gxRuntime *rt,IDirectDraw7 *dd,IDirectDrawSurface7 *fs,IDirectDrawSurface7 *bs,bool d3d ): -runtime(rt),dirDraw(dd),dir3d(0),dir3dDev(0),def_font(0),gfx_lost(false),dummy_mesh(0){ +gxGraphics::gxGraphics(gxRuntime *rt, IDirectDraw7 *dd, IDirectDrawSurface7 *fs, IDirectDrawSurface7 *bs, bool d3d) : + runtime(rt), dirDraw(dd), dir3d(0), dir3dDev(0), def_font(0), gfx_lost(false), dummy_mesh(0) { - dirDraw->QueryInterface( IID_IDirectDraw,(void**)&ds_dirDraw ); + dirDraw->QueryInterface(IID_IDirectDraw, (void**)&ds_dirDraw); - front_canvas=d_new gxCanvas( this,fs,0 ); - back_canvas=d_new gxCanvas( this,bs,0 ); + front_canvas = d_new gxCanvas(this, fs, 0); + back_canvas = d_new gxCanvas(this, bs, 0); front_canvas->cls(); back_canvas->cls(); - def_font=loadFont( "courier",12,0 ); + def_font = loadFont("courier", 12, 0); - front_canvas->setFont( def_font ); - back_canvas->setFont( def_font ); + front_canvas->setFont(def_font); + back_canvas->setFont(def_font); - memset(&primFmt,0,sizeof(primFmt)); - primFmt.dwSize=sizeof(primFmt); - fs->GetPixelFormat( &primFmt ); + memset(&primFmt, 0, sizeof(primFmt)); + primFmt.dwSize = sizeof(primFmt); + fs->GetPixelFormat(&primFmt); //are we fullscreen? - _gamma=0; - if( fs!=bs ){ - if( fs->QueryInterface( IID_IDirectDrawGammaControl,(void**)&_gamma )>=0 ){ - if( _gamma->GetGammaRamp( 0,&_gammaRamp )<0 ) _gamma=0; + _gamma = 0; + if (fs != bs) { + if (fs->QueryInterface(IID_IDirectDrawGammaControl, (void**)&_gamma) >= 0) { + if (_gamma->GetGammaRamp(0, &_gammaRamp) < 0) _gamma = 0; } } - if( !_gamma ){ - for( int k=0;k<256;++k ) _gammaRamp.red[k]=_gammaRamp.blue[k]=_gammaRamp.green[k]=k; + if (!_gamma) { + for (int k = 0; k < 256; ++k) _gammaRamp.red[k] = _gammaRamp.blue[k] = _gammaRamp.green[k] = k; } } -gxGraphics::~gxGraphics(){ - if( _gamma ) _gamma->Release(); -#ifdef PRO - while( scene_set.size() ) freeScene( *scene_set.begin() ); -#endif - while( movie_set.size() ) closeMovie( *movie_set.begin() ); - while( font_set.size() ) freeFont( *font_set.begin() ); - while( canvas_set.size() ) freeCanvas( *canvas_set.begin() ); +gxGraphics::~gxGraphics() { + if (_gamma) _gamma->Release(); + while (scene_set.size()) freeScene(*scene_set.begin()); + while (movie_set.size()) closeMovie(*movie_set.begin()); + while (font_set.size()) freeFont(*font_set.begin()); + while (canvas_set.size()) freeCanvas(*canvas_set.begin()); set::iterator it; - for( it=font_res.begin();it!=font_res.end();++it ) RemoveFontResource( (*it).c_str() ); + for (it = font_res.begin(); it != font_res.end(); ++it) RemoveFontResource((*it).c_str()); font_res.clear(); delete back_canvas; @@ -59,561 +57,555 @@ gxGraphics::~gxGraphics(){ dirDraw->Release(); } -void gxGraphics::setGamma( int r,int g,int b,float dr,float dg,float db ){ - _gammaRamp.red[r&255]=dr*257.0f; - _gammaRamp.green[g&255]=dg*257.0f; - _gammaRamp.blue[b&255]=db*257.0f; +void gxGraphics::setGamma(int r, int g, int b, float dr, float dg, float db) { + _gammaRamp.red[r & 255] = dr*257.0f; + _gammaRamp.green[g & 255] = dg*257.0f; + _gammaRamp.blue[b & 255] = db*257.0f; } -void gxGraphics::updateGamma( bool calibrate ){ - if( !_gamma ) return; - _gamma->SetGammaRamp( calibrate ? DDSGR_CALIBRATE : 0,&_gammaRamp ); +void gxGraphics::updateGamma(bool calibrate) { + if (!_gamma) return; + _gamma->SetGammaRamp(calibrate ? DDSGR_CALIBRATE : 0, &_gammaRamp); } -void gxGraphics::getGamma( int r,int g,int b,float *dr,float *dg,float *db ){ - *dr=_gammaRamp.red[r&255]/257.0f; - *dg=_gammaRamp.green[g&255]/257.0f; - *db=_gammaRamp.blue[b&255]/257.0f; +void gxGraphics::getGamma(int r, int g, int b, float *dr, float *dg, float *db) { + *dr = _gammaRamp.red[r & 255] / 257.0f; + *dg = _gammaRamp.green[g & 255] / 257.0f; + *db = _gammaRamp.blue[b & 255] / 257.0f; } -void gxGraphics::backup(){ +void gxGraphics::backup() { } -bool gxGraphics::restore(){ +bool gxGraphics::restore() { - while( dirDraw->TestCooperativeLevel()!=DD_OK ){ + while (dirDraw->TestCooperativeLevel() != DD_OK) { - if( dirDraw->TestCooperativeLevel()==DDERR_WRONGMODE ) return false; + if (dirDraw->TestCooperativeLevel() == DDERR_WRONGMODE) return false; - Sleep( 100 ); + Sleep(100); } - if( back_canvas->getSurface()->IsLost()==DD_OK ) return true; + if (back_canvas->getSurface()->IsLost() == DD_OK) return true; dirDraw->RestoreAllSurfaces(); //restore all canvases set::iterator it; - for( it=canvas_set.begin();it!=canvas_set.end();++it ){ + for (it = canvas_set.begin(); it != canvas_set.end(); ++it) { (*it)->restore(); } -#ifdef PRO //restore all meshes (b3d surfaces) set::iterator mesh_it; - for( mesh_it=mesh_set.begin();mesh_it!=mesh_set.end();++mesh_it ){ + for (mesh_it = mesh_set.begin(); mesh_it != mesh_set.end(); ++mesh_it) { (*mesh_it)->restore(); } - if( dir3d ) dir3d->EvictManagedTextures(); -#endif + if (dir3d) dir3d->EvictManagedTextures(); return true; } -gxCanvas *gxGraphics::getFrontCanvas()const{ +gxCanvas *gxGraphics::getFrontCanvas()const { return front_canvas; } -gxCanvas *gxGraphics::getBackCanvas()const{ +gxCanvas *gxGraphics::getBackCanvas()const { return back_canvas; } -gxFont *gxGraphics::getDefaultFont()const{ +gxFont *gxGraphics::getDefaultFont()const { return def_font; } -void gxGraphics::vwait(){ - dirDraw->WaitForVerticalBlank( DDWAITVB_BLOCKBEGIN,0 ); +void gxGraphics::vwait() { + dirDraw->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0); } -void gxGraphics::flip( bool v ){ - runtime->flip( v ); +void gxGraphics::flip(bool v) { + runtime->flip(v); } -void gxGraphics::copy( gxCanvas *dest,int dx,int dy,int dw,int dh,gxCanvas *src,int sx,int sy,int sw,int sh ){ - RECT r={ dx,dy,dx+dw,dy+dh }; - ddUtil::copy( dest->getSurface(),dx,dy,dw,dh,src->getSurface(),sx,sy,sw,sh ); - dest->damage( r ); +void gxGraphics::copy(gxCanvas *dest, int dx, int dy, int dw, int dh, gxCanvas *src, int sx, int sy, int sw, int sh) { + RECT r = { dx,dy,dx + dw,dy + dh }; + ddUtil::copy(dest->getSurface(), dx, dy, dw, dh, src->getSurface(), sx, sy, sw, sh); + dest->damage(r); } -int gxGraphics::getScanLine()const{ - DWORD t=0; - dirDraw->GetScanLine( &t ); +int gxGraphics::getScanLine()const { + DWORD t = 0; + dirDraw->GetScanLine(&t); return t; } -int gxGraphics::getTotalVidmem()const{ - DDCAPS caps={sizeof(caps)}; - dirDraw->GetCaps( &caps,0 ); +int gxGraphics::getTotalVidmem()const { + DDCAPS caps = { sizeof(caps) }; + dirDraw->GetCaps(&caps, 0); return caps.dwVidMemTotal; } -int gxGraphics::getAvailVidmem()const{ - DDCAPS caps={sizeof(caps)}; - dirDraw->GetCaps( &caps,0 ); +int gxGraphics::getAvailVidmem()const { + DDCAPS caps = { sizeof(caps) }; + dirDraw->GetCaps(&caps, 0); return caps.dwVidMemFree; } -gxMovie *gxGraphics::openMovie( const string &file,int flags ){ +gxMovie *gxGraphics::openMovie(const string &file, int flags) { - IAMMultiMediaStream *iam_stream; + /*IAMMultiMediaStream *iam_stream; - if( CoCreateInstance( - CLSID_AMMultiMediaStream,NULL,CLSCTX_INPROC_SERVER, - IID_IAMMultiMediaStream,(void **)&iam_stream )==S_OK ){ + if (CoCreateInstance( + CLSID_AMMultiMediaStream, NULL, CLSCTX_INPROC_SERVER, + IID_IAMMultiMediaStream, (void **)&iam_stream) == S_OK) { - if( iam_stream->Initialize( STREAMTYPE_READ,AMMSF_NOGRAPHTHREAD,NULL )==S_OK ){ + if (iam_stream->Initialize(STREAMTYPE_READ, AMMSF_NOGRAPHTHREAD, NULL) == S_OK) { - if( iam_stream->AddMediaStream( ds_dirDraw,&MSPID_PrimaryVideo,0,NULL )==S_OK ){ + if (iam_stream->AddMediaStream(ds_dirDraw, &MSPID_PrimaryVideo, 0, NULL) == S_OK) { - iam_stream->AddMediaStream( NULL,&MSPID_PrimaryAudio,AMMSF_ADDDEFAULTRENDERER,NULL ); + iam_stream->AddMediaStream(NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL); - WCHAR *path=new WCHAR[ file.size()+1 ]; - MultiByteToWideChar( CP_ACP,0,file.c_str(),-1,path,sizeof(WCHAR)*(file.size()+1) ); - int n=iam_stream->OpenFile( path,0 ); + WCHAR *path = new WCHAR[file.size() + 1]; + MultiByteToWideChar(CP_ACP, 0, file.c_str(), -1, path, sizeof(WCHAR)*(file.size() + 1)); + int n = iam_stream->OpenFile(path, 0); delete path; - if( n==S_OK ){ - gxMovie *movie=d_new gxMovie( this,iam_stream ); - movie_set.insert( movie ); + if (n == S_OK) { + gxMovie *movie = d_new gxMovie(this, iam_stream); + movie_set.insert(movie); return movie; } } } iam_stream->Release(); - } + }*/ return 0; } -gxMovie *gxGraphics::verifyMovie( gxMovie *m ){ - return movie_set.count( m ) ? m : 0; +gxMovie *gxGraphics::verifyMovie(gxMovie *m) { + return movie_set.count(m) ? m : 0; } -void gxGraphics::closeMovie( gxMovie *m ){ - if( movie_set.erase( m ) ) delete m; +void gxGraphics::closeMovie(gxMovie *m) { + if (movie_set.erase(m)) delete m; } -gxCanvas *gxGraphics::createCanvas( int w,int h,int flags ){ - ddSurf *s=ddUtil::createSurface( w,h,flags,this ); - if( !s ) return 0; - gxCanvas *c=d_new gxCanvas( this,s,flags ); - canvas_set.insert( c ); +gxCanvas *gxGraphics::createCanvas(int w, int h, int flags) { + ddSurf *s = ddUtil::createSurface(w, h, flags, this); + if (!s) return 0; + gxCanvas *c = d_new gxCanvas(this, s, flags); + canvas_set.insert(c); c->cls(); return c; } -gxCanvas *gxGraphics::loadCanvas( const string &f,int flags ){ - ddSurf *s=ddUtil::loadSurface( f,flags,this ); - if( !s ) return 0; - gxCanvas *c=d_new gxCanvas( this,s,flags ); - canvas_set.insert( c ); +gxCanvas *gxGraphics::loadCanvas(const string &f, int flags) { + ddSurf *s = ddUtil::loadSurface(f, flags, this); + if (!s) return 0; + gxCanvas *c = d_new gxCanvas(this, s, flags); + canvas_set.insert(c); return c; } -gxCanvas *gxGraphics::verifyCanvas( gxCanvas *c ){ - return canvas_set.count( c ) || c==front_canvas || c==back_canvas ? c : 0; +gxCanvas *gxGraphics::verifyCanvas(gxCanvas *c) { + return canvas_set.count(c) || c == front_canvas || c == back_canvas ? c : 0; } -void gxGraphics::freeCanvas( gxCanvas *c ){ - if( canvas_set.erase( c ) ) delete c; +void gxGraphics::freeCanvas(gxCanvas *c) { + if (canvas_set.erase(c)) delete c; } -int gxGraphics::getWidth()const{ +int gxGraphics::getWidth()const { return front_canvas->getWidth(); } -int gxGraphics::getHeight()const{ +int gxGraphics::getHeight()const { return front_canvas->getHeight(); } -int gxGraphics::getDepth()const{ +int gxGraphics::getDepth()const { return front_canvas->getDepth(); } -gxFont *gxGraphics::loadFont( const string &f,int height,int flags ){ +gxFont *gxGraphics::loadFont(const string &f, int height, int flags) { - int bold=flags & gxFont::FONT_BOLD ? FW_BOLD : FW_REGULAR; - int italic=flags & gxFont::FONT_ITALIC ? 1 : 0; - int underline=flags & gxFont::FONT_UNDERLINE ? 1 : 0; - int strikeout=0; + int bold = flags & gxFont::FONT_BOLD ? FW_BOLD : FW_REGULAR; + int italic = flags & gxFont::FONT_ITALIC ? 1 : 0; + int underline = flags & gxFont::FONT_UNDERLINE ? 1 : 0; + int strikeout = 0; string t; - int n=f.find('.'); - if( n!=string::npos ){ - t=fullfilename(f); - if( !font_res.count(t) && AddFontResource( t.c_str() ) ) font_res.insert( t ); - t=filenamefile( f.substr(0,n) ); - }else{ - t=f; + int n = f.find('.'); + if (n != string::npos) { + t = fullfilename(f); + if (!font_res.count(t) && AddFontResource(t.c_str())) font_res.insert(t); + t = filenamefile(f.substr(0, n)); + } else { + t = f; } //save and turn off font smoothing.... - BOOL smoothing=FALSE; - SystemParametersInfo( SPI_GETFONTSMOOTHING,0,&smoothing,0 ); - SystemParametersInfo( SPI_SETFONTSMOOTHING,FALSE,0,0 ); + BOOL smoothing = FALSE; + SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &smoothing, 0); + SystemParametersInfo(SPI_SETFONTSMOOTHING, FALSE, 0, 0); - HFONT hfont=CreateFont( - height,0,0,0, - bold,italic,underline,strikeout, - ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, - DEFAULT_PITCH|FF_DONTCARE,t.c_str() ); + HFONT hfont = CreateFont( + height, 0, 0, 0, + bold, italic, underline, strikeout, + ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + DEFAULT_PITCH | FF_DONTCARE, t.c_str()); - if( !hfont ){ + if (!hfont) { //restore font smoothing - SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 ); + SystemParametersInfo(SPI_SETFONTSMOOTHING, smoothing, 0, 0); return 0; } - HDC hdc=CreateCompatibleDC( 0 ); - HFONT pfont=(HFONT)SelectObject( hdc,hfont ); + HDC hdc = CreateCompatibleDC(0); + HFONT pfont = (HFONT)SelectObject(hdc, hfont); - TEXTMETRIC tm={0}; - if( !GetTextMetrics( hdc,&tm ) ){ - SelectObject( hdc,pfont ); - DeleteDC( hdc ); - DeleteObject( hfont ); - SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 ); + TEXTMETRIC tm = { 0 }; + if (!GetTextMetrics(hdc, &tm)) { + SelectObject(hdc, pfont); + DeleteDC(hdc); + DeleteObject(hfont); + SystemParametersInfo(SPI_SETFONTSMOOTHING, smoothing, 0, 0); return 0; } - height=tm.tmHeight; + height = tm.tmHeight; - int first=tm.tmFirstChar,last=tm.tmLastChar; - int sz=last-first+1; - int *offs=d_new int[sz]; - int *widths=d_new int[sz]; - int *as=d_new int[sz]; + int first = tm.tmFirstChar, last = tm.tmLastChar; + int sz = last - first + 1; + int *offs = d_new int[sz]; + int *widths = d_new int[sz]; + int *as = d_new int[sz]; //calc size of canvas to hold font. - int x=0,y=0,max_x=0; - for( int k=0;kgetWidth() ){ x=0;y+=height; } - offs[k]=(x<<16)|y; - widths[k]=w; - x+=w;if( x>max_x ) max_x=x; + if (x && x + w > getWidth()) { x = 0; y += height; } + offs[k] = (x << 16) | y; + widths[k] = w; + x += w; if (x > max_x) max_x = x; } - SelectObject( hdc,pfont ); - DeleteDC( hdc ); + SelectObject(hdc, pfont); + DeleteDC(hdc); - int cw=max_x,ch=y+height; + int cw = max_x, ch = y + height; - if( gxCanvas *c=createCanvas( cw,ch,0 ) ){ - ddSurf *surf=c->getSurface(); + if (gxCanvas *c = createCanvas(cw, ch, 0)) { + ddSurf *surf = c->getSurface(); HDC surf_hdc; - if( surf->GetDC( &surf_hdc )>=0 ){ - HFONT pfont=(HFONT)SelectObject( surf_hdc,hfont ); + if (surf->GetDC(&surf_hdc) >= 0) { + HFONT pfont = (HFONT)SelectObject(surf_hdc, hfont); - SetBkColor( surf_hdc,0x000000 ); - SetTextColor( surf_hdc,0xffffff ); + SetBkColor(surf_hdc, 0x000000); + SetTextColor(surf_hdc, 0xffffff); - for( int k=0;k>16)&0xffff,y=offs[k]&0xffff; - char t=k+first; - RECT rect={x,y,x+widths[k],y+height}; - ExtTextOut( surf_hdc,x+as[k],y,ETO_CLIPPED,&rect,&t,1,0 ); + for (int k = 0; k < sz; ++k) { + int x = (offs[k] >> 16) & 0xffff, y = offs[k] & 0xffff; + char t = k + first; + RECT rect = { x,y,x + widths[k],y + height }; + ExtTextOut(surf_hdc, x + as[k], y, ETO_CLIPPED, &rect, &t, 1, 0); } - SelectObject( surf_hdc,pfont ); - surf->ReleaseDC( surf_hdc ); - DeleteObject( hfont ); + SelectObject(surf_hdc, pfont); + surf->ReleaseDC(surf_hdc); + DeleteObject(hfont); delete[] as; c->backup(); - gxFont *font=d_new gxFont( this,c,tm.tmMaxCharWidth,height,first,last+1,tm.tmDefaultChar,offs,widths ); - font_set.insert( font ); + gxFont *font = d_new gxFont(this, c, tm.tmMaxCharWidth, height, first, last + 1, tm.tmDefaultChar, offs, widths); + font_set.insert(font); //restore font smoothing - SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 ); + SystemParametersInfo(SPI_SETFONTSMOOTHING, smoothing, 0, 0); return font; - }else{ + } else { } - freeCanvas( c ); - }else{ + freeCanvas(c); + } else { } - DeleteObject( hfont ); + DeleteObject(hfont); delete[] as; delete[] widths; delete[] offs; //restore font smoothing - SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 ); + SystemParametersInfo(SPI_SETFONTSMOOTHING, smoothing, 0, 0); return 0; } -gxFont *gxGraphics::verifyFont( gxFont *f ){ - return font_set.count( f ) ? f : 0; +gxFont *gxGraphics::verifyFont(gxFont *f) { + return font_set.count(f) ? f : 0; } -void gxGraphics::freeFont( gxFont *f ){ - if( font_set.erase( f ) ) delete f; +void gxGraphics::freeFont(gxFont *f) { + if (font_set.erase(f)) delete f; } ////////////// // 3D STUFF // ////////////// -#ifdef PRO - static int maxDevType; -static HRESULT CALLBACK enumDevice( char *desc,char *name,D3DDEVICEDESC7 *devDesc,void *context ){ - gxGraphics *g=(gxGraphics*)context; - int t=0; - GUID guid=devDesc->deviceGUID; - if( guid==IID_IDirect3DRGBDevice ) t=1; - else if( guid==IID_IDirect3DHALDevice ) t=2; - else if( guid==IID_IDirect3DTnLHalDevice ) t=3; - if( t>maxDevType ){ - g->dir3dDevDesc=*devDesc; - maxDevType=t; +static HRESULT CALLBACK enumDevice(char *desc, char *name, D3DDEVICEDESC7 *devDesc, void *context) { + gxGraphics *g = (gxGraphics*)context; + int t = 0; + GUID guid = devDesc->deviceGUID; + if (guid == IID_IDirect3DRGBDevice) t = 1; + else if (guid == IID_IDirect3DHALDevice) t = 2; + else if (guid == IID_IDirect3DTnLHalDevice) t = 3; + if (t > maxDevType) { + g->dir3dDevDesc = *devDesc; + maxDevType = t; } return D3DENUMRET_OK; } -static HRESULT CALLBACK enumZbuffFormat( LPDDPIXELFORMAT format,void *context ){ - gxGraphics *g=(gxGraphics*)context; - if( format->dwZBufferBitDepth==g->primFmt.dwRGBBitCount ){ - g->zbuffFmt=*format; +static HRESULT CALLBACK enumZbuffFormat(LPDDPIXELFORMAT format, void *context) { + gxGraphics *g = (gxGraphics*)context; + if (format->dwZBufferBitDepth == g->primFmt.dwRGBBitCount) { + g->zbuffFmt = *format; return D3DENUMRET_CANCEL; } - if( format->dwZBufferBitDepth>g->zbuffFmt.dwZBufferBitDepth ){ - if( format->dwZBufferBitDepthprimFmt.dwRGBBitCount ){ - g->zbuffFmt=*format; + if (format->dwZBufferBitDepth > g->zbuffFmt.dwZBufferBitDepth) { + if (format->dwZBufferBitDepth < g->primFmt.dwRGBBitCount) { + g->zbuffFmt = *format; } } return D3DENUMRET_OK; } -struct TexFmt{ +struct TexFmt { DDPIXELFORMAT fmt; - int bits,a_bits,rgb_bits; + int bits, a_bits, rgb_bits; }; -static int cntBits( int mask ){ - int n=0; - for( int k=0;k<32;++k ){ - if( mask & (1< tex_fmts; -static HRESULT CALLBACK enumTextureFormat( DDPIXELFORMAT *fmt,void *p ){ +static HRESULT CALLBACK enumTextureFormat(DDPIXELFORMAT *fmt, void *p) { TexFmt t; - t.fmt=*fmt; - t.bits=fmt->dwRGBBitCount; - t.a_bits=(fmt->dwFlags & DDPF_ALPHAPIXELS) ? cntBits(fmt->dwRGBAlphaBitMask) : 0; - t.rgb_bits=(fmt->dwFlags & DDPF_RGB) ? cntBits(fmt->dwRBitMask|fmt->dwGBitMask|fmt->dwBBitMask) : 0; + t.fmt = *fmt; + t.bits = fmt->dwRGBBitCount; + t.a_bits = (fmt->dwFlags & DDPF_ALPHAPIXELS) ? cntBits(fmt->dwRGBAlphaBitMask) : 0; + t.rgb_bits = (fmt->dwFlags & DDPF_RGB) ? cntBits(fmt->dwRBitMask | fmt->dwGBitMask | fmt->dwBBitMask) : 0; - tex_fmts.push_back( t ); + tex_fmts.push_back(t); return D3DENUMRET_OK; } -static string itobin( int n ){ +static string itobin(int n) { string t; - for( int k=0;k<32;n<<=1,++k ){ - t+=(n&0x80000000) ? '1' : '0'; + for (int k = 0; k < 32; n <<= 1, ++k) { + t += (n & 0x80000000) ? '1' : '0'; } return t; } -static void debugPF( const DDPIXELFORMAT &pf ){ +static void debugPF(const DDPIXELFORMAT &pf) { string t; - t="Bits:"+itoa( pf.dwRGBBitCount ); - gx_runtime->debugLog( t.c_str() ); - t="R Mask:"+itobin( pf.dwRBitMask ); - gx_runtime->debugLog( t.c_str() ); - t="G Mask:"+itobin( pf.dwGBitMask ); - gx_runtime->debugLog( t.c_str() ); - t="B Mask:"+itobin( pf.dwBBitMask ); - gx_runtime->debugLog( t.c_str() ); - t="A Mask:"+itobin( pf.dwRGBAlphaBitMask ); - gx_runtime->debugLog( t.c_str() ); + t = "Bits:" + itoa(pf.dwRGBBitCount); + gx_runtime->debugLog(t.c_str()); + t = "R Mask:" + itobin(pf.dwRBitMask); + gx_runtime->debugLog(t.c_str()); + t = "G Mask:" + itobin(pf.dwGBitMask); + gx_runtime->debugLog(t.c_str()); + t = "B Mask:" + itobin(pf.dwBBitMask); + gx_runtime->debugLog(t.c_str()); + t = "A Mask:" + itobin(pf.dwRGBAlphaBitMask); + gx_runtime->debugLog(t.c_str()); } -static void pickTexFmts( gxGraphics *g,int hi ){ +static void pickTexFmts(gxGraphics *g, int hi) { //texRGBFmt. { - int pick=-1,max=0,bits; - for( int d=g->primFmt.dwRGBBitCount;d<=32;d+=8 ){ - for( int k=0;kd || !t.rgb_bits || t.rgb_bits=bits ) continue; - pick=k;max=t.rgb_bits;bits=t.bits; + int pick = -1, max = 0, bits; + for (int d = g->primFmt.dwRGBBitCount; d <= 32; d += 8) { + for (int k = 0; k < tex_fmts.size(); ++k) { + const TexFmt &t = tex_fmts[k]; + if (t.bits > d || !t.rgb_bits || t.rgb_bits < max) continue; + if (t.rgb_bits == max && t.bits >= bits) continue; + pick = k; max = t.rgb_bits; bits = t.bits; } - if( !hi && pick>=0 ) break; + if (!hi && pick >= 0) break; } - if( pick<0 ) g->texRGBFmt[hi]=g->primFmt; - else g->texRGBFmt[hi]=tex_fmts[pick].fmt; + if (pick < 0) g->texRGBFmt[hi] = g->primFmt; + else g->texRGBFmt[hi] = tex_fmts[pick].fmt; } //texAlphaFmt { - int pick=-1,max=0,bits; - for( int d=g->primFmt.dwRGBBitCount;d<=32;d+=8 ){ - for( int k=0;kd || !t.a_bits || t.a_bits=bits ) continue; - pick=k;max=t.a_bits;bits=t.bits; + int pick = -1, max = 0, bits; + for (int d = g->primFmt.dwRGBBitCount; d <= 32; d += 8) { + for (int k = 0; k < tex_fmts.size(); ++k) { + const TexFmt &t = tex_fmts[k]; + if (t.bits > d || !t.a_bits || t.a_bits < max) continue; + if (t.a_bits == max && t.bits >= bits) continue; + pick = k; max = t.a_bits; bits = t.bits; } - if( !hi && pick>=0 ) break; + if (!hi && pick >= 0) break; } - if( pick<0 ) g->texAlphaFmt[hi]=g->primFmt; - else g->texAlphaFmt[hi]=tex_fmts[pick].fmt; + if (pick < 0) g->texAlphaFmt[hi] = g->primFmt; + else g->texAlphaFmt[hi] = tex_fmts[pick].fmt; } //texRGBAlphaFmt { - int pick=-1,a8rgb8=-1,max=0,bits; - for( int d=g->primFmt.dwRGBBitCount;d<=32;d+=8 ){ - for( int k=0;kd || !t.a_bits || !t.rgb_bits || t.a_bits=bits ) continue; - pick=k;max=t.a_bits;bits=t.bits; + int pick = -1, a8rgb8 = -1, max = 0, bits; + for (int d = g->primFmt.dwRGBBitCount; d <= 32; d += 8) { + for (int k = 0; k < tex_fmts.size(); ++k) { + const TexFmt &t = tex_fmts[k]; + if (t.a_bits == 8 && t.bits == 16) { a8rgb8 = k; continue; } + if (t.bits > d || !t.a_bits || !t.rgb_bits || t.a_bits < max) continue; + if (t.a_bits == max && t.bits >= bits) continue; + pick = k; max = t.a_bits; bits = t.bits; } - if( !hi && pick>=0 ) break; + if (!hi && pick >= 0) break; } - if( pick<0 ) pick=a8rgb8; - if( pick<0 ) g->texRGBAlphaFmt[hi]=g->primFmt; - else g->texRGBAlphaFmt[hi]=tex_fmts[pick].fmt; + if (pick < 0) pick = a8rgb8; + if (pick < 0) g->texRGBAlphaFmt[hi] = g->primFmt; + else g->texRGBAlphaFmt[hi] = tex_fmts[pick].fmt; } //texRGBMaskFmt... { - int pick=-1,max=0,bits; - for( int d=g->primFmt.dwRGBBitCount;d<=32;d+=8 ){ - for( int k=0;k=bits ) continue; - pick=k;max=t.rgb_bits;bits=t.bits; + int pick = -1, max = 0, bits; + for (int d = g->primFmt.dwRGBBitCount; d <= 32; d += 8) { + for (int k = 0; k < tex_fmts.size(); ++k) { + const TexFmt &t = tex_fmts[k]; + if (!t.a_bits || !t.rgb_bits || t.rgb_bits < max) continue; + if (t.rgb_bits == max && t.bits >= bits) continue; + pick = k; max = t.rgb_bits; bits = t.bits; } - if( !hi && pick>=0 ) break; + if (!hi && pick >= 0) break; } - if( pick<0 ) g->texRGBMaskFmt[hi]=g->primFmt; - else g->texRGBMaskFmt[hi]=tex_fmts[pick].fmt; + if (pick < 0) g->texRGBMaskFmt[hi] = g->primFmt; + else g->texRGBMaskFmt[hi] = tex_fmts[pick].fmt; } } -gxScene *gxGraphics::createScene( int flags ){ - if( scene_set.size() ) return 0; +gxScene *gxGraphics::createScene(int flags) { + if (scene_set.size()) return 0; //get d3d - if( dirDraw->QueryInterface( IID_IDirect3D7,(void**)&dir3d )>=0 ){ + if (dirDraw->QueryInterface(IID_IDirect3D7, (void**)&dir3d) >= 0) { //enum devices - maxDevType=0; - if( dir3d->EnumDevices( enumDevice,this )>=0 && maxDevType>1 ){ + maxDevType = 0; + if (dir3d->EnumDevices(enumDevice, this) >= 0 && maxDevType > 1) { //enum zbuffer formats - zbuffFmt.dwZBufferBitDepth=0; - if( dir3d->EnumZBufferFormats( dir3dDevDesc.deviceGUID,enumZbuffFormat,this )>=0 ){ + zbuffFmt.dwZBufferBitDepth = 0; + if (dir3d->EnumZBufferFormats(dir3dDevDesc.deviceGUID, enumZbuffFormat, this) >= 0) { //create zbuff for back buffer - if( back_canvas->attachZBuffer() ){ + if (back_canvas->attachZBuffer()) { //create 3d device - if( dir3d->CreateDevice( dir3dDevDesc.deviceGUID,back_canvas->getSurface(),&dir3dDev )>=0 ){ + if (dir3d->CreateDevice(dir3dDevDesc.deviceGUID, back_canvas->getSurface(), &dir3dDev) >= 0) { //enum texture formats tex_fmts.clear(); - if( dir3dDev->EnumTextureFormats( enumTextureFormat,this )>=0 ){ - pickTexFmts( this,0 ); - pickTexFmts( this,1 ); + if (dir3dDev->EnumTextureFormats(enumTextureFormat, this) >= 0) { + pickTexFmts(this, 0); + pickTexFmts(this, 1); tex_fmts.clear(); #ifdef BETA - gx_runtime->debugLog( "Texture RGB format:" ); - debugPF( texRGBFmt ); - gx_runtime->debugLog( "Texture Alpha format:" ); - debugPF( texAlphaFmt ); - gx_runtime->debugLog( "Texture RGB Alpha format:" ); - debugPF( texRGBAlphaFmt ); - gx_runtime->debugLog( "Texture RGB Mask format:" ); - debugPF( texRGBMaskFmt ); - gx_runtime->debugLog( "Texture Primary format:" ); - debugPF( primFmt ); - string ts="ZBuffer Bit Depth:"+itoa( zbuffFmt.dwZBufferBitDepth ); - gx_runtime->debugLog( ts.c_str() ); + gx_runtime->debugLog("Texture RGB format:"); + debugPF(texRGBFmt); + gx_runtime->debugLog("Texture Alpha format:"); + debugPF(texAlphaFmt); + gx_runtime->debugLog("Texture RGB Alpha format:"); + debugPF(texRGBAlphaFmt); + gx_runtime->debugLog("Texture RGB Mask format:"); + debugPF(texRGBMaskFmt); + gx_runtime->debugLog("Texture Primary format:"); + debugPF(primFmt); + string ts = "ZBuffer Bit Depth:" + itoa(zbuffFmt.dwZBufferBitDepth); + gx_runtime->debugLog(ts.c_str()); #endif - gxScene *scene=d_new gxScene( this,back_canvas ); - scene_set.insert( scene ); + gxScene *scene = d_new gxScene(this, back_canvas); + scene_set.insert(scene); - dummy_mesh=createMesh( 8,12,0 ); + dummy_mesh = createMesh(8, 12, 0); return scene; } dir3dDev->Release(); - dir3dDev=0; + dir3dDev = 0; } back_canvas->releaseZBuffer(); } } } dir3d->Release(); - dir3d=0; + dir3d = 0; } return 0; } -gxScene *gxGraphics::verifyScene( gxScene *s ){ - return scene_set.count( s ) ? s : 0; +gxScene *gxGraphics::verifyScene(gxScene *s) { + return scene_set.count(s) ? s : 0; } -void gxGraphics::freeScene( gxScene *scene ){ - if( !scene_set.erase( scene ) ) return; - dummy_mesh=0; - while( mesh_set.size() ) freeMesh( *mesh_set.begin() ); +void gxGraphics::freeScene(gxScene *scene) { + if (!scene_set.erase(scene)) return; + dummy_mesh = 0; + while (mesh_set.size()) freeMesh(*mesh_set.begin()); back_canvas->releaseZBuffer(); - if( dir3dDev ){ dir3dDev->Release();dir3dDev=0; } - if( dir3d ){ dir3d->Release();dir3d=0; } + if (dir3dDev) { dir3dDev->Release(); dir3dDev = 0; } + if (dir3d) { dir3d->Release(); dir3d = 0; } delete scene; } -gxMesh *gxGraphics::createMesh( int max_verts,int max_tris,int flags ){ +gxMesh *gxGraphics::createMesh(int max_verts, int max_tris, int flags) { - static const int VTXFMT= - D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX2| - D3DFVF_TEXCOORDSIZE2(0)|D3DFVF_TEXCOORDSIZE2(1); + static const int VTXFMT = + D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2 | + D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE2(1); - int vbflags=0; + int vbflags = 0; //XP or less? - if( runtime->osinfo.dwMajorVersion<6 ){ - vbflags|=D3DVBCAPS_WRITEONLY; - } + /*if (runtime->osinfo.dwMajorVersion < 6) { + vbflags |= D3DVBCAPS_WRITEONLY; + }*/ - D3DVERTEXBUFFERDESC desc={ sizeof(desc),vbflags,VTXFMT,max_verts }; + D3DVERTEXBUFFERDESC desc = { sizeof(desc),vbflags,VTXFMT,max_verts }; IDirect3DVertexBuffer7 *buff; - if( dir3d->CreateVertexBuffer( &desc,&buff,0 )<0 ) return 0; - WORD *indices=d_new WORD[max_tris*3]; - gxMesh *mesh=d_new gxMesh( this,buff,indices,max_verts,max_tris ); - mesh_set.insert( mesh ); + if (dir3d->CreateVertexBuffer(&desc, &buff, 0) < 0) return 0; + WORD *indices = d_new WORD[max_tris * 3]; + gxMesh *mesh = d_new gxMesh(this, buff, indices, max_verts, max_tris); + mesh_set.insert(mesh); return mesh; } -gxMesh *gxGraphics::verifyMesh( gxMesh *m ){ - return mesh_set.count( m ) ? m : 0; +gxMesh *gxGraphics::verifyMesh(gxMesh *m) { + return mesh_set.count(m) ? m : 0; } -void gxGraphics::freeMesh( gxMesh *mesh ){ - if( mesh_set.erase( mesh ) ) delete mesh; -} - -#endif +void gxGraphics::freeMesh(gxMesh *mesh) { + if (mesh_set.erase(mesh)) delete mesh; +} \ No newline at end of file diff --git a/gxruntime/gxgraphics.h b/gxruntime/gxgraphics.h index 74ed971..77487fe 100644 --- a/gxruntime/gxgraphics.h +++ b/gxruntime/gxgraphics.h @@ -4,6 +4,8 @@ #include #include + +#include "GraphicsRuntime.h" #include #include "ddutil.h" @@ -16,8 +18,18 @@ class gxRuntime; -class gxGraphics{ +class gxGraphics { +private: + // Direct3D9 + //LPDIRECT3D9 d3d9; + //LPDIRECT3DDEVICE9 d3d9dev; + //IDirect3DDevice9* d3d9Device; + public: + gxGraphics(gxRuntime* runtime); + gxGraphics(gxRuntime* runtime, IDirectDraw7 *dirDraw, IDirectDrawSurface7 *front, IDirectDrawSurface7 *back, bool d3d); + ~gxGraphics(); + IDirectDraw7 *dirDraw; IDirectDraw *ds_dirDraw; @@ -26,10 +38,7 @@ public: D3DDEVICEDESC7 dir3dDevDesc; DDPIXELFORMAT primFmt,zbuffFmt; - DDPIXELFORMAT texRGBFmt[2],texAlphaFmt[2],texRGBAlphaFmt[2],texRGBMaskFmt[2]; - - gxGraphics( gxRuntime *runtime,IDirectDraw7 *dirDraw,IDirectDrawSurface7 *front,IDirectDrawSurface7 *back,bool d3d ); - ~gxGraphics(); + DDPIXELFORMAT texRGBFmt[2], texAlphaFmt[2], texRGBAlphaFmt[2], texRGBMaskFmt[2]; void backup(); bool restore(); @@ -38,14 +47,14 @@ public: private: - gxCanvas *front_canvas,*back_canvas; + gxCanvas *front_canvas, *back_canvas; gxFont *def_font; bool gfx_lost; gxMesh *dummy_mesh; - DDSURFACEDESC2 initDesc( int w,int h,int flags ); - ddSurf *createSurface( int width,int height,int flags ); - ddSurf *loadSurface( const std::string &f,int flags ); + DDSURFACEDESC2 initDesc(int w, int h, int flags); + ddSurf *createSurface(int width, int height, int flags); + ddSurf *loadSurface(const std::string &f, int flags); std::set font_set; std::set canvas_set; @@ -59,24 +68,24 @@ private: /***** GX INTERFACE *****/ public: - enum{ - GRAPHICS_WINDOWED=1, //windowed mode - GRAPHICS_SCALED=2, //scaled window - GRAPHICS_3D=4, //3d mode! Hurrah! - GRAPHICS_AUTOSUSPEND=8 //suspend graphics when app suspended + enum { + GRAPHICS_WINDOWED = 1, //windowed mode + GRAPHICS_SCALED = 2, //scaled window + GRAPHICS_3D = 4, //3d mode! Hurrah! + GRAPHICS_AUTOSUSPEND = 8 //suspend graphics when app suspended }; //MANIPULATORS void vwait(); - void flip( bool vwait ); + void flip(bool vwait); //SPECIAL! - void copy( gxCanvas *dest,int dx,int dy,int dw,int dh,gxCanvas *src,int sx,int sy,int sw,int sh ); + void copy(gxCanvas *dest, int dx, int dy, int dw, int dh, gxCanvas *src, int sx, int sy, int sw, int sh); //NEW! Gamma control! - void setGamma( int r,int g,int b,float dr,float dg,float db ); - void getGamma( int r,int g,int b,float *dr,float *dg,float *db ); - void updateGamma( bool calibrate ); + void setGamma(int r, int g, int b, float dr, float dg, float db); + void getGamma(int r, int g, int b, float *dr, float *dg, float *db); + void updateGamma(bool calibrate); //ACCESSORS int getWidth()const; @@ -91,26 +100,26 @@ public: gxFont *getDefaultFont()const; //OBJECTS - gxCanvas *createCanvas( int width,int height,int flags ); - gxCanvas *loadCanvas( const std::string &file,int flags ); - gxCanvas *verifyCanvas( gxCanvas *canvas ); - void freeCanvas( gxCanvas *canvas ); + gxCanvas *createCanvas(int width, int height, int flags); + gxCanvas *loadCanvas(const std::string &file, int flags); + gxCanvas *verifyCanvas(gxCanvas *canvas); + void freeCanvas(gxCanvas *canvas); - gxMovie *openMovie( const std::string &file,int flags ); - gxMovie *verifyMovie( gxMovie *movie ); - void closeMovie( gxMovie *movie ); + gxMovie *openMovie(const std::string &file, int flags); + gxMovie *verifyMovie(gxMovie *movie); + void closeMovie(gxMovie *movie); - gxFont *loadFont( const std::string &font,int height,int flags ); - gxFont *verifyFont( gxFont *font ); - void freeFont( gxFont *font ); + gxFont *loadFont(const std::string &font, int height, int flags); + gxFont *verifyFont(gxFont *font); + void freeFont(gxFont *font); - gxScene *createScene( int flags ); - gxScene *verifyScene( gxScene *scene ); - void freeScene( gxScene *scene ); + gxScene *createScene(int flags); + gxScene *verifyScene(gxScene *scene); + void freeScene(gxScene *scene); - gxMesh *createMesh( int max_verts,int max_tris,int flags ); - gxMesh *verifyMesh( gxMesh *mesh ); - void freeMesh( gxMesh *mesh ); + gxMesh *createMesh(int max_verts, int max_tris, int flags); + gxMesh *verifyMesh(gxMesh *mesh); + void freeMesh(gxMesh *mesh); }; #endif \ No newline at end of file diff --git a/gxruntime/gxinput.cpp b/gxruntime/gxinput.cpp index 398661b..51b7514 100644 --- a/gxruntime/gxinput.cpp +++ b/gxruntime/gxinput.cpp @@ -1,126 +1,128 @@ +#pragma once #include "std.h" #include "gxinput.h" #include "gxruntime.h" -#include +static const int QUE_SIZE = 32; -static const int QUE_SIZE=32; - -class Device : public gxDevice{ +class Device : public gxDevice { public: bool acquired; gxInput *input; - IDirectInputDevice7 *device; + LPDIRECTINPUTDEVICE8 device; - Device( gxInput *i,IDirectInputDevice7 *d ):input(i),acquired(false),device(d){ + Device(gxInput *i, LPDIRECTINPUTDEVICE8 d) :input(i), acquired(false), device(d) { } - virtual ~Device(){ + virtual ~Device() { device->Release(); + //device->Release(); } - bool acquire(){ - return acquired=device->Acquire()>=0; + bool acquire() { + return device->Acquire() >= 0; + //return acquired=device->Acquire()>=0; } - void unacquire(){ + void unacquire() { device->Unacquire(); - acquired=false; + //device->Unacquire(); + acquired = false; } }; -class Keyboard : public Device{ +class Keyboard : public Device { public: - Keyboard( gxInput *i,IDirectInputDevice7 *d ):Device(i,d){ + Keyboard(gxInput *i, LPDIRECTINPUTDEVICE8 d) :Device(i, d) { } - void update(){ - if( !acquired ){ + void update() { + if (!acquired) { input->runtime->idle(); return; } - int k,cnt=32; - DIDEVICEOBJECTDATA data[32],*curr; - if( device->GetDeviceData( sizeof(DIDEVICEOBJECTDATA),data,(DWORD*)&cnt,0 )<0 ) return; - curr=data; - for( k=0;kdwOfs;if( !n || n>255 ) continue; - if( curr->dwData&0x80 ) downEvent( n ); - else upEvent( n ); + int k, cnt = 32; + DIDEVICEOBJECTDATA data[32], *curr; + if (device->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), data, (DWORD*)&cnt, 0) < 0) return; + curr = data; + for (k = 0; k < cnt; ++curr, ++k) { + int n = curr->dwOfs; if (!n || n > 255) continue; + if (curr->dwData & 0x80) downEvent(n); + else upEvent(n); } } }; -class Mouse : public Device{ +class Mouse : public Device { public: - Mouse( gxInput *i,IDirectInputDevice7 *d ):Device(i,d){ + Mouse(gxInput *i, LPDIRECTINPUTDEVICE8 d) :Device(i, d) { } - void update(){ - if( !acquired ){ + void update() { + if (!acquired) { input->runtime->idle(); return; } DIMOUSESTATE state; - if( device->GetDeviceState(sizeof(state),&state)<0 ) return; - if( gxGraphics *g=input->runtime->graphics ){ - int mx=axis_states[0]+state.lX; - int my=axis_states[1]+state.lY; - if( mx<0 ) mx=0; - else if( mx>=g->getWidth() ) mx=g->getWidth()-1; - if( my<0 ) my=0; - else if( my>=g->getHeight() ) my=g->getHeight()-1; - axis_states[0]=mx; - axis_states[1]=my; - axis_states[2]+=state.lZ; + if (device->GetDeviceState(sizeof(state), &state) < 0) return; + if (gxGraphics *g = input->runtime->graphics) { + int mx = axis_states[0] + state.lX; + int my = axis_states[1] + state.lY; + if (mx < 0) mx = 0; + else if (mx >= g->getWidth()) mx = g->getWidth() - 1; + if (my < 0) my = 0; + else if (my >= g->getHeight()) my = g->getHeight() - 1; + axis_states[0] = mx; + axis_states[1] = my; + axis_states[2] += state.lZ; } - for( int k=0;k<3;++k ){ - setDownState( k+1,state.rgbButtons[k]&0x80 ? true : false ); + for (int k = 0; k < 3; ++k) { + setDownState(k + 1, state.rgbButtons[k] & 0x80 ? true : false); } } }; -class Joystick : public Device{ +class Joystick : public Device { public: - int type,poll_time; - int mins[12],maxs[12]; - Joystick( gxInput *i,IDirectInputDevice7 *d,int t ):Device(i,d),type(t),poll_time(0){ - for( int k=0;k<12;++k ){ + int type, poll_time; + int mins[12], maxs[12]; + Joystick(gxInput *i, LPDIRECTINPUTDEVICE8 d, int t) :Device(i, d), type(t), poll_time(0) { + for (int k = 0; k < 12; ++k) { //initialize joystick axis ranges (d'oh!) DIPROPRANGE range; - range.diph.dwSize=sizeof(DIPROPRANGE); - range.diph.dwHeaderSize=sizeof(DIPROPHEADER); - range.diph.dwObj=k*4+12; - range.diph.dwHow=DIPH_BYOFFSET; - if( d->GetProperty( DIPROP_RANGE,&range.diph )<0 ){ - mins[k]=0; - maxs[k]=65535; + range.diph.dwSize = sizeof(DIPROPRANGE); + range.diph.dwHeaderSize = sizeof(DIPROPHEADER); + range.diph.dwObj = k * 4 + 12; + range.diph.dwHow = DIPH_BYOFFSET; + if (d->GetProperty(DIPROP_RANGE, &range.diph) < 0) { + mins[k] = 0; + maxs[k] = 65535; continue; } - mins[k]=range.lMin; - maxs[k]=range.lMax-range.lMin; + mins[k] = range.lMin; + maxs[k] = range.lMax - range.lMin; } } - void update(){ - unsigned tm=timeGetTime(); - if( tm-poll_time<3 ) return; - if( device->Poll()<0 ){ - acquired=false; + void update() { + unsigned tm = timeGetTime(); + if (tm - poll_time < 3) return; + if (device->Poll() < 0) { + acquired = false; input->runtime->idle(); - acquire();if( device->Poll()<0 ) return; + acquire(); if (device->Poll() < 0) return; } - poll_time=tm; + poll_time = tm; DIJOYSTATE state; - if( device->GetDeviceState( sizeof( state ),&state )<0 ) return; - axis_states[0]=(state.lX-mins[0])/(float)maxs[0]*2-1; - axis_states[1]=(state.lY-mins[1])/(float)maxs[1]*2-1; - axis_states[2]=(state.lZ-mins[2])/(float)maxs[2]*2-1; - axis_states[3]=(state.rglSlider[0]-mins[6])/(float)maxs[6]*2-1; - axis_states[4]=(state.rglSlider[1]-mins[7])/(float)maxs[7]*2-1; - axis_states[5]=(state.lRx-mins[3])/(float)maxs[3]*2-1; - axis_states[6]=(state.lRy-mins[4])/(float)maxs[4]*2-1; - axis_states[7]=(state.lRz-mins[5])/(float)maxs[5]*2-1; - if( (state.rgdwPOV[0]&0xffff)==0xffff ) axis_states[8]=-1; - else axis_states[8]=floor(state.rgdwPOV[0]/100.0f+.5f); + if (device->GetDeviceState(sizeof(state), &state) < 0) return; + axis_states[0] = (state.lX - mins[0]) / (float)maxs[0] * 2 - 1; + axis_states[1] = (state.lY - mins[1]) / (float)maxs[1] * 2 - 1; + axis_states[2] = (state.lZ - mins[2]) / (float)maxs[2] * 2 - 1; + axis_states[3] = (state.rglSlider[0] - mins[6]) / (float)maxs[6] * 2 - 1; + axis_states[4] = (state.rglSlider[1] - mins[7]) / (float)maxs[7] * 2 - 1; + axis_states[5] = (state.lRx - mins[3]) / (float)maxs[3] * 2 - 1; + axis_states[6] = (state.lRy - mins[4]) / (float)maxs[4] * 2 - 1; + axis_states[7] = (state.lRz - mins[5]) / (float)maxs[5] * 2 - 1; + if ((state.rgdwPOV[0] & 0xffff) == 0xffff) axis_states[8] = -1; + else axis_states[8] = floor(state.rgdwPOV[0] / 100.0f + .5f); - for( int k=0;k<31;++k ){ - setDownState( k+1,state.rgbButtons[k]&0x80 ? true : false ); + for (int k = 0; k < 31; ++k) { + setDownState(k + 1, state.rgbButtons[k] & 0x80 ? true : false); } } }; @@ -128,69 +130,69 @@ public: static Keyboard *keyboard; static Mouse *mouse; static vector joysticks; - -static Keyboard *createKeyboard( gxInput *input ){ - IDirectInputDevice7 *dev; - if( input->dirInput->CreateDeviceEx( GUID_SysKeyboard,IID_IDirectInputDevice7,(void**)&dev,0 )>=0 ){ - if( dev->SetCooperativeLevel( input->runtime->hwnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE )>=0 ){ - if( dev->SetDataFormat( &c_dfDIKeyboard )>=0 ){ +static Keyboard *createKeyboard(gxInput *input) { + LPDIRECTINPUTDEVICE8 dev; + if (input->dirInput->CreateDevice(GUID_SysKeyboard, &dev, NULL) >= 0) { + if (dev->SetCooperativeLevel(input->runtime->hwnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE) >= 0) { + + if (dev->SetDataFormat(&c_dfDIKeyboard) >= 0) { DIPROPDWORD dword; - memset( &dword,0,sizeof(dword) ); - dword.diph.dwSize=sizeof(DIPROPDWORD); - dword.diph.dwHeaderSize=sizeof(DIPROPHEADER); - dword.diph.dwObj=0; - dword.diph.dwHow=DIPH_DEVICE; - dword.dwData=32; - if( dev->SetProperty( DIPROP_BUFFERSIZE,&dword.diph )>=0 ){ - return d_new Keyboard( input,dev ); - }else{ -// input->runtime->debugInfo( "keyboard: SetProperty failed" ); + memset(&dword, 0, sizeof(dword)); + dword.diph.dwSize = sizeof(DIPROPDWORD); + dword.diph.dwHeaderSize = sizeof(DIPROPHEADER); + dword.diph.dwObj = 0; + dword.diph.dwHow = DIPH_DEVICE; + dword.dwData = 32; + if (dev->SetProperty(DIPROP_BUFFERSIZE, &dword.diph) >= 0) { + return d_new Keyboard(input, dev); + } else { + // input->runtime->debugInfo( "keyboard: SetProperty failed" ); } - }else{ -// input->runtime->debugInfo( "keyboard: SetDataFormat failed" ); + } else { + // input->runtime->debugInfo( "keyboard: SetDataFormat failed" ); } - return d_new Keyboard( input,dev ); + return d_new Keyboard(input, dev); - }else{ - input->runtime->debugInfo( "keyboard: SetCooperativeLevel failed" ); + } else { + input->runtime->debugInfo("keyboard: SetCooperativeLevel failed"); } dev->Release(); - }else{ - input->runtime->debugInfo( "keyboard: CreateDeviceEx failed" ); + } else { + input->runtime->debugInfo("keyboard: CreateDeviceEx failed"); } return 0; } -static Mouse *createMouse( gxInput *input ){ - IDirectInputDevice7 *dev; - if( input->dirInput->CreateDeviceEx( GUID_SysMouse,IID_IDirectInputDevice7,(void**)&dev,0 )>=0 ){ - if( dev->SetCooperativeLevel( input->runtime->hwnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE )>=0 ){ +static Mouse *createMouse(gxInput *input) { + LPDIRECTINPUTDEVICE8 dev; + if (input->dirInput->CreateDevice(GUID_SysMouse, &dev, 0) >= 0) { + if (dev->SetCooperativeLevel(input->runtime->hwnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE) >= 0) { - if( dev->SetDataFormat( &c_dfDIMouse )>=0 ){ - return d_new Mouse( input,dev ); - }else{ -// input->runtime->debugInfo( "mouse: SetDataFormat failed" ); + if (dev->SetDataFormat(&c_dfDIMouse) >= 0) { + return d_new Mouse(input, dev); + } else { + // input->runtime->debugInfo( "mouse: SetDataFormat failed" ); } - return d_new Mouse( input,dev ); + return d_new Mouse(input, dev); - }else{ - input->runtime->debugInfo( "mouse: SetCooperativeLevel failed" ); + } else { + input->runtime->debugInfo("mouse: SetCooperativeLevel failed"); } dev->Release(); - }else{ - input->runtime->debugInfo( "mouse: CreateDeviceEx failed" ); + } else { + input->runtime->debugInfo("mouse: CreateDeviceEx failed"); } return 0; } -static Joystick *createJoystick( gxInput *input,LPCDIDEVICEINSTANCE devinst ){ - IDirectInputDevice7 *dev; - if( input->dirInput->CreateDeviceEx( devinst->guidInstance,IID_IDirectInputDevice7,(void**)&dev,0 )>=0 ){ - if( dev->SetCooperativeLevel( input->runtime->hwnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE )>=0 ){ - if( dev->SetDataFormat( &c_dfDIJoystick )>=0 ){ - int t=((devinst->dwDevType>>8)&0xff)==DIDEVTYPEJOYSTICK_GAMEPAD ? 1 : 2; - return d_new Joystick( input,dev,t ); +static Joystick *createJoystick(gxInput *input, LPCDIDEVICEINSTANCE devinst) { + LPDIRECTINPUTDEVICE8 dev; + if (input->dirInput->CreateDevice(devinst->guidInstance, &dev, 0) >= 0) { + if (dev->SetCooperativeLevel(input->runtime->hwnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE) >= 0) { + if (dev->SetDataFormat(&c_dfDIJoystick) >= 0) { + int t = ((devinst->dwDevType >> 8) & 0xff) == DI8DEVCLASS_GAMECTRL ? 1 : 2; + return d_new Joystick(input, dev, t); } } dev->Release(); @@ -198,26 +200,25 @@ static Joystick *createJoystick( gxInput *input,LPCDIDEVICEINSTANCE devinst ){ return 0; } -static BOOL CALLBACK enumJoystick( LPCDIDEVICEINSTANCE devinst,LPVOID pvRef ){ +static BOOL CALLBACK enumJoystick(LPCDIDEVICEINSTANCE devinst, LPVOID pvRef) { - if( (devinst->dwDevType&0xff)!=DIDEVTYPE_JOYSTICK ) return DIENUM_CONTINUE; + if ((devinst->dwDevType & 0xff) != DI8DEVCLASS_GAMECTRL) return DIENUM_CONTINUE; - if( Joystick *joy=createJoystick( (gxInput*)pvRef,devinst ) ){ - joysticks.push_back( joy ); + if (Joystick *joy = createJoystick((gxInput*)pvRef, devinst)) { + joysticks.push_back(joy); } return DIENUM_CONTINUE; } -gxInput::gxInput( gxRuntime *rt,IDirectInput7 *di ): -runtime(rt),dirInput(di){ - keyboard=createKeyboard( this ); - mouse=createMouse( this ); +gxInput::gxInput(gxRuntime *rt, LPDIRECTINPUT8 di) : runtime(rt), dirInput(di) { + keyboard = createKeyboard(this); + mouse = createMouse(this); joysticks.clear(); - dirInput->EnumDevices( DIDEVTYPE_JOYSTICK,enumJoystick,this,DIEDFL_ATTACHEDONLY ); + dirInput->EnumDevices(DI8DEVCLASS_GAMECTRL, enumJoystick, this, DIEDFL_ATTACHEDONLY); } -gxInput::~gxInput(){ - for( int k=0;kRelease(); } -void gxInput::wm_keydown( int key ){ - if( keyboard ) keyboard->downEvent( key ); +void gxInput::wm_keydown(int key) { + if (keyboard) keyboard->downEvent(key); } -void gxInput::wm_keyup( int key ){ - if( keyboard ) keyboard->upEvent( key ); +void gxInput::wm_keyup(int key) { + if (keyboard) keyboard->upEvent(key); } -void gxInput::wm_mousedown( int key ){ - if( mouse ) mouse->downEvent( key ); +void gxInput::wm_mousedown(int key) { + if (mouse) mouse->downEvent(key); } -void gxInput::wm_mouseup( int key ){ - if( mouse ) mouse->upEvent( key ); +void gxInput::wm_mouseup(int key) { + if (mouse) mouse->upEvent(key); } -void gxInput::wm_mousemove( int x,int y ){ - if( mouse ){ - mouse->axis_states[0]=x; - mouse->axis_states[1]=y; +void gxInput::wm_mousemove(int x, int y) { + if (mouse) { + mouse->axis_states[0] = x; + mouse->axis_states[1] = y; } } -void gxInput::wm_mousewheel( int dz ){ - if( mouse ) mouse->axis_states[2]+=dz; +void gxInput::wm_mousewheel(int dz) { + if (mouse) mouse->axis_states[2] += dz; } -void gxInput::reset(){ - if( mouse ) mouse->reset(); - if( keyboard ) keyboard->reset(); - for( int k=0;kreset(); +void gxInput::reset() { + if (mouse) mouse->reset(); + if (keyboard) keyboard->reset(); + for (int k = 0; k < joysticks.size(); ++k) joysticks[k]->reset(); } -bool gxInput::acquire(){ - bool m_ok=true,k_ok=true; - if( mouse ) m_ok=mouse->acquire(); - if( keyboard ) k_ok=keyboard->acquire(); - if( m_ok && k_ok ) return true; - if( k_ok ) keyboard->unacquire(); - if( m_ok ) mouse->unacquire(); +bool gxInput::acquire() { + bool m_ok = true, k_ok = true; + if (mouse) m_ok = mouse->acquire(); + if (keyboard) k_ok = keyboard->acquire(); + if (m_ok && k_ok) return true; + if (k_ok) keyboard->unacquire(); + if (m_ok) mouse->unacquire(); return false; } -void gxInput::unacquire(){ - if( keyboard ) keyboard->unacquire(); - if( mouse ) mouse->unacquire(); +void gxInput::unacquire() { + if (keyboard) keyboard->unacquire(); + if (mouse) mouse->unacquire(); } -void gxInput::moveMouse( int x,int y ){ - if( !mouse ) return; - mouse->axis_states[0]=x; - mouse->axis_states[1]=y; - runtime->moveMouse( x,y ); +void gxInput::moveMouse(int x, int y) { + if (!mouse) return; + mouse->axis_states[0] = x; + mouse->axis_states[1] = y; + runtime->moveMouse(x, y); } -gxDevice *gxInput::getMouse()const{ +gxDevice *gxInput::getMouse()const { return mouse; } -gxDevice *gxInput::getKeyboard()const{ +gxDevice *gxInput::getKeyboard()const { return keyboard; } -gxDevice *gxInput::getJoystick( int n )const{ - return n>=0 && n= 0 && n < joysticks.size() ? joysticks[n] : 0; } -int gxInput::getJoystickType( int n )const{ - return n>=0 && ntype : 0; +int gxInput::getJoystickType(int n)const { + return n >= 0 && n < joysticks.size() ? joysticks[n]->type : 0; } -int gxInput::numJoysticks()const{ +int gxInput::numJoysticks()const { return joysticks.size(); } -int gxInput::toAscii( int scan )const{ - switch( scan ){ - case DIK_INSERT:return ASC_INSERT; - case DIK_DELETE:return ASC_DELETE; - case DIK_HOME:return ASC_HOME; - case DIK_END:return ASC_END; - case DIK_PGUP:return ASC_PAGEUP; - case DIK_PGDN:return ASC_PAGEDOWN; - case DIK_UP:return ASC_UP; - case DIK_DOWN:return ASC_DOWN; - case DIK_LEFT:return ASC_LEFT; - case DIK_RIGHT:return ASC_RIGHT; +int gxInput::toAscii(int scan)const { + switch (scan) { + case DIK_INSERT:return ASC_INSERT; + case DIK_DELETE:return ASC_DELETE; + case DIK_HOME:return ASC_HOME; + case DIK_END:return ASC_END; + case DIK_PGUP:return ASC_PAGEUP; + case DIK_PGDN:return ASC_PAGEDOWN; + case DIK_UP:return ASC_UP; + case DIK_DOWN:return ASC_DOWN; + case DIK_LEFT:return ASC_LEFT; + case DIK_RIGHT:return ASC_RIGHT; } - scan&=0x7f; - int virt=MapVirtualKey( scan,1 ); - if( !virt ) return 0; + scan &= 0x7f; + int virt = MapVirtualKey(scan, 1); + if (!virt) return 0; static unsigned char mat[256]; - mat[VK_LSHIFT]=keyboard->keyDown( DIK_LSHIFT ) ? 0x80 : 0; - mat[VK_RSHIFT]=keyboard->keyDown( DIK_RSHIFT ) ? 0x80 : 0; - mat[VK_SHIFT]=mat[VK_LSHIFT]|mat[VK_RSHIFT]; - mat[VK_LCONTROL]=keyboard->keyDown( DIK_LCONTROL ) ? 0x80 : 0; - mat[VK_RCONTROL]=keyboard->keyDown( DIK_RCONTROL ) ? 0x80 : 0; - mat[VK_CONTROL]=mat[VK_LCONTROL]|mat[VK_RCONTROL]; - mat[VK_LMENU]=keyboard->keyDown( DIK_LMENU ) ? 0x80 : 0; - mat[VK_RMENU]=keyboard->keyDown( DIK_RMENU ) ? 0x80 : 0; - mat[VK_MENU]=mat[VK_LMENU]|mat[VK_RMENU]; + mat[VK_LSHIFT] = keyboard->keyDown(DIK_LSHIFT) ? 0x80 : 0; + mat[VK_RSHIFT] = keyboard->keyDown(DIK_RSHIFT) ? 0x80 : 0; + mat[VK_SHIFT] = mat[VK_LSHIFT] | mat[VK_RSHIFT]; + mat[VK_LCONTROL] = keyboard->keyDown(DIK_LCONTROL) ? 0x80 : 0; + mat[VK_RCONTROL] = keyboard->keyDown(DIK_RCONTROL) ? 0x80 : 0; + mat[VK_CONTROL] = mat[VK_LCONTROL] | mat[VK_RCONTROL]; + mat[VK_LMENU] = keyboard->keyDown(DIK_LMENU) ? 0x80 : 0; + mat[VK_RMENU] = keyboard->keyDown(DIK_RMENU) ? 0x80 : 0; + mat[VK_MENU] = mat[VK_LMENU] | mat[VK_RMENU]; WORD ch; - if( ToAscii( virt,scan,mat,&ch,0 )!=1 ) return 0; + if (ToAscii(virt, scan, mat, &ch, 0) != 1) return 0; return ch & 255; } diff --git a/gxruntime/gxinput.h b/gxruntime/gxinput.h index 8ce6b02..4f0d87b 100644 --- a/gxruntime/gxinput.h +++ b/gxruntime/gxinput.h @@ -1,19 +1,17 @@ +#pragma once -#ifndef GXINPUT_H -#define GXINPUT_H - -#include - +#include "std.h" #include "gxdevice.h" +#include "GraphicsRuntime.h" class gxRuntime; class gxInput{ public: gxRuntime *runtime; - IDirectInput7 *dirInput; + LPDIRECTINPUT8 dirInput; - gxInput( gxRuntime *runtime,IDirectInput7 *di ); + gxInput( gxRuntime *runtime, LPDIRECTINPUT8 di ); ~gxInput(); void reset(); @@ -45,6 +43,4 @@ public: int getJoystickType( int port )const; int numJoysticks()const; int toAscii( int key )const; -}; - -#endif \ No newline at end of file +}; \ No newline at end of file diff --git a/gxruntime/gxlight.cpp b/gxruntime/gxlight.cpp index acedd44..b215648 100644 --- a/gxruntime/gxlight.cpp +++ b/gxruntime/gxlight.cpp @@ -7,7 +7,6 @@ const float PI=3.14159265359f; //180 degrees const float TWOPI=PI*2.0f; //360 degrees const float HALFPI=PI*.5f; //90 degrees -const float FLT_EPSILON=.000001f; gxLight::gxLight( gxScene *s,int type ): scene(s){ diff --git a/gxruntime/gxlight.h b/gxruntime/gxlight.h index 50db4b6..522a459 100644 --- a/gxruntime/gxlight.h +++ b/gxruntime/gxlight.h @@ -1,4 +1,6 @@ +#include "GraphicsRuntime.h" + #ifndef GXLIGHT_H #define GXLIGHT_H diff --git a/gxruntime/gxmesh.cpp b/gxruntime/gxmesh.cpp index 2adcfe5..587a74a 100644 --- a/gxruntime/gxmesh.cpp +++ b/gxruntime/gxmesh.cpp @@ -35,9 +35,9 @@ bool gxMesh::lock( bool all ){ int flags=DDLOCK_WAIT|DDLOCK_WRITEONLY; //XP or less? - if( graphics->runtime->osinfo.dwMajorVersion<6 ){ + /*if( graphics->runtime->osinfo.dwMajorVersion<6 ){ flags|=(all ? DDLOCK_DISCARDCONTENTS : DDLOCK_NOOVERWRITE); - } + }*/ if( vertex_buff->Lock( flags,(void**)&locked_verts,0 )>=0 ){ mesh_dirty=false; diff --git a/gxruntime/gxmovie.cpp b/gxruntime/gxmovie.cpp index 2fffd8d..539a7bf 100644 --- a/gxruntime/gxmovie.cpp +++ b/gxruntime/gxmovie.cpp @@ -3,28 +3,28 @@ #include "gxmovie.h" #include "gxgraphics.h" -gxMovie::gxMovie( gxGraphics *g,IMultiMediaStream *mm ) -:gfx(g),mm_stream( mm ),playing(true){ +gxMovie::gxMovie(gxGraphics *g, IMultiMediaStream *mm) + :gfx(g), mm_stream(mm), playing(true) { - mm_stream->GetMediaStream( MSPID_PrimaryVideo,&vid_stream ); - vid_stream->QueryInterface( IID_IDirectDrawMediaStream,(void**)&dd_stream ); + ////mm_stream->GetMediaStream( MSPID_PrimaryVideo,&vid_stream ); + ////vid_stream->QueryInterface(IID_IDirectDrawMediaStream, (void**)&dd_stream); - DDSURFACEDESC desc={sizeof(desc)}; - dd_stream->GetFormat( &desc,0,0,0 ); + //DDSURFACEDESC desc = { sizeof(desc) }; + //dd_stream->GetFormat(&desc, 0, 0, 0); - canvas=gfx->createCanvas( desc.dwWidth,desc.dwHeight,0 ); //gxCanvas::CANVAS_NONDISPLAY ); - canvas->getSurface()->QueryInterface( IID_IDirectDrawSurface,(void**)&dd_surf ); + //canvas = gfx->createCanvas(desc.dwWidth, desc.dwHeight, 0); //gxCanvas::CANVAS_NONDISPLAY ); + //canvas->getSurface()->QueryInterface(IID_IDirectDrawSurface, (void**)&dd_surf); - src_rect.left=src_rect.top=0; - src_rect.right=desc.dwWidth;src_rect.bottom=desc.dwHeight; + //src_rect.left = src_rect.top = 0; + //src_rect.right = desc.dwWidth; src_rect.bottom = desc.dwHeight; - dd_stream->CreateSample( dd_surf,&src_rect,0,&dd_sample ); + //dd_stream->CreateSample(dd_surf, &src_rect, 0, &dd_sample); - mm_stream->SetState( STREAMSTATE_RUN ); + //mm_stream->SetState(STREAMSTATE_RUN); } -gxMovie::~gxMovie(){ - mm_stream->SetState( STREAMSTATE_STOP ); +gxMovie::~gxMovie() { + /*mm_stream->SetState(STREAMSTATE_STOP); dd_sample->Release(); dd_surf->Release(); @@ -32,17 +32,17 @@ gxMovie::~gxMovie(){ vid_stream->Release(); mm_stream->Release(); - gfx->freeCanvas( canvas ); + gfx->freeCanvas(canvas);*/ } -bool gxMovie::draw( gxCanvas *dest,int x,int y,int w,int h ){ - if( !playing ) return false; - if( !dd_sample->Update( 0,0,0,0 ) ){ - RECT dest_rect={x,y,x+w,y+h}; - dest->getSurface()->Blt( &dest_rect,canvas->getSurface(),&src_rect,DDBLT_WAIT,0 ); - dest->damage( dest_rect ); - }else{ - playing=false; - } +bool gxMovie::draw(gxCanvas *dest, int x, int y, int w, int h) { + if (!playing) return false; + /*if (!dd_sample->Update(0, 0, 0, 0)) { + RECT dest_rect = { x,y,x + w,y + h }; + dest->getSurface()->Blt(&dest_rect, canvas->getSurface(), &src_rect, DDBLT_WAIT, 0); + dest->damage(dest_rect); + } else { + playing = false; + }*/ return playing; } diff --git a/gxruntime/gxruntime.cpp b/gxruntime/gxruntime.cpp index f975283..6e4b5cc 100644 --- a/gxruntime/gxruntime.cpp +++ b/gxruntime/gxruntime.cpp @@ -1,42 +1,43 @@ +#pragma once +#include "GraphicsRuntime.h" #include "std.h" #include "gxruntime.h" #include "zmouse.h" +#include "windows.h" #define SPI_SETMOUSESPEED 113 -struct gxRuntime::GfxMode{ +struct gxRuntime::GfxMode { DDSURFACEDESC2 desc; }; -struct gxRuntime::GfxDriver{ +struct gxRuntime::GfxDriver { GUID *guid; std::string name; std::vector modes; -#ifdef PRO D3DDEVICEDESC7 d3d_desc; -#endif }; -static const int static_ws=WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX; -static const int scaled_ws=WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX; +static const int static_ws = WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; +static const int scaled_ws = WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; static string app_title; static string app_close; static gxRuntime *runtime; -static bool busy,suspended; +static bool busy, suspended; static volatile bool run_flag; static DDSURFACEDESC2 desktop_desc; -typedef int (_stdcall *LibFunc)( const void *in,int in_sz,void *out,int out_sz ); +typedef int(_stdcall *LibFunc)(const void *in, int in_sz, void *out, int out_sz); -struct gxDll{ +struct gxDll { HINSTANCE hinst; - map funcs; + map funcs; }; -static map libs; +static map libs; -static LRESULT CALLBACK windowProc( HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam ); +static LRESULT CALLBACK windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); //current gfx mode // @@ -58,183 +59,179 @@ static Debugger *debugger; static set timers; -enum{ - WM_STOP=WM_USER+1,WM_RUN,WM_END +enum { + WM_STOP = WM_USER + 1, WM_RUN, WM_END }; //////////////////// // STATIC STARTUP // //////////////////// -gxRuntime *gxRuntime::openRuntime( HINSTANCE hinst,const string &cmd_line,Debugger *d ){ - if( runtime ) return 0; +gxRuntime *gxRuntime::openRuntime(HINSTANCE hinst, const string &cmd_line, Debugger *d) { + if (runtime) return 0; //create debugger - debugger=d; + debugger = d; //create WNDCLASS WNDCLASS wndclass; - memset(&wndclass,0,sizeof(wndclass)); - wndclass.style=CS_HREDRAW|CS_VREDRAW|CS_OWNDC; - wndclass.lpfnWndProc=::windowProc; - wndclass.hInstance=hinst; - wndclass.lpszClassName="Blitz Runtime Class"; - wndclass.hCursor=(HCURSOR)LoadCursor( 0,IDC_ARROW ); - wndclass.hbrBackground=(HBRUSH)GetStockObject( BLACK_BRUSH ); - RegisterClass( &wndclass ); + memset(&wndclass, 0, sizeof(wndclass)); + wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wndclass.lpfnWndProc = ::windowProc; + wndclass.hInstance = hinst; + wndclass.lpszClassName = TEXT("Blitz Runtime Class"); + wndclass.hCursor = (HCURSOR)LoadCursor(0, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + RegisterClass(&wndclass); - gfx_mode=0; - clipper=0;primSurf=0; - busy=suspended=false; - run_flag=true; + gfx_mode = 0; + clipper = 0; primSurf = 0; + busy = suspended = false; + run_flag = true; - const char *app_t=" "; - int ws=WS_CAPTION,ws_ex=0; + const char *app_t = " "; + int ws = WS_CAPTION, ws_ex = 0; - HWND hwnd=CreateWindowEx( ws_ex,"Blitz Runtime Class",app_t,ws,0,0,0,0,0,0,0,0 ); + HWND hwnd = CreateWindowEx(ws_ex, "Blitz Runtime Class", app_t, ws, 0, 0, 0, 0, 0, 0, 0, 0); - UpdateWindow( hwnd ); + UpdateWindow(hwnd); - runtime=d_new gxRuntime( hinst,cmd_line,hwnd ); + runtime = d_new gxRuntime(hinst, cmd_line, hwnd); return runtime; } -void gxRuntime::closeRuntime( gxRuntime *r ){ - if( !runtime || runtime!=r ) return; +void gxRuntime::closeRuntime(gxRuntime *r) { + if (!runtime || runtime != r) return; - map::const_iterator it; - for( it=libs.begin();it!=libs.end();++it ){ - FreeLibrary( it->second->hinst ); + map::const_iterator it; + for (it = libs.begin(); it != libs.end(); ++it) { + FreeLibrary(it->second->hinst); } libs.clear(); delete runtime; - runtime=0; + runtime = 0; } ////////////////////////// // RUNTIME CONSTRUCTION // ////////////////////////// -typedef int (_stdcall *SetAppCompatDataFunc)( int x,int y ); +typedef int(_stdcall *SetAppCompatDataFunc)(int x, int y); -gxRuntime::gxRuntime( HINSTANCE hi,const string &cl,HWND hw ): -hinst(hi),cmd_line(cl),hwnd(hw),curr_driver(0),enum_all(false), -pointer_visible(true),audio(0),input(0),graphics(0),fileSystem(0),use_di(false){ +gxRuntime::gxRuntime(HINSTANCE hi, const string &cl, HWND hw) : + hinst(hi), cmd_line(cl), hwnd(hw), curr_driver(0), enum_all(false), + pointer_visible(true), audio(0), input(0), graphics(0), fileSystem(0), use_di(false) { - CoInitialize( 0 ); + CoInitialize(0); enumGfx(); TIMECAPS tc; - timeGetDevCaps( &tc,sizeof(tc) ); - timeBeginPeriod( tc.wPeriodMin ); + timeGetDevCaps(&tc, sizeof(tc)); + timeBeginPeriod(tc.wPeriodMin); - memset( &osinfo,0,sizeof(osinfo) ); - osinfo.dwOSVersionInfoSize=sizeof(osinfo); - GetVersionEx( &osinfo ); - - HMODULE ddraw=LoadLibraryA( "ddraw.dll" ); - if( ddraw ){ - SetAppCompatDataFunc SetAppCompatData=(SetAppCompatDataFunc)GetProcAddress( ddraw,"SetAppCompatData" ); - if( SetAppCompatData ) SetAppCompatData( 12,0 ); - FreeLibrary( ddraw ); + HMODULE ddraw = LoadLibraryA("ddraw.dll"); + if (ddraw) { + SetAppCompatDataFunc SetAppCompatData = (SetAppCompatDataFunc)GetProcAddress(ddraw, "SetAppCompatData"); + if (SetAppCompatData) SetAppCompatData(12, 0); + FreeLibrary(ddraw); } } -gxRuntime::~gxRuntime(){ - while( timers.size() ) freeTimer( *timers.begin() ); - if( audio ) closeAudio( audio ); - if( graphics ) closeGraphics( graphics ); - if( input ) closeInput( input ); +gxRuntime::~gxRuntime() { + while (timers.size()) freeTimer(*timers.begin()); + if (audio) closeAudio(audio); + if (graphics) closeGraphics(graphics); + if (input) closeInput(input); TIMECAPS tc; - timeGetDevCaps( &tc,sizeof(tc) ); - timeEndPeriod( tc.wPeriodMin ); + timeGetDevCaps(&tc, sizeof(tc)); + timeEndPeriod(tc.wPeriodMin); denumGfx(); - DestroyWindow( hwnd ); - UnregisterClass( "Blitz Runtime Class",hinst ); + DestroyWindow(hwnd); + UnregisterClass("Blitz Runtime Class", hinst); CoUninitialize(); } -void gxRuntime::pauseAudio(){ - if( audio ) audio->pause(); +void gxRuntime::pauseAudio() { + if (audio) audio->pause(); } -void gxRuntime::resumeAudio(){ - if( audio ) audio->resume(); +void gxRuntime::resumeAudio() { + if (audio) audio->resume(); } -void gxRuntime::backupGraphics(){ - if( auto_suspend ){ +void gxRuntime::backupGraphics() { + if (auto_suspend) { graphics->backup(); } } -void gxRuntime::restoreGraphics(){ - if( auto_suspend ){ - if( !graphics->restore() ) gfx_lost=true; +void gxRuntime::restoreGraphics() { + if (auto_suspend) { + if (!graphics->restore()) gfx_lost = true; } } -void gxRuntime::resetInput(){ - if( input ) input->reset(); +void gxRuntime::resetInput() { + if (input) input->reset(); } -void gxRuntime::acquireInput(){ - if( !input ) return; - if( gfx_mode==3 ){ - if( use_di ){ - use_di=input->acquire(); - }else{ +void gxRuntime::acquireInput() { + if (!input) return; + if (gfx_mode == 3) { + if (use_di) { + use_di = input->acquire(); + } else { } } input->reset(); } -void gxRuntime::unacquireInput(){ - if( !input ) return; - if( gfx_mode==3 && use_di ) input->unacquire(); +void gxRuntime::unacquireInput() { + if (!input) return; + if (gfx_mode == 3 && use_di) input->unacquire(); input->reset(); } ///////////// // SUSPEND // ///////////// -void gxRuntime::suspend(){ - busy=true; +void gxRuntime::suspend() { + busy = true; pauseAudio(); backupGraphics(); unacquireInput(); - suspended=true; - busy=false; + suspended = true; + busy = false; - if( gfx_mode==3 ) ShowCursor(1); + if (gfx_mode == 3) ShowCursor(1); - if( debugger ) debugger->debugStop(); + if (debugger) debugger->debugStop(); } //////////// // RESUME // //////////// -void gxRuntime::resume(){ - if( gfx_mode==3 ) ShowCursor(0); - busy=true; +void gxRuntime::resume() { + if (gfx_mode == 3) ShowCursor(0); + busy = true; acquireInput(); restoreGraphics(); resumeAudio(); - suspended=false; - busy=false; + suspended = false; + busy = false; - if( debugger ) debugger->debugRun(); + if (debugger) debugger->debugRun(); } /////////////////// // FORCE SUSPEND // /////////////////// -void gxRuntime::forceSuspend(){ - if( gfx_mode==3 ){ - SetForegroundWindow( GetDesktopWindow() ); - ShowWindow( GetDesktopWindow(),SW_SHOW ); - }else{ +void gxRuntime::forceSuspend() { + if (gfx_mode == 3) { + SetForegroundWindow(GetDesktopWindow()); + ShowWindow(GetDesktopWindow(), SW_SHOW); + } else { suspend(); } } @@ -242,11 +239,11 @@ void gxRuntime::forceSuspend(){ ////////////////// // FORCE RESUME // ////////////////// -void gxRuntime::forceResume(){ - if( gfx_mode==3 ){ - SetForegroundWindow( hwnd ); - ShowWindow( hwnd,SW_SHOWMAXIMIZED ); - }else{ +void gxRuntime::forceResume() { + if (gfx_mode == 3) { + SetForegroundWindow(hwnd); + ShowWindow(hwnd, SW_SHOWMAXIMIZED); + } else { resume(); } } @@ -254,27 +251,27 @@ void gxRuntime::forceResume(){ /////////// // PAINT // /////////// -void gxRuntime::paint(){ - switch( gfx_mode ){ - case 0: +void gxRuntime::paint() { + switch (gfx_mode) { + case 0: { } break; - case 1:case 2: //scaled windowed mode. + case 1:case 2: //scaled windowed mode. { - RECT src,dest; - src.left=src.top=0; - GetClientRect( hwnd,&dest ); - src.right=gfx_mode==1 ? graphics->getWidth() : dest.right; - src.bottom=gfx_mode==1 ? graphics->getHeight() : dest.bottom; - POINT p;p.x=p.y=0;ClientToScreen( hwnd,&p ); - dest.left+=p.x;dest.right+=p.x; - dest.top+=p.y;dest.bottom+=p.y; - gxCanvas *f=graphics->getFrontCanvas(); - primSurf->Blt( &dest,f->getSurface(),&src,0,0 ); + RECT src, dest; + src.left = src.top = 0; + GetClientRect(hwnd, &dest); + src.right = gfx_mode == 1 ? graphics->getWidth() : dest.right; + src.bottom = gfx_mode == 1 ? graphics->getHeight() : dest.bottom; + POINT p; p.x = p.y = 0; ClientToScreen(hwnd, &p); + dest.left += p.x; dest.right += p.x; + dest.top += p.y; dest.bottom += p.y; + gxCanvas *f = graphics->getFrontCanvas(); + primSurf->Blt(&dest, f->getSurface(), &src, 0, 0); } break; - case 3: + case 3: { //exclusive mode } @@ -285,236 +282,236 @@ void gxRuntime::paint(){ ////////// // FLIP // ////////// -void gxRuntime::flip( bool vwait ){ - gxCanvas *b=graphics->getBackCanvas(); - gxCanvas *f=graphics->getFrontCanvas(); +void gxRuntime::flip(bool vwait) { + gxCanvas *b = graphics->getBackCanvas(); + gxCanvas *f = graphics->getFrontCanvas(); int n; - switch( gfx_mode ){ - case 1:case 2: - if( vwait ) graphics->vwait(); - f->setModify( b->getModify() ); - if( f->getModify()!=mod_cnt ){ - mod_cnt=f->getModify(); - paint(); - } - break; - case 3: - if( vwait ){ - BOOL vb; - while( graphics->dirDraw->GetVerticalBlankStatus( &vb )>=0 && vb ) {} - n=f->getSurface()->Flip( 0,DDFLIP_WAIT ); - }else{ - n=f->getSurface()->Flip( 0,DDFLIP_NOVSYNC|DDFLIP_WAIT ); - } - if( n>=0 ) return; - string t="Flip Failed! Return code:"+itoa(n&0x7fff); - debugLog( t.c_str() ); - break; + switch (gfx_mode) { + case 1:case 2: + if (vwait) graphics->vwait(); + f->setModify(b->getModify()); + if (f->getModify() != mod_cnt) { + mod_cnt = f->getModify(); + paint(); + } + break; + case 3: + if (vwait) { + BOOL vb; + while (graphics->dirDraw->GetVerticalBlankStatus(&vb) >= 0 && vb) {} + n = f->getSurface()->Flip(0, DDFLIP_WAIT); + } else { + n = f->getSurface()->Flip(0, DDFLIP_NOVSYNC | DDFLIP_WAIT); + } + if (n >= 0) return; + string t = "Flip Failed! Return code:" + itoa(n & 0x7fff); + debugLog(t.c_str()); + break; } } //////////////// // MOVE MOUSE // //////////////// -void gxRuntime::moveMouse( int x,int y ){ +void gxRuntime::moveMouse(int x, int y) { POINT p; RECT rect; - switch( gfx_mode ){ - case 1: - GetClientRect( hwnd,&rect ); - x=x*(rect.right-rect.left)/graphics->getWidth(); - y=y*(rect.bottom-rect.top)/graphics->getHeight(); - case 2: - p.x=x;p.y=y;ClientToScreen( hwnd,&p );x=p.x;y=p.y; - break; - case 3: - if( use_di ) return; - break; - default: - return; + switch (gfx_mode) { + case 1: + GetClientRect(hwnd, &rect); + x = x*(rect.right - rect.left) / graphics->getWidth(); + y = y*(rect.bottom - rect.top) / graphics->getHeight(); + case 2: + p.x = x; p.y = y; ClientToScreen(hwnd, &p); x = p.x; y = p.y; + break; + case 3: + if (use_di) return; + break; + default: + return; } - SetCursorPos( x,y ); + SetCursorPos(x, y); } ///////////////// // WINDOW PROC // ///////////////// -LRESULT gxRuntime::windowProc( HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam ){ +LRESULT gxRuntime::windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { - if( busy ){ - return DefWindowProc( hwnd,msg,wparam,lparam ); + if (busy) { + return DefWindowProc(hwnd, msg, wparam, lparam); } PAINTSTRUCT ps; //handle 'special' messages! - switch( msg ){ - case WM_PAINT: - if( gfx_mode && !auto_suspend ){ - if( !graphics->restore() ) gfx_lost=true; - } - BeginPaint( hwnd,&ps ); - paint(); - EndPaint( hwnd,&ps ); - return DefWindowProc( hwnd,msg,wparam,lparam ); - case WM_ERASEBKGND: - return gfx_mode ? 1 : DefWindowProc( hwnd,msg,wparam,lparam ); - case WM_CLOSE: - if( app_close.size() ){ - int n=MessageBox( hwnd,app_close.c_str(),app_title.c_str(),MB_OKCANCEL|MB_ICONWARNING|MB_SETFOREGROUND|MB_TOPMOST ); - if( n!=IDOK ) return 0; - } - asyncEnd(); - return 0; - case WM_SETCURSOR: - if( !suspended ){ - if( gfx_mode==3 ){ - SetCursor( 0 ); - return 1; - }else if( !pointer_visible ){ - POINT p; - GetCursorPos( &p ); - ScreenToClient( hwnd,&p ); - RECT r;GetClientRect( hwnd,&r ); - if( p.x>=0 && p.y>=0 && p.xrestore()) gfx_lost = true; + } + BeginPaint(hwnd, &ps); + paint(); + EndPaint(hwnd, &ps); + return DefWindowProc(hwnd, msg, wparam, lparam); + case WM_ERASEBKGND: + return gfx_mode ? 1 : DefWindowProc(hwnd, msg, wparam, lparam); + case WM_CLOSE: + if (app_close.size()) { + int n = MessageBox(hwnd, app_close.c_str(), app_title.c_str(), MB_OKCANCEL | MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST); + if (n != IDOK) return 0; + } + asyncEnd(); + return 0; + case WM_SETCURSOR: + if (!suspended) { + if (gfx_mode == 3) { + SetCursor(0); return 1; + } else if (!pointer_visible) { + POINT p; + GetCursorPos(&p); + ScreenToClient(hwnd, &p); + RECT r; GetClientRect(hwnd, &r); + if (p.x >= 0 && p.y >= 0 && p.x < r.right && p.y < r.bottom) { + SetCursor(0); + return 1; + } } } - } - break; - case WM_ACTIVATEAPP: - if( auto_suspend ){ - if( wparam ){ - if( suspended ) resume(); - }else{ - if( !suspended ) suspend(); + break; + case WM_ACTIVATEAPP: + if (auto_suspend) { + if (wparam) { + if (suspended) resume(); + } else { + if (!suspended) suspend(); + } } - } - break; + break; } - if( !input || suspended ) return DefWindowProc( hwnd,msg,wparam,lparam ); + if (!input || suspended) return DefWindowProc(hwnd, msg, wparam, lparam); - if( gfx_mode==3 && use_di ){ - use_di=input->acquire(); - return DefWindowProc( hwnd,msg,wparam,lparam ); + if (gfx_mode == 3 && use_di) { + use_di = input->acquire(); + return DefWindowProc(hwnd, msg, wparam, lparam); } - static const int MK_ALLBUTTONS=MK_LBUTTON|MK_RBUTTON|MK_MBUTTON; + static const int MK_ALLBUTTONS = MK_LBUTTON | MK_RBUTTON | MK_MBUTTON; //handle input messages - switch( msg ){ - case WM_LBUTTONDOWN: - input->wm_mousedown(1); - SetCapture(hwnd); - break; - case WM_LBUTTONUP: - input->wm_mouseup(1); - if( !(wparam&MK_ALLBUTTONS) ) ReleaseCapture(); - break; - case WM_RBUTTONDOWN: - input->wm_mousedown(2); - SetCapture( hwnd ); - break; - case WM_RBUTTONUP: - input->wm_mouseup(2); - if( !(wparam&MK_ALLBUTTONS) ) ReleaseCapture(); - break; - case WM_MBUTTONDOWN: - input->wm_mousedown(3); - SetCapture( hwnd ); - break; - case WM_MBUTTONUP: - input->wm_mouseup(3); - if( !(wparam&MK_ALLBUTTONS) ) ReleaseCapture(); - break; - case WM_MOUSEMOVE: - if( !graphics ) break; - if( gfx_mode==3 && !use_di ){ - POINT p;GetCursorPos( &p ); - input->wm_mousemove( p.x,p.y ); - }else{ - int x=(short)(lparam&0xffff),y=lparam>>16; - if( gfx_mode==1 ){ - RECT rect;GetClientRect( hwnd,&rect ); - x=x*graphics->getWidth()/(rect.right-rect.left); - y=y*graphics->getHeight()/(rect.bottom-rect.top); + switch (msg) { + case WM_LBUTTONDOWN: + input->wm_mousedown(1); + SetCapture(hwnd); + break; + case WM_LBUTTONUP: + input->wm_mouseup(1); + if (!(wparam&MK_ALLBUTTONS)) ReleaseCapture(); + break; + case WM_RBUTTONDOWN: + input->wm_mousedown(2); + SetCapture(hwnd); + break; + case WM_RBUTTONUP: + input->wm_mouseup(2); + if (!(wparam&MK_ALLBUTTONS)) ReleaseCapture(); + break; + case WM_MBUTTONDOWN: + input->wm_mousedown(3); + SetCapture(hwnd); + break; + case WM_MBUTTONUP: + input->wm_mouseup(3); + if (!(wparam&MK_ALLBUTTONS)) ReleaseCapture(); + break; + case WM_MOUSEMOVE: + if (!graphics) break; + if (gfx_mode == 3 && !use_di) { + POINT p; GetCursorPos(&p); + input->wm_mousemove(p.x, p.y); + } else { + int x = (short)(lparam & 0xffff), y = lparam >> 16; + if (gfx_mode == 1) { + RECT rect; GetClientRect(hwnd, &rect); + x = x*graphics->getWidth() / (rect.right - rect.left); + y = y*graphics->getHeight() / (rect.bottom - rect.top); + } + if (x < 0) x = 0; + else if (x >= graphics->getWidth()) x = graphics->getWidth() - 1; + if (y < 0) y = 0; + else if (y >= graphics->getHeight()) y = graphics->getHeight() - 1; + input->wm_mousemove(x, y); } - if( x<0 ) x=0; - else if( x>=graphics->getWidth() ) x=graphics->getWidth()-1; - if( y<0 ) y=0; - else if( y>=graphics->getHeight() ) y=graphics->getHeight()-1; - input->wm_mousemove( x,y ); - } - break; - case WM_MOUSEWHEEL: - input->wm_mousewheel( (short)HIWORD( wparam ) ); - break; - case WM_KEYDOWN:case WM_SYSKEYDOWN: - if( lparam & 0x40000000 ) break; - if( int n=((lparam>>17)&0x80)|((lparam>>16)&0x7f) ) input->wm_keydown( n ); - break; - case WM_KEYUP:case WM_SYSKEYUP: - if( int n=((lparam>>17)&0x80)|((lparam>>16)&0x7f) ) input->wm_keyup( n ); - break; - default: - return DefWindowProc( hwnd,msg,wparam,lparam ); + break; + case WM_MOUSEWHEEL: + input->wm_mousewheel((short)HIWORD(wparam)); + break; + case WM_KEYDOWN:case WM_SYSKEYDOWN: + if (lparam & 0x40000000) break; + if (int n = ((lparam >> 17) & 0x80) | ((lparam >> 16) & 0x7f)) input->wm_keydown(n); + break; + case WM_KEYUP:case WM_SYSKEYUP: + if (int n = ((lparam >> 17) & 0x80) | ((lparam >> 16) & 0x7f)) input->wm_keyup(n); + break; + default: + return DefWindowProc(hwnd, msg, wparam, lparam); } return 0; } -static LRESULT CALLBACK windowProc( HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam ){ - if( runtime ) return runtime->windowProc( hwnd,msg,wparam,lparam ); - return DefWindowProc( hwnd,msg,wparam,lparam ); +static LRESULT CALLBACK windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { + if (runtime) return runtime->windowProc(hwnd, msg, wparam, lparam); + return DefWindowProc(hwnd, msg, wparam, lparam); } ////////////////////////////// //STOP FROM EXTERNAL SOURCE // ////////////////////////////// -void gxRuntime::asyncStop(){ - PostMessage( hwnd,WM_STOP,0,0 ); +void gxRuntime::asyncStop() { + PostMessage(hwnd, WM_STOP, 0, 0); } ////////////////////////////// //RUN FROM EXTERNAL SOURCE // ////////////////////////////// -void gxRuntime::asyncRun(){ - PostMessage( hwnd,WM_RUN,0,0 ); +void gxRuntime::asyncRun() { + PostMessage(hwnd, WM_RUN, 0, 0); } ////////////////////////////// // END FROM EXTERNAL SOURCE // ////////////////////////////// -void gxRuntime::asyncEnd(){ - PostMessage( hwnd,WM_END,0,0 ); +void gxRuntime::asyncEnd() { + PostMessage(hwnd, WM_END, 0, 0); } ////////// // IDLE // ////////// -bool gxRuntime::idle(){ - for(;;){ +bool gxRuntime::idle() { + for (;;) { MSG msg; - if( suspended && run_flag ){ - GetMessage( &msg,0,0,0 ); - }else{ - if( !PeekMessage( &msg,0,0,0,PM_REMOVE ) ) return run_flag; + if (suspended && run_flag) { + GetMessage(&msg, 0, 0, 0); + } else { + if (!PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) return run_flag; } - switch( msg.message ){ - case WM_STOP: - if( !suspended ) forceSuspend(); - break; - case WM_RUN: - if( suspended ) forceResume(); - break; - case WM_END: - debugger=0; - run_flag=false; - break; - default: - DispatchMessage( &msg ); + switch (msg.message) { + case WM_STOP: + if (!suspended) forceSuspend(); + break; + case WM_RUN: + if (suspended) forceResume(); + break; + case WM_END: + debugger = 0; + run_flag = false; + break; + default: + DispatchMessage(&msg); } } return run_flag; @@ -523,203 +520,204 @@ bool gxRuntime::idle(){ /////////// // DELAY // /////////// -bool gxRuntime::delay( int ms ){ - int t=timeGetTime()+ms; - for(;;){ - if( !idle() ) return false; - int d=t-timeGetTime(); //how long left to wait - if( d<=0 ) return true; - if( d>100 ) d=100; - Sleep( d ); +bool gxRuntime::delay(int ms) { + int t = timeGetTime() + ms; + for (;;) { + if (!idle()) return false; + int d = t - timeGetTime(); //how long left to wait + if (d <= 0) return true; + if (d > 100) d = 100; + Sleep(d); } } /////////////// // DEBUGSTMT // /////////////// -void gxRuntime::debugStmt( int pos,const char *file ){ - if( debugger ) debugger->debugStmt( pos,file ); +void gxRuntime::debugStmt(int pos, const char *file) { + if (debugger) debugger->debugStmt(pos, file); } /////////////// // DEBUGSTOP // /////////////// -void gxRuntime::debugStop(){ - if( !suspended ) forceSuspend(); +void gxRuntime::debugStop() { + if (!suspended) forceSuspend(); } //////////////// // DEBUGENTER // //////////////// -void gxRuntime::debugEnter( void *frame,void *env,const char *func ){ - if( debugger ) debugger->debugEnter( frame,env,func ); +void gxRuntime::debugEnter(void *frame, void *env, const char *func) { + if (debugger) debugger->debugEnter(frame, env, func); } //////////////// // DEBUGLEAVE // //////////////// -void gxRuntime::debugLeave(){ - if( debugger ) debugger->debugLeave(); +void gxRuntime::debugLeave() { + if (debugger) debugger->debugLeave(); } //////////////// // DEBUGERROR // //////////////// -void gxRuntime::debugError( const char *t ){ - if( !debugger ) return; - Debugger *d=debugger; +void gxRuntime::debugError(const char *t) { + if (!debugger) return; + Debugger *d = debugger; asyncEnd(); - if( !suspended ){ + if (!suspended) { forceSuspend(); } - d->debugMsg( t,true ); + d->debugMsg(t, true); } /////////////// // DEBUGINFO // /////////////// -void gxRuntime::debugInfo( const char *t ){ - if( !debugger ) return; - Debugger *d=debugger; +void gxRuntime::debugInfo(const char *t) { + if (!debugger) return; + Debugger *d = debugger; asyncEnd(); - if( !suspended ){ + if (!suspended) { forceSuspend(); } - d->debugMsg( t,false ); + d->debugMsg(t, false); } ////////////// // DEBUGLOG // ////////////// -void gxRuntime::debugLog( const char *t ){ - if( debugger ) debugger->debugLog( t ); +void gxRuntime::debugLog(const char *t) { + if (debugger) debugger->debugLog(t); } ///////////////////////// // RETURN COMMAND LINE // ///////////////////////// -string gxRuntime::commandLine(){ +string gxRuntime::commandLine() { return cmd_line; } ///////////// // EXECUTE // ///////////// -bool gxRuntime::execute( const string &cmd_line ){ +bool gxRuntime::execute(const string &cmd_line) { - if( !cmd_line.size() ) return false; + if (!cmd_line.size()) return false; //convert cmd_line to cmd and params - string cmd=cmd_line,params; - while( cmd.size() && cmd[0]==' ' ) cmd=cmd.substr( 1 ); - if( cmd.find( '\"' )==0 ){ - int n=cmd.find( '\"',1 ); - if( n!=string::npos ){ - params=cmd.substr( n+1 ); - cmd=cmd.substr( 1,n-1 ); + string cmd = cmd_line, params; + while (cmd.size() && cmd[0] == ' ') cmd = cmd.substr(1); + if (cmd.find('\"') == 0) { + int n = cmd.find('\"', 1); + if (n != string::npos) { + params = cmd.substr(n + 1); + cmd = cmd.substr(1, n - 1); } - }else{ - int n=cmd.find( ' ' ); - if( n!=string::npos ){ - params=cmd.substr( n+1 ); - cmd=cmd.substr( 0,n ); + } else { + int n = cmd.find(' '); + if (n != string::npos) { + params = cmd.substr(n + 1); + cmd = cmd.substr(0, n); } } - while( params.size() && params[0]==' ' ) params=params.substr( 1 ); - while( params.size() && params[params.size()-1]==' ' ) params=params.substr( 0,params.size()-1 ); + while (params.size() && params[0] == ' ') params = params.substr(1); + while (params.size() && params[params.size() - 1] == ' ') params = params.substr(0, params.size() - 1); - SetForegroundWindow( GetDesktopWindow() ); + SetForegroundWindow(GetDesktopWindow()); - return (int)ShellExecute( GetDesktopWindow(),0,cmd.c_str(),params.size() ? params.c_str() : 0,0,SW_SHOW )>32; + return (int)ShellExecute(GetDesktopWindow(), 0, cmd.c_str(), params.size() ? params.c_str() : 0, 0, SW_SHOW) > 32; } /////////////// // APP TITLE // /////////////// -void gxRuntime::setTitle( const string &t,const string &e ){ - app_title=t; - app_close=e; - SetWindowText( hwnd,app_title.c_str() ); +void gxRuntime::setTitle(const string &t, const string &e) { + app_title = t; + app_close = e; + SetWindowText(hwnd, app_title.c_str()); } ////////////////// // GETMILLISECS // ////////////////// -int gxRuntime::getMilliSecs(){ +int gxRuntime::getMilliSecs() { return timeGetTime(); } ///////////////////// // POINTER VISIBLE // ///////////////////// -void gxRuntime::setPointerVisible( bool vis ){ - if( pointer_visible==vis ) return; +void gxRuntime::setPointerVisible(bool vis) { + if (pointer_visible == vis) return; - pointer_visible=vis; - if( gfx_mode==3 ) return; + pointer_visible = vis; + if (gfx_mode == 3) return; //force a WM_SETCURSOR POINT pt; - GetCursorPos( &pt ); - SetCursorPos( pt.x,pt.y ); + GetCursorPos(&pt); + SetCursorPos(pt.x, pt.y); } ///////////////// // AUDIO SETUP // ///////////////// -gxAudio *gxRuntime::openAudio( int flags ){ - if( audio ) return 0; +gxAudio *gxRuntime::openAudio(int flags) { + if (audio) return 0; - int f_flags= - FSOUND_INIT_GLOBALFOCUS| + int f_flags = + FSOUND_INIT_GLOBALFOCUS | FSOUND_INIT_USEDEFAULTMIDISYNTH; - FSOUND_SetHWND( hwnd ); - if( !FSOUND_Init( 44100,1024,f_flags ) ){ + FSOUND_SetHWND(hwnd); + if (!FSOUND_Init(44100, 1024, f_flags)) { return 0; } - audio=d_new gxAudio( this ); + audio = d_new gxAudio(this); return audio; } -void gxRuntime::closeAudio( gxAudio *a ){ - if( !audio || audio!=a ) return; +void gxRuntime::closeAudio(gxAudio *a) { + if (!audio || audio != a) return; delete audio; - audio=0; + audio = 0; } ///////////////// // INPUT SETUP // ///////////////// -gxInput *gxRuntime::openInput( int flags ){ - if( input ) return 0; - IDirectInput7 *di; - if( DirectInputCreateEx( hinst,DIRECTINPUT_VERSION,IID_IDirectInput7,(void**)&di,0 )>=0 ){ - input=d_new gxInput( this,di ); +gxInput *gxRuntime::openInput(int flags) { + if (input) return 0; + LPDIRECTINPUT8 di; + if (DirectInput8Create(hinst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&di, NULL) >= 0) { + //if (DirectInput8Create(hinst, DIRECTINPUT_VERSION, (void**)&di, NULL) >= 0) { + input = d_new gxInput(this, di); acquireInput(); - }else{ - debugInfo( "Create DirectInput failed" ); + } else { + debugInfo("Create DirectInput failed"); } return input; } -void gxRuntime::closeInput( gxInput *i ){ - if( !input || input!=i ) return; +void gxRuntime::closeInput(gxInput *i) { + if (!input || input != i) return; unacquireInput(); delete input; - input=0; + input = 0; } ///////////////////////////////////////////////////// // TIMER CALLBACK FOR AUTOREFRESH OF WINDOWED MODE // ///////////////////////////////////////////////////// -static void CALLBACK timerCallback( UINT id,UINT msg,DWORD user,DWORD dw1,DWORD dw2 ){ - if( gfx_mode ){ - gxCanvas *f=runtime->graphics->getFrontCanvas(); - if( f->getModify()!=mod_cnt ){ - mod_cnt=f->getModify(); - InvalidateRect( runtime->hwnd,0,false ); +static void CALLBACK timerCallback(UINT id, UINT msg, DWORD user, DWORD dw1, DWORD dw2) { + if (gfx_mode) { + gxCanvas *f = runtime->graphics->getFrontCanvas(); + if (f->getModify() != mod_cnt) { + mod_cnt = f->getModify(); + InvalidateRect(runtime->hwnd, 0, false); } } } @@ -727,91 +725,89 @@ static void CALLBACK timerCallback( UINT id,UINT msg,DWORD user,DWORD dw1,DWORD //////////////////// // GRAPHICS SETUP // //////////////////// -void gxRuntime::backupWindowState(){ - GetWindowRect( hwnd,&t_rect ); - t_style=GetWindowLong( hwnd,GWL_STYLE ); +void gxRuntime::backupWindowState() { + GetWindowRect(hwnd, &t_rect); + t_style = GetWindowLong(hwnd, GWL_STYLE); } -void gxRuntime::restoreWindowState(){ - SetWindowLong( hwnd,GWL_STYLE,t_style ); - SetWindowPos( - hwnd,0,t_rect.left,t_rect.top, - t_rect.right-t_rect.left,t_rect.bottom-t_rect.top, - SWP_NOZORDER|SWP_FRAMECHANGED ); +void gxRuntime::restoreWindowState() { + SetWindowLong(hwnd, GWL_STYLE, t_style); + SetWindowPos( + hwnd, 0, t_rect.left, t_rect.top, + t_rect.right - t_rect.left, t_rect.bottom - t_rect.top, + SWP_NOZORDER | SWP_FRAMECHANGED); } -bool gxRuntime::setDisplayMode( int w,int h,int d,bool d3d,IDirectDraw7 *dirDraw ){ +bool gxRuntime::setDisplayMode(int w, int h, int d, bool d3d, IDirectDraw7 *dirDraw) { - if( d ) return dirDraw->SetDisplayMode( w,h,d,0,0 )>=0; + if (d) return dirDraw->SetDisplayMode(w, h, d, 0, 0) >= 0; - int best_d=0; + int best_d = 0; - if( d3d ){ -#ifdef PRO - int bd=curr_driver->d3d_desc.dwDeviceRenderBitDepth; - if( bd & DDBD_32 ) best_d=32; - else if( bd & DDBD_24 ) best_d=24; - else if( bd & DDBD_16 ) best_d=16; -#endif - }else{ - int best_n=0; - for( d=16;d<=32;d+=8 ){ - if( dirDraw->SetDisplayMode( w,h,d,0,0 )<0 ) continue; - DDCAPS caps={ sizeof(caps) }; - dirDraw->GetCaps( &caps,0 ); - int n=0; - if( caps.dwCaps & DDCAPS_BLT ) ++n; - if( caps.dwCaps & DDCAPS_BLTCOLORFILL ) ++n; - if( caps.dwCKeyCaps & DDCKEYCAPS_SRCBLT ) ++n; - if( caps.dwCaps2 & DDCAPS2_WIDESURFACES ) ++n; - if( n==4 ) return true; - if( n>best_n ){ - best_d=d; - best_n=n; + if (d3d) { + int bd = curr_driver->d3d_desc.dwDeviceRenderBitDepth; + if (bd & DDBD_32) best_d = 32; + else if (bd & DDBD_24) best_d = 24; + else if (bd & DDBD_16) best_d = 16; + } else { + int best_n = 0; + for (d = 16; d <= 32; d += 8) { + if (dirDraw->SetDisplayMode(w, h, d, 0, 0) < 0) continue; + DDCAPS caps = { sizeof(caps) }; + dirDraw->GetCaps(&caps, 0); + int n = 0; + if (caps.dwCaps & DDCAPS_BLT) ++n; + if (caps.dwCaps & DDCAPS_BLTCOLORFILL) ++n; + if (caps.dwCKeyCaps & DDCKEYCAPS_SRCBLT) ++n; + if (caps.dwCaps2 & DDCAPS2_WIDESURFACES) ++n; + if (n == 4) return true; + if (n > best_n) { + best_d = d; + best_n = n; } dirDraw->RestoreDisplayMode(); } } - return best_d ? dirDraw->SetDisplayMode( w,h,best_d,0,0 )>=0 : false; + return best_d ? dirDraw->SetDisplayMode(w, h, best_d, 0, 0) >= 0 : false; } -gxGraphics *gxRuntime::openWindowedGraphics( int w,int h,int d,bool d3d ){ +gxGraphics *gxRuntime::openWindowedGraphics(int w, int h, int d, bool d3d) { IDirectDraw7 *dd; - if( DirectDrawCreateEx( curr_driver->guid,(void**)&dd,IID_IDirectDraw7,0 )<0 ) return 0; + if (DirectDrawCreateEx(curr_driver->guid, (void**)&dd, IID_IDirectDraw7, 0) < 0) return 0; //set coop level - if( dd->SetCooperativeLevel( hwnd,DDSCL_NORMAL )>=0 ){ + if (dd->SetCooperativeLevel(hwnd, DDSCL_NORMAL) >= 0) { //create primary surface IDirectDrawSurface7 *ps; - DDSURFACEDESC2 desc={sizeof(desc)}; - desc.dwFlags=DDSD_CAPS; - desc.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE; - if( dd->CreateSurface( &desc,&ps,0 )>=0 ){ + DDSURFACEDESC2 desc = { sizeof(desc) }; + desc.dwFlags = DDSD_CAPS; + desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + if (dd->CreateSurface(&desc, &ps, 0) >= 0) { //create clipper IDirectDrawClipper *cp; - if( dd->CreateClipper( 0,&cp,0 )>=0 ){ + if (dd->CreateClipper(0, &cp, 0) >= 0) { //attach clipper - if( ps->SetClipper( cp )>=0 ){ + if (ps->SetClipper(cp) >= 0) { //set clipper HWND - if( cp->SetHWnd( 0,hwnd )>=0 ){ + if (cp->SetHWnd(0, hwnd) >= 0) { //create front buffer IDirectDrawSurface7 *fs; - DDSURFACEDESC2 desc={sizeof(desc)}; - desc.dwFlags=DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS; - desc.dwWidth=w;desc.dwHeight=h; - desc.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN; + DDSURFACEDESC2 desc = { sizeof(desc) }; + desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; + desc.dwWidth = w; desc.dwHeight = h; + desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - if( d3d ) desc.ddsCaps.dwCaps|=DDSCAPS_3DDEVICE; + if (d3d) desc.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE; - if( dd->CreateSurface( &desc,&fs,0 )>=0 ){ - if( timerID=timeSetEvent( 100,10,timerCallback,0,TIME_PERIODIC ) ){ + if (dd->CreateSurface(&desc, &fs, 0) >= 0) { + if (timerID = timeSetEvent(100, 10, timerCallback, 0, TIME_PERIODIC)) { //Success! - clipper=cp; - primSurf=ps; - mod_cnt=0; + clipper = cp; + primSurf = ps; + mod_cnt = 0; fs->AddRef(); - return d_new gxGraphics( this,dd,fs,fs,d3d ); + return d_new gxGraphics(this, dd, fs, fs, d3d); } fs->Release(); } @@ -826,31 +822,31 @@ gxGraphics *gxRuntime::openWindowedGraphics( int w,int h,int d,bool d3d ){ return 0; } -gxGraphics *gxRuntime::openExclusiveGraphics( int w,int h,int d,bool d3d ){ +gxGraphics *gxRuntime::openExclusiveGraphics(int w, int h, int d, bool d3d) { IDirectDraw7 *dd; - if( DirectDrawCreateEx( curr_driver->guid,(void**)&dd,IID_IDirectDraw7,0 )<0 ) return 0; + if (DirectDrawCreateEx(curr_driver->guid, (void**)&dd, IID_IDirectDraw7, 0) < 0) return 0; //Set coop level - if( dd->SetCooperativeLevel( hwnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT )>=0 ){ + if (dd->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT) >= 0) { //Set display mode - if( setDisplayMode( w,h,d,d3d,dd ) ){ + if (setDisplayMode(w, h, d, d3d, dd)) { //create primary surface IDirectDrawSurface7 *ps; - DDSURFACEDESC2 desc={sizeof(desc)}; - desc.dwFlags=DDSD_CAPS|DDSD_BACKBUFFERCOUNT; - desc.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE|DDSCAPS_COMPLEX|DDSCAPS_FLIP; + DDSURFACEDESC2 desc = { sizeof(desc) }; + desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; + desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; - desc.dwBackBufferCount=1; - if( d3d ) desc.ddsCaps.dwCaps|=DDSCAPS_3DDEVICE; + desc.dwBackBufferCount = 1; + if (d3d) desc.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE; - if( dd->CreateSurface( &desc,&ps,0 )>=0 ){ + if (dd->CreateSurface(&desc, &ps, 0) >= 0) { //find back surface IDirectDrawSurface7 *bs; - DDSCAPS2 caps={sizeof caps}; - caps.dwCaps=DDSCAPS_BACKBUFFER; - if( ps->GetAttachedSurface( &caps,&bs )>=0 ){ - return d_new gxGraphics( this,dd,ps,bs,d3d ); + DDSCAPS2 caps = { sizeof caps }; + caps.dwCaps = DDSCAPS_BACKBUFFER; + if (ps->GetAttachedSurface(&caps, &bs) >= 0) { + return d_new gxGraphics(this, dd, ps, bs, d3d); } ps->Release(); } @@ -861,373 +857,337 @@ gxGraphics *gxRuntime::openExclusiveGraphics( int w,int h,int d,bool d3d ){ return 0; } -gxGraphics *gxRuntime::openGraphics( int w,int h,int d,int driver,int flags ){ - if( graphics ) return 0; +gxGraphics *gxRuntime::openGraphics(int w, int h, int d, int driver, int flags) { + if (graphics) return 0; - busy=true; + busy = true; - bool d3d=flags & gxGraphics::GRAPHICS_3D ? true : false; - bool windowed=flags & gxGraphics::GRAPHICS_WINDOWED ? true : false; + bool d3d = flags & gxGraphics::GRAPHICS_3D ? true : false; + bool windowed = flags & gxGraphics::GRAPHICS_WINDOWED ? true : false; - if( windowed ) driver=0; + if (windowed) driver = 0; - curr_driver=drivers[driver]; + curr_driver = drivers[driver]; - if( windowed ){ - if( graphics=openWindowedGraphics( w,h,d,d3d ) ){ - gfx_mode=(flags & gxGraphics::GRAPHICS_SCALED) ? 1 : 2; - auto_suspend=(flags & gxGraphics::GRAPHICS_AUTOSUSPEND) ? true : false; - int ws,ww,hh; - if( gfx_mode==1 ){ - ws=scaled_ws; + if (windowed) { + if (graphics = openWindowedGraphics(w, h, d, d3d)) { + gfx_mode = (flags & gxGraphics::GRAPHICS_SCALED) ? 1 : 2; + auto_suspend = (flags & gxGraphics::GRAPHICS_AUTOSUSPEND) ? true : false; + int ws, ww, hh; + if (gfx_mode == 1) { + ws = scaled_ws; RECT c_r; - GetClientRect( hwnd,&c_r ); - ww=c_r.right-c_r.left; - hh=c_r.bottom-c_r.top; - }else{ - ws=static_ws; - ww=w; - hh=h; + GetClientRect(hwnd, &c_r); + ww = c_r.right - c_r.left; + hh = c_r.bottom - c_r.top; + } else { + ws = static_ws; + ww = w; + hh = h; } - SetWindowLong( hwnd,GWL_STYLE,ws ); - SetWindowPos( hwnd,0,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED ); + SetWindowLong(hwnd, GWL_STYLE, ws); + SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); - RECT w_r,c_r; - GetWindowRect( hwnd,&w_r ); - GetClientRect( hwnd,&c_r ); - int tw=(w_r.right-w_r.left)-(c_r.right-c_r.left); - int th=(w_r.bottom-w_r.top)-(c_r.bottom-c_r.top ); - int cx=( GetSystemMetrics( SM_CXSCREEN )-ww )/2; - int cy=( GetSystemMetrics( SM_CYSCREEN )-hh )/2; - POINT zz={0,0}; - ClientToScreen( hwnd,&zz ); - int bw=zz.x-w_r.left,bh=zz.y-w_r.top; - int wx=cx-bw,wy=cy-bh;if( wy<0 ) wy=0; //not above top! - MoveWindow( hwnd,wx,wy,ww+tw,hh+th,true ); + RECT w_r, c_r; + GetWindowRect(hwnd, &w_r); + GetClientRect(hwnd, &c_r); + int tw = (w_r.right - w_r.left) - (c_r.right - c_r.left); + int th = (w_r.bottom - w_r.top) - (c_r.bottom - c_r.top); + int cx = (GetSystemMetrics(SM_CXSCREEN) - ww) / 2; + int cy = (GetSystemMetrics(SM_CYSCREEN) - hh) / 2; + POINT zz = { 0,0 }; + ClientToScreen(hwnd, &zz); + int bw = zz.x - w_r.left, bh = zz.y - w_r.top; + int wx = cx - bw, wy = cy - bh; if (wy < 0) wy = 0; //not above top! + MoveWindow(hwnd, wx, wy, ww + tw, hh + th, true); } - }else{ + } else { backupWindowState(); - SetWindowLong( hwnd,GWL_STYLE,WS_VISIBLE|WS_POPUP ); - SetWindowPos( hwnd,0,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED ); + SetWindowLong(hwnd, GWL_STYLE, WS_VISIBLE | WS_POPUP); + SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); - ShowCursor( 0 ); - if( graphics=openExclusiveGraphics( w,h,d,d3d ) ){ - gfx_mode=3; - auto_suspend=true; - SetCursorPos(0,0); + ShowCursor(0); + if (graphics = openExclusiveGraphics(w, h, d, d3d)) { + gfx_mode = 3; + auto_suspend = true; + SetCursorPos(0, 0); acquireInput(); - }else{ - ShowCursor( 1 ); + } else { + ShowCursor(1); restoreWindowState(); } } - if( !graphics ) curr_driver=0; + if (!graphics) curr_driver = 0; - gfx_lost=false; + gfx_lost = false; - busy=false; + busy = false; return graphics; } -void gxRuntime::closeGraphics( gxGraphics *g ){ - if( !graphics || graphics!=g ) return; +void gxRuntime::closeGraphics(gxGraphics *g) { + if (!graphics || graphics != g) return; - auto_suspend=false; + auto_suspend = false; - busy=true; + busy = true; unacquireInput(); - if( timerID ){ timeKillEvent( timerID );timerID=0; } - if( clipper ){ clipper->Release();clipper=0; } - if( primSurf ){ primSurf->Release();primSurf=0; } - delete graphics;graphics=0; + if (timerID) { timeKillEvent(timerID); timerID = 0; } + if (clipper) { clipper->Release(); clipper = 0; } + if (primSurf) { primSurf->Release(); primSurf = 0; } + delete graphics; graphics = 0; - if( gfx_mode==3 ){ - ShowCursor( 1 ); + if (gfx_mode == 3) { + ShowCursor(1); restoreWindowState(); } - gfx_mode=0; + gfx_mode = 0; - gfx_lost=false; + gfx_lost = false; - busy=false; + busy = false; } -bool gxRuntime::graphicsLost(){ +bool gxRuntime::graphicsLost() { return gfx_lost; } -gxFileSystem *gxRuntime::openFileSystem( int flags ){ - if( fileSystem ) return 0; +gxFileSystem *gxRuntime::openFileSystem(int flags) { + if (fileSystem) return 0; - fileSystem=d_new gxFileSystem(); + fileSystem = d_new gxFileSystem(); return fileSystem; } -void gxRuntime::closeFileSystem( gxFileSystem *f ){ - if( !fileSystem || fileSystem!=f ) return; +void gxRuntime::closeFileSystem(gxFileSystem *f) { + if (!fileSystem || fileSystem != f) return; delete fileSystem; - fileSystem=0; + fileSystem = 0; } //////////////////// // GFX ENUM STUFF // //////////////////// -static HRESULT WINAPI enumMode( DDSURFACEDESC2 *desc,void *context ){ - int dp=desc->ddpfPixelFormat.dwRGBBitCount; - if( dp==16 || dp==24 || dp==32 ){ - gxRuntime::GfxMode *m=d_new gxRuntime::GfxMode; - m->desc=*desc; - gxRuntime::GfxDriver *d=(gxRuntime::GfxDriver*)context; - d->modes.push_back( m ); +static HRESULT WINAPI enumMode(DDSURFACEDESC2 *desc, void *context) { + int dp = desc->ddpfPixelFormat.dwRGBBitCount; + if (dp == 16 || dp == 24 || dp == 32) { + gxRuntime::GfxMode *m = d_new gxRuntime::GfxMode; + m->desc = *desc; + gxRuntime::GfxDriver *d = (gxRuntime::GfxDriver*)context; + d->modes.push_back(m); } return DDENUMRET_OK; } -#ifdef PRO static int maxDevType; -static HRESULT CALLBACK enumDevice( char *desc,char *name,D3DDEVICEDESC7 *devDesc,void *context ){ - int t=0; - GUID guid=devDesc->deviceGUID; - if( guid==IID_IDirect3DRGBDevice ) t=1; - else if( guid==IID_IDirect3DHALDevice ) t=2; - else if( guid==IID_IDirect3DTnLHalDevice ) t=3; - if( t>1 && t>maxDevType ){ - maxDevType=t; - gxRuntime::GfxDriver *d=(gxRuntime::GfxDriver*)context; - d->d3d_desc=*devDesc; +static HRESULT CALLBACK enumDevice(char *desc, char *name, D3DDEVICEDESC7 *devDesc, void *context) { + int t = 0; + GUID guid = devDesc->deviceGUID; + if (guid == IID_IDirect3DRGBDevice) t = 1; + else if (guid == IID_IDirect3DHALDevice) t = 2; + else if (guid == IID_IDirect3DTnLHalDevice) t = 3; + if (t > 1 && t > maxDevType) { + maxDevType = t; + gxRuntime::GfxDriver *d = (gxRuntime::GfxDriver*)context; + d->d3d_desc = *devDesc; } return D3DENUMRET_OK; } -#endif -static BOOL WINAPI enumDriver( GUID FAR *guid,LPSTR desc,LPSTR name,LPVOID context,HMONITOR hm ){ +static BOOL WINAPI enumDriver(GUID FAR *guid, LPSTR desc, LPSTR name, LPVOID context, HMONITOR hm) { IDirectDraw7 *dd; - if( DirectDrawCreateEx( guid,(void**)&dd,IID_IDirectDraw7,0 )<0 ) return 0; + if (DirectDrawCreateEx(guid, (void**)&dd, IID_IDirectDraw7, 0) < 0) return 0; - if( !guid && !desktop_desc.ddpfPixelFormat.dwRGBBitCount ){ - desktop_desc.dwSize=sizeof(desktop_desc); - dd->GetDisplayMode( &desktop_desc ); + if (!guid && !desktop_desc.ddpfPixelFormat.dwRGBBitCount) { + desktop_desc.dwSize = sizeof(desktop_desc); + dd->GetDisplayMode(&desktop_desc); } - gxRuntime::GfxDriver *d=d_new gxRuntime::GfxDriver; + gxRuntime::GfxDriver *d = d_new gxRuntime::GfxDriver; - d->guid=guid ? d_new GUID( *guid ) : 0; - d->name=desc;//string( name )+" "+string( desc ); + d->guid = guid ? d_new GUID(*guid) : 0; + d->name = desc;//string( name )+" "+string( desc ); -#ifdef PRO - memset( &d->d3d_desc,0,sizeof(d->d3d_desc) ); + memset(&d->d3d_desc, 0, sizeof(d->d3d_desc)); IDirect3D7 *dir3d; - if( dd->QueryInterface( IID_IDirect3D7,(void**)&dir3d )>=0 ){ - maxDevType=0; - dir3d->EnumDevices( enumDevice,d ); + if (dd->QueryInterface(IID_IDirect3D7, (void**)&dir3d) >= 0) { + maxDevType = 0; + dir3d->EnumDevices(enumDevice, d); dir3d->Release(); } -#endif - vector *drivers=(vector*)context; - drivers->push_back( d ); - dd->EnumDisplayModes( 0,0,d,enumMode ); + vector *drivers = (vector*)context; + drivers->push_back(d); + dd->EnumDisplayModes(0, 0, d, enumMode); dd->Release(); return 1; } -void gxRuntime::enumGfx(){ +void gxRuntime::enumGfx() { denumGfx(); - if( enum_all ){ - DirectDrawEnumerateEx( enumDriver,&drivers,DDENUM_ATTACHEDSECONDARYDEVICES|DDENUM_NONDISPLAYDEVICES ); - }else{ - DirectDrawEnumerateEx( enumDriver,&drivers,0 ); + if (enum_all) { + DirectDrawEnumerateEx(enumDriver, &drivers, DDENUM_ATTACHEDSECONDARYDEVICES | DDENUM_NONDISPLAYDEVICES); + } else { + DirectDrawEnumerateEx(enumDriver, &drivers, 0); } } -void gxRuntime::denumGfx(){ - for( int k=0;kmodes.size();++j ) delete d->modes[j]; +void gxRuntime::denumGfx() { + for (int k = 0; k < drivers.size(); ++k) { + gxRuntime::GfxDriver *d = drivers[k]; + for (unsigned int j = 0; j < d->modes.size(); ++j) delete d->modes[j]; delete d->guid; delete d; } drivers.clear(); } -int gxRuntime::numGraphicsDrivers(){ - if( !enum_all ){ - enum_all=true; +int gxRuntime::enumerateGraphicsDrivers() { + if (!enum_all) { + enum_all = true; enumGfx(); } return drivers.size(); } -void gxRuntime::graphicsDriverInfo( int driver,string *name,int *c ){ - GfxDriver *g=drivers[driver]; - int caps=0; -#ifdef PRO - if( g->d3d_desc.dwDeviceRenderBitDepth ) caps|=GFXMODECAPS_3D; -#endif - *name=g->name; - *c=caps; +void gxRuntime::graphicsDriverInfo(int driver, string *name, int *c) { + GfxDriver *g = drivers[driver]; + int caps = 0; + if (g->d3d_desc.dwDeviceRenderBitDepth) caps |= GFXMODECAPS_3D; + *name = g->name; + *c = caps; } -int gxRuntime::numGraphicsModes( int driver ){ +int gxRuntime::countGraphicsModes(int driver) { return drivers[driver]->modes.size(); } -void gxRuntime::graphicsModeInfo( int driver,int mode,int *w,int *h,int *d,int *c ){ - GfxDriver *g=drivers[driver]; - GfxMode *m=g->modes[mode]; - int caps=0; -#ifdef PRO - int bd=0; - switch( m->desc.ddpfPixelFormat.dwRGBBitCount ){ - case 16:bd=DDBD_16;break; - case 24:bd=DDBD_24;break; - case 32:bd=DDBD_32;break; +void gxRuntime::graphicsModeInfo(int driver, int mode, int *w, int *h, int *d, int *c) { + GfxDriver *g = drivers[driver]; + GfxMode *m = g->modes[mode]; + int caps = 0; + int bd = 0; + switch (m->desc.ddpfPixelFormat.dwRGBBitCount) { + case 16:bd = DDBD_16; break; + case 24:bd = DDBD_24; break; + case 32:bd = DDBD_32; break; } - if( g->d3d_desc.dwDeviceRenderBitDepth & bd ) caps|=GFXMODECAPS_3D; -#endif - *w=m->desc.dwWidth; - *h=m->desc.dwHeight; - *d=m->desc.ddpfPixelFormat.dwRGBBitCount; - *c=caps; + if (g->d3d_desc.dwDeviceRenderBitDepth & bd) caps |= GFXMODECAPS_3D; + *w = m->desc.dwWidth; + *h = m->desc.dwHeight; + *d = m->desc.ddpfPixelFormat.dwRGBBitCount; + *c = caps; } -void gxRuntime::windowedModeInfo( int *c ){ - int caps=0; -#ifdef PRO - int bd=0; - switch( desktop_desc.ddpfPixelFormat.dwRGBBitCount ){ - case 16:bd=DDBD_16;break; - case 24:bd=DDBD_24;break; - case 32:bd=DDBD_32;break; +void gxRuntime::windowedModeInfo(int *c) { + int caps = 0; + int bd = 0; + switch (desktop_desc.ddpfPixelFormat.dwRGBBitCount) { + case 16:bd = DDBD_16; break; + case 24:bd = DDBD_24; break; + case 32:bd = DDBD_32; break; } - if( drivers[0]->d3d_desc.dwDeviceRenderBitDepth & bd ) caps|=GFXMODECAPS_3D; -#endif - *c=caps; + if (drivers[0]->d3d_desc.dwDeviceRenderBitDepth & bd) caps |= GFXMODECAPS_3D; + *c = caps; } -gxTimer *gxRuntime::createTimer( int hertz ){ - gxTimer *t=d_new gxTimer( this,hertz ); - timers.insert( t ); +gxTimer *gxRuntime::createTimer(int hertz) { + gxTimer *t = d_new gxTimer(this, hertz); + timers.insert(t); return t; } -void gxRuntime::freeTimer( gxTimer *t ){ - if( !timers.count( t ) ) return; - timers.erase( t ); +void gxRuntime::freeTimer(gxTimer *t) { + if (!timers.count(t)) return; + timers.erase(t); delete t; } -static string toDir( string t ){ - if( t.size() && t[t.size()-1]!='\\' ) t+='\\'; +static string toDir(string t) { + if (t.size() && t[t.size() - 1] != '\\') t += '\\'; return t; } -string gxRuntime::systemProperty( const std::string &p ){ - char buff[MAX_PATH+1]; - string t=tolower(p); - if( t=="cpu" ){ +string gxRuntime::systemProperty(const std::string &p) { + char buff[MAX_PATH + 1]; + string t = tolower(p); + if (t == "cpu") { return "Intel"; - }else if( t=="os" ){ - switch( osinfo.dwMajorVersion ){ - case 3: - switch( osinfo.dwMinorVersion ){ - case 51:return "Windows NT 3.1"; - } - break; - case 4: - switch( osinfo.dwMinorVersion ){ - case 0:return "Windows 95"; - case 10:return "Windows 98"; - case 90:return "Windows ME"; - } - break; - case 5: - switch( osinfo.dwMinorVersion ){ - case 0:return "Windows 2000"; - case 1:return "Windows XP"; - case 2:return "Windows Server 2003"; - } - break; - case 6: - switch( osinfo.dwMinorVersion ){ - case 0:return "Windows Vista"; - case 1:return "Windows 7"; - } - break; + } else if (t == "os") { + return "Windows"; + } else if (t == "appdir") { + if (GetModuleFileName(0, buff, MAX_PATH)) { + string t = buff; + int n = t.find_last_of('\\'); + if (n != string::npos) t = t.substr(0, n); + return toDir(t); } - }else if( t=="appdir" ){ - if( GetModuleFileName( 0,buff,MAX_PATH ) ){ - string t=buff; - int n=t.find_last_of( '\\' ); - if( n!=string::npos ) t=t.substr( 0,n ); - return toDir( t ); - } - }else if( t=="apphwnd" ){ - return itoa( (int)hwnd ); - }else if( t=="apphinstance" ){ - return itoa( (int)hinst ); - }else if( t=="windowsdir" ){ - if( GetWindowsDirectory( buff,MAX_PATH ) ) return toDir( buff ); - }else if( t=="systemdir" ){ - if( GetSystemDirectory( buff,MAX_PATH ) ) return toDir( buff ); - }else if( t=="tempdir" ){ - if( GetTempPath( MAX_PATH,buff ) ) return toDir( buff ); - }else if( t=="direct3d7" ){ - if( graphics ) return itoa( (int)graphics->dir3d ); - }else if( t=="direct3ddevice7" ){ - if( graphics ) return itoa( (int)graphics->dir3dDev ); - }else if( t=="directdraw7" ){ - if( graphics ) return itoa( (int)graphics->dirDraw ); - }else if( t=="directinput7" ){ - if( input ) return itoa( (int)input->dirInput ); + } else if (t == "apphwnd") { + return itoa((int)hwnd); + } else if (t == "apphinstance") { + return itoa((int)hinst); + } else if (t == "windowsdir") { + if (GetWindowsDirectory(buff, MAX_PATH)) return toDir(buff); + } else if (t == "systemdir") { + if (GetSystemDirectory(buff, MAX_PATH)) return toDir(buff); + } else if (t == "tempdir") { + if (GetTempPath(MAX_PATH, buff)) return toDir(buff); + } else if (t == "direct3d7") { + if (graphics) return itoa((int)graphics->dir3d); + } else if (t == "direct3ddevice7") { + if (graphics) return itoa((int)graphics->dir3dDev); + } else if (t == "directdraw7") { + if (graphics) return itoa((int)graphics->dirDraw); + } else if (t == "directinput7") { + if (input) return itoa((int)input->dirInput); } return ""; } -void gxRuntime::enableDirectInput( bool enable ){ - if( use_di=enable ){ +void gxRuntime::enableDirectInput(bool enable) { + if (use_di = enable) { acquireInput(); - }else{ + } else { unacquireInput(); } } -int gxRuntime::callDll( const std::string &dll,const std::string &func,const void *in,int in_sz,void *out,int out_sz ){ +int gxRuntime::callDll(const std::string &dll, const std::string &func, const void *in, int in_sz, void *out, int out_sz) { - map::const_iterator lib_it=libs.find( dll ); + map::const_iterator lib_it = libs.find(dll); - if( lib_it==libs.end() ){ - HINSTANCE h=LoadLibrary( dll.c_str() ); - if( !h ) return 0; - gxDll *t=d_new gxDll; - t->hinst=h; - lib_it=libs.insert( make_pair( dll,t ) ).first; + if (lib_it == libs.end()) { + HINSTANCE h = LoadLibrary(dll.c_str()); + if (!h) return 0; + gxDll *t = d_new gxDll; + t->hinst = h; + lib_it = libs.insert(make_pair(dll, t)).first; } - gxDll *t=lib_it->second; - map::const_iterator fun_it=t->funcs.find( func ); + gxDll *t = lib_it->second; + map::const_iterator fun_it = t->funcs.find(func); - if( fun_it==t->funcs.end() ){ - LibFunc f=(LibFunc)GetProcAddress( t->hinst,func.c_str() ); - if( !f ) return 0; - fun_it=t->funcs.insert( make_pair( func,f ) ).first; + if (fun_it == t->funcs.end()) { + LibFunc f = (LibFunc)GetProcAddress(t->hinst, func.c_str()); + if (!f) return 0; + fun_it = t->funcs.insert(make_pair(func, f)).first; } static void *save_esp; - _asm{ - mov [save_esp],esp + _asm { + mov[save_esp], esp }; - int n=fun_it->second( in,in_sz,out,out_sz ); + int n = fun_it->second(in, in_sz, out, out_sz); - _asm{ - mov esp,[save_esp] + _asm { + mov esp, [save_esp] }; return n; diff --git a/gxruntime/gxruntime.h b/gxruntime/gxruntime.h index 83a42de..0a1e0b1 100644 --- a/gxruntime/gxruntime.h +++ b/gxruntime/gxruntime.h @@ -110,10 +110,10 @@ public: void debugError( const char *t ); void debugLog( const char *t ); - int numGraphicsDrivers(); + int enumerateGraphicsDrivers(); void graphicsDriverInfo( int driver,std::string *name,int *caps ); - int numGraphicsModes( int driver ); + int countGraphicsModes( int driver ); void graphicsModeInfo( int driver,int mode,int *w,int *h,int *d,int *caps ); void windowedModeInfo( int *caps ); diff --git a/gxruntime/gxruntime.vcxproj b/gxruntime/gxruntime.vcxproj index 7ba3e7f..8a0648f 100644 --- a/gxruntime/gxruntime.vcxproj +++ b/gxruntime/gxruntime.vcxproj @@ -1,14 +1,6 @@  - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - Debug Win32 @@ -17,52 +9,32 @@ Release Win32 - - Template - Win32 - {FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18} - 10.0.10586.0 + GraphicsRuntime + 8.1 - - Application - v140 - StaticLibrary v140 false MultiByte + false StaticLibrary v140 false MultiByte - - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte + false - - - @@ -71,113 +43,44 @@ - - - - - - - - - - .\gxruntime___Win32_Blitz2DRelease\ - .\gxruntime___Win32_Blitz2DRelease\ - false - - - .\gxruntime___Win32_Blitz3DRelease\ - .\gxruntime___Win32_Blitz3DRelease\ - false - - .\Release\ - .\Release\ + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 ..\#Build\$(ProjectName)\$(ConfigurationName)\ ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ true + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 - - - MultiThreaded - AnySuitable - true - true - MaxSpeed - true - Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\gxruntime___Win32_Blitz2DRelease\ - .\gxruntime___Win32_Blitz2DRelease\gxruntime.pch - Use - std.h - .\gxruntime___Win32_Blitz2DRelease\ - .\gxruntime___Win32_Blitz2DRelease\ - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\gxruntime___Win32_Blitz2DRelease\gxruntime.bsc - - - true - .\gxruntime___Win32_Blitz2DRelease\gxruntime.lib - - - - - MultiThreaded - AnySuitable - true - true - MaxSpeed - true - Level3 - _LIB;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\gxruntime___Win32_Blitz3DRelease\ - .\gxruntime___Win32_Blitz3DRelease\gxruntime.pch - - .\gxruntime___Win32_Blitz3DRelease\ - .\gxruntime___Win32_Blitz3DRelease\ - StdCall - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\gxruntime___Win32_Blitz3DRelease\gxruntime.bsc - - - true - .\gxruntime___Win32_Blitz3DRelease\gxruntime.lib - - MultiThreaded - AnySuitable + OnlyExplicitInline true MaxSpeed - true - Level3 true - Size + Speed true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\Release\ - .\Release\gxruntime.pch - Use - std.h - .\Release\ - .\Release\ + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + false + false + true + Level3 + false + Guard + $(IntDir)vc$(PlatformToolsetVersion).pdb + false + false + false + StdCall 0x0409 @@ -189,26 +92,34 @@ true - .\Release\gxruntime.lib + dxguid.lib;ddraw.lib;dinput8.lib;dsound.lib;d3dxof.lib;dxgi.lib;d3dx9.lib + MachineX86 MultiThreadedDebug Default - false + true Disabled - true - Level3 true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\gxruntime.pch - Use - std.h - .\Debug\ - .\Debug\ + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) EnableFastChecks + true + true + false + false + true + Speed + true + true + Guard + Level3 + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + true + false + StdCall 0x0409 @@ -220,7 +131,8 @@ true - .\Debug\gxruntime.lib + dxguid.lib;ddraw.lib;dinput8.lib;dsound.lib;d3dxof.lib;dxgi.lib;d3dx9.lib + MachineX86 @@ -238,18 +150,12 @@ - AssemblyAndSourceCode - AssemblyAndSourceCode AssemblyAndSourceCode - Create - std.h - Create - std.h Create std.h Create @@ -259,6 +165,7 @@ + diff --git a/gxruntime/gxruntime.vcxproj.filters b/gxruntime/gxruntime.vcxproj.filters index fd7366c..51e1028 100644 --- a/gxruntime/gxruntime.vcxproj.filters +++ b/gxruntime/gxruntime.vcxproj.filters @@ -124,5 +124,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/gxruntime/gxscene.cpp b/gxruntime/gxscene.cpp index 6abb52c..29e7f72 100644 --- a/gxruntime/gxscene.cpp +++ b/gxruntime/gxscene.cpp @@ -560,6 +560,7 @@ void gxScene::render( gxMesh *m,int first_vert,int vert_cnt,int first_tri,int tr tris_drawn+=tri_cnt; if( n_texs<=tex_stages ) return; + setTSS( 0,D3DTSS_COLOROP,D3DTOP_SELECTARG1 ); setTSS( 0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1 ); if( tex_stages>1 ){ diff --git a/gxruntime/gxscene.h b/gxruntime/gxscene.h index c6b65af..116d14a 100644 --- a/gxruntime/gxscene.h +++ b/gxruntime/gxscene.h @@ -1,4 +1,6 @@ +#include "GraphicsRuntime.h" + #ifndef GXSCENE_H #define GXSCENE_H diff --git a/gxruntime/std.h b/gxruntime/std.h index 78be9f3..224dd1c 100644 --- a/gxruntime/std.h +++ b/gxruntime/std.h @@ -2,7 +2,7 @@ #ifndef STD_H #define STD_H -#include "../fmodapi375win/api/inc/fmod.h" +#include "../#ThirdParty/fmodapi375win/api/inc/fmod.h" #include "../config/config.h" #include "../stdutil/stdutil.h" @@ -10,7 +10,6 @@ #pragma warning( disable:4786 ) #define DIRECTSOUND_VERSION 0x700 -#define DIRECTINPUT_VERSION 0x700 #include #include @@ -22,9 +21,7 @@ #include #include -#include -#include -#include +#include "GraphicsRuntime.h" using namespace std; diff --git a/linker/linker.vcxproj b/linker/linker.vcxproj deleted file mode 100644 index 5f2bb87..0000000 --- a/linker/linker.vcxproj +++ /dev/null @@ -1,252 +0,0 @@ - - - - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - - - Debug - Win32 - - - Release - Win32 - - - Template - Win32 - - - - - - {0B629BA3-D138-407A-801D-DBE7C8DC4324} - 10.0.10586.0 - - - - Application - v140 - - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - ..\#Build\$(ProjectName)\$(ConfigurationName)\ - ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ - true - - - .\Release\ - .\Release\ - false - - - .\linker___Win32_Blitz2DRelease\ - .\linker___Win32_Blitz2DRelease\ - false - - - .\linker___Win32_Blitz3DRelease\ - .\linker___Win32_Blitz3DRelease\ - false - - - - MultiThreadedDebug - Default - false - Disabled - true - Level3 - true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\linker.pch - .\Debug\ - .\Debug\ - EnableFastChecks - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - true - .\Debug\linker.bsc - - - true - .\Debug\linker.lib - - - - - MultiThreaded - AnySuitable - true - true - MaxSpeed - true - Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\Release\ - .\Release\linker.pch - Use - std.h - .\Release\ - .\Release\ - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\Release\linker.bsc - - - true - .\Release\linker.lib - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\linker___Win32_Blitz2DRelease\ - .\linker___Win32_Blitz2DRelease\linker.pch - Use - std.h - .\linker___Win32_Blitz2DRelease\ - .\linker___Win32_Blitz2DRelease\ - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\linker___Win32_Blitz2DRelease\linker.bsc - - - true - .\linker___Win32_Blitz2DRelease\linker.lib - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - _LIB;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\linker___Win32_Blitz3DRelease\ - .\linker___Win32_Blitz3DRelease\linker.pch - - .\linker___Win32_Blitz3DRelease\ - .\linker___Win32_Blitz3DRelease\ - StdCall - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\linker___Win32_Blitz3DRelease\linker.bsc - - - true - .\linker___Win32_Blitz3DRelease\linker.lib - - - - - - - Create - std.h - Create - std.h - Create - std.h - - - - - - - - - - {3e355353-96d8-4aaf-bf95-8e6ca0d4b1ba} - false - - - {6bcfc5ca-ea71-4ae9-8b96-28b8701f939e} - false - - - - - - \ No newline at end of file diff --git a/linker_dll/linker_dll.vcxproj b/linker_dll/linker_dll.vcxproj deleted file mode 100644 index ee307c3..0000000 --- a/linker_dll/linker_dll.vcxproj +++ /dev/null @@ -1,283 +0,0 @@ - - - - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - - - Debug - Win32 - - - Release - Win32 - - - Template - Win32 - - - - - - {778BCC7F-40F9-4309-9A88-C0F60D9B364D} - 10.0.10586.0 - - - - Application - v140 - - - DynamicLibrary - v140 - false - MultiByte - - - DynamicLibrary - v140 - false - MultiByte - - - DynamicLibrary - v140 - false - MultiByte - - - DynamicLibrary - v140 - false - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - .\linker_dll___Win32_Blitz3DRelease\ - .\linker_dll___Win32_Blitz3DRelease\ - false - - - .\linker_dll___Win32_Blitz2DRelease\ - .\linker_dll___Win32_Blitz2DRelease\ - false - - - ..\#Build\$(ProjectName)\$(ConfigurationName)\ - ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ - false - - - .\Release\ - .\Release\ - false - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - _WINDOWS;_USRDLL;LINKER_DLL_EXPORTS;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\linker_dll___Win32_Blitz3DRelease\ - .\linker_dll___Win32_Blitz3DRelease\linker_dll.pch - .\linker_dll___Win32_Blitz3DRelease\ - .\linker_dll___Win32_Blitz3DRelease\ - StdCall - - - true - NDEBUG;%(PreprocessorDefinitions) - .\linker_dll___Win32_Blitz3DRelease\linker_dll.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\linker_dll___Win32_Blitz3DRelease\linker_dll.bsc - - - true - true - Console - ../_release/bin/linker.dll - .\linker_dll___Win32_Blitz3DRelease\linker.lib - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreaded - Default - true - true - MinSpace - true - Level3 - WIN32;NDEBUG;_WINDOWS;_USRDLL;LINKER_DLL_EXPORTS;%(PreprocessorDefinitions) - .\linker_dll___Win32_Blitz2DRelease\ - .\linker_dll___Win32_Blitz2DRelease\linker_dll.pch - .\linker_dll___Win32_Blitz2DRelease\ - .\linker_dll___Win32_Blitz2DRelease\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\linker_dll___Win32_Blitz2DRelease\linker_dll.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\linker_dll___Win32_Blitz2DRelease\linker_dll.bsc - - - true - true - Console - ..\..\release\blitz2drelease\bin\linker.dll - .\linker_dll___Win32_Blitz2DRelease\linker.lib - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreadedDebug - Default - false - Disabled - true - Level3 - true - WIN32;_DEBUG;_WINDOWS;_USRDLL;LINKER_DLL_EXPORTS;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\linker_dll.pch - .\Debug\ - .\Debug\ - EnableFastChecks - - - true - _DEBUG;%(PreprocessorDefinitions) - .\Debug\linker_dll.tlb - true - Win32 - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - true - .\Debug\linker_dll.bsc - - - true - true - true - Console - ..\blitzbasic\bin\linker.dll - .\Debug\linker.lib - /FIXED:NO - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - MultiThreaded - AnySuitable - true - true - MaxSpeed - true - Level3 - WIN32;NDEBUG;_WINDOWS;_USRDLL;LINKER_DLL_EXPORTS;%(PreprocessorDefinitions) - .\Release\ - .\Release\linker_dll.pch - .\Release\ - .\Release\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\Release\linker_dll.tlb - true - Win32 - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\Release\linker_dll.bsc - - - true - true - Console - ..\blitzbasic\bin\linker.dll - .\Release\linker.lib - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - {3e355353-96d8-4aaf-bf95-8e6ca0d4b1ba} - false - - - {0b629ba3-d138-407a-801d-dbe7c8dc4324} - false - - - {6bcfc5ca-ea71-4ae9-8b96-28b8701f939e} - false - - - - - - \ No newline at end of file diff --git a/stdutil/stdutil.cpp b/stdutil/stdutil.cpp index ca3f4d4..f23d152 100644 --- a/stdutil/stdutil.cpp +++ b/stdutil/stdutil.cpp @@ -10,183 +10,184 @@ using namespace std; #ifdef MEMDEBUG -struct Mem{ - Mem *next,*prev; +struct Mem { + Mem *next, *prev; const char *file; - int line,size,tag; + int line, size, tag; }; static bool track; -static Mem head,tail; -static Mem x_head,x_tail; +static Mem head, tail; +static Mem x_head, x_tail; -static void remove( Mem *m ){ - m->next->prev=m->prev; - m->prev->next=m->next; +static void remove(Mem *m) { + m->next->prev = m->prev; + m->prev->next = m->next; } -static void insert( Mem *m,Mem *next ){ - m->next=next; - m->prev=next->prev; - next->prev->next=m; - next->prev=m; +static void insert(Mem *m, Mem *next) { + m->next = next; + m->prev = next->prev; + next->prev->next = m; + next->prev = m; } -static void init(){ - if( head.next ) return; - head.next=head.prev=&tail;head.tag='HEAD'; - tail.next=tail.prev=&head;tail.tag='TAIL'; - x_head.next=x_head.prev=&x_tail;x_head.tag='HEAD'; - x_tail.next=x_tail.prev=&x_head;x_tail.tag='TAIL'; +static void init() { + if (head.next) return; + head.next = head.prev = &tail; head.tag = 'HEAD'; + tail.next = tail.prev = &head; tail.tag = 'TAIL'; + x_head.next = x_head.prev = &x_tail; x_head.tag = 'HEAD'; + x_tail.next = x_tail.prev = &x_head; x_tail.tag = 'TAIL'; } -static void check( Mem *m ){ - if( m->tag!='DNEW' ){ - MessageBox( GetDesktopWindow(),"mem_check: pre_tag!='DNEW'","Memory error",MB_OK|MB_ICONWARNING ); - if( m->tag=='NDWE' ){ - string t="Probable double delete"; - t+="- d_new file: "+string(m->file)+" line:"+itoa(m->line); - MessageBox( GetDesktopWindow(),t.c_str(),"Memory error",MB_OK|MB_ICONWARNING ); +static void check(Mem *m) { + if (m->tag != 'DNEW') { + MessageBox(GetDesktopWindow(), "mem_check: pre_tag!='DNEW'", "Memory error", MB_OK | MB_ICONWARNING); + if (m->tag == 'NDWE') { + string t = "Probable double delete"; + t += "- d_new file: " + string(m->file) + " line:" + itoa(m->line); + MessageBox(GetDesktopWindow(), t.c_str(), "Memory error", MB_OK | MB_ICONWARNING); } - ExitProcess( 0 ); + ExitProcess(0); } - int *t=(int*)( (char*)(m+1)+m->size ); - if( *t!='dnew' ){ - MessageBox( GetDesktopWindow(),"mem_check: post_tag!='dnew'","Memory error",MB_OK|MB_ICONWARNING ); - string t="Probable memory overwrite - d_new file: "+string(m->file)+" line:"+itoa(m->line); - MessageBox( GetDesktopWindow(),t.c_str(),"Memory error",MB_OK|MB_ICONWARNING ); - ExitProcess( 0 ); + int *t = (int*)((char*)(m + 1) + m->size); + if (*t != 'dnew') { + MessageBox(GetDesktopWindow(), "mem_check: post_tag!='dnew'", "Memory error", MB_OK | MB_ICONWARNING); + string t = "Probable memory overwrite - d_new file: " + string(m->file) + " line:" + itoa(m->line); + MessageBox(GetDesktopWindow(), t.c_str(), "Memory error", MB_OK | MB_ICONWARNING); + ExitProcess(0); } } -static void *op_new( size_t size,const char *file="",int line=0 ){ +static void *op_new(size_t size, const char *file = "", int line = 0) { init(); - Mem *m=(Mem*)malloc( sizeof(Mem)+size+sizeof(int) ); - memset( m+1,0xcc,size ); - m->file=file;m->line=line;m->size=size;m->tag='DNEW'; - int *t=(int*)( (char*)(m+1)+size );*t='dnew'; - if( track ) insert( m,head.next ); - else insert( m,x_head.next ); - return m+1; + Mem *m = (Mem*)malloc(sizeof(Mem) + size + sizeof(int)); + memset(m + 1, 0xcc, size); + m->file = file; m->line = line; m->size = size; m->tag = 'DNEW'; + int *t = (int*)((char*)(m + 1) + size); *t = 'dnew'; + if (track) insert(m, head.next); + else insert(m, x_head.next); + return m + 1; } -static void op_delete( void *q ){ +static void op_delete(void *q) { init(); - if( !q ) return; - Mem *m=(Mem*)q-1; - check( m ); - remove( m ); - m->tag='NDWE'; - *(int*)( (char*)(m+1)+m->size )='ndwe'; - free( m ); + if (!q) return; + Mem *m = (Mem*)q - 1; + check(m); + remove(m); + m->tag = 'NDWE'; + *(int*)((char*)(m + 1) + m->size) = 'ndwe'; + free(m); } -void trackmem( bool enable ){ +void trackmem(bool enable) { init(); - if( track==enable ) return; - track=enable; + if (track == enable) return; + track = enable; Mem *m; - while( (m=head.next)!=&tail ){ - remove( m );insert( m,x_head.next ); + while ((m = head.next) != &tail) { + remove(m); insert(m, x_head.next); } } -void checkmem( ostream &out ){ +void checkmem(ostream &out) { init(); - Mem *m,*next; - int sum=0,usum=0,xsum=0; - for( m=head.next;m!=&tail;m=next ){ - check( m ); - next=m->next; - if( m->line ){ - out<file<<" line:"<line<<" "<size<<" bytes"<size; - }else{ - usum+=m->size; + Mem *m, *next; + int sum = 0, usum = 0, xsum = 0; + for (m = head.next; m != &tail; m = next) { + check(m); + next = m->next; + if (m->line) { + out << m->file << " line:" << m->line << " " << m->size << " bytes" << endl; + sum += m->size; + } else { + usum += m->size; } } - for( m=x_head.next;m!=&x_tail;m=m->next ){ - check( m ); - xsum+=m->size; + for (m = x_head.next; m != &x_tail; m = m->next) { + check(m); + xsum += m->size; } - out<<"Tracked blitz mem in use:"<> 20 ) & eMax; - - return e != eMax; -} - -static int _isnan( double n ){ // definition: exponent 2047, nonzero fraction. - - int e; // 11 bit exponent - const int eMax = 2047; // 0x7ff, all bits = 1 - - int *pn = (int *) &n; - - e = *++pn; // Intel order! - e = ( e >> 20 ) & eMax; - - if ( e != 2047 ) return 0; // almost always return here - - int fHi, fLo; // 52 bit fraction - - fHi = ( *pn ) & 0xfffff; // first 20 bits - fLo = *--pn; // last 32 bits - - return ( fHi | fLo ) != 0; // returns 0,1 not just 0,nonzero -} +//static int _finite(double n) { // definition: exponent anything but 2047. +// +// int e; // 11 bit exponent +// const int eMax = 2047; // 0x7ff, all bits = 1 +// +// int *pn = (int *)&n; +// +// e = *++pn; // Intel order! +// e = (e >> 20) & eMax; +// +// return e != eMax; +//} +// +//static int _isnan(double n) { // definition: exponent 2047, nonzero fraction. +// +// int e; // 11 bit exponent +// const int eMax = 2047; // 0x7ff, all bits = 1 +// +// int *pn = (int *)&n; +// +// e = *++pn; // Intel order! +// e = (e >> 20) & eMax; +// +// if (e != 2047) return 0; // almost always return here +// +// int fHi, fLo; // 52 bit fraction +// +// fHi = (*pn) & 0xfffff; // first 20 bits +// fLo = *--pn; // last 32 bits +// +// return (fHi | fLo) != 0; // returns 0,1 not just 0,nonzero +//} ///////////// //By FLOYD!// ///////////// -string ftoa( float n ){ +string ftoa(float n) { - static const int digits=6; + static const int digits = 6; int eNeg = -4, ePos = 8; // limits for e notation. @@ -194,54 +195,52 @@ string ftoa( float n ){ string t; int dec, sign; - if ( _finite( n ) ){ + if (_finite(n)) { -// if ( digits < 1 ) digits = 1; // less than one digit is nonsense -// if ( digits > 8 ) digits = 8; // practical maximum for float - - t = _ecvt( n, digits, &dec, &sign ); + // if ( digits < 1 ) digits = 1; // less than one digit is nonsense + // if ( digits > 8 ) digits = 8; // practical maximum for float - if ( dec <= eNeg + 1 || dec > ePos ){ + t = _ecvt(n, digits, &dec, &sign); - _gcvt( n, digits, buffer ); + if (dec <= eNeg + 1 || dec > ePos) { + + _gcvt(n, digits, buffer); t = buffer; return t; } - + // Here is the tricky case. We want a nicely formatted // number with no e-notation or multiple trailing zeroes. - - if ( dec <= 0 ){ - t = "0." + string( -dec, '0' ) + t; + if (dec <= 0) { + + t = "0." + string(-dec, '0') + t; dec = 1; // new location for decimal point - } - else if( dec < digits ){ + } else if (dec < digits) { - t = t.substr( 0, dec ) + "." + t.substr( dec ); + t = t.substr(0, dec) + "." + t.substr(dec); - } - else{ + } else { - t = t + string( dec - digits, '0' ) + ".0"; + t = t + string(dec - digits, '0') + ".0"; dec += dec - digits; } - + // Finally, trim off excess zeroes. - int dp1 = dec + 1, p = t.length(); - while( --p > dp1 && t[p] == '0' ); - t = string( t, 0, ++p ); + int dp1 = dec + 1, p = t.length(); + while (--p > dp1 && t[p] == '0'); + t = string(t, 0, ++p); return sign ? "-" + t : t; } // end of finite case - if ( _isnan( n ) ) return "NaN"; - if ( n > 0.0 ) return "Infinity"; - if ( n < 0.0 ) return "-Infinity"; + if (_isnan(n)) return "NaN"; + if (n > 0.0) return "Infinity"; + if (n < 0.0) return "-Infinity"; abort(); } @@ -283,80 +282,80 @@ string ftoa( float n ){ } */ -string tolower( const string &s ){ - string t=s; - for( int k=0;k - - Blitz2DRelease - Win32 - - - Blitz3DRelease - Win32 - Debug Win32 @@ -17,34 +9,14 @@ Release Win32 - - Template - Win32 - {6BCFC5CA-EA71-4AE9-8B96-28B8701F939E} - 10.0.10586.0 + 8.1 - - Application - v140 - - - StaticLibrary - v140 - false - MultiByte - - - StaticLibrary - v140 - false - MultiByte - StaticLibrary v140 @@ -60,17 +32,6 @@ - - - - - - - - - - - @@ -81,40 +42,43 @@ - .\Release\ - .\Release\ + ..\#Build\$(ProjectName)\$(ConfigurationName)\ + ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 ..\#Build\$(ProjectName)\$(ConfigurationName)\ ..\#Intermediate\$(ProjectName)\$(ConfigurationName)\ true - - - .\stdutil___Win32_Blitz2DRelease\ - .\stdutil___Win32_Blitz2DRelease\ - false - - - .\stdutil___Win32_Blitz3DRelease\ - .\stdutil___Win32_Blitz3DRelease\ - false + $(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 MultiThreaded - AnySuitable + OnlyExplicitInline true true MaxSpeed true Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\Release\ - .\Release\stdutil.pch - - .\Release\ - .\Release\ + _CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions) + true + true + true + false + false + false + Guard + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + false + false + false + StdCall 0x0409 @@ -126,24 +90,34 @@ true - .\Release\stdutil.lib + MachineX86 MultiThreadedDebug Default - false Disabled true - Level3 true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - .\Debug\ - .\Debug\stdutil.pch - .\Debug\ - .\Debug\ + _CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions) + true EnableFastChecks + true + true + true + false + false + true + Guard + Level3 + $(IntDir)vc$(PlatformToolsetVersion).pdb + true + Speed + true + true + false + StdCall 0x0409 @@ -155,66 +129,7 @@ true - .\Debug\stdutil.lib - - - - - MultiThreaded - AnySuitable - true - true - MaxSpeed - true - Level3 - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - .\stdutil___Win32_Blitz2DRelease\ - .\stdutil___Win32_Blitz2DRelease\stdutil.pch - - .\stdutil___Win32_Blitz2DRelease\ - .\stdutil___Win32_Blitz2DRelease\ - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\stdutil___Win32_Blitz2DRelease\stdutil.bsc - - - true - .\stdutil___Win32_Blitz2DRelease\stdutil.lib - - - - - MultiThreaded - AnySuitable - true - true - MaxSpeed - true - Level3 - _LIB;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions) - .\stdutil___Win32_Blitz3DRelease\ - .\stdutil___Win32_Blitz3DRelease\stdutil.pch - - .\stdutil___Win32_Blitz3DRelease\ - .\stdutil___Win32_Blitz3DRelease\ - StdCall - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - true - .\stdutil___Win32_Blitz3DRelease\stdutil.bsc - - - true - .\stdutil___Win32_Blitz3DRelease\stdutil.lib + MachineX86